--- 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;