Merge lane-av1rect8x16 @ ee56661f — test-only refusal_inventory gate for decode_block_rect's `_` arm
Browse files at this commit2 changed files +495 -0
crates/ec-av1/src/refusal_inventory.rsmodified+248 -0
| @@ -553,6 +553,27 @@ const PROVEN: &[(&str, &str)] = &[ | ||
| 553 | 553 | "a 64-axis strip whose chroma unit has no coefficient table", |
| 554 | 554 | "every_chroma_unit_a_64_axis_strip_can_present_has_a_coefficient_table", |
| 555 | 555 | ), |
| 556 | + // lane-av1rect8x16, enumeration: `decode_block_rect`'s `_` arm. The nine | |
| 557 | + // textual `decode_block_rect(` matches are 1 declaration + 8 call sites | |
| 558 | + // (this test's `assert_eq!(sites, 8)` counts the calls); all eight pass | |
| 559 | + // `bw`/`bh` as integer LITERALS and every one of them is | |
| 560 | + // a 32-level `PARTITION_HORZ`/`VERT`/`HORZ_A`/`_B`/`VERT_A`/`_B` arm of | |
| 561 | + // `read_sb128_root`'s `match part32`, so the caller shape set is exactly | |
| 562 | + // {32x16, 16x32} and their chroma halves under the three subsamplings an | |
| 563 | + // AV1 `color_config` can carry are {(16,8), (8,16), (16,16), (8,32), | |
| 564 | + // (32,16), (16,32)} -- every one of which has a row. The shape the | |
| 565 | + // sibling sweep left open, a 4:2:0 8x16 luma strip's (4,8) chroma, is | |
| 566 | + // NOT reachable here: a 16-level 2:1 luma strip is read by | |
| 567 | + // `decode_leaf_rect`, which carries the (4,8)/(8,4) rows itself | |
| 568 | + // (decode.rs:15409-15420). Measured, not assumed: 840 real aomenc 4:2:0 | |
| 569 | + // key-frame encodes, 826 of whose parsed leaf lists carry a coded | |
| 570 | + // 16-level 2:1 luma strip (`horz_vert_intra_hits()`, which fires only | |
| 571 | + // at the three `decode_leaf_rect` strip sites), decoded to completion | |
| 572 | + // with this string firing 0 times. | |
| 573 | + ( | |
| 574 | + "a rectangular chroma transform whose size has no coefficient table", | |
| 575 | + "every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table", | |
| 576 | + ), | |
| 556 | 577 | // lane-t900 r33, enumeration: each of the four symbols this guard tests is |
| 557 | 578 | // read under a size gate that no 128-pixel side passes (the call site's |
| 558 | 579 | // literal `cfl=false`, `filter_intra_size_class_rect`'s table, and |
| @@ -1514,6 +1535,233 @@ mod tests { | ||
| 1514 | 1535 | ); |
| 1515 | 1536 | } |
| 1516 | 1537 | |
| 1538 | + /// lane-av1rect8x16, ENUMERATION for "a rectangular chroma transform | |
| 1539 | + /// whose size has no coefficient table" -- | |
| 1540 | + /// [`crate::decode::decode_block_rect`]'s `_` arm. | |
| 1541 | + /// | |
| 1542 | + /// This refusal had NO `PROVEN` row: the sibling sweep that found the | |
| 1543 | + /// gap (`every_rect_strip_shape_the_split_path_codes_has_a_luma_and_ | |
| 1544 | + /// chroma_table`, which audits `decode_rect_split`'s tables, not this | |
| 1545 | + /// function's) asserted only the superblock-level 64x32/32x64 | |
| 1546 | + /// footprints, so the 8x16 luma strip's 4x8 chroma was left unasked. | |
| 1547 | + /// | |
| 1548 | + /// The answer is that the shape is UNREACHABLE, and structurally so: | |
| 1549 | + /// every one of the function's call sites passes its `bw`/`bh` as | |
| 1550 | + /// integer LITERALS, and all of them are 32-level `PARTITION_HORZ` / | |
| 1551 | + /// `VERT` / `HORZ_A` / `HORZ_B` / `VERT_A` / `VERT_B` arms of | |
| 1552 | + /// `read_sb128_root`'s `match part32` -- i.e. 32x16 or 16x32, never | |
| 1553 | + /// 8x16. A 16-level 2:1 luma strip (16x8 / 8x16) is read by | |
| 1554 | + /// [`crate::decode::decode_leaf_rect`], which carries the matching | |
| 1555 | + /// `(4, 8)` / `(8, 4)` chroma rows (decode.rs:15409-15420, | |
| 1556 | + /// `TxbSet::ChromaRect8x4` + `SCAN_4X8` / `SCAN_8X4`). | |
| 1557 | + /// | |
| 1558 | + /// So the proof is the CALLER SHAPE SET, read out of the call sites' | |
| 1559 | + /// own argument lists, walked through `bw >> ss_x` / `bh >> ss_y` for | |
| 1560 | + /// every subsampling an AV1 `color_config` can carry, against the | |
| 1561 | + /// `match (chroma_w, chroma_h)` table read out of the function's own | |
| 1562 | + /// text (class `table-and-reader-move-together`: a table edit | |
| 1563 | + /// invalidates this test rather than sneaking past it). | |
| 1564 | + /// | |
| 1565 | + /// The subsampling domain is `{(0,0), (1,0), (1,1)}` and excludes | |
| 1566 | + /// `(0,1)`: `ec-av1-syntax`'s `color_config` only ever READS | |
| 1567 | + /// `subsampling_y` when `subsampling_x == 1` (sequence.rs:481), so | |
| 1568 | + /// `(0,1)` is uncodable. `(1,0)` is 4:2:2, refused at the sequence | |
| 1569 | + /// header by `a_non_420_subsampled_sequence_header_is_refused_by_name` | |
| 1570 | + /// -- it is walked anyway, so the proof does not depend on that guard | |
| 1571 | + /// staying in place. | |
| 1572 | + #[test] | |
| 1573 | + fn every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table() { | |
| 1574 | + let src = include_str!("decode.rs"); | |
| 1575 | + | |
| 1576 | + // (1) The caller shape set, read out of the call sites' own | |
| 1577 | + // argument lists. `decode_block_rect(dec, cdfs, neighbours, at, bw, | |
| 1578 | + // bh, ...)`, so args 4 and 5 (0-based, after the opening paren) are | |
| 1579 | + // `bw` and `bh`; the first three are the fixed `&mut` borrows. | |
| 1580 | + const LEAD: [&str; 3] = ["&mut dec", "&mut cdfs", "&mut neighbours"]; | |
| 1581 | + let mut shapes: BTreeSet<(usize, usize)> = BTreeSet::new(); | |
| 1582 | + let mut sites = 0usize; | |
| 1583 | + let at_def = src | |
| 1584 | + .find("fn decode_block_rect(") | |
| 1585 | + .expect("decode_block_rect is gone"); | |
| 1586 | + for (i, _) in src.match_indices("decode_block_rect(") { | |
| 1587 | + // The definition's own parameter list carries the same text, | |
| 1588 | + // preceded by "fn " -- that is a declaration, not a call. | |
| 1589 | + if src[..i].ends_with("fn ") { | |
| 1590 | + continue; | |
| 1591 | + } | |
| 1592 | + // Split the argument list at top level (paren/bracket/angle | |
| 1593 | + // balanced), so the `(at32.0 + 1, at32.1)` origin argument -- | |
| 1594 | + // which contains its own comma -- does not shift the indices. | |
| 1595 | + let open = i + "decode_block_rect(".len(); | |
| 1596 | + let bytes = src.as_bytes(); | |
| 1597 | + let mut args: Vec<String> = Vec::new(); | |
| 1598 | + let mut depth = 0i32; | |
| 1599 | + let mut start = open; | |
| 1600 | + for j in open..bytes.len() { | |
| 1601 | + match bytes[j] { | |
| 1602 | + b'(' | b'[' => depth += 1, | |
| 1603 | + b')' | b']' => { | |
| 1604 | + if depth == 0 { | |
| 1605 | + args.push(src[start..j].to_string()); | |
| 1606 | + break; | |
| 1607 | + } | |
| 1608 | + depth -= 1; | |
| 1609 | + } | |
| 1610 | + b',' if depth == 0 => { | |
| 1611 | + args.push(src[start..j].to_string()); | |
| 1612 | + start = j + 1; | |
| 1613 | + } | |
| 1614 | + _ => {} | |
| 1615 | + } | |
| 1616 | + } | |
| 1617 | + assert!( | |
| 1618 | + args.len() >= 6, | |
| 1619 | + "a decode_block_rect call has only {} arguments -- the arg indices this \ | |
| 1620 | + enumeration reads are off", | |
| 1621 | + args.len() | |
| 1622 | + ); | |
| 1623 | + for k in 0..3 { | |
| 1624 | + assert_eq!( | |
| 1625 | + args[k].trim(), | |
| 1626 | + LEAD[k], | |
| 1627 | + "decode_block_rect's first three arguments changed -- re-derive the bw/bh \ | |
| 1628 | + argument indices below" | |
| 1629 | + ); | |
| 1630 | + } | |
| 1631 | + let lit = |a: &str| -> usize { | |
| 1632 | + a.trim().parse::<usize>().unwrap_or_else(|_| { | |
| 1633 | + panic!( | |
| 1634 | + "decode_block_rect is called with a non-literal strip size {:?} -- \ | |
| 1635 | + this enumeration can no longer read the caller shape set", | |
| 1636 | + a.trim() | |
| 1637 | + ) | |
| 1638 | + }) | |
| 1639 | + }; | |
| 1640 | + shapes.insert((lit(&args[4]), lit(&args[5]))); | |
| 1641 | + sites += 1; | |
| 1642 | + } | |
| 1643 | + assert_eq!( | |
| 1644 | + sites, 8, | |
| 1645 | + "the number of decode_block_rect call sites changed" | |
| 1646 | + ); | |
| 1647 | + let expected_shapes: BTreeSet<(usize, usize)> = | |
| 1648 | + [(32usize, 16usize), (16, 32)].into_iter().collect(); | |
| 1649 | + assert_eq!( | |
| 1650 | + shapes, expected_shapes, | |
| 1651 | + "the set of strip sizes decode_block_rect is called with changed -- re-derive \ | |
| 1652 | + the chroma domain below. An 8x16/16x8 caller makes this refusal LIVE (a \ | |
| 1653 | + 4:2:0 8x16 luma strip's chroma is 4x8, which libaom codes as TX_4X8: \ | |
| 1654 | + av1_ss_size_lookup[BLOCK_8X16][1][1] = BLOCK_4X8 in \ | |
| 1655 | + av1/common/common_data.c:24, then max_txsize_rect_lookup[BLOCK_4X8] = TX_4X8 \ | |
| 1656 | + in av1/common/common_data.h:130, via av1_get_max_uv_txsize, blockd.h:1372)" | |
| 1657 | + ); | |
| 1658 | + | |
| 1659 | + // (2) The table, read out of the function's own text: every | |
| 1660 | + // `(w, h) =>` / `(w, h) |` arm head between the match and the guard. | |
| 1661 | + let body_at = at_def; | |
| 1662 | + let rest = &src[body_at..]; | |
| 1663 | + let body = &rest[..rest.find("\nfn ").expect("unterminated fn")]; | |
| 1664 | + let from = body | |
| 1665 | + .find("let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (chroma_w, chroma_h)") | |
| 1666 | + .expect("decode_block_rect's chroma match is gone"); | |
| 1667 | + let to = body[from..] | |
| 1668 | + .find("a rectangular chroma transform whose size has no coefficient table") | |
| 1669 | + .expect("the refusal string is gone from decode_block_rect") | |
| 1670 | + + from; | |
| 1671 | + let table = &body[from..to]; | |
| 1672 | + let mut arms: BTreeSet<(usize, usize)> = BTreeSet::new(); | |
| 1673 | + let bytes = table.as_bytes(); | |
| 1674 | + for (i, _) in table.match_indices('(') { | |
| 1675 | + let mut j = i + 1; | |
| 1676 | + let mut w = 0usize; | |
| 1677 | + while j < bytes.len() && bytes[j].is_ascii_digit() { | |
| 1678 | + w = w * 10 + usize::from(bytes[j] - b'0'); | |
| 1679 | + j += 1; | |
| 1680 | + } | |
| 1681 | + if j == i + 1 || !table[j..].starts_with(", ") { | |
| 1682 | + continue; | |
| 1683 | + } | |
| 1684 | + j += 2; | |
| 1685 | + let mut h = 0usize; | |
| 1686 | + let start_h = j; | |
| 1687 | + while j < bytes.len() && bytes[j].is_ascii_digit() { | |
| 1688 | + h = h * 10 + usize::from(bytes[j] - b'0'); | |
| 1689 | + j += 1; | |
| 1690 | + } | |
| 1691 | + if j == start_h || !table[j..].starts_with(')') { | |
| 1692 | + continue; | |
| 1693 | + } | |
| 1694 | + // Only an arm HEAD counts, never a `(32, 8)` inside prose. | |
| 1695 | + let after = table[j + 1..].trim_start(); | |
| 1696 | + if after.starts_with("=>") || after.starts_with('|') { | |
| 1697 | + arms.insert((w, h)); | |
| 1698 | + } | |
| 1699 | + } | |
| 1700 | + // (3) The enumeration itself -- run BEFORE the exact-table pin below | |
| 1701 | + // so a deleted arm fails HERE, naming the footprint, instead of | |
| 1702 | + // behind a vaguer "the table changed". | |
| 1703 | + let mut checked = 0u32; | |
| 1704 | + for &(bw, bh) in &shapes { | |
| 1705 | + for (ss_x, ss_y) in [(0usize, 0usize), (1, 0), (1, 1)] { | |
| 1706 | + let (cw, ch) = (bw >> ss_x, bh >> ss_y); | |
| 1707 | + assert!( | |
| 1708 | + arms.contains(&(cw, ch)), | |
| 1709 | + "a {bw}x{bh} strip at subsampling ({ss_x},{ss_y}) has a {cw}x{ch} chroma \ | |
| 1710 | + transform with no coefficient table -- the chroma refusal is LIVE" | |
| 1711 | + ); | |
| 1712 | + checked += 1; | |
| 1713 | + } | |
| 1714 | + } | |
| 1715 | + assert_eq!( | |
| 1716 | + checked, 6, | |
| 1717 | + "the chroma domain is not two shapes x three formats" | |
| 1718 | + ); | |
| 1719 | + | |
| 1720 | + // (4) And the table is EXACTLY those six rows -- no row is a shape no | |
| 1721 | + // caller can present, which is what makes the `_` arm dead. | |
| 1722 | + assert_eq!( | |
| 1723 | + arms, | |
| 1724 | + [ | |
| 1725 | + (8usize, 16usize), | |
| 1726 | + (8, 32), | |
| 1727 | + (16, 8), | |
| 1728 | + (16, 16), | |
| 1729 | + (16, 32), | |
| 1730 | + (32, 16) | |
| 1731 | + ] | |
| 1732 | + .into_iter() | |
| 1733 | + .collect::<BTreeSet<(usize, usize)>>(), | |
| 1734 | + "decode_block_rect's chroma table changed -- re-derive the walk above" | |
| 1735 | + ); | |
| 1736 | + | |
| 1737 | + // (5) The residual, stated as an assertion so it cannot rot: the two | |
| 1738 | + // 4:2:0 rows an 8x16/16x8 luma strip would need are NOT in this | |
| 1739 | + // table, and (4,8)/(8,4) is not a shape any caller can produce. If a | |
| 1740 | + // future caller hands this function an 8x16, step (1) goes red | |
| 1741 | + // first, and the new row has to be added here with it. | |
| 1742 | + for residual in [(4usize, 8usize), (8, 4)] { | |
| 1743 | + assert!( | |
| 1744 | + !arms.contains(&residual), | |
| 1745 | + "decode_block_rect grew a {0}x{1} chroma row -- update the residual note", | |
| 1746 | + residual.0, | |
| 1747 | + residual.1 | |
| 1748 | + ); | |
| 1749 | + } | |
| 1750 | + let produces: BTreeSet<(usize, usize)> = shapes | |
| 1751 | + .iter() | |
| 1752 | + .flat_map(|&(bw, bh)| { | |
| 1753 | + [(0usize, 0usize), (1, 0), (1, 1)] | |
| 1754 | + .into_iter() | |
| 1755 | + .map(move |(sx, sy)| (bw >> sx, bh >> sy)) | |
| 1756 | + }) | |
| 1757 | + .collect(); | |
| 1758 | + assert!( | |
| 1759 | + !produces.contains(&(4, 8)) && !produces.contains(&(8, 4)), | |
| 1760 | + "the caller set can now produce a 4x8/8x4 chroma shape but the table has no \ | |
| 1761 | + such row -- the chroma refusal is LIVE" | |
| 1762 | + ); | |
| 1763 | + } | |
| 1764 | + | |
| 1517 | 1765 | /// lane-av1-refusalaudit, ENUMERATION for "a 64-axis strip whose chroma |
| 1518 | 1766 | /// unit has no coefficient table" -- [`decode_block_rect64`]'s `_` arm, |
| 1519 | 1767 | /// reached only for depth-0, non-skip, non-lossless superblock-level |
lanes/av1rect8x16.report.mdadded+247 -0
| @@ -0,0 +1,247 @@ | ||
| 1 | +# lane-av1rect8x16 — is `decode_block_rect`'s missing `(4, 8)` chroma arm a live refusal or a documented upstream gate? | |
| 2 | + | |
| 3 | +**Base:** `afa13bcff4a988534555a4ca34b84937d0b6036d` (branch `lane-av1rect8x16`, worktree `~/.cache/wt/av1rect8x16`). | |
| 4 | +**Verdict:** **(a) UNREACHABLE — documented upstream gate.** The claim is true about the `match` and false about the decoder: a 4:2:0 8x16 luma strip is never handed to `decode_block_rect` at all, so no conformant stream can reach the refusal. A conformant 4:2:0 stream that codes 8x16/16x8 luma strips decodes to completion; measured 826 of them. | |
| 5 | + | |
| 6 | +--- | |
| 7 | + | |
| 8 | +## 0. The question, restated | |
| 9 | + | |
| 10 | +`decode_block_rect` (`decode.rs:14475`) ends its non-skip chroma read with | |
| 11 | + | |
| 12 | +```rust | |
| 13 | +let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (chroma_w, chroma_h) { // decode.rs:14788 | |
| 14 | + (32, 16) => (TxbSet::ChromaRect32x16, &SCAN_32X16), | |
| 15 | + (16, 32) => (TxbSet::ChromaRect32x16, &SCAN_16X32), | |
| 16 | + (16, 8) => (TxbSet::ChromaRect16x8, &SCAN_16X8), | |
| 17 | + (8, 16) => (TxbSet::ChromaRect16x8, &SCAN_8X16), | |
| 18 | + (16, 16) => (TxbSet::Chroma16, default_scan(16)), | |
| 19 | + (8, 32) => (TxbSet::Chroma16, &SCAN_8X32), | |
| 20 | + _ => { | |
| 21 | + return Err(unsupported( // decode.rs:14804 | |
| 22 | + "a rectangular chroma transform whose size has no coefficient table", | |
| 23 | + )); | |
| 24 | + } | |
| 25 | +}; | |
| 26 | +``` | |
| 27 | + | |
| 28 | +`(chroma_w, chroma_h) == (bw >> ss_x(fctx), bh >> ss_y(fctx))` (`decode.rs:14680`). A 4:2:0 8x16 luma strip halves both axes to a 4x8 chroma block, `(4, 8)` has no arm, so the string would fire **if that shape reached the function**. The sibling test `every_rect_strip_shape_the_split_path_codes_has_a_luma_and_chroma_table` audits `decode_rect_split`'s tables, not this one, so it never asks. | |
| 29 | + | |
| 30 | +**State on arrival:** the string was in `REFUSALS` (`refusal_inventory.rs:50`) with **no `PROVEN` row** — the one unproven row this audit round was cataloguing. | |
| 31 | + | |
| 32 | +--- | |
| 33 | + | |
| 34 | +## 1. CALLER SET, mechanically | |
| 35 | + | |
| 36 | +`decode_block_rect(` has **9 textual matches in the crate: 1 declaration + 8 call sites.** All 8 call sites are in one function, `read_sb128_root` (`decode.rs:32852`), and none is inside a `macro_rules!` body. | |
| 37 | + | |
| 38 | +The dispatch chain that reaches them: | |
| 39 | + | |
| 40 | +``` | |
| 41 | +SB match PARTITION_SPLIT decode.rs:33651 | |
| 42 | + -> 4 x 32x32 quadrant (r32, c32) = (sb_r*2 + q/2, sb_c*2 + q%2) decode.rs:33652-33656 | |
| 43 | + -> part32 = dec.symbol(&mut cdfs.partition_w32[ctx32]) (BLOCK_32X32, bsize=9) decode.rs:33663-33674 | |
| 44 | + -> match part32 { decode.rs:33743 | |
| 45 | + PARTITION_HORZ | HORZ_A | HORZ_B | VERT | VERT_A | VERT_B ==> decode_block_rect | |
| 46 | + PARTITION_SPLIT => 4 x 16x16 (sr, sc) decode.rs:33774-33778 | |
| 47 | + part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]) (BLOCK_16X16, bsize=6) decode.rs:33801 | |
| 48 | + match part16 { ... } decode.rs:33844 / 33989 / 34037 | |
| 49 | +``` | |
| 50 | + | |
| 51 | +| # | call site | enclosing arm | upstream guard (verbatim) | `bw`/`bh` passed | can it be handed an 8x16 / 16x8 strip? | | |
| 52 | +|---|---|---|---|---|---| | |
| 53 | +| 1 | `decode.rs:34485` | `PARTITION_HORZ =>` | `match part32 {` at `decode.rs:33743`, `part32` read at `decode.rs:33674` from `cdfs.partition_w32[ctx32]` | `at32, 32, 16` | **No** — 32-level HORZ, two 32x16 strips | | |
| 54 | +| 2 | `decode.rs:34509` | same arm, frame-edge half | `if has_rows32 {` at `decode.rs:34508`; `has_rows32` from `has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows)` at `decode.rs:33661` | `(at32.0 + 1, at32.1), 32, 16` | **No** | | |
| 55 | +| 3 | `decode.rs:34531` | `PARTITION_VERT =>` | same `match part32` | `at32, 16, 32` | **No** | | |
| 56 | +| 4 | `decode.rs:34555` | same arm, frame-edge half | `if has_cols32 {` at `decode.rs:34554`; `has_cols32` from `has_half(c32 * BLOCK_MI, BLOCK_MI, mi_cols)` at `decode.rs:33660` | `(at32.0, at32.1 + 1), 16, 32` | **No** | | |
| 57 | +| 5 | `decode.rs:34634` | `PARTITION_HORZ_A =>` | `match part32` (`PARTITION_HORZ_A` is value 8, read from the same `partition_w32` symbol) | `(at32.0 + 1, at32.1), 32, 16` | **No** — the 32x16 is the third child of a 32x32 | | |
| 58 | +| 6 | `decode.rs:34658` | `PARTITION_HORZ_B =>` | `match part32` | `at32, 32, 16` | **No** | | |
| 59 | +| 7 | `decode.rs:34790` | `PARTITION_VERT_A =>` | `match part32` | `(at32.0, at32.1 + 1), 16, 32` | **No** | | |
| 60 | +| 8 | `decode.rs:34815` | `PARTITION_VERT_B =>` | `match part32` | `at32, 16, 32` | **No** | | |
| 61 | + | |
| 62 | +**The caller shape set is exactly `{(32, 16), (16, 32)}`, and every `bw`/`bh` is an integer literal — there is no variable, no computed size, no dispatch that could yield 8x16.** This is now asserted in code, not merely observed: `every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table` parses the argument lists out of `decode.rs` itself (§5). | |
| 63 | + | |
| 64 | +### Where an 8x16 / 16x8 luma strip ACTUALLY goes | |
| 65 | + | |
| 66 | +Every 16-level 2:1 luma strip is read by **`decode_leaf_rect`** (`decode.rs:15064`), which is a different function with the matching chroma rows: | |
| 67 | + | |
| 68 | +| 16-level route | call site | strip | reader | | |
| 69 | +|---|---|---|---| | |
| 70 | +| `part16 == PARTITION_HORZ` | `decode.rs:33995` / `34014` | `16, 8` x2 | `decode_leaf_rect` | | |
| 71 | +| `part16 == PARTITION_VERT` | `decode.rs:34044` / `34063` | `8, 16` x2 | `decode_leaf_rect` | | |
| 72 | +| `part16 ∈ HORZ_A..=VERT_B` via `ab_strip!` | `decode.rs:33942`, `33946`, `33963`, `33967` | `16, 8` / `8, 16` | `decode_leaf_rect` | | |
| 73 | +| frame-edge 8-mod-16 strip | `decode.rs:34336` | `(16, 8)` or `(8, 16)` per `if has_cols16 { (16, 8) } else { (8, 16) }` (`decode.rs:34334`) | `decode_leaf_rect` | | |
| 74 | + | |
| 75 | +`decode_leaf_rect` handles the 4:2:0 chroma half of exactly those strips — `(4, 8)` and `(8, 4)` — with `SCAN_4X8` / `SCAN_8X4` and `TxbSet::ChromaRect8x4` (`decode.rs:15409-15420`): | |
| 76 | + | |
| 77 | +```rust | |
| 78 | +} else if bw == 16 { | |
| 79 | + (&SCAN_16X8, &SCAN_8X4) | |
| 80 | +} else { | |
| 81 | + (&SCAN_8X16, &SCAN_4X8) | |
| 82 | +}; | |
| 83 | +``` | |
| 84 | + | |
| 85 | +So the `(4, 8)` arm is missing from a function that cannot be handed a 4x8, and present in the function that can. | |
| 86 | + | |
| 87 | +### Chroma-domain walk over the caller set | |
| 88 | + | |
| 89 | +For each caller shape, under each subsampling an AV1 `color_config` can carry: | |
| 90 | + | |
| 91 | +| caller | (ss_x, ss_y) | chroma `(bw>>ss_x, bh>>ss_y)` | arm? | | |
| 92 | +|---|---|---|---| | |
| 93 | +| 32x16 | (0,0) 4:4:4 | (32, 16) | yes | | |
| 94 | +| 32x16 | (1,0) 4:2:2 | (16, 16) | yes | | |
| 95 | +| 32x16 | (1,1) 4:2:0 | (16, 8) | yes | | |
| 96 | +| 16x32 | (0,0) 4:4:4 | (16, 32) | yes | | |
| 97 | +| 16x32 | (1,0) 4:2:2 | (8, 32) | yes | | |
| 98 | +| 16x32 | (1,1) 4:2:0 | (8, 16) | yes | | |
| 99 | + | |
| 100 | +`(0, 1)` is **structurally uncodable**: `ec-av1-syntax`'s `color_config` only reads `subsampling_y` when `subsampling_x == 1` (`crates/ec-av1-syntax/src/sequence.rs:480-485`), so that pair never exists. `(1, 0)` is 4:2:2, refused at the sequence header by `a_non_420_subsampled_sequence_header_is_refused_by_name` — walked anyway, so the proof does not lean on that guard. **The table is complete over the caller set. The refusal is dead code.** | |
| 101 | + | |
| 102 | +--- | |
| 103 | + | |
| 104 | +## 2. EMPIRICAL — the decisive test | |
| 105 | + | |
| 106 | +Non-vacuity precondition: `HORZ_VERT_INTRA_HITS` fires at exactly three sites, `decode.rs:33990`, `34038`, `34330` — all three are `decode_leaf_rect` 16-level 2:1 strip routes. **A nonzero `horz_vert_intra_hits()` delta is therefore proof that the stream's parsed leaf list really contains a coded 16x8/8x16 luma strip**, not a proxy for it. | |
| 107 | + | |
| 108 | +Sweep: 7 sources (mandelbrot 64x64 / 128x128 / 130x122, testsrc2 64x64 / 128x128, rgbtestsrc, smptebars) x cq {16,22,28,34,42,52} x (`--cpu-used`, `--max-partition-size`) ∈ {(0,16),(0,32),(1,16),(3,32),(4,64)} x `--enable-ab-partitions` {0,1} x `--reduced-tx-type-set` {0,1}, always `--codec=av1 --passes=1 --end-usage=q --threads=1 --row-mt=0 --sb-size=64 --kf-max-dist=0 --enable-rect-partitions=1 --enable-1to4-partitions=0 --enable-cdef=0 --enable-restoration=0 --min-partition-size=8 --obu`, single yuv420p key frame from `ffmpeg -f lavfi`. | |
| 109 | + | |
| 110 | +``` | |
| 111 | +SUMMARY attempts=840 decoded=840 streams_with_16lvl_strips=826 refusals_with_16lvl_strips=0 | |
| 112 | +``` | |
| 113 | + | |
| 114 | +| recipe family | parsed 16-level 2:1 luma strips | decode | `"a rectangular chroma transform…"` | | |
| 115 | +|---|---|---|---| | |
| 116 | +| 840 encodes (full grid above) | 826 of 840 streams carry ≥1 (3–20 each; cq 52 cpu=0 max=16 reached 20) | **840/840 `Ok`**, 1 frame each | **0 occurrences** | | |
| 117 | +| the 14 that carry none | 0 | 840 group total, all `Ok` | 0 | | |
| 118 | + | |
| 119 | +Three witness streams, each independently carrying coded 8x16/16x8 luma strips and each decoding `Ok`: | |
| 120 | + | |
| 121 | +| file | recipe | 16-lvl strips | sha256 | size | | |
| 122 | +|---|---|---|---|---| | |
| 123 | +| `w_cq34_cpu0_max16.obu` | mandelbrot 130x122, `--cq-level=34 --cpu-used=0 --min-partition-size=8 --max-partition-size=16 --enable-ab-partitions=1` | 17 | `6189103938308fac94fb027448f64d0cf3fc791968cf8aae4cb27a8d904f7ae8` | 1588 | | |
| 124 | +| `w_cq28_cpu1_max16.obu` | same, `--cq-level=28 --cpu-used=1` | 13 | `e32a7f0de4d6d339716d0410f304ba985e210111a37c80c5eabf36b2301839d9` | 1991 | | |
| 125 | +| `w_cq42_cpu0_max16.obu` | same, `--cq-level=42 --cpu-used=0` | 15 | `8fee40fdfa04b0a4904e9947343c494fbb9d6958827eefb169c9e1d1e87eb629` | 1063 | | |
| 126 | + | |
| 127 | +(Written to `~/.cache/av1rect8x16/`. **Not committed as a fixture**: outcome (a) needs no pin, and a fixture whose only job is to keep an unreachable guard unreachable is what the enumeration test is for.) | |
| 128 | + | |
| 129 | +**A refusal on a stream whose parsed leaves carry an 8x16 rect block would be the defect. That never happened — 0 refusals over 826 non-vacuous streams.** | |
| 130 | + | |
| 131 | +--- | |
| 132 | + | |
| 133 | +## 3. VERDICT | |
| 134 | + | |
| 135 | +> **(a) UNREACHABLE.** The upstream gate is structural, not a size heuristic: all 8 call sites of `decode_block_rect` are 32-level `match part32` arms of `read_sb128_root` and pass `bw`/`bh` as the integer literals `32, 16` or `16, 32`, so the function's chroma footprint set is `{(16,8), (8,16), (16,16), (8,32), (32,16), (16,32)}` — all six of which have a row. A 4:2:0 8x16 luma strip's 4x8 chroma is read by `decode_leaf_rect`, not here, and that function carries the `(4, 8)` / `(8, 4)` rows itself. Measured over 840 real aomenc 4:2:0 key-frame encodes — 826 of which provably code a 16-level 2:1 luma strip — the refusal fires **0** times and every stream decodes to completion. | |
| 136 | + | |
| 137 | +**This is NOT a decoder capability defect. No conformant stream is refused by name.** | |
| 138 | + | |
| 139 | +### What the arm would have been (recorded, not added) | |
| 140 | + | |
| 141 | +For the record, had an 8x16 caller appeared, libaom *does* have the shape — so the row would be legitimate, not a fabrication: | |
| 142 | + | |
| 143 | +- `av1_ss_size_lookup[BLOCK_8X16][subsampling_x=1][subsampling_y=1] = BLOCK_4X8` — `~/.cache/aom-oracle/src/av1/common/common_data.c:24` (row 5 of the table; and `[BLOCK_16X8][1][1] = BLOCK_8X4` at `common_data.c:25`) | |
| 144 | +- `max_txsize_rect_lookup[BLOCK_4X8] = TX_4X8` — `~/.cache/aom-oracle/src/av1/common/common_data.h:130` | |
| 145 | +- chained by `av1_get_max_uv_txsize(bsize, subsampling_x, subsampling_y)` — `~/.cache/aom-oracle/src/av1/common/blockd.h:1372-1379`, which is `av1_get_tx_size`'s chroma branch (`blockd.h:1381-1388`) | |
| 146 | + | |
| 147 | +So the 4:2:0 chroma of an 8x16 luma block is a genuine single `TX_4X8` in libaom. `decode_leaf_rect` already decodes it (`SCAN_4X8` + `TxbSet::ChromaRect8x4`, `decode.rs:15412`/`:15419`). The `(4, 8)` row in `decode_block_rect` would be a duplicate of that path for a shape no caller produces. | |
| 148 | + | |
| 149 | +--- | |
| 150 | + | |
| 151 | +## 4. Deliverable: the claim is now PROVEN by the tree, not argued in this file | |
| 152 | + | |
| 153 | +> **The 840-encode sweep in §2 is CORROBORATION, not the proof.** It shows the | |
| 154 | +> refusal does not fire on 826 streams that provably code the shape; it cannot | |
| 155 | +> show the shape is unreachable in a stream nobody encoded. The proof is the | |
| 156 | +> static caller-shape-set derivation in §1, and the deliverable below is what | |
| 157 | +> makes the tree enforce it rather than trusting this report. | |
| 158 | + | |
| 159 | +`refusal_inventory.rs` gained a `PROVEN` row for the string (it previously had | |
| 160 | +**none** — it was the audit round's single unproven row) and the test that proves | |
| 161 | +it, in the same file as the sibling enumeration. | |
| 162 | + | |
| 163 | +### Where the assertions live, and why not inside the sibling test | |
| 164 | + | |
| 165 | +Main asked for this to be folded into | |
| 166 | +`every_rect_strip_shape_the_split_path_codes_has_a_luma_and_chroma_table`. It is | |
| 167 | +shipped as a sibling test in the same file instead, because that test audits | |
| 168 | +`decode_rect_split`'s two `match` tables via a `depth_to_tx_wh` walk — it has no | |
| 169 | +caller-shape-set notion at all. Getting `decode_block_rect`'s domain requires a | |
| 170 | +paren-balanced argument splitter over the call sites (~60 lines) plus a | |
| 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)`. | |
| 231 | + | |
| 232 | +--- | |
| 233 | + | |
| 234 | +## 5. Scope and hygiene | |
| 235 | + | |
| 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. | |
| 239 | +- `decode_rect_split` and `read_block_tx_size` untouched (other lanes own them). `decode.rs` untouched. | |
| 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`). | |
| 241 | +- The scratch sweep lived in two `#[ignore]`d tests, ran, and were deleted; the tree diff is the 246-line addition above. | |
| 242 | +- Main untouched: `git -C /home/user/Documents/Code/Rust/edith_codecs status --porcelain` shows no tracked-file modification from this lane. Never pushed. | |
| 243 | + | |
| 244 | + | |
| 245 | +## 6. Checked and CLEARED (recorded so it is not re-opened) | |
| 246 | + | |
| 247 | +`decode_leaf_rect` reads a 4:2:0 8x16 strip's 4x8 chroma with `TxbSet::ChromaRect8x4` + `SCAN_4X8`, while libaom's `get_txsize_entropy_ctx(TX_4X8)` reduces to the **8x8 square** set — a name that looks like a possible disagreement. It is not one: `Cdfs::txb` resolves `TxbSet::ChromaRect8x4` (`cdf_state.rs:2116`) to the *same* 8x8 chroma CDFs as `TxbSet::Chroma8` (`cdf_state.rs:1852`) — `txb_skip_chroma_8`, `eob_extra_chroma_8`, `base_chroma_8`, `base_eob_chroma_8`, `br_chroma_8`, `dc_sign_chroma`, `tx_type: None`, `side: 8` — differing only in the end-of-block group (`eob_pt_32_chroma` / `eob_pt_32_chroma_class1`, the rect-appropriate EOB_PT_32, versus `eob_pt_64_chroma`). The entropy set is the square-up one, as libaom has it; the variant name is a convenience for the distinct EOB table. |