forge
Explore
Log in

Don't you dare go Hollow

Commits

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

2026-09-02

fix(av1): the mv-stack frame-edge clamp window is signed -- a block overhanging the bottom/right edge was never clampedAhmet Kaan Gümüş · 3bd2894
fix(av1): the mv-stack frame-edge clamp window is signed -- a block overhanging the bottom/right edge was never clamped

libaom's `mb_to_right_edge` / `mb_to_bottom_edge` (`set_mi_row_col`,
av1_common_int.h) are signed: a block that overhangs the frame's right or
bottom edge keeps its full `bw4`/`bh4`, so `mi_cols - bw4 - mi_col` and
`mi_rows - bh4 - mi_row` go NEGATIVE and `clamp_mv_ref` (mvref_common.h)
narrows the predictor window by exactly that much. Our port computed both
terms with `usize::saturating_sub`, which clipped them to 0 and left the
window up to two block sizes too wide, so an edge block's stack entry was
never clamped.

On a 10-bit 3840x1608 stream (`mi_rows == 402`) every bottom-row 64x64 block
overhangs by 14 mi units: the 64x64 NEWMV block at mi(400,368) of decode
frame 88 took `mv0=(224,568)` where libaom takes `(32,568)` -- the entropy
stream is identical (same range at EC_MODE and EC_MODE_MV), only the
reconstructed value differed -- and its MC then read the reference's
replicated last row instead of real rows 1604..1606. That frame was the only
non-exact one in the 100-frame 4K head prefix (221 bytes); it is now exact.

New counter `mvstack::mv_clamp_edge_overhang_hits` (also printed by
decode_probe) counts stack entries the negative-edge window actually moves.

crates/ec-av1/fixtures/reelb_head_mvclamp_witness.obu (72158 bytes, sha256
451a9b138995e636f22308847a123b5c8621d4908cd93772cf5bbf2b37df39d7, truncated
twice to identical hashes) is the smallest prefix of that head firing it
(N=79 -> 0, N=80 -> 5); new gate
`a_10bit_film_frames_with_frame_edge_mv_clamping_decode_pixel_exact` decodes
its 52 shown frames pixel-exact against ffmpeg on every plane and hard-asserts
the counter. `clamp_mv_ref_window_is_signed_at_the_frame_bottom_edge` pins the
ladder's exact numbers.
fix(av1): the warp-sample top-right probe needs libaom's rect shape refinements, not just the longer sideAhmet Kaan Gümüş · 00aa449
fix(av1): the warp-sample top-right probe needs libaom's rect shape refinements, not just the longer side

r9 changed `av1_findSamples`' top-right probe to libaom's
`AOMMAX(xd->width, xd->height)` (mvref_common.c:1235) but left our
`has_top_right` port without the two shape refinements libaom applies right
after the mask loop (`av1_common_int.h:1419-1428`):

  is_last_vertical_rect  = !((mi_col + width) & (height - 1))   [width < height]
  is_first_horizontal_rect = !(mi_row & (width - 1))            [width > height]

Both are derivable from mi_row/mi_col/bw4/bh4 alone -- no partition context --
and they only bite when bw4 != bh4, i.e. exactly the blocks whose probe size
r9 changed. Probing at the longer side WITHOUT them is half a port: it fixed
the 64x128 block (bs=32 > 16, early-out, no top-right sample, 2-symbol obmc
alphabet) and broke a 32-wide tall leaf in an earlier superblock, moving the
first divergence of the 10-bit 1920x792 264-frame cut EARLIER (decode frame 49,
mi(24,376) -> its successor mi(24,380) read a different rng).

With the refinements ported, on that cut:
* mode ladder vs the instrumented reference decoder over ALL 264 frames:
  915 equal runs, 914 inserts (our per-sub-block prints the reference does not
  emit), ZERO replace/delete -- every EC_MODE (mi_row, mi_col, rng) triple the
  reference emits matches ours, previously the first mismatch was frame 49.
