From b2e65a79247ea54818ae5b54fcb8c31db06b71c6 Mon Sep 17 00:00:00 2001 From: Dan Minor Date: Mon, 30 May 2016 05:36:11 -0400 Subject: [PATCH] Bug 1265408 - Avoid subnormals in IIRFilter; r=karlt MozReview-Commit-ID: F4NUE8834tM --HG-- extra : rebase_source : 1a5d118f7aed0f4803bc83feda482f940218d65d extra : source : 784521a9cc94ad399d1405ada007f06d255c6c29 --- dom/media/webaudio/blink/Biquad.cpp | 1 + dom/media/webaudio/blink/IIRFilter.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dom/media/webaudio/blink/Biquad.cpp b/dom/media/webaudio/blink/Biquad.cpp index 38c92ff11329..fbc4cf0776d1 100644 --- a/dom/media/webaudio/blink/Biquad.cpp +++ b/dom/media/webaudio/blink/Biquad.cpp @@ -76,6 +76,7 @@ void Biquad::process(const float* sourceP, float* destP, size_t framesToProcess) // Avoid introducing a stream of subnormals when input is silent and the // tail approaches zero. + // TODO: Remove this code when Bug 1157635 is fixed. if (x1 == 0.0 && x2 == 0.0 && (y1 != 0.0 || y2 != 0.0) && fabs(y1) < FLT_MIN && fabs(y2) < FLT_MIN) { // Flush future values to zero (until there is new input). diff --git a/dom/media/webaudio/blink/IIRFilter.cpp b/dom/media/webaudio/blink/IIRFilter.cpp index cc5273dc140c..3bfafbce364b 100644 --- a/dom/media/webaudio/blink/IIRFilter.cpp +++ b/dom/media/webaudio/blink/IIRFilter.cpp @@ -98,7 +98,13 @@ void IIRFilter::process(const float* sourceP, float* destP, size_t framesToProce m_bufferIndex = (m_bufferIndex + 1) & (kBufferLength - 1); - destP[n] = yn; + // Avoid introducing a stream of subnormals + // TODO: Remove this code when Bug 1157635 is fixed. + if (fabs(yn) >= FLT_MIN) { + destP[n] = yn; + } else { + destP[n] = 0.0; + } } }