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