diff --git a/crates/ec-h264/src/enc/quant.rs b/crates/ec-h264/src/enc/quant.rs index bd23233a..b17066e1 100644 --- a/crates/ec-h264/src/enc/quant.rs +++ b/crates/ec-h264/src/enc/quant.rs @@ -29,6 +29,16 @@ const MF: [[i32; 3]; 6] = [ /// block at 1/6 — the classic asymmetry, which spends bits where prediction is /// weakest. Measured against 1/3 and 1/2 for the inter case on 1080p camera /// and screen-capture clips: 1/6 is level or ahead at matched bitrate. +/// +/// Re-measured 2026-08-23 against x264 with `bd_psnr_vs_x264` on a 3840x1608 +/// clip, sweeping both numerators as sixty-fourths the way x264 spells +/// `--deadzone-intra` / `--deadzone-inter`. The intra offset is the one that +/// matters and ours is the better of the two: x264's 11/64 reads -1.667 dB +/// all-intra where ours (21/64, i.e. 1/3) reads -0.745 dB, with the inter +/// value making no difference to that. The inter offset is inert across the +/// whole useful range -- 6/64, 16/64, 21/64 and 32/64 span -1.571 to +/// -1.532 dB, a 0.04 dB spread, while the bit counts move by 0.8%. So the +/// remaining distance to x264 is not in the dead zone. #[inline] fn round_offset(qbits: u32, intra: bool) -> i32 { (1i32 << qbits) / if intra { 3 } else { 6 } diff --git a/lanes/h264x264-r1.report.md b/lanes/h264x264-r1.report.md index 9c896b8c..adc7cb38 100644 --- a/lanes/h264x264-r1.report.md +++ b/lanes/h264x264-r1.report.md @@ -70,7 +70,27 @@ Synthetic default -5.202 -> -5.140 dB, floor retightened to -5.25. Full `ec-h264 reads -1.587 dB against `Fast`'s -1.557 dB — slower and marginally worse. Either its search changes need to be replaced with something that measures, or the preset should go. Needs the user's call because it is public API. -- **The remaining -1.557 dB is still unattributed.** All-intra was -0.749 dB before this fix; - re-measure it now and split the rest between prediction and quantisation. The untested - hypothesis on record: our dead zone is inverted against x264's (ours 1/3 intra, 1/6 inter; - x264 uses 11/64 intra, 21/64 inter), and we have no trellis/RDOQ and no P_8x8 sub-partitions. +- **The remaining -1.557 dB is still unattributed.** All-intra re-measures at -0.749 dB after + the fix (unchanged -- I pictures always had Intra_4x4), so the split is about 0.75 dB intra + and 0.81 dB P-picture coding. + + The dead-zone hypothesis on record -- that ours is inverted against x264's -- was tested and + is **dead**. Sweeping both numerators as sixty-fourths on the same clip: + + | intra, inter (/64) | GOP 10 | all-intra | + |---|---|---| + | ours (21.3, 10.7 equivalent) | -1.557 dB | -0.749 dB | + | 11, 21 (x264's own) | -2.132 dB | -1.667 dB | + | 21, 21 | -1.535 dB | -0.745 dB | + | 11, 11 | -2.128 dB | -1.667 dB | + | 21, 6 | -1.557 dB | -0.745 dB | + | 21, 16 | -1.532 dB | - | + | 21, 32 | -1.571 dB | - | + + The intra offset is the only one that moves the number, and ours is the better of the two by + 0.92 dB all-intra. The inter offset is inert: 6/64 through 32/64 span 0.04 dB while the bit + counts move 0.8%, so the path is reached and simply does not matter. Recorded in + `round_offset`'s doc comment so the sweep is not repeated. + + Still untested, in order of expected size: no trellis/RDOQ (x264 runs `trellis=1` at + `-preset medium`), no P_8x8 sub-partitions, and the intra mode decision itself.