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.
Mux the chapters of vorbis_chapter_extension_demo.ogg with generated audio and B-frame video into a fragmented MP4, then seek to 8 s with use_mfra_for=pts and read 40 packets across one fragment boundary.
The reference records the current behaviour, where the read starts at 2 s without audio because the chapter track's seek leaves the fragment index on the first fragment.
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>
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>
Audio from 10 s with WebVTT segments mapping cue time 0 to 10 s, a cue
that spans three segments and a seek into the second segment.
Note tests are ugly with printf generation, but this is the only way to
get full HLS test to work, it's not a single file that we could upload
to fate samples server.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Only 0xFF was tested, while the decoders use masks up to 0xFFFF
(HuffYUV up to 16 bits, UtVideo 10 bits, MagicYUV 10 to 14 bits).
Test the masks for all bit depths from 8 to 16.
Signed-off-by: Gyula Sebok <gyula.sbk@gmail.com>
1 + rnd() % 16*128 is parsed as 1 + (rnd() % 16) * 128, which only
gives 16 different widths, all of them 1 modulo 128. Use 1..2048, as
intended in 78193e6490.
Signed-off-by: Gyula Sebok <gyula.sbk@gmail.com>
Exercise empty input and short streams around the decode delay without requiring hardware. Print results for FATE comparison, including the EOF state and timestamp difference.
Assisted-by: Fairy
Encode a 16-bit gray image with the jpegls encoder, set the ILV byte of
the SOS header to 1 and check that it decodes to the source picture.
Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
cavs/avsplus-1080i-testcard.ts is five pictures (I P B P B) of a 1080i
broadcast test card, captured off air from a Beijing DTMB multiplex on
2021-09-23. It carries no program content, only a zone plate, frequency
bursts and channel idents.
The five pictures cover AEC intra and inter decoding, field coded
pictures, two enhanced field coded B pictures and 15 annex A pseudo
start codes. No existing FATE sample reaches any of these paths:
fate-cavs and fate-cavs-bunny are both JiZhun and progressive.
Signed-off-by: Rainbaby <r@bgr.jp>
The horizontal pass of the two dimensional quarter sample interpolation
reaches (96 + 42) * 255 = 35190 in the ii and kk positions and overflows
the int16_t intermediate. The other four positions use the half sample
filter, stay within -510..2550 and keep int16_t. Only the C path is
affected; the x86 SIMD covers just the one dimensional positions.
Signed-off-by: Rainbaby <r@bgr.jp>
cavs/bunny.mp4 is already in the FATE suite for fate-cavs-demux, and it
reaches decoding paths the existing fate-cavs sample does not.
Signed-off-by: Rainbaby <r@bgr.jp>
The test wrote two transport streams to tests/data/fate only to probe
the second. Pipe the remuxes into ffprobe instead.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
ffmpeg opens the input - with the fd protocol, which the test does not
depend on. Read pipe:, which it does.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
The header test wrote two KTX files only to read a few header fields,
the reject test wrote a file it expects to fail. Pipe the header test's
output into od, which dumps the fields from glInternalFormat to the
mipmap level count, and send the reject test's output to stdout.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
The GEN rule wrote the 24 zero bytes to a file that only this test
read. Pipe them straight into the decode instead.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
The GEN rule wrote the 21 bytes to a file that only this test read.
Print them straight into ffmpeg instead.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
The metadata test wrote its matroska files to tests/data/fate and
deleted them by hand, the override test went through run_with_temp.
Pipe the encode, the remux and the probe instead.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
The sample rate tests wrote each description to a file only to probe
it. Pipe it into ffprobe instead, with -f sdp, as the format was found
by the file extension before.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Both GEN rules wrote an ac3 file that only one test decoded. Pipe the
encode straight into the decode instead.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Each GEN rule wrote an adts file that only one probe test read. Pipe
the encode straight into the probe instead.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
A pipeline returns the status of its last command, so a test piping
ffmpeg into ffprobe or framecrc passed when ffmpeg failed after writing
its output, for example on a leak reported by LeakSanitizer. Enable
pipefail where the shell supports it.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Each page range was cut by dd from a data remux of the sample, and dd
stops reading before ffmpeg has written all of it. Read the ranges
from the sample directly, the test then needs only ffprobe.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Adds a new dsp function to compute a constants buffer in the form most
suitable to the specific implementation. This gets called once per
tile component to prepare the constants buffer, and then the transquant
functions get a pointer to that buffer to use.
CPU: Intel(R) Xeon(R) Gold 6252 CPU @ 2.10GHz
Before:
decode_transquant_10_c: 333.2
decode_transquant_10_avx2: 65.5 ( 5.09x)
After:
decode_transquant_10_c: 330.9
decode_transquant_10_avx2: 57.3 ( 5.78x)
No significant difference on ARM Cortex-A53/A73.
Test all bit depths, using random QP, qmatrix, and coefficients.
This makes the coefficients by sending a random residual through a
forward transform and quantisation in order to keep all of the
arithmetic within the encoder range. One coefficient is sometimes set
to a large value to exercise the dequantisation clipping, which is
otherwise never hit here.
Benchmarking continues to use a dense block similar to the old test to
ensure that results are comparable and represent the worst case.
set_string_number() parses the operand of a "+x" or "-x" flags update as
a double and casts it to int64_t to OR it into, or mask it out of, the
current flags. Only the combined value then reaches the range check in
write_number(), so the operand itself was never validated:
- A value outside the int64_t range, or inf, makes the conversion
undefined behaviour (C17 6.3.1.4). UBSan reports it for
av_opt_set(ctx, "flags", "+77777777777777777777", 0), and what the
cast produces depends on the target: measured on AArch64, where it
saturates, "+1e20" happened to be rejected downstream while "-1e20"
was accepted.
- A fractional operand is silently truncated, so "+1.5" and "-1.5" are
accepted although "1.5" is refused as not being a valid set of flags.
Run the existing flags range check on the operand before the cast, so an
invalid operand returns AVERROR(ERANGE) exactly like an invalid absolute
value, as av_opt_set() documents, and add the four cases to fate-opt.
Reported by FuzzAnything-ORG with a UBSan trace.
Fixes#22389
The DVB subtitles written by this encoder always use page 1 as
composition and ancillary page id, but the encoder never told the muxers
about it: it never set any extradata.
Muxers need it. The Matroska CodecPrivate of an S_DVBSUB track is
mandatory and holds the composition page id, the ancillary page id and
the subtitling type, five bytes in that order; MPEG-TS reorders these
fields into its subtitling descriptor, which carries the language and
the type before the page ids, and the decoder only reads the page ids.
A file without them is invalid, and players that require them (VLC
refuses to create such a track and then filters the segments by page id)
show no subtitles at all, while players that do not, like mpv, are
unaffected.
Set the five bytes in the encoder so that every container gets them,
including MPEG-TS, which previously filled in the page ids with the same
hardcoded default. The encoded packets are unchanged; only the
fate-sub-dvb reference gains the extradata line of the output stream.
Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/25610
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
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>
Convert the last MMX (mmxext) qpel functions, all 4-wide
8-bit and 10-bit paths, to SSE2, following the 8x8_l2
conversion: new symbols carry the sse2 suffix and dispatch
moves from EXTERNAL_MMXEXT to EXTERNAL_SSE2.
checkasm h264qpel passes. almost identical performance in most
converted functions except for small regression caused by replacing
MMX's memory operand with movq and reg-reg op.
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.
Splice pages of moog_small.ogg into a stream with comment and setup
headers without identification header, then an identification header
followed by audio.
The reference records the current output: the metadata of misplaced
comment headers is applied, and headers from different places are
packed into new extradata.
Patch the first quantizer of the first frame of a remuxed existing
sample that uses three quantizers per frame, and decode it with four
frame threads.
Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
Print intermediate chroma results for both range directions at
8/9/10/12/14/16 bits, including neutral and nearby values. Test both
planes with the C and available native implementations, and keep
expected values in tests/ref/fate/sws-range-convert.
Based on the test implementation from Forgejo_Fairy in PR #25549.
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
Include the neutral chroma center in the inputs compared between the C
and optimized range-conversion implementations at every tested depth.
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
solve_range_convert() anchored the range conversion offset at the upper
endpoint (src_max -> dst_max). For chroma, mapping the limited-range
interval [16, 240] to the full-range interval [0, 255] via the upper
endpoint shifts the neutral chroma center (128 << (bit_depth - 8)) to
127.5 in 8-bit units.
After 4bee010844 added the fixed-point rounding bias, that -0.5 LSB
shift canceled out the final output rounding bias for colored chroma,
leaving a systematic -0.5 LSB truncation bias in full-range chroma and
causing neutral gray to still round down to 127 on the x86 4:2:0 vertical
filter path.
Per ITU-T H.273 Section 8.3, the achromatic chroma center is
128 << (bit_depth - 8) in both limited and full range. Anchor the chroma
range conversion offset at the neutral chroma center while keeping the
luma offset anchored at the upper endpoint.
Based on the root-cause analysis and patch from Forgejo_Fairy and alec
in issues #24005 and #25521.
Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/24005
Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/25521
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
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>
hls-start-master.m3u8 has an EXT-X-START before its EXT-X-MEDIA and
EXT-X-STREAM-INF tags. Its variant hls-start-media.m3u8 has one of its
own and its audio rendition none. Both are live playlists of four
0.144 s segments. hls-start-variant.m3u8 is the same Master Playlist
without EXT-X-START. hls-start-endlist.m3u8 has an EXT-X-ENDLIST
between its EXT-X-START and its first segment.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
The graph closes its three looped inputs by letting trim return EOF
while the main input is still active. On the unfixed code this
deadlocks the CLI with a significant probability, so the test then
only finishes by timeout; with the fix it passes deterministically.
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
The test read its two parts through a concat: URL built from
target_path, which is not portable and doesn't work with Windows pathes,
at least not with enough escaping sprinkled on top. Pipe both parts
straight into the framecrc run and pass the comment to -/metadata
through a pipe, so the test writes no files.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>