forge
Explore
Log in

Don't you dare go Hollow

The delta_q unit is the 128 superblock under EC_AV1_SB128

Browse files at this commit

2dc9fc29e78b07487ee08e264b62bf9b0a8faaa6Ahmet Kaan GümüşParent: 7bb33bd
  • fix
    • the delta_q unit is the 128 superblock under EC_AV1_SB128
Show full message
fix(av1): the delta_q unit is the 128 superblock under EC_AV1_SB128

The writer gated its delta_qindex group on a hardcoded 64x64 position
(tile.rs SB_MI) while decode.rs maybe_read_delta_q gates on sb_mi_cur, so
with per-superblock delta_q armed (preset 0) and 128 superblocks on the
writer coded four symbol groups per 128 root and the reader read one --
the first divergent symbol is the second 64 cell's delta_q_abs, surfacing
frames later as the arf refusing a reference slot. The 64-root whole-block
call also claimed is_whole_sb under a 128 superblock, which suppresses the
read on the wrong side. The search-side grid is flattened per 128 root so
the qindex a cell is quantized at is the one its root codes.

Witness: a_128_superblock_clip_whose_root_search_codes_128x128_blocks... ok
crates/ec-av1/src/encode.rsmodified+15 -1
@@ -11739,7 +11739,21 @@ pub(crate) fn encode_inter_frame(
11739 let sb_q: Option<Vec<u8>> = match (&tpl_factors, deltaq_res) {11739 let sb_q: Option<Vec<u8>> = match (&tpl_factors, deltaq_res) {
11740 (Some(f), Some(res)) => {11740 (Some(f), Some(res)) => {
11741 let libaom = dq_tpl_strength();11741 let libaom = dq_tpl_strength();
11742- Some((0..sb_cols * _sb_rows).map(|sb| sb_qindex(f, res, sb, libaom)).collect())11742+ let mut g: Vec<u8> =
11743+ (0..sb_cols * _sb_rows).map(|sb| sb_qindex(f, res, sb, libaom)).collect();
11744+ // lane-b128m: under 128 superblocks the delta_q syntax is coded
11745+ // ONCE per 128 root (the reader's own unit), so all four 64x64
11746+ // cells of a root have to be searched -- and quantized -- at the
11747+ // one qindex the root's top-left cell codes.
11748+ if sb128_on() {
11749+ for sb_r in 0.._sb_rows {
11750+ for sb_c in 0..sb_cols {
11751+ let q = g[(sb_r & !1) * sb_cols + (sb_c & !1)];
11752+ g[sb_r * sb_cols + sb_c] = q;
11753+ }
11754+ }
11755+ }
11756+ Some(g)
11743 }11757 }
11744 _ => None,11758 _ => None,
11745 };11759 };
crates/ec-av1/src/tile.rsmodified+7 -2
@@ -1414,7 +1414,12 @@ fn write_delta_q(
1414 DELTA_Q.with(|c| {1414 DELTA_Q.with(|c| {
1415 let mut plan = c.borrow_mut();1415 let mut plan = c.borrow_mut();
1416 let Some(plan) = plan.as_mut() else { return };1416 let Some(plan) = plan.as_mut() else { return };
1417- if mi.0 % SB_MI as usize != 0 || mi.1 % SB_MI as usize != 0 {1417+ // lane-b128m: the delta_q unit is the SUPERBLOCK, so it is 128 wide
1418+ // under `EC_AV1_SB128` -- decode.rs `maybe_read_delta_q` gates on
1419+ // `sb_mi_cur`, and a writer gating on a hardcoded 64 codes three
1420+ // symbol groups per 128 root the reader never reads.
1421+ let sb_mi = if sb128_armed() { SB_MI as usize * 2 } else { SB_MI as usize };
1422+ if mi.0 % sb_mi != 0 || mi.1 % sb_mi != 0 {
1418 return;1423 return;
1419 }1424 }
1420 if is_whole_sb && skip {1425 if is_whole_sb && skip {
@@ -6619,7 +6624,7 @@ pub(crate) fn sb_coeff_inter_frame_tile_cdfs(
6619 + usize::from(neighbours.left_skip[mi_r]);6624 + usize::from(neighbours.left_skip[mi_r]);
6620 enc.symbol(usize::from(block.skip), &mut cdfs.skip[skip_ctx]);6625 enc.symbol(usize::from(block.skip), &mut cdfs.skip[skip_ctx]);
6621 write_cdef_idx(&mut enc, (mi_r, mi_c), block.skip);6626 write_cdef_idx(&mut enc, (mi_r, mi_c), block.skip);
6622- write_delta_q(&mut enc, &mut cdfs, (mi_r, mi_c), true, block.skip);6627+ write_delta_q(&mut enc, &mut cdfs, (mi_r, mi_c), !sb128_armed(), block.skip);
6623 let ii_ctx = intra_inter_ctx(6628 let ii_ctx = intra_inter_ctx(
6624 has_above,6629 has_above,
6625 has_left,6630 has_left,