report(av1): lane-palette r6 -- bisect closed, root cause pinned (UV palette mode_info skipped, index-map call site wrong), fix deferred to r7
Browse files at this commitb07f07aeecbefcfa032bccd431e82dd62a52ac44Parent: f62adbf1 changed file +155 -0
- lanes/palette-r6.report.md +155 -0
lanes/palette-r6.report.mdadded+155 -0
| @@ -0,0 +1,155 @@ | ||
| 1 | +# lane-palette r6 report | |
| 2 | + | |
| 3 | +VERDICT: PARTIAL -- the bisect the charter asked for is done and the root | |
| 4 | +cause is pinned exactly; the fix itself (reorder + UV palette mode_info | |
| 5 | +reads) is not implemented this round, so the refusal stays and no gate | |
| 6 | +was flipped to pixel-exact. | |
| 7 | + | |
| 8 | +## The bisect (committed 7485651) | |
| 9 | + | |
| 10 | +Added the matching `EC_AV1_TRACE`-gated `EC_PAL row=.. col=.. ctx=.. n=.. rng=..` | |
| 11 | +/ `EC_PAL_VAL row=.. col=.. color_idx=.. rng=..` print inside our own | |
| 12 | +`decode_color_index_map` (`crates/ec-av1/src/decode.rs` ~2370, matching | |
| 13 | +r4's oracle rung field-for-field), plus `TRACE pre_palette_y_mode` / | |
| 14 | +`palette_y_mode` / `palette_y_size` / `palette_y_colors` prints around | |
| 15 | +the Y palette-mode-info reads just above it (~3010-3024). | |
| 16 | + | |
| 17 | +Regenerated the r3/r4 gate's exact fixture once (`ffmpeg smptebars | |
| 18 | +size=64x64:rate=25` piped through `hue=s=0`, then the gate's pinned | |
| 19 | +`aomenc` recipe -- byte-identical across two ffmpeg runs, saved to | |
| 20 | +`/tmp/.../scratchpad/palette/out.obu`, 112 bytes) and ran both traces | |
| 21 | +against the identical bytes: | |
| 22 | + | |
| 23 | +- `aomdec EC_TRACE_PALETTE=1` (r4's existing rungs 6/6b) | |
| 24 | +- our own decoder via a throwaway `#[ignore]` test reading | |
| 25 | + `EC_AV1_SCRATCH_FILE` and calling `decode_stream` with `EC_AV1_TRACE=1` | |
| 26 | + (not committed -- removed after use, see below) | |
| 27 | + | |
| 28 | +**Range compare, per `compare-range-not-tell`:** every symbol up through | |
| 29 | +the Y palette colours is bit-identical between the two decoders for the | |
| 30 | +frame's first (top-left, mi=(0,0)) block: | |
| 31 | + | |
| 32 | +| point | oracle rng | ours rng | | |
| 33 | +|---|---|---| | |
| 34 | +| partition_w32(0,0) read | 58370 | 58370 | | |
| 35 | +| entering `read_palette_mode_info` (post skip/y_mode/uv_mode) | 34206 | 34206 | | |
| 36 | +| after `palette_y_mode` symbol (value=1) | 60032 | 60032 | | |
| 37 | +| after `palette_y_size` symbol (n=4) | 39344 | 39344 | | |
| 38 | +| after `read_palette_colors_y` (colours `[112,131,162,180]`) | 39432 | 39432 | | |
| 39 | +| `decode_color_map_tokens` / our `decode_color_index_map` **entry** | **51752** | **39432** | | |
| 40 | + | |
| 41 | +Ranges match to the byte through the Y colour read, then diverge exactly | |
| 42 | +at the point our `decode_color_index_map` is called. **Per the charter's | |
| 43 | +own steer this rules out a table/context bug in the map reader itself** | |
| 44 | +(r3 already audited those tables and this round's range trace confirms | |
| 45 | +it end to end) **and confirms the bug is positional, not a read bug**. | |
| 46 | + | |
| 47 | +## Root cause: `decode_color_index_map` is called from the wrong syntax position | |
| 48 | + | |
| 49 | +Traced why the oracle's rng jumps from 39432 (after Y colours) to 51752 | |
| 50 | +(entering the color-index-map) with no observable step in between on our | |
| 51 | +side: `libaom`'s `decode_color_map_tokens` is **not** called inline from | |
| 52 | +`read_palette_mode_info`. It runs later, from `parse_decode_block` | |
| 53 | +(`decodeframe.c:1135`, `av1_visit_palette(pbi, xd, r, | |
| 54 | +av1_decode_palette_tokens)`), called right after `decode_mbmi_block` | |
| 55 | +returns -- i.e. after the *entire* mode-info read for the block, | |
| 56 | +including **UV palette mode_info** (`read_palette_mode_info`'s own | |
| 57 | +second half: `palette_uv_mode_cdf` / `palette_uv_size_cdf` / | |
| 58 | +`read_palette_colors_uv`, gated on `uv_mode == UV_DC_PRED && | |
| 59 | +is_chroma_ref`) and `read_filter_intra_mode_info`. Confirmed live by | |
| 60 | +patching a throwaway `EC_PRE_PALETTE` / `EC_PALETTE_Y_MODE` / | |
| 61 | +`EC_PALETTE_Y_SIZE` / `EC_PALETTE_Y_COLORS` print into the oracle's | |
| 62 | +`decodemv.c` (rebuilt aomdec, ran the trace, matched ours field-for-field | |
| 63 | +through `EC_PALETTE_Y_COLORS rng=39432`, then confirmed | |
| 64 | +`read_palette_mode_info` returns and control passes to | |
| 65 | +`av1_visit_palette` before `decode_color_map_tokens` runs) -- **reverted | |
| 66 | +this patch after use** (`git diff --stat` on `~/.cache/aom-oracle/src` | |
| 67 | +clean of it, `ninja aomdec` rebuilt back to the pre-patch binary) since | |
| 68 | +that oracle checkout is shared with sibling lanes and the charter forbids | |
| 69 | +touching sibling worktrees; this diagnostic lived entirely outside this | |
| 70 | +repo and is not committed here. | |
| 71 | + | |
| 72 | +This gate's block has `uv_mode=0` (`UV_DC_PRED`) and is chroma-referenced | |
| 73 | +(32x32 luma with 4:2:0 subsampling is a real chroma block), so the | |
| 74 | +oracle genuinely reads a `palette_uv_mode` symbol (and, since it's a | |
| 75 | +binary CDF, possibly `palette_uv_size` + `read_palette_colors_uv` too) | |
| 76 | +between the Y colours and the color-index-map read -- bits our decoder | |
| 77 | +never consumes at all. Our `decode_color_index_map(dec, cdfs, n, side)` | |
| 78 | +call sits immediately after `read_palette_colors_y` inside the Y-palette | |
| 79 | +branch (`decode.rs` ~3023), which is wrong on two counts: (1) it skips | |
| 80 | +UV palette mode_info entirely when the block is chroma-referenced and | |
| 81 | +UV-DC, and (2) even where UV genuinely isn't read (monochrome / not | |
| 82 | +chroma-referenced / UV mode != DC), libaom still defers the color-index | |
| 83 | +map to a separate post-mode-info pass (after `filter_intra`), not inline. | |
| 84 | + | |
| 85 | +## What this closes, what it doesn't | |
| 86 | + | |
| 87 | +r3's table audit + this round's range trace together give a decisive | |
| 88 | +answer per `worker-cap-spent-reading`/`compare-range-not-tell`: **every | |
| 89 | +table this lane touches is exact**; the bug is 100% a call-site ordering | |
| 90 | +bug, not a CDF/context bug, so no more table re-reading is owed here. | |
| 91 | + | |
| 92 | +**Not done this round (next round's job):** the actual reorder fix -- | |
| 93 | +read (and, per the "Then" milestone, eventually reconstruct) UV palette | |
| 94 | +mode_info in `read_intra_mode`'s palette branch right after the Y | |
| 95 | +colours, then move both the Y and UV `decode_color_index_map` calls to | |
| 96 | +run after `filter_intra` is read, matching `parse_decode_block`'s real | |
| 97 | +call order. That is squarely the charter's "Then" milestone ("Palette | |
| 98 | +UV") arriving earlier than expected -- it turns out UV support isn't a | |
| 99 | +separate later feature, it's a hard prerequisite for Y's own bits to stay | |
| 100 | +synced whenever the block is chroma-referenced with UV_DC_PRED. The | |
| 101 | +refusal (`"a block that actually uses a palette (Y) -- the index map | |
| 102 | +decodes but the reconstructed pixels do not match libaom yet | |
| 103 | +(lane-palette r3/r4)"`) stays exactly as-is; removing it before the | |
| 104 | +reorder + UV-read fix lands would ship a real desync as a "decode", | |
| 105 | +which the charter explicitly forbids ("remove the refusal only in the | |
| 106 | +same commit as the gate that proves pixel exactness"). | |
| 107 | + | |
| 108 | +## Refusal strings | |
| 109 | + | |
| 110 | +None added, none removed, none reworded this round. | |
| 111 | + | |
| 112 | +## Check | |
| 113 | + | |
| 114 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j4` (timeout | |
| 115 | +600000ms, ran ~122s): **244 passed, 0 failed, 17 ignored** -- unchanged | |
| 116 | +from r5's baseline. `cargo build -p ec-av1 --tests -j4`: clean, no new | |
| 117 | +warnings from the trace additions. | |
| 118 | + | |
| 119 | +## Handoff for the next round | |
| 120 | + | |
| 121 | +1. In `read_intra_mode`'s palette branch (`decode.rs` ~3010-3024), right | |
| 122 | + after `read_palette_colors_y`, add the UV palette mode_info read: | |
| 123 | + `if num_planes > 1 && uv_mode == UV_DC_PRED (0) && is_chroma_ref { read | |
| 124 | + palette_uv_mode symbol; if set, palette_uv_size + palette colours (UV, | |
| 125 | + two channels) }` -- needs a `palette_uv_mode_cdf` / `palette_uv_size_cdf` | |
| 126 | + pair and a `read_palette_colors_uv` port (`decodemv.c` `read_palette_colors_uv`, | |
| 127 | + not yet ported -- check `cdf.rs` for whether the UV CDF tables already | |
| 128 | + exist before writing new ones). `is_chroma_ref` needs threading in if | |
| 129 | + it isn't already available at this call site. | |
| 130 | +2. Move both the Y (`decode_color_index_map(dec, cdfs, n, side)`, luma | |
| 131 | + plane) and the new UV color-index-map read to run *after* | |
| 132 | + `filter_intra` is read, not inline in the palette branch -- matching | |
| 133 | + `parse_decode_block`'s `decode_mbmi_block` (all mode info) then | |
| 134 | + `av1_visit_palette` (both planes' index maps) order. This likely means | |
| 135 | + restructuring `read_intra_mode`'s return type to carry the *undecoded* | |
| 136 | + palette colours/size out, with the actual `decode_color_index_map` | |
| 137 | + call(s) moved to the caller, after the `filter_intra` result is known. | |
| 138 | +3. Once reordered, rerun this round's exact trace recipe (`out.obu` in | |
| 139 | + the scratchpad, or regenerate -- see r3/r4/r6 for the recipe) with both | |
| 140 | + `EC_AV1_TRACE=1` on ours and (temporarily re-patching, then reverting, | |
| 141 | + the same 3 oracle `decodemv.c` prints this round used) to confirm the | |
| 142 | + ranges now match all the way to the end of the Y (and UV) color-index | |
| 143 | + maps before flipping the gate from "refuses by name" back to "decodes | |
| 144 | + pixel exact" and removing the refusal, in the same commit as the gate | |
| 145 | + flip, per charter. | |
| 146 | +4. The `palette_bsize_ctx` rect-strip refusal and `enable-intrabc` are | |
| 147 | + still fully unstarted (r4's original "Then" list) -- UV palette turned | |
| 148 | + out to be a hard prerequisite of Y, so it should stay first in line | |
| 149 | + next round rather than being deferred again. | |
| 150 | + | |
| 151 | +`deferred: the reorder fix + UV palette mode_info port -- root cause | |
| 152 | +pinned this round via a decisive range trace (compare-range-not-tell), | |
| 153 | +implementation not started, next round's first job.` | |
| 154 | +`deferred: palette_bsize_ctx rect-strip refusal, intrabc -- unstarted, | |
| 155 | +all budget went to the bisect + root-cause confirmation this round.` |