diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-01-28 19:15:15 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-01-31 16:53:35 +0100 |
commit | bc901998487bf9b77a423961d9f961bcc28a9291 (patch) | |
tree | 10fc23398897ab2e4294e11d3af307d091b3beeb /libavformat | |
parent | 0e72ad95f9fef6a6b8ae55e47339a5c40526502f (diff) | |
download | ffmpeg-bc901998487bf9b77a423961d9f961bcc28a9291.tar.gz |
lavc: set AVCodecContext.codec in avcodec_get_context_defaults3().
This way, if the AVCodecContext is allocated for a specific codec, the
caller doesn't need to store this codec separately and then pass it
again to avcodec_open2().
It also allows to set codec private options using av_opt_set_* before
opening the codec.
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/utils.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 1b2239a068..cf7180b3cf 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2009,7 +2009,9 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option if (!avcodec_is_open(st->codec)) { AVDictionary *thread_opt = NULL; - codec = avcodec_find_decoder(st->codec->codec_id); + codec = st->codec->codec ? st->codec->codec : + avcodec_find_decoder(st->codec->codec_id); + if (!codec) return -1; @@ -2169,8 +2171,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES; } } - assert(!st->codec->codec); - codec = avcodec_find_decoder(st->codec->codec_id); + codec = st->codec->codec ? st->codec->codec : + avcodec_find_decoder(st->codec->codec_id); /* force thread count to 1 since the h264 decoder will not extract SPS * and PPS to extradata during multi-threaded decoding */ |