report(av1): lane-realworld r7 -- merge done and gated, hbd typing plan scoped
Browse files at this commitd22f8c2806e3c0032bbb1c39fc5e18cfb4a0e04cParent: 772ae7b1 changed file +189 -0
- lanes/realworld-r7.report.md +189 -0
lanes/realworld-r7.report.mdadded+189 -0
| @@ -0,0 +1,189 @@ | |||
| 1 | +# lane-realworld r7 report | ||
| 2 | + | ||
| 3 | +VERDICT: Job 1 (merge main into lane-realworld) DONE, gated green, committed | ||
| 4 | +(f2e516f). Job 2 (high-bit-depth typing plan) DONE as scope-only, written | ||
| 5 | +below; no code changed for it, nothing half-wired. | ||
| 6 | + | ||
| 7 | +## Job 1 -- merge (f2e516f) | ||
| 8 | + | ||
| 9 | +`git merge main` (main at 92d8beb) hit the nine conflicts the charter named: | ||
| 10 | +eight hunks in `crates/ec-av1/src/stream.rs`, one in | ||
| 11 | +`decode_inter_frame_tile_with_cdfs` in `crates/ec-av1/src/decode.rs`. | ||
| 12 | + | ||
| 13 | +- `stream.rs` line ~173-204: kept HEAD's comment (delta_q/delta_lf already | ||
| 14 | + read/applied, r5) plus main's new bit-depth refusal (`"a stream whose bit | ||
| 15 | + depth is not 8..."`, kept verbatim per the charter); dropped main's | ||
| 16 | + now-stale `"a frame with delta_q_present or delta_lf_present set..."` | ||
| 17 | + refusal since that capability is this branch's own finished work. | ||
| 18 | +- `stream.rs` lines ~6545-6893: these seven remaining conflict markers were | ||
| 19 | + git's line-based diff conflating two *different* new test functions HEAD | ||
| 20 | + and main each appended at the same spot (HEAD's | ||
| 21 | + `a_real_aomenc_stream_with_delta_q_and_delta_lf_decodes_pixel_exact`, main's | ||
| 22 | + `a_real_aomenc_stream_with_two_tile_columns_and_an_inter_frame_decodes_pixel_exact`) | ||
| 23 | + -- not a real overlap. Resolved by pulling each side's complete function | ||
| 24 | + from `git show HEAD:.../stream.rs` / `git show main:.../stream.rs` and | ||
| 25 | + placing both, intact and un-interleaved, one after the other. | ||
| 26 | +- `decode.rs` (`decode_inter_frame_tile_with_cdfs`): main reworked the | ||
| 27 | + function from a single tile-wide decoder into the same per-tile loop | ||
| 28 | + `decode_key_frame_tile_with_cdfs` already had (fresh `cdfs`/`dec` per | ||
| 29 | + tile, `base_cdfs`/`result_cdfs` split). HEAD's delta_q/delta_lf state | ||
| 30 | + setup (`DELTA_Q_PRESENT`/`DELTA_Q_RES`/`DELTA_LF_PRESENT`/`DELTA_LF_RES`/ | ||
| 31 | + `DELTA_LF_MULTI`, all frame-level and `q_present`/`res` etc from | ||
| 32 | + `DeltaParams`) now lives once before the loop, same as the intra tile | ||
| 33 | + function; `CURRENT_Q_IDX`/`CURRENT_DELTA_LF` (both genuinely per-tile, | ||
| 34 | + spec `decode_tile` resets `CurrentQIndex` at the top of every tile) moved | ||
| 35 | + inside the loop, mirroring `decode_key_frame_tile_with_cdfs`'s own | ||
| 36 | + `CURRENT_Q_IDX.with(|c| c.set(i32::from(base_q_idx)))` / | ||
| 37 | + `CURRENT_DELTA_LF.with(|c| c.set([0; 4]))` pair placed right where that | ||
| 38 | + function creates its own per-tile `cdfs`/`dec`. | ||
| 39 | +- One knock-on compile error the merge exposed, not a conflict: main's | ||
| 40 | + `a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact` test | ||
| 41 | + (auto-merged cleanly, no conflict marker) calls | ||
| 42 | + `decode_key_frame_tile_with_cdfs` directly and was missing the trailing | ||
| 43 | + `delta: DeltaParams` argument this branch's signature already carries | ||
| 44 | + (r4). Added `header.delta` (the struct is `Copy`, same pattern every | ||
| 45 | + other call site in the file already uses) to fix the E0061. | ||
| 46 | + | ||
| 47 | +`export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-realworld && EC_AV1_REQUIRE_AOMENC=1 nice -n 19 cargo test -p ec-av1 --lib -j4`: | ||
| 48 | +**246 passed, 0 failed, 17 ignored** (was 243 pre-merge on this branch, 239 | ||
| 49 | +pre-merge on main; the merge is additive, no regressions). | ||
| 50 | + | ||
| 51 | +No refusal strings added/removed/reworded beyond what main already carried | ||
| 52 | +in (the bit-depth refusal, kept verbatim; the three reworded partition | ||
| 53 | +refusals, untouched by this merge). | ||
| 54 | + | ||
| 55 | +## Job 2 -- high bit depth: typing plan, not implemented | ||
| 56 | + | ||
| 57 | +Both real files in this box's library | ||
| 58 | +(`~/Downloads/reelb.mkv`, | ||
| 59 | +`~/Videos/Films/reelc.mkv`) are `yuv420p10le` and now stop at | ||
| 60 | +the bit-depth refusal landed by this merge. Turns ran out before probing | ||
| 61 | +them live with `decode_probe`/`ffmpeg -f obu` this round -- next lane's | ||
| 62 | +first move, not scoped further here. | ||
| 63 | + | ||
| 64 | +### Why `Vec<u8>` cannot just get a runtime scale | ||
| 65 | + | ||
| 66 | +`transform.rs` already takes `bit_depth: u8` and uses it for the inverse | ||
| 67 | +transform's own intermediate clamp widths (`row_clamp = bit_depth + 8`, | ||
| 68 | +`col_clamp = max(bit_depth + 6, 16)`, `transform.rs:829-830`) -- that part | ||
| 69 | +is bit-depth-aware today. Every dequant call site in `decode.rs` still | ||
| 70 | +hardcodes the literal `8` as that parameter (6 call sites: | ||
| 71 | +`dequant_and_inverse_typed`/`dequant_and_inverse_typed_wh`, e.g. | ||
| 72 | +`decode.rs:2986`, `:3316` intra rect luma/chroma x2 each plus the inter | ||
| 73 | +paths at `:5397`, `:5858`). Threading the real `bit_depth` through those 6 | ||
| 74 | +is narrow (same shape as `base_q_idx`'s existing pass-through). | ||
| 75 | + | ||
| 76 | +The actual width problem is downstream of the transform: **every | ||
| 77 | +reconstruction write clamps to `[0, 255]` and stores `as u8`.** This is | ||
| 78 | +not 2 sites, it is a whole-crate convention: | ||
| 79 | +`decode.rs`'s `PlaneBuf::reconstruct`/`reconstruct_rect` (`:3153`, | ||
| 80 | +`:3226`), CDEF pixel writes (`:4181`), deblocking's op/oq stores (`:4634` | ||
| 81 | +-`:4710`, ~14 sites across the 4/6/8/13/14-tap filters), plus every | ||
| 82 | +sample buffer write in `mc.rs` (inter prediction, `:406`/`:524`/`:587`) | ||
| 83 | +and `intra.rs` (intra prediction proper, `:307`/`:434`/`:568`, and filter | ||
| 84 | +intra `:762`). All of these assume an 8-bit sample IS a `u8`, both as the | ||
| 85 | +storage type and as the clamp bound. | ||
| 86 | + | ||
| 87 | +### The type to widen | ||
| 88 | + | ||
| 89 | +`Picture` (`encode.rs:86`, `y`/`u`/`v: Vec<u8>`) and `PlaneBuf` | ||
| 90 | +(`decode.rs:2980`, `data: Vec<u8>`) are the two sample-storage structs. | ||
| 91 | +Widening both to `Vec<u16>` (AV1 caps at 12-bit, so `u16` covers every | ||
| 92 | +legal `bit_depth`) is the natural target -- but doing that unconditionally | ||
| 93 | +regresses every existing 8-bit fixture's memory/perf for a capability the | ||
| 94 | +crate doesn't have yet. The narrower move: keep `Vec<u8>` as the on-disk | ||
| 95 | +`Picture` representation for the 8-bit case (all current fixtures, all | ||
| 96 | +current gates, `Picture::grey`'s `128u8` default) and give `PlaneBuf` | ||
| 97 | +(the internal, per-decode scratch buffer, never a public API surface) a | ||
| 98 | +generic sample type — either a `u16`-always internal buffer (simplest; | ||
| 99 | +8-bit content just never uses the top byte, same choice `dav1d`/libaom | ||
| 100 | +make internally) or a `PlaneBuf<S>` generic over `u8`/`u16` picked once at | ||
| 101 | +`decode_key_frame_tile_with_cdfs`'s entry from the sequence header's | ||
| 102 | +`bit_depth`. Given this crate has no perf-critical caller depending on | ||
| 103 | +`PlaneBuf` staying byte-sized (it is decode-internal, dropped at the end | ||
| 104 | +of each frame), **`u16`-always is the lower-risk pick**: one type, no | ||
| 105 | +monomorphization/dyn-dispatch fork through the ~30 clamp-and-store call | ||
| 106 | +sites, and the existing 8-bit path just runs with a wider-than-needed | ||
| 107 | +sample width, which every reference decoder already does internally. | ||
| 108 | + | ||
| 109 | +### Concrete surface, sized | ||
| 110 | + | ||
| 111 | +1. `PlaneBuf.data: Vec<u8>` -> `Vec<u16>`; every | ||
| 112 | + `.clamp(0, 255) as u8` write becomes `.clamp(0, max_val) as u16` where | ||
| 113 | + `max_val = (1i32 << bit_depth) - 1` (a new thread-local, same pattern | ||
| 114 | + as `CDEF_BITS`/`ENABLE_EDGE_FILTER`, set once per tile-function entry | ||
| 115 | + from the sequence header's `bit_depth`). ~30 call sites across | ||
| 116 | + `decode.rs` (reconstruct/reconstruct_rect/CDEF/deblock), `mc.rs` | ||
| 117 | + (inter prediction), `intra.rs` (intra + filter-intra prediction) -- | ||
| 118 | + every one is already a `.clamp(0, 255) as u8` grep hit, so the sweep is | ||
| 119 | + mechanical once the constant is threaded, not a design problem. | ||
| 120 | +2. `prediction: Vec<u8>` scratch buffers inside `reconstruct`/ | ||
| 121 | + `reconstruct_rect` (`decode.rs:3121`/`:3182`) and the `dst`/`out` | ||
| 122 | + parameters `mc::predict`/`intra::predict`/`predict_filter_intra` | ||
| 123 | + already take by `&mut [u8]` -- these become `&mut [u16]`, a pure | ||
| 124 | + signature widen, no logic change (the intermediate math is already | ||
| 125 | + `i32`/wider before the final clamp-and-store). | ||
| 126 | +3. `transform.rs`'s 6 `bit_depth: 8`-hardcoded call sites in `decode.rs` | ||
| 127 | + become the real `bit_depth: u8` from the sequence header's | ||
| 128 | + `color_config.bit_depth`, threaded the same way `base_q_idx` already | ||
| 129 | + is (a plain pass-through parameter, no new state needed — confirmed | ||
| 130 | + the value is already carried on `SequenceHeader.color_config` and | ||
| 131 | + reachable at every one of these 6 call sites' enclosing function). | ||
| 132 | +4. `Picture` (the public, post-decode return type) gains a `bit_depth: u8` | ||
| 133 | + field and its `y`/`u`/`v` become `Vec<u16>` too (matching what | ||
| 134 | + `ffmpeg_decode_sequence`'s gate helper will need to compare against, | ||
| 135 | + below) -- OR stays `Vec<u8>` for 8-bit and the crate adds a parallel | ||
| 136 | + `Vec<u16>` accessor/variant for >8-bit. Given no downstream consumer of | ||
| 137 | + `Picture` in this crate needs 8-bit specifically (it's an internal test | ||
| 138 | + type per `encode.rs`'s own doc comment "one 8-bit planar picture"), | ||
| 139 | + the simpler move is widening `Picture` itself to `Vec<u16>` too and | ||
| 140 | + dropping the "8-bit" from its doc comment -- `Picture::grey`'s `128` | ||
| 141 | + default is bit-depth-agnostic already (mid-grey is `1 << (bit_depth-1)` | ||
| 142 | + either way, one more thread-local read). | ||
| 143 | +5. The refusal (`stream.rs`, this merge's `"a stream whose bit depth is | ||
| 144 | + not 8..."`) is deleted once (1) through (4) land and a gate proves them, | ||
| 145 | + the same sequencing every other capability in this repo's ledger | ||
| 146 | + followed (interintra, masked compound, wedge, warp). | ||
| 147 | + | ||
| 148 | +### What the gate needs -- `ffmpeg_decode_sequence` also assumes 8-bit | ||
| 149 | + | ||
| 150 | +`stream.rs:738`'s test helper hardcodes `-pix_fmt yuv420p` on ffmpeg's | ||
| 151 | +raw output, which is 1 byte/sample regardless of source depth (ffmpeg | ||
| 152 | +would silently truncate a 10-bit decode to 8-bit there too, the exact | ||
| 153 | +silent-wrongness class the new refusal exists to avoid). A 10-bit gate | ||
| 154 | +needs a second helper (or a `bit_depth` parameter on this one) that asks | ||
| 155 | +ffmpeg for `-pix_fmt yuv420p10le` and parses the raw output as | ||
| 156 | +little-endian `u16` pairs, 2 bytes/sample -- mechanical, not a design | ||
| 157 | +question, but it is new code, not reuse of the existing 8-bit gate | ||
| 158 | +helper as-is. | ||
| 159 | + | ||
| 160 | +### Sizing | ||
| 161 | + | ||
| 162 | +This is at minimum its own lane, likely 2: one for the mechanical | ||
| 163 | +`u8`->`u16` PlaneBuf/prediction-buffer widening + real `bit_depth` | ||
| 164 | +threading through the 6 transform call sites (large diff, low risk -- | ||
| 165 | +every site is already a grep-identifiable `.clamp(0,255) as u8` pattern), | ||
| 166 | +gated first against synthetic 10-bit `aomenc` fixtures; a second for | ||
| 167 | +whatever the two real films' streams refuse on *next* (the charter's own | ||
| 168 | +prediction: "expect a new refusal to appear behind the bit-depth one"). | ||
| 169 | +Not attempted this round -- charter scoped this as "the shape, not the | ||
| 170 | +whole feature," and every comparable feature in this repo's ledger | ||
| 171 | +(warp, OBMC, interintra, masked compound, wedge) took multiple dedicated | ||
| 172 | +lane-rounds; landing even the mechanical half in whatever budget remained | ||
| 173 | +after Job 1 risked leaving a half-wired widening uncommitted at the turn | ||
| 174 | +cap, which the charter explicitly forbids ("land nothing half-wired"). | ||
| 175 | + | ||
| 176 | +deferred: probing the two real films with `decode_probe`/`ffmpeg -f obu` | ||
| 177 | +to name the next refusal — no turns left this round — unblocked by | ||
| 178 | +nothing (any future lane can run it immediately); the typing plan above | ||
| 179 | +does not depend on that probe's output, it depends only on the crate's | ||
| 180 | +existing `u8`-everywhere convention, which is repo-visible without the | ||
| 181 | +films. | ||
| 182 | + | ||
| 183 | +## Merge note for future lanes | ||
| 184 | + | ||
| 185 | +`gate_coverage.rs` / `refusal_inventory.rs` needed no manual entry beyond | ||
| 186 | +what the merge itself carried in (both auto-merged clean, no new gate or | ||
| 187 | +refusal added this round). Sibling worktrees (`-lr`, `-palette`, | ||
| 188 | +`-sbpart`, `-superres`, `-tiles`) were not touched. Nothing pushed. | ||
| 189 | +`lane-realworld` was not merged into `main`. | ||