overflow fix
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 25 Jun 2004 18:39:57 +0000 (18:39 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 25 Jun 2004 18:39:57 +0000 (18:39 +0000)
Originally committed as revision 3250 to svn://svn.ffmpeg.org/ffmpeg/trunk

tests/tiny_psnr.c

index 84ad90e..572dd27 100644 (file)
@@ -68,9 +68,10 @@ static uint64_t log16(uint64_t a){
     a<<=16;
     
     for(i=19;i>=0;i--){
-        if(a<(exp16_table[i]<<16)) continue;
+        int64_t b= exp16_table[i];
+        if(a<(b<<16)) continue;
         out |= 1<<i;
-        a = ((a<<16) + exp16_table[i]/2)/exp16_table[i];
+        a = ((a/b)<<16) + (((a%b)<<16) + b/2)/b;
     }
     return out;
 }