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... _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".