Name the var-tx parent-side publish defect at its site, keep the shipped value
Browse files at this commitff5d3c5b3fd1ffba4e620fcd8c3f27402b65f4a5Parent: aabeeaf- docs
- name the var-tx parent-side publish defect at its site, keep the shipped value
2 changed files +102 -7
- crates/ec-av1/src/decode.rs +16 -7
- lanes/mergefix-r3.report.md +86 -0
crates/ec-av1/src/decode.rsmodified+16 -7
| @@ -20850,13 +20850,22 @@ fn decode_inter_block( | ||
| 20850 | 20850 | if vartx_leaves.is_some() { |
| 20851 | 20851 | // Plane 0 is already correct per transform unit |
| 20852 | 20852 | // ([`Neighbours::record_mi_luma`] above); this writes everything else |
| 20853 | - // [`Neighbours::record_rect`] would. | |
| 20854 | - // lane-mergefix r3 (class `tx-grid-published-block-side`): a var-tx | |
| 20855 | - // block is NOT always square -- a superblock-level PARTITION_VERT | |
| 20856 | - // inter strip is 32x64 with `side == 64`, and publishing `side, side` | |
| 20857 | - // stamped the PARENT's 64 into `above_side_mi`/`left_side_mi`, so the | |
| 20858 | - // next superblock's partition ctx read 0 where libaom read 1. | |
| 20859 | - neighbours.record_split_luma_rect_mi(at, write_w, write_h, mode_for_tx, uv_predict_mode, [&u_grid, &v_grid]); | |
| 20853 | + // [`Neighbours::record_rect`] would (a var-tx block is always square, | |
| 20854 | + // so `write_w == write_h == side`). | |
| 20855 | + // | |
| 20856 | + // lane-mergefix r3 (class `tx-grid-published-block-side`, OPEN): that | |
| 20857 | + // premise is FALSE for a superblock-level PARTITION_VERT inter strip | |
| 20858 | + // (32x64 with `side == 64`), which stamps the PARENT's 64 into | |
| 20859 | + // `above_side_mi`/`left_side_mi` and makes the next superblock's | |
| 20860 | + // 64-level partition ctx read 0 where the oracle reads 1. Passing | |
| 20861 | + // `write_w, write_h` here (or republishing only the two side bands, | |
| 20862 | + // per piece or over the parent span) fixes that ladder AND turns two | |
| 20863 | + // attempts of `real_aomenc_1to4_streams_..._rect_vartx_leaves_fire` | |
| 20864 | + // into the named "non-skip rectangular strip needs rectangular | |
| 20865 | + // residual coding" refusal -- all three variants measured in r3, see | |
| 20866 | + // lanes/mergefix-r3.report.md. Left at the parent value until the | |
| 20867 | + // band write moves into the partition arms. | |
| 20868 | + neighbours.record_split_luma_rect_mi(at, side, side, mode_for_tx, uv_predict_mode, [&u_grid, &v_grid]); | |
| 20860 | 20869 | } else { |
| 20861 | 20870 | neighbours.record_rect_mi( |
| 20862 | 20871 | at, |
lanes/mergefix-r3.report.mdadded+86 -0
| @@ -0,0 +1,86 @@ | ||
| 1 | +# lane-mergefix r3 report | |
| 2 | + | |
| 3 | +## Verdict | |
| 4 | +Root cause of the `a_frame_edge_straddling_band_decodes_pixel_exact` partition-ctx | |
| 5 | +divergence FOUND and proven against the instrumented oracle; the fix is NOT shipped | |
| 6 | +because all three variants of it turn a green sibling gate red (class | |
| 7 | +`fix-trades-sibling-gate`). Branch is code-identical to r2 plus a `lane-mergefix r3` | |
| 8 | +comment at the site (`crates/ec-av1/src/decode.rs:20852`) naming the defect and the | |
| 9 | +three measured variants. Straddling gate stays RED at 3622 px, exactly as r2 left it. | |
| 10 | + | |
| 11 | +## Root cause (proven) | |
| 12 | +`decode_inter_block`'s var-tx branch (decode.rs ~20857) calls | |
| 13 | +`record_split_luma_rect_mi(at, side, side, ..)` on the comment's premise "a var-tx | |
| 14 | +block is always square, so `write_w == write_h == side`". FALSE: a superblock-level | |
| 15 | +`PARTITION_VERT` inter strip is 32x64 with `side == 64`, so the strip stamps the | |
| 16 | +PARENT's 64 into `above_side_mi`/`left_side_mi`. `Neighbours::partition_ctx_mi` | |
| 17 | +(decode.rs ~4985) then reads `above_side_mi[32] * 2 <= 64` as false and picks | |
| 18 | +partition CDF row 0 where libaom picks row 1. Class `tx-grid-published-block-side`, | |
| 19 | +7th instance. | |
| 20 | + | |
| 21 | +EVIDENCE: ladder at mi(16,32) of the pinned stream (md5 a14892ed0ba88b6ad2b566e251ea2d33, | |
| 22 | +192x68 cq61 tile_cols=1 8-bit, `~/.cache/mergefix-tmp/mkstr.sh`) | | |
| 23 | +`EC_TRACE_PART=1 <target>/debug/examples/decode_probe str61.obu` vs | |
| 24 | +`EC_TRACE_MODE=1 aomdec --rawvideo -o /dev/null str61.obu` | | |
| 25 | +ours `EC_PARTG mi_row=16 mi_col=32 bsize=12 ctx=0 rng=51641` -> with `write_w/write_h` | |
| 26 | +`ctx=1 rng=51641` then `bsize=9 rng=38495`, matching aomdec `EC_PART ... ctx=13 | |
| 27 | +(= bsl*4+1) rng=51641 -> value=3 (SPLIT) rng=38495`. | |
| 28 | + | |
| 29 | +EVIDENCE: gate delta | `cargo test -p ec-av1 --lib -- a_frame_edge_straddling_band_decodes_pixel_exact` | |
| 30 | +with the fix applied | 3622 -> 3376 differing pixels, same first pixel (frame 1, row 0 | |
| 31 | +col 64, ours 56 vs ffmpeg 178). | |
| 32 | + | |
| 33 | +## Why it is not shipped (the trade, measured 3 ways) | |
| 34 | +With the fix, `real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal` | |
| 35 | +goes green -> RED: two 8-bit attempts (16, 17) that previously decoded pixel-exact now | |
| 36 | +stop at the named refusal `unsupported: AV1 tile (a non-skip rectangular | |
| 37 | +(HORZ/VERT/HORZ_B) strip needs rectangular residual coding)`, so the gate's rect var-tx | |
| 38 | +leaf counter drops to 0 and it fails its own hard assert. | |
| 39 | + | |
| 40 | +Variants measured, each with both gates in one invocation: | |
| 41 | +1. `record_split_luma_rect_mi(at, write_w, write_h, ..)` -- straddling 3376, 1to4 "0 leaves, 0 refusals" FAIL. | |
| 42 | +2. keep the call at `side, side`, republish only `above_side_mi`/`left_side_mi` per piece with `write_w/write_h` -- straddling 3376, 1to4 2 refusals FAIL. | |
| 43 | +3. same, but over the PARENT span (`rmi & !(n-1)`, `n = side / MI`; libaom's `update_partition_context` takes `bsize`, not the piece) -- straddling 3376, 1to4 2 refusals FAIL. | |
| 44 | +4. variant 3 restricted to VERT shapes only (`write_w * 2 == side && write_h == side`) -- straddling 3376, 1to4 2 refusals FAIL. | |
| 45 | + | |
| 46 | +Reading: `side` at those 1:4-gate call sites is not necessarily the piece's PARENT | |
| 47 | +bsize (sb128 streams pass `side = 64` for pieces whose parent is 128), so a | |
| 48 | +parent-span write keyed off `side` stamps the wrong span there. The band write belongs | |
| 49 | +in the partition arms, where the parent bsize and origin are known -- that is the r4 job. | |
| 50 | + | |
| 51 | +## Swept sites (class sweep, `side`/parent dimension into a per-mi side band) | |
| 52 | +- decode.rs:20857 `record_split_luma_rect_mi(at, side, side, ..)` in `decode_inter_block` var-tx branch -- THE DEFECT (documented, not changed). | |
| 53 | +- decode.rs:6791 `record_split_luma_rect_mi(at_mi, bw, bh, ..)` -- already true footprint, OK. | |
| 54 | +- decode.rs:10798 `record_split_luma(at, side, ..)` in `decode_block` -- square intra block, `side` is its own, OK. | |
| 55 | +- decode.rs:5383 `record_mi_rect` / :5567 `record_split_luma_rect_mi` band writes -- take w/h from the caller, OK. | |
| 56 | +- decode.rs:8596, :11235, :11565, :11919, :21364, :21847 direct `above_side_mi`/`left_side_mi` writes -- all use the block's own `bw`/`bh` (or the documented 4/8 constants), OK. | |
| 57 | +- `record_rect_mi`/`record_inter_rect_mi`/`record_compound_ctx_rect_mi` square wrappers (:4821, :5097, :5497) -- callers are square blocks, OK. | |
| 58 | +No second instance of the parent-dimension shape found. | |
| 59 | + | |
| 60 | +## Second residue (unchanged by all of the above) | |
| 61 | +With the fix in place, frame 1 of the pinned stream is element-exact against the oracle | |
| 62 | +in BOTH ladders yet still differs by 3376 px: EC_MODE ladder identical for all 66 | |
| 63 | +blocks of frame 1 (first divergence is frame 2's block at mi(0,16)); the | |
| 64 | +`tag=all_zero`/`tag=eob` range ladder is identical for its first 225 entries (all of | |
| 65 | +frames 0-1) and only then diverges. The first bad pixel is frame 1 row 0 col 64 = | |
| 66 | +mi(0,16), a 32x32 compound skip block (`EC_MODE ... is_inter=1 skip=1 side=32`, | |
| 67 | +`mode=19 ref0=1 ref1=7 mv0=(0,0)`), so frame 1 is a RECONSTRUCTION defect (compound | |
| 68 | +prediction), not an entropy one. | |
| 69 | +EVIDENCE: ~/.cache/mergefix-tmp/{ours.txt,aom.txt,oc.txt,ac.txt} | `EC_TRACE_MODE=1` and | |
| 70 | +`EC_TRACE_COEFF=1` on both decoders over str61.obu | `paste`d EC_MODE rng columns equal | |
| 71 | +through frame 1 (66 blocks), coefficient ladders equal for 225/225 entries. | |
| 72 | + | |
| 73 | +## Suite | |
| 74 | +`systemd-run --user --unit=mergefix-suite-r3-1788352226 ... cargo test -p ec-av1 --lib -j3` | |
| 75 | +(log `$HOME/.cache/mergefix-suite-r3.log`, run WITH variant 1 applied): | |
| 76 | +`test result: FAILED. 404 passed; 2 failed; 37 ignored` -- | |
| 77 | +`a_frame_edge_straddling_band_decodes_pixel_exact` (3376 px) and | |
| 78 | +`real_aomenc_1to4_streams_..._rect_vartx_leaves_fire` (the trade above). | |
| 79 | +After reverting to the shipped state, the two gates re-run in one invocation give | |
| 80 | +`1 passed; 1 failed`: 1to4 ok, straddling 3622 px (r2's number, no regression). | |
| 81 | + | |
| 82 | +## Disposition | |
| 83 | +- fix-now for r4: move the partition-context band write out of `decode_inter_block` and | |
| 84 | + into the partition arms (parent bsize + origin known there), then re-run BOTH gates. | |
| 85 | +- deferred: frame-1 compound-skip reconstruction defect at mi(0,16) -- unblocked by a | |
| 86 | + prediction-side ladder (EC_AV1_PREFILT_DUMP on frame 1), independent of the above. |