forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-golomb' (173b793): frame-edge partition bits, luma-only deblock grid, cropped reference guards

Browse files at this commit

58dfef5fd77647439c08d67234671cf6d55c519bAhmet Kaan GümüşParent: edebe88414fb70
- frame-edge partition bits at the 32 level; edge32 gate.
- chroma deblock grid keeps the block's own av1_get_max_uv_txsize -- the var-tx
  leaf write is LUMA only (libaom get_transform_size splits for AOM_PLANE_Y alone).
  Merge resolution: lane-r14's RECT (row,col,tw,th) leaves are kept and routed
  through this lane's fill_lf_grid_leaf_luma.
- inter chroma tx_type set narrowing, cropped reference-size guard, loop-restoration
  crop, mc.rs:203 panic converted to a refusal (OBMC neighbour with no recorded
  switchable interp filter). The lane's second refusal string (palette on a 1:4 rect
  strip) is NOT carried: lane-kf900 lifted that shape, and it no longer exists in
  decode.rs.

Gates: 32x32_frame_edge (1), refusal_inventory (3), gate_coverage (9),
base_ctx_rect_offsets (1), vartx (1), 1to4 (6) -- all pass.

13 changed files +1700 -139

crates/ec-av1/src/decode.rsmodified+398 -139
@@ -2157,6 +2157,44 @@ pub(crate) fn sb_rect_hits() -> usize {
21572157 SB_RECT_HITS.with(|c| c.get())
21582158 }
21592159
2160+// lane-golomb r2: the 32x32-level FRAME-EDGE partition. Slot 0/1 = the
2161+// gathered edge bit read as 0 (HORZ/VERT) / 1 (SPLIT); slot 2 = a 32-level
2162+// PARTITION_HORZ decoded with `has_rows32 == false` (only the top 32x16 half
2163+// is coded), slot 3 = a PARTITION_VERT with `has_cols32 == false`. Both tile
2164+// paths (intra and inter) feed the same counter.
2165+//
2166+// lane-golomb r3: slots 4..7 are the same four facts one level up, at the
2167+// SUPERBLOCK (64x64) edge -- 4/5 = the gathered 64-level bit read as
2168+// HORZ/VERT / SPLIT, 6 = a 64x32 bottom-edge strip decoded with
2169+// `has_rows == false`, 7 = a 32x64 right-edge strip. Real aomenc answers a
2170+// bottom-edge superblock with the 64-level HORZ (measured: 192x80 flat-band,
2171+// every SB of the last row), so the 32-level slots stay 0 on that content and
2172+// only these prove the arm fired.
2173+thread_local! {
2174+ static EDGE32_HITS: std::cell::Cell<[usize; 8]> =
2175+ const { std::cell::Cell::new([0; 8]) };
2176+}
2177+
2178+/// Current value of [`EDGE32_HITS`].
2179+pub(crate) fn edge32_hits() -> [usize; 8] {
2180+ EDGE32_HITS.with(|c| c.get())
2181+}
2182+
2183+/// [`bump_edge32`] of `base + bit`, returning the bit -- the gathered edge
2184+/// reads are `if`-conditions, so the counter has to ride the expression.
2185+fn bump_edge32_bit(base: usize, bit: usize) -> usize {
2186+ bump_edge32(base + bit.min(1));
2187+ bit
2188+}
2189+
2190+fn bump_edge32(slot: usize) {
2191+ EDGE32_HITS.with(|c| {
2192+ let mut h = c.get();
2193+ h[slot] += 1;
2194+ c.set(h)
2195+ });
2196+}
2197+
21602198 // lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/
21612199 // `_B`/`VERT_A`/`_B` at 64x64 -- two 32x32 squares plus one 64x32/32x64
21622200 // strip) fired. Real aomenc picks these at 64 even with
@@ -4330,6 +4368,36 @@ impl Neighbours {
43304368 }
43314369 }
43324370
4371+ /// One var-tx / split-tx LEAF's own LUMA transform dims over its mi span.
4372+ /// libaom `get_transform_size` (av1_loopfilter.c:207) applies the split
4373+ /// override only `if ((plane == AOM_PLANE_Y) && ...)` -- chroma keeps
4374+ /// `av1_get_max_uv_txsize(mbmi->bsize)`, the whole BLOCK's uv transform.
4375+ /// Routing a leaf through [`Self::fill_lf_grid_rect`] recomputed the uv
4376+ /// dims from the LEAF span and so invented chroma transform edges the
4377+ /// deblocker then filtered (lane-golomb r6). `ref_grid`/`delta_lf_grid`
4378+ /// are already correct from the block's own fill over the same span.
4379+ fn fill_lf_grid_leaf_luma(
4380+ &mut self,
4381+ at_mi: (usize, usize),
4382+ w_mi: usize,
4383+ h_mi: usize,
4384+ tx_px: u8,
4385+ tx_h_px: u8,
4386+ ) {
4387+ let (mi_r, mi_c) = at_mi;
4388+ for rr in 0..h_mi {
4389+ for cc in 0..w_mi {
4390+ let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc);
4391+ if let Some(cell) = self.tx_grid.get_mut(idx) {
4392+ *cell = tx_px;
4393+ }
4394+ if let Some(cell) = self.tx_h_grid.get_mut(idx) {
4395+ *cell = tx_h_px;
4396+ }
4397+ }
4398+ }
4399+ }
4400+
43334401 /// Marks every 4x4 mi cell a just-decoded coded block covers with its
43344402 /// `skip` flag -- `at_mi`/`side_mi` are the block's own position and
43354403 /// width/height in 4x4 mode-info units (mirroring [`Self::record_mi`]'s
@@ -9258,8 +9326,22 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize,
92589326
92599327 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {
92609328 use std::io::Write;
9329+ // lane-golomb r6: one file per DECODE-order picture, like aomdec's own
9330+ // `ec_dump16` static index -- a single `.f0` overwritten every frame made
9331+ // the post-deblock stage uncomparable across a sequence.
9332+ thread_local! {
9333+ static STAGE_IDX: std::cell::RefCell<std::collections::HashMap<String, usize>> =
9334+ std::cell::RefCell::new(std::collections::HashMap::new());
9335+ }
9336+ let idx = STAGE_IDX.with(|m| {
9337+ let mut m = m.borrow_mut();
9338+ let e = m.entry(var.to_string()).or_insert(0);
9339+ let i = *e;
9340+ *e += 1;
9341+ i
9342+ });
92619343 if let Ok(path) = std::env::var(var)
9262- && let Ok(mut f) = std::fs::File::create(format!("{path}.f0"))
9344+ && let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}"))
92639345 {
92649346 for p in [y, u, v] {
92659347 let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect();
@@ -12359,8 +12441,8 @@ fn read_inter_plane_rect(
1235912441 // `av1_get_ext_tx_set_type`'s DCT-only clamp is on `tx_size_sqr_up`, i.e.
1236012442 // the *longer* side of this rect transform.
1236112443 let default_tx_type = match inherited_luma_tx_type {
12362- Some(t) if w.max(h) < 32 => t,
12363- _ => TxType::DctDct,
12444+ Some(t) => reduce_inherited_chroma_tx_type(t, w, h),
12445+ None => TxType::DctDct,
1236412446 };
1236512447 // lane-r14 r2: a 64-length axis codes only its low 32 coefficients
1236612448 // (`av1_get_max_eob`), so the coded unit is the `min(w,32) x min(h,32)`
@@ -12527,6 +12609,45 @@ fn read_inter_luma8(
1252712609
1252812610 /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its
1252912611 /// coefficient tables from -- the inter counterpart of [`txbset_for`].
12612+/// `av1_get_tx_type`'s chroma tail (libaom `av1/common/blockd.h:1291-1305`):
12613+/// an inter block's chroma transform inherits the *colocated luma* unit's
12614+/// coded `tx_type`, then drops back to `DCT_DCT` unless that type is a member
12615+/// of the extended set the CHROMA transform size selects
12616+/// (`av1_ext_tx_used[av1_get_ext_tx_set_type(uv_tx, 1, reduced)][tx_type]`,
12617+/// `blockd.h:1036`/`1097`). lane-golomb r7: we used to force `DCT_DCT` at
12618+/// every chroma side >= 32, but `av1_get_ext_tx_set_type`'s DCT-only rung is
12619+/// `tx_size_sqr_up > TX_32X32`; at exactly TX_32X32 an inter block reads
12620+/// `EXT_TX_SET_DCT_IDTX`, so a 64x64 inter block whose first luma leaf coded
12621+/// `IDTX` inherits IDTX on its 32x32 chroma units. `IDTX` and `DCT_DCT` are
12622+/// both `TX_CLASS_2D`, so that mistake left the entropy stream perfectly in
12623+/// sync and only corrupted the inverse transform (one 64x64 superblock of
12624+/// high-frequency chroma noise, luma bit-exact).
12625+fn reduce_inherited_chroma_tx_type(t: TxType, w: usize, h: usize) -> TxType {
12626+ use TxType::*;
12627+ let sqr_up = w.max(h);
12628+ let sqr = w.min(h);
12629+ let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
12630+ // `av1_get_ext_tx_set_type(tx_size, is_inter = 1, reduced)`.
12631+ let allowed: &[TxType] = if sqr_up > 32 {
12632+ // EXT_TX_SET_DCTONLY
12633+ &[DctDct]
12634+ } else if sqr_up == 32 || reduced {
12635+ // EXT_TX_SET_DCT_IDTX
12636+ &[DctDct, Idtx]
12637+ } else if sqr == 16 {
12638+ // EXT_TX_SET_DTT9_IDTX_1DDCT -- TX_TYPES 0..=11, i.e. everything but
12639+ // the four 1D ADST/FLIPADST types.
12640+ &[
12641+ DctDct, AdstDct, DctAdst, AdstAdst, FlipAdstDct, DctFlipAdst, FlipAdstFlipAdst,
12642+ AdstFlipAdst, FlipAdstAdst, Idtx, VDct, HDct,
12643+ ]
12644+ } else {
12645+ // EXT_TX_SET_ALL16
12646+ return t;
12647+ };
12648+ if allowed.contains(&t) { t } else { DctDct }
12649+}
12650+
1253012651 fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
1253112652 match tx_px {
1253212653 32 => TxbSet::Luma32Inter,
@@ -13032,6 +13153,18 @@ fn deblock_plane(
1303213153 // last coded mi column's horizontal edges were filtered when libaom's
1303313154 // real output leaves them untouched (r6's post-deblock diff, 37 px, all
1303413155 // in columns 44-47); clipping here closes it (3/3 frames pixel-exact).
13156+ // lane-golomb r9: the bound is the MI-ROUNDED frame, not the coded
13157+ // frame. libaom's `av1_filter_block_plane_vert/horz` walk the superblock
13158+ // and stop at `cm->mi_params.mi_cols`/`mi_rows`, which
13159+ // `av1_set_mb_mi` derives from `ALIGN_POWER_OF_TWO(width, 3)` -- the
13160+ // 8-pixel-aligned frame, i.e. a 68-wide frame is filtered out to column
13161+ // 72 and the vertical edge AT x=68 is a real edge that rewrites the
13162+ // in-crop columns 64..67. Clipping at `frame_width` skipped it, which is
13163+ // the +-1 straddling-band defect (68x192 cq35, frame 1, 141 luma pixels
13164+ // all in columns 64..67; frame 0 survived because that edge carried no
13165+ // filter level there). r7's superres measurement is preserved: its frame
13166+ // was already 8-aligned, so this bound equals `frame_width` there and
13167+ // still excludes the superblock padding up to `true_width`.
1303513168 let (cw, ch) = if chroma {
1303613169 (frame_width.div_ceil(2), frame_height.div_ceil(2))
1303713170 } else {
@@ -13042,11 +13175,17 @@ fn deblock_plane(
1304213175 plane.true_height.min(ch),
1304313176 plane.width,
1304413177 );
13178+ if std::env::var_os("EC_AV1_DEBLOCK_TRACE_V").is_some() {
13179+ eprintln!("DEBLOCK plane={plane_idx} tw={tw} th={th} stride={stride} true={}x{} crop={cw}x{ch}", plane.true_width, plane.true_height);
13180+ }
1304513181 let mut y0 = 0usize;
1304613182 while y0 < th {
1304713183 let mut x0 = 4usize;
1304813184 while x0 < tw {
1304913185 if let Some((len, level)) = edge_params(lf, n, plane_idx, 0, chroma, x0, y0) {
13186+ if std::env::var_os("EC_AV1_DEBLOCK_TRACE_V").is_some() && plane_idx == 0 {
13187+ eprintln!("VEDGE x0={x0} y0={y0} len={len} level={level}");
13188+ }
1305013189 filter_edge(
1305113190 &mut plane.data,
1305213191 y0 * stride + x0,
@@ -13246,13 +13385,30 @@ fn apply_loop_restoration(
1324613385 deblocked_v: &PlaneBuf,
1324713386 lr: &LoopRestorationParams,
1324813387 grid: &crate::restoration::RestorationGrid,
13388+ // lane-golomb r8: this frame header's own (cropped) luma size. Loop
13389+ // restoration is the ONE post-decode filter that does NOT run over the
13390+ // mi-rounded plane: libaom's `av1_loop_restoration_filter_frame` sizes
13391+ // every plane with `av1_get_upsampled_plane_size` -- `plane_w =
13392+ // ROUND_POWER_OF_TWO(cm->superres_upscaled_width, ss_x)`, `plane_h =
13393+ // ROUND_POWER_OF_TWO(cm->height, ss_y)` (`av1/common/restoration.c:47`)
13394+ // -- and asserts it equals the buffer's CROP width
13395+ // (`restoration.c:1106`), then `av1_extend_frame(..., plane_w, plane_h,
13396+ // ...)` (`restoration.c:1109`) replicates the right/bottom border from
13397+ // that cropped edge before any unit is filtered. Deblock and CDEF DO
13398+ // walk the mi grid, which is why passing `true_width`/`true_height`
13399+ // here went unnoticed until a frame whose size is not a multiple of 8
13400+ // (68 -> mi-rounded 72): the LR taps at the last four real columns then
13401+ // read this decoder's own decoded samples at columns 68..71 where
13402+ // libaom reads column 67 replicated -- +-1 over the straddling band
13403+ // (class av1-truesize-lane: true frame size vs mi-rounded).
13404+ (frame_w, frame_h): (usize, usize),
1324913405 ) {
1325013406 y.data = crate::restoration::apply_loop_restoration_plane(
1325113407 &y.data,
1325213408 &deblocked_y.data,
1325313409 y.width,
13254- y.true_width,
13255- y.true_height,
13410+ frame_w,
13411+ frame_h,
1325613412 0,
1325713413 lr.frame_restoration_type[0],
1325813414 lr.loop_restoration_size[0],
@@ -13263,8 +13419,8 @@ fn apply_loop_restoration(
1326313419 &u.data,
1326413420 &deblocked_u.data,
1326513421 u.width,
13266- u.true_width,
13267- u.true_height,
13422+ frame_w.div_ceil(2),
13423+ frame_h.div_ceil(2),
1326813424 1,
1326913425 lr.frame_restoration_type[1],
1327013426 lr.loop_restoration_size[1],
@@ -13275,8 +13431,8 @@ fn apply_loop_restoration(
1327513431 &v.data,
1327613432 &deblocked_v.data,
1327713433 v.width,
13278- v.true_width,
13279- v.true_height,
13434+ frame_w.div_ceil(2),
13435+ frame_h.div_ceil(2),
1328013436 1,
1328113437 lr.frame_restoration_type[2],
1328213438 lr.loop_restoration_size[2],
@@ -13840,12 +13996,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1384013996 (true, false) => {
1384113997 trace_edge((sb_r * SB_MI) as usize, (sb_c * SB_MI) as usize, 12, ctx, dec.debug_state().0 as u32);
1384213998 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE));
13999+ bump_edge32(4 + b.min(1) as usize);
1384314000 bump_edge_part(b.min(1) as usize);
1384414001 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
1384514002 }
1384614003 (false, true) => {
1384714004 trace_edge((sb_r * SB_MI) as usize, (sb_c * SB_MI) as usize, 12, ctx, dec.debug_state().0 as u32);
1384814005 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE));
14006+ bump_edge32(4 + b.min(1) as usize);
1384914007 bump_edge_part(b.min(1) as usize);
1385014008 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }
1385114009 }
@@ -13915,6 +14073,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1391514073 &cdfs.partition_w32[ctx32],
1391614074 VERT_ALIKE,
1391714075 ));
14076+ bump_edge32(b.min(1) as usize);
1391814077 bump_edge_part(2 + b.min(1) as usize);
1391914078 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
1392014079 }
@@ -13924,6 +14083,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1392414083 &cdfs.partition_w32[ctx32],
1392514084 HORZ_ALIKE,
1392614085 ));
14086+ bump_edge32(b.min(1) as usize);
1392714087 bump_edge_part(2 + b.min(1) as usize);
1392814088 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }
1392914089 }
@@ -14581,6 +14741,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1458114741 tx_select,
1458214742 reduced_tx_set,
1458314743 )?;
14744+ if !has_rows32 {
14745+ bump_edge32(2);
14746+ }
1458414747 // lane-hgkf r1: at the frame edge only the first half of the strip is
1458514748 // coded (libaom `decode_partition` guards the second half with the same
1458614749 // test that made this partition non-square).
@@ -14622,6 +14785,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1462214785 tx_select,
1462314786 reduced_tx_set,
1462414787 )?;
14788+ if !has_cols32 {
14789+ bump_edge32(3);
14790+ }
1462514791 // lane-hgkf r1: at the frame edge only the first half of the strip is
1462614792 // coded (libaom `decode_partition` guards the second half with the same
1462714793 // test that made this partition non-square).
@@ -15012,6 +15178,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1501215178 tx_select,
1501315179 reduced_tx_set,
1501415180 )?;
15181+ if !has_rows {
15182+ bump_edge32(6);
15183+ }
1501515184 // lane-golomb r1: at the frame edge only the first half of the
1501615185 // strip is coded (libaom `decode_partition` guards the second
1501715186 // with the same has_rows test that made this partition non-square).
@@ -15053,6 +15222,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1505315222 tx_select,
1505415223 reduced_tx_set,
1505515224 )?;
15225+ if !has_cols {
15226+ bump_edge32(7);
15227+ }
1505615228 // lane-golomb r1: at the frame edge only the first half of the
1505715229 // strip is coded (libaom `decode_partition` guards the second
1505815230 // with the same has_cols test that made this partition non-square).
@@ -15275,7 +15447,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1527515447 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
1527615448 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);
1527715449 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
15278- apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid);
15450+ apply_loop_restoration(
15451+ &mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid,
15452+ (frame_width as usize, frame_height as usize),
15453+ );
1527915454
1528015455 let (fw, fh) = (frame_width as usize, frame_height as usize);
1528115456 if fw == width && fh == height {
@@ -15667,10 +15842,9 @@ fn read_inter_plane(
1566715842 // `tx_type` -- `av1_get_tx_type` (libaom `blockd.h`): an inter block's
1566815843 // chroma plane never codes its own `tx_type` symbol, but (unlike an
1566915844 // intra block, which falls back to `Intra_Mode_To_Tx_Type`) it inherits
15670- // the colocated luma transform's coded type verbatim, clamped back to
15671- // `DCT_DCT` at the chroma tx sizes the spec forces DCT-only
15672- // (`av1_get_ext_tx_set_type`: `tx_size_sqr_up >= TX_32X32`, i.e. this
15673- // function's own `side >= 32`). `None` for the luma call itself
15845+ // the colocated luma transform's coded type, narrowed to the extended
15846+ // set the CHROMA size selects ([`reduce_inherited_chroma_tx_type`]).
15847+ // `None` for the luma call itself
1567415848 // (`plane_idx == 0`), where the `TxbSet`'s own symbol (or the true
1567515849 // `DCT_DCT` default at 32-point+) already resolves it without help.
1567615850 inherited_luma_tx_type: Option<TxType>,
@@ -15688,8 +15862,8 @@ fn read_inter_plane(
1568815862 };
1568915863 let mut coding = cdfs.txb(set, tx_mode);
1569015864 let default_tx_type = match inherited_luma_tx_type {
15691- Some(t) if side < 32 => t,
15692- _ => TxType::DctDct,
15865+ Some(t) => reduce_inherited_chroma_tx_type(t, side, side),
15866+ None => TxType::DctDct,
1569315867 };
1569415868 let (grid, tx_type) = read_coeffs(
1569515869 dec,
@@ -16082,22 +16256,33 @@ fn obmc_mask(len: usize) -> &'static [u8] {
1608216256 /// A bordering block's own resolved interp filter kernel, `(h, v)` --
1608316257 /// mirrors [`resolve_interp_filter`]'s own return order from its stored
1608416258 /// `[u8; 2]` (`Neighbours::above_filter`/`left_filter`, `[sym0, sym1]` =
16085-/// `[v_sym, h_sym]`). Never calls `from_switchable_symbol` on the `[3, 3]`
16086-/// sentinel: that value is only ever stored for an intra neighbour (already
16087-/// excluded by [`overlappable_above`]/[`overlappable_left`]'s `is_inter`
16088-/// gate) or when `interp_fixed` is `Some` for the whole frame, handled here
16089-/// first.
16259+/// `[v_sym, h_sym]`). The `[3, 3]` sentinel is only ever stored for an intra
16260+/// neighbour (excluded by [`overlappable_above`]/[`overlappable_left`]'s
16261+/// `is_inter` gate) or when `interp_fixed` is `Some` for the whole frame
16262+/// (handled here first) -- so a sentinel reaching the kernel lookup means the
16263+/// stream desynced upstream, and this refuses instead of panicking.
1609016264 fn neighbour_filter(
1609116265 interp_fixed: Option<mc::InterpFilterKind>,
1609216266 sym: [u8; 2],
16093-) -> (mc::InterpFilterKind, mc::InterpFilterKind) {
16267+) -> Result<(mc::InterpFilterKind, mc::InterpFilterKind)> {
1609416268 if let Some(kind) = interp_fixed {
16095- return (kind, kind);
16269+ return Ok((kind, kind));
16270+ }
16271+ // lane-golomb r9: this used to hand the sentinel straight to
16272+ // `from_switchable_symbol`, which PANICS on any value above 2 -- a crash
16273+ // on stream data (measured on a real 192x68 cq40 aomenc stream, where an
16274+ // inter leaf below 8x8 desyncs upstream and leaves an unrecorded filter
16275+ // behind). A decoder must refuse such a stream by name, never abort the
16276+ // process; the desync that produces the sentinel belongs to lane-intersub8.
16277+ if sym[0] > 2 || sym[1] > 2 {
16278+ return Err(unsupported(
16279+ "an OBMC neighbour whose switchable interp filter was never recorded",
16280+ ));
1609616281 }
16097- (
16282+ Ok((
1609816283 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),
1609916284 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),
16100- )
16285+ ))
1610116286 }
1610216287
1610316288 /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh
@@ -16375,7 +16560,7 @@ fn obmc_blend(
1637516560 let (h_kind, v_kind) = neighbour_filter(
1637616561 interp_fixed,
1637716562 neighbours.above_filter[mi_col + off4],
16378- );
16563+ )?;
1637916564 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
1638016565 let nb_scale = mc::scale_factor(ny.width, frame_width);
1638116566 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);
@@ -16394,7 +16579,7 @@ fn obmc_blend(
1639416579 let (h_kind, v_kind) = neighbour_filter(
1639516580 interp_fixed,
1639616581 neighbours.left_filter[mi_row + off4],
16397- );
16582+ )?;
1639816583 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
1639916584 let nb_scale = mc::scale_factor(ny.width, frame_width);
1640016585 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);
@@ -19515,21 +19700,21 @@ fn decode_inter_block(
1951519700 },
1951619701 );
1951719702 // lane-txselect: a var-tx block's deblock edges follow its own transform
19518- // units, not the block. Chroma still reads `tx_h_grid / 2` (the block's
19519- // uv transform is not split) -- a known corner-cut of this round.
19703+ // units, not the block -- for LUMA only (lane-golomb r6): the chroma
19704+ // grids keep the block's own `av1_get_max_uv_txsize`, which is what
19705+ // libaom's `get_transform_size` reads for `plane != AOM_PLANE_Y`.
1952019706 if let Some(leaves) = &vartx_leaves {
1952119707 for &(row, col, tw, th) in leaves {
19522- neighbours.fill_lf_grid_rect(
19708+ // lane-r14's RECT leaf dims through lane-golomb r6's luma-only
19709+ // writer: fill_lf_grid_rect would recompute CHROMA tx dims from
19710+ // the leaf span, but libaom's `get_transform_size` splits only for
19711+ // AOM_PLANE_Y (merge J, ledger constraint).
19712+ neighbours.fill_lf_grid_leaf_luma(
1952319713 (at_mi.0 + row, at_mi.1 + col),
1952419714 tw / MI,
1952519715 th / MI,
1952619716 tw as u8,
1952719717 th as u8,
19528- if globalmv_for_lf {
19529- -ref_frame_for_lf
19530- } else {
19531- ref_frame_for_lf
19532- },
1953319718 );
1953419719 }
1953519720 }
@@ -21244,7 +21429,18 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2124421429 // true size. Height must still match: AV1 superres never scales height
2124521430 // (r8's derivation, `mc.rs`'s own doc), and nothing in this decode path
2124621431 // has a vertical scaling pass.
21247- if reference.height != true_height {
21432+ // lane-golomb r8: the comparison is against the header's own frame
21433+ // height, NOT the mi-rounded `true_height`. libaom compares references
21434+ // on the CROPPED dimensions -- `av1_setup_scale_factors_for_frame(&sf,
21435+ // ref->y_crop_width, ref->y_crop_height, cm->width, cm->height)`
21436+ // (`av1/common/reconinter.c`), and a reference is "scaled" only when
21437+ // those differ (`av1_is_scaled`). A decoded `Picture` is cropped to
21438+ // `fw`/`fh`, so for any height that is not a multiple of 8 (68 ->
21439+ // mi_rows 18 -> `true_height` 72) this test compared 68 against 72 and
21440+ // refused every same-size reference (class av1-truesize-lane: true
21441+ // frame size vs mi-rounded). Height must still MATCH: AV1 superres
21442+ // never scales height, and no path here has a vertical scaling pass.
21443+ if reference.height != frame_height as usize {
2124821444 return Err(unsupported(
2124921445 "a reference picture whose height does not match this frame's own true size",
2125021446 ));
@@ -21684,7 +21880,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2168421880 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
2168521881 // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT
2168621882 // (libaom `ec_read_partition_impl`).
21687- if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)) == 1 {
21883+ if bump_edge32_bit(
21884+ 4,
21885+ dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)),
21886+ ) == 1 {
2168821887 PARTITION_SPLIT
2168921888 } else {
2169021889 PARTITION_HORZ
@@ -21694,7 +21893,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2169421893 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
2169521894 // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT
2169621895 // (libaom `ec_read_partition_impl`).
21697- if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)) == 1 {
21896+ if bump_edge32_bit(
21897+ 4,
21898+ dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)),
21899+ ) == 1 {
2169821900 PARTITION_SPLIT
2169921901 } else {
2170021902 PARTITION_VERT
@@ -21869,7 +22071,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2186922071 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
2187022072 // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT
2187122073 // (libaom `ec_read_partition_impl`).
21872- if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE)) == 1 {
22074+ if {
22075+ let b = dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE));
22076+ bump_edge32(b.min(1) as usize);
22077+ b
22078+ } == 1 {
2187322079 PARTITION_SPLIT
2187422080 } else {
2187522081 PARTITION_HORZ
@@ -21879,7 +22085,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2187922085 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
2188022086 // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT
2188122087 // (libaom `ec_read_partition_impl`).
21882- if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE)) == 1 {
22088+ if {
22089+ let b = dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE));
22090+ bump_edge32(b.min(1) as usize);
22091+ b
22092+ } == 1 {
2188322093 PARTITION_SPLIT
2188422094 } else {
2188522095 PARTITION_VERT
@@ -22606,55 +22816,63 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2260622816 allow_screen_content_tools,
2260722817 frame_width as usize,
2260822818 )?;
22609- decode_inter_block(
22610- &mut dec,
22611- &mut cdfs,
22612- &mut neighbours,
22613- &mut grid,
22614- sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)),
22615- BLOCK,
22616- mi_cols,
22617- mi_rows,
22618- &mut y,
22619- &mut u,
22620- &mut v,
22621- &ref_y,
22622- &ref_u,
22623- &ref_v,
22624- &ref_slots,
22625- &sign_bias_table,
22626- &global_motion,
22627- base_q_idx,
22628- TxbSet::Luma32,
22629- TxbSet::Luma32Inter,
22630- TxbSet::Chroma16,
22631- TX32,
22632- TX16,
22633- &scan32,
22634- &scan16,
22635- 3,
22636- allow_high_precision_mv,
22637- force_integer_mv,
22638- interp_fixed,
22639- enable_dual_filter,
22640- tpl_frame.as_ref(),
22641- reference_select,
22642- enable_masked_compound,
22643- enable_interintra_compound,
22644- enable_jnt_comp,
22645- order_hint_bits,
22646- order_hint,
22647- ref_order_hints,
22648- skip_mode_present,
22649- skip_mode_frame,
22650- switchable_motion_mode,
22651- allow_warped_motion,
22652- true,
22653- BLOCK,
22654- SUB,
22655- allow_screen_content_tools,
22656- frame_width as usize,
22657- )?;
22819+ if !has_rows32 {
22820+ bump_edge32(2);
22821+ }
22822+ // lane-golomb r2: at the frame edge only the first half of the
22823+ // strip is coded (libaom `decode_partition` guards the second
22824+ // with the same has_rows32 test that made this partition non-square).
22825+ if has_rows32 {
22826+ decode_inter_block(
22827+ &mut dec,
22828+ &mut cdfs,
22829+ &mut neighbours,
22830+ &mut grid,
22831+ sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)),
22832+ BLOCK,
22833+ mi_cols,
22834+ mi_rows,
22835+ &mut y,
22836+ &mut u,
22837+ &mut v,
22838+ &ref_y,
22839+ &ref_u,
22840+ &ref_v,
22841+ &ref_slots,
22842+ &sign_bias_table,
22843+ &global_motion,
22844+ base_q_idx,
22845+ TxbSet::Luma32,
22846+ TxbSet::Luma32Inter,
22847+ TxbSet::Chroma16,
22848+ TX32,
22849+ TX16,
22850+ &scan32,
22851+ &scan16,
22852+ 3,
22853+ allow_high_precision_mv,
22854+ force_integer_mv,
22855+ interp_fixed,
22856+ enable_dual_filter,
22857+ tpl_frame.as_ref(),
22858+ reference_select,
22859+ enable_masked_compound,
22860+ enable_interintra_compound,
22861+ enable_jnt_comp,
22862+ order_hint_bits,
22863+ order_hint,
22864+ ref_order_hints,
22865+ skip_mode_present,
22866+ skip_mode_frame,
22867+ switchable_motion_mode,
22868+ allow_warped_motion,
22869+ true,
22870+ BLOCK,
22871+ SUB,
22872+ allow_screen_content_tools,
22873+ frame_width as usize,
22874+ )?;
22875+ }
2265822876 }
2265922877 PARTITION_VERT => {
2266022878 // lane-rect r2: mirror of PARTITION_HORZ above with
@@ -22709,55 +22927,63 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2270922927 allow_screen_content_tools,
2271022928 frame_width as usize,
2271122929 )?;
22712- decode_inter_block(
22713- &mut dec,
22714- &mut cdfs,
22715- &mut neighbours,
22716- &mut grid,
22717- sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)),
22718- BLOCK,
22719- mi_cols,
22720- mi_rows,
22721- &mut y,
22722- &mut u,
22723- &mut v,
22724- &ref_y,
22725- &ref_u,
22726- &ref_v,
22727- &ref_slots,
22728- &sign_bias_table,
22729- &global_motion,
22730- base_q_idx,
22731- TxbSet::Luma32,
22732- TxbSet::Luma32Inter,
22733- TxbSet::Chroma16,
22734- TX32,
22735- TX16,
22736- &scan32,
22737- &scan16,
22738- 3,
22739- allow_high_precision_mv,
22740- force_integer_mv,
22741- interp_fixed,
22742- enable_dual_filter,
22743- tpl_frame.as_ref(),
22744- reference_select,
22745- enable_masked_compound,
22746- enable_interintra_compound,
22747- enable_jnt_comp,
22748- order_hint_bits,
22749- order_hint,
22750- ref_order_hints,
22751- skip_mode_present,
22752- skip_mode_frame,
22753- switchable_motion_mode,
22754- allow_warped_motion,
22755- true,
22756- SUB,
22757- BLOCK,
22758- allow_screen_content_tools,
22759- frame_width as usize,
22760- )?;
22930+ if !has_cols32 {
22931+ bump_edge32(3);
22932+ }
22933+ // lane-golomb r2: at the frame edge only the first half of the
22934+ // strip is coded (libaom `decode_partition` guards the second
22935+ // with the same has_cols32 test that made this partition non-square).
22936+ if has_cols32 {
22937+ decode_inter_block(
22938+ &mut dec,
22939+ &mut cdfs,
22940+ &mut neighbours,
22941+ &mut grid,
22942+ sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)),
22943+ BLOCK,
22944+ mi_cols,
22945+ mi_rows,
22946+ &mut y,
22947+ &mut u,
22948+ &mut v,
22949+ &ref_y,
22950+ &ref_u,
22951+ &ref_v,
22952+ &ref_slots,
22953+ &sign_bias_table,
22954+ &global_motion,
22955+ base_q_idx,
22956+ TxbSet::Luma32,
22957+ TxbSet::Luma32Inter,
22958+ TxbSet::Chroma16,
22959+ TX32,
22960+ TX16,
22961+ &scan32,
22962+ &scan16,
22963+ 3,
22964+ allow_high_precision_mv,
22965+ force_integer_mv,
22966+ interp_fixed,
22967+ enable_dual_filter,
22968+ tpl_frame.as_ref(),
22969+ reference_select,
22970+ enable_masked_compound,
22971+ enable_interintra_compound,
22972+ enable_jnt_comp,
22973+ order_hint_bits,
22974+ order_hint,
22975+ ref_order_hints,
22976+ skip_mode_present,
22977+ skip_mode_frame,
22978+ switchable_motion_mode,
22979+ allow_warped_motion,
22980+ true,
22981+ SUB,
22982+ BLOCK,
22983+ allow_screen_content_tools,
22984+ frame_width as usize,
22985+ )?;
22986+ }
2276122987 }
2276222988 PARTITION_HORZ_A => {
2276322989 // lane-partab r1: two 16x16 squares on top + a true
@@ -23337,7 +23563,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2333723563 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
2333823564 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);
2333923565 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
23340- apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid);
23566+ apply_loop_restoration(
23567+ &mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid,
23568+ (frame_width as usize, frame_height as usize),
23569+ );
2334123570
2334223571 let motion_field = build_motion_field(
2334323572 &grid,
@@ -23410,6 +23639,36 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2341023639 #[cfg(test)]
2341123640 mod tests {
2341223641
23642+ /// lane-golomb r7: [`reduce_inherited_chroma_tx_type`] must reproduce
23643+ /// `av1_ext_tx_used[av1_get_ext_tx_set_type(uv_tx, 1, reduced)]`
23644+ /// (libaom `av1/common/blockd.h:1036`/`1097`) exactly -- the g35 residue
23645+ /// was one 64x64 inter superblock whose 32x32 chroma units are
23646+ /// `EXT_TX_SET_DCT_IDTX`, where IDTX survives and we forced `DCT_DCT`.
23647+ #[test]
23648+ fn an_inter_chroma_transform_narrows_its_inherited_tx_type_to_its_own_set() {
23649+ use TxType::*;
23650+ // EXT_TX_SET_DCTONLY: `tx_size_sqr_up > TX_32X32`.
23651+ set_inter_tx_mode(true, false, true);
23652+ assert_eq!(reduce_inherited_chroma_tx_type(Idtx, 64, 64), DctDct);
23653+ // EXT_TX_SET_DCT_IDTX at exactly TX_32X32 -- the residue's case.
23654+ assert_eq!(reduce_inherited_chroma_tx_type(Idtx, 32, 32), Idtx);
23655+ assert_eq!(reduce_inherited_chroma_tx_type(AdstAdst, 32, 32), DctDct);
23656+ // EXT_TX_SET_DTT9_IDTX_1DDCT at `tx_size_sqr == TX_16X16`: the four
23657+ // 1D ADST/FLIPADST types (TX_TYPES 12..15) drop out, the rest stay.
23658+ assert_eq!(reduce_inherited_chroma_tx_type(HDct, 16, 16), HDct);
23659+ assert_eq!(reduce_inherited_chroma_tx_type(FlipAdstAdst, 16, 16), FlipAdstAdst);
23660+ assert_eq!(reduce_inherited_chroma_tx_type(HAdst, 16, 16), DctDct);
23661+ // EXT_TX_SET_ALL16 below that (`tx_size_sqr < TX_16X16`, so a 16x8
23662+ // chroma unit too).
23663+ assert_eq!(reduce_inherited_chroma_tx_type(HAdst, 16, 8), HAdst);
23664+ assert_eq!(reduce_inherited_chroma_tx_type(VFlipAdst, 8, 8), VFlipAdst);
23665+ // `reduced_tx_set` collapses every inter set to DCT_IDTX.
23666+ set_inter_tx_mode(true, true, true);
23667+ assert_eq!(reduce_inherited_chroma_tx_type(Idtx, 8, 8), Idtx);
23668+ assert_eq!(reduce_inherited_chroma_tx_type(HAdst, 8, 8), DctDct);
23669+ set_inter_tx_mode(true, false, true);
23670+ }
23671+
2341323672 /// lane-fistrip r1 (class `enumerate-the-table-domain`): every block
2341423673 /// shape this decoder can hand [`filter_intra_size_class_rect`], against
2341523674 /// `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 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
3839 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
3940 "a 32x32 partition type this decoder does not code (value={part32})",
crates/ec-av1/src/stream.rsmodified+360 -0
@@ -20517,6 +20517,366 @@ mod tests {
2051720517 );
2051820518 }
2051920519
20520+ /// lane-golomb r2 gate: a 32x32-level block that STRADDLES the frame edge
20521+ /// and whose partition is the gathered edge bit's `PARTITION_HORZ` (bottom
20522+ /// edge) / `PARTITION_VERT` (right edge). Since r1 that bit can name
20523+ /// HORZ/VERT instead of always inferring SPLIT, so the second 32x16/16x32
20524+ /// half is out of frame and must NOT be decoded (libaom `decode_partition`:
20525+ /// `case PARTITION_HORZ: decode_block(top); if (has_rows) decode_block(bottom)`).
20526+ /// The AB and 1:4 arms need no such guard: at an edge libaom's
20527+ /// `ec_read_partition_impl` can only yield HORZ/VERT/SPLIT, so those arms
20528+ /// are unreachable there.
20529+ ///
20530+ /// Geometry: 192x80 (mi_rows=20 -- the second SB row is 16 px tall, so its
20531+ /// 32-level blocks at y=64 have `has_rows32 == false`) and 80x192 for the
20532+ /// right edge. Natural content (`testsrc2`); `smptebars`-style screen
20533+ /// content trips the palette/screen-content refusal before the edge is
20534+ /// reached. cq sweep, 8-bit and 10-bit, plus a 5-frame inter arm.
20535+ /// Counters are sampled per attempt and summed only over attempts that
20536+ /// decoded AND pixel-compared (class `counter-from-refused-stream`).
20537+ #[test]
20538+ fn a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact() {
20539+ edge32_gate(
20540+ "a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact",
20541+ false,
20542+ );
20543+ }
20544+
20545+ /// lane-golomb r2 OPEN DEFECT, pinned as a runnable test: with the 16-px
20546+ /// straddling band left FLAT the encoder answers the 32-level edge bit
20547+ /// with HORZ (`edge32=[2, 0, 2, 0]` on 192x80 cq40 8-bit), the guard added
20548+ /// this round keeps the stream in entropy sync -- every pixel outside the
20549+ /// two edge strips matches ffmpeg -- but the strips themselves
20550+ /// reconstruct wrong: `plane Y: 1081 pixels differ, first at row 62 col
20551+ /// 128`, diffs confined to rows 62..79 over ~64 columns (exactly the two
20552+ /// 32x16 strips plus the deblock bleed above them). That is a
20553+ /// reconstruction defect inside the strip (prediction/availability), not
20554+ /// the partition guard. `#[ignore]` so the suite stays green; run it with
20555+ /// `cargo test -p ec-av1 --lib -- --ignored a_32x32_frame_edge_rect_partition_with_a_flat`.
20556+ #[test]
20557+ #[ignore = "open r2 defect: the 32-level edge HORZ strip reconstructs wrong pixels"]
20558+ fn a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact() {
20559+ edge32_gate(
20560+ "a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact",
20561+ true,
20562+ );
20563+ }
20564+
20565+ /// lane-golomb r9 OPEN DEFECT, pinned as a runnable test: a frame whose
20566+ /// height (192x68) or width (68x192) is not a multiple of 8 leaves a 4-px
20567+ /// straddling band inside the mi-rounded plane, and every INTER frame's
20568+ /// output is +-1 wrong across that band and the columns/rows next to it
20569+ /// (`68x192 cq35 8-bit: frame 1 plane Y: 145 pixels differ, first at row 0
20570+ /// col 64`, mass in columns 64..67). r9 bisected it stage by stage against
20571+ /// the instrumented aomdec on that exact stream:
20572+ /// * `EC_AV1_PREFILT_DUMP` frame 1 is BYTE-IDENTICAL over the cropped
20573+ /// 68 columns -- reconstruction and inter prediction are exact, so the
20574+ /// charter's "MC reads past the crop" hypothesis is refuted a second time.
20575+ /// * `EC_AV1_POSTDEBLOCK_DUMP` with `EC_AV1_DEBUG_SKIP_CDEF=1` also matches
20576+ /// aomdec's own post-deblock dump (which is 72 columns wide, i.e. it
20577+ /// exposes the straddling band) -- the deblock, including its
20578+ /// `frame_width` clip, is correct.
20579+ /// * The divergence therefore enters in CDEF, at the last 8x8 CDEF block
20580+ /// column/row, which is the one that straddles the crop edge.
20581+ /// `#[ignore]` so the suite stays green; run it with
20582+ /// `cargo test -p ec-av1 --lib -- --ignored a_frame_edge_straddling_band`.
20583+ #[test]
20584+ #[ignore = "open r9 defect: CDEF at the last straddling 8x8 block column/row"]
20585+ fn a_frame_edge_straddling_band_decodes_pixel_exact() {
20586+ edge32_gate(
20587+ "a_frame_edge_straddling_band_decodes_pixel_exact",
20588+ false,
20589+ );
20590+ }
20591+
20592+ fn edge32_gate(name: &str, flat_band: bool) {
20593+ let NAME = name;
20594+ let _gate_lock = lock_gate_counters();
20595+ if !have_ffmpeg() {
20596+ eprintln!("SKIP {NAME}: no ffmpeg");
20597+ return;
20598+ }
20599+ if !have_aomenc() {
20600+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
20601+ return;
20602+ }
20603+ // (width, height, frames, ten_bit)
20604+ let mut arms: Vec<(usize, usize, usize, bool)> = Vec::new();
20605+ for &(w, h) in &[(192usize, 80usize), (80usize, 192usize)] {
20606+ arms.push((w, h, 1, false));
20607+ arms.push((w, h, 1, true));
20608+ }
20609+ // The inter arm: >= 4 frames so the 32-level edge path in the INTER
20610+ // tile walk is exercised too.
20611+ arms.push((192, 80, 5, false));
20612+ // lane-golomb r9: the straddling-band arms, only under the ignored
20613+ // `a_frame_edge_straddling_band_decodes_pixel_exact` name (they are
20614+ // RED -- see that test's own comment for the stage bisection). Naming
20615+ // them here rather than in a second copy of this gate keeps the
20616+ // recipe, the counters and the refusal handling identical.
20617+ if name == "a_frame_edge_straddling_band_decodes_pixel_exact" {
20618+ arms.clear();
20619+ arms.push((192, 68, 5, false));
20620+ arms.push((192, 68, 5, true));
20621+ arms.push((68, 192, 5, false));
20622+ arms.push((68, 192, 5, true));
20623+ }
20624+ // lane-golomb r8 MEASURED, arm STILL NOT added (every cq level is
20625+ // vacuous, panicking or red -- each measured this round with
20626+ // `arms.push((192, 68, 5, false))`, log
20627+ // `$HOME/.cache/golomb-gate-r8{b,e,f,g}.log`):
20628+ // * the r7 blocker IS fixed -- no attempt refuses "a reference
20629+ // picture whose height does not match this frame's own true
20630+ // size" any more (`decode.rs`'s comparison now uses the header's
20631+ // frame height, per libaom's crop-dimension reference test).
20632+ // * cq35 now refuses LATER, by another lane's name: "an inter
20633+ // SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B)" -- so the
20634+ // arm compares nothing (class `counter-from-refused-stream`).
20635+ // * cq40 PANICS in `decode_inter_block8`
20636+ // (`from_switchable_symbol` handed a 4th symbol, `mc.rs:203`) =
20637+ // lane-sub8's own open below-8x8 desync; a panic cannot be
20638+ // tolerated as a named refusal.
20639+ // * cq59 8-bit is RED: `frame 1 plane Y: 217 pixels differ, first
20640+ // at row 60 col 170 (ours 172 vs ffmpeg 173)`, and the cq35
20641+ // 10-bit twin is RED at `row 56 col 48 (ours 530 vs ffmpeg
20642+ // 531)`. Both are +-1 bands in rows 56..63, i.e. the deblock/CDEF
20643+ // bleed ABOVE the 4-px straddling row band (64..67) -- the same
20644+ // shape as the `(68, 192, 5, false)` column defect below, so the
20645+ // two are very likely ONE straddling-band reconstruction defect.
20646+ // lane-golomb r7 MEASURED, arm NOT added (it would be vacuous or red):
20647+ // a 68-px axis leaves the last superblock straddling by 4 px, the
20648+ // shape `read_var_tx_size`'s `blk_row >= max_h_mi || blk_col >=
20649+ // max_w_mi` early return exists for. With
20650+ // `arms.push((192, 68, 5, false))` all EIGHT cq attempts refuse by
20651+ // name -- "a reference picture whose height does not match this
20652+ // frame's own true size" -- so the arm compares nothing (class
20653+ // `counter-from-refused-stream`). With
20654+ // `arms.push((68, 192, 5, false))` the gate goes RED on a real,
20655+ // separate defect: `68x192 cq35 frames=5 10bit=false frame 1 plane Y:
20656+ // 141 pixels differ, first at row 0 col 64 (ours 167 vs ffmpeg 166)
20657+ // [edge32=[0,34,0,0,1,17,0,1]]` -- LUMA, inside the 4-px straddling
20658+ // COLUMN. Both are unrelated to this round's chroma tx_type fix.
20659+ let cqs: [u32; 8] = [35, 40, 45, 50, 55, 57, 59, 61];
20660+ let mut totals = [0usize; 8];
20661+ let mut compared = 0usize;
20662+ let mut refusals: Vec<String> = Vec::new();
20663+ for &(width, height, frame_count, ten_bit) in &arms {
20664+ for &cq in &cqs {
20665+ let duration = frame_count as f64 / 25.0;
20666+ // `noise` (explicit seed) both defeats aomenc's
20667+ // screen-content detection -- which otherwise refuses every
20668+ // attempt at "a HORZ/VERT intra strip in a screen-content
20669+ // frame" -- and keeps the RD search off flat NONE blocks.
20670+ // Natural content over the whole superblock-aligned area,
20671+ // with the 16-px straddling band left FLAT (`pad`): with
20672+ // detail in that band aomenc always answers the edge bit with
20673+ // SPLIT (measured: 178 edge bits, 178 of them SPLIT, over a
20674+ // cq 35..61 sweep), so the HORZ/VERT arm this round guards
20675+ // never fired. `noise` on top keeps screen-content detection
20676+ // (and its palette-strip refusal) off.
20677+ let (cw, ch) = (
20678+ if flat_band && width % 64 != 0 { width - 16 } else { width },
20679+ if flat_band && height % 64 != 0 { height - 16 } else { height },
20680+ );
20681+ let pad = if flat_band {
20682+ format!("pad={width}:{height}:0:0:gray,")
20683+ } else {
20684+ String::new()
20685+ };
20686+ let source = format!(
20687+ "testsrc2=size={cw}x{ch}:duration={duration}:rate=25,\
20688+ {pad}noise=alls=6:allf=t+u:all_seed={cq}"
20689+ );
20690+ let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" };
20691+ let y4m = Command::new("ffmpeg")
20692+ .args([
20693+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", pix, "-strict",
20694+ "-1", "-t", &format!("{duration}"), "-f", "yuv4mpegpipe", "-",
20695+ ])
20696+ .stdin(Stdio::null())
20697+ .stdout(Stdio::piped())
20698+ .stderr(Stdio::piped())
20699+ .output()
20700+ .expect("ffmpeg failed to run");
20701+ assert!(
20702+ y4m.status.success(),
20703+ "{NAME}: ffmpeg fixture: {}",
20704+ String::from_utf8_lossy(&y4m.stderr)
20705+ );
20706+ let cq_arg = format!("--cq-level={cq}");
20707+ let mut args: Vec<&str> = vec![
20708+ "--codec=av1",
20709+ "--passes=1",
20710+ "--end-usage=q",
20711+ &cq_arg,
20712+ "--cpu-used=0",
20713+ "--threads=1",
20714+ "--row-mt=0",
20715+ "--sb-size=64",
20716+ "--enable-restoration=0",
20717+ "--enable-palette=0",
20718+ "--deltaq-mode=0",
20719+ "--enable-intrabc=0",
20720+ // Per-arm overrides go LAST (aomenc keeps the last
20721+ // occurrence of a repeated --enable-* flag).
20722+ "--enable-rect-partitions=1",
20723+ "--enable-ab-partitions=0",
20724+ "--enable-1to4-partitions=0",
20725+ // 32, not the charter's 8: at 8 the sub-16 AB and
20726+ // split-transform strip arms (still refused by name here)
20727+ // fire before the 32-level edge is reached and EVERY
20728+ // attempt refuses (measured). At 32 the edge block cannot
20729+ // split, so aomenc is forced onto the gathered edge bit's
20730+ // HORZ/VERT -- exactly the arm this round guards.
20731+ "--min-partition-size=32",
20732+ "--tune-content=film",
20733+ "--max-partition-size=64",
20734+ ];
20735+ if ten_bit {
20736+ args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);
20737+ }
20738+ args.extend_from_slice(&["--obu", "-o", "-", "-"]);
20739+ let mut child = Command::new(aomenc_path())
20740+ .args(&args)
20741+ .stdin(Stdio::piped())
20742+ .stdout(Stdio::piped())
20743+ .stderr(Stdio::piped())
20744+ .spawn()
20745+ .expect("aomenc failed to start");
20746+ child
20747+ .stdin
20748+ .take()
20749+ .expect("aomenc stdin")
20750+ .write_all(&y4m.stdout)
20751+ .expect("writing y4m to aomenc");
20752+ let out = child.wait_with_output().expect("aomenc failed to run");
20753+ assert!(
20754+ out.status.success(),
20755+ "{NAME}: aomenc refused the fixture: {}",
20756+ String::from_utf8_lossy(&out.stderr)
20757+ );
20758+ let stream = out.stdout;
20759+ if ten_bit {
20760+ assert_eq!(
20761+ parsed_bit_depth(&stream),
20762+ 10,
20763+ "{NAME}: aomenc did not write a 10-bit sequence header"
20764+ );
20765+ }
20766+ let tag = format!("{width}x{height} cq{cq} frames={frame_count} 10bit={ten_bit}");
20767+ let before = crate::decode::edge32_hits();
20768+ // lane-golomb r8: name the attempt BEFORE decoding it -- a
20769+ // desync surfaces as a panic deep in mc.rs with no arm in the
20770+ // message, and r8 spent a run bisecting arms by hand.
20771+ if std::env::var_os("EC_GATE_VERBOSE").is_some() {
20772+ eprintln!("{NAME}: attempting {tag}");
20773+ }
20774+ let decoded = match decode_stream(&stream) {
20775+ Ok(frames) => frames,
20776+ Err(e) => {
20777+ let msg = e.to_string();
20778+ assert!(
20779+ msg.contains("unsupported"),
20780+ "{NAME} failed outright, not a named refusal ({tag}): {msg}"
20781+ );
20782+ refusals.push(format!("{tag}: {msg}"));
20783+ continue;
20784+ }
20785+ };
20786+ let after = crate::decode::edge32_hits();
20787+ let delta: Vec<usize> =
20788+ (0..8).map(|i| after[i] - before[i]).collect();
20789+ let reference = if ten_bit {
20790+ ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len())
20791+ } else {
20792+ ffmpeg_decode_sequence(&stream, width, height, decoded.len())
20793+ };
20794+ assert_eq!(
20795+ decoded.len(),
20796+ reference.len(),
20797+ "{NAME}: {tag}: shown-frame count vs ffmpeg"
20798+ );
20799+ for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() {
20800+ for (plane, a, b, w) in [
20801+ ("Y", &ours.y, &theirs.y, width),
20802+ ("U", &ours.u, &theirs.u, width / 2),
20803+ ("V", &ours.v, &theirs.v, width / 2),
20804+ ] {
20805+ if let Some(d) = a.iter().zip(b.iter()).position(|(x, y)| x != y) {
20806+ let n = a.iter().zip(b.iter()).filter(|(x, y)| x != y).count();
20807+ if std::env::var_os("EC_EDGE32_ROWS").is_some() {
20808+ let mut per_row: std::collections::BTreeMap<usize, usize> =
20809+ Default::default();
20810+ for (k, (x, y)) in a.iter().zip(b.iter()).enumerate() {
20811+ if x != y {
20812+ *per_row.entry(k / w).or_default() += 1;
20813+ }
20814+ }
20815+ eprintln!("{NAME}: {tag} plane {plane} diffs per row: {per_row:?}");
20816+ }
20817+ panic!(
20818+ "{NAME}: {tag} frame {i} plane {plane}: {n} pixels differ, first \
20819+ at row {} col {} (ours {} vs ffmpeg {}) [edge32={delta:?}]",
20820+ d / w,
20821+ d % w,
20822+ a[d],
20823+ b[d]
20824+ );
20825+ }
20826+ }
20827+ }
20828+ compared += 1;
20829+ for i in 0..8 {
20830+ totals[i] += delta[i];
20831+ }
20832+ }
20833+ }
20834+ assert!(
20835+ compared > 0,
20836+ "{NAME}: every attempt hit a named refusal:\n{}",
20837+ refusals.join("\n")
20838+ );
20839+ assert!(
20840+ totals[0] + totals[1] + totals[4] + totals[5] > 0,
20841+ "{NAME}: no frame-edge partition bit was read at all over \
20842+ {compared} compared attempts -- the gate proved nothing"
20843+ );
20844+ // lane-golomb r3: the flat-band arm's ASSERT moved one level up. Until
20845+ // r3 the last superblock row was reached through a 32-level edge bit
20846+ // only because our own out-of-frame transform units had desynced the
20847+ // stream; with that fixed, real aomenc answers a bottom-edge
20848+ // superblock with the 64-level `PARTITION_HORZ` (and a right-edge one
20849+ // with `PARTITION_VERT`) and the 32-level slots stay 0 on this
20850+ // content. Slots 6/7 are the strips actually decoded at the edge.
20851+ assert!(
20852+ !flat_band || totals[6] > 0,
20853+ "{NAME}: no 64x32 bottom-edge HORZ strip was decoded \
20854+ (edge32={totals:?}, {compared} compared attempts)"
20855+ );
20856+ assert!(
20857+ !flat_band || totals[7] > 0,
20858+ "{NAME}: no 32x64 right-edge VERT strip was decoded \
20859+ (edge32={totals:?}, {compared} compared attempts)"
20860+ );
20861+ eprintln!(
20862+ "{NAME}: {compared} pixel-exact attempts, 32-level edge bits \
20863+ [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, 64-level edge bits \
20864+ [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, {} named refusals",
20865+ totals[0],
20866+ totals[1],
20867+ totals[2],
20868+ totals[3],
20869+ totals[4],
20870+ totals[5],
20871+ totals[6],
20872+ totals[7],
20873+ refusals.len()
20874+ );
20875+ for r in &refusals {
20876+ eprintln!("{NAME} refusal: {r}");
20877+ }
20878+ }
20879+
2052020880 /// lane-sqchroma r1 gate: a plain SQUARE-partition intra key frame with
2052120881 /// REAL chroma (no `hue=s=0` guard) and aomenc's tx-size search left at
2052220882 /// 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).