From 606ff1583f2ba275c3fde538577a389b17d76b16 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 15:22:03 +0300 Subject: [PATCH] fix(av1): rect tx-size context compared against the block side, not max_txsize_rect get_tx_size_context resolves the above/left transform sizes against max_txsize_rect_lookup[bsize], which tops out at 64x64: a 64x128 or 128x64 block must compare against 64, never against its own 128 side. The rect helper passed the raw block dimensions, so the right 64x128 half of a 128-root VERT read the tx-depth symbol off CDF row 0 where libaom uses row 1 -- entropy desync from that block on (326839/393216 bytes of a 512x512 key frame). The square path already capped this way. After the fix the whole 5370-element all_zero coefficient ladder of a 512x512 sb128 stream is identical to the oracle's; the residual is reconstruction-only. --- crates/ec-av1/src/decode.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 19988e50..fbc3554a 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -5848,6 +5848,12 @@ fn tx_size_context_rect( own_w: usize, own_h: usize, ) -> usize { + // `get_tx_size_context` compares against `max_txsize_rect_lookup[bsize]`, + // not the block's own side: no transform is wider or taller than 64, so a + // block with a 128 side resolves against 64 (the square path already caps + // this way, lane-sb128b r1). Without the cap the 64x128 half of a 128-root + // VERT reads the tx-depth symbol off row 0 where libaom uses row 1. + let (own_w, own_h) = (own_w.min(64), own_h.min(64)); let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w; let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h; usize::from(above) + usize::from(left)