From 95283c17011f7277e4ce73526f61889c3d446e4c Mon Sep 17 00:00:00 2001
From: Justin Ruggles <justin.ruggles@gmail.com>
Date: Sat, 5 Jan 2008 15:22:53 +0000
Subject: [PATCH] check for request_channels at codec init

Originally committed as revision 11415 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 libavcodec/ac3dec.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 5c09a2e40de..314eaa06240 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -312,6 +312,13 @@ static int ac3_decode_init(AVCodecContext *avctx)
         s->mul_bias = 32767.0f;
     }
 
+    /* allow downmixing to stereo or mono */
+    if (avctx->channels > 0 && avctx->request_channels > 0 &&
+            avctx->request_channels < avctx->channels &&
+            avctx->request_channels <= 2) {
+        avctx->channels = avctx->request_channels;
+    }
+
     return 0;
 }
 
-- 
GitLab