Bug 1248861: P11. Fix current downmixer. r?rillian draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 06 Apr 2016 14:52:49 +1000
changeset 348786 aeb8153d296ac8512e7728afb797c25909125f1d
parent 348785 a281204092845f0e5523cbfc122af44489643d12
child 517936 f4431c36c8c0bbd6941724db0910c62935469df0
push id14921
push userbmo:jyavenard@mozilla.com
push dateFri, 08 Apr 2016 03:22:06 +0000
reviewersrillian
bugs1248861
milestone48.0a1
Bug 1248861: P11. Fix current downmixer. r?rillian Current downmixer was using vorbis channel order (which isn't surprising as it was extracted from the Ogg reader). Make it use SMPTE order as that's now what all MediaDataDecoder output. MozReview-Commit-ID: 5Kf7UnC52wL
dom/media/VideoUtils.cpp
--- a/dom/media/VideoUtils.cpp
+++ b/dom/media/VideoUtils.cpp
@@ -143,44 +143,44 @@ media::TimeIntervals GetEstimatedBuffere
 int DownmixAudioToStereo(mozilla::AudioDataValue* buffer,
                          int channels, uint32_t frames)
 {
   int outChannels;
   outChannels = 2;
 #ifdef MOZ_SAMPLE_TYPE_FLOAT32
   // Downmix matrix. Per-row normalization 1 for rows 3,4 and 2 for rows 5-8.
   static const float dmatrix[6][8][2]= {
-      /*3*/{{0.5858f,0},{0.4142f,0.4142f},{0,     0.5858f}},
-      /*4*/{{0.4226f,0},{0,      0.4226f},{0.366f,0.2114f},{0.2114f,0.366f}},
-      /*5*/{{0.6510f,0},{0.4600f,0.4600f},{0,     0.6510f},{0.5636f,0.3254f},{0.3254f,0.5636f}},
-      /*6*/{{0.5290f,0},{0.3741f,0.3741f},{0,     0.5290f},{0.4582f,0.2645f},{0.2645f,0.4582f},{0.3741f,0.3741f}},
-      /*7*/{{0.4553f,0},{0.3220f,0.3220f},{0,     0.4553f},{0.3943f,0.2277f},{0.2277f,0.3943f},{0.2788f,0.2788f},{0.3220f,0.3220f}},
-      /*8*/{{0.3886f,0},{0.2748f,0.2748f},{0,     0.3886f},{0.3366f,0.1943f},{0.1943f,0.3366f},{0.3366f,0.1943f},{0.1943f,0.3366f},{0.2748f,0.2748f}},
+      /*3*/{{0.5858f,0},{0,0.5858f},{0.4142f,0.4142f}},
+      /*4*/{{0.4226f,0},{0,0.4226f},{0.366f, 0.2114f},{0.2114f,0.366f}},
+      /*5*/{{0.6510f,0},{0,0.6510f},{0.4600f,0.4600f},{0.5636f,0.3254f},{0.3254f,0.5636f}},
+      /*6*/{{0.5290f,0},{0,0.5290f},{0.3741f,0.3741f},{0.3741f,0.3741f},{0.4582f,0.2645f},{0.2645f,0.4582f}},
+      /*7*/{{0.4553f,0},{0,0.4553f},{0.3220f,0.3220f},{0.3220f,0.3220f},{0.2788f,0.2788f},{0.3943f,0.2277f},{0.2277f,0.3943f}},
+      /*8*/{{0.3886f,0},{0,0.3886f},{0.2748f,0.2748f},{0.2748f,0.2748f},{0.3366f,0.1943f},{0.1943f,0.3366f},{0.3366f,0.1943f},{0.1943f,0.3366f}},
   };
   // Re-write the buffer with downmixed data
   for (uint32_t i = 0; i < frames; i++) {
     float sampL = 0.0;
     float sampR = 0.0;
     for (int j = 0; j < channels; j++) {
       sampL+=buffer[i*channels+j]*dmatrix[channels-3][j][0];
       sampR+=buffer[i*channels+j]*dmatrix[channels-3][j][1];
     }
     buffer[i*outChannels]=sampL;
     buffer[i*outChannels+1]=sampR;
   }
 #else
   // Downmix matrix. Per-row normalization 1 for rows 3,4 and 2 for rows 5-8.
   // Coefficients in Q14.
   static const int16_t dmatrix[6][8][2]= {
-      /*3*/{{9598, 0},{6786,6786},{0,   9598}},
+      /*3*/{{9598, 0},{0,   9598},{6786,6786}},
       /*4*/{{6925, 0},{0,   6925},{5997,3462},{3462,5997}},
-      /*5*/{{10663,0},{7540,7540},{0,  10663},{9234,5331},{5331,9234}},
-      /*6*/{{8668, 0},{6129,6129},{0,   8668},{7507,4335},{4335,7507},{6129,6129}},
-      /*7*/{{7459, 0},{5275,5275},{0,   7459},{6460,3731},{3731,6460},{4568,4568},{5275,5275}},
-      /*8*/{{6368, 0},{4502,4502},{0,   6368},{5514,3184},{3184,5514},{5514,3184},{3184,5514},{4502,4502}}
+      /*5*/{{10663,0},{0,  10663},{7540,7540},{9234,5331},{5331,9234}},
+      /*6*/{{8668, 0},{0,   8668},{6129,6129},{6129,6129},{7507,4335},{4335,7507}},
+      /*7*/{{7459, 0},{0,   7459},{5275,5275},{5275,5275},{4568,4568},{6460,3731},{3731,6460}},
+      /*8*/{{6368, 0},{0,   6368},{4502,4502},{4502,4502},{5514,3184},{3184,5514},{5514,3184},{3184,5514}}
   };
   // Re-write the buffer with downmixed data
   for (uint32_t i = 0; i < frames; i++) {
     int32_t sampL = 0;
     int32_t sampR = 0;
     for (int j = 0; j < channels; j++) {
       sampL+=buffer[i*channels+j]*dmatrix[channels-3][j][0];
       sampR+=buffer[i*channels+j]*dmatrix[channels-3][j][1];