]> git.sesse.net Git - ffmpeg/commit
avutil/mathematics: correct documentation for av_gcd
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>
Wed, 28 Oct 2015 00:11:40 +0000 (20:11 -0400)
committerGanesh Ajjanagadde <gajjanagadde@gmail.com>
Fri, 30 Oct 2015 17:42:04 +0000 (13:42 -0400)
commit20a30077c3659e6dc0c5b9dfa08d39b70a6b5f4e
tree60278cfb15cdcf5e0556270f50cbfd3aba56dfbd
parente8e7eb150f152c9e4858ef0be3e76e4f98533cf6
avutil/mathematics: correct documentation for av_gcd

av_gcd is now always defined regardless of input. This documents this
change in the "documented API". Two benefits (closely related):
1. The function is robust, and there is no need to worry about INT64_MIN, etc.

2. Clients of av_gcd, like av_reduce, can now be made fully correct. Currently,
av_reduce can trigger undefined behavior if e.g num is INT64_MIN due to
integer overflow in the FFABS. Furthermore, this undefined behavior is
completely undocumented, and could be a fuzzer's paradise. The FFABS was needed in the past as
av_gcd was undefined for negative inputs. In order to make av_reduce
robust, it is essential to guarantee that av_gcd works for all int64_t.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
libavutil/mathematics.h