diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-12-08 06:57:44 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-01-31 07:55:24 +0100 |
commit | af08d9aeea870de017139f7b1c44b7d816cf8e56 (patch) | |
tree | a94b59c3d1976b21855e9af7b847e4c81ecb062d /libavformat/utils.c | |
parent | f7fe41a04f962707a99597d2ea49d73ca90b23a0 (diff) | |
download | ffmpeg-af08d9aeea870de017139f7b1c44b7d816cf8e56.tar.gz |
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().
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 9c59947fb7..1b2239a068 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -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]; |