LCOV - code coverage report
Current view: top level - dom/media/webaudio/blink - ReverbConvolverStage.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 34 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2010 Google Inc. All rights reserved.
       3             :  *
       4             :  * Redistribution and use in source and binary forms, with or without
       5             :  * modification, are permitted provided that the following conditions
       6             :  * are met:
       7             :  *
       8             :  * 1.  Redistributions of source code must retain the above copyright
       9             :  *     notice, this list of conditions and the following disclaimer.
      10             :  * 2.  Redistributions in binary form must reproduce the above copyright
      11             :  *     notice, this list of conditions and the following disclaimer in the
      12             :  *     documentation and/or other materials provided with the distribution.
      13             :  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
      14             :  *     its contributors may be used to endorse or promote products derived
      15             :  *     from this software without specific prior written permission.
      16             :  *
      17             :  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
      18             :  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
      19             :  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
      20             :  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
      21             :  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
      22             :  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
      23             :  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
      24             :  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      25             :  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
      26             :  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      27             :  */
      28             : 
      29             : #include "ReverbConvolverStage.h"
      30             : 
      31             : #include "ReverbAccumulationBuffer.h"
      32             : #include "ReverbConvolver.h"
      33             : #include "ReverbInputBuffer.h"
      34             : #include "mozilla/PodOperations.h"
      35             : 
      36             : using namespace mozilla;
      37             : 
      38             : namespace WebCore {
      39             : 
      40           0 : ReverbConvolverStage::ReverbConvolverStage(const float* impulseResponse, size_t,
      41             :                                            size_t reverbTotalLatency,
      42             :                                            size_t stageOffset,
      43             :                                            size_t stageLength,
      44             :                                            size_t fftSize, size_t renderPhase,
      45           0 :                                            ReverbAccumulationBuffer* accumulationBuffer)
      46             :     : m_accumulationBuffer(accumulationBuffer)
      47             :     , m_accumulationReadIndex(0)
      48           0 :     , m_inputReadIndex(0)
      49             : {
      50           0 :     MOZ_ASSERT(impulseResponse);
      51           0 :     MOZ_ASSERT(accumulationBuffer);
      52             : 
      53           0 :     m_fftKernel = new FFTBlock(fftSize);
      54           0 :     m_fftKernel->PadAndMakeScaledDFT(impulseResponse + stageOffset, stageLength);
      55           0 :     m_fftConvolver = new FFTConvolver(fftSize, renderPhase);
      56             : 
      57             :     // The convolution stage at offset stageOffset needs to have a corresponding delay to cancel out the offset.
      58           0 :     size_t totalDelay = stageOffset + reverbTotalLatency;
      59             : 
      60             :     // But, the FFT convolution itself incurs latency, so subtract this out...
      61           0 :     size_t fftLatency = m_fftConvolver->latencyFrames();
      62           0 :     MOZ_ASSERT(totalDelay >= fftLatency);
      63           0 :     totalDelay -= fftLatency;
      64             : 
      65           0 :     m_postDelayLength = totalDelay;
      66           0 : }
      67             : 
      68           0 : size_t ReverbConvolverStage::sizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
      69             : {
      70           0 :     size_t amount = aMallocSizeOf(this);
      71             : 
      72           0 :     if (m_fftKernel) {
      73           0 :         amount += m_fftKernel->SizeOfIncludingThis(aMallocSizeOf);
      74             :     }
      75             : 
      76           0 :     if (m_fftConvolver) {
      77           0 :         amount += m_fftConvolver->sizeOfIncludingThis(aMallocSizeOf);
      78             :     }
      79             : 
      80           0 :     return amount;
      81             : }
      82             : 
      83           0 : void ReverbConvolverStage::processInBackground(ReverbConvolver* convolver)
      84             : {
      85           0 :     ReverbInputBuffer* inputBuffer = convolver->inputBuffer();
      86           0 :     float* source = inputBuffer->directReadFrom(&m_inputReadIndex,
      87           0 :                                                 WEBAUDIO_BLOCK_SIZE);
      88           0 :     process(source);
      89           0 : }
      90             : 
      91           0 : void ReverbConvolverStage::process(const float* source)
      92             : {
      93           0 :     MOZ_ASSERT(source);
      94           0 :     if (!source)
      95           0 :         return;
      96             : 
      97             :     // Now, run the convolution (into the delay buffer).
      98             :     // An expensive FFT will happen every fftSize / 2 frames.
      99           0 :     const float* output = m_fftConvolver->process(m_fftKernel, source);
     100             : 
     101             :     // Now accumulate into reverb's accumulation buffer.
     102           0 :     m_accumulationBuffer->accumulate(output, WEBAUDIO_BLOCK_SIZE,
     103             :                                      &m_accumulationReadIndex,
     104           0 :                                      m_postDelayLength);
     105             : }
     106             : 
     107             : } // namespace WebCore

Generated by: LCOV version 1.13