ec-av1: the inventory listed 33 strings and PROVEN carried 31 rows
Browse files at this commitabb01bd95257b4526e7c9631d784cd3956062a16Parent: 69db7582 changed files +83 -0
crates/ec-av1/src/refusal_inventory.rsmodified+68 -0
| @@ -696,6 +696,35 @@ const PROVEN: &[(&str, &str, Proof)] = &[ | |||
| 696 | "an_inter_frame_naming_an_unrefreshed_primary_ref_slot_is_refused_by_name", | 696 | "an_inter_frame_naming_an_unrefreshed_primary_ref_slot_is_refused_by_name", |
| 697 | Proof::NegativeGate, | 697 | Proof::NegativeGate, |
| 698 | ), | 698 | ), |
| 699 | + // lane-av1bookkeep W1-4, NEGATIVE: the BLOCK_INVALID subsize refusal | ||
| 700 | + // (`refuse_invalid_plane_block`, decode.rs). It is libaom's own rule | ||
| 701 | + // (`get_plane_block_size` -> `AOM_CODEC_CORRUPT_FRAME`, decodeframe.c:1456) | ||
| 702 | + // applied to a stream whose header and tile disagree. The pin is a 4:2:2 | ||
| 703 | + // sequence header over a 4:2:0 key frame's tile, whose partition symbols | ||
| 704 | + // name 8x16 -- a subsize with no chroma plane block at ss (1,0) -- so the | ||
| 705 | + // guard FIRES, by name, and the gate also drives a genuine 4:2:2 pin that | ||
| 706 | + // must still decode, so it cannot pass by refusing everything. The gate's | ||
| 707 | + // body quotes the refusal WHOLE (not just the libaom citation inside it), | ||
| 708 | + // which is what makes this row an anchor the checker can hold. | ||
| 709 | + ( | ||
| 710 | + "a block size 4x8, 8x16 or 16x4 (or 8x4 at 4:4:0) has no chroma plane block at this frame's subsampling mode (libaom: \\\"Block size %dx%d invalid with this subsampling mode\\\", av1/decoder/decodeframe.c:1456, refusing by the same rule)", | ||
| 711 | + "a_422_header_over_a_420_tile_refuses_the_subsize_libaom_calls_corrupt", | ||
| 712 | + Proof::NegativeGate, | ||
| 713 | + ), | ||
| 714 | + // lane-av1bookkeep W1-4, ENUMERATION: the LONE capability claim. The guard | ||
| 715 | + // in `decode_block_rect` fires only when `filter_intra.is_some()`, and that | ||
| 716 | + // flag is `Some` only where `filter_intra_size_class_rect` says so. The | ||
| 717 | + // strips the guard protects are `(64, 32)` / `(32, 64)`; | ||
| 718 | + // `av1_filter_intra_allowed_bsize` caps both sides at 32x32, so no conformant | ||
| 719 | + // stream offers the symbol there. The gate walks every EXPLICIT arm of the | ||
| 720 | + // table (none admits a 64 axis), drives the square-delegate's callee | ||
| 721 | + // `filter_intra_size_class` at 32 and 64 directly, and quotes the claim's | ||
| 722 | + // leading clause in its own body. | ||
| 723 | + ( | ||
| 724 | + "filter intra on a superblock-level HORZ/VERT strip (never expected -- av1_filter_intra_allowed_bsize caps at 32x32)", | ||
| 725 | + "a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol", | ||
| 726 | + Proof::Enumeration, | ||
| 727 | + ), | ||
| 699 | ]; | 728 | ]; |
| 700 | 729 | ||
| 701 | /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than | 730 | /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than |
| @@ -2698,6 +2727,45 @@ mod tests { | |||
| 2698 | ); | 2727 | ); |
| 2699 | } | 2728 | } |
| 2700 | 2729 | ||
| 2730 | + /// The OTHER half of the inventory's invariant: every string LISTED in | ||
| 2731 | + /// [`REFUSALS`] or [`CAPABILITY_CLAIMS`] has a row in [`PROVEN`]. | ||
| 2732 | + /// | ||
| 2733 | + /// `every_proven_refusal_names_a_test_that_exists` checks the direction | ||
| 2734 | + /// row -> live refusal, so a string added to the inventory with no proving | ||
| 2735 | + /// gate was invisible: the file could list 33 strings, carry 31 rows, and | ||
| 2736 | + /// every test in the module stayed green. Two rows were missing on main | ||
| 2737 | + /// (the BLOCK_INVALID subsize refusal and the lone filter-intra capability | ||
| 2738 | + /// claim) precisely because nothing compared the two sets. This is that | ||
| 2739 | + /// comparison, so the next one cannot land unmeasured. | ||
| 2740 | + #[test] | ||
| 2741 | + fn every_listed_refusal_and_capability_claim_has_a_proven_row() { | ||
| 2742 | + let mut listed = 0usize; | ||
| 2743 | + let mut unmeasured: Vec<&str> = Vec::new(); | ||
| 2744 | + for reason in REFUSALS.iter().chain(CAPABILITY_CLAIMS.iter()) { | ||
| 2745 | + listed += 1; | ||
| 2746 | + if !PROVEN.iter().any(|(row, _, _)| *row == *reason) { | ||
| 2747 | + unmeasured.push(reason); | ||
| 2748 | + } | ||
| 2749 | + } | ||
| 2750 | + assert!( | ||
| 2751 | + unmeasured.is_empty(), | ||
| 2752 | + "these strings are listed as refusals / capability claims but no PROVEN row names a \ | ||
| 2753 | + gate that proves them -- an unmeasured claim is what this table exists to make \ | ||
| 2754 | + visible:\n{unmeasured:#?}" | ||
| 2755 | + ); | ||
| 2756 | + assert_eq!( | ||
| 2757 | + listed, | ||
| 2758 | + PROVEN.len(), | ||
| 2759 | + "{listed} strings are listed and {} rows exist -- they must be one to one, so a row \ | ||
| 2760 | + can never stand in for a string that is not listed", | ||
| 2761 | + PROVEN.len() | ||
| 2762 | + ); | ||
| 2763 | + eprintln!( | ||
| 2764 | + "refusal inventory: {listed} listed strings, {} PROVEN rows, one to one", | ||
| 2765 | + PROVEN.len() | ||
| 2766 | + ); | ||
| 2767 | + } | ||
| 2768 | + | ||
| 2701 | /// Lane-av1refusalspan, non-vacuity of the BOUNDARY (not of the anchor): | 2769 | /// Lane-av1refusalspan, non-vacuity of the BOUNDARY (not of the anchor): |
| 2702 | /// a neighbour's function must be unreachable from a gate's body, and a | 2770 | /// a neighbour's function must be unreachable from a gate's body, and a |
| 2703 | /// body that is not closed must fail rather than run on. | 2771 | /// body that is not closed must fail rather than run on. |
crates/ec-av1/src/stream.rsmodified+15 -0
| @@ -2936,6 +2936,16 @@ pub(crate) mod tests { | |||
| 2936 | .join("fixtures") | 2936 | .join("fixtures") |
| 2937 | .join("440_request_is_422.obu"); | 2937 | .join("440_request_is_422.obu"); |
| 2938 | let pinned = read_pin(&path, 2014, 0x98a1378df976253d, NAME); | 2938 | let pinned = read_pin(&path, 2014, 0x98a1378df976253d, NAME); |
| 2939 | + // The refusal this gate PROVES, quoted whole -- the anchor the PROVEN | ||
| 2940 | + // row in `refusal_inventory.rs` is checked against inside this body's | ||
| 2941 | + // own bounds. The assertion below used to match only the libaom | ||
| 2942 | + // citation *inside* the string, so a reworded guard kept passing for | ||
| 2943 | + // as long as it kept citing `decodeframe.c:1456`: the half that names | ||
| 2944 | + // OUR shapes (4x8 / 8x16 / 16x4, and 8x4 at 4:4:0) was never pinned. | ||
| 2945 | + const REFUSAL: &str = "a block size 4x8, 8x16 or 16x4 (or 8x4 at 4:4:0) has no chroma \ | ||
| 2946 | + plane block at this frame's subsampling mode (libaom: \"Block \ | ||
| 2947 | + size %dx%d invalid with this subsampling mode\", \ | ||
| 2948 | + av1/decoder/decodeframe.c:1456, refusing by the same rule)"; | ||
| 2939 | let err = decode_stream(&pinned) | 2949 | let err = decode_stream(&pinned) |
| 2940 | .err() | 2950 | .err() |
| 2941 | .unwrap_or_else(|| panic!("{NAME}: the pin must be REFUSED, not decoded")); | 2951 | .unwrap_or_else(|| panic!("{NAME}: the pin must be REFUSED, not decoded")); |
| @@ -2945,6 +2955,11 @@ pub(crate) mod tests { | |||
| 2945 | "{NAME}: the refusal must name the rule it refuses by (libaom's own wording), got: \ | 2955 | "{NAME}: the refusal must name the rule it refuses by (libaom's own wording), got: \ |
| 2946 | {msg}" | 2956 | {msg}" |
| 2947 | ); | 2957 | ); |
| 2958 | + assert!( | ||
| 2959 | + msg.contains(REFUSAL), | ||
| 2960 | + "{NAME}: the refusal must be this decoder's OWN string, whole -- the guard's wording \ | ||
| 2961 | + drifted, so the PROVEN row no longer names what fires, got: {msg}" | ||
| 2962 | + ); | ||
| 2948 | // Positive control: a real 4:2:2 stream must still decode, so the gate | 2963 | // Positive control: a real 4:2:2 stream must still decode, so the gate |
| 2949 | // cannot pass by refusing everything. | 2964 | // cannot pass by refusing everything. |
| 2950 | let ok_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | 2965 | let ok_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) |