lavc: add avcodec_is_open().

It allows to check whether an AVCodecContext is open in a documented
way. Right now the undocumented way this check is done in lavf/lavc is
by checking whether AVCodecContext.codec is NULL. However it's desirable
to be able to set AVCodecContext.codec before avcodec_open2().
This commit is contained in:
Anton Khirnov
2011-12-08 06:57:44 +01:00
parent f7fe41a04f
commit af08d9aeea
5 changed files with 20 additions and 4 deletions

View File

@@ -2006,7 +2006,7 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
AVFrame picture;
AVPacket pkt = *avpkt;
if(!st->codec->codec){
if (!avcodec_is_open(st->codec)) {
AVDictionary *thread_opt = NULL;
codec = avcodec_find_decoder(st->codec->codec_id);
@@ -2354,8 +2354,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
// close codecs which were opened in try_decode_frame()
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if(st->codec->codec)
avcodec_close(st->codec);
avcodec_close(st->codec);
}
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];