Commit Graph

53068 Commits

Author SHA1 Message Date
Michael Niedermayer
88b676105d avcodec/prores_raw: Check bits in get_value()
The code loads 32bit so we can at maximum use 32bit

the return type is also changed to uint16_t (was requested in review),

no path is known where a return value above 32767 is produced, but that was not exhaustively checked

Fixes: runtime error: shift exponent -9 is negative
Fixes: 439483046/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PRORES_RAW_DEC_fuzzer-6649466540326912

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-16 21:43:17 +01:00
Michael Niedermayer
9ccc33d84d avcodec/prores_raw: Prettify ff_prores_raw_*_cb
the values contain 3 4 bit values, thus using hex is more natural
and shows more information

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-16 21:34:38 +01:00
Cameron Gutman
d3dea2b142 avcodec/v4l2_buffers: map additional V4L2 TRCs
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-11-15 00:39:43 +00:00
Andreas Rheinhardt
e293091d98 avcodec/prores_raw: Reuse permutation
The ProresDSPContext already contains the idct_permutation.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-14 14:27:53 +01:00
Michael Niedermayer
41a9c6ec5f avcodec/mediacodecdec_common: Check that the input to mediacodec_wrap_sw_audio_buffer() contains channel * sample_size
Fixes: out of array access
no testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-14 12:16:48 +00:00
Dmitrii Ovchinnikov
62184be548 avutil/hwcontext_amf: Simplified blocking before frame submission
Instead of blocking the entire context, which can cause issues in more
complex pipelines, now only frame sending is blocked via AVMutex
2025-11-13 15:49:42 +01:00
Sean McGovern
35464ad9eb libavcodec/ppc: remove broken AltiVec acceleration for lossless audio
It fails sporadically on big- or little-endian POWER/PPC, as well as
triggers the undefined-behaviour & address scanners in GCC.
2025-11-12 14:40:14 -05:00
Andreas Rheinhardt
2452b81769 avcodec/h264idct_template: Deduplicate h264_{luma,chroma}_dc_dequant_idct
All the high bit depth functions of these types are identical.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-12 14:50:46 +01:00
Andreas Rheinhardt
1fafb13cd4 avcodec/bit_depth_template: Add PIXELSIZE
Sometimes functions for bit depth 9..16 are the same (because they
actually only depend on the underlying pixel type). The macros added
here allow to support this usecase.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-12 14:50:21 +01:00
Lynne
418235e98a vulkan_prores: fix buffer leaks on error 2025-11-12 00:37:25 +01:00
Lynne
d12bb4a2a5 vulkan_prores: fix pushconst updating
ff_vk_shader_update_push_const executes a command that
updates push data for the currently bound shader.
2025-11-12 00:37:25 +01:00
Lynne
a0d0b5cf73 ffv1enc_vulkan: only use native image representation
This was done for an unknown reason, and for whatever reason,
non-rgb 8+ bit formats were broken by this.
2025-11-12 00:37:24 +01:00
Lynne
9860017495 vulkan/ffv1: use u32vec2 for slice offsets
Simplifies calculations slightly.
2025-11-12 00:37:24 +01:00
Lynne
6080db7d23 ffv1dec: call ff_get_format if width and height change 2025-11-12 00:37:24 +01:00
Lynne
18d7ded29e prores_raw: call ff_get_format if width and height change 2025-11-12 00:37:24 +01:00
Lynne
e93e2a5be1 prores: call ff_get_format if width and height change
The issue is that hardware decoders may have some state they depend on,
which would get broken if the dimensions change.
2025-11-12 00:37:19 +01:00
Zhao Zhili
cbc6134a4a avcodec/nvenc: fix -Wenum-conversion on colorspace/pri/trc
SDK 12.0 defined enum types for colorspace/pri/trc, while lower
versions use uint32_t.
2025-11-11 20:08:36 +00:00
Zhao Zhili
141f5c9071 avcodec/hevc: reset long_term_rps.nb_refs for IDR
For mv-hevc, the second layer of IDR frame can be a P slice.
long_term_rps wasn't been reset before the patch, which leading to
ff_hevc_frame_nb_refs return incorrect result.

