forge
Explore
Log in

Don't you dare go Hollow

The compound 8x8 leaf voted its reference-frame CDFs off a hard-coded LAST_FRAME and cleared both per-slot is_global_mv_block flags -- entropy on the dual-filter/OBMC 8x8 stream is now range-exact end to end

Browse files at this commit

db58f21c581fa11aff1fd6a46e1cac9381b68b11Ahmet Kaan GümüşParent: c9ff494
  • fix
    • the compound 8x8 leaf voted its reference-frame CDFs off a hard-coded LAST_FRAME and cleared both per-slot is_global_mv_block flags -- entropy on the dual-filter/OBMC 8x8 stream is now range-exact end to end
Show full message
fix(av1): the compound 8x8 leaf voted its reference-frame CDFs off a hard-coded LAST_FRAME and cleared both per-slot is_global_mv_block flags -- entropy on the dual-filter/OBMC 8x8 stream is now range-exact end to end

Two twin-function drifts in `decode_inter_block8`'s COMPOUND arm, both found by a
phase-by-phase diff against `decode_inter_block` plus an msac RANGE ladder vs the
instrumented aomdec (class twin-functions-drift, memory adjacent-same-typed-args):

1. `read_compound_ref_frames` was passed `LAST_FRAME` for any inter neighbour and
   `-1` otherwise -- the old "coarse LAST_FRAME-or-intra" approximation -- while the
   side bands have carried the neighbour's REAL reference per mi since lane-inter8 r2.
   Every `av1_collect_neighbors_ref_counts` vote (uni_comp_ref_p1, comp_ref,
   comp_bwdref, ...) came off the wrong CDF row: the first compound 8x8 leaf of the
   pinned 5-frame stream decoded (LAST, LAST2) where aomdec reads (LAST, GOLDEN).
   Now passes `above_ref0`/`left_ref0`, the same two args `decode_inter_block` passes.

2. The leaf's grid stamp wrote `is_global_mv0: false, is_global_mv1: false`
   unconditionally, while `decode_inter_block`'s compound arm computes libaom's
   PER-SLOT `is_global_mv_block` (blockd.h:421-429). A neighbour carrying the flag
   makes `setup_ref_mv_list` substitute the READER's global mv for the neighbour's
   stored one, so the next block's stack held a stored mv where libaom has the global
   candidate -- 3 entries vs libaom's 2 at the 8x8 leaf mi (8,8), a different mv and
   a desync one block later.

Also: the leaf's single-ref arm now prints the same per-entry `EC_STACK` ladder
`decode_inter_block` prints (that is how (2) was isolated).

