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

127822 Commits

Author SHA1 Message Date
Michael Niedermayer
3a75cd0ad3 swscale/graph: copy the palette of a PAL8 frame as a whole
Fixes: NwCWHv3RIJff
Fixes: use of uninitialized memory
Use of uninitialized memory Replicated through API with MSAN
Found during triage of the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24851
2026-10-20 20:41:50 +00:00
Michael Niedermayer
dd98bbe096 avcodec/encode: assert that the subtitle buffer size is not negative
A negative size is caller misuse.

Fixes: 1JEyyg9rrIOc
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24913
2026-10-20 20:41:50 +00:00
Michael Niedermayer
1a42769362 avcodec/dvbsubenc: compute the line budget of the RLE coders in 64 bit
Fixes: tOTDK93gpiC1
Fixes: signed integer overflow
Signed integer overflow Replicated through API with UBSAN
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24913
2026-10-20 20:41:50 +00:00
Michael Niedermayer
728b70614c avcodec/dvbsubenc: assert that the rect dimensions and nb_colors are in range
A negative width, height or nb_colors, or more colors than the 256
entry palette holds, is caller misuse.

Fixes: tOTDK93gpiC1
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24913
2026-10-20 20:41:50 +00:00
Michael Niedermayer
d47bcf0817 avcodec/dvbsubenc: reject rects wider or higher than 65535
Region width and height are 16 bit fields (ETSI EN 300 743, 7.2.3);

Fixes: tOTDK93gpiC1
Fixes: out of array write
Fixes: signed integer overflow
Out of array write Replicated through API with ASAN
Signed integer overflow Replicated through API with UBSAN
Region width truncated to 16 bits Replicated through API with plain output check
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24913
2026-10-20 20:41:50 +00:00
Michael Niedermayer
d98487b687 ffplay: avoid signed overflow of the list shuffle seed
Volunteer for testing welcome

Fixes: Qc9DRRq5X1KU
Fixes: signed integer overflow
Signed integer overflow Replicated through Modified FFmpeg with UBSAN
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24589
2026-10-20 20:41:50 +00:00
Niklas Haas
ad0f34ca30 swscale/vulkan/ops: rename process() to spirv_process()
Distinguishes it from the many other process() functions in swscale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
f2f6cdfd79 swscale/vulkan/ops: handle errors in process()
Failures from ff_vk_create_imageviews_fmt() and friends were ignored,
leading to descriptors being updated with uninitialized image views.
Discard the execution and bail out instead. SwsPassFunc has no way to
return errors, so just log them for now.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
dbe29df93b swscale/vulkan/ops: factor out bit-exact linear op count
Move the count of arithmetic instructions emitted by
insert_bitexact_linear() into a helper, and assert that it matches the
number of IDs actually allocated, since the NoContraction decorations
are reserved and written based on this count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
581fcedc20 swscale/vulkan/ops: store constant and buffer IDs per op
Constants and buffers were collected into flat arrays and consumed via
running counters, which had to be kept in sync by hand between the
constant definition pass, the decoration pass and the code generation
loop. Store them in a struct indexed by the op instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
721a02e3eb swscale/vulkan/ops: use separate arrays for each descriptor set
The image descriptor array was reused for the buffer descriptors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
bbf8a9066f swscale/vulkan/ops: simplify device reinit check in ff_sws_vk_init()
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
c35a4245ca swscale/vulkan/ops: drop ff_ prefix from static function
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
e8f15ea61c swscale/vulkan/ops: remove trivial compile() wrapper
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
5f1e615d0b swscale/vulkan/ops: don't pass VulkanPriv to buffer creation helpers
Only its FFVulkanOpsCtx was used, which is already passed separately.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
1146e745da swscale/vulkan/ops: remove duplicate float zero constant
Since the float placeholder value was changed to 0.0, f32_p and f32_0 are
the same constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
346750c959 swscale/vulkan/ops: remove unused filter code paths
Filters are only ever merged into planar reads, so the packed filtered
read path and the buffers for filtered writes can never be used.

Standalone filter ops do reach the backend, since compile_subpass() first
tries to compile the unsplit op list. However, code generation has never
supported them and fails with ENOTSUP, after which the list is split at the
filter. The filter buffers allocated and uploaded for them were thus wasted
on every such attempt, and were not accounted for in the descriptor set
bindings either.

