forge
Explore
Log in

Don't you dare go Hollow

ec-av1: address lane-av1-hdr reviewer P3s (guard-arm audit, spec-cite fix)

Browse files at this commit

f92825a885b733bdbf400b265bc7c67e301201f6Ahmet Kaan GümüşParent: 89f30a9
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.rsmodified+31 -5
@@ -1379,9 +1379,12 @@ mod tests {
1379 /// `decode_block_rect` fires only when `filter_intra.is_some()`, and that1379 /// `decode_block_rect` fires only when `filter_intra.is_some()`, and that
1380 /// flag is `Some` only where `filter_intra_size_class_rect` says so. The1380 /// flag is `Some` only where `filter_intra_size_class_rect` says so. The
1381 /// strips the guard protects are `(64, 32)` / `(32, 64)`; this test1381 /// strips the guard protects are `(64, 32)` / `(32, 64)`; this test
1382- /// enumerates EVERY arm of that table and asserts none admits a `64`1382+ /// enumerates every EXPLICIT arm of that table (asserting none admits a
1383- /// axis, so no conformant stream (libaom `av1_filter_intra_allowed_bsize`1383+ /// `64` axis) AND drives the square-delegate guard arm's callee
1384- /// caps both sides at 32) can offer the symbol there.1384+ /// `filter_intra_size_class` directly at 32/64, so a widening on either
1385+ /// side turns it red. No conformant stream (libaom
1386+ /// `av1_filter_intra_allowed_bsize` caps both sides at 32) can offer the
1387+ /// symbol there.
1385 #[test]1388 #[test]
1386 fn a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol() {1389 fn a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol() {
1387 let src = include_str!("decode.rs");1390 let src = include_str!("decode.rs");
@@ -1393,12 +1396,24 @@ mod tests {
1393 .find("fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> {")1396 .find("fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> {")
1394 .expect("filter_intra_size_class_rect is gone");1397 .expect("filter_intra_size_class_rect is gone");
1395 let body = &src[at..at + src[at..].find("\n}\n").expect("unterminated fn")];1398 let body = &src[at..at + src[at..].find("\n}\n").expect("unterminated fn")];
1396- let (mut arms, mut saw_none_fallback) = (0usize, false);1399+ let (mut arms, mut saw_none_fallback, mut saw_square_delegate) = (0usize, false, false);
1397 let mut seen: Vec<(usize, usize)> = Vec::new();1400 let mut seen: Vec<(usize, usize)> = Vec::new();
1398 for line in body.lines() {1401 for line in body.lines() {
1399 let line = line.trim();1402 let line = line.trim();
1400 if line.starts_with('_') {1403 if line.starts_with('_') {
1401- saw_none_fallback |= line == "_ => None,";1404+ if line == "_ => None," {
1405+ saw_none_fallback = true;
1406+ } else if line.starts_with("_ if ") {
1407+ // The square-delegate guard arm hands a square strip to
1408+ // `filter_intra_size_class`; the numeric walk below cannot
1409+ // see it (it carries no `(bw, bh)` pair), so its callee is
1410+ // audited by the direct call after the loop instead.
1411+ assert!(
1412+ line == "_ if bw == bh => filter_intra_size_class(bw),",
1413+ "filter_intra_size_class_rect's guard arm changed shape: {line}"
1414+ );
1415+ saw_square_delegate = true;
1416+ }
1402 continue;1417 continue;
1403 }1418 }
1404 let Some(rest) = line.strip_prefix('(') else { continue };1419 let Some(rest) = line.strip_prefix('(') else { continue };
@@ -1417,6 +1432,17 @@ mod tests {
1417 }1432 }
1418 assert!(arms >= 10, "only {arms} arms parsed -- the table's shape changed");1433 assert!(arms >= 10, "only {arms} arms parsed -- the table's shape changed");
1419 assert!(saw_none_fallback, "filter_intra_size_class_rect lost its `_ => None` fallback");1434 assert!(saw_none_fallback, "filter_intra_size_class_rect lost its `_ => None` fallback");
1435+ assert!(saw_square_delegate, "filter_intra_size_class_rect lost its square-delegate arm");
1436+ // The guard arm delegates square strips to `filter_intra_size_class`;
1437+ // drive the delegate directly, so a widening there turns THIS test red
1438+ // (the numeric walk never reaches the guard arm).
1439+ assert!(
1440+ crate::decode::filter_intra_size_class(32).is_some()
1441+ && crate::decode::filter_intra_size_class(64).is_none(),
1442+ "filter_intra_size_class now admits a 64-pixel side -- the square-delegate arm of \
1443+ filter_intra_size_class_rect can then offer a `use_filter_intra` symbol on a \
1444+ superblock-level HORZ/VERT strip and its guard is reachable"
1445+ );
1420 for strip in [(64usize, 32usize), (32, 64)] {1446 for strip in [(64usize, 32usize), (32, 64)] {
1421 assert!(1447 assert!(
1422 !seen.contains(&strip),1448 !seen.contains(&strip),
lanes/av1hdr.report.mdmodified+1 -1
@@ -115,7 +115,7 @@ on the same stream**, so the pin is `spec-conformant`, not a capability gap.
115 | `show_existing_frame` naming an empty slot | `decodeframe.c:4651-4654` → `AOM_CODEC_UNSUP_BITSTREAM "Buffer does not contain a decoded frame"` | spec-conformant |115 | `show_existing_frame` naming an empty slot | `decodeframe.c:4651-4654` → `AOM_CODEC_UNSUP_BITSTREAM "Buffer does not contain a decoded frame"` | spec-conformant |
116 | a reference selected with no picture | `decodeframe.c:5008-5031` → `AOM_CODEC_CORRUPT_FRAME "Inter frame requests nonexistent reference"` | spec-conformant |116 | a reference selected with no picture | `decodeframe.c:5008-5031` → `AOM_CODEC_CORRUPT_FRAME "Inter frame requests nonexistent reference"` | spec-conformant |
117 | 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 |117 | 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 |
118-| 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 |118+| 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 |
119 | 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) |119 | 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) |
120 | a bit depth of 12 | libaom supports 8/10/12 with `CONFIG_AV1_HIGHBITDEPTH`; `read_sequence_header` accepts `twelve_bit` | **intentional gate** (see §4) |120 | a bit depth of 12 | libaom supports 8/10/12 with `CONFIG_AV1_HIGHBITDEPTH`; `read_sequence_header` accepts `twelve_bit` | **intentional gate** (see §4) |
121 | `SEG_LVL_REF_FRAME/SKIP/GLOBALMV` enabled | libaom **implements** them (`decodemv.c:431,437,1071,1350`) | **capability gap** (see §4) |121 | `SEG_LVL_REF_FRAME/SKIP/GLOBALMV` enabled | libaom **implements** them (`decodemv.c:431,437,1071,1350`) | **capability gap** (see §4) |