forge
Explore
Log in

Don't you dare go Hollow

av1: the 4:2:2 mu-chunk walk's chroma dc-sign context read luma cells

Browse files at this commit

f2fb6dd624695e5abd6cbed165854327bbfd6289Ahmet Kaan GümüşParent: 5ae8dcd
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.rsmodified+92 -28
@@ -15431,8 +15431,18 @@ fn decode_intrabc_128rect(
15431 );15431 );
15432 // Per unit, AFTER the earlier units' stamps: this15432 // Per unit, AFTER the earlier units' stamps: this
15433 // unit's coefficient context must see them.15433 // unit's coefficient context must see them.
15434- let cu_around =15434+ //
15435- neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h);15435+ // lane-av1muchunk422sym: same 4:2:2 pair rule as
15436+ // `decode_inter_block`'s mu-chunk walk -- at ss
15437+ // (1, 0) one CHROMA column spans two luma mi
15438+ // columns, so the plain rect gather doubles the
15439+ // above dc vote and flips `dc_sign_ctx` whenever
15440+ // above and left cancel.
15441+ let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
15442+ neighbours.around_mi_422_chroma(unit_mi, unit_luma_w, unit_luma_h)
15443+ } else {
15444+ neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h)
15445+ };
15436 if crate::envflags::env_flag!("EC_ECDUMP") {15446 if crate::envflags::env_flag!("EC_ECDUMP") {
15437 for p in 1..3 {15447 for p in 1..3 {
15438 let ab: Vec<String> = (0..unit_luma_w / MI)15448 let ab: Vec<String> = (0..unit_luma_w / MI)
@@ -43841,14 +43851,16 @@ fn decode_inter_block(
43841 // The unit's own footprint on the LUMA mi43851 // The unit's own footprint on the LUMA mi
43842 // grid, per axis (32 << ss) px: 64x64 (16x1643852 // grid, per axis (32 << ss) px: 64x64 (16x16
43843 // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4,43853 // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4,
43844- // 64x32 (16x8 mi) at 4:2:2. `around_mi_rect`43854+ // 64x32 (16x8 mi) at 4:2:2. The context
43845- // reads and43855+ // gather and `record_mi_chroma`'s stamp span
43846- // `record_mi_chroma` stamps span exactly the43856+ // exactly the unit's own cells -- `get_txb_ctx`
43847- // unit's own cells -- `get_txb_ctx` reads the43857+ // reads the 8 context cells of the TX_32X32
43848- // 8 context cells of the TX_32X32 itself, and43858+ // itself, and `av1_set_entropy_contexts` memsets
43849- // `av1_set_entropy_contexts` memsets the same43859+ // the same 8, so the unit over never sees this
43850- // 8, so the unit over never sees this unit's43860+ // unit's state and the unit below always does.
43851- // state and the unit below always does.43861+ // At ss (1, 0) those 8 are CHROMA cells, so the
43862+ // gather routes through the 4:2:2 pair rule
43863+ // (lane-av1muchunk422sym, see the walk below).
43852 let unit_luma_w = cu_tx << ss_x(fctx);43864 let unit_luma_w = cu_tx << ss_x(fctx);
43853 let unit_luma_h = cu_tx << ss_y(fctx);43865 let unit_luma_h = cu_tx << ss_y(fctx);
43854 let cu_scan = default_scan(cu_tx);43866 let cu_scan = default_scan(cu_tx);
@@ -43923,11 +43935,36 @@ fn decode_inter_block(
43923 // units' stamps: this unit's43935 // units' stamps: this unit's
43924 // coefficient context must see43936 // coefficient context must see
43925 // them.43937 // them.
43926- let cu_around = neighbours.around_mi_rect(43938+ //
43927- unit_mi,43939+ // lane-av1muchunk422sym: at ss
43928- unit_luma_w,43940+ // (1, 0) one CHROMA column spans
43929- unit_luma_h,43941+ // two luma mi columns, so the plain
43930- );43942+ // rect gather sums this unit's
43943+ // above dc sign TWICE where
43944+ // libaom's `get_txb_ctx_general`
43945+ // reads `txb_w_unit` CHROMA cells --
43946+ // one per column. `dc_sign_ctx`
43947+ // only sees the vote's signum, so
43948+ // the doubled vote flips the row
43949+ // exactly when above and left
43950+ // cancel; `around_mi_422_chroma`
43951+ // samples every second above cell,
43952+ // which IS libaom's sum. Same guard
43953+ // as the intra twin (13169) and the
43954+ // block-8 arm (19810).
43955+ let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
43956+ neighbours.around_mi_422_chroma(
43957+ unit_mi,
43958+ unit_luma_w,
43959+ unit_luma_h,
43960+ )
43961+ } else {
43962+ neighbours.around_mi_rect(
43963+ unit_mi,
43964+ unit_luma_w,
43965+ unit_luma_h,
43966+ )
43967+ };
43931 let (cu_x, cu_y) = (43968 let (cu_x, cu_y) = (
43932 cpx + cc * chunk_chroma_w + uc * cu_tx,43969 cpx + cc * chunk_chroma_w + uc * cu_tx,
43933 cpy + cr * chunk_chroma_h + ur * cu_tx,43970 cpy + cr * chunk_chroma_h + ur * cu_tx,
@@ -45664,14 +45701,16 @@ fn decode_inter_block(
45664 // The unit's own footprint on the LUMA mi45701 // The unit's own footprint on the LUMA mi
45665 // grid, per axis (32 << ss) px: 64x64 (16x1645702 // grid, per axis (32 << ss) px: 64x64 (16x16
45666 // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4,45703 // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4,
45667- // 64x32 (16x8 mi) at 4:2:2. `around_mi_rect`45704+ // 64x32 (16x8 mi) at 4:2:2. The context
45668- // reads and45705+ // gather and `record_mi_chroma`'s stamp span
45669- // `record_mi_chroma` stamps span exactly the45706+ // exactly the unit's own cells -- `get_txb_ctx`
45670- // unit's own cells -- `get_txb_ctx` reads the45707+ // reads the 8 context cells of the TX_32X32
45671- // 8 context cells of the TX_32X32 itself, and45708+ // itself, and `av1_set_entropy_contexts` memsets
45672- // `av1_set_entropy_contexts` memsets the same45709+ // the same 8, so the unit over never sees this
45673- // 8, so the unit over never sees this unit's45710+ // unit's state and the unit below always does.
45674- // state and the unit below always does.45711+ // At ss (1, 0) those 8 are CHROMA cells, so the
45712+ // gather routes through the 4:2:2 pair rule
45713+ // (lane-av1muchunk422sym, see the walk below).
45675 let unit_luma_w = cu_tx << ss_x(fctx);45714 let unit_luma_w = cu_tx << ss_x(fctx);
45676 let unit_luma_h = cu_tx << ss_y(fctx);45715 let unit_luma_h = cu_tx << ss_y(fctx);
45677 let cu_scan = default_scan(cu_tx);45716 let cu_scan = default_scan(cu_tx);
@@ -45726,11 +45765,36 @@ fn decode_inter_block(
45726 // units' stamps: this unit's45765 // units' stamps: this unit's
45727 // coefficient context must see45766 // coefficient context must see
45728 // them.45767 // them.
45729- let cu_around = neighbours.around_mi_rect(45768+ //
45730- unit_mi,45769+ // lane-av1muchunk422sym: at ss
45731- unit_luma_w,45770+ // (1, 0) one CHROMA column spans
45732- unit_luma_h,45771+ // two luma mi columns, so the plain
45733- );45772+ // rect gather sums this unit's
45773+ // above dc sign TWICE where
45774+ // libaom's `get_txb_ctx_general`
45775+ // reads `txb_w_unit` CHROMA cells --
45776+ // one per column. `dc_sign_ctx`
45777+ // only sees the vote's signum, so
45778+ // the doubled vote flips the row
45779+ // exactly when above and left
45780+ // cancel; `around_mi_422_chroma`
45781+ // samples every second above cell,
45782+ // which IS libaom's sum. Same guard
45783+ // as the intra twin (13169) and the
45784+ // block-8 arm (19810).
45785+ let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
45786+ neighbours.around_mi_422_chroma(
45787+ unit_mi,
45788+ unit_luma_w,
45789+ unit_luma_h,
45790+ )
45791+ } else {
45792+ neighbours.around_mi_rect(
45793+ unit_mi,
45794+ unit_luma_w,
45795+ unit_luma_h,
45796+ )
45797+ };
45734 let (cu_x, cu_y) = (45798 let (cu_x, cu_y) = (
45735 cpx + cc * chunk_chroma_w + uc * cu_tx,45799 cpx + cc * chunk_chroma_w + uc * cu_tx,
45736 cpy + cr * chunk_chroma_h + ur * cu_tx,45800 cpy + cr * chunk_chroma_h + ur * cu_tx,
crates/ec-av1/src/stream.rsmodified+99 -24
@@ -3624,6 +3624,27 @@ pub(crate) mod tests {
3624 body.matches(name).count()3624 body.matches(name).count()
3625 );3625 );
3626 }3626 }
3627+ // lane-av1muchunk422sym: the CHROMA gather of that same walk must take
3628+ // the 4:2:2 pair rule, exactly as `decode_inter_block`'s mu-chunk walk
3629+ // does (one chroma column per pair of luma mi cells; the plain rect
3630+ // gather doubles the above dc vote and flips `dc_sign_ctx` wherever
3631+ // above and left cancel). Reachability is measured: the walk fires at
3632+ // ss (1, 0) on `422_intrabc_sb128_strip.obu` (`EC_IBC128_BANDS`
3633+ // prints); that fixture's own votes do not cancel, so THIS gate -- not
3634+ // a pixel compare -- is what stops the routing being reverted.
3635+ for name in [
3636+ "let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {",
3637+ "neighbours.around_mi_422_chroma(",
3638+ ] {
3639+ assert_eq!(
3640+ body.matches(name).count(),
3641+ 1,
3642+ "{NAME}: `{name}` must appear exactly once in \
3643+ decode_intrabc_128rect's chroma chunk walk, found {} -- the \
3644+ gather has fallen back to the square per-mi rule",
3645+ body.matches(name).count()
3646+ );
3647+ }
3627 // The replay's own unit luma span is the lossless/lossy `cu << ss` form3648 // The replay's own unit luma span is the lossless/lossy `cu << ss` form
3628 // (site 2 spells it separately from the read walk's `cu_tx << ss`).3649 // (site 2 spells it separately from the read walk's `cu_tx << ss`).
3629 for name in [3650 for name in [
@@ -42895,22 +42916,19 @@ exit 0
42895 /// shares this exact source text and is routed out of the counter by42916 /// shares this exact source text and is routed out of the counter by
42896 /// `is_compound`.42917 /// `is_compound`.
42897 ///42918 ///
42898- /// **7 of the 8 streams this lane generated DIVERGE from ffmpeg; only42919+ /// **7 of the 8 streams this lane generated DIVERGED from ffmpeg; only
42899 /// `i6_grad128_iis` (the intra-in-inter fixture, pinned in the twin test42920 /// `i6_grad128_iis` (the intra-in-inter fixture, pinned in the twin test
42900- /// below) is byte-exact. This compound pin is therefore the COUNTER42921+ /// below) was byte-exact.** lane-av1muchunk422sym has since fixed this
42901- /// WITNESS, not an exactness witness** -- it asserts the walk ran, and42922+ /// pin's stream: the compound mu-chunk walk gathered its CHROMA
42902- /// nothing about pixels. The divergence on this tip is Y and U exact, V42923+ /// coefficient context with the plain rect rule, which at ss (1, 0) counts
42903- /// differing on a fixed column band (2063/8192, 2138/8192, 2105/8192 and42924+ /// one chroma column twice in the above vote (see the walk's own comment).
42904- /// 1988/8192 V samples on shown frames 1-4, first at V row 60 col 36), the42925+ /// **The stream is now byte-exact against the instrumented aomdec over all
42905- /// same shape on all four compound streams this lane produced, while the42926+ /// 7 decode-order frames (6 shown + 1 hidden alt-ref)**, so this test
42906- /// committed 4:2:2 128-root SINGLE-reference stream (`422_sb128_3f.obu`)42927+ /// carries both halves: the counter witness that the walk ran AND the
42907- /// and the committed compound-warp stream whose blocks are all <= 6442928+ /// exactness witness. The pinned V-plane hashes run without an oracle;
42908- /// (`422_residual_compound_warp_16f.obu`) both stay exact against the same42929+ /// `decode_all_frames_vs_oracle` adds the decode-order compare when one is
42909- /// oracle -- so it tracks the 128-root COMPOUND path these counters name.42930+ /// present. The counter half still stops this fixture silently ceasing to
42910- /// It is a NEW defect and fixing the walk is explicitly out of this lane's42931+ /// reach the walk it was pinned for.
42911- /// charter. When a fix lane lands, add the oracle compare to this test; the
42912- /// counter half already stops this fixture silently ceasing to reach the
42913- /// walk it was pinned for.
42914 ///42932 ///
42915 /// Recipe (byte-reproducible; whole aomenc argv):42933 /// Recipe (byte-reproducible; whole aomenc argv):
42916 /// ```text42934 /// ```text
@@ -42932,6 +42950,17 @@ exit 0
42932 const LEN: usize = 895;42950 const LEN: usize = 895;
42933 const FNV: u64 = 0xfb28_f9a7_cf23_9897;42951 const FNV: u64 = 0xfb28_f9a7_cf23_9897;
42934 const MIN_UNITS: usize = 32;42952 const MIN_UNITS: usize = 32;
42953+ // lane-av1muchunk422sym: shown frame 2's V plane byte-for-byte (it is
42954+ // the first intrinsically wrong frame; the pre-fix square gather put
42955+ // 2138 of these 8192 samples off by up to 4), and shown frame 0's as
42956+ // the unaffected control. 0xa0e5_8bf4_207b_29ba is the ffmpeg/aomdec
42957+ // exact plane.
42958+ const SHOWN_F2_V_FNV: u64 = 0xa0e5_8bf4_207b_29ba;
42959+ const SHOWN_F0_V_FNV: u64 = 0xcc5e_3291_1915_9024;
42960+ /// Chroma (36, 60) of shown frame 2 -- the FIRST sample that moved,
42961+ /// `60 * 64 + 36`. The pre-fix square gather read 113, the oracle 112.
42962+ const FIRST_WRONG_V: usize = 3876;
42963+ const SHOWN_F2_V_AT_FIRST_WRONG: u16 = 112;
42935 let _gate_lock = lock_gate_counters();42964 let _gate_lock = lock_gate_counters();
42936 let stream = read_pinned_muchunk_fixture(FILE, LEN, FNV, NAME);42965 let stream = read_pinned_muchunk_fixture(FILE, LEN, FNV, NAME);
42937 assert_eq!(42966 assert_eq!(
@@ -42943,9 +42972,9 @@ exit 0
42943 crate::decode::mu_chunk_compound_units(),42972 crate::decode::mu_chunk_compound_units(),
42944 crate::decode::mu_chunk_intra_in_inter_units(),42973 crate::decode::mu_chunk_intra_in_inter_units(),
42945 );42974 );
42946- let frames = crate::stream::decode_stream(&stream)42975+ let shown = crate::stream::decode_stream(&stream)
42947- .unwrap_or_else(|e| panic!("{NAME}: {FILE} no longer decodes cleanly: {e}"))42976+ .unwrap_or_else(|e| panic!("{NAME}: {FILE} no longer decodes cleanly: {e}"));
42948- .len();42977+ let frames = shown.len();
42949 let (compound, intra) = (42978 let (compound, intra) = (
42950 crate::decode::mu_chunk_compound_units() - before.0,42979 crate::decode::mu_chunk_compound_units() - before.0,
42951 crate::decode::mu_chunk_intra_in_inter_units() - before.1,42980 crate::decode::mu_chunk_intra_in_inter_units() - before.1,
@@ -42961,13 +42990,59 @@ exit 0
42961 "{NAME}: {FILE} also ran the intra-in-inter walk ({intra} units) -- the two fixtures \42990 "{NAME}: {FILE} also ran the intra-in-inter walk ({intra} units) -- the two fixtures \
42962 no longer separate the cells"42991 no longer separate the cells"
42963 );42992 );
42964- // DELIBERATELY NO ORACLE COMPARE: 7 of the 8 streams this lane generated42993+ // lane-av1muchunk422sym: the EXACTNESS half the diagnostic lane handed
42965- // diverge and this fixture is one of them. This test is the counter42994+ // over ("when a fix lane lands, add the oracle compare to this test").
42966- // witness, not an exactness witness -- see the doc comment.42995+ // The fix routes this walk's CHROMA context gather through the 4:2:2
42967- eprintln!(42996+ // pair rule (`around_mi_422_chroma`): at ss (1, 0) one chroma column
42968- "{NAME}: {FILE} compound_units={compound} intra_in_inter_units={intra} -- counter \42997+ // spans two luma mi columns, so the plain rect gather summed the unit's
42969- witness, pixels NOT asserted (this stream is measured DIVERGENT)"42998+ // above dc sign twice and `dc_sign_ctx`'s signum flipped whenever above
42999+ // and left cancelled. The first wrong symbol was the DC SIGN of the V
43000+ // unit at chunk (1, 1) of decode frame 2 -- ours read
43001+ // `dc_sign_cdf[1]`, the oracle row 0.
43002+ //
43003+ // The pinned half below needs NO oracle and is therefore the one that
43004+ // cannot silently skip: shown frame 2 (the first intrinsically wrong
43005+ // frame) is asserted sample-for-sample on its V plane. Frame 0's is
43006+ // asserted too, as the unaffected control that fails if the gather is
43007+ // "fixed" past its own cell.
43008+ assert_eq!(
43009+ shown[0].v.len(),
43010+ 64 * 128,
43011+ "{NAME}: {FILE} is no longer 4:2:2 -- the V plane shape moved"
42970 );43012 );
43013+ assert_eq!(
43014+ fnv1a64(&shown[2].v.iter().map(|&s| s as u8).collect::<Vec<u8>>()),
43015+ SHOWN_F2_V_FNV,
43016+ "{NAME}: {FILE} shown frame 2's V plane moved -- the compound mu-chunk walk's 4:2:2 \
43017+ chroma context gather is wrong again (first sample to move is chroma (36, 60), index \
43018+ 3876, expected {})",
43019+ SHOWN_F2_V_AT_FIRST_WRONG
43020+ );
43021+ assert_eq!(
43022+ shown[2].v[FIRST_WRONG_V], SHOWN_F2_V_AT_FIRST_WRONG,
43023+ "{NAME}: {FILE} shown frame 2 V[3876] (chroma (36, 60)) is {} -- the pre-fix square \
43024+ gather read 113 here",
43025+ shown[2].v[FIRST_WRONG_V]
43026+ );
43027+ assert_eq!(
43028+ fnv1a64(&shown[0].v.iter().map(|&s| s as u8).collect::<Vec<u8>>()),
43029+ SHOWN_F0_V_FNV,
43030+ "{NAME}: {FILE} shown frame 0's V plane moved -- the 4:2:2 routing changed a frame it \
43031+ must not touch"
43032+ );
43033+ if aomdec_available(NAME) {
43034+ let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, NAME);
43035+ assert_eq!(decoded, 7, "{NAME}: {FILE} decode-order frame count");
43036+ eprintln!(
43037+ "{NAME}: {FILE} byte-exact over {decoded} decode-order frame(s) ({hidden} hidden), \
43038+ compound_units={compound} intra_in_inter_units={intra}"
43039+ );
43040+ } else {
43041+ eprintln!(
43042+ "{NAME}: {FILE} compound_units={compound} intra_in_inter_units={intra} -- the \
43043+ decode-order oracle compare above did NOT run (no aomdec)"
43044+ );
43045+ }
42971 }43046 }
42972 43047
42973 /// lane-av1muchunk422b: the **intra-in-inter** `side > 64` mu-chunk walk --43048 /// lane-av1muchunk422b: the **intra-in-inter** `side > 64` mu-chunk walk --
lanes/av1muchunk422sym.report.mdadded+181 -0
@@ -0,0 +1,181 @@
1+# lane-av1muchunk422sym — the first wrong SYMBOL of `422_muchunk_compound_128root.obu`
2+
3+Base: `main` @ `df681fb7`. Branch: `lane/av1muchunk422sym`.
4+
5+**Verdict: the first wrong symbol is the DC SIGN of the V-plane unit at mu chunk
6+`(cr = 1, cc = 1)` of decode frame 2 — the last unit pair of the compound
7+`side > 64` mu-chunk walk. The context was chosen by `Neighbours::around_mi_rect`
8+(`decode.rs` 10623) as called by that walk: at ss (1, 0) it reads the unit's
9+above dc vote over 16 LUMA mi cells where libaom's `get_txb_ctx_general` reads
10+`txb_w_unit` = 8 CHROMA cells, doubling the above vote and flipping
11+`dc_sign_ctx`'s signum. FIXED, GATED, MUTATION-PROVEN.**
12+
13+## 1. The first wrong symbol, measured not argued
14+
15+Paired our `EC_TRACE_COEFF` / `EC_ECDUMP_IN` / `EC_DCDUMP` ladders (decode frame
16+2, via `EC_TRACE_COEFF_FRAME=2`) against the instrumented oracle's
17+(`~/.cache/aom-oracle/build/aomdec`, `EC_TRACE_COEFF` + `EC_ECDUMP_IN` +
18+`EC_ECDUMP`), unit-for-unit, on `(tag, symbol value, rng)` — the ECIN `(value,
19+rng)` pair matched on every unit up to the fork (the oracle's third field is a
20+different bit-position convention, off by a constant).
21+
22+Every unit and every symbol agrees until:
23+
24+| | ours | oracle |
25+|---|---|---|
26+| unit | plane V, `bc=8 br=16 tx=3` (chunk `(1,1)`, mi `(16,16)`) | same |
27+| symbol | `tag=sign c=0` (the DC sign) | same |
28+| value | `sign=0` | `sign=0` |
29+| **context** | **`dc_sign_ctx = 1`** (`dc_sign_cdf[1]`) | **`dc_sign_ctx = 0`** (`dc_sign_cdf[0]`) |
30+| `rng` after | `62776` | `37548` |
31+
32+Both decoders read the SAME sign value from DIFFERENT CDF rows, so the entropy
33+state forks at that read. That is exactly the "same magnitudes, different
34+signs" the diagnostic lane measured in the dequantised grid, and it is why Y
35+and U (and every earlier chunk of V) stayed bit-exact.
36+
37+The choosing functions, bottom-up:
38+
39+* `decode_inter_block`'s compound mu-chunk walk, `decode.rs` 43927 (pre-fix):
40+ `let cu_around = neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h);`
41+* `Neighbours::around_mi_rect`, `decode.rs` 10623 — sums `dc_vote` over
42+ `unit_luma_w / MI = 64 / 4 = 16` above cells.
43+* `read_inter_plane`, `decode.rs` 39532 — `dc_sign_ctx(around.2)`.
44+
45+Measured at that unit (our `EC_DCDUMP mi=(16,16) plane=2 wh=(64,32)`):
46+`above` = 16 cells all `Some(true)` → `-16`; `left` = 8 cells all `Some(false)`
47+→ `+8`; vote `-8` → ctx 1. libaom's sum is one chroma cell per PAIR of luma mi
48+columns (ss_x 1): `-8 + 8 = 0` → ctx 0, which is the oracle's row.
49+
50+## 2. Why that gather is the 4:2:2 pair rule and not a geometry error
51+
52+`get_txb_ctx_general` (oracle `av1/common/txb_common.h`) walks
53+`tx_size_wide_unit[TX_32X32] = 8` cells of `pd->above_entropy_context`, which is
54+indexed in the CHROMA plane's own 4-px units (`av1_set_entropy_contexts` writes
55+`blk_col + k` for `k < txb_w_unit`). `decode_token_recon_block` enters the
56+chroma unit at `blk_col = col >> ss_x`, so those 8 cells are chroma columns
57+8..15 — 8 cells, not 16. Our single luma-mi-indexed array
58+(`record_mi_chroma` stamps the unit's whole 16-luma-mi-column span, both
59+columns of each chroma column carrying the same whole-unit dc sign) therefore
60+counts each above column twice. `around_mi_422_chroma` samples every second
61+above cell, which IS libaom's sum — the same rule the file already applies at
62+`decode.rs` 13169 / 19810 / 16699.
63+
64+The walk's ADDRESSING is not implicated (the diagnostic lane proved it); only
65+the context gather.
66+
67+## 3. Fix
68+
69+Route the mu-chunk chroma gather through the pair rule when ss (1, 0), luma and
70+every other subsampling shape keeping the plain rect gather verbatim:
71+
72+```rust
73+let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
74+ neighbours.around_mi_422_chroma(unit_mi, unit_luma_w, unit_luma_h)
75+} else {
76+ neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h)
77+};
78+```
79+
80+Three source copies, all the same walk:
81+
82+1. `decode_inter_block` compound mu-chunk walk (`decode.rs` ~43927);
83+2. `decode_inter_block` single-reference twin (~45730) — same source text,
84+ same rule; its own votes do not cancel on this fixture (decode frame 1 was
85+ already exact), so it is a measured-reachable latent instance of the class;
86+3. `decode_intrabc_128rect`'s chroma chunk walk (~15435) — the IntraBC twin of
87+ the same walk. Reachability MEASURED, not assumed: `EC_IBC128_BANDS` prints
88+ at ss (1, 0) on the committed `422_intrabc_sb128_strip.obu` (96 lines).
89+ That fixture's own votes do not cancel either, so no committed cell
90+ discriminates the change; its source-scan gate
91+ `the_intrabc_128rect_chroma_chunk_walk_stays_per_axis` now pins the routing
92+ instead (`neighbours.around_mi_422_chroma(` and the guard literal, once
93+ each), so it cannot be silently reverted.
94+
95+At 4:2:0 (ss 1/1) and 4:4:4 the guard is false and nothing changes; the
96+pre-existing 4:2:0 exactness is explained by the same arithmetic — there BOTH
97+extents double (`2a + 2l`), so the signum is untouched.
98+
99+## 4. Evidence
100+
101+`ffmpeg -i X.obu -pix_fmt yuv422p -f rawvideo` (6 shown frames), ours before vs
102+after, differing bytes per shown frame (Y / U / V):
103+
104+| frame | 0 | 1 | 2 | 3 | 4 | 5 |
105+|---|---|---|---|---|---|---|
106+| before | 0 | V 2063 | V 2138 | V 2105 | V 1988 | 0 |
107+| after | 0 | 0 | 0 | 0 | 0 | 0 |
108+
109+Instrumented aomdec `EC_AV1_FINAL_DUMP` in DECODE order (7 frames = 6 shown + 1
110+hidden alt-ref), ours vs oracle, after the fix: **f0..f6 all EXACT**.
111+
112+## 5. Gate + mutation proof
113+
114+`a_422_muchunk_compound_128root_pinned_stream_reaches_its_unit_walk` now carries
115+BOTH halves (the diagnostic lane's hand-over: "when a fix lane lands, add the
116+oracle compare to this test"):
117+
118+* the counter half, untouched (compound units ≥ 32, intra-in-inter 0);
119+* an oracle-free pinned half that CANNOT silently skip: `fnv1a64` of shown
120+ frame 2's V plane must be `0xa0e58bf4207b29ba` (pre-fix
121+ `0xc4e7fdb873433479`) and `V[3876]` (chroma (36, 60), the first sample the
122+ diagnostic lane measured) must be `112` (pre-fix 113); shown frame 0's V
123+ plane is pinned as the unaffected control (`0xcc5e329119159024`);
124+* `decode_all_frames_vs_oracle` for the 7-decode-order-frame compare when an
125+ oracle is present.
126+
127+Red-before, measured: restoring the square gather at the COMPOUND site only
128+(`git`-restorable edit) and re-running produced
129+
130+```text
131+panicked at crates/ec-av1/src/stream.rs:42992:
132+ 422_muchunk_compound_128root.obu shown frame 2's V plane moved ...
133+ left: 14188588119703630969 right: 11593826696368433594
134+```
135+
136+`14188588119703630969 = 0xc4e7fdb873433479`, byte-for-byte the pre-fix hash.
137+Reverted, green again.
138+
139+Scoped regression runs, all green with `EC_AV1_AOMDEC` pointed at the
140+instrumented oracle: the three touched gates, the 20 `422`-named tests, and the
141+`chroma` (64), `rect`, `intrabc`, `sb128` filters.
142+
143+## 6. Residue — chroma rect gathers still outside the pair rule
144+
145+Enumerated mechanically (46 `around_mi_rect` call sites in `decode.rs`); the
146+ones that gather a CHROMA plane's coefficient context, feed `dc_sign_ctx`, lack
147+the pair rule, and belong to a DIFFERENT walk than the one this lane's symbol
148+named — each needs its own fixture-level discrimination and reachability
149+measurement, so this lane did not touch them:
150+
151+| `decode.rs` | function | walk |
152+|---|---|---|
153+| ~24924 | `decode_block_128rect` | intra 128-root rect per-chunk chroma walk |
154+| ~49552 | `decode_intra_sub8_leaf` | sub-8 intra leaf chroma rect |
155+| ~50400 | `decode_inter_sub8_rect2` | sub-8 inter rect chroma |
156+
157+Sites inside `sub8_leaf_chroma444` (~26798, ~26889) are 4:4:4-scoped (ss 0/0),
158+where the rule does not apply. Every other `around_mi_rect` site is luma
159+(`[0]`) or already routes through `around_mi_422_chroma`.
160+
161+## 7. Repro
162+
163+```text
164+git worktree add -b lane/av1muchunk422sym ~/.cache/wt/av1muchunk422sym df681fb7
165+cd ~/.cache/wt/av1muchunk422sym
166+CARGO_TARGET_DIR=~/.cache/tgt-av1muchunk422sym cargo build -p ec-av1 --example dump_yuv
167+B=~/.cache/tgt-av1muchunk422sym/debug/examples
168+EC_TRACE_COEFF=1 EC_TRACE_COEFF_FRAME=2 EC_ECDUMP_IN=1 EC_DCDUMP=1 EC_DQCOEFF=1 \
169+ $B/dump_yuv crates/ec-av1/fixtures/422_muchunk_compound_128root.obu /tmp/ours 2>ours.trace
170+EC_TRACE_COEFF=1 EC_ECDUMP_IN=1 EC_ECDUMP=1 EC_DQCOEFF=1 \
171+ ~/.cache/aom-oracle/build/aomdec --codec=av1 -o /tmp/o.y4m \
172+ crates/ec-av1/fixtures/422_muchunk_compound_128root.obu 2>oracle.trace
173+# pair on (tag, value, rng): first fork is tag=sign c=0 of the V unit bc=8 br=16
174+TMPDIR=$HOME/work-422sym/tmp EC_AV1_AOMDEC=~/.cache/aom-oracle/build/aomdec \
175+ cargo test -p ec-av1 --lib -- 422
176+```
177+
178+Fixture: `crates/ec-av1/fixtures/422_muchunk_compound_128root.obu`, 895 bytes,
179+fnv1a64 `0xfb28f9a7cf239897`, sha256
180+`9942bae279a60ba6fd4d35ba55469271317b655d5ea03158125deb4428e26ae7`,
181+128x128 4:2:2 (ss 1/0), 128-superblock, one inter block per frame.