Commit Graph
28132 Commits
Author SHA1 Message Date
Paper 7aab64c1f2 avformat/libopenmpt: align AVOptions and remove unnecessary whitespace
This is a purely cosmetic change.

Signed-off-by: Paper <paper@tflc.us>
2026-11-04 13:44:25 +00:00
Paper eab1c88448 avformat/libopenmpt: add configurable interpolation options
This commit adds an interpolation setting to the AVOptions
structure, allowing the user to choose which method they
would like to use. For modules, this is fairly important.
Most modules use lo-fi samples (read: 8khz 8-bit possibly
adpcm) which can sound terrible when mixing using high
quality interpolation algorithms. This becomes especially
prevalent in chiptune compositions, where hi-fi
interpolation completely changes the sound.

Virtually any value is accepted by libopenmpt, but only
[1,2,4,8] produce any tangible difference in output. All
other values seemingly get routed to the default, which
is equivalent to passing 8 (8-tap windowed sinc).

Signed-off-by: Paper <paper@tflc.us>
2026-11-04 13:44:25 +00:00
Romain Beauxis cac8deb2f9 avformat/mov: keep the current sample when a fragment is inserted at it
When a fragment's samples are inserted into the index exactly at a stream's current sample, current_sample is left on the first inserted entry, and tts_index is never moved with the shifted timing entries, so after a seek a stream moves back to the start of the loaded fragment or gets the composition offset of another sample.

Advance current_sample and tts_index past the inserted entries, and roll tts_index back with current_sample when a truncated trun is trimmed.

The seek in fate-mov-mp4-frag-chapters-seek now returns the same packets and timestamps as a read without the fragment index.
2026-11-04 13:19:26 +00:00
Romain Beauxis be65e08c18 avformat/mov: ignore discarded streams when placing the fragment position on seek
With seek_individually, the last stream seeked sets next_root_atom, so a chapter track whose samples all sit in the first fragment makes mov_read_packet() read every fragment from the start of the file before it reaches the seeked sample.

Resume reading from the earliest fragment any stream that is read landed in, which keeps the fragments that a lagging audio track still needs and ignores the chapter track.

The seek in fate-mov-mp4-frag-chapters-seek no longer restarts from the beginning of the file.
2026-11-04 13:19:26 +00:00
Kacper Michajłow ef53ec02d8 avformat/hls: drop WebVTT cues repeated across segment boundaries
A WebVTT segment contains every cue shown during its period (RFC 8216,
3.5), so a cue that reaches into the next segment appears in both. Keep
the cues of the previous segment and drop the ones the current segment
repeats, so each cue is delivered once. The kept cues read before the
media position was known move onto it once it is, so the comparison is on
one timeline. Nothing is repeated across a discontinuity, so the kept cues
are dropped when the opened segment has another discontinuity sequence
number (RFC 8216, 4.3.3.3), which also covers a boundary that already left
a live playlist.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-11-04 02:28:56 +00:00
Kacper Michajłow 729de963f9 avformat/hls: keep the subtitle cues still shown at the seek target
Discard the cues of a subtitle playlist by their end time when seeking
or when the playlist is enabled during playback, so a cue that is on
screen at the target is delivered instead of the next one starting after
it.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-11-04 02:28:56 +00:00
Kacper Michajłow 609972d4cc avformat/hls: keep subtitle playlists on the shared timeline
The cue times of a subtitle playlist are on the MPEG-TS timeline, and
the first cue of a segment says nothing about where the segment starts,
so use an offset of 0 instead of deriving one from the first cue, which
made a seek skip the cues within that offset.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-11-04 02:28:56 +00:00
Kacper Michajłow b4738344cd avformat/hls: apply the X-TIMESTAMP-MAP header of WebVTT segments
Set the timestamp_map option of the webvtt demuxer for the subtitle
segments in place of prefer_hls_mpegts_pts, which no demuxer has, so the
cue times land on the MPEG-TS timeline of the audio and video. That time
is on the 33 bit PES clock, so each cue is put on the period of that clock
nearest to the position of the media, which is read first when both are
enabled. A cue read without any media does not become that position, and
a cue still buffered when the media is enabled is placed relative to it
before it is returned.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-11-04 02:28:56 +00:00
Kacper Michajłow 039335d9bc avformat/webvttdec: add an option to apply the X-TIMESTAMP-MAP header
HLS WebVTT segments carry an X-TIMESTAMP-MAP header that maps a cue time
to an MPEG-TS time of the other renditions (RFC 8216, 3.5). With
timestamp_map set, add the offset it gives to the cue timestamps, and use
the 90 kHz MPEG-TS time base for the stream so that the mapping stays
exact. Skip the header when it comes in a block of its own instead of
ending the parsing there.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-11-04 02:28:56 +00:00
Ramiro Polla 3a3f5e24a9 avformat/webp_anim_dec: skip rereading of metadata after seek or looping
This prevents spurious warnings (even when looping) and an error when
AV_EF_EXPLODE is set.
2026-11-04 00:35:02 +00:00
Ramiro Polla 45714cee10 avformat/webp_anim_dec: fix keyframe flag when seeking
The keyframe flag was only being set when looping, and not when seeking
back.

