Commits
2026-09-12
ec-vp8 M3: inter frames byte-exact vs ffmpeg on ALL fixturesAhmet Kaan Gümüş · 80115ee
ec-vp8 M3: inter frames byte-exact vs ffmpeg on ALL fixtures
Four bugs fixed this pass:
- inter-frame B_PRED subblock modes used the keyframe context table
(KF_BMODE_PROB[a][l]); libvpx decodemv.c:467 reads fc.bmode_prob —
the FLAT vp8_bmode_prob {120,90,79,133,87,85,80,111,151}, no context
- MC interpolation filter is per-frame from the tag version bits
(vp8_setup_version): version 0 = six-tap for BOTH planes; chroma was
hardcoded bilinear. Version 3 fullpixel_mask (~7) added to the chroma
MV derivation
- SPLITMV chroma: quadrants are 4x4 CHROMA pixels at 4-px offsets; the
old loop predicted 8x8 at 8-px offsets, so the residual add read the
top-left quadrant's prediction for all four quadrants (whole-MB modes
masked the bug; every SPLITMV MB got wrong chroma)
- key frame with refresh_entropy==0 now reverts to DEFAULTS (libvpx
inits fc before lfc=fc), not the pre-keyframe context
keyframe_exact now witnesses full streams: gop/clip-obs/altref added as
interframe_streams_match_ffmpeg; suite 55 lib + 4 header_parse + 4
keyframe_exact green, zero rustc warnings. Model fixed to match libvpx
(inter ymode/uv defaults 112/86/140/37 + 162/101/204, flat inter bmode)ec-vp8 M3: long MV components read bits 9,8,7,6,5,4 (mvlong_width=10) — bit 9 was missingAhmet Kaan Gümüş · d5796e3
ec-vp8 M3: long MV components read bits 9,8,7,6,5,4 (mvlong_width=10) — bit 9 was missing RFC 6386 §17.1 and libvpx read SIX long-form bits (9 down to 4) before the sometimes-implicit bit 3; the port read only five (8..4), so every large motion vector decoded as garbage while short MVs and ZEROMV stayed correct. gop-160x96 frame 1: 51% -> 95.3% pixel match; frames 0-3 of gop and clip-obs now byte-exact vs ffmpeg. Remaining divergence from frame 4 onward is the next M3 target.
ec-vp8 M3: model hasy2 clobber fixed — mode records + early token phase now agree read-for-read; divergence narrowed to MB(0,8) block-15/16 context threadingAhmet Kaan Gümüş · 9fba4f9Browse files
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 MBsAhmet Kaan Gümüş · 71acae1
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 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).
ec-vp8 M3 debugging: inter census localization — model extended to inter frames, divergence pinned to MB(2,7) census countAhmet Kaan Gümüş · 1c98b09
ec-vp8 M3 debugging: inter census localization — model extended to inter frames, divergence pinned to MB(2,7) census count vp8ref_model.py now parses inter frames (refresh header, prob_intra/ last/gf, ymode/uv/MV updates, per-MB inter mode records with the census, SPLITMV, per-row tokens) with B/G/CNT/SP/IMB traces mirroring the Rust decoder's. Two model bugs fixed on the way (inter partition-0 offset is byte 3 not 10; clamp_mv2 wrote the clamped row into the column slot). Rust gained CNT (census result) and SP (SPLITMV subset) traces plus STAGE markers in the header parse. Result: model and Rust B streams agree read-for-read through frame 1's mode records up to MB(2,7), where the census diverges: model cnt=[0,2,2,3] vs rust cnt=[0,3,2,3] with IDENTICAL neighbour states (above=r1c7 NEAREST mv (-138,-100), left=r2c6 SPLITMV bmi15 (-134,-76), aboveleft=r1c6 mv (-138,-100) — rows 0-1 parse identically on both sides). The above-left +1 lands in cnt[NEAREST] (rust) vs cnt[NEAR] (model) — one of the two census implementations mishandles the above-left same-as-previous comparison; libvpx decodemv.c:307-361 is the arbiter to re-read next session. Pixel state: gop frame 1 at 51% vs ffmpeg before this divergence was understood.
ec-vp8: fix M2 token walk — ONE path missed sign/EOB; frame-0 byte-exact on all kf fixturesAhmet Kaan Gümüş · dd7b5a6
ec-vp8: fix M2 token walk — ONE path missed sign/EOB; frame-0 byte-exact on all kf fixtures get_coeffs' ONE-token path (p[2] branch) had the sign read, coefficient write, and EOB-after-nonzero check nested inside the magnitude branch only. The reference walk (libvpx detokenize.c GetCoeffs / RFC 6386 section 13.2) shares that tail between the ONE and magnitude paths. A ONE token therefore skipped the sign read and EOB check and re-entered the walk at the ZERO node — read counts stayed in lockstep (so stream positions matched) while the decoded stream diverged from the first ONE token, which is why the lossless single-MB fixture passed and busy fixtures split ~28 reads into block 0. Evidence: - EC_VP8_TRACE G-lines (n, band, ctx, prob, bit) vs scripts/vp8ref_model.py on kf-160x96-q20.ivf: 19131 decisions, 0 diffs (model also fixed: persistent per-partition decoders, G tracing with consulted prob + decoded bit). - examples/dump_frame frame 0 vs 'ffmpeg -frames:v 1': byte-exact on all 7 kf fixtures + mparts-160x96 kf0. - cargo test -p ec-vp8: unit 49 + header_parse 4 + webp green; keyframe_exact 1/3 (the 2 red cases decode every frame of each fixture and complete when M3 inter frames land).