lavr: fix matrix reduction for upmixing in certain cases
authorJustin Ruggles <justin.ruggles@gmail.com>
Fri, 18 Jan 2013 18:44:10 +0000 (13:44 -0500)
committerJustin Ruggles <justin.ruggles@gmail.com>
Tue, 12 Feb 2013 18:41:13 +0000 (13:41 -0500)
Do not skip an output if the corresponding input contributes to other output
channels.

libavresample/audio_mix.c

index 096bcf3..487bddf 100644 (file)
@@ -607,6 +607,7 @@ static void reduce_matrix(AudioMix *am, const double *matrix, int stride)
        corresponding input channel */
     for (o = 0; o < FFMIN(am->in_channels, am->out_channels); o++) {
         int skip = 1;
+        int o0;
 
         for (i = 0; i < am->in_channels; i++) {
             if ((o != i && matrix[o * stride + i] != 0.0) ||
@@ -615,6 +616,15 @@ static void reduce_matrix(AudioMix *am, const double *matrix, int stride)
                 break;
             }
         }
+        /* check if the corresponding input channel makes a contribution to
+           any other output channel */
+        i = o;
+        for (o0 = 0; o0 < am->out_channels; o0++) {
+            if (o0 != i && matrix[o0 * stride + i] != 0.0) {
+                skip = 0;
+                break;
+            }
+        }
         if (skip) {
             am->output_skip[o] = 1;
             am->out_matrix_channels--;