An inter block never stamped the luma/chroma mode maps, so a later intra block's edge-filter type fell back to a stale SMOOTH mode
Browse files at this commitcb1dc1fc856b96ef2fec85009ac37372b82a3887Parent: f6360d3- fix
- an inter block never stamped the luma/chroma mode maps, so a later intra block's edge-filter type fell back to a stale SMOOTH mode
2 changed files +50 -2
crates/ec-av1/src/decode.rsmodified+44 -1
| @@ -2515,6 +2515,22 @@ pub(crate) fn uv_mode_mi_override_hits() -> usize { | ||
| 2515 | 2515 | UV_MODE_MI_OVERRIDE_HITS.with(|c| c.get()) |
| 2516 | 2516 | } |
| 2517 | 2517 | |
| 2518 | +// lane-t900 r8: how many intra edge-filter-type reads (luma + chroma) the | |
| 2519 | +// INTER neighbour stamp saved: the coarse SUB band still held a SMOOTH mode | |
| 2520 | +// from an earlier block in that pixel row/column while the mi-exact map -- | |
| 2521 | +// which an inter block only started writing this round -- correctly says the | |
| 2522 | +// neighbour is not smooth (libaom `is_smooth`: an inter neighbour's `mode` is | |
| 2523 | +// an INTER mode, and its `uv_mode` "is not set for inter blocks"). | |
| 2524 | +thread_local! { | |
| 2525 | + static INTER_NEIGHBOUR_NOT_SMOOTH_HITS: std::cell::Cell<usize> = | |
| 2526 | + const { std::cell::Cell::new(0) }; | |
| 2527 | +} | |
| 2528 | + | |
| 2529 | +/// Current value of [`INTER_NEIGHBOUR_NOT_SMOOTH_HITS`]. | |
| 2530 | +pub(crate) fn inter_neighbour_not_smooth_hits() -> usize { | |
| 2531 | + INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|c| c.get()) | |
| 2532 | +} | |
| 2533 | + | |
| 2518 | 2534 | // lane-mtfix r1: how many times a chroma intra-edge filter-type read was |
| 2519 | 2535 | // suppressed at a TILE edge that is not a frame edge -- the above/left |
| 2520 | 2536 | // `uv_mode` neighbour of a block on a tile's first mi row/column lives in |
| @@ -5322,6 +5338,23 @@ impl Neighbours { | ||
| 5322 | 5338 | skip_mode: bool, |
| 5323 | 5339 | ) { |
| 5324 | 5340 | let (r, c) = at_mi; |
| 5341 | + // lane-t900 r8 (class new-map-ignores-tile-edge's twin: a map NOBODY | |
| 5342 | + // writes for a whole block class): an INTER block left the luma mode | |
| 5343 | + // map untouched, so a later intra block's `get_intra_edge_filter_type` | |
| 5344 | + // (spec 7.11.2, libaom `reconintra.h`'s `is_smooth`) fell back to the | |
| 5345 | + // coarse SUB-row band, which still held a SMOOTH mode from an earlier | |
| 5346 | + // block in that pixel row -- the directional edge filter then ran at | |
| 5347 | + // strength 3 instead of 2. libaom reads `mbmi->mode` of the neighbour, | |
| 5348 | + // which for an inter block is an INTER mode (>= NEARESTMV) and is | |
| 5349 | + // never smooth; DC_PRED is this map's equivalent (the sub-8x8 groups | |
| 5350 | + // already stamped it). | |
| 5351 | + // The chroma twin: `is_smooth(mbmi, plane > 0)` returns 0 outright for | |
| 5352 | + // an inter neighbour ("uv_mode is not set for inter blocks"), so the | |
| 5353 | + // uv map must read DC_PRED over an inter block's cells too. | |
| 5354 | + if is_inter { | |
| 5355 | + self.record_mode_mi(r, c, w_mi, h_mi, DC_PRED); | |
| 5356 | + self.record_uv_mode_mi(r, c, w_mi, h_mi, DC_PRED); | |
| 5357 | + } | |
| 5325 | 5358 | let altref = is_inter && ref_frame == crate::mvstack::ALTREF_FRAME; |
| 5326 | 5359 | for cell in 0..w_mi { |
| 5327 | 5360 | self.above_skip[c + cell] = skip; |
| @@ -5702,6 +5735,11 @@ impl Neighbours { | ||
| 5702 | 5735 | if above != self.above_uv_mode[c] || left != self.left_uv_mode[r] { |
| 5703 | 5736 | UV_MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); |
| 5704 | 5737 | } |
| 5738 | + if (is_smooth_mode(self.above_uv_mode[c]) && !is_smooth_mode(above)) | |
| 5739 | + || (is_smooth_mode(self.left_uv_mode[r]) && !is_smooth_mode(left)) | |
| 5740 | + { | |
| 5741 | + INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|h| h.set(h.get() + 1)); | |
| 5742 | + } | |
| 5705 | 5743 | is_smooth_mode(above) || is_smooth_mode(left) |
| 5706 | 5744 | } |
| 5707 | 5745 | |
| @@ -5757,6 +5795,11 @@ impl Neighbours { | ||
| 5757 | 5795 | if above != self.above_mode[c] || left != self.left_mode[r] { |
| 5758 | 5796 | MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); |
| 5759 | 5797 | } |
| 5798 | + if (is_smooth_mode(self.above_mode[c]) && !is_smooth_mode(above)) | |
| 5799 | + || (is_smooth_mode(self.left_mode[r]) && !is_smooth_mode(left)) | |
| 5800 | + { | |
| 5801 | + INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|h| h.set(h.get() + 1)); | |
| 5802 | + } | |
| 5760 | 5803 | // A neighbour the coarse band offered where the tile edge makes it |
| 5761 | 5804 | // unavailable -- must never happen (see `MODE_TILE_EDGE_COARSE_LEAKS`). |
| 5762 | 5805 | if (mi_r <= self.tile_row0_mi && self.above_mode[c] != DC_PRED) |
| @@ -11052,7 +11095,7 @@ impl PlaneBuf { | ||
| 11052 | 11095 | let row0: Vec<u16> = prediction[..side.min(8)].to_vec(); |
| 11053 | 11096 | let col0: Vec<u16> = (0..side.min(8)).map(|r| prediction[r * side]).collect(); |
| 11054 | 11097 | eprintln!( |
| 11055 | - "@{} OUR_PRED x={x} y={y} side={side} side={side} mode={mode} ad={angle_delta} sum={sum} row0={row0:?} col0={col0:?}", std::panic::Location::caller() | |
| 11098 | + "@{} OUR_PRED x={x} y={y} side={side} side={side} mode={mode} ad={angle_delta} ft={} sum={sum} row0={row0:?} col0={col0:?}", std::panic::Location::caller(), i32::from(smooth_neighbor) | |
| 11056 | 11099 | ); |
| 11057 | 11100 | } |
| 11058 | 11101 | for row in 0..side { |
crates/ec-av1/src/stream.rsmodified+6 -1
| @@ -30358,6 +30358,9 @@ mod tests { | ||
| 30358 | 30358 | crate::decode::edge_filter_mi_fix_hits(), |
| 30359 | 30359 | ); |
| 30360 | 30360 | let sub8tx_before = crate::decode::sub8_chroma_tx_from_ref_hits(); |
| 30361 | + // lane-t900 r8: the intra edge-filter type an INTER neighbour keeps | |
| 30362 | + // non-smooth (the coarse SUB band still holds an older SMOOTH mode). | |
| 30363 | + let notsmooth_before = crate::decode::inter_neighbour_not_smooth_hits(); | |
| 30361 | 30364 | let i16_before = crate::decode::intra16x4_in_inter_hits(); |
| 30362 | 30365 | let frames = match decode_stream(&stream) { |
| 30363 | 30366 | Ok(frames) => frames, |
| @@ -30373,6 +30376,7 @@ mod tests { | ||
| 30373 | 30376 | crate::decode::edge_filter_mi_fix_hits() - before.6, |
| 30374 | 30377 | ); |
| 30375 | 30378 | let sub8tx = crate::decode::sub8_chroma_tx_from_ref_hits() - sub8tx_before; |
| 30379 | + let notsmooth = crate::decode::inter_neighbour_not_smooth_hits() - notsmooth_before; | |
| 30376 | 30380 | let i16_now = crate::decode::intra16x4_in_inter_hits(); |
| 30377 | 30381 | let i16 = ( |
| 30378 | 30382 | i16_now.0 - i16_before.0, |
| @@ -30391,6 +30395,7 @@ mod tests { | ||
| 30391 | 30395 | ("intra16x4_in_inter 4x16", i16.1), |
| 30392 | 30396 | ("intra16x4_in_inter chroma_ref", i16.2), |
| 30393 | 30397 | ("sub8_chroma_tx_from_ref", sub8tx), |
| 30398 | + ("inter_neighbour_not_smooth", notsmooth), | |
| 30394 | 30399 | ] { |
| 30395 | 30400 | assert!( |
| 30396 | 30401 | n > 0, |
| @@ -30416,7 +30421,7 @@ mod tests { | ||
| 30416 | 30421 | "{NAME}: 15 shown frames pixel-exact on every plane; warp_plane_suppress={} \ |
| 30417 | 30422 | cdef_idx={} inter_sb128_vert={} interintra_rect={} non_chroma_ref_ctx_skip={} \ |
| 30418 | 30423 | intra_in_inter_txctx={} edge_filter_mi_fix={} intra16x4_in_inter={:?} \ |
| 30419 | - sub8_chroma_tx_from_ref={sub8tx}", | |
| 30424 | + sub8_chroma_tx_from_ref={sub8tx} inter_neighbour_not_smooth={notsmooth}", | |
| 30420 | 30425 | fired.0, fired.1, fired.2, fired.3, fired.4, fired.5, fired.6, i16 |
| 30421 | 30426 | ); |
| 30422 | 30427 | } |