forge
Explore
Log in

Don't you dare go Hollow

The 16x16-level PARTITION_VERT_B arm missed the vert availability tables

Browse files at this commit

1f9bde4cb2f7a4f1b2fbea29be025a944c9e622eAhmet Kaan GümüşParent: fb6a2f1
  • fix
    • the 16x16-level PARTITION_VERT_B arm missed the vert availability tables
Show full message
fix(av1): the 16x16-level PARTITION_VERT_B arm missed the vert availability tables

decode.rs:7008 visits its two 8x8 squares TR then BR, out of raster order, so
like the 32/64-level AB arms r5 fixed it must read libaom's has_tr_vert_8x8 /
has_bl_vert_8x8 (get_has_tr_table / get_has_bl_table take the partition type).
has_bl_8x8 is 0 where has_bl_vert_8x8 is 1 at all 16 even-row/odd-col 8x8 slots
-- exactly the TR square -- so its below_left was wrongly false for the
directional modes that read below-left (angle > 180: D203_PRED, D157_PRED with a
positive delta). Class swept: this was the only remaining unguarded VERT_A/_B
site at any level, intra or inter.

Gated by a table pin (encode.rs) rather than a stream: a bounded 112-encode
aomenc sweep produced no decodable 16-level VERT_B -- every stream that
partitions that small first hits the still-refused HORZ_A/HORZ_B/VERT_A-below-16
or coded-rect-strip-below-16 arms. Counts in lanes/part32-r6.report.md.

EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib: 270 passed, 0 failed.
crates/ec-av1/src/decode.rsmodified+12 -0
@@ -7007,6 +7007,18 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
7007 }7007 }
7008 if part16 == PARTITION_VERT_B {7008 if part16 == PARTITION_VERT_B {
7009 VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1));7009 VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1));
7010+ // lane-part32 r6: same availability
7011+ // defect r5 fixed one level up --
7012+ // the TR/BR 8x8 squares below are
7013+ // visited out of raster order, so
7014+ // they need libaom's
7015+ // `has_tr_vert_*`/`has_bl_vert_*`
7016+ // tables (the left 8x16 rect goes
7017+ // through `Reach::of_rect`, which
7018+ // the guard deliberately does not
7019+ // affect).
7020+ let _vert_ab =
7021+ crate::encode::Reach::vert_ab_partition();
7010 // Left rect: 8x16, real7022 // Left rect: 8x16, real
7011 // `decode_block_rect`, sat at the7023 // `decode_block_rect`, sat at the
7012 // 16x16 parent's own origin (no7024 // 16x16 parent's own origin (no
crates/ec-av1/src/encode.rsmodified+39 -0
@@ -3550,6 +3550,45 @@ mod tests {
3550 }3550 }
3551 }3551 }
3552 3552
3553+ /// lane-part32 r6: inside a `PARTITION_VERT_A`/`_B` the 8x8 squares are
3554+ /// visited TL, BL, TR, BR, so the TR square (even 8x8 row, odd 8x8
3555+ /// column inside the superblock) may read the below-left samples the
3556+ /// raster table forbids: `has_bl_8x8` is 0 at exactly those 16 slots
3557+ /// where `has_bl_vert_8x8` is 1. Pinned here because no aomenc recipe
3558+ /// swept in r6 produced a decodable 16x16-level VERT_B stream (every
3559+ /// stream that partitions that small first hits the still-refused
3560+ /// HORZ_A/HORZ_B/VERT_A-below-16 or coded-rect-strip-below-16 arms).
3561+ #[test]
3562+ fn vert_ab_partition_flips_below_left_for_the_top_right_8x8() {
3563+ let (width, height) = (SUPERBLOCK * 3, SUPERBLOCK * 3);
3564+ // Interior superblock, so neither the frame edge nor the col == 0 /
3565+ // last-row early returns answer instead of the table.
3566+ let (sb_x, sb_y) = (SUPERBLOCK, SUPERBLOCK);
3567+ let mut flipped = 0;
3568+ for row in 0..8 {
3569+ for col in 1..8 {
3570+ let (x, y) = (sb_x + col * 8, sb_y + row * 8);
3571+ let raster = Reach::of(8, x, y, width, height).below_left;
3572+ let vert = {
3573+ let _guard = Reach::vert_ab_partition();
3574+ Reach::of(8, x, y, width, height).below_left
3575+ };
3576+ // The TR square of a VERT_A/_B sits at an even row, odd
3577+ // column; every other slot must be untouched by the guard.
3578+ if row % 2 == 0 && col % 2 == 1 {
3579+ assert!(!raster, "raster below_left at row={row} col={col}");
3580+ assert!(vert, "vert below_left at row={row} col={col}");
3581+ flipped += 1;
3582+ } else {
3583+ assert_eq!(raster, vert, "guard moved row={row} col={col}");
3584+ }
3585+ }
3586+ }
3587+ assert_eq!(flipped, 4 * 4, "expected the 16 8x8 TR slots to flip");
3588+ // The guard is scoped: it must not leak past its own block.
3589+ assert!(!Reach::of(8, sb_x + 8, sb_y, width, height).below_left);
3590+ }
3591+
3553 /// An odd width or height is refused by name, not by however the padder3592 /// An odd width or height is refused by name, not by however the padder
3554 /// or the block coder would happen to fail on it.3593 /// or the block coder would happen to fail on it.
3555 #[test]3594 #[test]
lanes/part32-r6.report.mdadded+89 -0
@@ -0,0 +1,89 @@
1+# lane-part32 r6 — the 16x16-level VERT_B arm was the one AB site r5 missed
2+
3+Branch `lane-part32`, on top of r5 `02dbbd6`.
4+
5+## Class sweep: every VERT_A/VERT_B site in decode.rs
6+
7+`grep -n "PARTITION_VERT_A\|PARTITION_VERT_B" crates/ec-av1/src/decode.rs`, all
8+levels, intra and inter:
9+
10+| site | level | path | guard at r5 |
11+|---|---|---|---|
12+| `decode.rs:7008` | 16 | intra VERT_B (8x16 rect + TR/BR 8x8 `decode_leaf8`) | **MISSING — fixed this round** |
13+| `decode.rs:7538/7612` | 32 | intra VERT_A / VERT_B | present (r5) |
14+| `decode.rs:7779` | 64 (SB) | AB arm, vert arms only | present (r5) |
15+| `decode.rs:13445/13606` | 32 | inter VERT_A / VERT_B | present (r5) |
16+
17+No other site exists: the 16-level inter path has no AB arms (they are refused by
18+name, "a HORZ_A/HORZ_B/VERT_A partition below 16x16"), and 8-level partitions
19+below that are SPLIT-only. So one missed site, now guarded — the class is closed
20+for VERT_A/_B.
21+
22+The verifier's computation is confirmed exactly (checked bit by bit against the
23+transcribed tables in `encode.rs`): `has_bl_8x8` reads **0** where
24+`has_bl_vert_8x8` reads **1** at all 16 even-8x8-row / odd-8x8-column slots of a
25+superblock — that slot is precisely the TR square of a VERT_A/_B — so the TR
26+square's `below_left` was wrongly false for the bottom-left-reading directional
27+modes (angle > 180: `D203_PRED`, `D157_PRED` with a positive angle delta).
28+Mirror-image for `has_tr_8x8` vs `has_tr_vert_8x8` (1 -> 0) at odd-row /
29+even-column slots, which VERT_A/_B never visit at 8x8 (no BL square in either).
30+
31+## Files changed
32+
33+- `crates/ec-av1/src/decode.rs:7010` — the intra 16-level `PARTITION_VERT_B` arm
34+ takes `crate::encode::Reach::vert_ab_partition()` for the whole arm; the left
35+ 8x16 rect is unaffected by design (`Reach::of_rect`, libaom's own comment says
36+ vertical rectangles keep the non-vert table), the two `decode_leaf8` squares
37+ now read the vert tables.
38+- `crates/ec-av1/src/encode.rs:3565` — `vert_ab_partition_flips_below_left_for_the_top_right_8x8`,
39+ a table pin next to the existing libaom-availability test: all 16 TR slots flip
40+ `below_left` false -> true under the guard, every other slot is untouched, and
41+ the guard does not leak past its scope.
42+
43+## Gate: attempted, could not be built — the fix stays source-verified
44+
45+The charter's stream gate (a real-aomenc 16-level VERT_B, directional modes on,
46+decoded and compared pixel-exact) was written and run, and it cannot fire on this
47+aomenc build. Bounded sweep, all with
48+`--min-partition-size=8 --max-partition-size=16 --enable-rect-partitions=1
49+--enable-1to4-partitions=0 --enable-directional-intra=1 --enable-angle-delta=1
50+--cpu-used=0 --kf-max-dist=0 --passes=1`, 64x64 grey mandelbrot key frames:
51+
52+| recipe | attempts | decoded | refusals |
53+|---|---|---|---|
54+| cq=45, `--enable-ab-partitions=1` | 40 | 0 | 40 (below-16 HORZ_A/HORZ_B/VERT_A, or a coded non-skip rect strip below 16) |
55+| cq=45, ab={0,1} | 10 + 10 | 0 | 8 AB-below-16 + 2 coded-rect-strip, each |
56+| cq=63, ab={0,1} | 40 + 10 | all | none — but `partition_w16` never resolves to VERT_B (value=7): the frame stays at 16x16 NONE |
57+| cq={55,57,60}, mandelbrot / testsrc2 / cellauto | 12 | 3 | same two below-16 refusals |
58+
59+`EC_AV1_TRACE=1` `partition_w16` value histogram over every decoded stream: 0
60+occurrences of value=7 at any quality that decodes. Every stream that partitions
61+small enough to *reach* a 16-level VERT_B hits one of the two still-refused
62+below-16 capabilities first (HORZ_A/HORZ_B/VERT_A-below-16, coded rect strip
63+below-16), which abort the tile before the VERT_B arm. Writing a gate that
64+decodes only cq=63 streams would have been vacuous
65+(`gate-blind-to-feature`), so the sweep gate was **removed** rather than
66+committed green, and the pin above carries the fix instead.
67+
68+EVIDENCE: /tmp/.../scratchpad (r6 sweep, shell loop above) | 40+40+20+12 real aomenc encodes, `EC_AV1_TRACE=1 decode_probe` on each | 0 streams with `partition_w16 value=7`; at cq=45 40/40 refused with the two named below-16 refusals, at cq=63 50/50 decoded with 0 VERT_B
69+
70+EVIDENCE: `cargo test -p ec-av1 --lib -- vert_ab_partition_flips` | table pin of the guard at all 64 8x8 slots of an interior superblock | `test result: ok. 1 passed`; 16 TR slots flip false->true, 48 unchanged
71+
72+EVIDENCE: /tmp/.../scratchpad/r6full.txt | `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` | `test result: ok. 270 passed; 0 failed; 24 ignored; 0 measured` in 1585s (269 before this round's new pin)
73+
74+## Refusals
75+
76+None lifted or added this round (the two below-16 refusals above are other
77+lanes'). `refusal_inventory` and `gate_coverage` unchanged and green in the run
78+above.
79+
80+## Residue
81+
82+- deferred(a lane that ports HORZ_A/HORZ_B/VERT_A below 16x16, or the coded
83+ non-skip rect strip below 16x16): the pixel-exact stream gate for the 16-level
84+ VERT_B arm. Both refusals fire before the arm on every recipe swept; once
85+ either lands, re-run the sweep in this report and the gate becomes writable
86+ as-is.
87+- accepted: the fix is source-verified + table-pinned, not stream-proven. It is a
88+ one-bit availability change of exactly the shape r5 proved by pixel comparison
89+ one level up (4683 wrong luma samples there).