[FFmpeg-cvslog] avcodec: improve precission for cbrtf() emulation

Michael Niedermayer git at videolan.org
Tue Oct 15 21:14:04 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Oct 15 20:06:44 2013 +0200| [59352a07d856a67b81fe3480ac4644a92beac113] | committer: Michael Niedermayer

avcodec: improve precission for cbrtf() emulation

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 at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=59352a07d856a67b81fe3480ac4644a92beac113
---

 libavcodec/cbrt_tablegen.h      |    2 +-
 libavcodec/mpegaudio_tablegen.h |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h
index 5ef97c8..0db64fc 100644
--- a/libavcodec/cbrt_tablegen.h
+++ b/libavcodec/cbrt_tablegen.h
@@ -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;
         }
     }
diff --git a/libavcodec/mpegaudio_tablegen.h b/libavcodec/mpegaudio_tablegen.h
index 1e1a382..60303b1 100644
--- a/libavcodec/mpegaudio_tablegen.h
+++ b/libavcodec/mpegaudio_tablegen.h
@@ -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;



More information about the ffmpeg-cvslog mailing list