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

Ganesh Ajjanagadde gajjanag at mit.edu
Thu Nov 5 13:25:11 CET 2015


On Thu, Nov 5, 2015 at 6:05 AM, Moritz Barsnick <barsnick at gmx.net> wrote:
> 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?

Why not? Any decent compiler should - cos is a function with no side
effects, lending itself to "common subexpression elimination" or
whatever they call it.

>
> Thanks,
> Moritz
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list