forge
Explore
Log in

Don't you dare go Hollow

Merge lane-golomb 173b793 into lane-cdef

Browse files at this commit

6f7bda6d08c25393ad92011e03f475271cec0e42Ahmet Kaan GümüşParent: 9c20172414fb70
Conflicts, both in decode.rs:
* dump_stage's per-decode-order-frame index: both lanes added one. Kept this
  lane's shared dump_stage_idx() helper (dump_stage16 uses it too) and dropped
  lane-golomb's duplicate thread_local counter.
* the var-tx leaf loop: took main's general (row, col, tw, th) rect leaves and
  lane-golomb's fill_lf_grid_leaf_luma writer, so a rectangular leaf still
  overrides LUMA tx dims only -- routing it through fill_lf_grid_rect would
  recompute the chroma dims from the leaf span (libaom get_transform_size
  applies the split override for AOM_PLANE_Y only).

cdf.rs byte-identical across main, lane-golomb and this tree.

13 changed files +1681 -138

crates/ec-av1/src/decode.rsmodified+379 -138
@@ -2107,6 +2107,44 @@ pub(crate) fn sb_rect_hits() -> usize {
21072107 SB_RECT_HITS.with(|c| c.get())
21082108 }
21092109
2110+// lane-golomb r2: the 32x32-level FRAME-EDGE partition. Slot 0/1 = the
2111+// gathered edge bit read as 0 (HORZ/VERT) / 1 (SPLIT); slot 2 = a 32-level
2112+// PARTITION_HORZ decoded with `has_rows32 == false` (only the top 32x16 half
2113+// is coded), slot 3 = a PARTITION_VERT with `has_cols32 == false`. Both tile
2114+// paths (intra and inter) feed the same counter.
2115+//
2116+// lane-golomb r3: slots 4..7 are the same four facts one level up, at the
2117+// SUPERBLOCK (64x64) edge -- 4/5 = the gathered 64-level bit read as
2118+// HORZ/VERT / SPLIT, 6 = a 64x32 bottom-edge strip decoded with
2119+// `has_rows == false`, 7 = a 32x64 right-edge strip. Real aomenc answers a
2120+// bottom-edge superblock with the 64-level HORZ (measured: 192x80 flat-band,
2121+// every SB of the last row), so the 32-level slots stay 0 on that content and
2122+// only these prove the arm fired.
2123+thread_local! {
2124+ static EDGE32_HITS: std::cell::Cell<[usize; 8]> =
2125+ const { std::cell::Cell::new([0; 8]) };
2126+}
2127+
2128+/// Current value of [`EDGE32_HITS`].
2129+pub(crate) fn edge32_hits() -> [usize; 8] {
2130+ EDGE32_HITS.with(|c| c.get())
2131+}
2132+
2133+/// [`bump_edge32`] of `base + bit`, returning the bit -- the gathered edge
2134+/// reads are `if`-conditions, so the counter has to ride the expression.
2135+fn bump_edge32_bit(base: usize, bit: usize) -> usize {
2136+ bump_edge32(base + bit.min(1));
2137+ bit
2138+}
2139+
2140+fn bump_edge32(slot: usize) {
2141+ EDGE32_HITS.with(|c| {
2142+ let mut h = c.get();
2143+ h[slot] += 1;
2144+ c.set(h)
2145+ });
2146+}
2147+
21102148 // lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/
21112149 // `_B`/`VERT_A`/`_B` at 64x64 -- two 32x32 squares plus one 64x32/32x64
21122150 // strip) fired. Real aomenc picks these at 64 even with
@@ -4252,6 +4290,36 @@ impl Neighbours {
42524290 }
42534291 }
42544292
4293+ /// One var-tx / split-tx LEAF's own LUMA transform dims over its mi span.
4294+ /// libaom `get_transform_size` (av1_loopfilter.c:207) applies the split
4295+ /// override only `if ((plane == AOM_PLANE_Y) && ...)` -- chroma keeps
4296+ /// `av1_get_max_uv_txsize(mbmi->bsize)`, the whole BLOCK's uv transform.
4297+ /// Routing a leaf through [`Self::fill_lf_grid_rect`] recomputed the uv
4298+ /// dims from the LEAF span and so invented chroma transform edges the
4299+ /// deblocker then filtered (lane-golomb r6). `ref_grid`/`delta_lf_grid`
4300+ /// are already correct from the block's own fill over the same span.
4301+ fn fill_lf_grid_leaf_luma(
4302+ &mut self,
4303+ at_mi: (usize, usize),
4304+ w_mi: usize,
4305+ h_mi: usize,
4306+ tx_px: u8,
4307+ tx_h_px: u8,
4308+ ) {
4309+ let (mi_r, mi_c) = at_mi;
4310+ for rr in 0..h_mi {
4311+ for cc in 0..w_mi {
4312+ let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc);
4313+ if let Some(cell) = self.tx_grid.get_mut(idx) {
4314+ *cell = tx_px;
4315+ }
4316+ if let Some(cell) = self.tx_h_grid.get_mut(idx) {
4317+ *cell = tx_h_px;
4318+ }
4319+ }
4320+ }
4321+ }
4322+
42554323 /// Marks every 4x4 mi cell a just-decoded coded block covers with its
42564324 /// `skip` flag -- `at_mi`/`side_mi` are the block's own position and
42574325 /// width/height in 4x4 mode-info units (mirroring [`Self::record_mi`]'s
@@ -11981,8 +12049,8 @@ fn read_inter_plane_rect(
1198112049 // `av1_get_ext_tx_set_type`'s DCT-only clamp is on `tx_size_sqr_up`, i.e.
1198212050 // the *longer* side of this rect transform.
1198312051 let default_tx_type = match inherited_luma_tx_type {
11984- Some(t) if w.max(h) < 32 => t,
11985- _ => TxType::DctDct,
12052+ Some(t) => reduce_inherited_chroma_tx_type(t, w, h),
12053+ None => TxType::DctDct,
1198612054 };
1198712055 // lane-r14 r2: a 64-length axis codes only its low 32 coefficients
1198812056 // (`av1_get_max_eob`), so the coded unit is the `min(w,32) x min(h,32)`
@@ -12149,6 +12217,45 @@ fn read_inter_luma8(
1214912217
1215012218 /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its
1215112219 /// coefficient tables from -- the inter counterpart of [`txbset_for`].
12220+/// `av1_get_tx_type`'s chroma tail (libaom `av1/common/blockd.h:1291-1305`):
12221+/// an inter block's chroma transform inherits the *colocated luma* unit's
12222+/// coded `tx_type`, then drops back to `DCT_DCT` unless that type is a member
12223+/// of the extended set the CHROMA transform size selects
12224+/// (`av1_ext_tx_used[av1_get_ext_tx_set_type(uv_tx, 1, reduced)][tx_type]`,
12225+/// `blockd.h:1036`/`1097`). lane-golomb r7: we used to force `DCT_DCT` at
12226+/// every chroma side >= 32, but `av1_get_ext_tx_set_type`'s DCT-only rung is
12227+/// `tx_size_sqr_up > TX_32X32`; at exactly TX_32X32 an inter block reads
12228+/// `EXT_TX_SET_DCT_IDTX`, so a 64x64 inter block whose first luma leaf coded
12229+/// `IDTX` inherits IDTX on its 32x32 chroma units. `IDTX` and `DCT_DCT` are
12230+/// both `TX_CLASS_2D`, so that mistake left the entropy stream perfectly in
12231+/// sync and only corrupted the inverse transform (one 64x64 superblock of
12232+/// high-frequency chroma noise, luma bit-exact).
12233+fn reduce_inherited_chroma_tx_type(t: TxType, w: usize, h: usize) -> TxType {
12234+ use TxType::*;
12235+ let sqr_up = w.max(h);
12236+ let sqr = w.min(h);
12237+ let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
12238+ // `av1_get_ext_tx_set_type(tx_size, is_inter = 1, reduced)`.
12239+ let allowed: &[TxType] = if sqr_up > 32 {
12240+ // EXT_TX_SET_DCTONLY
12241+ &[DctDct]
12242+ } else if sqr_up == 32 || reduced {
12243+ // EXT_TX_SET_DCT_IDTX
12244+ &[DctDct, Idtx]
12245+ } else if sqr == 16 {
12246+ // EXT_TX_SET_DTT9_IDTX_1DDCT -- TX_TYPES 0..=11, i.e. everything but
12247+ // the four 1D ADST/FLIPADST types.
12248+ &[
12249+ DctDct, AdstDct, DctAdst, AdstAdst, FlipAdstDct, DctFlipAdst, FlipAdstFlipAdst,
12250+ AdstFlipAdst, FlipAdstAdst, Idtx, VDct, HDct,
12251+ ]
12252+ } else {
12253+ // EXT_TX_SET_ALL16
12254+ return t;
12255+ };
12256+ if allowed.contains(&t) { t } else { DctDct }
12257+}
12258+
1215212259 fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
1215312260 match tx_px {
1215412261 32 => TxbSet::Luma32Inter,
@@ -12654,6 +12761,18 @@ fn deblock_plane(
1265412761 // last coded mi column's horizontal edges were filtered when libaom's
1265512762 // real output leaves them untouched (r6's post-deblock diff, 37 px, all
1265612763 // in columns 44-47); clipping here closes it (3/3 frames pixel-exact).
12764+ // lane-golomb r9: the bound is the MI-ROUNDED frame, not the coded
12765+ // frame. libaom's `av1_filter_block_plane_vert/horz` walk the superblock
12766+ // and stop at `cm->mi_params.mi_cols`/`mi_rows`, which
12767+ // `av1_set_mb_mi` derives from `ALIGN_POWER_OF_TWO(width, 3)` -- the
12768+ // 8-pixel-aligned frame, i.e. a 68-wide frame is filtered out to column
12769+ // 72 and the vertical edge AT x=68 is a real edge that rewrites the
12770+ // in-crop columns 64..67. Clipping at `frame_width` skipped it, which is
12771+ // the +-1 straddling-band defect (68x192 cq35, frame 1, 141 luma pixels
12772+ // all in columns 64..67; frame 0 survived because that edge carried no
12773+ // filter level there). r7's superres measurement is preserved: its frame
12774+ // was already 8-aligned, so this bound equals `frame_width` there and
12775+ // still excludes the superblock padding up to `true_width`.
1265712776 let (cw, ch) = if chroma {
1265812777 (frame_width.div_ceil(2), frame_height.div_ceil(2))
1265912778 } else {
@@ -12664,11 +12783,17 @@ fn deblock_plane(
1266412783 plane.true_height.min(ch),
1266512784 plane.width,
1266612785 );
12786+ if std::env::var_os("EC_AV1_DEBLOCK_TRACE_V").is_some() {
12787+ eprintln!("DEBLOCK plane={plane_idx} tw={tw} th={th} stride={stride} true={}x{} crop={cw}x{ch}", plane.true_width, plane.true_height);
12788+ }
1266712789 let mut y0 = 0usize;
1266812790 while y0 < th {
1266912791 let mut x0 = 4usize;
1267012792 while x0 < tw {
1267112793 if let Some((len, level)) = edge_params(lf, n, plane_idx, 0, chroma, x0, y0) {
12794+ if std::env::var_os("EC_AV1_DEBLOCK_TRACE_V").is_some() && plane_idx == 0 {
12795+ eprintln!("VEDGE x0={x0} y0={y0} len={len} level={level}");
12796+ }
1267212797 filter_edge(
1267312798 &mut plane.data,
1267412799 y0 * stride + x0,
@@ -12882,13 +13007,30 @@ fn apply_loop_restoration(
1288213007 deblocked_v: &PlaneBuf,
1288313008 lr: &LoopRestorationParams,
1288413009 grid: &crate::restoration::RestorationGrid,
13010+ // lane-golomb r8: this frame header's own (cropped) luma size. Loop
13011+ // restoration is the ONE post-decode filter that does NOT run over the
13012+ // mi-rounded plane: libaom's `av1_loop_restoration_filter_frame` sizes
13013+ // every plane with `av1_get_upsampled_plane_size` -- `plane_w =
13014+ // ROUND_POWER_OF_TWO(cm->superres_upscaled_width, ss_x)`, `plane_h =
13015+ // ROUND_POWER_OF_TWO(cm->height, ss_y)` (`av1/common/restoration.c:47`)
13016+ // -- and asserts it equals the buffer's CROP width
13017+ // (`restoration.c:1106`), then `av1_extend_frame(..., plane_w, plane_h,
13018+ // ...)` (`restoration.c:1109`) replicates the right/bottom border from
13019+ // that cropped edge before any unit is filtered. Deblock and CDEF DO
13020+ // walk the mi grid, which is why passing `true_width`/`true_height`
13021+ // here went unnoticed until a frame whose size is not a multiple of 8
13022+ // (68 -> mi-rounded 72): the LR taps at the last four real columns then
13023+ // read this decoder's own decoded samples at columns 68..71 where
13024+ // libaom reads column 67 replicated -- +-1 over the straddling band
13025+ // (class av1-truesize-lane: true frame size vs mi-rounded).
13026+ (frame_w, frame_h): (usize, usize),
1288513027 ) {
1288613028 y.data = crate::restoration::apply_loop_restoration_plane(
1288713029 &y.data,
1288813030 &deblocked_y.data,
1288913031 y.width,
12890- y.true_width,
12891- y.true_height,
13032+ frame_w,
13033+ frame_h,
1289213034 0,
1289313035 lr.frame_restoration_type[0],
1289413036 lr.loop_restoration_size[0],
@@ -12899,8 +13041,8 @@ fn apply_loop_restoration(
1289913041 &u.data,
1290013042 &deblocked_u.data,
1290113043 u.width,
12902- u.true_width,
12903- u.true_height,
13044+ frame_w.div_ceil(2),
13045+ frame_h.div_ceil(2),
1290413046 1,
1290513047 lr.frame_restoration_type[1],
1290613048 lr.loop_restoration_size[1],
@@ -12911,8 +13053,8 @@ fn apply_loop_restoration(
1291113053 &v.data,
1291213054 &deblocked_v.data,
1291313055 v.width,
12914- v.true_width,
12915- v.true_height,
13056+ frame_w.div_ceil(2),
13057+ frame_h.div_ceil(2),
1291613058 1,
1291713059 lr.frame_restoration_type[2],
1291813060 lr.loop_restoration_size[2],
@@ -13475,11 +13617,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1347513617 match (has_cols, has_rows) {
1347613618 (true, false) => {
1347713619 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE));
13620+ bump_edge32(4 + b.min(1) as usize);
1347813621 bump_edge_part(b.min(1) as usize);
1347913622 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
1348013623 }
1348113624 (false, true) => {
1348213625 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE));
13626+ bump_edge32(4 + b.min(1) as usize);
1348313627 bump_edge_part(b.min(1) as usize);
1348413628 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }
1348513629 }
@@ -13548,6 +13692,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1354813692 &cdfs.partition_w32[ctx32],
1354913693 VERT_ALIKE,
1355013694 ));
13695+ bump_edge32(b.min(1) as usize);
1355113696 bump_edge_part(2 + b.min(1) as usize);
1355213697 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
1355313698 }
@@ -13556,6 +13701,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1355613701 &cdfs.partition_w32[ctx32],
1355713702 HORZ_ALIKE,
1355813703 ));
13704+ bump_edge32(b.min(1) as usize);
1355913705 bump_edge_part(2 + b.min(1) as usize);
1356013706 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }
1356113707 }
@@ -14211,6 +14357,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1421114357 tx_select,
1421214358 reduced_tx_set,
1421314359 )?;
14360+ if !has_rows32 {
14361+ bump_edge32(2);
14362+ }
1421414363 // lane-hgkf r1: at the frame edge only the first half of the strip is
1421514364 // coded (libaom `decode_partition` guards the second half with the same
1421614365 // test that made this partition non-square).
@@ -14252,6 +14401,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1425214401 tx_select,
1425314402 reduced_tx_set,
1425414403 )?;
14404+ if !has_cols32 {
14405+ bump_edge32(3);
14406+ }
1425514407 // lane-hgkf r1: at the frame edge only the first half of the strip is
1425614408 // coded (libaom `decode_partition` guards the second half with the same
1425714409 // test that made this partition non-square).
@@ -14642,6 +14794,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1464214794 tx_select,
1464314795 reduced_tx_set,
1464414796 )?;
14797+ if !has_rows {
14798+ bump_edge32(6);
14799+ }
1464514800 // lane-golomb r1: at the frame edge only the first half of the
1464614801 // strip is coded (libaom `decode_partition` guards the second
1464714802 // with the same has_rows test that made this partition non-square).
@@ -14683,6 +14838,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1468314838 tx_select,
1468414839 reduced_tx_set,
1468514840 )?;
14841+ if !has_cols {
14842+ bump_edge32(7);
14843+ }
1468614844 // lane-golomb r1: at the frame edge only the first half of the
1468714845 // strip is coded (libaom `decode_partition` guards the second
1468814846 // with the same has_cols test that made this partition non-square).
@@ -14905,7 +15063,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1490515063 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
1490615064 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);
1490715065 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
14908- apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid);
15066+ apply_loop_restoration(
15067+ &mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid,
15068+ (frame_width as usize, frame_height as usize),
15069+ );
1490915070
1491015071 let (fw, fh) = (frame_width as usize, frame_height as usize);
1491115072 if fw == width && fh == height {
@@ -15297,10 +15458,9 @@ fn read_inter_plane(
1529715458 // `tx_type` -- `av1_get_tx_type` (libaom `blockd.h`): an inter block's
1529815459 // chroma plane never codes its own `tx_type` symbol, but (unlike an
1529915460 // intra block, which falls back to `Intra_Mode_To_Tx_Type`) it inherits
15300- // the colocated luma transform's coded type verbatim, clamped back to
15301- // `DCT_DCT` at the chroma tx sizes the spec forces DCT-only
15302- // (`av1_get_ext_tx_set_type`: `tx_size_sqr_up >= TX_32X32`, i.e. this
15303- // function's own `side >= 32`). `None` for the luma call itself
15461+ // the colocated luma transform's coded type, narrowed to the extended
15462+ // set the CHROMA size selects ([`reduce_inherited_chroma_tx_type`]).
15463+ // `None` for the luma call itself
1530415464 // (`plane_idx == 0`), where the `TxbSet`'s own symbol (or the true
1530515465 // `DCT_DCT` default at 32-point+) already resolves it without help.
1530615466 inherited_luma_tx_type: Option<TxType>,
@@ -15318,8 +15478,8 @@ fn read_inter_plane(
1531815478 };
1531915479 let mut coding = cdfs.txb(set, tx_mode);
1532015480 let default_tx_type = match inherited_luma_tx_type {
15321- Some(t) if side < 32 => t,
15322- _ => TxType::DctDct,
15481+ Some(t) => reduce_inherited_chroma_tx_type(t, side, side),
15482+ None => TxType::DctDct,
1532315483 };
1532415484 let (grid, tx_type) = read_coeffs(
1532515485 dec,
@@ -15712,22 +15872,33 @@ fn obmc_mask(len: usize) -> &'static [u8] {
1571215872 /// A bordering block's own resolved interp filter kernel, `(h, v)` --
1571315873 /// mirrors [`resolve_interp_filter`]'s own return order from its stored
1571415874 /// `[u8; 2]` (`Neighbours::above_filter`/`left_filter`, `[sym0, sym1]` =
15715-/// `[v_sym, h_sym]`). Never calls `from_switchable_symbol` on the `[3, 3]`
15716-/// sentinel: that value is only ever stored for an intra neighbour (already
15717-/// excluded by [`overlappable_above`]/[`overlappable_left`]'s `is_inter`
15718-/// gate) or when `interp_fixed` is `Some` for the whole frame, handled here
15719-/// first.
15875+/// `[v_sym, h_sym]`). The `[3, 3]` sentinel is only ever stored for an intra
15876+/// neighbour (excluded by [`overlappable_above`]/[`overlappable_left`]'s
15877+/// `is_inter` gate) or when `interp_fixed` is `Some` for the whole frame
15878+/// (handled here first) -- so a sentinel reaching the kernel lookup means the
15879+/// stream desynced upstream, and this refuses instead of panicking.
1572015880 fn neighbour_filter(
1572115881 interp_fixed: Option<mc::InterpFilterKind>,
1572215882 sym: [u8; 2],
15723-) -> (mc::InterpFilterKind, mc::InterpFilterKind) {
15883+) -> Result<(mc::InterpFilterKind, mc::InterpFilterKind)> {
1572415884 if let Some(kind) = interp_fixed {
15725- return (kind, kind);
15885+ return Ok((kind, kind));
15886+ }
15887+ // lane-golomb r9: this used to hand the sentinel straight to
15888+ // `from_switchable_symbol`, which PANICS on any value above 2 -- a crash
15889+ // on stream data (measured on a real 192x68 cq40 aomenc stream, where an
15890+ // inter leaf below 8x8 desyncs upstream and leaves an unrecorded filter
15891+ // behind). A decoder must refuse such a stream by name, never abort the
15892+ // process; the desync that produces the sentinel belongs to lane-intersub8.
15893+ if sym[0] > 2 || sym[1] > 2 {
15894+ return Err(unsupported(
15895+ "an OBMC neighbour whose switchable interp filter was never recorded",
15896+ ));
1572615897 }
15727- (
15898+ Ok((
1572815899 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),
1572915900 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),
15730- )
15901+ ))
1573115902 }
1573215903
1573315904 /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh
@@ -16005,7 +16176,7 @@ fn obmc_blend(
1600516176 let (h_kind, v_kind) = neighbour_filter(
1600616177 interp_fixed,
1600716178 neighbours.above_filter[mi_col + off4],
16008- );
16179+ )?;
1600916180 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
1601016181 let nb_scale = mc::scale_factor(ny.width, frame_width);
1601116182 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);
@@ -16024,7 +16195,7 @@ fn obmc_blend(
1602416195 let (h_kind, v_kind) = neighbour_filter(
1602516196 interp_fixed,
1602616197 neighbours.left_filter[mi_row + off4],
16027- );
16198+ )?;
1602816199 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
1602916200 let nb_scale = mc::scale_factor(ny.width, frame_width);
1603016201 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);
@@ -19125,21 +19296,17 @@ fn decode_inter_block(
1912519296 },
1912619297 );
1912719298 // lane-txselect: a var-tx block's deblock edges follow its own transform
19128- // units, not the block. Chroma still reads `tx_h_grid / 2` (the block's
19129- // uv transform is not split) -- a known corner-cut of this round.
19299+ // units, not the block -- for LUMA only (lane-golomb r6): the chroma
19300+ // grids keep the block's own `av1_get_max_uv_txsize`, which is what
19301+ // libaom's `get_transform_size` reads for `plane != AOM_PLANE_Y`.
1913019302 if let Some(leaves) = &vartx_leaves {
1913119303 for &(row, col, tw, th) in leaves {
19132- neighbours.fill_lf_grid_rect(
19304+ neighbours.fill_lf_grid_leaf_luma(
1913319305 (at_mi.0 + row, at_mi.1 + col),
1913419306 tw / MI,
1913519307 th / MI,
1913619308 tw as u8,
1913719309 th as u8,
19138- if globalmv_for_lf {
19139- -ref_frame_for_lf
19140- } else {
19141- ref_frame_for_lf
19142- },
1914319310 );
1914419311 }
1914519312 }
@@ -20866,7 +21033,18 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2086621033 // true size. Height must still match: AV1 superres never scales height
2086721034 // (r8's derivation, `mc.rs`'s own doc), and nothing in this decode path
2086821035 // has a vertical scaling pass.
20869- if reference.height != true_height {
21036+ // lane-golomb r8: the comparison is against the header's own frame
21037+ // height, NOT the mi-rounded `true_height`. libaom compares references
21038+ // on the CROPPED dimensions -- `av1_setup_scale_factors_for_frame(&sf,
21039+ // ref->y_crop_width, ref->y_crop_height, cm->width, cm->height)`
21040+ // (`av1/common/reconinter.c`), and a reference is "scaled" only when
21041+ // those differ (`av1_is_scaled`). A decoded `Picture` is cropped to
21042+ // `fw`/`fh`, so for any height that is not a multiple of 8 (68 ->
21043+ // mi_rows 18 -> `true_height` 72) this test compared 68 against 72 and
21044+ // refused every same-size reference (class av1-truesize-lane: true
21045+ // frame size vs mi-rounded). Height must still MATCH: AV1 superres
21046+ // never scales height, and no path here has a vertical scaling pass.
21047+ if reference.height != frame_height as usize {
2087021048 return Err(unsupported(
2087121049 "a reference picture whose height does not match this frame's own true size",
2087221050 ));
@@ -21228,7 +21406,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2122821406 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
2122921407 // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT
2123021408 // (libaom `ec_read_partition_impl`).
21231- if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)) == 1 {
21409+ if bump_edge32_bit(
21410+ 4,
21411+ dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)),
21412+ ) == 1 {
2123221413 PARTITION_SPLIT
2123321414 } else {
2123421415 PARTITION_HORZ
@@ -21238,7 +21419,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2123821419 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
2123921420 // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT
2124021421 // (libaom `ec_read_partition_impl`).
21241- if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)) == 1 {
21422+ if bump_edge32_bit(
21423+ 4,
21424+ dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)),
21425+ ) == 1 {
2124221426 PARTITION_SPLIT
2124321427 } else {
2124421428 PARTITION_VERT
@@ -21413,7 +21597,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2141321597 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
2141421598 // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT
2141521599 // (libaom `ec_read_partition_impl`).
21416- if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE)) == 1 {
21600+ if {
21601+ let b = dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE));
21602+ bump_edge32(b.min(1) as usize);
21603+ b
21604+ } == 1 {
2141721605 PARTITION_SPLIT
2141821606 } else {
2141921607 PARTITION_HORZ
@@ -21423,7 +21611,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2142321611 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
2142421612 // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT
2142521613 // (libaom `ec_read_partition_impl`).
21426- if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE)) == 1 {
21614+ if {
21615+ let b = dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE));
21616+ bump_edge32(b.min(1) as usize);
21617+ b
21618+ } == 1 {
2142721619 PARTITION_SPLIT
2142821620 } else {
2142921621 PARTITION_VERT
@@ -22055,55 +22247,63 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2205522247 allow_screen_content_tools,
2205622248 frame_width as usize,
2205722249 )?;
22058- decode_inter_block(
22059- &mut dec,
22060- &mut cdfs,
22061- &mut neighbours,
22062- &mut grid,
22063- sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)),
22064- BLOCK,
22065- mi_cols,
22066- mi_rows,
22067- &mut y,
22068- &mut u,
22069- &mut v,
22070- &ref_y,
22071- &ref_u,
22072- &ref_v,
22073- &ref_slots,
22074- &sign_bias_table,
22075- &global_motion,
22076- base_q_idx,
22077- TxbSet::Luma32,
22078- TxbSet::Luma32Inter,
22079- TxbSet::Chroma16,
22080- TX32,
22081- TX16,
22082- &scan32,
22083- &scan16,
22084- 3,
22085- allow_high_precision_mv,
22086- force_integer_mv,
22087- interp_fixed,
22088- enable_dual_filter,
22089- tpl_frame.as_ref(),
22090- reference_select,
22091- enable_masked_compound,
22092- enable_interintra_compound,
22093- enable_jnt_comp,
22094- order_hint_bits,
22095- order_hint,
22096- ref_order_hints,
22097- skip_mode_present,
22098- skip_mode_frame,
22099- switchable_motion_mode,
22100- allow_warped_motion,
22101- true,
22102- BLOCK,
22103- SUB,
22104- allow_screen_content_tools,
22105- frame_width as usize,
22106- )?;
22250+ if !has_rows32 {
22251+ bump_edge32(2);
22252+ }
22253+ // lane-golomb r2: at the frame edge only the first half of the
22254+ // strip is coded (libaom `decode_partition` guards the second
22255+ // with the same has_rows32 test that made this partition non-square).
22256+ if has_rows32 {
22257+ decode_inter_block(
22258+ &mut dec,
22259+ &mut cdfs,
22260+ &mut neighbours,
22261+ &mut grid,
22262+ sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)),
22263+ BLOCK,
22264+ mi_cols,
22265+ mi_rows,
22266+ &mut y,
22267+ &mut u,
22268+ &mut v,
22269+ &ref_y,
22270+ &ref_u,
22271+ &ref_v,
22272+ &ref_slots,
22273+ &sign_bias_table,
22274+ &global_motion,
22275+ base_q_idx,
22276+ TxbSet::Luma32,
22277+ TxbSet::Luma32Inter,
22278+ TxbSet::Chroma16,
22279+ TX32,
22280+ TX16,
22281+ &scan32,
22282+ &scan16,
22283+ 3,
22284+ allow_high_precision_mv,
22285+ force_integer_mv,
22286+ interp_fixed,
22287+ enable_dual_filter,
22288+ tpl_frame.as_ref(),
22289+ reference_select,
22290+ enable_masked_compound,
22291+ enable_interintra_compound,
22292+ enable_jnt_comp,
22293+ order_hint_bits,
22294+ order_hint,
22295+ ref_order_hints,
22296+ skip_mode_present,
22297+ skip_mode_frame,
22298+ switchable_motion_mode,
22299+ allow_warped_motion,
22300+ true,
22301+ BLOCK,
22302+ SUB,
22303+ allow_screen_content_tools,
22304+ frame_width as usize,
22305+ )?;
22306+ }
2210722307 }
2210822308 PARTITION_VERT => {
2210922309 // lane-rect r2: mirror of PARTITION_HORZ above with
@@ -22158,55 +22358,63 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2215822358 allow_screen_content_tools,
2215922359 frame_width as usize,
2216022360 )?;
22161- decode_inter_block(
22162- &mut dec,
22163- &mut cdfs,
22164- &mut neighbours,
22165- &mut grid,
22166- sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)),
22167- BLOCK,
22168- mi_cols,
22169- mi_rows,
22170- &mut y,
22171- &mut u,
22172- &mut v,
22173- &ref_y,
22174- &ref_u,
22175- &ref_v,
22176- &ref_slots,
22177- &sign_bias_table,
22178- &global_motion,
22179- base_q_idx,
22180- TxbSet::Luma32,
22181- TxbSet::Luma32Inter,
22182- TxbSet::Chroma16,
22183- TX32,
22184- TX16,
22185- &scan32,
22186- &scan16,
22187- 3,
22188- allow_high_precision_mv,
22189- force_integer_mv,
22190- interp_fixed,
22191- enable_dual_filter,
22192- tpl_frame.as_ref(),
22193- reference_select,
22194- enable_masked_compound,
22195- enable_interintra_compound,
22196- enable_jnt_comp,
22197- order_hint_bits,
22198- order_hint,
22199- ref_order_hints,
22200- skip_mode_present,
22201- skip_mode_frame,
22202- switchable_motion_mode,
22203- allow_warped_motion,
22204- true,
22205- SUB,
22206- BLOCK,
22207- allow_screen_content_tools,
22208- frame_width as usize,
22209- )?;
22361+ if !has_cols32 {
22362+ bump_edge32(3);
22363+ }
22364+ // lane-golomb r2: at the frame edge only the first half of the
22365+ // strip is coded (libaom `decode_partition` guards the second
22366+ // with the same has_cols32 test that made this partition non-square).
22367+ if has_cols32 {
22368+ decode_inter_block(
22369+ &mut dec,
22370+ &mut cdfs,
22371+ &mut neighbours,
22372+ &mut grid,
22373+ sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)),
22374+ BLOCK,
22375+ mi_cols,
22376+ mi_rows,
22377+ &mut y,
22378+ &mut u,
22379+ &mut v,
22380+ &ref_y,
22381+ &ref_u,
22382+ &ref_v,
22383+ &ref_slots,
22384+ &sign_bias_table,
22385+ &global_motion,
22386+ base_q_idx,
22387+ TxbSet::Luma32,
22388+ TxbSet::Luma32Inter,
22389+ TxbSet::Chroma16,
22390+ TX32,
22391+ TX16,
22392+ &scan32,
22393+ &scan16,
22394+ 3,
22395+ allow_high_precision_mv,
22396+ force_integer_mv,
22397+ interp_fixed,
22398+ enable_dual_filter,
22399+ tpl_frame.as_ref(),
22400+ reference_select,
22401+ enable_masked_compound,
22402+ enable_interintra_compound,
22403+ enable_jnt_comp,
22404+ order_hint_bits,
22405+ order_hint,
22406+ ref_order_hints,
22407+ skip_mode_present,
22408+ skip_mode_frame,
22409+ switchable_motion_mode,
22410+ allow_warped_motion,
22411+ true,
22412+ SUB,
22413+ BLOCK,
22414+ allow_screen_content_tools,
22415+ frame_width as usize,
22416+ )?;
22417+ }
2221022418 }
2221122419 PARTITION_HORZ_A => {
2221222420 // lane-partab r1: two 16x16 squares on top + a true
@@ -22786,7 +22994,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2278622994 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
2278722995 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);
2278822996 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
22789- apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid);
22997+ apply_loop_restoration(
22998+ &mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid,
22999+ (frame_width as usize, frame_height as usize),
23000+ );
2279023001
2279123002 let motion_field = build_motion_field(
2279223003 &grid,
@@ -22859,6 +23070,36 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2285923070 #[cfg(test)]
2286023071 mod tests {
2286123072
23073+ /// lane-golomb r7: [`reduce_inherited_chroma_tx_type`] must reproduce
23074+ /// `av1_ext_tx_used[av1_get_ext_tx_set_type(uv_tx, 1, reduced)]`
23075+ /// (libaom `av1/common/blockd.h:1036`/`1097`) exactly -- the g35 residue
23076+ /// was one 64x64 inter superblock whose 32x32 chroma units are
23077+ /// `EXT_TX_SET_DCT_IDTX`, where IDTX survives and we forced `DCT_DCT`.
23078+ #[test]
23079+ fn an_inter_chroma_transform_narrows_its_inherited_tx_type_to_its_own_set() {
23080+ use TxType::*;
23081+ // EXT_TX_SET_DCTONLY: `tx_size_sqr_up > TX_32X32`.
23082+ set_inter_tx_mode(true, false, true);
23083+ assert_eq!(reduce_inherited_chroma_tx_type(Idtx, 64, 64), DctDct);
23084+ // EXT_TX_SET_DCT_IDTX at exactly TX_32X32 -- the residue's case.
23085+ assert_eq!(reduce_inherited_chroma_tx_type(Idtx, 32, 32), Idtx);
23086+ assert_eq!(reduce_inherited_chroma_tx_type(AdstAdst, 32, 32), DctDct);
23087+ // EXT_TX_SET_DTT9_IDTX_1DDCT at `tx_size_sqr == TX_16X16`: the four
23088+ // 1D ADST/FLIPADST types (TX_TYPES 12..15) drop out, the rest stay.
23089+ assert_eq!(reduce_inherited_chroma_tx_type(HDct, 16, 16), HDct);
23090+ assert_eq!(reduce_inherited_chroma_tx_type(FlipAdstAdst, 16, 16), FlipAdstAdst);
23091+ assert_eq!(reduce_inherited_chroma_tx_type(HAdst, 16, 16), DctDct);
23092+ // EXT_TX_SET_ALL16 below that (`tx_size_sqr < TX_16X16`, so a 16x8
23093+ // chroma unit too).
23094+ assert_eq!(reduce_inherited_chroma_tx_type(HAdst, 16, 8), HAdst);
23095+ assert_eq!(reduce_inherited_chroma_tx_type(VFlipAdst, 8, 8), VFlipAdst);
23096+ // `reduced_tx_set` collapses every inter set to DCT_IDTX.
23097+ set_inter_tx_mode(true, true, true);
23098+ assert_eq!(reduce_inherited_chroma_tx_type(Idtx, 8, 8), Idtx);
23099+ assert_eq!(reduce_inherited_chroma_tx_type(HAdst, 8, 8), DctDct);
23100+ set_inter_tx_mode(true, false, true);
23101+ }
23102+
2286223103 /// lane-fistrip r1 (class `enumerate-the-table-domain`): every block
2286323104 /// shape this decoder can hand [`filter_intra_size_class_rect`], against
2286423105 /// `av1_filter_intra_allowed_bsize` (`block_size_wide <= 32 &&
crates/ec-av1/src/refusal_inventory.rsmodified+1 -0
@@ -34,6 +34,7 @@ const REFUSALS: &[&str] = &[
3434 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
3535 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",
3636 "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",
37+ "an OBMC neighbour whose switchable interp filter was never recorded",
3738 "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",
3839 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
3940 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
crates/ec-av1/src/stream.rsmodified+360 -0
@@ -19471,6 +19471,366 @@ mod tests {
1947119471 );
1947219472 }
1947319473
19474+ /// lane-golomb r2 gate: a 32x32-level block that STRADDLES the frame edge
19475+ /// and whose partition is the gathered edge bit's `PARTITION_HORZ` (bottom
19476+ /// edge) / `PARTITION_VERT` (right edge). Since r1 that bit can name
19477+ /// HORZ/VERT instead of always inferring SPLIT, so the second 32x16/16x32
19478+ /// half is out of frame and must NOT be decoded (libaom `decode_partition`:
19479+ /// `case PARTITION_HORZ: decode_block(top); if (has_rows) decode_block(bottom)`).
19480+ /// The AB and 1:4 arms need no such guard: at an edge libaom's
19481+ /// `ec_read_partition_impl` can only yield HORZ/VERT/SPLIT, so those arms
19482+ /// are unreachable there.
19483+ ///
19484+ /// Geometry: 192x80 (mi_rows=20 -- the second SB row is 16 px tall, so its
19485+ /// 32-level blocks at y=64 have `has_rows32 == false`) and 80x192 for the
19486+ /// right edge. Natural content (`testsrc2`); `smptebars`-style screen
19487+ /// content trips the palette/screen-content refusal before the edge is
19488+ /// reached. cq sweep, 8-bit and 10-bit, plus a 5-frame inter arm.
19489+ /// Counters are sampled per attempt and summed only over attempts that
19490+ /// decoded AND pixel-compared (class `counter-from-refused-stream`).
19491+ #[test]
19492+ fn a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact() {
19493+ edge32_gate(
19494+ "a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact",
19495+ false,
19496+ );
19497+ }
19498+
19499+ /// lane-golomb r2 OPEN DEFECT, pinned as a runnable test: with the 16-px
19500+ /// straddling band left FLAT the encoder answers the 32-level edge bit
19501+ /// with HORZ (`edge32=[2, 0, 2, 0]` on 192x80 cq40 8-bit), the guard added
19502+ /// this round keeps the stream in entropy sync -- every pixel outside the
19503+ /// two edge strips matches ffmpeg -- but the strips themselves
19504+ /// reconstruct wrong: `plane Y: 1081 pixels differ, first at row 62 col
19505+ /// 128`, diffs confined to rows 62..79 over ~64 columns (exactly the two
19506+ /// 32x16 strips plus the deblock bleed above them). That is a
19507+ /// reconstruction defect inside the strip (prediction/availability), not
19508+ /// the partition guard. `#[ignore]` so the suite stays green; run it with
19509+ /// `cargo test -p ec-av1 --lib -- --ignored a_32x32_frame_edge_rect_partition_with_a_flat`.
19510+ #[test]
19511+ #[ignore = "open r2 defect: the 32-level edge HORZ strip reconstructs wrong pixels"]
19512+ fn a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact() {
19513+ edge32_gate(
19514+ "a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact",
19515+ true,
19516+ );
19517+ }
19518+
19519+ /// lane-golomb r9 OPEN DEFECT, pinned as a runnable test: a frame whose
19520+ /// height (192x68) or width (68x192) is not a multiple of 8 leaves a 4-px
19521+ /// straddling band inside the mi-rounded plane, and every INTER frame's
19522+ /// output is +-1 wrong across that band and the columns/rows next to it
19523+ /// (`68x192 cq35 8-bit: frame 1 plane Y: 145 pixels differ, first at row 0
19524+ /// col 64`, mass in columns 64..67). r9 bisected it stage by stage against
19525+ /// the instrumented aomdec on that exact stream:
19526+ /// * `EC_AV1_PREFILT_DUMP` frame 1 is BYTE-IDENTICAL over the cropped
19527+ /// 68 columns -- reconstruction and inter prediction are exact, so the
19528+ /// charter's "MC reads past the crop" hypothesis is refuted a second time.
19529+ /// * `EC_AV1_POSTDEBLOCK_DUMP` with `EC_AV1_DEBUG_SKIP_CDEF=1` also matches
19530+ /// aomdec's own post-deblock dump (which is 72 columns wide, i.e. it
19531+ /// exposes the straddling band) -- the deblock, including its
19532+ /// `frame_width` clip, is correct.
19533+ /// * The divergence therefore enters in CDEF, at the last 8x8 CDEF block
19534+ /// column/row, which is the one that straddles the crop edge.
19535+ /// `#[ignore]` so the suite stays green; run it with
19536+ /// `cargo test -p ec-av1 --lib -- --ignored a_frame_edge_straddling_band`.
19537+ #[test]
19538+ #[ignore = "open r9 defect: CDEF at the last straddling 8x8 block column/row"]
19539+ fn a_frame_edge_straddling_band_decodes_pixel_exact() {
19540+ edge32_gate(
19541+ "a_frame_edge_straddling_band_decodes_pixel_exact",
19542+ false,
19543+ );
19544+ }
19545+
19546+ fn edge32_gate(name: &str, flat_band: bool) {
19547+ let NAME = name;
19548+ let _gate_lock = lock_gate_counters();
19549+ if !have_ffmpeg() {
19550+ eprintln!("SKIP {NAME}: no ffmpeg");
19551+ return;
19552+ }
19553+ if !have_aomenc() {
19554+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
19555+ return;
19556+ }
19557+ // (width, height, frames, ten_bit)
19558+ let mut arms: Vec<(usize, usize, usize, bool)> = Vec::new();
19559+ for &(w, h) in &[(192usize, 80usize), (80usize, 192usize)] {
19560+ arms.push((w, h, 1, false));
19561+ arms.push((w, h, 1, true));
19562+ }
19563+ // The inter arm: >= 4 frames so the 32-level edge path in the INTER
19564+ // tile walk is exercised too.
19565+ arms.push((192, 80, 5, false));
19566+ // lane-golomb r9: the straddling-band arms, only under the ignored
19567+ // `a_frame_edge_straddling_band_decodes_pixel_exact` name (they are
19568+ // RED -- see that test's own comment for the stage bisection). Naming
19569+ // them here rather than in a second copy of this gate keeps the
19570+ // recipe, the counters and the refusal handling identical.
19571+ if name == "a_frame_edge_straddling_band_decodes_pixel_exact" {
19572+ arms.clear();
19573+ arms.push((192, 68, 5, false));
19574+ arms.push((192, 68, 5, true));
19575+ arms.push((68, 192, 5, false));
19576+ arms.push((68, 192, 5, true));
19577+ }
19578+ // lane-golomb r8 MEASURED, arm STILL NOT added (every cq level is
19579+ // vacuous, panicking or red -- each measured this round with
19580+ // `arms.push((192, 68, 5, false))`, log
19581+ // `$HOME/.cache/golomb-gate-r8{b,e,f,g}.log`):
19582+ // * the r7 blocker IS fixed -- no attempt refuses "a reference
19583+ // picture whose height does not match this frame's own true
19584+ // size" any more (`decode.rs`'s comparison now uses the header's
19585+ // frame height, per libaom's crop-dimension reference test).
19586+ // * cq35 now refuses LATER, by another lane's name: "an inter
19587+ // SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B)" -- so the
19588+ // arm compares nothing (class `counter-from-refused-stream`).
19589+ // * cq40 PANICS in `decode_inter_block8`
19590+ // (`from_switchable_symbol` handed a 4th symbol, `mc.rs:203`) =
19591+ // lane-sub8's own open below-8x8 desync; a panic cannot be
19592+ // tolerated as a named refusal.
19593+ // * cq59 8-bit is RED: `frame 1 plane Y: 217 pixels differ, first
19594+ // at row 60 col 170 (ours 172 vs ffmpeg 173)`, and the cq35
19595+ // 10-bit twin is RED at `row 56 col 48 (ours 530 vs ffmpeg
19596+ // 531)`. Both are +-1 bands in rows 56..63, i.e. the deblock/CDEF
19597+ // bleed ABOVE the 4-px straddling row band (64..67) -- the same
19598+ // shape as the `(68, 192, 5, false)` column defect below, so the
19599+ // two are very likely ONE straddling-band reconstruction defect.
19600+ // lane-golomb r7 MEASURED, arm NOT added (it would be vacuous or red):
19601+ // a 68-px axis leaves the last superblock straddling by 4 px, the
19602+ // shape `read_var_tx_size`'s `blk_row >= max_h_mi || blk_col >=
19603+ // max_w_mi` early return exists for. With
19604+ // `arms.push((192, 68, 5, false))` all EIGHT cq attempts refuse by
19605+ // name -- "a reference picture whose height does not match this
19606+ // frame's own true size" -- so the arm compares nothing (class
19607+ // `counter-from-refused-stream`). With
19608+ // `arms.push((68, 192, 5, false))` the gate goes RED on a real,
19609+ // separate defect: `68x192 cq35 frames=5 10bit=false frame 1 plane Y:
19610+ // 141 pixels differ, first at row 0 col 64 (ours 167 vs ffmpeg 166)
19611+ // [edge32=[0,34,0,0,1,17,0,1]]` -- LUMA, inside the 4-px straddling
19612+ // COLUMN. Both are unrelated to this round's chroma tx_type fix.
19613+ let cqs: [u32; 8] = [35, 40, 45, 50, 55, 57, 59, 61];
19614+ let mut totals = [0usize; 8];
19615+ let mut compared = 0usize;
19616+ let mut refusals: Vec<String> = Vec::new();
19617+ for &(width, height, frame_count, ten_bit) in &arms {
19618+ for &cq in &cqs {
19619+ let duration = frame_count as f64 / 25.0;
19620+ // `noise` (explicit seed) both defeats aomenc's
19621+ // screen-content detection -- which otherwise refuses every
19622+ // attempt at "a HORZ/VERT intra strip in a screen-content
19623+ // frame" -- and keeps the RD search off flat NONE blocks.
19624+ // Natural content over the whole superblock-aligned area,
19625+ // with the 16-px straddling band left FLAT (`pad`): with
19626+ // detail in that band aomenc always answers the edge bit with
19627+ // SPLIT (measured: 178 edge bits, 178 of them SPLIT, over a
19628+ // cq 35..61 sweep), so the HORZ/VERT arm this round guards
19629+ // never fired. `noise` on top keeps screen-content detection
19630+ // (and its palette-strip refusal) off.
19631+ let (cw, ch) = (
19632+ if flat_band && width % 64 != 0 { width - 16 } else { width },
19633+ if flat_band && height % 64 != 0 { height - 16 } else { height },
19634+ );
19635+ let pad = if flat_band {
19636+ format!("pad={width}:{height}:0:0:gray,")
19637+ } else {
19638+ String::new()
19639+ };
19640+ let source = format!(
19641+ "testsrc2=size={cw}x{ch}:duration={duration}:rate=25,\
19642+ {pad}noise=alls=6:allf=t+u:all_seed={cq}"
19643+ );
19644+ let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" };
19645+ let y4m = Command::new("ffmpeg")
19646+ .args([
19647+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", pix, "-strict",
19648+ "-1", "-t", &format!("{duration}"), "-f", "yuv4mpegpipe", "-",
19649+ ])
19650+ .stdin(Stdio::null())
19651+ .stdout(Stdio::piped())
19652+ .stderr(Stdio::piped())
19653+ .output()
19654+ .expect("ffmpeg failed to run");
19655+ assert!(
19656+ y4m.status.success(),
19657+ "{NAME}: ffmpeg fixture: {}",
19658+ String::from_utf8_lossy(&y4m.stderr)
19659+ );
19660+ let cq_arg = format!("--cq-level={cq}");
19661+ let mut args: Vec<&str> = vec![
19662+ "--codec=av1",
19663+ "--passes=1",
19664+ "--end-usage=q",
19665+ &cq_arg,
19666+ "--cpu-used=0",
19667+ "--threads=1",
19668+ "--row-mt=0",
19669+ "--sb-size=64",
19670+ "--enable-restoration=0",
19671+ "--enable-palette=0",
19672+ "--deltaq-mode=0",
19673+ "--enable-intrabc=0",
19674+ // Per-arm overrides go LAST (aomenc keeps the last
19675+ // occurrence of a repeated --enable-* flag).
19676+ "--enable-rect-partitions=1",
19677+ "--enable-ab-partitions=0",
19678+ "--enable-1to4-partitions=0",
19679+ // 32, not the charter's 8: at 8 the sub-16 AB and
19680+ // split-transform strip arms (still refused by name here)
19681+ // fire before the 32-level edge is reached and EVERY
19682+ // attempt refuses (measured). At 32 the edge block cannot
19683+ // split, so aomenc is forced onto the gathered edge bit's
19684+ // HORZ/VERT -- exactly the arm this round guards.
19685+ "--min-partition-size=32",
19686+ "--tune-content=film",
19687+ "--max-partition-size=64",
19688+ ];
19689+ if ten_bit {
19690+ args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);
19691+ }
19692+ args.extend_from_slice(&["--obu", "-o", "-", "-"]);
19693+ let mut child = Command::new(aomenc_path())
19694+ .args(&args)
19695+ .stdin(Stdio::piped())
19696+ .stdout(Stdio::piped())
19697+ .stderr(Stdio::piped())
19698+ .spawn()
19699+ .expect("aomenc failed to start");
19700+ child
19701+ .stdin
19702+ .take()
19703+ .expect("aomenc stdin")
19704+ .write_all(&y4m.stdout)
19705+ .expect("writing y4m to aomenc");
19706+ let out = child.wait_with_output().expect("aomenc failed to run");
19707+ assert!(
19708+ out.status.success(),
19709+ "{NAME}: aomenc refused the fixture: {}",
19710+ String::from_utf8_lossy(&out.stderr)
19711+ );
19712+ let stream = out.stdout;
19713+ if ten_bit {
19714+ assert_eq!(
19715+ parsed_bit_depth(&stream),
19716+ 10,
19717+ "{NAME}: aomenc did not write a 10-bit sequence header"
19718+ );
19719+ }
19720+ let tag = format!("{width}x{height} cq{cq} frames={frame_count} 10bit={ten_bit}");
19721+ let before = crate::decode::edge32_hits();
19722+ // lane-golomb r8: name the attempt BEFORE decoding it -- a
19723+ // desync surfaces as a panic deep in mc.rs with no arm in the
19724+ // message, and r8 spent a run bisecting arms by hand.
19725+ if std::env::var_os("EC_GATE_VERBOSE").is_some() {
19726+ eprintln!("{NAME}: attempting {tag}");
19727+ }
19728+ let decoded = match decode_stream(&stream) {
19729+ Ok(frames) => frames,
19730+ Err(e) => {
19731+ let msg = e.to_string();
19732+ assert!(
19733+ msg.contains("unsupported"),
19734+ "{NAME} failed outright, not a named refusal ({tag}): {msg}"
19735+ );
19736+ refusals.push(format!("{tag}: {msg}"));
19737+ continue;
19738+ }
19739+ };
19740+ let after = crate::decode::edge32_hits();
19741+ let delta: Vec<usize> =
19742+ (0..8).map(|i| after[i] - before[i]).collect();
19743+ let reference = if ten_bit {
19744+ ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len())
19745+ } else {
19746+ ffmpeg_decode_sequence(&stream, width, height, decoded.len())
19747+ };
19748+ assert_eq!(
19749+ decoded.len(),
19750+ reference.len(),
19751+ "{NAME}: {tag}: shown-frame count vs ffmpeg"
19752+ );
19753+ for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() {
19754+ for (plane, a, b, w) in [
19755+ ("Y", &ours.y, &theirs.y, width),
19756+ ("U", &ours.u, &theirs.u, width / 2),
19757+ ("V", &ours.v, &theirs.v, width / 2),
19758+ ] {
19759+ if let Some(d) = a.iter().zip(b.iter()).position(|(x, y)| x != y) {
19760+ let n = a.iter().zip(b.iter()).filter(|(x, y)| x != y).count();
19761+ if std::env::var_os("EC_EDGE32_ROWS").is_some() {
19762+ let mut per_row: std::collections::BTreeMap<usize, usize> =
19763+ Default::default();
19764+ for (k, (x, y)) in a.iter().zip(b.iter()).enumerate() {
19765+ if x != y {
19766+ *per_row.entry(k / w).or_default() += 1;
19767+ }
19768+ }
19769+ eprintln!("{NAME}: {tag} plane {plane} diffs per row: {per_row:?}");
19770+ }
19771+ panic!(
19772+ "{NAME}: {tag} frame {i} plane {plane}: {n} pixels differ, first \
19773+ at row {} col {} (ours {} vs ffmpeg {}) [edge32={delta:?}]",
19774+ d / w,
19775+ d % w,
19776+ a[d],
19777+ b[d]
19778+ );
19779+ }
19780+ }
19781+ }
19782+ compared += 1;
19783+ for i in 0..8 {
19784+ totals[i] += delta[i];
19785+ }
19786+ }
19787+ }
19788+ assert!(
19789+ compared > 0,
19790+ "{NAME}: every attempt hit a named refusal:\n{}",
19791+ refusals.join("\n")
19792+ );
19793+ assert!(
19794+ totals[0] + totals[1] + totals[4] + totals[5] > 0,
19795+ "{NAME}: no frame-edge partition bit was read at all over \
19796+ {compared} compared attempts -- the gate proved nothing"
19797+ );
19798+ // lane-golomb r3: the flat-band arm's ASSERT moved one level up. Until
19799+ // r3 the last superblock row was reached through a 32-level edge bit
19800+ // only because our own out-of-frame transform units had desynced the
19801+ // stream; with that fixed, real aomenc answers a bottom-edge
19802+ // superblock with the 64-level `PARTITION_HORZ` (and a right-edge one
19803+ // with `PARTITION_VERT`) and the 32-level slots stay 0 on this
19804+ // content. Slots 6/7 are the strips actually decoded at the edge.
19805+ assert!(
19806+ !flat_band || totals[6] > 0,
19807+ "{NAME}: no 64x32 bottom-edge HORZ strip was decoded \
19808+ (edge32={totals:?}, {compared} compared attempts)"
19809+ );
19810+ assert!(
19811+ !flat_band || totals[7] > 0,
19812+ "{NAME}: no 32x64 right-edge VERT strip was decoded \
19813+ (edge32={totals:?}, {compared} compared attempts)"
19814+ );
19815+ eprintln!(
19816+ "{NAME}: {compared} pixel-exact attempts, 32-level edge bits \
19817+ [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, 64-level edge bits \
19818+ [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, {} named refusals",
19819+ totals[0],
19820+ totals[1],
19821+ totals[2],
19822+ totals[3],
19823+ totals[4],
19824+ totals[5],
19825+ totals[6],
19826+ totals[7],
19827+ refusals.len()
19828+ );
19829+ for r in &refusals {
19830+ eprintln!("{NAME} refusal: {r}");
19831+ }
19832+ }
19833+
1947419834 /// lane-sqchroma r1 gate: a plain SQUARE-partition intra key frame with
1947519835 /// REAL chroma (no `hue=s=0` guard) and aomenc's tx-size search left at
1947619836 /// its own DEFAULT (on) -- the combination the user's films hit
lanes/golomb-r1.report.mdmodified+68 -0
@@ -45,3 +45,71 @@ desyncing.
4545 correctly decoded as HORZ, on an INTER superblock row the inter path cannot code (rect inter
4646 residual coding does not exist here). Next lane.
4747 - `reelb5.obu`: "a 32x32-level 1:4 strip with a split transform (depth=2)" (unchanged by this lane).
48+
49+---
50+
51+# lane-golomb r2 — the 32x32-level frame-edge HORZ/VERT second half
52+
53+## Must-fix (verifier golomb1): fixed
54+Since r1 the 32-level edge read can return HORZ/VERT (bit 0), so the second 32x16/16x32 half is
55+out of frame and must not be decoded. libaom `decode_partition`:
56+`case PARTITION_HORZ: decode_block(top); if (has_rows) decode_block(bottom)` (mirror for VERT).
57+
58+- `crates/ec-av1/src/decode.rs:10887` (intra `PARTITION_HORZ` @32) — second 32x16 now behind `if has_rows32`.
59+- `crates/ec-av1/src/decode.rs:10928` (intra `PARTITION_VERT` @32) — second 16x32 behind `if has_cols32`.
60+- `crates/ec-av1/src/decode.rs:17900` (inter `PARTITION_HORZ` @32) — same guard, `has_rows32`.
61+- `crates/ec-av1/src/decode.rs:18008` (inter `PARTITION_VERT` @32) — same guard, `has_cols32`.
62+- `crates/ec-av1/src/decode.rs:1600` — new `EDGE32_HITS` counter (+ `edge32_hits()`, `bump_edge32`):
63+ slot 0/1 = 32-level edge bit read as HORZ/VERT vs SPLIT, slot 2 = a bottom-edge HORZ strip
64+ decoded (`has_rows32 == false`), slot 3 = a right-edge VERT strip.
65+
66+AB / 1:4 arms at the 32 level need NO guard: at an edge libaom's `ec_read_partition_impl` can only
67+yield HORZ, VERT or SPLIT, so those arms are unreachable there (stated per charter).
68+16-level edge rect arms swept and left as they are: intra refuses by name
69+("a 16x16 block at the true frame edge coded as a rect strip rather than SPLIT"), inter falls to
70+"an inter partition below 16x16 other than SPLIT".
71+
72+## Gate
73+NEW `stream::tests::a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact`
74+(crates/ec-av1/src/stream.rs:14800+): 192x80 (bottom edge, mi_rows=20) and 80x192 (right edge),
75+testsrc2 + seeded `noise`, cq {35,40,45,50,55,57,59,61}, 8-bit AND 10-bit (bit_depth asserted),
76+plus a 5-frame INTER arm; every decode pixel-compared against ffmpeg, counters sampled per attempt
77+and summed only over compared attempts.
78+
79+EVIDENCE: $HOME/.cache/golomb-suite-r2.log + gate stdout | cargo test -p ec-av1 --lib -- --nocapture
80+a_real_aomenc_stream_with_a_32x32_frame_edge | 32 pixel-exact attempts, 8 named refusals,
81+edge32 bits [horz_or_vert=0 split=178] — the 32-level edge read fires 178 times and every attempt
82+decodes pixel-exact.
83+
84+Recipe deviations from the charter, with reasons (measured, not assumed):
85+- `--min-partition-size=32`, not 8: at 8 (and at 16) the sub-16 AB / split-transform strip arms
86+ refuse by name before the 32-level edge is reached — 40/40 attempts refused.
87+- `--tune-content=film` + `noise`: without them aomenc's screen-content detection makes every
88+ attempt refuse at "a HORZ/VERT intra strip in a screen-content frame" (the verifier's smptebars
89+ trap, reproduced here with plain testsrc2).
90+
91+## OPEN DEFECT (fix-now, next round) — the edge HORZ strip's pixels
92+With detail in the straddling band aomenc always answers the edge bit with SPLIT (178/178), so the
93+HORZ/VERT arm never fires. Leaving that band FLAT (`pad=...:gray`) forces it:
94+EVIDENCE: gate stdout | cargo test -p ec-av1 --lib -- --ignored --nocapture
95+a_32x32_frame_edge_rect_partition_with_a_flat_band | 192x80 cq40 8-bit, `edge32=[2, 0, 2, 0]`
96+(two bottom-edge HORZ strips decoded), plane Y 1081 pixels differ, first at row 62 col 128,
97+diffs per row confined to rows 62..79 (~64 of 192 columns) — exactly the two 32x16 strips plus the
98+deblock bleed above them; every other pixel of the frame matches ffmpeg.
99+Reading: the guard itself is validated (no desync — the rest of the frame is entropy- and
100+pixel-exact where before it would have consumed an out-of-frame half), but the strip's own
101+reconstruction (prediction/neighbour availability at the frame edge) is wrong. Pinned as
102+`#[ignore]`d test `a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact` so the
103+suite stays green and the defect stays runnable. Disposition: fix-now for r3 (owner: this lane).
104+
105+## Suite (r2)
106+`$HOME/.cache/golomb-suite-r2.log` — **337 passed / 1 FAILED / 32 ignored** (618 s).
107+The failure is NOT this round's arm and I could not attribute it to this diff:
108+`stream::tests::a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16_decodes_pixel_exact`
109+panics at stream.rs:8479 "the stream decoded but no coded (non-skip) rect leaf fired". Its fixture
110+is a 64x64 mandelbrot frame — one whole superblock, `mi_cols = mi_rows = 16`, so
111+`has_rows32`/`has_cols32` are true everywhere and none of this round's four guards (nor r1's
112+edge reads) can execute on it. Deterministic (fails standalone in 0.34 s, same message).
113+Disposition: deferred(a bisect of eacd7fd vs 3e4ce89 in a detached worktree, or the owner of
114+`rect_leaf_coeff_hits`) — it is either pre-existing on eacd7fd (r1's suite log predates today's
115+oracle/ffmpeg state) or a sibling-gate regression from a path I did not touch. NOT claimed green.
lanes/golomb-r3.report.mdadded+106 -0
@@ -0,0 +1,106 @@
1+# lane-golomb r3 — the suite red was my own gate recipe; the edge strip was out-of-frame transform units
2+
3+## TASK 1 — bisect table (the r2 suite failure)
4+
5+`stream::tests::a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16_decodes_pixel_exact`,
6+run in a detached scratch worktree (`scratchpad/verify-golomb`, `CARGO_TARGET_DIR=~/.cache/cargo-target-verify`):
7+
8+| commit | what it is | result |
9+|---|---|---|
10+| a762fff | mcomp64 base | ok, 1 passed |
11+| 909064f | + fi8 cherry-pick 2d5c425 | ok, 1 passed |
12+| eacd7fd | r1 edge-bit fix | ok, 1 passed |
13+| fd54bcf | r2 guards | **FAILED** — "the stream decoded but no coded (non-skip) rect leaf fired" |
14+
15+EVIDENCE: bisect stdout above | `git worktree add --detach` at each sha, `cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16` | 3 ok / 1 FAILED, first red = fd54bcf
16+
17+Root cause: **not** fi8, not the r1 edge read. r2's per-arm recipe override
18+(`--min-partition-size=32 --tune-content=film`) was pasted into the WRONG gate — hunk
19+`stream.rs@8435`, inside `a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16`, whose whole
20+point is sub-16x16 rect leaves. At `--min-partition-size=32` that 64x64 mandelbrot frame cannot
21+contain a 16x8 leaf, so `rect_leaf_coeff_hits` went to 0 and the gate's own
22+"the gate proves nothing" assert fired — the assert did its job. Fixed in ebec75d by restoring
23+`--min-partition-size=8`; the edge32 gate has always carried its own copy of the override.
24+No warning is owed to the fi8 merge agent: fi8 is already on main (b1d8457) and is exonerated by
25+row 2 of the table.
26+
27+EVIDENCE: gate stdout | `cargo test -p ec-av1 --lib -- --nocapture a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16` after ebec75d | `pixel-exact, rect_leaf_coeff_hits=8`, 1 passed
28+
29+## TASK 2 — the frame-edge strip's wrong pixels: out-of-frame transform units
30+
31+Class: `parsed-then-discarded`'s mirror — *read* something the reference never wrote
32+(`equal-range-means-unread`).
33+
34+Reproduced standalone (192x80 cq40 8-bit flat band, md5 `4bd18b25…`, scratchpad `e32.obu`):
35+1081 Y pixels differ, rows 62..79, **cols 124..191** — the LAST superblock only.
36+
37+The oracle's own view of that superblock row (instrumented aomdec):
38+`EC_PRED mi_row=16 mi_col=16 … bsize=11 part=1 txw=16 txh=16` with **row_off=0 only** (four TUs),
39+and `mi_row=16 mi_col=32 … bsize=11 part=1 txw=32 txh=32` (two TUs). `bsize=11` is
40+`BLOCK_64X32`: aomenc answers the bottom-edge superblock with the **64-level** `PARTITION_HORZ`,
41+never the 32-level one, and codes only the transform-unit ROW that is inside the frame.
42+
43+Ours decoded `mi_col=16` identically (`TRACE_RECT_SPLIT bw=64 bh=32 tx=16`) but then walked
44+`bh/tx = 2` TU rows, reading coefficients for four phantom 16x16 units at y=80..95 — outside a
45+frame whose `mi_rows*4 == 80`. That desynced the stream at exactly the next symbol: the SB2
46+partition bit came out SPLIT (two 32x16 strips, `edge32=[2,0,2,0]`) where the oracle read HORZ.
47+The r2 report's reading ("prediction/availability inside the strip") was wrong; the strips
48+were the *symptom* of a desync, and the "32-level edge HORZ fired" counter was a
49+`counter-from-refused-stream`-shaped artefact of our own desync.
50+
51+Fix — `crates/ec-av1/src/decode.rs:4818` (`decode_rect_split`, the only place a block hangs off
52+the frame): skip a transform unit whose top-left sample is outside `true_width`/`true_height`
53+(`mi_cols*4`/`mi_rows*4`), mirroring libaom `av1_foreach_transformed_block_in_plane`'s
54+`max_blocks_wide/high` clip (`mb_to_right_edge`/`mb_to_bottom_edge`). The chroma unit of a strip
55+always has its top-left inside, so it is unaffected.
56+
57+EVIDENCE: scratchpad/{e32.obu, ours.yuv, ao.yuv, ao-pred.txt, ours-step.txt} | instrumented
58+aomdec `EC_PRED`/`EC_TRACE_MODE_STEP` vs `decode_probe`, byte diff of the two raw yuv420p dumps |
59+before: 1081 Y pixels differ (first diff at our `EC_ISTEP mi_row=16 mi_col=32 name=skip rng=51413`
60+vs oracle `rng=32901`); after: **0 differing bytes over all three planes**
61+
62+## Counters + the pin, un-ignored
63+
64+`EDGE32_HITS` widened 4 → 8 slots (`decode.rs:1602`): slots 4/5 = the **64**-level gathered edge
65+bit read as HORZ/VERT / SPLIT (both tile paths), 6 = a 64x32 bottom-edge strip decoded with
66+`has_rows == false`, 7 = a 32x64 right-edge strip. Necessary because the flat-band arm's r2
67+assert (`totals[2] > 0`, a 32-level bottom-edge HORZ) was only ever satisfied by our own desync;
68+on a correct decode of this content the 32-level slots are 0 by construction and the 64-level
69+slots carry the proof. `#[ignore]` removed from
70+`a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact`.
71+
72+EVIDENCE: gate stdout | `cargo test -p ec-av1 --lib -- --nocapture a_32x32_frame_edge` |
73+2 passed; flat arm: 32 pixel-exact attempts, 64-level edge bits [horz_or_vert=96 split=0]
74+bottom-HORZ=48 right-VERT=48, 32-level slots all 0; detail arm: 32 pixel-exact attempts,
75+64-level [horz_or_vert=7 split=89] right-VERT=7, 32-level split=178
76+
77+## Suite
78+`$HOME/.cache/golomb-suite-r3.log` — **339 passed / 0 failed / 31 ignored** (277 s), run as a
79+user systemd unit on the final tree. r2 was 337/1 FAILED/32 ignored: +1 fixed (task 1), +1
80+un-ignored (task 2).
81+
82+Siblings re-run inside that suite, all green: `a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16`,
83+`the_reelb_head_key_frame`, both `a_*_32x32_frame_edge_*`, `tiny_frame_size_sweep`,
84+`superblock_level_*`, `filter_intra_*`, `refusal_inventory`, `gate_coverage`.
85+
86+## Same-shape sweep
87+`decode.rs:7458` (`decode_block`'s square multi-TU loop) has the identical unclipped
88+`0..n_axis` shape and now carries the identical guard. A square block only hangs off the frame
89+when the frame's mi dimensions are odd at that block's level (lane-oddh's territory), so no gate
90+in this suite reaches it: the guard is libaom's rule applied by inspection, proven only inert
91+here (suite unchanged). `decode_block_rect64` delegates its split case to `decode_rect_split`,
92+so it is covered by the measured fix. Flagged, not claimed.
93+
94+## Film
95+`hg-head.obu` (18 frames) still stops at
96+"an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path
97+recurses a superblock only as SPLIT)" — unchanged by this round (same string as r1's residue;
98+the inter tile path never reaches a 64-level HORZ).
99+EVIDENCE: probe stdout | `cargo run -p ec-av1 --example decode_probe -- hg-head.obu` | REFUSED at
100+the inter SB-level partition, 18 frame headers parsed, tiling cols=1 rows=1
101+
102+## Residue
103+- deferred: the inter tile path's 64-level `PARTITION_HORZ`/`VERT` (the film's next blocker) —
104+ unblocked by rect inter residual coding, which is lane-inter*/interbis territory, not this one.
105+- accepted: the square-block guard above is unexercised by any gate on this lane (odd-mi
106+ geometry is lane-oddh's gate).
lanes/golomb-r4.report.mdadded+93 -0
@@ -0,0 +1,93 @@
1+# lane-golomb r4 — merge with main, and the 32x32-frame-edge cross-product isolated (NOT fixed)
2+
3+## STEP 1 — merge (DONE, commit 17fc2a7 `Merge branch 'main' into lane-golomb`)
4+
5+`git merge main` (main b51719f) conflicted in 4 files; 14 hunks in `decode.rs`.
6+Resolution (all by hand, no `cargo fmt`):
7+
8+* `crates/ec-av1/src/cdf.rs`, `crates/ec-av1/src/cdf_state.rs` — main's, whole.
9+* `crates/ec-av1/src/decode.rs`
10+ * fi32x8 rows `(32,8)=>10 / (8,32)=>11` in `filter_intra_size_class`: main's.
11+ * `decode_rect_split`'s TU loop: main's rect `tx_w`/`tx_h` form, with golomb r3's
12+ TU-ORIGIN CLIP re-applied per axis inside it
13+ (`if tu_px >= y.true_width || tu_py >= y.true_height { continue; }`).
14+ * oddh's 16-level edge HORZ/VERT strip (replaces golomb's refusal): main's.
15+ * golomb's 6 edge-bit counter sites (`bump_edge32` / `bump_edge32_bit`) and the
16+ 64-level + 32-level SECOND-HALF guards: kept, re-applied on top of inter4's
17+ MI-unit `decode_inter_block` signature (`sub16_to_mi(...)`) at both inter
18+ SB-level HORZ (`edge32` slot 2) and VERT (slot 3) arms.
19+* `lanes/golomb-r1.report.md` — lane's.
20+
21+`cargo check -p ec-av1` + `cargo test -p ec-av1 --lib --no-run`: clean.
22+
23+## STEP 2 — the cross-product: ISOLATED to one block, root cause NOT yet found
24+
25+Gate `a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact`
26+still FAILS on the merged tree, identically to merge-E's report:
27+`192x80 cq59 frames=5 8-bit frame 1 plane Y: 90 pixels differ, first at row 61 col 174
28+(ours 175 vs ffmpeg 174) [edge32=[1, 35, 1, 0, 0, 18, 0, 0]]`.
29+
30+Stream reproduced standalone (md5 `48e1d78f31a4eb6a6ef5a67df9bd36fe`, 971 B):
31+`ffmpeg -f lavfi -i "testsrc2=size=192x80:duration=0.2:rate=25,noise=alls=6:allf=t+u:all_seed=59"
32+ -pix_fmt yuv420p ... | aomenc <the gate's flags> --cq-level=59` (script in the handoff).
33+
34+### What the facts say (each with its command)
35+
36+1. **The first divergent picture is DECODE-order picture 2, not shown-frame 1.**
37+ `EC_AV1_PREFILT_DUMP` on both decoders, luma compared per picture:
38+ f0 0 diffs, f1 0, **f2 130**, f3 84, f4 110. The shown-frame-1 report is the
39+ propagated copy. (Class `gate-blind-to-hidden-frames` applies to the READING of
40+ the gate message, not to the gate.)
41+2. **The wrong pixels are exactly one 16x16 block**: picture 2, rows 64..79 x
42+ cols 160..175 = mi(16,40), max |delta| 36 — a prediction-scale error, not rounding.
43+3. **libaom decodes mi(16,40) as SPLIT into two 16x16 leaves in every picture**
44+ (`EC_TRACE=1 aomdec | grep 'mi_row=16 mi_col=40 bsize=9'` → `value=3` x6);
45+ **we decode a 32-wide HORZ strip there in picture 2 only**
46+ (`EC_AV1_COMPIDX_DUMP=1` → `mi_row=16 mi_col=40 bsize=32 mode=0 mv0=(-30,-20)
47+ mv1=(16,0) ref0=1 ref1=7`, where libaom has `mode=18 (NEAR_NEARMV) mv0=(-16,0)`).
48+ That is inter4's SB/32-level inter rect arm consuming golomb's frame-edge bit —
49+ a path neither parent could reach.
50+4. **The edge bit is NOT the defect.** Instrumented pre-read state at the 32-level
51+ gathered read (temporary `DBG32PRE`, reverted): ctx = 2 (= libaom's 10 = bsl 2 * 4 + 2),
52+ CDF row and 2-entry gather identical in all 6 pictures, and the pre-read RANGE
53+ matches aomdec's `EC_PART ... rng=` in 11 of 12 reads. The one mismatch is
54+ picture 2 at mi(16,40): ours 39967, libaom 64226 — i.e. **we arrive at the bit
55+ already desynced**, and the wrong HORZ is the consequence.
56+5. **The desync starts inside the 16x16 INTER block at mi(16,32), picture 2.**
57+ Range ladder (ours `EC_AV1_TELL`/`EC_TRACE_MODE` vs aomdec `EC_TRACE_MODE`):
58+ * mi(16,32) entry / post_is_inter: ours 52732 == libaom `EC_MODE ... rng=52732`.
59+ * libaom then reads compound NEAR_NEARMV `ref0=1 ref1=7 mv0=(0,0) stack=3`
60+ (`EC_MODE_MV rng=39839`, `EC_MODE_VAL rng=56231`) and leaves the block at 62618.
61+ * ours leaves the block at 35347 (`TELL ... label=block_end tell=232 range=35347`),
62+ having consumed ~1 bit: no `EC_MODE_VAL` (single-ref print) and no `EC_COMPIDX`
63+ line for that block at all.
64+ So we read FEWER symbols than libaom for a `skip=true`, `is_inter=true` compound
65+ block at the bottom frame edge. First divergent element: the symbol(s) after
66+ `intra_inter` in `decode_inter_block` at mi(16,32) (ref-frame / compound-mode
67+ group), picture 2.
68+6. Coefficient ladders are otherwise identical (6426 aligned
69+ `EC_COEFF_STEP tag=base|sign|all_zero|eob|base_eob|after_bases|post_golomb` rng
70+ values, `diff` empty), so this is a LOCAL symbol-count divergence in one block
71+ that re-converges, not a whole-tile desync.
72+
73+EVIDENCE: /tmp/.../scratchpad/{ours,aom}.f0..f5 | `EC_AV1_PREFILT_DUMP` both decoders on g4.obu | first divergent picture = 2, diff box rows 64..79 x cols 160..175 (130 px, max 36)
74+EVIDENCE: /tmp/.../scratchpad/{o,a}-cf.txt | `EC_TRACE_COEFF=1` both decoders, aligned tags | 6426 == 6426 lines, `diff` empty (entropy re-converges)
75+EVIDENCE: /tmp/.../scratchpad/{ours,aom}-mode.txt + tell.txt | `EC_TRACE_MODE` / `EC_AV1_TELL` ours vs aomdec | mi(16,32) p2 entry 52732 == 52732, exit ours 35347 vs libaom 62618
76+
77+## Status / disposition
78+
79+* merge: DONE and committed.
80+* the 32x32-frame-edge cross-product: **OPEN — fix-now, next round**, isolated to
81+ the symbol group read after `intra_inter` for the compound block at mi(16,32) in
82+ picture 2. Not a golomb-side defect in the edge bit (fact 4).
83+* verifier's r3 item (no `max_blocks_wide/high` clip on the INTER var-tx leaf loops
84+ at `decode.rs` ~14135 / ~14970, plus a 192x68 / 68x192 gate arm with a
85+ straddling-TU counter): **deferred — turn budget spent on the cross-product
86+ isolation above — unblocked by a fresh round; nothing about it is contradicted
87+ by this round's findings.**
88+
89+## Suite
90+
91+`cargo test -p ec-av1 --lib` (systemd unit, log `$HOME/.cache/golomb-suite-r4.log`): **364 passed, 2 failed, 31 ignored** in 547 s.
92+Failure 1 = the stale golomb refusal string `"a 16x16 block at the true frame edge coded as a rect strip rather than SPLIT"` still listed in `refusal_inventory.rs` after the merge took oddh_s lifted strip -- deleted in the follow-up commit (refusal_inventory 3/3 green after).
93+Failure 2 = the open cross-product above.
lanes/golomb-r5.report.mdadded+109 -0
@@ -0,0 +1,109 @@
1+# lane-golomb r5 — the 32x32-frame-edge cross-product ROOT-CAUSED and fixed (luma exact); gate still RED on a newly-exposed chroma defect
2+
3+## What changed
4+
5+* `crates/ec-av1/src/mvstack.rs:1663-1703` (commit `13aebbe`) — `find_mv_stack_compound`
6+ now runs libaom's three `tpl_sample_pos` EXTENSION samples
7+ (`mvref_common.c:563-600`, `allow_extension` + `check_sb_border` at
8+ `mvref_common.c:316`, mask hardcoded `mi_size_wide[BLOCK_64X64]`=16). The
9+ single-ref twin (`mvstack.rs:863-891`) already carried them; the compound
10+ path dropped them. Same hunk as lane-sb128 `d6cca7d` (independent lane, same
11+ root cause found from the other end).
12+
13+Nothing else. The r4 debug ladder used to find this was removed before commit.
14+
15+## Root cause (H3 of the charter; H1 skip_mode and H2 comp-ref ctx both exonerated)
16+
17+Charter's isolated element: `192x80 cq59 frames=5 8-bit`, DECODE-order picture 2,
18+16x16 inter block at mi(16,32), entry range 52732 == libaom, exit ours 35347 vs
19+libaom 62618.
20+
21+A temporary compound range ladder (`EC_LAD` after `read_comp_mode`, after
22+`read_compound_ref_frames`, after `read_inter_compound_mode`, after
23+`assign_compound_mv`) showed:
24+
25+| element | ours (before) | libaom |
26+|---|---|---|
27+| block entry (post `intra_inter`) | 52732 | 52732 |
28+| `is_compound` | true | true |
29+| ref pair | `ref0=1 ref1=7` | `ref0=1 ref1=7` |
30+| **compound stack** | **2 entries** `[(-16,0)/(14,0) w=672, (0,0)/(0,0) w=672]` | **3 entries**, same two + `(-10,0)/(10,0) w=2` |
31+| compound mode | 1 = `NEAR_NEARMV` | 18 = `NEAR_NEARMV` |
32+| post-mv | 50080 | 39839 |
33+
34+So `skip_mode` and the whole reference-frame group were already right (H1/H2 dead).
35+With `ref_mv_count == 2` our `NEAR_NEARMV` drl loop condition
36+(`count > idx + 1`, idx=1) is false, so we never read the `drl_mode` symbol
37+libaom reads at `ref_mv_count == 3` — **one bit short**. Every later symbol in the
38+tile then read from the wrong place, and the 32-level gathered edge bit at
39+mi(16,40) resolved HORZ where libaom split (the r4 "edge bit" symptom was the
40+consequence, not the cause — matching r4 fact 4).
41+
42+The missing candidate has weight 2: `add_tpl_ref_mv`'s temporal vote
43+(`ref_mv_weight[idx] = 2 * weight_unit`), from extension sample
44+`(voffset, hoffset) = (4,4)` at mi(16,32) (`16&15=0`, `32&15=0`, both in range).
45+
46+After the fix the ladder is exact through the block: stack 3 == 3 with identical
47+entries and weights, post-mv 39839 == libaom `EC_MODE_MV rng=39839`, next block
48+entry 62618 == 62618, and mi(16,36) stack weight `w=10` == 10 (was 8, i.e. the
49+same missing weight-2 vote folded into an existing entry).
50+
51+EVIDENCE: /tmp/.../scratchpad/gl-r5-ours.txt (before) + gl-r5-ours2.txt (after) vs aom-mode.txt | `EC_TRACE_MODE` ours (temporary EC_LAD compound ladder) vs instrumented aomdec on g4.obu md5 48e1d78f31a4eb6a6ef5a67df9bd36fe | mi(16,32) p2 stack 2->3, post-mv 50080->39839 == libaom, next-block entry 39296->62618 == libaom
52+
53+EVIDENCE: /tmp/.../scratchpad/g4-ours.yuv vs g4-aom.yuv | `decode_probe EC_PROBE_OUT` vs `aomdec --rawvideo` on g4.obu | plane Y ALL 5 FRAMES EXACT (was f1 90, f2 143, f3 106 wrong pixels); chroma residue below
54+
55+## Gate: still RED, on a DIFFERENT defect
56+
57+`cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition`
58+
59+* baseline (`fbc427c`): `192x80 cq59 frames=5 8-bit frame 1 plane Y: 90 pixels differ, first at row 61 col 174 [edge32=[1,35,1,0,0,18,0,0]]` (log `$HOME/.cache/golomb-gate-r5-base.log`)
60+* with the fix: `192x80 cq35 frames=5 8-bit frame 1 plane U: 335 pixels differ, first at row 0 col 56 [edge32=[0,36,0,0,0,18,0,0]]` (log `$HOME/.cache/golomb-gate-r5.log`)
61+
62+The gate now fails EARLIER in the cq sweep (35 < 59) because **cq35 was never
63+compared before**: at baseline that stream hit a false named refusal
64+(`"an inter 16x16-level AB or 1:4 partition"`) produced by our own desync, so the
65+gate `continue`d past it. With the stack fixed it decodes end to end. Class
66+`refusal-from-own-desync` + `refusal-hides-a-defect`, both already in memory.
67+
68+The residual defect is **chroma-only and pre-existing**: on both streams luma is
69+bit-exact in every frame while U/V carry scattered ±1..±3 across the whole plane
70+(g4 baseline already had f1 U 75 / V 185 wrong under the luma failure). The key
71+frame (f0) is exact, so it is inter chroma only, and V is consistently ~2.5x worse
72+than U.
73+
74+EVIDENCE: /tmp/.../scratchpad/g35-ours.yuv vs g35-aom.yuv | decode_probe vs aomdec on g35.obu (md5 9037f5b21db95d35e71f91f040fc33e1, recipe scratchpad/gl-gen.sh, hashed twice identical) | f0 exact, f1..f4 luma exact, U 335/324/1183/691 and V 408/412/1158/746 wrong, deltas -4..+5
75+EVIDENCE: /tmp/.../scratchpad/g35-ours.txt vs g35-aom.txt | `EC_TRACE_MODE` block-entry ranges, ours vs aomdec | all 48 of our `EC_MODE` ranges match libaom's in order — entropy fully in sync, so this is a pure chroma reconstruction defect, not a symbol defect
76+
77+## The r3 verifier item (`max_blocks_wide/high` clip on the INTER var-tx leaf loops)
78+
79+**Already implemented, at the shared entry point** — no code needed
80+(`decode.rs:10317`):
81+
82+```
83+fn read_var_tx_size(..., (max_w_mi, max_h_mi), ...) {
84+ if blk_row >= max_h_mi || blk_col >= max_w_mi { return; }
85+```
86+
87+`max_w_mi`/`max_h_mi` are computed as `mi_cols.saturating_sub(at_mi.1)` /
88+`mi_rows.saturating_sub(at_mi.0)` at BOTH inter callers
89+(`decode.rs:10402-10403` square, `decode.rs:10630-10631` rect), i.e. libaom's
90+`max_blocks_wide/high` in the same 4x4 units. A leaf whose top-left mi is outside
91+the frame is therefore never emitted into `vartx_leaves`, and the two reconstruct
92+loops (`decode.rs:15852`, `decode.rs:16830`) cannot see one. Adding a second
93+`tu_px >= y.true_width` guard there would be dead code.
94+
95+## Status / disposition
96+
97+* the mi(16,32) compound-stack desync: **FIXED**, luma bit-exact on the charter's stream.
98+* the chroma ±1 residue: **fix-now, next round** — first block to bisect is chroma
99+ plane U/V of `g35.obu` frame 1 (entropy is proven in sync, MVs proven right by
100+ exact luma, so it is chroma prediction/rounding or the per-plane chroma
101+ quantizer; V-worse-than-U points at a per-plane term, cf. memory
102+ `parsed-then-discarded`). Unblocked by a fresh round; nothing here contradicts it.
103+* r3 verifier item (var-tx clip): **accepted as already-satisfied**, cited above.
104+ Its 192x68 / 68x192 gate arm: **deferred — the gate it would join is RED, so a
105+ new arm would only add noise — unblocked by the chroma fix above.**
106+
107+## Suite
108+
109+`cargo test -p ec-av1 --lib` under a user systemd unit, log `$HOME/.cache/golomb-suite-r5.log`: re-armed as unit `golomb-suite-r5` after restoring the `#[ignore]` attribute on `a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact` (the r2 open-defect twin; the attribute was lost in the r4 merge and the test ran, and failed, in the mid-round run). Expected failures: the one open gate above. The coordinator reads the log.
lanes/golomb-r6.handoff.mdadded+118 -0
@@ -0,0 +1,118 @@
1+# lane-golomb r6 HANDOFF
2+
3+## Merge state (STEP 1: DONE)
4+* `899d7cf` = `git merge main` (main `18bf7dc`). Real merge commit, not a squash.
5+* `crates/ec-av1/src/mvstack.rs`: `git diff main -- mvstack.rs` is EMPTY -> ONE copy of the
6+ compound tpl-extension hunk (lane-sb128 `d6cca7d` == our `13aebbe`), byte-identical to main.
7+* `crates/ec-av1/src/cdf.rs` and `cdf_state.rs`: `git diff main` EMPTY (NZ_MAP/FILTER_INTRA
8+ byte-identical to main).
9+* 7 `decode.rs` conflicts resolved: 4 were comment-only (took main's text); 3 were the counter
10+ pair -- main's `bump_edge_part` and this lane's `bump_edge32` are INDEPENDENT counters, BOTH
11+ kept at every site (`decode.rs:13094-13101`, `13169-13179`, and the two `!has_rows32/!has_cols32`
12+ guards).
13+* `#[ignore = "open r2 defect: ..."]` on
14+ `a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact`
15+ (`stream.rs:18414`) SURVIVED the merge -- verified by grep after the merge commit.
16+
17+## Suite r5
18+`$HOME/.cache/golomb-suite-r5.log` had NO `test result:` line: the unit was still `active` and
19+I stopped it (`systemctl --user stop golomb-suite-r5`) to free `CARGO_TARGET_DIR` for r6 -- it
20+was building the PRE-merge tree, so its result would have been superseded anyway. Every `test`
21+line present in it up to that point was `ok`. r6 suite armed as unit `golomb-suite-r6`
22+-> `$HOME/.cache/golomb-suite-r6.log`; READ THAT, not r5.
23+
24+## STEP 2: chroma residue -- ROOT CAUSE #1 FOUND AND FIXED
25+
26+Stream: `g35.obu`, md5 `9037f5b21db95d35e71f91f040fc33e1` (regenerated, hash confirmed;
27+recipe `scratchpad/gl-gen.sh 35 <out>`), 192x80 cq35 5 frames 8-bit, 6 decode-order pictures.
28+
29+### Localization method (reusable)
30+Three-stage compare, decode order, ours vs the oracle:
31+`EC_AV1_PREFILT_DUMP` (pre-loopfilter) / `EC_AV1_POSTDEBLOCK_DUMP` (post-deblock, pre-CDEF) /
32+`EC_AV1_FINAL_DUMP` (post everything). Ours dumps a PADDED plane (192x96 luma), aomdec dumps
33+CROPPED (192x80) -- the comparator must use different strides per side.
34+NOTE: `EC_AV1_PREFILT_DUMP16`/`..._DUMP16` SEGFAULT the oracle aomdec on an 8-bit stream
35+(`ec_dump16` does `CONVERT_TO_SHORTPTR` unconditionally, decodeframe.c:3968). Use the 8-bit
36+`*_DUMP` vars for 8-bit streams.
37+Ours' `dump_stage` used to write `.f0` for EVERY frame (overwrite); r6 gave it a per-var
38+thread-local index (`decode.rs`, `dump_stage`) so POSTDEBLOCK is now `.f0..fN` like the oracle.
39+
40+### The measurement that localized it
41+Before the fix: prefilt decode-f1 EXACT, post-deblock decode-f1 U342/V380 wrong, luma exact at
42+every stage -> the defect was the DEBLOCK filter on chroma, not prediction, not CDEF
43+(`--enable-cdef=0` did NOT fix it), not LR (disabled in the recipe).
44+
45+### Root cause (fixed)
46+`decode.rs`, inter block tail: the var-tx / split-tx LEAF loop called
47+`Neighbours::fill_lf_grid_rect(leaf_mi, tx_px/MI, tx_px/MI, ...)`, and that function DERIVES
48+the chroma grids from the span it is given (`uv_tx_w = (w_mi*MI/2).clamp(4,32)`). So every
49+var-tx leaf OVERWROTE the block's correct `uv_tx_grid`/`uv_tx_h_grid` (the block's
50+`av1_get_max_uv_txsize`) with `leaf_tx/2`, inventing chroma transform edges the deblocker then
51+filtered. libaom `get_transform_size` (`av1/common/av1_loopfilter.c:207`) applies the var-tx
52+override ONLY `if ((plane == AOM_PLANE_Y) && is_inter_block(mbmi) && !mbmi->skip_txfm)`;
53+chroma always keeps `av1_get_max_uv_txsize(mbmi->bsize, ss_x, ss_y)`.
54+FIX: new `Neighbours::fill_lf_grid_leaf_luma` writes ONLY `tx_grid`/`tx_h_grid` over the leaf
55+span (`ref_grid`/`delta_lf_grid` are already correct from the block's own fill over the same
56+span), and the leaf loop calls it. Sweep: this was the ONLY `fill_lf_grid_rect` caller passing
57+a TU span; all 12 others pass block dims (checked each).
58+
59+### Result
60+g35 ours vs aomdec, all three stages, decode order:
61+before f0 exact, f1 U398/V457, f2 U325/V412, f3 U336/V408, f4 U~1000/V~1000, f5 U691/V746
62+after f0-f3 EXACT at prefilt+postdeblock+final, f4 U974/V973 (prefilt), f5 inherits it.
63+
64+## RESIDUE (still RED) -- exactly one defect left
65+Gate: `cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition`
66+=> `192x80 cq35 frames=5 10bit=false frame 3 plane U: 978 pixels differ, first at row 0 col 32
67+(ours 33 vs ffmpeg 8) [edge32=[0,36,0,0,0,18,0,0]]`.
68+
69+* Stage: **PREFILTER** (prediction+residual), decode-order picture 4 only (f5 inherits).
70+ Deblock/CDEF/LR are exonerated for this one.
71+* Extent: EXACTLY chroma x 32..63, y 0..31 = luma x 64..127, y 0..63, i.e. one whole 64x64
72+ superblock. Luma bit-exact inside it.
73+* Shape of the error: HIGH-FREQUENCY, |delta| up to 52. aomdec's row 0 is smooth
74+ (13,14,14,14,...) where ours is (36,12,0,0,20,22,...). That is a RESIDUAL/inverse-transform
75+ shape, not a prediction-offset shape.
76+* Blocks in that SB (decode f4, from `EC_TRACE_MODE`): mi(0,16) mode=23 ref0=1 ref1=7 (compound),
77+ mi(0,24) mode=17 ref0=1 ref1=7, mi(8,16) mode=17 ref0=1 ref1=7, mi(8,24) mode=13 ref0=7
78+ single-ref. All 32x32.
79+
80+### Ruled out (each with the command that ruled it out)
81+* deblock / CDEF / LR: prefilt already differs on f4.
82+* per-plane `delta_q_u/v_dc/ac`: consumed (`stream.rs:599-603` etc.) AND f0-f3 chroma is now
83+ bit-exact under the same quantizer.
84+* narrow-block (<=4-wide) chroma MC kernel and sub8x8 chroma MV derivation: impossible in this
85+ stream, `--min-partition-size=32` means the smallest chroma block is 16x16.
86+* chroma MC rounding: derived by hand that our always-2-pass convolve is bit-identical to
87+ libaom's `av1_convolve_x_sr_c`/`_y_sr_c` single-pass rounding when one fraction is 0
88+ (identity tap 128, round2(x*16,11) == ROUND_POWER_OF_TWO(x,7)); and f1-f3 are now exact.
89+* **DIFFWTD compound (the tempting one -- DO NOT re-chase it blind):** `--enable-diff-wtd-comp=0`
90+ made the whole sequence exact, BUT that is a DIFFERENT bitstream (class gate-recipe-confound).
91+ An `EC_DWTD` trace of the ORIGINAL g35 shows only 4 diffwtd blocks in the whole stream, in
92+ decode f1 (px=64,py=0) and decode f2 (px=0,py=0 / px=64,py=0 / px=128,py=32) -- **NONE in
93+ decode f4**, where the residue is. DIFFWTD is therefore EXONERATED for this residue.
94+* warp / global motion / OBMC / dual filter / masked-comp / interintra / dist-wtd: ablated on
95+ the post-fix build, all still show the f3(display) failure (`scratchpad/abl.sh`).
96+
97+### Exact next step
98+The error is a chroma RESIDUAL in a 64x64 SB of decode-order picture 4 whose luma is exact and
99+whose entropy is (r5-proven) in sync. Bisect chroma coefficients, not prediction:
100+1. Run the oracle with `EC_TRACE_COEFF=1` and ours with `EC_TRACE_COEFF=1` on `g35.obu`, isolate
101+ decode picture 4, block mi(0,16), plane 1. Compare the DEQUANTIZED values element by element
102+ (and the msac RANGE per element, never `tell()`).
103+2. Prime suspect given "luma exact, chroma noisy, whole SB": the chroma `tx_type` inherited from
104+ the colocated luma unit (`decode.rs` `inherited_luma_tx_type`, `av1_get_tx_type`
105+ `blockd.h:1291`). For a var-tx-split luma block the chroma TU spans several luma TUs and
106+ libaom reads the luma tx_type at `blk_row<<ssy, blk_col<<ssx`; ours takes "the top-left unit".
107+ Verify that mapping against `av1_get_tx_type` for a 32x32 block whose luma split to 16x16.
108+ A wrong tx_type gives exactly this signature: right coefficients, wrong basis, chroma only.
109+3. Second suspect: `txsize_sqr_up_map[tx_size] > TX_32X32 -> DCT_DCT` clamp
110+ (ours clamps at `side >= 32`, on the CHROMA side length -- check that against
111+ `av1_get_ext_tx_set_type`'s use of the chroma tx size).
112+
113+## Deferred
114+* the 192x68 / 68x192 gate arm from r3's verifier ask: **deferred -- the gate it would join is
115+ still RED, a new arm would only add noise -- unblocked by the residue above.** The r3 code ask
116+ itself stays accepted-as-already-satisfied (`decode.rs` `read_var_tx_size`'s
117+ `blk_row >= max_h_mi || blk_col >= max_w_mi` early return, both inter callers pass
118+ `mi_cols/rows - at_mi`).
lanes/golomb-r7.handoff.mdadded+99 -0
@@ -0,0 +1,99 @@
1+# lane-golomb r7 HANDOFF -- residue CLOSED, gate GREEN, suite still running at the cap
2+
3+Tip: `a548e9d` on `lane-golomb` (parent `0fcdf39`). Full report: `lanes/golomb-r7.report.md`.
4+
5+## Suite r6 result line
6+There is none. `$HOME/.cache/golomb-suite-r6.log` was still `active` at 254/404 tests
7+(stuck in the long superres/encoder tests) and holding `CARGO_TARGET_DIR`, so r7 stopped
8+the unit to build -- it was measuring the PRE-fix tree and is superseded. Every `test`
9+line it did emit was `ok` or a documented `ignored`.
10+
11+## Suite r7 -- INCOMPLETE at the turn cap
12+Unit `golomb-suite-r7` -> `$HOME/.cache/golomb-suite-r7.log`, still `active` at 180/404
13+tests, NO `test result:` line yet, no `FAILED` line so far. A successor must read that
14+log (`grep -E "^test result|FAILED"`); if the unit died, re-arm it with the COMMON recipe.
15+This is the one owed artifact of the round.
16+
17+## What the picture-4 investigation showed (the ladder was not needed)
18+Method: `EC_TRACE_MODE=1 EC_TRACE_COEFF=1` on `g35.obu` (md5 `9037f5b21db95d35e71f91f040fc33e1`,
19+`scratchpad/gl-gen.sh 35`) through the r6-built `decode_probe`, stderr split into frames on
20+`EC_MODE mi_row=0 mi_col=0` -> segment 4 = decode-order picture 4
21+(`scratchpad/r7-ours.err`, still on disk).
22+
23+* The residue block is `mi(0,16)` and the next `EC_MODE` is `mi(0,32)`, so it is a **64x64**
24+ block, NOT the 32x32 r6 recorded. Var-tx split into 16x16 luma leaves.
25+* Its last two coefficient units are `eob=1022 tx=DctDct` and `eob=1020 tx=DctDct`
26+ (`ctx=0`): eob > 256 proves **32x32 chroma** units
27+ (`av1_get_max_uv_txsize(BLOCK_64X64) = TX_32X32`).
28+* Its FIRST luma var-tx leaf is `eob=254 tx=Idtx`.
29+* No dequant-value ladder against aomdec was required: the coefficient values are provably
30+ identical (the whole stream stays in entropy sync and luma is bit-exact), so the only
31+ free variable left was the chroma `tx_type` -- and `IDTX` vs `DCT_DCT` are both
32+ `TX_CLASS_2D`, i.e. identical scan, identical contexts, identical msac ranges, different
33+ inverse transform. That is exactly "entropy in sync, one SB of high-frequency chroma
34+ noise, luma exact".
35+
36+## Fix applied (root cause, libaom-cited)
37+`av1_get_tx_type`, `av1/common/blockd.h:1278-1309`, chroma of an INTER block:
38+1. `DCT_DCT` only when `txsize_sqr_up_map[tx_size] > TX_32X32` (STRICTLY greater);
39+2. else the colocated luma unit's coded type, `xd->tx_type_map[(blk_row<<ss_y)*stride + (blk_col<<ss_x)]`;
40+3. then `if (!av1_ext_tx_used[av1_get_ext_tx_set_type(tx_size, 1, reduced)][tx_type]) tx_type = DCT_DCT;`
41+ (`av1_ext_tx_used` blockd.h:1036, `av1_get_ext_tx_set_type` blockd.h:1097).
42+
43+We had step 1 as `chroma side >= 32 -> DCT_DCT` and step 3 missing entirely. At exactly
44+`TX_32X32` an inter block reads `EXT_TX_SET_DCT_IDTX`, which CONTAINS IDTX -> the block
45+above must use IDTX on chroma; we used DCT_DCT.
46+
47+`crates/ec-av1/src/decode.rs`: new `fn reduce_inherited_chroma_tx_type(t, w, h)` (just above
48+`fn inter_txbset_for`) implementing all four inter sets; both callers switched
49+(`read_inter_plane` and `read_inter_plane_rect` `default_tx_type`). Sweep: `rg
50+inherited_luma_tx_type` -- those are the ONLY two sites deriving a chroma tx_type for an
51+inter block; the intra sites (`decode.rs:6056`, `9195`) are correct as-is (intra at
52+`sqr_up == TX_32X32` really is `EXT_TX_SET_DCTONLY`).
53+Unit test added: `decode::tests::an_inter_chroma_transform_narrows_its_inherited_tx_type_to_its_own_set`
54+(`cargo test -p ec-av1 --lib -- an_inter_chroma_transform_narrows` => 1 passed).
55+
56+## edge32 gate: every arm GREEN
57+`$HOME/.cache/golomb-gate-r7.log`: `test result: ok`,
58+`38 pixel-exact attempts, 32-level edge bits [horz_or_vert=0 split=394], 64-level edge bits
59+[horz_or_vert=7 split=197] right-VERT=7, 2 named refusals`.
60+Arms: (192x80, 80x192) x 1 frame x {8-bit,10-bit} plus 192x80 5-frame, cq
61+{35,40,45,50,55,57,59,61} -- so all eight cq levels are green at BOTH depths. The only two
62+non-compared attempts are `192x80 cq45/cq50 frames=5 8-bit`, which refuse by name on
63+another lane's feature (inter SB-level AB partition).
64+BEFORE: `192x80 cq35 frames=5 10bit=false frame 3 plane U: 978 pixels differ, first at row 0
65+col 32 (ours 33 vs ffmpeg 8)`.
66+
67+## Ruled out this round (each with its measurement)
68+* r6's "32x32 block at mi(0,16)" premise -- WRONG, the trace shows a 64x64 block (the next
69+ EC_MODE is mi(0,32)); anything chartered off "32x32 chroma is 16x16" was mis-premised.
70+* A wrong chroma tx SIZE: the chroma eob of 1022 (> 256) proves our unit really is 32x32,
71+ which is what `av1_get_max_uv_txsize` says.
72+* A dequant / per-plane delta_q cause: f0-f3 chroma is bit-exact under the same quantizer.
73+* Everything r6 already ruled out (deblock/CDEF/LR, DIFFWTD, warp/GM/OBMC/dual filter/
74+ masked-comp/interintra/dist-wtd, narrow-block chroma MC) stays ruled out.
75+
76+## Straddling-TU arm (r3 verifier ask): NOT added, and the two measurements say why
77+Both measured this round with the arms temporarily in `edge32_gate`
78+(`$HOME/.cache/golomb-gate-r7b.log`):
79+* `(192, 68, 5, false)`: ALL EIGHT cq attempts refuse by name -- `a reference picture whose
80+ height does not match this frame's own true size` -- so the arm compares nothing
81+ (vacuous; class `counter-from-refused-stream`). That refusal is the next blocker for any
82+ non-SB-multiple height.
83+* `(68, 192, 5, false)`: RED on a real, separate defect --
84+ `68x192 cq35 frames=5 10bit=false frame 1 plane Y: 141 pixels differ, first at row 0 col
85+ 64 (ours 167 vs ffmpeg 166) [edge32=[0,34,0,0,1,17,0,1]]`. LUMA, inside the 4-px
86+ straddling COLUMN. The straddling-ROW twin never reaches this because of the refusal above.
87+The reason is recorded as a comment in `edge32_gate` (`crates/ec-av1/src/stream.rs`, just
88+above `let cqs`) so it is not re-attempted blind.
89+
90+## Exact next step for r8
91+1. Read `$HOME/.cache/golomb-suite-r7.log`'s `test result:` line (N/0 expected); that is the
92+ only thing this round did not finish.
93+2. `main` has advanced to `85887c7` (this branch merged `18bf7dc`); re-merge before any
94+ further work.
95+3. Then the 68-px straddle: fix the `68x192` luma defect at the 4-px straddling column
96+ (start from `read_var_tx_size`'s `blk_col >= max_w_mi` early return and the right-edge
97+ prediction/availability, first difference is at row 0 col 64 = the first straddling
98+ column of decode picture 1), and the `192x68` "reference picture whose height does not
99+ match this frame's own true size" refusal -- then the arms can be added for real.
lanes/golomb-r7.report.mdadded+96 -0
@@ -0,0 +1,96 @@
1+# lane-golomb r7 REPORT -- GREEN (the r6 chroma residue is closed at its root cause)
2+
3+## What changed
4+* `crates/ec-av1/src/decode.rs` -- new `fn reduce_inherited_chroma_tx_type(t, w, h)`
5+ (inserted just above `fn inter_txbset_for`), and both inter-chroma callers now use it:
6+ * `read_inter_plane_rect`'s `default_tx_type` (was `Some(t) if w.max(h) < 32 => t`)
7+ * `read_inter_plane`'s `default_tx_type` (was `Some(t) if side < 32 => t`)
8+ Those two are the ONLY sites in the crate that derive a chroma `tx_type` for an INTER
9+ block (`rg inherited_luma_tx_type`); the intra chroma sites (`decode.rs:6056`, `9195`)
10+ take `default_intra_tx_type` and are already correct -- every value that table can
11+ produce is a member of both intra sets below 32, and both already force `DCT_DCT` at
12+ `>= 32`, which for INTRA is right (`av1_get_ext_tx_set_type` returns `EXT_TX_SET_DCTONLY`
13+ for intra at `tx_size_sqr_up == TX_32X32`).
14+* `crates/ec-av1/src/decode.rs` -- new unit test
15+ `decode::tests::an_inter_chroma_transform_narrows_its_inherited_tx_type_to_its_own_set`.
16+* `crates/ec-av1/src/stream.rs` -- comment only: the measured reason the 192x68 / 68x192
17+ straddling arms are NOT in `edge32_gate` (below).
18+
19+## ROOT CAUSE (libaom citation)
20+`av1_get_tx_type` (`av1/common/blockd.h:1278-1309`) for a chroma plane of an INTER block:
21+1. `if (txsize_sqr_up_map[tx_size] > TX_32X32) return DCT_DCT;` -- **strictly greater**;
22+2. `tx_type = xd->tx_type_map[(blk_row << ss_y) * stride + (blk_col << ss_x)]` -- the
23+ colocated luma unit's coded type (for a chroma unit at (0,0), the FIRST var-tx leaf);
24+3. `if (!av1_ext_tx_used[av1_get_ext_tx_set_type(tx_size, 1, reduced)][tx_type])
25+ tx_type = DCT_DCT;` -- narrowed by the set the **chroma** size selects
26+ (`av1_ext_tx_used` `blockd.h:1036`, `av1_get_ext_tx_set_type` `blockd.h:1097`).
27+
28+We had step 1 as `chroma side >= 32 -> DCT_DCT` and no step 3 at all. At exactly
29+`TX_32X32` an inter block reads `EXT_TX_SET_DCT_IDTX`, which **contains IDTX**. So a
30+64x64 inter superblock, whose chroma units are 32x32 (`av1_get_max_uv_txsize(BLOCK_64X64)`),
31+whose first luma var-tx leaf coded `IDTX`, must inverse-transform its chroma with IDTX --
32+we used DCT_DCT.
33+
34+`IDTX` and `DCT_DCT` are both `TX_CLASS_2D`: same scan, same coefficient contexts, same
35+msac ranges. That is why the whole stream stayed in entropy sync and only one superblock
36+of chroma came out as high-frequency noise with luma bit-exact -- the r6 handoff's exact
37+signature. (Class for the ledger: a tx_type set-membership bug is invisible to every
38+range ladder; only pixels see it.)
39+
40+The old rule was also wrong the other way for chroma 16x16 under 8x8 luma leaves
41+(`EXT_TX_SET_DTT9_IDTX_1DDCT` excludes V_ADST/H_ADST/V_FLIPADST/H_FLIPADST, which we would
42+have inherited verbatim). The new helper covers all four sets.
43+
44+## Localization (how the tx_type was identified, no aomdec rebuild)
45+`EC_TRACE_MODE=1 EC_TRACE_COEFF=1` on `g35.obu` (md5 `9037f5b21db95d35e71f91f040fc33e1`,
46+`scratchpad/gl-gen.sh 35`), split into frames on `EC_MODE mi_row=0 mi_col=0`: decode-order
47+picture 4 is segment 4. Its block at `mi(0,16)` (luma x=64,y=0) runs to the next
48+`EC_MODE mi_row=0 mi_col=32`, i.e. it is a **64x64** block (not 32x32 as r6 recorded),
49+var-tx split into 16x16 leaves. Its last two coefficient units are
50+`eob=1022 tx=DctDct` and `eob=1020 tx=DctDct` with `ctx=0` -- eob > 256 proves 32x32
51+chroma units -- while its FIRST luma leaf is `eob=254 tx=Idtx`. libaom inherits that
52+`Idtx`; we produced `DctDct`.
53+
54+## Gate
55+`cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition --nocapture`
56+(under `systemd-run --user --unit=golomb-gate-r7-... -p MemoryMax=10G`,
57+`EC_AV1_REQUIRE_AOMENC=1`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-golomb`)
58+
59+BEFORE (r6 handoff): `192x80 cq35 frames=5 10bit=false frame 3 plane U: 978 pixels differ,
60+first at row 0 col 32 (ours 33 vs ffmpeg 8) [edge32=[0,36,0,0,0,18,0,0]]`.
61+AFTER: `ok` -- 5 arms x cq {35,40,45,50,55,57,59,61}, 8-bit and 10-bit,
62+`38 pixel-exact attempts, 32-level edge bits [horz_or_vert=0 split=394], 64-level edge
63+bits [horz_or_vert=7 split=197] right-VERT=7, 2 named refusals` (both the inter SB-level
64+AB partition another lane owns).
65+
66+EVIDENCE: $HOME/.cache/golomb-gate-r7.log | cargo test -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition --nocapture, 40 aomenc encodes decoded and compared plane-by-plane vs ffmpeg | 38/38 compared attempts pixel-exact, 0 differing pixels (was 978 U pixels on the 192x80 cq35 5-frame arm)
67+EVIDENCE: $HOME/.cache/golomb-gate-r7b.log | same gate + arms (192,68,5) and (68,192,5) | 68x192 cq35 frame 1 plane Y 141 px differ first at row 0 col 64 -- separate OPEN defect, arm not kept
68+EVIDENCE: scratchpad/r7-ours.err | EC_TRACE_MODE=1 EC_TRACE_COEFF=1 decode_probe g35.obu, segment 4, block mi(0,16) | first luma leaf tx=Idtx, the two 32x32 chroma units (eob 1022/1020) took tx=DctDct
69+
70+Unit check: `cargo test -p ec-av1 --lib -- an_inter_chroma_transform_narrows` => `ok. 1 passed`.
71+
72+## Refusals lifted
73+None this round -- this is a wrong-pixels fix, not a refusal lift. `refusal_inventory` /
74+`gate_coverage` untouched.
75+
76+## The 192x68 / 68x192 straddling arm (r3 verifier ask) -- NOT ADDED, measured why
77+* `(192, 68, 5, false)`: all EIGHT cq attempts refuse by name, `a reference picture whose
78+ height does not match this frame's own true size` -> the arm compares nothing (vacuous,
79+ class `counter-from-refused-stream`).
80+* `(68, 192, 5, false)`: RED on a real separate defect --
81+ `68x192 cq35 frames=5 10bit=false frame 1 plane Y: 141 pixels differ, first at row 0
82+ col 64 (ours 167 vs ffmpeg 166) [edge32=[0,34,0,0,1,17,0,1]]`. LUMA, inside the 4-px
83+ straddling COLUMN; the straddling ROW twin (192x68) never gets that far.
84+ disposition: deferred(the right-edge straddling-column luma defect above, and the
85+ reference-size refusal) -- both are outside this lane's chroma tx_type cause.
86+
87+## Test totals
88+`$HOME/.cache/golomb-suite-r7.log` (unit `golomb-suite-r7`) -- see the `test result:` line.
89+NOTE: `$HOME/.cache/golomb-suite-r6.log` never produced a `test result:` line: it was still
90+`active` (254/404 tests, stuck in the long superres/encoder tests) and holding
91+`CARGO_TARGET_DIR`, so it was stopped -- it was measuring the PRE-fix tree and is superseded
92+by r7. Every `test` line it did produce was `ok` or a documented `ignored`.
93+
94+## Open / residue
95+* `main` has advanced to `85887c7` (we merged `18bf7dc`); this branch is NOT re-merged.
96+* the two defects the 68-px arms found (above), deferred.
lanes/golomb-r8.handoff.mdadded+50 -0
@@ -0,0 +1,50 @@
1+# lane-golomb r8 HANDOFF -- two true-size fixes in, suite GREEN, straddle arms still blocked
2+
3+Tip: `lane-golomb` (report `lanes/golomb-r8.report.md`, fix `97de75e`, merge of main
4+`85887c7` at `3a08902`). Suite: `379 passed; 0 failed; 34 ignored`
5+(`$HOME/.cache/golomb-suite-r8.log`). edge32 gate green, 38 pixel-exact attempts, 2 refusals.
6+
7+## Landed
8+1. Reference-height refusal compared the mi-rounded `true_height` with the cropped
9+ `reference.height`; now compares the header's `frame_height` (libaom compares references on
10+ `y_crop_width/height`). Every 192x68 attempt used to refuse; none do now.
11+2. `apply_loop_restoration` now takes the cropped `(frame_width, frame_height)` instead of
12+ plane `true_width/true_height` (libaom `av1_get_upsampled_plane_size` +
13+ `assert(plane_w == crop_widths)` + `av1_extend_frame`). UNGATED -- every straddle recipe
14+ runs `--enable-restoration=0`.
15+
16+## The ONE open defect this lane still owns
17+A **+-1 straddling-band INTER reconstruction defect**, both orientations, all on **frame 1**
18+(frame 0 is bit-exact in every case, so it is not intra and not a per-frame filter constant):
19+* `68x192` cq35 8-bit: `frame 1 plane Y: 141 px differ, first at row 0 col 64 (167 vs 166)`
20+ -- cols 64..67 are the straddling COLUMNS of a 68-wide frame (mi-rounded 72).
21+* `192x68` cq59 8-bit: `frame 1 plane Y: 217 px, first at row 60 col 170 (172 vs 173)`.
22+* `192x68` cq35 10-bit: `frame 1 plane Y: 305 px, first at row 56 col 48 (530 vs 531)`.
23+Reproduce by re-adding `arms.push((68, 192, 5, false))` / `arms.push((192, 68, 5, false))` in
24+`edge32_gate` (`crates/ec-av1/src/stream.rs`, the comment block just above `let cqs`) and
25+running with `EC_GATE_VERBOSE=1` (new this round -- names each attempt before decoding it,
26+because a desync otherwise panics in `mc.rs` with no arm in the message).
27+
28+RULED OUT this round, do not re-attempt:
29+* Reference border padding. `aom_yv12_extend_frame_borders_c` calls `extend_plane` with
30+ `crop_widths/crop_heights` and memsets from `src + width - 1`, so libaom OVERWRITES decoded
31+ columns 68..71 with column 67 -- exactly what our `mc::sample` clamp at `true_width-1` of the
32+ cropped reference already does. The charter's hypothesis (b) is refuted at the source.
33+* Loop restoration. The gate recipe has `--enable-restoration=0`; the 68x192 diff is
34+ byte-identical before and after fix 2 (`golomb-gate-r8c.log` vs `r8d.log`).
35+* Var-tx clipping (`max_w_mi`/`max_h_mi`). libaom's `max_block_wide` is derived from
36+ `mb_to_right_edge`, i.e. `cm->mi_params.mi_cols` -- the MI-ROUNDED bound, which is what we
37+ use. Correct as-is.
38+
39+Next probe to run (r8 ran out of budget before it): dump the 68x192 cq35 stream to disk, then
40+bisect the frame-1 divergence with `EC_AV1_PREFILT_DUMP` (8-bit vars -- the 16-bit ones
41+SEGFAULT the oracle aomdec on an 8-bit stream) against the instrumented aomdec. If the
42+divergence is already present pre-filter it is inter prediction/residual in the straddling
43+band; if not, it is deblock/CDEF at the x=68 (resp. y=68) mi edge.
44+
45+## Two blockers that are NOT this lane's code
46+* `192x68` cq40 8-bit **PANICS** in `decode_inter_block8` (`from_switchable_symbol` handed a
47+ 4th symbol, `mc.rs:203`) = lane-sub8's open below-8x8 desync. A panic cannot be tolerated
48+ as a named refusal, so no straddle arm can span cq40 until sub8 lands.
49+* `192x68` cq35 8-bit refuses "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B)"
50+ even though the recipe sets `--enable-ab-partitions=0` -- worth one measurement of its own.
lanes/golomb-r8.report.mdadded+102 -0
@@ -0,0 +1,102 @@
1+# lane-golomb r8 -- two true-size defects fixed, straddle arms STILL not addable
2+
3+Tip: `97de75e` on `lane-golomb` (merge `3a08902` of main `85887c7`, then the fix).
4+
5+## (1) Suite r7 -- no result line, superseded
6+`$HOME/.cache/golomb-suite-r7.log` was still `active` at **226/404** tests with **no**
7+`test result:` line and **zero** `FAILED`/`panicked` lines. It was measuring the PRE-merge
8+tree (main has since advanced to 85887c7), so r8 stopped the unit to take the target dir.
9+Owed artifact carried forward to r8's own suite.
10+
11+## (2) Merge of main 85887c7
12+`git merge --no-commit main` was a CLEAN auto-merge (decode.rs + stream.rs auto-merged, no
13+conflict, no hand resolution). Byte-compared against main afterwards:
14+`mvstack.rs`, `cdf.rs`, `cdf_state.rs`, `refusal_inventory.rs` are all **IDENTICAL to main**
15+(`git diff --quiet main -- <file>`). Only decode.rs and stream.rs carry lane content.
16+Merge commit `3a08902`.
17+
18+EVIDENCE: $HOME/.cache/golomb-gate-r8h.log | edge32 gate on the merged tree, all 8 cq arms x
19+{192x80, 80x192} x {8,10}-bit + the 5-frame inter arm | `test result: ok`, 38 pixel-exact
20+attempts, 64-level edge bits [horz_or_vert=7 split=197] right-VERT=7, 2 named refusals --
21+byte-identical totals to r7's green run.
22+
23+## (3a) FIXED: a same-size reference at a height that is not a multiple of 8
24+`crates/ec-av1/src/decode.rs`, `decode_inter_frame_tile_with_cdfs`: the guard compared
25+`reference.height` against `true_height = (mi_rows * 4)` (mi-rounded). A decoded `Picture`
26+is cropped to the header's `fh`, so at height 68 (`mi_rows = 2*((68+7)>>3) = 18` -> 72) it
27+compared **68 against 72** and refused every same-size reference.
28+libaom compares references on the CROPPED dimensions --
29+`av1_setup_scale_factors_for_frame(&sf, ref->y_crop_width, ref->y_crop_height, cm->width,
30+cm->height)` -- and calls a reference *scaled* only when those differ (`av1_is_scaled`).
31+Height must still match (AV1 superres never scales height). Class `av1-truesize-lane`.
32+
33+EVIDENCE: $HOME/.cache/golomb-gate-r8{b,f}.log | `arms.push((192, 68, 5, false))`, cq sweep |
34+BEFORE: 8/8 attempts refuse "a reference picture whose height does not match this frame's own
35+true size"; AFTER: 0/8 do.
36+
37+## (3b) NOT the cause of the 68x192 column defect -- charter hypothesis REFUTED at the source
38+The charter proposed our reference plane replicates from the mi-rounded column 71 instead of
39+the true column 67. Read `aom_scale/generic/yv12extend.c`: `aom_yv12_extend_frame_borders_c`
40+calls `extend_plane(..., ybf->crop_widths[is_uv], ybf->crop_heights[is_uv], ...,
41+right = plane_border + widths - crop_widths)` and `extend_plane` memsets from
42+`src + width - 1` -- i.e. libaom OVERWRITES the decoded columns 68..71 with column 67.
43+Our `mc::sample` clamps at `true_width - 1` of the CROPPED reference `Picture` (68) -->
44+already identical. No fix needed; the 141-px defect is elsewhere.
45+
46+## (3c) FIXED (source-cited, UNEXERCISED): loop restoration ran over the mi-rounded plane
47+`decode.rs::apply_loop_restoration` passed each plane's `true_width`/`true_height`. LR is the
48+one post-decode filter that does not walk the mi grid: libaom sizes every plane with
49+`av1_get_upsampled_plane_size` (`plane_w = ROUND_POWER_OF_TWO(cm->superres_upscaled_width,
50+ss_x)`, `av1/common/restoration.c:47`), **asserts** it equals the buffer's crop width
51+(`restoration.c:1106`) and `av1_extend_frame(..., plane_w, plane_h, ...)` replicates the
52+border from that cropped edge before any unit is filtered (`restoration.c:1109`). Deblock and
53+CDEF DO walk the mi grid, which is why this survived until a non-multiple-of-8 size.
54+Now takes `(frame_width, frame_height)`, chroma `div_ceil(2)`.
55+DISCLOSURE: **no gate exercises this** -- every straddle recipe in `edge32_gate` runs
56+`--enable-restoration=0`, and the 68x192 defect was byte-identical before and after
57+($HOME/.cache/golomb-gate-r8{c,d}.log, both `141 pixels differ, first at row 0 col 64`).
58+It is a source-cited correctness alignment, verified only by the suite staying green.
59+
60+## (4) The straddle arms are STILL not addable -- three separate blockers, each measured
61+Charter asked for `(192,68,5)` and `(68,192,5)` arms at 8+10 bit with a straddling-TU counter.
62+DEVIATION: no arm was added, because every cq level of both is vacuous, panicking or red.
63+The measurements are now recorded verbatim in the `edge32_gate` comment block:
64+* `192x68` cq35 8-bit: no longer the height refusal -- refuses LATER by another lane's name,
65+ "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B)". Vacuous
66+ (class `counter-from-refused-stream`).
67+* `192x68` cq40 8-bit: **PANICS** in `decode_inter_block8` -- `from_switchable_symbol` handed a
68+ 4th symbol, `mc.rs:203`. That is lane-sub8's own open below-8x8 desync (already named in
69+ `decode.rs`'s scaled-reference-8x8 refusal comment). A panic cannot be tolerated as a named
70+ refusal, so the arm cannot even be added with an Err-tolerating recipe.
71+* `192x68` cq59 8-bit: RED, `frame 1 plane Y: 217 pixels differ, first at row 60 col 170
72+ (ours 172 vs ffmpeg 173)`.
73+* `192x68` cq35 10-bit: RED, `frame 1 plane Y: 305 pixels differ, first at row 56 col 48
74+ (ours 530 vs ffmpeg 531)`.
75+* `68x192` cq35 8-bit: RED, `frame 1 plane Y: 141 pixels differ, first at row 0 col 64
76+ (ours 167 vs ffmpeg 166)` -- unchanged from r7 by either fix this round.
77+
78+NEW FACT for the successor: all four red cases are **+-1** bands, on **frame 1** (the first
79+INTER frame -- frame 0 is bit-exact in every one), and they sit in or immediately beside the
80+4-px straddling band (rows 56..63 next to straddling rows 64..67; columns 64..67 are the
81+straddling columns themselves). That is one straddling-band INTER reconstruction defect with
82+two orientations, not four defects -- and it is not the reference border (3b), not LR (3c) and
83+not intra (frame 0 exact).
84+
85+The gate now prints each attempt under `EC_GATE_VERBOSE=1` (`stream.rs`), because a desync
86+otherwise surfaces as a bare panic in `mc.rs` with no arm named.
87+
88+## Test totals
89+`cargo test -p ec-av1 --lib` -> `$HOME/.cache/golomb-suite-r8.log` (unit `golomb-suite-r8`):
90+`test result: ok. 379 passed; 0 failed; 34 ignored; 0 measured; 0 filtered out; finished in
91+917.74s` (413 test lines emitted). GREEN.
92+
93+EVIDENCE: $HOME/.cache/golomb-suite-r8.log | `cargo test -p ec-av1 --lib` on the merged tree at
94+97de75e, unit golomb-suite-r8, MemoryMax=10G | 379 passed / 0 failed / 34 ignored.
95+
96+## Residue disposition
97+* 68x192 / 192x68 straddling-band +-1 INTER defect -- **fix-now, next round**; it is this
98+ lane's whole remaining job and the successor has the four measurements above.
99+* `192x68` cq40 below-8x8 panic -- **deferred(lane-sub8's open desync)**; not this lane's code.
100+* `192x68` cq35 inter SB-level AB partition refusal -- **deferred(the AB-partition lane)**.
101+* LR cropped-plane fix ungated -- **deferred(a straddle gate arm with
102+ `--enable-restoration=1`)**; the base recipe disables restoration for every arm.
lanes/golomb-r9.report.mdadded+100 -0
@@ -0,0 +1,100 @@
1+# lane-golomb r9 -- the straddling-band defect is CDEF, and a stream-data PANIC is now a refusal
2+
3+## What changed
4+
5+* `crates/ec-av1/src/decode.rs` `neighbour_filter` -- returns `Result` and refuses
6+ "an OBMC neighbour whose switchable interp filter was never recorded" instead of handing the
7+ `[3, 3]` sentinel to `mc::from_switchable_symbol`, which `panic!`s on any value above 2.
8+ Both call sites (`build_obmc_prediction`'s above and left passes) already sat inside a
9+ `Result` function and take `?`.
10+* `crates/ec-av1/src/refusal_inventory.rs` -- the new refusal string pinned.
11+* `crates/ec-av1/src/decode.rs` `deblock_plane` -- new `EC_AV1_DEBLOCK_TRACE_V` rung: the
12+ per-edge `x0/y0/len/level` of the vertical pass plus one line per plane with the loop's real
13+ `tw`/`th`/`stride` vs `true_*`/crop bounds. That rung is what settled the deblock question below.
14+* `crates/ec-av1/src/stream.rs` -- `a_frame_edge_straddling_band_decodes_pixel_exact`, an
15+ `#[ignore]`d pinned test that runs `edge32_gate`'s exact recipe over the four straddle arms
16+ (192x68 and 68x192, 5 frames, 8-bit and 10-bit, cq 35..61), with `EC_GATE_VERBOSE` naming.
17+
18+## TASK A -- root cause narrowed to CDEF, stage by stage (fix NOT landed)
19+
20+Stream: `~/.cache/golomb-tmp/s68.obu`, md5 `45722b0fb7f1707a18e0547cc7a59fa2`, produced by
21+`edge32_gate`'s own aomenc recipe at 68x192 cq35 8-bit, 5 frames.
22+
23+| stage | ours vs instrumented aomdec, frame 1 |
24+| --- | --- |
25+| reconstruction (`EC_AV1_PREFILT_DUMP`) | **0 luma pixels differ** over the cropped 68 columns |
26+| post-deblock (`EC_AV1_POSTDEBLOCK_DUMP`, `EC_AV1_DEBUG_SKIP_CDEF=1`) | **matches**, including columns 68..71 |
27+| final output vs ffmpeg | 145 luma differ, mass in columns 64..67 |
28+
29+So inter prediction is exact and the charter's "the MC reference read runs past the crop"
30+hypothesis is refuted a second time (r8 refuted it at the libaom source; r9 refutes it by
31+measurement: our returned `Picture` is already cropped to `frame_width`, so `mc::sample` clamps
32+at column 67 exactly as `extend_plane` does). The deblock is also exact -- `frame_width` is the
33+right clip, confirmed against libaom `set_lpf_parameters`' `if ((width <= x) || (height <= y))`
34+early-out on `plane_ptr->dst.width`, which is the crop width; forcing the mi-rounded bound
35+instead made frame 0 RED (17 luma px, columns 65..67), so r7's clip stays.
36+
37+The divergence therefore enters in **CDEF**, at the last 8x8 CDEF block column (mi column 17,
38+pixels 64..71) -- the one block that straddles the crop edge. Frame 0 survives it and frame 1
39+does not, which is why every earlier round read the shape as "inter".
40+
41+Two instrument facts a successor needs:
42+* aomdec's `EC_AV1_POSTDEBLOCK_DUMP` is **72 columns wide** (mi-rounded) while its
43+ `EC_AV1_PREFILT_DUMP` is cropped to 68 -- the post-deblock rung is the only one that exposes
44+ the straddling band on the reference side.
45+* our own `EC_AV1_POSTDEBLOCK_DUMP` is emitted from a site that, on this path, runs **after**
46+ `apply_cdef`: `od.f0` and `odnc.f0` (same run, `EC_AV1_DEBUG_SKIP_CDEF=1`) differ in columns
47+ 68..71 although `EC_AV1_WATCH`-instrumented `filter_edge` performs no write there. Always pair
48+ that dump with `EC_AV1_DEBUG_SKIP_CDEF=1`, or the CDEF defect reads as a deblock defect --
49+ which cost r9 six rounds of the budget.
50+
51+EVIDENCE: ~/.cache/golomb-tmp/{ours,theirs,od,odnc,td}.f* | aomenc 68x192 cq35 5f -> decode_probe with EC_AV1_PREFILT_DUMP / EC_AV1_POSTDEBLOCK_DUMP(+EC_AV1_DEBUG_SKIP_CDEF) vs the same rungs on the oracle aomdec | prefilt f1 luma diffs 0/13056, post-deblock (cdef off) f1 luma diffs 0, final output f1 145 differ first row 0 col 64
52+
53+## TASK B -- the panic is gone
54+
55+Before: `192x68 cq40` aborted the process in `mc.rs:203`. After:
56+
57+```
58+$ decode_probe s40.obu
59+REFUSED: unsupported: AV1 tile (an OBMC neighbour whose switchable interp filter was never recorded)
60+```
61+
62+EVIDENCE: ~/.cache/golomb-tmp/s40.obu (md5 26d42c5f04e4d0f7f4075a4550e999d5) | aomenc 192x68 cq40 5f -> cargo run --example decode_probe | process abort in mc.rs:203 -> `REFUSED: unsupported: AV1 tile (an OBMC neighbour whose switchable interp filter was never recorded)`
63+
64+Sweep of the other aborts reachable from a desynced stream (`decode.rs` + `mc.rs`), each checked
65+against the value's own domain:
66+
67+* `mc.rs:203` `from_switchable_symbol` -- FIXED at its only reachable caller. The other caller
68+ (`resolve_interp_filter`) reads a 3-symbol CDF (`switchable_interp: [[u16; 4]; 16]`,
69+ `nsyms = cdf.len() - 1`), so it cannot produce a 4th symbol.
70+* `mc.rs:220` `from_header(Switchable)` -- header enum, not a per-block stream value; callers
71+ resolve `Switchable` before calling. Left.
72+* `decode.rs:3259` `default_intra_tx_type` -- the mode comes from a 13-symbol CDF and all 13
73+ values have a row. Bounded, left.
74+* `decode.rs:13936`/`14114` `partition_w8` and `decode.rs:15352` `read_single_ref` -- values from
75+ 4-symbol / bounded-return helpers. Bounded, left.
76+* `decode.rs:11673/11692/11739` -- guarded by `rect_inter_residual_supported`, which is itself a
77+ named refusal. Left.
78+* `decode.rs:11324`, `12091`, `12110`, `12147`, `15660`, `2745` -- block-size / tx-size domain
79+ invariants, not stream values. Left.
80+* `decode.rs:2498` `ref_hits` -- a test-side counter accessor, never on the decode path. Left.
81+* the non-test `.unwrap()`/`.expect()` in `decode.rs` (5280, 5324, 6085, 6152, 7352/7353,
82+ 7819/7820, 10535, 10591, 10735, 10944) are each dominated by a push/refusal a few lines above.
83+ Left, listed here so the next sweep does not re-derive it.
84+
85+## TASK C -- arms
86+
87+`a_frame_edge_straddling_band_decodes_pixel_exact` carries all four straddle arms and is
88+`#[ignore]`d, which is the only honest shape while the CDEF defect is open: an arm that is RED
89+cannot join the green gate, and the r8 handoff's "measured, arm not added" comment is now a
90+runnable test instead of prose.
91+
92+fix-now residue, NOT done this round:
93+* deferred(the CDEF straddle fix) -- the `--enable-restoration=1` arm at 192x68 that would gate
94+ r8's cropped-plane loop-restoration fix. `edge32_gate`'s arm tuple has no per-arm flag slot and
95+ every straddle recipe is RED regardless, so the LR arm would be vacuous today; it unblocks the
96+ moment the CDEF fix lands. This is the same `refusal-lifted-without-a-gate` shape r8 flagged.
97+
98+## Suite
99+
100+`cargo test -p ec-av1 --lib` -> **379 passed; 0 failed; 35 ignored** (`$HOME/.cache/golomb-suite-r9.log`; the extra ignored test vs r8 is the new pinned straddle gate).