From df156df06a8bd8bc13470424123fe092ca840f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Sep 2026 07:24:11 +0300 Subject: [PATCH] fix(av1): refuse the 128 NONE block by its MEASURED residual, and green the 64x72 sb128 gate The chroma TU loop landed but the arm is still not pixel-exact (first luma TX_64X64 unit reads AC where libaom has DC only), so the product path refuses it again by name rather than emitting wrong pixels; the gate stays the reproducer. The 64x72 cpu-used=0 --sb-size=128 stream main used to refuse now decodes PIXEL-EXACT once its unrelated 1:4 sub-16 partitions are disabled. --- crates/ec-av1/src/decode.rs | 12 ++++++++++++ crates/ec-av1/src/refusal_inventory.rs | 1 + crates/ec-av1/src/stream.rs | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 1345afa9..25ed7fd0 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -11929,6 +11929,18 @@ fn read_sb128_root( PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)); } else { PART128_NONE_HITS.with(|c| c.set(c.get() + 1)); + // lane-sb128b r2 RESIDUAL, measured (gate + // `a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact`, + // 384x384 cq63 seed 42, a 76-byte near-flat frame): the chroma TU loop + // landed and the tile decodes end to end, but frame 0 luma differs from + // ffmpeg at 139162/147456 samples -- ffmpeg's row 0 is a constant 115 + // where ours ramps 115 -> 112 across the first TX_64X64 unit, i.e. our + // first luma unit reads AC coefficients libaom never wrote. The DC and + // the mode agree; the divergence is inside that unit's coefficient + // read. Refuse rather than emit wrong pixels. + return Err(unsupported( + "a 128x128 PARTITION_NONE block (four TX_64X64 luma and four TX_32X32 chroma units all decode, but the first unit's coefficients already carry AC where libaom has DC only -- lane-sb128b r2's open entropy residual)", + )); } Ok(part128) } diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 464b7dc5..b2b864bc 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -43,6 +43,7 @@ const REFUSALS: &[&str] = &[ "a tx_type symbol outside its CDF's own set: {t}", "an INTER 32x32 partition type this decoder does not code (value={part32})", "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4", + "a 128x128 PARTITION_NONE block (four TX_64X64 luma and four TX_32X32 chroma units all decode, but the first unit's coefficients already carry AC where libaom has DC only -- lane-sb128b r2's open entropy residual)", "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)", "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)", "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index b408f911..406d4186 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -1149,6 +1149,10 @@ mod tests { .args([ "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", "--cpu-used=0", "--sb-size=128", "--kf-max-dist=0", "--limit=1", + // Unrelated to the 128 root: a 64x72 frame at cpu-used=0 also + // picks PARTITION_HORZ_4 below 16x16, which this decoder + // refuses by name (lane-sb128b r2). + "--enable-1to4-partitions=0", "--min-partition-size=16", "--threads=1", "--row-mt=0", "--obu", "-o", "-", "-", ]) .stdin(Stdio::piped()) @@ -17685,6 +17689,9 @@ mod tests { /// Smooth gradients at a high `--cq-level` are what make the RD search /// keep a whole 128x128 block; `part128_none_hits` HARD-asserts it did. #[test] + #[ignore = "lane-sb128b r2 reproducer: the 128 NONE luma AND chroma units all \ + decode, the first luma unit still reads AC libaom never wrote, so the \ + product path refuses the arm by name"] fn a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact() { const NAME: &str = "a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact";