12544 Commits

Author SHA1 Message Date
Andreas Rheinhardt
2f59339479 avfilter/buffersink: Fix indentation
Necessary after 509c1f99a7.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 22:38:55 +00:00
Niklas Haas
9420146e6d avfilter/vf_scale_cuda: re-indent after previous change
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas
5d0748243f avfilter/vf_scale_cuda: add use_filters option
This may be faster or slower than the existing specialized kernels,
so I opted not to prefer it by default. I also deliberately didn't expose
additional filter function capabilites yet.

The main motivating reason here is to get correct anti-aliasing behavior
when downscaling, which is currently completely broken.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas
469281fa50 avfilter/vf_scale_cuda: add generic 1D filter kernel
This can be useful for any sort of separable filtering with arbitrary
weights.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas
d98cc462f6 avfilter/vf_scale_cuda: generalize kernel signature to accept weights
Ignored for now by the existing fixed function kernels.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas
b400791442 avfilter/scale_filters: add internal copy of libswscale/filters.c
Useful for GPU-based filters, which may also need to compute filter weights.
Since we cannot cross-link to internal functions, we need to recompile this
helper inside libavfilter.c.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Andreas Rheinhardt
762b94e672 libs: Bump major version of all libraries
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
2d3776b8cc avutil/x86/emms: Unavpriv avpriv_emms_asm()
This fallback function is used if external MMX is available,
while inline MMX and intrinsics for emitting emms are unavailable.
It is implemented as an avpriv function, which has several
drawbacks for shared builds:
1. The function is so small (3 bytes; 16 with padding)
that the overhead of exporting and importing it dwarfs
the gains from code deduplication.
2. A call to an external library has more overhead than
a library-internal one.
3. It may cause linking failures when a libavutil not exporting
avpriv_emms_asm() is paired with a library needing it
(if inline assembly and intrinsics were unavailable when building
the dependent library). I am not aware of this ever happening.
4. We would be forced to keep avpriv_emms_asm() around for ABI stability
even after it is no longer needed.

This commit therefore uses the STLIBOBJS, SHLIBOBJS approach
to duplicating it into each library on its own if needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
9f58e3014c avfilter: Remove FF_API_LIBNPP_SUPPORT
libnpp and the corresponding filters have been deprecated
in commit 994a368451
on 2025-09-26. By the time of our next release,
a year will have passed, so they are removed immediately.

Note: Passing --enable-libnpp to configure results in
a warning about the deprecation and is otherwise a no-op.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt
7116138857 avfilter/avfilter: Remove FF_API_CONTEXT_PUBLIC
Deprecated on 2024-10-07.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt
509c1f99a7 avfilter: Remove deprecated FF_API_BUFFERSINK_OPTS
Deprecated since 2024-09-30.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Jun Zhao
b08c9c5f53 lavfi/vf_subtitles: expose shaping option
The ass filter exposes libass' shaping mode selection so callers can
request complex shaping for scripts such as Arabic. The subtitles filter
uses the same renderer path but did not expose the option.

This left the zero-initialized shaping field to select
ASS_SHAPING_SIMPLE implicitly.

Expose the same shaping option for subtitles and default it to auto,
matching the ass filter. This allows subtitles=...:shaping=complex to
render Arabic lam-alef correctly when libass is built with HarfBuzz
support.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-23 03:57:25 +00:00
Kacper Michajłow
efa8b20987 vf_libplacebo: remove compatibility code with not supported versions 2026-06-22 16:18:59 +00:00
stevxiao
a2856b3c30 avfilter/dnn: add ONNX Runtime backend with GPU execution provider support
This patch adds ONNX Runtime as a new DNN backend for FFmpeg's dnn_processing
filter, enabling hardware-accelerated neural network inference on multiple
GPU and NPU platforms.

Execution Providers Supported:
- CPU execution provider (default)
- CUDA execution provider (NVIDIA GPUs)
- DirectML execution provider (AMD/Intel/NVIDIA GPUs on Windows)
- VitisAI execution provider (AMD Ryzen AI NPU)

