E1: peaks_of geomean — regressed (gap 0.015→0.183, corr 0.97→0.78)
Browse files at this commit3777a229d81269ceadfccbc222176f3caadf62a6Parent: 30a832c2 changed files +21 -3
crates/ec-vorbis/src/encode.rsmodified+12 -3
| @@ -929,6 +929,13 @@ impl VorbisEncoder { | |||
| 929 | /// Each point owns the coefficients halfway to its neighbours either side, so | 929 | /// Each point owns the coefficients halfway to its neighbours either side, so |
| 930 | /// the whole spectrum is covered exactly once and a peak between two points | 930 | /// the whole spectrum is covered exactly once and a peak between two points |
| 931 | /// still raises the floor that has to carry it. | 931 | /// still raises the floor that has to carry it. |
| 932 | +/// | ||
| 933 | +/// E1 (lane-vorbis-floor r2): returns the per-region **geometric mean** of | ||
| 934 | +/// |bin| (≡ mean of dB) instead of the max. The max set the floor to the | ||
| 935 | +/// region's loudest bin; bins 20–40 dB under it quantised to zero, so we coded | ||
| 936 | +/// 45–57% as many non-zero residues as libvorbis at 1.5–2.1× bits each. The | ||
| 937 | +/// geometric mean tracks the envelope: most bins sit near it and land at | ||
| 938 | +/// q ≈ 10^(headroom/20) ≈ ±3, matching libvorbis's dense ±1/±2. | ||
| 932 | fn peaks_of(floor: &Floor1, half: usize, spectra: &[&Vec<f32>]) -> Vec<f64> { | 939 | fn peaks_of(floor: &Floor1, half: usize, spectra: &[&Vec<f32>]) -> Vec<f64> { |
| 933 | let x = &floor.x_list; | 940 | let x = &floor.x_list; |
| 934 | x.iter() | 941 | x.iter() |
| @@ -939,13 +946,15 @@ fn peaks_of(floor: &Floor1, half: usize, spectra: &[&Vec<f32>]) -> Vec<f64> { | |||
| 939 | let hi = above.map_or(half, |a| ((a + centre) / 2) as usize + 1); | 946 | let hi = above.map_or(half, |a| ((a + centre) / 2) as usize + 1); |
| 940 | let lo = lo.min(half - 1); | 947 | let lo = lo.min(half - 1); |
| 941 | let hi = hi.clamp(lo + 1, half); | 948 | let hi = hi.clamp(lo + 1, half); |
| 942 | - let mut peak = 0.0f64; | 949 | + let mut sum_log = 0.0f64; |
| 950 | + let mut count = 0usize; | ||
| 943 | for spectrum in spectra { | 951 | for spectrum in spectra { |
| 944 | for &value in &spectrum[lo..hi] { | 952 | for &value in &spectrum[lo..hi] { |
| 945 | - peak = peak.max(f64::from(value.abs())); | 953 | + sum_log += f64::from(value.abs()).max(1e-9).ln(); |
| 954 | + count += 1; | ||
| 946 | } | 955 | } |
| 947 | } | 956 | } |
| 948 | - peak | 957 | + (sum_log / count as f64).exp() |
| 949 | }) | 958 | }) |
| 950 | .collect() | 959 | .collect() |
| 951 | } | 960 | } |
lanes/vorbis-psy-r1.sweep.txtadded+9 -0
| @@ -0,0 +1,9 @@ | |||
| 1 | +source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap verdict | ||
| 2 | +nik 96 83.2 84.5 -1.59 0.7641 0.9903 0.2262 FAIL | ||
| 3 | +nik 128 113.1 115.8 -2.30 0.8342 0.9951 0.1609 FAIL | ||
| 4 | +her 96 83.8 89.9 -6.78 0.7089 0.9867 0.2778 FAIL | ||
| 5 | +her 128 111.6 124.9 -10.62 0.7941 0.9927 0.1986 FAIL | ||
| 6 | +reell 96 84.8 85.5 -0.80 0.7999 0.9923 0.1924 FAIL | ||
| 7 | +reell 128 120.3 120.9 -0.48 0.8890 0.9968 0.1078 FAIL | ||
| 8 | +dl8a 96 86.0 86.9 -1.01 0.8091 0.9916 0.1825 FAIL | ||
| 9 | +dl8a 128 116.4 117.8 -1.17 0.8783 0.9957 0.1174 FAIL | ||