Skip to content

Commit

Permalink
Merge mozilla-central to autoland.
Browse files Browse the repository at this point in the history
  • Loading branch information
CosminSabou committed Jan 13, 2023
2 parents ff398a0 + 09ffc3f commit a4f2cf6
Show file tree
Hide file tree
Showing 80 changed files with 843 additions and 27,991 deletions.
2 changes: 0 additions & 2 deletions build/moz.configure/toolchain.configure
Original file line number Diff line number Diff line change
Expand Up @@ -3091,5 +3091,3 @@ set_config("MMX_FLAGS", ["-mmmx"])
set_config("SSE_FLAGS", ["-msse"])
set_config("SSE2_FLAGS", ["-msse2"])
set_config("SSSE3_FLAGS", ["-mssse3"])
set_config("SSE4_2_FLAGS", ["-msse4.2"])
set_config("FMA_FLAGS", ["-mfma"])
155 changes: 64 additions & 91 deletions dom/media/webaudio/AudioNodeEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@
#include "mozilla/AbstractThread.h"
#ifdef USE_NEON
# include "mozilla/arm.h"
# include "AudioNodeEngineGeneric.h"
# include "AudioNodeEngineNEON.h"
#endif
#ifdef USE_SSE2
# include "mozilla/SSE.h"
# include "AudioNodeEngineGeneric.h"
#endif
#if defined(USE_SSE42) && defined(USE_FMA3)
# include "mozilla/SSE.h"
# include "AudioNodeEngineGeneric.h"
# include "AlignmentUtils.h"
# include "AudioNodeEngineSSE2.h"
#endif
#include "AudioBlock.h"
#include "Tracing.h"
Expand Down Expand Up @@ -70,25 +67,39 @@ void AudioBufferAddWithScale(const float* aInput, float aScale, float* aOutput,
uint32_t aSize) {
#ifdef USE_NEON
if (mozilla::supports_neon()) {
Engine<xsimd::neon>::AudioBufferAddWithScale(aInput, aScale, aOutput,
aSize);
AudioBufferAddWithScale_NEON(aInput, aScale, aOutput, aSize);
return;
}
#endif

#ifdef USE_SSE2
if (mozilla::supports_sse2()) {
# if defined(USE_SSE42) && defined(USE_FMA3)
if (mozilla::supports_fma3() && mozilla::supports_sse4_2()) {
Engine<xsimd::fma3<xsimd::sse4_2>>::AudioBufferAddWithScale(
aInput, aScale, aOutput, aSize);
} else
# endif
{
Engine<xsimd::sse2>::AudioBufferAddWithScale(aInput, aScale, aOutput,
aSize);
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;
}
return;
}
#endif

Expand Down Expand Up @@ -116,16 +127,14 @@ void AudioBlockCopyChannelWithScale(const float* aInput, float aScale,
} else {
#ifdef USE_NEON
if (mozilla::supports_neon()) {
Engine<xsimd::neon>::AudioBlockCopyChannelWithScale(aInput, aScale,
aOutput);
AudioBlockCopyChannelWithScale_NEON(aInput, aScale, aOutput);
return;
}
#endif

#ifdef USE_SSE2
if (mozilla::supports_sse2()) {
Engine<xsimd::sse2>::AudioBlockCopyChannelWithScale(aInput, aScale,
aOutput);
AudioBlockCopyChannelWithScale_SSE(aInput, aScale, aOutput);
return;
}
#endif
Expand All @@ -138,24 +147,9 @@ void AudioBlockCopyChannelWithScale(const float* aInput, float aScale,

void BufferComplexMultiply(const float* aInput, const float* aScale,
float* aOutput, uint32_t aSize) {
#ifdef USE_NEON
if (mozilla::supports_neon()) {
Engine<xsimd::neon>::BufferComplexMultiply(aInput, aScale, aOutput, aSize);
return;
}
#endif
#ifdef USE_SSE2
if (mozilla::supports_sse()) {
# if defined(USE_SSE42) && defined(USE_FMA3)
if (mozilla::supports_fma3() && mozilla::supports_sse4_2()) {
Engine<xsimd::fma3<xsimd::sse4_2>>::BufferComplexMultiply(aInput, aScale,
aOutput, aSize);
} else
# endif
{
Engine<xsimd::sse2>::BufferComplexMultiply(aInput, aScale, aOutput,
aSize);
}
BufferComplexMultiply_SSE(aInput, aScale, aOutput, aSize);
return;
}
#endif
Expand Down Expand Up @@ -188,16 +182,14 @@ void AudioBlockCopyChannelWithScale(const float aInput[WEBAUDIO_BLOCK_SIZE],
float aOutput[WEBAUDIO_BLOCK_SIZE]) {
#ifdef USE_NEON
if (mozilla::supports_neon()) {
Engine<xsimd::neon>::AudioBlockCopyChannelWithScale(aInput, aScale,
aOutput);
AudioBlockCopyChannelWithScale_NEON(aInput, aScale, aOutput);
return;
}
#endif

#ifdef USE_SSE2
if (mozilla::supports_sse2()) {
Engine<xsimd::sse2>::AudioBlockCopyChannelWithScale(aInput, aScale,
aOutput);
AudioBlockCopyChannelWithScale_SSE(aInput, aScale, aOutput);
return;
}
#endif
Expand All @@ -222,14 +214,14 @@ void AudioBufferInPlaceScale(float* aBlock, float aScale, uint32_t aSize) {
}
#ifdef USE_NEON
if (mozilla::supports_neon()) {
Engine<xsimd::neon>::AudioBufferInPlaceScale(aBlock, aScale, aSize);
AudioBufferInPlaceScale_NEON(aBlock, aScale, aSize);
return;
}
#endif

#ifdef USE_SSE2
if (mozilla::supports_sse2()) {
Engine<xsimd::sse2>::AudioBufferInPlaceScale(aBlock, aScale, aSize);
AudioBufferInPlaceScale_SSE(aBlock, aScale, aSize);
return;
}
#endif
Expand All @@ -242,14 +234,14 @@ void AudioBufferInPlaceScale(float* aBlock, float aScale, uint32_t aSize) {
void AudioBufferInPlaceScale(float* aBlock, float* aScale, uint32_t aSize) {
#ifdef USE_NEON
if (mozilla::supports_neon()) {
Engine<xsimd::neon>::AudioBufferInPlaceScale(aBlock, aScale, aSize);
AudioBufferInPlaceScale_NEON(aBlock, aScale, aSize);
return;
}
#endif

#ifdef USE_SSE2
if (mozilla::supports_sse2()) {
Engine<xsimd::sse2>::AudioBufferInPlaceScale(aBlock, aScale, aSize);
AudioBufferInPlaceScale_SSE(aBlock, aScale, aSize);
return;
}
#endif
Expand Down Expand Up @@ -283,24 +275,16 @@ void AudioBlockPanStereoToStereo(const float aInputL[WEBAUDIO_BLOCK_SIZE],
float aOutputR[WEBAUDIO_BLOCK_SIZE]) {
#ifdef USE_NEON
if (mozilla::supports_neon()) {
Engine<xsimd::neon>::AudioBlockPanStereoToStereo(
aInputL, aInputR, aGainL, aGainR, aIsOnTheLeft, aOutputL, aOutputR);
AudioBlockPanStereoToStereo_NEON(aInputL, aInputR, aGainL, aGainR,
aIsOnTheLeft, aOutputL, aOutputR);
return;
}
#endif

#ifdef USE_SSE2
if (mozilla::supports_sse2()) {
# if defined(USE_SSE42) && defined(USE_FMA3)
if (mozilla::supports_fma3() && mozilla::supports_sse4_2()) {
Engine<xsimd::fma3<xsimd::sse4_2>>::AudioBlockPanStereoToStereo(
aInputL, aInputR, aGainL, aGainR, aIsOnTheLeft, aOutputL, aOutputR);
} else
# endif
{
Engine<xsimd::sse2>::AudioBlockPanStereoToStereo(
aInputL, aInputR, aGainL, aGainR, aIsOnTheLeft, aOutputL, aOutputR);
}
AudioBlockPanStereoToStereo_SSE(aInputL, aInputR, aGainL, aGainR,
aIsOnTheLeft, aOutputL, aOutputR);
return;
}
#endif
Expand Down Expand Up @@ -329,24 +313,8 @@ void AudioBlockPanStereoToStereo(const float aInputL[WEBAUDIO_BLOCK_SIZE],
float aOutputR[WEBAUDIO_BLOCK_SIZE]) {
#ifdef USE_NEON
if (mozilla::supports_neon()) {
Engine<xsimd::neon>::AudioBlockPanStereoToStereo(
aInputL, aInputR, aGainL, aGainR, aIsOnTheLeft, aOutputL, aOutputR);
return;
}
#endif

#ifdef USE_SSE2
if (mozilla::supports_sse2()) {
# if defined(USE_SSE42) && defined(USE_FMA3)
if (mozilla::supports_fma3() && mozilla::supports_sse4_2()) {
Engine<xsimd::fma3<xsimd::sse2>>::AudioBlockPanStereoToStereo(
aInputL, aInputR, aGainL, aGainR, aIsOnTheLeft, aOutputL, aOutputR);
} else
# endif
{
Engine<xsimd::sse2>::AudioBlockPanStereoToStereo(
aInputL, aInputR, aGainL, aGainR, aIsOnTheLeft, aOutputL, aOutputR);
}
AudioBlockPanStereoToStereo_NEON(aInputL, aInputR, aGainL, aGainR,
aIsOnTheLeft, aOutputL, aOutputR);
return;
}
#endif
Expand All @@ -364,27 +332,32 @@ void AudioBlockPanStereoToStereo(const float aInputL[WEBAUDIO_BLOCK_SIZE],
}

float AudioBufferSumOfSquares(const float* aInput, uint32_t aLength) {
#ifdef USE_NEON
if (mozilla::supports_neon()) {
return Engine<xsimd::neon>::AudioBufferSumOfSquares(aInput, aLength);
}
#endif
float sum = 0.0f;

#ifdef USE_SSE2
if (mozilla::supports_sse()) {
# if defined(USE_SSE42) && defined(USE_FMA3)
if (mozilla::supports_fma3() && mozilla::supports_sse4_2()) {
return Engine<xsimd::fma3<xsimd::sse4_2>>::AudioBufferSumOfSquares(
aInput, aLength);
} else
# endif
{
return Engine<xsimd::sse2>::AudioBufferSumOfSquares(aInput, aLength);
const float* alignedInput = ALIGNED16(aInput);

// use scalar operations for any unaligned data at the beginning
while (aInput != alignedInput) {
if (!aLength) {
return sum;
}
sum += *aInput * *aInput;
++aInput;
--aLength;
}

uint32_t vLength = (aLength >> 4) << 4;
sum += AudioBufferSumOfSquares_SSE(alignedInput, vLength);

// adjust aInput and aLength to use scalar operations for any
// remaining values
aInput = alignedInput + vLength;
aLength -= vLength;
}
#endif

float sum = 0.f;
while (aLength--) {
sum += *aInput * *aInput;
++aInput;
Expand All @@ -395,7 +368,7 @@ float AudioBufferSumOfSquares(const float* aInput, uint32_t aLength) {
void NaNToZeroInPlace(float* aSamples, size_t aCount) {
#ifdef USE_SSE2
if (mozilla::supports_sse2()) {
Engine<xsimd::sse2>::NaNToZeroInPlace(aSamples, aCount);
NaNToZeroInPlace_SSE(aSamples, aCount);
return;
}
#endif
Expand Down
Loading

0 comments on commit a4f2cf6

Please sign in to comment.