forge
Explore
Log in

Don't you dare go Hollow

av1: bound the lossless rect strip's chroma walk by the CHROMA PLANE

Browse files at this commit

ca7bfb4f538fe53add6a61977ad7401d9a60252cAhmet Kaan GümüşParent: 7929331
The 40 extra `txb_skip` reads at the bottom-right partial superblock of a
176x144 mixed-lossless+altref stream were `decode_rect_split`'s LOSSLESS
plane-major 4x4 chroma walk, which counted the block's own
`chroma_w / 4` x `chroma_h / 4` units. libaom counts the PLANE's:
`max_block_wide/high(xd, plane_bsize, plane)` adds
`mb_to_right_edge >> (3 + pd->subsampling_x)` and
`av1_foreach_transformed_block_in_plane` drops any unit past it
(av1_common_int.h:1565, decodeframe.c:1124). The LUMA walk in the same
function already carried that clip; the chroma walk did not.

The bottom-right superblock of a 176x144 frame is a 48x16 sliver, but the
block coded at mi=(32,32) is bw=64 bh=32, so its chroma plane block is 32x16
at origin (64,64) on an 88x72 plane: 8x4 units walked where 6x2 are coded,
20 phantom units per plane, 40 in total. Every one carries `all_zero` and
consumes no data -- the bit position freezes at 36288 -- which is why frame
0's pixels are byte-exact either way and why the desync only surfaces
11 970 reads later as an unbounded Golomb tail.

Frame 0's transform-unit count goes 2413 -> 2373, and 2373 is the oracle's
own EC_ECDUMP_IN census for the same bytes. The paired EC_SYMR ladder is
bit-identical through read 29410 (was 25791).

Fixture: frame 0 of `mix_176x144_6.obu` (the 6-frame stream is 20 069 B,
sha256 02b15d0d...; this fixture is its first 4581 B), so the gate decodes
cleanly in isolation. The gate asserts the off-tile counter is nonzero, the
unit count equals the oracle's census, and the pixels match aomdec; it goes
red at 2381 with the width half of the clip disabled and red on
gate-blind-to-feature with the clip removed.

Regression control: mix_640x480_5/6, mix_320x240_6, mix_176x144_5 and c_mix5
are unchanged. Note 640x480 does not decode CORRECTLY at base -- every inter
frame already differs from the oracle by 352066 / 414286 / 313795 / 399471
of 460 800 bytes -- and this patch is inert there.