Use ctx->first_anmf_offset to detect first keyframe instead of trying
to count cur_frame.
2026-11-04 00:35:02 +00:00
Ramiro Polla 078f7e7f48 avformat/webp_anim_dec: fix seeking by setting correct packet position
Set pkt->pos to the start of the ANMF chunk (before the header) after
av_get_packet() is called. This fixes seeking and the warning message:
 Skipping chunk: [0][0][0][0]
2026-11-04 00:35:02 +00:00
Michael Niedermayer d9b151c967 avformat/mux: do not overflow the default block_align computation
Fixes: 6nHC3ciDJMZ6
Fixes: signed integer overflow
Signed integer overflow Replicated through UnModified FFmpeg with UBSAN
Found during triage of the security report Zc8wjsgxLWvu
2026-11-03 16:12:58 +00:00
Rainbaby 0519bc5df6 avformat/cavsvideodec: use the AV_PROFILE_CAVS_* constants
Signed-off-by: Rainbaby <r@bgr.jp>
2026-11-02 22:18:06 +00:00
James Almer 38f040d12d avformat/av1dec: increase score for OBU and retry probing as long as more data can be fed
With the recent addition of the raw LCEVC demuxer, probing for OBU samples that
include a Metadata OBU with an LCEVC payload, if said payload was of
considerable size and present before a Frame Header, would result in the LCEVC
probing function returning success before OBU could even reach a point in the
bitstream where it may return a score.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-11-02 17:21:45 -03:00
Peter Ross b034eb5e7e avformat/riffdec: improved RIFX handling
When decoding RIFX files, parse decode WAVEFORMATEX header as big-endian,
and treat little-endian PCM as big-endian PCM.

Suggested-by: Kae
Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/25617
2026-11-02 07:38:20 +00:00
Peter Ross 881404bf5d avformat/aiffdec: improved handling of unaligned chunks
Use dedicated variable for signalling an unaligned chunk.  When an APPL
chunk is encountered, size is modified, so the size variable cannot be
later used as a reliable unaligned indicator.

Suggested-by: Kae
Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/25617
2026-11-02 07:35:45 +00:00
J-RAPandClaude Opus 5.5 836436cfb9 avformat/tls_openssl: also trust the Windows certificate store
The tls and dtls protocols verify the peer by default. Without ca_file,
OpenSSL only looks in the default locations configured when it was
built, which on Windows usually do not exist, so every connection fails
certificate verification unless the caller provides a CA file. The
Schannel backend uses the system store and does not have this problem.

OpenSSL 3.2 added a store loader for the Windows ROOT system store.
When no ca_file is given, register it in addition to the default
locations, unless OpenSSL was built without it. Its certificates are
looked up during verification, with the usual OpenSSL checks; trust
restrictions that Windows keeps as certificate properties are not
enforced by the loader.

OpenSSL 3.5.0 crashes in this loader (openssl/openssl#27355, fixed in
3.5.1); no workaround is added for that superseded release.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: J-RAP <srrapero720@hotmail.com>
2026-11-01 12:08:49 +00:00
James Almer 0783904188 avformat/version: bump minor version after the recent additions
Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-31 20:46:07 -03:00
James Almer af3b6af836 avformat: add a raw LCEVC muxer
Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-31 20:38:49 -03:00
James Almer ba7a998c57 avformat: add a raw LCEVC demuxer
Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-31 20:38:49 -03:00
James Almer bb6b65ca4c avformat/mpegtsenc: fix writing LCEVC_LINKAGE_DESCRIPTOR for HEVC streams
There's a check for HEVC above, and it would prevent reaching this block.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-31 20:38:49 -03:00
James Almer dce50db5d8 avformat/mpegtsenc: convert MP4 style LCEVC packets into Annex B before muxing
Use the existing lcevc_metadata filter, as it does the job without the need
for an explicit bsf for this purpose (No need to insert specific NALs at
certain intervals like h264 and others).

Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-31 20:38:49 -03:00
Kacper Michajłow ace9cc2cc9 avformat/vividas: allocate the SB entries per block
track_index() allocated entries for the largest packet count in the
index, up to INT_MAX, before any block was read. Allocate them in
load_sb_block() for the loaded block and return its errors to the
header, packet and seek callbacks, and skip a block that declares more
packets than fit in it, as each entry takes at least two bytes.

Fixes: OOM
Fixes: clusterfuzz-testcase-fuzzer_protocol_lavf-6404424499789824

Found-by: https://github.com/google/oss-fuzz/tree/master/projects/mpv
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-31 23:37:29 +00:00
Kacper Michajłow 5442733480 avformat/nsvdec: do not allocate the declared info strings size
The NSVf header declares the size of its info strings, up to 2 GiB, and
the buffer was allocated and zeroed before reading them, also when the
file is much shorter. Read them with avio_read_to_bprint(), which
allocates as the data arrives.

Fixes: OOM
Fixes: clusterfuzz-testcase-fuzzer_protocol_memory-6327893299625984
Fixes: clusterfuzz-testcase-fuzzer_protocol_edl-5153066277208064

Found-by: https://github.com/google/oss-fuzz/tree/master/projects/mpv
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-31 23:37:29 +00:00
Michael Niedermayer 4b1149c8eb avformat/mov: fix leak of the gain map parameters when the tmap payload allocation fails
The payload size is the item's extent length from the file, so the
allocation can fail for a crafted file.

Leak Replicated through UnModified FFmpeg with LSAN

Found by a grok bot based audit of the code.
2026-10-31 13:49:30 +00:00
Michael Niedermayer 00edc310fa avformat/mvrdec: drop AVFMT_GENERIC_INDEX
Seeking only needs the index entries, not the flag.

Re-read failure Replicated through UnModified FFmpeg with ASAN

Found by a grok bot based audit of the code
2026-10-31 13:49:30 +00:00
Jun Zhao 53c4520719 avformat/mpegtsenc: keep the hard of hearing subtitling type
The subtitling type written into the subtitling descriptor is taken from
the stream extradata whenever it holds a full record, five bytes per
service: composition page id, ancillary page id and subtitling type.
That record can come from an encoder, which cannot know dispositions, so
a stream for the hard of hearing would be written as a normal subtitle.

Replace a normal subtitling type (0x1x) with the matching one for the
hard of hearing (0x2x, same monitor aspect ratio criticality) when the
stream disposition says so. Only single-service records are adjusted:
the demuxer flags the whole stream as soon as one of several services is
for the hard of hearing, so rewriting a multi-service record would also
change the type of the other services.

Covered by fate-mpegts-dvbsub-hearing-impaired (single service) and
fate-mpegts-dvbsub-multi-service (several services).

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-10-31 11:00:25 +00:00
Martin Mirchev 332df18e67 avformat/mov: reject tfra boxes smaller than their header
mov_read_mfra() calls read_tfra() until it returns non-zero, and
read_tfra() ends by seeking to the box start plus its declared size.
A tfra box with size 0 therefore seeks back onto itself and is parsed
again forever. Since the whole box stays in the AVIOContext buffer, no
read reaches the protocol layer and the interrupt callback is never
checked, so the demuxer cannot be interrupted either.

