[FFmpeg-devel] [PATCH] lavu/audioconvert: add av_guess_channel_layout() function
Stefano Sabatini
stefano.sabatini-lala at poste.it
Sun Sep 11 00:36:14 CEST 2011
---
doc/APIchanges | 3 +++
libavutil/audioconvert.c | 14 ++++++++++++++
libavutil/audioconvert.h | 8 ++++++++
3 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 65d76bd..71a4bb4 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2011-04-18
API changes, most recent first:
+2011-09-xx - xxxxxxx - lavu 51.X.0
+ Add av_guess_channel_layout().
+
2011-08-xx - xxxxxxx - lavc 53.10.0
lavf 53.6.0
lsws 2.1.0
diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c
index 97c02f5..000c45b 100644
--- a/libavutil/audioconvert.c
+++ b/libavutil/audioconvert.c
@@ -130,3 +130,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 e37a2e8..2fe4808 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