11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
25PROMEKI_NAMESPACE_BEGIN
31class UncompressedVideoPayload;
139 PROMEKI_DATATYPE(PixelFormat, DataTypePixelFormat, 1)
142 Error writeToStream(DataStream &s) const;
144 template <uint32_t V> static Result<PixelFormat> readFromStream(DataStream &s);
146 static constexpr
size_t MaxComps = PixelMemLayout::MaxComps;
166 YUV10_422_Rec709 = 5,
171 JPEG_YUV8_422_Rec709 =
173 JPEG_YUV8_420_Rec709 =
177 YUV8_422_UYVY_Rec709 = 10,
178 YUV10_422_UYVY_LE_Rec709 = 11,
179 YUV10_422_UYVY_BE_Rec709 = 12,
180 YUV12_422_UYVY_LE_Rec709 = 13,
181 YUV12_422_UYVY_BE_Rec709 = 14,
184 YUV10_422_v210_Rec709 = 15,
187 YUV8_422_Planar_Rec709 = 16,
188 YUV10_422_Planar_LE_Rec709 = 17,
189 YUV10_422_Planar_BE_Rec709 = 18,
190 YUV12_422_Planar_LE_Rec709 = 19,
191 YUV12_422_Planar_BE_Rec709 = 20,
194 YUV8_420_Planar_Rec709 = 21,
195 YUV10_420_Planar_LE_Rec709 = 22,
196 YUV10_420_Planar_BE_Rec709 = 23,
197 YUV12_420_Planar_LE_Rec709 = 24,
198 YUV12_420_Planar_BE_Rec709 = 25,
201 YUV8_420_SemiPlanar_Rec709 = 26,
202 YUV10_420_SemiPlanar_LE_Rec709 = 27,
203 YUV10_420_SemiPlanar_BE_Rec709 = 28,
204 YUV12_420_SemiPlanar_LE_Rec709 = 29,
205 YUV12_420_SemiPlanar_BE_Rec709 = 30,
222 YUV10_DPX_Rec709 = 43,
268 RGBAF16_LE_LinearRec709 = 79,
269 RGBAF16_BE_LinearRec709 = 80,
270 RGBF16_LE_LinearRec709 = 81,
271 RGBF16_BE_LinearRec709 = 82,
272 MonoF16_LE_LinearRec709 = 83,
273 MonoF16_BE_LinearRec709 = 84,
274 RGBAF32_LE_LinearRec709 = 85,
275 RGBAF32_BE_LinearRec709 = 86,
276 RGBF32_LE_LinearRec709 = 87,
277 RGBF32_BE_LinearRec709 = 88,
278 MonoF32_LE_LinearRec709 = 89,
279 MonoF32_BE_LinearRec709 = 90,
282 RGB10A2_LE_sRGB = 91,
283 RGB10A2_BE_sRGB = 92,
284 BGR10A2_LE_sRGB = 93,
285 BGR10A2_BE_sRGB = 94,
289 YUV10_LE_Rec709 = 96,
290 YUV10_BE_Rec709 = 97,
291 YUV12_LE_Rec709 = 98,
292 YUV12_BE_Rec709 = 99,
293 YUV16_LE_Rec709 = 100,
294 YUV16_BE_Rec709 = 101,
297 YUV10_422_UYVY_LE_Rec2020 = 102,
298 YUV10_422_UYVY_BE_Rec2020 = 103,
299 YUV12_422_UYVY_LE_Rec2020 = 104,
300 YUV12_422_UYVY_BE_Rec2020 = 105,
301 YUV10_420_Planar_LE_Rec2020 = 106,
302 YUV10_420_Planar_BE_Rec2020 = 107,
303 YUV12_420_Planar_LE_Rec2020 = 108,
304 YUV12_420_Planar_BE_Rec2020 = 109,
322 YUV10_422_UYVY_LE_Rec2020_PQ = 200,
323 YUV10_422_UYVY_LE_Rec2020_HLG = 201,
324 YUV12_422_UYVY_LE_Rec2020_PQ = 202,
325 YUV12_422_UYVY_LE_Rec2020_HLG = 203,
327 YUV10_420_Planar_LE_Rec2020_PQ = 204,
328 YUV10_420_Planar_LE_Rec2020_HLG = 205,
329 YUV12_420_Planar_LE_Rec2020_PQ = 206,
330 YUV12_420_Planar_LE_Rec2020_HLG = 207,
332 YUV10_420_SemiPlanar_LE_Rec2020_PQ = 208,
333 YUV10_420_SemiPlanar_LE_Rec2020_HLG = 209,
335 YUV16_422_SemiPlanar_LE_Rec2020_PQ = 210,
336 YUV16_422_SemiPlanar_LE_Rec2020_HLG = 211,
338 RGB10A2_LE_Rec2020_PQ = 212,
339 RGB10A2_LE_Rec2020_HLG = 213,
341 RGB16_LE_Rec2020_PQ = 214,
342 RGB16_LE_Rec2020_HLG = 215,
344 RGBAF16_LE_LinearRec2020 = 216,
345 RGBF16_LE_LinearRec2020 = 217,
347 RGB16_LE_DCI_P3_PQ = 218,
350 YUV8_422_Rec601 = 110,
351 YUV8_422_UYVY_Rec601 = 111,
352 YUV8_420_Planar_Rec601 = 112,
353 YUV8_420_SemiPlanar_Rec601 = 113,
356 YUV8_420_NV21_Rec709 = 114,
357 YUV10_420_NV21_LE_Rec709 = 115,
358 YUV10_420_NV21_BE_Rec709 = 116,
359 YUV12_420_NV21_LE_Rec709 = 117,
360 YUV12_420_NV21_BE_Rec709 = 118,
363 YUV8_422_SemiPlanar_Rec709 = 119,
364 YUV10_422_SemiPlanar_LE_Rec709 = 120,
365 YUV10_422_SemiPlanar_BE_Rec709 = 121,
366 YUV12_422_SemiPlanar_LE_Rec709 = 122,
367 YUV12_422_SemiPlanar_BE_Rec709 = 123,
370 YUV8_411_Planar_Rec709 = 124,
373 YUV16_422_UYVY_LE_Rec709 = 125,
374 YUV16_422_UYVY_BE_Rec709 = 126,
375 YUV16_422_Planar_LE_Rec709 = 127,
376 YUV16_422_Planar_BE_Rec709 = 128,
377 YUV16_420_Planar_LE_Rec709 = 129,
378 YUV16_420_Planar_BE_Rec709 = 130,
379 YUV16_420_SemiPlanar_LE_Rec709 = 131,
380 YUV16_420_SemiPlanar_BE_Rec709 = 132,
381 YUV16_422_SemiPlanar_LE_Rec709 = 164,
382 YUV16_422_SemiPlanar_BE_Rec709 = 165,
385 RGB10_DPX_LE_sRGB = 133,
386 YUV10_DPX_B_Rec709 = 134,
392 ProRes_422_Proxy = 137,
397 ProRes_4444_XQ = 142,
413 YUV8_422_Rec709_Full = 143,
414 YUV8_422_Rec601_Full = 144,
415 YUV8_420_Planar_Rec709_Full = 145,
416 YUV8_420_Planar_Rec601_Full = 146,
439 JPEG_YUV8_422_Rec601 =
441 JPEG_YUV8_420_Rec601 =
443 JPEG_YUV8_422_Rec709_Full =
445 JPEG_YUV8_420_Rec709_Full =
447 JPEG_YUV8_422_Rec601_Full =
449 JPEG_YUV8_420_Rec601_Full =
463 JPEG_XS_YUV8_422_Rec709 =
465 JPEG_XS_YUV10_422_Rec709 =
467 JPEG_XS_YUV12_422_Rec709 =
469 JPEG_XS_YUV8_420_Rec709 =
471 JPEG_XS_YUV10_420_Rec709 =
473 JPEG_XS_YUV12_420_Rec709 =
475 JPEG_XS_RGB8_sRGB = 159,
478 RGB8_Planar_sRGB = 160,
481 YUV8_444_Planar_Rec709 = 162,
482 YUV10_444_Planar_LE_Rec709 = 163,
488 using IDList = ::promeki::List<ID>;
491 struct CompSemantic {
503 PixelMemLayout memLayout;
504 ColorModel colorModel;
505 bool hasAlpha =
false;
506 int alphaCompIndex = -1;
507 bool compressed =
false;
510 List<ID> encodeSources;
511 List<ID> decodeTargets;
512 FourCC::List fourccList;
513 CompSemantic compSemantics[MaxComps] = {};
523 PaintEngine (*createPaintEngineFunc)(
const Data *d,
524 const UncompressedVideoPayload &payload) =
nullptr;
532 static ID registerType();
539 static void registerData(Data &&data);
548 static IDList registeredIDs();
563 static PixelFormat lookup(
const String &name);
584 static PixelFormat lookup(
const String &name, Error *err);
593 static Result<PixelFormat> fromString(
const String &name) {
595 PixelFormat p = lookup(name, &err);
596 if (err.isError())
return makeError<PixelFormat>(err);
597 return makeResult(p);
604 inline PixelFormat(ID
id = Invalid);
607 bool isValid()
const {
return d !=
nullptr && d->id != Invalid; }
610 ID id()
const {
return d->id; }
613 const String &name()
const {
return d->name; }
616 String toString()
const {
return d->name; }
619 const String &desc()
const {
return d->desc; }
622 const PixelMemLayout &memLayout()
const {
return d->memLayout; }
625 const ColorModel &colorModel()
const {
return d->colorModel; }
644 VideoRange videoRange()
const {
return d->videoRange; }
647 bool hasAlpha()
const {
return d->hasAlpha; }
650 int alphaCompIndex()
const {
return d->alphaCompIndex; }
653 bool isCompressed()
const {
return d->compressed; }
662 const VideoCodec &videoCodec()
const {
return d->videoCodec; }
673 const List<ID> &encodeSources()
const {
return d->encodeSources; }
684 const List<ID> &decodeTargets()
const {
return d->decodeTargets; }
687 const FourCC::List &fourccList()
const {
return d->fourccList; }
690 size_t compCount()
const {
return d->memLayout.compCount(); }
697 const CompSemantic &compSemantic(
size_t index)
const {
return d->compSemantics[index]; }
700 size_t planeCount()
const {
return d->memLayout.planeCount(); }
711 size_t lineStride(
size_t planeIndex,
const ImageDesc &desc)
const;
722 size_t planeSize(
size_t planeIndex,
const ImageDesc &desc)
const;
732 PaintEngine createPaintEngine(
const UncompressedVideoPayload &payload)
const;
748 bool hasPaintEngine()
const {
return d !=
nullptr && d->createPaintEngineFunc !=
nullptr; }
751 bool operator==(
const PixelFormat &o)
const {
return d == o.d; }
754 bool operator!=(
const PixelFormat &o)
const {
return d != o.d; }
757 const Data *data()
const {
return d; }
760 const Data *d =
nullptr;
761 static const Data *lookupData(ID
id);
764inline PixelFormat::PixelFormat(ID
id) : d(lookupData(id)) {}