Commit graph

125012 commits

Author SHA1 Message Date
Niklas Haas
a37c00c4e9 avformat/shared: add missing ret = 0
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
deng.zewen
f704dd77b7 libavcodec/riscv: add RVV optimized hevc_add_res 2026-06-14 03:10:29 +00:00
James Almer
e772f50a65 fftools/ffmpeg_demux: ensure tile grid stream groups are sane
This is already checked in libavformat, at least in the only demuxer that
creates them, but best not risk an out-of-bounds access in case a new demuxer
doesn't take the proper measures.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-13 21:52:32 -03:00
James Almer
3d2c02f1dd avcodec/bsf/h264_mp4toannexb: don't overwrite output codecpar extradata after init()
It's against the documented behavior of bitstream filters.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-13 21:32:07 -03:00
Michael Niedermayer
ab5043f055 avcodec/sanm: reject codec37 frames taller than the allocated buffer
No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 22:03:59 +00:00
Michael Niedermayer
b2695bcbb3 avcodec/sanm: reject codec47 frames taller than the allocated buffer
Fixes: 513469519/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5024854725427200
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 22:03:59 +00:00
Michael Niedermayer
f7368f97b9 avfilter: use ff_slice_pos() for per-slice boundary computation
This is a behavior preserving change for all non-overflowing cases.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 21:41:05 +00:00
Michael Niedermayer
218b4771a3 avfilter: add ff_slice_pos() helper for slice boundaries
Slice based filter workers compute their per-thread row/sample/channel
boundaries as total * jobnr / nb_jobs. The total * jobnr product is
evaluated in int and overflows signed int for large dimensions and many
slice threads, before the division by nb_jobs brings it back in range.
2026-06-13 21:41:05 +00:00
Michael Niedermayer
200e0cba67 avfilter/estdif: avoid signed overflow in slice boundary calculation
deinterlace_slice() computed per-thread row boundaries with int
multiplication height * (jobnr + 1). With a tall frame and many filter
threads the product overflows signed int before the division by nb_jobs.

Use int64_t for the intermediate product before converting back to int
row indices.

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 21:41:05 +00:00
Michael Niedermayer
2ff28aca4b avcodec/jpeglsdec: bound cumulative decoded JPEG-LS height per packet
Fixes: Timeout
Fixes: 509211998/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-5098892286033920
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 21:40:40 +00:00
Michael Niedermayer
10f2abc41f swscale: support sliced input with cascaded scaling contexts
Previously scale_cascaded() assumed the whole source frame arrived in a
single sws_scale() call, and the dispatcher only routed full-frame calls
to it. A partial input slice fell through to ff_swscale() on the parent
dispatcher context, whose scaler state (c->desc) is never initialized in
cascade mode, causing a NULL dereference / crash.

Top-down sliced output is bit-exact with full-frame scaling; bottom-up
matches swscale's pre-existing (non-cascade) slice behaviour for
subsampled intermediate formats.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 21:32:37 +00:00
Michael Niedermayer
6049b4d7bc avformat/rtspdec: bound Content-Length in the ANNOUNCE handler to SDP_MAX_SIZE
Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.
2026-06-13 21:31:18 +00:00
James Almer
0cf9169c85 avcodec/cbs_h266_syntax_template: reject subpic info with res_change_in_clvs
Found-by: Anthony Hurtado
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 15:57:19 +00:00
Michael Niedermayer
7b717fe50d avcodec/misc4: Check nb channels
Found-by: Forgejo Fairy
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 15:55:40 +00:00
Michael Niedermayer
0c662529f6 avcodec/rv10, rv34: check init_get_bits8() before RealVideo bit access
Found-by: Samarth Kumbla <samarthk@cantina.security>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-13 15:54:44 +00:00
Ling, Edison
3773831c21 avcodec/d3d12va_encode: Add H264/HEVC constrained intra prediction parameter support
Add parameter `constrained_intra_pred` for users to enable constrained intra prediction (as opposed to default unconstrained) in D3D12 H264 and HEVC encoding.

Usage:
  false (default): `-constrained_intra_pred false`  or  `-constrained_intra_pred 0`
  true:            `-constrained_intra_pred true`   or  `-constrained_intra_pred 1`

