[FFmpeg-cvslog] avformat: close parser if codec changed
Andreas Cadhalpun
git at videolan.org
Fri Nov 18 01:08:38 EET 2016
ffmpeg | branch: release/3.2 | Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com> | Mon Oct 17 20:26:51 2016 +0200| [dc2942bbc889c18dd23acd2202ffb2520fac697a] | committer: Andreas Cadhalpun
avformat: close parser if codec changed
The parser depends on the codec and thus must not be used with a different one.
If it is, the 'avctx->codec_id == s->parser->codec_ids[0] ...' assert in
av_parser_parse2 gets triggered.
Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
(cherry picked from commit f84ae3f04aa074afeaeafe6b478d603ce46df55e)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dc2942bbc889c18dd23acd2202ffb2520fac697a
---
libavformat/utils.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 31572f3..5664646 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -480,6 +480,12 @@ static int update_stream_avctx(AVFormatContext *s)
if (!st->internal->need_context_update)
continue;
+ /* close parser, because it depends on the codec */
+ if (st->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
+ av_parser_close(st->parser);
+ st->parser = NULL;
+ }
+
/* update internal codec context, for the parser */
ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar);
if (ret < 0)
@@ -1515,6 +1521,12 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
st->info->found_decoder = 0;
}
+ /* close parser, because it depends on the codec */
+ if (st->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
+ av_parser_close(st->parser);
+ st->parser = NULL;
+ }
+
ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar);
if (ret < 0)
return ret;
More information about the ffmpeg-cvslog
mailing list