From 32bafc88378c699fc2db5b0c4c0ddb7986e98990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 23 Aug 2026 04:28:07 +0300 Subject: [PATCH] =?UTF-8?q?E3:=20per-region=20RMS=20=E2=80=94=20regressed?= =?UTF-8?q?=20(gap=200.073,=20better=20than=20geomean=20but=204.8x=20basel?= =?UTF-8?q?ine)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/ec-vorbis/src/encode.rs | 19 +++++++++---------- lanes/vorbis-psy-r1.sweep.txt | 16 ++++++++-------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/crates/ec-vorbis/src/encode.rs b/crates/ec-vorbis/src/encode.rs index 6ccb4358..466ce905 100644 --- a/crates/ec-vorbis/src/encode.rs +++ b/crates/ec-vorbis/src/encode.rs @@ -935,15 +935,14 @@ impl VorbisEncoder { /// the whole spectrum is covered exactly once and a peak between two points /// still raises the floor that has to carry it. /// -/// E2 (lane-vorbis-floor r2): returns the per-region geometric mean of |bin| -/// (≡ mean dB) **plus `ENVELOPE_MARGIN_DB`** — halfway between the pure -/// envelope (E1, too low → clamp-lift saturation) and the peak (baseline, -/// too high → sparse large q). The margin lifts the floor enough that the -/// loudest bins in each region stay within the residue-book range without the -/// refit loop, while quieter bins still get a small non-zero q. +/// E3 (lane-vorbis-floor r2): returns the per-region **RMS** of |bin| instead +/// of the max. RMS sits between the geometric mean (E1, dominated by +/// noise-floor bins → too low) and the peak (baseline, follows only the +/// loudest bin). Tried because E1/E2 moved the gap (in the wrong direction): +/// the trend k=0→6→12→peak was monotonically better, so RMS is expected to +/// land above geomean but still below peak. fn peaks_of(floor: &Floor1, half: usize, spectra: &[&Vec]) -> Vec { let x = &floor.x_list; - let margin = 10.0_f64.powf(ENVELOPE_MARGIN_DB / 20.0); x.iter() .map(|¢re| { let below = x.iter().filter(|&&o| o < centre).max().copied(); @@ -952,15 +951,15 @@ fn peaks_of(floor: &Floor1, half: usize, spectra: &[&Vec]) -> Vec { let hi = above.map_or(half, |a| ((a + centre) / 2) as usize + 1); let lo = lo.min(half - 1); let hi = hi.clamp(lo + 1, half); - let mut sum_log = 0.0f64; + let mut sum_sq = 0.0f64; let mut count = 0usize; for spectrum in spectra { for &value in &spectrum[lo..hi] { - sum_log += f64::from(value.abs()).max(1e-9).ln(); + sum_sq += f64::from(value) * f64::from(value); count += 1; } } - (sum_log / count as f64).exp() * margin + (sum_sq / count as f64).sqrt() }) .collect() } diff --git a/lanes/vorbis-psy-r1.sweep.txt b/lanes/vorbis-psy-r1.sweep.txt index 6e29381d..19141b81 100644 --- a/lanes/vorbis-psy-r1.sweep.txt +++ b/lanes/vorbis-psy-r1.sweep.txt @@ -1,9 +1,9 @@ source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap verdict -nik 96 83.6 84.5 -1.11 0.7706 0.9903 0.2197 FAIL -nik 128 114.1 115.8 -1.45 0.8434 0.9951 0.1517 FAIL -her 96 87.3 89.9 -2.80 0.7320 0.9867 0.2547 FAIL -her 128 119.9 124.9 -4.04 0.8235 0.9927 0.1692 FAIL -reell 96 84.9 85.5 -0.66 0.8176 0.9923 0.1747 FAIL -reell 128 120.8 120.9 -0.01 0.9127 0.9968 0.0841 FAIL -dl8a 96 85.9 86.9 -1.18 0.8241 0.9916 0.1675 FAIL -dl8a 128 116.5 117.8 -1.12 0.8922 0.9957 0.1035 FAIL +nik 96 83.5 84.5 -1.22 0.9102 0.9903 0.0801 FAIL +nik 128 114.6 115.8 -0.96 0.9601 0.9951 0.0351 FAIL +her 96 88.8 89.9 -1.22 0.8206 0.9867 0.1661 FAIL +her 128 122.4 124.9 -2.02 0.9238 0.9927 0.0689 FAIL +reell 96 84.9 85.5 -0.70 0.9224 0.9923 0.0699 FAIL +reell 128 121.0 120.9 +0.13 0.9701 0.9968 0.0267 FAIL +dl8a 96 85.9 86.9 -1.13 0.8993 0.9916 0.0923 FAIL +dl8a 128 116.8 117.8 -0.86 0.9520 0.9957 0.0437 FAIL