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
use ffi::AVPictureType::*;
use ffi::*;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};

#[derive(Eq, PartialEq, Clone, Copy, Debug)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub enum Type {
    None,
    I,
    P,
    B,
    S,
    SI,
    SP,
    BI,
}

impl From<AVPictureType> for Type {
    #[inline(always)]
    fn from(value: AVPictureType) -> Type {
        match value {
            AV_PICTURE_TYPE_NONE => Type::None,
            AV_PICTURE_TYPE_I => Type::I,
            AV_PICTURE_TYPE_P => Type::P,
            AV_PICTURE_TYPE_B => Type::B,
            AV_PICTURE_TYPE_S => Type::S,
            AV_PICTURE_TYPE_SI => Type::SI,
            AV_PICTURE_TYPE_SP => Type::SP,
            AV_PICTURE_TYPE_BI => Type::BI,

            #[cfg(feature = "non-exhaustive-enums")]
            _ => unimplemented!(),
        }
    }
}

impl From<Type> for AVPictureType {
    #[inline(always)]
    fn from(value: Type) -> AVPictureType {
        match value {
            Type::None => AV_PICTURE_TYPE_NONE,
            Type::I => AV_PICTURE_TYPE_I,
            Type::P => AV_PICTURE_TYPE_P,
            Type::B => AV_PICTURE_TYPE_B,
            Type::S => AV_PICTURE_TYPE_S,
            Type::SI => AV_PICTURE_TYPE_SI,
            Type::SP => AV_PICTURE_TYPE_SP,
            Type::BI => AV_PICTURE_TYPE_BI,
        }
    }
}