[FFmpeg-devel] [PATCH 02/14] libavcodec: Implementation of AAC_fixed_decoder (LC-module) [2/5]
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Mon Sep 1 20:18:30 CEST 2014
On Mon, Sep 01, 2014 at 07:55:40PM +0200, Nedeljko Babic wrote:
> +/* 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.
More information about the ffmpeg-devel
mailing list