Browse Source

audioconvert: add a function for getting channel's index in layout

tags/n1.0
Anton Khirnov 13 years ago
parent
commit
406b257de9
2 changed files with 22 additions and 0 deletions
  1. +10
    -0
      libavutil/audioconvert.c
  2. +12
    -0
      libavutil/audioconvert.h

+ 10
- 0
libavutil/audioconvert.c View File

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

+ 12
- 0
libavutil/audioconvert.h View File

@@ -143,6 +143,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);

/**
* @}
*/


Loading…
Cancel
Save