]> git.sesse.net Git - ffmpeg/commitdiff
avformat/sccdec: fix sub->pos values
authorPaul B Mahol <onemda@gmail.com>
Mon, 23 Dec 2019 21:39:46 +0000 (22:39 +0100)
committerPaul B Mahol <onemda@gmail.com>
Mon, 23 Dec 2019 21:39:46 +0000 (22:39 +0100)
libavformat/sccdec.c

index 37570e0fb0ea4c5391bd9fae96bcd1d1232b0c15..0cf09c458a2e409ca30387f6b208b630f562ec28 100644 (file)
@@ -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;
     }