[FFmpeg-devel] [PATCH] Yet more ALAC cleanup (#define removal)
Vitor
vitor1001
Sat Aug 18 02:59:44 CEST 2007
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?
-Vitor
More information about the ffmpeg-devel
mailing list