avutil/common: add FFDIFFSIGN macro
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>
Fri, 30 Oct 2015 18:21:15 +0000 (14:21 -0400)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 11 Nov 2015 23:00:57 +0000 (00:00 +0100)
commit476ddffccbede4fdd3272b174b8f63a2e8125c8b
tree7dd9354073a0b2c110f412c42298716f7241777a
parentb533998d0a1da259b08c21a48de9cedb3e262348
avutil/common: add FFDIFFSIGN macro

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 this macro accordingly.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
(cherry picked from commit 265f83fd35977a80e93b3cc13ceb65f52f129a3c)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavutil/common.h