Commits
Commits on
8dbd683068d7f87f21dcc4ed1dfdca786d82c52bFiltered to crates/ec-av1/src/mvstack.rsClear filter2026-08-28
fix(av1): single-ref mvstack scan votes a compound neighbour's second slotAhmet Kaan Gümüş · 2b9615f
fix(av1): single-ref mvstack scan votes a compound neighbour's second slot Named read #538 (EC_RNG global trace): L5039, the new_mv symbol in decode_inter_block16's single-ref path, fed a new_mv_ctx computed from find_mv_stack_with_sign_bias. Its row/col/corner scans and the single-ref extension pass (process_single_ref_mv_candidate) matched a neighbour on info.ref_frame alone, silently dropping the vote whenever a compound-coded neighbour's match sat in its second slot (ref_frame1/mv1) -- the third instance of the neighbour-votes-all-its- fields class. Frame 10 (decode order) has reference_select=true, so a compound neighbour is live next to the diverging single-ref query. Added single_ref_match() (mirrors libaom's add_ref_mv_candidate `for ref in 0..1+is_compound`), used by scan_row/scan_col/scan_corner/ scan_top_right; extended process_single_ref_mv_candidate to donate both of a compound candidate's slots instead of just the first. Proof: av1idx-refsel-pin.obu (20 frames) now 60/60 plane-MATCH against ffmpeg (0 mismatches), 3x. Full ec-av1 --lib suite 214/0/19 green. Also: added a CURRENT_OP thread-local (msac.rs) plus a per-call-site tag before every dec.symbol()/symbol_fixed() read in decode.rs (r5 scratch instrumentation, EC_RNG=1 trace now prints op=L<line>), and a reference_select/primary_ref_frame field on the EC_AV1_SREF_DUMP print (stream.rs) used to confirm frame 10's header state.
wip(av1): r6 root cause -- ref-frame ctx undercounts compound neighboursAhmet Kaan Gümüş · d706250
wip(av1): r6 root cause -- ref-frame ctx undercounts compound neighbours libaom av1_collect_neighbors_ref_counts (mvref_common.h) counts BOTH ref_frame[0] and ref_frame[1] of a compound neighbour; our ref_ctx family took one scalar per side, so every single_ref/comp_ref/comp_bwdref ctx row was wrong next to a compound neighbour -- value-equal decodes with different interval narrowing, drifting entropy state into compound_idx. All vote functions now take each side's pair. Compiles clean. Dying words: rebuild and rerun the failing test, then full proof chain (unmask both blends, seed-45 byte-exact, cdfflake pin re-decode, gates 3x, suite 3x, scratch cleanup).
fix(av1): port libaom's real compound mvstack tpl fold-in and combine dedupAhmet Kaan Gümüş · ac83457
fix(av1): port libaom's real compound mvstack tpl fold-in and combine dedup find_mv_stack_compound carried two documented conservative deviations from libaom's mvref_common.c: the temporal add_tpl_ref_mv fold-in dropped a compound candidate when the crate's own re-lookup happened to fail one side independently, instead of zero-filling; and the extension-pass combine step ran every candidate through the ordinary weight-bump dedup instead of libaom's real is_dup check (setup_ref_mv_list ~735-754: exactly one new entry when the stack already has one, comparing only comp_list[0] against it and taking comp_list[1] on a match; both entries appended unconditionally, un-deduped, when the stack is empty). Both are now exact ports (mvref_common.c:341-433, 692-762), with compound_dedupes_same_pair_and_sums_weight updated to the real two-entries- unmerged outcome the is_dup port actually produces. cargo test --release -p ec-av1 --lib: 205 passed / 0 failed / 16 ignored.
WIP(av1): compound mvstack candidate machinery, not yet wiredAhmet Kaan Gümüş · 368413c
WIP(av1): compound mvstack candidate machinery, not yet wired find_mv_stack_compound: parallel entry point to find_mv_stack_with_sign_bias for a block predicted against a reference-frame pair (spec 7.10.2's is_compound path). Adds: - MiInfo.mv1 (the compound second MV, paired with r3's ref_frame1) - scan_row_compound/scan_col_compound/scan_top_right_compound/ scan_corner_compound: exact-pair-matched twins of the single-ref scans - process_compound_ref_mv_candidate + CompoundRefLists + combine_compound_candidates: the compound extension/topping pass (mvref_common.c's process_compound_ref_mv_candidate + the combine step) - CompoundTplArgs: compound temporal-MV fold-in, reusing motion_field's existing single-ref add_tpl_ref_mv once per side of the pair - new_mv_ctx/ref_mv_ctx reuse the existing (nearest_match, ref_match_count) switch, which libaom's own mode_context switch is ref-count-agnostic about Documented deviations: tpl compound candidates drop (not zero-fill) a missing side; the extension combine step dedups by weight-bump instead of libaom's real is_dup skip-on-first-match. Both noted in find_mv_stack_compound's doc for a later round to tighten if a live compound gate's drl_ctx disagrees. Every existing single-reference caller (find_mv_stack/ find_mv_stack_with_sign_bias and their 23 pre-existing tests) is untouched; this is purely additive, unwired code, same pattern as r1/r3. 6 new tests, cargo test --release -p ec-av1 --lib: 205 passed / 0 failed / 16 ignored.
WIP(av1): carry a compound second reference through MiInfo/NeighboursAhmet Kaan Gümüş · cfa1e23
WIP(av1): carry a compound second reference through MiInfo/Neighbours Step 1 of the compound-decode chain (lane-av1comp): MiInfo grows ref_frame1: Option<i8> (spec RefFrames[1]) and decode.rs's Neighbours grows above_ref1/left_ref1 alongside above_ref/left_ref, mirroring the existing i8 single-ref tracking. Every one of the 24 MiInfo literal sites across decode.rs/encode.rs/mvstack.rs/tile.rs sets it to None -- no decode or encode path here ever produces a compound block yet, so this is pure plumbing: find_mv_stack's scan still matches candidates on ref_frame alone, and reference_mode_ctx/comp_reference_type_ctx (landed r1, 1fcb059) still have no caller. Next: read_ref_frames replacing stream.rs:181-195's reference_select refusal (decodemv.c:966-990/1000+, is_comp_ref_allowed blockd.h:65-67), then inter_compound_mode CDF/tree + compound DRL, then mvstack's dual- ref candidate scan (process_compound_ref_mv_candidate, mvref_common.c:435-455/696-762 -- the largest remaining piece), then the COMPOUND_AVERAGE/dist_wtd_comp_avg MC blend. See the lane-av1comp ledger entries for the full ordered plan.
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.
WIP(av1): single-ref LAST2/LAST3/BWDREF/ALTREF2/ALTREF decode — agent capped mid-verificationAhmet Kaan Gümüş · 96e6529Browse files
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.