[FFmpeg-devel] [PATCH] Make av_get_channel_layout_string() guess the number of channels if it was not provided.

Stefano Sabatini stefano.sabatini-lala
Wed Jan 12 22:21:35 CET 2011


---
 libavcore/audioconvert.c |    3 +++
 libavcore/audioconvert.h |    1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libavcore/audioconvert.c b/libavcore/audioconvert.c
index 171d6b1..c720733 100644
--- a/libavcore/audioconvert.c
+++ b/libavcore/audioconvert.c
@@ -78,6 +78,9 @@ void av_get_channel_layout_string(char *buf, int buf_size,
 {
     int i;
 
+    if (nb_channels <= 0)
+        nb_channels = av_get_channel_layout_nb_channels(channel_layout);
+
     for (i = 0; channel_layout_map[i].name; i++)
         if (nb_channels    == channel_layout_map[i].nb_channels &&
             channel_layout == channel_layout_map[i].layout) {
diff --git a/libavcore/audioconvert.h b/libavcore/audioconvert.h
index 0c6b979..89e9c55 100644
--- a/libavcore/audioconvert.h
+++ b/libavcore/audioconvert.h
@@ -80,6 +80,7 @@ int64_t av_get_channel_layout(const char *name);
 
 /**
  * Return a description of a channel layout.
+ * If nb_channels is <= 0, it is guessed from the channel_layout.
  *
  * @param buf put here the string containing the channel layout
  * @param buf_size size in bytes of the buffer
-- 
1.7.2.3




More information about the ffmpeg-devel mailing list