PR #24401 opened by Forgejo_Fairy URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24401 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24401.patch
Seeking into ordinary AVC in MXF can initialize the decoder with synthetic AVC-Intra SPS/PPS instead of the stream's actual parameter sets. In #22467, seeking to 34.06 seconds starts at a non-IDR I picture without SPS/PPS and produces decoding errors because the generated PPS selects CAVLC while the stream uses CABAC. Restrict `ff_generate_avci_extradata()` to streams identified by the existing intra-only classification. This allows probing to extract the actual in-band headers for long GOP AVC. Add a FATE probe test checking extradata size and MD5 using the existing XAVC sample; no new sample is required. Validation on Linux/aarch64: - All 2,297 decoded frames from the reported seek time through EOF match decoding from the start, with no errors. - All 48 frames in the reported problematic interval match separately. - Seeking the stream-copy remux succeeds. - All 17 tests selected by `make -j8 fate-mxf fate-h264-xavc-4389 SAMPLES=/opt/fate-suite` pass. - Removing the fix makes the new FATE test fail and restores the reported decoding errors. Fixes #22467. >From c390e967b2282e3382eb5765c93d3b290301941f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sun, 6 Sep 2026 22:11:52 +0000 Subject: [PATCH] avformat/mxfdec: restrict AVC-Intra extradata to intra-only streams Generating AVC-Intra parameter sets for ordinary AVC streams leaves codecpar with extradata unrelated to the in-band SPS/PPS. Seeking to a non-IDR I picture without parameter sets then initializes the decoder with the wrong headers, even when the stream has constant parameter sets. Use the existing intra-only classification to restrict this fallback, allowing stream probing to extract the actual headers for long GOP AVC. Add a probe test using the existing XAVC sample to check the extradata size and hash. It fails with the generated AVC-Intra headers. Fixes: #22467 Assisted-by: Fairy --- libavformat/mxfdec.c | 2 +- tests/fate/mxf.mak | 5 +++++ tests/ref/fate/mxf-probe-h264-extradata | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/ref/fate/mxf-probe-h264-extradata diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4ba4af1fa7..280a20aad3 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -3129,7 +3129,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) if (!ff_alloc_extradata(st->codecpar, descriptor->extradata_size)) { memcpy(st->codecpar->extradata, descriptor->extradata, descriptor->extradata_size); } - } else if (st->codecpar->codec_id == AV_CODEC_ID_H264) { + } else if (st->codecpar->codec_id == AV_CODEC_ID_H264 && source_track->intra_only) { int coded_width = mxf_get_codec_ul(mxf_intra_only_picture_coded_width, &descriptor->essence_codec_ul)->id; if (coded_width) diff --git a/tests/fate/mxf.mak b/tests/fate/mxf.mak index ba09d136ce..10c310dd34 100644 --- a/tests/fate/mxf.mak +++ b/tests/fate/mxf.mak @@ -23,6 +23,11 @@ FATE_MXF_PROBE-$(call DEMDEC, MXF, MPEG2VIDEO PCM_S16LE, MPEGVIDEO_PARSER EXTRAC fate-mxf-probe-d10: SRC = $(TARGET_SAMPLES)/mxf/Sony-00001.mxf fate-mxf-probe-d10: CMD = run $(PROBE_FORMAT_STREAMS_COMMAND) -i "$(SRC)" +# Long GOP AVC must retain its in-band parameter sets, not AVC-Intra defaults. +FATE_MXF_PROBE-$(call DEMDEC, MXF, H264, H264_PARSER EXTRACT_EXTRADATA_BSF) += fate-mxf-probe-h264-extradata +fate-mxf-probe-h264-extradata: SRC = $(TARGET_SAMPLES)/h264/SonyXAVC_LongGOP_green_pixelation_early_Frames.MXF +fate-mxf-probe-h264-extradata: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -bitexact -v 0 -select_streams v -show_entries stream=extradata,extradata_size,extradata_hash -show_data_hash md5 -i "$(SRC)" + FATE_MXF_PROBE-$(call DEMDEC, MXF, DNXHD) += fate-mxf-probe-dnxhd fate-mxf-probe-dnxhd: SRC = $(TARGET_SAMPLES)/mxf/multiple_components.mxf fate-mxf-probe-dnxhd: CMD = run $(PROBE_FORMAT_STREAMS_COMMAND) -i "$(SRC)" diff --git a/tests/ref/fate/mxf-probe-h264-extradata b/tests/ref/fate/mxf-probe-h264-extradata new file mode 100644 index 0000000000..482bca0ce5 --- /dev/null +++ b/tests/ref/fate/mxf-probe-h264-extradata @@ -0,0 +1,4 @@ +[STREAM] +extradata_size=254 +extradata_hash=MD5:0a4fe18be973294d0433253d1e8548bc +[/STREAM] -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
