scuffle_ffmpeg/enums/av_picture_type.rs
1use nutype_enum::nutype_enum;
2
3use crate::ffi::*;
4
5const _: () = {
6 assert!(std::mem::size_of::<AVPictureType>() == std::mem::size_of_val(&AV_PICTURE_TYPE_NONE));
7};
8
9nutype_enum! {
10 /// Picture types used in FFmpeg's `AVPictureType`.
11 ///
12 /// Picture types define the role of a frame within a video compression scheme.
13 ///
14 /// See the official FFmpeg documentation:
15 /// <https://ffmpeg.org/doxygen/trunk/avutil_8h.html>
16 pub enum AVPictureType(i32) {
17 /// Undefined or unknown picture type.
18 /// - **Used for**: Uninitialized or unspecified frames.
19 /// - **Equivalent to**: `AV_PICTURE_TYPE_NONE`
20 None = AV_PICTURE_TYPE_NONE as _,
21
22 /// **Intra-frame (I-frame)**: A self-contained frame that does not reference others.
23 /// - **Used for**: Keyframes in compressed video.
24 /// - **Efficient for**: Random access (seeking).
25 /// - **Equivalent to**: `AV_PICTURE_TYPE_I`
26 Intra = AV_PICTURE_TYPE_I as _,
27
28 /// **Predicted frame (P-frame)**: Encodes differences relative to previous frames.
29 /// - **Used for**: Intermediate frames in video compression.
30 /// - **Smaller than I-frames but requires previous frames for decoding.**
31 /// - **Equivalent to**: `AV_PICTURE_TYPE_P`
32 Predicted = AV_PICTURE_TYPE_P as _,
33
34 /// **Bi-directional predicted frame (B-frame)**: Uses both past and future frames for prediction.
35 /// - **Used for**: High compression efficiency in video encoding.
36 /// - **Requires both previous and future frames for decoding.**
37 /// - **Equivalent to**: `AV_PICTURE_TYPE_B`
38 BiPredicted = AV_PICTURE_TYPE_B as _,
39
40 /// **Sprite (S-GMC) VOP** in MPEG-4.
41 /// - **Used for**: Global motion compensation (GMC) in older MPEG-4 video.
42 /// - **Equivalent to**: `AV_PICTURE_TYPE_S`
43 SpriteGmc = AV_PICTURE_TYPE_S as _,
44
45 /// **Switching Intra-frame (SI-frame)**: A special type of I-frame.
46 /// - **Used for**: Scalable video coding, ensuring smooth transitions.
47 /// - **Equivalent to**: `AV_PICTURE_TYPE_SI`
48 SwitchingIntra = AV_PICTURE_TYPE_SI as _,
49
50 /// **Switching Predicted frame (SP-frame)**: A special type of P-frame.
51 /// - **Used for**: Scalable video coding, allowing switching between streams.
52 /// - **Equivalent to**: `AV_PICTURE_TYPE_SP`
53 SwitchingPredicted = AV_PICTURE_TYPE_SP as _,
54
55 /// **BI type frame**: Similar to a B-frame but has additional constraints.
56 /// - **Used for**: Certain video codecs with different motion compensation.
57 /// - **Equivalent to**: `AV_PICTURE_TYPE_BI`
58 BiType = AV_PICTURE_TYPE_BI as _,
59 }
60}
61
62impl PartialEq<i32> for AVPictureType {
63 fn eq(&self, other: &i32) -> bool {
64 self.0 == *other
65 }
66}
67
68impl From<u32> for AVPictureType {
69 fn from(value: u32) -> Self {
70 AVPictureType(value as _)
71 }
72}
73
74impl From<AVPictureType> for u32 {
75 fn from(value: AVPictureType) -> Self {
76 value.0 as u32
77 }
78}