# lane-kf900 r4 report -- rect-strip palette reconstruction ## What changed (all in `crates/ec-av1/`) | path:line (post-change) | why | | --- | --- | | `src/decode.rs` `Neighbours::palette_ctx_and_cache_mi` / `palette_uv_cache_mi` | `av1_get_palette_cache` drops the above neighbour on a 64-px SB boundary keyed on the block's own PIXEL row (`pred_common.c:76`). The old code read `at.0 % 4` off the 16-px `SUB` cell, so strip 1 of a HORZ_4 (8 px into the cell) wrongly excluded strip 0 from its cache in every SB-top cell row. Old entry points kept, delegating. | | `src/decode.rs` `read_intra_mode_rect`, chroma colour-index map | the map is `av1_get_plane_block_size(bsize,1,1)` (`ss_size_lookup`), not a plain halving: BLOCK_16X4 -> BLOCK_8X4, BLOCK_4X16 -> BLOCK_4X8. `(bw/2, bh/2)` read HALF the colour-index symbols of a 1:4 strip's chroma palette. Now `((bw/2).max(4), (bh/2).max(4))`. | | `src/decode.rs` `record_strip_palette` (new) | the coarse `SUB`-cell palette arrays alias all four strips of a HORZ_4/VERT_4 (and both leaves of a 16x8/8x16 pair) onto one entry, so stamping BOTH axes after every strip hands strip i+1 strip i's colours on the WRONG axis too. Writes the split axis until the closing strip, both on it. | | `src/decode.rs` `decode_block_rect4` (32x8/8x32) | was `palette: None, &[]` -> real ctx + cache; palette-Y/UV prediction wired into the split-tx walk (`RectStripModes`), the coded arm and the skip arm; palette state stamped on all three exits. Refusal dropped. | | `src/decode.rs` `decode_rect4_16` (16x4/4x16) | same, per strip, incl. the inlined per-TU split walk (window of the block's palette buffer per unit) and the pair's chroma. Refusal dropped. | | `src/decode.rs` `decode_leaf_rect` (16x8/8x16) | sibling refusal "a palette block on a HORZ/VERT intra strip below 16x16" dropped the same way; its zero-clear of the palette arrays became `record_strip_palette`, which also fixes leaf 0 of a pair zeroing the LEFT entry leaf 1 legitimately reads. | | `src/decode.rs` `RECT4_PALETTE_HITS` / `rect4_palette_hits()` | the gate's counter: rect intra strips that ACTUALLY use a palette. | | `src/refusal_inventory.rs` | both lifted strings removed (47 -> 45). | | `src/stream.rs` `a_real_aomenc_rect_strip_palette_decodes_pixel_exact` | the gate. | libaom sites cited: `decodemv.c` `read_palette_mode_info` (`av1_allow_palette`, `av1_get_palette_bsize_ctx`, `av1_get_palette_mode_ctx`), `read_palette_colors_y` (`decodemv.c:478`) / `read_palette_colors_uv` (`:509`), `pred_common.c:73` `av1_get_palette_cache`, `decodeframe.c` `decode_color_map_tokens` via `av1_visit_palette` (map read AFTER all mode info -- unchanged, already correct here). ## Refusals lifted (2) 1. `a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)` 2. `a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)` ## Gate `crates/ec-av1/src/stream.rs::a_real_aomenc_rect_strip_palette_decodes_pixel_exact` 3 arms x 2 depths. Arm 0 IS the r3 pinned stream: `testsrc2=s=256x192:r=25`, `--cq-level=59 --cpu-used=0 --lag-in-frames=0 --kf-max-dist=1 --limit=1 --threads=1 --tile-columns=0 --enable-tx-size-search=1 --min-partition-size=8 --enable-rect-partitions=1`, and the encoder invocation inside the test reproduces md5 `e5f033d8fe34e4418d8cca3ac9d2b595` byte for byte at 10-bit. Arms 1-2 add `--tune-content=screen --enable-palette=1 --enable-1to4-partitions=1 --min-partition-size=8` on testsrc2 / smptebars. Every decode-order frame, all three planes, compared against ffmpeg's decode of the identical bytes. Hard asserts: a rect-strip palette block fired (`rect4_palette_hits()` delta), `out_of_scope_mismatch == 0`, sources render byte-identical twice. A NAMED (`unsupported`) refusal is counted and printed, never a pass. ``` cargo test -p ec-av1 --lib a_real_aomenc_rect_strip_palette_decodes_pixel_exact -- --nocapture ``` EVIDENCE: $HOME/.cache/kf900/sweep/g.obu + gate stdout | aomenc pinned recipe -> decode_stream -> ffmpeg compare, 3 arms x {8,10} bit | 2 attempts with a rect-strip palette block, both whole-frame pixel-exact (Y+U+V), 0 out-of-scope mismatches, 4 named refusals on other shapes, md5 of the test's own 10-bit arm-0 stream == e5f033d8fe34e4418d8cca3ac9d2b595 EVIDENCE: decode_probe on $HOME/.cache/kf900/sweep/g.obu | before/after this commit | `REFUSED: ... a 1:4 rect strip that actually uses a palette` -> `OK: 1 frames decoded, 256x192`, rect4_32 horz=8 vert=0 -> horz=12 vert=16 ## Corrected premises (both stated as fact in the charter/handoff) - **`skip_split_tx` does NOT fire on the pinned stream.** `decode_probe` on the fully decoded stream prints `skip_split_tx: 0`. The r3 handoff's "fires skip_split_tx AND reaches that refusal" is half wrong, so the gate asserts the palette counter and does not assert `skip_split_tx`; asserting it would have been a vacuous/failing gate. - **64x16/16x64 needed no work.** `decode_block_rect64` already passes the real ctx/cache and reconstructs palette; its only palette refusal is the separate corner-cropped-luma one. ## Open residue - **deferred(8-bit rect-strip palette coverage)** -- `fired 8-bit=0, 10-bit=2`. At 8 bit aomenc puts its palettes on SQUARE blocks; every 8-bit recipe tried that reaches a rect strip with a palette lands on a shape still out of scope (`a block that actually uses a palette (Y)` on an 8x8 square leaf, or `a palette block with a real transform on a superblock-level HORZ/VERT strip`). Unblocked by lifting either of those two refusals. The 8-bit arms still run and prove the decode path; the counter is printed, not hidden. - **fix-now-elsewhere: a NEW pre-existing 8-bit 1:4 pixel mismatch, unrelated to palette.** Recipe: `testsrc2=s=256x192:r=25`, 8-bit, base recipe above plus `--tune-content=screen --enable-palette=1 --enable-1to4-partitions=1 --max-partition-size=32 --sb-size=64`. Decodes `OK: 1 frames decoded` with `rect4_32: horz=8 vert=8 coded=16` and frame 0 differs from ffmpeg. Proved unrelated to this round: the stream reads ZERO palette symbols (`EC_AV1_TRACE=1 decode_probe | grep -c "^EC_PAL "` == 0), so every change in this commit is inert on it. Needs its own lane. - **accepted**: `a palette block with a real transform on a superblock-level HORZ/VERT strip` and `a block that actually uses a palette (Y/UV)` (8x8 square leaf) remain -- out of this lane's charter (both are square/SB-level, not rect strips).