Commit Graph

53347 Commits

Author SHA1 Message Date
Ramiro Polla
165448f7d1 avcodec/mjpegdec: remove buggy_avid field from MJpegDecodeContext
This field has been unused since b6c04b6821.
2026-01-08 16:29:32 +00:00
Ruikai Peng
f1dbef3e38 avcodec/mjpegdec: avoid negative len in APP parser
The APP parser can read a fixed number of bytes without checking len,
making len negative and passing it to bytestream2_skipu(), which takes
an unsigned size. This can advance the buffer by a huge amount and
results in undefined behavior.

Add small len guards in the fixed-size AVI1/LJIF paths and only skip
the tail if len > 0.

Signed-off-by: Ruikai Peng <ruikai@pwno.io>
2026-01-07 17:33:02 +00:00
Andreas Rheinhardt
1461dfcde7 avcodec/amfdec: Check correct value, return error upon error
Found via an unused-variable warning from GCC.
Also just forward the error from amf_init_frames_context().

This bug has been introduced in
4479d28103.

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Reviewed-by: Mikhail Mironov <mikhail.mironov@amd.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 17:32:06 +01:00
Cosmin Stejerean
56bc8fd0a1 avcodec/dovi_rpu(enc|dec) - fix parsing and writing of L11 DoVi metadata
sharpness, noise_reduction, mpeg_noise_reduction,
frame_rate_conversion, brightness and color are not actual fields in
L11 metadata, this appears to be based on perhaps an out of date
patent specification. Instead the two bytes are considered
reserved.

Drop reading them and write out 0s, the fields will be deprecated from
the struct in a future commit and scheduled for removal.
2026-01-07 13:14:11 +00:00
Leo Izen
ec42a0aec0 avcodec/exif: avoid overflow with supplemental extra IFDs
If extra IFDs occur outside of the top level, we don't allocate enough
buffer space for them. This commit changes our calculation to include
their size always, and then we shrink the allocated buffer once every
IFD is written (by at most 192 bytes).

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-01-07 04:01:51 -05:00
Andreas Rheinhardt
90920a645e avcodec/vc1dec: Reduce size of allocation
blk_mv_type is only set for block 0-3, not for chroma blocks,
so it only needs four elements per MB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-06 00:02:16 +01:00
Timo Rothenpieler
b5d6cfd55b avcodec/notchlc: zero-initialize history buffer
Otherwise a specially crafted bitstream can potentially read
uninitialized stack memory.

Fixes #YWH-PGM40646-37
2026-01-05 13:30:38 +00:00
Timo Rothenpieler
7f44dcfbfb avcodec/notchlc: actually use HISTORY_SIZE to initialize history 2026-01-05 13:30:38 +00:00
Ramiro Polla
1debadd58e avcodec/mjpegdec: use GetByteContext instead of GetBitContext where possible
JPEG is mostly byte-aligned. We only really need GetBitContext while
decoding the image data.

Suggested-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-05 13:14:15 +00:00
Ramiro Polla
6f6826d2e0 avcodec/mxpegdec: remove unnecessary scope and indentation 2026-01-05 13:14:15 +00:00
Ramiro Polla
fdff03425b avcodec/mjpegdec: fix indentation for previous commit 2026-01-05 13:14:15 +00:00
Ramiro Polla
a84627aca9 avcodec/mjpegdec: add mjpeg_parse_len() helper
And check for length field in a consistent manner.
2026-01-05 13:14:15 +00:00
Ramiro Polla
abb0247017 avcodec/mjpegdec: improve check for length in ff_mjpeg_decode_dqt() 2026-01-05 13:14:15 +00:00
Zhao Zhili
840183d823 aarch64/hpeldsp_neon: fix out-of-bounds read
Fix #21141

The performance improved a little bit.
On A76:
                              Before            After
put_pixels_tab[0][1]_neon:    32.4 ( 3.91x)     31.6 ( 3.99x)
put_pixels_tab[0][3]_neon:    88.0 ( 4.50x)     74.6 ( 5.31x)
put_pixels_tab[1][1]_neon:    33.5 ( 2.52x)     31.2 ( 2.71x)
put_pixels_tab[1][3]_neon:    30.5 ( 3.61x)     21.7 ( 5.08x)

On A55:
                             Before            After
