[FFmpeg-cvslog] dcaenc: Allow encoding without specifying a channel_layout.

Reimar Döffinger git at videolan.org
Sat Apr 7 16:35:49 CEST 2012


ffmpeg | branch: master | Reimar Döffinger <Reimar.Doeffinger at gmx.de> | Sat Apr  7 12:01:50 2012 +0200| [4395c058d261a6b23fbfaff9f55d0cafc329d3b6] | committer: Reimar Döffinger

dcaenc: Allow encoding without specifying a channel_layout.

It will print a warning, making the behaviour consistent
with the AC3 encoder.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4395c058d261a6b23fbfaff9f55d0cafc329d3b6
---

 libavcodec/dcaenc.c       |    9 ++++++++-
 tests/codec-regression.sh |    2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
index 71106d7..d6efd25 100644
--- a/libavcodec/dcaenc.c
+++ b/libavcodec/dcaenc.c
@@ -534,11 +534,18 @@ static int encode_init(AVCodecContext *avctx)
 {
     DCAContext *c = avctx->priv_data;
     int i;
+    uint64_t layout = avctx->channel_layout;
 
     c->prim_channels = avctx->channels;
     c->lfe_channel   = (avctx->channels == 3 || avctx->channels == 6);
 
-    switch (avctx->channel_layout) {
+    if (!layout) {
+        av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The "
+                                      "encoder will guess the layout, but it "
+                                      "might be incorrect.\n");
+        layout = av_get_default_channel_layout(avctx->channels);
+    }
+    switch (layout) {
     case AV_CH_LAYOUT_STEREO:       c->a_mode = 2; c->num_channel = 2; break;
     case AV_CH_LAYOUT_5POINT0:      c->a_mode = 9; c->num_channel = 9; break;
     case AV_CH_LAYOUT_5POINT1:      c->a_mode = 9; c->num_channel = 9; break;
diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh
index 2f63b69..0a84f0f 100755
--- a/tests/codec-regression.sh
+++ b/tests/codec-regression.sh
@@ -440,7 +440,7 @@ do_audio_decoding
 fi
 
 if [ -n "$do_dca" ] ; then
-do_audio_encoding dca.dts "-strict -2 -channel_layout 3 -acodec dca"
+do_audio_encoding dca.dts "-strict -2 -acodec dca"
 # decoding is not bit-exact, so skip md5 of decoded file
 do_audio_decoding_nomd5
 $tiny_psnr $pcm_dst $pcm_ref 2 1920



More information about the ffmpeg-cvslog mailing list