forge
Explore
Log in

Don't you dare go Hollow

Merge lane-golomb 173b793 into lane-sb128c: per-leaf lf grid write is luma-only (fill_lf_grid_leaf_luma), kept with the skip-inter internal-edge suppression and the (tw,th) leaf tuple

Browse files at this commit

319109828e9d1d3370c60ad00410c705b2b8df10Ahmet Kaan GümüşParent: 5810c77414fb70

13 changed files +1696 -143

crates/ec-av1/src/decode.rsmodified+394 -143
@@ -2130,6 +2130,44 @@ pub(crate) fn sb_rect_hits() -> usize {
2130 SB_RECT_HITS.with(|c| c.get())2130 SB_RECT_HITS.with(|c| c.get())
2131 }2131 }
2132 2132
2133+// lane-golomb r2: the 32x32-level FRAME-EDGE partition. Slot 0/1 = the
2134+// gathered edge bit read as 0 (HORZ/VERT) / 1 (SPLIT); slot 2 = a 32-level
2135+// PARTITION_HORZ decoded with `has_rows32 == false` (only the top 32x16 half
2136+// is coded), slot 3 = a PARTITION_VERT with `has_cols32 == false`. Both tile
2137+// paths (intra and inter) feed the same counter.
2138+//
2139+// lane-golomb r3: slots 4..7 are the same four facts one level up, at the
2140+// SUPERBLOCK (64x64) edge -- 4/5 = the gathered 64-level bit read as
2141+// HORZ/VERT / SPLIT, 6 = a 64x32 bottom-edge strip decoded with
2142+// `has_rows == false`, 7 = a 32x64 right-edge strip. Real aomenc answers a
2143+// bottom-edge superblock with the 64-level HORZ (measured: 192x80 flat-band,
2144+// every SB of the last row), so the 32-level slots stay 0 on that content and
2145+// only these prove the arm fired.
2146+thread_local! {
2147+ static EDGE32_HITS: std::cell::Cell<[usize; 8]> =
2148+ const { std::cell::Cell::new([0; 8]) };
2149+}
2150+
2151+/// Current value of [`EDGE32_HITS`].
2152+pub(crate) fn edge32_hits() -> [usize; 8] {
2153+ EDGE32_HITS.with(|c| c.get())
2154+}
2155+
2156+/// [`bump_edge32`] of `base + bit`, returning the bit -- the gathered edge
2157+/// reads are `if`-conditions, so the counter has to ride the expression.
2158+fn bump_edge32_bit(base: usize, bit: usize) -> usize {
2159+ bump_edge32(base + bit.min(1));
2160+ bit
2161+}
2162+
2163+fn bump_edge32(slot: usize) {
2164+ EDGE32_HITS.with(|c| {
2165+ let mut h = c.get();
2166+ h[slot] += 1;
2167+ c.set(h)
2168+ });
2169+}
2170+
2133 // lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/2171 // lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/
2134 // `_B`/`VERT_A`/`_B` at 64x64 -- two 32x32 squares plus one 64x32/32x642172 // `_B`/`VERT_A`/`_B` at 64x64 -- two 32x32 squares plus one 64x32/32x64
2135 // strip) fired. Real aomenc picks these at 64 even with2173 // strip) fired. Real aomenc picks these at 64 even with
@@ -4278,6 +4316,36 @@ impl Neighbours {
4278 }4316 }
4279 }4317 }
4280 4318
4319+ /// One var-tx / split-tx LEAF's own LUMA transform dims over its mi span.
4320+ /// libaom `get_transform_size` (av1_loopfilter.c:207) applies the split
4321+ /// override only `if ((plane == AOM_PLANE_Y) && ...)` -- chroma keeps
4322+ /// `av1_get_max_uv_txsize(mbmi->bsize)`, the whole BLOCK's uv transform.
4323+ /// Routing a leaf through [`Self::fill_lf_grid_rect`] recomputed the uv
4324+ /// dims from the LEAF span and so invented chroma transform edges the
4325+ /// deblocker then filtered (lane-golomb r6). `ref_grid`/`delta_lf_grid`
4326+ /// are already correct from the block's own fill over the same span.
4327+ fn fill_lf_grid_leaf_luma(
4328+ &mut self,
4329+ at_mi: (usize, usize),
4330+ w_mi: usize,
4331+ h_mi: usize,
4332+ tx_px: u8,
4333+ tx_h_px: u8,
4334+ ) {
4335+ let (mi_r, mi_c) = at_mi;
4336+ for rr in 0..h_mi {
4337+ for cc in 0..w_mi {
4338+ let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc);
4339+ if let Some(cell) = self.tx_grid.get_mut(idx) {
4340+ *cell = tx_px;
4341+ }
4342+ if let Some(cell) = self.tx_h_grid.get_mut(idx) {
4343+ *cell = tx_h_px;
4344+ }
4345+ }
4346+ }
4347+ }
4348+
4281 /// Marks every 4x4 mi cell a just-decoded coded block covers with its4349 /// Marks every 4x4 mi cell a just-decoded coded block covers with its
4282 /// `skip` flag -- `at_mi`/`side_mi` are the block's own position and4350 /// `skip` flag -- `at_mi`/`side_mi` are the block's own position and
4283 /// width/height in 4x4 mode-info units (mirroring [`Self::record_mi`]'s4351 /// width/height in 4x4 mode-info units (mirroring [`Self::record_mi`]'s
@@ -8915,11 +8983,20 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize,
8915 8983
8916 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {8984 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {
8917 use std::io::Write;8985 use std::io::Write;
8918- // lane-sb128c r4: decode-order index like `EC_AV1_PREFILT_DUMP`'s -- a8986+ // lane-golomb r6: one file per DECODE-order picture, like aomdec's own
8919- // fixed `.f0` overwrote every frame, so the only comparable stage dump8987+ // `ec_dump16` static index -- a single `.f0` overwritten every frame made
8920- // was the last decoded picture (aomdec's own rung indexes its files).8988+ // the post-deblock stage uncomparable across a sequence.
8921- static STAGE_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);8989+ thread_local! {
8922- let idx = STAGE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);8990+ static STAGE_IDX: std::cell::RefCell<std::collections::HashMap<String, usize>> =
8991+ std::cell::RefCell::new(std::collections::HashMap::new());
8992+ }
8993+ let idx = STAGE_IDX.with(|m| {
8994+ let mut m = m.borrow_mut();
8995+ let e = m.entry(var.to_string()).or_insert(0);
8996+ let i = *e;
8997+ *e += 1;
8998+ i
8999+ });
8923 if let Ok(path) = std::env::var(var)9000 if let Ok(path) = std::env::var(var)
8924 && let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}"))9001 && let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}"))
8925 {9002 {
@@ -11691,7 +11768,7 @@ fn read_block_tx_size(
11691 let mut leaves = Vec::new();11768 let mut leaves = Vec::new();
11692 for row in (0..side / MI).step_by(step) {11769 for row in (0..side / MI).step_by(step) {
11693 for col in (0..side / MI).step_by(step) {11770 for col in (0..side / MI).step_by(step) {
11694- leaves.push((row, col, 64));11771+ leaves.push((row, col, 64, 64));
11695 }11772 }
11696 }11773 }
11697 return Ok((64, Some(leaves)));11774 return Ok((64, Some(leaves)));
@@ -12026,8 +12103,8 @@ fn read_inter_plane_rect(
12026 // `av1_get_ext_tx_set_type`'s DCT-only clamp is on `tx_size_sqr_up`, i.e.12103 // `av1_get_ext_tx_set_type`'s DCT-only clamp is on `tx_size_sqr_up`, i.e.
12027 // the *longer* side of this rect transform.12104 // the *longer* side of this rect transform.
12028 let default_tx_type = match inherited_luma_tx_type {12105 let default_tx_type = match inherited_luma_tx_type {
12029- Some(t) if w.max(h) < 32 => t,12106+ Some(t) => reduce_inherited_chroma_tx_type(t, w, h),
12030- _ => TxType::DctDct,12107+ None => TxType::DctDct,
12031 };12108 };
12032 // lane-r14 r2: a 64-length axis codes only its low 32 coefficients12109 // lane-r14 r2: a 64-length axis codes only its low 32 coefficients
12033 // (`av1_get_max_eob`), so the coded unit is the `min(w,32) x min(h,32)`12110 // (`av1_get_max_eob`), so the coded unit is the `min(w,32) x min(h,32)`
@@ -12194,6 +12271,45 @@ fn read_inter_luma8(
12194 12271
12195 /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its12272 /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its
12196 /// coefficient tables from -- the inter counterpart of [`txbset_for`].12273 /// coefficient tables from -- the inter counterpart of [`txbset_for`].
12274+/// `av1_get_tx_type`'s chroma tail (libaom `av1/common/blockd.h:1291-1305`):
12275+/// an inter block's chroma transform inherits the *colocated luma* unit's
12276+/// coded `tx_type`, then drops back to `DCT_DCT` unless that type is a member
12277+/// of the extended set the CHROMA transform size selects
12278+/// (`av1_ext_tx_used[av1_get_ext_tx_set_type(uv_tx, 1, reduced)][tx_type]`,
12279+/// `blockd.h:1036`/`1097`). lane-golomb r7: we used to force `DCT_DCT` at
12280+/// every chroma side >= 32, but `av1_get_ext_tx_set_type`'s DCT-only rung is
12281+/// `tx_size_sqr_up > TX_32X32`; at exactly TX_32X32 an inter block reads
12282+/// `EXT_TX_SET_DCT_IDTX`, so a 64x64 inter block whose first luma leaf coded
12283+/// `IDTX` inherits IDTX on its 32x32 chroma units. `IDTX` and `DCT_DCT` are
12284+/// both `TX_CLASS_2D`, so that mistake left the entropy stream perfectly in
12285+/// sync and only corrupted the inverse transform (one 64x64 superblock of
12286+/// high-frequency chroma noise, luma bit-exact).
12287+fn reduce_inherited_chroma_tx_type(t: TxType, w: usize, h: usize) -> TxType {
12288+ use TxType::*;
12289+ let sqr_up = w.max(h);
12290+ let sqr = w.min(h);
12291+ let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
12292+ // `av1_get_ext_tx_set_type(tx_size, is_inter = 1, reduced)`.
12293+ let allowed: &[TxType] = if sqr_up > 32 {
12294+ // EXT_TX_SET_DCTONLY
12295+ &[DctDct]
12296+ } else if sqr_up == 32 || reduced {
12297+ // EXT_TX_SET_DCT_IDTX
12298+ &[DctDct, Idtx]
12299+ } else if sqr == 16 {
12300+ // EXT_TX_SET_DTT9_IDTX_1DDCT -- TX_TYPES 0..=11, i.e. everything but
12301+ // the four 1D ADST/FLIPADST types.
12302+ &[
12303+ DctDct, AdstDct, DctAdst, AdstAdst, FlipAdstDct, DctFlipAdst, FlipAdstFlipAdst,
12304+ AdstFlipAdst, FlipAdstAdst, Idtx, VDct, HDct,
12305+ ]
12306+ } else {
12307+ // EXT_TX_SET_ALL16
12308+ return t;
12309+ };
12310+ if allowed.contains(&t) { t } else { DctDct }
12311+}
12312+
12197 fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {12313 fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet {
12198 match tx_px {12314 match tx_px {
12199 // lane-sb128c r1: a 128x128 inter block's own luma unit12315 // lane-sb128c r1: a 128x128 inter block's own luma unit
@@ -12705,6 +12821,18 @@ fn deblock_plane(
12705 // last coded mi column's horizontal edges were filtered when libaom's12821 // last coded mi column's horizontal edges were filtered when libaom's
12706 // real output leaves them untouched (r6's post-deblock diff, 37 px, all12822 // real output leaves them untouched (r6's post-deblock diff, 37 px, all
12707 // in columns 44-47); clipping here closes it (3/3 frames pixel-exact).12823 // in columns 44-47); clipping here closes it (3/3 frames pixel-exact).
12824+ // lane-golomb r9: the bound is the MI-ROUNDED frame, not the coded
12825+ // frame. libaom's `av1_filter_block_plane_vert/horz` walk the superblock
12826+ // and stop at `cm->mi_params.mi_cols`/`mi_rows`, which
12827+ // `av1_set_mb_mi` derives from `ALIGN_POWER_OF_TWO(width, 3)` -- the
12828+ // 8-pixel-aligned frame, i.e. a 68-wide frame is filtered out to column
12829+ // 72 and the vertical edge AT x=68 is a real edge that rewrites the
12830+ // in-crop columns 64..67. Clipping at `frame_width` skipped it, which is
12831+ // the +-1 straddling-band defect (68x192 cq35, frame 1, 141 luma pixels
12832+ // all in columns 64..67; frame 0 survived because that edge carried no
12833+ // filter level there). r7's superres measurement is preserved: its frame
12834+ // was already 8-aligned, so this bound equals `frame_width` there and
12835+ // still excludes the superblock padding up to `true_width`.
12708 let (cw, ch) = if chroma {12836 let (cw, ch) = if chroma {
12709 (frame_width.div_ceil(2), frame_height.div_ceil(2))12837 (frame_width.div_ceil(2), frame_height.div_ceil(2))
12710 } else {12838 } else {
@@ -12715,11 +12843,17 @@ fn deblock_plane(
12715 plane.true_height.min(ch),12843 plane.true_height.min(ch),
12716 plane.width,12844 plane.width,
12717 );12845 );
12846+ if std::env::var_os("EC_AV1_DEBLOCK_TRACE_V").is_some() {
12847+ eprintln!("DEBLOCK plane={plane_idx} tw={tw} th={th} stride={stride} true={}x{} crop={cw}x{ch}", plane.true_width, plane.true_height);
12848+ }
12718 let mut y0 = 0usize;12849 let mut y0 = 0usize;
12719 while y0 < th {12850 while y0 < th {
12720 let mut x0 = 4usize;12851 let mut x0 = 4usize;
12721 while x0 < tw {12852 while x0 < tw {
12722 if let Some((len, level)) = edge_params(lf, n, plane_idx, 0, chroma, x0, y0) {12853 if let Some((len, level)) = edge_params(lf, n, plane_idx, 0, chroma, x0, y0) {
12854+ if std::env::var_os("EC_AV1_DEBLOCK_TRACE_V").is_some() && plane_idx == 0 {
12855+ eprintln!("VEDGE x0={x0} y0={y0} len={len} level={level}");
12856+ }
12723 filter_edge(12857 filter_edge(
12724 &mut plane.data,12858 &mut plane.data,
12725 y0 * stride + x0,12859 y0 * stride + x0,
@@ -12919,13 +13053,30 @@ fn apply_loop_restoration(
12919 deblocked_v: &PlaneBuf,13053 deblocked_v: &PlaneBuf,
12920 lr: &LoopRestorationParams,13054 lr: &LoopRestorationParams,
12921 grid: &crate::restoration::RestorationGrid,13055 grid: &crate::restoration::RestorationGrid,
13056+ // lane-golomb r8: this frame header's own (cropped) luma size. Loop
13057+ // restoration is the ONE post-decode filter that does NOT run over the
13058+ // mi-rounded plane: libaom's `av1_loop_restoration_filter_frame` sizes
13059+ // every plane with `av1_get_upsampled_plane_size` -- `plane_w =
13060+ // ROUND_POWER_OF_TWO(cm->superres_upscaled_width, ss_x)`, `plane_h =
13061+ // ROUND_POWER_OF_TWO(cm->height, ss_y)` (`av1/common/restoration.c:47`)
13062+ // -- and asserts it equals the buffer's CROP width
13063+ // (`restoration.c:1106`), then `av1_extend_frame(..., plane_w, plane_h,
13064+ // ...)` (`restoration.c:1109`) replicates the right/bottom border from
13065+ // that cropped edge before any unit is filtered. Deblock and CDEF DO
13066+ // walk the mi grid, which is why passing `true_width`/`true_height`
13067+ // here went unnoticed until a frame whose size is not a multiple of 8
13068+ // (68 -> mi-rounded 72): the LR taps at the last four real columns then
13069+ // read this decoder's own decoded samples at columns 68..71 where
13070+ // libaom reads column 67 replicated -- +-1 over the straddling band
13071+ // (class av1-truesize-lane: true frame size vs mi-rounded).
13072+ (frame_w, frame_h): (usize, usize),
12922 ) {13073 ) {
12923 y.data = crate::restoration::apply_loop_restoration_plane(13074 y.data = crate::restoration::apply_loop_restoration_plane(
12924 &y.data,13075 &y.data,
12925 &deblocked_y.data,13076 &deblocked_y.data,
12926 y.width,13077 y.width,
12927- y.true_width,13078+ frame_w,
12928- y.true_height,13079+ frame_h,
12929 0,13080 0,
12930 lr.frame_restoration_type[0],13081 lr.frame_restoration_type[0],
12931 lr.loop_restoration_size[0],13082 lr.loop_restoration_size[0],
@@ -12936,8 +13087,8 @@ fn apply_loop_restoration(
12936 &u.data,13087 &u.data,
12937 &deblocked_u.data,13088 &deblocked_u.data,
12938 u.width,13089 u.width,
12939- u.true_width,13090+ frame_w.div_ceil(2),
12940- u.true_height,13091+ frame_h.div_ceil(2),
12941 1,13092 1,
12942 lr.frame_restoration_type[1],13093 lr.frame_restoration_type[1],
12943 lr.loop_restoration_size[1],13094 lr.loop_restoration_size[1],
@@ -12948,8 +13099,8 @@ fn apply_loop_restoration(
12948 &v.data,13099 &v.data,
12949 &deblocked_v.data,13100 &deblocked_v.data,
12950 v.width,13101 v.width,
12951- v.true_width,13102+ frame_w.div_ceil(2),
12952- v.true_height,13103+ frame_h.div_ceil(2),
12953 1,13104 1,
12954 lr.frame_restoration_type[2],13105 lr.frame_restoration_type[2],
12955 lr.loop_restoration_size[2],13106 lr.loop_restoration_size[2],
@@ -13512,11 +13663,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13512 match (has_cols, has_rows) {13663 match (has_cols, has_rows) {
13513 (true, false) => {13664 (true, false) => {
13514 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE));13665 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE));
13666+ bump_edge32(4 + b.min(1) as usize);
13515 bump_edge_part(b.min(1) as usize);13667 bump_edge_part(b.min(1) as usize);
13516 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }13668 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
13517 }13669 }
13518 (false, true) => {13670 (false, true) => {
13519 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE));13671 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE));
13672+ bump_edge32(4 + b.min(1) as usize);
13520 bump_edge_part(b.min(1) as usize);13673 bump_edge_part(b.min(1) as usize);
13521 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }13674 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }
13522 }13675 }
@@ -13585,6 +13738,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13585 &cdfs.partition_w32[ctx32],13738 &cdfs.partition_w32[ctx32],
13586 VERT_ALIKE,13739 VERT_ALIKE,
13587 ));13740 ));
13741+ bump_edge32(b.min(1) as usize);
13588 bump_edge_part(2 + b.min(1) as usize);13742 bump_edge_part(2 + b.min(1) as usize);
13589 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }13743 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
13590 }13744 }
@@ -13593,6 +13747,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13593 &cdfs.partition_w32[ctx32],13747 &cdfs.partition_w32[ctx32],
13594 HORZ_ALIKE,13748 HORZ_ALIKE,
13595 ));13749 ));
13750+ bump_edge32(b.min(1) as usize);
13596 bump_edge_part(2 + b.min(1) as usize);13751 bump_edge_part(2 + b.min(1) as usize);
13597 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }13752 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }
13598 }13753 }
@@ -14248,6 +14403,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14248 tx_select,14403 tx_select,
14249 reduced_tx_set,14404 reduced_tx_set,
14250 )?;14405 )?;
14406+ if !has_rows32 {
14407+ bump_edge32(2);
14408+ }
14251 // lane-hgkf r1: at the frame edge only the first half of the strip is14409 // lane-hgkf r1: at the frame edge only the first half of the strip is
14252 // coded (libaom `decode_partition` guards the second half with the same14410 // coded (libaom `decode_partition` guards the second half with the same
14253 // test that made this partition non-square).14411 // test that made this partition non-square).
@@ -14289,6 +14447,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14289 tx_select,14447 tx_select,
14290 reduced_tx_set,14448 reduced_tx_set,
14291 )?;14449 )?;
14450+ if !has_cols32 {
14451+ bump_edge32(3);
14452+ }
14292 // lane-hgkf r1: at the frame edge only the first half of the strip is14453 // lane-hgkf r1: at the frame edge only the first half of the strip is
14293 // coded (libaom `decode_partition` guards the second half with the same14454 // coded (libaom `decode_partition` guards the second half with the same
14294 // test that made this partition non-square).14455 // test that made this partition non-square).
@@ -14679,6 +14840,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14679 tx_select,14840 tx_select,
14680 reduced_tx_set,14841 reduced_tx_set,
14681 )?;14842 )?;
14843+ if !has_rows {
14844+ bump_edge32(6);
14845+ }
14682 // lane-golomb r1: at the frame edge only the first half of the14846 // lane-golomb r1: at the frame edge only the first half of the
14683 // strip is coded (libaom `decode_partition` guards the second14847 // strip is coded (libaom `decode_partition` guards the second
14684 // with the same has_rows test that made this partition non-square).14848 // with the same has_rows test that made this partition non-square).
@@ -14720,6 +14884,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14720 tx_select,14884 tx_select,
14721 reduced_tx_set,14885 reduced_tx_set,
14722 )?;14886 )?;
14887+ if !has_cols {
14888+ bump_edge32(7);
14889+ }
14723 // lane-golomb r1: at the frame edge only the first half of the14890 // lane-golomb r1: at the frame edge only the first half of the
14724 // strip is coded (libaom `decode_partition` guards the second14891 // strip is coded (libaom `decode_partition` guards the second
14725 // with the same has_cols test that made this partition non-square).14892 // with the same has_cols test that made this partition non-square).
@@ -14942,7 +15109,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14942 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);15109 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
14943 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);15110 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);
14944 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);15111 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
14945- apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid);15112+ apply_loop_restoration(
15113+ &mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid,
15114+ (frame_width as usize, frame_height as usize),
15115+ );
14946 15116
14947 let (fw, fh) = (frame_width as usize, frame_height as usize);15117 let (fw, fh) = (frame_width as usize, frame_height as usize);
14948 if fw == width && fh == height {15118 if fw == width && fh == height {
@@ -15334,10 +15504,9 @@ fn read_inter_plane(
15334 // `tx_type` -- `av1_get_tx_type` (libaom `blockd.h`): an inter block's15504 // `tx_type` -- `av1_get_tx_type` (libaom `blockd.h`): an inter block's
15335 // chroma plane never codes its own `tx_type` symbol, but (unlike an15505 // chroma plane never codes its own `tx_type` symbol, but (unlike an
15336 // intra block, which falls back to `Intra_Mode_To_Tx_Type`) it inherits15506 // intra block, which falls back to `Intra_Mode_To_Tx_Type`) it inherits
15337- // the colocated luma transform's coded type verbatim, clamped back to15507+ // the colocated luma transform's coded type, narrowed to the extended
15338- // `DCT_DCT` at the chroma tx sizes the spec forces DCT-only15508+ // set the CHROMA size selects ([`reduce_inherited_chroma_tx_type`]).
15339- // (`av1_get_ext_tx_set_type`: `tx_size_sqr_up >= TX_32X32`, i.e. this15509+ // `None` for the luma call itself
15340- // function's own `side >= 32`). `None` for the luma call itself
15341 // (`plane_idx == 0`), where the `TxbSet`'s own symbol (or the true15510 // (`plane_idx == 0`), where the `TxbSet`'s own symbol (or the true
15342 // `DCT_DCT` default at 32-point+) already resolves it without help.15511 // `DCT_DCT` default at 32-point+) already resolves it without help.
15343 inherited_luma_tx_type: Option<TxType>,15512 inherited_luma_tx_type: Option<TxType>,
@@ -15361,8 +15530,8 @@ fn read_inter_plane(
15361 };15530 };
15362 let mut coding = cdfs.txb(set, tx_mode);15531 let mut coding = cdfs.txb(set, tx_mode);
15363 let default_tx_type = match inherited_luma_tx_type {15532 let default_tx_type = match inherited_luma_tx_type {
15364- Some(t) if side < 32 => t,15533+ Some(t) => reduce_inherited_chroma_tx_type(t, side, side),
15365- _ => TxType::DctDct,15534+ None => TxType::DctDct,
15366 };15535 };
15367 let (grid, tx_type) = read_coeffs(15536 let (grid, tx_type) = read_coeffs(
15368 dec,15537 dec,
@@ -15755,22 +15924,33 @@ fn obmc_mask(len: usize) -> &'static [u8] {
15755 /// A bordering block's own resolved interp filter kernel, `(h, v)` --15924 /// A bordering block's own resolved interp filter kernel, `(h, v)` --
15756 /// mirrors [`resolve_interp_filter`]'s own return order from its stored15925 /// mirrors [`resolve_interp_filter`]'s own return order from its stored
15757 /// `[u8; 2]` (`Neighbours::above_filter`/`left_filter`, `[sym0, sym1]` =15926 /// `[u8; 2]` (`Neighbours::above_filter`/`left_filter`, `[sym0, sym1]` =
15758-/// `[v_sym, h_sym]`). Never calls `from_switchable_symbol` on the `[3, 3]`15927+/// `[v_sym, h_sym]`). The `[3, 3]` sentinel is only ever stored for an intra
15759-/// sentinel: that value is only ever stored for an intra neighbour (already15928+/// neighbour (excluded by [`overlappable_above`]/[`overlappable_left`]'s
15760-/// excluded by [`overlappable_above`]/[`overlappable_left`]'s `is_inter`15929+/// `is_inter` gate) or when `interp_fixed` is `Some` for the whole frame
15761-/// gate) or when `interp_fixed` is `Some` for the whole frame, handled here15930+/// (handled here first) -- so a sentinel reaching the kernel lookup means the
15762-/// first.15931+/// stream desynced upstream, and this refuses instead of panicking.
15763 fn neighbour_filter(15932 fn neighbour_filter(
15764 interp_fixed: Option<mc::InterpFilterKind>,15933 interp_fixed: Option<mc::InterpFilterKind>,
15765 sym: [u8; 2],15934 sym: [u8; 2],
15766-) -> (mc::InterpFilterKind, mc::InterpFilterKind) {15935+) -> Result<(mc::InterpFilterKind, mc::InterpFilterKind)> {
15767 if let Some(kind) = interp_fixed {15936 if let Some(kind) = interp_fixed {
15768- return (kind, kind);15937+ return Ok((kind, kind));
15938+ }
15939+ // lane-golomb r9: this used to hand the sentinel straight to
15940+ // `from_switchable_symbol`, which PANICS on any value above 2 -- a crash
15941+ // on stream data (measured on a real 192x68 cq40 aomenc stream, where an
15942+ // inter leaf below 8x8 desyncs upstream and leaves an unrecorded filter
15943+ // behind). A decoder must refuse such a stream by name, never abort the
15944+ // process; the desync that produces the sentinel belongs to lane-intersub8.
15945+ if sym[0] > 2 || sym[1] > 2 {
15946+ return Err(unsupported(
15947+ "an OBMC neighbour whose switchable interp filter was never recorded",
15948+ ));
15769 }15949 }
15770- (15950+ Ok((
15771 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),15951 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),
15772 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),15952 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),
15773- )15953+ ))
15774 }15954 }
15775 15955
15776 /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh15956 /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh
@@ -16053,7 +16233,7 @@ fn obmc_blend(
16053 let (h_kind, v_kind) = neighbour_filter(16233 let (h_kind, v_kind) = neighbour_filter(
16054 interp_fixed,16234 interp_fixed,
16055 neighbours.above_filter[mi_col + off4],16235 neighbours.above_filter[mi_col + off4],
16056- );16236+ )?;
16057 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;16237 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
16058 let nb_scale = mc::scale_factor(ny.width, frame_width);16238 let nb_scale = mc::scale_factor(ny.width, frame_width);
16059 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);16239 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);
@@ -16072,7 +16252,7 @@ fn obmc_blend(
16072 let (h_kind, v_kind) = neighbour_filter(16252 let (h_kind, v_kind) = neighbour_filter(
16073 interp_fixed,16253 interp_fixed,
16074 neighbours.left_filter[mi_row + off4],16254 neighbours.left_filter[mi_row + off4],
16075- );16255+ )?;
16076 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;16256 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
16077 let nb_scale = mc::scale_factor(ny.width, frame_width);16257 let nb_scale = mc::scale_factor(ny.width, frame_width);
16078 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);16258 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);
@@ -19459,7 +19639,9 @@ fn decode_inter_block(
19459 },19639 },
19460 );19640 );
19461 // lane-txselect: a var-tx block's deblock edges follow its own transform19641 // lane-txselect: a var-tx block's deblock edges follow its own transform
19462- // units, not the block.19642+ // units, not the block -- for LUMA only (lane-golomb r6): the chroma
19643+ // grids keep the block's own `av1_get_max_uv_txsize`, which is what
19644+ // libaom's `get_transform_size` reads for `plane != AOM_PLANE_Y`.
19463 // lane-sb128c r4: libaom `set_one_param_for_line_luma` suppresses every19645 // lane-sb128c r4: libaom `set_one_param_for_line_luma` suppresses every
19464 // edge that is a TU edge but not a PU edge when19646 // edge that is a TU edge but not a PU edge when
19465 // `curr_skipped = mbmi->skip_txfm && is_inter_block(mbmi)`, so a SKIP19647 // `curr_skipped = mbmi->skip_txfm && is_inter_block(mbmi)`, so a SKIP
@@ -19473,17 +19655,12 @@ fn decode_inter_block(
19473 }19655 }
19474 if let Some(leaves) = (!(skip && is_inter)).then_some(()).and(vartx_leaves.as_ref()) {19656 if let Some(leaves) = (!(skip && is_inter)).then_some(()).and(vartx_leaves.as_ref()) {
19475 for &(row, col, tw, th) in leaves {19657 for &(row, col, tw, th) in leaves {
19476- neighbours.fill_lf_grid_rect(19658+ neighbours.fill_lf_grid_leaf_luma(
19477 (at_mi.0 + row, at_mi.1 + col),19659 (at_mi.0 + row, at_mi.1 + col),
19478 tw / MI,19660 tw / MI,
19479 th / MI,19661 th / MI,
19480 tw as u8,19662 tw as u8,
19481 th as u8,19663 th as u8,
19482- if globalmv_for_lf {
19483- -ref_frame_for_lf
19484- } else {
19485- ref_frame_for_lf
19486- },
19487 );19664 );
19488 }19665 }
19489 }19666 }
@@ -21198,7 +21375,18 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
21198 // true size. Height must still match: AV1 superres never scales height21375 // true size. Height must still match: AV1 superres never scales height
21199 // (r8's derivation, `mc.rs`'s own doc), and nothing in this decode path21376 // (r8's derivation, `mc.rs`'s own doc), and nothing in this decode path
21200 // has a vertical scaling pass.21377 // has a vertical scaling pass.
21201- if reference.height != true_height {21378+ // lane-golomb r8: the comparison is against the header's own frame
21379+ // height, NOT the mi-rounded `true_height`. libaom compares references
21380+ // on the CROPPED dimensions -- `av1_setup_scale_factors_for_frame(&sf,
21381+ // ref->y_crop_width, ref->y_crop_height, cm->width, cm->height)`
21382+ // (`av1/common/reconinter.c`), and a reference is "scaled" only when
21383+ // those differ (`av1_is_scaled`). A decoded `Picture` is cropped to
21384+ // `fw`/`fh`, so for any height that is not a multiple of 8 (68 ->
21385+ // mi_rows 18 -> `true_height` 72) this test compared 68 against 72 and
21386+ // refused every same-size reference (class av1-truesize-lane: true
21387+ // frame size vs mi-rounded). Height must still MATCH: AV1 superres
21388+ // never scales height, and no path here has a vertical scaling pass.
21389+ if reference.height != frame_height as usize {
21202 return Err(unsupported(21390 return Err(unsupported(
21203 "a reference picture whose height does not match this frame's own true size",21391 "a reference picture whose height does not match this frame's own true size",
21204 ));21392 ));
@@ -21609,7 +21797,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
21609 // lane-golomb r1 (class `parsed-then-discarded`): the gathered21797 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
21610 // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT21798 // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT
21611 // (libaom `ec_read_partition_impl`).21799 // (libaom `ec_read_partition_impl`).
21612- if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)) == 1 {21800+ if bump_edge32_bit(
21801+ 4,
21802+ dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)),
21803+ ) == 1 {
21613 PARTITION_SPLIT21804 PARTITION_SPLIT
21614 } else {21805 } else {
21615 PARTITION_HORZ21806 PARTITION_HORZ
@@ -21619,7 +21810,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
21619 // lane-golomb r1 (class `parsed-then-discarded`): the gathered21810 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
21620 // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT21811 // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT
21621 // (libaom `ec_read_partition_impl`).21812 // (libaom `ec_read_partition_impl`).
21622- if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)) == 1 {21813+ if bump_edge32_bit(
21814+ 4,
21815+ dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)),
21816+ ) == 1 {
21623 PARTITION_SPLIT21817 PARTITION_SPLIT
21624 } else {21818 } else {
21625 PARTITION_VERT21819 PARTITION_VERT
@@ -21794,7 +21988,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
21794 // lane-golomb r1 (class `parsed-then-discarded`): the gathered21988 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
21795 // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT21989 // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT
21796 // (libaom `ec_read_partition_impl`).21990 // (libaom `ec_read_partition_impl`).
21797- if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE)) == 1 {21991+ if {
21992+ let b = dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE));
21993+ bump_edge32(b.min(1) as usize);
21994+ b
21995+ } == 1 {
21798 PARTITION_SPLIT21996 PARTITION_SPLIT
21799 } else {21997 } else {
21800 PARTITION_HORZ21998 PARTITION_HORZ
@@ -21804,7 +22002,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
21804 // lane-golomb r1 (class `parsed-then-discarded`): the gathered22002 // lane-golomb r1 (class `parsed-then-discarded`): the gathered
21805 // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT22003 // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT
21806 // (libaom `ec_read_partition_impl`).22004 // (libaom `ec_read_partition_impl`).
21807- if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE)) == 1 {22005+ if {
22006+ let b = dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE));
22007+ bump_edge32(b.min(1) as usize);
22008+ b
22009+ } == 1 {
21808 PARTITION_SPLIT22010 PARTITION_SPLIT
21809 } else {22011 } else {
21810 PARTITION_VERT22012 PARTITION_VERT
@@ -22436,55 +22638,63 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
22436 allow_screen_content_tools,22638 allow_screen_content_tools,
22437 frame_width as usize,22639 frame_width as usize,
22438 )?;22640 )?;
22439- decode_inter_block(22641+ if !has_rows32 {
22440- &mut dec,22642+ bump_edge32(2);
22441- &mut cdfs,22643+ }
22442- &mut neighbours,22644+ // lane-golomb r2: at the frame edge only the first half of the
22443- &mut grid,22645+ // strip is coded (libaom `decode_partition` guards the second
22444- sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)),22646+ // with the same has_rows32 test that made this partition non-square).
22445- BLOCK,22647+ if has_rows32 {
22446- mi_cols,22648+ decode_inter_block(
22447- mi_rows,22649+ &mut dec,
22448- &mut y,22650+ &mut cdfs,
22449- &mut u,22651+ &mut neighbours,
22450- &mut v,22652+ &mut grid,
22451- &ref_y,22653+ sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)),
22452- &ref_u,22654+ BLOCK,
22453- &ref_v,22655+ mi_cols,
22454- &ref_slots,22656+ mi_rows,
22455- &sign_bias_table,22657+ &mut y,
22456- &global_motion,22658+ &mut u,
22457- base_q_idx,22659+ &mut v,
22458- TxbSet::Luma32,22660+ &ref_y,
22459- TxbSet::Luma32Inter,22661+ &ref_u,
22460- TxbSet::Chroma16,22662+ &ref_v,
22461- TX32,22663+ &ref_slots,
22462- TX16,22664+ &sign_bias_table,
22463- &scan32,22665+ &global_motion,
22464- &scan16,22666+ base_q_idx,
22465- 3,22667+ TxbSet::Luma32,
22466- allow_high_precision_mv,22668+ TxbSet::Luma32Inter,
22467- force_integer_mv,22669+ TxbSet::Chroma16,
22468- interp_fixed,22670+ TX32,
22469- enable_dual_filter,22671+ TX16,
22470- tpl_frame.as_ref(),22672+ &scan32,
22471- reference_select,22673+ &scan16,
22472- enable_masked_compound,22674+ 3,
22473- enable_interintra_compound,22675+ allow_high_precision_mv,
22474- enable_jnt_comp,22676+ force_integer_mv,
22475- order_hint_bits,22677+ interp_fixed,
22476- order_hint,22678+ enable_dual_filter,
22477- ref_order_hints,22679+ tpl_frame.as_ref(),
22478- skip_mode_present,22680+ reference_select,
22479- skip_mode_frame,22681+ enable_masked_compound,
22480- switchable_motion_mode,22682+ enable_interintra_compound,
22481- allow_warped_motion,22683+ enable_jnt_comp,
22482- true,22684+ order_hint_bits,
22483- BLOCK,22685+ order_hint,
22484- SUB,22686+ ref_order_hints,
22485- allow_screen_content_tools,22687+ skip_mode_present,
22486- frame_width as usize,22688+ skip_mode_frame,
22487- )?;22689+ switchable_motion_mode,
22690+ allow_warped_motion,
22691+ true,
22692+ BLOCK,
22693+ SUB,
22694+ allow_screen_content_tools,
22695+ frame_width as usize,
22696+ )?;
22697+ }
22488 }22698 }
22489 PARTITION_VERT => {22699 PARTITION_VERT => {
22490 // lane-rect r2: mirror of PARTITION_HORZ above with22700 // lane-rect r2: mirror of PARTITION_HORZ above with
@@ -22539,55 +22749,63 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
22539 allow_screen_content_tools,22749 allow_screen_content_tools,
22540 frame_width as usize,22750 frame_width as usize,
22541 )?;22751 )?;
22542- decode_inter_block(22752+ if !has_cols32 {
22543- &mut dec,22753+ bump_edge32(3);
22544- &mut cdfs,22754+ }
22545- &mut neighbours,22755+ // lane-golomb r2: at the frame edge only the first half of the
22546- &mut grid,22756+ // strip is coded (libaom `decode_partition` guards the second
22547- sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)),22757+ // with the same has_cols32 test that made this partition non-square).
22548- BLOCK,22758+ if has_cols32 {
22549- mi_cols,22759+ decode_inter_block(
22550- mi_rows,22760+ &mut dec,
22551- &mut y,22761+ &mut cdfs,
22552- &mut u,22762+ &mut neighbours,
22553- &mut v,22763+ &mut grid,
22554- &ref_y,22764+ sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)),
22555- &ref_u,22765+ BLOCK,
22556- &ref_v,22766+ mi_cols,
22557- &ref_slots,22767+ mi_rows,
22558- &sign_bias_table,22768+ &mut y,
22559- &global_motion,22769+ &mut u,
22560- base_q_idx,22770+ &mut v,
22561- TxbSet::Luma32,22771+ &ref_y,
22562- TxbSet::Luma32Inter,22772+ &ref_u,
22563- TxbSet::Chroma16,22773+ &ref_v,
22564- TX32,22774+ &ref_slots,
22565- TX16,22775+ &sign_bias_table,
22566- &scan32,22776+ &global_motion,
22567- &scan16,22777+ base_q_idx,
22568- 3,22778+ TxbSet::Luma32,
22569- allow_high_precision_mv,22779+ TxbSet::Luma32Inter,
22570- force_integer_mv,22780+ TxbSet::Chroma16,
22571- interp_fixed,22781+ TX32,
22572- enable_dual_filter,22782+ TX16,
22573- tpl_frame.as_ref(),22783+ &scan32,
22574- reference_select,22784+ &scan16,
22575- enable_masked_compound,22785+ 3,
22576- enable_interintra_compound,22786+ allow_high_precision_mv,
22577- enable_jnt_comp,22787+ force_integer_mv,
22578- order_hint_bits,22788+ interp_fixed,
22579- order_hint,22789+ enable_dual_filter,
22580- ref_order_hints,22790+ tpl_frame.as_ref(),
22581- skip_mode_present,22791+ reference_select,
22582- skip_mode_frame,22792+ enable_masked_compound,
22583- switchable_motion_mode,22793+ enable_interintra_compound,
22584- allow_warped_motion,22794+ enable_jnt_comp,
22585- true,22795+ order_hint_bits,
22586- SUB,22796+ order_hint,
22587- BLOCK,22797+ ref_order_hints,
22588- allow_screen_content_tools,22798+ skip_mode_present,
22589- frame_width as usize,22799+ skip_mode_frame,
22590- )?;22800+ switchable_motion_mode,
22801+ allow_warped_motion,
22802+ true,
22803+ SUB,
22804+ BLOCK,
22805+ allow_screen_content_tools,
22806+ frame_width as usize,
22807+ )?;
22808+ }
22591 }22809 }
22592 PARTITION_HORZ_A => {22810 PARTITION_HORZ_A => {
22593 // lane-partab r1: two 16x16 squares on top + a true22811 // lane-partab r1: two 16x16 squares on top + a true
@@ -23167,7 +23385,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
23167 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);23385 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
23168 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);23386 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);
23169 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);23387 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
23170- apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid);23388+ apply_loop_restoration(
23389+ &mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid,
23390+ (frame_width as usize, frame_height as usize),
23391+ );
23171 23392
23172 let motion_field = build_motion_field(23393 let motion_field = build_motion_field(
23173 &grid,23394 &grid,
@@ -23240,6 +23461,36 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
23240 #[cfg(test)]23461 #[cfg(test)]
23241 mod tests {23462 mod tests {
23242 23463
23464+ /// lane-golomb r7: [`reduce_inherited_chroma_tx_type`] must reproduce
23465+ /// `av1_ext_tx_used[av1_get_ext_tx_set_type(uv_tx, 1, reduced)]`
23466+ /// (libaom `av1/common/blockd.h:1036`/`1097`) exactly -- the g35 residue
23467+ /// was one 64x64 inter superblock whose 32x32 chroma units are
23468+ /// `EXT_TX_SET_DCT_IDTX`, where IDTX survives and we forced `DCT_DCT`.
23469+ #[test]
23470+ fn an_inter_chroma_transform_narrows_its_inherited_tx_type_to_its_own_set() {
23471+ use TxType::*;
23472+ // EXT_TX_SET_DCTONLY: `tx_size_sqr_up > TX_32X32`.
23473+ set_inter_tx_mode(true, false, true);
23474+ assert_eq!(reduce_inherited_chroma_tx_type(Idtx, 64, 64), DctDct);
23475+ // EXT_TX_SET_DCT_IDTX at exactly TX_32X32 -- the residue's case.
23476+ assert_eq!(reduce_inherited_chroma_tx_type(Idtx, 32, 32), Idtx);
23477+ assert_eq!(reduce_inherited_chroma_tx_type(AdstAdst, 32, 32), DctDct);
23478+ // EXT_TX_SET_DTT9_IDTX_1DDCT at `tx_size_sqr == TX_16X16`: the four
23479+ // 1D ADST/FLIPADST types (TX_TYPES 12..15) drop out, the rest stay.
23480+ assert_eq!(reduce_inherited_chroma_tx_type(HDct, 16, 16), HDct);
23481+ assert_eq!(reduce_inherited_chroma_tx_type(FlipAdstAdst, 16, 16), FlipAdstAdst);
23482+ assert_eq!(reduce_inherited_chroma_tx_type(HAdst, 16, 16), DctDct);
23483+ // EXT_TX_SET_ALL16 below that (`tx_size_sqr < TX_16X16`, so a 16x8
23484+ // chroma unit too).
23485+ assert_eq!(reduce_inherited_chroma_tx_type(HAdst, 16, 8), HAdst);
23486+ assert_eq!(reduce_inherited_chroma_tx_type(VFlipAdst, 8, 8), VFlipAdst);
23487+ // `reduced_tx_set` collapses every inter set to DCT_IDTX.
23488+ set_inter_tx_mode(true, true, true);
23489+ assert_eq!(reduce_inherited_chroma_tx_type(Idtx, 8, 8), Idtx);
23490+ assert_eq!(reduce_inherited_chroma_tx_type(HAdst, 8, 8), DctDct);
23491+ set_inter_tx_mode(true, false, true);
23492+ }
23493+
23243 /// lane-fistrip r1 (class `enumerate-the-table-domain`): every block23494 /// lane-fistrip r1 (class `enumerate-the-table-domain`): every block
23244 /// shape this decoder can hand [`filter_intra_size_class_rect`], against23495 /// shape this decoder can hand [`filter_intra_size_class_rect`], against
23245 /// `av1_filter_intra_allowed_bsize` (`block_size_wide <= 32 &&23496 /// `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] = &[
34 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",34 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
35 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",35 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",
36 "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",36 "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",
37 "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",38 "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",
38 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",39 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
39 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",40 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
crates/ec-av1/src/stream.rsmodified+360 -0
@@ -19497,6 +19497,366 @@ mod tests {
19497 );19497 );
19498 }19498 }
19499 19499
19500+ /// lane-golomb r2 gate: a 32x32-level block that STRADDLES the frame edge
19501+ /// and whose partition is the gathered edge bit's `PARTITION_HORZ` (bottom
19502+ /// edge) / `PARTITION_VERT` (right edge). Since r1 that bit can name
19503+ /// HORZ/VERT instead of always inferring SPLIT, so the second 32x16/16x32
19504+ /// half is out of frame and must NOT be decoded (libaom `decode_partition`:
19505+ /// `case PARTITION_HORZ: decode_block(top); if (has_rows) decode_block(bottom)`).
19506+ /// The AB and 1:4 arms need no such guard: at an edge libaom's
19507+ /// `ec_read_partition_impl` can only yield HORZ/VERT/SPLIT, so those arms
19508+ /// are unreachable there.
19509+ ///
19510+ /// Geometry: 192x80 (mi_rows=20 -- the second SB row is 16 px tall, so its
19511+ /// 32-level blocks at y=64 have `has_rows32 == false`) and 80x192 for the
19512+ /// right edge. Natural content (`testsrc2`); `smptebars`-style screen
19513+ /// content trips the palette/screen-content refusal before the edge is
19514+ /// reached. cq sweep, 8-bit and 10-bit, plus a 5-frame inter arm.
19515+ /// Counters are sampled per attempt and summed only over attempts that
19516+ /// decoded AND pixel-compared (class `counter-from-refused-stream`).
19517+ #[test]
19518+ fn a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact() {
19519+ edge32_gate(
19520+ "a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact",
19521+ false,
19522+ );
19523+ }
19524+
19525+ /// lane-golomb r2 OPEN DEFECT, pinned as a runnable test: with the 16-px
19526+ /// straddling band left FLAT the encoder answers the 32-level edge bit
19527+ /// with HORZ (`edge32=[2, 0, 2, 0]` on 192x80 cq40 8-bit), the guard added
19528+ /// this round keeps the stream in entropy sync -- every pixel outside the
19529+ /// two edge strips matches ffmpeg -- but the strips themselves
19530+ /// reconstruct wrong: `plane Y: 1081 pixels differ, first at row 62 col
19531+ /// 128`, diffs confined to rows 62..79 over ~64 columns (exactly the two
19532+ /// 32x16 strips plus the deblock bleed above them). That is a
19533+ /// reconstruction defect inside the strip (prediction/availability), not
19534+ /// the partition guard. `#[ignore]` so the suite stays green; run it with
19535+ /// `cargo test -p ec-av1 --lib -- --ignored a_32x32_frame_edge_rect_partition_with_a_flat`.
19536+ #[test]
19537+ #[ignore = "open r2 defect: the 32-level edge HORZ strip reconstructs wrong pixels"]
19538+ fn a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact() {
19539+ edge32_gate(
19540+ "a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact",
19541+ true,
19542+ );
19543+ }
19544+
19545+ /// lane-golomb r9 OPEN DEFECT, pinned as a runnable test: a frame whose
19546+ /// height (192x68) or width (68x192) is not a multiple of 8 leaves a 4-px
19547+ /// straddling band inside the mi-rounded plane, and every INTER frame's
19548+ /// output is +-1 wrong across that band and the columns/rows next to it
19549+ /// (`68x192 cq35 8-bit: frame 1 plane Y: 145 pixels differ, first at row 0
19550+ /// col 64`, mass in columns 64..67). r9 bisected it stage by stage against
19551+ /// the instrumented aomdec on that exact stream:
19552+ /// * `EC_AV1_PREFILT_DUMP` frame 1 is BYTE-IDENTICAL over the cropped
19553+ /// 68 columns -- reconstruction and inter prediction are exact, so the
19554+ /// charter's "MC reads past the crop" hypothesis is refuted a second time.
19555+ /// * `EC_AV1_POSTDEBLOCK_DUMP` with `EC_AV1_DEBUG_SKIP_CDEF=1` also matches
19556+ /// aomdec's own post-deblock dump (which is 72 columns wide, i.e. it
19557+ /// exposes the straddling band) -- the deblock, including its
19558+ /// `frame_width` clip, is correct.
19559+ /// * The divergence therefore enters in CDEF, at the last 8x8 CDEF block
19560+ /// column/row, which is the one that straddles the crop edge.
19561+ /// `#[ignore]` so the suite stays green; run it with
19562+ /// `cargo test -p ec-av1 --lib -- --ignored a_frame_edge_straddling_band`.
19563+ #[test]
19564+ #[ignore = "open r9 defect: CDEF at the last straddling 8x8 block column/row"]
19565+ fn a_frame_edge_straddling_band_decodes_pixel_exact() {
19566+ edge32_gate(
19567+ "a_frame_edge_straddling_band_decodes_pixel_exact",
19568+ false,
19569+ );
19570+ }
19571+
19572+ fn edge32_gate(name: &str, flat_band: bool) {
19573+ let NAME = name;
19574+ let _gate_lock = lock_gate_counters();
19575+ if !have_ffmpeg() {
19576+ eprintln!("SKIP {NAME}: no ffmpeg");
19577+ return;
19578+ }
19579+ if !have_aomenc() {
19580+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
19581+ return;
19582+ }
19583+ // (width, height, frames, ten_bit)
19584+ let mut arms: Vec<(usize, usize, usize, bool)> = Vec::new();
19585+ for &(w, h) in &[(192usize, 80usize), (80usize, 192usize)] {
19586+ arms.push((w, h, 1, false));
19587+ arms.push((w, h, 1, true));
19588+ }
19589+ // The inter arm: >= 4 frames so the 32-level edge path in the INTER
19590+ // tile walk is exercised too.
19591+ arms.push((192, 80, 5, false));
19592+ // lane-golomb r9: the straddling-band arms, only under the ignored
19593+ // `a_frame_edge_straddling_band_decodes_pixel_exact` name (they are
19594+ // RED -- see that test's own comment for the stage bisection). Naming
19595+ // them here rather than in a second copy of this gate keeps the
19596+ // recipe, the counters and the refusal handling identical.
19597+ if name == "a_frame_edge_straddling_band_decodes_pixel_exact" {
19598+ arms.clear();
19599+ arms.push((192, 68, 5, false));
19600+ arms.push((192, 68, 5, true));
19601+ arms.push((68, 192, 5, false));
19602+ arms.push((68, 192, 5, true));
19603+ }
19604+ // lane-golomb r8 MEASURED, arm STILL NOT added (every cq level is
19605+ // vacuous, panicking or red -- each measured this round with
19606+ // `arms.push((192, 68, 5, false))`, log
19607+ // `$HOME/.cache/golomb-gate-r8{b,e,f,g}.log`):
19608+ // * the r7 blocker IS fixed -- no attempt refuses "a reference
19609+ // picture whose height does not match this frame's own true
19610+ // size" any more (`decode.rs`'s comparison now uses the header's
19611+ // frame height, per libaom's crop-dimension reference test).
19612+ // * cq35 now refuses LATER, by another lane's name: "an inter
19613+ // SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B)" -- so the
19614+ // arm compares nothing (class `counter-from-refused-stream`).
19615+ // * cq40 PANICS in `decode_inter_block8`
19616+ // (`from_switchable_symbol` handed a 4th symbol, `mc.rs:203`) =
19617+ // lane-sub8's own open below-8x8 desync; a panic cannot be
19618+ // tolerated as a named refusal.
19619+ // * cq59 8-bit is RED: `frame 1 plane Y: 217 pixels differ, first
19620+ // at row 60 col 170 (ours 172 vs ffmpeg 173)`, and the cq35
19621+ // 10-bit twin is RED at `row 56 col 48 (ours 530 vs ffmpeg
19622+ // 531)`. Both are +-1 bands in rows 56..63, i.e. the deblock/CDEF
19623+ // bleed ABOVE the 4-px straddling row band (64..67) -- the same
19624+ // shape as the `(68, 192, 5, false)` column defect below, so the
19625+ // two are very likely ONE straddling-band reconstruction defect.
19626+ // lane-golomb r7 MEASURED, arm NOT added (it would be vacuous or red):
19627+ // a 68-px axis leaves the last superblock straddling by 4 px, the
19628+ // shape `read_var_tx_size`'s `blk_row >= max_h_mi || blk_col >=
19629+ // max_w_mi` early return exists for. With
19630+ // `arms.push((192, 68, 5, false))` all EIGHT cq attempts refuse by
19631+ // name -- "a reference picture whose height does not match this
19632+ // frame's own true size" -- so the arm compares nothing (class
19633+ // `counter-from-refused-stream`). With
19634+ // `arms.push((68, 192, 5, false))` the gate goes RED on a real,
19635+ // separate defect: `68x192 cq35 frames=5 10bit=false frame 1 plane Y:
19636+ // 141 pixels differ, first at row 0 col 64 (ours 167 vs ffmpeg 166)
19637+ // [edge32=[0,34,0,0,1,17,0,1]]` -- LUMA, inside the 4-px straddling
19638+ // COLUMN. Both are unrelated to this round's chroma tx_type fix.
19639+ let cqs: [u32; 8] = [35, 40, 45, 50, 55, 57, 59, 61];
19640+ let mut totals = [0usize; 8];
19641+ let mut compared = 0usize;
19642+ let mut refusals: Vec<String> = Vec::new();
19643+ for &(width, height, frame_count, ten_bit) in &arms {
19644+ for &cq in &cqs {
19645+ let duration = frame_count as f64 / 25.0;
19646+ // `noise` (explicit seed) both defeats aomenc's
19647+ // screen-content detection -- which otherwise refuses every
19648+ // attempt at "a HORZ/VERT intra strip in a screen-content
19649+ // frame" -- and keeps the RD search off flat NONE blocks.
19650+ // Natural content over the whole superblock-aligned area,
19651+ // with the 16-px straddling band left FLAT (`pad`): with
19652+ // detail in that band aomenc always answers the edge bit with
19653+ // SPLIT (measured: 178 edge bits, 178 of them SPLIT, over a
19654+ // cq 35..61 sweep), so the HORZ/VERT arm this round guards
19655+ // never fired. `noise` on top keeps screen-content detection
19656+ // (and its palette-strip refusal) off.
19657+ let (cw, ch) = (
19658+ if flat_band && width % 64 != 0 { width - 16 } else { width },
19659+ if flat_band && height % 64 != 0 { height - 16 } else { height },
19660+ );
19661+ let pad = if flat_band {
19662+ format!("pad={width}:{height}:0:0:gray,")
19663+ } else {
19664+ String::new()
19665+ };
19666+ let source = format!(
19667+ "testsrc2=size={cw}x{ch}:duration={duration}:rate=25,\
19668+ {pad}noise=alls=6:allf=t+u:all_seed={cq}"
19669+ );
19670+ let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" };
19671+ let y4m = Command::new("ffmpeg")
19672+ .args([
19673+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", pix, "-strict",
19674+ "-1", "-t", &format!("{duration}"), "-f", "yuv4mpegpipe", "-",
19675+ ])
19676+ .stdin(Stdio::null())
19677+ .stdout(Stdio::piped())
19678+ .stderr(Stdio::piped())
19679+ .output()
19680+ .expect("ffmpeg failed to run");
19681+ assert!(
19682+ y4m.status.success(),
19683+ "{NAME}: ffmpeg fixture: {}",
19684+ String::from_utf8_lossy(&y4m.stderr)
19685+ );
19686+ let cq_arg = format!("--cq-level={cq}");
19687+ let mut args: Vec<&str> = vec![
19688+ "--codec=av1",
19689+ "--passes=1",
19690+ "--end-usage=q",
19691+ &cq_arg,
19692+ "--cpu-used=0",
19693+ "--threads=1",
19694+ "--row-mt=0",
19695+ "--sb-size=64",
19696+ "--enable-restoration=0",
19697+ "--enable-palette=0",
19698+ "--deltaq-mode=0",
19699+ "--enable-intrabc=0",
19700+ // Per-arm overrides go LAST (aomenc keeps the last
19701+ // occurrence of a repeated --enable-* flag).
19702+ "--enable-rect-partitions=1",
19703+ "--enable-ab-partitions=0",
19704+ "--enable-1to4-partitions=0",
19705+ // 32, not the charter's 8: at 8 the sub-16 AB and
19706+ // split-transform strip arms (still refused by name here)
19707+ // fire before the 32-level edge is reached and EVERY
19708+ // attempt refuses (measured). At 32 the edge block cannot
19709+ // split, so aomenc is forced onto the gathered edge bit's
19710+ // HORZ/VERT -- exactly the arm this round guards.
19711+ "--min-partition-size=32",
19712+ "--tune-content=film",
19713+ "--max-partition-size=64",
19714+ ];
19715+ if ten_bit {
19716+ args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);
19717+ }
19718+ args.extend_from_slice(&["--obu", "-o", "-", "-"]);
19719+ let mut child = Command::new(aomenc_path())
19720+ .args(&args)
19721+ .stdin(Stdio::piped())
19722+ .stdout(Stdio::piped())
19723+ .stderr(Stdio::piped())
19724+ .spawn()
19725+ .expect("aomenc failed to start");
19726+ child
19727+ .stdin
19728+ .take()
19729+ .expect("aomenc stdin")
19730+ .write_all(&y4m.stdout)
19731+ .expect("writing y4m to aomenc");
19732+ let out = child.wait_with_output().expect("aomenc failed to run");
19733+ assert!(
19734+ out.status.success(),
19735+ "{NAME}: aomenc refused the fixture: {}",
19736+ String::from_utf8_lossy(&out.stderr)
19737+ );
19738+ let stream = out.stdout;
19739+ if ten_bit {
19740+ assert_eq!(
19741+ parsed_bit_depth(&stream),
19742+ 10,
19743+ "{NAME}: aomenc did not write a 10-bit sequence header"
19744+ );
19745+ }
19746+ let tag = format!("{width}x{height} cq{cq} frames={frame_count} 10bit={ten_bit}");
19747+ let before = crate::decode::edge32_hits();
19748+ // lane-golomb r8: name the attempt BEFORE decoding it -- a
19749+ // desync surfaces as a panic deep in mc.rs with no arm in the
19750+ // message, and r8 spent a run bisecting arms by hand.
19751+ if std::env::var_os("EC_GATE_VERBOSE").is_some() {
19752+ eprintln!("{NAME}: attempting {tag}");
19753+ }
19754+ let decoded = match decode_stream(&stream) {
19755+ Ok(frames) => frames,
19756+ Err(e) => {
19757+ let msg = e.to_string();
19758+ assert!(
19759+ msg.contains("unsupported"),
19760+ "{NAME} failed outright, not a named refusal ({tag}): {msg}"
19761+ );
19762+ refusals.push(format!("{tag}: {msg}"));
19763+ continue;
19764+ }
19765+ };
19766+ let after = crate::decode::edge32_hits();
19767+ let delta: Vec<usize> =
19768+ (0..8).map(|i| after[i] - before[i]).collect();
19769+ let reference = if ten_bit {
19770+ ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len())
19771+ } else {
19772+ ffmpeg_decode_sequence(&stream, width, height, decoded.len())
19773+ };
19774+ assert_eq!(
19775+ decoded.len(),
19776+ reference.len(),
19777+ "{NAME}: {tag}: shown-frame count vs ffmpeg"
19778+ );
19779+ for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() {
19780+ for (plane, a, b, w) in [
19781+ ("Y", &ours.y, &theirs.y, width),
19782+ ("U", &ours.u, &theirs.u, width / 2),
19783+ ("V", &ours.v, &theirs.v, width / 2),
19784+ ] {
19785+ if let Some(d) = a.iter().zip(b.iter()).position(|(x, y)| x != y) {
19786+ let n = a.iter().zip(b.iter()).filter(|(x, y)| x != y).count();
19787+ if std::env::var_os("EC_EDGE32_ROWS").is_some() {
19788+ let mut per_row: std::collections::BTreeMap<usize, usize> =
19789+ Default::default();
19790+ for (k, (x, y)) in a.iter().zip(b.iter()).enumerate() {
19791+ if x != y {
19792+ *per_row.entry(k / w).or_default() += 1;
19793+ }
19794+ }
19795+ eprintln!("{NAME}: {tag} plane {plane} diffs per row: {per_row:?}");
19796+ }
19797+ panic!(
19798+ "{NAME}: {tag} frame {i} plane {plane}: {n} pixels differ, first \
19799+ at row {} col {} (ours {} vs ffmpeg {}) [edge32={delta:?}]",
19800+ d / w,
19801+ d % w,
19802+ a[d],
19803+ b[d]
19804+ );
19805+ }
19806+ }
19807+ }
19808+ compared += 1;
19809+ for i in 0..8 {
19810+ totals[i] += delta[i];
19811+ }
19812+ }
19813+ }
19814+ assert!(
19815+ compared > 0,
19816+ "{NAME}: every attempt hit a named refusal:\n{}",
19817+ refusals.join("\n")
19818+ );
19819+ assert!(
19820+ totals[0] + totals[1] + totals[4] + totals[5] > 0,
19821+ "{NAME}: no frame-edge partition bit was read at all over \
19822+ {compared} compared attempts -- the gate proved nothing"
19823+ );
19824+ // lane-golomb r3: the flat-band arm's ASSERT moved one level up. Until
19825+ // r3 the last superblock row was reached through a 32-level edge bit
19826+ // only because our own out-of-frame transform units had desynced the
19827+ // stream; with that fixed, real aomenc answers a bottom-edge
19828+ // superblock with the 64-level `PARTITION_HORZ` (and a right-edge one
19829+ // with `PARTITION_VERT`) and the 32-level slots stay 0 on this
19830+ // content. Slots 6/7 are the strips actually decoded at the edge.
19831+ assert!(
19832+ !flat_band || totals[6] > 0,
19833+ "{NAME}: no 64x32 bottom-edge HORZ strip was decoded \
19834+ (edge32={totals:?}, {compared} compared attempts)"
19835+ );
19836+ assert!(
19837+ !flat_band || totals[7] > 0,
19838+ "{NAME}: no 32x64 right-edge VERT strip was decoded \
19839+ (edge32={totals:?}, {compared} compared attempts)"
19840+ );
19841+ eprintln!(
19842+ "{NAME}: {compared} pixel-exact attempts, 32-level edge bits \
19843+ [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, 64-level edge bits \
19844+ [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, {} named refusals",
19845+ totals[0],
19846+ totals[1],
19847+ totals[2],
19848+ totals[3],
19849+ totals[4],
19850+ totals[5],
19851+ totals[6],
19852+ totals[7],
19853+ refusals.len()
19854+ );
19855+ for r in &refusals {
19856+ eprintln!("{NAME} refusal: {r}");
19857+ }
19858+ }
19859+
19500 /// lane-sqchroma r1 gate: a plain SQUARE-partition intra key frame with19860 /// lane-sqchroma r1 gate: a plain SQUARE-partition intra key frame with
19501 /// REAL chroma (no `hue=s=0` guard) and aomenc's tx-size search left at19861 /// REAL chroma (no `hue=s=0` guard) and aomenc's tx-size search left at
19502 /// its own DEFAULT (on) -- the combination the user's films hit19862 /// its own DEFAULT (on) -- the combination the user's films hit
lanes/golomb-r1.report.mdmodified+68 -0
@@ -45,3 +45,71 @@ desyncing.
45 correctly decoded as HORZ, on an INTER superblock row the inter path cannot code (rect inter45 correctly decoded as HORZ, on an INTER superblock row the inter path cannot code (rect inter
46 residual coding does not exist here). Next lane.46 residual coding does not exist here). Next lane.
47 - `reelb5.obu`: "a 32x32-level 1:4 strip with a split transform (depth=2)" (unchanged by this lane).47 - `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).