*: refactor setters to return self
This commit is contained in:
@ -54,10 +54,12 @@ impl Audio {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_rate(&mut self, rate: i32) {
|
||||
pub fn set_rate(&mut self, rate: i32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).sample_rate = rate;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn rate(&self) -> u32 {
|
||||
@ -66,10 +68,12 @@ impl Audio {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_format(&mut self, value: format::Sample) {
|
||||
pub fn set_format(&mut self, value: format::Sample) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).sample_fmt = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn format(&self) -> format::Sample {
|
||||
@ -78,10 +82,12 @@ impl Audio {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) {
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).channel_layout = value.bits();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn channel_layout(&self) -> ChannelLayout {
|
||||
@ -90,10 +96,12 @@ impl Audio {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_channels(&mut self, value: i32) {
|
||||
pub fn set_channels(&mut self, value: i32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).channels = value;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn channels(&self) -> u16 {
|
||||
|
@ -35,31 +35,39 @@ impl Encoder {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_bit_rate(&mut self, value: usize) {
|
||||
pub fn set_bit_rate(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).bit_rate = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_max_bit_rate(&mut self, value: usize) {
|
||||
pub fn set_max_bit_rate(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).rc_max_rate = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_tolerance(&mut self, value: usize) {
|
||||
pub fn set_tolerance(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).bit_rate_tolerance = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_quality(&mut self, value: usize) {
|
||||
pub fn set_quality(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).global_quality = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_compression(&mut self, value: Option<usize>) {
|
||||
pub fn set_compression(&mut self, value: Option<usize>) -> &mut Self {
|
||||
unsafe {
|
||||
if let Some(value) = value {
|
||||
(*self.as_mut_ptr()).compression_level = value as c_int;
|
||||
@ -68,15 +76,19 @@ impl Encoder {
|
||||
(*self.as_mut_ptr()).compression_level = -1;
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_time_base<R: Into<Rational>>(&mut self, value: R) {
|
||||
pub fn set_time_base<R: Into<Rational>>(&mut self, value: R) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).time_base = value.into().into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_frame_rate<R: Into<Rational>>(&mut self, value: Option<R>) {
|
||||
pub fn set_frame_rate<R: Into<Rational>>(&mut self, value: Option<R>) -> &mut Self {
|
||||
unsafe {
|
||||
if let Some(value) = value {
|
||||
(*self.as_mut_ptr()).framerate = value.into().into();
|
||||
@ -86,6 +98,8 @@ impl Encoder {
|
||||
(*self.as_mut_ptr()).framerate.den = 1;
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,10 +54,12 @@ impl Video {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_width(&mut self, value: u32) {
|
||||
pub fn set_width(&mut self, value: u32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).width = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn width(&self) -> u32 {
|
||||
@ -66,10 +68,12 @@ impl Video {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_height(&mut self, value: u32) {
|
||||
pub fn set_height(&mut self, value: u32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).height = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn height(&self) -> u32 {
|
||||
@ -78,16 +82,20 @@ impl Video {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_gop(&mut self, value: u32) {
|
||||
pub fn set_gop(&mut self, value: u32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).gop_size = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_format(&mut self, value: format::Pixel) {
|
||||
pub fn set_format(&mut self, value: format::Pixel) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).pix_fmt = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn format(&self) -> format::Pixel {
|
||||
@ -96,151 +104,199 @@ impl Video {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_motion_estimation(&mut self, value: MotionEstimation) {
|
||||
pub fn set_motion_estimation(&mut self, value: MotionEstimation) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_method = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_max_b_frames(&mut self, value: usize) {
|
||||
pub fn set_max_b_frames(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).max_b_frames = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_b_quant_factor(&mut self, value: f32) {
|
||||
pub fn set_b_quant_factor(&mut self, value: f32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).b_quant_factor = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_b_quant_offset(&mut self, value: f32) {
|
||||
pub fn set_b_quant_offset(&mut self, value: f32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).b_quant_offset = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_i_quant_factor(&mut self, value: f32) {
|
||||
pub fn set_i_quant_factor(&mut self, value: f32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).i_quant_factor = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_i_quant_offset(&mut self, value: f32) {
|
||||
pub fn set_i_quant_offset(&mut self, value: f32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).i_quant_offset = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_lumi_masking(&mut self, value: f32) {
|
||||
pub fn set_lumi_masking(&mut self, value: f32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).lumi_masking = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_temporal_cplx_masking(&mut self, value: f32) {
|
||||
pub fn set_temporal_cplx_masking(&mut self, value: f32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).temporal_cplx_masking = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_spatial_cplx_masking(&mut self, value: f32) {
|
||||
pub fn set_spatial_cplx_masking(&mut self, value: f32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).spatial_cplx_masking = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_p_masking(&mut self, value: f32) {
|
||||
pub fn set_p_masking(&mut self, value: f32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).p_masking = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_dark_masking(&mut self, value: f32) {
|
||||
pub fn set_dark_masking(&mut self, value: f32) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).dark_masking = value as c_float;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_prediction(&mut self, value: Prediction) {
|
||||
pub fn set_prediction(&mut self, value: Prediction) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).prediction_method = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_aspect_ratio<R: Into<Rational>>(&mut self, value: R) {
|
||||
pub fn set_aspect_ratio<R: Into<Rational>>(&mut self, value: R) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).sample_aspect_ratio = value.into().into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_me_comparison(&mut self, value: Comparison) {
|
||||
pub fn set_me_comparison(&mut self, value: Comparison) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_cmp = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_me_sub_comparison(&mut self, value: Comparison) {
|
||||
pub fn set_me_sub_comparison(&mut self, value: Comparison) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_sub_cmp = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_mb_comparison(&mut self, value: Comparison) {
|
||||
pub fn set_mb_comparison(&mut self, value: Comparison) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).mb_cmp = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_ildct_comparison(&mut self, value: Comparison) {
|
||||
pub fn set_ildct_comparison(&mut self, value: Comparison) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).ildct_cmp = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_dia_size(&mut self, value: usize) {
|
||||
pub fn set_dia_size(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).dia_size = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_last_predictors(&mut self, value: usize) {
|
||||
pub fn set_last_predictors(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).last_predictor_count = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_pre_me(&mut self, value: MotionEstimation) {
|
||||
pub fn set_pre_me(&mut self, value: MotionEstimation) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).pre_me = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_me_pre_comparison(&mut self, value: Comparison) {
|
||||
pub fn set_me_pre_comparison(&mut self, value: Comparison) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_pre_cmp = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_pre_dia_size(&mut self, value: usize) {
|
||||
pub fn set_pre_dia_size(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).pre_dia_size = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_me_subpel_quality(&mut self, value: usize) {
|
||||
pub fn set_me_subpel_quality(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_subpel_quality = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_me_range(&mut self, value: usize) {
|
||||
pub fn set_me_range(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).me_range = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_intra_quant_bias(&mut self, value: Option<usize>) {
|
||||
pub fn set_intra_quant_bias(&mut self, value: Option<usize>) -> &mut Self {
|
||||
unsafe {
|
||||
if let Some(value) = value {
|
||||
(*self.as_mut_ptr()).intra_quant_bias = value as c_int;
|
||||
@ -249,9 +305,11 @@ impl Video {
|
||||
(*self.as_mut_ptr()).intra_quant_bias = FF_DEFAULT_QUANT_BIAS;
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_inter_quant_bias(&mut self, value: Option<usize>) {
|
||||
pub fn set_inter_quant_bias(&mut self, value: Option<usize>) -> &mut Self {
|
||||
unsafe {
|
||||
if let Some(value) = value {
|
||||
(*self.as_mut_ptr()).inter_quant_bias = value as c_int;
|
||||
@ -260,18 +318,24 @@ impl Video {
|
||||
(*self.as_mut_ptr()).inter_quant_bias = FF_DEFAULT_QUANT_BIAS;
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_mb_decision(&mut self, value: Decision) {
|
||||
pub fn set_mb_decision(&mut self, value: Decision) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).mb_decision = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_intra_dc_precision(&mut self, value: u8) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user