forge
Explore
Log in

Don't you dare go Hollow

The second half of a 128-root HORZ/VERT inter block never read its own cdef_idx literal

Browse files at this commit

d5c0a13384281712d9f8dab7f427587dc4d3bbefAhmet Kaan GümüşParent: 9385d73
  • fix
    • the second half of a 128-root HORZ/VERT inter block never read its own cdef_idx literal
Show full message
fix(av1): the second half of a 128-root HORZ/VERT inter block never read its own cdef_idx literal

libaom keeps `cdef_transmitted[4]` -- one flag per 64x64 CDEF unit of a
128x128 superblock, indexed `(mi_col & 16) != 0` + 2 * `(mi_row & 16) != 0`
(`read_cdef`, decodemv.c:50-81) -- so both halves of a 128-root
PARTITION_HORZ/VERT read a `cdef_bits`-wide literal, each into its own unit.
Our flag is a single bool reset per coded piece, and the inter tile loop's
128-root HORZ/VERT arm was the one arm that never reset it between the two
halves (the key-frame loop already did), so the second half consumed
`cdef_bits` fewer bits than the encoder wrote and the tile desynced at that
block's mode info -- a literal-width divergence invisible to a value ladder
(the whole coefficient block before it is bit-identical, ranges rejoin only
at the next block's entry: 57521 -> aomdec 40079, ours 39850).

Witness, 10-bit 1920x792 128-superblock stream, decode-order frame 10, first
differing luma pixel px(192,0) = mi(0,48) = the right half of a 128x128
PARTITION_VERT. Pre-filter decode-order compare vs the instrumented aomdec
over a 16-frame cut: frames 10..13 go 2316966 / 1746025 / 1307747 / 2161740
differing bytes -> 0 each; frames 0..9 stay exact; residue moves to frame 14
(14 bytes).
crates/ec-av1/src/decode.rsmodified+9 -0
@@ -27266,6 +27266,15 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
27266 if i > 0 && (at_mi.0 >= mi_rows as usize || at_mi.1 >= mi_cols as usize) {27266 if i > 0 && (at_mi.0 >= mi_rows as usize || at_mi.1 >= mi_cols as usize) {
27267 break;27267 break;
27268 }27268 }
27269+ // Each half reads its OWN `cdef_idx` literal: libaom keeps
27270+ // `cdef_transmitted[4]`, one flag per 64x64 CDEF unit of a
27271+ // 128x128 superblock (`read_cdef`, decodemv.c:50-81), and
27272+ // the two halves of a 128-root HORZ/VERT sit in different
27273+ // units (index `col_in_sb != 0` + 2 * `row_in_sb != 0`).
27274+ // The key-frame 128 loop already resets here; without it
27275+ // the second half skipped a `cdef_bits`-wide literal that
27276+ // libaom reads, desyncing the tile at that block.
27277+ CDEF_TRANSMITTED.with(|c| c.set(false));
27269 inter_piece!(27278 inter_piece!(
27270 at_mi, SB * 2,27279 at_mi, SB * 2,
27271 TxbSet::Luma64, TxbSet::Luma64, TxbSet::Chroma32, TX32, TX32,27280 TxbSet::Luma64, TxbSet::Luma64, TxbSet::Chroma32, TX32, TX32,