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

--HG--
extra : source : a61652a27e8cc83682b24a9f920df0955b4720b4
extra : amend_source : 6960da7cbae1677685b8af431db301e818d4d4fe
This commit is contained in:
Paul Adenot 2015-10-08 11:16:31 +02:00
Родитель 5bef9005b8
Коммит 1858803b03
1 изменённых файлов: 14 добавлений и 6 удалений

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

@ -229,26 +229,34 @@ public:
AllocateAudioBlock(channelCount, aOutput);
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;