bug 1224102 reduce the size of the final FFT convolution stage if possible r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 12 Nov 2015 17:34:13 +1300
changeset 308660 d3b584b54bb9f56cf522099b0830a132b06bc996
parent 308659 335c2779216be1186d937a95f29d082d8a4045d6
child 308661 51287ab3d66af6767908f3dfc7f39d998eb0ff61
push id7513
push useratolfsen@mozilla.com
push dateFri, 13 Nov 2015 14:03:43 +0000
reviewerspadenot
bugs1224102
milestone45.0a1
bug 1224102 reduce the size of the final FFT convolution stage if possible r=padenot
dom/media/webaudio/blink/ReverbConvolver.cpp
--- a/dom/media/webaudio/blink/ReverbConvolver.cpp
+++ b/dom/media/webaudio/blink/ReverbConvolver.cpp
@@ -89,18 +89,24 @@ ReverbConvolver::ReverbConvolver(const f
     size_t stageOffset = 0;
     size_t stagePhase = 0;
     size_t fftSize = MinFFTSize;
     while (stageOffset < totalResponseLength) {
         size_t stageSize = fftSize / 2;
 
         // For the last stage, it's possible that stageOffset is such that we're straddling the end
         // of the impulse response buffer (if we use stageSize), so reduce the last stage's length...
-        if (stageSize + stageOffset > totalResponseLength)
+        if (stageSize + stageOffset > totalResponseLength) {
             stageSize = totalResponseLength - stageOffset;
+            // Use smallest FFT that is large enough to cover the last stage.
+            fftSize = MinFFTSize;
+            while (stageSize * 2 > fftSize) {
+              fftSize *= 2;
+            }
+        }
 
         // This "staggers" the time when each FFT happens so they don't all happen at the same time
         int renderPhase = convolverRenderPhase + stagePhase;
 
         nsAutoPtr<ReverbConvolverStage> stage
           (new ReverbConvolverStage(response, totalResponseLength,
                                     reverbTotalLatency, stageOffset, stageSize,
                                     fftSize, renderPhase,