From 3f636a9655f08221a9fdc57641c9fcec88681b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 28 Aug 2026 10:13:40 +0300 Subject: [PATCH] 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. --- crates/ec-av1/src/decode.rs | 32 +++++++++++++++++++++++++++----- crates/ec-av1/src/stream.rs | 13 +++++++++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index c6fa73ff..d4eee380 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -4652,8 +4652,27 @@ fn decode_inter_block( // still correct; the four candidates above were not re-audited // this round. Refusing here (rather than shipping a value-exact- // most-of-the-time blend) until one of them is found wrong. - // r6 TEMP PROBE: refusal disabled to trace the compound_idx read - // itself; restore before commit. + // r6/r7: found and fixed one real bug (mvstack.rs ref_ctx family + // undercounted compound neighbours in the single_ref_p*/comp_ref*/ + // comp_bwdref* context reads -- kept, real fix). Unmasking on + // that fix alone and running the wide gate sweep (many seeds, + // `a_real_aomenc_stream_with_compound_references_decodes_pixel_exact`/ + // `a_real_aomenc_stream_with_reference_select_reads_comp_mode_correctly`, + // cq-level=45) still mismatches roughly half the time, at + // different frames each run for the SAME seed -- aomenc's own + // cpu-used=0 RD search is run-to-run nondeterministic (noted + // above), so this is a second, still-unfound compound_idx defect, + // not the one r6/r7 fixed. r6's own residual-mismatch note (321/ + // 846 pixels not fitting the (9,7)-vs-plain-average hypothesis + // either) already flagged more than one bug here. Re-masking: + // do not ship a blend that is right only sometimes. + return Err(unsupported( + "a COMPOUND_REFERENCE 16x16 leaf using the plain/distance-weighted \ + average blend (comp_group_idx == 0) -- proven non-pixel-exact against \ + real aomenc streams beyond the one bug lane-av1blend r6/r7 fixed \ + (lane-av1blend r7, wide gate sweep)", + )); + #[allow(unreachable_code)] let (fwd_offset, bck_offset, compound_idx) = if !skip_mode && enable_jnt_comp { let idx_ctx = get_comp_index_context( neighbours, @@ -5557,12 +5576,15 @@ fn decode_inter_block8( // that comment. // r3: same defect as the 16x16 leaf's own mask above -- see // that comment (compound_idx's decoded value, not the blend - // math or reference-slot bookkeeping). + // math or reference-slot bookkeeping). r6/r7: same re-mask + // as the 16x16 leaf above -- one real bug found and fixed + // (mvstack.rs ref_ctx family), a second, still-unfound + // compound_idx defect surfaces on the wide gate sweep. return Err(unsupported( "a COMPOUND_REFERENCE 8x8 leaf using the plain/distance-weighted \ average blend (comp_group_idx == 0) -- proven non-pixel-exact \ - against a real aomenc stream (lane-av1blend r1/r3, see \ - av1blend-r1-mismatch.obu)", + against real aomenc streams beyond the one bug lane-av1blend \ + r6/r7 fixed (lane-av1blend r7, wide gate sweep)", )); #[allow(unreachable_code)] let (fwd_offset, bck_offset, compound_idx) = if !skip_mode && enable_jnt_comp { diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index ef960a11..0a746d1c 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -744,9 +744,9 @@ mod tests { // constructing the (module-private) `Neighbours` itself. const PARTITION_NONE: usize = 0; let ii_ctx = intra_inter_ctx(false, false, false, false); - let sr_p1_ctx = single_ref_p1_ctx(None, None); - let sr_p3_ctx = single_ref_p3_ctx(None, None); - let sr_p5_ctx = single_ref_p5_ctx(None, None); + let sr_p1_ctx = single_ref_p1_ctx(None, None, None, None); + let sr_p3_ctx = single_ref_p3_ctx(None, None, None, None); + let sr_p5_ctx = single_ref_p5_ctx(None, None, None, None); for run in 0..4 { let picture = test_card(width, height); @@ -2633,7 +2633,12 @@ mod tests { // capability gap tracked on its own (not a // COMPOUND_REFERENCE defect); accept it here too // rather than fail a compound-specific gate on a - // partition-search coincidence. + // partition-search coincidence. lane-av1blend r7: + // re-swept the wide gate with the plain-average + // blend unmasked (r6/r7's ref_ctx fix alone) and it + // still mismatches on real streams beyond that one + // bug -- re-masked comp_group_idx == 0 too, so this + // stays a legal named refusal. assert!( msg.contains("COMPOUND_REFERENCE") || msg.contains("a partition"), "{NAME}: comp_mode fired (seed {seed}) but the refusal \