*: refactor setters to return self
This commit is contained in:
@ -62,10 +62,12 @@ impl Context {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_flags(&mut self, value: Flags) {
|
||||
pub fn set_flags(&mut self, value: Flags) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).flags = value.bits() as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Id {
|
||||
@ -86,12 +88,14 @@ impl Context {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_threading(&mut self, config: threading::Config) {
|
||||
pub fn set_threading(&mut self, config: threading::Config) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).thread_type = config.kind.into();
|
||||
(*self.as_mut_ptr()).thread_count = config.count as c_int;
|
||||
(*self.as_mut_ptr()).thread_safe_callbacks = if config.safe { 1 } else { 0 };
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn threading(&self) -> threading::Config {
|
||||
|
@ -64,16 +64,20 @@ 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 request_channel_layout(&mut self, value: ChannelLayout) {
|
||||
pub fn request_channel_layout(&mut self, value: ChannelLayout) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).request_channel_layout = value.bits();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn audio_service(&mut self) -> AudioService {
|
||||
|
@ -84,28 +84,36 @@ impl Video {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_slice_count(&mut self, value: usize) {
|
||||
pub fn set_slice_count(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).slice_count = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_slice_flags(&mut self, value: slice::Flags) {
|
||||
pub fn set_slice_flags(&mut self, value: slice::Flags) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).slice_flags = value.bits();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn skip_top(&mut self, value: usize) {
|
||||
pub fn skip_top(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).skip_top = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn skip_bottom(&mut self, value: usize) {
|
||||
pub fn skip_bottom(&mut self, value: usize) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).skip_bottom = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn references(&self) -> usize {
|
||||
@ -114,10 +122,12 @@ impl Video {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_field_order(&mut self, value: FieldOrder) {
|
||||
pub fn set_field_order(&mut self, value: FieldOrder) -> &mut Self {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).field_order = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
// intra_matrix
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,21 +69,25 @@ impl Packet {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rescale_ts<S, D>(&mut self, source: S, destination: D)
|
||||
pub fn rescale_ts<S, D>(&mut self, source: S, destination: D) -> &mut Self
|
||||
where S: Into<Rational>,
|
||||
D: Into<Rational>
|
||||
{
|
||||
unsafe {
|
||||
av_packet_rescale_ts(self.as_mut_ptr(), source.into().into(), destination.into().into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn flags(&self) -> Flags {
|
||||
Flags::from_bits_truncate(self.0.flags)
|
||||
}
|
||||
|
||||
pub fn set_flags(&mut self, value: Flags) {
|
||||
pub fn set_flags(&mut self, value: Flags) -> &mut Self {
|
||||
self.0.flags = value.bits();
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn is_key(&self) -> bool {
|
||||
@ -98,8 +102,10 @@ impl Packet {
|
||||
self.0.stream_index as usize
|
||||
}
|
||||
|
||||
pub fn set_stream(&mut self, index: usize) {
|
||||
pub fn set_stream(&mut self, index: usize) -> &mut Self {
|
||||
self.0.stream_index = index as c_int;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn pts(&self) -> Option<i64> {
|
||||
|
@ -69,24 +69,30 @@ impl Subtitle {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_pts(&mut self, value: Option<i64>) {
|
||||
pub fn set_pts(&mut self, value: Option<i64>) -> &mut Self {
|
||||
self.0.pts = value.unwrap_or(AV_NOPTS_VALUE);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn start(&self) -> u32 {
|
||||
self.0.start_display_time as u32
|
||||
}
|
||||
|
||||
pub fn set_start(&mut self, value: u32) {
|
||||
pub fn set_start(&mut self, value: u32) -> &mut Self {
|
||||
self.0.start_display_time = value as uint32_t;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn end(&self) -> u32 {
|
||||
self.0.end_display_time as u32
|
||||
}
|
||||
|
||||
pub fn set_end(&mut self, value: u32) {
|
||||
pub fn set_end(&mut self, value: u32) -> &mut Self {
|
||||
self.0.end_display_time = value as uint32_t;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn rects(&self) -> RectIter {
|
||||
|
Reference in New Issue
Block a user