From 287d79c7d0fe62b925f080b123d895bad7c02344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 30 Sep 2026 01:10:14 +0300 Subject: [PATCH] 4:4:4 witness pin + ss-derived chroma extent at the 128-root intra-BC strip Pins crates/ec-av1/fixtures/r512.obu (6948 B, blob bff992e9, taken from lane-chromahalvings-r3 -- the only one of the three chromahalvings refs that carries it) and replaces `decode_intrabc_owned_rect`'s hardcoded `(bw / 2, bh / 2)` chroma extent and its eight `px / 2, py / 2` chroma MV origin pairs with the ss-derived `>> ss_x` / `>> ss_y` forms. libaom: `av1_get_max_uv_txsize` (blockd.h:1372) is `max_txsize_rect_lookup[get_plane_block_size(bsize, ss_x, ss_y)]` through `av1_get_adjusted_tx_size`, and `get_plane_block_size` is `ss_size_lookup[bsize]` -- at ss (0,0) the chroma plane block IS the luma footprint. At 4:2:0 the two forms are the same arithmetic. RED-BEFORE, measured on the UNPATCHED line in this worktree, per-plane sample counts against the instrumented aomdec (`EC_AV1_FINAL_DUMP`): f0 Y 166229 wrong from 65728 | U 155383 from 32848 | V 153498 from 32848 f1 Y 0 (byte-exact) | U 74708 from 49282 | V 73501 from 49280 f2 Y 0 (byte-exact) | U 9216 from 114880 | V 8192 from 229760 Luma byte-exact on f1 and f2 while chroma is wrong is the signature that makes this a chroma-plane sizing defect and not a block-geometry one. New counter IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS: the 128-root intra-BC strips whose chroma plane block was sized at ss (0,0). At 4:2:0 the corrected and halving forms are identical, so >= 1 cannot be satisfied by a 4:2:0 stream; the arm is exclusive to this function. Gate `a_444_intrabc_owned_rect_strip_refuses_the_missing_rect_chroma_ coefficient_set` asserts -- deliberately -- that the witness is now REFUSED with the exact string "a rectangular inter chroma transform unit whose shape has no coefficient table set here". That is the state this commit lands in: the extent is libaom-correct, and a 4:4:4 32x64 luma block's chroma plane block is 32x64, which this crate has no `TxbSet` for. The gate exists so the day that arm lands the gate goes RED and the assertion has to become the pixel-exactness check. Reach proof for the site, on the whole witness with EC_HALVSWEEP=1: 5 strips (mi 32x64 skip=false at mi(32,40); 32x64 skip=true at mi(48,64); 16x64 skip=true at mi(64,108); 32x64 skip=true at mi(112,96) and mi(112,104)). --- crates/ec-av1/fixtures/r512.obu | Bin 0 -> 6948 bytes crates/ec-av1/src/decode.rs | 106 +++++++++++++++++--------------- crates/ec-av1/src/stream.rs | 69 +++++++++++++++++++++ 3 files changed, 125 insertions(+), 50 deletions(-) create mode 100644 crates/ec-av1/fixtures/r512.obu diff --git a/crates/ec-av1/fixtures/r512.obu b/crates/ec-av1/fixtures/r512.obu new file mode 100644 index 0000000000000000000000000000000000000000..bff992e98d01fed6ec73ed35ddd73f9fa482d19f GIT binary patch literal 6948 zcmV+<8{6a(0165q000a}|Nj5{!7}?06ac0`0Qt{;b12~vj$=Ys&UI-}3BrKXzpP=0 zbS-d~yJz7UG;H`hC@0)jC=}YCtSAJ96YzoUe$#rbx*M{?dIPY8%Ij` z3Yr&{*=tzrKfh#laCZZdUL$vd&FwIbWqeAkZFVTo#ob`L*(!!xgN!VTmI5^F>c;`Q zpTY>@-X)a8+TmFIyXV@I5-kSIk+67n=l(v5NcQk%mC+lJG9r^og*OJq5acTezz8m0lbMfe<|V25nowe)XZrKI+vor z?iKW~Wc70zLjV^~0L2L=!KS1|IpMgw{T_-+*XpN=K|Uq|8@A|4y$Gq8Bjay%?;^}% zcZ90hV}a_c%IqjN-PLVn-;ruTkbNJPT?(@ZX1%&s!v&i6WMVcJvOMC>mXe$s7A2c* z0}^=M!k=WPP5N|A^>y+7WsM`}{w|FE#>k!71+*dJ{6RSaT?d#HOPJN6x;qG!*c9M&S$>7YpR2_VEl`0^!X8Vl)R`!1m*4oZ zC6Ap`2ARB(8u1}GtwYaZjNgzqe;kpqOATH{IeL;Z$$4VLiw2hg1N|5Sn;1t)i2_+n z5FlM*V1B`j!+JP|l`h;pyJy5_AaS(Ps#lH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1k6^0~xAt?EzY2_Q}| zQR}lB(z;uP;G6zUp7{wE;avYte-mtd@hr7QkN0M)x9y)TZDDtSrqTf~L5LG^+OEX%XiFp7`Us z?P2!7VX=t?=lxXQ5zcEofEs4zK!H%k^3H^IW76ebQz5eB{udfWC}1rFWV(AJWQnfb zXCAn{9RqH))Shb*x6VS;;pfCdn!}wiRzd)&!N6~wu{$jH-Aus7_X!4dz%f3TKU=(Ex!i$s~w!VkqpCP z!=?JMk2m{ew{rm7T8nxk4V>QzTCHkle4ldw7K}XelM?V8qMgvD9p?Z`dPQj=o7^d3 ziECw}(7AG0r?Q83&iB9;?3y4(oP2eWm!Y6THY4=P&FQ)A=Sk@RBIHxG*MNH}mw%Lg zt@_b2QaIJTSk&dkqO=Dra>tEV*QEMB(&b{X8{ffNZJf%Su2DY7?BO>Wlbrh&bb$%i zjI|UgPtzl7fZ7Qv>s@RXc z`=9dsZa!B-7?4#*FPV1|;c?dDG<0}u`p)OYY~;rJ!OxDAP8319i>Q&XEO>w3!3!i^ z2R*xIkyS9#Xcnl~%3odtrk>2P-ij_F>CA=?q%KTf)-OFrZnGuy!(FqMPt^u>e!52< zIZD%kicT7O+wj4VAlpVjS0y3Z{;AXw+#kqA%`go)g4( zX0LK&(lIZV{>u@+g6$k|(OMZ6*wJK1agHX2M?qw!{nKSOjEA~@7zZeF=ddO-V+WgH q$r{ZasoXJb_Q!ORc;iEOIk#{4w8$ZwCcK6L2dX3;dOly#2k*jC&U#D$ literal 0 HcmV?d00001 diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 19c3dbb5..0ddb1234 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -4708,6 +4708,16 @@ thread_local! { /// be satisfied by any older route. static INTRABC_RECT_LOSSLESS_CHROMA4_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; + /// lane-av1chromarect: 128-root intra-BC HORZ/VERT strips + /// ([`decode_intrabc_owned_rect`]) whose chroma plane block was sized + /// `bw >> ss_x` by `bh >> ss_y` -- the 4:4:4 and 4:4:0 cells, where + /// `av1_get_max_uv_txsize` (`ss_size_lookup[bsize]`, blockd.h:1372) applies + /// no halving of its own. At 4:2:0 the two forms are the same arithmetic, + /// so a `>= 1` witness can only come from a stream that is not 4:2:0. + /// EXCLUSIVE to this arm: no other caller sizes a 128-root intra-BC + /// strip's chroma plane block. + static IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; } /// lane-av1-intrabc r4: coded (`skip == 0`) rect intrabc blocks reconstructed, @@ -4751,6 +4761,18 @@ pub(crate) fn reset_ibc_rect_chroma_footprint_444_hits() { IBC_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.set(0)); } +/// lane-av1chromarect: [`IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS`]. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub fn ibc_owned_rect_chroma_footprint_444_hits() -> usize { + IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.get()) +} + +/// lane-av1chromarect: zeroes [`IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS`]. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub(crate) fn reset_ibc_owned_rect_chroma_footprint_444_hits() { + IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.set(0)); +} + /// lane-whtshape: [`INTRABC_RECT_LOSSLESS_CHROMA4_HITS`]. #[allow(dead_code)] // read only from the `#[cfg(test)]` gates pub fn intrabc_rect_lossless_chroma4_hits() -> usize { @@ -16838,25 +16860,31 @@ fn decode_intrabc_owned_rect( ) -> Result<()> { let _ = base_q_idx; let (px, py) = (mi_c * MI, mi_r * MI); - // lane-av1chromahalvings r5: libaom-WRONG at 4:4:4 -- `av1_get_max_uv_txsize` - // is `ss_size_lookup[bsize]` and `get_vartx_max_txsize` (blockd.h:1447) reads - // that plane block as `max_txsize_rect_lookup[plane_bsize]`, so chroma extent - // == luma extent at ss (0,0) -- and the chroma MV origins below are the - // prediction half of the same defect. MEASURED on the 4:4:4 LOSSY witness - // fixtures/r512.obu, chroma-only, luma byte-exact on both inter frames. - // BLOCKED, not missing: with the ss-derived extent the decode REFUSES -- - // "a rectangular inter chroma transform unit whose shape has no coefficient - // table set here" -- because a 4:4:4 32x64 chroma plane block needs a - // `TxbSet` this crate lacks. The fix is a new coefficient set, not a swap. - // Left as the halving deliberately: turning a decoding stream into a - // refusal is a behaviour change with its own decision. See - // lanes/av1chromahalvings.report.md r5. + // lane-av1chromarect: libaom does NOT halve a 128-root intra-BC strip's + // chroma plane block. `av1_get_max_uv_txsize` (blockd.h:1372) is + // `max_txsize_rect_lookup[get_plane_block_size(bsize, ss_x, ss_y)]` run + // through `av1_get_adjusted_tx_size`, and `get_plane_block_size` is + // `ss_size_lookup[bsize]` -- at 4:4:4 the chroma plane block is the block's + // OWN footprint, so the extent below and the eight chroma MV origin pairs + // that follow must be `>> ss_x` / `>> ss_y`, not `/ 2`. At 4:2:0 + // (`ss_x == ss_y == 1`) the two forms are the same arithmetic. + // MEASURED on the 4:4:4 LOSSY witness `fixtures/r512.obu` (6948 B, 3 + // frames, 5 strips through this function): with the halving, frame 0 + // diverges from the aomdec oracle in 166229 Y / 155383 U / 153498 V + // samples and both later frames keep luma byte-exact while 74708 U + + // 73501 V (f1) and 9216 U + 8192 V (f2) are wrong -- chroma-only, which is + // what makes this a chroma-sizing defect and not a block-geometry one. + // Re-measured by this lane; see lanes/av1chromarect.report.md. if crate::envflags::env_flag!("EC_HALVSWEEP") { eprintln!("EC_HALV ibc_owned mi=({mi_r},{mi_c}) bw={bw} bh={bh} skip={skip}"); } - let (cw, ch) = (bw / 2, bh / 2); + let (cw, ch) = (bw >> ss_x(fctx), bh >> ss_y(fctx)); + let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); let side = bw.max(bh); let cside = cw.max(ch); + if ss_x(fctx) == 0 && ss_y(fctx) == 0 { + hit!(IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS); + } let saved_reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get); let saved_tx = fctx.tx_select_inter.with(std::cell::Cell::get); fctx.reduced_tx_set_inter.with(|c| c.set(reduced_tx_set)); @@ -16871,30 +16899,8 @@ fn decode_intrabc_owned_rect( flush_recon(fctx, y, u, v); let pred_y = predict_intrabc_window(y, px, py, bw, bh, dv_col, dv_row, true, side, fctx); - let pred_u = predict_intrabc_window( - u, - px / 2, - py / 2, - cw, - ch, - dv_col, - dv_row, - false, - cside, - fctx, - ); - let pred_v = predict_intrabc_window( - v, - px / 2, - py / 2, - cw, - ch, - dv_col, - dv_row, - false, - cside, - fctx, - ); + let pred_u = predict_intrabc_window(u, cpx, cpy, cw, ch, dv_col, dv_row, false, cside, fctx); + let pred_v = predict_intrabc_window(v, cpx, cpy, cw, ch, dv_col, dv_row, false, cside, fctx); let mi_cols = 2 * y.true_width.div_ceil(8); let mi_rows = 2 * y.true_height.div_ceil(8); @@ -16928,8 +16934,8 @@ fn decode_intrabc_owned_rect( ); push_mc_rect( 1, - px / 2, - py / 2, + cpx, + cpy, cside, cw, ch, @@ -16939,8 +16945,8 @@ fn decode_intrabc_owned_rect( ); push_mc_rect( 2, - px / 2, - py / 2, + cpx, + cpy, cside, cw, ch, @@ -17044,8 +17050,8 @@ fn decode_intrabc_owned_rect( around[1], 0, u, - px / 2, - py / 2, + cpx, + cpy, Pred::Inline(&pred_u, cside), Some(luma_tx_type), None, @@ -17061,8 +17067,8 @@ fn decode_intrabc_owned_rect( around[2], 0, v, - px / 2, - py / 2, + cpx, + cpy, Pred::Inline(&pred_v, cside), Some(luma_tx_type), None, @@ -17101,8 +17107,8 @@ fn decode_intrabc_owned_rect( around[1], 0, u, - px / 2, - py / 2, + cpx, + cpy, Pred::Inline(&pred_u, cside), Some(luma_tx_type), None, @@ -17118,8 +17124,8 @@ fn decode_intrabc_owned_rect( around[2], 0, v, - px / 2, - py / 2, + cpx, + cpy, Pred::Inline(&pred_v, cside), Some(luma_tx_type), None, diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 3b8bfeea..e11e7b27 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -140,6 +140,23 @@ pub fn reset_ibc444rect_hits() { crate::decode::reset_ibc444rect_hits() } +/// lane-av1chromarect: 128-root intra-BC HORZ/VERT strips whose chroma plane +/// block was sized `bw >> ss_x` by `bh >> ss_y` rather than the hardcoded +/// 4:2:0 halving -- i.e. the 4:4:4 (and 4:4:0) cells, where +/// `av1_get_max_uv_txsize` (`ss_size_lookup[bsize]`, blockd.h:1372) applies no +/// halving of its own. At 4:2:0 the two forms are the same arithmetic, so a +/// `>= 1` witness can only come from a stream that is not 4:2:0. EXCLUSIVE to +/// `decode_intrabc_owned_rect`: no other caller sizes a 128-root intra-BC +/// strip's chroma plane block. +pub fn ibc_owned_rect_chroma_footprint_444_hits() -> usize { + crate::decode::ibc_owned_rect_chroma_footprint_444_hits() +} + +/// Gate-side reset for the lane-av1chromarect counter above. +pub fn reset_ibc_owned_rect_chroma_footprint_444_hits() { + crate::decode::reset_ibc_owned_rect_chroma_footprint_444_hits() +} + /// `(y, uv)` palette blocks RECONSTRUCTED inside an inter frame (lane-t900 /// r22) -- the counter a screen-content witness gate reads to prove it /// exercises the inter-frame palette path, not the key frame's. @@ -48449,4 +48466,56 @@ pub(crate) mod tests { (lanes/ibc444c.report.md r2), NOT an assertion" ); } + + /// lane-av1chromarect: the 128-root intra-BC HORZ/VERT strip's chroma + /// plane block, on the 4:4:4 LOSSY witness that reaches + /// `decode_intrabc_owned_rect`. + /// + /// The extent is the ss-derived one (`bw >> ss_x` by `bh >> ss_y`, + /// `av1_get_max_uv_txsize` = `ss_size_lookup[bsize]`, blockd.h:1372), and + /// the witness is pinned at the size that shape forces -- a 4:4:4 32x64 + /// luma block's chroma plane block is 32x64. **This gate asserts the + /// refusal, on purpose.** It exists so the day the missing arm lands the + /// gate goes RED and the assertion has to be rewritten as the + /// pixel-exactness check -- a witness with no gate is a pin, and a pin + /// with no governing refusal is a defect nobody is looking at. + #[test] + fn a_444_intrabc_owned_rect_strip_refuses_the_missing_rect_chroma_coefficient_set() { + const NAME: &str = + "a_444_intrabc_owned_rect_strip_refuses_the_missing_rect_chroma_coefficient_set"; + const FILE: &str = "r512.obu"; + const LEN: usize = 6948; + let path = + std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("fixtures/{FILE}")); + let stream = std::fs::read(&path) + .unwrap_or_else(|e| panic!("{NAME}: pinned fixture {FILE} missing: {e}")); + assert_eq!(stream.len(), LEN, "{NAME}: {FILE} length moved"); + assert_444_header(&stream, NAME, 8); + + let _guard = lock_gate_counters(); + reset_ibc_owned_rect_chroma_footprint_444_hits(); + let err = decode_stream(&stream).err().unwrap_or_else(|| { + panic!( + "{NAME}: the witness DECODED -- the extent is not the ss-derived one any \ + more, so this gate is no longer measuring what it names" + ) + }); + let msg = err.to_string(); + assert!( + msg.contains( + "a rectangular inter chroma transform unit whose shape has no coefficient table \ + set here" + ), + "{NAME}: expected the missing-rect-chroma-set refusal, got: {msg}" + ); + let hits = ibc_owned_rect_chroma_footprint_444_hits(); + // Exactly 1, not 5: the decode stops AT the first 4:4:4 strip, so this + // counts the strips that reached the corrected extent before the + // refusal ended the stream. The pixel-exactness gate that replaces + // this one sees all five. + assert_eq!( + hits, 1, + "{NAME}: {hits} 128-root intra-BC strip(s) sized at 4:4:4 before the refusal, not 1" + ); + } }