nihed-cros-libva: introduce more enums instead of constants
[nihav-player.git] / nihed-cros-libva / src / formats.rs
CommitLineData
0f2fb233
KS
1//! Provides Rust wrappers for common enumerations used throughout the library.
2
3use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign};
4
5use crate::bindings;
6
7/// Colourspace parameters.
8#[repr(u32)]
9#[derive(Clone, Copy, Debug, PartialEq)]
10pub enum RTFormat {
11 /// YUV 4:2:0 8-bit.
12 YUV420 = bindings::constants::VA_RT_FORMAT_YUV420,
13 /// YUV 4:2:2 8-bit.
14 YUV422 = bindings::constants::VA_RT_FORMAT_YUV422,
15 /// YUV 4:4:4 8-bit.
16 YUV444 = bindings::constants::VA_RT_FORMAT_YUV444,
17 /// YUV 4:1:1 8-bit.
18 YUV411 = bindings::constants::VA_RT_FORMAT_YUV411,
19 /// Greyscale 8-bit.
20 YUV400 = bindings::constants::VA_RT_FORMAT_YUV400,
21 /// YUV 4:2:0 10-bit.
22 YUV420_10 = bindings::constants::VA_RT_FORMAT_YUV420_10,
23 /// YUV 4:2:2 10-bit.
24 YUV422_10 = bindings::constants::VA_RT_FORMAT_YUV422_10,
25 /// YUV 4:4:4 10-bit.
26 YUV444_10 = bindings::constants::VA_RT_FORMAT_YUV444_10,
27 /// YUV 4:2:0 12-bit.
28 YUV420_12 = bindings::constants::VA_RT_FORMAT_YUV420_12,
29 /// YUV 4:2:2 12-bit.
30 YUV422_12 = bindings::constants::VA_RT_FORMAT_YUV422_12,
31 /// YUV 4:4:4 12-bit.
32 YUV444_12 = bindings::constants::VA_RT_FORMAT_YUV444_12,
33 /// Packed RGB, 16 bits per pixel.
34 RGB16 = bindings::constants::VA_RT_FORMAT_RGB16,
35 /// Packed RGB, 32 bits per pixel, 8 bits per colour sample.
36 RGB32 = bindings::constants::VA_RT_FORMAT_RGB32,
37 /// Planar RGB, 8 bits per sample.
38 RGBP = bindings::constants::VA_RT_FORMAT_RGBP,
39 /// Packed RGB, 32 bits per pixel, 10 bits per colour sample.
40 RGB32_10 = bindings::constants::VA_RT_FORMAT_RGB32_10,
41 /// Protected or unknown format.
42 Protected = bindings::constants::VA_RT_FORMAT_PROTECTED
43}
44
45impl From<RTFormat> for u32 {
46 fn from(val: RTFormat) -> u32 {
47 val as u32
48 }
49}
50
51impl From<u32> for RTFormat {
52 fn from(val: u32) -> RTFormat {
53 match val {
54 bindings::constants::VA_RT_FORMAT_YUV420 => RTFormat::YUV420,
55 bindings::constants::VA_RT_FORMAT_YUV422 => RTFormat::YUV422,
56 bindings::constants::VA_RT_FORMAT_YUV444 => RTFormat::YUV444,
57 bindings::constants::VA_RT_FORMAT_YUV411 => RTFormat::YUV411,
58 bindings::constants::VA_RT_FORMAT_YUV400 => RTFormat::YUV400,
59 bindings::constants::VA_RT_FORMAT_YUV420_10 => RTFormat::YUV420_10,
60 bindings::constants::VA_RT_FORMAT_YUV422_10 => RTFormat::YUV422_10,
61 bindings::constants::VA_RT_FORMAT_YUV444_10 => RTFormat::YUV444_10,
62 bindings::constants::VA_RT_FORMAT_YUV420_12 => RTFormat::YUV420_12,
63 bindings::constants::VA_RT_FORMAT_YUV422_12 => RTFormat::YUV422_12,
64 bindings::constants::VA_RT_FORMAT_YUV444_12 => RTFormat::YUV444_12,
65 bindings::constants::VA_RT_FORMAT_RGB16 => RTFormat::RGB16,
66 bindings::constants::VA_RT_FORMAT_RGB32 => RTFormat::RGB32,
67 bindings::constants::VA_RT_FORMAT_RGBP => RTFormat::RGBP,
68 bindings::constants::VA_RT_FORMAT_RGB32_10 => RTFormat::RGB32_10,
69 bindings::constants::VA_RT_FORMAT_PROTECTED => RTFormat::Protected,
70 _ => RTFormat::Protected,
71 }
72 }
73}
74
75impl std::fmt::Display for RTFormat {
76 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
77 write!(f, "{:?}", self)
78 }
79}
80
81/// Recognized FOURCCs.
82#[repr(u32)]
83#[derive(Clone, Copy, Debug, PartialEq)]
84#[allow(non_camel_case_types)]
85pub enum VAFourcc {
86 /// NV12: two-plane 8-bit YUV 4:2:0.
87 /// The first plane contains Y, the second plane contains U and V in pairs of bytes.
88 NV12 = bindings::constants::VA_FOURCC_NV12,
89 /// NV21: two-plane 8-bit YUV 4:2:0.
90 /// Same as NV12, but with U and V swapped.
91 NV21 = bindings::constants::VA_FOURCC_NV21,
92 /// AI44: packed 4-bit YA.
93 ///
94 /// The bottom half of each byte contains luma, the top half contains alpha.
95 A144 = bindings::constants::VA_FOURCC_AI44,
96 /// RGBA: packed 8-bit RGBA.
97 ///
98 // Four bytes per pixel: red, green, blue, alpha.
99 RGBA = bindings::constants::VA_FOURCC_RGBA,
100 /// RGBX: packed 8-bit RGB.
101 ///
102 /// Four bytes per pixel: red, green, blue, unspecified.
103 RGBX = bindings::constants::VA_FOURCC_RGBX,
104 /// BGRA: packed 8-bit RGBA.
105 ///
106 /// Four bytes per pixel: blue, green, red, alpha.
107 BGRA = bindings::constants::VA_FOURCC_BGRA,
108 /// BGRX: packed 8-bit RGB.
109 ///
110 /// Four bytes per pixel: blue, green, red, unspecified.
111 BGRX = bindings::constants::VA_FOURCC_BGRX,
112 /// ARGB: packed 8-bit RGBA.
113 ///
114 /// Four bytes per pixel: alpha, red, green, blue.
115 ARGB = bindings::constants::VA_FOURCC_ARGB,
116 /// XRGB: packed 8-bit RGB.
117 ///
118 /// Four bytes per pixel: unspecified, red, green, blue.
119 XRGB = bindings::constants::VA_FOURCC_XRGB,
120 /// ABGR: packed 8-bit RGBA.
121 ///
122 /// Four bytes per pixel: alpha, blue, green, red.
123 ABGR = bindings::constants::VA_FOURCC_ABGR,
124 /// XBGR: packed 8-bit RGB.
125 ///
126 /// Four bytes per pixel: unspecified, blue, green, red.
127 XBGR = bindings::constants::VA_FOURCC_XBGR,
128 /// UYUV: packed 8-bit YUV 4:2:2.
129 ///
130 /// Four bytes per pair of pixels: U, Y, U, V.
131 UYVY = bindings::constants::VA_FOURCC_UYVY,
132 /// YUY2: packed 8-bit YUV 4:2:2.
133 ///
134 /// Four bytes per pair of pixels: Y, U, Y, V.
135 YUY2 = bindings::constants::VA_FOURCC_YUY2,
136 /// AYUV: packed 8-bit YUVA 4:4:4.
137 ///
138 /// Four bytes per pixel: A, Y, U, V.
139 AYUV = bindings::constants::VA_FOURCC_AYUV,
140 /// NV11: two-plane 8-bit YUV 4:1:1.
141 ///
142 /// The first plane contains Y, the second plane contains U and V in pairs of bytes.
143 NV11 = bindings::constants::VA_FOURCC_NV11,
144 /// YV12: three-plane 8-bit YUV 4:2:0.
145 ///
146 /// The three planes contain Y, V and U respectively.
147 YV12 = bindings::constants::VA_FOURCC_YV12,
148 /// P208: two-plane 8-bit YUV 4:2:2.
149 ///
150 /// The first plane contains Y, the second plane contains U and V in pairs of bytes.
151 P208 = bindings::constants::VA_FOURCC_P208,
152 /// I420: three-plane 8-bit YUV 4:2:0.
153 ///
154 /// The three planes contain Y, U and V respectively.
155 I420 = bindings::constants::VA_FOURCC_I420,
156 /// YV24: three-plane 8-bit YUV 4:4:4.
157 ///
158 /// The three planes contain Y, V and U respectively.
159 YV24 = bindings::constants::VA_FOURCC_YV24,
160 /// YV32: four-plane 8-bit YUVA 4:4:4
161 ///
162 /// The four planes contain Y, V, U and A respectively.
163 YV32 = bindings::constants::VA_FOURCC_YV32,
164 /// Y800: 8-bit greyscale.
165 Y800 = bindings::constants::VA_FOURCC_Y800,
166 /// IMC3: three-plane 8-bit YUV 4:2:0.
167 ///
168 /// Equivalent to YV12, but with the additional constraint that the pitch of all three planes
169 /// must be the same.
170 IMC3 = bindings::constants::VA_FOURCC_IMC3,
171 /// 411P: three-plane 8-bit YUV 4:1:1.
172 ///
173 /// The three planes contain Y, U and V respectively.
174 YUV_411P = bindings::constants::VA_FOURCC_411P,
175 /// 411R: three-plane 8-bit YUV.
176 ///
177 /// The subsampling is the transpose of 4:1:1 - full chroma appears on every fourth line.
178 /// The three planes contain Y, U and V respectively.
179 YUV_411R = bindings::constants::VA_FOURCC_411R,
180 /// 422H: three-plane 8-bit YUV 4:2:2.
181 ///
182 /// The three planes contain Y, U and V respectively.
183 YUV_422H = bindings::constants::VA_FOURCC_422H,
184 /// 422V: three-plane 8-bit YUV 4:4:0.
185 ///
186 /// The three planes contain Y, U and V respectively.
187 YUV_422V = bindings::constants::VA_FOURCC_422V,
188 /// 444P: three-plane 8-bit YUV 4:4:4.
189 ///
190 /// The three planes contain Y, U and V respectively.
191 YUV_444P = bindings::constants::VA_FOURCC_444P,
192 /// RGBP: three-plane 8-bit RGB.
193 ///
194 /// The three planes contain red, green and blue respectively.
195 RGBP = bindings::constants::VA_FOURCC_RGBP,
196 /// BGRP: three-plane 8-bit RGB.
197 ///
198 /// The three planes contain blue, green and red respectively.
199 BGRP = bindings::constants::VA_FOURCC_BGRP,
200 /// RG16: packed 5/6-bit RGB.
201 ///
202 /// Each pixel is a two-byte little-endian value.
203 /// Red, green and blue are found in bits 15:11, 10:5, 4:0 respectively.
204 RGB565 = bindings::constants::VA_FOURCC_RGB565,
205 /// BG16: packed 5/6-bit RGB.
206 ///
207 /// Each pixel is a two-byte little-endian value.
208 /// Blue, green and red are found in bits 15:11, 10:5, 4:0 respectively.
209 BGR565 = bindings::constants::VA_FOURCC_BGR565,
210 /// Y210: packed 10-bit YUV 4:2:2.
211 ///
212 /// Eight bytes represent a pair of pixels. Each sample is a two-byte little-endian value,
213 /// with the bottom six bits ignored. The samples are in the order Y, U, Y, V.
214 Y210 = bindings::constants::VA_FOURCC_Y210,
215 /// Y212: packed 12-bit YUV 4:2:2.
216 ///
217 /// Eight bytes represent a pair of pixels. Each sample is a two-byte little-endian value,
218 /// with the bottom six bits ignored. The samples are in the order Y, U, Y, V.
219 Y212 = bindings::constants::VA_FOURCC_Y212,
220 /// Y216: packed 16-bit YUV 4:2:2.
221 ///
222 /// Eight bytes represent a pair of pixels. Each sample is a two-byte little-endian value.
223 /// The samples are in the order Y, U, Y, V.
224 Y216 = bindings::constants::VA_FOURCC_Y216,
225 /// Y410: packed 10-bit YUVA 4:4:4.
226 ///
227 /// Each pixel is a six-byte little-endian value.
228 /// A, V, Y, U are found in bits 31:30, 29:20, 19:10, 9:0 respectively.
229 Y410 = bindings::constants::VA_FOURCC_Y410,
230 /// Y412: packed 12-bit YUVA 4:4:4.
231 ///
232 /// Each pixel is a set of four samples, each of which is a two-byte little-endian value.
233 /// The samples are in the order A, V, Y, U.
234 Y412 = bindings::constants::VA_FOURCC_Y412,
235 /// Y416: packed 16-bit YUVA 4:4:4.
236 ///
237 /// Each pixel is a set of four samples, each of which is a two-byte little-endian value.
238 /// The samples are in the order A, V, Y, U.
239 Y416 = bindings::constants::VA_FOURCC_Y416,
240 /// YV16: three-plane 8-bit YUV 4:2:2.
241 ///
242 /// The three planes contain Y, V and U respectively.
243 YV16 = bindings::constants::VA_FOURCC_YV16,
244 /// P010: two-plane 10-bit YUV 4:2:0.
245 ///
246 /// Each sample is a two-byte little-endian value with the bottom six bits ignored.
247 /// The first plane contains Y, the second plane contains U and V in pairs of samples.
248 P010 = bindings::constants::VA_FOURCC_P010,
249 /// P012: two-plane 12-bit YUV 4:2:0.
250 ///
251 /// Each sample is a two-byte little-endian value. The first plane contains Y, the second
252 /// plane contains U and V in pairs of samples.
253 P012 = bindings::constants::VA_FOURCC_P012,
254 /// P016: two-plane 16-bit YUV 4:2:0.
255 ///
256 /// Each sample is a two-byte little-endian value. The first plane contains Y, the second
257 /// plane contains U and V in pairs of samples.
258 P016 = bindings::constants::VA_FOURCC_P016,
259 /// I010: three-plane 10-bit YUV 4:2:0.
260 ///
261 /// Each sample is a two-byte little-endian value with the top six bits ignored.
262 /// The three planes contain Y, V and U respectively.
263 I010 = bindings::constants::VA_FOURCC_I010,
264 /// IYUV: three-plane 8-bit YUV 4:2:0.
265 ///
266 /// @deprecated Use I420 instead.
267 IYUV = bindings::constants::VA_FOURCC_IYUV,
268 /// 10-bit Pixel RGB formats.
269 A2R10G10B10 = bindings::constants::VA_FOURCC_A2R10G10B10,
270 /// 10-bit Pixel BGR formats.
271 A2B10G10R10 = bindings::constants::VA_FOURCC_A2B10G10R10,
272 /// 10-bit Pixel RGB formats without alpha.
273 X2R10G10B10 = bindings::constants::VA_FOURCC_X2R10G10B10,
274 /// 10-bit Pixel BGR formats without alpha.
275 X2B10G10R10 = bindings::constants::VA_FOURCC_X2B10G10R10,
276 /// Y8: 8-bit greyscale.
277 ///
278 /// Only a single sample, 8 bit Y plane for monochrome images
279 Y8 = bindings::constants::VA_FOURCC_Y8,
280 /// Y16: 16-bit greyscale.
281 ///
282 /// Only a single sample, 16 bit Y plane for monochrome images
283 Y16 = bindings::constants::VA_FOURCC_Y16,
284 /// VYUV: packed 8-bit YUV 4:2:2.
285 ///
286 /// Four bytes per pair of pixels: V, Y, U, V.
287 VYUY = bindings::constants::VA_FOURCC_VYUY,
288 /// YVYU: packed 8-bit YUV 4:2:2.
289 ///
290 /// Four bytes per pair of pixels: Y, V, Y, U.
291 YVYU = bindings::constants::VA_FOURCC_YVYU,
292 /// AGRB64: three-plane 16-bit ARGB 16:16:16:16
293 ///
294 /// The four planes contain: alpha, red, green, blue respectively.
295 ARGB64 = bindings::constants::VA_FOURCC_ARGB64,
296 /// ABGR64: three-plane 16-bit ABGR 16:16:16:16
297 ///
298 /// The four planes contain: alpha, blue, green, red respectively.
299 ABGR64 = bindings::constants::VA_FOURCC_ABGR64,
300 /// XYUV: packed 8-bit YUVX 4:4:4.
301 ///
302 /// Four bytes per pixel: X, Y, U, V.
303 XYUV = bindings::constants::VA_FOURCC_XYUV,
304}
305
306impl From<VAFourcc> for u32 {
307 fn from(val: VAFourcc) -> u32 {
308 val as u32
309 }
310}
311
312impl TryFrom<u32> for VAFourcc {
313 type Error = ();
314 fn try_from(val: u32) -> Result<Self, Self::Error> {
315 match val {
316 bindings::constants::VA_FOURCC_NV12 => Ok(VAFourcc::NV12),
317 bindings::constants::VA_FOURCC_NV21 => Ok(VAFourcc::NV21),
318 bindings::constants::VA_FOURCC_AI44 => Ok(VAFourcc::A144),
319 bindings::constants::VA_FOURCC_RGBA => Ok(VAFourcc::RGBA),
320 bindings::constants::VA_FOURCC_RGBX => Ok(VAFourcc::RGBX),
321 bindings::constants::VA_FOURCC_BGRA => Ok(VAFourcc::BGRA),
322 bindings::constants::VA_FOURCC_BGRX => Ok(VAFourcc::BGRX),
323 bindings::constants::VA_FOURCC_ARGB => Ok(VAFourcc::ARGB),
324 bindings::constants::VA_FOURCC_XRGB => Ok(VAFourcc::XRGB),
325 bindings::constants::VA_FOURCC_ABGR => Ok(VAFourcc::ABGR),
326 bindings::constants::VA_FOURCC_XBGR => Ok(VAFourcc::XBGR),
327 bindings::constants::VA_FOURCC_UYVY => Ok(VAFourcc::UYVY),
328 bindings::constants::VA_FOURCC_YUY2 => Ok(VAFourcc::YUY2),
329 bindings::constants::VA_FOURCC_AYUV => Ok(VAFourcc::AYUV),
330 bindings::constants::VA_FOURCC_NV11 => Ok(VAFourcc::NV11),
331 bindings::constants::VA_FOURCC_YV12 => Ok(VAFourcc::YV12),
332 bindings::constants::VA_FOURCC_P208 => Ok(VAFourcc::P208),
333 bindings::constants::VA_FOURCC_I420 => Ok(VAFourcc::I420),
334 bindings::constants::VA_FOURCC_YV24 => Ok(VAFourcc::YV24),
335 bindings::constants::VA_FOURCC_YV32 => Ok(VAFourcc::YV32),
336 bindings::constants::VA_FOURCC_Y800 => Ok(VAFourcc::Y800),
337 bindings::constants::VA_FOURCC_IMC3 => Ok(VAFourcc::IMC3),
338 bindings::constants::VA_FOURCC_411P => Ok(VAFourcc::YUV_411P),
339 bindings::constants::VA_FOURCC_411R => Ok(VAFourcc::YUV_411R),
340 bindings::constants::VA_FOURCC_422H => Ok(VAFourcc::YUV_422H),
341 bindings::constants::VA_FOURCC_422V => Ok(VAFourcc::YUV_422V),
342 bindings::constants::VA_FOURCC_444P => Ok(VAFourcc::YUV_444P),
343 bindings::constants::VA_FOURCC_RGBP => Ok(VAFourcc::RGBP),
344 bindings::constants::VA_FOURCC_BGRP => Ok(VAFourcc::BGRP),
345 bindings::constants::VA_FOURCC_RGB565 => Ok(VAFourcc::RGB565),
346 bindings::constants::VA_FOURCC_BGR565 => Ok(VAFourcc::BGR565),
347 bindings::constants::VA_FOURCC_Y210 => Ok(VAFourcc::Y210),
348 bindings::constants::VA_FOURCC_Y212 => Ok(VAFourcc::Y212),
349 bindings::constants::VA_FOURCC_Y216 => Ok(VAFourcc::Y216),
350 bindings::constants::VA_FOURCC_Y410 => Ok(VAFourcc::Y410),
351 bindings::constants::VA_FOURCC_Y412 => Ok(VAFourcc::Y412),
352 bindings::constants::VA_FOURCC_Y416 => Ok(VAFourcc::Y416),
353 bindings::constants::VA_FOURCC_YV16 => Ok(VAFourcc::YV16),
354 bindings::constants::VA_FOURCC_P010 => Ok(VAFourcc::P010),
355 bindings::constants::VA_FOURCC_P012 => Ok(VAFourcc::P012),
356 bindings::constants::VA_FOURCC_P016 => Ok(VAFourcc::P016),
357 bindings::constants::VA_FOURCC_I010 => Ok(VAFourcc::I010),
358 bindings::constants::VA_FOURCC_IYUV => Ok(VAFourcc::IYUV),
359 bindings::constants::VA_FOURCC_A2R10G10B10 => Ok(VAFourcc::A2R10G10B10),
360 bindings::constants::VA_FOURCC_A2B10G10R10 => Ok(VAFourcc::A2B10G10R10),
361 bindings::constants::VA_FOURCC_X2R10G10B10 => Ok(VAFourcc::X2R10G10B10),
362 bindings::constants::VA_FOURCC_X2B10G10R10 => Ok(VAFourcc::X2B10G10R10),
363 bindings::constants::VA_FOURCC_Y8 => Ok(VAFourcc::Y8),
364 bindings::constants::VA_FOURCC_Y16 => Ok(VAFourcc::Y16),
365 bindings::constants::VA_FOURCC_VYUY => Ok(VAFourcc::VYUY),
366 bindings::constants::VA_FOURCC_YVYU => Ok(VAFourcc::YVYU),
367 bindings::constants::VA_FOURCC_ARGB64 => Ok(VAFourcc::ARGB64),
368 bindings::constants::VA_FOURCC_ABGR64 => Ok(VAFourcc::ABGR64),
369 bindings::constants::VA_FOURCC_XYUV => Ok(VAFourcc::XYUV),
370 _ => Err(()),
371 }
372 }
373}
374
375/// H.264 picture flags structure.
376#[derive(Default, Clone, Copy, Debug, PartialEq)]
377pub struct H264PictureFlags(u32);
378
379impl H264PictureFlags {
380 /// Returns picture flags value as 32-bit integer.
381 pub fn bits(self) -> u32 {
382 self.0
383 }
384}
385
386impl From<H264PictureFlags> for u32 {
387 fn from(val: H264PictureFlags) -> u32 {
388 val.bits()
389 }
390}
391
392impl BitOr<H264PictureFlag> for H264PictureFlags {
393 type Output = Self;
394
395 fn bitor(self, rhs: H264PictureFlag) -> Self {
396 Self(self.0 | rhs.bits())
397 }
398}
399
400impl BitOrAssign<H264PictureFlag> for H264PictureFlags {
401 fn bitor_assign(&mut self, rhs: H264PictureFlag) {
402 self.0 |= rhs.bits();
403 }
404}
405
406impl BitXor<H264PictureFlag> for H264PictureFlags {
407 type Output = Self;
408
409 fn bitxor(self, rhs: H264PictureFlag) -> Self {
410 Self(self.0 ^ rhs.bits())
411 }
412}
413
414impl BitXorAssign<H264PictureFlag> for H264PictureFlags {
415 fn bitxor_assign(&mut self, rhs: H264PictureFlag) {
416 self.0 ^= rhs.bits();
417 }
418}
419
420impl BitAnd<H264PictureFlag> for H264PictureFlags {
421 type Output = Self;
422
423 fn bitand(self, rhs: H264PictureFlag) -> Self {
424 Self(self.0 & rhs.bits())
425 }
426}
427
428impl BitAndAssign<H264PictureFlag> for H264PictureFlags {
429 fn bitand_assign(&mut self, rhs: H264PictureFlag) {
430 self.0 &= rhs.bits();
431 }
432}
433
434/// H.264 picture property flags.
435#[repr(u32)]
436#[derive(Clone, Copy, Debug, PartialEq)]
437pub enum H264PictureFlag {
438 /// Picture is invalid.
439 Invalid = bindings::constants::VA_PICTURE_H264_INVALID,
440 /// Top field present.
441 TopField = bindings::constants::VA_PICTURE_H264_TOP_FIELD,
442 /// Bottom field present.
443 BottomField = bindings::constants::VA_PICTURE_H264_BOTTOM_FIELD,
444 /// Picture is used as a short-term reference.
445 ShortTermReference = bindings::constants::VA_PICTURE_H264_SHORT_TERM_REFERENCE,
446 /// Picture is used as a short-term reference.
447 LongTermReference = bindings::constants::VA_PICTURE_H264_LONG_TERM_REFERENCE,
448}
449
450impl From<H264PictureFlag> for H264PictureFlags {
451 fn from(val: H264PictureFlag) -> Self {
452 Self(val.bits())
453 }
454}
455
456impl From<H264PictureFlag> for u32 {
457 fn from(val: H264PictureFlag) -> u32 {
458 val.bits()
459 }
460}
461
462impl H264PictureFlag {
463 pub(crate) fn bits(self) -> u32 {
464 self as u32
465 }
466}
467
468/// Slice data contents type.
469///
470/// There will be cases where the bitstream buffer will not have enough room to hold
471/// the data for the entire slice, and the following flags will be used in the slice
472/// parameter to signal to the server for the possible cases.
473/// If a slice parameter buffer and slice data buffer pair is sent to the server with
474/// the slice data partially in the slice data buffer (BEGIN and MIDDLE cases below),
475/// then a slice parameter and data buffer needs to be sent again to complete this slice.
476#[repr(u32)]
477#[derive(Clone, Copy, Debug, PartialEq)]
478pub enum VASliceDataFlag {
479 /// Whole slice is in the buffer.
480 All = bindings::constants::VA_SLICE_DATA_FLAG_ALL,
481 /// The beginning of the slice is in the buffer but the end if not.
482 Begin = bindings::constants::VA_SLICE_DATA_FLAG_BEGIN,
483 /// Neither beginning nor end of the slice is in the buffer.
484 Middle = bindings::constants::VA_SLICE_DATA_FLAG_MIDDLE,
485 /// End of the slice is in the buffer.
486 End = bindings::constants::VA_SLICE_DATA_FLAG_END,
487}