[FFmpeg-devel] [PATCHv4] VP4 video decoder

Reimar Döffinger Reimar.Doeffinger at gmx.de
Wed May 22 22:45:46 EEST 2019


On Tue, May 21, 2019 at 09:30:54PM +0200, Reimar Döffinger wrote:
> > +#define SHIFT(v, shift) ((v) >> (shift))
> > +#define ABS_SHIFT(v, shift) ((v) > 0 ? SHIFT(v, shift) : -SHIFT(-v, shift))
>
> Don't we have something like that already?

Seems we don't

> I think this should rather be:
> (v - (v >> 31)) >> shift
> ?

Not right for shift > 1.
But this one according to my testing is equivalent:
((a + (a >> 31)) >> b) - (a >> 31)
Not certain it will be fewer instructions,
but it is branchless.
On some ISAs the simple
a / (1 << b)
might even be faster, so maybe worth
going for that...


More information about the ffmpeg-devel mailing list