mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
b=944143 avoid producing infinite stream of subnormals in ZeroPole tail r=padenot
--HG-- extra : transplant_source : gI%94%E9%DB%99%83%B7%09%B6%82q%FF9%5DI%BE%D6%EF%B6
This commit is contained in:
parent
3d7d128e05
commit
f3dc828963
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -28,11 +28,12 @@
|
||||
|
||||
#include "ZeroPole.h"
|
||||
|
||||
#include "DenormalDisabler.h"
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
|
||||
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
|
||||
|
@ -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; }
|
||||
|
Loading…
Reference in New Issue
Block a user