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