forge
Explore
Log in

Don't you dare go Hollow

lane-av1-444-128: port the inter 128x128 mu-chunk chroma walk to per-unit TX_32X32 at ss 0/0 (av1_get_max_uv_txsize + decode_token_recon_block bug-for-bug); per-unit stamps and covering-leaf tx_type inheritance; 444 witness byte-exact on the merged 444 tree (6cd1ded4), 420 arm identical (e1072eb0); report + census gate

Browse files at this commit

d003fbbe3898d4b4da9d0f89335752c21a42f5ceAhmet Kaan GümüşParent: e32630c
crates/ec-av1/src/decode.rsmodified+322 -102
@@ -29843,11 +29843,18 @@ fn decode_inter_block(
29843 neighbours.around_mi(at, side)29843 neighbours.around_mi(at, side)
29844 };29844 };
29845 let luma_tx_type;29845 let luma_tx_type;
29846- // lane-sb128c r1: a 128x128 inter block's four chroma units29846+ // lane-sb128c r1: a 128x128 inter block's chroma is read
29847- // are read INSIDE the luma leaf loop (one per 64x64 mu chunk);29847+ // INSIDE the luma leaf loop (each 64x64 mu chunk's own units:
29848- // these collect them for the block-level neighbour write-back.29848+ // one per chunk at 4:2:0, FOUR TX_32X32 at ss 0/0); these
29849+ // collect them for the block-level neighbour write-back.
29849 let mut u_units: Vec<i32> = Vec::new();29850 let mut u_units: Vec<i32> = Vec::new();
29850 let mut v_units: Vec<i32> = Vec::new();29851 let mut v_units: Vec<i32> = Vec::new();
29852+ // lane-av1-444-128: every luma leaf's coded tx_type, so the
29853+ // chunk tail's chroma units can each inherit the type of the
29854+ // leaf covering their own quadrant (`av1_get_tx_type`,
29855+ // blockd.h:1291, scales the CHROMA 4x4 position back to luma).
29856+ let mut leaf_tx_types: Vec<(usize, usize, usize, usize, TxType)> =
29857+ Vec::new();
29851 if let Some(leaves) = vartx_leaves.as_ref() {29858 if let Some(leaves) = vartx_leaves.as_ref() {
29852 // spec 5.11.17's transform tree, leaf by leaf in the order29859 // spec 5.11.17's transform tree, leaf by leaf in the order
29853 // `read_var_tx_size` coded it: each unit reads its own29860 // `read_var_tx_size` coded it: each unit reads its own
@@ -29913,6 +29920,12 @@ fn decode_inter_block(
29913 if idx == 0 {29920 if idx == 0 {
29914 first_tx_type = tu_tx_type;29921 first_tx_type = tu_tx_type;
29915 }29922 }
29923+ // lane-av1-444-128: the per-unit chroma inheritance in
29924+ // the chunk tail resolves each unit's own tx_type from
29925+ // the luma leaf covering its quadrant.
29926+ if side > 64 {
29927+ leaf_tx_types.push((row, col, tw, th, tu_tx_type));
29928+ }
29916 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);29929 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
29917 // lane-sb128c r1: libaom's `decode_token_recon_block`29930 // lane-sb128c r1: libaom's `decode_token_recon_block`
29918 // walks 64x64 "mu" chunks (`mu_blocks_wide/high =29931 // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
@@ -29930,21 +29943,37 @@ fn decode_inter_block(
29930 let (cr, cc) = chunk;29943 let (cr, cc) = chunk;
29931 // `av1_get_max_uv_txsize(BLOCK_128X128)` =29944 // `av1_get_max_uv_txsize(BLOCK_128X128)` =
29932 // `av1_get_adjusted_tx_size(TX_64X64)` =29945 // `av1_get_adjusted_tx_size(TX_64X64)` =
29933- // TX_32X32: one 32x32 chroma unit per chunk.29946+ // TX_32X32. The mu walk
29947+ // (`decode_token_recon_block`, decodeframe.c)
29948+ // then enumerates, per plane, EVERY TX_32X32
29949+ // unit of the chunk's chroma in raster order:
29950+ // at ss 0/0 the chunk's chroma is 64x64 and
29951+ // that is FOUR units; at 4:2:0 it is 32x32
29952+ // and the loop degenerates to the one unit
29953+ // this arm has always coded. `chroma_side`
29954+ // already carries the subsampling.
29934 let cu_tx = 32usize;29955 let cu_tx = 32usize;
29935- let luma_span = cu_tx * 2;29956+ let chunk_chroma = chroma_side * 64 / side;
29936- let cu_mi = (at_mi.0 + cr * 16, at_mi.1 + cc * 16);29957+ let units = chunk_chroma / cu_tx;
29937- let cu_around = neighbours.around_mi(cu_mi, luma_span);29958+ // The unit's own footprint on the LUMA mi
29938- let (cu_x, cu_y) = (cpx + cc * cu_tx, cpy + cr * cu_tx);29959+ // grid: 64 px (16 mi) at 4:2:0, 32 px (8 mi)
29960+ // at ss 0/0. `around_mi` reads and
29961+ // `record_mi_chroma` stamps span exactly the
29962+ // unit's own cells -- `get_txb_ctx` reads the
29963+ // 8 context cells of the TX_32X32 itself, and
29964+ // `av1_set_entropy_contexts` memsets the same
29965+ // 8, so the unit over never sees this unit's
29966+ // state and the unit below always does.
29967+ let unit_luma = cu_tx * (side / chroma_side);
29939 let cu_scan = default_scan(cu_tx);29968 let cu_scan = default_scan(cu_tx);
29940 if lossless(fctx) {29969 if lossless(fctx) {
29941- // lane-lossless2: this chunk's chroma is29970+ // lane-lossless2: TX_4X4 units over this
29942- // 8x8 TX_4X4 units per plane, not one29971+ // chunk's chroma, not one TX_32X32 unit.
29943- // TX_32X32 unit.
29944 read_inter_chroma_lossless(29972 read_inter_chroma_lossless(
29945 dec, cdfs, neighbours, u, v, su, sv,29973 dec, cdfs, neighbours, u, v, su, sv,
29946 at_mi, (cpx, cpy),29974 at_mi, (cpx, cpy),
29947- (cc * cu_tx, cr * cu_tx), (cu_tx, cu_tx),29975+ (cc * chunk_chroma, cr * chunk_chroma),
29976+ (chunk_chroma, chunk_chroma),
29948 (write_chroma_w, write_chroma_h),29977 (write_chroma_w, write_chroma_h),
29949 chroma_side, mode_for_tx, base_q_idx,29978 chroma_side, mode_for_tx, base_q_idx,
29950 &mut u_units, &mut v_units, fctx,29979 &mut u_units, &mut v_units, fctx,
@@ -29958,50 +29987,131 @@ fn decode_inter_block(
29958 } else {29987 } else {
29959 (sv, &mut *v)29988 (sv, &mut *v)
29960 };29989 };
29961- let cu_pred =29990+ // Plane-major per chunk (libaom's plane
29962- src.offset(cr * cu_tx * chroma_side + cc * cu_tx);29991+ // loop is outermost inside the mu walk);
29963- let cu_grid = read_inter_plane(29992+ // within a plane the units walk raster.
29964- dec,29993+ for ur in 0..units {
29965- cdfs,29994+ for uc in 0..units {
29966- chroma_set,29995+ let unit_mi = (
29967- &cu_scan,29996+ at_mi.0 + cr * 16
29968- plane_idx,29997+ + ur * (unit_luma / MI),
29969- cu_around[plane_idx],29998+ at_mi.1 + cc * 16
29970- mode_for_tx,29999+ + uc * (unit_luma / MI),
29971- buf,30000+ );
29972- cu_x,30001+ // Per unit, AFTER the earlier
29973- cu_y,30002+ // units' stamps: this unit's
29974- cu_tx,30003+ // coefficient context must see
29975- base_q_idx,30004+ // them.
29976- cu_pred,30005+ let cu_around = neighbours
29977- Some(first_tx_type),30006+ .around_mi(unit_mi, unit_luma);
29978- Some(3), fctx,30007+ let (cu_x, cu_y) = (
29979- )?30008+ cpx + cc * chunk_chroma
29980- .0;30009+ + uc * cu_tx,
29981- // Immediately, so the NEXT chunk's unit30010+ cpy + cr * chunk_chroma
29982- // reads this one's coefficient context.30011+ + ur * cu_tx,
29983- neighbours.record_mi_chroma(30012+ );
29984- cu_mi, luma_span, luma_span, plane_idx, &cu_grid,30013+ // `av1_get_tx_type` (blockd.h:
29985- );30014+ // 1291): an inter block's chroma
29986- hit!(CHROMA_SPLIT_TX_HITS);30015+ // unit never codes a tx_type; it
29987- mu_chroma = true;30016+ // inherits the coded type of the
29988- let dst = mu_units(30017+ // luma leaf covering its own
29989- if plane_idx == 1 { &mut u_units } else { &mut v_units },30018+ // quadrant (all of this chunk's
29990- chroma_side * chroma_side,30019+ // leaves are read by now).
29991- );30020+ let unit_rel_mi = (
29992- for rr in 0..cu_tx {30021+ unit_mi.0 - at_mi.0,
29993- let start =30022+ unit_mi.1 - at_mi.1,
29994- (cr * cu_tx + rr) * chroma_side + cc * cu_tx;30023+ );
29995- dst[start..start + cu_tx]30024+ let covering = leaf_tx_types
29996- .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]);30025+ .iter()
30026+ .copied()
30027+ // leaf (row, col) are mi but
30028+ // (tw, th) are px (the rect
30029+ // leaf path divides by MI too)
30030+ .find(
30031+ |&(lr, lc, lw, lh, _)| {
30032+ lr <= unit_rel_mi.0
30033+ && unit_rel_mi.0
30034+ < lr + lh / MI
30035+ && lc <= unit_rel_mi.1
30036+ && unit_rel_mi.1
30037+ < lc + lw / MI
30038+ },
30039+ )
30040+ .map(|(_, _, _, _, t)| t);
30041+ let cu_pred = src.offset(
30042+ (cr * chunk_chroma
30043+ + ur * cu_tx)
30044+ * chroma_side
30045+ + cc * chunk_chroma
30046+ + uc * cu_tx,
30047+ );
30048+ let cu_grid = read_inter_plane(
30049+ dec,
30050+ cdfs,
30051+ chroma_set,
30052+ &cu_scan,
30053+ plane_idx,
30054+ cu_around[plane_idx],
30055+ mode_for_tx,
30056+ buf,
30057+ cu_x,
30058+ cu_y,
30059+ cu_tx,
30060+ base_q_idx,
30061+ cu_pred,
30062+ Some(
30063+ covering.unwrap_or(
30064+ TxType::DctDct
30065+ ),
30066+ ),
30067+ Some(3), fctx,
30068+ )?
30069+ .0;
30070+ // Immediately, so the NEXT unit
30071+ // reads this one's coefficient
30072+ // context.
30073+ neighbours.record_mi_chroma(
30074+ unit_mi,
30075+ unit_luma,
30076+ unit_luma,
30077+ plane_idx,
30078+ &cu_grid,
30079+ );
30080+ hit!(CHROMA_SPLIT_TX_HITS);
30081+ mu_chroma = true;
30082+ let dst = mu_units(
30083+ if plane_idx == 1 {
30084+ &mut u_units
30085+ } else {
30086+ &mut v_units
30087+ },
30088+ chroma_side * chroma_side,
30089+ );
30090+ for rr in 0..cu_tx {
30091+ let start = (cr * chunk_chroma
30092+ + ur * cu_tx
30093+ + rr)
30094+ * chroma_side
30095+ + cc * chunk_chroma
30096+ + uc * cu_tx;
30097+ dst[start..start + cu_tx]
30098+ .copy_from_slice(
30099+ &cu_grid
30100+ [rr * cu_tx..]
30101+ [..cu_tx],
30102+ );
30103+ }
30104+ }
29997 }30105 }
29998 }30106 }
29999 }30107 }
30000 }30108 }
30001 }30109 }
30002- // `av1_get_tx_type`'s chroma lookup scales the chroma30110+ // The block-level `luma_tx_type` stays the first
30003- // position back to luma, so an inter block's chroma30111+ // (top-left) luma unit's coded type; the PER-UNIT chroma
30004- // inherits the *first* (top-left) luma unit's coded type.30112+ // inheritance in the chunk tail above resolves each unit's
30113+ // own covering leaf instead (`av1_get_tx_type`,
30114+ // blockd.h:1291).
30005 luma_tx_type = first_tx_type;30115 luma_tx_type = first_tx_type;
30006 luma_grid = Grid::Zero(side * side);30116 luma_grid = Grid::Zero(side * side);
30007 } else if rect_tu {30117 } else if rect_tu {
@@ -31177,11 +31287,18 @@ fn decode_inter_block(
31177 _ => around,31287 _ => around,
31178 };31288 };
31179 let luma_tx_type;31289 let luma_tx_type;
31180- // lane-sb128c r1: a 128x128 inter block's four chroma units31290+ // lane-sb128c r1: a 128x128 inter block's chroma is read
31181- // are read INSIDE the luma leaf loop (one per 64x64 mu chunk);31291+ // INSIDE the luma leaf loop (each 64x64 mu chunk's own units:
31182- // these collect them for the block-level neighbour write-back.31292+ // one per chunk at 4:2:0, FOUR TX_32X32 at ss 0/0); these
31293+ // collect them for the block-level neighbour write-back.
31183 let mut u_units: Vec<i32> = Vec::new();31294 let mut u_units: Vec<i32> = Vec::new();
31184 let mut v_units: Vec<i32> = Vec::new();31295 let mut v_units: Vec<i32> = Vec::new();
31296+ // lane-av1-444-128: every luma leaf's coded tx_type, so the
31297+ // chunk tail's chroma units can each inherit the type of the
31298+ // leaf covering their own quadrant (`av1_get_tx_type`,
31299+ // blockd.h:1291, scales the CHROMA 4x4 position back to luma).
31300+ let mut leaf_tx_types: Vec<(usize, usize, usize, usize, TxType)> =
31301+ Vec::new();
31185 if let Some(leaves) = vartx_leaves.as_ref() {31302 if let Some(leaves) = vartx_leaves.as_ref() {
31186 // spec 5.11.17's transform tree, leaf by leaf in the order31303 // spec 5.11.17's transform tree, leaf by leaf in the order
31187 // `read_var_tx_size` coded it: each unit reads its own31304 // `read_var_tx_size` coded it: each unit reads its own
@@ -31247,6 +31364,12 @@ fn decode_inter_block(
31247 if idx == 0 {31364 if idx == 0 {
31248 first_tx_type = tu_tx_type;31365 first_tx_type = tu_tx_type;
31249 }31366 }
31367+ // lane-av1-444-128: the per-unit chroma inheritance in
31368+ // the chunk tail resolves each unit's own tx_type from
31369+ // the luma leaf covering its quadrant.
31370+ if side > 64 {
31371+ leaf_tx_types.push((row, col, tw, th, tu_tx_type));
31372+ }
31250 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);31373 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
31251 // lane-sb128c r1: libaom's `decode_token_recon_block`31374 // lane-sb128c r1: libaom's `decode_token_recon_block`
31252 // walks 64x64 "mu" chunks (`mu_blocks_wide/high =31375 // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
@@ -31264,21 +31387,37 @@ fn decode_inter_block(
31264 let (cr, cc) = chunk;31387 let (cr, cc) = chunk;
31265 // `av1_get_max_uv_txsize(BLOCK_128X128)` =31388 // `av1_get_max_uv_txsize(BLOCK_128X128)` =
31266 // `av1_get_adjusted_tx_size(TX_64X64)` =31389 // `av1_get_adjusted_tx_size(TX_64X64)` =
31267- // TX_32X32: one 32x32 chroma unit per chunk.31390+ // TX_32X32. The mu walk
31391+ // (`decode_token_recon_block`, decodeframe.c)
31392+ // then enumerates, per plane, EVERY TX_32X32
31393+ // unit of the chunk's chroma in raster order:
31394+ // at ss 0/0 the chunk's chroma is 64x64 and
31395+ // that is FOUR units; at 4:2:0 it is 32x32
31396+ // and the loop degenerates to the one unit
31397+ // this arm has always coded. `chroma_side`
31398+ // already carries the subsampling.
31268 let cu_tx = 32usize;31399 let cu_tx = 32usize;
31269- let luma_span = cu_tx * 2;31400+ let chunk_chroma = chroma_side * 64 / side;
31270- let cu_mi = (at_mi.0 + cr * 16, at_mi.1 + cc * 16);31401+ let units = chunk_chroma / cu_tx;
31271- let cu_around = neighbours.around_mi(cu_mi, luma_span);31402+ // The unit's own footprint on the LUMA mi
31272- let (cu_x, cu_y) = (cpx + cc * cu_tx, cpy + cr * cu_tx);31403+ // grid: 64 px (16 mi) at 4:2:0, 32 px (8 mi)
31404+ // at ss 0/0. `around_mi` reads and
31405+ // `record_mi_chroma` stamps span exactly the
31406+ // unit's own cells -- `get_txb_ctx` reads the
31407+ // 8 context cells of the TX_32X32 itself, and
31408+ // `av1_set_entropy_contexts` memsets the same
31409+ // 8, so the unit over never sees this unit's
31410+ // state and the unit below always does.
31411+ let unit_luma = cu_tx * (side / chroma_side);
31273 let cu_scan = default_scan(cu_tx);31412 let cu_scan = default_scan(cu_tx);
31274 if lossless(fctx) {31413 if lossless(fctx) {
31275- // lane-lossless2: this chunk's chroma is31414+ // lane-lossless2: TX_4X4 units over this
31276- // 8x8 TX_4X4 units per plane, not one31415+ // chunk's chroma, not one TX_32X32 unit.
31277- // TX_32X32 unit.
31278 read_inter_chroma_lossless(31416 read_inter_chroma_lossless(
31279 dec, cdfs, neighbours, u, v, su, sv,31417 dec, cdfs, neighbours, u, v, su, sv,
31280 at_mi, (cpx, cpy),31418 at_mi, (cpx, cpy),
31281- (cc * cu_tx, cr * cu_tx), (cu_tx, cu_tx),31419+ (cc * chunk_chroma, cr * chunk_chroma),
31420+ (chunk_chroma, chunk_chroma),
31282 (write_chroma_w, write_chroma_h),31421 (write_chroma_w, write_chroma_h),
31283 chroma_side, mode_for_tx, base_q_idx,31422 chroma_side, mode_for_tx, base_q_idx,
31284 &mut u_units, &mut v_units, fctx,31423 &mut u_units, &mut v_units, fctx,
@@ -31292,50 +31431,131 @@ fn decode_inter_block(
31292 } else {31431 } else {
31293 (sv, &mut *v)31432 (sv, &mut *v)
31294 };31433 };
31295- let cu_pred =31434+ // Plane-major per chunk (libaom's plane
31296- src.offset(cr * cu_tx * chroma_side + cc * cu_tx);31435+ // loop is outermost inside the mu walk);
31297- let cu_grid = read_inter_plane(31436+ // within a plane the units walk raster.
31298- dec,31437+ for ur in 0..units {
31299- cdfs,31438+ for uc in 0..units {
31300- chroma_set,31439+ let unit_mi = (
31301- &cu_scan,31440+ at_mi.0 + cr * 16
31302- plane_idx,31441+ + ur * (unit_luma / MI),
31303- cu_around[plane_idx],31442+ at_mi.1 + cc * 16
31304- mode_for_tx,31443+ + uc * (unit_luma / MI),
31305- buf,31444+ );
31306- cu_x,31445+ // Per unit, AFTER the earlier
31307- cu_y,31446+ // units' stamps: this unit's
31308- cu_tx,31447+ // coefficient context must see
31309- base_q_idx,31448+ // them.
31310- cu_pred,31449+ let cu_around = neighbours
31311- Some(first_tx_type),31450+ .around_mi(unit_mi, unit_luma);
31312- Some(3), fctx,31451+ let (cu_x, cu_y) = (
31313- )?31452+ cpx + cc * chunk_chroma
31314- .0;31453+ + uc * cu_tx,
31315- // Immediately, so the NEXT chunk's unit31454+ cpy + cr * chunk_chroma
31316- // reads this one's coefficient context.31455+ + ur * cu_tx,
31317- neighbours.record_mi_chroma(31456+ );
31318- cu_mi, luma_span, luma_span, plane_idx, &cu_grid,31457+ // `av1_get_tx_type` (blockd.h:
31319- );31458+ // 1291): an inter block's chroma
31320- hit!(CHROMA_SPLIT_TX_HITS);31459+ // unit never codes a tx_type; it
31321- mu_chroma = true;31460+ // inherits the coded type of the
31322- let dst = mu_units(31461+ // luma leaf covering its own
31323- if plane_idx == 1 { &mut u_units } else { &mut v_units },31462+ // quadrant (all of this chunk's
31324- chroma_side * chroma_side,31463+ // leaves are read by now).
31325- );31464+ let unit_rel_mi = (
31326- for rr in 0..cu_tx {31465+ unit_mi.0 - at_mi.0,
31327- let start =31466+ unit_mi.1 - at_mi.1,
31328- (cr * cu_tx + rr) * chroma_side + cc * cu_tx;31467+ );
31329- dst[start..start + cu_tx]31468+ let covering = leaf_tx_types
31330- .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]);31469+ .iter()
31470+ .copied()
31471+ // leaf (row, col) are mi but
31472+ // (tw, th) are px (the rect
31473+ // leaf path divides by MI too)
31474+ .find(
31475+ |&(lr, lc, lw, lh, _)| {
31476+ lr <= unit_rel_mi.0
31477+ && unit_rel_mi.0
31478+ < lr + lh / MI
31479+ && lc <= unit_rel_mi.1
31480+ && unit_rel_mi.1
31481+ < lc + lw / MI
31482+ },
31483+ )
31484+ .map(|(_, _, _, _, t)| t);
31485+ let cu_pred = src.offset(
31486+ (cr * chunk_chroma
31487+ + ur * cu_tx)
31488+ * chroma_side
31489+ + cc * chunk_chroma
31490+ + uc * cu_tx,
31491+ );
31492+ let cu_grid = read_inter_plane(
31493+ dec,
31494+ cdfs,
31495+ chroma_set,
31496+ &cu_scan,
31497+ plane_idx,
31498+ cu_around[plane_idx],
31499+ mode_for_tx,
31500+ buf,
31501+ cu_x,
31502+ cu_y,
31503+ cu_tx,
31504+ base_q_idx,
31505+ cu_pred,
31506+ Some(
31507+ covering.unwrap_or(
31508+ TxType::DctDct
31509+ ),
31510+ ),
31511+ Some(3), fctx,
31512+ )?
31513+ .0;
31514+ // Immediately, so the NEXT unit
31515+ // reads this one's coefficient
31516+ // context.
31517+ neighbours.record_mi_chroma(
31518+ unit_mi,
31519+ unit_luma,
31520+ unit_luma,
31521+ plane_idx,
31522+ &cu_grid,
31523+ );
31524+ hit!(CHROMA_SPLIT_TX_HITS);
31525+ mu_chroma = true;
31526+ let dst = mu_units(
31527+ if plane_idx == 1 {
31528+ &mut u_units
31529+ } else {
31530+ &mut v_units
31531+ },
31532+ chroma_side * chroma_side,
31533+ );
31534+ for rr in 0..cu_tx {
31535+ let start = (cr * chunk_chroma
31536+ + ur * cu_tx
31537+ + rr)
31538+ * chroma_side
31539+ + cc * chunk_chroma
31540+ + uc * cu_tx;
31541+ dst[start..start + cu_tx]
31542+ .copy_from_slice(
31543+ &cu_grid
31544+ [rr * cu_tx..]
31545+ [..cu_tx],
31546+ );
31547+ }
31548+ }
31331 }31549 }
31332 }31550 }
31333 }31551 }
31334 }31552 }
31335 }31553 }
31336- // `av1_get_tx_type`'s chroma lookup scales the chroma31554+ // The block-level `luma_tx_type` stays the first
31337- // position back to luma, so an inter block's chroma31555+ // (top-left) luma unit's coded type; the PER-UNIT chroma
31338- // inherits the *first* (top-left) luma unit's coded type.31556+ // inheritance in the chunk tail above resolves each unit's
31557+ // own covering leaf instead (`av1_get_tx_type`,
31558+ // blockd.h:1291).
31339 luma_tx_type = first_tx_type;31559 luma_tx_type = first_tx_type;
31340 luma_grid = Grid::Zero(side * side);31560 luma_grid = Grid::Zero(side * side);
31341 } else if rect_tu {31561 } else if rect_tu {
crates/ec-av1/src/stream.rsmodified+135 -0
@@ -28055,6 +28055,141 @@ pub(crate) mod tests {
28055 );28055 );
28056 }28056 }
28057 28057
28058+ /// lane-av1-444-128: a real `aomenc` stream whose inter frames are ONE
28059+ /// 128x128 PARTITION_NONE block each, non-skip, must walk that block's
28060+ /// chroma through the mu-chunk loop -- one TX_32X32 unit per 64x64 mu
28061+ /// chunk per plane at 4:2:0 (`decode_token_recon_block`'s mu walk with
28062+ /// `av1_get_max_uv_txsize(BLOCK_128X128)` = `TX_32X32`), each unit read
28063+ /// at its own origin against its own entropy-cell span and stamped
28064+ /// immediately (`av1_set_entropy_contexts`). The census asserts the walk
28065+ /// actually ran (two units per plane per coded 128-none block); the key
28066+ /// frame splits to 64x64 (detailed testsrc2 content), so the whole
28067+ /// stream stays inside the 4:2:0 paths this tree decodes. The 4:4:4 twin
28068+ /// of this shape (FOUR TX_32X32 units per chunk per plane) is witnessed
28069+ /// in `lanes/av1444128.report.md` against the merged 444 tree -- this
28070+ /// tree still refuses non-4:2:0 sequences by name.
28071+ #[test]
28072+ fn a_real_aomenc_128x128_none_inter_blocks_coded_chroma_per_mu_chunk_decodes_pixel_exact() {
28073+ const NAME: &str =
28074+ "a_real_aomenc_128x128_none_inter_blocks_coded_chroma_per_mu_chunk_decodes_pixel_exact";
28075+ let _gate_lock = lock_gate_counters();
28076+ if !have_ffmpeg() || !have_aomenc() {
28077+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc/aomdec");
28078+ return;
28079+ }
28080+ let y4m = Command::new("ffmpeg")
28081+ .args([
28082+ "-v",
28083+ "error",
28084+ "-f",
28085+ "lavfi",
28086+ "-i",
28087+ "testsrc2=size=128x128:rate=30",
28088+ "-frames:v",
28089+ "12",
28090+ "-pix_fmt",
28091+ "yuv420p",
28092+ "-strict",
28093+ "-1",
28094+ "-f",
28095+ "yuv4mpegpipe",
28096+ "-",
28097+ ])
28098+ .stdin(Stdio::null())
28099+ .stdout(Stdio::piped())
28100+ .stderr(Stdio::piped())
28101+ .output()
28102+ .expect("ffmpeg failed to run");
28103+ assert!(
28104+ y4m.status.success(),
28105+ "{NAME}: ffmpeg fixture: {}",
28106+ String::from_utf8_lossy(&y4m.stderr)
28107+ );
28108+ let args: Vec<&str> = vec![
28109+ "--codec=av1",
28110+ "--passes=1",
28111+ "--end-usage=q",
28112+ "--cq-level=8",
28113+ "--cpu-used=2",
28114+ "--threads=1",
28115+ "--row-mt=0",
28116+ "--lag-in-frames=0",
28117+ "--kf-max-dist=100",
28118+ "--enable-fwd-kf=0",
28119+ "--sb-size=128",
28120+ "--max-partition-size=128",
28121+ "--min-partition-size=64",
28122+ "--enable-palette=0",
28123+ "--enable-intrabc=0",
28124+ "--enable-cdef=0",
28125+ "--enable-restoration=0",
28126+ "--loopfilter-control=0",
28127+ "--enable-obmc=0",
28128+ "--enable-warped-motion=0",
28129+ "--enable-interintra-comp=0",
28130+ "--enable-interintra-wedge=0",
28131+ "--enable-smooth-interintra=0",
28132+ "--enable-ref-frame-mvs=0",
28133+ "--deltaq-mode=0",
28134+ "--tile-columns=0",
28135+ "--limit=12",
28136+ "--obu",
28137+ "-o",
28138+ "-",
28139+ "-",
28140+ ];
28141+ let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout);
28142+ assert!(
28143+ out.status.success(),
28144+ "{NAME}: aomenc refused the fixture: {}",
28145+ String::from_utf8_lossy(&out.stderr)
28146+ );
28147+ let stream = out.stdout;
28148+ let header = {
28149+ let mut parser = ec_av1_syntax::Av1Parser::new();
28150+ let mut pos = 0usize;
28151+ while let Ok(obu) = parser.parse_obu(&stream[pos..]) {
28152+ pos += obu.total_size;
28153+ if pos >= stream.len() {
28154+ break;
28155+ }
28156+ }
28157+ parser
28158+ .sequence_header()
28159+ .map(|q| (q.use_128x128_superblock, q.color_config.bit_depth))
28160+ };
28161+ assert_eq!(
28162+ header,
28163+ Some((true, 8)),
28164+ "{NAME}: the encoder did not write a 128x128-superblock 8-bit sequence header -- \
28165+ the flags never arrived"
28166+ );
28167+ let before = (crate::decode::inter_sb128_none_hits(), crate::decode::chroma_split_tx_hits());
28168+ let (frames, hidden) = decode_all_frames_vs_oracle(&stream, "av1444128-128none-mu-chroma");
28169+ let (none128, chroma_units) = (
28170+ crate::decode::inter_sb128_none_hits() - before.0,
28171+ crate::decode::chroma_split_tx_hits() - before.1,
28172+ );
28173+ assert!(
28174+ frames >= 11,
28175+ "{NAME}: only {frames} decode-order frames"
28176+ );
28177+ assert!(
28178+ none128 >= 8,
28179+ "{NAME}: only {none128} inter 128x128 PARTITION_NONE roots -- the recipe stopped \
28180+ exercising the shape this gate names"
28181+ );
28182+ assert!(
28183+ chroma_units >= 8 * 8,
28184+ "{NAME}: only {chroma_units} mu-chunk chroma units read -- the per-unit walk this \
28185+ gate names never fired (two units per plane per coded 128-none inter block)"
28186+ );
28187+ eprintln!(
28188+ "{NAME}: {frames} decode-order frames pixel-exact ({hidden} hidden), \
28189+ inter_sb128_none_hits={none128} chroma_units={chroma_units}"
28190+ );
28191+ }
28192+
28058 /// lane-sbpart r2: a real `aomenc` stream whose superblock-level28193 /// lane-sbpart r2: a real `aomenc` stream whose superblock-level
28059 /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must28194 /// partition decision is genuinely HORZ/VERT (not NONE/SPLIT) must
28060 /// decode pixel-exact through [`crate::decode::decode_block_rect64`] --28195 /// decode pixel-exact through [`crate::decode::decode_block_rect64`] --
lanes/av1444128.report.mdadded+147 -0
@@ -0,0 +1,147 @@
1+# Lane av1444128: AV1 4:4:4 inter 128x128 mu-chunk chroma port (side>64 arm)
2+
3+Base: main `73f3ac64`. Branch `lane-av1-444-128`, worktree
4+`/home/user/Documents/Code/Rust/edith_codecs-av1444128`. Closes the named gap
5+in `lanes/av1444.report.md` continuation 8 item 5: "an inter 128x128 block at
6+4:4:4 still codes ONE chroma unit per mu chunk where libaom codes four
7+(`side > 64` arm)".
8+
9+## What changed (decode.rs, both inter arms -- compound and single-ref; the two
10+arms' text was byte-identical, the patch asserts that and rewrites both)
11+
12+1. **The chunk tail's chroma read is now a per-unit walk** (libaom
13+ `decode_token_recon_block`, decodeframe.c mu loop + `av1_get_max_uv_txsize`
14+ blockd.h:1361): `av1_get_max_uv_txsize(BLOCK_128X128)` = TX_32X32, and the mu
15+ walk enumerates EVERY TX_32X32 unit of the chunk's chroma per plane in raster
16+ order. At ss 0/0 the chunk's chroma is 64x64 -> FOUR units; at 4:2:0 it is
17+ 32x32 -> the loop degenerates to the one unit the arm always coded
18+ (`chunk_chroma = chroma_side * 64 / side`, `units = chunk_chroma / 32` --
19+ derived from the existing `chroma_side`, so the patch composes with the 444
20+ lane's `chroma_side = side >> ss_x` threading without touching it).
21+2. **Per-unit geometry and stamps** (the 444 lane's continuation-8 lesson):
22+ each unit reads `around_mi` at its own mi origin over its own entropy-cell
23+ span (64 px at 4:2:0, 32 px = 8 mi cells at ss 0/0; `get_txb_ctx` reads 8
24+ chroma context cells either way) and `record_mi_chroma`s the unit's own grid
25+ immediately, so the next unit over reads this one's state. Offsets
26+ (`cu_x/cu_y`, the MC predictor slice, the assembled `u_units`/`v_units`
27+ grid placement) are all generalized off `chunk_chroma`; at 4:2:0 every
28+ generalized expression equals the old literal (byte-identical degenerate
29+ case, witnessed below).
30+3. **Per-unit chroma tx_type inheritance** (`av1_get_tx_type`, blockd.h:1291):
31+ an inter block's chroma unit inherits the coded type of the luma leaf
32+ covering its own quadrant (the map is read at the chroma 4x4 position scaled
33+ back to luma), not the block's first leaf. The arms now collect each luma
34+ leaf's `(row, col, tw, th, tx_type)` and resolve the cover per unit. At
35+ 4:2:0 with unsplit TX_64X64 leaves every type is DCT_DCT and this equals the
36+ old `first_tx_type` pass-through (byte-identical); with split leaves the old
37+ code was wrong and the new code is libaom-exact. `reduce_inherited_chroma_tx_type`
38+ (the chroma ext-tx narrowing) is unchanged.
39+4. The lossless sub-arm's call now passes the generalized chunk offset/size;
40+ its internal per-unit walk is unchanged.
41+5. New regression gate
42+ `a_real_aomenc_128x128_none_inter_blocks_coded_chroma_per_mu_chunk_decodes_pixel_exact`
43+ (stream.rs): testsrc2 128x128, `--sb-size=128 --min-partition-size=64
44+ --max-partition-size=128 --cq-level=8 --cpu-used=2`, 12 frames; the key
45+ frame splits to 64x64 (detailed content) and ALL 11 inter frames are
46+ non-skip 128x128 PARTITION_NONE blocks. Hard census asserts
47+ (`inter_sb128_none_hits >= 8`, `chroma_split_tx_hits >= 64` = two units per
48+ plane per coded block -- measured 11 and 88) + pixel-exact via
49+ `decode_all_frames_vs_oracle`.
50+
51+## Reproduce (ticket step 1)
52+
53+Recipe: `ffmpeg testsrc2=size=128x128` 12f y4m | `aomenc --profile=1
54+--sb-size=128 --min-partition-size=64 --max-partition-size=128 --cq-level=8
55+--cpu-used=2 --enable-obmc=0 --enable-warped-motion=0 --enable-interintra-comp=0
56+--enable-interintra-wedge=0 --enable-smooth-interintra=0 --enable-ref-frame-mvs=0
57+--kf-max-dist=100 --enable-fwd-kf=0 --enable-palette=0 --enable-intrabc=0
58+--enable-cdef=0 --enable-restoration=0 --loopfilter-control=0 --obu` (`w128_444.obu`,
59+scripts in `$HOME/.cache/av1444128/`). Partition census (instrumented aomdec
60+`EC_TRACE`): frame 0 = 128 root SPLIT (four 64x64 NONE -- no 128x128 INTRA
61+block anywhere, which matters because the 444 tree's INTRA 128 arm is still
62+one-unit-per-chunk, see gaps); frames 1..11 = 128x128 PARTITION_NONE, all
63+non-skip. Pre-port confirmation (probe built from lane-av1-444 `1ad7e0fc`):
64+frame 0 decodes byte-exact; every inter frame is garbage (~40k differing
65+samples of 49152) with the entropy ladder still consuming the same symbol
66+count -- our side reads 24 coefficient units per inter frame where libaom reads
67+48, and the oracle trace shows the FOUR TX_32X32 chroma units per chunk per
68+plane (`EC_COEFF plane=1 rows/cols 0,0 0,8 8,0 8,8` per chunk) that the old arm
69+never read. Note the encoder split the LUMA var-tx tree to TX_32X32 leaves
70+here, so the one DctDct leaf in the stream also exercised inheritance (below).
71+
72+## Defect found and fixed during verification (class mixed-unit-tuple)
73+
74+The vartx leaf tuple `(row, col, tw, th)` mixes units: `(row, col)` are MI,
75+`(tw, th)` are PIXELS (the rect-leaf path already divides by `MI`). The first
76+cut of the covering-leaf lookup compared the px extents as mi, so the one
77+non-Idtx leaf in the witness stream (DctDct at luma (64,96)) mapped its chroma
78+unit to the wrong type (Idtx) -- reconstruction-only corruption of exactly that
79+unit (~1.2k chroma samples/frame, entropy in sync, Y exact). Fixed by dividing
80+the leaf extents by `MI` in the predicate (`EC_LEAFDBG` scratch instrumentation
81+pinned it; instrument removed after).
82+
83+## Byte-exactness (probe `decode_probe`; `EC_PROBE_OUT` raw planes vs
84+`aomdec --rawvideo` and `ffmpeg -pix_fmt` rawvideo; all fresh runs, `-y`)
85+
86+| tree | stream | result |
87+| --- | --- | --- |
88+| scratch = lane-av1-444 `1ad7e0fc` + this patch | `w128_444.obu` (11 non-skip 128-none inter, 444) | **IDENTICAL three-way**, sha256 `6cd1ded4ffa94ff7538704fe57e4e4ca40853f45eaab0eb5f5ba7dd879c03e8e` (589824 B) |
89+| this tree (main + patch) | `w128_420.obu` (same recipe, profile 0) | **IDENTICAL three-way**, sha256 `e1072eb0b6484da8d75cb6f587299ffe029cc4c0b12f7a510f0699ddbb2bbaf9` (294912 B) |
90+| scratch | the 444 lane's full 60-frame fixture `full.obu` | **IDENTICAL**, sha256 `c3f95bca00f0ba5ea9f7071f5645edd910b590efebea2d73398017d10dc272d7` -- the same sha continuation 8 quoted; zero regression |
91+| scratch | `f_nolf.obu`, `f444_64.obu`, `sq444.obu` | decode, no refusal |
92+| scratch | `w128c_444.obu` (lag-in-frames=3: ARF exists; 7 non-skip 128-none inter frames, `EC_MODE_VAL mode=23/24` = real COMPOUND_REFERENCE picks, ref1=4/7) | **IDENTICAL** vs aomdec, sha256 `bdc3da9f1c8ec75cd7315606b0d260da955996ae86fbd85bb7d3c33e9e0cedd8` -- the compound arm's copy of the patch is exercised and exact |
93+| this tree | new census gate (above) | ok (11 none-roots, 88 units, pixel-exact) |
94+
95+The committed diff is main-only; the 444 witness necessarily rides the scratch
96+merge with the 444 lane because this tree still refuses non-4:2:0 sequences by
97+name (that refusal lift is lane-av1-444's, in review). The two arms' pre-patch
98+text was byte-identical across both trees (asserted by the patch script,
99+`$HOME/.cache/av1444128/patch_128.py`), so the same patch applied to both.
100+
101+## Still refused or unproven (named gaps, unchanged by this lane)
102+
103+| shape | disposition |
104+| --- | --- |
105+| INTRA 128x128 chroma at ss 0/0 (one unit per chunk, libaom codes four) | exists only on lane-av1-444's tree (main refuses 444); same class one arm over -- flagged for the 444 lane's next continuation |
106+| `read_inter_chroma_lossless` indexes chroma units at `ox / 2` (4:2:0 mi math) | 444-lossless inter chroma unported upstream; offsets passed in are now generalized, internals are the 444 lane's |
107+| 128x128 block overhanging the frame edge: the mu walk does not clip unit origins past `mi_cols`/`mi_rows` (libaom `max_block_wide/high`) | pre-existing at 4:2:0 (unexercised by every byte-exact fixture); left untouched so the 4:2:0 degenerate case stays byte-identical |
108+| a committed suite test for the 444 twin | impossible on this tree (444 refused); recipe + scratch-tree witness above are ready for the post-merge tree |
109+
110+## Build
111+
112+`cargo build --release -p ec-av1 --example decode_probe`: 0 warnings (release
113+target recompiled after touching decode.rs; grep -ci warning = 0).
114+
115+## Full suite
116+
117+Handed to Main per the batch standing order (full suites run on the server, not
118+locally; the locally started run was stopped at ~10 min). Main staged the clean
119+worktree at commit `5bc108bc` to server-3 (user@host-b, unit
120+`av1444128-suite`) with `EC_AV1_REQUIRE_AOMENC=1 EC_AV1_REQUIRE_FFMPEG=1`,
121+command `cargo test -p ec-av1 -- --test-threads=1`. The literal final
122+`test result:` line is appended to this section (and the commit amended) when
123+the run lands.
124+
125+PENDING (server-3 run in flight)
126+
127+LANDED (server-3, payload 5bc108bc, code bytes identical to 6a670aa0):
128+
129+`test result: FAILED. 603 passed; 4 failed; 60 ignored; 0 measured; 0 filtered out; finished in 23908.50s`
130+
131+All four failures are server-staging absences (Main's triage of the bodies: the
132+tarball excludes `lanes/`, and only the oracle aomenc was installed), not lane
133+regressions -- this lane's new census gate passed:
134+
135+- `intra::tests::rect_predictors_match_c_dump` -- missing
136+ `lanes/intrarect_dump.c` (tarball excludes `lanes/`)
137+- `stream::tests::a_real_affine_global_motion_stream_decodes_pixel_exact` --
138+ no aomenc at `~/.cache/aom-affine/build/aomenc` on that host (only the
139+ oracle aomenc was installed); the same test is also the 444 lane's known
140+ live-aomenc infra race (continuation 8), green in isolated re-runs
141+- `stream::tests::a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` --
142+ NotFound (fixture or tool path), not a pixel diff
143+- `wedge::tests::wedge_codebook_matches_libaom_dump` -- missing
144+ `lanes/wedge_libaom.expected.txt`
145+
146+Main is filling the missing paths for the next suite on that host.
147+