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.
This commit is contained in:
Anton Khirnov
2012-01-28 19:15:15 +01:00
parent 0e72ad95f9
commit bc90199848
4 changed files with 23 additions and 8 deletions

View File

@@ -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 */