Commit graph

52961 commits

Author SHA1 Message Date
Andreas Rheinhardt
c6efe1abda avcodec/h264chroma: Move mc1 function to mpegvideo_dec.c
It is only used by mpegvideo decoders (for lowres). It is also only used
for bitdepth == 8, so don't build the bitdepth == 16 function at all any
more.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 13:31:57 +01:00
James Almer
6879c8ee5d avcodec/avcodec: add helpers to convert between packet and frame side data
They will be used in following commits.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 10:54:01 -03:00
Andreas Rheinhardt
0242cb36a5 avcodec/rv34dsp: Reduce size of qpel functions arrays
Only size 16 and 8 are used (and set).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-30 12:17:25 +01:00
Zhao Zhili
82c495fd15 avcodec/hevc: fix false alarm when build with enable-small
profile_name is always NULL with --enable-small, which leading to
a warning message "Unknown profile bitstream".
2025-10-30 09:26:17 +00:00
Andreas Rheinhardt
0f105b96a3 avcodec/x86/hevc/idct: Port ff_hevc_idct_4x4_dc_{8,10,12}_mmxext to SSE2
Practically no change in benchmarks (and in codesize).

hevc_idct_4x4_dc_8_c:                                    7.8 ( 1.00x)
hevc_idct_4x4_dc_8_mmxext:                               6.9 ( 1.14x)
hevc_idct_4x4_dc_8_sse2:                                 6.8 ( 1.15x)
hevc_idct_4x4_dc_10_c:                                   7.9 ( 1.00x)
hevc_idct_4x4_dc_10_mmxext:                              6.9 ( 1.16x)
hevc_idct_4x4_dc_10_sse2:                                6.8 ( 1.16x)
hevc_idct_4x4_dc_12_c:                                   7.8 ( 1.00x)
hevc_idct_4x4_dc_12_mmxext:                              7.0 ( 1.13x)
hevc_idct_4x4_dc_12_sse2:                                6.8 ( 1.15x)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-30 08:56:45 +01:00
Michael Niedermayer
909af3a571
avcodec/g723_1enc: Make min_err 64bit
This is intending to fix the case described in https://lists.ffmpeg.org/archives/list/ffmpeg-devel@ffmpeg.org/thread/AAZ7GJPPUJI5SCVTDGJ6QL7UUEP56WOM/
Where FCBParam optim is used uninitialized

a min_err of 1<<30, allows the struct to be never initilialized as all
err (which is int32_t) can be larger than min_err. By increasing min_err
above the int32_t range this is no longer possible

Untested, as i do not have the testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>i
2025-10-30 03:41:24 +01:00
Michael Niedermayer
d8ffec5bf9
avcodec/vlc: Clear val8/16 in vlc_multi_gen() by av_mallocz()
Fixes: use of uninitialized memory
Fixes: 427814450/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_DEC_fuzzer-646512196065689
Fixes: 445961558/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_DEC_fuzzer-5515158672965632

the multi vlc code will otherwise return uninitialized data. Now one can argue that this data should
not be used, but on errors this data can remain ...

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-30 02:08:14 +01:00
Lynne
afd927e0ca prores_raw: skip frames if the discard flag is set
All other decoders do this.
2025-10-28 23:10:15 +01:00
Andreas Rheinhardt
0941646182 avcodec/fflcms2: Don't access inexistent array elements
This would happen if one of the extended transfer characteristics is in
use (currently only AVCOL_TRC_V_LOG).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-28 21:40:50 +01:00
Lynne
e85947576c
ffv1enc_vulkan: limit probability caching to RADV only
Nvidia's drivers recently broke this.
2025-10-28 20:46:25 +01:00
Lynne
bcfb4b2e3e prores_raw_parser: set color params based on vendor
Panasonic cameras record ProRes RAW in V-Log/V-Gamut internally.

Atomos is a brand of recorders which can record uncompressed
non-debayered RAW over HDMI.
All known cameras output linear RAW over HDMI, so mark the transfer function
as linear in that case.
2025-10-28 20:46:21 +01:00
Lynne
aeb9b19ebc lavu: add support for Panasonic V-Log 2025-10-28 20:46:21 +01:00
James Almer
530ca627a3 avcodec/mlpdec: don't depend on context channel layout when setting substream masks
If avctx->ch_layout is unset (as it's allowed and even expeced by the
AV_CODEC_CAP_CHANNEL_CONF flag), the code setting substream masks will fail for
stereo and mono layouts unless a downmix channel was requested.
Fix this by deriving the mask with coded values only.

Fixes issue #20764.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-28 13:08:02 +00:00
xin.guo
0a4bd6cc23 avcodec/h264_vulkan: Fix param error in set_sps
Signed-off-by: xin.guo <xin.guo@sophgo.com>
2025-10-28 06:12:36 +00:00
averne
909d71322a vulkan/prores: output LSB-padded data
For consistency with existing Vulkan-based hwaccels
2025-10-28 06:12:14 +00:00
Lynne
70be2e2ae2
lavc/hwaccels: properly order list 2025-10-28 07:11:26 +01:00
Lynne
51843adfe5
vulkan/rangecoder: ifdef out encode and decode chunks
There's little code sharing between them.
2025-10-28 07:11:26 +01:00
Lynne
3cd678506c
vulkan_decode: align images to the subsampling
Normally, the Vulkan drivers handle this. But Vulkan decided "nah".

This requires API users to crop out odd-numbered images with subsampling.
2025-10-28 07:11:26 +01:00
Lynne
5b388f2838 hwcontext_vulkan: remove unsupported/broken pixel formats
We have no use for 14-bit pixel formats for now, so remove support for gray14,
which was broken due to the LSB padding issue.

Similarly YUVA at 10/12 bit was broken for the same reason.
2025-10-27 22:59:41 -03:00
Lynne
98ee3f6718 hwcontext_vulkan: fix planar 10 and 12-bit RGB formats using the new MSB formats 2025-10-27 22:59:41 -03:00
Lynne
41ecb203c5 hwcontext_vulkan: fix 3-plane 444 10 and 12-bit formats using the new MSB formats
We previously tried to fudge this somehow, but the pixel formats
are simply broken and we cannot use them without declaring them as MSB.
2025-10-27 22:59:41 -03:00
Lynne
471acedec2 hwcontext_vulkan: fix grayscale 10 and 12-bit formats using the new MSB formats 2025-10-27 22:59:41 -03:00
Kacper Michajłow
a6ccaa2eea
avcodec/d3d12va_encode_h264: remove unused variables
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 15:39:39 +01:00
Kacper Michajłow
d57de83352
avcodec/d3d12va_encode: fix format specifier for HRESULT
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 15:39:39 +01:00
David Rosca
a0a16f2ea4 cbs_vp9: Always update loop filter and segmentation from current frame
Fixes decoding vp90-2-09-aq2, vp90-2-15-segkey_adpq, vp90-2-15-segkey
and vp90-2-22-svc_1280x720_1 with Vulkan hwaccel.

Fixes: 26a2a76346 ("cbs_vp9: Fix VP9 passthrough")
2025-10-27 13:44:03 +00:00
Andreas Rheinhardt
d01608e022 avcodec/proresdec: Remove unused hwaccel_last_picture_private
ProRes is an intra-only codec.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-25 22:34:30 +02:00
averne
23df9d4172 avcodec/prores: add parser
Introduce a basic parser for ProRes frame headers.
This avoid having to decode an entire frame to
extract codec information.
2025-10-25 19:56:44 +00:00
averne
98412edfed lavc: add a ProRes Vulkan hwaccel
Add a shader-based Apple ProRes decoder.
It supports all codec features for profiles up to
the 4444 XQ profile, ie.:
- 4:2:2 and 4:4:4 chroma subsampling
- 10- and 12-bit component depth
- Interlacing
- Alpha

The implementation consists in two shaders: the
VLD kernel does entropy decoding for color/alpha,
and the IDCT kernel performs the inverse transform
on color components.

