forge
Explore
Log in

Don't you dare go Hollow

Tx_size_context_txfm read above_inter/left_inter at SUB granularity, not mi

Browse files at this commit

4ee6fb63534241484b9e6f6eb3aeb42351a4cfcfAhmet Kaan GümüşParent: 05708e1
  • fix
    • tx_size_context_txfm read above_inter/left_inter at SUB granularity, not mi
Show full message
fix(av1): tx_size_context_txfm read above_inter/left_inter at SUB granularity, not mi

`Neighbours::above_inter`/`left_inter` are written per mi cell by
`record_inter_rect_mi`, but `tx_size_context_txfm` indexed them with
`mi_c / (SUB / MI)` / `mi_r / (SUB / MI)` -- i.e. it asked a block two mi
away whether it was inter. libaom's `get_tx_size_context` lets an INTER
neighbour contribute its BLOCK size instead of its transform size, so
whenever that mis-indexed cell said "intra" while the true neighbour was a
var-tx-split inter block, the neighbour contributed its (smaller) split
transform size and the `tx_depth` symbol was read from CDF row 0 instead of
row 1 -- a silent entropy desync at the first intra-in-inter block whose
left/above neighbour split its transform.

Gate `a_real_aomenc_10bit_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact`
(64x64 10-bit, seed 54) goes RED -> green: first diverging element was
frame 4 mi(4,12) `tx_depth val=1 ctx=0 rng=46620` vs the instrumented
aomdec's `ctx=1 cat=1 rng=51092`.
crates/ec-av1/src/decode.rsmodified+8 -2
@@ -12202,10 +12202,16 @@ fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize), side: usiz
1220212202 let has_left = mi_c > n.tile_col0_mi;
1220312203 let mut above = usize::from(n.above_txfm[mi_c]) >= side;
1220412204 let mut left = usize::from(n.left_txfm[mi_r]) >= side;
12205- if has_above && n.above_inter[mi_c / (SUB / MI)] {
12205+ // lane-mergefix: `above_inter`/`left_inter` are written per mi
12206+ // (`record_inter_rect_mi`), NOT per [`SUB`] cell -- reading them at
12207+ // `mi_c / (SUB / MI)` asked a block two mi rows/columns away whether it
12208+ // was inter, so a var-tx-split inter neighbour contributed its (smaller)
12209+ // transform size instead of its block size and the `tx_depth` CDF row
12210+ // came out one too low.
12211+ if has_above && n.above_inter[mi_c] {
1220612212 above = n.above_side_mi[mi_c] >= side;
1220712213 }
12208- if has_left && n.left_inter[mi_r / (SUB / MI)] {
12214+ if has_left && n.left_inter[mi_r] {
1220912215 left = n.left_side_mi[mi_r] >= side;
1221012216 }
1221112217 match (has_above, has_left) {