Implementing in-line filtering in the future (e.g. via shared memory) would
need its own buffer setup and code generation regardless, since the taps
would no longer be read directly from the source image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
857a27b508 swscale/vulkan/ops: cosmetic fixes
Fix indentation and alignment of continuation lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
ec3f175db7 swscale/vulkan/ops: reject filtered reads with non-float output
The filtered read always accumulates and returns floats, so any other
output type would be silently misinterpreted by the following ops.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
42ab9010b5 swscale/vulkan/ops: don't reference the input image in passes without reads
The input image variable was only defined when the pass contains a read,
but was unconditionally decorated and listed in the entrypoint interface,
referencing an undefined ID and producing invalid SPIR-V.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
91d6402932 swscale/vulkan/ops: track entrypoint interface variables by name
Instead of hard-coding the layout of the in_vars[] array, give the fixed
variables names and build the entrypoint interface list by appending.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
caf17a3247 swscale/vulkan/ops: don't declare unused capabilities
The shader only uses 32-bit integer types and never accesses 8-bit storage
buffers, so the Int8, Int16 and StorageBuffer8BitAccess capabilities are
not needed. Declaring them requires the device to support the
corresponding features.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Niklas Haas
34906ccdcb swscale/vulkan/ops: fix error return in create_filter_buf()
Failures were silently returning 0, leaving behind an unallocated buffer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 19:50:40 +00:00
Michael Niedermayer
1c767fe664 avutil/mips/mmiutils: provide the Loongson MMI mnemonics GNU binutils lacks
GNU binutils spells the MMI instructions pxor, pand, por, pnor, ssrld
and sslld as xor, and, or, nor, dsrl and dsll on floating point
registers, with -march=loongson2e/2f/3a and since 2.32 with
-mloongson-mmi; the p-named entries in its opcode table are the R5900
instructions on general purpose registers. The other 43 p-named MMI
instructions FFmpeg uses are spelled the same by everyone. Loongson's
gcc toolchain accepts both spellings (ebedd26eef), the binutils 2.24
of their cross-gcc-4.9.3-n64-loongson-rc6.1 only the GNU ones.

Since 903c5d58f0 configure probes pxor and so silently disables MMI
with every GNU binutils. Probe Loongson's spelling first and fall
back to the GNU one together with assembler macros that define the
six names, as asmdefs.h already does for parse_r. The macros assemble
to the same encodings as the GNU spelling with binutils 2.24, 2.28
and 2.42.

The GNU fallback is limited to little-endian mips64: the MMI code does
not build for O32 and its unaligned loads assume little-endian.
2026-10-20 17:27:32 +00:00
Michael Niedermayer
c4047d1921 avcodec/mips/Makefile: build mpegvideoencdsp_mmi.o under its current name
The source was renamed from mpegvideoenc_mmi.c when denoise_dct moved
to MpegvideoEncDSPContext, the MMI object list still had the old name.
2026-10-20 17:27:32 +00:00
Michael Niedermayer
eda615ba34 avcodec/mips/mpegvideo_mmi: use av_assert2() for the remaining assert() 2026-10-20 17:27:32 +00:00
Michael Niedermayer
e43f905551 avcodec/mips/mpegvideo_mmi: include avassert.h for av_assert2() 2026-10-20 17:27:32 +00:00
Michael Niedermayer
c7218f393f avcodec/mips/vp8dsp_mmi: constify src in the ff_put_vp8_*_mmi definitions 2026-10-20 17:27:32 +00:00
Michael Niedermayer
10743d0642 tests/swscale: compare unscaled conversion across thread counts
Compare one-thread conversion with 2, 3, 7 and 16 threads for five even
frame heights, including cases that otherwise produce odd slices. Cover
NV12, NV21, YUV420P, YUVA420P and YUV422P to packed and planar RGB,
including both byte orders of the 16-bit formats.

Exercise both dynamic and initialized legacy swscale contexts. Disable
dithering so the AArch64 selector must supply its own slice alignment
for planar inputs as well. Compare within each implementation to avoid
requiring identical color conversion rounding across architectures.
Print mismatching row counts for FATE to compare with its reference.

The test fails before the preceding fixes on native AArch64 and on
32-bit ARM NEON, and passes afterwards on both. It also passes on
native x86-64.

