forge
Explore
Log in

Don't you dare go Hollow

lane-av1leftwit: the +ss_y left-reference shape is reachable, and pinned

Browse files at this commit

aec3e0f906238d191eda5fe36569b013184f3c73Ahmet Kaan GümüşParent: a460dca
The shipped `+ss_y` term on `smooth_uv_neighbour_unsnapped`'s left read had no
witness, and the two claims standing in for evidence were both wrong.

1. "Structurally absent, because aomenc never starts a block on an odd mi
   row" -- 1 mi is 4 luma px, not 8; libaom's PARTITION_HORZ_4 puts its
   `i == 0` child on the PARENT's own mi row, which for a 16x16 is a multiple
   of 4 and therefore even (av1/decoder/decodeframe.c, `mi_row + i * bw / 4`),
   and av1_ss_size_lookup[..][1][1] is non-INVALID for every 4-px-tall bsize.
2. "Six committed 4:2:0 fixtures reach it, and on reelb_ss600_key_frame.obu the
   boolean flips" (a comment in decode.rs) -- never measured. Measured over all
   48 committed fixtures that decode, reelb_ss600 reads mode_diff=0
   smooth_diff=0 split1mi=0.

`uv_left_ss_y_reads` cannot tell "reached the shape" from "read two cells of
the same block", which is why both claims survived. New `uv_owner` per-cell
owner stamp (epoch-tagged per tile, written beside `uv_mode_grid`) plus
`UV_LEFT_1MI_SPLIT_HITS` / `uv_left_1mi_split_hits()` count decode-path reads
whose two cells were written by different blocks -- the run-of-length-1
geometry. It is NOT zero: 5 of 48 fixtures, 15 reads (gm_small_side 5,
reelc_sb128_inter 7, av112bit-{inter,compound,compound-masked} 1 each), all on
the decode path, all at even mi rows, with a 32x16 block above a 16x4 one.

The term is kept: `chroma_left_mi = base_mi[ss_y * mi_stride - 1]`
(av1_common_int.h:1411) is exactly the shipped read. What stays unwitnessed is
narrower and now says so: in all 15 reads the two blocks agree on `uv_mode`,
so the term moves no pixel (byte-identical on all five with the term reverted,
§6 of the report). A 115-encode targeted hunt -- 1-mi chroma bands, phase-
shifted vertical stripes, sub-transform noise, random mosaics, 36 real lavfi
arms, min/max-partition 4..128, lossless and cq 8..45 -- produced no
1-mi-tall leaf at all, and the `EC_LEFTSSY` leaf census says why: a wide block
codes 1-D structure almost for free, and content fine enough to force small
blocks stops at 8x8, which is 2 mi tall.

Gate: `a_committed_4to20_stream_presents_a_one_mi_left_neighbour_to_a_decode_path_read`
pins the census on two fixtures. Non-vacuous: removing the `uv_owner` stamp
drops both arms to 0 and fails it. Deliberately NOT a mutation of the term
itself, which leaves these reads untouched.

The 16x4/4x16 pair witness's counter-only mirror (decode.rs:17629) is kept --
it measures a live comparison and fires 51/24/121/0/1 on the fixtures
censused -- but both it and the `decode_path` flag no longer claim to be
evidence about this term.

