scuffle_ffmpeg/enums/
av_picture_type.rs

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