[FFmpeg-devel] [PATCH] lavu/audioconvert: add av_guess_channel_layout() function
Stefano Sabatini
stefano.sabatini-lala at poste.it
Sun Aug 21 19:12:19 CEST 2011
---
libavutil/audioconvert.c | 14 ++++++++++++++
libavutil/audioconvert.h | 8 ++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c
index 6e8649d..9fd9ecc 100644
--- a/libavutil/audioconvert.c
+++ b/libavutil/audioconvert.c
@@ -115,3 +115,17 @@ int av_get_channel_layout_nb_channels(int64_t channel_layout)
x &= x-1; // unset lowest set bit
return count;
}
+
+int64_t av_guess_channel_layout(int nb_channels)
+{
+ switch (nb_channels) {
+ case 1: return AV_CH_LAYOUT_MONO;
+ case 2: return AV_CH_LAYOUT_STEREO;
+ case 3: return AV_CH_LAYOUT_SURROUND;
+ case 4: return AV_CH_LAYOUT_QUAD;
+ case 5: return AV_CH_LAYOUT_5POINT0;
+ case 6: return AV_CH_LAYOUT_5POINT1;
+ case 8: return AV_CH_LAYOUT_7POINT1;
+ default: return 0;
+ }
+}
diff --git a/libavutil/audioconvert.h b/libavutil/audioconvert.h
index 134c610..c8523ca 100644
--- a/libavutil/audioconvert.h
+++ b/libavutil/audioconvert.h
@@ -92,4 +92,12 @@ void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int6
*/
int av_get_channel_layout_nb_channels(int64_t channel_layout);
+/**
+ * Guess the channel layout from the number of channels.
+ *
+ * @return channel layout mask, 0 if it cannot guess the channel
+ * layout
+ */
+int64_t av_guess_channel_layout(int nb_channels);
+
#endif /* AVUTIL_AUDIOCONVERT_H */
--
1.7.2.5
More information about the ffmpeg-devel
mailing list