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;