[FFmpeg-devel] [PATCH] AAC: type puns for 16 bit floating point rounding

Måns Rullgård mans
Thu Dec 4 13:40:36 CET 2008


Michael Niedermayer wrote:
> On Thu, Dec 04, 2008 at 03:13:57AM +0000, M?ns Rullg?rd wrote:
>> "Alex Converse" <alex.converse at gmail.com> writes:
>>
>> > Hi,
>> >
>> > Attached is the remaing patch from the AAC Main series with the
>> > rounding functions rewritten as suggested to do arithmetic in the
>> > integer domain rather than the floating point domain.
>> >
>> > A configure check has been added as suggested but I'm not happy with
>> > it. Any input on this is greatly appreciated.
>> >
>> > Regards,
>> > Alex Converse
>> >
>> > diff --git a/configure b/configure
>> > index 605bf3f..035e939 100755
>> > --- a/configure
>> > +++ b/configure
>> > @@ -844,6 +844,7 @@ HAVE_LIST="
>> >      gethrtime
>> >      GetProcessTimes
>> >      getrusage
>> > +    ieee754_pun
>> >      imlib2
>> >      inet_aton
>> >      inline_asm
>> > @@ -1800,6 +1801,13 @@ EOF
>> >  od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
>> >
>> >  # ---
>> > +# IEEE float test
>> > +check_cc <<EOF || die "IEEE float test failed"
>> > +float f[3] = {218387568.0f, 218387568.0f, 218387568.0f };
>> > +EOF
>> > +strings $TMPO | grep -E -q 'MPEGMPEGMPEG|GEPMGEPMGEPM' && enable
>> ieee754_pun
>>
>> That test isn't portable.  However, I think it's safe to assume
>> IEEE754 floats.  I doubt anyone will ever run FFmpeg on a VAX, and
>> it's already broken on Cray since we assume two's complement signed
>> integers.
>
> Arent there some floating point emulators (for FPUless CPUs) that use non
> IEEE floats?

Softfloat libraries tend to use IEEE format since a lot of code expects
that, not only in bit representations, but in precision, range etc.

> No i cant point to a specific real world case, its just that
> if i was writing one, i would use 8/16/32 bit "words" instead of squeezing
> bits in a 32bit IEEE float with an implicit leading bit.
> Also libavutil/softfloat.c/h is non IEEE, though its AFAIK not used by
> anyone, people maybe prefer emulators doing lots of uneeded IEEE bit packing

That's not going to be used by any compiler, and that's what matters here.

> besides, i do prefer a IEEE float detection that detects all IEEE systems and
> maybe misdetects some hypotetical non IEEE systems over no detection at all.

Checking for IEEE754 floats is about as meaningful as checking for two's
complement integers.  There are machines using other formats, but I very
much doubt anyone is running FFmpeg on them.  I doubt FFmpeg would even
build on those systems.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list