COMPILES. Does not fix the pin (still mismatches). round 2 of lane-comppin,
capped at budget -- leaving the decisive lead + instrumentation for round 3.
WHAT THIS ROUND RULED OUT (all re-verified against libaom source, all correct):
- mc.rs predict_compound_intermediate/combine_compound: CONV_BUF-domain i32
intermediates, round2 offsets, INTER_ROUND_1_COMPOUND=7/INTER_POST_ROUND=4/
DIST_PRECISION_BITS=4 all match av1_dist_wtd_convolve_2d_c bit-for-bit
(already landed pre-r1, re-audited this round, still correct).
- compound.rs dist_wtd_comp_weight_assign: QUANT_DIST_WEIGHT/LOOKUP_TABLE
match libaom's reconinter.c/common_data.h row-for-row.
- decode.rs get_comp_index_context / get_comp_group_idx_context: match
pred_common.c av1_get_comp_index_context/av1_get_pred_context_comp_group_idx
line for line, including the single-ref ALTREF_FRAME special case
(Neighbours::record_inter's altref bit at decode.rs ~1028-1032).
- reference_mode_ctx (mvstack.rs ~1876): matches av1_get_reference_mode_context
exactly, including the has_second_ref asymmetric branches.
- read_skip_mode_params (ec-av1-syntax/src/frame.rs:1644): matches spec 5.9.22's
skipModeAllowed forward/backward-ref search verbatim.
THE ACTUAL DEFECT (new this round): decode-order frame 1 of the pin
(sb128-compound-refs-flake.obu, EC_AV1_PIN_N=24) is 4x 32x32 leaves, all
identical: ref0=LAST(1) ref1=ALTREF(7 or 5), mv=(0,0)/(0,0), mode
NEAREST_NEARESTMV, compound_idx=1 (plain average) -- EVERY block reads
skip_mode=true (added EC_AV1_COMPIDX_DUMP trace at decode.rs ~5017/~6022,
EC_PRECOMP trace at ~4671 dumps skip_mode/skip/reference_select/tell before
the comp_mode read).
Cross-checked against a real instrumented aomdec (rebuilt
/tmp/libaom-src/build/decoder-debug/aomdec with a `mbmi->compound_idx` field
added to decodemv.c's existing EC_TRACE fprintf ~1671-1685, since the prior
round's patch only traced comp_group_idx not compound_idx): the REAL
bitstream's frame 1 block (0,0) is `ref=(1,-1)` -- SINGLE reference LAST_FRAME,
real coded MV (-2,-8) in 1/8-pel, skip_mode is NEVER forced there. Any true
skip_mode block would be forced compound by spec 5.11.24 -- a single-ref
result at that block proves the real bitstream's skip_mode bit read false
there, not true.
skip_mode_present (the frame-level bit, spec 5.9.22) is very likely read
correctly -- header fields after it (force_integer_mv, primary_ref_frame,
etc, dumped for all 24 frames by the existing scratch_isolate_pinned_mismatch
test) look sane and stay sane for the rest of the stream, which would not
survive a header-level bit-count desync this early. So the bug is specific to
the PER-BLOCK skip_mode symbol read at decode.rs ~4623 (skip_mode_ctx =
above_skip_mode[c] + left_skip_mode[r], SKIP_MODE cdf table cdf.rs:1206):
`SKIP_MODE = [[32621,32768,0], [20708,32768,0], [8127,32768,0]]` (verified
byte-identical to libaom's default_skip_mode_cdfs) means ctx=0 (both
neighbours false, true at any tile's mi_row=0/mi_col=0 corner if Neighbours
resets its skip_mode arrays per frame) has ~99.6% weight on skip_mode=false
-- decoding true there, then AGAIN at (0,8)/(8,0)/(8,8) (all four leaves of
the frame, tell values repeating 8/16/24 across MANY of the 24 frames, not
just frame 1) is not plausible as a correctly-drawn symbol from that CDF. The
leading hypothesis: `Neighbours::above_skip_mode`/`left_skip_mode` are stale
(not reset per frame, or reset at the wrong granularity) so skip_mode_ctx is
NOT actually 0 at (0,0) despite no real neighbour existing yet -- OR the same
DPB/ref_frame_idx bookkeeping the r1-era av1blend investigation already
flagged (ref_slots/refresh_frame_flags) is corrupting `skip_mode_frame`'s
own reference *pair* (LAST vs ALTREF/BWDREF getting mixed up across frames --
note ref1 alternates 7/5/4 across frames in the EC_COMPIDX dump, tracking
DPB slot churn) even when the boolean itself is right.
UPGRADE PATH for round 3, in order:
1. Print skip_mode_ctx (not just skip_mode) at every read (the second Edit
attempt this round hit "2 matches, use replace_all" on the identical
leaf16/leaf8 skip_mode block -- disambiguate by including the `skip_ctx`
line that follows, which differs between the two call sites) and confirm
ctx is really 0 at (0,0) of frame 1. If ctx != 0, the neighbour-array
reset is the bug (grep Neighbours::new / wherever it's re-constructed
per frame in decode_stream, stream.rs).
2. If ctx IS 0 and the symbol still reads 1, instrument SymbolDecoder::symbol
itself (msac.rs) to dump (cdf_before, symbol_read, rng, value) for this
ONE call across frames 1-3 and diff against a fresh COMPIDX_BLK-style hook
in decodemv.c's own skip_mode read (~line before 1656 in
/tmp/libaom-src/av1/decoder/decodemv.c -- not yet added, do this first).
3. Only after (1)/(2) rule out a local read bug: chase the DPB/ref_frame_idx
bookkeeping the ref1=7/5/4 churn hints at (stream.rs's ref_slots /
refresh_frame_flags, same suspect the pre-existing decode.rs ~4832-4845
comment already named for a different fixture).
Gates a_real_aomenc_stream_with_compound_references_decodes_pixel_exact /
_reference_select_ NOT yet given the self-pin-on-failure treatment (step 4 of
the charter) -- deferred to round 3, no budget left this round.
Instrumented aomdec debug build lives at
/tmp/libaom-src/build/decoder-debug/aomdec (not repo-tracked, rebuild with
`make -j12 aomdec` there if it goes stale); its decodemv.c EC_TRACE fprintf
now also carries mbmi->compound_idx.