summaryrefslogtreecommitdiff
path: root/libavutil
Commit message (Collapse)AuthorAge
* avutil/motion_vector: export subpel motion informationClément Bœsch2015-11-23
| | | | FATE test changes because of the switch from shift to division.
* Merge commit '588b6215b4c74945994eb9636b0699028c069ed2'Derek Buitenhuis2015-11-22
|\ | | | | | | | | | | | | | | | | | | | | * commit '588b6215b4c74945994eb9636b0699028c069ed2': rtmpcrypt: Do the xtea decryption in little endian mode xtea: Add functions for little endian mode Conflicts: libavutil/xtea.c Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * xtea: Add functions for little endian modeMartin Storsjö2015-11-13
| | | | | | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* | avutil/eval: change sqrt to hypotGanesh Ajjanagadde2015-11-21
| | | | | | | | | | | | | | This improves the mathematical behavior of hypotenuse computation. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | configure+libm.h: add hypot emulationGanesh Ajjanagadde2015-11-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It is known that the naive sqrt(x*x + y*y) approach for computing the hypotenuse suffers from overflow and accuracy issues, see e.g http://www.johndcook.com/blog/2010/06/02/whats-so-hard-about-finding-a-hypotenuse/. This adds hypot support to FFmpeg, a C99 function. On platforms without hypot, this patch does a reaonable workaround, that although not as accurate as GNU libm, is readable and does not suffer from the overflow issue. Improvements can be made separately. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | avutil/libm: correct isnan, isinf compat hacksGanesh Ajjanagadde2015-11-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | isnan and isinf are actually macros as per the standard. In particular, the existing implementation has incorrect signature. Furthermore, this results in undefined behavior for e.g double values outside float range as per the standard. This patch corrects the undefined behavior for all usage within FFmpeg. Note that long double is not handled as it is not used in FFmpeg. Furthermore, even if at some point long double gets used, it is likely not needed to modify the macro in practice for usage in FFmpeg. See below for analysis. Getting long double to work strictly per the spec is significantly harder since a long double may be an IEEE 128 bit quad (very rare), 80 bit extended precision value (on GCC/Clang), or simply double (on recent Microsoft). On the other hand, any potential future usage of long double is likely for precision (when a platform offers extra precision) and not for range, since the range anyway varies and is not as portable as IEEE 754 single/double precision. In such cases, the implicit cast to a double is well defined and isinf and isnan should work as intended. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | Merge commit '1fc94724f1fd52944bb5ae571475c621da4b77a0'Derek Buitenhuis2015-11-19
|\| | | | | | | | | | | | | * commit '1fc94724f1fd52944bb5ae571475c621da4b77a0': xtea: Clarify that the current API works in big endian mode Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * xtea: Clarify that the current API works in big endian modeMartin Storsjö2015-11-13
| | | | | | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* | avutil/mem: Add av_fast_mallocz()Michael Niedermayer2015-11-18
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil: Move av_rint64_clip_* to internal.hMichael Niedermayer2015-11-15
| | | | | | | | | | | | | | | | | | | | The function is renamed to ff_rint64_clip() This should avoid build failures on VS2012 Feel free to changes this to a different solution Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/common: add av_rint64_clipGanesh Ajjanagadde2015-11-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The rationale for this function is reflected in the documentation for it, and is copied here: Clip a double value into the long long amin-amax range. This function is needed because conversion of floating point to integers when it does not fit in the integer's representation does not necessarily saturate correctly (usually converted to a cvttsd2si on x86) which saturates numbers > INT64_MAX to INT64_MIN. The standard marks such conversions as undefined behavior, allowing this sort of mathematically bogus conversions. This provides a safe alternative that is slower obviously but assures safety and better mathematical behavior. API: @param a value to clip @param amin minimum value of the clip range @param amax maximum value of the clip range @return clipped value Note that a priori if one can guarantee from the calling side that the double is in range, it is safe to simply do an explicit/implicit cast, and that will be far faster. However, otherwise this function should be used. avutil minor version is bumped. Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | avutil/x86/intmath: Fix intrinsic header include when using newer gcc with ↵Matt Oliver2015-11-12
| | | | | | | | | | | | older icc. Signed-off-by: Matt Oliver <protogonoi@gmail.com>
* | avutil/x86/bswap: Add msvc bswap instrinsics.Matt Oliver2015-11-12
| | | | | | | | | | | | This adds msvc optimisations as well as fixing an error in icl whereby it will generate invalid code otherwise. Signed-off-by: Matt Oliver <protogonoi@gmail.com>
* | avutil/x86/intmath: Disable use of tzcnt on older intel compilers.Matt Oliver2015-11-11
| | | | | | | | | | | | | | ICC versions older than atleast 12.1.6 dont have the tzcnt intrinsics. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Matt Oliver <protogonoi@gmail.com>
* | avutil/softfloat: use abort() instead of av_assert0(0)James Almer2015-11-10
| | | | | | | | | | | | | | Fixes compilation of host tool aacps_fixed_tablegen. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* | avutil/x86/intmath: Correct intrinsic headers for older compilers.Matt Oliver2015-11-09
| | | | | | | | Signed-off-by: Matt Oliver <protogonoi@gmail.com>
* | softfloat: handle INT_MIN correctly in av_int2sfAndreas Cadhalpun2015-11-08
| | | | | | | | | | | | | | | | 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>
* | softfloat: assert when the argument of av_sqrt_sf is negativeAndreas Cadhalpun2015-11-08
| | | | | | | | | | | | | | | | 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>
* | avutil/softfloat: Include negative numbers in cmp/gt testsMichael Niedermayer2015-11-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/softfloat: Fix av_gt_sf() with large exponents try #2Michael Niedermayer2015-11-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/softfloat: Add test for av_gt_sf()Michael Niedermayer2015-11-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/softfloat: Extend the av_cmp_sf() test to cover a wider range of ↵Michael Niedermayer2015-11-08
| | | | | | | | | | | | exponents Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/softfloat: Fix overflows in shifts in av_cmp_sf() and av_gt_sf()Michael Niedermayer2015-11-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/softfloat: Add test for av_cmp_sf()Michael Niedermayer2015-11-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/softfloat: Add tests for exponent underflowsMichael Niedermayer2015-11-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/softfloat: Fix exponent underflow in av_div_sf()Michael Niedermayer2015-11-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/softfloat: Fix exponent underflow in av_mul_sf()Michael Niedermayer2015-11-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/softfloat: Fix typo in av_mul_sf() doxyMichael Niedermayer2015-11-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Revert "avutil/softfloat: Check for MIN_EXP in av_sqrt_sf()"Michael Niedermayer2015-11-08
| | | | | | | | | | | | | | This case should not be possible if the input has a exponent within the valid range This reverts commit 0269fb11e3de17375f86d9120599af8c87cdfa0a.
* | avutil/softfloat: Check for MIN_EXP in av_sqrt_sf()Michael Niedermayer2015-11-08
| | | | | | | | | | | | Otherwise the exponent could eventually underflow Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/softfloat: Correctly set the exponent for 0.0 in av_sqrt_sf()Michael Niedermayer2015-11-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/softfloat: FLOAT_0 should use MIN_EXPMichael Niedermayer2015-11-08
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | lavu/opt: enhance printing durations.Nicolas George2015-11-07
| | | | | | | | | | | | | | 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.
* | libavutil/channel_layout: Check strtol*() for failureMichael Niedermayer2015-11-05
| | | | | | | | | | | | | | | | 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>
* | avutil/common: add FFDIFFSIGN macroGanesh Ajjanagadde2015-11-03
| | | | | | | | | | | | | | | | | | | | | | 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>
* | avutil/file_open: avoid file handle inheritance on WindowsTobias Rapp2015-11-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | avutil/eval: minor typoGanesh Ajjanagadde2015-11-01
| | | | | | | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | avutil/x86/intmath: Add missing header.Matt Oliver2015-11-01
| | | | | | | | Signed-off-by: Matt Oliver <protogonoi@gmail.com>
* | avutil/opencl_internal: add av_warn_unused_resultGanesh Ajjanagadde2015-10-31
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | avutil/x86/intmath: Use tzcnt in place of bsf.Matt Oliver2015-10-31
| | | | | | | | Signed-off-by: Matt Oliver <protogonoi@gmail.com>
* | avutil/rational: use frexp rather than ad-hoc log to get floating point exponentGanesh Ajjanagadde2015-10-30
| | | | | | | | | | | | | | | | 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>
* | avutil/wchar_filename: add av_warn_unused_resultGanesh Ajjanagadde2015-10-30
| | | | | | | | | | | | | | Current code is fine, this just adds robustness. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | avutil/mathematics: correct documentation for av_gcdGanesh Ajjanagadde2015-10-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | avutil/mathematics: make av_gcd more robustGanesh Ajjanagadde2015-10-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | avutil/audio_fifo: add av_warn_unused_resultGanesh Ajjanagadde2015-10-28
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | avutil/ripemd: make rol macro more robust by adding parenthesesGanesh Ajjanagadde2015-10-28
| | | | | | | | | | | | | | | | | | 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>
* | lavu/aes: test CBC functionalityRodger Combs2015-10-28
| |
* | lavu/aes: align AVAES struct membersRodger Combs2015-10-28
| |
* | lavu/aes: add runtime dispatch for crypt functionRodger Combs2015-10-28
| |
* | lavu/aes: move AVAES to separate internal headerRodger Combs2015-10-28
| |