[FFmpeg-devel] [PATCH] swresample/resample: speed up build_filter for Blackman-Nuttall filter

Moritz Barsnick barsnick at gmx.net
Thu Nov 5 12:05:02 CET 2015


On Wed, Nov 04, 2015 at 22:08:27 -0500, Ganesh Ajjanagadde wrote:
> This uses the trigonometric double and triple angle formulae to avoid
> repeated (expensive) evaluation of libc's cos().
[...]
> -                y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 0.0106411 * cos(3*w);
> +                y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * (2*cos(w)*cos(w)-1) - 0.0106411 * (4*cos(w)*cos(w)*cos(w) - 3*cos(w));

Q: Does the compilers' optimization ensure that cos(w) is evaluated
only once?

Thanks,
Moritz


More information about the ffmpeg-devel mailing list