2012-08-15 01:01:55 -07:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <arm_neon.h>
|
|
|
|
|
|
|
|
#include "AL/al.h"
|
|
|
|
#include "AL/alc.h"
|
|
|
|
#include "alMain.h"
|
|
|
|
#include "alu.h"
|
2014-02-23 21:28:34 -08:00
|
|
|
#include "hrtf.h"
|
2012-08-15 01:01:55 -07:00
|
|
|
|
|
|
|
|
2014-11-23 10:49:54 -08:00
|
|
|
static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2],
|
|
|
|
const ALuint IrSize,
|
|
|
|
ALfloat (*restrict Coeffs)[2],
|
|
|
|
const ALfloat (*restrict CoeffStep)[2],
|
|
|
|
ALfloat left, ALfloat right)
|
|
|
|
{
|
|
|
|
ALuint c;
|
|
|
|
float32x4_t leftright4;
|
|
|
|
{
|
|
|
|
float32x2_t leftright2 = vdup_n_f32(0.0);
|
|
|
|
leftright2 = vset_lane_f32(left, leftright2, 0);
|
|
|
|
leftright2 = vset_lane_f32(right, leftright2, 1);
|
|
|
|
leftright4 = vcombine_f32(leftright2, leftright2);
|
|
|
|
}
|
|
|
|
for(c = 0;c < IrSize;c += 2)
|
|
|
|
{
|
|
|
|
const ALuint o0 = (Offset+c)&HRIR_MASK;
|
|
|
|
const ALuint o1 = (o0+1)&HRIR_MASK;
|
|
|
|
float32x4_t vals = vcombine_f32(vld1_f32((float32_t*)&Values[o0][0]),
|
|
|
|
vld1_f32((float32_t*)&Values[o1][0]));
|
|
|
|
float32x4_t coefs = vld1q_f32((float32_t*)&Coeffs[c][0]);
|
|
|
|
float32x4_t deltas = vld1q_f32(&CoeffStep[c][0]);
|
|
|
|
|
|
|
|
vals = vmlaq_f32(vals, coefs, leftright4);
|
|
|
|
coefs = vaddq_f32(coefs, deltas);
|
|
|
|
|
|
|
|
vst1_f32((float32_t*)&Values[o0][0], vget_low_f32(vals));
|
|
|
|
vst1_f32((float32_t*)&Values[o1][0], vget_high_f32(vals));
|
|
|
|
vst1q_f32(&Coeffs[c][0], coefs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-28 22:27:07 -07:00
|
|
|
static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
|
|
|
|
const ALuint IrSize,
|
|
|
|
ALfloat (*restrict Coeffs)[2],
|
|
|
|
ALfloat left, ALfloat right)
|
2012-08-15 01:01:55 -07:00
|
|
|
{
|
|
|
|
ALuint c;
|
|
|
|
float32x4_t leftright4;
|
|
|
|
{
|
|
|
|
float32x2_t leftright2 = vdup_n_f32(0.0);
|
|
|
|
leftright2 = vset_lane_f32(left, leftright2, 0);
|
|
|
|
leftright2 = vset_lane_f32(right, leftright2, 1);
|
|
|
|
leftright4 = vcombine_f32(leftright2, leftright2);
|
|
|
|
}
|
2012-09-11 01:59:42 -07:00
|
|
|
for(c = 0;c < IrSize;c += 2)
|
2012-08-15 01:01:55 -07:00
|
|
|
{
|
|
|
|
const ALuint o0 = (Offset+c)&HRIR_MASK;
|
|
|
|
const ALuint o1 = (o0+1)&HRIR_MASK;
|
|
|
|
float32x4_t vals = vcombine_f32(vld1_f32((float32_t*)&Values[o0][0]),
|
|
|
|
vld1_f32((float32_t*)&Values[o1][0]));
|
|
|
|
float32x4_t coefs = vld1q_f32((float32_t*)&Coeffs[c][0]);
|
|
|
|
|
|
|
|
vals = vmlaq_f32(vals, coefs, leftright4);
|
|
|
|
|
|
|
|
vst1_f32((float32_t*)&Values[o0][0], vget_low_f32(vals));
|
|
|
|
vst1_f32((float32_t*)&Values[o1][0], vget_high_f32(vals));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-15 01:37:46 -07:00
|
|
|
#define MixHrtf MixHrtf_Neon
|
2016-08-12 05:26:36 -07:00
|
|
|
#define MixDirectHrtf MixDirectHrtf_Neon
|
2012-08-15 01:01:55 -07:00
|
|
|
#include "mixer_inc.c"
|
2015-08-15 01:37:46 -07:00
|
|
|
#undef MixHrtf
|
2014-01-26 01:34:39 -08:00
|
|
|
|
|
|
|
|
2014-08-31 23:46:43 -07:00
|
|
|
void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
|
|
|
|
MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize)
|
2014-01-26 01:34:39 -08:00
|
|
|
{
|
2014-06-13 13:34:19 -07:00
|
|
|
ALfloat gain, step;
|
|
|
|
float32x4_t gain4;
|
2014-01-26 01:34:39 -08:00
|
|
|
ALuint c;
|
|
|
|
|
2014-06-13 13:34:19 -07:00
|
|
|
for(c = 0;c < OutChans;c++)
|
2014-01-26 01:34:39 -08:00
|
|
|
{
|
2014-03-23 06:57:00 -07:00
|
|
|
ALuint pos = 0;
|
2014-06-13 13:34:19 -07:00
|
|
|
gain = Gains[c].Current;
|
|
|
|
step = Gains[c].Step;
|
2014-11-25 02:08:48 -08:00
|
|
|
if(step != 0.0f && Counter > 0)
|
2014-03-23 06:57:00 -07:00
|
|
|
{
|
2015-09-30 17:25:28 -07:00
|
|
|
ALuint minsize = minu(BufferSize, Counter);
|
2016-08-05 18:47:26 -07:00
|
|
|
/* Mix with applying gain steps in aligned multiples of 4. */
|
|
|
|
if(minsize-pos > 3)
|
|
|
|
{
|
|
|
|
float32x4_t step4;
|
|
|
|
gain4 = vsetq_lane_f32(gain, gain4, 0);
|
|
|
|
gain4 = vsetq_lane_f32(gain + step, gain4, 1);
|
|
|
|
gain4 = vsetq_lane_f32(gain + step + step, gain4, 2);
|
|
|
|
gain4 = vsetq_lane_f32(gain + step + step + step, gain4, 3);
|
|
|
|
step4 = vdupq_n_f32(step + step + step + step);
|
|
|
|
do {
|
|
|
|
const float32x4_t val4 = vld1q_f32(&data[pos]);
|
|
|
|
float32x4_t dry4 = vld1q_f32(&OutBuffer[c][OutPos+pos]);
|
|
|
|
dry4 = vmlaq_f32(dry4, val4, gain4);
|
|
|
|
gain4 = vaddq_f32(gain4, step4);
|
|
|
|
vst1q_f32(&OutBuffer[c][OutPos+pos], dry4);
|
|
|
|
pos += 4;
|
|
|
|
} while(minsize-pos > 3);
|
|
|
|
/* NOTE: gain4 now represents the next four gains after the
|
|
|
|
* last four mixed samples, so the lowest element represents
|
|
|
|
* the next gain to apply.
|
|
|
|
*/
|
|
|
|
gain = vgetq_lane_f32(gain4, 0);
|
|
|
|
}
|
|
|
|
/* Mix with applying left over gain steps that aren't aligned multiples of 4. */
|
2015-09-30 17:25:28 -07:00
|
|
|
for(;pos < minsize;pos++)
|
2014-03-23 06:57:00 -07:00
|
|
|
{
|
2014-06-13 13:34:19 -07:00
|
|
|
OutBuffer[c][OutPos+pos] += data[pos]*gain;
|
2014-11-25 02:08:48 -08:00
|
|
|
gain += step;
|
2014-03-23 06:57:00 -07:00
|
|
|
}
|
2014-05-04 00:13:19 -07:00
|
|
|
if(pos == Counter)
|
2014-06-13 13:34:19 -07:00
|
|
|
gain = Gains[c].Target;
|
|
|
|
Gains[c].Current = gain;
|
2015-09-30 17:25:28 -07:00
|
|
|
|
2014-05-03 17:24:46 -07:00
|
|
|
/* Mix until pos is aligned with 4 or the mix is done. */
|
2015-10-18 13:46:52 -07:00
|
|
|
minsize = minu(BufferSize, (pos+3)&~3);
|
2015-09-30 17:25:28 -07:00
|
|
|
for(;pos < minsize;pos++)
|
2014-06-13 13:34:19 -07:00
|
|
|
OutBuffer[c][OutPos+pos] += data[pos]*gain;
|
2014-03-23 06:57:00 -07:00
|
|
|
}
|
|
|
|
|
2014-10-31 16:55:19 -07:00
|
|
|
if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD))
|
2014-01-26 01:34:39 -08:00
|
|
|
continue;
|
2014-06-13 13:34:19 -07:00
|
|
|
gain4 = vdupq_n_f32(gain);
|
2014-03-23 06:57:00 -07:00
|
|
|
for(;BufferSize-pos > 3;pos += 4)
|
2014-01-26 01:34:39 -08:00
|
|
|
{
|
|
|
|
const float32x4_t val4 = vld1q_f32(&data[pos]);
|
|
|
|
float32x4_t dry4 = vld1q_f32(&OutBuffer[c][OutPos+pos]);
|
2015-09-30 13:34:09 -07:00
|
|
|
dry4 = vmlaq_f32(dry4, val4, gain4);
|
2014-01-26 01:34:39 -08:00
|
|
|
vst1q_f32(&OutBuffer[c][OutPos+pos], dry4);
|
|
|
|
}
|
|
|
|
for(;pos < BufferSize;pos++)
|
2014-06-13 13:34:19 -07:00
|
|
|
OutBuffer[c][OutPos+pos] += data[pos]*gain;
|
2014-03-23 16:11:21 -07:00
|
|
|
}
|
2014-01-26 01:34:39 -08:00
|
|
|
}
|
2016-06-01 23:39:13 -07:00
|
|
|
|
2016-09-02 00:29:46 -07:00
|
|
|
void MixRow_Neon(ALfloat *OutBuffer, const ALfloat *Gains, ALfloat (*restrict data)[BUFFERSIZE], ALuint InChans, ALuint BufferSize)
|
2016-06-01 23:39:13 -07:00
|
|
|
{
|
|
|
|
float32x4_t gain4;
|
|
|
|
ALuint c;
|
|
|
|
|
|
|
|
for(c = 0;c < InChans;c++)
|
|
|
|
{
|
|
|
|
ALuint pos = 0;
|
2016-09-02 00:29:46 -07:00
|
|
|
ALfloat gain = Gains[c];
|
2016-06-01 23:39:13 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|