From eff8b4beda14d97d253dcea1cbd962b356c5e01a Mon Sep 17 00:00:00 2001 From: Sergey Vlasov 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 --- 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