* pixel compare vs the reference decoder: 231/267 frames bit-exact, 36 frames
  differ by 1-3 bytes each (the known chroma-MC bottom-row clamp residue,
  lane-t900 r8); was 218/267 frames differing, frame 49 alone by 2.26 MB.

`tr_reach_longer_side_hits()` now counts blocks where the full probe disagrees
with the old square-at-width probe (9936 on that cut).

corner-cut: libaom's third refinement (PARTITION_VERT_A bottom-left square)
still not ported -- it needs the parent partition type; ceiling and upgrade
path recorded on `mvstack::has_top_right`.
fix(av1): mv-stack row/col scans dropped libaom's sub-8px clauses, desyncing every 4-wide/4-high blockAhmet Kaan Gümüş · 9d5ecaa
fix(av1): mv-stack row/col scans dropped libaom's sub-8px clauses, desyncing every 4-wide/4-high block

`scan_row`/`scan_col` (and the compound twins) applied the weight and
`processed_rows`/`processed_cols` update whenever `bw4 <= n4`, but libaom
`scan_row_mbmi`/`scan_col_mbmi` (mvref_common.c:172/222) gate that on
`xd->width >= mi_size_wide[BLOCK_8X8]` as well, and step the |offset|>1 column
back on an odd mi_col under a sub-8px block. A 4-wide 1:4 strip therefore got a
raised candidate weight and a shifted outer scan: on a 128x128 cq60 aomenc
stream, mi(24,15) built the stack (12,28) w648 / (-4,26) w648 / (-4,18) w8 where
libaom builds (12,28) w650 / (-4,18) w648 / (-4,26) w8 / (6,332) w4, picking a
different mv and desyncing 5466 luma pixels of frame 1 from (122,13).

With both clauses ported the same stream is entropy-exact (125/125 aomdec
EC_MODE entries match, value and range) and stops on another lane's named
sub-8x8 intra refusal instead of decoding wrong pixels.

The intra 16x4/4x16 gate becomes continue-and-sweep: every arm decodes, named
refusals only from a measured list, every decode-order frame compared on every
plane, and ONE end-of-sweep assert over the recorded failures plus a per-bit-
depth firing assert. Still ignored, refusal NOT lifted -- no recipe found yet
gives a pixel-exact attempt with the counter above zero.
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): gate the top-right mv probe on the bs>64 half of has_top_right only, and cap inter var-tx leaves per root sizeAhmet Kaan Gümüş · 76749a1
fix(av1): gate the top-right mv probe on the bs>64 half of has_top_right only, and cap inter var-tx leaves per root size

The r5 wiring applied libaom's whole has_top_right, position mask included,
without its three shape refinements (is_last_vertical_rect,
is_first_horizontal_rect, the PARTITION_VERT_A bottom-left square). That is
right for a 128 block (bs > 64 -> no candidate, the defect r5 fixed) and wrong
below it: the 64-level AB, free-partition and 1:4 stream gates lost frame 16
luma. Gate on the size half only; ceiling and upgrade path named at the helper.
Also: the merged var-tx leaf ceiling is per root (32 below the 128 root, 64 at
it, where the mu-chunk reader codes a TX_64X64's 32x32 coded corner), and the
skipped-inter internal-edge suppression is narrowed to the 128 root, the only
size whose leaves are not the block.
fix(av1): gate the mv-stack top-right probe on has_top_right; 128-root motion_mode/obmc CDF rows; TX_64X64 coded corner on the intra-in-inter pathAhmet Kaan Gümüş · b6c54c5
fix(av1): gate the mv-stack top-right probe on has_top_right; 128-root motion_mode/obmc CDF rows; TX_64X64 coded corner on the intra-in-inter path

Three root causes behind the 128x128 inter gate's frame-5 reconstruction residue,
all on a 256x256 8/10-bit stream with use_128x128_superblock:

1. mvstack.rs find_mv_stack{,_compound} called scan_top_right unconditionally.
   libaom setup_ref_mv_list (mvref_common.c:497/546) gates it on has_top_right,
   which is 0 for bs > 16 -- a 128x128 block's above-right cell is populated
   (previous SB row) but unavailable, so we invented a candidate and desynced
   the drl symbols.
2. decode.rs mapped a square block's motion_mode/obmc CDF row with
   trailing_zeros - 3, sending 128 to our packed BLOCK_16X32 row. Added libaom
   default_motion_mode_cdf / default_obmc_cdf rows 13/14/15 (64X128, 128X64,
   128X128) and explicit match arms ahead of the square one.
3. A TX_64X64 luma unit on the intra-in-inter-frame path used the full 64x64
   scan and tx_side; only the top-left 32x32 is coded (spec 5.11.40), which
   panicked the inverse transform on the 10-bit arm.

All 9 decode-order frames of the 8-bit and 10-bit gate arms are now pixel-exact
(EC_AV1_PREFILT_DUMP, was 19550/14164/26667/26716 wrong bytes on f5..f8); the
mode-value ladder matches aomdec exactly. The tx-size-search arm is still red on
4 post-deblock chroma pixels -- a phantom chroma TU edge published by the
per-vartx-leaf lf-grid write, analysed in lanes/sb128c-r5.handoff.md.
fix(av1): three MV-stack divergences from libaom setup_ref_mv_list, one of them a compound-vs-single twin driftAhmet Kaan Gümüş · 199abd2
fix(av1): three MV-stack divergences from libaom setup_ref_mv_list, one of them a compound-vs-single twin drift

Phase-by-phase diff of both twins (find_mv_stack_with_sign_bias and
find_mv_stack_compound) against libaom mvref_common.c; full 20-phase table in
lanes/mvtwin-r1.report.md.

1. TWIN DRIFT (compound only): combine_compound_candidates filled a comp_list
   slot past both ref_id/ref_diff lists with (0, 0). libaom fills it with THAT
   SIDE's own gm_mv_candidates[idx] (mvref_common.c:718-719) -- the single-ref
   twin closed the identical gm-fallback gap on its mv_ref_list tail in r6.
   Wrong the moment a compound pair names a ROTZOOM/AFFINE reference and the
   scans leave the stack short.

2. BOTH twins: add_candidate/add_compound_candidate pushed unbounded and let a
   later sort+truncate pick the survivors. libaom drops the 9th distinct
   candidate AT INSERTION (*refmv_count < MAX_REF_MV_STACK_SIZE,
   mvref_common.c:100/128/388/425), keeping a different set. The dedup weight
   bump on a full stack is preserved.

3. BOTH twins: the row/col reach and the up/left availability gates were
   FRAME-relative. libaom's find_valid_row_offset/find_valid_col_offset clamp
   to tile->mi_row_start/mi_col_start (mvref_common.c:512-533). MiGrid::get
   already hid the out-of-tile cells, so the symptom was the scan weight (inc)
   and through it the stack order, inside every tile not starting at mi 0.

Not defects, checked and recorded: the two bubble passes vs one stable sort
(equivalent -- no post-boost entry can reach REF_CAT_LEVEL), the compound
add_tpl_ref_mv double lookup (offset-independent, so both sides resolve
together), and the has_tr grid probe (mask logic and "already decoded"
coincide for square blocks, and libaom's is_last_vertical_rect refinement
restores the rect case our probe already gets right).

Gates: new a_real_aomenc_compound_mv_stack_gate, the first compound gate here
that leaves --enable-ref-frame-mvs ON, with --auto-alt-ref=1 --lag-in-frames=25,
a cq sweep and 30 seeds per arm; three arms (8-bit sb64 gm=0, 8-bit sb64 gm=1,
10-bit sb128 gm=1) decode every frame pixel-exact vs ffmpeg while hard-asserting
comp_mode_hits AND tmv_hits advanced. Plus one deterministic unit test per
defect.

Found but NOT caused here: a 128x64 --tile-columns=1 stream mis-decodes frame 1
luma (ablation-proven pre-existing); kept as an #[ignore]d reproducer with the
repro command in its doc comment.
fix(av1): keep the MV stack's top-right grid probe (the has_top_right port red-lined 8 gates); docs(sb128): r2 reportAhmet Kaan Gümüş · 9852037
fix(av1): keep the MV stack's top-right grid probe (the has_top_right port red-lined 8 gates); docs(sb128): r2 report
feat(av1): 128x128 superblock root in the INTER tile loop (visit order + prologue), sb-aware has_top_right; refusal kept for a residual one-frame mismatchAhmet Kaan Gümüş · b7c0e21
feat(av1): 128x128 superblock root in the INTER tile loop (visit order + prologue), sb-aware has_top_right; refusal kept for a residual one-frame mismatch

The inter tile loop now walks libaom's quadrant visit order (sb_visit_order) and
reads the 128 root once per superblock (read_lr over the whole 128x128, the
8-symbol partition_w128 with its edge gather) through a new shared
read_sb128_root, extracted from the key-frame loop so both paths cannot drift.
libaom has_top_right is now a single sb-aware port in mvstack (the warp-sample
copy in decode.rs hardcoded a 64x64 superblock and now delegates to it), and
the MV stack's top-right probe is gated on it instead of a bare grid probe.

8 of the 9 decode-order frames of the new gate stream are pixel-exact against
the instrumented aomdec, hidden alt-ref included; frame 6 still differs by 996
luma bytes with the entropy stream in sync, and the same content at
--sb-size=64 is exact (sb128_r2_control_sb64), so the residual is
sb128-specific. The product-path refusal therefore STAYS and the gate ships
#[ignore]d as its reproducer -- silent wrong pixels on his films are worse.

2026-09-01

feat(av1): decode an intrabc block vector -- use_intrabc now reads a real DV instead of refusingAhmet Kaan Gümüş · fbda1c6
feat(av1): decode an intrabc block vector -- use_intrabc now reads a real DV instead of refusing

The DV predictor is the ordinary MV stack queried with INTRA_FRAME
(libaom av1_find_mv_refs/av1_find_ref_dv), the difference reads off a
separate ndvc context at full-pel precision (MV_SUBPEL_NONE), and the
block-copy prediction rides the existing PALETTE_PRED per-block
prediction override with BILINEAR taps off the current frame's own
pre-loop-filter planes (all loop filters are already off when
allow_intrabc). tx_type switches to the inter ext-tx sets, since libaom
counts an intrabc block as is_inter_block.

Two real index bugs fell out: mvstack's sign_bias() and gm_mv() both
indexed table[ref_frame - LAST_FRAME] unguarded, so any INTRA_FRAME
query -- exactly what intrabc does -- panicked at usize::MAX.

The lane's refusal is REPLACED, not lifted: every real aomenc intrabc
block sits under TX_MODE_SELECT, whose inter var-tx transform tree
(read_var_tx_size) this decoder has nowhere, so no stream reconstructs
one end to end yet and enable-intrabc stays in gate_coverage's
NEVER_EXERCISED list. Recipe + evidence in lanes/intrabc-r1.report.md.

2026-08-30

feat(av1): inter frame per-tile decode loop, MV stack bounded per tileAhmet Kaan Gümüş · aaa4b1b
feat(av1): inter frame per-tile decode loop, MV stack bounded per tile

decode_inter_frame_tile_with_cdfs now takes tiles: &[&[u8]] + &TileInfo and
grows the same per-tile loop decode_key_frame_tile_with_cdfs already has:
fresh SymbolDecoder + CDF copy per tile, PlaneBuf::set_tile_origin threaded
with real x1/y1 (right/bottom reach bound), only context_update_tile_id's
own adapted table kept as the frame's own output.

mvstack.rs: MiGrid gets tile_row0/col0/row1/col1 bounds (set_tile_bounds,
called once per tile) so scan_row/scan_col/scan_top_right's grid.get()
cannot see a cell outside the current tile -- bounds all four
find_mv_stack*/find_mv_stack_compound call sites through the one grid they
all read, without touching their own signatures.

Lifts the "an inter frame with more than one tile" refusal (verbatim,
removed from stream.rs and refusal_inventory.rs's pinned list). The
>2-columns and multi-tile-with-loop-filter refusals stay -- not
gate-proven safe to lift this round (deferred, see report).

cargo check clean; scoped tests green: tile/frame/mvstack/stream tile
tests (44), refusal_inventory (2), gate_coverage (2), including the
existing mi_units_outside_the_tile_contribute_nothing tile-bound test and
both real-aomenc two-tile-column gates.
fix(av1): mv-stack single-ref predictor falls back to global motion, not zeroAhmet Kaan Gümüş · 43e5d8c
fix(av1): mv-stack single-ref predictor falls back to global motion, not zero

Root cause of lane-gm r4/r5's "more than one concurrently active
ROTZOOM/AFFINE ref slot" refusal, found by range-laddering the r5 pin
against a new aomdec EC_TRACE_MODE instrument: libaom's
setup_ref_mv_list fills any mv_ref_list slot the neighbour scan left
short with gm_get_motion_vector for that block's own ref, not zero.
Our find_mv_stack_with_sign_bias used (0, 0) -- invisible whenever the
live ref's global motion is itself identity/translation, wrong the
moment it's a real ROTZOOM/AFFINE and a block's own stack (e.g. the
very first block of a frame, no neighbours) comes up short. Symbol
consumption was already bit-exact (rng matched aomdec before/after
mode info); only the predictor value was wrong.

Fixed at the fallback (nearest_mv/near_mv now default to gm_mv(gm,
ref_frame)); the r5/r6 pin decodes all 24 frames byte-exact through
the unmodified decode_stream. The multi-slot refusal that was masking
this is lifted (AFFINE-on-single-ref refusal stays). Wedge gate:
10/40 matches -> 33/40 (7 remaining refusals are all an unrelated
screen-content-tools capability gap).

Full ec-av1 --lib suite: 230/231 green (1 filter_intra gate flake,
confirmed non-regression by standalone rerun -- ok).
test(av1): gm r2 -- add NO_GM_MV to mvstack's own compound test call sitesAhmet Kaan Gümüş · aad87a1
test(av1): gm r2 -- add NO_GM_MV to mvstack's own compound test call sites

Compile fix only, matches decode.rs leaf8's stub. golden3/golden4/scratch_*
pinned-test failures observed this round are pre-existing env-only gaps
(hardcoded path to a different session's scratchpad, or need EC_AV1_PIN set
manually) unrelated to gm; real pinned gates (golden7, warp) pass green.
wip(av1): gm r2 -- compound mvstack gm threading, GLOBALMV real mv, interp two-predicate split (does not compile yet)Ahmet Kaan Gümüş · 5417eab
wip(av1): gm r2 -- compound mvstack gm threading, GLOBALMV real mv, interp two-predicate split (does not compile yet)

Committed by the orchestrator: the builder wrote ~9 edits deep and hit its turn
cap before it could commit. Known-incomplete, recorded verbatim so it survives.
wip(av1): mvstack global-motion substitution plumbing (inert: NO_GM_MV, all flags false)Ahmet Kaan Gümüş · 149fd7a
wip(av1): mvstack global-motion substitution plumbing (inert: NO_GM_MV, all flags false)

MiInfo gains is_global_mv0/1 (all ctors false), GmMvTable threaded through the
single-ref scans, and the TPL zero_mv_ctx comparison now measures against gm_mv
instead of zero (mvref_common.c:369-370). decode.rs still passes NO_GM_MV, so
behaviour is unchanged until the wiring lands.

2026-08-28

fix(av1): mvstack scan weight inc mins by the candidate's cross axisAhmet Kaan Gümüş · d6cb150
fix(av1): mvstack scan weight inc mins by the candidate's cross axis

libaom's scan_row_mbmi mins inc by mi_size_high (candidate height), scan_col
by width; ours used the scan's own axis at all 4 sites (single + compound).
Square candidates hide it; a 32x16 strip above tied weights, reordering DRL
entry 1 and suppressing the -5 extended row scan. rect-flake-2 byte-exact,
pin added to the default list; lib 220/0.
fix(av1): rect-flake-1 byte-exact -- MiInfo size_h, rect warp samples/projection dims, OBMC per-pass overlap, deblock tx-height gridAhmet Kaan Gümüş · 8e2b541
fix(av1): rect-flake-1 byte-exact -- MiInfo size_h, rect warp samples/projection dims, OBMC per-pass overlap, deblock tx-height grid

Three prediction-side root causes after the CDF rows: (1) neighbour records
carry true height (size_h) so a rect strip donates warp samples at ITS
center and col scans step/weight by height; find_projection gets the
strip's true dims -- wmmat now matches aomdec exactly. (2) obmc_blend:
per-pass neighbour caps (width-log2 above, height-log2 left) and overlaps
(bh/2 above, bw/2 left). (3) tx_h_grid: deblock horizontal edges gate by
transform HEIGHT; the single-scalar grid deblocked the strip seam wrong
(1-px chroma drift).
feat(av1): decode non-wedge interintra prediction; fix warp-sample interintra exclusion; reset switchable_interp CDF counterAhmet Kaan Gümüş · a5a10f4
feat(av1): decode non-wedge interintra prediction; fix warp-sample interintra exclusion; reset switchable_interp CDF counter

- interintra syntax (flag -> 4-ary mode -> wedge flag, wedge==1 stays a
  named refusal) + non-wedge smooth blend (II_DC/V/H/SMOOTH, ii_weights1d,
  all planes) on the 16/32 single-ref path and the 8x8 leaf
- interintra blocks record ref_frame1 = INTRA_FRAME(0) in the mi grid so
  find_samples/num_proj_ref exclude them (libaom av1_findSamples requires
  ref_frame[1] == NONE_FRAME); mvstack ref-diff scan guards rf1 > 0
- ii-flake-9: switchable_interp was the one Cdfs field missing from
  reset_counts -- unreset counter saturated past 15 reads and slowed the
  adaptation rate to >>5 while libaom (per-frame counter reset,
  av1_reset_cdf_symbol_counters) stays >>4; rows drifted a few counts and
  the gate flaked on read-dense streams. Field-list audit: no other gap.
- new gate a_real_aomenc_stream_with_interintra_decodes_pixel_exact
  (interintra refusals forbidden, hits counter asserted); pinned-stream
  test extended to 11 fixtures (ii-flake-1..9)

Evidence: 11/11 pins byte-exact; interintra gate 12/12 hammer clean
(hits 11-22 per run); warp gate 3/3; ec-av1 lib 218 passed / 0 failed.
fix(av1): clamp every mvstack entry, not just the derived nearest/near pairAhmet Kaan Gümüş · 569067b
fix(av1): clamp every mvstack entry, not just the derived nearest/near pair

libaom av1_find_mv_refs clamps each stack entry after the build; the NEWMV
predictor is the DRL-selected ENTRY, so a left neighbour coded past the
frame edge (col 520 in pinned warp-flake-5.obu) predicted unclamped where
libaom used 384 -- an mv drift with IDENTICAL entropy (same diff symbols,
range ladder exact at every partition read) surfacing as +-1 warp rounding
crumbs in a hidden altref, inherited by shown frames (V-plane assert).
Both builders (single + compound). All three warp pins green.

class: value-equal narrowing drift (neighbour-votes-all-its-fields family);
localization = part-read range ladder exact -> prediction-side, then
EC_MV pred diff vs patched aomdec.
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.
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.