PR #24406 opened by Forgejo_Fairy URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24406 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24406.patch
MTV headers with nonzero audio_subsegments can still produce a zero video frame rate through integer truncation. Passing that value to avpriv_set_pts_info() emits an invalid-timebase warning and leaves the default video timebase in place; with a 512-byte header, opening the input can succeed. Reject a zero computed frame rate with AVERROR_INVALIDDATA before creating streams. Positive frame rates and the existing handling of zero audio_subsegments are unchanged. Fixes #23451. Validation on arm64 against master 5e95a3ddfbdb: - Reproduced the warning with the issue attachment and a corrected version with img_segment_size at offset 56 and audio_subsegments at offset 62, including headers padded to 512 bytes. - Compared 13 cases before and after the patch. Zero-rate inputs now return AVERROR_INVALIDDATA; positive-rate inputs retain their timebases; zero audio_subsegments retains its existing error. - Tested (audio_br, audio_subsegments) pairs: (0,1), (1,1), (3,1), (4,1), (7,2), (8,2), (65535,16384), (65535,1), (128,2), and (4,0). - Passed make fate-mtv SAMPLES=/opt/fate-suite and git diff --check. Source inspection also finds the unchecked calculation on release/9.0, release/8.1, release/8.0, release/7.1, release/6.1, release/5.1, and release/4.4. >From a3a40ed6172b07d8c06e0bb28da8e246ed8cae3d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Mon, 7 Sep 2026 01:42:07 +0000 Subject: [PATCH] avformat/mtv: reject a zero video frame rate The integer frame-rate calculation can produce zero even when audio_subsegments is nonzero. Reject such headers before creating streams instead of passing a zero denominator to avpriv_set_pts_info() and retaining the default video time base. Fixes #23451. Assisted-by: Fairy --- libavformat/mtv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/mtv.c b/libavformat/mtv.c index c888443b7a..c28e793286 100644 --- a/libavformat/mtv.c +++ b/libavformat/mtv.c @@ -156,7 +156,10 @@ static int mtv_read_header(AVFormatContext *s) mtv->img_segment_size; mtv->video_fps = (mtv->audio_br / 4) / audio_subsegments; - // FIXME Add sanity check here + if (!mtv->video_fps) { + av_log(s, AV_LOG_ERROR, "Invalid video frame rate\n"); + return AVERROR_INVALIDDATA; + } // all systems go! init decoders -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
