[Ffmpeg-cvslog] r8474 - trunk/libavcodec/resample2.c

Rich Felker dalias
Thu Mar 22 04:50:06 CET 2007


On Thu, Mar 22, 2007 at 01:52:49AM +0100, michael wrote:
> Author: michael
> Date: Thu Mar 22 01:52:49 2007
> New Revision: 8474
> 
> Modified:
>    trunk/libavcodec/resample2.c
> 
> Log:
> optimize bessel function instead of trusting gcc to do trivial optimizations (as gcc doesnt ...)
> 
> 
> Modified: trunk/libavcodec/resample2.c
> ==============================================================================
> --- trunk/libavcodec/resample2.c	(original)
> +++ trunk/libavcodec/resample2.c	Thu Mar 22 01:52:49 2007
> @@ -71,9 +71,10 @@ static double bessel(double x){
>      double t=1;
>      int i;
>  
> +    x= x*x/4;
>      for(i=1; i<50; i++){
> -        t *= i;
> -        v += pow(x*x/4, i)/(t*t);
> +        t *= x/(i*i);
> +        v += t;

This is not trivial and most likely an illegal optimization for the
compiler to make. As soon as you go to floating point, algebraic
identities simply fail to hold in the general case, and
"optimizations" using them will make code do the wrong things in
corner cases. You may not care about the corner cases, but the
compiler can't know that. So floating point optimization of this sort
always needs to be done explicitly by the coder.

Rich




More information about the ffmpeg-cvslog mailing list