edith_codecs
Clone
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
lane-tiles — multi-tile decode
Worktree /home/user/Documents/Code/Rust/edith_codecs-tiles, branch
lane-tiles, off main (48a6e29 or later).
Goal
Remove the refusal at crates/ec-av1/src/stream.rs:293-298
("a frame with more than one tile (this decoder only ever decodes tile 0)")
by decoding every tile of every tile group, in order, into one picture.
What is already there
crates/ec-av1-syntax/src/frame.rs:115TileInfoalready carries everything the walk needs:cols,rows,cols_log2,rows_log2,mi_col_starts(TileCols + 1entries, 4x4 units),mi_row_starts,context_update_tile_id,tile_size_bytes. The uniform/non-uniform spacing derivation is atframe.rs:1292onward and is already implemented — READ it, do not re-derive.- The tile-group OBU parse already produces per-tile
offset/size; todaystream.rstakestiles.first()and drops the rest.Tile::offsetis relative to the OBU buffer, not todata— see the comment at stream.rs:298. - The superblock walk lives in
crates/ec-av1/src/decode.rs(two sites, around lines 4547 and 9275:for sb_r in 0..sb_rows { for sb_c ... }). Today those bounds are the whole frame; per tile they become the tile's own sb range derived frommi_row_starts[t]..mi_row_starts[t+1].
The three things that make tiles more than a loop
- Entropy reset per tile. Each tile starts a FRESH msac decoder over its
own byte range AND a fresh copy of the frame's initial CDFs (spec 5.11.2
decode_tile:init_symbol+clear_above_context). Only the tile named bycontext_update_tile_idhas its END-of-tile adapted CDFs saved as the frame's output tables (specexit_symbol) — every other tile's adaptation is discarded. This is exactly what the current refusal comment warns about. - Context reset at tile boundaries. Above-context arrays are cleared at the
start of each tile ROW of superblocks within the tile; left-context at each
superblock row. Neighbour availability MUST be clipped to the tile: a block
at the tile's left edge has NO left neighbour even though a decoded block
sits there in the picture. Same for above. Grep libaom
av1/decoder/decodeframe.cav1_tile_init/av1_tile_set_col/av1_tile_set_rowandav1/common/tile_common.c; the availability predicates arexd->left_available/xd->up_available, set inset_mi_row_col(av1/common/blockd.h). Deblocking and CDEF, by contrast, run ACROSS tile boundaries unlessloop_filter_across_tilessays otherwise — check the actual v3.13.3 source, AV1 has no such flag in the final spec but verify rather than assume. Also check the mv-stack / ref-mv scan (crates/ec-av1/src/mvstack.rs) and the CDEF/deblock neighbour reads for the same tile clipping. - Tile ordering across tile groups. A frame may carry several tile-group
OBUs; tiles are numbered
tg_start..tg_endglobally.
Method
CLASS compare-range-not-tell: compare the msac RANGE against the oracle after
each element, never tell(). The instrumented oracle is at ~/.cache/aom-oracle
with env-gated rungs (EC_TRACE=1 partitions, EC_TRACE_COEFF=1,
EC_TRACE_MODE=1); scripts/instrument-aom-oracle.sh + scripts/build-aom-oracle.sh
add and rebuild rungs. If you need a per-tile rung (tile index at each
decode_tile entry), add one 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.
Staging — COMMIT AFTER EVERY GREEN MILESTONE (75-turn cap; builders have lost whole implementations here)
- Two tiles, one column split, all-intra key frame. COMMIT.
- Tile rows as well as columns; non-uniform spacing. COMMIT.
- Inter frames (mv-stack + neighbour clipping is where this will break). COMMIT.
- Several tile-group OBUs per frame. COMMIT.
context_update_tile_idproven: a stream where it is NOT tile 0, decoding pixel-exact across the following frame (which inherits those CDFs). COMMIT.
Gate (mandatory, in crates/ec-av1/src/stream.rs beside the existing gates)
- Copy the existing gate shape. Tests must be run with
EC_AV1_REQUIRE_AOMENC=1so a missing oracle FAILS instead of SKIPping. - Bound every ffmpeg
generatewith-t <seconds>(an unbounded source once hung a gate for an hour). - Build fixtures through the existing
gradients_source(seed, w, h, tail)helper — ffmpeg'sgradientsignores its own seed, so a hand-writtengradients=size=string makes the gate non-reproducible. - aomenc:
--threads=1 --row-mt=0plus--tile-columns=1 --tile-rows=1(log2 values in aomenc) on a frame large enough that the tiles are legal — a 64x64 frame cannot be split, so size the fixture accordingly. - Hard-assert a firing count: a thread-local
Cell<usize>counter in decode.rs matching the existing*_HITS(thread-local, NOT atomics), incremented per tile decoded, asserted> 1. CLASSgate-blind-to-feature: a gate that cannot prove its feature fired is vacuous. - Refusals inside the gate are FORBIDDEN once the stage removing them lands.
Hard rules
export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-tiles. Foreground builds only,nice -n 19 cargo ... -j4. Never build in or edit another worktree: edith_codecs, -chroma, -realworld, -lr, -superres all have agents in them NOW.- Suite:
nice -n 19 cargo test -p ec-av1 --lib, baseline 232 passed / 0 failed (~67 s). It stays green. - NEVER push, never merge, never touch
main. Commit onlane-tilesonly. - Refuse-by-name rather than desync; never write a refusal string claiming the
encoder cannot emit a case unless you proved it (class
refusal-claim-disproved-by-its-own-gate). - End with
lanes/tiles.report.md: what landed, gate name + firing count, remaining refusal strings verbatim, next lever.