forge
Explore
Log in

Don't you dare go Hollow

Rect intra leaves inside an inter frame read the deblock-grid tx-depth context (sibling sweep)

Browse files at this commit

a0c409b88f80fb677020f3e22d84a049b5e89e54Ahmet Kaan GümüşParent: 27250ff
  • fix
    • rect intra leaves inside an inter frame read the deblock-grid tx-depth context (sibling sweep)
Show full message
fix(av1): rect intra leaves inside an inter frame read the deblock-grid tx-depth context (sibling sweep)

Class sweep of the measured `decode_block_rect4` defect: `decode_leaf_rect`
and `decode_leaf_rect8` still built their tx-depth CDF row from
[`tx_size_context_rect`] (the key frame's deblock-grid approximation) where
libaom's `get_tx_size_context` reads the `TXFM_CONTEXT` bands for every block
of an inter frame. No-op unless `INTRA_IN_INTER_MODE` is set, i.e. key frames
are byte-identical.

Unmeasured on their own (the measured instance is the 32x8 strip at
mi(48,176) of the 10-bit 1920x792 128-superblock stream) -- kept in a separate
commit so it can be reverted without losing that fix. lanes/t900-r2.handoff.md
carries the ladder state, the next divergence (a chroma txb_skip context row)
and the gate that was red mid-suite when the round ended.
crates/ec-av1/src/decode.rsmodified+14 -2
@@ -8344,7 +8344,13 @@ fn decode_leaf_rect(
83448344 // a constant `false`.
83458345 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c);
83468346 let depth = if tx_select {
8347- let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh);
8347+ // lane-t900 r2 (sibling sweep): the in-inter `TXFM_CONTEXT` band read
8348+ // every other rect reader now does -- a no-op on a key frame.
8349+ let ctx = if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() {
8350+ tx_size_context_txfm_rect(neighbours, leaf_mi, bw, bh)
8351+ } else {
8352+ tx_size_context_rect(neighbours, leaf_mi, bw, bh)
8353+ };
83488354 // lane-rectsplitx r1: `bsize_to_tx_size_cat` (libaom `blockd.h`,
83498355 // `bsize_to_tx_size_depth_table`) is 2 for BLOCK_16X8/BLOCK_8X16, so
83508356 // the category is 1 -- NOT the 2 the 32x16 strips read. Same symbol
@@ -13084,7 +13090,13 @@ fn decode_leaf_rect8(
1308413090 // and desynced the tile at the very first rect leaf (class
1308513091 // `symbol-consumption-gap`).
1308613092 let depth = if tx_select {
13087- let ctx = tx_size_context_rect(neighbours, lmi, bw, bh);
13093+ // lane-t900 r2 (sibling sweep): the in-inter `TXFM_CONTEXT` band
13094+ // read every other rect reader now does -- a no-op on a key frame.
13095+ let ctx = if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() {
13096+ tx_size_context_txfm_rect(neighbours, lmi, bw, bh)
13097+ } else {
13098+ tx_size_context_rect(neighbours, lmi, bw, bh)
13099+ };
1308813100 dec.symbol(&mut cdfs.tx_size_cat0[ctx])
1308913101 } else {
1309013102 0
lanes/t900-r2.handoff.mdadded+136 -0
@@ -0,0 +1,136 @@
1+# lane-t900 r2 handoff -- in-inter rect tx-depth context; next wall is the chroma txb_skip ctx
2+
3+Branch `lane-t900`, worktree `edith_codecs-t900`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-t900` (a second `-t900-b` dir was
5+used for `cargo check` while the suite unit held the first).
6+
7+## STEP 1 -- merge of main `5d81a67` (commit `85ce8ff`)
8+
9+One conflict, `crates/ec-av1/src/decode.rs`, in the 2:1 intra-in-inter
10+`tx_depth` rung: HEAD's cached `step_trace` bool vs main's inline
11+`std::env::var_os("EC_TRACE_MODE_STEP")`. Resolved to HEAD's `step_trace`
12+(same condition, one env read per block instead of per symbol).
13+
14+Publication per exit: NOT one write per exit, but every write is IDENTICAL.
15+`publish_txfm_bands_if_in_inter` sits right after the depth symbol in
16+`decode_block_rect4` / `decode_block_rect64` and covers every later exit;
17+frame36's `txfm_partition_update_rect` tails sit before the split arms'
18+`return Ok(...)`. Both write `depth_to_tx_wh(bw, bh, depth)` over the same
19+(bw,bh) footprint, so the split arms write the same bytes twice -- idempotent,
20+no double-update hazard. Left as-is deliberately (removing either one loses a
21+different exit). `publish_txfm_bands_if_in_inter` itself also duplicates
22+`txfm_partition_update_rect`'s two loops with the same values; harmless.
23+
24+`cargo check -p ec-av1`: clean. Re-ladder of `t900_2.obu` after the merge:
25+`mi(0,320) tx_depth val=1 ctx=0 cat=1 rng=54736` still == aomdec, r1's fix
26+survived the merge.
27+
28+## STEP 2 -- ROOT CAUSE FOUND AND FIXED (commit after this file)
29+
30+The in-inter `tx_depth` CDF row of a 1:4 strip came from the KEY FRAME's
31+deblock-grid approximation (`tx_size_context_rect`) instead of the real
32+`TXFM_CONTEXT` bands (`tx_size_context_txfm_rect`). The 2:1 arm
33+(decode.rs:7660) and the 16x4 strip (`decode_rect4_16_strip`) already switched
34+on `INTRA_IN_INTER_MODE`; `decode_block_rect4`, `decode_block_rect64`,
35+`decode_block_rect` and (sweep) `decode_leaf_rect`, `decode_leaf_rect8` did
36+not.
37+
38+Measured on the 2-frame cut (10-bit 1920x792, 128-superblock), decode-order
39+frame 1: the 32x8 `PARTITION_HORZ_4` strip at mi(48,176) read `tx_size_cat2`
40+row 1 where libaom reads row 2 (`EC_TXCTX ... above_px=16 left_px=32 ctx=1`
41+vs aomdec `ctx=2`). Ladder before: sustained divergence from mi(48,176).
42+Ladder after: exact through mi(40,221) (`tx_depth val=0 ctx=2 cat=1
43+rng=40539` == aomdec), ~230 more oracle symbols.
44+
45+New rungs added so a ladder can see the symbol at all (this is what made r1's
46+bisection stop one block short): `EC_ISTEP ... name=tx_depth val= ctx= cat=`
47+in `decode_block_rect4` (cat 2), `decode_block_rect` (cat 2),
48+`decode_block_rect64` (cat 3), `decode_rect4_16_strip` (cat 1).
49+
50+## NEXT DIVERGENCE (exact, do not re-bisect)
51+
52+Block mi(40,222): strip 2 of a `PARTITION_VERT_4` of the 16x16 at mi(40,220)
53+(four 4x16 strips, cols 220..223; strip 0 inter, 1..3 intra-in-inter).
54+Everything through strip 1's luma TU matches. The first differing symbol is
55+strip 1's CHROMA `all_zero` (txb_skip):
56+
57+| | ours | aomdec |
58+|---|---|---|
59+| plane 1 `all_zero` (entry rng=37582) | ctx base **1** -> rng **37384** | ctx **9** (= base 2 + chroma offset 7) -> rng **51992** |
60+| plane 2 `all_zero` | ctx base 1 -> rng 36800 | ctx 9 -> rng 33312 |
61+
62+Same VALUES (1 then 0), different CDF ROW. Our chroma skip ctx is built at
63+`decode_rect4_16_strip`'s chroma call (`let skip_ctx = usize::from(around[plane].0)
64++ usize::from(around[plane].1)`, decode.rs ~9480, feeding `read_coeffs_rect`
65+with `TxbSet::ChromaRect8x4`): the base is 1 where libaom's `get_txb_ctx`
66+gathers 2. The suspect is the chroma entropy-context map an INTER neighbour
67+writes (the strip's left/above chroma neighbour here is an inter block), i.e.
68+class `new-map-ignores-tile-edge` / `context-read-from-one-cell` on the chroma
69+side -- verify with `EC_DCDUMP`/`around_mi_rect` on the pair mi, and check
70+whether the inter chroma TU path records that map at all. Reproduce:
71+
72+ systemd-run --user --scope -q -p MemoryMax=6G env EC_INTRA128_IN_INTER=1 \
73+ EC_TRACE_COEFF=1 <target>/release/examples/decode_probe \
74+ ~/.cache/inter128intra-tmp/t900_2.obu 2>&1 | grep -n 'entry=37582'
75+
76+ (oracle: `EC_TRACE_COEFF=1 ~/.cache/aom-oracle/build/aomdec --codec=av1 \
77+ -o /dev/null ~/.cache/inter128intra-tmp/t900_2.obu`, line ~475902.)
78+
79+## Film state (decode-order frame compare vs instrumented aomdec, EC_AV1_FINAL_DUMP)
80+
81+| cut | aomdec frames | ours | f0 | first differing frame |
82+|---|---|---|---|---|
83+| 2-frame cut of the 900 s cut | 2 | OK 1 shown | EXACT | 1 (1924240 B, was 2134171 B before the fix) |
84+| 2 s at 900 s | 267 | REFUSED Golomb tail after 2 | EXACT | 1 |
85+| 2 s at 5400 s | 275 | REFUSED Golomb tail after 10 | EXACT | 1 |
86+| 2 s at 6300 s | 125 | (run cut short) | EXACT | 1 |
87+
88+So the intra128 witness route is still blocked: no cut is exact through a
89+frame that fires `intra128_in_inter`, therefore NO fixture was pinned, NO
90+refusal was lifted, and `refusal_inventory.rs` / `gate_coverage.rs` are
91+untouched. `EC_INTRA128_IN_INTER` remains opt-in.
92+
93+## Suite
94+
95+Unit `t900-suite-r2-1788370358` (MemoryMax=10G), log `$HOME/.cache/t900-suite.log`,
96+was still running at the turn cap and is INCOMPLETE. What it had produced:
97+`a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus_decode_pixel_exact`
98+**FAILED** (no panic text captured yet -- the log was mid-run). That gate is
99+the prime suspect for the `decode_block_rect64` / `decode_leaf_rect*` arms of
100+the ctx switch: re-run it FIRST
101+
102+ CARGO_TARGET_DIR=$HOME/.cache/cargo-target-t900 EC_NOMEMGUARD=1 \
103+ EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib \
104+ a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus -- --nocapture
105+
106+and, if it is this lane's change, bisect the switch per reader (rect4 alone is
107+the measured one; rect64 / rect / leaf_rect / leaf_rect8 were a class sweep
108+with no measurement of their own -- reverting those four is the cheap
109+fallback). Note the sweep commit is SEPARATE from the measured rect4/rect64
110+commit for exactly that reason.
111+
112+## Next step list
113+
114+1. Re-run the failing 16x4/rect64 gate; if red from this lane, bisect the five
115+ ctx switches (rect4 is measured; the other four are unmeasured sweep).
116+2. Full suite as a systemd unit (COMMON recipe) and compare totals with
117+ 424 passed / 1 pre-existing failure / 37 ignored.
118+3. Fix the chroma txb_skip ctx above; re-run the decode-order compare
119+ (`~/.cache/t900-tmp/cmp.sh <name> <obu>`, aomdec+ours EC_AV1_FINAL_DUMP,
120+ per-frame byte diff) on `t900_2.obu` until frame 1 is exact.
121+4. Only then: pin the smallest exact firing prefix (census4/trunc.py) as
122+ `crates/ec-av1/fixtures/reelc_intra128_witness.obu` (`git add -f`, hash
123+ twice), gate every plane of every decode-order frame with a hard
124+ `intra128_in_inter` counter assert, lift the refusal, drop
125+ `EC_INTRA128_IN_INTER`, update `refusal_inventory.rs` + `gate_coverage.rs`.
126+5. Re-probe `~/.cache/reelc-0-10s.obu` (not run this round).
127+
128+## Artifacts
129+
130+- `~/.cache/t900-tmp/cmp.sh` -- decode-order frame compare (aomdec vs ours).
131+- `~/.cache/t900-tmp/{aom_full.trace,ours_full.trace}` -- mode/part ladders,
132+ same round; `{aom_coeff.trace,ours_coeff.trace}` -- `EC_TRACE_COEFF` ladders.
133+- `~/.cache/t900-tmp/cuts.log` -- the film table above.
134+- Ladder matcher: greedy in-order match on `(mi_row, mi_col, name, rng)` of
135+ `EC_ISTEP` lines with a 200-entry window -- `difflib` on the deduped rng
136+ sequence is USELESS here (our extra rungs make every hunk an insert).