forge
Explore
Log in

Don't you dare go Hollow

ec-av1: decode_inter_block's 422 chroma half on the per-axis plane-block model

Browse files at this commit

e371b5781e41f4018625eff6769000c661377946Ahmet Kaan GümüşParent: 19f693e
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.rsmodified+424 -130
@@ -10213,6 +10213,21 @@ fn decode_rect_split(
1021310213 let (px, py) = (mi_c * MI, mi_r * MI);
1021410214 let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));
1021510215 let (chroma_w, chroma_h) = (bw >> ss_x(fctx), bh >> ss_y(fctx));
10216+ // lane-av1-422blockhalf: at ss (1,0) the tall/wide 1:2 and 1:4 strips'
10217+ // chroma plane block is BLOCK_INVALID (`av1_ss_size_lookup[...][1][0]`,
10218+ // blockd.h -- the 4:2:2 column maps BLOCK_8X16/16X32/32X64/64X128 and
10219+ // BLOCK_8X32/16X64, plus 4-wide BLOCK_4X16, to BLOCK_INVALID), so
10220+ // `av1_get_max_uv_txsize` indexes `max_txsize_rect_lookup` OUT OF BOUNDS
10221+ // and the pinned Release oracle byte there is TX_4X8 (the lane-av1-422m
10222+ // measurement). The plane is still coded -- `decode_token_recon_block`
10223+ // steps it in that (4, 8) unit shape -- so the strip's chroma tiles into
10224+ // 4x8 rect units, plane-major.
10225+ let chroma_422_oob = ss_x(fctx) == 1
10226+ && ss_y(fctx) == 0
10227+ && matches!(
10228+ (bw, bh),
10229+ (8, 16) | (16, 32) | (32, 64) | (64, 128) | (8, 32) | (16, 64)
10230+ );
1021610231 // The chroma transform is picked before any symbol is read, so an
1021710232 // unsupported chroma shape refuses before this strip desyncs the tile.
1021810233 let chroma: Option<(TxbSet, &[u16])> = match (chroma_w, chroma_h) {
@@ -10251,12 +10266,22 @@ fn decode_rect_split(
1025110266 });
1025210267 }
1025310268 }
10254- if chroma.is_none() {
10255- // Diagnostic for the next caller that lands here (class
10256- // refusal-names-a-correlate: the message names the tool, not the
10257- // shape); the refusal below keeps its inventory-pinned wording.
10258- eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx_w}x{tx_h} chroma={chroma_w}x{chroma_h}");
10259- }
10269+ }
10270+ // lane-av1-422blockhalf: the tiled arms below handle every shape this
10271+ // strip can carry (including the 4:2:2 BLOCK_INVALID planes), so the
10272+ // diagnostic names only the shapes that would actually refuse -- it used
10273+ // to fire for every tiled square too (the parent lane's `chroma=8x8`
10274+ // rows) and sent the next lane chasing handled shapes.
10275+ let chroma_tiled = chroma_422_oob
10276+ || matches!(
10277+ (chroma_w, chroma_h),
10278+ (64, 32) | (32, 64) | (64, 16) | (16, 64) | (32, 32) | (16, 16) | (8, 8)
10279+ );
10280+ if !m.skip && chroma.is_none() && !chroma_tiled {
10281+ // Diagnostic for the next caller that lands here (class
10282+ // refusal-names-a-correlate: the message names the tool, not the
10283+ // shape); the refusal below keeps its inventory-pinned wording.
10284+ eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx_w}x{tx_h} chroma={chroma_w}x{chroma_h}");
1026010285 }
1026110286 // lane-rectsplit r2 (verifier finding): with both callers wired
1026210287 // (`decode_block_rect`'s 32x16/16x32 and `decode_block_rect64`'s
@@ -10273,7 +10298,6 @@ fn decode_rect_split(
1027310298 // (16x8 luma -> 8x8 chroma) -- the square rows below. At 4:2:0 and 4:4:4 a
1027410299 // rect strip's chroma is itself rect, so the square rows are unreachable
1027510300 // there and cannot change their results.
10276- let chroma_tiled = matches!((chroma_w, chroma_h), (64, 32) | (32, 64) | (64, 16) | (16, 64) | (32, 32) | (16, 16) | (8, 8));
1027710301 if !m.skip && chroma.is_none() && !chroma_tiled {
1027810302 return Err(unsupported(
1027910303 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
@@ -10573,20 +10597,59 @@ fn decode_rect_split(
1057310597 (zero.clone(), zero)
1057410598 } else if m.skip {
1057510599 let zero = Grid::Zero(chroma_w * chroma_h);
10576- if let Some((ub, _)) = &m.palette_uv {
10577- set_palette_pred(ub.clone(), fctx);
10578- }
10579- push_intra_rect(1,
10580- cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero,
10581- m.alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, m.smooth_neighbor_uv, fctx,
10582- );
10583- if let Some((_, vb)) = &m.palette_uv {
10584- set_palette_pred(vb.clone(), fctx);
10600+ if chroma_422_oob {
10601+ // lane-av1-422blockhalf: libaom predicts an INTRA strip's chroma
10602+ // per transform unit even when the strip is skipped
10603+ // (`decode_token_recon_block`'s per-TU plane walk runs before the
10604+ // skip guard), so the BLOCK_INVALID plane predicts as (4, 8)
10605+ // units -- one whole-plane push here would ask the intra
10606+ // predictor for a 1:8 rect it never needs.
10607+ let (uw, uh) = (4usize, 8usize);
10608+ for plane_idx in 1..=2 {
10609+ if let Some((ub, vb)) = &m.palette_uv {
10610+ let buf = if plane_idx == 1 { ub } else { vb };
10611+ set_palette_pred(buf.clone(), fctx);
10612+ }
10613+ for cu_row in 0..chroma_h / uh {
10614+ for cu_col in 0..chroma_w / uw {
10615+ push_intra_rect(
10616+ plane_idx,
10617+ cpx + cu_col * uw,
10618+ cpy + cu_row * uh,
10619+ uw,
10620+ uh,
10621+ m.uv_predict_mode,
10622+ m.angle_delta_uv,
10623+ reach,
10624+ &ZERO_RESIDUAL[..uw * uh],
10625+ m.alpha.zip(ac.clone()).map(|((au, av), ac)| {
10626+ (
10627+ if plane_idx == 1 { au } else { av },
10628+ ac,
10629+ )
10630+ }),
10631+ None,
10632+ m.smooth_neighbor_uv, fctx,
10633+ );
10634+ }
10635+ }
10636+ }
10637+ } else {
10638+ if let Some((ub, _)) = &m.palette_uv {
10639+ set_palette_pred(ub.clone(), fctx);
10640+ }
10641+ push_intra_rect(1,
10642+ cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero,
10643+ m.alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, m.smooth_neighbor_uv, fctx,
10644+ );
10645+ if let Some((_, vb)) = &m.palette_uv {
10646+ set_palette_pred(vb.clone(), fctx);
10647+ }
10648+ push_intra_rect(2,
10649+ cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero,
10650+ m.alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, m.smooth_neighbor_uv, fctx,
10651+ );
1058510652 }
10586- push_intra_rect(2,
10587- cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero,
10588- m.alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, m.smooth_neighbor_uv, fctx,
10589- );
1059010653 (zero.clone(), zero)
1059110654 } else if lossless(fctx) {
1059210655 // lane-lossless: the strip's chroma plane block is coded as 4x4
@@ -10643,15 +10706,22 @@ fn decode_rect_split(
1064310706 let [ug, vg] = last;
1064410707 (ug, vg)
1064510708 } else if chroma_tiled {
10646- let (uw, uh, set, scan): (usize, usize, TxbSet, &[u16]) = match (chroma_w, chroma_h) {
10647- (64, 32) | (32, 64) | (32, 32) => (32, 32, TxbSet::Chroma32, default_scan(32)),
10648- (64, 16) => (32, 16, TxbSet::ChromaRect32x16, &SCAN_32X16),
10649- (16, 64) => (16, 32, TxbSet::ChromaRect32x16, &SCAN_16X32),
10650- // lane-av1-422: the 4:2:2 square chroma planes (height unhalved),
10651- // through the square reader like every other square chroma unit.
10652- (16, 16) => (16, 16, TxbSet::Chroma16, default_scan(16)),
10653- (8, 8) => (8, 8, TxbSet::Chroma8, default_scan(8)),
10654- _ => unreachable!("chroma_tiled"),
10709+ let (uw, uh, set, scan): (usize, usize, TxbSet, &[u16]) = if chroma_422_oob {
10710+ // lane-av1-422blockhalf: the BLOCK_INVALID-plane strip's (4, 8)
10711+ // units -- the Release oracle's out-of-bounds
10712+ // `max_txsize_rect_lookup[BLOCK_INVALID]` byte (see above).
10713+ (4, 8, TxbSet::ChromaRect8x4, &SCAN_4X8)
10714+ } else {
10715+ match (chroma_w, chroma_h) {
10716+ (64, 32) | (32, 64) | (32, 32) => (32, 32, TxbSet::Chroma32, default_scan(32)),
10717+ (64, 16) => (32, 16, TxbSet::ChromaRect32x16, &SCAN_32X16),
10718+ (16, 64) => (16, 32, TxbSet::ChromaRect32x16, &SCAN_16X32),
10719+ // lane-av1-422: the 4:2:2 square chroma planes (height unhalved),
10720+ // through the square reader like every other square chroma unit.
10721+ (16, 16) => (16, 16, TxbSet::Chroma16, default_scan(16)),
10722+ (8, 8) => (8, 8, TxbSet::Chroma8, default_scan(8)),
10723+ _ => unreachable!("chroma_tiled"),
10724+ }
1065510725 };
1065610726 // lane-av1-422: the witness counter, keyed to ss (1,0) so only a 4:2:2
1065710727 // frame's square chroma units count it.
@@ -10660,7 +10730,15 @@ fn decode_rect_split(
1066010730 }
1066110731 let (nw, nh) = (chroma_w / uw, chroma_h / uh);
1066210732 let bigger = chroma_w * chroma_h > uw * uh;
10663- let default_tx = TxType::DctDct;
10733+ // `av1_get_ext_tx_set_type`: a chroma transform whose square-up size
10734+ // is TX_32X32 or bigger resolves to `EXT_TX_SET_DCTONLY` for intra;
10735+ // smaller rect units (the 4:2:2 BLOCK_INVALID-plane (4, 8)s) take the
10736+ // mode-indexed default, the same rule the unsplit arm below applies.
10737+ let default_tx = if uw.max(uh) >= 32 {
10738+ TxType::DctDct
10739+ } else {
10740+ default_intra_tx_type(m.uv_predict_mode as u8)
10741+ };
1066410742 let mut last = [Grid::Zero(uw * uh), Grid::Zero(uw * uh)];
1066510743 for plane_idx in 1..=2 {
1066610744 for cu_row in 0..nh {
@@ -10671,7 +10749,17 @@ fn decode_rect_split(
1067110749 mi_r + cu_row * (luma_span_y / MI),
1067210750 mi_c + cu_col * (luma_span_x / MI),
1067310751 );
10674- let cu_around = neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y);
10752+ // lane-av1-422blockhalf: the 4:2:2 (4, 8) units read their
10753+ // chroma context per chroma cell
10754+ // ([`Neighbours::around_mi_422_chroma`], the block-8
10755+ // rule) -- the plain rect walk samples one chroma cell
10756+ // twice at ss_x 1. Every pre-existing shape keeps its own
10757+ // walk.
10758+ let cu_around = if chroma_422_oob {
10759+ neighbours.around_mi_422_chroma(cu_mi, luma_span_x, luma_span_y)
10760+ } else {
10761+ neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y)
10762+ };
1067510763 let (cu_x, cu_y) = (cpx + cu_col * uw, cpy + cu_row * uh);
1067610764 let cfl = m.alpha.map(|(au, av)| {
1067710765 let alpha = if plane_idx == 1 { au } else { av };
@@ -23228,6 +23316,12 @@ fn read_inter_rect_chroma(
2322823316 let (nx, ny) = (write_chroma_w / uw, write_chroma_h / uh);
2322923317 let multi = nx * ny > 1;
2323023318 let set = rect_inter_chroma_set(uw, uh)?;
23319+ // lane-av1-422blockhalf: the assembled block grid is the PRED stride x
23320+ // the plane's true height -- at 4:2:2 a square block's plane is
23321+ // (side/2, side), so the old `chroma_side`-square sizing under-allocated
23322+ // every row past `chroma_stride` once the caller began passing the
23323+ // per-axis stride.
23324+ let assembled_h = write_chroma_h.max(chroma_side);
2323123325 let mut assembled: [Vec<i32>; 2] = [Vec::new(), Vec::new()];
2323223326 // The multi-unit stamps below are rewritten by the caller's whole-block
2323323327 // record (`record_rect_mi`/`record_split_luma_rect_mi` write ONE
@@ -23239,8 +23333,8 @@ fn read_inter_rect_chroma(
2323923333 if multi {
2324023334 hit!(CHROMA_SPLIT_TX_HITS);
2324123335 assembled = [
23242- vec![0i32; chroma_side * chroma_side],
23243- vec![0i32; chroma_side * chroma_side],
23336+ vec![0i32; chroma_side * assembled_h],
23337+ vec![0i32; chroma_side * assembled_h],
2324423338 ];
2324523339 }
2324623340 for plane_idx in 1..=2 {
@@ -23291,7 +23385,12 @@ fn read_inter_rect_chroma(
2329123385 }
2329223386 units.push((cu_mi, plane_idx, cu_grid, span_x, span_y));
2329323387 } else {
23294- assembled[plane_idx - 1] = embed_rect_grid(&cu_grid, uw, uh, chroma_side);
23388+ let mut full = vec![0i32; chroma_side * assembled_h];
23389+ for rr in 0..uh {
23390+ full[rr * chroma_side..][..uw]
23391+ .copy_from_slice(&cu_grid[rr * uw..][..uw]);
23392+ }
23393+ assembled[plane_idx - 1] = full;
2329523394 }
2329623395 }
2329723396 }
@@ -31827,6 +31926,20 @@ fn decode_inter_block(
3182731926 }
3182831927 _ => (write_w >> ss_x(fctx), write_h >> ss_y(fctx)),
3182931928 };
31929+ // lane-av1-422blockhalf: the chroma PREDICTION buffers take the PLANE
31930+ // BLOCK's own per-axis shape at 4:2:2 -- (side/2, side) -- instead of the
31931+ // enclosing square `chroma_side` the pre-port model indexed, and the
31932+ // masked-compound blend reads its luma mask through the plane's real
31933+ // subsampling shifts (aom_dsp/blend-a64-mask.c's four branches; the
31934+ // stop-note this lane owns). Every consumer below strides with
31935+ // `chroma_stride`. At 4:2:0 and 4:4:4 both values reduce to the square
31936+ // `chroma_side` verbatim, so only 4:2:2 changes shape.
31937+ let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0;
31938+ let (chroma_stride, chroma_buf_h) = if chroma_422 {
31939+ (write_chroma_w, write_chroma_h)
31940+ } else {
31941+ (chroma_side, chroma_side)
31942+ };
3183031943 let (chroma_set, chroma_tx, scan_chroma) =
3183131944 if ss_x(fctx) == 0 && ss_y(fctx) == 0 && strip_chroma.is_none() {
3183231945 let tx = if side >= 64 { 32 } else { side };
@@ -32708,7 +32821,7 @@ fn decode_inter_block(
3270832821 mc::combine_compound(&inter0_y, &inter1_y, fwd_offset, bck_offset, &mut pred_y, fctx);
3270932822 }
3271032823
32711- let mut inter0_u = vec![0i32; chroma_side * chroma_side];
32824+ let mut inter0_u = vec![0i32; chroma_stride * chroma_buf_h];
3271232825 mc::predict_compound_intermediate_kern(
3271332826 &pu0.data,
3271432827 pu0.width,
@@ -32717,8 +32830,8 @@ fn decode_inter_block(
3271732830 mv_to_q4(cpx, mv0.1, ss_x(fctx)),
3271832831 mv_to_q4(cpy, mv0.0, ss_x(fctx)),
3271932832 scale0,
32720- chroma_side,
32721- chroma_side,
32833+ chroma_stride,
32834+ chroma_buf_h,
3272232835 write_chroma_w,
3272332836 write_chroma_h,
3272432837 h_filter,
@@ -32732,11 +32845,11 @@ fn decode_inter_block(
3273232845 crate::warp::warp_affine_compound(
3273332846 wp, &pu0.data, pu0.true_width as i32, pu0.true_height as i32,
3273432847 pu0.width as i32, &mut inter0_u, cpx as i32, cpy as i32,
32735- chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx,
32848+ chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx,
3273632849 );
3273732850 }
3273832851 }
32739- let mut inter1_u = vec![0i32; chroma_side * chroma_side];
32852+ let mut inter1_u = vec![0i32; chroma_stride * chroma_buf_h];
3274032853 mc::predict_compound_intermediate_kern(
3274132854 &pu1.data,
3274232855 pu1.width,
@@ -32745,8 +32858,8 @@ fn decode_inter_block(
3274532858 mv_to_q4(cpx, mv1.1, ss_x(fctx)),
3274632859 mv_to_q4(cpy, mv1.0, ss_x(fctx)),
3274732860 scale1,
32748- chroma_side,
32749- chroma_side,
32861+ chroma_stride,
32862+ chroma_buf_h,
3275032863 write_chroma_w,
3275132864 write_chroma_h,
3275232865 h_filter,
@@ -32760,35 +32873,33 @@ fn decode_inter_block(
3276032873 crate::warp::warp_affine_compound(
3276132874 wp, &pu1.data, pu1.true_width as i32, pu1.true_height as i32,
3276232875 pu1.width as i32, &mut inter1_u, cpx as i32, cpy as i32,
32763- chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx,
32876+ chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx,
3276432877 );
3276532878 }
3276632879 }
32767- let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_side * chroma_side);
32880+ let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_stride * chroma_buf_h);
3276832881 if let Some(mask_y) = mask_y {
32769- // lane-av1-422sub8rect stop-note: this fn's 4:2:2 chroma
32770- // prediction is still the square-cut model (the owning
32771- // parent-lane surface) -- its buffer is `chroma_side`-square
32772- // and cannot be indexed by the subsampled-axis mask walks,
32773- // so at ss_x != ss_y the blend keeps the direct
32774- // luma-resolution read (the pre-port behaviour, known
32775- // divergent there) until that surface itself is ported.
32882+ // lane-av1-422blockhalf: the blend walks this plane's own
32883+ // (chroma_stride x chroma_buf_h) rect through the plane's
32884+ // real subsampling shifts -- the mask read is aom_dsp/
32885+ // blend-a64-mask.c's `(1, 0)` branch at 4:2:2, the direct
32886+ // luma sample at 4:2:0/4:4:4.
3277632887 mc::blend_masked_compound(
3277732888 &inter0_u,
3277832889 &inter1_u,
3277932890 mask_y,
3278032891 side,
32781- chroma_side,
32782- chroma_side,
32783- if ss_x(fctx) == ss_y(fctx) { ss_x(fctx) } else { 0 },
32784- if ss_x(fctx) == ss_y(fctx) { ss_y(fctx) } else { 0 },
32892+ chroma_stride,
32893+ chroma_buf_h,
32894+ ss_x(fctx),
32895+ ss_y(fctx),
3278532896 &mut pred_u, fctx,
3278632897 );
3278732898 } else {
3278832899 mc::combine_compound(&inter0_u, &inter1_u, fwd_offset, bck_offset, &mut pred_u, fctx);
3278932900 }
3279032901
32791- let mut inter0_v = vec![0i32; chroma_side * chroma_side];
32902+ let mut inter0_v = vec![0i32; chroma_stride * chroma_buf_h];
3279232903 mc::predict_compound_intermediate_kern(
3279332904 &pv0.data,
3279432905 pv0.width,
@@ -32797,8 +32908,8 @@ fn decode_inter_block(
3279732908 mv_to_q4(cpx, mv0.1, ss_x(fctx)),
3279832909 mv_to_q4(cpy, mv0.0, ss_x(fctx)),
3279932910 scale0,
32800- chroma_side,
32801- chroma_side,
32911+ chroma_stride,
32912+ chroma_buf_h,
3280232913 write_chroma_w,
3280332914 write_chroma_h,
3280432915 h_filter,
@@ -32812,11 +32923,11 @@ fn decode_inter_block(
3281232923 crate::warp::warp_affine_compound(
3281332924 wp, &pv0.data, pv0.true_width as i32, pv0.true_height as i32,
3281432925 pv0.width as i32, &mut inter0_v, cpx as i32, cpy as i32,
32815- chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx,
32926+ chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx,
3281632927 );
3281732928 }
3281832929 }
32819- let mut inter1_v = vec![0i32; chroma_side * chroma_side];
32930+ let mut inter1_v = vec![0i32; chroma_stride * chroma_buf_h];
3282032931 mc::predict_compound_intermediate_kern(
3282132932 &pv1.data,
3282232933 pv1.width,
@@ -32825,8 +32936,8 @@ fn decode_inter_block(
3282532936 mv_to_q4(cpx, mv1.1, ss_x(fctx)),
3282632937 mv_to_q4(cpy, mv1.0, ss_x(fctx)),
3282732938 scale1,
32828- chroma_side,
32829- chroma_side,
32939+ chroma_stride,
32940+ chroma_buf_h,
3283032941 write_chroma_w,
3283132942 write_chroma_h,
3283232943 h_filter,
@@ -32840,28 +32951,26 @@ fn decode_inter_block(
3284032951 crate::warp::warp_affine_compound(
3284132952 wp, &pv1.data, pv1.true_width as i32, pv1.true_height as i32,
3284232953 pv1.width as i32, &mut inter1_v, cpx as i32, cpy as i32,
32843- chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx,
32954+ chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx,
3284432955 );
3284532956 }
3284632957 }
32847- let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_side * chroma_side);
32958+ let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_stride * chroma_buf_h);
3284832959 if let Some(mask_y) = mask_y {
32849- // lane-av1-422sub8rect stop-note: this fn's 4:2:2 chroma
32850- // prediction is still the square-cut model (the owning
32851- // parent-lane surface) -- its buffer is `chroma_side`-square
32852- // and cannot be indexed by the subsampled-axis mask walks,
32853- // so at ss_x != ss_y the blend keeps the direct
32854- // luma-resolution read (the pre-port behaviour, known
32855- // divergent there) until that surface itself is ported.
32960+ // lane-av1-422blockhalf: the blend walks this plane's own
32961+ // (chroma_stride x chroma_buf_h) rect through the plane's
32962+ // real subsampling shifts -- the mask read is aom_dsp/
32963+ // blend-a64-mask.c's `(1, 0)` branch at 4:2:2, the direct
32964+ // luma sample at 4:2:0/4:4:4.
3285632965 mc::blend_masked_compound(
3285732966 &inter0_v,
3285832967 &inter1_v,
3285932968 mask_y,
3286032969 side,
32861- chroma_side,
32862- chroma_side,
32863- if ss_x(fctx) == ss_y(fctx) { ss_x(fctx) } else { 0 },
32864- if ss_x(fctx) == ss_y(fctx) { ss_y(fctx) } else { 0 },
32970+ chroma_stride,
32971+ chroma_buf_h,
32972+ ss_x(fctx),
32973+ ss_y(fctx),
3286532974 &mut pred_v, fctx,
3286632975 );
3286732976 } else {
@@ -32877,8 +32986,8 @@ fn decode_inter_block(
3287732986 push_pred(fctx, build);
3287832987 (
3287932988 Pred::Cur { plane: 0, stride: side, off: 0 },
32880- Pred::Cur { plane: 1, stride: chroma_side, off: 0 },
32881- Pred::Cur { plane: 2, stride: chroma_side, off: 0 },
32989+ Pred::Cur { plane: 1, stride: chroma_stride, off: 0 },
32990+ Pred::Cur { plane: 2, stride: chroma_stride, off: 0 },
3288232991 )
3288332992 } else {
3288432993 let mut built: [Vec<u16>; 3] = Default::default();
@@ -32887,8 +32996,8 @@ fn decode_inter_block(
3288732996 (pred_y, pred_u, pred_v) = (by, bu, bv);
3288832997 (
3288932998 Pred::Inline(&pred_y, side),
32890- Pred::Inline(&pred_u, chroma_side),
32891- Pred::Inline(&pred_v, chroma_side),
32999+ Pred::Inline(&pred_u, chroma_stride),
33000+ Pred::Inline(&pred_v, chroma_stride),
3289233001 )
3289333002 };
3289433003
@@ -32929,24 +33038,24 @@ fn decode_inter_block(
3292933038 push_mc_rect(1,
3293033039 cpx,
3293133040 cpy,
32932- chroma_side,
33041+ chroma_stride,
3293333042 write_chroma_w,
3293433043 write_chroma_h,
3293533044 su,
32936- &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
33045+ &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx,
3293733046 );
3293833047 push_mc_rect(2,
3293933048 cpx,
3294033049 cpy,
32941- chroma_side,
33050+ chroma_stride,
3294233051 write_chroma_w,
3294333052 write_chroma_h,
3294433053 sv,
32945- &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
33054+ &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx,
3294633055 );
3294733056 luma_grid = Grid::Zero(side * side);
32948- u_grid = Grid::Zero(chroma_side * chroma_side);
32949- v_grid = Grid::Zero(chroma_side * chroma_side);
33057+ u_grid = Grid::Zero(chroma_stride * chroma_buf_h);
33058+ v_grid = Grid::Zero(chroma_stride * chroma_buf_h);
3295033059 } else {
3295133060 // lane-inter4 r2: a rect strip's coefficient context spans its
3295233061 // OWN width above and height left -- reading `side` cells both
@@ -33277,12 +33386,12 @@ fn decode_inter_block(
3327733386 // root a rect (128x64/64x128) block's chroma is per mu
3327833387 // chunk too, so this test comes BEFORE the `rect_tu` one.
3327933388 u_grid = if u_units.is_empty() {
33280- Grid::Zero(chroma_side * chroma_side)
33389+ Grid::Zero(chroma_stride * chroma_buf_h)
3328133390 } else {
3328233391 Grid::Own(std::mem::take(&mut u_units))
3328333392 };
3328433393 v_grid = if v_units.is_empty() {
33285- Grid::Zero(chroma_side * chroma_side)
33394+ Grid::Zero(chroma_stride * chroma_buf_h)
3328633395 } else {
3328733396 Grid::Own(std::mem::take(&mut v_units))
3328833397 };
@@ -33293,7 +33402,7 @@ fn decode_inter_block(
3329333402 read_inter_chroma_lossless(
3329433403 dec, cdfs, neighbours, u, v, su, sv, at_mi, (cpx, cpy),
3329533404 (0, 0), (write_chroma_w, write_chroma_h),
33296- (write_chroma_w, write_chroma_h), chroma_side,
33405+ (write_chroma_w, write_chroma_h), chroma_stride,
3329733406 mode_for_tx, base_q_idx, &mut uo, &mut vo, fctx,
3329833407 )?;
3329933408 let zero = chroma_side * chroma_side;
@@ -33328,7 +33437,7 @@ fn decode_inter_block(
3332833437 at_mi,
3332933438 (cpx, cpy),
3333033439 (write_chroma_w, write_chroma_h),
33331- chroma_side,
33440+ chroma_stride,
3333233441 mode_for_tx,
3333333442 luma_tx_type, fctx,
3333433443 )?;
@@ -34107,7 +34216,7 @@ fn decode_inter_block(
3410734216 side,
3410834217 write_w,
3410934218 write_h,
34110- chroma_side,
34219+ chroma_stride,
3411134220 px,
3411234221 py,
3411334222 cpx,
@@ -34129,8 +34238,8 @@ fn decode_inter_block(
3412934238 return;
3413034239 };
3413134240 let mut pred_y = refill(std::mem::take(&mut out[0]), side * side);
34132- let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_side * chroma_side);
34133- let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_side * chroma_side);
34241+ let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_stride * chroma_buf_h);
34242+ let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_stride * chroma_buf_h);
3413434243 if luma_scale == mc::REF_NO_SCALE {
3413534244 mc::predict_with_filters_kern(
3413634245 &py_ref.data,
@@ -34154,8 +34263,8 @@ fn decode_inter_block(
3415434263 pu_ref.true_height,
3415534264 mv_to_q4(cpx, mv.1, ss_x(fctx)),
3415634265 mv_to_q4(cpy, mv.0, ss_x(fctx)),
34157- chroma_side,
34158- chroma_side,
34266+ chroma_stride,
34267+ chroma_buf_h,
3415934268 write_chroma_w,
3416034269 write_chroma_h,
3416134270 h_filter,
@@ -34169,8 +34278,8 @@ fn decode_inter_block(
3416934278 pv_ref.true_height,
3417034279 mv_to_q4(cpx, mv.1, ss_x(fctx)),
3417134280 mv_to_q4(cpy, mv.0, ss_x(fctx)),
34172- chroma_side,
34173- chroma_side,
34281+ chroma_stride,
34282+ chroma_buf_h,
3417434283 write_chroma_w,
3417534284 write_chroma_h,
3417634285 h_filter,
@@ -34202,8 +34311,8 @@ fn decode_inter_block(
3420234311 mv_to_q4(cpx, mv.1, ss_x(fctx)),
3420334312 mv_to_q4(cpy, mv.0, ss_x(fctx)),
3420434313 luma_scale,
34205- chroma_side,
34206- chroma_side,
34314+ chroma_stride,
34315+ chroma_buf_h,
3420734316 write_chroma_w,
3420834317 write_chroma_h,
3420934318 h_filter,
@@ -34218,8 +34327,8 @@ fn decode_inter_block(
3421834327 mv_to_q4(cpx, mv.1, ss_x(fctx)),
3421934328 mv_to_q4(cpy, mv.0, ss_x(fctx)),
3422034329 luma_scale,
34221- chroma_side,
34222- chroma_side,
34330+ chroma_stride,
34331+ chroma_buf_h,
3422334332 write_chroma_w,
3422434333 write_chroma_h,
3422534334 h_filter,
@@ -34259,13 +34368,11 @@ fn decode_inter_block(
3425934368 if warp_plane_allowed(write_chroma_w, write_chroma_h) {
3426034369 crate::warp::warp_affine(
3426134370 params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32,
34262- pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32,
34263- chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx,
34371+ 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,
3426434372 );
3426534373 crate::warp::warp_affine(
3426634374 params, &pv_ref.data, pv_ref.true_width as i32, pv_ref.true_height as i32,
34267- pv_ref.width as i32, &mut pred_v, cpx as i32, cpy as i32, chroma_side as i32,
34268- chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx,
34375+ 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,
3426934376 );
3427034377 }
3427134378 }
@@ -34279,11 +34386,11 @@ fn decode_inter_block(
3427934386 }
3428034387 interintra_blend(y, px, py, write_w, write_h, side, 0, 0, ii, wedge_mask, &mut pred_y, fctx);
3428134388 interintra_blend(
34282- u, cpx, cpy, write_chroma_w, write_chroma_h, chroma_side, ss_x(fctx),
34389+ u, cpx, cpy, write_chroma_w, write_chroma_h, chroma_stride, ss_x(fctx),
3428334390 ss_y(fctx), ii, wedge_mask, &mut pred_u, fctx,
3428434391 );
3428534392 interintra_blend(
34286- v, cpx, cpy, write_chroma_w, write_chroma_h, chroma_side, ss_x(fctx),
34393+ v, cpx, cpy, write_chroma_w, write_chroma_h, chroma_stride, ss_x(fctx),
3428734394 ss_y(fctx), ii, wedge_mask, &mut pred_v, fctx,
3428834395 );
3428934396 }
@@ -34322,7 +34429,7 @@ fn decode_inter_block(
3432234429 &mut piece, fctx,
3432334430 );
3432434431 for row in 0..piece_h {
34325- dst[row * chroma_side..row * chroma_side + piece_w]
34432+ dst[row * chroma_stride..row * chroma_stride + piece_w]
3432634433 .copy_from_slice(&piece[row * piece_w..(row + 1) * piece_w]);
3432734434 }
3432834435 }
@@ -34347,8 +34454,8 @@ fn decode_inter_block(
3434734454 push_pred(fctx, build);
3434834455 (
3434934456 Pred::Cur { plane: 0, stride: side, off: 0 },
34350- Pred::Cur { plane: 1, stride: chroma_side, off: 0 },
34351- Pred::Cur { plane: 2, stride: chroma_side, off: 0 },
34457+ Pred::Cur { plane: 1, stride: chroma_stride, off: 0 },
34458+ Pred::Cur { plane: 2, stride: chroma_stride, off: 0 },
3435234459 )
3435334460 } else {
3435434461 if interintra_mode.is_some() {
@@ -34372,8 +34479,8 @@ fn decode_inter_block(
3437234479 // through to the ordinary whole-block predictor.
3437334480 (
3437434481 Pred::Inline(&pred_y, side),
34375- Pred::Inline(&pred_u, chroma_side),
34376- Pred::Inline(&pred_v, chroma_side),
34482+ Pred::Inline(&pred_u, chroma_stride),
34483+ Pred::Inline(&pred_v, chroma_stride),
3437734484 )
3437834485 };
3437934486
@@ -34418,25 +34525,25 @@ fn decode_inter_block(
3441834525 push_mc_rect(1,
3441934526 cpx,
3442034527 cpy,
34421- chroma_side,
34528+ chroma_stride,
3442234529 write_chroma_w,
3442334530 write_chroma_h,
3442434531 su,
34425- &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
34532+ &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx,
3442634533 );
3442734534 push_mc_rect(2,
3442834535 cpx,
3442934536 cpy,
34430- chroma_side,
34537+ chroma_stride,
3443134538 write_chroma_w,
3443234539 write_chroma_h,
3443334540 sv,
34434- &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
34541+ &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx,
3443534542 );
3443634543 }
3443734544 luma_grid = Grid::Zero(side * side);
34438- u_grid = Grid::Zero(chroma_side * chroma_side);
34439- v_grid = Grid::Zero(chroma_side * chroma_side);
34545+ u_grid = Grid::Zero(chroma_stride * chroma_buf_h);
34546+ v_grid = Grid::Zero(chroma_stride * chroma_buf_h);
3444034547 } else {
3444134548 // lane-inter4 r2: a rect strip's coefficient context spans its
3444234549 // OWN width above and height left -- reading `side` cells both
@@ -34781,19 +34888,19 @@ fn decode_inter_block(
3478134888 // `reconstruct_inter_block`'s `for (plane...)` guarded by
3478234889 // `xd->is_chroma_ref`) codes NO chroma transform here, so
3478334890 // neither symbol nor context exists.
34784- u_grid = Grid::Zero(chroma_side * chroma_side);
34785- v_grid = Grid::Zero(chroma_side * chroma_side);
34891+ u_grid = Grid::Zero(chroma_stride * chroma_buf_h);
34892+ v_grid = Grid::Zero(chroma_stride * chroma_buf_h);
3478634893 } else if side > 64 {
3478734894 // Already read inside the mu-chunk loop above -- at the 128
3478834895 // root a rect (128x64/64x128) block's chroma is per mu
3478934896 // chunk too, so this test comes BEFORE the `rect_tu` one.
3479034897 u_grid = if u_units.is_empty() {
34791- Grid::Zero(chroma_side * chroma_side)
34898+ Grid::Zero(chroma_stride * chroma_buf_h)
3479234899 } else {
3479334900 Grid::Own(std::mem::take(&mut u_units))
3479434901 };
3479534902 v_grid = if v_units.is_empty() {
34796- Grid::Zero(chroma_side * chroma_side)
34903+ Grid::Zero(chroma_stride * chroma_buf_h)
3479734904 } else {
3479834905 Grid::Own(std::mem::take(&mut v_units))
3479934906 };
@@ -34804,7 +34911,7 @@ fn decode_inter_block(
3480434911 read_inter_chroma_lossless(
3480534912 dec, cdfs, neighbours, u, v, su, sv, at_mi, (cpx, cpy),
3480634913 (0, 0), (write_chroma_w, write_chroma_h),
34807- (write_chroma_w, write_chroma_h), chroma_side,
34914+ (write_chroma_w, write_chroma_h), chroma_stride,
3480834915 mode_for_tx, base_q_idx, &mut uo, &mut vo, fctx,
3480934916 )?;
3481034917 let zero = chroma_side * chroma_side;
@@ -34836,7 +34943,7 @@ fn decode_inter_block(
3483634943 at_mi,
3483734944 (cpx, cpy),
3483834945 (write_chroma_w, write_chroma_h),
34839- chroma_side,
34946+ chroma_stride,
3484034947 mode_for_tx,
3484134948 luma_tx_type, fctx,
3484234949 )?;
@@ -35541,12 +35648,12 @@ fn decode_inter_block(
3554135648 // Chroma is already coded and reconstructed per mu chunk above.
3554235649 luma_grid = Grid::Zero(side * side);
3554335650 u_grid = if u_units.is_empty() {
35544- Grid::Zero(chroma_side * chroma_side)
35651+ Grid::Zero(chroma_stride * chroma_buf_h)
3554535652 } else {
3554635653 Grid::Own(std::mem::take(&mut u_units))
3554735654 };
3554835655 v_grid = if v_units.is_empty() {
35549- Grid::Zero(chroma_side * chroma_side)
35656+ Grid::Zero(chroma_stride * chroma_buf_h)
3555035657 } else {
3555135658 Grid::Own(std::mem::take(&mut v_units))
3555235659 };
@@ -37700,6 +37807,28 @@ fn decode_inter_sub8_rect2(
3770037807 // there is no shared group unit (aomdec EC_COEFF on
3770137808 // `av1-profile1-444.ivf` decode-order frame 1, mi (3,8)).
3770237809 let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0;
37810+ // lane-av1-422blockhalf: at ss (1,0) the chroma reference is PER PIECE
37811+ // too, keyed by `is_chroma_reference`'s own terms: an 8x4 HORZ piece is
37812+ // 2 mi wide (`!(bw & 1)`), so BOTH pieces of the group are references;
37813+ // a 4x8 VERT piece is 1 mi wide, so only the ODD-column piece is
37814+ // (`mi_col & 1`) -- measured on the pinned t422 fixture frame 1: the
37815+ // horz group at mi (8,10)/(9,10) reads U+V TX_4X4 after EACH piece's
37816+ // luma (rng 37134/37852 then 63752/50952), and the vert group at
37817+ // (3,10)/(3,11) reads U+V on the odd-column piece (3,11) alone. The old
37818+ // `i == 1` rule coded the group's chroma on the wrong piece (and, for
37819+ // horz, half of the units) and desynced frame 1 at (8,10)'s uv_mode.
37820+ let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0;
37821+ // 4:4:4: every piece. 4:2:2: both horz pieces, the odd-column vert piece.
37822+ // 4:2:0 keeps its existing second-piece model untouched.
37823+ let piece_is_chroma_ref = |i: usize| -> bool {
37824+ if ss_x(fctx) == 0 && ss_y(fctx) == 0 {
37825+ true
37826+ } else if chroma_422 {
37827+ !vert || ((gc + i) & 1) == 1
37828+ } else {
37829+ i == 1
37830+ }
37831+ };
3770337832 // This piece's first transform's luma `tx_type` (libaom `mbmi->tx_type`):
3770437833 // an inter block's chroma plane never codes its own symbol but inherits
3770537834 // the colocated luma type (`av1_get_tx_type`, blockd.h:1291).
@@ -37760,7 +37889,7 @@ fn decode_inter_sub8_rect2(
3776037889 "EC_SUB8INTRA shape={}x{} sub={i} has_chroma={} skip={skip} mi={rmi},{cmi} tx_select={}",
3776137890 bw,
3776237891 bh,
37763- i == 1,
37892+ piece_is_chroma_ref(i),
3776437893 fctx.tx_select_inter.with(std::cell::Cell::get),
3776537894 );
3776637895 }
@@ -37778,7 +37907,7 @@ fn decode_inter_sub8_rect2(
3777837907 group_mi,
3777937908 lmi,
3778037909 (bw, bh),
37781- chroma_444 || i == 1,
37910+ piece_is_chroma_ref(i),
3778237911 skip,
3778337912 scan4,
3778437913 y,
@@ -37789,7 +37918,7 @@ fn decode_inter_sub8_rect2(
3778937918 fctx.tx_select_inter.with(std::cell::Cell::get),
3779037919 reduced_tx_set, fctx,
3779137920 )?;
37792- if i == 1 {
37921+ if piece_is_chroma_ref(i) {
3779337922 intra_chroma = true;
3779437923 }
3779537924 continue;
@@ -38199,6 +38328,166 @@ fn decode_inter_sub8_rect2(
3819938328 neighbours.record_mi_chroma(lmi, bw, bh, 1, &ug);
3820038329 neighbours.record_mi_chroma(lmi, bw, bh, 2, &vg);
3820138330 }
38331+ // lane-av1-422blockhalf: the 4:2:2 per-piece arm. The chroma
38332+ // reference piece codes its own U and V TX_4X4 units right after its
38333+ // luma -- both pieces of a horz group, the odd-column piece of a
38334+ // vert one (see `piece_is_chroma_ref` above; measured on the pinned
38335+ // t422 fixture frame 1, horz group (8,10)/(9,10) and vert group
38336+ // (3,10)/(3,11)). The unit anchors at the FLOORED chroma cell
38337+ // (`av1_setup_dst_planes`' `(mi_col & !1) * MI >> ss_x`, the
38338+ // lane-av1-422kf2 rule) and reads through
38339+ // [`Neighbours::around_mi_422_chroma`]'s per-chroma-cell context.
38340+ // A horz piece IS 4x4 chroma (8 luma wide, ss_y 0): its unit
38341+ // predicts whole from its own mv/filters. A vert piece is 2 chroma
38342+ // px wide, so its 4-px unit predicts in halves --
38343+ // `build_inter_predictors_sub8x8`'s rule: the left 2x4 from the
38344+ // piece to the LEFT (the group's own left piece, or the decoded
38345+ // neighbour when the group starts on an odd column), the right 2x4
38346+ // from this piece. A skipped reference piece still predicts (spec
38347+ // 7.11.3) but codes no coefficients.
38348+ } else if chroma_422 && piece_is_chroma_ref(i) {
38349+ const B4: usize = 4;
38350+ let (pc_ref, pc_mv, pc_hf, pc_vf) = piece[i].expect("inter piece recorded above");
38351+ let unit_x = ((lmi.1 & !1) * MI) >> ss_x(fctx);
38352+ let unit_y = py;
38353+ // The left 2x4 half's source: the in-group left piece when this
38354+ // piece is the group's second, else the decoded neighbour one mi
38355+ // to the left (an odd-column group start). Its interp filters
38356+ // are not on the mi grid, so an outside neighbour borrows this
38357+ // piece's own.
38358+ let left_piece = if i > 0 {
38359+ piece[i - 1]
38360+ } else if lmi.1 > 0 {
38361+ grid.get(rmi, lmi.1 - 1).filter(|mi| mi.is_inter).map(
38362+ |mi| {
38363+ (
38364+ mi.ref_frame,
38365+ (i32::from(mi.mv.0), i32::from(mi.mv.1)),
38366+ pc_hf,
38367+ pc_vf,
38368+ )
38369+ },
38370+ )
38371+ } else {
38372+ None
38373+ };
38374+ let build_c = move |_y: &mut PlaneBuf<'static>,
38375+ _u: &mut PlaneBuf<'static>,
38376+ _v: &mut PlaneBuf<'static>,
38377+ fctx: &crate::decode::FrameCtx,
38378+ out: &mut [Vec<u16>; 3]| {
38379+ let Some((pc_ref_y, sref_u, sref_v)) = ref_planes_deferred(pc_ref, refpix) else {
38380+ return;
38381+ };
38382+ let pc_scale = mc::scale_factor(pc_ref_y.width, frame_width);
38383+ let mut pred_u = refill(std::mem::take(&mut out[1]), B4 * B4);
38384+ let mut pred_v = refill(std::mem::take(&mut out[2]), B4 * B4);
38385+ for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] {
38386+ let mut buf = vec![0u16; B4 * B4];
38387+ if vert {
38388+ // Right 2x4 half: this piece's own ref/mv/filters.
38389+ let mut half = vec![0u16; 2 * 4];
38390+ mc::predict_maybe_scaled(
38391+ &plane.data,
38392+ plane.width,
38393+ plane.true_width,
38394+ plane.true_height,
38395+ mv_to_q4(unit_x + 2, pc_mv.1, ss_x(fctx)),
38396+ mv_to_q4(unit_y, pc_mv.0, ss_y(fctx)),
38397+ pc_scale,
38398+ 2,
38399+ 4,
38400+ pc_hf,
38401+ pc_vf,
38402+ &mut half, fctx,
38403+ );
38404+ for row in 0..4 {
38405+ buf[row * B4 + 2..row * B4 + 4]
38406+ .copy_from_slice(&half[row * 2..row * 2 + 2]);
38407+ }
38408+ // Left 2x4 half: the piece to the left (an
38409+ // intra/off-frame neighbour reduces to whole-from-own,
38410+ // `is_sub8x8_inter`'s rule).
38411+ let (l_ref, l_mv, l_hf, l_vf) = match left_piece {
38412+ Some((l_ref, l_mv, l_hf, l_vf)) => (l_ref, l_mv, l_hf, l_vf),
38413+ None => (pc_ref, pc_mv, pc_hf, pc_vf),
38414+ };
38415+ let Some((l_y, l_u, _)) = ref_planes_deferred(l_ref, refpix) else {
38416+ continue;
38417+ };
38418+ mc::predict_maybe_scaled(
38419+ &l_u.data,
38420+ l_u.width,
38421+ l_u.true_width,
38422+ l_u.true_height,
38423+ mv_to_q4(unit_x, l_mv.1, ss_x(fctx)),
38424+ mv_to_q4(unit_y, l_mv.0, ss_y(fctx)),
38425+ mc::scale_factor(l_y.width, frame_width),
38426+ 2,
38427+ 4,
38428+ l_hf,
38429+ l_vf,
38430+ &mut half, fctx,
38431+ );
38432+ for row in 0..4 {
38433+ buf[row * B4..row * B4 + 2]
38434+ .copy_from_slice(&half[row * 2..row * 2 + 2]);
38435+ }
38436+ } else {
38437+ mc::predict_maybe_scaled(
38438+ &plane.data,
38439+ plane.width,
38440+ plane.true_width,
38441+ plane.true_height,
38442+ mv_to_q4(unit_x, pc_mv.1, ss_x(fctx)),
38443+ mv_to_q4(unit_y, pc_mv.0, ss_y(fctx)),
38444+ pc_scale,
38445+ B4,
38446+ B4,
38447+ pc_hf,
38448+ pc_vf,
38449+ &mut buf, fctx,
38450+ );
38451+ }
38452+ dst.copy_from_slice(&buf);
38453+ }
38454+ out[1] = pred_u;
38455+ out[2] = pred_v;
38456+ };
38457+ let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>);
38458+ let (su, sv) = if recon_deferred(fctx) {
38459+ push_pred(fctx, build_c);
38460+ (
38461+ Pred::Cur { plane: 1, stride: B4, off: 0 },
38462+ Pred::Cur { plane: 2, stride: B4, off: 0 },
38463+ )
38464+ } else {
38465+ let mut built: [Vec<u16>; 3] = Default::default();
38466+ build_c(y, u, v, fctx, &mut built);
38467+ let [_, bu, bv] = built;
38468+ (pred_cu, pred_cv) = (bu, bv);
38469+ (Pred::Inline(&pred_cu, B4), Pred::Inline(&pred_cv, B4))
38470+ };
38471+ let ctx_mi = (lmi.0, lmi.1 & !1);
38472+ let ca = neighbours.around_mi_422_chroma(ctx_mi, 8, 4);
38473+ if skip {
38474+ push_mc(1, unit_x, unit_y, B4, su, &ZERO_RESIDUAL[..B4 * B4], fctx);
38475+ push_mc(2, unit_x, unit_y, B4, sv, &ZERO_RESIDUAL[..B4 * B4], fctx);
38476+ neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]);
38477+ neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]);
38478+ } else {
38479+ hit!(CHROMA422_INTER_SUB8_HITS);
38480+ let (ug, _) = read_inter_plane(
38481+ dec, cdfs, TxbSet::Chroma4, scan4, 1, ca[1], 0, u, unit_x, unit_y, B4,
38482+ base_q_idx, su, Some(piece_tx_type), None, fctx,
38483+ )?;
38484+ let (vg, _) = read_inter_plane(
38485+ dec, cdfs, TxbSet::Chroma4, scan4, 2, ca[2], 0, v, unit_x, unit_y, B4,
38486+ base_q_idx, sv, Some(piece_tx_type), None, fctx,
38487+ )?;
38488+ neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ug);
38489+ neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &vg);
38490+ }
3820238491 }
3820338492 neighbours.record_mode_mi(rmi, cmi, w_mi, h_mi, DC_PRED);
3820438493 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(
3822038509 // `uv_predict_mode`, and this DC stamp ran after it and flattened the
3822138510 // mi-exact cell (class `override-slot-on-one-arm`, this lane's own
3822238511 // 10-bit film gate regression at 1ad7e0fc; port of lane-av1-cfl's
38223- // 7c6dad53).
38224- if !chroma_444 && !intra_chroma {
38512+ // 7c6dad53). lane-av1-422blockhalf: 4:2:2 never takes it either -- the
38513+ // group unit does not exist there; every chroma-reference piece coded
38514+ // (and recorded) its own unit inside the loop above.
38515+ if !chroma_444 && !chroma_422 && !intra_chroma {
3822538516 neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED);
3822638517 }
3822738518 // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map
@@ -38235,7 +38526,10 @@ fn decode_inter_sub8_rect2(
3823538526 record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);
3823638527 // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded
3823738528 // and reconstructed the group's one chroma unit itself.
38238- if !chroma_444 && !intra_chroma {
38529+ // lane-av1-422blockhalf: 4:2:2 never runs this tail -- the shared group
38530+ // unit does not exist at ss (1,0); each chroma-reference piece coded its
38531+ // own U/V TX_4X4 inside the loop above, exactly like the 4:4:4 arm.
38532+ if !chroma_444 && !chroma_422 && !intra_chroma {
3823938533 // The group's single 4x4 chroma unit per plane, on the chroma-reference
3824038534 // (second) sub-block's own skip flag.
3824138535 const B4: usize = 4;
lanes/av1422blockhalf.report.mdadded+133 -0
@@ -0,0 +1,133 @@
1+# lane-av1-422blockhalf — `decode_inter_block`'s 4:2:2 chroma half ported to the
2+# per-axis plane-block model (per-axis pred buffers + real-subsampling masked
3+# compound blend), the `EC_RECTCHROMA_GAP` 16x8 / 8x32 chroma shapes coded as
4+# the (4, 8) unit tiling the Release oracle's OOB `max_txsize_rect_lookup[
5+# BLOCK_INVALID]` byte produces, and `decode_inter_sub8_rect2`'s has_chroma
6+# gating moved from `i == 1` to the per-piece `is_chroma_reference` rule;
7+# frame 0 stays byte-exact at PREFILT/POSTDEB/POSTCDEF, all 16 frames now
8+# decode (the frame-11 `(4, 32)` refusal is gone), and the inter-frame
9+# divergence is REMEASURED and REATTRIBUTED to a partition-dispatch defect
10+# upstream of the chroma half (ours dispatches SPLIT4 where the oracle codes
11+# HORZ at mi(8,10)) — frame exactness NOT claimed for frames 1+
12+
13+## Outcome
14+
15+1. `decode_inter_block`'s chroma PREDICTION buffers (compound and
16+ single-ref arms, OBMC plan, interintra stride, skip pushes, su/sv Pred
17+ strides, the `read_inter_rect_chroma`/`read_inter_chroma_lossless` pred
18+ strides) are keyed to the PLANE BLOCK's own per-axis shape at ss (1, 0):
19+ `(chroma_stride, chroma_buf_h) = (write_chroma_w, write_chroma_h)`
20+ instead of the enclosing square `chroma_side`. The two masked-compound
21+ blend sites now pass the plane's REAL subsampling shifts — the
22+ stop-note's pre-port direct luma-resolution mask read is gone
23+ (aom_dsp/blend-a64-mask.c's `(1, 0)` branch at 4:2:2). Every replaced
24+ expression reduces to the parent values at 4:2:0/4:4:4
25+ (`chroma_stride == chroma_buf_h == chroma_side` there), byte-identical
26+ by construction.
27+2. `read_inter_rect_chroma` now takes the per-axis stride correctly: its
28+ assembled block grid is `stride x plane-height` (`assembled_h`), the
29+ single-unit embed included — the old square `chroma_side * chroma_side`
30+ allocation panicked (`range end index 20 out of range for slice of
31+ length 16`) the moment the per-axis stride reached it.
32+3. `decode_rect_split`'s 4:2:2 BLOCK_INVALID chroma planes: the tall/wide
33+ 1:2 and 1:4 strips (`8x16, 16x32, 32x64, 8x32, 16x64`, + `64x128` for
34+ 128-SB streams) have NO chroma plane block
35+ (`av1_ss_size_lookup[...][1][0] == BLOCK_INVALID`); the plane is still
36+ coded, tiled into (4, 8) rect units — the Release oracle's
37+ out-of-bounds `max_txsize_rect_lookup[BLOCK_INVALID]` byte is TX_4X8
38+ (lane-av1-422m's measurement), and `decode_token_recon_block` steps the
39+ plane in that unit shape. Units read `TxbSet::ChromaRect8x4`/`SCAN_4X8`
40+ with `around_mi_422_chroma` ctx, mode-indexed intra tx type (the
41+ `< 32` square-up rule, pre-existing rect units unchanged at DctDct),
42+ per-unit stamps + units replay. SKIP strips predict per (4, 8) unit as
43+ well (`decode_token_recon_block`'s per-TU plane walk runs before the
44+ skip guard) — the old single whole-plane zero push asked the intra
45+ predictor for a 1:8 rect (`dc_rect_multiplier` panic, bw=8 bh=64).
46+ `EC_RECTCHROMA_GAP` now prints only truly-unhandled shapes (it used to
47+ misfire on every tiled square — the parent lane's `chroma=8x8` rows);
48+ it prints ZERO times on the fixture now. `chroma422_chunk` = 344 on the
49+ full fixture (new units provably fire).
50+4. `decode_inter_sub8_rect2`'s has_chroma gating: per-piece
51+ `is_chroma_reference` — 4:4:4 every piece, 4:2:2 both horz pieces
52+ (`!(bw & 1)`) / the odd-column vert piece (`mi_col & 1`), 4:2:0 keeps
53+ `i == 1` verbatim. The inter pieces take a per-piece inline chroma arm
54+ at 4:2:2 (U then V TX_4X4 at the floored cell, `around_mi_422_chroma`
55+ ctx, inherited piece tx type; horz predicts whole-from-own mv, vert
56+ predicts halves `build_inter_predictors_sub8x8`-style, left half from
57+ the in-group left piece or the decoded grid neighbour when the group
58+ starts on an odd column — filters unavailable on the grid, so an
59+ outside neighbour borrows this piece's filters). The 4:2:0 group tail
60+ (and the group DC stamp) are gated off at 4:2:2.
61+5. MEASURED (17-frame probe, per-OBU cut harness `/tmp/i422/cut_frames.py`,
62+ comparator ours-padded-u8-cropped vs instrumented
63+ `$HOME/.cache/aom-oracle/build` aomdec-cropped-u8; fixture `/tmp/t422.obu`
64+ sha256 `d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`):
65+ - frame 0: byte-exact at PREFILT, POSTDEB and POSTCDEF on Y, U and V —
66+ 0 diffs everywhere (FINAL not re-run this round; frame 0's final state
67+ is bracketed by POSTCDEF on a key frame).
68+ - all 16 frames decode, exit 0 — the parent lane's frame-11 refusal
69+ (`a coded HORZ/VERT strip whose chroma transform has no rect
70+ coefficient tables here`, the `luma=8x32 tx=8x8 chroma=4x32` GAP) is
71+ gone.
72+ - frames 1..15 still diverge (~24-36k Y, ~13-18k U/V per stage; ladder
73+ in `/tmp/i422/ladder/`). **Frame exactness is NOT claimed.**
74+6. REATTRIBUTION (the round's real finding): the frames-1+ divergence is
75+ NOT the chroma half. Strict stream-order EC_ISTEP pairing on the
76+ frames-0-1 cut puts the first entropy divergence at index 167 — the
77+ 8x8 group at mi(8,10): the ORACLE codes PARTITION_HORZ (pieces (8,10)
78+ and (9,10) only, both intra with uv; oracle partition trace
79+ `EC_PART mi_row=8 mi_col=10 bsize=3 ctx=0 value=1`) while OURS
80+ dispatches decode_inter_sub8_split4 (EC_SUB8INTRA: `shape=4x4 sub=0
81+ has_chroma=false mi=8,10` ... four pieces, one extra uv_mode
82+ consumption on the (9,11) odd piece). Same bits, different partition
83+ outcome at the 8x8-leaf partition read (`partition_w8` ctx/value —
84+ ours `ctx=2` at the (8,8) sibling). Every downstream diff in the
85+ ladder is walk-shift noise from that point. This is a pre-existing
86+ defect upstream of the named chroma surfaces, newly visible now that
87+ the chroma shapes no longer refuse.
88+
89+## Decision
90+
91+- The header refusal STAYS unconditional in `stream.rs`; the bypass was
92+ local-only, applied and reverted byte-identical (0 occurrences left;
93+ `stream::tests::a_non_420_subsampled_sequence_header_is_refused_by_name`
94+ green after the revert).
95+- 4:2:0/4:4:4 untouched by construction (ss-keyed arms; the 4:2:0 sub8
96+ group tail and `i == 1` rule verbatim).
97+- `read_coeffs_rect` untouched; the 4:2:0 group-tail SKIP arm untouched.
98+
99+## Deferred
100+
101+(a) The (8,10)-class partition-dispatch defect (ours SPLIT4 vs oracle
102+ HORZ) — the frames-1+ exactness blocker. Unblock: capture the 8x8
103+ leaf partition context both sides (ours `EC_TRACE_PART`, oracle's
104+ shipped partition probe) and compare `partition_ctx_mi` vs libaom's
105+ `partition_context` gather at that leaf; the chroma half itself is
106+ now shape-honest and rides on the fix.
107+(b) 4-wide strips (4x16, 4x8 luma) at 4:2:2: `decode_rect_split` still
108+ refuses `(2, 16)` chroma by name (no pair-anchor machinery there; the
109+ 4:2:0 `(4, 16)` single-unit arm would be wrong at ss (1, 0)).
110+ Unblock: the split4-style floored-pair anchor ported to the 1-mi-wide
111+ strip callers, then the OOB (4, 8) tiling.
112+(c) 128-root 4:2:2 chroma chunking (`decode_inter_block`'s side > 64
113+ mu-chunk chroma) still passes the square `chroma_side` geometry —
114+ unreachable on <=64-superblock streams (this fixture is 64-SB);
115+ flagged for whoever lands 4:2:2 128-SB support.
116+
117+## Verification
118+
119+- `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422blockhalf`):
120+ 0 warnings, 0 errors.
121+- Refusal gate green post-revert (1 passed).
122+- Probe: `OK: 16 frames decoded`; 0 `EC_RECTCHROMA_GAP` prints;
123+ `chroma422_chunk=344`, `chroma422_square=197` on the full fixture.
124+- Ladder: frame 0 = 0 diffs at PREFILT/POSTDEB/POSTCDEF (Y=U=V); frames
125+ 1..15 divergent (see 5/6 — attributed, not claimed).
126+
127+## State
128+
129+- Commit on lane-av1-422blockhalf (no push): the per-axis decode_inter_block
130+ chroma half, the read_inter_rect_chroma stride fix, the decode_rect_split
131+ (4, 8) chroma tiling incl. per-unit skip prediction, the rect2 per-piece
132+ has_chroma gating, and this report.
133+- Ladder dumps under `/tmp/i422/ladder/` (scratch, not committed).