edith_codecs
Clone
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
lane-palette — palette reconstruction, then intra block copy
Worktree /home/user/Documents/Code/Rust/edith_codecs-palette, branch
lane-palette, off main (c4904ee or later).
Goal
Two of the five coding tools that no gate in this repository exercises
(main's crates/ec-av1/src/gate_coverage.rs pins the set) are palette and
intrabc. Both have their syntax consumed and both refuse the moment a block
actually uses them. Make them decode.
Where the refusals are
- Palette, key-frame reader —
crates/ec-av1/src/decode.rs:2484-2494:"a block that actually uses a palette (Y) -- reconstruction is out of scope"and the(UV)twin. Thepalette_y_mode/palette_uv_modesymbols ARE read; only a nonzero size refuses. - Palette, inter-frame intra-block reader —
decode.rs:7795-7805, the same two strings. Note the comment there:palette_mode_ctx/palette_uv_mode_ctxare hardcoded 0, which is only safe while a nonzero neighbourpalette_sizeis impossible. The moment palette blocks decode, those contexts become live —av1_get_palette_mode_ctx(pred_common.h) reads the neighbours' ownpalette_size[0] > 0. Classcontext-read-from-one-cellandcdf-row-held-constantboth apply: fix the context in the SAME round that removes the refusal, or the gate will desync in a way that looks like a table bug. - Intrabc —
decode.rs:2408-2416:"a block that actually uses intrabc (this decoder never reconstructs one)". - Also
decode.rs:1940-1947: a HORZ/VERT intra strip in a screen-content frame refuses becausepalette_bsize_ctxis keyed on a single side. That refusal is in scope for stage 3.
Anchors
- Spec 5.11.13
palette_mode_info, 5.11.46palette_tokens, 5.11.50get_palette_cache, 7.11.4palette prediction process; 5.11.13read_intrabc_info, 6.10.19, 7.11.3.x for the intrabc MV rules. - libaom, source tree under
~/.cache/aom-oracle:av1/decoder/decodemv.cread_palette_mode_info(line ~567),read_palette_colors_y/read_palette_colors_uv, and the delta-coded colour reads;av1/common/pred_common.hav1_get_palette_mode_ctxandav1_get_palette_bsize_ctx;av1/decoder/decodetxb.c/av1/common/blockd.hfor the colour index map;av1_get_palette_cache(av1/common/reconintra.c) for the above/left colour cache;read_intrabc_info(decodemv.c ~693) andav1_find_ref_dvfor intrabc's forced DV predictor and its validity bounds. crates/ec-av1/src/cdf_state.rs:425-433already carriespalette_y_mode,palette_y_size,palette_uv_mode,palette_uv_sizewith defaults and counter resets. The colour-index-map CDFs (palette_y_color_index/palette_uv_color_index, indexed by palette size and a neighbour context) are NOT there — adding them is four wiring sites: struct field, defaults array, save/restore, per-frame counter reset (cdf_state.rsreset2/reset3are length-generic and save/restore is a whole-struct Clone, so the defaults array is what needs hand-checking; still verify the counter reset covers the new tables — classcdf-counter-not-reset).
Staging — COMMIT AFTER EVERY GREEN MILESTONE
- Palette Y. Colour cache from the above/left neighbours, delta-coded
colours, the colour index map (wavefront diagonal scan, the
palette_color_indexsymbol per pixel with its neighbour context), and reconstruction. Fixpalette_mode_ctx/palette_uv_mode_ctxto read the neighbours' real palette sizes in this same commit. COMMIT. - Palette UV. COMMIT.
- The rect-strip refusal at decode.rs:1940 — key
palette_bsize_ctxon both sides the wayav1_get_palette_bsize_ctxdoes (num_pels_log2_lookup[bsize]). COMMIT. - Intrabc. The DV predictor, the wavefront/delay validity bounds (a DV may only reference already-reconstructed pixels far enough behind the current superblock), and prediction from the current frame's own reconstruction. COMMIT.
Gate (mandatory, in crates/ec-av1/src/stream.rs beside the existing gates)
- Copy an existing gate's shape.
EC_AV1_REQUIRE_AOMENC=1must be set on every test run, so a missing oracle FAILS rather than SKIPs. - Bound every ffmpeg
generatewith-t <seconds>. - Build fixtures through the existing
gradients_source(seed, w, h, tail)helper — ffmpeg'sgradientssource ignores its own seed. Palette and intrabc are screen-content tools: aomenc will only choose them on flat, few-colour, repetitive content, so you will likely need a synthetic source (few-colour test pattern, repeated tiles) rather than a gradient. Whatever you use, it must be deterministic — hash the fixture across two runs and prove it. - aomenc
--threads=1 --row-mt=0 --enable-palette=1(and--enable-intrabc=1for stage 4), plus--tune-content=screenif that is what makes the encoder actually pick the tool. - Hard-assert firing counts via thread-local
Cell<usize>counters in decode.rs matching the existing*_HITS(thread-local, NOT atomics): palette blocks reconstructed > 0, intrabc blocks > 0. A gate that cannot prove its feature fired is vacuous (classgate-blind-to-feature). - Main's
gate_coverage.rsguard will fail by design once your gate enables these tools: itsNEVER_EXERCISEDlist namesenable-paletteandenable-intrabc. Deleting those two entries is part of landing this work.
Method
CLASS compare-range-not-tell: compare the msac RANGE against the oracle after
each element, never tell(). Oracle at ~/.cache/aom-oracle; env-gated rungs
EC_TRACE=1 (partitions), EC_TRACE_COEFF=1, EC_TRACE_MODE=1 (inter + intra
mode info), EC_AV1_PREFILT_DUMP=<prefix> (per-frame pre-filter recon — the
right rung for separating a prediction bug from a filter one). Add a rung with
scripts/instrument-aom-oracle.sh + scripts/build-aom-oracle.sh in the
existing shape (env-gated, silent when unset, idempotent, wrapper-around-impl).
CLASS equal-range-means-unread: reference range unchanged where ours moves =
we read a symbol it never wrote; theirs moves and ours does not = we skipped one.
Hard rules
export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-palette. Foreground builds,nice -n 19 cargo ... -j4. Give everycargo testa timeout of at least 600000 ms — the suite runs 3-4 minutes and a 120 s default kills it.- Sibling worktrees (edith_codecs, -chroma, -realworld, -lr, -superres, -tiles) have live agents. Never build in or edit them.
- Baseline: 234 passed / 0 failed on main.
- NEVER push, never merge, never touch
main. Commit onlane-paletteonly. - 75-turn cap and it does NOT reset on resume: commit at every green step. Stage 1 committed and green is a good round on its own.
- Refuse-by-name rather than desync; never claim in a refusal string that the encoder cannot emit a case unless you proved it.
- End with
lanes/palette.report.md, VERDICT on the first line: what landed, gate names + firing counts, remaining refusal strings verbatim, next lever.