ffmpeg_the_third/codec/parameters/
common.rs1use crate::macros::impl_for_many;
2
3use super::{Parameters, ParametersMut, ParametersRef};
4use crate::chroma::Location;
5use crate::codec::Id;
6use crate::color;
7use crate::media;
8use crate::{FieldOrder, Rational};
9
10#[cfg(feature = "ffmpeg_8_1")]
11use crate::format::AlphaMode;
12
13use crate::ChannelLayout;
14
15impl_for_many! {
16 impl for Parameters, ParametersRef<'p>, ParametersMut<'p> {
17 pub fn medium(&self) -> media::Type {
18 unsafe { (*self.as_ptr()).codec_type.into() }
19 }
20
21 pub fn id(&self) -> Id {
22 unsafe { (*self.as_ptr()).codec_id.into() }
23 }
24
25 pub fn bit_rate(&self) -> i64 {
31 unsafe { (*self.as_ptr()).bit_rate }
32 }
33
34 pub fn bits_per_coded_sample(&self) -> u32 {
35 unsafe { (*self.as_ptr()).bits_per_coded_sample as u32 }
36 }
37
38 pub fn bits_per_raw_sample(&self) -> u32 {
39 unsafe { (*self.as_ptr()).bits_per_raw_sample as u32 }
40 }
41
42 pub fn profile(&self) -> i32 {
43 unsafe { (*self.as_ptr()).profile as i32 }
44 }
45
46 pub fn level(&self) -> i32 {
47 unsafe { (*self.as_ptr()).level as i32 }
48 }
49
50 pub fn width(&self) -> u32 {
52 unsafe { (*self.as_ptr()).width as u32 }
53 }
54
55 pub fn height(&self) -> u32 {
57 unsafe { (*self.as_ptr()).height as u32 }
58 }
59
60 pub fn sample_aspect_ratio(&self) -> Rational {
62 unsafe { (*self.as_ptr()).sample_aspect_ratio.into() }
63 }
64
65 #[cfg(feature = "ffmpeg_6_1")]
67 pub fn framerate(&self) -> Rational {
68 unsafe { (*self.as_ptr()).framerate.into() }
69 }
70
71 pub fn field_order(&self) -> FieldOrder {
73 unsafe { (*self.as_ptr()).field_order.into() }
74 }
75
76 pub fn color_range(&self) -> color::Range {
78 unsafe { (*self.as_ptr()).color_range.into() }
79 }
80
81 pub fn color_primaries(&self) -> color::Primaries {
83 unsafe { (*self.as_ptr()).color_primaries.into() }
84 }
85
86 pub fn color_transfer_characteristic(&self) -> color::TransferCharacteristic {
88 unsafe { (*self.as_ptr()).color_trc.into() }
89 }
90
91 pub fn color_space(&self) -> color::Space {
93 unsafe { (*self.as_ptr()).color_space.into() }
94 }
95
96 pub fn chroma_location(&self) -> Location {
98 unsafe { (*self.as_ptr()).chroma_location.into() }
99 }
100
101 pub fn video_delay(&self) -> i32 {
103 unsafe { (*self.as_ptr()).video_delay as i32 }
104 }
105
106 pub fn ch_layout(&self) -> ChannelLayout<'_> {
108 unsafe { ChannelLayout::from(&(*self.as_ptr()).ch_layout) }
109 }
110
111 pub fn sample_rate(&self) -> u32 {
113 unsafe { (*self.as_ptr()).sample_rate as u32 }
114 }
115
116 pub fn block_align(&self) -> u32 {
118 unsafe { (*self.as_ptr()).block_align as u32 }
119 }
120
121 pub fn frame_size(&self) -> u32 {
123 unsafe { (*self.as_ptr()).frame_size as u32 }
124 }
125
126 pub fn initial_padding(&self) -> u32 {
128 unsafe { (*self.as_ptr()).initial_padding as u32 }
129 }
130
131 pub fn trailing_padding(&self) -> u32 {
133 unsafe { (*self.as_ptr()).trailing_padding as u32 }
134 }
135
136 pub fn seek_preroll(&self) -> u32 {
138 unsafe { (*self.as_ptr()).seek_preroll as u32 }
139 }
140
141 #[cfg(feature = "ffmpeg_8_1")]
142 pub fn alpha_mode(&self) -> AlphaMode {
143 unsafe { (*self.as_ptr()).alpha_mode.into() }
144 }
145 }
146}