diff --git a/crates/ec-h265/src/ctu.rs b/crates/ec-h265/src/ctu.rs index 452d5827..3b906814 100644 --- a/crates/ec-h265/src/ctu.rs +++ b/crates/ec-h265/src/ctu.rs @@ -1553,7 +1553,12 @@ impl<'a> CtuEncoder<'a> { for (i, &sample) in source[..n * n].iter().enumerate() { self.scratch.residual[i] = i32::from(sample) - i32::from(self.scratch.pred[i]); } - let skip = n == 4 && if self.ts_rd { self.ts_luma } else { self.transform_skip }; + let skip = n == 4 + && if self.ts_rd { + self.ts_luma + } else { + self.transform_skip + }; let dst = uses_dst(n, true); if skip { forward_transform_skip(&self.scratch.residual, &mut self.scratch.coeffs, n); diff --git a/crates/ec-h265/src/encoder.rs b/crates/ec-h265/src/encoder.rs index eedcf1bf..2471cadb 100644 --- a/crates/ec-h265/src/encoder.rs +++ b/crates/ec-h265/src/encoder.rs @@ -183,6 +183,26 @@ pub struct EncoderConfig { /// loss. `false` restores exact per-trial CABAC replay for A/B. pub rdoq_estimate: bool, /// Whether 4x4 TUs may skip the integer transform. + /// + /// `Rd` by default: the tool is the screen-content lever, and it wants a + /// per-block decision, not a switch. BD-PSNR luma / all-plane against x265 + /// at matched features over the four-QP ladder (`EC_H265_TSKIP=0|always|rd` + /// in `bd_psnr_vs_x265`, real clips, 24 pictures each): + /// + /// | clip | `Off` | `AlwaysFor4x4` | `Rd` | + /// |------|-------|----------------|------| + /// | 1440p screen capture A | -0.381 / -0.438 | +1.485 / +1.373 | +1.034 / +0.918 | + /// | 1440p screen capture B | +0.716 / +0.561 | +0.783 / +0.222 | +1.133 / +0.781 | + /// | 1440p screen capture C | +0.213 / +0.099 | | +0.124 / +0.008 | + /// | 1080p film | +0.584 / +0.468 | | +0.580 / +0.460 | + /// + /// Unconditional skip is worth +1.8 dB all-plane on A and -0.34 dB on B, so + /// neither setting of a switch is right; the per-block trial takes A's win + /// without B's loss and leaves film where it was (-0.008 dB, the estimate + /// proxy's noise). The cost is the second quantise-and-reconstruct pass on + /// every committed 4x4 luma block: the whole four-QP ladder went 111s -> + /// 290s on screen capture A and 427s -> 494s on film. Set `Off` to buy that + /// time back. pub transform_skip: TransformSkip, /// Whether the transform tree may split once (rate-quantisation transform): /// the luma TU of a 2Nx2N coding unit may be coded as four half-size @@ -243,7 +263,7 @@ impl EncoderConfig { sign_hiding: false, rdoq: true, rdoq_estimate: true, - transform_skip: TransformSkip::Off, + transform_skip: TransformSkip::Rd, rqt: true, cu64: true, video_signal_type: None, diff --git a/crates/ec-h265/tests/rdoq_cache_hash.rs b/crates/ec-h265/tests/rdoq_cache_hash.rs index 158da6e1..88c00dd5 100644 --- a/crates/ec-h265/tests/rdoq_cache_hash.rs +++ b/crates/ec-h265/tests/rdoq_cache_hash.rs @@ -64,8 +64,13 @@ fn rdoq_cache_hash_416x240() { /// (`EncoderConfig::rdoq_estimate`, now on by default) — deliberately /// bit-different, not exact-mode-preserving; see that field's doc comment /// for the BD/speed numbers that justified flipping the default. +/// +/// lane-h265screen: re-pinned after every committed 4x4 luma block gained a +/// rate-distortion decision on `transform_skip_flag` (`TransformSkip::Rd`, now +/// the default) — deliberately bit-different; see that field's doc comment for +/// the BD numbers per clip. #[test] fn rdoq_cache_hash_is_pinned() { - assert_eq!(encode_hash(416, 240), 0x3dc2876c9104b7b3); - assert_eq!(encode_hash(1920, 1080), 0x03188155f21c2174); + assert_eq!(encode_hash(416, 240), 0x39d93f8b600b072e); + assert_eq!(encode_hash(1920, 1080), 0x8c5e05c6f65515c8); }