From 75017f18331c5087edecb2a89dee3f3593b1c7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 30 Aug 2026 08:57:33 +0300 Subject: [PATCH] fix(av1): gm_get_motion_vector block-centre -1 offset; root-cause seed-43 wedge mismatch to missing global-warp prediction path (not fixed) Root-caused lane-gm r2's interintra-wedge gate mismatch (seed 43, frame 1 luma) via a pinned/self-decoded-twice reproduction and a msac range-ladder comparison against a patched aomdec: entropy is in sync at the divergent block (rng=38664 both sides), and this decoder's gm_get_motion_vector computes the spec-correct mv once block_center_x/y's missing "- 1" is fixed (found by diffing against the real oracle's mv.h). The remaining gap is real but unfixed this round: libaom predicts every is_global_mv_block (ROTZOOM/AFFINE GLOBALMV, >=8x8) with the full per-pixel affine global-motion warp (reconinter.c's allow_warp / global_warp_allowed), independent of motion_mode; this decoder only builds a warp prediction for local WARPED_CAUSAL and falls back to translational MC for every other GLOBALMV block. Whole-frame global_motion != IDENTITY refusal in stream.rs stays in place. --- crates/ec-av1/src/stream.rs | 20 ++++++++++++++++++++ crates/ec-av1/src/warp.rs | 9 +++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 145e2553..4d96fd86 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -215,6 +215,26 @@ pub fn decode_stream(data: &[u8]) -> Result> { // is not yet provably correct end to end; keeping the refusal // until that seed is captured (EC_AV1_GATE_DUMP), self-pinned, and // root-caused rather than shipping a wrong decode. + // + // lane-gm r3 ROOT CAUSE (pinned, range-ladder-confirmed, still not + // fixed): the mismatch is NOT an mv/mvstack/entropy bug -- msac + // RANGE at the first divergent block (mi=(8,0), frame 1) matches + // aomdec's own `EC_PART` trace bit-for-bit (rng=38664 both sides), + // and this decoder's own `gm_get_motion_vector` for that block + // (ROTZOOM, seed 43's own header) computes the spec-correct + // mv=(-8,8) (hand-verified against mv.h's `block_center_x`/`_y`, + // which found and fixed a real `- 1` omission in `warp.rs` -- + // harmless for THIS block's rounding but a genuine spec bug fixed + // regardless). The actual gap: `reconinter.c`'s `allow_warp` has a + // `global_warp_allowed` branch (`warp_types.global_warp_allowed = + // is_global_mv_block(...)`, `reconinter_enc.c:281`) that predicts + // an `is_global_mv_block` block (ROTZOOM/AFFINE GLOBALMV, >=8x8) + // with the FULL per-pixel affine global-motion warp, independent + // of `motion_mode` -- this decoder only ever builds a warp + // prediction for local `WARPED_CAUSAL` motion mode and falls back + // to plain translational MC with the block-centre mv for every + // other GLOBALMV block, which is only a centre-point approximation + // of the true per-pixel warp. That is the entire remaining gap. if header.frame_type != FrameType::Key && header.global_motion[..7] .iter() diff --git a/crates/ec-av1/src/warp.rs b/crates/ec-av1/src/warp.rs index f434ec9f..db33c9cd 100644 --- a/crates/ec-av1/src/warp.rs +++ b/crates/ec-av1/src/warp.rs @@ -104,8 +104,13 @@ pub fn gm_get_motion_vector( params[1] >> GM_TRANS_ONLY_PREC_DIFF, ), WarpModel::Rotzoom | WarpModel::Affine => { - let x = (mi_col * MI_SIZE as usize + (bw4 * MI_SIZE as usize) / 2) as i64; - let y = (mi_row * MI_SIZE as usize + (bh4 * MI_SIZE as usize) / 2) as i64; + // `block_center_x`/`block_center_y` (mv.h:183-191): `- 1`, not + // just the halved block size -- lane-gm r3's root cause, missing + // here made every ROTZOOM/AFFINE GLOBALMV prediction off by a + // sub-pel fraction (small luma delta growing across P-frames as + // it propagates through the reference chain). + let x = (mi_col * MI_SIZE as usize + (bw4 * MI_SIZE as usize) / 2) as i64 - 1; + let y = (mi_row * MI_SIZE as usize + (bh4 * MI_SIZE as usize) / 2) as i64 - 1; let xc = (params[2] as i64 - (1i64 << WARPEDMODEL_PREC_BITS)) * x + params[3] as i64 * y + params[0] as i64;