aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale
Commit message (Collapse)AuthorAgeFilesLines
* all: fix typos found by codespellTimo Rothenpieler17 hours10-22/+22
|
* swscale/output: Fix all bilinear integer overflowsMichael Niedermayer36 hours1-22/+27
| | | | | | | | | Ticket11686 hinted at one of these overflows this fixes them all Issue in line 1325/1326 found by HAORAN FANG <xfanghaoran@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swscale/output: Fix integer overflow with lum/chr/alpha filterMichael Niedermayer36 hours1-47/+47
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swscale/alphablend: don't overread alpha plane on subsampled odd sizeNiklas Haas4 days1-13/+19
| | | | | | | | | | | | | This function overreads the input plane for odd dimensions, because the chroma plane is always rounded up, which means (xy << subsample) + 1 exceeds the actual alpha plane size. To verify: valgrind ffmpeg -pix_fmt yuva420p -f lavfi -i color -vf \ "scale=1x1,format=yuva420p,scale=alphablend=uniform_color,format=yuv420p \ -vframes 1 -f null - Fixes: https://trac.ffmpeg.org/ticket/11692
* swscale/lut3d: remove unused functionKacper Michajłow12 days1-13/+0
| | | | Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
* swscale/swscale_unscaled: don't add offsets to more NULL pointersJames Almer2025-07-181-2/+2
| | | | | | Continuation of af9b43455a972841154b194057a79ee8b606e727. Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/swscale_unscaled: don't add offsets to NULL pointersJames Almer2025-07-181-1/+1
| | | | | Fixes: libswscale/swscale_unscaled.c:916:20: runtime error: applying zero offset to null pointer Signed-off-by: James Almer <jamrial@gmail.com>
* swscale: add support for new 10/12 bit MSB formatsTimo Rothenpieler2025-07-1111-57/+328
|
* swscale/output: Fix integer overflows in yuv2rgba64_1_c_template()Michael Niedermayer2025-07-061-4/+4
| | | | | | | | Fixes: signed integer overflow: -132524 * 16525 cannot be represented in type 'int' Fixes: 414862270/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-4869083202125824 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swscale/utils: Fix potential race when initializing xyz tablesAndreas Rheinhardt2025-05-271-22/+31
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* swscale/swscale_unscaled: fix planarRgbToplanarRgbWrapper() for formats with ↵Ramiro Polla2025-05-231-2/+9
| | | | | | | | | bpc between 9-14 bits Currently, planarRgbToplanarRgbWrapper() always sets the alpha value to 255, without taking the bit depth into consideration. This commit restricts the alpha value to the bit depth.
* swscale/swscale_unscaled: fix packed16togbra16() for formats with bpc ↵Ramiro Polla2025-05-231-4/+4
| | | | | | | | | | | | | | | | | | | | | between 9-14 bits Currently, packed16togbra16() always sets the alpha value to 0xFFFF, without taking the bit depth into consideration. This causes a bug on x86, which can be reproduced with: ./libswscale/tests/swscale -unscaled 1 -src xyz12le -dst gbrap12be The problem arises in ff_hscale14to15_4_ssse3(), in the conversion from gbrap12be to yuva444p, which comes after the conversion from xyz12le to gbrap12be. It has something to do with pmaddwd not working on unsigned values. There is some code to deal with 0xFFFF if the input has a bit depth of 16, but not for bit depths < 16. We could fix ff_hscale14to15_4_ssse3() to also work correctly with 0xFFFF on bit depths < 16, or we could just not write 0xFFFF there in the first place, which is what this commit does.
* swscale/swscale_unscaled: fix packed30togbra10() for formats with bpc ↵Ramiro Polla2025-05-231-2/+3
| | | | | | | | | between 9-14 bits Currently, packed30togbra10() always sets the alpha value to 0xFFFF, without taking the bit depth into consideration. This commit restricts the alpha value to the bit depth.
* swscale/swscale_unscaled: fix planarCopyWrapper() for yuv444p => yuva444pRamiro Polla2025-05-221-1/+1
| | | | | | | | Currently, planarCopyWrapper() assumes that src[3] must be NULL when the source format has no alpha plane. This commit updates the condition for filling the alpha plane based on the number of components available in the source format as well.
* swscale/graph: prefer bools to intsNiklas Haas2025-05-183-5/+9
| | | | | This is more consistent with the rest of the newly added code, which universally switched to using bools for boolean values.
* swscale/graph: move vshift() and shift_img() to shared headerNiklas Haas2025-05-182-22/+21
| | | | I need to reuse these inside `ops.c`.
* swscale/graph: make noop loop more robustNiklas Haas2025-05-181-1/+3
| | | | | | | | | The current loop only works if the input and output have the same number of planes. However, with the new scaling logic, we can also optimize into a noop the case where the input has extra unneeded planes. For the memcpy fallback to work in these cases we have to instead check if the *output* pointer is set, rather than the input pointer.
* swscale/graph: expose ff_sws_graph_add_passNiklas Haas2025-05-182-21/+38
| | | | So we can move pass-adding business logic outside of graph.c.
* tests/swscale: improve colorization of speedupNiklas Haas2025-05-181-5/+6
| | | | | | The old limits were a bit too tightly clustered around 1.0. Make the value range much more generous, and also introduce a new highlight for speedups above 10.0 (order of magnitude improvement).
* swscale/output: fix integer overflow in yuv2rgba64_full_1_c_template()Michael Niedermayer2025-05-151-4/+4
| | | | | | | | Fixes: signed integer overflow: -293650 * 16525 cannot be represented in type 'int' Fixes: 408304111/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-4762210299871232 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swscale/x86/rgb2rgb: Deduplicate ASM constantsAndreas Rheinhardt2025-04-131-2/+2
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* swscale/swscale: Do not crash on floatsMichael Niedermayer2025-04-101-1/+1
| | | | | | | | | | Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int' Fixes: division by zero Fixes: 391981061/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-6691017763389440 Fixes: 392929028/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5142088307507200 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swscale/output: Fix integer overflow in yuv2gbrp_full_X_c()Michael Niedermayer2025-04-101-3/+3
| | | | | | | | Fixes: signed integer overflow: 1966895953 + 210305024 cannot be represented in type 'int' Fixes: 391921975/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5916798905548800 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swscale/csputils: Remove unused ff_sws_matrix3x3_rmul()Andreas Rheinhardt2025-04-032-14/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* swscale/swscale_unscaled: Actually use X2->RGBA64 conversionsAndreas Rheinhardt2025-03-311-1/+2
| | | | | | | | | The conversion functions were added in e7382b4d0101f02e61fdf5ad2c48aca500bb413f, yet they were never really enabled. Found via -ffunction-sections and --gc-sections. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* tests/swscale: allow setting log verbosityNiklas Haas2025-03-311-0/+4
| | | | | Helpful for debugging the new swscale code, since it dumps the operations list in verbose logging mode.
* tests/swscale: constrain reference SSIM for low bit depth formatsNiklas Haas2025-03-311-0/+12
| | | | | | | | | | | | | | Sometimes, the reference SSIM is significantly higher than the SSIM level expected for the test. This is the case when the source format has a much lower bit depth than the destination format. In this case, the fact that legacy swscale does not accurately preserve the source dither pattern gives it an unfair advantage in a direct comparison, leading to false positives. For example, conversion like rgb4 -> rgb565 should be lossless, but swscale low passes / downscales the input chroma, throwing away massive amounts of detail. This gives it a higher SSIM score since the lowpassed result removes some of the dither noise that was present in the source.
* tests/swscale: calculate theoretical expected SSIMNiklas Haas2025-03-311-12/+62
| | | | | | | | | We can calculate with some confidence the theoretical expected SSIM from an "ideal" conversion, by computing the reference SSIM level for an image dithered with uniformly distributed quatization noise. This gives us an additional safety net to check for regressions even in the absence of a reference to compare against.
* tests/swscale: remove stray whitespace in scanf formatNiklas Haas2025-03-311-1/+1
|
* tests/swscale: check supported inputs for legacy swscale separatelyNiklas Haas2025-03-311-1/+1
| | | | | The new code path supports more formats, so we can't test them all against the legacy implementation.
* tests/swscale: print performance stats on exitNiklas Haas2025-03-311-9/+38
|
* tests/swscale: switch from MSE to SSIMNiklas Haas2025-03-311-43/+65
| | | | | | | | | | And bias it towards Y. This is much better at ignoring errors due to differing dither patterns, and rewards algorithms that lower luma noise at the cost of higher chroma noise. The (0.8, 0.1, 0.1) weights for YCbCr are taken from the paper: "Understanding SSIM" by Jim Nilsson and Tomas Akenine-Möller (https://arxiv.org/abs/2006.13846)
* tests/swscale: use yuva444p as referenceNiklas Haas2025-03-311-4/+4
| | | | | | | Instead of the lossy yuva420p. This does change the results compared to the status quo, but is more reflective of the actual strength of a conversion, since it will faithfully measure the round-trip error from subsampling and upsampling.
* tests/swscale: print speedup numbers in colorNiklas Haas2025-03-311-4/+11
|
* tests/swscale: allow testing only unscaled convertorsNiklas Haas2025-03-311-4/+25
| | | | | | I need this to be able to test the new unscaled conversion code more quickly. We re-order the flags order to make 0 the first entry, so we don't set any flags when performing unscaled tests.
* tests/swscale: use hex format for flags valuesNiklas Haas2025-03-311-2/+2
|
* tests/swscale: allow choosing specific flags and dither modeNiklas Haas2025-03-311-11/+31
| | | | So I can quickly iterate on the new swscale code.
* libs: bump major version for all librariesJames Almer2025-03-282-3/+3
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/x86/rgb2rgb: optimize AVX2 version of uyvytoyuv422Shreesh Adiga2025-03-231-34/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the AVX2 version of uyvytoyuv422 in the SIMD loop does the following: 4 vinsertq to have interleaving of the vector lanes during load from memory. 4 vperm2i128 inside 4 RSHIFT_COPY calls to achieve the desired layout. This patch replaces the above 8 instructions with 2 vpermq and 2 vpermd with a vector register similar to AVX512ICL version. Observed the following numbers on various microarchitectures: On AMD Zen3 laptop: Before: uyvytoyuv422_c: 51979.7 ( 1.00x) uyvytoyuv422_sse2: 5410.5 ( 9.61x) uyvytoyuv422_avx: 4642.7 (11.20x) uyvytoyuv422_avx2: 4249.0 (12.23x) After: uyvytoyuv422_c: 51659.8 ( 1.00x) uyvytoyuv422_sse2: 5420.8 ( 9.53x) uyvytoyuv422_avx: 4651.2 (11.11x) uyvytoyuv422_avx2: 3953.8 (13.07x) On Intel Macbook Pro 2019: Before: uyvytoyuv422_c: 185014.4 ( 1.00x) uyvytoyuv422_sse2: 22800.4 ( 8.11x) uyvytoyuv422_avx: 19796.9 ( 9.35x) uyvytoyuv422_avx2: 13141.9 (14.08x) After: uyvytoyuv422_c: 185093.4 ( 1.00x) uyvytoyuv422_sse2: 22795.4 ( 8.12x) uyvytoyuv422_avx: 19791.9 ( 9.35x) uyvytoyuv422_avx2: 12043.1 (15.37x) On AMD Zen4 desktop: Before: uyvytoyuv422_c: 29105.0 ( 1.00x) uyvytoyuv422_sse2: 3888.0 ( 7.49x) uyvytoyuv422_avx: 3374.2 ( 8.63x) uyvytoyuv422_avx2: 2649.8 (10.98x) uyvytoyuv422_avx512icl: 1615.0 (18.02x) After: uyvytoyuv422_c: 29093.4 ( 1.00x) uyvytoyuv422_sse2: 3874.4 ( 7.51x) uyvytoyuv422_avx: 3371.6 ( 8.63x) uyvytoyuv422_avx2: 2174.6 (13.38x) uyvytoyuv422_avx512icl: 1625.1 (17.90x) Signed-off-by: Shreesh Adiga <16567adigashreesh@gmail.com>
* avutil/libm: Only include intfloat.h when neededAndreas Rheinhardt2025-03-223-2/+5
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* swscale/tests/swscale: Fix potential buffer overflowAndreas Rheinhardt2025-03-211-1/+1
| | | | | | | | | | The field width in a %s directive gives the amount of characters to read from the input and not the size of the receiving buffer; the latter must be of course also have space for the trailing \0 which has been forgotten here. The commit adds it (and fixes a -Wfortify-source warning from Clang). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/csp: Improve enum range comparisonsAndreas Rheinhardt2025-03-211-2/+2
| | | | | | | | | | | | | | | | | | | The underlying integer type of an enumeration is implementation-defined (see C11, 6.7.2.2 (4)); GCC defaults to unsigned if there are no negative values like for all enums from pixfmt.h except enum AVPixelFormat. This means that tests like "if (csp >= AVCOL_SPC_NB)" for invalid colorspaces need not work as expected (namely if enum AVColorSpace is signed). It also means that testing for such an enum variable to be >= 0 may be tautologically true. Clang emits a -Wtautological-unsigned-enum-zero-compare warning for this. Fix both of these issues by casting to unsigned. Also do the same in libswscale/format.c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* swscale/output: add support for NV20James Almer2025-03-193-24/+31
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/input: add support for NV20James Almer2025-03-192-10/+29
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil: only duplicate hal2float and float2half in shared buildsJames Almer2025-03-181-2/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/swscale_unscaled: avoid nv12 <-> nv21 bugNiklas Haas2025-03-171-1/+2
| | | | This is not handled by the planar copy wrapper, so exclude it.
* swscale: fix gray -> grayf32 SIGFPENiklas Haas2025-03-171-1/+1
| | | | | | | | | swscale internals don't distinguish between 16-bit and higher bit depth output formats internally when it comes to the choice of intermediate representation. Clamping this value both prevents a SIGFPE and also aligns the check with reality.
* swscale/swscale_unscaled: make the fast planar copy path work with more formatsJames Almer2025-03-151-19/+11
| | | | | | | | | dst_depth - src_depth where the result is 6 or 7 in a high bd path means this is only executed for 16 -> 10 and 16 -> 9. This patch makes this path general, supporting arbitrary formats as long as dst_depth > src_depth > 8. Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/swscale_unscaled: account for semi planar formats with data in the msbJames Almer2025-03-151-36/+38
| | | | | | Fixes fate failures introduced by recent tests that exercise the faulty code. Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/utils: split off format code into new fileNiklas Haas2025-03-1410-568/+592
| | | | | | | | | | utils.c is getting quite crowded, and I need a new place to dump a lot of format handling code for the ongoing rewrite. Rather than bloating this file even more, start splitting format handling helpers off into a new file. This also renames the existing utils.h header, which didn't really contain anything except the SwsFormat definition anyway (the prototypes for what should have been in utils.h are all still in the legacy swscale_internal.h).