From d1d292914fdbd97b3278f5b870482bb62905489b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 6 Sep 2026 19:00:31 +0300 Subject: [PATCH] perf(opus): tf boost swept as a term -- 12 gate runs, no point keeps, k=1.25 is the nearest miss k in {1.25,1.5,2}, offset in {.04,.044,.06,.08}, the transient-flag gate and a tf_estimate threshold gate, each on the 12-row library gate. No point passes the keep rule. k=1.25 on every frame (r8) costs only her@64 +.001 / her@96 +.021 err_ratio with corr no worse than -.0005 and buys reell@64 2.697->1.440, reell@96 4.499->2.516, hein@64 .853->.302; the reell gain lives entirely on frames with tf_estimate >= 0.6, and so does her@96's loss, so no gate built from the transient analysis separates them. Default term unchanged; the whole table is at the decision site. --- crates/ec-opus/src/celt_enc.rs | 30 ++++++++++++++++++++++++++---- lanes/opus-opustr2-r10.sweep.txt | 16 ++++++++++++++++ lanes/opus-opustr2-r11.sweep.txt | 16 ++++++++++++++++ lanes/opus-opustr2-r12.sweep.txt | 16 ++++++++++++++++ lanes/opus-opustr2-r9.sweep.txt | 16 ++++++++++++++++ 5 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 lanes/opus-opustr2-r10.sweep.txt create mode 100644 lanes/opus-opustr2-r11.sweep.txt create mode 100644 lanes/opus-opustr2-r12.sweep.txt create mode 100644 lanes/opus-opustr2-r9.sweep.txt diff --git a/crates/ec-opus/src/celt_enc.rs b/crates/ec-opus/src/celt_enc.rs index 3f586e3a..2a2cabb8 100644 --- a/crates/ec-opus/src/celt_enc.rs +++ b/crates/ec-opus/src/celt_enc.rs @@ -913,10 +913,32 @@ impl CeltEncoder { // hein@64 and .0014 on hein@96 and pushes 5 err_ratio rows the // wrong way, so the x1 stand-in stays. The reelm rows that carried // the first rejection are gone; hein reproduced it exactly. - // It is nonetheless the only lever measured to move the reell rows: - // with it, reell@64 goes 2.697 -> 1.764 and reell@96 4.499 -> 2.114 - // (`lanes/opus-opustr-r2.sweep.txt`). Upgrade path: gate the x2 on - // content -- it pays on music transients and starves hein's speech. + // SWEPT WHOLE (lane opustr2, 12 detached gate runs, r1 = this + // default reproducing the base rows exactly; the gate is + // deterministic, so every delta below is real, not run noise). + // err_ratio deltas vs r1, worst rows only: + // k=2 off=.04 her@96 +.021 hein@96 +.067, hein corr + // -.0024 (r2) + // k=1.5 off=.04/.06/.08 reelo@96 +.09 her@96 +.019, hein corr + // -.0012 -- the offset is inert (r3,7,6) + // k=2 off=.04 transient reelo@96 +.095 dl8a@96 +.040 (r4) + // k=1.5 off=.04 transient hein@64 +.026 her@96 +.020 (r5) + // k=2 tfe>=.6 / >=.35 nik@96 +.042/+.060 hein@96 +.075 (r9,10) + // k=1.25 tfe>=.6 / >=.35 hein@64 +.090 / dl8a@96 +.065 (r11,12) + // k=1.25 off=.044 her@64 +.001 her@96 +.021 ONLY, corr + // worst -.0005 (hein@64), and reell@64 + // 2.697->1.440, reell@96 4.499->2.516, + // hein@64 .853->.302, nik@64 .708->.643, + // dl8a@96 .374->.315 (r8) + // r8 is the nearest miss ever measured on this term and still + // fails the keep rule on her@96, so the x1 stand-in stays. Every + // variant that moves reell also costs her@96 ~+.02, and the reell gain + // comes entirely from frames with tf_estimate >= 0.6 (r11 keeps the + // full reell win) -- so her@96's loss lives on the same frames and + // no content gate built from `tf_estimate` or the transient flag + // can separate them. Upgrade path: libopus gates this boost with + // its tonality analysis (`analysis->valid`, music_prob), which this + // encoder does not run at all. Sweeps: lanes/opus-opustr2-r*.sweep.txt. // SWEPT (lane opustr2): k/offset/gate come from `tf_boost_params()`; // the defaults (k=1, off=.044, gate=all) are the shipped point and // reproduce the line above byte for byte. diff --git a/lanes/opus-opustr2-r10.sweep.txt b/lanes/opus-opustr2-r10.sweep.txt new file mode 100644 index 00000000..b072b496 --- /dev/null +++ b/lanes/opus-opustr2-r10.sweep.txt @@ -0,0 +1,16 @@ +# lane-opustr2 r10: k=2.0 off=.04 thresh tfe>=0.35 +# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1) +# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo +# source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap Q_ours Q_ref err_ratio minsec_ours minsec_ref drop_ours drop_ref +nik 64 69.0 69.2 -0.2 0.9887 0.9864 -0.0023 -84.80 -154.78 0.661 0.9772 0.9745 0 0 +nik 96 100.8 101.0 -0.2 0.9947 0.9940 -0.0006 -36.59 -31.55 1.045 0.9891 0.9888 0 0 +reelo 64 63.4 63.6 -0.3 0.9892 0.9866 -0.0026 -202.86 -123.36 1.510 0.9684 0.9686 0 0 +reelo 96 93.1 93.9 -0.9 0.9945 0.9937 -0.0007 -131.57 -125.18 1.037 0.9858 0.9854 0 0 +her 64 67.4 67.9 -0.8 0.9831 0.9794 -0.0037 -365.96 -339.00 1.104 0.9465 0.9406 0 0 +her 96 100.6 101.5 -0.9 0.9911 0.9902 -0.0009 -206.26 -191.50 1.072 0.9717 0.9728 0 0 +reell 64 71.3 71.3 -0.0 0.9908 0.9880 -0.0028 -244.05 -128.39 1.764 0.9710 0.9644 0 0 +reell 96 105.3 105.4 -0.1 0.9956 0.9948 -0.0008 -137.01 -29.16 2.114 0.9854 0.9804 0 0 +dl8a 64 65.5 65.8 -0.4 0.9886 0.9865 -0.0022 -223.08 -378.84 0.541 0.9785 0.9723 0 0 +dl8a 96 96.3 96.8 -0.6 0.9940 0.9934 -0.0006 -202.46 -423.47 0.422 0.9870 0.9864 0 0 +hein 64 64.3 64.9 -0.8 0.9868 0.9874 +0.0006 -195.36 -388.31 0.460 0.9195 0.9148 0 0 +hein 96 86.2 86.9 -0.9 0.9933 0.9930 -0.0003 -94.13 -246.46 0.456 0.9618 0.9499 0 0 diff --git a/lanes/opus-opustr2-r11.sweep.txt b/lanes/opus-opustr2-r11.sweep.txt new file mode 100644 index 00000000..01b0e8a3 --- /dev/null +++ b/lanes/opus-opustr2-r11.sweep.txt @@ -0,0 +1,16 @@ +# lane-opustr2 r11: k=1.25 off=.044 thresh tfe>=0.6 +# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1) +# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo +# source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap Q_ours Q_ref err_ratio minsec_ours minsec_ref drop_ours drop_ref +nik 64 69.1 69.2 -0.1 0.9887 0.9864 -0.0024 -95.49 -154.78 0.709 0.9767 0.9745 0 0 +nik 96 100.9 101.0 -0.1 0.9947 0.9940 -0.0007 -31.81 -31.55 1.002 0.9888 0.9888 0 0 +reelo 64 63.5 63.6 -0.1 0.9893 0.9866 -0.0027 -202.81 -123.36 1.510 0.9701 0.9686 0 0 +reelo 96 93.3 93.9 -0.6 0.9946 0.9937 -0.0009 -112.98 -125.18 0.931 0.9861 0.9854 0 0 +her 64 67.6 67.9 -0.5 0.9834 0.9794 -0.0039 -365.71 -339.00 1.103 0.9473 0.9406 0 0 +her 96 100.9 101.5 -0.6 0.9913 0.9902 -0.0011 -205.93 -191.50 1.070 0.9726 0.9728 0 0 +reell 64 71.3 71.3 -0.0 0.9908 0.9880 -0.0028 -198.89 -128.39 1.440 0.9719 0.9644 0 0 +reell 96 105.3 105.4 -0.0 0.9956 0.9948 -0.0008 -169.83 -29.16 2.516 0.9855 0.9804 0 0 +dl8a 64 65.7 65.8 -0.2 0.9889 0.9865 -0.0024 -226.16 -378.84 0.548 0.9791 0.9723 0 0 +dl8a 96 96.5 96.8 -0.3 0.9942 0.9934 -0.0008 -171.29 -423.47 0.363 0.9879 0.9864 0 0 +hein 64 64.7 64.9 -0.2 0.9884 0.9874 -0.0011 -371.64 -388.31 0.943 0.9299 0.9148 0 0 +hein 96 86.7 86.9 -0.3 0.9944 0.9930 -0.0013 -100.91 -246.46 0.476 0.9677 0.9499 0 0 diff --git a/lanes/opus-opustr2-r12.sweep.txt b/lanes/opus-opustr2-r12.sweep.txt new file mode 100644 index 00000000..44e11bd4 --- /dev/null +++ b/lanes/opus-opustr2-r12.sweep.txt @@ -0,0 +1,16 @@ +# lane-opustr2 r12: k=1.25 off=.044 thresh tfe>=0.35 +# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1) +# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo +# source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap Q_ours Q_ref err_ratio minsec_ours minsec_ref drop_ours drop_ref +nik 64 69.1 69.2 -0.1 0.9887 0.9864 -0.0024 -91.33 -154.78 0.690 0.9768 0.9745 0 0 +nik 96 100.9 101.0 -0.1 0.9947 0.9940 -0.0007 -36.69 -31.55 1.046 0.9887 0.9888 0 0 +reelo 64 63.5 63.6 -0.1 0.9893 0.9866 -0.0027 -202.82 -123.36 1.510 0.9699 0.9686 0 0 +reelo 96 93.3 93.9 -0.6 0.9946 0.9937 -0.0009 -112.41 -125.18 0.927 0.9861 0.9854 0 0 +her 64 67.6 67.9 -0.5 0.9833 0.9794 -0.0039 -366.27 -339.00 1.105 0.9472 0.9406 0 0 +her 96 100.8 101.5 -0.7 0.9913 0.9902 -0.0011 -206.39 -191.50 1.073 0.9725 0.9728 0 0 +reell 64 71.3 71.3 -0.0 0.9908 0.9880 -0.0028 -198.89 -128.39 1.440 0.9719 0.9644 0 0 +reell 96 105.3 105.4 -0.0 0.9956 0.9948 -0.0008 -169.83 -29.16 2.516 0.9855 0.9804 0 0 +dl8a 64 65.7 65.8 -0.2 0.9889 0.9865 -0.0024 -225.53 -378.84 0.547 0.9789 0.9723 0 0 +dl8a 96 96.5 96.8 -0.3 0.9942 0.9934 -0.0008 -211.05 -423.47 0.439 0.9879 0.9864 0 0 +hein 64 64.7 64.9 -0.3 0.9883 0.9874 -0.0010 -130.19 -388.31 0.329 0.9281 0.9148 0 0 +hein 96 86.7 86.9 -0.3 0.9943 0.9930 -0.0013 -105.05 -246.46 0.488 0.9674 0.9499 0 0 diff --git a/lanes/opus-opustr2-r9.sweep.txt b/lanes/opus-opustr2-r9.sweep.txt new file mode 100644 index 00000000..8ab0cbbb --- /dev/null +++ b/lanes/opus-opustr2-r9.sweep.txt @@ -0,0 +1,16 @@ +# lane-opustr2 r9: k=2.0 off=.04 thresh tfe>=0.6 +# ec-opus encoder vs ffmpeg libopus — encoders-only gate (r1) +# both bitstreams decoded by ec-opus; 120s cap; VBR; 48kHz stereo +# source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap Q_ours Q_ref err_ratio minsec_ours minsec_ref drop_ours drop_ref +nik 64 69.1 69.2 -0.1 0.9887 0.9864 -0.0023 -99.01 -154.78 0.725 0.9770 0.9745 0 0 +nik 96 100.8 101.0 -0.2 0.9947 0.9940 -0.0006 -34.57 -31.55 1.027 0.9887 0.9888 0 0 +reelo 64 63.5 63.6 -0.2 0.9893 0.9866 -0.0026 -202.81 -123.36 1.510 0.9697 0.9686 0 0 +reelo 96 93.2 93.9 -0.7 0.9946 0.9937 -0.0008 -112.97 -125.18 0.931 0.9858 0.9854 0 0 +her 64 67.5 67.9 -0.7 0.9832 0.9794 -0.0038 -367.01 -339.00 1.108 0.9471 0.9406 0 0 +her 96 100.7 101.5 -0.8 0.9912 0.9902 -0.0010 -206.14 -191.50 1.071 0.9721 0.9728 0 0 +reell 64 71.3 71.3 -0.0 0.9908 0.9880 -0.0028 -244.05 -128.39 1.764 0.9714 0.9644 0 0 +reell 96 105.3 105.4 -0.1 0.9956 0.9948 -0.0008 -137.01 -29.16 2.114 0.9854 0.9804 0 0 +dl8a 64 65.6 65.8 -0.2 0.9888 0.9865 -0.0023 -226.92 -378.84 0.550 0.9795 0.9723 0 0 +dl8a 96 96.4 96.8 -0.4 0.9941 0.9934 -0.0007 -175.88 -423.47 0.371 0.9876 0.9864 0 0 +hein 64 64.6 64.9 -0.5 0.9875 0.9874 -0.0002 -350.42 -388.31 0.873 0.9219 0.9148 0 0 +hein 96 86.5 86.9 -0.5 0.9937 0.9930 -0.0007 -141.11 -246.46 0.603 0.9634 0.9499 0 0