From 2bde8e466a4451c7319e3a072d118917957d6554 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Wed, 25 May 2011 19:08:45 +0100 Subject: Merge WebKit at r82507: Initial merge by git Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e --- Source/WebCore/platform/audio/HRTFKernel.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'Source/WebCore/platform/audio/HRTFKernel.cpp') 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(log2(length)) == length); + ASSERT(channel->length() >= analysisFFTSize); + + // Check for power-of-2. + ASSERT(1UL << static_cast(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(); -- cgit v1.1