Browse Source

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

tags/n1.0
Anton Khirnov 13 years ago
parent
commit
59d58b3390
2 changed files with 19 additions and 0 deletions
  1. +14
    -0
      libavutil/audioconvert.c
  2. +5
    -0
      libavutil/audioconvert.h

+ 14
- 0
libavutil/audioconvert.c View File

@@ -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;
}

+ 5
- 0
libavutil/audioconvert.h View File

@@ -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.
*


Loading…
Cancel
Save