forge
Explore
Log in

Don't you dare go Hollow

av1intrapred: arm INTRABC_CHROMA_TX for leaf8 TX4-split intrabc leaves

Browse files at this commit

7fb533fa99c91c8580b3ed4cde69c3b2da050f2eAhmet Kaan GümüşParent: cfa56e2
decode_leaf8's resolved==4 (TX4 var-tx split) arm read each luma 4x4 TU
off the 16-symbol inter tx_type set (correct) but never armed
INTRABC_CHROMA_TX, so the group's chroma reads fell back to
default_intra_tx_type(DC_PRED) = DCT_DCT and took the 2D eob row, 2D
scan and 2D nz contexts where libaom (which classifies intrabc as
is_inter_block) inherits the co-located luma TU's coded type. R5's first
fork, mi (36,66): luma TU (0,0) coded H_ADST, chroma U decoded eob=11
off the 2D row where aomdec decoded eob=13 off the class-1 row.

Also disarm the slot after the arm's two chroma reads: left set, the
next leaf's chroma inherited the intrabc leaf's luma type instead of its
own derivation (seen live at mi (54,24)).

Gates: R5 entropy now aligns 3321/3321 all_zero reads rng-for-rng vs
instrumented aomdec (was 2162); luma byte-exact; first pixel diff moved
82216 -> 231864, total chroma diffs 127862 -> 3305. W2 (cq8 re-encode)
352 -> 231848, 305032 -> 3254. R9 stays byte-exact vs ffmpeg. Suite:
607 passed / 0 failed (exit 0).