put_pixels_tab[0][1]_neon:   175.2 ( 2.41x)    138.7 ( 3.04x)
put_pixels_tab[0][3]_neon:   334.3 ( 2.71x)    296.1 ( 3.07x)
put_pixels_tab[1][1]_neon:   168.3 ( 1.78x)     94.1 ( 3.19x)
put_pixels_tab[1][3]_neon:   112.3 ( 2.20x)     90.0 ( 2.74x)
2026-01-04 03:22:55 +00:00
Andreas Rheinhardt
fb72a3d567 avcodec/vc1_block: Simplify vc1_coded_block_pred()
Make it already apply the prediction, avoiding the pointer indirection.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt
0d2ab41ec8 avcodec/h261: Remove H261Context
It only contains a single field, so add this directly to MPVContext
and remove private_ctx. This avoids an indirection in
ff_h261_loop_filter().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt
3946e57797 avcodec/mpegvideo: Move permutated_intra scans to {H263Dec,MPVEnc}Ctx
Only used by these two.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt
c9c452688b avcodec/wmv2dec: Avoid indirection
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt
90191e8ab9 avcodec/wmv2: Remove WMV2Context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt
f02f948ed0 avcodec/wmv2dsp: Modify IDCTDSPContext directly
This allows to remove ff_wmv2_common_init() altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt
34c9438bbe avcodec/wmv2dsp: Move mspel motion functions out of WMV2DSPContext
They are only used by the decoder (which has them twice, because
the IntraX8Context contains a WMV2DSPContext whose put_mspel_pixels
functions were unused), so move them there.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt
956bfec115 avcodec/wmv2: Move ff_msmpel_motion() to the decoder
mspel is not supported by the encoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt
70b58e770d avcodec/msmpeg4: Mark unreachable code as unreachable
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:22 +01:00
Andreas Rheinhardt
1674ff14e9 avcodec/wmv2dec: Mark unreachable code as unreachable
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt
224473b676 avcodec/wmv2dec: Don't put skip_type in context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt
11b32b780f avcodec/msmpeg4: Avoid branch
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt
4f4cbed928 avcodec/msmpeg4: Initialize WMV2 generically
WMV1 and WMV2 use other scantables and therefore
ff_msmpeg4_common_init() reinitializes them. Yet WMV2
also uses a different IDCT overwriting the ordinary one,
so that the IDCT permutation changes and therefore
ff_wmv2_common_init() (called after ff_msmpeg4_common_init())
needs to reinitialize the scantables again.

Avoid this by calling ff_wmv2_common_init() in
ff_msmpeg4_common_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt
15e1e61888 avcodec/wmv2: Don't initialize BlockDSPContext redundantly
ff_mpv_common_init() already does it for us.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Ramiro Polla
ee5d6e7ee1 avcodec/jpeglsdec: propagate error from ff_jpegls_decode_picture()
Fixes fe7fbf3a22
2026-01-01 23:57:08 +00:00
Lynne
58bd5ad630 vulkan/prores_raw_idct: use the same prores_idct method for loading coeffs
This saves 2 barriers.
Also implement workbank avoidance.
2025-12-31 15:00:47 +01:00
Lynne
7f2783dcef vulkan_prores_raw: avoid long lines
Just some tidying up.
2025-12-31 15:00:47 +01:00
Lynne
c3e117670d vulkan_prores: use ff_vk_buf_barrier() 2025-12-31 15:00:47 +01:00
Lynne
f956e9817c ffv1enc_vulkan: use ff_vk_buf_barrier() 2025-12-31 15:00:46 +01:00
Lynne
eeeae0e0af vulkan_ffv1: use ff_vk_buf_barrier() 2025-12-31 15:00:46 +01:00
Lynne
9f3a04d2f6 vulkan: use HOST_CACHED memory flag only if such a heap exists
NVK does not offer such, so our code failed to allocate memory.
2025-12-31 15:00:46 +01:00
Kacper Michajłow
0a8b915b04 avcodec/vulkan_decode: fix logic error when checking for encode support
Both FF_VK_EXT_VIDEO_ENCODE_QUEUE and FF_VK_EXT_VIDEO_MAINTENANCE_1 are
required, not only one of them.

Found by VVL.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-31 10:30:36 +00:00
hajin-chung
991ba3fbac avcodec/qsvdec: fix refcount leak in two-stage QSV init
The temporary hw_frames_ctx created for header parsing was not being
fully released, leading to a leak. Explicitly unreference the temporary
context after use to resolve the leak.

