[FFmpeg-devel] [PATCH 1/3] Indeo 5 decoder: common functions

Måns Rullgård mans
Mon Jan 18 00:42:37 CET 2010


Maxim <max_pole at gmx.de> writes:

> Reimar D?ffinger schrieb:
>> [...]
>>> static inline int ivi_pic_config_cmp(IVIPicConfig *str1, IVIPicConfig *str2)
>>>     
>>
>> No documentation.
>>
>>   
>>> /** convert unsigned values into signed ones (the sign is in the LSB) */
>>> /* TODO: find a way to calculate this without the conditional using bit magic */
>>> #define IVI_TOSIGNED(val) (((val) & 1) ? ((val) + 1) >> 1 : -(((val) + 1) >> 1))
>>>     
>>
>> I'm sure this kind of code is already in other decoders.
>> However the + 1 in the part after : sure is useless.
>> Also I strongly suggest to make this a static inline function.
>> And bit magic to do it should be
>> ((sign_extend(val & 1, 1) ^ val) >> 1) + 1
>>   
>
> Ok, I suggest the following bitexact replacement:
>
> -((val >> 1) ^ -(val & 1));

Is val signed or unsigned there?

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list