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

Reimar Döffinger Reimar.Doeffinger
Sun Jan 17 22:41:48 CET 2010


On Sun, Jan 17, 2010 at 09:37:07PM +0000, M?ns Rullg?rd wrote:
> Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
> 
> > On Fri, Jan 15, 2010 at 11:45:00AM +0200, Kostya wrote:
> >> /** 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.
> 
> Why is inline better in this case?

Not in this case specifically.
With a macro you have multiple evaluation issues, you need to add annoying
() and you can't sanely simplify the code by using variables for
intermediate values (the + 1 in the original code here) or early returns.
So unless you have to suspect the compiler will mess up or you have
more than one return value or need it to work for different types
IMO you shouldn't be using a macro.



More information about the ffmpeg-devel mailing list