From cb5d22b0bd04fbc52d91e027cc18168c47c8bc6b 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 11:26:09 +0300 Subject: [PATCH] lane-av1422warp: a 4:2:2 rect leaf's chroma dc-sign vote must sample chroma cells decode_leaf_rect's around_mi_rect call was the one 4:2:2 chroma gather in the file still ungated: at ss (1,0) a 16x8/8x16 luma leaf's chroma is a SQUARE (side/2, side) block, so `side` chroma 4-px cells above it spread over `side` LUMA mi columns, one chroma column per PAIR of luma mi cells, and both cells of a pair carry the covering unit's whole-unit dc sign. The per-mi rect gather therefore double-counts every chroma column's sign. around_mi_422_chroma's every-second above-cell sampling IS libaom's txb_w_unit sum, and every sibling gather in this file already routes through it under `ss_x == 1 && ss_y == 0`; this one did not, so a 4:2:2 rect leaf voted over luma unit counts. Measured on the pinned 4:2:2 rotzoom stream (a1.obu frame 0, cut to a1_f0.obu). The 16x8 leaf at mi(48,28) resolved its V plane's dc sign from vote 0 -- dc_sign_cdf[0] -- where the oracle resolves a negative vote, dc_sign_cdf[1]: before EC_DCDUMP mi=(48,28) plane=2 wh=(16,8) vote=0 above=[None/6,None/6,Some(false)/7,Some(false)/7] FOUR cells after EC_DCDUMP422 mi=(48,28) plane=2 wh=(16,8) vote=-1 above=[None/6,Some(false)/7] TWO cells Red/green. The bit offset between the two decoders is a clean constant through coefficient unit 1418 and turned 6 bits at 1419; after this fix unit 1418 pairs and the first divergence moves to unit 2427. Frame 0 coefficient units: 1959 wrong-shaped before, 2680 after (oracle 2512). Whole stream, 16 frames vs aomdec --rawvideo: 1619115 -> 1380482 differing samples. Still 0/16 frames exact -- see the hand-off below. Identity, measured four ways, all unchanged: - 4:2:0 control a420.obu byte-identical to aomdec --rawvideo. The gate is ss (1,0), so the sampler is not reached at 4:2:0 or 4:4:4; `chroma_422` is already computed in this arm for the scan selection. - 4:4:4 444_sb128rect_lr_witness.obu byte-identical to the pre-lane build. - pinned 422_allskip_2f.obu (2 frames) and 422_sb128_3f.obu (3 frames) still pixel-exact against aomdec. - the decodetxb/aomdec EC_DCSIGN and EC_COEFF_STEP bitpos rungs used to pin this are all reverted; aomdec is rebuilt to its committed shape. Hand-off: the new first divergence is at coefficient unit 2427 / TU 2428, mi(64,24), where the oracle codes a 32x32 luma TU and we code 8x8 leaves. That is a different CLASS from this fix -- block/partition structure, not a neighbour vote -- so it is reported rather than chased. --- crates/ec-av1/src/decode.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 9fad6be0..2d63ed33 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -13701,7 +13701,28 @@ fn decode_leaf_rect( } else { TxbSet::ChromaRect8x4 }; - let around = neighbours.around_mi_rect(leaf_mi, bw, bh); + // lane-av1422warp: at ss (1,0) this leaf's chroma is a SQUARE + // (side/2, side) block, so `side` chroma 4-px cells above it spread + // over `side` LUMA mi columns -- one chroma column per PAIR of luma + // mi cells, and both carry the covering unit's whole-unit dc sign. + // The per-mi rect gather therefore double-counts every chroma + // column's sign. `around_mi_422_chroma`'s every-second above-cell + // sampling is libaom's `txb_w_unit` sum, and every other 4:2:2 chroma + // gather in this file already routes through it (see the gate at this + // arm's siblings); this one did not, so a 4:2:2 rect leaf voted over + // luma unit counts. Measured on the pinned 4:2:2 rotzoom stream + // (a1.obu frame 0): the 16x8 leaf at mi(48,28) resolved its V plane's + // dc sign from vote 0 (`dc_sign_cdf[0]`) where the oracle resolves a + // negative vote (`dc_sign_cdf[1]`), which is the first bit-position + // divergence in the frame (the bit offset is a clean constant through + // coefficient unit 1418 and turns 6 bits at 1419). Luma keeps the + // per-mi gather; 4:2:0 and 4:4:4 keep the plain rect walk verbatim. + let mut around = neighbours.around_mi_rect(leaf_mi, bw, bh); + if chroma_422 { + let c = neighbours.around_mi_422_chroma(leaf_mi, bw, bh); + around[1] = c[1]; + around[2] = c[2]; + } let luma_set = if reduced_tx_set { TxbSet::LumaRect16x8 } else {