forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1422llinter2: a lossless chroma plane block is PER-AXIS -- 4:2:2's 4x8 block was coded as one TX_4X8 unit at ctx_offset 7, and the wrong CDF row desynchronised the whole frame

Browse files at this commit

75564f7efc3b2669d87e04501afc21dbc6f4d3eaAhmet Kaan GümüşParent: b510942fe8c25f
Three of the four remaining lossless 4:2:2 cells go byte-exact: W_intrabc 1/17 -> 17/17 decode frames,
X_intrabc_tiled 1/17 -> 17/17, Y_intrabc_10b 1/4 -> 17/17 (all three planes, all frames, cmp-verified
against the oracle), plus the probe cell ll422_noibc 2/16 -> 16/16.

NAMED EXPRESSION: av1_get_tx_size returns TX_4X4 for EVERY plane of a lossless block
(av1/decoder/decodeframe.c:1196-1197 returns TX_4X4 before TX_MODE_SELECT is ever read), so the chroma
plane block is a raster of TX_4X4 units whenever it is bigger than one -- and it is PER-AXIS:
av1_ss_size_lookup[BLOCK_8X8][ss_x][ss_y] (av1/common/blockd.h:1186) gives BLOCK_8X8 at 4:4:4 (2x2
units), BLOCK_4X8 at 4:2:2 (1x2) and BLOCK_4X4 at 4:2:0 (one unit). Our three 8x8-leaf gates read
`chroma_w == 8 && lossless(fctx)`, and chroma_w == 8 is SIDE >> ss_x == 8, i.e. ss_x == 0 -- 4:4:4
ONLY. 4:2:2 (chroma_w 4, chroma_h 8) fell through to a ONE-unit TX_4X8 read at ctx_offset 7, where
libaom's get_txb_ctx chroma branch (av1/common/txb_common.h:429-435, plane_bsize > txsize_to_bsize[tx]
=> offset 10) reads TWO units. The first unit's txb_skip (av1/decoder/decodetxb.c:158) then came out of
txb_skip_cdf[..][1] where libaom uses [..][11]; at an identical coder state those rows answer 1 and 0,
1 = all_zero, so we skipped a plane block libaom descends into -- read counts diverge from that symbol
and the coder is desynchronised for the REST of the frame. That is why the miss was ~90% of the first
inter frame while frame 0 (Key + intra + intrabc, never reaching decode_inter_block8's chroma arm) was
byte-exact, and why all of it sat pre-filter with every post-recon filter inert.

EVIDENCE (paired ladders, not inference): the oracle's EC_DBGCTX on the forked unit reads
`mi=2,0 plane=1 tx=0 above0=7 left0=0 base=1 off=10 ctx=11` where ours read
`EC_COEFF_STEP tag=all_zero plane=1 ctx=1 entry=33288` -- ctx 11 vs 1 from the same entry range; 55113
reads of EC_SYMR lockstep before the fork at decodetxb.c:158.

Fix: leaf8_inter_chroma_lossless takes the per-axis (blk_w, blk_h) and the composed grid's stride
instead of hardcoding (8,8)/8; all three gates became `lossless(fctx) && (chroma_w > 4 || chroma_h > 4)
&& !mono(fctx)` (the same predicate read_inter_chroma_lossless already uses for the offset-10 rows); the
intra-in-inter arm's (chroma_w, chroma_w) became (chroma_w, chroma_h) and Grid::Zero(64) became
chroma_w * chroma_h. At 4:4:4 every argument passes through verbatim and 4:2:0's 4x4 plane block keeps
its single-unit read, so those formats are unchanged by construction.

CLASS SWEEP: every lossless chroma gate in decode.rs enumerated -- the intra-frame 8x8 leaf, the >=8x16
inter arms and the sub-8 rect inter arm were already shape-generic; these three 8x8-leaf sites were the
only ones keyed to a chroma format's shape, all three are fixed, and no fourth exists.
Non-vacuity of the new arm via gate counters (bypass on, W_intrabc): chroma422_rect 88 -> 0 (the
one-unit 4:2:2 read is gone), chroma422_sub8 169 -> 391 (222 unit reads moved into the 4x4 walk),
chroma422_square unchanged at 3312.

Y_intrabc_10b also settles the localising lane's flagged discrepancy: the pre-fix build emitted only 4 of
the oracle's 17 decode frames and stopped SILENTLY -- the desync, not a missing refusal string.
NOT GATEABLE from a committed test: 4:2:2 is refused at the sequence header, so this is
measurement-plus-isolation evidence, and the report says so plainly.
crates/ec-av1/src/decode.rsmodified+71 -41
@@ -38053,14 +38053,30 @@ fn read_inter_chroma_lossless(
38053 Ok(())38053 Ok(())
38054 }38054 }
38055 38055
38056-/// The 8x8 inter leaf's lossless 4:4:4 chroma arm (lane-av1-llinter), shared38056+/// The 8x8 inter leaf's lossless chroma arm (lane-av1-llinter), shared by the
38057-/// by the single-ref and compound paths: the plane block is a 2x2 raster of38057+/// single-ref and compound paths, for every plane block BIGGER than 4x4:
38058-/// TX_4X4 units (`av1_get_tx_size`: lossless returns TX_4X4 for EVERY plane,38058+/// libaom's `read_tx_size` (`av1/decoder/decodeframe.c:1197`,
38059-/// not just luma), read by the same per-unit walk the bigger inter blocks38059+/// `if (xd->lossless[xd->mi[0]->segment_id]) return TX_4X4;`) returns TX_4X4
38060-/// run. Returns the two block grids composed at stride 8 (`Grid::Zero` when38060+/// for EVERY plane of a lossless block, not just luma, so the plane block is
38061-/// every unit hung off the frame edge) and leaves each unit's own coefficient38061+/// a raster of TX_4X4 units read by the same per-unit walk the bigger inter
38062-/// context stamped in the neighbour bands -- the caller's tail must not let38062+/// blocks run.
38063-/// its whole-block `record_mi` overwrite them.38063+///
38064+/// **The plane block is PER-AXIS**, `av1_ss_size_lookup[BLOCK_8X8][ss_x][ss_y]`
38065+/// (`av1/common/blockd.h:1186`): BLOCK_8X8 at 4:4:4 (2x2 units), BLOCK_4X8 at
38066+/// 4:2:2 (1x2 units), BLOCK_4X4 at 4:2:0 (one unit, `get_txb_ctx`'s
38067+/// `plane_bsize == txsize_to_bsize[tx_size]` branch, ctx_offset 7 -- the one
38068+/// shape that keeps the single-unit read and is NOT routed here). Gating this
38069+/// arm on the 4:4:4 shape instead left 4:2:2 coding its 4x8 plane block as ONE
38070+/// TX_4X8 unit at ctx_offset 7, where libaom reads TWO TX_4X4 units at
38071+/// ctx_offset 10 (`av1/common/txb_common.h:430-433`): the first unit's
38072+/// `txb_skip` symbol then came out of the wrong CDF row, which desynchronised
38073+/// the coder for the rest of the frame.
38074+///
38075+/// `(blk_w, blk_h)` is that per-axis plane block and `stride` the composed
38076+/// grid's row pitch (the leaf's `chroma_w`); the grids are `stride * blk_h`
38077+/// (`Grid::Zero` when every unit hung off the frame edge) and each unit's own
38078+/// coefficient context is left stamped in the neighbour bands -- the caller's
38079+/// tail must not let its whole-block `record_mi` overwrite them.
38064 #[allow(clippy::too_many_arguments)]38080 #[allow(clippy::too_many_arguments)]
38065 fn leaf8_inter_chroma_lossless(38081 fn leaf8_inter_chroma_lossless(
38066 dec: &mut SymbolDecoder,38082 dec: &mut SymbolDecoder,
@@ -38072,6 +38088,10 @@ fn leaf8_inter_chroma_lossless(
38072 sv: Pred<'_>,38088 sv: Pred<'_>,
38073 at_mi: (usize, usize),38089 at_mi: (usize, usize),
38074 (cpx, cpy): (usize, usize),38090 (cpx, cpy): (usize, usize),
38091+ // The leaf's CHROMA PLANE BLOCK, per axis, and the composed grid's row
38092+ // pitch -- `(8, 8)`/`8` at 4:4:4, `(4, 8)`/`4` at 4:2:2.
38093+ (blk_w, blk_h): (usize, usize),
38094+ stride: usize,
38075 base_q_idx: u8,38095 base_q_idx: u8,
38076 fctx: &crate::decode::FrameCtx,38096 fctx: &crate::decode::FrameCtx,
38077 ) -> Result<(Grid, Grid)> {38097 ) -> Result<(Grid, Grid)> {
@@ -38087,23 +38107,24 @@ fn leaf8_inter_chroma_lossless(
38087 at_mi,38107 at_mi,
38088 (cpx, cpy),38108 (cpx, cpy),
38089 (0, 0),38109 (0, 0),
38090- (8, 8),38110+ (blk_w, blk_h),
38091- (8, 8),38111+ (blk_w, blk_h),
38092- 8,38112+ stride,
38093 0,38113 0,
38094 base_q_idx,38114 base_q_idx,
38095 &mut uo,38115 &mut uo,
38096 &mut vo,38116 &mut vo,
38097 fctx,38117 fctx,
38098 )?;38118 )?;
38119+ let n = stride * blk_h;
38099 Ok((38120 Ok((
38100 if uo.is_empty() {38121 if uo.is_empty() {
38101- Grid::Zero(64)38122+ Grid::Zero(n)
38102 } else {38123 } else {
38103 Grid::Own(uo)38124 Grid::Own(uo)
38104 },38125 },
38105 if vo.is_empty() {38126 if vo.is_empty() {
38106- Grid::Zero(64)38127+ Grid::Zero(n)
38107 } else {38128 } else {
38108 Grid::Own(vo)38129 Grid::Own(vo)
38109 },38130 },
@@ -49982,12 +50003,15 @@ fn decode_inter_block8(
49982 fctx,50003 fctx,
49983 )?;50004 )?;
49984 luma_grid = grid8;50005 luma_grid = grid8;
49985- // 4:4:4 lossless 8x8 inter leaf: the chroma plane block is50006+ // Lossless 8x8 inter leaf: `av1_get_tx_size` returns
49986- // the 8x8 leaf itself, read as one unit by the 444 walk50007+ // TX_4X4 for EVERY plane of a lossless block
49987- // (`chroma_w == 8` is `SIDE >> ss_x == 8`, i.e. ss_x 0).50008+ // (`decodeframe.c:1197`), so the chroma plane block is a
49988- // The 4:2:2 rect unit and the 4:2:0/4:4:4 square read are50009+ // raster of TX_4X4 units whenever it is BIGGER than one --
49989- // the `else` below, dispatched on `chroma_422`.50010+ // 4:4:4's 8x8 (2x2) and 4:2:2's 4x8 (1x2). Only 4:2:0's
49990- if chroma_w == 8 && lossless(fctx) && !mono(fctx) {50011+ // 4x4 keeps the single-unit read, where
50012+ // `plane_bsize == txsize_to_bsize[tx_size]` puts
50013+ // `get_txb_ctx`'s ctx_offset at 7.
50014+ if lossless(fctx) && (chroma_w > 4 || chroma_h > 4) && !mono(fctx) {
49991 let (ug, vg) = leaf8_inter_chroma_lossless(50015 let (ug, vg) = leaf8_inter_chroma_lossless(
49992 dec,50016 dec,
49993 cdfs,50017 cdfs,
@@ -49998,6 +50022,8 @@ fn decode_inter_block8(
49998 sv,50022 sv,
49999 leaf_mi,50023 leaf_mi,
50000 (cpx, cpy),50024 (cpx, cpy),
50025+ (chroma_w, chroma_h),
50026+ chroma_w,
50001 base_q_idx,50027 base_q_idx,
50002 fctx,50028 fctx,
50003 )?;50029 )?;
@@ -50941,11 +50967,10 @@ fn decode_inter_block8(
50941 fctx,50967 fctx,
50942 )?;50968 )?;
50943 luma_grid = grid8;50969 luma_grid = grid8;
50944- // 4:4:4 lossless 8x8 inter leaf (compound twin of the single-ref50970+ // Lossless 8x8 inter leaf, compound twin of the single-ref arm
50945- // arm above): the chroma plane block is the 8x8 leaf itself, read50971+ // above -- same per-axis plane block (4:4:4 8x8, 4:2:2 4x8) and
50946- // as one unit by the 444 walk. The 4:2:2 rect unit and the50972+ // the same "bigger than one TX_4X4" gate.
50947- // 4:2:0/4:4:4 square read are the `else` below.50973+ if lossless(fctx) && (chroma_w > 4 || chroma_h > 4) && !mono(fctx) {
50948- if chroma_w == 8 && lossless(fctx) && !mono(fctx) {
50949 let (ug, vg) = leaf8_inter_chroma_lossless(50974 let (ug, vg) = leaf8_inter_chroma_lossless(
50950 dec,50975 dec,
50951 cdfs,50976 cdfs,
@@ -50956,6 +50981,8 @@ fn decode_inter_block8(
50956 sv,50981 sv,
50957 leaf_mi,50982 leaf_mi,
50958 (cpx, cpy),50983 (cpx, cpy),
50984+ (chroma_w, chroma_h),
50985+ chroma_w,
50959 base_q_idx,50986 base_q_idx,
50960 fctx,50987 fctx,
50961 )?;50988 )?;
@@ -51563,19 +51590,22 @@ fn decode_inter_block8(
51563 } else {51590 } else {
51564 (around[1], around[2])51591 (around[1], around[2])
51565 };51592 };
51566- if chroma_w == 8 && lossless(fctx) && !mono(fctx) {51593+ // lane-av1-llintra8: lossless codes TX_4X4 on EVERY plane
51567- // lane-av1-llintra8: lossless codes TX_4X4 on EVERY plane51594+ // (`av1_get_tx_size`, blockd.h:1383), so this intra leaf's chroma
51568- // (`av1_get_tx_size`, blockd.h:1383), so this intra leaf's 8x851595+ // plane block is a raster of TX_4X4 units per plane, plane-major
51569- // chroma plane block is a 2x2 raster of TX_4X4 units per51596+ // -- the same per-unit walk the >=16x16 intra-in-inter block
51570- // plane, plane-major -- the same per-unit walk the >=16x1651597+ // runs, not one TX_8X8 unit (whose WHT hits `TxParams::run`'s
51571- // intra-in-inter block runs, not one TX_8X8 unit (whose WHT51598+ // `(8, 8) != (4, 4)` lossless assert). The plane block is
51572- // hits `TxParams::run`'s `(8, 8) != (4, 4)` lossless assert).51599+ // PER-AXIS, `av1_ss_size_lookup[BLOCK_8X8][ss_x][ss_y]`: 8x8 at
51573- // The walk stamps each unit's own coefficient context51600+ // 4:4:4 (2x2 units) and 4x8 at 4:2:2 (1x2), so both walk here and
51574- // (`record_mi_chroma` inside it), so the tail's whole-block51601+ // only 4:2:0's 4x4 keeps the single-unit read in the `else`
51575- // `record_mi` gets its chroma half saved/restored around --51602+ // below (`plane_bsize == txsize_to_bsize[tx_size]`, ctx_offset 7).
51576- // the same rule the INTER arms'51603+ // The walk stamps each unit's own coefficient context
51577- // `leaf8_inter_chroma_lossless` obeys. 4:2:0 keeps its single51604+ // (`record_mi_chroma` inside it), so the tail's whole-block
51578- // TX_4X4 unit in the `else` below.51605+ // `record_mi` gets its chroma half saved/restored around --
51606+ // the same rule the INTER arms'
51607+ // `leaf8_inter_chroma_lossless` obeys.
51608+ if lossless(fctx) && (chroma_w > 4 || chroma_h > 4) && !mono(fctx) {
51579 let (mut uo, mut vo) = (Vec::new(), Vec::new());51609 let (mut uo, mut vo) = (Vec::new(), Vec::new());
51580 read_intra_chroma_lossless(51610 read_intra_chroma_lossless(
51581 dec,51611 dec,
@@ -51587,9 +51617,9 @@ fn decode_inter_block8(
51587 (px, py),51617 (px, py),
51588 (cpx, cpy),51618 (cpx, cpy),
51589 SIDE,51619 SIDE,
51590- (chroma_w, chroma_w),51620+ (chroma_w, chroma_h),
51591 (0, 0),51621 (0, 0),
51592- (chroma_w, chroma_w),51622+ (chroma_w, chroma_h),
51593 chroma_w,51623 chroma_w,
51594 reach,51624 reach,
51595 (y.width, y.height),51625 (y.width, y.height),
@@ -51604,12 +51634,12 @@ fn decode_inter_block8(
51604 fctx,51634 fctx,
51605 )?;51635 )?;
51606 u_grid = if uo.is_empty() {51636 u_grid = if uo.is_empty() {
51607- Grid::Zero(64)51637+ Grid::Zero(chroma_w * chroma_h)
51608 } else {51638 } else {
51609 Grid::Own(uo)51639 Grid::Own(uo)
51610 };51640 };
51611 v_grid = if vo.is_empty() {51641 v_grid = if vo.is_empty() {
51612- Grid::Zero(64)51642+ Grid::Zero(chroma_w * chroma_h)
51613 } else {51643 } else {
51614 Grid::Own(vo)51644 Grid::Own(vo)
51615 };51645 };
lanes/av1422llinter2.report.mdadded+449 -0
@@ -0,0 +1,449 @@
1+# lane-av1422llinter2 — the lossless 4:2:2 inter divergence is FIXED
2+
3+Tip: `main` = `cc211d13` (Merge lane-av1422llinter). Worktree
4+`/home/user/.cache/wt/av1422llinter2`, branch `lane-av1422llinter2`, commit
5+`475c45ac`. One source file changed: `crates/ec-av1/src/decode.rs`. The 4:2:2
6+sequence-header bypass was applied, measured with, and reverted;
7+`git status` is clean on the lane tree and on the primary checkout.
8+
9+**Result: `W_intrabc`, `X_intrabc_tiled` and `Y_intrabc_10b` go from
10+1-of-17 / 1-of-17 / 1-of-4 exact decode frames to 17-of-17, 17-of-17 and
11+17-of-17, on all three planes.** `ll422_noibc` goes 2/16 → 16/16. The
12+4:2:0 and 4:4:4 lossless controls are unchanged. §7 states plainly that none
13+of this is gate-able.
14+
15+---
16+
17+## 1. Geometry first (the brief's numbers were stale, again)
18+
19+`W_intrabc.obu` (130 320 B) and `X_intrabc_tiled.obu` (131 696 B) are
20+**320x240 4:2:2, 8-bit**: 76 800 Y + 38 400 U + 38 400 V = **153 600 B per
21+frame**, and the instrumented oracle emits 17 DECODE-order frames of exactly
22+that size. `Y_intrabc_10b.obu` (202 281 B) is **300x256 4:2:2, 10-bit stored
23+16-bit LE**: 76 800 + 38 400 + 38 400 samples = **307 200 B per frame**, 17
24+decode frames. All three are already committed as fixtures
25+(`crates/ec-av1/fixtures/{W_intrabc,X_intrabc_tiled,Y_intrabc_10b}.obu`,
26+sha256 `0aad0d6f…`, `e7c0c60a…`, `ce84d7cb…`, pinned by
27+`scripts/fixture-library.tsv:204-206`).
28+
29+Decode order confirmed by re-measurement: 17 coded frames, 16 shown, 6 of
30+those `show_existing`. `EC_AV1_FINAL_DUMP` is DECODE order on both sides and
31+`EC_ECDUMP_IN`'s bit position resets to 22 at the 9600th TU — the start of
32+decode frame 1. **Decode frame 0 is byte-exact on all three cells on all
33+three planes; decode frame 1 is the first inter frame and the first bad one.**
34+
35+## 2. The named expression
36+
37+**libaom, `av1/decoder/decodeframe.c:1196-1197`**, in `read_tx_size`:
38+
39+```c
40+static TX_SIZE read_tx_size(const MACROBLOCKD *const xd, TX_MODE tx_mode,
41+ int is_inter, int allow_select_inter, aom_reader *r) {
42+ const BLOCK_SIZE bsize = xd->mi[0]->bsize;
43+ if (xd->lossless[xd->mi[0]->segment_id]) return TX_4X4;
44+```
45+
46+TX_4X4 for **every plane** of a lossless block — luma *and* chroma. That
47+`mbmi->tx_size` is then walked per plane in
48+`av1/decoder/decodeframe.c:299-302` (`decode_reconstruct_tx`) and
49+`ec_read_coeffs_txb_impl` (`decodetxb.c:449-469`):
50+
51+```c
52+ const BLOCK_SIZE plane_bsize =
53+ get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
54+ TXB_CTX txb_ctx;
55+ get_txb_ctx(plane_bsize, tx_size, plane, pd->above_entropy_context + col,
56+ pd->left_entropy_context + row, &txb_ctx);
57+```
58+
59+and the symbol the fork turned on is **`av1/decoder/decodetxb.c:158`**:
60+
61+```c
62+ const int all_zero = aom_read_symbol(
63+ r, ec_ctx->txb_skip_cdf[txs_ctx][txb_ctx->txb_skip_ctx], 2, ACCT_STR);
64+```
65+
66+`get_plane_block_size` (`av1/common/blockd.h:1186-1193`) is
67+`av1_ss_size_lookup[bsize][ss_x][ss_y]` — **the plane block is PER-AXIS**. For
68+`BLOCK_8X8` that is BLOCK_8X8 at 4:4:4, **BLOCK_4X8 at 4:2:2**, BLOCK_4X4 at
69+4:2:0. The chroma branch of `get_txb_ctx` (`av1/common/txb_common.h:429-435`,
70+the `get_txb_ctx_4x4` specialisation) is then
71+
72+```c
73+ const int ctx_base = get_entropy_context(tx_size, a, l);
74+ const int ctx_offset = (num_pels_log2_lookup[plane_bsize] >
75+ num_pels_log2_lookup[txsize_to_bsize[tx_size]])
76+ ? 10
77+ : 7;
78+ txb_ctx->txb_skip_ctx = ctx_base + ctx_offset;
79+```
80+
81+`get_entropy_context` (`av1/common/entropy.h:87-93`, `return` at :170) is a
82+**boolean** combine for TX_4X4 — `above_ec = a[0] != 0; left_ec = l[0] != 0;`
83+then `combine_entropy_contexts` — so `ctx_base` is 0, 1 or 2.
84+
85+**Ours, `crates/ec-av1/src/decode.rs:50012` before the fix** (and the same
86+line at `50970` and `51588`), the 8x8 inter leaf's lossless chroma arm:
87+
88+```rust
89+if chroma_w == 8 && lossless(fctx) && !mono(fctx) {
90+ let (ug, vg) = leaf8_inter_chroma_lossless(...)?; // (8, 8) / stride 8 hardcoded
91+} else {
92+ u_grid = if chroma_422 {
93+ read_inter_plane_rect(dec, cdfs, chroma_set, (chroma_w, chroma_h),
94+ chroma_w, 1, chroma_around[1], mode_for_tx, u,
95+ cpx, cpy, su, Some(luma_tx_type),
96+ None /* luma_skip_ctx */, fctx)?.0
97+```
98+
99+`chroma_w == 8` is `SIDE >> ss_x == 8`, i.e. **ss_x == 0: the gate tests for
100+4:4:4**. At 4:2:2 `chroma_w` is 4, the gate is false, and the leaf's 4x8
101+plane block is coded as **one TX_4X8 unit at ctx_offset 7** (our port's
102+offset-7 rows are `txb_skip_chroma_8` rows 0..3, so `skip_ctx = above + left`
103+with no `+3`). The `None` is the offset itself:
104+`read_inter_plane_rect`'s `skip_ctx` (decode.rs:30529) is
105+`above + left + luma_skip_ctx.unwrap_or(0)`, and `multi.then_some(3)` was the
106+only thing that ever supplied the offset-10 rows.
107+
108+**Why it is a ~90% first-inter-frame divergence while frame 0 stays exact.**
109+It is a pure CDF-ROW error on one 2-symbol read, not a read-count error: the
110+first 4:2:2 chroma unit is read against `txb_skip_cdf[..][1]` where libaom
111+uses `txb_skip_cdf[..][11]`, and the two rows answer `1` and `0` for the same
112+coder state. `1` means `all_zero` — our side skips the whole plane block,
113+libaom descends into its coefficients — so from that symbol on the two decoders
114+read a different number of symbols and the coder is desynchronised for the
115+rest of the frame. Frame 0 is intra/intrabc and never reaches
116+`decode_inter_block8`, so it cannot see it. The 4:2:0 and 4:4:4 arms are
117+correct precisely because the 4:4:4 shape is the one the gate admits, and
118+`chroma422_rect` (the one-unit 4:2:2 read) only ever fired at 4:2:2.
119+
120+**Direct measurement of the wrong context** (oracle `EC_DBGCTX`, a rung that
121+prints the base, the offset and the final index):
122+
123+```
124+EC_DBGCTX mi=2,0 plane=1 tx=0 above0=7 left0=0 base=1 off=10 ctx=11 cellsA=7, cellsL=0,
125+```
126+
127+`off=10` is libaom's own number for this unit. Ours, from
128+`EC_COEFF_STEP tag=all_zero` on the same unit:
129+
130+```
131+EC_COEFF_STEP tag=all_zero plane=1 ctx=1 entry=33288 all_zero=1 rng=59556 bit=0 post_bit=1093
132+```
133+
134+`ctx=1` where the oracle has `ctx=11`, from an **identical coder state**
135+(`entry=33288` is the oracle's `ECIN=(3851,33288,1076)`), and `all_zero=1`
136+where the oracle reads `s=0`.
137+
138+## 3. How it was localised (the ladder, not a guess)
139+
140+1. `EC_SYMR` on both sides (`msac.rs:489` / libaom `aom_dsp/bitreader.h:262`)
141+ gives a read-by-read stream. Two conventions are excluded from the
142+ comparison, each measured: `pre_bit` differs by a **constant 15** (ours
143+ counts from the end of the buffer), and `cdf0` is PRE-adapt on ours and
144+ POST-adapt on the oracle. `cdf=` (the table name) is one-shot on the oracle
145+ and unlabelled on ours. Comparing on `(pre_value, pre_range, n, symbol)`,
146+ the ladders agree for **55 113 reads** and first differ at index 55 113,
147+ at the oracle's `decodetxb.c:158`.
148+2. The oracle's `EC_ECDUMP_IN` record carrying that exact pre-state is
149+ `plane=1 mi=(2,0) bc=0 br=0 tx=0 ctx=11` — a chroma TX_4x4 unit of the
150+ 8x8 inter block at `mi(2,0)`, `mode=13` (NEARESTMV), `rf=(1,0)`,
151+ `mv0=(0,0)`, `skip=0`, with the block's four luma TX_4x4 units immediately
152+ before it and all four matching ours.
153+3. A `#[track_caller]` `#[inline(never)]` breadcrumb in
154+ `read_inter_plane_rect` (temporary, reverted) pinned the ours-side unit:
155+ `w=4 h=8 plane=1 off=None lossless=true`, 418 of them over the cell —
156+ every one a wrong single-TX_4X8 read at offset 7.
157+
158+**The oracle's unit walk, read off `EC_ECDUMP_IN` for decode frame 1** (this
159+is the shape the fix has to reproduce): every TU is `tx=0` (TX_4x4); per
160+block the luma units come first, then **all** of plane 1, then **all** of
161+plane 2; inside a plane the order is **row-major** (`br` outer, `bc` inner).
162+An 8x8 leaf codes `plane=1 bc=0 br=0` then `bc=0 br=1`; a 16x16 leaf codes
163+`plane=1` as `(0,0) (1,0) (0,1) (1,1) (0,2) (1,2) (0,3) (1,3)`. That is
164+exactly what `read_inter_chroma_lossless` already walks, which is why the fix
165+routes to it instead of writing a new walk.
166+
167+## 4. The fix
168+
169+`475c45ac`, one file. The intra-frame 8x8 leaf already had the right predicate
170+— `(chroma_444 || chroma_422) && lossless(fctx)` at `decode.rs:24544`, with a
171+`CHROMA422_LOSSLESS_4X4_HITS` counter and `ll422_allintra` byte-exact. The
172+three inter / intra-in-inter 8x8-leaf arms had the wrong one.
173+
174+1. `leaf8_inter_chroma_lossless` now takes the leaf's **per-axis** plane block
175+ `(blk_w, blk_h)` and the composed grid's `stride`, instead of hardcoding
176+ `(8, 8)`/`8`; its grids are `stride * blk_h`. At 4:4:4 that is the
177+ previous `(8, 8)`/`8`/`64` verbatim.
178+2. All three gates became `lossless(fctx) && (chroma_w > 4 || chroma_h > 4) && !mono(fctx)`
179+ — the same predicate `read_inter_chroma_lossless` already uses to choose the
180+ offset-10 rows. 4:2:0's 4x4 plane block is the one shape that keeps the
181+ single-unit read, and it keeps it.
182+3. The intra-in-inter arm additionally passed `(chroma_w, chroma_w)` where the
183+ plane block is `(chroma_w, chroma_h)`, and `Grid::Zero(64)` where it is
184+ `chroma_w * chroma_h`.
185+
186+**Class sweep (same batch, same commit).** Every lossless chroma gate in
187+`decode.rs` was enumerated. The intra-frame leaf (24544, 24618, 24752) and the
188+`>=8x16` inter arms (42244, 44025) and the sub-8 rect inter arm (18368) were
189+already shape-generic. The three 8x8-leaf sites were the only ones keyed to a
190+chroma format's shape, and all three are fixed; no fourth exists.
191+
192+**Non-vacuity of the new arm, measured** (gate counters, `W_intrabc`, bypass
193+on, before → after):
194+
195+| counter | before | after |
196+|---|---|---|
197+| `chroma422_rect` (the one-unit 4:2:2 read) | **88** | **0** |
198+| `chroma422_sub8` (the per-4x4-unit 4:2:2 walk) | 169 | **391** |
199+| `chroma422_square` (the 64x64 lossless walk) | 3312 | 3312 |
200+
201+The 88 single-unit reads are gone and 222 unit reads moved to the 4x4 walk.
202+(`intra128_lossless` 8 → 0 and `rect4_16_pair.lossless_chroma` 106 → 72 also
203+move, because the **before** counts are read off a desynchronised parse that
204+wanders into shapes the bitstream never codes; the after counts are the truth
205+and the output is byte-exact.)
206+
207+## 5. Per-cell, per-plane, per-decode-frame before → after
208+
209+Comparator: `/home/user/.cache/lane2/beforeafter.py` and
210+`cmp422.py` / `cmp422_10.py`, against the instrumented oracle
211+`/home/user/.cache/aom-oracle/build/aomdec` (`EC_AV1_FINAL_DUMP`, DECODE
212+order). BEFORE = a binary built at `cc211d13`, AFTER = this tip, **both with
213+the same one-line header bypass**.
214+
215+### W_intrabc.obu — 320x240 4:2:2 8-bit (Y 76 800, U 38 400, V 38 400)
216+
217+| decode | Y before | Y after | U before | U after | V before | V after |
218+|---|---|---|---|---|---|---|
219+| f0 | 0 | **0** | 0 | **0** | 0 | **0** |
220+| f1 | 68878 | **0** | 33705 | **0** | 36125 | **0** |
221+| f2 | 61759 | **0** | 33722 | **0** | 31699 | **0** |
222+| f3 | 38655 | **0** | 22290 | **0** | 22672 | **0** |
223+| f4 | 60575 | **0** | 30740 | **0** | 31932 | **0** |
224+| f5 | 62519 | **0** | 32023 | **0** | 32766 | **0** |
225+| f6 | 47888 | **0** | 25253 | **0** | 26030 | **0** |
226+| f7 | 55451 | **0** | 29072 | **0** | 29251 | **0** |
227+| f8 | 64691 | **0** | 33976 | **0** | 34825 | **0** |
228+| f9 | 68648 | **0** | 32663 | **0** | 34986 | **0** |
229+| f10 | 63161 | **0** | 34011 | **0** | 34183 | **0** |
230+| f11 | 67701 | **0** | 33187 | **0** | 34221 | **0** |
231+| f12 | 67757 | **0** | 32706 | **0** | 35316 | **0** |
232+| f13 | 61672 | **0** | 35592 | **0** | 35639 | **0** |
233+| f14 | 70701 | **0** | 34980 | **0** | 36703 | **0** |
234+| f15 | 65392 | **0** | 33087 | **0** | 34597 | **0** |
235+| f16 | 61404 | **0** | 31116 | **0** | 32791 | **0** |
236+
237+First differing sample before, decode f1: `Y(r0,c32)` oracle 81 / ours 83,
238+`U(r0,c8)` 88 / 86, `V(r0,c13)` 247 / 246. **`W_intrabc`: 1/17 → 17/17 exact.**
239+
240+### X_intrabc_tiled.obu — 320x240 4:2:2 8-bit
241+
242+| decode | Y before | Y after | U before | U after | V before | V after |
243+|---|---|---|---|---|---|---|
244+| f0 | 0 | **0** | 0 | **0** | 0 | **0** |
245+| f1 | 54402 | **0** | 27737 | **0** | 26919 | **0** |
246+| f2 | 52502 | **0** | 26535 | **0** | 24645 | **0** |
247+| f3 | 59058 | **0** | 28274 | **0** | 27378 | **0** |
248+| f4 | 42325 | **0** | 19863 | **0** | 20461 | **0** |
249+| f5 | 61220 | **0** | 25404 | **0** | 25952 | **0** |
250+| f6 | 61042 | **0** | 29397 | **0** | 29989 | **0** |
251+| f7 | 51250 | **0** | 24985 | **0** | 25541 | **0** |
252+| f8 | 62799 | **0** | 31017 | **0** | 31519 | **0** |
253+| f9 | 59296 | **0** | 29642 | **0** | 28010 | **0** |
254+| f10 | 57825 | **0** | 28145 | **0** | 27357 | **0** |
255+| f11 | 64944 | **0** | 31939 | **0** | 31561 | **0** |
256+| f12 | 60101 | **0** | 30189 | **0** | 29064 | **0** |
257+| f13 | 59572 | **0** | 29504 | **0** | 28687 | **0** |
258+| f14 | 54986 | **0** | 27697 | **0** | 27353 | **0** |
259+| f15 | 62070 | **0** | 30998 | **0** | 30081 | **0** |
260+| f16 | 55335 | **0** | 28123 | **0** | 27374 | **0** |
261+
262+**`X_intrabc_tiled`: 1/17 → 17/17 exact.**
263+
264+### Y_intrabc_10b.obu — 300x256 4:2:2 10-bit (differing SAMPLES)
265+
266+| decode | frames emitted before / oracle | Y before | Y after | U before | U after | V before | V after |
267+|---|---|---|---|---|---|---|---|
268+| f0 | 4 / 17 | 0 | **0** | 0 | **0** | 0 | **0** |
269+| f1 | | 63609 | **0** | 33415 | **0** | 31993 | **0** |
270+| f2 | | 53597 | **0** | 29657 | **0** | 29215 | **0** |
271+| f3 | | 61289 | **0** | 33685 | **0** | 33657 | **0** |
272+| f4..f16 | 0 / 13 | — | **0** | — | **0** | — | **0** |
273+
274+**The before build emitted only 4 of the oracle's 17 decode frames and then
275+stopped silently.** The after build emits 17 and **all 17 are byte-exact on
276+all three planes** (76 800 + 38 400 + 38 400 samples each, 307 200 B). This
277+settles the two items lane-av1422llinter flagged as unverified:
278+
279+* the `Golomb tail longer than this decoder reads` refusal in the debt **does
280+ not exist** — no message is printed, before or after; and
281+* the "4 of 17 frames then silence" was **this desync**, not a separate
282+ defect. `Y_intrabc_10b` needs no handover.
283+
284+### Oracle-flip control (both cells, both comparators)
285+
286+| control | result |
287+|---|---|
288+| W: XOR `0x01` into oracle decode f0 sample 0 | exactly **1** differing byte, reported at f0 plane Y (0,0); f1 stays exact |
289+| X: XOR `0x01` into oracle decode f1 sample 0 | exactly **1** differing byte, reported at f1 plane Y (0,0); f0 and f2 stay exact |
290+
291+The comparator bites on a single flipped byte, so the 17/17 rows are not a
292+comparator that has stopped comparing.
293+
294+## 6. The rest of the 4:2:2 corpus, and the 4:2:0 / 4:4:4 controls
295+
296+`/home/user/.cache/lane2/census422.sh` — every `.obu` under
297+`av1422lpf/` and `av1422lpf/lossy_all/`, before and after, same oracle.
298+"bad-frames" counts decode frames that differ from the oracle in any byte.
299+
300+| cell | oracle frames | bad before | bad after |
301+|---|---|---|---|
302+| **W_intrabc** | 17 | 16 | **0** |
303+| **X_intrabc_tiled** | 17 | 16 | **0** |
304+| **Y_intrabc_10b** | 17 | 16 (only 4 emitted) | **0** (17 emitted) |
305+| **ll422_noibc** (probe) | 16 | 14 | **0** |
306+| 422_allskip_2f | 2 | 0 | 0 |
307+| 422_intrabc_sb128_strip | 5 | 0 | 0 |
308+| 422_intrabc_sb128_strip_notxsearch | 5 | 0 | 0 |
309+| 422_residual_compound_warp_16f | 16 | 0 | 0 |
310+| 422_residual_compound_warp_nolr_16f | 16 | 0 | 0 |
311+| 422_sb128_3f | 3 | 0 | 0 |
312+| ll422_allintra (probe) | 1 | 0 | 0 |
313+| AA_inter_compound | 43 | 0 | 0 |
314+| AD_inter_nogm | 43 | 0 | 0 |
315+| A_testsrc2_cpu0 | 17 | 0 | 0 |
316+| B_testsrc2_cpu6 | 17 | 0 | 0 |
317+| C_mandel320 | 16 | 0 | 0 |
318+| D_bars | 16 | 0 | 0 |
319+| E_noglobal | 17 | 0 | 0 |
320+| F_allintra | 16 | 0 | 0 |
321+| H_10bit_testsrc2 | 17 | 0 | 0 |
322+| I_10bit_mandel | 16 | 0 | 0 |
323+| J_10bit_lr0 | 17 | 0 | 0 |
324+| K_sct | 17 | 0 | 0 |
325+| L_tiled | 17 | 0 | 0 |
326+| R_odd322x240 | 17 | 0 | 0 |
327+| T_tilecols2 | 17 | 0 | 0 |
328+| U_tilerows1 | 17 | 0 | 0 |
329+| V_tile2x2_odd | 17 | 0 | 0 |
330+| **AB_inter_warp_odd** | 43 | 43 | 43 |
331+| **O_odd322x242** | 17 | 17 | 17 |
332+| **Q_odd320x242** | 17 | 17 | 17 |
333+| **S_odd326x242_10b** | 17 | 17 | 17 |
334+
335+**24 of 31 unique 4:2:2 cells exact before → 27 of 31 after.** The four
336+remaining are the **odd-HEIGHT** cluster lane-av1422llinter flagged in its §4b
337+as a different mechanism: all 242 px tall, all failing at decode **frame 0**
338+(intra, no reference slot read), and `R_odd322x240` — odd *width*, even
339+height — is exact. Untouched here, as instructed.
340+
341+**4:2:0 / 4:4:4 lossless controls** (`regress_420/`, `regress_444/`,
342+`probe/ll420_allintra`, `probe/ll444_allintra`), all before-and-after:
343+
344+| cell | framesize | oracle | bad before | bad after |
345+|---|---|---|---|---|
346+| ll420_a / ll420_b / ll420_c / ll420_d | 115 200 | 16 | 0 | 0 |
347+| ll444_a / ll444_b | 230 400 | 16 | 0 | 0 |
348+| ll444_c | 230 400 | 18 | 0 | 0 |
349+| ll420_allintra | 115 200 | 1 | 0 | 0 |
350+| ll444_allintra | 230 400 | 1 | 0 | 0 |
351+
352+No byte moved at 4:2:0 or 4:4:4, which is the shape of the claim: 4:2:0's plane
353+block is 4x4 (gate false before and after, one unit at offset 7) and 4:4:4's
354+is 8x8 (gate true before and after, `(8, 8)`/`8` passed through verbatim).
355+
356+## 7. Gate-ability: **NO.** Stated plainly, with the measurement.
357+
358+4:2:2 is refused at the **sequence header** — `stream.rs:1803`,
359+`if seq.subsampling_x != seq.subsampling_y { return Err(...) }` — which
360+returns before any tile, mode-info or coefficient code runs. Measured on this
361+tip, on the committed fixture, with the bypass reverted:
362+
363+```
364+$ decode_probe crates/ec-av1/fixtures/W_intrabc.obu
365+REFUSED: unsupported: AV1 decode_stream (a chroma format of 4:2:2
366+(subsampling_x != subsampling_y): this decoder decodes 4:2:0 and 4:4:4;
367+4:2:2 is not ported, and 4:4:0 (0,1) is not a codable cell)
368+```
369+
370+**Isolation control.** With the bypass applied and nothing else changed, the
371+six committed 4:2:2 tests fail with `called Result::unwrap_err() on an Ok
372+value: [Picture { width: 320, height: 240, y: [74, 74, …` — i.e. with the
373+guard patched out the decoder *decodes* the pinned witnesses. Those six tests
374+are `a_non_420_subsampled_sequence_header_is_refused_by_name`,
375+`the_pinned_422_bigblock_witnesses_…`,
376+`the_pinned_422_intrabc_sb128_strip_witnesses_…`,
377+`the_pinned_422_lossless_inter_witnesses_…`,
378+`the_pinned_422_lr_off_witness_…` and
379+`the_pinned_422_residual_compound_warp_witness_…`. Every one of them asserts
380+**the header refusal**, which fires before the fixed code is reachable.
381+Measured, both trees with the bypass reverted:
382+`cargo test -p ec-av1 --lib -- 422 refuse` gives
383+**`34 passed; 0 failed`** at the clean parent `cc211d13` and
384+**`34 passed; 0 failed`** at this tip — identical, so all six are vacuous
385+with respect to this commit.
386+
387+**So: the fixture bytes are committed, pinned and byte-exact-verified, but no
388+committed test can execute the code this commit changes, because the only
389+committed entry point refuses 4:2:2 first. A byte-exactness gate would have
390+to lift that refusal, which is the user's product decision and explicitly out
391+of scope here.** The evidence offered instead is measurement plus the
392+single-variable controls in §6 (one source, one encoder, three chroma formats
393+→ 4:2:0 and 4:4:4 exact before and after, 4:2:2 exact only after) and the
394+oracle-flip controls in §5. **No source-scan substitute is offered**: the
395+committed `the_422_lossless_inter_chroma_walk_sites_stay_per_axis` proves
396+spelling and nothing about pixels, and this commit's guard is a *predicate*,
397+which no spelling scan could distinguish from the predicate it replaced.
398+
399+The path to a real gate, for whoever lifts the refusal: the three fixtures are
400+already in `crates/ec-av1/fixtures/` and already in
401+`scripts/fixture-library.tsv`, and their oracle decode-order dumps are exactly
402+the `EC_AV1_FINAL_DUMP` files §5 tabulates. `W_intrabc` and `X_intrabc_tiled`
403+then become 17/17 byte-exactness gates immediately, and should be
404+mutation-proved (revert the guard predicate → 16/17).
405+
406+## 8. Regression
407+
408+On the reverted (bypass-free) tree at `475c45ac`:
409+
410+```
411+$ cargo test -p ec-av1 --lib -- 420 422 444 lossless warp intra \
412+ --skip bitrate_target_lands_within_5_percent_over_48_frames
413+test result: ok. 181 passed; 0 failed; 2 ignored; 0 measured; 618 filtered out; finished in 251.38s
414+```
415+
416+**181 passed, 0 failed, 2 ignored, 618 filtered out** — the same count
417+lane-av1422llinter measured as its baseline at `cc211d13`, so the six fixes
418+that landed before this one are untouched. (`cargo check -p ec-av1
419+--all-targets` is clean.)
420+
421+## 9. What was refuted, and how
422+
423+| claim | verdict | how |
424+|---|---|---|
425+| "frame 0's exactness exonerates the coefficient path" | **refuted** | it exonerates the *intra* path only; frame 1 is the first to reach `decode_inter_block8`'s chroma arm at all, and the fork is on its 24th transform unit |
426+| "the divergence is a coefficient read-COUNT error (an extra or missing symbol)" | **refuted** | the forked read has an identical coder state (`entry=33288` both sides), the same alphabet (n=2), and differs only in the value — a wrong CDF ROW, not a wrong number of reads. The read count only diverges *downstream* of the bad symbol |
427+| "the oracle's chroma `txb_skip_ctx` is a sum of the neighbour contexts" | **refuted** | `EC_DBGCTX` prints `above0=7 left0=0 base=1`; `get_entropy_context` is a boolean combine (`entropy.h:93`, `return combine_entropy_contexts(...)` at :170), so 7+0 masks to 1 |
428+| "it is OBMC / warp / compound / the reference slot / the interpolating filter" | **refuted** | the fork is a *token-read* divergence with no MC in the path at all: it happens while reading the first chroma unit's `txb_skip`, before any prediction is applied. The prefilter-vs-final identity that exonerates the filters is inherited from lane-av1422llinter §2 and is not re-litigated |
429+| "the intra and inter paths need different fixes" | **refuted** | the intra-frame 8x8 leaf already had `(chroma_444 || chroma_422) && lossless` (decode.rs:24544) and `ll422_allintra` was byte-exact; the inter and intra-in-inter arms were the three outliers and all three now share one predicate |
430+| "4:2:0 or 4:4:4 might be affected too" | **refuted** | 7 lossless 4:2:0/4:4:4 control cells measured before and after, 0 bad frames in both directions; the guard is false at 4:2:0 in both and the (8,8)/8 arguments pass through verbatim at 4:4:4 |
431+| "the 4 odd-HEIGHT cells are this defect" | **refuted** | they fail at decode frame 0 (intra, no reference read) at 242 px height while `R_odd322x240` is exact, and they are byte-identical before and after this commit |
432+| "the `Golomb tail` refusal in the debt is real" | **refuted** | no message is printed on either build; the before build's 4-of-17 silent stop is this desync and disappears with the fix (`Y_intrabc_10b` is now 17/17) |
433+
434+## 10. Handover
435+
436+1. **Nothing is broken and nothing is handed over.** Three committed 4:2:2
437+ fixtures that were 1/17, 1/17 and 1/4 exact are now 17/17, 17/17 and
438+ 17/17 on all three planes, and `ll422_noibc` is 16/16.
439+2. **Gating needs the refusal lifted** (§7); that is the user's call. When it
440+ is, `W_intrabc.obu` and `X_intrabc_tiled.obu` are the gates and the
441+ mutation is one predicate.
442+3. **The odd-HEIGHT cluster is untouched and unclaimed**: `AB_inter_warp_odd`,
443+ `O_odd322x242`, `Q_odd320x242`, `S_odd326x242_10b`, all 242 px tall, all
444+ failing at decode frame 0. Adjacent to the closed `lane-av1oddheightfork3`.
445+4. The instruments live in `/home/user/.cache/lane2/`:
446+ `cmp422.py`, `cmp422_10.py`, `beforeafter.py` (per-plane comparators with
447+ the flip control), `symrpair.py` (the read-by-read `EC_SYMR` pairer, with
448+ the two conventions it excludes and why), `census422.sh`, `reg420444.sh`,
449+ `probe.sh`.