[FFmpeg-devel] Input requested on floating point decomposition for AAC Main

Alex Converse alex.converse
Tue Nov 11 07:39:05 CET 2008

To do 16-bit floating point rounding for AAC-Main, I need a function
that will decompose a float into a normalized scheme and it's
exponent. Conveniently there exists the x87 instruction FXTRACT for
this very purpose. There are also a variety of standard library

Once computations are done in this space I need to reverse the process
with, a * 2 ** b, There exists x87 FSCALE for this.

Callgrind shows the decoder spending a ridiculous amount of time in
these functions so, they are speed critical

float frexpf(float a, int* b) - uses RADIX 2, from C99 (double version
from SVr4, 4.3BSD, C89) - glibc implementation is a long mess with no
int ilogbf(float) - uses FLT_RADIX from C99 - glibc uses fxtract with
a lot of extra crap "because ilogb(+-Inf) is required to return
float logbf(float) - uses FLT_RADIX, from C99 - glibc uses simple fxtract
float significandf(float) - FLT_RADIX (I think?), _SVID_SOURCE ||
_BSD_SOURCE - glibc uses simple fxtract

float scalbf(float a, float b) - a * FLT_RADIX ** b, from 4.3BSD and
POSIX.1-2001, marked obsolete (in favor of scalbnf) - This function
looks like a big mess on glibc x86 (no fscale)
float scalbnf(float a, int b) - a * FLT_RADIX ** b, from C99 and
POSIX.1-2001 - glibc x86 uses fscale
float ldexpf(float a, int b) - a * 2 **b, from C99 (the double version
is from SVr4, 4.3BSD, C89) - glibc implementation wraps scalbnf with
extra checks

Now I have some problems here, there is the whole FLT_RADIX vs base 2
thing. I can't seem to find much on the topic of FLT_RADIX except that
it's usually 2. Another thing to worry about is that zero is a special
case with floating point numbers and must be handled with the utmost

To me, it seems like the only sane solution is to write assembly for
x86 and uses the venerable double versions of frexp and ldexp
elsewhere. Am I missing a better choice?

Alex Converse

More information about the ffmpeg-devel mailing list