ec-av1: lane-av1-422bigblock review close -- the 128-rect walk reshaped onto the reviewed 349b3918 expression form and the report's 4:4:4 evidence made honest
Browse files at this commitc8187741d5e40462672c54a8277240f07a22c628Parent: c74c9122 changed files +60 -27
- crates/ec-av1/src/decode.rs +21 -19
- lanes/av1422bigblock.report.md +39 -8
crates/ec-av1/src/decode.rsmodified+21 -19
| @@ -18566,18 +18566,17 @@ fn decode_block_128rect( | ||
| 18566 | 18566 | let mi_rows = 2 * y.true_height.div_ceil(8); |
| 18567 | 18567 | let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(mi_c)); |
| 18568 | 18568 | let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(mi_r)); |
| 18569 | - // Non-lossless: per mu chunk, the chroma units per axis are | |
| 18570 | - // ((64 >> ss_x) / chroma_tx, (64 >> ss_y) / chroma_tx) -- one 32x32 unit | |
| 18571 | - // per chunk at 4:2:0, TWO stacked on the tall axis at 4:2:2 (the chunk's | |
| 18572 | - // chroma plane block is 32x64), four at 4:4:4. The old square-cut assert | |
| 18573 | - // demanded one unit per chunk on BOTH axes, which no 4:2:2 stream can | |
| 18574 | - // satisfy (lane-av1-422bigblock: the s2.obu witness). | |
| 18575 | - let chunk_cw = (64usize) >> ss_x(fctx); | |
| 18576 | - let chunk_ch = (64usize) >> ss_y(fctx); | |
| 18569 | + // Non-lossless: per mu chunk, `(64 >> ss) / chroma_tx` chroma units per | |
| 18570 | + // axis -- one 32x32 at 4:2:0, two stacked on the tall axis at 4:2:2 | |
| 18571 | + // (lane-av1-422bigblock: the chunk's chroma plane block is 32x64 there), | |
| 18572 | + // four at 4:4:4 (lane-av1-444sb's own finding on this same walk). | |
| 18577 | 18573 | debug_assert!( |
| 18578 | 18574 | lossless_frame |
| 18579 | - || (nch_x * (chunk_cw / chroma_tx), nch_y * (chunk_ch / chroma_tx)) | |
| 18580 | - == (chroma_w / chroma_tx, chroma_h / chroma_tx) | |
| 18575 | + || (chroma_w / chroma_tx, chroma_h / chroma_tx) | |
| 18576 | + == ( | |
| 18577 | + nch_x * ((64 >> ss_x(fctx)) / chroma_tx), | |
| 18578 | + nch_y * ((64 >> ss_y(fctx)) / chroma_tx) | |
| 18579 | + ) | |
| 18581 | 18580 | ); |
| 18582 | 18581 | let tpc = 64 / logical_tx; |
| 18583 | 18582 | let zero_tu = vec![0i32; logical_tx * logical_tx]; |
| @@ -18657,12 +18656,15 @@ fn decode_block_128rect( | ||
| 18657 | 18656 | neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid); |
| 18658 | 18657 | } |
| 18659 | 18658 | } |
| 18660 | - // Transform units per axis inside this mu chunk's chroma span | |
| 18661 | - // -- (64 >> ss_x) x (64 >> ss_y): one 32x32 unit at 4:2:0, TWO | |
| 18662 | - // stacked TX_32X32 at 4:2:2, four at 4:4:4; 8x8 TX_4X4 units | |
| 18663 | - // when lossless. | |
| 18664 | - let cn_w = (chunk_cw / chroma_tx).max(1); | |
| 18665 | - let cn_h = (chunk_ch / chroma_tx).max(1); | |
| 18659 | + // Transform units per axis inside this mu chunk's chroma span: | |
| 18660 | + // a 64x64 luma chunk covers `64 >> ss` chroma pixels per axis, | |
| 18661 | + // so it holds `(64 >> ss) / chroma_tx` units -- one 32x32 at | |
| 18662 | + // 4:2:0, four at 4:4:4 (lane-av1-444sb), TWO STACKED TX_32X32 on | |
| 18663 | + // the tall axis at 4:2:2 (lane-av1-422bigblock: the chunk's | |
| 18664 | + // chroma plane block is 32x64 there, so the two axes' counts | |
| 18665 | + // part ways -- 1 x 2); 8x8 TX_4X4 units when lossless. | |
| 18666 | + let cn = ((64 >> ss_x(fctx)) / chroma_tx).max(1); | |
| 18667 | + let cn_h = ((64 >> ss_y(fctx)) / chroma_tx).max(1); | |
| 18666 | 18668 | // libaom's per-chunk `unit_width/height` (plane-mi units of the |
| 18667 | 18669 | // luma mi grid): `min(mu_blocks + col, max_blocks) >> ss`. |
| 18668 | 18670 | let unit_w = ((ch_col + 1) * 16).min(max_w_mi) >> ss_x(fctx); |
| @@ -18675,7 +18677,7 @@ fn decode_block_128rect( | ||
| 18675 | 18677 | // frame's 4x4 chroma units are where it becomes observable. |
| 18676 | 18678 | for plane_pass in 1..=2usize { |
| 18677 | 18679 | for ci_row in 0..cn_h { |
| 18678 | - for ci_col in 0..cn_w { | |
| 18680 | + for ci_col in 0..cn { | |
| 18679 | 18681 | // The clamp strides are the CHUNK's chroma mi extent |
| 18680 | 18682 | // per axis: 16 luma mi >> the axis's own ss. |
| 18681 | 18683 | if ch_col * (16 >> ss_x(fctx)) + ci_col * stepc >= unit_w |
| @@ -18683,8 +18685,8 @@ fn decode_block_128rect( | ||
| 18683 | 18685 | { |
| 18684 | 18686 | continue; |
| 18685 | 18687 | } |
| 18686 | - let cu_x = cpx + ch_col * chunk_cw + ci_col * chroma_tx; | |
| 18687 | - let cu_y = cpy + ch_row * chunk_ch + ci_row * chroma_tx; | |
| 18688 | + let cu_x = cpx + ch_col * (64 >> ss_x(fctx)) + ci_col * chroma_tx; | |
| 18689 | + let cu_y = cpy + ch_row * (64 >> ss_y(fctx)) + ci_row * chroma_tx; | |
| 18688 | 18690 | let cu_mi = ( |
| 18689 | 18691 | mi_r + ch_row * 16 + ci_row * ((chroma_tx << ss_y(fctx)) / 4), |
| 18690 | 18692 | mi_c + ch_col * 16 + ci_col * ((chroma_tx << ss_x(fctx)) / 4), |
lanes/av1422bigblock.report.mdmodified+39 -8
| @@ -95,8 +95,13 @@ PARTITION_NONE non-skip inter block carries all three causes; the oracle codes | ||
| 95 | 95 | pixels were right (the crop is ss-aware) — only inter prediction off the |
| 96 | 96 | slot was wrong, so the bottom mu-chunk row predicted from a clamped row-63 |
| 97 | 97 | edge (±1–2 diffs over chroma rows 64..127, 3.3–3.6k samples/plane). Fixed |
| 98 | - with a three-way length inference (`w*h` / `halfw*h` / `halfw*halfh` — | |
| 99 | - pairwise distinct for every w,h ≥ 1). | |
| 98 | + with a three-way length inference (`w*h` / `halfw*h` / `halfw*halfh`, | |
| 99 | + `halfw = (w+1)/2`, `halfh = (h+1)/2` — the three lengths are pairwise | |
| 100 | + distinct for every w,h ≥ 1). DISCLOSED 4:2:0 edge: at ODD reference | |
| 101 | + dimensions the half-width uses ceil (`(w+1)/2`, matching the picture | |
| 102 | + crop's `round_ss`) where the old guess used floor (`w/2`) — ceil is the | |
| 103 | + correct stored-crop shape and the change is visible only at odd w/h, which | |
| 104 | + no committed fixture exercises. | |
| 100 | 105 | |
| 101 | 106 | After the fixes: `422_sb128_3f.obu` and the full `b422_wit.obu` decode |
| 102 | 107 | pixel-exact vs aomdec; every coefficient unit of every frame pairs |
| @@ -119,10 +124,19 @@ intra 128-rect twin of the square-cut walk: | ||
| 119 | 124 | - `decode_block_128rect`'s chroma walk was chunk-square (`cn = 32/chroma_tx`, |
| 120 | 125 | `cu_y = cpy + ch_row*32`, clamp strides 8/8) with a `debug_assert!` that no |
| 121 | 126 | 4:2:2 stream can satisfy. Fixed per-axis exactly like the inter walk |
| 122 | - (`cn_w/cn_h`, per-axis chunk offsets and clamp strides, `tu_reach_rect`, | |
| 123 | - `around_mi_rect`, per-axis record spans). 420/444 degenerate to the old | |
| 124 | - values; 4:4:4's previously-broken (assert-caught) non-lossless 128-rect | |
| 125 | - chroma becomes correct as a side effect. | |
| 127 | + (`tu_reach_rect`, `around_mi_rect`, per-axis record spans), in the SAME | |
| 128 | + expression shape the already-reviewed 444 fix landed on lane-av1-444sb | |
| 129 | + (`349b3918`): `cn = ((64 >> ss_x)/chroma_tx).max(1)` for the width axis | |
| 130 | + plus the added `cn_h = ((64 >> ss_y)/chroma_tx).max(1)` for the height | |
| 131 | + axis, per-axis chunk offsets `(64 >> ss)` and clamp strides `(16 >> ss)` — | |
| 132 | + at ss(0,0) the code reduces line-for-line to `349b3918`'s form, so the | |
| 133 | + merge with that chain is a semantic union. DISCLOSED 4:4:4 behavior change: | |
| 134 | + the parent's walk was provably broken at ss(0,0) (one unit per chunk instead | |
| 135 | + of four; the stale assert caught it) and this rewrite, like `349b3918`, | |
| 136 | + codes the four units — NOT byte-identical to parent at 4:4:4, by design, | |
| 137 | + and pinned by `349b3918`'s own witness on the merged tree (see the identity | |
| 138 | + section). DISCLOSED 4:2:0 identity: at ss(1,1) every new expression reduces | |
| 139 | + to the old constant (32, offsets 32, strides 8, one unit). | |
| 126 | 140 | |
| 127 | 141 | Result: s2.obu decodes all 16 frames, no panic (`OK: 16 frames decoded, |
| 128 | 142 | 256x144`). The crash the charter assigned is closed. **Deferred (named for its |
| @@ -142,8 +156,25 @@ unit 38, mi(12,24), TX_4X8, plane 2. | ||
| 142 | 156 | - `a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact` — green. |
| 143 | 157 | - `a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_stream` |
| 144 | 158 | (live aomenc, 420, inter, tiles) — green. |
| 145 | -- `a_lossless_sb128_rect_intra_block_decodes_sample_exact` (4:4:4 lossless | |
| 146 | - sb128) — green. | |
| 159 | +- `a_lossless_sb128_rect_intra_block_decodes_sample_exact` — green. LABEL | |
| 160 | + CORRECTION (review finding 2): this stream is 4:2:0 (seq_profile 0 in the | |
| 161 | + fixture bytes), NOT 4:4:4 as this report first claimed; it is a 4:2:0 | |
| 162 | + lossless sb128 gate and proves nothing about 4:4:4. | |
| 163 | +- 4:4:4 evidence, done properly: `444_sb128rect_lr_witness.obu` (sha256 | |
| 164 | + `27825e14…`, the lane-av1-444sb witness, 192x160 profile-1, 3 frames) was | |
| 165 | + decoded on THIS tree (`OK: 3 frames decoded`) and its output is | |
| 166 | + BYTE-IDENTICAL to the parent commit's output on the same stream — measured | |
| 167 | + by stash-and-rebuild, all three frames — so the rewrite is proven | |
| 168 | + output-neutral on it. The stream itself still diverges from aomdec on this | |
| 169 | + ancestry, identically before and after the fix: this branch predates the | |
| 170 | + 444 chain's chroma-context fixes (`9e77c16b` ss-aware chroma-above skip, | |
| 171 | + `76f8c3fe`), the desync starts at frame-0 Y sample 128 (the first | |
| 172 | + 128-column superblock) and the first 128-rect block never fires downstream | |
| 173 | + of it, so `decode_block_128rect` codes no samples on this stream on this | |
| 174 | + ancestry. `349b3918`'s own gate | |
| 175 | + (`a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact`, | |
| 176 | + frames 0/1 byte-exact vs aomdec AND ffmpeg) is the merged-tree pin: at | |
| 177 | + ss(0,0) this lane's walk reduces verbatim to that reviewed form. | |
| 147 | 178 | - `a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders` |
| 148 | 179 | and `a_128_root_compound_block_decodes_exact_through_both_decoders` (solo, |
| 149 | 180 | they pin the process-global superblock size) — green. |