Commit graph

12372 commits

Author SHA1 Message Date
Zhao Zhili
6b949407cb avfilter: use int instead of enum for AVOption fields
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-26 11:40:16 +08:00
Andreas Rheinhardt
f951aa9ef3 avfilter/af_loudnorm: Avoid unchecked allocation
Also deduplicate printing json and summary output.

Reviewed-by: Kyle Swanson <k@ylo.ph>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 20:35:16 +01:00
Lynne
3ba81f2af4
vulkan: drop support for descriptor buffers
Descriptor buffers were a neat attempt at organizing descriptors.
Simple, robust, reliable.

Unfortunately, driver support never caught on, and neither did validation
layer support.

Now they're being replaced by descriptor heaps, which promises to be
the future. We'll see how it goes.
2026-02-19 19:42:31 +01:00
Lynne
d616269035
vulkan: don't set FFVulkanDescriptorSetBinding.name when not necessary
It just bloats the code with unused strings.
2026-02-19 19:42:26 +01:00
Lynne
ae1a227cf6
Makefile: specify GLSL version via command line arguments
GLSL strictly mandates the version must be the very first non-comment
statement, which results in issues when #including for templating.
2026-02-19 19:42:20 +01:00
nyanmisaka
c96b0d94eb scale_vulkan: fix descriptor type for non debayer path
fixup 80229c1

[scale_vulkan @ 0000028b1c2c1300] scale:31: error: 'texture' : no matching overloaded function found
scale:31: error: 'return' : cannot convert return value to function return type

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-02-19 18:41:44 +00:00
Adam Jensen
059c57a83e avfilter/af_loudnorm: add stats_file option
loudnorm provides stats output that's meant to be used for two-pass
normalization. These stats are often interleaved with ffmpeg's stream
descriptions and other output, making them difficult to parse and pass
to the second pass. The new stats_file option enables writing the stats
to a separate file, or to standard output, for simple parsing and other
programmatic usage.

Signed-off-by: Adam Jensen <adam@acj.sh>
2026-02-19 12:48:58 +00:00
James Almer
eb36dce742 avfilter/video: reduce potential amount of pool reinitializations
Given we now align both dimensions when allocating buffers, don't reinitialize
the pool when dealing with dimension changes that will not affect the existing
pool size.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:19:01 -03:00
James Almer
14097ee1cd avfilter/framepool: add a few padding lines by aligning height
Fixes segfaults when handling files with odd chroma subsampled dimensions in
some scenarios like using the hstack filter.

./ffmpeg -lavfi testsrc=s=255x31,format=yuv420p -vframes 1 -y in.jpg && \
./ffmpeg -i in.jpg -i in.jpg -i in.jpg -i in.jpg -filter_complex "xstack=inputs=4:grid=2x2" -y out.png

Fixes issue #21739.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:19:01 -03:00
Sam.Richards@taurich.org
677cf95ea4 Initial checkin of OCIO filter.
Initial checkin of OCIO filter.

Initial checkin of OCIO filter.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Change for the right C++ library, should work on linux too.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding inverse when using display/view.

Removed comments.

Removed code that was setting the CICP values. Hopefully this can be done through OCIO at some point.

Config cleanup - need a modified require_cpp to handle namespacing.

Switch to using require_cpp so that namespace can be used.

Adding documentation.

Sadly a bit of linting went in here, but more importantly added a threads option to split the image into horizontal tiles, since OCIO was running rather slow.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding context parameters.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Add the OCIO config parameter.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Make the min threads 1 for now, reserve 0 for later if we can automatically pick something.
Also added a few comments.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

This is using ffmpeg-slicing.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding OCIO filetransform.

Making sure everything is using av_log rather than std::cerr.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Updating the tests so they would work without additional files.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding the file-transform documentation.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding copyright/license info.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Removing tests, since this is optional code.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Code cleanup.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Typo.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

