Lane-sbpart r8 report -- root cause + fix landed, gate pixel-exact
Browse files at this commit98000ad6cccd51d5d823b3773a2d76eba91fb5a0Parent: db23f4b- docs
- lane-sbpart r8 report -- root cause + fix landed, gate pixel-exact
1 changed file +94 -0
- lanes/sbpart-r8.report.md +94 -0
lanes/sbpart-r8.report.mdadded+94 -0
| @@ -0,0 +1,94 @@ | |||
| 1 | +VERDICT: PASS -- fixed, gate pixel-exact, committed d64ad23 | ||
| 2 | + | ||
| 3 | +## Order 1: TxbSet::Luma64 CDF-set resolution | ||
| 4 | + | ||
| 5 | +Checked libaom `get_txsize_entropy_ctx(TX_32X64)` against `txsize_sqr_map`/ | ||
| 6 | +`txsize_sqr_up_map` (`common_data.h`): `(TX_32X32 + TX_64X64 + 1) >> 1 = | ||
| 7 | +TX_64X64`. Matches this decoder's `TxbSet::Luma64` (used for both the plain | ||
| 8 | +64x64 and the superblock-strip 32x64/64x32 corner). **CDF-set selection is | ||
| 9 | +correct** -- ruled in as clean, per the charter's own "only if that matches" | ||
| 10 | +gate to move on. | ||
| 11 | + | ||
| 12 | +## Root cause: not base_ctx's neighbour math, but its position-offset table | ||
| 13 | + | ||
| 14 | +libaom's `read_coeffs_txb` (`decodetxb.c`) passes the **raw, un-adjusted** | ||
| 15 | +`tx_size` (`TX_32X64`/`TX_64X32`, not the corner-cropped `TX_32X32`) into | ||
| 16 | +`get_scan`/`get_lower_levels_ctx`. `get_scan` resolves to the same | ||
| 17 | +`default_scan_32x32` either way (checked `scan.c`, comment: "half of the | ||
| 18 | +coefficients of tx64 at higher frequencies are set to zeros, so tx32's scan | ||
| 19 | +order is used") -- that part this decoder already had right. But | ||
| 20 | +`get_nz_map_ctx_from_stats` (`txb_common.h`) separately indexes | ||
| 21 | +`av1_nz_map_ctx_offset[tx_size][coeff_idx]` by that same raw tx_size, and | ||
| 22 | +`av1_nz_map_ctx_offset_32x64`/`_64x32` (`txb_common.c`) are **distinct | ||
| 23 | +tables** from the square `av1_nz_map_ctx_offset_32x32` one -- e.g. at | ||
| 24 | +`(row=1, col=0)` the square table gives offset 1, the 32x64 (width<height) | ||
| 25 | +table gives offset 11. This decoder's `base_ctx` always used the square | ||
| 26 | +`NZ_MAP_CTX_OFFSET_32` table, regardless of the true block shape, for every | ||
| 27 | +`read_coeffs` caller including `decode_block_rect64`'s truncated-corner | ||
| 28 | +luma read -- exactly the symptom r7 pinned (same range in, wrong symbol | ||
| 29 | +out, no earlier desync). | ||
| 30 | + | ||
| 31 | +This decoder already has the *right pattern* for this, just not wired to | ||
| 32 | +the >32 corner case: `base_ctx_rect` (lane-rectwire, used by | ||
| 33 | +`decode_block_rect`'s 32x16/16x32 strips) implements the same `w<h`/`w>h` | ||
| 34 | +branch libaom's own doc comment names. It couldn't be reused directly here | ||
| 35 | +because its `neighbour_rect` indexes the grid by the *true* `w`/`h` | ||
| 36 | +(64/32), but the truncated-corner grid is genuinely only 32x32 -- reusing it | ||
| 37 | +would break the neighbour bounds. Verified the two real libaom tables | ||
| 38 | +(`av1_nz_map_ctx_offset_32x64`/`_64x32`) reduce to the same `row.min(4)`/ | ||
| 39 | +`col.min(4)` 5x5-clamp pattern `NZ_MAP_CTX_OFFSET_32` already uses (checked | ||
| 40 | +programmatically against all 1024 entries of both tables), so added them as | ||
| 41 | +plain 5x5 consts instead of trying to force-fit `base_ctx_rect`'s neighbour | ||
| 42 | +function onto a 32-wide grid. | ||
| 43 | + | ||
| 44 | +## Fix | ||
| 45 | + | ||
| 46 | +- `cdf.rs`: added `NZ_MAP_CTX_OFFSET_32X64`/`NZ_MAP_CTX_OFFSET_64X32` | ||
| 47 | + (verified against libaom's real tables, not the approximate row/col<2 | ||
| 48 | + formula in its comment -- that formula does not actually reproduce every | ||
| 49 | + cell, e.g. `(row=0, col=2)` is 6 in the real 32x64 table, not the naive | ||
| 50 | + ctx+11 the row<2 branch alone would give). | ||
| 51 | +- `decode.rs`: `base_ctx` gained a `rect_shape: Option<(usize, usize)>` | ||
| 52 | + parameter, used only for `TxClass::TwoD` to pick the matching table | ||
| 53 | + (`w<h` -> 32x64, `w>h` -> 64x32, else/`None` -> square). Threaded through | ||
| 54 | + `read_coeffs` (`rect_shape` param, doc'd). All three `read_coeffs` | ||
| 55 | + callers updated: `decode_block_rect64`'s luma corner passes | ||
| 56 | + `Some((bw, bh))` (the real, un-adjusted strip shape); `decode_block`'s | ||
| 57 | + own 64x64 corner and the inter path pass `None` (genuinely square). | ||
| 58 | + | ||
| 59 | +## Gate result | ||
| 60 | + | ||
| 61 | +``` | ||
| 62 | +EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib \ | ||
| 63 | + a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact \ | ||
| 64 | + -- --nocapture | ||
| 65 | +``` | ||
| 66 | +Before this round: 0/40 pixel-exact, mismatches on every attempt that | ||
| 67 | +reached a block2-shaped luma read. After: **15/40 pixel-exact matches, 25 | ||
| 68 | +named refusals (unrelated partition/palette/Golomb capability gaps, not this | ||
| 69 | +defect), 0 pixel mismatches, `sb_rect_hits=36`** -- hard pass. | ||
| 70 | + | ||
| 71 | +## Ruled out (per charter, not revisited) | ||
| 72 | + | ||
| 73 | +`around_rect`, the CDEF per-SB guard, the reconstruction theory. | ||
| 74 | + | ||
| 75 | +## Not attempted | ||
| 76 | + | ||
| 77 | +Stage 2 (32x32 `part32`) and the inter path, per the charter's explicit | ||
| 78 | +"do not start" instruction. The same class (offset table indexed by raw vs | ||
| 79 | +adjusted tx_size) could in principle recur wherever a >32 transform corner | ||
| 80 | +is truncated elsewhere in this codebase, but the only other truncation site | ||
| 81 | +(`decode_block`'s plain 64x64) is genuinely square, so it does not need this | ||
| 82 | +fix -- swept by inspection (both non-`decode_block_rect64` `read_coeffs` | ||
| 83 | +call sites checked and confirmed square, see above). | ||
| 84 | + | ||
| 85 | +## Hard rules followed | ||
| 86 | + | ||
| 87 | +Worked only in this worktree; `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sbpart` | ||
| 88 | +every build; foreground `nice -n 19 cargo ... -j4`; `EC_AV1_REQUIRE_AOMENC=1` | ||
| 89 | +on the gate; aomenc recipe unchanged/inherited (`--threads=1 --row-mt=0 | ||
| 90 | +--sb-size=64 --enable-tx-size-search=0`); read-only use of the shared | ||
| 91 | +`~/.cache/aom-oracle` source tree (no rebuild, no patch left behind -- this | ||
| 92 | +round needed only to read existing libaom `.c`/`.h` source, not to | ||
| 93 | +instrument aomdec further); no other worktree touched; no push, no merge | ||
| 94 | +into main. | ||