The mfra is read on the first moof when use_mfra_for is enabled, which
an "Anevia" free box does by default, so a 76-byte file can make
avformat_open_input() spin indefinitely.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-30 17:20:33 +00:00
Romain Beauxis 1bfb91609d avformat/oggparsevorbis: prevent out of order or missing chained headers
Header packets of a chained stream are only buffered in identification,
comment, setup order. A misplaced packet discards the buffered set with
a warning, so a missing or misordered header no longer mixes headers
from different chains into the new extradata. A misplaced comment
header is skipped without applying its metadata.

Reserved packet types are ignored, as required by Vorbis I section
1.3.2, and leave a buffered header set intact.
2026-10-30 13:57:55 +00:00
Romain Beauxis 1347b93c27 avformat/oggparsevorbis: ignore comment headers outside a header set
255302da70 and 5a633ec2dd applied the metadata of mid-stream comment
headers for MPD streams. No MPD release sends them: since v0.15, its
encoder starts a new chain with a full header set on tag changes.

A lone comment header is invalid. It is skipped to avoid failing the
stream, but its metadata is not honoured.
2026-10-30 13:57:55 +00:00
Marvin Scholz 5385979def libavformat/flvdec: validate avio_read size on extended data
Use ffio_read_size in flv_parse_mod_ex_data to ensure that an error is returned
if the complete ex_size chunk wasn't read, instead of reading uninitialized data.

This fixes a MemorySanitizer use-of-uninitialized-value issue where a short read
would leave the buffer partially uninitialized before parsing nano_offset.

Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-10-29 21:41:02 +00:00
Marvin Scholz d42f8d8767 avformat/matroskadec: prevent duration float-cast-overflow
Reset matroska->duration to 0 if it is negative or if matroska->duration *
matroska->time_scale would exceed INT64_MAX, preventing a float-cast-overflow
when calculating the duration.

Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-10-29 21:22:06 +00:00
Kacper Michajłow 37515cfd87 avformat/subfile: clip the seek offsets to int64
Use av_clip64(), and clamp the end to the start when the start
lies past the end of the file, so the bounds do not cross and the size
is 0 rather than negative.

Fixes: e29016a9de
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-29 18:28:42 +00:00
Kacper Michajłow b615717e51 avformat/mccdec: end log messages with a newline
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-29 18:28:42 +00:00
Kacper Michajłow 72dac5d5c0 avformat/msf: compute the packet size in read_header
The packet size was derived from the codecpar channel count on every
read. For MP3, which is parsed, the channel count of the parser's codec
context is copied back to codecpar, 0 when the decoder could not be
opened, and the empty packets that followed never reached EOF, so
seek_frame_generic() looped forever.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-29 18:28:42 +00:00
Niklas Haas c49ccf40ca avformat/shared: add an offset option
This additionally fixes a prior silent corruption when a parent `offset`
option was implicitly passed down to the inner protocol, resulting in a
stream that did not start at 0, yet the inner protocol offset tracking
did not account for this.

By just always handling this option ourselves, we avoid this class of
problem.

Fixes: https://github.com/nxtedition/FFmpeg/issues/80
See-Also: https://github.com/nxtedition/casparcg/pull/103
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-10-29 12:24:38 +00:00
Kacper Michajłow be7a24041b avformat/hls: fix the EXT-X-START warning messages
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-29 02:15:48 +00:00
Kacper Michajłow def599cc17 avformat/hls: parse the EXT-X-START attributes in any order
TIME-OFFSET was only read as the first attribute of EXT-X-START, so a
tag with PRECISE first was ignored. RFC 8216 4.2 does not order the
pairs of an attribute-list. Parse it with ff_parse_key_value() as the
other attribute lists are.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-29 02:15:48 +00:00
Kacper Michajłow 9719420739 libavformat/tests: remove the hls test program
The hls-start demux tests cover the cases of the hls-parse tests
through the demuxer. There is no need for hls.c API test code.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-29 02:15:48 +00:00
Kacper Michajłow 126802b169 avformat/oggparsevorbis: reuse fixup_vorbis_headers() for chained streams
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-28 20:57:24 -05:00
yefei5 c69954c345 avformat/rmdec: reset audio deinterleave state on seek
rm_read_seek() clears rm->audio_pkt_cnt but leaves the per-stream
ast->sub_packet_cnt and ast->audiotimestamp untouched. For the
interleaved deinterleavers (GENR / INT4 / SIPR) a stale sub_packet_cnt
makes the next block complete after only (h - sub_packet_cnt) new rm
packets, so it keeps pre-seek payload in the remaining descramble slots
and loses its container timestamp.