I went the wrong way, av_log is expecting \n

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Fix indenting to 4 spaces.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Fixing lint issues and a spelling mistake.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Code formatting cleanup to match conventions.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Whitespace removal.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>
2026-02-14 12:21:10 +00:00
stevxiao
680f32c4c9
avfilter/dnn: add PyTorch version check for XPU initialization in torch backend
Starting with PyTorch 2.6, the hooks API was redesigned so it no longer depends on the device type.

As part of this change, the XPU initialization function was renamed from initXPU() to init().

Add version check to support both old and new LibTorch versions.

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-02-12 10:48:58 -05:00
stevxiao
57fe259773 avfilter/dnn: add synchronous execution path in torch backend
When using `dnn_processing` filter with torch backend, FFmpeg hangs indefinitely because no inference is actually performed.
Resolve this problem by add "else" branch for synchronous execution path.

Usage:
    ffmpeg -i input.mp4 -vf scale=224:224,format=rgb24,dnn_processing=dnn_backend=torch:model=sr_model_torch.pt:device=cpu output.mp4
2026-02-12 20:30:53 +08:00
Kacper Michajłow
590e2b1894 vf_libplacebo: sync peak detection parameters with upstream
Fixes peak detection for samples like in https://github.com/haasn/libplacebo/issues/358

This might introduce flickering on some other samples, but was agreed
upstream that they are better overall.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-12 00:12:48 +00:00
Andreas Rheinhardt
b08e849af8 avfilter/lavfutils: Avoid AVDictionary
Set thread_type directly instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt
2273902be8 avfilter/lavfutils: Avoid copying frame in ff_load_image()
Return the data in an AVFrame instead. This is what several users
({find,cover}_rect*) want anyway. This also avoids accessing
AVFrame.format (an int) via an enum AVPixelFormat*.

*: This commit actually avoids two frame copies For find_rect:
av_frame_clone() contained an implicit alloc+copy.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt
31173f148c avfilter/vf_removelogo: Properly handle allocation error
Don't rely on av_image_copy_plane() handling a NULL dst
gracefully.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt
0c7424e817 avfilter/filters: Restrict ff_fmt_is_in() to enum AVPixelFormat
Also rename it to ff_pixfmt_is_in(). This is more type-safe;
in particular, it is required to support -fshort-enum.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:43 +01:00
Michael Niedermayer
c6c6874c44
avfilter/vf_find_rect: Check x/y min/max
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:08:30 +01:00
Michael Niedermayer
12321e5eba
vfilter/vf_find_rect: Clamp x/y min/max to valid values
Fixes: #YWH-PGM40646-15
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:08:30 +01:00
WyattBlue
e48eaa8c62 avfilter/af_whisper: Add max_len parameter 2026-02-04 21:26:02 +00:00
WyattBlue
065c2582c0 avfilter/af_whisper: Add newline for txt format 2026-02-03 21:45:43 +00:00
Ruikai Peng
55d5b2b507 avfilter/drawvg: limit VGS parser recursion depth 2026-02-03 21:07:29 +00:00
stevxiao
7e9fe341df avfilter: version bump for filter mestimate_d3d12
Bump library version for filter 'mestimate_d3d12'.

This is the follow-up for commit https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21217/commits

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-02-02 04:16:50 +00:00
Andreas Rheinhardt
67c87cde99 avfilter/formats,vsrc_testsrc: use type-safe formats functions
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 15:20:08 +01:00
Andreas Rheinhardt
5b4ba2e1ac avfilter/vsrc_amf: Remove unused-but-set variable
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 22:33:33 +01:00
Zhao Zhili
f4ca7950d8 avfilter/vf_mestimate_d3d12: remove redundant mb_size constants
A constant named 8 has value 8 is redundant. These constants cannot
prevent user from setting other vaues. Just describe valid values
in the help message.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-27 17:05:27 +00:00
stevxiao
451ff239e6 avfilter: d3d12 motion estimation filter support
This commit introduces a video filter `mestimate_d3d12` that provides hardware-accelerated motion estimation using DirectX 12 Video Encoding APIs. The filter leverages GPU hardware motion estimation capabilities to achieve significant performance improvements over the existing software-based mestimate filter.

