aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-05-28 08:16:40 +0200
committerAnton Khirnov <anton@khirnov.net>2012-06-10 08:02:18 +0200
commit406b257de936b59f1fc943e399fbf1289fec6b95 (patch)
tree7bbacf18560a6a1308e3f90fdc8e4409d00545ed /libavutil
parent3596de55fc054b5c336e7e542c26ced0505d4f2e (diff)
downloadffmpeg-406b257de936b59f1fc943e399fbf1289fec6b95.tar.gz
audioconvert: add a function for getting channel's index in layout
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/audioconvert.c10
-rw-r--r--libavutil/audioconvert.h12
2 files changed, 22 insertions, 0 deletions
diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c
index 1a8e5ee239..9e2f812d7c 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 35a1a087f6..6f6b4447ef 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);
+
+/**
* @}
*/