519ebb5ee5 added rm_read_seek() for the same problem (ticket #1605) but
only reset the output counter, not the assembly progress.

Signed-off-by: yefei5 <yefei5@xiaomi.com>
2026-10-28 04:40:17 +00:00
Martin Mirchev 94110fbc39 avformat/oggparsevorbis: fix chained streams with headers over 64 KiB
When a chained Vorbis stream starts, its three header packets are
packed into new extradata with 16-bit size prefixes. A header larger
than 65535 bytes, typically a comment header with embedded cover art,
gets its size truncated, so the Vorbis parser cannot be reinitialized
and demuxing fails with "Failed to re-initialize Vorbis parser". The
audio of the new chained stream and everything after it is lost.

Use Xiph lacing instead, as vorbis_header() already does for the
initial extradata.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-28 01:57:05 +00:00
Michael Niedermayer 8b46bd6487 avformat/dashdec: clear pending segment restart when seeking
Probing a small fragment can reach EOF and set is_restart_needed before a
seek. dash_seek selects a new segment but leaves this flag set, so
read_data does not advance cur_seq_no at the next EOF. The selected
segment is then opened a second time.

Clear the pending restart along with the other segment read state before
reopening the component. Do this before probing the new segment, which
may legitimately set the flag again.

Add generated MP2 DASH tests comparing seek-to-zero and sequential packet
checksums and timestamps. The seek test emits 14 duplicate packets without
the reset; both tests produce the same 42 packets with it.

Fixes #25247

Assisted-by: Fairy
2026-10-26 18:57:05 +00:00
Zhao Zhili 246d0da2c1 avformat/img2enc: Split rawvideo planes only for fully planar formats
AV_PIX_FMT_FLAG_PLANAR does not exclude semi-planar formats such as
NV12, so they were split into .y/.U/.V files with corrupted chroma:

    ffmpeg -f lavfi -i testsrc -frames:v 1 -pix_fmt nv12 \
        -c:v rawvideo out.%03d.y

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-10-26 17:02:09 +00:00
Michael Niedermayer 46bd2205b9 avformat/r3d: seek through an index built from the RDVO offsets
Fixes: nLpmeA2sqSrC
Fixes: swarm-r3d_seek-uses-count-as-byte-offset-seeks-to-wrong-location-74db25

Found-by: zhang xingxing <2388969553@qq.com>
The report suggested seeking to the frame offsets of the RDVO atom.

Failing seek Replicated through UnModified FFmpeg with the R3D samples

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-24 20:19:14 +00:00
zhang xingxing 941598a1ef avformat/dashdec: do not seek before the first segment
Fixes: lyANsYWHaqPo
Fixes: swarm-Out-of-bounds-fragments-array-index-lacks-sign-check-38a148

Found-by: zhang xingxing <2388969553@qq.com>

Request of nonexistent segments Replicated through UnModified FFmpeg with the demuxer log

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-24 20:19:14 +00:00
James Almer 5f0a7701c1 Bump minor after branching release/9.1
Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-24 17:05:20 -03:00
James Almer aecf409c18 Bump minor version for release/9.1
Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-24 17:05:20 -03:00
Jun Zhao f5f31760f8 tests/fate: cover chapter subframe alignment and non-synchsafe v2.4 CHAP
Extend fate-id3v2chap to verify that:
- unread trailing bytes after a NUL-terminated text subframe (TPE1) are
  skipped so both TPE1 ("artist") and the following embedded subframe
  (TIT2) are parsed;
- a non-conforming v2.4 CHAP frame with a plain 32-bit size whose high
  bit is set (0x000000b6) is not truncated even when the stripped offset
  contains a fitting empty frame header;
- a valid synchsafe v2.4 CHAP frame followed by an empty TPE1 frame and
  a TALB frame preserves the subsequent frames;
- an ambiguous plain 256-byte v2.4 CHAP size (0x00000100, all high bits
  clear) rejects the 128-byte synchsafe candidate whose fake header
  exceeds the remaining tag length.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-10-24 15:15:50 +00:00