Commit 3f78989289 for ffmpeg

commit 3f789892899d27d4de5354351f200970da043c18
Author: marcos ashton <marcosashiglesias@gmail.com>
Date:   Tue Dec 1 19:47:26 2026 +0000

    avfilter/af_biquads: fix tdi dry mix and disabled output

    BIQUAD_TDI_FILTER has overwritten in with ibuf[i] + s1 since d166317cdda added tdi, so the dry part of mix < 1 and the output of a disabled filter were that sum.

diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c
index 19a6c63fd5..c44c172d6b 100644
--- a/libavfilter/af_biquads.c
+++ b/libavfilter/af_biquads.c
@@ -350,28 +350,29 @@ static void biquad_tdi_## name (BiquadsContext *s,                            \
     ftype s4 = fcache[3];                                                     \
     ftype wet = s->mix;                                                       \
     ftype dry = 1. - wet;                                                     \
-    ftype in, out;                                                            \
+    ftype in, w, out;                                                         \
                                                                               \
     for (int i = 0; i < len; i++) {                                           \
         ftype t1, t2, t3, t4;                                                 \
-        in = ibuf[i] + s1;                                                    \
-        t1 = in * a1 + s2;                                                    \
-        t2 = in * a2;                                                         \
-        t3 = in * b1 + s4;                                                    \
-        t4 = in * b2;                                                         \
-        out = b0 * in + s3;                                                   \
+        in = *ibuf++;                                                         \
+        w = in + s1;                                                          \
+        t1 = w * a1 + s2;                                                     \
+        t2 = w * a2;                                                          \
+        t3 = w * b1 + s4;                                                     \
+        t4 = w * b2;                                                          \
+        out = b0 * w + s3;                                                    \
         out = out * wet + in * dry;                                           \
         s1 = t1; s2 = t2; s3 = t3; s4 = t4;                                   \
         if (disabled) {                                                       \
-            obuf[i] = in;                                                     \
+            *obuf++ = in;                                                     \
         } else if (need_clipping && out < min) {                              \
             (*clippings)++;                                                   \
-            obuf[i] = min;                                                    \
+            *obuf++ = min;                                                    \
         } else if (need_clipping && out > max) {                              \
             (*clippings)++;                                                   \
-            obuf[i] = max;                                                    \
+            *obuf++ = max;                                                    \
         } else {                                                              \
-            obuf[i] = out;                                                    \
+            *obuf++ = out;                                                    \
         }                                                                     \
     }                                                                         \
                                                                               \
diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index dd709d51a8..5f16a08b47 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -462,6 +462,13 @@ FATE_AFILTER_API-$(CONFIG_AMIX_FILTER) += fate-filter-amix-pts
 fate-filter-amix-pts: libavfilter/tests/amix$(EXESUF)
 fate-filter-amix-pts: CMD = run libavfilter/tests/amix$(EXESUF)

+# tdi and di differ only by rounding, far less than half an s16 step
+fate-filter-biquads-tdi-mix: CMD = framecrc -auto_conversion_filters -filter_complex "sine=f=440:r=48000:d=0.2,aformat=dblp,asplit[a][b];[a]lowpass=a=di:mix=0.7[x];[b]lowpass=a=tdi:mix=0.7[y];[x][y]amerge,aeval=not(lte(abs(val(0)-val(1))\,1/65536)):c=mono,aformat=s16"
+FATE_AFILTER-$(call FILTERFRAMECRC, SINE AFORMAT ASPLIT LOWPASS AMERGE AEVAL ARESAMPLE) += fate-filter-biquads-tdi-mix
+
+fate-filter-biquads-tdi-disabled: CMD = framecrc -auto_conversion_filters -filter_complex "sine=f=440:r=48000:d=0.2,aformat=dblp,asplit[a][b];[b]lowpass=a=tdi:enable=0[y];[a][y]amerge,aeval=not(eq(val(0)\,val(1))):c=mono,aformat=s16"
+FATE_AFILTER-$(call FILTERFRAMECRC, SINE AFORMAT ASPLIT LOWPASS AMERGE AEVAL ARESAMPLE) += fate-filter-biquads-tdi-disabled
+
 FATE_AFILTER-yes += fate-filter-formats
 fate-filter-formats: libavfilter/tests/formats$(EXESUF)
 fate-filter-formats: CMD = run libavfilter/tests/formats$(EXESUF)
diff --git a/tests/ref/fate/filter-biquads-tdi-disabled b/tests/ref/fate/filter-biquads-tdi-disabled
new file mode 100644
index 0000000000..59c02711cc
--- /dev/null
+++ b/tests/ref/fate/filter-biquads-tdi-disabled
@@ -0,0 +1,15 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: 1 channels
+0,          0,          0,     1024,     2048, 0x00000000
+0,       1024,       1024,     1024,     2048, 0x00000000
+0,       2048,       2048,     1024,     2048, 0x00000000
+0,       3072,       3072,     1024,     2048, 0x00000000
+0,       4096,       4096,     1024,     2048, 0x00000000
+0,       5120,       5120,     1024,     2048, 0x00000000
+0,       6144,       6144,     1024,     2048, 0x00000000
+0,       7168,       7168,     1024,     2048, 0x00000000
+0,       8192,       8192,     1024,     2048, 0x00000000
+0,       9216,       9216,      384,      768, 0x00000000
diff --git a/tests/ref/fate/filter-biquads-tdi-mix b/tests/ref/fate/filter-biquads-tdi-mix
new file mode 100644
index 0000000000..59c02711cc
--- /dev/null
+++ b/tests/ref/fate/filter-biquads-tdi-mix
@@ -0,0 +1,15 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: 1 channels
+0,          0,          0,     1024,     2048, 0x00000000
+0,       1024,       1024,     1024,     2048, 0x00000000
+0,       2048,       2048,     1024,     2048, 0x00000000
+0,       3072,       3072,     1024,     2048, 0x00000000
+0,       4096,       4096,     1024,     2048, 0x00000000
+0,       5120,       5120,     1024,     2048, 0x00000000
+0,       6144,       6144,     1024,     2048, 0x00000000
+0,       7168,       7168,     1024,     2048, 0x00000000
+0,       8192,       8192,     1024,     2048, 0x00000000
+0,       9216,       9216,      384,      768, 0x00000000