Signed-off-by: hajin-chung <hajinchung1@gmail.com>
2025-12-31 08:06:48 +00:00
Leo Izen
4bfac71ecd avcodec/exif.c: avoid buffer overflow with extra IFDs
Maliciously constructed input EXIF blocks could use the extra IFDs we
set aside in noncontinugous ways, which will cause them to be written
as subdirectories of IFD0 rather than existing IFDs. The base tag size
is (correctly) excluded from the size calculation, but if they are
being written as additional tags, the allocation will be too small and
a write may overflow.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-30 20:43:49 -05:00
Benjamin Cheng
531e184944 lavc/vulkan_video: Drop sampler
With the limiting of video usages on the image views, we no longer need
a yuv sampler, since no multi-plane image will be created with the
SAMPLED usage bit.
2025-12-30 14:39:08 -05:00
Benjamin Cheng
b8de254e8c lavc/vulkan_video: Restrict usages for image views
These image views are used only internally for video coding, so they do
not need all the usages of the image it's created from.
2025-12-30 14:38:37 -05:00
Benjamin Cheng
24db09a881 lavc/vulkan_video: Restrict usages for image views
These image views are used only internally for video coding, so they do
not need all the usages of the image it's created from.
2025-12-30 14:15:46 -05:00
Ramiro Polla
aa80a7880b avcodec/jpegls: rename SOF48 to SOF55
SOF48 (0xf0) was used in a public draft of the standard (FCD 14495).
In the final specification it is called SOF55 (0xf7).
2025-12-30 17:30:45 +00:00
Frank Plowman
72a38c12e5 lavc/vvc: Prevent OOB write to slice_top_left_ctu_x in PPS CBS
Prior to the fix, in the case of a tile containing multiple slices
(pps_num_exp_slices_in_tile != 0) the number of slices was temporarily
allowed to exceed pps_num_slices_in_pic_minus1+1 and therefore
VVC_MAX_SLICES.  The number of slices was later verified, but while the
current slice index was higher than expected it was used to write to a
array of size VVC_MAX_SLICES, leading to an OOB write.

To rectify this, the patch adds some checks at an earlier stage, to
ensure that the slice index i + j at no point exceeds
pps_num_slices_in_pic_minus1.

Fixes #YWH-PGM40646-30
2025-12-30 13:39:40 +00:00
Ramiro Polla
7dda7f3b99 avcodec/mjpegdec: speed up find_marker()
Minimize number of reads and simplify conditionals.

Also use memchr(), as suggested by Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-29 21:44:07 +00:00
Ramiro Polla
254124f869 avcodec/mjpegdec: fix some error return codes 2025-12-29 17:22:34 +01:00
tangsha
d28250eada avcodec/adpcm: Fix step_index decoding by skipping padding byte
The bug was caused by incorrect reading of the step_index field: the original
code read a 16-bit value (including a padding byte) instead of the correct
8-bit step_index as defined by the ADPCM format. This led to distorted audio
or incorrect step calculations when decoding specific ADPCM-encoded files.

Fix by:
1. Reading step_index as an 8-bit unsigned byte via bytestream2_get_byteu()
2. Skipping the subsequent 8-bit padding byte with bytestream2_skip()
2025-12-29 14:18:35 +00:00
Michael Niedermayer
ecd2919174 avcodec/mjpegdec: only test the size bound in sequential mjpeg
The original fix was intended only for sequential mjpeg, but it was also used for progressive
which broke. This commit fixes this regression

Fixes: issue21225

The testcase 6381/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-5665032743419904 still exits within 240ms

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-29 13:57:33 +00:00
James Almer
fc5f45bd42 avcodec/libdav1d: only consider colorspace when choosing between YUV and GBR
Several files use values for primaries and transfer characteristics other than
BT709 and IEC_61966 respectively, while still being GBR.
Also always set color_range while at it. It's always coded in the bistream.

Fixes part of #21304.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-28 15:32:57 -03:00
James Almer
a8f1c2366e avcodec/libaomdec: don't overwrite color information from the container if unset in the bitstream
Fixes part of #21304.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-28 15:31:13 -03:00
James Almer
afeff1c729 avcodec/interplayacm: add a flush callback function
Should prevent potential buffer overflows if passing new packets after seeking.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-28 12:55:59 -03:00