forge
Explore
Log in

Don't you dare go Hollow

Tx_size ctx read above_inter/left_inter at mi/4, so an intra neighbour whose tx_depth split to 4x4 read as an inter neighbour contributing its block size -- ctx 1 vs libaom's 2 at one block, adapting the wrong tx_size_cat0 row and desyncing the next tx_depth read

Browse files at this commit

5cb1524ef799db48b6d90ca80c86cec05f4d59b3Ahmet Kaan GümüşParent: 741a48a
  • fix
    • tx_size ctx read above_inter/left_inter at mi/4, so an intra neighbour whose tx_depth split to 4x4 read as an inter neighbour contributing its block size -- ctx 1 vs libaom's 2 at one block, adapting the wrong tx_size_cat0 row and desyncing the next tx_depth read
    • the pinned 10-bit split-leaf stream now decodes pixel-exact
Show full message
fix(av1): tx_size ctx read above_inter/left_inter at mi/4, so an intra neighbour whose tx_depth split to 4x4 read as an inter neighbour contributing its block size -- ctx 1 vs libaom's 2 at one block, adapting the wrong tx_size_cat0 row and desyncing the next tx_depth read; the pinned 10-bit split-leaf stream now decodes pixel-exact

Also traces the `br` rung of the square coefficient path (`EC_COEFF_STEP
tag=br`), without which the cross-decoder range ladder is blind to every
base-range symbol and mis-attributes the first divergence.
crates/ec-av1/src/decode.rsmodified+19 -2
@@ -3680,6 +3680,17 @@ fn read_coeffs(
3680 let mut sent = 0;3680 let mut sent = 0;
3681 loop {3681 loop {
3682 let k = dec.symbol(&mut coding.br[ctx]) as i32;3682 let k = dec.symbol(&mut coding.br[ctx]) as i32;
3683+ if ec_trace_coeff {
3684+ // lane-leaf8tx r3: the `br` rung was missing from THIS
3685+ // path's trace, so the cross-decoder range ladder was
3686+ // blind to every base-range symbol and mis-reported the
3687+ // first divergence (class [[gate-blind-to-feature]]).
3688+ let (rng, _) = dec.debug_state();
3689+ let apos = col * side + row;
3690+ eprintln!(
3691+ "EC_COEFF_STEP tag=br c={scan_idx} pos={apos} ctx={ctx} k={k} rng={rng}"
3692+ );
3693+ }
3683 if trace {3694 if trace {
3684 eprintln!(3695 eprintln!(
3685 "TRACE br scan_idx={scan_idx} pos={pos} row={row} col={col} ctx={ctx} value={k}"3696 "TRACE br scan_idx={scan_idx} pos={pos} row={row} col={col} ctx={ctx} value={k}"
@@ -11929,10 +11940,16 @@ fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize), side: usiz
11929 let has_left = mi_c > n.tile_col0_mi;11940 let has_left = mi_c > n.tile_col0_mi;
11930 let mut above = usize::from(n.above_txfm[mi_c]) >= side;11941 let mut above = usize::from(n.above_txfm[mi_c]) >= side;
11931 let mut left = usize::from(n.left_txfm[mi_r]) >= side;11942 let mut left = usize::from(n.left_txfm[mi_r]) >= side;
11932- if has_above && n.above_inter[mi_c / (SUB / MI)] {11943+ // lane-leaf8tx r3: `above_inter`/`left_inter` are per-MI bands (written
11944+ // by `record_inter` as `[c + cell]`, read everywhere else as `[cmi]`),
11945+ // so dividing the mi index by `SUB / MI` read a column four mi to the
11946+ // left -- an intra neighbour whose tx_depth split to 4x4 then read as an
11947+ // inter neighbour contributing its 8-px BLOCK size, flipping this ctx
11948+ // 1 -> 2 and adapting the wrong `tx_size_cat0` row.
11949+ if has_above && n.above_inter[mi_c] {
11933 above = n.above_side_mi[mi_c] >= side;11950 above = n.above_side_mi[mi_c] >= side;
11934 }11951 }
11935- if has_left && n.left_inter[mi_r / (SUB / MI)] {11952+ if has_left && n.left_inter[mi_r] {
11936 left = n.left_side_mi[mi_r] >= side;11953 left = n.left_side_mi[mi_r] >= side;
11937 }11954 }
11938 match (has_above, has_left) {11955 match (has_above, has_left) {
lanes/leaf8tx-r3.handoff.mdadded+67 -0
@@ -0,0 +1,67 @@
1+# lane-leaf8tx r3 handoff (turn cap)
2+
3+## ROOT CAUSE FOUND AND FIXED (decode.rs `tx_size_context_txfm`)
4+
5+`crates/ec-av1/src/decode.rs:11943/11946` read the per-MI bands
6+`above_inter`/`left_inter` as `[mi_c / (SUB / MI)]` / `[mi_r / (SUB / MI)]`.
7+Those two vectors are written by `record_inter` as `[c + cell]` (per MI) and are
8+read as `[cmi]`/`[rmi]` at every other site (17426, 20183, 20614, 21180), so the
9+division read a column/row FOUR mi away. When that stale cell said "inter", the
10+neighbour contributed its 8-px BLOCK size instead of its 4-px TRANSFORM size and
11+`get_tx_size_context` returned 2 where libaom returns 1. Fix = index by `mi_c` /
12+`mi_r`. Only 2 sites in the file used the division (grep `/ (SUB / MI)]`); both
13+fixed, no sibling instances remain.
14+
15+libaom reference: `pred_common.h` `get_tx_size_context` (above/left from
16+`above_txfm_context[0]`, overridden by `block_size_wide/high` only when the
17+neighbour `is_inter_block`).
18+
19+## The r2 premise was WRONG -- do not chase txb_skip again
20+- The txb_skip CDF row is NOT divergent. libaom stores INVERTED cdfs: aomdec's
21+ `[15,0,32]` IS our `[32753,32768,32]`. Verified read-by-read: a private
22+ instrumented aomdec (`EC_TRACE_TXBCDF`, private build dir
23+ `~/.cache/leaf8tx-aombuild`, source patch reverted afterwards) printed
24+ `txb_skip_cdf[txs_ctx][ctx]` at every all_zero read; all 1220 luma
25+ (txs=0,ctx=6) reads carry cdfs identical to ours, and the per-class read
26+ histograms match exactly (aom `plane0 txs0 ctx6`=1220 = our `side=4 ctx=6`;
27+ aom chroma ctx 7/8/9 = our chroma rows 0/1/2).
28+- The real desync is one element EARLIER, in the MODE ladder: `EC_ISTEP`
29+ `name=tx_depth mi_row=30 mi_col=36` -- same range in (43044), same value (1),
30+ same ctx (2), different range out (ours 47744, aomdec 50432), because two
31+ blocks earlier at mi(20,46) we read ctx=2 where aomdec reads ctx=1 (identical
32+ range there by luck, class [[wrong-alphabet-same-value]]) and adapted the wrong
33+ `tx_size_cat0` row. Exactly 1 ctx mismatch in 449 tx_depth reads of the stream.
34+- Instrument fixed on our side too: the square coefficient path never traced the
35+ `br` rung, so the cross-decoder ladder was blind to base-range symbols and
36+ mis-reported the divergence. `EC_COEFF_STEP tag=br ...` added at decode.rs:3679.
37+
38+## EVIDENCE
39+EVIDENCE: ~/.cache/leaf8tx-tmp/our2.yuv vs ref.yuv | EC_LEAF8TX_SPLIT=1 decode_probe on the pinned 10-bit stream s68.obu (md5 587b4f1d6fbc15249c0ddd0479d55fd7) vs aomdec --rawvideo | `cmp` byte-identical (PIXEL EXACT; r2's 1140/281/285 mismatching samples are gone)
40+EVIDENCE: ~/.cache/leaf8tx-tmp/our_istep4.log | EC_TRACE_MODE_STEP ladder ours vs aomdec | 0 tx_depth ctx mismatches after the fix (was 1 at mi(20,46))
41+
42+## STATE / still owed
43+- The tx_depth-split REFUSAL IS STILL IN PLACE (decode.rs:22610, bypassable with
44+ `EC_LEAF8TX_SPLIT=1`); refusal_inventory.rs:72 unchanged. Lifting it needs the
45+ gate arms + a suite run, which the turn cap cut. The pixel-exact pin above is
46+ the proof that the lift is now unblocked.
47+- `a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact`
48+ (r2's continue-and-sweep conversion) was NOT run to completion: the r3 suite
49+ (`$HOME/.cache/leaf8tx-suite-r3base.log`, PRE-fix code) never printed a
50+ `test result` line before the cap; it shows 2 failures that predate this round's
51+ fix: `decode::tests::an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking`
52+ and `refusal_inventory::tests::the_decode_path_refuses_exactly_the_listed_cases`
53+ (both look like r2 merge-resolution fallout of the OBMC refusal string, not
54+ entropy). Re-run the whole suite on the fixed tree FIRST.
55+- The angle-delta gate and cdef/sub16 gate were not re-run this round.
56+
57+## Oracle source incident (fixed, read this before touching the oracle)
58+I ran `git checkout av1/decoder/decodetxb.c` in `~/.cache/aom-oracle/src` to drop
59+my own one-line probe and it wiped 50 lines of OTHER lanes' uncommitted
60+instrumentation (class [[checkout-ate-uncommitted-work]] again). Restored:
61+`scripts/instrument-aom-oracle.sh` re-applied rungs 3+11, and the remaining
62+hand-added prints (base/br in both `read_coeffs_reverse*`, all_zero, tx_type
63+outside the AOM_PLANE_Y branch, extended base_eob) were reconstructed from the
64+shared aomdec binary's format strings. Proof of restoration: a fresh trace from a
65+rebuild of the restored source is `cmp`-identical to the pre-incident
66+`~/.cache/leaf8tx-tmp/aom_coeff.log`. The SHARED `~/.cache/aom-oracle/build`
67+was never rebuilt.