bug 1221833 replace initial direct convolution stage with fft r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 04 Nov 2015 08:40:12 +1300
changeset 271438 fe2266a55ca19d4270b91f3658786d5549267b09
parent 271437 26eaa1b7e87850896d3f334ce385db11c49c46e3
child 271439 b69c165bf3c0224504f536f3321bb5f25630f33a
push id29641
push usercbook@mozilla.com
push dateFri, 06 Nov 2015 12:44:48 +0000
treeherdermozilla-central@512caeeb5565 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1221833
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1221833 replace initial direct convolution stage with fft r=padenot
dom/media/webaudio/blink/ReverbConvolver.cpp
--- a/dom/media/webaudio/blink/ReverbConvolver.cpp
+++ b/dom/media/webaudio/blink/ReverbConvolver.cpp
@@ -78,56 +78,57 @@ ReverbConvolver::ReverbConvolver(const f
 
     // For the moment, a good way to know if we have real-time constraint is to check if we're using background threads.
     // Otherwise, assume we're being run from a command-line tool.
     bool hasRealtimeConstraint = useBackgroundThreads;
 
     const float* response = impulseResponseData;
     size_t totalResponseLength = impulseResponseLength;
 
-    // The total latency is zero because the direct-convolution is used in the leading portion.
+    // The total latency is zero because the first FFT stage is small enough
+    // to return output in the first block.
     size_t reverbTotalLatency = 0;
 
     size_t stageOffset = 0;
     size_t stagePhase = 0;
     size_t fftSize = m_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)
             stageSize = totalResponseLength - stageOffset;
 
         // This "staggers" the time when each FFT happens so they don't all happen at the same time
         int renderPhase = convolverRenderPhase + stagePhase;
 
-        bool useDirectConvolver = !stageOffset;
+        bool useDirectConvolver = false;
 
         nsAutoPtr<ReverbConvolverStage> stage
           (new ReverbConvolverStage(response, totalResponseLength,
                                     reverbTotalLatency, stageOffset, stageSize,
                                     fftSize, renderPhase,
                                     &m_accumulationBuffer, useDirectConvolver));
 
         bool isBackgroundStage = false;
 
         if (this->useBackgroundThreads() && stageOffset > RealtimeFrameLimit) {
             m_backgroundStages.AppendElement(stage.forget());
             isBackgroundStage = true;
         } else
             m_stages.AppendElement(stage.forget());
 
-        stageOffset += stageSize;
-
-        if (!useDirectConvolver) {
+        if (stageOffset != 0) {
             // Figure out next FFT size
             fftSize *= 2;
         }
 
+        stageOffset += stageSize;
+
         if (hasRealtimeConstraint && !isBackgroundStage
             && fftSize > m_maxRealtimeFFTSize) {
             fftSize = m_maxRealtimeFFTSize;
             // Custom phase positions for all but the first of the realtime
             // stages of largest size.  These spread out the work of the
             // larger realtime stages.  None of the FFTs of size 1024, 2048 or
             // 4096 are performed when processing the same block.  The first
             // MaxRealtimeFFTSize = 4096 stage, at the end of the doubling,