Assisted-by: Fairy
2026-10-20 13:39:20 +00:00
Michael Niedermayer
3b5d53038e swscale/arm: align unscaled NEON YUV to RGB slices to source chroma
The 32-bit ARM NEON YUV-to-RGB converters selected by
SET_FF_NVX_TO_RGBX_FUNC share the even-slice precondition with their
AArch64 counterparts: for vertically subsampled input they process two
luma rows per iteration, so an odd slice boundary picks the wrong
chroma phase and the last iteration writes one row past the slice end.
Threaded conversion produces such slices because the packed RGB
destination keeps dst_slice_align at one row.

Raise dst_slice_align when selecting these converters, mirroring the
preceding AArch64 change. YUV422P keeps full-height chroma and stays
single-row, so its alignment is unchanged.

Fixes: d6fdc78e91 ("sws: implement slice threading")
Assisted-by: Fairy
2026-10-20 13:39:20 +00:00
Kevin Watters
92c554caeb swscale/aarch64: align unscaled YUV to RGB slices to source chroma
The NV12 and NV21 NEON converters need even slice boundaries, but the
RGB destination only requests one-row alignment. Threaded conversion
can therefore start on an odd luma row and use the wrong chroma phase.
The current two-row converters additionally write past odd slice ends.

Raise dst_slice_align when selecting a NEON converter, preserving any
larger existing alignment. This also covers planar 4:2:0 when dithering
options bypass the generic yuv2rgb selector's alignment assignment.

Update the assembly precondition comment to include graph dispatch.

Fixes #24266.
Fixes: d6fdc78e91 ("sws: implement slice threading")
Assisted-by: Fairy
2026-10-20 13:39:20 +00:00
Niklas Haas
56dbd4cd37 swscale/vulkan/ops: implement SWS_OP_PACK and SWS_OP_UNPACK properly
These were hacked into the code as swizzles relying on the _UINT_PACK32 view
of the image to do the actual (un)packing, which only covered the 2:10:10:10
formats, and silently produced garbage on drivers lacking storage support
for those view formats (e.g. ANV).

Implement these operations properly, the way they were intended, by doing
the actual documented bit-packing operation instead whatever hacky
assumptions the swizzle was making.

Fixes fate-sws-unscaled-spirv on Intel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 11:43:04 +00:00
Niklas Haas
f146abc85c swscale/vulkan/ops: resolve image view formats at compile time
Unsupported formats now fail at compile time instead of being silently
ignored in process().

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 11:43:04 +00:00
Niklas Haas
d623255739 swscale/vulkan/spvasm: add OpBitwiseOr
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 11:43:04 +00:00
Niklas Haas
0c9b8145bc avutil/vulkan: add ff_vk_create_imageviews_fmt()
Like ff_vk_create_imageviews(), but with an explicit view format per plane.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 11:43:04 +00:00
Niklas Haas
687fb754b1 avutil/vulkan: export ff_vk_map_fmt_to_rep()
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-20 11:43:04 +00:00
Michael Niedermayer
1ab25e6897 avcodec/cbs_apv: reject ITU-T T.35 metadata shorter than its country code
Fixes: F9Vetk0Ebf1N

Found during triage of the security report 00smV7L5DOfY

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-20 11:36:57 +00:00
zhang xingxing
64afb8a930 avcodec/cbs_apv: reject user defined metadata shorter than its UUID
This is not a security issue.

Fixes: 00smV7L5DOfY
Fixes: swarm-metadata_user_defined-data_size-underflows-on-payload_size-16-5ff8a8

Found-by: zhang xingxing <2388969553@qq.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-20 11:36:57 +00:00
zhang xingxing
ddb610f9fe avfilter/qrencode: free the rendered width expressions
This is not a security issue.

Fixes: oFKoC1YimRPu
Fixes: swarm-Memory-leak-qr--text-and-pexpr-fields-not-freed-in-uninit-5cc723

Found-by: zhang xingxing <2388969553@qq.com>

Memory leak Replicated through UnModified FFmpeg with LSAN

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-20 11:36:57 +00:00
zhang xingxing
97daefb4d6 avformat/tls_mbedtls: free the mbedtls contexts on every error path
This is not a security issue.

Not replicated, compile tested only (mbedtls 3.6.2).

