Commit ac25b31e authored by Alexander Strasser's avatar Alexander Strasser

lswr: Improve default resampler's default parameters

After making some blind tests on a small collection of music
samples for home usage. It turned out that the default cutoff
was too low.

The impact of filter_size was not clearly distinguishable (the
results were on the edge) with the music samples but turned out
to be clearly audible in some synthetic samples.

Thanks to Daniel for helping out with the listening tests.
Signed-off-by: 's avatarAlexander Strasser <eclipse7@gmx.net>
parent a08194b4
...@@ -121,7 +121,7 @@ case. ...@@ -121,7 +121,7 @@ case.
@end table @end table
@item filter_size @item filter_size
For swr only, set resampling filter size, default value is 16. For swr only, set resampling filter size, default value is 32.
@item phase_shift @item phase_shift
For swr only, set resampling phase shift, default value is 10, must be included For swr only, set resampling phase shift, default value is 10, must be included
...@@ -132,7 +132,7 @@ Use Linear Interpolation if set to 1, default value is 0. ...@@ -132,7 +132,7 @@ Use Linear Interpolation if set to 1, default value is 0.
@item cutoff @item cutoff
Set cutoff frequency (swr: 6dB point; soxr: 0dB point) ratio; must be a float Set cutoff frequency (swr: 6dB point; soxr: 0dB point) ratio; must be a float
value between 0 and 1. Default value is 0.8 with swr, and 0.91 with soxr value between 0 and 1. Default value is 0.97 with swr, and 0.91 with soxr
(which, with a sample-rate of 44100, preserves the entire audio band to 20kHz). (which, with a sample-rate of 44100, preserves the entire audio band to 20kHz).
@item precision @item precision
......
...@@ -198,7 +198,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap ...@@ -198,7 +198,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear,
double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, int kaiser_beta, double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, int kaiser_beta,
double precision, int cheby){ double precision, int cheby){
double cutoff = cutoff0? cutoff0 : 0.8; double cutoff = cutoff0? cutoff0 : 0.97;
double factor= FFMIN(out_rate * cutoff / in_rate, 1.0); double factor= FFMIN(out_rate * cutoff / in_rate, 1.0);
int phase_count= 1<<phase_shift; int phase_count= 1<<phase_shift;
......
...@@ -80,7 +80,7 @@ static const AVOption options[]={ ...@@ -80,7 +80,7 @@ static const AVOption options[]={
{"triangular" , "select triangular dither" , 0 , AV_OPT_TYPE_CONST, {.i64=SWR_DITHER_TRIANGULAR }, INT_MIN, INT_MAX , PARAM, "dither_method"}, {"triangular" , "select triangular dither" , 0 , AV_OPT_TYPE_CONST, {.i64=SWR_DITHER_TRIANGULAR }, INT_MIN, INT_MAX , PARAM, "dither_method"},
{"triangular_hp" , "select triangular dither with high pass" , 0 , AV_OPT_TYPE_CONST, {.i64=SWR_DITHER_TRIANGULAR_HIGHPASS }, INT_MIN, INT_MAX, PARAM, "dither_method"}, {"triangular_hp" , "select triangular dither with high pass" , 0 , AV_OPT_TYPE_CONST, {.i64=SWR_DITHER_TRIANGULAR_HIGHPASS }, INT_MIN, INT_MAX, PARAM, "dither_method"},
{"filter_size" , "set swr resampling filter size", OFFSET(filter_size) , AV_OPT_TYPE_INT , {.i64=16 }, 0 , INT_MAX , PARAM }, {"filter_size" , "set swr resampling filter size", OFFSET(filter_size) , AV_OPT_TYPE_INT , {.i64=32 }, 0 , INT_MAX , PARAM },
{"phase_shift" , "set swr resampling phase shift", OFFSET(phase_shift) , AV_OPT_TYPE_INT , {.i64=10 }, 0 , 30 , PARAM }, {"phase_shift" , "set swr resampling phase shift", OFFSET(phase_shift) , AV_OPT_TYPE_INT , {.i64=10 }, 0 , 30 , PARAM },
{"linear_interp" , "enable linear interpolation" , OFFSET(linear_interp) , AV_OPT_TYPE_INT , {.i64=0 }, 0 , 1 , PARAM }, {"linear_interp" , "enable linear interpolation" , OFFSET(linear_interp) , AV_OPT_TYPE_INT , {.i64=0 }, 0 , 1 , PARAM },
{"cutoff" , "set cutoff frequency ratio" , OFFSET(cutoff) , AV_OPT_TYPE_DOUBLE,{.dbl=0. }, 0 , 1 , PARAM }, {"cutoff" , "set cutoff frequency ratio" , OFFSET(cutoff) , AV_OPT_TYPE_DOUBLE,{.dbl=0. }, 0 , 1 , PARAM },
......
c8ff13cf7ebece23af76502f5785202e *tests/data/fate/acodec-roqaudio.roq 75859976d7098588aeaebbc5551484a9 *tests/data/fate/acodec-roqaudio.roq
265992 tests/data/fate/acodec-roqaudio.roq 265992 tests/data/fate/acodec-roqaudio.roq
709fd60aea880c73b375094ab5307c77 *tests/data/fate/acodec-roqaudio.out.wav be6d954adaf984f2dc65a3ff50b55f26 *tests/data/fate/acodec-roqaudio.out.wav
stddev: 4610.71 PSNR: 23.05 MAXDIFF:43883 bytes: 1058400/ 1058400 stddev: 4481.70 PSNR: 23.30 MAXDIFF:46250 bytes: 1058400/ 1058400
6f9cfff48f536fa727696f2f9fb3ac08 *./tests/data/lavf/lavf.dv 11be3e5caa2892236b3475c3f7807b76 *./tests/data/lavf/lavf.dv
3600000 ./tests/data/lavf/lavf.dv 3600000 ./tests/data/lavf/lavf.dv
./tests/data/lavf/lavf.dv CRC=0x5ce4e5e4 ./tests/data/lavf/lavf.dv CRC=0x25bdd732
2e8989478f05f6d4eaf1921fdfac4799 *./tests/data/lavf/lavf.dv 7c789e3559b5102de9459211ae4acf06 *./tests/data/lavf/lavf.dv
3600000 ./tests/data/lavf/lavf.dv 3600000 ./tests/data/lavf/lavf.dv
./tests/data/lavf/lavf.dv CRC=0x747caf33 ./tests/data/lavf/lavf.dv CRC=0x3f43a4f5
87d3b20f656235671383a7eaa2f66330 *./tests/data/lavf/lavf.dv 87d3b20f656235671383a7eaa2f66330 *./tests/data/lavf/lavf.dv
3600000 ./tests/data/lavf/lavf.dv 3600000 ./tests/data/lavf/lavf.dv
./tests/data/lavf/lavf.dv CRC=0x0e868a82 ./tests/data/lavf/lavf.dv CRC=0x0e868a82
72e150dc3430a6a78656790658eb9a09 *./tests/data/lavf/lavf.gxf c8b3a8e3ba0185ce39122ac150c12bc3 *./tests/data/lavf/lavf.gxf
795876 ./tests/data/lavf/lavf.gxf 795876 ./tests/data/lavf/lavf.gxf
./tests/data/lavf/lavf.gxf CRC=0xaee412d1 ./tests/data/lavf/lavf.gxf CRC=0x147ff044
cb6b1f522a9a8df145f55905c63a65b6 *./tests/data/lavf/lavf.gxf 4c6594c58da57af745eb511bdd65bca7 *./tests/data/lavf/lavf.gxf
816752 ./tests/data/lavf/lavf.gxf 816752 ./tests/data/lavf/lavf.gxf
./tests/data/lavf/lavf.gxf CRC=0xb73759d8 ./tests/data/lavf/lavf.gxf CRC=0xfa7c375a
e4721383461d7a9feae41435567c9257 *./tests/data/lavf/lavf.gxf e4721383461d7a9feae41435567c9257 *./tests/data/lavf/lavf.gxf
795876 ./tests/data/lavf/lavf.gxf 795876 ./tests/data/lavf/lavf.gxf
./tests/data/lavf/lavf.gxf CRC=0xd9d58865 ./tests/data/lavf/lavf.gxf CRC=0xd9d58865
c53c9f7ee2091405fbe50374f9055679 *./tests/data/lavf/lavf.mxf 967f6ee9223c865328f4891465191108 *./tests/data/lavf/lavf.mxf
525369 ./tests/data/lavf/lavf.mxf 525369 ./tests/data/lavf/lavf.mxf
./tests/data/lavf/lavf.mxf CRC=0x17ce1069 ./tests/data/lavf/lavf.mxf CRC=0xdbfff6f1
14d0ac1513840b670a785daf4331aca8 *./tests/data/lavf/lavf.mxf ec951485333c0b320d2ede8692c602ae *./tests/data/lavf/lavf.mxf
554553 ./tests/data/lavf/lavf.mxf 554553 ./tests/data/lavf/lavf.mxf
./tests/data/lavf/lavf.mxf CRC=0x468cdbc4 ./tests/data/lavf/lavf.mxf CRC=0xfbaac0b0
5636cee18b0f34a5acb33a8efb9f80c6 *./tests/data/lavf/lavf.mxf ce535b606423d117675213b16275206a *./tests/data/lavf/lavf.mxf
525369 ./tests/data/lavf/lavf.mxf 525369 ./tests/data/lavf/lavf.mxf
./tests/data/lavf/lavf.mxf CRC=0x17ce1069 ./tests/data/lavf/lavf.mxf CRC=0xdbfff6f1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment