[FFmpeg-cvslog] lavu: add av_get_media_type_string() convenience function

Stefano Sabatini git at videolan.org
Sat Aug 20 14:25:50 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Thu Aug 18 12:27:44 2011 +0200| [69e2c1a95ac4dd00cb09ba3a166efc1275f5ba40] | committer: Stefano Sabatini

lavu: add av_get_media_type_string() convenience function

Avoid code duplication.

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

 doc/APIchanges     |    3 +++
 libavutil/avutil.h |    8 +++++++-
 libavutil/utils.c  |   12 ++++++++++++
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index ed87c0d..cb1dad7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
+2011-08-20 - xxxxxx - lavu 51.13.0
+  Add av_get_media_type_string().
+
 2011-08-14 - xxxxxx - lavu 52.12.0
   Add av_fifo_peek2(), deprecate av_fifo_peek().
 
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index fc437dd..25b5567 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -40,7 +40,7 @@
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
 
 #define LIBAVUTIL_VERSION_MAJOR 51
-#define LIBAVUTIL_VERSION_MINOR 12
+#define LIBAVUTIL_VERSION_MINOR 13
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -95,6 +95,12 @@ enum AVMediaType {
     AVMEDIA_TYPE_NB
 };
 
+/**
+ * Return a string describing the media_type enum, NULL if media_type
+ * is unknown.
+ */
+const char *av_get_media_type_string(enum AVMediaType media_type);
+
 #define FF_LAMBDA_SHIFT 7
 #define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
 #define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
diff --git a/libavutil/utils.c b/libavutil/utils.c
index c77a060..e6c8424 100644
--- a/libavutil/utils.c
+++ b/libavutil/utils.c
@@ -40,6 +40,18 @@ const char *avutil_license(void)
     return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
 }
 
+const char *av_get_media_type_string(enum AVMediaType media_type)
+{
+    switch (media_type) {
+    case AVMEDIA_TYPE_VIDEO:      return "video";
+    case AVMEDIA_TYPE_AUDIO:      return "audio";
+    case AVMEDIA_TYPE_DATA:       return "data";
+    case AVMEDIA_TYPE_SUBTITLE:   return "subtitle";
+    case AVMEDIA_TYPE_ATTACHMENT: return "attachment";
+    default:                      return NULL;
+    }
+}
+
 char av_get_picture_type_char(enum AVPictureType pict_type)
 {
     switch (pict_type) {



More information about the ffmpeg-cvslog mailing list