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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use enumn::N;
use super::bindings;
use crate::error::Result;
use crate::format::*;
#[derive(Debug, Clone, Copy)]
pub struct OutputProfile {
pub profile: Profile,
pub max_width: u32,
pub max_height: u32,
pub max_framerate_numerator: u32,
pub max_framerate_denominator: u32,
}
impl OutputProfile {
pub(crate) fn new(p: &bindings::vea_profile_t) -> Result<Self> {
Ok(Self {
profile: Profile::new(p.profile)?,
max_width: p.max_width,
max_height: p.max_height,
max_framerate_numerator: p.max_framerate_numerator,
max_framerate_denominator: p.max_framerate_denominator,
})
}
pub(crate) unsafe fn from_raw_parts(
data: *const bindings::vea_profile_t,
len: usize,
) -> Result<Vec<Self>> {
validate_formats(data, len, Self::new)
}
}
#[derive(Debug, Clone, Copy, N)]
#[repr(u32)]
pub enum BitrateMode {
VBR = bindings::vea_bitrate_mode_VBR,
CBR = bindings::vea_bitrate_mode_CBR,
}
#[derive(Debug, Clone, Copy)]
pub struct Bitrate {
pub mode: BitrateMode,
pub target: u32,
pub peak: u32,
}
impl Bitrate {
pub fn to_raw_bitrate(&self) -> bindings::vea_bitrate_t {
bindings::vea_bitrate_t {
mode: match self.mode {
BitrateMode::VBR => bindings::vea_bitrate_mode_VBR,
BitrateMode::CBR => bindings::vea_bitrate_mode_CBR,
},
target: self.target,
peak: self.peak,
}
}
}