PR #25559 opened by Kacper Michajłow (kasper93) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25559 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25559.patch
From 7ecab5e2f1cc418c9c1d2f593e999acf8041c33d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]> Date: Wed, 28 Oct 2026 06:01:51 +0100 Subject: [PATCH 1/3] avformat/msf: compute the packet size in read_header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 <[email protected]> --- libavformat/msf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/msf.c b/libavformat/msf.c index 37e05b538bd..3a25ede752c 100644 --- a/libavformat/msf.c +++ b/libavformat/msf.c @@ -24,6 +24,10 @@ #include "demux.h" #include "internal.h" +typedef struct MSFDemuxContext { + int packet_size; +} MSFDemuxContext; + static int msf_probe(const AVProbeData *p) { if (memcmp(p->buf, "MSF", 3)) @@ -43,6 +47,7 @@ static int msf_probe(const AVProbeData *p) static int msf_read_header(AVFormatContext *s) { + MSFDemuxContext *msf = s->priv_data; unsigned codec, size; AVStream *st; int ret; @@ -90,6 +95,8 @@ static int msf_read_header(AVFormatContext *s) avpriv_request_sample(s, "Codec %d", codec); return AVERROR_PATCHWELCOME; } + msf->packet_size = st->codecpar->block_align ? st->codecpar->block_align + : 1024 * st->codecpar->ch_layout.nb_channels; st->duration = av_get_audio_frame_duration2(st->codecpar, size); avio_skip(s->pb, 0x40 - avio_tell(s->pb)); avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); @@ -99,15 +106,16 @@ static int msf_read_header(AVFormatContext *s) static int msf_read_packet(AVFormatContext *s, AVPacket *pkt) { - AVCodecParameters *par = s->streams[0]->codecpar; + MSFDemuxContext *msf = s->priv_data; - return av_get_packet(s->pb, pkt, par->block_align ? par->block_align : 1024 * par->ch_layout.nb_channels); + return av_get_packet(s->pb, pkt, msf->packet_size); } const FFInputFormat ff_msf_demuxer = { .p.name = "msf", .p.long_name = NULL_IF_CONFIG_SMALL("Sony PS3 MSF"), .p.extensions = "msf", + .priv_data_size = sizeof(MSFDemuxContext), .read_probe = msf_probe, .read_header = msf_read_header, .read_packet = msf_read_packet, -- 2.54.0 From dd7857378c6568058d1656f40746d49a258a45f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]> Date: Wed, 28 Oct 2026 06:01:51 +0100 Subject: [PATCH 2/3] avformat/mccdec: end log messages with a newline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kacper Michajłow <[email protected]> --- libavformat/mccdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/mccdec.c b/libavformat/mccdec.c index 9d72e5545e0..9674e871838 100644 --- a/libavformat/mccdec.c +++ b/libavformat/mccdec.c @@ -186,7 +186,7 @@ static int parse_time_code_rate(AVFormatContext *s, AVStream *st, TimeTracker *t return time_tracker_init(tt, st, valid_time_code_rates[i].rate, s); } } - av_log(s, AV_LOG_FATAL, "invalid mcc time code rate: %s", time_code_rate); + av_log(s, AV_LOG_FATAL, "invalid mcc time code rate: %s\n", time_code_rate); return AVERROR_INVALIDDATA; } @@ -292,7 +292,7 @@ static int mcc_read_header(AVFormatContext *s) MCCTimecode tc; ret = mcc_parse_time_code(&line_left, &tc); if (ret < 0) { - av_log(s, AV_LOG_ERROR, "can't parse mcc time code"); + av_log(s, AV_LOG_ERROR, "can't parse mcc time code\n"); continue; } -- 2.54.0 From cedfa24ae701c2353bed501e47e569adfbcf70d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]> Date: Wed, 28 Oct 2026 06:13:47 +0100 Subject: [PATCH 3/3] avformat/subfile: clip the seek offsets to int64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 <[email protected]> --- libavformat/subfile.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavformat/subfile.c b/libavformat/subfile.c index a77e477db2e..dc4fe244424 100644 --- a/libavformat/subfile.c +++ b/libavformat/subfile.c @@ -123,18 +123,19 @@ static int64_t subfile_seek(URLContext *h, int64_t pos, int whence) end = c->end; if (end == INT64_MAX && (end = ffurl_seek(c->h, 0, AVSEEK_SIZE)) < 0) return end; + end = FFMAX(end, c->start); switch (whence) { case AVSEEK_SIZE: return end - c->start; case SEEK_SET: - new_pos = c->start + av_clip(pos, 0, end - c->start); + new_pos = c->start + av_clip64(pos, 0, end - c->start); break; case SEEK_CUR: - new_pos = c->pos + av_clip(pos, -(c->pos - c->start), end - c->pos); + new_pos = c->pos + av_clip64(pos, -(c->pos - c->start), end - c->pos); break; case SEEK_END: - new_pos = end + av_clip(pos, -(end - c->start), 0); + new_pos = end + av_clip64(pos, -(end - c->start), 0); break; default: av_assert0(0); -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
