#pragma once // Packed YUV layouts: // VUY888 — 1 pixel / 24-bit, 8-bit Y/U/V (storage uint32_t, // bytes_per_pixel = 3; parallels BGR888 in the YUV // register order) // XVUY8888 — 1 pixel / 32-bit word, 8-bit Y/U/V + 8-bit padding // XVUY2101010 — 1 pixel / 32-bit word, 10-bit Y/U/V + 2-bit padding // AVUY16161616 — 1 pixel / 64-bit word, 16-bit Y/U/V/A (normalized) // YUYV / YVYU / UYVY / VYUY — 4:2:2, 2 pixels / 32-bit word // Y210 / Y212 / Y216 — 4:2:2, 2 pixels / 64-bit word, with // each component MSB-aligned in a 16-bit slot // // XVUY/AVUY name is register MSB-first (X/A in the top bits). The // YUYV names follow V4L2 / pixpat memory-byte order (Y0 in byte 0), // so shifts ascend in name order — opposite of XRGB-style. #include "../layout.h" #include "../io/packed.h" #include "../io/packed_yuv.h" namespace pixpat::formats { // 1-pixel-per-word packed (single Pixel/Word; uses PackedSource/Sink). struct VUY888 : Layout > { using Source = PackedSource; using Sink = PackedSink; }; struct XVUY8888 : Layout > { using Source = PackedSource; using Sink = PackedSink; }; struct XVUY2101010 : Layout > { using Source = PackedSource; using Sink = PackedSink; }; struct AVUY16161616 : Layout > { using Source = PackedSource; using Sink = PackedSink; }; // 2-pixel-per-word 4:2:2 (uses PackedYUVSource/Sink). #define PIXPAT_PACKED_YUV422(name, ...) \ struct name : Layout > { \ using Source = PackedYUVSource; \ using Sink = PackedYUVSink; \ } PIXPAT_PACKED_YUV422(YUYV, Comp{ C::Y, 8, 0 }, Comp{ C::U, 8, 8 }, Comp{ C::Y, 8, 16 }, Comp{ C::V, 8, 24 }); PIXPAT_PACKED_YUV422(YVYU, Comp{ C::Y, 8, 0 }, Comp{ C::V, 8, 8 }, Comp{ C::Y, 8, 16 }, Comp{ C::U, 8, 24 }); PIXPAT_PACKED_YUV422(UYVY, Comp{ C::U, 8, 0 }, Comp{ C::Y, 8, 8 }, Comp{ C::V, 8, 16 }, Comp{ C::Y, 8, 24 }); PIXPAT_PACKED_YUV422(VYUY, Comp{ C::V, 8, 0 }, Comp{ C::Y, 8, 8 }, Comp{ C::U, 8, 16 }, Comp{ C::Y, 8, 24 }); #undef PIXPAT_PACKED_YUV422 // Y210 / Y212 / Y216: 4:2:2, 2 pixels per 64-bit word, MSB-aligned in // 16-bit slots. Y210 has 6 unused LSBs per slot, Y212 has 4, Y216 has // none. The X padding entries pad total_bits to 64 so bytes_per_pixel // resolves to 8; PackedYUVSink leaves their slots zero via the // value-array zero-init (see io/packed_yuv.h). struct Y210 : Layout > { using Source = PackedYUVSource; using Sink = PackedYUVSink; }; struct Y212 : Layout > { using Source = PackedYUVSource; using Sink = PackedYUVSink; }; struct Y216 : Layout > { using Source = PackedYUVSource; using Sink = PackedYUVSink; }; } // namespace pixpat::formats