This cell's refusal is NOT gone by this commit alone: the first divergence
moves to 29411, the var-tx/lossless conjunct lane Agent05-5 owns. Measured in a
scratch tree at 658d37fa with this patch on top, both 176x144 and 352x288
decode and match the oracle byte for byte; 640x480 REFUSES with both, which
is Agent05-5's regression and not this walk's. See lanes/av1offtile.report.md.
crates/ec-av1/fixtures/mix176_offtile_chroma_clip.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+67 -0
@@ -2403,6 +2403,21 @@ fn census_unit(
24032403 );
24042404 }
24052405
2406+/// How many transform units this thread has read since the last
2407+/// [`reset_census_unit_n`] (lane-av1offtile). The per-unit oracle twin is
2408+/// `EC_ECDUMP_IN`, one line per `read_coeffs_txb` call, so this count IS
2409+/// directly comparable with an oracle `EC_ECDUMP_IN` census -- which is what
2410+/// makes "we walk N units where libaom walks M" a gated claim rather than an
2411+/// inference from the desync's position.
2412+pub fn census_unit_n() -> usize {
2413+ CENSUS_UNIT_N.with(|c| c.get())
2414+}
2415+
2416+/// Reset [`census_unit_n`] to zero (lane-av1offtile).
2417+pub fn reset_census_unit_n() {
2418+ CENSUS_UNIT_N.with(|c| c.set(0));
2419+}
2420+
24062421 /// lane-av1ibcfork: this decoder's half of the per-unit BIT INTERVAL -- the
24072422 /// exact mirror of the oracle's `EC_ECDUMP_IN` / `EC_ECDUMP_OUT` /
24082423 /// `EC_ECDUMP_END` triple (`aom-oracle2/src/av1/decoder/decodetxb.c`: one
@@ -6700,6 +6715,15 @@ thread_local! {
67006715 /// asserting the reach fix must see this nonzero, or the fixture never
67016716 /// exercised the fixed path.
67026717 static SUB8_CHROMA444_LOSSLESS_TU_REACH_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
6718+ /// lane-av1offtile: 4x4 chroma units a lossless HORZ/VERT strip's plane-
6719+ /// major walk skipped because their top-left sample falls outside the
6720+ /// CHROMA plane. libaom bounds that walk per plane (`max_block_wide/high`,
6721+ /// av1_common_int.h:1565); this walk used to count the block's own
6722+ /// `chroma_w / 4` x `chroma_h / 4`. Zero means no stream decoded a
6723+ /// lossless strip overhanging the frame edge -- a gate asserting the
6724+ /// clip must see this nonzero.
6725+ static RECT_SPLIT_LOSSLESS_CHROMA_OFFTILE_HITS: std::cell::Cell<usize> =
6726+ const { std::cell::Cell::new(0) };
67036727 }
67046728
67056729 /// How many skipped sub-8x8 chroma blocks carried a CfL alpha (the shape
@@ -6730,6 +6754,19 @@ pub fn rect_split_lossless_chroma444_hits() -> usize {
67306754 RECT_SPLIT_LOSSLESS_CHROMA444_HITS.with(|c| c.get())
67316755 }
67326756
6757+/// How many 4x4 chroma units a lossless HORZ/VERT strip's plane-major walk
6758+/// skipped for falling outside the chroma plane (lane-av1offtile). Zero means
6759+/// no stream decoded a lossless strip overhanging the frame edge -- a gate
6760+/// asserting the clip must see this nonzero.
6761+pub fn rect_split_lossless_chroma_offtile_hits() -> usize {
6762+ RECT_SPLIT_LOSSLESS_CHROMA_OFFTILE_HITS.with(|c| c.get())
6763+}
6764+
6765+/// Reset [`rect_split_lossless_chroma_offtile_hits`] to zero (lane-av1offtile).
6766+pub fn reset_rect_split_lossless_chroma_offtile_hits() {
6767+ RECT_SPLIT_LOSSLESS_CHROMA_OFFTILE_HITS.with(|c| c.set(0));
6768+}
6769+
67336770 /// How many unskipped intrabc 8x4/4x8 leaves a lossless frame walked luma as
67346771 /// per-4x4 inter units (lane-av1-ibc444rect).
67356772 pub fn intrabc_rect8_lossless_luma_hits() -> usize {
@@ -12859,6 +12896,36 @@ fn decode_rect_split(
1285912896 for plane_idx in 1..=2 {
1286012897 for cu_row in 0..ch_n {
1286112898 for cu_col in 0..cw_n {
12899+ // lane-av1offtile: the CHROMA twin of the luma walk's
12900+ // `max_blocks_wide/high` clip (decode.rs:12516, lane-hgkf
12901+ // r1). libaom computes those bounds per PLANE
12902+ // (`max_block_wide(xd, plane_bsize, plane)`,
12903+ // av1_common_int.h:1565 -- `mb_to_right_edge >>
12904+ // (3 + pd->subsampling_x)`, then `>> MI_SIZE_LOG2`), so a
12905+ // chroma unit whose top-left sample falls outside the
12906+ // CHROMA plane is never coded. This walk counted
12907+ // `chroma_w / 4` x `chroma_h / 4` units off the BLOCK's
12908+ // own extent instead.
12909+ //
12910+ // MEASURED on `mix_176x144_6.obu` (4:2:0 8-bit,
12911+ // --cq-level=0 --aq-mode=1 altref; the 48x16 bottom-right
12912+ // sliver, block mi=(32,32) px=(128,128) bw=64 bh=32):
12913+ // the chroma plane is 88x72, so `cw_n` must be
12914+ // `(88 - 64) / 4 = 6` and `ch_n` `(72 - 64) / 4 = 2` --
12915+ // the oracle's own `EC_ECDUMP_IN` for that block is
12916+ // exactly 12 units per plane (bc 0..5 x br 0..1). Ours
12917+ // walked 8 x 4 = 32 per plane: 20 phantom units x 2
12918+ // planes = the 40 extra `txb_skip` reads after SYMR
12919+ // 25791, all at `mi=(32,32)`, all `all_zero`, all with
12920+ // the bit position FROZEN at 36288 -- reads out of a
12921+ // tile already exhausted, which is what turned the
12922+ // desync 11 970 reads later into a hard
12923+ // `REFUSED: unsupported: AV1 tile (a Golomb tail longer
12924+ // than this decoder reads)`.
12925+ if cpx + cu_col * 4 >= u.true_width || cpy + cu_row * 4 >= u.true_height {
12926+ hit!(RECT_SPLIT_LOSSLESS_CHROMA_OFFTILE_HITS);
12927+ continue;
12928+ }
1286212929 let cu_mi = (mi_r + cu_row * (span_y / MI), mi_c + cu_col * (span_x / MI));
1286312930 // lane-av1422llintra: at ss (1, 0) one chroma column
1286412931 // spans TWO luma mi columns, so the plain rect walk sums
crates/ec-av1/src/stream.rsmodified+106 -0
@@ -52099,6 +52099,112 @@ exit 0
5209952099 /// makes `bw >> ss_x` the same arithmetic as the halving, and the pinned
5210052100 /// 4:2:0 twin (`420_intrabc_rect4_witness.obu`) is asserted byte-exact
5210152101 /// against the oracle in the same run.
52102+ /// lane-av1offtile: a lossless HORZ/VERT strip's PLANE-MAJOR 4x4 chroma
52103+ /// walk is bounded by the CHROMA PLANE, not by the block's own footprint.
52104+ ///
52105+ /// libaom bounds every transform walk per PLANE -- `max_block_wide` /
52106+ /// `max_block_high` (`av1_common_int.h:1565`) add `mb_to_right_edge >>
52107+ /// (3 + pd->subsampling_x)` to the plane block's size before the
52108+ /// `>> MI_SIZE_LOG2`, and `av1_foreach_transformed_block_in_plane`
52109+ /// (`decodeframe.c:1124`) drops any unit whose `blk_col`/`blk_row` is past
52110+ /// them. `decode_rect_split`'s luma walk carries that clip
52111+ /// (`decode.rs`, the `tu_px >= y.true_width` guard lane-hgkf r1 added for
52112+ /// the LUMA plane); its lossless chroma walk counted `chroma_w / 4` x
52113+ /// `chroma_h / 4` off the block instead, so a block overhanging the bottom-
52114+ /// right frame edge read chroma transform units that do not exist.
52115+ ///
52116+ /// MEASURED on `mix176_offtile_chroma_clip.obu`, whose bytes are frame 0
52117+ /// of the 4:2:0 8-bit `mix_176x144_6.obu`
52118+ /// (`ffmpeg -f lavfi -i testsrc2=size=176x144:rate=25 -frames:v 6
52119+ /// -pix_fmt yuv420p`, then `aomenc --codec=av1 --obu --passes=1
52120+ /// --cpu-used=4 --limit=6 --end-usage=q --cq-level=0 --aq-mode=1`; the
52121+ /// whole 6-frame stream is 20 069 B, sha256
52122+ /// `02b15d0d5b08aa5aebf139aee94c31b4f8363d14649c238cd7a19a9785ef124a`,
52123+ /// and this fixture is its first 4 581 B -- the temporal delimiter,
52124+ /// sequence header and frame-0 OBU, nothing else). The bottom-right
52125+ /// superblock is the 48x16 sliver of a 176x144 frame, and its block at
52126+ /// `mi=(32,32)` `px=(128,128)` is `bw=64 bh=32`, so the chroma plane
52127+ /// block (`cpx=64 cpy=64`, plane 88x72) is 32x16 where only 24x8 is coded.
52128+ /// That is `cw_n` 8 -> 6 and `ch_n` 4 -> 2: **20 phantom units per plane,
52129+ /// 40 in total**, and 40 is exactly the extra-read count the paired
52130+ /// `EC_SYMR` ladder measures (ours 25792..25831, the oracle doing a
52131+ /// range-coder init for the next frame there).
52132+ ///
52133+ /// The unit count below is the load-bearing number, not the pixels: the
52134+ /// 40 phantom reads all carry `all_zero` and consume no data (the bit
52135+ /// position freezes at 36288), so frame 0's pixels are byte-exact EITHER
52136+ /// WAY and a pixel compare alone would be blind to this defect. Frame 0's
52137+ /// transform-unit count is 2413 without the clip and 2373 with it, and
52138+ /// **2373 is the oracle's own count** -- the number of `EC_ECDUMP_IN`
52139+ /// lines the shared `aomdec` prints for the same bytes. Reverting the
52140+ /// clip restores 2413 and fails this assert; that is the mutation proof.
52141+ ///
52142+ /// What the 40 reads cost, on the FULL 6-frame stream rather than this
52143+ /// prefix: the desync is 11 970 reads downstream of them, where the
52144+ /// exhausted tile yields an unbounded `read_golomb` tail and the decoder
52145+ /// refuses with `unsupported: AV1 tile (a Golomb tail longer than this
52146+ /// decoder reads)` -- a supported 4:2:0 8-bit cell lost to a walk that ran
52147+ /// off its own tile. Fixing the walk moves the first remaining divergence
52148+ /// on the full stream from SYMR 25 792 to 29 411, a different block at a
52149+ /// different geometry (the var-tx/`lossless` conjunct lane-av1mixllfork
52150+ /// and lane-av1golomb320 own), and both this clip and that one applied
52151+ /// together decode the cell and match the oracle byte for byte. That
52152+ /// composition is measured, not claimed: this gate pins only the walk
52153+ /// this commit fixes.
52154+ #[test]
52155+ fn a_420_lossless_rect_chroma_walk_is_bounded_by_the_chroma_plane() {
52156+ const NAME: &str = "a_420_lossless_rect_chroma_walk_is_bounded_by_the_chroma_plane";
52157+ const FIXTURE: &str = "mix176_offtile_chroma_clip.obu";
52158+ const FIXTURE_LEN: usize = 4581;
52159+ const FIXTURE_FNV: u64 = 0x5e31be5efc9c3c1d;
52160+ /// The oracle's own `EC_ECDUMP_IN` count for these bytes.
52161+ const ORACLE_UNITS: usize = 2373;
52162+ const W: usize = 176;
52163+ const H: usize = 144;
52164+
52165+ let path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
52166+ .join(format!("fixtures/{FIXTURE}"));
52167+ let stream = read_pin(&path, FIXTURE_LEN, FIXTURE_FNV, NAME);
52168+ assert_eq!(
52169+ stream_bit_depth(&stream, NAME),
52170+ 8,
52171+ "{NAME}: the pinned witness is not 8-bit"
52172+ );
52173+
52174+ let _guard = lock_gate_counters();
52175+ crate::decode::reset_rect_split_lossless_chroma_offtile_hits();
52176+ crate::decode::reset_census_unit_n();
52177+ let frames = decode_stream(&stream)
52178+ .unwrap_or_else(|e| panic!("{NAME}: the pinned witness no longer decodes: {e}"));
52179+ assert_eq!(frames.len(), 1, "{NAME}: frame count");
52180+ assert_eq!(
52181+ (frames[0].width, frames[0].height),
52182+ (W, H),
52183+ "{NAME}: dimensions"
52184+ );
52185+
52186+ // Non-vacuity: the clip must have run on this fixture, or the unit
52187+ // count below is just "the walk happened to be short here" (class
52188+ // gate-blind-to-feature).
52189+ let clipped = crate::decode::rect_split_lossless_chroma_offtile_hits();
52190+ assert!(
52191+ clipped > 0,
52192+ "{NAME}: no lossless rect chroma unit fell outside the chroma plane -- \
52193+ the corrected walk never ran, so this gate is measuring the \
52194+ unclipped one (class gate-blind-to-feature)"
52195+ );
52196+
52197+ // The oracle-anchored red-before/green-after: 2413 without the clip.
52198+ let units = crate::decode::census_unit_n();
52199+ assert_eq!(
52200+ units, ORACLE_UNITS,
52201+ "{NAME}: frame 0 walked {units} transform units, the oracle's own \
52202+ EC_ECDUMP_IN census for these bytes is {ORACLE_UNITS}"
52203+ );
52204+
52205+ decode_all_frames_vs_oracle(&stream, NAME);
52206+ }
52207+
5210252208 #[test]
5210352209 fn a_444_intrabc_rect_chroma_plane_block_is_the_block_footprint() {
5210452210 const NAME: &str = "a_444_intrabc_rect_chroma_plane_block_is_the_block_footprint";
lanes/av1offtile.report.mdadded+415 -0
@@ -0,0 +1,415 @@
1+# lane-av1offtile — the 40 off-tile reads are `decode_rect_split`'s LOSSLESS chroma walk: it counted the block's own `chroma_w/4 x chroma_h/4`, libaom counts the CHROMA PLANE's
2+
3+Base `main` = `6bb66a4a`. Worktree `/home/user/.cache/wt/av1offtile`, target dir
4+`$HOME/.cache/cargo-target-av1offtile`, `EC_NOMEMGUARD=1`. Oracle
5+`~/.cache/aom-oracle/build/{aomdec,aomenc}` (shared, untouched). ffmpeg 8.1.x.
6+**No var-tx conjunct taken, no edit to `decode.rs:48259` / `:27140` (Agent05-5 owns
7+those), no probe bypass and no env-gated trace left in the tree.**
8+
9+---
10+
11+## 0. Verdict
12+
13+| | |
14+|---|---|
15+| Owner of the 40 reads identified | **yes** — `fn decode_rect_split`, the `else if lossless(fctx)` arm's plane-major 4x4 chroma double loop (`for plane_idx in 1..=2 { for cu_row in 0..ch_n { for cu_col in 0..cw_n }`), fed by `let (cw_n, ch_n) = (chroma_w / 4, chroma_h / 4)` |
16+| Is it the tile loop? | **no.** The tile walk (`decode_tile`'s `sb_visit_order` loop, `decode.rs` ~35086) sets `set_tile_origin` correctly and is not implicated; §4 measures this |
17+| Extent walked | the **block's own** `chroma_w / 4` x `chroma_h / 4`. libaom walks `max_block_wide/high(xd, plane_bsize, 1)`, i.e. the **chroma plane's** extent |
18+| Why the bit position freezes | the walk ran **off the end of the tile's byte range** into an exhausted `SymbolDecoder`; `dec.literal(1)` then returns 0 forever, so every further `aom_read_symbol` renormalises `rng` (decaying ~509/read here) and advances **no** bits |
19+| Fix | **landed** — 2 lines, the chroma twin of the luma `max_blocks_wide/high` clip already in the same function |
20+| 40 extra reads | **gone**; frame 0's transform-unit count is now the oracle's own number (2373 = 2373) |
21+| The hard refusal | **still present on this cell at this commit**, and it is NOT this walk's — §5 measures exactly which defect now owns it |
22+| 640x480 control | **decodes 5/5 and 6/6 unchanged, and RED on pixels at base** — this walk is inert there (§6) |
23+| Gate + fixture + mutation proof | **yes**, §6 |
24+| A wrong claim, caught and corrected | **yes** — §5, 640x480 under the COMBINED fixes |
25+| Class sweep | **done**, §7: one site; the two sibling chroma walks never trip the same condition on 18 generated edge-overhang cells or the whole committed corpus |
26+
27+## 1. The cells
28+
29+Same recipe as the inherited context, per size:
30+
31+```text
32+ffmpeg -f lavfi -i testsrc2=size=<S>:rate=25 -frames:v 6 -pix_fmt yuv420p s.y4m
33+aomenc --codec=av1 --obu -o <out> --passes=1 --cpu-used=4 --limit=6 \
34+ --end-usage=q --cq-level=0 --aq-mode=1 s.y4m
35+```
36+
37+| cell | bytes | sha256 |
38+|---|---:|---|
39+| `mix_176x144_6.obu` | 20 069 | `02b15d0d5b08aa5aebf139aee94c31b4f8363d14649c238cd7a19a9785ef124a` |
40+| `mix_352x288_6.obu` | 46 490 | `e43c74b8d847e701953cef19dbfb78e4efb5949c4c9293a74201b075a0c85d81` |
41+
42+At `6bb66a4a` both `REFUSED: unsupported: AV1 tile (a Golomb tail longer than
43+this decoder reads)`, reproducing the inherited frame exactly. Controls at the
44+same base, all decoding: `mix_640x480_5/6`, `mix_320x240_6`, `mix_176x144_5`,
45+`c_mix5.obu` (the peer's 256x128 red cell).
46+
47+## 2. The 40 reads, named
48+
49+Paired `EC_SYMR` (`EC_SYMR=1` both sides), compared on `pre[0]`, `pre[1]`, `n`,
50+`s`, `post_rng`; `pre[2]` and `cdf0` carry the known per-site constant offset
51+and the ICDF-mirroring convention.
52+
53+```text
54+reads 0..25791 IDENTICAL on both sides
55+read 25791 both: mi=(32,32) txb_skip, pre=(15655,42168,·) n=2 s=1 post_rng=41660
56+read 25792 ORACLE: decodeframe.c:1348 pre=(4399,32768,0) <- range-coder init: frame 0 ENDED
57+read 25792 OURS: mi=(32,32) txb_skip pre=(15655,41660,·) n=2 s=1 post_rng=41152
58+... reads 25792..25831 OURS ONLY, 40 extra
59+```
60+
61+Ours total 41 381 reads, the oracle 106 820. With the +40 offset the two sides
62+re-lock for **3 619 reads** (`oracle[k-40] == ours[k]` on all five compared
63+fields), then fork at oracle 29 411 / ours 29 451.
64+
65+**The owning walk, named.** Every one of the 40 is `tag=all_zero side=4` — the
66+plane-major 4x4 chroma unit read of `fn decode_rect_split`'s
67+`else if lossless(fctx)` arm. Env-gated `EC_CENSUS_UNIT` gives the plane split
68+directly, and `EC_ECDUMP_IN` gives the per-unit geometry:
69+
70+```text
71+frame 0, our last block: 48 units plane 0 | 32 units plane 1 | 32 units plane 2
72+frame 0, oracle mi=(32,32): plane 0 bc 0..11 br 0..3 (48 units)
73+ plane 1 bc 0..5 br 0..1 (12 units)
74+ plane 2 bc 0..5 br 0..1 (12 units) = 72 total
75+```
76+
77+**48 - 12 = 20 phantom units per plane, x2 planes = 40.** The arithmetic is
78+exact, not fitted.
79+
80+**Which block, and how big.** A temporary env-gated rung inside
81+`decode_rect_split` (added, measured, removed — not in the tree) printed the
82+walk's own inputs:
83+
84+```text
85+EC_OFFTILE rectsplit mi=(32,32) px=(128,128) bw=64 bh=32 cw=32 ch=16 cpx=64 cpy=64
86+ tx=4x4 tw=176 th=144 utw=88 uth=72
87+```
88+
89+`176x144` frame, `mi=(32,32)` = pixel (128,128): the bottom-right superblock is
90+the **48x16 sliver** the brief names, but the block coded there is
91+`bw=64 bh=32` (a partition size that overhangs), so its chroma plane block is
92+`cw=32 ch=16` at origin `cpx=64 cpy=64` — while the chroma plane is only
93+**88x72**. The walk therefore counted `cw_n = 32/4 = 8`, `ch_n = 16/4 = 4` and
94+emitted 8x4 units per plane where only **6x2** exist.
95+
96+## 3. What libaom does instead, and why the bit freezes
97+
98+`av1_common_int.h:1565`:
99+
100+```c
101+static inline int max_block_wide(const MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane) {
102+ int max_blocks_wide = block_size_wide[bsize];
103+ if (xd->mb_to_right_edge < 0) {
104+ const struct macroblockd_plane *const pd = &xd->plane[plane];
105+ max_blocks_wide += xd->mb_to_right_edge >> (3 + pd->subsampling_x);
106+ }
107+ return max_blocks_wide >> MI_SIZE_LOG2;
108+}
109+```
110+
111+Two things matter and both were missing:
112+
113+1. **It is per PLANE.** `pd->subsampling_x` is the PLANE's subsampling, so the
114+ bound is in chroma pixels. Ours had no chroma-plane bound at all.
115+2. **It is applied per unit.** `av1_foreach_transformed_block_in_plane`
116+ (`decodeframe.c:1124-1125`) drops the unit:
117+ `if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;`
118+
119+`decode_rect_split`'s **luma** walk already carries that clip — the
120+`tu_px >= y.true_width || tu_py >= y.true_height` guard lane-hgkf r1 added — and
121+it is why our 48 luma units are already correct. The **lossless chroma** walk
122+two hundred lines below it did not, which is the whole defect: the same
123+function, the same rule, one plane covered.
124+
125+**Why the bit position freezes.** The 40 units are beyond the tile's coded
126+extent. `read_golomb` (`decode.rs:7989-8018`) counts its unary prefix with
127+`dec.literal(1)`, and an exhausted `SymbolDecoder` returns 0 forever, so the
128+tail runs past the `length > 20` cap and the walk desyncs out of a tile with no
129+data left. Measured on the frozen region: `bit == post_bit == 36288` on all 40,
130+`range` decaying ~509 per read (`41660 -> 41152 -> 40644 -> …`). The oracle's own
131+frozen-region reads (`bit == post_bit == 19908`, 62 of them) are the same
132+phenomenon at the tail of the last real block — the difference is **how many**
133+phantom units each side emits after its own last real one.
134+
135+## 4. The fix
136+
137+```rust
138+// decode_rect_split, else-if lossless(fctx) chroma arm, inside the cu_row/cu_col loop
139+if cpx + cu_col * 4 >= u.true_width || cpy + cu_row * 4 >= u.true_height {
140+ hit!(RECT_SPLIT_LOSSLESS_CHROMA_OFFTILE_HITS);
141+ continue;
142+}
143+```
144+
145+the exact chroma twin of the luma guard already 380 lines above it in the same
146+function, using the chroma plane's own `true_width`/`true_height` (88x72 here)
147+exactly as libaom's `max_block_wide(xd, plane_bsize, /*plane=*/1)` does.
148+
149+**It is not the tile loop.** `decode_tile`'s `sb_visit_order` walk sets
150+`set_tile_origin` per tile correctly and never appears in the divergence: the
151+phantom units are stamped `mi=(32,32)`, which is inside the tile, and the tile's
152+own `mi_col1 * 4` bound is what `sb_r1`/`sb_c1` already derive. The block
153+footprint, not the tile, was the wrong extent. Measured, not inferred: with the
154+clip in place the tile walk's `sb_c1`/`sb_r1` are unchanged and the ladder
155+divergence simply moves.
156+
157+**Result on the paired ladder:**
158+
159+```text
160+ before after
161+first mismatch read 25792 29411
162+reads 0..N identical 0..25791 0..29410 (frame 0 FULLY bit-identical)
163+extra all_zero reads 40 (ours 25792..25831) 0
164+```
165+
166+Frame 0 now consumes **2373** transform units against the oracle's own
167+`EC_ECDUMP_IN` census of **2373** for the same bytes (base: 2413).
168+
169+## 5. The refusal: what this commit does and does not fix
170+
171+Stated plainly because it is the acceptance question.
172+
173+* **This walk is fixed and the 40 reads are accounted for.** Frame 0 is
174+ bit-identical to the oracle for all 25 792 reads and its unit census matches.
175+* **The cell still refuses at this commit**, because a **second, independent**
176+ defect now owns the first divergence — read 29411, oracle `mi=(9,14)`
177+ `decodemv.c:1036 -> decodetxb.c:158`, ours `mi=(8,12)` reading a different
178+ CDF row (`cdf0` 20675 vs 22401) off the **identical** pre-state
179+ `(41839, 52168)`. That is the var-tx/`lossless`-conjunct class, i.e. the
180+ `decode.rs:48259` / `:27140` gates **Agent05-5 owns**, and it is out of my scope.
181+* **The two fixes compose and close the cell.** Measured in a scratch worktree at
182+ Agent25-3's `658d37fa` with this patch applied on top:
183+
184+ ```text
185+ mix_176x144_6.obu OK: 6 frames decoded, 176x144 (base: REFUSED)
186+ mix_352x288_6.obu OK: 6 frames decoded, 352x288 (base: REFUSED)
187+ both, byte-for-byte against aomdec --rawvideo: cmp: IDENTICAL
188+ 228096 bytes (176x144) and 912384 bytes (352x288)
189+ ```
190+
191+ **CORRECTION (after Agent05-5's counter-measurement).** An earlier draft of this
192+ report claimed that both fixes applied together leave `mix_640x480_5/6`
193+ decoding. **That was wrong — I had measured 640x480 only against MY tree, not
194+ against the combination, and extrapolated.** Re-measured on the combined
195+ scratch binary (`658d37fa` + this patch):
196+
197+ ```text
198+ mix_640x480_5.obu REFUSED: unsupported: AV1 tile (a Golomb tail longer than this decoder reads)
199+ mix_640x480_6.obu REFUSED: unsupported: AV1 tile (a Golomb tail longer than this decoder reads)
200+ ```
201+
202+ Agent05-5 measured the same and, further, that my clip changes nothing there —
203+ the per-frame red byte counts are identical with and without it. This
204+ patch touches no var-tx gate, so that is the expected answer; it just is not
205+ the answer I had claimed. The 640x480 refusal with both applied is Agent05-5's
206+ §5 regression, unowned by this lane.
207+
208+* **I do not claim this commit removes the refusal on its own.** It removes the
209+ off-tile walk; the remaining refusal belongs to Agent05-5's lane, and I did not
210+ take that route as instructed.
211+
212+## 6. Regression control, gate, fixture, mutation
213+
214+**Regression controls — all at this commit, `decode_probe`:**
215+
216+"Decodes" below means *not refused* — NOT that the pixels are right. It is stated
217+that way because on 640x480 the two are very different facts, and conflating
218+them is what produced the wrong claim in §5.
219+
220+| cell | at base `6bb66a4a` | with this fix | pixels? |
221+|---|---|---|---|
222+| `mix_640x480_5.obu` | decodes 5/5 | **decodes 5/5, unchanged** | **RED on every inter frame** — see below |
223+| `mix_640x480_6.obu` | decodes 6/6 | **decodes 6/6, unchanged** | red, same class |
224+| `mix_320x240_6.obu` | decodes 6/6 | **decodes 6/6** | not measured by this lane |
225+| `mix_176x144_5.obu` | decodes 5/5 | **decodes 5/5** | not measured by this lane |
226+| `c_mix5.obu` (peer's 256x128 red cell) | decodes, red on pixels | **untouched by this patch** | red at base |
227+
228+**640x480 does not decode CORRECTLY at base, and saying it "decodes" without
229+that caveat is misleading.** Measured here on my own tree (decode-order dumps vs
230+the oracle's `EC_AV1_FINAL_DUMP`, `mix_640x480_5.obu`, 460 800 B/frame):
231+
232+```text
233+f0 EXACT
234+f1 352066 bytes differ
235+f2 414286
236+f3 313795
237+f4 399471
238+```
239+
240+i.e. roughly 80 % of every inter frame is already wrong before any change. A
241+refusal there replaces silent corruption with a loud failure; it does not
242+remove a working decode. Agent05-5 measured the identical counts, and also that
243+they are **unchanged by this patch** — which is the point: this walk is inert
244+on that cell.
245+
246+**Fixture** `crates/ec-av1/fixtures/mix176_offtile_chroma_clip.obu`, **4 581 B**,
247+FNV-1a64 `0x5e31be5efc9c3c1d`. It is frame 0 of `mix_176x144_6.obu` — the
248+temporal delimiter, sequence header and frame-0 OBU, nothing else — so the gate
249+decodes cleanly in isolation instead of depending on a stream that a second
250+unfixed defect refuses. Full-stream provenance (bytes + sha256) is in the gate's
251+doc comment.
252+
253+**Gate** `stream::tests::a_420_lossless_rect_chroma_walk_is_bounded_by_the_chroma_plane`:
254+pinned fixture, 8-bit header asserted, clean decode, off-tile counter nonzero
255+(non-vacuity), **unit count == 2373 == the oracle's own `EC_ECDUMP_IN`
256+census**, then `decode_all_frames_vs_oracle`.
257+
258+```text
259+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1offtile EC_NOMEMGUARD=1 \
260+ cargo test -p ec-av1 --lib a_420_lossless_rect_chroma_walk_is_bounded_by_the_chroma_plane
261+
262+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 803 filtered out; finished in 0.03s
263+```
264+
265+**Mutation proof** — the clip surgically reverted in the working tree, gate re-run:
266+
267+```text
268+(a) width half disabled (`if false && cpx + cu_col*4 >= u.true_width || ...`)
269+ paniced at crates/ec-av1/src/stream.rs:52195:
270+ frame 0 walked 2381 transform units, the oracle's own EC_ECDUMP_IN census for
271+ these bytes is 2373
272+ test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 803 filtered out
273+
274+(b) clip removed outright
275+ paniced at crates/ec-av1/src/stream.rs:52186:
276+ no lossless rect chroma unit fell outside the chroma plane -- the corrected
277+ walk never ran, so this gate is measuring the unclipped one
278+ (class gate-blind-to-feature)
279+ test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 803 filtered out
280+```
281+
282+2381 and 2413 are both measured on real builds (§2, and the clean
283+`658d37fa`-only binary reads 2413), so (a)'s number is not a fitted constant.
284+
285+**Scoped regression** — exact command and output in §10.
286+
287+## 7. Class sweep
288+
289+**Source.** Every chroma unit walk in `decode.rs` that derives a unit count from
290+the block footprint, each re-derived against `max_block_wide/high`:
291+
292+| site | walk | verdict |
293+|---|---|---|
294+| `decode_rect_split` luma, `for tu_row in 0..bh/tx_h { for tu_col in 0..bw/tx_w }` | reads coefficients | **carries the clip** (`tu_px >= y.true_width`), correct |
295+| `decode_rect_split` **lossless chroma, `for plane_idx 1..=2 { for cu_row in 0..ch_n { for cu_col in 0..cw_n } }`** | reads coefficients | **this lane's defect — now clipped** |
296+| `decode_rect_split` `m.skip` arm, `for cu_row in 0..chroma_block_h/uh` | **no reads** (writes a zero grid) | not entropy-relevant |
297+| `decode_rect_split` `chroma_tiled` arm, `(nw, nh) = (chroma_block_w/uw, chroma_block_h/uh)` | reads coefficients | instrumented, **0 hits** (§7b) |
298+| `decode_block_rect64`, `(nw, nh) = (chroma_w/uw, chroma_h/uh)` | reads coefficients | instrumented, **0 hits** (§7b) — Agent14-7's region, probed read-only, not edited |
299+| `rect_inter_chroma`, `(nx, ny) = (write_chroma_w/uw, write_chroma_h/uh)` | inter chroma rect walk | not a rect/lossless intra arm; no overhang witness reachable (§7b) |
300+
301+**Streams.** The two non-fixed coefficient-reading walks above were temporarily
302+instrumented with the same `>= u.true_width / u.true_height` test and swept
303+over:
304+
305+* the **whole committed fixture corpus** (`crates/ec-av1/fixtures/*.obu`, every
306+ file the crate ships) — **0 hits**;
307+* **18 generated edge-overhang cells** — `testsrc2` at 178x146, 182x150, 190x158,
308+ 200x180, 176x142, 144x176, 210x134, 128x128, 320x244, each at
309+ `--cq-level=0 --aq-mode=1` and `--lossless=1` (the two arms that put a
310+ lossless strip at a frame edge) — **0 hits**, and all 18 decode byte-exact
311+ against the oracle;
312+* the 12 `mix_*` cells plus `c_mix5.obu` — **0 hits**.
313+
314+**This is a measured negative on the corpus and on every edge geometry I could
315+generate, not a proof of unreachability.** The instrumentation has been removed;
316+`grep -c EC_OFFTILE crates/ec-av1/src/decode.rs` is `0`.
317+
318+## 8. Hunk scope
319+
320+* `crates/ec-av1/src/decode.rs` — **2 logic lines** (the clip + its
321+ `hit!`), plus the counter, its two accessors, and `census_unit_n` /
322+ `reset_census_unit_n`.
323+* `crates/ec-av1/src/stream.rs` — the gate, no production code.
324+* `crates/ec-av1/fixtures/mix176_offtile_chroma_clip.obu` — the pinned fixture.
325+* **Not touched:** `decode.rs:48259`, `decode.rs:27140`, `decode_block_rect64`
326+ (`19634-20315`, Agent14-7's), and the var-tx `lossless` derivation. Peer scope
327+ was announced over IRC before the first edit and held throughout.
328+* The primary checkout was never edited; `git status` there is clean apart from
329+ peers' own branches.
330+
331+## 9. What is NOT measured
332+
333+* **This commit does not remove the refusal on `mix_176x144_6.obu` /
334+ `mix_352x288_6.obu` by itself** (§5). It removes the off-tile walk and moves
335+ the first divergence from 25792 to 29411. Closing the cell needs Agent05-5's
336+ conjunct, and the composition is measured but not landed by me.
337+* **The 640x480 `658d37fa` regression is untouched by this lane and not
338+ diagnosed here.** With both fixes applied 640x480 **REFUSES** (Agent05-5 measured
339+ the same); my patch changes nothing on that cell. Agent05-5 further localises the
340+ 640x480 residual to a **third** defect — a missing TXFM_CONTEXT band write
341+ above mi column 110 (`decode.rs:47264`, forcing `ctx=1` there makes 640x480
342+ bit-identical over all 457 907 reads), class
343+ `context-band-not-published`, which is theirs to carry and is not mine. My own
344+ measurement is only the "red at base, unchanged by this patch" half of that;
345+ the `ctx` attribution is Agent05-5's and I did not verify it.
346+* **The class sweep is a corpus + generated-cells negative**, §7. A wider sweep
347+ (10/12-bit, 4:4:4 edge cells, screen content) was not run; §7's instrumented
348+ walks are the ones a future sweep should re-arm.
349+* **Frame 0's pixels are byte-exact at base too**, so nothing here is a pixel
350+ claim: the 40 phantom reads all carry `all_zero` and consume no data. The
351+ gated number is the unit census, not the picture.
352+* The `mix_352x288_6.obu` ladder was not paired read-by-read (its first
353+ divergence is the same var-tx site); the cell's byte-exactness with both
354+ fixes is measured, its per-read attribution is not.
355+
356+## 10. Regression result
357+
358+Exact command, run in the lane worktree at the fix commit:
359+
360+```text
361+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1offtile EC_NOMEMGUARD=1 \
362+ cargo test -p ec-av1 --lib -- 420 444 422 lossless stream \
363+ --skip bitrate_target_lands_within_5_percent_over_48_frames
364+```
365+
366+```text
367+test result: ok. 375 passed; 0 failed; 7 ignored; 0 measured; 422 filtered out;
368+ finished in 1970.18s
369+```
370+
371+`375 / 0 / 7 / 422`. The two prior reports that ran this exact scope on
372+`32d944bf` record `373 / 0 / 7 / 422`, so this is `+2`: one of them is this
373+lane's new gate and the other is a test that landed on `6bb66a4a` after those
374+runs. The load-bearing part is **0 failed**. The gate itself is in this run
375+(`a_420_lossless_rect_chroma_walk_is_bounded_by_the_chroma_plane ... ok`).
376+
377+## 11. Fix-now | deferred | accepted
378+
379+* **fix-now:** nothing outstanding in the tree. The clip, the counter, the gate
380+ and the fixture are all in this commit.
381+* **deferred(unblock: Agent05-5 landing the var-tx `lossless` conjunct):** the
382+ `mix_176x144_6` / `mix_352x288_6` refusal. §5 measures that the two fixes
383+ compose and make both cells byte-exact against the oracle; neither alone does.
384+* **deferred(unblock: a >= 640x480 mixed-lossless + altref committed fixture):**
385+ §5's composition claim is a hand-measured A/B, and the `658d37fa` regression
386+ it would have caught has no gate. That is a fixture-coverage gap, not this
387+ lane's fix.
388+* **accepted:** the two non-fixed chroma walks (§7) stay as they are on this
389+ corpus. They are the same class and one env-gated probe line away from a
390+ witness; the probe has been removed and the negative is recorded rather than
391+ papered over with an assertion.
392+
393+## 12. Reproduction
394+
395+```bash
396+W=~/.cache/wt/av1offtile
397+P=$HOME/.cache/cargo-target-av1offtile/debug/examples/decode_probe
398+D=~/.cache/aom-oracle/build
399+F=$W/crates/ec-av1/fixtures/mix176_offtile_chroma_clip.obu
400+
401+# the gate
402+(cd $W && CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1offtile EC_NOMEMGUARD=1 \
403+ cargo test -p ec-av1 --lib a_420_lossless_rect_chroma_walk_is_bounded_by_the_chroma_plane)
404+
405+# the red-before: 2413 units against the oracle's 2373
406+EC_NOMEMGUARD=1 EC_ECDUMP_IN=1 $HOME/.cache/cargo-target-av1offtile-xb/debug/examples/decode_probe \
407+ $F 2>&1 >/dev/null | grep -c ECDUMP_IN # 2413
408+EC_ECDUMP_IN=1 $D/aomdec --codec=av1 -o /dev/null $F 2>&1 >/dev/null | grep -c ECDUMP_IN # 2373
409+EC_NOMEMGUARD=1 EC_ECDUMP_IN=1 $P $F 2>&1 >/dev/null | grep -c ECDUMP_IN # 2373
410+
411+# the 40 extra reads, before and after, on the full 6-frame stream
412+EC_NOMEMGUARD=1 EC_SYMR=1 $P /tmp/g320/sweep/mix_176x144_6.obu 2>our.symr >/dev/null
413+EC_SYMR=1 $D/aomdec --codec=av1 -o /dev/null /tmp/g320/sweep/mix_176x144_6.obu 2>orc.symr >/dev/null
414+# base: first mismatch at 25792, ours 25792..25831 extra; after: first mismatch at 29411
415+```