[FFmpeg-devel] [PATCH 02/14] libavcodec: Implementation of AAC_fixed_decoder (LC-module) [2/5]

Nedeljko Babic Nedeljko.Babic at imgtec.com
Tue Sep 2 11:44:27 CEST 2014


>> +/* Rounding to zero used for simplicity */
>> +static av_always_inline aac_float_t float_add(aac_float_t a, aac_float_t b)
>> +{
>> +    int diff;
>> +
>> +    if (a.mant == 0)
>> +        return b;
>> +
>> +    if (b.mant == 0)
>> +        return a;
>> +
>> +    diff = a.expo - b.expo;
>> +
>> +    if (diff < 0)  // a.expo < b.expo
>> +    {
>> +        diff = -diff;
>> +        if (diff >= 31)
>> +            a.mant = 0;
>> +        else
>> +            a.mant >>= diff;
>> +        a.expo = b.expo;
>> +    }
>> +    else  // a.expo >= b.expo
>> +    {
>> +        if (diff >= 31)
>> +            b.mant = 0;
>> +        else
>> +            b.mant >>= diff;
>> +    }
>
>In addition to the comments I had before, if you care only
>about (mostly) matching single-precision IEEE you can
>save some cycles by changing to diff > 24 instead
>of >= 31.
>Obviously that means you need to change the
>code to directly return e.g. a in the else
>path instead of insisting on explicitly
>adding 0 to a, otherwise it won't get any faster of course.

The idea for this entire emulation was not to make IEEE compliant emulation, but 
to create a tool that is used in aac fixed point decoder on places where dynamical 
range is to large for fixed point operations to be used.

Probably our mistake was in that we didn't put a comment regarding this in the file, 
but it was easily overlooked since this patch is part of the patch set that implements 
fixed point AAC decoder and not stand alone patch for implementing float emulation.
Also name for this file should probably be changed back to aac_float_emu.h instead 
float_emu.h to emphasize this.

Having this in mind, changing diff >= 31 with > 24 here is not an option unless entire 
algorithm is changed.


More information about the ffmpeg-devel mailing list