diff --git a/crates/ec-h264/tests/encode.rs b/crates/ec-h264/tests/encode.rs index 1160b090..9aa3f2ba 100644 --- a/crates/ec-h264/tests/encode.rs +++ b/crates/ec-h264/tests/encode.rs @@ -908,9 +908,19 @@ fn x264_encode_qp(sources: &[Planes], w: usize, h: usize, qp: i32, gop: u32) -> // ipratio/pbratio 1.0 matter: x264's constant-QP mode otherwise codes // I pictures at a lower QP than the one asked for, which reads as a // rate-quality win that is really a different quantiser. + // EC_H264_X264_PARAMS appends to this list, which is how a single + // reference feature gets attributed: running the sweep again with + // `trellis=0` says how much of x264's lead is its rate-distortion + // quantisation rather than its prediction. .args([ "-x264-params", - "scenecut=0:aq-mode=0:psy=0:8x8dct=0:ipratio=1.0:pbratio=1.0:qcomp=1.0:chroma-qp-offset=0", + &format!( + "scenecut=0:aq-mode=0:psy=0:8x8dct=0:ipratio=1.0:pbratio=1.0:qcomp=1.0:chroma-qp-offset=0{}", + match std::env::var("EC_H264_X264_PARAMS") { + Ok(extra) if !extra.trim().is_empty() => format!(":{}", extra.trim()), + _ => String::new(), + } + ), ]) .args(["-f", "h264"]) .arg(&out) diff --git a/lanes/h264x264-r1.report.md b/lanes/h264x264-r1.report.md index adc7cb38..1aa17e1e 100644 --- a/lanes/h264x264-r1.report.md +++ b/lanes/h264x264-r1.report.md @@ -92,5 +92,22 @@ Synthetic default -5.202 -> -5.140 dB, floor retightened to -5.25. Full `ec-h264 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. + Attributing the rest by ablating **the reference** (`EC_H264_X264_PARAMS`, same clip): + + | x264 configuration | GOP 10 | all-intra | + |---|---|---| + | `-preset medium` (the gate's) | -1.557 dB | -0.749 dB | + | `trellis=0` | -1.456 dB | -0.587 dB | + | `trellis=2` | -1.642 dB | -0.811 dB | + | `trellis=0:subme=1:me=dia` | -0.873 dB | **+0.216 dB** | + + Trellis is worth only 0.10 dB inter and 0.16 dB intra of x264's lead, so RDOQ is not the + lever it looked like. Turning off x264's rate-distortion **mode decision** (`subme=1`, which + drops the RD refinement of macroblock types) is worth 0.80 dB intra and a further 0.58 dB + inter -- and with it off we are *ahead* of x264 on all-intra by 0.216 dB. + + So the distance is the mode decision: we choose macroblock and prediction modes on + SATD-plus-estimated-rate, x264 chooses the survivors on true coded bits against + reconstruction SSD. That is the next build slice, and it is worth about 1.4 dB. P_8x8 + sub-partitions and the search itself stay unmeasured but are bounded above by what is left + after that.