Commit Graph

12570 Commits

Author SHA1 Message Date
Michael Niedermayer
b3c7ebc1ed avfilter/vf_swaprect: size the temp row buffer for the widest plane
Fixes: out of array access
Fixes: 7aj_swaprect_odd17_nv12.nut / 7aj_generate_swaprect_odd17_nv12.py
Fixes: VRAXYvKtmKa8
Found-by: Adrian Junge (vurlo) <adjun37@gmail.com>
(cherry picked from commit a7e38b617b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-21 22:59:59 +02:00
Michael Niedermayer
30a52276f9 avfilter/vf_floodfill: remove unneeded variables
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f186c50cf5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-21 22:59:59 +02:00
Michael Niedermayer
a20608d325 avfilter/vf_floodfill: size the point stack for the current frame
Fixes: out of array access
Fixes: 8aj_floodfill_dynamic_size.pgm / 8aj_generate_floodfill_dynamic_size_pgm.py
Fixes: 3MleMXjGZvu3
Found-by: Adrian Junge (vurlo) <adjun37@gmail.com>
(cherry picked from commit 24c322fdb2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-21 22:59:58 +02:00
Michael Niedermayer
989444060d avfilter/vf_lut3d: compute size2 after the 3DLUTSIZE directive
Fixes: out of array access
Fixes: lut3d_poc/poc_3dlut2.dat
Fixes: 6p0ahHBxreqG
Found-by: SecBuddyF - Tencent KeenLab
(cherry picked from commit 0089694c06)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-21 22:59:58 +02:00
Michael Niedermayer
e6bcc30dcd avfilter/vf_v360: keep remap source coordinates in bounds
Two runtime paths could compute out-of-range source coordinates for
degenerate projection geometry, causing heap-buffer-overflow reads

Fixes: out of array read
Fixes: assertion failure
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a73d648f6e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-21 22:59:55 +02:00
Michael Niedermayer
85d7bb2280 avfilter/vf_v360: reject dimensions too small for the projection
Fixes: out of array read
Fixes: assertion failure
Fixes: mQzloVqnivHQ
Found-by: Anthony Hurtado
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b3712addc9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-21 22:59:55 +02:00
Michael Niedermayer
c20d78c683 avfilter/vf_quirc: resize the quirc buffers when the input size changes
Fixes: out of array access
Fixes: JbvzNObhorBp
Fixes: 030e140145 (lavfi: add quirc filter)
Found-by: Adrian Junge (vurlo)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4da9812e25)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-21 22:59:53 +02:00
Pavel Kohout
2ec918330e avfilter/boxblur: reject pixel formats deeper than 16 bits
Fixes: heap buffer overflow
Fixes: CRufFb6TVikL
Fixes: dee7440531 (vf_boxblur: Templatize blur{8,16})
Found-by: Pavel Kohout (Aisle Research)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0dac41d2e5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-21 22:59:51 +02:00
Michael Niedermayer
eaf524a746 avfilter/vf_removelogo: free the whole mask on allocation failure
Found-by: Ao Xijie
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9a01c1cb6a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-21 22:59:50 +02:00
Michael Niedermayer
4423d1b59e avfilter/af_adeclick: free transform contexts and buffers on error
Found-by: Ao Xijie
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 59a5090070)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-21 22:59:50 +02:00
Jiale Yao
8af6c71d96 avfilter/vf_vif: Fix out of array access with small dimensions
The hand written boundary mirroring reflected an out of range index only
once, which is insufficient when the image dimension is smaller than the
filter half width (filt_w/2 == 8). A 1x1 input made the index reach 8
and -7, reading out of the src[]/temp[] arrays. Use avpriv_mirror(),
which mirrors repeatedly and stays in range for any dimension.

Fixes: out of array access
Fixes: repro.sh
Fixes: HuQn51lLiVJX
Fixes: 38aea9b041 (avfilter: add vif filter)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 56309e476a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-21 22:59:48 +02:00
Lynne
d124bfeada vf_libplacebo: add missing avstring.h include
Otherwise compilation fails due to vulkan.h no longer including it.

(cherry picked from commit 90436de5e1)
2026-07-14 00:14:28 +09:00
Lynne
062de19095 configure: remove libshaderc and libglslang support
All of it is now gone.

(cherry picked from commit 92f2e6374d)
2026-07-14 00:14:28 +09:00
Lynne
ca089c35c4 vulkan: remove runtime shader compilation support
No longer needed.

