Drop the duplicate in-inter tx-depth ctx override, keep the counter on the band read
Browse files at this commiteec9297869583f9d3dbb117ebe595aa426d803c0Parent: 4516c32- refactor
- drop the duplicate in-inter tx-depth ctx override, keep the counter on the band read
1 changed file +15 -27
- crates/ec-av1/src/decode.rs +15 -27
crates/ec-av1/src/decode.rsmodified+15 -27
| @@ -6749,32 +6749,6 @@ fn tx_size_context_rect( | |||
| 6749 | // this way, lane-sb128b r1). Without the cap the 64x128 half of a 128-root | 6749 | // this way, lane-sb128b r1). Without the cap the 64x128 half of a 128-root |
| 6750 | // VERT reads the tx-depth symbol off row 0 where libaom uses row 1. | 6750 | // VERT reads the tx-depth symbol off row 0 where libaom uses row 1. |
| 6751 | let (own_w, own_h) = (own_w.min(64), own_h.min(64)); | 6751 | let (own_w, own_h) = (own_w.min(64), own_h.min(64)); |
| 6752 | - // lane-midcut r2: on an INTER frame `get_tx_size_context` reads the real | ||
| 6753 | - // `TXFM_CONTEXT` bands and lets an INTER neighbour contribute its BLOCK | ||
| 6754 | - // size ([`tx_size_context_txfm_rect`]); the deblock-grid approximation | ||
| 6755 | - // below is the KEY FRAME's, and it is right only where those bands were | ||
| 6756 | - // never written. The 1:4 intra strip already branched this way at its own | ||
| 6757 | - // call site -- every other rect intra reader reached from an inter frame | ||
| 6758 | - // (2:1 strips, the 32-level and 64-level 1:4 bodies) read `tx_size_cat*` | ||
| 6759 | - // off the wrong row whenever the neighbour above was an inter block whose | ||
| 6760 | - // var-tx tree had split (measured: a 32x8 intra strip at mi(118,280) of | ||
| 6761 | - // the 10-bit 3840x1608 stream read ctx 1 where aomdec reads ctx 2). | ||
| 6762 | - if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() { | ||
| 6763 | - let ctx = tx_size_context_txfm_rect(n, (mi_r, mi_c), own_w, own_h); | ||
| 6764 | - // Count only the blocks the deblock-grid approximation got WRONG, so a | ||
| 6765 | - // gate asserting this counter proves the override changed a CDF row | ||
| 6766 | - // (class gate-blind-to-feature: a plain "rect intra in inter" tally is | ||
| 6767 | - // green on the buggy code too). | ||
| 6768 | - let stale = usize::from( | ||
| 6769 | - mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w, | ||
| 6770 | - ) + usize::from( | ||
| 6771 | - mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h, | ||
| 6772 | - ); | ||
| 6773 | - if ctx != stale { | ||
| 6774 | - INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 6775 | - } | ||
| 6776 | - return ctx; | ||
| 6777 | - } | ||
| 6778 | let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w; | 6752 | let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w; |
| 6779 | let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h; | 6753 | let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h; |
| 6780 | if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { | 6754 | if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { |
| @@ -13713,12 +13687,26 @@ fn tx_size_context_txfm_rect( | |||
| 13713 | n.left_side_mi[mi_r], | 13687 | n.left_side_mi[mi_r], |
| 13714 | ); | 13688 | ); |
| 13715 | } | 13689 | } |
| 13716 | - match (has_above, has_left) { | 13690 | + let ctx = match (has_above, has_left) { |
| 13717 | (true, true) => usize::from(above) + usize::from(left), | 13691 | (true, true) => usize::from(above) + usize::from(left), |
| 13718 | (true, false) => usize::from(above), | 13692 | (true, false) => usize::from(above), |
| 13719 | (false, true) => usize::from(left), | 13693 | (false, true) => usize::from(left), |
| 13720 | (false, false) => 0, | 13694 | (false, false) => 0, |
| 13695 | + }; | ||
| 13696 | + // lane-midcut r3: count only the blocks the KEY FRAME deblock-grid | ||
| 13697 | + // approximation ([`tx_size_context_rect`]) would have read off a DIFFERENT | ||
| 13698 | + // CDF row, i.e. exactly the blocks this band read fixes -- a plain "rect | ||
| 13699 | + // intra in an inter frame" tally is green on the buggy code too (class | ||
| 13700 | + // gate-blind-to-feature). | ||
| 13701 | + if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() { | ||
| 13702 | + let (cw, ch) = (own_w.min(64), own_h.min(64)); | ||
| 13703 | + let stale = usize::from(has_above && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= cw) | ||
| 13704 | + + usize::from(has_left && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= ch); | ||
| 13705 | + if ctx != stale { | ||
| 13706 | + INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 13707 | + } | ||
| 13721 | } | 13708 | } |
| 13709 | + ctx | ||
| 13722 | } | 13710 | } |
| 13723 | 13711 | ||
| 13724 | /// lane-intrasplit r3: `above_inter`/`left_inter` are mi-granular bands (they | 13712 | /// lane-intrasplit r3: `above_inter`/`left_inter` are mi-granular bands (they |