From 79abd1e668357c06c30c5f4c752925eefdbda491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Sep 2026 19:33:46 +0300 Subject: [PATCH] fix(av1): a split-transform superblock-level strip published no TXFM_CONTEXT band `decode_block_rect64`'s `depth != 0` arm returns early, past the tail `txfm_partition_update_rect` lane-frame36 r1 added, so a SPLIT 64x16/16x64/ 64x32/32x64 strip left the above/left TXFM_CONTEXT bands holding the row's init value 64. libaom runs `set_txfm_ctxs(mbmi->tx_size, ...)` for EVERY block, with the SPLIT unit's size. Measured on the 10-bit 3840x1608 stream (58-OBU prefix), decode-order frame 33 (the hidden ARF): after the split 16x64 strip at mi(192,140) (`tx_depth=1` -> TX_16X32) the 32x64 intra block at mi(192,144) read `left_txfm=64` and took `tx_size_cat3` row 2 where aomdec takes row 1 -- same value, different range, desync from there to the end of the frame. With the fix every superblock entry range of every traced frame equals aomdec's, and all 37 output frames of the prefix are byte-exact against ffmpeg (frame 36 was 765464 differing bytes at r1's tip, 1992768 before it). Also adds the oracle's own `EC_ISTEP ... name=tx_depth ... cat=` line to the 2:1 intra-in-inter arm, which is what named this defect. --- crates/ec-av1/src/decode.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 4ec83b8e..5226f94f 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -7542,11 +7542,18 @@ fn decode_intra_rect_in_inter( // The INTER frame's own `TXFM_CONTEXT` bands, not the key frame's // deblock-grid approximation -- [`tx_size_context_txfm_rect`]. let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw.min(64), bh.min(64)); - match tx_cat { + let d = match tx_cat { 1 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), _ => dec.symbol(&mut cdfs.tx_size_cat3[ctx]), + }; + if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { + eprintln!( + "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat={tx_cat} rng={}", + dec.debug_state().0 + ); } + d } else { 0 }; @@ -9584,6 +9591,15 @@ fn decode_block_rect64( let (puv_size, puv_colors) = palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); + // lane-frame36 r2: `set_txfm_ctxs` runs for EVERY block and this early + // return skips the fn's own tail, so a SPLIT superblock-level strip + // published no TXFM_CONTEXT band and the next block read the row's init + // value 64 as its left transform height. Measured on the 10-bit + // 3840x1608 stream, decode-order frame 33: after the split 16x64 strip + // at mi(192,140) (`tx_depth=1` -> TX_16X32) the 32x64 block at + // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The + // bands carry the SPLIT unit's size, not the block's. + txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); return Ok(()); }