forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1leftwit @ d5ab6ef4 — +ss_y left-reference reachability, exact-counter census gate, four additive source corrections

Browse files at this commit

913d97774fb8aa16722275725f08561ba442ebf9Ahmet Kaan GümüşParent: aa976f1aec3e0f
crates/ec-av1/examples/decode_probe.rsmodified+7 -2
@@ -51,12 +51,17 @@ fn main() {
51 ec_av1::decode::chroma422_pair_wide_hits()51 ec_av1::decode::chroma422_pair_wide_hits()
52 );52 );
53 println!(53 println!(
54- "uv_left_ss_y: reads={} mode_diff={} smooth_diff={}",54+ "uv_left_ss_y: reads={} mode_diff={} smooth_diff={} split1mi={}",
55 ec_av1::decode::uv_left_ss_y_reads(),55 ec_av1::decode::uv_left_ss_y_reads(),
56 ec_av1::decode::uv_left_ss_y_mode_diff_hits(),56 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(),
58 );59 );
59 let (h, v, c) = ec_av1::stream::rect4_32_counters();60 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+ );
60 println!("rect4_32: horz={h} vert={v} coded={c}");65 println!("rect4_32: horz={h} vert={v} coded={c}");
61 println!(66 println!(
62 "rect_intrabc_reads: {}",67 "rect_intrabc_reads: {}",
crates/ec-av1/src/decode.rsmodified+119 -16
@@ -5906,6 +5906,27 @@ pub fn uv_left_ss_y_smooth_diff_hits() -> usize {
5906 UV_LEFT_SS_Y_SMOOTH_DIFF_HITS.with(|c| c.get())5906 UV_LEFT_SS_Y_SMOOTH_DIFF_HITS.with(|c| c.get())
5907 }5907 }
5908 5908
5909+// lane-av1leftwit: decode-path chroma edge-filter-type reads at `ss_y > 0`
5910+// whose left-neighbour COLUMN holds a run of length 1 -- the cell this
5911+// decoder reads (its own mi row) and the cell libaom reads (one row down)
5912+// were written by two DIFFERENT blocks, i.e. the left neighbour is at most
5913+// 1 mi tall. That is the only geometry in which the `+ss_y` term can change
5914+// the answer at all; `UV_LEFT_SS_Y_READS` alone proves nothing about it.
5915+thread_local! {
5916+ static UV_LEFT_1MI_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
5917+}
5918+
5919+/// Current value of [`UV_LEFT_1MI_SPLIT_HITS`].
5920+pub fn uv_left_1mi_split_hits() -> usize {
5921+ UV_LEFT_1MI_SPLIT_HITS.with(|c| c.get())
5922+}
5923+
5924+// lane-av1leftwit: the per-tile epoch `uv_owner` cells are stamped with.
5925+// Bumped in `Neighbours::start_tile`; never read by decode logic.
5926+thread_local! {
5927+ static UV_OWNER_EPOCH: std::cell::Cell<u32> = const { std::cell::Cell::new(0) };
5928+}
5929+
5909 // lane-cfl r1 gate counters: `UV_CFL_PRED` blocks (every `cfl_alpha_signs`5930 // lane-cfl r1 gate counters: `UV_CFL_PRED` blocks (every `cfl_alpha_signs`
5910 // read) and chroma blocks with a NONZERO `angle_delta_uv` -- the two block5931 // read) and chroma blocks with a NONZERO `angle_delta_uv` -- the two block
5911 // shapes the r1 chroma defect showed up on.5932 // shapes the r1 chroma defect showed up on.
@@ -8489,6 +8510,16 @@ struct Neighbours {
8489 /// [`Self::uv_mode_grid`]'s stride, in mi units (superblock-padded, like8510 /// [`Self::uv_mode_grid`]'s stride, in mi units (superblock-padded, like
8490 /// every other band here).8511 /// every other band here).
8491 uv_grid_cols: usize,8512 uv_grid_cols: usize,
8513+ /// lane-av1leftwit: which BLOCK wrote each cell of [`Self::uv_mode_grid`],
8514+ /// as `(epoch << 24) | (mi_r << 12) | mi_c` of the writing block's own
8515+ /// top-left mi. The `uv_mode` value alone cannot answer "are the two cells
8516+ /// the `+ss_y` read compares written by the same block?", which is the
8517+ /// whole question the `+ss_y` term turns on: the term is only observable
8518+ /// when the left neighbour is 1 mi tall, i.e. when the cell this decoder
8519+ /// used to read and the cell libaom reads hold DIFFERENT blocks. `epoch`
8520+ /// is [`UV_OWNER_EPOCH`], bumped once per tile, so a cell no block wrote
8521+ /// in this tile can never be mistaken for a written one.
8522+ uv_owner: Vec<u32>,
8492 /// Whether the block above/left of this column/row was coded `skip` --8523 /// Whether the block above/left of this column/row was coded `skip` --
8493 /// an inter frame's own `skip` context (spec `SkipContext`), which the8524 /// an inter frame's own `skip` context (spec `SkipContext`), which the
8494 /// key-frame writer never tracks (its skip context is always zero); a8525 /// key-frame writer never tracks (its skip context is always zero); a
@@ -8682,6 +8713,7 @@ impl Neighbours {
8682 uv_mode_row: vec![(u16::MAX, 0); rows * (SUB / MI)],8713 uv_mode_row: vec![(u16::MAX, 0); rows * (SUB / MI)],
8683 uv_mode_grid: vec![u8::MAX; cols * (SUB / MI) * rows * (SUB / MI)],8714 uv_mode_grid: vec![u8::MAX; cols * (SUB / MI) * rows * (SUB / MI)],
8684 uv_grid_cols: cols * (SUB / MI),8715 uv_grid_cols: cols * (SUB / MI),
8716+ uv_owner: vec![0; cols * (SUB / MI) * rows * (SUB / MI)],
8685 above_txfm: vec![TXFM_CTX_INIT; cols * (SUB / MI)],8717 above_txfm: vec![TXFM_CTX_INIT; cols * (SUB / MI)],
8686 left_txfm: vec![TXFM_CTX_INIT; rows * (SUB / MI)],8718 left_txfm: vec![TXFM_CTX_INIT; rows * (SUB / MI)],
8687 // lane-inter8 r2: mi(4px)-granular, not [`SUB`]-granular -- an8719 // lane-inter8 r2: mi(4px)-granular, not [`SUB`]-granular -- an
@@ -8751,6 +8783,10 @@ impl Neighbours {
8751 // lane-seg: `AvailU`/`AvailL` for the segment-id neighbour prediction8783 // lane-seg: `AvailU`/`AvailL` for the segment-id neighbour prediction
8752 // are tile-relative, same as every other neighbour lookup here.8784 // are tile-relative, same as every other neighbour lookup here.
8753 fctx.seg_tile_origin.with(|c| c.set((row0_mi, col0_mi)));8785 fctx.seg_tile_origin.with(|c| c.set((row0_mi, col0_mi)));
8786+ // lane-av1leftwit: a fresh epoch stamps every `uv_owner` cell this
8787+ // tile writes, so the `+ss_y` read's "different block?" probe never
8788+ // compares against a cell a previous tile left behind.
8789+ UV_OWNER_EPOCH.with(|c| c.set(c.get().wrapping_add(1) | (1 << 24)));
8754 self.tile_row0_mi = row0_mi;8790 self.tile_row0_mi = row0_mi;
8755 self.tile_col0_mi = col0_mi;8791 self.tile_col0_mi = col0_mi;
8756 let end = col1_mi.min(self.above.len());8792 let end = col1_mi.min(self.above.len());
@@ -9860,6 +9896,17 @@ impl Neighbours {
9860 uv_mode as u8,9896 uv_mode as u8,
9861 );9897 );
9862 }9898 }
9899+ // lane-av1leftwit: stamp the writing block's own mi over its extent,
9900+ // the same cells and the same clipping as `uv_mode_grid` above.
9901+ let owner = UV_OWNER_EPOCH.with(|c| c.get()) | ((mi_r as u32) << 12) | mi_c as u32;
9902+ for row in mi_r..=last_r {
9903+ fill_span(&mut self.uv_owner, row * stride + mi_c, n, owner);
9904+ }
9905+ if crate::envflags::env_flag!("EC_LEFTSSY") {
9906+ eprintln!(
9907+ "EC_LEAF mi=({mi_r},{mi_c}) wh=({mi_w},{mi_h}) uv_mode={uv_mode}"
9908+ );
9909+ }
9863 }9910 }
9864 9911
9865 /// Whether either mi-exact chroma neighbour of the block at `(mi_r, mi_c)`9912 /// Whether either mi-exact chroma neighbour of the block at `(mi_r, mi_c)`
@@ -9920,11 +9967,16 @@ impl Neighbours {
9920 /// decode path uses the snapping form.9967 /// decode path uses the snapping form.
9921 /// `decode_path` is `true` only for the snapping form every decode call9968 /// `decode_path` is `true` only for the snapping form every decode call
9922 /// site uses; the 16x4/4x16 pair witness's mirror passes `false`, so the9969 /// site uses; the 16x4/4x16 pair witness's mirror passes `false`, so the
9923- /// `+ss_y` counters measure the read that actually filters a chroma edge9970+ /// `+ss_y` counters measure a read that actually filters a chroma edge and
9924- /// and not the counter-only one. (The mirror reads an ODD mi row -- the9971+ /// not the counter-only one.
9925- /// pair's chroma-reference half -- where the two cells differ far more9972+ ///
9926- /// often; counting it would make this lane look reachable when no9973+ /// lane-av1leftwit: the mirror's justification used to be "no committed
9927- /// committed fixture reaches it on the decode path.)9974+ /// fixture reaches the shape on the decode path", and that was false --
9975+ /// `UV_LEFT_1MI_SPLIT_HITS` fires on five of them. The flag stays (a
9976+ /// counter-only mirror at an ODD mi row is still not a decode-path read,
9977+ /// and its result feeds only `RECT4_16_UV_PAIR_FILT_HITS`), but it is no
9978+ /// longer evidence about the `+ss_y` term, and nothing may cite it as such.
9979+ /// The decode path's own reach is `uv_left_1mi_split_hits()`.
9928 fn smooth_uv_neighbour_unsnapped(9980 fn smooth_uv_neighbour_unsnapped(
9929 &self,9981 &self,
9930 mi_r: usize,9982 mi_r: usize,
@@ -9981,13 +10033,18 @@ impl Neighbours {
9981 // its own row at 4:2:2 (`ss_y == 0`); this read its own row at every10033 // its own row at 4:2:2 (`ss_y == 0`); this read its own row at every
9982 // subsampling. An earlier attempt applied the `ss_y` term to the WRONG10034 // subsampling. An earlier attempt applied the `ss_y` term to the WRONG
9983 // read (the above) and regressed the byte-exact 4:2:0 control, which10035 // read (the above) and regressed the byte-exact 4:2:0 control, which
9984- // is what exposed the crossing. The premise that blocked the correct10036+ // is what exposed the crossing. lane-av1leftwit CORRECTED the claim
9985- // read -- "no committed fixture presents a 1-mi-tall left neighbour at10037+ // this comment used to make: "six committed 4:2:0 fixtures reach it,
9986- // 4:2:0/4:4:0" -- was wrong: the observable condition is not the 8x410038+ // and on `reelb_ss600_key_frame.obu` the boolean flips" was never
9987- // leaf specifically but any left neighbour at most 1 mi tall, which10039+ // measured. Measured over all 48 committed fixtures that decode
9988- // 4:2:0 partitioning produces constantly. Six committed 4:2:010040+ // (`lanes/av1leftwit.report.md`), `reelb_ss600_key_frame.obu` reads
9989- // fixtures reach it (see the report's measurement table), and on10041+ // `mode_diff=0 smooth_diff=0 split1mi=0`, and exactly FIVE fixtures
9990- // `reelb_ss600_key_frame.obu` the boolean flips.10042+ // put a 1-mi-tall left neighbour in front of a decode-path read at
10043+ // all -- `gm_small_side_witness` (5), `reelc_sb128_inter_witness` (7),
10044+ // `av112bit-{inter,compound,compound-masked}` (1 each) -- and in every
10045+ // one of those reads the two blocks agree on `uv_mode`. So the SHAPE is
10046+ // reachable (see `UV_LEFT_1MI_SPLIT_HITS`) and the term's VALUE
10047+ // changing is what is still unwitnessed.
9991 let above_mi = (mi_r.saturating_sub(1), mi_c + ss_x);10048 let above_mi = (mi_r.saturating_sub(1), mi_c + ss_x);
9992 // lane-av1leftref: libaom's LEFT read carries the `+ss_y` ROW term --10049 // lane-av1leftref: libaom's LEFT read carries the `+ss_y` ROW term --
9993 // `base_mi[ss_y * mi_stride - 1]` (`av1_common_int.h:1400-1401`) is10050 // `base_mi[ss_y * mi_stride - 1]` (`av1_common_int.h:1400-1401`) is
@@ -9996,11 +10053,17 @@ impl Neighbours {
9996 // row at every subsampling. The term is only observable when the two10053 // row at every subsampling. The term is only observable when the two
9997 // cells hold DIFFERENT blocks, i.e. the left neighbour is 1 mi tall or10054 // cells hold DIFFERENT blocks, i.e. the left neighbour is 1 mi tall or
9998 // shorter -- then `(row, col-1)` and `(row+1, col-1)` are two blocks10055 // shorter -- then `(row, col-1)` and `(row+1, col-1)` are two blocks
9999- // and only libaom's is the chroma reference. The two counters below10056+ // and only libaom's is the chroma reference. Three counters measure
10000- // are the gate's non-vacuity proof: the mode value moved on10057+ // that, and the third is the one the other two need: a read can only
10001- // `UV_LEFT_SS_Y_MODE_DIFF_HITS` reads, and the boolean this feeds10058+ // differ if the two cells are written by DIFFERENT blocks, which
10059+ // `UV_LEFT_1MI_SPLIT_HITS` counts off the per-cell owner stamp
10060+ // (`uv_owner`, below). A DIFF bucket that reads 0 while SPLIT reads 0
10061+ // was never in contention; a DIFF bucket that reads 0 while SPLIT
10062+ // reads > 0 is the term being unobservable on real material, not
10063+ // unreachable. `..._MODE_DIFF_HITS` / `..._SMOOTH_DIFF_HITS` then say
10064+ // whether the mode value, and the boolean this feeds
10002 // (`is_smooth_mode` -> `av1_get_intra_edge_filter_type` -> the chroma10065 // (`is_smooth_mode` -> `av1_get_intra_edge_filter_type` -> the chroma
10003- // edge filter) flipped on `UV_LEFT_SS_Y_SMOOTH_DIFF_HITS`.10066+ // edge filter), actually moved.
10004 let left_mi = (mi_r + ss_y, mi_c.saturating_sub(1));10067 let left_mi = (mi_r + ss_y, mi_c.saturating_sub(1));
10005 let read_left = |row: usize| -> usize {10068 let read_left = |row: usize| -> usize {
10006 match self.uv_mode_row.get(row) {10069 match self.uv_mode_row.get(row) {
@@ -10037,6 +10100,36 @@ impl Neighbours {
10037 if is_smooth_mode(own_row) != is_smooth_mode(left) {10100 if is_smooth_mode(own_row) != is_smooth_mode(left) {
10038 hit!(UV_LEFT_SS_Y_SMOOTH_DIFF_HITS);10101 hit!(UV_LEFT_SS_Y_SMOOTH_DIFF_HITS);
10039 }10102 }
10103+ // lane-av1leftwit: the geometry the `+ss_y` term needs. The two
10104+ // cells are one left mi column apart, so they are two different
10105+ // blocks exactly when the left neighbour is 1 mi tall or shorter.
10106+ let col = left_mi.1;
10107+ let epoch = UV_OWNER_EPOCH.with(|c| c.get()) & 0xff00_0000;
10108+ let own = (col < self.uv_grid_cols)
10109+ .then(|| self.uv_owner.get(mi_r * self.uv_grid_cols + col).copied())
10110+ .flatten()
10111+ .filter(|o| o & 0xff00_0000 == epoch)
10112+ .unwrap_or(0);
10113+ let down = self
10114+ .uv_owner
10115+ .get((mi_r + ss_y) * self.uv_grid_cols + col)
10116+ .copied()
10117+ .filter(|o| o & 0xff00_0000 == epoch)
10118+ .unwrap_or(0);
10119+ if own != 0 && down != 0 && own != down {
10120+ hit!(UV_LEFT_1MI_SPLIT_HITS);
10121+ if crate::envflags::env_flag!("EC_LEFTSSY") {
10122+ eprintln!(
10123+ "EC_LEFTSSY epoch={} mi=({mi_r},{mi_c}) left_col={col} \
10124+ owners=({},{})->({},{}) modes={own_row}/{left}",
10125+ epoch >> 24,
10126+ own >> 12 & 0xfff,
10127+ own & 0xfff,
10128+ down >> 12 & 0xfff,
10129+ down & 0xfff,
10130+ );
10131+ }
10132+ }
10040 }10133 }
10041 if have_above && cell(&self.uv_mode_grid, mi_r - 1, mi_c).is_some_and(|m| {10134 if have_above && cell(&self.uv_mode_grid, mi_r - 1, mi_c).is_some_and(|m| {
10042 !matches!(self.uv_mode_col.get(mi_c), Some(&(row, cm)) if usize::from(row) == mi_r - 1 && usize::from(cm) == m)10135 !matches!(self.uv_mode_col.get(mi_c), Some(&(row, cm)) if usize::from(row) == mi_r - 1 && usize::from(cm) == m)
@@ -17912,6 +18005,16 @@ fn decode_rect4_16_strip(
17912 // frame's own `ss_x` -- the unsnapped read is the pair-merge witness18005 // frame's own `ss_x` -- the unsnapped read is the pair-merge witness
17913 // counter's mirror of the snapping form, and the shipped read offsets18006 // counter's mirror of the snapping form, and the shipped read offsets
17914 // the above COLUMN by `+ss_x` (libaom's `chroma_above_mi`).18007 // the above COLUMN by `+ss_x` (libaom's `chroma_above_mi`).
18008+ //
18009+ // lane-av1leftwit: this mirror is NOT evidence about the left read's
18010+ // `+ss_y` term, whatever a report once said. It reads the leaf's own
18011+ // (odd) mi row, which no decode call site does -- every one of them
18012+ // uses the snapping form, whose base row is even -- and its result
18013+ // feeds `RECT4_16_UV_PAIR_FILT_HITS` only. What it measures is real
18014+ // and worth keeping (the pair's chroma-reference read against the
18015+ // leaf's own row: 51/24/121/0/1 hits on the five fixtures censused),
18016+ // so it stays; the decode path's own reach for the `+ss_y` term is
18017+ // `uv_left_1mi_split_hits()`.
17915 if smooth_neighbor_uv18018 if smooth_neighbor_uv
17916 != neighbours.smooth_uv_neighbour_unsnapped(18019 != neighbours.smooth_uv_neighbour_unsnapped(
17917 lmi.0,18020 lmi.0,
crates/ec-av1/src/stream.rsmodified+95 -8
@@ -44870,14 +44870,17 @@ pub(crate) mod tests {
44870 /// every subsampling until this lane.44870 /// every subsampling until this lane.
44871 ///44871 ///
44872 /// The read is only observable when the two cells hold DIFFERENT blocks --44872 /// The read is only observable when the two cells hold DIFFERENT blocks --
44873- /// a left neighbour at most 1 mi tall. Measured over every committed44873+ /// a left neighbour at most 1 mi tall (1 mi = 4 luma px, so a 4x4/8x4/16x4
44874- /// fixture and ~1000 swept aomenc encodes (report table), that never44874+ /// /32x4/64x4 leaf). lane-av1leftwit measured that shape off a per-cell
44875- /// happens on a decode-path read: `uv_mode_grid` runs down a left mi44875+ /// owner stamp instead of the mode value: `uv_left_1mi_split_hits()` counts
44876- /// column always have EVEN length, because libaom only starts a block on44876+ /// decode-path reads whose two cells were written by DIFFERENT blocks, and
44877- /// an odd mi row with an 8-px strip, and the 4-px `HORZ_4` strips aomenc44877+ /// it is NOT zero -- five committed fixtures carry it (15 reads in all,
44878- /// does pick all land inside one mi row. So the term is a proven no-op on44878+ /// `lanes/av1leftwit.report.md`). What no committed fixture shows is the two
44879- /// today's material, and this gate pins BOTH halves of that statement:44879+ /// blocks DISAGREEING on `uv_mode`, which is what `mode_diff`/`smooth_diff`
44880- /// the arm runs thousands of times, and it never changes an answer.44880+ /// below measure. So this gate pins both halves honestly: the arm runs
44881+ /// thousands of times, the shape it needs is genuinely reached, and the
44882+ /// term has not yet been seen to change an answer. Its exactness arms are
44883+ /// what would decide the shipped read if a DIFF bucket ever went non-zero.
44881 ///44884 ///
44882 /// A non-zero DIFF bucket is not a failure here -- it is the first stream44885 /// A non-zero DIFF bucket is not a failure here -- it is the first stream
44883 /// that witnesses the term, and the exactness arms below are what then44886 /// that witnesses the term, and the exactness arms below are what then
@@ -44925,6 +44928,90 @@ pub(crate) mod tests {
44925 );44928 );
44926 }44929 }
44927 44930
44931+ /// lane-av1leftwit: the `+ss_y` term's SHAPE is reachable on the decode
44932+ /// path, and this is the gate that says so.
44933+ ///
44934+ /// lane-av1leftref shipped the left read's `+ss_y` row term with the
44935+ /// argument that the shape it needs -- a left neighbour at most 1 mi tall,
44936+ /// so the cell this decoder read and the cell libaom reads belong to
44937+ /// different blocks -- is "structurally absent, because aomenc never starts
44938+ /// a block on an odd mi row". Both halves of that are wrong. libaom's
44939+ /// `PARTITION_HORZ_4` puts its `i == 0` child on the PARENT's own mi row
44940+ /// (`decode_partition`, `av1/decoder/decodeframe.c`: `mi_row + i * bw / 4`),
44941+ /// and a 16x16 parent sits on a 4-mi grid, so a 1-mi-tall leaf at an EVEN
44942+ /// row is what the syntax asks for, not forbids. And the shape is measured
44943+ /// in the corpus: these two fixtures each present it to a real decode-path
44944+ /// read.
44945+ ///
44946+ /// The counter is `decode::uv_left_1mi_split_hits()`, incremented only
44947+ /// where `decode_path` is true -- the snapping form every decode call site
44948+ /// uses -- so the 16x4/4x16 pair witness's counter-only mirror (which
44949+ /// reads an odd mi row and feeds `RECT4_16_UV_PAIR_FILT_HITS`) cannot
44950+ /// inflate it. `UV_LEFT_SS_Y_READS` alone would prove nothing: it counts
44951+ /// every read with a left neighbour, whether or not the two cells differ.
44952+ ///
44953+ /// NON-VACUITY: the `uv_owner` stamp the counter turns on was removed for
44954+ /// one build; both arms fell to 0 and this gate failed on the census
44955+ /// (report §5), so a decoder that stops recording which block owns a cell
44956+ /// fails here instead of passing vacuously. It is deliberately NOT a
44957+ /// mutation of the `+ss_y` term itself: the term's own mutation leaves
44958+ /// these reads untouched, which is the honest limit of what the fixture
44959+ /// set can decide (the kf900 gate above owns the exactness side).
44960+ #[test]
44961+ fn a_committed_4to20_stream_presents_a_one_mi_left_neighbour_to_a_decode_path_read() {
44962+ const NAME: &str = "a_committed_4to20_stream_presents_a_one_mi_left_neighbour_to_a_decode_path_read";
44963+ // (fixture, frames, width, height, measured split-owner reads)
44964+ let arms: [(&str, usize, usize, usize, usize); 2] = [
44965+ ("gm_small_side_witness.obu", 33, 1920, 792, 5),
44966+ ("reelc_sb128_inter_witness.obu", 15, 1920, 792, 7),
44967+ ];
44968+ for (fixture, want_frames, width, height, want_split) in arms {
44969+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
44970+ .join("fixtures")
44971+ .join(fixture);
44972+ let stream = std::fs::read(&path)
44973+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
44974+ let before_split = crate::decode::uv_left_1mi_split_hits();
44975+ let before_reads = crate::decode::uv_left_ss_y_reads();
44976+ let before_mode = crate::decode::uv_left_ss_y_mode_diff_hits();
44977+ let before_smooth = crate::decode::uv_left_ss_y_smooth_diff_hits();
44978+ let frames = match decode_stream(&stream) {
44979+ Ok(frames) => frames,
44980+ Err(e) => panic!("{NAME}: {fixture} refused: {e}"),
44981+ };
44982+ let split = crate::decode::uv_left_1mi_split_hits() - before_split;
44983+ assert_eq!(
44984+ frames.len(),
44985+ want_frames,
44986+ "{NAME}: {fixture} frame count"
44987+ );
44988+ assert!(
44989+ frames
44990+ .iter()
44991+ .all(|f| (f.width, f.height) == (width, height)),
44992+ "{NAME}: {fixture} is not {width}x{height}"
44993+ );
44994+ assert_eq!(
44995+ split, want_split,
44996+ "{NAME}: {fixture} presented {split} 1-mi-tall left neighbours to \
44997+ a decode-path read, measured {want_split} -- the census this \
44998+ gate pins moved"
44999+ );
45000+ // Printed, not asserted: `== 0` would pin an accident, and a
45001+ // non-zero value is the first WITNESS of the term rather than a
45002+ // failure (that is what the kf900 gate above then decides against
45003+ // the oracle).
45004+ eprintln!(
45005+ "{NAME}: {fixture}: {split} 1-mi-tall left neighbours in \
45006+ {} decode-path reads, +ss_y changed the mode {} and the smooth \
45007+ boolean {} times",
45008+ crate::decode::uv_left_ss_y_reads() - before_reads,
45009+ crate::decode::uv_left_ss_y_mode_diff_hits() - before_mode,
45010+ crate::decode::uv_left_ss_y_smooth_diff_hits() - before_smooth,
45011+ );
45012+ }
45013+ }
45014+
44928 /// lane-av1formatsweep: the ODD CODED DIMENSION cell -- a frame whose45015 /// lane-av1formatsweep: the ODD CODED DIMENSION cell -- a frame whose
44929 /// width or height is not a multiple of 8, so the last mode-info column45016 /// width or height is not a multiple of 8, so the last mode-info column
44930 /// and the last chroma plane row/column are PARTIAL (`mi_cols * 8 >45017 /// 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.