1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00
Commit Graph

12273 Commits

Author SHA1 Message Date
Zhao Zhili
a5cc0e5c9e avfilter/vf_drawtext: fix call GET_UTF8 with invalid argument
For GET_UTF8(val, GET_BYTE, ERROR), val has type of uint32_t,
GET_BYTE must return an unsigned integer, otherwise signed
extension happened due to val= (GET_BYTE), and GET_UTF8 went to
the error path.

This bug incidentally cancelled the bug where hb_buffer_add_utf8
was being called with incorrect argument, allowing drawtext to
function correctly on x86 and macOS ARM, which defined char as
signed. However, on Linux and Android ARM environments, because
char is unsigned by default, GET_UTF8 now returns the correct
return, which unexpectedly revealed issue #20906.
2025-11-19 17:46:06 +00:00
Zhao Zhili
9bc3c572ea avfilter/vf_drawtext: fix incorrect text length
From the doc of HarfBuzz, what hb_buffer_add_utf8 needs is the
number of bytes, not Unicode character:
hb_buffer_add_utf8(buf, text, strlen(text), 0, strlen(text));

Fix issue #20906.
2025-11-19 17:46:06 +00:00
Stefan Breunig
f8bfc20281 avfilter/vf_frei0r: fix time when input is realigned
av_frame_copy doesn't copy the input's PTS property, which resulted
in the frei0r filter always receiving the same static time.

Example that has a static distortion without patch:

ffmpeg -filter_complex "testsrc2=s=328x240:d=5,frei0r=distort0r" out.mp4
2025-11-18 21:26:36 +00:00
Carl Hetherington via ffmpeg-devel
1eb2cbd865 avfilter/f_ebur128: Fix incorrect ebur128 peak calculation.
Since 3b26b782ee it would only look at the
first channel.

Signed-off-by: Carl Hetherington <cth@carlh.net>
Reviewed-by: Niklas Haas <ffmpeg@haasn.xyz>
2025-11-18 08:40:08 +01:00
Andreas Rheinhardt
ddf443f1e9 avfilter/vf_fsppdsp: Fix left shifts of negative numbers
They are undefined behavior and UBSan warns about them
(in the checkasm test). Put the shifts in the constants
instead. This even gives a tiny speedup here:

