]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/af_acrossover: unroll biquad_process loop
authorPaul B Mahol <onemda@gmail.com>
Mon, 30 Nov 2020 13:20:45 +0000 (14:20 +0100)
committerPaul B Mahol <onemda@gmail.com>
Mon, 30 Nov 2020 13:53:14 +0000 (14:53 +0100)
Makes code significantly faster for higher orders.

libavfilter/af_acrossover.c

index 7788251d3af4b02528b994644f3cfad6ee33ae0c..6150af79330b98145ea59e3cdc43e070296796b7 100644 (file)
@@ -288,7 +288,25 @@ static void biquad_process_## name(const BiquadCoeffs *const c,\
     type z1 = b->z1;                                           \
     type z2 = b->z2;                                           \
                                                                \
-    for (int n = 0; n < nb_samples; n++) {                     \
+    for (int n = 0; n + 1 < nb_samples; n++) {                 \
+        type in = src[n];                                      \
+        type out;                                              \
+                                                               \
+        out = in * b0 + z1;                                    \
+        z1 = b1 * in + z2 + a1 * out;                          \
+        z2 = b2 * in + a2 * out;                               \
+        dst[n] = out;                                          \
+                                                               \
+        n++;                                                   \
+        in = src[n];                                           \
+        out = in * b0 + z1;                                    \
+        z1 = b1 * in + z2 + a1 * out;                          \
+        z2 = b2 * in + a2 * out;                               \
+        dst[n] = out;                                          \
+    }                                                          \
+                                                               \
+    if (nb_samples & 1) {                                      \
+        const int n = nb_samples - 1;                          \
         const type in = src[n];                                \
         type out;                                              \
                                                                \