forge
Explore
Log in

Don't you dare go Hollow

ec-av1: 4:4:4 inter sub8/64x64 chroma port, entropy ladder end-to-end clean

Browse files at this commit

30614c6cd96cc3986ea718b32e7b9715a84b9571Ahmet Kaan GümüşParent: e21f07c
- split4 per-piece chroma inherits the piece's own luma tx_type
  (av1_get_tx_type, blockd.h:1291); fixes the round-4 eob_multi_ctx wall
- rect2 per-piece 8x4/4x8 chroma units (ChromaRect8x4), group unit
  gated to 4:2:0, mode bookkeeping hoisted
- decode_intra_sub8_leaf chroma is per-piece at ss 0/0: 4x4 square and
  own-shape rect units anchored at the piece, uv-mode tx derivation
- 64x64 inter blocks code four TX_32X32 chroma units plane-major with
  the +10 txb_skip offset (rows at +3, lane-sb128b convention)

Fixture: entropy ladder in sync end-to-end (24-frame cut, zero
mismatch); shown frames 0..17 byte-exact; frame 18 carries a 2-sample
U +1 reconstruction diff (pre-filter, prediction identical) - see
lanes/av1444.report.md continuation 5.
crates/ec-av1/src/decode.rsmodified+308 -25
@@ -29515,6 +29515,55 @@ fn decode_inter_block(
29515 mode_for_tx,29515 mode_for_tx,
29516 luma_tx_type, fctx,29516 luma_tx_type, fctx,
29517 )?;29517 )?;
29518+ } else if ss_x(fctx) == 0 && ss_y(fctx) == 0 && chroma_side > chroma_tx {
29519+ // lane-av1-444: at ss 0/0 this block's chroma plane is
29520+ // `chroma_side` square while `av1_get_max_uv_txsize` caps
29521+ // the units at TX_32X32 -- each plane codes FOUR TX_32X32
29522+ // units, plane-major inside the block's one 64x64 mu chunk
29523+ // (libaom `decode_token_recon_block`'s plane loop). Each
29524+ // unit's `txb_skip_ctx` carries the +10
29525+ // `get_txb_ctx_general` offset (plane block larger than the
29526+ // transform); our `txb_skip_chroma_32` holds those rows at
29527+ // +3, so `luma_skip_ctx: Some(3)` (lane-sb128b r3's
29528+ // convention, as the 128 mu path above).
29529+ let cu_tx = chroma_tx;
29530+ let mu_chroma_units = chroma_side / cu_tx;
29531+ for plane_idx in 1..3 {
29532+ let (src, buf) = if plane_idx == 1 { (su, &mut *u) } else { (sv, &mut *v) };
29533+ for cr in 0..mu_chroma_units {
29534+ for cc in 0..mu_chroma_units {
29535+ let cu_mi = (rmi + cr * (cu_tx / MI), cmi + cc * (cu_tx / MI));
29536+ let cu_around = neighbours.around_mi(cu_mi, cu_tx);
29537+ let cu_grid = read_inter_plane(
29538+ dec,
29539+ cdfs,
29540+ chroma_set,
29541+ &scan_chroma,
29542+ plane_idx,
29543+ cu_around[plane_idx],
29544+ mode_for_tx,
29545+ buf,
29546+ cpx + cc * cu_tx,
29547+ cpy + cr * cu_tx,
29548+ cu_tx,
29549+ base_q_idx,
29550+ src.offset(cr * cu_tx * chroma_side + cc * cu_tx),
29551+ Some(luma_tx_type),
29552+ Some(3), fctx,
29553+ )?
29554+ .0;
29555+ // Immediately, so the next unit's context sees
29556+ // this one's coefficients.
29557+ neighbours.record_mi_chroma(
29558+ cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid,
29559+ );
29560+ hit!(CHROMA_SPLIT_TX_HITS);
29561+ }
29562+ }
29563+ }
29564+ mu_chroma = true;
29565+ u_grid = Grid::Zero(chroma_side * chroma_side);
29566+ v_grid = Grid::Zero(chroma_side * chroma_side);
29518 } else {29567 } else {
29519 u_grid = read_inter_plane(29568 u_grid = read_inter_plane(
29520 dec,29569 dec,
@@ -30827,6 +30876,55 @@ fn decode_inter_block(
30827 mode_for_tx,30876 mode_for_tx,
30828 luma_tx_type, fctx,30877 luma_tx_type, fctx,
30829 )?;30878 )?;
30879+ } else if ss_x(fctx) == 0 && ss_y(fctx) == 0 && chroma_side > chroma_tx {
30880+ // lane-av1-444: at ss 0/0 this block's chroma plane is
30881+ // `chroma_side` square while `av1_get_max_uv_txsize` caps
30882+ // the units at TX_32X32 -- each plane codes FOUR TX_32X32
30883+ // units, plane-major inside the block's one 64x64 mu chunk
30884+ // (libaom `decode_token_recon_block`'s plane loop). Each
30885+ // unit's `txb_skip_ctx` carries the +10
30886+ // `get_txb_ctx_general` offset (plane block larger than the
30887+ // transform); our `txb_skip_chroma_32` holds those rows at
30888+ // +3, so `luma_skip_ctx: Some(3)` (lane-sb128b r3's
30889+ // convention, as the 128 mu path above).
30890+ let cu_tx = chroma_tx;
30891+ let mu_chroma_units = chroma_side / cu_tx;
30892+ for plane_idx in 1..3 {
30893+ let (src, buf) = if plane_idx == 1 { (su, &mut *u) } else { (sv, &mut *v) };
30894+ for cr in 0..mu_chroma_units {
30895+ for cc in 0..mu_chroma_units {
30896+ let cu_mi = (rmi + cr * (cu_tx / MI), cmi + cc * (cu_tx / MI));
30897+ let cu_around = neighbours.around_mi(cu_mi, cu_tx);
30898+ let cu_grid = read_inter_plane(
30899+ dec,
30900+ cdfs,
30901+ chroma_set,
30902+ &scan_chroma,
30903+ plane_idx,
30904+ cu_around[plane_idx],
30905+ mode_for_tx,
30906+ buf,
30907+ cpx + cc * cu_tx,
30908+ cpy + cr * cu_tx,
30909+ cu_tx,
30910+ base_q_idx,
30911+ src.offset(cr * cu_tx * chroma_side + cc * cu_tx),
30912+ Some(luma_tx_type),
30913+ Some(3), fctx,
30914+ )?
30915+ .0;
30916+ // Immediately, so the next unit's context sees
30917+ // this one's coefficients.
30918+ neighbours.record_mi_chroma(
30919+ cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid,
30920+ );
30921+ hit!(CHROMA_SPLIT_TX_HITS);
30922+ }
30923+ }
30924+ }
30925+ mu_chroma = true;
30926+ u_grid = Grid::Zero(chroma_side * chroma_side);
30927+ v_grid = Grid::Zero(chroma_side * chroma_side);
30830 } else {30928 } else {
30831 u_grid = read_inter_plane(30929 u_grid = read_inter_plane(
30832 dec,30930 dec,
@@ -31944,6 +32042,10 @@ fn decode_inter_sub8_split4(
31944 [None; 4];32042 [None; 4];
31945 let mut first_tx_type = TxType::DctDct;32043 let mut first_tx_type = TxType::DctDct;
31946 let mut sub0_tx_type = TxType::DctDct;32044 let mut sub0_tx_type = TxType::DctDct;
32045+ // This loop iteration's own sub-block luma `tx_type` (libaom `mbmi->tx_type`
32046+ // after its `read_tx_type`): the per-piece 4:4:4 chroma units inherit it
32047+ // (`av1_get_tx_type`, blockd.h -- inter chroma never codes its own symbol).
32048+ let mut piece_tx_type = TxType::DctDct;
31947 let mut last_skip = true;32049 let mut last_skip = true;
31948 // Set when the chroma-reference (last) sub-block is INTRA: it coded the32050 // Set when the chroma-reference (last) sub-block is INTRA: it coded the
31949 // group's one chroma unit itself.32051 // group's one chroma unit itself.
@@ -32291,6 +32393,7 @@ fn decode_inter_sub8_split4(
32291 None,32393 None,
32292 None, fctx,32394 None, fctx,
32293 )?;32395 )?;
32396+ piece_tx_type = tx_type;
32294 if i == 0 {32397 if i == 0 {
32295 sub0_tx_type = tx_type;32398 sub0_tx_type = tx_type;
32296 }32399 }
@@ -32315,8 +32418,11 @@ fn decode_inter_sub8_split4(
32315 // (aomdec EC_COEFF on `av1-profile1-444.ivf` frame 1). Chroma MC is32418 // (aomdec EC_COEFF on `av1-profile1-444.ivf` frame 1). Chroma MC is
32316 // the piece's own mv and filters at the piece's own pixel position32419 // the piece's own mv and filters at the piece's own pixel position
32317 // (ss 0: the chroma planes share luma's grid), and each unit's32420 // (ss 0: the chroma planes share luma's grid), and each unit's
32318- // tx_type is its own piece's luma type -- a TX_4X4 codes no tx_type32421+ // tx_type is its own piece's luma type -- an inter block's chroma
32319- // symbol, so DctDct.32422+ // plane never codes its own tx_type symbol but inherits the
32423+ // colocated luma transform's coded type verbatim (`av1_get_tx_type`,
32424+ // blockd.h), which decides the eob CDF's class-1 row
32425+ // (`eob_multi_ctx`, decodetxb.c:214).
32320 if chroma_444 {32426 if chroma_444 {
32321 let (pc_ref, pc_mv, pc_hf, pc_vf) = piece[i].expect("inter piece recorded above");32427 let (pc_ref, pc_mv, pc_hf, pc_vf) = piece[i].expect("inter piece recorded above");
32322 let build_c = move |_y: &mut PlaneBuf<'static>,32428 let build_c = move |_y: &mut PlaneBuf<'static>,
@@ -32374,11 +32480,11 @@ fn decode_inter_sub8_split4(
32374 let ca = neighbours.around_mi(lmi, B4);32480 let ca = neighbours.around_mi(lmi, B4);
32375 let (ug, _) = read_inter_plane(32481 let (ug, _) = read_inter_plane(
32376 dec, cdfs, TxbSet::Chroma4, scan4, 1, ca[1], 0, u, px, py, B4, base_q_idx,32482 dec, cdfs, TxbSet::Chroma4, scan4, 1, ca[1], 0, u, px, py, B4, base_q_idx,
32377- su, Some(TxType::DctDct), None, fctx,32483+ su, Some(piece_tx_type), None, fctx,
32378 )?;32484 )?;
32379 let (vg, _) = read_inter_plane(32485 let (vg, _) = read_inter_plane(
32380 dec, cdfs, TxbSet::Chroma4, scan4, 2, ca[2], 0, v, px, py, B4, base_q_idx,32486 dec, cdfs, TxbSet::Chroma4, scan4, 2, ca[2], 0, v, px, py, B4, base_q_idx,
32381- sv, Some(TxType::DctDct), None, fctx,32487+ sv, Some(piece_tx_type), None, fctx,
32382 )?;32488 )?;
32383 neighbours.record_mi_chroma(lmi, B4, B4, 1, &ug);32489 neighbours.record_mi_chroma(lmi, B4, B4, 1, &ug);
32384 neighbours.record_mi_chroma(lmi, B4, B4, 2, &vg);32490 neighbours.record_mi_chroma(lmi, B4, B4, 2, &vg);
@@ -32612,6 +32718,14 @@ fn decode_intra_sub8_leaf(
32612 // `is_cfl_allowed` is `wide <= 32 && high <= 32` -- true for this32718 // `is_cfl_allowed` is `wide <= 32 && high <= 32` -- true for this
32613 // shape, so the 14-symbol CFL alphabet is the right one.32719 // shape, so the 14-symbol CFL alphabet is the right one.
32614 let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]);32720 let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]);
32721+ if step {
32722+ eprintln!(
32723+ "EC_ISTEP mi_row={} mi_col={} name=uv_mode val={uv_mode} rng={}",
32724+ lmi.0,
32725+ lmi.1,
32726+ dec.debug_state().0
32727+ );
32728+ }
32615 if (9..=12).contains(&uv_mode) {32729 if (9..=12).contains(&uv_mode) {
32616 hit!(SMOOTH_UV_HITS);32730 hit!(SMOOTH_UV_HITS);
32617 }32731 }
@@ -32936,39 +33050,114 @@ fn decode_intra_sub8_leaf(
32936 // group is intra, and the decoder reconstructs chroma with the33050 // group is intra, and the decoder reconstructs chroma with the
32937 // chroma-reference block's own type. Same body as [`decode_leaf_rect8`]'s33051 // chroma-reference block's own type. Same body as [`decode_leaf_rect8`]'s
32938 // post-loop chroma.33052 // post-loop chroma.
33053+ //
33054+ // lane-av1-444: at ss 0/0 EVERY piece is its own chroma reference
33055+ // (`is_chroma_reference`, av1_common_int.h:1459), so the unit anchors at
33056+ // the piece's own position with the piece's own shape -- a 4x4 unit under
33057+ // SPLIT, the leaf's own 8x4/4x8 unit under HORZ/VERT (`ChromaRect8x4`,
33058+ // tx_type from the uv mode via `Intra_Mode_To_Tx_Type`, which decides the
33059+ // eob CDF's class-1 row, decodetxb.c:214).
33060+ let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0;
32939 let (gpx, gpy) = (gc * MI, gr * MI);33061 let (gpx, gpy) = (gc * MI, gr * MI);
32940 let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx));33062 let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx));
33063+ let (unit_x, unit_y) = if chroma_444 { (px, py) } else { (cpx, cpy) };
32941 let group_reach = Reach::of(8, gpx, gpy, y.width, y.height, fctx);33064 let group_reach = Reach::of(8, gpx, gpy, y.width, y.height, fctx);
32942- let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(gr, gc, r, c, fctx);33065+ let reach_c = if chroma_444 && bw != bh {
33066+ Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx)
33067+ } else if chroma_444 {
33068+ Reach::of(bw, px, py, y.width, y.height, fctx)
33069+ } else {
33070+ group_reach
33071+ };
33072+ let (band_r, band_c) = if chroma_444 {
33073+ (lmi.0 / (SUB / MI), lmi.1 / (SUB / MI))
33074+ } else {
33075+ (r, c)
33076+ };
33077+ let smooth_neighbor_uv =
33078+ neighbours.smooth_uv_neighbour(if chroma_444 { lmi.0 } else { gr }, if chroma_444 { lmi.1 } else { gc }, band_r, band_c, fctx);
32943 let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };33079 let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
32944 let angle_delta_uv = 0;33080 let angle_delta_uv = 0;
32945- neighbours.above_uv_mode[c] = uv_predict_mode;33081+ neighbours.above_uv_mode[band_c] = uv_predict_mode;
32946- neighbours.left_uv_mode[r] = uv_predict_mode;33082+ neighbours.left_uv_mode[band_r] = uv_predict_mode;
33083+ if chroma_444 {
33084+ neighbours.record_uv_mode_mi(lmi.0, lmi.1, w_mi, h_mi, uv_predict_mode);
33085+ } else {
32947 neighbours.record_uv_mode_mi(gr, gc, 2, 2, uv_predict_mode);33086 neighbours.record_uv_mode_mi(gr, gc, 2, 2, uv_predict_mode);
33087+ }
32948 33088
32949- let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));33089+ let ac = alpha.map(|_| if chroma_444 { cfl_src_rect(px, py, bw, bh) } else { cfl_src(gpx, gpy, 8) });
32950 let (u_grid, v_grid): (Grid, Grid) = if skip {33090 let (u_grid, v_grid): (Grid, Grid) = if skip {
32951 if alpha.is_some() {33091 if alpha.is_some() {
32952 hit!(CHROMA_SKIP_CFL_HITS);33092 hit!(CHROMA_SKIP_CFL_HITS);
32953 hit!(SKIP_CFL_HITS);33093 hit!(SKIP_CFL_HITS);
32954 }33094 }
32955- push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);33095+ if chroma_444 && bw != bh {
32956- push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);33096+ let zeros = Grid::Zero(bw * bh);
33097+ push_intra_rect(1, unit_x, unit_y, bw, bh, uv_predict_mode, angle_delta_uv, reach_c, &zeros, alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);
33098+ push_intra_rect(2, unit_x, unit_y, bw, bh, uv_predict_mode, angle_delta_uv, reach_c, &zeros, alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);
33099+ (zeros, Grid::Zero(bw * bh))
33100+ } else {
33101+ push_intra(1, unit_x, unit_y, 4, uv_predict_mode, angle_delta_uv, reach_c, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);
33102+ push_intra(2, unit_x, unit_y, 4, uv_predict_mode, angle_delta_uv, reach_c, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);
32957 (Grid::Zero(16), Grid::Zero(16))33103 (Grid::Zero(16), Grid::Zero(16))
33104+ }
33105+ } else if chroma_444 && bw != bh {
33106+ // The leaf's own TX_8X4/TX_4X8 chroma unit: it IS the chroma plane
33107+ // block, so `get_txb_ctx` fixes the skip context at above+left.
33108+ let ca = neighbours.around_mi_rect(lmi, bw, bh);
33109+ let scan_c: &[u16] = if vert { &SCAN_4X8 } else { &SCAN_8X4 };
33110+ let uv_tx = default_intra_tx_type(uv_predict_mode as u8);
33111+ let mut read_chroma = |plane: usize,
33112+ around: (bool, bool, i32),
33113+ alpha_uv: Option<(i32, CflSrc)>|
33114+ -> Result<Grid> {
33115+ let mut coding = cdfs.txb(TxbSet::ChromaRect8x4, 0);
33116+ let skip_ctx = usize::from(around.0) + usize::from(around.1);
33117+ let (levels, tx_type) = read_coeffs_rect(
33118+ dec,
33119+ &mut coding,
33120+ scan_c,
33121+ bw,
33122+ bh,
33123+ skip_ctx,
33124+ dc_sign_ctx(around.2),
33125+ uv_tx,
33126+ )?;
33127+ let residual = dequant_and_inverse_typed_wh(
33128+ &levels,
33129+ bw,
33130+ bh,
33131+ crate::decode::bit_depth(fctx),
33132+ block_q_idx(fctx),
33133+ plane_q_delta(plane, fctx).0,
33134+ plane_q_delta(plane, fctx).1,
33135+ tx_type,
33136+ );
33137+ push_intra_rect(plane, unit_x, unit_y, bw, bh, uv_predict_mode, angle_delta_uv, reach_c, &residual, alpha_uv, None, smooth_neighbor_uv, fctx);
33138+ Ok(levels)
33139+ };
33140+ let ug = read_chroma(1, ca[1], alpha.zip(ac).map(|((au, _), ac)| (au, ac)))?;
33141+ let vg = read_chroma(2, ca[2], alpha.zip(ac).map(|((_, av), ac)| (av, ac)))?;
33142+ (ug, vg)
32958 } else {33143 } else {
32959- let chroma_around = neighbours.around_mi(group_mi, 8);33144+ let chroma_around = neighbours.around_mi(if chroma_444 { lmi } else { group_mi }, if chroma_444 { 4 } else { 8 });
32960 let ug = read_plane(33145 let ug = read_plane(
32961 dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,33146 dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,
32962- angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx,33147+ angle_delta_uv, reach_c, u, unit_x, unit_y, 4, TX4, base_q_idx,
32963 alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx,33148 alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx,
32964 )?;33149 )?;
32965 let vg = read_plane(33150 let vg = read_plane(
32966 dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,33151 dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,
32967- angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx,33152+ angle_delta_uv, reach_c, v, unit_x, unit_y, 4, TX4, base_q_idx,
32968 alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx,33153 alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx,
32969 )?;33154 )?;
32970 (ug, vg)33155 (ug, vg)
32971 };33156 };
33157+ if chroma_444 {
33158+ neighbours.record_mi_chroma(lmi, bw, bh, 1, &u_grid);
33159+ neighbours.record_mi_chroma(lmi, bw, bh, 2, &v_grid);
33160+ } else {
32972 let round_up_even = |n: usize| n.div_ceil(2) * 2;33161 let round_up_even = |n: usize| n.div_ceil(2) * 2;
32973 let bound_h = round_up_even(neighbours.mi_rows);33162 let bound_h = round_up_even(neighbours.mi_rows);
32974 let bound_w = round_up_even(neighbours.mi_cols);33163 let bound_w = round_up_even(neighbours.mi_cols);
@@ -32984,6 +33173,7 @@ fn decode_intra_sub8_leaf(
32984 neighbours.above[gc + cell][2] = v_state;33173 neighbours.above[gc + cell][2] = v_state;
32985 }33174 }
32986 }33175 }
33176+ }
32987 Ok(mode)33177 Ok(mode)
32988 }33178 }
32989 33179
@@ -33073,6 +33263,16 @@ fn decode_inter_sub8_rect2(
33073 [None; 2];33263 [None; 2];
33074 let mut first_tx_type = TxType::DctDct;33264 let mut first_tx_type = TxType::DctDct;
33075 let mut sub0_tx_type = TxType::DctDct;33265 let mut sub0_tx_type = TxType::DctDct;
33266+ // lane-av1-444: `is_chroma_reference` is unconditional at subsampling 0/0
33267+ // (av1_common_int.h:1459), so every 8x4/4x8 piece is its own chroma
33268+ // reference and codes its own 8x4/4x8 U/V units right after its luma --
33269+ // there is no shared group unit (aomdec EC_COEFF on
33270+ // `av1-profile1-444.ivf` decode-order frame 1, mi (3,8)).
33271+ let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0;
33272+ // This piece's first transform's luma `tx_type` (libaom `mbmi->tx_type`):
33273+ // an inter block's chroma plane never codes its own symbol but inherits
33274+ // the colocated luma type (`av1_get_tx_type`, blockd.h:1291).
33275+ let mut piece_tx_type = TxType::DctDct;
33076 let mut last_skip = true;33276 let mut last_skip = true;
33077 // Set when the chroma-reference sub-block is INTRA: it coded the group's33277 // Set when the chroma-reference sub-block is INTRA: it coded the group's
33078 // one chroma unit itself.33278 // one chroma unit itself.
@@ -33147,7 +33347,7 @@ fn decode_inter_sub8_rect2(
33147 group_mi,33347 group_mi,
33148 lmi,33348 lmi,
33149 (bw, bh),33349 (bw, bh),
33150- i == 1,33350+ chroma_444 || i == 1,
33151 skip,33351 skip,
33152 scan4,33352 scan4,
33153 y,33353 y,
@@ -33468,6 +33668,9 @@ fn decode_inter_sub8_rect2(
33468 None, fctx,33668 None, fctx,
33469 )?33669 )?
33470 };33670 };
33671+ if idx == 0 {
33672+ piece_tx_type = tu_tx_type;
33673+ }
33471 if idx == 0 && i == 0 {33674 if idx == 0 && i == 0 {
33472 sub0_tx_type = tu_tx_type;33675 sub0_tx_type = tu_tx_type;
33473 }33676 }
@@ -33491,14 +33694,104 @@ fn decode_inter_sub8_rect2(
33491 ref_frame.max(LAST_FRAME), fctx,33694 ref_frame.max(LAST_FRAME), fctx,
33492 );33695 );
33493 }33696 }
33697+ // lane-av1-444: at ss 0/0 this piece codes its OWN 8x4/4x8 U and V
33698+ // units right after its luma, plane order 0,1,2 (libaom decodes each
33699+ // piece as its own block: `decode_token_recon_block`'s plane-major
33700+ // loop over `av1_get_max_uv_txsize(BLOCK_8X4, 0, 0) == TX_8X4`). The
33701+ // unit's prediction is the piece's own mv/filters at the piece's own
33702+ // pixel position (ss 0: the chroma planes share luma's grid), and its
33703+ // tx_type is this piece's first luma transform's coded type.
33704+ if chroma_444 {
33705+ let build_c = move |_y: &mut PlaneBuf<'static>,
33706+ _u: &mut PlaneBuf<'static>,
33707+ _v: &mut PlaneBuf<'static>,
33708+ fctx: &crate::decode::FrameCtx,
33709+ out: &mut [Vec<u16>; 3]| {
33710+ let Some((_, sref_u, sref_v)) = ref_planes_deferred(ref_frame, refpix) else {
33711+ return;
33712+ };
33713+ let piece_scale = mc::scale_factor(ref_width, frame_width);
33714+ let mut pred_u = refill(std::mem::take(&mut out[1]), SIDE * SIDE);
33715+ let mut pred_v = refill(std::mem::take(&mut out[2]), SIDE * SIDE);
33716+ for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] {
33717+ let mut dense = vec![0u16; bw * bh];
33718+ mc::predict_maybe_scaled(
33719+ &plane.data,
33720+ plane.width,
33721+ plane.true_width,
33722+ plane.true_height,
33723+ mv_to_q4(px, mv.1, ss_x(fctx)),
33724+ mv_to_q4(py, mv.0, ss_x(fctx)),
33725+ piece_scale,
33726+ bw,
33727+ bh,
33728+ h_filter,
33729+ v_filter,
33730+ &mut dense, fctx,
33731+ );
33732+ for row in 0..bh {
33733+ dst[row * SIDE..][..bw].copy_from_slice(&dense[row * bw..][..bw]);
33734+ }
33735+ }
33736+ out[1] = pred_u;
33737+ out[2] = pred_v;
33738+ };
33739+ let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>);
33740+ let (su, sv) = if recon_deferred(fctx) {
33741+ push_pred(fctx, build_c);
33742+ (
33743+ Pred::Cur { plane: 1, stride: SIDE, off: 0 },
33744+ Pred::Cur { plane: 2, stride: SIDE, off: 0 },
33745+ )
33746+ } else {
33747+ let mut built: [Vec<u16>; 3] = Default::default();
33748+ build_c(y, u, v, fctx, &mut built);
33749+ let [_, bu, bv] = built;
33750+ (pred_cu, pred_cv) = (bu, bv);
33751+ (Pred::Inline(&pred_cu, SIDE), Pred::Inline(&pred_cv, SIDE))
33752+ };
33753+ if skip {
33754+ push_mc_rect(1, px, py, SIDE, bw, bh, su, &ZERO_RESIDUAL[..SIDE * SIDE], fctx);
33755+ push_mc_rect(2, px, py, SIDE, bw, bh, sv, &ZERO_RESIDUAL[..SIDE * SIDE], fctx);
33756+ neighbours.record_mi_chroma(lmi, bw, bh, 1, &ZERO_RESIDUAL[..bw * bh]);
33757+ neighbours.record_mi_chroma(lmi, bw, bh, 2, &ZERO_RESIDUAL[..bw * bh]);
33758+ } else {
33759+ let ca = neighbours.around_mi_rect(lmi, bw, bh);
33760+ let (ug, _) = read_inter_plane_rect(
33761+ dec, cdfs, TxbSet::ChromaRect8x4, (bw, bh), SIDE, 1, ca[1], 0, u, px, py,
33762+ su, Some(piece_tx_type), None, fctx,
33763+ )?;
33764+ let (vg, _) = read_inter_plane_rect(
33765+ dec, cdfs, TxbSet::ChromaRect8x4, (bw, bh), SIDE, 2, ca[2], 0, v, px, py,
33766+ sv, Some(piece_tx_type), None, fctx,
33767+ )?;
33768+ neighbours.record_mi_chroma(lmi, bw, bh, 1, &ug);
33769+ neighbours.record_mi_chroma(lmi, bw, bh, 2, &vg);
33770+ }
33771+ }
33494 neighbours.record_mode_mi(rmi, cmi, w_mi, h_mi, DC_PRED);33772 neighbours.record_mode_mi(rmi, cmi, w_mi, h_mi, DC_PRED);
33495 neighbours.record_inter_rect_mi(lmi, w_mi, h_mi, skip, true, ref_frame, resolved_filter, false);33773 neighbours.record_inter_rect_mi(lmi, w_mi, h_mi, skip, true, ref_frame, resolved_filter, false);
33496 neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip);33774 neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip);
33497 last_skip = skip;33775 last_skip = skip;
33498 }33776 }
33777+ // lane-av1-444: at ss 0/0 the group unit does not exist -- each piece
33778+ // coded its own U/V inside the loop above. The mode-level bookkeeping
33779+ // below still runs for both subsamplings: an inter piece's
33780+ // `mbmi->uv_mode` is the DC_PRED default and no piece can be a palette
33781+ // block, exactly as the 4:2:0 path already published.
33782+ neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED);
33783+ // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map
33784+ // needs EVERY writer): a sub-8x8 group published no palette state, so
33785+ // once an 8x8 leaf of the same row can BE a palette block, the group
33786+ // left the row's band holding that earlier block's size and the next
33787+ // intra block read `av1_get_palette_mode_ctx` one too high (measured:
33788+ // mi(30,30) of decode-order frame 1, ours ctx 1 where libaom gathers
33789+ // 0). No sub-8x8 piece can itself be a palette (`av1_allow_palette`
33790+ // needs `bsize >= BLOCK_8X8`), so the group always clears.
33791+ record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);
33499 // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded33792 // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded
33500 // and reconstructed the group's one chroma unit itself.33793 // and reconstructed the group's one chroma unit itself.
33501- if !intra_chroma {33794+ if !chroma_444 && !intra_chroma {
33502 // The group's single 4x4 chroma unit per plane, on the chroma-reference33795 // The group's single 4x4 chroma unit per plane, on the chroma-reference
33503 // (second) sub-block's own skip flag.33796 // (second) sub-block's own skip flag.
33504 const B4: usize = 4;33797 const B4: usize = 4;
@@ -33615,16 +33908,6 @@ fn decode_inter_sub8_rect2(
33615 note_sub8_chroma_tx(sub0_tx_type, first_tx_type, coded);33908 note_sub8_chroma_tx(sub0_tx_type, first_tx_type, coded);
33616 (ug, vg)33909 (ug, vg)
33617 };33910 };
33618- neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED);
33619- // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map
33620- // needs EVERY writer): a sub-8x8 group published no palette state, so
33621- // once an 8x8 leaf of the same row can BE a palette block, the group
33622- // left the row's band holding that earlier block's size and the next
33623- // intra block read `av1_get_palette_mode_ctx` one too high (measured:
33624- // mi(30,30) of decode-order frame 1, ours ctx 1 where libaom gathers
33625- // 0). No sub-8x8 piece can itself be a palette (`av1_allow_palette`
33626- // needs `bsize >= BLOCK_8X8`), so the group always clears.
33627- record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);
33628 let round_up_even = |n: usize| n.div_ceil(2) * 2;33911 let round_up_even = |n: usize| n.div_ceil(2) * 2;
33629 let bound_h = round_up_even(neighbours.mi_rows);33912 let bound_h = round_up_even(neighbours.mi_rows);
33630 let bound_w = round_up_even(neighbours.mi_cols);33913 let bound_w = round_up_even(neighbours.mi_cols);
lanes/av1444.report.mdmodified+98 -14
@@ -9,9 +9,12 @@ Status: **WIP**. 4:4:4 is byte-exact on every SQUARE witness: 8-bit
9 profile 1 filters off AND on (loop filter + CDEF + restoration),9 profile 1 filters off AND on (loop filter + CDEF + restoration),
10 forced-64x64-block arms (exercises the four-TX_32X32 chroma loop),10 forced-64x64-block arms (exercises the four-TX_32X32 chroma loop),
11 10-bit profile 2 filters off AND on. 420 square arms stay IDENTICAL11 10-bit profile 2 filters off AND on. 420 square arms stay IDENTICAL
12-(regression). 4:2:2 stays a named refusal. The rect/1:4 paths at 4:4:412+(regression). 4:2:2 stays a named refusal. The inter sub8/64x64 chroma
13-are mid-port: `av1-profile1-444.ivf` gets further every round but still13+paths at 4:4:4 are now ported (continuation 5, below): the entropy
14-panics (see below). Full suite NOT run.14+ladder of `av1-profile1-444.ivf` is in sync END-TO-END and shown frames
15+0..17 are byte-exact vs aomdec/ffmpeg; frame 18 carries the first pixel
16+diff (2 U samples, +1, pre-filter — reconstruction, not entropy).
17+Full suite NOT run this round (budget wall).
15 18
16 ## What changed (this continuation, on top of the staged WIP commit)19 ## What changed (this continuation, on top of the staged WIP commit)
17 20
@@ -158,14 +161,95 @@ panics (see below). Full suite NOT run.
158 161
159 ## Next162 ## Next
160 163
161-1. Fix the chroma-4x4 eob CDF adaptation-source mismatch (see wall above):164+1. Frame 18's 2-pixel U diff (see continuation 5's wall): confirm
162- diff `eob_flag_cdf16[UV][2D]` adaptation sources per TU — port165+ whether the covering block is a UV-PALETTE block (`intra_in_inter_palette:
163- `decode_inter_sub8_rect2` per-piece chroma (8x4/4x8 units, same166+ uv=76` counter fires) — compare `read_palette_colors_uv`
164- 16-coeff eob class) and verify the intra 16x4/4x16 strips' chroma167+ (decode.rs:8979, libaom decodemv.c:509) delta decoding vs libaom, or
165- units land on `eob_flag_cdf16[UV][2D]` at 4:4:4.168+ if not palette, dump the residual/inverse of the covering 4x4.
166-2. Then re-run the ladder: divergence should move past (2,6)U; iterate169+2. Then frames 18..59: iterate the same way (ladder is already
167- until decode_idx 1 is bit-exact, then frames 2..59.170+ end-to-end clean on the 24-frame cut, so expect reconstruction-only
168-3. Then the fixture end-to-end vs ffmpeg; flip the refusal gate171+ walls; re-diff per frame group).
169- (`a_non_420_subsampled_sequence_header_is_refused_by_name` re-scope)172+3. Flip the refusal gate (`a_non_420_subsampled_sequence_header_is_
170- to a fixture witness gate; witness or refuse inter square 64x64 444.173+ refused_by_name` re-scope) to a fixture witness gate; witness or
171-4. Full suite `--test-threads=1`, 0-warning parity, update this report.174+ refuse inter square 64x64 444 (the forced-64x64 witness already
175+ passes — that arm is intra-only, the inter 64x64 path is new).
176+4. Full suite `--test-threads=1` (NOT run this round), 0-warning
177+ parity (build IS warning-clean), update this report.
178+
179+## Continuation 5 (2026-09-23, Semiha)
180+
181+Round-4's wall was misdiagnosed: aom's divergent eob read was
182+`eob_flag_cdf16[PLANE_UV][ctx=1]` (the trace prints `ctx=1`; the
183+"[UV][2D]" reading was wrong), adapted in frame 1, while ours bound the
184+ctx-0 row. Chasing it surfaced four real defects, all entropy-side; the
185+whole-stream ladder then went clean and the wall moved to a
186+reconstruction rounding.
187+
188+1. **`decode_inter_sub8_split4` per-piece chroma now inherits the
189+ piece's own luma `tx_type`** (was hardcoded `Some(DctDct)`): an inter
190+ block's chroma never codes its own symbol but inherits the colocated
191+ luma transform's coded type (`av1_get_tx_type`, blockd.h:1291), which
192+ decides `eob_multi_ctx` (decodetxb.c:214: `(tx_class == TX_CLASS_2D)
193+ ? 0 : 1`). A piece whose luma picked V_DCT/H_DCT desynced the chroma
194+ eob read one row. This was the round-4 wall.
195+2. **`decode_inter_sub8_rect2` per-piece 8x4/4x8 chroma ported** (round
196+ 4's suspect (a), confirmed by trace: aom codes a chroma TX_8X4 at
197+ mi (3,8) that ours skipped): at ss 0/0 every piece codes its own U/V
198+ units right after its luma, predicted from the piece's own mv/filters
199+ at the piece's own pixel position, inheriting the piece's first
200+ luma TU's tx_type (`TxbSet::ChromaRect8x4`). The 4:2:0 group unit is
201+ gated `!chroma_444`; `record_uv_mode_mi`/`record_strip_palette` are
202+ hoisted to run at both subsamplings (same pattern as split4's r4
203+ port). Skip pieces push zero-residual MC and zero chroma context.
204+3. **`decode_intra_sub8_leaf` chroma is per-piece at ss 0/0** (round 4
205+ had `chroma_444 || i == 3` on the split caller only, and the leaf
206+ still anchored "the group's one 4x4 unit" at the group origin): the
207+ leaf now anchors at the piece's own position with the piece's own
208+ shape — a 4x4 unit under SPLIT (`Chroma4`, `read_plane`), the leaf's
209+ own TX_8X4/4X8 unit under HORZ/VERT (`ChromaRect8x4` via
210+ `read_coeffs_rect`, tx_type from the uv mode via
211+ `Intra_Mode_To_Tx_Type`, CFL alpha window over the piece's own
212+ footprint). The rect2 caller passes `chroma_444 || i == 1`. uv_mode
213+ neighbour publishing is per-piece at ss 0/0
214+ (`record_uv_mode_mi(lmi, w_mi, h_mi, ..)`).
215+4. **A 64x64 INTER block codes FOUR TX_32X32 chroma units, plane-major,
216+ at ss 0/0** (was one 64x64 read through 32-class tables): each unit
217+ carries the +10 `get_txb_ctx_general` offset (chroma plane block
218+ larger than the transform; our `txb_skip_chroma_32` holds those rows
219+ at +3, so `luma_skip_ctx: Some(3)`, the lane-sb128b r3 convention as
220+ the 128 mu path), predicts from its own 32x32 window of the block's
221+ MC buffer, and records chroma context per unit immediately
222+ (`record_mi_chroma`), with `mu_chroma = true` so the block-level
223+ record does not overwrite the per-unit states.
224+
225+Ladder evidence (`ladder.py` left in `$HOME/.cache/av1444/`; two-pointer
226+walk on `(tag, rng)` tolerating the known instrument asymmetries — aom's
227+chroma `tag=tx_type` prints, `post_golomb` echo rows, ours' `sign_rect`
228+batching and golomb-tail br rows): on the 24-frame cut
229+(`w24.obu`), ours 358473/358473 steps, aom 355132/355132, zero
230+unexplained mismatch — the ENTROPY stream is end-to-end in sync.
231+Round-4's named suspects (b) — intra 16x4/4x16 strips feeding
232+`eob_flag_cdf16[UV][2D]` — did NOT materialize: TX_16X4 chroma is
233+64-coeff (cdf64 class); the cdf16 UV instance is fed only by split4
234+piece chroma, all of which now bind correctly.
235+
236+Pixel state (`w24.our.yuv` vs `w24.ref.yuv`, 24-frame cut): shown
237+frames 0..17 byte-exact; frame 18 differs in exactly TWO U samples,
238+(168,230)=218 vs 217 and (168,231)=204 vs 203 (+1 both), confirmed
239+PRE-loop-filter via `EC_AV1_PREFILT_DUMP` (decode idx 20 == shown 18) —
240+a reconstruction defect, not entropy. Full 60-frame run: frames
241+0..17 exact, first diffs frame 18 (U,2 px), then sparse U diffs frames
242+19..37, Y diffs from frame 49 (drift accumulating behind the frame-18
243+seed). Prediction of the covering block is IDENTICAL to the oracle
244+(aom `EC_PREDOUT8 mi_row=42 mi_col=57 plane=1 sum=3280 row0=205,206,209,200`
245+== ours), so the residual/dequant/inverse or a UV-palette colour write
246+is the remaining suspect: the block is adjacent to `intra_in_inter_
247+palette uv=76` territory and the (224,168) 8x8 leaves no `OUR_TXTYPE`
248+trace, so it is likely a UV-PALETTE block — compare `read_palette_
249+colors_uv` (decode.rs:8979, libaom decodemv.c:509) delta/rounding.
250+
251+Regression arms this round: 444 square filters off IDENTICAL, 444
252+filters on IDENTICAL (aomdec==ffmpeg cross-check), 420+forced-64x64
253+IDENTICAL. 10-bit arms and mono NOT rerun this round. Full suite NOT
254+run (budget wall). Build is 0-warning
255+(`cargo build --release -p ec-av1 --example decode_probe`).