Sample Command Line:

1. Basic mestimate_d3d12 functionality
```
	ffmpeg_g.exe -hwaccel d3d12va -i test.mp4 -vf mestimate_d3d12=mb_size=16 -f null -
```
2. Motion vector visualization
```
	ffmpeg -hwaccel d3d12va -i input.mp4 -vf "mestimate_d3d12,hwdownload,format=nv12,codecview=mv=pf" -c:v libx264 output.mp4
```
2026-01-26 11:31:48 +00:00
Ruikai Peng
905a432403 libavfilter/showcwt: fix OOB write for DU/RL position init
In config_output() for direction=DU/RL, the position
is initialized to s->sono_size, which equals h or w
when bar=0. That position is later used as an
in-bounds pixel coordinate without clamping in draw(),
causing writes past the end of the output planes.

Repro:
ffmpeg -f lavfi -i sine=frequency=1000:sample_rate=44100 \
  -filter_complex "[0:a]showcwt=s=640x512:bar=0:direction=du[v]" \
  -map "[v]" -frames:v 1 -f null -

AddressSanitizer: heap-buffer-overflow ... WRITE of size 1

Initialize and wrap the DU/RL position to sono_size - 1
(or 0 when empty), preventing out-of-bounds row/column
writes when bar=0 while preserving existing slide behavior.
2026-01-24 22:05:34 +00:00
GeoffreyAA
ff63d4865b avfilter/vf_libplacebo: add chroma_location option
Add chroma_location option so that, in the subsampled-to-subsampled case, the destination's chroma siting can be changed from the source's without having to use other filters. Useful, for example, when converting BT.2020 to BT.709, where the former customarily uses "top left" and the latter "left."

Update documentation.

Closes: #21185
2026-01-24 11:01:34 +00:00
niyinghao
ec8e0b3592 libavfilter: Use type-safe format negotiation functions with enum parameters
Replace generic format functions with type-safe variants to prevent undefined
behavior with -fshort-enums compiler flag.

- 44/20 filters: ff_set_common_formats_from_list2 -> ff_set_*_formats_from_list2 (sample/pixel)
- 16/41 filters: ff_make_format_list → ff_make_*_format_list (sample/pixel)

Signed-off-by: niyinghao <niyinghao@xiaomi.com>
2026-01-24 08:11:19 +00:00
Marton Balint
0c3afc7e56 Revert "lavfi: make sure frame SAR matches the link value"
This reverts commit fcc33ada47.

It breaks playback of files with changing aspect ratio in ffplay, such as [1],
because the filter chain is initialized with the initial aspect ratio, so any
change is overwritten.

[1] https://samples.ffmpeg.org/archive/container/mpegts/mpegts+mpeg2video+mp2++aspect.ts
2026-01-21 22:06:12 +00:00
Marton Balint
a275ae8d64 avfilter: do not overwrite frame aspect ratio with source frame props in histogram and vectorscrope
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:06:12 +00:00
realies
c6c11b0b6d avfilter/af_loudnorm: fix limiter buffer over-allocation
The limiter_buf was being allocated with buf_size (3000ms worth of
samples) instead of limiter_buf_size (210ms worth of samples).

This resulted in allocating approximately 14x more memory than needed
for the limiter buffer. At 192kHz stereo:
- buf_size: 1,152,000 samples = 9.2 MB
- limiter_buf_size: 80,640 samples = 0.6 MB
- Wasted: ~8.2 MB per filter instance

The bug was introduced when the limiter buffer was added but the
wrong size variable was used in av_malloc_array().
2026-01-20 20:24:36 +00:00
Lynne
8dcf02ac63
vulkan: remove IS_WITHIN macro
This is the more correct GLSL solution.
2026-01-19 16:37:15 +01:00
Dmitrii Ovchinnikov
6972b127de avfilter: Add vsrc_amf - AMF based screen capture
This patch adds screen capture support via AMF vsrc_amf:
ffmpeg -y \
    -filter_complex "vsrc_amf=framerate=120:capture_mode=keep_framerate" \
    -c:v hevc_amf \
    -frames:v 300 \
    output_grab.mp4

