forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on c80603181233ea5cc197af8a8e2f365c4654b4f6

2026-08-28

Merge branch 'lane-av1blend': ref-frame ctx counts both compound-neighbour refs; interp_filter read orderAhmet Kaan Gümüş · c806031
Merge branch 'lane-av1blend': ref-frame ctx counts both compound-neighbour refs; interp_filter read order

Seven-round bisect. Real fixes: mvstack ref_ctx family now counts both
refs of a compound neighbour (libaom av1_collect_neighbors_ref_counts);
resolve_interp_filter read moved after the compound reads per spec
5.11.19. Pinned compound fixture now decodes 24/24 frames byte-exact
unmasked; a second compound_idx defect remains, so comp_group_idx==0
blends stay refused-by-name and gates stay green. Trace instrumentation
from the bisect rides along, cleanup queued.
Merge branch 'lane-h265perf': hoist loop-invariant scan/size derivation out of encode_subblockAhmet Kaan Gümüş · e117d90
Merge branch 'lane-h265perf': hoist loop-invariant scan/size derivation out of encode_subblock

Bit-exact (identical AU bytes), suite green; wall-clock inert at bench
scale -- kept for the removed redundant recompute. Real RDOQ lever
(estimated bit-cost table) goes to its own BD-gated lane.
fix(av1): r7 -- fix leftover test call sites for the r6 ref_ctx fix, but re-mask compound_idx blendAhmet Kaan Gümüş · 3f636a9
fix(av1): r7 -- fix leftover test call sites for the r6 ref_ctx fix, but re-mask compound_idx blend

Two stream.rs test call sites (single_ref_p1/p3/p5_ctx) still used the pre-r6
2-arg signature, so the crate did not compile after r6's committed fix -- now
pass all four (above0, above1, left0, left1).

Verification of r6's own claim ("root cause found") does NOT hold up under the
wide gate sweep: the fresh seed-45 pinned fixture (av1blend-r1-mismatch.obu)
now decodes byte-exact for all 24 frames/72 planes, confirming r6/r7's
mvstack.rs ref_ctx fix (single_ref_p*/comp_ref*/comp_bwdref* now count both
sides of a compound neighbour, matching libaom's
av1_collect_neighbors_ref_counts) is a real, independently-correct fix -- kept.

But re-running a_real_aomenc_stream_with_compound_references_decodes_pixel_exact
and a_real_aomenc_stream_with_reference_select_reads_comp_mode_correctly
(cq-level=45, many seeds) with the plain-average (comp_group_idx == 0) blend
unmasked on that fix alone still mismatches roughly half the time, at a
different frame each run for the identical seed (aomenc's own cpu-used=0 RD
search is run-to-run nondeterministic, so "same seed" is not "same
bitstream"). r6's own residual-mismatch note already flagged this: 321/846
mismatched pixels in its analysis did not fit the (9,7)-vs-plain-average
hypothesis its fix addresses either -- more than one compound_idx bug lives
here. Re-masked both leaf16 and leaf8's comp_group_idx == 0 path (dead code
kept beneath, #[allow(unreachable_code)]) rather than ship a blend that is
right only sometimes; widened the reference_select gate's refusal-accept
back to accept COMPOUND_REFERENCE, since that refusal is legal again.

cdfflake pin (frame 2 luma 359/4096, right-edge col 63, seed 45,
w=64 h=64 n=4) reproduces exactly as pinned -- unrelated to this lane's
compound work, still open.

Full `cargo test -p ec-av1 --release --lib` 214/0/19 green x2.
perf(h265): hoist scan-table lookups out of encode_subblock's hot RDOQ loopAhmet Kaan Gümüş · b54343a
perf(h265): hoist scan-table lookups out of encode_subblock's hot RDOQ loop

profile-first (perf record on ec-bench's 640x360x10f h265 encode row):
encode_subblock is 26% self time, the single hottest symbol, driven by
RDOQ's per-trial tail re-encode (encode_subblock_range walks every
sub-block from the trial position down to sub-block 0 on every candidate,
since a real adaptive-CABAC bit count cannot be decomposed into a local
delta -- range/low state and context adaptation both carry forward). That
replay cost is structural to exact-CABAC RDOQ and not safely reducible
without changing which candidate wins (disallowed: this lane's gate is
bit-exact output before/after).

What's still free: log2_size/sub_wide/the two scan tables were re-derived
from `n` on every single encode_subblock call, even though they are loop
invariants for the whole encode_subblock_range walk (and, in rdoq's own
direct-call site, invariant for the whole rdoq() call). Hoisted to the
callers and threaded through as parameters -- same values, fewer
recomputations, zero behavior change.

Verified bit-exact: sha256 of ec-bench's h265 AU output identical
before/after (temporary EC_BENCH_DUMP_H265_AUS dump hook, reverted).
cargo test -p ec-h265 --release: 57 passed, 0 failed, including the
pinned rdoq_cache_hash tests. No measurable wall-clock change at the
640x360x10f bench's scale (~2610-2650ms both sides, noise-dominated) --
this hoist's savings are real but too small relative to the required
CABAC replay volume to show above that noise floor.
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): r5 -- interp_filter read-order spec bug (real, inert on this fixture); re-mask leaf16 blend, deepen compound_idx traceAhmet Kaan Gümüş · 4d7335c
fix(av1): r5 -- interp_filter read-order spec bug (real, inert on this fixture); re-mask leaf16 blend, deepen compound_idx trace

