From b7da69510c85b776ba119d69c4c74aa38d412594 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 1 Jun 2016 23:39:13 -0700 Subject: [PATCH] Implement a Neon-enhanced MixRow --- Alc/bformatdec.c | 4 ++++ Alc/mixer_defs.h | 2 ++ Alc/mixer_neon.c | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c index 7da50692..9ebaba27 100644 --- a/Alc/bformatdec.c +++ b/Alc/bformatdec.c @@ -159,6 +159,10 @@ static inline MatrixMixerFunc SelectMixer(void) if((CPUCapFlags&CPU_CAP_SSE)) return MixRow_SSE; #endif +#ifdef HAVE_NEON + if((CPUCapFlags&CPU_CAP_NEON)) + return MixRow_Neon; +#endif return MixRow_C; } diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h index 8d208b9c..8b934c58 100644 --- a/Alc/mixer_defs.h +++ b/Alc/mixer_defs.h @@ -80,5 +80,7 @@ void MixHrtf_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint struct HrtfState *hrtfstate, ALuint BufferSize); void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], struct MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize); +void MixRow_Neon(ALfloat *OutBuffer, const ALfloat *Mtx, ALfloat (*restrict data)[BUFFERSIZE], + ALuint InChans, ALuint BufferSize); #endif /* MIXER_DEFS_H */ diff --git a/Alc/mixer_neon.c b/Alc/mixer_neon.c index 96936ef5..073f62c8 100644 --- a/Alc/mixer_neon.c +++ b/Alc/mixer_neon.c @@ -118,3 +118,28 @@ void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer OutBuffer[c][OutPos+pos] += data[pos]*gain; } } + +void MixRow_Neon(ALfloat *OutBuffer, const ALfloat *Mtx, ALfloat (*restrict data)[BUFFERSIZE], ALuint InChans, ALuint BufferSize) +{ + float32x4_t gain4; + ALuint c; + + for(c = 0;c < InChans;c++) + { + ALuint pos = 0; + ALfloat gain = Mtx[c]; + if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD)) + continue; + + gain4 = vdupq_n_f32(gain); + for(;BufferSize-pos > 3;pos += 4) + { + const float32x4_t val4 = vld1q_f32(&data[c][pos]); + float32x4_t dry4 = vld1q_f32(&OutBuffer[pos]); + dry4 = vmlaq_f32(dry4, val4, gain4); + vst1q_f32(&OutBuffer[pos], dry4); + } + for(;pos < BufferSize;pos++) + OutBuffer[pos] += data[c][pos]*gain; + } +} -- 2.11.4.GIT