From af08d9aeea870de017139f7b1c44b7d816cf8e56 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 8 Dec 2011 06:57:44 +0100 Subject: 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(). --- libavcodec/utils.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libavcodec/utils.c') 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; +} -- cgit v1.1