From f47eba7d7d4c6a1d9501e027b63bbab04bb7d417 Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Thu, 30 Mar 2017 23:31:39 +0000 Subject: add NEON optimization --- libopna/opnassg.c | 81 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 17 deletions(-) (limited to 'libopna/opnassg.c') diff --git a/libopna/opnassg.c b/libopna/opnassg.c index ec03437..4a12f76 100644 --- a/libopna/opnassg.c +++ b/libopna/opnassg.c @@ -1,5 +1,6 @@ #include "opnassg.h" #include "oscillo/oscillo.h" +#include /* static const float voltable[32] = { 0.0f, 0.0f, 0x1.ae89f9p-8f, 0x1.000000p-7f, @@ -27,9 +28,6 @@ static const int16_t voltable[32] = { 6494, 7723, 9185, 10922 }; -#define SINCTABLEBIT 7 -#define SINCTABLELEN (1<ch[i].tone_counter = 0; @@ -78,7 +130,7 @@ void opna_ssg_reset(struct opna_ssg *ssg) { } void opna_ssg_resampler_reset(struct opna_ssg_resampler *resampler) { - for (int i = 0; i < SINCTABLELEN; i++) { + for (int i = 0; i < OPNA_SSG_SINCTABLELEN; i++) { resampler->buf[i] = 0; } resampler->index = 0; @@ -215,7 +267,7 @@ void opna_ssg_generate_raw(struct opna_ssg *ssg, int16_t *buf, int samples) { } } -#define BUFINDEX(n) ((((resampler->index)>>1)+n)&(SINCTABLELEN-1)) +#define BUFINDEX(n) ((((resampler->index)>>1)+n)&(OPNA_SSG_SINCTABLELEN-1)) void opna_ssg_mix_55466( struct opna_ssg *ssg, struct opna_ssg_resampler *resampler, @@ -246,18 +298,13 @@ void opna_ssg_mix_55466( resampler->index += 9; } int32_t sample = 0; + resampler->index &= (1u<<(OPNA_SSG_SINCTABLEBIT+1))-1; + memcpy(resampler->buf + OPNA_SSG_SINCTABLELEN*3, resampler->buf, OPNA_SSG_SINCTABLELEN*3*sizeof(*resampler->buf)); + int32_t outbuf[3]; + opna_ssg_sinc_calc_func(resampler->index, resampler->buf, outbuf); for (int ch = 0; ch < 3; ch++) { - int32_t chsample = 0; - for (int j = 0; j < SINCTABLELEN; j++) { - unsigned sincindex = j*2; - if (!(resampler->index&1)) sincindex++; - bool sincsign = sincindex & (1<<(SINCTABLEBIT)); - unsigned sincmask = ((1<<(SINCTABLEBIT))-1); - sincindex = (sincindex & sincmask) ^ (sincsign ? sincmask : 0); - chsample += (resampler->buf[BUFINDEX(j)*3+ch] * sinctable[sincindex])>>2; - } - if (oscillo) oscillo[ch].buf[offset+i] = chsample >> 13; - if (!(ssg->mask & (1<> 15; + if (!(ssg->mask & (1<> 2; } sample >>= 16; sample *= 13000; -- cgit v1.2.3