forge
Explore
Log in

Don't you dare go Hollow

lane-av1-444interband: the inter 1:4 strip's chroma pair rewrite is 4:2:0-only

Browse files at this commit

1ddefc1ef28757dd490a734ab73094aa55998c71Ahmet Kaan GümüşParent: 50b44b4
decode_inter_block's strip tail ran the lane-inter16ab pair-span chroma
context rewrite unconditionally, but the pair form (16x8 / 8x16 span at
pair_mi) only exists at 4:2:0. At ss 0/0 every strip is its own chroma
reference and its own record already stamps exactly its own 16x4 (4x16)
span, so the rewrite smeared the strip's chroma state over one extra
row/col of cells: a skipped strip zeroed left[r+1] planes 1-2, erasing
the 16x16-intra block to its left's U/V coefficient-context stamps, and
the strip below read its chroma txb_skip off the wrong CDF row.

Measured on the default-partition lossless 4:4:4 6-frame stream in
/tmp/llkf (t6.obu, per av1llkf.report.md): decode refused mid-frame-1 at
the 16x4 strip mi(2,8) with the strip's U unit reading txb_skip base 0
where aom reads base 1 (left[2][1] 0 vs 23; the oracle's cells trace to
the intra block (0,4)'s U unit bc=3/br=2 as the last writer). Post-fix
all 6 frames are byte-exact against fresh aomdec --rawvideo output, and
INTER16_CHROMA_PAIR_HITS no longer fires on the pairless stream (31 -> 0
while the 48 strips still decode).

Gates: cargo test -p ec-av1 --lib a_lossless 7 passed 0 failed (both
4:2:0 lossless libaom gates untouched, the 444 min-partition-64 and
min-partition-8 inter gates, the sb128 pair, the 16x4 pair). cargo check
-p ec-av1 --all-targets: 0 warnings, 0 errors. rustfmt --check reports
no hunks inside the edited ranges.
crates/ec-av1/src/decode.rsmodified+20 -0
@@ -8980,6 +8980,13 @@ impl Neighbours {
89808980 let round_up_even = |n: usize| n.div_ceil(2) * 2;
89818981 let (bound_h, bound_w) = (round_up_even(self.mi_rows), round_up_even(self.mi_cols));
89828982 let state = neighbour_state(grid);
8983+ if crate::envflags::env_flag!("EC_CHROMA_PUB") {
8984+ eprintln!(
8985+ "EC_CHROMA_PUB plane={plane} mi=({mi_r},{mi_c}) wh=({w_px},{h_px}) lvl={} dc={}",
8986+ state.level,
8987+ state.dc.map_or(-1, |s| i32::from(s))
8988+ );
8989+ }
89838990 for cell in 0..(h_px / MI).min(bound_h.saturating_sub(mi_r)) {
89848991 self.left[mi_r + cell][plane] = state;
89858992 }
@@ -34643,8 +34650,21 @@ fn decode_inter_block(
3464334650 // strip's own record wrote empty chroma state over those cells -- this
3464434651 // rewrite is what libaom's single `av1_set_contexts` call for the 8x4
3464534652 // (4x8) chroma unit leaves behind.
34653+ // lane-av1-444interband: 4:2:0 ONLY. At ss 0/0 every strip IS its own
34654+ // chroma reference (`is_chroma_reference`, no mi parity test), its own
34655+ // `record_rect_mi` above already stamps exactly the strip's 16x4 (4x16)
34656+ // chroma span -- libaom `av1_set_entropy_contexts`, or
34657+ // `av1_reset_entropy_context` for a skipped strip (decodeframe.c:1180)
34658+ // -- and the pair-form 16x8 (8x16) span anchored at `pair_mi` (== the
34659+ // strip's own mi at ss 0/0) smeared the strip's state over one extra
34660+ // row/col of cells: a skipped strip wrote zero over `left[r+1][1..2]`,
34661+ // erasing the 16x16-intra block to its left's U/V stamps, and the strip
34662+ // below read its chroma `txb_skip` off the wrong CDF row (t6 frame 1,
34663+ // U unit (2,8): our base 0 vs aom's base 1, `left[2][1]` 0 vs 23 --
34664+ // `INTER16_CHROMA_PAIR_HITS` fired 31x on a stream that has no pairs).
3464634665 let pair_chroma = strip_chroma
3464734666 .filter(|s| s.has_chroma)
34667+ .filter(|_| ss_x(fctx) == 1 && ss_y(fctx) == 1)
3464834668 .map(|s| (s, neighbour_state(&u_grid), neighbour_state(&v_grid)));
3464934669 // lane-vert46 r1: libaom stamps the chroma entropy context PER TRANSFORM
3465034670 // UNIT (`av1_set_entropy_contexts` inside `decode_reconstruct_tx`'s mu-chunk