12 Commits
Author SHA1 Message Date
Martin Mirchev 0718c6e195 fate/ogg-vorbis: add a test for a chained stream with a large comment
Remux two short streams from an existing sample, the second one with a
70000-byte comment header, and demux their concatenation.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-28 01:57:05 +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
Martin Mirchev ab0eeb03cc tests/fate/filter-video: add tests for vignette backward mode
Use angle 0, so the gain is exactly 1 inside dmax, and move the center
to the top left corner so that part of the frame lies beyond dmax and
must saturate. Cover the planar (yuv444p) and packed (rgb24) paths.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-26 22:36:19 +00:00
Martin Mirchev a7241b6a77 avfilter/vf_vignette: keep the backward gain finite
In backward mode the gain is 1 / factor, but the factor is 0 for pixels
farther than dmax from the center (possible with x0/y0 or aspect), so
the gain is inf. inf * sample, or inf * 0 = NaN, is then converted to
int, which is undefined behaviour; on x86 these pixels come out black
instead of saturated.

For angles close to PI/2, the factor can also become small enough that
a finite backward gain produces sample values outside the range of int
before av_clip_uint8() is called. Bound the gain at 256 to keep these
conversions in range while preserving the saturated 8-bit output.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-26 22:36:19 +00:00
Martin Mirchev 4bef4614fe tests/fate/mov: add a test for IAMF stream group id collisions
Mux two IAMF audio elements with ids 1 and 2 and a mix presentation with
id 1 into mp4, then demux and probe the result. Without the previous
commit the mov demuxer aborts on an assertion when reading this file.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-21 16:32:08 +00:00
Martin Mirchev 6dba2558c0 avformat/mov: check the stream group type when updating IAMF streams
The lookup of the stream group for each IAMF audio element compared only
the group id and kept the last match. Mix presentation groups are created
after the audio element groups and use the mix_presentation_id as their
id, so if a mix_presentation_id equals an audio_element_id the mix
presentation group was picked instead. Its entries are the streams of
every audio element, so the same output stream got its index entries
filled twice and the av_assert0(!out_sti->index_entries) aborted.

Such files are written by FFmpeg's own mp4 muxer, e.g. with two audio
elements with ids 1 and 2 and a mix presentation with id 1.

Also check the group type. Keep using the last match: audio element ids
are only unique within one IAMF track, and the groups of the current
track were just appended, so the last match is the audio element of the
current track even if an earlier track uses the same id.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-21 16:32:08 +00:00
Martin Mirchev ca85613d10 tests/fate/libavutil: add a test for the IAMF AVClass hierarchy
Print the child class tree of the IAMF AVClasses as returned by
av_opt_child_class_iterate() and look up options of the child classes
with av_opt_find2() and AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-21 14:56:54 +00:00
Martin Mirchev 54502377c6 avutil/iamf: fix child_class_iterate callbacks
The child_class_iterate callbacks of AVIAMFAudioElement,
AVIAMFSubmixElement and AVIAMFMixPresentation returned their single
child class only for a non-zero iteration state. The state starts at
zero, so they never returned anything, and av_opt_child_class_iterate()
and av_opt_find2() with AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ
could not reach the AVIAMFLayer, AVIAMFParamDefinition and AVIAMFSubmix
options from these classes.

Return the child class on the first call instead.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-21 14:56:54 +00:00
Martin Mirchev 510dbddd52 avcodec/h264_parse: return SPS/PPS errors from avcC with explode
decode_extradata_ps_mp4() skips the retry with an escaped NAL when
AV_EF_EXPLODE is set, but then returns 0 regardless, so a parameter set
that fails to parse in avcC extradata is silently ignored exactly when
the caller asked for errors to be fatal. h264_decode_init() fails on
extradata errors only with explode, so avcodec_open2() succeeded with
-err_detect explode on avcC extradata with a broken SPS, and the
"Decoding sps %d from avcC failed" path was unreachable.

Return the error when explode is set.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-21 14:52:52 +00:00
Martin Mirchev 5993347a1b avformat/flvenc: reject text packets too long for an AMF0 string
AV_CODEC_ID_TEXT packets are written as an AMF0 string, whose length is a
16-bit field. For text over 65535 bytes the length wrapped (e.g. 4464 for
70000 bytes) while the whole text was written, so readers misparse the
onTextData tag.

Fail on such packets before writing the tag.
Found while reviewing the metadata length fix for FLV.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-19 19:33:13 +00:00
Martin Mirchev beb7168452 swscale/output: write the last partial byte in the mono error-diffusion paths
The SWS_DITHER_ED branches of yuv2mono_1_c_template() and
yuv2mono_2_c_template() only store a byte when (i & 7) == 6, so for widths
whose last pixel pair does not end a byte the final partial byte of each
row is never written and keeps whatever the destination held. Converting a
white 100x8 frame with -sws_flags +error_diffusion -pix_fmt monob leaves the
last 4 pixels of rows 1-7 black (0x00 instead of 0xf0).

Write the pending bits after the loop, shifted into the high bits as monob
expects, like the non-ED paths.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-19 00:51:53 +00:00
Martin Mirchev 6076399974 avfilter/vf_colormap: fix single-patch coefficient index
With one patch, the per-channel gains were written to transposed
coefficient indices. Subsequent channel initialization cleared the first
two misplaced gains, while the third was stored in an unused column,
leaving the identity transform in place: mapping 0xA06040 to 0x503020
turned 0xA06040 into (160,97,63) instead of (80,48,32).

Store each gain at icoeff[1+c][c], matching the pixel loop and the
two-patch case.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-18 19:07:29 +00:00