diff options
author | Chris Robinson <[email protected]> | 2018-03-14 17:21:19 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-03-14 17:27:41 -0700 |
commit | 7c0e68a33e1d25dfe4676f600c072e0f3edc2853 (patch) | |
tree | 755f9594a273529d85aa8556662327ba9540e182 /Alc/mixer_c.c | |
parent | f65e83c3499ed26ee3dea4b0a1ca0282d47ae7cc (diff) |
Store the filter history in local variables
Despite being marked as restrict (and const for src) to mark the pointers as
being non-aliased, it seems the compiler optimizes better this way.
Diffstat (limited to 'Alc/mixer_c.c')
-rw-r--r-- | Alc/mixer_c.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c index f8c3c833..2346080a 100644 --- a/Alc/mixer_c.c +++ b/Alc/mixer_c.c @@ -97,26 +97,24 @@ void ALfilterState_processC(ALfilterState *filter, ALfloat *restrict dst, const ALsizei i; if(LIKELY(numsamples > 1)) { - dst[0] = filter->b0 * src[0] + - filter->b1 * filter->x[0] + - filter->b2 * filter->x[1] - - filter->a1 * filter->y[0] - - filter->a2 * filter->y[1]; - dst[1] = filter->b0 * src[1] + - filter->b1 * src[0] + - filter->b2 * filter->x[0] - - filter->a1 * dst[0] - - filter->a2 * filter->y[0]; - for(i = 2;i < numsamples;i++) - dst[i] = filter->b0 * src[i] + - filter->b1 * src[i-1] + - filter->b2 * src[i-2] - - filter->a1 * dst[i-1] - - filter->a2 * dst[i-2]; - filter->x[0] = src[i-1]; - filter->x[1] = src[i-2]; - filter->y[0] = dst[i-1]; - filter->y[1] = dst[i-2]; + ALfloat x0 = filter->x[0]; + ALfloat x1 = filter->x[1]; + ALfloat y0 = filter->y[0]; + ALfloat y1 = filter->y[1]; + + for(i = 0;i < numsamples;i++) + { + dst[i] = filter->b0* src[i] + + filter->b1*x0 + filter->b2*x1 - + filter->a1*y0 - filter->a2*y1; + y1 = y0; y0 = dst[i]; + x1 = x0; x0 = src[i]; + } + + filter->x[0] = x0; + filter->x[1] = x1; + filter->y[0] = y0; + filter->y[1] = y1; } else if(numsamples == 1) { |