From f92825a885b733bdbf400b265bc7c67e301201f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 20 Sep 2026 05:25:16 +0300 Subject: [PATCH] ec-av1: address lane-av1-hdr reviewer P3s (guard-arm audit, spec-cite fix) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refusal_inventory: a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol skipped the square-delegate guard arm (`_ if bw == bh => filter_intra_size_class(bw),`), so a widening of the delegate was unaudited. The parser now recognises that arm and the test drives filter_intra_size_class(32)/filter_intra_size_class(64) directly, so a delegate widening turns it red. Doc comment updated to say what it enumerates. lanes/av1hdr.report.md: §3 cited `compute_image_size`, which is AV1-spec pseudocode and not a libaom v3.13.3 symbol; name the real site (`dec_set_mb_mi`, decoder.c:57-58; cf. av1_get_MBs, alloccommon.c:32-33). (reviewer's third finding, the 12-bit warp round_0 value, was withdrawn as an arithmetic slip: FILTER_BITS=7 gives round_0=5 at bd 12, as the report already stated.) --- crates/ec-av1/src/refusal_inventory.rs | 36 ++++++++++++++++++++++---- lanes/av1hdr.report.md | 2 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index caaff979..34f3934e 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -1379,9 +1379,12 @@ mod tests { /// `decode_block_rect` fires only when `filter_intra.is_some()`, and that /// flag is `Some` only where `filter_intra_size_class_rect` says so. The /// strips the guard protects are `(64, 32)` / `(32, 64)`; this test - /// enumerates EVERY arm of that table and asserts none admits a `64` - /// axis, so no conformant stream (libaom `av1_filter_intra_allowed_bsize` - /// caps both sides at 32) can offer the symbol there. + /// enumerates every EXPLICIT arm of that table (asserting none admits a + /// `64` axis) AND drives the square-delegate guard arm's callee + /// `filter_intra_size_class` directly at 32/64, so a widening on either + /// side turns it red. No conformant stream (libaom + /// `av1_filter_intra_allowed_bsize` caps both sides at 32) can offer the + /// symbol there. #[test] fn a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol() { let src = include_str!("decode.rs"); @@ -1393,12 +1396,24 @@ mod tests { .find("fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option {") .expect("filter_intra_size_class_rect is gone"); let body = &src[at..at + src[at..].find("\n}\n").expect("unterminated fn")]; - let (mut arms, mut saw_none_fallback) = (0usize, false); + let (mut arms, mut saw_none_fallback, mut saw_square_delegate) = (0usize, false, false); let mut seen: Vec<(usize, usize)> = Vec::new(); for line in body.lines() { let line = line.trim(); if line.starts_with('_') { - saw_none_fallback |= line == "_ => None,"; + if line == "_ => None," { + saw_none_fallback = true; + } else if line.starts_with("_ if ") { + // The square-delegate guard arm hands a square strip to + // `filter_intra_size_class`; the numeric walk below cannot + // see it (it carries no `(bw, bh)` pair), so its callee is + // audited by the direct call after the loop instead. + assert!( + line == "_ if bw == bh => filter_intra_size_class(bw),", + "filter_intra_size_class_rect's guard arm changed shape: {line}" + ); + saw_square_delegate = true; + } continue; } let Some(rest) = line.strip_prefix('(') else { continue }; @@ -1417,6 +1432,17 @@ mod tests { } assert!(arms >= 10, "only {arms} arms parsed -- the table's shape changed"); assert!(saw_none_fallback, "filter_intra_size_class_rect lost its `_ => None` fallback"); + assert!(saw_square_delegate, "filter_intra_size_class_rect lost its square-delegate arm"); + // The guard arm delegates square strips to `filter_intra_size_class`; + // drive the delegate directly, so a widening there turns THIS test red + // (the numeric walk never reaches the guard arm). + assert!( + crate::decode::filter_intra_size_class(32).is_some() + && crate::decode::filter_intra_size_class(64).is_none(), + "filter_intra_size_class now admits a 64-pixel side -- the square-delegate arm of \ + filter_intra_size_class_rect can then offer a `use_filter_intra` symbol on a \ + superblock-level HORZ/VERT strip and its guard is reachable" + ); for strip in [(64usize, 32usize), (32, 64)] { assert!( !seen.contains(&strip), diff --git a/lanes/av1hdr.report.md b/lanes/av1hdr.report.md index a425795d..6de2beb9 100644 --- a/lanes/av1hdr.report.md +++ b/lanes/av1hdr.report.md @@ -115,7 +115,7 @@ on the same stream**, so the pin is `spec-conformant`, not a capability gap. | `show_existing_frame` naming an empty slot | `decodeframe.c:4651-4654` → `AOM_CODEC_UNSUP_BITSTREAM "Buffer does not contain a decoded frame"` | spec-conformant | | a reference selected with no picture | `decodeframe.c:5008-5031` → `AOM_CODEC_CORRUPT_FRAME "Inter frame requests nonexistent reference"` | spec-conformant | | an inter frame with no key frame before it | same site — libaom permits a stream to open on an intra-only frame, but a reference resolving to an unset slot errors (`decodeframe.c:5008-5016` comment + error) | spec-conformant | -| a frame with no mode-info grid | libaom derives the mi grid from the frame size; a 0-sized frame is unrepresentable (`compute_image_size`); no error site exists because no conformant header codes one | spec-conformant / defensive | +| a frame with no mode-info grid | libaom derives the mi grid from the frame size (`dec_set_mb_mi`, `decoder.c:57-58` — the frame's `mi_cols`/`mi_rows` from `ALIGN_POWER_OF_TWO(width, 3) >> MI_SIZE_LOG2`; cf. `av1_get_MBs`, `alloccommon.c:32-33`). `compute_image_size`, cited earlier, is AV1-spec pseudocode and is not a libaom symbol; a 0-sized frame is unrepresentable, so no error site exists — no conformant header codes one | spec-conformant / defensive | | a reference picture whose height does not match | `decodeframe.c:5089-5099` → libaom **scales** (`av1_setup_scale_factors_for_frame`) and only errors on an out-of-range scale (`AOM_CODEC_UNSUP_BITSTREAM "Reference frame has invalid dimensions"`) | **capability gap** (we port only width scaling) | | a bit depth of 12 | libaom supports 8/10/12 with `CONFIG_AV1_HIGHBITDEPTH`; `read_sequence_header` accepts `twelve_bit` | **intentional gate** (see §4) | | `SEG_LVL_REF_FRAME/SKIP/GLOBALMV` enabled | libaom **implements** them (`decodemv.c:431,437,1071,1350`) | **capability gap** (see §4) |