[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

crogers at google.com crogers at google.com
Wed Dec 22 12:51:52 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 9054d57bb749384e835bb5e680d7f2ce1eb7fe14
Author: crogers at google.com <crogers at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 31 21:02:11 2010 +0000

    2010-08-31  Chris Rogers  <crogers at google.com>
    
            Reviewed by Kenneth Russell.
    
            audio engine: add FFTConvolver class
            https://bugs.webkit.org/show_bug.cgi?id=34907
    
            No new tests since audio API is not yet implemented.
    
            * platform/audio: Added.
            * platform/audio/FFTConvolver.cpp: Added.
            (WebCore::FFTConvolver::FFTConvolver):
            (WebCore::FFTConvolver::process):
            (WebCore::FFTConvolver::reset):
            * platform/audio/FFTConvolver.h: Added.
            (WebCore::FFTConvolver::fftSize):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66529 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index a88639b..038a1f4 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2010-08-31  Chris Rogers  <crogers at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        audio engine: add FFTConvolver class
+        https://bugs.webkit.org/show_bug.cgi?id=34907
+
+        No new tests since audio API is not yet implemented.
+
+        * platform/audio: Added.
+        * platform/audio/FFTConvolver.cpp: Added.
+        (WebCore::FFTConvolver::FFTConvolver):
+        (WebCore::FFTConvolver::process):
+        (WebCore::FFTConvolver::reset):
+        * platform/audio/FFTConvolver.h: Added.
+        (WebCore::FFTConvolver::fftSize):
+
 2010-08-31  Jian Li  <jianli at chromium.org>
 
         Reviewed by Darin Fisher and David Levin.
diff --git a/WebCore/platform/audio/FFTConvolver.cpp b/WebCore/platform/audio/FFTConvolver.cpp
new file mode 100644
index 0000000..b0211fd
--- /dev/null
+++ b/WebCore/platform/audio/FFTConvolver.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "FFTConvolver.h"
+
+#include "Accelerate.h"
+
+namespace WebCore {
+
+FFTConvolver::FFTConvolver(size_t fftSize)
+    : m_frame(fftSize)
+    , m_readWriteIndex(0)
+    , m_inputBuffer(fftSize) // 2nd half of buffer is always zeroed
+    , m_outputBuffer(fftSize)
+    , m_lastOverlapBuffer(fftSize / 2)
+{
+}
+
+void FFTConvolver::process(FFTFrame* fftKernel, float* sourceP, float* destP, size_t framesToProcess)
+{
+    // FIXME: make so framesToProcess is not required to fit evenly into fftSize/2
+
+    // Copy samples to input buffer (note contraint above!)
+    float* inputP = m_inputBuffer.data();
+
+    // Sanity check
+    bool isCopyGood1 = sourceP && inputP && m_readWriteIndex + framesToProcess <= m_inputBuffer.size();
+    ASSERT(isCopyGood1);
+    if (!isCopyGood1)
+        return;
+    
+    memcpy(inputP + m_readWriteIndex, sourceP, sizeof(float) * framesToProcess);
+
+    // Copy samples from output buffer
+    float* outputP = m_outputBuffer.data();
+
+    // Sanity check
+    bool isCopyGood2 = destP && outputP && m_readWriteIndex + framesToProcess <= m_outputBuffer.size();
+    ASSERT(isCopyGood2);
+    if (!isCopyGood2)
+        return;
+
+    memcpy(destP, outputP + m_readWriteIndex, sizeof(float) * framesToProcess);
+    m_readWriteIndex += framesToProcess;
+
+
+    // Check if it's time to perform the next FFT
+    size_t halfSize = fftSize() / 2;
+    if (m_readWriteIndex == halfSize) {
+        // The input buffer is now filled (get frequency-domain version)
+        m_frame.doFFT(m_inputBuffer.data());
+        m_frame.multiply(*fftKernel);
+        m_frame.doInverseFFT(m_outputBuffer.data());
+
+        // Overlap-add 1st half from previous time
+        vadd(m_outputBuffer.data(), 1, m_lastOverlapBuffer.data(), 1, m_outputBuffer.data(), 1, halfSize);
+
+        // Finally, save 2nd half of result
+        bool isCopyGood3 = m_outputBuffer.size() == 2 * halfSize && m_lastOverlapBuffer.size() == halfSize;
+        ASSERT(isCopyGood3);
+        if (!isCopyGood3)
+            return;
+        
+        memcpy(m_lastOverlapBuffer.data(), m_outputBuffer.data() + halfSize, sizeof(float) * halfSize);
+
+        // Reset index back to start for next time
+        m_readWriteIndex = 0;
+    }
+}
+
+void FFTConvolver::reset()
+{
+    m_lastOverlapBuffer.zero();
+    m_readWriteIndex = 0;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)
diff --git a/WebCore/platform/audio/FFTConvolver.h b/WebCore/platform/audio/FFTConvolver.h
new file mode 100644
index 0000000..0eec7c1
--- /dev/null
+++ b/WebCore/platform/audio/FFTConvolver.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FFTConvolver_h
+#define FFTConvolver_h
+
+#include "AudioFloatArray.h"
+#include "FFTFrame.h"
+
+namespace WebCore {
+
+class FFTConvolver {
+public:
+    // fftSize must be a power of two
+    FFTConvolver(size_t fftSize);
+
+    // For now, with multiple calls to Process(), framesToProcess MUST add up EXACTLY to fftSize / 2
+    //
+    // FIXME: Later, we can do more sophisticated buffering to relax this requirement...
+    //
+    // The input to output latency is equal to fftSize / 2
+    //
+    // Processing in-place is allowed...
+    void process(FFTFrame* fftKernel, float* sourceP, float* destP, size_t framesToProcess);
+
+    void reset();
+
+    size_t fftSize() const { return m_frame.fftSize(); }
+
+private:
+    FFTFrame m_frame;
+
+    // Buffer input until we get fftSize / 2 samples then do an FFT
+    size_t m_readWriteIndex;
+    AudioFloatArray m_inputBuffer;
+
+    // Stores output which we read a little at a time
+    AudioFloatArray m_outputBuffer;
+
+    // Saves the 2nd half of the FFT buffer, so we can do an overlap-add with the 1st half of the next one
+    AudioFloatArray m_lastOverlapBuffer;
+};
+
+} // namespace WebCore
+
+#endif // FFTConvolver_h

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list