diff options
author | Chris Robinson <[email protected]> | 2018-09-17 01:43:02 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-09-17 04:07:56 -0700 |
commit | 7f4441ffbe072c45ea5a141fc126d81095fe7fca (patch) | |
tree | e91a7f1194bb377bed9c226ecdb0b14e62ae41bb /Alc/mixer | |
parent | 8bacb5dfb8ef910586fcf5b5cd89526ec81061e8 (diff) |
Handle the bsinc C resampler like the others
Diffstat (limited to 'Alc/mixer')
-rw-r--r-- | Alc/mixer/mixer_c.c | 79 | ||||
-rw-r--r-- | Alc/mixer/mixer_neon.c | 2 | ||||
-rw-r--r-- | Alc/mixer/mixer_sse.c | 2 |
3 files changed, 36 insertions, 47 deletions
diff --git a/Alc/mixer/mixer_c.c b/Alc/mixer/mixer_c.c index 25149e00..2dcd6c6b 100644 --- a/Alc/mixer/mixer_c.c +++ b/Alc/mixer/mixer_c.c @@ -9,12 +9,37 @@ #include "defs.h" -static inline ALfloat do_point(const ALfloat *restrict vals, ALsizei UNUSED(frac)) +static inline ALfloat do_point(const InterpState* UNUSED(state), const ALfloat *restrict vals, ALsizei UNUSED(frac)) { return vals[0]; } -static inline ALfloat do_lerp(const ALfloat *restrict vals, ALsizei frac) +static inline ALfloat do_lerp(const InterpState* UNUSED(state), const ALfloat *restrict vals, ALsizei frac) { return lerp(vals[0], vals[1], frac * (1.0f/FRACTIONONE)); } -static inline ALfloat do_cubic(const ALfloat *restrict vals, ALsizei frac) +static inline ALfloat do_cubic(const InterpState* UNUSED(state), const ALfloat *restrict vals, ALsizei frac) { return cubic(vals[0], vals[1], vals[2], vals[3], frac * (1.0f/FRACTIONONE)); } +static inline ALfloat do_bsinc(const InterpState *state, const ALfloat *restrict vals, ALsizei frac) +{ + const ALfloat *fil, *scd, *phd, *spd; + ALsizei j_f, pi; + ALfloat pf, r; + + ASSUME(state->bsinc.m > 0); + + // Calculate the phase index and factor. +#define FRAC_PHASE_BITDIFF (FRACTIONBITS-BSINC_PHASE_BITS) + pi = frac >> FRAC_PHASE_BITDIFF; + pf = (frac & ((1<<FRAC_PHASE_BITDIFF)-1)) * (1.0f/(1<<FRAC_PHASE_BITDIFF)); +#undef FRAC_PHASE_BITDIFF + + fil = ASSUME_ALIGNED(state->bsinc.filter + state->bsinc.m*pi*4, 16); + scd = ASSUME_ALIGNED(fil + state->bsinc.m, 16); + phd = ASSUME_ALIGNED(scd + state->bsinc.m, 16); + spd = ASSUME_ALIGNED(phd + state->bsinc.m, 16); + + // Apply the scale and phase interpolated filter. + r = 0.0f; + for(j_f = 0;j_f < state->bsinc.m;j_f++) + r += (fil[j_f] + state->bsinc.sf*scd[j_f] + pf*(phd[j_f] + state->bsinc.sf*spd[j_f])) * vals[j_f]; + return r; +} const ALfloat *Resample_copy_C(const InterpState* UNUSED(state), const ALfloat *restrict src, ALsizei UNUSED(frac), ALint UNUSED(increment), @@ -30,16 +55,19 @@ const ALfloat *Resample_copy_C(const InterpState* UNUSED(state), } #define DECL_TEMPLATE(Tag, Sampler, O) \ -const ALfloat *Resample_##Tag##_C(const InterpState* UNUSED(state), \ +const ALfloat *Resample_##Tag##_C(const InterpState *state, \ const ALfloat *restrict src, ALsizei frac, ALint increment, \ ALfloat *restrict dst, ALsizei numsamples) \ { \ + const InterpState istate = *state; \ ALsizei i; \ \ + ASSUME(numsamples > 0); \ + \ src -= O; \ for(i = 0;i < numsamples;i++) \ { \ - dst[i] = Sampler(src, frac); \ + dst[i] = Sampler(&istate, src, frac); \ \ frac += increment; \ src += frac>>FRACTIONBITS; \ @@ -51,49 +79,10 @@ const ALfloat *Resample_##Tag##_C(const InterpState* UNUSED(state), \ DECL_TEMPLATE(point, do_point, 0) DECL_TEMPLATE(lerp, do_lerp, 0) DECL_TEMPLATE(cubic, do_cubic, 1) +DECL_TEMPLATE(bsinc, do_bsinc, istate.bsinc.l) #undef DECL_TEMPLATE -const ALfloat *Resample_bsinc_C(const InterpState *state, const ALfloat *restrict src, - ALsizei frac, ALint increment, ALfloat *restrict dst, - ALsizei dstlen) -{ - const ALfloat *fil, *scd, *phd, *spd; - const ALfloat *const filter = state->bsinc.filter; - const ALfloat sf = state->bsinc.sf; - const ALsizei m = state->bsinc.m; - ALsizei j_f, pi, i; - ALfloat pf, r; - - ASSUME(m > 0); - - src += state->bsinc.l; - for(i = 0;i < dstlen;i++) - { - // Calculate the phase index and factor. -#define FRAC_PHASE_BITDIFF (FRACTIONBITS-BSINC_PHASE_BITS) - pi = frac >> FRAC_PHASE_BITDIFF; - pf = (frac & ((1<<FRAC_PHASE_BITDIFF)-1)) * (1.0f/(1<<FRAC_PHASE_BITDIFF)); -#undef FRAC_PHASE_BITDIFF - - fil = ASSUME_ALIGNED(filter + m*pi*4, 16); - scd = ASSUME_ALIGNED(fil + m, 16); - phd = ASSUME_ALIGNED(scd + m, 16); - spd = ASSUME_ALIGNED(phd + m, 16); - - // Apply the scale and phase interpolated filter. - r = 0.0f; - for(j_f = 0;j_f < m;j_f++) - r += (fil[j_f] + sf*scd[j_f] + pf*(phd[j_f] + sf*spd[j_f])) * src[j_f]; - dst[i] = r; - - frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; - } - return dst; -} - static inline void ApplyCoeffs(ALsizei Offset, ALfloat (*restrict Values)[2], const ALsizei IrSize, diff --git a/Alc/mixer/mixer_neon.c b/Alc/mixer/mixer_neon.c index db61fd41..0b8996fd 100644 --- a/Alc/mixer/mixer_neon.c +++ b/Alc/mixer/mixer_neon.c @@ -82,7 +82,7 @@ const ALfloat *Resample_bsinc_Neon(const InterpState *state, ASSUME(m > 0); ASSUME(dstlen > 0); - src += state->bsinc.l; + src -= state->bsinc.l; for(i = 0;i < dstlen;i++) { // Calculate the phase index and factor. diff --git a/Alc/mixer/mixer_sse.c b/Alc/mixer/mixer_sse.c index d7d54993..78cf26f1 100644 --- a/Alc/mixer/mixer_sse.c +++ b/Alc/mixer/mixer_sse.c @@ -27,7 +27,7 @@ const ALfloat *Resample_bsinc_SSE(const InterpState *state, const ALfloat *restr ASSUME(m > 0); ASSUME(dstlen > 0); - src += state->bsinc.l; + src -= state->bsinc.l; for(i = 0;i < dstlen;i++) { // Calculate the phase index and factor. |