changeset 6114:f6b691720c7d libavcodec

use request_channels in liba52 decoder
author jbr
date Sat, 05 Jan 2008 16:45:25 +0000
parents 5e7585cd5fd3
children 98be2e14e5d6
files liba52.c
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/liba52.c	Sat Jan 05 15:23:39 2008 +0000
+++ b/liba52.c	Sat Jan 05 16:45:25 2008 +0000
@@ -117,6 +117,13 @@
     s->inbuf_ptr = s->inbuf;
     s->frame_size = 0;
 
+    /* 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;
 }
 
@@ -179,12 +186,11 @@
                     s->channels = ac3_channels[s->flags & 7];
                     if (s->flags & A52_LFE)
                         s->channels++;
-                    if (avctx->channels == 0)
-                        /* No specific number of channel requested */
                         avctx->channels = s->channels;
-                    else if (s->channels < avctx->channels) {
-                        av_log(avctx, AV_LOG_ERROR, "ac3dec: AC3 Source channels are less than specified: output to %d channels.. (frmsize: %d)\n", s->channels, len);
-                        avctx->channels = s->channels;
+                    if (avctx->request_channels > 0 &&
+                            avctx->request_channels <= 2 &&
+                            avctx->request_channels < s->channels) {
+                        avctx->channels = avctx->request_channels;
                     }
                     avctx->bit_rate = bit_rate;
                 }