This fix decoding failure for samples from Pico VR.
2025-11-10 12:22:05 +08:00
Zhao Zhili
6bdea3ae23 avcodec/hevc: remove an always true condition
long_rps is &sh->long_term_rps.
2025-11-10 12:22:05 +08:00
Michael Niedermayer
729d0379ab avcodec/rv60dec: Clear blk_info
Fixes: use of uninitialized memory
Fixes: 418335931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5103986067963904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-10 01:46:52 +00:00
Michael Niedermayer
59db32b433 avcodec/utvideodec: Set B for the width= 1 case in restore_median_planar_il()
Fixes: use of uninitialized memory
Fixes: 439878388/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_DEC_fuzzer-5635866203848704

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-09 10:44:09 +00:00
Michael Niedermayer
08816b9376 avcodec/osq: Fix 32bit sample overflow
Fixes: signed integer overflow: 2147483565 + 128 cannot be represented in type 'int'
Fixes: 428055715/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6358069900804096

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-09 02:42:17 +01:00
averne
d00f41f213 vulkan/prores: forward quantization parameter to the IDCT shader
The qScale syntax element has a maximum value of 512, which would overflow the 16-bit store from the VLD shader in extreme cases.
This fixes that edge case by forwarding the element in a storage buffer, and applying the inverse quantization fully in the IDCT shader.
2025-11-08 22:31:21 +00:00
Andreas Rheinhardt
32f32537b6 avcodec/dvdec,mjpegdec: Remove emms_c
It is no longer necessary now that the IDCTDSP is always ABI-compliant
(and free of MMX).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt
ade54335b2 avcodec/x86/simple_idct: Port to SSE2
Before this commit, the (32-bit only) simple idct came in three
versions: A pure MMX IDCT and idct-put and idct-add versions
which use SSE2 at the put and add stage, but still use pure MMX
for the actual IDCT.

This commit ports said IDCT to SSE2; this was entirely trivial
for the IDCT1-5 and IDCT7 parts (where one can directly use
the full register width) and was easy for IDCT6 and IDCT8
(involving a few movhps and pshufds). Unfortunately, DC_COND_INIT
and Z_COND_INIT still use only the lower half of the registers.

