ffmpeg/libavutil
Ganesh Ajjanagadde b7fb7c4542 avutil/mathematics: make av_gcd more robust
This ensures that no undefined behavior is invoked, while retaining
identical return values in all cases and at no loss of performance
(identical asm on clang and gcc).
Essentially, this patch exchanges undefined behavior with implementation
defined behavior, a strict improvement.

Rationale:
1. The ideal solution is to have the return type a uint64_t. This
unfortunately requires an API change.
2. The only pathological behavior happens if both arguments are
INT64_MIN, to the best of my knowledge. In such a case, the
implementation defined behavior is invoked in the sense that UINT64_MAX
is interpreted as INT64_MIN, which any reasonable implementation will
do. In any case, any usage where both arguments are INT64_MIN is a
fuzzer anyway.
3. Alternatives of checking, etc require branching and lose performance
for no concrete gain - no client cares about av_gcd's actual value when
both args are INT64_MIN. Even if it did, on sane platforms (e.g all the
ones FFmpeg cares about), it produces a correct gcd, namely INT64_MIN.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-29 19:13:55 -04:00
..
aarch64
arm avutil/attributes: add AV_GCC_VERSION_AT_MOST 2015-09-18 12:41:29 -03:00
avr32
bfin
mips mips: intreadwrite: Only execute that code for mips r1 or r2 2015-09-29 11:10:37 +02:00
ppc avutil/ppc/cpu: add include avassert.h 2015-06-05 19:12:58 +02:00
sh4
tomi
x86 lavu: add AESNI CPU flag 2015-10-28 04:23:14 -05:00
adler32.c avutil/adler32: Fix data type in test code 2015-06-19 02:25:48 +02:00
adler32.h
aes_internal.h lavu/aes: align AVAES struct members 2015-10-28 04:23:14 -05:00
aes.c lavu/aes: test CBC functionality 2015-10-28 09:38:21 -05:00
aes.h lavu: Drop deprecated context size variables 2015-08-28 16:04:27 +02:00
atomic_gcc.h
atomic_suncc.h
atomic_win32.h
atomic.c
atomic.h
attributes.h avutil/attributes: add av_warn_unused_result 2015-10-05 19:30:20 +02:00
audio_fifo.c avfilter: add showfreqs filter 2015-08-19 16:15:13 +00:00
audio_fifo.h avutil/audio_fifo: add av_warn_unused_result 2015-10-28 23:05:31 -04:00
avassert.h
avstring.c avutil/avstring: Inline some tiny functions 2015-10-03 13:45:37 +02:00
avstring.h avutil/avstring: add av_warn_unused_result 2015-10-27 23:16:09 -04:00
avutil.h doxygen: Remove lavu_internal group 2015-08-22 10:07:05 -07:00
avutilres.rc
base64.c
base64.h
blowfish.c avutil: undo FF_API_CRYPTO_CONTEXT deprecation 2015-10-16 19:13:38 -03:00
blowfish.h avutil: undo FF_API_CRYPTO_CONTEXT deprecation 2015-10-16 19:13:38 -03:00
bprint.c
bprint.h
bswap.h
buffer_internal.h
buffer.c
buffer.h
camellia.c avutil: use EINVAL instead of -1 for the return code of crypto related init functions 2015-10-18 15:17:58 -04:00
camellia.h
cast5.c avutil: use EINVAL instead of -1 for the return code of crypto related init functions 2015-10-18 15:17:58 -04:00
cast5.h avutil/cast5: update Doxygen for av_cast5_init with return information 2015-10-15 22:32:58 -04:00
channel_layout.c lavu: Drop FF_API_GET_CHANNEL_LAYOUT_COMPAT cruft 2015-09-05 20:36:19 +02:00
channel_layout.h Merge commit 'e23f84d9652474353d8bbc42787a56ec1991908f' 2015-08-24 10:40:24 +02:00
color_utils.c avutil/color_utils: Add basic transfer functions for each AVColorTransferCharacteristic 2015-09-10 23:53:05 +02:00
color_utils.h avutil/color_utils: Add basic transfer functions for each AVColorTransferCharacteristic 2015-09-10 23:53:05 +02:00
colorspace.h avutil/colorspace: Remove RGB_TO_Y/U/V 2015-06-06 18:21:01 +02:00
common.h Merge commit 'cdfe45ad371b7a8e6135b6c063b6b2a93152cb3a' 2015-09-05 17:17:15 +02:00
cpu_internal.h Merge commit 'cae39851201b7781f1262e1c23627b45e6e80bb4' 2015-05-31 23:59:48 +02:00
cpu.c lavu: add AESNI CPU flag 2015-10-28 04:23:14 -05:00
cpu.h lavu: add AESNI CPU flag 2015-10-28 04:23:14 -05:00
crc.c avutil/crc: use EINVAL instead of -1 for the return code of av_crc_init() 2015-10-16 03:24:36 +02:00
crc.h
des.c avutil: use EINVAL instead of -1 for the return code of crypto related init functions 2015-10-18 15:17:58 -04:00
des.h avutil: undo FF_API_CRYPTO_CONTEXT deprecation 2015-10-16 19:13:38 -03:00
dict.c Merge commit '11c5f438ff83da5040e85bfa6299f56b321d32ef' 2015-10-14 14:01:11 +02:00
dict.h Merge commit '11c5f438ff83da5040e85bfa6299f56b321d32ef' 2015-10-14 14:01:11 +02:00
display.c
display.h
downmix_info.c
downmix_info.h
dynarray.h
error.c
error.h
eval.c avutil: add ff_reverse as av_reverse replacement 2015-08-12 00:14:14 +02:00
eval.h
fifo.c avutil/fifo: add function av_fifo_generic_peek_at() 2015-10-14 20:23:58 +02:00
fifo.h avutil/fifo: add function av_fifo_generic_peek_at() 2015-10-14 20:23:58 +02:00
file_open.c
file.c
file.h avutil/file: add av_warn_unused_result to av_file_map 2015-10-16 17:18:39 -04:00
fixed_dsp.c avutil/fixed_dsp: remove ff_ prefix from static function 2015-06-20 03:39:09 -03:00
fixed_dsp.h libavutil: Add new fixed dsp functions. 2015-06-03 22:50:53 +02:00
float_dsp.c avutil: merge avpriv_float_dsp_init into avpriv_float_dsp_alloc 2015-10-21 00:24:58 +02:00
float_dsp.h avutil: merge avpriv_float_dsp_init into avpriv_float_dsp_alloc 2015-10-21 00:24:58 +02:00
frame.c Merge commit '1aa24df74c052a73175c43e57d35b4835e537ec8' 2015-10-03 09:52:39 +02:00
frame.h Merge commit '1aa24df74c052a73175c43e57d35b4835e537ec8' 2015-10-03 09:52:39 +02:00
hash.c
hash.h
hmac.c lavu/hmac: remove deprecated type ids 2015-09-05 18:07:20 +02:00
hmac.h lavu/hmac: remove deprecated type ids 2015-09-05 18:07:20 +02:00
imgutils.c Merge commit '2268db2cd052674fde55c7d48b7a5098ce89b4ba' 2015-09-08 16:35:28 +02:00
imgutils.h
integer.c
integer.h
internal.h avutil/internal: add av_warn_unused_result to avpriv_open 2015-10-16 17:18:21 -04:00
intfloat.h
intmath.c intmath: remove av_ctz. 2015-10-11 18:03:10 -04:00
intmath.h avutil/intmath: fix undefined behavior in ff_ctzll_c() 2015-10-22 14:10:42 +02:00
intreadwrite.h
lfg.c
lfg.h
libavutil.v
libm.h
lls.c lavu: Drop deprecated private lls functions 2015-08-28 16:04:27 +02:00
lls.h lavu: Drop deprecated private lls functions 2015-08-28 16:04:27 +02:00
log2_tab.c
log.c avutil/log: fix zero length gnu_printf format string warning 2015-09-17 18:58:01 +02:00
log.h avutil/log: modify AV_LOG_MAX_OFFSET for AV_LOG_TRACE 2015-06-26 14:02:35 +02:00
lzo.c
lzo.h
macros.h
Makefile avutil: install des.h, rc4.h and tree.h as public headers 2015-10-21 00:23:10 +02:00
mathematics.c avutil/mathematics: make av_gcd more robust 2015-10-29 19:13:55 -04:00
mathematics.h
md5.c lavu: Drop deprecated context size variables 2015-08-28 16:04:27 +02:00
md5.h lavu: Drop deprecated context size variables 2015-08-28 16:04:27 +02:00
mem_internal.h avutil/mem_internal: add missing header includes 2015-07-13 21:54:15 -03:00
mem.c Factor duplicated ff_fast_malloc() out into mem_internal.h 2015-07-13 02:41:43 +02:00
mem.h avutil/mem: add av_warn_unused_result 2015-10-16 19:53:55 -04:00
motion_vector.h
murmur3.c
murmur3.h
opencl_internal.c
opencl_internal.h
opencl.c opencl: Use "opencl" as log context name 2015-10-17 01:16:50 -07:00
opencl.h opencl: Force the use of 1.2 APIs 2015-10-17 01:16:50 -07:00
opt.c avutil/opt: print more meaningful default flags values 2015-10-25 22:47:16 +01:00
opt.h lavu/opt: add flag to return NULL when applicable in av_opt_get 2015-10-09 04:12:57 -05:00
parseutils.c Merge commit '219b39a71a5694b1c14a07b86477f665a5b6849b' 2015-07-21 16:55:39 +02:00
parseutils.h
pca.c
pca.h
pixdesc.c pixfmt: Add new SMPTE color primaries and transfer characteristic values 2015-09-17 10:31:43 +02:00
pixdesc.h Merge commit '7b02cb29d9d60cdd5ef321043d11d02023e7dc8f' 2015-09-12 13:03:04 +02:00
pixelutils.c
pixelutils.h
pixfmt.h pixfmt: Add new SMPTE color primaries and transfer characteristic values 2015-09-17 10:31:43 +02:00
qsort.h avutil/qsort: use the do while form for AV_QSORT, AV_MSORT 2015-10-23 08:41:16 -04:00
random_seed.c
random_seed.h
rational.c avutil: Add av_q2intfloat() 2015-05-26 18:31:53 +02:00
rational.h avutil: Add av_q2intfloat() 2015-05-26 18:31:53 +02:00
rc4.c avutil: use EINVAL instead of -1 for the return code of crypto related init functions 2015-10-18 15:17:58 -04:00
rc4.h avutil: undo FF_API_CRYPTO_CONTEXT deprecation 2015-10-16 19:13:38 -03:00
replaygain.h
reverse.c avutil: add ff_reverse as av_reverse replacement 2015-08-12 00:14:14 +02:00
ripemd.c avutil/ripemd: make rol macro more robust by adding parentheses 2015-10-28 21:42:15 -04:00
ripemd.h
samplefmt.c
samplefmt.h
sha512.c avutil: use EINVAL instead of -1 for the return code of crypto related init functions 2015-10-18 15:17:58 -04:00
sha512.h
sha.c avutil: use EINVAL instead of -1 for the return code of crypto related init functions 2015-10-18 15:17:58 -04:00
sha.h lavu: Drop deprecated context size variables 2015-08-28 16:04:27 +02:00
softfloat_tables.h
softfloat.c avutil/softfloat: Add a test for av_sincos_sf() 2015-07-25 21:42:42 +02:00
softfloat.h avutil/softfloat: move av_sincos_sf() back to header 2015-07-22 23:12:21 -03:00
stereo3d.c
stereo3d.h
tea.c Add support for TEA (Tiny Encryption Algorithm) 2015-07-21 23:10:44 +02:00
tea.h Add support for TEA (Tiny Encryption Algorithm) 2015-07-21 23:10:44 +02:00
thread.h Merge commit 'c53e796f8b69799b7ad6d28fbab981d37edf1bc9' 2015-10-14 23:02:35 +02:00
threadmessage.c
threadmessage.h
time_internal.h
time.c
time.h
timecode.c timecode: Support HFR values 2015-10-26 15:05:26 +01:00
timecode.h
timer.h
timestamp.h
tree.c avutil/tree: clean up pointer incompatibility warnings 2015-10-25 12:45:10 -04:00
tree.h avutil/tree: Document the guaranteed ordering of compare arguments for av_tree_find() 2015-10-25 17:28:47 +01:00
twofish.c avutil: use EINVAL instead of -1 for the return code of crypto related init functions 2015-10-18 15:17:58 -04:00
twofish.h
utf8.c
utils.c lavu: disable wrong value check in get_version() upon api bump. 2015-08-18 15:57:20 -04:00
version.h lavu: add AESNI CPU flag 2015-10-28 04:23:14 -05:00
wchar_filename.h
x86_cpu.h
xga_font_data.c
xga_font_data.h
xtea.c avutil: undo FF_API_CRYPTO_CONTEXT deprecation 2015-10-16 19:13:38 -03:00
xtea.h avutil: undo FF_API_CRYPTO_CONTEXT deprecation 2015-10-16 19:13:38 -03:00