[FFmpeg-devel] [PATCH 2/9] avcodec/gdv: Replace divisions by shifts in rescale()

Nicolas George george at nsup.org
Mon Aug 6 00:37:24 EEST 2018

James Almer (2018-08-05):
> This patch makes the code slightly less readable, IMO. What compiler
> doesn't optimize out an integer division by 2 into a right shift?

Any compiler that cannot figure out that x is positive in this
convoluted loop. Signed divisions cannot be optimized as shifts. Make
everything unsigned and it will be fine.

But I do not understand the logic in having i going from 0 to w-1 just
to compute x from w-1 to 0.

	unsigned w, x;
	for (x = w - 1; x < w; x--)

would be better IMHO.


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180805/9bd056bc/attachment.sig>

More information about the ffmpeg-devel mailing list