Benchmarks for a 4k yuv422p10 sample:
- AMD Radeon 6700XT:   178 fps
- Intel i7 Tiger Lake: 37 fps
- NVidia Orin Nano:    70 fps
2025-10-25 19:54:13 +00:00
averne
3fd55d952e avcodec/proresdec: save slice width parameter in codec context
Save the log2_desired_slice_size_in_mb syntax
element in the codec context.
Required by the Vulkan hwaccel to compute slice
widths and positions.
2025-10-25 19:54:13 +00:00
averne
987368ef25 avcodec/prores: adapt hwaccel code for slice-based accelerators
In preparation for the Vulkan hwaccel.
The existing hwaccel code was designed around
videotoolbox, which ingests the whole frame
bitstream including picture headers.
This adapts the code to accomodate lower-level,
slice-based hwaccels.
2025-10-25 19:54:13 +00:00
averne
9195af77eb proresdec: allocate private memory for hwaccel pictures
In preparation for the Vulkan hwaccel, which
stores per-frame acceleration structures.
2025-10-25 19:54:13 +00:00
Kacper Michajłow
ddeec523a2
avcodec/x86/idctdsp: add restrict to match function pointer types
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow
49cfafefd4
avcodec/rectangle: use uintptr_t for integer pointer type
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow
0cd999266f
avcodec/put_bits: add explicit cast to suppress MSVC warning
Supresses:
warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)

Also drop L, as shift will never exceed 31.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow
fe425d97d1
avcodec/cbs*: remove redundant const, it's already in typedef
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow
9ad20839fb
avcodec/pixblockdsp: be consistent about restrict use in ff_{get,diff}_pixels
Suppresses warnings about function pointer mismatch.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow
c597d8cac1
avcodec/aacpsdsp: add restrict to function pointers to match declarations
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:14 +02:00
Kacper Michajłow
a2b47ccfbf avcodec/{png,mov}enc: use EOTF gamma approximation for gAMA chunk
This is how images encoded with specific transfer function should be
viewed. Image viewers that doesn't support named trc metadata, will
fallback to simple gAMA value and both of those cases should produce the
same image apperance for the viewer.

Fixes: https://github.com/mpv-player/mpv/issues/13438

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-24 22:24:54 +00:00
Bin Peng
3115c0c0e6 lavc/aarch64: Fix addp overflow in ff_pred16x16_plane_neon_10
The mismatch between neon and C functions can be reproduced
using the following bitstream and command line on aarch64 devices.

wget https://streams.videolan.org/ffmpeg/incoming/replay_intra_pred_16x16.h264
 ./ffmpeg -cpuflags 0  -threads 1 -i replay_intra_pred_16x16.h264  -f framemd5 -y md5_ref
 ./ffmpeg              -threads 1 -i replay_intra_pred_16x16.h264 -f framemd5 -y md5_neon

Signed-off-by: Bin Peng <pengbin@visionular.com>
2025-10-24 15:32:35 +00:00
cenzhanquan1
1120b3db30 avcodec/liblc3enc: support packed float (AV_SAMPLE_FMT_FLT) input.
Previously, the LC3 encoder only accepted planar float (AV_SAMPLE_FMT_FLTP).
This change extends support to packed float (AV_SAMPLE_FMT_FLT) by properly
handling channel layout and sample stride.

The pcm data pointer and stride are now calculated based on the sample
format: for planar, use frame->data[ch]; for packed, use frame->data[0]
with channel offset. The stride is set to 1 for planar and number of
channels for packed layout.

This enables encoding from common packed audio sources without requiring
a prior planar conversion, improving usability and efficiency.

Signed-off-by: cenzhanquan1 <cenzhanquan1@xiaomi.com>
2025-10-23 14:42:50 +00:00
cenzhanquan1
0eb572f080 avcodec/liblc3dec: support sample format negotiation and planar layout.
1. Adds support for respecting the requested sample format. Previously,
   the decoder always used AV_SAMPLE_FMT_FLTP. Now it checks if the
   caller requested a specific format via avctx->request_sample_fmt and
   honors that request when supported.

2. Improves planar/interleaved audio buffer handling. The decoding
   logic now properly handles both planar and interleaved sample
   formats by calculating the correct stride and buffer pointers based
   on the actual sample format.

The changes include:
- Added format mapping between AVSampleFormat and lc3_pcm_format
- Implemented format selection logic in initialization.
- Updated buffer pointer calculation for planar/interleaved data.
- Maintained backward compatibility with existing behavior.

