From f2fb6dd624695e5abd6cbed165854327bbfd6289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 4 Oct 2026 13:24:22 +0300 Subject: [PATCH] av1: the 4:2:2 mu-chunk walk's chroma dc-sign context read luma cells The compound 128-root mu-chunk walk (and its single-reference and IntraBC twins) gathered each chroma unit's coefficient context with the plain rect gather. At ss (1, 0) one CHROMA column spans two luma mi columns, so that gather sums the unit's above dc sign over 16 luma mi cells where libaom's get_txb_ctx_general reads txb_w_unit = 8 CHROMA cells. dc_sign_ctx sees only the vote's signum, so the doubled above vote flips its row exactly when above and left cancel. Measured on 422_muchunk_compound_128root.obu, decode frame 2, the last mu chunk (cr 1, cc 1) of the walk: our V unit at chroma (bc 8, br 16) read dc_sign_cdf[1] where the oracle read row 0 -- same sign value, different CDF row, so the entropy state forked there. It is the first wrong symbol of the stream, and the fix makes all 7 decode-order frames byte-exact against the instrumented aomdec and all 6 shown frames byte-exact against ffmpeg. Route that gather through the 4:2:2 pair rule (around_mi_422_chroma) when ss is (1, 0), the plain rect gather everywhere else: 4:2:0 and 4:4:4 keep it verbatim and are unaffected (at 4:2:0 both extents double, so the signum never moved). Gate: a_422_muchunk_compound_128root_pinned_stream_reaches_its_unit_walk gains the exactness half the diagnostic lane handed over -- pinned fnv1a64 of shown frame 2's V plane (0xa0e58bf4207b29ba, pre-fix 0xc4e7fdb873433479) and of shown frame 0's control plane, plus the decode-order oracle compare. Restoring the square gather reds the pinned hash with exactly the pre-fix value. the_intrabc_128rect_chroma_chunk_walk_stays_per_axis now also pins that walk's 4:2:2 routing: its chroma chunk walk is reachable at ss (1, 0) on 422_intrabc_sb128_strip.obu (EC_IBC128_BANDS prints), but no committed fixture's votes cancel there, so the source scan -- not a pixel compare -- is what stops the routing being reverted. Residue named in lanes/av1muchunk422sym.report.md: the chroma rect gathers of decode_block_128rect, decode_intra_sub8_leaf and decode_inter_sub8_rect2 are the same class but different walks, and need their own reachability measurement. --- crates/ec-av1/src/decode.rs | 120 +++++++++++++++----- crates/ec-av1/src/stream.rs | 123 +++++++++++++++++---- lanes/av1muchunk422sym.report.md | 181 +++++++++++++++++++++++++++++++ 3 files changed, 372 insertions(+), 52 deletions(-) create mode 100644 lanes/av1muchunk422sym.report.md diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index fa25d2f6..b790da3a 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -15431,8 +15431,18 @@ fn decode_intrabc_128rect( ); // Per unit, AFTER the earlier units' stamps: this // unit's coefficient context must see them. - let cu_around = - neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h); + // + // lane-av1muchunk422sym: same 4:2:2 pair rule as + // `decode_inter_block`'s mu-chunk walk -- at ss + // (1, 0) one CHROMA column spans two luma mi + // columns, so the plain rect gather doubles the + // above dc vote and flips `dc_sign_ctx` whenever + // above and left cancel. + let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { + neighbours.around_mi_422_chroma(unit_mi, unit_luma_w, unit_luma_h) + } else { + neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h) + }; if crate::envflags::env_flag!("EC_ECDUMP") { for p in 1..3 { let ab: Vec = (0..unit_luma_w / MI) @@ -43841,14 +43851,16 @@ fn decode_inter_block( // The unit's own footprint on the LUMA mi // grid, per axis (32 << ss) px: 64x64 (16x16 // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4, - // 64x32 (16x8 mi) at 4:2:2. `around_mi_rect` - // reads and - // `record_mi_chroma` stamps span exactly the - // unit's own cells -- `get_txb_ctx` reads the - // 8 context cells of the TX_32X32 itself, and - // `av1_set_entropy_contexts` memsets the same - // 8, so the unit over never sees this unit's - // state and the unit below always does. + // 64x32 (16x8 mi) at 4:2:2. The context + // gather and `record_mi_chroma`'s stamp span + // exactly the unit's own cells -- `get_txb_ctx` + // reads the 8 context cells of the TX_32X32 + // itself, and `av1_set_entropy_contexts` memsets + // the same 8, so the unit over never sees this + // unit's state and the unit below always does. + // At ss (1, 0) those 8 are CHROMA cells, so the + // gather routes through the 4:2:2 pair rule + // (lane-av1muchunk422sym, see the walk below). let unit_luma_w = cu_tx << ss_x(fctx); let unit_luma_h = cu_tx << ss_y(fctx); let cu_scan = default_scan(cu_tx); @@ -43923,11 +43935,36 @@ fn decode_inter_block( // units' stamps: this unit's // coefficient context must see // them. - let cu_around = neighbours.around_mi_rect( - unit_mi, - unit_luma_w, - unit_luma_h, - ); + // + // lane-av1muchunk422sym: at ss + // (1, 0) one CHROMA column spans + // two luma mi columns, so the plain + // rect gather sums this unit's + // above dc sign TWICE where + // libaom's `get_txb_ctx_general` + // reads `txb_w_unit` CHROMA cells -- + // one per column. `dc_sign_ctx` + // only sees the vote's signum, so + // the doubled vote flips the row + // exactly when above and left + // cancel; `around_mi_422_chroma` + // samples every second above cell, + // which IS libaom's sum. Same guard + // as the intra twin (13169) and the + // block-8 arm (19810). + let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { + neighbours.around_mi_422_chroma( + unit_mi, + unit_luma_w, + unit_luma_h, + ) + } else { + neighbours.around_mi_rect( + unit_mi, + unit_luma_w, + unit_luma_h, + ) + }; let (cu_x, cu_y) = ( cpx + cc * chunk_chroma_w + uc * cu_tx, cpy + cr * chunk_chroma_h + ur * cu_tx, @@ -45664,14 +45701,16 @@ fn decode_inter_block( // The unit's own footprint on the LUMA mi // grid, per axis (32 << ss) px: 64x64 (16x16 // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4, - // 64x32 (16x8 mi) at 4:2:2. `around_mi_rect` - // reads and - // `record_mi_chroma` stamps span exactly the - // unit's own cells -- `get_txb_ctx` reads the - // 8 context cells of the TX_32X32 itself, and - // `av1_set_entropy_contexts` memsets the same - // 8, so the unit over never sees this unit's - // state and the unit below always does. + // 64x32 (16x8 mi) at 4:2:2. The context + // gather and `record_mi_chroma`'s stamp span + // exactly the unit's own cells -- `get_txb_ctx` + // reads the 8 context cells of the TX_32X32 + // itself, and `av1_set_entropy_contexts` memsets + // the same 8, so the unit over never sees this + // unit's state and the unit below always does. + // At ss (1, 0) those 8 are CHROMA cells, so the + // gather routes through the 4:2:2 pair rule + // (lane-av1muchunk422sym, see the walk below). let unit_luma_w = cu_tx << ss_x(fctx); let unit_luma_h = cu_tx << ss_y(fctx); let cu_scan = default_scan(cu_tx); @@ -45726,11 +45765,36 @@ fn decode_inter_block( // units' stamps: this unit's // coefficient context must see // them. - let cu_around = neighbours.around_mi_rect( - unit_mi, - unit_luma_w, - unit_luma_h, - ); + // + // lane-av1muchunk422sym: at ss + // (1, 0) one CHROMA column spans + // two luma mi columns, so the plain + // rect gather sums this unit's + // above dc sign TWICE where + // libaom's `get_txb_ctx_general` + // reads `txb_w_unit` CHROMA cells -- + // one per column. `dc_sign_ctx` + // only sees the vote's signum, so + // the doubled vote flips the row + // exactly when above and left + // cancel; `around_mi_422_chroma` + // samples every second above cell, + // which IS libaom's sum. Same guard + // as the intra twin (13169) and the + // block-8 arm (19810). + let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { + neighbours.around_mi_422_chroma( + unit_mi, + unit_luma_w, + unit_luma_h, + ) + } else { + neighbours.around_mi_rect( + unit_mi, + unit_luma_w, + unit_luma_h, + ) + }; let (cu_x, cu_y) = ( cpx + cc * chunk_chroma_w + uc * cu_tx, cpy + cr * chunk_chroma_h + ur * cu_tx, diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 42b06a45..6e1a9775 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -3624,6 +3624,27 @@ pub(crate) mod tests { body.matches(name).count() ); } + // lane-av1muchunk422sym: the CHROMA gather of that same walk must take + // the 4:2:2 pair rule, exactly as `decode_inter_block`'s mu-chunk walk + // does (one chroma column per pair of luma mi cells; the plain rect + // gather doubles the above dc vote and flips `dc_sign_ctx` wherever + // above and left cancel). Reachability is measured: the walk fires at + // ss (1, 0) on `422_intrabc_sb128_strip.obu` (`EC_IBC128_BANDS` + // prints); that fixture's own votes do not cancel, so THIS gate -- not + // a pixel compare -- is what stops the routing being reverted. + for name in [ + "let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {", + "neighbours.around_mi_422_chroma(", + ] { + assert_eq!( + body.matches(name).count(), + 1, + "{NAME}: `{name}` must appear exactly once in \ + decode_intrabc_128rect's chroma chunk walk, found {} -- the \ + gather has fallen back to the square per-mi rule", + body.matches(name).count() + ); + } // The replay's own unit luma span is the lossless/lossy `cu << ss` form // (site 2 spells it separately from the read walk's `cu_tx << ss`). for name in [ @@ -42895,22 +42916,19 @@ exit 0 /// shares this exact source text and is routed out of the counter by /// `is_compound`. /// - /// **7 of the 8 streams this lane generated DIVERGE from ffmpeg; only + /// **7 of the 8 streams this lane generated DIVERGED from ffmpeg; only /// `i6_grad128_iis` (the intra-in-inter fixture, pinned in the twin test - /// below) is byte-exact. This compound pin is therefore the COUNTER - /// WITNESS, not an exactness witness** -- it asserts the walk ran, and - /// nothing about pixels. The divergence on this tip is Y and U exact, V - /// differing on a fixed column band (2063/8192, 2138/8192, 2105/8192 and - /// 1988/8192 V samples on shown frames 1-4, first at V row 60 col 36), the - /// same shape on all four compound streams this lane produced, while the - /// committed 4:2:2 128-root SINGLE-reference stream (`422_sb128_3f.obu`) - /// and the committed compound-warp stream whose blocks are all <= 64 - /// (`422_residual_compound_warp_16f.obu`) both stay exact against the same - /// oracle -- so it tracks the 128-root COMPOUND path these counters name. - /// It is a NEW defect and fixing the walk is explicitly out of this lane's - /// charter. When a fix lane lands, add the oracle compare to this test; the - /// counter half already stops this fixture silently ceasing to reach the - /// walk it was pinned for. + /// below) was byte-exact.** lane-av1muchunk422sym has since fixed this + /// pin's stream: the compound mu-chunk walk gathered its CHROMA + /// coefficient context with the plain rect rule, which at ss (1, 0) counts + /// one chroma column twice in the above vote (see the walk's own comment). + /// **The stream is now byte-exact against the instrumented aomdec over all + /// 7 decode-order frames (6 shown + 1 hidden alt-ref)**, so this test + /// carries both halves: the counter witness that the walk ran AND the + /// exactness witness. The pinned V-plane hashes run without an oracle; + /// `decode_all_frames_vs_oracle` adds the decode-order compare when one is + /// present. The counter half still stops this fixture silently ceasing to + /// reach the walk it was pinned for. /// /// Recipe (byte-reproducible; whole aomenc argv): /// ```text @@ -42932,6 +42950,17 @@ exit 0 const LEN: usize = 895; const FNV: u64 = 0xfb28_f9a7_cf23_9897; const MIN_UNITS: usize = 32; + // lane-av1muchunk422sym: shown frame 2's V plane byte-for-byte (it is + // the first intrinsically wrong frame; the pre-fix square gather put + // 2138 of these 8192 samples off by up to 4), and shown frame 0's as + // the unaffected control. 0xa0e5_8bf4_207b_29ba is the ffmpeg/aomdec + // exact plane. + const SHOWN_F2_V_FNV: u64 = 0xa0e5_8bf4_207b_29ba; + const SHOWN_F0_V_FNV: u64 = 0xcc5e_3291_1915_9024; + /// Chroma (36, 60) of shown frame 2 -- the FIRST sample that moved, + /// `60 * 64 + 36`. The pre-fix square gather read 113, the oracle 112. + const FIRST_WRONG_V: usize = 3876; + const SHOWN_F2_V_AT_FIRST_WRONG: u16 = 112; let _gate_lock = lock_gate_counters(); let stream = read_pinned_muchunk_fixture(FILE, LEN, FNV, NAME); assert_eq!( @@ -42943,9 +42972,9 @@ exit 0 crate::decode::mu_chunk_compound_units(), crate::decode::mu_chunk_intra_in_inter_units(), ); - let frames = crate::stream::decode_stream(&stream) - .unwrap_or_else(|e| panic!("{NAME}: {FILE} no longer decodes cleanly: {e}")) - .len(); + let shown = crate::stream::decode_stream(&stream) + .unwrap_or_else(|e| panic!("{NAME}: {FILE} no longer decodes cleanly: {e}")); + let frames = shown.len(); let (compound, intra) = ( crate::decode::mu_chunk_compound_units() - before.0, crate::decode::mu_chunk_intra_in_inter_units() - before.1, @@ -42961,13 +42990,59 @@ exit 0 "{NAME}: {FILE} also ran the intra-in-inter walk ({intra} units) -- the two fixtures \ no longer separate the cells" ); - // DELIBERATELY NO ORACLE COMPARE: 7 of the 8 streams this lane generated - // diverge and this fixture is one of them. This test is the counter - // witness, not an exactness witness -- see the doc comment. - eprintln!( - "{NAME}: {FILE} compound_units={compound} intra_in_inter_units={intra} -- counter \ - witness, pixels NOT asserted (this stream is measured DIVERGENT)" + // lane-av1muchunk422sym: the EXACTNESS half the diagnostic lane handed + // over ("when a fix lane lands, add the oracle compare to this test"). + // The fix routes this walk's CHROMA context gather through the 4:2:2 + // pair rule (`around_mi_422_chroma`): at ss (1, 0) one chroma column + // spans two luma mi columns, so the plain rect gather summed the unit's + // above dc sign twice and `dc_sign_ctx`'s signum flipped whenever above + // and left cancelled. The first wrong symbol was the DC SIGN of the V + // unit at chunk (1, 1) of decode frame 2 -- ours read + // `dc_sign_cdf[1]`, the oracle row 0. + // + // The pinned half below needs NO oracle and is therefore the one that + // cannot silently skip: shown frame 2 (the first intrinsically wrong + // frame) is asserted sample-for-sample on its V plane. Frame 0's is + // asserted too, as the unaffected control that fails if the gather is + // "fixed" past its own cell. + assert_eq!( + shown[0].v.len(), + 64 * 128, + "{NAME}: {FILE} is no longer 4:2:2 -- the V plane shape moved" ); + assert_eq!( + fnv1a64(&shown[2].v.iter().map(|&s| s as u8).collect::>()), + SHOWN_F2_V_FNV, + "{NAME}: {FILE} shown frame 2's V plane moved -- the compound mu-chunk walk's 4:2:2 \ + chroma context gather is wrong again (first sample to move is chroma (36, 60), index \ + 3876, expected {})", + SHOWN_F2_V_AT_FIRST_WRONG + ); + assert_eq!( + shown[2].v[FIRST_WRONG_V], SHOWN_F2_V_AT_FIRST_WRONG, + "{NAME}: {FILE} shown frame 2 V[3876] (chroma (36, 60)) is {} -- the pre-fix square \ + gather read 113 here", + shown[2].v[FIRST_WRONG_V] + ); + assert_eq!( + fnv1a64(&shown[0].v.iter().map(|&s| s as u8).collect::>()), + SHOWN_F0_V_FNV, + "{NAME}: {FILE} shown frame 0's V plane moved -- the 4:2:2 routing changed a frame it \ + must not touch" + ); + if aomdec_available(NAME) { + let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, NAME); + assert_eq!(decoded, 7, "{NAME}: {FILE} decode-order frame count"); + eprintln!( + "{NAME}: {FILE} byte-exact over {decoded} decode-order frame(s) ({hidden} hidden), \ + compound_units={compound} intra_in_inter_units={intra}" + ); + } else { + eprintln!( + "{NAME}: {FILE} compound_units={compound} intra_in_inter_units={intra} -- the \ + decode-order oracle compare above did NOT run (no aomdec)" + ); + } } /// lane-av1muchunk422b: the **intra-in-inter** `side > 64` mu-chunk walk -- diff --git a/lanes/av1muchunk422sym.report.md b/lanes/av1muchunk422sym.report.md new file mode 100644 index 00000000..7cf0764e --- /dev/null +++ b/lanes/av1muchunk422sym.report.md @@ -0,0 +1,181 @@ +# lane-av1muchunk422sym — the first wrong SYMBOL of `422_muchunk_compound_128root.obu` + +Base: `main` @ `df681fb7`. Branch: `lane/av1muchunk422sym`. + +**Verdict: the first wrong symbol is the DC SIGN of the V-plane unit at mu chunk +`(cr = 1, cc = 1)` of decode frame 2 — the last unit pair of the compound +`side > 64` mu-chunk walk. The context was chosen by `Neighbours::around_mi_rect` +(`decode.rs` 10623) as called by that walk: at ss (1, 0) it reads the unit's +above dc vote over 16 LUMA mi cells where libaom's `get_txb_ctx_general` reads +`txb_w_unit` = 8 CHROMA cells, doubling the above vote and flipping +`dc_sign_ctx`'s signum. FIXED, GATED, MUTATION-PROVEN.** + +## 1. The first wrong symbol, measured not argued + +Paired our `EC_TRACE_COEFF` / `EC_ECDUMP_IN` / `EC_DCDUMP` ladders (decode frame +2, via `EC_TRACE_COEFF_FRAME=2`) against the instrumented oracle's +(`~/.cache/aom-oracle/build/aomdec`, `EC_TRACE_COEFF` + `EC_ECDUMP_IN` + +`EC_ECDUMP`), unit-for-unit, on `(tag, symbol value, rng)` — the ECIN `(value, +rng)` pair matched on every unit up to the fork (the oracle's third field is a +different bit-position convention, off by a constant). + +Every unit and every symbol agrees until: + +| | ours | oracle | +|---|---|---| +| unit | plane V, `bc=8 br=16 tx=3` (chunk `(1,1)`, mi `(16,16)`) | same | +| symbol | `tag=sign c=0` (the DC sign) | same | +| value | `sign=0` | `sign=0` | +| **context** | **`dc_sign_ctx = 1`** (`dc_sign_cdf[1]`) | **`dc_sign_ctx = 0`** (`dc_sign_cdf[0]`) | +| `rng` after | `62776` | `37548` | + +Both decoders read the SAME sign value from DIFFERENT CDF rows, so the entropy +state forks at that read. That is exactly the "same magnitudes, different +signs" the diagnostic lane measured in the dequantised grid, and it is why Y +and U (and every earlier chunk of V) stayed bit-exact. + +The choosing functions, bottom-up: + +* `decode_inter_block`'s compound mu-chunk walk, `decode.rs` 43927 (pre-fix): + `let cu_around = neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h);` +* `Neighbours::around_mi_rect`, `decode.rs` 10623 — sums `dc_vote` over + `unit_luma_w / MI = 64 / 4 = 16` above cells. +* `read_inter_plane`, `decode.rs` 39532 — `dc_sign_ctx(around.2)`. + +Measured at that unit (our `EC_DCDUMP mi=(16,16) plane=2 wh=(64,32)`): +`above` = 16 cells all `Some(true)` → `-16`; `left` = 8 cells all `Some(false)` +→ `+8`; vote `-8` → ctx 1. libaom's sum is one chroma cell per PAIR of luma mi +columns (ss_x 1): `-8 + 8 = 0` → ctx 0, which is the oracle's row. + +## 2. Why that gather is the 4:2:2 pair rule and not a geometry error + +`get_txb_ctx_general` (oracle `av1/common/txb_common.h`) walks +`tx_size_wide_unit[TX_32X32] = 8` cells of `pd->above_entropy_context`, which is +indexed in the CHROMA plane's own 4-px units (`av1_set_entropy_contexts` writes +`blk_col + k` for `k < txb_w_unit`). `decode_token_recon_block` enters the +chroma unit at `blk_col = col >> ss_x`, so those 8 cells are chroma columns +8..15 — 8 cells, not 16. Our single luma-mi-indexed array +(`record_mi_chroma` stamps the unit's whole 16-luma-mi-column span, both +columns of each chroma column carrying the same whole-unit dc sign) therefore +counts each above column twice. `around_mi_422_chroma` samples every second +above cell, which IS libaom's sum — the same rule the file already applies at +`decode.rs` 13169 / 19810 / 16699. + +The walk's ADDRESSING is not implicated (the diagnostic lane proved it); only +the context gather. + +## 3. Fix + +Route the mu-chunk chroma gather through the pair rule when ss (1, 0), luma and +every other subsampling shape keeping the plain rect gather verbatim: + +```rust +let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { + neighbours.around_mi_422_chroma(unit_mi, unit_luma_w, unit_luma_h) +} else { + neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h) +}; +``` + +Three source copies, all the same walk: + +1. `decode_inter_block` compound mu-chunk walk (`decode.rs` ~43927); +2. `decode_inter_block` single-reference twin (~45730) — same source text, + same rule; its own votes do not cancel on this fixture (decode frame 1 was + already exact), so it is a measured-reachable latent instance of the class; +3. `decode_intrabc_128rect`'s chroma chunk walk (~15435) — the IntraBC twin of + the same walk. Reachability MEASURED, not assumed: `EC_IBC128_BANDS` prints + at ss (1, 0) on the committed `422_intrabc_sb128_strip.obu` (96 lines). + That fixture's own votes do not cancel either, so no committed cell + discriminates the change; its source-scan gate + `the_intrabc_128rect_chroma_chunk_walk_stays_per_axis` now pins the routing + instead (`neighbours.around_mi_422_chroma(` and the guard literal, once + each), so it cannot be silently reverted. + +At 4:2:0 (ss 1/1) and 4:4:4 the guard is false and nothing changes; the +pre-existing 4:2:0 exactness is explained by the same arithmetic — there BOTH +extents double (`2a + 2l`), so the signum is untouched. + +## 4. Evidence + +`ffmpeg -i X.obu -pix_fmt yuv422p -f rawvideo` (6 shown frames), ours before vs +after, differing bytes per shown frame (Y / U / V): + +| frame | 0 | 1 | 2 | 3 | 4 | 5 | +|---|---|---|---|---|---|---| +| before | 0 | V 2063 | V 2138 | V 2105 | V 1988 | 0 | +| after | 0 | 0 | 0 | 0 | 0 | 0 | + +Instrumented aomdec `EC_AV1_FINAL_DUMP` in DECODE order (7 frames = 6 shown + 1 +hidden alt-ref), ours vs oracle, after the fix: **f0..f6 all EXACT**. + +## 5. Gate + mutation proof + +`a_422_muchunk_compound_128root_pinned_stream_reaches_its_unit_walk` now carries +BOTH halves (the diagnostic lane's hand-over: "when a fix lane lands, add the +oracle compare to this test"): + +* the counter half, untouched (compound units ≥ 32, intra-in-inter 0); +* an oracle-free pinned half that CANNOT silently skip: `fnv1a64` of shown + frame 2's V plane must be `0xa0e58bf4207b29ba` (pre-fix + `0xc4e7fdb873433479`) and `V[3876]` (chroma (36, 60), the first sample the + diagnostic lane measured) must be `112` (pre-fix 113); shown frame 0's V + plane is pinned as the unaffected control (`0xcc5e329119159024`); +* `decode_all_frames_vs_oracle` for the 7-decode-order-frame compare when an + oracle is present. + +Red-before, measured: restoring the square gather at the COMPOUND site only +(`git`-restorable edit) and re-running produced + +```text +panicked at crates/ec-av1/src/stream.rs:42992: + 422_muchunk_compound_128root.obu shown frame 2's V plane moved ... + left: 14188588119703630969 right: 11593826696368433594 +``` + +`14188588119703630969 = 0xc4e7fdb873433479`, byte-for-byte the pre-fix hash. +Reverted, green again. + +Scoped regression runs, all green with `EC_AV1_AOMDEC` pointed at the +instrumented oracle: the three touched gates, the 20 `422`-named tests, and the +`chroma` (64), `rect`, `intrabc`, `sb128` filters. + +## 6. Residue — chroma rect gathers still outside the pair rule + +Enumerated mechanically (46 `around_mi_rect` call sites in `decode.rs`); the +ones that gather a CHROMA plane's coefficient context, feed `dc_sign_ctx`, lack +the pair rule, and belong to a DIFFERENT walk than the one this lane's symbol +named — each needs its own fixture-level discrimination and reachability +measurement, so this lane did not touch them: + +| `decode.rs` | function | walk | +|---|---|---| +| ~24924 | `decode_block_128rect` | intra 128-root rect per-chunk chroma walk | +| ~49552 | `decode_intra_sub8_leaf` | sub-8 intra leaf chroma rect | +| ~50400 | `decode_inter_sub8_rect2` | sub-8 inter rect chroma | + +Sites inside `sub8_leaf_chroma444` (~26798, ~26889) are 4:4:4-scoped (ss 0/0), +where the rule does not apply. Every other `around_mi_rect` site is luma +(`[0]`) or already routes through `around_mi_422_chroma`. + +## 7. Repro + +```text +git worktree add -b lane/av1muchunk422sym ~/.cache/wt/av1muchunk422sym df681fb7 +cd ~/.cache/wt/av1muchunk422sym +CARGO_TARGET_DIR=~/.cache/tgt-av1muchunk422sym cargo build -p ec-av1 --example dump_yuv +B=~/.cache/tgt-av1muchunk422sym/debug/examples +EC_TRACE_COEFF=1 EC_TRACE_COEFF_FRAME=2 EC_ECDUMP_IN=1 EC_DCDUMP=1 EC_DQCOEFF=1 \ + $B/dump_yuv crates/ec-av1/fixtures/422_muchunk_compound_128root.obu /tmp/ours 2>ours.trace +EC_TRACE_COEFF=1 EC_ECDUMP_IN=1 EC_ECDUMP=1 EC_DQCOEFF=1 \ + ~/.cache/aom-oracle/build/aomdec --codec=av1 -o /tmp/o.y4m \ + crates/ec-av1/fixtures/422_muchunk_compound_128root.obu 2>oracle.trace +# pair on (tag, value, rng): first fork is tag=sign c=0 of the V unit bc=8 br=16 +TMPDIR=$HOME/work-422sym/tmp EC_AV1_AOMDEC=~/.cache/aom-oracle/build/aomdec \ + cargo test -p ec-av1 --lib -- 422 +``` + +Fixture: `crates/ec-av1/fixtures/422_muchunk_compound_128root.obu`, 895 bytes, +fnv1a64 `0xfb28f9a7cf239897`, sha256 +`9942bae279a60ba6fd4d35ba55469271317b655d5ea03158125deb4428e26ae7`, +128x128 4:2:2 (ss 1/0), 128-superblock, one inter block per frame.