]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/oggparseogm.c
avformat/mpegtsenc: move is_dvb_subtitle/is_dvb_teletext initialization upwards
[ffmpeg] / libavformat / oggparseogm.c
index ca6b62669d5a5182ed2566cfbe445b8078deef60..469b22999536c150c7a25f2faae4ec8203328bc4 100644 (file)
@@ -43,6 +43,7 @@ ogm_header(AVFormatContext *s, int idx)
     uint64_t time_unit;
     uint64_t spu;
     uint32_t size;
+    int ret;
 
     bytestream2_init(&p, os->buf + os->pstart, os->psize);
     if (!(bytestream2_peek_byte(&p) & 1))
@@ -108,12 +109,14 @@ ogm_header(AVFormatContext *s, int idx)
                 size -= 52;
                 if (bytestream2_get_bytes_left(&p) < size)
                     return AVERROR_INVALIDDATA;
-                av_freep(&st->codecpar->extradata);
-                if (ff_alloc_extradata(st->codecpar, size) < 0)
-                    return AVERROR(ENOMEM);
+                if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
+                    return ret;
                 bytestream2_get_buffer(&p, st->codecpar->extradata, st->codecpar->extradata_size);
             }
         }
+
+        // Update internal avctx with changes to codecpar above.
+        st->internal->need_context_update = 1;
     } else if (bytestream2_peek_byte(&p) == 3) {
         bytestream2_skip(&p, 7);
         if (bytestream2_get_bytes_left(&p) > 1)
@@ -176,11 +179,14 @@ ogm_packet(AVFormatContext *s, int idx)
         os->pflags |= AV_PKT_FLAG_KEY;
 
     lb = ((*p & 2) << 1) | ((*p >> 6) & 3);
+    if (os->psize < lb + 1)
+        return AVERROR_INVALIDDATA;
+
     os->pstart += lb + 1;
     os->psize -= lb + 1;
 
     while (lb--)
-        os->pduration += p[lb+1] << (lb*8);
+        os->pduration += (uint64_t)p[lb+1] << (lb*8);
 
     return 0;
 }