[FFmpeg-cvslog] audioconvert: add a function for extracting the channel with the given index

Anton Khirnov git at videolan.org
Sun Jun 10 21:39:49 CEST 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon May 28 12:20:57 2012 +0200| [59d58b3390cf866a5db6d3cd3908922d2905de6e] | committer: Anton Khirnov

audioconvert: add a function for extracting the channel with the given index

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

 libavutil/audioconvert.c |   14 ++++++++++++++
 libavutil/audioconvert.h |    5 +++++
 2 files changed, 19 insertions(+)

diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c
index 36d07ee..1ac63a3 100644
--- a/libavutil/audioconvert.c
+++ b/libavutil/audioconvert.c
@@ -213,3 +213,17 @@ const char *av_get_channel_name(uint64_t channel)
             return get_channel_name(i);
     return NULL;
 }
+
+uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index)
+{
+    int i;
+
+    if (av_get_channel_layout_nb_channels(channel_layout) <= index)
+        return 0;
+
+    for (i = 0; i < 64; i++) {
+        if ((1ULL << i) & channel_layout && !index--)
+            return 1ULL << i;
+    }
+    return 0;
+}
diff --git a/libavutil/audioconvert.h b/libavutil/audioconvert.h
index e516ae8..691c64a 100644
--- a/libavutil/audioconvert.h
+++ b/libavutil/audioconvert.h
@@ -156,6 +156,11 @@ int av_get_channel_layout_channel_index(uint64_t channel_layout,
                                         uint64_t channel);
 
 /**
+ * Get the channel with the given index in channel_layout.
+ */
+uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index);
+
+/**
  * Get the name of a given channel.
  *
  * @return channel name on success, NULL on error.



More information about the ffmpeg-cvslog mailing list