lane-av1rect8x16: run the footprint walk before the exact-table pin
Browse files at this commit4bb956ec633cbaa817301327001d0fe69d2507e6Parent: 406d6732 changed files +106 -42
crates/ec-av1/src/refusal_inventory.rsmodified+21 -18
| @@ -1695,23 +1695,9 @@ mod tests { | |||
| 1695 | arms.insert((w, h)); | 1695 | arms.insert((w, h)); |
| 1696 | } | 1696 | } |
| 1697 | } | 1697 | } |
| 1698 | - assert_eq!( | 1698 | + // (3) The enumeration itself -- run BEFORE the exact-table pin below |
| 1699 | - arms, | 1699 | + // so a deleted arm fails HERE, naming the footprint, instead of |
| 1700 | - [ | 1700 | + // behind a vaguer "the table changed". |
| 1701 | - (8usize, 16usize), | ||
| 1702 | - (8, 32), | ||
| 1703 | - (16, 8), | ||
| 1704 | - (16, 16), | ||
| 1705 | - (16, 32), | ||
| 1706 | - (32, 16) | ||
| 1707 | - ] | ||
| 1708 | - .into_iter() | ||
| 1709 | - .collect::<BTreeSet<(usize, usize)>>(), | ||
| 1710 | - "decode_block_rect's chroma table changed -- re-derive the walk below" | ||
| 1711 | - ); | ||
| 1712 | - | ||
| 1713 | - // (3) The enumeration itself: every caller shape under every | ||
| 1714 | - // subsampling an AV1 color_config can carry. | ||
| 1715 | let mut checked = 0u32; | 1701 | let mut checked = 0u32; |
| 1716 | for &(bw, bh) in &shapes { | 1702 | for &(bw, bh) in &shapes { |
| 1717 | for (ss_x, ss_y) in [(0usize, 0usize), (1, 0), (1, 1)] { | 1703 | for (ss_x, ss_y) in [(0usize, 0usize), (1, 0), (1, 1)] { |
| @@ -1729,7 +1715,24 @@ mod tests { | |||
| 1729 | "the chroma domain is not two shapes x three formats" | 1715 | "the chroma domain is not two shapes x three formats" |
| 1730 | ); | 1716 | ); |
| 1731 | 1717 | ||
| 1732 | - // (4) The residual, stated as an assertion so it cannot rot: the two | 1718 | + // (4) And the table is EXACTLY those six rows -- no row is a shape no |
| 1719 | + // caller can present, which is what makes the `_` arm dead. | ||
| 1720 | + assert_eq!( | ||
| 1721 | + arms, | ||
| 1722 | + [ | ||
| 1723 | + (8usize, 16usize), | ||
| 1724 | + (8, 32), | ||
| 1725 | + (16, 8), | ||
| 1726 | + (16, 16), | ||
| 1727 | + (16, 32), | ||
| 1728 | + (32, 16) | ||
| 1729 | + ] | ||
| 1730 | + .into_iter() | ||
| 1731 | + .collect::<BTreeSet<(usize, usize)>>(), | ||
| 1732 | + "decode_block_rect's chroma table changed -- re-derive the walk above" | ||
| 1733 | + ); | ||
| 1734 | + | ||
| 1735 | + // (5) The residual, stated as an assertion so it cannot rot: the two | ||
| 1733 | // 4:2:0 rows an 8x16/16x8 luma strip would need are NOT in this | 1736 | // 4:2:0 rows an 8x16/16x8 luma strip would need are NOT in this |
| 1734 | // table, and (4,8)/(8,4) is not a shape any caller can produce. If a | 1737 | // table, and (4,8)/(8,4) is not a shape any caller can produce. If a |
| 1735 | // future caller hands this function an 8x16, step (1) goes red | 1738 | // future caller hands this function an 8x16, step (1) goes red |
lanes/av1rect8x16.report.mdmodified+85 -24
| @@ -148,36 +148,97 @@ So the 4:2:0 chroma of an 8x16 luma block is a genuine single `TX_4X8` in libaom | |||
| 148 | 148 | ||
| 149 | --- | 149 | --- |
| 150 | 150 | ||
| 151 | -## 4. Deliverable: the claim is now PROVEN, not assumed | 151 | +## 4. Deliverable: the claim is now PROVEN by the tree, not argued in this file |
| 152 | - | 152 | + |
| 153 | -`refusal_inventory.rs` gained a `PROVEN` row for the string (it previously had **none** — it was the audit round's single unproven row) and the test that proves it: | 153 | +> **The 840-encode sweep in §2 is CORROBORATION, not the proof.** It shows the |
| 154 | - | 154 | +> refusal does not fire on 826 streams that provably code the shape; it cannot |
| 155 | -- **`every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table`** (`refusal_inventory.rs:1571`) | 155 | +> show the shape is unreachable in a stream nobody encoded. The proof is the |
| 156 | - 1. reads the caller shape set out of `decode.rs`'s own call-site argument lists (paren-balanced argument splitter, so the `(at32.0 + 1, at32.1)` origin argument does not shift the indices), asserts the site count and the shape set; | 156 | +> static caller-shape-set derivation in §1, and the deliverable below is what |
| 157 | - 2. reads the `match (chroma_w, chroma_h)` arm heads out of the function's own text and pins the exact six-row set (class `table-and-reader-move-together`: a table edit invalidates the test); | 157 | +> makes the tree enforce it rather than trusting this report. |
| 158 | - 3. walks every caller shape under `{(0,0), (1,0), (1,1)}` and asserts a row exists for each; | 158 | + |
| 159 | - 4. asserts the residual as code, not a comment: `(4, 8)` / `(8, 4)` are *not* rows, and no caller shape can produce them. | 159 | +`refusal_inventory.rs` gained a `PROVEN` row for the string (it previously had |
| 160 | - | 160 | +**none** — it was the audit round's single unproven row) and the test that proves |
| 161 | -The inventory summary moved from **32 proven to 33 proven**; all 16 `refusal_inventory` tests pass. | 161 | +it, in the same file as the sibling enumeration. |
| 162 | - | 162 | + |
| 163 | -### Non-vacuity: three red-proofs, then revert | 163 | +### Where the assertions live, and why not inside the sibling test |
| 164 | - | 164 | + |
| 165 | -| mutation | result | | 165 | +Main asked for this to be folded into |
| 166 | -|---|---| | 166 | +`every_rect_strip_shape_the_split_path_codes_has_a_luma_and_chroma_table`. It is |
| 167 | -| `decode.rs:34490` `32,` → `8,` (an 8x16 caller appears) | **RED** — `the set of strip sizes decode_block_rect is called with changed … An 8x16/16x8 caller makes this refusal LIVE` | | 167 | +shipped as a sibling test in the same file instead, because that test audits |
| 168 | -| a `(4, 8) => (TxbSet::ChromaRect8x4, &SCAN_4X8),` row added to the table | **RED** — `decode_block_rect's chroma table changed -- re-derive the walk below` | | 168 | +`decode_rect_split`'s two `match` tables via a `depth_to_tx_wh` walk — it has no |
| 169 | -| `decode.rs:34490` `32,` → `at32.0 * 2,` (a call site stops being a literal) | **RED** — `decode_block_rect is called with a non-literal strip size "at32.0 * 2"` | | 169 | +caller-shape-set notion at all. Getting `decode_block_rect`'s domain requires a |
| 170 | - | 170 | +paren-balanced argument splitter over the call sites (~60 lines) plus a |
| 171 | -`decode.rs` restored byte-identical after each (`git status` shows `refusal_inventory.rs` as the only modified file). | 171 | +subsampling walk. Folding that in would have made the sibling test answer two |
| 172 | +different claims and would have duplicated the parser to do it. The two tests | ||
| 173 | +are adjacent and the `PROVEN` row names the new one, so the claim is still | ||
| 174 | +asserted in exactly one place. Say the word and I will move it. | ||
| 175 | + | ||
| 176 | +### `every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table` (`refusal_inventory.rs:1571`) | ||
| 177 | + | ||
| 178 | +1. **Caller shape set**, read out of `decode.rs`'s own call-site argument lists | ||
| 179 | + with a paren/bracket-balanced splitter — the `at` argument is | ||
| 180 | + `(at32.0 + 1, at32.1)`, whose internal comma shifts every later index by one, | ||
| 181 | + so naive indexing reads `at32` as `bw` (I hit this). Asserts the site count | ||
| 182 | + (8) and requires `bw`/`bh` to be **integer literals**. This is the invariant | ||
| 183 | + that makes the whole argument true, and it is pinned in the shape this crate | ||
| 184 | + already uses for such scans: `include_str!("decode.rs")` read at | ||
| 185 | + compile time. | ||
| 186 | +2. **The table**, read out of the function's own text, arm heads only | ||
| 187 | + (`(w, h) =>` / `(w, h) |`, never a `(32, 8)` inside prose). | ||
| 188 | +3. **The walk** — every caller shape under every subsampling an AV1 | ||
| 189 | + `color_config` can carry, `{(0,0), (1,0), (1,1)}`. Asserts a row for each. | ||
| 190 | +4. **The exact-table pin**: the table is *exactly* those six rows — no row is a | ||
| 191 | + shape no caller can present, which is what makes the `_` arm dead. | ||
| 192 | +5. **The residual as code, not a comment**: `(4, 8)` / `(8, 4)` are *not* rows, | ||
| 193 | + and no caller shape can produce them. | ||
| 194 | + | ||
| 195 | +The inventory summary moved from **32 proven to 33 proven**; all 16 | ||
| 196 | +`refusal_inventory` tests pass. | ||
| 197 | + | ||
| 198 | +### Ordering note (fixed mid-lane, kept) | ||
| 199 | + | ||
| 200 | +Steps 3 and 4 were first written the other way round, and the exact-table pin | ||
| 201 | +masked the walk: deleting the `(16, 8)` arm failed with "the chroma table | ||
| 202 | +changed" instead of naming the footprint. **The walk now runs before the pin**, so | ||
| 203 | +a deleted arm fails naming the strip and its subsampling. | ||
| 204 | + | ||
| 205 | +### Non-vacuity: four red-befores, each reverted with `decode.rs` byte-identical | ||
| 206 | + | ||
| 207 | +This crate's census tests read compile-time sources via `include_str!`, so | ||
| 208 | +`decode.rs` is `touch`ed before each re-run — otherwise a stale test binary can | ||
| 209 | +report the previous state. | ||
| 210 | + | ||
| 211 | +| # | mutation | result | | ||
| 212 | +|---|---|---| | ||
| 213 | +| A | `decode.rs:14791` — delete the `(16, 8) =>` arm | **RED** at `refusal_inventory.rs:1705` — `a 32x16 strip at subsampling (1,1) has a 16x8 chroma transform with no coefficient table -- the chroma refusal is LIVE` | | ||
| 214 | +| B | `decode.rs:14801` — delete the `(16, 16) =>` arm (the 4:2:2 row) | **RED** at `refusal_inventory.rs:1705` — `a 32x16 strip at subsampling (1,0) has a 16x16 chroma transform with no coefficient table -- the chroma refusal is LIVE` | | ||
| 215 | +| C | `decode.rs:34536` — the `PARTITION_VERT` call site's `16,` → `8,` (an 8x16 caller appears) | **RED** at `refusal_inventory.rs:1647` — `the set of strip sizes decode_block_rect is called with changed -- re-derive the chroma domain below. An 8x16/16x8 caller makes this refusal LIVE` | | ||
| 216 | +| D | `decode.rs:34490` — `32,` → `at32.0 * 2,` (a call site stops being a literal) | **RED** at `refusal_inventory.rs:1631` — `decode_block_rect is called with a non-literal strip size "at32.0 * 2" -- this enumeration can no longer read the caller shape set` | | ||
| 217 | + | ||
| 218 | +A and B are the row-coverage arm (they fail **naming the footprint**); C and D | ||
| 219 | +are the caller-set invariant (they fail before the table is even consulted). | ||
| 220 | +Restored byte-identical after each; `git status` shows | ||
| 221 | +`refusal_inventory.rs` as the only modified file. | ||
| 222 | + | ||
| 223 | +### What makes the claim survive a future edit | ||
| 224 | + | ||
| 225 | +- A new caller with a different size → **C** fires (shape set changed). | ||
| 226 | +- A caller whose size stops being a literal → **D** fires, because a variable | ||
| 227 | + could be anything and the enumeration must not silently under-count. | ||
| 228 | +- A row deleted → **A**/**B** fires, naming the strip and subsampling. | ||
| 229 | +- A row *added* for a shape no caller presents → step 4 fires, and step 5 fires | ||
| 230 | + if it is `(4, 8)` / `(8, 4)`. | ||
| 172 | 231 | ||
| 173 | --- | 232 | --- |
| 174 | 233 | ||
| 175 | ## 5. Scope and hygiene | 234 | ## 5. Scope and hygiene |
| 176 | 235 | ||
| 177 | -- No existing test weakened, renamed, or re-pinned. Net diff: `crates/ec-av1/src/refusal_inventory.rs`, **+240 / -0**. | 236 | +- No existing test weakened, renamed, or re-pinned. Net diff vs the lane base |
| 237 | + `afa13bcf`: `crates/ec-av1/src/refusal_inventory.rs` **+246 / -0** (the new | ||
| 238 | + `PROVEN` row plus the new test) and this report. | ||
| 178 | - `decode_rect_split` and `read_block_tx_size` untouched (other lanes own them). `decode.rs` untouched. | 239 | - `decode_rect_split` and `read_block_tx_size` untouched (other lanes own them). `decode.rs` untouched. |
| 179 | -- `decode_block_rect` itself untouched — the refusal stays as a named shape guard for the next caller, the repo's convention for a proven-unreachable guard (same as `a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol`). | 240 | +- `decode_block_rect` itself untouched — the refusal stays as a named shape guard for the next caller, the repo convention for a proven-unreachable guard (same as `a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol`). |
| 180 | -- The scratch sweep lived in two `#[ignore]`d tests, ran, and were deleted; the tree diff is the 240-line addition above. | 241 | +- The scratch sweep lived in two `#[ignore]`d tests, ran, and were deleted; the tree diff is the 246-line addition above. |
| 181 | - Main untouched: `git -C /home/user/Documents/Code/Rust/edith_codecs status --porcelain` shows no tracked-file modification from this lane. Never pushed. | 242 | - Main untouched: `git -C /home/user/Documents/Code/Rust/edith_codecs status --porcelain` shows no tracked-file modification from this lane. Never pushed. |
| 182 | 243 | ||
| 183 | 244 | ||