From 569067b9ca4fbebf27b8f39e2a6d04e0262d7341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 28 Aug 2026 21:18:19 +0300 Subject: [PATCH] fix(av1): clamp every mvstack entry, not just the derived nearest/near pair libaom av1_find_mv_refs clamps each stack entry after the build; the NEWMV predictor is the DRL-selected ENTRY, so a left neighbour coded past the frame edge (col 520 in pinned warp-flake-5.obu) predicted unclamped where libaom used 384 -- an mv drift with IDENTICAL entropy (same diff symbols, range ladder exact at every partition read) surfacing as +-1 warp rounding crumbs in a hidden altref, inherited by shown frames (V-plane assert). Both builders (single + compound). All three warp pins green. class: value-equal narrowing drift (neighbour-votes-all-its-fields family); localization = part-read range ladder exact -> prediction-side, then EC_MV pred diff vs patched aomdec. --- crates/ec-av1/src/mvstack.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/ec-av1/src/mvstack.rs b/crates/ec-av1/src/mvstack.rs index fafc4d0f..d61d2315 100644 --- a/crates/ec-av1/src/mvstack.rs +++ b/crates/ec-av1/src/mvstack.rs @@ -932,6 +932,14 @@ pub fn find_mv_stack_with_sign_bias( } let clamp = |mv| clamp_mv_ref(mv, mi_row, mi_col, bw4, bh4, mi_cols, mi_rows); + // libaom `av1_find_mv_refs` clamps EVERY stack entry once the stack is + // built -- the NEWMV predictor is the DRL-selected entry itself, so a + // raw out-of-range candidate (left neighbour coding past the frame + // edge) must not survive here (pinned warp-flake-5.obu: pred col 520 + // vs libaom's clamped 384, a value-equal-entropy mv drift). + for e in candidates.iter_mut() { + e.mv = clamp(e.mv); + } let nearest_mv = candidates.first().map_or((0, 0), |e| clamp(e.mv)); let near_mv = candidates.get(1).map_or((0, 0), |e| clamp(e.mv)); let pred_mv = if candidates.is_empty() { @@ -1606,6 +1614,12 @@ pub fn find_mv_stack_compound( } let clamp = |mv| clamp_mv_ref(mv, mi_row, mi_col, bw4, bh4, mi_cols, mi_rows); + // Same as the single-ref builder: libaom clamps every stack entry, and + // DRL reads the entries directly. + for e in candidates.iter_mut() { + e.mv0 = clamp(e.mv0); + e.mv1 = clamp(e.mv1); + } let nearest_mv = candidates .first() .map_or(((0, 0), (0, 0)), |e| (clamp(e.mv0), clamp(e.mv1)));