The options for dnn_processing with dnn_backend=onnx:
- device: execution provider — cpu, cuda, dml, or vitisai (default: cpu)
- device_id: GPU device index (default: 0)
- threads_per_operation: inference thread count for CPU EP (default: 0, auto)
- input: input tensor name. When omitted the backend resolves it from loaded session
- output: output tensor name. When omitted the backend resolves it from loaded session

Example usage:
  # CPU inference
  ffmpeg -i input.mp4 -vf "format=rgb24,dnn_processing=dnn_backend=onnx:model=model.onnx:input=image_in:output=image_out" output.mp4

  # CUDA GPU inference
  ffmpeg -i input.mp4 -vf "dnn_processing=dnn_backend=onnx:model=model.onnx:device=cuda:device_id=0" output.mp4

  # DirectML GPU inference (Windows)
  ffmpeg -i input.mp4 -vf "dnn_processing=dnn_backend=onnx:model=model.onnx:device=dml:device_id=0" output.mp4

  # VitisAI NPU inference
  ffmpeg -i input.mp4 -vf "dnn_processing=dnn_backend=onnx:model=model.onnx:device=vitisai" output.mp4

  Note: depending on the model, you may need a format filter (e.g. format=rgb24 or format=grayf32) before dnn_processing to convert the frames to the pixel format the model's input tensor expects.

Signed-off-by: younengxiao <steven.xiao@amd.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2026-06-22 20:06:40 +08:00
Zhao Zhili
07b9158994 avfilter/avf_showcwt: drop redundant outer av_clip
av_clipd() already bounds the result to [1, 65536]. The surrounding
av_clip() can never alter it.
2026-06-22 11:43:51 +00:00
Marvin Scholz
bfa67bafad lavfi: af_showinfo: add support for IAMF side-data 2026-06-17 00:03:14 +00:00
Michael Niedermayer
44d082edc8 avfilter/convolution: compute user matrix products in unsigned
Fixes: integer overflow

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 03:15:19 +00:00
Michael Niedermayer
5f13df1b51 avfilter/avf_showcwt: fix DIRECTION_RL EOF fill clearing the wrong columns
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:08:21 +00:00
Michael Niedermayer
b276ac07e8 avfilter/avf_showcwt: avoid undefined float to int conversion of nb_consumed_samples
Reproduced with:
ffmpeg -f lavfi -i "sine=frequency=440" -filter_complex \
 "[0:a]showcwt=size=32x32:deviation=0[v]" -map "[v]" -f null -

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:08:21 +00:00
Michael Niedermayer
d133b4a231 avfilter/avf_showcwt: fix out of array read in compute_kernel
Reproduced with a small output (e.g. size=2x2) under ASan.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:08:21 +00:00
jiale yao
0d0eadd8ed avfilter/avf_showcwt: fix DIRECTION_DU EOF fill clearing the wrong rows
Fixes: out of array read

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:08:21 +00:00
Michael Niedermayer
a55a8c9a68 avfilter/v360: compute remap table offsets in 64bit
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:01:41 +00:00
Michael Niedermayer
fd6b3fa423 avfilter/v360: reject out-of-range dimensions
Fixes: integer overflow

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 21:01:41 +00:00
Michael Niedermayer
f7368f97b9 avfilter: use ff_slice_pos() for per-slice boundary computation
This is a behavior preserving change for all non-overflowing cases.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 21:41:05 +00:00
Michael Niedermayer
218b4771a3 avfilter: add ff_slice_pos() helper for slice boundaries
Slice based filter workers compute their per-thread row/sample/channel
boundaries as total * jobnr / nb_jobs. The total * jobnr product is
evaluated in int and overflows signed int for large dimensions and many
slice threads, before the division by nb_jobs brings it back in range.
2026-06-13 21:41:05 +00:00
Michael Niedermayer
200e0cba67 avfilter/estdif: avoid signed overflow in slice boundary calculation
deinterlace_slice() computed per-thread row boundaries with int
multiplication height * (jobnr + 1). With a tall frame and many filter
threads the product overflows signed int before the division by nb_jobs.

