Merge branch 'lane-counters' (0ec260f9): 388 gate-counter bumps routed through hit!/hit_do! behind the default-on cargo feature gate-counters; --no-default-features drops them (-0.8% instructions) with 24/24 gate hashes identical on both builds; inter_last_mc and the trace latch are decode state, left alone
Browse files at this commit12 changed files +628 -500
- crates/ec-av1/Cargo.toml +8 -0
- crates/ec-av1/examples/decode_probe.rs +5 -0
- crates/ec-av1/src/decode.rs +532 -472
- crates/ec-av1/src/film_grain.rs +2 -1
- crates/ec-av1/src/hits.rs +47 -0
- crates/ec-av1/src/intra.rs +4 -3
- crates/ec-av1/src/lib.rs +1 -0
- crates/ec-av1/src/mc.rs +7 -6
- crates/ec-av1/src/motion_field.rs +3 -2
- crates/ec-av1/src/mvstack.rs +9 -8
- crates/ec-av1/src/restoration.rs +8 -7
- crates/ec-av1/src/superres.rs +2 -1
crates/ec-av1/Cargo.tomlmodified+8 -0
| @@ -9,3 +9,11 @@ authors.workspace = true | ||
| 9 | 9 | [dependencies] |
| 10 | 10 | ec-core.workspace = true |
| 11 | 11 | ec-av1-syntax.workspace = true |
| 12 | + | |
| 13 | +[features] | |
| 14 | +default = ["gate-counters"] | |
| 15 | +# Compiles the ~550 `*_HITS` gate counters (see `src/hits.rs`). ON by default so | |
| 16 | +# every test gate and the probe's census see the same numbers they always have; | |
| 17 | +# a shipped decoder can build `--no-default-features` to drop the TLS bump on | |
| 18 | +# each counted path -- the `*_hits()` accessors still compile and return 0. | |
| 19 | +gate-counters = [] |
crates/ec-av1/examples/decode_probe.rsmodified+5 -0
| @@ -29,6 +29,11 @@ fn main() { | ||
| 29 | 29 | } |
| 30 | 30 | }; |
| 31 | 31 | let report = || { |
| 32 | + // The census below reads ec-av1's gate counters; without the crate's | |
| 33 | + // `gate-counters` feature every one of them is compiled out and reads 0. | |
| 34 | + if !cfg!(feature = "gate-counters") { | |
| 35 | + println!("counters disabled (built without the gate-counters feature)"); | |
| 36 | + } | |
| 32 | 37 | let (sc, dp) = ec_av1::decode::reelc_chroma_counters(); |
| 33 | 38 | println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}"); |
| 34 | 39 | let (h, v, c) = ec_av1::stream::rect4_32_counters(); |
crates/ec-av1/src/decode.rsmodified+532 -472
Diff too large; view file
| @@ -20,6 +20,7 @@ | ||
| 20 | 20 | //! inside one, forcing the gathered-CDF partial-superblock path, is round 2 |
| 21 | 21 | //! too). Anything outside that refuses with [`Error::unsupported`] rather than |
| 22 | 22 | //! silently miscoding. |
| 23 | +use crate::hits::{hit, hit_do}; | |
| 23 | 24 | |
| 24 | 25 | use ec_av1_syntax::{ |
| 25 | 26 | CdefParams, DeltaParams, LoopFilterParams, LoopRestorationParams, |
| @@ -526,7 +527,7 @@ fn warp_plane_allowed(w: usize, h: usize) -> bool { | ||
| 526 | 527 | if w >= 8 && h >= 8 { |
| 527 | 528 | return true; |
| 528 | 529 | } |
| 529 | - WARP_PLANE_SUPPRESS_HITS.with(|c| c.set(c.get() + 1)); | |
| 530 | + hit!(WARP_PLANE_SUPPRESS_HITS); | |
| 530 | 531 | false |
| 531 | 532 | } |
| 532 | 533 | |
| @@ -638,7 +639,7 @@ fn maybe_read_delta_q(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_ | ||
| 638 | 639 | } |
| 639 | 640 | let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; |
| 640 | 641 | let reduced = if sign_negative { -abs } else { abs }; |
| 641 | - DELTA_Q_HITS.with(|c| c.set(c.get() + 1)); | |
| 642 | + hit!(DELTA_Q_HITS); | |
| 642 | 643 | let res = fctx.delta_q_res.with(|c| c.get()); |
| 643 | 644 | fctx.current_q_idx.with(|c| c.set((c.get() + reduced * res).clamp(1, 255))); |
| 644 | 645 | } |
| @@ -702,7 +703,7 @@ fn maybe_read_delta_lf(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi | ||
| 702 | 703 | let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; |
| 703 | 704 | let reduced = if sign_negative { -abs } else { abs }; |
| 704 | 705 | cur[i] = (cur[i] + reduced * res).clamp(-63, 63); |
| 705 | - DELTA_LF_HITS.with(|c| c.set(c.get() + 1)); | |
| 706 | + hit!(DELTA_LF_HITS); | |
| 706 | 707 | } |
| 707 | 708 | fctx.current_delta_lf.with(|c| c.set(cur)); |
| 708 | 709 | } |
| @@ -720,7 +721,7 @@ fn maybe_read_cdef_idx(dec: &mut SymbolDecoder, mi_r: usize, mi_c: usize, skip: | ||
| 720 | 721 | } |
| 721 | 722 | let idx = dec.literal(u32::from(bits)) as u8; |
| 722 | 723 | fctx.cdef_transmitted.with(|c| c.set(true)); |
| 723 | - CDEF_IDX_HITS.with(|c| c.set(c.get() + 1)); | |
| 724 | + hit!(CDEF_IDX_HITS); | |
| 724 | 725 | let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize); |
| 725 | 726 | let sb_cols = fctx.cdef_sb_cols.with(|c| c.get()); |
| 726 | 727 | if sb_cols > 0 { |
| @@ -951,7 +952,7 @@ fn read_segment_id(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_c: | ||
| 951 | 952 | return pred as u8; |
| 952 | 953 | } |
| 953 | 954 | let coded = dec.symbol(&mut cdfs.segment_id[ctx]) as i32; |
| 954 | - SEG_ID_HITS.with(|c| c.set(c.get() + 1)); | |
| 955 | + hit!(SEG_ID_HITS); | |
| 955 | 956 | let last_active = fctx.seg.with(|s| i32::from(s.borrow().last_active_seg_id)); |
| 956 | 957 | neg_deinterleave(coded, pred, last_active + 1).clamp(0, last_active) as u8 |
| 957 | 958 | } |
| @@ -1024,7 +1025,7 @@ fn inter_segment_id( | ||
| 1024 | 1025 | let id = if temporal_update { |
| 1025 | 1026 | let ctx = seg_pred_ctx(mi_r, mi_c, fctx); |
| 1026 | 1027 | let predicted = dec.symbol(&mut cdfs.segment_pred[ctx]) != 0; |
| 1027 | - SEG_PRED_HITS.with(|c| c.set(c.get() + 1)); | |
| 1028 | + hit!(SEG_PRED_HITS); | |
| 1028 | 1029 | stamp_seg_pred(mi_r, mi_c, w_mi, h_mi, u8::from(predicted), fctx); |
| 1029 | 1030 | if predicted { |
| 1030 | 1031 | predicted_segment_id(mi_r, mi_c, w_mi, h_mi, fctx) |
| @@ -1130,7 +1131,7 @@ fn tu_reach( | ||
| 1130 | 1131 | let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, block); |
| 1131 | 1132 | let standalone = Reach::of(tx, px + col_off, py + row_off, width, height, fctx); |
| 1132 | 1133 | if fixed != standalone { |
| 1133 | - SPLIT_TU_REACH_FIX_HITS.with(|c| c.set(c.get() + 1)); | |
| 1134 | + hit!(SPLIT_TU_REACH_FIX_HITS); | |
| 1134 | 1135 | } |
| 1135 | 1136 | fixed |
| 1136 | 1137 | } |
| @@ -1252,7 +1253,7 @@ pub(crate) fn fwd_kf_hits() -> usize { | ||
| 1252 | 1253 | |
| 1253 | 1254 | /// Records one decoded forward keyframe (see [`FWD_KF_HITS`]). |
| 1254 | 1255 | pub(crate) fn note_fwd_kf() { |
| 1255 | - FWD_KF_HITS.with(|c| c.set(c.get() + 1)); | |
| 1256 | + hit!(FWD_KF_HITS); | |
| 1256 | 1257 | } |
| 1257 | 1258 | |
| 1258 | 1259 | // How many [`read_tx_size`] reads resolved a `tx_depth` strictly less than |
| @@ -1459,11 +1460,13 @@ pub(crate) fn ab16_hits_by_arm() -> [usize; 4] { | ||
| 1459 | 1460 | } |
| 1460 | 1461 | |
| 1461 | 1462 | fn bump_ab16(arm: usize) { |
| 1462 | - AB16_HITS.with(|c| { | |
| 1463 | - let mut v = c.get(); | |
| 1464 | - v[arm] += 1; | |
| 1465 | - c.set(v); | |
| 1466 | - }); | |
| 1463 | + hit_do! { | |
| 1464 | + AB16_HITS.with(|c| { | |
| 1465 | + let mut v = c.get(); | |
| 1466 | + v[arm] += 1; | |
| 1467 | + c.set(v); | |
| 1468 | + }); | |
| 1469 | + } | |
| 1467 | 1470 | } |
| 1468 | 1471 | |
| 1469 | 1472 | // How many `partition_w16` reads resolved to a plain `PARTITION_HORZ`/ |
| @@ -1511,11 +1514,13 @@ thread_local! { | ||
| 1511 | 1514 | |
| 1512 | 1515 | /// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`]. |
| 1513 | 1516 | pub(crate) fn bump_inter_edge_strip(idx: usize) { |
| 1514 | - INTER_EDGE_STRIP_HITS.with(|c| { | |
| 1515 | - let mut v = c.get(); | |
| 1516 | - v[idx] += 1; | |
| 1517 | - c.set(v); | |
| 1518 | - }); | |
| 1517 | + hit_do! { | |
| 1518 | + INTER_EDGE_STRIP_HITS.with(|c| { | |
| 1519 | + let mut v = c.get(); | |
| 1520 | + v[idx] += 1; | |
| 1521 | + c.set(v); | |
| 1522 | + }); | |
| 1523 | + } | |
| 1519 | 1524 | } |
| 1520 | 1525 | |
| 1521 | 1526 | // lane-edgeboth r1: how many partition nodes were coded as the BOTH-AXES-CUT |
| @@ -1529,11 +1534,13 @@ thread_local! { | ||
| 1529 | 1534 | } |
| 1530 | 1535 | |
| 1531 | 1536 | fn bump_edge_both_cut(level: usize) { |
| 1532 | - EDGE_BOTH_CUT_HITS.with(|c| { | |
| 1533 | - let mut v = c.get(); | |
| 1534 | - v[level] += 1; | |
| 1535 | - c.set(v); | |
| 1536 | - }); | |
| 1537 | + hit_do! { | |
| 1538 | + EDGE_BOTH_CUT_HITS.with(|c| { | |
| 1539 | + let mut v = c.get(); | |
| 1540 | + v[level] += 1; | |
| 1541 | + c.set(v); | |
| 1542 | + }); | |
| 1543 | + } | |
| 1537 | 1544 | } |
| 1538 | 1545 | |
| 1539 | 1546 | /// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`). |
| @@ -3477,7 +3484,7 @@ pub fn fimv_frame_hits() -> usize { | ||
| 3477 | 3484 | /// Bump [`FIMV_FRAME_HITS`] -- called once per decoded frame header whose |
| 3478 | 3485 | /// `force_integer_mv` bit is set. |
| 3479 | 3486 | pub fn note_force_integer_mv_frame() { |
| 3480 | - FIMV_FRAME_HITS.with(|c| c.set(c.get() + 1)); | |
| 3487 | + hit!(FIMV_FRAME_HITS); | |
| 3481 | 3488 | } |
| 3482 | 3489 | |
| 3483 | 3490 | /// Current value of [`OBMC_HITS`]. |
| @@ -4308,11 +4315,13 @@ pub(crate) fn reset_edge_part_hits() { | ||
| 4308 | 4315 | } |
| 4309 | 4316 | |
| 4310 | 4317 | fn bump_edge_part(slot: usize) { |
| 4311 | - EDGE_PART_HITS.with(|c| { | |
| 4312 | - let mut h = c.get(); | |
| 4313 | - h[slot] += 1; | |
| 4314 | - c.set(h); | |
| 4315 | - }); | |
| 4318 | + hit_do! { | |
| 4319 | + EDGE_PART_HITS.with(|c| { | |
| 4320 | + let mut h = c.get(); | |
| 4321 | + h[slot] += 1; | |
| 4322 | + c.set(h); | |
| 4323 | + }); | |
| 4324 | + } | |
| 4316 | 4325 | } |
| 4317 | 4326 | |
| 4318 | 4327 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| @@ -4352,11 +4361,13 @@ fn bump_edge32_bit(base: usize, bit: usize) -> usize { | ||
| 4352 | 4361 | } |
| 4353 | 4362 | |
| 4354 | 4363 | fn bump_edge32(slot: usize) { |
| 4355 | - EDGE32_HITS.with(|c| { | |
| 4356 | - let mut h = c.get(); | |
| 4357 | - h[slot] += 1; | |
| 4358 | - c.set(h) | |
| 4359 | - }); | |
| 4364 | + hit_do! { | |
| 4365 | + EDGE32_HITS.with(|c| { | |
| 4366 | + let mut h = c.get(); | |
| 4367 | + h[slot] += 1; | |
| 4368 | + c.set(h) | |
| 4369 | + }); | |
| 4370 | + } | |
| 4360 | 4371 | } |
| 4361 | 4372 | |
| 4362 | 4373 | // lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/ |
| @@ -4576,11 +4587,13 @@ pub(crate) struct InterStripChroma { | ||
| 4576 | 4587 | /// last -- read by the next 1:4 strip to build its pair's chroma. |
| 4577 | 4588 | |
| 4578 | 4589 | fn bump_ab16_inter(arm: usize) { |
| 4579 | - AB16_INTER_HITS.with(|c| { | |
| 4580 | - let mut v = c.get(); | |
| 4581 | - v[arm] += 1; | |
| 4582 | - c.set(v); | |
| 4583 | - }); | |
| 4590 | + hit_do! { | |
| 4591 | + AB16_INTER_HITS.with(|c| { | |
| 4592 | + let mut v = c.get(); | |
| 4593 | + v[arm] += 1; | |
| 4594 | + c.set(v); | |
| 4595 | + }); | |
| 4596 | + } | |
| 4584 | 4597 | } |
| 4585 | 4598 | |
| 4586 | 4599 | // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or |
| @@ -5105,7 +5118,7 @@ pub fn sub8_chroma_tx_from_ref_hits() -> usize { | ||
| 5105 | 5118 | |
| 5106 | 5119 | fn note_sub8_chroma_tx(first_sub: TxType, chroma_ref: TxType, coeffs: bool) { |
| 5107 | 5120 | if coeffs && first_sub != chroma_ref { |
| 5108 | - SUB8_CHROMA_TX_FROM_REF_HITS.with(|c| c.set(c.get() + 1)); | |
| 5121 | + hit!(SUB8_CHROMA_TX_FROM_REF_HITS); | |
| 5109 | 5122 | } |
| 5110 | 5123 | } |
| 5111 | 5124 | |
| @@ -5183,7 +5196,7 @@ pub(crate) fn chroma_eob_class1_hits() -> usize { | ||
| 5183 | 5196 | /// `tx_type` put this block's `eob_pt` on the class-1 row. |
| 5184 | 5197 | fn note_chroma_class1(plane_idx: usize, tx_type: TxType) { |
| 5185 | 5198 | if plane_idx > 0 && TxClass::of(tx_type) != TxClass::TwoD { |
| 5186 | - CHROMA_EOB_CLASS1_HITS.with(|c| c.set(c.get() + 1)); | |
| 5199 | + hit!(CHROMA_EOB_CLASS1_HITS); | |
| 5187 | 5200 | } |
| 5188 | 5201 | } |
| 5189 | 5202 | |
| @@ -5974,8 +5987,8 @@ fn read_coeffs( | ||
| 5974 | 5987 | |
| 5975 | 5988 | let class = TxClass::of(tx_type); |
| 5976 | 5989 | if class != TxClass::TwoD { |
| 5977 | - TX_CLASS1_HITS.with(|c| c.set(c.get() + 1)); | |
| 5978 | - RECT_CLASS1_HITS.with(|c| c.set(c.get() + 1)); | |
| 5990 | + hit!(TX_CLASS1_HITS); | |
| 5991 | + hit!(RECT_CLASS1_HITS); | |
| 5979 | 5992 | } |
| 5980 | 5993 | let eob = read_eob(dec, coding, class); |
| 5981 | 5994 | if trace { |
| @@ -6158,7 +6171,7 @@ fn read_coeffs_rect( | ||
| 6158 | 6171 | return Ok((Grid::Zero(w * h), TxType::DctDct)); |
| 6159 | 6172 | } |
| 6160 | 6173 | let mut grid = vec![0i32; w * h]; |
| 6161 | - RECT_COEFF_TU_HITS.with(|c| c.set(c.get() + 1)); | |
| 6174 | + hit!(RECT_COEFF_TU_HITS); | |
| 6162 | 6175 | // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is |
| 6163 | 6176 | // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including |
| 6164 | 6177 | // the `V_DCT`/`H_DCT` members whose 1D tx class needs its own scan and |
| @@ -6177,7 +6190,7 @@ fn read_coeffs_rect( | ||
| 6177 | 6190 | } |
| 6178 | 6191 | let class = TxClass::of(tx_type); |
| 6179 | 6192 | if class != TxClass::TwoD { |
| 6180 | - TX_CLASS1_HITS.with(|c| c.set(c.get() + 1)); | |
| 6193 | + hit!(TX_CLASS1_HITS); | |
| 6181 | 6194 | } |
| 6182 | 6195 | let eob = read_eob(dec, coding, class); |
| 6183 | 6196 | if rect_trace { |
| @@ -7074,7 +7087,7 @@ impl Neighbours { | ||
| 7074 | 7087 | fn fill_skip_grid_rect(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize, skip: bool) { |
| 7075 | 7088 | let (mi_r, mi_c) = at_mi; |
| 7076 | 7089 | if skip && w_mi != h_mi { |
| 7077 | - RECT_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | |
| 7090 | + hit!(RECT_SKIP_BAND_HITS); | |
| 7078 | 7091 | } |
| 7079 | 7092 | for rr in 0..h_mi { |
| 7080 | 7093 | let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c; |
| @@ -7623,7 +7636,7 @@ impl Neighbours { | ||
| 7623 | 7636 | if self.tile_row0_mi > 0 && !have_above && self.above_uv_mode[c] != DC_PRED |
| 7624 | 7637 | || self.tile_col0_mi > 0 && !have_left && self.left_uv_mode[r] != DC_PRED |
| 7625 | 7638 | { |
| 7626 | - UV_TILE_EDGE_SUPPRESSED_HITS.with(|h| h.set(h.get() + 1)); | |
| 7639 | + hit!(UV_TILE_EDGE_SUPPRESSED_HITS); | |
| 7627 | 7640 | } |
| 7628 | 7641 | // The mi grid is libaom's own read; the two maps below stay as the |
| 7629 | 7642 | // fallback for cells no block has written (see [`Self::uv_mode_grid`]). |
| @@ -7651,18 +7664,18 @@ impl Neighbours { | ||
| 7651 | 7664 | }) || have_left && cell(&self.uv_mode_grid, mi_r, mi_c - 1).is_some_and(|m| { |
| 7652 | 7665 | !matches!(self.uv_mode_row.get(mi_r), Some(&(col, cm)) if usize::from(col) == mi_c - 1 && usize::from(cm) == m) |
| 7653 | 7666 | }) { |
| 7654 | - UV_MODE_GRID_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); | |
| 7667 | + hit!(UV_MODE_GRID_OVERRIDE_HITS); | |
| 7655 | 7668 | } |
| 7656 | 7669 | // lane-cfl r1 counter: how often the mi-exact chroma neighbour differs |
| 7657 | 7670 | // from the coarse [`SUB`] slot -- i.e. how often a chroma edge would |
| 7658 | 7671 | // have been filtered at the wrong strength by the coarse map alone. |
| 7659 | 7672 | if above != self.above_uv_mode[c] || left != self.left_uv_mode[r] { |
| 7660 | - UV_MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); | |
| 7673 | + hit!(UV_MODE_MI_OVERRIDE_HITS); | |
| 7661 | 7674 | } |
| 7662 | 7675 | if (is_smooth_mode(self.above_uv_mode[c]) && !is_smooth_mode(above)) |
| 7663 | 7676 | || (is_smooth_mode(self.left_uv_mode[r]) && !is_smooth_mode(left)) |
| 7664 | 7677 | { |
| 7665 | - INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|h| h.set(h.get() + 1)); | |
| 7678 | + hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS); | |
| 7666 | 7679 | } |
| 7667 | 7680 | is_smooth_mode(above) || is_smooth_mode(left) |
| 7668 | 7681 | } |
| @@ -7717,19 +7730,19 @@ impl Neighbours { | ||
| 7717 | 7730 | let (above, left) = |
| 7718 | 7731 | self.modes_above_left_mi(mi_r, mi_c, (self.above_mode[c], self.left_mode[r])); |
| 7719 | 7732 | if above != self.above_mode[c] || left != self.left_mode[r] { |
| 7720 | - MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); | |
| 7733 | + hit!(MODE_MI_OVERRIDE_HITS); | |
| 7721 | 7734 | } |
| 7722 | 7735 | if (is_smooth_mode(self.above_mode[c]) && !is_smooth_mode(above)) |
| 7723 | 7736 | || (is_smooth_mode(self.left_mode[r]) && !is_smooth_mode(left)) |
| 7724 | 7737 | { |
| 7725 | - INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|h| h.set(h.get() + 1)); | |
| 7738 | + hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS); | |
| 7726 | 7739 | } |
| 7727 | 7740 | // A neighbour the coarse band offered where the tile edge makes it |
| 7728 | 7741 | // unavailable -- must never happen (see `MODE_TILE_EDGE_COARSE_LEAKS`). |
| 7729 | 7742 | if (mi_r <= self.tile_row0_mi && self.above_mode[c] != DC_PRED) |
| 7730 | 7743 | || (mi_c <= self.tile_col0_mi && self.left_mode[r] != DC_PRED) |
| 7731 | 7744 | { |
| 7732 | - MODE_TILE_EDGE_COARSE_LEAKS.with(|h| h.set(h.get() + 1)); | |
| 7745 | + hit!(MODE_TILE_EDGE_COARSE_LEAKS); | |
| 7733 | 7746 | } |
| 7734 | 7747 | (above, left) |
| 7735 | 7748 | } |
| @@ -8508,7 +8521,7 @@ fn read_intra_mode_rect( | ||
| 8508 | 8521 | // offer the 14-symbol CFL alphabet on a 64-axis block (class |
| 8509 | 8522 | // wrong-alphabet-same-value: same value, wrong interval, silent desync). |
| 8510 | 8523 | let cfl = if cfl && bw.max(bh) > 32 { |
| 8511 | - NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1)); | |
| 8524 | + hit!(NOCFL_UV_MODE_HITS); | |
| 8512 | 8525 | false |
| 8513 | 8526 | } else { |
| 8514 | 8527 | cfl |
| @@ -8550,10 +8563,10 @@ fn read_intra_mode_rect( | ||
| 8550 | 8563 | // refused by name when it fires. |
| 8551 | 8564 | if allow_intrabc_frame(fctx) { |
| 8552 | 8565 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; |
| 8553 | - RECT_INTRABC_READS.with(|c| c.set(c.get() + 1)); | |
| 8566 | + hit!(RECT_INTRABC_READS); | |
| 8554 | 8567 | istep!("intrabc", use_intrabc as i32); |
| 8555 | 8568 | if use_intrabc { |
| 8556 | - INTRABC_HITS.with(|c| c.set(c.get() + 1)); | |
| 8569 | + hit!(INTRABC_HITS); | |
| 8557 | 8570 | return Err(unsupported( |
| 8558 | 8571 | "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", |
| 8559 | 8572 | )); |
| @@ -8600,17 +8613,17 @@ fn read_intra_mode_rect( | ||
| 8600 | 8613 | None |
| 8601 | 8614 | }; |
| 8602 | 8615 | if has_chroma && (9..=12).contains(&uv_mode) { |
| 8603 | - SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 8616 | + hit!(SMOOTH_UV_HITS); | |
| 8604 | 8617 | } |
| 8605 | 8618 | let angle_delta_uv = if has_chroma && (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 8606 | - DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 8619 | + hit!(DIRECTIONAL_UV_HITS); | |
| 8607 | 8620 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 8608 | 8621 | } else { |
| 8609 | 8622 | 0 |
| 8610 | 8623 | }; |
| 8611 | 8624 | istep!("angle_uv", angle_delta_uv); |
| 8612 | 8625 | if angle_delta_uv != 0 { |
| 8613 | - UV_ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1)); | |
| 8626 | + hit!(UV_ANGLE_DELTA_HITS); | |
| 8614 | 8627 | } |
| 8615 | 8628 | // `read_palette_mode_info` (spec 5.11.13), rect-generalised |
| 8616 | 8629 | // (lane-palette2 r4): same bsize-ctx-gated read as [`read_intra_mode`], |
| @@ -8627,7 +8640,7 @@ fn read_intra_mode_rect( | ||
| 8627 | 8640 | // r6: this is the exact site the removed blanket refusal used to |
| 8628 | 8641 | // guard -- reached for EVERY rect strip in a screen-content frame, |
| 8629 | 8642 | // independent of whether the block ends up using a palette. |
| 8630 | - RECT_SCREEN_CONTENT_HITS.with(|c| c.set(c.get() + 1)); | |
| 8643 | + hit!(RECT_SCREEN_CONTENT_HITS); | |
| 8631 | 8644 | let (mode_ctx, cache) = palette.unwrap_or((0, &[])); |
| 8632 | 8645 | let use_palette_y = |
| 8633 | 8646 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][mode_ctx]) != 0; |
| @@ -8670,7 +8683,7 @@ fn read_intra_mode_rect( | ||
| 8670 | 8683 | } |
| 8671 | 8684 | istep!("use_filter_intra", use_filter_intra as i32); |
| 8672 | 8685 | if use_filter_intra { |
| 8673 | - FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | |
| 8686 | + hit!(FILTER_INTRA_HITS); | |
| 8674 | 8687 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 8675 | 8688 | istep!("filter_intra_mode", fi_mode as i32); |
| 8676 | 8689 | filter_intra = Some(fi_mode); |
| @@ -8680,8 +8693,8 @@ fn read_intra_mode_rect( | ||
| 8680 | 8693 | // same order as [`read_intra_mode`]'s own square path. |
| 8681 | 8694 | let palette_y = palette_y_pending.map(|(n, colors)| { |
| 8682 | 8695 | let map = decode_color_index_map_wh(dec, cdfs, n, bw, bh, false); |
| 8683 | - PALETTE_HITS.with(|c| c.set(c.get() + 1)); | |
| 8684 | - PALETTE_RECT_HITS.with(|c| c.set(c.get() + 1)); | |
| 8696 | + hit!(PALETTE_HITS); | |
| 8697 | + hit!(PALETTE_RECT_HITS); | |
| 8685 | 8698 | PaletteY { size: n, colors, map } |
| 8686 | 8699 | }); |
| 8687 | 8700 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { |
| @@ -8692,7 +8705,7 @@ fn read_intra_mode_rect( | ||
| 8692 | 8705 | // chroma palette and desynced the tile from there. |
| 8693 | 8706 | let (cw, ch) = ((bw / 2).max(4), (bh / 2).max(4)); |
| 8694 | 8707 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, true); |
| 8695 | - PALETTE_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 8708 | + hit!(PALETTE_UV_HITS); | |
| 8696 | 8709 | PaletteUv { size: n, u_colors, v_colors, map } |
| 8697 | 8710 | }); |
| 8698 | 8711 | Ok(( |
| @@ -8945,11 +8958,13 @@ fn decode_rect_split( | ||
| 8945 | 8958 | (4, 8) => Some(3), |
| 8946 | 8959 | _ => None, |
| 8947 | 8960 | } { |
| 8948 | - RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| { | |
| 8949 | - let mut hits = c.get(); | |
| 8950 | - hits[i] += 1; | |
| 8951 | - c.set(hits); | |
| 8952 | - }); | |
| 8961 | + hit_do! { | |
| 8962 | + RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| { | |
| 8963 | + let mut hits = c.get(); | |
| 8964 | + hits[i] += 1; | |
| 8965 | + c.set(hits); | |
| 8966 | + }); | |
| 8967 | + } | |
| 8953 | 8968 | } |
| 8954 | 8969 | if chroma.is_none() { |
| 8955 | 8970 | // Diagnostic for the next caller that lands here (class |
| @@ -8970,9 +8985,9 @@ fn decode_rect_split( | ||
| 8970 | 8985 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 8971 | 8986 | )); |
| 8972 | 8987 | } |
| 8973 | - RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 8988 | + hit!(RECT_SPLIT_TX_HITS); | |
| 8974 | 8989 | if bw.max(bh) == 64 && bw / tx_w > 1 && bh / tx_h > 1 { |
| 8975 | - RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.set(c.get() + 1)); | |
| 8990 | + hit!(RECT_SPLIT_SB_INTERIOR_TU_HITS); | |
| 8976 | 8991 | } |
| 8977 | 8992 | // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. |
| 8978 | 8993 | // A square unit reads through the ordinary square [`read_plane`]; a rect |
| @@ -9099,11 +9114,13 @@ fn decode_rect_split( | ||
| 9099 | 9114 | if crate::envflags::env_flag!("EC_RECT64TU") { |
| 9100 | 9115 | eprintln!("EC_RECT64TU mi={tu_mi:?} tx={tx_w}x{tx_h} mode={}", m.mode); |
| 9101 | 9116 | } |
| 9102 | - RECT64_CORNER_TU_HITS.with(|c| { | |
| 9103 | - let mut v = c.get(); | |
| 9104 | - v[usize::from(tx_h > tx_w)] += 1; | |
| 9105 | - c.set(v); | |
| 9106 | - }); | |
| 9117 | + hit_do! { | |
| 9118 | + RECT64_CORNER_TU_HITS.with(|c| { | |
| 9119 | + let mut v = c.get(); | |
| 9120 | + v[usize::from(tx_h > tx_w)] += 1; | |
| 9121 | + c.set(v); | |
| 9122 | + }); | |
| 9123 | + } | |
| 9107 | 9124 | let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; |
| 9108 | 9125 | let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra)); |
| 9109 | 9126 | let (corner, tu_tx_type) = read_coeffs( |
| @@ -9283,7 +9300,7 @@ fn decode_rect_split( | ||
| 9283 | 9300 | // superblock strips onto this path, so only counting there would |
| 9284 | 9301 | // leave the delta_q gate's counter silent for them). |
| 9285 | 9302 | if bw.max(bh) == 64 && fctx.current_q_idx.with(|c| c.get()) != i32::from(base_q_idx) { |
| 9286 | - RECT64_QIDX_DRIFT_HITS.with(|c| c.set(c.get() + 1)); | |
| 9303 | + hit!(RECT64_QIDX_DRIFT_HITS); | |
| 9287 | 9304 | } |
| 9288 | 9305 | let residual = dequant_and_inverse_typed_wh( |
| 9289 | 9306 | &levels, |
| @@ -9631,12 +9648,14 @@ fn decode_intra_rect_in_inter( | ||
| 9631 | 9648 | mi_r * MI |
| 9632 | 9649 | ); |
| 9633 | 9650 | } |
| 9634 | - INTRA16X4_IN_INTER_HITS.with(|h| { | |
| 9635 | - let mut v = h.get(); | |
| 9636 | - v[usize::from(!horz)] += 1; | |
| 9637 | - v[2] += usize::from(has_chroma); | |
| 9638 | - h.set(v); | |
| 9639 | - }); | |
| 9651 | + hit_do! { | |
| 9652 | + INTRA16X4_IN_INTER_HITS.with(|h| { | |
| 9653 | + let mut v = h.get(); | |
| 9654 | + v[usize::from(!horz)] += 1; | |
| 9655 | + v[2] += usize::from(has_chroma); | |
| 9656 | + h.set(v); | |
| 9657 | + }); | |
| 9658 | + } | |
| 9640 | 9659 | return Ok(()); |
| 9641 | 9660 | } |
| 9642 | 9661 | // lane-inter128intra r1: the 128 superblock's PARTITION_HORZ/VERT half |
| @@ -9783,11 +9802,13 @@ fn decode_intra_rect_in_inter( | ||
| 9783 | 9802 | (32, 8) => 2, |
| 9784 | 9803 | _ => 3, |
| 9785 | 9804 | }; |
| 9786 | - INTRA_RECT4_IN_INTER_HITS.with(|h| { | |
| 9787 | - let mut v = h.get(); | |
| 9788 | - v[shape] += 1; | |
| 9789 | - h.set(v); | |
| 9790 | - }); | |
| 9805 | + hit_do! { | |
| 9806 | + INTRA_RECT4_IN_INTER_HITS.with(|h| { | |
| 9807 | + let mut v = h.get(); | |
| 9808 | + v[shape] += 1; | |
| 9809 | + h.set(v); | |
| 9810 | + }); | |
| 9811 | + } | |
| 9791 | 9812 | return Ok(()); |
| 9792 | 9813 | } |
| 9793 | 9814 | let mode = dec.symbol(&mut cdfs.y_mode[size_group]); |
| @@ -9815,7 +9836,7 @@ fn decode_intra_rect_in_inter( | ||
| 9815 | 9836 | 0 |
| 9816 | 9837 | }; |
| 9817 | 9838 | if angle_delta_y != 0 { |
| 9818 | - INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.set(c.get() + 1)); | |
| 9839 | + hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS); | |
| 9819 | 9840 | } |
| 9820 | 9841 | // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the |
| 9821 | 9842 | // superblock-level strip reads the no-CFL alphabet -- the same split |
| @@ -9834,7 +9855,7 @@ fn decode_intra_rect_in_inter( | ||
| 9834 | 9855 | ); |
| 9835 | 9856 | } |
| 9836 | 9857 | if (9..=12).contains(&uv_mode) { |
| 9837 | - SMOOTH_UV_HITS.with(|h| h.set(h.get() + 1)); | |
| 9858 | + hit!(SMOOTH_UV_HITS); | |
| 9838 | 9859 | } |
| 9839 | 9860 | let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { |
| 9840 | 9861 | Some(read_cfl_alphas(dec, cdfs)) |
| @@ -9847,14 +9868,14 @@ fn decode_intra_rect_in_inter( | ||
| 9847 | 9868 | uv_mode |
| 9848 | 9869 | }; |
| 9849 | 9870 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 9850 | - DIRECTIONAL_UV_HITS.with(|h| h.set(h.get() + 1)); | |
| 9871 | + hit!(DIRECTIONAL_UV_HITS); | |
| 9851 | 9872 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 9852 | 9873 | } else { |
| 9853 | 9874 | 0 |
| 9854 | 9875 | }; |
| 9855 | 9876 | if angle_delta_uv != 0 { |
| 9856 | - UV_ANGLE_DELTA_HITS.with(|h| h.set(h.get() + 1)); | |
| 9857 | - INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|h| h.set(h.get() + 1)); | |
| 9877 | + hit!(UV_ANGLE_DELTA_HITS); | |
| 9878 | + hit!(INTRA_IN_INTER_ANGLE_DELTA_UV_HITS); | |
| 9858 | 9879 | } |
| 9859 | 9880 | // `read_palette_mode_info` (spec 5.11.13), in the position |
| 9860 | 9881 | // `read_intra_block_mode_info` writes it: after the chroma mode and |
| @@ -9873,7 +9894,7 @@ fn decode_intra_rect_in_inter( | ||
| 9873 | 9894 | if allow_screen_content_tools |
| 9874 | 9895 | && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh) |
| 9875 | 9896 | { |
| 9876 | - INTRA_RECT_IN_INTER_SCREEN_HITS.with(|c| c.set(c.get() + 1)); | |
| 9897 | + hit!(INTRA_RECT_IN_INTER_SCREEN_HITS); | |
| 9877 | 9898 | let use_palette_y = |
| 9878 | 9899 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0; |
| 9879 | 9900 | if use_palette_y { |
| @@ -9907,23 +9928,23 @@ fn decode_intra_rect_in_inter( | ||
| 9907 | 9928 | && let Some(class) = filter_intra_size_class_rect(bw, bh) |
| 9908 | 9929 | && dec.symbol(&mut cdfs.filter_intra[class]) != 0 |
| 9909 | 9930 | { |
| 9910 | - FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1)); | |
| 9911 | - INTRA_IN_INTER_FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1)); | |
| 9931 | + hit!(FILTER_INTRA_HITS); | |
| 9932 | + hit!(INTRA_IN_INTER_FILTER_INTRA_HITS); | |
| 9912 | 9933 | filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); |
| 9913 | 9934 | } |
| 9914 | 9935 | // `av1_visit_palette`: Y's colour-index map then the shared chroma one. |
| 9915 | 9936 | let palette_y = palette_y_pending.map(|(n, colors)| { |
| 9916 | 9937 | let map = decode_color_index_map_wh(dec, cdfs, n, bw, bh, false); |
| 9917 | - PALETTE_HITS.with(|c| c.set(c.get() + 1)); | |
| 9918 | - PALETTE_RECT_HITS.with(|c| c.set(c.get() + 1)); | |
| 9919 | - INTRA_IN_INTER_PALETTE_Y_HITS.with(|c| c.set(c.get() + 1)); | |
| 9938 | + hit!(PALETTE_HITS); | |
| 9939 | + hit!(PALETTE_RECT_HITS); | |
| 9940 | + hit!(INTRA_IN_INTER_PALETTE_Y_HITS); | |
| 9920 | 9941 | PaletteY { size: n, colors, map } |
| 9921 | 9942 | }); |
| 9922 | 9943 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { |
| 9923 | 9944 | let (cw, ch) = ((bw / 2).max(4), (bh / 2).max(4)); |
| 9924 | 9945 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, true); |
| 9925 | - PALETTE_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 9926 | - INTRA_IN_INTER_PALETTE_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 9946 | + hit!(PALETTE_UV_HITS); | |
| 9947 | + hit!(INTRA_IN_INTER_PALETTE_UV_HITS); | |
| 9927 | 9948 | PaletteUv { size: n, u_colors, v_colors, map } |
| 9928 | 9949 | }); |
| 9929 | 9950 | // The intra-edge filter type is the NEIGHBOUR's mode (libaom |
| @@ -9938,11 +9959,11 @@ fn decode_intra_rect_in_inter( | ||
| 9938 | 9959 | let coarse_pair = neighbours.modes_above_left(r, c); |
| 9939 | 9960 | let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left_mi(mi_r, mi_c, coarse_pair); |
| 9940 | 9961 | if (nb_above_mode, nb_left_mode) != coarse_pair { |
| 9941 | - EDGE_FILTER_MI_FIX_HITS.with(|c| c.set(c.get() + 1)); | |
| 9962 | + hit!(EDGE_FILTER_MI_FIX_HITS); | |
| 9942 | 9963 | } |
| 9943 | 9964 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 9944 | 9965 | if smooth_neighbor { |
| 9945 | - SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1)); | |
| 9966 | + hit!(SMOOTH_LUMA_HITS); | |
| 9946 | 9967 | } |
| 9947 | 9968 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); |
| 9948 | 9969 | let depth = if fctx.tx_select_inter.with(std::cell::Cell::get) { |
| @@ -9965,15 +9986,17 @@ fn decode_intra_rect_in_inter( | ||
| 9965 | 9986 | 0 |
| 9966 | 9987 | }; |
| 9967 | 9988 | if depth != 0 { |
| 9968 | - TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); | |
| 9989 | + hit!(TX_DEPTH_HITS); | |
| 9969 | 9990 | // lane-intrasplit r1: a split intra strip in an inter frame walks the |
| 9970 | 9991 | // key frame's own per-TU path ([`decode_rect_split`] below); what was |
| 9971 | 9992 | // wrong when this refusal was written was the depth SYMBOL, not the walk. |
| 9972 | - INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(|h| { | |
| 9973 | - let mut v = h.get(); | |
| 9974 | - v[depth.min(2)] += 1; | |
| 9975 | - h.set(v); | |
| 9976 | - }); | |
| 9993 | + hit_do! { | |
| 9994 | + INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(|h| { | |
| 9995 | + let mut v = h.get(); | |
| 9996 | + v[depth.min(2)] += 1; | |
| 9997 | + h.set(v); | |
| 9998 | + }); | |
| 9999 | + } | |
| 9977 | 10000 | } |
| 9978 | 10001 | // lane-intrasplit r3: print EVERY intra strip with its depth, not only the |
| 9979 | 10002 | // split ones -- a `depth=0`-only stream is a witness gap in the SOURCE, and |
| @@ -10061,11 +10084,13 @@ fn decode_intra_rect_in_inter( | ||
| 10061 | 10084 | 32 => 1, |
| 10062 | 10085 | _ => 2, |
| 10063 | 10086 | }; |
| 10064 | - INTRA_RECT_IN_INTER_HITS.with(|h| { | |
| 10065 | - let mut v = h.get(); | |
| 10066 | - v[class] += 1; | |
| 10067 | - h.set(v); | |
| 10068 | - }); | |
| 10087 | + hit_do! { | |
| 10088 | + INTRA_RECT_IN_INTER_HITS.with(|h| { | |
| 10089 | + let mut v = h.get(); | |
| 10090 | + v[class] += 1; | |
| 10091 | + h.set(v); | |
| 10092 | + }); | |
| 10093 | + } | |
| 10069 | 10094 | Ok(()) |
| 10070 | 10095 | } |
| 10071 | 10096 | |
| @@ -10121,7 +10146,7 @@ fn decode_block_rect( | ||
| 10121 | 10146 | )?; |
| 10122 | 10147 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 10123 | 10148 | if smooth_neighbor { |
| 10124 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | |
| 10149 | + hit!(SMOOTH_LUMA_HITS); | |
| 10125 | 10150 | } |
| 10126 | 10151 | // lane-chroma r3: chroma's own edge-filter-strength neighbour check |
| 10127 | 10152 | // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's |
| @@ -10134,7 +10159,7 @@ fn decode_block_rect( | ||
| 10134 | 10159 | // predicts instead of refusing. The below-16x16 leaf arm |
| 10135 | 10160 | // (`decode_leaf_rect`) keeps the refusal: it has no gate of its own. |
| 10136 | 10161 | if filter_intra.is_some() { |
| 10137 | - FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | |
| 10162 | + hit!(FILTER_INTRA_RECT_HITS); | |
| 10138 | 10163 | } |
| 10139 | 10164 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 10140 | 10165 | DC_PRED |
| @@ -10174,7 +10199,7 @@ fn decode_block_rect( | ||
| 10174 | 10199 | 0 |
| 10175 | 10200 | }; |
| 10176 | 10201 | if depth != 0 { |
| 10177 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | |
| 10202 | + hit!(TX_DEPTH_HITS); | |
| 10178 | 10203 | // lane-rectsplit r1: a split transform is predicted and reconstructed |
| 10179 | 10204 | // per transform unit, each unit taking its edges from the previous |
| 10180 | 10205 | // unit's reconstruction inside this same strip (spec 5.11.36) -- |
| @@ -10208,7 +10233,7 @@ fn decode_block_rect( | ||
| 10208 | 10233 | }), |
| 10209 | 10234 | }; |
| 10210 | 10235 | if palette_y.is_some() || palette_uv.is_some() { |
| 10211 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 10236 | + hit!(PALETTE_SPLIT_TX_HITS); | |
| 10212 | 10237 | } |
| 10213 | 10238 | decode_rect_split( |
| 10214 | 10239 | dec, |
| @@ -10238,7 +10263,7 @@ fn decode_block_rect( | ||
| 10238 | 10263 | let (puv_size, puv_colors) = |
| 10239 | 10264 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 10240 | 10265 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); |
| 10241 | - RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | |
| 10266 | + hit!(RECT_PARTITION_HITS); | |
| 10242 | 10267 | return Ok(()); |
| 10243 | 10268 | } |
| 10244 | 10269 | let (tx_w, tx_h) = (bw, bh); |
| @@ -10498,7 +10523,7 @@ fn decode_block_rect( | ||
| 10498 | 10523 | smooth_neighbor_uv, fctx, |
| 10499 | 10524 | ); |
| 10500 | 10525 | neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[&luma_levels[..], &u_levels[..], &v_levels[..]]); |
| 10501 | - RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); | |
| 10526 | + hit!(RECT_COEFF_HITS); | |
| 10502 | 10527 | } |
| 10503 | 10528 | } |
| 10504 | 10529 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| @@ -10508,7 +10533,7 @@ fn decode_block_rect( | ||
| 10508 | 10533 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); |
| 10509 | 10534 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); |
| 10510 | 10535 | neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0, fctx); |
| 10511 | - RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | |
| 10536 | + hit!(RECT_PARTITION_HITS); | |
| 10512 | 10537 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| 10513 | 10538 | eprintln!("TRACE_RECT32_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh}"); |
| 10514 | 10539 | } |
| @@ -10583,7 +10608,7 @@ fn decode_leaf_rect( | ||
| 10583 | 10608 | let smooth_neighbor = |
| 10584 | 10609 | is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 10585 | 10610 | if smooth_neighbor { |
| 10586 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | |
| 10611 | + hit!(SMOOTH_LUMA_HITS); | |
| 10587 | 10612 | } |
| 10588 | 10613 | // The palette-Y mode CDF row is picked by the neighbours' palette use |
| 10589 | 10614 | // (`palette_ctx_and_cache`), so this sub-16x16 leaf must pass its own real |
| @@ -10620,7 +10645,7 @@ fn decode_leaf_rect( | ||
| 10620 | 10645 | // map -> base colours buffer [`decode_block_rect`] hands each |
| 10621 | 10646 | // `reconstruct_rect` through [`set_palette_pred`]. |
| 10622 | 10647 | if palette_y.is_some() || palette_uv.is_some() { |
| 10623 | - RECT4_PALETTE_HITS.with(|c| c.set(c.get() + 1)); | |
| 10648 | + hit!(RECT4_PALETTE_HITS); | |
| 10624 | 10649 | } |
| 10625 | 10650 | let palette_y_buf: Option<Vec<u16>> = palette_y |
| 10626 | 10651 | .as_ref() |
| @@ -10643,8 +10668,8 @@ fn decode_leaf_rect( | ||
| 10643 | 10668 | // patches over a true `bw`x`bh` block (lane-rectsplit r1), so an |
| 10644 | 10669 | // 8x16/16x8 strip predicts through the same call `reconstruct_rect` |
| 10645 | 10670 | // below already makes; this refusal was square-only prose. |
| 10646 | - FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | |
| 10647 | - FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.set(c.get() + 1)); | |
| 10671 | + hit!(FILTER_INTRA_RECT_HITS); | |
| 10672 | + hit!(FILTER_INTRA_RECT_SUB16_HITS); | |
| 10648 | 10673 | } |
| 10649 | 10674 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; |
| 10650 | 10675 | // lane-cfl r1, same defect as [`decode_leaf_8x8`]: chroma's intra-edge |
| @@ -10683,8 +10708,8 @@ fn decode_leaf_rect( | ||
| 10683 | 10708 | // The same per-transform-unit walk the bigger strips take |
| 10684 | 10709 | // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at |
| 10685 | 10710 | // depth 2), addressed at this leaf's own mi position. |
| 10686 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | |
| 10687 | - SUB16_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | |
| 10711 | + hit!(TX_DEPTH_HITS); | |
| 10712 | + hit!(SUB16_SPLIT_HITS); | |
| 10688 | 10713 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); |
| 10689 | 10714 | let modes = RectStripModes { |
| 10690 | 10715 | skip, |
| @@ -10703,7 +10728,7 @@ fn decode_leaf_rect( | ||
| 10703 | 10728 | palette_uv: palette_uv_bufs.clone(), |
| 10704 | 10729 | }; |
| 10705 | 10730 | if palette_y.is_some() || palette_uv.is_some() { |
| 10706 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 10731 | + hit!(PALETTE_SPLIT_TX_HITS); | |
| 10707 | 10732 | } |
| 10708 | 10733 | decode_rect_split( |
| 10709 | 10734 | dec, |
| @@ -10834,7 +10859,7 @@ fn decode_leaf_rect( | ||
| 10834 | 10859 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual, |
| 10835 | 10860 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx, |
| 10836 | 10861 | ); |
| 10837 | - RECT_LEAF_COEFF_HITS.with(|c| c.set(c.get() + 1)); | |
| 10862 | + hit!(RECT_LEAF_COEFF_HITS); | |
| 10838 | 10863 | } |
| 10839 | 10864 | neighbours.record_mi_rect(leaf_mi, bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]); |
| 10840 | 10865 | neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip); |
| @@ -10950,7 +10975,7 @@ fn decode_block_rect4( | ||
| 10950 | 10975 | // mapped through the base colours IS the prediction (it reads no edge |
| 10951 | 10976 | // pixels), handed to each `reconstruct_rect` through [`set_palette_pred`]. |
| 10952 | 10977 | if palette_y.is_some() || palette_uv.is_some() { |
| 10953 | - RECT4_PALETTE_HITS.with(|c| c.set(c.get() + 1)); | |
| 10978 | + hit!(RECT4_PALETTE_HITS); | |
| 10954 | 10979 | } |
| 10955 | 10980 | let palette_y_buf: Option<Vec<u16>> = palette_y |
| 10956 | 10981 | .as_ref() |
| @@ -10967,7 +10992,7 @@ fn decode_block_rect4( | ||
| 10967 | 10992 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 10968 | 10993 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 10969 | 10994 | if smooth_neighbor { |
| 10970 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | |
| 10995 | + hit!(SMOOTH_LUMA_HITS); | |
| 10971 | 10996 | } |
| 10972 | 10997 | // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's |
| 10973 | 10998 | // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so |
| @@ -10977,11 +11002,11 @@ fn decode_block_rect4( | ||
| 10977 | 11002 | // with luma bit-exact). |
| 10978 | 11003 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); |
| 10979 | 11004 | if filter_intra.is_some() { |
| 10980 | - FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | |
| 11005 | + hit!(FILTER_INTRA_RECT_HITS); | |
| 10981 | 11006 | if bw > bh { |
| 10982 | - FILTER_INTRA_RECT4_HORZ_HITS.with(|c| c.set(c.get() + 1)); | |
| 11007 | + hit!(FILTER_INTRA_RECT4_HORZ_HITS); | |
| 10983 | 11008 | } else { |
| 10984 | - FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.set(c.get() + 1)); | |
| 11009 | + hit!(FILTER_INTRA_RECT4_VERT_HITS); | |
| 10985 | 11010 | } |
| 10986 | 11011 | } |
| 10987 | 11012 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| @@ -11027,7 +11052,7 @@ fn decode_block_rect4( | ||
| 11027 | 11052 | // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16 |
| 11028 | 11053 | // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8; |
| 11029 | 11054 | // both interleave in every real stream. |
| 11030 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | |
| 11055 | + hit!(TX_DEPTH_HITS); | |
| 11031 | 11056 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); |
| 11032 | 11057 | // lane-rectsplitx r2: both depths ship together, as the r1 handoff |
| 11033 | 11058 | // predicted -- depth 1 fires FIRST in every attempt that splits at |
| @@ -11039,7 +11064,7 @@ fn decode_block_rect4( | ||
| 11039 | 11064 | } else { |
| 11040 | 11065 | &RECT4_SPLIT_DEPTH2_HITS |
| 11041 | 11066 | }; |
| 11042 | - which.with(|c| c.set(c.get() + 1)); | |
| 11067 | + hit_do! { which.with(|c| c.set(c.get() + 1)); } | |
| 11043 | 11068 | let modes = RectStripModes { |
| 11044 | 11069 | skip, |
| 11045 | 11070 | mode, |
| @@ -11054,7 +11079,7 @@ fn decode_block_rect4( | ||
| 11054 | 11079 | palette_uv: palette_uv_bufs.clone(), |
| 11055 | 11080 | }; |
| 11056 | 11081 | if palette_y.is_some() || palette_uv.is_some() { |
| 11057 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 11082 | + hit!(PALETTE_SPLIT_TX_HITS); | |
| 11058 | 11083 | } |
| 11059 | 11084 | decode_rect_split( |
| 11060 | 11085 | dec, |
| @@ -11077,12 +11102,12 @@ fn decode_block_rect4( | ||
| 11077 | 11102 | pal_uv_colors, |
| 11078 | 11103 | ); |
| 11079 | 11104 | if bw > bh { |
| 11080 | - RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | |
| 11105 | + hit!(RECT4_32_HORZ_HITS); | |
| 11081 | 11106 | } else { |
| 11082 | - RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); | |
| 11107 | + hit!(RECT4_32_VERT_HITS); | |
| 11083 | 11108 | } |
| 11084 | 11109 | if !skip { |
| 11085 | - RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1)); | |
| 11110 | + hit!(RECT4_COEFF_HITS); | |
| 11086 | 11111 | } |
| 11087 | 11112 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 11088 | 11113 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| @@ -11163,7 +11188,7 @@ fn decode_block_rect4( | ||
| 11163 | 11188 | } |
| 11164 | 11189 | let (v_levels, v_tx_type) = planes.pop().expect("plane 2"); |
| 11165 | 11190 | let (u_levels, u_tx_type) = planes.pop().expect("plane 1"); |
| 11166 | - RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1)); | |
| 11191 | + hit!(RECT4_COEFF_HITS); | |
| 11167 | 11192 | let luma_residual = dequant_and_inverse_typed_wh( |
| 11168 | 11193 | &luma_levels, |
| 11169 | 11194 | bw, |
| @@ -11237,9 +11262,9 @@ fn decode_block_rect4( | ||
| 11237 | 11262 | pal_uv_colors, |
| 11238 | 11263 | ); |
| 11239 | 11264 | if bw > bh { |
| 11240 | - RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | |
| 11265 | + hit!(RECT4_32_HORZ_HITS); | |
| 11241 | 11266 | } else { |
| 11242 | - RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); | |
| 11267 | + hit!(RECT4_32_VERT_HITS); | |
| 11243 | 11268 | } |
| 11244 | 11269 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 11245 | 11270 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| @@ -11306,9 +11331,9 @@ fn decode_block_rect4( | ||
| 11306 | 11331 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, |
| 11307 | 11332 | ); |
| 11308 | 11333 | if bw > bh { |
| 11309 | - RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | |
| 11334 | + hit!(RECT4_32_HORZ_HITS); | |
| 11310 | 11335 | } else { |
| 11311 | - RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); | |
| 11336 | + hit!(RECT4_32_VERT_HITS); | |
| 11312 | 11337 | } |
| 11313 | 11338 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 11314 | 11339 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| @@ -11490,7 +11515,7 @@ fn decode_rect4_16_strip( | ||
| 11490 | 11515 | lmi.1, fctx, |
| 11491 | 11516 | )?; |
| 11492 | 11517 | if palette_y.is_some() || palette_uv.is_some() { |
| 11493 | - RECT4_PALETTE_HITS.with(|h| h.set(h.get() + 1)); | |
| 11518 | + hit!(RECT4_PALETTE_HITS); | |
| 11494 | 11519 | } |
| 11495 | 11520 | // The colour-index map through the base colours IS the prediction. |
| 11496 | 11521 | // Chroma's map is the PAIR's 8x4 (4x8) block, matching the one |
| @@ -11506,10 +11531,10 @@ fn decode_rect4_16_strip( | ||
| 11506 | 11531 | }); |
| 11507 | 11532 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 11508 | 11533 | if smooth_neighbor { |
| 11509 | - SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1)); | |
| 11534 | + hit!(SMOOTH_LUMA_HITS); | |
| 11510 | 11535 | } |
| 11511 | 11536 | if filter_intra.is_some() { |
| 11512 | - FILTER_INTRA_RECT_HITS.with(|h| h.set(h.get() + 1)); | |
| 11537 | + hit!(FILTER_INTRA_RECT_HITS); | |
| 11513 | 11538 | } |
| 11514 | 11539 | // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is |
| 11515 | 11540 | // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the |
| @@ -11540,8 +11565,8 @@ fn decode_rect4_16_strip( | ||
| 11540 | 11565 | 0 |
| 11541 | 11566 | }; |
| 11542 | 11567 | if depth != 0 { |
| 11543 | - TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); | |
| 11544 | - RECT4_16_SPLIT_HITS.with(|h| h.set(h.get() + 1)); | |
| 11568 | + hit!(TX_DEPTH_HITS); | |
| 11569 | + hit!(RECT4_16_SPLIT_HITS); | |
| 11545 | 11570 | } |
| 11546 | 11571 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); |
| 11547 | 11572 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| @@ -11623,7 +11648,7 @@ fn decode_rect4_16_strip( | ||
| 11623 | 11648 | None, filter_intra, smooth_neighbor, fctx, |
| 11624 | 11649 | ); |
| 11625 | 11650 | if tu_grid.iter().any(|&l| l != 0) { |
| 11626 | - RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | |
| 11651 | + hit!(RECT4_16_COEFF_HITS); | |
| 11627 | 11652 | } |
| 11628 | 11653 | neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); |
| 11629 | 11654 | } else { |
| @@ -11652,7 +11677,7 @@ fn decode_rect4_16_strip( | ||
| 11652 | 11677 | smooth_neighbor, fctx, |
| 11653 | 11678 | )?; |
| 11654 | 11679 | if tu_grid.iter().any(|&l| l != 0) { |
| 11655 | - RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | |
| 11680 | + hit!(RECT4_16_COEFF_HITS); | |
| 11656 | 11681 | } |
| 11657 | 11682 | neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid); |
| 11658 | 11683 | } |
| @@ -11707,7 +11732,7 @@ fn decode_rect4_16_strip( | ||
| 11707 | 11732 | px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra, |
| 11708 | 11733 | smooth_neighbor, fctx, |
| 11709 | 11734 | ); |
| 11710 | - RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | |
| 11735 | + hit!(RECT4_16_COEFF_HITS); | |
| 11711 | 11736 | levels |
| 11712 | 11737 | }; |
| 11713 | 11738 | neighbours.record_mi_luma_rect(lmi, bw, bh, &levels); |
| @@ -11728,7 +11753,7 @@ fn decode_rect4_16_strip( | ||
| 11728 | 11753 | } |
| 11729 | 11754 | } |
| 11730 | 11755 | if has_chroma { |
| 11731 | - RECT4_16_CHROMA_HITS.with(|h| h.set(h.get() + 1)); | |
| 11756 | + hit!(RECT4_16_CHROMA_HITS); | |
| 11732 | 11757 | let pair_mi = if horz { |
| 11733 | 11758 | (lmi.0 - 1, lmi.1) |
| 11734 | 11759 | } else { |
| @@ -11740,7 +11765,7 @@ fn decode_rect4_16_strip( | ||
| 11740 | 11765 | let (cw, ch) = (pw / 2, ph / 2); |
| 11741 | 11766 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; |
| 11742 | 11767 | if (V_PRED..=D67_PRED).contains(&uv_predict_mode) { |
| 11743 | - RECT4_16_CHROMA_DIR_HITS.with(|h| h.set(h.get() + 1)); | |
| 11768 | + hit!(RECT4_16_CHROMA_DIR_HITS); | |
| 11744 | 11769 | } |
| 11745 | 11770 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height, fctx); |
| 11746 | 11771 | // lane-kf1200 r1: the chroma edge-filter type reads the neighbours |
| @@ -11758,7 +11783,7 @@ fn decode_rect4_16_strip( | ||
| 11758 | 11783 | neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c); |
| 11759 | 11784 | if smooth_neighbor_uv != neighbours.smooth_uv_neighbour_unsnapped(lmi.0, lmi.1, r, c) |
| 11760 | 11785 | { |
| 11761 | - RECT4_16_UV_PAIR_FILT_HITS.with(|h| h.set(h.get() + 1)); | |
| 11786 | + hit!(RECT4_16_UV_PAIR_FILT_HITS); | |
| 11762 | 11787 | } |
| 11763 | 11788 | let (u_levels, v_levels) = if skip { |
| 11764 | 11789 | let zeros = Grid::Zero(cw * ch); |
| @@ -11769,7 +11794,7 @@ fn decode_rect4_16_strip( | ||
| 11769 | 11794 | // chroma-only bounded box on ReelC's key frames. |
| 11770 | 11795 | let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph)); |
| 11771 | 11796 | if alpha.is_some() { |
| 11772 | - CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | |
| 11797 | + hit!(CHROMA_SKIP_CFL_HITS); | |
| 11773 | 11798 | } |
| 11774 | 11799 | for (_buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] { |
| 11775 | 11800 | if let Some((ub, vb)) = &palette_uv_bufs { |
| @@ -11879,9 +11904,9 @@ fn decode_rect4_16_strip( | ||
| 11879 | 11904 | last_uv_mode = Some(uv_predict_mode); |
| 11880 | 11905 | } |
| 11881 | 11906 | if horz { |
| 11882 | - RECT4_16_HORZ_HITS.with(|h| h.set(h.get() + 1)); | |
| 11907 | + hit!(RECT4_16_HORZ_HITS); | |
| 11883 | 11908 | } else { |
| 11884 | - RECT4_16_VERT_HITS.with(|h| h.set(h.get() + 1)); | |
| 11909 | + hit!(RECT4_16_VERT_HITS); | |
| 11885 | 11910 | } |
| 11886 | 11911 | let (pal_y_size, pal_y_colors) = |
| 11887 | 11912 | palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| @@ -11974,11 +11999,11 @@ fn decode_block_rect64( | ||
| 11974 | 11999 | // -- counted so its gate cannot go vacuous (this was a refusal until |
| 11975 | 12000 | // r34; see the gate `a_real_aomenc_palette_stream_with_8x8_leaves_ |
| 11976 | 12001 | // decodes_pixel_exact`). |
| 11977 | - PALETTE_SB_STRIP_HITS.with(|c| c.set(c.get() + 1)); | |
| 12002 | + hit!(PALETTE_SB_STRIP_HITS); | |
| 11978 | 12003 | } |
| 11979 | 12004 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 11980 | 12005 | if smooth_neighbor { |
| 11981 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | |
| 12006 | + hit!(SMOOTH_LUMA_HITS); | |
| 11982 | 12007 | } |
| 11983 | 12008 | let smooth_neighbor_uv = |
| 11984 | 12009 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); |
| @@ -12038,7 +12063,7 @@ fn decode_block_rect64( | ||
| 12038 | 12063 | (bw, bh), fctx, |
| 12039 | 12064 | ); |
| 12040 | 12065 | if depth != 0 { |
| 12041 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | |
| 12066 | + hit!(TX_DEPTH_HITS); | |
| 12042 | 12067 | // lane-rectsplit r1/r4: the superblock-level strip splits its |
| 12043 | 12068 | // transform through the very same per-unit path as its 32x32-level |
| 12044 | 12069 | // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 |
| @@ -12051,7 +12076,7 @@ fn decode_block_rect64( | ||
| 12051 | 12076 | } else { |
| 12052 | 12077 | &RECT4_SPLIT_DEPTH2_HITS |
| 12053 | 12078 | }; |
| 12054 | - which.with(|c| c.set(c.get() + 1)); | |
| 12079 | + hit_do! { which.with(|c| c.set(c.get() + 1)); } | |
| 12055 | 12080 | } |
| 12056 | 12081 | if crate::envflags::env_flag!("EC_SBPART_DUMP64") { |
| 12057 | 12082 | eprintln!( |
| @@ -12081,7 +12106,7 @@ fn decode_block_rect64( | ||
| 12081 | 12106 | }), |
| 12082 | 12107 | }; |
| 12083 | 12108 | if palette_y.is_some() || palette_uv.is_some() { |
| 12084 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 12109 | + hit!(PALETTE_SPLIT_TX_HITS); | |
| 12085 | 12110 | } |
| 12086 | 12111 | decode_rect_split( |
| 12087 | 12112 | dec, |
| @@ -12117,8 +12142,8 @@ fn decode_block_rect64( | ||
| 12117 | 12142 | // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The |
| 12118 | 12143 | // bands carry the SPLIT unit's size, not the block's. |
| 12119 | 12144 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); |
| 12120 | - RECT64_SPLIT_TXFM_PUBLISH_HITS.with(|c| c.set(c.get() + 1)); | |
| 12121 | - RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | |
| 12145 | + hit!(RECT64_SPLIT_TXFM_PUBLISH_HITS); | |
| 12146 | + hit!(RECT_PARTITION_HITS); | |
| 12122 | 12147 | return Ok(()); |
| 12123 | 12148 | } |
| 12124 | 12149 | let (tx_w, tx_h) = (bw, bh); |
| @@ -12257,7 +12282,7 @@ fn decode_block_rect64( | ||
| 12257 | 12282 | { |
| 12258 | 12283 | let cur = block_q_idx(fctx); |
| 12259 | 12284 | if cur != i32::from(base_q_idx) { |
| 12260 | - RECT64_QIDX_DRIFT_HITS.with(|c| c.set(c.get() + 1)); | |
| 12285 | + hit!(RECT64_QIDX_DRIFT_HITS); | |
| 12261 | 12286 | } |
| 12262 | 12287 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| 12263 | 12288 | eprintln!( |
| @@ -12340,7 +12365,7 @@ fn decode_block_rect64( | ||
| 12340 | 12365 | { |
| 12341 | 12366 | let cur = block_q_idx(fctx); |
| 12342 | 12367 | if cur != i32::from(base_q_idx) { |
| 12343 | - RECT64_QIDX_DRIFT_HITS.with(|c| c.set(c.get() + 1)); | |
| 12368 | + hit!(RECT64_QIDX_DRIFT_HITS); | |
| 12344 | 12369 | } |
| 12345 | 12370 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| 12346 | 12371 | eprintln!( |
| @@ -12404,7 +12429,7 @@ fn decode_block_rect64( | ||
| 12404 | 12429 | { |
| 12405 | 12430 | let cur = block_q_idx(fctx); |
| 12406 | 12431 | if cur != i32::from(base_q_idx) { |
| 12407 | - RECT64_QIDX_DRIFT_HITS.with(|c| c.set(c.get() + 1)); | |
| 12432 | + hit!(RECT64_QIDX_DRIFT_HITS); | |
| 12408 | 12433 | } |
| 12409 | 12434 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| 12410 | 12435 | eprintln!( |
| @@ -12439,7 +12464,7 @@ fn decode_block_rect64( | ||
| 12439 | 12464 | smooth_neighbor_uv, fctx, |
| 12440 | 12465 | ); |
| 12441 | 12466 | neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[&luma_levels[..], &u_levels[..], &v_levels[..]]); |
| 12442 | - RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); | |
| 12467 | + hit!(RECT_COEFF_HITS); | |
| 12443 | 12468 | } |
| 12444 | 12469 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| 12445 | 12470 | neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors); |
| @@ -12459,10 +12484,10 @@ fn decode_block_rect64( | ||
| 12459 | 12484 | // 3840x1608 10-bit stream's first silent wall, decode-order frame 33 at |
| 12460 | 12485 | // mi(16,480)). Same write as [`set_txfm_ctxs`], rect-aware. |
| 12461 | 12486 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); |
| 12462 | - SB_RECT_HITS.with(|c| c.set(c.get() + 1)); | |
| 12487 | + hit!(SB_RECT_HITS); | |
| 12463 | 12488 | match (bw, bh) { |
| 12464 | - (64, 16) => SB_RECT4_HORZ_HITS.with(|c| c.set(c.get() + 1)), | |
| 12465 | - (16, 64) => SB_RECT4_VERT_HITS.with(|c| c.set(c.get() + 1)), | |
| 12489 | + (64, 16) => hit!(SB_RECT4_HORZ_HITS), | |
| 12490 | + (16, 64) => hit!(SB_RECT4_VERT_HITS), | |
| 12466 | 12491 | _ => {} |
| 12467 | 12492 | } |
| 12468 | 12493 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| @@ -12479,7 +12504,7 @@ fn decode_block_rect64( | ||
| 12479 | 12504 | fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 { |
| 12480 | 12505 | let symbol = dec.symbol(cdf); |
| 12481 | 12506 | if symbol != ANGLE_DELTA_ZERO { |
| 12482 | - ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1)); | |
| 12507 | + hit!(ANGLE_DELTA_HITS); | |
| 12483 | 12508 | } |
| 12484 | 12509 | symbol as i32 - ANGLE_DELTA_ZERO as i32 |
| 12485 | 12510 | } |
| @@ -12549,7 +12574,7 @@ fn read_intra_mode( | ||
| 12549 | 12574 | // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single |
| 12550 | 12575 | // point every square caller routes through (see `read_intra_mode_rect`). |
| 12551 | 12576 | let cfl = if cfl && side > 32 { |
| 12552 | - NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1)); | |
| 12577 | + hit!(NOCFL_UV_MODE_HITS); | |
| 12553 | 12578 | false |
| 12554 | 12579 | } else { |
| 12555 | 12580 | cfl |
| @@ -12599,7 +12624,7 @@ fn read_intra_mode( | ||
| 12599 | 12624 | eprintln!("TRACE intrabc dv={dv:?}"); |
| 12600 | 12625 | } |
| 12601 | 12626 | fctx.intrabc_dv.with(|c| c.set(Some(dv))); |
| 12602 | - INTRABC_HITS.with(|c| c.set(c.get() + 1)); | |
| 12627 | + hit!(INTRABC_HITS); | |
| 12603 | 12628 | // spec 5.11.13 / libaom `read_intra_frame_mode_info` returns the |
| 12604 | 12629 | // moment `is_intrabc_block`: no y/uv mode, angle delta, palette, |
| 12605 | 12630 | // CFL or filter-intra syntax follows. `YMode`/`UVMode` are forced |
| @@ -12654,7 +12679,7 @@ fn read_intra_mode( | ||
| 12654 | 12679 | // bug in that fallback this lane's own scope does not cover. Keep it |
| 12655 | 12680 | // refused here rather than ship a silently-wrong decode. |
| 12656 | 12681 | if (9..=12).contains(&uv_mode) { |
| 12657 | - SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 12682 | + hit!(SMOOTH_UV_HITS); | |
| 12658 | 12683 | } |
| 12659 | 12684 | // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the |
| 12660 | 12685 | // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads |
| @@ -12662,14 +12687,14 @@ fn read_intra_mode( | ||
| 12662 | 12687 | // so a CFL block (uv_mode==13, outside `V_PRED..=D67_PRED`) already takes |
| 12663 | 12688 | // the `else` branch below and never reads one either way. |
| 12664 | 12689 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 12665 | - DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 12690 | + hit!(DIRECTIONAL_UV_HITS); | |
| 12666 | 12691 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 12667 | 12692 | } else { |
| 12668 | 12693 | 0 |
| 12669 | 12694 | }; |
| 12670 | 12695 | istep!("angle_uv", angle_delta_uv); |
| 12671 | 12696 | if angle_delta_uv != 0 { |
| 12672 | - UV_ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1)); | |
| 12697 | + hit!(UV_ANGLE_DELTA_HITS); | |
| 12673 | 12698 | } |
| 12674 | 12699 | // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called |
| 12675 | 12700 | // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`): |
| @@ -12768,7 +12793,7 @@ fn read_intra_mode( | ||
| 12768 | 12793 | } |
| 12769 | 12794 | istep!("use_filter_intra", use_filter_intra as i32); |
| 12770 | 12795 | if use_filter_intra { |
| 12771 | - FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | |
| 12796 | + hit!(FILTER_INTRA_HITS); | |
| 12772 | 12797 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 12773 | 12798 | if trace { |
| 12774 | 12799 | eprintln!("TRACE filter_intra_mode value={fi_mode}"); |
| @@ -12781,7 +12806,7 @@ fn read_intra_mode( | ||
| 12781 | 12806 | // shared U/V map) -- the same order libaom's own loop visits them in. |
| 12782 | 12807 | let palette_y = palette_y_pending.map(|(n, colors)| { |
| 12783 | 12808 | let map = decode_color_index_map(dec, cdfs, n, side, false); |
| 12784 | - PALETTE_HITS.with(|c| c.set(c.get() + 1)); | |
| 12809 | + hit!(PALETTE_HITS); | |
| 12785 | 12810 | if trace { |
| 12786 | 12811 | eprintln!("TRACE palette_y size={n} colors={:?}", &colors[..n]); |
| 12787 | 12812 | } |
| @@ -12789,7 +12814,7 @@ fn read_intra_mode( | ||
| 12789 | 12814 | }); |
| 12790 | 12815 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { |
| 12791 | 12816 | let map = decode_color_index_map(dec, cdfs, n, side / 2, true); |
| 12792 | - PALETTE_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 12817 | + hit!(PALETTE_UV_HITS); | |
| 12793 | 12818 | if trace { |
| 12794 | 12819 | eprintln!( |
| 12795 | 12820 | "TRACE palette_uv size={n} u_colors={:?} v_colors={:?}", |
| @@ -12824,7 +12849,7 @@ const UV_CFL_PRED: usize = 13; | ||
| 12824 | 12849 | /// joint sign the same way. Returns each plane's final signed `alpha_q3` |
| 12825 | 12850 | /// (`cfl_idx_to_alpha`, cfl.c): magnitude `idx + 1`, sign-zero collapsing to 0. |
| 12826 | 12851 | fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) { |
| 12827 | - CFL_BLOCK_HITS.with(|c| c.set(c.get() + 1)); | |
| 12852 | + hit!(CFL_BLOCK_HITS); | |
| 12828 | 12853 | let joint_sign = dec.symbol(&mut cdfs.cfl_sign) as i32; |
| 12829 | 12854 | let sign_u = ((joint_sign + 1) * 11) >> 5; |
| 12830 | 12855 | let sign_v = (joint_sign + 1) - 3 * sign_u; |
| @@ -13104,9 +13129,9 @@ impl PlaneBuf<'_> { | ||
| 13104 | 13129 | let corner = |
| 13105 | 13130 | (x > self.tile_x0 && y > self.tile_y0).then(|| self.data[(y - 1) * self.width + x - 1]); |
| 13106 | 13131 | if matches!((bw, bh), (16, 8) | (8, 16)) { |
| 13107 | - RECT_STRIP_PRED_HITS.with(|h| h.set(h.get() + 1)); | |
| 13132 | + hit!(RECT_STRIP_PRED_HITS); | |
| 13108 | 13133 | if across > own_across || down > own_down { |
| 13109 | - RECT_STRIP_REACH_HITS.with(|h| h.set(h.get() + 1)); | |
| 13134 | + hit!(RECT_STRIP_REACH_HITS); | |
| 13110 | 13135 | } |
| 13111 | 13136 | } |
| 13112 | 13137 | (above, left, corner) |
| @@ -13517,7 +13542,7 @@ fn decode_block( | ||
| 13517 | 13542 | c * (SUB / MI), fctx, |
| 13518 | 13543 | )?; |
| 13519 | 13544 | if at_tile_left && palette_y.is_some() { |
| 13520 | - PALETTE_TILE_LEFT_HITS.with(|c| c.set(c.get() + 1)); | |
| 13545 | + hit!(PALETTE_TILE_LEFT_HITS); | |
| 13521 | 13546 | } |
| 13522 | 13547 | let intrabc_dv = fctx.intrabc_dv.with(|c| c.take()); |
| 13523 | 13548 | // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED` |
| @@ -13530,7 +13555,7 @@ fn decode_block( | ||
| 13530 | 13555 | }; |
| 13531 | 13556 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 13532 | 13557 | if smooth_neighbor { |
| 13533 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | |
| 13558 | + hit!(SMOOTH_LUMA_HITS); | |
| 13534 | 13559 | } |
| 13535 | 13560 | let smooth_neighbor_uv = |
| 13536 | 13561 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); |
| @@ -13580,7 +13605,7 @@ fn decode_block( | ||
| 13580 | 13605 | ); |
| 13581 | 13606 | } |
| 13582 | 13607 | } |
| 13583 | - INTRABC_VARTX_HITS.with(|c| c.set(c.get() + 1)); | |
| 13608 | + hit!(INTRABC_VARTX_HITS); | |
| 13584 | 13609 | // The luma reconstruct loop below is a UNIFORM grid of one square |
| 13585 | 13610 | // transform (the intra `tx_depth` shape), so a tree that resolved to |
| 13586 | 13611 | // mixed leaf sizes is refused by name rather than reconstructed at the |
| @@ -13610,7 +13635,7 @@ fn decode_block( | ||
| 13610 | 13635 | (side.min(64), luma_tx) |
| 13611 | 13636 | }; |
| 13612 | 13637 | if tx_select && logical_tx < side && uv_mode != DC_PRED { |
| 13613 | - SQ_CHROMA_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 13638 | + hit!(SQ_CHROMA_TX_HITS); | |
| 13614 | 13639 | } |
| 13615 | 13640 | let luma_set = if tx_select { |
| 13616 | 13641 | txbset_for(logical_tx, reduced_tx_set) |
| @@ -13729,7 +13754,7 @@ fn decode_block( | ||
| 13729 | 13754 | logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); |
| 13730 | 13755 | if split_tx_skip { |
| 13731 | 13756 | if tx_select { |
| 13732 | - SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 13757 | + hit!(SKIP_SPLIT_TX_HITS); | |
| 13733 | 13758 | } |
| 13734 | 13759 | let n_axis = side / logical_tx; |
| 13735 | 13760 | for tu_row in 0..n_axis { |
| @@ -13992,7 +14017,7 @@ fn decode_block( | ||
| 13992 | 14017 | // `get_txb_ctx_general`'s `plane_bsize != tx_size` branch). |
| 13993 | 14018 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, logical_tx / MI); |
| 13994 | 14019 | if let Some(buf) = &palette_y_buf { |
| 13995 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 14020 | + hit!(PALETTE_SPLIT_TX_HITS); | |
| 13996 | 14021 | let mut window = vec![0u16; logical_tx * logical_tx]; |
| 13997 | 14022 | for row in 0..logical_tx { |
| 13998 | 14023 | let src = (tu_row * logical_tx + row) * side + tu_col * logical_tx; |
| @@ -14089,7 +14114,7 @@ fn decode_block( | ||
| 14089 | 14114 | None, chroma_ctx_offset, smooth_neighbor_uv, fctx, |
| 14090 | 14115 | )?; |
| 14091 | 14116 | if cn > 1 { |
| 14092 | - CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 14117 | + hit!(CHROMA_SPLIT_TX_HITS); | |
| 14093 | 14118 | // Immediately, so the NEXT unit of this same block reads |
| 14094 | 14119 | // this one's coefficient context (libaom's chroma |
| 14095 | 14120 | // `txb_skip_ctx` for the second quadrant is 11, i.e. base |
| @@ -14269,7 +14294,7 @@ fn decode_block_128rect( | ||
| 14269 | 14294 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; |
| 14270 | 14295 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 14271 | 14296 | if smooth_neighbor { |
| 14272 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | |
| 14297 | + hit!(SMOOTH_LUMA_HITS); | |
| 14273 | 14298 | } |
| 14274 | 14299 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); |
| 14275 | 14300 | // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or |
| @@ -14290,13 +14315,15 @@ fn decode_block_128rect( | ||
| 14290 | 14315 | 0 |
| 14291 | 14316 | }; |
| 14292 | 14317 | if depth != 0 { |
| 14293 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | |
| 14318 | + hit!(TX_DEPTH_HITS); | |
| 14319 | + } | |
| 14320 | + hit_do! { | |
| 14321 | + INTRA_SB128_DEPTH_HITS.with(|c| { | |
| 14322 | + let mut h = c.get(); | |
| 14323 | + h[depth.min(2)] += 1; | |
| 14324 | + c.set(h); | |
| 14325 | + }); | |
| 14294 | 14326 | } |
| 14295 | - INTRA_SB128_DEPTH_HITS.with(|c| { | |
| 14296 | - let mut h = c.get(); | |
| 14297 | - h[depth.min(2)] += 1; | |
| 14298 | - c.set(h); | |
| 14299 | - }); | |
| 14300 | 14327 | let logical_tx = 64 >> depth; |
| 14301 | 14328 | // A 64-point transform codes nothing past its low 32 coefficients. |
| 14302 | 14329 | let coeff_tx_side = logical_tx.min(32); |
| @@ -14426,7 +14453,7 @@ fn decode_block_128rect( | ||
| 14426 | 14453 | angle_delta_uv, cu_r, v, cu_x, cu_y, chroma_tx, chroma_tx, base_q_idx, None, None, |
| 14427 | 14454 | Some(3), smooth_neighbor_uv, fctx, |
| 14428 | 14455 | )?; |
| 14429 | - CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 14456 | + hit!(CHROMA_SPLIT_TX_HITS); | |
| 14430 | 14457 | // Immediately, so the NEXT unit of this same block reads this |
| 14431 | 14458 | // one's coefficient context; replayed after `record_split_luma_rect` |
| 14432 | 14459 | // below, which would otherwise clobber them whole-block. |
| @@ -14489,15 +14516,17 @@ fn decode_block_128rect( | ||
| 14489 | 14516 | (logical_tx, logical_tx), |
| 14490 | 14517 | (bw, bh), |
| 14491 | 14518 | ); |
| 14492 | - INTRA128_IN_INTER_HITS.with(|c| { | |
| 14493 | - let mut h = c.get(); | |
| 14494 | - h[usize::from(bw < bh)] += 1; | |
| 14495 | - c.set(h); | |
| 14496 | - }); | |
| 14519 | + hit_do! { | |
| 14520 | + INTRA128_IN_INTER_HITS.with(|c| { | |
| 14521 | + let mut h = c.get(); | |
| 14522 | + h[usize::from(bw < bh)] += 1; | |
| 14523 | + c.set(h); | |
| 14524 | + }); | |
| 14525 | + } | |
| 14497 | 14526 | } else if bw > bh { |
| 14498 | - INTRA_SB128_HORZ_HITS.with(|c| c.set(c.get() + 1)); | |
| 14527 | + hit!(INTRA_SB128_HORZ_HITS); | |
| 14499 | 14528 | } else { |
| 14500 | - INTRA_SB128_VERT_HITS.with(|c| c.set(c.get() + 1)); | |
| 14529 | + hit!(INTRA_SB128_VERT_HITS); | |
| 14501 | 14530 | } |
| 14502 | 14531 | Ok(()) |
| 14503 | 14532 | } |
| @@ -14589,7 +14618,7 @@ fn decode_leaf8( | ||
| 14589 | 14618 | // that exact mi cell. |
| 14590 | 14619 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); |
| 14591 | 14620 | if smooth_neighbor { |
| 14592 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | |
| 14621 | + hit!(SMOOTH_LUMA_HITS); | |
| 14593 | 14622 | } |
| 14594 | 14623 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec |
| 14595 | 14624 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other |
| @@ -14630,7 +14659,7 @@ fn decode_leaf8( | ||
| 14630 | 14659 | // mirrors `decode_block`'s own intrabc handling at 16x16 and up. |
| 14631 | 14660 | let intrabc_dv = fctx.intrabc_dv.with(|c| c.take()); |
| 14632 | 14661 | if intrabc_dv.is_some() { |
| 14633 | - LEAF8_INTRABC_HITS.with(|c| c.set(c.get() + 1)); | |
| 14662 | + hit!(LEAF8_INTRABC_HITS); | |
| 14634 | 14663 | } |
| 14635 | 14664 | // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour |
| 14636 | 14665 | // index map, mapped through the base colours, IS the block's prediction -- |
| @@ -14650,7 +14679,7 @@ fn decode_leaf8( | ||
| 14650 | 14679 | let (pal_uv_size, pal_uv_colors) = |
| 14651 | 14680 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 14652 | 14681 | if palette_y.is_some() || palette_uv.is_some() { |
| 14653 | - PALETTE_LEAF8_HITS.with(|c| c.set(c.get() + 1)); | |
| 14682 | + hit!(PALETTE_LEAF8_HITS); | |
| 14654 | 14683 | } |
| 14655 | 14684 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 14656 | 14685 | DC_PRED |
| @@ -14691,7 +14720,7 @@ fn decode_leaf8( | ||
| 14691 | 14720 | 0, |
| 14692 | 14721 | &mut leaves, |
| 14693 | 14722 | ); |
| 14694 | - INTRABC_VARTX_HITS.with(|c| c.set(c.get() + 1)); | |
| 14723 | + hit!(INTRABC_VARTX_HITS); | |
| 14695 | 14724 | leaves.first().map_or(8, |l| l.2) |
| 14696 | 14725 | } else if tx_select && intrabc_dv.is_none() { |
| 14697 | 14726 | read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, None) |
| @@ -14749,7 +14778,7 @@ fn decode_leaf8( | ||
| 14749 | 14778 | // rule) -- so a palette leaf takes the single 8x8 reconstruct below |
| 14750 | 14779 | // even when `tx_depth` resolved to TX_4X4. |
| 14751 | 14780 | if resolved == 4 && palette_y_buf.is_none() { |
| 14752 | - SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 14781 | + hit!(SKIP_SPLIT_TX_HITS); | |
| 14753 | 14782 | for tu_row in 0..2 { |
| 14754 | 14783 | for tu_col in 0..2 { |
| 14755 | 14784 | let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4); |
| @@ -14949,7 +14978,7 @@ fn decode_leaf8( | ||
| 14949 | 14978 | let tu_py = py + tu_row * 4; |
| 14950 | 14979 | let tu_around = neighbours.around_mi(tu_mi, 4)[0]; |
| 14951 | 14980 | if crate::encode::Reach::in_vert_ab() { |
| 14952 | - VERT_AB_TX4_HITS.with(|c| c.set(c.get() + 1)); | |
| 14981 | + hit!(VERT_AB_TX4_HITS); | |
| 14953 | 14982 | } |
| 14954 | 14983 | let tu_reach = tu_reach( |
| 14955 | 14984 | 8, |
| @@ -14969,7 +14998,7 @@ fn decode_leaf8( | ||
| 14969 | 14998 | // 16x16 and up) -- the whole-block buffer would be taken by |
| 14970 | 14999 | // the FIRST unit and indexed at the wrong stride. |
| 14971 | 15000 | if let Some(buf) = &palette_y_buf { |
| 14972 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 15001 | + hit!(PALETTE_SPLIT_TX_HITS); | |
| 14973 | 15002 | let mut window = vec![0u16; 16]; |
| 14974 | 15003 | for row in 0..4 { |
| 14975 | 15004 | let src = (tu_row * 4 + row) * 8 + tu_col * 4; |
| @@ -15123,7 +15152,7 @@ fn decode_leaf8( | ||
| 15123 | 15152 | neighbours.record_palette_y_rect(leaf_mi, 8, 8, pal_y_size, pal_y_colors); |
| 15124 | 15153 | neighbours.record_palette_uv_rect(leaf_mi, 8, 8, pal_uv_size, pal_uv_colors); |
| 15125 | 15154 | } |
| 15126 | - INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | |
| 15155 | + hit!(INTER8_SKIP_BAND_HITS); | |
| 15127 | 15156 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 15128 | 15157 | // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal |
| 15129 | 15158 | // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm && |
| @@ -15213,7 +15242,7 @@ fn read_intra_mode_sub8( | ||
| 15213 | 15242 | eprintln!("TRACE sub8 uv_mode value={uv_mode} rng={}", dec.debug_state().0); |
| 15214 | 15243 | } |
| 15215 | 15244 | if (9..=12).contains(&uv_mode) { |
| 15216 | - SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 15245 | + hit!(SMOOTH_UV_HITS); | |
| 15217 | 15246 | } |
| 15218 | 15247 | let alpha = if uv_mode == UV_CFL_PRED { |
| 15219 | 15248 | Some(read_cfl_alphas(dec, cdfs)) |
| @@ -15221,7 +15250,7 @@ fn read_intra_mode_sub8( | ||
| 15221 | 15250 | None |
| 15222 | 15251 | }; |
| 15223 | 15252 | if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 15224 | - DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 15253 | + hit!(DIRECTIONAL_UV_HITS); | |
| 15225 | 15254 | } |
| 15226 | 15255 | // See the luma comment above: no angle delta below 8x8. |
| 15227 | 15256 | let angle_delta_uv = 0; |
| @@ -15236,7 +15265,7 @@ fn read_intra_mode_sub8( | ||
| 15236 | 15265 | eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32); |
| 15237 | 15266 | } |
| 15238 | 15267 | if use_filter_intra { |
| 15239 | - FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | |
| 15268 | + hit!(FILTER_INTRA_HITS); | |
| 15240 | 15269 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 15241 | 15270 | filter_intra = Some(fi_mode); |
| 15242 | 15271 | } |
| @@ -15275,7 +15304,7 @@ fn decode_leaf_split4( | ||
| 15275 | 15304 | // one a neighbour to its RIGHT sees (its top-right 4x4, mi(row, col-1))., fctx: &crate::decode::FrameCtx |
| 15276 | 15305 | fctx: &crate::decode::FrameCtx, |
| 15277 | 15306 | ) -> Result<(usize, usize)> { |
| 15278 | - SUB8_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | |
| 15307 | + hit!(SUB8_SPLIT_HITS); | |
| 15279 | 15308 | let (r, c) = outer_at; |
| 15280 | 15309 | let mut above_mode = neighbours.above_mode[c]; |
| 15281 | 15310 | let mut left_mode = neighbours.left_mode[r]; |
| @@ -15321,7 +15350,7 @@ fn decode_leaf_split4( | ||
| 15321 | 15350 | neighbours.record_mode_mi(lmi.0, lmi.1, 1, 1, mode); |
| 15322 | 15351 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); |
| 15323 | 15352 | if smooth_neighbor { |
| 15324 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | |
| 15353 | + hit!(SMOOTH_LUMA_HITS); | |
| 15325 | 15354 | } |
| 15326 | 15355 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 15327 | 15356 | let reach = Reach::of(4, px, py, y.width, y.height, fctx); |
| @@ -15385,8 +15414,8 @@ fn decode_leaf_split4( | ||
| 15385 | 15414 | // their gates goes vacuous. |
| 15386 | 15415 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); |
| 15387 | 15416 | if alpha.is_some() { |
| 15388 | - CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | |
| 15389 | - SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); | |
| 15417 | + hit!(CHROMA_SKIP_CFL_HITS); | |
| 15418 | + hit!(SKIP_CFL_HITS); | |
| 15390 | 15419 | } |
| 15391 | 15420 | push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx); |
| 15392 | 15421 | push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx); |
| @@ -15535,8 +15564,8 @@ fn decode_leaf_rect8( | ||
| 15535 | 15564 | // same `reconstruct_rect`/`reconstruct` calls below -- and under |
| 15536 | 15565 | // a split transform, per 4x4 unit with that unit's own edge, |
| 15537 | 15566 | // which is exactly what the depth-1 loop already does. |
| 15538 | - FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | |
| 15539 | - FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.set(c.get() + 1)); | |
| 15567 | + hit!(FILTER_INTRA_RECT_HITS); | |
| 15568 | + hit!(FILTER_INTRA_RECT_SUB8_HITS); | |
| 15540 | 15569 | } |
| 15541 | 15570 | // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4 |
| 15542 | 15571 | // leaf too, and is read for every intra block, skipped or not. Its |
| @@ -15561,15 +15590,15 @@ fn decode_leaf_rect8( | ||
| 15561 | 15590 | 0 |
| 15562 | 15591 | }; |
| 15563 | 15592 | if depth != 0 { |
| 15564 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | |
| 15565 | - RECT8_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 15593 | + hit!(TX_DEPTH_HITS); | |
| 15594 | + hit!(RECT8_SPLIT_TX_HITS); | |
| 15566 | 15595 | } |
| 15567 | 15596 | leaf_modes[i] = mode; |
| 15568 | 15597 | leaf_skips[i] = skip; |
| 15569 | 15598 | neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); |
| 15570 | 15599 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); |
| 15571 | 15600 | if smooth_neighbor { |
| 15572 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | |
| 15601 | + hit!(SMOOTH_LUMA_HITS); | |
| 15573 | 15602 | } |
| 15574 | 15603 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 15575 | 15604 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); |
| @@ -15653,9 +15682,9 @@ fn decode_leaf_rect8( | ||
| 15653 | 15682 | } |
| 15654 | 15683 | if done > 0 { |
| 15655 | 15684 | if vert { |
| 15656 | - TX4X8_CODED_HITS.with(|h| h.set(h.get() + 1)); | |
| 15685 | + hit!(TX4X8_CODED_HITS); | |
| 15657 | 15686 | } else { |
| 15658 | - TX8X4_CODED_HITS.with(|h| h.set(h.get() + 1)); | |
| 15687 | + hit!(TX8X4_CODED_HITS); | |
| 15659 | 15688 | } |
| 15660 | 15689 | } |
| 15661 | 15690 | neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); |
| @@ -15695,9 +15724,9 @@ fn decode_leaf_rect8( | ||
| 15695 | 15724 | )?; |
| 15696 | 15725 | if levels.iter().any(|&l| l != 0) { |
| 15697 | 15726 | if vert { |
| 15698 | - TX4X8_CODED_HITS.with(|h| h.set(h.get() + 1)); | |
| 15727 | + hit!(TX4X8_CODED_HITS); | |
| 15699 | 15728 | } else { |
| 15700 | - TX8X4_CODED_HITS.with(|h| h.set(h.get() + 1)); | |
| 15729 | + hit!(TX8X4_CODED_HITS); | |
| 15701 | 15730 | } |
| 15702 | 15731 | } |
| 15703 | 15732 | let residual = dequant_and_inverse_typed_wh( |
| @@ -15757,8 +15786,8 @@ fn decode_leaf_rect8( | ||
| 15757 | 15786 | // their gates goes vacuous. |
| 15758 | 15787 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); |
| 15759 | 15788 | if alpha.is_some() { |
| 15760 | - CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | |
| 15761 | - SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); | |
| 15789 | + hit!(CHROMA_SKIP_CFL_HITS); | |
| 15790 | + hit!(SKIP_CFL_HITS); | |
| 15762 | 15791 | } |
| 15763 | 15792 | push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx); |
| 15764 | 15793 | push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx); |
| @@ -16576,7 +16605,7 @@ fn tx_size_context_txfm_rect( | ||
| 16576 | 16605 | own_w: usize, |
| 16577 | 16606 | own_h: usize, fctx: &crate::decode::FrameCtx, |
| 16578 | 16607 | ) -> usize { |
| 16579 | - INTRA_IN_INTER_TXCTX_HITS.with(|c| c.set(c.get() + 1)); | |
| 16608 | + hit!(INTRA_IN_INTER_TXCTX_HITS); | |
| 16580 | 16609 | let has_above = mi_r > n.tile_row0_mi; |
| 16581 | 16610 | let has_left = mi_c > n.tile_col0_mi; |
| 16582 | 16611 | let mut above = usize::from(n.above_txfm[mi_c]) >= own_w; |
| @@ -16616,7 +16645,7 @@ fn tx_size_context_txfm_rect( | ||
| 16616 | 16645 | let stale = usize::from(has_above && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= cw) |
| 16617 | 16646 | + usize::from(has_left && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= ch); |
| 16618 | 16647 | if ctx != stale { |
| 16619 | - INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS.with(|c| c.set(c.get() + 1)); | |
| 16648 | + hit!(INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS); | |
| 16620 | 16649 | } |
| 16621 | 16650 | } |
| 16622 | 16651 | ctx |
| @@ -16714,7 +16743,7 @@ fn read_tx_size( | ||
| 16714 | 16743 | ); |
| 16715 | 16744 | } |
| 16716 | 16745 | if depth != 0 { |
| 16717 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | |
| 16746 | + hit!(TX_DEPTH_HITS); | |
| 16718 | 16747 | } |
| 16719 | 16748 | max_tx >> depth |
| 16720 | 16749 | } |
| @@ -17025,7 +17054,7 @@ fn read_var_tx_size( | ||
| 17025 | 17054 | tx_h, |
| 17026 | 17055 | ); |
| 17027 | 17056 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; |
| 17028 | - TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1)); | |
| 17057 | + hit!(TXFM_SPLIT_READS); | |
| 17029 | 17058 | if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { |
| 17030 | 17059 | let (rng, _) = dec.debug_state(); |
| 17031 | 17060 | eprintln!( |
| @@ -17040,7 +17069,7 @@ fn read_var_tx_size( | ||
| 17040 | 17069 | txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h)); |
| 17041 | 17070 | return; |
| 17042 | 17071 | } |
| 17043 | - TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | |
| 17072 | + hit!(TXFM_SPLIT_HITS); | |
| 17044 | 17073 | let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h); |
| 17045 | 17074 | if (sub_w, sub_h) == (4, 4) { |
| 17046 | 17075 | // libaom's `sub_txs == TX_4X4` early return: every mi cell of the |
| @@ -17185,11 +17214,13 @@ fn read_block_tx_size( | ||
| 17185 | 17214 | leaves.push((row, col, tx, tx)); |
| 17186 | 17215 | } |
| 17187 | 17216 | } |
| 17188 | - INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| { | |
| 17189 | - let mut h = c.get(); | |
| 17190 | - h[(side.trailing_zeros() as usize).saturating_sub(3).min(3)] += 1; | |
| 17191 | - c.set(h); | |
| 17192 | - }); | |
| 17217 | + hit_do! { | |
| 17218 | + INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| { | |
| 17219 | + let mut h = c.get(); | |
| 17220 | + h[(side.trailing_zeros() as usize).saturating_sub(3).min(3)] += 1; | |
| 17221 | + c.set(h); | |
| 17222 | + }); | |
| 17223 | + } | |
| 17193 | 17224 | return Ok((tx, Some(leaves))); |
| 17194 | 17225 | } |
| 17195 | 17226 | Ok((tx, None)) |
| @@ -17593,7 +17624,7 @@ fn read_block_tx_size_rect( | ||
| 17593 | 17624 | // transform, and `set_txfm_ctxs` records exactly what |
| 17594 | 17625 | // `txfm_partition_update` would for that same unit. |
| 17595 | 17626 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); |
| 17596 | - RECT_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); | |
| 17627 | + hit!(RECT_INTER_TU_HITS); | |
| 17597 | 17628 | return Ok(None); |
| 17598 | 17629 | } |
| 17599 | 17630 | let ctx = txfm_partition_ctx_rect( |
| @@ -17604,7 +17635,7 @@ fn read_block_tx_size_rect( | ||
| 17604 | 17635 | tx_h, |
| 17605 | 17636 | ); |
| 17606 | 17637 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; |
| 17607 | - TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1)); | |
| 17638 | + hit!(TXFM_SPLIT_READS); | |
| 17608 | 17639 | if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { |
| 17609 | 17640 | let (rng, _) = dec.debug_state(); |
| 17610 | 17641 | eprintln!( |
| @@ -17616,11 +17647,11 @@ fn read_block_tx_size_rect( | ||
| 17616 | 17647 | } |
| 17617 | 17648 | if !split { |
| 17618 | 17649 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); |
| 17619 | - RECT_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); | |
| 17650 | + hit!(RECT_INTER_TU_HITS); | |
| 17620 | 17651 | return Ok(None); |
| 17621 | 17652 | } |
| 17622 | - TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | |
| 17623 | - RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1)); | |
| 17653 | + hit!(TXFM_SPLIT_HITS); | |
| 17654 | + hit!(RECT_INTER_TXSPLIT_HITS); | |
| 17624 | 17655 | // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays |
| 17625 | 17656 | // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`, |
| 17626 | 17657 | // `[TX_16X64] == TX_16X32` -- so the recursion below is the general |
| @@ -17705,14 +17736,16 @@ fn read_inter_plane_rect( | ||
| 17705 | 17736 | // rectangular shape (lane-sbpart r8). |
| 17706 | 17737 | let (cw, ch) = (w.min(32), h.min(32)); |
| 17707 | 17738 | if plane_idx == 0 && w.max(h) == 64 { |
| 17708 | - RECT64_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); | |
| 17739 | + hit!(RECT64_INTER_TU_HITS); | |
| 17709 | 17740 | } |
| 17710 | 17741 | if plane_idx == 0 && (w, h) == (32, 8) || plane_idx == 0 && (w, h) == (8, 32) { |
| 17711 | - RECT32X8_INTER_TU_HITS.with(|c| { | |
| 17712 | - let mut v = c.get(); | |
| 17713 | - v[usize::from(w == 8)] += 1; | |
| 17714 | - c.set(v); | |
| 17715 | - }); | |
| 17742 | + hit_do! { | |
| 17743 | + RECT32X8_INTER_TU_HITS.with(|c| { | |
| 17744 | + let mut v = c.get(); | |
| 17745 | + v[usize::from(w == 8)] += 1; | |
| 17746 | + c.set(v); | |
| 17747 | + }); | |
| 17748 | + } | |
| 17716 | 17749 | } |
| 17717 | 17750 | let (corner, tx_type) = if (cw, ch) == (32, 32) { |
| 17718 | 17751 | let scan32 = default_scan(TX32); |
| @@ -18286,7 +18319,7 @@ fn edge_params_body( | ||
| 18286 | 18319 | [4, 8, 14, 14, 14][dim] |
| 18287 | 18320 | }; |
| 18288 | 18321 | let level = if cur_level != 0 { cur_level } else { pv_level }; |
| 18289 | - DEBLOCK_HITS.with(|c| c.set(c.get() + 1)); | |
| 18322 | + hit!(DEBLOCK_HITS); | |
| 18290 | 18323 | Some((len, level)) |
| 18291 | 18324 | } |
| 18292 | 18325 | |
| @@ -19474,7 +19507,7 @@ fn cdef_band( | ||
| 19474 | 19507 | let mut mi_c = 0usize; |
| 19475 | 19508 | while mi_c < skip_grid.mi_cols { |
| 19476 | 19509 | if skip_grid.is_skip_txfm(mi_r, mi_c) { |
| 19477 | - CDEF_SKIPPED_UNITS.with(|c| c.set(c.get() + 1)); | |
| 19510 | + hit!(CDEF_SKIPPED_UNITS); | |
| 19478 | 19511 | } |
| 19479 | 19512 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { |
| 19480 | 19513 | let sidx = strength_idx(mi_r, mi_c); |
| @@ -19524,7 +19557,7 @@ fn cdef_band( | ||
| 19524 | 19557 | || cdef.uv_pri_strength[sidx] != 0 |
| 19525 | 19558 | || cdef.uv_sec_strength[sidx] != 0) |
| 19526 | 19559 | { |
| 19527 | - CDEF_STRADDLE_UNITS.with(|c| c.set(c.get() + 1)); | |
| 19560 | + hit!(CDEF_STRADDLE_UNITS); | |
| 19528 | 19561 | } |
| 19529 | 19562 | if enable_primary || enable_secondary { |
| 19530 | 19563 | cdef_filter_block( |
| @@ -19995,6 +20028,8 @@ fn pipe_filters_ok(fctx: &crate::decode::FrameCtx, tile_cols: u32, lf_present: b | ||
| 19995 | 20028 | /// [`apply_cdef`]'s early returns (lane-pipefilt: the pipelined path |
| 19996 | 20029 | /// never enters `apply_cdef`, so it calls this itself). |
| 19997 | 20030 | fn cdef_scan_counters(skip_grid: &Neighbours) { |
| 20031 | + let _ = skip_grid; | |
| 20032 | + hit_do! { | |
| 19998 | 20033 | let mut r = 0usize; |
| 19999 | 20034 | while r < skip_grid.mi_rows { |
| 20000 | 20035 | let mut c = 0usize; |
| @@ -20007,7 +20042,7 @@ fn cdef_scan_counters(skip_grid: &Neighbours) { | ||
| 20007 | 20042 | .map_or(true, |x| x.written) |
| 20008 | 20043 | }) |
| 20009 | 20044 | }) { |
| 20010 | - CDEF_UNWRITTEN_SKIP_UNITS.with(|c2| c2.set(c2.get() + 1)); | |
| 20045 | + hit!(CDEF_UNWRITTEN_SKIP_UNITS); | |
| 20011 | 20046 | if crate::envflags::env_flag!("EC_AV1_DEBUG_CDEF_BAND") { |
| 20012 | 20047 | eprintln!("cdef band unwritten at mi ({r},{c}) px ({},{})", r * 4, c * 4); |
| 20013 | 20048 | } |
| @@ -20020,12 +20055,13 @@ fn cdef_scan_counters(skip_grid: &Neighbours) { | ||
| 20020 | 20055 | }; |
| 20021 | 20056 | let first = cell(0, 0); |
| 20022 | 20057 | if (0..2).any(|rr| (0..2).any(|cc| cell(rr, cc) != first)) { |
| 20023 | - CDEF_MIXED_SKIP_UNITS.with(|c2| c2.set(c2.get() + 1)); | |
| 20058 | + hit!(CDEF_MIXED_SKIP_UNITS); | |
| 20024 | 20059 | } |
| 20025 | 20060 | c += 2; |
| 20026 | 20061 | } |
| 20027 | 20062 | r += 2; |
| 20028 | 20063 | } |
| 20064 | + } | |
| 20029 | 20065 | } |
| 20030 | 20066 | |
| 20031 | 20067 | /// `true` when this frame's CDEF cannot change a sample: `bits == 0` still |
| @@ -20468,7 +20504,7 @@ fn read_sb128_root( | ||
| 20468 | 20504 | let ctx128 = neighbours.partition_ctx(at128, 128); |
| 20469 | 20505 | let (has_cols128, has_rows128) = (mi_c128 + SB_MI < mi_cols, mi_r128 + SB_MI < mi_rows); |
| 20470 | 20506 | let part128 = if has_cols128 && has_rows128 { |
| 20471 | - PART128_SYMBOLS.with(|c| c.set(c.get() + 1)); | |
| 20507 | + hit!(PART128_SYMBOLS); | |
| 20472 | 20508 | let p = dec.symbol(&mut cdfs.partition_w128[ctx128]); |
| 20473 | 20509 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| 20474 | 20510 | eprintln!("TRACE partition_w128 ctx={ctx128} value={p}"); |
| @@ -20481,13 +20517,13 @@ fn read_sb128_root( | ||
| 20481 | 20517 | // gathered arm. Value 1 is SPLIT; 0 is HORZ (rows out of frame) or |
| 20482 | 20518 | // VERT (cols out of frame), which the refusal below then names |
| 20483 | 20519 | // instead of silently reconstructing a split. |
| 20484 | - PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() + 1)); | |
| 20520 | + hit!(PART128_GATHERED_SYMBOLS); | |
| 20485 | 20521 | match (has_cols128, has_rows128) { |
| 20486 | 20522 | (true, false) => { |
| 20487 | 20523 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 { |
| 20488 | 20524 | PARTITION_SPLIT |
| 20489 | 20525 | } else { |
| 20490 | - PART128_EDGE_HORZ_HITS.with(|c| c.set(c.get() + 1)); | |
| 20526 | + hit!(PART128_EDGE_HORZ_HITS); | |
| 20491 | 20527 | PARTITION_HORZ |
| 20492 | 20528 | } |
| 20493 | 20529 | } |
| @@ -20495,7 +20531,7 @@ fn read_sb128_root( | ||
| 20495 | 20531 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 { |
| 20496 | 20532 | PARTITION_SPLIT |
| 20497 | 20533 | } else { |
| 20498 | - PART128_EDGE_VERT_HITS.with(|c| c.set(c.get() + 1)); | |
| 20534 | + hit!(PART128_EDGE_VERT_HITS); | |
| 20499 | 20535 | PARTITION_VERT |
| 20500 | 20536 | } |
| 20501 | 20537 | } |
| @@ -20517,19 +20553,21 @@ fn read_sb128_root( | ||
| 20517 | 20553 | // for BLOCK_128X128 by `av1_get_partition_cdf`'s 8-symbol alphabet, |
| 20518 | 20554 | // which stops at VERT_B). |
| 20519 | 20555 | match part128 { |
| 20520 | - PARTITION_SPLIT => PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)), | |
| 20521 | - PARTITION_NONE => PART128_NONE_HITS.with(|c| c.set(c.get() + 1)), | |
| 20522 | - PARTITION_HORZ => PART128_HORZ_HITS.with(|c| c.set(c.get() + 1)), | |
| 20523 | - PARTITION_VERT => PART128_VERT_HITS.with(|c| c.set(c.get() + 1)), | |
| 20556 | + PARTITION_SPLIT => hit!(PART128_SPLIT_HITS), | |
| 20557 | + PARTITION_NONE => hit!(PART128_NONE_HITS), | |
| 20558 | + PARTITION_HORZ => hit!(PART128_HORZ_HITS), | |
| 20559 | + PARTITION_VERT => hit!(PART128_VERT_HITS), | |
| 20524 | 20560 | // lane-sb128c r9: the four AB shapes at the 128 root -- one |
| 20525 | 20561 | // 128x64/64x128 half plus two 64x64 quadrants, decoded by both tile |
| 20526 | 20562 | // paths below in libaom `decode_partition`'s own visit order. |
| 20527 | 20563 | p if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&p) => { |
| 20528 | - PART128_AB_HITS.with(|c| { | |
| 20529 | - let mut h = c.get(); | |
| 20530 | - h[p - PARTITION_HORZ_A] += 1; | |
| 20531 | - c.set(h); | |
| 20532 | - }); | |
| 20564 | + hit_do! { | |
| 20565 | + PART128_AB_HITS.with(|c| { | |
| 20566 | + let mut h = c.get(); | |
| 20567 | + h[p - PARTITION_HORZ_A] += 1; | |
| 20568 | + c.set(h); | |
| 20569 | + }); | |
| 20570 | + } | |
| 20533 | 20571 | } |
| 20534 | 20572 | _ => { |
| 20535 | 20573 | return Err(unsupported( |
| @@ -20727,7 +20765,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 20727 | 20765 | (mi_col1 as usize * 2).min(v.width), |
| 20728 | 20766 | (mi_row1 as usize * 2).min(v.height), |
| 20729 | 20767 | ); |
| 20730 | - TILE_HITS.with(|c| c.set(c.get() + 1)); | |
| 20768 | + hit!(TILE_HITS); | |
| 20731 | 20769 | |
| 20732 | 20770 | // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` -- |
| 20733 | 20771 | // its one block covers all four 64x64 quadrants, so the remaining three |
| @@ -21302,7 +21340,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 21302 | 21340 | let arm = part16 - PARTITION_HORZ_A; |
| 21303 | 21341 | bump_ab16(arm); |
| 21304 | 21342 | if part16 == PARTITION_VERT_B { |
| 21305 | - VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1)); | |
| 21343 | + hit!(VERT_B_INTRA_HITS); | |
| 21306 | 21344 | } |
| 21307 | 21345 | let _vert_guard = if part16 == PARTITION_VERT_A || part16 == PARTITION_VERT_B { |
| 21308 | 21346 | Some(crate::encode::Reach::vert_ab_partition()) |
| @@ -21401,7 +21439,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 21401 | 21439 | continue; |
| 21402 | 21440 | } |
| 21403 | 21441 | if part16 == PARTITION_HORZ { |
| 21404 | - HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); | |
| 21442 | + hit!(HORZ_VERT_INTRA_HITS); | |
| 21405 | 21443 | let (mi_row0, mi_col0) = ( |
| 21406 | 21444 | sr as u32 * SUB_MI, |
| 21407 | 21445 | sc as u32 * SUB_MI, |
| @@ -21449,7 +21487,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 21449 | 21487 | continue; |
| 21450 | 21488 | } |
| 21451 | 21489 | if part16 == PARTITION_VERT { |
| 21452 | - HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); | |
| 21490 | + hit!(HORZ_VERT_INTRA_HITS); | |
| 21453 | 21491 | let (mi_row0, mi_col0) = ( |
| 21454 | 21492 | sr as u32 * SUB_MI, |
| 21455 | 21493 | sc as u32 * SUB_MI, |
| @@ -21703,8 +21741,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 21703 | 21741 | // whole visible band of a frame whose |
| 21704 | 21742 | // height (resp. width) is 8 mod 16 -- |
| 21705 | 21743 | // the user's 3840x1608 film. |
| 21706 | - HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); | |
| 21707 | - EDGE_RECT_STRIP_HITS.with(|c| c.set(c.get() + 1)); | |
| 21744 | + hit!(HORZ_VERT_INTRA_HITS); | |
| 21745 | + hit!(EDGE_RECT_STRIP_HITS); | |
| 21708 | 21746 | let (mi_row0, mi_col0) = |
| 21709 | 21747 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 21710 | 21748 | let (bw, bh) = if has_cols16 { (16, 8) } else { (8, 16) }; |
| @@ -21933,7 +21971,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 21933 | 21971 | // a true 32x16 strip below (mirrors |
| 21934 | 21972 | // decode_inter_block's cd6cb6d HORZ_A: TL, |
| 21935 | 21973 | // TR, bottom strip). |
| 21936 | - INTRA_HORZ_A_HITS.with(|c| c.set(c.get() + 1)); | |
| 21974 | + hit!(INTRA_HORZ_A_HITS); | |
| 21937 | 21975 | decode_block( |
| 21938 | 21976 | &mut dec, |
| 21939 | 21977 | &mut cdfs, |
| @@ -22008,7 +22046,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 22008 | 22046 | // two 16x16 squares below (mirrors HORZ_A |
| 22009 | 22047 | // with the strip/squares order flipped, same |
| 22010 | 22048 | // shape as libaom decode_partition's HORZ_B). |
| 22011 | - INTRA_HORZ_B_HITS.with(|c| c.set(c.get() + 1)); | |
| 22049 | + hit!(INTRA_HORZ_B_HITS); | |
| 22012 | 22050 | decode_block_rect( |
| 22013 | 22051 | &mut dec, |
| 22014 | 22052 | &mut cdfs, |
| @@ -22082,7 +22120,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 22082 | 22120 | // lane-part32 r1: mirror of HORZ_A with |
| 22083 | 22121 | // width/height swapped (TL, BL, right 16x32 |
| 22084 | 22122 | // strip). |
| 22085 | - INTRA_VERT_A_HITS.with(|c| c.set(c.get() + 1)); | |
| 22123 | + hit!(INTRA_VERT_A_HITS); | |
| 22086 | 22124 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 22087 | 22125 | decode_block( |
| 22088 | 22126 | &mut dec, |
| @@ -22158,7 +22196,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 22158 | 22196 | // left + two 16x16 squares on the right |
| 22159 | 22197 | // (libaom decode_partition VERT_B: left |
| 22160 | 22198 | // strip, TR, BR). |
| 22161 | - INTRA_VERT_B_HITS.with(|c| c.set(c.get() + 1)); | |
| 22199 | + hit!(INTRA_VERT_B_HITS); | |
| 22162 | 22200 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 22163 | 22201 | decode_block_rect( |
| 22164 | 22202 | &mut dec, |
| @@ -22374,11 +22412,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 22374 | 22412 | // TR, BR). The pieces are exactly the ones already proven |
| 22375 | 22413 | // by the `PARTITION_NONE`-under-SPLIT (32x32 square) and |
| 22376 | 22414 | // `PARTITION_HORZ`/`VERT` (rect64 strip) arms above. |
| 22377 | - SB_AB_HITS.with(|c| { | |
| 22378 | - let mut h = c.get(); | |
| 22379 | - h[part - PARTITION_HORZ_A] += 1; | |
| 22380 | - c.set(h); | |
| 22381 | - }); | |
| 22415 | + hit_do! { | |
| 22416 | + SB_AB_HITS.with(|c| { | |
| 22417 | + let mut h = c.get(); | |
| 22418 | + h[part - PARTITION_HORZ_A] += 1; | |
| 22419 | + c.set(h); | |
| 22420 | + }); | |
| 22421 | + } | |
| 22382 | 22422 | // lane-part32 r5: only the two VERTICAL arms reorder the |
| 22383 | 22423 | // square sub-blocks (TL, BL, TR, BR), so only they switch |
| 22384 | 22424 | // libaom's `has_tr`/`has_bl` tables. |
| @@ -22815,7 +22855,7 @@ fn resolve_interp_filter( | ||
| 22815 | 22855 | sym0 |
| 22816 | 22856 | }; |
| 22817 | 22857 | if enable_dual_filter && sym0 != sym1 { |
| 22818 | - DUAL_FILTER_DIFF_HITS.with(|c| c.set(c.get() + 1)); | |
| 22858 | + hit!(DUAL_FILTER_DIFF_HITS); | |
| 22819 | 22859 | } |
| 22820 | 22860 | if crate::envflags::env_flag!("EC_TRACE_MODE") { |
| 22821 | 22861 | eprintln!( |
| @@ -23182,7 +23222,7 @@ fn read_single_ref( | ||
| 23182 | 23222 | } |
| 23183 | 23223 | }; |
| 23184 | 23224 | if ref_frame != LAST_FRAME { |
| 23185 | - NON_LAST_REF_HITS.with(|c| c.set(c.get() + 1)); | |
| 23225 | + hit!(NON_LAST_REF_HITS); | |
| 23186 | 23226 | let c = match ref_frame { |
| 23187 | 23227 | LAST2_FRAME => &LAST2_HITS, |
| 23188 | 23228 | LAST3_FRAME => &LAST3_HITS, |
| @@ -23192,7 +23232,7 @@ fn read_single_ref( | ||
| 23192 | 23232 | ALTREF_FRAME => &ALTREF_HITS, |
| 23193 | 23233 | _ => unreachable!("read_single_ref only ever returns LAST_FRAME..=ALTREF_FRAME"), |
| 23194 | 23234 | }; |
| 23195 | - c.with(|v| v.set(v.get() + 1)); | |
| 23235 | + hit_do! { c.with(|v| v.set(v.get() + 1)); } | |
| 23196 | 23236 | } |
| 23197 | 23237 | ref_frame |
| 23198 | 23238 | } |
| @@ -23442,7 +23482,7 @@ fn overlappable_above( | ||
| 23442 | 23482 | if let Some(info) = nb { |
| 23443 | 23483 | if info.is_inter { |
| 23444 | 23484 | if src != col { |
| 23445 | - OBMC_PAIR_FILTER_HITS.with(|c| c.set(c.get() + 1)); | |
| 23485 | + hit!(OBMC_PAIR_FILTER_HITS); | |
| 23446 | 23486 | } |
| 23447 | 23487 | // lane-t900 r14: libaom passes `AOMMIN(xd->width, mi_step)` |
| 23448 | 23488 | // as `op_mi_size` -- the block's OWN width, never the |
| @@ -23495,7 +23535,7 @@ fn overlappable_left( | ||
| 23495 | 23535 | if let Some(info) = nb { |
| 23496 | 23536 | if info.is_inter { |
| 23497 | 23537 | if src != row { |
| 23498 | - OBMC_PAIR_FILTER_HITS.with(|c| c.set(c.get() + 1)); | |
| 23538 | + hit!(OBMC_PAIR_FILTER_HITS); | |
| 23499 | 23539 | } |
| 23500 | 23540 | // lane-t900 r14: `AOMMIN(xd->height, mi_step)` -- see |
| 23501 | 23541 | // `overlappable_above`. |
| @@ -23667,7 +23707,7 @@ fn find_samples( | ||
| 23667 | 23707 | // wrong-alphabet-same-value). |
| 23668 | 23708 | let tr_reach = crate::mvstack::has_top_right(mi_row, mi_col, bw4, bh4, fctx); |
| 23669 | 23709 | if do_tr && bw4 != bh4 && tr_reach != has_top_right(mi_row, mi_col, bw4, fctx) { |
| 23670 | - TR_REACH_LONGER_SIDE_HITS.with(|c| c.set(c.get() + 1)); | |
| 23710 | + hit!(TR_REACH_LONGER_SIDE_HITS); | |
| 23671 | 23711 | } |
| 23672 | 23712 | if do_tr && tr_reach { |
| 23673 | 23713 | let tr_col = mi_col + bw4; |
| @@ -23765,7 +23805,7 @@ fn neighbour_filter( | ||
| 23765 | 23805 | "an OBMC neighbour whose switchable interp filter was never recorded", |
| 23766 | 23806 | )); |
| 23767 | 23807 | } |
| 23768 | - OBMC_FILTER_BAND_READS.with(|c| c.set(c.get() + 1)); | |
| 23808 | + hit!(OBMC_FILTER_BAND_READS); | |
| 23769 | 23809 | Ok(( |
| 23770 | 23810 | mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize), |
| 23771 | 23811 | mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize), |
| @@ -24130,7 +24170,7 @@ fn obmc_plan( | ||
| 24130 | 24170 | // byte-exact against an instrumented aomdec, the refusal is gone and the |
| 24131 | 24171 | // counter below is what the gate's `--enable-obmc=1` arm reads. |
| 24132 | 24172 | if matches!((write_w, write_h), (16, 8) | (8, 16)) { |
| 24133 | - OBMC_RECT_LEAF_HITS.with(|c| c.set(c.get() + 1)); | |
| 24173 | + hit!(OBMC_RECT_LEAF_HITS); | |
| 24134 | 24174 | } |
| 24135 | 24175 | // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own |
| 24136 | 24176 | // half (`reconinter.c` 860/899), inert below 128. |
| @@ -24159,7 +24199,7 @@ fn obmc_plan( | ||
| 24159 | 24199 | ec_obmc_trace("above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); |
| 24160 | 24200 | let (nb_width, _) = ref_dims(nb.ref_frame, refpix)?; |
| 24161 | 24201 | if mi_col + off4 + span4 > mi_cols { |
| 24162 | - OBMC_EDGE_SPAN_HITS.with(|c| c.set(c.get() + 1)); | |
| 24202 | + hit!(OBMC_EDGE_SPAN_HITS); | |
| 24163 | 24203 | } |
| 24164 | 24204 | above.push(ObmcNb { |
| 24165 | 24205 | off4, |
| @@ -24183,7 +24223,7 @@ fn obmc_plan( | ||
| 24183 | 24223 | ec_obmc_trace("left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); |
| 24184 | 24224 | let (nb_width, _) = ref_dims(nb.ref_frame, refpix)?; |
| 24185 | 24225 | if mi_row + off4 + span4 > mi_rows { |
| 24186 | - OBMC_EDGE_SPAN_HITS.with(|c| c.set(c.get() + 1)); | |
| 24226 | + hit!(OBMC_EDGE_SPAN_HITS); | |
| 24187 | 24227 | } |
| 24188 | 24228 | left.push(ObmcNb { |
| 24189 | 24229 | off4, |
| @@ -24496,7 +24536,7 @@ fn read_comp_mode( | ||
| 24496 | 24536 | let ctx = reference_mode_ctx(above, left); |
| 24497 | 24537 | let compound = dec.symbol(&mut cdfs.comp_mode[ctx]) == 1; |
| 24498 | 24538 | if compound { |
| 24499 | - COMP_MODE_HITS.with(|c| c.set(c.get() + 1)); | |
| 24539 | + hit!(COMP_MODE_HITS); | |
| 24500 | 24540 | } |
| 24501 | 24541 | compound |
| 24502 | 24542 | } |
| @@ -24539,7 +24579,7 @@ fn read_compound_ref_frames( | ||
| 24539 | 24579 | let type_ctx = comp_reference_type_ctx(above, left); |
| 24540 | 24580 | let unidir = dec.symbol(&mut cdfs.comp_ref_type[type_ctx]) == 0; |
| 24541 | 24581 | if unidir { |
| 24542 | - UNI_COMP_HITS.with(|c| c.set(c.get() + 1)); | |
| 24582 | + hit!(UNI_COMP_HITS); | |
| 24543 | 24583 | // uni_comp_ref (p0): forward vs. backward -- av1_get_pred_context_- |
| 24544 | 24584 | // uni_comp_ref_p is single_ref_p1's own forward/backward vote. |
| 24545 | 24585 | let bit = dec.symbol(&mut cdfs.uni_comp_ref[single_ref_p1_ctx(a, a1, l, l1)][0]); |
| @@ -24601,7 +24641,7 @@ fn read_inter_compound_mode( | ||
| 24601 | 24641 | ref_mv_ctx: usize, |
| 24602 | 24642 | ) -> u8 { |
| 24603 | 24643 | let ctx = cdf::COMPOUND_MODE_CTX_MAP[ref_mv_ctx >> 1][new_mv_ctx.min(4)]; |
| 24604 | - COMPOUND_MODE_HITS.with(|c| c.set(c.get() + 1)); | |
| 24644 | + hit!(COMPOUND_MODE_HITS); | |
| 24605 | 24645 | dec.symbol(&mut cdfs.inter_compound_mode[ctx]) as u8 |
| 24606 | 24646 | } |
| 24607 | 24647 | |
| @@ -24940,7 +24980,7 @@ fn decode_inter_block( | ||
| 24940 | 24980 | ); |
| 24941 | 24981 | } |
| 24942 | 24982 | if skip_mode { |
| 24943 | - SKIP_MODE_HITS.with(|c| c.set(c.get() + 1)); | |
| 24983 | + hit!(SKIP_MODE_HITS); | |
| 24944 | 24984 | } |
| 24945 | 24985 | |
| 24946 | 24986 | let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); |
| @@ -25177,7 +25217,7 @@ fn decode_inter_block( | ||
| 25177 | 25217 | // model, so a 4-px-sided block still reads its interp filter. |
| 25178 | 25218 | let gm_nontrans = gm_nontrans_models && bw4.min(bh4) >= 2; |
| 25179 | 25219 | if gm_nontrans_models && !gm_nontrans { |
| 25180 | - GM_NONTRANS_SMALL_SIDE_HITS.with(|c| c.set(c.get() + 1)); | |
| 25220 | + hit!(GM_NONTRANS_SMALL_SIDE_HITS); | |
| 25181 | 25221 | } |
| 25182 | 25222 | // lane-defer8: both slots' pictures are resolved inside the |
| 25183 | 25223 | // prediction closure; the parse only needs their SIZES. |
| @@ -25229,7 +25269,7 @@ fn decode_inter_block( | ||
| 25229 | 25269 | let warp0 = compound_warp(ref0, is_global_mv0).filter(|_| ref_unscaled(ref0)); |
| 25230 | 25270 | let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1)); |
| 25231 | 25271 | if warp0.is_some() || warp1.is_some() { |
| 25232 | - COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1)); | |
| 25272 | + hit!(COMPOUND_WARP_HITS); | |
| 25233 | 25273 | } |
| 25234 | 25274 | // spec `get_ref_filter_type`: matches when EITHER of the |
| 25235 | 25275 | // neighbour's two references equals this block's own ref0 -- |
| @@ -25343,13 +25383,15 @@ fn decode_inter_block( | ||
| 25343 | 25383 | // verified vs independent C dump (wedge.rs). |
| 25344 | 25384 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); |
| 25345 | 25385 | let wedge_sign = dec.literal(1); |
| 25346 | - WEDGE_HITS.with(|c| c.set(c.get() + 1)); | |
| 25386 | + hit!(WEDGE_HITS); | |
| 25347 | 25387 | if let Some(k) = rect_wedge_slot(write_w, write_h) { |
| 25348 | - RECT_WEDGE_HITS.with(|c| { | |
| 25349 | - let mut a = c.get(); | |
| 25350 | - a[k] += 1; | |
| 25351 | - c.set(a); | |
| 25352 | - }); | |
| 25388 | + hit_do! { | |
| 25389 | + RECT_WEDGE_HITS.with(|c| { | |
| 25390 | + let mut a = c.get(); | |
| 25391 | + a[k] += 1; | |
| 25392 | + c.set(a); | |
| 25393 | + }); | |
| 25394 | + } | |
| 25353 | 25395 | } |
| 25354 | 25396 | // lane-inter16ab r5: the codebook row is this block's TRUE |
| 25355 | 25397 | // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for |
| @@ -25368,12 +25410,12 @@ fn decode_inter_block( | ||
| 25368 | 25410 | let mask_type = dec.literal(1); |
| 25369 | 25411 | diffwtd_mask_type = Some(mask_type as u8); |
| 25370 | 25412 | if wedge_bsize.is_none() { |
| 25371 | - DIFFWTD_INFERRED_HITS.with(|c| c.set(c.get() + 1)); | |
| 25413 | + hit!(DIFFWTD_INFERRED_HITS); | |
| 25372 | 25414 | } |
| 25373 | 25415 | } |
| 25374 | - MASKED_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); | |
| 25416 | + hit!(MASKED_COMPOUND_HITS); | |
| 25375 | 25417 | if write_w != write_h { |
| 25376 | - RECT_MASKED_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); | |
| 25418 | + hit!(RECT_MASKED_COMPOUND_HITS); | |
| 25377 | 25419 | } |
| 25378 | 25420 | } |
| 25379 | 25421 | // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): r16/r17 |
| @@ -25649,13 +25691,13 @@ fn decode_inter_block( | ||
| 25649 | 25691 | let scale0 = mc::scale_factor(ref_dims(ref0, refpix)?.0, frame_width); |
| 25650 | 25692 | let scale1 = mc::scale_factor(ref_dims(ref1, refpix)?.0, frame_width); |
| 25651 | 25693 | if scale0 != mc::REF_NO_SCALE || scale1 != mc::REF_NO_SCALE { |
| 25652 | - SCALED_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); | |
| 25694 | + hit!(SCALED_COMPOUND_HITS); | |
| 25653 | 25695 | } |
| 25654 | 25696 | // lane-scaledref r2: the MIXED case -- one tap scaled, the other |
| 25655 | 25697 | // not -- is the one an all-frames-scaled recipe never produces, |
| 25656 | 25698 | // and the one a single shared scale factor would get wrong. |
| 25657 | 25699 | if (scale0 == mc::REF_NO_SCALE) != (scale1 == mc::REF_NO_SCALE) { |
| 25658 | - MIXED_SCALE_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); | |
| 25700 | + hit!(MIXED_SCALE_COMPOUND_HITS); | |
| 25659 | 25701 | } |
| 25660 | 25702 | |
| 25661 | 25703 | // lane-wave4 (the compound arm's half): this block's whole |
| @@ -25737,7 +25779,7 @@ fn decode_inter_block( | ||
| 25737 | 25779 | // either way, only the mask source differs. |
| 25738 | 25780 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { |
| 25739 | 25781 | diffwtd_mask_y = vec![0u8; side * side]; |
| 25740 | - DIFFWTD_HITS.with(|c| c.set(c.get() + 1)); | |
| 25782 | + hit!(DIFFWTD_HITS); | |
| 25741 | 25783 | mc::diffwtd_mask(&inter0_y, &inter1_y, mask_type == 1, &mut diffwtd_mask_y, fctx); |
| 25742 | 25784 | Some(diffwtd_mask_y.as_slice()) |
| 25743 | 25785 | } else { |
| @@ -26113,7 +26155,7 @@ fn decode_inter_block( | ||
| 26113 | 26155 | neighbours.record_mi_chroma( |
| 26114 | 26156 | cu_mi, luma_span, luma_span, plane_idx, &cu_grid, |
| 26115 | 26157 | ); |
| 26116 | - CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 26158 | + hit!(CHROMA_SPLIT_TX_HITS); | |
| 26117 | 26159 | mu_chroma = true; |
| 26118 | 26160 | let dst = mu_units( |
| 26119 | 26161 | if plane_idx == 1 { &mut u_units } else { &mut v_units }, |
| @@ -26504,13 +26546,15 @@ fn decode_inter_block( | ||
| 26504 | 26546 | // NO sign symbol follows -- libaom fixes |
| 26505 | 26547 | // INTERINTRA_WEDGE_SIGN 0 (blockd.h). |
| 26506 | 26548 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); |
| 26507 | - WII_HITS.with(|c| c.set(c.get() + 1)); | |
| 26549 | + hit!(WII_HITS); | |
| 26508 | 26550 | if let Some(k) = rect_wedge_slot(write_w, write_h) { |
| 26509 | - RECT_WII_HITS.with(|c| { | |
| 26510 | - let mut a = c.get(); | |
| 26511 | - a[k] += 1; | |
| 26512 | - c.set(a); | |
| 26513 | - }); | |
| 26551 | + hit_do! { | |
| 26552 | + RECT_WII_HITS.with(|c| { | |
| 26553 | + let mut a = c.get(); | |
| 26554 | + a[k] += 1; | |
| 26555 | + c.set(a); | |
| 26556 | + }); | |
| 26557 | + } | |
| 26514 | 26558 | } |
| 26515 | 26559 | // lane-inter16ab r5: true-footprint codebook row, |
| 26516 | 26560 | // mask padded to stride `max(bw,bh) == side` -- see |
| @@ -26522,7 +26566,7 @@ fn decode_inter_block( | ||
| 26522 | 26566 | side, |
| 26523 | 26567 | )); |
| 26524 | 26568 | } else { |
| 26525 | - INTERINTRA_HITS.with(|c| c.set(c.get() + 1)); | |
| 26569 | + hit!(INTERINTRA_HITS); | |
| 26526 | 26570 | } |
| 26527 | 26571 | interintra_mode = Some(ii); |
| 26528 | 26572 | } |
| @@ -26660,10 +26704,10 @@ fn decode_inter_block( | ||
| 26660 | 26704 | let warp_eligible = |
| 26661 | 26705 | allow_warped_motion && !ref_is_scaled && !force_integer_mv && proj_ok; |
| 26662 | 26706 | if allow_warped_motion && proj_ok && ref_is_scaled { |
| 26663 | - SCALED_WARP_SUPPRESSED_HITS.with(|c| c.set(c.get() + 1)); | |
| 26707 | + hit!(SCALED_WARP_SUPPRESSED_HITS); | |
| 26664 | 26708 | } |
| 26665 | 26709 | if allow_warped_motion && proj_ok && !ref_is_scaled && force_integer_mv { |
| 26666 | - FIMV_ALPHABET_HITS.with(|c| c.set(c.get() + 1)); | |
| 26710 | + hit!(FIMV_ALPHABET_HITS); | |
| 26667 | 26711 | } |
| 26668 | 26712 | if warp_eligible { |
| 26669 | 26713 | let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); |
| @@ -26671,11 +26715,11 @@ fn decode_inter_block( | ||
| 26671 | 26715 | 0 => {} |
| 26672 | 26716 | 1 => { |
| 26673 | 26717 | obmc_selected = true; |
| 26674 | - OBMC_HITS.with(|c| c.set(c.get() + 1)); | |
| 26718 | + hit!(OBMC_HITS); | |
| 26675 | 26719 | } |
| 26676 | 26720 | _ => { |
| 26677 | 26721 | warped_selected = true; |
| 26678 | - WARP_SELECTED_HITS.with(|c| c.set(c.get() + 1)); | |
| 26722 | + hit!(WARP_SELECTED_HITS); | |
| 26679 | 26723 | let mut samples = find_samples( |
| 26680 | 26724 | grid, |
| 26681 | 26725 | mi_row, |
| @@ -26724,7 +26768,7 @@ fn decode_inter_block( | ||
| 26724 | 26768 | } else { |
| 26725 | 26769 | obmc_selected = dec.symbol(&mut cdfs.obmc[bsize_idx]) == 1; |
| 26726 | 26770 | if obmc_selected { |
| 26727 | - OBMC_HITS.with(|c| c.set(c.get() + 1)); | |
| 26771 | + hit!(OBMC_HITS); | |
| 26728 | 26772 | } |
| 26729 | 26773 | } |
| 26730 | 26774 | // lane-t900 r9: which ALPHABET this block read (3-symbol |
| @@ -26764,7 +26808,7 @@ fn decode_inter_block( | ||
| 26764 | 26808 | if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { |
| 26765 | 26809 | warp_params = crate::warp::global_warp_params(gm_ref.params); |
| 26766 | 26810 | if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine { |
| 26767 | - AFFINE_GM_HITS.with(|c| c.set(c.get() + 1)); | |
| 26811 | + hit!(AFFINE_GM_HITS); | |
| 26768 | 26812 | } |
| 26769 | 26813 | } |
| 26770 | 26814 | if crate::envflags::env_flag!("EC_AV1_TELL") { |
| @@ -26871,13 +26915,13 @@ fn decode_inter_block( | ||
| 26871 | 26915 | // which this file used to SKIP under a scaled reference |
| 26872 | 26916 | // (fixed in the same commit), not the warp fallback. |
| 26873 | 26917 | if warp_params.is_some() { |
| 26874 | - SCALED_WARP_FALLBACK_HITS.with(|c| c.set(c.get() + 1)); | |
| 26918 | + hit!(SCALED_WARP_FALLBACK_HITS); | |
| 26875 | 26919 | } |
| 26876 | 26920 | if obmc_selected { |
| 26877 | - SCALED_OBMC_HITS.with(|c| c.set(c.get() + 1)); | |
| 26921 | + hit!(SCALED_OBMC_HITS); | |
| 26878 | 26922 | } |
| 26879 | 26923 | if interintra_mode.is_some() { |
| 26880 | - SCALED_INTERINTRA_HITS.with(|c| c.set(c.get() + 1)); | |
| 26924 | + hit!(SCALED_INTERINTRA_HITS); | |
| 26881 | 26925 | } |
| 26882 | 26926 | } |
| 26883 | 26927 | |
| @@ -26891,7 +26935,7 @@ fn decode_inter_block( | ||
| 26891 | 26935 | let sub8 = match strip_chroma.filter(|s| s.has_chroma).and_then(|s| s.prev.map(|p| (s.horz, p))) { |
| 26892 | 26936 | Some((horz, (prev_ref, prev_mv, prev_h, prev_v))) => { |
| 26893 | 26937 | let (prev_width, _) = ref_dims(prev_ref, refpix)?; |
| 26894 | - INTER16_SUB8_PIECE_HITS.with(|c| c.set(c.get() + 1)); | |
| 26938 | + hit!(INTER16_SUB8_PIECE_HITS); | |
| 26895 | 26939 | Some(( |
| 26896 | 26940 | horz, |
| 26897 | 26941 | prev_ref, |
| @@ -27094,7 +27138,7 @@ fn decode_inter_block( | ||
| 27094 | 27138 | // plane loop). |
| 27095 | 27139 | if let Some(ii) = interintra_mode { |
| 27096 | 27140 | if write_w != write_h { |
| 27097 | - INTERINTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | |
| 27141 | + hit!(INTERINTRA_RECT_HITS); | |
| 27098 | 27142 | } |
| 27099 | 27143 | interintra_blend(y, px, py, write_w, write_h, side, ii, wedge_mask, &mut pred_y, fctx); |
| 27100 | 27144 | interintra_blend( |
| @@ -27403,7 +27447,7 @@ fn decode_inter_block( | ||
| 27403 | 27447 | neighbours.record_mi_chroma( |
| 27404 | 27448 | cu_mi, luma_span, luma_span, plane_idx, &cu_grid, |
| 27405 | 27449 | ); |
| 27406 | - CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 27450 | + hit!(CHROMA_SPLIT_TX_HITS); | |
| 27407 | 27451 | mu_chroma = true; |
| 27408 | 27452 | let dst = mu_units( |
| 27409 | 27453 | if plane_idx == 1 { &mut u_units } else { &mut v_units }, |
| @@ -27749,7 +27793,7 @@ fn decode_inter_block( | ||
| 27749 | 27793 | 0 |
| 27750 | 27794 | }; |
| 27751 | 27795 | if angle_delta_y != 0 { |
| 27752 | - INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.set(c.get() + 1)); | |
| 27796 | + hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS); | |
| 27753 | 27797 | } |
| 27754 | 27798 | // The delta'd angle decides whether the intra edge filter runs at |
| 27755 | 27799 | // all, so this block needs the same luma edge-filter-type neighbour |
| @@ -27768,7 +27812,7 @@ fn decode_inter_block( | ||
| 27768 | 27812 | // block on. |
| 27769 | 27813 | let cfl_allowed = write_w.max(write_h) <= 32; |
| 27770 | 27814 | if !cfl_allowed { |
| 27771 | - NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1)); | |
| 27815 | + hit!(NOCFL_UV_MODE_HITS); | |
| 27772 | 27816 | } |
| 27773 | 27817 | let uv_mode = if cfl_allowed { |
| 27774 | 27818 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| @@ -27776,7 +27820,7 @@ fn decode_inter_block( | ||
| 27776 | 27820 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 27777 | 27821 | }; |
| 27778 | 27822 | if (9..=12).contains(&uv_mode) { |
| 27779 | - SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); |
crates/ec-av1/src/film_grain.rsmodified+2 -1
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | //! [`crate::stream::decode_stream`] is the only caller: it applies this to |
| 13 | 13 | //! the frame it pushes onto its output `Vec<Picture>`, after saving the |
| 14 | 14 | //! clean decode into the reference slot bank. |
| 15 | +use crate::hits::hit; | |
| 15 | 16 | |
| 16 | 17 | use crate::decode::WithRef; |
| 17 | 18 | use crate::encode::Picture; |
| @@ -1107,7 +1108,7 @@ pub(crate) fn apply_grain( | ||
| 1107 | 1108 | return picture.clone(); |
| 1108 | 1109 | } |
| 1109 | 1110 | fctx.grain_bit_depth.with(|c| c.set(bit_depth)); |
| 1110 | - GRAIN_HITS.with(|c| c.set(c.get() + 1)); | |
| 1111 | + hit!(GRAIN_HITS); | |
| 1111 | 1112 | let width = picture.width as i32; |
| 1112 | 1113 | let height = picture.height as i32; |
| 1113 | 1114 | let y_stride = width; |
crates/ec-av1/src/hits.rsadded+47 -0
| @@ -0,0 +1,47 @@ | ||
| 1 | +//! Gate-counter bumps, compiled out when the `gate-counters` feature is off. | |
| 2 | +//! | |
| 3 | +//! The ~550 `*_HITS` thread-locals in this crate exist only so the test gates | |
| 4 | +//! (and the probe's census print) can prove a coding path fired; every bump is | |
| 5 | +//! a TLS access plus a `Cell` read-modify-write on the parse thread. Routing | |
| 6 | +//! all of them through [`hit!`]/[`hit_do!`] lets a shipped decoder drop them | |
| 7 | +//! (`--no-default-features`) while the accessors keep compiling and returning | |
| 8 | +//! whatever the counters hold (0 when the feature is off), so no caller needs | |
| 9 | +//! a `cfg`. | |
| 10 | + | |
| 11 | +/// Bumps counter `$name` by one -- nothing at all without `gate-counters`. | |
| 12 | +/// Usable in expression position (it evaluates to `()`). | |
| 13 | +#[cfg(feature = "gate-counters")] | |
| 14 | +macro_rules! hit { | |
| 15 | + ($name:ident) => {{ | |
| 16 | + $name.with(|c| c.set(c.get() + 1)); | |
| 17 | + }}; | |
| 18 | +} | |
| 19 | + | |
| 20 | +#[cfg(not(feature = "gate-counters"))] | |
| 21 | +macro_rules! hit { | |
| 22 | + ($name:ident) => {{}}; | |
| 23 | +} | |
| 24 | + | |
| 25 | +/// Same, for a bump that is not a plain `+= 1` (array/tuple buckets, the | |
| 26 | +/// `inter_last_mc` stamp, the counter-only scan loops): the whole statement | |
| 27 | +/// list disappears without `gate-counters`. | |
| 28 | +#[cfg(feature = "gate-counters")] | |
| 29 | +macro_rules! hit_do { | |
| 30 | + ($($t:tt)*) => {{ | |
| 31 | + $($t)* | |
| 32 | + }}; | |
| 33 | +} | |
| 34 | + | |
| 35 | +// Without the feature the statements stay type-checked but unreachable, so the | |
| 36 | +// values they read (bucket indices, filter kinds) still count as used and the | |
| 37 | +// optimiser drops the whole branch. | |
| 38 | +#[cfg(not(feature = "gate-counters"))] | |
| 39 | +macro_rules! hit_do { | |
| 40 | + ($($t:tt)*) => {{ | |
| 41 | + if false { | |
| 42 | + $($t)* | |
| 43 | + } | |
| 44 | + }}; | |
| 45 | +} | |
| 46 | + | |
| 47 | +pub(crate) use {hit, hit_do}; |
crates/ec-av1/src/intra.rsmodified+4 -3
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | //! not this module's business -- the caller passes the samples it has, and the |
| 8 | 8 | //! edge is extended by repeating the last one, which is what the decoder does |
| 9 | 9 | //! with its own `BlockDecoded` bookkeeping (spec 7.11.2.2). |
| 10 | +use crate::hits::hit; | |
| 10 | 11 | |
| 11 | 12 | /// The average of the neighbours (spec 7.11.2.5). |
| 12 | 13 | pub const DC_PRED: u8 = 0; |
| @@ -284,9 +285,9 @@ pub(crate) fn predict( | ||
| 284 | 285 | assert_eq!(dst.len(), bw * bh, "the destination is the block"); |
| 285 | 286 | match mode { |
| 286 | 287 | SMOOTH_PRED | SMOOTH_V_PRED | SMOOTH_H_PRED => { |
| 287 | - SMOOTH_PRED_HITS.with(|c| c.set(c.get() + 1)); | |
| 288 | + hit!(SMOOTH_PRED_HITS); | |
| 288 | 289 | } |
| 289 | - PAETH_PRED => PAETH_PRED_HITS.with(|c| c.set(c.get() + 1)), | |
| 290 | + PAETH_PRED => hit!(PAETH_PRED_HITS), | |
| 290 | 291 | _ => {} |
| 291 | 292 | } |
| 292 | 293 | let edges = Edges::build(above, left, corner, bw, bh, fctx); |
| @@ -483,7 +484,7 @@ fn filter_intra_edge(buf: &mut [i32], strength: i32) { | ||
| 483 | 484 | if strength == 0 { |
| 484 | 485 | return; |
| 485 | 486 | } |
| 486 | - EDGE_FILTER_HITS.with(|c| c.set(c.get() + 1)); | |
| 487 | + hit!(EDGE_FILTER_HITS); | |
| 487 | 488 | const KERNEL: [[i32; 5]; 3] = [[0, 4, 8, 4, 0], [0, 5, 6, 5, 0], [2, 4, 4, 4, 2]]; |
| 488 | 489 | let filt = usize::try_from(strength - 1).expect("a filter strength is never negative"); |
| 489 | 490 | let sz = buf.len() as i32; |
crates/ec-av1/src/lib.rsmodified+1 -0
| @@ -34,6 +34,7 @@ mod envflags; | ||
| 34 | 34 | mod film_grain; |
| 35 | 35 | pub mod frame; |
| 36 | 36 | mod gate_coverage; |
| 37 | +mod hits; | |
| 37 | 38 | pub mod intra; |
| 38 | 39 | pub mod mc; |
| 39 | 40 | pub mod motion; |
crates/ec-av1/src/mc.rsmodified+7 -6
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | //! in 1/16-pel steps -- luma motion vectors are stored at 1/8-pel and always |
| 9 | 9 | //! land on an even step; chroma vectors, once scaled for subsampling, can |
| 10 | 10 | //! land on any of the 16. |
| 11 | +use crate::hits::hit; | |
| 11 | 12 | |
| 12 | 13 | /// `Round2` (spec 4.7): halves round up. |
| 13 | 14 | fn round2(value: i32, shift: u32) -> i32 { |
| @@ -1133,7 +1134,7 @@ pub(crate) fn predict_with_filters_kern( | ||
| 1133 | 1134 | ) { |
| 1134 | 1135 | assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); |
| 1135 | 1136 | assert!(!reference.is_empty(), "a reference plane has samples"); |
| 1136 | - INTER_PRED_HITS.with(|c| c.set(c.get() + 1)); | |
| 1137 | + hit!(INTER_PRED_HITS); | |
| 1137 | 1138 | |
| 1138 | 1139 | #[cfg(test)] |
| 1139 | 1140 | let stage_t = std::time::Instant::now(); |
| @@ -1328,7 +1329,7 @@ pub fn reset_rect_narrow_kern_hits() { | ||
| 1328 | 1329 | /// the destination buffer's dims would not have. |
| 1329 | 1330 | fn note_narrow_kern(block_w: usize, block_h: usize, kern_w: usize, kern_h: usize) { |
| 1330 | 1331 | if (kern_w <= 4) != (block_w <= 4) || (kern_h <= 4) != (block_h <= 4) { |
| 1331 | - RECT_NARROW_KERN_HITS.with(|c| c.set(c.get() + 1)); | |
| 1332 | + hit!(RECT_NARROW_KERN_HITS); | |
| 1332 | 1333 | } |
| 1333 | 1334 | } |
| 1334 | 1335 | |
| @@ -1514,8 +1515,8 @@ pub(crate) fn predict_scaled_kern( | ||
| 1514 | 1515 | ) { |
| 1515 | 1516 | assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); |
| 1516 | 1517 | assert!(!reference.is_empty(), "a reference plane has samples"); |
| 1517 | - INTER_PRED_HITS.with(|c| c.set(c.get() + 1)); | |
| 1518 | - PREDICT_SCALED_HITS.with(|c| c.set(c.get() + 1)); | |
| 1518 | + hit!(INTER_PRED_HITS); | |
| 1519 | + hit!(PREDICT_SCALED_HITS); | |
| 1519 | 1520 | |
| 1520 | 1521 | let y0 = y_q4.div_euclid(16); |
| 1521 | 1522 | let yfrac = y_q4.rem_euclid(16) as usize; |
| @@ -1655,10 +1656,10 @@ pub fn predict_compound_intermediate_kern( | ||
| 1655 | 1656 | ) { |
| 1656 | 1657 | assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); |
| 1657 | 1658 | assert!(!reference.is_empty(), "a reference plane has samples"); |
| 1658 | - INTER_PRED_HITS.with(|c| c.set(c.get() + 1)); | |
| 1659 | + hit!(INTER_PRED_HITS); | |
| 1659 | 1660 | |
| 1660 | 1661 | if x_scale_fp != REF_NO_SCALE { |
| 1661 | - PREDICT_SCALED_HITS.with(|c| c.set(c.get() + 1)); | |
| 1662 | + hit!(PREDICT_SCALED_HITS); | |
| 1662 | 1663 | } |
| 1663 | 1664 | |
| 1664 | 1665 | let y0 = y_q4.div_euclid(16); |
crates/ec-av1/src/motion_field.rsmodified+3 -2
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | //! (`av1/common/mvref_common.c`) and the projection math `add_tpl_ref_mv` |
| 6 | 6 | //! (same file) applies a second time, per query block, against the block's |
| 7 | 7 | //! own single reference frame. |
| 8 | +use crate::hits::hit; | |
| 8 | 9 | |
| 9 | 10 | use crate::mvstack::{ALTREF_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME}; |
| 10 | 11 | |
| @@ -400,10 +401,10 @@ pub fn setup_motion_field<M: std::borrow::Borrow<MotionField>>( | ||
| 400 | 401 | }) |
| 401 | 402 | .count(); |
| 402 | 403 | if intra_forward_refs >= 1 { |
| 403 | - REFSTAMP_INTRA_FRAMES.with(|c| c.set(c.get() + 1)); | |
| 404 | + hit!(REFSTAMP_INTRA_FRAMES); | |
| 404 | 405 | } |
| 405 | 406 | if intra_forward_refs >= 2 { |
| 406 | - REFSTAMP_INTRA2_FRAMES.with(|c| c.set(c.get() + 1)); | |
| 407 | + hit!(REFSTAMP_INTRA2_FRAMES); | |
| 407 | 408 | } |
| 408 | 409 | |
| 409 | 410 | if let Some(last) = slot_of(LAST_FRAME) { |
crates/ec-av1/src/mvstack.rsmodified+9 -8
| @@ -77,6 +77,7 @@ | ||
| 77 | 77 | //! added by the row/col scan), and the "extra search" that pads a short |
| 78 | 78 | //! stack to two entries (spec 7.10.2.12) — this module's stack can be |
| 79 | 79 | //! shorter than two candidates where libaom's never is. |
| 80 | +use crate::hits::hit; | |
| 80 | 81 | |
| 81 | 82 | thread_local! { |
| 82 | 83 | /// How many query blocks [`find_mv_stack_with_sign_bias`] has folded at |
| @@ -503,7 +504,7 @@ fn add_candidate(candidates: &mut StackVec, mv: (i32, i32), weight: u32) { | ||
| 503 | 504 | if let Some(entry) = candidates.iter_mut().find(|e| e.mv == mv) { |
| 504 | 505 | entry.weight += weight; |
| 505 | 506 | } else if candidates.len() >= MAX_STACK_SIZE { |
| 506 | - STACK_FULL_DROPS.with(|c| c.set(c.get() + 1)); | |
| 507 | + hit!(STACK_FULL_DROPS); | |
| 507 | 508 | } else { |
| 508 | 509 | // libaom `add_ref_mv_candidate` (mvref_common.c:100) and |
| 509 | 510 | // `add_tpl_ref_mv` (:388) only push when |
| @@ -983,7 +984,7 @@ fn clamp_mv_ref( | ||
| 983 | 984 | let clamped_row = row.clamp(to_top - bh8 - MV_BORDER, to_bottom + bh8 + MV_BORDER); |
| 984 | 985 | let clamped_col = col.clamp(to_left - bw8 - MV_BORDER, to_right + bw8 + MV_BORDER); |
| 985 | 986 | if clamped_row != row || clamped_col != col { |
| 986 | - MV_CLAMP_EDGE_OVERHANG_HITS.with(|c| c.set(c.get() + 1)); | |
| 987 | + hit!(MV_CLAMP_EDGE_OVERHANG_HITS); | |
| 987 | 988 | } |
| 988 | 989 | } |
| 989 | 990 | |
| @@ -1194,7 +1195,7 @@ pub fn find_mv_stack_with_sign_bias( | ||
| 1194 | 1195 | // `None` for the cells outside the tile. |
| 1195 | 1196 | let (tile_row0, tile_col0) = grid.tile_origin(); |
| 1196 | 1197 | if tile_row0 > 0 || tile_col0 > 0 { |
| 1197 | - TILE_REACH_CLIPS.with(|c| c.set(c.get() + 1)); | |
| 1198 | + hit!(TILE_REACH_CLIPS); | |
| 1198 | 1199 | } |
| 1199 | 1200 | let max_row_offset: isize = if mi_row > tile_row0 { |
| 1200 | 1201 | let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj); |
| @@ -1361,7 +1362,7 @@ pub fn find_mv_stack_with_sign_bias( | ||
| 1361 | 1362 | } |
| 1362 | 1363 | } |
| 1363 | 1364 | if any_hit { |
| 1364 | - TMV_HITS.with(|c| c.set(c.get() + 1)); | |
| 1365 | + hit!(TMV_HITS); | |
| 1365 | 1366 | } |
| 1366 | 1367 | zero_mv_ctx = usize::from(first_sample_missing || first_sample_far); |
| 1367 | 1368 | } |
| @@ -1661,7 +1662,7 @@ fn add_compound_candidate( | ||
| 1661 | 1662 | if let Some(entry) = candidates.iter_mut().find(|e| e.mv0 == mv0 && e.mv1 == mv1) { |
| 1662 | 1663 | entry.weight += weight; |
| 1663 | 1664 | } else if candidates.len() >= MAX_STACK_SIZE { |
| 1664 | - STACK_FULL_DROPS.with(|c| c.set(c.get() + 1)); | |
| 1665 | + hit!(STACK_FULL_DROPS); | |
| 1665 | 1666 | } else { |
| 1666 | 1667 | // Same insertion cap as [`add_candidate`]: libaom's compound branch |
| 1667 | 1668 | // of `add_ref_mv_candidate` (mvref_common.c:128) and `add_tpl_ref_mv` |
| @@ -1946,7 +1947,7 @@ fn combine_compound_candidates( | ||
| 1946 | 1947 | std::array::from_fn(|i| { |
| 1947 | 1948 | merged.get(i).copied().unwrap_or_else(|| { |
| 1948 | 1949 | if gm_mv_candidates[side] != (0, 0) { |
| 1949 | - COMP_GM_FILL_HITS.with(|c| c.set(c.get() + 1)); | |
| 1950 | + hit!(COMP_GM_FILL_HITS); | |
| 1950 | 1951 | } |
| 1951 | 1952 | gm_mv_candidates[side] |
| 1952 | 1953 | }) |
| @@ -2006,7 +2007,7 @@ pub fn find_mv_stack_compound( | ||
| 2006 | 2007 | // `None` for the cells outside the tile. |
| 2007 | 2008 | let (tile_row0, tile_col0) = grid.tile_origin(); |
| 2008 | 2009 | if tile_row0 > 0 || tile_col0 > 0 { |
| 2009 | - TILE_REACH_CLIPS.with(|c| c.set(c.get() + 1)); | |
| 2010 | + hit!(TILE_REACH_CLIPS); | |
| 2010 | 2011 | } |
| 2011 | 2012 | let max_row_offset: isize = if mi_row > tile_row0 { |
| 2012 | 2013 | let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj); |
| @@ -2171,7 +2172,7 @@ pub fn find_mv_stack_compound( | ||
| 2171 | 2172 | } |
| 2172 | 2173 | } |
| 2173 | 2174 | if any_hit { |
| 2174 | - TMV_HITS.with(|c| c.set(c.get() + 1)); | |
| 2175 | + hit!(TMV_HITS); | |
| 2175 | 2176 | } |
| 2176 | 2177 | zero_mv_ctx = usize::from(first_sample_missing || first_sample_far); |
| 2177 | 2178 | } |
crates/ec-av1/src/restoration.rsmodified+8 -7
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | //! `av1_loop_restoration_corners_in_sb`, restoration.c:1277) and spec 7.17's |
| 4 | 4 | //! two pixel filters (Wiener, self-guided/SGR). See `lanes/lr.report.md` for |
| 5 | 5 | //! the full derivation (libaom `decodeframe.c`/`restoration.c` line refs). |
| 6 | +use crate::hits::hit; | |
| 6 | 7 | |
| 7 | 8 | use crate::msac::SymbolDecoder; |
| 8 | 9 | use ec_av1_syntax::obu::floor_log2; |
| @@ -426,23 +427,23 @@ fn read_lr_unit( | ||
| 426 | 427 | ) -> UnitFilter { |
| 427 | 428 | match ftype { |
| 428 | 429 | RestorationType::Switchable => { |
| 429 | - SWITCHABLE_HITS.with(|c| c.set(c.get() + 1)); | |
| 430 | + hit!(SWITCHABLE_HITS); | |
| 430 | 431 | let t = dec.symbol(&mut cdfs.restore_switchable); |
| 431 | 432 | match t { |
| 432 | 433 | 0 => UnitFilter::None, |
| 433 | 434 | 1 => { |
| 434 | - WIENER_HITS.with(|c| c.set(c.get() + 1)); | |
| 435 | + hit!(WIENER_HITS); | |
| 435 | 436 | UnitFilter::Wiener(read_wiener_filter(dec, chroma, &mut reference.0)) |
| 436 | 437 | } |
| 437 | 438 | _ => { |
| 438 | - SGRPROJ_HITS.with(|c| c.set(c.get() + 1)); | |
| 439 | + hit!(SGRPROJ_HITS); | |
| 439 | 440 | UnitFilter::Sgrproj(read_sgrproj_filter(dec, &mut reference.1)) |
| 440 | 441 | } |
| 441 | 442 | } |
| 442 | 443 | } |
| 443 | 444 | RestorationType::Wiener => { |
| 444 | 445 | if dec.symbol(&mut cdfs.restore_wiener) != 0 { |
| 445 | - WIENER_HITS.with(|c| c.set(c.get() + 1)); | |
| 446 | + hit!(WIENER_HITS); | |
| 446 | 447 | UnitFilter::Wiener(read_wiener_filter(dec, chroma, &mut reference.0)) |
| 447 | 448 | } else { |
| 448 | 449 | UnitFilter::None |
| @@ -451,7 +452,7 @@ fn read_lr_unit( | ||
| 451 | 452 | RestorationType::Sgrproj => { |
| 452 | 453 | let bit = dec.symbol(&mut cdfs.restore_sgrproj); |
| 453 | 454 | if bit != 0 { |
| 454 | - SGRPROJ_HITS.with(|c| c.set(c.get() + 1)); | |
| 455 | + hit!(SGRPROJ_HITS); | |
| 455 | 456 | UnitFilter::Sgrproj(read_sgrproj_filter(dec, &mut reference.1)) |
| 456 | 457 | } else { |
| 457 | 458 | UnitFilter::None |
| @@ -1191,10 +1192,10 @@ fn filter_restoration_unit( | ||
| 1191 | 1192 | let stripe_v_end = stripe_v_start + h; |
| 1192 | 1193 | if !matches!(filter, UnitFilter::None) { |
| 1193 | 1194 | if stripe_v_start == 0 { |
| 1194 | - LR_STRIPE0_HITS.with(|c| c.set(c.get() + 1)); | |
| 1195 | + hit!(LR_STRIPE0_HITS); | |
| 1195 | 1196 | } |
| 1196 | 1197 | if stripe_v_end == plane_h && h < nominal_h { |
| 1197 | - LR_LAST_STRIPE_HITS.with(|c| c.set(c.get() + 1)); | |
| 1198 | + hit!(LR_LAST_STRIPE_HITS); | |
| 1198 | 1199 | } |
| 1199 | 1200 | } |
| 1200 | 1201 | match filter { |
crates/ec-av1/src/superres.rsmodified+2 -1
| @@ -10,6 +10,7 @@ | ||
| 10 | 10 | //! Every constant and the 64x8 `av1_resize_filter_normative` coefficient |
| 11 | 11 | //! table below is copied verbatim from libaom `aom_dsp/aom_filter.h` and |
| 12 | 12 | //! `av1/common/resize.c` (`AOM_VERSION=v3.13.3`, `~/.cache/aom-oracle`). |
| 13 | +use crate::hits::hit; | |
| 13 | 14 | |
| 14 | 15 | /// `RS_SUBPEL_BITS`. |
| 15 | 16 | const RS_SUBPEL_BITS: u32 = 6; |
| @@ -184,7 +185,7 @@ pub(crate) fn superres_hits() -> usize { | ||
| 184 | 185 | |
| 185 | 186 | /// Counts one whole upscaled picture (all three planes) for [`SUPERRES_HITS`]. |
| 186 | 187 | pub(crate) fn note_upscaled_picture() { |
| 187 | - SUPERRES_HITS.with(|c| c.set(c.get() + 1)); | |
| 188 | + hit!(SUPERRES_HITS); | |
| 188 | 189 | } |
| 189 | 190 | |
| 190 | 191 | #[cfg(test)] |