forge
Explore
Log in

Don't you dare go Hollow

ec-av1: 4:4:4 inter sub8 per-piece chroma + edge-clamped contexts

Browse files at this commit

e21f07c4674d6cfdc492472bd2e16b8d998fe571Ahmet Kaan GümüşParent: 8b574e6
- clamp Neighbours::around_mi/around_mi_rect/luma_skip_ctx_rect to the
  frame's true mi_cols/mi_rows extent: libaom's above/left entropy arrays
  are calloc(aligned_mi_cols) and zero beyond the frame, so beyond-frame
  cells contribute nothing (fixture's reconstruct_rect len-64 panic gone;
  all 60 frames decode, exit 0)
- decode_inter_sub8_split4 at ss 0/0: every 4x4 piece codes its own 4x4
  U/V unit right after its luma (is_chroma_reference unconditional at
  ss 0/0), with per-piece MC and record_mi_chroma; the 4:2:0 group unit
  is gated !chroma_444 and the group's uv_mode/palette bookkeeping is
  hoisted to run at both subsamplings
- fixture decode_idx 1 entropy ladder vs instrumented aomdec: first
  mismatch moved 387 -> 925 (all partition_w8 + first 15 chroma TUs now
  bit-identical); current wall = chroma-4x4 eob CDF adaptation source
  (report)
- diagnostics: EC_DBG_SUB8 (per-b8 partition + per-piece decisions),
  EC_TRACE_PART, oracle-side EC_EOBPT_CDF