Fixes: T7EtPuJBKWqg
Fixes: swarm-Memory-leak-early-return-skips-mbedtls-resource-cleanup-a1d295

Found-by: zhang xingxing <2388969553@qq.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-20 11:36:57 +00:00
Michael Niedermayer
0ff8cac632 avformat/md5proto: free the MD5 context when opening the output fails
This is not a security issue.

Fixes: ORPoDnVi3BLg
Fixes: swarm-MD5-context-leaked-when-output-URL-open-fails-e4415f

Found-by: zhang xingxing <2388969553@qq.com>

Memory leak Replicated through UnModified FFmpeg with LSAN

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-20 11:36:57 +00:00
zhang xingxing
f02f1707b1 avcodec/dvbsubdec: check the object segment size before reading its header
This is not a security issue.

Fixes: hlm9X3ZdVjBu
Fixes: swarm-Missing-buf_size-validation-in-dvbsub_parse_object_segment-a29b35

Found-by: zhang xingxing <2388969553@qq.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-20 11:36:57 +00:00
zhang xingxing
5d59b7c45d avcodec/mpc7: reject a last frame length larger than a frame
Fixes: out of array read
Fixes: dcrkQkffMQ8b
Fixes: swarm-Missing-bounds-check-on-last-frame-length-enables-heap-OOB-read-e00668

Found-by: zhang xingxing <2388969553@qq.com>

Out of array read Replicated through UnModified FFmpeg with ASAN

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-20 11:36:57 +00:00
Michael Niedermayer
d58b31a865 avformat/matroskaenc: describe timestamp jumps when starting a cluster
The existing warning does not distinguish a forward timestamp outside the
Block's signed 16-bit range from a late packet that forces a backward
Cluster timestamp jump. Include the direction, stream index, incoming
timestamp, current Cluster timestamp and signed difference in milliseconds.

This addresses the diagnostic part of issue #24379. It does not change
packet interleaving or turn the condition into a muxing error.

Assisted-by: Fairy
2026-10-20 11:34:03 +00:00
Prasanna Dabi
fdd4e83ea0 avutil/hwcontext_vulkan: copy only the bytes of the visible rows
copy_buffer_data() copied FFABS(linesize) bytes per row between the
software frame and the staging buffer. The last row of a plane does not
have to extend to the full linesize, so this read past the end of the
software frame on upload and wrote past it on download.

The staging path is always taken for frames with a negative linesize,
and by default for multi-plane formats on the NVIDIA proprietary driver,
where host image copies are disabled and host memory import is avoided.

Same issue as fixed for hwcontext_cuda in f07f02abb8.

Out of array read and write replicated through the API with ASAN.
2026-10-20 14:24:12 +05:30
Michael Niedermayer
744588782d swscale: reject planes whose size does not fit in int
Fixes: signed integer overflow
Fixes: out of array access
Fixes: pdA1vTaOO5Be
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24851
Signed integer overflow Replicated through API with UBSAN
Out of array access Replicated through API with ASAN
2026-10-20 02:25:09 +00:00
Michael Niedermayer
254cebc4e8 avcodec/encode: reject video frames that do not match the encoder
Fixes: out of array read
Fixes: DdI1HfjoEG1l
Found during triage of the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24765
Out of array read Replicated through UnModified FFmpeg with ASAN
2026-10-20 02:25:09 +00:00
Michael Niedermayer
81f2ea37e4 avcodec: declare support for parameter changes in the rawvideo and wrapped_avframe encoders
Both encoders take the size and format of every frame from the frame
itself.
2026-10-20 02:25:09 +00:00
Michael Niedermayer
f07f02abb8 avutil/hwcontext_cuda: copy only the bytes of the visible rows
Fixes: out of array access
Fixes: ZqshmgSdN2Q2
Found during triage of the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24595
Out of array read and write Replicated through API with ASAN
Out of array read Replicated through UnModified FFmpeg with a guard page allocator
2026-10-20 02:25:09 +00:00
Michael Niedermayer
341553de8a avfilter/dnn_backend_openvino: do not free the model when updating it fails
Fixes: double free
Fixes: QIOnvFKEz80N
Regression since: 22652b576c
Found during triage of the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24617
Double free Replicated through UnModified FFmpeg with ASAN
2026-10-20 02:25:09 +00:00