138 {
140
142
143
146 bool present = false;
149 const fl::json videoNode = envelope[kVideo];
151 colorNode = videoNode[kColor];
152
153
154
155 present = !colorNode.
is_null();
156 }
157 }
158
159 if (!present) {
160
161
162 VideoColor resolved;
165 }
166 *out = resolved;
168 }
169
172 }
173
174 const fl::string kPrimaries("primaries");
175 const fl::string kTransfer("transfer");
176 const fl::string kMatrix("matrix");
177 const fl::string kRange("range");
178
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);
183
184
185
186
187 if (!hasTuple && !(hasP && hasT && hasM && hasR)) {
189 }
190
193
198 for (fl::size i = 0; i < 8; ++i) resolved.customPrimaries[i] = 0.0f;
199 }
201
202
203 if (hasP) {
204 const fl::json node = colorNode[kPrimaries];
208 }
217 } else {
219 }
220 }
221
222
223 if (hasT) {
224 const fl::json node = colorNode[kTransfer];
232 case TransferName::Pq:
233 case TransferName::Hlg:
234
236 case TransferName::Unrecognized:
238 }
239 }
240
241
245 }
248 }
249
250
251 if (hasM) {
252 const fl::json node = colorNode[kMatrix];
257
258
261 }
263 }
264
265
266 if (hasR) {
267 const fl::json node = colorNode[kRange];
273 }
else if (
nameIs(*s,
"limited")) {
275 } else {
277 }
278 }
279
280 *out = resolved;
282}
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
bool isReservedMatrixName(const fl::string &s) FL_NO_EXCEPT
bool isDisplayEncodedRgb(fl::u8 pf) 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 defaultVideoColor(fl::u8 pixelFormat, VideoColor *out) FL_NO_EXCEPT
@ MalformedCustomPrimaries
@ TransferConflictsWithFormat
@ LimitedRangeUnsupported
bool pixelFormatHasDefaultTuple(fl::u8 pixelFormat) FL_NO_EXCEPT