Commit 59d58b33 authored by Anton Khirnov's avatar Anton Khirnov

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

parent 5df320e1
......@@ -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;
}
......@@ -155,6 +155,11 @@ uint64_t av_get_default_channel_layout(int nb_channels);
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.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment