forge
Explore
Log in

Don't you dare go Hollow

ec-av1: 4:4:4 rect/1:4 chroma port (WIP) + byte-exact square witnesses

Browse files at this commit

a236cd35629353c532bfa16589e5ae1c8afbfa62Ahmet Kaan GümüşParent: 6f661bc
Square witnesses all byte-exact vs aomdec+ffmpeg (recipes under
$HOME/.cache/av1444/witness_*.sh): 8-bit profile-1 filters off and on,
forced-64x64-block arms (four-TX_32X32 chroma loop), 10-bit profile-2
filters off and on; 420 square arms unchanged (IDENTICAL).

Root causes fixed this round:
- u/v set_tile_origin hardcoded the 4:2:0 halving; at 4:4:4 the clamp
  hid the above/left edges from every chroma block in the right/bottom
  half of a tile (the 36k-diff chroma defect; entropy ladder was fully
  synced, 1596/1596 rng rungs vs instrumented aomdec).
- deblock_plane_span clipped the chroma loop filter to a quarter of
  the plane at 4:4:4 (CDEF/restoration were already exact).
- decode_block single-TU arm codes a 64x64 block's 4:4:4 chroma as
  four plane-major TX_32X32 units (av1_get_max_uv_txsize).

Rect/1:4 4:4:4 port (in progress):
- decode_block_rect4: shape-keyed chroma tables + the
  av1_get_ext_tx_set_type DCT_ONLY clamp (was ADST-at-32 panic).
- read_inter_rect_chroma helper: 64-axis inter strips code two
  plane-major 32-capped chroma units at 4:4:4; both inter rect readers
  use it; read_inter_plane_rect chroma skip_ctx takes the +3 offset.
- decode_rect4_16_strip: no 4:2:0 chroma pair at 4:4:4 -- every strip
  is its own chroma reference (key and inter paths), tables/CfL/edges
  anchor at the strip.

