Commits
Commits on
8dbd683068d7f87f21dcc4ed1dfdca786d82c52bFiltered to crates/ec-av1/src/decode.rsClear filter2026-08-28
wip(av1): reduced_tx_set=false inter tx sets -- CDFs + inverse transforms, NOT WIRED YETAhmet Kaan Gümüş · 8dbd683
wip(av1): reduced_tx_set=false inter tx sets -- CDFs + inverse transforms, NOT WIRED YET
Compiles clean; NOT YET reachable from any decode path (dying-words WIP,
budget exhausted mid-lane -- entropy layer is done, threading is not).
What this round did (root cause from r1: cdf_state.rs TxbSet::Luma16Inter/
Luma8Inter hardcode the reduced_tx_set=true 2-symbol table; a real aomenc
stream with reduced_tx_set=false needs wider sets there):
1. Transcribed from /tmp/libaom-src (entropymode.c:369-403, entropymode.h:
169-185, blockd.h:1036-1122, common_data.h:149-159, av1_txfm.h:169-207,
txb_common.h:32-47, aom_dsp/txfm_common.h:52-68):
- av1_ext_tx_set_lookup[is_inter=1][tx_size_sqr==TX_16X16] gives, for a
16x16 inter block, EXT_TX_SET_DTT9_IDTX_1DDCT (12 symbols) -- NOT
DTT4_IDTX_1DDCT as the r1 handoff guessed (right symbol count, wrong
set name); for 8x8 (and 4x4) inter, EXT_TX_SET_ALL16 (16 symbols).
- New cdf.rs tables INTER_TX_TYPE_SET2_16 (TX_16X16 row of
default_inter_ext_tx_cdf[EXT_TX_SET_DTT9_IDTX_1DDCT]) and
INTER_TX_TYPE_SET1_8 (TX_8X8 row of
default_inter_ext_tx_cdf[EXT_TX_SET_ALL16]), transcribed verbatim.
- New cdf_state.rs storage (inter_tx_type_16_set2, inter_tx_type_8_set1),
reset1-wired (adaptation) and seeded from the new cdf.rs tables in
Cdfs::new -- both join the existing reset sweep so a forwarded-CDF
frame carries them too (av1-cdffwd-three-bugs class: nothing here is a
new table left off the forwarding/reset map).
- New TxbSet::Luma16InterSet1/Luma8InterSet1 variants + txb() match arms.
2. Coverage check (tx-class-cross-cutting class, repo memory) -- swept
every libaom array indexed by tx_type/tx_set for the new TxType members
this needs (FLIPADST_DCT, DCT_FLIPADST, FLIPADST_FLIPADST, ADST_FLIPADST,
FLIPADST_ADST, V_ADST, H_ADST, V_FLIPADST, H_FLIPADST -- 9 new variants):
- transform.rs: TxType gained the 9 variants + from_symbol_set2_12 (12-
symbol table, av1_ext_tx_inv[EXT_TX_SET_DTT9_IDTX_1DDCT]) +
from_symbol_all16 (16-symbol, av1_ext_tx_inv[EXT_TX_SET_ALL16]).
- axes(): FLIPADST reads the *same* 1D ADST kernel as ADST (common_data.h
vtx_tab/htx_tab map both FLIPADST_1D and ADST_1D to the identical
butterfly network) -- no new 1D transform to port, confirmed against
av1_inv_txfm2d.c's inv_txfm2d_add_c (lines 234-316): the flip is pure
post-processing (lr_flip reverses which column the column-pass reads,
ud_flip reverses which output row the result lands in), never a
different arithmetic kernel. Added TxType::flip() and rewired
inverse_transform_2d_typed to read from an un-mutated `residual`
buffer into a separate `out` buffer under the flip (the naive in-place
version has a real RAW hazard: for side/2 columns, a flipped write at
iteration j clobbers a source column iteration side-1-j will read
later -- caught before it shipped, not left as a corner-cut).
- decode.rs TxClass::of: V_ADST/V_FLIPADST -> Vert, H_ADST/H_FLIPADST ->
Horiz (txb_common.h's tx_type_to_class table), matching V_DCT/H_DCT's
existing treatment -- coefficient scan/context tables are already
generic over TxClass, not TxType, so no further surface needed there.
- decode.rs read_coeffs: CDF-length dispatch (already the crate's own
idiom, doc'd at the read site) extended from 2-way to 4-way: 17 slots
-> from_symbol_all16, 13 -> from_symbol_set2_12, 8 -> from_symbol_set1,
else -> from_symbol (unchanged 2-/5-symbol sets).
3. NOT DONE (why this is WIP, not a fix): no call site actually threads
reduced_tx_set into TxbSet::Luma16InterSet1/Luma8InterSet1 selection.
decode_inter_frame_tile_with_cdfs (decode.rs:6197) does not even take a
reduced_tx_set parameter -- the entire inter tile path hardcodes the
reduced (2-symbol) inter tables today, unconditionally. Wiring needs:
- reduced_tx_set: bool added to decode_inter_frame_tile/_with_cdfs
(decode.rs:6147/6197) and its caller (stream.rs, frame-header
reduced_tx_set bit -- already parsed for the key-frame/intra path,
needs finding/threading for inter frames too).
- threaded through decode_inter_block (4259) and decode_inter_block8
(5384) as a new parameter, to their four call sites (6399, 6465,
6535, 7307).
- TxbSet::Luma16Inter -> Luma16InterSet1 and Luma8Inter ->
Luma8InterSet1 selection gated on !reduced_tx_set at decode.rs:6484,
7326 (Luma16*) and 5746, 5940 (Luma8*) -- mirroring txbset_for's
existing reduced_tx_set match, but for the inter call sites which
currently have no such helper.
- the pinned repro (cdfflake-stream-seed45.bin) will not go green
until this wiring lands; not run this round since the desync path
is still unreached.
Intra ext-tx (default_intra_ext_tx_cdf) was NOT re-checked for the same
hardcoding this round -- r8's comment (Luma8Set1/Luma4Set1 exist) says
intra's reduced_tx_set split is already handled at 8x8/4x4, and 16x16
intra is DCT_IDTX-set-only regardless of the flag per
av1_get_ext_tx_set_type (`tx_size_sqr == TX_16X16` branch skips the
`use_reduced_set` check for BOTH is_inter values) -- so intra should
already be correct, but this was reasoned, not re-verified against
entropymode.c line by line this round.
Also unaddressed (pre-existing, r1-noted gap): no Luma4Inter path exists
at all in this crate -- an inter TX_4X4 transform (also EXT_TX_SET_ALL16
under reduced_tx_set=false, TX_4X4 row of the same CDF, not yet
transcribed) has nowhere to decode to. Out of this round's scope.wip(av1): root-cause cdfflake-stream-seed45 pin -- reduced_tx_set=false inter tx_type gapAhmet Kaan Gümüş · dcd3feb
wip(av1): root-cause cdfflake-stream-seed45 pin -- reduced_tx_set=false inter tx_type gap Bisected the pinned frame-2 mismatch (cdfflake-stream-seed45.bin, 359/4096 luma px, worst delta 6, right-edge block). Added scratch instrumentation (env-gated, zero behavior change): scratch_dump_prefilt in decode.rs (EC_AV1_PREFILT_DUMP_OURS, mirrors the instrumented aomdec's own EC_AV1_PREFILT_DUMP) and an EC_RNG per-symbol trace in msac.rs (SymbolDecoder::symbol_fixed), matching libaom's aom_dsp/entdec.c format exactly (rng_before/rng_after/nsyms/symbol, shared global counter). Verdict: PIXEL-PATH, not entropy garbage-cascade in the usual sense -- pre-deblock buffers already differ (497/4096 luma mismatches at frame 2, rows 48-63 cols 32-63, exactly the mi(12,8)/mi(12,12) 16x16x2 region), proving the defect is in reconstruction, but the root symbol-level cause IS a real entropy divergence: gdb-bisected via `EC_RNG` + a conditional breakpoint on od_ec_decode_cdf_q15 in the instrumented aomdec build to n=787, which resolves (backtrace) to av1_read_tx_type -> decodetxb.c:read_coeffs_txb, nsyms=12 -- libaom's EXT_TX_SET_DTT4_IDTX_1DDCT, selected by av1_get_ext_tx_set_type(TX_16X16, is_inter=1, use_reduced_set=0) (blockd.h:1097, av1_ext_tx_set_lookup[1][1]). Our decoder read a 2-symbol table (nsyms=2) at the same point instead. Root cause: cdf_state.rs's TxbSet::Luma16Inter (and Luma8Inter) are hardcoded to the *reduced_tx_set=true* 2-symbol EXT_TX_SET_DCT_IDTX table only (doc comments there already say so explicitly); this crate's own writer always emits reduced_tx_set=true so the gap never showed up on a round-trip test. A real aomenc stream with reduced_tx_set=false (this pin) hits an inter 16x16 block whose tx_type this decoder cannot read at all -- it silently misreads a binary CDF where the real bitstream encoded a 12-way EXT_TX_SET_DTT4_IDTX_1DDCT symbol, desyncing the rest of the frame's own coefficient reads (491 more luma reads through the tile) and poisoning the CDFs forwarded into frame 3. Same-shape sibling gaps found by reading av1_get_ext_tx_set_type (NOT yet fixed, name only): 8x8 inter + reduced_tx_set=false wants EXT_TX_SET_ALL16 (16-symbol), also unimplemented (Luma8Inter is likewise reduced-only per its own doc comment). 32x32+/64x64 inter are fine (EXT_TX_SET_DCT_IDTX unconditionally regardless of reduced_tx_set, per blockd.h:1101-1102) -- Luma32Inter's existing 2-symbol table is already correct there. NOT fixed this round (budget): needs a new TxbSet::Luma16InterSet1 (12-symbol CDF, transcribed from libaom entropymode.c default_inter_ext_tx_cdf[EXT_TX_SET_DTT4_IDTX_1DDCT][TX_16X16], + the EXT_TX_SET_DTT4_IDTX_1DDCT symbol->TxType mapping from av1_ext_tx_used/inter table), wired into decode_inter_block's TxbSet selection (currently hardcoded to TxbSet::Luma16Inter at every call site, e.g. decode.rs:6484) gated on `!reduced_tx_set`, and the same for TxbSet::Luma8InterSet1 (16-symbol EXT_TX_SET_ALL16). Dying words: pull default_inter_ext_tx_cdf's 16x16-DTT4_IDTX_1DDCT row (12 probs) and the matching tx_type index table from /tmp/libaom-src/av1/common/av1_entropymode.c + av1/common/enums.h(EXT_TX_SET_DTT4_IDTX_1DDCT symbol order), add the two TxbSet variants + a reduced_tx_set-gated select at every `16 =>` / `8 if reduced_tx_set` dispatch site feeding an inter block, then rerun scratch_isolate_pinned_mismatch on cdfflake-stream-seed45.bin to confirm 4/4 frames byte-exact, then remove scratch_dump_prefilt/EC_RNG (or leave as documented scratch, orchestrator's call), then the cdf-forwarding gate 5x + full ec-av1 --lib suite 3x.
chore(av1): remove bisect scratch instrumentation (SREF/COMPIDX/COMPOUND_DEBUG/r17 dump)Ahmet Kaan Gümüş · d6ab49e
chore(av1): remove bisect scratch instrumentation (SREF/COMPIDX/COMPOUND_DEBUG/r17 dump) Strips the env-gated dump machinery (EC_AV1_SREF_DUMP, EC_AV1_COMPIDX_DUMP, EC_AV1_COMPOUND_DEBUG, BITPOS_BLK_START, IFILTER_RS prints) and the r17_dump frame-counter/PREFILT/POSTFILT scaffolding from decode.rs/stream.rs, plus the three scratch #[ignore] tests that depended on it in stream.rs (scratch_decode_pinned_stream, scratch_dump_compound_idx_cdf_state, scratch_sweep_compound_mismatch). Keeps scratch_isolate_pinned_mismatch and scratch_decode_pinned_stream_once as generic pin-repro tools, GATE_COUNTER_LOCK, the hardened cdf gate, pin fixtures, tile.rs's own EC_RNG trace, and the comp_group_idx==1 wedge/diffwtd refusal untouched.
wip(av1): r6 -- sweep clean, class sweep clean, CURRENT_OP scaffolding removedAhmet Kaan Gümüş · a3b0b8a
wip(av1): r6 -- sweep clean, class sweep clean, CURRENT_OP scaffolding removed Sweep: both wide gates (reference_select, compound_references) 10/10 green, all pixel-exact, no defect found. Old pins re-verified: av1blend- r1-mismatch.obu 24/24 MATCH (already closed by r6/r7's ref_ctx fix, not a new result); cdfflake-stream-seed45.bin still mismatches at frame 2 (359/4096 luma, worst delta 6) -- unrelated cdf-forwarding defect, NOT closed by the mvstack fix. Charter's "comp_group_idx==0 refusal" premise did not match HEAD 8f08e06: only a comp_group_idx==1 (wedge/diffwtd) refusal exists, which is a genuinely-unsupported blend type the charter itself says must stay masked. No comp_group_idx==0/compound_idx refusal exists anywhere in decode.rs -- that path is already live and unmasked, and the sweep confirms it is currently defect-free. Nothing to unmask. Class sweep (neighbour votes all its fields): every remaining site (single_ref/comp_ref/comp_bwdref/uni_comp_ref ctx family, reference_mode_ctx, comp_reference_type_ctx, get_comp_group_idx_context, get_comp_index_context, switchable_interp_ctx, the either-ref filter_ctx checks) already threads both compound slots correctly -- verified against mvstack.rs/decode.rs source, no new bug found. Cleanup (partial, budget-bound): removed msac.rs's EC_RNG trace block and the CURRENT_OP thread_local plus all 102 call sites in decode.rs that set it. tile.rs's separate, older EC_RNG trace (lane-av1truesize, still load-bearing for the encoder side) is untouched -- out of this lane's scope. Still owed: EC_AV1_SREF_DUMP/EC_AV1_COMPIDX_DUMP/ EC_AV1_COMPOUND_DEBUG/BITPOS_BLK_START blocks, r17_dump/ R17_DUMP_FRAME_IDX (EC_AV1_PREFILT/POSTFILT_DUMP), and scratch_* #[ignore] tests beyond the two pin-repro tools -- next round. cargo test -p ec-av1 --lib: 214 passed/0 failed/19 ignored (individual runs); one flaked FAILED in a full-suite run reproduced green in isolation -- pre-existing aomenc-RD-nondeterminism flake class, not a regression from this change.
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): r3 -- r2's ref1 fix real but does not close the pin; isolate to one switchable_interp symbolAhmet Kaan Gümüş · 8cbebd5
wip(av1): r3 -- r2's ref1 fix real but does not close the pin; isolate to one switchable_interp symbol
Pin verdict: r2's neighbour-ref1 filter-ctx fix (b7977cd) is a real, correct
fix but does NOT close fixtures/av1idx-refsel-pin.obu -- 3x repro identical
(149 y mismatches, worst delta 1, frame 8, row 32 col 58). The mismatching
frame (aomdec's frame 8, this decoder's internal r17 index 7) has ZERO
compound blocks -- all 4 32x32 leaves are single-ref -- so the CREF ref1
fix cannot be the cause of THIS fixture's residual defect; keeping it
anyway as an independently-real bug fix.
Isolation (new IFILTER_RS dump, gated EC_AV1_SREF_DUMP, kept as
instrumentation): built an instrumented aomdec (decodemv.c
read_mb_interp_filter, EC_IFILTER_DBG env var, /tmp/libaom-src
decoder-debug target) and traced every switchable_interp read in this
frame. mi(0,0) dir0 (ctx=3) and the next three blocks' reads all decode
identically to aomdec (values AND post-adapt CDF state converted through
AOM_ICDF match byte-for-byte). Exactly one read diverges: mi(0,0) dir1
(ctx=11, the x_filter direction) -- both decoders enter this read holding
the literal default CDF ([27403, 32636, 32768], confirmed against both
crates/ec-av1/src/cdf.rs::SWITCHABLE_INTERP[11] and libaom
entropymode.c's default_switchable_interp_cdf row 11 via the AOM_ICDF
inversion) -- yet we decode symbol=1, aomdec decodes symbol=0 (confirmed
via aomdec's post-adapt CDF shape matching a symbol=0 adaptation, same
direction/magnitude as the confirmed-matching dir0 case).
Matching CDF + matching context + a symbol=0 decode on both sides for the
immediately preceding dir0 read is NOT proof the raw entropy coder
(value/range) state was actually synced entering dir1 -- CDF state is a
pure function of decoded symbols and says nothing about the coder's
internal value/range, so a desync introduced earlier in this exact block
(is_inter, ref_frame, new_mv/zero_mv/ref_mv, or partition reads before
this leaf) that happens to still decode the SAME symbol at dir0 by
coincidence remains a live hypothesis, not ruled out. msac.rs::symbol_fixed
was read against spec 8.2.6 and looks structurally sound; did not find a
defect in it directly, and it is used by thousands of other passing reads
across the suite, making a generic bug there unlikely.
Next step: instrument this crate's own SymbolDecoder value/range
(self.value, self.range) immediately after EVERY symbol read in this
exact block (partition down through mode/mv/ref_frame/is_inter, ahead of
the two interp_filter reads) and diff against an aomdec od_ec_dec trace
of the same (needs a matching dif/rng eprintf added to
av1/decoder/decodemv.c's read path, not just read_mb_interp_filter) --
find the FIRST read in this block where value/range diverges, not just
where a decoded symbol first differs. The mismatching block is
mi_row=8/mi_col=8 (frame's 4th leaf, ref_frame=7) but the diverging
SYMBOL read is on the FIRST leaf mi_row=0/mi_col=0 dir1 -- i.e. the
divergence is a probability-table/entropy-state issue from block 1 that
apparently self-corrects for blocks 2-4's decoded symbol VALUES (all
match aomdec) yet still produces a different final pixel outcome at block
4 -- suggesting the wrong dir1 symbol at block 1 changes block 1's own
x_filter kernel (used for MC) without moving the bitstream position
differently enough to cascade a symbol-level desync, but IS enough to
shift block 4's reconstruction via some other coupling (context array
carrying the wrong filter forward?) -- re-check whether block1's WRONG
x_filter[dir1]=1 (SMOOTH) vs correct 0 (REGULAR) is used as `above_filter`
context for block 3 (mi_row=8,mi_col=0) and beyond, which could
explain why block 4 (not block 1) is where the PIXEL mismatch surfaces
even though block1's own MC output apparently still matched (rows 0-31
all MATCH per the pin's per-plane report).
Instrumented aomdec: /tmp/libaom-src/build/decoder-debug/aomdec, rebuilt
after adding EC_IFILTER_DBG to decodemv.c (patch is outside this repo, in
/tmp/libaom-src, not committed here -- reapply by re-adding the
getenv("EC_IFILTER_DBG") block in read_mb_interp_filter before the
!enable_dual_filter check, then `cd /tmp/libaom-src/build/decoder-debug
&& make -j12 aomdec`).
Class sweep (neighbour-votes-all-its-fields) and the wide-gate unmask are
both DEFERRED to the next round -- the pin still fails, so unmasking the
compound gates would ship an unproven blend again per the r1/r6/r7
history's own lesson.wip(av1): r2 -- interp filter ctx matches neighbour's SECOND ref tooAhmet Kaan Gümüş · 49ec72b
wip(av1): r2 -- interp filter ctx matches neighbour's SECOND ref too get_ref_filter_type: a neighbour votes with EITHER of its two references (record_compound_ctx supplies the real second ref); ref0-only matching dropped real filter matches to the no-neighbour sentinel. Second instance of the neighbour-votes-all-its-fields class. Dying words: checking whether the per-OBU loop's local header is stale/different vs the header used elsewhere for the same frame.
fix(av1): switchable_interp compound-block ctx offset; re-pin second compound_idx defectAhmet Kaan Gümüş · 3ab7e16
fix(av1): switchable_interp compound-block ctx offset; re-pin second compound_idx defect Fix (real, spec-verified): switchable_interp_ctx never folded in libaom's INTER_FILTER_COMP_OFFSET (av1_get_pred_context_switchable_interp, pred_common.c) for a block that itself has a second reference -- a stale "this decoder never codes a compound reference" doc comment baked the offset to always-0. resolve_interp_filter now takes is_compound and adds +4 to the CDF context bucket for the compound leaf16 call site only (the single-ref leaf16 call site passes false; leaf8 still never resolves a switchable filter at all -- pre-existing documented corner-cut, out of scope this round). Bisect (lane-av1idx r1): unmasked both comp_group_idx==0 refusals locally, looped a_real_aomenc_stream_with_reference_select_reads_comp_mode_correctly with EC_AV1_GATE_DUMP until a mismatch pinned (seed 61) -> fixtures/av1idx-refsel-pin.obu. Confirmed deterministic 3x via scratch_isolate_pinned_mismatch. First divergence: decode-order frame 8 (the stream's one Switchable-interpolation-filter frame), small deltas (worst 1-2), 149-299 luma px, propagating through frames 9-12 via DPB reference before frames 13-19 return to MATCH -- consistent with a wrong CDF context bucket (occasional wrong bit) rather than a hard desync. Re-tested the pinned fixture after the ctx-offset fix: mismatch UNCHANGED (same frame, same deltas) -- this fix is real and kept, but does not explain this fixture's defect. A second, still-unfound compound_idx bug remains. Re-masked both refusals (still non-pixel-exact beyond the two bugs now fixed across lane-av1blend r6/r7 + this round). Next step: scratch_isolate_pinned_mismatch already narrows it to frame 8's own decode or an upstream DPB slot corruption reaching it -- bisect frame 8's tile decode (EC_TOK/EC_PART trace vs instrumented aomdec) now that the fixture is small (501 bytes, 20 frames of 64x64) and cheap to iterate on. Both wide gates green (legal named refusal), cargo test -p ec-av1 --lib --skip aomenc: 196 passed/0 failed/19 ignored.
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.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.
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.
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).
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).
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): 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.
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): temporal MV wiring + gate — r2 capped at final compile checkAhmet Kaan Gümüş · 253fdd8Browse 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.
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.
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.
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.
fix(av1): gate switchable_interp neighbour ctx by ref_frame, keep GOLDEN_FRAME maskedAhmet Kaan Gümüş · 71a371f
fix(av1): gate switchable_interp neighbour ctx by ref_frame, keep GOLDEN_FRAME masked resolve_interp_filter fed a block's above/left filter context straight from Neighbours regardless of which reference frame each neighbour coded -- a different-ref neighbour's filter choice was corrupting the symbol read for this block's own filter, instead of reading as unset ([3,3], the same sentinel intra neighbours already produce). Gate both above_filter and left_filter on above_ref/left_ref matching this block's ref_frame. Round 8's GOLDEN_FRAME unmask attempt with this ctx fix still produces a real mismatch: a golden gate run 20x reproduces a frame-0 (intra keyframe) luma diff against ffmpeg whenever GOLDEN_FRAME actually fires later in the same stream (seeds 57, 59, both live-reproduced). The ctx fix itself is not the cause -- decode_inter_block8 never resolves switchable_interp context at all (it refuses non-LAST_FRAME before reaching any filter code), so this bug is golden-adjacent elsewhere, unproven past that. GOLDEN_FRAME stays a named refusal; added the same EC_AV1_GATE_DUMP pin-on-mismatch pattern the CDF forwarding gate already has to the golden gate test, and captured the reproducing stream for the next round.
2026-08-27
fix(av1): clear apply_deblock for the GOLDEN residue, isolate to MCAhmet Kaan Gümüş · c672fef
fix(av1): clear apply_deblock for the GOLDEN residue, isolate to MC Bisected the pinned 3-pixel GOLDEN-live residue against a patched aomdec's pre/post-loop-filter frame dumps: our own decoder's luma is already wrong at those exact 3 pixels before apply_deblock runs, byte- identical to the loop filter's post-filter mismatch -- the wide deblock kernel (round 6's suspect) is cleared. All 3 pixels sit inside one skip=1 32x32 GOLDEN_FRAME NEWMV block, mv=(-7,-7) 1/8-pel (both axes fraction 2/16), REGULAR/REGULAR resolved filter -- pure MC output, no residual. The golden reference bytes that block reads are already proven bit-exact (frames 0-2 match ffmpeg), so the defect is inside mc::predict_with_filters's 2D convolution or filter-symbol resolution for this exact combination, not yet isolated further this round. Re-masked with an updated round-7 comment recording the bisect.
fix(av1): re-derive the GOLDEN_FRAME loop-filter residue, re-mask with a pinAhmet Kaan Gümüş · d02f017
fix(av1): re-derive the GOLDEN_FRAME loop-filter residue, re-mask with a pin Un-masked decode_inter_block's GOLDEN_FRAME arm this round and re-ran the forwarding + golden-reference gates: two real aomenc streams mismatched (30-run forwarding gate: 4/30 real failures, all a real aomenc GOLDEN stream, not the documented flake). Pinned one (seed 43, frame 3 luma) as stream::tests::pinned_golden4_stream_decodes_pixel_exact (#[ignore]d) and traced it: 3 of 4096 luma pixels off by exactly +-1, all inside the loop filter's edge window at a GOLDEN_FRAME/LAST_FRAME block boundary. Hand- checked lf_level's ref_deltas/mode_deltas arithmetic against spec 7.14.4 at that edge -- it matches the default table exactly, so the residue is still open: a narrow deblock-kernel rounding defect, or a golden-side pixel one filter tap upstream. Re-narrowed the mask (decode_inter_block's GOLDEN_FRAME arm refuses by name again) and reverted a_hand_built_golden_reference_refuses_by_name to its refusal-asserting form -- no fix proven this round, but the pinned fixture and the narrowed-down suspect (deblock edge, not lf_level's own math) carry forward.
fix(av1): GLOBALMV loop-filter mode delta; mask GOLDEN behind its stacked defectAhmet Kaan Gümüş · ef03524
fix(av1): GLOBALMV loop-filter mode delta; mask GOLDEN behind its stacked defect lane-av1golden2 round 5. The round-4 GOLDEN flip's hand-built fixture proved the symbol path and a whole-pel skip copy -- the first real aomenc GOLDEN streams through the live arm mismatched. Symbol-trace vs a patched aomdec isolated one cause on the LAST_FRAME-reachable side: lf_level applied mode_deltas[1] to every inter block, but spec 7.14.4's mode_lf_lut maps GLOBALMV to mode_deltas[0]. Fixed by packing the GLOBALMV bit into ref_grid's sign; that moved the forwarding gate's failure from seed 42 frame 1 to seed 48 frame 3 -- at least one more stacked defect on the GOLDEN-live path, so the GOLDEN arm narrows back to a named refusal (threading kept, unread) and the hand-built fixture now asserts the mask by name instead of pixel exactness. A rare (~1/10..1/30) all-LAST mismatch on the forwarding gate remains reachable even with the mask -- present with semantics identical to the previously pushed baseline -- pinned as this lane's next round.
feat(av1): flip the GOLDEN_FRAME refusal, proven by a hand-built OBU fixtureAhmet Kaan Gümüş · 5fb6ee3
feat(av1): flip the GOLDEN_FRAME refusal, proven by a hand-built OBU fixture 120+ real aomenc attempts never produced a decodable stream that fired GOLDEN_FRAME before hitting an unrelated refusal first. A hand-built 3-frame stream (real key frame; a hand-coded intra "different content" frame refreshing LAST_FRAME's slot; a hand-coded frame whose lone block codes single_ref out to GOLDEN_FRAME and a skip zero-MV NEARESTMV) drives decode_stream directly and is cross-checked against ffmpeg's own decode of the identical wire bytes, 4 consecutive runs. decode_inter_block now threads GOLDEN_FRAME to the golden_y/u/v planes already passed to it instead of refusing every non-LAST_FRAME reference; LAST2/LAST3/BWDREF/ ALTREF2/ALTREF still refuse, unproven. intra_inter_ctx made pub(crate) so the fixture can compute the exact context the decoder does.
guard(av1): GOLDEN decode stays refused until a stream proves it liveAhmet Kaan Gümüş · ed5f4c7
guard(av1): GOLDEN decode stays refused until a stream proves it live The full single-non-LAST implementation stays (reference tree, MC threading, mvstack filter, deblock ref deltas), but decode_stream refuses GOLDEN narrowly again: 120 recipe attempts never produced a decodable stream that actually fires the path, and an accepted-but- unproven decode is the silent-miscode shape this repo does not ship. The gate documents the refusal and the firing hunt continues.
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): use the drl-selected stack entry as NEWMV's base predictorAhmet Kaan Gümüş · f5ee53b
fix(av1): use the drl-selected stack entry as NEWMV's base predictor
decode_inter_block's NEWMV arm read the drl_mode bit (when the stack has
more than one entry) but discarded it and always based the predicted MV
on stack.entries[0] -- spec 5.11.24's read_drl_idx picks RefMvIdx via up
to two drl_mode reads, and 7.10.2.10's assign_mv bases NEWMV's PredMv on
entries[RefMvIdx], not always entry 0. Ported the same idx-selection loop
NEARMV already had (mirrored in both NEWMV arms: decode_inter_block and
the leaf8 decoder). Confirmed against a patched aomdec (read_drl_idx
trace) that libaom reads the identical number of drl bits per NEWMV
stack size -- the desync was purely which entry we fed to read_mv.
Verified against the round's pinned 4-frame stream (seed 44): frames 0-2
now decode pixel-exact against ffmpeg/aomdec (frame idx2 was the
decisive divergent case -- mi_row=4,mi_col=8 NEWMV column now matches).
Frame 3 (and the pre-existing a_real_aomenc_inter_sequence_with_cdf_
forwarding flake) still mismatches -- traced to a second, real defect:
mvstack.rs's IMMEDIATE_WEIGHT=2-per-cell approximation is only tied
between above/left neighbours for the fixed bw4==bh4==8 caller the
module doc assumes (tile.rs); decode.rs calls find_mv_stack with the
leaf's real (smaller/mixed) block size, where libaom's real weight
formula (`len * max(2, inc)`, scan_row_mbmi/scan_col_mbmi,
mvref_common.c) is *not* tied -- confirmed live against a patched
libaom at mi_row=4,mi_col=8/frame 3: real weights 660 vs 668 (raw 20 vs
28), ours ties both at 8, giving the wrong stack order and hence the
wrong DRL-selected entry despite an identical drl_mode bit value. This
is the module doc's own predicted gap ("A caller with mixed block sizes
would need the real weight formula; none exists today") now confirmed
reachable and needs a dedicated port of the real weight formula --
follow-up lane, not attempted here (budget).fix(av1): give intra prediction its real neighbour reach, twenty call sitesAhmet Kaan Gümüş · 0c4687e
fix(av1): give intra prediction its real neighbour reach, twenty call sites Twenty decode call sites passed Reach::none() where the block's actual top-right/bottom-left availability belonged, so directional prediction fell back to replicated corner samples wherever the true neighbours existed. Found by three-checkpoint bisect (pre-deblock/between-passes/ post-deblock) against an instrumented aomdec: the deblock-corner hypothesis died there -- the divergence entered with prediction's edge array after all. The directional-chroma gate now fires and passes 4/4; the full suite is green. The rare cross-frame chroma ±1 flake remains (1/10 runs) -- a separate open defect, not masked here.
feat(av1): implement the intra edge filter/upsample (spec 7.11.2.7-2.9)Ahmet Kaan Gümüş · 645882d
feat(av1): implement the intra edge filter/upsample (spec 7.11.2.7-2.9) r5 left directional()'s edge filter/upsample as an unimplemented corner-cut and left the two new predict() bool params half-plumbed (encode.rs call sites done, stream.rs/decode.rs test-module sites missing). This round: - finished the plumbing: decode.rs threads the sequence header's enable_intra_edge_filter through a thread-local (ENABLE_EDGE_FILTER, set once per decode_key_frame_tile_with_cdfs call, not per-block -- documented why a thread-local beats touching two dozen call sites) down to PlaneBuf::reconstruct's predict() call; stream.rs sets it from the parsed seq header; encode.rs sites already passed false (our encoder never turns it on, so round-trips stay bit-green regardless). - filter_intra_edge (5-tap kernel, 3 strength buckets via intra_edge_filter_strength's two smooth/non-smooth threshold tables), the filter_corner blend, and upsample_intra_edge (av1_upsample_intra_edge_c) were transcribed against libaom's reconintra.c and wired into directional()'s z1/z2/z3 walk (base/shift math doubled for the upsampled-density case). All present, none stubbed. - flipped the gate's --enable-intra-edge-filter=0 to =1 so a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact actually exercises the new path instead of the disabled one. The gate still fails, but NOT from this filter: patched-aomdec cross-checks (EC_UDUMP dqcoeff/pred/recon dumps, /tmp/libaom-src's decodeframe.c, not committed) prove the failing TU (chroma cpx=0/cpy=0, DC_PRED, tx_type DctDct, skip=1 both sides) reconstructs bit-identically pre-loop-filter in both decoders -- flat 128 either way, edge filter inapplicable there (no real neighbours, corner-filter's 2n>=24 gate doesn't fire at n=8). A PREDEBLOCK/POSTDEBLOCK trace (also not committed) localizes the actual divergence to apply_deblock: our decoder introduces a value our own pre-filter data does not justify at the row6-9/col6-9 TU-corner intersection, where both a horizontal and a vertical deblock edge are filtered back to back. r4/r5's "intra edge filter gap" and "tx_type path" suspects are both now falsified for this failure; the next round's target is deblock_plane's edge-intersection order/read-back (vertical-then-horizontal at a corner where an already-filtered vertical sample feeds the horizontal filter's taps). Suite: 174 passed, 1 failed (the known gate above) -- no regression from r5's own checkpoint of the same numbers; the cdffwd flake did not fire this run.
wip(av1): chroma tx_type derivation from Intra_Mode_To_Tx_Type, wires default_tx_typeAhmet Kaan Gümüş · 637d48a
wip(av1): chroma tx_type derivation from Intra_Mode_To_Tx_Type, wires default_tx_type read_coeffs already carried a default_tx_type parameter from a prior round; both call sites (read_plane's intra path and read_inter_plane's inter path) didn't pass it yet, so the tree didn't compile. Wires them: - read_plane (intra): plane_idx==0 or side>=32 -> DctDct (av1_get_tx_type, blockd.h: 64-and-up is unconditional, 32x32 chroma survives intra_mode_to_tx_type only to be re-forced by EXT_TX_SET_DCTONLY gating in av1_get_ext_tx_set_type); otherwise chroma takes default_intra_tx_type(predict_mode), a from-libaom transcription of intra_mode_to_tx_type's static table (D45_PRED is DCT_DCT, not an ADST mode -- transcribed exactly, no set-membership fallback needed since every entry the table can produce (DCT_DCT/ADST_DCT/DCT_ADST/ADST_ADST) is already inside both TX_SET_INTRA_1 and _2). - read_inter_plane: always DctDct -- Intra_Mode_To_Tx_Type only applies to an intra block's chroma plane per av1_get_tx_type's own is_inter branch. Cross-checked against a live patched aomdec (EC_CHROMA_TXTYPE trace in /tmp/libaom-src/av1/decoder/decodetxb.c, not committed here) on the lane's own seed-42 aomenc fixture: every uv_mode -> tx_type pair libaom picked for this stream's chroma matches default_intra_tx_type exactly. Suite: 174 passed, 1 failed (the new a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact) -- NOT the pre-existing cdffwd flake. Confirmed the failure predates and survives this fix: reverting default_tx_type to always-DctDct made the mismatch start at pixel row 0 (whole-plane wrong); with this fix it starts at row 6 and grows outward in a triangular fan, meaning the tx_type choice is not itself wrong (matches libaom's own choice byte-for-byte) but something downstream of it -- reconstruction/ directional-prediction propagation -- still diverges. Left failing, not silenced or adjusted, for the next round to chase with the two named suspects (intra edge filter gap, this tx_type path) now narrowed to one.
Merge branch 'lane-av1tx4': TX4 luma decode and the 1D transform classesAhmet Kaan Gümüş · 843a5a8
Merge branch 'lane-av1tx4': TX4 luma decode and the 1D transform classes Seven rounds: TX4 coefficient tables (transcription cross-verified), V_DCT/H_DCT scan orders and the class-split eob_pt CDF, the leaf8 scan-table fix, and a gate that fires the class-1 path on real aomenc bytes and decodes pixel-exact. The tx-class lesson: a transform class is a cross-cutting dimension -- scan, eob table, and context each carry it.
feat(av1): gate the V_DCT/H_DCT class-1 path on real aomenc bytesAhmet Kaan Gümüş · 5147651
feat(av1): gate the V_DCT/H_DCT class-1 path on real aomenc bytes The sub-8 refusal verdict, the fixture recipe, and a tx_class1_hits counter: a min/max-partition-8 horizontal-stripe stream fires H_DCT through the class-split eob path and decodes full-frame pixel-exact vs ffmpeg, 4/4 runs.
fix(av1): TX4/TX8 eob_pt CDF is class-split (V_DCT/H_DCT vs 2D)Ahmet Kaan Gümüş · ea55462
fix(av1): TX4/TX8 eob_pt CDF is class-split (V_DCT/H_DCT vs 2D)
libaom's av1_default_eob_multi{16,64}_cdfs carry a [2] dimension this
decoder never read: TX_CLASS_2D vs TX_CLASS_HORIZ/VERT. Read order
(all_zero -> tx_type -> eob) verified against decodetxb.c's
read_coeffs_txb; the class-1 tables transcribed from token_cdfs.h and
checked value-for-value. Wired only where TX_SET_INTRA_1 (the 7-type
set carrying V_DCT/H_DCT) is reachable: Luma4/Luma4Set1/Luma8/Luma8Set1.
Verified: full ec-av1 suite green (172 passed), and a synthetic
8x8-partition intra stream now exercises H_DCT (tx_type=3) through
read_eob's class1 branch without desyncing before an unrelated,
pre-existing refusal later in the same frame (small-partition support
is a separate gap, not this one).
Removed the scratch probe_tx4.rs example used to drive this check.fix(av1): V_DCT/H_DCT coefficient scan order + TX4 leaf8 scan table mixupAhmet Kaan Gümüş · 700543b
fix(av1): V_DCT/H_DCT coefficient scan order + TX4 leaf8 scan table mixup Two real desync causes past r3's tx-class context-derivation fix: 1. read_coeffs always read coefficients in the default zigzag scan regardless of tx_type. libaom's V_DCT/H_DCT classes use Mrow_Scan/ Mcol_Scan instead (scan.c av1_scan_orders index 10/11) -- decoded here as class_scan_table: V_DCT's class-scan is our grid's own natural row-major order (0..N), H_DCT's is that walk transposed. base_ctx/br_ctx's row/col-offset formulas (r3's fix) were already correct; only the scan order feeding position/row/col into them was wrong. 2. decode_leaf8's TX4 split loop (an 8x8 leaf's tx_depth=1 case) read its four 4x4 luma transform units with `scans.0` -- the leaf's own *8x8* scan table (64 entries) -- instead of `scans.1` (the 4x4 table), so `pos` values up to 63 got written into a 16-cell grid. Pre-existing bug, only reachable/visible once (1) stopped eating the stream earlier. 5-scale probe (examples/probe_tx4.rs, /tmp/tx4work/s*.obu) moved past every prior refusal point to new, later ones (scale 1.5 now refuses on "a directional chroma mode (round 2)" instead of an angle_delta/partition desync) -- real progress, not yet clean; next round needs the same trace-correlation to chase the remaining divergence(s). Suite green 172/172.
feat(av1): interpolation filters beyond REGULAR, incl. per-block SWITCHABLEAhmet Kaan Gümüş · 10f24e6
feat(av1): interpolation filters beyond REGULAR, incl. per-block SWITCHABLE The ~13% decodes-but-wrong inter flake was a whole missing filter family: motion compensation always used the REGULAR subpel tables, while real encoders pick SMOOTH/SHARP per frame -- or SWITCHABLE, reading a per-block filter symbol pair this decoder never read (the silently-unread class again; our own encoder writes one fixed filter). All four table sets land in mc.rs with an aomdec-pinned unit test, the switchable_interp CDFs and neighbour context follow libaom's read_mb_interp_filter, and the filter threads from the frame header through both inter block paths. The forwarding gate ran 10/10 with zero pixel mismatches and no vacuous skips.
feat(av1): the seven-type TX_SET_INTRA_1 tx_type row, V_DCT/H_DCT, gate firesAhmet Kaan Gümüş · 2411791
feat(av1): the seven-type TX_SET_INTRA_1 tx_type row, V_DCT/H_DCT, gate fires A reduced_tx_set=0 frame's 8x8-and-under intra transforms read tx_type from the seven-symbol TX_SET_INTRA_1, not the five-symbol reduced row our tables carried (the row-held-constant class, on the tx-set dimension -- our own encoder always writes reduced_tx_set=1, the same writer-never-needs-it trap as mv_hp). New set-1 CDF row, the set-1 symbol order from av1_ext_tx_inv, and the V_DCT/H_DCT inverse transforms (one-axis DCT, identity on the other). The tx-select gate now actually FIRES: mandelbrot content at min-partition 16 splits 16x16 blocks into TX8 TUs that read the set-1 rows and decode pixel-exact vs ffmpeg, 4/4 runs, no skips. Resolved 4x4 luma stays a named refusal (no TX4 coefficient tables yet).
wip(av1): finish the txb_skip 7-context rewire; find TX16 tx_type mismatchAhmet Kaan Gümüş · dcf1147
wip(av1): finish the txb_skip 7-context rewire; find TX16 tx_type mismatch Adds the luma_skip_ctx debug trace and a partition_w16 trace print (both gated behind EC_AV1_TRACE) used to bisect the pinned mb.obu stream against a fprintf-instrumented aomdec build. The 7-context txb_skip rewire itself (cdf.rs/cdf_state.rs/decode.rs, prior round) compiles and the whole ec-av1 suite is green, but the pinned stream still desyncs: tracing symbol-by- symbol against real aomdec's EC_TXBCTX/EC_TXBSKIP/EC_TXTYPE_VAL output shows the two decoders already disagree on a NON-split 16x16 block's own tx_type (mi_row=4,mi_col=0 in the second superblock quadrant: real reads tx_type=3 off a reduced 5-symbol intra set, txs_ctx=2/tx_set_type=2/eset=2; ours reads tx_type=2) -- upstream of the txb_skip multi-TU logic this round targeted, and not fixed by it. tx_size_context/get_txb_ctx_general/ SKIP_CONTEXTS were all checked byte-for-byte against libaom's av1/common/txb_common.h and match. The gate (a_real_aomenc_intra_stream_with_tx_select_decodes_pixel_exact, stream.rs) is not wired to this recipe: it still passes today only via its own soft-skip path (every attempt either refuses or never resolves a split tx_depth), so wiring it now would just turn a silent skip into the same real failure traced above. Left unwired until the tx_type mismatch is fixed.