forge
Explore
Log in

Don't you dare go Hollow

Rect tx-size context compared against the block side, not max_txsize_rect

Browse files at this commit

606ff1583f2ba275c3fde538577a389b17d76b16Ahmet Kaan GümüşParent: 71e7de0
  • fix
    • rect tx-size context compared against the block side, not max_txsize_rect
Show full message
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.rsmodified+6 -0
@@ -5848,6 +5848,12 @@ fn tx_size_context_rect(
5848 own_w: usize,5848 own_w: usize,
5849 own_h: usize,5849 own_h: usize,
5850 ) -> usize {5850 ) -> usize {
5851+ // `get_tx_size_context` compares against `max_txsize_rect_lookup[bsize]`,
5852+ // not the block's own side: no transform is wider or taller than 64, so a
5853+ // block with a 128 side resolves against 64 (the square path already caps
5854+ // this way, lane-sb128b r1). Without the cap the 64x128 half of a 128-root
5855+ // VERT reads the tx-depth symbol off row 0 where libaom uses row 1.
5856+ let (own_w, own_h) = (own_w.min(64), own_h.min(64));
5851 let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w;5857 let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w;
5852 let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h;5858 let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h;
5853 usize::from(above) + usize::from(left)5859 usize::from(above) + usize::from(left)