forge
Explore
Log in

Don't you dare go Hollow

ec-vp8 M3: census merge fix — above-left third-candidate merge is ALIVE in libvpx, mode records now agree read-for-read for all 60 MBs

Browse files at this commit

71acae1e958707d6837a91a76d93dd919a4dec8eAhmet Kaan GümüşParent: deb802d
The predecessor's 'dead in libvpx too' note about the cnt[CNT_SPLITMV]
merge was a misread: when the above-left pushes a THIRD distinct
candidate, cntx reaches slot 3 and its count lands in
cnt[CNT_SPLITMV], so decodemv.c:366's merge check sees it non-zero and
absorbs the candidate into NEAREST when it equals the nearest. Rust's
find_near_mvs already implemented this correctly (the ported guard is
live); the model lacked the merge entirely. Model fixed (plus a
closure-scope idx/ix bug it exposed) — CNT and SP streams now zero-diff
across all 60 MBs of gop frame 1, and the B streams agree through the
entire mode-record phase (first divergence moved into frame 1's token
phase at MB(0,1)'s Y2, prob 131 vs 202 — next suspect: the frame-0
refresh_entropy revert path feeding frame 1's coef prob tables).
crates/ec-vp8/src/modes.rsmodified+5 -3
@@ -462,9 +462,11 @@ pub fn find_near_mvs(
462462 }
463463 }
464464
465- // libvpx checks `cnt[CNT_SPLITMV]` BEFORE computing it (the write
466- // happens later in the same branch), so the above-left merge is
467- // effectively dead there; ported as-is with the same dead guard.
465+ // Above-left merge (libvpx decodemv.c:366): when the above-left
466+ // pushed a THIRD distinct candidate, its count landed in
467+ // cnt[CNT_SPLITMV] (cntx reached slot 3), and if that candidate
468+ // equals the nearest candidate, NEAREST absorbs it. The split count
469+ // is then overwritten with the SPLITMV-neighbour census below.
468470 if cnt[CNT_SPLITMV] != 0 && mvs[idx] == mvs[CNT_NEAREST] {
469471 cnt[CNT_NEAREST] += 1;
470472 }
scripts/vp8ref_model.pymodified+7 -1
@@ -342,6 +342,12 @@ def main():
342342 cnt[cx] += wgt
343343 else:
344344 cnt[0] += wgt
345+ # libvpx decodemv.c:366 — when the above-left pushed a THIRD
346+ # distinct candidate it counted into cnt[CNT_SPLITMV] (cntx
347+ # reached slot 3), and if that candidate equals the nearest,
348+ # NEAREST absorbs it. Alive, not dead.
349+ if cnt[3] != 0 and mvs[ix] == mvs[1]:
350+ cnt[1] += 1
345351 cnt[3] = (above["split"] * 2) + (left["split"] * 2) + aboveleft["split"]
346352 if cnt[2] > cnt[1]:
347353 cnt[1], cnt[2] = cnt[2], cnt[1]
@@ -525,7 +531,7 @@ def main():
525531 import traceback; traceback.print_exc()
526532 print(f"EXC at r={r} c={c}: {e}")
527533 raise SystemExit(1)
528- mvref_print = 4 if mbsplit[r][c] else {-1: 3, -2: 1, -3: 2, -4: 3}.get(
534+ mvref_print = 4 if mbsplit[r][c] else {-1: 0, -2: 1, -3: 2, -4: 3}.get(
529535 mbmode[r][c], 0
530536 )
531537 print(