bug 1223520 avoid leaking NaNs to and from the otherwise unused imaginary frequency components r=padenot a=ritu
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 11 Nov 2015 20:34:41 +1300
changeset 305529 68adba814ed03f18126e43a395b74d4306ef3248
parent 305528 54e1a12b93e69c68970f71ae0c52e17321875885
child 305530 3ac88e18ff69d5dd16e37ee9354c55d68b79b91c
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot, ritu
bugs1223520
milestone44.0a2
bug 1223520 avoid leaking NaNs to and from the otherwise unused imaginary frequency components r=padenot a=ritu The zeroth component is not removed from the BufferComplexMultiply() call so as not to disrupt alignment. The mOutputBuffer[halfSize].i assertions are removed because the code no longer uses these components, and so their values are irrelevant.
dom/media/webaudio/FFTBlock.h
--- a/dom/media/webaudio/FFTBlock.h
+++ b/dom/media/webaudio/FFTBlock.h
@@ -138,24 +138,25 @@ public:
 #endif
   }
 
   void Multiply(const FFTBlock& aFrame)
   {
     uint32_t halfSize = mFFTSize / 2;
     // DFTs are not packed.
     MOZ_ASSERT(mOutputBuffer[0].i == 0);
-    MOZ_ASSERT(mOutputBuffer[halfSize].i == 0);
     MOZ_ASSERT(aFrame.mOutputBuffer[0].i == 0);
-    MOZ_ASSERT(aFrame.mOutputBuffer[halfSize].i == 0);
 
     BufferComplexMultiply(mOutputBuffer.Elements()->f,
                           aFrame.mOutputBuffer.Elements()->f,
                           mOutputBuffer.Elements()->f,
-                          halfSize + 1);
+                          halfSize);
+    mOutputBuffer[halfSize].r *= aFrame.mOutputBuffer[halfSize].r;
+    // This would have been set to NaN if either real component was NaN.
+    mOutputBuffer[0].i = 0.0f;
   }
 
   // Perform a forward FFT on |aData|, assuming zeros after dataSize samples,
   // and pre-scale the generated internal frequency domain coefficients so
   // that GetInverseWithoutScaling() can be used to transform to the time
   // domain.  This is useful for convolution kernels.
   void PadAndMakeScaledDFT(const float* aData, size_t dataSize)
   {