Route every gate counter through hit!/hit_do! behind a default-on gate-counters feature
Browse files at this commit04187f1499251a83be3090f06548d0a16bf5d33aParent: 36b27a7- perf
- route every gate counter through hit!/hit_do! behind a default-on gate-counters feature
11 changed files +634 -509
- crates/ec-av1/Cargo.toml +8 -0
- crates/ec-av1/src/decode.rs +543 -481
- 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/src/decode.rsmodified+543 -481
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, |
| @@ -259,16 +260,18 @@ thread_local! { | |||
| 259 | /// Called by [`crate::stream::decode_stream`] before each frame's tiles with | 260 | /// Called by [`crate::stream::decode_stream`] before each frame's tiles with |
| 260 | /// that frame's DECODE-order index. | 261 | /// that frame's DECODE-order index. |
| 261 | pub fn set_coeff_trace_frame(idx: usize) { | 262 | pub fn set_coeff_trace_frame(idx: usize) { |
| 262 | - COEFF_TRACE_FRAME.with(|c| { | 263 | + hit_do! { |
| 263 | - if c.get().is_none() { | 264 | + COEFF_TRACE_FRAME.with(|c| { |
| 264 | - let want = match crate::envflags::var("EC_TRACE_COEFF_FRAME") { | 265 | + if c.get().is_none() { |
| 265 | - Ok(v) => v.parse::<usize>().unwrap_or(usize::MAX), | 266 | + let want = match crate::envflags::var("EC_TRACE_COEFF_FRAME") { |
| 266 | - // unset: keep tracing every frame, as before this rung existed | 267 | + Ok(v) => v.parse::<usize>().unwrap_or(usize::MAX), |
| 267 | - Err(_) => usize::MAX - 1, | 268 | + // unset: keep tracing every frame, as before this rung existed |
| 268 | - }; | 269 | + Err(_) => usize::MAX - 1, |
| 269 | - c.set(Some(want)); | 270 | + }; |
| 270 | - } | 271 | + c.set(Some(want)); |
| 271 | - }); | 272 | + } |
| 273 | + }); | ||
| 274 | + } | ||
| 272 | COEFF_TRACE_CUR.with(|c| c.set(idx)); | 275 | COEFF_TRACE_CUR.with(|c| c.set(idx)); |
| 273 | if crate::envflags::env_flag!("EC_TRACE_COEFF") { | 276 | if crate::envflags::env_flag!("EC_TRACE_COEFF") { |
| 274 | eprintln!("EC_COEFF_FRAME decode_idx={idx}"); | 277 | eprintln!("EC_COEFF_FRAME decode_idx={idx}"); |
| @@ -526,7 +529,7 @@ fn warp_plane_allowed(w: usize, h: usize) -> bool { | |||
| 526 | if w >= 8 && h >= 8 { | 529 | if w >= 8 && h >= 8 { |
| 527 | return true; | 530 | return true; |
| 528 | } | 531 | } |
| 529 | - WARP_PLANE_SUPPRESS_HITS.with(|c| c.set(c.get() + 1)); | 532 | + hit!(WARP_PLANE_SUPPRESS_HITS); |
| 530 | false | 533 | false |
| 531 | } | 534 | } |
| 532 | 535 | ||
| @@ -638,7 +641,7 @@ fn maybe_read_delta_q(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_ | |||
| 638 | } | 641 | } |
| 639 | let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; | 642 | let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; |
| 640 | let reduced = if sign_negative { -abs } else { abs }; | 643 | let reduced = if sign_negative { -abs } else { abs }; |
| 641 | - DELTA_Q_HITS.with(|c| c.set(c.get() + 1)); | 644 | + hit!(DELTA_Q_HITS); |
| 642 | let res = fctx.delta_q_res.with(|c| c.get()); | 645 | 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))); | 646 | fctx.current_q_idx.with(|c| c.set((c.get() + reduced * res).clamp(1, 255))); |
| 644 | } | 647 | } |
| @@ -702,7 +705,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 }; | 705 | let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; |
| 703 | let reduced = if sign_negative { -abs } else { abs }; | 706 | let reduced = if sign_negative { -abs } else { abs }; |
| 704 | cur[i] = (cur[i] + reduced * res).clamp(-63, 63); | 707 | cur[i] = (cur[i] + reduced * res).clamp(-63, 63); |
| 705 | - DELTA_LF_HITS.with(|c| c.set(c.get() + 1)); | 708 | + hit!(DELTA_LF_HITS); |
| 706 | } | 709 | } |
| 707 | fctx.current_delta_lf.with(|c| c.set(cur)); | 710 | fctx.current_delta_lf.with(|c| c.set(cur)); |
| 708 | } | 711 | } |
| @@ -720,7 +723,7 @@ fn maybe_read_cdef_idx(dec: &mut SymbolDecoder, mi_r: usize, mi_c: usize, skip: | |||
| 720 | } | 723 | } |
| 721 | let idx = dec.literal(u32::from(bits)) as u8; | 724 | let idx = dec.literal(u32::from(bits)) as u8; |
| 722 | fctx.cdef_transmitted.with(|c| c.set(true)); | 725 | fctx.cdef_transmitted.with(|c| c.set(true)); |
| 723 | - CDEF_IDX_HITS.with(|c| c.set(c.get() + 1)); | 726 | + hit!(CDEF_IDX_HITS); |
| 724 | let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize); | 727 | 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()); | 728 | let sb_cols = fctx.cdef_sb_cols.with(|c| c.get()); |
| 726 | if sb_cols > 0 { | 729 | if sb_cols > 0 { |
| @@ -951,7 +954,7 @@ fn read_segment_id(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_c: | |||
| 951 | return pred as u8; | 954 | return pred as u8; |
| 952 | } | 955 | } |
| 953 | let coded = dec.symbol(&mut cdfs.segment_id[ctx]) as i32; | 956 | let coded = dec.symbol(&mut cdfs.segment_id[ctx]) as i32; |
| 954 | - SEG_ID_HITS.with(|c| c.set(c.get() + 1)); | 957 | + hit!(SEG_ID_HITS); |
| 955 | let last_active = fctx.seg.with(|s| i32::from(s.borrow().last_active_seg_id)); | 958 | 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 | 959 | neg_deinterleave(coded, pred, last_active + 1).clamp(0, last_active) as u8 |
| 957 | } | 960 | } |
| @@ -1024,7 +1027,7 @@ fn inter_segment_id( | |||
| 1024 | let id = if temporal_update { | 1027 | let id = if temporal_update { |
| 1025 | let ctx = seg_pred_ctx(mi_r, mi_c, fctx); | 1028 | let ctx = seg_pred_ctx(mi_r, mi_c, fctx); |
| 1026 | let predicted = dec.symbol(&mut cdfs.segment_pred[ctx]) != 0; | 1029 | let predicted = dec.symbol(&mut cdfs.segment_pred[ctx]) != 0; |
| 1027 | - SEG_PRED_HITS.with(|c| c.set(c.get() + 1)); | 1030 | + hit!(SEG_PRED_HITS); |
| 1028 | stamp_seg_pred(mi_r, mi_c, w_mi, h_mi, u8::from(predicted), fctx); | 1031 | stamp_seg_pred(mi_r, mi_c, w_mi, h_mi, u8::from(predicted), fctx); |
| 1029 | if predicted { | 1032 | if predicted { |
| 1030 | predicted_segment_id(mi_r, mi_c, w_mi, h_mi, fctx) | 1033 | predicted_segment_id(mi_r, mi_c, w_mi, h_mi, fctx) |
| @@ -1130,7 +1133,7 @@ fn tu_reach( | |||
| 1130 | let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, block); | 1133 | 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); | 1134 | let standalone = Reach::of(tx, px + col_off, py + row_off, width, height, fctx); |
| 1132 | if fixed != standalone { | 1135 | if fixed != standalone { |
| 1133 | - SPLIT_TU_REACH_FIX_HITS.with(|c| c.set(c.get() + 1)); | 1136 | + hit!(SPLIT_TU_REACH_FIX_HITS); |
| 1134 | } | 1137 | } |
| 1135 | fixed | 1138 | fixed |
| 1136 | } | 1139 | } |
| @@ -1252,7 +1255,7 @@ pub(crate) fn fwd_kf_hits() -> usize { | |||
| 1252 | 1255 | ||
| 1253 | /// Records one decoded forward keyframe (see [`FWD_KF_HITS`]). | 1256 | /// Records one decoded forward keyframe (see [`FWD_KF_HITS`]). |
| 1254 | pub(crate) fn note_fwd_kf() { | 1257 | pub(crate) fn note_fwd_kf() { |
| 1255 | - FWD_KF_HITS.with(|c| c.set(c.get() + 1)); | 1258 | + hit!(FWD_KF_HITS); |
| 1256 | } | 1259 | } |
| 1257 | 1260 | ||
| 1258 | // How many [`read_tx_size`] reads resolved a `tx_depth` strictly less than | 1261 | // How many [`read_tx_size`] reads resolved a `tx_depth` strictly less than |
| @@ -1459,11 +1462,13 @@ pub(crate) fn ab16_hits_by_arm() -> [usize; 4] { | |||
| 1459 | } | 1462 | } |
| 1460 | 1463 | ||
| 1461 | fn bump_ab16(arm: usize) { | 1464 | fn bump_ab16(arm: usize) { |
| 1462 | - AB16_HITS.with(|c| { | 1465 | + hit_do! { |
| 1463 | - let mut v = c.get(); | 1466 | + AB16_HITS.with(|c| { |
| 1464 | - v[arm] += 1; | 1467 | + let mut v = c.get(); |
| 1465 | - c.set(v); | 1468 | + v[arm] += 1; |
| 1466 | - }); | 1469 | + c.set(v); |
| 1470 | + }); | ||
| 1471 | + } | ||
| 1467 | } | 1472 | } |
| 1468 | 1473 | ||
| 1469 | // How many `partition_w16` reads resolved to a plain `PARTITION_HORZ`/ | 1474 | // How many `partition_w16` reads resolved to a plain `PARTITION_HORZ`/ |
| @@ -1511,11 +1516,13 @@ thread_local! { | |||
| 1511 | 1516 | ||
| 1512 | /// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`]. | 1517 | /// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`]. |
| 1513 | pub(crate) fn bump_inter_edge_strip(idx: usize) { | 1518 | pub(crate) fn bump_inter_edge_strip(idx: usize) { |
| 1514 | - INTER_EDGE_STRIP_HITS.with(|c| { | 1519 | + hit_do! { |
| 1515 | - let mut v = c.get(); | 1520 | + INTER_EDGE_STRIP_HITS.with(|c| { |
| 1516 | - v[idx] += 1; | 1521 | + let mut v = c.get(); |
| 1517 | - c.set(v); | 1522 | + v[idx] += 1; |
| 1518 | - }); | 1523 | + c.set(v); |
| 1524 | + }); | ||
| 1525 | + } | ||
| 1519 | } | 1526 | } |
| 1520 | 1527 | ||
| 1521 | // lane-edgeboth r1: how many partition nodes were coded as the BOTH-AXES-CUT | 1528 | // lane-edgeboth r1: how many partition nodes were coded as the BOTH-AXES-CUT |
| @@ -1529,11 +1536,13 @@ thread_local! { | |||
| 1529 | } | 1536 | } |
| 1530 | 1537 | ||
| 1531 | fn bump_edge_both_cut(level: usize) { | 1538 | fn bump_edge_both_cut(level: usize) { |
| 1532 | - EDGE_BOTH_CUT_HITS.with(|c| { | 1539 | + hit_do! { |
| 1533 | - let mut v = c.get(); | 1540 | + EDGE_BOTH_CUT_HITS.with(|c| { |
| 1534 | - v[level] += 1; | 1541 | + let mut v = c.get(); |
| 1535 | - c.set(v); | 1542 | + v[level] += 1; |
| 1536 | - }); | 1543 | + c.set(v); |
| 1544 | + }); | ||
| 1545 | + } | ||
| 1537 | } | 1546 | } |
| 1538 | 1547 | ||
| 1539 | /// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`). | 1548 | /// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`). |
| @@ -3480,7 +3489,7 @@ pub fn fimv_frame_hits() -> usize { | |||
| 3480 | /// Bump [`FIMV_FRAME_HITS`] -- called once per decoded frame header whose | 3489 | /// Bump [`FIMV_FRAME_HITS`] -- called once per decoded frame header whose |
| 3481 | /// `force_integer_mv` bit is set. | 3490 | /// `force_integer_mv` bit is set. |
| 3482 | pub fn note_force_integer_mv_frame() { | 3491 | pub fn note_force_integer_mv_frame() { |
| 3483 | - FIMV_FRAME_HITS.with(|c| c.set(c.get() + 1)); | 3492 | + hit!(FIMV_FRAME_HITS); |
| 3484 | } | 3493 | } |
| 3485 | 3494 | ||
| 3486 | /// Current value of [`OBMC_HITS`]. | 3495 | /// Current value of [`OBMC_HITS`]. |
| @@ -4311,11 +4320,13 @@ pub(crate) fn reset_edge_part_hits() { | |||
| 4311 | } | 4320 | } |
| 4312 | 4321 | ||
| 4313 | fn bump_edge_part(slot: usize) { | 4322 | fn bump_edge_part(slot: usize) { |
| 4314 | - EDGE_PART_HITS.with(|c| { | 4323 | + hit_do! { |
| 4315 | - let mut h = c.get(); | 4324 | + EDGE_PART_HITS.with(|c| { |
| 4316 | - h[slot] += 1; | 4325 | + let mut h = c.get(); |
| 4317 | - c.set(h); | 4326 | + h[slot] += 1; |
| 4318 | - }); | 4327 | + c.set(h); |
| 4328 | + }); | ||
| 4329 | + } | ||
| 4319 | } | 4330 | } |
| 4320 | 4331 | ||
| 4321 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 4332 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| @@ -4355,11 +4366,13 @@ fn bump_edge32_bit(base: usize, bit: usize) -> usize { | |||
| 4355 | } | 4366 | } |
| 4356 | 4367 | ||
| 4357 | fn bump_edge32(slot: usize) { | 4368 | fn bump_edge32(slot: usize) { |
| 4358 | - EDGE32_HITS.with(|c| { | 4369 | + hit_do! { |
| 4359 | - let mut h = c.get(); | 4370 | + EDGE32_HITS.with(|c| { |
| 4360 | - h[slot] += 1; | 4371 | + let mut h = c.get(); |
| 4361 | - c.set(h) | 4372 | + h[slot] += 1; |
| 4362 | - }); | 4373 | + c.set(h) |
| 4374 | + }); | ||
| 4375 | + } | ||
| 4363 | } | 4376 | } |
| 4364 | 4377 | ||
| 4365 | // lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/ | 4378 | // lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/ |
| @@ -4579,11 +4592,13 @@ pub(crate) struct InterStripChroma { | |||
| 4579 | /// last -- read by the next 1:4 strip to build its pair's chroma. | 4592 | /// last -- read by the next 1:4 strip to build its pair's chroma. |
| 4580 | 4593 | ||
| 4581 | fn bump_ab16_inter(arm: usize) { | 4594 | fn bump_ab16_inter(arm: usize) { |
| 4582 | - AB16_INTER_HITS.with(|c| { | 4595 | + hit_do! { |
| 4583 | - let mut v = c.get(); | 4596 | + AB16_INTER_HITS.with(|c| { |
| 4584 | - v[arm] += 1; | 4597 | + let mut v = c.get(); |
| 4585 | - c.set(v); | 4598 | + v[arm] += 1; |
| 4586 | - }); | 4599 | + c.set(v); |
| 4600 | + }); | ||
| 4601 | + } | ||
| 4587 | } | 4602 | } |
| 4588 | 4603 | ||
| 4589 | // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or | 4604 | // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or |
| @@ -5108,7 +5123,7 @@ pub fn sub8_chroma_tx_from_ref_hits() -> usize { | |||
| 5108 | 5123 | ||
| 5109 | fn note_sub8_chroma_tx(first_sub: TxType, chroma_ref: TxType, coeffs: bool) { | 5124 | fn note_sub8_chroma_tx(first_sub: TxType, chroma_ref: TxType, coeffs: bool) { |
| 5110 | if coeffs && first_sub != chroma_ref { | 5125 | if coeffs && first_sub != chroma_ref { |
| 5111 | - SUB8_CHROMA_TX_FROM_REF_HITS.with(|c| c.set(c.get() + 1)); | 5126 | + hit!(SUB8_CHROMA_TX_FROM_REF_HITS); |
| 5112 | } | 5127 | } |
| 5113 | } | 5128 | } |
| 5114 | 5129 | ||
| @@ -5186,7 +5201,7 @@ pub(crate) fn chroma_eob_class1_hits() -> usize { | |||
| 5186 | /// `tx_type` put this block's `eob_pt` on the class-1 row. | 5201 | /// `tx_type` put this block's `eob_pt` on the class-1 row. |
| 5187 | fn note_chroma_class1(plane_idx: usize, tx_type: TxType) { | 5202 | fn note_chroma_class1(plane_idx: usize, tx_type: TxType) { |
| 5188 | if plane_idx > 0 && TxClass::of(tx_type) != TxClass::TwoD { | 5203 | if plane_idx > 0 && TxClass::of(tx_type) != TxClass::TwoD { |
| 5189 | - CHROMA_EOB_CLASS1_HITS.with(|c| c.set(c.get() + 1)); | 5204 | + hit!(CHROMA_EOB_CLASS1_HITS); |
| 5190 | } | 5205 | } |
| 5191 | } | 5206 | } |
| 5192 | 5207 | ||
| @@ -5977,8 +5992,8 @@ fn read_coeffs( | |||
| 5977 | 5992 | ||
| 5978 | let class = TxClass::of(tx_type); | 5993 | let class = TxClass::of(tx_type); |
| 5979 | if class != TxClass::TwoD { | 5994 | if class != TxClass::TwoD { |
| 5980 | - TX_CLASS1_HITS.with(|c| c.set(c.get() + 1)); | 5995 | + hit!(TX_CLASS1_HITS); |
| 5981 | - RECT_CLASS1_HITS.with(|c| c.set(c.get() + 1)); | 5996 | + hit!(RECT_CLASS1_HITS); |
| 5982 | } | 5997 | } |
| 5983 | let eob = read_eob(dec, coding, class); | 5998 | let eob = read_eob(dec, coding, class); |
| 5984 | if trace { | 5999 | if trace { |
| @@ -6161,7 +6176,7 @@ fn read_coeffs_rect( | |||
| 6161 | return Ok((Grid::Zero(w * h), TxType::DctDct)); | 6176 | return Ok((Grid::Zero(w * h), TxType::DctDct)); |
| 6162 | } | 6177 | } |
| 6163 | let mut grid = vec![0i32; w * h]; | 6178 | let mut grid = vec![0i32; w * h]; |
| 6164 | - RECT_COEFF_TU_HITS.with(|c| c.set(c.get() + 1)); | 6179 | + hit!(RECT_COEFF_TU_HITS); |
| 6165 | // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is | 6180 | // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is |
| 6166 | // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including | 6181 | // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including |
| 6167 | // the `V_DCT`/`H_DCT` members whose 1D tx class needs its own scan and | 6182 | // the `V_DCT`/`H_DCT` members whose 1D tx class needs its own scan and |
| @@ -6180,7 +6195,7 @@ fn read_coeffs_rect( | |||
| 6180 | } | 6195 | } |
| 6181 | let class = TxClass::of(tx_type); | 6196 | let class = TxClass::of(tx_type); |
| 6182 | if class != TxClass::TwoD { | 6197 | if class != TxClass::TwoD { |
| 6183 | - TX_CLASS1_HITS.with(|c| c.set(c.get() + 1)); | 6198 | + hit!(TX_CLASS1_HITS); |
| 6184 | } | 6199 | } |
| 6185 | let eob = read_eob(dec, coding, class); | 6200 | let eob = read_eob(dec, coding, class); |
| 6186 | if rect_trace { | 6201 | if rect_trace { |
| @@ -7077,7 +7092,7 @@ impl Neighbours { | |||
| 7077 | fn fill_skip_grid_rect(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize, skip: bool) { | 7092 | fn fill_skip_grid_rect(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize, skip: bool) { |
| 7078 | let (mi_r, mi_c) = at_mi; | 7093 | let (mi_r, mi_c) = at_mi; |
| 7079 | if skip && w_mi != h_mi { | 7094 | if skip && w_mi != h_mi { |
| 7080 | - RECT_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | 7095 | + hit!(RECT_SKIP_BAND_HITS); |
| 7081 | } | 7096 | } |
| 7082 | for rr in 0..h_mi { | 7097 | for rr in 0..h_mi { |
| 7083 | let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c; | 7098 | let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c; |
| @@ -7626,7 +7641,7 @@ impl Neighbours { | |||
| 7626 | if self.tile_row0_mi > 0 && !have_above && self.above_uv_mode[c] != DC_PRED | 7641 | if self.tile_row0_mi > 0 && !have_above && self.above_uv_mode[c] != DC_PRED |
| 7627 | || self.tile_col0_mi > 0 && !have_left && self.left_uv_mode[r] != DC_PRED | 7642 | || self.tile_col0_mi > 0 && !have_left && self.left_uv_mode[r] != DC_PRED |
| 7628 | { | 7643 | { |
| 7629 | - UV_TILE_EDGE_SUPPRESSED_HITS.with(|h| h.set(h.get() + 1)); | 7644 | + hit!(UV_TILE_EDGE_SUPPRESSED_HITS); |
| 7630 | } | 7645 | } |
| 7631 | // The mi grid is libaom's own read; the two maps below stay as the | 7646 | // The mi grid is libaom's own read; the two maps below stay as the |
| 7632 | // fallback for cells no block has written (see [`Self::uv_mode_grid`]). | 7647 | // fallback for cells no block has written (see [`Self::uv_mode_grid`]). |
| @@ -7654,18 +7669,18 @@ impl Neighbours { | |||
| 7654 | }) || have_left && cell(&self.uv_mode_grid, mi_r, mi_c - 1).is_some_and(|m| { | 7669 | }) || have_left && cell(&self.uv_mode_grid, mi_r, mi_c - 1).is_some_and(|m| { |
| 7655 | !matches!(self.uv_mode_row.get(mi_r), Some(&(col, cm)) if usize::from(col) == mi_c - 1 && usize::from(cm) == m) | 7670 | !matches!(self.uv_mode_row.get(mi_r), Some(&(col, cm)) if usize::from(col) == mi_c - 1 && usize::from(cm) == m) |
| 7656 | }) { | 7671 | }) { |
| 7657 | - UV_MODE_GRID_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); | 7672 | + hit!(UV_MODE_GRID_OVERRIDE_HITS); |
| 7658 | } | 7673 | } |
| 7659 | // lane-cfl r1 counter: how often the mi-exact chroma neighbour differs | 7674 | // lane-cfl r1 counter: how often the mi-exact chroma neighbour differs |
| 7660 | // from the coarse [`SUB`] slot -- i.e. how often a chroma edge would | 7675 | // from the coarse [`SUB`] slot -- i.e. how often a chroma edge would |
| 7661 | // have been filtered at the wrong strength by the coarse map alone. | 7676 | // have been filtered at the wrong strength by the coarse map alone. |
| 7662 | if above != self.above_uv_mode[c] || left != self.left_uv_mode[r] { | 7677 | if above != self.above_uv_mode[c] || left != self.left_uv_mode[r] { |
| 7663 | - UV_MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); | 7678 | + hit!(UV_MODE_MI_OVERRIDE_HITS); |
| 7664 | } | 7679 | } |
| 7665 | if (is_smooth_mode(self.above_uv_mode[c]) && !is_smooth_mode(above)) | 7680 | if (is_smooth_mode(self.above_uv_mode[c]) && !is_smooth_mode(above)) |
| 7666 | || (is_smooth_mode(self.left_uv_mode[r]) && !is_smooth_mode(left)) | 7681 | || (is_smooth_mode(self.left_uv_mode[r]) && !is_smooth_mode(left)) |
| 7667 | { | 7682 | { |
| 7668 | - INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|h| h.set(h.get() + 1)); | 7683 | + hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS); |
| 7669 | } | 7684 | } |
| 7670 | is_smooth_mode(above) || is_smooth_mode(left) | 7685 | is_smooth_mode(above) || is_smooth_mode(left) |
| 7671 | } | 7686 | } |
| @@ -7720,19 +7735,19 @@ impl Neighbours { | |||
| 7720 | let (above, left) = | 7735 | let (above, left) = |
| 7721 | self.modes_above_left_mi(mi_r, mi_c, (self.above_mode[c], self.left_mode[r])); | 7736 | self.modes_above_left_mi(mi_r, mi_c, (self.above_mode[c], self.left_mode[r])); |
| 7722 | if above != self.above_mode[c] || left != self.left_mode[r] { | 7737 | if above != self.above_mode[c] || left != self.left_mode[r] { |
| 7723 | - MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); | 7738 | + hit!(MODE_MI_OVERRIDE_HITS); |
| 7724 | } | 7739 | } |
| 7725 | if (is_smooth_mode(self.above_mode[c]) && !is_smooth_mode(above)) | 7740 | if (is_smooth_mode(self.above_mode[c]) && !is_smooth_mode(above)) |
| 7726 | || (is_smooth_mode(self.left_mode[r]) && !is_smooth_mode(left)) | 7741 | || (is_smooth_mode(self.left_mode[r]) && !is_smooth_mode(left)) |
| 7727 | { | 7742 | { |
| 7728 | - INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|h| h.set(h.get() + 1)); | 7743 | + hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS); |
| 7729 | } | 7744 | } |
| 7730 | // A neighbour the coarse band offered where the tile edge makes it | 7745 | // A neighbour the coarse band offered where the tile edge makes it |
| 7731 | // unavailable -- must never happen (see `MODE_TILE_EDGE_COARSE_LEAKS`). | 7746 | // unavailable -- must never happen (see `MODE_TILE_EDGE_COARSE_LEAKS`). |
| 7732 | if (mi_r <= self.tile_row0_mi && self.above_mode[c] != DC_PRED) | 7747 | if (mi_r <= self.tile_row0_mi && self.above_mode[c] != DC_PRED) |
| 7733 | || (mi_c <= self.tile_col0_mi && self.left_mode[r] != DC_PRED) | 7748 | || (mi_c <= self.tile_col0_mi && self.left_mode[r] != DC_PRED) |
| 7734 | { | 7749 | { |
| 7735 | - MODE_TILE_EDGE_COARSE_LEAKS.with(|h| h.set(h.get() + 1)); | 7750 | + hit!(MODE_TILE_EDGE_COARSE_LEAKS); |
| 7736 | } | 7751 | } |
| 7737 | (above, left) | 7752 | (above, left) |
| 7738 | } | 7753 | } |
| @@ -8511,7 +8526,7 @@ fn read_intra_mode_rect( | |||
| 8511 | // offer the 14-symbol CFL alphabet on a 64-axis block (class | 8526 | // offer the 14-symbol CFL alphabet on a 64-axis block (class |
| 8512 | // wrong-alphabet-same-value: same value, wrong interval, silent desync). | 8527 | // wrong-alphabet-same-value: same value, wrong interval, silent desync). |
| 8513 | let cfl = if cfl && bw.max(bh) > 32 { | 8528 | let cfl = if cfl && bw.max(bh) > 32 { |
| 8514 | - NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1)); | 8529 | + hit!(NOCFL_UV_MODE_HITS); |
| 8515 | false | 8530 | false |
| 8516 | } else { | 8531 | } else { |
| 8517 | cfl | 8532 | cfl |
| @@ -8553,10 +8568,10 @@ fn read_intra_mode_rect( | |||
| 8553 | // refused by name when it fires. | 8568 | // refused by name when it fires. |
| 8554 | if allow_intrabc_frame(fctx) { | 8569 | if allow_intrabc_frame(fctx) { |
| 8555 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; | 8570 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; |
| 8556 | - RECT_INTRABC_READS.with(|c| c.set(c.get() + 1)); | 8571 | + hit!(RECT_INTRABC_READS); |
| 8557 | istep!("intrabc", use_intrabc as i32); | 8572 | istep!("intrabc", use_intrabc as i32); |
| 8558 | if use_intrabc { | 8573 | if use_intrabc { |
| 8559 | - INTRABC_HITS.with(|c| c.set(c.get() + 1)); | 8574 | + hit!(INTRABC_HITS); |
| 8560 | return Err(unsupported( | 8575 | return Err(unsupported( |
| 8561 | "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", | 8576 | "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", |
| 8562 | )); | 8577 | )); |
| @@ -8603,17 +8618,17 @@ fn read_intra_mode_rect( | |||
| 8603 | None | 8618 | None |
| 8604 | }; | 8619 | }; |
| 8605 | if has_chroma && (9..=12).contains(&uv_mode) { | 8620 | if has_chroma && (9..=12).contains(&uv_mode) { |
| 8606 | - SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | 8621 | + hit!(SMOOTH_UV_HITS); |
| 8607 | } | 8622 | } |
| 8608 | let angle_delta_uv = if has_chroma && (V_PRED..=D67_PRED).contains(&uv_mode) { | 8623 | let angle_delta_uv = if has_chroma && (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 8609 | - DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); | 8624 | + hit!(DIRECTIONAL_UV_HITS); |
| 8610 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | 8625 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 8611 | } else { | 8626 | } else { |
| 8612 | 0 | 8627 | 0 |
| 8613 | }; | 8628 | }; |
| 8614 | istep!("angle_uv", angle_delta_uv); | 8629 | istep!("angle_uv", angle_delta_uv); |
| 8615 | if angle_delta_uv != 0 { | 8630 | if angle_delta_uv != 0 { |
| 8616 | - UV_ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1)); | 8631 | + hit!(UV_ANGLE_DELTA_HITS); |
| 8617 | } | 8632 | } |
| 8618 | // `read_palette_mode_info` (spec 5.11.13), rect-generalised | 8633 | // `read_palette_mode_info` (spec 5.11.13), rect-generalised |
| 8619 | // (lane-palette2 r4): same bsize-ctx-gated read as [`read_intra_mode`], | 8634 | // (lane-palette2 r4): same bsize-ctx-gated read as [`read_intra_mode`], |
| @@ -8630,7 +8645,7 @@ fn read_intra_mode_rect( | |||
| 8630 | // r6: this is the exact site the removed blanket refusal used to | 8645 | // r6: this is the exact site the removed blanket refusal used to |
| 8631 | // guard -- reached for EVERY rect strip in a screen-content frame, | 8646 | // guard -- reached for EVERY rect strip in a screen-content frame, |
| 8632 | // independent of whether the block ends up using a palette. | 8647 | // independent of whether the block ends up using a palette. |
| 8633 | - RECT_SCREEN_CONTENT_HITS.with(|c| c.set(c.get() + 1)); | 8648 | + hit!(RECT_SCREEN_CONTENT_HITS); |
| 8634 | let (mode_ctx, cache) = palette.unwrap_or((0, &[])); | 8649 | let (mode_ctx, cache) = palette.unwrap_or((0, &[])); |
| 8635 | let use_palette_y = | 8650 | let use_palette_y = |
| 8636 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][mode_ctx]) != 0; | 8651 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][mode_ctx]) != 0; |
| @@ -8673,7 +8688,7 @@ fn read_intra_mode_rect( | |||
| 8673 | } | 8688 | } |
| 8674 | istep!("use_filter_intra", use_filter_intra as i32); | 8689 | istep!("use_filter_intra", use_filter_intra as i32); |
| 8675 | if use_filter_intra { | 8690 | if use_filter_intra { |
| 8676 | - FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | 8691 | + hit!(FILTER_INTRA_HITS); |
| 8677 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); | 8692 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 8678 | istep!("filter_intra_mode", fi_mode as i32); | 8693 | istep!("filter_intra_mode", fi_mode as i32); |
| 8679 | filter_intra = Some(fi_mode); | 8694 | filter_intra = Some(fi_mode); |
| @@ -8683,8 +8698,8 @@ fn read_intra_mode_rect( | |||
| 8683 | // same order as [`read_intra_mode`]'s own square path. | 8698 | // same order as [`read_intra_mode`]'s own square path. |
| 8684 | let palette_y = palette_y_pending.map(|(n, colors)| { | 8699 | let palette_y = palette_y_pending.map(|(n, colors)| { |
| 8685 | let map = decode_color_index_map_wh(dec, cdfs, n, bw, bh, false); | 8700 | let map = decode_color_index_map_wh(dec, cdfs, n, bw, bh, false); |
| 8686 | - PALETTE_HITS.with(|c| c.set(c.get() + 1)); | 8701 | + hit!(PALETTE_HITS); |
| 8687 | - PALETTE_RECT_HITS.with(|c| c.set(c.get() + 1)); | 8702 | + hit!(PALETTE_RECT_HITS); |
| 8688 | PaletteY { size: n, colors, map } | 8703 | PaletteY { size: n, colors, map } |
| 8689 | }); | 8704 | }); |
| 8690 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { | 8705 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { |
| @@ -8695,7 +8710,7 @@ fn read_intra_mode_rect( | |||
| 8695 | // chroma palette and desynced the tile from there. | 8710 | // chroma palette and desynced the tile from there. |
| 8696 | let (cw, ch) = ((bw / 2).max(4), (bh / 2).max(4)); | 8711 | let (cw, ch) = ((bw / 2).max(4), (bh / 2).max(4)); |
| 8697 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, true); | 8712 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, true); |
| 8698 | - PALETTE_UV_HITS.with(|c| c.set(c.get() + 1)); | 8713 | + hit!(PALETTE_UV_HITS); |
| 8699 | PaletteUv { size: n, u_colors, v_colors, map } | 8714 | PaletteUv { size: n, u_colors, v_colors, map } |
| 8700 | }); | 8715 | }); |
| 8701 | Ok(( | 8716 | Ok(( |
| @@ -8948,11 +8963,13 @@ fn decode_rect_split( | |||
| 8948 | (4, 8) => Some(3), | 8963 | (4, 8) => Some(3), |
| 8949 | _ => None, | 8964 | _ => None, |
| 8950 | } { | 8965 | } { |
| 8951 | - RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| { | 8966 | + hit_do! { |
| 8952 | - let mut hits = c.get(); | 8967 | + RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| { |
| 8953 | - hits[i] += 1; | 8968 | + let mut hits = c.get(); |
| 8954 | - c.set(hits); | 8969 | + hits[i] += 1; |
| 8955 | - }); | 8970 | + c.set(hits); |
| 8971 | + }); | ||
| 8972 | + } | ||
| 8956 | } | 8973 | } |
| 8957 | if chroma.is_none() { | 8974 | if chroma.is_none() { |
| 8958 | // Diagnostic for the next caller that lands here (class | 8975 | // Diagnostic for the next caller that lands here (class |
| @@ -8973,9 +8990,9 @@ fn decode_rect_split( | |||
| 8973 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", | 8990 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 8974 | )); | 8991 | )); |
| 8975 | } | 8992 | } |
| 8976 | - RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 8993 | + hit!(RECT_SPLIT_TX_HITS); |
| 8977 | if bw.max(bh) == 64 && bw / tx_w > 1 && bh / tx_h > 1 { | 8994 | if bw.max(bh) == 64 && bw / tx_w > 1 && bh / tx_h > 1 { |
| 8978 | - RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.set(c.get() + 1)); | 8995 | + hit!(RECT_SPLIT_SB_INTERIOR_TU_HITS); |
| 8979 | } | 8996 | } |
| 8980 | // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. | 8997 | // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. |
| 8981 | // A square unit reads through the ordinary square [`read_plane`]; a rect | 8998 | // A square unit reads through the ordinary square [`read_plane`]; a rect |
| @@ -9102,11 +9119,13 @@ fn decode_rect_split( | |||
| 9102 | if crate::envflags::env_flag!("EC_RECT64TU") { | 9119 | if crate::envflags::env_flag!("EC_RECT64TU") { |
| 9103 | eprintln!("EC_RECT64TU mi={tu_mi:?} tx={tx_w}x{tx_h} mode={}", m.mode); | 9120 | eprintln!("EC_RECT64TU mi={tu_mi:?} tx={tx_w}x{tx_h} mode={}", m.mode); |
| 9104 | } | 9121 | } |
| 9105 | - RECT64_CORNER_TU_HITS.with(|c| { | 9122 | + hit_do! { |
| 9106 | - let mut v = c.get(); | 9123 | + RECT64_CORNER_TU_HITS.with(|c| { |
| 9107 | - v[usize::from(tx_h > tx_w)] += 1; | 9124 | + let mut v = c.get(); |
| 9108 | - c.set(v); | 9125 | + v[usize::from(tx_h > tx_w)] += 1; |
| 9109 | - }); | 9126 | + c.set(v); |
| 9127 | + }); | ||
| 9128 | + } | ||
| 9110 | let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; | 9129 | let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; |
| 9111 | let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra)); | 9130 | let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra)); |
| 9112 | let (corner, tu_tx_type) = read_coeffs( | 9131 | let (corner, tu_tx_type) = read_coeffs( |
| @@ -9286,7 +9305,7 @@ fn decode_rect_split( | |||
| 9286 | // superblock strips onto this path, so only counting there would | 9305 | // superblock strips onto this path, so only counting there would |
| 9287 | // leave the delta_q gate's counter silent for them). | 9306 | // leave the delta_q gate's counter silent for them). |
| 9288 | if bw.max(bh) == 64 && fctx.current_q_idx.with(|c| c.get()) != i32::from(base_q_idx) { | 9307 | if bw.max(bh) == 64 && fctx.current_q_idx.with(|c| c.get()) != i32::from(base_q_idx) { |
| 9289 | - RECT64_QIDX_DRIFT_HITS.with(|c| c.set(c.get() + 1)); | 9308 | + hit!(RECT64_QIDX_DRIFT_HITS); |
| 9290 | } | 9309 | } |
| 9291 | let residual = dequant_and_inverse_typed_wh( | 9310 | let residual = dequant_and_inverse_typed_wh( |
| 9292 | &levels, | 9311 | &levels, |
| @@ -9634,12 +9653,14 @@ fn decode_intra_rect_in_inter( | |||
| 9634 | mi_r * MI | 9653 | mi_r * MI |
| 9635 | ); | 9654 | ); |
| 9636 | } | 9655 | } |
| 9637 | - INTRA16X4_IN_INTER_HITS.with(|h| { | 9656 | + hit_do! { |
| 9638 | - let mut v = h.get(); | 9657 | + INTRA16X4_IN_INTER_HITS.with(|h| { |
| 9639 | - v[usize::from(!horz)] += 1; | 9658 | + let mut v = h.get(); |
| 9640 | - v[2] += usize::from(has_chroma); | 9659 | + v[usize::from(!horz)] += 1; |
| 9641 | - h.set(v); | 9660 | + v[2] += usize::from(has_chroma); |
| 9642 | - }); | 9661 | + h.set(v); |
| 9662 | + }); | ||
| 9663 | + } | ||
| 9643 | return Ok(()); | 9664 | return Ok(()); |
| 9644 | } | 9665 | } |
| 9645 | // lane-inter128intra r1: the 128 superblock's PARTITION_HORZ/VERT half | 9666 | // lane-inter128intra r1: the 128 superblock's PARTITION_HORZ/VERT half |
| @@ -9786,11 +9807,13 @@ fn decode_intra_rect_in_inter( | |||
| 9786 | (32, 8) => 2, | 9807 | (32, 8) => 2, |
| 9787 | _ => 3, | 9808 | _ => 3, |
| 9788 | }; | 9809 | }; |
| 9789 | - INTRA_RECT4_IN_INTER_HITS.with(|h| { | 9810 | + hit_do! { |
| 9790 | - let mut v = h.get(); | 9811 | + INTRA_RECT4_IN_INTER_HITS.with(|h| { |
| 9791 | - v[shape] += 1; | 9812 | + let mut v = h.get(); |
| 9792 | - h.set(v); | 9813 | + v[shape] += 1; |
| 9793 | - }); | 9814 | + h.set(v); |
| 9815 | + }); | ||
| 9816 | + } | ||
| 9794 | return Ok(()); | 9817 | return Ok(()); |
| 9795 | } | 9818 | } |
| 9796 | let mode = dec.symbol(&mut cdfs.y_mode[size_group]); | 9819 | let mode = dec.symbol(&mut cdfs.y_mode[size_group]); |
| @@ -9818,7 +9841,7 @@ fn decode_intra_rect_in_inter( | |||
| 9818 | 0 | 9841 | 0 |
| 9819 | }; | 9842 | }; |
| 9820 | if angle_delta_y != 0 { | 9843 | if angle_delta_y != 0 { |
| 9821 | - INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.set(c.get() + 1)); | 9844 | + hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS); |
| 9822 | } | 9845 | } |
| 9823 | // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the | 9846 | // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the |
| 9824 | // superblock-level strip reads the no-CFL alphabet -- the same split | 9847 | // superblock-level strip reads the no-CFL alphabet -- the same split |
| @@ -9837,7 +9860,7 @@ fn decode_intra_rect_in_inter( | |||
| 9837 | ); | 9860 | ); |
| 9838 | } | 9861 | } |
| 9839 | if (9..=12).contains(&uv_mode) { | 9862 | if (9..=12).contains(&uv_mode) { |
| 9840 | - SMOOTH_UV_HITS.with(|h| h.set(h.get() + 1)); | 9863 | + hit!(SMOOTH_UV_HITS); |
| 9841 | } | 9864 | } |
| 9842 | let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { | 9865 | let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { |
| 9843 | Some(read_cfl_alphas(dec, cdfs)) | 9866 | Some(read_cfl_alphas(dec, cdfs)) |
| @@ -9850,14 +9873,14 @@ fn decode_intra_rect_in_inter( | |||
| 9850 | uv_mode | 9873 | uv_mode |
| 9851 | }; | 9874 | }; |
| 9852 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { | 9875 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 9853 | - DIRECTIONAL_UV_HITS.with(|h| h.set(h.get() + 1)); | 9876 | + hit!(DIRECTIONAL_UV_HITS); |
| 9854 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | 9877 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 9855 | } else { | 9878 | } else { |
| 9856 | 0 | 9879 | 0 |
| 9857 | }; | 9880 | }; |
| 9858 | if angle_delta_uv != 0 { | 9881 | if angle_delta_uv != 0 { |
| 9859 | - UV_ANGLE_DELTA_HITS.with(|h| h.set(h.get() + 1)); | 9882 | + hit!(UV_ANGLE_DELTA_HITS); |
| 9860 | - INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|h| h.set(h.get() + 1)); | 9883 | + hit!(INTRA_IN_INTER_ANGLE_DELTA_UV_HITS); |
| 9861 | } | 9884 | } |
| 9862 | // `read_palette_mode_info` (spec 5.11.13), in the position | 9885 | // `read_palette_mode_info` (spec 5.11.13), in the position |
| 9863 | // `read_intra_block_mode_info` writes it: after the chroma mode and | 9886 | // `read_intra_block_mode_info` writes it: after the chroma mode and |
| @@ -9876,7 +9899,7 @@ fn decode_intra_rect_in_inter( | |||
| 9876 | if allow_screen_content_tools | 9899 | if allow_screen_content_tools |
| 9877 | && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh) | 9900 | && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh) |
| 9878 | { | 9901 | { |
| 9879 | - INTRA_RECT_IN_INTER_SCREEN_HITS.with(|c| c.set(c.get() + 1)); | 9902 | + hit!(INTRA_RECT_IN_INTER_SCREEN_HITS); |
| 9880 | let use_palette_y = | 9903 | let use_palette_y = |
| 9881 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0; | 9904 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0; |
| 9882 | if use_palette_y { | 9905 | if use_palette_y { |
| @@ -9910,23 +9933,23 @@ fn decode_intra_rect_in_inter( | |||
| 9910 | && let Some(class) = filter_intra_size_class_rect(bw, bh) | 9933 | && let Some(class) = filter_intra_size_class_rect(bw, bh) |
| 9911 | && dec.symbol(&mut cdfs.filter_intra[class]) != 0 | 9934 | && dec.symbol(&mut cdfs.filter_intra[class]) != 0 |
| 9912 | { | 9935 | { |
| 9913 | - FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1)); | 9936 | + hit!(FILTER_INTRA_HITS); |
| 9914 | - INTRA_IN_INTER_FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1)); | 9937 | + hit!(INTRA_IN_INTER_FILTER_INTRA_HITS); |
| 9915 | filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); | 9938 | filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); |
| 9916 | } | 9939 | } |
| 9917 | // `av1_visit_palette`: Y's colour-index map then the shared chroma one. | 9940 | // `av1_visit_palette`: Y's colour-index map then the shared chroma one. |
| 9918 | let palette_y = palette_y_pending.map(|(n, colors)| { | 9941 | let palette_y = palette_y_pending.map(|(n, colors)| { |
| 9919 | let map = decode_color_index_map_wh(dec, cdfs, n, bw, bh, false); | 9942 | let map = decode_color_index_map_wh(dec, cdfs, n, bw, bh, false); |
| 9920 | - PALETTE_HITS.with(|c| c.set(c.get() + 1)); | 9943 | + hit!(PALETTE_HITS); |
| 9921 | - PALETTE_RECT_HITS.with(|c| c.set(c.get() + 1)); | 9944 | + hit!(PALETTE_RECT_HITS); |
| 9922 | - INTRA_IN_INTER_PALETTE_Y_HITS.with(|c| c.set(c.get() + 1)); | 9945 | + hit!(INTRA_IN_INTER_PALETTE_Y_HITS); |
| 9923 | PaletteY { size: n, colors, map } | 9946 | PaletteY { size: n, colors, map } |
| 9924 | }); | 9947 | }); |
| 9925 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { | 9948 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { |
| 9926 | let (cw, ch) = ((bw / 2).max(4), (bh / 2).max(4)); | 9949 | let (cw, ch) = ((bw / 2).max(4), (bh / 2).max(4)); |
| 9927 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, true); | 9950 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, true); |
| 9928 | - PALETTE_UV_HITS.with(|c| c.set(c.get() + 1)); | 9951 | + hit!(PALETTE_UV_HITS); |
| 9929 | - INTRA_IN_INTER_PALETTE_UV_HITS.with(|c| c.set(c.get() + 1)); | 9952 | + hit!(INTRA_IN_INTER_PALETTE_UV_HITS); |
| 9930 | PaletteUv { size: n, u_colors, v_colors, map } | 9953 | PaletteUv { size: n, u_colors, v_colors, map } |
| 9931 | }); | 9954 | }); |
| 9932 | // The intra-edge filter type is the NEIGHBOUR's mode (libaom | 9955 | // The intra-edge filter type is the NEIGHBOUR's mode (libaom |
| @@ -9941,11 +9964,11 @@ fn decode_intra_rect_in_inter( | |||
| 9941 | let coarse_pair = neighbours.modes_above_left(r, c); | 9964 | let coarse_pair = neighbours.modes_above_left(r, c); |
| 9942 | let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left_mi(mi_r, mi_c, coarse_pair); | 9965 | let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left_mi(mi_r, mi_c, coarse_pair); |
| 9943 | if (nb_above_mode, nb_left_mode) != coarse_pair { | 9966 | if (nb_above_mode, nb_left_mode) != coarse_pair { |
| 9944 | - EDGE_FILTER_MI_FIX_HITS.with(|c| c.set(c.get() + 1)); | 9967 | + hit!(EDGE_FILTER_MI_FIX_HITS); |
| 9945 | } | 9968 | } |
| 9946 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | 9969 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 9947 | if smooth_neighbor { | 9970 | if smooth_neighbor { |
| 9948 | - SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1)); | 9971 | + hit!(SMOOTH_LUMA_HITS); |
| 9949 | } | 9972 | } |
| 9950 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); | 9973 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); |
| 9951 | let depth = if fctx.tx_select_inter.with(std::cell::Cell::get) { | 9974 | let depth = if fctx.tx_select_inter.with(std::cell::Cell::get) { |
| @@ -9968,15 +9991,17 @@ fn decode_intra_rect_in_inter( | |||
| 9968 | 0 | 9991 | 0 |
| 9969 | }; | 9992 | }; |
| 9970 | if depth != 0 { | 9993 | if depth != 0 { |
| 9971 | - TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); | 9994 | + hit!(TX_DEPTH_HITS); |
| 9972 | // lane-intrasplit r1: a split intra strip in an inter frame walks the | 9995 | // lane-intrasplit r1: a split intra strip in an inter frame walks the |
| 9973 | // key frame's own per-TU path ([`decode_rect_split`] below); what was | 9996 | // key frame's own per-TU path ([`decode_rect_split`] below); what was |
| 9974 | // wrong when this refusal was written was the depth SYMBOL, not the walk. | 9997 | // wrong when this refusal was written was the depth SYMBOL, not the walk. |
| 9975 | - INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(|h| { | 9998 | + hit_do! { |
| 9976 | - let mut v = h.get(); | 9999 | + INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(|h| { |
| 9977 | - v[depth.min(2)] += 1; | 10000 | + let mut v = h.get(); |
| 9978 | - h.set(v); | 10001 | + v[depth.min(2)] += 1; |
| 9979 | - }); | 10002 | + h.set(v); |
| 10003 | + }); | ||
| 10004 | + } | ||
| 9980 | } | 10005 | } |
| 9981 | // lane-intrasplit r3: print EVERY intra strip with its depth, not only the | 10006 | // lane-intrasplit r3: print EVERY intra strip with its depth, not only the |
| 9982 | // split ones -- a `depth=0`-only stream is a witness gap in the SOURCE, and | 10007 | // split ones -- a `depth=0`-only stream is a witness gap in the SOURCE, and |
| @@ -10064,11 +10089,13 @@ fn decode_intra_rect_in_inter( | |||
| 10064 | 32 => 1, | 10089 | 32 => 1, |
| 10065 | _ => 2, | 10090 | _ => 2, |
| 10066 | }; | 10091 | }; |
| 10067 | - INTRA_RECT_IN_INTER_HITS.with(|h| { | 10092 | + hit_do! { |
| 10068 | - let mut v = h.get(); | 10093 | + INTRA_RECT_IN_INTER_HITS.with(|h| { |
| 10069 | - v[class] += 1; | 10094 | + let mut v = h.get(); |
| 10070 | - h.set(v); | 10095 | + v[class] += 1; |
| 10071 | - }); | 10096 | + h.set(v); |
| 10097 | + }); | ||
| 10098 | + } | ||
| 10072 | Ok(()) | 10099 | Ok(()) |
| 10073 | } | 10100 | } |
| 10074 | 10101 | ||
| @@ -10124,7 +10151,7 @@ fn decode_block_rect( | |||
| 10124 | )?; | 10151 | )?; |
| 10125 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | 10152 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 10126 | if smooth_neighbor { | 10153 | if smooth_neighbor { |
| 10127 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 10154 | + hit!(SMOOTH_LUMA_HITS); |
| 10128 | } | 10155 | } |
| 10129 | // lane-chroma r3: chroma's own edge-filter-strength neighbour check | 10156 | // lane-chroma r3: chroma's own edge-filter-strength neighbour check |
| 10130 | // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's | 10157 | // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's |
| @@ -10137,7 +10164,7 @@ fn decode_block_rect( | |||
| 10137 | // predicts instead of refusing. The below-16x16 leaf arm | 10164 | // predicts instead of refusing. The below-16x16 leaf arm |
| 10138 | // (`decode_leaf_rect`) keeps the refusal: it has no gate of its own. | 10165 | // (`decode_leaf_rect`) keeps the refusal: it has no gate of its own. |
| 10139 | if filter_intra.is_some() { | 10166 | if filter_intra.is_some() { |
| 10140 | - FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | 10167 | + hit!(FILTER_INTRA_RECT_HITS); |
| 10141 | } | 10168 | } |
| 10142 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { | 10169 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 10143 | DC_PRED | 10170 | DC_PRED |
| @@ -10177,7 +10204,7 @@ fn decode_block_rect( | |||
| 10177 | 0 | 10204 | 0 |
| 10178 | }; | 10205 | }; |
| 10179 | if depth != 0 { | 10206 | if depth != 0 { |
| 10180 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | 10207 | + hit!(TX_DEPTH_HITS); |
| 10181 | // lane-rectsplit r1: a split transform is predicted and reconstructed | 10208 | // lane-rectsplit r1: a split transform is predicted and reconstructed |
| 10182 | // per transform unit, each unit taking its edges from the previous | 10209 | // per transform unit, each unit taking its edges from the previous |
| 10183 | // unit's reconstruction inside this same strip (spec 5.11.36) -- | 10210 | // unit's reconstruction inside this same strip (spec 5.11.36) -- |
| @@ -10211,7 +10238,7 @@ fn decode_block_rect( | |||
| 10211 | }), | 10238 | }), |
| 10212 | }; | 10239 | }; |
| 10213 | if palette_y.is_some() || palette_uv.is_some() { | 10240 | if palette_y.is_some() || palette_uv.is_some() { |
| 10214 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 10241 | + hit!(PALETTE_SPLIT_TX_HITS); |
| 10215 | } | 10242 | } |
| 10216 | decode_rect_split( | 10243 | decode_rect_split( |
| 10217 | dec, | 10244 | dec, |
| @@ -10241,7 +10268,7 @@ fn decode_block_rect( | |||
| 10241 | let (puv_size, puv_colors) = | 10268 | let (puv_size, puv_colors) = |
| 10242 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 10269 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 10243 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); | 10270 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); |
| 10244 | - RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | 10271 | + hit!(RECT_PARTITION_HITS); |
| 10245 | return Ok(()); | 10272 | return Ok(()); |
| 10246 | } | 10273 | } |
| 10247 | let (tx_w, tx_h) = (bw, bh); | 10274 | let (tx_w, tx_h) = (bw, bh); |
| @@ -10501,7 +10528,7 @@ fn decode_block_rect( | |||
| 10501 | smooth_neighbor_uv, fctx, | 10528 | smooth_neighbor_uv, fctx, |
| 10502 | ); | 10529 | ); |
| 10503 | neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[&luma_levels[..], &u_levels[..], &v_levels[..]]); | 10530 | neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[&luma_levels[..], &u_levels[..], &v_levels[..]]); |
| 10504 | - RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); | 10531 | + hit!(RECT_COEFF_HITS); |
| 10505 | } | 10532 | } |
| 10506 | } | 10533 | } |
| 10507 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | 10534 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| @@ -10511,7 +10538,7 @@ fn decode_block_rect( | |||
| 10511 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); | 10538 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); |
| 10512 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); | 10539 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); |
| 10513 | neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0, fctx); | 10540 | neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0, fctx); |
| 10514 | - RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | 10541 | + hit!(RECT_PARTITION_HITS); |
| 10515 | if crate::envflags::env_flag!("EC_AV1_TRACE") { | 10542 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| 10516 | eprintln!("TRACE_RECT32_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh}"); | 10543 | eprintln!("TRACE_RECT32_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh}"); |
| 10517 | } | 10544 | } |
| @@ -10586,7 +10613,7 @@ fn decode_leaf_rect( | |||
| 10586 | let smooth_neighbor = | 10613 | let smooth_neighbor = |
| 10587 | is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | 10614 | is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 10588 | if smooth_neighbor { | 10615 | if smooth_neighbor { |
| 10589 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 10616 | + hit!(SMOOTH_LUMA_HITS); |
| 10590 | } | 10617 | } |
| 10591 | // The palette-Y mode CDF row is picked by the neighbours' palette use | 10618 | // The palette-Y mode CDF row is picked by the neighbours' palette use |
| 10592 | // (`palette_ctx_and_cache`), so this sub-16x16 leaf must pass its own real | 10619 | // (`palette_ctx_and_cache`), so this sub-16x16 leaf must pass its own real |
| @@ -10623,7 +10650,7 @@ fn decode_leaf_rect( | |||
| 10623 | // map -> base colours buffer [`decode_block_rect`] hands each | 10650 | // map -> base colours buffer [`decode_block_rect`] hands each |
| 10624 | // `reconstruct_rect` through [`set_palette_pred`]. | 10651 | // `reconstruct_rect` through [`set_palette_pred`]. |
| 10625 | if palette_y.is_some() || palette_uv.is_some() { | 10652 | if palette_y.is_some() || palette_uv.is_some() { |
| 10626 | - RECT4_PALETTE_HITS.with(|c| c.set(c.get() + 1)); | 10653 | + hit!(RECT4_PALETTE_HITS); |
| 10627 | } | 10654 | } |
| 10628 | let palette_y_buf: Option<Vec<u16>> = palette_y | 10655 | let palette_y_buf: Option<Vec<u16>> = palette_y |
| 10629 | .as_ref() | 10656 | .as_ref() |
| @@ -10646,8 +10673,8 @@ fn decode_leaf_rect( | |||
| 10646 | // patches over a true `bw`x`bh` block (lane-rectsplit r1), so an | 10673 | // patches over a true `bw`x`bh` block (lane-rectsplit r1), so an |
| 10647 | // 8x16/16x8 strip predicts through the same call `reconstruct_rect` | 10674 | // 8x16/16x8 strip predicts through the same call `reconstruct_rect` |
| 10648 | // below already makes; this refusal was square-only prose. | 10675 | // below already makes; this refusal was square-only prose. |
| 10649 | - FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | 10676 | + hit!(FILTER_INTRA_RECT_HITS); |
| 10650 | - FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.set(c.get() + 1)); | 10677 | + hit!(FILTER_INTRA_RECT_SUB16_HITS); |
| 10651 | } | 10678 | } |
| 10652 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; | 10679 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; |
| 10653 | // lane-cfl r1, same defect as [`decode_leaf_8x8`]: chroma's intra-edge | 10680 | // lane-cfl r1, same defect as [`decode_leaf_8x8`]: chroma's intra-edge |
| @@ -10686,8 +10713,8 @@ fn decode_leaf_rect( | |||
| 10686 | // The same per-transform-unit walk the bigger strips take | 10713 | // The same per-transform-unit walk the bigger strips take |
| 10687 | // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at | 10714 | // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at |
| 10688 | // depth 2), addressed at this leaf's own mi position. | 10715 | // depth 2), addressed at this leaf's own mi position. |
| 10689 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | 10716 | + hit!(TX_DEPTH_HITS); |
| 10690 | - SUB16_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | 10717 | + hit!(SUB16_SPLIT_HITS); |
| 10691 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | 10718 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); |
| 10692 | let modes = RectStripModes { | 10719 | let modes = RectStripModes { |
| 10693 | skip, | 10720 | skip, |
| @@ -10706,7 +10733,7 @@ fn decode_leaf_rect( | |||
| 10706 | palette_uv: palette_uv_bufs.clone(), | 10733 | palette_uv: palette_uv_bufs.clone(), |
| 10707 | }; | 10734 | }; |
| 10708 | if palette_y.is_some() || palette_uv.is_some() { | 10735 | if palette_y.is_some() || palette_uv.is_some() { |
| 10709 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 10736 | + hit!(PALETTE_SPLIT_TX_HITS); |
| 10710 | } | 10737 | } |
| 10711 | decode_rect_split( | 10738 | decode_rect_split( |
| 10712 | dec, | 10739 | dec, |
| @@ -10837,7 +10864,7 @@ fn decode_leaf_rect( | |||
| 10837 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual, | 10864 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual, |
| 10838 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx, | 10865 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx, |
| 10839 | ); | 10866 | ); |
| 10840 | - RECT_LEAF_COEFF_HITS.with(|c| c.set(c.get() + 1)); | 10867 | + hit!(RECT_LEAF_COEFF_HITS); |
| 10841 | } | 10868 | } |
| 10842 | neighbours.record_mi_rect(leaf_mi, bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]); | 10869 | neighbours.record_mi_rect(leaf_mi, bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]); |
| 10843 | neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip); | 10870 | neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip); |
| @@ -10953,7 +10980,7 @@ fn decode_block_rect4( | |||
| 10953 | // mapped through the base colours IS the prediction (it reads no edge | 10980 | // mapped through the base colours IS the prediction (it reads no edge |
| 10954 | // pixels), handed to each `reconstruct_rect` through [`set_palette_pred`]. | 10981 | // pixels), handed to each `reconstruct_rect` through [`set_palette_pred`]. |
| 10955 | if palette_y.is_some() || palette_uv.is_some() { | 10982 | if palette_y.is_some() || palette_uv.is_some() { |
| 10956 | - RECT4_PALETTE_HITS.with(|c| c.set(c.get() + 1)); | 10983 | + hit!(RECT4_PALETTE_HITS); |
| 10957 | } | 10984 | } |
| 10958 | let palette_y_buf: Option<Vec<u16>> = palette_y | 10985 | let palette_y_buf: Option<Vec<u16>> = palette_y |
| 10959 | .as_ref() | 10986 | .as_ref() |
| @@ -10970,7 +10997,7 @@ fn decode_block_rect4( | |||
| 10970 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 10997 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 10971 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | 10998 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 10972 | if smooth_neighbor { | 10999 | if smooth_neighbor { |
| 10973 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 11000 | + hit!(SMOOTH_LUMA_HITS); |
| 10974 | } | 11001 | } |
| 10975 | // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's | 11002 | // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's |
| 10976 | // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so | 11003 | // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so |
| @@ -10980,11 +11007,11 @@ fn decode_block_rect4( | |||
| 10980 | // with luma bit-exact). | 11007 | // with luma bit-exact). |
| 10981 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); | 11008 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); |
| 10982 | if filter_intra.is_some() { | 11009 | if filter_intra.is_some() { |
| 10983 | - FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | 11010 | + hit!(FILTER_INTRA_RECT_HITS); |
| 10984 | if bw > bh { | 11011 | if bw > bh { |
| 10985 | - FILTER_INTRA_RECT4_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 11012 | + hit!(FILTER_INTRA_RECT4_HORZ_HITS); |
| 10986 | } else { | 11013 | } else { |
| 10987 | - FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.set(c.get() + 1)); | 11014 | + hit!(FILTER_INTRA_RECT4_VERT_HITS); |
| 10988 | } | 11015 | } |
| 10989 | } | 11016 | } |
| 10990 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { | 11017 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| @@ -11030,7 +11057,7 @@ fn decode_block_rect4( | |||
| 11030 | // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16 | 11057 | // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16 |
| 11031 | // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8; | 11058 | // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8; |
| 11032 | // both interleave in every real stream. | 11059 | // both interleave in every real stream. |
| 11033 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | 11060 | + hit!(TX_DEPTH_HITS); |
| 11034 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | 11061 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); |
| 11035 | // lane-rectsplitx r2: both depths ship together, as the r1 handoff | 11062 | // lane-rectsplitx r2: both depths ship together, as the r1 handoff |
| 11036 | // predicted -- depth 1 fires FIRST in every attempt that splits at | 11063 | // predicted -- depth 1 fires FIRST in every attempt that splits at |
| @@ -11057,7 +11084,7 @@ fn decode_block_rect4( | |||
| 11057 | palette_uv: palette_uv_bufs.clone(), | 11084 | palette_uv: palette_uv_bufs.clone(), |
| 11058 | }; | 11085 | }; |
| 11059 | if palette_y.is_some() || palette_uv.is_some() { | 11086 | if palette_y.is_some() || palette_uv.is_some() { |
| 11060 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 11087 | + hit!(PALETTE_SPLIT_TX_HITS); |
| 11061 | } | 11088 | } |
| 11062 | decode_rect_split( | 11089 | decode_rect_split( |
| 11063 | dec, | 11090 | dec, |
| @@ -11080,12 +11107,12 @@ fn decode_block_rect4( | |||
| 11080 | pal_uv_colors, | 11107 | pal_uv_colors, |
| 11081 | ); | 11108 | ); |
| 11082 | if bw > bh { | 11109 | if bw > bh { |
| 11083 | - RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 11110 | + hit!(RECT4_32_HORZ_HITS); |
| 11084 | } else { | 11111 | } else { |
| 11085 | - RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); | 11112 | + hit!(RECT4_32_VERT_HITS); |
| 11086 | } | 11113 | } |
| 11087 | if !skip { | 11114 | if !skip { |
| 11088 | - RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1)); | 11115 | + hit!(RECT4_COEFF_HITS); |
| 11089 | } | 11116 | } |
| 11090 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, | 11117 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 11091 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter | 11118 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| @@ -11166,7 +11193,7 @@ fn decode_block_rect4( | |||
| 11166 | } | 11193 | } |
| 11167 | let (v_levels, v_tx_type) = planes.pop().expect("plane 2"); | 11194 | let (v_levels, v_tx_type) = planes.pop().expect("plane 2"); |
| 11168 | let (u_levels, u_tx_type) = planes.pop().expect("plane 1"); | 11195 | let (u_levels, u_tx_type) = planes.pop().expect("plane 1"); |
| 11169 | - RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1)); | 11196 | + hit!(RECT4_COEFF_HITS); |
| 11170 | let luma_residual = dequant_and_inverse_typed_wh( | 11197 | let luma_residual = dequant_and_inverse_typed_wh( |
| 11171 | &luma_levels, | 11198 | &luma_levels, |
| 11172 | bw, | 11199 | bw, |
| @@ -11240,9 +11267,9 @@ fn decode_block_rect4( | |||
| 11240 | pal_uv_colors, | 11267 | pal_uv_colors, |
| 11241 | ); | 11268 | ); |
| 11242 | if bw > bh { | 11269 | if bw > bh { |
| 11243 | - RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 11270 | + hit!(RECT4_32_HORZ_HITS); |
| 11244 | } else { | 11271 | } else { |
| 11245 | - RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); | 11272 | + hit!(RECT4_32_VERT_HITS); |
| 11246 | } | 11273 | } |
| 11247 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, | 11274 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 11248 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter | 11275 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| @@ -11309,9 +11336,9 @@ fn decode_block_rect4( | |||
| 11309 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, | 11336 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, |
| 11310 | ); | 11337 | ); |
| 11311 | if bw > bh { | 11338 | if bw > bh { |
| 11312 | - RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 11339 | + hit!(RECT4_32_HORZ_HITS); |
| 11313 | } else { | 11340 | } else { |
| 11314 | - RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); | 11341 | + hit!(RECT4_32_VERT_HITS); |
| 11315 | } | 11342 | } |
| 11316 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, | 11343 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 11317 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter | 11344 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| @@ -11493,7 +11520,7 @@ fn decode_rect4_16_strip( | |||
| 11493 | lmi.1, fctx, | 11520 | lmi.1, fctx, |
| 11494 | )?; | 11521 | )?; |
| 11495 | if palette_y.is_some() || palette_uv.is_some() { | 11522 | if palette_y.is_some() || palette_uv.is_some() { |
| 11496 | - RECT4_PALETTE_HITS.with(|h| h.set(h.get() + 1)); | 11523 | + hit!(RECT4_PALETTE_HITS); |
| 11497 | } | 11524 | } |
| 11498 | // The colour-index map through the base colours IS the prediction. | 11525 | // The colour-index map through the base colours IS the prediction. |
| 11499 | // Chroma's map is the PAIR's 8x4 (4x8) block, matching the one | 11526 | // Chroma's map is the PAIR's 8x4 (4x8) block, matching the one |
| @@ -11509,10 +11536,10 @@ fn decode_rect4_16_strip( | |||
| 11509 | }); | 11536 | }); |
| 11510 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | 11537 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 11511 | if smooth_neighbor { | 11538 | if smooth_neighbor { |
| 11512 | - SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1)); | 11539 | + hit!(SMOOTH_LUMA_HITS); |
| 11513 | } | 11540 | } |
| 11514 | if filter_intra.is_some() { | 11541 | if filter_intra.is_some() { |
| 11515 | - FILTER_INTRA_RECT_HITS.with(|h| h.set(h.get() + 1)); | 11542 | + hit!(FILTER_INTRA_RECT_HITS); |
| 11516 | } | 11543 | } |
| 11517 | // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is | 11544 | // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is |
| 11518 | // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the | 11545 | // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the |
| @@ -11543,8 +11570,8 @@ fn decode_rect4_16_strip( | |||
| 11543 | 0 | 11570 | 0 |
| 11544 | }; | 11571 | }; |
| 11545 | if depth != 0 { | 11572 | if depth != 0 { |
| 11546 | - TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); | 11573 | + hit!(TX_DEPTH_HITS); |
| 11547 | - RECT4_16_SPLIT_HITS.with(|h| h.set(h.get() + 1)); | 11574 | + hit!(RECT4_16_SPLIT_HITS); |
| 11548 | } | 11575 | } |
| 11549 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | 11576 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); |
| 11550 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); | 11577 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| @@ -11626,7 +11653,7 @@ fn decode_rect4_16_strip( | |||
| 11626 | None, filter_intra, smooth_neighbor, fctx, | 11653 | None, filter_intra, smooth_neighbor, fctx, |
| 11627 | ); | 11654 | ); |
| 11628 | if tu_grid.iter().any(|&l| l != 0) { | 11655 | if tu_grid.iter().any(|&l| l != 0) { |
| 11629 | - RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | 11656 | + hit!(RECT4_16_COEFF_HITS); |
| 11630 | } | 11657 | } |
| 11631 | neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); | 11658 | neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); |
| 11632 | } else { | 11659 | } else { |
| @@ -11655,7 +11682,7 @@ fn decode_rect4_16_strip( | |||
| 11655 | smooth_neighbor, fctx, | 11682 | smooth_neighbor, fctx, |
| 11656 | )?; | 11683 | )?; |
| 11657 | if tu_grid.iter().any(|&l| l != 0) { | 11684 | if tu_grid.iter().any(|&l| l != 0) { |
| 11658 | - RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | 11685 | + hit!(RECT4_16_COEFF_HITS); |
| 11659 | } | 11686 | } |
| 11660 | neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid); | 11687 | neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid); |
| 11661 | } | 11688 | } |
| @@ -11710,7 +11737,7 @@ fn decode_rect4_16_strip( | |||
| 11710 | px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra, | 11737 | px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra, |
| 11711 | smooth_neighbor, fctx, | 11738 | smooth_neighbor, fctx, |
| 11712 | ); | 11739 | ); |
| 11713 | - RECT4_16_COEFF_HITS.with(|h| h.set(h.get() + 1)); | 11740 | + hit!(RECT4_16_COEFF_HITS); |
| 11714 | levels | 11741 | levels |
| 11715 | }; | 11742 | }; |
| 11716 | neighbours.record_mi_luma_rect(lmi, bw, bh, &levels); | 11743 | neighbours.record_mi_luma_rect(lmi, bw, bh, &levels); |
| @@ -11731,7 +11758,7 @@ fn decode_rect4_16_strip( | |||
| 11731 | } | 11758 | } |
| 11732 | } | 11759 | } |
| 11733 | if has_chroma { | 11760 | if has_chroma { |
| 11734 | - RECT4_16_CHROMA_HITS.with(|h| h.set(h.get() + 1)); | 11761 | + hit!(RECT4_16_CHROMA_HITS); |
| 11735 | let pair_mi = if horz { | 11762 | let pair_mi = if horz { |
| 11736 | (lmi.0 - 1, lmi.1) | 11763 | (lmi.0 - 1, lmi.1) |
| 11737 | } else { | 11764 | } else { |
| @@ -11743,7 +11770,7 @@ fn decode_rect4_16_strip( | |||
| 11743 | let (cw, ch) = (pw / 2, ph / 2); | 11770 | let (cw, ch) = (pw / 2, ph / 2); |
| 11744 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; | 11771 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; |
| 11745 | if (V_PRED..=D67_PRED).contains(&uv_predict_mode) { | 11772 | if (V_PRED..=D67_PRED).contains(&uv_predict_mode) { |
| 11746 | - RECT4_16_CHROMA_DIR_HITS.with(|h| h.set(h.get() + 1)); | 11773 | + hit!(RECT4_16_CHROMA_DIR_HITS); |
| 11747 | } | 11774 | } |
| 11748 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height, fctx); | 11775 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height, fctx); |
| 11749 | // lane-kf1200 r1: the chroma edge-filter type reads the neighbours | 11776 | // lane-kf1200 r1: the chroma edge-filter type reads the neighbours |
| @@ -11761,7 +11788,7 @@ fn decode_rect4_16_strip( | |||
| 11761 | neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c); | 11788 | neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c); |
| 11762 | if smooth_neighbor_uv != neighbours.smooth_uv_neighbour_unsnapped(lmi.0, lmi.1, r, c) | 11789 | if smooth_neighbor_uv != neighbours.smooth_uv_neighbour_unsnapped(lmi.0, lmi.1, r, c) |
| 11763 | { | 11790 | { |
| 11764 | - RECT4_16_UV_PAIR_FILT_HITS.with(|h| h.set(h.get() + 1)); | 11791 | + hit!(RECT4_16_UV_PAIR_FILT_HITS); |
| 11765 | } | 11792 | } |
| 11766 | let (u_levels, v_levels) = if skip { | 11793 | let (u_levels, v_levels) = if skip { |
| 11767 | let zeros = Grid::Zero(cw * ch); | 11794 | let zeros = Grid::Zero(cw * ch); |
| @@ -11772,7 +11799,7 @@ fn decode_rect4_16_strip( | |||
| 11772 | // chroma-only bounded box on ReelC's key frames. | 11799 | // chroma-only bounded box on ReelC's key frames. |
| 11773 | let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph)); | 11800 | let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph)); |
| 11774 | if alpha.is_some() { | 11801 | if alpha.is_some() { |
| 11775 | - CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | 11802 | + hit!(CHROMA_SKIP_CFL_HITS); |
| 11776 | } | 11803 | } |
| 11777 | for (_buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] { | 11804 | for (_buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] { |
| 11778 | if let Some((ub, vb)) = &palette_uv_bufs { | 11805 | if let Some((ub, vb)) = &palette_uv_bufs { |
| @@ -11882,9 +11909,9 @@ fn decode_rect4_16_strip( | |||
| 11882 | last_uv_mode = Some(uv_predict_mode); | 11909 | last_uv_mode = Some(uv_predict_mode); |
| 11883 | } | 11910 | } |
| 11884 | if horz { | 11911 | if horz { |
| 11885 | - RECT4_16_HORZ_HITS.with(|h| h.set(h.get() + 1)); | 11912 | + hit!(RECT4_16_HORZ_HITS); |
| 11886 | } else { | 11913 | } else { |
| 11887 | - RECT4_16_VERT_HITS.with(|h| h.set(h.get() + 1)); | 11914 | + hit!(RECT4_16_VERT_HITS); |
| 11888 | } | 11915 | } |
| 11889 | let (pal_y_size, pal_y_colors) = | 11916 | let (pal_y_size, pal_y_colors) = |
| 11890 | palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | 11917 | palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| @@ -11977,11 +12004,11 @@ fn decode_block_rect64( | |||
| 11977 | // -- counted so its gate cannot go vacuous (this was a refusal until | 12004 | // -- counted so its gate cannot go vacuous (this was a refusal until |
| 11978 | // r34; see the gate `a_real_aomenc_palette_stream_with_8x8_leaves_ | 12005 | // r34; see the gate `a_real_aomenc_palette_stream_with_8x8_leaves_ |
| 11979 | // decodes_pixel_exact`). | 12006 | // decodes_pixel_exact`). |
| 11980 | - PALETTE_SB_STRIP_HITS.with(|c| c.set(c.get() + 1)); | 12007 | + hit!(PALETTE_SB_STRIP_HITS); |
| 11981 | } | 12008 | } |
| 11982 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | 12009 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 11983 | if smooth_neighbor { | 12010 | if smooth_neighbor { |
| 11984 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 12011 | + hit!(SMOOTH_LUMA_HITS); |
| 11985 | } | 12012 | } |
| 11986 | let smooth_neighbor_uv = | 12013 | let smooth_neighbor_uv = |
| 11987 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); | 12014 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); |
| @@ -12041,7 +12068,7 @@ fn decode_block_rect64( | |||
| 12041 | (bw, bh), fctx, | 12068 | (bw, bh), fctx, |
| 12042 | ); | 12069 | ); |
| 12043 | if depth != 0 { | 12070 | if depth != 0 { |
| 12044 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | 12071 | + hit!(TX_DEPTH_HITS); |
| 12045 | // lane-rectsplit r1/r4: the superblock-level strip splits its | 12072 | // lane-rectsplit r1/r4: the superblock-level strip splits its |
| 12046 | // transform through the very same per-unit path as its 32x32-level | 12073 | // transform through the very same per-unit path as its 32x32-level |
| 12047 | // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 | 12074 | // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 |
| @@ -12084,7 +12111,7 @@ fn decode_block_rect64( | |||
| 12084 | }), | 12111 | }), |
| 12085 | }; | 12112 | }; |
| 12086 | if palette_y.is_some() || palette_uv.is_some() { | 12113 | if palette_y.is_some() || palette_uv.is_some() { |
| 12087 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 12114 | + hit!(PALETTE_SPLIT_TX_HITS); |
| 12088 | } | 12115 | } |
| 12089 | decode_rect_split( | 12116 | decode_rect_split( |
| 12090 | dec, | 12117 | dec, |
| @@ -12120,8 +12147,8 @@ fn decode_block_rect64( | |||
| 12120 | // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The | 12147 | // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The |
| 12121 | // bands carry the SPLIT unit's size, not the block's. | 12148 | // bands carry the SPLIT unit's size, not the block's. |
| 12122 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); | 12149 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); |
| 12123 | - RECT64_SPLIT_TXFM_PUBLISH_HITS.with(|c| c.set(c.get() + 1)); | 12150 | + hit!(RECT64_SPLIT_TXFM_PUBLISH_HITS); |
| 12124 | - RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | 12151 | + hit!(RECT_PARTITION_HITS); |
| 12125 | return Ok(()); | 12152 | return Ok(()); |
| 12126 | } | 12153 | } |
| 12127 | let (tx_w, tx_h) = (bw, bh); | 12154 | let (tx_w, tx_h) = (bw, bh); |
| @@ -12260,7 +12287,7 @@ fn decode_block_rect64( | |||
| 12260 | { | 12287 | { |
| 12261 | let cur = block_q_idx(fctx); | 12288 | let cur = block_q_idx(fctx); |
| 12262 | if cur != i32::from(base_q_idx) { | 12289 | if cur != i32::from(base_q_idx) { |
| 12263 | - RECT64_QIDX_DRIFT_HITS.with(|c| c.set(c.get() + 1)); | 12290 | + hit!(RECT64_QIDX_DRIFT_HITS); |
| 12264 | } | 12291 | } |
| 12265 | if crate::envflags::env_flag!("EC_AV1_TRACE") { | 12292 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| 12266 | eprintln!( | 12293 | eprintln!( |
| @@ -12343,7 +12370,7 @@ fn decode_block_rect64( | |||
| 12343 | { | 12370 | { |
| 12344 | let cur = block_q_idx(fctx); | 12371 | let cur = block_q_idx(fctx); |
| 12345 | if cur != i32::from(base_q_idx) { | 12372 | if cur != i32::from(base_q_idx) { |
| 12346 | - RECT64_QIDX_DRIFT_HITS.with(|c| c.set(c.get() + 1)); | 12373 | + hit!(RECT64_QIDX_DRIFT_HITS); |
| 12347 | } | 12374 | } |
| 12348 | if crate::envflags::env_flag!("EC_AV1_TRACE") { | 12375 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| 12349 | eprintln!( | 12376 | eprintln!( |
| @@ -12407,7 +12434,7 @@ fn decode_block_rect64( | |||
| 12407 | { | 12434 | { |
| 12408 | let cur = block_q_idx(fctx); | 12435 | let cur = block_q_idx(fctx); |
| 12409 | if cur != i32::from(base_q_idx) { | 12436 | if cur != i32::from(base_q_idx) { |
| 12410 | - RECT64_QIDX_DRIFT_HITS.with(|c| c.set(c.get() + 1)); | 12437 | + hit!(RECT64_QIDX_DRIFT_HITS); |
| 12411 | } | 12438 | } |
| 12412 | if crate::envflags::env_flag!("EC_AV1_TRACE") { | 12439 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| 12413 | eprintln!( | 12440 | eprintln!( |
| @@ -12442,7 +12469,7 @@ fn decode_block_rect64( | |||
| 12442 | smooth_neighbor_uv, fctx, | 12469 | smooth_neighbor_uv, fctx, |
| 12443 | ); | 12470 | ); |
| 12444 | neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[&luma_levels[..], &u_levels[..], &v_levels[..]]); | 12471 | neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[&luma_levels[..], &u_levels[..], &v_levels[..]]); |
| 12445 | - RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); | 12472 | + hit!(RECT_COEFF_HITS); |
| 12446 | } | 12473 | } |
| 12447 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | 12474 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| 12448 | neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors); | 12475 | neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors); |
| @@ -12462,10 +12489,10 @@ fn decode_block_rect64( | |||
| 12462 | // 3840x1608 10-bit stream's first silent wall, decode-order frame 33 at | 12489 | // 3840x1608 10-bit stream's first silent wall, decode-order frame 33 at |
| 12463 | // mi(16,480)). Same write as [`set_txfm_ctxs`], rect-aware. | 12490 | // mi(16,480)). Same write as [`set_txfm_ctxs`], rect-aware. |
| 12464 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); | 12491 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); |
| 12465 | - SB_RECT_HITS.with(|c| c.set(c.get() + 1)); | 12492 | + hit!(SB_RECT_HITS); |
| 12466 | match (bw, bh) { | 12493 | match (bw, bh) { |
| 12467 | - (64, 16) => SB_RECT4_HORZ_HITS.with(|c| c.set(c.get() + 1)), | 12494 | + (64, 16) => hit!(SB_RECT4_HORZ_HITS), |
| 12468 | - (16, 64) => SB_RECT4_VERT_HITS.with(|c| c.set(c.get() + 1)), | 12495 | + (16, 64) => hit!(SB_RECT4_VERT_HITS), |
| 12469 | _ => {} | 12496 | _ => {} |
| 12470 | } | 12497 | } |
| 12471 | if crate::envflags::env_flag!("EC_AV1_TRACE") { | 12498 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| @@ -12482,7 +12509,7 @@ fn decode_block_rect64( | |||
| 12482 | fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 { | 12509 | fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 { |
| 12483 | let symbol = dec.symbol(cdf); | 12510 | let symbol = dec.symbol(cdf); |
| 12484 | if symbol != ANGLE_DELTA_ZERO { | 12511 | if symbol != ANGLE_DELTA_ZERO { |
| 12485 | - ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1)); | 12512 | + hit!(ANGLE_DELTA_HITS); |
| 12486 | } | 12513 | } |
| 12487 | symbol as i32 - ANGLE_DELTA_ZERO as i32 | 12514 | symbol as i32 - ANGLE_DELTA_ZERO as i32 |
| 12488 | } | 12515 | } |
| @@ -12552,7 +12579,7 @@ fn read_intra_mode( | |||
| 12552 | // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single | 12579 | // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single |
| 12553 | // point every square caller routes through (see `read_intra_mode_rect`). | 12580 | // point every square caller routes through (see `read_intra_mode_rect`). |
| 12554 | let cfl = if cfl && side > 32 { | 12581 | let cfl = if cfl && side > 32 { |
| 12555 | - NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1)); | 12582 | + hit!(NOCFL_UV_MODE_HITS); |
| 12556 | false | 12583 | false |
| 12557 | } else { | 12584 | } else { |
| 12558 | cfl | 12585 | cfl |
| @@ -12602,7 +12629,7 @@ fn read_intra_mode( | |||
| 12602 | eprintln!("TRACE intrabc dv={dv:?}"); | 12629 | eprintln!("TRACE intrabc dv={dv:?}"); |
| 12603 | } | 12630 | } |
| 12604 | fctx.intrabc_dv.with(|c| c.set(Some(dv))); | 12631 | fctx.intrabc_dv.with(|c| c.set(Some(dv))); |
| 12605 | - INTRABC_HITS.with(|c| c.set(c.get() + 1)); | 12632 | + hit!(INTRABC_HITS); |
| 12606 | // spec 5.11.13 / libaom `read_intra_frame_mode_info` returns the | 12633 | // spec 5.11.13 / libaom `read_intra_frame_mode_info` returns the |
| 12607 | // moment `is_intrabc_block`: no y/uv mode, angle delta, palette, | 12634 | // moment `is_intrabc_block`: no y/uv mode, angle delta, palette, |
| 12608 | // CFL or filter-intra syntax follows. `YMode`/`UVMode` are forced | 12635 | // CFL or filter-intra syntax follows. `YMode`/`UVMode` are forced |
| @@ -12657,7 +12684,7 @@ fn read_intra_mode( | |||
| 12657 | // bug in that fallback this lane's own scope does not cover. Keep it | 12684 | // bug in that fallback this lane's own scope does not cover. Keep it |
| 12658 | // refused here rather than ship a silently-wrong decode. | 12685 | // refused here rather than ship a silently-wrong decode. |
| 12659 | if (9..=12).contains(&uv_mode) { | 12686 | if (9..=12).contains(&uv_mode) { |
| 12660 | - SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | 12687 | + hit!(SMOOTH_UV_HITS); |
| 12661 | } | 12688 | } |
| 12662 | // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the | 12689 | // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the |
| 12663 | // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads | 12690 | // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads |
| @@ -12665,14 +12692,14 @@ fn read_intra_mode( | |||
| 12665 | // so a CFL block (uv_mode==13, outside `V_PRED..=D67_PRED`) already takes | 12692 | // so a CFL block (uv_mode==13, outside `V_PRED..=D67_PRED`) already takes |
| 12666 | // the `else` branch below and never reads one either way. | 12693 | // the `else` branch below and never reads one either way. |
| 12667 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { | 12694 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 12668 | - DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); | 12695 | + hit!(DIRECTIONAL_UV_HITS); |
| 12669 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | 12696 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 12670 | } else { | 12697 | } else { |
| 12671 | 0 | 12698 | 0 |
| 12672 | }; | 12699 | }; |
| 12673 | istep!("angle_uv", angle_delta_uv); | 12700 | istep!("angle_uv", angle_delta_uv); |
| 12674 | if angle_delta_uv != 0 { | 12701 | if angle_delta_uv != 0 { |
| 12675 | - UV_ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1)); | 12702 | + hit!(UV_ANGLE_DELTA_HITS); |
| 12676 | } | 12703 | } |
| 12677 | // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called | 12704 | // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called |
| 12678 | // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`): | 12705 | // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`): |
| @@ -12771,7 +12798,7 @@ fn read_intra_mode( | |||
| 12771 | } | 12798 | } |
| 12772 | istep!("use_filter_intra", use_filter_intra as i32); | 12799 | istep!("use_filter_intra", use_filter_intra as i32); |
| 12773 | if use_filter_intra { | 12800 | if use_filter_intra { |
| 12774 | - FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | 12801 | + hit!(FILTER_INTRA_HITS); |
| 12775 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); | 12802 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 12776 | if trace { | 12803 | if trace { |
| 12777 | eprintln!("TRACE filter_intra_mode value={fi_mode}"); | 12804 | eprintln!("TRACE filter_intra_mode value={fi_mode}"); |
| @@ -12784,7 +12811,7 @@ fn read_intra_mode( | |||
| 12784 | // shared U/V map) -- the same order libaom's own loop visits them in. | 12811 | // shared U/V map) -- the same order libaom's own loop visits them in. |
| 12785 | let palette_y = palette_y_pending.map(|(n, colors)| { | 12812 | let palette_y = palette_y_pending.map(|(n, colors)| { |
| 12786 | let map = decode_color_index_map(dec, cdfs, n, side, false); | 12813 | let map = decode_color_index_map(dec, cdfs, n, side, false); |
| 12787 | - PALETTE_HITS.with(|c| c.set(c.get() + 1)); | 12814 | + hit!(PALETTE_HITS); |
| 12788 | if trace { | 12815 | if trace { |
| 12789 | eprintln!("TRACE palette_y size={n} colors={:?}", &colors[..n]); | 12816 | eprintln!("TRACE palette_y size={n} colors={:?}", &colors[..n]); |
| 12790 | } | 12817 | } |
| @@ -12792,7 +12819,7 @@ fn read_intra_mode( | |||
| 12792 | }); | 12819 | }); |
| 12793 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { | 12820 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { |
| 12794 | let map = decode_color_index_map(dec, cdfs, n, side / 2, true); | 12821 | let map = decode_color_index_map(dec, cdfs, n, side / 2, true); |
| 12795 | - PALETTE_UV_HITS.with(|c| c.set(c.get() + 1)); | 12822 | + hit!(PALETTE_UV_HITS); |
| 12796 | if trace { | 12823 | if trace { |
| 12797 | eprintln!( | 12824 | eprintln!( |
| 12798 | "TRACE palette_uv size={n} u_colors={:?} v_colors={:?}", | 12825 | "TRACE palette_uv size={n} u_colors={:?} v_colors={:?}", |
| @@ -12827,7 +12854,7 @@ const UV_CFL_PRED: usize = 13; | |||
| 12827 | /// joint sign the same way. Returns each plane's final signed `alpha_q3` | 12854 | /// joint sign the same way. Returns each plane's final signed `alpha_q3` |
| 12828 | /// (`cfl_idx_to_alpha`, cfl.c): magnitude `idx + 1`, sign-zero collapsing to 0. | 12855 | /// (`cfl_idx_to_alpha`, cfl.c): magnitude `idx + 1`, sign-zero collapsing to 0. |
| 12829 | fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) { | 12856 | fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) { |
| 12830 | - CFL_BLOCK_HITS.with(|c| c.set(c.get() + 1)); | 12857 | + hit!(CFL_BLOCK_HITS); |
| 12831 | let joint_sign = dec.symbol(&mut cdfs.cfl_sign) as i32; | 12858 | let joint_sign = dec.symbol(&mut cdfs.cfl_sign) as i32; |
| 12832 | let sign_u = ((joint_sign + 1) * 11) >> 5; | 12859 | let sign_u = ((joint_sign + 1) * 11) >> 5; |
| 12833 | let sign_v = (joint_sign + 1) - 3 * sign_u; | 12860 | let sign_v = (joint_sign + 1) - 3 * sign_u; |
| @@ -13107,9 +13134,9 @@ impl PlaneBuf<'_> { | |||
| 13107 | let corner = | 13134 | let corner = |
| 13108 | (x > self.tile_x0 && y > self.tile_y0).then(|| self.data[(y - 1) * self.width + x - 1]); | 13135 | (x > self.tile_x0 && y > self.tile_y0).then(|| self.data[(y - 1) * self.width + x - 1]); |
| 13109 | if matches!((bw, bh), (16, 8) | (8, 16)) { | 13136 | if matches!((bw, bh), (16, 8) | (8, 16)) { |
| 13110 | - RECT_STRIP_PRED_HITS.with(|h| h.set(h.get() + 1)); | 13137 | + hit!(RECT_STRIP_PRED_HITS); |
| 13111 | if across > own_across || down > own_down { | 13138 | if across > own_across || down > own_down { |
| 13112 | - RECT_STRIP_REACH_HITS.with(|h| h.set(h.get() + 1)); | 13139 | + hit!(RECT_STRIP_REACH_HITS); |
| 13113 | } | 13140 | } |
| 13114 | } | 13141 | } |
| 13115 | (above, left, corner) | 13142 | (above, left, corner) |
| @@ -13520,7 +13547,7 @@ fn decode_block( | |||
| 13520 | c * (SUB / MI), fctx, | 13547 | c * (SUB / MI), fctx, |
| 13521 | )?; | 13548 | )?; |
| 13522 | if at_tile_left && palette_y.is_some() { | 13549 | if at_tile_left && palette_y.is_some() { |
| 13523 | - PALETTE_TILE_LEFT_HITS.with(|c| c.set(c.get() + 1)); | 13550 | + hit!(PALETTE_TILE_LEFT_HITS); |
| 13524 | } | 13551 | } |
| 13525 | let intrabc_dv = fctx.intrabc_dv.with(|c| c.take()); | 13552 | let intrabc_dv = fctx.intrabc_dv.with(|c| c.take()); |
| 13526 | // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED` | 13553 | // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED` |
| @@ -13533,7 +13560,7 @@ fn decode_block( | |||
| 13533 | }; | 13560 | }; |
| 13534 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | 13561 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 13535 | if smooth_neighbor { | 13562 | if smooth_neighbor { |
| 13536 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 13563 | + hit!(SMOOTH_LUMA_HITS); |
| 13537 | } | 13564 | } |
| 13538 | let smooth_neighbor_uv = | 13565 | let smooth_neighbor_uv = |
| 13539 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); | 13566 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); |
| @@ -13583,7 +13610,7 @@ fn decode_block( | |||
| 13583 | ); | 13610 | ); |
| 13584 | } | 13611 | } |
| 13585 | } | 13612 | } |
| 13586 | - INTRABC_VARTX_HITS.with(|c| c.set(c.get() + 1)); | 13613 | + hit!(INTRABC_VARTX_HITS); |
| 13587 | // The luma reconstruct loop below is a UNIFORM grid of one square | 13614 | // The luma reconstruct loop below is a UNIFORM grid of one square |
| 13588 | // transform (the intra `tx_depth` shape), so a tree that resolved to | 13615 | // transform (the intra `tx_depth` shape), so a tree that resolved to |
| 13589 | // mixed leaf sizes is refused by name rather than reconstructed at the | 13616 | // mixed leaf sizes is refused by name rather than reconstructed at the |
| @@ -13613,7 +13640,7 @@ fn decode_block( | |||
| 13613 | (side.min(64), luma_tx) | 13640 | (side.min(64), luma_tx) |
| 13614 | }; | 13641 | }; |
| 13615 | if tx_select && logical_tx < side && uv_mode != DC_PRED { | 13642 | if tx_select && logical_tx < side && uv_mode != DC_PRED { |
| 13616 | - SQ_CHROMA_TX_HITS.with(|c| c.set(c.get() + 1)); | 13643 | + hit!(SQ_CHROMA_TX_HITS); |
| 13617 | } | 13644 | } |
| 13618 | let luma_set = if tx_select { | 13645 | let luma_set = if tx_select { |
| 13619 | txbset_for(logical_tx, reduced_tx_set) | 13646 | txbset_for(logical_tx, reduced_tx_set) |
| @@ -13732,7 +13759,7 @@ fn decode_block( | |||
| 13732 | logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); | 13759 | logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); |
| 13733 | if split_tx_skip { | 13760 | if split_tx_skip { |
| 13734 | if tx_select { | 13761 | if tx_select { |
| 13735 | - SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 13762 | + hit!(SKIP_SPLIT_TX_HITS); |
| 13736 | } | 13763 | } |
| 13737 | let n_axis = side / logical_tx; | 13764 | let n_axis = side / logical_tx; |
| 13738 | for tu_row in 0..n_axis { | 13765 | for tu_row in 0..n_axis { |
| @@ -13995,7 +14022,7 @@ fn decode_block( | |||
| 13995 | // `get_txb_ctx_general`'s `plane_bsize != tx_size` branch). | 14022 | // `get_txb_ctx_general`'s `plane_bsize != tx_size` branch). |
| 13996 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, logical_tx / MI); | 14023 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, logical_tx / MI); |
| 13997 | if let Some(buf) = &palette_y_buf { | 14024 | if let Some(buf) = &palette_y_buf { |
| 13998 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 14025 | + hit!(PALETTE_SPLIT_TX_HITS); |
| 13999 | let mut window = vec![0u16; logical_tx * logical_tx]; | 14026 | let mut window = vec![0u16; logical_tx * logical_tx]; |
| 14000 | for row in 0..logical_tx { | 14027 | for row in 0..logical_tx { |
| 14001 | let src = (tu_row * logical_tx + row) * side + tu_col * logical_tx; | 14028 | let src = (tu_row * logical_tx + row) * side + tu_col * logical_tx; |
| @@ -14092,7 +14119,7 @@ fn decode_block( | |||
| 14092 | None, chroma_ctx_offset, smooth_neighbor_uv, fctx, | 14119 | None, chroma_ctx_offset, smooth_neighbor_uv, fctx, |
| 14093 | )?; | 14120 | )?; |
| 14094 | if cn > 1 { | 14121 | if cn > 1 { |
| 14095 | - CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 14122 | + hit!(CHROMA_SPLIT_TX_HITS); |
| 14096 | // Immediately, so the NEXT unit of this same block reads | 14123 | // Immediately, so the NEXT unit of this same block reads |
| 14097 | // this one's coefficient context (libaom's chroma | 14124 | // this one's coefficient context (libaom's chroma |
| 14098 | // `txb_skip_ctx` for the second quadrant is 11, i.e. base | 14125 | // `txb_skip_ctx` for the second quadrant is 11, i.e. base |
| @@ -14272,7 +14299,7 @@ fn decode_block_128rect( | |||
| 14272 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; | 14299 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; |
| 14273 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | 14300 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 14274 | if smooth_neighbor { | 14301 | if smooth_neighbor { |
| 14275 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 14302 | + hit!(SMOOTH_LUMA_HITS); |
| 14276 | } | 14303 | } |
| 14277 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); | 14304 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); |
| 14278 | // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or | 14305 | // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or |
| @@ -14293,13 +14320,15 @@ fn decode_block_128rect( | |||
| 14293 | 0 | 14320 | 0 |
| 14294 | }; | 14321 | }; |
| 14295 | if depth != 0 { | 14322 | if depth != 0 { |
| 14296 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | 14323 | + hit!(TX_DEPTH_HITS); |
| 14324 | + } | ||
| 14325 | + hit_do! { | ||
| 14326 | + INTRA_SB128_DEPTH_HITS.with(|c| { | ||
| 14327 | + let mut h = c.get(); | ||
| 14328 | + h[depth.min(2)] += 1; | ||
| 14329 | + c.set(h); | ||
| 14330 | + }); | ||
| 14297 | } | 14331 | } |
| 14298 | - INTRA_SB128_DEPTH_HITS.with(|c| { | ||
| 14299 | - let mut h = c.get(); | ||
| 14300 | - h[depth.min(2)] += 1; | ||
| 14301 | - c.set(h); | ||
| 14302 | - }); | ||
| 14303 | let logical_tx = 64 >> depth; | 14332 | let logical_tx = 64 >> depth; |
| 14304 | // A 64-point transform codes nothing past its low 32 coefficients. | 14333 | // A 64-point transform codes nothing past its low 32 coefficients. |
| 14305 | let coeff_tx_side = logical_tx.min(32); | 14334 | let coeff_tx_side = logical_tx.min(32); |
| @@ -14429,7 +14458,7 @@ fn decode_block_128rect( | |||
| 14429 | angle_delta_uv, cu_r, v, cu_x, cu_y, chroma_tx, chroma_tx, base_q_idx, None, None, | 14458 | angle_delta_uv, cu_r, v, cu_x, cu_y, chroma_tx, chroma_tx, base_q_idx, None, None, |
| 14430 | Some(3), smooth_neighbor_uv, fctx, | 14459 | Some(3), smooth_neighbor_uv, fctx, |
| 14431 | )?; | 14460 | )?; |
| 14432 | - CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 14461 | + hit!(CHROMA_SPLIT_TX_HITS); |
| 14433 | // Immediately, so the NEXT unit of this same block reads this | 14462 | // Immediately, so the NEXT unit of this same block reads this |
| 14434 | // one's coefficient context; replayed after `record_split_luma_rect` | 14463 | // one's coefficient context; replayed after `record_split_luma_rect` |
| 14435 | // below, which would otherwise clobber them whole-block. | 14464 | // below, which would otherwise clobber them whole-block. |
| @@ -14492,15 +14521,17 @@ fn decode_block_128rect( | |||
| 14492 | (logical_tx, logical_tx), | 14521 | (logical_tx, logical_tx), |
| 14493 | (bw, bh), | 14522 | (bw, bh), |
| 14494 | ); | 14523 | ); |
| 14495 | - INTRA128_IN_INTER_HITS.with(|c| { | 14524 | + hit_do! { |
| 14496 | - let mut h = c.get(); | 14525 | + INTRA128_IN_INTER_HITS.with(|c| { |
| 14497 | - h[usize::from(bw < bh)] += 1; | 14526 | + let mut h = c.get(); |
| 14498 | - c.set(h); | 14527 | + h[usize::from(bw < bh)] += 1; |
| 14499 | - }); | 14528 | + c.set(h); |
| 14529 | + }); | ||
| 14530 | + } | ||
| 14500 | } else if bw > bh { | 14531 | } else if bw > bh { |
| 14501 | - INTRA_SB128_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 14532 | + hit!(INTRA_SB128_HORZ_HITS); |
| 14502 | } else { | 14533 | } else { |
| 14503 | - INTRA_SB128_VERT_HITS.with(|c| c.set(c.get() + 1)); | 14534 | + hit!(INTRA_SB128_VERT_HITS); |
| 14504 | } | 14535 | } |
| 14505 | Ok(()) | 14536 | Ok(()) |
| 14506 | } | 14537 | } |
| @@ -14592,7 +14623,7 @@ fn decode_leaf8( | |||
| 14592 | // that exact mi cell. | 14623 | // that exact mi cell. |
| 14593 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); | 14624 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); |
| 14594 | if smooth_neighbor { | 14625 | if smooth_neighbor { |
| 14595 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 14626 | + hit!(SMOOTH_LUMA_HITS); |
| 14596 | } | 14627 | } |
| 14597 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec | 14628 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec |
| 14598 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other | 14629 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other |
| @@ -14633,7 +14664,7 @@ fn decode_leaf8( | |||
| 14633 | // mirrors `decode_block`'s own intrabc handling at 16x16 and up. | 14664 | // mirrors `decode_block`'s own intrabc handling at 16x16 and up. |
| 14634 | let intrabc_dv = fctx.intrabc_dv.with(|c| c.take()); | 14665 | let intrabc_dv = fctx.intrabc_dv.with(|c| c.take()); |
| 14635 | if intrabc_dv.is_some() { | 14666 | if intrabc_dv.is_some() { |
| 14636 | - LEAF8_INTRABC_HITS.with(|c| c.set(c.get() + 1)); | 14667 | + hit!(LEAF8_INTRABC_HITS); |
| 14637 | } | 14668 | } |
| 14638 | // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour | 14669 | // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour |
| 14639 | // index map, mapped through the base colours, IS the block's prediction -- | 14670 | // index map, mapped through the base colours, IS the block's prediction -- |
| @@ -14653,7 +14684,7 @@ fn decode_leaf8( | |||
| 14653 | let (pal_uv_size, pal_uv_colors) = | 14684 | let (pal_uv_size, pal_uv_colors) = |
| 14654 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 14685 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 14655 | if palette_y.is_some() || palette_uv.is_some() { | 14686 | if palette_y.is_some() || palette_uv.is_some() { |
| 14656 | - PALETTE_LEAF8_HITS.with(|c| c.set(c.get() + 1)); | 14687 | + hit!(PALETTE_LEAF8_HITS); |
| 14657 | } | 14688 | } |
| 14658 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { | 14689 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 14659 | DC_PRED | 14690 | DC_PRED |
| @@ -14694,7 +14725,7 @@ fn decode_leaf8( | |||
| 14694 | 0, | 14725 | 0, |
| 14695 | &mut leaves, | 14726 | &mut leaves, |
| 14696 | ); | 14727 | ); |
| 14697 | - INTRABC_VARTX_HITS.with(|c| c.set(c.get() + 1)); | 14728 | + hit!(INTRABC_VARTX_HITS); |
| 14698 | leaves.first().map_or(8, |l| l.2) | 14729 | leaves.first().map_or(8, |l| l.2) |
| 14699 | } else if tx_select && intrabc_dv.is_none() { | 14730 | } else if tx_select && intrabc_dv.is_none() { |
| 14700 | read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, None) | 14731 | read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, None) |
| @@ -14752,7 +14783,7 @@ fn decode_leaf8( | |||
| 14752 | // rule) -- so a palette leaf takes the single 8x8 reconstruct below | 14783 | // rule) -- so a palette leaf takes the single 8x8 reconstruct below |
| 14753 | // even when `tx_depth` resolved to TX_4X4. | 14784 | // even when `tx_depth` resolved to TX_4X4. |
| 14754 | if resolved == 4 && palette_y_buf.is_none() { | 14785 | if resolved == 4 && palette_y_buf.is_none() { |
| 14755 | - SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 14786 | + hit!(SKIP_SPLIT_TX_HITS); |
| 14756 | for tu_row in 0..2 { | 14787 | for tu_row in 0..2 { |
| 14757 | for tu_col in 0..2 { | 14788 | for tu_col in 0..2 { |
| 14758 | let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4); | 14789 | let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4); |
| @@ -14952,7 +14983,7 @@ fn decode_leaf8( | |||
| 14952 | let tu_py = py + tu_row * 4; | 14983 | let tu_py = py + tu_row * 4; |
| 14953 | let tu_around = neighbours.around_mi(tu_mi, 4)[0]; | 14984 | let tu_around = neighbours.around_mi(tu_mi, 4)[0]; |
| 14954 | if crate::encode::Reach::in_vert_ab() { | 14985 | if crate::encode::Reach::in_vert_ab() { |
| 14955 | - VERT_AB_TX4_HITS.with(|c| c.set(c.get() + 1)); | 14986 | + hit!(VERT_AB_TX4_HITS); |
| 14956 | } | 14987 | } |
| 14957 | let tu_reach = tu_reach( | 14988 | let tu_reach = tu_reach( |
| 14958 | 8, | 14989 | 8, |
| @@ -14972,7 +15003,7 @@ fn decode_leaf8( | |||
| 14972 | // 16x16 and up) -- the whole-block buffer would be taken by | 15003 | // 16x16 and up) -- the whole-block buffer would be taken by |
| 14973 | // the FIRST unit and indexed at the wrong stride. | 15004 | // the FIRST unit and indexed at the wrong stride. |
| 14974 | if let Some(buf) = &palette_y_buf { | 15005 | if let Some(buf) = &palette_y_buf { |
| 14975 | - PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 15006 | + hit!(PALETTE_SPLIT_TX_HITS); |
| 14976 | let mut window = vec![0u16; 16]; | 15007 | let mut window = vec![0u16; 16]; |
| 14977 | for row in 0..4 { | 15008 | for row in 0..4 { |
| 14978 | let src = (tu_row * 4 + row) * 8 + tu_col * 4; | 15009 | let src = (tu_row * 4 + row) * 8 + tu_col * 4; |
| @@ -15126,7 +15157,7 @@ fn decode_leaf8( | |||
| 15126 | neighbours.record_palette_y_rect(leaf_mi, 8, 8, pal_y_size, pal_y_colors); | 15157 | neighbours.record_palette_y_rect(leaf_mi, 8, 8, pal_y_size, pal_y_colors); |
| 15127 | neighbours.record_palette_uv_rect(leaf_mi, 8, 8, pal_uv_size, pal_uv_colors); | 15158 | neighbours.record_palette_uv_rect(leaf_mi, 8, 8, pal_uv_size, pal_uv_colors); |
| 15128 | } | 15159 | } |
| 15129 | - INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | 15160 | + hit!(INTER8_SKIP_BAND_HITS); |
| 15130 | neighbours.fill_skip_grid(leaf_mi, 2, skip); | 15161 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 15131 | // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal | 15162 | // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal |
| 15132 | // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm && | 15163 | // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm && |
| @@ -15216,7 +15247,7 @@ fn read_intra_mode_sub8( | |||
| 15216 | eprintln!("TRACE sub8 uv_mode value={uv_mode} rng={}", dec.debug_state().0); | 15247 | eprintln!("TRACE sub8 uv_mode value={uv_mode} rng={}", dec.debug_state().0); |
| 15217 | } | 15248 | } |
| 15218 | if (9..=12).contains(&uv_mode) { | 15249 | if (9..=12).contains(&uv_mode) { |
| 15219 | - SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | 15250 | + hit!(SMOOTH_UV_HITS); |
| 15220 | } | 15251 | } |
| 15221 | let alpha = if uv_mode == UV_CFL_PRED { | 15252 | let alpha = if uv_mode == UV_CFL_PRED { |
| 15222 | Some(read_cfl_alphas(dec, cdfs)) | 15253 | Some(read_cfl_alphas(dec, cdfs)) |
| @@ -15224,7 +15255,7 @@ fn read_intra_mode_sub8( | |||
| 15224 | None | 15255 | None |
| 15225 | }; | 15256 | }; |
| 15226 | if (V_PRED..=D67_PRED).contains(&uv_mode) { | 15257 | if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 15227 | - DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); | 15258 | + hit!(DIRECTIONAL_UV_HITS); |
| 15228 | } | 15259 | } |
| 15229 | // See the luma comment above: no angle delta below 8x8. | 15260 | // See the luma comment above: no angle delta below 8x8. |
| 15230 | let angle_delta_uv = 0; | 15261 | let angle_delta_uv = 0; |
| @@ -15239,7 +15270,7 @@ fn read_intra_mode_sub8( | |||
| 15239 | eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32); | 15270 | eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32); |
| 15240 | } | 15271 | } |
| 15241 | if use_filter_intra { | 15272 | if use_filter_intra { |
| 15242 | - FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | 15273 | + hit!(FILTER_INTRA_HITS); |
| 15243 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); | 15274 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 15244 | filter_intra = Some(fi_mode); | 15275 | filter_intra = Some(fi_mode); |
| 15245 | } | 15276 | } |
| @@ -15278,7 +15309,7 @@ fn decode_leaf_split4( | |||
| 15278 | // one a neighbour to its RIGHT sees (its top-right 4x4, mi(row, col-1))., fctx: &crate::decode::FrameCtx | 15309 | // one a neighbour to its RIGHT sees (its top-right 4x4, mi(row, col-1))., fctx: &crate::decode::FrameCtx |
| 15279 | fctx: &crate::decode::FrameCtx, | 15310 | fctx: &crate::decode::FrameCtx, |
| 15280 | ) -> Result<(usize, usize)> { | 15311 | ) -> Result<(usize, usize)> { |
| 15281 | - SUB8_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | 15312 | + hit!(SUB8_SPLIT_HITS); |
| 15282 | let (r, c) = outer_at; | 15313 | let (r, c) = outer_at; |
| 15283 | let mut above_mode = neighbours.above_mode[c]; | 15314 | let mut above_mode = neighbours.above_mode[c]; |
| 15284 | let mut left_mode = neighbours.left_mode[r]; | 15315 | let mut left_mode = neighbours.left_mode[r]; |
| @@ -15324,7 +15355,7 @@ fn decode_leaf_split4( | |||
| 15324 | neighbours.record_mode_mi(lmi.0, lmi.1, 1, 1, mode); | 15355 | neighbours.record_mode_mi(lmi.0, lmi.1, 1, 1, mode); |
| 15325 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); | 15356 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); |
| 15326 | if smooth_neighbor { | 15357 | if smooth_neighbor { |
| 15327 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 15358 | + hit!(SMOOTH_LUMA_HITS); |
| 15328 | } | 15359 | } |
| 15329 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); | 15360 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 15330 | let reach = Reach::of(4, px, py, y.width, y.height, fctx); | 15361 | let reach = Reach::of(4, px, py, y.width, y.height, fctx); |
| @@ -15388,8 +15419,8 @@ fn decode_leaf_split4( | |||
| 15388 | // their gates goes vacuous. | 15419 | // their gates goes vacuous. |
| 15389 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); | 15420 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); |
| 15390 | if alpha.is_some() { | 15421 | if alpha.is_some() { |
| 15391 | - CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | 15422 | + hit!(CHROMA_SKIP_CFL_HITS); |
| 15392 | - SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); | 15423 | + hit!(SKIP_CFL_HITS); |
| 15393 | } | 15424 | } |
| 15394 | 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); | 15425 | 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); |
| 15395 | 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); | 15426 | 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); |
| @@ -15538,8 +15569,8 @@ fn decode_leaf_rect8( | |||
| 15538 | // same `reconstruct_rect`/`reconstruct` calls below -- and under | 15569 | // same `reconstruct_rect`/`reconstruct` calls below -- and under |
| 15539 | // a split transform, per 4x4 unit with that unit's own edge, | 15570 | // a split transform, per 4x4 unit with that unit's own edge, |
| 15540 | // which is exactly what the depth-1 loop already does. | 15571 | // which is exactly what the depth-1 loop already does. |
| 15541 | - FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | 15572 | + hit!(FILTER_INTRA_RECT_HITS); |
| 15542 | - FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.set(c.get() + 1)); | 15573 | + hit!(FILTER_INTRA_RECT_SUB8_HITS); |
| 15543 | } | 15574 | } |
| 15544 | // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4 | 15575 | // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4 |
| 15545 | // leaf too, and is read for every intra block, skipped or not. Its | 15576 | // leaf too, and is read for every intra block, skipped or not. Its |
| @@ -15564,15 +15595,15 @@ fn decode_leaf_rect8( | |||
| 15564 | 0 | 15595 | 0 |
| 15565 | }; | 15596 | }; |
| 15566 | if depth != 0 { | 15597 | if depth != 0 { |
| 15567 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | 15598 | + hit!(TX_DEPTH_HITS); |
| 15568 | - RECT8_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 15599 | + hit!(RECT8_SPLIT_TX_HITS); |
| 15569 | } | 15600 | } |
| 15570 | leaf_modes[i] = mode; | 15601 | leaf_modes[i] = mode; |
| 15571 | leaf_skips[i] = skip; | 15602 | leaf_skips[i] = skip; |
| 15572 | neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); | 15603 | neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); |
| 15573 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); | 15604 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); |
| 15574 | if smooth_neighbor { | 15605 | if smooth_neighbor { |
| 15575 | - SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 15606 | + hit!(SMOOTH_LUMA_HITS); |
| 15576 | } | 15607 | } |
| 15577 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); | 15608 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 15578 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); | 15609 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); |
| @@ -15656,9 +15687,9 @@ fn decode_leaf_rect8( | |||
| 15656 | } | 15687 | } |
| 15657 | if done > 0 { | 15688 | if done > 0 { |
| 15658 | if vert { | 15689 | if vert { |
| 15659 | - TX4X8_CODED_HITS.with(|h| h.set(h.get() + 1)); | 15690 | + hit!(TX4X8_CODED_HITS); |
| 15660 | } else { | 15691 | } else { |
| 15661 | - TX8X4_CODED_HITS.with(|h| h.set(h.get() + 1)); | 15692 | + hit!(TX8X4_CODED_HITS); |
| 15662 | } | 15693 | } |
| 15663 | } | 15694 | } |
| 15664 | neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); | 15695 | neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); |
| @@ -15698,9 +15729,9 @@ fn decode_leaf_rect8( | |||
| 15698 | )?; | 15729 | )?; |
| 15699 | if levels.iter().any(|&l| l != 0) { | 15730 | if levels.iter().any(|&l| l != 0) { |
| 15700 | if vert { | 15731 | if vert { |
| 15701 | - TX4X8_CODED_HITS.with(|h| h.set(h.get() + 1)); | 15732 | + hit!(TX4X8_CODED_HITS); |
| 15702 | } else { | 15733 | } else { |
| 15703 | - TX8X4_CODED_HITS.with(|h| h.set(h.get() + 1)); | 15734 | + hit!(TX8X4_CODED_HITS); |
| 15704 | } | 15735 | } |
| 15705 | } | 15736 | } |
| 15706 | let residual = dequant_and_inverse_typed_wh( | 15737 | let residual = dequant_and_inverse_typed_wh( |
| @@ -15760,8 +15791,8 @@ fn decode_leaf_rect8( | |||
| 15760 | // their gates goes vacuous. | 15791 | // their gates goes vacuous. |
| 15761 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); | 15792 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); |
| 15762 | if alpha.is_some() { | 15793 | if alpha.is_some() { |
| 15763 | - CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | 15794 | + hit!(CHROMA_SKIP_CFL_HITS); |
| 15764 | - SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); | 15795 | + hit!(SKIP_CFL_HITS); |
| 15765 | } | 15796 | } |
| 15766 | 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); | 15797 | 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); |
| 15767 | 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); | 15798 | 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); |
| @@ -16579,7 +16610,7 @@ fn tx_size_context_txfm_rect( | |||
| 16579 | own_w: usize, | 16610 | own_w: usize, |
| 16580 | own_h: usize, fctx: &crate::decode::FrameCtx, | 16611 | own_h: usize, fctx: &crate::decode::FrameCtx, |
| 16581 | ) -> usize { | 16612 | ) -> usize { |
| 16582 | - INTRA_IN_INTER_TXCTX_HITS.with(|c| c.set(c.get() + 1)); | 16613 | + hit!(INTRA_IN_INTER_TXCTX_HITS); |
| 16583 | let has_above = mi_r > n.tile_row0_mi; | 16614 | let has_above = mi_r > n.tile_row0_mi; |
| 16584 | let has_left = mi_c > n.tile_col0_mi; | 16615 | let has_left = mi_c > n.tile_col0_mi; |
| 16585 | let mut above = usize::from(n.above_txfm[mi_c]) >= own_w; | 16616 | let mut above = usize::from(n.above_txfm[mi_c]) >= own_w; |
| @@ -16619,7 +16650,7 @@ fn tx_size_context_txfm_rect( | |||
| 16619 | let stale = usize::from(has_above && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= cw) | 16650 | let stale = usize::from(has_above && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= cw) |
| 16620 | + usize::from(has_left && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= ch); | 16651 | + usize::from(has_left && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= ch); |
| 16621 | if ctx != stale { | 16652 | if ctx != stale { |
| 16622 | - INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS.with(|c| c.set(c.get() + 1)); | 16653 | + hit!(INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS); |
| 16623 | } | 16654 | } |
| 16624 | } | 16655 | } |
| 16625 | ctx | 16656 | ctx |
| @@ -16717,7 +16748,7 @@ fn read_tx_size( | |||
| 16717 | ); | 16748 | ); |
| 16718 | } | 16749 | } |
| 16719 | if depth != 0 { | 16750 | if depth != 0 { |
| 16720 | - TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | 16751 | + hit!(TX_DEPTH_HITS); |
| 16721 | } | 16752 | } |
| 16722 | max_tx >> depth | 16753 | max_tx >> depth |
| 16723 | } | 16754 | } |
| @@ -17028,7 +17059,7 @@ fn read_var_tx_size( | |||
| 17028 | tx_h, | 17059 | tx_h, |
| 17029 | ); | 17060 | ); |
| 17030 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; | 17061 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; |
| 17031 | - TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1)); | 17062 | + hit!(TXFM_SPLIT_READS); |
| 17032 | if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | 17063 | if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { |
| 17033 | let (rng, _) = dec.debug_state(); | 17064 | let (rng, _) = dec.debug_state(); |
| 17034 | eprintln!( | 17065 | eprintln!( |
| @@ -17043,7 +17074,7 @@ fn read_var_tx_size( | |||
| 17043 | txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h)); | 17074 | txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h)); |
| 17044 | return; | 17075 | return; |
| 17045 | } | 17076 | } |
| 17046 | - TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | 17077 | + hit!(TXFM_SPLIT_HITS); |
| 17047 | let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h); | 17078 | let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h); |
| 17048 | if (sub_w, sub_h) == (4, 4) { | 17079 | if (sub_w, sub_h) == (4, 4) { |
| 17049 | // libaom's `sub_txs == TX_4X4` early return: every mi cell of the | 17080 | // libaom's `sub_txs == TX_4X4` early return: every mi cell of the |
| @@ -17188,11 +17219,13 @@ fn read_block_tx_size( | |||
| 17188 | leaves.push((row, col, tx, tx)); | 17219 | leaves.push((row, col, tx, tx)); |
| 17189 | } | 17220 | } |
| 17190 | } | 17221 | } |
| 17191 | - INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| { | 17222 | + hit_do! { |
| 17192 | - let mut h = c.get(); | 17223 | + INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| { |
| 17193 | - h[(side.trailing_zeros() as usize).saturating_sub(3).min(3)] += 1; | 17224 | + let mut h = c.get(); |
| 17194 | - c.set(h); | 17225 | + h[(side.trailing_zeros() as usize).saturating_sub(3).min(3)] += 1; |
| 17195 | - }); | 17226 | + c.set(h); |
| 17227 | + }); | ||
| 17228 | + } | ||
| 17196 | return Ok((tx, Some(leaves))); | 17229 | return Ok((tx, Some(leaves))); |
| 17197 | } | 17230 | } |
| 17198 | Ok((tx, None)) | 17231 | Ok((tx, None)) |
| @@ -17596,7 +17629,7 @@ fn read_block_tx_size_rect( | |||
| 17596 | // transform, and `set_txfm_ctxs` records exactly what | 17629 | // transform, and `set_txfm_ctxs` records exactly what |
| 17597 | // `txfm_partition_update` would for that same unit. | 17630 | // `txfm_partition_update` would for that same unit. |
| 17598 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); | 17631 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); |
| 17599 | - RECT_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); | 17632 | + hit!(RECT_INTER_TU_HITS); |
| 17600 | return Ok(None); | 17633 | return Ok(None); |
| 17601 | } | 17634 | } |
| 17602 | let ctx = txfm_partition_ctx_rect( | 17635 | let ctx = txfm_partition_ctx_rect( |
| @@ -17607,7 +17640,7 @@ fn read_block_tx_size_rect( | |||
| 17607 | tx_h, | 17640 | tx_h, |
| 17608 | ); | 17641 | ); |
| 17609 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; | 17642 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; |
| 17610 | - TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1)); | 17643 | + hit!(TXFM_SPLIT_READS); |
| 17611 | if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | 17644 | if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { |
| 17612 | let (rng, _) = dec.debug_state(); | 17645 | let (rng, _) = dec.debug_state(); |
| 17613 | eprintln!( | 17646 | eprintln!( |
| @@ -17619,11 +17652,11 @@ fn read_block_tx_size_rect( | |||
| 17619 | } | 17652 | } |
| 17620 | if !split { | 17653 | if !split { |
| 17621 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); | 17654 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); |
| 17622 | - RECT_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); | 17655 | + hit!(RECT_INTER_TU_HITS); |
| 17623 | return Ok(None); | 17656 | return Ok(None); |
| 17624 | } | 17657 | } |
| 17625 | - TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | 17658 | + hit!(TXFM_SPLIT_HITS); |
| 17626 | - RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1)); | 17659 | + hit!(RECT_INTER_TXSPLIT_HITS); |
| 17627 | // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays | 17660 | // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays |
| 17628 | // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`, | 17661 | // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`, |
| 17629 | // `[TX_16X64] == TX_16X32` -- so the recursion below is the general | 17662 | // `[TX_16X64] == TX_16X32` -- so the recursion below is the general |
| @@ -17708,14 +17741,16 @@ fn read_inter_plane_rect( | |||
| 17708 | // rectangular shape (lane-sbpart r8). | 17741 | // rectangular shape (lane-sbpart r8). |
| 17709 | let (cw, ch) = (w.min(32), h.min(32)); | 17742 | let (cw, ch) = (w.min(32), h.min(32)); |
| 17710 | if plane_idx == 0 && w.max(h) == 64 { | 17743 | if plane_idx == 0 && w.max(h) == 64 { |
| 17711 | - RECT64_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); | 17744 | + hit!(RECT64_INTER_TU_HITS); |
| 17712 | } | 17745 | } |
| 17713 | if plane_idx == 0 && (w, h) == (32, 8) || plane_idx == 0 && (w, h) == (8, 32) { | 17746 | if plane_idx == 0 && (w, h) == (32, 8) || plane_idx == 0 && (w, h) == (8, 32) { |
| 17714 | - RECT32X8_INTER_TU_HITS.with(|c| { | 17747 | + hit_do! { |
| 17715 | - let mut v = c.get(); | 17748 | + RECT32X8_INTER_TU_HITS.with(|c| { |
| 17716 | - v[usize::from(w == 8)] += 1; | 17749 | + let mut v = c.get(); |
| 17717 | - c.set(v); | 17750 | + v[usize::from(w == 8)] += 1; |
| 17718 | - }); | 17751 | + c.set(v); |
| 17752 | + }); | ||
| 17753 | + } | ||
| 17719 | } | 17754 | } |
| 17720 | let (corner, tx_type) = if (cw, ch) == (32, 32) { | 17755 | let (corner, tx_type) = if (cw, ch) == (32, 32) { |
| 17721 | let scan32 = default_scan(TX32); | 17756 | let scan32 = default_scan(TX32); |
| @@ -18289,7 +18324,7 @@ fn edge_params_body( | |||
| 18289 | [4, 8, 14, 14, 14][dim] | 18324 | [4, 8, 14, 14, 14][dim] |
| 18290 | }; | 18325 | }; |
| 18291 | let level = if cur_level != 0 { cur_level } else { pv_level }; | 18326 | let level = if cur_level != 0 { cur_level } else { pv_level }; |
| 18292 | - DEBLOCK_HITS.with(|c| c.set(c.get() + 1)); | 18327 | + hit!(DEBLOCK_HITS); |
| 18293 | Some((len, level)) | 18328 | Some((len, level)) |
| 18294 | } | 18329 | } |
| 18295 | 18330 | ||
| @@ -19477,7 +19512,7 @@ fn cdef_band( | |||
| 19477 | let mut mi_c = 0usize; | 19512 | let mut mi_c = 0usize; |
| 19478 | while mi_c < skip_grid.mi_cols { | 19513 | while mi_c < skip_grid.mi_cols { |
| 19479 | if skip_grid.is_skip_txfm(mi_r, mi_c) { | 19514 | if skip_grid.is_skip_txfm(mi_r, mi_c) { |
| 19480 | - CDEF_SKIPPED_UNITS.with(|c| c.set(c.get() + 1)); | 19515 | + hit!(CDEF_SKIPPED_UNITS); |
| 19481 | } | 19516 | } |
| 19482 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { | 19517 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { |
| 19483 | let sidx = strength_idx(mi_r, mi_c); | 19518 | let sidx = strength_idx(mi_r, mi_c); |
| @@ -19527,7 +19562,7 @@ fn cdef_band( | |||
| 19527 | || cdef.uv_pri_strength[sidx] != 0 | 19562 | || cdef.uv_pri_strength[sidx] != 0 |
| 19528 | || cdef.uv_sec_strength[sidx] != 0) | 19563 | || cdef.uv_sec_strength[sidx] != 0) |
| 19529 | { | 19564 | { |
| 19530 | - CDEF_STRADDLE_UNITS.with(|c| c.set(c.get() + 1)); | 19565 | + hit!(CDEF_STRADDLE_UNITS); |
| 19531 | } | 19566 | } |
| 19532 | if enable_primary || enable_secondary { | 19567 | if enable_primary || enable_secondary { |
| 19533 | cdef_filter_block( | 19568 | cdef_filter_block( |
| @@ -19998,6 +20033,8 @@ fn pipe_filters_ok(fctx: &crate::decode::FrameCtx, tile_cols: u32, lf_present: b | |||
| 19998 | /// [`apply_cdef`]'s early returns (lane-pipefilt: the pipelined path | 20033 | /// [`apply_cdef`]'s early returns (lane-pipefilt: the pipelined path |
| 19999 | /// never enters `apply_cdef`, so it calls this itself). | 20034 | /// never enters `apply_cdef`, so it calls this itself). |
| 20000 | fn cdef_scan_counters(skip_grid: &Neighbours) { | 20035 | fn cdef_scan_counters(skip_grid: &Neighbours) { |
| 20036 | + let _ = skip_grid; | ||
| 20037 | + hit_do! { | ||
| 20001 | let mut r = 0usize; | 20038 | let mut r = 0usize; |
| 20002 | while r < skip_grid.mi_rows { | 20039 | while r < skip_grid.mi_rows { |
| 20003 | let mut c = 0usize; | 20040 | let mut c = 0usize; |
| @@ -20010,7 +20047,7 @@ fn cdef_scan_counters(skip_grid: &Neighbours) { | |||
| 20010 | .map_or(true, |x| x.written) | 20047 | .map_or(true, |x| x.written) |
| 20011 | }) | 20048 | }) |
| 20012 | }) { | 20049 | }) { |
| 20013 | - CDEF_UNWRITTEN_SKIP_UNITS.with(|c2| c2.set(c2.get() + 1)); | 20050 | + hit!(CDEF_UNWRITTEN_SKIP_UNITS); |
| 20014 | if crate::envflags::env_flag!("EC_AV1_DEBUG_CDEF_BAND") { | 20051 | if crate::envflags::env_flag!("EC_AV1_DEBUG_CDEF_BAND") { |
| 20015 | eprintln!("cdef band unwritten at mi ({r},{c}) px ({},{})", r * 4, c * 4); | 20052 | eprintln!("cdef band unwritten at mi ({r},{c}) px ({},{})", r * 4, c * 4); |
| 20016 | } | 20053 | } |
| @@ -20023,12 +20060,13 @@ fn cdef_scan_counters(skip_grid: &Neighbours) { | |||
| 20023 | }; | 20060 | }; |
| 20024 | let first = cell(0, 0); | 20061 | let first = cell(0, 0); |
| 20025 | if (0..2).any(|rr| (0..2).any(|cc| cell(rr, cc) != first)) { | 20062 | if (0..2).any(|rr| (0..2).any(|cc| cell(rr, cc) != first)) { |
| 20026 | - CDEF_MIXED_SKIP_UNITS.with(|c2| c2.set(c2.get() + 1)); | 20063 | + hit!(CDEF_MIXED_SKIP_UNITS); |
| 20027 | } | 20064 | } |
| 20028 | c += 2; | 20065 | c += 2; |
| 20029 | } | 20066 | } |
| 20030 | r += 2; | 20067 | r += 2; |
| 20031 | } | 20068 | } |
| 20069 | + } | ||
| 20032 | } | 20070 | } |
| 20033 | 20071 | ||
| 20034 | /// `true` when this frame's CDEF cannot change a sample: `bits == 0` still | 20072 | /// `true` when this frame's CDEF cannot change a sample: `bits == 0` still |
| @@ -20471,7 +20509,7 @@ fn read_sb128_root( | |||
| 20471 | let ctx128 = neighbours.partition_ctx(at128, 128); | 20509 | let ctx128 = neighbours.partition_ctx(at128, 128); |
| 20472 | let (has_cols128, has_rows128) = (mi_c128 + SB_MI < mi_cols, mi_r128 + SB_MI < mi_rows); | 20510 | let (has_cols128, has_rows128) = (mi_c128 + SB_MI < mi_cols, mi_r128 + SB_MI < mi_rows); |
| 20473 | let part128 = if has_cols128 && has_rows128 { | 20511 | let part128 = if has_cols128 && has_rows128 { |
| 20474 | - PART128_SYMBOLS.with(|c| c.set(c.get() + 1)); | 20512 | + hit!(PART128_SYMBOLS); |
| 20475 | let p = dec.symbol(&mut cdfs.partition_w128[ctx128]); | 20513 | let p = dec.symbol(&mut cdfs.partition_w128[ctx128]); |
| 20476 | if crate::envflags::env_flag!("EC_AV1_TRACE") { | 20514 | if crate::envflags::env_flag!("EC_AV1_TRACE") { |
| 20477 | eprintln!("TRACE partition_w128 ctx={ctx128} value={p}"); | 20515 | eprintln!("TRACE partition_w128 ctx={ctx128} value={p}"); |
| @@ -20484,13 +20522,13 @@ fn read_sb128_root( | |||
| 20484 | // gathered arm. Value 1 is SPLIT; 0 is HORZ (rows out of frame) or | 20522 | // gathered arm. Value 1 is SPLIT; 0 is HORZ (rows out of frame) or |
| 20485 | // VERT (cols out of frame), which the refusal below then names | 20523 | // VERT (cols out of frame), which the refusal below then names |
| 20486 | // instead of silently reconstructing a split. | 20524 | // instead of silently reconstructing a split. |
| 20487 | - PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() + 1)); | 20525 | + hit!(PART128_GATHERED_SYMBOLS); |
| 20488 | match (has_cols128, has_rows128) { | 20526 | match (has_cols128, has_rows128) { |
| 20489 | (true, false) => { | 20527 | (true, false) => { |
| 20490 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 { | 20528 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 { |
| 20491 | PARTITION_SPLIT | 20529 | PARTITION_SPLIT |
| 20492 | } else { | 20530 | } else { |
| 20493 | - PART128_EDGE_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 20531 | + hit!(PART128_EDGE_HORZ_HITS); |
| 20494 | PARTITION_HORZ | 20532 | PARTITION_HORZ |
| 20495 | } | 20533 | } |
| 20496 | } | 20534 | } |
| @@ -20498,7 +20536,7 @@ fn read_sb128_root( | |||
| 20498 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 { | 20536 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 { |
| 20499 | PARTITION_SPLIT | 20537 | PARTITION_SPLIT |
| 20500 | } else { | 20538 | } else { |
| 20501 | - PART128_EDGE_VERT_HITS.with(|c| c.set(c.get() + 1)); | 20539 | + hit!(PART128_EDGE_VERT_HITS); |
| 20502 | PARTITION_VERT | 20540 | PARTITION_VERT |
| 20503 | } | 20541 | } |
| 20504 | } | 20542 | } |
| @@ -20520,19 +20558,21 @@ fn read_sb128_root( | |||
| 20520 | // for BLOCK_128X128 by `av1_get_partition_cdf`'s 8-symbol alphabet, | 20558 | // for BLOCK_128X128 by `av1_get_partition_cdf`'s 8-symbol alphabet, |
| 20521 | // which stops at VERT_B). | 20559 | // which stops at VERT_B). |
| 20522 | match part128 { | 20560 | match part128 { |
| 20523 | - PARTITION_SPLIT => PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)), | 20561 | + PARTITION_SPLIT => hit!(PART128_SPLIT_HITS), |
| 20524 | - PARTITION_NONE => PART128_NONE_HITS.with(|c| c.set(c.get() + 1)), | 20562 | + PARTITION_NONE => hit!(PART128_NONE_HITS), |
| 20525 | - PARTITION_HORZ => PART128_HORZ_HITS.with(|c| c.set(c.get() + 1)), | 20563 | + PARTITION_HORZ => hit!(PART128_HORZ_HITS), |
| 20526 | - PARTITION_VERT => PART128_VERT_HITS.with(|c| c.set(c.get() + 1)), | 20564 | + PARTITION_VERT => hit!(PART128_VERT_HITS), |
| 20527 | // lane-sb128c r9: the four AB shapes at the 128 root -- one | 20565 | // lane-sb128c r9: the four AB shapes at the 128 root -- one |
| 20528 | // 128x64/64x128 half plus two 64x64 quadrants, decoded by both tile | 20566 | // 128x64/64x128 half plus two 64x64 quadrants, decoded by both tile |
| 20529 | // paths below in libaom `decode_partition`'s own visit order. | 20567 | // paths below in libaom `decode_partition`'s own visit order. |
| 20530 | p if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&p) => { | 20568 | p if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&p) => { |
| 20531 | - PART128_AB_HITS.with(|c| { | 20569 | + hit_do! { |
| 20532 | - let mut h = c.get(); | 20570 | + PART128_AB_HITS.with(|c| { |
| 20533 | - h[p - PARTITION_HORZ_A] += 1; | 20571 | + let mut h = c.get(); |
| 20534 | - c.set(h); | 20572 | + h[p - PARTITION_HORZ_A] += 1; |
| 20535 | - }); | 20573 | + c.set(h); |
| 20574 | + }); | ||
| 20575 | + } | ||
| 20536 | } | 20576 | } |
| 20537 | _ => { | 20577 | _ => { |
| 20538 | return Err(unsupported( | 20578 | return Err(unsupported( |
| @@ -20730,7 +20770,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 20730 | (mi_col1 as usize * 2).min(v.width), | 20770 | (mi_col1 as usize * 2).min(v.width), |
| 20731 | (mi_row1 as usize * 2).min(v.height), | 20771 | (mi_row1 as usize * 2).min(v.height), |
| 20732 | ); | 20772 | ); |
| 20733 | - TILE_HITS.with(|c| c.set(c.get() + 1)); | 20773 | + hit!(TILE_HITS); |
| 20734 | 20774 | ||
| 20735 | // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` -- | 20775 | // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` -- |
| 20736 | // its one block covers all four 64x64 quadrants, so the remaining three | 20776 | // its one block covers all four 64x64 quadrants, so the remaining three |
| @@ -21305,7 +21345,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 21305 | let arm = part16 - PARTITION_HORZ_A; | 21345 | let arm = part16 - PARTITION_HORZ_A; |
| 21306 | bump_ab16(arm); | 21346 | bump_ab16(arm); |
| 21307 | if part16 == PARTITION_VERT_B { | 21347 | if part16 == PARTITION_VERT_B { |
| 21308 | - VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1)); | 21348 | + hit!(VERT_B_INTRA_HITS); |
| 21309 | } | 21349 | } |
| 21310 | let _vert_guard = if part16 == PARTITION_VERT_A || part16 == PARTITION_VERT_B { | 21350 | let _vert_guard = if part16 == PARTITION_VERT_A || part16 == PARTITION_VERT_B { |
| 21311 | Some(crate::encode::Reach::vert_ab_partition()) | 21351 | Some(crate::encode::Reach::vert_ab_partition()) |
| @@ -21404,7 +21444,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 21404 | continue; | 21444 | continue; |
| 21405 | } | 21445 | } |
| 21406 | if part16 == PARTITION_HORZ { | 21446 | if part16 == PARTITION_HORZ { |
| 21407 | - HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); | 21447 | + hit!(HORZ_VERT_INTRA_HITS); |
| 21408 | let (mi_row0, mi_col0) = ( | 21448 | let (mi_row0, mi_col0) = ( |
| 21409 | sr as u32 * SUB_MI, | 21449 | sr as u32 * SUB_MI, |
| 21410 | sc as u32 * SUB_MI, | 21450 | sc as u32 * SUB_MI, |
| @@ -21452,7 +21492,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 21452 | continue; | 21492 | continue; |
| 21453 | } | 21493 | } |
| 21454 | if part16 == PARTITION_VERT { | 21494 | if part16 == PARTITION_VERT { |
| 21455 | - HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); | 21495 | + hit!(HORZ_VERT_INTRA_HITS); |
| 21456 | let (mi_row0, mi_col0) = ( | 21496 | let (mi_row0, mi_col0) = ( |
| 21457 | sr as u32 * SUB_MI, | 21497 | sr as u32 * SUB_MI, |
| 21458 | sc as u32 * SUB_MI, | 21498 | sc as u32 * SUB_MI, |
| @@ -21706,8 +21746,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 21706 | // whole visible band of a frame whose | 21746 | // whole visible band of a frame whose |
| 21707 | // height (resp. width) is 8 mod 16 -- | 21747 | // height (resp. width) is 8 mod 16 -- |
| 21708 | // the user's 3840x1608 film. | 21748 | // the user's 3840x1608 film. |
| 21709 | - HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); | 21749 | + hit!(HORZ_VERT_INTRA_HITS); |
| 21710 | - EDGE_RECT_STRIP_HITS.with(|c| c.set(c.get() + 1)); | 21750 | + hit!(EDGE_RECT_STRIP_HITS); |
| 21711 | let (mi_row0, mi_col0) = | 21751 | let (mi_row0, mi_col0) = |
| 21712 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | 21752 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 21713 | let (bw, bh) = if has_cols16 { (16, 8) } else { (8, 16) }; | 21753 | let (bw, bh) = if has_cols16 { (16, 8) } else { (8, 16) }; |
| @@ -21936,7 +21976,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 21936 | // a true 32x16 strip below (mirrors | 21976 | // a true 32x16 strip below (mirrors |
| 21937 | // decode_inter_block's cd6cb6d HORZ_A: TL, | 21977 | // decode_inter_block's cd6cb6d HORZ_A: TL, |
| 21938 | // TR, bottom strip). | 21978 | // TR, bottom strip). |
| 21939 | - INTRA_HORZ_A_HITS.with(|c| c.set(c.get() + 1)); | 21979 | + hit!(INTRA_HORZ_A_HITS); |
| 21940 | decode_block( | 21980 | decode_block( |
| 21941 | &mut dec, | 21981 | &mut dec, |
| 21942 | &mut cdfs, | 21982 | &mut cdfs, |
| @@ -22011,7 +22051,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 22011 | // two 16x16 squares below (mirrors HORZ_A | 22051 | // two 16x16 squares below (mirrors HORZ_A |
| 22012 | // with the strip/squares order flipped, same | 22052 | // with the strip/squares order flipped, same |
| 22013 | // shape as libaom decode_partition's HORZ_B). | 22053 | // shape as libaom decode_partition's HORZ_B). |
| 22014 | - INTRA_HORZ_B_HITS.with(|c| c.set(c.get() + 1)); | 22054 | + hit!(INTRA_HORZ_B_HITS); |
| 22015 | decode_block_rect( | 22055 | decode_block_rect( |
| 22016 | &mut dec, | 22056 | &mut dec, |
| 22017 | &mut cdfs, | 22057 | &mut cdfs, |
| @@ -22085,7 +22125,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 22085 | // lane-part32 r1: mirror of HORZ_A with | 22125 | // lane-part32 r1: mirror of HORZ_A with |
| 22086 | // width/height swapped (TL, BL, right 16x32 | 22126 | // width/height swapped (TL, BL, right 16x32 |
| 22087 | // strip). | 22127 | // strip). |
| 22088 | - INTRA_VERT_A_HITS.with(|c| c.set(c.get() + 1)); | 22128 | + hit!(INTRA_VERT_A_HITS); |
| 22089 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); | 22129 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 22090 | decode_block( | 22130 | decode_block( |
| 22091 | &mut dec, | 22131 | &mut dec, |
| @@ -22161,7 +22201,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 22161 | // left + two 16x16 squares on the right | 22201 | // left + two 16x16 squares on the right |
| 22162 | // (libaom decode_partition VERT_B: left | 22202 | // (libaom decode_partition VERT_B: left |
| 22163 | // strip, TR, BR). | 22203 | // strip, TR, BR). |
| 22164 | - INTRA_VERT_B_HITS.with(|c| c.set(c.get() + 1)); | 22204 | + hit!(INTRA_VERT_B_HITS); |
| 22165 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); | 22205 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 22166 | decode_block_rect( | 22206 | decode_block_rect( |
| 22167 | &mut dec, | 22207 | &mut dec, |
| @@ -22377,11 +22417,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 22377 | // TR, BR). The pieces are exactly the ones already proven | 22417 | // TR, BR). The pieces are exactly the ones already proven |
| 22378 | // by the `PARTITION_NONE`-under-SPLIT (32x32 square) and | 22418 | // by the `PARTITION_NONE`-under-SPLIT (32x32 square) and |
| 22379 | // `PARTITION_HORZ`/`VERT` (rect64 strip) arms above. | 22419 | // `PARTITION_HORZ`/`VERT` (rect64 strip) arms above. |
| 22380 | - SB_AB_HITS.with(|c| { | 22420 | + hit_do! { |
| 22381 | - let mut h = c.get(); | 22421 | + SB_AB_HITS.with(|c| { |
| 22382 | - h[part - PARTITION_HORZ_A] += 1; | 22422 | + let mut h = c.get(); |
| 22383 | - c.set(h); | 22423 | + h[part - PARTITION_HORZ_A] += 1; |
| 22384 | - }); | 22424 | + c.set(h); |
| 22425 | + }); | ||
| 22426 | + } | ||
| 22385 | // lane-part32 r5: only the two VERTICAL arms reorder the | 22427 | // lane-part32 r5: only the two VERTICAL arms reorder the |
| 22386 | // square sub-blocks (TL, BL, TR, BR), so only they switch | 22428 | // square sub-blocks (TL, BL, TR, BR), so only they switch |
| 22387 | // libaom's `has_tr`/`has_bl` tables. | 22429 | // libaom's `has_tr`/`has_bl` tables. |
| @@ -22818,7 +22860,7 @@ fn resolve_interp_filter( | |||
| 22818 | sym0 | 22860 | sym0 |
| 22819 | }; | 22861 | }; |
| 22820 | if enable_dual_filter && sym0 != sym1 { | 22862 | if enable_dual_filter && sym0 != sym1 { |
| 22821 | - DUAL_FILTER_DIFF_HITS.with(|c| c.set(c.get() + 1)); | 22863 | + hit!(DUAL_FILTER_DIFF_HITS); |
| 22822 | } | 22864 | } |
| 22823 | if crate::envflags::env_flag!("EC_TRACE_MODE") { | 22865 | if crate::envflags::env_flag!("EC_TRACE_MODE") { |
| 22824 | eprintln!( | 22866 | eprintln!( |
| @@ -23185,7 +23227,7 @@ fn read_single_ref( | |||
| 23185 | } | 23227 | } |
| 23186 | }; | 23228 | }; |
| 23187 | if ref_frame != LAST_FRAME { | 23229 | if ref_frame != LAST_FRAME { |
| 23188 | - NON_LAST_REF_HITS.with(|c| c.set(c.get() + 1)); | 23230 | + hit!(NON_LAST_REF_HITS); |
| 23189 | let c = match ref_frame { | 23231 | let c = match ref_frame { |
| 23190 | LAST2_FRAME => &LAST2_HITS, | 23232 | LAST2_FRAME => &LAST2_HITS, |
| 23191 | LAST3_FRAME => &LAST3_HITS, | 23233 | LAST3_FRAME => &LAST3_HITS, |
| @@ -23445,7 +23487,7 @@ fn overlappable_above( | |||
| 23445 | if let Some(info) = nb { | 23487 | if let Some(info) = nb { |
| 23446 | if info.is_inter { | 23488 | if info.is_inter { |
| 23447 | if src != col { | 23489 | if src != col { |
| 23448 | - OBMC_PAIR_FILTER_HITS.with(|c| c.set(c.get() + 1)); | 23490 | + hit!(OBMC_PAIR_FILTER_HITS); |
| 23449 | } | 23491 | } |
| 23450 | // lane-t900 r14: libaom passes `AOMMIN(xd->width, mi_step)` | 23492 | // lane-t900 r14: libaom passes `AOMMIN(xd->width, mi_step)` |
| 23451 | // as `op_mi_size` -- the block's OWN width, never the | 23493 | // as `op_mi_size` -- the block's OWN width, never the |
| @@ -23498,7 +23540,7 @@ fn overlappable_left( | |||
| 23498 | if let Some(info) = nb { | 23540 | if let Some(info) = nb { |
| 23499 | if info.is_inter { | 23541 | if info.is_inter { |
| 23500 | if src != row { | 23542 | if src != row { |
| 23501 | - OBMC_PAIR_FILTER_HITS.with(|c| c.set(c.get() + 1)); | 23543 | + hit!(OBMC_PAIR_FILTER_HITS); |
| 23502 | } | 23544 | } |
| 23503 | // lane-t900 r14: `AOMMIN(xd->height, mi_step)` -- see | 23545 | // lane-t900 r14: `AOMMIN(xd->height, mi_step)` -- see |
| 23504 | // `overlappable_above`. | 23546 | // `overlappable_above`. |
| @@ -23670,7 +23712,7 @@ fn find_samples( | |||
| 23670 | // wrong-alphabet-same-value). | 23712 | // wrong-alphabet-same-value). |
| 23671 | let tr_reach = crate::mvstack::has_top_right(mi_row, mi_col, bw4, bh4, fctx); | 23713 | let tr_reach = crate::mvstack::has_top_right(mi_row, mi_col, bw4, bh4, fctx); |
| 23672 | if do_tr && bw4 != bh4 && tr_reach != has_top_right(mi_row, mi_col, bw4, fctx) { | 23714 | if do_tr && bw4 != bh4 && tr_reach != has_top_right(mi_row, mi_col, bw4, fctx) { |
| 23673 | - TR_REACH_LONGER_SIDE_HITS.with(|c| c.set(c.get() + 1)); | 23715 | + hit!(TR_REACH_LONGER_SIDE_HITS); |
| 23674 | } | 23716 | } |
| 23675 | if do_tr && tr_reach { | 23717 | if do_tr && tr_reach { |
| 23676 | let tr_col = mi_col + bw4; | 23718 | let tr_col = mi_col + bw4; |
| @@ -23768,7 +23810,7 @@ fn neighbour_filter( | |||
| 23768 | "an OBMC neighbour whose switchable interp filter was never recorded", | 23810 | "an OBMC neighbour whose switchable interp filter was never recorded", |
| 23769 | )); | 23811 | )); |
| 23770 | } | 23812 | } |
| 23771 | - OBMC_FILTER_BAND_READS.with(|c| c.set(c.get() + 1)); | 23813 | + hit!(OBMC_FILTER_BAND_READS); |
| 23772 | Ok(( | 23814 | Ok(( |
| 23773 | mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize), | 23815 | mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize), |
| 23774 | mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize), | 23816 | mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize), |
| @@ -24133,7 +24175,7 @@ fn obmc_plan( | |||
| 24133 | // byte-exact against an instrumented aomdec, the refusal is gone and the | 24175 | // byte-exact against an instrumented aomdec, the refusal is gone and the |
| 24134 | // counter below is what the gate's `--enable-obmc=1` arm reads. | 24176 | // counter below is what the gate's `--enable-obmc=1` arm reads. |
| 24135 | if matches!((write_w, write_h), (16, 8) | (8, 16)) { | 24177 | if matches!((write_w, write_h), (16, 8) | (8, 16)) { |
| 24136 | - OBMC_RECT_LEAF_HITS.with(|c| c.set(c.get() + 1)); | 24178 | + hit!(OBMC_RECT_LEAF_HITS); |
| 24137 | } | 24179 | } |
| 24138 | // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own | 24180 | // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own |
| 24139 | // half (`reconinter.c` 860/899), inert below 128. | 24181 | // half (`reconinter.c` 860/899), inert below 128. |
| @@ -24162,7 +24204,7 @@ fn obmc_plan( | |||
| 24162 | ec_obmc_trace("above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); | 24204 | ec_obmc_trace("above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); |
| 24163 | let (nb_width, _) = ref_dims(nb.ref_frame, refpix)?; | 24205 | let (nb_width, _) = ref_dims(nb.ref_frame, refpix)?; |
| 24164 | if mi_col + off4 + span4 > mi_cols { | 24206 | if mi_col + off4 + span4 > mi_cols { |
| 24165 | - OBMC_EDGE_SPAN_HITS.with(|c| c.set(c.get() + 1)); | 24207 | + hit!(OBMC_EDGE_SPAN_HITS); |
| 24166 | } | 24208 | } |
| 24167 | above.push(ObmcNb { | 24209 | above.push(ObmcNb { |
| 24168 | off4, | 24210 | off4, |
| @@ -24186,7 +24228,7 @@ fn obmc_plan( | |||
| 24186 | ec_obmc_trace("left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); | 24228 | ec_obmc_trace("left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); |
| 24187 | let (nb_width, _) = ref_dims(nb.ref_frame, refpix)?; | 24229 | let (nb_width, _) = ref_dims(nb.ref_frame, refpix)?; |
| 24188 | if mi_row + off4 + span4 > mi_rows { | 24230 | if mi_row + off4 + span4 > mi_rows { |
| 24189 | - OBMC_EDGE_SPAN_HITS.with(|c| c.set(c.get() + 1)); | 24231 | + hit!(OBMC_EDGE_SPAN_HITS); |
| 24190 | } | 24232 | } |
| 24191 | left.push(ObmcNb { | 24233 | left.push(ObmcNb { |
| 24192 | off4, | 24234 | off4, |
| @@ -24499,7 +24541,7 @@ fn read_comp_mode( | |||
| 24499 | let ctx = reference_mode_ctx(above, left); | 24541 | let ctx = reference_mode_ctx(above, left); |
| 24500 | let compound = dec.symbol(&mut cdfs.comp_mode[ctx]) == 1; | 24542 | let compound = dec.symbol(&mut cdfs.comp_mode[ctx]) == 1; |
| 24501 | if compound { | 24543 | if compound { |
| 24502 | - COMP_MODE_HITS.with(|c| c.set(c.get() + 1)); | 24544 | + hit!(COMP_MODE_HITS); |
| 24503 | } | 24545 | } |
| 24504 | compound | 24546 | compound |
| 24505 | } | 24547 | } |
| @@ -24542,7 +24584,7 @@ fn read_compound_ref_frames( | |||
| 24542 | let type_ctx = comp_reference_type_ctx(above, left); | 24584 | let type_ctx = comp_reference_type_ctx(above, left); |
| 24543 | let unidir = dec.symbol(&mut cdfs.comp_ref_type[type_ctx]) == 0; | 24585 | let unidir = dec.symbol(&mut cdfs.comp_ref_type[type_ctx]) == 0; |
| 24544 | if unidir { | 24586 | if unidir { |
| 24545 | - UNI_COMP_HITS.with(|c| c.set(c.get() + 1)); | 24587 | + hit!(UNI_COMP_HITS); |
| 24546 | // uni_comp_ref (p0): forward vs. backward -- av1_get_pred_context_- | 24588 | // uni_comp_ref (p0): forward vs. backward -- av1_get_pred_context_- |
| 24547 | // uni_comp_ref_p is single_ref_p1's own forward/backward vote. | 24589 | // uni_comp_ref_p is single_ref_p1's own forward/backward vote. |
| 24548 | let bit = dec.symbol(&mut cdfs.uni_comp_ref[single_ref_p1_ctx(a, a1, l, l1)][0]); | 24590 | let bit = dec.symbol(&mut cdfs.uni_comp_ref[single_ref_p1_ctx(a, a1, l, l1)][0]); |
| @@ -24604,7 +24646,7 @@ fn read_inter_compound_mode( | |||
| 24604 | ref_mv_ctx: usize, | 24646 | ref_mv_ctx: usize, |
| 24605 | ) -> u8 { | 24647 | ) -> u8 { |
| 24606 | let ctx = cdf::COMPOUND_MODE_CTX_MAP[ref_mv_ctx >> 1][new_mv_ctx.min(4)]; | 24648 | let ctx = cdf::COMPOUND_MODE_CTX_MAP[ref_mv_ctx >> 1][new_mv_ctx.min(4)]; |
| 24607 | - COMPOUND_MODE_HITS.with(|c| c.set(c.get() + 1)); | 24649 | + hit!(COMPOUND_MODE_HITS); |
| 24608 | dec.symbol(&mut cdfs.inter_compound_mode[ctx]) as u8 | 24650 | dec.symbol(&mut cdfs.inter_compound_mode[ctx]) as u8 |
| 24609 | } | 24651 | } |
| 24610 | 24652 | ||
| @@ -24882,7 +24924,7 @@ fn decode_inter_block( | |||
| 24882 | // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd | 24924 | // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd |
| 24883 | // strip (`is_chroma_reference`); every other block keeps its own. | 24925 | // strip (`is_chroma_reference`); every other block keeps its own. |
| 24884 | let strip_chroma = fctx.inter_strip_chroma.with(std::cell::Cell::take); | 24926 | let strip_chroma = fctx.inter_strip_chroma.with(std::cell::Cell::take); |
| 24885 | - fctx.inter_last_mc.with(|c| c.set(None)); | 24927 | + hit_do! { fctx.inter_last_mc.with(|c| c.set(None)); } |
| 24886 | let has_chroma = strip_chroma.is_none_or(|s| s.has_chroma); | 24928 | let has_chroma = strip_chroma.is_none_or(|s| s.has_chroma); |
| 24887 | let (cpx, cpy) = match strip_chroma { | 24929 | let (cpx, cpy) = match strip_chroma { |
| 24888 | Some(s) if s.has_chroma => (s.pair_mi.1 * MI / 2, s.pair_mi.0 * MI / 2), | 24930 | Some(s) if s.has_chroma => (s.pair_mi.1 * MI / 2, s.pair_mi.0 * MI / 2), |
| @@ -24943,7 +24985,7 @@ fn decode_inter_block( | |||
| 24943 | ); | 24985 | ); |
| 24944 | } | 24986 | } |
| 24945 | if skip_mode { | 24987 | if skip_mode { |
| 24946 | - SKIP_MODE_HITS.with(|c| c.set(c.get() + 1)); | 24988 | + hit!(SKIP_MODE_HITS); |
| 24947 | } | 24989 | } |
| 24948 | 24990 | ||
| 24949 | let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); | 24991 | let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); |
| @@ -25180,7 +25222,7 @@ fn decode_inter_block( | |||
| 25180 | // model, so a 4-px-sided block still reads its interp filter. | 25222 | // model, so a 4-px-sided block still reads its interp filter. |
| 25181 | let gm_nontrans = gm_nontrans_models && bw4.min(bh4) >= 2; | 25223 | let gm_nontrans = gm_nontrans_models && bw4.min(bh4) >= 2; |
| 25182 | if gm_nontrans_models && !gm_nontrans { | 25224 | if gm_nontrans_models && !gm_nontrans { |
| 25183 | - GM_NONTRANS_SMALL_SIDE_HITS.with(|c| c.set(c.get() + 1)); | 25225 | + hit!(GM_NONTRANS_SMALL_SIDE_HITS); |
| 25184 | } | 25226 | } |
| 25185 | // lane-defer8: both slots' pictures are resolved inside the | 25227 | // lane-defer8: both slots' pictures are resolved inside the |
| 25186 | // prediction closure; the parse only needs their SIZES. | 25228 | // prediction closure; the parse only needs their SIZES. |
| @@ -25232,7 +25274,7 @@ fn decode_inter_block( | |||
| 25232 | let warp0 = compound_warp(ref0, is_global_mv0).filter(|_| ref_unscaled(ref0)); | 25274 | let warp0 = compound_warp(ref0, is_global_mv0).filter(|_| ref_unscaled(ref0)); |
| 25233 | let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1)); | 25275 | let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1)); |
| 25234 | if warp0.is_some() || warp1.is_some() { | 25276 | if warp0.is_some() || warp1.is_some() { |
| 25235 | - COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1)); | 25277 | + hit!(COMPOUND_WARP_HITS); |
| 25236 | } | 25278 | } |
| 25237 | // spec `get_ref_filter_type`: matches when EITHER of the | 25279 | // spec `get_ref_filter_type`: matches when EITHER of the |
| 25238 | // neighbour's two references equals this block's own ref0 -- | 25280 | // neighbour's two references equals this block's own ref0 -- |
| @@ -25346,13 +25388,15 @@ fn decode_inter_block( | |||
| 25346 | // verified vs independent C dump (wedge.rs). | 25388 | // verified vs independent C dump (wedge.rs). |
| 25347 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); | 25389 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); |
| 25348 | let wedge_sign = dec.literal(1); | 25390 | let wedge_sign = dec.literal(1); |
| 25349 | - WEDGE_HITS.with(|c| c.set(c.get() + 1)); | 25391 | + hit!(WEDGE_HITS); |
| 25350 | if let Some(k) = rect_wedge_slot(write_w, write_h) { | 25392 | if let Some(k) = rect_wedge_slot(write_w, write_h) { |
| 25351 | - RECT_WEDGE_HITS.with(|c| { | 25393 | + hit_do! { |
| 25352 | - let mut a = c.get(); | 25394 | + RECT_WEDGE_HITS.with(|c| { |
| 25353 | - a[k] += 1; | 25395 | + let mut a = c.get(); |
| 25354 | - c.set(a); | 25396 | + a[k] += 1; |
| 25355 | - }); | 25397 | + c.set(a); |
| 25398 | + }); | ||
| 25399 | + } | ||
| 25356 | } | 25400 | } |
| 25357 | // lane-inter16ab r5: the codebook row is this block's TRUE | 25401 | // lane-inter16ab r5: the codebook row is this block's TRUE |
| 25358 | // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for | 25402 | // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for |
| @@ -25371,12 +25415,12 @@ fn decode_inter_block( | |||
| 25371 | let mask_type = dec.literal(1); | 25415 | let mask_type = dec.literal(1); |
| 25372 | diffwtd_mask_type = Some(mask_type as u8); | 25416 | diffwtd_mask_type = Some(mask_type as u8); |
| 25373 | if wedge_bsize.is_none() { | 25417 | if wedge_bsize.is_none() { |
| 25374 | - DIFFWTD_INFERRED_HITS.with(|c| c.set(c.get() + 1)); | 25418 | + hit!(DIFFWTD_INFERRED_HITS); |
| 25375 | } | 25419 | } |
| 25376 | } | 25420 | } |
| 25377 | - MASKED_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); | 25421 | + hit!(MASKED_COMPOUND_HITS); |
| 25378 | if write_w != write_h { | 25422 | if write_w != write_h { |
| 25379 | - RECT_MASKED_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); | 25423 | + hit!(RECT_MASKED_COMPOUND_HITS); |
| 25380 | } | 25424 | } |
| 25381 | } | 25425 | } |
| 25382 | // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): r16/r17 | 25426 | // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): r16/r17 |
| @@ -25652,13 +25696,13 @@ fn decode_inter_block( | |||
| 25652 | let scale0 = mc::scale_factor(ref_dims(ref0, refpix)?.0, frame_width); | 25696 | let scale0 = mc::scale_factor(ref_dims(ref0, refpix)?.0, frame_width); |
| 25653 | let scale1 = mc::scale_factor(ref_dims(ref1, refpix)?.0, frame_width); | 25697 | let scale1 = mc::scale_factor(ref_dims(ref1, refpix)?.0, frame_width); |
| 25654 | if scale0 != mc::REF_NO_SCALE || scale1 != mc::REF_NO_SCALE { | 25698 | if scale0 != mc::REF_NO_SCALE || scale1 != mc::REF_NO_SCALE { |
| 25655 | - SCALED_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); | 25699 | + hit!(SCALED_COMPOUND_HITS); |
| 25656 | } | 25700 | } |
| 25657 | // lane-scaledref r2: the MIXED case -- one tap scaled, the other | 25701 | // lane-scaledref r2: the MIXED case -- one tap scaled, the other |
| 25658 | // not -- is the one an all-frames-scaled recipe never produces, | 25702 | // not -- is the one an all-frames-scaled recipe never produces, |
| 25659 | // and the one a single shared scale factor would get wrong. | 25703 | // and the one a single shared scale factor would get wrong. |
| 25660 | if (scale0 == mc::REF_NO_SCALE) != (scale1 == mc::REF_NO_SCALE) { | 25704 | if (scale0 == mc::REF_NO_SCALE) != (scale1 == mc::REF_NO_SCALE) { |
| 25661 | - MIXED_SCALE_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); | 25705 | + hit!(MIXED_SCALE_COMPOUND_HITS); |
| 25662 | } | 25706 | } |
| 25663 | 25707 | ||
| 25664 | // lane-wave4 (the compound arm's half): this block's whole | 25708 | // lane-wave4 (the compound arm's half): this block's whole |
| @@ -25740,7 +25784,7 @@ fn decode_inter_block( | |||
| 25740 | // either way, only the mask source differs. | 25784 | // either way, only the mask source differs. |
| 25741 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { | 25785 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { |
| 25742 | diffwtd_mask_y = vec![0u8; side * side]; | 25786 | diffwtd_mask_y = vec![0u8; side * side]; |
| 25743 | - DIFFWTD_HITS.with(|c| c.set(c.get() + 1)); | 25787 | + hit!(DIFFWTD_HITS); |
| 25744 | mc::diffwtd_mask(&inter0_y, &inter1_y, mask_type == 1, &mut diffwtd_mask_y, fctx); | 25788 | mc::diffwtd_mask(&inter0_y, &inter1_y, mask_type == 1, &mut diffwtd_mask_y, fctx); |
| 25745 | Some(diffwtd_mask_y.as_slice()) | 25789 | Some(diffwtd_mask_y.as_slice()) |
| 25746 | } else { | 25790 | } else { |
| @@ -26116,7 +26160,7 @@ fn decode_inter_block( | |||
| 26116 | neighbours.record_mi_chroma( | 26160 | neighbours.record_mi_chroma( |
| 26117 | cu_mi, luma_span, luma_span, plane_idx, &cu_grid, | 26161 | cu_mi, luma_span, luma_span, plane_idx, &cu_grid, |
| 26118 | ); | 26162 | ); |
| 26119 | - CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 26163 | + hit!(CHROMA_SPLIT_TX_HITS); |
| 26120 | mu_chroma = true; | 26164 | mu_chroma = true; |
| 26121 | let dst = mu_units( | 26165 | let dst = mu_units( |
| 26122 | if plane_idx == 1 { &mut u_units } else { &mut v_units }, | 26166 | if plane_idx == 1 { &mut u_units } else { &mut v_units }, |
| @@ -26507,13 +26551,15 @@ fn decode_inter_block( | |||
| 26507 | // NO sign symbol follows -- libaom fixes | 26551 | // NO sign symbol follows -- libaom fixes |
| 26508 | // INTERINTRA_WEDGE_SIGN 0 (blockd.h). | 26552 | // INTERINTRA_WEDGE_SIGN 0 (blockd.h). |
| 26509 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); | 26553 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); |
| 26510 | - WII_HITS.with(|c| c.set(c.get() + 1)); | 26554 | + hit!(WII_HITS); |
| 26511 | if let Some(k) = rect_wedge_slot(write_w, write_h) { | 26555 | if let Some(k) = rect_wedge_slot(write_w, write_h) { |
| 26512 | - RECT_WII_HITS.with(|c| { | 26556 | + hit_do! { |
| 26513 | - let mut a = c.get(); | 26557 | + RECT_WII_HITS.with(|c| { |
| 26514 | - a[k] += 1; | 26558 | + let mut a = c.get(); |
| 26515 | - c.set(a); | 26559 | + a[k] += 1; |
| 26516 | - }); | 26560 | + c.set(a); |
| 26561 | + }); | ||
| 26562 | + } | ||
| 26517 | } | 26563 | } |
| 26518 | // lane-inter16ab r5: true-footprint codebook row, | 26564 | // lane-inter16ab r5: true-footprint codebook row, |
| 26519 | // mask padded to stride `max(bw,bh) == side` -- see | 26565 | // mask padded to stride `max(bw,bh) == side` -- see |
| @@ -26525,7 +26571,7 @@ fn decode_inter_block( | |||
| 26525 | side, | 26571 | side, |
| 26526 | )); | 26572 | )); |
| 26527 | } else { | 26573 | } else { |
| 26528 | - INTERINTRA_HITS.with(|c| c.set(c.get() + 1)); | 26574 | + hit!(INTERINTRA_HITS); |
| 26529 | } | 26575 | } |
| 26530 | interintra_mode = Some(ii); | 26576 | interintra_mode = Some(ii); |
| 26531 | } | 26577 | } |
| @@ -26663,10 +26709,10 @@ fn decode_inter_block( | |||
| 26663 | let warp_eligible = | 26709 | let warp_eligible = |
| 26664 | allow_warped_motion && !ref_is_scaled && !force_integer_mv && proj_ok; | 26710 | allow_warped_motion && !ref_is_scaled && !force_integer_mv && proj_ok; |
| 26665 | if allow_warped_motion && proj_ok && ref_is_scaled { | 26711 | if allow_warped_motion && proj_ok && ref_is_scaled { |
| 26666 | - SCALED_WARP_SUPPRESSED_HITS.with(|c| c.set(c.get() + 1)); | 26712 | + hit!(SCALED_WARP_SUPPRESSED_HITS); |
| 26667 | } | 26713 | } |
| 26668 | if allow_warped_motion && proj_ok && !ref_is_scaled && force_integer_mv { | 26714 | if allow_warped_motion && proj_ok && !ref_is_scaled && force_integer_mv { |
| 26669 | - FIMV_ALPHABET_HITS.with(|c| c.set(c.get() + 1)); | 26715 | + hit!(FIMV_ALPHABET_HITS); |
| 26670 | } | 26716 | } |
| 26671 | if warp_eligible { | 26717 | if warp_eligible { |
| 26672 | let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); | 26718 | let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); |
| @@ -26674,11 +26720,11 @@ fn decode_inter_block( | |||
| 26674 | 0 => {} | 26720 | 0 => {} |
| 26675 | 1 => { | 26721 | 1 => { |
| 26676 | obmc_selected = true; | 26722 | obmc_selected = true; |
| 26677 | - OBMC_HITS.with(|c| c.set(c.get() + 1)); | 26723 | + hit!(OBMC_HITS); |
| 26678 | } | 26724 | } |
| 26679 | _ => { | 26725 | _ => { |
| 26680 | warped_selected = true; | 26726 | warped_selected = true; |
| 26681 | - WARP_SELECTED_HITS.with(|c| c.set(c.get() + 1)); | 26727 | + hit!(WARP_SELECTED_HITS); |
| 26682 | let mut samples = find_samples( | 26728 | let mut samples = find_samples( |
| 26683 | grid, | 26729 | grid, |
| 26684 | mi_row, | 26730 | mi_row, |
| @@ -26727,7 +26773,7 @@ fn decode_inter_block( | |||
| 26727 | } else { | 26773 | } else { |
| 26728 | obmc_selected = dec.symbol(&mut cdfs.obmc[bsize_idx]) == 1; | 26774 | obmc_selected = dec.symbol(&mut cdfs.obmc[bsize_idx]) == 1; |
| 26729 | if obmc_selected { | 26775 | if obmc_selected { |
| 26730 | - OBMC_HITS.with(|c| c.set(c.get() + 1)); | 26776 | + hit!(OBMC_HITS); |
| 26731 | } | 26777 | } |
| 26732 | } | 26778 | } |
| 26733 | // lane-t900 r9: which ALPHABET this block read (3-symbol | 26779 | // lane-t900 r9: which ALPHABET this block read (3-symbol |
| @@ -26767,7 +26813,7 @@ fn decode_inter_block( | |||
| 26767 | if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { | 26813 | if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { |
| 26768 | warp_params = crate::warp::global_warp_params(gm_ref.params); | 26814 | warp_params = crate::warp::global_warp_params(gm_ref.params); |
| 26769 | if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine { | 26815 | if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine { |
| 26770 | - AFFINE_GM_HITS.with(|c| c.set(c.get() + 1)); | 26816 | + hit!(AFFINE_GM_HITS); |
| 26771 | } | 26817 | } |
| 26772 | } | 26818 | } |
| 26773 | if crate::envflags::env_flag!("EC_AV1_TELL") { | 26819 | if crate::envflags::env_flag!("EC_AV1_TELL") { |
| @@ -26874,13 +26920,13 @@ fn decode_inter_block( | |||
| 26874 | // which this file used to SKIP under a scaled reference | 26920 | // which this file used to SKIP under a scaled reference |
| 26875 | // (fixed in the same commit), not the warp fallback. | 26921 | // (fixed in the same commit), not the warp fallback. |
| 26876 | if warp_params.is_some() { | 26922 | if warp_params.is_some() { |
| 26877 | - SCALED_WARP_FALLBACK_HITS.with(|c| c.set(c.get() + 1)); | 26923 | + hit!(SCALED_WARP_FALLBACK_HITS); |
| 26878 | } | 26924 | } |
| 26879 | if obmc_selected { | 26925 | if obmc_selected { |
| 26880 | - SCALED_OBMC_HITS.with(|c| c.set(c.get() + 1)); | 26926 | + hit!(SCALED_OBMC_HITS); |
| 26881 | } | 26927 | } |
| 26882 | if interintra_mode.is_some() { | 26928 | if interintra_mode.is_some() { |
| 26883 | - SCALED_INTERINTRA_HITS.with(|c| c.set(c.get() + 1)); | 26929 | + hit!(SCALED_INTERINTRA_HITS); |
| 26884 | } | 26930 | } |
| 26885 | } | 26931 | } |
| 26886 | 26932 | ||
| @@ -26888,13 +26934,13 @@ fn decode_inter_block( | |||
| 26888 | // PREVIOUS strip's `mv`/`ref_frame`/`interp_filters` | 26934 | // PREVIOUS strip's `mv`/`ref_frame`/`interp_filters` |
| 26889 | // (reconinter_template.inc:75-82); record them for the next 1:4 | 26935 | // (reconinter_template.inc:75-82); record them for the next 1:4 |
| 26890 | // strip, which is the only reader. | 26936 | // strip, which is the only reader. |
| 26891 | - fctx.inter_last_mc.with(|c| c.set(Some((ref_frame, mv, h_filter, v_filter)))); | 26937 | + hit_do! { fctx.inter_last_mc.with(|c| c.set(Some((ref_frame, mv, h_filter, v_filter)))); } |
| 26892 | // lane-defer8: the sub-8x8 chroma piece's own reference resolved to | 26938 | // lane-defer8: the sub-8x8 chroma piece's own reference resolved to |
| 26893 | // a SIZE here and to pixels inside the closure, like the block's own. | 26939 | // a SIZE here and to pixels inside the closure, like the block's own. |
| 26894 | let sub8 = match strip_chroma.filter(|s| s.has_chroma).and_then(|s| s.prev.map(|p| (s.horz, p))) { | 26940 | let sub8 = match strip_chroma.filter(|s| s.has_chroma).and_then(|s| s.prev.map(|p| (s.horz, p))) { |
| 26895 | Some((horz, (prev_ref, prev_mv, prev_h, prev_v))) => { | 26941 | Some((horz, (prev_ref, prev_mv, prev_h, prev_v))) => { |
| 26896 | let (prev_width, _) = ref_dims(prev_ref, refpix)?; | 26942 | let (prev_width, _) = ref_dims(prev_ref, refpix)?; |
| 26897 | - INTER16_SUB8_PIECE_HITS.with(|c| c.set(c.get() + 1)); | 26943 | + hit!(INTER16_SUB8_PIECE_HITS); |
| 26898 | Some(( | 26944 | Some(( |
| 26899 | horz, | 26945 | horz, |
| 26900 | prev_ref, | 26946 | prev_ref, |
| @@ -27097,7 +27143,7 @@ fn decode_inter_block( | |||
| 27097 | // plane loop). | 27143 | // plane loop). |
| 27098 | if let Some(ii) = interintra_mode { | 27144 | if let Some(ii) = interintra_mode { |
| 27099 | if write_w != write_h { | 27145 | if write_w != write_h { |
| 27100 | - INTERINTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | 27146 | + hit!(INTERINTRA_RECT_HITS); |
| 27101 | } | 27147 | } |
| 27102 | interintra_blend(y, px, py, write_w, write_h, side, ii, wedge_mask, &mut pred_y, fctx); | 27148 | interintra_blend(y, px, py, write_w, write_h, side, ii, wedge_mask, &mut pred_y, fctx); |
| 27103 | interintra_blend( | 27149 | interintra_blend( |
| @@ -27406,7 +27452,7 @@ fn decode_inter_block( | |||
| 27406 | neighbours.record_mi_chroma( | 27452 | neighbours.record_mi_chroma( |
| 27407 | cu_mi, luma_span, luma_span, plane_idx, &cu_grid, | 27453 | cu_mi, luma_span, luma_span, plane_idx, &cu_grid, |
| 27408 | ); | 27454 | ); |
| 27409 | - CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 27455 | + hit!(CHROMA_SPLIT_TX_HITS); |
| 27410 | mu_chroma = true; | 27456 | mu_chroma = true; |
| 27411 | let dst = mu_units( | 27457 | let dst = mu_units( |
| 27412 | if plane_idx == 1 { &mut u_units } else { &mut v_units }, | 27458 | if plane_idx == 1 { &mut u_units } else { &mut v_units }, |
| @@ -27752,7 +27798,7 @@ fn decode_inter_block( | |||
| 27752 | 0 | 27798 | 0 |
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)] |