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().
---
doc/APIchanges | 3 +++
libavcodec/avcodec.h | 5 +++++
libavcodec/utils.c | 5 +++++
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 7cac096..b4e2390 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2011-04-18
API changes, most recent first:
+2012-xx-xx - xxxxxxx - lavc 54.01.0
+ Add avcodec_is_open() function.
+
2012-01-25 - lavf 53.22.0
f1caf01 Allow doing av_write_frame(ctx, NULL) for flushing possible
buffered data within a muxer. Added AVFMT_ALLOW_FLUSH for
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index d8e56ca..29e4e6a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4176,4 +4176,9 @@ enum AVMediaType avcodec_get_type(enum CodecID codec_id);
*/
const AVClass *avcodec_get_class(void);
+/**
+ * @return a positive value if s is open, 0 otherwise.
+ */
+int avcodec_is_open(AVCodecContext *s);
+
#endif /* AVCODEC_AVCODEC_H */
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 34a4122..c3e898b 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1803,3 +1803,8 @@ enum AVMediaType avcodec_get_type(enum CodecID codec_id)
return AVMEDIA_TYPE_UNKNOWN;
}
+
+int avcodec_is_open(AVCodecContext *s)
+{
+ return !!s->internal;
+}
--
1.7.7.3
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel