| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Intel Inc. All rights reserved. | 2 * Copyright (C) 2012 Intel Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 | 30 |
| 31 #if ENABLE(WEB_AUDIO) | 31 #if ENABLE(WEB_AUDIO) |
| 32 | 32 |
| 33 #include "core/platform/audio/DirectConvolver.h" | 33 #include "core/platform/audio/DirectConvolver.h" |
| 34 | 34 |
| 35 #if OS(DARWIN) | 35 #if OS(MACOSX) |
| 36 #include <Accelerate/Accelerate.h> | 36 #include <Accelerate/Accelerate.h> |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 #include "core/platform/audio/VectorMath.h" | 39 #include "core/platform/audio/VectorMath.h" |
| 40 | 40 |
| 41 namespace WebCore { | 41 namespace WebCore { |
| 42 | 42 |
| 43 using namespace VectorMath; | 43 using namespace VectorMath; |
| 44 | 44 |
| 45 DirectConvolver::DirectConvolver(size_t inputBlockSize) | 45 DirectConvolver::DirectConvolver(size_t inputBlockSize) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 ippsConv_32f(static_cast<const Ipp32f*>(sourceP), framesToProcess, static_ca
st<Ipp32f*>(kernelP), kernelSize, static_cast<Ipp32f*>(outputBuffer)); | 82 ippsConv_32f(static_cast<const Ipp32f*>(sourceP), framesToProcess, static_ca
st<Ipp32f*>(kernelP), kernelSize, static_cast<Ipp32f*>(outputBuffer)); |
| 83 | 83 |
| 84 vadd(outputBuffer, 1, overlayBuffer, 1, destP, 1, framesToProcess); | 84 vadd(outputBuffer, 1, overlayBuffer, 1, destP, 1, framesToProcess); |
| 85 memcpy(overlayBuffer, outputBuffer + m_inputBlockSize, sizeof(float) * kerne
lSize); | 85 memcpy(overlayBuffer, outputBuffer + m_inputBlockSize, sizeof(float) * kerne
lSize); |
| 86 #else | 86 #else |
| 87 float* inputP = m_buffer.data() + m_inputBlockSize; | 87 float* inputP = m_buffer.data() + m_inputBlockSize; |
| 88 | 88 |
| 89 // Copy samples to 2nd half of input buffer. | 89 // Copy samples to 2nd half of input buffer. |
| 90 memcpy(inputP, sourceP, sizeof(float) * framesToProcess); | 90 memcpy(inputP, sourceP, sizeof(float) * framesToProcess); |
| 91 | 91 |
| 92 #if OS(DARWIN) | 92 #if OS(MACOSX) |
| 93 #if defined(__ppc__) || defined(__i386__) | 93 #if defined(__ppc__) || defined(__i386__) |
| 94 conv(inputP - kernelSize + 1, 1, kernelP + kernelSize - 1, -1, destP, 1, fra
mesToProcess, kernelSize); | 94 conv(inputP - kernelSize + 1, 1, kernelP + kernelSize - 1, -1, destP, 1, fra
mesToProcess, kernelSize); |
| 95 #else | 95 #else |
| 96 vDSP_conv(inputP - kernelSize + 1, 1, kernelP + kernelSize - 1, -1, destP, 1
, framesToProcess, kernelSize); | 96 vDSP_conv(inputP - kernelSize + 1, 1, kernelP + kernelSize - 1, -1, destP, 1
, framesToProcess, kernelSize); |
| 97 #endif // defined(__ppc__) || defined(__i386__) | 97 #endif // defined(__ppc__) || defined(__i386__) |
| 98 #else | 98 #else |
| 99 // FIXME: The macro can be further optimized to avoid pipeline stalls. One p
ossibility is to maintain 4 separate sums and change the macro to CONVOLVE_FOUR_
SAMPLES. | 99 // FIXME: The macro can be further optimized to avoid pipeline stalls. One p
ossibility is to maintain 4 separate sums and change the macro to CONVOLVE_FOUR_
SAMPLES. |
| 100 #define CONVOLVE_ONE_SAMPLE \ | 100 #define CONVOLVE_ONE_SAMPLE \ |
| 101 sum += inputP[i - j] * kernelP[j]; \ | 101 sum += inputP[i - j] * kernelP[j]; \ |
| 102 j++; | 102 j++; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 CONVOLVE_ONE_SAMPLE // 127 | 358 CONVOLVE_ONE_SAMPLE // 127 |
| 359 CONVOLVE_ONE_SAMPLE // 128 | 359 CONVOLVE_ONE_SAMPLE // 128 |
| 360 } else { | 360 } else { |
| 361 while (j < kernelSize) { | 361 while (j < kernelSize) { |
| 362 // Non-optimized using actual while loop. | 362 // Non-optimized using actual while loop. |
| 363 CONVOLVE_ONE_SAMPLE | 363 CONVOLVE_ONE_SAMPLE |
| 364 } | 364 } |
| 365 } | 365 } |
| 366 destP[i++] = sum; | 366 destP[i++] = sum; |
| 367 } | 367 } |
| 368 #endif // OS(DARWIN) | 368 #endif // OS(MACOSX) |
| 369 | 369 |
| 370 // Copy 2nd half of input buffer to 1st half. | 370 // Copy 2nd half of input buffer to 1st half. |
| 371 memcpy(m_buffer.data(), inputP, sizeof(float) * framesToProcess); | 371 memcpy(m_buffer.data(), inputP, sizeof(float) * framesToProcess); |
| 372 #endif | 372 #endif |
| 373 } | 373 } |
| 374 | 374 |
| 375 void DirectConvolver::reset() | 375 void DirectConvolver::reset() |
| 376 { | 376 { |
| 377 m_buffer.zero(); | 377 m_buffer.zero(); |
| 378 #if USE(WEBAUDIO_IPP) | 378 #if USE(WEBAUDIO_IPP) |
| 379 m_overlayBuffer.zero(); | 379 m_overlayBuffer.zero(); |
| 380 #endif // USE(WEBAUDIO_IPP) | 380 #endif // USE(WEBAUDIO_IPP) |
| 381 } | 381 } |
| 382 | 382 |
| 383 } // namespace WebCore | 383 } // namespace WebCore |
| 384 | 384 |
| 385 #endif // ENABLE(WEB_AUDIO) | 385 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |