forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to crates/ec-av1/src/mvstack.rsClear filter

2026-08-28

WIP(av1): compound-reference symbol-reading CDFs and contexts, not yet wiredAhmet Kaan Gümüş · 651448b
WIP(av1): compound-reference symbol-reading CDFs and contexts, not yet wired

Spec 5.11.25's read_ref_frames compound path (comp_mode, comp_reference_type,
uni_comp_ref/comp_ref/comp_bwdref trees) needs five new default-CDF tables
(cdf::COMP_MODE/COMP_REF_TYPE/UNI_COMP_REF/COMP_REF/COMP_BWDREF, ported from
libaom entropymode.c) plus their adaptation state (cdf_state.rs), and two new
context functions (mvstack::reference_mode_ctx/comp_reference_type_ctx,
libaom's av1_get_reference_mode_context/av1_get_comp_reference_type_context)
unit-tested against hand-derived cases matching libaom's branch tables. The
comp_ref*/comp_bwdref* trees reuse the existing single_ref_p2/p3/p4/p5/p6
context shape (ref_ctx) since libaom's own functions are literally aliases of
the single-ref ones; only uni_comp_ref_p1 needed a new vote set.

Not yet wired to decode_inter_block or stream.rs's reference_select refusal:
that needs Neighbours to carry per-cell compound state (today every decoded
neighbour is proven single-ref, so NeighbourRef is exercised only by its unit
tests), and reading comp_mode/comp_ref_type still dead-ends at "decode this
compound block" with no inter_compound_mode CDF, no compound DRL, no mvstack
dual-ref scan, and no distance-weighted MC blend behind it -- porting comp_mode
reading alone without that chain would trade one frame-level refusal for an
identical per-block one, with no stream this decoder can actually finish.
Left as tested, reviewable infrastructure for the next round; see ledger
lane-av1comp entries for the precise next steps and libaom line references.
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.
fix(av1): port libaom's exact single-ref MV stack extensionAhmet Kaan Gümüş · 81de048
fix(av1): port libaom's exact single-ref MV stack extension

Replace the hand-written GOLDEN-fix extension pass (mvref_common.c
reduction guessed by hand: gated on the 8-entry stack cap, flat
unconditional weight=2 adds) with an exact port of
process_single_ref_mv_candidate + setup_ref_mv_list's single-reference
extension: real gate is MAX_MV_REF_CANDIDATES (2, not 8), real reach
is the query block's own bw4/bh4 (not a flat 16), dedup/weight/
sign-bias now match libaom's function precisely.

Fixes the 3 real-clip encoder regressions the hand-written pass
caused (stack contents diverged from what a real decoder derives,
desyncing DRL/MV coding). All 3 pinned/hand-built golden tests still
green; full ec-av1 suite green (179 passed); forwarding gate 20/20
clean, 0 mismatches. Golden gate fires=0/20 live (aomenc's fixed
seeds never select GOLDEN_FRAME in this environment) -- GOLDEN arm
stays unmasked since the pinned fixtures and forwarding gate already
prove it correct; re-masking per the fires=0 contingency would break
those pinned tests, a direct conflict flagged rather than resolved
silently.

2026-08-27

feat(av1): decode a single non-LAST_FRAME reference (GOLDEN_FRAME)Ahmet Kaan Gümüş · 8a443b2
feat(av1): decode a single non-LAST_FRAME reference (GOLDEN_FRAME)

Round 2 continuation: read_single_ref threads the full single_ref_p1..p6
spec tree (context from the block's real above/left reference via
Neighbours::above_ref/left_ref, not a bare is_inter bool), decode_inter_block
threads a GOLDEN_FRAME picture down to motion compensation when the frame
header's ref_frame_idx[3] names a live DPB slot, and the deblock filter's
ref_frame_for_lf now indexes loop_filter_ref_deltas by the block's actual
reference instead of assuming LAST_FRAME for every inter block.

decode_stream widens its global-motion IDENTITY refusal to cover both
LAST_FRAME and GOLDEN_FRAME's own entries, and adds a reference_select
refusal (comp_mode/compound prediction stays out of scope; skip_mode is a
spec-guaranteed consequence of that same refusal, not a separate check).

mvstack's find_mv_stack candidate filtering and decode_inter_block8's
straddling-8x8 leaf path were already ref_frame-generic/LAST-only
respectively and needed no changes.

Gate: a_real_aomenc_inter_sequence_with_a_golden_reference_decodes_pixel_exact
(stream.rs) -- an 8-frame real-aomenc sequence with order-hint left on (the
one flag the sibling CDF-forwarding test disables specifically to suppress
GOLDEN_FRAME), asserting pixel-exact decode against ffmpeg whenever
decode::non_last_ref_hits() actually advances. Across the attempt budgets
tried this round, aomenc's RD never produced a stream that both fully
decoded under this crate's existing round-2 refusals AND picked
GOLDEN_FRAME -- the test SKIPs loudly rather than claim untested coverage,
same pattern as its cdf-forwarding sibling.

cargo test -p ec-av1 --release: 177 passed, 0 failed, 12 ignored.
fix(av1): port libaom's real MV-stack weight formula for variable block sizesAhmet Kaan Gümüş · 34a0447
fix(av1): port libaom's real MV-stack weight formula for variable block sizes

decode.rs's real streams query find_mv_stack with block sizes other than
tile.rs's fixed 8-mi case, where the crate's flat IMMEDIATE_WEIGHT=2
approximation silently diverged from libaom's real len*max(2,inc) row/col
weight and 2*mi_size_wide[BLOCK_8X8] corner/top-right weight — producing a
wrong stack order that the (already-correct) DRL index then read from,
mismatching the pinned av1resid seed-44 stream at frame 3 and causing the
forwarding gate's historic ~17% flake (never aomenc RD nondeterminism).

Ported scan_row/scan_col into libaom's real per-block-run weight
accumulation (threading processed_rows/processed_cols across the
immediate and extended-offset scans the way mvref_common.c's single ints
do), and fixed scan_top_right/scan_corner to libaom's fixed weight 4.
tile.rs's own fixed-8 encoder path keeps its unit tests green: the
REF_CAT_LEVEL threshold and scan-order effects are unchanged even though
raw weight numbers now differ from the old flat approximation.

Pin (av1resid-pin.obu, seed 44) now decodes 4/4 frames pixel-exact.
Forwarding gate (a_real_aomenc_inter_sequence_with_cdf_forwarding_decodes_pixel_exact)
ran 20 consecutive times, 0 failures. Full ec-av1 suite: 176 passed, 0
failed, 12 pre-existing ignored.
fix(av1): mvstack extended row/col scan, intra-aware coverage; enable 16x16 inter leavesAhmet Kaan Gümüş · b26ee9f
fix(av1): mvstack extended row/col scan, intra-aware coverage; enable 16x16 inter leaves

Ports spec 7.10.2.4's extended row/col scan (libaom scan_row_mbmi/
scan_col_mbmi's idx=2..MVREF_ROW_COLS positions), invisible at pure
8-mi geometry because the immediate scan's own processed_rows/cols
coverage already reaches as far -- but only once that coverage counts
every *coded* neighbour cell, intra or inter, the way libaom's
processed_rows update sits outside add_ref_mv_candidate's ref-frame
match. The straddle-test attempt this round started from computed
coverage only from ref-matching (inter) cells, so an intra neighbour
above an 8-mi query silently un-suppressed the extended scan -- a real
8-mi behavior change, caught by two new differential tests
(extended_{row,col}_scan_is_a_no_op_at_8mi_geometry_even_behind_an_intra_neighbour)
that place a distinctively-MV'd tracer candidate at the extended
offsets and assert it never gets picked up. MiGrid now records intra
cells (encode.rs/tile.rs's else branches) so mvstack sees them.

With the no-op proven, lifts the `false &&` gate on 16x16-leaf
NEARESTMV (encode.rs:1231, wired r1, gated since dead code never
touched write_inter_frame_leaf's real symbol chain): full suite
130+3 new = 133/0/9, straddle and real_clip both green with the gate
live. The 640x384 real-clip fixture tiles exactly into 32x32
quadrants (no true-edge straddle), so its numbers are unchanged
(45.41 dB / 69861 bytes) -- the gate's leaf path is unexercised there;
the straddle test is what proves it live.

2026-08-26

fix(av1): new_mv_ctx case-0 takes the corner-derived ref_match_count bitAhmet Kaan Gümüş · d5bf53b
fix(av1): new_mv_ctx case-0 takes the corner-derived ref_match_count bit

Real-motion content desynced from inter frame 3-4 at aligned sizes: a block
whose only neighbour match is the diagonal corner has nearest_match == 0
but ref_match_count == 1, and libaom sets mode_context |= 1 there
(mvref_common.c ~621) while our arm hardcoded 0 — wrong NEWMV CDF row,
rng drift, decoder rejects the tile. Sibling of the ref_mv_ctx corner fix;
zero_mv_ctx checked, no such dependency. New test pins the corner-only-match
shape. Both I8 failing clips re-encode to 10/10 clean aomdec+ffmpeg decodes,
byte-exact vs reconstruction.
Merge branch 'lane-av1-size': pad-to-32 with cropped reconstructionsAhmet Kaan Gümüş · 77b8ab9
Merge branch 'lane-av1-size': pad-to-32 with cropped reconstructions

The merge exposed a latent mvstack defect the two lanes could only trip
together: real inter residuals (lane-av1-desync) on padded content
(lane-av1-size) hit a block whose ref_mv context libaom derives from a
diagonal corner probe our reduction never ran. Folded into this merge:

- port libaom's scan_blk_mbmi(-1,-1) corner probe; ref_mv_ctx now
  splits (nearest_match, ref_match_count) exactly as mvref_common.c does
- fix the REF_CAT_LEVEL DRL boost comparison (was trivially true);
  weights are boosted in place before the corner probe can add an
  unboosted entry
- SymbolEncoder::tell(), the od_ec_enc_tell mirror the hunt relied on

Gate: cargo test -p ec-av1 --release = 116 passed, 5 ignored.
fix(av1): exact spec 7.10.2.8 mvstack contexts, 7.10.2.14 MV clampingAhmet Kaan Gümüş · 23d548c
fix(av1): exact spec 7.10.2.8 mvstack contexts, 7.10.2.14 MV clamping

Replaces the documented monotonic stand-in NewMvContext/RefMvContext/
ZeroMvContext/DrlCtx with an exact port of libaom's av1_find_mv_stack
mode_context switch and av1_drl_ctx (mvref_common.c/.h), which collapse
to closed forms given this module's already-reduced scan (no extended
row/col offsets, no temporal MV projection): ref_match_count ==
nearest_match always, so drl_ctx is always 0 (every candidate gets the
REF_CAT_LEVEL nearest-bonus), and zero_mv_ctx is always 0 (GLOBALMV_OFFSET
is only ever set by temporal MV projection). Adds MiInfo::is_new_mv so
new_mv_ctx can read whether a neighbour was itself coded NEWMV, matching
libaom's newmv_count. Adds clamp_mv_ref (7.10.2.14) applied to
nearest_mv/near_mv/pred_mv, requiring find_mv_stack's new mi_cols/mi_rows
params. Adds single_ref_ctx: the LAST-only reduction collapses libaom's
three single_ref_p1/p3/p4 context functions to one two-valued test since
LAST2/LAST3/GOLDEN/backward counts are always zero here.

Ledger: does not include the inter tile writer (ec-av1 tile.rs) this
lane's charter also scoped -- see HANDOFF for the exact block-writer
design (symbol order, size groups, MV component coding) worked out but
not yet landed.
feat(av1): MV prediction stack (spec 7.10.2, single-ref reduction)Ahmet Kaan Gümüş · ec98d16
feat(av1): MV prediction stack (spec 7.10.2, single-ref reduction)

find_mv_stack scans row-above/col-left/top-right neighbours over a
block's whole 4x4-mi span, dedupes into a weighted RefStackMv, and
derives NearestMv/NearMv/PredMv plus NewMv/RefMv/ZeroMv/DRL contexts.
Compound refs, temporal MV projection and bit-exact context tables are
deliberately out of scope until a consumer needs them.