12 static inline void ApplyCoeffsStep(ALuint Offset
, ALfloat (*restrict Values
)[2],
14 ALfloat (*restrict Coeffs
)[2],
15 const ALfloat (*restrict CoeffStep
)[2],
16 ALfloat left
, ALfloat right
)
19 float32x4_t leftright4
;
21 float32x2_t leftright2
= vdup_n_f32(0.0);
22 leftright2
= vset_lane_f32(left
, leftright2
, 0);
23 leftright2
= vset_lane_f32(right
, leftright2
, 1);
24 leftright4
= vcombine_f32(leftright2
, leftright2
);
26 for(c
= 0;c
< IrSize
;c
+= 2)
28 const ALuint o0
= (Offset
+c
)&HRIR_MASK
;
29 const ALuint o1
= (o0
+1)&HRIR_MASK
;
30 float32x4_t vals
= vcombine_f32(vld1_f32((float32_t
*)&Values
[o0
][0]),
31 vld1_f32((float32_t
*)&Values
[o1
][0]));
32 float32x4_t coefs
= vld1q_f32((float32_t
*)&Coeffs
[c
][0]);
33 float32x4_t deltas
= vld1q_f32(&CoeffStep
[c
][0]);
35 vals
= vmlaq_f32(vals
, coefs
, leftright4
);
36 coefs
= vaddq_f32(coefs
, deltas
);
38 vst1_f32((float32_t
*)&Values
[o0
][0], vget_low_f32(vals
));
39 vst1_f32((float32_t
*)&Values
[o1
][0], vget_high_f32(vals
));
40 vst1q_f32(&Coeffs
[c
][0], coefs
);
44 static inline void ApplyCoeffs(ALuint Offset
, ALfloat (*restrict Values
)[2],
46 ALfloat (*restrict Coeffs
)[2],
47 ALfloat left
, ALfloat right
)
50 float32x4_t leftright4
;
52 float32x2_t leftright2
= vdup_n_f32(0.0);
53 leftright2
= vset_lane_f32(left
, leftright2
, 0);
54 leftright2
= vset_lane_f32(right
, leftright2
, 1);
55 leftright4
= vcombine_f32(leftright2
, leftright2
);
57 for(c
= 0;c
< IrSize
;c
+= 2)
59 const ALuint o0
= (Offset
+c
)&HRIR_MASK
;
60 const ALuint o1
= (o0
+1)&HRIR_MASK
;
61 float32x4_t vals
= vcombine_f32(vld1_f32((float32_t
*)&Values
[o0
][0]),
62 vld1_f32((float32_t
*)&Values
[o1
][0]));
63 float32x4_t coefs
= vld1q_f32((float32_t
*)&Coeffs
[c
][0]);
65 vals
= vmlaq_f32(vals
, coefs
, leftright4
);
67 vst1_f32((float32_t
*)&Values
[o0
][0], vget_low_f32(vals
));
68 vst1_f32((float32_t
*)&Values
[o1
][0], vget_high_f32(vals
));
72 #define MixHrtf MixHrtf_Neon
73 #define MixDirectHrtf MixDirectHrtf_Neon
74 #include "mixer_inc.c"
78 void Mix_Neon(const ALfloat
*data
, ALuint OutChans
, ALfloat (*restrict OutBuffer
)[BUFFERSIZE
],
79 ALfloat
*CurrentGains
, const ALfloat
*TargetGains
, ALuint Counter
, ALuint OutPos
,
82 ALfloat gain
, delta
, step
;
86 delta
= (Counter
> 0) ? 1.0f
/(ALfloat
)Counter
: 0.0f
;
88 for(c
= 0;c
< OutChans
;c
++)
91 gain
= CurrentGains
[c
];
92 step
= (TargetGains
[c
] - gain
) * delta
;
93 if(fabsf(step
) > FLT_EPSILON
)
95 ALuint minsize
= minu(BufferSize
, Counter
);
96 /* Mix with applying gain steps in aligned multiples of 4. */
100 gain4
= vsetq_lane_f32(gain
, gain4
, 0);
101 gain4
= vsetq_lane_f32(gain
+ step
, gain4
, 1);
102 gain4
= vsetq_lane_f32(gain
+ step
+ step
, gain4
, 2);
103 gain4
= vsetq_lane_f32(gain
+ step
+ step
+ step
, gain4
, 3);
104 step4
= vdupq_n_f32(step
+ step
+ step
+ step
);
106 const float32x4_t val4
= vld1q_f32(&data
[pos
]);
107 float32x4_t dry4
= vld1q_f32(&OutBuffer
[c
][OutPos
+pos
]);
108 dry4
= vmlaq_f32(dry4
, val4
, gain4
);
109 gain4
= vaddq_f32(gain4
, step4
);
110 vst1q_f32(&OutBuffer
[c
][OutPos
+pos
], dry4
);
112 } while(minsize
-pos
> 3);
113 /* NOTE: gain4 now represents the next four gains after the
114 * last four mixed samples, so the lowest element represents
115 * the next gain to apply.
117 gain
= vgetq_lane_f32(gain4
, 0);
119 /* Mix with applying left over gain steps that aren't aligned multiples of 4. */
120 for(;pos
< minsize
;pos
++)
122 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*gain
;
126 gain
= TargetGains
[c
];
127 CurrentGains
[c
] = gain
;
129 /* Mix until pos is aligned with 4 or the mix is done. */
130 minsize
= minu(BufferSize
, (pos
+3)&~3);
131 for(;pos
< minsize
;pos
++)
132 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*gain
;
135 if(!(fabsf(gain
) > GAIN_SILENCE_THRESHOLD
))
137 gain4
= vdupq_n_f32(gain
);
138 for(;BufferSize
-pos
> 3;pos
+= 4)
140 const float32x4_t val4
= vld1q_f32(&data
[pos
]);
141 float32x4_t dry4
= vld1q_f32(&OutBuffer
[c
][OutPos
+pos
]);
142 dry4
= vmlaq_f32(dry4
, val4
, gain4
);
143 vst1q_f32(&OutBuffer
[c
][OutPos
+pos
], dry4
);
145 for(;pos
< BufferSize
;pos
++)
146 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*gain
;
150 void MixRow_Neon(ALfloat
*OutBuffer
, const ALfloat
*Gains
, const ALfloat (*restrict data
)[BUFFERSIZE
], ALuint InChans
, ALuint InPos
, ALuint BufferSize
)
155 for(c
= 0;c
< InChans
;c
++)
158 ALfloat gain
= Gains
[c
];
159 if(!(fabsf(gain
) > GAIN_SILENCE_THRESHOLD
))
162 gain4
= vdupq_n_f32(gain
);
163 for(;BufferSize
-pos
> 3;pos
+= 4)
165 const float32x4_t val4
= vld1q_f32(&data
[c
][InPos
+pos
]);
166 float32x4_t dry4
= vld1q_f32(&OutBuffer
[pos
]);
167 dry4
= vmlaq_f32(dry4
, val4
, gain4
);
168 vst1q_f32(&OutBuffer
[pos
], dry4
);
170 for(;pos
< BufferSize
;pos
++)
171 OutBuffer
[pos
] += data
[c
][InPos
+pos
]*gain
;