]> git.sesse.net Git - ffmpeg/commitdiff
avcodec: improve precission for cbrtf() emulation
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 15 Oct 2013 18:06:44 +0000 (20:06 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 15 Oct 2013 19:03:03 +0000 (21:03 +0200)
cbrtf() took floats but it represented 1/3 exactly
and even if not more precission should be better in theory
for the table generation

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/cbrt_tablegen.h
libavcodec/mpegaudio_tablegen.h

index 5ef97c854555d3796be573d09b2c96ae175f6f5f..0db64fcf954cf2a40dab371c270371b95d711aba 100644 (file)
@@ -42,7 +42,7 @@ static void cbrt_tableinit(void)
                 float f;
                 uint32_t i;
             } f;
-            f.f = powf(i, 1.0 / 3.0) * i;
+            f.f = pow(i, 1.0 / 3.0) * i;
             cbrt_tab[i] = f.i;
         }
     }
index 1e1a38296b9b6798998524fa300c71ebc44eb5c1..60303b16adb984ff325f4866f3fca356ed0c6d7d 100644 (file)
@@ -49,7 +49,7 @@ static void mpegaudio_tableinit(void)
         double f, fm;
         int e, m;
         /* cbrtf() isn't available on all systems, so we use powf(). */
-        f  = value / IMDCT_SCALAR * powf(value, 1.0 / 3.0) * pow(2, (i & 3) * 0.25);
+        f  = value / IMDCT_SCALAR * pow(value, 1.0 / 3.0) * pow(2, (i & 3) * 0.25);
         fm = frexp(f, &e);
         m  = (uint32_t)(fm * (1LL << 31) + 0.5);
         e += FRAC_BITS - 31 + 5 - 100;
@@ -61,7 +61,7 @@ static void mpegaudio_tableinit(void)
     for (exponent = 0; exponent < 512; exponent++) {
         for (value = 0; value < 16; value++) {
             /* cbrtf() isn't available on all systems, so we use powf(). */
-            double f = (double)value * powf(value, 1.0 / 3.0) * pow(2, (exponent - 400) * 0.25 + FRAC_BITS + 5) / IMDCT_SCALAR;
+            double f = (double)value * pow(value, 1.0 / 3.0) * pow(2, (exponent - 400) * 0.25 + FRAC_BITS + 5) / IMDCT_SCALAR;
             /* llrint() isn't always available, so round and cast manually. */
             expval_table_fixed[exponent][value] = (long long int) (f >= 0 ? floor(f + 0.5) : ceil(f - 0.5));
             expval_table_float[exponent][value] = f;