[FFmpeg-cvslog] lavc: add avcodec_get_type() for mapping codec_id -> type.

Anton Khirnov git at videolan.org
Wed Aug 17 14:42:48 CEST 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Thu Aug 11 17:45:50 2011 +0200| [bca06e77e1b07f1dab04c3b9fef6fdcb62b4a401] | committer: Anton Khirnov

lavc: add avcodec_get_type() for mapping codec_id -> type.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bca06e77e1b07f1dab04c3b9fef6fdcb62b4a401
---

 doc/APIchanges       |    3 +++
 libavcodec/avcodec.h |    8 ++++++++
 libavcodec/utils.c   |   14 ++++++++++++++
 libavcodec/version.h |    4 ++--
 4 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index ac95d16..64d1571 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
+2011-08-xx - xxxxxxx - lavc 53.8.0
+  Add avcodec_get_type().
+
 2011-08-06 - 2f63440 - lavf 53.4.0
   Add error_recognition to AVFormatContext.
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 5bc1878..0859e0e 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -210,6 +210,7 @@ enum CodecID {
     CODEC_ID_DFA,
 
     /* various PCM "codecs" */
+    CODEC_ID_FIRST_AUDIO = 0x10000,     ///< A dummy id pointing at the start of audio codecs
     CODEC_ID_PCM_S16LE= 0x10000,
     CODEC_ID_PCM_S16BE,
     CODEC_ID_PCM_U16LE,
@@ -340,6 +341,7 @@ enum CodecID {
     CODEC_ID_QDMC,
 
     /* subtitle codecs */
+    CODEC_ID_FIRST_SUBTITLE = 0x17000,          ///< A dummy ID pointing at the start of subtitle codecs.
     CODEC_ID_DVD_SUBTITLE= 0x17000,
     CODEC_ID_DVB_SUBTITLE,
     CODEC_ID_TEXT,  ///< raw UTF-8 text
@@ -351,6 +353,7 @@ enum CodecID {
     CODEC_ID_SRT,
 
     /* other specific kind of codecs (generally used for attachments) */
+    CODEC_ID_FIRST_UNKNOWN = 0x18000,           ///< A dummy ID pointing at the start of various fake codecs.
     CODEC_ID_TTF= 0x18000,
 
     CODEC_ID_PROBE= 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
@@ -4273,4 +4276,9 @@ enum AVLockOp {
  */
 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
 
+/**
+ * Get the type of the given codec.
+ */
+enum AVMediaType avcodec_get_type(enum CodecID codec_id);
+
 #endif /* AVCODEC_AVCODEC_H */
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 0abab9a..166fbec 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1301,3 +1301,17 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count)
     return ff_thread_init(s);
 }
 #endif
+
+enum AVMediaType avcodec_get_type(enum CodecID codec_id)
+{
+    if (codec_id <= CODEC_ID_NONE)
+        return AVMEDIA_TYPE_UNKNOWN;
+    else if (codec_id < CODEC_ID_FIRST_AUDIO)
+        return AVMEDIA_TYPE_VIDEO;
+    else if (codec_id < CODEC_ID_FIRST_SUBTITLE)
+        return AVMEDIA_TYPE_AUDIO;
+    else if (codec_id < CODEC_ID_FIRST_UNKNOWN)
+        return AVMEDIA_TYPE_SUBTITLE;
+
+    return AVMEDIA_TYPE_UNKNOWN;
+}
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 7eb5ce0..24a33d7 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -21,8 +21,8 @@
 #define AVCODEC_VERSION_H
 
 #define LIBAVCODEC_VERSION_MAJOR 53
-#define LIBAVCODEC_VERSION_MINOR  7
-#define LIBAVCODEC_VERSION_MICRO  1
+#define LIBAVCODEC_VERSION_MINOR  8
+#define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list