⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 94002 in webkit


Ignore:
Timestamp:
Aug 29, 2011, 12:23:00 PM (15 years ago)
Author:
commit-queue@webkit.org
Message:

Source/WebCore: Fix failures when FFT size is changed.
https://bugs.webkit.org/show_bug.cgi?id=66916

Patch by Chris Palmer <palmer@google.com> on 2011-08-29
Reviewed by Kenneth Russell.

Test: webaudio/fft-sizing.html

  • webaudio/RealtimeAnalyser.cpp:

(WebCore::RealtimeAnalyser::setFftSize): Assert size sanity.
(WebCore::RealtimeAnalyser::doFFTAnalysis): Iterate the correct number of times over magnitudeBuffer.

  • webaudio/RealtimeAnalyser.h: Put member fields in the correct order (Min before Max).

LayoutTests: Fix failures when FFT array size is changed.
https://bugs.webkit.org/show_bug.cgi?id=66916

Patch by Chris Palmer <palmer@google.com> on 2011-08-29
Reviewed by Kenneth Russell.

  • webaudio/realtimeanalyser-fft-sizing-expected.txt: Added.
  • webaudio/realtimeanalyser-fft-sizing.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r94001 r94002  
     12011-08-29  Chris Palmer  <palmer@google.com>
     2
     3        Fix failures when FFT array size is changed.
     4        https://bugs.webkit.org/show_bug.cgi?id=66916
     5
     6        Reviewed by Kenneth Russell.
     7
     8        * webaudio/realtimeanalyser-fft-sizing-expected.txt: Added.
     9        * webaudio/realtimeanalyser-fft-sizing.html: Added.
     10
    1112011-08-29  Abhishek Arya  <inferno@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r94001 r94002  
     12011-08-29  Chris Palmer  <palmer@google.com>
     2
     3        Fix failures when FFT size is changed.
     4        https://bugs.webkit.org/show_bug.cgi?id=66916
     5
     6        Reviewed by Kenneth Russell.
     7
     8        Test: webaudio/fft-sizing.html
     9
     10        * webaudio/RealtimeAnalyser.cpp:
     11        (WebCore::RealtimeAnalyser::setFftSize): Assert size sanity.
     12        (WebCore::RealtimeAnalyser::doFFTAnalysis): Iterate the correct number of times over magnitudeBuffer.
     13        * webaudio/RealtimeAnalyser.h: Put member fields in the correct order (Min before Max).
     14
    1152011-08-29  Abhishek Arya  <inferno@chromium.org>
    216
  • trunk/Source/WebCore/webaudio/RealtimeAnalyser.cpp

    r92408 r94002  
    5050
    5151const unsigned RealtimeAnalyser::DefaultFFTSize = 2048;
     52// All FFT implementations are expected to handle power-of-two sizes MinFFTSize <= size <= MaxFFTSize.
     53const unsigned RealtimeAnalyser::MinFFTSize = 128;
    5254const unsigned RealtimeAnalyser::MaxFFTSize = 2048;
    5355const unsigned RealtimeAnalyser::InputBufferSize = RealtimeAnalyser::MaxFFTSize * 2;
     
    8385    unsigned log2size = static_cast<unsigned>(log2(size));
    8486    bool isPOT(1UL << log2size == size);
    85    
    86     if (!isPOT || size > MaxFFTSize) {
     87
     88    if (!isPOT || size > MaxFFTSize || size < MinFFTSize) {
    8789        // FIXME: It would be good to also set an exception.
    8890        return;
     
    9092
    9193    if (m_fftSize != size) {
    92         m_analysisFrame = adoptPtr(new FFTFrame(m_fftSize));
    93         m_magnitudeBuffer.allocate(size);
     94        m_analysisFrame = adoptPtr(new FFTFrame(size));
     95        // m_magnitudeBuffer has size = fftSize / 2 because it contains floats reduced from complex values in m_analysisFrame.
     96        m_magnitudeBuffer.allocate(size / 2);
    9497        m_fftSize = size;
    9598    }
     
    166169    m_analysisFrame->doFFT(tempP);
    167170
    168     size_t n = DefaultFFTSize / 2;
    169 
    170171    float* realP = m_analysisFrame->realData();
    171172    float* imagP = m_analysisFrame->imagData();
     
    184185    // Convert the analysis data from complex to magnitude and average with the previous result.
    185186    float* destination = magnitudeBuffer().data();
    186     for (unsigned i = 0; i < n; ++i) {
     187    size_t n = magnitudeBuffer().size();
     188    for (size_t i = 0; i < n; ++i) {
    187189        Complex c(realP[i], imagP[i]);
    188190        double scalarMagnitude = abs(c) * MagnitudeScale;       
  • trunk/Source/WebCore/webaudio/RealtimeAnalyser.h

    r87173 r94002  
    7171
    7272    static const unsigned DefaultFFTSize;
     73    static const unsigned MinFFTSize;
    7374    static const unsigned MaxFFTSize;
    7475    static const unsigned InputBufferSize;
Note: See TracChangeset for help on using the changeset viewer.