From da9587952a855db0e03f90f1f0d86f60318acc24 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 26 Apr 2012 01:35:22 +0200 Subject: [PATCH] swr: pass resample parameters from the user to the resampler. doxy and names stolen from avr Signed-off-by: Michael Niedermayer --- libswresample/swresample.c | 6 +++++- libswresample/swresample_internal.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libswresample/swresample.c b/libswresample/swresample.c index d8ead573f3..414d84cafb 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -72,6 +72,10 @@ static const AVOption options[]={ {"rectangular" , "Rectangular Dither" , 0 , AV_OPT_TYPE_CONST, {.dbl=SWR_DITHER_RECTANGULAR}, INT_MIN, INT_MAX , PARAM, "dither_method"}, {"triangular" , "Triangular Dither" , 0 , AV_OPT_TYPE_CONST, {.dbl=SWR_DITHER_TRIANGULAR }, INT_MIN, INT_MAX , PARAM, "dither_method"}, {"triangular_hp" , "Triangular Dither With High Pass" , 0 , AV_OPT_TYPE_CONST, {.dbl=SWR_DITHER_TRIANGULAR_HIGHPASS }, INT_MIN, INT_MAX, PARAM, "dither_method"}, +{"filter_size" , "Resampling Filter Size" , OFFSET(filter_size) , AV_OPT_TYPE_INT , {.dbl=16 }, 0 , INT_MAX , PARAM }, +{"phase_shift" , "Resampling Phase Shift" , OFFSET(phase_shift) , AV_OPT_TYPE_INT , {.dbl=10 }, 0 , 30 , PARAM }, +{"linear_interp" , "Use Linear Interpolation" , OFFSET(linear_interp) , AV_OPT_TYPE_INT , {.dbl=0 }, 0 , 1 , PARAM }, +{"cutoff" , "Cutoff Frequency Ratio" , OFFSET(cutoff) , AV_OPT_TYPE_DOUBLE,{.dbl=0.8 }, 0 , 1 , PARAM }, {0} }; @@ -215,7 +219,7 @@ int swr_init(struct SwrContext *s){ } if (s->out_sample_rate!=s->in_sample_rate || (s->flags & SWR_FLAG_RESAMPLE)){ - s->resample = swri_resample_init(s->resample, s->out_sample_rate, s->in_sample_rate, 16, 10, 0, 0.8, s->int_sample_fmt); + s->resample = swri_resample_init(s->resample, s->out_sample_rate, s->in_sample_rate, s->filter_size, s->phase_shift, s->linear_interp, s->cutoff, s->int_sample_fmt); }else swri_resample_free(&s->resample); if( s->int_sample_fmt != AV_SAMPLE_FMT_S16 diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h index 0575cece29..06578b8ee5 100644 --- a/libswresample/swresample_internal.h +++ b/libswresample/swresample_internal.h @@ -52,6 +52,10 @@ struct SwrContext { enum SwrDitherType dither_method; int dither_pos; float dither_scale; + int filter_size; /**< length of each FIR filter in the resampling filterbank relative to the cutoff frequency */ + int phase_shift; /**< log2 of the number of entries in the resampling polyphase filterbank */ + int linear_interp; /**< if 1 then the resampling FIR filter will be linearly interpolated */ + double cutoff; /**< resampling cutoff frequency. 1.0 corresponds to half the output sample rate */ int int_bps; ///< internal bytes per sample int resample_first; ///< 1 if resampling must come first, 0 if rematrixing