forge
Explore
Log in

Don't you dare go Hollow

A SKIP inter 128x128 block's internal TX_64X64 edges were deblocked

Browse files at this commit

a1764582a4f85f09c7d96a7e8917fbff26bb8126Ahmet Kaan GümüşParent: 8aecbc5
  • fix
    • a SKIP inter 128x128 block's internal TX_64X64 edges were deblocked
Show full message
fix(av1): a SKIP inter 128x128 block's internal TX_64X64 edges were deblocked

libaom `set_one_param_for_line_luma`/`_chroma` suppress every edge that is a
transform-unit edge but not a prediction-unit edge when
`curr_skipped = mbmi->skip_txfm && is_inter_block(mbmi)`. `get_transform_size`
still reports TX_64X64 (luma) / TX_32X32 (chroma) for a skipped 128x128 inter
block, so the tu_edge at the block's own x=64 / y=64 exists -- it is simply
never filtered. This decoder published those units into the lf grid
unconditionally and filtered them.

Two changes in `crates/ec-av1/src/decode.rs`:
- the per-leaf `fill_lf_grid_rect` loop is now gated on `!(skip && is_inter)`,
  leaving the block-level 128 publication (no internal luma edge) in place --
  the 128 root is the only block that reaches that loop skipped, because
  `read_block_tx_size` hands back four TX_64X64 leaves for `side > 64`
  regardless of `skip`.
- `fill_lf_grid_rect`'s uv extent drops its `.min(32)` cap: inert for every
  block up to 64 wide (64/2 == 32) and wrong for a 128-sided one, where it
  published an internal chroma edge every 32 chroma px. A non-skip 128 block
  still gets uv 32 through its own per-leaf calls (`w_mi * MI == 64`).

Also indexes `dump_stage`'s output per decode-order picture (`EC_AV1_POSTDEBLOCK_DUMP`
overwrote `.f0` every frame, so only the last picture was comparable against
aomdec's own indexed rung -- that rung is what isolated this defect).

Measured on the 8-bit 256x256 sb128 inter gate stream: decode-order frames 0-4
were pre-filter exact and frame 4 diverged post-deblock (98 luma px in a 9-px
band at x=64, 274 chroma); all five stages are now exact. aomdec's post-deblock
dump changes ZERO pixels in columns 50..78 of that frame -- it filters nothing
there.
crates/ec-av1/src/decode.rsmodified+27 -8
@@ -4181,10 +4181,17 @@ impl Neighbours {
4181 ) {4181 ) {
4182 let (mi_r, mi_c) = at_mi;4182 let (mi_r, mi_c) = at_mi;
4183 // `av1_get_max_uv_txsize` under 4:2:0: the block's chroma extent is4183 // `av1_get_max_uv_txsize` under 4:2:0: the block's chroma extent is
4184- // half its luma one (min 4 px, the smallest transform), capped at4184+ // half its luma one (min 4 px, the smallest transform).
4185- // TX_32X32 -- independent of this block's luma `tx_depth`.4185+ // lane-sb128c r4: the old `.min(32)` TX_32X32 cap was inert for every
4186- let uv_tx_w = ((w_mi * MI / 2).max(4).min(32)) as u8;4186+ // block up to 64 wide (64/2 == 32) and WRONG for a 128-sided one: it
4187- let uv_tx_h = ((h_mi * MI / 2).max(4).min(32)) as u8;4187+ // published an internal chroma TU edge every 32 chroma px inside the
4188+ // block, which libaom only filters when the block is not
4189+ // `curr_skipped` -- and a non-skip 128 block reaches here again
4190+ // through its own per-leaf calls (`w_mi * MI == 64`, uv 32), which
4191+ // publish that edge correctly. The cap is therefore redundant where
4192+ // it was right and harmful where it was not.
4193+ let uv_tx_w = (w_mi * MI / 2).max(4) as u8;
4194+ let uv_tx_h = (h_mi * MI / 2).max(4) as u8;
4188 let cur = CURRENT_DELTA_LF.with(|c| c.get());4195 let cur = CURRENT_DELTA_LF.with(|c| c.get());
4189 let snapshot: [i8; 4] = if DELTA_LF_MULTI.with(|c| c.get()) {4196 let snapshot: [i8; 4] = if DELTA_LF_MULTI.with(|c| c.get()) {
4190 std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8)4197 std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8)
@@ -8845,8 +8852,13 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize,
8845 8852
8846 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {8853 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {
8847 use std::io::Write;8854 use std::io::Write;
8855+ // lane-sb128c r4: decode-order index like `EC_AV1_PREFILT_DUMP`'s -- a
8856+ // fixed `.f0` overwrote every frame, so the only comparable stage dump
8857+ // was the last decoded picture (aomdec's own rung indexes its files).
8858+ static STAGE_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
8859+ let idx = STAGE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
8848 if let Ok(path) = std::env::var(var)8860 if let Ok(path) = std::env::var(var)
8849- && let Ok(mut f) = std::fs::File::create(format!("{path}.f0"))8861+ && let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}"))
8850 {8862 {
8851 for p in [y, u, v] {8863 for p in [y, u, v] {
8852 let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect();8864 let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect();
@@ -19250,9 +19262,16 @@ fn decode_inter_block(
19250 },19262 },
19251 );19263 );
19252 // lane-txselect: a var-tx block's deblock edges follow its own transform19264 // lane-txselect: a var-tx block's deblock edges follow its own transform
19253- // units, not the block. Chroma still reads `tx_h_grid / 2` (the block's19265+ // units, not the block.
19254- // uv transform is not split) -- a known corner-cut of this round.19266+ // lane-sb128c r4: libaom `set_one_param_for_line_luma` suppresses every
19255- if let Some(leaves) = &vartx_leaves {19267+ // edge that is a TU edge but not a PU edge when
19268+ // `curr_skipped = mbmi->skip_txfm && is_inter_block(mbmi)`, so a SKIP
19269+ // inter block's internal transform edges are never filtered even though
19270+ // `get_transform_size` still reports TX_64X64 for it. The only block that
19271+ // reaches here skipped is the 128 root (`read_block_tx_size` hands back
19272+ // four TX_64X64 leaves for `side > 64` regardless of `skip`); leaving its
19273+ // block-level 128 publication in place is exactly that suppression.
19274+ if let Some(leaves) = (!(skip && is_inter)).then_some(()).and(vartx_leaves.as_ref()) {
19256 for &(row, col, tx_px) in leaves {19275 for &(row, col, tx_px) in leaves {
19257 neighbours.fill_lf_grid_rect(19276 neighbours.fill_lf_grid_rect(
19258 (at_mi.0 + row, at_mi.1 + col),19277 (at_mi.0 + row, at_mi.1 + col),