[FFmpeg-cvslog] audioconvert: add a function for getting channel's index in layout

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 08:16:40 2012 +0200| [406b257de936b59f1fc943e399fbf1289fec6b95] | committer: Anton Khirnov

audioconvert: add a function for getting channel's index in layout

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

 libavutil/audioconvert.c |   10 ++++++++++
 libavutil/audioconvert.h |   12 ++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c
index 1a8e5ee..9e2f812 100644
--- a/libavutil/audioconvert.c
+++ b/libavutil/audioconvert.c
@@ -192,3 +192,13 @@ uint64_t av_get_default_channel_layout(int nb_channels)
     default: return 0;
     }
 }
+
+int av_get_channel_layout_channel_index(uint64_t channel_layout,
+                                        uint64_t channel)
+{
+    if (!(channel_layout & channel) ||
+        av_get_channel_layout_nb_channels(channel) != 1)
+        return AVERROR(EINVAL);
+    channel_layout &= channel - 1;
+    return av_get_channel_layout_nb_channels(channel_layout);
+}
diff --git a/libavutil/audioconvert.h b/libavutil/audioconvert.h
index 35a1a08..6f6b444 100644
--- a/libavutil/audioconvert.h
+++ b/libavutil/audioconvert.h
@@ -144,6 +144,18 @@ int av_get_channel_layout_nb_channels(uint64_t channel_layout);
 uint64_t av_get_default_channel_layout(int nb_channels);
 
 /**
+ * Get the index of a channel in channel_layout.
+ *
+ * @param channel a channel layout describing exactly one channel which must be
+ *                present in channel_layout.
+ *
+ * @return index of channel in channel_layout on success, a negative AVERROR
+ *         on error.
+ */
+int av_get_channel_layout_channel_index(uint64_t channel_layout,
+                                        uint64_t channel);
+
+/**
  * @}
  */
 



More information about the ffmpeg-cvslog mailing list