forge
Explore
Log in

Don't you dare go Hollow

E1: LF headroom tilt +6 dB (1.1-2 kHz) — mean gap 0.00536 (was 0.01525)

Browse files at this commit

982ef467cae8c6bb215765d56157850f34097114Ahmet Kaan GümüşParent: 93cf89c
crates/ec-vorbis/src/encode.rsmodified+53 -5
@@ -123,6 +123,38 @@ const CO_MASK_RANGE_SHORT: f64 = f64::INFINITY;
123 const POINT_STEREO_HZ: f64 = 4_000.0;123 const POINT_STEREO_HZ: f64 = 4_000.0;
124 /// Least headroom a short block is quantised with, whatever the rate loop's.124 /// Least headroom a short block is quantised with, whatever the rate loop's.
125 const HEADROOM_SHORT_MIN: f64 = 42.0;125 const HEADROOM_SHORT_MIN: f64 = 42.0;
126+/// Per-post headroom tilt (dB): extra headroom below `TILT_LF_LO_HZ` so the
127+/// floor sits lower at low frequencies — finer step, more bits where the ear
128+/// is sensitive and the reference spends. Tapers to 0 by `TILT_LF_HI_HZ`.
129+/// `TILT_HF_DB` (negative) trims step resolution above `TILT_HF_HI_HZ`,
130+/// routing those bits to LF. The rate loop's global headroom rebalances the
131+/// total. Tuned by lanes/vorbis-floor-r3.report.md (8-row sweep).
132+const TILT_LF_DB: f64 = 6.0;
133+const TILT_LF_LO_HZ: f64 = 1_100.0;
134+const TILT_LF_HI_HZ: f64 = 2_000.0;
135+const TILT_HF_DB: f64 = 0.0;
136+const TILT_HF_LO_HZ: f64 = 4_000.0;
137+const TILT_HF_HI_HZ: f64 = 6_000.0;
138+
139+/// Extra headroom (dB) for one floor post at `hz`: LF boost tapering to 0,
140+/// plus an HF cut (negative) tapering in. Zero outside both bands.
141+fn headroom_tilt(hz: f64) -> f64 {
142+ let lf = if hz <= TILT_LF_LO_HZ {
143+ TILT_LF_DB
144+ } else if hz < TILT_LF_HI_HZ {
145+ TILT_LF_DB * (TILT_LF_HI_HZ - hz) / (TILT_LF_HI_HZ - TILT_LF_LO_HZ)
146+ } else {
147+ 0.0
148+ };
149+ let hf = if hz <= TILT_HF_LO_HZ {
150+ 0.0
151+ } else if hz < TILT_HF_HI_HZ {
152+ TILT_HF_DB * (hz - TILT_HF_LO_HZ) / (TILT_HF_HI_HZ - TILT_HF_LO_HZ)
153+ } else {
154+ TILT_HF_DB
155+ };
156+ lf + hf
157+}
126 /// Samples per transient-detection tick — the short block's own hop, so a158 /// Samples per transient-detection tick — the short block's own hop, so a
127 /// tick lines up with the finest time resolution the encoder has.159 /// tick lines up with the finest time resolution the encoder has.
128 const TICK: usize = BLOCK_SHORT / 4;160 const TICK: usize = BLOCK_SHORT / 4;
@@ -687,6 +719,17 @@ impl VorbisEncoder {
687 } else {719 } else {
688 MASKING_OFFSET_DB720 MASKING_OFFSET_DB
689 };721 };
722+ // Per-post headroom tilt: LF boost, HF cut, long blocks only — the
723+ // rate loop's global headroom rebalances the total bitrate.
724+ let tilt: Vec<f64> = if plan.is_long {
725+ bc.floor
726+ .x_list
727+ .iter()
728+ .map(|&x| headroom_tilt(x as f64 * f64::from(self.config.sample_rate) / (2.0 * half as f64)))
729+ .collect()
730+ } else {
731+ vec![0.0; bc.floor.x_list.len()]
732+ };
690 let (floor_values, quantised) = loop {733 let (floor_values, quantised) = loop {
691 let mut curves: Vec<Vec<f32>> = vec![Vec::new(); channels];734 let mut curves: Vec<Vec<f32>> = vec![Vec::new(); channels];
692 let mut floor_values: Vec<Vec<i32>> = vec![Vec::new(); channels];735 let mut floor_values: Vec<Vec<i32>> = vec![Vec::new(); channels];
@@ -707,6 +750,7 @@ impl VorbisEncoder {
707 bc.co_mask,750 bc.co_mask,
708 masking_offset,751 masking_offset,
709 &peaks,752 &peaks,
753+ &tilt,
710 );754 );
711 let mut curve = vec![0.0f32; half];755 let mut curve = vec![0.0f32; half];
712 render_floor1(&bc.floor, &y, &step2, &mut curve);756 render_floor1(&bc.floor, &y, &step2, &mut curve);
@@ -955,7 +999,8 @@ fn peaks_of(floor: &Floor1, half: usize, spectra: &[&Vec<f32>]) -> Vec<f64> {
955 /// Spread first (a masker covers its neighbours, with an extra Bark-local999 /// Spread first (a masker covers its neighbours, with an extra Bark-local
956 /// near-band pass), then subtract the rate loop's headroom, then hold the1000 /// near-band pass), then subtract the rate loop's headroom, then hold the
957 /// absolute threshold of hearing as a lower bound: below it the residue1001 /// absolute threshold of hearing as a lower bound: below it the residue
958-/// quantises to zero and costs a class-0 partition.1002+/// quantises to zero and costs a class-0 partition. `headroom` is tilted per
1003+/// post by [`headroom_tilt`]: more at LF for a finer step, less at HF.
959 fn fit_floor(1004 fn fit_floor(
960 floor: &Floor1,1005 floor: &Floor1,
961 ath: &[f64],1006 ath: &[f64],
@@ -965,6 +1010,7 @@ fn fit_floor(
965 co_mask: f64,1010 co_mask: f64,
966 masking_offset: f64,1011 masking_offset: f64,
967 peaks: &[f64],1012 peaks: &[f64],
1013+ tilt: &[f64],
968 ) -> (Vec<i32>, Vec<bool>) {1014 ) -> (Vec<i32>, Vec<bool>) {
969 let db: Vec<f64> = peaks1015 let db: Vec<f64> = peaks
970 .iter()1016 .iter()
@@ -998,11 +1044,13 @@ fn fit_floor(
998 let target: Vec<f64> = spread1044 let target: Vec<f64> = spread
999 .iter()1045 .iter()
1000 .zip(ath.iter())1046 .zip(ath.iter())
1001- .map(|(&level, &threshold)| {1047+ .enumerate()
1048+ .map(|(i, (&level, &threshold))| {
1049+ let h = headroom + tilt[i];
1002 let threshold = threshold.max(loudest - co_mask);1050 let threshold = threshold.max(loudest - co_mask);
1003- let offset = (masking_offset - (headroom - range).max(0.0)).max(0.0);1051+ let offset = (masking_offset - (h - range).max(0.0)).max(0.0);
1004- (level - headroom.min(range) + offset)1052+ (level - h.min(range) + offset)
1005- .max(threshold - (headroom - range).max(0.0))1053+ .max(threshold - (h - range).max(0.0))
1006 })1054 })
1007 .collect();1055 .collect();
1008 let y: Vec<i32> = target1056 let y: Vec<i32> = target
lanes/vorbis-psy-r1.sweep.txtmodified+8 -8
@@ -1,9 +1,9 @@
1 source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap verdict1 source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap verdict
2-nik 96 84.0 84.5 -0.61 0.9690 0.9903 0.0213 FAIL2+nik 96 83.8 84.5 -0.84 0.9809 0.9903 0.0094 FAIL
3-nik 128 115.5 115.8 -0.24 0.9838 0.9951 0.0113 FAIL3+nik 128 115.3 115.8 -0.37 0.9899 0.9951 0.0053 FAIL
4-her 96 89.9 89.9 +0.04 0.9668 0.9867 0.0199 FAIL4+her 96 89.3 89.9 -0.65 0.9827 0.9867 0.0040 PASS
5-her 128 123.5 124.9 -1.13 0.9810 0.9927 0.0117 FAIL5+her 128 123.1 124.9 -1.47 0.9889 0.9927 0.0039 PASS
6-reell 96 85.4 85.5 -0.12 0.9792 0.9923 0.0131 FAIL6+reell 96 85.1 85.5 -0.48 0.9890 0.9923 0.0034 PASS
7-reell 128 121.3 120.9 +0.39 0.9914 0.9968 0.0054 FAIL7+reell 128 121.1 120.9 +0.22 0.9952 0.9968 0.0016 PASS
8-dl8a 96 86.9 86.9 -0.01 0.9655 0.9916 0.0261 FAIL8+dl8a 96 86.6 86.9 -0.38 0.9814 0.9916 0.0102 FAIL
9-dl8a 128 118.7 117.8 +0.80 0.9826 0.9957 0.0132 FAIL9+dl8a 128 118.5 117.8 +0.58 0.9906 0.9957 0.0051 FAIL