summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/audio/HRTFKernel.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-25 19:08:45 +0100
committerSteve Block <steveblock@google.com>2011-06-08 13:51:31 +0100
commit2bde8e466a4451c7319e3a072d118917957d6554 (patch)
tree28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebCore/platform/audio/HRTFKernel.cpp
parent6939c99b71d9372d14a0c74a772108052e8c48c8 (diff)
downloadexternal_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip
external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz
external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebCore/platform/audio/HRTFKernel.cpp')
-rw-r--r--Source/WebCore/platform/audio/HRTFKernel.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/Source/WebCore/platform/audio/HRTFKernel.cpp b/Source/WebCore/platform/audio/HRTFKernel.cpp
index 22d4b12..9db35ba 100644
--- a/Source/WebCore/platform/audio/HRTFKernel.cpp
+++ b/Source/WebCore/platform/audio/HRTFKernel.cpp
@@ -45,17 +45,18 @@ namespace WebCore {
// This represents the initial delay before the most energetic part of the impulse response.
// The sample-frame delay is removed from the impulseP impulse response, and this value is returned.
// the length of the passed in AudioChannel must be a power of 2.
-static double extractAverageGroupDelay(AudioChannel* channel)
+static double extractAverageGroupDelay(AudioChannel* channel, size_t analysisFFTSize)
{
ASSERT(channel);
float* impulseP = channel->data();
- size_t length = channel->length();
- // Check that length is power-of-2;
- ASSERT(1UL << static_cast<unsigned>(log2(length)) == length);
+ ASSERT(channel->length() >= analysisFFTSize);
+
+ // Check for power-of-2.
+ ASSERT(1UL << static_cast<unsigned>(log2(analysisFFTSize)) == analysisFFTSize);
- FFTFrame estimationFrame(length);
+ FFTFrame estimationFrame(analysisFFTSize);
estimationFrame.doFFT(impulseP);
double frameDelay = estimationFrame.extractAverageGroupDelay();
@@ -71,7 +72,7 @@ HRTFKernel::HRTFKernel(AudioChannel* channel, size_t fftSize, double sampleRate,
ASSERT(channel);
// Determine the leading delay (average group delay) for the response.
- m_frameDelay = extractAverageGroupDelay(channel);
+ m_frameDelay = extractAverageGroupDelay(channel, fftSize / 2);
float* impulseResponse = channel->data();
size_t responseLength = channel->length();