[FFmpeg-devel] [PATCH] Yet more ALAC cleanup (#define removal)
Vitor Sessak
vitor1001
Thu Aug 16 03:37:03 CEST 2007
Hi
Aurelien Jacobs wrote:
>>> Reimar D?ffinger wrote:
>>>> On Wed, Aug 15, 2007 at 08:22:59PM +0200, Vitor Sessak wrote:
>>>>> -#define SIGN_ONLY(v) \
>>>>> - ((v < 0) ? (-1) : \
>>>>> - ((v > 0) ? (1) : \
>>>>> - (0)))
>>>>> +static inline int sign_only(int v)
>>>>> +{
>>>>> + if (v < 0)
>>>>> + return -1;
>>>>> + else if (v > 0)
>>>>> + return 1;
>>>>> + else
>>>>> + return 0;
>>>>> +}
>>>> Since you change it anyway, I'd suggest
>>>> if (v == 0) return 0;
>>>> return FFSIGN(v);
>>>> Though benchmarking it might be a good idea unless it is really
>>>> uncritical.
>>>> Greetings,
>>>> Reimar D?ffinger
>>> Nice suggestion, but I don't think it is worth benchmarking. Unless the
>>> compiler is very stupid,
>> anyone did a IQ test with gcc lately?
>>
>> anyway, if you benchmark it, also try
>> (v>>31)-((-v)>>31)
>
> And maybe also this similar solution:
> !!v | v>>31
Interestingly, (v>>31)-((-v)>>31) is as fast as the FFSIGN
implementation and the !!v is slower. I wonder if it's different for
other architectures/compilers. I propose to apply the patch with the
FFSIGN (which is easier to read). Ok to apply?
-Vitor
More information about the ffmpeg-devel
mailing list