*: returning &mut Self from setters was an awful idea
Deref breaks things.
This commit is contained in:
@ -54,12 +54,10 @@ impl Audio {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_rate(&mut self, rate: i32) -> &mut Self {
|
||||
pub fn set_rate(&mut self, rate: i32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).sample_rate = rate;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn rate(&self) -> u32 {
|
||||
@ -68,12 +66,10 @@ impl Audio {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_format(&mut self, value: format::Sample) -> &mut Self {
|
||||
pub fn set_format(&mut self, value: format::Sample) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).sample_fmt = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn format(&self) -> format::Sample {
|
||||
@ -82,12 +78,10 @@ impl Audio {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) -> &mut Self {
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).channel_layout = value.bits();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn channel_layout(&self) -> ChannelLayout {
|
||||
@ -96,12 +90,10 @@ impl Audio {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_channels(&mut self, value: i32) -> &mut Self {
|
||||
pub fn set_channels(&mut self, value: i32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).channels = value;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn channels(&self) -> u16 {
|
||||
|
@ -68,39 +68,31 @@ impl Encoder {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_bit_rate(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_bit_rate(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).bit_rate = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_max_bit_rate(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_max_bit_rate(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).rc_max_rate = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_tolerance(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_tolerance(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).bit_rate_tolerance = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_quality(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_quality(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).global_quality = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_compression(&mut self, value: Option<usize>) -> &mut Self {
|
||||
pub fn set_compression(&mut self, value: Option<usize>) {
|
||||
unsafe {
|
||||
if let Some(value) = value {
|
||||
(*self.as_mut_ptr()).compression_level = value as c_int;
|
||||
@ -109,19 +101,15 @@ impl Encoder {
|
||||
(*self.as_mut_ptr()).compression_level = -1;
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_time_base<R: Into<Rational>>(&mut self, value: R) -> &mut Self {
|
||||
pub fn set_time_base<R: Into<Rational>>(&mut self, value: R) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).time_base = value.into().into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_frame_rate<R: Into<Rational>>(&mut self, value: Option<R>) -> &mut Self {
|
||||
pub fn set_frame_rate<R: Into<Rational>>(&mut self, value: Option<R>) {
|
||||
unsafe {
|
||||
if let Some(value) = value {
|
||||
(*self.as_mut_ptr()).framerate = value.into().into();
|
||||
@ -131,8 +119,6 @@ impl Encoder {
|
||||
(*self.as_mut_ptr()).framerate.den = 1;
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,12 +58,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_width(&mut self, value: u32) -> &mut Self {
|
||||
pub fn set_width(&mut self, value: u32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).width = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -74,12 +72,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_height(&mut self, value: u32) -> &mut Self {
|
||||
pub fn set_height(&mut self, value: u32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).height = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -90,21 +86,17 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_gop(&mut self, value: u32) -> &mut Self {
|
||||
pub fn set_gop(&mut self, value: u32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).gop_size = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_format(&mut self, value: format::Pixel) -> &mut Self {
|
||||
pub fn set_format(&mut self, value: format::Pixel) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).pix_fmt = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -115,223 +107,175 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_motion_estimation(&mut self, value: MotionEstimation) -> &mut Self {
|
||||
pub fn set_motion_estimation(&mut self, value: MotionEstimation) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_method = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_max_b_frames(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_max_b_frames(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).max_b_frames = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_b_quant_factor(&mut self, value: f32) -> &mut Self {
|
||||
pub fn set_b_quant_factor(&mut self, value: f32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).b_quant_factor = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_b_quant_offset(&mut self, value: f32) -> &mut Self {
|
||||
pub fn set_b_quant_offset(&mut self, value: f32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).b_quant_offset = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_i_quant_factor(&mut self, value: f32) -> &mut Self {
|
||||
pub fn set_i_quant_factor(&mut self, value: f32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).i_quant_factor = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_i_quant_offset(&mut self, value: f32) -> &mut Self {
|
||||
pub fn set_i_quant_offset(&mut self, value: f32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).i_quant_offset = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_lumi_masking(&mut self, value: f32) -> &mut Self {
|
||||
pub fn set_lumi_masking(&mut self, value: f32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).lumi_masking = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_temporal_cplx_masking(&mut self, value: f32) -> &mut Self {
|
||||
pub fn set_temporal_cplx_masking(&mut self, value: f32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).temporal_cplx_masking = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_spatial_cplx_masking(&mut self, value: f32) -> &mut Self {
|
||||
pub fn set_spatial_cplx_masking(&mut self, value: f32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).spatial_cplx_masking = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_p_masking(&mut self, value: f32) -> &mut Self {
|
||||
pub fn set_p_masking(&mut self, value: f32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).p_masking = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_dark_masking(&mut self, value: f32) -> &mut Self {
|
||||
pub fn set_dark_masking(&mut self, value: f32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).dark_masking = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_prediction(&mut self, value: Prediction) -> &mut Self {
|
||||
pub fn set_prediction(&mut self, value: Prediction) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).prediction_method = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_aspect_ratio<R: Into<Rational>>(&mut self, value: R) -> &mut Self {
|
||||
pub fn set_aspect_ratio<R: Into<Rational>>(&mut self, value: R) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).sample_aspect_ratio = value.into().into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_me_comparison(&mut self, value: Comparison) -> &mut Self {
|
||||
pub fn set_me_comparison(&mut self, value: Comparison) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_cmp = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_me_sub_comparison(&mut self, value: Comparison) -> &mut Self {
|
||||
pub fn set_me_sub_comparison(&mut self, value: Comparison) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_sub_cmp = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_mb_comparison(&mut self, value: Comparison) -> &mut Self {
|
||||
pub fn set_mb_comparison(&mut self, value: Comparison) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).mb_cmp = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_ildct_comparison(&mut self, value: Comparison) -> &mut Self {
|
||||
pub fn set_ildct_comparison(&mut self, value: Comparison) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).ildct_cmp = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_dia_size(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_dia_size(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).dia_size = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_last_predictors(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_last_predictors(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).last_predictor_count = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_pre_me(&mut self, value: MotionEstimation) -> &mut Self {
|
||||
pub fn set_pre_me(&mut self, value: MotionEstimation) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).pre_me = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_me_pre_comparison(&mut self, value: Comparison) -> &mut Self {
|
||||
pub fn set_me_pre_comparison(&mut self, value: Comparison) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_pre_cmp = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_pre_dia_size(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_pre_dia_size(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).pre_dia_size = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_me_subpel_quality(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_me_subpel_quality(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_subpel_quality = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_me_range(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_me_range(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_range = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_intra_quant_bias(&mut self, value: Option<usize>) -> &mut Self {
|
||||
pub fn set_intra_quant_bias(&mut self, value: Option<usize>) {
|
||||
unsafe {
|
||||
if let Some(value) = value {
|
||||
(*self.as_mut_ptr()).intra_quant_bias = value as c_int;
|
||||
@ -340,12 +284,10 @@ impl Video {
|
||||
(*self.as_mut_ptr()).intra_quant_bias = FF_DEFAULT_QUANT_BIAS;
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_inter_quant_bias(&mut self, value: Option<usize>) -> &mut Self {
|
||||
pub fn set_inter_quant_bias(&mut self, value: Option<usize>) {
|
||||
unsafe {
|
||||
if let Some(value) = value {
|
||||
(*self.as_mut_ptr()).inter_quant_bias = value as c_int;
|
||||
@ -354,44 +296,55 @@ impl Video {
|
||||
(*self.as_mut_ptr()).inter_quant_bias = FF_DEFAULT_QUANT_BIAS;
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_mb_decision(&mut self, value: Decision) -> &mut Self {
|
||||
pub fn set_mb_decision(&mut self, value: Decision) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).mb_decision = value.into();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_mb_lmin(&mut self, value: i32) -> &mut Self {
|
||||
pub fn set_mb_lmin(&mut self, value: i32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).mb_lmin = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_mb_lmax(&mut self, value: i32) -> &mut Self {
|
||||
pub fn set_mb_lmax(&mut self, value: i32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).mb_lmax = value as c_int;
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
#[inline]
|
||||
pub fn set_intra_dc_precision(&mut self, value: u8) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).intra_dc_precision = value as c_int;
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_qmin(&mut self, value: i32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).qmin = value as c_int;
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_qmax(&mut self, value: i32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).qmax = value as c_int;
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_global_quality(&mut self, value: i32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).global_quality = value as c_int;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -458,3 +411,10 @@ impl Deref for Encoder {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for Encoder {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut <Self as Deref>::Target {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user