Commit Graph

3914 Commits

Author SHA1 Message Date
Matt Oliver f984174512 avutil/x86/intmath: Correct intrinsic headers for older compilers.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-11-09 21:40:33 +11:00
Andreas Cadhalpun 9ac61e73d0 softfloat: handle INT_MIN correctly in av_int2sf
Otherwise v=INT_MIN doesn't get normalized and thus triggers av_assert2
in other functions.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-11-08 21:06:40 +01:00
Andreas Cadhalpun f3866a14c3 softfloat: assert when the argument of av_sqrt_sf is negative
The correct result can't be expressed in SoftFloat.
Currently it returns a random value from an out of bounds read.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-11-08 21:05:21 +01:00
Michael Niedermayer 955cdc43a3 avutil/softfloat: Include negative numbers in cmp/gt tests
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 15:04:05 +01:00
Michael Niedermayer 05b05a7a84 avutil/softfloat: Fix av_gt_sf() with large exponents try #2
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 15:03:28 +01:00
Michael Niedermayer 791ea23e57 avutil/softfloat: Add test for av_gt_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 15:02:05 +01:00
Michael Niedermayer ecfb076141 avutil/softfloat: Extend the av_cmp_sf() test to cover a wider range of exponents
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:55:22 +01:00
Michael Niedermayer cee3c9d29a avutil/softfloat: Fix overflows in shifts in av_cmp_sf() and av_gt_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:54:51 +01:00
Michael Niedermayer df2a2117d2 avutil/softfloat: Add test for av_cmp_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:39:46 +01:00
Michael Niedermayer 596dfe7d6c avutil/softfloat: Add tests for exponent underflows
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:23:38 +01:00
Michael Niedermayer 046218b212 avutil/softfloat: Fix exponent underflow in av_div_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:23:38 +01:00
Michael Niedermayer a1e3303fc0 avutil/softfloat: Fix exponent underflow in av_mul_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:23:38 +01:00
Michael Niedermayer 4135a2bfd6 avutil/softfloat: Fix typo in av_mul_sf() doxy
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:23:37 +01:00
Michael Niedermayer 4b6ad23609 Revert "avutil/softfloat: Check for MIN_EXP in av_sqrt_sf()"
This case should not be possible if the input has a exponent within
the valid range

This reverts commit 0269fb11e3.
2015-11-08 14:23:37 +01:00
Michael Niedermayer 0269fb11e3 avutil/softfloat: Check for MIN_EXP in av_sqrt_sf()
Otherwise the exponent could eventually underflow

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 13:39:06 +01:00
Michael Niedermayer 107db5abf3 avutil/softfloat: Correctly set the exponent for 0.0 in av_sqrt_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 13:39:06 +01:00
Michael Niedermayer a66b243d52 avutil/softfloat: FLOAT_0 should use MIN_EXP
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 03:57:02 +01:00
Nicolas George 47ea04ff10 lavu/opt: enhance printing durations.
Trim unneeded leading components and trailing zeros.
Move the formating code in a separate function.
Use the function also to format the default value, it was currently
printed as plain integer, inconsistent to the way it is parsed.
2015-11-07 16:04:09 +01:00
Michael Niedermayer c9bfd6a8c3 libavutil/channel_layout: Check strtol*() for failure
Fixes assertion failure
Fixes: 4f5814bb15d2dda6fc18ef9791b13816/signal_sigabrt_7ffff6ae7cc9_65_7209d160d168b76f311be6cd64a548eb.wv

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-05 19:28:19 +01:00
Ganesh Ajjanagadde 265f83fd35 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>
2015-11-03 16:28:12 -05:00
Tobias Rapp 4746653466 avutil/file_open: avoid file handle inheritance on Windows
Avoids inheritance of file handles on Windows systems similar to the
O_CLOEXEC/FD_CLOEXEC flag on Linux.

Fixes file lock issues in Windows applications when a child process
is started with handle inheritance enabled (standard input/output
redirection) while a FFmpeg transcoding is running in the parent
process.

Links relevant to the subject:

https://msdn.microsoft.com/en-us/library/w7sa2b22.aspx

Describes the _wsopen() function and the O_NOINHERIT flag. File handles
opened by _wsopen() are inheritable by default.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx

Describes handle inheritance when creating new processes. Handle
inheritance must be enabled (bInheritHandles = TRUE) e.g. when you want
to pass handles for stdin/stdout via lpStartupInfo.

Signed-off-by: Tobias Rapp <t.rapp@noa-audio.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-02 17:40:49 +01:00
Ganesh Ajjanagadde c03044c86a avutil/eval: minor typo
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-01 19:35:01 -05:00
Matt Oliver bff009697d avutil/x86/intmath: Add missing header.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-11-01 02:11:29 +11:00
Ganesh Ajjanagadde 8a5b60a6b1 avutil/opencl_internal: add av_warn_unused_result
clSetKernelArg can return an error due to lack of memory (for instance):
https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clSetKernelArg.html.
Thus this error must be propagated.

