From 232e604388a7d46f614d58f65f96356f776c0819 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 08:13:17 +0300 Subject: [PATCH] =?UTF-8?q?fix(av1):=20mask=20non-pixel-exact=20COMPOUND?= =?UTF-8?q?=5FREFERENCE=20plain-average=20blend=20=E2=80=94=20r16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- crates/ec-av1/src/decode.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index b833bb56..d2c5c0b0 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -4445,6 +4445,25 @@ fn decode_inter_block( weighted/simple-average combine only, lane-av1comp", )); } + // corner-cut (lane-av1comp r16): a real aomenc stream (fixtures/ + // av1comp-r16-compound-mismatch.obu, seed 42) proved + // predict_compound_intermediate/combine_compound wrong by up to + // 4/255 in a ~30x32 patch of one 32x32 quadrant, spilling a few + // pixels into neighbours (loop-filter-shaped, not a desync -- + // DRL/assign_compound_mv/dist_wtd_comp_weight_assign all cross- + // checked bit-for-bit against libaom decodemv.c/reconinter.c and + // matched). Root cause not yet isolated; refuse by name rather + // than ship a non-pixel-exact compound blend. Ceiling: r13/r14's + // MC plumbing above this line stays -- only the plain-average + // reconstruct is masked off again. Upgrade: bisect against the + // pinned fixture (frame 1, rows 16-31 cols 32-63). + return Err(unsupported( + "a COMPOUND_REFERENCE block using the plain/distance-weighted \ + average blend (comp_group_idx == 0) -- proven non-pixel-exact \ + against a real aomenc stream (lane-av1comp r16, see \ + av1comp-r16-compound-mismatch.obu)", + )); + #[allow(unreachable_code)] let (fwd_offset, bck_offset, compound_idx) = if !skip_mode && enable_jnt_comp { let idx_ctx = get_comp_index_context( neighbours, @@ -5277,6 +5296,16 @@ fn decode_inter_block8( weighted/simple-average combine only, lane-av1comp", )); } + // corner-cut (lane-av1comp r16): same non-pixel-exact plain- + // average defect as the 16x16 leaf's own mask above -- see + // that comment. + 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-av1comp r16, see \ + av1comp-r16-compound-mismatch.obu)", + )); + #[allow(unreachable_code)] let (fwd_offset, bck_offset, compound_idx) = if !skip_mode && enable_jnt_comp { let idx_ctx = get_comp_index_context( neighbours,