forge
Explore
Log in

Don't you dare go Hollow

av1lm444loss: appendix r2 -- lead (b) blocking defect diagnosed in full

Browse files at this commit

dd7df0ce792655a1a8e290a4a29d87ba17215af8Ahmet Kaan GümüşParent: 65ae1e4
decode_intrabc_rect lines 13065/13070 hardcode a 4:2:0 chroma halving
((px/2, py/2), (bw/2, bh/2)) where the geometry is (px >> ss_x, py >>
ss_y) and (bw >> ss_x, bh >> ss_y). At 4:4:4 a lossless 1:4 rect block's
chroma shape arrives rect and trips TxParams::run's 4x4-only WHT assert.
Evidence: backtrace, and a probe showing leaves=Some(8) all-TX_4X4 for
bw=8 bh=16, so the rect shape is the chroma call, not a luma leaf.

Written before the fix so the diagnosis survives independently.
lanes/av1lm444loss.report.mdmodified+99 -0
@@ -256,3 +256,102 @@ lane's invariant names.
256 than libaom's floor `h >> 3`; the two agree on every multiple-of-8 height,256 than libaom's floor `h >> 3`; the two agree on every multiple-of-8 height,
257 which is the fixture's 96, and differ by at most one 4-px transform row257 which is the fixture's 96, and differ by at most one 4-px transform row
258 otherwise — the same approximation the shipped var-tx branch already carries.258 otherwise — the same approximation the shipped var-tx branch already carries.
259+
260+---
261+
262+# Appendix r2 — lead (b): the blocking defect, diagnosed in full
263+
264+Written BEFORE the fix, so the diagnosis survives even if the work stops here.
265+
266+## The line
267+
268+`crates/ec-av1/src/decode.rs`, `decode_intrabc_rect`, line 13065 and line 13070
269+at the base tree:
270+
271+```rust
272+let (cpx, cpy) = (px / 2, py / 2); // line 13065
273+let (cw, ch) = (bw / 2, bh / 2); // line 13070
274+```
275+
276+Both are a **hardcoded 4:2:0 halving**. The chroma plane block's true geometry
277+is `bw >> ss_x(fctx)` x `bh >> ss_y(fctx)` at `(px >> ss_x(fctx),
278+py >> ss_y(fctx))`. At `ss (0,0)` (4:4:4) `ss_x = ss_y = 0`, so every one of
279+those four values is halved when it must not be.
280+
281+## Mechanism
282+
283+`decode_intrabc_rect` serves a 1:4 rect partition inside an IntraBC block. Its
284+chroma arm calls
285+
286+```rust
287+read_inter_plane_rect(dec, cdfs, rect_inter_chroma_set(cw, ch)?, (cw, ch),
288+ cside, plane, around[plane], ...)
289+```
290+
291+with the halved `(cw, ch)`. On a **lossless** block that shape reaches
292+`TxParams::run`, whose lossless arm is the 4x4 Walsh-Hadamard path and carries
293+
294+```rust
295+debug_assert_eq!((self.w, self.h), (4, 4));
296+```
297+
298+So a lossless 4:4:4 rect block whose halved chroma shape is rect (any 1:4
299+strip: 8x16 -> 4x8, 4x32 -> 2x16, ...) asserts. Release builds compile the
300+`debug_assert` out, `dequant_and_inverse_wht4x4` returns a buffer shorter than
301+`w * h`, and the failure surfaces one frame later in the strided residual copy:
302+
303+```
304+thread 'main' panicked at crates/ec-av1/src/decode.rs:2823:59:
305+range end index 4 out of range for slice of length 0
306+```
307+
308+which is the release-mode face of the same defect.
309+
310+## Evidence
311+
312+Recipe `testsrc2 512x128 yuv444p --lossless=1 --cpu-used=2 --lag-in-frames=0
313+--kf-max-dist=100 --limit=6` (121844 bytes), base tree, debug build:
314+
315+```
316+thread 'main' panicked at crates/ec-av1/src/decode.rs:2787:13:
317+assertion `left == right` failed
318+ left: (4, 8)
319+ right: (4, 4)
320+ 4: <ec_av1::decode::TxParams>::run
321+ 5: ec_av1::decode::push_mc_rect_tx
322+ 6: ec_av1::decode::read_inter_plane_rect
323+ 7: ec_av1::decode::decode_intrabc_rect
324+ 8: ec_av1::decode::decode_leaf_rect
325+ 9: ec_av1::decode::decode_key_frame_tile_with_cdfs
326+```
327+
328+A temporary env-gated probe at `decode_intrabc_rect`'s residual split isolates
329+which side is wrong:
330+
331+```
332+EC_PROBE_IBC mi=(28,106) bw=8 bh=16 lossless=true leaves=Some(8)
333+```
334+
335+`leaves=Some(8)` with `bw=8, bh=16` is **2 x 4 = 8 TX_4X4 units** — the lossless
336+leaf builder is CORRECT and produced no rect luma unit at all. The `(4, 8)` in
337+the assert therefore cannot be luma. At 4:4:4 this block's chroma plane block is
338+8x16; the hardcoded halving turns it into 4x8, which is exactly the `left`
339+value in the assert. `ss_x = ss_y = 0`, so `(bw >> ss_x, bh >> ss_y)` is a
340+no-op there and `(bw / 2, bh / 2)` is a pure error.
341+
342+Confirming it is the ONLY blocker on this stream: the identical recipe re-encoded
343+with `--enable-intrabc=0` (118365 bytes, which never routes through
344+`decode_intrabc_rect`) decodes on this tree **byte-exact against the oracle
345+aomdec on all six frames**. So the 18779 -> 130708 damage and the 459866 vs
346+369136 `EC_SYMR` asymmetry the sweep recorded are behind this line, not
347+independent of it.
348+
349+## Class and ownership
350+
351+Same class `av1tilerows` landed in the lossless 16x4/4x16 chroma-pair walk: a
352+hardcoded 4:2:0-shaped chroma reach at 4:4:4. `decode_intrabc_rect` is a
353+different function from the one that lane fixed and carries its own gates
354+(`a_lossless_444_intrabc_rect_leaf_walks_per_4x4_units`,
355+`a_skipped_lossless_intrabc_rect_strip_zeroes_its_entropy_bands`), which is why
356+r1 reported rather than fixed it. Appendix r3 takes it on, on this branch, with
357+those gates as the blast-radius check.