Gate `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` stays
ignored, on a NEW and much smaller failure: the whole 16-frame stream now parses and
all 570 mode elements match aomdec's range line for line; what remains is a luma-only
reconstruction residue (|delta| <= 8) from decode frame 7.
crates/ec-av1/src/decode.rsmodified+29 -2
@@ -19406,6 +19406,22 @@ fn decode_inter_block8(
1940619406 SCALED_BLOCK8_HITS.with(|c| c.set(c.get() + 1));
1940719407 }
1940819408
19409+ // lane-interp3 r2 (class twin-functions-drift): both slots
19410+ // used to be stamped `false`, while [`decode_inter_block`]'s
19411+ // compound arm computes libaom's PER-SLOT `is_global_mv_block`
19412+ // (blockd.h:421-429 -- mode GLOBAL_GLOBALMV, block >= 8x8
19413+ // (always true for this leaf) and THAT slot's own gm model >
19414+ // TRANSLATION). A neighbour carrying the flag makes
19415+ // `setup_ref_mv_list` substitute the READER's global mv for
19416+ // the neighbour's stored one, so a cleared flag fed the next
19417+ // block's stack a stored mv where libaom has the global
19418+ // candidate -- a wrong mv stack, wrong mode contexts, and a
19419+ // desync one block later.
19420+ let is_globalmv_c = compound_mode == 6;
19421+ let is_global_mv0_c = is_globalmv_c
19422+ && global_motion[(ref0 - LAST_FRAME) as usize].model as u8 > 1;
19423+ let is_global_mv1_c = is_globalmv_c
19424+ && global_motion[(ref1 - LAST_FRAME) as usize].model as u8 > 1;
1940919425 for dr in 0..2 {
1941019426 for dc in 0..2 {
1941119427 grid.set(
@@ -19420,8 +19436,8 @@ fn decode_inter_block8(
1942019436 is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7),
1942119437 size: 2,
1942219438 size_h: 2,
19423- is_global_mv0: false,
19424- is_global_mv1: false,
19439+ is_global_mv0: is_global_mv0_c,
19440+ is_global_mv1: is_global_mv1_c,
1942519441 },
1942619442 );
1942719443 }
@@ -19723,6 +19739,17 @@ fn decode_inter_block8(
1972319739 &gm_table,
1972419740 tpl,
1972519741 );
19742+ // lane-interp3 r2: same per-entry EC_STACK ladder
19743+ // [`decode_inter_block`]'s single-ref arm prints, so this leaf's stack
19744+ // diffs line for line against the oracle's.
19745+ if std::env::var_os("EC_TRACE_MODE").is_some() {
19746+ for (i, e) in stack.entries.iter().enumerate() {
19747+ eprintln!(
19748+ "EC_STACK mi_row={mi_row} mi_col={mi_col} ref={ref_frame} i={i} this=({},{}) comp=(0,0) w={}",
19749+ e.mv.0, e.mv.1, e.weight
19750+ );
19751+ }
19752+ }
1972619753
1972719754 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
1972819755 let mut is_globalmv = false;
crates/ec-av1/src/stream.rsmodified+16 -13
@@ -6312,19 +6312,22 @@ mod tests {
63126312 /// arrived: a compound 8x8 leaf that really read the filter, a block whose
63136313 /// two dual-filter directions DIFFER (impossible with dual filter off),
63146314 /// and an 8x8 OBMC blend.
6315- // lane-interp3 r1: RED, and ignored rather than deleted -- MEASURED, not
6316- // assumed. At `EC_INTERP3_FRAMES=4` (the other arms' length) aomenc codes
6317- // no compound block at all and the stream decodes; from 5 frames on it
6318- // does, and the decode then stops at "an inter 16x16-level AB or 1:4
6319- // partition" WITH this round's filter read and at "an inter partition
6320- // below 8x8" WITHOUT it (measured by ablating the read) -- both are
6321- // impossible on a `--enable-ab-partitions=0 --enable-1to4-partitions=0
6322- // --min-partition-size=8` recipe, so BOTH are our own desync
6323- // (class refusal-from-own-desync) and the compound 8x8 leaf carries at
6324- // least one more missing/misplaced symbol beyond the interp filter this
6325- // round added. Next round: EC_TRACE range ladder vs aomdec on the first
6326- // compound leaf of frame 5.
6327- #[ignore = "lane-interp3 r1: the compound 8x8 leaf still desyncs past the interp-filter read (surfaces as a bogus AB/1:4 refusal); the panic it used to end in is now a named refusal"]
6315+ // lane-interp3 r2: the ENTROPY desync r1 measured is CLOSED -- the full
6316+ // 16-frame stream now parses end to end and every `EC_MODE`/`EC_MODE_VAL`
6317+ // element's msac RANGE matches the instrumented aomdec's line for line
6318+ // (570/570 mode elements, 0 diff). Two twin-drift root causes, both in
6319+ // `decode_inter_block8`'s compound arm: `read_compound_ref_frames` was
6320+ // passed a hard-coded `LAST_FRAME` for every inter neighbour instead of
6321+ // the real per-mi band, and the grid stamp cleared both per-slot
6322+ // `is_global_mv_block` flags. This gate stays RED and ignored on a
6323+ // RECONSTRUCTION residue, not an entropy one: luma-only, |delta| <= 8,
6324+ // first at decode frame 7 pixel (42,15) -- the 8x8 leaf at mi (10,4),
6325+ // spilling one pixel across its left/bottom deblock edges -- growing to
6326+ // 222 Y + 4 U + 1 V samples by frame 15 (pure propagation; chroma stays
6327+ // exact until frame 14). Next round: the OBMC blend over a compound
6328+ // neighbour (the oracle's `EC_OBMC` rung prints `filt=` per neighbour;
6329+ // this decoder has no `EC_OBMC` emitter yet -- build it first).
6330+ #[ignore = "lane-interp3 r2: entropy is now exact on the whole stream (range ladder 570/570); RED on a luma-only reconstruction residue from decode frame 7 (|delta| <= 8, first at the 8x8 leaf mi (10,4))"]
63286331 #[test]
63296332 fn a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact() {
63306333 const NAME: &str =