Bug 1203616 - Properly scale the input buffer of a WaveShaperNode before processing it with the curve. r=karlt

--HG--
extra : rebase_source : b2505272bf0b177dfb0c6215d0e232a591b6650a
This commit is contained in:
Paul Adenot 2015-10-08 11:16:31 +02:00
Родитель 7c64f71620
Коммит e1154a6a56
1 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -230,26 +230,34 @@ public:
aOutput->AllocateChannels(channelCount);
for (uint32_t i = 0; i < channelCount; ++i) {
float* scaledSample = (float *)(aInput.mChannelData[i]);
AudioBlockInPlaceScale(scaledSample, aInput.mVolume);
const float* inputBuffer = static_cast<const float*>(scaledSample);
const float* inputSamples;
float scaledInput[WEBAUDIO_BLOCK_SIZE];
if (aInput.mVolume != 1.0f) {
AudioBlockCopyChannelWithScale(
static_cast<const float*>(aInput.mChannelData[i]),
aInput.mVolume,
scaledInput);
inputSamples = scaledInput;
} else {
inputSamples = static_cast<const float*>(aInput.mChannelData[i]);
}
float* outputBuffer = aOutput->ChannelFloatsForWrite(i);
float* sampleBuffer;
switch (mType) {
case OverSampleType::None:
mResampler.Reset(channelCount, aStream->SampleRate(), OverSampleType::None);
ProcessCurve<1>(inputBuffer, outputBuffer);
ProcessCurve<1>(inputSamples, outputBuffer);
break;
case OverSampleType::_2x:
mResampler.Reset(channelCount, aStream->SampleRate(), OverSampleType::_2x);
sampleBuffer = mResampler.UpSample(i, inputBuffer, 2);
sampleBuffer = mResampler.UpSample(i, inputSamples, 2);
ProcessCurve<2>(sampleBuffer, sampleBuffer);
mResampler.DownSample(i, outputBuffer, 2);
break;
case OverSampleType::_4x:
mResampler.Reset(channelCount, aStream->SampleRate(), OverSampleType::_4x);
sampleBuffer = mResampler.UpSample(i, inputBuffer, 4);
sampleBuffer = mResampler.UpSample(i, inputSamples, 4);
ProcessCurve<4>(sampleBuffer, sampleBuffer);
mResampler.DownSample(i, outputBuffer, 4);
break;