1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00
Commit Graph

12601 Commits

Author SHA1 Message Date
Vincent Herbst
20339a85af avfilter/vf_yadif_videotoolbox: fix over-release of autoreleased Metal objects
call_kernel() obtains the command buffer and compute encoder from
property getters (mtlQueue.commandBuffer, buffer.computeCommandEncoder),
which return autoreleased references under the non-ARC build, and then
releases them via ff_objc_release(). That is an over-release: when the
enclosing autorelease pool is drained, the objects are released a second
time and the process crashes with EXC_BAD_ACCESS in objc_release.

On current macOS this is reproducible with the ffmpeg CLI itself. The
filter thread's thread-local autorelease pool is popped during pthread
TSD cleanup at thread exit, so any run that used yadif_videotoolbox
crashes when the filter thread terminates:

  ffmpeg -init_hw_device videotoolbox=vt -filter_hw_device vt \
    -f lavfi -i testsrc2=size=640x480:rate=30 \
    -vf setfield=tff,format=nv12,hwupload,yadif_videotoolbox,\
  hwdownload,format=nv12 -frames:v 20 -f null -

  Thread 11 Crashed:: vf#0:0
  0 libobjc.A.dylib  objc_release + 16
  1 libobjc.A.dylib  AutoreleasePoolPage::releaseUntil(objc_object**) + 204
  2 libobjc.A.dylib  objc_autoreleasePoolPop + 244
  3 libobjc.A.dylib  objc_tls_direct_base<...>::dtor_(void*) + 156
  4 libsystem_pthread.dylib  _pthread_tsd_cleanup + 620
  5 libsystem_pthread.dylib  _pthread_exit + 84

Host applications hit the same crash earlier, for example when a
dispatch queue drains its last-resort pool after a work item that ran
the filter.

Wrap the kernel invocation in @autoreleasepool and drop the manual
releases, making the pool pop the single balanced release and draining
the Metal transients once per frame. The ff_objc_release() calls on the
s->mtl* members in do_uninit() stay: those hold owned references
obtained from new* methods.

(cherry picked from commit 7f2e5cdd7c)
2026-10-20 21:55:40 +00:00
Timo Rothenpieler
46d8f462ee avfilter/vf_scale_cuda: consider chroma subsampling for scaling decisions
(cherry picked from commit a621ef4291)

Assisted-by: Fairy
2026-09-30 18:29:59 +00:00
Timo Rothenpieler
38a8f88ca8 avfilter/vf_scale_cuda: always have valid passes setup
(cherry picked from commit 4566eee588)

Assisted-by: Fairy
2026-09-30 18:29:59 +00:00
Timo Rothenpieler
1da9555474 avfilter/vf_scale_cuda: extract pass determination into its own function
(cherry picked from commit dda8b8253c)

Assisted-by: Fairy
2026-09-30 18:29:59 +00:00
Timo Rothenpieler
979b335e33 avfilter/vf_scale_cuda: skip allocating intermediate texture if not needed
(cherry picked from commit 3d7ea1dac4)

Assisted-by: Fairy
2026-09-30 18:29:59 +00:00
Timo Rothenpieler
7832132d32 avfilter/vf_scale_cuda: don't try to execute disabled filter passes
(cherry picked from commit 50a9e34e1b)

Assisted-by: Fairy
2026-09-30 18:29:59 +00:00
Timo Rothenpieler
0a76163ce2 avfilter/vf_convolution: don't assume frame is multiple of 16 pixels wide
Limit the 8-bit column filter to the pixels remaining in the current slice. Pass slice_end - y at all three call sites so both the 8-bit and high-bit-depth column filters receive the correct remaining width. This handles partial 16-pixel blocks at frame and thread-slice boundaries. The non-column callbacks do not use this argument.

