From e371b5781e41f4018625eff6769000c661377946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 26 Sep 2026 01:44:36 +0300 Subject: [PATCH] ec-av1: decode_inter_block's 422 chroma half on the per-axis plane-block model lane-av1-422blockhalf: per-axis chroma pred buffers and blends, assembled grid stride x height sizing, BLOCK_INVALID 422 chroma as (4,8) unit tiling lifting the frame-11 (4,32) refusal, sub8_rect2 has_chroma per is_chroma_reference. 420/444 byte-identical; t422 frame 0 exact at three stages; frames-1+ blocker reattributed upstream to the mi(8,10) partition dispatch. --- crates/ec-av1/src/decode.rs | 554 ++++++++++++++++++++++++-------- lanes/av1422blockhalf.report.md | 133 ++++++++ 2 files changed, 557 insertions(+), 130 deletions(-) create mode 100644 lanes/av1422blockhalf.report.md diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 2f989080..2bd42aa6 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -10213,6 +10213,21 @@ fn decode_rect_split( let (px, py) = (mi_c * MI, mi_r * MI); let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); let (chroma_w, chroma_h) = (bw >> ss_x(fctx), bh >> ss_y(fctx)); + // lane-av1-422blockhalf: at ss (1,0) the tall/wide 1:2 and 1:4 strips' + // chroma plane block is BLOCK_INVALID (`av1_ss_size_lookup[...][1][0]`, + // blockd.h -- the 4:2:2 column maps BLOCK_8X16/16X32/32X64/64X128 and + // BLOCK_8X32/16X64, plus 4-wide BLOCK_4X16, to BLOCK_INVALID), so + // `av1_get_max_uv_txsize` indexes `max_txsize_rect_lookup` OUT OF BOUNDS + // and the pinned Release oracle byte there is TX_4X8 (the lane-av1-422m + // measurement). The plane is still coded -- `decode_token_recon_block` + // steps it in that (4, 8) unit shape -- so the strip's chroma tiles into + // 4x8 rect units, plane-major. + let chroma_422_oob = ss_x(fctx) == 1 + && ss_y(fctx) == 0 + && matches!( + (bw, bh), + (8, 16) | (16, 32) | (32, 64) | (64, 128) | (8, 32) | (16, 64) + ); // The chroma transform is picked before any symbol is read, so an // unsupported chroma shape refuses before this strip desyncs the tile. let chroma: Option<(TxbSet, &[u16])> = match (chroma_w, chroma_h) { @@ -10251,12 +10266,22 @@ fn decode_rect_split( }); } } - if chroma.is_none() { - // Diagnostic for the next caller that lands here (class - // refusal-names-a-correlate: the message names the tool, not the - // shape); the refusal below keeps its inventory-pinned wording. - eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx_w}x{tx_h} chroma={chroma_w}x{chroma_h}"); - } + } + // lane-av1-422blockhalf: the tiled arms below handle every shape this + // strip can carry (including the 4:2:2 BLOCK_INVALID planes), so the + // diagnostic names only the shapes that would actually refuse -- it used + // to fire for every tiled square too (the parent lane's `chroma=8x8` + // rows) and sent the next lane chasing handled shapes. + let chroma_tiled = chroma_422_oob + || matches!( + (chroma_w, chroma_h), + (64, 32) | (32, 64) | (64, 16) | (16, 64) | (32, 32) | (16, 16) | (8, 8) + ); + if !m.skip && chroma.is_none() && !chroma_tiled { + // Diagnostic for the next caller that lands here (class + // refusal-names-a-correlate: the message names the tool, not the + // shape); the refusal below keeps its inventory-pinned wording. + eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx_w}x{tx_h} chroma={chroma_w}x{chroma_h}"); } // lane-rectsplit r2 (verifier finding): with both callers wired // (`decode_block_rect`'s 32x16/16x32 and `decode_block_rect64`'s @@ -10273,7 +10298,6 @@ fn decode_rect_split( // (16x8 luma -> 8x8 chroma) -- the square rows below. At 4:2:0 and 4:4:4 a // rect strip's chroma is itself rect, so the square rows are unreachable // there and cannot change their results. - let chroma_tiled = matches!((chroma_w, chroma_h), (64, 32) | (32, 64) | (64, 16) | (16, 64) | (32, 32) | (16, 16) | (8, 8)); if !m.skip && chroma.is_none() && !chroma_tiled { return Err(unsupported( "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", @@ -10573,20 +10597,59 @@ fn decode_rect_split( (zero.clone(), zero) } else if m.skip { let zero = Grid::Zero(chroma_w * chroma_h); - if let Some((ub, _)) = &m.palette_uv { - set_palette_pred(ub.clone(), fctx); - } - push_intra_rect(1, - cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero, - m.alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, m.smooth_neighbor_uv, fctx, - ); - if let Some((_, vb)) = &m.palette_uv { - set_palette_pred(vb.clone(), fctx); + if chroma_422_oob { + // lane-av1-422blockhalf: libaom predicts an INTRA strip's chroma + // per transform unit even when the strip is skipped + // (`decode_token_recon_block`'s per-TU plane walk runs before the + // skip guard), so the BLOCK_INVALID plane predicts as (4, 8) + // units -- one whole-plane push here would ask the intra + // predictor for a 1:8 rect it never needs. + let (uw, uh) = (4usize, 8usize); + for plane_idx in 1..=2 { + if let Some((ub, vb)) = &m.palette_uv { + let buf = if plane_idx == 1 { ub } else { vb }; + set_palette_pred(buf.clone(), fctx); + } + for cu_row in 0..chroma_h / uh { + for cu_col in 0..chroma_w / uw { + push_intra_rect( + plane_idx, + cpx + cu_col * uw, + cpy + cu_row * uh, + uw, + uh, + m.uv_predict_mode, + m.angle_delta_uv, + reach, + &ZERO_RESIDUAL[..uw * uh], + m.alpha.zip(ac.clone()).map(|((au, av), ac)| { + ( + if plane_idx == 1 { au } else { av }, + ac, + ) + }), + None, + m.smooth_neighbor_uv, fctx, + ); + } + } + } + } else { + if let Some((ub, _)) = &m.palette_uv { + set_palette_pred(ub.clone(), fctx); + } + push_intra_rect(1, + cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero, + m.alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, m.smooth_neighbor_uv, fctx, + ); + if let Some((_, vb)) = &m.palette_uv { + set_palette_pred(vb.clone(), fctx); + } + push_intra_rect(2, + cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero, + m.alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, m.smooth_neighbor_uv, fctx, + ); } - push_intra_rect(2, - cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero, - m.alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, m.smooth_neighbor_uv, fctx, - ); (zero.clone(), zero) } else if lossless(fctx) { // lane-lossless: the strip's chroma plane block is coded as 4x4 @@ -10643,15 +10706,22 @@ fn decode_rect_split( let [ug, vg] = last; (ug, vg) } else if chroma_tiled { - let (uw, uh, set, scan): (usize, usize, TxbSet, &[u16]) = match (chroma_w, chroma_h) { - (64, 32) | (32, 64) | (32, 32) => (32, 32, TxbSet::Chroma32, default_scan(32)), - (64, 16) => (32, 16, TxbSet::ChromaRect32x16, &SCAN_32X16), - (16, 64) => (16, 32, TxbSet::ChromaRect32x16, &SCAN_16X32), - // lane-av1-422: the 4:2:2 square chroma planes (height unhalved), - // through the square reader like every other square chroma unit. - (16, 16) => (16, 16, TxbSet::Chroma16, default_scan(16)), - (8, 8) => (8, 8, TxbSet::Chroma8, default_scan(8)), - _ => unreachable!("chroma_tiled"), + let (uw, uh, set, scan): (usize, usize, TxbSet, &[u16]) = if chroma_422_oob { + // lane-av1-422blockhalf: the BLOCK_INVALID-plane strip's (4, 8) + // units -- the Release oracle's out-of-bounds + // `max_txsize_rect_lookup[BLOCK_INVALID]` byte (see above). + (4, 8, TxbSet::ChromaRect8x4, &SCAN_4X8) + } else { + match (chroma_w, chroma_h) { + (64, 32) | (32, 64) | (32, 32) => (32, 32, TxbSet::Chroma32, default_scan(32)), + (64, 16) => (32, 16, TxbSet::ChromaRect32x16, &SCAN_32X16), + (16, 64) => (16, 32, TxbSet::ChromaRect32x16, &SCAN_16X32), + // lane-av1-422: the 4:2:2 square chroma planes (height unhalved), + // through the square reader like every other square chroma unit. + (16, 16) => (16, 16, TxbSet::Chroma16, default_scan(16)), + (8, 8) => (8, 8, TxbSet::Chroma8, default_scan(8)), + _ => unreachable!("chroma_tiled"), + } }; // lane-av1-422: the witness counter, keyed to ss (1,0) so only a 4:2:2 // frame's square chroma units count it. @@ -10660,7 +10730,15 @@ fn decode_rect_split( } let (nw, nh) = (chroma_w / uw, chroma_h / uh); let bigger = chroma_w * chroma_h > uw * uh; - let default_tx = TxType::DctDct; + // `av1_get_ext_tx_set_type`: a chroma transform whose square-up size + // is TX_32X32 or bigger resolves to `EXT_TX_SET_DCTONLY` for intra; + // smaller rect units (the 4:2:2 BLOCK_INVALID-plane (4, 8)s) take the + // mode-indexed default, the same rule the unsplit arm below applies. + let default_tx = if uw.max(uh) >= 32 { + TxType::DctDct + } else { + default_intra_tx_type(m.uv_predict_mode as u8) + }; let mut last = [Grid::Zero(uw * uh), Grid::Zero(uw * uh)]; for plane_idx in 1..=2 { for cu_row in 0..nh { @@ -10671,7 +10749,17 @@ fn decode_rect_split( mi_r + cu_row * (luma_span_y / MI), mi_c + cu_col * (luma_span_x / MI), ); - let cu_around = neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y); + // lane-av1-422blockhalf: the 4:2:2 (4, 8) units read their + // chroma context per chroma cell + // ([`Neighbours::around_mi_422_chroma`], the block-8 + // rule) -- the plain rect walk samples one chroma cell + // twice at ss_x 1. Every pre-existing shape keeps its own + // walk. + let cu_around = if chroma_422_oob { + neighbours.around_mi_422_chroma(cu_mi, luma_span_x, luma_span_y) + } else { + neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y) + }; let (cu_x, cu_y) = (cpx + cu_col * uw, cpy + cu_row * uh); let cfl = m.alpha.map(|(au, av)| { let alpha = if plane_idx == 1 { au } else { av }; @@ -23228,6 +23316,12 @@ fn read_inter_rect_chroma( let (nx, ny) = (write_chroma_w / uw, write_chroma_h / uh); let multi = nx * ny > 1; let set = rect_inter_chroma_set(uw, uh)?; + // lane-av1-422blockhalf: the assembled block grid is the PRED stride x + // the plane's true height -- at 4:2:2 a square block's plane is + // (side/2, side), so the old `chroma_side`-square sizing under-allocated + // every row past `chroma_stride` once the caller began passing the + // per-axis stride. + let assembled_h = write_chroma_h.max(chroma_side); let mut assembled: [Vec; 2] = [Vec::new(), Vec::new()]; // The multi-unit stamps below are rewritten by the caller's whole-block // record (`record_rect_mi`/`record_split_luma_rect_mi` write ONE @@ -23239,8 +23333,8 @@ fn read_inter_rect_chroma( if multi { hit!(CHROMA_SPLIT_TX_HITS); assembled = [ - vec![0i32; chroma_side * chroma_side], - vec![0i32; chroma_side * chroma_side], + vec![0i32; chroma_side * assembled_h], + vec![0i32; chroma_side * assembled_h], ]; } for plane_idx in 1..=2 { @@ -23291,7 +23385,12 @@ fn read_inter_rect_chroma( } units.push((cu_mi, plane_idx, cu_grid, span_x, span_y)); } else { - assembled[plane_idx - 1] = embed_rect_grid(&cu_grid, uw, uh, chroma_side); + let mut full = vec![0i32; chroma_side * assembled_h]; + for rr in 0..uh { + full[rr * chroma_side..][..uw] + .copy_from_slice(&cu_grid[rr * uw..][..uw]); + } + assembled[plane_idx - 1] = full; } } } @@ -31827,6 +31926,20 @@ fn decode_inter_block( } _ => (write_w >> ss_x(fctx), write_h >> ss_y(fctx)), }; + // lane-av1-422blockhalf: the chroma PREDICTION buffers take the PLANE + // BLOCK's own per-axis shape at 4:2:2 -- (side/2, side) -- instead of the + // enclosing square `chroma_side` the pre-port model indexed, and the + // masked-compound blend reads its luma mask through the plane's real + // subsampling shifts (aom_dsp/blend-a64-mask.c's four branches; the + // stop-note this lane owns). Every consumer below strides with + // `chroma_stride`. At 4:2:0 and 4:4:4 both values reduce to the square + // `chroma_side` verbatim, so only 4:2:2 changes shape. + let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0; + let (chroma_stride, chroma_buf_h) = if chroma_422 { + (write_chroma_w, write_chroma_h) + } else { + (chroma_side, chroma_side) + }; let (chroma_set, chroma_tx, scan_chroma) = if ss_x(fctx) == 0 && ss_y(fctx) == 0 && strip_chroma.is_none() { let tx = if side >= 64 { 32 } else { side }; @@ -32708,7 +32821,7 @@ fn decode_inter_block( mc::combine_compound(&inter0_y, &inter1_y, fwd_offset, bck_offset, &mut pred_y, fctx); } - let mut inter0_u = vec![0i32; chroma_side * chroma_side]; + let mut inter0_u = vec![0i32; chroma_stride * chroma_buf_h]; mc::predict_compound_intermediate_kern( &pu0.data, pu0.width, @@ -32717,8 +32830,8 @@ fn decode_inter_block( mv_to_q4(cpx, mv0.1, ss_x(fctx)), mv_to_q4(cpy, mv0.0, ss_x(fctx)), scale0, - chroma_side, - chroma_side, + chroma_stride, + chroma_buf_h, write_chroma_w, write_chroma_h, h_filter, @@ -32732,11 +32845,11 @@ fn decode_inter_block( crate::warp::warp_affine_compound( wp, &pu0.data, pu0.true_width as i32, pu0.true_height as i32, pu0.width as i32, &mut inter0_u, cpx as i32, cpy as i32, - chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, + chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, ); } } - let mut inter1_u = vec![0i32; chroma_side * chroma_side]; + let mut inter1_u = vec![0i32; chroma_stride * chroma_buf_h]; mc::predict_compound_intermediate_kern( &pu1.data, pu1.width, @@ -32745,8 +32858,8 @@ fn decode_inter_block( mv_to_q4(cpx, mv1.1, ss_x(fctx)), mv_to_q4(cpy, mv1.0, ss_x(fctx)), scale1, - chroma_side, - chroma_side, + chroma_stride, + chroma_buf_h, write_chroma_w, write_chroma_h, h_filter, @@ -32760,35 +32873,33 @@ fn decode_inter_block( crate::warp::warp_affine_compound( wp, &pu1.data, pu1.true_width as i32, pu1.true_height as i32, pu1.width as i32, &mut inter1_u, cpx as i32, cpy as i32, - chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, + chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, ); } } - let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_side * chroma_side); + let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_stride * chroma_buf_h); if let Some(mask_y) = mask_y { - // lane-av1-422sub8rect stop-note: this fn's 4:2:2 chroma - // prediction is still the square-cut model (the owning - // parent-lane surface) -- its buffer is `chroma_side`-square - // and cannot be indexed by the subsampled-axis mask walks, - // so at ss_x != ss_y the blend keeps the direct - // luma-resolution read (the pre-port behaviour, known - // divergent there) until that surface itself is ported. + // lane-av1-422blockhalf: the blend walks this plane's own + // (chroma_stride x chroma_buf_h) rect through the plane's + // real subsampling shifts -- the mask read is aom_dsp/ + // blend-a64-mask.c's `(1, 0)` branch at 4:2:2, the direct + // luma sample at 4:2:0/4:4:4. mc::blend_masked_compound( &inter0_u, &inter1_u, mask_y, side, - chroma_side, - chroma_side, - if ss_x(fctx) == ss_y(fctx) { ss_x(fctx) } else { 0 }, - if ss_x(fctx) == ss_y(fctx) { ss_y(fctx) } else { 0 }, + chroma_stride, + chroma_buf_h, + ss_x(fctx), + ss_y(fctx), &mut pred_u, fctx, ); } else { mc::combine_compound(&inter0_u, &inter1_u, fwd_offset, bck_offset, &mut pred_u, fctx); } - let mut inter0_v = vec![0i32; chroma_side * chroma_side]; + let mut inter0_v = vec![0i32; chroma_stride * chroma_buf_h]; mc::predict_compound_intermediate_kern( &pv0.data, pv0.width, @@ -32797,8 +32908,8 @@ fn decode_inter_block( mv_to_q4(cpx, mv0.1, ss_x(fctx)), mv_to_q4(cpy, mv0.0, ss_x(fctx)), scale0, - chroma_side, - chroma_side, + chroma_stride, + chroma_buf_h, write_chroma_w, write_chroma_h, h_filter, @@ -32812,11 +32923,11 @@ fn decode_inter_block( crate::warp::warp_affine_compound( wp, &pv0.data, pv0.true_width as i32, pv0.true_height as i32, pv0.width as i32, &mut inter0_v, cpx as i32, cpy as i32, - chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, + chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, ); } } - let mut inter1_v = vec![0i32; chroma_side * chroma_side]; + let mut inter1_v = vec![0i32; chroma_stride * chroma_buf_h]; mc::predict_compound_intermediate_kern( &pv1.data, pv1.width, @@ -32825,8 +32936,8 @@ fn decode_inter_block( mv_to_q4(cpx, mv1.1, ss_x(fctx)), mv_to_q4(cpy, mv1.0, ss_x(fctx)), scale1, - chroma_side, - chroma_side, + chroma_stride, + chroma_buf_h, write_chroma_w, write_chroma_h, h_filter, @@ -32840,28 +32951,26 @@ fn decode_inter_block( crate::warp::warp_affine_compound( wp, &pv1.data, pv1.true_width as i32, pv1.true_height as i32, pv1.width as i32, &mut inter1_v, cpx as i32, cpy as i32, - chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, + chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, ); } } - let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_side * chroma_side); + let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_stride * chroma_buf_h); if let Some(mask_y) = mask_y { - // lane-av1-422sub8rect stop-note: this fn's 4:2:2 chroma - // prediction is still the square-cut model (the owning - // parent-lane surface) -- its buffer is `chroma_side`-square - // and cannot be indexed by the subsampled-axis mask walks, - // so at ss_x != ss_y the blend keeps the direct - // luma-resolution read (the pre-port behaviour, known - // divergent there) until that surface itself is ported. + // lane-av1-422blockhalf: the blend walks this plane's own + // (chroma_stride x chroma_buf_h) rect through the plane's + // real subsampling shifts -- the mask read is aom_dsp/ + // blend-a64-mask.c's `(1, 0)` branch at 4:2:2, the direct + // luma sample at 4:2:0/4:4:4. mc::blend_masked_compound( &inter0_v, &inter1_v, mask_y, side, - chroma_side, - chroma_side, - if ss_x(fctx) == ss_y(fctx) { ss_x(fctx) } else { 0 }, - if ss_x(fctx) == ss_y(fctx) { ss_y(fctx) } else { 0 }, + chroma_stride, + chroma_buf_h, + ss_x(fctx), + ss_y(fctx), &mut pred_v, fctx, ); } else { @@ -32877,8 +32986,8 @@ fn decode_inter_block( push_pred(fctx, build); ( Pred::Cur { plane: 0, stride: side, off: 0 }, - Pred::Cur { plane: 1, stride: chroma_side, off: 0 }, - Pred::Cur { plane: 2, stride: chroma_side, off: 0 }, + Pred::Cur { plane: 1, stride: chroma_stride, off: 0 }, + Pred::Cur { plane: 2, stride: chroma_stride, off: 0 }, ) } else { let mut built: [Vec; 3] = Default::default(); @@ -32887,8 +32996,8 @@ fn decode_inter_block( (pred_y, pred_u, pred_v) = (by, bu, bv); ( Pred::Inline(&pred_y, side), - Pred::Inline(&pred_u, chroma_side), - Pred::Inline(&pred_v, chroma_side), + Pred::Inline(&pred_u, chroma_stride), + Pred::Inline(&pred_v, chroma_stride), ) }; @@ -32929,24 +33038,24 @@ fn decode_inter_block( push_mc_rect(1, cpx, cpy, - chroma_side, + chroma_stride, write_chroma_w, write_chroma_h, su, - &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx, + &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx, ); push_mc_rect(2, cpx, cpy, - chroma_side, + chroma_stride, write_chroma_w, write_chroma_h, sv, - &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx, + &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx, ); luma_grid = Grid::Zero(side * side); - u_grid = Grid::Zero(chroma_side * chroma_side); - v_grid = Grid::Zero(chroma_side * chroma_side); + u_grid = Grid::Zero(chroma_stride * chroma_buf_h); + v_grid = Grid::Zero(chroma_stride * chroma_buf_h); } else { // lane-inter4 r2: a rect strip's coefficient context spans its // OWN width above and height left -- reading `side` cells both @@ -33277,12 +33386,12 @@ fn decode_inter_block( // root a rect (128x64/64x128) block's chroma is per mu // chunk too, so this test comes BEFORE the `rect_tu` one. u_grid = if u_units.is_empty() { - Grid::Zero(chroma_side * chroma_side) + Grid::Zero(chroma_stride * chroma_buf_h) } else { Grid::Own(std::mem::take(&mut u_units)) }; v_grid = if v_units.is_empty() { - Grid::Zero(chroma_side * chroma_side) + Grid::Zero(chroma_stride * chroma_buf_h) } else { Grid::Own(std::mem::take(&mut v_units)) }; @@ -33293,7 +33402,7 @@ fn decode_inter_block( read_inter_chroma_lossless( dec, cdfs, neighbours, u, v, su, sv, at_mi, (cpx, cpy), (0, 0), (write_chroma_w, write_chroma_h), - (write_chroma_w, write_chroma_h), chroma_side, + (write_chroma_w, write_chroma_h), chroma_stride, mode_for_tx, base_q_idx, &mut uo, &mut vo, fctx, )?; let zero = chroma_side * chroma_side; @@ -33328,7 +33437,7 @@ fn decode_inter_block( at_mi, (cpx, cpy), (write_chroma_w, write_chroma_h), - chroma_side, + chroma_stride, mode_for_tx, luma_tx_type, fctx, )?; @@ -34107,7 +34216,7 @@ fn decode_inter_block( side, write_w, write_h, - chroma_side, + chroma_stride, px, py, cpx, @@ -34129,8 +34238,8 @@ fn decode_inter_block( return; }; let mut pred_y = refill(std::mem::take(&mut out[0]), side * side); - let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_side * chroma_side); - let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_side * chroma_side); + let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_stride * chroma_buf_h); + let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_stride * chroma_buf_h); if luma_scale == mc::REF_NO_SCALE { mc::predict_with_filters_kern( &py_ref.data, @@ -34154,8 +34263,8 @@ fn decode_inter_block( pu_ref.true_height, mv_to_q4(cpx, mv.1, ss_x(fctx)), mv_to_q4(cpy, mv.0, ss_x(fctx)), - chroma_side, - chroma_side, + chroma_stride, + chroma_buf_h, write_chroma_w, write_chroma_h, h_filter, @@ -34169,8 +34278,8 @@ fn decode_inter_block( pv_ref.true_height, mv_to_q4(cpx, mv.1, ss_x(fctx)), mv_to_q4(cpy, mv.0, ss_x(fctx)), - chroma_side, - chroma_side, + chroma_stride, + chroma_buf_h, write_chroma_w, write_chroma_h, h_filter, @@ -34202,8 +34311,8 @@ fn decode_inter_block( mv_to_q4(cpx, mv.1, ss_x(fctx)), mv_to_q4(cpy, mv.0, ss_x(fctx)), luma_scale, - chroma_side, - chroma_side, + chroma_stride, + chroma_buf_h, write_chroma_w, write_chroma_h, h_filter, @@ -34218,8 +34327,8 @@ fn decode_inter_block( mv_to_q4(cpx, mv.1, ss_x(fctx)), mv_to_q4(cpy, mv.0, ss_x(fctx)), luma_scale, - chroma_side, - chroma_side, + chroma_stride, + chroma_buf_h, write_chroma_w, write_chroma_h, h_filter, @@ -34259,13 +34368,11 @@ fn decode_inter_block( if warp_plane_allowed(write_chroma_w, write_chroma_h) { crate::warp::warp_affine( params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32, - pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32, - chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, + pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, ); crate::warp::warp_affine( params, &pv_ref.data, pv_ref.true_width as i32, pv_ref.true_height as i32, - pv_ref.width as i32, &mut pred_v, cpx as i32, cpy as i32, chroma_side as i32, - chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, + pv_ref.width as i32, &mut pred_v, cpx as i32, cpy as i32, chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, ); } } @@ -34279,11 +34386,11 @@ fn decode_inter_block( } interintra_blend(y, px, py, write_w, write_h, side, 0, 0, ii, wedge_mask, &mut pred_y, fctx); interintra_blend( - u, cpx, cpy, write_chroma_w, write_chroma_h, chroma_side, ss_x(fctx), + u, cpx, cpy, write_chroma_w, write_chroma_h, chroma_stride, ss_x(fctx), ss_y(fctx), ii, wedge_mask, &mut pred_u, fctx, ); interintra_blend( - v, cpx, cpy, write_chroma_w, write_chroma_h, chroma_side, ss_x(fctx), + v, cpx, cpy, write_chroma_w, write_chroma_h, chroma_stride, ss_x(fctx), ss_y(fctx), ii, wedge_mask, &mut pred_v, fctx, ); } @@ -34322,7 +34429,7 @@ fn decode_inter_block( &mut piece, fctx, ); for row in 0..piece_h { - dst[row * chroma_side..row * chroma_side + piece_w] + dst[row * chroma_stride..row * chroma_stride + piece_w] .copy_from_slice(&piece[row * piece_w..(row + 1) * piece_w]); } } @@ -34347,8 +34454,8 @@ fn decode_inter_block( push_pred(fctx, build); ( Pred::Cur { plane: 0, stride: side, off: 0 }, - Pred::Cur { plane: 1, stride: chroma_side, off: 0 }, - Pred::Cur { plane: 2, stride: chroma_side, off: 0 }, + Pred::Cur { plane: 1, stride: chroma_stride, off: 0 }, + Pred::Cur { plane: 2, stride: chroma_stride, off: 0 }, ) } else { if interintra_mode.is_some() { @@ -34372,8 +34479,8 @@ fn decode_inter_block( // through to the ordinary whole-block predictor. ( Pred::Inline(&pred_y, side), - Pred::Inline(&pred_u, chroma_side), - Pred::Inline(&pred_v, chroma_side), + Pred::Inline(&pred_u, chroma_stride), + Pred::Inline(&pred_v, chroma_stride), ) }; @@ -34418,25 +34525,25 @@ fn decode_inter_block( push_mc_rect(1, cpx, cpy, - chroma_side, + chroma_stride, write_chroma_w, write_chroma_h, su, - &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx, + &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx, ); push_mc_rect(2, cpx, cpy, - chroma_side, + chroma_stride, write_chroma_w, write_chroma_h, sv, - &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx, + &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx, ); } luma_grid = Grid::Zero(side * side); - u_grid = Grid::Zero(chroma_side * chroma_side); - v_grid = Grid::Zero(chroma_side * chroma_side); + u_grid = Grid::Zero(chroma_stride * chroma_buf_h); + v_grid = Grid::Zero(chroma_stride * chroma_buf_h); } else { // lane-inter4 r2: a rect strip's coefficient context spans its // OWN width above and height left -- reading `side` cells both @@ -34781,19 +34888,19 @@ fn decode_inter_block( // `reconstruct_inter_block`'s `for (plane...)` guarded by // `xd->is_chroma_ref`) codes NO chroma transform here, so // neither symbol nor context exists. - u_grid = Grid::Zero(chroma_side * chroma_side); - v_grid = Grid::Zero(chroma_side * chroma_side); + u_grid = Grid::Zero(chroma_stride * chroma_buf_h); + v_grid = Grid::Zero(chroma_stride * chroma_buf_h); } else if side > 64 { // Already read inside the mu-chunk loop above -- at the 128 // root a rect (128x64/64x128) block's chroma is per mu // chunk too, so this test comes BEFORE the `rect_tu` one. u_grid = if u_units.is_empty() { - Grid::Zero(chroma_side * chroma_side) + Grid::Zero(chroma_stride * chroma_buf_h) } else { Grid::Own(std::mem::take(&mut u_units)) }; v_grid = if v_units.is_empty() { - Grid::Zero(chroma_side * chroma_side) + Grid::Zero(chroma_stride * chroma_buf_h) } else { Grid::Own(std::mem::take(&mut v_units)) }; @@ -34804,7 +34911,7 @@ fn decode_inter_block( read_inter_chroma_lossless( dec, cdfs, neighbours, u, v, su, sv, at_mi, (cpx, cpy), (0, 0), (write_chroma_w, write_chroma_h), - (write_chroma_w, write_chroma_h), chroma_side, + (write_chroma_w, write_chroma_h), chroma_stride, mode_for_tx, base_q_idx, &mut uo, &mut vo, fctx, )?; let zero = chroma_side * chroma_side; @@ -34836,7 +34943,7 @@ fn decode_inter_block( at_mi, (cpx, cpy), (write_chroma_w, write_chroma_h), - chroma_side, + chroma_stride, mode_for_tx, luma_tx_type, fctx, )?; @@ -35541,12 +35648,12 @@ fn decode_inter_block( // Chroma is already coded and reconstructed per mu chunk above. luma_grid = Grid::Zero(side * side); u_grid = if u_units.is_empty() { - Grid::Zero(chroma_side * chroma_side) + Grid::Zero(chroma_stride * chroma_buf_h) } else { Grid::Own(std::mem::take(&mut u_units)) }; v_grid = if v_units.is_empty() { - Grid::Zero(chroma_side * chroma_side) + Grid::Zero(chroma_stride * chroma_buf_h) } else { Grid::Own(std::mem::take(&mut v_units)) }; @@ -37700,6 +37807,28 @@ fn decode_inter_sub8_rect2( // there is no shared group unit (aomdec EC_COEFF on // `av1-profile1-444.ivf` decode-order frame 1, mi (3,8)). let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0; + // lane-av1-422blockhalf: at ss (1,0) the chroma reference is PER PIECE + // too, keyed by `is_chroma_reference`'s own terms: an 8x4 HORZ piece is + // 2 mi wide (`!(bw & 1)`), so BOTH pieces of the group are references; + // a 4x8 VERT piece is 1 mi wide, so only the ODD-column piece is + // (`mi_col & 1`) -- measured on the pinned t422 fixture frame 1: the + // horz group at mi (8,10)/(9,10) reads U+V TX_4X4 after EACH piece's + // luma (rng 37134/37852 then 63752/50952), and the vert group at + // (3,10)/(3,11) reads U+V on the odd-column piece (3,11) alone. The old + // `i == 1` rule coded the group's chroma on the wrong piece (and, for + // horz, half of the units) and desynced frame 1 at (8,10)'s uv_mode. + let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0; + // 4:4:4: every piece. 4:2:2: both horz pieces, the odd-column vert piece. + // 4:2:0 keeps its existing second-piece model untouched. + let piece_is_chroma_ref = |i: usize| -> bool { + if ss_x(fctx) == 0 && ss_y(fctx) == 0 { + true + } else if chroma_422 { + !vert || ((gc + i) & 1) == 1 + } else { + i == 1 + } + }; // This piece's first transform's luma `tx_type` (libaom `mbmi->tx_type`): // an inter block's chroma plane never codes its own symbol but inherits // the colocated luma type (`av1_get_tx_type`, blockd.h:1291). @@ -37760,7 +37889,7 @@ fn decode_inter_sub8_rect2( "EC_SUB8INTRA shape={}x{} sub={i} has_chroma={} skip={skip} mi={rmi},{cmi} tx_select={}", bw, bh, - i == 1, + piece_is_chroma_ref(i), fctx.tx_select_inter.with(std::cell::Cell::get), ); } @@ -37778,7 +37907,7 @@ fn decode_inter_sub8_rect2( group_mi, lmi, (bw, bh), - chroma_444 || i == 1, + piece_is_chroma_ref(i), skip, scan4, y, @@ -37789,7 +37918,7 @@ fn decode_inter_sub8_rect2( fctx.tx_select_inter.with(std::cell::Cell::get), reduced_tx_set, fctx, )?; - if i == 1 { + if piece_is_chroma_ref(i) { intra_chroma = true; } continue; @@ -38199,6 +38328,166 @@ fn decode_inter_sub8_rect2( neighbours.record_mi_chroma(lmi, bw, bh, 1, &ug); neighbours.record_mi_chroma(lmi, bw, bh, 2, &vg); } + // lane-av1-422blockhalf: the 4:2:2 per-piece arm. The chroma + // reference piece codes its own U and V TX_4X4 units right after its + // luma -- both pieces of a horz group, the odd-column piece of a + // vert one (see `piece_is_chroma_ref` above; measured on the pinned + // t422 fixture frame 1, horz group (8,10)/(9,10) and vert group + // (3,10)/(3,11)). The unit anchors at the FLOORED chroma cell + // (`av1_setup_dst_planes`' `(mi_col & !1) * MI >> ss_x`, the + // lane-av1-422kf2 rule) and reads through + // [`Neighbours::around_mi_422_chroma`]'s per-chroma-cell context. + // A horz piece IS 4x4 chroma (8 luma wide, ss_y 0): its unit + // predicts whole from its own mv/filters. A vert piece is 2 chroma + // px wide, so its 4-px unit predicts in halves -- + // `build_inter_predictors_sub8x8`'s rule: the left 2x4 from the + // piece to the LEFT (the group's own left piece, or the decoded + // neighbour when the group starts on an odd column), the right 2x4 + // from this piece. A skipped reference piece still predicts (spec + // 7.11.3) but codes no coefficients. + } else if chroma_422 && piece_is_chroma_ref(i) { + const B4: usize = 4; + let (pc_ref, pc_mv, pc_hf, pc_vf) = piece[i].expect("inter piece recorded above"); + let unit_x = ((lmi.1 & !1) * MI) >> ss_x(fctx); + let unit_y = py; + // The left 2x4 half's source: the in-group left piece when this + // piece is the group's second, else the decoded neighbour one mi + // to the left (an odd-column group start). Its interp filters + // are not on the mi grid, so an outside neighbour borrows this + // piece's own. + let left_piece = if i > 0 { + piece[i - 1] + } else if lmi.1 > 0 { + grid.get(rmi, lmi.1 - 1).filter(|mi| mi.is_inter).map( + |mi| { + ( + mi.ref_frame, + (i32::from(mi.mv.0), i32::from(mi.mv.1)), + pc_hf, + pc_vf, + ) + }, + ) + } else { + None + }; + let build_c = move |_y: &mut PlaneBuf<'static>, + _u: &mut PlaneBuf<'static>, + _v: &mut PlaneBuf<'static>, + fctx: &crate::decode::FrameCtx, + out: &mut [Vec; 3]| { + let Some((pc_ref_y, sref_u, sref_v)) = ref_planes_deferred(pc_ref, refpix) else { + return; + }; + let pc_scale = mc::scale_factor(pc_ref_y.width, frame_width); + let mut pred_u = refill(std::mem::take(&mut out[1]), B4 * B4); + let mut pred_v = refill(std::mem::take(&mut out[2]), B4 * B4); + for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] { + let mut buf = vec![0u16; B4 * B4]; + if vert { + // Right 2x4 half: this piece's own ref/mv/filters. + let mut half = vec![0u16; 2 * 4]; + mc::predict_maybe_scaled( + &plane.data, + plane.width, + plane.true_width, + plane.true_height, + mv_to_q4(unit_x + 2, pc_mv.1, ss_x(fctx)), + mv_to_q4(unit_y, pc_mv.0, ss_y(fctx)), + pc_scale, + 2, + 4, + pc_hf, + pc_vf, + &mut half, fctx, + ); + for row in 0..4 { + buf[row * B4 + 2..row * B4 + 4] + .copy_from_slice(&half[row * 2..row * 2 + 2]); + } + // Left 2x4 half: the piece to the left (an + // intra/off-frame neighbour reduces to whole-from-own, + // `is_sub8x8_inter`'s rule). + let (l_ref, l_mv, l_hf, l_vf) = match left_piece { + Some((l_ref, l_mv, l_hf, l_vf)) => (l_ref, l_mv, l_hf, l_vf), + None => (pc_ref, pc_mv, pc_hf, pc_vf), + }; + let Some((l_y, l_u, _)) = ref_planes_deferred(l_ref, refpix) else { + continue; + }; + mc::predict_maybe_scaled( + &l_u.data, + l_u.width, + l_u.true_width, + l_u.true_height, + mv_to_q4(unit_x, l_mv.1, ss_x(fctx)), + mv_to_q4(unit_y, l_mv.0, ss_y(fctx)), + mc::scale_factor(l_y.width, frame_width), + 2, + 4, + l_hf, + l_vf, + &mut half, fctx, + ); + for row in 0..4 { + buf[row * B4..row * B4 + 2] + .copy_from_slice(&half[row * 2..row * 2 + 2]); + } + } else { + mc::predict_maybe_scaled( + &plane.data, + plane.width, + plane.true_width, + plane.true_height, + mv_to_q4(unit_x, pc_mv.1, ss_x(fctx)), + mv_to_q4(unit_y, pc_mv.0, ss_y(fctx)), + pc_scale, + B4, + B4, + pc_hf, + pc_vf, + &mut buf, fctx, + ); + } + dst.copy_from_slice(&buf); + } + out[1] = pred_u; + out[2] = pred_v; + }; + let (pred_cu, pred_cv): (Vec, Vec); + let (su, sv) = if recon_deferred(fctx) { + push_pred(fctx, build_c); + ( + Pred::Cur { plane: 1, stride: B4, off: 0 }, + Pred::Cur { plane: 2, stride: B4, off: 0 }, + ) + } else { + let mut built: [Vec; 3] = Default::default(); + build_c(y, u, v, fctx, &mut built); + let [_, bu, bv] = built; + (pred_cu, pred_cv) = (bu, bv); + (Pred::Inline(&pred_cu, B4), Pred::Inline(&pred_cv, B4)) + }; + let ctx_mi = (lmi.0, lmi.1 & !1); + let ca = neighbours.around_mi_422_chroma(ctx_mi, 8, 4); + if skip { + push_mc(1, unit_x, unit_y, B4, su, &ZERO_RESIDUAL[..B4 * B4], fctx); + push_mc(2, unit_x, unit_y, B4, sv, &ZERO_RESIDUAL[..B4 * B4], fctx); + neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]); + neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]); + } else { + hit!(CHROMA422_INTER_SUB8_HITS); + let (ug, _) = read_inter_plane( + dec, cdfs, TxbSet::Chroma4, scan4, 1, ca[1], 0, u, unit_x, unit_y, B4, + base_q_idx, su, Some(piece_tx_type), None, fctx, + )?; + let (vg, _) = read_inter_plane( + dec, cdfs, TxbSet::Chroma4, scan4, 2, ca[2], 0, v, unit_x, unit_y, B4, + base_q_idx, sv, Some(piece_tx_type), None, fctx, + )?; + neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ug); + neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &vg); + } } neighbours.record_mode_mi(rmi, cmi, w_mi, h_mi, DC_PRED); neighbours.record_inter_rect_mi(lmi, w_mi, h_mi, skip, true, ref_frame, resolved_filter, false); @@ -38220,8 +38509,10 @@ fn decode_inter_sub8_rect2( // `uv_predict_mode`, and this DC stamp ran after it and flattened the // mi-exact cell (class `override-slot-on-one-arm`, this lane's own // 10-bit film gate regression at 1ad7e0fc; port of lane-av1-cfl's - // 7c6dad53). - if !chroma_444 && !intra_chroma { + // 7c6dad53). lane-av1-422blockhalf: 4:2:2 never takes it either -- the + // group unit does not exist there; every chroma-reference piece coded + // (and recorded) its own unit inside the loop above. + if !chroma_444 && !chroma_422 && !intra_chroma { neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED); } // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map @@ -38235,7 +38526,10 @@ fn decode_inter_sub8_rect2( record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]); // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded // and reconstructed the group's one chroma unit itself. - if !chroma_444 && !intra_chroma { + // lane-av1-422blockhalf: 4:2:2 never runs this tail -- the shared group + // unit does not exist at ss (1,0); each chroma-reference piece coded its + // own U/V TX_4X4 inside the loop above, exactly like the 4:4:4 arm. + if !chroma_444 && !chroma_422 && !intra_chroma { // The group's single 4x4 chroma unit per plane, on the chroma-reference // (second) sub-block's own skip flag. const B4: usize = 4; diff --git a/lanes/av1422blockhalf.report.md b/lanes/av1422blockhalf.report.md new file mode 100644 index 00000000..eed75c47 --- /dev/null +++ b/lanes/av1422blockhalf.report.md @@ -0,0 +1,133 @@ +# lane-av1-422blockhalf — `decode_inter_block`'s 4:2:2 chroma half ported to the +# per-axis plane-block model (per-axis pred buffers + real-subsampling masked +# compound blend), the `EC_RECTCHROMA_GAP` 16x8 / 8x32 chroma shapes coded as +# the (4, 8) unit tiling the Release oracle's OOB `max_txsize_rect_lookup[ +# BLOCK_INVALID]` byte produces, and `decode_inter_sub8_rect2`'s has_chroma +# gating moved from `i == 1` to the per-piece `is_chroma_reference` rule; +# frame 0 stays byte-exact at PREFILT/POSTDEB/POSTCDEF, all 16 frames now +# decode (the frame-11 `(4, 32)` refusal is gone), and the inter-frame +# divergence is REMEASURED and REATTRIBUTED to a partition-dispatch defect +# upstream of the chroma half (ours dispatches SPLIT4 where the oracle codes +# HORZ at mi(8,10)) — frame exactness NOT claimed for frames 1+ + +## Outcome + +1. `decode_inter_block`'s chroma PREDICTION buffers (compound and + single-ref arms, OBMC plan, interintra stride, skip pushes, su/sv Pred + strides, the `read_inter_rect_chroma`/`read_inter_chroma_lossless` pred + strides) are keyed to the PLANE BLOCK's own per-axis shape at ss (1, 0): + `(chroma_stride, chroma_buf_h) = (write_chroma_w, write_chroma_h)` + instead of the enclosing square `chroma_side`. The two masked-compound + blend sites now pass the plane's REAL subsampling shifts — the + stop-note's pre-port direct luma-resolution mask read is gone + (aom_dsp/blend-a64-mask.c's `(1, 0)` branch at 4:2:2). Every replaced + expression reduces to the parent values at 4:2:0/4:4:4 + (`chroma_stride == chroma_buf_h == chroma_side` there), byte-identical + by construction. +2. `read_inter_rect_chroma` now takes the per-axis stride correctly: its + assembled block grid is `stride x plane-height` (`assembled_h`), the + single-unit embed included — the old square `chroma_side * chroma_side` + allocation panicked (`range end index 20 out of range for slice of + length 16`) the moment the per-axis stride reached it. +3. `decode_rect_split`'s 4:2:2 BLOCK_INVALID chroma planes: the tall/wide + 1:2 and 1:4 strips (`8x16, 16x32, 32x64, 8x32, 16x64`, + `64x128` for + 128-SB streams) have NO chroma plane block + (`av1_ss_size_lookup[...][1][0] == BLOCK_INVALID`); the plane is still + coded, tiled into (4, 8) rect units — the Release oracle's + out-of-bounds `max_txsize_rect_lookup[BLOCK_INVALID]` byte is TX_4X8 + (lane-av1-422m's measurement), and `decode_token_recon_block` steps the + plane in that unit shape. Units read `TxbSet::ChromaRect8x4`/`SCAN_4X8` + with `around_mi_422_chroma` ctx, mode-indexed intra tx type (the + `< 32` square-up rule, pre-existing rect units unchanged at DctDct), + per-unit stamps + units replay. SKIP strips predict per (4, 8) unit as + well (`decode_token_recon_block`'s per-TU plane walk runs before the + skip guard) — the old single whole-plane zero push asked the intra + predictor for a 1:8 rect (`dc_rect_multiplier` panic, bw=8 bh=64). + `EC_RECTCHROMA_GAP` now prints only truly-unhandled shapes (it used to + misfire on every tiled square — the parent lane's `chroma=8x8` rows); + it prints ZERO times on the fixture now. `chroma422_chunk` = 344 on the + full fixture (new units provably fire). +4. `decode_inter_sub8_rect2`'s has_chroma gating: per-piece + `is_chroma_reference` — 4:4:4 every piece, 4:2:2 both horz pieces + (`!(bw & 1)`) / the odd-column vert piece (`mi_col & 1`), 4:2:0 keeps + `i == 1` verbatim. The inter pieces take a per-piece inline chroma arm + at 4:2:2 (U then V TX_4X4 at the floored cell, `around_mi_422_chroma` + ctx, inherited piece tx type; horz predicts whole-from-own mv, vert + predicts halves `build_inter_predictors_sub8x8`-style, left half from + the in-group left piece or the decoded grid neighbour when the group + starts on an odd column — filters unavailable on the grid, so an + outside neighbour borrows this piece's filters). The 4:2:0 group tail + (and the group DC stamp) are gated off at 4:2:2. +5. MEASURED (17-frame probe, per-OBU cut harness `/tmp/i422/cut_frames.py`, + comparator ours-padded-u8-cropped vs instrumented + `$HOME/.cache/aom-oracle/build` aomdec-cropped-u8; fixture `/tmp/t422.obu` + sha256 `d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`): + - frame 0: byte-exact at PREFILT, POSTDEB and POSTCDEF on Y, U and V — + 0 diffs everywhere (FINAL not re-run this round; frame 0's final state + is bracketed by POSTCDEF on a key frame). + - all 16 frames decode, exit 0 — the parent lane's frame-11 refusal + (`a coded HORZ/VERT strip whose chroma transform has no rect + coefficient tables here`, the `luma=8x32 tx=8x8 chroma=4x32` GAP) is + gone. + - frames 1..15 still diverge (~24-36k Y, ~13-18k U/V per stage; ladder + in `/tmp/i422/ladder/`). **Frame exactness is NOT claimed.** +6. REATTRIBUTION (the round's real finding): the frames-1+ divergence is + NOT the chroma half. Strict stream-order EC_ISTEP pairing on the + frames-0-1 cut puts the first entropy divergence at index 167 — the + 8x8 group at mi(8,10): the ORACLE codes PARTITION_HORZ (pieces (8,10) + and (9,10) only, both intra with uv; oracle partition trace + `EC_PART mi_row=8 mi_col=10 bsize=3 ctx=0 value=1`) while OURS + dispatches decode_inter_sub8_split4 (EC_SUB8INTRA: `shape=4x4 sub=0 + has_chroma=false mi=8,10` ... four pieces, one extra uv_mode + consumption on the (9,11) odd piece). Same bits, different partition + outcome at the 8x8-leaf partition read (`partition_w8` ctx/value — + ours `ctx=2` at the (8,8) sibling). Every downstream diff in the + ladder is walk-shift noise from that point. This is a pre-existing + defect upstream of the named chroma surfaces, newly visible now that + the chroma shapes no longer refuse. + +## Decision + +- The header refusal STAYS unconditional in `stream.rs`; the bypass was + local-only, applied and reverted byte-identical (0 occurrences left; + `stream::tests::a_non_420_subsampled_sequence_header_is_refused_by_name` + green after the revert). +- 4:2:0/4:4:4 untouched by construction (ss-keyed arms; the 4:2:0 sub8 + group tail and `i == 1` rule verbatim). +- `read_coeffs_rect` untouched; the 4:2:0 group-tail SKIP arm untouched. + +## Deferred + +(a) The (8,10)-class partition-dispatch defect (ours SPLIT4 vs oracle + HORZ) — the frames-1+ exactness blocker. Unblock: capture the 8x8 + leaf partition context both sides (ours `EC_TRACE_PART`, oracle's + shipped partition probe) and compare `partition_ctx_mi` vs libaom's + `partition_context` gather at that leaf; the chroma half itself is + now shape-honest and rides on the fix. +(b) 4-wide strips (4x16, 4x8 luma) at 4:2:2: `decode_rect_split` still + refuses `(2, 16)` chroma by name (no pair-anchor machinery there; the + 4:2:0 `(4, 16)` single-unit arm would be wrong at ss (1, 0)). + Unblock: the split4-style floored-pair anchor ported to the 1-mi-wide + strip callers, then the OOB (4, 8) tiling. +(c) 128-root 4:2:2 chroma chunking (`decode_inter_block`'s side > 64 + mu-chunk chroma) still passes the square `chroma_side` geometry — + unreachable on <=64-superblock streams (this fixture is 64-SB); + flagged for whoever lands 4:2:2 128-SB support. + +## Verification + +- `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422blockhalf`): + 0 warnings, 0 errors. +- Refusal gate green post-revert (1 passed). +- Probe: `OK: 16 frames decoded`; 0 `EC_RECTCHROMA_GAP` prints; + `chroma422_chunk=344`, `chroma422_square=197` on the full fixture. +- Ladder: frame 0 = 0 diffs at PREFILT/POSTDEB/POSTCDEF (Y=U=V); frames + 1..15 divergent (see 5/6 — attributed, not claimed). + +## State + +- Commit on lane-av1-422blockhalf (no push): the per-axis decode_inter_block + chroma half, the read_inter_rect_chroma stride fix, the decode_rect_split + (4, 8) chroma tiling incl. per-unit skip prediction, the rect2 per-piece + has_chroma gating, and this report. +- Ladder dumps under `/tmp/i422/ladder/` (scratch, not committed).