changeset 9511:c2dba7ed94dc libavcodec

Check that channel layout is compatible with number of channels for output audio stream.
author jbr
date Sun, 19 Apr 2009 14:05:55 +0000
parents f0f37cb6e3e5
children ba5d9a97ab2f
files audioconvert.c audioconvert.h
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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;