Signed-off-by: cenzhanquan1 <cenzhanquan1@xiaomi.com>
2025-10-23 22:06:04 +08:00
Zhao Zhili
edf5b777c9 avcodec/vvc: fix false alarm of missing ref on RASL 2025-10-21 13:21:52 +00:00
Andreas Rheinhardt
05b8608c76 avcodec/x86/mpegvideoencdsp_init: Fix left shift of negative number
Uncovered by UBSan when running the mpegvideoencdsp checkasm
test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-21 12:11:55 +02:00
Leo Izen
dc39a576ad
avcodec/pngenc: include EXIF buffer in max_packet_size
When calculating the max size of an output PNG packet, we should
include the size of a possible eXIf chunk that we may write.

This fixes a regression since d3190a64c3
as well as a bug that existed prior in the apng encoder since commit
4a580975d4.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-10-19 09:17:38 -04:00
Michael Niedermayer
388e6fb3be
avcodec/ffv1enc: Consider variation in slice sizes
When splitting a 5 lines image in 2 slices one will be 3 lines and thus need more space

Fixes: Assertion sc->slice_coding_mode == 0 failed at libavcodec/ffv1enc.c:1668
Fixes: 422811239/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-4933405139861504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:26 +02:00
Michael Niedermayer
4666c1eed3
libavcodec/cbs_apv_syntax_template: limit tile to 2gb
We do not support larger tiles as we use signed int
Alternatively we can check this in apv_decode_tile_component() or init_get_bits*()
or support bitstreams above 2gb length

Fixes: init_get_bits() failure later
Fixes: 421817631/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APV_fuzzer-4957386534354944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:32:42 +02:00
Araz Iusubov
d19b7c283c avcodec/d3d12va_encode: D3D12 H264 encoding support
This patch introduces hardware-accelerated H.264 encoding
using Direct3D 12 Video API (D3D12VA).
2025-10-18 12:20:11 +00:00
Andreas Rheinhardt
ed007ad427 avcodec/x86/fpel: Port ff_put_pixels8_mmx() to SSE2
This has the advantage of not violating the ABI by using
MMX registers without issuing emms; it e.g. allows
to remove an emms_c from bink.c.

This commit uses GP registers on Unix64 (there are not
enough volatile registers to do likewise on Win64) which
reduces codesize and is faster on some CPUs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-17 13:27:56 +02:00
Andreas Rheinhardt
d91b1559e0 avcodec/x86/me_cmp: Replace MMXEXT size 16 funcs by unaligned SSE2 funcs
Snow calls some of the me_cmp_funcs with insufficient alignment
for the first pointer (see get_block_rd() in snowenc.c);
therefore SSE2 functions which really need this alignment
don't get set for Snow and 542765ce3e
consequently didn't remove MMXEXT functions which are overridden
by these SSE2 functions for normal codecs.

For reference, here is a command line which would segfault
if one simply used the ordinary SSE2 functions for Snow:

./ffmpeg -i mm-short.mpg -an -vcodec snow -t 0.2 -pix_fmt yuv444p \
-vstrict -2 -qscale 2 -flags +qpel -motion_est iter 444iter.avi

This commit adds unaligned SSE2 versions of these functions
and removes the MMXEXT ones. This in particular implies that
sad 16x16 now never uses MMX which allows to remove an emms_c
from ac3enc.c.

Benchmarks (u means unaligned version):
sad_0_c:                                                 8.2 ( 1.00x)
sad_0_mmxext:                                           10.8 ( 0.76x)
sad_0_sse2:                                              6.2 ( 1.33x)
sad_0_sse2u:                                             6.7 ( 1.23x)

vsad_0_c:                                               44.7 ( 1.00x)
vsad_0_mmxext (approx):                                 12.2 ( 3.68x)
vsad_0_sse2 (approx):                                    7.8 ( 5.75x)

vsad_4_c:                                               88.4 ( 1.00x)
vsad_4_mmxext:                                           7.1 (12.46x)
vsad_4_sse2:                                             4.2 (21.15x)
vsad_4_sse2u:                                            5.5 (15.96x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-17 13:05:07 +02:00
Andreas Rheinhardt
69a700043d avcodec/x86/me_cmp: Remove MMXEXT functions overridden by SSE2
The SSE2 function overriding them are currently only set
if the SSE2SLOW flag is not set and if the codec is not Snow.
The former affects only outdated processors (AMDs from
before Barcelona (i.e. before 2007)) and is therefore irrelevant.
Snow does not use the pix_abs function pointers at all,
so this is also no obstacle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-17 13:05:07 +02:00