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>
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.
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.
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>
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>
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>
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>
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>
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.
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]
Fixes: 6nHC3ciDJMZ6
Fixes: signed integer overflow
Signed integer overflow Replicated through UnModified FFmpeg with UBSAN
Found during triage of the security report Zc8wjsgxLWvu
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>
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
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>
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>
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>
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>
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.
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
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>
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>
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.
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
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>
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>
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>
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>