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.
--- 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)
{