Lane-palw report -- writer-side palette on-screen clamp, sweep tables
Browse files at this commitecec9a68c05244fb67dd81b1220758b64c9f53e3Parent: 254b908- docs
- lane-palw report -- writer-side palette on-screen clamp, sweep tables
1 changed file +107 -0
- lanes/palw.report.md +107 -0
lanes/palw.report.mdadded+107 -0
| @@ -0,0 +1,107 @@ | |||
| 1 | +# lane-palw — the palette colour-index map WRITTEN past the frame edge | ||
| 2 | + | ||
| 3 | +Class: **writer-phantom-units-past-edge** (previous instance: the residual | ||
| 4 | +transform-unit writer coding TUs past the right frame edge, lane-av1straddle). | ||
| 5 | +The reader half was lane-svtinter's `map-read-past-frame-edge`; this is its | ||
| 6 | +mirror on our own encoder. | ||
| 7 | + | ||
| 8 | +## Defect | ||
| 9 | + | ||
| 10 | +Spec 5.11.50 `palette_tokens` codes a block's colour-index map over its | ||
| 11 | +`onscreenWidth x onscreenHeight` corner ONLY and replicates the last on-screen | ||
| 12 | +column/row outward (detokenize.c:71). `tile::write_color_index_map` walked the | ||
| 13 | +full `side x side` grid, so every palette block our encoder coded straddling | ||
| 14 | +the frame's right/bottom mi edge carried symbols a conformant decoder never | ||
| 15 | +reads: libaom/dav1d/ffmpeg desync from that block on. Our own trial decode | ||
| 16 | +agreed with itself because `FrameCtx::for_encoder` never runs | ||
| 17 | +`set_segmentation`, so `decode::palette_onscreen` read `(0, 0)` mi dims and | ||
| 18 | +took the `corner-cut:` branch that mirrored the unclamped writer. | ||
| 19 | + | ||
| 20 | +## Fix (commit `16f7d271`) | ||
| 21 | + | ||
| 22 | +* `encode.rs` (both frame encoders, beside their `true_width`/`true_height`): | ||
| 23 | + publish the header's `(mi_rows, mi_cols)` onto the encoder's `FrameCtx` and | ||
| 24 | + arm them on every tile writer (`tile::arm_frame_mi_dims`, beside | ||
| 25 | + `arm_screen`). | ||
| 26 | +* `encode.rs` palette search, luma and chroma: the searched map is folded to | ||
| 27 | + the on-screen corner through the decoder's own | ||
| 28 | + `decode::palette_replicate` before it is priced, predicted from and | ||
| 29 | + committed -- so the map priced, the map reconstructed and the map written | ||
| 30 | + are one map. The colour search itself still runs over the full block. | ||
| 31 | +* `tile.rs`: `write_color_index_map` takes `(onscreenWidth, onscreenHeight)` | ||
| 32 | + and walks the wavefront over that corner at the full-block stride; | ||
| 33 | + `palette_bits`/`palette_uv_bits` price the same corner; | ||
| 34 | + `write_palette_syntax` derives it with `decode::palette_onscreen_dims` (the | ||
| 35 | + reader's own function) and `decode::palette_onscreen_uv` for chroma. | ||
| 36 | + Counter `palette_cut_maps_written()`. | ||
| 37 | +* `decode.rs`: the `corner-cut:` mirror-the-writer branch is GONE -- both | ||
| 38 | + sides now clamp everywhere. `palette_onscreen_dims`/`palette_replicate` are | ||
| 39 | + shared by the two sides so they cannot drift. | ||
| 40 | + | ||
| 41 | +## Witness | ||
| 42 | + | ||
| 43 | +`encoder::tests::a_palette_block_cut_by_the_frame_edge_decodes_exactly_through_ffmpeg` | ||
| 44 | +(encoder.rs). Drives the ENTRY SURFACE (`Av1Encoder`, what the editor's export | ||
| 45 | +calls) on a 384x152 8-px two-tone screen card: 152 rows = 38 mi, so the bottom | ||
| 46 | +superblock row's 16x16 blocks at y=144 and 32x32 blocks at y=128 hang off the | ||
| 47 | +mi grid. Asserts `tile::palette_cut_maps_written() > 0` (12 here), decodes | ||
| 48 | +through `decode_stream` AND ffmpeg and compares EVERY plane of every frame. | ||
| 49 | + | ||
| 50 | +* RED (`write_color_index_map` forced back to the full grid, everything else | ||
| 51 | + as shipped): `our decoder: Unsupported { what: "AV1 tile", why: "a Golomb | ||
| 52 | + tail longer than this decoder reads" }` -- `test result: FAILED. 0 passed; | ||
| 53 | + 1 failed`. | ||
| 54 | +* GREEN: `test result: ok. 1 passed`, `12 cut colour-index maps written`. | ||
| 55 | + | ||
| 56 | +`screen_card`'s 4-px bands were tried first and fire 9 palettes, NONE of them | ||
| 57 | +cut (`cut 0`) -- the row would have passed blind (class gate-blind-to-feature), | ||
| 58 | +which is what the counter assert catches. | ||
| 59 | + | ||
| 60 | +## Conformance sweep (our encoder -> ffmpeg, all three planes, 3 frames) | ||
| 61 | + | ||
| 62 | +Two screen sources, four sizes whose mi grid cuts blocks, two quantizers. | ||
| 63 | +`cut maps` is `palette_cut_maps_written()` for that point: every row really | ||
| 64 | +exercises the fixed path. | ||
| 65 | + | ||
| 66 | +Checkerboard card (8-px two-tone): | ||
| 67 | + | ||
| 68 | +| size | q | bytes | cut maps | ours vs ffmpeg | | ||
| 69 | +|---|---|---|---|---| | ||
| 70 | +| 384x152 | 60 | 286 | 12 | EXACT | | ||
| 71 | +| 384x152 | 150 | 288 | 12 | EXACT | | ||
| 72 | +| 320x184 | 60 | 256 | 5 | EXACT | | ||
| 73 | +| 320x184 | 150 | 257 | 5 | EXACT | | ||
| 74 | +| 640x366 | 60 | 706 | 10 | EXACT | | ||
| 75 | +| 640x366 | 150 | 707 | 10 | EXACT | | ||
| 76 | +| 1000x562 | 60 | 1499 | 24 | EXACT | | ||
| 77 | +| 1000x562 | 150 | 1500 | 24 | EXACT | | ||
| 78 | + | ||
| 79 | +`smptebars=s=WxH,drawgrid=w=8:h=8:t=1:c=black` (lavfi): | ||
| 80 | + | ||
| 81 | +| size | q | bytes | cut maps | ours vs ffmpeg | | ||
| 82 | +|---|---|---|---|---| | ||
| 83 | +| 384x152 | 60 | 1398 | 2 | EXACT | | ||
| 84 | +| 384x152 | 150 | 1397 | 6 | EXACT | | ||
| 85 | +| 320x184 | 60 | 1488 | 1 | EXACT | | ||
| 86 | +| 320x184 | 150 | 1406 | 2 | EXACT | | ||
| 87 | +| 640x366 | 60 | 2708 | 2 | EXACT | | ||
| 88 | +| 640x366 | 150 | 2596 | 0 | EXACT | | ||
| 89 | +| 1000x562 | 60 | 3924 | 6 | EXACT | | ||
| 90 | +| 1000x562 | 150 | 3731 | 2 | EXACT | | ||
| 91 | + | ||
| 92 | +Before the fix, the same recipe refuses (the RED run above is 384x152 of the | ||
| 93 | +first table). | ||
| 94 | + | ||
| 95 | +## Same-shape sweep, WRITER side | ||
| 96 | + | ||
| 97 | +Every per-cell syntax family this writer emits, at a block cut by the mi grid: | ||
| 98 | + | ||
| 99 | +| family | writer site | state | | ||
| 100 | +|---|---|---| | ||
| 101 | +| palette colour-index map, luma + chroma | tile.rs `write_color_index_map` | **fixed here** | | ||
| 102 | +| residual transform units, luma | tile.rs:4367 `tu_mi.0 >= neighbours.mi_rows \|\| tu_mi.1 >= neighbours.mi_cols` | clipped (lane-av1straddle) | | ||
| 103 | +| residual transform units, chroma | tile.rs:2612 `bound_h`/`bound_w` with libaom's `ROUND_POWER_OF_TWO` round-up | clipped | | ||
| 104 | +| var-tx split units | tile.rs:4520 -- the encoder only picks depth 1 for a block wholly inside the frame, `debug_assert`ed per unit | clipped | | ||
| 105 | +| partition | tile.rs:184 / 2972 / 3052 `has_cols`/`has_rows` inferred split at 128, 64 and 32 | clipped | | ||
| 106 | +| segment ids | none: this encoder writes no segmentation map (`write_segment_id` exists only in decode.rs) | n/a | | ||
| 107 | +| CfL, intrabc | one alpha pair / one vector per block, no per-cell loop | n/a | | ||