# HG changeset patch # User jbr # Date 1240149955 0 # Node ID c2dba7ed94dc585016aa9102f6495cfcee7f5d8a # Parent f0f37cb6e3e5bcf6a85c3f5a2854fd8e7376624f Check that channel layout is compatible with number of channels for output audio stream. diff -r f0f37cb6e3e5 -r c2dba7ed94dc audioconvert.c --- a/audioconvert.c Sun Apr 19 00:55:46 2009 +0000 +++ b/audioconvert.c Sun Apr 19 14:05:55 2009 +0000 @@ -153,6 +153,15 @@ } } +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 -r f0f37cb6e3e5 -r c2dba7ed94dc audioconvert.h --- a/audioconvert.h Sun Apr 19 00:55:46 2009 +0000 +++ b/audioconvert.h Sun Apr 19 14:05:55 2009 +0000 @@ -73,6 +73,10 @@ */ 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;