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

Changeset 94029 in webkit


Ignore:
Timestamp:
Aug 29, 2011, 4:35:40 PM (15 years ago)
Author:
cevans@google.com
Message:

Merge 94002
BUG=93978
Review URL: http://codereview.chromium.org/7793016

Location:
branches/chromium/835/Source/WebCore/webaudio
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/chromium/835/Source/WebCore/webaudio/RealtimeAnalyser.cpp

    r93810 r94029  
    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;       
  • branches/chromium/835/Source/WebCore/webaudio/RealtimeAnalyser.h

    r87173 r94029  
    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.