diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-05-28 08:16:40 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-06-10 08:02:18 +0200 |
commit | 406b257de936b59f1fc943e399fbf1289fec6b95 (patch) | |
tree | 7bbacf18560a6a1308e3f90fdc8e4409d00545ed /libavutil | |
parent | 3596de55fc054b5c336e7e542c26ced0505d4f2e (diff) | |
download | ffmpeg-406b257de936b59f1fc943e399fbf1289fec6b95.tar.gz |
audioconvert: add a function for getting channel's index in layout
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/audioconvert.c | 10 | ||||
-rw-r--r-- | libavutil/audioconvert.h | 12 |
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); + +/** * @} */ |