forge
Explore
Log in

Don't you dare go Hollow

lane-av1unwritten r3: the predicate is a transcription of av1_ss_size_lookup, not a guess

Browse files at this commit

b9fb4993feeadbdcf2853662b5ccae71b13d5fedAhmet Kaan GümüşParent: ff41e00
Main's r3 refutation is right on both counts. The r2 four-cell match refused
(16,4) at ss (1,0), where the table says BLOCK_8X4 -- a legal 4:2:2 shape that
libaom's own encoder emits, since partition_search.c:3383-3389 gates
partition_rect_allowed[HORZ] with exactly this table. And it covered two of the
eight shapes libaom refuses at 4:2:2; r2's claim that the 32/64-level roots need
no check was true of the PARENT rows and false of the children
(get_partition_subsize(BLOCK_32X32, PARTITION_VERT) = BLOCK_16X32, INVALID at
(1,0)).

chroma_plane_block_codable is now two const lists holding every BLOCK_INVALID
cell of common_data.c:17-41 and nothing else -- at (1,0): 4x8, 8x16, 16x32,
32x64, 64x128, 4x16, 8x32, 16x64; at (0,1): 8x4, 16x8, 32x16, 64x32, 128x64,
16x4, 32x8, 64x16; none at (0,0) or (1,1) -- so a reader diffs it against the C
source line by line.

New gate chroma_plane_block_codable_matches_the_libaom_table transcribes all 22
rows x 4 subsampling pairs literally and asserts agreement cell for cell. It
reds on exactly the mistake r2 made: transcribing it caught two rows (32x8 and
64x16 at (0,1)) I had copied wrong out of the briefing, and it pins 16x4@4:2:2
as legal, which is the direction the corpus cannot see.

Site coverage is now stated as installed (partition_w8, partition_w16) plus six
named gaps (VERT_4/HORZ_4 1:4 -> 4x16; w32/w64/128 VERT -> 16x32/32x64/64x128;
VERT_A/VERT_B -> 8x32/16x64), each with the next step, rather than claiming
coverage. decode_rect4_16_intrabc stays out of scope and is named as such.

