diff options
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/audioconvert.c | 9 | ||||
-rw-r--r-- | libavcodec/audioconvert.h | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/libavcodec/audioconvert.c b/libavcodec/audioconvert.c index b0a8afacb4..5842801093 100644 --- a/libavcodec/audioconvert.c +++ b/libavcodec/audioconvert.c @@ -153,6 +153,15 @@ void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, } } +int avcodec_channel_layout_num_channels(int64_t channel_layout) +{ + int count; + uint64_t x = channel_layout; + for (count = 0; x; count++) + x &= x-1; // unset lowest set bit + return count; +} + struct AVAudioConvert { int in_channels, out_channels; int fmt_pair; diff --git a/libavcodec/audioconvert.h b/libavcodec/audioconvert.h index 157bd44e21..46ba3d3929 100644 --- a/libavcodec/audioconvert.h +++ b/libavcodec/audioconvert.h @@ -73,6 +73,10 @@ void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, */ int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name); +/** + * @return the number of channels in the channel layout. + */ +int avcodec_channel_layout_num_channels(int64_t channel_layout); struct AVAudioConvert; typedef struct AVAudioConvert AVAudioConvert; |