aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-03-29 11:18:16 -0700
committerChris Robinson <[email protected]>2018-03-29 16:11:46 -0700
commit880d5550600a77fef23d8ade9cd8a9137564bea1 (patch)
tree72d04f96124c57871538e7c66f131abfbd061df6 /Alc
parent5523913a814f9e06e5034d32574a21e7a278e9ea (diff)
Combine two loops
Diffstat (limited to 'Alc')
-rw-r--r--Alc/bformatdec.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c
index ff0cd657..7ab315c3 100644
--- a/Alc/bformatdec.c
+++ b/Alc/bformatdec.c
@@ -34,43 +34,41 @@ void bandsplit_clear(BandSplitter *splitter)
void bandsplit_process(BandSplitter *splitter, ALfloat *restrict hpout, ALfloat *restrict lpout,
const ALfloat *input, ALsizei count)
{
- ALfloat coeff, d, x;
- ALfloat z1, z2;
+ ALfloat lp_coeff, hp_coeff, lp_y, hp_y, d;
+ ALfloat lp_z1, lp_z2, hp_z1;
ALsizei i;
- coeff = splitter->coeff*0.5f + 0.5f;
- z1 = splitter->lp_z1;
- z2 = splitter->lp_z2;
+ hp_coeff = splitter->coeff;
+ lp_coeff = splitter->coeff*0.5f + 0.5f;
+ lp_z1 = splitter->lp_z1;
+ lp_z2 = splitter->lp_z2;
+ hp_z1 = splitter->hp_z1;
for(i = 0;i < count;i++)
{
- x = input[i];
+ ALfloat in = input[i];
- d = (x - z1) * coeff;
- x = z1 + d;
- z1 = x + d;
+ /* Low-pass sample processing. */
+ d = (in - lp_z1) * lp_coeff;
+ lp_y = lp_z1 + d;
+ lp_z1 = lp_y + d;
- d = (x - z2) * coeff;
- x = z2 + d;
- z2 = x + d;
+ d = (lp_y - lp_z2) * lp_coeff;
+ lp_y = lp_z2 + d;
+ lp_z2 = lp_y + d;
- lpout[i] = x;
- }
- splitter->lp_z1 = z1;
- splitter->lp_z2 = z2;
+ lpout[i] = lp_y;
- coeff = splitter->coeff;
- z1 = splitter->hp_z1;
- for(i = 0;i < count;i++)
- {
- x = input[i];
-
- d = x - coeff*z1;
- x = z1 + coeff*d;
- z1 = d;
+ /* All-pass sample processing. */
+ d = in - hp_coeff*hp_z1;
+ hp_y = hp_z1 + hp_coeff*d;
+ hp_z1 = d;
- hpout[i] = x - lpout[i];
+ /* High-pass generated from removing low-passed output. */
+ hpout[i] = hp_y - lp_y;
}
- splitter->hp_z1 = z1;
+ splitter->lp_z1 = lp_z1;
+ splitter->lp_z2 = lp_z2;
+ splitter->hp_z1 = hp_z1;
}