[FFmpeg-cvslog] swr: pass resample parameters from the user to the resampler.

Michael Niedermayer git at videolan.org
Thu Apr 26 01:51:10 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Apr 26 01:35:22 2012 +0200| [da9587952a855db0e03f90f1f0d86f60318acc24] | committer: Michael Niedermayer

swr: pass resample parameters from the user to the resampler.

doxy and names stolen from avr

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=da9587952a855db0e03f90f1f0d86f60318acc24
---

 libswresample/swresample.c          |    6 +++++-
 libswresample/swresample_internal.h |    4 ++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index d8ead57..414d84c 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 0575cec..06578b8 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



More information about the ffmpeg-cvslog mailing list