Currently should not trigger warnings, but adds robustness.
Untested.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-31 10:40:54 -04:00
Matt Oliver 6c6ac9cb17 avutil/x86/intmath: Use tzcnt in place of bsf.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-10-31 23:11:32 +11:00
Ganesh Ajjanagadde 8d9f86bd37 avutil/rational: use frexp rather than ad-hoc log to get floating point exponent
This simplifies and cleans up the code.
Furthermore, it is much faster due to absence of the slow log computation.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-30 23:18:43 -04:00
Ganesh Ajjanagadde 191f611906 avutil/wchar_filename: add av_warn_unused_result
Current code is fine, this just adds robustness.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-30 13:47:28 -04:00
Ganesh Ajjanagadde 20a30077c3 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>
2015-10-30 13:42:04 -04:00
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
Ganesh Ajjanagadde dd36749557 avutil/audio_fifo: add av_warn_unused_result
This one should not trigger any warnings, but will be useful for future
robustness.

Strictly speaking, one could check the size after the call by examining
the structure instead of the return value. Such a use case is highly
unusual, and this commit may be easily reverted if there is a legitimate
need of such use.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-28 23:05:31 -04:00
Ganesh Ajjanagadde fab1562a50 avutil/ripemd: make rol macro more robust by adding parentheses
This ensures that the macro remains correct in the sense of allowing
expressions for value and bits, by placing the value and bits expressions within
parentheses.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-28 21:42:15 -04:00
Rodger Combs cceed8389d lavu/aes: test CBC functionality 2015-10-28 09:38:21 -05:00
Rodger Combs 54cd1ab555 lavu/aes: align AVAES struct members 2015-10-28 04:23:14 -05:00
Rodger Combs 15ff5c7215 lavu/aes: add runtime dispatch for crypt function 2015-10-28 04:23:14 -05:00
Rodger Combs ec588db56f lavu/aes: move AVAES to separate internal header 2015-10-28 04:23:14 -05:00
Rodger Combs 1e477a970f lavu: add AESNI CPU flag 2015-10-28 04:23:14 -05:00
Ganesh Ajjanagadde a0e390e8ff avutil/avstring: add av_warn_unused_result
This does not trigger any warnings, but adds robustness.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-27 23:16:09 -04:00
Vittorio Giovara 63ea8e0610 timecode: Support HFR values 2015-10-26 15:05:26 +01:00
Vittorio Giovara 8c22148220 timecode: Do not fail for non-standard framerates
Instead just warn, and use the parse fps normally.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-10-26 15:05:05 +01:00
Clément Bœsch 6b5412cbfa avutil/opt: print more meaningful default flags values
Example:
% ./ffmpeg -h encoder=gif
[...]
GIF encoder AVOptions:
  -gifflags          <flags>      E..V.... set GIF flags (default offsetting+transdiff)
     offsetting                   E..V.... enable picture offsetting
     transdiff                    E..V.... enable transparency detection between frames
2015-10-25 22:47:16 +01:00
Ganesh Ajjanagadde bbd6bc6bd0 avutil/tree: clean up pointer incompatibility warnings
Commit 7c8fcbbde3 introduced some warnings
that get triggered on the test build. This should fix them.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-25 12:45:10 -04:00
Michael Niedermayer 65ffca9f80 avutil/tree: Document the guaranteed ordering of compare arguments for av_tree_find()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-25 17:28:47 +01:00
Ganesh Ajjanagadde 7c8fcbbde3 avutil/tree: add additional const qualifier to the comparator
libc's qsort comparator has a const qualifier on both arguments. This
adds a missing const qualifier to exactly match the comparator API.

Existing usages of av_tree_find, av_tree_insert are appropriately
modified: type signature changes of the comparators, and removal of
unnecessary void * casts of function pointers.

Reviewed-by: Henrik Gramner <henrik@gramner.com>
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-24 20:38:07 -04:00
Ganesh Ajjanagadde 94f333f9dc avutil/tree: improve documentation for av_tree_find, av_tree_insert
This documents the additional constness, and provides a useful libc
reference for the API specification of the comparator.

Reviewed-by: Henrik Gramner <henrik@gramner.com>
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-24 20:38:06 -04:00
Ganesh Ajjanagadde 8ed79c45b4 avutil/qsort: use the do while form for AV_QSORT, AV_MSORT
Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-23 08:41:16 -04:00
Michael Niedermayer 00efaa7983 avutil/intmath: fix undefined behavior in ff_ctzll_c()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-22 14:10:42 +02:00
Andreas Cadhalpun 451b6a990a avutil: merge avpriv_float_dsp_init into avpriv_float_dsp_alloc
Also replace the last two usages of avpriv_float_dsp_init with
avpriv_float_dsp_alloc.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-10-21 00:24:58 +02:00
Andreas Cadhalpun 95687dc310 avutil: install des.h, rc4.h and tree.h as public headers
These headers contain functions supposed to be public.

libavutil/des.h:
 av_des_alloc
 av_des_crypt
 av_des_init
 av_des_mac
libavutil/rc4.h:
 av_rc4_alloc
 av_rc4_crypt
 av_rc4_init
libavutil/tree.h
 av_tree_destroy
 av_tree_enumerate
 av_tree_find
 av_tree_insert
 av_tree_node_alloc
 av_tree_node_size

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-10-21 00:23:10 +02:00
Matt Oliver b0bb1dc62d lavu/intmath.h: Move x86 only msvc/icl functions to x86 specific header.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-10-19 13:40:51 +11:00
Matt Oliver 216cc1f6fe lavu/intmath.h: Add msvc/icl ctzll optimisations.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-10-19 13:40:27 +11:00