summaryrefslogtreecommitdiff
path: root/libavutil
Commit message (Collapse)AuthorAge
* avutil/common: Protect GET_BYTE in GET_UTF8() by ()Michael Niedermayer2016-01-13
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Correct two build/built typosTimothy Gu2016-01-11
| | | | | Found-by: Leo Izen <leo.izen@gmail.com> as thebombzen on IRC Signed-off-by: Timothy Gu <timothygu99@gmail.com>
* x86/float_dsp: zero extend offset from ff_scalarproduct_float_sseJames Almer2016-01-08
| | | | | Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* x86/float_dsp: zero extend len from ff_butterflies_float_sse implicitlyJames Almer2016-01-08
| | | | | Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* x86/float_dsp: remove len check from ff_butterflies_float_sseJames Almer2016-01-08
| | | | | | | The function documentation explicitly mentions it needs to be a multiple of 4. Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavu: rename and move ff_parity to av_parityJames Almer2016-01-07
| | | | | | | av_popcount is not defined in intmath.h. Reviewed-by: ubitux Signed-off-by: James Almer <jamrial@gmail.com>
* lavu: add ff_parity()Clément Bœsch2016-01-07
|
* lavu/common: add an explanation to FF_CEIL_RSHIFT()Clément Bœsch2016-01-07
|
* lavu/common: fix FF_CEIL_RSHIFT() range commentClément Bœsch2016-01-07
|
* x86/intmath: add sse optimized av_clipf and av_clipdJames Almer2016-01-07
| | | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/cpu: add missing entry for vfp_vm to av_parse_cpu_capsHendrik Leppkes2016-01-02
|
* Merge commit 'e2710e790c09e49e86baa58c6063af0097cc8cb0'Hendrik Leppkes2016-01-02
|\ | | | | | | | | | | | | * commit 'e2710e790c09e49e86baa58c6063af0097cc8cb0': arm: add a cpu flag for the VFPv2 vector mode Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * arm: add a cpu flag for the VFPv2 vector modeJanne Grunau2015-12-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The vector mode was deprecated in ARMv7-A/VFPv3 and various cpu implementations do not support it in hardware. Vector mode code will depending the OS either be emulated in software or result in an illegal instruction on cpus which does not support it. This was not really problem in practice since NEON implementations of the same functions are preferred. It will however become a problem for checkasm which tests every cpu flag separately. Since this is a cpu feature newer cpu do not support anymore the behaviour of this flag differs from the other flags. It can be only activated by runtime cpu feature selection.
* | Merge commit '64034849dad8410bedbe1def4c533490fb85cc4a'Hendrik Leppkes2016-01-02
|\| | | | | | | | | | | | | * commit '64034849dad8410bedbe1def4c533490fb85cc4a': arm64: add cycle counter support Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * arm64: add cycle counter supportJanne Grunau2015-12-14
| | | | | | | | | | | | The ISB (instruction synchronization barrier) might be too heavy for START/STOPTIMER use but should be more accurate in checkasm where the timing overhead is subtracted.
* | Merge commit '50078c1c8070dd8d1c329e8117ff30ec72489039'Hendrik Leppkes2016-01-02
|\| | | | | | | | | | | | | * commit '50078c1c8070dd8d1c329e8117ff30ec72489039': libavutil: move FFALIGN macro from common.h to macros.h Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * libavutil: move FFALIGN macro from common.h to macros.hJanne Grunau2015-12-14
| | | | | | | | | | | | | | | | | | Include macros.h explicitly in common.h so that external code using FFALIGN does not break. It was already implicitly included through version.h. Include macros.h in lls.h and internal.h for FFALIGN. lls.h was including common.h only for FFALIGN and internal.h was missing the include for FFALIGN. `make checkheaders` did not catch it because it's an internal header.
* | lavu/eval: replace pow(10,x) by ff_exp10(x)Ganesh Ajjanagadde2015-12-25
| | | | | | | | | | Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | lavu/internal: add ff_exp10Ganesh Ajjanagadde2015-12-25
| | | | | | | | | | | | | | | | | | | | | | | | | | Fast, reasonably accurate 10^x. Alternative of detection of libm exp10 at configure time is not worth the trouble, since it is anyway not POSIX or ISO C, and currently only the GNU libm has it. Furthermore, GNU libm's variant is ~ 2x slower, and is ironically not correctly rounded (2 ulp off) to justify all that slowdown. Reviewed-by: James Almer <jamrial@gmail.com> Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | lavu/libm,configure: remove exp10, exp10f detectionGanesh Ajjanagadde2015-12-25
| | | | | | | | | | | | Subsequent commit introduces ff_exp10 instead. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | lavu/libm: misc, minor changesGanesh Ajjanagadde2015-12-25
| | | | | | | | | | | | | | Addition of comments marking the end of ifdef blocks, correction of an incorrect (at double precision) M_LN2, removal of an unnecessary undef. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | lavu/libm: add exp10 supportGanesh Ajjanagadde2015-12-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | exp10 is a function available in GNU libm. Looks like no other common libm has it. This adds support for it to FFmpeg. There are essentially 2 ways of handling the fallback: 1. Using pow(10, x) 2. Using exp2(M_LOG2_10 * x). First one represents a Pareto improvement, with no speed or accuracy regression anywhere, but speed improvement limited to GNU libm. Second one represents a slight accuracy loss (relative error ~ 1e-13) for non GNU libm. Speedup of > 2x is obtained on non GNU libm platforms, ~30% on GNU libm. These are "average case numbers", another benefit is the lack of triggering of the well-known terrible worst case paths through pow. Based on reviews, second one chosen. Comment added accordingly. Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | lavu/libm: add erf hack and make dynaudnorm available everywhereGanesh Ajjanagadde2015-12-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Source code is from Boost: http://www.boost.org/doc/libs/1_46_1/boost/math/special_functions/erf.hpp with appropriate modifications for FFmpeg. Tested on interval -6 to 6 (beyond which it saturates), +/-NAN, +/-INFINITY under -fsanitize=undefined on clang to test for possible undefined behavior. This function turns out to actually be essentially as accurate and faster than the libm (GNU/BSD's/Mac OS X), and I can think of 3 reasons why upstream does not use this: 1. They are not aware of it. 2. They are concerned about licensing - this applies especially to GNU libm. 3. They do not know and/or appreciate the benefits of rational approximations over polynomial approximations. Boost uses them to great effect, see e.g swr/resample for bessel derived from them, which is also similarly superior to libm variants. First, performance. sample benchmark (clang -O3, Haswell, GNU/Linux): 3e8 values evenly spaced from 0 to 6 time (libm): ./test 13.39s user 0.00s system 100% cpu 13.376 total time (boost based): ./test 9.20s user 0.00s system 100% cpu 9.190 total Second, accuracy. 1e8 eval pts from 0 to 6 maxdiff (absolute): 2.2204460492503131e-16 occuring at point where libm erf is correctly rounded, this is not. Illustration of superior rounding of this function: arg : 0.83999999999999997 erf : 0.76514271145499457 boost : 0.76514271145499446 real : 0.76514271145499446 i.e libm is actually incorrectly rounded. Note that this is clear from: https://github.com/JuliaLang/openlibm/blob/master/src/s_erf.c (the Sun implementation used by both BSD and GNU libm's), where only 1 ulp is guaranteed. Reasons it is not easy/worthwhile to create a "correctly rounded" variant of this function (i.e 0.5ulp): 1. Upstream libm's don't do it anyway, so we can't guarantee this unless we force this implementation on all platforms. This is not easy, as the linker would complain unless measures are taken. 2. Nothing in FFmpeg cares or can care about such things, due to the above and FFmpeg's nature. 3. Creating a correctly rounded function will in practice need some use of long double/fma. long double, although C89/C90, unfortunately has problems on ppc. This needs fixing of toolchain flags/configure. In any case this will be slower for miniscule gain. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | lavu/libm: add copysign hackGanesh Ajjanagadde2015-12-19
| | | | | | | | | | | | | | | | | | | | | | | | For systems with broken libms. Tested with NAN, -NAN, INFINITY, -INFINITY, +/-x for regular double x and combinations of these. Old versions of MSVC need some UINT64_C hackery. Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | lavu/intmath: add faster clz supportGanesh Ajjanagadde2015-12-19
| | | | | | | | | | | | | | | | This should be useful for the sofalizer filter. Reviewed-by: Kieran Kunhya <kierank@ob-encoder.com> Reviewed-by: Clément Bœsch <u@pkh.me> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | lavu/error: add missing error messages for errors supported on all platformsMarton Balint2015-12-18
| | | | | | | | | | | | | | | | We need these if we have no strerror_r. Descriptions are taken from doc/errno.txt except for ENOMEM. Signed-off-by: Marton Balint <cus@passwd.hu>
* | lavu/random_seed: use arc4random() when availableGanesh Ajjanagadde2015-12-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | arc4random() was designed as a superior interface for system random number generation, designed for OpenBSD and subsequently incorporated by other BSD's, Mac OS X, and some non-standard libc's. It is thus an improvement to use it whenever available. As a side note, this may or may not get included in glibc, and there is a proposal to create a posix_random family based on these ideas: http://austingroupbugs.net/view.php?id=859. Tested on Mac OS X. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | lavu/eval: remove pow and exp2 for postfixesGanesh Ajjanagadde2015-12-16
| | | | | | | | | | | | | | | | | | | | These postfixes can be computed statically, and there is no need to waste runtime resources. Tested with FATE. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | libavutil: add aes-ctr supporterankor2015-12-15
| | | | | | | | | | | | for supporting mp4 cenc encoding/decoding Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | 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>