Still open: av1-profile1-444.ivf decodes 24+ frames then panics
(reconstruct_rect len 64 index 64) on a 64x16 intra strip with split
transform -- decode_rect_split's 64-axis chroma at 4:4:4 is next.
Full suite not run.
crates/ec-av1/src/decode.rsmodified+195 -105
@@ -10081,7 +10081,6 @@ fn decode_rect_split(
10081 let [ug, vg] = last;10081 let [ug, vg] = last;
10082 (ug, vg)10082 (ug, vg)
10083 } else if chroma_tiled {10083 } else if chroma_tiled {
10084- eprintln!("EC_TILE chroma={chroma_w}x{chroma_h}");
10085 let (uw, uh, set, scan): (usize, usize, TxbSet, &[u16]) = match (chroma_w, chroma_h) {10084 let (uw, uh, set, scan): (usize, usize, TxbSet, &[u16]) = match (chroma_w, chroma_h) {
10086 (64, 32) | (32, 64) => (32, 32, TxbSet::Chroma32, default_scan(32)),10085 (64, 32) | (32, 64) => (32, 32, TxbSet::Chroma32, default_scan(32)),
10087 (64, 16) => (32, 16, TxbSet::ChromaRect32x16, &SCAN_32X16),10086 (64, 16) => (32, 16, TxbSet::ChromaRect32x16, &SCAN_32X16),
@@ -12060,11 +12059,21 @@ fn decode_block_rect4(
12060 let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));12059 let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));
12061 let (chroma_w, chroma_h) = (bw >> ss_x(fctx), bh >> ss_y(fctx));12060 let (chroma_w, chroma_h) = (bw >> ss_x(fctx), bh >> ss_y(fctx));
12062 let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx);12061 let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx);
12063- let (luma_scan, chroma_scan): (&[u16], &[u16]) = if bw > bh {12062+ // lane-av1-444: the strip's chroma shape follows the subsampling.
12064- (&SCAN_32X8, &SCAN_16X4)12063+ // 4:2:0 codes 16x4/4x16 (`TxbSet::Chroma8`); 4:4:4 codes the strip
12065- } else {12064+ // itself, 32x8/8x32 (`get_txsize_entropy_ctx(TX_32X8)` =
12066- (&SCAN_8X32, &SCAN_4X16)12065+ // `(wide_log2 + high_log2 + 1) >> 1` = the 16x16 set,
12066+ // `TxbSet::Chroma16`). The caller set is closed -- this reader only
12067+ // ever sees 32x8 / 8x32 luma and the sequence header admits ss 0/0
12068+ // and 1/1 only -- so the table is exhaustive.
12069+ let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (chroma_w, chroma_h) {
12070+ (16, 4) => (TxbSet::Chroma8, &SCAN_16X4[..]),
12071+ (4, 16) => (TxbSet::Chroma8, &SCAN_4X16[..]),
12072+ (32, 8) => (TxbSet::Chroma16, &SCAN_32X8[..]),
12073+ (8, 32) => (TxbSet::Chroma16, &SCAN_8X32[..]),
12074+ _ => unreachable!("decode_block_rect4 chroma shape set is closed"),
12067 };12075 };
12076+ let luma_scan: &[u16] = if bw > bh { &SCAN_32X8 } else { &SCAN_8X32 };
12068 let (luma_levels, u_levels, v_levels) = if skip {12077 let (luma_levels, u_levels, v_levels) = if skip {
12069 (12078 (
12070 vec![0i32; bw * bh],12079 vec![0i32; bw * bh],
@@ -12086,9 +12095,18 @@ fn decode_block_rect4(
12086 )?;12095 )?;
12087 let mut planes = Vec::with_capacity(2);12096 let mut planes = Vec::with_capacity(2);
12088 for plane in 1..3 {12097 for plane in 1..3 {
12089- let default_tx = default_intra_tx_type(uv_predict_mode as u8);12098+ // `av1_get_tx_type` (`blockd.h:1278`): the mode-indexed type
12099+ // stands only while it is a member of this tx size's set; a
12100+ // 32x8/8x32 chroma transform (4:4:4) squares up to TX_32X32,
12101+ // whose intra set is `EXT_TX_SET_DCTONLY` -- every ADST clamps
12102+ // to DCT_DCT there, and ADST is undefined at widths above 16.
12103+ let default_tx = if chroma_w.max(chroma_h) >= 32 {
12104+ TxType::DctDct
12105+ } else {
12106+ default_intra_tx_type(uv_predict_mode as u8)
12107+ };
12090 let skip_ctx = usize::from(around[plane].0) + usize::from(around[plane].1);12108 let skip_ctx = usize::from(around[plane].0) + usize::from(around[plane].1);
12091- let mut coding = cdfs.txb(TxbSet::Chroma8, uv_predict_mode);12109+ let mut coding = cdfs.txb(chroma_set, uv_predict_mode);
12092 let (levels, tx_type) = read_chroma_coeffs_rect(12110 let (levels, tx_type) = read_chroma_coeffs_rect(
12093 dec,12111 dec,
12094 &mut coding,12112 &mut coding,
@@ -12317,7 +12335,10 @@ fn decode_rect4_16(
12317 } else {12335 } else {
12318 (mi_row0, mi_col0 + i)12336 (mi_row0, mi_col0 + i)
12319 };12337 };
12320- let has_chroma = i % 2 == 1;12338+ // lane-av1-444: at 4:4:4 every strip is its own chroma reference
12339+ // (no mi-parity test at ss 0/0, and the strip's own chroma block is
12340+ // already >= 4x4) -- there is no 4:2:0 pair to close.
12341+ let has_chroma = i % 2 == 1 || (ss_x(fctx) == 0 && ss_y(fctx) == 0);
12321 let (mode, uv, _tx) = decode_rect4_16_strip(12342 let (mode, uv, _tx) = decode_rect4_16_strip(
12322 dec,12343 dec,
12323 cdfs,12344 cdfs,
@@ -12382,7 +12403,6 @@ fn decode_rect4_16_strip(
12382 let (bw, bh) = if horz { (16usize, 4usize) } else { (4, 16) };12403 let (bw, bh) = if horz { (16usize, 4usize) } else { (4, 16) };
12383 let (mi_w, mi_h) = (bw / MI, bh / MI);12404 let (mi_w, mi_h) = (bw / MI, bh / MI);
12384 let scan: &[u16] = if horz { &SCAN_16X4 } else { &SCAN_4X16 };12405 let scan: &[u16] = if horz { &SCAN_16X4 } else { &SCAN_4X16 };
12385- let chroma_scan: &[u16] = if horz { &SCAN_8X4 } else { &SCAN_4X8 };
12386 let mut last_uv_mode: Option<usize> = None;12406 let mut last_uv_mode: Option<usize> = None;
12387 // `decode_block_rect4`'s own neighbour rule: the coarse 16-px cell12407 // `decode_block_rect4`'s own neighbour rule: the coarse 16-px cell
12388 // aliases all four strips onto one entry, so the mi-exact map wins and12408 // aliases all four strips onto one entry, so the mi-exact map wins and
@@ -12663,12 +12683,17 @@ fn decode_rect4_16_strip(
12663 }12683 }
12664 if has_chroma {12684 if has_chroma {
12665 hit!(RECT4_16_CHROMA_HITS);12685 hit!(RECT4_16_CHROMA_HITS);
12666- let pair_mi = if horz {12686+ // lane-av1-444: at 4:4:4 there is no pair -- every strip is its
12667- (lmi.0 - 1, lmi.1)12687+ // own chroma reference and codes its own 16x4 / 4x16 chroma
12688+ // block. (`set_mi_offsets`'s chroma snap is the zero offset at
12689+ // ss 0/0, so the neighbour reads below anchor at the strip.)
12690+ let (pair_mi, pw, ph) = if ss_x(fctx) == 0 && ss_y(fctx) == 0 {
12691+ (lmi, bw, bh)
12692+ } else if horz {
12693+ ((lmi.0 - 1, lmi.1), 16, 8)
12668 } else {12694 } else {
12669- (lmi.0, lmi.1 - 1)12695+ ((lmi.0, lmi.1 - 1), 8, 16)
12670 };12696 };
12671- let (pw, ph) = if horz { (16, 8) } else { (8, 16) };
12672 let (ppx, ppy) = (pair_mi.1 * MI, pair_mi.0 * MI);12697 let (ppx, ppy) = (pair_mi.1 * MI, pair_mi.0 * MI);
12673 let (cpx, cpy) = (ppx >> ss_x(fctx), ppy >> ss_y(fctx));12698 let (cpx, cpy) = (ppx >> ss_x(fctx), ppy >> ss_y(fctx));
12674 let (cw, ch) = (pw >> ss_x(fctx), ph >> ss_y(fctx));12699 let (cw, ch) = (pw >> ss_x(fctx), ph >> ss_y(fctx));
@@ -12728,11 +12753,21 @@ fn decode_rect4_16_strip(
12728 (zeros.clone(), zeros)12753 (zeros.clone(), zeros)
12729 } else {12754 } else {
12730 let around = neighbours.around_mi_rect(pair_mi, pw, ph);12755 let around = neighbours.around_mi_rect(pair_mi, pw, ph);
12756+ // lane-av1-444: the strip's own 16x4 / 4x16 chroma at ss 0/0
12757+ // (`TxbSet::Chroma8`, `get_txsize_entropy_ctx(TX_16X4)` =
12758+ // the 8x8 set); 4:2:0 keeps the pair's 8x4 / 4x8.
12759+ let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (cw, ch) {
12760+ (8, 4) => (TxbSet::ChromaRect8x4, &SCAN_8X4[..]),
12761+ (4, 8) => (TxbSet::ChromaRect8x4, &SCAN_4X8[..]),
12762+ (16, 4) => (TxbSet::Chroma8, &SCAN_16X4[..]),
12763+ (4, 16) => (TxbSet::Chroma8, &SCAN_4X16[..]),
12764+ _ => unreachable!("decode_rect4_16_strip chroma shape set is closed"),
12765+ };
12731 let mut planes = Vec::with_capacity(2);12766 let mut planes = Vec::with_capacity(2);
12732 for plane in 1..3 {12767 for plane in 1..3 {
12733 let default_tx = default_intra_tx_type(uv_predict_mode as u8);12768 let default_tx = default_intra_tx_type(uv_predict_mode as u8);
12734 let skip_ctx = usize::from(around[plane].0) + usize::from(around[plane].1);12769 let skip_ctx = usize::from(around[plane].0) + usize::from(around[plane].1);
12735- let mut coding = cdfs.txb(TxbSet::ChromaRect8x4, uv_predict_mode);12770+ let mut coding = cdfs.txb(chroma_set, uv_predict_mode);
12736 let (levels, tx_type) = read_chroma_coeffs_rect(12771 let (levels, tx_type) = read_chroma_coeffs_rect(
12737 dec,12772 dec,
12738 &mut coding,12773 &mut coding,
@@ -19019,6 +19054,10 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> Result<TxbSet> {
19019 // set for TX_16X4/TX_4X16 (`get_txsize_entropy_ctx` = TX_8X8,19054 // set for TX_16X4/TX_4X16 (`get_txsize_entropy_ctx` = TX_8X8,
19020 // `txsize_log2_minus4` = 2, 64-coefficient `eob_pt`).19055 // `txsize_log2_minus4` = 2, 64-coefficient `eob_pt`).
19021 (16, 4) | (4, 16) => TxbSet::Chroma8,19056 (16, 4) | (4, 16) => TxbSet::Chroma8,
19057+ // lane-av1-444: one 32x32 unit of a 4:4:4 64x32/32x64 chroma plane
19058+ // block (`av1_get_max_uv_txsize` adjusts `TX_64X32`/`TX_32X64` to
19059+ // `TX_32X32`); `get_txsize_entropy_ctx(TX_32X32)` is the 32x32 set.
19060+ (32, 32) => TxbSet::Chroma32,
19022 _ => {19061 _ => {
19023 return Err(unsupported(19062 return Err(unsupported(
19024 "a rectangular inter chroma transform unit whose shape has no coefficient table set here",19063 "a rectangular inter chroma transform unit whose shape has no coefficient table set here",
@@ -19027,6 +19066,7 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> Result<TxbSet> {
19027 })19066 })
19028 }19067 }
19029 19068
19069+
19030 /// libaom `size_group_lookup[bsize]` for the block shapes this decoder's19070 /// libaom `size_group_lookup[bsize]` for the block shapes this decoder's
19031 /// inter path reaches, from the block's TRUE footprint rather than the19071 /// inter path reaches, from the block's TRUE footprint rather than the
19032 /// square `side` corner-cut: 8x8/8x16/16x8 -> 1, 16x16/16x32/32x16 -> 2,19072 /// square `side` corner-cut: 8x8/8x16/16x8 -> 1, 16x16/16x32/32x16 -> 2,
@@ -19303,6 +19343,100 @@ fn read_block_tx_size_rect(
19303 Ok(Some(leaves))19343 Ok(Some(leaves))
19304 }19344 }
19305 19345
19346+/// The chroma half of a whole-block rectangular INTER transform unit (both
19347+/// [`decode_inter_block`] rect readers): `av1_get_max_uv_txsize(bsize)` gives
19348+/// the strip's own rect chroma size at 4:2:0 (one unit for the whole block),
19349+/// but at 4:4:4 the chroma plane block keeps the luma block's 64-px axis,
19350+/// which `av1_get_adjusted_tx_size` caps at 32 (`TX_64X16` -> `TX_32X16`),
19351+/// so it codes TWO units plane-major (every U, then every V --
19352+/// `decode_token_recon_block`'s inter branch loops `for plane` outside
19353+/// `for blk_row/blk_col` inside the one mu chunk). No unit codes a `tx_type`
19354+/// symbol: each inherits the block-wide luma one (`av1_get_tx_type`'s inter
19355+/// UV lookup at ss 0 reads the tx_type_map at its own mi, which a single-TU
19356+/// luma block fills uniformly).
19357+#[allow(clippy::too_many_arguments)]
19358+fn read_inter_rect_chroma(
19359+ dec: &mut SymbolDecoder,
19360+ cdfs: &mut Cdfs,
19361+ neighbours: &mut Neighbours,
19362+ around: [(bool, bool, i32); 3],
19363+ u: &mut PlaneBuf<'static>,
19364+ v: &mut PlaneBuf<'static>,
19365+ su: Pred<'_>,
19366+ sv: Pred<'_>,
19367+ at_mi: (usize, usize),
19368+ (cpx, cpy): (usize, usize),
19369+ (write_chroma_w, write_chroma_h): (usize, usize),
19370+ chroma_side: usize,
19371+ mode_for_tx: usize,
19372+ luma_tx_type: TxType,
19373+ fctx: &crate::decode::FrameCtx,
19374+) -> Result<(Grid, Grid)> {
19375+ let (uw, uh) = (write_chroma_w.min(32), write_chroma_h.min(32));
19376+ let (nx, ny) = (write_chroma_w / uw, write_chroma_h / uh);
19377+ let multi = nx * ny > 1;
19378+ let set = rect_inter_chroma_set(uw, uh)?;
19379+ let mut assembled: [Vec<i32>; 2] = [Vec::new(), Vec::new()];
19380+ if multi {
19381+ hit!(CHROMA_SPLIT_TX_HITS);
19382+ assembled = [
19383+ vec![0i32; chroma_side * chroma_side],
19384+ vec![0i32; chroma_side * chroma_side],
19385+ ];
19386+ }
19387+ for plane_idx in 1..=2 {
19388+ let (src, buf) = if plane_idx == 1 { (su, &mut *u) } else { (sv, &mut *v) };
19389+ for cu_row in 0..ny {
19390+ for cu_col in 0..nx {
19391+ let (span_x, span_y) = (uw << ss_x(fctx), uh << ss_y(fctx));
19392+ let cu_mi = (
19393+ at_mi.0 + cu_row * (span_y / MI),
19394+ at_mi.1 + cu_col * (span_x / MI),
19395+ );
19396+ let cu_around = if multi {
19397+ neighbours.around_mi_rect(cu_mi, span_x, span_y)
19398+ } else {
19399+ around
19400+ };
19401+ let (cu_x, cu_y) = (cpx + cu_col * uw, cpy + cu_row * uh);
19402+ let cu_pred = src.offset(cu_row * uh * chroma_side + cu_col * uw);
19403+ let cu_grid = read_inter_plane_rect(
19404+ dec,
19405+ cdfs,
19406+ set,
19407+ (uw, uh),
19408+ chroma_side,
19409+ plane_idx,
19410+ cu_around[plane_idx],
19411+ mode_for_tx,
19412+ buf,
19413+ cu_x,
19414+ cu_y,
19415+ cu_pred,
19416+ Some(luma_tx_type),
19417+ multi.then_some(3), fctx,
19418+ )?
19419+ .0;
19420+ if multi {
19421+ // Immediately, so the next unit of this block reads this
19422+ // one's coefficient context (libaom updates the chroma
19423+ // above/left contexts per unit).
19424+ neighbours.record_mi_chroma(cu_mi, span_x, span_y, plane_idx, &cu_grid);
19425+ let dst = &mut assembled[plane_idx - 1];
19426+ for rr in 0..uh {
19427+ let start = (cu_row * uh + rr) * chroma_side + cu_col * uw;
19428+ dst[start..start + uw].copy_from_slice(&cu_grid[rr * uw..][..uw]);
19429+ }
19430+ } else {
19431+ assembled[plane_idx - 1] = embed_rect_grid(&cu_grid, uw, uh, chroma_side);
19432+ }
19433+ }
19434+ }
19435+ }
19436+ let [ug, vg] = assembled;
19437+ Ok((Grid::Own(ug), Grid::Own(vg)))
19438+}
19439+
19306 /// [`read_inter_plane`] for a rectangular transform unit (lane-inter4 r2):19440 /// [`read_inter_plane`] for a rectangular transform unit (lane-inter4 r2):
19307 /// the coefficients are read with the rect coefficient machinery19441 /// the coefficients are read with the rect coefficient machinery
19308 /// ([`read_coeffs_rect`], whose `TxClass` handling covers the 1D `V_*`/`H_*`19442 /// ([`read_coeffs_rect`], whose `TxClass` handling covers the 1D `V_*`/`H_*`
@@ -19345,7 +19479,12 @@ fn read_inter_plane_rect(
19345 // block; a var-tx leaf passes its own neighbour-table context.19479 // block; a var-tx leaf passes its own neighbour-table context.
19346 luma_skip_ctx.unwrap_or(0)19480 luma_skip_ctx.unwrap_or(0)
19347 } else {19481 } else {
19348- usize::from(around.0) + usize::from(around.1)19482+ // libaom `get_txb_ctx`: a chroma unit's context is
19483+ // `combine_entropy_contexts(above, left)` plus 7, or plus 10 when the
19484+ // plane block is bigger than the transform. Our chroma tables hold the
19485+ // offset-7 rows first, so a multi-unit caller adds 3 through
19486+ // `luma_skip_ctx` (same convention as [`read_plane`]).
19487+ usize::from(around.0) + usize::from(around.1) + luma_skip_ctx.unwrap_or(0)
19349 };19488 };
19350 let mut coding = cdfs.txb(set, tx_mode);19489 let mut coding = cdfs.txb(set, tx_mode);
19351 // libaom `read_tx_type` (`av1/decoder/decodetxb.c`): "No need to read19490 // libaom `read_tx_type` (`av1/decoder/decodetxb.c`): "No need to read
@@ -27678,7 +27817,11 @@ fn decode_inter_block(
27678 let chroma_side = side >> ss_x(fctx);27817 let chroma_side = side >> ss_x(fctx);
27679 let (write_chroma_w, write_chroma_h) = match strip_chroma {27818 let (write_chroma_w, write_chroma_h) = match strip_chroma {
27680 Some(s) if s.has_chroma => {27819 Some(s) if s.has_chroma => {
27681- if s.horz {27820+ // 4:2:0: the PAIR's 8x4 / 4x8. 4:4:4: the strip's own 16x4 /
27821+ // 4x16 (lane-av1-444; no pair at ss 0/0).
27822+ if ss_x(fctx) == 0 && ss_y(fctx) == 0 {
27823+ if s.horz { (16, 4) } else { (4, 16) }
27824+ } else if s.horz {
27682 (8, 4)27825 (8, 4)
27683 } else {27826 } else {
27684 (4, 8)27827 (4, 8)
@@ -29031,55 +29174,24 @@ fn decode_inter_block(
29031 // assembled grid (class `override-slot-on-one-arm`).29174 // assembled grid (class `override-slot-on-one-arm`).
29032 mu_chroma = true;29175 mu_chroma = true;
29033 } else if rect_tu {29176 } else if rect_tu {
29034- // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a29177+ // One chroma read for the whole strip at 4:2:0, two
29035- // 2:1 strip is the strip's own rect chroma size (16x8 /29178+ // 32-capped units at 4:4:4 -- see the helper.
29036- // 8x16), one unit for the whole block, and it codes no29179+ (u_grid, v_grid) = read_inter_rect_chroma(
29037- // `tx_type` symbol -- it inherits the luma unit's.
29038- let (uw, uh) = (write_chroma_w, write_chroma_h);
29039- u_grid = Grid::Own(embed_rect_grid(
29040- &read_inter_plane_rect(
29041 dec,29180 dec,
29042 cdfs,29181 cdfs,
29043- rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,29182+ neighbours,
29044- (uw, uh),29183+ around,
29045- chroma_side,
29046- 1,
29047- around[1],
29048- mode_for_tx,
29049 u,29184 u,
29050- cpx,
29051- cpy,
29052- su,
29053- Some(luma_tx_type),
29054- None, fctx,
29055- )?
29056- .0,
29057- uw,
29058- uh,
29059- chroma_side,
29060- ));
29061- v_grid = Grid::Own(embed_rect_grid(
29062- &read_inter_plane_rect(
29063- dec,
29064- cdfs,
29065- rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,
29066- (uw, uh),
29067- chroma_side,
29068- 2,
29069- around[2],
29070- mode_for_tx,
29071 v,29185 v,
29072- cpx,29186+ su,
29073- cpy,
29074 sv,29187 sv,
29075- Some(luma_tx_type),29188+ at_mi,
29076- None, fctx,29189+ (cpx, cpy),
29077- )?29190+ (write_chroma_w, write_chroma_h),
29078- .0,
29079- uw,
29080- uh,
29081 chroma_side,29191 chroma_side,
29082- ));29192+ mode_for_tx,
29193+ luma_tx_type, fctx,
29194+ )?;
29083 } else {29195 } else {
29084 u_grid = read_inter_plane(29196 u_grid = read_inter_plane(
29085 dec,29197 dec,
@@ -30374,55 +30486,24 @@ fn decode_inter_block(
30374 // assembled grid (class `override-slot-on-one-arm`).30486 // assembled grid (class `override-slot-on-one-arm`).
30375 mu_chroma = true;30487 mu_chroma = true;
30376 } else if rect_tu {30488 } else if rect_tu {
30377- // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a30489+ // One chroma read for the whole strip at 4:2:0, two
30378- // 2:1 strip is the strip's own rect chroma size (16x8 /30490+ // 32-capped units at 4:4:4 -- see the helper.
30379- // 8x16), one unit for the whole block, and it codes no30491+ (u_grid, v_grid) = read_inter_rect_chroma(
30380- // `tx_type` symbol -- it inherits the luma unit's.
30381- let (uw, uh) = (write_chroma_w, write_chroma_h);
30382- u_grid = Grid::Own(embed_rect_grid(
30383- &read_inter_plane_rect(
30384 dec,30492 dec,
30385 cdfs,30493 cdfs,
30386- rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,30494+ neighbours,
30387- (uw, uh),30495+ around_c,
30388- chroma_side,
30389- 1,
30390- around_c[1],
30391- mode_for_tx,
30392 u,30496 u,
30393- cpx,
30394- cpy,
30395- su,
30396- Some(luma_tx_type),
30397- None, fctx,
30398- )?
30399- .0,
30400- uw,
30401- uh,
30402- chroma_side,
30403- ));
30404- v_grid = Grid::Own(embed_rect_grid(
30405- &read_inter_plane_rect(
30406- dec,
30407- cdfs,
30408- rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,
30409- (uw, uh),
30410- chroma_side,
30411- 2,
30412- around_c[2],
30413- mode_for_tx,
30414 v,30497 v,
30415- cpx,30498+ su,
30416- cpy,
30417 sv,30499 sv,
30418- Some(luma_tx_type),30500+ at_mi,
30419- None, fctx,30501+ (cpx, cpy),
30420- )?30502+ (write_chroma_w, write_chroma_h),
30421- .0,
30422- uw,
30423- uh,
30424 chroma_side,30503 chroma_side,
30425- ));30504+ mode_for_tx,
30505+ luma_tx_type, fctx,
30506+ )?;
30426 } else {30507 } else {
30427 u_grid = read_inter_plane(30508 u_grid = read_inter_plane(
30428 dec,30509 dec,
@@ -37172,8 +37253,17 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
37172 {37253 {
37173 break;37254 break;
37174 }37255 }
37175- let strip_has_chroma = i % 2 == 1;37256+ // lane-av1-444: at 4:4:4 every strip is
37176- let pair_mi = if !strip_has_chroma {37257+ // its own chroma reference
37258+ // (`is_chroma_reference`: no mi parity
37259+ // test at ss 0/0 and the strip's 16x4 /
37260+ // 4x16 chroma block is already >= 4x4),
37261+ // so there is no pair: each strip codes
37262+ // and predicts its own chroma from its
37263+ // own motion (`prev` = None).
37264+ let strip_has_chroma =
37265+ i % 2 == 1 || (ss_x(fctx) == 0 && ss_y(fctx) == 0);
37266+ let pair_mi = if !strip_has_chroma || ss_x(fctx) == 0 {
37177 at_mi37267 at_mi
37178 } else if horz {37268 } else if horz {
37179 (at_mi.0 - 1, at_mi.1)37269 (at_mi.0 - 1, at_mi.1)
@@ -37185,7 +37275,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
37185 has_chroma: strip_has_chroma,37275 has_chroma: strip_has_chroma,
37186 horz,37276 horz,
37187 pair_mi,37277 pair_mi,
37188- prev: if strip_has_chroma {37278+ prev: if strip_has_chroma && ss_x(fctx) == 1 {
37189 fctx.inter_last_mc.with(std::cell::Cell::get)37279 fctx.inter_last_mc.with(std::cell::Cell::get)
37190 } else {37280 } else {
37191 None37281 None
lanes/av1444.report.mdmodified+89 -83
@@ -5,95 +5,101 @@ Branch `lane-av1-444`, base `7f8d6cf6`. Worktree
5 `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1444`,5 `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1444`,
6 `TMPDIR=$HOME/.cache/av1444-tmp`. Not pushed.6 `TMPDIR=$HOME/.cache/av1444-tmp`. Not pushed.
7 7
8-Status: **WIP**. 4:4:4 is no longer refused. Luma of a square profile-18+Status: **WIP**. 4:4:4 is byte-exact on every SQUARE witness: 8-bit
9-keyframe is byte-exact vs aomdec and ffmpeg. Chroma is not. 4:2:2 stays a9+profile 1 filters off AND on (loop filter + CDEF + restoration),
10-named refusal. Full suite was not run.10+forced-64x64-block arms (exercises the four-TX_32X32 chroma loop),
11-11+10-bit profile 2 filters off AND on. 420 square arms stay IDENTICAL
12-Commit: blocked by the global pre-commit hook12+(regression). 4:2:2 stays a named refusal. The rect/1:4 paths at 4:4:4
13-(`format-staged.py` runs `rustfmt <file>` with no `--edition`). That rustfmt13+are mid-port: `av1-profile1-444.ivf` gets further every round but still
14-rejects the pre-existing `let` chains in `decode.rs` (`edition = "2024"`).14+panics (see below). Full suite NOT run.
15-`rustfmt --edition 2024 --check` wants a wholesale reformat of `decode.rs`,15+
16-so the hook was not bypassed and the reformat was not applied. Changes are16+## What changed (this continuation, on top of the staged WIP commit)
17-staged, not committed. `git status` in the worktree is the source of truth.17+
18-18+1. `decode_block` single-TU arm (was the prior agent's unstaged edit,
19-## What changed19+ debug prints removed): at 4:4:4 a 64x64 block's chroma is coded as
20-20+ four TX_32X32 units plane-major — confirmed bug-for-bug against
21-- `stream.rs`: the sequence-header refusal now fires only when21+ libaom `av1_get_max_uv_txsize` (`av1_get_adjusted_tx_size`,
22- `subsampling_x != subsampling_y` (4:2:2). 4:4:4 (`0,0`) and 4:2:0 (`1,1`)22+ blockd.h:1361) and the plane-major unit loop in
23- proceed. `set_subsampling` publishes the header values onto `FrameCtx`23+ `decode_token_recon_block` (decodeframe.c:970-1010).
24- once per frame, same slot as `set_mono`.24+2. **Root cause of the 36k chroma diffs** (the prior agent chased a
25-- `decode.rs`: chroma plane size, tx size, CFL window, loop-filter chroma25+ phantom 64x64 block — the stream has none): `u`/`v`
26- step, and the 8x8 leaf's chroma unit follow `ss_x`/`ss_y`. At 4:4:4 an26+ `set_tile_origin` hardcoded the 4:2:0 halving (`mi * 2`). At 4:4:4
27- 8x8 leaf's chroma is 8x8 (`TxbSet::Chroma8`, `scans.0`), not the hardcoded27+ the halved `tile_x1` clamped `PlaneBuf::edges`' `across` below the
28- 4x4. A square block below 64 uses chroma tx = block side. A 64 block still28+ block's own x for every chroma block in the right half of the tile
29- takes the single-TU arm (see the divergence below).29+ (and `tile_y1` the left edge in the bottom half), so those blocks
30-- `restoration.rs`: chroma restoration unit size is no longer hardcoded30+ predicted with edges missing (left-only/above-only DC). Localized by
31- half-res. Not witnessed (the proof stream disables restoration).31+ proving the entropy ladder identical (1596/1596 rng rungs vs the
32-- `refusal_inventory.rs`: the old "any non-4:2:0" string is replaced by the32+ instrumented aomdec), then diffing `OUR_PRED`/`EC_PREDOUT8` for the
33- 4:2:2 string. Gate `a_non_420_subsampled_sequence_header_is_refused_by_name`33+ first divergent CFL block: aom DC 129, ours 145, traced to
34- asserts that 4:2:2 string only. The gate was not re-run in this wrap-up.34+ `above=None` in `edges()`. Tile bounds now `mi * 4 >> ss`; identical
35-35+ at 4:2:0.
36-## Byte-exactness36+3. Loop filter: `deblock_plane_span` clipped chroma to
37-37+ `frame_width/2 × frame_height/2` (another hardcoded halving) — at
38-Oracle: `~/.cache/aom-oracle/build/aomenc` + `aomdec`, cross-checked with38+ 4:4:4 the filter never touched three quarters of each chroma plane.
39-ffmpeg 8.x raw `yuv444p` / `yuv420p`. aomdec `--rawvideo` and ffmpeg39+ Crop now follows `ss`. (CDEF and restoration were already exact:
40-`-pix_fmt yuv444p` were identical on the 444 witness, so the mismatch below40+ isolating arms `--loopfilter-control=0` vs `--enable-cdef=0` /
41-is ours.41+ `--enable-restoration=0`.)
42-42+4. Rect/1:4 4:4:4 port (in progress):
43-Recipe (both profiles): `testsrc2=128x128`, 2 frames, `--cpu-used=843+ - `decode_block_rect4` (32x8/8x32 strips): chroma table was
44---usage=2 --end-usage=q --cq-level=40 --min-partition-size=1644+ hardcoded 4:2:0 (`Chroma8`, SCAN_16X4/4X16, mode-derived tx_type
45---enable-rect-partitions=0 --enable-cdef=0 --enable-restoration=045+ with no size clamp → ADST-at-32 panic). Now shape-keyed
46---loopfilter-control=0 --threads=1 --obu`. Profile 1 adds `--profile=1` and46+ (4:4:4: `Chroma16`, SCAN_32X8/8X32) with the
47-yuv444p input. Probe: `decode_probe` 8-bit dump (low byte of each plane).47+ `av1_get_ext_tx_set_type` DCT_ONLY clamp at square-up ≥ 32
48-48+ (blockd.h:1278).
49-| stream | vs | result |49+ - Inter rect chroma: a 64-axis strip at 4:4:4 keeps its 64-px chroma
50-| --- | --- | --- |50+ axis, capped to 32-wide units (`av1_get_max_uv_txsize`), so it
51-| profile 0, filters off, square | ffmpeg `yuv420p` | IDENTICAL (98304 B, 2 frames) |51+ codes TWO units plane-major. New `read_inter_rect_chroma` helper
52-| profile 1, filters off, square | aomdec and ffmpeg `yuv444p` | luma IDENTICAL both frames (0 diffs / 16384). chroma NOT. 37389 diffs / 98304. First chroma mismatch: frame 0 U (112, 0), ours 192 vs oracle 167 |52+ (both `decode_inter_block` rect readers call it);
53-| profile 1 with rect partitions (earlier `sq8.obu`) | — | panics in `decode_rect4_16_strip` → `reconstruct_rect` (`len 64, index 64`). Not a witness |53+ `read_inter_plane_rect`'s chroma skip_ctx takes the +3 (libaom
54-54+ +10) offset for multi-unit blocks; `rect_inter_chroma_set` gained
55-`av1-profile1-444.ivf` was not re-decoded. It contains the rect/1:4 shapes55+ the (32,32) → `Chroma32` entry.
56-this tree still mishandles, so it will not be byte-exact.56+ - `decode_rect4_16_strip` (16x4/4x16 strips): at 4:4:4 there is no
57-57+ 4:2:0 chroma pair — every strip is its own chroma reference
58-## Exact divergence58+ (`is_chroma_reference`: no mi-parity test at ss 0/0, strip's own
59-59+ chroma ≥ 4x4). `has_chroma` is now true for every strip at ss 0/0
60-First profile-1 block is an 8x8 leaf at mi (0, 0). Before the leaf fix that60+ (key-frame caller `decode_rect4_16` AND the inter
61-leaf read 4x4 chroma, under-consumed symbols, and luma diverged at pixel 8.61+ `inter_strip_chroma` construction), the pair origin/tables/CfL
62-After the fix, luma of both frames matches and U/V match until x=112.62+ window anchor at the strip itself, and the inter `prev`
63-63+ (both-strips MC) is disabled at 4:4:4.
64-x=112 sits inside the 64x64 block at pixel (64, 0) (`EC_BLOCK side=6464+ - Leftover instrumentation from the staged WIP removed (EC_64*,
65-at=(0, 4)`, `chroma_in=32`). That block takes `decode_block`'s65+ EC_TILE); `EC_RECTCHROMA_GAP` stays (deliberate diagnostic per its
66-`logical_tx == side` arm (side 64, one luma TU whose coefficient grid is66+ comment).
67-32). The arm then reads **one** chroma unit with reconstruct side67+
68-`chroma_side` (64 at 4:4:4) and coeff tx `chroma_tx` (32). libaom codes68+## Byte-exactness (all vs aomdec, ffmpeg cross-checked; recipes in
69-**four** TX_32X32 chroma units for a 64x64 uv plane block at 4:4:469+`$HOME/.cache/av1444/witness_*.sh`)
70-(`av1_get_max_uv_txsize` of a 64x64 uv bsize is TX_32X32, 2x2). The70+
71-multi-TU arm already loops `cn = chroma_side / chroma_tx` units, but a71+| stream | result |
72-64 block never enters it because `logical_tx == side`. Comment is on the72+| --- | --- |
73-U `read_plane` in that arm.73+| profile 1, filters off, square 128x128 2f | IDENTICAL (98304 B) |
74-74+| profile 1, filters ON (LF+CDEF+LR), square | IDENTICAL |
75-Quadrant diffs inside that 64x64, U plane, frame 0: (0,0) 764/1024,75+| profile 1, filters off, forced 64x64 blocks (`gradients --min-partition-size=64`, 8 64x64 leaves) | IDENTICAL |
76-(1,0) 896/1024, (0,1) 973/1024, (1,1) 1024/1024. Row 0 of the block matches76+| profile 1, filters on, forced 64x64 blocks | IDENTICAL |
77-for the first 48 samples, then goes flat-wrong. That is a wrong chroma77+| profile 2 10-bit, filters off, square | IDENTICAL (196608 B yuv444p10le) |
78-unit, not a luma desync.78+| profile 2 10-bit, filters on, square | IDENTICAL |
79+| profile 0 420, filters off, square | IDENTICAL (regression) |
80+| profile 0 420, filters on, square | IDENTICAL (regression) |
81+| `av1-profile1-444.ivf` (320x240, rect/1:4 shapes) | decodes 24+ frames, then **panics** `reconstruct_rect len 64 index 64` (decode.rs:3619, `exec_intra` track-caller) after `EC_RECTCHROMA_GAP luma=64x16 tx=16x16` — the 64-axis intra strip's split-transform chroma path is the next defect |
79 82
80 ## Still refused or unproven83 ## Still refused or unproven
81 84
82 | shape | disposition |85 | shape | disposition |
83 | --- | --- |86 | --- | --- |
84 | 4:2:2 (`ss_x != ss_y`) | refused by name. Gate re-scoped, not re-run |87 | 4:2:2 (`ss_x != ss_y`) | refused by name. Gate re-scoped, not re-run |
85-| 4:4:4 64x64 chroma (and any block that takes the single-TU arm with `chroma_side != chroma_tx`) | decodes, not byte-exact. Next edit: when `ss==0` and `chroma_side > chroma_tx`, use the existing `cn` loop instead of one `read_plane` |88+| 64-axis intra strips with split luma transforms at 4:4:4 (`decode_rect_split` chroma (64,16)/(64,32)/(16,64) with tx < block) | panics, not a named refusal. The `chroma_tiled` unit loop exists but the residual reaching `reconstruct_rect` is sized for a 4:2:0 unit somewhere in this path |
86-| 1:4 strips (`decode_rect4_16`) | panic, not a named refusal. Not in the square witness |89+| `av1-profile1-444.ivf` | not byte-exact (panic above). Refusal-gate flip to witness gate NOT done |
87-| sub-8 group chroma (`Chroma4` / size 4 in the 4x4-group tails) | still hardcoded 4:2:0. Square witness did not hit this first |90+| inter square 64x64 at 4:4:4 (var-tx and single-TU) | unwitnessed — the square inter chroma path codes one unit; libaom codes four TX_32X32. No stream has exercised it yet |
88-| loop filter, CDEF, restoration on | threaded with `ss_*`, not witnessed (proof stream disables them) |91+| full `cargo test -p ec-av1` | NOT run. Do not claim green |
89-| 10-bit 4:4:4 | not encoded, not compared |92+| 0-warning parity | not measured this round |
90-| `av1-profile1-444.ivf` | not re-run |
91-| full `cargo test -p ec-av1` | not run. Do not claim green |
92 93
93 ## Next94 ## Next
94 95
95-1. In `decode_block`, when `logical_tx == side` but `chroma_side > chroma_tx`, code chroma as `cn` x `cn` units (the multi-TU loop already does this). Re-run the square profile-1 recipe. Luma must stay identical; chroma must go to 0 diffs.96+1. Fix the `decode_rect_split` 64-axis-strip chroma at 4:4:4 (the
96-2. Then turn filters back on one at a time.97+ len-64 panic): trace which unit feeds `reconstruct_rect` a 64-long
97-3. Then a 10-bit profile-2 444 stream (`yuv444p10le`).98+ residual; the `chroma_tiled` arm's (32,16)/(16,32) rect units go
98-4. Then the existing `av1-profile1-444.ivf`, after the 1:4 path no longer panics.99+ through `read_coeffs_rect` + `dequant_and_inverse_typed_wh` — check
99-5. Full suite, `--test-threads=1`, `TMPDIR` on `$HOME`.100+ the scratch/grid sizing against libaom's two-unit plane-major order.
101+2. Then the inter square-64 four-unit chroma (mirror the intra fix).
102+3. Then the fixture end-to-end vs ffmpeg; flip the refusal gate
103+ (`a_non_420_subsampled_sequence_header_is_refused_by_name` re-scope)
104+ to a fixture witness gate.
105+4. Full suite `--test-threads=1`, 0-warning parity, update this report.