mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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@gmx.at>
This commit is contained in:
parent
e516921143
commit
59352a07d8
@ -42,7 +42,7 @@ static void cbrt_tableinit(void)
|
|||||||
float f;
|
float f;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
} f;
|
} f;
|
||||||
f.f = powf(i, 1.0 / 3.0) * i;
|
f.f = pow(i, 1.0 / 3.0) * i;
|
||||||
cbrt_tab[i] = f.i;
|
cbrt_tab[i] = f.i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ static void mpegaudio_tableinit(void)
|
|||||||
double f, fm;
|
double f, fm;
|
||||||
int e, m;
|
int e, m;
|
||||||
/* cbrtf() isn't available on all systems, so we use powf(). */
|
/* 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);
|
fm = frexp(f, &e);
|
||||||
m = (uint32_t)(fm * (1LL << 31) + 0.5);
|
m = (uint32_t)(fm * (1LL << 31) + 0.5);
|
||||||
e += FRAC_BITS - 31 + 5 - 100;
|
e += FRAC_BITS - 31 + 5 - 100;
|
||||||
@ -61,7 +61,7 @@ static void mpegaudio_tableinit(void)
|
|||||||
for (exponent = 0; exponent < 512; exponent++) {
|
for (exponent = 0; exponent < 512; exponent++) {
|
||||||
for (value = 0; value < 16; value++) {
|
for (value = 0; value < 16; value++) {
|
||||||
/* cbrtf() isn't available on all systems, so we use powf(). */
|
/* 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. */
|
/* 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_fixed[exponent][value] = (long long int) (f >= 0 ? floor(f + 0.5) : ceil(f - 0.5));
|
||||||
expval_table_float[exponent][value] = f;
|
expval_table_float[exponent][value] = f;
|
||||||
|
Loading…
Reference in New Issue
Block a user