mpegaudio_tablegen: Don't use llrint

You cannot count on it being present on all systems, and you
cannot include libm.h in a host tool, so just hard code a baseline
implementation.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
Derek Buitenhuis 2013-01-15 16:28:05 -05:00
parent 5086720993
commit e516921143
1 changed files with 2 additions and 1 deletions

View File

@ -62,7 +62,8 @@ static void mpegaudio_tableinit(void)
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;
expval_table_fixed[exponent][value] = llrint(f);
/* 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;
}
exp_table_fixed[exponent] = expval_table_fixed[exponent][1];