scuffle_ffmpeg/enums/av_pixel_format.rs
1use nutype_enum::nutype_enum;
2
3use crate::ffi::*;
4
5nutype_enum! {
6 /// Pixel formats used in FFmpeg's `AVPixelFormat` enumeration.
7 ///
8 /// This enum represents different ways pixels can be stored in memory,
9 /// including packed, planar, and hardware-accelerated formats.
10 ///
11 /// See the official FFmpeg documentation:
12 /// <https://ffmpeg.org/doxygen/trunk/pixfmt_8h.html>
13 pub enum AVPixelFormat(i32) {
14 /// No pixel format specified or unknown format.
15 /// Corresponds to `AV_PIX_FMT_NONE`.
16 None = AV_PIX_FMT_NONE,
17
18 /// Planar YUV 4:2:0 format, 12 bits per pixel.
19 /// Each plane is stored separately, with 1 Cr & Cb sample per 2x2 Y samples.
20 /// Corresponds to `AV_PIX_FMT_YUV420P`.
21 Yuv420p = AV_PIX_FMT_YUV420P,
22
23 /// Packed YUV 4:2:2 format, 16 bits per pixel.
24 /// Stored as Y0 Cb Y1 Cr.
25 /// Corresponds to `AV_PIX_FMT_Yuyv422`.
26 Yuyv422 = AV_PIX_FMT_YUYV422,
27
28 /// Packed RGB format, 8 bits per channel (24bpp).
29 /// Stored as RGBRGB...
30 /// Corresponds to `AV_PIX_FMT_RGB24`.
31 Rgb24 = AV_PIX_FMT_RGB24,
32
33 /// Packed BGR format, 8 bits per channel (24bpp).
34 /// Stored as BGRBGR...
35 /// Corresponds to `AV_PIX_FMT_BGR24`.
36 Bgr24 = AV_PIX_FMT_BGR24,
37
38 /// Planar YUV 4:2:2 format, 16 bits per pixel.
39 /// Each plane is stored separately, with 1 Cr & Cb sample per 2x1 Y samples.
40 /// Corresponds to `AV_PIX_FMT_YUV422P`.
41 Yuv422p = AV_PIX_FMT_YUV422P,
42
43 /// Planar YUV 4:4:4 format, 24 bits per pixel.
44 /// Each plane is stored separately, with 1 Cr & Cb sample per 1x1 Y samples.
45 /// Corresponds to `AV_PIX_FMT_YUV444P`.
46 Yuv444p = AV_PIX_FMT_YUV444P,
47
48 /// 8-bit grayscale format, 8 bits per pixel.
49 /// Corresponds to `AV_PIX_FMT_GRAY8`.
50 Gray8 = AV_PIX_FMT_GRAY8,
51
52 /// 1-bit monochrome format, 0 is white, 1 is black.
53 /// Pixels are stored in bytes, ordered from the most significant bit.
54 /// Corresponds to `AV_PIX_FMT_MonoWhite`.
55 MonoWhite = AV_PIX_FMT_MONOWHITE,
56
57 /// 1-bit monochrome format, 0 is black, 1 is white.
58 /// Pixels are stored in bytes, ordered from the most significant bit.
59 /// Corresponds to `AV_PIX_FMT_MonoBlack`.
60 MonoBlack = AV_PIX_FMT_MONOBLACK,
61
62 /// Packed RGB 5:6:5 format, 16 bits per pixel.
63 /// Corresponds to: `AV_PIX_FMT_RGB565BE`
64 Rgb565Be = AV_PIX_FMT_RGB565BE,
65
66 /// Packed RGB 5:6:5 format, 16 bits per pixel.
67 /// Corresponds to: `AV_PIX_FMT_RGB565LE`
68 Rgb565Le = AV_PIX_FMT_RGB565LE,
69
70 /// Packed RGB 5:5:5 format, 16 bits per pixel.
71 /// Corresponds to: `AV_PIX_FMT_RGB555BE`
72 Rgb555Be = AV_PIX_FMT_RGB555BE,
73
74 /// Packed RGB 5:5:5 format, 16 bits per pixel.
75 /// Corresponds to: `AV_PIX_FMT_RGB555LE`
76 Rgb555Le = AV_PIX_FMT_RGB555LE,
77
78 /// Packed BGR 5:6:5 format, 16 bits per pixel.
79 /// Corresponds to: `AV_PIX_FMT_BGR565BE`
80 Bgr565Be = AV_PIX_FMT_BGR565BE,
81
82 /// Packed BGR 5:6:5 format, 16 bits per pixel.
83 /// Corresponds to: `AV_PIX_FMT_BGR565LE`
84 Bgr565Le = AV_PIX_FMT_BGR565LE,
85
86 /// Packed BGR 5:5:5 format, 16 bits per pixel.
87 /// Corresponds to: `AV_PIX_FMT_BGR555BE`
88 Bgr555Be = AV_PIX_FMT_BGR555BE,
89
90 /// Packed BGR 5:5:5 format, 16 bits per pixel.
91 /// Corresponds to: `AV_PIX_FMT_BGR555LE`
92 Bgr555Le = AV_PIX_FMT_BGR555LE,
93
94 /// Planar YUV 4:2:0 format, 16 bits per pixel.
95 /// Corresponds to: `AV_PIX_FMT_YUV420P16BE`
96 Yuv420p16Be = AV_PIX_FMT_YUV420P16BE,
97
98 /// Planar YUV 4:2:0 format, 16 bits per pixel.
99 /// Corresponds to: `AV_PIX_FMT_YUV420P16LE`
100 Yuv420p16Le = AV_PIX_FMT_YUV420P16LE,
101
102 /// Planar YUV 4:2:2 format, 16 bits per pixel.
103 /// Corresponds to: `AV_PIX_FMT_YUV422P16BE`
104 Yuv422p16Be = AV_PIX_FMT_YUV422P16BE,
105
106 /// Planar YUV 4:2:2 format, 16 bits per pixel.
107 /// Corresponds to: `AV_PIX_FMT_YUV422P16LE`
108 Yuv422p16Le = AV_PIX_FMT_YUV422P16LE,
109
110 /// Planar YUV 4:4:4 format, 16 bits per pixel.
111 /// Corresponds to: `AV_PIX_FMT_YUV444P16BE`
112 Yuv444p16Be = AV_PIX_FMT_YUV444P16BE,
113
114 /// Planar YUV 4:4:4 format, 16 bits per pixel.
115 /// Corresponds to: `AV_PIX_FMT_YUV444P16LE`
116 Yuv444p16Le = AV_PIX_FMT_YUV444P16LE,
117
118 /// Packed RGB 16:16:16 format, 48 bits per pixel.
119 /// Corresponds to: `AV_PIX_FMT_RGB48BE`
120 Rgb48Be = AV_PIX_FMT_RGB48BE,
121
122 /// Packed RGB 16:16:16 format, 48 bits per pixel.
123 /// Corresponds to: `AV_PIX_FMT_RGB48LE`
124 Rgb48Le = AV_PIX_FMT_RGB48LE,
125
126 /// Packed RGBA 16:16:16:16 format, 64 bits per pixel.
127 /// Corresponds to: `AV_PIX_FMT_RGBA64BE`
128 Rgba64Be = AV_PIX_FMT_RGBA64BE,
129
130 /// Packed RGBA 16:16:16:16 format, 64 bits per pixel.
131 /// Corresponds to: `AV_PIX_FMT_RGBA64LE`
132 Rgba64Le = AV_PIX_FMT_RGBA64LE,
133
134 /// Packed BGRA 16:16:16:16 format, 64 bits per pixel.
135 /// Corresponds to: `AV_PIX_FMT_BGRA64BE`
136 Bgra64Be = AV_PIX_FMT_BGRA64BE,
137
138 /// Packed BGRA 16:16:16:16 format, 64 bits per pixel.
139 /// Corresponds to: `AV_PIX_FMT_BGRA64LE`
140 Bgra64Le = AV_PIX_FMT_BGRA64LE,
141
142 /// Hardware-accelerated format through VA-API.
143 /// Corresponds to `AV_PIX_FMT_VAAPI`.
144 Vaapi = AV_PIX_FMT_VAAPI,
145
146 /// Planar GBR format, 4:4:4 subsampling.
147 /// Corresponds to `AV_PIX_FMT_GBRP`.
148 Gbrp = AV_PIX_FMT_GBRP,
149
150 /// Format count, not an actual pixel format.
151 /// Used internally by FFmpeg.
152 /// Corresponds to `AV_PIX_FMT_NB`.
153 Nb = AV_PIX_FMT_NB,
154 }
155}
156
157impl PartialEq<i32> for AVPixelFormat {
158 fn eq(&self, other: &i32) -> bool {
159 self.0 == *other
160 }
161}
162
163impl From<u32> for AVPixelFormat {
164 fn from(value: u32) -> Self {
165 AVPixelFormat(value as i32)
166 }
167}
168
169impl From<AVPixelFormat> for u32 {
170 fn from(value: AVPixelFormat) -> Self {
171 value.0 as u32
172 }
173}