Fixes: #YWH-PGM40646-36
(cherry picked from commit 8b9e02cc17)
2026-09-29 20:15:31 +00:00
Michael Niedermayer
946fcce07b Update for 9.0.2
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-09-18 01:19:50 +02:00
Michael Niedermayer
eb33250528 avfilter/vf_decimate: reject blocks smaller than one chroma sample
Fixes: out of array access
Fixes: division by zero
Fixes: vdfZuLhrGLdR
Found-by: zhang xingxing

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 590fb407b0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-09-18 00:51:27 +02:00
Michael Niedermayer
356fef62b4 avfilter/vf_colorconstancy: free only allocated buffers on setup failure
Fixes: invalid free on allocation failure
Fixes: BvbItG8H5bk7
Found-by: zhang xingxing
(cherry picked from commit 432679772a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-09-17 01:30:44 +02:00
Michael Niedermayer
b47d79d4d5 avfilter/vf_uspp: Fix qpcount
Fixes: division by zero
Fixes: tiny_16x8.h264
Fixes: W9IyRhjCcQxd
Found-by: zhang xingxing

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2c05ce65e1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-09-17 01:30:43 +02:00
Yongqiang Tian
6f45c7392c avfilter/f_metadata: avoid overread on long formatted output
vsnprintf() returns the number of characters that would have been written
when its output is truncated. Passing that value to avio_write() makes it
read beyond the 128-byte stack buffer for long metadata values.

Use avio_vprintf() to write the complete formatted string without the fixed
intermediate buffer.

Fixes: b0159af6bc
Signed-off-by: Yongqiang Tian <yqtian668@gmail.com>
(cherry picked from commit fd625f452c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-09-17 01:30:42 +02:00
Ayoub Nabil Boubagrat
b7d8e10e61 avfilter/acrossover: reject non-finite parameters
Signed-off-by: Ayoub Nabil Boubagrat <237098474+ayoubnabil@users.noreply.github.com>
(cherry picked from commit 0ba7514f99)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-09-04 21:54:00 +02:00
Ayoub Nabil Boubagrat
ea68d02c47 avfilter/aiir: reject non-finite parameters
Signed-off-by: Ayoub Nabil Boubagrat <237098474+ayoubnabil@users.noreply.github.com>
(cherry picked from commit 1d49dc80a9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-09-04 21:54:00 +02:00
Ayoub Nabil Boubagrat
e00134132e avfilter/firequalizer: reject overflowing delays
Signed-off-by: Ayoub Nabil Boubagrat <237098474+ayoubnabil@users.noreply.github.com>
(cherry picked from commit 31e92a56ca)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-09-04 21:54:00 +02:00
Ayoub Nabil Boubagrat
9fa9960cea avfilter/aecho: reject non-finite delays and decays
Signed-off-by: Ayoub Nabil Boubagrat <237098474+ayoubnabil@users.noreply.github.com>
(cherry picked from commit 71f9ea2d84)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-09-04 21:53:59 +02:00
Hao Chen
e32d862f13 avfilter/aarch64/vf_bwdif_init: Fix stride bound check
Fix stride condition when bounding w.

Signed-off-by: Hao Chen <haochenc@google.com>
(cherry picked from commit d9ed77cb52)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-09-04 21:53:59 +02:00
Michael Niedermayer
2e41be62b7 Bump for 9.0.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-08-12 05:22:39 +02:00
Michael Niedermayer
be329d65d5 avfilter/spectrumsynth: negotiate one pixel format for both inputs
Fixes: out of array access
Fixes: ndSS0e433gq
Found-by: Eunsoo Kim, Microsoft FORGE Labs
(cherry picked from commit 4d896a22dd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-08-12 04:52:01 +02:00
Michael Niedermayer
3fbb956082 avfilter/afir: bound the crossfades by the samples of the input frame
Fixes: ffmpeg -i tail.wav -i ir.wav -filter_complex "[0][1]afir=dry=1:wet=1:enable='lte(t,0.5)'" -f null -

Fixes: out of array access
Fixes: uQcNui1HxUqe
Regression since: 1835f884b7
Found-by: Eunsoo Kim, Microsoft FORGE Labs

(cherry picked from commit a681001244)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-08-12 04:52:01 +02:00
iSold Leo
9989a953fe avfilter/af_pan: check the id of named input channels before use
parse_channel_name() only rejects negative values on the named channel
path, while the numbered "c%d" path also checks against MAX_CHANNELS.
av_channel_from_string() accepts UNSD (512), UNK (768) and AMBI (1024),
and the id was then used directly to index used_in_ch[MAX_CHANNELS] on
the stack and pan->gain[out_ch_id][in_ch_id].

Before this change:

  ffmpeg -f lavfi -i "anullsrc=cl=stereo" -af "pan=stereo|FL=AMBI" -f null -
  af_pan.c:214:17: runtime error: index 1024 out of bounds for type 'int[64]'

The first out of bounds access is the read at the "reference twice"
check, so the symptom depends on what happens to be on the stack:
FL=UNK is silently accepted and produces silence, FL=UNSD reports
"Can not reference in channel 512 twice", and FL=AMBI aborts.

The check has to be at the caller and not in parse_channel_name(), which
is shared with the out channel path: there the named id is converted by
av_channel_layout_index_from_channel() into a layout index, so high ids
are legitimately supported and "pan=AMBI|AMBI=FL" works.

AVERROR_PATCHWELCOME is used because these are valid AVChannel values
that af_pan cannot represent: for named input channels the gain matrix is
indexed by the raw id, and the renumbering loop in config_props() is
bounded by MAX_CHANNELS as well, so such a mapping never worked.

The in_ch_id < 0 half is currently unreachable and only kept for symmetry
with the out channel check above.

Regression since 1f96db959c, which dropped
the "channel_id >= MAX_CHANNELS" part of the check when converting to the
new channel layout API.

Reported-by: karnakarreddi
Fixes: #22963
Signed-off-by: iSold Leo <s@qwqlog.com>
(cherry picked from commit f02c4372ed)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-08-12 04:51:58 +02:00
Kacper Michajłow
03d9533176 Revert "lavfi/bwdif: fix heap-buffer-overflow with small height videos"
This reverts commit 795bccdaf5.

The heap-buffer-overflow was a symptom of the >8 bit boundary
conditions bug fixed in the previous commit. This workaround is no
longer needed.

This restores spatial-only interpolation of the whole frame for the
first and last fields, instead of running the temporal edge filter
against cloned reference frames on the outermost lines. Because of that
first frame references are updated to pre-fix values.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
(cherry picked from commit 3cd408c2a6e5a7de8b6d641dedd12d523b94014c)
2026-08-08 21:46:50 +00:00
Kacper Michajłow
dcf567a048 avfilter/vf_bwdif: fix line boundary checks for >8 bits content
The mrefs/prefs boundary conditions scaled the y limits by the number of
bytes per sample, even though the ref offsets are already expressed in
elements. For content deeper than 8 bits this clamped perfectly valid
in-bounds line taps.

Found by validating the libplacebo GPU port against this filter, which
matches exactly on 16-bit content everywhere except these lines.

This changes the output for >8 bit content on the affected lines.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
(cherry picked from commit 7d96c87a7382fed8d571748d6ed5c1869c192c31)
2026-08-08 21:46:49 +00:00
Raja-89
eebd95977f avfilter/dnn: fix async teardown race condition in all backends
When the filter graph is torn down early (e.g. at EOF with -frames:v),
the main thread calls dnn_free_model and destroys the request queue
while async inference threads may still be running. When a detached
thread finishes and tries to push its result back to the destroyed
queue, it triggers a segmentation fault.

Add ff_dnn_wait_requests() to dnn_backend_common which blocks
until all allocated request items (ctx->nireq) have been safely
returned to the request_queue. Call it from dnn_free_model in the
torch, tensorflow, openvino, and onnx backends before destroying the queue.

(cherry picked from commit b52c71e438)
Co-Authored-by: Fable 5
2026-08-02 06:24:00 +02:00
Zhao Zhili
79e64c80bf avfilter/vf_scale_cuda: fix non-scaling format conversion
A format-only conversion leaves the auto use_filters value unresolved.
Regression since 5d0748243f.

Fix issue #23737

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
(cherry picked from commit c57660fb18)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-08-02 06:03:04 +02:00
Dan Dennedy
90243e3985 scale_d3d11: Fix hw_frame_ctx reference leak
This fixes #20995. The reference is taken twice and assigned to the same pointer (see above in the same function). Only the latter is needed.

(cherry picked from commit 66a8c37582)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-08-02 02:47:32 +02:00
Michael Niedermayer
3b962c40dd avfilter/af_arnndn: pad the DCT input buffers to the read length
Fixes: out of array access
Fixes: SUcVEyk7r3Gc
Found-by: Kenan Alghythee <kalghy2@uic.edu>
(cherry picked from commit e38b5d15bd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-08-02 02:47:31 +02:00
Kenan Alghythee
3257728c61 avfilter/vf_xpsnr: avoid a zero block size on small frames
Fixes: division by zero
Fixes: SUcVEyk7r3Gc
Found-by: Kenan Alghythee <kalghy2@uic.edu>
(cherry picked from commit 06fd4fd0e7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-08-02 02:47:29 +02:00
Michael Niedermayer
107072ee9b avfilter/vf_lut3d: do not compute size*size before the size is validated
parse_dat(), parse_cube(), and parse_cinespace() multiply an untrusted LUT size
before allocate_3dlut() validates it, which can overflow int.
Use the validated lutsize2 computed by allocate_3dlut() instead.

Fixes: signed integer overflow
(cherry picked from commit 92cd5c9781)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-08-02 02:47:28 +02:00
Michael Niedermayer
62294b6a8a avfilter/vf_hqdn3d: support dynamic frame sizes
(cherry picked from commit 5d7112c60e)
2026-08-02 02:47:28 +02:00
Michael Niedermayer
e3d0c719fd avfilter/vf_hqdn3d: reject unsupported frame parameter changes
Fixes: out of array access
Fixes: 9aj_hqdn3d_dynamic_res.mjpg / 9aj_generate_hqdn3d_dynamic_res_mjpg.py
Fixes: wWDsy2oDvMuR
Found-by: Adrian Junge (vurlo) <adjun37@gmail.com>
(cherry picked from commit f0f634b658)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-08-02 02:47:28 +02:00
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