The loop filter ignored spec 7.14.2's skip/pu_edge suppression, filtering a var-tx interior edge lattice the reference never touches
Browse files at this commitfc0fe408d7258b84a7ee54323edd455672a14302Parent: 6f01e4d- fix
- the loop filter ignored spec 7.14.2's skip/pu_edge suppression, filtering a var-tx interior edge lattice the reference never touches
1 changed file +31 -0
- crates/ec-av1/src/decode.rs +31 -0
crates/ec-av1/src/decode.rsmodified+31 -0
| @@ -4428,6 +4428,12 @@ struct Neighbours { | ||
| 4428 | 4428 | /// unobservable from the pixels alone. Counted by |
| 4429 | 4429 | /// [`cdef_unwritten_skip_units`]. |
| 4430 | 4430 | skip_written: Vec<bool>, |
| 4431 | + /// Per-4x4-mi origin `(mi_row, mi_col)` of the coded (prediction) block | |
| 4432 | + /// covering that cell -- spec 7.14.2's `isBlockEdge`/libaom `pu_edge`, | |
| 4433 | + /// which re-enables the loop filter at a prediction boundary between two | |
| 4434 | + /// skipped inter blocks (lane-mergefix r4). Written by | |
| 4435 | + /// [`Self::fill_skip_grid_rect`], whose `at_mi` IS that origin. | |
| 4436 | + blk_org_grid: Vec<[u16; 2]>, | |
| 4431 | 4437 | skip_grid_cols_mi: usize, |
| 4432 | 4438 | /// Per-4x4-mi luma transform width in pixels (8/16/32/64) -- this decoder |
| 4433 | 4439 | /// never splits a coded block's transform below its own size (round 2: |
| @@ -4548,6 +4554,7 @@ impl Neighbours { | ||
| 4548 | 4554 | mi_rows, |
| 4549 | 4555 | skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], |
| 4550 | 4556 | skip_written: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], |
| 4557 | + blk_org_grid: vec![[0u16; 2]; cols * (SUB / MI) * rows * (SUB / MI)], | |
| 4551 | 4558 | skip_grid_cols_mi: cols * (SUB / MI), |
| 4552 | 4559 | tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 4553 | 4560 | tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| @@ -4982,6 +4989,9 @@ impl Neighbours { | ||
| 4982 | 4989 | if let Some(cell) = self.skip_written.get_mut(idx) { |
| 4983 | 4990 | *cell = true; |
| 4984 | 4991 | } |
| 4992 | + if let Some(org) = self.blk_org_grid.get_mut(idx) { | |
| 4993 | + *org = [mi_r as u16, mi_c as u16]; | |
| 4994 | + } | |
| 4985 | 4995 | } |
| 4986 | 4996 | } |
| 4987 | 4997 | } |
| @@ -14211,6 +14221,27 @@ fn edge_params( | ||
| 14211 | 14221 | let cur_delta_lf = i32::from(n.delta_lf_grid[mi_r * n.skip_grid_cols_mi + mi_c][delta_idx]); |
| 14212 | 14222 | let pv_delta_lf = i32::from(n.delta_lf_grid[pv_mi_r * n.skip_grid_cols_mi + pv_mi_c][delta_idx]); |
| 14213 | 14223 | |
| 14224 | + // spec 7.14.2 / libaom `set_lpf_parameters`: a transform edge between two | |
| 14225 | + // SKIPPED INTER blocks is filtered only when it is also a prediction | |
| 14226 | + // (coded-block) edge -- `!pv_skip || !curr_skipped || pu_edge`. The | |
| 14227 | + // omission of this term (on the stale invariant "a coded block's transform | |
| 14228 | + // is always its own full size", which var-tx broke) had us filtering an | |
| 14229 | + // interior 8-px lattice the reference never touches: on the pinned 192x68 | |
| 14230 | + // inter stream frame 1 went from 7244 wrong post-deblock luma px to 0. | |
| 14231 | + let cur_org = n.blk_org_grid[mi_r * n.skip_grid_cols_mi + mi_c]; | |
| 14232 | + let pu_edge = if dir == 0 { | |
| 14233 | + mi_c == usize::from(cur_org[1]) | |
| 14234 | + } else { | |
| 14235 | + mi_r == usize::from(cur_org[0]) | |
| 14236 | + }; | |
| 14237 | + if !pu_edge | |
| 14238 | + && cur_ref != 0 | |
| 14239 | + && pv_ref != 0 | |
| 14240 | + && n.skip_at(mi_r, mi_c) | |
| 14241 | + && n.skip_at(pv_mi_r, pv_mi_c) | |
| 14242 | + { | |
| 14243 | + return None; | |
| 14244 | + } | |
| 14214 | 14245 | let cur_level = lf_level(lf, plane_idx, dir, cur_ref, cur_delta_lf, segment_id_at(mi_r, mi_c)); |
| 14215 | 14246 | let pv_level = lf_level( |
| 14216 | 14247 | lf, |