Superblock-level HORZ/VERT strips with a split transform -- root cause was a transposed nz_map ctx offset table
Browse files at this commitc936fdcc071ca4625c3152609b0dfe6610f1e17eParent: ec3268e- feat
- superblock-level HORZ/VERT strips with a split transform -- root cause was a transposed nz_map ctx offset table
2 changed files +78 -1
crates/ec-av1/src/stream.rsmodified+2 -1
| @@ -9951,7 +9951,8 @@ mod tests { | ||
| 9951 | 9951 | ); |
| 9952 | 9952 | eprintln!( |
| 9953 | 9953 | "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals, \ |
| 9954 | - rect_split_tx_hits delta={split_hits} out of {n_attempts} attempts" | |
| 9954 | + rect_split_sb_interior_tu_hits delta={split_hits} (over COMPARED streams only) \ | |
| 9955 | + out of {n_attempts} attempts" | |
| 9955 | 9956 | ); |
| 9956 | 9957 | } |
| 9957 | 9958 |
lanes/rectsplit-r2.report.mdadded+76 -0
| @@ -0,0 +1,76 @@ | ||
| 1 | +# lane-rectsplit r2 — superblock-level split-transform strips, and the transposed nz_map offset | |
| 2 | + | |
| 3 | +Branch `lane-rectsplit` off main `3808cf8` (r1 `3627fe9` already merged into main). | |
| 4 | +r2's build work was capped mid-round and preserved as WIP `bf53652`; this round ran the | |
| 5 | +gates it never reached, fixed one stale print label, and reports the result. | |
| 6 | + | |
| 7 | +## What changed (r2's WIP `bf53652`, verified this round) | |
| 8 | + | |
| 9 | +- `crates/ec-av1/src/decode.rs:4054` `decode_block_rect64` — the refusal | |
| 10 | + "a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is | |
| 11 | + not ported)" REMOVED; the SB-level strip now routes through the same per-transform-unit | |
| 12 | + path as its 32x32-level sibling (`decode_rect_split`, `sub_tx_size_map[TX_64X32] == | |
| 13 | + TX_32X32`, so `bw.min(bh) >> (depth - 1)` names the square unit). | |
| 14 | + `refusal_inventory.rs:46` drops that string. | |
| 15 | +- **ROOT CAUSE of r1's RED gate (b)** — `crates/ec-av1/src/decode.rs:1159` `base_ctx`, | |
| 16 | + `TxClass::TwoD`: libaom's `av1_nz_map_ctx_offset[tx_size]` is a FLAT array indexed by a | |
| 17 | + COLUMN-major `coeff_idx` (`col * height + row`), so a transcription holding 32 consecutive | |
| 18 | + entries per outer index is `[col][row]`, not `[row][col]`. The square table is symmetric | |
| 19 | + and never noticed; the two rect tables are not. Read `table[col.min(4)][row.min(4)]`. | |
| 20 | + This is defect class `reference-layout-not-spec` / `scan-weights-cross-axis`, NOT the | |
| 21 | + per-unit edge-availability rule r1 suspected. | |
| 22 | +- `crates/ec-av1/src/decode.rs` (tests) `nz_map_ctx_offset_tables_match_the_rect_rule` — | |
| 23 | + pins both rect tables against `base_ctx_rect`'s independently-written generating rule | |
| 24 | + (`w<h && row<2 -> +11`, `w>h && col<2 -> +16`, else the square table) in display | |
| 25 | + coordinates. A transposed read breaks it. | |
| 26 | +- `crates/ec-av1/src/decode.rs:3248` — the chroma-shape refusal | |
| 27 | + "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here" is | |
| 28 | + documented as UNREACHABLE with both callers wired, and KEPT as the shape guard for the | |
| 29 | + next caller (without it a new strip size panics on the `expect` instead of refusing by | |
| 30 | + name). It stays in `refusal_inventory::REFUSALS`. | |
| 31 | +- `crates/ec-av1/src/stream.rs` gates (a) `:9363`, (c) `:9554`, (b) `:9790` — per-attempt | |
| 32 | + counter sampling: a feature-hit delta is folded in ONLY after that attempt decoded AND | |
| 33 | + pixel-compared, so hits from a stream that later hits a named refusal can no longer make | |
| 34 | + a gate pass vacuously (ledger dead-end "counter-delta firing asserts ... count hits from | |
| 35 | + streams that LATER refuse"). Gate (b) asserts on the NEW | |
| 36 | + `decode::rect_split_sb_interior_tu_hits` (`bw.max(bh)==64 && bw/tx>1 && bh/tx>1`), i.e. | |
| 37 | + a superblock-level strip split past depth 1 with a genuinely interior transform unit — | |
| 38 | + the shared `rect_split_tx_hits` also counts 32x32-level and depth-1 strips and could not | |
| 39 | + prove this case. Mismatch reporting gained the mismatching-sample count + bbox. | |
| 40 | +- Gate (c)'s stale comment claiming the directional/smooth/paeth competitors are disabled | |
| 41 | + is replaced by the measured reason they cannot be (r1's table: competitors off -> 0 rect | |
| 42 | + strips); the quantiser `--cq-level=25` is what fires filter intra on a strip. | |
| 43 | +- `crates/ec-av1/examples/decode_probe.rs` — optional 2nd arg dumps decoded planes as raw | |
| 44 | + I420 for per-pixel diffing outside a gate. | |
| 45 | +- THIS ROUND: `stream.rs:9953` gate (b)'s summary line said `rect_split_tx_hits delta=` while | |
| 46 | + asserting the SB-interior counter; relabelled `rect_split_sb_interior_tu_hits delta=N | |
| 47 | + (over COMPARED streams only)`. | |
| 48 | + | |
| 49 | +## Refusals lifted | |
| 50 | + | |
| 51 | +| refusal | gate | result | | |
| 52 | +| --- | --- | --- | | |
| 53 | +| "a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is not ported)" | `a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact` | GREEN (was `#[ignore]`d RED in r1): 20/20 pixel-exact, 0 named refusals, SB-interior-TU delta 7 over compared streams | | |
| 54 | + | |
| 55 | +Still refused (unchanged, not this round's): the below-16x16 `decode_leaf_rect` strip arms | |
| 56 | +(deferred(a below-16x16 strip gate — lane-sub8's territory)); the unreachable chroma shape | |
| 57 | +guard above (accepted, justified in place). | |
| 58 | + | |
| 59 | +## Evidence | |
| 60 | + | |
| 61 | +EVIDENCE: `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3 -- split_transform filter_intra_on_a_horz refusal_inventory gate_coverage nz_map_ctx_offset --nocapture` | 3 aomenc gates + inventory/coverage/table tests on lane-rectsplit @ bf53652 | 9 passed, 0 failed, 0 ignored, 47.68s — gate (b) 20 pixel-exact / 0 refusals / SB-interior delta=7 (nonzero on seeds 57,60,61); gate (a) 20/20 delta=2; gate (c) 40/40 filter_intra_rect delta=3 | |
| 62 | + | |
| 63 | +## Film check (both films, 0.4s extracts) | |
| 64 | + | |
| 65 | +``` | |
| 66 | +ffmpeg -v error -t 0.4 -i "<reelc.mkv>" -c:v copy -f obu reelc.obu # 418 bytes | |
| 67 | +ffmpeg -v error -t 0.4 -i "<reelb.mkv>" -c:v copy -f obu hg.obu # 1817 bytes | |
| 68 | +cargo run -p ec-av1 --example decode_probe -- reelc.obu | |
| 69 | +REFUSED: unsupported: AV1 tile (a 32x32 partition type this decoder does not code (value=4)) | |
| 70 | +cargo run -p ec-av1 --example decode_probe -- hg.obu | |
| 71 | +REFUSED: unsupported: AV1 tile (a partition below 8x8 (this decoder codes no leaf smaller than 8x8)) | |
| 72 | +``` | |
| 73 | + | |
| 74 | +EVIDENCE: scratchpad `reelc.obu` (418 B) / `hg.obu` (1817 B) | `ffmpeg -t 0.4 -c:v copy -f obu` then `decode_probe` on lane-rectsplit | ReelC stops at "a 32x32 partition type ... (value=4)", ReelB at "a partition below 8x8" — neither is a refusal this lane owns, both upstream of every line touched here | |
| 75 | + | |
| 76 | +disposition: deferred(lane-sub8's below-8x8 leaf; the 32x32 value=4 AB-partition arm) — outside this lane. |