Two things this round:

1. Real bug, independently found and fixed: `resolve_interp_filter`'s
   symbol read sat BEFORE `comp_group_idx`/`compound_idx` in the compound
   leaf16 path. Spec 5.11.19 / libaom decodemv.c:1575 reads
   `read_mb_interp_filter` AFTER `read_compound_type`, not before. Moved
   the call to after the compound_idx read (still before its h_filter/
   v_filter are used for MC). Confirmed via a one-off dump that this
   fixture's own stream carries `interp_fixed = Some(Regular)` (fixed,
   non-Switchable filter), so the reorder moves zero bits here and does
   NOT explain the fixture's mismatch -- kept anyway as a genuine,
   independently-verified spec-order fix for the next Switchable-filter
   compound stream.

2. r4 had left leaf16's compound blend UNMASKED (live) with no gate rerun;
   confirmed this round that live state FAILS both compound gates (frame
   17 luma mismatch, seed 42). Re-added leaf16's refusal-by-name (matching
   leaf8's existing one), restoring both compound gates to green
   (a_real_aomenc_stream_with_compound_references_decodes_pixel_exact,
   a_real_aomenc_stream_with_reference_select_reads_comp_mode_correctly,
   1x each) and the full `cargo test -p ec-av1 --release --lib` suite to
   213 passed / 1 failed (bwdref-reference gate, known parallel-run flake
   per ledger's "PID-keyed temp path" class -- green standalone).

Root cause of the actual compound_idx mismatch is still open. This round
falsified: CDF-forwarding-map gap (rebuilt+ran the instrumented aomdec's
own COMPIDX_PRE dump -- ctx0..ctx5 identical to ours at the same frame,
byte for byte) and the interp_filter reorder (inert here, see above).
Comparing `SymbolDecoder::debug_bitpos()` to aomdec's `aom_reader_tell()`
is NOT a valid probe (different quantities -- see the code comment right
above the restored refusal) -- do not repeat it. Next real lead: audit
`read_comp_mode`/`read_compound_ref_frames`/`read_inter_compound_mode`'s
own context computations for this exact (LAST, BWDREF) pair -- all three
decode the SAME symbol values as aomdec on this block (ref0=1, ref1=5,
mode=NEAREST_NEARESTMV), which does not rule out a context/CDF mismatch
that happens to decode the same value while still narrowing `range` by a
different amount than aomdec, drifting entropy state into the next read
(compound_idx) without ever showing up as a value mismatch upstream.

Scratch instrumentation kept, not cleaned up (r1-r5 EC_AV1_COMPIDX_DUMP/
EC_AV1_COMPOUND_DEBUG dumps, IFILTER_PRE/BITPOS_BLK_START additions this
round, scratch_dump_compound_idx_cdf_state/scratch_sweep_compound_mismatch
tests) -- budget spent on the bisection above, not cleanup.
wip(av1): r4 compound_idx CDF-state trace instrumentation, built not yet runAhmet Kaan Gümüş · dc3404f
wip(av1): r4 compound_idx CDF-state trace instrumentation, built not yet run

COMPIDX_PRE dumps per-frame pre-tile compound_idx CDF words; COMPIDX_BLK/VAL
trace every read. scratch_dump_compound_idx_cdf_state pins the fixture run.
fix(av1): r3 bisect -- falsify deblock hypothesis, narrow BWDREF compound defect to compound_idx's decoded valueAhmet Kaan Gümüş · 210dfc8
fix(av1): r3 bisect -- falsify deblock hypothesis, narrow BWDREF compound defect to compound_idx's decoded value

Recalibrated the r2 pre-deblock frame-index gap (23 ours vs 24 aomdec
dumps): the keyframe never calls this crate's own r17_dump at all
(only decode_inter_frame_tile does) -- not a real alignment bug.
Content-hash-matched every pre-deblock dump against an instrumented
aomdec build: PRE-deblock already differs at decode-order frame 3
(fixtures/av1blend-r1-mismatch.obu, seed 45), falsifying the
deblock-parameterization hypothesis. decodemv's own EC_TRACE
(mode/mv/skip) matches this decoder's block loop exactly for every
block in that frame, and both compound inputs are independently
bit-exact pre- and post-deblock. Solving aomval = (key*w0+bwd*w1+8)>>4
against the ~20% of mismatching luma pixels picks out w0=9, w1=7 for
the majority with zero matches for the plain average this decoder
emits -- compound_idx is being decoded as 1 (simple average) when the
real bitstream encoded 0 (COMPOUND_DISTWTD, whose weights for this
frame's order-hint distances are exactly (9, 7)). CDF table, context
function, and read gate were all independently reverified correct
against libaom source; the wrong value is local to this one symbol's
decode, not a wider desync. Masks stay in place, comments updated
with the narrowed finding for the next round.
fix(av1): r2 bisect -- BWDREF compound divergence is per-block, not DPB slotAhmet Kaan Gümüş · 70c2a11
fix(av1): r2 bisect -- BWDREF compound divergence is per-block, not DPB slot

r1's fixture (av1blend-r1-mismatch.obu) was gitignored and lost; could not
be regenerated byte-exact. Static review of stream.rs's ref_slots/
refresh_frame_flags/cdf_slots bookkeeping and the show_existing_frame
refresh arm (spec 7.21, already correctly gated on frame_type==Key in
ec-av1-syntax's frame.rs) found nothing wrong -- the DPB slot bookkeeping
r1 suspected is spec-correct.

A fresh unmasked sweep (seed 45, same recipe) isolated a narrower shape:
decode-order frame 3 (BWDREF compound, zero MV, simple average) is the
first to diverge from ffmpeg even though both its compound inputs are
independently proven pixel-exact and the blend arithmetic is the same
formula r1 proved algebraically exact. That rules out a stale/wrong
reference picture for this fixture -- the defect is in that frame's own
per-block decode (entropy desync or the compound mode/MV read itself),
not reference-slot bookkeeping. Not isolated further within budget.

Both masks stay (comp_group_idx == 0 and == 1); instrumentation is
env-gated (EC_AV1_COMPOUND_DEBUG frame-state trace in stream.rs,
scratch_sweep_compound_mismatch to find a fresh repro seed). Full
`cargo test --release -p ec-av1 --lib`: 214 passed, 0 failed, 18 ignored.
Merge branch 'lane-cdfflake': harden the CDF-forwarding gate — length asserts, fingerprints, on-mismatch pinningAhmet Kaan Gümüş · 81586f2
Merge branch 'lane-cdfflake': harden the CDF-forwarding gate — length asserts, fingerprints, on-mismatch pinning

The gate's rare parallel-run failure is now proven a real deterministic
decode defect (pinned stream reproduces standalone 3/3), not subprocess
instability; the decoder fix is tracked on the compound/DPB lane.
fix(av1): pin a real cdf-forwarding decode defect, harden the gate's instrumentationAhmet Kaan Gümüş · bc99468
fix(av1): pin a real cdf-forwarding decode defect, harden the gate's instrumentation

The cdf-forwarding gate's rare parallel-run "flake" is not instability: a
standalone 3x-reproduction of the pinned seed-45 stream deterministically
mismatches frame 2 luma (359/4096 bytes, first diff row 43 col 63) every
time -- a real decode defect that only a lucky seed sequence exposes, not
a race. The gate itself never reads a counter-gated compare (no
GATE_COUNTER_LOCK coverage needed here), so hypothesis A's "attempt
selection" shape does not apply to this test.

Hardens the gate for future triage instead of masking the defect:
- hard length assert on the y4m fixture (header + frames*(6 + w*h*3/2))
- FNV-1a fingerprints of the y4m/stream/ffmpeg-raw bytes on every attempt
- unconditional (no env var needed) pin-to-scratchpad of both the aomenc
  stream and ffmpeg's raw reference bytes on any mismatch

Repro pinned at /tmp/.../scratchpad/cdfflake-stream-seed45.bin (gitignored
scratchpad, not committed) for the follow-on lane that fixes the decoder.
fix(av1): r1 bisect -- falsify the compound-blend arithmetic hypothesisAhmet Kaan Gümüş · 793125d
fix(av1): r1 bisect -- falsify the compound-blend arithmetic hypothesis

r16/r17 called the masked COMPOUND_REFERENCE reconstruction a
predict_compound_intermediate/combine_compound rounding bug. Unmasking
both sites and running the real gates falsifies that: combine_compound's
combined round2 shift is proven algebraically identical to libaom's
separate DIST_PRECISION_BITS-then-ROUND_POWER_OF_TWO sequence, and a
whole-pel zero-MV compound block reproduces aomdec's own pre-deblock
dump byte-for-byte for several consecutive frames (decode-order 0, 1,
10-18 of the r1 gate fixture).

The real defect: decode-order frame 2 (first block pair to reference
BWDREF_FRAME instead of ALTREF_FRAME, same zero MV, same math shape as
the matching frame 1) is the first frame to diverge from aomdec, and
the corruption propagates into every later frame via refresh_frame_flags
regardless of which reference a later block names -- a DPB slot/
reference-bookkeeping bug, not an MC/blend arithmetic bug. Re-masked
both sites (comp_group_idx == 0) with the corrected root-cause comment;
kept the r17_dump/EC_AV1_COMPOUND_DEBUG instrumentation used to find
this, per the bisect's own re-mask-and-report contingency.
Merge branch 'lane-av1comp': compound-reference symbol chain, skip_mode decode, show_existing_frame outputAhmet Kaan Gümüş · 0b7c477
Merge branch 'lane-av1comp': compound-reference symbol chain, skip_mode decode, show_existing_frame output

17 rounds. Compound refs read fully (comp_mode through per-side MV assign,
comp_group_idx/compound_idx, DRL) in both block paths; skip_mode decoded
(forced NEAREST_NEARESTMV of the SkipModeFrame pair); show_existing_frame
now outputs the named slot instead of emitting hidden altrefs in decode
order. Compound MC blend is implemented but masked by a named refusal:
a real-stream reconstruction defect (one 32x32 quadrant, pre-deblock,
loop filter cross-checked clean) is pinned with live r17_dump scaffolding
and stays a lane away from unmasking.
fix(av1): r17 bisect -- falsify loop-filter hypothesis for the masked compound blendAhmet Kaan Gümüş · 80caed5
fix(av1): r17 bisect -- falsify loop-filter hypothesis for the masked compound blend

r16 called the plain-average COMPOUND_REFERENCE blend defect
"loop-filter-shaped". r17 adds an env-gated pre/post-deblock frame dump
(decode.rs's r17_dump, EC_AV1_PREFILT_DUMP/EC_AV1_POSTFILT_DUMP, matching
aomdec's own hooks of the same name) and a one-shot pinned-stream decode
test (stream.rs's scratch_decode_pinned_stream_once, needed so this
decoder's own frame-index counter lines up with aomdec's numbering).

Result: the 32x32-quadrant mismatch (898/1024 px, rows 32-63 cols 32-63 of
a 64x64 luma plane) is already present *before* this decoder's own loop
filter runs, at parity with aomdec's own pre-deblock buffer for the same
frame -- this falsifies "loop-filter-shaped, not a desync" from r16. It is
a predict_compound_intermediate/combine_compound reconstruction defect.
Root cause still not isolated within that arithmetic (out of this round's
budget); both refusal sites stay masked, with the comment corrected to
this finding and the exact fixture location so the next round can bisect
predict_compound_intermediate itself instead of the loop filter.

Task B (cdf_forwarding-gate flake) not reached this round -- no budget
left after the bisect; the flake did not fire in 3x full-suite runs here
either (214 passed/0 failed/17 ignored each), consistent with its known
low reproduction rate.
fix(av1): mask non-pixel-exact COMPOUND_REFERENCE plain-average blend — r16Ahmet Kaan Gümüş · 232e604
fix(av1): mask non-pixel-exact COMPOUND_REFERENCE plain-average blend — r16

Root cause found: the reference_select/compound_references gate flake was
not a test-harness or counter race (aomenc encode is byte-deterministic
under load, decode_stream is deterministic and pure; both proven by
standalone repro). It is a real, seed/content-dependent defect in the
compound plain/distance-weighted average blend (predict_compound_intermediate
+ combine_compound): a saved aomenc seed-42 stream decodes with up to 4/255
error concentrated in one 32x32 quadrant (683/1024 px), spilling a few px
into neighbours -- loop-filter-shaped, not a desync. DRL/assign_compound_mv/
dist_wtd_comp_weight_assign were cross-checked bit-for-bit against libaom
decodemv.c/reconinter.c and match; round_offset omission in
predict_compound_intermediate is provably a no-op (bias cancels exactly
under arithmetic right shift). True cause not isolated in budget.

Masks comp_group_idx == 0 (the only path this decoder ever reaches) at both
call sites, matching the existing comp_group_idx == 1 mask style -- refuses
by name instead of shipping a non-pixel-exact compound reconstruction.
"pixel-flaky gate = unpinned defect, always" (ledger).
feat(av1): add skip_mode CDF table + adaptation state (unwired)Ahmet Kaan Gümüş · 3403b03
feat(av1): add skip_mode CDF table + adaptation state (unwired)

default_skip_mode_cdfs (libaom entropymode.c, SKIP_MODE_CONTEXTS=3) ported
as cdf::SKIP_MODE, plumbed through Cdfs::new/reset/forwarding the same way
comp_mode/comp_group_idx are. Not yet read by any block decoder -- the
frame-level skip_mode_params() derivation (spec 5.9.22) already lives in
ec-av1-syntax's read_skip_mode_params (SkipModeFrame ref-pair via nearest
forward/backward order-hint distance, matching libaom
av1_setup_skip_mode_allowed bit for bit) and needed no change; the
block-level skip_mode symbol read (spec 7.11.3, forced NEAREST_NEARESTMV
compound + skip=1, decodemv.c read_skip_mode/read_inter_block_mode_info)
is the next round's work, still refused by name at stream.rs:191.
wip(av1): compound MC wired in the 8x8 leaf path, ref1/uni threaded to neighboursAhmet Kaan Gümüş · 1324c3d
wip(av1): compound MC wired in the 8x8 leaf path, ref1/uni threaded to neighbours

decode_inter_block8's COMPOUND_REFERENCE arm (decode.rs) now mirrors the
main-path decode_inter_block: comp_group_idx (masked compound still refused
by name) / compound_idx reads, dist_wtd_comp_weight_assign, and
predict_compound_intermediate + combine_compound blend for y/u/v (chroma
4x4), fixed InterpFilterKind::Regular to match this leaf's existing
single-ref filter approximation. grid.set now records ref_frame1/mv1 for
compound leaves; the caller threads the leaf's own (ref0, ref1,
comp_group_idx, compound_idx) into Neighbours::record_inter/
record_compound_ctx after the straddling-16x16 loop.

Neighbours::record_compound_ctx now also stamps above_ref1/left_ref1 with
the real second reference (previously record_inter always cleared it to
None, so no NeighbourRef ever saw a real compound neighbour). NeighbourRef's
uni field is now computed from the recorded ref pair via a new
is_uni_comp_ref (both refs same temporal side), instead of hardcoded false,
in the main path's above_nbr/left_nbr construction.

Tests: is_uni_comp_ref_matches_forward_backward_sides,
record_compound_ctx_stamps_ref1_for_the_next_block_to_read. 213/213 lib
tests green (211 prior + 2 new).

Remaining: masked compound (comp_group_idx==1) still refused everywhere;
skip_mode read not started; pixel-exact compound gate still blocked on
skip_mode_present per the existing reference_select-gate comment; block8's
NeighbourRef stays the coarse LAST_FRAME-or-intra shape (never sees a real
compound neighbour at that granularity, documented in place).
fix(perf-gates): retry-once-on-marginal-miss for two contention-flaky wall-clock gatesAhmet Kaan Gümüş · 6af4e5c
fix(perf-gates): retry-once-on-marginal-miss for two contention-flaky wall-clock gates

p010_zero_copy_encode_is_realtime (ec-hw) and the WebP animation total-budget
gate (ec-image) both flaked once under parallel-lane contention: real timings
just over the hard bound while another process was compiling. Both now rerun
once when the miss lands within 1.5x of the bound and keep the better
attempt; a genuine regression stays slow on both runs and still fails.
wip(av1): compound r11 — comp_group_idx/compound_idx read, MC blend wired in main pathAhmet Kaan Gümüş · fed4a60
wip(av1): compound r11 — comp_group_idx/compound_idx read, MC blend wired in main path

Round capped mid-wiring; committed by orchestrator after fixing the two
test-wrapper call sites (the five new seq/order-hint params threaded, not
neutralised, where the tile fn has them in scope). 211/211 lib tests green.
Remaining: decode_inter_block8 blend path, record_inter threading of
ref_frame1/mv1/compound_idx, remaining COMPOUND_REFERENCE refusals, firing
gate.
feat(av1): compound CONV_BUF blend + distance-weight assign, not wired yetAhmet Kaan Gümüş · 181a784
feat(av1): compound CONV_BUF blend + distance-weight assign, not wired yet

mc.rs: predict_compound_intermediate (round_1=7, no clip, mirrors libaom's
COMPOUND_ROUND1_BITS path) and combine_compound (spec 7.11.3.15 weighted
average, shift = InterPostRound + DIST_PRECISION_BITS) -- pinned against a
whole-pel identity case that round-trips exactly through both stages.

compound.rs (new): dist_wtd_comp_weight_assign, a pure port of libaom's
av1_dist_wtd_comp_weight_assign (quant_dist_weight/quant_dist_lookup_table
search), tested standalone against hand-worked order-hint cases.

Neither is wired into decode.rs yet -- comp_group_idx/compound_idx reads,
Neighbours compound_idx tracking, and the reconstruction call sites are
still open (see HANDOFF).
feat(av1): read compound DRL + assign compound MVs, still refuse before MCAhmet Kaan Gümüş · 214cdf2
feat(av1): read compound DRL + assign compound MVs, still refuse before MC

find_mv_stack_compound + read_inter_compound_mode now mirrored into
decode_inter_block8's compound arm (task a). A new assign_compound_mv
helper ports libaom decodemv.c's compound read_drl_idx branches and
assign_mv's compound modes (NEAREST_NEARESTMV..NEW_NEWMV) verbatim,
shared by both decode_inter_block and decode_inter_block8 (tasks b/c).
Both paths still refuse right after the MV pair is assigned -- two-
reference motion compensation (COMPOUND_AVERAGE/dist-wtd averaging in
the CONV_BUF domain, not pixel domain) is not wired yet.
feat(av1): read inter_compound_mode past comp_ref, still refuse MCAhmet Kaan Gümüş · cadc399
feat(av1): read inter_compound_mode past comp_ref, still refuse MC

Ports libaom's default_inter_compound_mode_cdf + compound_mode_ctx_map
(entropymode.c / mvref_common.h) and wires read_inter_compound_mode
into decode_inter_block's COMPOUND_REFERENCE arm: once comp_mode/
comp_ref name the reference pair, find_mv_stack_compound now builds
the real compound mvstack (with CompoundTplArgs when tpl_frame is
live) and the block reads its own compound_mode symbol before still
refusing by name -- compound DRL, MV assignment, and two-reference MC
remain unwired. decode_inter_block8's 8x8-leaf arm is untouched (still
refuses at comp_ref). New COMPOUND_MODE_HITS counter (compound_mode_hits())
mirrors COMP_MODE_HITS for a future firing gate.
feat(av1): wire comp_mode/comp_ref reads into both inter-block decodersAhmet Kaan Gümüş · 14ea0a6
feat(av1): wire comp_mode/comp_ref reads into both inter-block decoders

reference_select now threads from the frame header through
decode_inter_frame_tile(_with_cdfs) into decode_inter_block and
decode_inter_block8: when set, each inter block reads comp_mode (spec
5.11.25) first and, on COMPOUND_REFERENCE, reads comp_ref_type/
comp_ref/comp_bwdref via read_compound_ref_frames before refusing the
block by name -- two-reference motion compensation is not wired yet.
This keeps the arithmetic decoder in sync for reference_select streams
that never actually pick compound, and replaces the old blanket
frame-level reference_select refusal with a comp_mode-count-verified
per-block one. skip_mode_present (a separate header bit) gets its own
frame-level refusal since no block-level reader for it exists yet.

Added COMP_MODE_HITS/comp_mode_hits() and a real-aomenc gate
(a_real_aomenc_stream_with_reference_select_reads_comp_mode_correctly)
proving both outcomes: a fully-decoded reference_select stream that
never fired compound, or a refusal that names COMPOUND_REFERENCE with
comp_mode_hits having advanced. Live run: every aomenc attempt in this
recipe hit skip_mode_present or allow_screen_content_tools first (both
separate unimplemented capabilities), so comp_mode itself has not yet
fired live -- next round needs a recipe/attempt-count that clears both
before reaching a bidirectional-reference block.
feat(av1): port comp_mode + compound ref-pair reads, not yet wiredAhmet Kaan Gümüş · a75a2e1
feat(av1): port comp_mode + compound ref-pair reads, not yet wired

read_comp_mode (spec 5.11.25 comp_mode) and read_compound_ref_frames
(comp_reference_type + uni_comp_ref/comp_ref/comp_bwdref trees) mirror
libaom decodemv.c's read_ref_frames compound arm bit-for-bit. Audited
every libaom pred_common.c compound context function against the
existing single_ref_p1..p6_ctx/uni_comp_ref_p1_ctx helpers: each one
(uni_comp_ref_p/p2, comp_ref_p/p1/p2, comp_bwdref_p/p1) is the same
vote-the-neighbours shape under a different libaom name, so no new
context function was needed.

Not yet called from decode_inter_block/decode_inter_block8 -- the
frame-level reference_select refusal in stream.rs still gates every
caller, so this is dead code today (#[allow(dead_code)]), kept
compiling and reviewable for the round that wires it into the block
decode path and adds the inter_compound_mode/DRL/MV/MC chain.
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.
Merge branch 'lane-av1tmvp'Ahmet Kaan Gümüş · 1229793Browse files
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.
Merge branch 'lane-av1refs'Ahmet Kaan Gümüş · 2bcbc81Browse files
feat(av1): pixel-exact single-ref decode for LAST2/LAST3/BWDREF/ALTREF2/ALTREFAhmet Kaan Gümüş · 1719c8e
feat(av1): pixel-exact single-ref decode for LAST2/LAST3/BWDREF/ALTREF2/ALTREF

Adds per-reference hit counters (decode::ref_hits) so a gate can prove the
SPECIFIC reference it targets fired, not just non_last_ref_hits. Adds 5
targeted real-aomenc gates (dropping the golden gate's own
--max-reference-frames=3/--reduced-reference-set=1 narrowing, which
suppresses exactly these references; backward refs additionally need
--auto-alt-ref=1/--lag-in-frames for aomenc to code them at all). All 5
decode pixel-exact against ffmpeg across 3 repeated runs (15/15), proving
the WIP's sign_bias threading for BWDREF/ALTREF2/ALTREF is correct.

Also cherry-picks b650420 (--enable-ref-frame-mvs=0 swept into every
recipe) and a668c49 (film-grain gate pinned below the same fix) from
main, which this branch had forked before -- fixes the 3 real-aomenc
gates that were failing on the WIP alone.
fix(av1): pin the film-grain gate below use_ref_frame_mvs's unimplemented pathAhmet Kaan Gümüş · 25e8a4f
fix(av1): pin the film-grain gate below use_ref_frame_mvs's unimplemented path

real_aomenc_film_grain_streams_decode_pixel_exact's frame-1 mismatch was
never a grain bug: aomenc turns on temporal MV projection
(use_ref_frame_mvs) by default once order hints are enabled, and
mvstack.rs's documented corner-cut always computes zero_mv_ctx and the
mode-context GLOBALMV_OFFSET bit as if it were off, desyncing the symbol
stream from the first NEARESTMV block that inherits a temporal-adjusted
context. Add --enable-ref-frame-mvs=0 alongside this gate's other
disabled features so it isolates grain synthesis as its own comment
already claims, matching every real-aomenc gate's envelope pattern.
Temporal MV projection stays a separate, unimplemented capability.
fix(av1): sweep --enable-ref-frame-mvs=0 into every aomenc test recipeAhmet Kaan Gümüş · 6836b28
fix(av1): sweep --enable-ref-frame-mvs=0 into every aomenc test recipe

use_ref_frame_mvs (temporal MV projection) is unimplemented; mvstack
computes zero_mv_ctx/GLOBALMV_OFFSET as if it were off, so any real
aomenc stream with it enabled desyncs the symbol decoder on inter
frames. The film-grain gate hit this (frame-1 luma mismatch pinned to
this, grain falsified); the remaining 7 aomenc recipes carried the same
latent flake and are now pinned inside the supported envelope. The
ffmpeg single-frame helper is keyframe-only and unaffected.
fix(av1): sweep --enable-ref-frame-mvs=0 into every aomenc test recipeAhmet Kaan Gümüş · eb24ce5
fix(av1): sweep --enable-ref-frame-mvs=0 into every aomenc test recipe

use_ref_frame_mvs (temporal MV projection) is unimplemented; mvstack
computes zero_mv_ctx/GLOBALMV_OFFSET as if it were off, so any real
aomenc stream with it enabled desyncs the symbol decoder on inter
frames. The film-grain gate hit this (frame-1 luma mismatch pinned to
this, grain falsified); the remaining 7 aomenc recipes carried the same
latent flake and are now pinned inside the supported envelope. The
ffmpeg single-frame helper is keyframe-only and unaffected.
Merge branch 'lane-grainfix'Ahmet Kaan Gümüş · 553118aBrowse files
fix(av1): pin the film-grain gate below use_ref_frame_mvs's unimplemented pathAhmet Kaan Gümüş · 07a8e46
fix(av1): pin the film-grain gate below use_ref_frame_mvs's unimplemented path

real_aomenc_film_grain_streams_decode_pixel_exact's frame-1 mismatch was
never a grain bug: aomenc turns on temporal MV projection
(use_ref_frame_mvs) by default once order hints are enabled, and
mvstack.rs's documented corner-cut always computes zero_mv_ctx and the
mode-context GLOBALMV_OFFSET bit as if it were off, desyncing the symbol
stream from the first NEARESTMV block that inherits a temporal-adjusted
context. Add --enable-ref-frame-mvs=0 alongside this gate's other
disabled features so it isolates grain synthesis as its own comment
already claims, matching every real-aomenc gate's envelope pattern.
Temporal MV projection stays a separate, unimplemented capability.
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.
test(av1): drive the film-grain sweep with the repo aomenc and the supported-envelope recipeAhmet Kaan Gümüş · 4da5dbf
test(av1): drive the film-grain sweep with the repo aomenc and the supported-envelope recipe

The sweep probed bare `aomenc` on PATH (always absent) and so always
skipped; it now uses aomenc_path() like every other gate. The recipe
adopts the forwarding gate's constraint set so the streams stay inside
the decoder's supported envelope, with --tune-content=film as the one
flag under test. At 64x64 the streams now reach the GOLDEN_FRAME
refusal on this branch; the test goes green once the mvstack
extension-pass fix (lane-av1golden8) merges and unmasks GOLDEN.
feat(av1): implement spec 7.18.3 film grain synthesis, flip the refusalAhmet Kaan Gümüş · 84e41d9
feat(av1): implement spec 7.18.3 film grain synthesis, flip the refusal

Port the AR-filtered grain template generation, piecewise-linear scaling
LUT, and 32x32/16x16 tiled overlap-blend application from libaom's
reference synthesis (crates/ec-av1/src/film_grain.rs), wired into
decode_stream's frame-finalize path so the reference bank keeps the
clean pre-grain decode (spec 7.18.3.1) while only the caller's output
picture carries grain.

Header parsing (ec-av1-syntax FilmGrainParams, load_grain_params
ref-slot forwarding) was already spec-complete -- no changes needed
there.

Replaces the apply_grain refusal with a pixel-exact gate against
ffmpeg's own AV1 decoder on the pinned aomenc fixture (frame 0, the
span the original mismatch was traced to; later frames in that fixture
hit an unrelated pre-existing GOLDEN_FRAME MC gap, out of this lane's
scope), plus an aomenc multi-seed sweep gate that skips gracefully
when aomenc is unavailable.
fix(av1): re-mask GOLDEN_FRAME behind the LAST_FRAME refusal arm, pin round-9 residualAhmet Kaan Gümüş · 2e169ef
fix(av1): re-mask GOLDEN_FRAME behind the LAST_FRAME refusal arm, pin round-9 residual

Round 9's own forwarding gate still shows GOLDEN_FRAME motion compensation
mismatching a real aomenc stream once the film-grain refusal is in place
(1/20, frame 3 luma, apply_grain=false). Collapse the GOLDEN_FRAME arm back
into the single LAST_FRAME/_ refusal match so it refuses by name again, and
add an #[ignore]d pinned_golden7_stream_decodes_pixel_exact test (same shape
as golden4's) against the pinned repro fixture for round 10. Also drops the
debug-only probe_env_stream test.