summaryrefslogtreecommitdiffstats
path: root/libavcodec/utils.c
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 /libavcodec/utils.c
parentf7fe41a04f962707a99597d2ea49d73ca90b23a0 (diff)
downloadffmpeg-streaming-af08d9aeea870de017139f7b1c44b7d816cf8e56.zip
ffmpeg-streaming-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 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 34a4122..3ee6b09 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -627,6 +627,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD
int ret = 0;
AVDictionary *tmp = NULL;
+ if (avcodec_is_open(avctx))
+ return 0;
+
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
return AVERROR(EINVAL);
@@ -1803,3 +1806,8 @@ enum AVMediaType avcodec_get_type(enum CodecID codec_id)
return AVMEDIA_TYPE_UNKNOWN;
}
+
+int avcodec_is_open(AVCodecContext *s)
+{
+ return !!s->internal;
+}
OpenPOWER on IntegriCloud