check for request_channels at codec init
authorJustin Ruggles <justin.ruggles@gmail.com>
Sat, 5 Jan 2008 15:22:53 +0000 (15:22 +0000)
committerJustin Ruggles <justin.ruggles@gmail.com>
Sat, 5 Jan 2008 15:22:53 +0000 (15:22 +0000)
Originally committed as revision 11415 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/ac3dec.c

index 5c09a2e..314eaa0 100644 (file)
@@ -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;
 }