Sample command line:
```
ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v h264_d3d12va -constrained_intra_pred true -y output.mp4
ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v hevc_d3d12va -constrained_intra_pred true -y output.mp4
```
2026-06-13 11:21:14 +00:00
Kacper Michajłow
bb6de744cc
avcodec/opus/enc_psy: init intensity_stereo for silent frames
Silent frames return early from ff_opus_psy_celt_frame_init before
intensity_stereo is set, but postencode_update reads it into
avg_is_band, causing a use-of-uninitialized-value. Set it to end_band
like the non-silent path does.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-13 12:08:10 +02:00
Niklas Haas
f71c30ef9e swscale/x86/ops: fix CPU flags checks
This should be using EXTERNAL_*() as the code lives in separately assembled
files. Also, the FMA4 check should have been FMA3.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-13 08:26:19 +00:00
Andrew Kelley
2797dad735 hevc: qualify libavcodec include paths
Removes the special -I flag specified in the avcodec/hevc/ subdirectory.

This makes code copy-pastable to other parts of the ffmpeg codebase, as
well as simplifying the build script.

It also reduces ambiguity, since there are many instances of same-named
header files existing in both libavformat/ and libavcodec/
subdirectories.

Follows: b29bdd3715
2026-06-13 05:48:44 +00:00
Daniel Verkamp
4a7cc39c63 doc/muxers: Document wav muxer
Signed-off-by: Daniel Verkamp <daniel@drv.nu>
2026-06-13 04:10:48 +00:00
Daniel Verkamp
7d416470c7 doc/demuxers: Document wav ignore_length option
Signed-off-by: Daniel Verkamp <daniel@drv.nu>
2026-06-13 04:10:48 +00:00
Romain Beauxis
bf8f1550f0 tests/fate: move fate-wav-bad-avg-byterate to
fate-seek-bad-avg-byterate, fix build dependency on libavformat/tests/seek
2026-06-12 14:45:42 -05:00
haoyuLiu
dd9083cb89 avformat/http: reject request-line tokens not terminated by whitespace
Fixes out of array access

Found-by: Cloud-LHY (@Clouditera-lhy) / VulnForge Security Research Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 16:47:05 +00:00
James Almer
b817e19259 avformat/dump: support printing Dolby Vision stream group information
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-12 15:10:12 +00:00
Andreas Rheinhardt
9dd0fe0225 avcodec/allcodecs: Move AV_CODEC_PROP_ENHANCEMENT check to test tool
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-12 15:11:53 +02:00
James Almer
631ac6d055 fftools/ffmpeg_filter: propagate display matrix side data through the filterchain
But only if autorotating is disabled.

Fixes issue #23383.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-12 09:28:20 -03:00
Michael Niedermayer
2cc7b87bdb avformat/mov: reject out of range ispe dimensions, avoid overflow summing HEIF tile dimensions
ispe width/height are read as uint32 but stored in int HEIFItem fields;
values above INT_MAX became negative, and read_image_grid() summing such
widths into coded_width overflowed int:
libavformat/mov.c:10404:33: runtime error: signed integer overflow: -2147483647 + -2147483647 cannot be represented in type 'int'

Also accumulate the grid tile dimensions and running offsets in 64bit
and validate the totals, as up to 256 tile columns of individually
valid widths can still overflow int.

Found-by: 51511
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 02:00:36 +00:00
Michael Niedermayer
c82196b299 avformat/hlsenc: reject out-of-range EXT-X-PROGRAM-DATE-TIME
Parse the timestamp with av_small_strptime() instead of sscanf(): it
range-checks each field (year 0-9999, month, day, hour, minute, second)
and limits the number of digits consumed, so an oversized field can no
longer overflow during parsing. The mktime() result is additionally
checked for EOVERFLOW.

Fixes: integer overflow

Found-by: Kery (Qi Kery <qikeyu2001@outlook.com>)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 01:57:06 +00:00
Michael Niedermayer
369a50fe75 tools/target_dec_fuzzer: Bound cumulative get_buffer allocation
Fixes: Timeout
Fixes: 509366072/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-4588961581563904
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 01:56:23 +00:00
Lynne
03be563053
hwcontext_vulkan: fix BGRA/BGR0 images
The fix was a lot simpler than I thought it was.
2026-06-12 10:14:33 +09:00
Andrew Kelley
8a10a8a03e opus: qualify libavcodec include paths
Removes the special -I flag specified in the avcodec/opus/ subdirectory.

This makes code copy-pastable to other parts of the ffmpeg codebase, as
well as simplifying the build script.

It also reduces ambiguity, since there are many instances of same-named
header files existing in both libavformat/ and libavcodec/
subdirectories.

Follows: b29bdd3715
2026-06-12 00:49:14 +00:00
David Korczynski
4527854281 avcodec/agm: validate actual src_y against prev plane in decode_inter_plane
Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 00:47:12 +00:00
David Korczynski
50e65074f5 avformat/dhav: Fix second integer overflow in get_duration()
Fixes: ada-2-poc.dhav

