• Ganesh Ajjanagadde's avatar
    swresample/resample: speed up build_filter for Blackman-Nuttall filter · c8780822
    Ganesh Ajjanagadde authored
    This uses the trigonometric double and triple angle formulae to avoid
    repeated (expensive) evaluation of libc's cos().
    
    Sample benchmark (x86-64, Haswell, GNU/Linux)
    test: fate-swr-resample-dblp-44100-2626
    old:
    1104466600 decicycles in build_filter(loop 1000),     256 runs,      0 skips
    1096765286 decicycles in build_filter(loop 1000),     512 runs,      0 skips
    1070479590 decicycles in build_filter(loop 1000),    1024 runs,      0 skips
    
    new:
    588861423 decicycles in build_filter(loop 1000),     256 runs,      0 skips
    591262754 decicycles in build_filter(loop 1000),     512 runs,      0 skips
    577355145 decicycles in build_filter(loop 1000),    1024 runs,      0 skips
    
    This results in small differences with the old expression:
    difference (worst case on [0, 2*M_PI]), argmax 0.008:
    max diff (relative): 0.000000000000157289807188
    blackman_old(0.008): 0.000363951585488813192382
    blackman_new(0.008): 0.000363951585488755946507
    
    These are judged to be insignificant for the performance gain. PSNR to
    reference file is unchanged up to second decimal point for instance.
    Reviewed-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
    Signed-off-by: 's avatarGanesh Ajjanagadde <gajjanagadde@gmail.com>
    c8780822
Name
Last commit
Last update
..
aarch64 Loading commit data...
arm Loading commit data...
x86 Loading commit data...
Makefile Loading commit data...
audioconvert.c Loading commit data...
audioconvert.h Loading commit data...
dither.c Loading commit data...
dither_template.c Loading commit data...
libswresample.v Loading commit data...
log2_tab.c Loading commit data...
noise_shaping_data.c Loading commit data...
options.c Loading commit data...
rematrix.c Loading commit data...
rematrix_template.c Loading commit data...
resample.c Loading commit data...
resample.h Loading commit data...
resample_dsp.c Loading commit data...
resample_template.c Loading commit data...
soxr_resample.c Loading commit data...
swresample-test.c Loading commit data...
swresample.c Loading commit data...
swresample.h Loading commit data...
swresample_frame.c Loading commit data...
swresample_internal.h Loading commit data...
swresampleres.rc Loading commit data...
version.h Loading commit data...