Merge lane-av1422losslesspanic: the 4:2:2 lossless INTER panic is a FIVE-site family, not one line (report only)
Browse files at this commit1 changed file +245 -0
lanes/av1422losslesspanic.report.mdadded+245 -0
| @@ -0,0 +1,245 @@ | |||
| 1 | +# lane-av1422losslesspanic — the `--lossless=1` 4:2:2 panic is a FAMILY, not a one-line extent | ||
| 2 | + | ||
| 3 | +Base `ef9d7c97` (main, the merged `lane-av1422re4222`), worktree | ||
| 4 | +`~/.cache/wt/av1422lp`, branch `lane-av1422losslesspanic`. **Report-only: no | ||
| 5 | +source change is committed.** `crates/ec-av1/src/decode.rs` is untouched | ||
| 6 | +(`git status` clean apart from the local-only 4:2:2 probe bypass in | ||
| 7 | +`stream.rs`, which is reverted before yielding and is not in any commit). | ||
| 8 | + | ||
| 9 | +## Verdict | ||
| 10 | + | ||
| 11 | +Main asked for a one-line extent fix in `read_inter_chroma_lossless`. **It is | ||
| 12 | +not one line, and I am not shipping a half of it.** I applied the first three | ||
| 13 | +sites, watched the panic walk forward through three more, and reverted. What | ||
| 14 | +follows is the full site inventory with the measured geometry at each one, so | ||
| 15 | +the next lane starts at site 4 instead of at site 1. | ||
| 16 | + | ||
| 17 | +The three `--lossless=1` 4:2:2 cells still panic. Nothing is fixed; the | ||
| 18 | +deliverable is the map. | ||
| 19 | + | ||
| 20 | +## 1. The panic, reproduced, and why it is 4:2:2-only | ||
| 21 | + | ||
| 22 | +All three cells, unpatched, at `crates/ec-av1/src/decode.rs:37565` (the line | ||
| 23 | +number in the merged report; the `mu_units` allocation is `37555..37562`): | ||
| 24 | + | ||
| 25 | +``` | ||
| 26 | +W_intrabc.obu 130320 B --lossless=1, 320x240 4:2:2 | ||
| 27 | +X_intrabc_tiled.obu 131696 B W + --tile-columns=1 --tile-rows=1 | ||
| 28 | +Y_intrabc_10b.obu 202281 B W at 10-bit | ||
| 29 | + -> panicked at crates/ec-av1/src/decode.rs:37565:24: | ||
| 30 | + range end index 20 out of range for slice of length 16 | ||
| 31 | + -> backtrace: read_inter_chroma_lossless -> decode_inter_block | ||
| 32 | + -> decode_inter_frame_tile_with_cdfs | ||
| 33 | +``` | ||
| 34 | + | ||
| 35 | +The copy, verbatim: | ||
| 36 | + | ||
| 37 | +```rust | ||
| 38 | +let dst = mu_units( | ||
| 39 | + if plane_idx == 1 { &mut *u_out } else { &mut *v_out }, | ||
| 40 | + stride * stride, | ||
| 41 | +); | ||
| 42 | +for row in 0..4 { | ||
| 43 | + let start = (oy + row) * stride + ox; | ||
| 44 | + dst[start..start + 4].copy_from_slice(&cu_grid[row * 4..][..4]); | ||
| 45 | +} | ||
| 46 | +``` | ||
| 47 | + | ||
| 48 | +Instrumented geometry at the failing call (temporary `eprintln`, since | ||
| 49 | +removed): | ||
| 50 | + | ||
| 51 | +``` | ||
| 52 | +ZZLIC cpx=12 cpy=0 org=(0,0) reg=(4,16) blk=(4,16) stride=4 | ||
| 53 | + tw=160 th=240 need=64 alloc=16 | ||
| 54 | +``` | ||
| 55 | + | ||
| 56 | +`reg`/`blk` are a 4-wide x 16-tall chroma plane block with `stride` 4. The | ||
| 57 | +walk addresses row `oy + row` for `row in 0..4` over `reg_h / 4 = 4` bands, so | ||
| 58 | +its top row is 15 and its last element is `(4+3)*4 + 0 + 4 = 24`... the | ||
| 59 | +measured `need` is 64 elements against the square's `4*4 = 16`, and the first | ||
| 60 | +out-of-range slice starts at element 20. Matches the panic text exactly. | ||
| 61 | + | ||
| 62 | +**Why only 4:2:2.** `stride` is documented at the call site as "the block's | ||
| 63 | +**square** chroma side, even for a 2:1 strip, which embeds its narrower plane | ||
| 64 | +block in the same square grid". That contract holds when the chroma plane | ||
| 65 | +block is square, which it is at 4:2:0 (`side/2 x side/2`) and 4:4:4 | ||
| 66 | +(`side x side`). At 4:2:2 `decode_inter_block` (line 40004) hands the caller | ||
| 67 | +the **per-axis** pair: | ||
| 68 | + | ||
| 69 | +```rust | ||
| 70 | +let (chroma_stride, chroma_buf_h) = if chroma_422 { | ||
| 71 | + (write_chroma_w, write_chroma_h) // 4:2:2: per-axis | ||
| 72 | +} else { | ||
| 73 | + (chroma_side, chroma_side) // 4:2:0 / 4:4:4: the square | ||
| 74 | +}; | ||
| 75 | +``` | ||
| 76 | + | ||
| 77 | +so an 8x16 luma strip's chroma plane block is 4x16 — twice as tall as it is | ||
| 78 | +wide — and `stride * stride` is half of what the walk writes. | ||
| 79 | + | ||
| 80 | +**The discriminator, measured.** I encoded and ran the 4:2:0 and 4:4:4 lossless | ||
| 81 | +families on this tree with the same comparator (`count_rawvideo_diffs`, the | ||
| 82 | +crate's own) and none of them reaches this line: | ||
| 83 | + | ||
| 84 | +| family | cell | result | | ||
| 85 | +|---|---|---| | ||
| 86 | +| 4:2:0 lossless | `--lag-in-frames=0 --auto-alt-ref=0 --enable-global-motion=0` | **exact** 16/16, decode order 16/16 | | ||
| 87 | +| 4:2:0 lossless | `--lag-in-frames=0 --auto-alt-ref=1 --enable-global-motion=0` | **exact** 16/16, 16/16 | | ||
| 88 | +| 4:2:0 lossless | `--lag-in-frames=25 --auto-alt-ref=0 --enable-global-motion=0` | **exact** 16/16, 16/16 | | ||
| 89 | +| 4:2:0 lossless | `--lag-in-frames=25 --auto-alt-ref=1 --enable-global-motion=0` | refused by name (`AV1 tile: a Golomb tail longer than this decoder reads`) | | ||
| 90 | +| 4:2:0 lossless | `--lag-in-frames=25 --auto-alt-ref=1 --enable-global-motion=1` | **DIVERGES**, 1 254 308 wrong, 1/16 (see §5) | | ||
| 91 | +| 4:4:4 lossless | committed `a_lossless_444_*` gates (6 of them) | pass | | ||
| 92 | + | ||
| 93 | +The four committed 4:2:2 lossless/IBC pins — `422_intrabc_sb128_strip.obu` | ||
| 94 | +and `422_intrabc_sb128_strip_notxsearch.obu` among them — decode byte-exact, | ||
| 95 | +so the lossless **intra**/IBC 4:2:2 chroma path is fine. The gap is | ||
| 96 | +specifically lossless **inter** 4:2:2. | ||
| 97 | + | ||
| 98 | +## 2. The site inventory, in the order the panic reaches them | ||
| 99 | + | ||
| 100 | +Each site below was applied, the three cells re-run, and the panic observed to | ||
| 101 | +move. That walk IS the evidence that these are the sites; there is no | ||
| 102 | +speculation in the list. | ||
| 103 | + | ||
| 104 | +**Site 1 — `decode.rs:37580`, `mu_units(..., stride * stride)`.** | ||
| 105 | +Applied: `stride * blk_h`. The walk's top addressed row is | ||
| 106 | +`org_y + reg_h - 1`, and every one of the eight call sites passes a region | ||
| 107 | +that is a sub-rect of `blk` with `org` inside `blk`, so `stride * blk_h` is | ||
| 108 | +exactly the requirement and reduces to the old expression verbatim wherever | ||
| 109 | +the plane block is square. **Effect: the `range end index 20 ... length 16` | ||
| 110 | +panic is gone and all three cells decode further.** This part is real and I | ||
| 111 | +am confident in it — it is simply not sufficient. | ||
| 112 | + | ||
| 113 | +**Site 2 — `decode.rs:45037`, `(cr * cu + rr) * chroma_side + cc * cu` in the | ||
| 114 | +lossless TX_4x4 unit split.** The grid being split is the per-axis plane grid, | ||
| 115 | +so it must be indexed at `chroma_stride`. `chroma_side` runs off the end on | ||
| 116 | +the last chroma row at 4:2:2 and is the same number at 4:2:0 / 4:4:4. | ||
| 117 | +**Effect: panic moves from 37580 to 45030.** | ||
| 118 | + | ||
| 119 | +**Site 3 — `decode.rs:45023`, the unit counts.** | ||
| 120 | + | ||
| 121 | +```rust | ||
| 122 | +let (rows, cols) = ( | ||
| 123 | + (write_h >> ss_y(fctx)).div_ceil(cu), // LUMA-per-subsampling | ||
| 124 | + (write_w >> ss_x(fctx)).div_ceil(cu), | ||
| 125 | +); | ||
| 126 | +``` | ||
| 127 | + | ||
| 128 | +At 4:2:2 `ss_y` is 0, so `rows` counts the LUMA height while the grid holds | ||
| 129 | +chroma rows. Measured: `chroma_buf_h = 8`, `chroma_side = 16`, | ||
| 130 | +`chroma_stride = 4`, `grid_len = 32`, `cu = 4`, and the old expression gives | ||
| 131 | +`rows = 4` where the grid has 2 unit rows. Applied: | ||
| 132 | +`(chroma_buf_h.div_ceil(cu), chroma_stride.div_ceil(cu))`, identical at 4:2:0 | ||
| 133 | +and 4:4:4. **Effect: panic moves from 45030 to the prediction path.** | ||
| 134 | + | ||
| 135 | +**Site 4 — `decode.rs:39995-40001`, the strip chroma extents.** The `else` | ||
| 136 | +arm hands 4:2:2 the 4:2:0 pair's chroma rect: | ||
| 137 | + | ||
| 138 | +```rust | ||
| 139 | +} else if s.horz { (8, 4) } else { (4, 8) } | ||
| 140 | +``` | ||
| 141 | + | ||
| 142 | +The pair is 16x8 luma (horz) or 8x16 luma (vert); 4:2:2 subsamples X only, so | ||
| 143 | +the same pair is **8x8 / 4x16** in chroma. Measured on the failing cell | ||
| 144 | +(`side = 16`, `strip_chroma = Some`, `px = 4`, `py = 48`): | ||
| 145 | +`write_chroma_w = 4`, `write_chroma_h = 8` — half the rows of the 4x16 the | ||
| 146 | +block actually has. Applied: a `ss (1,0)` arm returning `(8, 8)` / `(4, 16)`. | ||
| 147 | +**This one changes `chroma_stride` and `chroma_buf_h` for the whole of | ||
| 148 | +`decode_inter_block` at 4:2:2, including the LOSSY arms that currently | ||
| 149 | +measure byte-exact. It is the first site with a real regression surface and | ||
| 150 | +the reason I stopped.** | ||
| 151 | + | ||
| 152 | +**Site 5 — the chroma prediction source stride (NOT reached, measured only).** | ||
| 153 | +With sites 1-4 applied the panic lands at `decode.rs:4366` inside | ||
| 154 | +`push_mc_rect_tx`, reached from `read_inter_plane` called by | ||
| 155 | +`read_inter_chroma_lossless`: | ||
| 156 | + | ||
| 157 | +``` | ||
| 158 | +ZZLIC3 w=4 h=4 stride=128 res_stride=4 pred_len=452 tx_stride=0 | ||
| 159 | +ZZLIC3 w=4 h=4 stride=64 res_stride=4 pred_len=0 tx_stride=0 | ||
| 160 | + -> panicked at crates/ec-av1/src/decode.rs:4369:66: | ||
| 161 | + range end index 4 out of range for slice of length 0 | ||
| 162 | +``` | ||
| 163 | + | ||
| 164 | +A 4x4 **chroma** unit is being read at a prediction stride of 128 and then | ||
| 165 | +64 — those are luma-plane strides — and the failing call's prediction buffer | ||
| 166 | +is empty. This is the chroma prediction plumbing for lossless 4:2:2 inter, and | ||
| 167 | +it is a different layer from the extents above: it needs the prediction | ||
| 168 | +source's own stride resolved per axis, which I have not established. | ||
| 169 | + | ||
| 170 | +## 3. Why I reverted rather than shipping sites 1-3 | ||
| 171 | + | ||
| 172 | +Sites 1-3 are each provably correct in isolation and provably | ||
| 173 | +format-preserving at 4:2:0 and 4:4:4. But **no cell decodes byte-exact with | ||
| 174 | +them**, so I would be committing a change to a bit-exact decoder that no | ||
| 175 | +oracle has ever seen produce a right pixel, on a path where the very next | ||
| 176 | +site is a stride the size of a whole luma plane. A partial fix here converts a | ||
| 177 | +loud panic into a plausible-looking wrong picture on a code path no gate | ||
| 178 | +covers. That is the worse outcome, so the tree is back at `ef9d7c97`. | ||
| 179 | + | ||
| 180 | +I also did not write a gate, because there is nothing to gate yet: a gate | ||
| 181 | +whose only red is "still panics" is a ratchet on a defect, not a fix, and | ||
| 182 | +Main's step 4 asked for a gate that bites on the *fixed* code. | ||
| 183 | + | ||
| 184 | +## 4. What the next lane should do | ||
| 185 | + | ||
| 186 | +1. **Sites 1-3 as written above.** They are ready to apply, they are | ||
| 187 | + format-preserving at 4:2:0 / 4:4:4, and the panic-walk is the proof that | ||
| 188 | + each one is on the path. | ||
| 189 | +2. **Site 4 needs a regression harness before it lands**, not after: the | ||
| 190 | + 4:2:2 lossy corpus in `lanes/av1422re4222.report.md` (`AA_inter_compound`, | ||
| 191 | + `AB_inter_warp_odd`, `AD_inter_nogm`, `L_tiled`, `T_tilecols2`, | ||
| 192 | + `U_tilerows1`, `V_tile2x2_odd`, and the six pins) is the set that would | ||
| 193 | + catch it, and every one of them must still be byte-exact. | ||
| 194 | +3. **Site 5 is the real work.** A 4x4 chroma unit read at a luma prediction | ||
| 195 | + stride is not an off-by-one; it is the chroma prediction source never | ||
| 196 | + having been resolved per axis on this path. Expect that to be where the | ||
| 197 | + time goes, and expect the byte-exactness to follow from fixing it rather | ||
| 198 | + than from the extents. | ||
| 199 | +4. **Do not chase the height-242 family.** It is untouched here, still open, | ||
| 200 | + and belongs to its own lane. | ||
| 201 | + | ||
| 202 | +## 5. Still true from the previous round, unchanged | ||
| 203 | + | ||
| 204 | +- The **height-242 4:2:2 divergence** (4/4 cells, chroma-only, luma exact, | ||
| 205 | + already differing at `EC_AV1_PREFILT_DUMP`) is **untouched and still open**. | ||
| 206 | + Not chased in this lane, by instruction. | ||
| 207 | +- The **4:2:0 lossless alt-ref + global-motion divergence** is untouched: | ||
| 208 | + 1 254 308 wrong presented samples, 1/16 shown frames exact, first divergent | ||
| 209 | + at frame 1 byte 268 plane 0. It refuses by name with alt-ref and no global | ||
| 210 | + motion, and is exact in every other lossless recipe. It is a 4:2:0 cell and | ||
| 211 | + it belongs to the lossless-inter owner. | ||
| 212 | + | ||
| 213 | +## Gates run | ||
| 214 | + | ||
| 215 | +Clean tree at `ef9d7c97` (this lane commits no source change), scoped: | ||
| 216 | + | ||
| 217 | +- `a_lossless_libaom_inter_frame_decodes_sample_exact` — pass | ||
| 218 | +- `the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name` — pass | ||
| 219 | +- `the_pinned_422_intrabc_sb128_strip_witnesses_refuse_by_name` — pass | ||
| 220 | +- `the_pinned_422_lr_off_witness_is_present_and_refuses_by_name` — pass | ||
| 221 | +- `the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name` — pass | ||
| 222 | + | ||
| 223 | +## Instrumentation disclosure | ||
| 224 | + | ||
| 225 | +Three temporary `eprintln` traces (`ZZLIC`, `ZZLIC2`, `ZZLIC3`), each removed | ||
| 226 | +immediately after the reading that produced the numbers above, and the four | ||
| 227 | +candidate source edits reverted with `git checkout --`. The `EC_AV1_ALLOW_422_PROBE` | ||
| 228 | +bypass at `stream.rs:1803` is patch-run-restore and is not in any commit. | ||
| 229 | +**Nothing was added to the decoder or the oracle in the committed tree.** | ||
| 230 | + | ||
| 231 | +## `not_done` | ||
| 232 | + | ||
| 233 | +- **The panic is NOT fixed.** All three `--lossless=1` 4:2:2 cells still panic | ||
| 234 | + at `decode.rs:37565` on `ef9d7c97`. | ||
| 235 | +- **No gate committed**, for the reason in §3. | ||
| 236 | +- **Site 5 is characterised, not fixed**: a 4x4 chroma unit is read at | ||
| 237 | + prediction strides 128 and 64, and the failing prediction buffer is empty. | ||
| 238 | + I did not establish where that stride comes from. | ||
| 239 | +- **Site 4's effect on the 4:2:2 lossy arms is predicted, not measured.** I | ||
| 240 | + did not run the 4:2:2 lossy corpus with site 4 applied, because applying | ||
| 241 | + it is the point at which the change stops being a local extent. | ||
| 242 | +- **The height-242 4:2:2 divergence** — open, not chased, by instruction. | ||
| 243 | +- **The 4:2:0 lossless alt-ref + global-motion divergence** — named, not owned. | ||
| 244 | +- **Full suite not run** (lane rules: scoped only; project-wide validation is | ||
| 245 | + Main's). | ||