bug 1223520 avoid leaking NaNs to and from the otherwise unused imaginary frequency components r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 11 Nov 2015 20:34:41 +1300
changeset 308662 cd88c2150e1ee4574e78ce1199911ed9a16f366a
parent 308661 51287ab3d66af6767908f3dfc7f39d998eb0ff61
child 308663 a4ce197dfecef223c0e9f84ab3bc1fc27c5cf0cb
push id7513
push useratolfsen@mozilla.com
push dateFri, 13 Nov 2015 14:03:43 +0000
reviewerspadenot
bugs1223520
milestone45.0a1
bug 1223520 avoid leaking NaNs to and from the otherwise unused imaginary frequency components r=padenot 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
@@ -133,24 +133,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)
   {