This saved 4658B here; the benchmarking option of the dct test tool
showed a 15% speedup.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt
625f5c993c avcodec/tests/dct: Remove unnecessary emms_c
Unnecessary since the Xvid IDCT no longer uses MMX registers at all.
(Notice that the simple MMX IDCT issues emms and is therefore ABI
compliant.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt
a26b99f793 avcodec/x86/xvididct: Remove remnants of MMX
The non-MMX code only uses the first six rounders.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt
b03b09aeda avcodec/x86/xvididct: Don't use MMX registers in SSE2 function
It is higly surprising and would necessitate emms in order to be ABI
compliant; but it is better just not to use them in the first place.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt
a7013f813c avcodec/tests/x86/dct: Test 32bit simple idct
The test has been removed in bfb28b5ce8
when MMX idctdsp functions overridden by SSE2 were removed;
ff_simple_idct_mmx() has been completely disabled in this patch
for x64 and so the test should have been disabled on x64 instead
of removing it.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt
86f8adc58e avcodec/x86/idctdsp_init: Fix IDCT permutation for 32bit without SSE2
bfb28b5ce8 removed the MMX idct_put
and idct_add functions, because they were overridden by SSE2 versions
(which use SSE2 only for the put/add part, not the actual IDCT).
This meant that for MMX, the idct functions are not set in unison,
so that the permutation which is meant to apply to all three
is incorrect on 32bit systems if SSE2 is unavailable/disabled.

Fix this by setting the MMX version only if SSE2 is enabled.

(No one complained, so apparently no one uses a new FFmpeg
with non-SSE2 capable systems.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt
a8dd83b4b1 avcodec/get_bits: Avoid unused variable
Fixes lots of warnings from MSVC (which does not support av_unused).

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 14:48:12 +01:00
Michael Niedermayer
d80f8f3651 avcodec/exr: spelling
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 01:17:46 +01:00
oblivionsage
8abeb879df avcodec/rv60dec: add upper bound check for qp
The quantization parameter (qp) can exceed 63 when the base value
from frame header (0-63) is combined with the offset from slice data
(up to +2), resulting in qp=65. This causes out-of-bounds access to
the rv60_qp_to_idx[64] array in decode_cbp8(), decode_cbp16(), and
get_c4x4_set().

Fixes: Out-of-bounds read
Signed-off-by: oblivionsage <cookieandcream560@gmail.com>

No testsample is available

This is related to 61cbcaf93f and clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5160167345291264
which fixed rv60_qp_to_idx[qp + 32] out of array access
These 2 checks are not redundant and neither covers the cases of the other

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 01:16:39 +01:00
veygax
162f75b5e6 avcodec/exr: use tile dimensions in pxr24 UINT case
update the switch statement for EXR_UINT in pxr24_uncompress to
correctly use the tile width td->xsize instead of using the full window
width s->xdelta. s->delta is larger than td->xsize which lead to two
buffer overflows when interacting with the ptr variable in the same
switch statement.

Fixes: out of bounds read and write
Found-by: veygax's insomnia network (INSOMNIA-1)
Signed-off-by: veygax <veyga@veygax.dev>
2025-11-07 23:27:34 +01:00
Michael Niedermayer
6e8cf0377f avcodec/exr: Simple check for available channels
The existing is_luma check is fragile as depending on the order
of channels it can be set or reset

No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-07 23:12:42 +01:00
Andreas Rheinhardt
dd092f7fd9 avcodec/avcodec: Simplify sentinel checks
There is no need to check the whole AVChannelLayout; checking
its nb_channels is enough.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt
946a1dbd94 avcodec/tests/avcodec: Check codec {pix,sample}_fmt etc. arrays
E.g. check that the ordinary entries are valid (e.g. no negative sample
rates, must have pix fmt descriptor) and also that the sentinels
are valid where they contain redundant information.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt
e9be8b831d avcodec/tests/avcodec: Test that decoders don't set encoder-only fields
For decoders, the pixel format is negotiated via the get_format callback
(if there is a choice at all), so decoders should not set pix_fmts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt
2523235a31 avcodec/amfdec: Don't set AVCodec.pix_fmts
It is not supposed to be set by decoders (where format negotiation
happens via the get_format callback).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt
ef3e337079 avcodec/tests/avcodec: Test color_ranges and alpha_modes
Test that they are only set by video codecs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt
ab70751c8a avcodec/codec_internal: Use bitfield for alpha_modes
Right now, FFCodec contains a dedicated pointer for
alpha_mode; this is wasteful, as there is only a very limited
range of options for this value, namely four.
So store it as a two-bit bitfield like color_ranges.
This reduces sizeof(FFCodec) by 16 here (the placement
of alpha_mode entailed unnecessary padding) and
saves 11328B of .data.rel.ro here (on a standard build with
no external libraries).

(If it were not for effective-type violations, one could
share the code and the table with AV_CODEC_CONFIG_COLOR_RANGE.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt
df1b6f9cfd avcodec/avcodec: Avoid relocations for color ranges
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt
1d68ae7389 avcodec/avcodec: Remove always-true branches
avcodec_get_supported_config() always sets a dummy for
the pointer to the number of entries in case it is not set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt
a2210902ff avcodec/encode: Use enum AVPictureType in ff_encode_add_stats_side_data
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Andreas Rheinhardt
08e75b8211 avcodec/packet: Move ff_side_data_set_encoder_stats() to encode.c
And rename it to ff_encode_add_stats_side_data() and move its
declaration to encode.h. Also constify the error pointee.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Andreas Rheinhardt
ec239259a7 avcodec/libx265: Remove stray FF_ENABLE_DEPRECATION_WARNINGS
Forgotten in 7d07723db5.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Andreas Rheinhardt
8a46fe1a7d avcodec/libaomenc: Avoid av_unused
pict_type is always used since 5e0eac3d4566839598f6d6fe5d77770023d6713a;
ctx in set_pix_fmt() seems to have been always unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Rémi Denis-Courmont
39abb1ac94 pixblockdsp: avoid segments on R-V V diff_pixels_unaligned
On SpacemiT X86, before:
diff_pixels_unaligned_rvv_i32:                         250.2 ( 0.59x)
...after:
diff_pixels_unaligned_rvv_i32:                          56.9 ( 2.60x)
2025-11-07 08:43:23 +00:00
Rémi Denis-Courmont
c17d304e1f pixblockdsp: avoid segments on R-V V get_pixels_unaligned
On SpacemiT X86, before:
get_pixels_unaligned_rvv_i32:                          172.4 ( 0.37x)
...after:
get_pixels_unaligned_rvv_i32:                           34.4 ( 1.84x)
2025-11-07 08:43:23 +00:00
Rémi Denis-Courmont
e3b0d58394 Revert "lavc/pixblockdsp: rework R-V V get_pixels_unaligned"
The optimised version does not work if the stride is not a multiple 8,
which can occur as reproduce by vsynth3-asv1 and vsynth3-asv2 tests.

This reverts commit 02594c8c01.

Conflicts:
	libavcodec/riscv/pixblockdsp_init.c
	libavcodec/riscv/pixblockdsp_rvv.S
2025-11-07 08:43:23 +00:00