[Ffmpeg-devel] [PATCH] cook: use bitshift instead of pow(f) func

Alexander Strasser eclipse7
Fri Feb 10 12:30:56 CET 2006


Hi,

  basically it is all in the subject. Why?

1 Because it is an integer operation anyway and this way it
  is easier to recognize it. The produced tables are identical.
2 The powf() function is not that widely supported yet, so when
  there is no need for it i don't see any reason to harm portability.

  Patch attached.

  If this solution is considered flawed or not acceptable for
one or the other reason, then at least consider changing powf()
to pow().

  Alex (beastd)
-------------- next part --------------
Index: libavcodec/cook.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/cook.c,v
retrieving revision 1.8
diff -u -r1.8 cook.c
--- libavcodec/cook.c	6 Feb 2006 11:21:10 -0000	1.8
+++ libavcodec/cook.c	10 Feb 2006 10:54:08 -0000
@@ -185,8 +185,8 @@
     int i;
     q->pow2tab[63] = 1.0;
     for (i=1 ; i<64 ; i++){
-        q->pow2tab[63+i]=(float)pow(2.0,(double)i);
-        q->pow2tab[63-i]=1.0/(float)pow(2.0,(double)i);
+        q->pow2tab[63+i]=(float)((uint64_t)1<<i);
+        q->pow2tab[63-i]=1.0/(float)((uint64_t)1<<i);
     }
 }
 
@@ -195,8 +195,8 @@
     int i;
     q->rootpow2tab[63] = 1.0;
     for (i=1 ; i<64 ; i++){
-        q->rootpow2tab[63+i]=sqrt((float)powf(2.0,(float)i));
-        q->rootpow2tab[63-i]=sqrt(1.0/(float)powf(2.0,(float)i));
+        q->rootpow2tab[63+i]=sqrt((float)((uint64_t)1<<i));
+        q->rootpow2tab[63-i]=sqrt(1.0/(float)((uint64_t)1<<i));
     }
 }
 



More information about the ffmpeg-devel mailing list