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