E3: HF per-region RMS refuted (gap 0.0073, rate +2.8%) — revert to peak-hold, keep E2 tilt
Browse files at this commit63444aad29b5d4e16e97e520e60bdbb74c681bd8Parent: 8c3661e2 changed files +17 -10
crates/ec-vorbis/src/encode.rsmodified+12 -5
| @@ -718,17 +718,20 @@ impl VorbisEncoder { | |||
| 718 | } else { | 718 | } else { |
| 719 | MASKING_OFFSET_DB | 719 | MASKING_OFFSET_DB |
| 720 | }; | 720 | }; |
| 721 | - // Per-post headroom tilt: LF boost, HF cut, long blocks only — the | 721 | + // Per-post frequency, headroom tilt, and (for HF) the RMS-vs-peak |
| 722 | - // rate loop's global headroom rebalances the total bitrate. | 722 | + // choice: long blocks only — the rate loop's global headroom |
| 723 | - let tilt: Vec<f64> = if plan.is_long { | 723 | + // rebalances the total bitrate. Short blocks get a flat zero tilt and |
| 724 | + // pure peak-hold (hz set to 0 so no post crosses the HF threshold). | ||
| 725 | + let post_hz: Vec<f64> = if plan.is_long { | ||
| 724 | bc.floor | 726 | bc.floor |
| 725 | .x_list | 727 | .x_list |
| 726 | .iter() | 728 | .iter() |
| 727 | - .map(|&x| headroom_tilt(x as f64 * f64::from(self.config.sample_rate) / (2.0 * half as f64))) | 729 | + .map(|&x| x as f64 * f64::from(self.config.sample_rate) / (2.0 * half as f64)) |
| 728 | .collect() | 730 | .collect() |
| 729 | } else { | 731 | } else { |
| 730 | vec![0.0; bc.floor.x_list.len()] | 732 | vec![0.0; bc.floor.x_list.len()] |
| 731 | }; | 733 | }; |
| 734 | + let tilt: Vec<f64> = post_hz.iter().map(|&hz| headroom_tilt(hz)).collect(); | ||
| 732 | let (floor_values, quantised) = loop { | 735 | let (floor_values, quantised) = loop { |
| 733 | let mut curves: Vec<Vec<f32>> = vec![Vec::new(); channels]; | 736 | let mut curves: Vec<Vec<f32>> = vec![Vec::new(); channels]; |
| 734 | let mut floor_values: Vec<Vec<i32>> = vec![Vec::new(); channels]; | 737 | let mut floor_values: Vec<Vec<i32>> = vec![Vec::new(); channels]; |
| @@ -971,7 +974,11 @@ impl VorbisEncoder { | |||
| 971 | /// | 974 | /// |
| 972 | /// Each point owns the coefficients halfway to its neighbours either side, so | 975 | /// Each point owns the coefficients halfway to its neighbours either side, so |
| 973 | /// the whole spectrum is covered exactly once and a peak between two points | 976 | /// the whole spectrum is covered exactly once and a peak between two points |
| 974 | -/// still raises the floor that has to carry it. | 977 | +/// still raises the floor that has to carry it. Peak-hold is used at every |
| 978 | +/// frequency: per-region RMS was tried at HF (>6 kHz, r3 E3) but it lowers the | ||
| 979 | +/// floor estimate, promoting noise-like HF bins to residue and regressing | ||
| 980 | +/// correlation — peak-hold plus the HF headroom tilt zeros them instead, which | ||
| 981 | +/// matches the reference. See lanes/vorbis-floor-r3.report.md. | ||
| 975 | fn peaks_of(floor: &Floor1, half: usize, spectra: &[&Vec<f32>]) -> Vec<f64> { | 982 | fn peaks_of(floor: &Floor1, half: usize, spectra: &[&Vec<f32>]) -> Vec<f64> { |
| 976 | let x = &floor.x_list; | 983 | let x = &floor.x_list; |
| 977 | x.iter() | 984 | x.iter() |
lanes/vorbis-psy-r1.sweep.txtmodified+5 -5
| @@ -1,9 +1,9 @@ | |||
| 1 | source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap verdict | 1 | source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap verdict |
| 2 | nik 96 83.5 84.5 -1.20 0.9863 0.9903 0.0040 PASS | 2 | nik 96 83.5 84.5 -1.20 0.9863 0.9903 0.0040 PASS |
| 3 | -nik 128 115.0 115.8 -0.63 0.9927 0.9951 0.0024 PASS | 3 | +nik 128 115.0 115.8 -0.64 0.9927 0.9951 0.0024 PASS |
| 4 | -her 96 88.1 89.9 -1.98 0.9879 0.9867 -0.0012 PASS | 4 | +her 96 88.1 89.9 -1.96 0.9879 0.9867 -0.0012 PASS |
| 5 | -her 128 121.8 124.9 -2.46 0.9917 0.9927 0.0010 PASS | 5 | +her 128 121.8 124.9 -2.49 0.9917 0.9927 0.0011 PASS |
| 6 | reell 96 84.6 85.5 -1.08 0.9932 0.9923 -0.0009 PASS | 6 | reell 96 84.6 85.5 -1.08 0.9932 0.9923 -0.0009 PASS |
| 7 | reell 128 120.6 120.9 -0.18 0.9969 0.9968 -0.0001 PASS | 7 | reell 128 120.6 120.9 -0.18 0.9969 0.9968 -0.0001 PASS |
| 8 | -dl8a 96 86.1 86.9 -0.95 0.9880 0.9916 0.0036 PASS | 8 | +dl8a 96 86.1 86.9 -0.96 0.9878 0.9916 0.0038 PASS |
| 9 | -dl8a 128 117.7 117.8 -0.08 0.9940 0.9957 0.0018 PASS | 9 | +dl8a 128 117.6 117.8 -0.12 0.9938 0.9957 0.0019 PASS |