39 static const char*
const kReserved[] = {
40 "bt709",
"bt601",
"bt470bg",
"smpte170m",
"bt2020ncl",
"bt2020cl",
41 "ycbcr",
"ycgco",
"fcc",
43 for (fl::size i = 0; i <
sizeof(kReserved) /
sizeof(kReserved[0]); ++i) {
44 if (
nameIs(s, kReserved[i]))
return true;
66 if (v != v)
return false;
67 return v > -1e30f && v < 1e30f;
88 if (!node.is_array())
return false;
92 if (node.size() != 2)
return false;
93 auto x = node[
static_cast<fl::size
>(0)].as_float();
94 auto y = node[
static_cast<fl::size
>(1)].as_float();
95 if (!
x || !
y)
return false;
96 const float fx =
static_cast<float>(*x);
97 const float fy =
static_cast<float>(*y);
99 if (fy <= 0.0f)
return false;
107 static const char*
const kKeys[4] = {
"red",
"green",
"blue",
"white"};
108 for (fl::size i = 0; i < 4; ++i) {
110 if (!node.contains(key))
return false;
111 if (!
readXy(node[key], &out8[i * 2], &out8[i * 2 + 1]))
return false;
119 return isDisplayEncodedRgb(pixelFormat) || isLinearRgb(pixelFormat);
123 if (!out)
return false;
130 out->declared =
false;
131 for (fl::size i = 0; i < 8; ++i) {
132 out->customPrimaries[i] = 0.0f;
146 bool present =
false;
148 if (envelope.is_object() && envelope.contains(kVideo)) {
149 const fl::json videoNode = envelope[kVideo];
151 colorNode = videoNode[kColor];
155 present = !colorNode.
is_null();
179 const bool hasP = colorNode.
contains(kPrimaries);
180 const bool hasT = colorNode.
contains(kTransfer);
181 const bool hasM = colorNode.
contains(kMatrix);
182 const bool hasR = colorNode.
contains(kRange);
187 if (!hasTuple && !(hasP && hasT && hasM && hasR)) {
204 const fl::json node = colorNode[kPrimaries];
224 const fl::json node = colorNode[kTransfer];
228 switch (parseTransferName(*s)) {
232 case TransferName::Pq:
233 case TransferName::Hlg:
236 case TransferName::Unrecognized:
242 if (isDisplayEncodedRgb(pixelFormat) &&
252 const fl::json node = colorNode[kMatrix];
256 if (!nameIs(*s,
"rgb")) {
267 const fl::json node = colorNode[kRange];
271 if (nameIs(*s,
"full")) {
273 }
else if (nameIs(*s,
"limited")) {
313 switch (storage.mFormat) {
338 return "resolveVideoColor called with a null out-pointer";
340 return "video.color is absent and this pixel_format defines no default color tuple";
342 return "video.color must be a JSON object";
344 return "video.color.primaries is not a recognized name or custom xy object";
346 return "video.color.transfer is not a recognized transfer function";
348 return "video.color.matrix is not a recognized value";
350 return "video.color.range is not a recognized value";
352 return "video.color.transfer conflicts with the header pixel_format";
354 return "video.color.range \"limited\" is reserved and unsupported in v1";
356 return "video.color.matrix values other than \"rgb\" are reserved in v1";
358 return "this pixel_format defines no default tuple: video.color must declare all four keys or be absent";
360 return "video.color.primaries object needs red/green/blue/white CIE xy pairs";
362 return "unknown color status";
366 if (out ==
nullptr) {
370 switch (
color.primaries) {
389 switch (
color.transfer) {
bool is_object() const FL_NO_EXCEPT
fl::optional< fl::string > as_string() const FL_NO_EXCEPT
bool is_null() const FL_NO_EXCEPT
bool contains(size_t idx) const FL_NO_EXCEPT
bool is_string() const FL_NO_EXCEPT
FastLED's Elegant JSON Library: fl::json
bool isReservedMatrixName(const fl::string &s) FL_NO_EXCEPT
bool isDisplayEncodedRgb(fl::u8 pf) FL_NO_EXCEPT
bool isOrdinaryNumber(float v) FL_NO_EXCEPT
bool readCustomPrimaries(const fl::json &node, float *out8) FL_NO_EXCEPT
bool isLinearRgb(fl::u8 pf) FL_NO_EXCEPT
TransferName parseTransferName(const fl::string &s) FL_NO_EXCEPT
bool nameIs(const fl::string &s, const char *lit) FL_NO_EXCEPT
bool readXy(const fl::json &node, float *outX, float *outY) FL_NO_EXCEPT
bool toFledPixelFormat(const PixelStorage &storage, const VideoColor &color, PixelFormat *out) FL_NO_EXCEPT
bool defaultVideoColor(fl::u8 pixelFormat, VideoColor *out) FL_NO_EXCEPT
ColorStatus resolveVideoColor(const fl::json &envelope, fl::u8 pixelFormat, VideoColor *out) FL_NO_EXCEPT
bool toSourceProfile(const VideoColor &color, SourceProfile *out) FL_NO_EXCEPT
@ MalformedCustomPrimaries
@ TransferConflictsWithFormat
@ LimitedRangeUnsupported
bool pixelFormatHasDefaultTuple(fl::u8 pixelFormat) FL_NO_EXCEPT
const char * colorStatusMessage(ColorStatus status) FL_NO_EXCEPT
constexpr int type_rank< T >::value
int strcmp(const char *s1, const char *s2) FL_NO_EXCEPT
InputGamut g FL_NO_EXCEPT
Base definition for an LED controller.
CIE 1931 xy chromaticity, independent of encoded storage and chipset.
static constexpr SourceProfile srgbBt709() FL_NO_EXCEPT
static constexpr SourceProfile bt2020() FL_NO_EXCEPT
static constexpr SourceProfile displayP3() FL_NO_EXCEPT
A source declaration, not a container or an output-device selection.