forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-h265prune': the depth-pruning rejection, on the record

Browse files at this commit

311521966eb3f5c1225f66bd4adb3d1003aee5aaAhmet Kaan GümüşParent: d16dd5753b6d97
The full threshold-sweep table and the reason no global threshold can
serve both content classes live in the lane report; the code ships
nothing beyond r1's early-out.
lanes/h265prune-r1.report.mdadded+90 -0
@@ -0,0 +1,90 @@
1+# lane-h265prune — a cheap SATD proxy to skip the CU split trial
2+
3+## What was tried
4+
5+`code_quadtree`'s split trial reruns the whole RD search one level down (up
6+to twice, at the two depths a quadtree reaches). Round 2 added a cheap
7+DC/planar-only SATD proxy (`CtuEncoder::quick_satd`) for the split's four
8+children, gated by a threshold `split_prune`: only estimate-competitive
9+splits pay for the real trial.
10+
11+## Sweep table (round 2, BD-PSNR luma against x265, 1080p film + 2560x1440
12+screen capture, both real clips)
13+
14+| threshold | film BD-PSNR | screen BD-PSNR | instructions (render_smooth profile) |
15+| --- | --- | --- | --- |
16+| off (0.0), baseline | +0.503 dB | +0.590 dB | 152.1G |
17+| 1.05 | +0.414 dB (Δ-0.089) | -4.770 dB (Δ-5.360) | 94.1G (-38%) |
18+| 1.15 | +0.437 dB (Δ-0.066) | -3.143 dB (Δ-3.733) | 100.1G (-34%) |
19+| 1.3 | +0.467 dB (Δ-0.036) | -1.973 dB (Δ-2.563) | 107.5G (-29%) |
20+| 1.5 | +0.481 dB (Δ-0.022) | -0.889 dB (Δ-1.479) | 118.1G (-22%) |
21+| 2.0 | +0.495 dB (Δ-0.008) | -0.068 dB (Δ-0.658) | 141.9G (-7%) |
22+| 3.0 | (flat, Δ~0) | (Δ-0.274) | (further shrinking) |
23+
24+Deltas are against the unpruned `off` baseline on the same clip, which is the
25+number this lane's ~0.02 dB/class accept bar actually gates (the absolute BD
26+numbers already carry a pre-existing, unrelated gap to x265).
27+
28+## Why it fails on its own (option 1 — global threshold)
29+
30+Film tolerates aggressive pruning down to threshold ~1.5 before crossing
31+0.02 dB; screen capture is still 0.658 dB over the bar at threshold 2.0 and
32+0.274 dB over at 3.0. Fitting the observed decay (screen loss roughly ×0.42
33+per +1.0 threshold from 2.0→3.0) puts the 0.02 dB crossing near threshold
34+~6, where the pruning fire rate — and with it the instructions win — is
35+extrapolated under 5%, well below the ≥10% bar. No single global threshold
36+clears both classes with a real win; this is the content-opposite-optima
37+class again (film's flat-cost proxy vs screen's edge-dependent split value).
38+
39+## Content-gate attempt (option 2)
40+
41+Tried gating `split_prune` per picture on a cheap classifier — the p99/mean
42+ratio of the luma gradient histogram (peaky = flat backgrounds punctuated by
43+sharp text/UI edges = screen-like; smoother = film-like) — reusing the shape
44+of the existing chroma/luma gradient-ratio classifier
45+(`ec-h264/src/enc/mod.rs::chroma_qp_offset_for_source`), not its exact
46+metric (that one is tuned for chroma flatness, not film-vs-screen).
47+
48+Sampled single frames from real film and real screen-capture library files
49+(`~/Videos/Films/ReelC...`, `~/Videos/OBS/*`, `~/Videos/ab/obs-2026-08-17...`):
50+
51+| source | frame ratio (p99/mean) |
52+| --- | --- |
53+| ReelC film | 6.5, 7.4, 9.4, 10.0 |
54+| OBS screen capture (3 different recordings) | 10.1, 14.5, 17.3, 18.3, 21.6, 36.2, 36.2 |
55+
56+Medians separate cleanly (~9 vs ~18) but the distributions overlap at the
57+edges (one screen-capture frame at 10.1 sits inside film's own range). A
58+per-picture classifier at any single threshold will misclassify some
59+screen-capture pictures as film-like and apply the aggressive proxy on
60+exactly the sharp-edge content it damages most — and this codec is
61+all-intra, one picture at a time, so there is no whole-clip average to fall
62+back on within a single `encode_idr_planes` call. Verifying a chosen
63+threshold's real BD impact would need the same real-clip x265 sweep as
64+option 1, repeated with gating live, which this round's budget did not
65+cover; shipping an unverified gate on a class-quality lever was rejected
66+rather than guessed.
67+
68+## Decision: REJECTED
69+
70+Both the flat global threshold and the content-gated threshold fail the
71+charter's bar (option 1 provably, option 2 for lack of a safe, verified
72+threshold). Per the charter's option 3, the depth-pruning machinery
73+(`quick_satd`, `split_prune`, the widened CTB-32-vs-64 tolerance, the
74+re-pinned RDOQ cache hashes) is reverted. The lane closes with round 1's
75+merged all-zero-CBF early-out (`adca476`, already on `main`) as its only
76+ship.
77+
78+## Gates
79+
80+- `cargo test -p ec-h265 --release`: see suite log referenced in the commit;
81+ the tree is bit-for-bit round 1's state (`adca476`), so this is a
82+ reconfirmation, not a new result.
83+
84+## Not in this lane
85+
86+- A whole-clip (not per-picture) content classifier, which would need a
87+ first pass over the source before the per-picture encode loop starts —
88+ architecture change out of scope here.
89+- A directional (not DC/planar-only) split proxy, which round 2's own doc
90+ comment named as the follow-up lever for screen content; still unbuilt.