diff --git a/content/media/webaudio/blink/Biquad.cpp b/content/media/webaudio/blink/Biquad.cpp index 45776bf4609f..5ed1432f65b8 100644 --- a/content/media/webaudio/blink/Biquad.cpp +++ b/content/media/webaudio/blink/Biquad.cpp @@ -86,7 +86,7 @@ void Biquad::process(const float* sourceP, float* destP, size_t framesToProcess) // Flush future values to zero (until there is new input). y1 = y2 = 0.0; // Flush calculated values. - for (int i = framesToProcess; i-- && fabs(destP[i]) < FLT_MIN; ) { + for (int i = framesToProcess; i-- && fabsf(destP[i]) < FLT_MIN; ) { destP[i] = 0.0f; } } diff --git a/content/media/webaudio/blink/ZeroPole.cpp b/content/media/webaudio/blink/ZeroPole.cpp index 02879f981e85..ac0b15c7adc1 100644 --- a/content/media/webaudio/blink/ZeroPole.cpp +++ b/content/media/webaudio/blink/ZeroPole.cpp @@ -28,11 +28,12 @@ #include "ZeroPole.h" -#include "DenormalDisabler.h" +#include +#include namespace WebCore { -void ZeroPole::process(const float *source, float *destination, unsigned framesToProcess) +void ZeroPole::process(const float *source, float *destination, int framesToProcess) { float zero = m_zero; float pole = m_pole; @@ -45,8 +46,8 @@ void ZeroPole::process(const float *source, float *destination, unsigned framesT float lastX = m_lastX; float lastY = m_lastY; - while (framesToProcess--) { - float input = *source++; + for (int i = 0; i < framesToProcess; ++i) { + float input = source[i]; // Zero float output1 = k1 * (input - zero * lastX); @@ -56,13 +57,22 @@ void ZeroPole::process(const float *source, float *destination, unsigned framesT float output2 = k2 * output1 + pole * lastY; lastY = output2; - *destination++ = output2; + destination[i] = output2; } // Locals to member variables. Flush denormals here so we don't // slow down the inner loop above. - m_lastX = DenormalDisabler::flushDenormalFloatToZero(lastX); - m_lastY = DenormalDisabler::flushDenormalFloatToZero(lastY); + if (lastX == 0.0f && lastY != 0.0f && fabsf(lastY) < FLT_MIN) { + // Flush future values to zero (until there is new input). + lastY = 0.0; + // Flush calculated values. + for (int i = framesToProcess; i-- && fabsf(destination[i]) < FLT_MIN; ) { + destination[i] = 0.0f; + } + } + + m_lastX = lastX; + m_lastY = lastY; } } // namespace WebCore diff --git a/content/media/webaudio/blink/ZeroPole.h b/content/media/webaudio/blink/ZeroPole.h index 4cb1d174563f..7381bde3d2ef 100644 --- a/content/media/webaudio/blink/ZeroPole.h +++ b/content/media/webaudio/blink/ZeroPole.h @@ -43,7 +43,7 @@ public: { } - void process(const float *source, float *destination, unsigned framesToProcess); + void process(const float *source, float *destination, int framesToProcess); // Reset filter state. void reset() { m_lastX = 0; m_lastY = 0; }