forge
Explore
Log in

Don't you dare go Hollow

Lane-dq report -- the two delta_q mappings censused on one tpl map, objective at 0.25 shipped for preset 0

Browse files at this commit

ce95864b9cbd890d7482055119214d6c0bcc788eAhmet Kaan GümüşParent: 7680c47
  • docs
    • lane-dq report -- the two delta_q mappings censused on one tpl map, objective at 0.25 shipped for preset 0
Show full message
docs(av1): lane-dq report -- the two delta_q mappings censused on one tpl map, objective at 0.25 shipped for preset 0
lanes/dq.report.mdadded+154 -0
@@ -0,0 +1,154 @@
1+# lane-dq — the per-superblock `delta_q` mapping, ours vs libaom's objective
2+
3+## 0. The charter's premise, corrected first
4+
5+The charter asked what the existing `delta_q` derives its offsets from and
6+"whether the tpl map feeds it at all". It does, and has since lane-deltaq:
7+`encode::deltaq_for_factor` inverts the tpl LAMBDA factor through the `ac_q`
8+table. Nothing was variance-driven and no map was inert. What was never
9+measured is that OUR mapping and LIBAOM's read the same map into offsets an
10+order of magnitude apart — that is this lane's finding, and the strength
11+between them is what shipped.
12+
13+## 1. Census instrument — `EC_AV1_DQ_CENSUS=1`
14+
15+One line per inter frame from `encode_inter_frame`, printing, for the SAME
16+superblocks and the same tpl map, the offsets the shipped mapping
17+(`deltaq_for_factor`) emits and the ones libaom's objective
18+(`deltaq_libaom`, new) would, plus which of the two the frame actually coded
19+(`coded=none` when the lever is off — the census then prices a hypothetical
20+`res = 4` grid). Zero cost when unset.
21+
22+Film B, native gate crop `1920x1024` at `00:40:00`, 12 frames, q=150,
23+preset 0, lever OFF (`enc_probe … gate 0 12 150`, 27634 B = the gate's own
24+q150 point). 480 superblocks per frame, `base=162`, `res=4`:
25+
26+| frame | r_frame | ours (range, \|mean\|, nonzero, levels) | libaom (same) |
27+|---|---|---|---|
28+| … | 2.70 | −4..8, 3.04, 321/480, 4 | −24..32, 13.97, 450/480, 15 |
29+| … | 2.85 | −4..8, 2.81, 308/480, 4 | −28..32, 14.94, 454/480, 16 |
30+| … | 2.83 | −4..8, 2.86, 307/480, 4 | −24..32, 14.32, 448/480, 15 |
31+| … | 2.51 | −4..8, 2.88, 305/480, 4 | −24..32, 14.45, 451/480, 15 |
32+| … | 2.06 | −4..8, 2.93, 312/480, 4 | −24..32, 13.84, 449/480, 15 |
33+| … | 1.74 | −4..8, 2.60, 294/480, 4 | −24..32, 13.58, 447/480, 15 |
34+| … | 1.27 | −4..8, 2.39, 280/480, 4 | −20..32, 12.03, 448/480, 14 |
35+| … | 0.91 | −4..4, 1.76, 211/480, 3 | −20..28, 11.07, 450/480, 13 |
36+| … | 0.45 | −4..4, 1.38, 166/480, 3 | −12..12, 5.87, 409/480, 7 |
37+
38+**The shipped mapping moves ~5x less quantizer than libaom's on the identical
39+map**, and it never reaches its own `±16` clamp (its widest offset is `+8`),
40+so the clamp is NOT what bounds it: the `log2(1+r)` compression plus
41+`TPL_POWER = 0.5` plus the mean normalisation is. libaom's own clamp
42+(`±(delta_q_res * 9 − 1)`, `±32` at `res = 4`) IS reached. The census matches
43+lane-cen3's census fact that libaom codes `delta_q` in every inter frame while
44+we coded it in none at preset 0.
45+
46+The census's `libaom` column prints the strength actually in force, so it is
47+raw libaom (`k = 1`) whenever the lever is off and the shipped `k = 0.25`
48+otherwise — the shipped default on the same clip prints
49+`coded=libaom k=0.25 … libaom range −4..4 |mean| 1.21..1.83`, i.e. the
50+strength brings the objective mapping down to the shipped mapping's own
51+extent while keeping its SHAPE (different superblocks, 145..220 nonzero vs
52+166..211), and codes 28304 B against the control's 27634 B.
53+
54+`aomdec -EC_TRACE_TPL` was not used: it exposes no per-SB qindex, so libaom's
55+mapping is reimplemented on OUR map instead, which is also the only way to
56+compare the two mappings at one map (class `shared-oracle blindness` cuts the
57+other way here — one map, two mappings, is exactly the controlled comparison).
58+
59+## 2. The mapping, from libaom's source
60+
61+`av1_get_q_for_deltaq_objective` (`av1/encoder/encodeframe_utils.c:893`) forms
62+`rk = exp((intra_cost − mc_dep_cost) / w)` in the LOG domain per superblock,
63+divides the frame-level `r0` (`encoder_utils.c:627`, the same expression at
64+frame scope) by it, and asks `av1_get_deltaq_offset` (`rd.c`) for the qindex
65+whose **DC** step is `dc_q(base) / sqrt(beta)`; the offset is clamped to
66+`±(delta_q_res * 9 − 1)`.
67+
68+With per-cell costs `intra` and `intra + mc_dep`, `rk = 1/(1 + r)` for this
69+crate's `r = mc_dep / intra`, so `beta = (1 + r_sb) / (1 + r_frame)` with
70+`r_frame` read the log-mean way libaom reads `r0`. `encode::deltaq_libaom`
71+is that; `encode::tpl_frame_ratio` is `r0`. `tpl_lambda_factors` now returns
72+the raw per-cell ratio beside the lambda factors, because the factor alone has
73+been through a mean normalisation the ratio cannot be recovered across.
74+
75+Two things differ from `deltaq_for_factor` and both are the point: the table
76+inverted is `dc_q` not `ac_q`, and the ratio is read RAW (`sqrt(1+r)`) rather
77+than through the log-compressed, `TPL_POWER`-flattened, mean-normalised lambda
78+factor.
79+
80+Self-check: `encode::tests::the_objective_delta_q_mapping_leans_the_right_way_and_stops_at_libaom_s_clamp`
81+— direction (leaned-on SB finer, idle coarser, average exactly at base),
82+`res`-congruence of every offset, libaom's clamp reached from both ends,
83+monotone in strength, and `tpl_frame_ratio` flat-in/flat-out.
84+
85+## 3. Sweep — 12-frame `bd_rate_screen_native` (BD vs libaom / rav1e)
86+
87+Control reproduces the charter to the digit on all three real rows.
88+
89+| arm | film A | film B | screen |
90+|---|---|---|---|
91+| control (no delta_q) | +21.0/−4.8 | +24.9/−1.9 | +14.5/−33.2 |
92+| shipped mapping (`EC_AV1_DELTAQ=2`) | +20.6/−4.8 | +25.4/−1.1 | byte-identical |
93+| **objective, k=0.25** | **+20.7/−4.8** | **+24.8/−1.7** | byte-identical |
94+| objective, k=0.5 | +20.6/−4.5 | +25.8/−0.7 | byte-identical |
95+| objective, k=1.0 | — | +25.9/−0.1 | — |
96+
97+At 12 frames the lever is flat at k=0.25 and LOSES at k≥0.5 (film B +0.9/+1.2
98+at k=0.5, +1.0/+1.8 at k=1.0 — monotone in strength, so k=1.5 was not run;
99+`deferred` below). The screen capture is byte-identical at every arm: a frame
100+that set `allow_screen_content_tools` codes no delta syntax at all
101+(lane-dq3's content gate), so the keep rule's screen bound is met by
102+construction, not by luck.
103+
104+## 4. Long GOP — 48 pictures, `bd_rate_film_long_gop` (the shape his exports have)
105+
106+| arm | film A | film B |
107+|---|---|---|
108+| control | +25.2/−7.2 | +86.7/+7.3 |
109+| shipped mapping | +24.6/−7.3 | +86.1/+7.5 |
110+| **objective, k=0.25** | **+24.4/−7.5** | **+86.0/+7.3** |
111+| objective, k=0.5 | +23.8/−7.6 | +86.5/+7.9 |
112+| objective, k=1.0 | +24.0/−7.0 | +88.4/+9.7 |
113+
114+Control reproduces the charter to the digit on both rows. **k=0.25 is the only
115+arm down on both films on the libaom column with neither rav1e column worse**
116+(film A −0.8/−0.3, film B −0.7/+0.0): it clears the keep rule's second clause
117+(one row ≥0.5 down, the other flat inside ±0.3) with room, and the screen row
118+is out of this gate but byte-identical anyway. k=0.5 buys film A another 0.6
119+and hands film B back 0.6 on the rav1e column; k=1.0 is worse than k=0.5 on
120+three of the four columns. The lever is a LONG-GOP lever, as lane-cen3
121+predicted and as the class `short-GOP gate hid the gap` says to expect.
122+
123+## 5. Shipped
124+
125+* `speed::DELTAQ_RES[0] = 2` (was 4 = off) — preset 0 codes `delta_q_res = 4`.
126+* `speed::DQ_TPL_K = [0.25, 0, …]` — the objective mapping at strength 0.25,
127+ preset 0 ONLY. Presets 5 and 6 keep `deltaq_for_factor` (`DQ_TPL_K = 0`)
128+ and are byte-identical to before this lane; nothing was measured for them
129+ and nothing changed.
130+* `EC_AV1_DQ_TPL=0/1` forces the mapping either way, `EC_AV1_DQ_TPL_K` the
131+ strength, `EC_AV1_DQ_CENSUS=1` the instrument.
132+* Byte pins re-taken with a four-line comment: `(150, 8325 → 8419)`,
133+ `(60, 33014 → 33029)`; green at default and at `EC_AV1_SPEED=6`.
134+
135+Spec syntax: unchanged from lane-deltaq — the frame's `delta_q_present` /
136+`delta_q_res` go through `write_delta_q_params`, the per-SB `delta_qindex`
137+through `tile::write_delta_q` at the spec's `skip → cdef → delta_q` order,
138+`delta_lf_present` stays 0, and the encoder's own trial decode reads the frame
139+back (a desync would refuse, class `refusal-from-own-desync`).
140+
141+## Deferred
142+
143+* `deferred: objective k=1.5 at 12 frames —` the 12-frame sweep is monotone
144+ worse in k above 0.25 (film B +0.9 at 0.5, +1.0 at 1.0) and long GOP peaks
145+ at 0.25/0.5, so 1.5 cannot win either gate — `unblocked by a reason to
146+ believe the curve turns back up`.
147+* `deferred: the objective mapping at presets 5 and 6 —` they already ship
148+ `delta_q` through the OLD mapping and are untouched here; a strength for
149+ them is a second sweep on a different preset — `unblocked by a lane that
150+ charters presets 5/6`.
151+* `deferred: per-level (ARF vs leaf) strength —` lane-cen3 says our top ARF is
152+ the overspent level; a single frame-type-blind strength cannot move quality
153+ toward the key, and this lane deliberately did not re-open the pyramid
154+ offsets — `unblocked by a lane that charters both together`.