[FFmpeg-devel] [Issue 664] [PATCH] Fix AAC PNS Scaling

Uoti Urpala uoti.urpala
Tue Oct 7 23:02:26 CEST 2008


On Tue, 2008-10-07 at 16:40 -0400, Alex Converse wrote:
> On Tue, Oct 7, 2008 at 4:27 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Tue, Oct 07, 2008 at 03:23:50PM -0400, Alex Converse wrote:
> >> +/** Fast Carmack-Lomont 1/sqrtf(), see Lomont 2003 */
> >> +static float inv_sqrtf(float x) {
> >> +    union { float f; int i; } pun;
> >> +    float xhalf = 0.5f*x;
> >> +    pun.f = x;
> >> +    pun.i = 0x5f3759df - (pun.i>>1);
> >> +    x = pun.f;
> >> +    x = x*(1.5f-xhalf*x*x);
> >> +    return x;
> >> +}

> > that stuff is not portable, it contains assumtations about endianness
> > and sizes of int and float.
> >
> 
> Are you sure it's endian specific?

I think not endian specific, but it assumes that ints and floats are
both 32 bits.

> Is there an integer size guaranteed to be sizeof(float)?

That alone wouldn't make it more general; you'd at least need a
different constant in stead of 0x5f3759df if floats are not 32 bits.
int32_t is the best type you can use without modifying the rest of the
code.





More information about the ffmpeg-devel mailing list