]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/oggdec.c
Merge commit '57231e4d5b467833fb289439cd35a92513bb55c1'
[ffmpeg] / libavformat / oggdec.c
index 0fce8986b12d01568c171f78250d30320cf1ffce..11645c945d6cdef46707bd96366ff3fabb6601da 100644 (file)
@@ -57,6 +57,7 @@ static const struct ogg_codec * const ogg_codecs[] = {
 };
 
 static int64_t ogg_calc_pts(AVFormatContext *s, int idx, int64_t *dts);
+static int ogg_read_close(AVFormatContext *s);
 
 //FIXME We could avoid some structure duplication
 static int ogg_save(AVFormatContext *s)
@@ -173,6 +174,7 @@ static int ogg_replace_stream(AVFormatContext *s, uint32_t serial)
     struct ogg_stream *os;
     unsigned bufsize;
     uint8_t *buf;
+    struct ogg_codec *codec;
 
     if (ogg->nstreams != 1) {
         av_log_missing_feature(s, "Changing stream parameters in multistream ogg", 0);
@@ -183,6 +185,7 @@ static int ogg_replace_stream(AVFormatContext *s, uint32_t serial)
 
     buf = os->buf;
     bufsize = os->bufsize;
+    codec   = os->codec;
 
     if (!ogg->state || ogg->state->streams[0].private != os->private)
         av_freep(&ogg->streams[0].private);
@@ -194,6 +197,7 @@ static int ogg_replace_stream(AVFormatContext *s, uint32_t serial)
     os->bufsize = bufsize;
     os->buf = buf;
     os->header = -1;
+    os->codec = codec;
 
     return 0;
 }
@@ -596,8 +600,10 @@ static int ogg_read_header(AVFormatContext *s)
     //linear headers seek from start
     do {
         ret = ogg_packet(s, NULL, NULL, NULL, NULL);
-        if (ret < 0)
+        if (ret < 0) {
+            ogg_read_close(s);
             return ret;
+        }
     } while (!ogg->headers);
     av_dlog(s, "found headers\n");