From 13bffa79698e8bfe08634a1aefa9650dc74a58a2 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 23 Dec 2019 22:39:46 +0100 Subject: [PATCH] avformat/sccdec: fix sub->pos values --- libavformat/sccdec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/sccdec.c b/libavformat/sccdec.c index 37570e0fb0..0cf09c458a 100644 --- a/libavformat/sccdec.c +++ b/libavformat/sccdec.c @@ -78,13 +78,14 @@ static int scc_read_header(AVFormatContext *s) st->codecpar->codec_id = AV_CODEC_ID_EIA_608; while (!ff_text_eof(&tr)) { - const int64_t pos = ff_text_pos(&tr); + int64_t current_pos, next_pos; char *saveptr = NULL, *lline; int hh1, mm1, ss1, fs1, i; int hh2, mm2, ss2, fs2; AVPacket *sub; if (count == 0) { + current_pos = ff_text_pos(&tr); while (!ff_text_eof(&tr)) { len = ff_subtitles_read_line(&tr, line, sizeof(line)); if (len > 13) @@ -99,6 +100,7 @@ static int scc_read_header(AVFormatContext *s) ts_start = (hh1 * 3600LL + mm1 * 60LL + ss1) * 1000LL + fs1 * 33; + next_pos = ff_text_pos(&tr); while (!ff_text_eof(&tr)) { len2 = ff_subtitles_read_line(&tr, line2, sizeof(line2)); if (len2 > 13) @@ -135,10 +137,11 @@ try_again: if (!sub) return AVERROR(ENOMEM); - sub->pos = pos; + sub->pos = current_pos; sub->pts = ts_start; sub->duration = FFMAX(1200, ts_end - ts_start); memmove(line, line2, sizeof(line)); + current_pos = next_pos; line2[0] = 0; }