Regression arms rerun green: 420 square, 444 square filters off/on,
forced-64x64 444; fixture frame 0 byte-exact
crates/ec-av1/src/decode.rsmodified+126 -23
@@ -8083,15 +8083,24 @@ impl Neighbours {
8083 // One pass over the cells accumulating all three planes, not one pass8083 // One pass over the cells accumulating all three planes, not one pass
8084 // per plane: the three planes of a cell live in the same8084 // per plane: the three planes of a cell live in the same
8085 // `[Neighbour; 3]` (6 bytes), so the per-plane form loaded the same8085 // `[Neighbour; 3]` (6 bytes), so the per-plane form loaded the same
8086- // cache lines three times (lane-publish).8086+ // cache lines three times (lane-publish). Clamp each edge to the true
8087+ // frame extent: a block at the right/bottom edge may be padded beyond
8088+ // `mi_cols`/`mi_rows`, and libaom's unavailable context is zero there.
8089+ let above_mi = side_mi.min(self.mi_cols.saturating_sub(mi_c));
8090+ let left_mi = side_mi.min(self.mi_rows.saturating_sub(mi_r));
8087 let mut out = [(false, false, 0i32); 3];8091 let mut out = [(false, false, 0i32); 3];
8088- for cell in 0..side_mi {8092+ for cell in 0..above_mi {
8089 let above = &self.above[mi_c + cell];8093 let above = &self.above[mi_c + cell];
8090- let left = &self.left[mi_r + cell];
8091 for (plane, o) in out.iter_mut().enumerate() {8094 for (plane, o) in out.iter_mut().enumerate() {
8092 o.0 |= above[plane].level != 0;8095 o.0 |= above[plane].level != 0;
8096+ o.2 += dc_vote(above[plane].dc);
8097+ }
8098+ }
8099+ for cell in 0..left_mi {
8100+ let left = &self.left[mi_r + cell];
8101+ for (plane, o) in out.iter_mut().enumerate() {
8093 o.1 |= left[plane].level != 0;8102 o.1 |= left[plane].level != 0;
8094- o.2 += dc_vote(above[plane].dc) + dc_vote(left[plane].dc);8103+ o.2 += dc_vote(left[plane].dc);
8095 }8104 }
8096 }8105 }
8097 out8106 out
@@ -8108,16 +8117,18 @@ impl Neighbours {
8108 /// mode-info units, mirroring [`Self::around_mi`].8117 /// mode-info units, mirroring [`Self::around_mi`].
8109 fn around_mi_rect(&self, (mi_r, mi_c): (usize, usize), w: usize, h: usize) -> [(bool, bool, i32); 3] {8118 fn around_mi_rect(&self, (mi_r, mi_c): (usize, usize), w: usize, h: usize) -> [(bool, bool, i32); 3] {
8110 let (w_mi, h_mi) = (w / MI, h / MI);8119 let (w_mi, h_mi) = (w / MI, h / MI);
8120+ let above_mi = w_mi.min(self.mi_cols.saturating_sub(mi_c));
8121+ let left_mi = h_mi.min(self.mi_rows.saturating_sub(mi_r));
8111 // [`Self::around_mi`]'s single pass, with the two extents split.8122 // [`Self::around_mi`]'s single pass, with the two extents split.
8112 let mut out = [(false, false, 0i32); 3];8123 let mut out = [(false, false, 0i32); 3];
8113- for cell in 0..w_mi {8124+ for cell in 0..above_mi {
8114 let above = &self.above[mi_c + cell];8125 let above = &self.above[mi_c + cell];
8115 for (plane, o) in out.iter_mut().enumerate() {8126 for (plane, o) in out.iter_mut().enumerate() {
8116 o.0 |= above[plane].level != 0;8127 o.0 |= above[plane].level != 0;
8117 o.2 += dc_vote(above[plane].dc);8128 o.2 += dc_vote(above[plane].dc);
8118 }8129 }
8119 }8130 }
8120- for cell in 0..h_mi {8131+ for cell in 0..left_mi {
8121 let left = &self.left[mi_r + cell];8132 let left = &self.left[mi_r + cell];
8122 for (plane, o) in out.iter_mut().enumerate() {8133 for (plane, o) in out.iter_mut().enumerate() {
8123 o.1 |= left[plane].level != 0;8134 o.1 |= left[plane].level != 0;
@@ -8127,10 +8138,10 @@ impl Neighbours {
8127 if crate::envflags::env_flag!("EC_DCDUMP") {8138 if crate::envflags::env_flag!("EC_DCDUMP") {
8128 for (plane, o) in out.iter().enumerate() {8139 for (plane, o) in out.iter().enumerate() {
8129 let vote = o.2;8140 let vote = o.2;
8130- let ab: Vec<String> = (0..w_mi)8141+ let ab: Vec<String> = (0..above_mi)
8131 .map(|k| format!("{:?}/{}", self.above[mi_c + k][plane].dc, self.above[mi_c + k][plane].level))8142 .map(|k| format!("{:?}/{}", self.above[mi_c + k][plane].dc, self.above[mi_c + k][plane].level))
8132 .collect();8143 .collect();
8133- let lf: Vec<String> = (0..h_mi)8144+ let lf: Vec<String> = (0..left_mi)
8134 .map(|k| format!("{:?}/{}", self.left[mi_r + k][plane].dc, self.left[mi_r + k][plane].level))8145 .map(|k| format!("{:?}/{}", self.left[mi_r + k][plane].dc, self.left[mi_r + k][plane].level))
8135 .collect();8146 .collect();
8136 eprintln!("EC_DCDUMP mi=({mi_r},{mi_c}) plane={plane} wh=({w},{h}) vote={vote} above=[{}] left=[{}]", ab.join(","), lf.join(","));8147 eprintln!("EC_DCDUMP mi=({mi_r},{mi_c}) plane={plane} wh=({w},{h}) vote={vote} above=[{}] left=[{}]", ab.join(","), lf.join(","));
@@ -8160,20 +8171,22 @@ impl Neighbours {
8160 h_mi: usize,8171 h_mi: usize,
8161 ) -> usize {8172 ) -> usize {
8162 let side_mi = w_mi;8173 let side_mi = w_mi;
8174+ let above_mi = w_mi.min(self.mi_cols.saturating_sub(mi_c));
8175+ let left_mi = h_mi.min(self.mi_rows.saturating_sub(mi_r));
8163 let mut top = 0u8;8176 let mut top = 0u8;
8164 let mut left = 0u8;8177 let mut left = 0u8;
8165- for cell in 0..w_mi {8178+ for cell in 0..above_mi {
8166 top |= self.above[mi_c + cell][0].level;8179 top |= self.above[mi_c + cell][0].level;
8167 }8180 }
8168- for cell in 0..h_mi {8181+ for cell in 0..left_mi {
8169 left |= self.left[mi_r + cell][0].level;8182 left |= self.left[mi_r + cell][0].level;
8170 }8183 }
8171 let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)];8184 let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)];
8172 if crate::envflags::env_flag!("EC_ECDUMP") {8185 if crate::envflags::env_flag!("EC_ECDUMP") {
8173 let ab: Vec<String> =8186 let ab: Vec<String> =
8174- (0..w_mi).map(|k| self.above[mi_c + k][0].level.to_string()).collect();8187+ (0..above_mi).map(|k| self.above[mi_c + k][0].level.to_string()).collect();
8175 let lf: Vec<String> =8188 let lf: Vec<String> =
8176- (0..h_mi).map(|k| self.left[mi_r + k][0].level.to_string()).collect();8189+ (0..left_mi).map(|k| self.left[mi_r + k][0].level.to_string()).collect();
8177 eprintln!(8190 eprintln!(
8178 "EC_ECDUMP plane=0 mi=({mi_r},{mi_c}) wh=({w_mi},{h_mi}) ctx={ctx} above=[{},] left=[{},]",8191 "EC_ECDUMP plane=0 mi=({mi_r},{mi_c}) wh=({w_mi},{h_mi}) ctx={ctx} above=[{},] left=[{},]",
8179 ab.join(","), lf.join(",")8192 ab.join(","), lf.join(",")
@@ -31953,6 +31966,7 @@ fn decode_inter_sub8_split4(
31953 // No `skip_mode` symbol: `is_comp_ref_allowed(BLOCK_4X4)` is false.31966 // No `skip_mode` symbol: `is_comp_ref_allowed(BLOCK_4X4)` is false.
31954 let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]);31967 let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]);
31955 let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;31968 let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;
31969+ let ec_skip_post = if std::env::var_os("EC_DBG_SUB8").is_some() { Some(dec.debug_state().0) } else { None };
31956 inter_segment_id(dec, cdfs, rmi, cmi, 1, 1, skip, false, fctx);31970 inter_segment_id(dec, cdfs, rmi, cmi, 1, 1, skip, false, fctx);
31957 maybe_read_cdef_idx(dec, rmi, cmi, (2, 2), skip, fctx);31971 maybe_read_cdef_idx(dec, rmi, cmi, (2, 2), skip, fctx);
31958 maybe_read_delta_q(dec, cdfs, rmi, cmi, false, skip, fctx);31972 maybe_read_delta_q(dec, cdfs, rmi, cmi, false, skip, fctx);
@@ -31968,6 +31982,9 @@ fn decode_inter_sub8_split4(
31968 neighbours.left_inter[rmi],31982 neighbours.left_inter[rmi],
31969 );31983 );
31970 let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;31984 let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
31985+ if std::env::var_os("EC_DBG_SUB8").is_some() {
31986+ eprintln!("EC_DBG piece mi=({rmi},{cmi}) skip={skip} skipctx={skip_ctx} skip_post={:?} is_inter={is_inter} iictx={ii_ctx} post={}", ec_skip_post, dec.debug_state().0);
31987+ }
31971 if !is_inter {31988 if !is_inter {
31972 if crate::envflags::env_flag!("EC_SUB8INTRA") {31989 if crate::envflags::env_flag!("EC_SUB8INTRA") {
31973 eprintln!(31990 eprintln!(
@@ -32291,6 +32308,82 @@ fn decode_inter_sub8_split4(
32291 }32308 }
32292 neighbours.record_mi_luma_rect(lmi, B4, B4, &luma_grid);32309 neighbours.record_mi_luma_rect(lmi, B4, B4, &luma_grid);
32293 }32310 }
32311+ // lane-av1-444: `is_chroma_reference` is unconditional at ss 0/0
32312+ // (av1_common_int.h:1459 -- `!subsampling_x`/`!subsampling_y` force
32313+ // both disjuncts true), so at 4:4:4 this 4x4 sub-block codes its own
32314+ // 4x4 U and V units right after its luma, plane order 0,1,2 per leaf
32315+ // (aomdec EC_COEFF on `av1-profile1-444.ivf` frame 1). Chroma MC is
32316+ // the piece's own mv and filters at the piece's own pixel position
32317+ // (ss 0: the chroma planes share luma's grid), and each unit's
32318+ // tx_type is its own piece's luma type -- a TX_4X4 codes no tx_type
32319+ // symbol, so DctDct.
32320+ if chroma_444 {
32321+ let (pc_ref, pc_mv, pc_hf, pc_vf) = piece[i].expect("inter piece recorded above");
32322+ let build_c = move |_y: &mut PlaneBuf<'static>,
32323+ _u: &mut PlaneBuf<'static>,
32324+ _v: &mut PlaneBuf<'static>,
32325+ fctx: &crate::decode::FrameCtx,
32326+ out: &mut [Vec<u16>; 3]| {
32327+ let Some((pc_ref_y, sref_u, sref_v)) = ref_planes_deferred(pc_ref, refpix) else {
32328+ return;
32329+ };
32330+ let pc_scale = mc::scale_factor(pc_ref_y.width, frame_width);
32331+ let mut pred_u = refill(std::mem::take(&mut out[1]), B4 * B4);
32332+ let mut pred_v = refill(std::mem::take(&mut out[2]), B4 * B4);
32333+ for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] {
32334+ let mut buf = vec![0u16; B4 * B4];
32335+ mc::predict_maybe_scaled(
32336+ &plane.data,
32337+ plane.width,
32338+ plane.true_width,
32339+ plane.true_height,
32340+ mv_to_q4(px, pc_mv.1, ss_x(fctx)),
32341+ mv_to_q4(py, pc_mv.0, ss_x(fctx)),
32342+ pc_scale,
32343+ B4,
32344+ B4,
32345+ pc_hf,
32346+ pc_vf,
32347+ &mut buf, fctx,
32348+ );
32349+ dst.copy_from_slice(&buf);
32350+ }
32351+ out[1] = pred_u;
32352+ out[2] = pred_v;
32353+ };
32354+ let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>);
32355+ let (su, sv) = if recon_deferred(fctx) {
32356+ push_pred(fctx, build_c);
32357+ (
32358+ Pred::Cur { plane: 1, stride: B4, off: 0 },
32359+ Pred::Cur { plane: 2, stride: B4, off: 0 },
32360+ )
32361+ } else {
32362+ let mut built: [Vec<u16>; 3] = Default::default();
32363+ build_c(y, u, v, fctx, &mut built);
32364+ let [_, bu, bv] = built;
32365+ (pred_cu, pred_cv) = (bu, bv);
32366+ (Pred::Inline(&pred_cu, B4), Pred::Inline(&pred_cv, B4))
32367+ };
32368+ if skip {
32369+ push_mc(1, px, py, B4, su, &ZERO_RESIDUAL[..B4 * B4], fctx);
32370+ push_mc(2, px, py, B4, sv, &ZERO_RESIDUAL[..B4 * B4], fctx);
32371+ neighbours.record_mi_chroma(lmi, B4, B4, 1, &ZERO_RESIDUAL[..B4 * B4]);
32372+ neighbours.record_mi_chroma(lmi, B4, B4, 2, &ZERO_RESIDUAL[..B4 * B4]);
32373+ } else {
32374+ let ca = neighbours.around_mi(lmi, B4);
32375+ let (ug, _) = read_inter_plane(
32376+ dec, cdfs, TxbSet::Chroma4, scan4, 1, ca[1], 0, u, px, py, B4, base_q_idx,
32377+ su, Some(TxType::DctDct), None, fctx,
32378+ )?;
32379+ let (vg, _) = read_inter_plane(
32380+ dec, cdfs, TxbSet::Chroma4, scan4, 2, ca[2], 0, v, px, py, B4, base_q_idx,
32381+ sv, Some(TxType::DctDct), None, fctx,
32382+ )?;
32383+ neighbours.record_mi_chroma(lmi, B4, B4, 1, &ug);
32384+ neighbours.record_mi_chroma(lmi, B4, B4, 2, &vg);
32385+ }
32386+ }
32294 neighbours.record_mode_mi(rmi, cmi, 1, 1, DC_PRED);32387 neighbours.record_mode_mi(rmi, cmi, 1, 1, DC_PRED);
32295 neighbours.record_inter_rect_mi(lmi, 1, 1, skip, true, ref_frame, resolved_filter, false);32388 neighbours.record_inter_rect_mi(lmi, 1, 1, skip, true, ref_frame, resolved_filter, false);
32296 // lane-inter16ab r8 (same-shape sweep of the intra-strip band gap):32389 // lane-inter16ab r8 (same-shape sweep of the intra-strip band gap):
@@ -32305,7 +32398,22 @@ fn decode_inter_sub8_split4(
32305 }32398 }
32306 // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded32399 // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded
32307 // and reconstructed the group's one chroma unit itself.32400 // and reconstructed the group's one chroma unit itself.
32308- if !intra_chroma {32401+ // lane-av1-444: at ss 0/0 the group unit does not exist -- every piece
32402+ // coded its own U/V inside the loop above. The mode-level bookkeeping
32403+ // below still runs for both subsamplings: an inter 4x4 piece's
32404+ // `mbmi->uv_mode` is the DC_PRED default and no piece can be a palette
32405+ // block, exactly as the 4:2:0 path already published.
32406+ neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED);
32407+ // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map
32408+ // needs EVERY writer): a sub-8x8 group published no palette state, so
32409+ // once an 8x8 leaf of the same row can BE a palette block, the group
32410+ // left the row's band holding that earlier block's size and the next
32411+ // intra block read `av1_get_palette_mode_ctx` one too high (measured:
32412+ // mi(30,30) of decode-order frame 1, ours ctx 1 where libaom gathers
32413+ // 0). No sub-8x8 piece can itself be a palette (`av1_allow_palette`
32414+ // needs `bsize >= BLOCK_8X8`), so the group always clears.
32415+ record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);
32416+ if !chroma_444 && !intra_chroma {
32309 // Chroma, once for the whole group, on the last sub-block's own `skip`32417 // Chroma, once for the whole group, on the last sub-block's own `skip`
32310 // flag -- prediction from all four sub-blocks (2x2 pieces), residual as32418 // flag -- prediction from all four sub-blocks (2x2 pieces), residual as
32311 // one TX_4X4 unit per plane.32419 // one TX_4X4 unit per plane.
@@ -32411,16 +32519,6 @@ fn decode_inter_sub8_split4(
32411 note_sub8_chroma_tx(sub0_tx_type, first_tx_type, coded);32519 note_sub8_chroma_tx(sub0_tx_type, first_tx_type, coded);
32412 (ug, vg)32520 (ug, vg)
32413 };32521 };
32414- neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED);
32415- // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map
32416- // needs EVERY writer): a sub-8x8 group published no palette state, so
32417- // once an 8x8 leaf of the same row can BE a palette block, the group
32418- // left the row's band holding that earlier block's size and the next
32419- // intra block read `av1_get_palette_mode_ctx` one too high (measured:
32420- // mi(30,30) of decode-order frame 1, ours ctx 1 where libaom gathers
32421- // 0). No sub-8x8 piece can itself be a palette (`av1_allow_palette`
32422- // needs `bsize >= BLOCK_8X8`), so the group always clears.
32423- record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);
32424 let round_up_even = |n: usize| n.div_ceil(2) * 2;32522 let round_up_even = |n: usize| n.div_ceil(2) * 2;
32425 let bound_h = round_up_even(neighbours.mi_rows);32523 let bound_h = round_up_even(neighbours.mi_rows);
32426 let bound_w = round_up_even(neighbours.mi_cols);32524 let bound_w = round_up_even(neighbours.mi_cols);
@@ -37671,7 +37769,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
37671 let leaf_mi = (mr as usize, mc as usize);37769 let leaf_mi = (mr as usize, mc as usize);
37672 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);37770 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
37673 if crate::envflags::env_flag!("EC_TRACE_PART") { eprintln!("EC_PART mi_row={} mi_col={} bsize=3 ctx={} rng={}", leaf_mi.0, leaf_mi.1, leaf_ctx, dec.debug_state().0); }37771 if crate::envflags::env_flag!("EC_TRACE_PART") { eprintln!("EC_PART mi_row={} mi_col={} bsize=3 ctx={} rng={}", leaf_mi.0, leaf_mi.1, leaf_ctx, dec.debug_state().0); }
37772+ let ec_dbg_pre = dec.debug_state().0;
37674 let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);37773 let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);
37774+ if std::env::var_os("EC_DBG_SUB8").is_some() {
37775+ let ec_dbg_post = dec.debug_state().0;
37776+ eprintln!("EC_DBG b8 mi=({},{}) ctx={leaf_ctx} val={part8} pre={ec_dbg_pre} post={ec_dbg_post}", leaf_mi.0, leaf_mi.1);
37777+ }
37675 if part8 == PARTITION_SPLIT {37778 if part8 == PARTITION_SPLIT {
37676 // lane-intersub8: four BLOCK_4X4 inter37779 // lane-intersub8: four BLOCK_4X4 inter
37677 // sub-blocks, chroma once per 8x8.37780 // sub-blocks, chroma once per 8x8.
lanes/av1444.report.mdmodified+78 -12
@@ -85,21 +85,87 @@ panics (see below). Full suite NOT run.
85 | shape | disposition |85 | shape | disposition |
86 | --- | --- |86 | --- | --- |
87 | 4:2:2 (`ss_x != ss_y`) | refused by name. Gate re-scoped, not re-run |87 | 4:2:2 (`ss_x != ss_y`) | refused by name. Gate re-scoped, not re-run |
88-| 64-axis intra strips with split luma transforms at 4:4:4 (`decode_rect_split` chroma (64,16)/(64,32)/(16,64) with tx < block) | panics, not a named refusal. The `chroma_tiled` unit loop exists but the residual reaching `reconstruct_rect` is sized for a 4:2:0 unit somewhere in this path |88+| inter rect2 sub8 (8x4/4x8 pieces) at 4:4:4 per-piece chroma | unported — `decode_inter_sub8_rect2` still codes the 4:2:0 group unit |
89-| `av1-profile1-444.ivf` | not byte-exact (panic above). Refusal-gate flip to witness gate NOT done |89+| `decode_inter_sub8_split4` per-piece chroma eob CDF adaptation | wall (below), first mismatch deep in frame 1 |
90-| inter square 64x64 at 4:4:4 (var-tx and single-TU) | unwitnessed — the square inter chroma path codes one unit; libaom codes four TX_32X32. No stream has exercised it yet |90+| full `cargo test -p ec-av1` | NOT run this round. Do not claim green |
91-| full `cargo test -p ec-av1` | NOT run. Do not claim green |91+| 0-warning parity | build is warning-clean (`cargo build --release -p ec-av1 --example decode_probe`); full-suite parity not measured |
92-| 0-warning parity | not measured this round |92+
93+## Continuation 4 (2026-09-23, Av1X444Cont4)
94+
95+1. **Edge panic fixed (Rauf's clamp, verified bug-for-bug, committed)**:
96+ `around_mi`/`around_mi_rect`/`luma_skip_ctx_rect` clamp each walk to
97+ `mi_cols`/`mi_rows`. libaom facts checked: the above/left entropy+coeff
98+ arrays are `aom_calloc(aligned_mi_cols, ..)` per tile row
99+ (alloccommon.c:437-448, `ALIGN_POWER_OF_TWO(mi_cols, MAX_MIB_SIZE_LOG2)` =
100+ exactly 80 for the 320 px fixture) — zero-initialized and never written
101+ beyond the frame extent, and `get_txb_ctx_general` (txb_common.h:281)
102+ walks only the TXB's own span, so beyond-frame cells contribute ZERO to
103+ every context on libaom's side too. The clamp reproduces exactly that;
104+ there is no edge sample extension for these entropy-context arrays. The
105+ fixture's `reconstruct_rect len 64 index 64` panic is gone: the probe
106+ decodes all 60 frames, exit 0.
107+2. **Fixture frame 0 (first shown frame) still byte-exact** vs ffmpeg
108+ yuv444p after the above (re-verified every round).
109+3. **decode_idx 1 (hidden inter, base_q 57, show_frame=0) root-caused and
110+ partially fixed**: the frame's first partition reads
111+ (`w64/w32/w16` all SPLIT at mi (0,0)) were in sync, but aom reads an
112+ **8x8-level `partition_w8` symbol** before each 8x8 leaf of the inter
113+ walker too (the keyframe walker already read it; the inter walker reads
114+ it silently — the missing *per-piece chroma* was the real gap):
115+ at ss 0/0 `is_chroma_reference` is unconditional
116+ (av1_common_int.h:1459 — `!subsampling_x/y` force both disjuncts true),
117+ so every 4x4 piece of a `partition_w8 == SPLIT` group codes its OWN 4x4
118+ U and V unit right after its luma, plane order 0,1,2 per leaf.
119+ `decode_inter_sub8_split4` coded the 4:2:0 group unit instead. Fixed:
120+ per-piece chroma MC (piece's own mv/filters, ss 0) + per-piece
121+ `read_inter_plane` + `record_mi_chroma`; the group unit is now gated
122+ `!chroma_444`, with `record_uv_mode_mi`/`record_strip_palette` hoisted so
123+ they run at both subsamplings. Result: the coefficient-step ladder
124+ against instrumented aomdec moved from first mismatch at step 387 to
125+ step 925 (15 chroma TUs + the whole (0,2) group and (2,0)/(2,2) 8x8
126+ blocks now bit-identical; all `partition_w8` values match through
127+ mi (2,6)).
128+4. **Current wall (precisely localized)**: decode_idx 1, the (2,6) split4
129+ group's piece-0 U TU (4x4, ss 0/0). Both sides read the identical
130+ `all_zero` symbol (rng 34242, value 0), then the `eob_pt` read diverges:
131+ aom eob=4, ours eob=2, from identical pre-state. Instrumented oracle
132+ (`EC_EOBPT_CDF` print added to decodetxb.c, `ninja aomdec` rebuild) shows
133+ aom's `eob_flag_cdf16[PLANE_UV][0]` contents at that read =
134+ `[30271, 28672, 23902, 15775]` — heavily adapted — while ours
135+ (`eob_pt_16_chroma`, bound `cdf_state.rs:1841`) is still near its default
136+ `[6764, 8165, 12733, 17250]`. So aom's chroma-4x4-2D eob CDF instance
137+ receives adaptation from reads our model routes elsewhere (or misses):
138+ the next suspects are (a) `decode_inter_sub8_rect2`'s per-piece chroma
139+ (still the 4:2:0 group unit — aom codes per-piece 8x4/4x8 chroma units,
140+ same 16-coeff eob class), and (b) the intra 16x4/4x16 strips' chroma
141+ units in inter frames (`intra16x4_in_inter` 16x4=68 4x16=24), whose
142+ 4x4-class eob reads must land on the same `eob_flag_cdf16[UV][2D]`
143+ instance. Tooling left in place: `EC_DBG_SUB8=1` (per-b8 partition
144+ value/pre/post rng, per-piece skip/is_inter), `EC_TRACE_PART=1`
145+ (EC_PART-style partition walk), oracle-side `EC_EOBPT_CDF=1`
146+ (per-4x4-eob CDF contents + mi). Comparison harness:
147+ `EC_TRACE_COEFF=1 aomdec` vs `EC_TRACE_COEFF=1 decode_probe` on
148+ `$HOME/.cache/av1444/f2.obu` (2-frame cut), diff with the 15
149+ instrument-only chroma `tx_type` lines dropped.
150+5. Regression arms after the change: 420 square IDENTICAL, 444 square
151+ filters off IDENTICAL, 444 square filters on IDENTICAL, forced-64x64
152+ 444 IDENTICAL (witness scripts, rerun this round).
153+6. **Frame-output policy note**: `decode_probe` writes only SHOWN frames
154+ (`is_shown` gate); aomdec/ffmpeg likewise. The first shown frame is
155+ decode_idx 0; decode_idx 1..5 are hidden alt-ref/LF-update frames — they
156+ still must decode bit-exactly because every later shown frame references
157+ them.
93 158
94 ## Next159 ## Next
95 160
96-1. Fix the `decode_rect_split` 64-axis-strip chroma at 4:4:4 (the161+1. Fix the chroma-4x4 eob CDF adaptation-source mismatch (see wall above):
97- len-64 panic): trace which unit feeds `reconstruct_rect` a 64-long162+ diff `eob_flag_cdf16[UV][2D]` adaptation sources per TU — port
98- residual; the `chroma_tiled` arm's (32,16)/(16,32) rect units go163+ `decode_inter_sub8_rect2` per-piece chroma (8x4/4x8 units, same
99- through `read_coeffs_rect` + `dequant_and_inverse_typed_wh` — check164+ 16-coeff eob class) and verify the intra 16x4/4x16 strips' chroma
100- the scratch/grid sizing against libaom's two-unit plane-major order.165+ units land on `eob_flag_cdf16[UV][2D]` at 4:4:4.
101-2. Then the inter square-64 four-unit chroma (mirror the intra fix).166+2. Then re-run the ladder: divergence should move past (2,6)U; iterate
167+ until decode_idx 1 is bit-exact, then frames 2..59.
102 3. Then the fixture end-to-end vs ffmpeg; flip the refusal gate168 3. Then the fixture end-to-end vs ffmpeg; flip the refusal gate
103 (`a_non_420_subsampled_sequence_header_is_refused_by_name` re-scope)169 (`a_non_420_subsampled_sequence_header_is_refused_by_name` re-scope)
104- to a fixture witness gate.170+ to a fixture witness gate; witness or refuse inter square 64x64 444.
105 4. Full suite `--test-threads=1`, 0-warning parity, update this report.171 4. Full suite `--test-threads=1`, 0-warning parity, update this report.