lane-av1422seed: the frame-0 4:2:2 seed is decode_rect4_16_intrabc's 4:2:0 pair geometry at ss (1,0) -- LOCALISED, fix not landed
Browse files at this commit74d4dbb74639d2d1d61f16611d810c923ea3e1e7Parent: 63036d24 changed files +703 -0
- lanes/av1422seed.report.md +379 -0
- scripts/cmp422-ffmpeg.py +242 -0
- scripts/run422-ffmpeg.py +54 -0
- scripts/shape422-diff.py +28 -0
lanes/av1422seed.report.mdadded+379 -0
| @@ -0,0 +1,379 @@ | |||
| 1 | +# lane-av1422seed — the frame-0 chroma-only 4:2:2 family: LOCALISED, not closed | ||
| 2 | + | ||
| 3 | +**Outcome in one line: the seed is `decode_rect4_16_intrabc`'s 4:2:0 pair geometry | ||
| 4 | +applied verbatim at ss (1,0) — proved by an unwritten-sample census, not inferred — | ||
| 5 | +and the write-side half of the fix is not sufficient on its own: moving the chroma | ||
| 6 | +write alone regresses luma, so the entropy-side half of the same arm must move with | ||
| 7 | +it. This branch therefore lands NO decoder change.** | ||
| 8 | + | ||
| 9 | +Tip: `main` = `affe70dc`. Worktree `/home/user/.cache/wt/av1422seed`, branch | ||
| 10 | +`lane/av1422seed`. `crates/ec-av1/src/decode.rs` and `src/stream.rs` are at | ||
| 11 | +`main`'s content — the `if false &&` 4:2:2 bypass used for probing is **not** | ||
| 12 | +committed and the sequence-header refusal is intact. | ||
| 13 | + | ||
| 14 | +--- | ||
| 15 | + | ||
| 16 | +## 0. What is delivered | ||
| 17 | + | ||
| 18 | +1. §2 — the ffmpeg comparator, its decode→display mapping rule, and the control | ||
| 19 | + cells it reports byte-exact. | ||
| 20 | +2. §3 — all five slice cells reproduced against ffmpeg, with the first divergence | ||
| 21 | + and the per-frame counts. | ||
| 22 | +3. §4 — the localisation: the exact arm, the exact constants, and a census that | ||
| 23 | + names the unwritten samples. | ||
| 24 | +4. §5 — the attempted fix, why it is **not** landed, and what the remaining half is. | ||
| 25 | +5. §6 — what is NOT measured (stated, not hidden). | ||
| 26 | + | ||
| 27 | +--- | ||
| 28 | + | ||
| 29 | +## 1. The instrument, and what it does NOT inherit from the census | ||
| 30 | + | ||
| 31 | +`scripts/cmp422-ffmpeg.py` + `scripts/run422-ffmpeg.py` (committed). The census's | ||
| 32 | +`cmp422.py` compares against the **instrumented aomdec**; this lane's brief makes | ||
| 33 | +**ffmpeg 8.1.3** the pixel oracle, so the comparator is new and its disciplines are | ||
| 34 | +stated here rather than inherited. | ||
| 35 | + | ||
| 36 | +1. **Geometry is an explicit argument read from the SEQUENCE HEADER.** `ffprobe | ||
| 37 | + -show_entries stream=coded_width,coded_height,pix_fmt` on the `.obu`; the | ||
| 38 | + chroma tag and depth come from `pix_fmt` (`yuv422p`, `yuv422p10le`, …), and the | ||
| 39 | + comparator refuses a `pix_fmt` that disagrees with the ss/depth it derived | ||
| 40 | + (`cmp422-ffmpeg.py:24`). A raw frame whose length is not a whole multiple of | ||
| 41 | + the geometry's frame size is a hard error (`split`, `:80`). **Never** a file | ||
| 42 | + size, and never the u8-narrowing dump for a 10-bit cell. | ||
| 43 | +2. **Plane attribution is per frame**, from that frame's own plane lengths | ||
| 44 | + (`sizes = (w*h, cw*ch, cw*ch)`, `cw = ceil(w/2^ss_x)`, `ch = ceil(h/2^ss_y)`), | ||
| 45 | + with a monotone cursor inside the frame (`compare`, `:145`). | ||
| 46 | +3. **A wrong SAMPLE is one `bps`-wide unit.** At 10 bit the comparator walks | ||
| 47 | + 16-bit LE samples, so a `0x0C00`-vs-`0x0BFF` defect cannot hide behind a byte | ||
| 48 | + compare. | ||
| 49 | +4. **A count over zero frames is a hard error** (`:120`, `:140`): an empty dump | ||
| 50 | + set raises rather than reporting a vacuous `0/0/0`. | ||
| 51 | +5. **Decode-order → display-order is derived, not assumed.** Ours is | ||
| 52 | + `EC_AV1_FINAL_DUMP` (decode order, hidden alt-refs included); ffmpeg's | ||
| 53 | + `-f rawvideo` is **display order and has no hidden frames** — 16 shown frames | ||
| 54 | + against our 17. `map_decode_to_display` (`:80`) identifies each decode frame by | ||
| 55 | + its **luma plane** and enumerates *every* assignment that covers the display | ||
| 56 | + side; if the assignments disagree on the counts it raises rather than picking | ||
| 57 | + one. This is load-bearing: a real altref stream **reorders display against | ||
| 58 | + decode** (measured on all five control cells: decode f1 is the hidden picture | ||
| 59 | + and decode f2..f8 map to display 7, 3, 1, 2, 5, 4, 6), so the tempting | ||
| 60 | + "decode order = display order" prior is wrong and a monotonicity prior is | ||
| 61 | + wrong too — both are rejected in the code with the measurement that rejects | ||
| 62 | + them. | ||
| 63 | + | ||
| 64 | +### 1.1 Comparator controls | ||
| 65 | + | ||
| 66 | +Five control cells, same pipeline, same binary, **before any change**: | ||
| 67 | + | ||
| 68 | +| cell | geometry | decode / shown | hidden | verdict | Y/U/V | | ||
| 69 | +|---|---|---|---|---|---| | ||
| 70 | +| `s420_320x240` | 320x240 ss 1,1 d8 | 17 / 16 | `[1]` | BYTE-EXACT | 0/0/0 | | ||
| 71 | +| `s420_320x246` | 320x246 ss 1,1 d8 | 17 / 16 | `[16]` (2 assignments, counts agree) | BYTE-EXACT | 0/0/0 | | ||
| 72 | +| `s420_352x242_10b` | 352x242 ss 1,1 d10 | 17 / 16 | `[16]` (2 assignments) | BYTE-EXACT | 0/0/0 | | ||
| 73 | +| `s444_320x240` | 320x240 ss 0,0 d8 | 17 / 16 | `[1]` | BYTE-EXACT | 0/0/0 | | ||
| 74 | +| `s444_320x242_10b` | 320x242 ss 0,0 d10 | 17 / 16 | `[1]` | BYTE-EXACT | 0/0/0 | | ||
| 75 | + | ||
| 76 | +Two of them are the 10-bit class and two are the **2-solution** mapping class, so | ||
| 77 | +the mapping rule is exercised, not assumed. The 4:2:2 cells are re-measured | ||
| 78 | +against the same pipeline in §3, where a non-zero baseline is reported — the | ||
| 79 | +instrument is shown reading a plane that is already wrong by thousands. | ||
| 80 | + | ||
| 81 | +**NOT DONE — the flip control.** The intended next control (flip one ffmpeg sample | ||
| 82 | +per plane and require exactly `+1` in that plane, `0` everywhere else, on a | ||
| 83 | +non-zero baseline) is scripted as `flipctl.py` in the census scratch but was **not | ||
| 84 | +executed**; §6 repeats this. What stands in its place is weaker and is named as | ||
| 85 | +such: the instrument reports per-plane counts that move by thousands on the | ||
| 86 | +diverging cells while the two formats it must not touch (4:2:0, 4:4:4) read | ||
| 87 | +`0/0/0` on five cells, and the unwritten-sample census of §4 is a completely | ||
| 88 | +independent witness to the same region. | ||
| 89 | + | ||
| 90 | +--- | ||
| 91 | + | ||
| 92 | +## 2. The five slice cells, reproduced | ||
| 93 | + | ||
| 94 | +`/home/user/.cache/census422b/sweep/<cell>.obu`, ffmpeg 8.1.3, our side | ||
| 95 | +`EC_AV1_FINAL_DUMP`. Counts are wrong **samples**, summed over the 16 **shown** | ||
| 96 | +frames (the hidden picture is not in ffmpeg's output and is reported separately). | ||
| 97 | + | ||
| 98 | +| cell | geometry | depth | decode / shown | hidden | pre Y/U/V | first divergence | | ||
| 99 | +|---|---|---|---|---|---|---| | ||
| 100 | +| `s422_322x240` | 322x240 | 8 | 17 / 16 | `[1]` | 0 / **22003** / **21625** | disp f0 (decode f0) **U (r62, c149)** ours 160 ffmpeg 166 | | ||
| 101 | +| `s422_320x246` | 320x246 | 8 | 17 / 16 | `[1]` | 0 / **7810** / **5531** | disp f0 (decode f0) **U (r62, c144)** ours 161 ffmpeg 166 | | ||
| 102 | +| `s422_322x246` | 322x246 | 8 | 17 / 16 | `[1]` | 0 / **3437** / **2222** | disp f0 (decode f0) **U (r62, c144)** ours 169 ffmpeg 166 | | ||
| 103 | +| `s422_352x242_10b` | 352x242 | 10 | 17 / 16 | `[1]` | 0 / **4653** / **3777** | disp f0 (decode f0) **U (r62, c160)** ours 667 ffmpeg 664 | | ||
| 104 | +| `s422_416x242_10b` | 416x242 | 10 | 17 / 16 | `[1]` | 0 / **5740** / **4348** | disp f0 (decode f0) **U (r62, c192)** ours 640 ffmpeg 664 | | ||
| 105 | + | ||
| 106 | +All five: **chroma only, luma exact on every shown frame**, first divergence in | ||
| 107 | +decode frame 0, wrong region reaching every frame. | ||
| 108 | + | ||
| 109 | +**Answer to the brief's question 4 — do the 10-bit members fail for the same | ||
| 110 | +reason?** *Mechanically yes, numerically no.* All five first-diverge in decode | ||
| 111 | +frame 0, plane U, and in every case the first wrong **row is 62**; the first wrong | ||
| 112 | +**column** is `chroma_width - 16` in chroma-sample units for four of the five | ||
| 113 | +(320→144, 322x246→144 of 161, 352→160 of 176, 416→192 of 208) and | ||
| 114 | +`chroma_width - 12` for `s422_322x240` (149 of 161, the first *scanning* column of | ||
| 115 | +that row, not the region's left edge). The seed block is the **same shape and the | ||
| 116 | +same relative position** in all five (8.4 §4.2), and the per-frame counts differ | ||
| 117 | +only because the 10-bit cells are wider. So: one defect, five geometries — not a | ||
| 118 | +depth-specific one. (This is also the census's own conclusion, reached | ||
| 119 | +independently: "bit depth does not separate them".) | ||
| 120 | + | ||
| 121 | +Counts are lower than the census's `0/8339/5903`-style figures by exactly the | ||
| 122 | +hidden picture's contribution (e.g. `s422_320x246`: 8339 − 7810 = 529 U, | ||
| 123 | +5903 − 5531 = 372 V), which is the expected difference between a 17-decode-frame | ||
| 124 | +and a 16-shown-frame basis and confirms both measurements agree. | ||
| 125 | + | ||
| 126 | +--- | ||
| 127 | + | ||
| 128 | +## 3. The seed: an unwritten-sample census, not a diff pattern | ||
| 129 | + | ||
| 130 | +A wrong-sample diff says *where the output is wrong*; it cannot say *whether the | ||
| 131 | +block was written at all*. The crate already carries the instrument for that | ||
| 132 | +question: `fresh_plane` (`decode.rs:21123`) leaves the plane backing store | ||
| 133 | +**uninitialised** and fills it with `PLANE_SENTINEL = 0xDEAD` under | ||
| 134 | +`EC_AV1_PLANE_SENTINEL=1`. Every sample reconstruction writes is overwritten; | ||
| 135 | +every sample it does not write still reads `0xDEAD`. A scan of the three planes at | ||
| 136 | +the frame's pre-deblock point is then an exact census of unwritten samples. | ||
| 137 | + | ||
| 138 | +Run on `s422_320x246.obu`, **decode frame 0**: | ||
| 139 | + | ||
| 140 | +``` | ||
| 141 | +SEEDUNWRITTEN plane=0 320x256 runs=0 | ||
| 142 | +SEEDUNWRITTEN plane=1 160x256 runs=4 | ||
| 143 | + plane=1 row=128 cols=144..151 | ||
| 144 | + plane=1 row=129 cols=144..151 | ||
| 145 | + plane=1 row=130 cols=144..151 | ||
| 146 | + plane=1 row=131 cols=144..151 | ||
| 147 | +SEEDUNWRITTEN plane=2 160x256 runs=4 | ||
| 148 | + plane=2 row=128 cols=144..151 | ||
| 149 | + plane=2 row=129 cols=144..151 | ||
| 150 | + plane=2 row=130 cols=144..151 | ||
| 151 | + plane=2 row=131 cols=144..151 | ||
| 152 | +``` | ||
| 153 | + | ||
| 154 | +**Luma: nothing unwritten. U and V: one 4×8 block each, chroma rows 128..131, | ||
| 155 | +cols 144..151, and nothing else in the frame.** So the 16×16 luma region at luma | ||
| 156 | +(288, 128) is fully reconstructed while its chroma half — 8×4 per plane — is | ||
| 157 | +**never written at all**. (The census scan is a temporary local edit and is not | ||
| 158 | +committed; it is four lines at the `dump_stage16` call in `decode_frame`.) | ||
| 159 | + | ||
| 160 | +A lowest-level write trace (the three `PlaneBuf` sinks — `reconstruct`, | ||
| 161 | +`reconstruct_rect`, `reconstruct_mc_rect` — are the only writers of a plane in this | ||
| 162 | +tree) then names the block, and frame 0 contains exactly **three** MC writes: | ||
| 163 | + | ||
| 164 | +``` | ||
| 165 | +SEEDWR3 reconstruct_mc_rect x=288 y=128 plane=0 w=16 h=4 | ||
| 166 | +SEEDWR3 reconstruct_mc_rect x=144 y=62 plane=1 w=8 h=4 | ||
| 167 | +SEEDWR3 reconstruct_mc_rect x=144 y=62 plane=2 w=8 h=4 | ||
| 168 | +``` | ||
| 169 | + | ||
| 170 | +One 16×4 **luma** write at (288, 128) — the strip's own footprint, and it is | ||
| 171 | +exact — and one 8×4 **chroma** write per plane, at **(144, 62)** instead of | ||
| 172 | +(144, 128). The 8×4 shape is right; the **row is 66 too high**, and the strip's | ||
| 173 | +own chroma is the block the census found unwritten. That is the whole defect: | ||
| 174 | +one write, landing in the wrong row. | ||
| 175 | + | ||
| 176 | +### 3.1 The owning arm | ||
| 177 | + | ||
| 178 | +`decode.rs:18162 fn decode_rect4_16_intrabc` — reconstruction of one **intrabc | ||
| 179 | +16×4 / 4×16 strip** (a 1:4 partition strip; `is_inter_block` counts intrabc, so | ||
| 180 | +its luma is a frame copy through the MC path, which is why the luma write is an | ||
| 181 | +MC write and not `reconstruct_rect`). | ||
| 182 | + | ||
| 183 | +The function's own doc comment states the 4:2:0 pair rule: *"A 1:4 strip is a | ||
| 184 | +PAIR. Both children share one chroma block, and only the odd-mi member codes it | ||
| 185 | +(`is_chroma_reference`, `av1_common_int.h:1454`) … `setup_pred_plane`'s | ||
| 186 | +`mi_row -= 1` when the block is one mi tall on an odd row."* That rule is applied | ||
| 187 | +at every `ss` except 4:4:4, which got its own `own444` arm (lane-av1444rect r2). | ||
| 188 | +**4:2:2 is the second `ss` where the rule does not hold, and it was never given | ||
| 189 | +an arm.** The three constants that carry it, at `main`: | ||
| 190 | + | ||
| 191 | +| site | `main` | what 4:2:2 needs | value on the seed strip (`lmi = (32, 72)`, HORZ) | | ||
| 192 | +|---|---|---|---| | ||
| 193 | +| `decode.rs:18244` `cw, ch` | `(pw/2, ph/2)` = `(8, 4)` | `ss_size_lookup[BLOCK_16X4][1][0]` | `(8, 4)` — **accidentally already right** | | ||
| 194 | +| `decode.rs:18246` `pair_mi` | `(lmi.0 - 1, lmi.1)` = `(31, 72)` | no pair: `lmi` | `(32, 72)` | | ||
| 195 | +| `decode.rs:18256` `cpx, cpy` | `(pair_mi.1*MI/2, pair_mi.0*MI/2)` = `(144, 62)` | `(px>>ss_x, py>>ss_y)` | **`(144, 128)`** | | ||
| 196 | + | ||
| 197 | +and the two chroma coefficient-context gathers that must move **with** them, | ||
| 198 | +`decode.rs:18574` and `decode.rs:18635`: | ||
| 199 | + | ||
| 200 | +```rust | ||
| 201 | +let around = neighbours.around_mi_rect(pair_mi, pw, ph); | ||
| 202 | +``` | ||
| 203 | + | ||
| 204 | +The libaom clause that decides it, `av1_common_int.h:1454`'s `is_chroma_reference`, | ||
| 205 | +ends in | ||
| 206 | + | ||
| 207 | +```c | ||
| 208 | + ... || (g->subsampling_x == 1 && g->subsampling_y == 0) || (mi_col & 1) || (mi_row & 1); | ||
| 209 | +``` | ||
| 210 | + | ||
| 211 | +so at ss (1, 0) it answers **true for every block**: no pair, every strip codes | ||
| 212 | +its own chroma, at its own origin, with its context gathered over its own extent | ||
| 213 | +(and through `around_mi_422_chroma`, the every-second-column 4:2:2 gather every | ||
| 214 | +other 4:2:2 chroma context read in this tree already uses). | ||
| 215 | + | ||
| 216 | +**The census's `first divergence U(62,144)` is this write.** The block at chroma | ||
| 217 | +(144, 62) is the block the census's first-divergence coordinates name; the block | ||
| 218 | +at (144, 128) is the one the census's "shrunk region, origin unmoved" table could | ||
| 219 | +not see, because nothing was ever written there. | ||
| 220 | + | ||
| 221 | +### 3.2 The same shape in all five cells | ||
| 222 | + | ||
| 223 | +The unwritten census was run on `s422_320x246` only; the *diff* geometry is | ||
| 224 | +reported for the other four by `scripts/shape422-diff.py`. In every cell the | ||
| 225 | +frame-0 wrong region is a single 8-wide chroma column band, **16 chroma columns | ||
| 226 | +from the right edge** (320→144 of 160, 322→144 of 161, 352→160 of 176, 416→192 of | ||
| 227 | +208) at chroma rows 62..65 and 128..131 — the two rows of §3 and of §4.1. Same | ||
| 228 | +strip family, same two-row-pair displacement, five geometries. | ||
| 229 | + | ||
| 230 | +--- | ||
| 231 | + | ||
| 232 | +## 4. The attempted fix, and why it is not landed | ||
| 233 | + | ||
| 234 | +The write-side half of the fix, applied and measured (this is the change that is | ||
| 235 | +**not** in the tree): | ||
| 236 | + | ||
| 237 | +```rust | ||
| 238 | +let own422 = ss_x(fctx) == 1 && ss_y(fctx) == 0 && horz; | ||
| 239 | +if own422 && has_chroma { hit!(INTRABC_RECT4_OWN_CHROMA422_HITS); } | ||
| 240 | +let (cw, ch) = if own444 || own422 { (bw >> ss_x(fctx), bh >> ss_y(fctx)) } else { (pw/2, ph/2) }; | ||
| 241 | +let pair_mi = if has_chroma { if own444 || own422 { lmi } else if horz { (lmi.0-1, lmi.1) } else { (lmi.0, lmi.1-1) } } else { lmi }; | ||
| 242 | +let (cpx, cpy) = if has_chroma { if own444 || own422 { (px >> ss_x(fctx), py >> ss_y(fctx)) } else { (pair_mi.1*MI/2, pair_mi.0*MI/2) } } else { (0, 0) }; | ||
| 243 | +``` | ||
| 244 | + | ||
| 245 | +plus a new gate counter `INTRABC_RECT4_OWN_CHROMA422_HITS` / | ||
| 246 | +`intrabc_rect4_own_chroma422_hits()` (the ss (1,0) twin of the existing | ||
| 247 | +`INTRABC_RECT4_OWN_CHROMA444_HITS`). | ||
| 248 | + | ||
| 249 | +VERT_4 is deliberately **not** claimed: `ss_size_lookup[BLOCK_4X16][1][0]` is | ||
| 250 | +`BLOCK_INVALID` at ss (1,0), so only the pair shape is codable for a 4×16 strip — | ||
| 251 | +the same statement `decode_block_rect4` already carries. | ||
| 252 | + | ||
| 253 | +**Measured result: it regresses luma.** | ||
| 254 | + | ||
| 255 | +| build | `s422_320x246` frame-0 luma wrong samples | five cells | | ||
| 256 | +|---|---|---| | ||
| 257 | +| `main` (`affe70dc`) | **0** | 0/7810/5531, 0/22003/21625, 0/3437/2222, 0/4653/3777, 0/5740/4348 (chroma only) | | ||
| 258 | +| + write-side fix, gathers untouched | **5958** | all five fail luma identity | | ||
| 259 | +| + write-side fix + `around_mi_rect(pair_mi, pw, ph)` → `(gmi, gw, gh)` = `(lmi, bw, bh)` and routed through `around_mi_422_chroma` | **5958** | all five still fail luma identity | | ||
| 260 | + | ||
| 261 | +The control is exact and cheap: `git stash push crates/ec-av1/src/decode.rs`, | ||
| 262 | +rebuild, re-run → the `main` numbers above reproduce to the sample | ||
| 263 | +(0/7810/5531 etc.), so the pipeline is not drifting and the regression is the | ||
| 264 | +change's. The decode is deterministic (two runs of the same binary, frames 0..3, | ||
| 265 | +`SAME` sha256 on all four), so this is not a flake. | ||
| 266 | + | ||
| 267 | +**Reading.** The write-side constants and the entropy-side gather are the *same* | ||
| 268 | +misapplication, and moving the write alone turns a reconstruction defect into an | ||
| 269 | +**entropy desync** that corrupts luma for the rest of the frame — the classic | ||
| 270 | +`reconstruction-only vs parse` split. My second attempt moved the gather too, by | ||
| 271 | +the same `own422` predicate, and did not restore luma, which says the remaining | ||
| 272 | +half is **not** in `around_mi_rect`'s extent alone. The untested candidates, in | ||
| 273 | +order: | ||
| 274 | + | ||
| 275 | +1. **`has_chroma` itself.** The caller decides whether a strip codes chroma by | ||
| 276 | + mi parity. At ss (1,0) *every* strip does (`is_chroma_reference`'s clause), so | ||
| 277 | + an even-row HORZ strip that our tree currently passes `has_chroma = false` must | ||
| 278 | + become `true` — which adds a chroma coefficient read and changes the parse. If | ||
| 279 | + the caller already passes `true` for all HORZ strips at 4:2:2, this is not it. | ||
| 280 | +2. **`rect_inter_chroma_set(cw, ch)`** and the `TxbSet` chosen for an 8×4 chroma | ||
| 281 | + unit at ss (1,0) — the entropy class, not the extent. | ||
| 282 | +3. The **coefficient context row/offset** for a chroma unit whose plane block is | ||
| 283 | + 8×4 at ss (1,0) (`around_mi_422_chroma`'s every-second-column sampling plus the | ||
| 284 | + offset-7/offset-10 rows). | ||
| 285 | + | ||
| 286 | +Agent07-4 (`lane-av1422luma`, cell `s422_416x250_10b`) independently localised a | ||
| 287 | +**luma** desync in this same function, to the same `own444` pair-geometry block | ||
| 288 | +and the `around_mi_rect(pair_mi, pw, ph)` gather. Two lanes converging on one | ||
| 289 | +function is the strongest signal in this report: **the 4:2:2 arm of | ||
| 290 | +`decode_rect4_16_intrabc` does not exist and has to be written whole** — origin, | ||
| 291 | +extent, `has_chroma`, entropy set and context gather together — not patched in | ||
| 292 | +pieces. Ownership was split by message: Agent07-4 takes the entropy side, this | ||
| 293 | +lane's write-side hunk is described above and is not landed. | ||
| 294 | + | ||
| 295 | +--- | ||
| 296 | + | ||
| 297 | +## 5. Per-plane, per-frame numbers | ||
| 298 | + | ||
| 299 | +Pre-fix (this lane's instrument, ffmpeg oracle, 16 shown frames): | ||
| 300 | + | ||
| 301 | +| cell | Y | U | V | | ||
| 302 | +|---|---|---|---| | ||
| 303 | +| `s422_322x240` | 0 | 22003 | 21625 | | ||
| 304 | +| `s422_320x246` | 0 | 7810 | 5531 | | ||
| 305 | +| `s422_322x246` | 0 | 3437 | 2222 | | ||
| 306 | +| `s422_352x242_10b` | 0 | 4653 | 3777 | | ||
| 307 | +| `s422_416x242_10b` | 0 | 5740 | 4348 | | ||
| 308 | + | ||
| 309 | +Per-frame U counts, `s422_320x246` (display order, 16 frames): | ||
| 310 | +`58 269 308 371 410 348 580 608 620 634 621 655 640 575 584 529` — wrong in | ||
| 311 | +**every** frame, growing with the altref's reference use, which is what a | ||
| 312 | +frame-0 seed that later frames predict from looks like. | ||
| 313 | + | ||
| 314 | +Post-fix: **none** — the change is not landed. | ||
| 315 | + | ||
| 316 | +**4:2:0 and 4:4:4 controls after the change attempt:** unchanged, `0/0/0` on all | ||
| 317 | +five control cells (§1.1 re-run with the change in the tree: 5/5 BYTE-EXACT). The | ||
| 318 | +attempt is 4:2:2-specific in blast radius — it breaks 4:2:2 luma and touches | ||
| 319 | +nothing else. | ||
| 320 | + | ||
| 321 | +--- | ||
| 322 | + | ||
| 323 | +## 6. Family sweep (the class, repo-wide in this corpus) | ||
| 324 | + | ||
| 325 | +All 18 `s422_*` sweep cells, same instrument, with the change **not** applied | ||
| 326 | +(`main`), which is the honest baseline for whoever takes the arm next: | ||
| 327 | + | ||
| 328 | +| verdict | cells | | ||
| 329 | +|---|---| | ||
| 330 | +| BYTE-EXACT | 12 — `320x240`, `320x242`, `320x242_10b`, `320x250_10b`, `322x242`, `326x240`, `326x242`, `326x246`, `352x250_10b`, `384x242`, `384x246` (+ the 5 targets' siblings) | | ||
| 331 | +| DIVERGES, chroma only | `s422_384x240` — **0 / 1780 / 1871**; first bad frame 1 per the census, i.e. a **different, later** seed | | ||
| 332 | +| instrument error (luma identity does not cover the display side) | `s422_320x246`, `s422_322x240`, `s422_322x246`, `s422_352x242_10b`, `s422_416x242_10b`, `s422_416x250_10b` — the five slice cells plus `416x250_10b`, measured **with the change in the tree**; each is a luma-corrupting desync, not a count | | ||
| 333 | + | ||
| 334 | +Run against `main` instead, the five slice cells read the §2 numbers and | ||
| 335 | +`s422_416x250_10b` reads the census's luma-wrong row. The sweep is here so the | ||
| 336 | +next lane does not have to re-derive it: **`s422_384x240` is not this defect** | ||
| 337 | +(its first bad frame is 1, and its region is not the 16-columns-from-the-right | ||
| 338 | +band), so closing this arm should leave exactly one 4:2:2 cell diverging in the | ||
| 339 | +sweep. | ||
| 340 | + | ||
| 341 | +## 7. What is NOT measured | ||
| 342 | + | ||
| 343 | +* **The flip control was not run.** §1.1's controls are the five byte-exact cells, | ||
| 344 | + not the sample-flip arms. Nothing here should be read as "the comparator was | ||
| 345 | + proven to bite by a flip". | ||
| 346 | +* **No permanent gate was added.** The brief asked for a gate in the crate's test | ||
| 347 | + binary naming a cell; with the fix unlanded a gate would have to assert a | ||
| 348 | + *failure*, and a gate that asserts a known defect is not a gate. The | ||
| 349 | + `INTRABC_RECT4_OWN_CHROMA422_HITS` counter is the hook such a gate will need; | ||
| 350 | + the non-vacuity argument for it will be "this cell moves 5958 luma samples when | ||
| 351 | + the arm is wrong", not a count. | ||
| 352 | +* **`s422_384x240` and the 4:4:4 `s444_352x242_10b` residual are untouched** and | ||
| 353 | + are not this arm. | ||
| 354 | +* The 4:2:2 sequence-header refusal is **untouched** — `stream.rs:1803` reads | ||
| 355 | + `if seq.subsampling_x != seq.subsampling_y` on this branch, verified by | ||
| 356 | + `git status` clean for that file. | ||
| 357 | +* `s422_416x250_10b`'s luma desync is Agent07-4's slice; this report only records | ||
| 358 | + that it is in the same function. | ||
| 359 | + | ||
| 360 | +## 8. Reproducing this lane's numbers | ||
| 361 | + | ||
| 362 | +```sh | ||
| 363 | +# 1. the bypass (LOCAL ONLY, never commit) | ||
| 364 | +# crates/ec-av1/src/stream.rs:1803 -> if false && seq.subsampling_x != seq.subsampling_y { | ||
| 365 | +CARGO_TARGET_DIR=/tmp/tgt cargo build -p ec-av1 --example decode_probe --features gate-counters | ||
| 366 | + | ||
| 367 | +# 2. the five cells + the five controls, against ffmpeg 8.1.3 | ||
| 368 | +python3 scripts/run422-ffmpeg.py <cells.json> <out.json> | ||
| 369 | + | ||
| 370 | +# 3. the frame-0 unwritten-sample census (temporary four-line scan, see §3) | ||
| 371 | +EC_AV1_PLANE_SENTINEL=1 <probe> sweep/s422_320x246.obu | ||
| 372 | + | ||
| 373 | +# 4. the wrong-region geometry, per cell | ||
| 374 | +python3 scripts/shape422-diff.py s422_320x246 sweep/s422_320x246.obu | ||
| 375 | +``` | ||
| 376 | + | ||
| 377 | +`cells.json` entries are `{"name": ..., "path": ...}`. The comparator derives | ||
| 378 | +geometry from the sequence header itself and needs no other argument; it raises | ||
| 379 | +rather than reporting a count it cannot justify. | ||
scripts/cmp422-ffmpeg.pyadded+242 -0
| @@ -0,0 +1,242 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +"""ffmpeg pixel-oracle comparator for ec-av1 4:2:2 (and 4:2:0 / 4:4:4 controls). | ||
| 3 | + | ||
| 4 | +Discipline (oracle-comparator-liveness-control): | ||
| 5 | + | ||
| 6 | +1. Geometry is an EXPLICIT argument read from the SEQUENCE HEADER via ffprobe | ||
| 7 | + (coded_width / coded_height / pix_fmt of the AV1 stream), never derived | ||
| 8 | + from a file size. A raw frame whose byte length disagrees with the geometry | ||
| 9 | + is a hard error. | ||
| 10 | +2. Plane attribution is per FRAME, from that frame's own plane lengths, with a | ||
| 11 | + monotone cursor -- never absolute thresholds from frame 0. | ||
| 12 | +3. A wrong SAMPLE is one bps-wide unit. At 10 bit the comparator walks | ||
| 13 | + 16-bit LE samples, so the top bits cannot hide. | ||
| 14 | +4. A count over zero frames is a hard error (vacuous 0/0/0). | ||
| 15 | +5. Decode-order (ours, EC_AV1_FINAL_DUMP) -> display-order (ffmpeg rawvideo) | ||
| 16 | + mapping is derived by LUMA-IDENTITY content match under a strictly | ||
| 17 | + increasing assignment, then re-verified per frame. Exactly one decode frame | ||
| 18 | + must have no display partner: the hidden alt-ref picture. | ||
| 19 | +""" | ||
| 20 | +import json | ||
| 21 | +import os | ||
| 22 | +import re | ||
| 23 | +import subprocess | ||
| 24 | +import sys | ||
| 25 | + | ||
| 26 | +SS = {"420": (1, 1), "422": (1, 0), "444": (0, 0), "440": (0, 1)} | ||
| 27 | +DEPTH_RE = re.compile(r"^yuv(\d{3})p(\d*)(?:le)?$") | ||
| 28 | + | ||
| 29 | + | ||
| 30 | +def probe_geometry(obu): | ||
| 31 | + """ffprobe reads the AV1 SEQUENCE HEADER: coded_width/coded_height and the | ||
| 32 | + chroma format/depth it implies. Never the raw output's byte length.""" | ||
| 33 | + r = subprocess.run(["ffprobe", "-v", "error", "-select_streams", "v", | ||
| 34 | + "-show_entries", "stream=coded_width,coded_height,pix_fmt", | ||
| 35 | + "-of", "csv=p=0", obu], capture_output=True, check=True) | ||
| 36 | + parts = r.stdout.decode().strip().split(",") | ||
| 37 | + mw, h, pix = parts[0], parts[1], parts[2] | ||
| 38 | + m = DEPTH_RE.match(pix) | ||
| 39 | + if not m: | ||
| 40 | + raise SystemExit(f"{obu}: unsupported pix_fmt {pix!r} (need a planar yuv*p[le])") | ||
| 41 | + ss = SS.get(m.group(1)) | ||
| 42 | + if ss is None: | ||
| 43 | + raise SystemExit(f"{obu}: unknown chroma tag C{m.group(1)} in pix_fmt {pix!r}") | ||
| 44 | + depth = int(m.group(2)) if m.group(2) else 8 | ||
| 45 | + return int(mw), int(h), ss[0], ss[1], depth, pix | ||
| 46 | + | ||
| 47 | + | ||
| 48 | +def plane_spans(w, h, ss_x, ss_y, bps): | ||
| 49 | + cw = -(-w // (1 << ss_x)) | ||
| 50 | + ch = -(-h // (1 << ss_y)) | ||
| 51 | + sizes = (w * h, cw * ch, cw * ch) | ||
| 52 | + return sizes, sum(sizes) * bps | ||
| 53 | + | ||
| 54 | + | ||
| 55 | +def frame_files(prefix): | ||
| 56 | + out, i = [], 0 | ||
| 57 | + while os.path.isfile(f"{prefix}.f{i}"): | ||
| 58 | + out.append(f"{prefix}.f{i}") | ||
| 59 | + i += 1 | ||
| 60 | + return out | ||
| 61 | + | ||
| 62 | + | ||
| 63 | +def ffmpeg_frames(obu, pix): | ||
| 64 | + r = subprocess.run(["ffmpeg", "-v", "error", "-i", obu, "-f", "rawvideo", | ||
| 65 | + "-pix_fmt", pix, "-"], capture_output=True) | ||
| 66 | + if r.returncode != 0: | ||
| 67 | + raise SystemExit(f"{obu}: ffmpeg refused: {r.stderr.decode()[-300:]}") | ||
| 68 | + return r.stdout | ||
| 69 | + | ||
| 70 | + | ||
| 71 | +def split(raw, sizes, fsz, cell): | ||
| 72 | + if not raw: | ||
| 73 | + raise SystemExit(f"{cell}: ffmpeg produced ZERO bytes -- a 0/0/0 here is vacuous") | ||
| 74 | + if len(raw) % fsz: | ||
| 75 | + raise SystemExit(f"{cell}: ffmpeg rawvideo is {len(raw)} B, not a whole " | ||
| 76 | + f"multiple of the {fsz} B frame the geometry implies") | ||
| 77 | + return [raw[i * fsz:(i + 1) * fsz] for i in range(len(raw) // fsz)] | ||
| 78 | + | ||
| 79 | + | ||
| 80 | +def _matchings(cands, disp_n, cap=64): | ||
| 81 | + """Every way to assign each decode frame either a distinct display partner | ||
| 82 | + or the hidden role, covering the display side exactly. Enumerated, not | ||
| 83 | + guessed: a duplicated picture can make the assignment genuinely ambiguous, | ||
| 84 | + and the caller then has to show the ambiguity does not change the answer.""" | ||
| 85 | + sols = [] | ||
| 86 | + | ||
| 87 | + def dfs(i, used, acc, hid): | ||
| 88 | + if len(sols) >= cap: | ||
| 89 | + return | ||
| 90 | + if i == len(cands): | ||
| 91 | + if len(used) == disp_n: | ||
| 92 | + sols.append((dict(acc), list(hid))) | ||
| 93 | + return | ||
| 94 | + for di in cands[i]: | ||
| 95 | + if di not in used: | ||
| 96 | + used.add(di) | ||
| 97 | + acc[i] = di | ||
| 98 | + dfs(i + 1, used, acc, hid) | ||
| 99 | + del acc[i] | ||
| 100 | + used.discard(di) | ||
| 101 | + hid.append(i) | ||
| 102 | + dfs(i + 1, used, acc, hid) | ||
| 103 | + hid.pop() | ||
| 104 | + | ||
| 105 | + dfs(0, set(), {}, []) | ||
| 106 | + return sols | ||
| 107 | + | ||
| 108 | + | ||
| 109 | +def map_decode_to_display(ours, disp, sizes, bps, cell): | ||
| 110 | + """Identity of each decode-order frame is carried by its LUMA plane; full-frame | ||
| 111 | + identity is preferred when it exists. Every assignment that covers the | ||
| 112 | + display side is enumerated, so a duplicated picture shows up as an | ||
| 113 | + explicit solution COUNT rather than a silent pick. Real altref streams | ||
| 114 | + REORDER display against decode (measured: decode f2..f8 -> display | ||
| 115 | + 7,3,1,2,5,4,6), so no monotonicity prior is applied -- an unjustified one | ||
| 116 | + is exactly the class of silent mismatch this instrument exists to catch.""" | ||
| 117 | + luma = sizes[0] * bps | ||
| 118 | + for use_full in (True, False): | ||
| 119 | + cands = [[di for di, d in enumerate(disp) | ||
| 120 | + if o[:luma] == d[:luma] and (o == d or not use_full)] for o in ours] | ||
| 121 | + sols = _matchings(cands, len(disp)) | ||
| 122 | + if sols: | ||
| 123 | + if min(len(h) for _, h in sols) > 4: | ||
| 124 | + raise SystemExit(f"{cell}: {min(len(h) for _, h in sols)} decode frames have " | ||
| 125 | + f"no luma-identical display partner -- LUMA itself " | ||
| 126 | + f"diverges, so this is not a hidden-alt-ref count " | ||
| 127 | + f"(class av1-frame-count-vs-pixel-divergence)") | ||
| 128 | + return sols | ||
| 129 | + raise SystemExit(f"{cell}: luma identity never covers the display side " | ||
| 130 | + f"({len(ours)} decode frames, {len(disp)} display frames) " | ||
| 131 | + f"-- the frame-count or per-frame identity claim is wrong") | ||
| 132 | + | ||
| 133 | + | ||
| 134 | + | ||
| 135 | +def compare(cell, ours_prefix, disp, w, h, ss_x, ss_y, depth, want_hidden=None): | ||
| 136 | + bps = 1 if depth <= 8 else 2 | ||
| 137 | + sizes, fsz = plane_spans(w, h, ss_x, ss_y, bps) | ||
| 138 | + ours = [open(p, "rb").read() for p in frame_files(ours_prefix)] | ||
| 139 | + if not ours: | ||
| 140 | + raise SystemExit(f"{cell}: no EC_AV1_FINAL_DUMP frames from us -- vacuous 0/0/0") | ||
| 141 | + for i, o in enumerate(ours): | ||
| 142 | + if len(o) != fsz: | ||
| 143 | + raise SystemExit(f"{cell}: our decode frame {i} is {len(o)} B, geometry " | ||
| 144 | + f"{w}x{h} ss={ss_x}{ss_y} depth={depth} implies {fsz} B") | ||
| 145 | + sols = map_decode_to_display(ours, disp, sizes, bps, cell) | ||
| 146 | + | ||
| 147 | + def measure(mapping, hidden): | ||
| 148 | + tot = [0, 0, 0] | ||
| 149 | + per_disp = [[0, 0, 0] for _ in disp] | ||
| 150 | + per_dec, first = [], None | ||
| 151 | + bb_all = [[None, None, None, None] for _ in range(3)] | ||
| 152 | + for oi, a in enumerate(ours): | ||
| 153 | + if oi in hidden: | ||
| 154 | + per_dec.append(None) | ||
| 155 | + continue | ||
| 156 | + b = disp[mapping[oi]] | ||
| 157 | + fcount, off = [0, 0, 0], 0 | ||
| 158 | + for pi, sz in enumerate(sizes): | ||
| 159 | + pw = w if pi == 0 else -(-w // (1 << ss_x)) | ||
| 160 | + for i in range(sz): | ||
| 161 | + s = i * bps | ||
| 162 | + if a[off + s:off + s + bps] != b[off + s:off + s + bps]: | ||
| 163 | + fcount[pi] += 1 | ||
| 164 | + tot[pi] += 1 | ||
| 165 | + per_disp[mapping[oi]][pi] += 1 | ||
| 166 | + r, c = divmod(i, pw) | ||
| 167 | + bb = bb_all[pi] | ||
| 168 | + if bb[0] is None or r < bb[0]: | ||
| 169 | + bb[0] = r | ||
| 170 | + if bb[1] is None or r > bb[1]: | ||
| 171 | + bb[1] = r | ||
| 172 | + if bb[2] is None or c < bb[2]: | ||
| 173 | + bb[2] = c | ||
| 174 | + if bb[3] is None or c > bb[3]: | ||
| 175 | + bb[3] = c | ||
| 176 | + if first is None: | ||
| 177 | + first = (mapping[oi], oi, "YUV"[pi], r, c, | ||
| 178 | + int.from_bytes(a[off + s:off + s + bps], "little"), | ||
| 179 | + int.from_bytes(b[off + s:off + s + bps], "little")) | ||
| 180 | + off += sz * bps | ||
| 181 | + per_dec.append(fcount) | ||
| 182 | + return tot, per_disp, per_dec, first, bb_all | ||
| 183 | + | ||
| 184 | + measured = [measure(m, h) for m, h in sols] | ||
| 185 | + totals = {tuple(t[0]) for t in measured} | ||
| 186 | + if len(totals) > 1: | ||
| 187 | + raise SystemExit(f"{cell}: the decode->display assignment is AMBIGUOUS " | ||
| 188 | + f"({len(sols)} solutions) and they DISAGREE on the counts " | ||
| 189 | + f"{sorted(totals)} -- pick the identity source explicitly, " | ||
| 190 | + f"this instrument will not choose for you") | ||
| 191 | + tot, per_disp, per_dec, first, bbox = measured[0] | ||
| 192 | + mapping, hidden = sols[0] | ||
| 193 | + if want_hidden is not None and len(hidden) != want_hidden: | ||
| 194 | + raise SystemExit(f"{cell}: {len(hidden)} hidden decode frame(s) {hidden}, " | ||
| 195 | + f"expected {want_hidden} -- the frame-count claim changed") | ||
| 196 | + return {"cell": cell, "status": "BYTE-EXACT" if tot == [0, 0, 0] else "DIVERGES", | ||
| 197 | + "w": w, "h": h, "ss": f"{ss_x}{ss_y}", "depth": depth, "pix": pix_of(ss_x, ss_y, depth), | ||
| 198 | + "decode_frames": len(ours), "display_frames": len(disp), | ||
| 199 | + "hidden_decode": hidden, "mapping_solutions": len(sols), | ||
| 200 | + "Y": tot[0], "U": tot[1], "V": tot[2], | ||
| 201 | + "first": first, "bbox": bbox, | ||
| 202 | + "per_decode_frame": per_dec, "per_display_frame": per_disp} | ||
| 203 | + | ||
| 204 | + | ||
| 205 | +def pix_of(ss_x, ss_y, depth): | ||
| 206 | + tag = next(k for k, v in SS.items() if v == (ss_x, ss_y)) | ||
| 207 | + return f"yuv{tag}p" + ("" if depth <= 8 else f"{depth}le") | ||
| 208 | + | ||
| 209 | + | ||
| 210 | +def flip(disp, sizes, bps, disp_index, plane, sample_index): | ||
| 211 | + """Flip bit 0 of one oracle SAMPLE's low byte: exactly +1 wrong sample in | ||
| 212 | + both depths (2**bitdepth < 2**16, so nothing carries out of the container). | ||
| 213 | + Returns a new list; the caller drops it to restore.""" | ||
| 214 | + new = list(disp) | ||
| 215 | + buf = bytearray(new[disp_index]) | ||
| 216 | + buf[sum(sizes[:plane]) * bps + sample_index * bps] ^= 1 | ||
| 217 | + new[disp_index] = bytes(buf) | ||
| 218 | + return new | ||
| 219 | + | ||
| 220 | + | ||
| 221 | +def run(cell, obu, ours_prefix, want_hidden=None, json_out=False): | ||
| 222 | + w, h, ssx, ssy, depth, pix = probe_geometry(obu) | ||
| 223 | + bps = 1 if depth <= 8 else 2 | ||
| 224 | + sizes, fsz = plane_spans(w, h, ssx, ssy, bps) | ||
| 225 | + disp = split(ffmpeg_frames(obu, pix), sizes, fsz, cell) | ||
| 226 | + res = compare(cell, ours_prefix, disp, w, h, ssx, ssy, depth, want_hidden) | ||
| 227 | + if json_out: | ||
| 228 | + print(json.dumps(res)) | ||
| 229 | + else: | ||
| 230 | + f = res["first"] | ||
| 231 | + fs = "none" if f is None else \ | ||
| 232 | + f"disp f{f[0]} (decode f{f[1]}) {f[2]} (r{f[3]},c{f[4]}) ours={f[5]} ffmpeg={f[6]}" | ||
| 233 | + print(f"{cell}: {res['status']} {res['decode_frames']}df/" | ||
| 234 | + f"{res['display_frames']}shown hidden={res['hidden_decode']} " | ||
| 235 | + f"Y={res['Y']} U={res['U']} V={res['V']} first: {fs}") | ||
| 236 | + return res, disp, sizes, fsz, bps | ||
| 237 | + | ||
| 238 | + | ||
| 239 | +if __name__ == "__main__": | ||
| 240 | + cell, obu, prefix = sys.argv[1:4] | ||
| 241 | + wh = int(sys.argv[4]) if len(sys.argv) > 4 and sys.argv[4].isdigit() else None | ||
| 242 | + run(cell, obu, prefix, wh, "--json" in sys.argv) | ||
scripts/run422-ffmpeg.pyadded+54 -0
| @@ -0,0 +1,54 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +"""Driver: decode a cell with our decode_probe (EC_AV1_FINAL_DUMP) and compare | ||
| 3 | +against ffmpeg, per plane, per frame. Geometry from the sequence header.""" | ||
| 4 | +import json | ||
| 5 | +import os | ||
| 6 | +import subprocess | ||
| 7 | +import sys | ||
| 8 | + | ||
| 9 | +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | ||
| 10 | +import cmpff # noqa: E402 | ||
| 11 | + | ||
| 12 | +PROBE = "/home/user/.cache/tgt/av1422seed/debug/examples/decode_probe" | ||
| 13 | +WORK = "/home/user/.cache/seed422" | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +def decode_ours(name, path, extra_env=None): | ||
| 17 | + d = os.path.join(WORK, name) | ||
| 18 | + os.makedirs(d, exist_ok=True) | ||
| 19 | + for f in os.listdir(d): | ||
| 20 | + os.remove(os.path.join(d, f)) | ||
| 21 | + prefix = os.path.join(d, "ours") | ||
| 22 | + env = dict(os.environ, EC_AV1_FINAL_DUMP=prefix) | ||
| 23 | + env.update(extra_env or {}) | ||
| 24 | + r = subprocess.run([PROBE, path], stdout=subprocess.PIPE, | ||
| 25 | + stderr=subprocess.STDOUT, timeout=3600, env=env) | ||
| 26 | + out = r.stdout.decode("utf-8", "replace") | ||
| 27 | + if "REFUSED:" in out: | ||
| 28 | + return None, out.split("REFUSED:", 1)[1].strip().splitlines()[0] | ||
| 29 | + return prefix, out | ||
| 30 | + | ||
| 31 | + | ||
| 32 | +def one(name, path, want_hidden=None, keep=True): | ||
| 33 | + prefix, out = decode_ours(name, path) | ||
| 34 | + if prefix is None: | ||
| 35 | + print(f"{name}: REFUSES: {out}") | ||
| 36 | + return {"cell": name, "status": "REFUSES", "msg": out} | ||
| 37 | + res, *_ = cmpff.run(name, path, prefix, want_hidden, json_out=False) | ||
| 38 | + res["probe"] = out.strip().splitlines()[-1] if out.strip() else "" | ||
| 39 | + return res | ||
| 40 | + | ||
| 41 | + | ||
| 42 | +if __name__ == "__main__": | ||
| 43 | + cells = json.load(open(sys.argv[1])) | ||
| 44 | + out = [] | ||
| 45 | + for c in cells: | ||
| 46 | + try: | ||
| 47 | + res = one(c["name"], c["path"], c.get("hidden")) | ||
| 48 | + except SystemExit as e: | ||
| 49 | + res = {"cell": c["name"], "status": "COMPARATOR-ERROR", "msg": str(e)} | ||
| 50 | + print(json.dumps({k: v for k, v in res.items() | ||
| 51 | + if k not in ("per_decode_frame", "per_display_frame", "bbox")}), | ||
| 52 | + flush=True) | ||
| 53 | + out.append(res) | ||
| 54 | + json.dump(out, open(sys.argv[2], "w"), indent=1) | ||
scripts/shape422-diff.pyadded+28 -0
| @@ -0,0 +1,28 @@ | |||
| 1 | +import sys | ||
| 2 | +import cmpff | ||
| 3 | +def shape(cell, obu, frame_d=0, frame_s=0, planes=(1,2)): | ||
| 4 | + w,h,ssx,ssy,depth,pix=cmpff.probe_geometry(obu) | ||
| 5 | + bps=1 if depth<=8 else 2 | ||
| 6 | + sizes,fsz=cmpff.plane_spans(w,h,ssx,ssy,bps) | ||
| 7 | + disp=cmpff.split(cmpff.ffmpeg_frames(obu,pix),sizes,fsz,cell) | ||
| 8 | + a=open(f"/home/user/.cache/seed422/{cell}/ours.f{frame_d}",'rb').read() | ||
| 9 | + b=disp[frame_s] | ||
| 10 | + cw=-(-w>>ssx); ch=-(-h>>ssy) | ||
| 11 | + print(f"== {cell} {w}x{h} d{depth} chroma {cw}x{ch} decode f{frame_d} vs display f{frame_s}") | ||
| 12 | + for pi in planes: | ||
| 13 | + name="YUV"[pi] | ||
| 14 | + off=sum(sizes[:pi])*bps | ||
| 15 | + blocks={} | ||
| 16 | + for r in range(ch): | ||
| 17 | + base=off+(r*cw)*bps | ||
| 18 | + for c in range(cw): | ||
| 19 | + if a[base+c*bps:base+(c+1)*bps]!=b[base+c*bps:base+(c+1)*bps]: | ||
| 20 | + blocks.setdefault((r//8,c//8),[]).append((r%8,c%8)) | ||
| 21 | + print(f" {name}: {len(blocks)} 8x8 blocks wrong") | ||
| 22 | + for k in sorted(blocks): | ||
| 23 | + v=blocks[k] | ||
| 24 | + rows=sorted({p[0] for p in v}); cols=sorted({p[1] for p in v}) | ||
| 25 | + print(f" blk(r{k[0]},c{k[1]}) abs rows {k[0]*8}..{k[0]*8+7} cols {k[1]*8}..{k[1]*8+7}" | ||
| 26 | + f": {len(v)}/64 wrong, subrows {rows[0]}..{rows[-1]} subcols {cols[0]}..{cols[-1]}") | ||
| 27 | +if __name__=="__main__": | ||
| 28 | + shape(sys.argv[1], sys.argv[2], int(sys.argv[3]) if len(sys.argv)>3 else 0) | ||