diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index f52b2958..ae0925c9 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -2275,6 +2275,119 @@ pub(crate) fn rect_class1_hits() -> usize { RECT_CLASS1_HITS.with(|c| c.get()) } +// lane-av1readcensus: the PER-UNIT coefficient census -- one unit counted +// per `read_coeffs`/`read_coeffs_rect` call, i.e. per object this decoder +// actually walks, which is the unit the round-4 `av1444rect` count measured +// (636 square chroma reads against the oracle's 1086). The counters are +// 4:4:4-ONLY (`CENSUS_444`, set per frame beside `set_subsampling`), so a +// 4:2:0 control reads `(0, 0, 0)` -- a walk-shape change at 4:2:0 is another +// lane's business, and this census must not fire there. +thread_local! { + /// Per-plane unit counts, `[luma, u, v]`, at 4:4:4 only. + static CENSUS_444_UNITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; + /// Of [`CENSUS_444_UNITS`], the units that coded at least one coefficient + /// (`txb_skip == 0`) -- the per-plane split is only comparable against + /// the oracle's when both sides count all-zero units the same way. + static CENSUS_444_CODED: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; + /// Sequential unit index, so a trace line names its own position in the + /// frame's walk rather than relying on line order alone. + static CENSUS_UNIT_N: std::cell::Cell = const { std::cell::Cell::new(0) }; + /// The plane the units read from here on belong to. A thread-local rather + /// than a `read_coeffs` parameter because the three luma call sites + /// (`decode_rect_split`, `decode_block_rect64`, `read_inter_plane_rect`) + /// are not this lane's to edit and would each grow an argument; the + /// plane-owning readers stamp it once on entry instead. + static CENSUS_PLANE: std::cell::Cell = const { std::cell::Cell::new(0) }; + /// 4:4:4 (`subsampling_x == 0 && subsampling_y == 0`) for the frame being + /// decoded, set per frame from [`crate::stream`]. + static CENSUS_444: std::cell::Cell = const { std::cell::Cell::new(false) }; +} + +/// Current `[luma, u, v]` 4:4:4 coefficient-unit counts. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub(crate) fn census_444_units() -> [usize; 3] { + CENSUS_444_UNITS.with(|c| c.get()) +} + +/// Current `[luma, u, v]` 4:4:4 counts of units that coded coefficients. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub(crate) fn census_444_coded() -> [usize; 3] { + CENSUS_444_CODED.with(|c| c.get()) +} + +/// lane-av1readcensus: arms the 4:4:4 census for the frame about to decode, +/// called once per frame from [`crate::stream`]'s decode loop beside +/// [`set_subsampling`]. At 4:2:0 (or 4:2:2) every census counter stays zero -- +/// the walk-shape question this census answers is a 4:4:4 one. +pub(crate) fn set_census_444(ss_x: u8, ss_y: u8) { + CENSUS_444.with(|c| c.set(ss_x == 0 && ss_y == 0)); +} + +/// lane-av1readcensus: the plane the units read from here on belong to, +/// stamped by the plane-owning readers ([`read_plane`], [`read_inter_plane`], +/// [`read_inter_plane_rect`]) on entry. +pub(crate) fn set_census_plane(plane: usize) { + CENSUS_PLANE.with(|c| c.set(plane)); +} + +/// lane-av1readcensus: is the per-unit census trace on? Shares +/// [`coeff_trace_on`]'s per-frame narrowing so one frame's walk can be +/// dumped without the rest of the stream. +fn census_trace_on() -> bool { + if !crate::envflags::env_flag!("EC_CENSUS_UNIT") { + return false; + } + match COEFF_TRACE_FRAME.with(|c| c.get()) { + None => true, + Some(w) if w >= usize::MAX - 1 => true, + Some(w) => COEFF_TRACE_CUR.with(|c| c.get()) == w, + } +} + +/// lane-av1readcensus: one line per coefficient unit this decoder walks, the +/// twin of the oracle's `EC_COEFF` / `EC_COEFF_VAL` bracket around each +/// `av1_read_coeffs_txb` call. Pair the two sides by `post_rng` (or by `n`), +/// never by plane label or by walk position -- the walk order is exactly what +/// the census is measuring. +fn census_unit( + w: usize, + h: usize, + tx_type: TxType, + eob: usize, + all_zero: bool, + entry_rng: u32, + dec: &SymbolDecoder, +) { + let plane = CENSUS_PLANE.with(|c| c.get()).min(2); + let coded = usize::from(!all_zero); + CENSUS_UNIT_N.with(|c| c.set(c.get() + 1)); + hit_do! { + CENSUS_444_UNITS.with(|c| { + if CENSUS_444.with(|on| on.get()) { + let mut v = c.get(); + v[plane] += 1; + c.set(v); + } + }); + CENSUS_444_CODED.with(|c| { + if CENSUS_444.with(|on| on.get()) { + let mut v = c.get(); + v[plane] += coded; + c.set(v); + } + }); + } + if !census_trace_on() { + return; + } + let n = CENSUS_UNIT_N.with(|c| c.get()) - 1; + let post_rng = dec.debug_state().0; + eprintln!( + "EC_CENSUS_UNIT side=ours n={n} plane={plane} w={w} h={h} tx={tx_type:?} eob={eob} \ + all_zero={all_zero} entry_rng={entry_rng} post_rng={post_rng}" + ); +} + // As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16 // (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the // shapes whose `use_filter_intra` symbol had no CDF class before this round. @@ -7561,6 +7674,11 @@ fn read_coeffs( ) -> Result<(Grid, TxType)> { let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); let side = coding.side; + // lane-av1readcensus: this unit's own entry state, so the census line + // carries the pre-read rng and pairs against the oracle's `EC_COEFF` + // (which prints `r->ec.rng` before the same `txb_skip` read). + let census_entry_rng = dec.debug_state().0; + let (census_w, census_h) = rect_shape.unwrap_or((side, side)); if crate::envflags::env_flag!("EC_AV1_EOBPT_CDF") { let (range, value) = dec.debug_state(); eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}"); @@ -7603,6 +7721,15 @@ fn read_coeffs( if all_zero { // lane-coefgrid: the all-zero unit (60% of the 4K segment's) names the // shared zero grid instead of allocating and zeroing its own. + census_unit( + census_w, + census_h, + TxType::DctDct, + 0, + true, + census_entry_rng, + dec, + ); return Ok((Grid::Zero(side * side), TxType::DctDct)); } let mut grid = vec![0i32; side * side]; @@ -7811,6 +7938,15 @@ fn read_coeffs( } grid[pos] = if negative { -level } else { level }; } + census_unit( + census_w, + census_h, + tx_type, + eob, + false, + census_entry_rng, + dec, + ); Ok((Grid::Own(grid), tx_type)) } @@ -7840,6 +7976,13 @@ fn read_coeffs_rect( ) -> Result<(Grid, TxType)> { let rect_trace = coeff_trace_on(); let entry_rng = dec.debug_state().0; + // lane-av1readcensus: this reader is handed the real plane (lane-av1chrtx + // threaded it in for the `EC_COEFF_STEP` traces), so it stamps the census + // plane itself rather than inheriting whichever reader did last. The + // luma-only readers (`decode_rect_split`, `decode_block_rect64`, + // `read_inter_plane_rect`'s corner) are all plane 0 -- the stamp's initial + // value -- and the other plane-owning readers stamp on entry. + set_census_plane(plane); let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; if rect_trace { eprintln!( @@ -7849,6 +7992,7 @@ fn read_coeffs_rect( ); } if all_zero { + census_unit(w, h, TxType::DctDct, 0, true, entry_rng, dec); return Ok((Grid::Zero(w * h), TxType::DctDct)); } let mut grid = vec![0i32; w * h]; @@ -8052,6 +8196,7 @@ fn read_coeffs_rect( nz.join(",") ); } + census_unit(w, h, tx_type, eob, false, entry_rng, dec); Ok((Grid::Own(grid), tx_type)) } @@ -19858,6 +20003,8 @@ fn read_plane( if plane_idx > 0 && mono(fctx) { return Ok(Grid::Zero(side * side)); } + // lane-av1readcensus: the units read from here on are this plane's. + set_census_plane(plane_idx); let skip_ctx = if plane_idx == 0 { luma_skip_ctx.unwrap_or(0) } else { @@ -28431,6 +28578,8 @@ fn read_inter_plane_rect( if plane_idx > 0 && mono(fctx) { return Ok((Grid::Zero(w * h), TxType::DctDct)); } + // lane-av1readcensus: the units read from here on are this plane's. + set_census_plane(plane_idx); let skip_ctx = if plane_idx == 0 { // `get_txb_ctx_general`: 0 only when this unit IS the whole plane // block; a var-tx leaf passes its own neighbour-table context. @@ -35501,6 +35650,8 @@ fn read_inter_plane( if plane_idx > 0 && mono(fctx) { return Ok((Grid::Zero(side * side), TxType::DctDct)); } + // lane-av1readcensus: the units read from here on are this plane's. + set_census_plane(plane_idx); let skip_ctx = if plane_idx == 0 { luma_skip_ctx.unwrap_or(0) } else { diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 56fd2cca..ad3b403c 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -1837,6 +1837,10 @@ fn decode_frame( // 4:2:0 one never inherits the wrong plane count. crate::decode::set_mono(seq.mono_chrome, fctx); crate::decode::set_subsampling(seq.subsampling_x, seq.subsampling_y, fctx); + // lane-av1readcensus: the 4:4:4 coefficient-unit census is armed here, + // off the same sequence-header subsampling -- at 4:2:0/4:2:2 every census + // counter reads zero, so a 4:2:0 control can assert exactly that. + crate::decode::set_census_444(seq.subsampling_x, seq.subsampling_y); // lane-av1txr: spec 5.9.2 `disable_cdf_update` -- a frame that sets it // codes every tile symbol against the CDFs it started with, so the tile // readers must not adapt (libaom `decodeframe.c:2909`: @@ -19369,6 +19373,141 @@ pub(crate) mod tests { ); } + /// lane-av1readcensus: the 4:4:4 coefficient-UNIT census, pinned. + /// + /// The lane report `av1444rect` round 4 left an unexplained signal: 636 + /// square chroma reads against the oracle's 1086, and 2052 luma reads + /// against its 1309, recorded as "most likely a counting-shape difference" + /// with no evidence either way. This gate is that evidence. + /// + /// Measured on this arm (`ll444_minp8_inter`, pixel-exact against aomdec + /// on every plane of every frame -- see + /// `a_lossless_444_min_partition8_inter_stream_decodes_sample_exact`), + /// pairing each of our 11292 walked units with the oracle's + /// `av1_read_coeffs_txb` call BY `post_rng` (the msac state after the + /// unit) rather than by plane label or walk position: EVERY unit pairs, + /// and no unit's plane, shape, eob or all-zero flag differs. The per-plane + /// split is equal too -- 3764 units per plane on both sides, of which + /// 975 / 1793 / 1859 coded coefficients. So on a pixel-exact arm there is + /// no asymmetry to explain at all; the round-4 numbers came from + /// `444_intrabc_rect4_witness`, an arm that DIVERGES (390380 of 921600 + /// samples wrong), where our surplus is the divergence itself. + /// + /// What this gate pins is the walk's OBJECT SHAPE on the pixel-exact arm: + /// a change to the number or plane split of coefficient units this decoder + /// walks shows up here as an intentional diff, not as the next lane's + /// mystery signal. The 4:2:0 control asserts the census is inert there. + #[test] + fn a_pixel_exact_444_stream_walks_the_same_coefficient_units_the_oracle_does() { + const NAME: &str = + "a_pixel_exact_444_stream_walks_the_same_coefficient_units_the_oracle_does"; + const FIXTURE_LEN: usize = 34037; + const FIXTURE_FNV: u64 = 0x2c8f_4a2c_c025_52da; + let _gate_lock = lock_gate_counters(); + if !have_aomenc() { + eprintln!( + "SKIP {NAME}: no aomenc/aomdec oracle at {}", + aomenc_path().display() + ); + return; + } + let path = + std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/ll444_minp8_inter.obu"); + let stream = std::fs::read(&path) + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); + assert_eq!(stream.len(), FIXTURE_LEN, "{NAME}: fixture length moved"); + assert_eq!(fnv1a64(&stream), FIXTURE_FNV, "{NAME}: fixture bytes moved"); + let delta = |now: [usize; 3], before: [usize; 3]| { + [now[0] - before[0], now[1] - before[1], now[2] - before[2]] + }; + + let u0 = crate::decode::census_444_units(); + let c0 = crate::decode::census_444_coded(); + let (frames, hidden) = decode_all_frames_vs_oracle(&stream, NAME); + assert_eq!( + frames + hidden, + 8, + "{NAME}: expected 8 decode-order frames (6 shown + 2 hidden)" + ); + let walked = delta(crate::decode::census_444_units(), u0); + let coded = delta(crate::decode::census_444_coded(), c0); + + // The oracle's own census on the same stream, paired by post_rng: + // 3764 units per plane, 975 / 1793 / 1859 of them coded. + assert_eq!( + walked, + [3764, 3764, 3764], + "{NAME}: the 4:4:4 unit walk changed -- {walked:?} against the oracle's \ + [3764, 3764, 3764] (measured by post_rng pairing, every unit matching). A change \ + here is a WALK-SHAPE change: re-measure against aomdec before assuming it is a bug" + ); + assert_eq!( + coded, + [975, 1793, 1859], + "{NAME}: the coded-unit split changed -- {coded:?} against the oracle's [975, 1793, 1859]" + ); + assert!( + walked.iter().all(|&v| v > 0) && coded.iter().all(|&v| v > 0), + "{NAME}: an all-zero plane split means the census did not run, not that the walk is empty" + ); + + // A SECOND pixel-exact arm, with a MIXED unit-shape mix -- the pinned + // lossless stream above is all TX_4X4 (min-partition-8), so on its own + // it would not notice a var-tx walk that started folding 8x8/4x8 + // leaves. This one walks 4x4/8x8/8x4/4x8/4x16/16x4/8x16/16x16, and + // the oracle's census on it pairs unit-for-unit by post_rng with no + // shape, plane, eob or all-zero difference: 1373 units, 629 luma and + // 372 per chroma plane, of which 130 / 253 / 278 coded. + let path2 = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("fixtures/444_lossy_rect4_inter_witness.obu"); + let stream2 = std::fs::read(&path2) + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path2.display())); + let m0 = crate::decode::census_444_units(); + let mc0 = crate::decode::census_444_coded(); + let (frames2, hidden2) = decode_all_frames_vs_oracle(&stream2, NAME); + assert!( + frames2 + hidden2 > 0, + "{NAME}: the mixed-shape 4:4:4 arm decoded no frames" + ); + let walked2 = delta(crate::decode::census_444_units(), m0); + let coded2 = delta(crate::decode::census_444_coded(), mc0); + assert_eq!( + walked2, + [629, 372, 372], + "{NAME}: the mixed-shape 4:4:4 walk changed -- {walked2:?} against the oracle's \ + [629, 372, 372]. The all-4x4 arm above cannot see a var-tx fold; this one can" + ); + assert_eq!( + coded2, + [130, 253, 278], + "{NAME}: the mixed-shape coded-unit split changed -- {coded2:?} against the oracle's \ + [130, 253, 278]" + ); + + // 4:2:0 control: the census is a 4:4:4 question and must not fire. + let control = std::fs::read( + std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("fixtures/av1_192x128_8bit_intra64_in_inter.obu"), + ) + .unwrap_or_else(|e| panic!("{NAME}: reading the 4:2:0 control: {e}")); + let k0 = crate::decode::census_444_units(); + let kc0 = crate::decode::census_444_coded(); + let k_frames = decode_stream(&control) + .unwrap_or_else(|e| panic!("{NAME}: the 4:2:0 control no longer decodes: {e}")) + .len(); + assert!(k_frames > 0, "{NAME}: the 4:2:0 control decoded no frames"); + assert_eq!( + delta(crate::decode::census_444_units(), k0), + [0, 0, 0], + "{NAME}: the 4:4:4 census fired on the 4:2:0 control" + ); + assert_eq!( + delta(crate::decode::census_444_coded(), kc0), + [0, 0, 0], + "{NAME}: the 4:4:4 coded-unit census fired on the 4:2:0 control" + ); + } + /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT` /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r1 /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs @@ -39628,7 +39767,6 @@ pub(crate) mod tests { "{NAME}: no attempt decoded a depth-1 1:4 split strip -- the recipe no longer \ covers the shape this round fixed" ); - eprintln!("{NAME}: {depth1_decoded} depth-1 1:4 split strips decoded pixel-exact"); } /// The chroma-rect gate's fixture + aomenc recipe for one attempt, shared diff --git a/lanes/av1readcensus.report.md b/lanes/av1readcensus.report.md new file mode 100644 index 00000000..c7e24d21 --- /dev/null +++ b/lanes/av1readcensus.report.md @@ -0,0 +1,189 @@ +# lane-av1readcensus — the 4:4:4 coefficient-read count asymmetry, settled + +**Branch:** `lane-av1readcensus`, worktree `~/.cache/wt/av1readcensus`, stacked on +`lane-av1chrtx` (`ff7cf47c`, whose `d791c464` threaded the real plane index into +`read_coeffs_rect`'s traces — the census pairs on that). + +**Verdict: COUNTING SHAPE — and not even that. On every pixel-exact 4:4:4 arm +there is no asymmetry at all: both sides walk the same number of units, in the +same order, with the same plane, shape, eob and all-zero flag. The recorded +636-vs-1086 / 2052-vs-1309 signal came from an arm that DIVERGES, where the +surplus is the divergence itself, not a counting-shape difference.** + +## 1. The signal, and why the census was admissible only on a pixel-exact arm + +`av1444rect` round 4 recorded 636 square chroma reads against the oracle's 1086, +and 2052 luma reads against its 1309, on `444_intrabc_rect4_witness`, and filed +it as "most likely a counting-shape difference … it is NOT established either +way". Two things had to be settled before counting anything: + +- the arm must be **pixel-exact**. On a diverging arm the counts are polluted by + the divergence: a decoder reading the wrong coefficients also walks a different + number of units, so the count difference is a *symptom*, and the count cannot + distinguish cause from effect. Measured: `444_intrabc_rect4_witness` is wrong in + 390380 of 921600 samples, and `444_leaf8_oob` in 281306 of 737280. +- the pairing must not assume either side's own labels. + +Measured exactness of every 4:4:4 fixture in the crate (ours vs `aomdec +--rawvideo`, plane-concatenated, u16→u8): + +| fixture | pixels | pixel-exact? | +|---|---|---| +| `ll444_minp8_inter` | 6 frames | **yes** | +| `444_quad_leaf_tx_type` | 4 frames | **yes** | +| `444_lossy_rect4_inter_witness` | 2 frames | **yes** | +| `444_rect_strip_leaf_tx_type` | 3 frames | **yes** | +| `444_sb128rect_lr_witness` | 3 frames | **yes** | +| `444_intrabc_rect4_witness` | 1 frame | no (390380 / 921600 wrong) | +| `444_leaf8_oob` | 3 frames | no (281306 / 737280 wrong) | + +## 2. Method — the census, both sides, same frame + +**Ours.** A new env-gated rung `EC_CENSUS_UNIT` (`EC_CENSUS_UNIT=1`), one line +per coefficient unit **this decoder walks** — one per `read_coeffs` / +`read_coeffs_rect` call, which is exactly the object the round-4 count measured. +Fields: `n` (sequential index), `plane`, `w`, `h`, `tx`, `eob`, `all_zero`, +`entry_rng` (msac `range` before the unit's `txb_skip` read), `post_rng` (after +the unit). The plane comes from a thread-local stamped by the plane-owning +readers (`read_plane`, `read_inter_plane`, `read_inter_plane_rect`) and by +`read_coeffs_rect` from the real `plane` argument lane-av1chrtx already threads +in — a thread-local rather than a `read_coeffs` parameter because the three +luma-only call sites (`decode_rect_split`, `decode_block_rect64`, +`read_inter_plane_rect`'s corner) belong to other lanes. + +**Oracle.** No rebuild needed: the instrumented aomdec already brackets every +`av1_read_coeffs_txb` call with `EC_COEFF …rng=
` on entry and
+`EC_COEFF_VAL …rng=` on exit (`EC_TRACE_COEFF=1`), with
+`EC_COEFF_STEP tag=all_zero` / `tag=eob` inside the bracket. That is the same
+five fields.
+
+**Pairing: by `post_rng`, never by plane label and never by walk position or
+`n`.** `post_rng` is the msac state after the unit, so two units that consumed
+the same bits end at the same state. This matters concretely here: pairing by
+`n`/position invents matches the moment the two walks order a U and a V unit
+differently, and pairing by plane label invents them whenever a walk's plane
+attribution is what is in question. The walk is a two-pointer merge on `post_rng`;
+a unit is emitted only when the two sides agree on the pairing key.
+
+**Buckets** (each difference lands in exactly one):
+
+- **(i) SAME UNIT** — the two sides' units pair, and plane/shape/eob/all-zero agree.
+- **(ii) OUR-ONLY** — we walk a unit the oracle does not, at that bit position.
+- **(iii) ORACLE-ONLY** — the oracle walks one we do not.
+- **(iv) SIZE/ORDER** — the units pair but disagree on shape, plane label, eob
+  or all-zero.
+
+## 3. Per-bucket table (whole stream, paired by `post_rng`)
+
+| arm | pixels | units ours / oracle | (i) | (ii) | (iii) | (iv) |
+|---|---|---|---|---|---|---|
+| `ll444_minp8_inter` (6 frames) | exact | **11292 / 11292** | **11292** | 0 | 0 | 0 |
+| `444_lossy_rect4_inter_witness` (mixed shapes) | exact | **1373 / 1373** | **1373** | 0 | 0 | 0 |
+| `444_quad_leaf_tx_type` | exact | **192 / 192** | **192** | 0 | 0 | 0 |
+| `444_rect_strip_leaf_tx_type` | exact | 591 / 591 | 587 | 0 | 0 | 4 |
+| `444_sb128rect_lr_witness` | exact | 467 / 467 | 463 | 0 | 0 | 4 |
+| `444_intrabc_rect4_witness` | **diverges** | 2740 / 2395 | 1909 | 823 | 478 | 8 |
+| `444_leaf8_oob` | **diverges** | 1778 / 1678 | 1027 | 751 | 651 | 0 |
+
+Per-plane split on the primary arm, both sides identical:
+
+| | luma | u | v |
+|---|---|---|---|
+| units (ours) | 3764 | 3764 | 3764 |
+| units (oracle) | 3764 | 3764 | 3764 |
+| of which coded (`txb_skip == 0`) | 975 | 1793 | 1859 |
+
+So the round-4 asymmetry does not survive on an arm whose pixels are right.
+Reproduced exactly on the diverging arm: `444_intrabc_rect4_witness` reads 1518
+luma / 611 / 611 against the oracle's 1309 / 543 / 543 — the luma 1309 and the
+per-plane 543/543 are *the round-4 oracle numbers*, so the count was never a
+counting artefact. It was a real count, taken on an arm that does not decode.
+
+## 4. The eight (iv) entries on the exact arms are a tracing artefact, not a defect
+
+On `444_rect_strip_leaf_tx_type` and `444_sb128rect_lr_witness`, 4 units each
+bucket as (iv). All four have **identical `entry_rng`, `post_rng`, `eob` and
+all-zero flag on both sides** and differ only in the reported extent:
+
+```
+idx 202: ours plane=0 32x32 eob=0 az=true | oracle plane=0 txsz=TX_64X64 eob=0 az=true | post=41441
+idx 498: ours plane=0 32x32 eob=0 az=true | oracle plane=0 txsz=TX_64X64 eob=0 az=true | post=33499
+```
+
+Both sides read exactly one `txb_skip` symbol and consumed the same bits; ours
+reports the *corner* it decoded (the 32×32 low-frequency corner of a 64×64
+luma block — `read_coeffs`' `rect_shape` path, spec 5.11.40) while libaom's
+`EC_COEFF` prints the `TX_64X64` it was called with. A shape **label**
+difference on an otherwise identical unit, not a walk difference. Two of the
+four also carry a plane-label difference with the same entry/post rng — the same
+class. Under the ticket's own rule ("a real divergence requires a unit in (i) or
+(iv) whose **eob/values** differ") these are neither: no eob and no value
+differs anywhere on any pixel-exact arm.
+
+## 5. Gate
+
+`a_pixel_exact_444_stream_walks_the_same_coefficient_units_the_oracle_does`
+(`crates/ec-av1/src/stream.rs`) pins the walk's object shape on two
+pixel-exact 4:4:4 arms:
+
+- `ll444_minp8_inter` — all-TX_4X4 (min-partition-8 lossless): `[3764, 3764,
+  3764]` units, `[975, 1793, 1859]` coded;
+- `444_lossy_rect4_inter_witness` — **mixed shapes** (4×4, 8×8, 8×4, 4×8, 4×16,
+  16×4, 8×16, 16×16): `[629, 372, 372]` units, `[130, 253, 278]` coded.
+
+The second arm is not redundant: the first is uniformly 4×4 and would not notice
+a var-tx walk that started folding 8×8 leaves. Both numbers are the oracle's own
+census on the same stream.
+
+**Mutation-proven.** Dropping 8×8 units from the walk turns it red by name:
+
+```
+the mixed-shape 4:4:4 walk changed -- [571, 313, 313] against the oracle's [629, 372, 372]
+  left: [571, 313, 313]   right: [629, 372, 372]
+```
+
+and the all-4×4 arm is untouched by that mutation — which is exactly why both
+arms are pinned.
+
+**4:2:0 control.** The census is armed per frame from the sequence header's
+subsampling (`set_census_444(ss_x, ss_y)` in `stream.rs`, beside
+`set_mono`/`set_subsampling`), so at 4:2:0/4:2:2 every counter stays zero; the
+gate asserts exactly `(0, 0, 0)` for both the unit and coded-unit counters on a
+committed 4:2:0 stream that decodes. The accounting is separate from the sibling
+counter pair the ticket mentions.
+
+## 6. What this settles for the next lane
+
+- The 636-vs-1086 / 2052-vs-1309 signal is **retracted**: it was measured on
+  `444_intrabc_rect4_witness`, which is wrong in 390380 of 921600 samples. Do not
+  carry it forward as a walk-shape hypothesis.
+- Counting the coefficient units on a **pixel-exact 4:4:4** arm reproduces the
+  oracle exactly, per plane, per unit. The census is now a one-command check:
+  `EC_CENSUS_UNIT=1 cargo run -p ec-av1 --example decode_probe -- .obu`
+  against `EC_TRACE_COEFF=1 aomdec`, paired by `post_rng`.
+- If a future lane sees a count asymmetry, the first question is whether the arm
+  decodes — not whether the walk shape differs. That check is now the gate.
+
+## 7. Not fixed here, by design
+
+The 4:4:4 intra-BC chroma divergence (`444_intrabc_rect4_witness`, 390380 /
+921600) is untouched: this lane's deliverable is the census. Per §4 there is no
+value-level divergence on any pixel-exact arm for this census to point at, so the
+remaining fork is not a coefficient-read-count problem and needs a fresh charter.
+
+## 8. Method notes for whoever repeats this
+
+- **Pair by `post_rng`.** Position/`n` pairing invents matches when a walk
+  orders U and V differently; plane-label pairing invents them when plane
+  attribution is the thing in question.
+- **A pixel-exact arm is mandatory.** On `444_intrabc_rect4_witness` the counts
+  diverge by 823/478 units *because* the decode does; the count difference is a
+  symptom, not a cause.
+- **`EC_SYMR` is still the right rung for symbol-level work**; `EC_COEFF_STEP`
+  is filtered (the oracle prints `tag=tx_type` for all three planes but reads it
+  only for Y), so it is not a per-unit bracket. `EC_COEFF`/`EC_COEFF_VAL` are
+  the per-unit bracket and were already in the oracle build — no rebuild needed.
+- Our own rung must carry the real plane: `read_coeffs` had no plane parameter,
+  and a stamp inherited from whichever reader ran last mis-attributes chroma as
+  luma (this bit the census's first run and is the same trap `d791c464` fixed for
+  the rect trace).