lane-av1unwritten r3: the predicate is a transcription of av1_ss_size_lookup, not a guess
Browse files at this commitb9fb4993feeadbdcf2853662b5ccae71b13d5fedParent: ff41e002 changed files +248 -13
- crates/ec-av1/src/decode.rs +200 -5
- lanes/av1unwritten.report.md +48 -8
crates/ec-av1/src/decode.rsmodified+200 -5
| @@ -21370,12 +21370,77 @@ fn plane_sentinel_on() -> bool { | ||
| 21370 | 21370 | /// CHANGED RUN TO RUN. `aomdec` on the same file: |
| 21371 | 21371 | /// `Failed to decode frame 1: Corrupt frame detected` / `Block size 8x16 |
| 21372 | 21372 | /// invalid with this subsampling mode`. |
| 21373 | +/// `av1_ss_size_lookup`'s `BLOCK_INVALID` cells, transcribed verbatim: | |
| 21374 | +/// `(common_data.c:17-41`, rows in `BLOCK_SIZES_ALL` order, indexed | |
| 21375 | +/// `[subsampling_x][subsampling_y])`. Every entry below is an (luma width, | |
| 21376 | +/// luma height) whose plane block does not EXIST at that subsampling pair, so | |
| 21377 | +/// libaom refuses any subsize of that shape | |
| 21378 | +/// (`av1/decoder/decodeframe.c:1449-1458`, `AOM_CODEC_CORRUPT_FRAME`, | |
| 21379 | +/// "Block size %dx%d invalid with this subsampling mode"). | |
| 21380 | +/// | |
| 21381 | +/// There is no other `BLOCK_INVALID` cell in the table: at (0,0) 4:4:4 and at | |
| 21382 | +/// (1,1) 4:2:0 every row is valid, and the sixteen shapes below are the only | |
| 21383 | +/// ones that are invalid at (1,0) 4:2:2 or (0,1) 4:4:0. The table test | |
| 21384 | +/// [`chroma_plane_block_codable_matches_the_libaom_table`] re-transcribes all | |
| 21385 | +/// 22 rows and checks this list cell for cell -- a diff against the C source, | |
| 21386 | +/// not a restatement of it. | |
| 21387 | +/// | |
| 21388 | +/// ``` | |
| 21389 | +/// BLOCK_4X8 {4X8, 4X4} {INVALID, 4X4} <- INVALID @ (1,0) | |
| 21390 | +/// BLOCK_8X4 {8X4, INVALID} {4X4, 4X4} <- INVALID @ (0,1) | |
| 21391 | +/// BLOCK_8X16 {8X16, 8X8} {INVALID, 4X8} <- INVALID @ (1,0) | |
| 21392 | +/// BLOCK_16X8 {16X8, INVALID} {8X8, 8X4} <- INVALID @ (0,1) | |
| 21393 | +/// BLOCK_16X32 {16X32, 16X16} {INVALID, 8X16} <- INVALID @ (1,0) | |
| 21394 | +/// BLOCK_32X16 {32X16, INVALID}{16X16, 16X8} <- INVALID @ (0,1) | |
| 21395 | +/// BLOCK_32X64 {32X64, 32X32} {INVALID, 16X32} <- INVALID @ (1,0) | |
| 21396 | +/// BLOCK_64X32 {64X32, INVALID}{32X32, 32X16} <- INVALID @ (0,1) | |
| 21397 | +/// BLOCK_64X128 {64X128,64X64} {INVALID, 32X64} <- INVALID @ (1,0) | |
| 21398 | +/// BLOCK_128X64 {128X64,INVALID}{64X64, 64X32} <- INVALID @ (0,1) | |
| 21399 | +/// BLOCK_4X16 {4X16, 4X8} {INVALID, 4X8} <- INVALID @ (1,0) | |
| 21400 | +/// BLOCK_16X4 {16X4, 8X4} {8X4, 8X4} <- valid @ (1,0) | |
| 21401 | +/// BLOCK_8X32 {8X32, 8X16} {INVALID, 4X16} <- INVALID @ (1,0) | |
| 21402 | +/// BLOCK_32X8 {32X8, 16X8} {32X8, 16X4} <- valid @ (0,1) | |
| 21403 | +/// BLOCK_16X64 {16X64,16X32} {INVALID, 8X32} <- INVALID @ (1,0) | |
| 21404 | +/// BLOCK_64X16 {64X16,32X16} {32X16, 32X8} <- valid @ (0,1) | |
| 21405 | +/// ``` | |
| 21406 | +/// | |
| 21407 | +/// The two "valid" rows are here on purpose: an earlier version of this | |
| 21408 | +/// predicate hardcoded BLOCK_16X4@(1,0) and BLOCK_32X8@(0,1) as invalid, which | |
| 21409 | +/// REFUSED a legal 4:2:2 shape -- one aomenc itself emits, since its own | |
| 21410 | +/// `partition_search.c:3383-3389` gates `partition_rect_allowed[HORZ]` with | |
| 21411 | +/// exactly this table. | |
| 21412 | +const PLANE_BLOCK_INVALID_422: &[(usize, usize)] = &[ | |
| 21413 | + (4, 8), | |
| 21414 | + (8, 16), | |
| 21415 | + (16, 32), | |
| 21416 | + (32, 64), | |
| 21417 | + (64, 128), | |
| 21418 | + (4, 16), | |
| 21419 | + (8, 32), | |
| 21420 | + (16, 64), | |
| 21421 | +]; | |
| 21422 | + | |
| 21423 | +/// The same list at 4:4:0 `(0, 1)` -- a shape no `color_config` can request | |
| 21424 | +/// (libaom asserts `subsampling_y == 0` when `subsampling_x == 0`), kept so | |
| 21425 | +/// the table test can cover every cell rather than only the reachable ones. | |
| 21426 | +const PLANE_BLOCK_INVALID_440: &[(usize, usize)] = &[ | |
| 21427 | + (8, 4), | |
| 21428 | + (16, 8), | |
| 21429 | + (32, 16), | |
| 21430 | + (64, 32), | |
| 21431 | + (128, 64), | |
| 21432 | + (16, 4), | |
| 21433 | + (32, 8), | |
| 21434 | + (64, 16), | |
| 21435 | +]; | |
| 21436 | + | |
| 21437 | +/// Whether `av1_ss_size_lookup[(bw, bh)][sx][sy]` is not `BLOCK_INVALID` -- i.e. | |
| 21438 | +/// whether libaom lets a subsize of this luma shape have a chroma plane block | |
| 21439 | +/// at this subsampling at all. | |
| 21373 | 21440 | fn chroma_plane_block_codable(bw: usize, bh: usize, sx: usize, sy: usize) -> bool { |
| 21374 | - match (bw, bh) { | |
| 21375 | - (4, 8) => (sx, sy) != (1, 0), | |
| 21376 | - (8, 4) => (sx, sy) != (0, 1), | |
| 21377 | - (8, 16) => (sx, sy) != (1, 0), | |
| 21378 | - (16, 4) => (sx, sy) != (1, 0), | |
| 21441 | + match (sx, sy) { | |
| 21442 | + (1, 0) => !PLANE_BLOCK_INVALID_422.contains(&(bw, bh)), | |
| 21443 | + (0, 1) => !PLANE_BLOCK_INVALID_440.contains(&(bw, bh)), | |
| 21379 | 21444 | _ => true, |
| 21380 | 21445 | } |
| 21381 | 21446 | } |
| @@ -56259,6 +56324,136 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 56259 | 56324 | |
| 56260 | 56325 | #[cfg(test)] |
| 56261 | 56326 | mod tests { |
| 56327 | + | |
| 56328 | + /// lane-av1unwritten: the port is a TRANSCRIPTION, and this is the artefact | |
| 56329 | + /// that makes it checkable. It re-writes `av1_ss_size_lookup`'s 22 rows | |
| 56330 | + /// (`common_data.c:17-41`) literally -- every shape, every subsampling | |
| 56331 | + /// pair, the real BLOCK_INVALID markers -- and asserts | |
| 56332 | + /// [`chroma_plane_block_codable`] agrees cell for cell. A predicate that | |
| 56333 | + /// hardcodes the wrong cell (this lane's first version marked BLOCK_16X4 at | |
| 56334 | + /// 4:2:2 invalid; the table says `BLOCK_8X4`) reds here, not in a corpus | |
| 56335 | + /// that happens not to carry the shape. | |
| 56336 | + #[test] | |
| 56337 | + fn chroma_plane_block_codable_matches_the_libaom_table() { | |
| 56338 | + // (width, height, [ss_x=0][ss_y=0], [0][1], [1][0], [1][1]); `None` is | |
| 56339 | + // BLOCK_INVALID. | |
| 56340 | + const I: Option<(usize, usize)> = None; | |
| 56341 | + let table: &[(usize, usize, [Option<(usize, usize)>; 4])] = &[ | |
| 56342 | + ( | |
| 56343 | + 4, | |
| 56344 | + 4, | |
| 56345 | + [Some((4, 4)), Some((4, 4)), Some((4, 4)), Some((4, 4))], | |
| 56346 | + ), | |
| 56347 | + (4, 8, [Some((4, 8)), Some((4, 4)), I, Some((4, 4))]), | |
| 56348 | + (8, 4, [Some((8, 4)), I, Some((4, 4)), Some((4, 4))]), | |
| 56349 | + ( | |
| 56350 | + 8, | |
| 56351 | + 8, | |
| 56352 | + [Some((8, 8)), Some((8, 4)), Some((4, 8)), Some((4, 4))], | |
| 56353 | + ), | |
| 56354 | + (8, 16, [Some((8, 16)), Some((8, 8)), I, Some((4, 8))]), | |
| 56355 | + (16, 8, [Some((16, 8)), I, Some((8, 8)), Some((4, 4))]), | |
| 56356 | + ( | |
| 56357 | + 16, | |
| 56358 | + 16, | |
| 56359 | + [Some((16, 16)), Some((8, 16)), Some((8, 8)), Some((4, 8))], | |
| 56360 | + ), | |
| 56361 | + (16, 32, [Some((16, 32)), Some((16, 16)), I, Some((8, 16))]), | |
| 56362 | + (32, 16, [Some((32, 16)), I, Some((16, 16)), Some((16, 8))]), | |
| 56363 | + ( | |
| 56364 | + 32, | |
| 56365 | + 32, | |
| 56366 | + [ | |
| 56367 | + Some((32, 32)), | |
| 56368 | + Some((16, 32)), | |
| 56369 | + Some((16, 16)), | |
| 56370 | + Some((16, 8)), | |
| 56371 | + ], | |
| 56372 | + ), | |
| 56373 | + (32, 64, [Some((32, 64)), Some((32, 32)), I, Some((16, 32))]), | |
| 56374 | + (64, 32, [Some((64, 32)), I, Some((32, 32)), Some((32, 16))]), | |
| 56375 | + ( | |
| 56376 | + 64, | |
| 56377 | + 64, | |
| 56378 | + [ | |
| 56379 | + Some((64, 64)), | |
| 56380 | + Some((32, 64)), | |
| 56381 | + Some((32, 32)), | |
| 56382 | + Some((32, 16)), | |
| 56383 | + ], | |
| 56384 | + ), | |
| 56385 | + ( | |
| 56386 | + 64, | |
| 56387 | + 128, | |
| 56388 | + [Some((64, 128)), Some((64, 64)), I, Some((32, 64))], | |
| 56389 | + ), | |
| 56390 | + ( | |
| 56391 | + 128, | |
| 56392 | + 64, | |
| 56393 | + [Some((128, 64)), I, Some((64, 64)), Some((64, 32))], | |
| 56394 | + ), | |
| 56395 | + ( | |
| 56396 | + 128, | |
| 56397 | + 128, | |
| 56398 | + [ | |
| 56399 | + Some((128, 128)), | |
| 56400 | + Some((64, 128)), | |
| 56401 | + Some((64, 64)), | |
| 56402 | + Some((64, 32)), | |
| 56403 | + ], | |
| 56404 | + ), | |
| 56405 | + (4, 16, [Some((4, 16)), Some((4, 8)), I, Some((4, 8))]), | |
| 56406 | + (16, 4, [Some((16, 4)), I, Some((8, 4)), Some((8, 4))]), | |
| 56407 | + (8, 32, [Some((8, 32)), Some((8, 16)), I, Some((4, 16))]), | |
| 56408 | + (32, 8, [Some((32, 8)), I, Some((16, 8)), Some((16, 4))]), | |
| 56409 | + (16, 64, [Some((16, 64)), Some((16, 32)), I, Some((8, 32))]), | |
| 56410 | + (64, 16, [Some((64, 16)), I, Some((32, 16)), Some((32, 8))]), | |
| 56411 | + ( | |
| 56412 | + 128, | |
| 56413 | + 256, | |
| 56414 | + [ | |
| 56415 | + Some((128, 256)), | |
| 56416 | + Some((64, 256)), | |
| 56417 | + Some((64, 128)), | |
| 56418 | + Some((64, 64)), | |
| 56419 | + ], | |
| 56420 | + ), | |
| 56421 | + ( | |
| 56422 | + 256, | |
| 56423 | + 128, | |
| 56424 | + [ | |
| 56425 | + Some((256, 128)), | |
| 56426 | + Some((128, 256)), | |
| 56427 | + Some((128, 64)), | |
| 56428 | + Some((128, 64)), | |
| 56429 | + ], | |
| 56430 | + ), | |
| 56431 | + ]; | |
| 56432 | + for &(w, h, cells) in table { | |
| 56433 | + for sx in 0..2usize { | |
| 56434 | + for sy in 0..2usize { | |
| 56435 | + let want_codable = cells[sx * 2 + sy].is_some(); | |
| 56436 | + assert_eq!( | |
| 56437 | + chroma_plane_block_codable(w, h, sx, sy), | |
| 56438 | + want_codable, | |
| 56439 | + "av1_ss_size_lookup[{w}x{h}][{sx}][{sy}] is {:?} in libaom \ | |
| 56440 | + (common_data.c) but our predicate says the opposite", | |
| 56441 | + cells[sx * 2 + sy] | |
| 56442 | + ); | |
| 56443 | + } | |
| 56444 | + } | |
| 56445 | + } | |
| 56446 | + // The two cells an earlier, hand-picked predicate got wrong: both are | |
| 56447 | + // LEGAL at 4:2:2, and libaom's own encoder emits the 16x4 one. | |
| 56448 | + assert!( | |
| 56449 | + chroma_plane_block_codable(16, 4, 1, 0), | |
| 56450 | + "16x4 at 4:2:2 is BLOCK_8X4" | |
| 56451 | + ); | |
| 56452 | + assert!( | |
| 56453 | + !chroma_plane_block_codable(32, 8, 0, 1), | |
| 56454 | + "32x8 at 4:4:0 is BLOCK_INVALID" | |
| 56455 | + ); | |
| 56456 | + } | |
| 56262 | 56457 | /// lane-av1chrtx: [`covering_leaf_tx_type`] resolves a chroma unit's |
| 56263 | 56458 | /// `tx_type` from the luma leaf covering the unit's OWN quadrant, and |
| 56264 | 56459 | /// reports "no leaf there" as `None` so the caller can fall back to the |
lanes/av1unwritten.report.mdmodified+48 -8
| @@ -10,7 +10,21 @@ sentinel census that found the class is kept as the instrument.** | ||
| 10 | 10 | |
| 11 | 11 | Branch `lane/av1unwritten`, base `main` = `8d6998d7`. No push. |
| 12 | 12 | |
| 13 | -> **This report was rewritten.** The first version of this lane claimed a libaom | |
| 13 | +> **r3 correction, on top of r2.** The r2 predicate was a four-cell hand-picked | |
| 14 | +> `match`, and it was wrong in BOTH directions. It refused `(16, 4)` at ss (1,0), | |
| 15 | +> where `av1_ss_size_lookup[BLOCK_16X4][1][0]` is `BLOCK_8X4` — a LEGAL 4:2:2 | |
| 16 | +> shape, and one libaom's own encoder emits (`partition_search.c:3383-3389` | |
| 17 | +> gates `partition_rect_allowed[HORZ]` with this very table), so we were refusing | |
| 18 | +> a stream aomenc produces. And it covered only two of the eight shapes libaom | |
| 19 | +> refuses at 4:2:2. r3 replaces the `match` with a verbatim transcription of | |
| 20 | +> the table's `BLOCK_INVALID` cells (§3.1) and adds | |
| 21 | +> `chroma_plane_block_codable_matches_the_libaom_table`, which re-writes all 22 | |
| 22 | +> rows x 4 subsampling pairs from `common_data.c:17-41` and checks the predicate | |
| 23 | +> cell for cell. The corpus sweep CANNOT see the false positive — no committed | |
| 24 | +> fixture carries a 16x8 block split `PARTITION_HORZ` at 4:2:2 — and that table | |
| 25 | +> test is what covers that direction. | |
| 26 | +> | |
| 27 | +> **This report was rewritten once before. The first version of this lane claimed a libaom | |
| 14 | 28 | > `TX_4X8` chroma unit for a `BLOCK_4X8` subsize and landed a port of it. The |
| 15 | 29 | > refutation pass (Agent03-5, verified first-hand by Main) showed that port does |
| 16 | 30 | > not exist: `get_plane_block_size` is a single indexed return |
| @@ -120,8 +134,18 @@ diff cannot tell an unwritten sample from a mis-predicted one). | ||
| 120 | 134 | |
| 121 | 135 | `crates/ec-av1/src/decode.rs`: |
| 122 | 136 | |
| 123 | -* `chroma_plane_block_codable(bw, bh, ss_x, ss_y)` — the four | |
| 124 | - `BLOCK_INVALID` cells of `av1_ss_size_lookup`, nothing else. | |
| 137 | +* `chroma_plane_block_codable(bw, bh, ss_x, ss_y)` — a verbatim transcription | |
| 138 | + of `av1_ss_size_lookup`'s `BLOCK_INVALID` cells, in two const lists so a | |
| 139 | + reader can diff them against `common_data.c` line by line: | |
| 140 | + | |
| 141 | + | subsampling | INVALID luma shapes | | |
| 142 | + |---|---| | |
| 143 | + | 4:2:2 `(1,0)` | 4x8, 8x16, 16x32, 32x64, 64x128, 4x16, 8x32, 16x64 | | |
| 144 | + | 4:4:0 `(0,1)` | 8x4, 16x8, 32x16, 64x32, 128x64, 16x4, 32x8, 64x16 | | |
| 145 | + | 4:4:4 `(0,0)`, 4:2:0 `(1,1)` | none | | |
| 146 | + | |
| 147 | + Checked by `chroma_plane_block_codable_matches_the_libaom_table`, which | |
| 148 | + transcribes all 22 rows x 4 pairs literally from `common_data.c:17-41`. | |
| 125 | 149 | * `refuse_invalid_plane_block(...)` — a **returned** error (never an |
| 126 | 150 | `assert!`: a partition symbol is stream data, so hostile bytes reach it), |
| 127 | 151 | carrying libaom's own wording so the message names the rule: |
| @@ -153,11 +177,22 @@ Same refusal class as the oracle, same rule, same shape named. | ||
| 153 | 177 | | `partition_w8` (2 sites, 36549 / 36767 region) | 8x4, 4x8 | **yes**, installed | |
| 154 | 178 | | `partition_w16` intra (36175 region) | 16x8, 8x16 | **yes**, installed | |
| 155 | 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 | |
| 156 | -| `PARTITION_HORZ_4` / `VERT_4` on 8x16 / 16x8 (`decode_rect_split`) | 4x16, 16x4 | **NOT installed — known gap, stated here** | | |
| 157 | -| 32/64-level partitions, 128 root, AB partitions | squares and 32x64/64x32 | no: every cell of those rows is non-INVALID at every subsampling this decoder accepts | | |
| 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** | | |
| 181 | +| `partition_w32` `PARTITION_VERT` | 16x32 — INVALID at 4:2:2 | **NOT installed — named gap** | | |
| 182 | +| `partition_w64` `PARTITION_VERT` | 32x64 — INVALID at 4:2:2 | **NOT installed — named gap** | | |
| 183 | +| 128 root `PARTITION_VERT` | 64x128 — INVALID at 4:2:2 | **NOT installed — named gap** | | |
| 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** | | |
| 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 | | |
| 158 | 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 | |
| 159 | 187 | |
| 160 | -The 1:4 sites are the honest gap: `PARTITION_HORZ_4` on an 8x16 yields a 4x16, | |
| 188 | +So r3 installs the check at two sites and NAMES the other six rather than | |
| 189 | +claiming them covered. The predicate is now correct for every shape, so each | |
| 190 | +remaining site is a one-line call at a dispatch that is already written; none of | |
| 191 | +them is reachable by a committed fixture (§4 shows the corpus cannot see even | |
| 192 | +the false-positive direction), which is why they are a declared gap and not a | |
| 193 | +claim. | |
| 194 | + | |
| 195 | +The 1:4 sites were already the honest gap: `PARTITION_HORZ_4` on an 8x16 yields a 4x16, | |
| 161 | 196 | whose 4:2:2 plane block is `BLOCK_INVALID`, and this lane did not install the |
| 162 | 197 | check there. `decode_rect4_16_intrabc` is on another lane's charter and was not |
| 163 | 198 | touched; the neighbouring non-intrabc `decode_rect4_16_strip` site is where the |
| @@ -171,8 +206,13 @@ instrument is what would show it if one ever did. | ||
| 171 | 206 | * **Corpus, both trees.** Every fixture decoded with `EC_AV1_FINAL_DUMP`, every |
| 172 | 207 | `.f*` hashed. Pre-fix vs post-fix the **126 valid fixtures are byte-identical** |
| 173 | 208 | and **none newly refuses**; the witness is the only difference and it now |
| 174 | - refuses. Measured by the same loop as the §2 hashes, with the per-fixture | |
| 175 | - stderr scanned for `REFUSED`. | |
| 209 | + refuses. Re-run on the r3 (corrected) predicate: `differing: | |
| 210 | + ['440_request_is_422']`, 126 fixtures emitting dumps, and exactly one fixture | |
| 211 | + 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 | |
| 213 | + split `PARTITION_HORZ` at 4:2:2, which is why r2's over-refusal passed 126/126 | |
| 214 | + unnoticed. That direction is covered by | |
| 215 | + `chroma_plane_block_codable_matches_the_libaom_table`, not by the sweep. | |
| 176 | 216 | * **Sentinel sweep** (127 fixtures, `EC_AV1_PLANE_SENTINEL=1`): pre-fix exactly |
| 177 | 217 | one fixture had a non-empty census (the witness, 112+112); post-fix the corpus |
| 178 | 218 | has no unwritten sample anywhere — the witness decodes nothing at all now, and |