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

Måns Rullgård mans
Mon Jan 18 00:23:59 CET 2010


M?ns Rullg?rd <mans at mansr.com> writes:

>>> /** divide the motion vector mv by 4 */
>>> #define IVI_MV_DIV4(mv) (((mv) + 1 + ((mv) > 0))>>2)
>>> 
>>> /** divide the motion vector mv by 2 */
>>> #define IVI_MV_DIV2(mv) (((mv) + ((mv) > 0))>>1)
>>
>> Since the mv == 0 case does not matter, you should be able to avoid
>> the comparison by
>> static inline int32_t ivi_mv_div4(int32_t mv)
>> {
>>     return (mv + 2 - ((uint32_t)mv >> 31)) >> 2;
>> }
>
> Might make sense to create some common macros/functions for rounding
> division of signed numbers.  The fastest way probably differs between
> architectures.

And that would be RSHIFT() from common.h.  Yes, that's a terrible name
to have in a public header.

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



More information about the ffmpeg-devel mailing list