summaryrefslogtreecommitdiff
path: root/libavutil
Commit message (Collapse)AuthorAge
* avutil/softfloat: Assert that the exponent did not overflow the legal range ↵Michael Niedermayer2015-12-11
| | | | | | in av_normalize1_sf() Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/mathematics: Fix division by 0Michael Niedermayer2015-12-09
| | | | | | Fixes: CID1341571 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavu/frame: use AVPALETTE_SIZE instead of 1024Clément Bœsch2015-12-08
|
* lavu/opencl: restore #if HAVE_THREADSClément Bœsch2015-12-07
| | | | | | Fix regression since a8bb81a. Spotted-by: RiCON
* cosmetics: Fix weird indentationsTimothy Gu2015-12-07
|
* lavc, lavu: use avutil/thread.h instead of redundant conditional includesClément Bœsch2015-12-07
|
* avutil/threadmessage: fix build without HAVE_THREADS, new attemptClément Bœsch2015-12-07
|
* avutil/threadmessage: fix build without HAVE_THREADSClément Bœsch2015-12-07
|
* avutil/threadmessage: split the pthread condition in twoClément Bœsch2015-12-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix a dead lock under certain conditions. Let's assume we have a queue of 1 message max, 2 senders, and 1 receiver. Scenario (real record obtained with debug added): [...] SENDER #0: acquired lock SENDER #0: queue is full, wait SENDER #1: acquired lock SENDER #1: queue is full, wait RECEIVER: acquired lock RECEIVER: reading a msg from the queue RECEIVER: signal the cond RECEIVER: acquired lock RECEIVER: queue is empty, wait SENDER #0: writing a msg the queue SENDER #0: signal the cond SENDER #0: acquired lock SENDER #0: queue is full, wait SENDER #1: queue is full, wait Translated: - initially the queue contains 1/1 message with 2 senders blocking on it, waiting to push another message. - Meanwhile the receiver is obtaining the lock, read the message, signal & release the lock. For some reason it is able to acquire the lock again before the signal wakes up one of the sender. Since it just emptied the queue, the reader waits for the queue to fill up again. - The signal finally reaches one of the sender, which writes a message and then signal the condition. Unfortunately, instead of waking up the reader, it actually wakes up the other worker (signal = notify the condition just for 1 waiter), who can't push another message in the queue because it's full. - Meanwhile, the receiver is still waiting. Deadlock. This scenario can be triggered with for example: tests/api/api-threadmessage-test 1 2 100 100 1 1000 1000 One working solution is to make av_thread_message_queue_{send,recv}() call pthread_cond_broadcast() instead of pthread_cond_signal() so both senders and receivers are unlocked when work is done (be it reading or writing). This second solution replaces the condition with two: one to notify the senders, and one to notify the receivers. This prevents senders from notifying other senders instead of a reader, and the other way around. It also avoid broadcasting to everyone like the first solution, and is, as a result in theory more optimized.
* avutil/threadmessage: add av_thread_message_flush()Clément Bœsch2015-12-07
|
* libavutil: add version component accessor macrosReynaldo H. Verdejo Pinochet2015-12-06
| | | | | | | | | | | Pretty standard macros, these should help libav* users avoid repeating ver.si.on parsing code, which aids in compatibility-checking tasks like identifying FFmpeg from Libav (_MICRO >= 100 check). Something many are doing since we are not intercompatible anymore. Signed-off-by: Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>
* libavutil/tablegen: add missing math.h includeHendrik Leppkes2015-12-04
|
* avutil/timecode: Fix fps checkMichael Niedermayer2015-12-03
| | | | | | | | | | | | The fps variable is explicitly set to -1 in case of some errors, the check must thus be signed or the code setting it needs to use 0 as error code the type of the field could be changed as well but its in an installed header Fixes: integer overflow Fixes: 9982cc157b1ea90429435640a989122f/asan_generic_3ad004a_3799_22cf198d9cd09928e2d9ad250474fa58.mov Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/crc: avoid needless space wastage of hardcoded crc tableGanesh Ajjanagadde2015-12-02
| | | | | | | | | | | | | There was no reason AFAIK for making AV_CRC_24_IEEE 12. This simply resulted in wasted space under --enable-hardcoded-tables: dynamic: 1318672 libavutil/libavutil.so.55 old : 1330680 libavutil/libavutil.so.55 new : 1326488 libavutil/libavutil.so.55 Minor version number is bumped, with ifdefry due to API breakage. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* avutil/rational: Test av_rescale_rnd() with combinations of "special" valuesMichael Niedermayer2015-12-02
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/mathematics: return INT64_MIN (=AV_NOPTS_VALUE) from av_rescale_rnd() ↵Michael Niedermayer2015-12-02
| | | | | | | | | | for overflows Fixes integer overflow Fixes: mozilla bug 1229167 Found-by: Tyson Smith Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/tablegen: add tablegen libm compatibility shimsGanesh Ajjanagadde2015-12-01
| | | | | | | | | | | | This is useful for build-time table generation (--enable-hardcoded-tables), by providing compat shims for hosts that have broken libms. This file is deliberately kept minimal; functions can always be added on an as-needed basis. Reviewed-by: Clément Bœsch <u@pkh.me> Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* avutil/mathematics: Do not treat INT64_MIN as positive in av_rescale_rndMichael Niedermayer2015-12-01
| | | | | | | | | The code expects actual positive numbers and gives completely wrong results if INT64_MIN is treated as positive Instead clip it into the valid range that is add 1 and treat it as negative Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/integer: Fix av_mod_i() with negative dividendMichael Niedermayer2015-12-01
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/lls: speed up performance of solve_llsGanesh Ajjanagadde2015-11-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a trivial rewrite of the loops that results in better prefetching and associated cache efficiency. Essentially, the problem is that modern prefetching logic is based on finite state Markov memory, a reasonable assumption that is used elsewhere in CPU's in for instance branch predictors. Surrounding loops all iterate forward through the array, making the predictor think of prefetching in the forward direction, but the intermediate loop is unnecessarily in the backward direction. Speedup is nontrivial. Benchmarks obtained by 10^6 iterations within solve_lls, with START/STOP_TIMER. File is tests/data/fate/flac-16-lpc-cholesky.err. Hardware: x86-64, Haswell, GNU/Linux. new: 17291 decicycles in solve_lls, 2096706 runs, 446 skips 17255 decicycles in solve_lls, 4193657 runs, 647 skips 17231 decicycles in solve_lls, 8384997 runs, 3611 skips 17189 decicycles in solve_lls,16771010 runs, 6206 skips 17132 decicycles in solve_lls,33544757 runs, 9675 skips 17092 decicycles in solve_lls,67092404 runs, 16460 skips 17058 decicycles in solve_lls,134188213 runs, 29515 skips old: 18009 decicycles in solve_lls, 2096665 runs, 487 skips 17805 decicycles in solve_lls, 4193320 runs, 984 skips 17779 decicycles in solve_lls, 8386855 runs, 1753 skips 18289 decicycles in solve_lls,16774280 runs, 2936 skips 18158 decicycles in solve_lls,33548104 runs, 6328 skips 18420 decicycles in solve_lls,67091793 runs, 17071 skips 18310 decicycles in solve_lls,134187219 runs, 30509 skips Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* avutil/libm: fix isnan compatibility hackGanesh Ajjanagadde2015-11-24
| | | | | | | | | | | | | Commit 14ea4151d7c3c26500193f11ac661ed20c7c2b9c had a bug in that the conversion of the uint64_t result to an int (the return signature) would lead to implementation defined behavior, and in this case simply returned 0 for NAN. A fix via AND'ing the result with 1 does the trick, simply by ensuring a 0 or 1 return value. Patch tested with FATE on x86-64, GNU/Linux by forcing the compatibility code via an ifdef hack suggested by Michael. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* imgutils: Use designated initializers for AVClassTimothy Gu2015-11-23
| | | | More readable and less breakable.
* avutil/x86/bswap: Remove warning about bswap intrinsics with msvc.Matt Oliver2015-11-23
| | | | Signed-off-by: Matt Oliver <protogonoi@gmail.com>
* 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>