From 2375b81ae41184ef9cb6ce5602519ba9c583bad4 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 13:00:16 +0300 Subject: [PATCH] lane-av1422warp: clamp the OBMC pair-merge snap so it cannot land below the block Both OBMC neighbour walks snap back to the chroma pair's even row/column (`row &= !1` / `col &= !1`) so the ODD half is the neighbour for both strips. That snap rounds DOWN, so at an ODD `mi_row` / `mi_col` it lands on `mi_row - 1` / `mi_col - 1` and the `row - mi_row` / `col - mi_col` offsets pushed into the neighbour list UNDERFLOW: `usize::MAX` in release, and a debug-build panic ("attempt to subtract with overflow", `overlappable_left` / `overlappable_above` called from `decode_inter_block`). Witness: a1.obu decodes clean, but with EC_TRACE_MODE_STEP=1 it panics at decode.rs:31540 and then 31491 -- reproducibly, single- AND multi-threaded. I could not explain why the flag is needed to reach the path, and am recording that as unexplained rather than inventing a reason. Both snaps are now clamped with `.max(mi_row)` / `.max(mi_col)`: the offset can never be negative, and where it was already non-negative the arithmetic is unchanged. NOT the frame-3 divergence: the 16-frame EC_SYMR sequence diff is unchanged, first divergence still seq=107517 at mi(64,56). So this fix removes a real defect the stream does not exercise in a normal decode; it does not move the boundary. Identity re-proved after the edit: 4:2:0 control byte-exact, 4:4:4 witness byte-identical to the pre-lane build, both pinned 422 witnesses pixel-exact. --- crates/ec-av1/src/decode.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index d005ebc6..6c18da55 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -31471,7 +31471,10 @@ fn overlappable_above( // The pair merge: the walk snaps back to the pair's even column // and the ODD half (the chroma-carrying one) is the neighbour for // both -- a 4-wide 1:4 strip is never an OBMC source on its own. - col &= !1; + // lane-av1422warp r25: as in `overlappable_left`, snapping down + // lands on `mi_col - 1` at an ODD `mi_col` and the offsets below + // underflow (debug-build panic; `usize::MAX` in release). Clamp. + col = (col & !1).max(mi_col); src = col + 1; nb = grid.get(mi_row - 1, src); step = 2; @@ -31524,7 +31527,13 @@ fn overlappable_left( // The pair merge, left-column mirror: a 4-TALL neighbour (a 16x4 // strip) is half of a chroma pair and the pair's SECOND row is the // neighbour for both. - row &= !1; + // lane-av1422warp r25: `row &= !1` rounds DOWN, so at an ODD + // `mi_row` it lands on `mi_row - 1` and the `row - mi_row` + // offsets below underflow -- `usize::MAX` in release, and a + // debug-build panic ("attempt to subtract with overflow", + // `overlappable_left` called from `decode_inter_block`) with + // EC_TRACE_MODE_STEP set. Clamp: the offset can never be negative. + row = (row & !1).max(mi_row); src = row + 1; nb = grid.get(src, mi_col - 1); step = 2;