void AudioBufferAddWithScale(const float* aInput, float aScale, float* aOutput, uint32_t aSize) { #ifdef BUILD_ARM_NEON if (mozilla::supports_neon()) { AudioBufferAddWithScale_NEON(aInput, aScale, aOutput, aSize); return; } #endif #ifdef USE_SSE2 if (mozilla::supports_sse2()) { AudioBufferAddWithScale_SSE(aInput, aScale, aOutput, aSize); return; } #endif if (aScale == 1.0f) { for (uint32_t i = 0; i < aSize; ++i) { aOutput[i] += aInput[i]; } } else { for (uint32_t i = 0; i < aSize; ++i) { aOutput[i] += aInput[i]*aScale; } } }
void AudioBufferAddWithScale(const float* aInput, float aScale, float* aOutput, uint32_t aSize) { #ifdef BUILD_ARM_NEON if (mozilla::supports_neon()) { AudioBufferAddWithScale_NEON(aInput, aScale, aOutput, aSize); return; } #endif #ifdef USE_SSE2 if (mozilla::supports_sse2()) { if (aScale == 1.0f) { while (aSize && (!IS_ALIGNED16(aInput) || !IS_ALIGNED16(aOutput))) { *aOutput += *aInput; ++aOutput; ++aInput; --aSize; } } else { while (aSize && (!IS_ALIGNED16(aInput) || !IS_ALIGNED16(aOutput))) { *aOutput += *aInput*aScale; ++aOutput; ++aInput; --aSize; } } // we need to round aSize down to the nearest multiple of 16 uint32_t alignedSize = aSize & ~0x0F; if (alignedSize > 0) { AudioBufferAddWithScale_SSE(aInput, aScale, aOutput, alignedSize); // adjust parameters for use with scalar operations below aInput += alignedSize; aOutput += alignedSize; aSize -= alignedSize; } } #endif if (aScale == 1.0f) { for (uint32_t i = 0; i < aSize; ++i) { aOutput[i] += aInput[i]; } } else { for (uint32_t i = 0; i < aSize; ++i) { aOutput[i] += aInput[i]*aScale; } } }