Re: [FFmpeg-devel] [PATCH 1/2] avutil/common: add FFDIFFSIGN macro

2015-11-03 Thread Ganesh Ajjanagadde
On Sun, Nov 1, 2015 at 5:54 PM, Michael Niedermayer wrote: > On Sun, Nov 01, 2015 at 12:19:47PM -0500, Ganesh Ajjanagadde wrote: >> This is of use for defining comparator callbacks. Common approaches like >> return x-y are not safe due to the risks of overflow. >> Furthermore, the (x > y) - (x < y

Re: [FFmpeg-devel] [PATCH 1/2] avutil/common: add FFDIFFSIGN macro

2015-11-01 Thread Michael Niedermayer
On Sun, Nov 01, 2015 at 12:19:47PM -0500, Ganesh Ajjanagadde wrote: > This is of use for defining comparator callbacks. Common approaches like > return x-y are not safe due to the risks of overflow. > Furthermore, the (x > y) - (x < y) trick is optimized to branchless > code. > This also documents