Found-by: Claude and Ada Logics. This issue was found by Anthropic from using agents to study security of open source projects, and I am from Ada Logics helping validate the found issues and report to maintainers.
2026-06-12 00:46:32 +00:00
Zhen Yan
fa391e90fb fftools/ffmpeg_dec: deep-copy subtitle_header to fix use-after-free
Found-by: Zhen Yan
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 00:45:29 +00:00
Michael Niedermayer
d2dd0a0a8f avcodec/cbs_h265: allocate VPS hrd_parameters dynamically
H265RawVPS embedded hrd_parameters as an inline array of
HEVC_MAX_LAYER_SETS (1024) H265RawHRDParameters, making the structure
roughly 7.9 MB. CBS allocates the whole content structure for every VPS
NAL unit before parsing it, so a packet consisting of many tiny VPS NALs
forces gigabytes of allocations and triggers an out-of-memory condition.

Allocate hrd_parameters separately, sized to vps_num_hrd_parameters,
backed by an AVBufferRef registered as a second internal reference
offset on the VPS unit type. This shrinks the resident structure to tens
of kilobytes and bounds the hrd_parameters allocation by the amount that
is actually parsed.

Fixes: 472754452/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6379024978083840
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 00:43:44 +00:00
Michael Niedermayer
82f097c825 avcodec/hevc/ps: Check window parameters
Fixes: signed integer overflow: -1094995529 * 2 cannot be represented in type 'int'
Fixes: 484567435/clusterfuzz-testcase-minimized-ffmpeg_dem_HXVS_fuzzer-5628836988649472

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 01:44:34 +02:00
Michael Niedermayer
8c868a1fd2 avcodec/hevc/ps: Factor window reading out
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-12 01:44:34 +02:00
James Almer
e4c631731e avformat/mov: allow outputting potentially truncated APV packets
The size field could be wrong while the actual payload is valid.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-11 21:09:24 +00:00
James Almer
4b23a90935 avcodec/lcevcdec: respect log level from the external library
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-11 17:28:14 -03:00
James Almer
d024831750 avcodec/lcevcdec: don't inherit the parent decoder logging context
Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-11 17:27:19 -03:00
Niklas Haas
625ab011f4 swscale/uops: add default fallback for translate_op()
Makes it a bit easier to add ops and uops in separate commits.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas
b488ee5553 swscale/ops: generalize SwsReadWriteOp.packed to enum
I want to start adding more data layouts, like semiplanar formats (nv12), or
palette formats. I made an effort to distinguish existing checks for rw.packed
into "mode != PLANAR" and "mode == PACKED", based on the intent of the
surrounding code, in anticipation of these new layouts.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas
01c007ec4d swscale/ops_memcpy: simplify plane count check
Instead of testing for this condition indirectly via packed and rw.elems,
we can now express the relevant condition directly. The memcpy backend works
if and only if each component lives on a separate plane.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas
84c8f55398 swscale/ops_optimizer: simplify shuffle solver plane checks
Using ff_sws_rw_op_planes(), to directly encode the relevant condition (i.e.
physical access to multiple planes).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas
5f43d0cd46 swscale/ops: add and use ff_sws_rw_op_planes()
This is rw_planes() from ops_dispatch.c, but exposed internally.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas
ef79a57b75 swscale/ops_dispatch: move some code from setup() to compile()
This won't change from frame to frame, so there's no reason to redundantly
re-setup these fields. Paves the way for the next change as well.

The one minor annoyance is that this relies on SwsOpList.src/dst being
populated, to gain access to the sub_x/sub_y fields. However, that's not
a big ask, given that e.g. the dispatch layer already relies on the
pixel dimensions from this field being accurate for sizing intermediate
buffers during filter splitting.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas
7c5d45b843 swscale/ops_dispatch: reword misleading error
The block size is given in units of pixels, so this message as written
does not even make sense.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas
addee69955 swscale/ops_dispatch: generalize block_size_in/out to array
See previous commit for justification. I decided to split these
refactors up into several independent commits to make it easier
to review and bisect, since they are all independent atomic changes.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas
2d01687fd0 swscale/ops_dispatch: generalize over_read/over_read to array
I want to introduce operations like semiplanar reads, which would
possibly require a different number of over_read bytes per plane.

That aside, this is just a general cleanliness improvement.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00
Niklas Haas
11900e4e12 swscale/ops: generalize SWS_OP_FILTER_* result type
Instead of hard-coding SWS_PIXEL_F32 here. This is not really useful
yet, but I wanted to clean up the semantics here regardless.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-11 16:27:47 +00:00