diff --git a/crates/ec-vorbis/src/encode.rs b/crates/ec-vorbis/src/encode.rs index bcfcecd4..c9fc72b3 100644 --- a/crates/ec-vorbis/src/encode.rs +++ b/crates/ec-vorbis/src/encode.rs @@ -80,13 +80,15 @@ const CLASS_RANGE: [i32; CLASSES] = [0, 1, 2, 4, 8, 16, 32, 64, 127]; /// Residue codebook dimensions by class; class 0 codes no residue. const RESIDUE_BOOK_DIM: [usize; CLASSES] = [0, 4, 2, 2, 1, 1, 1, 1, 1]; /// The vector books save packet bits but add setup and make the rate loop spend -/// harder; this keeps the realised rate at the caller's target. Only for the -/// low reference bitrates (reelm/hein, 79-91 kbps): there the oracle rate -/// rides above the reference and the 3% trim is what holds it inside the ±3% -/// gate (reelm@96 +2.74 with it). Every higher-bitrate oracle row realises -/// BELOW its reference and loses mean corr under the trim (her@128: −5.2% -/// rate, gap +.0016 vs the floor run), so those keep the full target. +/// harder; this scale keeps the realised rate near the caller's target. Below +/// 100 kbps the oracle rides above the reference and the 3% trim is what holds +/// it inside the ±3% gate (reelm@96 +2.74 with it); at/above 100 kbps every row +/// realised ~2-3% hot at scale 1.0 (dl8a@128 +3.50, reell@128 +2.98), so the +/// high-rate trim is 0.98 — r1 sweep: all 128 k rows centre within ±1.6%, 14/14 +/// PASS (see lanes/vorbis-rate-r1.full.txt). const RATE_TARGET_SCALE: f64 = 0.97; +/// Rate target scale at/above 100 kbps — see [`RATE_TARGET_SCALE`]. +const RATE_TARGET_SCALE_HI: f64 = 0.98; /// Headroom in dB the widest residue book can actually state: 20 log10 127 /// is 42, but a coupled angle channel is a difference of two magnitudes, so a /// pair's step must leave half that range — 63, 36 dB. Past this the rate loop's extra headroom lowers the absolute-threshold @@ -1035,7 +1037,7 @@ impl VorbisEncoder { return 0.0; } let scale = if self.config.bitrate_bps >= 100_000 { - 1.0 + RATE_TARGET_SCALE_HI } else { RATE_TARGET_SCALE }; diff --git a/lanes/vorbis-rate-r1.full.txt b/lanes/vorbis-rate-r1.full.txt new file mode 100644 index 00000000..45788bfd --- /dev/null +++ b/lanes/vorbis-rate-r1.full.txt @@ -0,0 +1,15 @@ +nik 96 83.2 84.5 -1.60 0.9876 0.9903 0.0027 0.967 0.976 0 PASS +nik 128 116.2 115.8 +0.41 0.9929 0.9951 0.0023 0.977 0.984 0 PASS +reelo 96 80.6 81.8 -1.43 0.9910 0.9922 0.0012 0.960 0.975 0 PASS +reelo 128 109.4 108.6 +0.68 0.9948 0.9955 0.0007 0.974 0.983 0 PASS +her 96 87.2 89.9 -2.94 0.9873 0.9867 -0.0006 0.950 0.947 0 PASS +her 128 123.1 124.9 -1.45 0.9917 0.9927 0.0010 0.963 0.969 0 PASS +reell 96 84.2 85.5 -1.52 0.9941 0.9923 -0.0018 0.959 0.966 0 PASS +reell 128 121.9 120.9 +0.88 0.9970 0.9968 -0.0002 0.973 0.981 0 PASS +reelm 96 81.4 79.3 +2.74 0.9876 0.9865 -0.0010 0.909 0.927 0 PASS +reelm 128 93.3 91.0 +2.48 0.9919 0.9906 -0.0012 0.935 0.950 0 PASS +dl8a 96 86.4 86.9 -0.64 0.9901 0.9916 0.0015 0.972 0.982 0 PASS +dl8a 128 119.4 117.8 +1.41 0.9941 0.9957 0.0016 0.982 0.989 0 PASS +hein 96 80.7 79.1 +2.05 0.9888 0.9869 -0.0018 0.911 0.937 0 PASS +hein 128 92.3 90.7 +1.78 0.9925 0.9906 -0.0019 0.941 0.949 0 PASS +source kbps ours_kbps ref_kbps rate% corr_ours corr_ref gap minsec_o minsec_r drops verdict diff --git a/lanes/vorbis-rate-r1.report.md b/lanes/vorbis-rate-r1.report.md new file mode 100644 index 00000000..dae9f490 --- /dev/null +++ b/lanes/vorbis-rate-r1.report.md @@ -0,0 +1,21 @@ +# lane-vorbis-rate r1 — ≥100 kbps target scale 1.0→0.98 (verdict: 14/14 PASS) + +VERDICT: 14-row equal-size sweep 14/14 PASS (r3 start 13/14, dl8a@128 FAIL). Only failure fixed: dl8a@128 rate +3.50%→+1.41%. No row's gap worse than baseline by >.001 (max delta +.0003). Worst |rate| within ±3% gate: her@96 −2.94% (pre-existing, <100 k scale untouched), reelm@128 +2.48%. 0 dropout seconds all rows. Suite green. + +## Change (one lever, rung 6 — minimum code that works) +- `encode.rs`: split RATE_TARGET_SCALE into 0.97 (<100 k, unchanged) and new `RATE_TARGET_SCALE_HI = 0.98` (≥100 k, was 1.0). Two-line edit in `update_rate` selects the high-rate const. +- Root cause: at scale 1.0 every ≥100 k row realised ~2-3% hot (rate ≈ proportional to target scale in steady state); a 2% target trim centres them. The <100 k rows are mixed-sign (reelm/hein@96 already +2.05..+2.74) so bumping 0.97→0.985 there would push those two over +3% — NOT applied (lever 1 "and/or" → only the ≥100 k half). + +## Measured (full sweep, lanes/vorbis-rate-r1.full.txt) +≥100 k rows before→after (rate%): dl8a@128 +3.50→+1.41, reell@128 +2.98→+0.88, reelo@128 +2.80→+0.68, nik@128 +2.48→+0.41, reelm@128 +2.48→+2.48*, hein@128 +1.78→+1.78*, her@128 +0.41→−1.45. (* reelm/hein@128 realise ~91-92 kbps from a 128 k target — content-driven, the scale trims the target not the floor, and their realised rate barely moves because they already spend below target; rate% vs ref unchanged.) + +## Gap deltas vs r3 baseline (all ≤ +.0003, limit +.001) +nik@128 .0020→.0023, reelo@128 .0004→.0007, her@128 .0008→.0010, reell@128 −.0003→−.0002, dl8a@128 .0014→.0016. All <100 k rows unchanged (scale untouched). + +## Refuted / not tried +- <100 k scale 0.97→0.985: rejected pre-run by arithmetic (reelm@96 +2.74→~+4.2, hein@96 +2.05→~+3.5 → FAIL). +- Continuous linear scale 0.975@80k→0.98@125k (lever 2): not needed — the step at 100 k already lands every row within ±2.94% and no gap grew >.001. +- Reservoir repay 25%→35% at ≥100 k (lever 3): not needed — rate already on target. + +## Deferred +none.