Attribute x264's lead to its mode decision, not trellis
Browse files at this commitb36a1af9041239021b57a99bdc99784e773aa37eParent: b25750f- test
- attribute x264's lead to its mode decision, not trellis
2 changed files +30 -3
crates/ec-h264/tests/encode.rsmodified+11 -1
| @@ -908,9 +908,19 @@ fn x264_encode_qp(sources: &[Planes], w: usize, h: usize, qp: i32, gop: u32) -> | |||
| 908 | // ipratio/pbratio 1.0 matter: x264's constant-QP mode otherwise codes | 908 | // ipratio/pbratio 1.0 matter: x264's constant-QP mode otherwise codes |
| 909 | // I pictures at a lower QP than the one asked for, which reads as a | 909 | // I pictures at a lower QP than the one asked for, which reads as a |
| 910 | // rate-quality win that is really a different quantiser. | 910 | // rate-quality win that is really a different quantiser. |
| 911 | + // EC_H264_X264_PARAMS appends to this list, which is how a single | ||
| 912 | + // reference feature gets attributed: running the sweep again with | ||
| 913 | + // `trellis=0` says how much of x264's lead is its rate-distortion | ||
| 914 | + // quantisation rather than its prediction. | ||
| 911 | .args([ | 915 | .args([ |
| 912 | "-x264-params", | 916 | "-x264-params", |
| 913 | - "scenecut=0:aq-mode=0:psy=0:8x8dct=0:ipratio=1.0:pbratio=1.0:qcomp=1.0:chroma-qp-offset=0", | 917 | + &format!( |
| 918 | + "scenecut=0:aq-mode=0:psy=0:8x8dct=0:ipratio=1.0:pbratio=1.0:qcomp=1.0:chroma-qp-offset=0{}", | ||
| 919 | + match std::env::var("EC_H264_X264_PARAMS") { | ||
| 920 | + Ok(extra) if !extra.trim().is_empty() => format!(":{}", extra.trim()), | ||
| 921 | + _ => String::new(), | ||
| 922 | + } | ||
| 923 | + ), | ||
| 914 | ]) | 924 | ]) |
| 915 | .args(["-f", "h264"]) | 925 | .args(["-f", "h264"]) |
| 916 | .arg(&out) | 926 | .arg(&out) |
lanes/h264x264-r1.report.mdmodified+19 -2
| @@ -92,5 +92,22 @@ Synthetic default -5.202 -> -5.140 dB, floor retightened to -5.25. Full `ec-h264 | |||
| 92 | counts move 0.8%, so the path is reached and simply does not matter. Recorded in | 92 | counts move 0.8%, so the path is reached and simply does not matter. Recorded in |
| 93 | `round_offset`'s doc comment so the sweep is not repeated. | 93 | `round_offset`'s doc comment so the sweep is not repeated. |
| 94 | 94 | ||
| 95 | - Still untested, in order of expected size: no trellis/RDOQ (x264 runs `trellis=1` at | 95 | + Attributing the rest by ablating **the reference** (`EC_H264_X264_PARAMS`, same clip): |
| 96 | - `-preset medium`), no P_8x8 sub-partitions, and the intra mode decision itself. | 96 | + |
| 97 | + | x264 configuration | GOP 10 | all-intra | | ||
| 98 | + |---|---|---| | ||
| 99 | + | `-preset medium` (the gate's) | -1.557 dB | -0.749 dB | | ||
| 100 | + | `trellis=0` | -1.456 dB | -0.587 dB | | ||
| 101 | + | `trellis=2` | -1.642 dB | -0.811 dB | | ||
| 102 | + | `trellis=0:subme=1:me=dia` | -0.873 dB | **+0.216 dB** | | ||
| 103 | + | ||
| 104 | + Trellis is worth only 0.10 dB inter and 0.16 dB intra of x264's lead, so RDOQ is not the | ||
| 105 | + lever it looked like. Turning off x264's rate-distortion **mode decision** (`subme=1`, which | ||
| 106 | + drops the RD refinement of macroblock types) is worth 0.80 dB intra and a further 0.58 dB | ||
| 107 | + inter -- and with it off we are *ahead* of x264 on all-intra by 0.216 dB. | ||
| 108 | + | ||
| 109 | + So the distance is the mode decision: we choose macroblock and prediction modes on | ||
| 110 | + SATD-plus-estimated-rate, x264 chooses the survivors on true coded bits against | ||
| 111 | + reconstruction SSD. That is the next build slice, and it is worth about 1.4 dB. P_8x8 | ||
| 112 | + sub-partitions and the search itself stay unmeasured but are bounded above by what is left | ||
| 113 | + after that. | ||