(cherry picked from commit 9e9ac0dcd9)
2026-07-14 00:14:28 +09:00
Lynne
9b53c361ab vf_scale_vulkan: port to compile-time SPIR-V generation
Same functionality as before, but cleaner.

(cherry picked from commit 6219d4fdd1)
2026-07-14 00:14:28 +09:00
Kacper Michajłow
b06c5316b7 avfilter/vsrc_gfxcapture_winrt: add missing system_error include
Fixes: error: no type named 'system_error' in namespace 'std'
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
(cherry picked from commit c6498178bb)
2026-07-06 09:55:38 +00:00
Niklas Haas
901a25e0d1 avfilter/vf_scale_cuda: fix inverted downscaling check
Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 6baf561303)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:59 +02:00
Niklas Haas
74c735ab10 avfilter/vf_scale_cuda: allocate inter buffer with correct subsampling
Since the input and output format can differ (e.g. 444 -> 420), we need to
reference the correct subsampling for the partially applied filter.

Keep track of this in the CUDATex itself.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 01972b4f85)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:47 +02:00
Niklas Haas
316651a9ae avfilter/vf_scale_cuda: allocate intermediate buffer directly
Instead of going via an AVFrame at all. This will allow us to fix the
intermediate chroma plane size for split downscaling.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 420a9e90b8)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:37 +02:00
Niklas Haas
3a7097cfa7 avfilter/vf_scale_cuda: use persistent intermediate CUDATex
Instead of re-creating this object every frame.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit e79e9f06ba)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:26 +02:00
Niklas Haas
f3f292929e avfilter/vf_scale_cuda: defer buffer allocation to setup_filters()
At this point, s->hwctx and CudaFunctions * are available.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 4289a29bb0)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:16 +02:00
Niklas Haas
c5caacd845 avfilter/vf_scale_cuda: introduce CUDATex and mapping helper
I want to disentangle the internal logic from AVFrame, because some
intermediate states (e.g. for partially subsampled chroma with simultaneous
scaling) may not directly map to a valid AVPixelFormat.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit fef976b197)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:10:05 +02:00
Niklas Haas
480bf29af3 avfilter/vf_scale_cuda: add fail: label (cosmetic)
Make the next commit a bit easier to review.

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 61750318db)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:09:51 +02:00
Niklas Haas
9573519b01 avfilter/vf_scale_cuda: eliminate redundant context push/pop
This is already done by cudascale_filter_frame().

Signed-off-by: Niklas Haas <git@haasn.dev>
(cherry picked from commit 0c3f04a97c)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-06-29 18:09:37 +02:00
Michael Niedermayer
47e9d68e20 Bump minor for release/9.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 02:43:34 +02:00
Diego de Souza
df94900c98 avfilter/cuda: support P012/P212 and MSB 4:4:4 in scale/transpose/thumbnail
NVDEC and CUVID now output AV_PIX_FMT_P012 (12-bit 4:2:0), AV_PIX_FMT_P212
(12-bit 4:2:2) and AV_PIX_FMT_YUV444P10MSB / AV_PIX_FMT_YUV444P12MSB
(10/12-bit 4:4:4) for high-bit-depth content, but these CUDA filters
rejected the formats in their supported-format lists, breaking pipelines
such as "-hwaccel cuda ... -vf scale_cuda" on 12-bit input.

These formats use 16-bit sample storage, and the filters select their CUDA
kernel by byte-storage size and plane layout, not by the number of valid
bits, so they can reuse the existing 16-bit kernels:

- scale_cuda: P012/P212 -> "semiplanar16", YUV444P10MSB/YUV444P12MSB ->
  "planar16".
- transpose_cuda: the ushort/ushort2 kernels are chosen from the pixel
  descriptor (byte size + channel count); just allow the new formats.
- thumbnail_cuda: P012 reuses the P010/P016 path and the MSB 4:4:4 formats
  reuse the YUV444P16 path; P012 is added to the 4:2:0 chroma-histogram
  scaling as well. (thumbnail has no 4:2:2 path, so P212 is not added.)

The CUDA deinterlacers (bwdif_cuda, yadif_cuda) already accept any format
with <= 2 bytes per sample and <= 2 channels, so they need no change. The
8-bit-only filters (overlay_cuda, pad_cuda, bilateral_cuda, chromakey_cuda,
colorspace_cuda) do not support high bit depths and are left untouched.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-24 12:18:15 +00:00
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