Use int64_t for the intermediate product before converting back to int
row indices.

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 21:41:05 +00:00
wangbin
c73476e107 avfilter/vf_scale_d3d11: ensure guids are defined
fix vf_scale_d3d11.o : error LNK2001: unresolved external symbol IID_ID3D11VideoContext
2026-06-10 15:08:12 +00:00
Robert Nagy
97491ce0d5 libavfilter/libplacebo: gamma22 and gamma28 aliases 2026-06-10 12:34:38 +00:00
haoyuLiu
6028720d70 avfilter/zmq: initialize send_buf before shared cleanup on parse failure
Found-by: VulnForge Security Research Team
Reported-by: Cloud-LHY <haoyuliu@clouditera.com>
2026-06-08 02:20:53 +00:00
Diego de Souza
6e857f12a7 avfilter/vf_scale_cuda: avoid <stdint.h> in CUDA device compilation
The device-only compilation path of vf_scale_cuda.h pulled in <stdint.h>
solely to obtain uint8_t for the CUdeviceptr typedef. On Windows-on-ARM
(aarch64 mingw) this drags in _mingw.h, whose ARM __prefetch intrinsic is
guarded by !__has_builtin(__prefetch). During clang's --cuda-device-only
pass __has_builtin has deferred/inconsistent semantics on the auxiliary
(host) target, so the guard mis-fires, the inline __prefetch definition is
emitted, and clang rejects it:

    _mingw.h: error: definition of builtin function '__prefetch'

This broke the msys2-clangarm64 FATE slot once ffnvcodec (and thus the
nvcc-compiled CUDA filters) was enabled for aarch64 Windows.

uint8_t is unsigned char, so use that directly and drop the <stdint.h>
include. Device-only code should not depend on the host C runtime headers.
No functional or ABI change.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-03 19:45:19 +00:00
jiale yao
e8031e5b9a avfilter/avf_showcwt: fix out-of-bounds read in du scroll
Fixes: out of array access
Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-03 12:25:00 +00:00
Michael Niedermayer
537e87e3c2 avfilter/f_ebur128: avoid signed-int wrap when sizing per-channel cache
Fixes: integer overflow
Fixes: out of array access

Found-by: Claude (Anthropic), reported by Omkhar Arasaratnam <omkhar@linkedin.com>.
2026-06-03 01:45:08 +00:00
Niklas Haas
bb5c461a47 avfilter/vf_libplacebo: setup pl_vulkan_queue.flags on import params
libplacebo versions before v365 passed .flags = 0 when retrieving the queues
from imported Vulkan devices, so we have to error out in the case of a mismatch
to avoid undefined behavior (Vulkan spec).

See-Also: https://code.videolan.org/videolan/libplacebo/-/merge_requests/856
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 13:32:44 +02:00
Niklas Haas
9b9d29e09a avfilter/vf_libplacebo: don't unnecessarily set fields to 0 (cosmetic)
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 13:32:44 +02:00
Jun Zhao
d092269996 lavfi/vf_drawtext: log inferred shaping properties at verbose
Log the script and direction picked by HarfBuzz, plus codepoint and
glyph counts, so the shaper choice can be verified. Differing
codepoint and glyph counts indicate reordering / ligation /
decomposition.

Codepoints are sampled before hb_shape(), which flips the buffer
content type to GLYPHS.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-02 00:52:03 +00:00
Jun Zhao
1f9888beb0 lavfi/vf_drawtext: fix HarfBuzz shaping of Bengali / Indic scripts
shape_text_hb() set HB_SCRIPT_LATIN and called
hb_buffer_guess_segment_properties() on an empty buffer, so the
inference was a no-op. Bengali and other Indic / USE scripts reached
the default OT shaper instead of their script-specific shaper,
leaving the virama visible and consonants disjointed (e.g. স্টারমার
rendered as স্ টারমার).

Add the UTF-8 text first, keep the existing LTR direction used by the
FriBidi visual-order pipeline, then guess segment properties so the
script comes from the actual Unicode contents.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/23014
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-02 00:52:03 +00:00
Michael Niedermayer
97ea5da419 avfilter/vf_scale: split rational multiply
Fixes: integer overflow in SAR
Found-by: jiale yao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 21:20:54 +00:00
Kacper Michajłow
a76eae2765 avfilter/Makefile: fix build with Vulkan and runtime GLSL compilation
Fixes: avfilter/vulkan_shaderc.c:90: undefined reference to `ff_vk_shader_print'
Fixes: #23231

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-31 13:38:30 +00:00
Michael Niedermayer
073c44b8bc avfilter/vf_drawtext: Avoid double free in glyph_enu_border_free()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
Michael Niedermayer
77554d85d7 avfilter/vf_drawtext: shape_text_hb() free allocated things on error
Fixes: memleak
Found-by: Fairy

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
Michael Niedermayer
47c503c6a9 avfilter/vf_drawtext: plug error-path leaks in measure_text/draw_text
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
Michael Niedermayer
9efca1d946 avfilter/vf_drawtext: avoid double-free of aliased FT_Glyph in glyph_enu_free
For glyphs whose source is already in bitmap form (color emoji fonts such
as NotoColorEmoji.ttf), FT_Glyph_To_Bitmap(..., destroy=0) returns the
input pointer unchanged. The result is that glyph->bglyph[idx] aliases
glyph->glyph (and analogously border_bglyph[t] may alias border_glyph).
glyph_enu_free then called FT_Done_Glyph on both, double-freeing the
underlying object.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
Michael Niedermayer
c51789b052 avfilter/vf_drawtext: don't double-free glyph that has been cached in tree
Reproducer:
  ffmpeg -f lavfi -i color=s=640x120:d=1 \
      -vf "drawtext=fontfile=/usr/share/fonts/truetype/noto/NotoColorEmoji.ttf:\
text='FFmpeg':fontsize=109:fontcolor=white:x=20:y=35" \
      -frames:v 1 out.png

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
Michael Niedermayer
c8c4e2d2a5 avfilter/vf_drawtext: always check pixel_mode == FT_PIXEL_MODE_MONO
The code as written can add such glyphs in the cache so we need to check
glyphs from the cache too.
This should be the most robust and simple solution

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-31 03:25:21 +00:00
James Almer
1a0ab27954 avfilter/af_aresample: propagate the matrix encoding used for downmixing
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-30 21:37:33 -03:00
James Almer
971da26361 avfilter/af_aresample: fix layout comparison when applying downmix coeffs
out_layout at this point is a zeroed struct, and even after being filled below in the code
it's ensured it will be the same as outlink->side_data.
The actual check should be between inlink and outlink layouts. If they differ, then swr
will do remixing and as such the downmix info side data will no longer be valid for any
filter or encoder down the chain.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-30 21:37:33 -03:00
Franciszek Kalinowski
461fb22053 avfilter/af_join: fix wrong loop bound in buffer dedup (use-after-free)
try_push_frame() decides whether an input buffer is already tracked by testing
`j == i` (the channel index) instead of `j == nb_buffers`. Once an earlier
channel shared a buffer, nb_buffers falls behind i and a genuinely new buffer is
never referenced, so it is freed while the output frame still points at it.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-05-25 22:21:41 +00:00
Lynne
437aa4d208 lavfi/blackdetect_vulkan: use integer timestamps and fix crash 2026-05-22 14:06:03 +09:00
Lynne
a189413832 vf_blackdetect_vulkan: port to compile-time SPIR-V generation 2026-05-22 14:06:03 +09:00
Lynne
2e25da3121 vf_nlmeans_vulkan: port to compile-time SPIR-V generation 2026-05-22 14:06:01 +09:00