[FFmpeg-devel] [PATCH] 03: dtsdec: downmix to mono or stereo if requested

Pavlov Konstantin thresh
Tue May 15 16:22:13 CEST 2007


Hello.

If avctx->channels is set to 1 or 2, ask libdts to downmix sound to
the requested number of channels instead of returning all channels.
This matches the AC3 decoder behavior and assumptions made by ffplay
and ffmpeg programs.

Patch by Sergey Vlasov <vsu at altlinux.ru>

-- 
If it's working, the diagnostics say it's fine.
If it's not working, the diagnostics say it's fine.
- A proposed addition to rules for realtime programming
-------------- next part --------------
>From eff8b4beda14d97d253dcea1cbd962b356c5e01a Mon Sep 17 00:00:00 2001
From: Sergey Vlasov <vsu at altlinux.ru>
Date: Tue, 15 May 2007 14:50:42 +0400
Subject: dtsdec: downmix to mono or stereo if requested

If avctx->channels is set to 1 or 2, ask libdts to downmix sound to
the requested number of channels instead of returning all channels.
This matches the AC3 decoder behavior and assumptions made by ffplay
and ffmpeg programs.

Signed-off-by: Sergey Vlasov <vsu at altlinux.ru>
---
 libavcodec/dtsdec.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/libavcodec/dtsdec.c b/libavcodec/dtsdec.c
index 17ba86f..ac2e9a1 100644
--- a/libavcodec/dtsdec.c
+++ b/libavcodec/dtsdec.c
@@ -216,7 +216,15 @@ dts_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
     level = CONVERT_LEVEL;
     bias = CONVERT_BIAS;
 
-    flags = s->flags | DTS_ADJUST_LEVEL;
+    if(avctx->channels == 1) {
+        flags = DTS_MONO;
+    } else if(avctx->channels == 2) {
+        flags = DTS_STEREO;
+    } else {
+        flags = s->flags;
+    }
+
+    flags |= DTS_ADJUST_LEVEL;
     if(dts_frame(s->state, s->buf, &flags, &level, bias)) {
         av_log(avctx, AV_LOG_ERROR, "dts_frame() failed\n");
         goto end;
-- 
1.5.1.1.197.g66b3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070515/7e1f5a19/attachment.pgp>



More information about the ffmpeg-devel mailing list