audioconvert: add a function for getting the name of a single channel.
authorAnton Khirnov <anton@khirnov.net>
Mon, 28 May 2012 06:39:10 +0000 (08:39 +0200)
committerAnton Khirnov <anton@khirnov.net>
Sun, 10 Jun 2012 06:03:11 +0000 (08:03 +0200)
libavutil/audioconvert.c
libavutil/audioconvert.h

index 9e2f812..36d07ee 100644 (file)
@@ -202,3 +202,14 @@ int av_get_channel_layout_channel_index(uint64_t channel_layout,
     channel_layout &= channel - 1;
     return av_get_channel_layout_nb_channels(channel_layout);
 }
+
+const char *av_get_channel_name(uint64_t channel)
+{
+    int i;
+    if (av_get_channel_layout_nb_channels(channel) != 1)
+        return NULL;
+    for (i = 0; i < 64; i++)
+        if ((1ULL<<i) & channel)
+            return get_channel_name(i);
+    return NULL;
+}
index 6f6b444..e516ae8 100644 (file)
@@ -156,6 +156,13 @@ int av_get_channel_layout_channel_index(uint64_t channel_layout,
                                         uint64_t channel);
 
 /**
+ * Get the name of a given channel.
+ *
+ * @return channel name on success, NULL on error.
+ */
+const char *av_get_channel_name(uint64_t channel);
+
+/**
  * @}
  */