diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index f84e1a87..46e0491f 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -51,12 +51,17 @@ fn main() { ec_av1::decode::chroma422_pair_wide_hits() ); println!( - "uv_left_ss_y: reads={} mode_diff={} smooth_diff={}", + "uv_left_ss_y: reads={} mode_diff={} smooth_diff={} split1mi={}", ec_av1::decode::uv_left_ss_y_reads(), ec_av1::decode::uv_left_ss_y_mode_diff_hits(), - ec_av1::decode::uv_left_ss_y_smooth_diff_hits() + ec_av1::decode::uv_left_ss_y_smooth_diff_hits(), + ec_av1::decode::uv_left_1mi_split_hits(), ); let (h, v, c) = ec_av1::stream::rect4_32_counters(); + println!( + "rect4_16_uv_pair_filt: {}", + ec_av1::decode::rect4_16_uv_pair_filt_hits() + ); println!("rect4_32: horz={h} vert={v} coded={c}"); println!( "rect_intrabc_reads: {}", diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 68e40e81..4c81f523 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -5696,6 +5696,27 @@ pub fn uv_left_ss_y_smooth_diff_hits() -> usize { UV_LEFT_SS_Y_SMOOTH_DIFF_HITS.with(|c| c.get()) } +// lane-av1leftwit: decode-path chroma edge-filter-type reads at `ss_y > 0` +// whose left-neighbour COLUMN holds a run of length 1 -- the cell this +// decoder reads (its own mi row) and the cell libaom reads (one row down) +// were written by two DIFFERENT blocks, i.e. the left neighbour is at most +// 1 mi tall. That is the only geometry in which the `+ss_y` term can change +// the answer at all; `UV_LEFT_SS_Y_READS` alone proves nothing about it. +thread_local! { + static UV_LEFT_1MI_SPLIT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Current value of [`UV_LEFT_1MI_SPLIT_HITS`]. +pub fn uv_left_1mi_split_hits() -> usize { + UV_LEFT_1MI_SPLIT_HITS.with(|c| c.get()) +} + +// lane-av1leftwit: the per-tile epoch `uv_owner` cells are stamped with. +// Bumped in `Neighbours::start_tile`; never read by decode logic. +thread_local! { + static UV_OWNER_EPOCH: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + // lane-cfl r1 gate counters: `UV_CFL_PRED` blocks (every `cfl_alpha_signs` // read) and chroma blocks with a NONZERO `angle_delta_uv` -- the two block // shapes the r1 chroma defect showed up on. @@ -8228,6 +8249,16 @@ struct Neighbours { /// [`Self::uv_mode_grid`]'s stride, in mi units (superblock-padded, like /// every other band here). uv_grid_cols: usize, + /// lane-av1leftwit: which BLOCK wrote each cell of [`Self::uv_mode_grid`], + /// as `(epoch << 24) | (mi_r << 12) | mi_c` of the writing block's own + /// top-left mi. The `uv_mode` value alone cannot answer "are the two cells + /// the `+ss_y` read compares written by the same block?", which is the + /// whole question the `+ss_y` term turns on: the term is only observable + /// when the left neighbour is 1 mi tall, i.e. when the cell this decoder + /// used to read and the cell libaom reads hold DIFFERENT blocks. `epoch` + /// is [`UV_OWNER_EPOCH`], bumped once per tile, so a cell no block wrote + /// in this tile can never be mistaken for a written one. + uv_owner: Vec, /// Whether the block above/left of this column/row was coded `skip` -- /// an inter frame's own `skip` context (spec `SkipContext`), which the /// key-frame writer never tracks (its skip context is always zero); a @@ -8421,6 +8452,7 @@ impl Neighbours { uv_mode_row: vec![(u16::MAX, 0); rows * (SUB / MI)], uv_mode_grid: vec![u8::MAX; cols * (SUB / MI) * rows * (SUB / MI)], uv_grid_cols: cols * (SUB / MI), + uv_owner: vec![0; cols * (SUB / MI) * rows * (SUB / MI)], above_txfm: vec![TXFM_CTX_INIT; cols * (SUB / MI)], left_txfm: vec![TXFM_CTX_INIT; rows * (SUB / MI)], // lane-inter8 r2: mi(4px)-granular, not [`SUB`]-granular -- an @@ -8490,6 +8522,10 @@ impl Neighbours { // lane-seg: `AvailU`/`AvailL` for the segment-id neighbour prediction // are tile-relative, same as every other neighbour lookup here. fctx.seg_tile_origin.with(|c| c.set((row0_mi, col0_mi))); + // lane-av1leftwit: a fresh epoch stamps every `uv_owner` cell this + // tile writes, so the `+ss_y` read's "different block?" probe never + // compares against a cell a previous tile left behind. + UV_OWNER_EPOCH.with(|c| c.set(c.get().wrapping_add(1) | (1 << 24))); self.tile_row0_mi = row0_mi; self.tile_col0_mi = col0_mi; let end = col1_mi.min(self.above.len()); @@ -9599,6 +9635,17 @@ impl Neighbours { uv_mode as u8, ); } + // lane-av1leftwit: stamp the writing block's own mi over its extent, + // the same cells and the same clipping as `uv_mode_grid` above. + let owner = UV_OWNER_EPOCH.with(|c| c.get()) | ((mi_r as u32) << 12) | mi_c as u32; + for row in mi_r..=last_r { + fill_span(&mut self.uv_owner, row * stride + mi_c, n, owner); + } + if crate::envflags::env_flag!("EC_LEFTSSY") { + eprintln!( + "EC_LEAF mi=({mi_r},{mi_c}) wh=({mi_w},{mi_h}) uv_mode={uv_mode}" + ); + } } /// Whether either mi-exact chroma neighbour of the block at `(mi_r, mi_c)` @@ -9659,11 +9706,16 @@ impl Neighbours { /// decode path uses the snapping form. /// `decode_path` is `true` only for the snapping form every decode call /// site uses; the 16x4/4x16 pair witness's mirror passes `false`, so the - /// `+ss_y` counters measure the read that actually filters a chroma edge - /// and not the counter-only one. (The mirror reads an ODD mi row -- the - /// pair's chroma-reference half -- where the two cells differ far more - /// often; counting it would make this lane look reachable when no - /// committed fixture reaches it on the decode path.) + /// `+ss_y` counters measure a read that actually filters a chroma edge and + /// not the counter-only one. + /// + /// lane-av1leftwit: the mirror's justification used to be "no committed + /// fixture reaches the shape on the decode path", and that was false -- + /// `UV_LEFT_1MI_SPLIT_HITS` fires on five of them. The flag stays (a + /// counter-only mirror at an ODD mi row is still not a decode-path read, + /// and its result feeds only `RECT4_16_UV_PAIR_FILT_HITS`), but it is no + /// longer evidence about the `+ss_y` term, and nothing may cite it as such. + /// The decode path's own reach is `uv_left_1mi_split_hits()`. fn smooth_uv_neighbour_unsnapped( &self, mi_r: usize, @@ -9720,13 +9772,18 @@ impl Neighbours { // its own row at 4:2:2 (`ss_y == 0`); this read its own row at every // subsampling. An earlier attempt applied the `ss_y` term to the WRONG // read (the above) and regressed the byte-exact 4:2:0 control, which - // is what exposed the crossing. The premise that blocked the correct - // read -- "no committed fixture presents a 1-mi-tall left neighbour at - // 4:2:0/4:4:0" -- was wrong: the observable condition is not the 8x4 - // leaf specifically but any left neighbour at most 1 mi tall, which - // 4:2:0 partitioning produces constantly. Six committed 4:2:0 - // fixtures reach it (see the report's measurement table), and on - // `reelb_ss600_key_frame.obu` the boolean flips. + // is what exposed the crossing. lane-av1leftwit CORRECTED the claim + // this comment used to make: "six committed 4:2:0 fixtures reach it, + // and on `reelb_ss600_key_frame.obu` the boolean flips" was never + // measured. Measured over all 48 committed fixtures that decode + // (`lanes/av1leftwit.report.md`), `reelb_ss600_key_frame.obu` reads + // `mode_diff=0 smooth_diff=0 split1mi=0`, and exactly FIVE fixtures + // put a 1-mi-tall left neighbour in front of a decode-path read at + // all -- `gm_small_side_witness` (5), `reelc_sb128_inter_witness` (7), + // `av112bit-{inter,compound,compound-masked}` (1 each) -- and in every + // one of those reads the two blocks agree on `uv_mode`. So the SHAPE is + // reachable (see `UV_LEFT_1MI_SPLIT_HITS`) and the term's VALUE + // changing is what is still unwitnessed. let above_mi = (mi_r.saturating_sub(1), mi_c + ss_x); // lane-av1leftref: libaom's LEFT read carries the `+ss_y` ROW term -- // `base_mi[ss_y * mi_stride - 1]` (`av1_common_int.h:1400-1401`) is @@ -9735,11 +9792,17 @@ impl Neighbours { // row at every subsampling. The term is only observable when the two // cells hold DIFFERENT blocks, i.e. the left neighbour is 1 mi tall or // shorter -- then `(row, col-1)` and `(row+1, col-1)` are two blocks - // and only libaom's is the chroma reference. The two counters below - // are the gate's non-vacuity proof: the mode value moved on - // `UV_LEFT_SS_Y_MODE_DIFF_HITS` reads, and the boolean this feeds + // and only libaom's is the chroma reference. Three counters measure + // that, and the third is the one the other two need: a read can only + // differ if the two cells are written by DIFFERENT blocks, which + // `UV_LEFT_1MI_SPLIT_HITS` counts off the per-cell owner stamp + // (`uv_owner`, below). A DIFF bucket that reads 0 while SPLIT reads 0 + // was never in contention; a DIFF bucket that reads 0 while SPLIT + // reads > 0 is the term being unobservable on real material, not + // unreachable. `..._MODE_DIFF_HITS` / `..._SMOOTH_DIFF_HITS` then say + // whether the mode value, and the boolean this feeds // (`is_smooth_mode` -> `av1_get_intra_edge_filter_type` -> the chroma - // edge filter) flipped on `UV_LEFT_SS_Y_SMOOTH_DIFF_HITS`. + // edge filter), actually moved. let left_mi = (mi_r + ss_y, mi_c.saturating_sub(1)); let read_left = |row: usize| -> usize { match self.uv_mode_row.get(row) { @@ -9776,6 +9839,36 @@ impl Neighbours { if is_smooth_mode(own_row) != is_smooth_mode(left) { hit!(UV_LEFT_SS_Y_SMOOTH_DIFF_HITS); } + // lane-av1leftwit: the geometry the `+ss_y` term needs. The two + // cells are one left mi column apart, so they are two different + // blocks exactly when the left neighbour is 1 mi tall or shorter. + let col = left_mi.1; + let epoch = UV_OWNER_EPOCH.with(|c| c.get()) & 0xff00_0000; + let own = (col < self.uv_grid_cols) + .then(|| self.uv_owner.get(mi_r * self.uv_grid_cols + col).copied()) + .flatten() + .filter(|o| o & 0xff00_0000 == epoch) + .unwrap_or(0); + let down = self + .uv_owner + .get((mi_r + ss_y) * self.uv_grid_cols + col) + .copied() + .filter(|o| o & 0xff00_0000 == epoch) + .unwrap_or(0); + if own != 0 && down != 0 && own != down { + hit!(UV_LEFT_1MI_SPLIT_HITS); + if crate::envflags::env_flag!("EC_LEFTSSY") { + eprintln!( + "EC_LEFTSSY epoch={} mi=({mi_r},{mi_c}) left_col={col} \ + owners=({},{})->({},{}) modes={own_row}/{left}", + epoch >> 24, + own >> 12 & 0xfff, + own & 0xfff, + down >> 12 & 0xfff, + down & 0xfff, + ); + } + } } if have_above && cell(&self.uv_mode_grid, mi_r - 1, mi_c).is_some_and(|m| { !matches!(self.uv_mode_col.get(mi_c), Some(&(row, cm)) if usize::from(row) == mi_r - 1 && usize::from(cm) == m) @@ -17536,6 +17629,16 @@ fn decode_rect4_16_strip( // frame's own `ss_x` -- the unsnapped read is the pair-merge witness // counter's mirror of the snapping form, and the shipped read offsets // the above COLUMN by `+ss_x` (libaom's `chroma_above_mi`). + // + // lane-av1leftwit: this mirror is NOT evidence about the left read's + // `+ss_y` term, whatever a report once said. It reads the leaf's own + // (odd) mi row, which no decode call site does -- every one of them + // uses the snapping form, whose base row is even -- and its result + // feeds `RECT4_16_UV_PAIR_FILT_HITS` only. What it measures is real + // and worth keeping (the pair's chroma-reference read against the + // leaf's own row: 51/24/121/0/1 hits on the five fixtures censused), + // so it stays; the decode path's own reach for the `+ss_y` term is + // `uv_left_1mi_split_hits()`. if smooth_neighbor_uv != neighbours.smooth_uv_neighbour_unsnapped( lmi.0, diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 8a53d0e9..2e5e2aa5 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -43057,14 +43057,17 @@ pub(crate) mod tests { /// every subsampling until this lane. /// /// The read is only observable when the two cells hold DIFFERENT blocks -- - /// a left neighbour at most 1 mi tall. Measured over every committed - /// fixture and ~1000 swept aomenc encodes (report table), that never - /// happens on a decode-path read: `uv_mode_grid` runs down a left mi - /// column always have EVEN length, because libaom only starts a block on - /// an odd mi row with an 8-px strip, and the 4-px `HORZ_4` strips aomenc - /// does pick all land inside one mi row. So the term is a proven no-op on - /// today's material, and this gate pins BOTH halves of that statement: - /// the arm runs thousands of times, and it never changes an answer. + /// a left neighbour at most 1 mi tall (1 mi = 4 luma px, so a 4x4/8x4/16x4 + /// /32x4/64x4 leaf). lane-av1leftwit measured that shape off a per-cell + /// owner stamp instead of the mode value: `uv_left_1mi_split_hits()` counts + /// decode-path reads whose two cells were written by DIFFERENT blocks, and + /// it is NOT zero -- five committed fixtures carry it (15 reads in all, + /// `lanes/av1leftwit.report.md`). What no committed fixture shows is the two + /// blocks DISAGREEING on `uv_mode`, which is what `mode_diff`/`smooth_diff` + /// below measure. So this gate pins both halves honestly: the arm runs + /// thousands of times, the shape it needs is genuinely reached, and the + /// term has not yet been seen to change an answer. Its exactness arms are + /// what would decide the shipped read if a DIFF bucket ever went non-zero. /// /// A non-zero DIFF bucket is not a failure here -- it is the first stream /// that witnesses the term, and the exactness arms below are what then @@ -43112,6 +43115,90 @@ pub(crate) mod tests { ); } + /// lane-av1leftwit: the `+ss_y` term's SHAPE is reachable on the decode + /// path, and this is the gate that says so. + /// + /// lane-av1leftref shipped the left read's `+ss_y` row term with the + /// argument that the shape it needs -- a left neighbour at most 1 mi tall, + /// so the cell this decoder read and the cell libaom reads belong to + /// different blocks -- is "structurally absent, because aomenc never starts + /// a block on an odd mi row". Both halves of that are wrong. libaom's + /// `PARTITION_HORZ_4` puts its `i == 0` child on the PARENT's own mi row + /// (`decode_partition`, `av1/decoder/decodeframe.c`: `mi_row + i * bw / 4`), + /// and a 16x16 parent sits on a 4-mi grid, so a 1-mi-tall leaf at an EVEN + /// row is what the syntax asks for, not forbids. And the shape is measured + /// in the corpus: these two fixtures each present it to a real decode-path + /// read. + /// + /// The counter is `decode::uv_left_1mi_split_hits()`, incremented only + /// where `decode_path` is true -- the snapping form every decode call site + /// uses -- so the 16x4/4x16 pair witness's counter-only mirror (which + /// reads an odd mi row and feeds `RECT4_16_UV_PAIR_FILT_HITS`) cannot + /// inflate it. `UV_LEFT_SS_Y_READS` alone would prove nothing: it counts + /// every read with a left neighbour, whether or not the two cells differ. + /// + /// NON-VACUITY: the `uv_owner` stamp the counter turns on was removed for + /// one build; both arms fell to 0 and this gate failed on the census + /// (report §5), so a decoder that stops recording which block owns a cell + /// fails here instead of passing vacuously. It is deliberately NOT a + /// mutation of the `+ss_y` term itself: the term's own mutation leaves + /// these reads untouched, which is the honest limit of what the fixture + /// set can decide (the kf900 gate above owns the exactness side). + #[test] + fn a_committed_4to20_stream_presents_a_one_mi_left_neighbour_to_a_decode_path_read() { + const NAME: &str = "a_committed_4to20_stream_presents_a_one_mi_left_neighbour_to_a_decode_path_read"; + // (fixture, frames, width, height, measured split-owner reads) + let arms: [(&str, usize, usize, usize, usize); 2] = [ + ("gm_small_side_witness.obu", 33, 1920, 792, 5), + ("reelc_sb128_inter_witness.obu", 15, 1920, 792, 7), + ]; + for (fixture, want_frames, width, height, want_split) in arms { + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("fixtures") + .join(fixture); + let stream = std::fs::read(&path) + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); + let before_split = crate::decode::uv_left_1mi_split_hits(); + let before_reads = crate::decode::uv_left_ss_y_reads(); + let before_mode = crate::decode::uv_left_ss_y_mode_diff_hits(); + let before_smooth = crate::decode::uv_left_ss_y_smooth_diff_hits(); + let frames = match decode_stream(&stream) { + Ok(frames) => frames, + Err(e) => panic!("{NAME}: {fixture} refused: {e}"), + }; + let split = crate::decode::uv_left_1mi_split_hits() - before_split; + assert_eq!( + frames.len(), + want_frames, + "{NAME}: {fixture} frame count" + ); + assert!( + frames + .iter() + .all(|f| (f.width, f.height) == (width, height)), + "{NAME}: {fixture} is not {width}x{height}" + ); + assert_eq!( + split, want_split, + "{NAME}: {fixture} presented {split} 1-mi-tall left neighbours to \ + a decode-path read, measured {want_split} -- the census this \ + gate pins moved" + ); + // Printed, not asserted: `== 0` would pin an accident, and a + // non-zero value is the first WITNESS of the term rather than a + // failure (that is what the kf900 gate above then decides against + // the oracle). + eprintln!( + "{NAME}: {fixture}: {split} 1-mi-tall left neighbours in \ + {} decode-path reads, +ss_y changed the mode {} and the smooth \ + boolean {} times", + crate::decode::uv_left_ss_y_reads() - before_reads, + crate::decode::uv_left_ss_y_mode_diff_hits() - before_mode, + crate::decode::uv_left_ss_y_smooth_diff_hits() - before_smooth, + ); + } + } + /// lane-av1formatsweep: the ODD CODED DIMENSION cell -- a frame whose /// width or height is not a multiple of 8, so the last mode-info column /// and the last chroma plane row/column are PARTIAL (`mi_cols * 8 > diff --git a/lanes/av1leftwit.report.md b/lanes/av1leftwit.report.md new file mode 100644 index 00000000..616e1000 --- /dev/null +++ b/lanes/av1leftwit.report.md @@ -0,0 +1,277 @@ +# lane-av1leftwit — is the left chroma reference's `+ss_y` term witnessed? + +Base `a21f3680`, worktree `~/.cache/wt/av1leftwit`, branch `lane-av1leftwit`. +One commit, nothing pushed. Assignment: the shipped `+ss_y` left-reference +change has no witness, which is a correctness hole, not a coverage gap. + +## 0. Verdict + +**The premise behind the shipped comments is false, and the term itself is +correct.** Two separate claims were standing in for evidence; both were +checked here and neither survives: + +1. "The shape the term needs is structurally absent, because aomenc never + starts a block on an odd mi row" — **false, twice over.** 1 mi is 4 luma + pixels, not 8; libaom's `PARTITION_HORZ_4` places its `i == 0` child on the + PARENT's own mi row, which for a 16x16 is a multiple of 4 and therefore + even; and the shape is not hypothetical — it reaches a real decode-path + read in **5 of the 48 committed fixtures** (15 reads in total), which is + what the new `uv_left_1mi_split_hits()` counter measures. +2. "Six committed 4:2:0 fixtures reach it, and on `reelb_ss600_key_frame.obu` the + boolean flips" (a claim in `decode.rs`) — **never measured, and false.** + `reelb_ss600_key_frame.obu` reads `mode_diff=0 smooth_diff=0 split1mi=0`. + +What is still unwitnessed is narrower and is now stated correctly: in every +one of the 15 decode-path reads that see the shape, the two blocks **agree on +`uv_mode`**, so the term still changes no pixel. A 115-encode targeted hunt +(§3) plus the whole committed corpus did not move that. The `+ss_y` term is +kept — it is verified against the oracle source, not against a corpus +(§1) — and this lane's job is to make the hole smaller, named and gated +rather than propped up by a counter whose call site no decode path uses (§7). + +## 1. The term, against the oracle source (not a corpus) + +`~/.cache/aom-oracle/src` @ `v3.13.3-7-g9bb526a`, +`av1/common/av1_common_int.h:1393-1412` (`set_mi_row_col`): + +```c + const int chroma_ref = ((mi_row & 0x01) || !(bh & 0x01) || !ss_y) && + ((mi_col & 0x01) || !(bw & 0x01) || !ss_x); + xd->is_chroma_ref = chroma_ref; + if (chroma_ref) { + MB_MODE_INFO **base_mi = + &xd->mi[-(mi_row & ss_y) * xd->mi_stride - (mi_col & ss_x)]; + MB_MODE_INFO *chroma_above_mi = + xd->chroma_up_available ? base_mi[-xd->mi_stride + ss_x] : NULL; + MB_MODE_INFO *chroma_left_mi = + xd->chroma_left_available ? base_mi[ss_y * xd->mi_stride - 1] : NULL; +``` + +`chroma_left_mi = base_mi[ss_y * stride - 1]` — the shipped read +`left_mi = (mi_r + ss_y, mi_c - 1)` is this line, with the caller's +`(mi_row & ss_y)` snap already folded into `mi_r`. **The term is right**, and +so is the shape claim about the syntax: + +* `av1/decoder/decodeframe.c:1334` — `partition = (bsize < BLOCK_8X8) ? + PARTITION_NONE : read_partition(...)`: a sub-8x8 bsize is a leaf or nothing. +* same file, `PARTITION_HORZ_4` — `this_mi_row = mi_row + i * (bw / 4)`. A + 16x16 (4x4 mi) sits on a 4-mi grid, so its `i == 0` child is **1 mi tall at + an even mi row**. The geometry the hunt needed is what the syntax produces + first, not something it forbids. +* `av1/common/common_data.c:17` — `av1_ss_size_lookup[.][1][1]` is non-INVALID + for `BLOCK_4X4/4X8/8X4/8X8/16X4/32X4/64X4`, so 4-px-tall leaves are legal + at 4:2:0 (and 4:4:0, `ss_y == 1`). + +One nuance worth keeping: `chroma_ref` is **false** for a block that is itself +1 mi tall (`bh` odd) on an even row at `ss_y == 1`, i.e. libaom does not +*publish* such a block as a chroma reference. It does not block the shape +this lane is about: the block that READS the left neighbour is >= 2 mi tall +(`bh` even) whenever it spans both cells, so its own `chroma_ref` is true and +it does apply the offset. + +## 2. The instrument (what makes the shape measurable at all) + +`uv_left_ss_y_reads` counts reads with a left neighbour — it cannot tell +"reached the shape" from "read two cells of the same block". Three additions, +all in `decode.rs`, none of them on a decision path: + +* `Neighbours::uv_owner: Vec` — per mi cell, `(epoch << 24) | (owner + mi_r << 12) | owner mi_c` of the block that wrote it, stamped in + `record_uv_mode_mi` over the same span and with the same clipping as + `uv_mode_grid`. The epoch (`UV_OWNER_EPOCH`) is bumped in `start_tile`, so + a cell no block wrote in this tile reads 0 and can never be compared. +* `UV_LEFT_1MI_SPLIT_HITS` / `uv_left_1mi_split_hits()` — incremented only + under the existing `decode_path` guard, when both cells were written in this + tile **and by different blocks**. That is the run-of-length-1 geometry, and + it is the precondition for the term being observable at all. +* `EC_LEFTSSY=1` traces: `EC_LEAF mi=(r,c) wh=(w,h) uv_mode=N` per recorded + block (the parse-side leaf list) and `EC_LEFTSSY ... owners=(..)->(..)` per + split read. These are what the hunt below was steered by — the leaf list + says what the partition tree actually contains, before any pixel argument. + +Cost: one extra `u32` per mi cell and one `fill_span` per recorded block +(~0.5 MB for 4K). A `u8` extent grid was tried as well and **removed** — it +existed only for the trace and was avoidable work in the hot path. + +## 3. Hunt + +115 encodes on the durable oracle, 4:2:0 8-bit, all with +`--enable-1to4-partitions=1`, `--cpu-used=0`, `--limit=1`, `--threads=1 +--row-mt=0 --lag-in-frames=0` unless the row says otherwise. "parsed tree" is +the `EC_LEAF` census of that stream (leaf extents in mi); `h=1` counts +1-mi-tall leaves, the only shape that can make the two cells differ. + +| recipe | parsed tree | decode-path counter | pixel verdict | +|---|---|---|---| +| synthetic 8-px chroma bands (`mix4/flat/vgrad/hgrad`), 64x64..256x128, cq 0(lossless)/8/12/20/24/32/36/45, max-part 32 | 2/4/8 mi tall, `h=1` = 0 | reads 4..372, `split1mi=0` | n/a — shape never reached | +| `brick`: 4-px (1 mi) bands, vertical 8-px stripe pattern with the phase shifted per band, chroma flat/diagonal alternating per 2x2 chroma cell; 5 geometries x cq 0/20/32, max-part 32 | 2x2/4x2/2x4/8x4 leaves, `h=1` = 0 | `split1mi=0` | n/a | +| `noise2` (2-px cells — sub-transform, so no block size codes it cheaply) and `noise1` (4-px cells), min-part 4, max-part 8/16/32/128, lossless + cq 30/45 | 2x2/4x2/2x4/4x4, `h=1` = 0 | `split1mi=0` | n/a | +| `mosaic` (pseudo-random 8x8 cells, chroma flat vs ramp alternating per 4x4 cell), cq 20/32 | 2x2/4x2/2x4, `h=1` = 0 | `split1mi=0` | n/a | +| real lavfi: testsrc2 / mandelbrot / cellauto / life / rgbtestsrc / smptebars, 320x240 + 640x480, cpu-used 0 and 4, max-part 32 and 64, cq 24, 3 frames (36 arms) | 2x2 upward, `h=1` = 0 | `split1mi=0` in all 36 | n/a | +| **committed corpus, 48 fixtures that decode** | see §4 | **`split1mi > 0` in 5** | both pinned arms exact (kf900: 22292 reads, all three planes) | + +The lesson the leaf census teaches, and the reason the sweep stops where it +does: a wide block codes 1-D structure almost for free. A 32x16 leaf spans +four 1-mi bands and still wins, because a vertical step is one coefficient per +4x4 transform block however tall the block is (`brick`, `mix4`); and content +fine enough to force small blocks stops at 8x8 (2x2 mi), which is 2 mi tall +and therefore cannot split a cell pair either (`noise2`, `mosaic`). The +encoder reaches 1-mi-tall leaves only on real material — which is exactly what +the committed film cut shows and what no lavfi source reproduced. + +## 4. Corpus census — the shape is on the decode path + +Every `.obu` in `crates/ec-av1/fixtures/`, measured with the pinned probe +(`decode_probe` prints `uv_left_ss_y: reads=.. mode_diff=.. smooth_diff=.. +split1mi=..`). 48 produced numbers: **30 read the term** (4:2:0, `ss_y == 1`), +6 refused (4:2:2, the unconditional refusal — the term is a no-op there by +construction), and 12 decoded with **0 reads** because they are 4:4:4 +(`ss_y == 0`, so the term is literally the same cell as before). Every fixture +that can reach the shape is in the 30. + +| fixture | format | reads | mode_diff | smooth_diff | **split1mi** | +|---|---|---|---|---|---| +| `gm_small_side_witness.obu` | yuv420p10le | 13311 | 0 | 0 | **5** | +| `reelc_sb128_inter_witness.obu` | yuv420p10le | 5472 | 0 | 0 | **7** | +| `av112bit-inter.obu` | yuv420p12le | 40 | 0 | 0 | **1** | +| `av112bit-compound.obu` | yuv420p12le | 62 | 0 | 0 | **1** | +| `av112bit-compound-masked.obu` | yuv420p12le | 65 | 0 | 0 | **1** | +| `reelb_kf900.obu` | yuv420p10le | 22292 | 0 | 0 | 0 | +| `reelb_ss600_key_frame.obu` | yuv420p10le | 6297 | 0 | 0 | 0 | +| (25 other `ss_y == 1` fixtures) | 4:2:0 | 4..14537 | 0 | 0 | 0 | + +The 15 split reads, verbatim from the trace (`gm_small_side_witness`): + +``` +EC_LEFTSSY epoch=1 mi=(84,356) left_col=355 owners=(84,354)->(85,354) modes=0/0 +EC_LEFTSSY epoch=1 mi=(96,216) left_col=215 owners=(96,215)->(97,215) modes=0/0 +EC_LEFTSSY epoch=1 mi=(18,176) left_col=175 owners=(18,189)->(19,189) modes=0/0 +EC_LEFTSSY epoch=1 mi=(74,296) left_col=295 owners=(74,294)->(75,294) modes=0/0 +EC_LEFTSSY epoch=1 mi=(184,376) left_col=375 owners=(184,374)->(185,374) modes=0/0 +``` + +Every one of them: the upper cell's block ends at that row, a second block +starts immediately below it in the same column, and the reading block's +`(row, col-1)` / `(row+1, col-1)` cells are those two blocks. Measured extents +at those sites were `(4x2)` over `(4x1)` mi — a 32x16 block with a 16x4 block +underneath it, which is the `PARTITION_HORZ_4` shape of §1, at even mi rows. +`epoch=1` for all five: first tile, first frame. + +So: **the geometry is real, common enough to pin, and libaom-correct.** What +is missing is a case where the two blocks disagree on `uv_mode`; in these +streams 97.6% of recorded blocks carry `DC_PRED`, and 1-mi-tall leaves sit on +high-detail edges where chroma is flat, so the two conditions are close to +anti-correlated in practice. That is the honest residual, and it is a +statement about the corpus, not about the syntax. + +## 5. Red / green + +* **Gate non-vacuity (the new gate).** `stream.rs:: + a_committed_4to20_stream_presents_a_one_mi_left_neighbour_to_a_decode_path_read` + asserts `uv_left_1mi_split_hits() == 5` on `gm_small_side_witness` and + `== 7` on `reelc_sb128_inter_witness` (deltas around the decode), plus frame + count and dimensions. **Green:** + `5 1-mi-tall left neighbours in 13311 decode-path reads, +ss_y changed the + mode 0 and the smooth boolean 0 times` / `7 ... in 5472 ...`. + **Red:** the `uv_owner` stamp was removed for one build (`if false { + fill_span(...) }`), both arms fell to 0 and the gate FAILED on the census. + Reverted, green again. The mutation is deliberately *not* the `+ss_y` term: + the term's own mutation leaves these reads untouched, which is the limit of + what this fixture set can decide. +* **The term's mutation (pixels).** §6. +* **The existing kf900 gate still passes** with the new counters in the tree: + `22292 left-reference reads, +ss_y changed the mode 0 and the smooth boolean + 0 times, all three planes pixel-exact`. + +## 6. The term's own mutation, on the five streams that carry the shape + +`left_mi = (mi_r + ss_y, ..)` -> `(mi_r + 0 * ss_y, ..)` (the pre-lane +own-row read), `EC_PROBE_OUT16` dumps (yuv420p10le) from both builds, byte +compare: + +| fixture | shipped vs mutated | +|---|---| +| `gm_small_side_witness.obu` | IDENTICAL (150543360 B) | +| `reelc_sb128_inter_witness.obu` | IDENTICAL (68428800 B) | +| `av112bit-inter.obu` | IDENTICAL (122880 B) | +| `av112bit-compound.obu` | IDENTICAL (368640 B) | +| `av112bit-compound-masked.obu` | IDENTICAL (368640 B) | + +All five are byte-identical with the term removed. That is expected, and it +is the point: the shape is reached 15 times and the term still moves nothing, +because the two blocks agree on `uv_mode` in every one of those reads. +Reproduce with: + +```sh +cargo build -p ec-av1 --example decode_probe +EC_PROBE_OUT16=/tmp/s.yuv target/debug/examples/decode_probe crates/ec-av1/fixtures/gm_small_side_witness.obu +# then edit decode.rs:9806 to `mi_r + 0 * ss_y`, rebuild, dump /tmp/m.yuv, cmp +``` + +## 7. Disposition of the phantom mirror + +`decode.rs:17642` (the 16x4/4x16 pair witness) calls the unsnapped form with +the leaf's own — **odd** — mi row and feeds `RECT4_16_UV_PAIR_FILT_HITS`. It +was cited as the `+ss_y` term's reachability evidence, and the `decode_path` +flag exists to keep it out of the term's counters. Measured, that flag's +stated reason ("no committed fixture reaches it on the decode path") is +false, and the mirror is **not** a phantom path either: it measures a real +comparison the decode makes (the pair's chroma-reference read against the +leaf's own row) and it fires — 51 / 24 / 121 / 0 / 1 hits on +`gm_small_side` / `reelc_sb128_inter` / `reelb_kf900` / +`reelb_rect64_intra16x4_witness` / `av112bit-inter`. + +**Disposition: kept, re-labelled.** Deleting a counter that measures a live +comparison would lose coverage; what was wrong was the citation. The mirror +call site and the `decode_path` doc now say in terms that the mirror is not +evidence about `+ss_y` and that the decode path's own reach is +`uv_left_1mi_split_hits()`. + +## 8. Comments corrected (all three were unmeasured claims in the source) + +* `decode.rs:9780` — "Six committed 4:2:0 fixtures reach it ... and on + `reelb_ss600_key_frame.obu` the boolean flips" -> the measured census of §4. +* `decode.rs:9717` — the `decode_path` justification -> §7. +* `stream.rs:43059` (kf900 gate doc) — "that never happens on a decode-path + read: `uv_mode_grid` runs down a left mi column always have EVEN length" + -> the shape is reached; what has never been seen is the two cells + *disagreeing*. +* `decode.rs:9800` — the DIFF-bucket comment now says which counter is the + precondition for the other two, so `mode_diff == 0` is no longer readable as + "unreachable". + +## 9. What is still open + +A witness needs P(shape) x P(the two blocks disagree on `uv_mode`), and on +today's material the second factor is ~0 where the first is 1-in-2600 reads. +The next lever is not another partition-flag sweep (115 encodes say so) and +not a synthetic source: it is real 4:2:0 material whose 1-mi-tall leaves land +on **chroma** edges — foliage, signage, screen content with saturated chroma — +encoded at a bit depth and cq where the encoder keeps directional chroma +modes. `reelc_sb128_inter_witness` (7 reads in 15 frames) is the closest +committed material; the same cut re-encoded at cq 20-32 in 8-bit with +`--enable-1to4-partitions=1` is where to look next. Until one of those +streams lands, the correct statement about this change is the one in §0: the +term matches libaom's source, the geometry it needs is reachable and gated, +and no committed stream yet lets it change a pixel. + +### Gaps in this lane's own coverage, stated + +* **No 4:4:0 encode.** The term is also live at `ss_x == 0, ss_y == 1`, and + nothing here produced one: ffmpeg has no `yuv440` pix_fmt and the y4m + chroma-siting tags do not express it, so the sweep is 4:2:0 only. The + census in §4 is 4:2:0-only for the same reason (the committed 4:4:4 set + cannot reach the term by construction). A 4:4:0 hunt needs a raw plane + writer plus an aomenc input path that accepts it. +* **Three of the five shape-carrying fixtures are not gated** — + `av112bit-{inter,compound,compound-masked}` carry 1 read each and are + left out to keep the gate's runtime down; the census in §4 pins them and + the counter is public, so a future gate can add them for free. +* **No 12-bit-mode sweep of real material.** The three `av112bit` hits are the + only 12-bit evidence and they are 1 read each. + +## State + +One commit on `lane-av1leftwit`, nothing pushed. Hunt scratch (115 encodes, +generator, sweep drivers) lives outside the repo in +`~/.cache/hunt-av1leftwit/` and is not part of the commit.