If the HW frames pool is insufficient,
increase extra_hw_frames in filter_complex.
2026-01-19 10:16:37 +00:00
niyinghao
a5091f6d66 avfilter/formats: add type-safe functions for AVSampleFormat/AVPixelFormat lists
This avoids undefined behavior when -fshort-enums is enabled, where accessing enum arrays through int pointers causes incorrect memory reads.

Signed-off-by: niyinghao <niyinghao@xiaomi.com>
2026-01-19 09:33:49 +00:00
Raja Rathour
408dbf3c74 avfilter/vf_blackframe: add slice threading using stdatomic
Signed-off-by: Raja Rathour <imraja729@gmail.com>
2026-01-15 16:26:09 +00:00
Michael Niedermayer
805931dfc8 avfilter/scale_eval: Avoid undefined behavior with double to int cast
We use INT32_MIN/MAX so as to ensure we dont have to deal with 64bit width or height
on a int is int64 system. int64 width would overflow in a system where we assume the product of 2
values fit in int64

Fixes: #YWH-PGM40646-14
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 22:25:53 +00:00
Michael Niedermayer
5bbc8f828e avfilter/scale_eval: Use 64bit for factor_w/h
Avoids truncation and overflows

Fixes: #YWH-PGM40646-14
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 22:25:53 +00:00
Lynne
80229c161b
scale_vulkan: use compile-time SPIR-V generation for debayering 2026-01-12 17:28:43 +01:00
Lynne
f3b0ca4f2c
avgblur_vulkan: generate SPIR-V during compilation 2026-01-12 17:28:42 +01:00
Lynne
a6391168f2
bwdif_vulkan: use compile-time SPIR-V 2026-01-12 17:28:42 +01:00
Lynne
dd69ebc9a8
vulkan_filter: don't use lg_size[2] as the number of workgroup.z
This was put there because who knows why, but it's wrong, this
ends up having double dispatches in the z direction if non-1.
2026-01-12 17:28:41 +01:00
Lynne
7ce22b085e
cuda/load_helper: move zlib decompression into a separate file
Allows it to be reused for Vulkan
2026-01-12 17:28:41 +01:00
Lynne
5996a9ad3d
configure: rename PTX_COMPRESSION to SHADER_COMPRESSION
Its useful for GLSL and Metal as well.
2026-01-12 17:28:40 +01:00
Lynne
f2affdfafb
configure/make: support compile-time SPIR-V generation 2026-01-12 17:28:40 +01:00
Michael Niedermayer
f99df7dbb3 avfilter/vf_find_rect: Fix handling odd sized images
Fixes: out of array read
Fixes: #YWH-PGM40646-17

Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-12 02:05:11 +00:00
Raja Rathour
06d799ce1a avfilter/dnn_backend_torch: handle lifecycle of worker thread
Initialize async resources in dnn_load_model_th and ensure proper cleanup and thread joining in dnn_free_model_th.

Signed-off-by: Raja Rathour <imraja729@gmail.com>
Reviewed-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2026-01-12 08:53:42 +08:00
Raja Rathour
5e8ad5c39b avfilter/dnn_backend_torch: implement async execution logic
Update execute_model_th to support asynchronous execution by pushing tasks to the pending queue and notifying the worker thread.

Signed-off-by: Raja Rathour <imraja729@gmail.com>
Reviewed-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2026-01-12 08:53:42 +08:00
Raja Rathour
910270b179 avfilter/dnn_backend_torch: add async infrastructure
Add worker thread, mutex, and condition variable to THModel.

Signed-off-by: Raja Rathour <imraja729@gmail.com>
Reviewed-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2026-01-12 08:53:42 +08:00