diff --git a/crates/ec-vorbis/src/encode.rs b/crates/ec-vorbis/src/encode.rs index c0ebafbd..f74d5ce6 100644 --- a/crates/ec-vorbis/src/encode.rs +++ b/crates/ec-vorbis/src/encode.rs @@ -929,6 +929,13 @@ impl VorbisEncoder { /// Each point owns the coefficients halfway to its neighbours either side, so /// the whole spectrum is covered exactly once and a peak between two points /// still raises the floor that has to carry it. +/// +/// E1 (lane-vorbis-floor r2): returns the per-region **geometric mean** of +/// |bin| (≡ mean of dB) instead of the max. The max set the floor to the +/// region's loudest bin; bins 20–40 dB under it quantised to zero, so we coded +/// 45–57% as many non-zero residues as libvorbis at 1.5–2.1× bits each. The +/// geometric mean tracks the envelope: most bins sit near it and land at +/// q ≈ 10^(headroom/20) ≈ ±3, matching libvorbis's dense ±1/±2. fn peaks_of(floor: &Floor1, half: usize, spectra: &[&Vec]) -> Vec { let x = &floor.x_list; x.iter() @@ -939,13 +946,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 peak = 0.0f64; + let mut sum_log = 0.0f64; + let mut count = 0usize; for spectrum in spectra { for &value in &spectrum[lo..hi] { - peak = peak.max(f64::from(value.abs())); + sum_log += f64::from(value.abs()).max(1e-9).ln(); + count += 1; } } - peak + (sum_log / count as f64).exp() }) .collect() } diff --git a/lanes/vorbis-psy-r1.sweep.txt b/lanes/vorbis-psy-r1.sweep.txt new file mode 100644 index 00000000..43f95472 --- /dev/null +++ b/lanes/vorbis-psy-r1.sweep.txt @@ -0,0 +1,9 @@ +source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap verdict +nik 96 83.2 84.5 -1.59 0.7641 0.9903 0.2262 FAIL +nik 128 113.1 115.8 -2.30 0.8342 0.9951 0.1609 FAIL +her 96 83.8 89.9 -6.78 0.7089 0.9867 0.2778 FAIL +her 128 111.6 124.9 -10.62 0.7941 0.9927 0.1986 FAIL +reell 96 84.8 85.5 -0.80 0.7999 0.9923 0.1924 FAIL +reell 128 120.3 120.9 -0.48 0.8890 0.9968 0.1078 FAIL +dl8a 96 86.0 86.9 -1.01 0.8091 0.9916 0.1825 FAIL +dl8a 128 116.4 117.8 -1.17 0.8783 0.9957 0.1174 FAIL