forge
Explore
Log in

Don't you dare go Hollow

The 16x16-level frame-edge partition bit was discarded too

Browse files at this commit

b5166a175cc8f387f061bba525e33e904264d26dAhmet Kaan GümüşParent: 135feff
  • fix
    • the 16x16-level frame-edge partition bit was discarded too
Show full message
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.rsmodified+38 -3
@@ -11902,16 +11902,51 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1190211902 does not code yet",
1190311903 ));
1190411904 }
11905- if has_cols16 {
11905+ // lane-hgkf r1, same class as the 64/32-level
11906+ // fix above: this gathered bit IS the partition
11907+ // (libaom `ec_read_partition_impl`), 0 =
11908+ // HORZ/VERT and only 1 = SPLIT. Forcing SPLIT
11909+ // desynced the bottom band of a 3840x1608 frame
11910+ // at mi_row=400 mi_col=32. Only the in-frame
11911+ // half of the strip is coded.
11912+ let edge_bit = if has_cols16 {
1190611913 dec.symbol_fixed(&gather(
1190711914 &cdfs.partition_w16[ctx16],
1190811915 VERT_ALIKE,
11909- ));
11916+ ))
1191011917 } else {
1191111918 dec.symbol_fixed(&gather(
1191211919 &cdfs.partition_w16[ctx16],
1191311920 HORZ_ALIKE,
11914- ));
11921+ ))
11922+ };
11923+ bump_edge_part(if edge_bit == 1 { 3 } else { 2 });
11924+ if edge_bit != 1 {
11925+ let strip_mi = (
11926+ sr * SUB_MI as usize,
11927+ sc * SUB_MI as usize,
11928+ );
11929+ let (sw, sh) = if has_cols16 { (16, 8) } else { (8, 16) };
11930+ let mode = decode_leaf_rect(
11931+ &mut dec,
11932+ &mut cdfs,
11933+ &mut neighbours,
11934+ at16,
11935+ strip_mi,
11936+ sw,
11937+ sh,
11938+ None,
11939+ &mut y,
11940+ &mut u,
11941+ &mut v,
11942+ enable_filter_intra,
11943+ allow_screen_content_tools,
11944+ base_q_idx,
11945+ tx_select,
11946+ reduced_tx_set,
11947+ )?;
11948+ let _ = mode;
11949+ continue;
1191511950 }
1191611951 let (mi_row0, mi_col0) =
1191711952 (sr as u32 * SUB_MI, sc as u32 * SUB_MI);