E2 k=12: geomean+12dB — regressed (gap 0.015→0.135)
Browse files at this commitbf1c9c8a38969fc1adc47007811ac83ee62cd6ccParent: 3777a222 changed files +21 -15
crates/ec-vorbis/src/encode.rsmodified+13 -7
| @@ -106,6 +106,11 @@ const CO_MASK_RANGE: f64 = 50.0; | ||
| 106 | 106 | /// rate/quality knob: raising the curve zeroes masked coefficients earlier, |
| 107 | 107 | /// while peaks still ride as residue above it. |
| 108 | 108 | const MASKING_OFFSET_DB: f64 = 9.0; |
| 109 | +/// dB added to the per-region geometric-mean floor level (E2, lane-vorbis-floor | |
| 110 | +/// r2). 0 = pure envelope (E1, too low → clamp-lift saturation); the gap between | |
| 111 | +/// mean dB and peak dB in a typical long-block region is 15–25 dB, so 12 sits | |
| 112 | +/// halfway and keeps the loudest bin within the residue-book range. | |
| 113 | +const ENVELOPE_MARGIN_DB: f64 = 12.0; | |
| 109 | 114 | /// All-zero partition guard: if the masked band still has a bin within this |
| 110 | 115 | /// fraction of the floor, keep that bin as one sign-only residue sample. |
| 111 | 116 | const NOISE_NORMALISE_MIN_RATIO: f32 = 0.5; |
| @@ -930,14 +935,15 @@ impl VorbisEncoder { | ||
| 930 | 935 | /// the whole spectrum is covered exactly once and a peak between two points |
| 931 | 936 | /// still raises the floor that has to carry it. |
| 932 | 937 | /// |
| 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. | |
| 938 | +/// E2 (lane-vorbis-floor r2): returns the per-region geometric mean of |bin| | |
| 939 | +/// (≡ mean dB) **plus `ENVELOPE_MARGIN_DB`** — halfway between the pure | |
| 940 | +/// envelope (E1, too low → clamp-lift saturation) and the peak (baseline, | |
| 941 | +/// too high → sparse large q). The margin lifts the floor enough that the | |
| 942 | +/// loudest bins in each region stay within the residue-book range without the | |
| 943 | +/// refit loop, while quieter bins still get a small non-zero q. | |
| 939 | 944 | fn peaks_of(floor: &Floor1, half: usize, spectra: &[&Vec<f32>]) -> Vec<f64> { |
| 940 | 945 | let x = &floor.x_list; |
| 946 | + let margin = 10.0_f64.powf(ENVELOPE_MARGIN_DB / 20.0); | |
| 941 | 947 | x.iter() |
| 942 | 948 | .map(|¢re| { |
| 943 | 949 | let below = x.iter().filter(|&&o| o < centre).max().copied(); |
| @@ -954,7 +960,7 @@ fn peaks_of(floor: &Floor1, half: usize, spectra: &[&Vec<f32>]) -> Vec<f64> { | ||
| 954 | 960 | count += 1; |
| 955 | 961 | } |
| 956 | 962 | } |
| 957 | - (sum_log / count as f64).exp() | |
| 963 | + (sum_log / count as f64).exp() * margin | |
| 958 | 964 | }) |
| 959 | 965 | .collect() |
| 960 | 966 | } |
lanes/vorbis-psy-r1.sweep.txtmodified+8 -8
| @@ -1,9 +1,9 @@ | ||
| 1 | 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 | |
| 2 | +nik 96 83.6 84.5 -1.07 0.7840 0.9903 0.2063 FAIL | |
| 3 | +nik 128 114.7 115.8 -0.88 0.8661 0.9951 0.1290 FAIL | |
| 4 | +her 96 92.3 89.9 +2.68 0.7755 0.9867 0.2112 FAIL | |
| 5 | +her 128 125.2 124.9 +0.21 0.8650 0.9927 0.1277 FAIL | |
| 6 | +reell 96 85.1 85.5 -0.42 0.8553 0.9923 0.1371 FAIL | |
| 7 | +reell 128 121.6 120.9 +0.62 0.9472 0.9968 0.0496 FAIL | |
| 8 | +dl8a 96 86.2 86.9 -0.81 0.8478 0.9916 0.1439 FAIL | |
| 9 | +dl8a 128 117.5 117.8 -0.26 0.9177 0.9957 0.0780 FAIL |