Old benchmarks:
column_fidct_c:                                       3369.9 ( 1.00x)
column_fidct_sse2:                                     829.1 ( 4.06x)
New benchmarks:
column_fidct_c:                                       3304.2 ( 1.00x)
column_fidct_sse2:                                     827.9 ( 3.99x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt
f8bcea4946 avfilter/vf_fsppdsp: Remove pointless cast
Also don't cast const away and use a smaller scope.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt
0c556a6b09 avfilter/vf_fspp: Pre-reorder threshold table
Avoids reordering at runtime.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt
778ff97efa avfilter/vf_fspp: Make output endian-independent
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt
f442145729 avfilter/vf_fspp: Avoid casts, effective-type violations
Maybe uint64_t has been used as a poor man's alignment specifier?
Anyway, reading an uint64_t via an lvalue of type int16_t (as happens
in the C versions of the dsp functions) is undefined behavior.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt
c0648b2004 avfilter/x86/vf_spp: Fix comment
Forgotten in dcb28ed860.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt
06b0dae51b avfilter/vf_fsppdsp: Constify
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt
cc97f1e276 avfilter/vf_fspp: Fix effective type violation
Also don't use unnecessarily large alignment; it avoids having to align
the stack.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt
3cd452cbf1 avfilter/x86/vf_fspp: Avoid stack on x64
Possible due to the amount of registers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt
ddd74276f8 avfilter/x86/vf_fspp: Port ff_column_fidct_mmx() to SSE2
It gains a lot because it has to operate on eight words;
it also saves 608B of .text here.

Old benchmarks:
column_fidct_c:                                       3365.7 ( 1.00x)
column_fidct_mmx:                                     1784.6 ( 1.89x)

New benchmarks:
column_fidct_c:                                       3361.5 ( 1.00x)
column_fidct_sse2:                                     801.1 ( 4.20x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:11 +01:00
Andreas Rheinhardt
63493bf0e0 avfilter/x86/vf_fspp: Put shifts into constants
This avoids some shift instructions and also gives us more headroom
in the registers. In fact, I have proven to myself that everything
that is supposed to fit into 16bits now actually does so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:11 +01:00
Andreas Rheinhardt
66af18d06a avfilter/x86/vf_fspp: Make ff_column_fidct_mmx() bitexact
It currently is not, because the shortcut mode uses different rounding
than the C code (as well as the non-shortcut code).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:11 +01:00
Andreas Rheinhardt
1049a5fba8 avfilter/vf_fsppdsp: Reduce discrepancies between C code and x86 asm
The x86 assembly uses the following pattern to zero all
the values with abs<threshold:
    x -= threshold;
    x satu+= threshold (unsigned saturated addition)
    x += threshold
    x satu-= threshold (unsigned saturated subtraction)
The reference C code meanwhile zeroed everything
with abs <= threshold. This commit makes the C code behave
like the x86 assembly to reduce discrepancies between the two.

An alternative would be to require SSSE3, so that
one can use pabsw, pcmpgtw for abs>threshold, followed by
a pand with the original data. Or one could modify the thresholds
to make both equal.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt
d19050a1ae avfilter/vf_fsppdsp: Use restrict
It is possible because the requirements are fulfilled;
it is also beneficial performance and code-size wise.
For GCC 14 (with -O3), this reduced codesize by 26750B
here; for Clang 20, it was 432B.

Old benchmarks:
mul_thrmat_c:                                            4.3 ( 1.00x)
mul_thrmat_sse2:                                         4.3 ( 1.00x)
store_slice_c:                                        2810.8 ( 1.00x)
store_slice_sse2:                                      542.5 ( 5.18x)
store_slice2_c:                                       3817.0 ( 1.00x)
store_slice2_sse2:                                     410.4 ( 9.30x)

New benchmarks:
mul_thrmat_c:                                            4.3 ( 1.00x)
mul_thrmat_sse2:                                         4.3 ( 1.00x)
store_slice_c:                                        1510.1 ( 1.00x)
store_slice_sse2:                                      545.2 ( 2.77x)
store_slice2_c:                                       1763.5 ( 1.00x)
store_slice2_sse2:                                     408.3 ( 4.32x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt
ff85a20b7d avfilter/x86/vf_fspp: Port store_slice to SSE2
Old benchmarks:
store_slice_c:                                        2798.3 ( 1.00x)
store_slice_mmx:                                       950.2 ( 2.94x)
store_slice2_c:                                       3811.7 ( 1.00x)
store_slice2_mmx:                                      682.3 ( 5.59x)

New benchmarks:
store_slice_c:                                        2797.2 ( 1.00x)
store_slice_sse2:                                      543.5 ( 5.15x)
store_slice2_c:                                       3817.0 ( 1.00x)
store_slice2_sse2:                                     408.2 ( 9.35x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt
e042f17e99 avfilter/vf_fsppdsp: Use standard clamping
This is obviously what is intended and what the MMX code does;
yet I cannot rule out that it changes the output for some inputs:
I have observed individual src values which would lead to temp
values just above 512 if they came in pairs (i.e. if both inputs
were simultaneously huge).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt
52ba2ac7bd avfilter/x86/vf_fspp: Port mul_thrmat to SSE2
This fixes an ABI violation, as mul_thrmat did not issue emms.
It seems that this ABI violation could reach the user, namely
if ff_get_video_buffer() fails. Notice that ff_get_video_buffer()
itself could fail because of this, namely if the allocator uses
floating point registers.

On x64 (where GCC already used SSE2 in the C version)
mul_thrmat_c:                                            4.4 ( 1.00x)
mul_thrmat_mmx:                                          8.6 ( 0.52x)
mul_thrmat_sse2:                                         4.4 ( 1.00x)

On 32bit (where SSE2 is not known to be available):
mul_thrmat_c:                                           56.0 ( 1.00x)
mul_thrmat_sse2:                                         6.0 ( 9.40x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt
9f4d5d818d avfilter/x86/vf_fspp: Don't duplicate dither table
Reuse the one from vf_fsppdsp.c; also don't overalign said table too
much.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt
1699de0955 avfilter/vf_fsppdsp: Use enum for constants
It means that the compiler does not have to optimize the static const
object away.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt
9b34088c4d avfilter/vf_fspp: Add DSPCtx, move DSP functions to file of their own
This is in preparation for adding checkasm tests; without it,
checkasm would pull all of libavfilter in.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Michael Niedermayer
ad956ff076 avfilter/vf_drawtext: Account for bbox text seperator
Fixes: out of array access
no test case

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-16 20:32:11 +01:00
Lynne
be99d2c0b2 vf_colorspace: allow for extended primaries and colorspace 2025-11-10 21:50:58 +00:00
Zhao Zhili
c4ce51ee62 avfilter/vf_libopencv: bump to opencv4 2025-11-10 04:12:50 +00:00
Stefan Breunig
549b45459e avfilter/vf_frei0r: fix time not being passed in seconds
The frei0r API expects the time in seconds, but was given it in
milliseconds. The bug might exist since 41f1d3a (~14 years ago),
but plugins depending on the time are unwatchable without this
patch. For example:

ffmpeg -filter_complex "testsrc2=d=5,frei0r=distort0r" out.mp4

Signed-off-by: Stefan Breunig <stefan-ffmpeg-devel@breunig.xyz>
2025-11-08 20:55:03 +00:00
Niklas Haas
84b365d522 avfilter/avfiltergraph: print both failing links on conversion error
This is more informative than the current behavior, because when the first
MERGE() succeeds but the second fails, the original link already has
merged formats and thus the error message is confusing.
2025-11-06 18:16:10 +01:00
Niklas Haas
6c3a63112b avfilter/avfiltergraph: only print format lists for failing mergers
Instead of printing all format lists on a link negotiation error, just print
the relevant/failing format lists.
2025-11-06 18:09:36 +01:00
Niklas Haas
7b564e2efc avfilter/avfiltergraph: print all format lists on config failure
Instead of just printing the pixel/sample formats.
2025-11-06 18:01:37 +01:00
Niklas Haas
ad5b151f88 avfilter/formats: add name field to AVFilterFormatMerger
Needed to properly print format lists on format configuration failure.
2025-11-06 18:01:33 +01:00
Niklas Haas
f5bc9704ed avfilter/formats: constify ff_filter_get_negotiation 2025-11-06 17:48:50 +01:00
Niklas Haas
c1717cb666 avfilter/format: add print_list() to AVFilterFormatsMerger
So that the generic code can correctly print format lists for failing mergers.
2025-11-06 17:34:43 +01:00
Niklas Haas
08eda05967 avfilter/vf_libplacebo: make rotation check more robust
This currently does not make any difference, but it makes the check
more robust against possible future changes to the rotation parameter.
2025-11-04 12:38:55 +00:00
Niklas Haas
49452967e7 avfilter/vf_libplacebo: don't override existing rotation attribute
This is a regression introduced by the addition of the rotation option,
which overrode the existing rotation attribute that may have been set to
the image.

To fix it, add the rotation istead of setting it - however we have to do this
directly when mapping, so as to not add it multiple times.

Fixes: 4f623b4c59
2025-11-04 12:38:55 +00:00
Lynne
0d11c5c2f9 libplacebo: extend allowed range of color primaries and transfer functions
This was left out of the earlier commits.
2025-10-28 22:19:34 +01:00
Lynne
92a688cabd lavu: add support for Panasonic V-Gamut 2025-10-28 20:46:21 +01:00
Lynne
aeb9b19ebc lavu: add support for Panasonic V-Log 2025-10-28 20:46:21 +01:00
James Almer
08c94518c9 avfilter/vsrc_testsrc: add support for YUV444P1{0,2}MSB to yuvtestsrc
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-28 19:16:58 +00:00
Kacper Michajłow
ccb1865a82 avfilter/buffersink: move ret declaration to suppress unused warning
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 15:39:39 +01:00
James Almer
d9853e66d3 avfilter/Makefile: fix dependency for drawvg test
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-25 10:57:56 -03:00
Ayose
016d767c8e lavfi: add drawvg video filter.
The drawvg filter can draw vector graphics on top of a video, using libcairo. It
is enabled if FFmpeg is configured with `--enable-cairo`.

The language for drawvg scripts is documented in `doc/drawvg-reference.texi`.

There are two new tests:

- `fate-filter-drawvg-interpreter` launch a script with most commands, and
  verify which libcairo functions are executed.
- `fate-filter-drawvg-video` render a very simple image, just to verify that
  libcairo is working as expected.

Signed-off-by: Ayose <ayosec@gmail.com>
2025-10-25 13:21:50 +00:00
Michael Yang
62d43ba2e3 libavfilter/vf_nlmeans_vulkan: fix str defaults
Revert back to NAN as -1.0 was erroneously to 0.0 to fit in the options
range.

Add special handling of str per requested.
2025-10-16 21:32:43 +00:00
Michael Yang
e8213f766f libavfilter/vf_nlmeans_vulkan: amend doc 2025-10-16 21:32:43 +00:00
Michael Yang
7d65ce7763 libavfilter/vf_nlmeans_vulkan: clean up defaults
Change per-plane strength defaults to -1.0.
2025-10-16 21:32:43 +00:00
Michael Yang
26dee5b43e libavfilter/vf_nlmeans_vulkan: reverse img_bar 2025-10-16 21:32:43 +00:00
Michael Yang
71ff349cc1 libavfilter/vf_nlmeans_vulkan: lower strength min
Lower (per-component) strength minimum from 1.0 to 0.0, with 0.0 skipping
integral and weights calculations.
2025-10-16 21:32:43 +00:00
Michael Yang
2e12b3251d libavfilter/vf_nlmeans_vulkan: clean up naming
Add `nb_components` to push data.

Rename `ws_total_*`` to `ws_*`.
2025-10-16 21:32:43 +00:00
Michael Yang
3fac2d8593 avfilter/vf_nlmeans_vulkan: rewrite filter
This is a major rewrite of the exising nlmeans vulkan code, with bug
fixes and major performance improvement.

Fix visual artifacts found in ticket #10661, #10733. Add OOB checks for
image loading and patch sized area around the border. Correct chroma
plane height, strength and buffer barrier index.

Improve parallelism with component workgroup axis and more but smaller
workgroups. Split weights pass into vertical/horizontal (integral) and
weights passes. Remove h/v order logic to always calculate sum on
vertical pass. Remove atomic float requirement, which causes high memory
locking contentions, at the cost of higher memory usage of w/s buffer.
Use cache blocking in h pass to reduce memory bandwidth usage.
2025-10-16 21:32:43 +00:00