| 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 19 matching lines...) Expand all Loading... |
| 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(MACOSX) | 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 #include "wtf/CPU.h" |
| 40 | 41 |
| 41 namespace WebCore { | 42 namespace WebCore { |
| 42 | 43 |
| 43 using namespace VectorMath; | 44 using namespace VectorMath; |
| 44 | 45 |
| 45 DirectConvolver::DirectConvolver(size_t inputBlockSize) | 46 DirectConvolver::DirectConvolver(size_t inputBlockSize) |
| 46 : m_inputBlockSize(inputBlockSize) | 47 : m_inputBlockSize(inputBlockSize) |
| 47 #if USE(WEBAUDIO_IPP) | 48 #if USE(WEBAUDIO_IPP) |
| 48 , m_overlayBuffer(inputBlockSize) | 49 , m_overlayBuffer(inputBlockSize) |
| 49 #endif // USE(WEBAUDIO_IPP) | 50 #endif // USE(WEBAUDIO_IPP) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 84 |
| 84 vadd(outputBuffer, 1, overlayBuffer, 1, destP, 1, framesToProcess); | 85 vadd(outputBuffer, 1, overlayBuffer, 1, destP, 1, framesToProcess); |
| 85 memcpy(overlayBuffer, outputBuffer + m_inputBlockSize, sizeof(float) * kerne
lSize); | 86 memcpy(overlayBuffer, outputBuffer + m_inputBlockSize, sizeof(float) * kerne
lSize); |
| 86 #else | 87 #else |
| 87 float* inputP = m_buffer.data() + m_inputBlockSize; | 88 float* inputP = m_buffer.data() + m_inputBlockSize; |
| 88 | 89 |
| 89 // Copy samples to 2nd half of input buffer. | 90 // Copy samples to 2nd half of input buffer. |
| 90 memcpy(inputP, sourceP, sizeof(float) * framesToProcess); | 91 memcpy(inputP, sourceP, sizeof(float) * framesToProcess); |
| 91 | 92 |
| 92 #if OS(MACOSX) | 93 #if OS(MACOSX) |
| 93 #if defined(__i386__) | 94 #if CPU(X86) |
| 94 conv(inputP - kernelSize + 1, 1, kernelP + kernelSize - 1, -1, destP, 1, fra
mesToProcess, kernelSize); | 95 conv(inputP - kernelSize + 1, 1, kernelP + kernelSize - 1, -1, destP, 1, fra
mesToProcess, kernelSize); |
| 95 #else | 96 #else |
| 96 vDSP_conv(inputP - kernelSize + 1, 1, kernelP + kernelSize - 1, -1, destP, 1
, framesToProcess, kernelSize); | 97 vDSP_conv(inputP - kernelSize + 1, 1, kernelP + kernelSize - 1, -1, destP, 1
, framesToProcess, kernelSize); |
| 97 #endif // defined(__i386__) | 98 #endif // CPU(X86) |
| 98 #else | 99 #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. | 100 // 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 \ | 101 #define CONVOLVE_ONE_SAMPLE \ |
| 101 sum += inputP[i - j] * kernelP[j]; \ | 102 sum += inputP[i - j] * kernelP[j]; \ |
| 102 j++; | 103 j++; |
| 103 | 104 |
| 104 size_t i = 0; | 105 size_t i = 0; |
| 105 while (i < framesToProcess) { | 106 while (i < framesToProcess) { |
| 106 size_t j = 0; | 107 size_t j = 0; |
| 107 float sum = 0; | 108 float sum = 0; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 { | 377 { |
| 377 m_buffer.zero(); | 378 m_buffer.zero(); |
| 378 #if USE(WEBAUDIO_IPP) | 379 #if USE(WEBAUDIO_IPP) |
| 379 m_overlayBuffer.zero(); | 380 m_overlayBuffer.zero(); |
| 380 #endif // USE(WEBAUDIO_IPP) | 381 #endif // USE(WEBAUDIO_IPP) |
| 381 } | 382 } |
| 382 | 383 |
| 383 } // namespace WebCore | 384 } // namespace WebCore |
| 384 | 385 |
| 385 #endif // ENABLE(WEB_AUDIO) | 386 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |