lane-av1unwritten r4: install the refusal at four more subsize sites
Browse files at this commite898fd732fb6ead7513f718e313d219f37a0e6b6Parent: b9fb4992 changed files +103 -6
- crates/ec-av1/src/decode.rs +68 -0
- lanes/av1unwritten.report.md +35 -6
crates/ec-av1/src/decode.rsmodified+68 -0
| @@ -21445,6 +21445,41 @@ fn chroma_plane_block_codable(bw: usize, bh: usize, sx: usize, sy: usize) -> boo | |||
| 21445 | } | 21445 | } |
| 21446 | } | 21446 | } |
| 21447 | 21447 | ||
| 21448 | +/// libaom `get_partition_subsize` (spec 6.10.3, `common_data.c`'s | ||
| 21449 | +/// `subsize_lookup`) reduced to its DIMENSIONS -- all the `av1_ss_size_lookup` | ||
| 21450 | +/// check needs, and, by construction, never the PARENT block's own shape | ||
| 21451 | +/// (that is the r2 mistake in a new place: refusing `16x4` at 4:2:2 by testing | ||
| 21452 | +/// the 16x8 parent). `PARTITION_HORZ_A`/`_B` and `PARTITION_VERT_A`/`_B` are | ||
| 21453 | +/// the four-way arms, whose subsizes are the strips they visit. | ||
| 21454 | +fn partition_subsize_dims(bsize: (usize, usize), part: usize) -> (usize, usize) { | ||
| 21455 | + let (w, h) = bsize; | ||
| 21456 | + match part { | ||
| 21457 | + PARTITION_SPLIT => (w / 2, h / 2), | ||
| 21458 | + PARTITION_HORZ | PARTITION_HORZ_A | PARTITION_HORZ_B => (w, h / 2), | ||
| 21459 | + PARTITION_VERT | PARTITION_VERT_A | PARTITION_VERT_B => (w / 2, h), | ||
| 21460 | + PARTITION_HORZ_4 => (w, h / 4), | ||
| 21461 | + PARTITION_VERT_4 => (w / 4, h), | ||
| 21462 | + _ => (w, h), | ||
| 21463 | + } | ||
| 21464 | +} | ||
| 21465 | + | ||
| 21466 | +/// [`chroma_plane_block_codable`] applied to the subsize a partition SYMBOL | ||
| 21467 | +/// selected, exactly as `decode_partition` does at `decodeframe.c:1449-1458` | ||
| 21468 | +/// before descending into it. Returns libaom's named refusal for the caller to | ||
| 21469 | +/// propagate. | ||
| 21470 | +fn refuse_invalid_subsize( | ||
| 21471 | + bsize: (usize, usize), | ||
| 21472 | + part: usize, | ||
| 21473 | + fctx: &crate::decode::FrameCtx, | ||
| 21474 | +) -> Result<()> { | ||
| 21475 | + let (bw, bh) = partition_subsize_dims(bsize, part); | ||
| 21476 | + if chroma_plane_block_codable(bw, bh, ss_x(fctx), ss_y(fctx)) { | ||
| 21477 | + Ok(()) | ||
| 21478 | + } else { | ||
| 21479 | + Err(refuse_invalid_plane_block(bw, bh, fctx)) | ||
| 21480 | + } | ||
| 21481 | +} | ||
| 21482 | + | ||
| 21448 | /// [`chroma_plane_block_codable`] as libaom's refusal: a returned error naming | 21483 | /// [`chroma_plane_block_codable`] as libaom's refusal: a returned error naming |
| 21449 | /// the shape and the subsampling mode, never an `assert!` -- a partition symbol | 21484 | /// the shape and the subsampling mode, never an `assert!` -- a partition symbol |
| 21450 | /// is stream data, so a hostile file can reach it. | 21485 | /// is stream data, so a hostile file can reach it. |
| @@ -35424,6 +35459,14 @@ fn read_sb128_root( | |||
| 35424 | // root has no 1:4 arm at all (`PARTITION_HORZ_4`/`VERT_4` are excluded | 35459 | // root has no 1:4 arm at all (`PARTITION_HORZ_4`/`VERT_4` are excluded |
| 35425 | // for BLOCK_128X128 by `av1_get_partition_cdf`'s 8-symbol alphabet, | 35460 | // for BLOCK_128X128 by `av1_get_partition_cdf`'s 8-symbol alphabet, |
| 35426 | // which stops at VERT_B). | 35461 | // which stops at VERT_B). |
| 35462 | + // lane-av1unwritten r4: guard the subsize THIS SYMBOL selected, never the | ||
| 35463 | + // root's own plane block. VERT on a 128x128 root selects BLOCK_64X128, | ||
| 35464 | + // whose 4:2:2 plane block is BLOCK_INVALID; the AB arms select 64x64 | ||
| 35465 | + // quadrants (valid), so PARTITION_HORZ / PARTITION_NONE / SPLIT keep | ||
| 35466 | + // decoding untouched. | ||
| 35467 | + if matches!(part128, PARTITION_VERT) { | ||
| 35468 | + refuse_invalid_subsize((128, 128), part128, fctx)?; | ||
| 35469 | + } | ||
| 35427 | match part128 { | 35470 | match part128 { |
| 35428 | PARTITION_SPLIT => hit!(PART128_SPLIT_HITS), | 35471 | PARTITION_SPLIT => hit!(PART128_SPLIT_HITS), |
| 35429 | PARTITION_NONE => hit!(PART128_NONE_HITS), | 35472 | PARTITION_NONE => hit!(PART128_NONE_HITS), |
| @@ -36227,6 +36270,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 36227 | } | 36270 | } |
| 36228 | } | 36271 | } |
| 36229 | }; | 36272 | }; |
| 36273 | + // lane-av1unwritten r4: VERT on a 32x32 block selects | ||
| 36274 | + // BLOCK_16X32 -- INVALID at 4:2:2. HORZ on the same | ||
| 36275 | + // block selects BLOCK_32X16, whose (1,0) cell is | ||
| 36276 | + // BLOCK_16X16 (valid) and MUST keep decoding, so the | ||
| 36277 | + // check is on the symbol's subsize, not the parent's. | ||
| 36278 | + if matches!(part32, PARTITION_VERT) { | ||
| 36279 | + refuse_invalid_subsize((32, 32), part32, fctx)?; | ||
| 36280 | + } | ||
| 36230 | match part32 { | 36281 | match part32 { |
| 36231 | PARTITION_NONE => { | 36282 | PARTITION_NONE => { |
| 36232 | decode_block( | 36283 | decode_block( |
| @@ -36438,6 +36489,16 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 36438 | let br = (mi_row0 + 2, mi_col0 + 2); | 36489 | let br = (mi_row0 + 2, mi_col0 + 2); |
| 36439 | let mut done: Vec<((usize, usize), usize)> = | 36490 | let mut done: Vec<((usize, usize), usize)> = |
| 36440 | Vec::new(); | 36491 | Vec::new(); |
| 36492 | + // lane-av1unwritten r4: the | ||
| 36493 | + // 16x16-level 1:4 split -- | ||
| 36494 | + // VERT_4 selects BLOCK_4X16, | ||
| 36495 | + // INVALID at 4:2:2; HORZ_4 | ||
| 36496 | + // selects BLOCK_16X4, whose (1,0) | ||
| 36497 | + // cell is BLOCK_8X4 (valid, the | ||
| 36498 | + // shape r2 wrongly refused). | ||
| 36499 | + if matches!(part16, PARTITION_VERT_4) { | ||
| 36500 | + refuse_invalid_subsize((16, 16), part16, fctx)?; | ||
| 36501 | + } | ||
| 36441 | match part16 { | 36502 | match part16 { |
| 36442 | PARTITION_HORZ_A => { | 36503 | PARTITION_HORZ_A => { |
| 36443 | let m_tl = | 36504 | let m_tl = |
| @@ -54217,6 +54278,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 54217 | )? | 54278 | )? |
| 54218 | }; | 54279 | }; |
| 54219 | } | 54280 | } |
| 54281 | + // lane-av1unwritten r4: VERT on a 64x64 block selects | ||
| 54282 | + // BLOCK_32X64 -- INVALID at 4:2:2. HORZ on the same block | ||
| 54283 | + // selects BLOCK_64X32, whose (1,0) cell is BLOCK_32X32 | ||
| 54284 | + // (valid) and MUST keep decoding. | ||
| 54285 | + if matches!(part64, PARTITION_VERT) { | ||
| 54286 | + refuse_invalid_subsize((64, 64), part64, fctx)?; | ||
| 54287 | + } | ||
| 54220 | match part64 { | 54288 | match part64 { |
| 54221 | PARTITION_HORZ_A => { | 54289 | PARTITION_HORZ_A => { |
| 54222 | ab_square32!(tl); | 54290 | ab_square32!(tl); |
lanes/av1unwritten.report.mdmodified+35 -6
| @@ -24,6 +24,16 @@ Branch `lane/av1unwritten`, base `main` = `8d6998d7`. No push. | |||
| 24 | > fixture carries a 16x8 block split `PARTITION_HORZ` at 4:2:2 — and that table | 24 | > fixture carries a 16x8 block split `PARTITION_HORZ` at 4:2:2 — and that table |
| 25 | > test is what covers that direction. | 25 | > test is what covers that direction. |
| 26 | > | 26 | > |
| 27 | +> **r4, on top of r3.** Main: "a found defect is swept whole, not partly." | ||
| 28 | +> r3 named the six remaining sites instead of installing them. r4 installs four | ||
| 29 | +> of them, via a helper that takes the PARTITION SYMBOL and maps it to its | ||
| 30 | +> subsize dimensions (`partition_subsize_dims`, spec 6.10.3 | ||
| 31 | +> `get_partition_subsize`) so the check can never be applied to a parent's own | ||
| 32 | +> shape -- the r2 mistake in a new place. The sites, their subsize, the cell | ||
| 33 | +> they guard, and the SIBLING that must keep decoding are in §3.2. Two are still | ||
| 34 | +> open and named (the inter-frame duplicate of the 64-level match, and the | ||
| 35 | +> `decode_rect4_16_intrabc` exception, which is another lane's charter). | ||
| 36 | +> | ||
| 27 | > **This report was rewritten once before. The first version of this lane claimed a libaom | 37 | > **This report was rewritten once before. The first version of this lane claimed a libaom |
| 28 | > `TX_4X8` chroma unit for a `BLOCK_4X8` subsize and landed a port of it. The | 38 | > `TX_4X8` chroma unit for a `BLOCK_4X8` subsize and landed a port of it. The |
| 29 | > refutation pass (Agent03-5, verified first-hand by Main) showed that port does | 39 | > refutation pass (Agent03-5, verified first-hand by Main) showed that port does |
| @@ -170,6 +180,22 @@ subsampling mode", av1/decoder/decodeframe.c:1456, refusing by the same rule)) | |||
| 170 | 180 | ||
| 171 | Same refusal class as the oracle, same rule, same shape named. | 181 | Same refusal class as the oracle, same rule, same shape named. |
| 172 | 182 | ||
| 183 | +### 3.2 The r4 site table | ||
| 184 | + | ||
| 185 | +| site | subsize it can select | cell it guards | sibling that must keep decoding | | ||
| 186 | +|---|---|---|---| | ||
| 187 | +| 128 root, `PARTITION_VERT` (`decode.rs`, `match part128`) | 64x128 | `(1,0)` INVALID | `PARTITION_HORZ` -> 128x64, `(1,0)` = 64x64 valid | | ||
| 188 | +| 64-level, `PARTITION_VERT` (`match part64`) | 32x64 | `(1,0)` INVALID | `PARTITION_HORZ` -> 64x32, `(1,0)` = 32x32 valid | | ||
| 189 | +| 32-level, `PARTITION_VERT` (`match part32`) | 16x32 | `(1,0)` INVALID | `PARTITION_HORZ` -> 32x16, `(1,0)` = 16x16 valid | | ||
| 190 | +| 16x16-level, `PARTITION_VERT_4` (`match part16`) | 4x16 | `(1,0)` INVALID | `PARTITION_HORZ_4` -> 16x4, `(1,0)` = 8x4 **valid** -- the exact shape r2 refused, and the one libaom's encoder emits | | ||
| 191 | +| 16-level, `PARTITION_HORZ`/`VERT` | 16x8 / 8x16 | 8x16 `(1,0)` INVALID | `PARTITION_HORZ` -> 16x8, `(1,0)` = 8x8 valid | | ||
| 192 | +| 8-level, `PARTITION_HORZ`/`VERT` | 8x4 / 4x8 | 4x8 `(1,0)` INVALID | `PARTITION_HORZ` -> 8x4, `(1,0)` = 4x4 valid | | ||
| 193 | + | ||
| 194 | +The sibling column is the r2 lesson turned into a rule: at every site the | ||
| 195 | +opposite-axis branch of the SAME dispatch must keep decoding, and the table test | ||
| 196 | +plus these guards are what prove it. `decode_rect4_16_intrabc` is the declared | ||
| 197 | +exception (another lane's charter). | ||
| 198 | + | ||
| 173 | ### 3.1 Sites found, and the ones proven not to need it | 199 | ### 3.1 Sites found, and the ones proven not to need it |
| 174 | 200 | ||
| 175 | | site | subsizes it can produce | needs the check? | | 201 | | site | subsizes it can produce | needs the check? | |
| @@ -177,11 +203,14 @@ Same refusal class as the oracle, same rule, same shape named. | |||
| 177 | | `partition_w8` (2 sites, 36549 / 36767 region) | 8x4, 4x8 | **yes**, installed | | 203 | | `partition_w8` (2 sites, 36549 / 36767 region) | 8x4, 4x8 | **yes**, installed | |
| 178 | | `partition_w16` intra (36175 region) | 16x8, 8x16 | **yes**, installed | | 204 | | `partition_w16` intra (36175 region) | 16x8, 8x16 | **yes**, installed | |
| 179 | | `partition_w16` edge split (`VERT_ALIKE`/`HORZ_ALIKE` gather) | same two, reached only when `has_cols16`/`has_rows16` is false | covered by the same rule at the sibling site; the edge arm's two-symbol gather can only choose SPLIT vs the matching strip | | 205 | | `partition_w16` edge split (`VERT_ALIKE`/`HORZ_ALIKE` gather) | same two, reached only when `has_cols16`/`has_rows16` is false | covered by the same rule at the sibling site; the edge arm's two-symbol gather can only choose SPLIT vs the matching strip | |
| 180 | -| `PARTITION_HORZ_4` / `VERT_4` on 8x16 / 16x8 (`decode_rect_split`) | 4x16 (INVALID at 4:2:2), 16x4 (legal at 4:2:2, INVALID at 4:4:0) | **NOT installed — named gap** | | 206 | +| `PARTITION_VERT_4` at the 16x16 level | 4x16 — INVALID at 4:2:2 | **yes, r4, installed** | |
| 181 | -| `partition_w32` `PARTITION_VERT` | 16x32 — INVALID at 4:2:2 | **NOT installed — named gap** | | 207 | +| `partition_w32` `PARTITION_VERT` | 16x32 — INVALID at 4:2:2 | **yes, r4, installed** | |
| 182 | -| `partition_w64` `PARTITION_VERT` | 32x64 — INVALID at 4:2:2 | **NOT installed — named gap** | | 208 | +| `partition_w64` `PARTITION_VERT` | 32x64 — INVALID at 4:2:2 | **yes, r4, installed** | |
| 183 | -| 128 root `PARTITION_VERT` | 64x128 — INVALID at 4:2:2 | **NOT installed — named gap** | | 209 | +| 128 root `PARTITION_VERT` | 64x128 — INVALID at 4:2:2 | **yes, r4, installed** | |
| 184 | -| the 4-way vertical splits at 16/32/64 (`VERT_A` / `VERT_B`) | 8x32, 16x64 — both INVALID at 4:2:2 | **NOT installed — named gap** | | 210 | +| the four-way vertical splits (`VERT_A` / `VERT_B`) at 16/32/64 | 8x32, 16x64 — both INVALID at 4:2:2 | **still open, named** | |
| 211 | +| `VERT_4` on 8x16 / 16x8 (`decode_rect_split`) | 8x32 — INVALID at 4:2:2 | **still open, named** | | ||
| 212 | +| the inter-frame duplicate of the 64-level match | 32x64 | **still open, named** | | ||
| 213 | +| `decode_rect4_16_intrabc` | 4x16 / 8x32 | **out of scope** — another lane's charter | | ||
| 185 | | 32/64/128 roots' OWN plane blocks, the AB partitions, `PARTITION_SPLIT` | BLOCK_32X32 (16X32), BLOCK_64X64 (32X32), BLOCK_128X128 (64X64), all valid | no — a PARENT row being valid says nothing about its children, which is exactly what r2 got wrong; the child rows are the four rows above | | 214 | | 32/64/128 roots' OWN plane blocks, the AB partitions, `PARTITION_SPLIT` | BLOCK_32X32 (16X32), BLOCK_64X64 (32X32), BLOCK_128X128 (64X64), all valid | no — a PARENT row being valid says nothing about its children, which is exactly what r2 got wrong; the child rows are the four rows above | |
| 186 | | 4:4:4 square leaves, `decode_leaf8`, `decode_leaf_split4` | BLOCK_4X4 / BLOCK_8X8 / BLOCK_16X16 | no: `(0,0)` column is non-INVALID for all of them | | 215 | | 4:4:4 square leaves, `decode_leaf8`, `decode_leaf_split4` | BLOCK_4X4 / BLOCK_8X8 / BLOCK_16X16 | no: `(0,0)` column is non-INVALID for all of them | |
| 187 | 216 | ||
| @@ -206,7 +235,7 @@ instrument is what would show it if one ever did. | |||
| 206 | * **Corpus, both trees.** Every fixture decoded with `EC_AV1_FINAL_DUMP`, every | 235 | * **Corpus, both trees.** Every fixture decoded with `EC_AV1_FINAL_DUMP`, every |
| 207 | `.f*` hashed. Pre-fix vs post-fix the **126 valid fixtures are byte-identical** | 236 | `.f*` hashed. Pre-fix vs post-fix the **126 valid fixtures are byte-identical** |
| 208 | and **none newly refuses**; the witness is the only difference and it now | 237 | and **none newly refuses**; the witness is the only difference and it now |
| 209 | - refuses. Re-run on the r3 (corrected) predicate: `differing: | 238 | + refuses. Re-run on the r4 predicate: `differing: |
| 210 | ['440_request_is_422']`, 126 fixtures emitting dumps, and exactly one fixture | 239 | ['440_request_is_422']`, 126 fixtures emitting dumps, and exactly one fixture |
| 211 | whose output contains `REFUSED` — the witness. **The sweep cannot see the | 240 | whose output contains `REFUSED` — the witness. **The sweep cannot see the |
| 212 | (16,4)-at-4:2:2 false positive**: no committed fixture carries a 16x8 block | 241 | (16,4)-at-4:2:2 false positive**: no committed fixture carries a 16x8 block |