Regression on the corrected predicate: 127 fixtures, both trees, per-fixture
aggregate hashes -- differing: ['440_request_is_422'], 126 emitting dumps, one
REFUSED. Gates green: the table test, the refusal gate with its 4:2:2 positive
control, and the realigned the_440_cell_is_not_a_codable_chroma_shape.
crates/ec-av1/src/decode.rsmodified+200 -5
@@ -21370,12 +21370,77 @@ fn plane_sentinel_on() -> bool {
21370 /// CHANGED RUN TO RUN. `aomdec` on the same file:21370 /// CHANGED RUN TO RUN. `aomdec` on the same file:
21371 /// `Failed to decode frame 1: Corrupt frame detected` / `Block size 8x1621371 /// `Failed to decode frame 1: Corrupt frame detected` / `Block size 8x16
21372 /// invalid with this subsampling mode`.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 fn chroma_plane_block_codable(bw: usize, bh: usize, sx: usize, sy: usize) -> bool {21440 fn chroma_plane_block_codable(bw: usize, bh: usize, sx: usize, sy: usize) -> bool {
21374- match (bw, bh) {21441+ match (sx, sy) {
21375- (4, 8) => (sx, sy) != (1, 0),21442+ (1, 0) => !PLANE_BLOCK_INVALID_422.contains(&(bw, bh)),
21376- (8, 4) => (sx, sy) != (0, 1),21443+ (0, 1) => !PLANE_BLOCK_INVALID_440.contains(&(bw, bh)),
21377- (8, 16) => (sx, sy) != (1, 0),
21378- (16, 4) => (sx, sy) != (1, 0),
21379 _ => true,21444 _ => true,
21380 }21445 }
21381 }21446 }
@@ -56259,6 +56324,136 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
56259 56324
56260 #[cfg(test)]56325 #[cfg(test)]
56261 mod tests {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 /// lane-av1chrtx: [`covering_leaf_tx_type`] resolves a chroma unit's56457 /// lane-av1chrtx: [`covering_leaf_tx_type`] resolves a chroma unit's
56263 /// `tx_type` from the luma leaf covering the unit's OWN quadrant, and56458 /// `tx_type` from the luma leaf covering the unit's OWN quadrant, and
56264 /// reports "no leaf there" as `None` so the caller can fall back to the56459 /// 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 Branch `lane/av1unwritten`, base `main` = `8d6998d7`. No push.11 Branch `lane/av1unwritten`, base `main` = `8d6998d7`. No push.
12 12
13-> **This report was rewritten.** The first version of this lane claimed a libaom13+> **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 > `TX_4X8` chroma unit for a `BLOCK_4X8` subsize and landed a port of it. The28 > `TX_4X8` chroma unit for a `BLOCK_4X8` subsize and landed a port of it. The
15 > refutation pass (Agent03-5, verified first-hand by Main) showed that port does29 > refutation pass (Agent03-5, verified first-hand by Main) showed that port does
16 > not exist: `get_plane_block_size` is a single indexed return30 > 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 `crates/ec-av1/src/decode.rs`:135 `crates/ec-av1/src/decode.rs`:
122 136
123-* `chroma_plane_block_codable(bw, bh, ss_x, ss_y)` — the four137+* `chroma_plane_block_codable(bw, bh, ss_x, ss_y)` — a verbatim transcription
124- `BLOCK_INVALID` cells of `av1_ss_size_lookup`, nothing else.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 * `refuse_invalid_plane_block(...)` — a **returned** error (never an149 * `refuse_invalid_plane_block(...)` — a **returned** error (never an
126 `assert!`: a partition symbol is stream data, so hostile bytes reach it),150 `assert!`: a partition symbol is stream data, so hostile bytes reach it),
127 carrying libaom's own wording so the message names the rule: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 | `partition_w8` (2 sites, 36549 / 36767 region) | 8x4, 4x8 | **yes**, installed |177 | `partition_w8` (2 sites, 36549 / 36767 region) | 8x4, 4x8 | **yes**, installed |
154 | `partition_w16` intra (36175 region) | 16x8, 8x16 | **yes**, installed |178 | `partition_w16` intra (36175 region) | 16x8, 8x16 | **yes**, installed |
155 | `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 |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** |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** |
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 |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 | 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 |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 whose 4:2:2 plane block is `BLOCK_INVALID`, and this lane did not install the196 whose 4:2:2 plane block is `BLOCK_INVALID`, and this lane did not install the
162 check there. `decode_rect4_16_intrabc` is on another lane's charter and was not197 check there. `decode_rect4_16_intrabc` is on another lane's charter and was not
163 touched; the neighbouring non-intrabc `decode_rect4_16_strip` site is where the198 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 * **Corpus, both trees.** Every fixture decoded with `EC_AV1_FINAL_DUMP`, every206 * **Corpus, both trees.** Every fixture decoded with `EC_AV1_FINAL_DUMP`, every
172 `.f*` hashed. Pre-fix vs post-fix the **126 valid fixtures are byte-identical**207 `.f*` hashed. Pre-fix vs post-fix the **126 valid fixtures are byte-identical**
173 and **none newly refuses**; the witness is the only difference and it now208 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-fixture209+ refuses. Re-run on the r3 (corrected) predicate: `differing:
175- stderr scanned for `REFUSED`.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 * **Sentinel sweep** (127 fixtures, `EC_AV1_PLANE_SENTINEL=1`): pre-fix exactly216 * **Sentinel sweep** (127 fixtures, `EC_AV1_PLANE_SENTINEL=1`): pre-fix exactly
177 one fixture had a non-empty census (the witness, 112+112); post-fix the corpus217 one fixture had a non-empty census (the witness, 112+112); post-fix the corpus
178 has no unwritten sample anywhere — the witness decodes nothing at all now, and218 has no unwritten sample anywhere — the witness decodes nothing at all now, and