The delta_q unit is the 128 superblock under EC_AV1_SB128
Browse files at this commit2dc9fc29e78b07487ee08e264b62bf9b0a8faaa6Parent: 7bb33bd- fix
- the delta_q unit is the 128 superblock under EC_AV1_SB128
2 changed files +22 -3
- crates/ec-av1/src/encode.rs +15 -1
- crates/ec-av1/src/tile.rs +7 -2
crates/ec-av1/src/encode.rsmodified+15 -1
| @@ -11739,7 +11739,21 @@ pub(crate) fn encode_inter_frame( | ||
| 11739 | 11739 | let sb_q: Option<Vec<u8>> = match (&tpl_factors, deltaq_res) { |
| 11740 | 11740 | (Some(f), Some(res)) => { |
| 11741 | 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 | 11758 | _ => None, |
| 11745 | 11759 | }; |
crates/ec-av1/src/tile.rsmodified+7 -2
| @@ -1414,7 +1414,12 @@ fn write_delta_q( | ||
| 1414 | 1414 | DELTA_Q.with(|c| { |
| 1415 | 1415 | let mut plan = c.borrow_mut(); |
| 1416 | 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 | 1423 | return; |
| 1419 | 1424 | } |
| 1420 | 1425 | if is_whole_sb && skip { |
| @@ -6619,7 +6624,7 @@ pub(crate) fn sb_coeff_inter_frame_tile_cdfs( | ||
| 6619 | 6624 | + usize::from(neighbours.left_skip[mi_r]); |
| 6620 | 6625 | enc.symbol(usize::from(block.skip), &mut cdfs.skip[skip_ctx]); |
| 6621 | 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 | 6628 | let ii_ctx = intra_inter_ctx( |
| 6624 | 6629 | has_above, |
| 6625 | 6630 | has_left, |