scuffle_ffmpeg/enums/
av_pixel_format.rs

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