forge
Explore
Log in

Don't you dare go Hollow

Revert r2's nz_map transposition -- it regressed the merged SB HORZ/VERT partition gate

Browse files at this commit

429edc6182b69306658d950cea44b128ec5c4fe8Ahmet Kaan GümüşParent: c936fdc
  • fix
    • revert r2's nz_map transposition -- it regressed the merged SB HORZ/VERT partition gate
    • SB split-tx refusal restored
Show full message
fix(av1): revert r2's nz_map transposition -- it regressed the merged SB HORZ/VERT partition gate; SB split-tx refusal restored

r3 ran the gates r2 never reached. r2's claimed root cause (base_ctx reading
the rect av1_nz_map_ctx_offset tables [row][col] instead of [col][row]) turns
the split-transform SB gate green at the cost of turning the MERGED gate
a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact
RED at seed 43. All four index/shape combinations measured; two fail both. The
real unknown is the orientation of (row,col) out of the square 32x32-corner
scan vs libaom's column-major coeff_idx, so the SB-level split-transform
refusal is restored and gate (b) is #[ignore]d again with that reason.

Kept from r2: per-attempt gate counters (no vacuous pass from a stream that
later refuses), the SB-interior-TU counter gate (b) asserts, the chroma shape
guard justification, gate (c)'s corrected recipe comment, the nz_map table
packing pin, and the EC_NZOFF_DUMP / decode_probe dump instruments.
crates/ec-av1/src/decode.rsmodified+36 -43
@@ -1159,26 +1159,33 @@ fn base_ctx(
1159 // (lane-sbpart r8 root cause: `(row=1, col=0)` reads ctx 2 under the1159 // (lane-sbpart r8 root cause: `(row=1, col=0)` reads ctx 2 under the
1160 // square table vs the real ctx 13 the rect table gives).1160 // square table vs the real ctx 13 the rect table gives).
1161 TxClass::TwoD => {1161 TxClass::TwoD => {
1162- // lane-rectsplit r2: libaom's `av1_nz_map_ctx_offset[tx_size]`1162+ // OPEN (lane-rectsplit r3, measured): the two rect
1163- // is a FLAT array indexed by its own `coeff_idx`, which is1163+ // transcriptions in [`cdf`] are packed `[col][row]` -- libaom's
1164- // COLUMN-major (`coeff_idx = col * height + row`, the same1164+ // `av1_nz_map_ctx_offset_32x64` is a FLAT 1024-entry array whose
1165- // packing `TX_CLASS_HORIZ` reads back as `coeff_idx >> bhl`) --1165+ // `coeff_idx` is COLUMN-major with stride 32 (`TX_CLASS_HORIZ`
1166- // so a `[a][b]` transcription of 32 consecutive entries per row1166+ // reads its column back as `coeff_idx >> bhl`), and entries
1167- // holds `[col][row]`, not `[row][col]`. The square table is1167+ // 0..5 / 32..35 match the generating rule (txb_common.h:199-209)
1168- // symmetric and never noticed; the two rect ones are not, and1168+ // only under `flat[col * 32 + row]`;
1169- // reading `NZ_MAP_CTX_OFFSET_32X64[2][0]` (11) where libaom1169+ // `nz_map_ctx_offset_tables_match_the_rect_rule` pins that.
1170- // reads offset 6 desynced the FIRST superblock-level 32x641170+ // Yet reading `[col][row]` here BREAKS
1171- // strip whose corner had a coefficient below row 1 (seed 50 of1171+ // `a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact`
1172- // gate (b), coefficient (row 2, col 0): ctx 11 vs the oracle's1172+ // (seed 43) while `[row][col]` breaks the split-transform SB gate
1173- // 6). [`base_ctx_rect`] states the same rule in display1173+ // (seed 50); swapping the shape test as well fails BOTH ways. So
1174- // coordinates directly; `nz_map_ctx_offset_tables_match_the_rect_rule`1174+ // this read is not the defect -- our (row, col) here come from a
1175- // pins the two against each other.1175+ // square 32x32-corner scan whose orientation relative to libaom's
1176+ // column-major `coeff_idx` is what is really unproven, and each
1177+ // "fix" only moves which rare corner position desyncs. Left at
1178+ // the r1 reading, the one every merged gate is green under.
1179+ // `EC_NZOFF_DUMP=1` prints every rect-shaped read.
1176 let table = match rect_shape {1180 let table = match rect_shape {
1177 Some((w, h)) if w < h => &cdf::NZ_MAP_CTX_OFFSET_32X64,1181 Some((w, h)) if w < h => &cdf::NZ_MAP_CTX_OFFSET_32X64,
1178 Some((w, h)) if w > h => &cdf::NZ_MAP_CTX_OFFSET_64X32,1182 Some((w, h)) if w > h => &cdf::NZ_MAP_CTX_OFFSET_64X32,
1179 _ => &cdf::NZ_MAP_CTX_OFFSET_32,1183 _ => &cdf::NZ_MAP_CTX_OFFSET_32,
1180 };1184 };
1181- ctx + table[col.min(4)][row.min(4)] as usize1185+ if std::env::var_os("EC_NZOFF_DUMP").is_some() {
1186+ eprintln!("NZOFF side={side} shape={rect_shape:?} row={row} col={col}");
1187+ }
1188+ ctx + table[row.min(4)][col.min(4)] as usize
1182 }1189 }
1183 TxClass::Horiz => ctx + nz_map_ctx_offset_1d(col.min(31)),1190 TxClass::Horiz => ctx + nz_map_ctx_offset_1d(col.min(31)),
1184 TxClass::Vert => ctx + nz_map_ctx_offset_1d(row.min(31)),1191 TxClass::Vert => ctx + nz_map_ctx_offset_1d(row.min(31)),
@@ -4054,34 +4061,20 @@ fn decode_block_rect64(
4054 };4061 };
4055 if depth != 0 {4062 if depth != 0 {
4056 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));4063 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
4057- // lane-rectsplit r2: the superblock-level strip splits its transform4064+ // lane-rectsplit r1/r3: [`decode_rect_split`] handles this shape too
4058- // through the very same per-unit path as its 32x32-level sibling4065+ // and the per-unit port is wired here, but the gate
4059- // (`sub_tx_size_map[TX_64X32] == TX_32X32`, square from the first4066+ // (`a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact`,
4060- // step on, so `bw.min(bh) >> (depth - 1)` names the unit).4067+ // `#[ignore]`d with its measurement) is still RED at seed 50 (luma
4061- let tx = bw.min(bh) >> (depth - 1);4068+ // (171,56), ours 147 vs ffmpeg 148). r2 believed the cause was a
4062- if std::env::var_os("EC_SBPART_DUMP64").is_some() {4069+ // transposed `av1_nz_map_ctx_offset` read; r3 measured that
4063- eprintln!(4070+ // transposing it turns THIS gate green and the merged SB-level
4064- "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \4071+ // HORZ/VERT partition gate RED (seed 43), so the cause is still
4065- depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \4072+ // open. A refusal this lane cannot lift is not one it may ship wrong
4066- angle_y={angle_delta_y}"4073+ // pixels past.
4067- );4074+ return Err(unsupported(
4068- }4075+ "a superblock-level HORZ/VERT strip with a split transform (per-unit rect \
4069- let modes = RectStripModes {4076+ prediction is not ported)",
4070- skip,4077+ ));
4071- mode,
4072- angle_delta_y,
4073- uv_predict_mode,
4074- angle_delta_uv,
4075- alpha,
4076- filter_intra,
4077- smooth_neighbor,
4078- smooth_neighbor_uv,
4079- };
4080- decode_rect_split(
4081- dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set,
4082- )?;
4083- RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));
4084- return Ok(());
4085 }4078 }
4086 let (tx_w, tx_h) = (bw, bh);4079 let (tx_w, tx_h) = (bw, bh);
4087 let (cpx, cpy) = (px / 2, py / 2);4080 let (cpx, cpy) = (px / 2, py / 2);
crates/ec-av1/src/refusal_inventory.rsmodified+1 -0
@@ -46,6 +46,7 @@ const REFUSALS: &[&str] = &[
46 "a Golomb tail longer than this decoder reads",46 "a Golomb tail longer than this decoder reads",
47 "a bit depth other than 8 with film grain applied (film_grain.rs's LUT and blend are hardcoded 8-bit)",47 "a bit depth other than 8 with film grain applied (film_grain.rs's LUT and blend are hardcoded 8-bit)",
48 "a bit depth other than 8 with use_superres set (superres.rs's upscale_row is hardcoded 8-bit)",48 "a bit depth other than 8 with use_superres set (superres.rs's upscale_row is hardcoded 8-bit)",
49+ "a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is not ported)",
49 "a tx_type symbol outside its CDF's own set: {t}",50 "a tx_type symbol outside its CDF's own set: {t}",
50 "an INTER 32x32 partition type this decoder does not code (value={part32})",51 "an INTER 32x32 partition type this decoder does not code (value={part32})",
51 "a superblock-level partition type other than NONE or SPLIT (this decoder's intra tile path codes only those two at 64x64)",52 "a superblock-level partition type other than NONE or SPLIT (this decoder's intra tile path codes only those two at 64x64)",
crates/ec-av1/src/stream.rsmodified+1 -0
@@ -9774,6 +9774,7 @@ mod tests {
9774 /// SB-level strip whose luma corner held a coefficient below row 1 (see9774 /// SB-level strip whose luma corner held a coefficient below row 1 (see
9775 /// that function's comment). The strip's own per-unit prediction was9775 /// that function's comment). The strip's own per-unit prediction was
9776 /// already exact.9776 /// already exact.
9777+ #[ignore = "lane-rectsplit r3: RED at seed 50; the nz_map transposition r2 blamed turns the merged SB HORZ/VERT partition gate RED at seed 43, cause still open"]
9777 #[test]9778 #[test]
9778 fn a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact() {9779 fn a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact() {
9779 const NAME: &str = "a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact";9780 const NAME: &str = "a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact";
lanes/rectsplit-r2.report.mdmodified+77 -64
@@ -1,76 +1,89 @@
1-# lane-rectsplit r2 — superblock-level split-transform strips, and the transposed nz_map offset1+# lane-rectsplit r2 (gates run and reported by r3) — SB-level split-transform strips: r2's root cause DISPROVED
2-2+
3-Branch `lane-rectsplit` off main `3808cf8` (r1 `3627fe9` already merged into main).3+Branch `lane-rectsplit` off main `3808cf8` (r1 `3627fe9` already merged). r2 was capped
4-r2's build work was capped mid-round and preserved as WIP `bf53652`; this round ran the4+before running any gate; its work is WIP `bf53652`. This round ran the gates, found that
5-gates it never reached, fixed one stale print label, and reports the result.5+r2's fix regresses a merged gate, and reverted the unsafe half.
6-6+
7-## What changed (r2's WIP `bf53652`, verified this round)7+## Headline
8-8+
9-- `crates/ec-av1/src/decode.rs:4054` `decode_block_rect64` — the refusal9+r2 claimed the root cause of r1's RED gate (b) was a transposed `av1_nz_map_ctx_offset`
10- "a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is10+read (`base_ctx`, `[row][col]` -> `[col][row]`). **Measured: that change turns gate (b)
11- not ported)" REMOVED; the SB-level strip now routes through the same per-transform-unit11+green (20/20) and turns the MERGED gate
12- path as its 32x32-level sibling (`decode_rect_split`, `sub_tx_size_map[TX_64X32] ==12+`a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact` RED
13- TX_32X32`, so `bw.min(bh) >> (depth - 1)` names the square unit).13+(seed 43 luma mismatch).** All four index/shape combinations were run:
14- `refusal_inventory.rs:46` drops that string.14+
15-- **ROOT CAUSE of r1's RED gate (b)** — `crates/ec-av1/src/decode.rs:1159` `base_ctx`,15+| base_ctx TwoD rect read | SB HORZ/VERT partition gate (merged) | split-tx SB gate (b) |
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 | --- | --- | --- |16 | --- | --- | --- |
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 |17+| `table(shape)[row][col]` (r1, shipped) | ok | FAILED (seed 50) |
18+| `table(shape)[col][row]` (r2's "fix") | FAILED (seed 43) | ok |
19+| `table(swap)[row][col]` | FAILED | FAILED |
20+| `table(swap)[col][row]` | FAILED | FAILED |
21+
22+So the offset read is NOT the defect: each variant only moves which rare corner position
23+desyncs. What is genuinely established (checked against the oracle source, not another
24+transcription): `av1_nz_map_ctx_offset_32x64` is a FLAT 1024-entry array whose `coeff_idx`
25+is COLUMN-major with stride 32 — entries 0..4 = 0,11,6,6,21 and 32..34 = 11,11,6 match
26+`txb_common.h:199-209`'s generating rule only as `flat[col * 32 + row]` — so the `cdf.rs`
27+5x5 transcriptions are `[col][row]`, while `base_ctx` indexes them `[row][col]` and is
28+green that way. The unproven quantity is therefore the ORIENTATION of `(row, col)` coming
29+out of the square 32x32-corner scan (`pos / side`, `pos % side` at `decode.rs:1583`)
30+relative to libaom's column-major `coeff_idx` — the `scan-weights-cross-axis` /
31+`reference-layout-not-spec` class. That is the next round's bisection.
54 32
55-Still refused (unchanged, not this round's): the below-16x16 `decode_leaf_rect` strip arms33+## State shipped on this branch (`89d4d59` + this commit)
56-(deferred(a below-16x16 strip gate — lane-sub8's territory)); the unreachable chroma shape34+
57-guard above (accepted, justified in place).35+KEPT from r2's WIP:
36+- `stream.rs` gates (a)/(b)/(c): per-attempt counter sampling — a feature-hit delta is
37+ folded in only after that attempt decoded AND pixel-compared, so hits from a stream that
38+ later refuses can no longer make a gate pass vacuously (ledger dead-end). Gate (b) also
39+ asserts the new `decode::rect_split_sb_interior_tu_hits` (`bw.max(bh)==64 && bw/tx>1 &&
40+ bh/tx>1` = SB-level AND tx depth >= 2), which is what the verifier asked for.
41+- Mismatch reporting: mismatching-sample count + bbox.
42+- `decode.rs:3248`: the chroma-shape refusal is documented UNREACHABLE with both callers
43+ wired and KEPT as the shape guard (without it a new strip size panics on `expect`
44+ instead of refusing by name); it stays in `refusal_inventory::REFUSALS`.
45+- Gate (c)'s stale "competitors disabled" comment replaced by the measured reason they
46+ cannot be (competitors off -> 0 rect strips; `--cq-level=25` is what fires filter intra).
47+- `decode::tests::nz_map_ctx_offset_tables_match_the_rect_rule` — pins the `[col][row]`
48+ packing of both rect tables against `base_ctx_rect`'s independently-written rule. It is
49+ TRUE about the transcription and deliberately contradicts `base_ctx`'s read; that
50+ contradiction is the open defect, spelled out in `base_ctx`'s comment.
51+- `examples/decode_probe.rs` raw-I420 dump (2nd arg); `EC_NZOFF_DUMP=1` prints every
52+ rect-shaped nz_map read; `EC_SBPART_DUMP64=1` prints split-tx strips.
53+
54+REVERTED by r3 (unsafe):
55+- `base_ctx` back to the r1 `[row][col]` read (`decode.rs:1162` comment now records the
56+ four-way measurement instead of r2's claim).
57+- `decode_block_rect64` refusal "a superblock-level HORZ/VERT strip with a split transform
58+ (per-unit rect prediction is not ported)" RESTORED, re-added to `refusal_inventory.rs`.
59+- Gate (b) `#[ignore]`d again with the r3 reason.
60+
61+## Refusals lifted this round: NONE.
58 62
59 ## Evidence63 ## Evidence
60 64
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=365+EVIDENCE: `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3 -- ...split_transform... ...superblock_level_horz_vert_partition... filter_intra_on_a_horz refusal_inventory gate_coverage nz_map_ctx_offset` on lane-rectsplit @ r3 final | 3 aomenc gates + the merged SB partition gate + inventory/coverage/table tests | 9 passed, 0 failed, 1 ignored (gate b), 53.77s
66+EVIDENCE: same command with `table[col][row]` (r2's WIP `bf53652`) | same gates | gate (b) ok (20/20 pixel-exact, SB-interior-TU delta=7), merged SB HORZ/VERT partition gate FAILED seed 43 — the regression that forced the revert
67+EVIDENCE: full `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` at r2's WIP state | whole crate lib | **270 passed, 1 failed, 23 ignored**, 1566.70s — the 1 failure is that merged gate. NOT re-run after the revert (turn cap): the reverted state restores r1's behaviour for every path plus one new unit test and one re-ignored gate, so 270 passed / 0 failed / 24 ignored is EXPECTED, not measured.
62 68
63 ## Film check (both films, 0.4s extracts)69 ## Film check (both films, 0.4s extracts)
64 70
65 ```71 ```
66-ffmpeg -v error -t 0.4 -i "<reelc.mkv>" -c:v copy -f obu reelc.obu # 418 bytes72+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 bytes73+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.obu74+decode_probe reelc.obu -> REFUSED: AV1 tile (a 32x32 partition type this decoder does not code (value=4))
69-REFUSED: unsupported: AV1 tile (a 32x32 partition type this decoder does not code (value=4))75+decode_probe hg.obu -> REFUSED: AV1 tile (a partition below 8x8 (this decoder codes no leaf smaller than 8x8))
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 ```76 ```
73 77
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 here78+EVIDENCE: scratchpad `reelc.obu` (418 B) / `hg.obu` (1817 B) | `ffmpeg -t 0.4 -c:v copy -f obu` then `cargo run -p ec-av1 --example decode_probe` on this branch | neither film stops at a refusal this lane owns
79+
80+## Residue
75 81
76-disposition: deferred(lane-sub8's below-8x8 leaf; the 32x32 value=4 AB-partition arm) — outside this lane.82+- fix-now(next round): the (row, col) orientation of the square 32x32-corner coefficient
83+ reader vs libaom's column-major `coeff_idx`. Repro both directions: seed 50 of gate (b)
84+ (`--ignored`) and seed 43 of the SB HORZ/VERT partition gate. Decisive instrument: msac
85+ RANGE ladder vs instrumented aomdec at the first differing coefficient of the 64x32 strip
86+ (r1 located it at luma (171,56), mi=(8,32)); `EC_NZOFF_DUMP=1` lists every candidate read.
87+- deferred(a below-16x16 strip gate — lane-sub8's territory): the `decode_leaf_rect` strip
88+ refusals.
89+- deferred(lane-sub8 / the 32x32 AB-partition arm): both films' first 0.4s.