forge
Explore
Log in

Don't you dare go Hollow

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 commit

e548d52e49ef9105439fb68fb882d4bb83c792efAhmet Kaan GümüşParent: b3aab1806bf080
crates/ec-av1/Cargo.tomlmodified+8 -0
@@ -9,3 +9,11 @@ authors.workspace = true
99 [dependencies]
1010 ec-core.workspace = true
1111 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() {
2929 }
3030 };
3131 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+ }
3237 let (sc, dp) = ec_av1::decode::reelc_chroma_counters();
3338 println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}");
3439 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 @@
2020 //! inside one, forcing the gathered-CDF partial-superblock path, is round 2
2121 //! too). Anything outside that refuses with [`Error::unsupported`] rather than
2222 //! silently miscoding.
23+use crate::hits::{hit, hit_do};
2324
2425 use ec_av1_syntax::{
2526 CdefParams, DeltaParams, LoopFilterParams, LoopRestorationParams,
@@ -526,7 +527,7 @@ fn warp_plane_allowed(w: usize, h: usize) -> bool {
526527 if w >= 8 && h >= 8 {
527528 return true;
528529 }
529- WARP_PLANE_SUPPRESS_HITS.with(|c| c.set(c.get() + 1));
530+ hit!(WARP_PLANE_SUPPRESS_HITS);
530531 false
531532 }
532533
@@ -638,7 +639,7 @@ fn maybe_read_delta_q(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_
638639 }
639640 let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true };
640641 let reduced = if sign_negative { -abs } else { abs };
641- DELTA_Q_HITS.with(|c| c.set(c.get() + 1));
642+ hit!(DELTA_Q_HITS);
642643 let res = fctx.delta_q_res.with(|c| c.get());
643644 fctx.current_q_idx.with(|c| c.set((c.get() + reduced * res).clamp(1, 255)));
644645 }
@@ -702,7 +703,7 @@ fn maybe_read_delta_lf(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi
702703 let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true };
703704 let reduced = if sign_negative { -abs } else { abs };
704705 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);
706707 }
707708 fctx.current_delta_lf.with(|c| c.set(cur));
708709 }
@@ -720,7 +721,7 @@ fn maybe_read_cdef_idx(dec: &mut SymbolDecoder, mi_r: usize, mi_c: usize, skip:
720721 }
721722 let idx = dec.literal(u32::from(bits)) as u8;
722723 fctx.cdef_transmitted.with(|c| c.set(true));
723- CDEF_IDX_HITS.with(|c| c.set(c.get() + 1));
724+ hit!(CDEF_IDX_HITS);
724725 let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize);
725726 let sb_cols = fctx.cdef_sb_cols.with(|c| c.get());
726727 if sb_cols > 0 {
@@ -951,7 +952,7 @@ fn read_segment_id(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_c:
951952 return pred as u8;
952953 }
953954 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);
955956 let last_active = fctx.seg.with(|s| i32::from(s.borrow().last_active_seg_id));
956957 neg_deinterleave(coded, pred, last_active + 1).clamp(0, last_active) as u8
957958 }
@@ -1024,7 +1025,7 @@ fn inter_segment_id(
10241025 let id = if temporal_update {
10251026 let ctx = seg_pred_ctx(mi_r, mi_c, fctx);
10261027 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);
10281029 stamp_seg_pred(mi_r, mi_c, w_mi, h_mi, u8::from(predicted), fctx);
10291030 if predicted {
10301031 predicted_segment_id(mi_r, mi_c, w_mi, h_mi, fctx)
@@ -1130,7 +1131,7 @@ fn tu_reach(
11301131 let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, block);
11311132 let standalone = Reach::of(tx, px + col_off, py + row_off, width, height, fctx);
11321133 if fixed != standalone {
1133- SPLIT_TU_REACH_FIX_HITS.with(|c| c.set(c.get() + 1));
1134+ hit!(SPLIT_TU_REACH_FIX_HITS);
11341135 }
11351136 fixed
11361137 }
@@ -1252,7 +1253,7 @@ pub(crate) fn fwd_kf_hits() -> usize {
12521253
12531254 /// Records one decoded forward keyframe (see [`FWD_KF_HITS`]).
12541255 pub(crate) fn note_fwd_kf() {
1255- FWD_KF_HITS.with(|c| c.set(c.get() + 1));
1256+ hit!(FWD_KF_HITS);
12561257 }
12571258
12581259 // 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] {
14591460 }
14601461
14611462 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+ }
14671470 }
14681471
14691472 // How many `partition_w16` reads resolved to a plain `PARTITION_HORZ`/
@@ -1511,11 +1514,13 @@ thread_local! {
15111514
15121515 /// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`].
15131516 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+ }
15191524 }
15201525
15211526 // lane-edgeboth r1: how many partition nodes were coded as the BOTH-AXES-CUT
@@ -1529,11 +1534,13 @@ thread_local! {
15291534 }
15301535
15311536 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+ }
15371544 }
15381545
15391546 /// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`).
@@ -3477,7 +3484,7 @@ pub fn fimv_frame_hits() -> usize {
34773484 /// Bump [`FIMV_FRAME_HITS`] -- called once per decoded frame header whose
34783485 /// `force_integer_mv` bit is set.
34793486 pub fn note_force_integer_mv_frame() {
3480- FIMV_FRAME_HITS.with(|c| c.set(c.get() + 1));
3487+ hit!(FIMV_FRAME_HITS);
34813488 }
34823489
34833490 /// Current value of [`OBMC_HITS`].
@@ -4308,11 +4315,13 @@ pub(crate) fn reset_edge_part_hits() {
43084315 }
43094316
43104317 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+ }
43164325 }
43174326
43184327 #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
@@ -4352,11 +4361,13 @@ fn bump_edge32_bit(base: usize, bit: usize) -> usize {
43524361 }
43534362
43544363 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+ }
43604371 }
43614372
43624373 // lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/
@@ -4576,11 +4587,13 @@ pub(crate) struct InterStripChroma {
45764587 /// last -- read by the next 1:4 strip to build its pair's chroma.
45774588
45784589 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+ }
45844597 }
45854598
45864599 // 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 {
51055118
51065119 fn note_sub8_chroma_tx(first_sub: TxType, chroma_ref: TxType, coeffs: bool) {
51075120 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);
51095122 }
51105123 }
51115124
@@ -5183,7 +5196,7 @@ pub(crate) fn chroma_eob_class1_hits() -> usize {
51835196 /// `tx_type` put this block's `eob_pt` on the class-1 row.
51845197 fn note_chroma_class1(plane_idx: usize, tx_type: TxType) {
51855198 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);
51875200 }
51885201 }
51895202
@@ -5974,8 +5987,8 @@ fn read_coeffs(
59745987
59755988 let class = TxClass::of(tx_type);
59765989 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);
59795992 }
59805993 let eob = read_eob(dec, coding, class);
59815994 if trace {
@@ -6158,7 +6171,7 @@ fn read_coeffs_rect(
61586171 return Ok((Grid::Zero(w * h), TxType::DctDct));
61596172 }
61606173 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);
61626175 // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is
61636176 // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including
61646177 // the `V_DCT`/`H_DCT` members whose 1D tx class needs its own scan and
@@ -6177,7 +6190,7 @@ fn read_coeffs_rect(
61776190 }
61786191 let class = TxClass::of(tx_type);
61796192 if class != TxClass::TwoD {
6180- TX_CLASS1_HITS.with(|c| c.set(c.get() + 1));
6193+ hit!(TX_CLASS1_HITS);
61816194 }
61826195 let eob = read_eob(dec, coding, class);
61836196 if rect_trace {
@@ -7074,7 +7087,7 @@ impl Neighbours {
70747087 fn fill_skip_grid_rect(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize, skip: bool) {
70757088 let (mi_r, mi_c) = at_mi;
70767089 if skip && w_mi != h_mi {
7077- RECT_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1));
7090+ hit!(RECT_SKIP_BAND_HITS);
70787091 }
70797092 for rr in 0..h_mi {
70807093 let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c;
@@ -7623,7 +7636,7 @@ impl Neighbours {
76237636 if self.tile_row0_mi > 0 && !have_above && self.above_uv_mode[c] != DC_PRED
76247637 || self.tile_col0_mi > 0 && !have_left && self.left_uv_mode[r] != DC_PRED
76257638 {
7626- UV_TILE_EDGE_SUPPRESSED_HITS.with(|h| h.set(h.get() + 1));
7639+ hit!(UV_TILE_EDGE_SUPPRESSED_HITS);
76277640 }
76287641 // The mi grid is libaom's own read; the two maps below stay as the
76297642 // fallback for cells no block has written (see [`Self::uv_mode_grid`]).
@@ -7651,18 +7664,18 @@ impl Neighbours {
76517664 }) || have_left && cell(&self.uv_mode_grid, mi_r, mi_c - 1).is_some_and(|m| {
76527665 !matches!(self.uv_mode_row.get(mi_r), Some(&(col, cm)) if usize::from(col) == mi_c - 1 && usize::from(cm) == m)
76537666 }) {
7654- UV_MODE_GRID_OVERRIDE_HITS.with(|h| h.set(h.get() + 1));
7667+ hit!(UV_MODE_GRID_OVERRIDE_HITS);
76557668 }
76567669 // lane-cfl r1 counter: how often the mi-exact chroma neighbour differs
76577670 // from the coarse [`SUB`] slot -- i.e. how often a chroma edge would
76587671 // have been filtered at the wrong strength by the coarse map alone.
76597672 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);
76617674 }
76627675 if (is_smooth_mode(self.above_uv_mode[c]) && !is_smooth_mode(above))
76637676 || (is_smooth_mode(self.left_uv_mode[r]) && !is_smooth_mode(left))
76647677 {
7665- INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|h| h.set(h.get() + 1));
7678+ hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS);
76667679 }
76677680 is_smooth_mode(above) || is_smooth_mode(left)
76687681 }
@@ -7717,19 +7730,19 @@ impl Neighbours {
77177730 let (above, left) =
77187731 self.modes_above_left_mi(mi_r, mi_c, (self.above_mode[c], self.left_mode[r]));
77197732 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);
77217734 }
77227735 if (is_smooth_mode(self.above_mode[c]) && !is_smooth_mode(above))
77237736 || (is_smooth_mode(self.left_mode[r]) && !is_smooth_mode(left))
77247737 {
7725- INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|h| h.set(h.get() + 1));
7738+ hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS);
77267739 }
77277740 // A neighbour the coarse band offered where the tile edge makes it
77287741 // unavailable -- must never happen (see `MODE_TILE_EDGE_COARSE_LEAKS`).
77297742 if (mi_r <= self.tile_row0_mi && self.above_mode[c] != DC_PRED)
77307743 || (mi_c <= self.tile_col0_mi && self.left_mode[r] != DC_PRED)
77317744 {
7732- MODE_TILE_EDGE_COARSE_LEAKS.with(|h| h.set(h.get() + 1));
7745+ hit!(MODE_TILE_EDGE_COARSE_LEAKS);
77337746 }
77347747 (above, left)
77357748 }
@@ -8508,7 +8521,7 @@ fn read_intra_mode_rect(
85088521 // offer the 14-symbol CFL alphabet on a 64-axis block (class
85098522 // wrong-alphabet-same-value: same value, wrong interval, silent desync).
85108523 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);
85128525 false
85138526 } else {
85148527 cfl
@@ -8550,10 +8563,10 @@ fn read_intra_mode_rect(
85508563 // refused by name when it fires.
85518564 if allow_intrabc_frame(fctx) {
85528565 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);
85548567 istep!("intrabc", use_intrabc as i32);
85558568 if use_intrabc {
8556- INTRABC_HITS.with(|c| c.set(c.get() + 1));
8569+ hit!(INTRABC_HITS);
85578570 return Err(unsupported(
85588571 "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)",
85598572 ));
@@ -8600,17 +8613,17 @@ fn read_intra_mode_rect(
86008613 None
86018614 };
86028615 if has_chroma && (9..=12).contains(&uv_mode) {
8603- SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
8616+ hit!(SMOOTH_UV_HITS);
86048617 }
86058618 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);
86078620 read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
86088621 } else {
86098622 0
86108623 };
86118624 istep!("angle_uv", angle_delta_uv);
86128625 if angle_delta_uv != 0 {
8613- UV_ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1));
8626+ hit!(UV_ANGLE_DELTA_HITS);
86148627 }
86158628 // `read_palette_mode_info` (spec 5.11.13), rect-generalised
86168629 // (lane-palette2 r4): same bsize-ctx-gated read as [`read_intra_mode`],
@@ -8627,7 +8640,7 @@ fn read_intra_mode_rect(
86278640 // r6: this is the exact site the removed blanket refusal used to
86288641 // guard -- reached for EVERY rect strip in a screen-content frame,
86298642 // 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);
86318644 let (mode_ctx, cache) = palette.unwrap_or((0, &[]));
86328645 let use_palette_y =
86338646 mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][mode_ctx]) != 0;
@@ -8670,7 +8683,7 @@ fn read_intra_mode_rect(
86708683 }
86718684 istep!("use_filter_intra", use_filter_intra as i32);
86728685 if use_filter_intra {
8673- FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));
8686+ hit!(FILTER_INTRA_HITS);
86748687 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);
86758688 istep!("filter_intra_mode", fi_mode as i32);
86768689 filter_intra = Some(fi_mode);
@@ -8680,8 +8693,8 @@ fn read_intra_mode_rect(
86808693 // same order as [`read_intra_mode`]'s own square path.
86818694 let palette_y = palette_y_pending.map(|(n, colors)| {
86828695 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);
86858698 PaletteY { size: n, colors, map }
86868699 });
86878700 let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| {
@@ -8692,7 +8705,7 @@ fn read_intra_mode_rect(
86928705 // chroma palette and desynced the tile from there.
86938706 let (cw, ch) = ((bw / 2).max(4), (bh / 2).max(4));
86948707 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);
86968709 PaletteUv { size: n, u_colors, v_colors, map }
86978710 });
86988711 Ok((
@@ -8945,11 +8958,13 @@ fn decode_rect_split(
89458958 (4, 8) => Some(3),
89468959 _ => None,
89478960 } {
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+ }
89538968 }
89548969 if chroma.is_none() {
89558970 // Diagnostic for the next caller that lands here (class
@@ -8970,9 +8985,9 @@ fn decode_rect_split(
89708985 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
89718986 ));
89728987 }
8973- RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
8988+ hit!(RECT_SPLIT_TX_HITS);
89748989 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);
89768991 }
89778992 // LUMA: `bw/tx` x `bh/tx` square transform units, raster order.
89788993 // A square unit reads through the ordinary square [`read_plane`]; a rect
@@ -9099,11 +9114,13 @@ fn decode_rect_split(
90999114 if crate::envflags::env_flag!("EC_RECT64TU") {
91009115 eprintln!("EC_RECT64TU mi={tu_mi:?} tx={tx_w}x{tx_h} mode={}", m.mode);
91019116 }
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+ }
91079124 let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0];
91089125 let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra));
91099126 let (corner, tu_tx_type) = read_coeffs(
@@ -9283,7 +9300,7 @@ fn decode_rect_split(
92839300 // superblock strips onto this path, so only counting there would
92849301 // leave the delta_q gate's counter silent for them).
92859302 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);
92879304 }
92889305 let residual = dequant_and_inverse_typed_wh(
92899306 &levels,
@@ -9631,12 +9648,14 @@ fn decode_intra_rect_in_inter(
96319648 mi_r * MI
96329649 );
96339650 }
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+ }
96409659 return Ok(());
96419660 }
96429661 // lane-inter128intra r1: the 128 superblock's PARTITION_HORZ/VERT half
@@ -9783,11 +9802,13 @@ fn decode_intra_rect_in_inter(
97839802 (32, 8) => 2,
97849803 _ => 3,
97859804 };
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+ }
97919812 return Ok(());
97929813 }
97939814 let mode = dec.symbol(&mut cdfs.y_mode[size_group]);
@@ -9815,7 +9836,7 @@ fn decode_intra_rect_in_inter(
98159836 0
98169837 };
98179838 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);
98199840 }
98209841 // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the
98219842 // superblock-level strip reads the no-CFL alphabet -- the same split
@@ -9834,7 +9855,7 @@ fn decode_intra_rect_in_inter(
98349855 );
98359856 }
98369857 if (9..=12).contains(&uv_mode) {
9837- SMOOTH_UV_HITS.with(|h| h.set(h.get() + 1));
9858+ hit!(SMOOTH_UV_HITS);
98389859 }
98399860 let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED {
98409861 Some(read_cfl_alphas(dec, cdfs))
@@ -9847,14 +9868,14 @@ fn decode_intra_rect_in_inter(
98479868 uv_mode
98489869 };
98499870 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);
98519872 read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
98529873 } else {
98539874 0
98549875 };
98559876 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);
98589879 }
98599880 // `read_palette_mode_info` (spec 5.11.13), in the position
98609881 // `read_intra_block_mode_info` writes it: after the chroma mode and
@@ -9873,7 +9894,7 @@ fn decode_intra_rect_in_inter(
98739894 if allow_screen_content_tools
98749895 && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh)
98759896 {
9876- INTRA_RECT_IN_INTER_SCREEN_HITS.with(|c| c.set(c.get() + 1));
9897+ hit!(INTRA_RECT_IN_INTER_SCREEN_HITS);
98779898 let use_palette_y =
98789899 mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0;
98799900 if use_palette_y {
@@ -9907,23 +9928,23 @@ fn decode_intra_rect_in_inter(
99079928 && let Some(class) = filter_intra_size_class_rect(bw, bh)
99089929 && dec.symbol(&mut cdfs.filter_intra[class]) != 0
99099930 {
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);
99129933 filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode));
99139934 }
99149935 // `av1_visit_palette`: Y's colour-index map then the shared chroma one.
99159936 let palette_y = palette_y_pending.map(|(n, colors)| {
99169937 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);
99209941 PaletteY { size: n, colors, map }
99219942 });
99229943 let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| {
99239944 let (cw, ch) = ((bw / 2).max(4), (bh / 2).max(4));
99249945 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);
99279948 PaletteUv { size: n, u_colors, v_colors, map }
99289949 });
99299950 // The intra-edge filter type is the NEIGHBOUR's mode (libaom
@@ -9938,11 +9959,11 @@ fn decode_intra_rect_in_inter(
99389959 let coarse_pair = neighbours.modes_above_left(r, c);
99399960 let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left_mi(mi_r, mi_c, coarse_pair);
99409961 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);
99429963 }
99439964 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
99449965 if smooth_neighbor {
9945- SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1));
9966+ hit!(SMOOTH_LUMA_HITS);
99469967 }
99479968 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c);
99489969 let depth = if fctx.tx_select_inter.with(std::cell::Cell::get) {
@@ -9965,15 +9986,17 @@ fn decode_intra_rect_in_inter(
99659986 0
99669987 };
99679988 if depth != 0 {
9968- TX_DEPTH_HITS.with(|h| h.set(h.get() + 1));
9989+ hit!(TX_DEPTH_HITS);
99699990 // lane-intrasplit r1: a split intra strip in an inter frame walks the
99709991 // key frame's own per-TU path ([`decode_rect_split`] below); what was
99719992 // 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+ }
997710000 }
997810001 // lane-intrasplit r3: print EVERY intra strip with its depth, not only the
997910002 // 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(
1006110084 32 => 1,
1006210085 _ => 2,
1006310086 };
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+ }
1006910094 Ok(())
1007010095 }
1007110096
@@ -10121,7 +10146,7 @@ fn decode_block_rect(
1012110146 )?;
1012210147 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
1012310148 if smooth_neighbor {
10124- SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
10149+ hit!(SMOOTH_LUMA_HITS);
1012510150 }
1012610151 // lane-chroma r3: chroma's own edge-filter-strength neighbour check
1012710152 // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's
@@ -10134,7 +10159,7 @@ fn decode_block_rect(
1013410159 // predicts instead of refusing. The below-16x16 leaf arm
1013510160 // (`decode_leaf_rect`) keeps the refusal: it has no gate of its own.
1013610161 if filter_intra.is_some() {
10137- FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
10162+ hit!(FILTER_INTRA_RECT_HITS);
1013810163 }
1013910164 let uv_predict_mode = if uv_mode == UV_CFL_PRED {
1014010165 DC_PRED
@@ -10174,7 +10199,7 @@ fn decode_block_rect(
1017410199 0
1017510200 };
1017610201 if depth != 0 {
10177- TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
10202+ hit!(TX_DEPTH_HITS);
1017810203 // lane-rectsplit r1: a split transform is predicted and reconstructed
1017910204 // per transform unit, each unit taking its edges from the previous
1018010205 // unit's reconstruction inside this same strip (spec 5.11.36) --
@@ -10208,7 +10233,7 @@ fn decode_block_rect(
1020810233 }),
1020910234 };
1021010235 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);
1021210237 }
1021310238 decode_rect_split(
1021410239 dec,
@@ -10238,7 +10263,7 @@ fn decode_block_rect(
1023810263 let (puv_size, puv_colors) =
1023910264 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
1024010265 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);
1024210267 return Ok(());
1024310268 }
1024410269 let (tx_w, tx_h) = (bw, bh);
@@ -10498,7 +10523,7 @@ fn decode_block_rect(
1049810523 smooth_neighbor_uv, fctx,
1049910524 );
1050010525 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);
1050210527 }
1050310528 }
1050410529 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(
1050810533 neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors);
1050910534 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);
1051010535 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);
1051210537 if crate::envflags::env_flag!("EC_AV1_TRACE") {
1051310538 eprintln!("TRACE_RECT32_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh}");
1051410539 }
@@ -10583,7 +10608,7 @@ fn decode_leaf_rect(
1058310608 let smooth_neighbor =
1058410609 is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
1058510610 if smooth_neighbor {
10586- SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
10611+ hit!(SMOOTH_LUMA_HITS);
1058710612 }
1058810613 // The palette-Y mode CDF row is picked by the neighbours' palette use
1058910614 // (`palette_ctx_and_cache`), so this sub-16x16 leaf must pass its own real
@@ -10620,7 +10645,7 @@ fn decode_leaf_rect(
1062010645 // map -> base colours buffer [`decode_block_rect`] hands each
1062110646 // `reconstruct_rect` through [`set_palette_pred`].
1062210647 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);
1062410649 }
1062510650 let palette_y_buf: Option<Vec<u16>> = palette_y
1062610651 .as_ref()
@@ -10643,8 +10668,8 @@ fn decode_leaf_rect(
1064310668 // patches over a true `bw`x`bh` block (lane-rectsplit r1), so an
1064410669 // 8x16/16x8 strip predicts through the same call `reconstruct_rect`
1064510670 // 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);
1064810673 }
1064910674 let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
1065010675 // lane-cfl r1, same defect as [`decode_leaf_8x8`]: chroma's intra-edge
@@ -10683,8 +10708,8 @@ fn decode_leaf_rect(
1068310708 // The same per-transform-unit walk the bigger strips take
1068410709 // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at
1068510710 // 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);
1068810713 let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
1068910714 let modes = RectStripModes {
1069010715 skip,
@@ -10703,7 +10728,7 @@ fn decode_leaf_rect(
1070310728 palette_uv: palette_uv_bufs.clone(),
1070410729 };
1070510730 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);
1070710732 }
1070810733 decode_rect_split(
1070910734 dec,
@@ -10834,7 +10859,7 @@ fn decode_leaf_rect(
1083410859 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual,
1083510860 alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx,
1083610861 );
10837- RECT_LEAF_COEFF_HITS.with(|c| c.set(c.get() + 1));
10862+ hit!(RECT_LEAF_COEFF_HITS);
1083810863 }
1083910864 neighbours.record_mi_rect(leaf_mi, bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);
1084010865 neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip);
@@ -10950,7 +10975,7 @@ fn decode_block_rect4(
1095010975 // mapped through the base colours IS the prediction (it reads no edge
1095110976 // pixels), handed to each `reconstruct_rect` through [`set_palette_pred`].
1095210977 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);
1095410979 }
1095510980 let palette_y_buf: Option<Vec<u16>> = palette_y
1095610981 .as_ref()
@@ -10967,7 +10992,7 @@ fn decode_block_rect4(
1096710992 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
1096810993 let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
1096910994 if smooth_neighbor {
10970- SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
10995+ hit!(SMOOTH_LUMA_HITS);
1097110996 }
1097210997 // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's
1097310998 // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so
@@ -10977,11 +11002,11 @@ fn decode_block_rect4(
1097711002 // with luma bit-exact).
1097811003 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c);
1097911004 if filter_intra.is_some() {
10980- FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
11005+ hit!(FILTER_INTRA_RECT_HITS);
1098111006 if bw > bh {
10982- FILTER_INTRA_RECT4_HORZ_HITS.with(|c| c.set(c.get() + 1));
11007+ hit!(FILTER_INTRA_RECT4_HORZ_HITS);
1098311008 } else {
10984- FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.set(c.get() + 1));
11009+ hit!(FILTER_INTRA_RECT4_VERT_HITS);
1098511010 }
1098611011 }
1098711012 let uv_predict_mode = if uv_mode == UV_CFL_PRED {
@@ -11027,7 +11052,7 @@ fn decode_block_rect4(
1102711052 // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16
1102811053 // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8;
1102911054 // both interleave in every real stream.
11030- TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
11055+ hit!(TX_DEPTH_HITS);
1103111056 let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
1103211057 // lane-rectsplitx r2: both depths ship together, as the r1 handoff
1103311058 // predicted -- depth 1 fires FIRST in every attempt that splits at
@@ -11039,7 +11064,7 @@ fn decode_block_rect4(
1103911064 } else {
1104011065 &RECT4_SPLIT_DEPTH2_HITS
1104111066 };
11042- which.with(|c| c.set(c.get() + 1));
11067+ hit_do! { which.with(|c| c.set(c.get() + 1)); }
1104311068 let modes = RectStripModes {
1104411069 skip,
1104511070 mode,
@@ -11054,7 +11079,7 @@ fn decode_block_rect4(
1105411079 palette_uv: palette_uv_bufs.clone(),
1105511080 };
1105611081 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);
1105811083 }
1105911084 decode_rect_split(
1106011085 dec,
@@ -11077,12 +11102,12 @@ fn decode_block_rect4(
1107711102 pal_uv_colors,
1107811103 );
1107911104 if bw > bh {
11080- RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
11105+ hit!(RECT4_32_HORZ_HITS);
1108111106 } else {
11082- RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1));
11107+ hit!(RECT4_32_VERT_HITS);
1108311108 }
1108411109 if !skip {
11085- RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1));
11110+ hit!(RECT4_COEFF_HITS);
1108611111 }
1108711112 // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm,
1108811113 // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter
@@ -11163,7 +11188,7 @@ fn decode_block_rect4(
1116311188 }
1116411189 let (v_levels, v_tx_type) = planes.pop().expect("plane 2");
1116511190 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);
1116711192 let luma_residual = dequant_and_inverse_typed_wh(
1116811193 &luma_levels,
1116911194 bw,
@@ -11237,9 +11262,9 @@ fn decode_block_rect4(
1123711262 pal_uv_colors,
1123811263 );
1123911264 if bw > bh {
11240- RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
11265+ hit!(RECT4_32_HORZ_HITS);
1124111266 } else {
11242- RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1));
11267+ hit!(RECT4_32_VERT_HITS);
1124311268 }
1124411269 // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm,
1124511270 // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter
@@ -11306,9 +11331,9 @@ fn decode_block_rect4(
1130611331 neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors,
1130711332 );
1130811333 if bw > bh {
11309- RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1));
11334+ hit!(RECT4_32_HORZ_HITS);
1131011335 } else {
11311- RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1));
11336+ hit!(RECT4_32_VERT_HITS);
1131211337 }
1131311338 // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm,
1131411339 // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter
@@ -11490,7 +11515,7 @@ fn decode_rect4_16_strip(
1149011515 lmi.1, fctx,
1149111516 )?;
1149211517 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);
1149411519 }
1149511520 // The colour-index map through the base colours IS the prediction.
1149611521 // Chroma's map is the PAIR's 8x4 (4x8) block, matching the one
@@ -11506,10 +11531,10 @@ fn decode_rect4_16_strip(
1150611531 });
1150711532 let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
1150811533 if smooth_neighbor {
11509- SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1));
11534+ hit!(SMOOTH_LUMA_HITS);
1151011535 }
1151111536 if filter_intra.is_some() {
11512- FILTER_INTRA_RECT_HITS.with(|h| h.set(h.get() + 1));
11537+ hit!(FILTER_INTRA_RECT_HITS);
1151311538 }
1151411539 // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is
1151511540 // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the
@@ -11540,8 +11565,8 @@ fn decode_rect4_16_strip(
1154011565 0
1154111566 };
1154211567 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);
1154511570 }
1154611571 let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
1154711572 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
@@ -11623,7 +11648,7 @@ fn decode_rect4_16_strip(
1162311648 None, filter_intra, smooth_neighbor, fctx,
1162411649 );
1162511650 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);
1162711652 }
1162811653 neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid);
1162911654 } else {
@@ -11652,7 +11677,7 @@ fn decode_rect4_16_strip(
1165211677 smooth_neighbor, fctx,
1165311678 )?;
1165411679 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);
1165611681 }
1165711682 neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid);
1165811683 }
@@ -11707,7 +11732,7 @@ fn decode_rect4_16_strip(
1170711732 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
1170811733 smooth_neighbor, fctx,
1170911734 );
11710- RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1));
11735+ hit!(RECT4_16_COEFF_HITS);
1171111736 levels
1171211737 };
1171311738 neighbours.record_mi_luma_rect(lmi, bw, bh, &levels);
@@ -11728,7 +11753,7 @@ fn decode_rect4_16_strip(
1172811753 }
1172911754 }
1173011755 if has_chroma {
11731- RECT4_16_CHROMA_HITS.with(|h| h.set(h.get() + 1));
11756+ hit!(RECT4_16_CHROMA_HITS);
1173211757 let pair_mi = if horz {
1173311758 (lmi.0 - 1, lmi.1)
1173411759 } else {
@@ -11740,7 +11765,7 @@ fn decode_rect4_16_strip(
1174011765 let (cw, ch) = (pw / 2, ph / 2);
1174111766 let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
1174211767 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);
1174411769 }
1174511770 let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height, fctx);
1174611771 // lane-kf1200 r1: the chroma edge-filter type reads the neighbours
@@ -11758,7 +11783,7 @@ fn decode_rect4_16_strip(
1175811783 neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c);
1175911784 if smooth_neighbor_uv != neighbours.smooth_uv_neighbour_unsnapped(lmi.0, lmi.1, r, c)
1176011785 {
11761- RECT4_16_UV_PAIR_FILT_HITS.with(|h| h.set(h.get() + 1));
11786+ hit!(RECT4_16_UV_PAIR_FILT_HITS);
1176211787 }
1176311788 let (u_levels, v_levels) = if skip {
1176411789 let zeros = Grid::Zero(cw * ch);
@@ -11769,7 +11794,7 @@ fn decode_rect4_16_strip(
1176911794 // chroma-only bounded box on ReelC's key frames.
1177011795 let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph));
1177111796 if alpha.is_some() {
11772- CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
11797+ hit!(CHROMA_SKIP_CFL_HITS);
1177311798 }
1177411799 for (_buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] {
1177511800 if let Some((ub, vb)) = &palette_uv_bufs {
@@ -11879,9 +11904,9 @@ fn decode_rect4_16_strip(
1187911904 last_uv_mode = Some(uv_predict_mode);
1188011905 }
1188111906 if horz {
11882- RECT4_16_HORZ_HITS.with(|h| h.set(h.get() + 1));
11907+ hit!(RECT4_16_HORZ_HITS);
1188311908 } else {
11884- RECT4_16_VERT_HITS.with(|h| h.set(h.get() + 1));
11909+ hit!(RECT4_16_VERT_HITS);
1188511910 }
1188611911 let (pal_y_size, pal_y_colors) =
1188711912 palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
@@ -11974,11 +11999,11 @@ fn decode_block_rect64(
1197411999 // -- counted so its gate cannot go vacuous (this was a refusal until
1197512000 // r34; see the gate `a_real_aomenc_palette_stream_with_8x8_leaves_
1197612001 // decodes_pixel_exact`).
11977- PALETTE_SB_STRIP_HITS.with(|c| c.set(c.get() + 1));
12002+ hit!(PALETTE_SB_STRIP_HITS);
1197812003 }
1197912004 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
1198012005 if smooth_neighbor {
11981- SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
12006+ hit!(SMOOTH_LUMA_HITS);
1198212007 }
1198312008 let smooth_neighbor_uv =
1198412009 neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c);
@@ -12038,7 +12063,7 @@ fn decode_block_rect64(
1203812063 (bw, bh), fctx,
1203912064 );
1204012065 if depth != 0 {
12041- TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
12066+ hit!(TX_DEPTH_HITS);
1204212067 // lane-rectsplit r1/r4: the superblock-level strip splits its
1204312068 // transform through the very same per-unit path as its 32x32-level
1204412069 // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64
@@ -12051,7 +12076,7 @@ fn decode_block_rect64(
1205112076 } else {
1205212077 &RECT4_SPLIT_DEPTH2_HITS
1205312078 };
12054- which.with(|c| c.set(c.get() + 1));
12079+ hit_do! { which.with(|c| c.set(c.get() + 1)); }
1205512080 }
1205612081 if crate::envflags::env_flag!("EC_SBPART_DUMP64") {
1205712082 eprintln!(
@@ -12081,7 +12106,7 @@ fn decode_block_rect64(
1208112106 }),
1208212107 };
1208312108 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);
1208512110 }
1208612111 decode_rect_split(
1208712112 dec,
@@ -12117,8 +12142,8 @@ fn decode_block_rect64(
1211712142 // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The
1211812143 // bands carry the SPLIT unit's size, not the block's.
1211912144 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);
1212212147 return Ok(());
1212312148 }
1212412149 let (tx_w, tx_h) = (bw, bh);
@@ -12257,7 +12282,7 @@ fn decode_block_rect64(
1225712282 {
1225812283 let cur = block_q_idx(fctx);
1225912284 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);
1226112286 }
1226212287 if crate::envflags::env_flag!("EC_AV1_TRACE") {
1226312288 eprintln!(
@@ -12340,7 +12365,7 @@ fn decode_block_rect64(
1234012365 {
1234112366 let cur = block_q_idx(fctx);
1234212367 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);
1234412369 }
1234512370 if crate::envflags::env_flag!("EC_AV1_TRACE") {
1234612371 eprintln!(
@@ -12404,7 +12429,7 @@ fn decode_block_rect64(
1240412429 {
1240512430 let cur = block_q_idx(fctx);
1240612431 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);
1240812433 }
1240912434 if crate::envflags::env_flag!("EC_AV1_TRACE") {
1241012435 eprintln!(
@@ -12439,7 +12464,7 @@ fn decode_block_rect64(
1243912464 smooth_neighbor_uv, fctx,
1244012465 );
1244112466 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);
1244312468 }
1244412469 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
1244512470 neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors);
@@ -12459,10 +12484,10 @@ fn decode_block_rect64(
1245912484 // 3840x1608 10-bit stream's first silent wall, decode-order frame 33 at
1246012485 // mi(16,480)). Same write as [`set_txfm_ctxs`], rect-aware.
1246112486 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);
1246312488 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),
1246612491 _ => {}
1246712492 }
1246812493 if crate::envflags::env_flag!("EC_AV1_TRACE") {
@@ -12479,7 +12504,7 @@ fn decode_block_rect64(
1247912504 fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 {
1248012505 let symbol = dec.symbol(cdf);
1248112506 if symbol != ANGLE_DELTA_ZERO {
12482- ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1));
12507+ hit!(ANGLE_DELTA_HITS);
1248312508 }
1248412509 symbol as i32 - ANGLE_DELTA_ZERO as i32
1248512510 }
@@ -12549,7 +12574,7 @@ fn read_intra_mode(
1254912574 // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single
1255012575 // point every square caller routes through (see `read_intra_mode_rect`).
1255112576 let cfl = if cfl && side > 32 {
12552- NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1));
12577+ hit!(NOCFL_UV_MODE_HITS);
1255312578 false
1255412579 } else {
1255512580 cfl
@@ -12599,7 +12624,7 @@ fn read_intra_mode(
1259912624 eprintln!("TRACE intrabc dv={dv:?}");
1260012625 }
1260112626 fctx.intrabc_dv.with(|c| c.set(Some(dv)));
12602- INTRABC_HITS.with(|c| c.set(c.get() + 1));
12627+ hit!(INTRABC_HITS);
1260312628 // spec 5.11.13 / libaom `read_intra_frame_mode_info` returns the
1260412629 // moment `is_intrabc_block`: no y/uv mode, angle delta, palette,
1260512630 // CFL or filter-intra syntax follows. `YMode`/`UVMode` are forced
@@ -12654,7 +12679,7 @@ fn read_intra_mode(
1265412679 // bug in that fallback this lane's own scope does not cover. Keep it
1265512680 // refused here rather than ship a silently-wrong decode.
1265612681 if (9..=12).contains(&uv_mode) {
12657- SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
12682+ hit!(SMOOTH_UV_HITS);
1265812683 }
1265912684 // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the
1266012685 // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads
@@ -12662,14 +12687,14 @@ fn read_intra_mode(
1266212687 // so a CFL block (uv_mode==13, outside `V_PRED..=D67_PRED`) already takes
1266312688 // the `else` branch below and never reads one either way.
1266412689 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);
1266612691 read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
1266712692 } else {
1266812693 0
1266912694 };
1267012695 istep!("angle_uv", angle_delta_uv);
1267112696 if angle_delta_uv != 0 {
12672- UV_ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1));
12697+ hit!(UV_ANGLE_DELTA_HITS);
1267312698 }
1267412699 // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called
1267512700 // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`):
@@ -12768,7 +12793,7 @@ fn read_intra_mode(
1276812793 }
1276912794 istep!("use_filter_intra", use_filter_intra as i32);
1277012795 if use_filter_intra {
12771- FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));
12796+ hit!(FILTER_INTRA_HITS);
1277212797 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);
1277312798 if trace {
1277412799 eprintln!("TRACE filter_intra_mode value={fi_mode}");
@@ -12781,7 +12806,7 @@ fn read_intra_mode(
1278112806 // shared U/V map) -- the same order libaom's own loop visits them in.
1278212807 let palette_y = palette_y_pending.map(|(n, colors)| {
1278312808 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);
1278512810 if trace {
1278612811 eprintln!("TRACE palette_y size={n} colors={:?}", &colors[..n]);
1278712812 }
@@ -12789,7 +12814,7 @@ fn read_intra_mode(
1278912814 });
1279012815 let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| {
1279112816 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);
1279312818 if trace {
1279412819 eprintln!(
1279512820 "TRACE palette_uv size={n} u_colors={:?} v_colors={:?}",
@@ -12824,7 +12849,7 @@ const UV_CFL_PRED: usize = 13;
1282412849 /// joint sign the same way. Returns each plane's final signed `alpha_q3`
1282512850 /// (`cfl_idx_to_alpha`, cfl.c): magnitude `idx + 1`, sign-zero collapsing to 0.
1282612851 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);
1282812853 let joint_sign = dec.symbol(&mut cdfs.cfl_sign) as i32;
1282912854 let sign_u = ((joint_sign + 1) * 11) >> 5;
1283012855 let sign_v = (joint_sign + 1) - 3 * sign_u;
@@ -13104,9 +13129,9 @@ impl PlaneBuf<'_> {
1310413129 let corner =
1310513130 (x > self.tile_x0 && y > self.tile_y0).then(|| self.data[(y - 1) * self.width + x - 1]);
1310613131 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);
1310813133 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);
1311013135 }
1311113136 }
1311213137 (above, left, corner)
@@ -13517,7 +13542,7 @@ fn decode_block(
1351713542 c * (SUB / MI), fctx,
1351813543 )?;
1351913544 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);
1352113546 }
1352213547 let intrabc_dv = fctx.intrabc_dv.with(|c| c.take());
1352313548 // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED`
@@ -13530,7 +13555,7 @@ fn decode_block(
1353013555 };
1353113556 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
1353213557 if smooth_neighbor {
13533- SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
13558+ hit!(SMOOTH_LUMA_HITS);
1353413559 }
1353513560 let smooth_neighbor_uv =
1353613561 neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c);
@@ -13580,7 +13605,7 @@ fn decode_block(
1358013605 );
1358113606 }
1358213607 }
13583- INTRABC_VARTX_HITS.with(|c| c.set(c.get() + 1));
13608+ hit!(INTRABC_VARTX_HITS);
1358413609 // The luma reconstruct loop below is a UNIFORM grid of one square
1358513610 // transform (the intra `tx_depth` shape), so a tree that resolved to
1358613611 // mixed leaf sizes is refused by name rather than reconstructed at the
@@ -13610,7 +13635,7 @@ fn decode_block(
1361013635 (side.min(64), luma_tx)
1361113636 };
1361213637 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);
1361413639 }
1361513640 let luma_set = if tx_select {
1361613641 txbset_for(logical_tx, reduced_tx_set)
@@ -13729,7 +13754,7 @@ fn decode_block(
1372913754 logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none();
1373013755 if split_tx_skip {
1373113756 if tx_select {
13732- SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
13757+ hit!(SKIP_SPLIT_TX_HITS);
1373313758 }
1373413759 let n_axis = side / logical_tx;
1373513760 for tu_row in 0..n_axis {
@@ -13992,7 +14017,7 @@ fn decode_block(
1399214017 // `get_txb_ctx_general`'s `plane_bsize != tx_size` branch).
1399314018 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, logical_tx / MI);
1399414019 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);
1399614021 let mut window = vec![0u16; logical_tx * logical_tx];
1399714022 for row in 0..logical_tx {
1399814023 let src = (tu_row * logical_tx + row) * side + tu_col * logical_tx;
@@ -14089,7 +14114,7 @@ fn decode_block(
1408914114 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,
1409014115 )?;
1409114116 if cn > 1 {
14092- CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
14117+ hit!(CHROMA_SPLIT_TX_HITS);
1409314118 // Immediately, so the NEXT unit of this same block reads
1409414119 // this one's coefficient context (libaom's chroma
1409514120 // `txb_skip_ctx` for the second quadrant is 11, i.e. base
@@ -14269,7 +14294,7 @@ fn decode_block_128rect(
1426914294 let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
1427014295 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
1427114296 if smooth_neighbor {
14272- SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
14297+ hit!(SMOOTH_LUMA_HITS);
1427314298 }
1427414299 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c);
1427514300 // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or
@@ -14290,13 +14315,15 @@ fn decode_block_128rect(
1429014315 0
1429114316 };
1429214317 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+ });
1429414326 }
14295- INTRA_SB128_DEPTH_HITS.with(|c| {
14296- let mut h = c.get();
14297- h[depth.min(2)] += 1;
14298- c.set(h);
14299- });
1430014327 let logical_tx = 64 >> depth;
1430114328 // A 64-point transform codes nothing past its low 32 coefficients.
1430214329 let coeff_tx_side = logical_tx.min(32);
@@ -14426,7 +14453,7 @@ fn decode_block_128rect(
1442614453 angle_delta_uv, cu_r, v, cu_x, cu_y, chroma_tx, chroma_tx, base_q_idx, None, None,
1442714454 Some(3), smooth_neighbor_uv, fctx,
1442814455 )?;
14429- CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
14456+ hit!(CHROMA_SPLIT_TX_HITS);
1443014457 // Immediately, so the NEXT unit of this same block reads this
1443114458 // one's coefficient context; replayed after `record_split_luma_rect`
1443214459 // below, which would otherwise clobber them whole-block.
@@ -14489,15 +14516,17 @@ fn decode_block_128rect(
1448914516 (logical_tx, logical_tx),
1449014517 (bw, bh),
1449114518 );
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+ }
1449714526 } else if bw > bh {
14498- INTRA_SB128_HORZ_HITS.with(|c| c.set(c.get() + 1));
14527+ hit!(INTRA_SB128_HORZ_HITS);
1449914528 } else {
14500- INTRA_SB128_VERT_HITS.with(|c| c.set(c.get() + 1));
14529+ hit!(INTRA_SB128_VERT_HITS);
1450114530 }
1450214531 Ok(())
1450314532 }
@@ -14589,7 +14618,7 @@ fn decode_leaf8(
1458914618 // that exact mi cell.
1459014619 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c);
1459114620 if smooth_neighbor {
14592- SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
14621+ hit!(SMOOTH_LUMA_HITS);
1459314622 }
1459414623 // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec
1459514624 // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other
@@ -14630,7 +14659,7 @@ fn decode_leaf8(
1463014659 // mirrors `decode_block`'s own intrabc handling at 16x16 and up.
1463114660 let intrabc_dv = fctx.intrabc_dv.with(|c| c.take());
1463214661 if intrabc_dv.is_some() {
14633- LEAF8_INTRABC_HITS.with(|c| c.set(c.get() + 1));
14662+ hit!(LEAF8_INTRABC_HITS);
1463414663 }
1463514664 // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour
1463614665 // index map, mapped through the base colours, IS the block's prediction --
@@ -14650,7 +14679,7 @@ fn decode_leaf8(
1465014679 let (pal_uv_size, pal_uv_colors) =
1465114680 palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
1465214681 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);
1465414683 }
1465514684 let uv_predict_mode = if uv_mode == UV_CFL_PRED {
1465614685 DC_PRED
@@ -14691,7 +14720,7 @@ fn decode_leaf8(
1469114720 0,
1469214721 &mut leaves,
1469314722 );
14694- INTRABC_VARTX_HITS.with(|c| c.set(c.get() + 1));
14723+ hit!(INTRABC_VARTX_HITS);
1469514724 leaves.first().map_or(8, |l| l.2)
1469614725 } else if tx_select && intrabc_dv.is_none() {
1469714726 read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, None)
@@ -14749,7 +14778,7 @@ fn decode_leaf8(
1474914778 // rule) -- so a palette leaf takes the single 8x8 reconstruct below
1475014779 // even when `tx_depth` resolved to TX_4X4.
1475114780 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);
1475314782 for tu_row in 0..2 {
1475414783 for tu_col in 0..2 {
1475514784 let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4);
@@ -14949,7 +14978,7 @@ fn decode_leaf8(
1494914978 let tu_py = py + tu_row * 4;
1495014979 let tu_around = neighbours.around_mi(tu_mi, 4)[0];
1495114980 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);
1495314982 }
1495414983 let tu_reach = tu_reach(
1495514984 8,
@@ -14969,7 +14998,7 @@ fn decode_leaf8(
1496914998 // 16x16 and up) -- the whole-block buffer would be taken by
1497014999 // the FIRST unit and indexed at the wrong stride.
1497115000 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);
1497315002 let mut window = vec![0u16; 16];
1497415003 for row in 0..4 {
1497515004 let src = (tu_row * 4 + row) * 8 + tu_col * 4;
@@ -15123,7 +15152,7 @@ fn decode_leaf8(
1512315152 neighbours.record_palette_y_rect(leaf_mi, 8, 8, pal_y_size, pal_y_colors);
1512415153 neighbours.record_palette_uv_rect(leaf_mi, 8, 8, pal_uv_size, pal_uv_colors);
1512515154 }
15126- INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1));
15155+ hit!(INTER8_SKIP_BAND_HITS);
1512715156 neighbours.fill_skip_grid(leaf_mi, 2, skip);
1512815157 // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal
1512915158 // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm &&
@@ -15213,7 +15242,7 @@ fn read_intra_mode_sub8(
1521315242 eprintln!("TRACE sub8 uv_mode value={uv_mode} rng={}", dec.debug_state().0);
1521415243 }
1521515244 if (9..=12).contains(&uv_mode) {
15216- SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
15245+ hit!(SMOOTH_UV_HITS);
1521715246 }
1521815247 let alpha = if uv_mode == UV_CFL_PRED {
1521915248 Some(read_cfl_alphas(dec, cdfs))
@@ -15221,7 +15250,7 @@ fn read_intra_mode_sub8(
1522115250 None
1522215251 };
1522315252 if (V_PRED..=D67_PRED).contains(&uv_mode) {
15224- DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1));
15253+ hit!(DIRECTIONAL_UV_HITS);
1522515254 }
1522615255 // See the luma comment above: no angle delta below 8x8.
1522715256 let angle_delta_uv = 0;
@@ -15236,7 +15265,7 @@ fn read_intra_mode_sub8(
1523615265 eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32);
1523715266 }
1523815267 if use_filter_intra {
15239- FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));
15268+ hit!(FILTER_INTRA_HITS);
1524015269 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);
1524115270 filter_intra = Some(fi_mode);
1524215271 }
@@ -15275,7 +15304,7 @@ fn decode_leaf_split4(
1527515304 // one a neighbour to its RIGHT sees (its top-right 4x4, mi(row, col-1))., fctx: &crate::decode::FrameCtx
1527615305 fctx: &crate::decode::FrameCtx,
1527715306 ) -> Result<(usize, usize)> {
15278- SUB8_SPLIT_HITS.with(|c| c.set(c.get() + 1));
15307+ hit!(SUB8_SPLIT_HITS);
1527915308 let (r, c) = outer_at;
1528015309 let mut above_mode = neighbours.above_mode[c];
1528115310 let mut left_mode = neighbours.left_mode[r];
@@ -15321,7 +15350,7 @@ fn decode_leaf_split4(
1532115350 neighbours.record_mode_mi(lmi.0, lmi.1, 1, 1, mode);
1532215351 let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left);
1532315352 if smooth_neighbor {
15324- SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
15353+ hit!(SMOOTH_LUMA_HITS);
1532515354 }
1532615355 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
1532715356 let reach = Reach::of(4, px, py, y.width, y.height, fctx);
@@ -15385,8 +15414,8 @@ fn decode_leaf_split4(
1538515414 // their gates goes vacuous.
1538615415 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
1538715416 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);
1539015419 }
1539115420 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);
1539215421 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(
1553515564 // same `reconstruct_rect`/`reconstruct` calls below -- and under
1553615565 // a split transform, per 4x4 unit with that unit's own edge,
1553715566 // 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);
1554015569 }
1554115570 // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4
1554215571 // leaf too, and is read for every intra block, skipped or not. Its
@@ -15561,15 +15590,15 @@ fn decode_leaf_rect8(
1556115590 0
1556215591 };
1556315592 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);
1556615595 }
1556715596 leaf_modes[i] = mode;
1556815597 leaf_skips[i] = skip;
1556915598 neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode);
1557015599 let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left);
1557115600 if smooth_neighbor {
15572- SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
15601+ hit!(SMOOTH_LUMA_HITS);
1557315602 }
1557415603 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
1557515604 let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx);
@@ -15653,9 +15682,9 @@ fn decode_leaf_rect8(
1565315682 }
1565415683 if done > 0 {
1565515684 if vert {
15656- TX4X8_CODED_HITS.with(|h| h.set(h.get() + 1));
15685+ hit!(TX4X8_CODED_HITS);
1565715686 } else {
15658- TX8X4_CODED_HITS.with(|h| h.set(h.get() + 1));
15687+ hit!(TX8X4_CODED_HITS);
1565915688 }
1566015689 }
1566115690 neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip);
@@ -15695,9 +15724,9 @@ fn decode_leaf_rect8(
1569515724 )?;
1569615725 if levels.iter().any(|&l| l != 0) {
1569715726 if vert {
15698- TX4X8_CODED_HITS.with(|h| h.set(h.get() + 1));
15727+ hit!(TX4X8_CODED_HITS);
1569915728 } else {
15700- TX8X4_CODED_HITS.with(|h| h.set(h.get() + 1));
15729+ hit!(TX8X4_CODED_HITS);
1570115730 }
1570215731 }
1570315732 let residual = dequant_and_inverse_typed_wh(
@@ -15757,8 +15786,8 @@ fn decode_leaf_rect8(
1575715786 // their gates goes vacuous.
1575815787 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
1575915788 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);
1576215791 }
1576315792 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);
1576415793 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(
1657616605 own_w: usize,
1657716606 own_h: usize, fctx: &crate::decode::FrameCtx,
1657816607 ) -> usize {
16579- INTRA_IN_INTER_TXCTX_HITS.with(|c| c.set(c.get() + 1));
16608+ hit!(INTRA_IN_INTER_TXCTX_HITS);
1658016609 let has_above = mi_r > n.tile_row0_mi;
1658116610 let has_left = mi_c > n.tile_col0_mi;
1658216611 let mut above = usize::from(n.above_txfm[mi_c]) >= own_w;
@@ -16616,7 +16645,7 @@ fn tx_size_context_txfm_rect(
1661616645 let stale = usize::from(has_above && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= cw)
1661716646 + usize::from(has_left && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= ch);
1661816647 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);
1662016649 }
1662116650 }
1662216651 ctx
@@ -16714,7 +16743,7 @@ fn read_tx_size(
1671416743 );
1671516744 }
1671616745 if depth != 0 {
16717- TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
16746+ hit!(TX_DEPTH_HITS);
1671816747 }
1671916748 max_tx >> depth
1672016749 }
@@ -17025,7 +17054,7 @@ fn read_var_tx_size(
1702517054 tx_h,
1702617055 );
1702717056 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);
1702917058 if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
1703017059 let (rng, _) = dec.debug_state();
1703117060 eprintln!(
@@ -17040,7 +17069,7 @@ fn read_var_tx_size(
1704017069 txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h));
1704117070 return;
1704217071 }
17043- TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));
17072+ hit!(TXFM_SPLIT_HITS);
1704417073 let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h);
1704517074 if (sub_w, sub_h) == (4, 4) {
1704617075 // libaom's `sub_txs == TX_4X4` early return: every mi cell of the
@@ -17185,11 +17214,13 @@ fn read_block_tx_size(
1718517214 leaves.push((row, col, tx, tx));
1718617215 }
1718717216 }
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+ }
1719317224 return Ok((tx, Some(leaves)));
1719417225 }
1719517226 Ok((tx, None))
@@ -17593,7 +17624,7 @@ fn read_block_tx_size_rect(
1759317624 // transform, and `set_txfm_ctxs` records exactly what
1759417625 // `txfm_partition_update` would for that same unit.
1759517626 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);
1759717628 return Ok(None);
1759817629 }
1759917630 let ctx = txfm_partition_ctx_rect(
@@ -17604,7 +17635,7 @@ fn read_block_tx_size_rect(
1760417635 tx_h,
1760517636 );
1760617637 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);
1760817639 if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
1760917640 let (rng, _) = dec.debug_state();
1761017641 eprintln!(
@@ -17616,11 +17647,11 @@ fn read_block_tx_size_rect(
1761617647 }
1761717648 if !split {
1761817649 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);
1762017651 return Ok(None);
1762117652 }
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);
1762417655 // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays
1762517656 // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`,
1762617657 // `[TX_16X64] == TX_16X32` -- so the recursion below is the general
@@ -17705,14 +17736,16 @@ fn read_inter_plane_rect(
1770517736 // rectangular shape (lane-sbpart r8).
1770617737 let (cw, ch) = (w.min(32), h.min(32));
1770717738 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);
1770917740 }
1771017741 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+ }
1771617749 }
1771717750 let (corner, tx_type) = if (cw, ch) == (32, 32) {
1771817751 let scan32 = default_scan(TX32);
@@ -18286,7 +18319,7 @@ fn edge_params_body(
1828618319 [4, 8, 14, 14, 14][dim]
1828718320 };
1828818321 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);
1829018323 Some((len, level))
1829118324 }
1829218325
@@ -19474,7 +19507,7 @@ fn cdef_band(
1947419507 let mut mi_c = 0usize;
1947519508 while mi_c < skip_grid.mi_cols {
1947619509 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);
1947819511 }
1947919512 if !skip_grid.is_skip_txfm(mi_r, mi_c) {
1948019513 let sidx = strength_idx(mi_r, mi_c);
@@ -19524,7 +19557,7 @@ fn cdef_band(
1952419557 || cdef.uv_pri_strength[sidx] != 0
1952519558 || cdef.uv_sec_strength[sidx] != 0)
1952619559 {
19527- CDEF_STRADDLE_UNITS.with(|c| c.set(c.get() + 1));
19560+ hit!(CDEF_STRADDLE_UNITS);
1952819561 }
1952919562 if enable_primary || enable_secondary {
1953019563 cdef_filter_block(
@@ -19995,6 +20028,8 @@ fn pipe_filters_ok(fctx: &crate::decode::FrameCtx, tile_cols: u32, lf_present: b
1999520028 /// [`apply_cdef`]'s early returns (lane-pipefilt: the pipelined path
1999620029 /// never enters `apply_cdef`, so it calls this itself).
1999720030 fn cdef_scan_counters(skip_grid: &Neighbours) {
20031+ let _ = skip_grid;
20032+ hit_do! {
1999820033 let mut r = 0usize;
1999920034 while r < skip_grid.mi_rows {
2000020035 let mut c = 0usize;
@@ -20007,7 +20042,7 @@ fn cdef_scan_counters(skip_grid: &Neighbours) {
2000720042 .map_or(true, |x| x.written)
2000820043 })
2000920044 }) {
20010- CDEF_UNWRITTEN_SKIP_UNITS.with(|c2| c2.set(c2.get() + 1));
20045+ hit!(CDEF_UNWRITTEN_SKIP_UNITS);
2001120046 if crate::envflags::env_flag!("EC_AV1_DEBUG_CDEF_BAND") {
2001220047 eprintln!("cdef band unwritten at mi ({r},{c}) px ({},{})", r * 4, c * 4);
2001320048 }
@@ -20020,12 +20055,13 @@ fn cdef_scan_counters(skip_grid: &Neighbours) {
2002020055 };
2002120056 let first = cell(0, 0);
2002220057 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);
2002420059 }
2002520060 c += 2;
2002620061 }
2002720062 r += 2;
2002820063 }
20064+ }
2002920065 }
2003020066
2003120067 /// `true` when this frame's CDEF cannot change a sample: `bits == 0` still
@@ -20468,7 +20504,7 @@ fn read_sb128_root(
2046820504 let ctx128 = neighbours.partition_ctx(at128, 128);
2046920505 let (has_cols128, has_rows128) = (mi_c128 + SB_MI < mi_cols, mi_r128 + SB_MI < mi_rows);
2047020506 let part128 = if has_cols128 && has_rows128 {
20471- PART128_SYMBOLS.with(|c| c.set(c.get() + 1));
20507+ hit!(PART128_SYMBOLS);
2047220508 let p = dec.symbol(&mut cdfs.partition_w128[ctx128]);
2047320509 if crate::envflags::env_flag!("EC_AV1_TRACE") {
2047420510 eprintln!("TRACE partition_w128 ctx={ctx128} value={p}");
@@ -20481,13 +20517,13 @@ fn read_sb128_root(
2048120517 // gathered arm. Value 1 is SPLIT; 0 is HORZ (rows out of frame) or
2048220518 // VERT (cols out of frame), which the refusal below then names
2048320519 // instead of silently reconstructing a split.
20484- PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() + 1));
20520+ hit!(PART128_GATHERED_SYMBOLS);
2048520521 match (has_cols128, has_rows128) {
2048620522 (true, false) => {
2048720523 if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 {
2048820524 PARTITION_SPLIT
2048920525 } else {
20490- PART128_EDGE_HORZ_HITS.with(|c| c.set(c.get() + 1));
20526+ hit!(PART128_EDGE_HORZ_HITS);
2049120527 PARTITION_HORZ
2049220528 }
2049320529 }
@@ -20495,7 +20531,7 @@ fn read_sb128_root(
2049520531 if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 {
2049620532 PARTITION_SPLIT
2049720533 } else {
20498- PART128_EDGE_VERT_HITS.with(|c| c.set(c.get() + 1));
20534+ hit!(PART128_EDGE_VERT_HITS);
2049920535 PARTITION_VERT
2050020536 }
2050120537 }
@@ -20517,19 +20553,21 @@ fn read_sb128_root(
2051720553 // for BLOCK_128X128 by `av1_get_partition_cdf`'s 8-symbol alphabet,
2051820554 // which stops at VERT_B).
2051920555 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),
2052420560 // lane-sb128c r9: the four AB shapes at the 128 root -- one
2052520561 // 128x64/64x128 half plus two 64x64 quadrants, decoded by both tile
2052620562 // paths below in libaom `decode_partition`'s own visit order.
2052720563 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+ }
2053320571 }
2053420572 _ => {
2053520573 return Err(unsupported(
@@ -20727,7 +20765,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2072720765 (mi_col1 as usize * 2).min(v.width),
2072820766 (mi_row1 as usize * 2).min(v.height),
2072920767 );
20730- TILE_HITS.with(|c| c.set(c.get() + 1));
20768+ hit!(TILE_HITS);
2073120769
2073220770 // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` --
2073320771 // 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(
2130221340 let arm = part16 - PARTITION_HORZ_A;
2130321341 bump_ab16(arm);
2130421342 if part16 == PARTITION_VERT_B {
21305- VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1));
21343+ hit!(VERT_B_INTRA_HITS);
2130621344 }
2130721345 let _vert_guard = if part16 == PARTITION_VERT_A || part16 == PARTITION_VERT_B {
2130821346 Some(crate::encode::Reach::vert_ab_partition())
@@ -21401,7 +21439,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2140121439 continue;
2140221440 }
2140321441 if part16 == PARTITION_HORZ {
21404- HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1));
21442+ hit!(HORZ_VERT_INTRA_HITS);
2140521443 let (mi_row0, mi_col0) = (
2140621444 sr as u32 * SUB_MI,
2140721445 sc as u32 * SUB_MI,
@@ -21449,7 +21487,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2144921487 continue;
2145021488 }
2145121489 if part16 == PARTITION_VERT {
21452- HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1));
21490+ hit!(HORZ_VERT_INTRA_HITS);
2145321491 let (mi_row0, mi_col0) = (
2145421492 sr as u32 * SUB_MI,
2145521493 sc as u32 * SUB_MI,
@@ -21703,8 +21741,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2170321741 // whole visible band of a frame whose
2170421742 // height (resp. width) is 8 mod 16 --
2170521743 // 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);
2170821746 let (mi_row0, mi_col0) =
2170921747 (sr as u32 * SUB_MI, sc as u32 * SUB_MI);
2171021748 let (bw, bh) = if has_cols16 { (16, 8) } else { (8, 16) };
@@ -21933,7 +21971,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2193321971 // a true 32x16 strip below (mirrors
2193421972 // decode_inter_block's cd6cb6d HORZ_A: TL,
2193521973 // TR, bottom strip).
21936- INTRA_HORZ_A_HITS.with(|c| c.set(c.get() + 1));
21974+ hit!(INTRA_HORZ_A_HITS);
2193721975 decode_block(
2193821976 &mut dec,
2193921977 &mut cdfs,
@@ -22008,7 +22046,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2200822046 // two 16x16 squares below (mirrors HORZ_A
2200922047 // with the strip/squares order flipped, same
2201022048 // 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);
2201222050 decode_block_rect(
2201322051 &mut dec,
2201422052 &mut cdfs,
@@ -22082,7 +22120,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2208222120 // lane-part32 r1: mirror of HORZ_A with
2208322121 // width/height swapped (TL, BL, right 16x32
2208422122 // strip).
22085- INTRA_VERT_A_HITS.with(|c| c.set(c.get() + 1));
22123+ hit!(INTRA_VERT_A_HITS);
2208622124 let _vert_ab = crate::encode::Reach::vert_ab_partition();
2208722125 decode_block(
2208822126 &mut dec,
@@ -22158,7 +22196,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2215822196 // left + two 16x16 squares on the right
2215922197 // (libaom decode_partition VERT_B: left
2216022198 // strip, TR, BR).
22161- INTRA_VERT_B_HITS.with(|c| c.set(c.get() + 1));
22199+ hit!(INTRA_VERT_B_HITS);
2216222200 let _vert_ab = crate::encode::Reach::vert_ab_partition();
2216322201 decode_block_rect(
2216422202 &mut dec,
@@ -22374,11 +22412,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2237422412 // TR, BR). The pieces are exactly the ones already proven
2237522413 // by the `PARTITION_NONE`-under-SPLIT (32x32 square) and
2237622414 // `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+ }
2238222422 // lane-part32 r5: only the two VERTICAL arms reorder the
2238322423 // square sub-blocks (TL, BL, TR, BR), so only they switch
2238422424 // libaom's `has_tr`/`has_bl` tables.
@@ -22815,7 +22855,7 @@ fn resolve_interp_filter(
2281522855 sym0
2281622856 };
2281722857 if enable_dual_filter && sym0 != sym1 {
22818- DUAL_FILTER_DIFF_HITS.with(|c| c.set(c.get() + 1));
22858+ hit!(DUAL_FILTER_DIFF_HITS);
2281922859 }
2282022860 if crate::envflags::env_flag!("EC_TRACE_MODE") {
2282122861 eprintln!(
@@ -23182,7 +23222,7 @@ fn read_single_ref(
2318223222 }
2318323223 };
2318423224 if ref_frame != LAST_FRAME {
23185- NON_LAST_REF_HITS.with(|c| c.set(c.get() + 1));
23225+ hit!(NON_LAST_REF_HITS);
2318623226 let c = match ref_frame {
2318723227 LAST2_FRAME => &LAST2_HITS,
2318823228 LAST3_FRAME => &LAST3_HITS,
@@ -23192,7 +23232,7 @@ fn read_single_ref(
2319223232 ALTREF_FRAME => &ALTREF_HITS,
2319323233 _ => unreachable!("read_single_ref only ever returns LAST_FRAME..=ALTREF_FRAME"),
2319423234 };
23195- c.with(|v| v.set(v.get() + 1));
23235+ hit_do! { c.with(|v| v.set(v.get() + 1)); }
2319623236 }
2319723237 ref_frame
2319823238 }
@@ -23442,7 +23482,7 @@ fn overlappable_above(
2344223482 if let Some(info) = nb {
2344323483 if info.is_inter {
2344423484 if src != col {
23445- OBMC_PAIR_FILTER_HITS.with(|c| c.set(c.get() + 1));
23485+ hit!(OBMC_PAIR_FILTER_HITS);
2344623486 }
2344723487 // lane-t900 r14: libaom passes `AOMMIN(xd->width, mi_step)`
2344823488 // as `op_mi_size` -- the block's OWN width, never the
@@ -23495,7 +23535,7 @@ fn overlappable_left(
2349523535 if let Some(info) = nb {
2349623536 if info.is_inter {
2349723537 if src != row {
23498- OBMC_PAIR_FILTER_HITS.with(|c| c.set(c.get() + 1));
23538+ hit!(OBMC_PAIR_FILTER_HITS);
2349923539 }
2350023540 // lane-t900 r14: `AOMMIN(xd->height, mi_step)` -- see
2350123541 // `overlappable_above`.
@@ -23667,7 +23707,7 @@ fn find_samples(
2366723707 // wrong-alphabet-same-value).
2366823708 let tr_reach = crate::mvstack::has_top_right(mi_row, mi_col, bw4, bh4, fctx);
2366923709 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);
2367123711 }
2367223712 if do_tr && tr_reach {
2367323713 let tr_col = mi_col + bw4;
@@ -23765,7 +23805,7 @@ fn neighbour_filter(
2376523805 "an OBMC neighbour whose switchable interp filter was never recorded",
2376623806 ));
2376723807 }
23768- OBMC_FILTER_BAND_READS.with(|c| c.set(c.get() + 1));
23808+ hit!(OBMC_FILTER_BAND_READS);
2376923809 Ok((
2377023810 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),
2377123811 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),
@@ -24130,7 +24170,7 @@ fn obmc_plan(
2413024170 // byte-exact against an instrumented aomdec, the refusal is gone and the
2413124171 // counter below is what the gate's `--enable-obmc=1` arm reads.
2413224172 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);
2413424174 }
2413524175 // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own
2413624176 // half (`reconinter.c` 860/899), inert below 128.
@@ -24159,7 +24199,7 @@ fn obmc_plan(
2415924199 ec_obmc_trace("above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind);
2416024200 let (nb_width, _) = ref_dims(nb.ref_frame, refpix)?;
2416124201 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);
2416324203 }
2416424204 above.push(ObmcNb {
2416524205 off4,
@@ -24183,7 +24223,7 @@ fn obmc_plan(
2418324223 ec_obmc_trace("left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind);
2418424224 let (nb_width, _) = ref_dims(nb.ref_frame, refpix)?;
2418524225 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);
2418724227 }
2418824228 left.push(ObmcNb {
2418924229 off4,
@@ -24496,7 +24536,7 @@ fn read_comp_mode(
2449624536 let ctx = reference_mode_ctx(above, left);
2449724537 let compound = dec.symbol(&mut cdfs.comp_mode[ctx]) == 1;
2449824538 if compound {
24499- COMP_MODE_HITS.with(|c| c.set(c.get() + 1));
24539+ hit!(COMP_MODE_HITS);
2450024540 }
2450124541 compound
2450224542 }
@@ -24539,7 +24579,7 @@ fn read_compound_ref_frames(
2453924579 let type_ctx = comp_reference_type_ctx(above, left);
2454024580 let unidir = dec.symbol(&mut cdfs.comp_ref_type[type_ctx]) == 0;
2454124581 if unidir {
24542- UNI_COMP_HITS.with(|c| c.set(c.get() + 1));
24582+ hit!(UNI_COMP_HITS);
2454324583 // uni_comp_ref (p0): forward vs. backward -- av1_get_pred_context_-
2454424584 // uni_comp_ref_p is single_ref_p1's own forward/backward vote.
2454524585 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(
2460124641 ref_mv_ctx: usize,
2460224642 ) -> u8 {
2460324643 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);
2460524645 dec.symbol(&mut cdfs.inter_compound_mode[ctx]) as u8
2460624646 }
2460724647
@@ -24940,7 +24980,7 @@ fn decode_inter_block(
2494024980 );
2494124981 }
2494224982 if skip_mode {
24943- SKIP_MODE_HITS.with(|c| c.set(c.get() + 1));
24983+ hit!(SKIP_MODE_HITS);
2494424984 }
2494524985
2494624986 let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]);
@@ -25177,7 +25217,7 @@ fn decode_inter_block(
2517725217 // model, so a 4-px-sided block still reads its interp filter.
2517825218 let gm_nontrans = gm_nontrans_models && bw4.min(bh4) >= 2;
2517925219 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);
2518125221 }
2518225222 // lane-defer8: both slots' pictures are resolved inside the
2518325223 // prediction closure; the parse only needs their SIZES.
@@ -25229,7 +25269,7 @@ fn decode_inter_block(
2522925269 let warp0 = compound_warp(ref0, is_global_mv0).filter(|_| ref_unscaled(ref0));
2523025270 let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1));
2523125271 if warp0.is_some() || warp1.is_some() {
25232- COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1));
25272+ hit!(COMPOUND_WARP_HITS);
2523325273 }
2523425274 // spec `get_ref_filter_type`: matches when EITHER of the
2523525275 // neighbour's two references equals this block's own ref0 --
@@ -25343,13 +25383,15 @@ fn decode_inter_block(
2534325383 // verified vs independent C dump (wedge.rs).
2534425384 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]);
2534525385 let wedge_sign = dec.literal(1);
25346- WEDGE_HITS.with(|c| c.set(c.get() + 1));
25386+ hit!(WEDGE_HITS);
2534725387 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+ }
2535325395 }
2535425396 // lane-inter16ab r5: the codebook row is this block's TRUE
2535525397 // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for
@@ -25368,12 +25410,12 @@ fn decode_inter_block(
2536825410 let mask_type = dec.literal(1);
2536925411 diffwtd_mask_type = Some(mask_type as u8);
2537025412 if wedge_bsize.is_none() {
25371- DIFFWTD_INFERRED_HITS.with(|c| c.set(c.get() + 1));
25413+ hit!(DIFFWTD_INFERRED_HITS);
2537225414 }
2537325415 }
25374- MASKED_COMPOUND_HITS.with(|c| c.set(c.get() + 1));
25416+ hit!(MASKED_COMPOUND_HITS);
2537525417 if write_w != write_h {
25376- RECT_MASKED_COMPOUND_HITS.with(|c| c.set(c.get() + 1));
25418+ hit!(RECT_MASKED_COMPOUND_HITS);
2537725419 }
2537825420 }
2537925421 // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): r16/r17
@@ -25649,13 +25691,13 @@ fn decode_inter_block(
2564925691 let scale0 = mc::scale_factor(ref_dims(ref0, refpix)?.0, frame_width);
2565025692 let scale1 = mc::scale_factor(ref_dims(ref1, refpix)?.0, frame_width);
2565125693 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);
2565325695 }
2565425696 // lane-scaledref r2: the MIXED case -- one tap scaled, the other
2565525697 // not -- is the one an all-frames-scaled recipe never produces,
2565625698 // and the one a single shared scale factor would get wrong.
2565725699 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);
2565925701 }
2566025702
2566125703 // lane-wave4 (the compound arm's half): this block's whole
@@ -25737,7 +25779,7 @@ fn decode_inter_block(
2573725779 // either way, only the mask source differs.
2573825780 let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type {
2573925781 diffwtd_mask_y = vec![0u8; side * side];
25740- DIFFWTD_HITS.with(|c| c.set(c.get() + 1));
25782+ hit!(DIFFWTD_HITS);
2574125783 mc::diffwtd_mask(&inter0_y, &inter1_y, mask_type == 1, &mut diffwtd_mask_y, fctx);
2574225784 Some(diffwtd_mask_y.as_slice())
2574325785 } else {
@@ -26113,7 +26155,7 @@ fn decode_inter_block(
2611326155 neighbours.record_mi_chroma(
2611426156 cu_mi, luma_span, luma_span, plane_idx, &cu_grid,
2611526157 );
26116- CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
26158+ hit!(CHROMA_SPLIT_TX_HITS);
2611726159 mu_chroma = true;
2611826160 let dst = mu_units(
2611926161 if plane_idx == 1 { &mut u_units } else { &mut v_units },
@@ -26504,13 +26546,15 @@ fn decode_inter_block(
2650426546 // NO sign symbol follows -- libaom fixes
2650526547 // INTERINTRA_WEDGE_SIGN 0 (blockd.h).
2650626548 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);
2650826550 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+ }
2651426558 }
2651526559 // lane-inter16ab r5: true-footprint codebook row,
2651626560 // mask padded to stride `max(bw,bh) == side` -- see
@@ -26522,7 +26566,7 @@ fn decode_inter_block(
2652226566 side,
2652326567 ));
2652426568 } else {
26525- INTERINTRA_HITS.with(|c| c.set(c.get() + 1));
26569+ hit!(INTERINTRA_HITS);
2652626570 }
2652726571 interintra_mode = Some(ii);
2652826572 }
@@ -26660,10 +26704,10 @@ fn decode_inter_block(
2666026704 let warp_eligible =
2666126705 allow_warped_motion && !ref_is_scaled && !force_integer_mv && proj_ok;
2666226706 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);
2666426708 }
2666526709 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);
2666726711 }
2666826712 if warp_eligible {
2666926713 let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]);
@@ -26671,11 +26715,11 @@ fn decode_inter_block(
2667126715 0 => {}
2667226716 1 => {
2667326717 obmc_selected = true;
26674- OBMC_HITS.with(|c| c.set(c.get() + 1));
26718+ hit!(OBMC_HITS);
2667526719 }
2667626720 _ => {
2667726721 warped_selected = true;
26678- WARP_SELECTED_HITS.with(|c| c.set(c.get() + 1));
26722+ hit!(WARP_SELECTED_HITS);
2667926723 let mut samples = find_samples(
2668026724 grid,
2668126725 mi_row,
@@ -26724,7 +26768,7 @@ fn decode_inter_block(
2672426768 } else {
2672526769 obmc_selected = dec.symbol(&mut cdfs.obmc[bsize_idx]) == 1;
2672626770 if obmc_selected {
26727- OBMC_HITS.with(|c| c.set(c.get() + 1));
26771+ hit!(OBMC_HITS);
2672826772 }
2672926773 }
2673026774 // lane-t900 r9: which ALPHABET this block read (3-symbol
@@ -26764,7 +26808,7 @@ fn decode_inter_block(
2676426808 if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid {
2676526809 warp_params = crate::warp::global_warp_params(gm_ref.params);
2676626810 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);
2676826812 }
2676926813 }
2677026814 if crate::envflags::env_flag!("EC_AV1_TELL") {
@@ -26871,13 +26915,13 @@ fn decode_inter_block(
2687126915 // which this file used to SKIP under a scaled reference
2687226916 // (fixed in the same commit), not the warp fallback.
2687326917 if warp_params.is_some() {
26874- SCALED_WARP_FALLBACK_HITS.with(|c| c.set(c.get() + 1));
26918+ hit!(SCALED_WARP_FALLBACK_HITS);
2687526919 }
2687626920 if obmc_selected {
26877- SCALED_OBMC_HITS.with(|c| c.set(c.get() + 1));
26921+ hit!(SCALED_OBMC_HITS);
2687826922 }
2687926923 if interintra_mode.is_some() {
26880- SCALED_INTERINTRA_HITS.with(|c| c.set(c.get() + 1));
26924+ hit!(SCALED_INTERINTRA_HITS);
2688126925 }
2688226926 }
2688326927
@@ -26891,7 +26935,7 @@ fn decode_inter_block(
2689126935 let sub8 = match strip_chroma.filter(|s| s.has_chroma).and_then(|s| s.prev.map(|p| (s.horz, p))) {
2689226936 Some((horz, (prev_ref, prev_mv, prev_h, prev_v))) => {
2689326937 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);
2689526939 Some((
2689626940 horz,
2689726941 prev_ref,
@@ -27094,7 +27138,7 @@ fn decode_inter_block(
2709427138 // plane loop).
2709527139 if let Some(ii) = interintra_mode {
2709627140 if write_w != write_h {
27097- INTERINTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
27141+ hit!(INTERINTRA_RECT_HITS);
2709827142 }
2709927143 interintra_blend(y, px, py, write_w, write_h, side, ii, wedge_mask, &mut pred_y, fctx);
2710027144 interintra_blend(
@@ -27403,7 +27447,7 @@ fn decode_inter_block(
2740327447 neighbours.record_mi_chroma(
2740427448 cu_mi, luma_span, luma_span, plane_idx, &cu_grid,
2740527449 );
27406- CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
27450+ hit!(CHROMA_SPLIT_TX_HITS);
2740727451 mu_chroma = true;
2740827452 let dst = mu_units(
2740927453 if plane_idx == 1 { &mut u_units } else { &mut v_units },
@@ -27749,7 +27793,7 @@ fn decode_inter_block(
2774927793 0
2775027794 };
2775127795 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);
2775327797 }
2775427798 // The delta'd angle decides whether the intra edge filter runs at
2775527799 // all, so this block needs the same luma edge-filter-type neighbour
@@ -27768,7 +27812,7 @@ fn decode_inter_block(
2776827812 // block on.
2776927813 let cfl_allowed = write_w.max(write_h) <= 32;
2777027814 if !cfl_allowed {
27771- NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1));
27815+ hit!(NOCFL_UV_MODE_HITS);
2777227816 }
2777327817 let uv_mode = if cfl_allowed {
2777427818 dec.symbol(&mut cdfs.uv_mode_cfl[mode])
@@ -27776,7 +27820,7 @@ fn decode_inter_block(
2777627820 dec.symbol(&mut cdfs.uv_mode_no_cfl[mode])
2777727821 };
2777827822 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 @@
1212 //! [`crate::stream::decode_stream`] is the only caller: it applies this to
1313 //! the frame it pushes onto its output `Vec<Picture>`, after saving the
1414 //! clean decode into the reference slot bank.
15+use crate::hits::hit;
1516
1617 use crate::decode::WithRef;
1718 use crate::encode::Picture;
@@ -1107,7 +1108,7 @@ pub(crate) fn apply_grain(
11071108 return picture.clone();
11081109 }
11091110 fctx.grain_bit_depth.with(|c| c.set(bit_depth));
1110- GRAIN_HITS.with(|c| c.set(c.get() + 1));
1111+ hit!(GRAIN_HITS);
11111112 let width = picture.width as i32;
11121113 let height = picture.height as i32;
11131114 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 @@
77 //! not this module's business -- the caller passes the samples it has, and the
88 //! edge is extended by repeating the last one, which is what the decoder does
99 //! with its own `BlockDecoded` bookkeeping (spec 7.11.2.2).
10+use crate::hits::hit;
1011
1112 /// The average of the neighbours (spec 7.11.2.5).
1213 pub const DC_PRED: u8 = 0;
@@ -284,9 +285,9 @@ pub(crate) fn predict(
284285 assert_eq!(dst.len(), bw * bh, "the destination is the block");
285286 match mode {
286287 SMOOTH_PRED | SMOOTH_V_PRED | SMOOTH_H_PRED => {
287- SMOOTH_PRED_HITS.with(|c| c.set(c.get() + 1));
288+ hit!(SMOOTH_PRED_HITS);
288289 }
289- PAETH_PRED => PAETH_PRED_HITS.with(|c| c.set(c.get() + 1)),
290+ PAETH_PRED => hit!(PAETH_PRED_HITS),
290291 _ => {}
291292 }
292293 let edges = Edges::build(above, left, corner, bw, bh, fctx);
@@ -483,7 +484,7 @@ fn filter_intra_edge(buf: &mut [i32], strength: i32) {
483484 if strength == 0 {
484485 return;
485486 }
486- EDGE_FILTER_HITS.with(|c| c.set(c.get() + 1));
487+ hit!(EDGE_FILTER_HITS);
487488 const KERNEL: [[i32; 5]; 3] = [[0, 4, 8, 4, 0], [0, 5, 6, 5, 0], [2, 4, 4, 4, 2]];
488489 let filt = usize::try_from(strength - 1).expect("a filter strength is never negative");
489490 let sz = buf.len() as i32;
crates/ec-av1/src/lib.rsmodified+1 -0
@@ -34,6 +34,7 @@ mod envflags;
3434 mod film_grain;
3535 pub mod frame;
3636 mod gate_coverage;
37+mod hits;
3738 pub mod intra;
3839 pub mod mc;
3940 pub mod motion;
crates/ec-av1/src/mc.rsmodified+7 -6
@@ -8,6 +8,7 @@
88 //! in 1/16-pel steps -- luma motion vectors are stored at 1/8-pel and always
99 //! land on an even step; chroma vectors, once scaled for subsampling, can
1010 //! land on any of the 16.
11+use crate::hits::hit;
1112
1213 /// `Round2` (spec 4.7): halves round up.
1314 fn round2(value: i32, shift: u32) -> i32 {
@@ -1133,7 +1134,7 @@ pub(crate) fn predict_with_filters_kern(
11331134 ) {
11341135 assert_eq!(dst.len(), block_w * block_h, "the destination is the block");
11351136 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);
11371138
11381139 #[cfg(test)]
11391140 let stage_t = std::time::Instant::now();
@@ -1328,7 +1329,7 @@ pub fn reset_rect_narrow_kern_hits() {
13281329 /// the destination buffer's dims would not have.
13291330 fn note_narrow_kern(block_w: usize, block_h: usize, kern_w: usize, kern_h: usize) {
13301331 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);
13321333 }
13331334 }
13341335
@@ -1514,8 +1515,8 @@ pub(crate) fn predict_scaled_kern(
15141515 ) {
15151516 assert_eq!(dst.len(), block_w * block_h, "the destination is the block");
15161517 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);
15191520
15201521 let y0 = y_q4.div_euclid(16);
15211522 let yfrac = y_q4.rem_euclid(16) as usize;
@@ -1655,10 +1656,10 @@ pub fn predict_compound_intermediate_kern(
16551656 ) {
16561657 assert_eq!(dst.len(), block_w * block_h, "the destination is the block");
16571658 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);
16591660
16601661 if x_scale_fp != REF_NO_SCALE {
1661- PREDICT_SCALED_HITS.with(|c| c.set(c.get() + 1));
1662+ hit!(PREDICT_SCALED_HITS);
16621663 }
16631664
16641665 let y0 = y_q4.div_euclid(16);
crates/ec-av1/src/motion_field.rsmodified+3 -2
@@ -5,6 +5,7 @@
55 //! (`av1/common/mvref_common.c`) and the projection math `add_tpl_ref_mv`
66 //! (same file) applies a second time, per query block, against the block's
77 //! own single reference frame.
8+use crate::hits::hit;
89
910 use crate::mvstack::{ALTREF_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME};
1011
@@ -400,10 +401,10 @@ pub fn setup_motion_field<M: std::borrow::Borrow<MotionField>>(
400401 })
401402 .count();
402403 if intra_forward_refs >= 1 {
403- REFSTAMP_INTRA_FRAMES.with(|c| c.set(c.get() + 1));
404+ hit!(REFSTAMP_INTRA_FRAMES);
404405 }
405406 if intra_forward_refs >= 2 {
406- REFSTAMP_INTRA2_FRAMES.with(|c| c.set(c.get() + 1));
407+ hit!(REFSTAMP_INTRA2_FRAMES);
407408 }
408409
409410 if let Some(last) = slot_of(LAST_FRAME) {
crates/ec-av1/src/mvstack.rsmodified+9 -8
@@ -77,6 +77,7 @@
7777 //! added by the row/col scan), and the "extra search" that pads a short
7878 //! stack to two entries (spec 7.10.2.12) — this module's stack can be
7979 //! shorter than two candidates where libaom's never is.
80+use crate::hits::hit;
8081
8182 thread_local! {
8283 /// 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) {
503504 if let Some(entry) = candidates.iter_mut().find(|e| e.mv == mv) {
504505 entry.weight += weight;
505506 } else if candidates.len() >= MAX_STACK_SIZE {
506- STACK_FULL_DROPS.with(|c| c.set(c.get() + 1));
507+ hit!(STACK_FULL_DROPS);
507508 } else {
508509 // libaom `add_ref_mv_candidate` (mvref_common.c:100) and
509510 // `add_tpl_ref_mv` (:388) only push when
@@ -983,7 +984,7 @@ fn clamp_mv_ref(
983984 let clamped_row = row.clamp(to_top - bh8 - MV_BORDER, to_bottom + bh8 + MV_BORDER);
984985 let clamped_col = col.clamp(to_left - bw8 - MV_BORDER, to_right + bw8 + MV_BORDER);
985986 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);
987988 }
988989 }
989990
@@ -1194,7 +1195,7 @@ pub fn find_mv_stack_with_sign_bias(
11941195 // `None` for the cells outside the tile.
11951196 let (tile_row0, tile_col0) = grid.tile_origin();
11961197 if tile_row0 > 0 || tile_col0 > 0 {
1197- TILE_REACH_CLIPS.with(|c| c.set(c.get() + 1));
1198+ hit!(TILE_REACH_CLIPS);
11981199 }
11991200 let max_row_offset: isize = if mi_row > tile_row0 {
12001201 let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj);
@@ -1361,7 +1362,7 @@ pub fn find_mv_stack_with_sign_bias(
13611362 }
13621363 }
13631364 if any_hit {
1364- TMV_HITS.with(|c| c.set(c.get() + 1));
1365+ hit!(TMV_HITS);
13651366 }
13661367 zero_mv_ctx = usize::from(first_sample_missing || first_sample_far);
13671368 }
@@ -1661,7 +1662,7 @@ fn add_compound_candidate(
16611662 if let Some(entry) = candidates.iter_mut().find(|e| e.mv0 == mv0 && e.mv1 == mv1) {
16621663 entry.weight += weight;
16631664 } else if candidates.len() >= MAX_STACK_SIZE {
1664- STACK_FULL_DROPS.with(|c| c.set(c.get() + 1));
1665+ hit!(STACK_FULL_DROPS);
16651666 } else {
16661667 // Same insertion cap as [`add_candidate`]: libaom's compound branch
16671668 // of `add_ref_mv_candidate` (mvref_common.c:128) and `add_tpl_ref_mv`
@@ -1946,7 +1947,7 @@ fn combine_compound_candidates(
19461947 std::array::from_fn(|i| {
19471948 merged.get(i).copied().unwrap_or_else(|| {
19481949 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);
19501951 }
19511952 gm_mv_candidates[side]
19521953 })
@@ -2006,7 +2007,7 @@ pub fn find_mv_stack_compound(
20062007 // `None` for the cells outside the tile.
20072008 let (tile_row0, tile_col0) = grid.tile_origin();
20082009 if tile_row0 > 0 || tile_col0 > 0 {
2009- TILE_REACH_CLIPS.with(|c| c.set(c.get() + 1));
2010+ hit!(TILE_REACH_CLIPS);
20102011 }
20112012 let max_row_offset: isize = if mi_row > tile_row0 {
20122013 let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj);
@@ -2171,7 +2172,7 @@ pub fn find_mv_stack_compound(
21712172 }
21722173 }
21732174 if any_hit {
2174- TMV_HITS.with(|c| c.set(c.get() + 1));
2175+ hit!(TMV_HITS);
21752176 }
21762177 zero_mv_ctx = usize::from(first_sample_missing || first_sample_far);
21772178 }
crates/ec-av1/src/restoration.rsmodified+8 -7
@@ -3,6 +3,7 @@
33 //! `av1_loop_restoration_corners_in_sb`, restoration.c:1277) and spec 7.17's
44 //! two pixel filters (Wiener, self-guided/SGR). See `lanes/lr.report.md` for
55 //! the full derivation (libaom `decodeframe.c`/`restoration.c` line refs).
6+use crate::hits::hit;
67
78 use crate::msac::SymbolDecoder;
89 use ec_av1_syntax::obu::floor_log2;
@@ -426,23 +427,23 @@ fn read_lr_unit(
426427 ) -> UnitFilter {
427428 match ftype {
428429 RestorationType::Switchable => {
429- SWITCHABLE_HITS.with(|c| c.set(c.get() + 1));
430+ hit!(SWITCHABLE_HITS);
430431 let t = dec.symbol(&mut cdfs.restore_switchable);
431432 match t {
432433 0 => UnitFilter::None,
433434 1 => {
434- WIENER_HITS.with(|c| c.set(c.get() + 1));
435+ hit!(WIENER_HITS);
435436 UnitFilter::Wiener(read_wiener_filter(dec, chroma, &mut reference.0))
436437 }
437438 _ => {
438- SGRPROJ_HITS.with(|c| c.set(c.get() + 1));
439+ hit!(SGRPROJ_HITS);
439440 UnitFilter::Sgrproj(read_sgrproj_filter(dec, &mut reference.1))
440441 }
441442 }
442443 }
443444 RestorationType::Wiener => {
444445 if dec.symbol(&mut cdfs.restore_wiener) != 0 {
445- WIENER_HITS.with(|c| c.set(c.get() + 1));
446+ hit!(WIENER_HITS);
446447 UnitFilter::Wiener(read_wiener_filter(dec, chroma, &mut reference.0))
447448 } else {
448449 UnitFilter::None
@@ -451,7 +452,7 @@ fn read_lr_unit(
451452 RestorationType::Sgrproj => {
452453 let bit = dec.symbol(&mut cdfs.restore_sgrproj);
453454 if bit != 0 {
454- SGRPROJ_HITS.with(|c| c.set(c.get() + 1));
455+ hit!(SGRPROJ_HITS);
455456 UnitFilter::Sgrproj(read_sgrproj_filter(dec, &mut reference.1))
456457 } else {
457458 UnitFilter::None
@@ -1191,10 +1192,10 @@ fn filter_restoration_unit(
11911192 let stripe_v_end = stripe_v_start + h;
11921193 if !matches!(filter, UnitFilter::None) {
11931194 if stripe_v_start == 0 {
1194- LR_STRIPE0_HITS.with(|c| c.set(c.get() + 1));
1195+ hit!(LR_STRIPE0_HITS);
11951196 }
11961197 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);
11981199 }
11991200 }
12001201 match filter {
crates/ec-av1/src/superres.rsmodified+2 -1
@@ -10,6 +10,7 @@
1010 //! Every constant and the 64x8 `av1_resize_filter_normative` coefficient
1111 //! table below is copied verbatim from libaom `aom_dsp/aom_filter.h` and
1212 //! `av1/common/resize.c` (`AOM_VERSION=v3.13.3`, `~/.cache/aom-oracle`).
13+use crate::hits::hit;
1314
1415 /// `RS_SUBPEL_BITS`.
1516 const RS_SUBPEL_BITS: u32 = 6;
@@ -184,7 +185,7 @@ pub(crate) fn superres_hits() -> usize {
184185
185186 /// Counts one whole upscaled picture (all three planes) for [`SUPERRES_HITS`].
186187 pub(crate) fn note_upscaled_picture() {
187- SUPERRES_HITS.with(|c| c.set(c.get() + 1));
188+ hit!(SUPERRES_HITS);
188189 }
189190
190191 #[cfg(test)]