From 173f19be75a98fbfcf58a7e99871058232dc9dc2 Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Fri, 4 Feb 2011 12:04:15 +0200 Subject: libavformat: Use avcodec_copy_context for chained muxers This avoids having the chained AVStream->codec point to the same AVCodecContext owned by the outer AVStream. The downside is that changes to the AVCodecContext made after calling av_write_header cannot be detected automatically within the chained muxer. This avoids having to manually unlink the chained AVStream->codec by setting it to null before freeing the chained muxer via generic freeing functions. Signed-off-by: Ronald S. Bultje (cherry picked from commit 1338dc082354b87c0e26f7f2ab09df5964b7f993) --- libavformat/rtpenc_chain.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'libavformat/rtpenc_chain.c') diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c index 19ea98f643..09b4ebd7c3 100644 --- a/libavformat/rtpenc_chain.c +++ b/libavformat/rtpenc_chain.c @@ -50,11 +50,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, /* Set the synchronized start time. */ rtpctx->start_time_realtime = s->start_time_realtime; - /* Remove the local codec, link to the original codec - * context instead, to give the rtp muxer access to - * codec parameters. */ - av_free(rtpctx->streams[0]->codec); - rtpctx->streams[0]->codec = st->codec; + avcodec_copy_context(rtpctx->streams[0]->codec, st->codec); if (handle) { url_fdopen(&rtpctx->pb, handle); @@ -70,6 +66,8 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, url_close_dyn_buf(rtpctx->pb, &ptr); av_free(ptr); } + av_free(rtpctx->streams[0]->codec->extradata); + av_free(rtpctx->streams[0]->codec); av_free(rtpctx->streams[0]->info); av_free(rtpctx->streams[0]); av_free(rtpctx); -- cgit v1.2.3