Title: [94002] trunk
- Revision
- 94002
- Author
- [email protected]
- Date
- 2011-08-29 12:23:00 -0700 (Mon, 29 Aug 2011)
Log Message
Source/WebCore: Fix failures when FFT size is changed.
https://bugs.webkit.org/show_bug.cgi?id=66916
Patch by Chris Palmer <[email protected]> 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 <[email protected]> on 2011-08-29
Reviewed by Kenneth Russell.
* webaudio/realtimeanalyser-fft-sizing-expected.txt: Added.
* webaudio/realtimeanalyser-fft-sizing.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (94001 => 94002)
--- trunk/LayoutTests/ChangeLog 2011-08-29 19:19:52 UTC (rev 94001)
+++ trunk/LayoutTests/ChangeLog 2011-08-29 19:23:00 UTC (rev 94002)
@@ -1,3 +1,13 @@
+2011-08-29 Chris Palmer <[email protected]>
+
+ Fix failures when FFT array size is changed.
+ https://bugs.webkit.org/show_bug.cgi?id=66916
+
+ Reviewed by Kenneth Russell.
+
+ * webaudio/realtimeanalyser-fft-sizing-expected.txt: Added.
+ * webaudio/realtimeanalyser-fft-sizing.html: Added.
+
2011-08-29 Abhishek Arya <[email protected]>
Crash in InlineBox::deleteLine due to accessing removed
Added: trunk/LayoutTests/webaudio/realtimeanalyser-fft-sizing-expected.txt (0 => 94002)
--- trunk/LayoutTests/webaudio/realtimeanalyser-fft-sizing-expected.txt (rev 0)
+++ trunk/LayoutTests/webaudio/realtimeanalyser-fft-sizing-expected.txt 2011-08-29 19:23:00 UTC (rev 94002)
@@ -0,0 +1,9 @@
+Test that re-sizing the FFT arrays does not fail.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS webkitAudioContext survived multiple invalid FFT array resizings.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/webaudio/realtimeanalyser-fft-sizing.html (0 => 94002)
--- trunk/LayoutTests/webaudio/realtimeanalyser-fft-sizing.html (rev 0)
+++ trunk/LayoutTests/webaudio/realtimeanalyser-fft-sizing.html 2011-08-29 19:23:00 UTC (rev 94002)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Test that re-sizing the FFT arrays does not fail.");
+
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+var doTest = function(fftSize) {
+ var c = new webkitAudioContext(1, 1000, 44100);
+ var a = c.createAnalyser();
+ a.fftSize = fftSize;
+ // This arbitrary size does not affect the correctness of the test.
+ var arr = new Float32Array(100);
+ a.getFloatFrequencyData(arr);
+}
+
+doTest(-1);
+doTest(0);
+doTest(1);
+for (var i = 2; i <= 0x20000; i *= 2) {
+ doTest(i);
+ doTest(i + 1);
+}
+
+if (window.layoutTestController)
+ layoutTestController.notifyDone();
+testPassed("webkitAudioContext survived multiple invalid FFT array resizings.");
+successfullyParsed = true;
+</script>
+
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (94001 => 94002)
--- trunk/Source/WebCore/ChangeLog 2011-08-29 19:19:52 UTC (rev 94001)
+++ trunk/Source/WebCore/ChangeLog 2011-08-29 19:23:00 UTC (rev 94002)
@@ -1,3 +1,17 @@
+2011-08-29 Chris Palmer <[email protected]>
+
+ Fix failures when FFT size is changed.
+ https://bugs.webkit.org/show_bug.cgi?id=66916
+
+ 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).
+
2011-08-29 Abhishek Arya <[email protected]>
Crash in InlineBox::deleteLine due to accessing removed
Modified: trunk/Source/WebCore/webaudio/RealtimeAnalyser.cpp (94001 => 94002)
--- trunk/Source/WebCore/webaudio/RealtimeAnalyser.cpp 2011-08-29 19:19:52 UTC (rev 94001)
+++ trunk/Source/WebCore/webaudio/RealtimeAnalyser.cpp 2011-08-29 19:23:00 UTC (rev 94002)
@@ -49,6 +49,8 @@
const double RealtimeAnalyser::DefaultMaxDecibels = -30.0;
const unsigned RealtimeAnalyser::DefaultFFTSize = 2048;
+// All FFT implementations are expected to handle power-of-two sizes MinFFTSize <= size <= MaxFFTSize.
+const unsigned RealtimeAnalyser::MinFFTSize = 128;
const unsigned RealtimeAnalyser::MaxFFTSize = 2048;
const unsigned RealtimeAnalyser::InputBufferSize = RealtimeAnalyser::MaxFFTSize * 2;
@@ -82,15 +84,16 @@
// Only allow powers of two.
unsigned log2size = static_cast<unsigned>(log2(size));
bool isPOT(1UL << log2size == size);
-
- if (!isPOT || size > MaxFFTSize) {
+
+ if (!isPOT || size > MaxFFTSize || size < MinFFTSize) {
// FIXME: It would be good to also set an exception.
return;
}
if (m_fftSize != size) {
- m_analysisFrame = adoptPtr(new FFTFrame(m_fftSize));
- m_magnitudeBuffer.allocate(size);
+ m_analysisFrame = adoptPtr(new FFTFrame(size));
+ // m_magnitudeBuffer has size = fftSize / 2 because it contains floats reduced from complex values in m_analysisFrame.
+ m_magnitudeBuffer.allocate(size / 2);
m_fftSize = size;
}
}
@@ -165,8 +168,6 @@
// Do the analysis.
m_analysisFrame->doFFT(tempP);
- size_t n = DefaultFFTSize / 2;
-
float* realP = m_analysisFrame->realData();
float* imagP = m_analysisFrame->imagData();
@@ -183,7 +184,8 @@
// Convert the analysis data from complex to magnitude and average with the previous result.
float* destination = magnitudeBuffer().data();
- for (unsigned i = 0; i < n; ++i) {
+ size_t n = magnitudeBuffer().size();
+ for (size_t i = 0; i < n; ++i) {
Complex c(realP[i], imagP[i]);
double scalarMagnitude = abs(c) * MagnitudeScale;
destination[i] = float(k * destination[i] + (1.0 - k) * scalarMagnitude);
Modified: trunk/Source/WebCore/webaudio/RealtimeAnalyser.h (94001 => 94002)
--- trunk/Source/WebCore/webaudio/RealtimeAnalyser.h 2011-08-29 19:19:52 UTC (rev 94001)
+++ trunk/Source/WebCore/webaudio/RealtimeAnalyser.h 2011-08-29 19:23:00 UTC (rev 94002)
@@ -70,6 +70,7 @@
static const double DefaultMaxDecibels;
static const unsigned DefaultFFTSize;
+ static const unsigned MinFFTSize;
static const unsigned MaxFFTSize;
static const unsigned InputBufferSize;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes