From: Michael Niedermayer Date: Tue, 15 Oct 2013 18:06:44 +0000 (+0200) Subject: avcodec: improve precission for cbrtf() emulation X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=59352a07d856a67b81fe3480ac4644a92beac113;p=ffmpeg 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 --- diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h index 5ef97c85455..0db64fcf954 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 1e1a38296b9..60303b16adb 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;