Report: lanes/av1leftwit.report.md (hunt table, corpus census, red/green).
crates/ec-av1/examples/decode_probe.rsmodified+7 -2
@@ -51,12 +51,17 @@ fn main() {
5151 ec_av1::decode::chroma422_pair_wide_hits()
5252 );
5353 println!(
54- "uv_left_ss_y: reads={} mode_diff={} smooth_diff={}",
54+ "uv_left_ss_y: reads={} mode_diff={} smooth_diff={} split1mi={}",
5555 ec_av1::decode::uv_left_ss_y_reads(),
5656 ec_av1::decode::uv_left_ss_y_mode_diff_hits(),
57- ec_av1::decode::uv_left_ss_y_smooth_diff_hits()
57+ ec_av1::decode::uv_left_ss_y_smooth_diff_hits(),
58+ ec_av1::decode::uv_left_1mi_split_hits(),
5859 );
5960 let (h, v, c) = ec_av1::stream::rect4_32_counters();
61+ println!(
62+ "rect4_16_uv_pair_filt: {}",
63+ ec_av1::decode::rect4_16_uv_pair_filt_hits()
64+ );
6065 println!("rect4_32: horz={h} vert={v} coded={c}");
6166 println!(
6267 "rect_intrabc_reads: {}",
crates/ec-av1/src/decode.rsmodified+119 -16
@@ -5696,6 +5696,27 @@ pub fn uv_left_ss_y_smooth_diff_hits() -> usize {
56965696 UV_LEFT_SS_Y_SMOOTH_DIFF_HITS.with(|c| c.get())
56975697 }
56985698
5699+// lane-av1leftwit: decode-path chroma edge-filter-type reads at `ss_y > 0`
5700+// whose left-neighbour COLUMN holds a run of length 1 -- the cell this
5701+// decoder reads (its own mi row) and the cell libaom reads (one row down)
5702+// were written by two DIFFERENT blocks, i.e. the left neighbour is at most
5703+// 1 mi tall. That is the only geometry in which the `+ss_y` term can change
5704+// the answer at all; `UV_LEFT_SS_Y_READS` alone proves nothing about it.
5705+thread_local! {
5706+ static UV_LEFT_1MI_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
5707+}
5708+
5709+/// Current value of [`UV_LEFT_1MI_SPLIT_HITS`].
5710+pub fn uv_left_1mi_split_hits() -> usize {
5711+ UV_LEFT_1MI_SPLIT_HITS.with(|c| c.get())
5712+}
5713+
5714+// lane-av1leftwit: the per-tile epoch `uv_owner` cells are stamped with.
5715+// Bumped in `Neighbours::start_tile`; never read by decode logic.
5716+thread_local! {
5717+ static UV_OWNER_EPOCH: std::cell::Cell<u32> = const { std::cell::Cell::new(0) };
5718+}
5719+
56995720 // lane-cfl r1 gate counters: `UV_CFL_PRED` blocks (every `cfl_alpha_signs`
57005721 // read) and chroma blocks with a NONZERO `angle_delta_uv` -- the two block
57015722 // shapes the r1 chroma defect showed up on.
@@ -8228,6 +8249,16 @@ struct Neighbours {
82288249 /// [`Self::uv_mode_grid`]'s stride, in mi units (superblock-padded, like
82298250 /// every other band here).
82308251 uv_grid_cols: usize,
8252+ /// lane-av1leftwit: which BLOCK wrote each cell of [`Self::uv_mode_grid`],
8253+ /// as `(epoch << 24) | (mi_r << 12) | mi_c` of the writing block's own
8254+ /// top-left mi. The `uv_mode` value alone cannot answer "are the two cells
8255+ /// the `+ss_y` read compares written by the same block?", which is the
8256+ /// whole question the `+ss_y` term turns on: the term is only observable
8257+ /// when the left neighbour is 1 mi tall, i.e. when the cell this decoder
8258+ /// used to read and the cell libaom reads hold DIFFERENT blocks. `epoch`
8259+ /// is [`UV_OWNER_EPOCH`], bumped once per tile, so a cell no block wrote
8260+ /// in this tile can never be mistaken for a written one.
8261+ uv_owner: Vec<u32>,
82318262 /// Whether the block above/left of this column/row was coded `skip` --
82328263 /// an inter frame's own `skip` context (spec `SkipContext`), which the
82338264 /// key-frame writer never tracks (its skip context is always zero); a
@@ -8421,6 +8452,7 @@ impl Neighbours {
84218452 uv_mode_row: vec![(u16::MAX, 0); rows * (SUB / MI)],
84228453 uv_mode_grid: vec![u8::MAX; cols * (SUB / MI) * rows * (SUB / MI)],
84238454 uv_grid_cols: cols * (SUB / MI),
8455+ uv_owner: vec![0; cols * (SUB / MI) * rows * (SUB / MI)],
84248456 above_txfm: vec![TXFM_CTX_INIT; cols * (SUB / MI)],
84258457 left_txfm: vec![TXFM_CTX_INIT; rows * (SUB / MI)],
84268458 // lane-inter8 r2: mi(4px)-granular, not [`SUB`]-granular -- an
@@ -8490,6 +8522,10 @@ impl Neighbours {
84908522 // lane-seg: `AvailU`/`AvailL` for the segment-id neighbour prediction
84918523 // are tile-relative, same as every other neighbour lookup here.
84928524 fctx.seg_tile_origin.with(|c| c.set((row0_mi, col0_mi)));
8525+ // lane-av1leftwit: a fresh epoch stamps every `uv_owner` cell this
8526+ // tile writes, so the `+ss_y` read's "different block?" probe never
8527+ // compares against a cell a previous tile left behind.
8528+ UV_OWNER_EPOCH.with(|c| c.set(c.get().wrapping_add(1) | (1 << 24)));
84938529 self.tile_row0_mi = row0_mi;
84948530 self.tile_col0_mi = col0_mi;
84958531 let end = col1_mi.min(self.above.len());
@@ -9599,6 +9635,17 @@ impl Neighbours {
95999635 uv_mode as u8,
96009636 );
96019637 }
9638+ // lane-av1leftwit: stamp the writing block's own mi over its extent,
9639+ // the same cells and the same clipping as `uv_mode_grid` above.
9640+ let owner = UV_OWNER_EPOCH.with(|c| c.get()) | ((mi_r as u32) << 12) | mi_c as u32;
9641+ for row in mi_r..=last_r {
9642+ fill_span(&mut self.uv_owner, row * stride + mi_c, n, owner);
9643+ }
9644+ if crate::envflags::env_flag!("EC_LEFTSSY") {
9645+ eprintln!(
9646+ "EC_LEAF mi=({mi_r},{mi_c}) wh=({mi_w},{mi_h}) uv_mode={uv_mode}"
9647+ );
9648+ }
96029649 }
96039650
96049651 /// Whether either mi-exact chroma neighbour of the block at `(mi_r, mi_c)`
@@ -9659,11 +9706,16 @@ impl Neighbours {
96599706 /// decode path uses the snapping form.
96609707 /// `decode_path` is `true` only for the snapping form every decode call
96619708 /// site uses; the 16x4/4x16 pair witness's mirror passes `false`, so the
9662- /// `+ss_y` counters measure the read that actually filters a chroma edge
9663- /// and not the counter-only one. (The mirror reads an ODD mi row -- the
9664- /// pair's chroma-reference half -- where the two cells differ far more
9665- /// often; counting it would make this lane look reachable when no
9666- /// committed fixture reaches it on the decode path.)
9709+ /// `+ss_y` counters measure a read that actually filters a chroma edge and
9710+ /// not the counter-only one.
9711+ ///
9712+ /// lane-av1leftwit: the mirror's justification used to be "no committed
9713+ /// fixture reaches the shape on the decode path", and that was false --
9714+ /// `UV_LEFT_1MI_SPLIT_HITS` fires on five of them. The flag stays (a
9715+ /// counter-only mirror at an ODD mi row is still not a decode-path read,
9716+ /// and its result feeds only `RECT4_16_UV_PAIR_FILT_HITS`), but it is no
9717+ /// longer evidence about the `+ss_y` term, and nothing may cite it as such.
9718+ /// The decode path's own reach is `uv_left_1mi_split_hits()`.
96679719 fn smooth_uv_neighbour_unsnapped(
96689720 &self,
96699721 mi_r: usize,
@@ -9720,13 +9772,18 @@ impl Neighbours {
97209772 // its own row at 4:2:2 (`ss_y == 0`); this read its own row at every
97219773 // subsampling. An earlier attempt applied the `ss_y` term to the WRONG
97229774 // read (the above) and regressed the byte-exact 4:2:0 control, which
9723- // is what exposed the crossing. The premise that blocked the correct
9724- // read -- "no committed fixture presents a 1-mi-tall left neighbour at
9725- // 4:2:0/4:4:0" -- was wrong: the observable condition is not the 8x4
9726- // leaf specifically but any left neighbour at most 1 mi tall, which
9727- // 4:2:0 partitioning produces constantly. Six committed 4:2:0
9728- // fixtures reach it (see the report's measurement table), and on
9729- // `reelb_ss600_key_frame.obu` the boolean flips.
9775+ // is what exposed the crossing. lane-av1leftwit CORRECTED the claim
9776+ // this comment used to make: "six committed 4:2:0 fixtures reach it,
9777+ // and on `reelb_ss600_key_frame.obu` the boolean flips" was never
9778+ // measured. Measured over all 48 committed fixtures that decode
9779+ // (`lanes/av1leftwit.report.md`), `reelb_ss600_key_frame.obu` reads
9780+ // `mode_diff=0 smooth_diff=0 split1mi=0`, and exactly FIVE fixtures
9781+ // put a 1-mi-tall left neighbour in front of a decode-path read at
9782+ // all -- `gm_small_side_witness` (5), `reelc_sb128_inter_witness` (7),
9783+ // `av112bit-{inter,compound,compound-masked}` (1 each) -- and in every
9784+ // one of those reads the two blocks agree on `uv_mode`. So the SHAPE is
9785+ // reachable (see `UV_LEFT_1MI_SPLIT_HITS`) and the term's VALUE
9786+ // changing is what is still unwitnessed.
97309787 let above_mi = (mi_r.saturating_sub(1), mi_c + ss_x);
97319788 // lane-av1leftref: libaom's LEFT read carries the `+ss_y` ROW term --
97329789 // `base_mi[ss_y * mi_stride - 1]` (`av1_common_int.h:1400-1401`) is
@@ -9735,11 +9792,17 @@ impl Neighbours {
97359792 // row at every subsampling. The term is only observable when the two
97369793 // cells hold DIFFERENT blocks, i.e. the left neighbour is 1 mi tall or
97379794 // shorter -- then `(row, col-1)` and `(row+1, col-1)` are two blocks
9738- // and only libaom's is the chroma reference. The two counters below
9739- // are the gate's non-vacuity proof: the mode value moved on
9740- // `UV_LEFT_SS_Y_MODE_DIFF_HITS` reads, and the boolean this feeds
9795+ // and only libaom's is the chroma reference. Three counters measure
9796+ // that, and the third is the one the other two need: a read can only
9797+ // differ if the two cells are written by DIFFERENT blocks, which
9798+ // `UV_LEFT_1MI_SPLIT_HITS` counts off the per-cell owner stamp
9799+ // (`uv_owner`, below). A DIFF bucket that reads 0 while SPLIT reads 0
9800+ // was never in contention; a DIFF bucket that reads 0 while SPLIT
9801+ // reads > 0 is the term being unobservable on real material, not
9802+ // unreachable. `..._MODE_DIFF_HITS` / `..._SMOOTH_DIFF_HITS` then say
9803+ // whether the mode value, and the boolean this feeds
97419804 // (`is_smooth_mode` -> `av1_get_intra_edge_filter_type` -> the chroma
9742- // edge filter) flipped on `UV_LEFT_SS_Y_SMOOTH_DIFF_HITS`.
9805+ // edge filter), actually moved.
97439806 let left_mi = (mi_r + ss_y, mi_c.saturating_sub(1));
97449807 let read_left = |row: usize| -> usize {
97459808 match self.uv_mode_row.get(row) {
@@ -9776,6 +9839,36 @@ impl Neighbours {
97769839 if is_smooth_mode(own_row) != is_smooth_mode(left) {
97779840 hit!(UV_LEFT_SS_Y_SMOOTH_DIFF_HITS);
97789841 }
9842+ // lane-av1leftwit: the geometry the `+ss_y` term needs. The two
9843+ // cells are one left mi column apart, so they are two different
9844+ // blocks exactly when the left neighbour is 1 mi tall or shorter.
9845+ let col = left_mi.1;
9846+ let epoch = UV_OWNER_EPOCH.with(|c| c.get()) & 0xff00_0000;
9847+ let own = (col < self.uv_grid_cols)
9848+ .then(|| self.uv_owner.get(mi_r * self.uv_grid_cols + col).copied())
9849+ .flatten()
9850+ .filter(|o| o & 0xff00_0000 == epoch)
9851+ .unwrap_or(0);
9852+ let down = self
9853+ .uv_owner
9854+ .get((mi_r + ss_y) * self.uv_grid_cols + col)
9855+ .copied()
9856+ .filter(|o| o & 0xff00_0000 == epoch)
9857+ .unwrap_or(0);
9858+ if own != 0 && down != 0 && own != down {
9859+ hit!(UV_LEFT_1MI_SPLIT_HITS);
9860+ if crate::envflags::env_flag!("EC_LEFTSSY") {
9861+ eprintln!(
9862+ "EC_LEFTSSY epoch={} mi=({mi_r},{mi_c}) left_col={col} \
9863+ owners=({},{})->({},{}) modes={own_row}/{left}",
9864+ epoch >> 24,
9865+ own >> 12 & 0xfff,
9866+ own & 0xfff,
9867+ down >> 12 & 0xfff,
9868+ down & 0xfff,
9869+ );
9870+ }
9871+ }
97799872 }
97809873 if have_above && cell(&self.uv_mode_grid, mi_r - 1, mi_c).is_some_and(|m| {
97819874 !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(
1753617629 // frame's own `ss_x` -- the unsnapped read is the pair-merge witness
1753717630 // counter's mirror of the snapping form, and the shipped read offsets
1753817631 // the above COLUMN by `+ss_x` (libaom's `chroma_above_mi`).
17632+ //
17633+ // lane-av1leftwit: this mirror is NOT evidence about the left read's
17634+ // `+ss_y` term, whatever a report once said. It reads the leaf's own
17635+ // (odd) mi row, which no decode call site does -- every one of them
17636+ // uses the snapping form, whose base row is even -- and its result
17637+ // feeds `RECT4_16_UV_PAIR_FILT_HITS` only. What it measures is real
17638+ // and worth keeping (the pair's chroma-reference read against the
17639+ // leaf's own row: 51/24/121/0/1 hits on the five fixtures censused),
17640+ // so it stays; the decode path's own reach for the `+ss_y` term is
17641+ // `uv_left_1mi_split_hits()`.
1753917642 if smooth_neighbor_uv
1754017643 != neighbours.smooth_uv_neighbour_unsnapped(
1754117644 lmi.0,
crates/ec-av1/src/stream.rsmodified+95 -8
@@ -43057,14 +43057,17 @@ pub(crate) mod tests {
4305743057 /// every subsampling until this lane.
4305843058 ///
4305943059 /// The read is only observable when the two cells hold DIFFERENT blocks --
43060- /// a left neighbour at most 1 mi tall. Measured over every committed
43061- /// fixture and ~1000 swept aomenc encodes (report table), that never
43062- /// happens on a decode-path read: `uv_mode_grid` runs down a left mi
43063- /// column always have EVEN length, because libaom only starts a block on
43064- /// an odd mi row with an 8-px strip, and the 4-px `HORZ_4` strips aomenc
43065- /// does pick all land inside one mi row. So the term is a proven no-op on
43066- /// today's material, and this gate pins BOTH halves of that statement:
43067- /// the arm runs thousands of times, and it never changes an answer.
43060+ /// a left neighbour at most 1 mi tall (1 mi = 4 luma px, so a 4x4/8x4/16x4
43061+ /// /32x4/64x4 leaf). lane-av1leftwit measured that shape off a per-cell
43062+ /// owner stamp instead of the mode value: `uv_left_1mi_split_hits()` counts
43063+ /// decode-path reads whose two cells were written by DIFFERENT blocks, and
43064+ /// it is NOT zero -- five committed fixtures carry it (15 reads in all,
43065+ /// `lanes/av1leftwit.report.md`). What no committed fixture shows is the two
43066+ /// blocks DISAGREEING on `uv_mode`, which is what `mode_diff`/`smooth_diff`
43067+ /// below measure. So this gate pins both halves honestly: the arm runs
43068+ /// thousands of times, the shape it needs is genuinely reached, and the
43069+ /// term has not yet been seen to change an answer. Its exactness arms are
43070+ /// what would decide the shipped read if a DIFF bucket ever went non-zero.
4306843071 ///
4306943072 /// A non-zero DIFF bucket is not a failure here -- it is the first stream
4307043073 /// that witnesses the term, and the exactness arms below are what then
@@ -43112,6 +43115,90 @@ pub(crate) mod tests {
4311243115 );
4311343116 }
4311443117
43118+ /// lane-av1leftwit: the `+ss_y` term's SHAPE is reachable on the decode
43119+ /// path, and this is the gate that says so.
43120+ ///
43121+ /// lane-av1leftref shipped the left read's `+ss_y` row term with the
43122+ /// argument that the shape it needs -- a left neighbour at most 1 mi tall,
43123+ /// so the cell this decoder read and the cell libaom reads belong to
43124+ /// different blocks -- is "structurally absent, because aomenc never starts
43125+ /// a block on an odd mi row". Both halves of that are wrong. libaom's
43126+ /// `PARTITION_HORZ_4` puts its `i == 0` child on the PARENT's own mi row
43127+ /// (`decode_partition`, `av1/decoder/decodeframe.c`: `mi_row + i * bw / 4`),
43128+ /// and a 16x16 parent sits on a 4-mi grid, so a 1-mi-tall leaf at an EVEN
43129+ /// row is what the syntax asks for, not forbids. And the shape is measured
43130+ /// in the corpus: these two fixtures each present it to a real decode-path
43131+ /// read.
43132+ ///
43133+ /// The counter is `decode::uv_left_1mi_split_hits()`, incremented only
43134+ /// where `decode_path` is true -- the snapping form every decode call site
43135+ /// uses -- so the 16x4/4x16 pair witness's counter-only mirror (which
43136+ /// reads an odd mi row and feeds `RECT4_16_UV_PAIR_FILT_HITS`) cannot
43137+ /// inflate it. `UV_LEFT_SS_Y_READS` alone would prove nothing: it counts
43138+ /// every read with a left neighbour, whether or not the two cells differ.
43139+ ///
43140+ /// NON-VACUITY: the `uv_owner` stamp the counter turns on was removed for
43141+ /// one build; both arms fell to 0 and this gate failed on the census
43142+ /// (report §5), so a decoder that stops recording which block owns a cell
43143+ /// fails here instead of passing vacuously. It is deliberately NOT a
43144+ /// mutation of the `+ss_y` term itself: the term's own mutation leaves
43145+ /// these reads untouched, which is the honest limit of what the fixture
43146+ /// set can decide (the kf900 gate above owns the exactness side).
43147+ #[test]
43148+ fn a_committed_4to20_stream_presents_a_one_mi_left_neighbour_to_a_decode_path_read() {
43149+ const NAME: &str = "a_committed_4to20_stream_presents_a_one_mi_left_neighbour_to_a_decode_path_read";
43150+ // (fixture, frames, width, height, measured split-owner reads)
43151+ let arms: [(&str, usize, usize, usize, usize); 2] = [
43152+ ("gm_small_side_witness.obu", 33, 1920, 792, 5),
43153+ ("reelc_sb128_inter_witness.obu", 15, 1920, 792, 7),
43154+ ];
43155+ for (fixture, want_frames, width, height, want_split) in arms {
43156+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
43157+ .join("fixtures")
43158+ .join(fixture);
43159+ let stream = std::fs::read(&path)
43160+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
43161+ let before_split = crate::decode::uv_left_1mi_split_hits();
43162+ let before_reads = crate::decode::uv_left_ss_y_reads();
43163+ let before_mode = crate::decode::uv_left_ss_y_mode_diff_hits();
43164+ let before_smooth = crate::decode::uv_left_ss_y_smooth_diff_hits();
43165+ let frames = match decode_stream(&stream) {
43166+ Ok(frames) => frames,
43167+ Err(e) => panic!("{NAME}: {fixture} refused: {e}"),
43168+ };
43169+ let split = crate::decode::uv_left_1mi_split_hits() - before_split;
43170+ assert_eq!(
43171+ frames.len(),
43172+ want_frames,
43173+ "{NAME}: {fixture} frame count"
43174+ );
43175+ assert!(
43176+ frames
43177+ .iter()
43178+ .all(|f| (f.width, f.height) == (width, height)),
43179+ "{NAME}: {fixture} is not {width}x{height}"
43180+ );
43181+ assert_eq!(
43182+ split, want_split,
43183+ "{NAME}: {fixture} presented {split} 1-mi-tall left neighbours to \
43184+ a decode-path read, measured {want_split} -- the census this \
43185+ gate pins moved"
43186+ );
43187+ // Printed, not asserted: `== 0` would pin an accident, and a
43188+ // non-zero value is the first WITNESS of the term rather than a
43189+ // failure (that is what the kf900 gate above then decides against
43190+ // the oracle).
43191+ eprintln!(
43192+ "{NAME}: {fixture}: {split} 1-mi-tall left neighbours in \
43193+ {} decode-path reads, +ss_y changed the mode {} and the smooth \
43194+ boolean {} times",
43195+ crate::decode::uv_left_ss_y_reads() - before_reads,
43196+ crate::decode::uv_left_ss_y_mode_diff_hits() - before_mode,
43197+ crate::decode::uv_left_ss_y_smooth_diff_hits() - before_smooth,
43198+ );
43199+ }
43200+ }
43201+
4311543202 /// lane-av1formatsweep: the ODD CODED DIMENSION cell -- a frame whose
4311643203 /// width or height is not a multiple of 8, so the last mode-info column
4311743204 /// and the last chroma plane row/column are PARTIAL (`mi_cols * 8 >
lanes/av1leftwit.report.mdadded+277 -0
@@ -0,0 +1,277 @@
1+# lane-av1leftwit — is the left chroma reference's `+ss_y` term witnessed?
2+
3+Base `a21f3680`, worktree `~/.cache/wt/av1leftwit`, branch `lane-av1leftwit`.
4+One commit, nothing pushed. Assignment: the shipped `+ss_y` left-reference
5+change has no witness, which is a correctness hole, not a coverage gap.
6+
7+## 0. Verdict
8+
9+**The premise behind the shipped comments is false, and the term itself is
10+correct.** Two separate claims were standing in for evidence; both were
11+checked here and neither survives:
12+
13+1. "The shape the term needs is structurally absent, because aomenc never
14+ starts a block on an odd mi row" — **false, twice over.** 1 mi is 4 luma
15+ pixels, not 8; libaom's `PARTITION_HORZ_4` places its `i == 0` child on the
16+ PARENT's own mi row, which for a 16x16 is a multiple of 4 and therefore
17+ even; and the shape is not hypothetical — it reaches a real decode-path
18+ read in **5 of the 48 committed fixtures** (15 reads in total), which is
19+ what the new `uv_left_1mi_split_hits()` counter measures.
20+2. "Six committed 4:2:0 fixtures reach it, and on `reelb_ss600_key_frame.obu` the
21+ boolean flips" (a claim in `decode.rs`) — **never measured, and false.**
22+ `reelb_ss600_key_frame.obu` reads `mode_diff=0 smooth_diff=0 split1mi=0`.
23+
24+What is still unwitnessed is narrower and is now stated correctly: in every
25+one of the 15 decode-path reads that see the shape, the two blocks **agree on
26+`uv_mode`**, so the term still changes no pixel. A 115-encode targeted hunt
27+(§3) plus the whole committed corpus did not move that. The `+ss_y` term is
28+kept — it is verified against the oracle source, not against a corpus
29+(§1) — and this lane's job is to make the hole smaller, named and gated
30+rather than propped up by a counter whose call site no decode path uses (§7).
31+
32+## 1. The term, against the oracle source (not a corpus)
33+
34+`~/.cache/aom-oracle/src` @ `v3.13.3-7-g9bb526a`,
35+`av1/common/av1_common_int.h:1393-1412` (`set_mi_row_col`):
36+
37+```c
38+ const int chroma_ref = ((mi_row & 0x01) || !(bh & 0x01) || !ss_y) &&
39+ ((mi_col & 0x01) || !(bw & 0x01) || !ss_x);
40+ xd->is_chroma_ref = chroma_ref;
41+ if (chroma_ref) {
42+ MB_MODE_INFO **base_mi =
43+ &xd->mi[-(mi_row & ss_y) * xd->mi_stride - (mi_col & ss_x)];
44+ MB_MODE_INFO *chroma_above_mi =
45+ xd->chroma_up_available ? base_mi[-xd->mi_stride + ss_x] : NULL;
46+ MB_MODE_INFO *chroma_left_mi =
47+ xd->chroma_left_available ? base_mi[ss_y * xd->mi_stride - 1] : NULL;
48+```
49+
50+`chroma_left_mi = base_mi[ss_y * stride - 1]` — the shipped read
51+`left_mi = (mi_r + ss_y, mi_c - 1)` is this line, with the caller's
52+`(mi_row & ss_y)` snap already folded into `mi_r`. **The term is right**, and
53+so is the shape claim about the syntax:
54+
55+* `av1/decoder/decodeframe.c:1334` — `partition = (bsize < BLOCK_8X8) ?
56+ PARTITION_NONE : read_partition(...)`: a sub-8x8 bsize is a leaf or nothing.
57+* same file, `PARTITION_HORZ_4` — `this_mi_row = mi_row + i * (bw / 4)`. A
58+ 16x16 (4x4 mi) sits on a 4-mi grid, so its `i == 0` child is **1 mi tall at
59+ an even mi row**. The geometry the hunt needed is what the syntax produces
60+ first, not something it forbids.
61+* `av1/common/common_data.c:17` — `av1_ss_size_lookup[.][1][1]` is non-INVALID
62+ for `BLOCK_4X4/4X8/8X4/8X8/16X4/32X4/64X4`, so 4-px-tall leaves are legal
63+ at 4:2:0 (and 4:4:0, `ss_y == 1`).
64+
65+One nuance worth keeping: `chroma_ref` is **false** for a block that is itself
66+1 mi tall (`bh` odd) on an even row at `ss_y == 1`, i.e. libaom does not
67+*publish* such a block as a chroma reference. It does not block the shape
68+this lane is about: the block that READS the left neighbour is >= 2 mi tall
69+(`bh` even) whenever it spans both cells, so its own `chroma_ref` is true and
70+it does apply the offset.
71+
72+## 2. The instrument (what makes the shape measurable at all)
73+
74+`uv_left_ss_y_reads` counts reads with a left neighbour — it cannot tell
75+"reached the shape" from "read two cells of the same block". Three additions,
76+all in `decode.rs`, none of them on a decision path:
77+
78+* `Neighbours::uv_owner: Vec<u32>` — per mi cell, `(epoch << 24) | (owner
79+ mi_r << 12) | owner mi_c` of the block that wrote it, stamped in
80+ `record_uv_mode_mi` over the same span and with the same clipping as
81+ `uv_mode_grid`. The epoch (`UV_OWNER_EPOCH`) is bumped in `start_tile`, so
82+ a cell no block wrote in this tile reads 0 and can never be compared.
83+* `UV_LEFT_1MI_SPLIT_HITS` / `uv_left_1mi_split_hits()` — incremented only
84+ under the existing `decode_path` guard, when both cells were written in this
85+ tile **and by different blocks**. That is the run-of-length-1 geometry, and
86+ it is the precondition for the term being observable at all.
87+* `EC_LEFTSSY=1` traces: `EC_LEAF mi=(r,c) wh=(w,h) uv_mode=N` per recorded
88+ block (the parse-side leaf list) and `EC_LEFTSSY ... owners=(..)->(..)` per
89+ split read. These are what the hunt below was steered by — the leaf list
90+ says what the partition tree actually contains, before any pixel argument.
91+
92+Cost: one extra `u32` per mi cell and one `fill_span` per recorded block
93+(~0.5 MB for 4K). A `u8` extent grid was tried as well and **removed** — it
94+existed only for the trace and was avoidable work in the hot path.
95+
96+## 3. Hunt
97+
98+115 encodes on the durable oracle, 4:2:0 8-bit, all with
99+`--enable-1to4-partitions=1`, `--cpu-used=0`, `--limit=1`, `--threads=1
100+--row-mt=0 --lag-in-frames=0` unless the row says otherwise. "parsed tree" is
101+the `EC_LEAF` census of that stream (leaf extents in mi); `h=1` counts
102+1-mi-tall leaves, the only shape that can make the two cells differ.
103+
104+| recipe | parsed tree | decode-path counter | pixel verdict |
105+|---|---|---|---|
106+| 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 |
107+| `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 |
108+| `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 |
109+| `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 |
110+| 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 |
111+| **committed corpus, 48 fixtures that decode** | see §4 | **`split1mi > 0` in 5** | both pinned arms exact (kf900: 22292 reads, all three planes) |
112+
113+The lesson the leaf census teaches, and the reason the sweep stops where it
114+does: a wide block codes 1-D structure almost for free. A 32x16 leaf spans
115+four 1-mi bands and still wins, because a vertical step is one coefficient per
116+4x4 transform block however tall the block is (`brick`, `mix4`); and content
117+fine enough to force small blocks stops at 8x8 (2x2 mi), which is 2 mi tall
118+and therefore cannot split a cell pair either (`noise2`, `mosaic`). The
119+encoder reaches 1-mi-tall leaves only on real material — which is exactly what
120+the committed film cut shows and what no lavfi source reproduced.
121+
122+## 4. Corpus census — the shape is on the decode path
123+
124+Every `.obu` in `crates/ec-av1/fixtures/`, measured with the pinned probe
125+(`decode_probe` prints `uv_left_ss_y: reads=.. mode_diff=.. smooth_diff=..
126+split1mi=..`). 48 produced numbers: **30 read the term** (4:2:0, `ss_y == 1`),
127+6 refused (4:2:2, the unconditional refusal — the term is a no-op there by
128+construction), and 12 decoded with **0 reads** because they are 4:4:4
129+(`ss_y == 0`, so the term is literally the same cell as before). Every fixture
130+that can reach the shape is in the 30.
131+
132+| fixture | format | reads | mode_diff | smooth_diff | **split1mi** |
133+|---|---|---|---|---|---|
134+| `gm_small_side_witness.obu` | yuv420p10le | 13311 | 0 | 0 | **5** |
135+| `reelc_sb128_inter_witness.obu` | yuv420p10le | 5472 | 0 | 0 | **7** |
136+| `av112bit-inter.obu` | yuv420p12le | 40 | 0 | 0 | **1** |
137+| `av112bit-compound.obu` | yuv420p12le | 62 | 0 | 0 | **1** |
138+| `av112bit-compound-masked.obu` | yuv420p12le | 65 | 0 | 0 | **1** |
139+| `reelb_kf900.obu` | yuv420p10le | 22292 | 0 | 0 | 0 |
140+| `reelb_ss600_key_frame.obu` | yuv420p10le | 6297 | 0 | 0 | 0 |
141+| (25 other `ss_y == 1` fixtures) | 4:2:0 | 4..14537 | 0 | 0 | 0 |
142+
143+The 15 split reads, verbatim from the trace (`gm_small_side_witness`):
144+
145+```
146+EC_LEFTSSY epoch=1 mi=(84,356) left_col=355 owners=(84,354)->(85,354) modes=0/0
147+EC_LEFTSSY epoch=1 mi=(96,216) left_col=215 owners=(96,215)->(97,215) modes=0/0
148+EC_LEFTSSY epoch=1 mi=(18,176) left_col=175 owners=(18,189)->(19,189) modes=0/0
149+EC_LEFTSSY epoch=1 mi=(74,296) left_col=295 owners=(74,294)->(75,294) modes=0/0
150+EC_LEFTSSY epoch=1 mi=(184,376) left_col=375 owners=(184,374)->(185,374) modes=0/0
151+```
152+
153+Every one of them: the upper cell's block ends at that row, a second block
154+starts immediately below it in the same column, and the reading block's
155+`(row, col-1)` / `(row+1, col-1)` cells are those two blocks. Measured extents
156+at those sites were `(4x2)` over `(4x1)` mi — a 32x16 block with a 16x4 block
157+underneath it, which is the `PARTITION_HORZ_4` shape of §1, at even mi rows.
158+`epoch=1` for all five: first tile, first frame.
159+
160+So: **the geometry is real, common enough to pin, and libaom-correct.** What
161+is missing is a case where the two blocks disagree on `uv_mode`; in these
162+streams 97.6% of recorded blocks carry `DC_PRED`, and 1-mi-tall leaves sit on
163+high-detail edges where chroma is flat, so the two conditions are close to
164+anti-correlated in practice. That is the honest residual, and it is a
165+statement about the corpus, not about the syntax.
166+
167+## 5. Red / green
168+
169+* **Gate non-vacuity (the new gate).** `stream.rs::
170+ a_committed_4to20_stream_presents_a_one_mi_left_neighbour_to_a_decode_path_read`
171+ asserts `uv_left_1mi_split_hits() == 5` on `gm_small_side_witness` and
172+ `== 7` on `reelc_sb128_inter_witness` (deltas around the decode), plus frame
173+ count and dimensions. **Green:**
174+ `5 1-mi-tall left neighbours in 13311 decode-path reads, +ss_y changed the
175+ mode 0 and the smooth boolean 0 times` / `7 ... in 5472 ...`.
176+ **Red:** the `uv_owner` stamp was removed for one build (`if false {
177+ fill_span(...) }`), both arms fell to 0 and the gate FAILED on the census.
178+ Reverted, green again. The mutation is deliberately *not* the `+ss_y` term:
179+ the term's own mutation leaves these reads untouched, which is the limit of
180+ what this fixture set can decide.
181+* **The term's mutation (pixels).** §6.
182+* **The existing kf900 gate still passes** with the new counters in the tree:
183+ `22292 left-reference reads, +ss_y changed the mode 0 and the smooth boolean
184+ 0 times, all three planes pixel-exact`.
185+
186+## 6. The term's own mutation, on the five streams that carry the shape
187+
188+`left_mi = (mi_r + ss_y, ..)` -> `(mi_r + 0 * ss_y, ..)` (the pre-lane
189+own-row read), `EC_PROBE_OUT16` dumps (yuv420p10le) from both builds, byte
190+compare:
191+
192+| fixture | shipped vs mutated |
193+|---|---|
194+| `gm_small_side_witness.obu` | IDENTICAL (150543360 B) |
195+| `reelc_sb128_inter_witness.obu` | IDENTICAL (68428800 B) |
196+| `av112bit-inter.obu` | IDENTICAL (122880 B) |
197+| `av112bit-compound.obu` | IDENTICAL (368640 B) |
198+| `av112bit-compound-masked.obu` | IDENTICAL (368640 B) |
199+
200+All five are byte-identical with the term removed. That is expected, and it
201+is the point: the shape is reached 15 times and the term still moves nothing,
202+because the two blocks agree on `uv_mode` in every one of those reads.
203+Reproduce with:
204+
205+```sh
206+cargo build -p ec-av1 --example decode_probe
207+EC_PROBE_OUT16=/tmp/s.yuv target/debug/examples/decode_probe crates/ec-av1/fixtures/gm_small_side_witness.obu
208+# then edit decode.rs:9806 to `mi_r + 0 * ss_y`, rebuild, dump /tmp/m.yuv, cmp
209+```
210+
211+## 7. Disposition of the phantom mirror
212+
213+`decode.rs:17642` (the 16x4/4x16 pair witness) calls the unsnapped form with
214+the leaf's own — **odd** — mi row and feeds `RECT4_16_UV_PAIR_FILT_HITS`. It
215+was cited as the `+ss_y` term's reachability evidence, and the `decode_path`
216+flag exists to keep it out of the term's counters. Measured, that flag's
217+stated reason ("no committed fixture reaches it on the decode path") is
218+false, and the mirror is **not** a phantom path either: it measures a real
219+comparison the decode makes (the pair's chroma-reference read against the
220+leaf's own row) and it fires — 51 / 24 / 121 / 0 / 1 hits on
221+`gm_small_side` / `reelc_sb128_inter` / `reelb_kf900` /
222+`reelb_rect64_intra16x4_witness` / `av112bit-inter`.
223+
224+**Disposition: kept, re-labelled.** Deleting a counter that measures a live
225+comparison would lose coverage; what was wrong was the citation. The mirror
226+call site and the `decode_path` doc now say in terms that the mirror is not
227+evidence about `+ss_y` and that the decode path's own reach is
228+`uv_left_1mi_split_hits()`.
229+
230+## 8. Comments corrected (all three were unmeasured claims in the source)
231+
232+* `decode.rs:9780` — "Six committed 4:2:0 fixtures reach it ... and on
233+ `reelb_ss600_key_frame.obu` the boolean flips" -> the measured census of §4.
234+* `decode.rs:9717` — the `decode_path` justification -> §7.
235+* `stream.rs:43059` (kf900 gate doc) — "that never happens on a decode-path
236+ read: `uv_mode_grid` runs down a left mi column always have EVEN length"
237+ -> the shape is reached; what has never been seen is the two cells
238+ *disagreeing*.
239+* `decode.rs:9800` — the DIFF-bucket comment now says which counter is the
240+ precondition for the other two, so `mode_diff == 0` is no longer readable as
241+ "unreachable".
242+
243+## 9. What is still open
244+
245+A witness needs P(shape) x P(the two blocks disagree on `uv_mode`), and on
246+today's material the second factor is ~0 where the first is 1-in-2600 reads.
247+The next lever is not another partition-flag sweep (115 encodes say so) and
248+not a synthetic source: it is real 4:2:0 material whose 1-mi-tall leaves land
249+on **chroma** edges — foliage, signage, screen content with saturated chroma —
250+encoded at a bit depth and cq where the encoder keeps directional chroma
251+modes. `reelc_sb128_inter_witness` (7 reads in 15 frames) is the closest
252+committed material; the same cut re-encoded at cq 20-32 in 8-bit with
253+`--enable-1to4-partitions=1` is where to look next. Until one of those
254+streams lands, the correct statement about this change is the one in §0: the
255+term matches libaom's source, the geometry it needs is reachable and gated,
256+and no committed stream yet lets it change a pixel.
257+
258+### Gaps in this lane's own coverage, stated
259+
260+* **No 4:4:0 encode.** The term is also live at `ss_x == 0, ss_y == 1`, and
261+ nothing here produced one: ffmpeg has no `yuv440` pix_fmt and the y4m
262+ chroma-siting tags do not express it, so the sweep is 4:2:0 only. The
263+ census in §4 is 4:2:0-only for the same reason (the committed 4:4:4 set
264+ cannot reach the term by construction). A 4:4:0 hunt needs a raw plane
265+ writer plus an aomenc input path that accepts it.
266+* **Three of the five shape-carrying fixtures are not gated** —
267+ `av112bit-{inter,compound,compound-masked}` carry 1 read each and are
268+ left out to keep the gate's runtime down; the census in §4 pins them and
269+ the counter is public, so a future gate can add them for free.
270+* **No 12-bit-mode sweep of real material.** The three `av112bit` hits are the
271+ only 12-bit evidence and they are 1 read each.
272+
273+## State
274+
275+One commit on `lane-av1leftwit`, nothing pushed. Hunt scratch (115 encodes,
276+generator, sweep drivers) lives outside the repo in
277+`~/.cache/hunt-av1leftwit/` and is not part of the commit.