summaryrefslogtreecommitdiff
path: root/libavutil
Commit message (Collapse)AuthorAge
* x86/tx_float: remove ff_ prefix from external constant tablesJames Almer2021-04-25
| | | | | | | Fixes compilation with some assemblers. Reviewed-by: Lynne Signed-off-by: James Almer <jamrial@gmail.com>
* x86/tx_float: fix forgotten 2-argument mulpsLynne2021-04-24
| | | | Yasm *really* cannot deal with any omitted arguments at all.
* x86/tx_float: use all arguments on vperm2f and vpermilps and reindent commentsLynne2021-04-24
| | | | Apparently even old nasm isn't required to accept incomplete instructions.
* x86/tx_float: Fixes compilation with old yasmJames Almer2021-04-24
| | | | | | | Use three operand format on some instructions, and lea to load effective addresses of tables. Signed-off-by: James Almer <jamrial@gmail.com>
* lavu/x86/tx_float: fix FMA3 implying AVX2 is availableLynne2021-04-24
| | | | It's the other way around - AVX2 implies FMA3 is available.
* lavu/x86: add FFT assemblyLynne2021-04-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a pure x86 assembly SIMD version of the FFT in libavutil/tx. The design of this pure assembly FFT is pretty unconventional. On the lowest level, instead of splitting the complex numbers into real and imaginary parts, we keep complex numbers together but split them in terms of parity. This saves a number of shuffles in each transform, but more importantly, it splits each transform into two independent paths, which we process using separate registers in parallel. This allows us to keep all units saturated and lets us use all available registers to avoid dependencies. Moreover, it allows us to double the granularity of our per-load permutation, skipping many expensive lookups and allowing us to use just 4 loads per register, rather than 8, or in case FMA3 (and by extension, AVX2), use the vgatherdpd instruction, which is at least as fast as 4 separate loads on old hardware, and quite a bit faster on modern CPUs). Higher up, we go for a bottom-up construction of large transforms, foregoing the traditional per-transform call-return recursion chains. Instead, we always start at the bottom-most basis transform (in this case, a 32-point transform), and continue constructing larger and larger transforms until we return to the top-most transform. This way, we only touch the stack 3 times per a complete target transform: once for the 1/2 length transform and two times for the 1/4 length transform. The combination algorithm we use is a standard Split-Radix algorithm, as used in our C code. Although a version with less operations exists (Steven G. Johnson and Matteo Frigo's "A modified split-radix FFT with fewer arithmetic operations", IEEE Trans. Signal Process. 55 (1), 111–119 (2007), which is the one FFTW uses), it only has 2% less operations and requires at least 4x the binary code (due to it needing 4 different paths to do a single transform). That version also has other issues which prevent it from being implemented with SIMD code as efficiently, which makes it lose the marginal gains it offered, and cannot be performed bottom-up, requiring many recursive call-return chains, whose overhead adds up. We go through a lot of effort to minimize load/stores by keeping as much in registers in between construcring transforms. This saves us around 32 cycles, on paper, but in reality a lot more due to load/store aliasing (a load from a memory location cannot be issued while there's a store pending, and there are only so many (2 for Zen 3) load/store units in a CPU). Also, we interleave coefficients during the last stage to save on a store+load per register. Each of the smallest, basis transforms (4, 8 and 16-point in our case) has been extremely optimized. Our 8-point transform is barely 20 instructions in total, beating our old implementation 8-point transform by 1 instruction. Our 2x8-point transform is 23 instructions, beating our old implementation by 6 instruction and needing 50% less cycles. Our 16-point transform's combination code takes slightly more instructions than our old implementation, but makes up for it by requiring a lot less arithmetic operations. Overall, the transform was optimized for the timings of Zen 3, which at the time of writing has the most IPC from all documented CPUs. Shuffles were preferred over arithmetic operations due to their 1/0.5 latency/throughput. On average, this code is 30% faster than our old libavcodec implementation. It's able to trade blows with the previously-untouchable FFTW on small transforms, and due to its tiny size and better prediction, outdoes FFTW on larger transforms by 11% on the largest currently supported size.
* checkasm: add av_tx FFT SIMD testing codeLynne2021-04-24
| | | | | | This sadly required making changes to the code itself, due to the same context needing to be reused for both versions. The lookup table had to be duplicated for both versions.
* lavu/tx: add parity revtab generator versionLynne2021-04-24
| | | | This will be used for SIMD support.
* lavu: bump minor and add APIchanges entry for the lavu/tx changesLynne2021-04-24
|
* lavu/tx: add full-sized iMDCT transform flagLynne2021-04-24
|
* lavu/tx: add unaligned flag to the APILynne2021-04-24
|
* lavu/tx: add a 9-point FFT and (i)MDCTLynne2021-04-24
|
* lavu/tx: add a 7-point FFT and (i)MDCTLynne2021-04-24
|
* lavu/tx: refactor power-of-two FFTLynne2021-04-24
| | | | | | | | | This commit refactors the power-of-two FFT, making it faster and halving the size of all tables, making the code much smaller on all systems. This removes the big/small pass split, because on modern systems the "big" pass is always faster, and even on older machines there is no measurable speed difference.
* lavu/tx: minor code style improvements and additional commentsLynne2021-04-24
|
* avutil/cpu: Schedule deprecated functions for removalAndreas Rheinhardt2021-04-19
| | | | | | | | av_set_cpu_flags_mask() has been deprecated in the commit which merged it: 6df42f98746be06c883ce683563e07c9a2af983f; av_parse_cpu_flags() has been deprecated in 4b529edff8934c258af95e5acc51f84deea66262. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Include attributes.h directlyAndreas Rheinhardt2021-04-19
| | | | | | | | Some files currently rely on libavutil/cpu.h to include it for them; yet said file won't use include it any more after the currently deprecated functions are removed, so include attributes.h directly. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSDBrad Smith2021-04-18
| | | | | Signed-off-by: Brad Smith <brad@comstyle.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* lavu/detection_bbox.h: use AV_NUM_DETECTION_BBOX_CLASSIFY to replace ↵Guo, Yejun2021-04-18
| | | | AV_NUM_BBOX_CLASSIFY
* lavu/detection_bboxes: add missing spaceLynne2021-04-17
| | | | | Could at least maintainers with push access follow the code styles we have?
* lavu: add side data AV_FRAME_DATA_DETECTION_BBOXES for object ↵Guo, Yejun2021-04-17
| | | | detection/classification
* avutil/frame: Return 0 on success in av_frame_ref()Andreas Rheinhardt2021-04-05
| | | | | | | | av_frame_copy() is allowed to return values >= 0 on success, whereas the documentation of av_frame_ref() states that the return value is 0 on success. Ergo the latter must not just return the former's return value. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/cpu: Fix race condition in av_cpu_count()Andreas Rheinhardt2021-04-02
| | | | | | | | | | av_cpu_count() intends to emit a debug message containing the number of logical cores when called the first time. The check currently works with a static volatile int; yet this does not help at all in case of concurrent accesses by multiple threads. So replace this with an atomic_int. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avutil/pixdesc: Fix 1 << 32Andreas Rheinhardt2021-04-01
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avutil/base64: Fix undefined NULL + 0Andreas Rheinhardt2021-04-01
| | | | | | Affected the base64 FATE test. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avutil/common: Add FF_PTR_ADD()Michael Niedermayer2021-03-31
| | | | | Suggested-by: Andreas Rheinhardt Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/frame: Deprecate av_get_colorspace_name()Andreas Rheinhardt2021-03-24
| | | | | | | Contrary to av_color_space_name() it doesn't even support newer colorspaces. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* Bump minor versions after release branchMichael Niedermayer2021-03-20
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Bump Versions before release/4.4 branchMichael Niedermayer2021-03-20
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/adler32: Switch av_adler32_update() to size_t on bumpAndreas Rheinhardt2021-03-19
| | | | | | | | | | av_adler32_update() is used by av_hash_update() which will be switched to size_t at the next bump. So it also has to be made to use size_t. This is also necessary for framecrcenc.c, because the size of side data will become a size_t, too. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avutil/avstring: Check for memory allocation error in av_escapeAndreas Rheinhardt2021-03-15
| | | | | | | | av_bprint_finalize() can still fail even when it has been checked that the AVBPrint is currently complete: Namely if the string was so short that it fit into the AVBPrint's internal buffer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avutil/avstring: Limit string length in av_escape to range of intAndreas Rheinhardt2021-03-15
| | | | | | Otherwise the caller can't distinguish the return value from an error. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avutil/timecode: Avoid fps overflowMichael Niedermayer2021-03-14
| | | | | | | | Fixes: Integer overflow and division by 0 Fixes: poc-202102-div.mov Found-by: 1vanChen of NSFOCUS Security Team Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavutil/timer: Fix clang reserved-user-defined-literalChristopher Degawa2021-03-13
| | | | | | | | clang errors when compiling with C++11 about needing spaces between literal and identifier Signed-off-by: Christopher Degawa <ccom@randomderp.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/buffer_internal: Include internal for buffer_size_tAndreas Rheinhardt2021-03-11
| | | | | | | Fixes checkheaders. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avutil: use the buffer_size_t typedef where requiredJames Almer2021-03-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: change av_frame_new_side_data() size parameter type to size_tJames Almer2021-03-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/buffer: change public function and struct size parameter types to size_tJames Almer2021-03-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/{avstring,bprint}: add XML escaping from ffprobe to avutilStefano Sabatini2021-03-05
| | | | | | | | | | Base escaping only escapes values required for base character data according to part 2.4 of XML, and if additional flags are added single and double quotes can additionally be escaped in order to handle single and double quoted attributes. Co-authored-by: Jan Ekström <jan.ekstrom@24i.com> Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
* avutil/parseutils: Check sign in av_parse_time()Michael Niedermayer2021-03-03
| | | | | | | | Fixes: signed integer overflow: -9223372053736 * 1000000 cannot be represented in type 'long' Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-6607924558430208 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/spherical: Use av_strstart instead of strncmpAndreas Rheinhardt2021-02-28
| | | | | | | It makes the intent clearer and avoids calculating the length separately. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avutil/stereo3d: Use av_strstart instead of strncmpAndreas Rheinhardt2021-02-28
| | | | | | | It makes the intent clearer and avoids calculating the length separately. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avutil/pixdesc: Use av_strstart where appropriateAndreas Rheinhardt2021-02-28
| | | | | | | It makes the intent clearer and allows to avoid calculating the strlen separately. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavu/tx: do not invert permutes on MDCTsLynne2021-02-27
|
* lavu/tx: invert permutation lookupsLynne2021-02-27
| | | | | | | | | | | | | out[lut[i]] = in[i] lookups were 4.04 times(!) slower than out[i] = in[lut[i]] lookups for an out-of-place FFT of length 4096. The permutes remain unchanged for anything but out-of-place monolithic FFT, as those benefit quite a lot from the current order (it means there's only 1 lookup necessary to add to an offset, rather than a full gather). The code was based around non-power-of-two FFTs, so this wasn't benchmarked early on.
* lavu/tx: simplify in-place permute search functionLynne2021-02-27
|
* lavu/tx: require output argument to match input for inplace transformsLynne2021-02-26
| | | | | This simplifies some assembly code by a lot, by either saving a branch or saving an entire duplicated function.
* avutil/buffer: free all pooled buffers immediately after uninitializing the poolJames Almer2021-02-24
| | | | | | | | | | | | | No buffer will be fetched from the pool after it's uninitialized, so there's no benefit from waiting until every single buffer has been returned to it before freeing them all. This should free some memory in certain scenarios, which can be beneficial in low memory systems. Based on a patch by Jonas Karlman. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/tx: Fix declaration after statementAndreas Rheinhardt2021-02-22
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* arm/aarch64: Use mach_absolute_time as timer on apple platformsMartin Storsjö2021-02-21
| | | | | | | | | This is much less precise than the cycle counter register, but the cycle counter register is not available on apple platforms (and on linux, it requires a kernel module for allowing user mode access). Signed-off-by: Martin Storsjö <martin@martin.st>