forge
Explore
Log in

Don't you dare go Hollow

lane-av1422warp: clamp the OBMC pair-merge snap so it cannot land below the block

Browse files at this commit

2375b81ae41184ef9cb6ce5602519ba9c583bad4Ahmet Kaan GümüşParent: 650ffb2
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.rsmodified+11 -2
@@ -31471,7 +31471,10 @@ fn overlappable_above(
31471 // The pair merge: the walk snaps back to the pair's even column31471 // The pair merge: the walk snaps back to the pair's even column
31472 // and the ODD half (the chroma-carrying one) is the neighbour for31472 // and the ODD half (the chroma-carrying one) is the neighbour for
31473 // both -- a 4-wide 1:4 strip is never an OBMC source on its own.31473 // both -- a 4-wide 1:4 strip is never an OBMC source on its own.
31474- col &= !1;31474+ // lane-av1422warp r25: as in `overlappable_left`, snapping down
31475+ // lands on `mi_col - 1` at an ODD `mi_col` and the offsets below
31476+ // underflow (debug-build panic; `usize::MAX` in release). Clamp.
31477+ col = (col & !1).max(mi_col);
31475 src = col + 1;31478 src = col + 1;
31476 nb = grid.get(mi_row - 1, src);31479 nb = grid.get(mi_row - 1, src);
31477 step = 2;31480 step = 2;
@@ -31524,7 +31527,13 @@ fn overlappable_left(
31524 // The pair merge, left-column mirror: a 4-TALL neighbour (a 16x431527 // The pair merge, left-column mirror: a 4-TALL neighbour (a 16x4
31525 // strip) is half of a chroma pair and the pair's SECOND row is the31528 // strip) is half of a chroma pair and the pair's SECOND row is the
31526 // neighbour for both.31529 // neighbour for both.
31527- row &= !1;31530+ // lane-av1422warp r25: `row &= !1` rounds DOWN, so at an ODD
31531+ // `mi_row` it lands on `mi_row - 1` and the `row - mi_row`
31532+ // offsets below underflow -- `usize::MAX` in release, and a
31533+ // debug-build panic ("attempt to subtract with overflow",
31534+ // `overlappable_left` called from `decode_inter_block`) with
31535+ // EC_TRACE_MODE_STEP set. Clamp: the offset can never be negative.
31536+ row = (row & !1).max(mi_row);
31528 src = row + 1;31537 src = row + 1;
31529 nb = grid.get(src, mi_col - 1);31538 nb = grid.get(src, mi_col - 1);
31530 step = 2;31539 step = 2;