forge
Explore
Log in

Don't you dare go Hollow

Lane-tiles report -- groundwork only, refusal still fires

Browse files at this commit

238090434db943e3534da4a005e2498080a93496Ahmet Kaan GümüşParent: 4057dda
  • docs
    • lane-tiles report -- groundwork only, refusal still fires
Show full message
docs(av1): lane-tiles report -- groundwork only, refusal still fires
lanes/tiles.report.mdadded+116 -0
@@ -0,0 +1,116 @@
1+# lane-tiles report
2+
3+## What landed
4+Groundwork only, commit `1231cd5` on branch `lane-tiles`:
5+`crates/ec-av1/src/decode.rs`
6+- `Neighbours` gained `tile_row0_mi`/`tile_col0_mi` (spec `MiRowStart`/
7+ `MiColStart`), default `0`, and `start_tile(row0_mi, col0_mi, col1_mi)`
8+ (spec `decode_tile`'s `clear_above_context` over the tile's own column
9+ span; left-context reset per SB row was already unconditional and needed
10+ no change).
11+- Every availability check that compared a raw mi position against literal
12+ `0` now compares against the tile origin instead: `skip_txfm_ctx`,
13+ `tx_size_context`, `tx_size_context_rect`, and `decode_inter_block`/
14+ `decode_inter_block8`'s `has_above`/`has_left`.
15+- Behaviourally a no-op today: nothing calls `start_tile`, so the origin
16+ stays `(0, 0)` everywhere and every existing test is bit-identical.
17+
18+The refusal at `crates/ec-av1/src/stream.rs:292-297` ("a frame with more
19+than one tile") is **unchanged and still fires** — it was not removed.
20+
21+## Why it stops here (turn budget)
22+Recon (charter + call-site tracing across `decode.rs`, `mvstack.rs`,
23+`ec-av1-syntax/frame.rs`'s `TileInfo`/`parse_tile_group`) took the first
24+~35 tool calls to establish the real shape of the three hard parts. What
25+full removal of the refusal needs, none of which is done:
26+1. **Entropy per tile.** `decode_key_frame_tile_with_cdfs` /
27+ `decode_inter_frame_tile_with_cdfs` each take one `data: &[u8]` and run
28+ one `SymbolDecoder`/`cdfs` over the whole `for sb_r in 0..sb_rows { for
29+ sb_c in 0..sb_cols }` walk. This needs restructuring into a `for tile in
30+ &tiles` outer loop: fresh `SymbolDecoder` per tile's own byte range
31+ (`Tile::offset` is relative to the OBU, already handled correctly in
32+ stream.rs for tile 0 today), fresh `cdfs = initial_cdfs.clone()` per
33+ tile, sb range narrowed to `mi_row_starts[t]/SB_MI..mi_row_starts[t+1]/
34+ SB_MI` (same for cols), and only `context_update_tile_id`'s own
35+ end-of-tile `cdfs` returned as the frame's adapted table. `TileInfo`
36+ already carries everything this needs (`frame.rs:115`); the derivation
37+ at `frame.rs:1292` confirms `mi_col_starts`/`mi_row_starts` are always
38+ fully populated by the real parser, including the `cols==rows==1` case.
39+2. **Context clipping — partially wired, NOT complete.** This commit's
40+ `Neighbours` change covers the context-symbol reads it touched. Two
41+ things it does **not** cover:
42+ - `PlaneBuf::edges`/`edges_rect` (`decode.rs` ~2653-2696) still gate
43+ intra-prediction pixel reach on `x > 0`/`y > 0` — a block at a tile's
44+ own left/top edge would read real reconstructed pixels from the
45+ PREVIOUS tile (decoded earlier, sitting right there in the shared
46+ buffer) instead of treating them as unavailable, which is a real
47+ pixel-value bug per spec (AV1 tiles are independently decodable;
48+ intra prediction does not cross tile boundaries). Needs a
49+ `tile_x0`/`tile_y0` pair on `PlaneBuf` (luma-pixel and chroma-pixel
50+ scaled, i.e. `mi_col0*4`/`mi_col0*2`), set before each tile, checked
51+ in `edges`/`edges_rect` in place of `0`.
52+ - `mvstack.rs`'s `find_mv_stack_with_sign_bias` (the actual MV
53+ neighbour scan for every inter block) still hardcodes
54+ `mi_row > 0`/`mi_col > 0` for `max_row_offset`/`max_col_offset` and
55+ `found_above`/`found_left` (its own doc comment at line ~690 already
56+ flags this: *"clamped to the tile's near edge (single-tile-per-frame
57+ here, so that's just the frame edge at 0)"*). `find_samples`/
58+ `num_proj_ref` (`decode.rs` ~5488/5617, warp-sample gathering for
59+ `WARPED_CAUSAL`) have the same gap. Neither was touched this round.
60+ - Deblock/CDEF were confirmed (not just assumed) to run across the
61+ whole picture after all tiles decode (`apply_deblock`/`apply_cdef`
62+ calls sit after the SB loop, once, over the full `y`/`u`/`v`) —
63+ these need **no** tile clipping, matching the charter's note.
64+3. **Tile-group ordering.** Not started. `ObuKind::Frame(header, tiles)`'s
65+ `tiles: Vec<Tile>` already spans every tile in `tg_start..tg_end` for a
66+ *single* OBU (`parse_tile_group`, `ec-av1-syntax/src/frame.rs:1992`),
67+ which covers the common `--tile-columns`/`--tile-rows` aomenc case (one
68+ `OBU_FRAME` carries every tile). The separate multi-OBU case
69+ (`ObuKind::FrameHeader` followed by one or more standalone
70+ `ObuKind::TileGroup(Vec<Tile>)` OBUs) is not collected at all today —
71+ `decode_stream`'s `while pos < data.len()` loop only matches
72+ `ObuKind::Frame`/`FrameHeader` (for `show_existing_frame`) and silently
73+ `continue`s past everything else, including a bare `TileGroup` OBU.
74+
75+No gate was added — the charter's mandatory gate asserts a tile-firing
76+counter `> 1` on real decoded output, which requires part 1 (entropy per
77+tile) to exist first; writing the gate against the untouched refusal would
78+either be vacuous or fail immediately.
79+
80+## Remaining refusal strings (verbatim, unchanged)
81+- `"a frame with more than one tile (this decoder only ever decodes tile 0)"`
82+ — `stream.rs:294-296`, still fires for every `tile_info.cols > 1 ||
83+ tile_info.rows > 1` frame, intra or inter.
84+
85+## Verification
86+`cargo test -p ec-av1 --lib` (`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-tiles`,
87+`EC_AV1_REQUIRE_AOMENC=1`): 232 passed, 0 failed, 17 ignored, 174.28s —
88+baseline unchanged, no regression from the groundwork commit.
89+
90+## Next lever (for whoever picks this up)
91+Land in the charter's own staged order, each its own commit:
92+1. Restructure `decode_key_frame_tile_with_cdfs` to accept
93+ `tiles: &[(u32 /* tile_num */, &[u8])]` + `&TileInfo` in place of a
94+ single `data: &[u8]`, wrap the existing SB double loop (currently
95+ `decode.rs` lines ~4547 header `for sb_r in 0..sb_rows` through its
96+ matching close ~4947) in `for &(tile_num, bytes) in tiles`, call
97+ `neighbours.start_tile(...)` (already written, unused) and set
98+ `PlaneBuf` tile pixel origins (not yet added) at each tile's start,
99+ narrow the sb range, and capture `cdfs` as the returned table only when
100+ `tile_num == tile_info.context_update_tile_id`. Update the one caller
101+ (`decode_key_frame_tile`, `decode.rs:4478`) and `stream.rs`'s key-frame
102+ branch to build the tile list instead of `tiles.first()`. Prove stage 1
103+ (two tiles, column split, all-intra) before touching anything else.
104+2. Same restructuring for `decode_inter_frame_tile_with_cdfs`, PLUS
105+ threading `tile_row0_mi`/`tile_col0_mi` into `find_mv_stack_with_sign_bias`
106+ and `find_samples`/`num_proj_ref` (both currently frame-relative-only).
107+3. Multi-tile-group OBU collection in `decode_stream`'s main loop
108+ (`ObuKind::FrameHeader` + trailing `ObuKind::TileGroup` accumulation
109+ before dispatch, mirroring the existing `pending: Option<FrameHeader>`
110+ field already on `Av1Parser` internally, though that field is private —
111+ check whether it's exposed or the collection has to happen in
112+ `decode_stream` itself against raw OBU events).
113+4. `context_update_tile_id != 0` pin test once tables save correctly.
114+5. The mandatory gate: `--tile-columns=1 --tile-rows=1` aomenc recipe
115+ (log2 values), thread-local `TILE_HITS` counter (not yet added)
116+ incremented once per tile actually decoded, hard-asserted `> 1`.