forge
Explore
Log in

Don't you dare go Hollow

Lane-sub8x4 r1 handoff -- merge resolution, two root causes, re-measured step-1 premises

Browse files at this commit

885adf5fc12669507a737a650bb2516001075272Ahmet Kaan GümüşParent: d0f01ab
  • docs
    • lane-sub8x4 r1 handoff -- merge resolution, two root causes, re-measured step-1 premises
Show full message
docs(av1): lane-sub8x4 r1 handoff -- merge resolution, two root causes, re-measured step-1 premises
lanes/sub8x4-r1.handoff.mdadded+138 -0
@@ -0,0 +1,138 @@
1+# lane-sub8x4 r1 HANDOFF (tip = `bb79462`, branch lane-sub8x4)
2+
3+Two commits on top of c1df2f2 (= lane-intra16x4 r3):
4+
5+* `1845281` merge of `367d873` (lane-sub8intra r2) + the sub-8x8 sibling-size fix
6+* `bb79462` compound 8x8 leaf early-return fix
7+
8+## 1. STEP 0 -- how the merge was resolved
9+
10+`git merge 367d873` conflicted in ONE file, `crates/ec-av1/src/mvstack.rs`, at 8 hunks
11+(4 functions x 2 hunks: `scan_row`, `scan_col`, `scan_row_compound`, `scan_col_compound`).
12+Every hunk was the SAME libaom clause ported twice, once per lane, with different comment
13+wording and `if/else` vs `usize::from` spelling -- **semantically identical on both sides**:
14+
15+1. the outer-scan step-back, `mvref_common.c:155-158` (`scan_row_mbmi`) and `:203-206`
16+ (`scan_col_mbmi`): `if (abs(row_offset) > 1) { col_offset = 1; if ((mi_col & 0x01) &&
17+ xd->width < width_8x8) --col_offset; }` and its transpose;
18+2. the weight / `processed_rows|cols` guard, `mvref_common.c:172` and `:222`:
19+ `if (xd->width >= width_8x8 && xd->width <= n4_w)` / `if (xd->height >= n8_h_8 &&
20+ xd->height <= n4_h)` -- the `>= mi_size_*[BLOCK_8X8]` half is what both lanes added.
21+
22+Resolution: kept the HEAD (intra16x4 r3) spelling of all 8 hunks, which cites the libaom
23+line numbers; the sub8intra rationale is preserved in this file. Both sides' `bw4 >= 2 &&
24+bw4 <= n4` / `bh4 >= 2 && bh4 <= n4` guard lines were already identical and auto-merged.
25+All four functions were then re-read whole against `mvref_common.c:143-236`: `end_mi`,
26+`use_step_16`, `len` floors (`width_16x16` / `width_8x8`), the weight `inc`, the
27+`processed_*` update and the `i += len` step all match.
28+
29+`decode.rs`, `stream.rs`, `examples/decode_probe.rs` auto-merged clean (both lanes' code
30+kept: the intra 16x4 strip path + OBMC pair merge from intra16x4, `decode_intra_sub8_leaf`
31++ the sub-8x8 chroma guards from sub8intra). Both env bypasses (`EC_SUB8INTRA_DECODE`,
32+`EC_INTRA16X4_DECODE`) are still in place; no refusal lifted this round.
33+
34+`cargo check -p ec-av1`: clean. Named gates run after the merge
35+(`cargo test -p ec-av1 --lib -- obmc mv_stack 1to4 sub8 refusal_inventory gate_coverage`):
36+**32 passed, 2 failed, 5 ignored**. The two failures are the two gates the ledger already
37+records as known-red RECIPE defects on main -- `a_real_aomenc_inter_sequence_with_16x16_
38+level_1to4_partitions_decodes_pixel_exact` ("VERT_4 / split-tx-8x4 arms read 0") and
39+`real_aomenc_1to4_streams_..._rect_vartx_leaves_fire` ("the rectangular var-tx leaf arm
40+never fired"). Both fail on a zero counter, neither on a pixel mismatch.
41+
42+## 2. Two defects found and fixed (both post-merge, both root-caused by ladder)
43+
44+### (a) `decode_inter_sub8_rect2`: leaf 1 never saw leaf 0's block size (`1845281`)
45+
46+libaom's `xd->above_mbmi`/`left_mbmi` are the neighbour block AS DECODED, so leaf 1 of an
47+8x8 HORZ/VERT group sees leaf 0's own bsize. We published `above_side_mi`/`left_side_mi`
48+only in the GROUP tail (after both leaves), so leaf 1 read the block preceding the whole
49+group. `get_tx_size_context` (`pred_common.h:342`) takes `block_size_wide[above_mbmi->bsize]`
50+from there.
51+
52+Witness `~/.cache/sub8intra-tmp/g_8_48_128x128.obu`, mi(25,2) (intra 8x4 leaf 1):
53+ours `tx_depth` **ctx=1** vs aomdec **ctx=2**, same decoded value 1, rng 35938 vs 55960.
54+`EC_TXCTX=1` (new env print in `tx_size_context_txfm_rect`) showed `above_side=4` where the
55+above neighbour is an inter 8x4 leaf of width 8. Class `tx-grid-published-block-side`.
56+
57+Fix: publish the leaf-0 side bands at the top of iteration `i == 1` of the leaf loop
58+(`decode.rs`, `decode_inter_sub8_rect2`). The group tail rewrites the same values, so
59+partition context is unchanged.
60+
61+### (b) `decode_leaf8` COMPOUND arm's early return clobbered its own per-TU luma ctx (`bb79462`)
62+
63+The compound arm `return`s before the fall-through tail, and that tail is where the
64+`split8` plane-0 save/restore around `record_mi` lives. A compound var-tx 8x8 leaf therefore
65+published the whole-block luma grid (all-zero when the transform is split into 4x4 units,
66+since `read_inter_luma8`'s `record_mi_luma` already wrote the per-unit state) into
67+`above[..][0]`/`left[..][0]`.
68+
69+Witness `~/.cache/intra16x4-tmp/g_8.obu` frame 2 mi(14,12), first luma TU: ours
70+`txb_skip` ctx=3 rng=43376 vs reference ctx=6 rng=61310 -- `get_txb_ctx`
71+(`txb_common.h:330`) `skip_contexts[4][0]=3` vs `[4][4]=6`; the block left of it, mi(14,10),
72+is a compound 8x8 whose four TX_4X4 units all read ctx=6 correctly and then had their
73+published levels zeroed. Class `early-return-skips-tail`.
74+
75+Fix: the same save/restore in the compound arm before/after its `record_mi`.
76+
77+## 3. Measured state (probe sweep, both bypasses on)
78+
79+`~/.cache/sub8x4-tmp/check.sh <obu>...` (decode + `cmp` vs `ffmpeg -f rawvideo`),
80+12 sub-8x8-intra streams `~/.cache/sub8intra-tmp/g_{8,10}_{48,55,63}_{128x128,192x128}.obu`:
81+
82+| state | before this round | after (a) | after (b) |
83+|---|---|---|---|
84+| pixel-EXACT (6/6 frames) | 5/12 | 10/12 | 10/12 |
85+| stops at a refusal | 2/12 | 2/12 | **1/12** |
86+
87+Remaining non-EXACT: `g_8_63_128x128.obu` (mismatch) and `g_10_55_192x128.obu` (was
88+"Golomb tail longer than this decoder reads", now decodes all 6 frames and mismatches).
89+
90+`~/.cache/intra16x4-tmp/g_8.obu` is now **entropy-exact end to end**: 2215/2215 `all_zero`
91+units identical in value AND range vs instrumented aomdec, with equal counts -- yet its
92+pixels still differ (frame 1 first at luma (64,88), 1185 px, max delta 20; frames 2..5
93+150-235 px each). That is a **reconstruction-only** residue (prediction / OBMC blend /
94+loop filter), not entropy. This supersedes the r3 handoff's section-2 diagnosis, whose
95+named cause (the 8x8 compound var-tx read) is now fixed.
96+
97+## 4. STEP 1 list, unchanged / re-measured
98+
99+* (a) sub-8x8 INTRA leaf reads `use_filter_intra` (+ `filter_intra_mode`): **premise was
100+ STALE -- already implemented** by sub8intra r2 in `decode_intra_sub8_leaf`
101+ (`decode.rs:23101`). Proven: with the new `EC_TRACE_MODE_STEP` prints added there, ours
102+ reads `use_filter_intra=1 rng=51020` then `filter_intra_mode=3 rng=45380` at mi(25,2),
103+ **bit-identical to aomdec**. `av1_filter_intra_allowed_bsize` is `reconintra.h:68`
104+ (`block_size_wide <= 32 && block_size_high <= 32`), so 8x4/4x8/4x4 are all allowed. No
105+ angle delta below 8x8 is likewise already implemented. What was actually wrong at that
106+ block was the tx_depth CDF ROW -- fix (a) above.
107+* (b) 8x8 COMPOUND inter leaf var-tx `txfm_split`: **premise partly stale** -- we DO read
108+ the symbol (ours `txfm_split val=1 ctx=19 rng=62656`, reference reaches the same 62656).
109+ The real defect was the `txb_skip` ctx, fix (b) above. DONE.
110+* (c) the flagged all-inter sub-8x8 chroma `first_tx_type` rule (`blockd.h:1288`,
111+ tx_type_map rebased to the chroma-reference = LAST sub-block): **NOT MEASURED this
112+ round.** Still open.
113+
114+## 5. Next step (r2)
115+
116+1. Root-cause the two remaining non-EXACT sub-8x8 streams and `g_8.obu`'s
117+ reconstruction-only residue (entropy is exact, so start at prediction: OBMC blend,
118+ sub-8x8 chroma MC, or the deblock grid a sub-8x8 group publishes).
119+2. Then the gates: **no sub-8x8-intra gate test exists yet in `stream.rs`** (only the
120+ `sub8_intra_rect_hits()` accessor at `stream.rs:91` and the 1:4 gate's refusal count).
121+ It must be WRITTEN, continue-and-sweep, over the now 10 EXACT arms of
122+ `~/.cache/sub8intra-tmp/sweep3.sh` (`--max-partition-size=8 --enable-1to4-partitions=0
123+ --min-partition-size=4`, 8/10-bit x cq 48/55/63 x 128x128/192x128). Only then lift
124+ `EC_SUB8INTRA_DECODE` + the two refusals at `refusal_inventory.rs:35-36`.
125+3. intra 16x4: still no EXACT witness; re-run `~/.cache/intra16x4-tmp/sweep_r3.sh` (it is
126+ idempotent and appends) now that both fixes landed -- r3 measured 0 EXACT of 49 rows
127+ BEFORE them.
128+4. Not run this round (turn cap): full `cargo test -p ec-av1 --lib` suite, film probes.
129+
130+## 6. New instrumentation on this branch (env-gated, keep)
131+
132+* `EC_TXCTX=1` -- `tx_size_context_txfm_rect` prints `above_txfm/left_txfm/above_inter/
133+ left_inter/above_side/left_side/above/left`; named defect (a) in one run.
134+* `EC_TRACE_MODE_STEP` now also prints `use_filter_intra` / `filter_intra_mode` from
135+ `decode_intra_sub8_leaf` (it read them silently before, which is what made the r2
136+ handoff conclude they were unread).
137+* `EC_AV1_TRACE` `luma_skip_ctx` line now dumps the whole `left[..][0]` level band;
138+ that dump is what localised defect (b).