forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 00c1b3ff2d80d84fef71bb6208110dedbbd95fc4Filtered to crates/ec-av1/src/motion_field.rsClear filter

2026-09-02

fix(av1): the saved motion field kept only the LAST tile's columns -- av1_copy_frame_mvs read the mi grid through the per-tile reach clampAhmet Kaan Gümüş · ba5351f
fix(av1): the saved motion field kept only the LAST tile's columns -- av1_copy_frame_mvs read the mi grid through the per-tile reach clamp

`build_motion_field` (this crate's `av1_copy_frame_mvs`) walks the whole
frame's mi grid AFTER the tile loop has finished, when `MiGrid`'s tile
window is still narrowed to the last tile. `MiGrid::get` returns `None`
outside that window, so every tile but the last saved no motion vectors at
all: on the pinned 192x68 2-tile-column stream the saved field held only
mi_col 32..47, and the next frame's temporal (MFMV) candidates over the
whole left two thirds silently vanished from the MV stack. The entropy
stream still matched symbol for symbol -- a missing weight-2 temporal vote
only reorders the stack -- so a NEW_NEWMV block at mi(0,24) took stack[1]
= (36,0) (the compound extension's zero-fill) instead of libaom's (0,0),
predicting 32 px off and leaving a 32-px-wide wrong column band.

New `MiGrid::get_frame` is the unclamped frame-level read; only
`build_motion_field` uses it. Rungs added with it: `EC_TPL` (per frame:
use_ref_frame_mvs + filled projected cells) and `EC_TRACE_TPL`'s new
`EC_TPL_SAVED` occupancy map of the saved field, which is what showed the
16-column hole.

Pre-filter reconstruction of all 6 decode-order frames of the pinned
stream goes 1306/3358/5027/6622 wrong luma px (frames 2..5) -> 0.
fix(av1): compound MV stack zero-filled the comp_list tail libaom fills with global motionAhmet Kaan Gümüş · e2010ef
fix(av1): compound MV stack zero-filled the comp_list tail libaom fills with global motion

The compound extension pass (`combine_compound_candidates`, mvstack.rs) filled the
`comp_list` slots left over after `ref_id`/`ref_diff` with `(0, 0)`. libaom fills them
with that side's GLOBAL MOTION vector (`setup_ref_mv_list`, av1/common/mvref_common.c:729:
`for (; comp_idx < MAX_MV_REF_CANDIDATES; ++comp_idx)
   comp_list[comp_idx][idx] = gm_mv_candidates[idx];`).

The zero fill was only right under IDENTITY global motion, the module's original
reduction; aomenc has --enable-global-motion on by default. A compound block with no
usable neighbour pair (frame top row, an intra block to its left, an empty temporal
field) then took a (0, 0) predictor where libaom took the frame's translation --
mv0 (-1,2) vs (128,-16) on the first such block, 32890/39907 wrong luma samples on
decode-order frame 2 of a 10-bit cq58/cq61 stream, with the entropy stream still in
sync (180/180 TU all_zero ranges identical to aomdec).

Also this round:
- the no-CFL uv_mode gate's source becomes the half-random fixture, so BOTH the 8-bit
  and the 10-bit arm carry >=1 intra-above-32x32 block per compared attempt (the flat
  half made aomenc code the right-hand superblocks skip at 8 bit: 0 hits).
- EC_AV1_PREFILT_DUMP16 is indexed by decode-order picture (it overwrote .f0 every
  frame, so a mid-sequence divergence could not be read out).
- setup_motion_field prints an EC_TPL_FIELD occupancy map under the existing
  EC_TRACE_TPL rung.

Probe grid after the fix (192x128, 6 frames, half-random geq), pixel diffs vs ffmpeg:
8-bit cq52/58/61 = 0/0/0 (5/2/3 hits), 10-bit cq52/58/61 = 0/0/0 (6/7/7 hits);
was 0/0/0 and 0/32890/39907.
fix(av1): motion_field_projection returns 0 for a key/intra start frame, so a forward key frame no longer spends a ref_stamp slot; av1_copy_frame_mvs clear portedAhmet Kaan Gümüş · 718eaba
fix(av1): motion_field_projection returns 0 for a key/intra start frame, so a forward key frame no longer spends a ref_stamp slot; av1_copy_frame_mvs clear ported
fix(av1): the saved motion field stored a compound block's FIRST reference, not its secondAhmet Kaan Gümüş · 72cffab
fix(av1): the saved motion field stored a compound block's FIRST reference, not its second

libaom `av1_copy_frame_mvs` walks BOTH of an inter block's reference slots and
the LAST qualifying one wins, skipping a slot whose reference is on the other
side (`av1_calculate_ref_frame_side`: OrderHint ahead of, or equal to, this
frame's) or whose mv exceeds `REFMVS_LIMIT`. `build_motion_field` kept slot 0
unconditionally, so every compound block's 8x8 motion-field cell carried the
wrong (mv, reference) pair; the next frame's `add_tpl_ref_mv` then projected it
with the wrong reference distance and a NEARESTMV block took a wrong temporal
candidate -- entropy exact, pixels wrong.

Pinned instance (lane-inter4 r2's open "decodes fully, still mismatches"):
192x128 rect-partition inter stream, cq 34, decode-order frame 5, the 32x32
block at mi(24,40) -- ours mv0=(0,72) from mfmv0=(0,24) rfo=1, aomdec
mv0=(0,-230) from mfmv0=(0,-230) rfo=3. 646 luma pixels, max delta 39.

Gate: a_real_aomenc_inter_sequence_with_temporal_mv_candidates_decodes_pixel_exact
(8-bit + 10-bit, every fully decoded attempt compared to ffmpeg, temporal-MV
counter asserted >0: 66/67 blocks). Reverting the fix reddens it at frame 5.

Class saved-field-keeps-slot-0: a per-frame summary of a multi-slot field must
replay the reference's slot walk (order + skips), not keep slot 0.

Instruments: EC_MODE_VAL/EC_STACK on our single-ref path, EC_TPL per
add_tpl_ref_mv probe (oracle side patched to match).

2026-08-28

wip(av1): temporal MV projection math (spec 7.9/7.10.2.8), not yet wiredAhmet Kaan Gümüş · 916263c
wip(av1): temporal MV projection math (spec 7.9/7.10.2.8), not yet wired

New crate::motion_field module: MotionField (per-frame saved 8x8 MV grid
+ order-hint bookkeeping), setup_motion_field (av1_setup_motion_field's
LAST/BWDREF/ALTREF2/ALTREF/LAST2 selection + motion_field_projection's
distance-scaled projection into a TplField), and add_tpl_ref_mv (the
per-query-block second projection). All ported from libaom
av1/common/mvref_common.c, unit-tested against hand-checked distance/
projection arithmetic.

mvstack::find_mv_stack_with_sign_bias gains an Option<TplArgs> parameter:
when Some, folds temporal candidates into the stack at libaom's real
insertion point (after the row/col/top-right REF_CAT_LEVEL boost, before
the corner probe) and derives zero_mv_ctx (GLOBALMV_OFFSET) from them;
None (every existing caller today) reproduces the prior always-0 exact
behaviour bit for bit -- all 13 existing mvstack unit tests still pass
unmodified.

NOT DONE: decode_inter_block's only call site still passes tpl: None
(see its own TODO), and nothing in decode_inter_frame_tile_with_cdfs or
stream::decode_stream builds a per-DPB-slot MotionField or calls
setup_motion_field -- so decode::tmv_hits() reads 0 against any real
stream, and no temporal-MV gate exists yet. See ledger DELTA for the
precise remaining wiring.