Skip to content

Commit 8b440fa

Browse files
committed
optimize
1 parent 1b12e6e commit 8b440fa

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/vocoder/mlsa.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,19 @@ fn fir(d: &mut [f64], x: f64, alpha: f64, coefficients: &[f64]) -> f64 {
8484
d[0] = x;
8585

8686
let a = alpha;
87-
let iaa = 1.0 - a * a;
87+
let aa = a * a;
88+
let iaa = 1.0 - aa;
8889
let mut rem = 0.0;
8990

90-
for di in &mut d[..] {
91+
let mut chunks = d.chunks_exact_mut(2);
92+
for chunk in chunks.by_ref() {
93+
(chunk[0], chunk[1], rem) = (
94+
a * chunk[0] + rem,
95+
iaa * chunk[0] + a * chunk[1] - a * rem,
96+
-a * iaa * chunk[0] + iaa * chunk[1] + aa * rem,
97+
);
98+
}
99+
for di in chunks.into_remainder() {
91100
(*di, rem) = (a * *di + rem, iaa * *di - a * rem);
92101
}
93102

0 commit comments

Comments
 (0)