forge
Explore
Log in

Don't you dare go Hollow

Merge 39f45c31 (422bigblock) — suite green: 422bigblock 624/0

Browse files at this commit

4f37b0bfa110e1e439ffc4452f686bb5f0c50ca2Ahmet Kaan GümüşParent: ee9bb04c818774
# Conflicts:
#	crates/ec-av1/src/decode.rs
crates/ec-av1/fixtures/422_allskip_2f.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/422_sb128_3f.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+167 -59
@@ -18802,7 +18802,9 @@ fn decode_block_128rect(
1880218802 let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(mi_c));
1880318803 let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(mi_r));
1880418804 // Non-lossless: per mu chunk, `(64 >> ss) / chroma_tx` chroma units per
18805- // axis (one 32x32 at 4:2:0, four 32x32 at 4:4:4 — lane-av1-444sb).
18805+ // axis -- one 32x32 at 4:2:0, two stacked on the tall axis at 4:2:2
18806+ // (lane-av1-422bigblock: the chunk's chroma plane block is 32x64 there),
18807+ // four at 4:4:4 (lane-av1-444sb's own finding on this same walk).
1880618808 debug_assert!(
1880718809 lossless_frame
1880818810 || (chroma_w / chroma_tx, chroma_h / chroma_tx)
@@ -18819,6 +18821,7 @@ fn decode_block_128rect(
1881918821 // The chroma context arrays are indexed in LUMA mi; every chroma unit of
1882018822 // every chunk shares this luma span (2 chroma pixels per luma unit).
1882118823 let luma_span = chroma_tx << ss_x(fctx);
18824+ let luma_span_h = chroma_tx << ss_y(fctx);
1882218825 for ch_row in 0..nch_y {
1882318826 for ch_col in 0..nch_x {
1882418827 for tu_row in ch_row * tpc..(ch_row + 1) * tpc {
@@ -18889,12 +18892,14 @@ fn decode_block_128rect(
1888918892 }
1889018893 }
1889118894 // Transform units per axis inside this mu chunk's chroma span:
18892- // a 64x64 luma chunk covers `64 >> ss` chroma pixels per axis, so
18893- // it holds `(64 >> ss) / chroma_tx` units — one 32x32 at 4:2:0,
18894- // four at 4:4:4 (lane-av1-444sb: the hardcoded 4:2:0 span read
18895- // one unit per chunk there, left six of a 128x64 block's eight
18896- // 32x32 units unread and desynced the tile from that block on).
18895+ // a 64x64 luma chunk covers `64 >> ss` chroma pixels per axis,
18896+ // so it holds `(64 >> ss) / chroma_tx` units -- one 32x32 at
18897+ // 4:2:0, four at 4:4:4 (lane-av1-444sb), TWO STACKED TX_32X32 on
18898+ // the tall axis at 4:2:2 (lane-av1-422bigblock: the chunk's
18899+ // chroma plane block is 32x64 there, so the two axes' counts
18900+ // part ways -- 1 x 2); 8x8 TX_4X4 units when lossless.
1889718901 let cn = ((64 >> ss_x(fctx)) / chroma_tx).max(1);
18902+ let cn_h = ((64 >> ss_y(fctx)) / chroma_tx).max(1);
1889818903 // libaom's per-chunk `unit_width/height` (plane-mi units of the
1889918904 // luma mi grid): `min(mu_blocks + col, max_blocks) >> ss`.
1890018905 let unit_w = ((ch_col + 1) * 16).min(max_w_mi) >> ss_x(fctx);
@@ -18906,8 +18911,10 @@ fn decode_block_128rect(
1890618911 // symbol order the interleaved pair used to read; a lossless
1890718912 // frame's 4x4 chroma units are where it becomes observable.
1890818913 for plane_pass in 1..=2usize {
18909- for ci_row in 0..cn {
18914+ for ci_row in 0..cn_h {
1891018915 for ci_col in 0..cn {
18916+ // The clamp strides are the CHUNK's chroma mi extent
18917+ // per axis: 16 luma mi >> the axis's own ss.
1891118918 if ch_col * (16 >> ss_x(fctx)) + ci_col * stepc >= unit_w
1891218919 || ch_row * (16 >> ss_y(fctx)) + ci_row * stepc >= unit_h
1891318920 {
@@ -18919,12 +18926,13 @@ fn decode_block_128rect(
1891918926 mi_r + ch_row * 16 + ci_row * ((chroma_tx << ss_y(fctx)) / 4),
1892018927 mi_c + ch_col * 16 + ci_col * ((chroma_tx << ss_x(fctx)) / 4),
1892118928 );
18922- let cu_r = tu_reach(
18929+ let cu_r = tu_reach_rect(
1892318930 bw,
1892418931 bh,
1892518932 ch_col * 64 + ci_col * luma_span,
18926- ch_row * 64 + ci_row * luma_span,
18933+ ch_row * 64 + ci_row * luma_span_h,
1892718934 luma_span,
18935+ luma_span_h,
1892818936 reach,
1892918937 px,
1893018938 py,
@@ -18938,7 +18946,8 @@ fn decode_block_128rect(
1893818946 );
1893918947 continue;
1894018948 }
18941- let cu_around = neighbours.around_mi(cu_mi, luma_span);
18949+ let cu_around =
18950+ neighbours.around_mi_rect(cu_mi, luma_span, luma_span_h);
1894218951 let buf: &mut PlaneBuf<'static> =
1894318952 if plane_pass == 1 { &mut *u } else { &mut *v };
1894418953 let grid = read_plane(
@@ -18952,7 +18961,13 @@ fn decode_block_128rect(
1895218961 // reads this one's coefficient context; replayed after
1895318962 // `record_split_luma_rect` below, which would otherwise
1895418963 // clobber them whole-block.
18955- neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, plane_pass, &grid);
18964+ neighbours.record_mi_chroma(
18965+ cu_mi,
18966+ luma_span,
18967+ luma_span_h,
18968+ plane_pass,
18969+ &grid,
18970+ );
1895618971 units.push((plane_pass, cu_mi, grid));
1895718972 }
1895818973 }
@@ -30977,15 +30992,42 @@ impl<'p> RefPix<'p> {
3097730992 (
3097830993 whole_plane(&g.y, g.width, g.height),
3097930994 {
30980- // Reference pictures carry no subsampling field. A
30981- // 4:4:4 chroma plane is luma-sized; 4:2:0 is the quarter.
30982- let full = g.u.len() == g.width * g.height;
30983- let (cw, ch) = if full { (g.width, g.height) } else { (g.width / 2, g.height / 2) };
30995+ // Reference pictures carry no subsampling field -- the
30996+ // plane's own shape is inferred from its length:
30997+ // luma-sized is 4:4:4, `halfw x height` is 4:2:2
30998+ // (ss_x 1, ss_y 0 -- the chroma plane is HALF-width
30999+ // and FULL-height), `halfw x halfh` is 4:2:0. The
31000+ // three lengths are pairwise distinct for every
31001+ // w, h >= 1, so the guess is exact. The old
31002+ // two-way guess read every 4:2:2 reference as
31003+ // quarter-height: a 128x128 frame's chroma resolved
31004+ // 64x64, the bottom mu-chunk row's prediction
31005+ // sampled a clamped row-63 edge and the frame's
31006+ // own pixels were right (the crop is ss-aware) --
31007+ // only INTER prediction off the slot was wrong
31008+ // (lane-av1-422bigblock: the sb128 witness's
31009+ // frame-2 chroma, rows 64..127).
31010+ let halfw = (g.width + 1) / 2;
31011+ let halfh = (g.height + 1) / 2;
31012+ let (cw, ch) = if g.u.len() == g.width * g.height {
31013+ (g.width, g.height)
31014+ } else if g.u.len() == halfw * g.height {
31015+ (halfw, g.height)
31016+ } else {
31017+ (halfw, halfh)
31018+ };
3098431019 whole_plane(&g.u, cw, ch)
3098531020 },
3098631021 {
30987- let full = g.v.len() == g.width * g.height;
30988- let (cw, ch) = if full { (g.width, g.height) } else { (g.width / 2, g.height / 2) };
31022+ let halfw = (g.width + 1) / 2;
31023+ let halfh = (g.height + 1) / 2;
31024+ let (cw, ch) = if g.v.len() == g.width * g.height {
31025+ (g.width, g.height)
31026+ } else if g.v.len() == halfw * g.height {
31027+ (halfw, g.height)
31028+ } else {
31029+ (halfw, halfh)
31030+ };
3098931031 whole_plane(&g.v, cw, ch)
3099031032 },
3099131033 )
@@ -33997,18 +34039,35 @@ fn decode_inter_block(
3399734039 // this arm has always coded. `chroma_side`
3399834040 // already carries the subsampling.
3399934041 let cu_tx = 32usize;
34000- let chunk_chroma = chroma_side * 64 / side;
34001- let units = chunk_chroma / cu_tx;
34042+ // lane-av1-422bigblock: a 64x64 mu chunk's
34043+ // chroma plane block is PER-AXIS
34044+ // (64 >> ss_x) x (64 >> ss_y) -- 32x64 at
34045+ // ss (1,0), i.e. TWO stacked TX_32X32 units
34046+ // per plane (`av1_get_max_uv_txsize` caps the
34047+ // unit at 32 on each axis). The old square-cut
34048+ // model walked `chroma_side`-square chunks:
34049+ // twice the units the oracle codes at 4:2:2,
34050+ // prediction windows indexed at the square
34051+ // `chroma_side` instead of the prediction
34052+ // buffer's own `chroma_stride`, and chunk
34053+ // columns at 64.. of a 64-wide chroma plane.
34054+ let chunk_chroma_w = (64usize) >> ss_x(fctx);
34055+ let chunk_chroma_h = (64usize) >> ss_y(fctx);
34056+ let units_w = chunk_chroma_w / cu_tx;
34057+ let units_h = chunk_chroma_h / cu_tx;
3400234058 // The unit's own footprint on the LUMA mi
34003- // grid: 64 px (16 mi) at 4:2:0, 32 px (8 mi)
34004- // at ss 0/0. `around_mi` reads and
34059+ // grid, per axis (32 << ss) px: 64x64 (16x16
34060+ // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4,
34061+ // 64x32 (16x8 mi) at 4:2:2. `around_mi_rect`
34062+ // reads and
3400534063 // `record_mi_chroma` stamps span exactly the
3400634064 // unit's own cells -- `get_txb_ctx` reads the
3400734065 // 8 context cells of the TX_32X32 itself, and
3400834066 // `av1_set_entropy_contexts` memsets the same
3400934067 // 8, so the unit over never sees this unit's
3401034068 // state and the unit below always does.
34011- let unit_luma = cu_tx * (side / chroma_side);
34069+ let unit_luma_w = cu_tx << ss_x(fctx);
34070+ let unit_luma_h = cu_tx << ss_y(fctx);
3401234071 let cu_scan = default_scan(cu_tx);
3401334072 if lossless(fctx) {
3401434073 // lane-lossless2: TX_4X4 units over this
@@ -34016,8 +34075,8 @@ fn decode_inter_block(
3401634075 read_inter_chroma_lossless(
3401734076 dec, cdfs, neighbours, u, v, su, sv,
3401834077 at_mi, (cpx, cpy),
34019- (cc * chunk_chroma, cr * chunk_chroma),
34020- (chunk_chroma, chunk_chroma),
34078+ (cc * chunk_chroma_w, cr * chunk_chroma_h),
34079+ (chunk_chroma_w, chunk_chroma_h),
3402134080 (write_chroma_w, write_chroma_h),
3402234081 chroma_side, mode_for_tx, base_q_idx,
3402334082 &mut u_units, &mut v_units, fctx,
@@ -34034,24 +34093,28 @@ fn decode_inter_block(
3403434093 // Plane-major per chunk (libaom's plane
3403534094 // loop is outermost inside the mu walk);
3403634095 // within a plane the units walk raster.
34037- for ur in 0..units {
34038- for uc in 0..units {
34096+ for ur in 0..units_h {
34097+ for uc in 0..units_w {
3403934098 let unit_mi = (
3404034099 at_mi.0 + cr * 16
34041- + ur * (unit_luma / MI),
34100+ + ur * (unit_luma_h / MI),
3404234101 at_mi.1 + cc * 16
34043- + uc * (unit_luma / MI),
34102+ + uc * (unit_luma_w / MI),
3404434103 );
3404534104 // Per unit, AFTER the earlier
3404634105 // units' stamps: this unit's
3404734106 // coefficient context must see
3404834107 // them.
3404934108 let cu_around = neighbours
34050- .around_mi(unit_mi, unit_luma);
34109+ .around_mi_rect(
34110+ unit_mi,
34111+ unit_luma_w,
34112+ unit_luma_h,
34113+ );
3405134114 let (cu_x, cu_y) = (
34052- cpx + cc * chunk_chroma
34115+ cpx + cc * chunk_chroma_w
3405334116 + uc * cu_tx,
34054- cpy + cr * chunk_chroma
34117+ cpy + cr * chunk_chroma_h
3405534118 + ur * cu_tx,
3405634119 );
3405734120 // `av1_get_tx_type` (blockd.h:
@@ -34082,11 +34145,16 @@ fn decode_inter_block(
3408234145 },
3408334146 )
3408434147 .map(|(_, _, _, _, t)| t);
34148+ // The prediction buffer is
34149+ // `chroma_stride`-strided (the
34150+ // plane block's own width at
34151+ // 4:2:2), not the square
34152+ // `chroma_side`.
3408534153 let cu_pred = src.offset(
34086- (cr * chunk_chroma
34154+ (cr * chunk_chroma_h
3408734155 + ur * cu_tx)
34088- * chroma_side
34089- + cc * chunk_chroma
34156+ * chroma_stride
34157+ + cc * chunk_chroma_w
3409034158 + uc * cu_tx,
3409134159 );
3409234160 let cu_grid = read_inter_plane(
@@ -34116,8 +34184,8 @@ fn decode_inter_block(
3411634184 // context.
3411734185 neighbours.record_mi_chroma(
3411834186 unit_mi,
34119- unit_luma,
34120- unit_luma,
34187+ unit_luma_w,
34188+ unit_luma_h,
3412134189 plane_idx,
3412234190 &cu_grid,
3412334191 );
@@ -34132,11 +34200,18 @@ fn decode_inter_block(
3413234200 chroma_side * chroma_side,
3413334201 );
3413434202 for rr in 0..cu_tx {
34135- let start = (cr * chunk_chroma
34203+ // The ASSEMBLED grid stays at
34204+ // the square `chroma_side`
34205+ // stride the block tail's
34206+ // `mu_chroma_units` re-stamp
34207+ // indexes; the unit's true
34208+ // per-axis position is what
34209+ // changes.
34210+ let start = (cr * chunk_chroma_h
3413634211 + ur * cu_tx
3413734212 + rr)
3413834213 * chroma_side
34139- + cc * chunk_chroma
34214+ + cc * chunk_chroma_w
3414034215 + uc * cu_tx;
3414134216 dst[start..start + cu_tx]
3414234217 .copy_from_slice(
@@ -35544,18 +35619,35 @@ fn decode_inter_block(
3554435619 // this arm has always coded. `chroma_side`
3554535620 // already carries the subsampling.
3554635621 let cu_tx = 32usize;
35547- let chunk_chroma = chroma_side * 64 / side;
35548- let units = chunk_chroma / cu_tx;
35622+ // lane-av1-422bigblock: a 64x64 mu chunk's
35623+ // chroma plane block is PER-AXIS
35624+ // (64 >> ss_x) x (64 >> ss_y) -- 32x64 at
35625+ // ss (1,0), i.e. TWO stacked TX_32X32 units
35626+ // per plane (`av1_get_max_uv_txsize` caps the
35627+ // unit at 32 on each axis). The old square-cut
35628+ // model walked `chroma_side`-square chunks:
35629+ // twice the units the oracle codes at 4:2:2,
35630+ // prediction windows indexed at the square
35631+ // `chroma_side` instead of the prediction
35632+ // buffer's own `chroma_stride`, and chunk
35633+ // columns at 64.. of a 64-wide chroma plane.
35634+ let chunk_chroma_w = (64usize) >> ss_x(fctx);
35635+ let chunk_chroma_h = (64usize) >> ss_y(fctx);
35636+ let units_w = chunk_chroma_w / cu_tx;
35637+ let units_h = chunk_chroma_h / cu_tx;
3554935638 // The unit's own footprint on the LUMA mi
35550- // grid: 64 px (16 mi) at 4:2:0, 32 px (8 mi)
35551- // at ss 0/0. `around_mi` reads and
35639+ // grid, per axis (32 << ss) px: 64x64 (16x16
35640+ // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4,
35641+ // 64x32 (16x8 mi) at 4:2:2. `around_mi_rect`
35642+ // reads and
3555235643 // `record_mi_chroma` stamps span exactly the
3555335644 // unit's own cells -- `get_txb_ctx` reads the
3555435645 // 8 context cells of the TX_32X32 itself, and
3555535646 // `av1_set_entropy_contexts` memsets the same
3555635647 // 8, so the unit over never sees this unit's
3555735648 // state and the unit below always does.
35558- let unit_luma = cu_tx * (side / chroma_side);
35649+ let unit_luma_w = cu_tx << ss_x(fctx);
35650+ let unit_luma_h = cu_tx << ss_y(fctx);
3555935651 let cu_scan = default_scan(cu_tx);
3556035652 if lossless(fctx) {
3556135653 // lane-lossless2: TX_4X4 units over this
@@ -35563,8 +35655,8 @@ fn decode_inter_block(
3556335655 read_inter_chroma_lossless(
3556435656 dec, cdfs, neighbours, u, v, su, sv,
3556535657 at_mi, (cpx, cpy),
35566- (cc * chunk_chroma, cr * chunk_chroma),
35567- (chunk_chroma, chunk_chroma),
35658+ (cc * chunk_chroma_w, cr * chunk_chroma_h),
35659+ (chunk_chroma_w, chunk_chroma_h),
3556835660 (write_chroma_w, write_chroma_h),
3556935661 chroma_side, mode_for_tx, base_q_idx,
3557035662 &mut u_units, &mut v_units, fctx,
@@ -35581,24 +35673,28 @@ fn decode_inter_block(
3558135673 // Plane-major per chunk (libaom's plane
3558235674 // loop is outermost inside the mu walk);
3558335675 // within a plane the units walk raster.
35584- for ur in 0..units {
35585- for uc in 0..units {
35676+ for ur in 0..units_h {
35677+ for uc in 0..units_w {
3558635678 let unit_mi = (
3558735679 at_mi.0 + cr * 16
35588- + ur * (unit_luma / MI),
35680+ + ur * (unit_luma_h / MI),
3558935681 at_mi.1 + cc * 16
35590- + uc * (unit_luma / MI),
35682+ + uc * (unit_luma_w / MI),
3559135683 );
3559235684 // Per unit, AFTER the earlier
3559335685 // units' stamps: this unit's
3559435686 // coefficient context must see
3559535687 // them.
3559635688 let cu_around = neighbours
35597- .around_mi(unit_mi, unit_luma);
35689+ .around_mi_rect(
35690+ unit_mi,
35691+ unit_luma_w,
35692+ unit_luma_h,
35693+ );
3559835694 let (cu_x, cu_y) = (
35599- cpx + cc * chunk_chroma
35695+ cpx + cc * chunk_chroma_w
3560035696 + uc * cu_tx,
35601- cpy + cr * chunk_chroma
35697+ cpy + cr * chunk_chroma_h
3560235698 + ur * cu_tx,
3560335699 );
3560435700 // `av1_get_tx_type` (blockd.h:
@@ -35629,11 +35725,16 @@ fn decode_inter_block(
3562935725 },
3563035726 )
3563135727 .map(|(_, _, _, _, t)| t);
35728+ // The prediction buffer is
35729+ // `chroma_stride`-strided (the
35730+ // plane block's own width at
35731+ // 4:2:2), not the square
35732+ // `chroma_side`.
3563235733 let cu_pred = src.offset(
35633- (cr * chunk_chroma
35734+ (cr * chunk_chroma_h
3563435735 + ur * cu_tx)
35635- * chroma_side
35636- + cc * chunk_chroma
35736+ * chroma_stride
35737+ + cc * chunk_chroma_w
3563735738 + uc * cu_tx,
3563835739 );
3563935740 let cu_grid = read_inter_plane(
@@ -35663,8 +35764,8 @@ fn decode_inter_block(
3566335764 // context.
3566435765 neighbours.record_mi_chroma(
3566535766 unit_mi,
35666- unit_luma,
35667- unit_luma,
35767+ unit_luma_w,
35768+ unit_luma_h,
3566835769 plane_idx,
3566935770 &cu_grid,
3567035771 );
@@ -35679,11 +35780,18 @@ fn decode_inter_block(
3567935780 chroma_side * chroma_side,
3568035781 );
3568135782 for rr in 0..cu_tx {
35682- let start = (cr * chunk_chroma
35783+ // The ASSEMBLED grid stays at
35784+ // the square `chroma_side`
35785+ // stride the block tail's
35786+ // `mu_chroma_units` re-stamp
35787+ // indexes; the unit's true
35788+ // per-axis position is what
35789+ // changes.
35790+ let start = (cr * chunk_chroma_h
3568335791 + ur * cu_tx
3568435792 + rr)
3568535793 * chroma_side
35686- + cc * chunk_chroma
35794+ + cc * chunk_chroma_w
3568735795 + uc * cu_tx;
3568835796 dst[start..start + cu_tx]
3568935797 .copy_from_slice(
crates/ec-av1/src/stream.rsmodified+56 -0
@@ -2226,6 +2226,62 @@ pub(crate) mod tests {
22262226 let frames = decode_stream(&stream).expect("the 4:2:0 control must decode");
22272227 assert_eq!(frames.len(), 1, "{NAME}: the 4:2:0 control decoded no frame");
22282228 }
2229+ /// lane-av1-422bigblock: the two witnessed 4:2:2 big-block defects, pinned
2230+ /// as fixtures (`git add -f`; `fixtures/` is gitignored).
2231+ ///
2232+ /// `422_allskip_2f.obu` (62 bytes) is a 128x128 profile-2 key frame plus
2233+ /// its all-skip first inter frame: the pre-port decoder read phantom
2234+ /// coefficient units in the inter frame and then panicked in
2235+ /// `reconstruct_mc_rect` on a full-height 4:2:2 chroma rect. At this
2236+ /// lane's HEAD the block-half port's per-axis plane-block model already
2237+ /// has it entropy-locked (all 20 key-frame coefficient units pair
2238+ /// rng-for-rng with the instrumented oracle, the inter frame reads
2239+ /// zero, matching the oracle) and pixel-exact vs aomdec.
2240+ ///
2241+ /// `422_sb128_3f.obu` (12543 bytes) carries the f2 128x128
2242+ /// `PARTITION_NONE` non-skip inter block: the mu-chunk chroma walk cut
2243+ /// each chunk's 32x64 chroma into a `chroma_side`-square 64x64 (twice
2244+ /// the units the oracle codes), indexed the prediction buffer at the
2245+ /// square `chroma_side` instead of `chroma_stride` (the empty-slice
2246+ /// panic at `push_mc_rect_tx`'s densify), and the reference plane
2247+ /// resolution guessed every non-4:4:4 picture quarter-height, so the
2248+ /// bottom mu-chunk row predicted from a clamped row-63 edge. All fixed;
2249+ /// both witnesses decode pixel-exact vs aomdec on the lane's local
2250+ /// `EC_AV1_ALLOW_422_PROBE` patch-run-restore build (recipe and measured
2251+ /// numbers in `lanes/av1422bigblock.report.md`).
2252+ ///
2253+ /// `decode_stream` itself still refuses 4:2:2 at the sequence header --
2254+ /// unconditionally, per the standing family rule -- so the committed
2255+ /// assertion is the byte pin (fnv1a64, the same load-bearing-identity
2256+ /// fingerprint as the cdf-forwarding gate) plus the refusal-by-name
2257+ /// contract over the pinned bytes.
2258+ #[test]
2259+ fn the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name() {
2260+ const NAME: &str = "the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name";
2261+ const REFUSAL: &str = "a chroma format of 4:2:2";
2262+ for (file, bytes, fp) in [
2263+ ("422_allskip_2f.obu", 62usize, 0x7e4d69d3c728c55f_u64),
2264+ ("422_sb128_3f.obu", 12543, 0x5171e0aab8000da7),
2265+ ] {
2266+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
2267+ .join("fixtures")
2268+ .join(file);
2269+ let data = std::fs::read(&path).unwrap_or_else(|e| {
2270+ panic!(
2271+ "{NAME}: pinned witness {} is missing ({e}) -- the gate cannot run",
2272+ path.display()
2273+ )
2274+ });
2275+ assert_eq!(data.len(), bytes, "{NAME}: {file} size drifted");
2276+ assert_eq!(fnv1a64(&data), fp, "{NAME}: {file} bytes drifted");
2277+ let err = decode_stream(&data).unwrap_err().to_string();
2278+ assert!(
2279+ err.contains(REFUSAL),
2280+ "{NAME}: {file} must refuse by name, got: {err}"
2281+ );
2282+ }
2283+ }
2284+
22292285
22302286 /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the
22312287 /// old gate `a_frame_using_quantisation_matrices_is_refused_by_name` is
lanes/av1422bigblock.report.mdadded+187 -0
@@ -0,0 +1,187 @@
1+# lane-av1-422bigblock — the two witnessed 4:2:2 big-block defects
2+
3+Branch `lane-av1-422bigblock`, HEAD `213c1eb0` (contains the block-half port).
4+Target dir `$HOME/.cache/cargo-target-av1422bigblock` throughout. No push.
5+
6+## Verdict
7+
8+Both witnessed defects are fixed and both witnesses are pixel-exact vs aomdec.
9+The panic the ticket predicted for defect 1 no longer reproduces at this HEAD —
10+the block-half port had already fixed the all-skip inter frame; re-verified, not
11+assumed. Defect 2 needed three fixes, two of them found below the historical
12+panic line. The 4:2:0/4:4:4 behavior is unchanged (targeted gates green, t422
13+frame 0 byte-exact at all four stages). Defect 3 (Main's IRC addition, the
14+s2.obu crash) is fixed as a crash; s2's remaining divergence is a pre-existing
15+sub-8 chroma class, fingerprinted for its owning lane. Committed code still
16+refuses 4:2:2 at the sequence header; the `EC_AV1_ALLOW_422_PROBE` bypass was
17+applied and reverted per probe run and is **not** in the commit.
18+
19+## Fixtures (pinned, `git add -f`; `fixtures/` is gitignored)
20+
21+| fixture | bytes | sha256 | fnv1a64 |
22+|---|---|---|---|
23+| `422_allskip_2f.obu` | 62 | `ba4932c14f95971b5f25321b04abce80c9fdd5de4b1fe6fffcdad82aaea87ce1` | `0x7e4d69d3c728c55f` |
24+| `422_sb128_3f.obu` | 12543 | `0b851799d99cb4d141a7d042138a3999aad7e0fb24d69c670bca1d38c286dce9` | `0x5171e0aab8000da7` |
25+
26+Provenance: the witness hunt's artifacts under `~/.cache/av1422sb128wit/`
27+(`422_allskip_2f.obu` = `b422_wit2f.obu`, `422_sb128_3f.obu` = `b422b_3f.obu`;
28+oracle refs `b422_wit.ref.yuv`). NOTE: the ticket said `422_sb128_3f.obu` is
29+10175 bytes; the live file is 12543 bytes and its sha256 matches the ticket —
30+the byte count in the charter is stale, the hash is authoritative.
31+
32+Gate: `the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name`
33+(stream.rs) asserts both byte pins and the refusal-by-name contract.
34+`decode_stream` still refuses 4:2:2 unconditionally in committed code, so a
35+committed gate cannot decode these streams; the decode-completes + counters +
36+pixel-exact assertions were measured through the probe build and are
37+reproducible from the recipe below. The counters over the sb128 witness:
38+`chroma422_square: 32`; over s2: `chroma422_square: 68, chroma422_rect: 222,
39+chroma422_sub8: 24, chroma422_chunk: 40`, `part128 none=3`.
40+
41+## Reproduce (patch-run-restore, local only)
42+
43+```
44+sed 's/if seq.subsampling_x != seq.subsampling_y {/if seq.subsampling_x != seq.subsampling_y \&\& std::env::var_os("EC_AV1_ALLOW_422_PROBE").is_none() {/' -i crates/ec-av1/src/stream.rs
45+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1422bigblock cargo build -p ec-av1 --example decode_probe --features gate-counters
46+EC_AV1_ALLOW_422_PROBE=1 EC_PROBE_OUT=/tmp/ours.raw \
47+ $HOME/.cache/cargo-target-av1422bigblock/debug/examples/decode_probe crates/ec-av1/fixtures/422_sb128_3f.obu
48+$HOME/.cache/aom-oracle/build/aomdec --rawvideo -o /tmp/oracle.raw crates/ec-av1/fixtures/422_sb128_3f.obu
49+cmp /tmp/ours.raw /tmp/oracle.raw # identical
50+git checkout -- crates/ec-av1/src/stream.rs
51+```
52+
53+## Defect 1 — all-skip 422 inter desync: NOT REPRODUCING at HEAD (fixed upstream)
54+
55+At `213c1eb0` the witness decodes clean: `OK: 2 frames decoded, 128x128`, no
56+panic, no phantom reads. Evidence:
57+
58+- Entropy: our `EC_TRACE_COEFF` pairs rng-for-rng with the instrumented
59+ oracle's — frame 0 codes 20 coefficient units (one nonzero 32x32 luma unit +
60+ 4 stacked-chroma per 32x32 quadrant), identical rng sequence on both sides;
61+ frame 1 codes **zero** units on both sides (all-skip, as the oracle).
62+- Pixels: the shown frame is byte-identical to `aomdec --rawvideo`.
63+
64+The ticket's "~20 phantom units + reconstruct_mc_rect side=64 w=64 h=128 panic"
65+is the pre-blockhalf state; the per-axis plane-block model fixed both the
66+phantom reads and the geometry. No code change needed here. The full hunt
67+stream `b422_wit.obu` (6 frames) also decodes OK at HEAD.
68+
69+## Defect 2 — 128-root square-cut chroma chunking: three stacked causes
70+
71+The historical `range end 4128 > 4096` (decode.rs:34279) no longer reproduces;
72+at HEAD the same block panicked deeper, in `push_mc_rect_tx`'s stride-densify
73+(`range end index 32 out of range for slice of length 0`). The f2 128x128
74+PARTITION_NONE non-skip inter block carries all three causes; the oracle codes
75+16 chroma units (8 per plane, 2 stacked TX_32X32 per 64x64 mu chunk).
76+
77+1. **Square-cut chunking** (`decode_inter_block`, both the inter-luma and the
78+ intra-in-inter walk): `chunk_chroma = chroma_side * 64 / side` cut each
79+ chunk's per-axis `(64>>ss_x) x (64>>ss_y)` chroma into a
80+ `chroma_side`-square 64x64 — twice the units the oracle codes at 4:2:2.
81+ Fixed per-axis (`chunk_cw/chunk_ch`, `units_w/units_h`), unit luma spans
82+ `(32<<ss_x, 32<<ss_y)` via `around_mi_rect`/per-axis
83+ `record_mi_chroma`, and the assembled grid placement per-axis.
84+2. **Prediction stride**: `cu_pred = src.offset((cr*chunk + ur*cu_tx) *
85+ chroma_side + ...)` indexed the prediction buffer at the square
86+ `chroma_side` (128) while the 4:2:2 buffer is `chroma_stride`-strided (the
87+ plane block's own width, 64). Chunk (0,0)'s tall unit read buffer row 64 as
88+ row 32, and chunk (1,0) offset to `len` exactly — the empty slice. Fixed to
89+ `* chroma_stride`; the assembled grid stays at the square `chroma_side`
90+ stride the block-tail `mu_chroma_units` re-stamp already indexes per-axis
91+ (verified unit-for-unit against the walk).
92+3. **Reference plane resolution** (`RefPix::planes`): a `Picture` carries no
93+ subsampling field, and the two-way guess (luma-sized = 4:4:4, otherwise
94+ quarter = 4:2:0) resolved every 4:2:2 reference 64x64. The frame's own
95+ pixels were right (the crop is ss-aware) — only inter prediction off the
96+ slot was wrong, so the bottom mu-chunk row predicted from a clamped row-63
97+ edge (±1–2 diffs over chroma rows 64..127, 3.3–3.6k samples/plane). Fixed
98+ with a three-way length inference (`w*h` / `halfw*h` / `halfw*halfh`,
99+ `halfw = (w+1)/2`, `halfh = (h+1)/2` — the three lengths are pairwise
100+ distinct for every w,h ≥ 1). DISCLOSED 4:2:0 edge: at ODD reference
101+ dimensions the half-width uses ceil (`(w+1)/2`, matching the picture
102+ crop's `round_ss`) where the old guess used floor (`w/2`) — ceil is the
103+ correct stored-crop shape and the change is visible only at odd w/h, which
104+ no committed fixture exercises.
105+
106+After the fixes: `422_sb128_3f.obu` and the full `b422_wit.obu` decode
107+pixel-exact vs aomdec; every coefficient unit of every frame pairs
108+rng-for-rng with the oracle (29/29, 32/32, 32/32).
109+
110+Class sweep of the same square-cut model:
111+- `decode_intrabc_128rect` has the same `cside * 64 / side` square chunk walk —
112+ **deferred** (same class, unwitnessed: no 4:2:2 intrabc 128-rect witness
113+ exists; unblock = one aomenc `--enable-intrabc` profile-2 128-SB hunt).
114+- The 444 branch of the inter walk degenerates to identical values (ss 0/0 ⇒
115+ per-axis == square, `chroma_stride == chroma_side`), verified by gate.
116+
117+## Defect 3 (Main's IRC) — s2.obu crash: crash fixed, residual named
118+
119+`/tmp/sa422/s2.obu` (recipe: `lanes/av1422stripanchor.report.md` "Observed, not
120+chased"; 420 control `b420_wit.obu`) panicked at `decode.rs:3709` at HEAD — the
121+same densify site, fed by defect 2's cause 3 (quarter-height reference) and the
122+intra 128-rect twin of the square-cut walk:
123+
124+- `decode_block_128rect`'s chroma walk was chunk-square (`cn = 32/chroma_tx`,
125+ `cu_y = cpy + ch_row*32`, clamp strides 8/8) with a `debug_assert!` that no
126+ 4:2:2 stream can satisfy. Fixed per-axis exactly like the inter walk
127+ (`tu_reach_rect`, `around_mi_rect`, per-axis record spans), in the SAME
128+ expression shape the already-reviewed 444 fix landed on lane-av1-444sb
129+ (`349b3918`): `cn = ((64 >> ss_x)/chroma_tx).max(1)` for the width axis
130+ plus the added `cn_h = ((64 >> ss_y)/chroma_tx).max(1)` for the height
131+ axis, per-axis chunk offsets `(64 >> ss)` and clamp strides `(16 >> ss)` —
132+ at ss(0,0) the code reduces line-for-line to `349b3918`'s form, so the
133+ merge with that chain is a semantic union. DISCLOSED 4:4:4 behavior change:
134+ the parent's walk was provably broken at ss(0,0) (one unit per chunk instead
135+ of four; the stale assert caught it) and this rewrite, like `349b3918`,
136+ codes the four units — NOT byte-identical to parent at 4:4:4, by design,
137+ and pinned by `349b3918`'s own witness on the merged tree (see the identity
138+ section). DISCLOSED 4:2:0 identity: at ss(1,1) every new expression reduces
139+ to the old constant (32, offsets 32, strides 8, one unit).
140+
141+Result: s2.obu decodes all 16 frames, no panic (`OK: 16 frames decoded,
142+256x144`). The crash the charter assigned is closed. **Deferred (named for its
143+owning lane):** s2's frame 0 diverges from aomdec (~45% of samples, maxabs
144+~180, Y first diff at sample 126) with an entropy desync: the oracle codes
145+1089 coefficient units in frame 0, ours 541, first divergence at unit 38 — a
146+plane-2 **TX_4X8** chroma unit at **mi(12,24)** (oracle `all_zero=0
147+rng=48745`, ours `rng=41584`). Class: sub-8/odd-strip 4:2:2 chroma under the
148+128-rect intra path (the `ss_size_lookup` BLOCK_INVALID family), pre-existing
149+— the base tree panics at frame 0's assert and never produced pixels. At base
150+the stream could not be measured at all; the pre-fix re-run log is
151+`/tmp/sa422/re-run-av1422ctxgather.log`. Fingerprint: `/tmp/sa422/s2f0.obu`,
152+unit 38, mi(12,24), TX_4X8, plane 2.
153+
154+## 4:2:0/4:4:4 identity + t422
155+
156+- `a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact` — green.
157+- `a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_stream`
158+ (live aomenc, 420, inter, tiles) — green.
159+- `a_lossless_sb128_rect_intra_block_decodes_sample_exact` — green. LABEL
160+ CORRECTION (review finding 2): this stream is 4:2:0 (seq_profile 0 in the
161+ fixture bytes), NOT 4:4:4 as this report first claimed; it is a 4:2:0
162+ lossless sb128 gate and proves nothing about 4:4:4.
163+- 4:4:4 evidence, done properly: `444_sb128rect_lr_witness.obu` (sha256
164+ `27825e14…`, the lane-av1-444sb witness, 192x160 profile-1, 3 frames) was
165+ decoded on THIS tree (`OK: 3 frames decoded`) and its output is
166+ BYTE-IDENTICAL to the parent commit's output on the same stream — measured
167+ by stash-and-rebuild, all three frames — so the rewrite is proven
168+ output-neutral on it. The stream itself still diverges from aomdec on this
169+ ancestry, identically before and after the fix: this branch predates the
170+ 444 chain's chroma-context fixes (`9e77c16b` ss-aware chroma-above skip,
171+ `76f8c3fe`), the desync starts at frame-0 Y sample 128 (the first
172+ 128-column superblock) and the first 128-rect block never fires downstream
173+ of it, so `decode_block_128rect` codes no samples on this stream on this
174+ ancestry. `349b3918`'s own gate
175+ (`a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact`,
176+ frames 0/1 byte-exact vs aomdec AND ffmpeg) is the merged-tree pin: at
177+ ss(0,0) this lane's walk reduces verbatim to that reviewed form.
178+- `a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders`
179+ and `a_128_root_compound_block_decodes_exact_through_both_decoders` (solo,
180+ they pin the process-global superblock size) — green.
181+- t422 frame 0 (`/tmp/i422/t422_1f.obu`) byte-exact vs the instrumented oracle
182+ at PREFILT, POSTDEBLOCK, POSTCDEF and FINAL on Y, U and V; t422 16-frame
183+ stream decodes with the same frame count as the parent (15 shown of 16 frame
184+ OBUs, unchanged at HEAD — the 16th is an `OBU_TILE_LIST` quirk, not a
185+ regression).
186+
187+`cargo check -p ec-av1`: 0 warnings. Committed on the branch, no push.