summaryrefslogtreecommitdiff
authorJustin Ruggles <justin.ruggles@gmail.com>2013-01-27 19:47:54 (GMT)
committer Justin Ruggles <justin.ruggles@gmail.com>2013-02-12 18:41:13 (GMT)
commit157542ebc15dd175e5b4d14ffa92afd74ab4a991 (patch)
treee440f41109dda33b410d9467ad416fc835d0d99b
parent600b4c973fb98f07ec3c5837112865048fb8a607 (diff)
downloadffmpeg-157542ebc15dd175e5b4d14ffa92afd74ab4a991.zip
ffmpeg-157542ebc15dd175e5b4d14ffa92afd74ab4a991.tar.gz
ffmpeg-157542ebc15dd175e5b4d14ffa92afd74ab4a991.tar.bz2
lavr: fix mixing matrix reduction when normalization is disabled
In some cases when an input contributes fully to the corresponding output, other inputs may also contribute to the same output. This is the case, for example, for the default 5.1 to stereo downmix matrix without normalization.
Diffstat
-rw-r--r--libavresample/audio_mix.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavresample/audio_mix.c b/libavresample/audio_mix.c
index 487bddf..b69bfbc 100644
--- a/libavresample/audio_mix.c
+++ b/libavresample/audio_mix.c
@@ -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;