1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2026-06-19 19:03:00 +02:00

125119 Commits

Author SHA1 Message Date
Niklas Haas fa6a5807c2 avformat/shared: allow AVERROR_EXIT/EAGAIN as transient failures
These shouldn't really permanently invalidate the block.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas f87923765d avformat/shared: robustness fix for seek-past-end
If the filesize is known as a result of AVERROR_EOF on a block that ends
before the current seek position, this might end up negative. Error
out cleanly instead of aborting.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas a22037858e avformat/shared: use flock() instead of fcntl()
flock() also locks against accesses by other threads of the same
process, unlike fcntl().

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas 9140cbe583 avformat/shared: don't read directly into cache file when racing writes
Instead, read to the output/temporary buffer (write_back path). This is to
lessen the impact of racing the write against other clients trying to race
the same pending block.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas 58e5ec8a5a avformat/shared: allocate fallback buffer unconditionally
Needed for the upcoming commit, but also more robust in general. The memory
waste is negligible.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas c97a2328c0 avformat/shared: set default cache timeout to 10 ms
This value is matched to the typical seek latency in a reasonably capable
7200 rpm disk device, as well as the typical latency of an on-premise HTTP
request.

Note that this change should rarely have a significant effect, because
it only matters when using multiple concurrent processes, and one process
is somehow stuck in I/O (or died). Since we sleep in a loop for 1/16th of
the requested timeout value, this should only increase the effective read
latency by up to ~500 us on top of the actual underlying latency.

The alternative is hammering the same underlying resource with the exact
same requests at the exact same time (e.g. during init).

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
Niklas Haas 5dd020faff avformat/shared: error out if filesize does not match expected
If this happens, something is almost surely wrong with the cache file
(e.g. mismatched source file), so it's much better to error out rather than
hit silent data corruption.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-14 11:10:12 +02:00
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