diff --git a/src/codec/encoder/video.rs b/src/codec/encoder/video.rs index fd83d3d..b14f112 100644 --- a/src/codec/encoder/video.rs +++ b/src/codec/encoder/video.rs @@ -12,6 +12,7 @@ use codec::traits; pub struct Video(pub Super); impl Video { + #[inline] pub fn open(mut self) -> Result { unsafe { match avcodec_open2(self.as_mut_ptr(), ptr::null(), ptr::null_mut()) { @@ -21,6 +22,7 @@ impl Video { } } + #[inline] pub fn open_as(mut self, codec: E) -> Result { unsafe { if let Some(codec) = codec.encoder() { @@ -35,6 +37,7 @@ impl Video { } } + #[inline] pub fn open_as_with(mut self, codec: E, options: Dictionary) -> Result { unsafe { if let Some(codec) = codec.encoder() { @@ -54,6 +57,7 @@ impl Video { } } + #[inline] pub fn set_width(&mut self, value: u32) -> &mut Self { unsafe { (*self.as_mut_ptr()).width = value as c_int; @@ -62,12 +66,14 @@ impl Video { self } + #[inline] pub fn width(&self) -> u32 { unsafe { (*self.as_ptr()).width as u32 } } + #[inline] pub fn set_height(&mut self, value: u32) -> &mut Self { unsafe { (*self.as_mut_ptr()).height = value as c_int; @@ -76,12 +82,14 @@ impl Video { self } + #[inline] pub fn height(&self) -> u32 { unsafe { (*self.as_ptr()).height as u32 } } + #[inline] pub fn set_gop(&mut self, value: u32) -> &mut Self { unsafe { (*self.as_mut_ptr()).gop_size = value as c_int; @@ -90,6 +98,7 @@ impl Video { self } + #[inline] pub fn set_format(&mut self, value: format::Pixel) -> &mut Self { unsafe { (*self.as_mut_ptr()).pix_fmt = value.into(); @@ -98,12 +107,14 @@ impl Video { self } + #[inline] pub fn format(&self) -> format::Pixel { unsafe { format::Pixel::from((*self.as_ptr()).pix_fmt) } } + #[inline] pub fn set_motion_estimation(&mut self, value: MotionEstimation) -> &mut Self { unsafe { (*self.as_mut_ptr()).me_method = value.into(); @@ -112,6 +123,7 @@ impl Video { self } + #[inline] pub fn set_max_b_frames(&mut self, value: usize) -> &mut Self { unsafe { (*self.as_mut_ptr()).max_b_frames = value as c_int; @@ -120,6 +132,7 @@ impl Video { self } + #[inline] pub fn set_b_quant_factor(&mut self, value: f32) -> &mut Self { unsafe { (*self.as_mut_ptr()).b_quant_factor = value as c_float; @@ -128,6 +141,7 @@ impl Video { self } + #[inline] pub fn set_b_quant_offset(&mut self, value: f32) -> &mut Self { unsafe { (*self.as_mut_ptr()).b_quant_offset = value as c_float; @@ -136,6 +150,7 @@ impl Video { self } + #[inline] pub fn set_i_quant_factor(&mut self, value: f32) -> &mut Self { unsafe { (*self.as_mut_ptr()).i_quant_factor = value as c_float; @@ -144,6 +159,7 @@ impl Video { self } + #[inline] pub fn set_i_quant_offset(&mut self, value: f32) -> &mut Self { unsafe { (*self.as_mut_ptr()).i_quant_offset = value as c_float; @@ -152,6 +168,7 @@ impl Video { self } + #[inline] pub fn set_lumi_masking(&mut self, value: f32) -> &mut Self { unsafe { (*self.as_mut_ptr()).lumi_masking = value as c_float; @@ -160,6 +177,7 @@ impl Video { self } + #[inline] pub fn set_temporal_cplx_masking(&mut self, value: f32) -> &mut Self { unsafe { (*self.as_mut_ptr()).temporal_cplx_masking = value as c_float; @@ -168,6 +186,7 @@ impl Video { self } + #[inline] pub fn set_spatial_cplx_masking(&mut self, value: f32) -> &mut Self { unsafe { (*self.as_mut_ptr()).spatial_cplx_masking = value as c_float; @@ -176,6 +195,7 @@ impl Video { self } + #[inline] pub fn set_p_masking(&mut self, value: f32) -> &mut Self { unsafe { (*self.as_mut_ptr()).p_masking = value as c_float; @@ -184,6 +204,7 @@ impl Video { self } + #[inline] pub fn set_dark_masking(&mut self, value: f32) -> &mut Self { unsafe { (*self.as_mut_ptr()).dark_masking = value as c_float; @@ -192,6 +213,7 @@ impl Video { self } + #[inline] pub fn set_prediction(&mut self, value: Prediction) -> &mut Self { unsafe { (*self.as_mut_ptr()).prediction_method = value.into(); @@ -200,6 +222,7 @@ impl Video { self } + #[inline] pub fn set_aspect_ratio>(&mut self, value: R) -> &mut Self { unsafe { (*self.as_mut_ptr()).sample_aspect_ratio = value.into().into(); @@ -208,6 +231,7 @@ impl Video { self } + #[inline] pub fn set_me_comparison(&mut self, value: Comparison) -> &mut Self { unsafe { (*self.as_mut_ptr()).me_cmp = value.into(); @@ -216,6 +240,7 @@ impl Video { self } + #[inline] pub fn set_me_sub_comparison(&mut self, value: Comparison) -> &mut Self { unsafe { (*self.as_mut_ptr()).me_sub_cmp = value.into(); @@ -224,6 +249,7 @@ impl Video { self } + #[inline] pub fn set_mb_comparison(&mut self, value: Comparison) -> &mut Self { unsafe { (*self.as_mut_ptr()).mb_cmp = value.into(); @@ -232,6 +258,7 @@ impl Video { self } + #[inline] pub fn set_ildct_comparison(&mut self, value: Comparison) -> &mut Self { unsafe { (*self.as_mut_ptr()).ildct_cmp = value.into(); @@ -240,6 +267,7 @@ impl Video { self } + #[inline] pub fn set_dia_size(&mut self, value: usize) -> &mut Self { unsafe { (*self.as_mut_ptr()).dia_size = value as c_int; @@ -248,6 +276,7 @@ impl Video { self } + #[inline] pub fn set_last_predictors(&mut self, value: usize) -> &mut Self { unsafe { (*self.as_mut_ptr()).last_predictor_count = value as c_int; @@ -256,6 +285,7 @@ impl Video { self } + #[inline] pub fn set_pre_me(&mut self, value: MotionEstimation) -> &mut Self { unsafe { (*self.as_mut_ptr()).pre_me = value.into(); @@ -264,6 +294,7 @@ impl Video { self } + #[inline] pub fn set_me_pre_comparison(&mut self, value: Comparison) -> &mut Self { unsafe { (*self.as_mut_ptr()).me_pre_cmp = value.into(); @@ -272,6 +303,7 @@ impl Video { self } + #[inline] pub fn set_pre_dia_size(&mut self, value: usize) -> &mut Self { unsafe { (*self.as_mut_ptr()).pre_dia_size = value as c_int; @@ -280,6 +312,7 @@ impl Video { self } + #[inline] pub fn set_me_subpel_quality(&mut self, value: usize) -> &mut Self { unsafe { (*self.as_mut_ptr()).me_subpel_quality = value as c_int; @@ -288,6 +321,7 @@ impl Video { self } + #[inline] pub fn set_me_range(&mut self, value: usize) -> &mut Self { unsafe { (*self.as_mut_ptr()).me_range = value as c_int; @@ -296,6 +330,7 @@ impl Video { self } + #[inline] pub fn set_intra_quant_bias(&mut self, value: Option) -> &mut Self { unsafe { if let Some(value) = value { @@ -309,6 +344,7 @@ impl Video { self } + #[inline] pub fn set_inter_quant_bias(&mut self, value: Option) -> &mut Self { unsafe { if let Some(value) = value { @@ -322,6 +358,7 @@ impl Video { self } + #[inline] pub fn set_mb_decision(&mut self, value: Decision) -> &mut Self { unsafe { (*self.as_mut_ptr()).mb_decision = value.into(); @@ -330,6 +367,7 @@ impl Video { self } + #[inline] pub fn set_intra_dc_precision(&mut self, value: u8) -> &mut Self { unsafe { (*self.as_mut_ptr()).intra_dc_precision = value as c_int; @@ -338,6 +376,7 @@ impl Video { self } + #[inline] pub fn set_mb_lmin(&mut self, value: i32) -> &mut Self { unsafe { (*self.as_mut_ptr()).mb_lmin = value as c_int; @@ -346,6 +385,7 @@ impl Video { self } + #[inline] pub fn set_mb_lmax(&mut self, value: i32) -> &mut Self { unsafe { (*self.as_mut_ptr()).mb_lmax = value as c_int; @@ -358,12 +398,14 @@ impl Video { impl Deref for Video { type Target = Super; + #[inline(always)] fn deref(&self) -> &::Target { &self.0 } } impl DerefMut for Video { + #[inline(always)] fn deref_mut(&mut self) -> &mut::Target { &mut self.0 } @@ -372,6 +414,7 @@ impl DerefMut for Video { pub struct Encoder(pub Video); impl Encoder { + #[inline] pub fn encode(&mut self, frame: &frame::Video, out: &mut Packet) -> Result { unsafe { if self.format() != frame.format() || self.width() != frame.width() || self.height() != frame.height() { @@ -387,6 +430,7 @@ impl Encoder { } } + #[inline] pub fn flush(&mut self, out: &mut Packet) -> Result { unsafe { let mut got: c_int = 0; @@ -398,6 +442,7 @@ impl Encoder { } } + #[inline] pub fn frame_size(&self) -> u32 { unsafe { (*self.as_ptr()).frame_size as u32 @@ -408,6 +453,7 @@ impl Encoder { impl Deref for Encoder { type Target = Video; + #[inline] fn deref(&self) -> &::Target { &self.0 }