]> git.sesse.net Git - ffmpeg/blobdiff - libavresample/audio_mix.c
lavr: fix mixing matrix reduction when normalization is disabled
[ffmpeg] / libavresample / audio_mix.c
index 487bddf7465240b717b8979331d50fd928ce680c..b69bfbcf3edcc4f80b31a3da087d90b4a76660a4 100644 (file)
@@ -572,11 +572,22 @@ static void reduce_matrix(AudioMix *am, const double *matrix, int stride)
         int skip = 1;
 
         for (o = 0; o < am->out_channels; o++) {
+            int i0;
             if ((o != i && matrix[o * stride + i] != 0.0) ||
                 (o == i && matrix[o * stride + i] != 1.0)) {
                 skip = 0;
                 break;
             }
+            /* if the input contributes fully to the output, also check that no
+               other inputs contribute to this output */
+            if (o == i) {
+                for (i0 = 0; i0 < am->in_channels; i0++) {
+                    if (i0 != i && matrix[o * stride + i0] != 0.0) {
+                        skip = 0;
+                        break;
+                    }
+                }
+            }
         }
         if (skip) {
             am->input_skip[i] = 1;