[FFmpeg-cvslog] avutil: Add av_get_default_channel_layout()
Justin Ruggles
git at videolan.org
Fri Apr 6 23:27:41 CEST 2012
ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Wed Mar 21 20:36:51 2012 -0400| [5cc51a5847ca9f333672370b1aa98e2d9f9518aa] | committer: Justin Ruggles
avutil: Add av_get_default_channel_layout()
Also, use the new function in the AC-3 encoder.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5cc51a5847ca9f333672370b1aa98e2d9f9518aa
---
doc/APIchanges | 3 +++
libavcodec/ac3enc.c | 2 +-
libavutil/audioconvert.c | 15 +++++++++++++++
libavutil/audioconvert.h | 5 +++++
libavutil/avutil.h | 2 +-
5 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 15eec40..80bea4f 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -12,6 +12,9 @@ libavutil: 2011-04-18
API changes, most recent first:
+2012-xx-xx - xxxxxxx - lavu 51.26.0 - audioconvert.h
+ Add av_get_default_channel_layout()
+
2012-03-06 - 4d851f8 - lavu 51.25.0 - cpu.h
Add av_set_cpu_flags_mask().
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index c903b72..3962fab 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -2074,7 +2074,7 @@ static av_cold int set_channel_info(AC3EncodeContext *s, int channels,
return AVERROR(EINVAL);
ch_layout = *channel_layout;
if (!ch_layout)
- ch_layout = avcodec_guess_channel_layout(channels, CODEC_ID_AC3, NULL);
+ ch_layout = av_get_default_channel_layout(channels);
s->lfe_on = !!(ch_layout & AV_CH_LOW_FREQUENCY);
s->channels = channels;
diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c
index 0a83b05..85c20e2 100644
--- a/libavutil/audioconvert.c
+++ b/libavutil/audioconvert.c
@@ -153,3 +153,18 @@ int av_get_channel_layout_nb_channels(uint64_t channel_layout)
x &= x-1; // unset lowest set bit
return count;
}
+
+uint64_t av_get_default_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 7: return AV_CH_LAYOUT_6POINT1;
+ case 8: return AV_CH_LAYOUT_7POINT1;
+ default: return 0;
+ }
+}
diff --git a/libavutil/audioconvert.h b/libavutil/audioconvert.h
index 55d79fc..2b0c9cd 100644
--- a/libavutil/audioconvert.h
+++ b/libavutil/audioconvert.h
@@ -125,6 +125,11 @@ void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint
int av_get_channel_layout_nb_channels(uint64_t channel_layout);
/**
+ * Return default channel layout for a given number of channels.
+ */
+uint64_t av_get_default_channel_layout(int nb_channels);
+
+/**
* @}
*/
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 21fc737..6ab4840 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -152,7 +152,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 51
-#define LIBAVUTIL_VERSION_MINOR 25
+#define LIBAVUTIL_VERSION_MINOR 26
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
More information about the ffmpeg-cvslog
mailing list