From b5166a175cc8f387f061bba525e33e904264d26d 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 06:35:40 +0300 Subject: [PATCH] fix(av1): the 16x16-level frame-edge partition bit was discarded too Same class as the 64/32-level fix in the previous commit (`parsed-then- discarded`): the 16-level edge reader gathered the bit and then always split into four 8x8 leaves. libaom answers that bit with PARTITION_HORZ (resp. VERT) when it is 0, i.e. a single 16x8 / 8x16 strip of which only the in-frame half is coded. On a 3840x1608 10-bit key frame this desynced from mi_row=400 mi_col=32 to the end of the tile. The strip decodes through `decode_leaf_rect` at the leaf's real mi origin (`sr * SUB_MI`, `sc * SUB_MI`) -- the first cut of this used the coarse index times two, which kept the entropy stream aligned but predicted the strip at mi(200,16) instead of mi(400,32) and reconstructed 34k samples wrong. Measured on the 3840x1608 10-bit mid-film key frame vs `ffmpeg -pix_fmt yuv420p10le`: 51768 mismatching samples (Y 35861 / U 8419 / V 7488) -> 2403, luma only, |delta| <= 2, chroma bit-exact. The pinned head key frame stays bit-exact. --- crates/ec-av1/src/decode.rs | 41 ++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index b3a6b824..aa9402e9 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -11902,16 +11902,51 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( does not code yet", )); } - if has_cols16 { + // lane-hgkf r1, same class as the 64/32-level + // fix above: this gathered bit IS the partition + // (libaom `ec_read_partition_impl`), 0 = + // HORZ/VERT and only 1 = SPLIT. Forcing SPLIT + // desynced the bottom band of a 3840x1608 frame + // at mi_row=400 mi_col=32. Only the in-frame + // half of the strip is coded. + let edge_bit = if has_cols16 { dec.symbol_fixed(&gather( &cdfs.partition_w16[ctx16], VERT_ALIKE, - )); + )) } else { dec.symbol_fixed(&gather( &cdfs.partition_w16[ctx16], HORZ_ALIKE, - )); + )) + }; + bump_edge_part(if edge_bit == 1 { 3 } else { 2 }); + if edge_bit != 1 { + let strip_mi = ( + sr * SUB_MI as usize, + sc * SUB_MI as usize, + ); + let (sw, sh) = if has_cols16 { (16, 8) } else { (8, 16) }; + let mode = decode_leaf_rect( + &mut dec, + &mut cdfs, + &mut neighbours, + at16, + strip_mi, + sw, + sh, + None, + &mut y, + &mut u, + &mut v, + enable_filter_intra, + allow_screen_content_tools, + base_q_idx, + tx_select, + reduced_tx_set, + )?; + let _ = mode; + continue; } let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI);