[FFmpeg-devel] AAC-Main (round 2)

Michael Niedermayer michaelni
Thu Nov 20 11:08:35 CET 2008


On Wed, Nov 19, 2008 at 01:42:55PM -0500, Alex Converse wrote:
[...]
> diff --git a/libavcodec/aac.c b/libavcodec/aac.c
> index 1ad0a58..9fb242b 100644
> --- a/libavcodec/aac.c
> +++ b/libavcodec/aac.c
> @@ -91,6 +91,11 @@
>  #include <math.h>
>  #include <string.h>
>  
> +#ifdef ARCH_X86
> +#define USE_754_PUNS
> +union float754 { float f; uint32_t i; };
> +#endif

The correctness of the USE_754_PUNS code could be tested by configure


> +
>  static VLC vlc_scalefactors;
>  static VLC vlc_spectral[11];
>  
> @@ -838,24 +843,70 @@ static int decode_spectrum_and_dequant(AACContext * ac, float coef[1024], GetBit
>  }
>  
>  static av_always_inline float flt16_round(float pf) {
> +#ifdef USE_754_PUNS

> +    union float754 tmp, tmp1, tmp2;
> +    uint32_t flg;
> +    
> +    tmp.f = pf;
> +    flg = tmp.i & 0x00008000U;
> +    tmp.i &= 0xFFFF0000U;
> +    if (flg) {
> +        tmp1 = tmp;
> +        tmp.i &= 0xFF800000U;
> +        tmp.i |= 0x00010000U;
> +        tmp2 = tmp;
> +        tmp.i &= 0xFF800000U;
> +        tmp.f = tmp1.f + tmp2.f - tmp.f;
> +    }
> +    return tmp.f;

tmp.f = pf;
tmp.i = (tmp.i + 0x8000) & ~0xFFFF;
return tmp.f;


> +#else
>      int exp;
>      pf = frexpf(pf, &exp);
>      pf = ldexpf(roundf(ldexpf(pf, 8)), exp-8);
>      return pf;
> +#endif
>  }
>  
>  static av_always_inline float flt16_even(float pf) {
> +#ifdef USE_754_PUNS
> +    union float754 tmp, tmp1, tmp2;
> +    uint32_t flg;
> +    
> +    tmp.f = pf;
> +    flg = tmp.i & 0x0001FFFFU;
> +    tmp.i &= 0xFFFE0000U;
> +    if (flg <= 0x00008000U) {
> +    } else if (flg < 0x00018000U) {
> +        tmp.i |= 0x00010000U;
> +    } else {
> +        tmp.i |= 0x00010000U;
> +        tmp1 = tmp;
> +        tmp.i &= 0xFF810000U;
> +        tmp2 = tmp;
> +        tmp.i &= 0xFF800000U;
> +        tmp.f = tmp1.f + tmp2.f - tmp.f;
> +    }
> +    return tmp.f;

this likely can be optimized similarly

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081120/b5ef6ece/attachment.pgp>



More information about the ffmpeg-devel mailing list