summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-12-08 06:57:44 +0100
committerAnton Khirnov <anton@khirnov.net>2012-01-31 07:55:24 +0100
commitaf08d9aeea870de017139f7b1c44b7d816cf8e56 (patch)
treea94b59c3d1976b21855e9af7b847e4c81ecb062d /libavformat
parentf7fe41a04f962707a99597d2ea49d73ca90b23a0 (diff)
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')
-rw-r--r--libavformat/utils.c5
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];