forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-h265-rdo': five intra candidates reach the rate-distortion trial

Browse files at this commit

966bf254eb49ca61cfbb13b6f35734e998103f0fAhmet Kaan GümüşParent: ccc4650b24f633
crates/ec-h265/src/encoder.rsmodified+19 -1
@@ -75,6 +75,24 @@ pub struct EncoderConfig {
7575 pub ctb_size: usize,
7676 /// How many of the 35 intra modes get a full rate-distortion trial, on top
7777 /// of the most probable mode, which always gets one.
78+ ///
79+ /// Swept against x265 at matched features on four real clips (BD-PSNR
80+ /// luma / all-plane, wall time for the whole four-QP ladder):
81+ ///
82+ /// | k | film 3840x1608 | web 1138x640 | screen 2560x1440 | phone 1080p |
83+ /// |---|----------------|-------------------|------------------|-------------|
84+ /// | 1 | -0.840 / -0.815 38s | -0.728 / -0.733 8s | | |
85+ /// | 2 | -0.731 / -0.730 40s | -0.603 / -0.632 9s | -2.521 / -2.420 29s | -0.435 / -0.444 11s |
86+ /// | 3 | -0.703 / -0.709 43s | -0.556 / -0.596 10s | -2.493 / -2.402 31s | -0.401 / -0.416 11s |
87+ /// | 4 | -0.693 / -0.705 46s | -0.530 / -0.574 10s | | |
88+ /// | 5 | -0.685 / -0.703 49s | -0.507 / -0.556 11s | -2.465 / -2.360 35s | -0.366 / -0.387 13s |
89+ /// | 8 | -0.684 / -0.710 59s | -0.471 / -0.525 14s | -2.453 / -2.368 41s | -0.340 / -0.361 16s |
90+ ///
91+ /// Every clip improves monotonically up to 5, which is why 5 is the
92+ /// default. Eight buys nothing on the film clip (+0.001 luma, and its
93+ /// all-plane figure goes *backwards*) for another 20% of wall time, so the
94+ /// knee is where the default sits. `EC_H265_RDO_CANDIDATES` in the gate
95+ /// test re-runs the sweep.
7896 pub rdo_candidates: usize,
7997 /// Smallest coding unit the search will produce, 8 or 16. Sixteen is a
8098 /// *coarser* search that is not always faster: on real pictures the 8x8
@@ -106,7 +124,7 @@ impl EncoderConfig {
106124 rate_control: RateControl::ConstantQp(27),
107125 threads: 0,
108126 ctb_size: 32,
109- rdo_candidates: 2,
127+ rdo_candidates: 5,
110128 min_cu_size: 8,
111129 video_signal_type: None,
112130 sample_aspect_ratio: None,
crates/ec-h265/tests/encode.rsmodified+11 -4
@@ -16,7 +16,7 @@ type Planes = (Vec<u8>, Vec<u8>, Vec<u8>);
1616 /// measured value with 0.15 dB of room for platform noise, so the advantage can
1717 /// shrink but not grow unnoticed; it is not a claim that the number is fine.
1818 ///
19-/// Measured +2.456 dB luma / +3.158 dB YUV on the recalibrated run (352x288,
19+/// Measured +2.507 dB luma / +3.238 dB YUV at `rdo_candidates: 5` (352x288,
2020 /// 24 pictures of `Clip::render_smooth`, x265 at QP 22/26/30/34, our ladder
2121 /// auto-shifted from a QP-26 probe to 16/20/24/28, both sides decoded through
2222 /// ffmpeg, union-range BD-PSNR, 0% extrapolation both sides). This is a
@@ -24,8 +24,10 @@ type Planes = (Vec<u8>, Vec<u8>, Vec<u8>);
2424 /// encoder is no leaner than x265 at matched QP (the probe measures a shift of
2525 /// 0) and the aligned BD is negative. Real-clip numbers, 24 pictures after
2626 /// 1500, ladders auto-aligned to 22/26/30/34, 0% extrapolation both sides:
27-/// • 3840x1608 film: -0.731 dB luma / -0.730 dB YUV
28-/// • 1138x640 web clip: -0.603 dB luma / -0.632 dB YUV
27+/// • 3840x1608 film: -0.685 dB luma / -0.703 dB YUV
28+/// • 1138x640 web clip: -0.507 dB luma / -0.556 dB YUV
29+/// • 2560x1440 screen capture: -2.465 dB luma / -2.360 dB YUV
30+/// • 1080p phone clip: -0.366 dB luma / -0.387 dB YUV
2931 /// Those two are the real gap to close; the synthetic number only guards
3032 /// against regression on a clip whose content is pinned.
3133 ///
@@ -36,7 +38,7 @@ type Planes = (Vec<u8>, Vec<u8>, Vec<u8>);
3638 /// all-intra rate-quality slope is genuine content behaviour (x264 forced
3739 /// all-intra shows the same shape); the fix is to auto-align the ladders from
3840 /// a probe encode, not to change x265's rate control.
39-const BD_PSNR_VS_X265_FLOOR: f64 = 2.306;
41+const BD_PSNR_VS_X265_FLOOR: f64 = 2.357;
4042
4143 /// A synthetic source with real structure: smooth gradients, a band of
4244 /// sinusoidal texture and a translating box, so prediction matters — the half
@@ -425,6 +427,11 @@ fn bd_psnr_vs_x265() {
425427 cfg.rate_control = RateControl::ConstantQp(qp);
426428 cfg.keep_recon = true;
427429 cfg.threads = 0;
430+ // Ablation knob: how many SATD survivors reach the full rate-distortion
431+ // trial in the luma mode search. The shipped default is 5.
432+ if let Ok(k) = std::env::var("EC_H265_RDO_CANDIDATES") {
433+ cfg.rdo_candidates = k.parse().expect("EC_H265_RDO_CANDIDATES must be a number");
434+ }
428435 let enc = Encoder::new(cfg).expect("encoder");
429436 let (mut stream, mut sum_recon) = (Vec::new(), 0.0);
430437 for (y, u, v) in &sources {