[FFmpeg-devel] [PATCH] Yet more ALAC cleanup (#define removal)

Michael Niedermayer michaelni
Sat Aug 18 03:29:51 CEST 2007


Hi

On Sat, Aug 18, 2007 at 02:59:44AM +0200, Vitor wrote:
> Hi
> 
> On 8/18/07, Michael Niedermayer <michaelni at gmx.at> wrote:
> 
> [...]
> 
> > -#define SIGN_EXTENDED32(val, bits) ((val << (32 - bits)) >> (32 - bits))
> > > +static inline int32_t sign_extended32(int32_t val, int bits)
> > > +{
> > > +    return (val << (32 - bits)) >> (32 - bits);
> > > +}
> >
> > maybe
> >
> > X= (-1)<<(bits-1)
> > return (val+X)^X
> >
> > is faster?
> > X can be precalcualted if bits is const
> >
> 
> 
> I'm not really good in logical math, but it looks like this code do not give
> the same values. What looks to me to give the same values (with only one op
> if bits is const) is:
> 
>     int32_t x = 0;
>     x = (~x) >> bits;
>     return val & x;
> 
> Am I missing something?

yes, val is signed
and the function / macro is called sign extend not mask out the evil bits that
i fear :)


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

If you really think that XML is the answer, then you definitly missunderstood
the question -- Attila Kinali
-------------- 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/20070818/df87d0c1/attachment.pgp>



More information about the ffmpeg-devel mailing list