From c8187741d5e40462672c54a8277240f07a22c628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 26 Sep 2026 05:30:22 +0300 Subject: [PATCH] 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 Review findings closed: the decode_block_128rect chroma walk now uses the same ss-parameterized expression the reviewed lane-av1-444sb fix (349b3918) landed -- cn = ((64 >> ss_x)/chroma_tx).max(1) for the width axis with the added cn_h = ((64 >> ss_y)/chroma_tx).max(1) for the height axis, per-axis (64 >> ss) chunk offsets and (16 >> ss) clamp strides -- so at ss(0,0) this lane's code reduces line-for-line to that reviewed form and the eventual merge of the two chains is a semantic union, not a conflict; at ss(1,0) the two axes' counts part ways (1 x 2 stacked TX_32X32). The 444_sb128rect_lr_witness (sha 27825e14) was decoded on this tree: its output is byte-identical to the parent commit's on the same stream (measured by stash-and-rebuild, all three frames), so the rewrite is proven output-neutral on it; the stream still diverges from aomdec identically before and after because this branch predates the 444 chain's chroma-context fixes (9e77c16b, 76f8c3fe) and the desync starts at frame-0 Y sample 128, before the first 128-rect block ever fires -- 349b3918's own frames-0/1 gate remains the merged-tree pin. Report corrections: the lossless sb128 gate is a 4:2:0 stream (seq_profile 0 in the fixture bytes) and is relabeled as such -- it never proved 4:4:4; the 4:4:4 behavior change of the 128rect rewrite (parent was assert-broken there) and the ceil-vs-floor half-width edge of the RefPix three-way inference at odd reference dimensions are now disclosed in the report. --- crates/ec-av1/src/decode.rs | 40 +++++++++++++++-------------- lanes/av1422bigblock.report.md | 47 ++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 27 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index e4cbfbe8..fddb1944 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -18566,18 +18566,17 @@ fn decode_block_128rect( let mi_rows = 2 * y.true_height.div_ceil(8); let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(mi_c)); let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(mi_r)); - // Non-lossless: per mu chunk, the chroma units per axis are - // ((64 >> ss_x) / chroma_tx, (64 >> ss_y) / chroma_tx) -- one 32x32 unit - // per chunk at 4:2:0, TWO stacked on the tall axis at 4:2:2 (the chunk's - // chroma plane block is 32x64), four at 4:4:4. The old square-cut assert - // demanded one unit per chunk on BOTH axes, which no 4:2:2 stream can - // satisfy (lane-av1-422bigblock: the s2.obu witness). - let chunk_cw = (64usize) >> ss_x(fctx); - let chunk_ch = (64usize) >> ss_y(fctx); + // Non-lossless: per mu chunk, `(64 >> ss) / chroma_tx` chroma units per + // axis -- one 32x32 at 4:2:0, two stacked on the tall axis at 4:2:2 + // (lane-av1-422bigblock: the chunk's chroma plane block is 32x64 there), + // four at 4:4:4 (lane-av1-444sb's own finding on this same walk). debug_assert!( lossless_frame - || (nch_x * (chunk_cw / chroma_tx), nch_y * (chunk_ch / chroma_tx)) - == (chroma_w / chroma_tx, chroma_h / chroma_tx) + || (chroma_w / chroma_tx, chroma_h / chroma_tx) + == ( + nch_x * ((64 >> ss_x(fctx)) / chroma_tx), + nch_y * ((64 >> ss_y(fctx)) / chroma_tx) + ) ); let tpc = 64 / logical_tx; let zero_tu = vec![0i32; logical_tx * logical_tx]; @@ -18657,12 +18656,15 @@ fn decode_block_128rect( neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid); } } - // Transform units per axis inside this mu chunk's chroma span - // -- (64 >> ss_x) x (64 >> ss_y): one 32x32 unit at 4:2:0, TWO - // stacked TX_32X32 at 4:2:2, four at 4:4:4; 8x8 TX_4X4 units - // when lossless. - let cn_w = (chunk_cw / chroma_tx).max(1); - let cn_h = (chunk_ch / chroma_tx).max(1); + // Transform units per axis inside this mu chunk's chroma span: + // a 64x64 luma chunk covers `64 >> ss` chroma pixels per axis, + // so it holds `(64 >> ss) / chroma_tx` units -- one 32x32 at + // 4:2:0, four at 4:4:4 (lane-av1-444sb), TWO STACKED TX_32X32 on + // the tall axis at 4:2:2 (lane-av1-422bigblock: the chunk's + // chroma plane block is 32x64 there, so the two axes' counts + // part ways -- 1 x 2); 8x8 TX_4X4 units when lossless. + let cn = ((64 >> ss_x(fctx)) / chroma_tx).max(1); + let cn_h = ((64 >> ss_y(fctx)) / chroma_tx).max(1); // libaom's per-chunk `unit_width/height` (plane-mi units of the // luma mi grid): `min(mu_blocks + col, max_blocks) >> ss`. let unit_w = ((ch_col + 1) * 16).min(max_w_mi) >> ss_x(fctx); @@ -18675,7 +18677,7 @@ fn decode_block_128rect( // frame's 4x4 chroma units are where it becomes observable. for plane_pass in 1..=2usize { for ci_row in 0..cn_h { - for ci_col in 0..cn_w { + for ci_col in 0..cn { // The clamp strides are the CHUNK's chroma mi extent // per axis: 16 luma mi >> the axis's own ss. if ch_col * (16 >> ss_x(fctx)) + ci_col * stepc >= unit_w @@ -18683,8 +18685,8 @@ fn decode_block_128rect( { continue; } - let cu_x = cpx + ch_col * chunk_cw + ci_col * chroma_tx; - let cu_y = cpy + ch_row * chunk_ch + ci_row * chroma_tx; + let cu_x = cpx + ch_col * (64 >> ss_x(fctx)) + ci_col * chroma_tx; + let cu_y = cpy + ch_row * (64 >> ss_y(fctx)) + ci_row * chroma_tx; let cu_mi = ( mi_r + ch_row * 16 + ci_row * ((chroma_tx << ss_y(fctx)) / 4), mi_c + ch_col * 16 + ci_col * ((chroma_tx << ss_x(fctx)) / 4), diff --git a/lanes/av1422bigblock.report.md b/lanes/av1422bigblock.report.md index 7ee938bd..1ab9055f 100644 --- a/lanes/av1422bigblock.report.md +++ b/lanes/av1422bigblock.report.md @@ -95,8 +95,13 @@ PARTITION_NONE non-skip inter block carries all three causes; the oracle codes pixels were right (the crop is ss-aware) — only inter prediction off the slot was wrong, so the bottom mu-chunk row predicted from a clamped row-63 edge (±1–2 diffs over chroma rows 64..127, 3.3–3.6k samples/plane). Fixed - with a three-way length inference (`w*h` / `halfw*h` / `halfw*halfh` — - pairwise distinct for every w,h ≥ 1). + with a three-way length inference (`w*h` / `halfw*h` / `halfw*halfh`, + `halfw = (w+1)/2`, `halfh = (h+1)/2` — the three lengths are pairwise + distinct for every w,h ≥ 1). DISCLOSED 4:2:0 edge: at ODD reference + dimensions the half-width uses ceil (`(w+1)/2`, matching the picture + crop's `round_ss`) where the old guess used floor (`w/2`) — ceil is the + correct stored-crop shape and the change is visible only at odd w/h, which + no committed fixture exercises. After the fixes: `422_sb128_3f.obu` and the full `b422_wit.obu` decode pixel-exact vs aomdec; every coefficient unit of every frame pairs @@ -119,10 +124,19 @@ intra 128-rect twin of the square-cut walk: - `decode_block_128rect`'s chroma walk was chunk-square (`cn = 32/chroma_tx`, `cu_y = cpy + ch_row*32`, clamp strides 8/8) with a `debug_assert!` that no 4:2:2 stream can satisfy. Fixed per-axis exactly like the inter walk - (`cn_w/cn_h`, per-axis chunk offsets and clamp strides, `tu_reach_rect`, - `around_mi_rect`, per-axis record spans). 420/444 degenerate to the old - values; 4:4:4's previously-broken (assert-caught) non-lossless 128-rect - chroma becomes correct as a side effect. + (`tu_reach_rect`, `around_mi_rect`, per-axis record spans), in the SAME + expression shape the already-reviewed 444 fix landed on lane-av1-444sb + (`349b3918`): `cn = ((64 >> ss_x)/chroma_tx).max(1)` for the width axis + plus the added `cn_h = ((64 >> ss_y)/chroma_tx).max(1)` for the height + axis, per-axis chunk offsets `(64 >> ss)` and clamp strides `(16 >> ss)` — + at ss(0,0) the code reduces line-for-line to `349b3918`'s form, so the + merge with that chain is a semantic union. DISCLOSED 4:4:4 behavior change: + the parent's walk was provably broken at ss(0,0) (one unit per chunk instead + of four; the stale assert caught it) and this rewrite, like `349b3918`, + codes the four units — NOT byte-identical to parent at 4:4:4, by design, + and pinned by `349b3918`'s own witness on the merged tree (see the identity + section). DISCLOSED 4:2:0 identity: at ss(1,1) every new expression reduces + to the old constant (32, offsets 32, strides 8, one unit). Result: s2.obu decodes all 16 frames, no panic (`OK: 16 frames decoded, 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. - `a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact` — green. - `a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_stream` (live aomenc, 420, inter, tiles) — green. -- `a_lossless_sb128_rect_intra_block_decodes_sample_exact` (4:4:4 lossless - sb128) — green. +- `a_lossless_sb128_rect_intra_block_decodes_sample_exact` — green. LABEL + CORRECTION (review finding 2): this stream is 4:2:0 (seq_profile 0 in the + fixture bytes), NOT 4:4:4 as this report first claimed; it is a 4:2:0 + lossless sb128 gate and proves nothing about 4:4:4. +- 4:4:4 evidence, done properly: `444_sb128rect_lr_witness.obu` (sha256 + `27825e14…`, the lane-av1-444sb witness, 192x160 profile-1, 3 frames) was + decoded on THIS tree (`OK: 3 frames decoded`) and its output is + BYTE-IDENTICAL to the parent commit's output on the same stream — measured + by stash-and-rebuild, all three frames — so the rewrite is proven + output-neutral on it. The stream itself still diverges from aomdec on this + ancestry, identically before and after the fix: this branch predates the + 444 chain's chroma-context fixes (`9e77c16b` ss-aware chroma-above skip, + `76f8c3fe`), the desync starts at frame-0 Y sample 128 (the first + 128-column superblock) and the first 128-rect block never fires downstream + of it, so `decode_block_128rect` codes no samples on this stream on this + ancestry. `349b3918`'s own gate + (`a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact`, + frames 0/1 byte-exact vs aomdec AND ffmpeg) is the merged-tree pin: at + ss(0,0) this lane's walk reduces verbatim to that reviewed form. - `a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders` and `a_128_root_compound_block_decodes_exact_through_both_decoders` (solo, they pin the process-global superblock size) — green.