Skip to main content

ffmpeg_next/util/
picture.rs

1use crate::ffi::AVPictureType::*;
2use crate::ffi::*;
3
4#[derive(Eq, PartialEq, Clone, Copy, Debug)]
5pub enum Type {
6    None,
7    I,
8    P,
9    B,
10    S,
11    SI,
12    SP,
13    BI,
14}
15
16impl From<AVPictureType> for Type {
17    #[inline(always)]
18    fn from(value: AVPictureType) -> Type {
19        match value {
20            AV_PICTURE_TYPE_NONE => Type::None,
21            AV_PICTURE_TYPE_I => Type::I,
22            AV_PICTURE_TYPE_P => Type::P,
23            AV_PICTURE_TYPE_B => Type::B,
24            AV_PICTURE_TYPE_S => Type::S,
25            AV_PICTURE_TYPE_SI => Type::SI,
26            AV_PICTURE_TYPE_SP => Type::SP,
27            AV_PICTURE_TYPE_BI => Type::BI,
28
29            #[cfg(feature = "non-exhaustive-enums")]
30            _ => unimplemented!(),
31        }
32    }
33}
34
35impl From<Type> for AVPictureType {
36    #[inline(always)]
37    fn from(value: Type) -> AVPictureType {
38        match value {
39            Type::None => AV_PICTURE_TYPE_NONE,
40            Type::I => AV_PICTURE_TYPE_I,
41            Type::P => AV_PICTURE_TYPE_P,
42            Type::B => AV_PICTURE_TYPE_B,
43            Type::S => AV_PICTURE_TYPE_S,
44            Type::SI => AV_PICTURE_TYPE_SI,
45            Type::SP => AV_PICTURE_TYPE_SP,
46            Type::BI => AV_PICTURE_TYPE_BI,
47        }
48    }
49}