diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-05-28 12:20:57 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-06-10 08:03:45 +0200 |
commit | 59d58b3390cf866a5db6d3cd3908922d2905de6e (patch) | |
tree | 97b977e11f4a4ea296c71eb1ab596c7fb1f73ac0 /libavutil/audioconvert.c | |
parent | 5df320e167dc5b5a6fa46e2d1d59f51263dea181 (diff) | |
download | ffmpeg-59d58b3390cf866a5db6d3cd3908922d2905de6e.tar.gz |
audioconvert: add a function for extracting the channel with the given index
Diffstat (limited to 'libavutil/audioconvert.c')
-rw-r--r-- | libavutil/audioconvert.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c index 36d07ee5a4..1ac63a37a6 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; +} |