*: returning &mut Self from setters was an awful idea
Deref breaks things.
This commit is contained in:
parent
0764c597e4
commit
132c514e3f
@ -15,10 +15,13 @@ fn filter(spec: &str, decoder: &codec::decoder::Audio, encoder: &codec::encoder:
|
||||
try!(filter.add(&filter::find("abuffer").unwrap(), "in", &args));
|
||||
try!(filter.add(&filter::find("abuffersink").unwrap(), "out", ""));
|
||||
|
||||
filter.get("out").unwrap()
|
||||
.set_sample_format(encoder.format())
|
||||
.set_channel_layout(encoder.channel_layout())
|
||||
.set_sample_rate(encoder.rate());
|
||||
{
|
||||
let mut out = filter.get("out").unwrap();
|
||||
|
||||
out.set_sample_format(encoder.format());
|
||||
out.set_channel_layout(encoder.channel_layout());
|
||||
out.set_sample_rate(encoder.rate());
|
||||
}
|
||||
|
||||
try!(try!(try!(filter.output("in", 0)).input("out", 0)).parse(spec));
|
||||
try!(filter.validate());
|
||||
@ -58,12 +61,12 @@ fn transcoder<P: AsRef<Path>>(ictx: &mut format::context::Input, octx: &mut form
|
||||
encoder.set_flags(ffmpeg::codec::flag::GLOBAL_HEADER);
|
||||
}
|
||||
|
||||
encoder.set_rate(decoder.rate() as i32)
|
||||
.set_channel_layout(channel_layout)
|
||||
.set_channels(channel_layout.channels())
|
||||
.set_format(codec.formats().expect("unknown supported formats").next().unwrap())
|
||||
.set_bit_rate(decoder.bit_rate())
|
||||
.set_max_bit_rate(decoder.max_bit_rate());
|
||||
encoder.set_rate(decoder.rate() as i32);
|
||||
encoder.set_channel_layout(channel_layout);
|
||||
encoder.set_channels(channel_layout.channels());
|
||||
encoder.set_format(codec.formats().expect("unknown supported formats").next().unwrap());
|
||||
encoder.set_bit_rate(decoder.bit_rate());
|
||||
encoder.set_max_bit_rate(decoder.max_bit_rate());
|
||||
|
||||
encoder.set_time_base((1, decoder.rate() as i32));
|
||||
output.set_time_base((1, decoder.rate() as i32));
|
||||
@ -119,9 +122,9 @@ fn main() {
|
||||
|
||||
while let Ok(..) = transcoder.filter.get("out").unwrap().sink().frame(&mut decoded) {
|
||||
if let Ok(true) = transcoder.encoder.encode(&decoded, &mut encoded) {
|
||||
encoded.set_stream(0)
|
||||
.rescale_ts(in_time_base, out_time_base)
|
||||
.write_interleaved(&mut octx).unwrap();
|
||||
encoded.set_stream(0);
|
||||
encoded.rescale_ts(in_time_base, out_time_base);
|
||||
encoded.write_interleaved(&mut octx).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,16 +135,16 @@ fn main() {
|
||||
|
||||
while let Ok(..) = transcoder.filter.get("out").unwrap().sink().frame(&mut decoded) {
|
||||
if let Ok(true) = transcoder.encoder.encode(&decoded, &mut encoded) {
|
||||
encoded.set_stream(0)
|
||||
.rescale_ts(in_time_base, out_time_base)
|
||||
.write_interleaved(&mut octx).unwrap();
|
||||
encoded.set_stream(0);
|
||||
encoded.rescale_ts(in_time_base, out_time_base);
|
||||
encoded.write_interleaved(&mut octx).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(true) = transcoder.encoder.flush(&mut encoded) {
|
||||
encoded.set_stream(0)
|
||||
.rescale_ts(in_time_base, out_time_base)
|
||||
.write_interleaved(&mut octx).unwrap();
|
||||
encoded.set_stream(0);
|
||||
encoded.rescale_ts(in_time_base, out_time_base);
|
||||
encoded.write_interleaved(&mut octx).unwrap();
|
||||
}
|
||||
|
||||
octx.write_trailer().unwrap();
|
||||
|
@ -62,12 +62,10 @@ impl Context {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_flags(&mut self, value: Flags) -> &mut Self {
|
||||
pub fn set_flags(&mut self, value: Flags) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).flags = value.bits() as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Id {
|
||||
@ -88,14 +86,12 @@ impl Context {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_threading(&mut self, config: threading::Config) -> &mut Self {
|
||||
pub fn set_threading(&mut self, config: threading::Config) {
|
||||
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,20 +64,16 @@ 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 request_channel_layout(&mut self, value: ChannelLayout) -> &mut Self {
|
||||
pub fn request_channel_layout(&mut self, value: ChannelLayout) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).request_channel_layout = value.bits();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn audio_service(&mut self) -> AudioService {
|
||||
|
@ -84,36 +84,28 @@ impl Video {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_slice_count(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_slice_count(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).slice_count = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_slice_flags(&mut self, value: slice::Flags) -> &mut Self {
|
||||
pub fn set_slice_flags(&mut self, value: slice::Flags) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).slice_flags = value.bits();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn skip_top(&mut self, value: usize) -> &mut Self {
|
||||
pub fn skip_top(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).skip_top = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn skip_bottom(&mut self, value: usize) -> &mut Self {
|
||||
pub fn skip_bottom(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).skip_bottom = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn references(&self) -> usize {
|
||||
@ -122,12 +114,10 @@ impl Video {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_field_order(&mut self, value: FieldOrder) -> &mut Self {
|
||||
pub fn set_field_order(&mut self, value: FieldOrder) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).field_order = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
// intra_matrix
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -83,15 +83,13 @@ impl Packet {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn rescale_ts<S, D>(&mut self, source: S, destination: D) -> &mut Self
|
||||
pub fn rescale_ts<S, D>(&mut self, source: S, destination: D)
|
||||
where S: Into<Rational>,
|
||||
D: Into<Rational>
|
||||
{
|
||||
unsafe {
|
||||
av_packet_rescale_ts(self.as_mut_ptr(), source.into().into(), destination.into().into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -100,10 +98,8 @@ impl Packet {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_flags(&mut self, value: Flags) -> &mut Self {
|
||||
pub fn set_flags(&mut self, value: Flags) {
|
||||
self.0.flags = value.bits();
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -122,10 +118,8 @@ impl Packet {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_stream(&mut self, index: usize) -> &mut Self {
|
||||
pub fn set_stream(&mut self, index: usize) {
|
||||
self.0.stream_index = index as c_int;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -69,30 +69,24 @@ impl Subtitle {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_pts(&mut self, value: Option<i64>) -> &mut Self {
|
||||
pub fn set_pts(&mut self, value: Option<i64>) {
|
||||
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) -> &mut Self {
|
||||
pub fn set_start(&mut self, value: u32) {
|
||||
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) -> &mut Self {
|
||||
pub fn set_end(&mut self, value: u32) {
|
||||
self.0.end_display_time = value as uint32_t;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn rects(&self) -> RectIter {
|
||||
|
@ -38,28 +38,20 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_pixel_format(&mut self, value: format::Pixel) -> &mut Self {
|
||||
pub fn set_pixel_format(&mut self, value: format::Pixel) {
|
||||
let _ = option::Settable::set::<AVPixelFormat>(self, "pix_fmts", &value.into());
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_sample_format(&mut self, value: format::Sample) -> &mut Self {
|
||||
pub fn set_sample_format(&mut self, value: format::Sample) {
|
||||
let _ = option::Settable::set::<AVSampleFormat>(self, "sample_fmts", &value.into());
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_sample_rate(&mut self, value: u32) -> &mut Self {
|
||||
pub fn set_sample_rate(&mut self, value: u32) {
|
||||
let _ = option::Settable::set(self, "sample_rates", &(value as i64));
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) -> &mut Self {
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) {
|
||||
let _ = option::Settable::set(self, "channel_layouts", &value.bits());
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,11 +32,9 @@ impl<'a> Sink<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_frame_size(&mut self, value: u32) -> &mut Self {
|
||||
pub fn set_frame_size(&mut self, value: u32) {
|
||||
unsafe {
|
||||
av_buffersink_set_frame_size(self.ctx.as_mut_ptr(), value);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -83,12 +83,10 @@ impl Output {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_metadata(&mut self, dictionary: Dictionary) -> &mut Self {
|
||||
pub fn set_metadata(&mut self, dictionary: Dictionary) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).metadata = dictionary.disown();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,20 +29,16 @@ impl<'a> StreamMut<'a> {
|
||||
}
|
||||
|
||||
impl<'a> StreamMut<'a> {
|
||||
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_rate<R: Into<Rational>>(&mut self, value: R) -> &mut Self {
|
||||
pub fn set_rate<R: Into<Rational>>(&mut self, value: R) {
|
||||
unsafe {
|
||||
av_stream_set_r_frame_rate(self.as_mut_ptr(), value.into().into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,9 @@ impl Audio {
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn alloc(&mut self, format: format::Sample, samples: usize, layout: ChannelLayout) {
|
||||
self.set_format(format)
|
||||
.set_samples(samples)
|
||||
.set_channel_layout(layout);
|
||||
self.set_format(format);
|
||||
self.set_samples(samples);
|
||||
self.set_channel_layout(layout);
|
||||
|
||||
av_frame_get_buffer(self.as_mut_ptr(), 0);
|
||||
}
|
||||
@ -58,12 +58,10 @@ impl Audio {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
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()).format = mem::transmute::<AVSampleFormat, c_int>(value.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -74,12 +72,10 @@ impl Audio {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) -> &mut Self {
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) {
|
||||
unsafe {
|
||||
av_frame_set_channel_layout(self.as_mut_ptr(), value.bits() as int64_t);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -90,12 +86,10 @@ impl Audio {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_channels(&mut self, value: u16) -> &mut Self {
|
||||
pub fn set_channels(&mut self, value: u16) {
|
||||
unsafe {
|
||||
av_frame_set_channels(self.as_mut_ptr(), value as c_int);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -106,12 +100,10 @@ impl Audio {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_rate(&mut self, value: u32) -> &mut Self {
|
||||
pub fn set_rate(&mut self, value: u32) {
|
||||
unsafe {
|
||||
av_frame_set_sample_rate(self.as_mut_ptr(), value as c_int);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -122,12 +114,10 @@ impl Audio {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_samples(&mut self, value: usize) -> &mut Self {
|
||||
pub fn set_samples(&mut self, value: usize) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).nb_samples = value as c_int;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -89,14 +89,14 @@ impl Frame {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_pts(&mut self, value: Option<i64>) -> &mut Self {
|
||||
#[inline]
|
||||
pub fn set_pts(&mut self, value: Option<i64>) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).pts = value.unwrap_or(AV_NOPTS_VALUE);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn timestamp(&self) -> Option<i64> {
|
||||
unsafe {
|
||||
match av_frame_get_best_effort_timestamp(self.as_ptr()) {
|
||||
@ -106,32 +106,35 @@ impl Frame {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn quality(&self) -> usize {
|
||||
unsafe {
|
||||
(*self.as_ptr()).quality as usize
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> Flags {
|
||||
unsafe {
|
||||
Flags::from_bits_truncate((*self.as_ptr()).flags)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn metadata(&self) -> DictionaryRef {
|
||||
unsafe {
|
||||
DictionaryRef::wrap(av_frame_get_metadata(self.as_ptr()))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_metadata(&mut self, value: Dictionary) -> &mut Self {
|
||||
#[inline]
|
||||
pub fn set_metadata(&mut self, value: Dictionary) {
|
||||
unsafe {
|
||||
av_frame_set_metadata(self.as_mut_ptr(), value.disown());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn side_data(&self, kind: side_data::Type) -> Option<SideData> {
|
||||
unsafe {
|
||||
let ptr = av_frame_get_side_data(self.as_ptr(), kind.into());
|
||||
|
@ -22,9 +22,9 @@ impl Video {
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn alloc(&mut self, format: format::Pixel, width: u32, height: u32) {
|
||||
self.set_format(format)
|
||||
.set_width(width)
|
||||
.set_height(height);
|
||||
self.set_format(format);
|
||||
self.set_width(width);
|
||||
self.set_height(height);
|
||||
|
||||
av_frame_get_buffer(self.as_mut_ptr(), 32);
|
||||
}
|
||||
@ -61,12 +61,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[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()).format = mem::transmute::<AVPixelFormat, c_int>(value.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -77,12 +75,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_kind(&mut self, value: picture::Type) -> &mut Self {
|
||||
pub fn set_kind(&mut self, value: picture::Type) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).pict_type = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -114,12 +110,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]
|
||||
@ -130,12 +124,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]
|
||||
@ -146,12 +138,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_space(&mut self, value: color::Space) -> &mut Self {
|
||||
pub fn set_color_space(&mut self, value: color::Space) {
|
||||
unsafe {
|
||||
av_frame_set_colorspace(self.as_mut_ptr(), value.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -162,12 +152,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_range(&mut self, value: color::Range) -> &mut Self {
|
||||
pub fn set_color_range(&mut self, value: color::Range) {
|
||||
unsafe {
|
||||
av_frame_set_color_range(self.as_mut_ptr(), value.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -178,12 +166,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_primaries(&mut self, value: color::Primaries) -> &mut Self {
|
||||
pub fn set_color_primaries(&mut self, value: color::Primaries) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).color_primaries = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -194,12 +180,10 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_color_transfer_characteristic(&mut self, value: color::TransferCharacteristic) -> &mut Self {
|
||||
pub fn set_color_transfer_characteristic(&mut self, value: color::TransferCharacteristic) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).color_trc = value.into();
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
Loading…
x
Reference in New Issue
Block a user