From a50f36314b99561dd49f13fdd34877c00d114d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 28 Sep 2026 10:29:00 +0300 Subject: [PATCH] ec-av1: lane-av1-ibc128chunk -- the 128-root intrabc strip's mu-chunk chroma walk de-square-cut, with a red/green 4:2:2 witness decode_intrabc_128rect cut each mu chunk's chroma plane block with `chunk_chroma = cside * 64 / side` -- a `chroma_side`-SQUARE chunk, i.e. the 4:2:0 unit count on BOTH axes. This is the same defect lane-av1-422bigblock fixed and witnessed in decode_inter_block and decode_block_128rect; this copy was deferred there as unwitnessed. It is now witnessed: a real `aomenc --i422 --profile=2 --sb-size=128 --enable-intrabc=1` stream reaches the shape. A 64x64 mu chunk's chroma plane block is (64 >> ss_x) x (64 >> ss_y) -- 32x32 at 4:2:0, 32x64 at 4:2:2 (TWO STACKED TX_32X32 per plane, which av1_get_max_uv_txsize still caps at 32 per axis), 64x64 at 4:4:4. At 4:2:2 the square cut read one chroma unit per plane per chunk instead of two, left the chunk's lower 32 chroma rows with no residual at all, and stamped each unit's entropy context over a 16x16-mi luma square instead of 16x8; the block's own plane block was still the 4:2:0-hardcoded `bw/2 x bh/2` (and `px/2, py/2`) even though the same function's two mv_to_q4 calls already scaled the DV per axis by ss_y. The halved unit count desynced the tile. Fix: per-axis at BOTH sites (the mu-chunk read walk and the mu_chroma per-unit context replay) in the same expression shape the two witnessed twins carry -- chunk_chroma_w/h = 64 >> ss, unit_luma_w/h = cu_tx << ss, around_mi_rect/record_mi_chroma on the per-axis spans, per-axis unit origins and composed-grid offsets, and cw/ch = bw/bh >> ss for the block's chroma plane block. Red before (parent a7d22aec, on the EC_AV1_ALLOW_422_PROBE patch-run-restore build): 8 chroma units stamped over 2 reached blocks, frames 0 and 3 diverge from aomdec (45135 / 44540 of 245760 samples), first difference at Y row 256 col 64 -- the top-left of the first 128x64 intrabc block. Green after: 48 chroma units, all 6 blocks decoded, and all FIVE frames byte-identical to aomdec --rawvideo. The recovered 4 blocks are the signal as much as the pixel count. Both witnesses pinned (422_intrabc_sb128_strip.obu sha f92000db, 422_intrabc_sb128_strip_notxsearch.obu sha 80dd0d4e) and gated by the_pinned_422_intrabc_sb128_strip_witnesses_refuse_by_name (byte pins plus the unconditional refusal-by-name contract; decode_stream still refuses 4:2:2 in committed code, so the decode-level assertions are probe-measured and reproducible from the lane report's recipe) and a comment-stripped source-scan arm the_intrabc_128rect_chroma_chunk_walk_stays_per_axis, whose non-vacuity is measured: re-introducing the square cut fails it. Two new counters (INTRABC_128RECT_CHROMA_CHUNK_HITS, INTRABC_128RECT_CHUNK_SHAPE) pin the walk for the probe arms. 4:2:0 is byte-identical (64 >> 1 = 32, 32 << 1 = 64, bw >> 1 = bw/2) and proven by the tree's own sb128 intrabc-rect gate -- same recipe as the witness, at yuv420p/yuv420p10le, 30 blocks through the changed walk, all three arms decode-order pixel-exact. DISCLOSED 4:4:4 behavior change: at ss (0,0) the walk now codes four TX_32X32 per chunk per plane and the block's chroma plane block is luma-sized; the parent's was provably wrong there (chroma_side is the 4:2:0 half-side, so the old 32x32 chunk covered a quarter of a 64x64 4:4:4 chunk and the origin was off by half a superblock). No committed 4:4:4 fixture engages this function at all (ibc128=0 on all six), so the change is landed on the twins' geometry argument and flagged as needing its own 4:4:4 witness. Battery green: an_sb128_rect_strip_with_intrabc_decodes_pixel_exact, an_sb128_screen_stream_with_intrabc_decodes_pixel_exact, a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact, a_lossless_sb128_rect_intra_block_decodes_sample_exact, the two other intrabc gates, the bigblock pin gate; intrabc filter 19/0, 422+444 filters 12/0; cargo check --all-targets 0 warnings. The EC_AV1_ALLOW_422_PROBE bypass is NOT in the commit. --- crates/ec-av1/examples/decode_probe.rs | 7 + .../fixtures/422_intrabc_sb128_strip.obu | Bin 0 -> 1672 bytes .../422_intrabc_sb128_strip_notxsearch.obu | Bin 0 -> 1675 bytes crates/ec-av1/src/decode.rs | 149 ++++++++--- crates/ec-av1/src/stream.rs | 179 +++++++++++++ lanes/av1ibc128chunk.report.md | 251 ++++++++++++++++++ 6 files changed, 552 insertions(+), 34 deletions(-) create mode 100644 crates/ec-av1/fixtures/422_intrabc_sb128_strip.obu create mode 100644 crates/ec-av1/fixtures/422_intrabc_sb128_strip_notxsearch.obu create mode 100644 lanes/av1ibc128chunk.report.md diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index bec376fd..0cc4fce0 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -91,6 +91,13 @@ fn main() { "intrabc_128rect: {}", ec_av1::stream::intrabc_128rect_hits() ); + // lane-av1-ibc128chunk: the 128-root intrabc strip's per-axis chroma + // mu-chunk walk -- unit count and the `(64>>ss_x)|(64>>ss_y)` extent. + println!( + "intrabc_128rect_chroma_chunk: units={} shape=0x{:x}", + ec_av1::stream::intrabc_128rect_chroma_chunk_hits(), + ec_av1::stream::intrabc_128rect_chunk_shape() + ); let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); println!( diff --git a/crates/ec-av1/fixtures/422_intrabc_sb128_strip.obu b/crates/ec-av1/fixtures/422_intrabc_sb128_strip.obu new file mode 100644 index 0000000000000000000000000000000000000000..d8e6180299408bf3938eb7f238e22d6a38d96eaf GIT binary patch literal 1672 zcmZwF{Xf%*0|4-kT`~_x9^#T^d1%S=GS(BO$itVWi*q`RxFO`}JPi#s4^1e{4clT) z$BuPhCL8n6NGR2vwT5In)*Q#RXpY(aa`$?DU%kHn!u$2s12i<<0bq~kZoYD75D)JM z831$ukWhW4u3Pk~YwqZL$J&v5UiscouXCB4bukF8F~526{9-useAy38 zKtY>=6!*A;C8N&woUJzBF$1e6!q{KWFL~-}E-TX!(E&kH(!L{Cs50KTYkEo@=1k>r z)8V+^FV(OBdO4H3*6Nhld3v;m%b57Zlh_^-!~0-IuQ?B^|B*VB3v-jP81}nksamSP zru}u*n!UX>uj$0$p)Uw(x;9Nt!7r^1E=)D|bczFx8Wq0urWmlEUcWy=>*As2!m4l0 z_Jvt4_WC&IY8a&6w@e&Q4&SK1V+$|lV6MaE`U8V&Hl7>DIQI=^WM50nErQ466fxn+ za=lMDpMVSi3jkCIEhJ372i7&%teG{SeWIY>%4-R#wgB~{61a=t|30Ry*33Pa38W?D zy^cyxsR=O*vi4JpfA)jYdN0i~Y4riEp>gvxWC{MwO7m=^Ph%UyW!TKUuS;m-rh|_a zCTn)#wCLEmIVKYui(44Sw{|u|%cmh|ZAlBZ&B!W9_-qBr1EvP)*wnr=sR6~lVd&=C^V+HbHE%A)8!@IL6W{v~nXUAKiM&p>|g=ZQ+FKMqS_XqNYi0 zePB~)@!2UN*J)z&V6i!36S=LIV4WEMEU=+HT>UB-(`=ioK*&{MAh)ei0y;WdrFIDFC3ABWFFaZ3209E7mk zIqH;(v`!ja8Kxdmkih`-FRjK+#$9=8BocQt&7lQ?oBatvdeJNFO_FQ36`9H<829?j z><<{_GW%toF^_MV8GQ=L`WLcJk(MXorIlR_D+=yTDe7oZ<44Kbt8G$46TPZ;t)2!5 zzMbAB7-kK<&Jp&E9+swGh)S+7yr2);22U_=6W-VxM`*Xc^d4~xZyphAxpfnl@re$x zWQ3Z?3;CuRJ7!U@D|<0j7k;jyda4`dO5GqKtTFdG_Yz_n36-$7$=FI0f~sBi&Nj@Mp7o@|7?I}*dI)!|+y zUZ){SW`CMjkDpW?JF!)YU+Nd+#o)_Yg8#Inr*|pX>-mgMzygUrshKBHRjslOD0$L} zjNH?d9ln$aP*uJQvyRJnb31b&QRF$BEPN;V9JP893YER>NXcD{F-q3H?n?C01pUaU*c*Z zF0kA~KYwtcs@Etr4wWs0!%zD*JUhS-ZT?~jc;!z?@{W^xjBSj%qj)_cg)^!BXnt;h z=V#2bY3~3CIAO}Fn41JoQ+Jn?^qbwWEH^z=f<;DY)PF7Y|v z|6y|XA3V&_89k+jWRe1WRdG{%vBmxSo#1^lA4TyxcgSk%c>)0Z9F)4&ifag o_02G{FCjTlK^e;>{<`98oSeHqfTLW9u7pNDS2G#2@ae_>4Wwc=^8f$< literal 0 HcmV?d00001 diff --git a/crates/ec-av1/fixtures/422_intrabc_sb128_strip_notxsearch.obu b/crates/ec-av1/fixtures/422_intrabc_sb128_strip_notxsearch.obu new file mode 100644 index 0000000000000000000000000000000000000000..717bf96f765238bad223962e793e7821cf94af16 GIT binary patch literal 1675 zcmZwF`8(SO0|4-Ev#JQwI?9Sv>S$`NQb8}oRmUrhuFR`-mN{DLnk%9~8%LvPLsCbQ z64ON%Yy?4C8b?cMZB#?5NruK4Z$rvUWWVfvp7-hd{tKVyqX|G%T>xOe$6l^t_bJYn z3(^MY0I)>$kvMJBD{i`=b8V^yA9?0_!93kFde+4tTgbdj|H49Dc4MEUpf?8N_43>mt~^Le;CiX&hF?0eV!q^u zdLWM>C&dl3*i!0zryJ3D*9feX0O$O3e$hiiby<;yh(ZNONQaJJqe^)%oYIoX;pfXw z84kq#ak-KW&`VpnYfW|uE$4U^Qv||JoLqx%66H-S=-BNPlXc=oh@S23ElijFN!w%<*mnqw00g+5JJ2= z*BfHG(CuxX1JO=-Y?|;QDRk4_8QeZ}Q(8~lW)6&ZsZUx%suJDe6pW-_>VAKyH#`w+ zh(&3B=J_0?4VVC+d{{ny>?5!a;jm}dfacM>J~Pinn6eP&LB(?yz`qPrRx1T%FVIRL~^P_Ijk3a2k5awfpNm6e);~|!Vh*5G?AIl48_zc`e zJ{ZzYXz$|thkd*T~Rk4 z-sGz-_r&VXI6|ZKpea|fEys3Udp}5a{^1!>yKrGDyhhNhFy{mKG#M@X3kqo8AFF~Y zqccksdm$BmCKHU(J?gHu$9#R+-L^6wcJ__Gvi@!XPF3%#W0!3FFgPr-r)V0Kjo_Es zN1oj$Axi?wLsWwD(wTtP<<+>cxN9$UMPgRH06jBvr|(99X4DEtMsn&ftEO`Cdfnc$ zhfzb^);_66^zdCH-OnMr{sT#tr(#9C)RIdf1%VyO1*}Hp=}2ia(IO={!IQXW_7XMo z-P9glC$s-;HotS|m?Z6DWKx;VMJ@Oac(nB%{++d6n0nKs*Pu;k!=PBrxr4BbOE?)@ zjZhYOI=&;ujF{ADNMBEoL*2`W6CH3T>Lv+c9{#B106w}7Uk-nt6jN@1SF+0LUm;a2 zhi&D078$+D8l4_kDsH8xOxRiYo|i}-MG?0ibZ26cNytyvZEj9NpKk_zI3CTbI>^03 zxJ5%0&HXg55nA$y#=B=pt*zkQpIAQY}s<%YWe!}SUji9Zpn z)#UrB+pzyFEGuJ<^Ko^qt|2bjc&jjw@Pxl(I2Zt58=3kZ = const { std::cell::Cell::new(0) }; + /// lane-av1-ibc128chunk: chroma transform units the 128-root intrabc + /// strip's mu-chunk walk read, one per `read_inter_plane` chroma call. + /// At 4:2:0 a 64x64 mu chunk's chroma plane block is 32x32, so one + /// TX_32X32 per plane per chunk; at 4:2:2 it is 32x64 and holds TWO + /// STACKED units per plane. The square-cut `chunk_chroma = cside * 64 / + /// side` model walked the 4:2:0 count on every axis, so this counter is + /// the reach/arm witness for the per-axis walk. + static INTRABC_128RECT_CHROMA_CHUNK_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; + /// lane-av1-ibc128chunk: the mu-chunk walk's per-axis chroma extents, as + /// `(64 >> ss_x) << 8 | (64 >> ss_y)` on the LAST chunk -- the pair the + /// per-axis walk used. A 4:2:2 run and a 4:2:0 run of the same block + /// differ here (32|64 vs 32|32), which is what the de-square-cut fixes. + static INTRABC_128RECT_CHUNK_SHAPE: std::cell::Cell = + const { std::cell::Cell::new(0) }; } /// Current value of [`INTRABC_128RECT_HITS`]. @@ -4193,6 +4208,26 @@ pub(crate) fn reset_intrabc_128rect_hits() { INTRABC_128RECT_HITS.with(|c| c.set(0)); } +/// Current value of [`INTRABC_128RECT_CHROMA_CHUNK_HITS`]. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub fn intrabc_128rect_chroma_chunk_hits() -> usize { + INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.get()) +} + +/// Current value of [`INTRABC_128RECT_CHUNK_SHAPE`]. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub fn intrabc_128rect_chunk_shape() -> usize { + INTRABC_128RECT_CHUNK_SHAPE.with(|c| c.get()) +} + +/// Zeroes [`INTRABC_128RECT_CHROMA_CHUNK_HITS`] and +/// [`INTRABC_128RECT_CHUNK_SHAPE`]. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub(crate) fn reset_intrabc_128rect_chroma_chunk_hits() { + INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.set(0)); + INTRABC_128RECT_CHUNK_SHAPE.with(|c| c.set(0)); +} + /// Current value of [`INTRABC_VARTX_HITS`]. pub fn intrabc_vartx_hits() -> usize { INTRABC_VARTX_HITS.with(|c| c.get()) @@ -12460,8 +12495,16 @@ fn decode_intrabc_128rect( ); } let (px, py) = (mi_c * MI, mi_r * MI); - let (cpx, cpy) = (px / 2, py / 2); - let (cw, ch) = (bw / 2, bh / 2); + // lane-av1-ibc128chunk: the block's chroma PLANE BLOCK is per-axis + // `(bw >> ss_x) x (bh >> ss_y)` -- 4:2:0 halves both (this fn's + // `mv_to_q4(cpy, dv_row, ss_y(fctx))` calls two lines below already + // scaled the DV on the y axis by ITS OWN subsampling, so the hardcoded + // `/2` origin and extent made the prediction window half as tall as + // the motion vector asked for), 4:2:2 is HALF-WIDTH and FULL-HEIGHT, + // 4:4:4 is luma-sized. At ss (1,1) every value below is the old + // `bw / 2, bh / 2` line-for-line. + let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); + let (cw, ch) = (bw >> ss_x(fctx), bh >> ss_y(fctx)); // The square strides the proven INTER path lays its residual grids, // prediction windows and `TxParams` at (see [`decode_intrabc_rect`]'s r2 // note): 128/64 here. @@ -12617,12 +12660,35 @@ fn decode_intrabc_128rect( // TX_32X32 chroma unit per plane per chunk at 4:2:0, raster // within the chunk, plane-major inside the chunk. let cu_tx = 32usize; - let chunk_chroma = cside * 64 / side; - let unit_luma = cu_tx * (side / cside); + // lane-av1-ibc128chunk: a 64x64 mu chunk's chroma plane + // block is PER-AXIS `(64 >> ss_x) x (64 >> ss_y)` -- 32x32 at + // 4:2:0, TWO STACKED TX_32X32 at 4:2:2 (the chunk's chroma + // plane block is 32x64 there), four at 4:4:4. The old + // `chunk_chroma = cside * 64 / side` walked a + // `chroma_side`-SQUARE chunk, i.e. the 4:2:0 count on both + // axes: at 4:2:2 it read HALF the chroma units of a chunk + // (one 32x32 at the chunk's top-left instead of two), left + // the chunk's lower 32 chroma rows with no residual at all, + // and stamped every unit's entropy context over a 16x16-mi + // luma span instead of 16x8. The same defect and the same + // per-axis repair as `decode_inter_block`'s + // `chunk_chroma_w/chunk_chroma_h` (lane-av1-422bigblock, + // witnessed on `422_sb128_3f.obu`). + let chunk_chroma_w = (64usize) >> ss_x(fctx); + let chunk_chroma_h = (64usize) >> ss_y(fctx); + // The unit's own footprint on the LUMA mi grid, per axis: + // `(32 << ss) px` = `(32 << ss) / MI` mi -- 16x16 at 4:2:0, + // 16x8 at 4:2:2, 8x8 at 4:4:4. `around_mi_rect` reads and + // `record_mi_chroma` stamp exactly the unit's own cells. + let unit_luma_w = cu_tx << ss_x(fctx); + let unit_luma_h = cu_tx << ss_y(fctx); + INTRABC_128RECT_CHUNK_SHAPE.with(|c| { + c.set((chunk_chroma_w << 8) | chunk_chroma_h); + }); let chunk_w_mi = 16.min(max_w_mi.saturating_sub(cc * 16)); let chunk_h_mi = 16.min(max_h_mi.saturating_sub(cr * 16)); - let units_x = chunk_w_mi / (unit_luma / MI); - let units_y = chunk_h_mi / (unit_luma / MI); + let units_x = chunk_w_mi / (unit_luma_w / MI); + let units_y = chunk_h_mi / (unit_luma_h / MI); if lossless(fctx) { // TX_4X4 chroma units over this chunk (lane-lossless2's // walk, shared with the inter 128 path). @@ -12630,8 +12696,8 @@ fn decode_intrabc_128rect( dec, cdfs, neighbours, u, v, Pred::Inline(&pred_u, cside), Pred::Inline(&pred_v, cside), (mi_r, mi_c), (cpx, cpy), - (cc * chunk_chroma, cr * chunk_chroma), - (chunk_chroma, chunk_chroma), + (cc * chunk_chroma_w, cr * chunk_chroma_h), + (chunk_chroma_w, chunk_chroma_h), (cw, ch), cside, 0, base_q_idx, &mut u_units, &mut v_units, fctx, @@ -12654,15 +12720,16 @@ fn decode_intrabc_128rect( for ur in 0..units_y { for uc in 0..units_x { let unit_mi = ( - mi_r + cr * 16 + ur * (unit_luma / MI), - mi_c + cc * 16 + uc * (unit_luma / MI), + mi_r + cr * 16 + ur * (unit_luma_h / MI), + mi_c + cc * 16 + uc * (unit_luma_w / MI), ); // Per unit, AFTER the earlier units' stamps: this // unit's coefficient context must see them. - let cu_around = neighbours.around_mi(unit_mi, unit_luma); + let cu_around = + neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h); if crate::envflags::env_flag!("EC_ECDUMP") { for p in 1..3 { - let ab: Vec = (0..unit_luma / MI) + let ab: Vec = (0..unit_luma_w / MI) .map(|k| { format!( "{:?}/{}", @@ -12671,7 +12738,7 @@ fn decode_intrabc_128rect( ) }) .collect(); - let lf: Vec = (0..unit_luma / MI) + let lf: Vec = (0..unit_luma_h / MI) .map(|k| { format!( "{:?}/{}", @@ -12687,8 +12754,8 @@ fn decode_intrabc_128rect( } } let (cu_x, cu_y) = ( - cpx + cc * chunk_chroma + uc * cu_tx, - cpy + cr * chunk_chroma + ur * cu_tx, + cpx + cc * chunk_chroma_w + uc * cu_tx, + cpy + cr * chunk_chroma_h + ur * cu_tx, ); // `av1_get_tx_type` (blockd.h:1291): an inter // block's chroma unit never codes a tx_type; it @@ -12709,9 +12776,12 @@ fn decode_intrabc_128rect( && unit_rel_mi.1 < lc + lw / MI }) .map(|(_, _, _, _, t)| t); + // The prediction window is the block's own square + // `cside` buffer with the unit's true per-axis + // position inside it. let cu_pred = src.offset( - (cr * chunk_chroma + ur * cu_tx) * cside - + cc * chunk_chroma + (cr * chunk_chroma_h + ur * cu_tx) * cside + + cc * chunk_chroma_w + uc * cu_tx, ); let cu_grid = read_inter_plane( @@ -12736,8 +12806,8 @@ fn decode_intrabc_128rect( // coefficient context. neighbours.record_mi_chroma( unit_mi, - unit_luma, - unit_luma, + unit_luma_w, + unit_luma_h, plane_idx, &cu_grid, ); @@ -12749,6 +12819,7 @@ fn decode_intrabc_128rect( ); } hit!(CHROMA_SPLIT_TX_HITS); + INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.set(c.get() + 1)); // lane-av1-ibcrect: per-unit chroma context -- the // end-of-block record's composed-grid re-stamp // must not stand (replayed below). @@ -12758,9 +12829,9 @@ fn decode_intrabc_128rect( cside * cside, ); for rr in 0..cu_tx { - let start = (cr * chunk_chroma + ur * cu_tx + rr) + let start = (cr * chunk_chroma_h + ur * cu_tx + rr) * cside - + cc * chunk_chroma + + cc * chunk_chroma_w + uc * cu_tx; dst[start..start + cu_tx] .copy_from_slice(&cu_grid[rr * cu_tx..][..cu_tx]); @@ -12815,27 +12886,37 @@ fn decode_intrabc_128rect( let cu = if lossless(fctx) { 4usize } else { 32usize }; // The unit's own footprint on the LUMA mi grid (the chroma context // bands are luma-mi indexed, [`Self::record_mi_chroma`]'s - // convention): 8 px x2 per TX_4X4 unit, 64 px per TX_32X32 one. - let unit_luma = cu * 2; - // Raster over the block's chroma plane, `chunk_chroma` per mu chunk - // (the same extents the read loop above laid the composed grid out - // at) -- a unit the frame edge clipped codes nothing and carries no - // composed samples beyond the clip, so it replays as the zero state - // exactly like libaom's uncoded unit. - let chunk_chroma = cside * 64 / side; - let (rows, cols) = ((ch / chunk_chroma).max(1), (cw / chunk_chroma).max(1)); + // convention), PER AXIS: `cu << ss` px, i.e. 8 px per TX_4X4 unit and + // 64 px per TX_32X32 one at 4:2:0 -- 4 px / 32 px at 4:2:2. + let unit_luma_w = cu << ss_x(fctx); + let unit_luma_h = cu << ss_y(fctx); + // Raster over the block's chroma plane, one mu chunk per axis step at + // its own per-axis chroma extent (the same extents the read loop + // above laid the composed grid out at) -- a unit the frame edge + // clipped codes nothing and carries no composed samples beyond the + // clip, so it replays as the zero state exactly like libaom's + // uncoded unit. lane-av1-ibc128chunk: the old `chunk_chroma = cside * + // 64 / side` cut the replay's step to the 4:2:0 square on BOTH axes, + // so at 4:2:2 it walked a 32-row step down a 64-row chunk and + // re-stamped a 16x16-mi span over an 8-row-tall unit. + let chunk_chroma_w = (64usize) >> ss_x(fctx); + let chunk_chroma_h = (64usize) >> ss_y(fctx); + let (rows, cols) = ((ch / chunk_chroma_h).max(1), (cw / chunk_chroma_w).max(1)); for cr in 0..rows { for cc in 0..cols { - let unit_mi = (mi_r + cr * (unit_luma / MI), mi_c + cc * (unit_luma / MI)); + let unit_mi = ( + mi_r + cr * (unit_luma_h / MI), + mi_c + cc * (unit_luma_w / MI), + ); for (plane_idx, grid) in [(1usize, &u_grid), (2usize, &v_grid)] { let mut unit = Vec::with_capacity(cu * cu); for rr in 0..cu { - let start = - (cr * chunk_chroma + rr) * cside + cc * chunk_chroma; + let start = (cr * chunk_chroma_h + rr) * cside + + cc * chunk_chroma_w; unit.extend_from_slice(&grid[start..start + cu]); } neighbours.record_mi_chroma( - unit_mi, unit_luma, unit_luma, plane_idx, &unit, + unit_mi, unit_luma_w, unit_luma_h, plane_idx, &unit, ); } } diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 2f9d5462..f20fad17 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -217,6 +217,22 @@ pub fn intrabc_128rect_hits() -> usize { crate::decode::intrabc_128rect_hits() } +/// lane-av1-ibc128chunk: chroma transform units the 128-root intrabc strip's +/// mu-chunk walk read, one per `read_inter_plane` chroma call. At 4:2:2 a +/// 64x64 mu chunk's chroma plane block is 32x64 and holds TWO STACKED +/// TX_32X32 units per plane; the square-cut walk this gate witnesses read +/// one. Measured on the pinned witness: 8 before, 48 after. +pub fn intrabc_128rect_chroma_chunk_hits() -> usize { + crate::decode::intrabc_128rect_chroma_chunk_hits() +} + +/// lane-av1-ibc128chunk: the 128-root intrabc strip's per-axis chroma chunk +/// extents as `(64 >> ss_x) << 8 | (64 >> ss_y)` on the last chunk walked -- +/// 32|32 at 4:2:0, 32|64 at 4:2:2, 64|64 at 4:4:4. +pub fn intrabc_128rect_chunk_shape() -> usize { + crate::decode::intrabc_128rect_chunk_shape() +} + /// Blocks reconstructed with intra block copy at an 8x8 LEAF specifically /// (lane-kf900 r7's shape); [`crate::decode::intrabc_hits`] counts every shape. pub fn leaf8_intrabc_hits() -> usize { @@ -2282,6 +2298,169 @@ pub(crate) mod tests { } } + /// lane-av1-ibc128chunk: the WITNESS for the 128-root intrabc strip's + /// de-square-cut mu-chunk chroma walk, and the byte pin for it. + /// + /// `decode_intrabc_128rect` cut each mu chunk's chroma plane block with + /// `chunk_chroma = cside * 64 / side` -- a `chroma_side`-SQUARE chunk, + /// i.e. the 4:2:0 count on BOTH axes (the same defect lane-av1-422bigblock + /// fixed, and witnessed, in `decode_inter_block` and + /// `decode_block_128rect`; this copy was deferred there as unwitnessed). + /// At 4:2:2 a 64x64 mu chunk's chroma plane block is 32x64, so it holds + /// TWO STACKED TX_32X32 units per plane: the square-cut walk read one per + /// plane per chunk, left the chunk's lower 32 chroma rows with no + /// residual at all, and stamped each unit's entropy context over a + /// 16x16-mi luma span instead of 16x8. + /// + /// Measured red-before on the pinned witness (parent `a7d22aec`, via the + /// local `EC_AV1_ALLOW_422_PROBE` patch-run-restore build): 8 chroma + /// units stamped over the stream's two reached blocks and frames 0 and 3 + /// diverge from `aomdec` (45135 / 44540 of 245760 samples each), the + /// first difference at Y sample 98368 -- frame 0, row 256, col 64, the + /// top-left corner of the first 128x64 intrabc block at mi(64,0). The + /// red build then lost 4 of the stream's 6 intrabc blocks to the desync. + /// Green-after, same fixture: 48 chroma units stamped, all 6 blocks + /// decoded, and ALL FIVE frames byte-identical to `aomdec --rawvideo`. + /// + /// Committed code refuses 4:2:2 at the sequence header, so the decode + /// assertions above are probe-measured and reproducible from the lane + /// report's recipe; what this gate can assert in committed code is the + /// byte pin, the refusal-by-name contract, and -- in the arm below -- + /// that the per-axis walk is still spelled per-axis in the source. + #[test] + fn the_pinned_422_intrabc_sb128_strip_witnesses_refuse_by_name() { + const NAME: &str = "the_pinned_422_intrabc_sb128_strip_witnesses_refuse_by_name"; + const REFUSAL: &str = "a chroma format of 4:2:2"; + for (file, bytes, fp) in [ + ("422_intrabc_sb128_strip.obu", 1672usize, 0x50f5cfc576e4cd00_u64), + ( + "422_intrabc_sb128_strip_notxsearch.obu", + 1675, + 0xd4936f252ff8cff0, + ), + ] { + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("fixtures") + .join(file); + let data = std::fs::read(&path).unwrap_or_else(|e| { + panic!( + "{NAME}: pinned witness {} is missing ({e}) -- the gate cannot run", + path.display() + ) + }); + assert_eq!(data.len(), bytes, "{NAME}: {file} size drifted"); + assert_eq!(fnv1a64(&data), fp, "{NAME}: {file} bytes drifted"); + let err = decode_stream(&data).unwrap_err().to_string(); + assert!( + err.contains(REFUSAL), + "{NAME}: {file} must refuse by name, got: {err}" + ); + } + } + + /// lane-av1-ibc128chunk: the SOURCE-SCAN arm of the witness gate above. + /// + /// The decode-level half of the red/green evidence cannot run in + /// committed code (the 4:2:2 refusal stands), so this arm pins the thing + /// that would silently bring the defect back: the square-cut + /// `chunk_chroma = cside * 64 / side` expression, and the per-axis + /// replacements that replaced it at BOTH sites in + /// [`decode_intrabc_128rect`] -- the mu-chunk read walk and the + /// `mu_chroma` per-unit context replay. It also pins the per-axis + /// counters' accessors so the arms stay reachable, and the walk's own + /// per-axis extent, derived here from the same `64 >> ss` form the + /// witnesses measured (4:2:0 = one TX_32X32 per plane per chunk, + /// 4:2:2 = two stacked, 4:4:4 = four). + #[test] + fn the_intrabc_128rect_chroma_chunk_walk_stays_per_axis() { + const NAME: &str = "the_intrabc_128rect_chroma_chunk_walk_stays_per_axis"; + let src = include_str!("decode.rs"); + let body = src + .split_once("fn decode_intrabc_128rect(") + .expect("decode_intrabc_128rect must exist") + .1 + .split_once("\nfn ") + .expect("decode_intrabc_128rect must be a top-level fn") + .0; + // Scan CODE only: the fix's own comments quote the old expression to + // say what it was, and a prose mention must not read as a + // reintroduction (nor mask one). + let stripped: Vec<&str> = body + .lines() + .map(|l| l.split_once("//").map_or(l, |(c, _)| c)) + .collect(); + let code = stripped.join("\n"); + let body = code.as_str(); + assert_eq!( + body.matches("cside * 64 / side").count(), + 0, + "{NAME}: the square-cut `cside * 64 / side` chunk extent is BACK in \ + decode_intrabc_128rect -- that expression is the 4:2:2 defect this \ + gate exists for (a 64x64 mu chunk's chroma plane block is \ + (64 >> ss_x) x (64 >> ss_y), not `chroma_side` square)" + ); + // Both sites, the read walk and the replay: each declares the pair + // once and each takes its steps on the per-axis halves. + for name in [ + "let chunk_chroma_w = (64usize) >> ss_x(fctx);", + "let chunk_chroma_h = (64usize) >> ss_y(fctx);", + ] { + assert_eq!( + body.matches(name).count(), + 2, + "{NAME}: `{name}` must appear at BOTH de-square-cut sites in \ + decode_intrabc_128rect (the mu-chunk read walk and the mu_chroma \ + context replay), found {}", + body.matches(name).count() + ); + } + for name in [ + "let unit_luma_w = cu_tx << ss_x(fctx);", + "let unit_luma_h = cu_tx << ss_y(fctx);", + "let (cw, ch) = (bw >> ss_x(fctx), bh >> ss_y(fctx));", + "let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));", + "neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h)", + ] { + assert_eq!( + body.matches(name).count(), + 1, + "{NAME}: `{name}` must appear exactly once in \ + decode_intrabc_128rect, found {}", + body.matches(name).count() + ); + } + // The replay's own unit luma span is the lossless/lossy `cu << ss` form + // (site 2 spells it separately from the read walk's `cu_tx << ss`). + for name in [ + "let unit_luma_w = cu << ss_x(fctx);", + "let unit_luma_h = cu << ss_y(fctx);", + ] { + assert_eq!( + body.matches(name).count(), + 1, + "{NAME}: `{name}` must appear exactly once in \ + decode_intrabc_128rect, found {}", + body.matches(name).count() + ); + } + // The per-axis chunk extent the geometry demands, spelled out here so + // the scan and the witnesses cannot disagree about it. + let per_axis_units = |ss_x: u32, ss_y: u32| (64 >> ss_x) / 32 * (64 >> ss_y) / 32; + assert_eq!(per_axis_units(1, 1), 1, "{NAME}: 4:2:0 must stay one unit"); + assert_eq!(per_axis_units(1, 0), 2, "{NAME}: 4:2:2 must be two units"); + assert_eq!(per_axis_units(0, 0), 4, "{NAME}: 4:4:4 must be four units"); + // The counters the probe arms read must stay exported. + for name in [ + "pub fn intrabc_128rect_chroma_chunk_hits()", + "pub fn intrabc_128rect_chunk_shape()", + ] { + assert!( + src.contains(name), + "{NAME}: the accessor `{name}` must stay in decode.rs" + ); + } + } + /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the /// old gate `a_frame_using_quantisation_matrices_is_refused_by_name` is diff --git a/lanes/av1ibc128chunk.report.md b/lanes/av1ibc128chunk.report.md new file mode 100644 index 00000000..422692b3 --- /dev/null +++ b/lanes/av1ibc128chunk.report.md @@ -0,0 +1,251 @@ +# lane-av1-ibc128chunk — the 128-root intrabc strip's square-cut mu-chunk chroma walk, de-square-cut and WITNESSED + +Branch `lane-av1-ibc128chunk`, parent `a7d22aec`. Target dir +`$HOME/.cache/cargo-target-av1ibc128chunk` throughout. No push. + +## Verdict + +The deferred copy is fixed **and witnessed** — this is not a defensive fix. +`decode_intrabc_128rect` cut each mu chunk's chroma plane block with +`chunk_chroma = cside * 64 / side` (two sites, decode.rs:12663 and decode.rs:12896 +at the parent), the same square-cut defect lane-av1-422bigblock fixed and +witnessed in `decode_inter_block` and `decode_block_128rect`. Red before: a real +4:2:2 `aomenc --enable-intrabc` sb128 stream loses half of every mu chunk's +chroma units and its frames 0 and 3 diverge from `aomdec`, first difference at +the top-left corner of the very first 128x64 intrabc block. Green after: the +same stream decodes all five frames byte-identical to `aomdec --rawvideo`, and +the red build's 4 lost blocks are recovered. + +Both pinned witnesses are committed; committed code still refuses 4:2:2 at the +sequence header and the `EC_AV1_ALLOW_422_PROBE` bypass was applied and +reverted per probe run (`git diff` on the refusal line is empty; the only +`EC_AV1_ALLOW_422_PROBE` strings left in the tree are two doc-comment mentions +of the recipe). + +## The defect (both sites) + +`decode_intrabc_128rect` is the intrabc arm of `decode_block_128rect`: a +128x64 / 64x128 / 128x128 strip coded with `use_intrabc`, predicted from this +frame's own reconstruction, reconstructed through the INTER residual walk +(`decode_token_recon_block`'s else arm). + +A 64x64 mu chunk's chroma plane block is **per-axis** `(64 >> ss_x) x +(64 >> ss_y)`: 32x32 at 4:2:0 (one TX_32X32 per plane per chunk), **32x64 at +4:2:2 (TWO STACKED TX_32X32 per plane per chunk)**, 64x64 at 4:4:4 (four). +`av1_get_max_uv_txsize` caps the unit at 32 on each axis. The square-cut model +walked a `chroma_side`-square chunk, i.e. the 4:2:0 count on both axes. + +Measured consequences at 4:2:2 (witness below): + +1. **Half the units.** One chroma unit per plane per chunk instead of two + stacked — the chunk's lower 32 chroma rows got no residual at all. +2. **Wrong extent, twice.** The block's own chroma plane block was still + `bw / 2 x bh / 2` (`cpx, cpy = px / 2, py / 2`), i.e. 4:2:0-shaped, even + though the same function's two `mv_to_q4(cpy, dv_row, ss_y(fctx))` calls + already scaled the DV on the y axis by **its own** subsampling — the + prediction window was half as tall as the motion vector asked for. +3. **Wrong entropy spans.** `around_mi` / `record_mi_chroma` stamped every unit + over a `unit_luma = cu_tx * (side / cside)` = 16x16-mi luma square instead + of the per-axis 16x8 at 4:2:2, and the `mu_chroma` per-unit replay walked a + 32-row step down a 64-row chunk. +4. **Entropy lock lost.** The halved unit count desynced the tile: the red build + decoded 2 of the stream's 6 intrabc blocks; the fixed build decodes all 6. + +## The fix (mirror of the two witnessed twins) + +Both sites, per-axis, in the same expression shape +`decode_inter_block` already carries: + +| old | new | +|---|---| +| `let (cpx, cpy) = (px / 2, py / 2);` | `(px >> ss_x(fctx), py >> ss_y(fctx))` | +| `let (cw, ch) = (bw / 2, bh / 2);` | `(bw >> ss_x(fctx), bh >> ss_y(fctx))` | +| `let chunk_chroma = cside * 64 / side;` | `chunk_chroma_w = (64usize) >> ss_x(fctx)` / `chunk_chroma_h = (64usize) >> ss_y(fctx)` | +| `let unit_luma = cu_tx * (side / cside);` | `unit_luma_w = cu_tx << ss_x(fctx)` / `unit_luma_h = cu_tx << ss_y(fctx)` | +| `units_x/y = chunk_*_mi / (unit_luma / MI)` | same, on `unit_luma_w` / `unit_luma_h` | +| `around_mi(unit_mi, unit_luma)` | `around_mi_rect(unit_mi, unit_luma_w, unit_luma_h)` | +| `record_mi_chroma(unit_mi, unit_luma, unit_luma, ..)` | `.. unit_luma_w, unit_luma_h, ..` | +| `cu_x = cpx + cc * chunk_chroma + uc * cu_tx` | `.. cc * chunk_chroma_w + ..` | +| `cu_y = cpy + cr * chunk_chroma + ur * cu_tx` | `.. cr * chunk_chroma_h + ..` | +| `cu_pred` / composed-grid `dst` offsets | per-axis offsets at the square `cside` stride | +| `read_inter_chroma_lossless(.., (cc*cc_, cr*cc_), (cc_, cc_), ..)` | per-axis org and region | +| replay `unit_luma = cu * 2` | `unit_luma_w = cu << ss_x(fctx)` / `unit_luma_h = cu << ss_y(fctx)` | +| replay `ch / chunk_chroma`, `cw / chunk_chroma` | `ch / chunk_chroma_h`, `cw / chunk_chroma_w` | +| `EC_IBC128_BANDS` trace spans | per-axis | + +New counters (both exported from `stream` and printed by `decode_probe`): +`INTRABC_128RECT_CHROMA_CHUNK_HITS` (one bump per chroma `read_inter_plane` of +this walk) and `INTRABC_128RECT_CHUNK_SHAPE` +(`(64 >> ss_x) << 8 | (64 >> ss_y)` of the last chunk walked). + +## Fixtures (pinned, `git add -f`; `fixtures/` is gitignored) + +| fixture | bytes | sha256 | fnv1a64 | +|---|---|---|---| +| `422_intrabc_sb128_strip.obu` | 1672 | `f92000db86df7acc577d60dd1d0d97454bff4705799ea59d9de34eb5a71dbbcd` | `0x50f5cfc576e4cd00` | +| `422_intrabc_sb128_strip_notxsearch.obu` | 1675 | `80dd0d4e93fd6c3d4b7188a43e69d9638f2bece38edfab60ff3582628314b5ec` | `0xd4936f252ff8cff0` | + +Source (the deterministic `geq` sinusoid the tree's own sb128 intrabc-rect gate +uses, re-cut at `yuv422p` — the 4:2:2 twin of that gate's arm 1): + + ffmpeg -v error -f lavfi -i "nullsrc=size=384x320:rate=25,format=yuv420p,\ + geq=lum='128+90*sin((X+2*N)/37)+30*sin(Y/29)':\ + cb='128+30*sin(X/23)':cr='128+30*sin((Y+N)/19)'" \ + -pix_fmt yuv422p -strict -1 -t 0.2 -f yuv4mpegpipe -y geq/384x320.y4m + + ~/.cache/aom-oracle/build/aomenc --codec=av1 --i422 --profile=2 --passes=1 \ + --end-usage=q --cq-level=32 --cpu-used=0 --threads=1 --row-mt=0 \ + --lag-in-frames=0 --kf-max-dist=1 --limit=5 --tile-columns=0 --sb-size=128 \ + --min-partition-size=64 --enable-rect-partitions=1 --enable-ab-partitions=0 \ + --enable-1to4-partitions=0 --enable-palette=0 --tune-content=screen \ + --enable-intrabc=1 --deltaq-mode=0 --enable-tx-size-search=1 \ + --obu -o geq/384x320_cq32_ts1.obu geq/384x320.y4m + +`_notxsearch` is the same command with `--enable-tx-size-search=0`. Both are +pinned and both are red-before / green-after (the tx-size-search arm is not +required — a mis-signed flag on a witness is a coin flip, so both went in). + +## Red before / green after (measured) + +`aomdec` is `~/.cache/aom-oracle/build/aomdec`; ours is `decode_probe` (debug, +`--features gate-counters`) on the `EC_AV1_ALLOW_422_PROBE` patch-run-restore +build, compared with `cmp` on the full raw output. + +| fixture | build | 128-root blocks | chroma units stamped | vs `aomdec` | +|---|---|---|---|---| +| `422_intrabc_sb128_strip.obu` | parent `a7d22aec` | **2** | **8** | **DIFF** | +| `422_intrabc_sb128_strip.obu` | this lane | **6** | **48** | **EXACT** (5/5 frames) | +| `422_intrabc_sb128_strip_notxsearch.obu` | parent `a7d22aec` | **2** | **8** | **DIFF** | +| `422_intrabc_sb128_strip_notxsearch.obu` | this lane | **6** | **48** | **EXACT** | + +Frame-level detail on the primary witness (245760 samples/frame: 384x320 Y + +2 x 192x320 chroma): + +- **red**, frame 0: 45135 samples differ, first at byte 98368 = Y **row 256, + col 64** — the top-left of the first 128x64 intrabc block (traced at + `mi_row=64 mi_col=0`, `py = 64*4 = 256`). Frame 3 the same shape (44540 + samples, same first offset). Frames 1, 2, 4 exact (no intrabc block). +- **fixed**: `cmp` identical on all 245760 x 5 bytes; 5 frames decoded, 0 hidden. + +The red build reached only 2 of the 6 blocks: reading 4 chroma units where +libaom codes 8 desynced the tile, and the remaining 4 blocks were misparsed. +Recovering them is the green signal, not just the pixel count. + +`EC_ECDUMP` per-unit stamps on the primary witness, red vs fixed, same entropy +position (`rng=49296` at the first block in both): + + red 4 stamps (1 per plane per chunk, 2 chunks) + fixed 8 stamps (2 per plane per chunk, 2 chunks) + +## Reproduce (patch-run-restore, local only) + + python3 - <<'EOF' + p='crates/ec-av1/src/stream.rs'; s=open(p).read() + s=s.replace(" if seq.subsampling_x != seq.subsampling_y {", + " if seq.subsampling_x != seq.subsampling_y && !crate::envflags::env_flag!(\"EC_AV1_ALLOW_422_PROBE\") {",1) + open(p,'w').write(s) + EOF + CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1ibc128chunk \ + cargo build -p ec-av1 --example decode_probe --features gate-counters + EC_AV1_ALLOW_422_PROBE=1 EC_ECDUMP=1 \ + $HOME/.cache/cargo-target-av1ibc128chunk/debug/examples/decode_probe \ + crates/ec-av1/fixtures/422_intrabc_sb128_strip.obu 2>&1 | grep -c EC_IBC128_STAMP + -> 48 (parent: 8) + EC_AV1_ALLOW_422_PROBE=1 EC_PROBE_OUT=/tmp/ours.raw \ + $HOME/.cache/cargo-target-av1ibc128chunk/debug/examples/decode_probe \ + crates/ec-av1/fixtures/422_intrabc_sb128_strip.obu + ~/.cache/aom-oracle/build/aomdec --rawvideo -o /tmp/oracle.raw \ + crates/ec-av1/fixtures/422_intrabc_sb128_strip.obu + cmp /tmp/ours.raw /tmp/oracle.raw # identical + git checkout -- crates/ec-av1/src/stream.rs + +## Gates + +- `the_pinned_422_intrabc_sb128_strip_witnesses_refuse_by_name` (stream.rs) — + both fixtures' byte pins (`len` + `fnv1a64`) and the unconditional + refusal-by-name contract. The decode-level assertions above cannot run in + committed code (the 4:2:2 refusal stands), so they are probe-measured and + reproducible from the recipe; this is the same split + `the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name` uses. +- `the_intrabc_128rect_chroma_chunk_walk_stays_per_axis` (stream.rs) — the + source-scan arm. Scans `decode_intrabc_128rect`'s body **with comments + stripped** (the fix's own comments quote the old expression to say what it + was) and pins: zero `cside * 64 / side`; the `chunk_chroma_w/h` pair at + **both** de-square-cut sites (read walk and `mu_chroma` replay); the + `unit_luma_w/h`, `cw/ch`, `cpx/cpy` and `around_mi_rect` forms once each; the + replay's own `cu << ss` pair; the per-axis unit arithmetic + (`(64>>ss_x)/32 * (64>>ss_y)/32` = 1 / 2 / 4 at 4:2:0 / 4:2:2 / 4:4:4); and + both new counter accessors. **Non-vacuity measured**: re-introducing + `let chunk_chroma_w = cside * 64 / side;` at the read-walk site makes it fail + with `left: 1, right: 0`; restored, it passes. + +## Byte-identity outside 4:2:2 + +- `an_sb128_rect_strip_with_intrabc_decodes_pixel_exact` — **green**, and it + is the right gate: same deterministic `geq` recipe as the witness, at + `yuv420p` / `yuv420p10le`, all three arms decode-order pixel-exact vs the + oracle with `intrabc_128rect_hits=+14 / +1 / +15` (30 blocks through the + changed walk, `skip=false`, real residual reads). At ss (1,1) every new + expression reduces to the old constant: `64 >> 1 = 32`, `32 << 1 = 64`, + `bw >> 1 = bw / 2`, 16x16-mi spans. +- `an_sb128_screen_stream_with_intrabc_decodes_pixel_exact` — green (8 arms, + 4-6 intrabc blocks each). +- `a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact` — green. +- `a_lossless_sb128_rect_intra_block_decodes_sample_exact` — green. +- `a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal` + and `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` — green. +- `the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name` — green + (the twin lane's fixtures are untouched). +- Scoped battery: `intrabc` filter 19 passed / 0 failed / 1 ignored; + `422` + `444` filters 12 passed / 0 failed. `cargo check -p ec-av1 + --all-targets`: 0 warnings. + +**DISCLOSED 4:4:4 behavior change.** At ss (0,0) the walk now codes FOUR +TX_32X32 units per mu chunk per plane (1x1 -> 2x2) where the parent coded one, +and the block's chroma plane block is now luma-sized (`bw x bh`) instead of +`bw/2 x bh/2`. This is the same disclosure lane-av1-422bigblock made for +`decode_block_128rect`: the parent's walk was **provably wrong** at ss (0,0) — +`cside = (side/2).max(...)` is the 4:2:0 half-side, so the old 32x32 chunk +covered a quarter of a 64x64 4:4:4 chroma chunk and the origin `px/2` was off by +half a superblock. Unlike that lane, this one also changes the *block* shape at +4:4:4 (`cw/ch`, `cpx/cpy`), so the ticket's "spans are equal at (0,0)" +premise does not hold for this function, whose extents were 4:2:0-hardcoded +throughout. Measured unreachability: **no committed 4:4:4 fixture engages +`decode_intrabc_128rect` at all** (`ibc128=0` on all six 4:4:4 fixtures +including `444_sb128rect_lr_witness.obu` and `ll444_ibc_rect.obu`), so no +green gate covers or contradicts the change; it is landed on the same geometry +argument that the two reviewed twins landed on, and the 4:4:4 route needs its +own witness (`aomenc --i444 --profile=1 --sb-size=128 --enable-rect-partitions=1 +--enable-intrabc=1` over content that makes aomenc take a 128-root PARTITION_NONE +or HORZ/VERT strip — no committed 4:4:4 fixture does). + +## Hunt recipe sweep (what was tried before the hit) + +`--profile=2 --sb-size=128 --enable-intrabc=1` at 4:2:2, all with +`--i422`, `--tune-content=screen`, `--enable-palette=0`, `--passes=1`, +`--lag-in-frames=0`, `--kf-max-dist=1`, `--min-partition-size=8`, +`--max-partition-size=128`, `--enable-rect-partitions=1`, +`--enable-1to4-partitions=1`: + +- **lavfi `testsrc2 / smptebars / mandelbrot / life / rgbtestsrc / + smptehdbars`, 128x128 and 256x256/384x256/512x256/128x128, `cpu-used` 0/2/3/4, + `cq-level` 15-60, 2x2/3x2/4x4 `tile=`** (24 encodes + 24 x 2 x 8 = ~400 + encodes): 9 streams reached `decode_intrabc_128rect`; **all 9 reached it with + a frame that was ALREADY desynced** before the block. The blocker is + pre-existing and unrelated: at 4:2:2 a chroma tx unit goes non-square + (TX_16X8 etc.) and the merged tree does not read the `tx_type` the oracle + codes for it — first divergence on `c_testsrc2_cq40.obu` at coefficient unit + **4** (plane 1, `mi_row=0 mi_col=0`, `tx_size=5` = TX_16X8: the oracle emits + `tx_type` after `all_zero` where ours goes straight to `eob`, rng 55680 / + 34568 identical up to that point). **Named for its owning lane, not chased + here.** +- **the tree's own gate recipe re-cut at `yuv422p`** (the `geq` sinusoid + sources, 384x320 cq32 and 512x512 cq45, `enable-tx-size-search` 0/1): the + smooth-chroma `geq` content avoids the non-square-chroma-tx defect, and both + cq32 arms are the red/green witnesses above. cq20/45/55 code no 128-root + intrabc block at all (`ibc128=0`), so the hit is a cq32 window, not a + content accident. + +Control that clean 4:2:2 witnesses do exist on this tree (so the "already +desynced" arms above were a content choice, not a tree-wide wall): +`422_sb128_3f.obu` decodes byte-exact vs `aomdec` here.