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