Remaining chroma diffs are a new class - intrabc chroma frame-copy
prediction (origin U(184,4), block mi (2,92), entropy identical) -
documented with a trace line in the lane report.
crates/ec-av1/src/decode.rsmodified+32 -0
@@ -17255,6 +17255,7 @@ fn decode_leaf8(
1725517255 // 8x8 `mode` and reading its own fresh context off the earlier
1725617256 // units in this same leaf (the same per-TU pattern `decode_block`'s
1725717257 // multi-TU branch runs at bigger blocks).
17258+ let mut first_leaf_tx: Option<TxType> = None;
1725817259 for tu_row in 0..2 {
1725917260 for tu_col in 0..2 {
1726017261 let tu_mi = (leaf_mi.0 + tu_row, leaf_mi.1 + tu_col);
@@ -17327,6 +17328,28 @@ fn decode_leaf8(
1732717328 );
1732817329 }
1732917330 neighbours.record_mi_luma(tu_mi, 4, &tu_grid);
17331+ // The FIRST (top-left, co-located with this group's chroma)
17332+ // TU's coded tx_type is what the group's chroma inherits --
17333+ // the same capture [`decode_block`]'s multi-TU branch makes
17334+ // for `first_leaf_tx` (libaom `av1_get_tx_type`, blockd.h:
17335+ // an inter-classified block's `PLANE_TYPE_UV` reads
17336+ // `tx_type_map`, and intrabc is inter-classified).
17337+ if first_leaf_tx.is_none() {
17338+ first_leaf_tx = Some(fctx.luma_tx_type.with(std::cell::Cell::get));
17339+ }
17340+ }
17341+ }
17342+ // lane-av1intrapred: an intrabc leaf whose var-tx tree split to
17343+ // TX_4X4 never armed [`INTRABC_CHROMA_TX`], so its chroma reads fell
17344+ // back to `default_intra_tx_type(DC_PRED)` = `DCT_DCT` and took the
17345+ // 2D scan, the 2D eob row and the 2D nz contexts where libaom takes
17346+ // the inherited luma type's (R5's first fork: mi (36,66), luma
17347+ // (0,0) coded `H_ADST` off the 16-symbol inter set, chroma U then
17348+ // decoded its `eob` from the wrong CDF row). Same arm the
17349+ // `resolved != 4` branch above runs for its whole-leaf unit.
17350+ if intrabc_dv.is_some() {
17351+ if let Some(t) = first_leaf_tx {
17352+ fctx.intrabc_chroma_tx.with(|c| c.set(Some(t)));
1733017353 }
1733117354 }
1733217355 let ac = alpha.map(|_| cfl_src(px, py, 8));
@@ -17381,6 +17404,15 @@ fn decode_leaf8(
1738117404 None,
1738217405 smooth_neighbor_uv, fctx,
1738317406 )?;
17407+ // The two chroma reads above are the only consulters of this leaf's
17408+ // armed [`INTRABC_CHROMA_TX`]; leaving it set would make the NEXT
17409+ // leaf's chroma inherit this leaf's luma type instead of its own
17410+ // derivation (class armed-slot-leak-into-next-leaf, seen live: the
17411+ // regular-intra leaf after an intrabc TX4 leaf took the intrabc
17412+ // luma's `V_ADST` for its chroma eob row).
17413+ if intrabc_dv.is_some() {
17414+ fctx.intrabc_chroma_tx.with(|c| c.set(None));
17415+ }
1738417416 // `record_split_luma` expects a `record`-style `(r, c)` position in
1738517417 // `SUB`-grid units and rescales it by `SUB / MI`; `leaf_mi` is
1738617418 // already in mi units, so calling it here double-scaled the
lanes/av1intrapred.report.mdmodified+70 -0
@@ -68,3 +68,73 @@ which I could not complete within this run's budget.
6868 * The oracle build `~/.cache/aom-oracle` gained extra env-gated probes during this hunt
6969 (EC_R5CELL, EC_ROWS8, `cdf0=` in the all_zero line, EC_DBGCTX retargeted to mi 36,66).
7070 They are env-gated and outside the repo; retarget/keep as needed.
71+
72+---
73+
74+# lane-av1-intrapred r2 — the reported CDF fork is FIXED; next fork is intrabc chroma prediction
75+
76+Base 3f6748d5, same worktree/branch. The reported "chroma txb_skip CDF-content" fork was
77+neither the Chroma4 defaults (all four q tables match aom `token_cdfs.h` exactly) nor the
78+adaptation — it was the missing `INTRABC_CHROMA_TX` arming in `decode_leaf8`'s TX4 arm.
79+
80+## Root cause (machine-checked against `~/.cache/aom-oracle` R5 traces)
81+
82+* mi (36,66) is an **intrabc** 8x8 leaf whose var-tx tree split luma to 4x TX_4X4.
83+ libaom classifies intrabc as `is_inter_block` (`blockd.h:373`), so:
84+ * each luma TU codes `tx_type` off the **16-symbol inter set**
85+ (`av1_get_ext_tx_set_type(TX_4X4, inter=1)` = `EXT_TX_SET_ALL16`) — TU (0,0) coded
86+ `H_ADST(13)` in R5;
87+ * each chroma TU **inherits** the co-located luma type (`av1_get_tx_type`'s
88+ `is_inter_block` branch reads `tx_type_map`) → class `TX_CLASS_HORIZ` → the class-1
89+ `eob_flag_cdf16[1][1]` row, the HORIZ scan and the HORIZ nz-context offsets.
90+* `decode_leaf8`'s `resolved != 4` arm already armed `INTRABC_CHROMA_TX`; the
91+ `resolved == 4` (TX4) arm did not. Its chroma reads fell back to
92+ `default_intra_tx_type(DC_PRED)` = `DCT_DCT` → 2D eob row → at the U txb of (36,66)
93+ ours decoded `eob=11` where aomdec decoded `eob=13` (same entry rng 44076), and the
94+ tile desynced one read later than the all_zero ladder could see.
95+* The r5-era `tx_type` handling of the luma side was already correct (ours read the same
96+ 16-symbol symbol and got `H_ADST`); only the chroma arming was missing.
97+
98+## Fix (two hunks in `decode_leaf8`, decode.rs)
99+
100+1. TX4 arm: capture the first TU's `tx_type` (`first_leaf_tx`, mirroring `decode_block`'s
101+ multi-TU capture) and arm `INTRABC_CHROMA_TX` with it before the group's chroma reads.
102+2. TX4 arm: disarm the slot after the two chroma reads — without this the slot leaked
103+ into the NEXT leaf (seen live: a regular-intra leaf at mi (54,24) took the previous
104+ intrabc leaf's `V_ADST` for its chroma eob row).
105+
106+## Gates (all machine-captured, same fixtures as the stop report)
107+
108+* R5 (`~/.cache/av1ibcvtx-tmp/R5.obu`): pre-fix first diff byte 82216 / 127862 differing
109+ bytes → post-fix first diff byte **231864** / 3305 differing bytes (luma byte-exact;
110+ aomdec and ffmpeg agree with each other, sha256 `c91229ee…` both).
111+* W2 (re-encoded at `--cq-level=8`, `/tmp/w2.obu` — the report's W2 was not in the cache):
112+ pre-fix first diff byte 352 (report said 353 ✓ reproduces) / 305032 diffs → post-fix
113+ 231848 / 3254. 23x further into the stream, 94x fewer diffs.
114+* R9 (smptebars): still byte-exact vs ffmpeg post-fix (regression clean).
115+* Entropy: ALL 3321 `all_zero` reads now align 1:1 rng-for-rng against the instrumented
116+ aomdec (was 2162/4248).
117+* Pre-fix non-vacuity: scratch worktree at 3f6748d5 rebuild reproduces the byte-352 fork
118+ on W2 and byte-82216 on R5.
119+
120+## Next fork (new class — NOT entropy, NOT the ticket's CDF fork)
121+
122+`R5` first differing byte 231864 = chroma U pixel **(184,4)**; 3305 differing bytes, all
123+chroma (U 1730 / V 1575), origin unit = the chroma 4x4 at cpx (184,4), i.e. the 8x8
124+**intrabc** leaf at luma (368,8), mi **(2,92)**, var-tx TX4 split, luma TU (1,0) coded
125+`H_ADST`, TU (0,0) `DCT_DCT`, chroma inherits `DCT_DCT` on BOTH sides (ours: probe slot
126+`Some(DctDct)`; aom: `EC_TXTYPE mi=2,92 plane=1 tx_type=0`). The full symbol stream is
127+aligned (3321/3321 `all_zero` reads, rng-identical), luma is byte-exact, so this is a
128+**prediction-stage** divergence: the intrabc chroma frame-copy (bilinear at the chroma
129+half-pel phase of the block DV) produces different samples than aomdec for this unit and
130+everything predicted off it. Trace line:
131+
132+```
133+R5: ours U(184,4)=[103,97,107,101] aom=[86,116,55,110]; entropy identical
134+ (read 2428 U / 2429 V of block mi (2,92) match through their coefficients);
135+ suspect the chroma DV rounding/clamp in the leaf8 intrabc_bufs path
136+ (mv_to_q4(cpx, dv_col, false) — odd-DV chroma phase) vs libaom's
137+ av1_predict_intra_block intrabc clamp.
138+```
139+
140+W2 shows the same signature (first diff U(168,4), byte 231848).