Bug 1262746: P3. Remove DownmixAudioToStereo method. r?rillian draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 08 Apr 2016 17:42:00 +1000
changeset 349687 7f4e1b6d991e3f35324d8bd9f9825c747dc3daeb
parent 349686 367b146936d2476e27514ddc2534a2275506b008
child 349688 157cefeb61c551fe956eb2e39a5b2bad4ebbd643
child 349794 fa856874a1999e94106e407449d8101c6d347210
push id15157
push userbmo:jyavenard@mozilla.com
push dateTue, 12 Apr 2016 02:25:53 +0000
reviewersrillian
bugs1262746
milestone48.0a1
Bug 1262746: P3. Remove DownmixAudioToStereo method. r?rillian Functionality is now provided through AudioConverter class. MozReview-Commit-ID: 5MchZT1XRoO
dom/media/VideoUtils.cpp
dom/media/VideoUtils.h
--- a/dom/media/VideoUtils.cpp
+++ b/dom/media/VideoUtils.cpp
@@ -135,70 +135,16 @@ media::TimeIntervals GetEstimatedBuffere
 
                               media::TimeUnit::FromMicroseconds(endUs));
     }
     startOffset = aStream->GetNextCachedData(endOffset);
   }
   return buffered;
 }
 
-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,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},{0,   9598},{6786,6786}},
-      /*4*/{{6925, 0},{0,   6925},{5997,3462},{3462,5997}},
-      /*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];
-    }
-    sampL = (sampL + 8192)>>14;
-    buffer[i*outChannels] = static_cast<mozilla::AudioDataValue>(MOZ_CLIP_TO_15(sampL));
-    sampR = (sampR + 8192)>>14;
-    buffer[i*outChannels+1] = static_cast<mozilla::AudioDataValue>(MOZ_CLIP_TO_15(sampR));
-  }
-#endif
-  return outChannels;
-}
-
 void DownmixStereoToMono(mozilla::AudioDataValue* aBuffer,
                          uint32_t aFrames)
 {
   MOZ_ASSERT(aBuffer);
   const int channels = 2;
   for (uint32_t fIdx = 0; fIdx < aFrames; ++fIdx) {
 #ifdef MOZ_SAMPLE_TYPE_FLOAT32
     float sample = 0.0;
--- a/dom/media/VideoUtils.h
+++ b/dom/media/VideoUtils.h
@@ -158,23 +158,16 @@ nsresult SecondsToUsecs(double aSeconds,
 static const int32_t MAX_VIDEO_WIDTH = 8192;
 static const int32_t MAX_VIDEO_HEIGHT = 4608;
 
 // Scales the display rect aDisplay by aspect ratio aAspectRatio.
 // Note that aDisplay must be validated by IsValidVideoRegion()
 // before being used!
 void ScaleDisplayByAspectRatio(nsIntSize& aDisplay, float aAspectRatio);
 
-// Downmix multichannel Audio samples to Stereo.
-// Input are the buffer contains multichannel data,
-// the number of channels and the number of frames.
-int DownmixAudioToStereo(mozilla::AudioDataValue* buffer,
-                         int channels,
-                         uint32_t frames);
-
 // Downmix Stereo audio samples to Mono.
 // Input are the buffer contains stereo data and the number of frames.
 void DownmixStereoToMono(mozilla::AudioDataValue* aBuffer,
                          uint32_t aFrames);
 
 bool IsVideoContentType(const nsCString& aContentType);
 
 // Returns true if it's safe to use aPicture as the picture to be