flowly_core/
fourcc.rs

1#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
2#[repr(C)]
3pub struct Fourcc([u8; 4]);
4
5impl Fourcc {
6    ///
7    /// Audio Codecs
8    ///
9    /// Dolby AC-3    
10    pub const AUDIO_AC3: Fourcc = Fourcc(*b"ac-3");
11
12    /// Dolby Digital Plus (E-AC-3)
13    pub const AUDIO_EC3: Fourcc = Fourcc(*b"ec-3");
14
15    /// Opus Audio Codec
16    pub const AUDIO_OPUS: Fourcc = Fourcc(*b"Opus");
17
18    /// Mp3 Audio Codec
19    pub const AUDIO_MP3: Fourcc = Fourcc(*b".mp3");
20
21    /// FLAC (Free Lossless Audio Codec)
22    pub const AUDIO_FLAC: Fourcc = Fourcc(*b"fLaC");
23
24    /// ACC (Advanced Audio Coding)
25    pub const AUDIO_AAC: Fourcc = Fourcc(*b"mp4a");
26
27    /// PCM codec series
28    pub const AUDIO_PCM: Fourcc = Fourcc(*b"PCM ");
29    pub const AUDIO_PCM_ALAW: Fourcc = Fourcc(*b"ALAW");
30    pub const AUDIO_PCM_ULAW: Fourcc = Fourcc(*b"ULAW");
31
32    ///
33    /// Video Codecs
34    ///
35    /// VP8 Video Codec
36    pub const VIDEO_VP8: Fourcc = Fourcc(*b"vp08");
37
38    /// VP9 Video Codec
39    pub const VIDEO_VP9: Fourcc = Fourcc(*b"vp09");
40
41    /// AV1 Video Codec
42    pub const VIDEO_AV1: Fourcc = Fourcc(*b"av01");
43
44    /// AVC (H264) Video Codec
45    pub const VIDEO_AVC: Fourcc = Fourcc(*b"avc1");
46
47    /// HEVC (H265) Video Codec
48    pub const VIDEO_HEVC: Fourcc = Fourcc(*b"hvc1");
49
50    /// MJPEG Codec
51    pub const VIDEO_MJPEG: Fourcc = Fourcc(*b"MJPG");
52
53    /// JPEG Codec
54    pub const VIDEO_JPEG: Fourcc = Fourcc(*b"JPEG");
55
56    /// Pixel formats
57    ///
58    /// | C1 C2 C3 C4 C5 C6 C7 C8 |
59    pub const PIXEL_FORMAT_C1: Fourcc = Fourcc(*b"C1  ");
60
61    /// | C1 C1 C2 C2 C3 C3 C4 C4 |
62    pub const PIXEL_FORMAT_C2: Fourcc = Fourcc(*b"C2  ");
63
64    /// | C1 C1 C1 C1 C2 C2 C2 C2 |
65    pub const PIXEL_FORMAT_C4: Fourcc = Fourcc(*b"C4  ");
66
67    /// | C C C C C C C C |
68    pub const PIXEL_FORMAT_C8: Fourcc = Fourcc(*b"C8  ");
69
70    ///
71    /// Darkness (inverse relationship between channel value and brightness)
72    ///
73    /// | D1 D2 D3 D4 D5 D6 D7 D8 |
74    pub const PIXEL_FORMAT_D1: Fourcc = Fourcc(*b"D1  ");
75
76    /// | D1 D1 D2 D2 D3 D3 D4 D4 |
77    pub const PIXEL_FORMAT_D2: Fourcc = Fourcc(*b"D2  ");
78
79    /// | C1 C1 C1 C1 C2 C2 C2 C2 |
80    pub const PIXEL_FORMAT_D4: Fourcc = Fourcc(*b"D4  ");
81
82    /// | D D D D D D D D |
83    pub const PIXEL_FORMAT_D8: Fourcc = Fourcc(*b"D8  ");
84
85    ///
86    /// Red (direct relationship between channel value and brightness)
87    ///
88    /// | R1 R2 R3 R4 R5 R6 R7 R8 |
89    pub const PIXEL_FORMAT_R1: Fourcc = Fourcc(*b"R1  ");
90
91    /// | R1 R1 R2 R2 R3 R3 R4 R4 |
92    pub const PIXEL_FORMAT_R2: Fourcc = Fourcc(*b"R2  ");
93
94    /// | R1 R1 R1 R1 R2 R2 R2 R2 |
95    pub const PIXEL_FORMAT_R4: Fourcc = Fourcc(*b"R4  ");
96
97    /// | R R R R R R R R |
98    pub const PIXEL_FORMAT_R8: Fourcc = Fourcc(*b"R8  ");
99
100    /// 10 bpp Red (direct relationship between channel value and brightness)
101    pub const PIXEL_FORMAT_R10: Fourcc = Fourcc(*b"R10 "); // [15:0] x:R 6:10 little endian 
102
103    /// 12 bpp Red (direct relationship between channel value and brightness)
104    pub const PIXEL_FORMAT_R12: Fourcc = Fourcc(*b"R12 "); // [15:0] x:R 4:12 little endian 
105
106    /// 16 bpp Red (direct relationship between channel value and brightness)
107    pub const PIXEL_FORMAT_R16: Fourcc = Fourcc(*b"R16 "); // [15:0] R little endian 
108
109    /// 16 bpp RG
110    pub const PIXEL_FORMAT_RG88: Fourcc = Fourcc(*b"RG88"); // [15:0] R:G 8:8 little endian 
111    pub const PIXEL_FORMAT_GR88: Fourcc = Fourcc(*b"GR88"); // [15:0] G:R 8:8 little endian 
112
113    /// 32 bpp RG
114    pub const PIXEL_FORMAT_RG1616: Fourcc = Fourcc(*b"RG32"); // [31:0] R:G 16:16 little endian 
115    pub const PIXEL_FORMAT_GR1616: Fourcc = Fourcc(*b"GR32"); // [31:0] G:R 16:16 little endian 
116
117    ///
118    /// 8 bpp RGB
119    ///
120    /// | R R R G G G B B |
121    pub const PIXEL_FORMAT_RGB332: Fourcc = Fourcc(*b"RGB8");
122
123    /// | B B G G G R R R |
124    pub const PIXEL_FORMAT_BGR233: Fourcc = Fourcc(*b"BGR8");
125
126    /// 16 bpp RGB
127    pub const PIXEL_FORMAT_XRGB4444: Fourcc = Fourcc(*b"XR12"); // [15:0] x:R:G:B 4:4:4:4 little endian 
128    pub const PIXEL_FORMAT_XBGR4444: Fourcc = Fourcc(*b"XB12"); // [15:0] x:B:G:R 4:4:4:4 little endian 
129    pub const PIXEL_FORMAT_RGBX4444: Fourcc = Fourcc(*b"RX12"); // [15:0] R:G:B:x 4:4:4:4 little endian 
130    pub const PIXEL_FORMAT_BGRX4444: Fourcc = Fourcc(*b"BX12"); // [15:0] B:G:R:x 4:4:4:4 little endian 
131
132    pub const PIXEL_FORMAT_ARGB4444: Fourcc = Fourcc(*b"AR12"); // [15:0] A:R:G:B 4:4:4:4 little endian 
133    pub const PIXEL_FORMAT_ABGR4444: Fourcc = Fourcc(*b"AB12"); // [15:0] A:B:G:R 4:4:4:4 little endian 
134    pub const PIXEL_FORMAT_RGBA4444: Fourcc = Fourcc(*b"RA12"); // [15:0] R:G:B:A 4:4:4:4 little endian 
135    pub const PIXEL_FORMAT_BGRA4444: Fourcc = Fourcc(*b"BA12"); // [15:0] B:G:R:A 4:4:4:4 little endian 
136
137    pub const PIXEL_FORMAT_XRGB1555: Fourcc = Fourcc(*b"XR15"); // [15:0] x:R:G:B 1:5:5:5 little endian 
138    pub const PIXEL_FORMAT_XBGR1555: Fourcc = Fourcc(*b"XB15"); // [15:0] x:B:G:R 1:5:5:5 little endian 
139    pub const PIXEL_FORMAT_RGBX5551: Fourcc = Fourcc(*b"RX15"); // [15:0] R:G:B:x 5:5:5:1 little endian 
140    pub const PIXEL_FORMAT_BGRX5551: Fourcc = Fourcc(*b"BX15"); // [15:0] B:G:R:x 5:5:5:1 little endian 
141
142    pub const PIXEL_FORMAT_ARGB1555: Fourcc = Fourcc(*b"AR15"); // [15:0] A:R:G:B 1:5:5:5 little endian 
143    pub const PIXEL_FORMAT_ABGR1555: Fourcc = Fourcc(*b"AB15"); // [15:0] A:B:G:R 1:5:5:5 little endian 
144    pub const PIXEL_FORMAT_RGBA5551: Fourcc = Fourcc(*b"RA15"); // [15:0] R:G:B:A 5:5:5:1 little endian 
145    pub const PIXEL_FORMAT_BGRA5551: Fourcc = Fourcc(*b"BA15"); // [15:0] B:G:R:A 5:5:5:1 little endian 
146
147    pub const PIXEL_FORMAT_RGB565: Fourcc = Fourcc(*b"RG16"); // [15:0] R:G:B 5:6:5 little endian 
148    pub const PIXEL_FORMAT_BGR565: Fourcc = Fourcc(*b"BG16"); // [15:0] B:G:R 5:6:5 little endian 
149
150    // 24 bpp RGB
151    pub const PIXEL_FORMAT_RGB888: Fourcc = Fourcc(*b"RG24"); // [23:0] R:G:B little endian 
152    pub const PIXEL_FORMAT_BGR888: Fourcc = Fourcc(*b"BG24"); // [23:0] B:G:R little endian 
153
154    // 32 bpp RGB
155    pub const PIXEL_FORMAT_XRGB8888: Fourcc = Fourcc(*b"XR24"); // [31:0] x:R:G:B 8:8:8:8 little endian 
156    pub const PIXEL_FORMAT_XBGR8888: Fourcc = Fourcc(*b"XB24"); // [31:0] x:B:G:R 8:8:8:8 little endian 
157    pub const PIXEL_FORMAT_RGBX8888: Fourcc = Fourcc(*b"RX24"); // [31:0] R:G:B:x 8:8:8:8 little endian 
158    pub const PIXEL_FORMAT_BGRX8888: Fourcc = Fourcc(*b"BX24"); // [31:0] B:G:R:x 8:8:8:8 little endian 
159
160    pub const PIXEL_FORMAT_ARGB8888: Fourcc = Fourcc(*b"AR24"); // [31:0] A:R:G:B 8:8:8:8 little endian 
161    pub const PIXEL_FORMAT_ABGR8888: Fourcc = Fourcc(*b"AB24"); // [31:0] A:B:G:R 8:8:8:8 little endian 
162    pub const PIXEL_FORMAT_RGBA8888: Fourcc = Fourcc(*b"RA24"); // [31:0] R:G:B:A 8:8:8:8 little endian 
163    pub const PIXEL_FORMAT_BGRA8888: Fourcc = Fourcc(*b"BA24"); // [31:0] B:G:R:A 8:8:8:8 little endian 
164
165    pub const PIXEL_FORMAT_XRGB2101010: Fourcc = Fourcc(*b"XR30"); // [31:0] x:R:G:B 2:10:10:10 little endian 
166    pub const PIXEL_FORMAT_XBGR2101010: Fourcc = Fourcc(*b"XB30"); // [31:0] x:B:G:R 2:10:10:10 little endian 
167    pub const PIXEL_FORMAT_RGBX1010102: Fourcc = Fourcc(*b"RX30"); // [31:0] R:G:B:x 10:10:10:2 little endian 
168    pub const PIXEL_FORMAT_BGRX1010102: Fourcc = Fourcc(*b"BX30"); // [31:0] B:G:R:x 10:10:10:2 little endian 
169
170    pub const PIXEL_FORMAT_ARGB2101010: Fourcc = Fourcc(*b"AR30"); // [31:0] A:R:G:B 2:10:10:10 little endian 
171    pub const PIXEL_FORMAT_ABGR2101010: Fourcc = Fourcc(*b"AB30"); // [31:0] A:B:G:R 2:10:10:10 little endian 
172    pub const PIXEL_FORMAT_RGBA1010102: Fourcc = Fourcc(*b"RA30"); // [31:0] R:G:B:A 10:10:10:2 little endian 
173    pub const PIXEL_FORMAT_BGRA1010102: Fourcc = Fourcc(*b"BA30"); // [31:0] B:G:R:A 10:10:10:2 little endian 
174
175    // 64 bpp RGB
176    pub const PIXEL_FORMAT_XRGB16161616: Fourcc = Fourcc(*b"XR48"); // [63:0] x:R:G:B 16:16:16:16 little endian 
177    pub const PIXEL_FORMAT_XBGR16161616: Fourcc = Fourcc(*b"XB48"); // [63:0] x:B:G:R 16:16:16:16 little endian 
178
179    pub const PIXEL_FORMAT_ARGB16161616: Fourcc = Fourcc(*b"AR48"); // [63:0] A:R:G:B 16:16:16:16 little endian 
180    pub const PIXEL_FORMAT_ABGR16161616: Fourcc = Fourcc(*b"AB48"); // [63:0] A:B:G:R 16:16:16:16 little endian 
181
182    ///
183    /// Floating point 64bpp RGB
184    /// IEEE 754-2008 binary16 half-precision float
185    /// [15:0] sign:exponent:mantissa 1:5:10
186    ///
187    pub const PIXEL_FORMAT_XRGB16161616F: Fourcc = Fourcc(*b"XR4H"); // [63:0] x:R:G:B 16:16:16:16 little endian 
188    pub const PIXEL_FORMAT_XBGR16161616F: Fourcc = Fourcc(*b"XB4H"); // [63:0] x:B:G:R 16:16:16:16 little endian 
189
190    pub const PIXEL_FORMAT_ARGB16161616F: Fourcc = Fourcc(*b"AR4H"); // [63:0] A:R:G:B 16:16:16:16 little endian 
191    pub const PIXEL_FORMAT_ABGR16161616F: Fourcc = Fourcc(*b"AB4H"); // [63:0] A:B:G:R 16:16:16:16 little endian 
192
193    ///
194    /// RGBA format with 10-bit components packed in 64-bit per pixel, with 6 bits
195    /// of unused padding per component:
196    ///
197    pub const PIXEL_FORMAT_AXBXGXRX106106106106: Fourcc = Fourcc(*b"AB10"); // [63:0] A:x:B:x:G:x:R:x 10:6:10:6:10:6:10:6 little endian 
198
199    // packed YCbCr
200    pub const PIXEL_FORMAT_YUYV: Fourcc = Fourcc(*b"YUYV"); // [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian 
201    pub const PIXEL_FORMAT_YVYU: Fourcc = Fourcc(*b"YVYU"); // [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian 
202    pub const PIXEL_FORMAT_UYVY: Fourcc = Fourcc(*b"UYVY"); // [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian 
203    pub const PIXEL_FORMAT_VYUY: Fourcc = Fourcc(*b"VYUY"); // [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian 
204
205    pub const PIXEL_FORMAT_AYUV: Fourcc = Fourcc(*b"AYUV"); // [31:0] A:Y:Cb:Cr 8:8:8:8 little endian 
206    pub const PIXEL_FORMAT_AVUY8888: Fourcc = Fourcc(*b"AVUY"); // [31:0] A:Cr:Cb:Y 8:8:8:8 little endian 
207    pub const PIXEL_FORMAT_XYUV8888: Fourcc = Fourcc(*b"XYUV"); // [31:0] X:Y:Cb:Cr 8:8:8:8 little endian 
208    pub const PIXEL_FORMAT_XVUY8888: Fourcc = Fourcc(*b"XVUY"); // [31:0] X:Cr:Cb:Y 8:8:8:8 little endian 
209    pub const PIXEL_FORMAT_VUY888: Fourcc = Fourcc(*b"VU24"); // [23:0] Cr:Cb:Y 8:8:8 little endian 
210    pub const PIXEL_FORMAT_VUY101010: Fourcc = Fourcc(*b"VU30"); // Y followed by U then V, 10:10:10. Non-linear modifier only 
211
212    /*
213     * packed Y2xx indicate for each component, xx valid data occupy msb
214     * 16-xx padding occupy lsb
215     */
216    pub const PIXEL_FORMAT_Y210: Fourcc = Fourcc(*b"Y210"); // [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 10:6:10:6:10:6:10:6 little endian per 2 Y pixels 
217    pub const PIXEL_FORMAT_Y212: Fourcc = Fourcc(*b"Y212"); // [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 12:4:12:4:12:4:12:4 little endian per 2 Y pixels 
218    pub const PIXEL_FORMAT_Y216: Fourcc = Fourcc(*b"Y216"); // [63:0] Cr0:Y1:Cb0:Y0 16:16:16:16 little endian per 2 Y pixels 
219
220    /*
221     * packed Y4xx indicate for each component, xx valid data occupy msb
222     * 16-xx padding occupy lsb except Y410
223     */
224    pub const PIXEL_FORMAT_Y410: Fourcc = Fourcc(*b"Y410"); // [31:0] A:Cr:Y:Cb 2:10:10:10 little endian 
225    pub const PIXEL_FORMAT_Y412: Fourcc = Fourcc(*b"Y412"); // [63:0] A:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian 
226    pub const PIXEL_FORMAT_Y416: Fourcc = Fourcc(*b"Y416"); // [63:0] A:Cr:Y:Cb 16:16:16:16 little endian 
227
228    pub const PIXEL_FORMAT_XVYU2101010: Fourcc = Fourcc(*b"XV30"); // [31:0] X:Cr:Y:Cb 2:10:10:10 little endian 
229    pub const PIXEL_FORMAT_XVYU12_16161616: Fourcc = Fourcc(*b"XV36"); // [63:0] X:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian 
230    pub const PIXEL_FORMAT_XVYU16161616: Fourcc = Fourcc(*b"XV48"); // [63:0] X:Cr:Y:Cb 16:16:16:16 little endian 
231
232    ///
233    /// 1-plane YUV 4:2:0
234    /// In these formats, the component ordering is specified (Y, followed by U
235    /// then V), but the exact Linear layout is undefined.
236    /// These formats can only be used with a non-Linear modifier.
237    ///
238    pub const PIXEL_FORMAT_YUV420_8BIT: Fourcc = Fourcc(*b"YU08");
239    pub const PIXEL_FORMAT_YUV420_10BIT: Fourcc = Fourcc(*b"YU10");
240
241    ///
242    /// 2 plane RGB + A
243    /// index 0 = RGB plane, same format as the corresponding non _A8 format has
244    /// index 1 = A plane, [7:0] A
245    ///
246    pub const PIXEL_FORMAT_XRGB8888_A8: Fourcc = Fourcc(*b"XRA8");
247    pub const PIXEL_FORMAT_XBGR8888_A8: Fourcc = Fourcc(*b"XBA8");
248    pub const PIXEL_FORMAT_RGBX8888_A8: Fourcc = Fourcc(*b"RXA8");
249    pub const PIXEL_FORMAT_BGRX8888_A8: Fourcc = Fourcc(*b"BXA8");
250    pub const PIXEL_FORMAT_RGB888_A8: Fourcc = Fourcc(*b"R8A8");
251    pub const PIXEL_FORMAT_BGR888_A8: Fourcc = Fourcc(*b"B8A8");
252    pub const PIXEL_FORMAT_RGB565_A8: Fourcc = Fourcc(*b"R5A8");
253    pub const PIXEL_FORMAT_BGR565_A8: Fourcc = Fourcc(*b"B5A8");
254
255    ///
256    /// 2 plane YCbCr
257    /// index 0 = Y plane, [7:0] Y
258    /// index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian
259    /// or
260    /// index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian
261    ///
262    pub const PIXEL_FORMAT_NV12: Fourcc = Fourcc(*b"NV12"); // 2x2 subsampled Cr:Cb plane 
263    pub const PIXEL_FORMAT_NV21: Fourcc = Fourcc(*b"NV21"); // 2x2 subsampled Cb:Cr plane 
264    pub const PIXEL_FORMAT_NV16: Fourcc = Fourcc(*b"NV16"); // 2x1 subsampled Cr:Cb plane 
265    pub const PIXEL_FORMAT_NV61: Fourcc = Fourcc(*b"NV61"); // 2x1 subsampled Cb:Cr plane 
266    pub const PIXEL_FORMAT_NV24: Fourcc = Fourcc(*b"NV24"); // non-subsampled Cr:Cb plane 
267    pub const PIXEL_FORMAT_NV42: Fourcc = Fourcc(*b"NV42"); // non-subsampled Cb:Cr plane 
268    ///
269    /// 2 plane YCbCr
270    /// index 0 = Y plane, [39:0] Y3:Y2:Y1:Y0 little endian
271    /// index 1 = Cr:Cb plane, [39:0] Cr1:Cb1:Cr0:Cb0 little endian
272    ///
273    pub const PIXEL_FORMAT_NV15: Fourcc = Fourcc(*b"NV15"); // 2x2 subsampled Cr:Cb plane 
274    pub const PIXEL_FORMAT_NV20: Fourcc = Fourcc(*b"NV20"); // 2x1 subsampled Cr:Cb plane 
275    pub const PIXEL_FORMAT_NV30: Fourcc = Fourcc(*b"NV30"); // non-subsampled Cr:Cb plane 
276
277    ///
278    /// 2 plane YCbCr MSB aligned
279    /// index 0 = Y plane, [15:0] Y:x [10:6] little endian
280    /// index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian
281    ///
282    pub const PIXEL_FORMAT_P210: Fourcc = Fourcc(*b"P210"); // 2x1 subsampled Cr:Cb plane, 10 bit per channel 
283
284    ///
285    /// 2 plane YCbCr MSB aligned
286    /// index 0 = Y plane, [15:0] Y:x [10:6] little endian
287    /// index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [10:6:10:6] little endian
288    ///
289    pub const PIXEL_FORMAT_P010: Fourcc = Fourcc(*b"P010"); // 2x2 subsampled Cr:Cb plane 10 bits per channel 
290
291    ///
292    /// 2 plane YCbCr MSB aligned
293    /// index 0 = Y plane, [15:0] Y:x [12:4] little endian
294    /// index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [12:4:12:4] little endian
295    ///
296    pub const PIXEL_FORMAT_P012: Fourcc = Fourcc(*b"P012"); // 2x2 subsampled Cr:Cb plane 12 bits per channel 
297
298    ///
299    /// 2 plane YCbCr MSB aligned
300    /// index 0 = Y plane, [15:0] Y little endian
301    /// index 1 = Cr:Cb plane, [31:0] Cr:Cb [16:16] little endian
302    ///
303    pub const PIXEL_FORMAT_P016: Fourcc = Fourcc(*b"P016"); // 2x2 subsampled Cr:Cb plane 16 bits per channel 
304
305    ///
306    /// 2 plane YCbCr42
307    /// 3 10 bit components and 2 padding bits packed into 4 bytes.
308    /// index 0 = Y plane, [31:0] x:Y2:Y1:Y0 2:10:10:10 little endian
309    /// index 1 = Cr:Cb plane, [63:0] x:Cr2:Cb2:Cr1:x:Cb1:Cr0:Cb0 [2:10:10:10:2:10:10:10] little endian
310    ///
311    pub const PIXEL_FORMAT_P030: Fourcc = Fourcc(*b"P030"); // 2x2 subsampled Cr:Cb plane 10 bits per channel packed 
312
313    ///
314    /// 3 plane non-subsampled (444) YCb
315    /// 16 bits per component, but only 10 bits are used and 6 bits are padded
316    /// index 0: Y plane, [15:0] Y:x [10:6] little endian
317    /// index 1: Cb plane, [15:0] Cb:x [10:6] little endian
318    /// index 2: Cr plane, [15:0] Cr:x [10:6] little endian
319    ///
320    pub const PIXEL_FORMAT_Q410: Fourcc = Fourcc(*b"Q410");
321
322    ///
323    /// 3 plane non-subsampled (444) YCr
324    /// 16 bits per component, but only 10 bits are used and 6 bits are padded
325    /// index 0: Y plane, [15:0] Y:x [10:6] little endian
326    /// index 1: Cr plane, [15:0] Cr:x [10:6] little endian
327    /// index 2: Cb plane, [15:0] Cb:x [10:6] little endian
328    ///
329    pub const PIXEL_FORMAT_Q401: Fourcc = Fourcc(*b"Q401");
330
331    ///
332    /// 3 plane YCbCr
333    /// index 0: Y plane, [7:0] Y
334    /// index 1: Cb plane, [7:0] Cb
335    /// index 2: Cr plane, [7:0] Cr
336    /// or
337    /// index 1: Cr plane, [7:0] Cr
338    /// index 2: Cb plane, [7:0] Cb
339    ///
340    pub const PIXEL_FORMAT_YUV410: Fourcc = Fourcc::from_static("YUV9"); // 4x4 subsampled Cb (1) and Cr (2) planes 
341    pub const PIXEL_FORMAT_YVU410: Fourcc = Fourcc::from_static("YVU9"); // 4x4 subsampled Cr (1) and Cb (2) planes 
342    pub const PIXEL_FORMAT_YUV411: Fourcc = Fourcc::from_static("YU11"); // 4x1 subsampled Cb (1) and Cr (2) planes 
343    pub const PIXEL_FORMAT_YVU411: Fourcc = Fourcc::from_static("YV11"); // 4x1 subsampled Cr (1) and Cb (2) planes 
344    pub const PIXEL_FORMAT_YUV420: Fourcc = Fourcc::from_static("YU12"); // 2x2 subsampled Cb (1) and Cr (2) planes 
345    pub const PIXEL_FORMAT_YVU420: Fourcc = Fourcc::from_static("YV12"); // 2x2 subsampled Cr (1) and Cb (2) planes 
346    pub const PIXEL_FORMAT_YUV422: Fourcc = Fourcc::from_static("YU16"); // 2x1 subsampled Cb (1) and Cr (2) planes 
347    pub const PIXEL_FORMAT_YVU422: Fourcc = Fourcc::from_static("YV16"); // 2x1 subsampled Cr (1) and Cb (2) planes 
348    pub const PIXEL_FORMAT_YUV444: Fourcc = Fourcc::from_static("YU24"); // non-subsampled Cb (1) and Cr (2) planes 
349    pub const PIXEL_FORMAT_YVU444: Fourcc = Fourcc::from_static("YV24"); // non-subsampled Cr (1) and Cb (2) planes 
350
351    pub const fn from_static(s: &str) -> Self {
352        assert!(s.len() == 4);
353
354        let bs = s.as_bytes();
355        Self([bs[3], bs[2], bs[1], bs[0]])
356    }
357}
358
359impl From<&str> for Fourcc {
360    fn from(s: &str) -> Self {
361        Self::from_static(s)
362    }
363}
364
365impl From<u32> for Fourcc {
366    fn from(fourcc: u32) -> Self {
367        Self(fourcc.to_be_bytes())
368    }
369}
370
371impl From<Fourcc> for u32 {
372    fn from(fourcc: Fourcc) -> Self {
373        u32::from_be_bytes(fourcc.0)
374    }
375}
376
377impl From<&[u8; 4]> for Fourcc {
378    fn from(n: &[u8; 4]) -> Self {
379        Self(*n)
380    }
381}
382
383impl From<Fourcc> for [u8; 4] {
384    fn from(n: Fourcc) -> Self {
385        n.0
386    }
387}
388
389impl From<[u8; 4]> for Fourcc {
390    fn from(n: [u8; 4]) -> Self {
391        Self(n)
392    }
393}
394
395impl std::fmt::Display for Fourcc {
396    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
397        let c: [u8; 4] = (*self).into();
398
399        f.write_fmt(format_args!(
400            "{}{}{}{}",
401            c[0] as char, c[1] as char, c[2] as char, c[3] as char
402        ))
403    }
404}
405
406impl std::fmt::Debug for Fourcc {
407    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
408        let c: [u8; 4] = (*self).into();
409
410        f.write_fmt(format_args!(
411            "Fourcc(['{}', '{}', '{}', '{}'])",
412            c[0] as char, c[1] as char, c[2] as char, c[3] as char
413        ))
414    }
415}