avformat/utils: update deprecated AVStream->codec when the context is updated
authorHendrik Leppkes <h.leppkes@gmail.com>
Thu, 30 Jun 2016 12:10:42 +0000 (14:10 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 30 Jun 2016 15:43:01 +0000 (17:43 +0200)
This ensures the AVStream->codec entry is kept in sync when new streams are
discovered mid-playback or changes to the context occur from other sources.

Fixes trac 5678.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/utils.c

index 6f343f2..d2a709c 100644 (file)
@@ -1483,6 +1483,15 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
             if (ret < 0)
                 return ret;
 
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+            /* update deprecated public codec context */
+            ret = avcodec_parameters_to_context(st->codec, st->codecpar);
+            if (ret < 0)
+                return ret;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
             st->internal->need_context_update = 0;
         }