Makes code significantly faster for higher orders.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -288,7 +288,25 @@ static void biquad_process_## name(const BiquadCoeffs *const c,\ · 287 unmodified lines | ||
| 288 | 288 | type z1 = b->z1; \ |
| 289 | 289 | type z2 = b->z2; \ |
| 290 | 290 | \ |
| 291 | − for (int n = 0; n < nb_samples; n++) { \ | |
| 291 | + for (int n = 0; n + 1 < nb_samples; n++) { \ | |
| 292 | + type in = src[n]; \ | |
| 293 | + type out; \ | |
| 294 | + \ | |
| 295 | + out = in * b0 + z1; \ | |
| 296 | + z1 = b1 * in + z2 + a1 * out; \ | |
| 297 | + z2 = b2 * in + a2 * out; \ | |
| 298 | + dst[n] = out; \ | |
| 299 | + \ | |
| 300 | + n++; \ | |
| 301 | + in = src[n]; \ | |
| 302 | + out = in * b0 + z1; \ | |
| 303 | + z1 = b1 * in + z2 + a1 * out; \ | |
| 304 | + z2 = b2 * in + a2 * out; \ | |
| 305 | + dst[n] = out; \ | |
| 306 | + } \ | |
| 307 | + \ | |
| 308 | + if (nb_samples & 1) { \ | |
| 309 | + const int n = nb_samples - 1; \ | |
| 292 | 310 | const type in = src[n]; \ |
| 293 | 311 | type out; \ |
| 294 | 312 | \ |