forge
Explore
Log in

Don't you dare go Hollow

U3: delete the gate-counter feature: hits.rs, counters.rs (~4.5k lines), every hit!/hit_do! site, the forwarding counter getters in stream, the counter-statement sites, and the census/unit-interval trace helpers (decode/coeffs, decode/mod). Counter-only asserts in encoder/tests dropped; decode_probe example deleted (it only printed counters). No output path reads them

Browse files at this commit

b4eb44d812302e026a0749eec2aad153defb738cAhmet Kaan GümüşParent: efec3ce
crates/ec-av1/Cargo.tomlmodified+0 -8
@@ -12,13 +12,5 @@ ec-av1-syntax.workspace = true
1212 archmage = "=0.9.31-beta.1"
1313 bytemuck = "1"
1414
15-[features]
16-default = ["gate-counters"]
17-# Compiles the ~550 `*_HITS` gate counters (see `src/hits.rs`). ON by default so
18-# every test gate and the probe's census see the same numbers they always have;
19-# a shipped decoder can build `--no-default-features` to drop the TLS bump on
20-# each counted path -- the `*_hits()` accessors still compile and return 0.
21-gate-counters = []
22-
2315 [dev-dependencies]
2416 ec-testkit.workspace = true
crates/ec-av1/examples/decode_probe.rsdeleted+0 -532
@@ -1,532 +0,0 @@
1-//! Where does a real stream stop? Decode one AV1 file and print the answer.
2-//!
3-//! The gates in [`ec_av1::stream`] each pin one capability against one encoder
4-//! recipe. This asks the complementary question -- given a stream someone
5-//! actually produced, which refusal comes first -- and it is how the refusal
6-//! distribution in commit 2be815f was measured rather than reasoned about:
7-//!
8-//! ```text
9-//! aomenc --codec=av1 --obu -o s.obu --passes=1 --cpu-used=4 --limit=4 in.y4m
10-//! cargo run -p ec-av1 --example decode_probe -- s.obu
11-//! ```
12-//!
13-//! Note `--obu`: [`ec_av1::stream::decode_stream`] takes a raw OBU stream, and
14-//! an IVF file decodes as zero frames rather than as an error.
15-//!
16-//! That run is also what disproved three refusal strings claiming an encoder
17-//! never writes a case it demonstrably writes, so this is a first-class
18-//! instrument, not a scratch file.
19-fn main() {
20- let Some(path) = std::env::args().nth(1) else {
21- eprintln!("usage: decode_probe <stream.obu>");
22- std::process::exit(2);
23- };
24- let data = match std::fs::read(&path) {
25- Ok(data) => data,
26- Err(e) => {
27- eprintln!("{path}: {e}");
28- std::process::exit(2);
29- }
30- };
31- let report = || {
32- // lane-av1unwritten r6: the subsize-guard coverage table (per call
33- // site, per partition value, reached vs fired). Env-gated
34- // (`EC_AV1_SUBSIZE_GUARD_TRACE`), so it is empty unless asked for.
35- ec_av1::decode::dump_subsize_guard_scan();
36- ec_av1::decode::dump_subsize_arm_scan();
37- // The census below reads ec-av1's gate counters; without the crate's
38- // `gate-counters` feature every one of them is compiled out and reads 0.
39- if !cfg!(feature = "gate-counters") {
40- println!("counters disabled (built without the gate-counters feature)");
41- }
42- let [a444, a422, s420, r420] = ec_av1::decode::cfl_ac_arm_hits();
43- println!(
44- "cfl_ac: 444={a444} 422={a422} 420sq={s420} 420rect={r420} q3_at={}",
45- ec_av1::decode::cfl_ac_q3_at_hits()
46- );
47- let (sc, dp) = ec_av1::decode::reelc_chroma_counters();
48- println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}");
49- println!(
50- "ibc128: mu_chroma={} intra128={}",
51- ec_av1::decode::intra_128_in_inter_mu_chroma_hits(),
52- ec_av1::decode::intra_128_in_inter_hits()
53- );
54- println!(
55- "chroma422_square: {}",
56- ec_av1::decode::chroma422_square_hits()
57- );
58- println!("chroma422_rect: {}", ec_av1::decode::chroma422_rect_hits());
59- println!("chroma422_sub8: {}", ec_av1::decode::chroma422_sub8_hits());
60- println!(
61- "chroma422_chunk: {}",
62- ec_av1::decode::chroma422_chunk_hits()
63- );
64- println!(
65- "chroma422_pair_wide: {}",
66- ec_av1::decode::chroma422_pair_wide_hits()
67- );
68- println!(
69- "uv_left_ss_y: reads={} mode_diff={} smooth_diff={} split1mi={}",
70- ec_av1::decode::uv_left_ss_y_reads(),
71- ec_av1::decode::uv_left_ss_y_mode_diff_hits(),
72- ec_av1::decode::uv_left_ss_y_smooth_diff_hits(),
73- ec_av1::decode::uv_left_1mi_split_hits(),
74- );
75- let (h, v, c) = ec_av1::stream::rect4_32_counters();
76- println!(
77- "rect4_16_uv_pair_filt: {}",
78- ec_av1::decode::rect4_16_uv_pair_filt_hits()
79- );
80- println!("rect4_32: horz={h} vert={v} coded={c}");
81- println!(
82- "rect_intrabc_reads: {}",
83- ec_av1::stream::rect_intrabc_reads()
84- );
85- let (pal_y, pal_uv) = ec_av1::stream::intra_in_inter_palette_hits();
86- println!("intra_in_inter_palette: y={pal_y} uv={pal_uv}");
87- println!(
88- "palette_422_unit_window: {}",
89- ec_av1::decode::palette_422_unit_window_hits()
90- );
91- println!(
92- "rect64_corner_tu: 64x32={} 32x64={}",
93- ec_av1::stream::rect64_corner_tu_hits(0),
94- ec_av1::stream::rect64_corner_tu_hits(1)
95- );
96- println!(
97- "leaf8_intrabc_hits: {}",
98- ec_av1::stream::leaf8_intrabc_hits()
99- );
100- println!("intrabc_hits: {}", ec_av1::stream::intrabc_hits());
101- println!(
102- "intrabc_vartx_trees: {}",
103- ec_av1::decode::intrabc_vartx_hits()
104- );
105- println!(
106- "intrabc_vartx_mixed_leaves: {}",
107- ec_av1::decode::intrabc_vartx_mixed_leaves_hits()
108- );
109- println!(
110- "skipped_intrabc_chroma_arm_hits: {}",
111- ec_av1::stream::skipped_intrabc_chroma_arm_hits()
112- );
113- println!(
114- "intrabc_rect: {} (var-tx tree: {})",
115- ec_av1::decode::intrabc_rect_hits(),
116- ec_av1::decode::intrabc_rect_vartx_hits()
117- );
118- // lane-av1-ibcrect: `use_intrabc` on a 128-root HORZ/VERT strip --
119- // the shape `decode_block_128rect` used to refuse.
120- println!(
121- "intrabc_128rect: {}",
122- ec_av1::stream::intrabc_128rect_hits()
123- );
124- // lane-av1-ibc128chunk: the 128-root intrabc strip's per-axis chroma
125- // mu-chunk walk -- unit count and the `(64>>ss_x)|(64>>ss_y)` extent.
126- println!(
127- "intrabc_128rect_chroma_chunk: units={} shape=0x{:x}",
128- ec_av1::stream::intrabc_128rect_chroma_chunk_hits(),
129- ec_av1::stream::intrabc_128rect_chunk_shape()
130- );
131- let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
132- println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
133- println!(
134- "sub8_inter_split: groups={}",
135- ec_av1::decode::sub8_inter_split_hits()
136- );
137- println!(
138- "skip_split_tx_override: {}",
139- ec_av1::decode::skip_split_tx_override_hits()
140- );
141- println!(
142- "interintra_rect: {}",
143- ec_av1::decode::interintra_rect_hits()
144- );
145- println!(
146- "gm_nontrans_small_side: {}",
147- ec_av1::decode::gm_nontrans_small_side_hits()
148- );
149- println!(
150- "tr_reach_longer_side: {}",
151- ec_av1::decode::tr_reach_longer_side_hits()
152- );
153- println!(
154- "mv_clamp_edge_overhang: {}",
155- ec_av1::mvstack::mv_clamp_edge_overhang_hits()
156- );
157- let (h84, h48) = ec_av1::decode::sub8_inter_rect_hits();
158- println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}");
159- println!(
160- "llintra8_chroma_walk: {}",
161- ec_av1::decode::llintra8_chroma_walk_hits()
162- );
163- println!(
164- "sub8rect444_chroma_walk: {}",
165- ec_av1::decode::llsub8rect444_chroma_walk_hits()
166- );
167- let si = ec_av1::stream::sub8_intra_rect_hits();
168- println!(
169- "sub8_intra_rect: horz8x4={} vert4x8={} chroma_ref={} mixed={} split4x4={}",
170- si.0, si.1, si.2, si.3, si.4
171- );
172- let leaf = ec_av1::stream::vartx_rect_leaf_hits();
173- println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);
174- // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep
175- // can tell "aomenc never picked one" from "it did and we decoded it".
176- let ab = ec_av1::decode::ab16_inter_hits_by_arm();
177- println!(
178- "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}",
179- ab[0], ab[1], ab[2], ab[3]
180- );
181- // lane-kf900 r1: the counter the skipped-8x8-split-transform gate
182- // asserts -- printed here so a recipe sweep can see it fire without a
183- // test-binary rebuild.
184- println!("skip_split_tx: {}", ec_av1::decode::skip_split_tx_hits());
185- let es = ec_av1::decode::inter_edge_strip_hits();
186- println!(
187- "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}",
188- es[0], es[1], es[2], es[3], es[4], es[5]
189- );
190- let (h4, v4, pairs, sub8) = ec_av1::decode::inter16_rect4_counters();
191- println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}");
192- let leaf4 = ec_av1::stream::vartx_rect_leaf4_hits();
193- println!("vartx_rect_leaf4: 8x4={} 4x8={}", leaf4[0], leaf4[1]);
194- // lane-av1txr: intrabc 4x8/8x4 leaves that read the inter var-tx tree
195- // (the symbol whose absence desynced `warped.obu`).
196- println!(
197- "rect_intrabc_vartx: {}",
198- ec_av1::decode::rect_intrabc_vartx_hits()
199- );
200- let rw = ec_av1::stream::rect_wedge_hits();
201- let rwi = ec_av1::stream::rect_wii_hits();
202- println!("rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}");
203- // lane-inter128intra r1: the 128 root's HORZ/VERT half coded INTRA in
204- // an INTER frame -- the arm this round implemented.
205- let i128 = ec_av1::stream::intra128_in_inter_counters();
206- println!("intra128_in_inter: 128x64={} 64x128={}", i128[0], i128[1]);
207- // lane-lossless128: intra 128-axis blocks on a LOSSLESS frame (every
208- // plane TX_4X4) -- the shape whose reconstruction used to panic.
209- println!(
210- "intra128_lossless: {}",
211- ec_av1::stream::intra128_lossless_counters()
212- );
213- let sb = ec_av1::stream::sb128_rect_counters();
214- println!(
215- "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}",
216- sb.0, sb.1, sb.2, sb.3
217- );
218- // lane-av1-ibcrect: the interior 128-root partition arms and the key
219- // frame's intra 128-axis blocks, so a recipe sweep can tell "the
220- // encoder never chose HORZ/VERT at the 128 root" from "it did".
221- let p128 = ec_av1::stream::part128_census();
222- println!(
223- "part128: split={} none={} horz={} vert={} ab={:?} intra_horz={} intra_vert={}",
224- p128.0, p128.1, p128.2, p128.3, p128.4, p128.5, p128.6
225- );
226- // lane-sbab r1: the superblock-level inter AB arms.
227- let sbab = ec_av1::decode::sb_ab_inter_hits_by_arm();
228- println!(
229- "inter_ab64: horz_a={} horz_b={} vert_a={} vert_b={}",
230- sbab[0], sbab[1], sbab[2], sbab[3]
231- );
232- let i4 = ec_av1::stream::intra_rect4_in_inter_counters();
233- println!(
234- "intra_rect4_in_inter: 64x16={} 16x64={} 32x8={} 8x32={}",
235- i4.0, i4.1, i4.2, i4.3
236- );
237- // lane-cdefstrip r1: 8x8 CDEF units whose skip band no coded block
238- // wrote this frame -- non-zero means a decode arm forgot
239- // `fill_skip_grid_rect`, and CDEF filtered a unit libaom may skip.
240- println!(
241- "cdef_unwritten_skip_units: {}",
242- ec_av1::decode::cdef_unwritten_skip_units()
243- );
244- println!(
245- "cdef_band: rect_skip_writes={} mixed_skip_units={}",
246- ec_av1::decode::rect_skip_band_hits(),
247- ec_av1::decode::cdef_mixed_skip_units()
248- );
249- let ir = ec_av1::stream::inter_rect_counters();
250- println!(
251- "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
252- ir.0, ir.1, ir.2, ir.3, ir.4, ir.5
253- );
254- // lane-rectres r1: how many of those 32x8/8x32 strips coded a real
255- // rectangular residual transform unit (a skipped one codes none).
256- println!(
257- "sub8_chroma_tx_from_ref: {}",
258- ec_av1::stream::sub8_chroma_tx_from_ref_hits()
259- );
260- let r328 = ec_av1::stream::rect32x8_inter_tu_hits();
261- println!("rect32x8_inter_tu: 32x8={} 8x32={}", r328[0], r328[1]);
262- // lane-intra16x4: INTRA strips of an inter 16x16-level 1:4 partition.
263- let i164 = ec_av1::stream::intra16x4_in_inter_hits();
264- println!(
265- "intra16x4_in_inter: 16x4={} 4x16={} chroma_ref={}",
266- i164.0, i164.1, i164.2
267- );
268- println!(
269- "rect4_16_pair: lossless_chroma={} intrabc={}",
270- ec_av1::decode::rect4_16_lossless_chroma_hits(),
271- ec_av1::decode::rect4_16_intrabc_hits(),
272- );
273- println!(
274- "loss64: chroma_edge_tu_clip={} skip_lossless_band_reset={}",
275- ec_av1::decode::chroma_edge_tu_clip_hits(),
276- ec_av1::decode::skip_lossless_band_reset_hits(),
277- );
278- println!(
279- "llband: rect_split_lossless_chroma444={}",
280- ec_av1::decode::rect_split_lossless_chroma444_hits()
281- );
282- // lane-t900 r12: chroma edge-filter neighbour answered from the mi-granular
283- // uv_mode grid instead of the coarse one-slot-per-column map.
284- println!(
285- "scaled: leaf8={} sub8={} warpfb={} predict_scaled={}",
286- ec_av1::decode::scaled_leaf8_hits(),
287- ec_av1::decode::scaled_sub8_hits(),
288- ec_av1::decode::scaled_warp_fallback_hits(),
289- ec_av1::mc::predict_scaled_hits()
290- );
291- println!(
292- "uv_mode_grid_override: {}",
293- ec_av1::decode::uv_mode_grid_override_hits()
294- );
295- // lane-thread2: proof the frame-parallel path actually fired (0 at
296- // the default EC_AV1_THREADS=1).
297- println!("frames_dispatched: {}", ec_av1::stream::frames_dispatched());
298- // lane-av1recipehunt: `intra_rect4_in_inter` above already reports the
299- // 1:4-in-inter shapes; this is the `delta_q` half of the same story --
300- // how many delta_q groups the stream really carried, and how many of
301- // them landed inside a rect64 dequant.
302- let (dq, dq_drift) = ec_av1::stream::rect64_qidx_drift_counters();
303- println!("delta_q: groups_read={dq} rect64_qidx_drift={dq_drift}");
304- // lane-av1422census422: the per-plane coefficient-unit census, armed
305- // for 4:4:4 and 4:2:2 (4:2:0 arms nothing, so a 4:2:0 recipe sweep
306- // reads `luma=0 u=0 v=0` BY DESIGN and must not read that as "the
307- // walk was empty" -- `units_total` is the UNCONDITIONAL per-frame
308- // total, so the two together say whether the census was armed at
309- // all). This is what makes a 4:2:2 non-vacuity requirement
310- // writable: before the widening every per-plane field read zero on a
311- // 4:2:2 cell BY CONSTRUCTION, so a byte-exact 4:2:2 gate could
312- // assert it and prove nothing about the stream it had decoded.
313- let cu = ec_av1::decode::census_nonsub_units();
314- let cc = ec_av1::decode::census_nonsub_coded();
315- println!(
316- "census_units: luma={} u={} v={} | coded: luma={} u={} v={} | units_total={}",
317- cu[0],
318- cu[1],
319- cu[2],
320- cc[0],
321- cc[1],
322- cc[2],
323- ec_av1::decode::census_unit_n(),
324- );
325- };
326- // lane-tiles: the tiling a real stream actually uses is a decision input
327- // (every gate in `stream.rs` picks its own `--tile-columns`), so report it
328- // from the frame headers before saying anything about pixels.
329- let mut parser = ec_av1_syntax::Av1Parser::new();
330- let mut seen: Vec<(u32, u32, bool, u32)> = Vec::new();
331- let mut pos = 0usize;
332- let mut frames_seen = 0usize;
333- // OBU at a time, so one unparseable OBU late in the stream still leaves
334- // every earlier frame header's tiling reported.
335- while pos < data.len() {
336- let Ok(obu) = parser.parse_obu(&data[pos..]) else {
337- break;
338- };
339- pos += obu.total_size.max(1);
340- let header = match &obu.kind {
341- ec_av1_syntax::ObuKind::FrameHeader(h) => h,
342- ec_av1_syntax::ObuKind::Frame(h, _) => h,
343- _ => continue,
344- };
345- frames_seen += 1;
346- // lane-frame36: `EC_PROBE_HDR=1` prints one line per frame header, so a
347- // silent wall can be triaged by "which header field is new at frame N"
348- // before any pixel work (class: a header field parsed then never consumed).
349- if std::env::var("EC_PROBE_HDR").is_ok() {
350- let h = header;
351- let gm: Vec<String> = h
352- .global_motion
353- .iter()
354- .map(|w| format!("{:?}", w.model))
355- .collect();
356- println!(
357- "HDR {}: type={:?} show={} showable={} show_existing={}({}) intra={} \
358- size={}x{} up={} superres={}/{} order_hint={} primary_ref={} refresh={:#04x} \
359- refs={:?} order_hints={:?} sign_bias={:?} err_res={} disable_cdf={} \
360- screen_tools={} int_mv={} intrabc={} hp_mv={} interp={:?} switchable_motion={} \
361- ref_mvs={} base_q={} seg={} deltaq={} deltalf={} lf_level={:?} lf_deltas={:?}/{:?} \
362- cdef_bits={} lr={:?} tx_mode={:?} ref_sel={} skip_mode={}({:?}) warp={} \
363- reduced_tx={} gm={:?} grain={}/seed={} lossless={}",
364- frames_seen - 1,
365- h.frame_type,
366- h.show_frame,
367- h.showable_frame,
368- h.show_existing_frame,
369- h.frame_to_show_map_idx,
370- h.frame_is_intra,
371- h.frame_width,
372- h.frame_height,
373- h.upscaled_width,
374- h.use_superres,
375- h.superres_denom,
376- h.order_hint,
377- h.primary_ref_frame,
378- h.refresh_frame_flags,
379- h.ref_frame_idx,
380- h.order_hints,
381- h.ref_frame_sign_bias,
382- h.error_resilient_mode,
383- h.disable_cdf_update,
384- h.allow_screen_content_tools,
385- h.force_integer_mv,
386- h.allow_intrabc,
387- h.allow_high_precision_mv,
388- h.interpolation_filter,
389- h.is_motion_mode_switchable,
390- h.use_ref_frame_mvs,
391- h.quantization.base_q_idx,
392- h.segmentation.enabled,
393- h.delta.q_present,
394- h.delta.lf_present,
395- h.loop_filter.level,
396- h.loop_filter.ref_deltas,
397- h.loop_filter.mode_deltas,
398- h.cdef.bits,
399- h.loop_restoration.frame_restoration_type,
400- h.tx_mode,
401- h.reference_select,
402- h.skip_mode_present,
403- h.skip_mode_frame,
404- h.allow_warped_motion,
405- h.reduced_tx_set,
406- gm,
407- h.film_grain.apply_grain,
408- h.film_grain.grain_seed,
409- h.coded_lossless,
410- );
411- }
412- let t = &header.tile_info;
413- let entry = (t.cols, t.rows, t.uniform_spacing, t.context_update_tile_id);
414- if !seen.contains(&entry) {
415- seen.push(entry);
416- }
417- }
418- println!("TILING: {frames_seen} frame headers parsed");
419- // lane-sb128 r4: the superblock size decides the whole partition tree, so
420- // report it next to the tiling -- it is the first thing a film blocker
421- // triage needs.
422- if let Some(seq) = parser.sequence_header() {
423- println!(
424- "SEQ: use_128x128_superblock={} bit_depth={} mono_chrome={} max_frame={}x{}",
425- seq.use_128x128_superblock,
426- seq.color_config.bit_depth,
427- seq.color_config.mono_chrome,
428- seq.max_frame_width,
429- seq.max_frame_height
430- );
431- }
432- for (cols, rows, uniform, ctx_id) in &seen {
433- println!(
434- "TILING: cols={cols} rows={rows} uniform_spacing={uniform} context_update_tile_id={ctx_id}"
435- );
436- }
437- if seen.is_empty() {
438- println!("TILING: no frame header parsed");
439- }
440-
441- // lane-streamsink r1: decode through the streaming entry point and write
442- // each shown frame out as it completes. The old path collected every
443- // picture in a Vec and then built a second full copy of the raw dump
444- // before one `fs::write`, so peak RSS was 2x the whole decoded segment (a
445- // 4K 8 s window needed >20 GiB, a whole film terabytes). Here at most one
446- // frame is held beyond the decoder's own DPB, and the printed lines are
447- // byte-identical to the old ones.
448- // `EC_PROBE_OUT16` is yuv420p10le (u16 LE); `EC_PROBE_OUT` / argv[2] is
449- // 8-bit (planes are u16, low byte taken). Either target may be a FIFO.
450- use std::io::Write;
451- let open = |path: &str| {
452- std::fs::OpenOptions::new()
453- .write(true)
454- .create(true)
455- .truncate(true)
456- .open(path)
457- .unwrap_or_else(|e| panic!("opening {path}: {e}"))
458- };
459- let out16 = std::env::var("EC_PROBE_OUT16").ok();
460- let out8 = std::env::args()
461- .nth(2)
462- .or_else(|| std::env::var("EC_PROBE_OUT").ok());
463- let null16 = out16.as_deref() == Some("/dev/null");
464- let mut f16 = out16.as_deref().map(open);
465- let mut f8 = out8.as_deref().map(open);
466- let mut written16 = 0usize;
467- let mut written8 = 0usize;
468- let mut shown = 0usize;
469- let mut dims = (0usize, 0usize);
470- let mut buf: Vec<u8> = Vec::new();
471- // lane-av1mono: a monochrome stream is luma only, so the raw dump is a
472- // single plane -- exactly what `ffmpeg -pix_fmt gray -f rawvideo` writes.
473- let mono = parser
474- .sequence_header()
475- .is_some_and(|s| s.color_config.mono_chrome);
476- let result = ec_av1::stream::decode_stream_with(&data, |f, _idx, is_shown| {
477- if !is_shown {
478- return Ok(());
479- }
480- shown += 1;
481- if shown == 1 {
482- dims = (f.width, f.height);
483- }
484- let planes: &[&Vec<u16>] = if mono { &[&f.y] } else { &[&f.y, &f.u, &f.v] };
485- if let Some(w) = f16.as_mut() {
486- let n = 2 * planes.iter().map(|p| p.len()).sum::<usize>();
487- if null16 {
488- // Timing runs point EC_PROBE_OUT16 at /dev/null; the u16->LE
489- // conversion was ~2% of the main thread for bytes nobody reads.
490- written16 += n;
491- } else {
492- buf.clear();
493- buf.resize(n, 0);
494- let mut off = 0;
495- for p in planes {
496- let end = off + 2 * p.len();
497- for (d, &s) in buf[off..end].as_chunks_mut::<2>().0.iter_mut().zip(p.iter()) {
498- d.copy_from_slice(&s.to_le_bytes());
499- }
500- off = end;
501- }
502- w.write_all(&buf).expect("writing raw planes");
503- written16 += buf.len();
504- }
505- }
506- if let Some(w) = f8.as_mut() {
507- buf.clear();
508- for p in planes {
509- buf.extend(p.iter().map(|&s| s as u8));
510- }
511- w.write_all(&buf).expect("writing raw planes");
512- written8 += buf.len();
513- }
514- Ok(())
515- });
516- match result {
517- Ok(()) if shown == 0 => {
518- println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?");
519- }
520- Ok(()) => {
521- if let Some(out) = &out16 {
522- println!("wrote {written16} bytes of yuv420p10le to {out}");
523- }
524- if let Some(out) = &out8 {
525- println!("wrote {written8} bytes of yuv420p to {out}");
526- }
527- println!("OK: {shown} frames decoded, {}x{}", dims.0, dims.1);
528- }
529- Err(e) => println!("REFUSED: {e}"),
530- }
531- report();
532-}
crates/ec-av1/src/decode/block.rsmodified+0 -68
@@ -72,7 +72,6 @@ pub(super) fn read_intra_mode(
7272 // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single
7373 // point every square caller routes through (see `read_intra_mode_rect`).
7474 let cfl = if cfl && side > 32 {
75- hit!(NOCFL_UV_MODE_HITS);
7675 false
7776 } else {
7877 cfl
@@ -133,7 +132,6 @@ pub(super) fn read_intra_mode(
133132 eprintln!("TRACE intrabc dv={dv:?}");
134133 }
135134 fctx.intrabc_dv.with(|c| c.set(Some(dv)));
136- hit!(INTRABC_HITS);
137135 // spec 5.11.13 / libaom `read_intra_frame_mode_info` returns the
138136 // moment `is_intrabc_block`: no y/uv mode, angle delta, palette,
139137 // CFL or filter-intra syntax follows. `YMode`/`UVMode` are forced
@@ -199,24 +197,17 @@ pub(super) fn read_intra_mode(
199197 // 78 against ffmpeg, traced 2026-08-27) -- an existing, un-lane-touched
200198 // bug in that fallback this lane's own scope does not cover. Keep it
201199 // refused here rather than ship a silently-wrong decode.
202- if (9..=12).contains(&uv_mode) {
203- hit!(SMOOTH_UV_HITS);
204- }
205200 // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the
206201 // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads
207202 // `angle_delta_uv` off `get_uv_mode(uv_mode)`, never off `uv_mode` raw,
208203 // so a CFL block (uv_mode==13, outside `V_PRED..=D67_PRED`) already takes
209204 // the `else` branch below and never reads one either way.
210205 let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {
211- hit!(DIRECTIONAL_UV_HITS);
212206 read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
213207 } else {
214208 0
215209 };
216210 istep!("angle_uv", angle_delta_uv);
217- if angle_delta_uv != 0 {
218- hit!(UV_ANGLE_DELTA_HITS);
219- }
220211 // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called
221212 // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`):
222213 // gated by `av1_allow_palette` (blockd.h -- size bound only,
@@ -322,7 +313,6 @@ pub(super) fn read_intra_mode(
322313 }
323314 istep!("use_filter_intra", use_filter_intra as i32);
324315 if use_filter_intra {
325- hit!(FILTER_INTRA_HITS);
326316 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);
327317 if trace {
328318 eprintln!("TRACE filter_intra_mode value={fi_mode}");
@@ -342,7 +332,6 @@ pub(super) fn read_intra_mode(
342332 palette_onscreen(mi_r, mi_c, side, side, fctx),
343333 false,
344334 );
345- hit!(PALETTE_HITS);
346335 if trace {
347336 eprintln!("TRACE palette_y size={n} colors={:?}", &colors[..n]);
348337 }
@@ -372,7 +361,6 @@ pub(super) fn read_intra_mode(
372361 on,
373362 true,
374363 );
375- hit!(PALETTE_UV_HITS);
376364 if trace {
377365 eprintln!(
378366 "TRACE palette_uv size={n} u_colors={:?} v_colors={:?}",
@@ -412,7 +400,6 @@ pub(super) const UV_CFL_PRED: usize = 13;
412400 /// joint sign the same way. Returns each plane's final signed `alpha_q3`
413401 /// (`cfl_idx_to_alpha`, cfl.c): magnitude `idx + 1`, sign-zero collapsing to 0.
414402 pub(super) fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) {
415- hit!(CFL_BLOCK_HITS);
416403 let joint_sign = dec.symbol(&mut cdfs.cfl_sign) as i32;
417404 let sign_u = ((joint_sign + 1) * 11) >> 5;
418405 let sign_v = (joint_sign + 1) - 3 * sign_u;
@@ -461,7 +448,6 @@ pub(super) fn cfl_ac_ss(
461448 ss_y: usize,
462449 ) -> Vec<i32> {
463450 if ss_x == 0 && ss_y == 0 {
464- hit!(CFL_AC_444_HITS);
465451 let mut ac = vec![0i32; bw * bh];
466452 let mut sum = 0i32;
467453 for row in 0..bh {
@@ -476,12 +462,6 @@ pub(super) fn cfl_ac_ss(
476462 ac.iter_mut().for_each(|v| *v -= avg);
477463 ac
478464 } else if ss_x == 1 && ss_y == 0 {
479- // lane-av1-422: `cfl_luma_subsampling_422_lbd_c` -- each chroma sample
480- // averages the HORIZONTAL luma pair above it, at full chroma height
481- // (`(a + b) >> 1` in Q3 is `(a + b) << 2`). A rect luma strip's chroma
482- // is square here, and the 4:2:0 rect/square helpers below would halve
483- // the height it must keep.
484- hit!(CFL_AC_422_HITS);
485465 let (cw, ch) = (bw >> 1, bh);
486466 let mut ac = vec![0i32; cw * ch];
487467 let mut sum = 0i32;
@@ -500,10 +480,8 @@ pub(super) fn cfl_ac_ss(
500480 ac.iter_mut().for_each(|v| *v -= avg);
501481 ac
502482 } else if bw == bh {
503- hit!(CFL_AC_420_SQ_HITS);
504483 cfl_ac_q3(y, px, py, bw)
505484 } else {
506- hit!(CFL_AC_420_RECT_HITS);
507485 cfl_ac_q3_rect(y, px, py, bw, bh)
508486 }
509487 }
@@ -515,7 +493,6 @@ pub(crate) fn cfl_ac_q3_at(
515493 bh: usize,
516494 sample: impl Fn(usize, usize) -> i32,
517495 ) -> Vec<i32> {
518- hit!(CFL_AC_Q3_AT_HITS);
519496 if crate::envflags::env_flag!("EC_HALVSWEEP") {
520497 eprintln!("EC_HALV cfl_ac_q3_at px={px} py={py} bw={bw} bh={bh}");
521498 }
@@ -1216,12 +1193,6 @@ impl PlaneBuf<'_> {
12161193 });
12171194 let corner =
12181195 (x > self.tile_x0 && y > self.tile_y0).then(|| self.data[(y - 1) * self.width + x - 1]);
1219- if matches!((bw, bh), (16, 8) | (8, 16)) {
1220- hit!(RECT_STRIP_PRED_HITS);
1221- if across > own_across || down > own_down {
1222- hit!(RECT_STRIP_REACH_HITS);
1223- }
1224- }
12251196 (above, left, corner)
12261197 }
12271198
@@ -1566,8 +1537,6 @@ pub(super) fn read_plane(
15661537 if plane_idx > 0 && mono(fctx) {
15671538 return Ok(Grid::Zero(side * side));
15681539 }
1569- // lane-av1readcensus: the units read from here on are this plane's.
1570- set_census_plane(plane_idx);
15711540 let skip_ctx = if plane_idx == 0 {
15721541 luma_skip_ctx.unwrap_or(0)
15731542 } else {
@@ -1848,9 +1817,6 @@ pub(super) fn read_rect_chroma_unit(
18481817 smooth_neighbor_uv: bool,
18491818 fctx: &crate::decode::FrameCtx,
18501819 ) -> Result<Grid> {
1851- if ss_x(fctx) == 1 && ss_y(fctx) == 0 && w != h {
1852- hit!(CHROMA422_RECT_HITS);
1853- }
18541820 // The same three cases as [`read_plane`], for the same reason: at 32 points
18551821 // an INTER chroma unit's transform set is `EXT_TX_SET_DCT_IDTX` (the luma's
18561822 // coded `IDTX` survives) where the intra set is `EXT_TX_SET_DCTONLY`, and
@@ -1974,9 +1940,6 @@ pub(super) fn decode_block(
19741940 c * (SUB / MI),
19751941 fctx,
19761942 )?;
1977- if at_tile_left && palette_y.is_some() {
1978- hit!(PALETTE_TILE_LEFT_HITS);
1979- }
19801943 // lane-lossless: a lossless BLOCK's transform is TX_4X4 on every plane
19811944 // (libaom `read_tx_size`, `decodeframe.c`), so the caller's per-size
19821945 // tables/scans are replaced by the 4x4 ones and the block always takes the
@@ -2045,9 +2008,6 @@ pub(super) fn decode_block(
20452008 uv_mode
20462009 };
20472010 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
2048- if smooth_neighbor {
2049- hit!(SMOOTH_LUMA_HITS);
2050- }
20512011 let smooth_neighbor_uv =
20522012 neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c, fctx);
20532013 if crate::envflags::env_flag!("EC_AV1_TRACE") {
@@ -2112,7 +2072,6 @@ pub(super) fn decode_block(
21122072 );
21132073 }
21142074 }
2115- hit!(INTRABC_VARTX_HITS);
21162075 // lane-t900 r33 census: the t900 recipes resolved every tree UNIFORM.
21172076 // lane-av1-ibcvtx: a tree that resolved to mixed leaf sizes is no
21182077 // longer refused -- the luma reconstruct below walks the tree's own
@@ -2127,7 +2086,6 @@ pub(super) fn decode_block(
21272086 .all(|l| (l.2, l.3) == (f.2, f.3) && l.2 == l.3)
21282087 });
21292088 if !uniform {
2130- hit!(INTRABC_VARTX_MIXED_LEAVES_HITS);
21312089 if crate::envflags::env_flag!("EC_AV1_IBCVTX_DEBUG") {
21322090 eprintln!(
21332091 "IBCVTX mixed intrabc tree mi=({mi_r},{mi_c}) side={side} \
@@ -2151,9 +2109,6 @@ pub(super) fn decode_block(
21512109 // single-unit path.
21522110 (lossless_tx(side.min(64), fctx), luma_tx)
21532111 };
2154- if tx_select && logical_tx < side && uv_mode != DC_PRED {
2155- hit!(SQ_CHROMA_TX_HITS);
2156- }
21572112 let luma_set = if tx_select {
21582113 txbset_for(logical_tx, reduced_tx_set)
21592114 } else {
@@ -2260,9 +2215,6 @@ pub(super) fn decode_block(
22602215 // Counted on the SHAPE, not on the arm below, so a gate can tell a stream
22612216 // that reaches this block apart from one that never does (class
22622217 // gate-blind-to-feature).
2263- if palette_y_buf.is_some() && skip && logical_tx < side {
2264- hit!(SKIP_SPLIT_TX_OVERRIDE_HITS);
2265- }
22662218 if let Some(buf) = &palette_y_buf
22672219 && (logical_tx == side || skip)
22682220 {
@@ -2313,9 +2265,6 @@ pub(super) fn decode_block(
23132265 // narrower meaning (a READ split tx depth).
23142266 let split_tx_skip = logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none();
23152267 if split_tx_skip {
2316- if tx_select {
2317- hit!(SKIP_SPLIT_TX_HITS);
2318- }
23192268 let n_axis = side / logical_tx;
23202269 for tu_row in 0..n_axis {
23212270 for tu_col in 0..n_axis {
@@ -2440,9 +2389,6 @@ pub(super) fn decode_block(
24402389 window
24412390 };
24422391 if let Some((ub, _)) = &palette_uv_bufs {
2443- if cn_cols * cn_rows > 1 {
2444- hit!(SKIP_CHROMA_OVERRIDE_WINDOW_HITS);
2445- }
24462392 set_palette_pred(chroma_window(ub), fctx);
24472393 }
24482394 push_intra_unit(
@@ -2513,10 +2459,6 @@ pub(super) fn decode_block(
25132459 // the total stayed 0.
25142460 let plane_block = chroma_side * chroma_height;
25152461 let short = plane_block.saturating_sub(u_grid.len());
2516- hit_do!(SKIP_ARM_CHROMA_SHORT_SAMPLES.with(|c| c.set(c.get() + short)));
2517- if chroma_side != chroma_height {
2518- hit!(SKIP_ARM_CHROMA_RECT_SHAPES);
2519- }
25202462 neighbours.record(
25212463 at,
25222464 side,
@@ -2785,10 +2727,6 @@ pub(super) fn decode_block(
27852727 smooth_neighbor_uv,
27862728 fctx,
27872729 )?;
2788- hit!(CHROMA_SPLIT_TX_HITS);
2789- if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
2790- hit!(CHROMA422_SQUARE_HITS);
2791- }
27922730 // Immediately, so the next unit of this block reads this
27932731 // one's coefficient context. `record` below stamps one
27942732 // chroma state across the whole block; the replay after
@@ -2943,7 +2881,6 @@ pub(super) fn decode_block(
29432881 (luma_set, luma_scan)
29442882 };
29452883 if let Some(buf) = &palette_y_buf {
2946- hit!(PALETTE_SPLIT_TX_HITS);
29472884 let mut window = vec![0u16; tu_tx * tu_tx];
29482885 for row in 0..tu_tx {
29492886 let src = (tu_off_y + row) * side + tu_off_x;
@@ -3070,7 +3007,6 @@ pub(super) fn decode_block(
30703007 };
30713008 let (unit_w, unit_h) = (chroma_tx / 4, chroma_tx_h / 4);
30723009 if cu_col * unit_w >= max_units_w || cu_row * unit_h >= max_units_h {
3073- hit!(CHROMA_EDGE_TU_CLIP_HITS);
30743010 continue;
30753011 }
30763012 // The chroma context arrays are indexed in LUMA mi, so this
@@ -3182,10 +3118,6 @@ pub(super) fn decode_block(
31823118 )?
31833119 };
31843120 if cn_rows * cn_cols > 1 {
3185- hit!(CHROMA_SPLIT_TX_HITS);
3186- if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
3187- hit!(CHROMA422_SQUARE_HITS);
3188- }
31893121 // Immediately, so the NEXT unit of this same block reads
31903122 // this one's coefficient context (libaom's chroma
31913123 // `txb_skip_ctx` for the second quadrant is 11, i.e. base
crates/ec-av1/src/decode/coeffs.rsmodified+1 -103
@@ -90,17 +90,7 @@ pub(super) fn read_coeffs(
9090 ) -> Result<(Grid, TxType)> {
9191 let trace = crate::envflags::env_flag!("EC_AV1_TRACE");
9292 let side = coding.side;
93- // lane-av1readcensus: this unit's own entry state, so the census line
94- // carries the pre-read rng and pairs against the oracle's `EC_COEFF`
95- // (which prints `r->ec.rng` before the same `txb_skip` read).
96- let census_entry_rng = dec.debug_state().0;
9793 let (census_w, census_h) = rect_shape.unwrap_or((side, side));
98- // lane-av1ibcfork: the per-unit BIT INTERVAL, the twin of the oracle's
99- // `EC_ECDUMP_IN` / `_OUT` / `_END`. The census plane, not a fresh label:
100- // it is the same source `census_unit` reads, so the interval line and the
101- // census line can never disagree about which plane a unit is on.
102- let iv_plane = CENSUS_PLANE.with(|c| c.get()).min(2);
103- let iv_bit = unit_iv_in(iv_plane, census_w, census_h, skip_ctx, dec);
10494 if crate::envflags::env_flag!("EC_AV1_EOBPT_CDF") {
10595 let (range, value) = dec.debug_state();
10696 eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}");
@@ -123,9 +113,6 @@ pub(super) fn read_coeffs(
123113 0
124114 };
125115 let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1;
126- unit_iv_skip(
127- dec, iv_bit, iv_plane, census_w, census_h, skip_ctx, all_zero,
128- );
129116 // lane-ibc444c: this reader logs an `all_zero` step even for a read that
130117 // consumes ZERO bits, so `post_bit == bit` means "no symbol was read" --
131118 // filter on it before pairing anything against the oracle.
@@ -161,18 +148,6 @@ pub(super) fn read_coeffs(
161148 eprintln!("EC_AV1_STATE_AFTER_TXBSKIP range={range} value={value}");
162149 }
163150 if all_zero {
164- // lane-coefgrid: the all-zero unit (60% of the 4K segment's) names the
165- // shared zero grid instead of allocating and zeroing its own.
166- census_unit(
167- census_w,
168- census_h,
169- TxType::DctDct,
170- 0,
171- true,
172- census_entry_rng,
173- dec,
174- );
175- unit_iv_end(dec, iv_plane, census_w, census_h, skip_ctx);
176151 return Ok((Grid::Zero(side * side), TxType::DctDct));
177152 }
178153 let mut grid = vec![0i32; side * side];
@@ -209,10 +184,6 @@ pub(super) fn read_coeffs(
209184 }
210185
211186 let class = TxClass::of(tx_type);
212- if class != TxClass::TwoD {
213- hit!(TX_CLASS1_HITS);
214- hit!(RECT_CLASS1_HITS);
215- }
216187 let eob = read_eob(dec, coding, class);
217188 if trace {
218189 eprintln!("TRACE eob value={eob}");
@@ -381,16 +352,6 @@ pub(super) fn read_coeffs(
381352 }
382353 grid[pos] = if negative { -level } else { level };
383354 }
384- census_unit(
385- census_w,
386- census_h,
387- tx_type,
388- eob,
389- false,
390- census_entry_rng,
391- dec,
392- );
393- unit_iv_end(dec, iv_plane, census_w, census_h, skip_ctx);
394355 Ok((Grid::Own(grid), tx_type))
395356 }
396357
@@ -425,19 +386,10 @@ pub(super) fn read_coeffs_rect(
425386 plane: usize,
426387 ) -> Result<(Grid, TxType)> {
427388 let rect_trace = coeff_trace_on();
428- let entry_rng = dec.debug_state().0;
429- // lane-av1readcensus: this reader is handed the real plane (lane-av1chrtx
430- // threaded it in for the `EC_COEFF_STEP` traces), so it stamps the census
431- // plane itself rather than inheriting whichever reader did last. The
432- // luma-only readers (`decode_rect_split`, `decode_block_rect64`,
433- // `read_inter_plane_rect`'s corner) are all plane 0 -- the stamp's initial
434- // value -- and the other plane-owning readers stamp on entry.
435- set_census_plane(plane);
436389 let ibctx_on = crate::envflags::env_flag!("EC_IBCTX");
437390 let entry_bit = if ibctx_on { dec.debug_bitpos() } else { 0 };
438- let iv_bit = unit_iv_in(plane, w, h, skip_ctx, dec);
391+ let entry_rng = dec.debug_state().0;
439392 let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1;
440- unit_iv_skip(dec, iv_bit, plane, w, h, skip_ctx, all_zero);
441393 if rect_trace {
442394 eprintln!(
443395 "EC_COEFF_STEP tag=all_zero plane={plane} ctx={skip_ctx} entry={entry_rng} all_zero={} rng={} bit={entry_bit} post_bit={}",
@@ -460,12 +412,9 @@ pub(super) fn read_coeffs_rect(
460412 );
461413 }
462414 if all_zero {
463- census_unit(w, h, TxType::DctDct, 0, true, entry_rng, dec);
464- unit_iv_end(dec, plane, w, h, skip_ctx);
465415 return Ok((Grid::Zero(w * h), TxType::DctDct));
466416 }
467417 let mut grid = vec![0i32; w * h];
468- hit!(RECT_COEFF_TU_HITS);
469418 // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is
470419 // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including
471420 // the `V_DCT`/`H_DCT` members whose 1D tx class needs its own scan and
@@ -487,9 +436,6 @@ pub(super) fn read_coeffs_rect(
487436 }
488437 }
489438 let class = TxClass::of(tx_type);
490- if class != TxClass::TwoD {
491- hit!(TX_CLASS1_HITS);
492- }
493439 let eob = read_eob(dec, coding, class);
494440 if rect_trace {
495441 eprintln!(
@@ -683,8 +629,6 @@ pub(super) fn read_coeffs_rect(
683629 nz.join(",")
684630 );
685631 }
686- census_unit(w, h, tx_type, eob, false, entry_rng, dec);
687- unit_iv_end(dec, plane, w, h, skip_ctx);
688632 Ok((Grid::Own(grid), tx_type))
689633 }
690634
@@ -1747,9 +1691,6 @@ impl Neighbours {
17471691 /// [`Self::fill_skip_grid`] with independent row/col extents (lane-partitions r1).
17481692 pub(super) fn fill_skip_grid_rect(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize, skip: bool) {
17491693 let (mi_r, mi_c) = at_mi;
1750- if skip && w_mi != h_mi {
1751- hit!(RECT_SKIP_BAND_HITS);
1752- }
17531694 for rr in 0..h_mi {
17541695 let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c;
17551696 fill_span(
@@ -2517,7 +2458,6 @@ impl Neighbours {
25172458 if self.tile_row0_mi > 0 && !have_above && self.above_uv_mode[c] != DC_PRED
25182459 || self.tile_col0_mi > 0 && !have_left && self.left_uv_mode[r] != DC_PRED
25192460 {
2520- hit!(UV_TILE_EDGE_SUPPRESSED_HITS);
25212461 }
25222462 // The mi grid is libaom's own read; the two maps below stay as the
25232463 // fallback for cells no block has written (see [`Self::uv_mode_grid`]).
@@ -2607,17 +2547,10 @@ impl Neighbours {
26072547 // `lanes/av1leftref.report.md`, which is what makes the read change a
26082548 // proven no-op on today's material rather than an unmeasured guess.
26092549 if decode_path && have_left && ss_y > 0 {
2610- hit!(UV_LEFT_SS_Y_READS);
26112550 // The pre-lane read, kept as the counter's own-row arm: it is what
26122551 // this decoder answered before the `+ss_y` term landed, and
26132552 // comparing against it is what proves the term is load-bearing.
26142553 let own_row = read_left(mi_r);
2615- if own_row != left {
2616- hit!(UV_LEFT_SS_Y_MODE_DIFF_HITS);
2617- }
2618- if is_smooth_mode(own_row) != is_smooth_mode(left) {
2619- hit!(UV_LEFT_SS_Y_SMOOTH_DIFF_HITS);
2620- }
26212554 // lane-av1leftwit: the geometry the `+ss_y` term needs. The two
26222555 // cells are one left mi column apart, so they are two different
26232556 // blocks exactly when the left neighbour is 1 mi tall or shorter.
@@ -2635,7 +2568,6 @@ impl Neighbours {
26352568 .filter(|o| o & 0xff00_0000 == epoch)
26362569 .unwrap_or(0);
26372570 if own != 0 && down != 0 && own != down {
2638- hit!(UV_LEFT_1MI_SPLIT_HITS);
26392571 if crate::envflags::env_flag!("EC_LEFTSSY") {
26402572 eprintln!(
26412573 "EC_LEFTSSY epoch={} mi=({mi_r},{mi_c}) left_col={col} \
@@ -2654,18 +2586,13 @@ impl Neighbours {
26542586 }) || have_left && cell(&self.uv_mode_grid, left_mi.0, left_mi.1).is_some_and(|m| {
26552587 !matches!(self.uv_mode_row.get(left_mi.0), Some(&(col, cm)) if usize::from(col) == left_mi.1 && usize::from(cm) == m)
26562588 }) {
2657- hit!(UV_MODE_GRID_OVERRIDE_HITS);
26582589 }
26592590 // lane-cfl r1 counter: how often the mi-exact chroma neighbour differs
26602591 // from the coarse [`SUB`] slot -- i.e. how often a chroma edge would
26612592 // have been filtered at the wrong strength by the coarse map alone.
2662- if above != self.above_uv_mode[c] || left != self.left_uv_mode[r] {
2663- hit!(UV_MODE_MI_OVERRIDE_HITS);
2664- }
26652593 if (is_smooth_mode(self.above_uv_mode[c]) && !is_smooth_mode(above))
26662594 || (is_smooth_mode(self.left_uv_mode[r]) && !is_smooth_mode(left))
26672595 {
2668- hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS);
26692596 }
26702597 is_smooth_mode(above) || is_smooth_mode(left)
26712598 }
@@ -2719,20 +2646,15 @@ impl Neighbours {
27192646 let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));
27202647 let (above, left) =
27212648 self.modes_above_left_mi(mi_r, mi_c, (self.above_mode[c], self.left_mode[r]));
2722- if above != self.above_mode[c] || left != self.left_mode[r] {
2723- hit!(MODE_MI_OVERRIDE_HITS);
2724- }
27252649 if (is_smooth_mode(self.above_mode[c]) && !is_smooth_mode(above))
27262650 || (is_smooth_mode(self.left_mode[r]) && !is_smooth_mode(left))
27272651 {
2728- hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS);
27292652 }
27302653 // A neighbour the coarse band offered where the tile edge makes it
27312654 // unavailable -- must never happen (see `MODE_TILE_EDGE_COARSE_LEAKS`).
27322655 if (mi_r <= self.tile_row0_mi && self.above_mode[c] != DC_PRED)
27332656 || (mi_c <= self.tile_col0_mi && self.left_mode[r] != DC_PRED)
27342657 {
2735- hit!(MODE_TILE_EDGE_COARSE_LEAKS);
27362658 }
27372659 (above, left)
27382660 }
@@ -2935,13 +2857,6 @@ impl Neighbours {
29352857 // the flags read the CALLER's origin, before the shadowing align below
29362858 let (row_mid, col_mid) = (mi_r & (step_y - 1) != 0, mi_c & (step_x - 1) != 0);
29372859 if row_mid || col_mid {
2938- CHROMA_MIDCELL_PUB_HITS.with(|c| {
2939- let mut v = c.get();
2940- v[0] += usize::from(row_mid);
2941- v[1] += usize::from(col_mid);
2942- v[2] += usize::from(row_mid && col_mid);
2943- c.set(v);
2944- });
29452860 }
29462861 let (mi_r, mi_c) = (mi_r & !(step_y - 1), mi_c & !(step_x - 1));
29472862 let round_up_even = |n: usize| n.div_ceil(2) * 2;
@@ -3571,9 +3486,6 @@ pub(super) fn decode_color_index_map_wh(
35713486 ) -> Vec<u8> {
35723487 let trace = crate::envflags::env_flag!("EC_AV1_TRACE");
35733488 let (on_bw, on_bh) = (on.0.clamp(1, bw), on.1.clamp(1, bh));
3574- if on_bw < bw || on_bh < bh {
3575- hit!(PALETTE_ONSCREEN_CUT_HITS);
3576- }
35773489 let mut map = vec![0u8; bw * bh];
35783490 if trace {
35793491 let (rng, _) = dec.debug_state();
@@ -3642,9 +3554,6 @@ pub(crate) fn palette_replicate(map: &mut [u8], bw: usize, bh: usize, on: (usize
36423554 /// it lands away from zero, for gate tests to prove a real stream fired one.
36433555 pub(super) fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 {
36443556 let symbol = dec.symbol(cdf);
3645- if symbol != ANGLE_DELTA_ZERO {
3646- hit!(ANGLE_DELTA_HITS);
3647- }
36483557 symbol as i32 - ANGLE_DELTA_ZERO as i32
36493558 }
36503559
@@ -3777,7 +3686,6 @@ pub(super) fn tx_size_context_txfm_rect(
37773686 own_h: usize,
37783687 fctx: &crate::decode::FrameCtx,
37793688 ) -> usize {
3780- hit!(INTRA_IN_INTER_TXCTX_HITS);
37813689 // `max_txsize_rect_lookup[bsize]` tops out at TX_64X64: no transform is
37823690 // wider or taller than 64, so a block with a 128 side resolves against 64
37833691 // (lane-sb128b r1).
@@ -3827,7 +3735,6 @@ pub(super) fn tx_size_context_txfm_rect(
38273735 if band_above != (has_above && usize::from(above) != 0)
38283736 || band_left != (has_left && usize::from(left) != 0)
38293737 {
3830- hit!(TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS);
38313738 }
38323739 }
38333740 if crate::envflags::env_flag!("EC_TXCTX") {
@@ -3861,9 +3768,6 @@ pub(super) fn tx_size_context_txfm_rect(
38613768 {
38623769 let stale = usize::from(has_above && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w)
38633770 + usize::from(has_left && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h);
3864- if ctx != stale {
3865- hit!(TXCTX_DEBLOCK_DIVERGENCE_HITS);
3866- }
38673771 }
38683772 ctx
38693773 }
@@ -3918,7 +3822,6 @@ pub(super) fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize),
39183822 if band_above != (has_above && usize::from(above) != 0)
39193823 || band_left != (has_left && usize::from(left) != 0)
39203824 {
3921- hit!(TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS);
39223825 }
39233826 }
39243827 if crate::envflags::env_flag!("EC_TXCTX") {
@@ -3990,9 +3893,6 @@ pub(super) fn read_tx_size(
39903893 "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={depth} ctx={ctx} rng={rng}"
39913894 );
39923895 }
3993- if depth != 0 {
3994- hit!(TX_DEPTH_HITS);
3995- }
39963896 max_tx >> depth
39973897 }
39983898
@@ -4408,7 +4308,6 @@ pub(super) fn read_var_tx_size(
44084308 tx_h,
44094309 );
44104310 let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1;
4411- hit!(TXFM_SPLIT_READS);
44124311 if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
44134312 let (rng, _) = dec.debug_state();
44144313 eprintln!(
@@ -4423,7 +4322,6 @@ pub(super) fn read_var_tx_size(
44234322 txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h));
44244323 return;
44254324 }
4426- hit!(TXFM_SPLIT_HITS);
44274325 let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h);
44284326 if (sub_w, sub_h) == (4, 4) {
44294327 // libaom's `sub_txs == TX_4X4` early return: every mi cell of the
crates/ec-av1/src/decode/counters.rsdeleted+0 -4459

Diff too large; view file

@@ -1,4459 +0,0 @@
1-//! Hit and census counters of the decode path: thread-local tallies bumped by the
2-//! `hit!` instrumentation and read back by the gate tests. Moved out of `decode/mod.rs`
3-//! by name (av1split D3); the items are unchanged except for `pub(super)` visibility.
4-
5-use super::*;
6-
7-// How many real 128-level partition symbols this decoder has read, and how
8-// many superblocks resolved to `PARTITION_SPLIT` (coded or forced) -- the
9-// gate's proof a `--sb-size=128` stream exercised the 128 partition root.
10-thread_local! {
11- pub(super) static PART128_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
12-}
13-
14-/// Current value of [`PART128_SPLIT_HITS`].
15-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
16-pub(crate) fn part128_split_hits() -> usize {
17- PART128_SPLIT_HITS.with(|c| c.get())
18-}
19-
20-// How many `use_filter_intra` symbols this decoder has read as `1`, across
21-// every call on the current thread -- the cheap counter [`filter_intra_hits`] gate
22-// tests read (before/after, not the absolute value) to prove a stream
23-// actually exercised the filter-intra predictor rather than silently
24-// skipping it.
25-thread_local! {
26- pub(super) static FILTER_INTRA_HITS: std::cell::Cell<usize> =
27- const { std::cell::Cell::new(0) };
28-}
29-
30-/// Current value of [`FILTER_INTRA_HITS`].
31-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
32-pub(crate) fn filter_intra_hits() -> usize {
33- FILTER_INTRA_HITS.with(|c| c.get())
34-}
35-
36-// lane-fiinter r1: how many of those `use_filter_intra == 1` symbols belonged
37-// to an INTRA block inside an INTER frame (`read_intra_block_mode_info`'s own
38-// `read_filter_intra_mode_info` call), which no gate exercised before this
39-// round -- every inter gate recipe passed `--enable-filter-intra=0`.
40-thread_local! {
41- pub(super) static INTRA_IN_INTER_FILTER_INTRA_HITS: std::cell::Cell<usize> =
42- const { std::cell::Cell::new(0) };
43-}
44-
45-/// Current value of [`INTRA_IN_INTER_FILTER_INTRA_HITS`].
46-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
47-pub(crate) fn intra_in_inter_filter_intra_hits() -> usize {
48- INTRA_IN_INTER_FILTER_INTRA_HITS.with(|c| c.get())
49-}
50-
51-// lane-angleinter r1: how many INTRA blocks inside an INTER frame carried a
52-// nonzero `angle_delta_y` / `angle_delta_uv` (`read_intra_angle_info`). Both
53-// arms refused a nonzero luma delta before this round, and no inter gate
54-// enabled `--enable-angle-delta` (aomenc's own default is 1).
55-thread_local! {
56- pub(super) static INTRA_IN_INTER_ANGLE_DELTA_Y_HITS: std::cell::Cell<usize> =
57- const { std::cell::Cell::new(0) };
58- pub(super) static INTRA_IN_INTER_ANGLE_DELTA_UV_HITS: std::cell::Cell<usize> =
59- const { std::cell::Cell::new(0) };
60-}
61-
62-/// Current value of [`INTRA_IN_INTER_ANGLE_DELTA_Y_HITS`].
63-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
64-pub(crate) fn intra_in_inter_angle_delta_y_hits() -> usize {
65- INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.get())
66-}
67-
68-/// Current value of [`INTRA_IN_INTER_ANGLE_DELTA_UV_HITS`].
69-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
70-pub(crate) fn intra_in_inter_angle_delta_uv_hits() -> usize {
71- INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|c| c.get())
72-}
73-
74-// lane-uv8 r1: the three non-DC chroma mode classes an INTRA 8x8 leaf inside
75-// an INTER frame ([`decode_inter_block8`]'s intra arm) can carry -- the arm
76-// read `uv_mode` and then refused everything but `DC_PRED`. Counted here and
77-// nowhere else so the gate's assert cannot be satisfied by a >=16x16 block.
78-thread_local! {
79- pub(super) static INTRA_IN_INTER8_UV_DIR_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
80- pub(super) static INTRA_IN_INTER8_UV_SMOOTH_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
81- pub(super) static INTRA_IN_INTER8_UV_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
82-}
83-
84-thread_local! {
85- pub(super) static INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
86-}
87-
88-/// Nonzero luma angle deltas coded by an intra 8x8 leaf inside an inter frame
89-/// (lane-leaf8tx r1) -- counted only in [`decode_inter_block8`]'s intra arm.
90-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
91-pub(crate) fn intra_in_inter8_angle_delta_y_hits() -> usize {
92- INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS.with(|c| c.get())
93-}
94-
95-/// `(directional, smooth/paeth, CfL)` chroma modes coded by an intra 8x8 leaf
96-/// inside an inter frame -- see [`INTRA_IN_INTER8_UV_DIR_HITS`].
97-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
98-pub(crate) fn intra_in_inter8_uv_hits() -> (usize, usize, usize) {
99- (
100- INTRA_IN_INTER8_UV_DIR_HITS.with(|c| c.get()),
101- INTRA_IN_INTER8_UV_SMOOTH_HITS.with(|c| c.get()),
102- INTRA_IN_INTER8_UV_CFL_HITS.with(|c| c.get()),
103- )
104-}
105-
106-// Whether this superblock's single CDEF unit (this decoder has no 128x128
107-// SB, so the SB IS the CDEF unit) has already had its `cdef_idx` literal
108-// read -- reset to `false` at the top of each superblock in the two tile
109-// loops, spec `read_cdef`'s `cdef_transmitted[index]`.
110-// Number of superblock columns in the current tile's grid, so
111-// [`maybe_read_cdef_idx`] can turn an `(mi_r, mi_c)` into a flat index into
112-// [`CDEF_IDX_GRID`].
113-// One resolved `cdef_idx` per superblock, read by [`apply_cdef`] to select
114-// which of the header's `1 << cdef.bits` strength pairs applies to that
115-// superblock's samples.
116-// How many real (`cdef.bits > 0`) `cdef_idx` literals [`maybe_read_cdef_idx`]
117-// has read, across every call on the current thread -- the gate's proof that a
118-// `cdef_bits > 0` stream actually reached the new reader rather than every
119-// superblock coincidentally being all-skip.
120-thread_local! {
121- pub(super) static CDEF_IDX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
122-}
123-
124-// How many times a warp was suppressed for one PLANE because that plane's own
125-// block is narrower or shorter than 8 (`av1_init_warp_params`'s own bail-out,
126-// reconinter.c) -- the gate's proof that a stream really carries the shape,
127-// since the square `side`/`chroma_side` can be 8 or more while the plane's
128-// true block is 4 wide (an 8x16 luma block's 4x8 chroma).
129-thread_local! {
130- pub(super) static WARP_PLANE_SUPPRESS_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
131-}
132-
133-/// Current value of [`WARP_PLANE_SUPPRESS_HITS`].
134-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
135-pub(crate) fn warp_plane_suppress_hits() -> usize {
136- WARP_PLANE_SUPPRESS_HITS.with(|c| c.get())
137-}
138-
139-/// Current value of [`CDEF_IDX_HITS`].
140-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
141-pub(crate) fn cdef_idx_hits() -> usize {
142- CDEF_IDX_HITS.with(|c| c.get())
143-}
144-
145-// lane-t900 r6: gate proof for the three r2-r4 root causes that shipped with no
146-// counter -- the in-inter tx-depth context (`tx_size_context_txfm_rect`), the
147-// non-chroma-reference block that must LEAVE its neighbours' chroma coefficient
148-// contexts alone, and the intra-edge filter neighbour pair taken mi-exact
149-// instead of from the coarse 16x16 cell.
150-thread_local! {
151- pub(super) static INTRA_IN_INTER_TXCTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
152- pub(super) static NON_CHROMA_REF_CTX_SKIP_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
153- pub(super) static EDGE_FILTER_MI_FIX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
154-}
155-
156-/// Current value of [`INTRA_IN_INTER_TXCTX_HITS`].
157-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
158-pub(crate) fn intra_in_inter_txctx_hits() -> usize {
159- INTRA_IN_INTER_TXCTX_HITS.with(|c| c.get())
160-}
161-
162-/// Current value of [`NON_CHROMA_REF_CTX_SKIP_HITS`].
163-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
164-pub(crate) fn non_chroma_ref_ctx_skip_hits() -> usize {
165- NON_CHROMA_REF_CTX_SKIP_HITS.with(|c| c.get())
166-}
167-
168-/// Current value of [`EDGE_FILTER_MI_FIX_HITS`].
169-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
170-pub(crate) fn edge_filter_mi_fix_hits() -> usize {
171- EDGE_FILTER_MI_FIX_HITS.with(|c| c.get())
172-}
173-
174-// lane-realworld r4: this frame's `delta.q_present` (spec 5.9.17) and its
175-// actual step (`1 << delta.q_res`, already the real multiplier, not the raw
176-// 2-bit field). `false`/`1` (the defaults) make [`maybe_read_delta_q`] a
177-// true no-op, matching every existing gate stream's `delta_q_present == 0`
178-// behaviour exactly, the same corner-cut [`CDEF_BITS`] takes above.
179-// The running quantizer index (spec `CurrentQIndex`, libaom
180-// `xd->current_base_qindex`) -- reset to the frame's own `base_q_idx` at the
181-// top of every tile (spec `decode_tile`), carried across superblocks within
182-// that tile, and mutated only by [`maybe_read_delta_q`]. Read back at the
183-// dequantization call sites instead of the frame-constant `base_q_idx`.
184-// This frame's own per-plane DC/AC quantizer-index deltas (lane-sbpart r11,
185-// spec 5.9.12/7.12.2, [`crate::quant::QuantDeltas`]) -- frame-constant (not
186-// per-superblock like [`CURRENT_Q_IDX`]), set once per frame decode and read
187-// back at every dequantization call site keyed on which plane it is doing.
188-// How many real `delta_q_present` symbol groups [`maybe_read_delta_q`] has
189-// read, across every call on the current thread -- the gate's proof that a
190-// `delta_q_present` stream actually reached the new reader.
191-thread_local! {
192- pub(super) static DELTA_Q_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
193-}
194-
195-/// Current value of [`DELTA_Q_HITS`].
196-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
197-pub(crate) fn delta_q_hits() -> usize {
198- DELTA_Q_HITS.with(|c| c.get())
199-}
200-
201-// lane-realworld r5: this frame's `delta.lf_present`/`lf_res`/`lf_multi`
202-// (spec 5.9.18) -- same no-op-by-default corner-cut as `DELTA_Q_PRESENT`.
203-// The running per-plane/direction loop-filter delta (spec `DeltaLF[i]`,
204-// `i` in `0..FRAME_LF_COUNT`) -- reset to `[0; 4]` at the top of every tile,
205-// mutated only by [`maybe_read_delta_lf`]. `!delta_lf_multi` mode only ever
206-// updates index 0 and every reader treats that as the value for all 4
207-// indices (spec `read_delta_lf_params`'s own single-cdf branch).
208-// How many real `delta_lf_present` symbol groups [`maybe_read_delta_lf`] has
209-// read -- the gate's proof the reader fired, mirroring [`DELTA_Q_HITS`].
210-thread_local! {
211- pub(super) static DELTA_LF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
212-}
213-
214-/// Current value of [`DELTA_LF_HITS`].
215-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
216-pub(crate) fn delta_lf_hits() -> usize {
217- DELTA_LF_HITS.with(|c| c.get())
218-}
219-
220-// ---------------------------------------------------------------------------
221-// lane-seg: segmentation. Header (spec 5.9.14) is parsed by `ec-av1-syntax`;
222-// this block is the per-block `segment_id` reader (spec 5.11.7-5.11.9) plus
223-// the two consumers a real stream exercises: the per-segment quantizer index
224-// (spec 7.12.2 `get_qindex`) and the per-segment loop-filter level
225-// (spec 7.14.4). Shapes follow libaom `decodemv.c:read_segment_id`/
226-// `read_intra_segment_id`/`read_inter_segment_id` and
227-// `pred_common.h:av1_get_spatial_seg_pred` -- note libaom returns the SPATIAL
228-// PREDICTION (not 0) from `read_segment_id` when the block is `skip`, which
229-// is what the oracle every gate here compares against actually does.
230-thread_local! {
231- /// `CurrentSegmentIds`: this frame's own map, `mi_rows * mi_cols` entries
232- /// with stride `mi_cols` (NOT the padded `Neighbours` grid stride).
233- /// `PrevSegmentIds`: the primary reference frame's saved map, empty when
234- /// this frame has no primary reference (spec `load_previous_segment_ids`).
235- /// `(mi_rows, mi_cols)` for both maps above.
236- /// `AboveSegPredContext` (per mi column) / `LeftSegPredContext` (per mi
237- /// row) -- spec 5.11.9's own `seg_id_predicted` neighbour state, which
238- /// libaom keeps on the neighbouring `mbmi->seg_id_predicted` instead.
239- /// The block currently being decoded -- read back by [`block_q_idx`].
240- /// The tile's own top-left mi position, for `AvailU`/`AvailL`.
241- /// How many real `segment_id` symbols were read, and the set of segment
242- /// ids any block ended up with -- the gate's proof the feature fired.
243- pub(super) static SEG_ID_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
244- /// How many `seg_id_predicted` symbols were read (temporal update).
245- pub(super) static SEG_PRED_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
246-}
247-
248-/// How many `segment_id` symbols have been read (never reset per frame).
249-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
250-pub(crate) fn segment_id_hits() -> usize {
251- SEG_ID_HITS.with(|c| c.get())
252-}
253-
254-/// How many `seg_id_predicted` symbols have been read (temporal update).
255-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
256-pub(crate) fn segment_pred_hits() -> usize {
257- SEG_PRED_HITS.with(|c| c.get())
258-}
259-
260-/// Resets the segmentation hit counters (gate setup).
261-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
262-pub(crate) fn reset_segment_hits() {
263- SEG_ID_HITS.with(|c| c.set(0));
264- SEG_IDS_SEEN.with(|c| c.set(0));
265- SEG_PRED_HITS.with(|c| c.set(0));
266- BLOCK_Q_SPAN.with(|c| c.set((i32::MAX, i32::MIN)));
267-}
268-
269-// How many key-frame luma blocks resolved `smooth_neighbor` (spec
270-// `get_intra_edge_filter_type`) to `true` -- lane-chroma r2's own before/after
271-// counter, proving a stream actually put a directional block next to a
272-// smooth-predicted neighbour rather than every block reading the (previously
273-// hardcoded `false`) edge-filter strength bucket unchanged.
274-thread_local! {
275- pub(super) static SMOOTH_LUMA_HITS: std::cell::Cell<usize> =
276- const { std::cell::Cell::new(0) };
277-}
278-
279-/// Current value of [`SMOOTH_LUMA_HITS`].
280-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
281-pub(crate) fn smooth_luma_hits() -> usize {
282- SMOOTH_LUMA_HITS.with(|c| c.get())
283-}
284-
285-thread_local! {
286- /// lane-band46 r1: how many split-transform units answered their intra
287- /// reach DIFFERENTLY under libaom's per-unit rules ([`Reach::of_tu`], the
288- /// palette2 r12 fix) than the standalone-block lookup this decoder used to
289- /// apply to them (class reach-is-per-transform-unit). Every hit is a
290- /// transform unit whose above-right / below-left reference samples would
291- /// be wrong without that fix.
292- pub(super) static SPLIT_TU_REACH_FIX_HITS: std::cell::Cell<usize> =
293- const { std::cell::Cell::new(0) };
294-}
295-
296-/// Current value of [`SPLIT_TU_REACH_FIX_HITS`].
297-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
298-pub(crate) fn split_tu_reach_fix_hits() -> usize {
299- SPLIT_TU_REACH_FIX_HITS.with(|c| c.get())
300-}
301-
302-// How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12),
303-// across every call on the current thread -- lane-chroma r3's own before/after
304-// counter, proving a stream actually exercised chroma's smooth/paeth
305-// predictor (the previously-refused round-2 gap) rather than every block
306-// landing on DC/CFL/directional.
307-thread_local! {
308- pub(super) static SMOOTH_UV_HITS: std::cell::Cell<usize> =
309- const { std::cell::Cell::new(0) };
310-}
311-
312-/// Current value of [`SMOOTH_UV_HITS`].
313-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
314-pub(crate) fn smooth_uv_hits() -> usize {
315- SMOOTH_UV_HITS.with(|c| c.get())
316-}
317-
318-// How many tiles [`decode_key_frame_tile_with_cdfs`] has actually decoded a
319-// full superblock walk over, across every call on the current thread --
320-// lane-tiles r2's own gate-blind-to-feature guard: a gate over a
321-// multi-tile stream must prove more than one tile actually fired, not just
322-// that the stream carried tile_info.cols > 1.
323-thread_local! {
324- pub(super) static TILE_HITS: std::cell::Cell<usize> =
325- const { std::cell::Cell::new(0) };
326-}
327-
328-/// Current value of [`TILE_HITS`].
329-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
330-pub(crate) fn tile_hits() -> usize {
331- TILE_HITS.with(|c| c.get())
332-}
333-
334-// How many 4-pixel deblocking edge groups [`edge_params`] has actually
335-// selected for filtering, across every call on the current thread -- the same
336-// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream
337-// exercised `apply_deblock` rather than every edge landing on level 0.
338-thread_local! {
339- pub(super) static DEBLOCK_HITS: std::cell::Cell<usize> =
340- const { std::cell::Cell::new(0) };
341-}
342-
343-/// Current value of [`DEBLOCK_HITS`].
344-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
345-pub(crate) fn deblock_hits() -> usize {
346- DEBLOCK_HITS.with(|c| c.get())
347-}
348-
349-// lane-defon r1: how many COMPOUND_REFERENCE blocks read a
350-// `UNIDIR_COMP_REFERENCE` pair (both references on the same temporal side,
351-// spec 5.11.25 `comp_reference_type == 0`) -- the gate's proof that a
352-// stream built with `--enable-onesided-comp=1` really exercised the
353-// `uni_comp_ref` alphabet rather than only bidirectional pairs.
354-thread_local! {
355- pub(super) static UNI_COMP_HITS: std::cell::Cell<usize> =
356- const { std::cell::Cell::new(0) };
357-}
358-
359-/// Current value of [`UNI_COMP_HITS`].
360-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
361-pub(crate) fn uni_comp_hits() -> usize {
362- UNI_COMP_HITS.with(|c| c.get())
363-}
364-
365-// lane-defon r1: how many blocks blended through a `COMPOUND_DIFFWTD` mask
366-// (`mc::diffwtd_mask`) -- the narrower half of `MASKED_COMPOUND_HITS`, the
367-// gate's proof that `--enable-diff-wtd-comp=1` reached the difference-weighted
368-// blend and not only the wedge arm.
369-thread_local! {
370- pub(super) static DIFFWTD_HITS: std::cell::Cell<usize> =
371- const { std::cell::Cell::new(0) };
372-}
373-
374-/// Current value of [`DIFFWTD_HITS`].
375-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
376-pub(crate) fn diffwtd_hits() -> usize {
377- DIFFWTD_HITS.with(|c| c.get())
378-}
379-
380-// lane-mcomp64 r1: how many blocks took the INFERRED `COMPOUND_DIFFWTD` arm --
381-// a block size where `av1_is_wedge_used` is false (64x64 is the only such size
382-// this decoder's square inter path reaches), so no `compound_type` symbol is
383-// coded at all. Strictly narrower than `DIFFWTD_HITS`, which also counts the
384-// coded-symbol DIFFWTD blocks at 8x8/16x16/32x32.
385-thread_local! {
386- pub(super) static DIFFWTD_INFERRED_HITS: std::cell::Cell<usize> =
387- const { std::cell::Cell::new(0) };
388-}
389-
390-/// Current value of [`DIFFWTD_INFERRED_HITS`].
391-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
392-pub(crate) fn diffwtd_inferred_hits() -> usize {
393- DIFFWTD_INFERRED_HITS.with(|c| c.get())
394-}
395-
396-// lane-defon r1: how many FORWARD KEYFRAMES were decoded -- a KEY frame coded
397-// with `show_frame == 0`, output later by a `show_existing_frame` header
398-// (aomenc `--enable-fwd-kf=1 --fwd-kf-dist=N`). Counted from
399-// `stream::decode_stream`, which is where the frame header is consumed; the
400-// gate's proof that the on-value really reached the bitstream rather than
401-// being dropped by the rate control.
402-thread_local! {
403- pub(super) static FWD_KF_HITS: std::cell::Cell<usize> =
404- const { std::cell::Cell::new(0) };
405-}
406-
407-/// Current value of [`FWD_KF_HITS`].
408-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
409-pub(crate) fn fwd_kf_hits() -> usize {
410- FWD_KF_HITS.with(|c| c.get())
411-}
412-
413-// How many [`read_tx_size`] reads resolved a `tx_depth` strictly less than
414-// the block's own side, across every call on the current thread -- the same
415-// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream
416-// actually exercised a *split* transform under `TxMode::Select` rather than
417-// every block coincidentally resolving `depth=0` (indistinguishable from
418-// `TxMode::Largest` pixel-wise).
419-thread_local! {
420- pub(super) static TX_DEPTH_HITS: std::cell::Cell<usize> =
421- const { std::cell::Cell::new(0) };
422-}
423-
424-// How many plain SQUARE intra blocks (lane-sqchroma r1) resolved a luma
425-// transform smaller than their own side (`tx_depth != 0`) while coding a
426-// chroma prediction other than `DC_PRED` -- the pair the square path's chroma
427-// only exercises with aomenc's tx-size search left ON (its default), which
428-// every older recipe in this file pins off. Counted at the block, so a stream
429-// where RD happened to give every split-transform block a DC chroma mode
430-// reads as zero rather than silently passing for free.
431-thread_local! {
432- pub(super) static SQ_CHROMA_TX_HITS: std::cell::Cell<usize> =
433- const { std::cell::Cell::new(0) };
434-}
435-
436-/// Current value of [`SQ_CHROMA_TX_HITS`].
437-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
438-pub(crate) fn sq_chroma_tx_hits() -> usize {
439- SQ_CHROMA_TX_HITS.with(|c| c.get())
440-}
441-
442-/// Current value of [`TX_DEPTH_HITS`].
443-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
444-pub(crate) fn tx_depth_hits() -> usize {
445- TX_DEPTH_HITS.with(|c| c.get())
446-}
447-
448-// lane-txselect: how many `txfm_split` symbols an inter frame's var-tx tree
449-// read, and how many of those actually took the split, on the current thread
450-// -- the same before/after counter pattern as [`TX_DEPTH_HITS`], proving a
451-// stream exercised spec 5.11.17's `read_var_tx_size` rather than every block
452-// coincidentally coding one whole-block transform.
453-thread_local! {
454- pub(super) static TXFM_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
455- // lane-inter4 r2: rectangular INTER residual coding -- how many rect
456- // strips coded one whole-block rect transform unit, and how many split
457- // their rect max transform into square sub-transforms.
458- pub(super) static RECT_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
459- pub(super) static RECT_INTER_TXSPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
460- // lane-r14 r2: luma transform units of an inter strip with a 64-px axis
461- // (64x32/32x64/64x16/16x64), whose coefficients are coded as the
462- // truncated low-32 corner.
463- pub(super) static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
464- // lane-rectres r1: whole-block luma transform units of a 32x32-level 1:4
465- // inter strip, `[32x8, 8x32]`.
466- pub(super) static RECT32X8_INTER_TU_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
467- // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32].
468- pub(super) static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
469- // lane-inter16ab r4: rectangular var-tx leaves with a 4-px axis, [8x4, 4x8]
470- // -- the `sub_tx_size_map[TX_16X4]` split leaves of a 16x16-level 1:4 strip.
471- pub(super) static VARTX_RECT_LEAF4_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
472- // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter
473- // frame -- 16x8 and 8x16 inter leaves.
474- pub(super) static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
475- pub(super) static INTER_LEAF16_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
476- // This frame's own `tx_mode == TxMode::Select` and `reduced_tx_set` bits,
477- // set once per inter tile by [`decode_inter_frame_tile_with_cdfs`] --
478- // `decode_inter_block` already carries forty parameters and both are
479- // frame-constant.
480- // lane-fiinter r1: this sequence header's own `enable_filter_intra` bit,
481- // frame-constant like the two above and stashed the same way -- an intra
482- // block inside an inter frame reads `use_filter_intra` under it.
483-}
484-
485-/// Current value of [`TXFM_SPLIT_HITS`].
486-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
487-pub(crate) fn txfm_split_hits() -> usize {
488- TXFM_SPLIT_HITS.with(|c| c.get())
489-}
490-
491-/// Current value of [`INTER_LEAF16_HORZ_HITS`] (lane-inter4 r3).
492-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
493-pub(crate) fn inter_leaf16_horz_hits() -> usize {
494- INTER_LEAF16_HORZ_HITS.with(|c| c.get())
495-}
496-
497-/// Current value of [`INTER_LEAF16_VERT_HITS`] (lane-inter4 r3).
498-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
499-pub(crate) fn inter_leaf16_vert_hits() -> usize {
500- INTER_LEAF16_VERT_HITS.with(|c| c.get())
501-}
502-
503-/// Current value of [`RECT_INTER_TU_HITS`] (lane-inter4 r2).
504-pub(crate) fn rect_inter_tu_hits() -> usize {
505- RECT_INTER_TU_HITS.with(|c| c.get())
506-}
507-
508-/// Current value of [`RECT_INTER_TXSPLIT_HITS`] (lane-inter4 r2).
509-pub(crate) fn rect_inter_txsplit_hits() -> usize {
510- RECT_INTER_TXSPLIT_HITS.with(|c| c.get())
511-}
512-
513-/// Current value of [`RECT64_INTER_TU_HITS`] (lane-r14 r2).
514-pub(crate) fn rect64_inter_tu_hits() -> usize {
515- RECT64_INTER_TU_HITS.with(|c| c.get())
516-}
517-
518-/// Current value of [`RECT32X8_INTER_TU_HITS`] (lane-rectres r1): `[32x8, 8x32]`
519-/// whole-block luma units of a 32x32-level 1:4 inter strip.
520-pub(crate) fn rect32x8_inter_tu_hits() -> [usize; 2] {
521- RECT32X8_INTER_TU_HITS.with(|c| c.get())
522-}
523-
524-/// Current value of [`VARTX_RECT_LEAF_HITS`] (lane-r14 r3): how many
525-/// rectangular var-tx leaf transform units were coded, `[32x16, 16x32]`.
526-pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] {
527- VARTX_RECT_LEAF_HITS.with(|c| c.get())
528-}
529-
530-/// Current value of [`VARTX_RECT_LEAF4_HITS`] (lane-inter16ab r4): 8x4/4x8
531-/// split leaves of a 16x4/4x16 strip, `[8x4, 4x8]`.
532-pub(crate) fn vartx_rect_leaf4_hits() -> [usize; 2] {
533- VARTX_RECT_LEAF4_HITS.with(|c| c.get())
534-}
535-
536-/// Records one rectangular var-tx leaf.
537-pub(super) fn vartx_rect_leaf_hit(tw: usize, th: usize) {
538- if crate::envflags::env_flag!("EC_VARTXLEAF") {
539- eprintln!("EC_VARTXLEAF tw={tw} th={th}");
540- }
541- let cell = if tw.min(th) == 4 {
542- &VARTX_RECT_LEAF4_HITS
543- } else {
544- &VARTX_RECT_LEAF_HITS
545- };
546- cell.with(|c| {
547- let mut h = c.get();
548- h[usize::from(th > tw)] += 1;
549- c.set(h);
550- });
551-}
552-
553-// How many `partition_w16` reads (a 16x16 block's own partition symbol, key
554-// intra-frame path) resolved to `PARTITION_VERT_B` -- lane-rect16 r1: a
555-// plain default-settings aomenc run over lavfi mandelbrot hits this arm on
556-// frame 0's very first non-NONE/SPLIT `partition_w16` symbol (mi=(3,2)), not
557-// the plain HORZ/VERT this lane's charter assumed. Left rect (8x16, real
558-// `decode_block_rect`) + two 8x8 leaves stacked on the right (`decode_leaf8`,
559-// chained via `prev_leaf` exactly like the existing 16x16-SPLIT-into-4x8x8
560-// path above).
561-thread_local! {
562- pub(super) static VERT_B_INTRA_HITS: std::cell::Cell<usize> =
563- const { std::cell::Cell::new(0) };
564-}
565-
566-/// Current value of [`VERT_B_INTRA_HITS`].
567-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
568-pub(crate) fn vert_b_intra_hits() -> usize {
569- VERT_B_INTRA_HITS.with(|c| c.get())
570-}
571-
572-// lane-ab16 r1: how many 16x16-level AB partitions fired, per arm, in
573-// `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B` order. Each arm is two
574-// 8x8 squares (`decode_leaf8`) plus one 16x8/8x16 strip (`decode_leaf_rect`,
575-// the non-skip coefficient path lane-rectx proved); the gate hard-asserts
576-// every arm separately so a run where aomenc's RD only picked one cannot
577-// pass as proof of four.
578-thread_local! {
579- pub(super) static AB16_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) };
580-}
581-
582-// [`AB16_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16).
583-thread_local! {
584- /// 4x4 transform units decoded inside an 8x8 square of a
585- /// `PARTITION_VERT_A`/`_B` -- the exact call that panicked before
586- /// [`crate::encode::Reach::of_tu`] (lane-ab16 r2), so the gate can prove
587- /// a real `--enable-tx-size-search=1` stream reaches it.
588- pub(super) static VERT_AB_TX4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
589-}
590-
591-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
592-pub(crate) fn vert_ab_tx4_hits() -> usize {
593- VERT_AB_TX4_HITS.with(std::cell::Cell::get)
594-}
595-
596-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
597-pub(crate) fn ab16_hits_by_arm() -> [usize; 4] {
598- AB16_HITS.with(std::cell::Cell::get)
599-}
600-
601-// How many `partition_w16` reads resolved to a plain `PARTITION_HORZ`/
602-// `PARTITION_VERT` (lane-rect16 r2): re-measuring after the VERT_B fix above
603-// showed mandelbrot's real first-hit blocker is this plain arm at mi=(0,7),
604-// not VERT_B (`refusal-names-a-correlate`; the VERT_B write-up's "frame 0's
605-// very first non-NONE/SPLIT symbol" claim was about decode ORDER within one
606-// superblock's z-order recursion, not raster mi position).
607-thread_local! {
608- pub(super) static HORZ_VERT_INTRA_HITS: std::cell::Cell<usize> =
609- const { std::cell::Cell::new(0) };
610-}
611-
612-/// Current value of [`HORZ_VERT_INTRA_HITS`].
613-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
614-pub(crate) fn horz_vert_intra_hits() -> usize {
615- HORZ_VERT_INTRA_HITS.with(|c| c.get())
616-}
617-
618-// How many blocks were decoded as a frame-edge rect strip -- the single
619-// coded half of a `PARTITION_HORZ`/`PARTITION_VERT` at the true frame edge
620-// (lane-oddh r1), i.e. a block living inside the 8px band of a frame whose
621-// height or width is 8 mod 16 (the user's 3840x1608 film). Intra and inter
622-// paths share the counter.
623-thread_local! {
624- pub(super) static EDGE_RECT_STRIP_HITS: std::cell::Cell<usize> =
625- const { std::cell::Cell::new(0) };
626-}
627-
628-/// Current value of [`EDGE_RECT_STRIP_HITS`].
629-#[allow(dead_code)] // gate counter accessor with no reader yet; the counter itself is live
630-pub(crate) fn edge_rect_strip_hits() -> usize {
631- EDGE_RECT_STRIP_HITS.with(|c| c.get())
632-}
633-
634-// lane-interedge r1: frame-edge half strips on the INTER path, per partition
635-// level (64/32/16) x axis (HORZ at a bottom edge, VERT at a right edge). The
636-// index is `level_idx * 2 + axis` with `level_idx` 0=64, 1=32, 2=16 and
637-// `axis` 0=HORZ (`!has_rows`), 1=VERT (`!has_cols`). Both of the user's films
638-// are height mod 16 == 8, so every inter frame crosses these nodes.
639-thread_local! {
640- pub(super) static INTER_EDGE_STRIP_HITS: std::cell::Cell<[usize; 6]> =
641- const { std::cell::Cell::new([0; 6]) };
642-}
643-
644-// lane-edgeboth r1: how many partition nodes were coded as the BOTH-AXES-CUT
645-// forced split -- libaom `decode_partition` (decodeframe.c):
646-// `else if (!has_rows && !has_cols) partition = PARTITION_SPLIT;`, the one
647-// straddle case that reads NO symbol at all. Indexed by level:
648-// 0 = 16x16, 1 = 32x32, 2 = 64x64, 3 = 128x128; intra and inter share it.
649-thread_local! {
650- pub(super) static EDGE_BOTH_CUT_HITS: std::cell::Cell<[usize; 4]> =
651- const { std::cell::Cell::new([0; 4]) };
652-}
653-
654-/// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`).
655-pub fn inter_edge_strip_hits() -> [usize; 6] {
656- INTER_EDGE_STRIP_HITS.with(|c| c.get())
657-}
658-
659-/// Resets [`INTER_EDGE_STRIP_HITS`] -- a refused attempt must not carry hits
660-/// into the next one (class `counter-from-refused-stream`).
661-pub fn reset_inter_edge_strip_hits() {
662- INTER_EDGE_STRIP_HITS.with(|c| c.set([0; 6]));
663-}
664-
665-/// Current value of [`EDGE_BOTH_CUT_HITS`] (`[16, 32, 64, 128]` levels).
666-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
667-pub(crate) fn edge_both_cut_hits() -> [usize; 4] {
668- EDGE_BOTH_CUT_HITS.with(|c| c.get())
669-}
670-
671-/// Zeroes [`EDGE_BOTH_CUT_HITS`] so a gate can measure a per-attempt delta.
672-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
673-pub(crate) fn reset_edge_both_cut_hits() {
674- EDGE_BOTH_CUT_HITS.with(|c| c.set([0; 4]));
675-}
676-
677-// How many HORZ/VERT intra strips resolved a SPLIT luma transform
678-// (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) --
679-// the case every rect path here refused by name before, and the first
680-// refusal the user's ReelB extract (600s in) stops at.
681-thread_local! {
682- pub(super) static RECT_SPLIT_TX_HITS: std::cell::Cell<usize> =
683- const { std::cell::Cell::new(0) };
684-}
685-
686-/// Current value of [`RECT_SPLIT_TX_HITS`].
687-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
688-pub(crate) fn rect_split_tx_hits() -> usize {
689- RECT_SPLIT_TX_HITS.with(|c| c.get())
690-}
691-
692-// The subset of [`RECT_SPLIT_TX_HITS`] that is BOTH superblock-level (one
693-// side 64) AND split past the first depth, i.e. tiled more than one unit in
694-// each axis -- the only shape with a transform unit that has neighbours on
695-// two sides inside its own strip (`row_off > 0 && col_off > 0`), and the one
696-// no gate fired before lane-rectsplit r2 (the shared counter above also
697-// counts 32x32-level and depth-1 strips, so it cannot prove this case).
698-thread_local! {
699- pub(super) static RECT_SPLIT_SB_INTERIOR_TU_HITS: std::cell::Cell<usize> =
700- const { std::cell::Cell::new(0) };
701-}
702-
703-/// Current value of [`RECT_SPLIT_SB_INTERIOR_TU_HITS`].
704-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
705-pub(crate) fn rect_split_sb_interior_tu_hits() -> usize {
706- RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.get())
707-}
708-
709-// Per-shape hit counts for the rect chroma transforms lane-rectchroma r1
710-// wired into [`decode_rect_split`] -- the shapes a split-transform strip's
711-// chroma half takes that had no coefficient tables before (index order:
712-// 32x8, 8x32, 8x4, 4x8). One counter per shape because a gate that only
713-// proves the pair it happens to hit cannot catch a transposed scan/context
714-// table (class scan-weights-cross-axis).
715-thread_local! {
716- pub(super) static RECT_SPLIT_CHROMA_SHAPE_HITS: std::cell::Cell<[usize; 4]> =
717- const { std::cell::Cell::new([0; 4]) };
718-}
719-
720-/// Current value of [`RECT_SPLIT_CHROMA_SHAPE_HITS`] (32x8, 8x32, 8x4, 4x8).
721-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
722-pub(crate) fn rect_split_chroma_shape_hits() -> [usize; 4] {
723- RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| c.get())
724-}
725-
726-// lane-av1-422: how many SQUARE chroma coefficient units the strip path read
727-// on a 4:2:2 frame (ss 1,0) -- the half-width, unhalved-height shape whose
728-// tables only exist because of the square rows in the chroma_tiled arm. A
729-// 4:2:0 or 4:4:4 frame can never increment it (their rect strips' chroma is
730-// itself rect), and a restored `/2 chroma height` diverts 4:2:2 squares onto
731-// the rect rows, so the witness gate reads 0 there and fails.
732-thread_local! {
733- pub(super) static CHROMA422_SQUARE_HITS: std::cell::Cell<usize> =
734- const { std::cell::Cell::new(0) };
735-}
736-
737-/// Current value of [`CHROMA422_SQUARE_HITS`].
738-// lane-av1-422b: `pub` so `examples/decode_probe.rs` can census it the way
739-// it does every other capability counter.
740-pub fn chroma422_square_hits() -> usize {
741- CHROMA422_SQUARE_HITS.with(|c| c.get())
742-}
743-
744-// lane-av1422tailskip: how many 4:2:2 (ss 1,0) intra-in-inter chroma TRANSFORM
745-// UNITS took their own window on the block-sized chroma palette prediction --
746-// `decode_inter_block`'s `side == 64` TX_32X32 walk, where the plane block is
747-// 32x64 but codes two stacked square units per plane. Zero on a 4:2:0 or 4:4:4
748-// frame (their chroma unit is the whole plane block, one window), and zero on
749-// a 4:2:2 block with no palette, so a witness gate reading 0 proves the arm
750-// never ran.
751-thread_local! {
752- pub(super) static PALETTE_422_UNIT_WINDOW_HITS: std::cell::Cell<usize> =
753- const { std::cell::Cell::new(0) };
754-}
755-
756-/// Current value of [`PALETTE_422_UNIT_WINDOW_HITS`].
757-// lane-av1422tailskip: `pub` so `examples/decode_probe.rs` can census it the
758-// way it does every other capability counter.
759-pub fn palette_422_unit_window_hits() -> usize {
760- PALETTE_422_UNIT_WINDOW_HITS.with(|c| c.get())
761-}
762-
763-// lane-av1-422f: how many RECT chroma coefficient units the square-block
764-// path read on a 4:2:2 frame (ss 1,0) -- TX_4X8 / TX_8X16 / TX_16X32, the
765-// plane block's own half-width, unhalved-height shape. A 4:2:0 or 4:4:4
766-// frame never takes the rect branch (their units are square
767-// `chroma_tx == chroma_tx_h`), so a witness gate reading 0 here proves the
768-// model reverted to squares.
769-thread_local! {
770- pub(super) static CHROMA422_RECT_HITS: std::cell::Cell<usize> =
771- const { std::cell::Cell::new(0) };
772-}
773-
774-/// Current value of [`CHROMA422_RECT_HITS`].
775-pub fn chroma422_rect_hits() -> usize {
776- CHROMA422_RECT_HITS.with(|c| c.get())
777-}
778-
779-// lane-av1-422g: how many PER-LEAF TX_4X4 chroma coefficient units the
780-// sub-8x8 split4 path read on a 4:2:2 frame (ss 1,0) -- one per even-column
781-// leaf per plane (`is_chroma_reference`'s `!(mi_col & ss_x)`). A 4:2:0 frame
782-// codes no sub-8 chroma at all and 4:4:4 goes through `sub8_leaf_chroma444`,
783-// so a witness gate reading 0 here proves the per-leaf 4:2:2 arm never ran.
784-thread_local! {
785- pub(super) static CHROMA422_SUB8_HITS: std::cell::Cell<usize> =
786- const { std::cell::Cell::new(0) };
787-}
788-
789-/// Current value of [`CHROMA422_SUB8_HITS`].
790-pub fn chroma422_sub8_hits() -> usize {
791- CHROMA422_SUB8_HITS.with(|c| c.get())
792-}
793-
794-// lane-av1422llintra: how many 4:2:2 LOSSLESS chroma plane blocks
795-// (`decode_leaf8`) were walked as 4x4 units rather than as the one
796-// `av1_get_max_uv_txsize` rect that rule only reaches OUTSIDE a lossless
797-// frame. A 4:2:0 or 4:4:4 frame never takes the arm (its own lossless walk
798-// was already there), so a witness gate reading 0 here proves the model
799-// reverted to the rect unit.
800-thread_local! {
801- pub(super) static CHROMA422_LOSSLESS_4X4_HITS: std::cell::Cell<usize> =
802- const { std::cell::Cell::new(0) };
803-}
804-
805-/// Current value of [`CHROMA422_LOSSLESS_4X4_HITS`].
806-pub fn chroma422_lossless_4x4_hits() -> usize {
807- CHROMA422_LOSSLESS_4X4_HITS.with(|c| c.get())
808-}
809-
810-// lane-av1-422sub8rect: how many PER-PIECE TX_4X4 chroma coefficient units
811-// the INTER sub-8x8 split4 path read on a 4:2:2 frame (ss 1,0) -- one per
812-// non-skipped odd-column piece per plane (`is_chroma_reference`'s
813-// `mi_col & 0x01` at ss_x 1). 4:2:0 goes through the shared group unit and
814-// 4:4:4 through [`sub8_leaf_chroma444`]'s own per-piece twin, so a witness
815-// gate reading 0 here proves the inter 4:2:2 per-piece arm never ran.
816-thread_local! {
817- pub(super) static CHROMA422_INTER_SUB8_HITS: std::cell::Cell<usize> =
818- const { std::cell::Cell::new(0) };
819-}
820-
821-/// Current value of [`CHROMA422_INTER_SUB8_HITS`].
822-pub fn chroma422_inter_sub8_hits() -> usize {
823- CHROMA422_INTER_SUB8_HITS.with(|c| c.get())
824-}
825-
826-// lane-av1-422m: how many TX_4X4 chunk units the invalid-ss-size chroma arm
827-// read (the 8x32 luma block whose 4:2:2 plane has no `ss_size_lookup` block).
828-// A 4:2:0 or 4:4:4 frame cannot increment it, so a non-zero read proves the
829-// chunked 4:2:2 chroma really decoded.
830-thread_local! {
831- pub(super) static CHROMA422_CHUNK_HITS: std::cell::Cell<usize> =
832- const { std::cell::Cell::new(0) };
833-}
834-
835-/// Current value of [`CHROMA422_CHUNK_HITS`].
836-pub fn chroma422_chunk_hits() -> usize {
837- CHROMA422_CHUNK_HITS.with(|c| c.get())
838-}
839-
840-// lane-av1-422stripanchor: how many 4-wide-strip PAIR chroma units
841-// ([`decode_rect_split`]'s ported floored-pair anchor) decoded. A 4:2:0 or
842-// 4:4:4 frame cannot increment it (the arm is keyed to a 2-px-wide chroma
843-// block, which only a 1-mi-wide strip at ss (1, 0) produces), so a non-zero
844-// read proves a stream routed a 4-wide strip through the split path.
845-thread_local! {
846- pub(super) static CHROMA422_PAIR_WIDE_HITS: std::cell::Cell<usize> =
847- const { std::cell::Cell::new(0) };
848-}
849-
850-/// Current value of [`CHROMA422_PAIR_WIDE_HITS`].
851-pub fn chroma422_pair_wide_hits() -> usize {
852- CHROMA422_PAIR_WIDE_HITS.with(|c| c.get())
853-}
854-
855-// How many HORZ/VERT intra strips actually predicted with filter intra
856-// (lane-rectsplit r1) -- the case `decode_block_rect` refused by name
857-// ("this decoder predicts square-only") until `predict_filter_intra` took
858-// `bw`x`bh`.
859-thread_local! {
860- pub(super) static FILTER_INTRA_RECT_HITS: std::cell::Cell<usize> =
861- const { std::cell::Cell::new(0) };
862-}
863-
864-/// Current value of [`FILTER_INTRA_RECT_HITS`].
865-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
866-pub(crate) fn filter_intra_rect_hits() -> usize {
867- FILTER_INTRA_RECT_HITS.with(|c| c.get())
868-}
869-
870-// As [`FILTER_INTRA_RECT_HITS`], counting only the 32x32-level 1:4 strips
871-// (32x8/8x32, lane-fi32x8 r1) -- the shapes whose `use_filter_intra` symbol
872-// was never read at all before that round, so a gate needs to prove the flag
873-// fired at THAT shape and not at a 16x8 one somewhere else in the frame.
874-// Split by ORIENTATION: rows 8 (32x8) and 9 (8x32) of `cdf::FILTER_INTRA`
875-// carry different probabilities (18101 vs 20229), so a transposed pair is
876-// only caught by a gate that sees the flag fire on BOTH shapes (class
877-// scan-weights-cross-axis).
878-thread_local! {
879- pub(super) static FILTER_INTRA_RECT4_HORZ_HITS: std::cell::Cell<usize> =
880- const { std::cell::Cell::new(0) };
881- pub(super) static FILTER_INTRA_RECT4_VERT_HITS: std::cell::Cell<usize> =
882- const { std::cell::Cell::new(0) };
883-}
884-
885-/// Current value of [`FILTER_INTRA_RECT4_HORZ_HITS`] (32x8 strips).
886-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
887-pub(crate) fn filter_intra_rect4_horz_hits() -> usize {
888- FILTER_INTRA_RECT4_HORZ_HITS.with(|c| c.get())
889-}
890-
891-/// Current value of [`FILTER_INTRA_RECT4_VERT_HITS`] (8x32 strips).
892-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
893-pub(crate) fn filter_intra_rect4_vert_hits() -> usize {
894- FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.get())
895-}
896-
897-// How many rectangular transform units actually coded coefficients through
898-// [`read_coeffs_rect`] (`all_zero == 0`) -- lane-rect1d's measure that a gate
899-// exercised the rect coefficient reader at all rather than passing on
900-// all-skip blocks.
901-thread_local! {
902- pub(super) static RECT_COEFF_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
903- pub(super) static RECT_CLASS1_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
904-}
905-
906-/// Current value of [`RECT_COEFF_TU_HITS`].
907-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
908-pub(crate) fn rect_coeff_tu_hits() -> usize {
909- RECT_COEFF_TU_HITS.with(|c| c.get())
910-}
911-
912-/// Rectangular transform units whose resolved `tx_type` is a 1D class
913-/// (`V_DCT`/`H_DCT`) -- [`TX_CLASS1_HITS`]'s rect-only half, so a gate can
914-/// pin that the 1D-class-on-a-RECT-transform path fired rather than settling
915-/// for the square reader's own 1D types.
916-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
917-pub(crate) fn rect_class1_hits() -> usize {
918- RECT_CLASS1_HITS.with(|c| c.get())
919-}
920-
921-// lane-av1readcensus: the PER-UNIT coefficient census -- one unit counted
922-// per `read_coeffs`/`read_coeffs_rect` call, i.e. per object this decoder
923-// actually walks, which is the unit the round-4 `av1444rect` count measured
924-// (636 square chroma reads against the oracle's 1086).
925-//
926-// lane-av1422census422 widened the arming. The counters used to be
927-// 4:4:4-ONLY (`CENSUS_444`), so at 4:2:2 -- a chroma format an AV1
928-// `color_config` can carry and libaom's writer emits -- every
929-// `census_444_units()` / `census_444_coded()` read zero BY CONSTRUCTION: a
930-// byte-exact 4:2:2 gate asserting those counters would be asserting a
931-// literal, and would be green while proving nothing about that stream. The
932-// census is now armed for every chroma format that leaves at least one luma
933-// axis unsubsampled -- (0,0) 4:4:4 and (1,0) 4:2:2 -- and 4:2:0 (1,1) stays
934-// off, so the existing 4:4:4 exact counts and the 4:2:0 zero control are
935-// unmoved by the widening. The counters are per-PLANE, not per-format, so a
936-// 4:2:2 cell's `[luma, u, v]` split is directly comparable with a 4:4:4
937-// cell's on the same walk shape.
938-thread_local! {
939- /// Per-plane unit counts, `[luma, u, v]`, at 4:4:4 and 4:2:2.
940- pub(super) static CENSUS_NONSUB_UNITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) };
941- /// Of [`CENSUS_NONSUB_UNITS`], the units that coded at least one
942- /// coefficient (`txb_skip == 0`) -- the per-plane split is only
943- /// comparable against the oracle's when both sides count all-zero units
944- /// the same way.
945- pub(super) static CENSUS_NONSUB_CODED: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) };
946- /// Sequential unit index, so a trace line names its own position in the
947- /// frame's walk rather than relying on line order alone.
948- pub(super) static CENSUS_UNIT_N: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
949- /// The plane the units read from here on belong to. A thread-local rather
950- /// than a `read_coeffs` parameter because the three luma call sites
951- /// (`decode_rect_split`, `decode_block_rect64`, `read_inter_plane_rect`)
952- /// are not this lane's to edit and would each grow an argument; the
953- /// plane-owning readers stamp it once on entry instead.
954- pub(super) static CENSUS_PLANE: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
955- /// At least one luma axis unsubsampled -- (0,0) 4:4:4 or (1,0) 4:2:2 --
956- /// for the frame being decoded, set per frame from [`crate::stream`].
957- /// 4:2:0 (1,1) arms nothing.
958- pub(super) static CENSUS_NONSUB: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
959-}
960-
961-/// Current `[luma, u, v]` coefficient-unit counts, per plane. Zero at 4:2:0
962-/// by design ([`set_census_nonsub`] arms nothing there).
963-pub fn census_nonsub_units() -> [usize; 3] {
964- CENSUS_NONSUB_UNITS.with(|c| c.get())
965-}
966-
967-/// Current `[luma, u, v]` counts of units that coded coefficients.
968-pub fn census_nonsub_coded() -> [usize; 3] {
969- CENSUS_NONSUB_CODED.with(|c| c.get())
970-}
971-
972-/// lane-av1readcensus: arms the coefficient-unit census for the frame about
973-/// to decode, called once per frame from [`crate::stream`]'s decode loop
974-/// beside [`set_subsampling`]. Armed for every chroma format with an
975-/// unsubsampled luma axis -- 4:4:4 (0,0) and 4:2:2 (1,0) -- and NOT for
976-/// 4:2:0 (1,1), where the walk-shape question this census answers does not
977-/// arise, so a 4:2:0 control can still assert exactly zero.
978-///
979-/// lane-av1422census422 widened this from `(ss_x == 0 && ss_y == 0)`. The
980-/// old condition made 4:2:2 silently UNCUNTABLE rather than uncounted. The
981-/// two format pairs keep disjoint conditions, so neither the 4:4:4 exact
982-/// counts nor the 4:2:0 zero control can move because of this.
983-pub(crate) fn set_census_nonsub(ss_x: u8, ss_y: u8) {
984- CENSUS_NONSUB.with(|c| c.set(ss_x == 0 || ss_y == 0));
985-}
986-
987-/// lane-av1readcensus: the plane the units read from here on belong to,
988-/// stamped by the plane-owning readers ([`read_plane`], [`read_inter_plane`],
989-/// [`read_inter_plane_rect`]) on entry.
990-pub(crate) fn set_census_plane(plane: usize) {
991- CENSUS_PLANE.with(|c| c.set(plane));
992-}
993-
994-/// lane-av1readcensus: is the per-unit census trace on? Shares
995-/// [`coeff_trace_on`]'s per-frame narrowing so one frame's walk can be
996-/// dumped without the rest of the stream.
997-fn census_trace_on() -> bool {
998- if !crate::envflags::env_flag!("EC_CENSUS_UNIT") {
999- return false;
1000- }
1001- match COEFF_TRACE_FRAME.with(|c| c.get()) {
1002- None => true,
1003- Some(w) if w >= usize::MAX - 1 => true,
1004- Some(w) => COEFF_TRACE_CUR.with(|c| c.get()) == w,
1005- }
1006-}
1007-
1008-/// lane-av1readcensus: one line per coefficient unit this decoder walks, the
1009-/// twin of the oracle's `EC_COEFF` / `EC_COEFF_VAL` bracket around each
1010-/// `av1_read_coeffs_txb` call. Pair the two sides by `post_rng` (or by `n`),
1011-/// never by plane label or by walk position -- the walk order is exactly what
1012-/// the census is measuring.
1013-pub(super) fn census_unit(
1014- w: usize,
1015- h: usize,
1016- tx_type: TxType,
1017- eob: usize,
1018- all_zero: bool,
1019- entry_rng: u32,
1020- dec: &SymbolDecoder,
1021-) {
1022- let plane = CENSUS_PLANE.with(|c| c.get()).min(2);
1023- let coded = usize::from(!all_zero);
1024- CENSUS_UNIT_N.with(|c| c.set(c.get() + 1));
1025- hit_do! {
1026- CENSUS_NONSUB_UNITS.with(|c| {
1027- if CENSUS_NONSUB.with(|on| on.get()) {
1028- let mut v = c.get();
1029- v[plane] += 1;
1030- c.set(v);
1031- }
1032- });
1033- CENSUS_NONSUB_CODED.with(|c| {
1034- if CENSUS_NONSUB.with(|on| on.get()) {
1035- let mut v = c.get();
1036- v[plane] += coded;
1037- c.set(v);
1038- }
1039- });
1040- }
1041- if !census_trace_on() {
1042- return;
1043- }
1044- let n = CENSUS_UNIT_N.with(|c| c.get()) - 1;
1045- let post_rng = dec.debug_state().0;
1046- eprintln!(
1047- "EC_CENSUS_UNIT side=ours n={n} plane={plane} w={w} h={h} tx={tx_type:?} eob={eob} \
1048- all_zero={all_zero} entry_rng={entry_rng} post_rng={post_rng}"
1049- );
1050-}
1051-
1052-/// How many transform units this thread has read since the last
1053-/// [`reset_census_unit_n`] (lane-av1offtile). The per-unit oracle twin is
1054-/// `EC_ECDUMP_IN`, one line per `read_coeffs_txb` call, so this count IS
1055-/// directly comparable with an oracle `EC_ECDUMP_IN` census -- which is what
1056-/// makes "we walk N units where libaom walks M" a gated claim rather than an
1057-/// inference from the desync's position.
1058-pub fn census_unit_n() -> usize {
1059- CENSUS_UNIT_N.with(|c| c.get())
1060-}
1061-
1062-/// Reset [`census_unit_n`] to zero (lane-av1offtile).
1063-pub fn reset_census_unit_n() {
1064- CENSUS_UNIT_N.with(|c| c.set(0));
1065-}
1066-
1067-// As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16
1068-// (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the
1069-// shapes whose `use_filter_intra` symbol had no CDF class before this round.
1070-// A gate asserting the wider counter would be satisfied by a 32x16 strip and
1071-// prove nothing about the new shapes.
1072-thread_local! {
1073- pub(super) static FILTER_INTRA_RECT_SUB16_HITS: std::cell::Cell<usize> =
1074- const { std::cell::Cell::new(0) };
1075-}
1076-
1077-/// Current value of [`FILTER_INTRA_RECT_SUB16_HITS`].
1078-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1079-pub(crate) fn filter_intra_rect_sub16_hits() -> usize {
1080- FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get())
1081-}
1082-
1083-// As [`FILTER_INTRA_RECT_SUB16_HITS`], one partition level further down:
1084-// 4x8/8x4 leaves of an 8x8 HORZ/VERT (lane-fi8 r1). A gate on the sub16
1085-// counter would be satisfied by a 16x8 strip and prove nothing here.
1086-thread_local! {
1087- pub(super) static FILTER_INTRA_RECT_SUB8_HITS: std::cell::Cell<usize> =
1088- const { std::cell::Cell::new(0) };
1089-}
1090-
1091-/// Current value of [`FILTER_INTRA_RECT_SUB8_HITS`].
1092-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1093-pub(crate) fn filter_intra_rect_sub8_hits() -> usize {
1094- FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.get())
1095-}
1096-
1097-// How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D`
1098-// (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every
1099-// call on the current thread -- the same before/after counter pattern as
1100-// [`TX_DEPTH_HITS`], proving a stream actually exercised the class-split
1101-// `eob_pt`/1D-neighbour context path rather than every block coincidentally
1102-// landing on `DCT_DCT`.
1103-thread_local! {
1104- pub(super) static TX_CLASS1_HITS: std::cell::Cell<usize> =
1105- const { std::cell::Cell::new(0) };
1106-}
1107-
1108-// How many `uv_mode` reads resolved to a directional chroma mode (neither
1109-// `DC_PRED` nor `UV_CFL_PRED`), across every call on the current thread -- the same
1110-// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream
1111-// actually exercised chroma's own directional predictor.
1112-thread_local! {
1113- pub(super) static DIRECTIONAL_UV_HITS: std::cell::Cell<usize> =
1114- const { std::cell::Cell::new(0) };
1115-}
1116-
1117-/// Current value of [`DIRECTIONAL_UV_HITS`].
1118-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1119-pub(crate) fn directional_uv_hits() -> usize {
1120- DIRECTIONAL_UV_HITS.with(|c| c.get())
1121-}
1122-
1123-// How many `angle_delta`/`angle_delta_uv` symbols this decoder has read as
1124-// something other than [`ANGLE_DELTA_ZERO`], across every call in the
1125-// process -- the same before/after counter pattern as [`FILTER_INTRA_HITS`],
1126-// proving a stream actually exercised a nonzero angle delta.
1127-thread_local! {
1128- pub(super) static ANGLE_DELTA_HITS: std::cell::Cell<usize> =
1129- const { std::cell::Cell::new(0) };
1130-}
1131-
1132-// How many [`read_single_ref`] reads resolved to a reference other than
1133-// `LAST_FRAME`, across every call on the current thread -- the same before/after
1134-// counter pattern as [`FILTER_INTRA_HITS`], proving a stream actually
1135-// exercised a non-`LAST_FRAME` reference (`GOLDEN_FRAME`, this decoder's
1136-// only other supported one so far) rather than every block coincidentally
1137-// resolving `LAST_FRAME`.
1138-thread_local! {
1139- pub(super) static NON_LAST_REF_HITS: std::cell::Cell<usize> =
1140- const { std::cell::Cell::new(0) };
1141-}
1142-
1143-/// Current value of [`NON_LAST_REF_HITS`].
1144-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1145-pub(crate) fn non_last_ref_hits() -> usize {
1146- NON_LAST_REF_HITS.with(|c| c.get())
1147-}
1148-
1149-// Per-reference [`NON_LAST_REF_HITS`] breakdown (lane-av1refs): one counter
1150-// per `MV_REFERENCE_FRAME` past `LAST_FRAME`, so a gate targeting one
1151-// specific reference (`LAST2`/`LAST3`/`GOLDEN`/`BWDREF`/`ALTREF2`/`ALTREF`)
1152-// can prove THAT reference fired rather than any non-`LAST_FRAME` one --
1153-// `NON_LAST_REF_HITS` alone cannot tell a `LAST2_FRAME` gate from a
1154-// `GOLDEN_FRAME` draw it did not ask for.
1155-thread_local! {
1156- pub(super) static LAST2_HITS: std::cell::Cell<usize> =
1157- const { std::cell::Cell::new(0) };
1158-}
1159-
1160-thread_local! {
1161- pub(super) static LAST3_HITS: std::cell::Cell<usize> =
1162- const { std::cell::Cell::new(0) };
1163-}
1164-
1165-thread_local! {
1166- pub(super) static GOLDEN_HITS: std::cell::Cell<usize> =
1167- const { std::cell::Cell::new(0) };
1168-}
1169-
1170-thread_local! {
1171- pub(super) static BWDREF_HITS: std::cell::Cell<usize> =
1172- const { std::cell::Cell::new(0) };
1173-}
1174-
1175-thread_local! {
1176- pub(super) static ALTREF2_HITS: std::cell::Cell<usize> =
1177- const { std::cell::Cell::new(0) };
1178-}
1179-
1180-thread_local! {
1181- pub(super) static ALTREF_HITS: std::cell::Cell<usize> =
1182- const { std::cell::Cell::new(0) };
1183-}
1184-
1185-// How many [`read_comp_mode`] reads resolved `COMPOUND_REFERENCE` (lane-av1comp)
1186-// -- proves a `reference_select` stream actually reached a block that picked
1187-// compound, not just that the header bit was set. Every such block is
1188-// refused after this fires ([`decode_inter_block`]/[`decode_inter_block8`]),
1189-// so this only ever counts attempted reads, never a completed decode.
1190-thread_local! {
1191- pub(super) static COMP_MODE_HITS: std::cell::Cell<usize> =
1192- const { std::cell::Cell::new(0) };
1193-}
1194-
1195-/// Current value of [`COMP_MODE_HITS`].
1196-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1197-pub(crate) fn comp_mode_hits() -> usize {
1198- COMP_MODE_HITS.with(|c| c.get())
1199-}
1200-
1201-// How many blocks [`read_intra_mode`] decoded a real (nonzero-size) palette-Y
1202-// use for, across every call on the current thread -- the same before/after
1203-// counter pattern as [`FILTER_INTRA_HITS`], proving a stream actually
1204-// exercised palette reconstruction rather than only reading and refusing the
1205-// `palette_y_mode` symbol.
1206-thread_local! {
1207- pub(super) static PALETTE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1208-}
1209-
1210-/// Current value of [`PALETTE_HITS`].
1211-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1212-pub(crate) fn palette_hits() -> usize {
1213- PALETTE_HITS.with(|c| c.get())
1214-}
1215-
1216-// lane-tiles r12: of those, how many sat at their own TILE's left column --
1217-// exactly the blocks whose palette cache/ctx must NOT see the previous tile's
1218-// colours (`av1_get_palette_cache`'s `xd->left_mbmi == NULL`). A multi-tile
1219-// palette gate that never hits one proves nothing about the tile guard.
1220-thread_local! {
1221- pub(super) static PALETTE_TILE_LEFT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1222-}
1223-
1224-/// Current value of [`PALETTE_TILE_LEFT_HITS`].
1225-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1226-pub(crate) fn palette_tile_left_hits() -> usize {
1227- PALETTE_TILE_LEFT_HITS.with(|c| c.get())
1228-}
1229-
1230-// lane-palette2 r1: as [`PALETTE_HITS`], for a real (nonzero-size) chroma
1231-// palette use -- proves a stream actually reconstructed UV palette pixels,
1232-// not just read and refused the `palette_uv_mode` symbol.
1233-thread_local! {
1234- pub(super) static PALETTE_UV_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1235-}
1236-
1237-/// Current value of [`PALETTE_UV_HITS`].
1238-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1239-pub(crate) fn palette_uv_hits() -> usize {
1240- PALETTE_UV_HITS.with(|c| c.get())
1241-}
1242-
1243-// lane-palette2 r1: how many HORZ/VERT rect intra strips ([`read_intra_mode_rect`])
1244-// decoded a real palette-Y use -- proves the rect strip's own palette syntax
1245-// (not just the square path's) actually fired.
1246-thread_local! {
1247- pub(super) static PALETTE_RECT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1248-}
1249-
1250-/// Current value of [`PALETTE_RECT_HITS`].
1251-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1252-pub(crate) fn palette_rect_hits() -> usize {
1253- PALETTE_RECT_HITS.with(|c| c.get())
1254-}
1255-
1256-// lane-palette2 r6: how many HORZ/VERT rect intra strips ran the
1257-// [`palette_bsize_ctx_wh`]-gated code path in [`read_intra_mode_rect`] --
1258-// i.e. `allow_screen_content_tools` was set and the strip's `bw`x`bh` was in
1259-// range, so `palette_y_mode`/`palette_uv_mode` were actually read (and, per
1260-// RD, almost always refused-on-use because the block doesn't end up USING a
1261-// palette -- see r5's report). This is the site the removed refusal
1262-// ("a HORZ/VERT intra strip in a screen-content frame") used to guard: it
1263-// fired here whether or not the block picked a palette, so this is the
1264-// counter that proves the case r5's narrower [`PALETTE_RECT_HITS`] almost
1265-// never observes.
1266-thread_local! {
1267- pub(super) static RECT_SCREEN_CONTENT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1268-}
1269-
1270-/// Current value of [`RECT_SCREEN_CONTENT_HITS`].
1271-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1272-pub(crate) fn rect_screen_content_hits() -> usize {
1273- RECT_SCREEN_CONTENT_HITS.with(|c| c.get())
1274-}
1275-
1276-// lane-palette2 r1: how many palette-Y luma transform UNITS decoded under a
1277-// split luma transform (`logical_tx != side`) -- proves the per-TU index-map
1278-// windowing actually ran, not just that the whole-block path stayed exact.
1279-// Counts units, not blocks (a 64x64 palette block split to 16x16 TUs adds 16);
1280-// first actually incremented in r7, when the refusal it guarded was lifted.
1281-thread_local! {
1282- pub(super) static PALETTE_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1283-}
1284-
1285-thread_local! {
1286- /// lane-kf900 r4: rect intra strips that ACTUALLY use a palette -- the
1287- /// 1:4 shapes (32x8/8x32, 16x4/4x16) and the sub-16x16 2:1 leaves
1288- /// (16x8/8x16), the two shapes the lifted refusals named.
1289- pub(super) static RECT4_PALETTE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1290-}
1291-
1292-/// Current value of [`RECT4_PALETTE_HITS`].
1293-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1294-pub(crate) fn rect4_palette_hits() -> usize {
1295- RECT4_PALETTE_HITS.with(|c| c.get())
1296-}
1297-
1298-/// Current value of [`PALETTE_SPLIT_TX_HITS`].
1299-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1300-pub(crate) fn palette_split_tx_hits() -> usize {
1301- PALETTE_SPLIT_TX_HITS.with(|c| c.get())
1302-}
1303-
1304-thread_local! {
1305- /// lane-av1444d10: chroma PREDICTION units on the 32-capped tiled chroma
1306- /// walk (`decode_block_rect`'s `uw/uh = min(chroma, 32)` units) that were
1307- /// handed a STRICT sub-slice of their block's palette buffer -- i.e. the
1308- /// units of a block the 32-cap actually TILED (`nw * nh > 1`).
1309- ///
1310- /// CORRECTED 2026-09-30 after the refutation pass `lanes/refute-av1444d10`
1311- /// read the numbers back: the previous comment claimed it counted "the
1312- /// units that are NOT the block's top-left corner", which is not what the
1313- /// code did -- the hit was unconditional, so a block's corner unit fired it
1314- /// too AND a single-unit block (whose window is a pure re-stride copy of
1315- /// the whole buffer) fired it as well. That made a hit prove only that some
1316- /// palette chroma block existed, not that the tiled arm ran. The `bigger`
1317- /// guard now makes the counter discriminate. On the pinned fixture the
1318- /// measured value is unchanged at 4 (one block with nw = 1, nh = 2 x two
1319- /// planes x two unit rows); a stream whose palette chroma blocks are all
1320- /// single-unit now leaves it at zero.
1321- ///
1322- /// FURTHER CORRECTED the same day by the palette lane's refutation
1323- /// (`lanes/av1444palw.report.md` + the arm-isolated mutation): the guard is
1324- /// about TILING, not about `nw > 1` specifically. Isolating the two window
1325- /// sites shows the RECT-unit arm alone reds the 10-bit cell, and the
1326- /// SQUARE-unit arm alone reds the 12-bit cell *and* the 10-bit one -- so
1327- /// windowing is load-bearing for every tiled block, and `nw > 1` is merely
1328- /// the case the corpus could not reach. Do not read this counter as
1329- /// evidence that only the horizontal term matters.
1330- pub(super) static CHROMA_PALETTE_WINDOW_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1331-}
1332-
1333-/// Current value of [`CHROMA_PALETTE_WINDOW_HITS`].
1334-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1335-pub(crate) fn chroma_palette_window_hits() -> usize {
1336- CHROMA_PALETTE_WINDOW_HITS.with(|c| c.get())
1337-}
1338-
1339-/// Zeroes [`CHROMA_PALETTE_WINDOW_HITS`] so a gate can read it as a DELTA
1340-/// (it is process-wide, like every counter here).
1341-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1342-pub(crate) fn reset_chroma_palette_window_hits() {
1343- CHROMA_PALETTE_WINDOW_HITS.with(|c| c.set(0));
1344-}
1345-
1346-thread_local! {
1347- /// lane-pal8 r1: square 8x8 LEAVES ([`decode_leaf8`]) that actually use a
1348- /// palette (Y or UV) -- the shape every 8-bit `--tune-content=screen`
1349- /// stream stopped on, since aomenc palettes square blocks at 8 bit and
1350- /// `--min-partition-size=8` puts them on this leaf path.
1351- pub(super) static PALETTE_LEAF8_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1352-}
1353-
1354-/// Current value of [`PALETTE_LEAF8_HITS`].
1355-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1356-pub(crate) fn palette_leaf8_hits() -> usize {
1357- PALETTE_LEAF8_HITS.with(|c| c.get())
1358-}
1359-
1360-/// Zeroes [`PALETTE_LEAF8_HITS`] (per-attempt gate counting).
1361-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1362-pub(crate) fn reset_palette_leaf8_hits() {
1363- PALETTE_LEAF8_HITS.with(|c| c.set(0));
1364-}
1365-
1366-thread_local! {
1367- /// lane-pal8 r1: NON-SKIP palette blocks on a superblock-level (64-level)
1368- /// HORZ/VERT or 1:4 strip ([`decode_block_rect64`]) -- i.e. a palette
1369- /// block that also carries a real, corner-cropped luma transform.
1370- pub(super) static PALETTE_SB_STRIP_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1371-}
1372-
1373-/// Current value of [`PALETTE_SB_STRIP_HITS`].
1374-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1375-pub(crate) fn palette_sb_strip_hits() -> usize {
1376- PALETTE_SB_STRIP_HITS.with(|c| c.get())
1377-}
1378-
1379-/// Zeroes [`PALETTE_SB_STRIP_HITS`] (per-attempt gate counting).
1380-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1381-pub(crate) fn reset_palette_sb_strip_hits() {
1382- PALETTE_SB_STRIP_HITS.with(|c| c.set(0));
1383-}
1384-
1385-thread_local! {
1386- /// lane-av1rectreach: units of `decode_rect_split`'s `chroma_tiled` walk
1387- /// whose PER-UNIT reach ([`tu_reach_rect`], libaom's per-unit
1388- /// `has_top_right` / `has_bottom_left`) DIFFERS from the block-level
1389- /// `reach` this walk used to hand every unit -- i.e. units for which the
1390- /// two answers are not interchangeable. This is what a gate needs before
1391- /// it compares the walk byte-exactly: if the two agreed everywhere, the
1392- /// substitution could not change a single predicted sample and the
1393- /// exactness assert would be measuring a witness the fix cannot touch.
1394- ///
1395- /// What it does NOT prove is that the argument handed to the unit reader
1396- /// is the per-unit one -- the count is taken from the same expression
1397- /// either way, so deleting the substitution reds the exactness assert
1398- /// rather than this counter. That is the right way round: the assert is
1399- /// the claim, this is only the floor under it.
1400- pub(super) static RECT_TILED_CHROMA_UNIT_REACH_HITS: std::cell::Cell<usize> =
1401- const { std::cell::Cell::new(0) };
1402- /// Chroma units of the same walk whose grid is exactly 2x1 (a 4:4:4
1403- /// 64x32 chroma plane block as two 32x32 units).
1404- pub(super) static RECT_TILED_CHROMA_2X1_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1405- /// Chroma units of the same walk whose grid is exactly 1x2 (4:4:4 32x64,
1406- /// or 16x64 as two 16x32s).
1407- pub(super) static RECT_TILED_CHROMA_1X2_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1408- /// Chroma units of the same walk in any other multi-unit grid (2x2 and
1409- /// up). lane-av1422lift: this used to say "only reachable at 4:2:2, which
1410- /// is refused, so this stays 0 on every admitted stream", and that was
1411- /// true. 4:2:2 is decoded now, so the "cannot happen" is gone -- but the
1412- /// arm is still UNWITNESSED: measured on this branch's tip over all 21
1413- /// committed 4:2:2 cells and over the 4:2:0 / 4:4:4 cells probed, it
1414- /// reads 0 on every one of them. No committed gate reads it either (the
1415- /// only readers of `rect_tiled_chroma_grid_hits()` are two 4:4:4 strip
1416- /// gates, where `nxn` is interpolated into a failure message and never
1417- /// asserted). Kept so the match above is exhaustive.
1418- pub(super) static RECT_TILED_CHROMA_NXN_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1419-}
1420-
1421-/// Current values of the four `RECT_TILED_CHROMA_*` counters, in the order
1422-/// `(unit_reach_differs, 2x1, 1x2, other multi-unit)`.
1423-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1424-pub(crate) fn rect_tiled_chroma_grid_hits() -> (usize, usize, usize, usize) {
1425- (
1426- RECT_TILED_CHROMA_UNIT_REACH_HITS.with(|c| c.get()),
1427- RECT_TILED_CHROMA_2X1_HITS.with(|c| c.get()),
1428- RECT_TILED_CHROMA_1X2_HITS.with(|c| c.get()),
1429- RECT_TILED_CHROMA_NXN_HITS.with(|c| c.get()),
1430- )
1431-}
1432-
1433-/// Zeroes the four `RECT_TILED_CHROMA_*` counters (gate tests call this
1434-/// before their own decode).
1435-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1436-pub(crate) fn reset_rect_tiled_chroma_grid_hits() {
1437- RECT_TILED_CHROMA_UNIT_REACH_HITS.with(|c| c.set(0));
1438- RECT_TILED_CHROMA_2X1_HITS.with(|c| c.set(0));
1439- RECT_TILED_CHROMA_1X2_HITS.with(|c| c.set(0));
1440- RECT_TILED_CHROMA_NXN_HITS.with(|c| c.set(0));
1441-}
1442-
1443-// lane-t900 r22: palette blocks reconstructed inside an INTER frame (the
1444-// intra-in-inter path, `decode_inter_block`/`decode_inter_block8`) -- counted
1445-// apart from [`PALETTE_HITS`] so a witness gate can prove the INTER-frame
1446-// capability rather than the key frame's, which every screen stream also
1447-// carries.
1448-thread_local! {
1449- pub(super) static INTRA_IN_INTER_PALETTE_Y_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1450- pub(super) static INTRA_IN_INTER_PALETTE_UV_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1451-}
1452-
1453-// lane-t900 r23: as [`INTRA_IN_INTER_PALETTE_Y_HITS`], narrowed to the 8x8
1454-// LEAF site ([`decode_inter_block8`]'s intra arm) -- the >=16 site fires the
1455-// shared counter too, so only this one proves a gate really reached the leaf
1456-// where the refusal used to sit.
1457-thread_local! {
1458- pub(super) static INTER8_PALETTE_HITS: std::cell::Cell<(usize, usize)> =
1459- const { std::cell::Cell::new((0, 0)) };
1460-}
1461-
1462-/// Current values of the 8x8-leaf intra-in-inter palette counters, `(y, uv)`.
1463-pub(crate) fn inter8_palette_hits() -> (usize, usize) {
1464- INTER8_PALETTE_HITS.with(std::cell::Cell::get)
1465-}
1466-
1467-/// Current values of the two intra-in-inter palette counters, `(y, uv)`.
1468-pub(crate) fn intra_in_inter_palette_hits() -> (usize, usize) {
1469- (
1470- INTRA_IN_INTER_PALETTE_Y_HITS.with(|c| c.get()),
1471- INTRA_IN_INTER_PALETTE_UV_HITS.with(|c| c.get()),
1472- )
1473-}
1474-
1475-// lane-hgkf r2: SKIPPED intra blocks whose `tx_depth` split the luma transform
1476-// and which are therefore predicted one transform unit at a time (a skipped
1477-// block codes no coefficients, so nothing else in the stream witnesses this
1478-// path -- only the pixels do).
1479-thread_local! {
1480- pub(super) static SKIP_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1481-}
1482-
1483-/// Current value of [`SKIP_SPLIT_TX_HITS`] (blocks, not units).
1484-pub fn skip_split_tx_hits() -> usize {
1485- SKIP_SPLIT_TX_HITS.with(|c| c.get())
1486-}
1487-
1488-// lane-svt1: SKIPPED square blocks carrying a palette/intrabc prediction whose
1489-// `tx_depth` split the luma transform -- the arm that predicted DC off the
1490-// block edges before the fix. Like [`SKIP_SPLIT_TX_HITS`] only the pixels
1491-// witness this path, so a gate that wants it needs the counter.
1492-thread_local! {
1493- pub(super) static SKIP_SPLIT_TX_OVERRIDE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1494- /// lane-av1chromadc: chroma units of a skipped block whose intra-BC /
1495- /// UV-palette override had to be WINDOWED to the unit's own extent --
1496- /// i.e. `cn_cols * cn_rows > 1`, which at 4:2:0 never happens (the chroma
1497- /// plane block is one 32x32 unit) and at 4:4:4 is every block of 64 and
1498- /// above. Counts UNITS, not blocks. EXCLUSIVE to this walk: the other two
1499- /// override sites (the luma slot and `decode_intrabc_owned_rect`) have
1500- /// their own windows.
1501- pub(super) static SKIP_CHROMA_OVERRIDE_WINDOW_HITS: std::cell::Cell<usize> =
1502- const { std::cell::Cell::new(0) };
1503-}
1504-
1505-/// Current value of [`SKIP_SPLIT_TX_OVERRIDE_HITS`] (blocks).
1506-pub fn skip_split_tx_override_hits() -> usize {
1507- SKIP_SPLIT_TX_OVERRIDE_HITS.with(|c| c.get())
1508-}
1509-
1510-/// lane-av1chromadc: [`SKIP_CHROMA_OVERRIDE_WINDOW_HITS`].
1511-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1512-pub fn skip_chroma_override_window_hits() -> usize {
1513- SKIP_CHROMA_OVERRIDE_WINDOW_HITS.with(|c| c.get())
1514-}
1515-
1516-/// Zeroes [`SKIP_CHROMA_OVERRIDE_WINDOW_HITS`] before a gate's own decode.
1517-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1518-pub fn reset_skip_chroma_override_window_hits() {
1519- SKIP_CHROMA_OVERRIDE_WINDOW_HITS.with(|c| c.set(0));
1520-}
1521-
1522-/// Zeroes [`SKIP_SPLIT_TX_OVERRIDE_HITS`] before a gate's own decode attempt.
1523-pub fn reset_skip_split_tx_override_hits() {
1524- SKIP_SPLIT_TX_OVERRIDE_HITS.with(|c| c.set(0));
1525-}
1526-
1527-// lane-svtinter: palette colour-index maps whose block is cut by the frame's
1528-// bottom/right mi edge, so spec 5.11.50's `onscreenWidth`/`onscreenHeight`
1529-// really are smaller than the block and FEWER symbols are read than the
1530-// block has cells (class map-read-past-frame-edge).
1531-thread_local! {
1532- pub(super) static PALETTE_ONSCREEN_CUT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1533-}
1534-
1535-/// Current value of [`PALETTE_ONSCREEN_CUT_HITS`] (colour-index maps).
1536-pub fn palette_onscreen_cut_hits() -> usize {
1537- PALETTE_ONSCREEN_CUT_HITS.with(|c| c.get())
1538-}
1539-
1540-/// Zeroes [`PALETTE_ONSCREEN_CUT_HITS`] before a gate's own decode attempt.
1541-pub fn reset_palette_onscreen_cut_hits() {
1542- PALETTE_ONSCREEN_CUT_HITS.with(|c| c.set(0));
1543-}
1544-
1545-/// Zeroes [`SKIP_SPLIT_TX_HITS`] before a gate's own decode attempt.
1546-pub fn reset_skip_split_tx_hits() {
1547- SKIP_SPLIT_TX_HITS.with(|c| c.set(0));
1548-}
1549-
1550-// lane-intrainter r1: intra blocks inside an INTER frame whose `tx_depth`
1551-// symbol split their luma transform, bucketed by block side (8, 16, 32, 64) --
1552-// the gate's proof that the lifted path actually ran, per size.
1553-thread_local! {
1554- pub(super) static INTRA_IN_INTER_SPLIT_TX_HITS: std::cell::Cell<[usize; 4]> =
1555- const { std::cell::Cell::new([0; 4]) };
1556-}
1557-
1558-/// Current value of [`INTRA_IN_INTER_SPLIT_TX_HITS`], indexed 8/16/32/64.
1559-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1560-pub(crate) fn intra_in_inter_split_tx_hits() -> [usize; 4] {
1561- INTRA_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get)
1562-}
1563-
1564-thread_local! {
1565- /// The current frame's `mi` grid, kept only while a frame header set
1566- /// `allow_intrabc` -- an intrabc block's DV predictor is the ordinary
1567- /// MV stack ([`crate::mvstack::find_mv_stack`]) built against
1568- /// `INTRA_FRAME`, which needs the neighbour state a key frame otherwise
1569- /// never keeps. `(grid, mi_cols, mi_rows)`; `None` on every frame that
1570- /// does not allow intrabc (so nothing is paid for it).
1571- ///
1572- /// corner-cut: only [`decode_block`] (the square path) records into it,
1573- /// so a frame mixing intrabc with rect/sub-8x8 leaves would predict off
1574- /// an incomplete grid. Ceiling: the DV *value* (never the parse) would
1575- /// be wrong there; upgrade = record from the rect/leaf paths too.
1576- /// The block vector [`read_intra_mode`] just decoded, handed to
1577- /// [`decode_block`] off the call stack (same idiom as [`PALETTE_PRED`],
1578- /// which the alternative -- a tenth tuple member through every caller --
1579- /// already avoids). Always `.take()`n by the block that reads it.
1580- /// How many blocks read `use_intrabc == 1` and took the DV path -- the
1581- /// gate's hit counter. Bumped on the READ, before the rect-strip refusal
1582- /// returns too, so it counts reads, not reconstructions (a refused block
1583- /// is never reconstructed).
1584- pub(super) static INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1585-}
1586-
1587-/// Zeroes [`RECT_INTRABC_READS`] (gate tests call this before a decode).
1588-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1589-pub(crate) fn reset_rect_intrabc_reads() {
1590- RECT_INTRABC_READS.with(|c| c.set(0));
1591-}
1592-
1593-thread_local! {
1594- /// Blocks that USED intrabc at an 8x8 LEAF (`decode_leaf8`) specifically
1595- /// -- the shape lane-kf900 r7 fixed; [`INTRABC_HITS`] counts every shape.
1596- pub(super) static LEAF8_INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1597-}
1598-
1599-thread_local! {
1600- /// Chroma reads of an intrabc TX4-split leaf that consulted an ARMED
1601- /// [`INTRABC_CHROMA_TX`] slot -- proof that the arm's frame-copy +
1602- /// inherited-type route actually ran (lane-av1intrapred r2's non-vacuity
1603- /// counter: zero means the gate's fixture no longer reaches the route).
1604- pub(super) static INTRABC_TX4_CHROMA_COPY_HITS: std::cell::Cell<usize> =
1605- const { std::cell::Cell::new(0) };
1606-}
1607-
1608-/// Current value of [`INTRABC_TX4_CHROMA_COPY_HITS`].
1609-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1610-pub(crate) fn intrabc_tx4_chroma_copy_hits() -> usize {
1611- INTRABC_TX4_CHROMA_COPY_HITS.with(|c| c.get())
1612-}
1613-
1614-/// Zeroes [`INTRABC_TX4_CHROMA_COPY_HITS`] (gate tests call this before a decode).
1615-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1616-pub(crate) fn reset_intrabc_tx4_chroma_copy_hits() {
1617- INTRABC_TX4_CHROMA_COPY_HITS.with(|c| c.set(0));
1618-}
1619-
1620-/// Current value of [`LEAF8_INTRABC_HITS`].
1621-pub(crate) fn leaf8_intrabc_hits() -> usize {
1622- LEAF8_INTRABC_HITS.with(|c| c.get())
1623-}
1624-
1625-/// Zeroes [`LEAF8_INTRABC_HITS`] (gate tests call this before a decode).
1626-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1627-pub(crate) fn reset_leaf8_intrabc_hits() {
1628- LEAF8_INTRABC_HITS.with(|c| c.set(0));
1629-}
1630-
1631-/// Current value of [`INTRABC_HITS`].
1632-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1633-pub(crate) fn intrabc_hits() -> usize {
1634- INTRABC_HITS.with(|c| c.get())
1635-}
1636-
1637-thread_local! {
1638- /// An intrabc block that IS a sub-8x8 group's CHROMA REFERENCE and is
1639- /// SKIPPED: the route that arms [`INTRABC_CHROMA_TX`] and then reads no
1640- /// chroma coefficient at all, so the slot used to stay armed into the NEXT
1641- /// block's chroma read. Both group shapes (4x4 split, 4x8/8x4 rect) count
1642- /// here. A non-zero value is what makes the disarm below load-bearing.
1643- pub(super) static SKIPPED_INTRABC_CHROMA_ARM_HITS: std::cell::Cell<usize> =
1644- const { std::cell::Cell::new(0) };
1645-}
1646-
1647-/// Current value of [`SKIPPED_INTRABC_CHROMA_ARM_HITS`].
1648-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates and the probe
1649-pub(crate) fn skipped_intrabc_chroma_arm_hits() -> usize {
1650- SKIPPED_INTRABC_CHROMA_ARM_HITS.with(|c| c.get())
1651-}
1652-
1653-/// Zeroes [`SKIPPED_INTRABC_CHROMA_ARM_HITS`] (gate tests call this before a
1654-/// decode).
1655-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1656-pub(crate) fn reset_skipped_intrabc_chroma_arm_hits() {
1657- SKIPPED_INTRABC_CHROMA_ARM_HITS.with(|c| c.set(0));
1658-}
1659-
1660-thread_local! {
1661- /// lane-av1-ibcskip2: a sub-8x8 4:4:4 leaf that is BOTH intrabc AND
1662- /// `skip` -- the arm whose chroma is the bare frame copy at the DV
1663- /// (libaom `av1_build_inter_predictors_sb` runs regardless of `skip`).
1664- /// Before the fix this route predicted intra-DC and every one of this
1665- /// fixture's 150 such cells differed from the oracle on both chroma
1666- /// planes.
1667- pub(super) static SKIPPED_INTRABC_DV_COPY_HITS: std::cell::Cell<usize> =
1668- const { std::cell::Cell::new(0) };
1669-}
1670-
1671-/// Current value of [`SKIPPED_INTRABC_DV_COPY_HITS`].
1672-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1673-pub(crate) fn skipped_intrabc_dv_copy_hits() -> usize {
1674- SKIPPED_INTRABC_DV_COPY_HITS.with(|c| c.get())
1675-}
1676-
1677-/// Zeroes [`SKIPPED_INTRABC_DV_COPY_HITS`] (gate tests call this before a
1678-/// decode).
1679-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1680-pub(crate) fn reset_skipped_intrabc_dv_copy_hits() {
1681- SKIPPED_INTRABC_DV_COPY_HITS.with(|c| c.set(0));
1682-}
1683-
1684-/// Zeroes [`INTRABC_HITS`] (gate tests call this before a decode).
1685-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1686-pub(crate) fn reset_intrabc_hits() {
1687- INTRABC_HITS.with(|c| c.set(0));
1688-}
1689-
1690-thread_local! {
1691- /// lane-t900 r32: intrabc blocks whose transform size came off the INTER
1692- /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability
1693- /// that replaced the refusal "an intrabc block under TxMode::Select".
1694- pub(super) static INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1695- /// lane-av1-ibcvtx: intrabc var-tx trees that resolved to MIXED leaf
1696- /// sizes (not one square size across every leaf) -- the engagement
1697- /// counter proving a witness actually exercises the per-leaf reconstruct.
1698- pub(super) static INTRABC_VARTX_MIXED_LEAVES_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1699- /// lane-av1txr: as above for a `BLOCK_4X8`/`BLOCK_8X4` intrabc leaf --
1700- /// libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`, so these leaves
1701- /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no
1702- /// symbol here desynced `warped.obu` at the very next block.
1703- pub(super) static RECT_INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1704- /// lane-av1-intrabc: rect INTRABC blocks whose reconstruction
1705- /// [`decode_intrabc_rect`] ran -- the engagement counter the rect-strip
1706- /// gates assert on (a refused block bumps [`INTRABC_HITS`] but never
1707- /// this one).
1708- pub(super) static INTRABC_RECT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1709- /// Of those, how many read the INTER var-tx tree (unskipped, TX_MODE_SELECT).
1710- pub(super) static INTRABC_RECT_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1711- /// lane-av1-intrabc r4: rect INTRABC blocks whose reconstruction
1712- /// [`decode_intrabc_rect`] ran with `skip == 0` (a real residual read),
1713- /// split by the strip's orientation -- `bw > bh` is a HORZ strip,
1714- /// `bh > bw` a VERT one. The reviewer's unblock condition needs a CODED
1715- /// witness in BOTH orientations, and the existing `INTRABC_RECT_HITS`
1716- /// counts neither orientation nor the skip flag, so an arm that flipped
1717- /// to an all-skip stream (no residual reader at all) would stay green.
1718- pub(super) static INTRABC_RECT_CODED_HITS: std::cell::Cell<[usize; 2]> =
1719- const { std::cell::Cell::new([0, 0]) };
1720- /// lane-av1-intrabc r5: the `skip == 1` twin of [`INTRABC_RECT_CODED_HITS`]
1721- /// -- rect INTRABC blocks reconstructed as a bare prediction copy, split
1722- /// by orientation. The r5 panic (residual stride `bw * bh` underrunning
1723- /// `reconstruct_mc_rect`'s `row * side + w` index on a VERT strip) was
1724- /// invisible to every gate because they only counted CODED strips.
1725- pub(super) static INTRABC_RECT_SKIPPED_HITS: std::cell::Cell<[usize; 2]> =
1726- const { std::cell::Cell::new([0, 0]) };
1727- /// lane-ibc444c: rect intra-BC blocks whose chroma plane block was sized
1728- /// `bw >> ss_x` by `bh >> ss_y` -- the 4:4:4 and 4:4:0 cells, where
1729- /// `av1_get_max_uv_txsize` (`ss_size_lookup[bsize]`, blockd.h) applies no
1730- /// halving of its own. At 4:2:0 this is the same arithmetic as the halving,
1731- /// so a `>= 1` witness can only come from a stream that is not 4:2:0.
1732- /// EXCLUSIVE to this arm: no other caller sizes an intrabc rect block's
1733- /// chroma plane block.
1734- pub(super) static IBC_RECT_CHROMA_FOOTPRINT_444_HITS: std::cell::Cell<usize> =
1735- const { std::cell::Cell::new(0) };
1736- /// lane-whtshape: LOSSLESS rect intrabc blocks whose chroma plane block
1737- /// [`decode_intrabc_rect`] walked as a `(cw/4) * (ch/4)` PLANE-MAJOR
1738- /// raster of TX_4X4 units -- the shape libaom's lossless geometry codes
1739- /// (`read_tx_size` returns `TX_4X4` for EVERY plane of a lossless block,
1740- /// `get_vartx_max_txsize` likewise, and `read_tx_mode` forced the frame's
1741- /// `ONLY_4X4`) -- instead of the single rect unit, which is what put a
1742- /// non-4x4 unit on the lossless Walsh-Hadamard path. EXCLUSIVE to this arm:
1743- /// no other caller walks a rect intrabc block's chroma, so `>= 1` cannot
1744- /// be satisfied by any older route.
1745- pub(super) static INTRABC_RECT_LOSSLESS_CHROMA4_HITS: std::cell::Cell<usize> =
1746- const { std::cell::Cell::new(0) };
1747- /// lane-av1chromarect: 128-root intra-BC HORZ/VERT strips
1748- /// ([`decode_intrabc_owned_rect`]) whose chroma plane block was sized
1749- /// `bw >> ss_x` by `bh >> ss_y` -- the 4:4:4 and 4:4:0 cells, where
1750- /// `av1_get_max_uv_txsize` (`ss_size_lookup[bsize]`, blockd.h:1372) applies
1751- /// no halving of its own. At 4:2:0 the two forms are the same arithmetic,
1752- /// so a `>= 1` witness can only come from a stream that is not 4:2:0.
1753- /// EXCLUSIVE to this arm: no other caller sizes a 128-root intra-BC
1754- /// strip's chroma plane block.
1755- pub(super) static IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS: std::cell::Cell<usize> =
1756- const { std::cell::Cell::new(0) };
1757- /// lane-av1422ibctxsel: `decode_intrabc_owned_rect`'s NON-SPLIT chroma
1758- /// gather taken through the 4:2:2 pair rule (`around_mi_422_chroma`)
1759- /// under the ss (1, 0) guard -- both residual branches (the var-tx tree
1760- /// and the no-leaves twin). `>= 1` can only come from a 4:2:2 stream
1761- /// that reaches this function's non-split chroma arm; the 4:2:0/4:4:4
1762- /// arms keep the plain `around_mi_rect` gather (`ss_y != 0` / `ss_x == 0`
1763- /// take the else), so the counter stays 0 for them.
1764- pub(super) static IBC_OWNED_RECT_422_PAIR_HITS: std::cell::Cell<usize> =
1765- const { std::cell::Cell::new(0) };
1766-}
1767-
1768-/// lane-av1-intrabc r4: coded (`skip == 0`) rect intrabc blocks reconstructed,
1769-/// as `[horz, vert]` -- see [`INTRABC_RECT_CODED_HITS`].
1770-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1771-pub fn intrabc_rect_coded_hits() -> [usize; 2] {
1772- INTRABC_RECT_CODED_HITS.with(std::cell::Cell::get)
1773-}
1774-
1775-/// lane-av1-intrabc r5: skipped (`skip == 1`) rect intrabc blocks
1776-/// reconstructed, as `[horz, vert]` -- see [`INTRABC_RECT_SKIPPED_HITS`].
1777-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1778-pub fn intrabc_rect_skipped_hits() -> [usize; 2] {
1779- INTRABC_RECT_SKIPPED_HITS.with(std::cell::Cell::get)
1780-}
1781-
1782-/// Current value of [`INTRABC_RECT_HITS`].
1783-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1784-pub fn intrabc_rect_hits() -> usize {
1785- INTRABC_RECT_HITS.with(|c| c.get())
1786-}
1787-
1788-/// Zeroes [`INTRABC_RECT_HITS`]/[`INTRABC_RECT_VARTX_HITS`].
1789-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1790-pub(crate) fn reset_intrabc_rect_hits() {
1791- INTRABC_RECT_HITS.with(|c| c.set(0));
1792- INTRABC_RECT_VARTX_HITS.with(|c| c.set(0));
1793- INTRABC_RECT_CODED_HITS.with(|c| c.set([0, 0]));
1794- INTRABC_RECT_SKIPPED_HITS.with(|c| c.set([0, 0]));
1795-}
1796-
1797-/// lane-ibc444c: [`IBC_RECT_CHROMA_FOOTPRINT_444_HITS`].
1798-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1799-pub fn ibc_rect_chroma_footprint_444_hits() -> usize {
1800- IBC_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.get())
1801-}
1802-
1803-/// lane-ibc444c: zeroes [`IBC_RECT_CHROMA_FOOTPRINT_444_HITS`].
1804-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1805-pub(crate) fn reset_ibc_rect_chroma_footprint_444_hits() {
1806- IBC_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.set(0));
1807-}
1808-
1809-/// lane-av1chromarect: [`IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS`].
1810-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1811-pub fn ibc_owned_rect_chroma_footprint_444_hits() -> usize {
1812- IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.get())
1813-}
1814-
1815-/// lane-av1chromarect: zeroes [`IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS`].
1816-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1817-pub(crate) fn reset_ibc_owned_rect_chroma_footprint_444_hits() {
1818- IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.set(0));
1819-}
1820-
1821-/// lane-av1422ibctxsel: [`IBC_OWNED_RECT_422_PAIR_HITS`].
1822-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1823-pub fn ibc_owned_rect_422_pair_hits() -> usize {
1824- IBC_OWNED_RECT_422_PAIR_HITS.with(|c| c.get())
1825-}
1826-
1827-/// lane-av1422ibctxsel: zeroes [`IBC_OWNED_RECT_422_PAIR_HITS`].
1828-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1829-pub(crate) fn reset_ibc_owned_rect_422_pair_hits() {
1830- IBC_OWNED_RECT_422_PAIR_HITS.with(|c| c.set(0));
1831-}
1832-
1833-/// lane-whtshape: [`INTRABC_RECT_LOSSLESS_CHROMA4_HITS`].
1834-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1835-pub fn intrabc_rect_lossless_chroma4_hits() -> usize {
1836- INTRABC_RECT_LOSSLESS_CHROMA4_HITS.with(|c| c.get())
1837-}
1838-
1839-/// lane-whtshape: zeroes [`INTRABC_RECT_LOSSLESS_CHROMA4_HITS`].
1840-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1841-pub(crate) fn reset_intrabc_rect_lossless_chroma4_hits() {
1842- INTRABC_RECT_LOSSLESS_CHROMA4_HITS.with(|c| c.set(0));
1843-}
1844-
1845-/// Current value of [`INTRABC_RECT_VARTX_HITS`].
1846-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1847-pub fn intrabc_rect_vartx_hits() -> usize {
1848- INTRABC_RECT_VARTX_HITS.with(|c| c.get())
1849-}
1850-
1851-thread_local! {
1852- /// lane-av1-ibcrect: `use_intrabc` blocks on a 128-root HORZ/VERT strip
1853- /// (BLOCK_128X64 / BLOCK_64X128) whose reconstruction
1854- /// [`decode_intrabc_128rect`] ran -- the shape the named refusal used to
1855- /// guard (`decode_block_128rect`). A refused block bumps
1856- /// [`INTRABC_HITS`] but never this one.
1857- pub(super) static INTRABC_128RECT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1858- /// lane-av1-ibc128chunk: chroma transform units the 128-root intrabc
1859- /// strip's mu-chunk walk read, one per `read_inter_plane` chroma call.
1860- /// At 4:2:0 a 64x64 mu chunk's chroma plane block is 32x32, so one
1861- /// TX_32X32 per plane per chunk; at 4:2:2 it is 32x64 and holds TWO
1862- /// STACKED units per plane. The square-cut `chunk_chroma = cside * 64 /
1863- /// side` model walked the 4:2:0 count on every axis, so this counter is
1864- /// the reach/arm witness for the per-axis walk.
1865- pub(super) static INTRABC_128RECT_CHROMA_CHUNK_HITS: std::cell::Cell<usize> =
1866- const { std::cell::Cell::new(0) };
1867-}
1868-
1869-/// Current value of [`INTRABC_128RECT_HITS`].
1870-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1871-pub fn intrabc_128rect_hits() -> usize {
1872- INTRABC_128RECT_HITS.with(|c| c.get())
1873-}
1874-
1875-/// Zeroes [`INTRABC_128RECT_HITS`].
1876-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1877-pub(crate) fn reset_intrabc_128rect_hits() {
1878- INTRABC_128RECT_HITS.with(|c| c.set(0));
1879-}
1880-
1881-/// Current value of [`INTRABC_128RECT_CHROMA_CHUNK_HITS`].
1882-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1883-pub fn intrabc_128rect_chroma_chunk_hits() -> usize {
1884- INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.get())
1885-}
1886-
1887-/// Zeroes [`INTRABC_128RECT_CHROMA_CHUNK_HITS`] and
1888-/// [`INTRABC_128RECT_CHUNK_SHAPE`].
1889-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1890-pub(crate) fn reset_intrabc_128rect_chroma_chunk_hits() {
1891- INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.set(0));
1892- INTRABC_128RECT_CHUNK_SHAPE.with(|c| c.set(0));
1893-}
1894-
1895-/// Current value of [`INTRABC_VARTX_HITS`].
1896-pub fn intrabc_vartx_hits() -> usize {
1897- INTRABC_VARTX_HITS.with(|c| c.get())
1898-}
1899-
1900-/// Current value of [`INTRABC_VARTX_MIXED_LEAVES_HITS`].
1901-pub fn intrabc_vartx_mixed_leaves_hits() -> usize {
1902- INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.get())
1903-}
1904-
1905-/// Zeroes [`INTRABC_VARTX_HITS`] (gate tests call this before a decode).
1906-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1907-pub(crate) fn reset_intrabc_vartx_hits() {
1908- INTRABC_VARTX_HITS.with(|c| c.set(0));
1909-}
1910-
1911-/// Zeroes [`INTRABC_VARTX_MIXED_LEAVES_HITS`] (gate tests call this before a
1912-/// decode).
1913-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1914-pub(crate) fn reset_intrabc_vartx_mixed_leaves_hits() {
1915- INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.set(0));
1916-}
1917-
1918-/// Current value of [`RECT_INTRABC_VARTX_HITS`].
1919-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1920-pub fn rect_intrabc_vartx_hits() -> usize {
1921- RECT_INTRABC_VARTX_HITS.with(|c| c.get())
1922-}
1923-
1924-// How many blocks decoded `skip_mode == 1` (lane-av1comp round 14) --
1925-// proves a real `skip_mode_present` stream actually reached a block that
1926-// picked it, not just that the frame header bit was set.
1927-thread_local! {
1928- pub(super) static SKIP_MODE_HITS: std::cell::Cell<usize> =
1929- const { std::cell::Cell::new(0) };
1930-}
1931-
1932-/// Current value of [`SKIP_MODE_HITS`].
1933-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1934-pub(crate) fn skip_mode_hits() -> usize {
1935- SKIP_MODE_HITS.with(|c| c.get())
1936-}
1937-
1938-// lane-motionmode: how many blocks actually decoded `obmc_selected == true`
1939-// (as opposed to just reaching an eligible `read_motion_mode` symbol read)
1940-// -- the gate's own proof that a real aomenc `--enable-obmc=1` stream
1941-// reached [`obmc_blend`], not just the header bit.
1942-thread_local! {
1943- pub(super) static OBMC_HITS: std::cell::Cell<usize> =
1944- const { std::cell::Cell::new(0) };
1945-}
1946-
1947-// lane-fimv r1 (class wrong-alphabet-same-value): how many blocks took the
1948-// 2-symbol `obmc_cdf` alphabet *because* `force_integer_mv` (or a scaled
1949-// reference) vetoed `WARPED_CAUSAL` in libaom `motion_mode_allowed`, while
1950-// `allow_warped_motion == 1` and `num_proj_ref >= 1` would otherwise have
1951-// picked the 3-symbol `motion_mode_cdf`. These are exactly the blocks this
1952-// decoder used to read with the wrong alphabet, so a gate that asserts this
1953-// counter advanced proves the fixed path fired (class
1954-// `gate-blind-to-feature`).
1955-thread_local! {
1956- pub(super) static FIMV_ALPHABET_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1957-}
1958-
1959-/// Current value of [`FIMV_ALPHABET_HITS`].
1960-pub fn fimv_alphabet_hits() -> usize {
1961- FIMV_ALPHABET_HITS.with(|c| c.get())
1962-}
1963-
1964-// lane-fimv r1: how many frame headers this decoder has decoded with
1965-// `force_integer_mv == 1` (bumped by `stream.rs` per frame). Lets a gate
1966-// prove the encoder really produced the header state under test rather than
1967-// assume it.
1968-thread_local! {
1969- pub(super) static FIMV_FRAME_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1970-}
1971-
1972-/// Current value of [`FIMV_FRAME_HITS`].
1973-pub fn fimv_frame_hits() -> usize {
1974- FIMV_FRAME_HITS.with(|c| c.get())
1975-}
1976-
1977-/// Current value of [`OBMC_HITS`].
1978-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1979-pub(crate) fn obmc_hits() -> usize {
1980- OBMC_HITS.with(|c| c.get())
1981-}
1982-
1983-// lane-scaledref r1: per-case firing counts for the scaled-reference gate
1984-// (class `gate-blind-to-feature`) -- a pixel match under an UNSCALED
1985-// reference would pass just as well and prove nothing, so the gate
1986-// hard-asserts each combination this round lifts actually occurred:
1987-// a compound block with a scaled tap, a warp block whose warp libaom
1988-// suppresses because the reference is scaled, an OBMC block, an interintra
1989-// block, and an 8x8 leaf.
1990-thread_local! {
1991- pub(super) static SCALED_COMPOUND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1992- pub(super) static SCALED_WARP_FALLBACK_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1993- pub(super) static SCALED_OBMC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1994- pub(super) static SCALED_INTERINTRA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1995- pub(super) static SCALED_BLOCK8_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1996- pub(super) static SCALED_WARP_SUPPRESSED_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1997- pub(super) static MIXED_SCALE_COMPOUND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1998-}
1999-
2000-/// Current value of [`MIXED_SCALE_COMPOUND_HITS`]: compound blocks with one
crates/ec-av1/src/decode/frame_tile.rsmodified+0 -84
@@ -582,7 +582,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
582582 mi_row1 as usize,
583583 mi_col1 as usize,
584584 );
585- hit!(TILE_HITS);
586585
587586 // lane-sb128 r2: at `sb_size == 128` the tile walks each 128x128
588587 // superblock's four 64x64 quadrants in libaom `decode_partition` order
@@ -985,9 +984,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
985984 bh
986985 );
987986 if horz {
988- hit!(INTER_SB128_HORZ_HITS);
989987 } else {
990- hit!(INTER_SB128_VERT_HITS);
991988 }
992989 }
993990 // One `cdef_idx` per BLOCK, copied to every 64x64 CDEF unit it
@@ -1022,7 +1019,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
10221019 continue;
10231020 }
10241021 if sb128_none {
1025- hit!(INTER_SB128_NONE_HITS);
10261022 let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4);
10271023 // lane-sb128c r3: `at128` is in SUB16 units like `sb_at`;
10281024 // `decode_inter_block` takes MI. Unconverted it was (0,0) for
@@ -1155,16 +1151,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
11551151 // see it.
11561152 refuse_invalid_subsize((64, 64), part64, fctx)?;
11571153 if part64 == PARTITION_NONE {
1158- // lane-inter8 r1: the whole superblock as one 64x64 inter
1159- // block. `SB`-sized syntax throughout (size_group 3, same as
1160- // 32x32 -- `size_group_lookup[BLOCK_64X64] == 3`), luma
1161- // coefficients through `TxbSet::Luma64` with the 32-point
1162- // scan (TX_64X64 codes only its top-left corner, spec
1163- // 5.11.40 -- `read_inter_plane` widens the corner back to
1164- // 64x64 before the inverse transform), chroma as a plain
1165- // 32x32 `TxbSet::Chroma32`. TX_64X64 carries no `tx_type`
1166- // symbol at all, so the intra/inter luma sets coincide.
1167- hit!(INTER_SB_NONE_HITS);
11681154 decode_inter_block(
11691155 &mut dec,
11701156 &mut cdfs,
@@ -1284,35 +1270,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
12841270 if !four && i == 0 && ((horz && !has_rows) || (!horz && !has_cols)) {
12851271 bump_inter_edge_strip(if horz { 0 } else { 1 });
12861272 }
1287- match (horz, four) {
1288- (true, false) => hit!(INTER_SB_HORZ_HITS),
1289- (false, false) => hit!(INTER_SB_VERT_HITS),
1290- (true, true) => hit!(INTER_SB_HORZ4_HITS),
1291- (false, true) => hit!(INTER_SB_VERT4_HITS),
1292- }
12931273 }
12941274 continue;
12951275 }
12961276 if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part64) {
1297- // lane-sbab r1: the four superblock-level AB arms on the
1298- // INTER path -- two 32x32 inter squares plus one true
1299- // 64x32/32x64 inter strip, in libaom `decode_partition`'s own
1300- // order (decodeframe.c: HORZ_A = TL, TR, bottom strip;
1301- // HORZ_B = top strip, BL, BR; VERT_A = TL, BL, right strip;
1302- // VERT_B = left strip, TR, BR). Every piece is one this
1303- // decoder already proves elsewhere: the 32x32 square is the
1304- // `PARTITION_NONE`-under-SPLIT block below, the strip is the
1305- // `PARTITION_HORZ`/`VERT` piece above (`inter_piece!`, which
1306- // keeps `side = SB` for syntax/CDF and names its true
1307- // footprint through `write_w`/`write_h`). The intra-frame
1308- // twin of this arm is lane-part32 r4's `SB_AB_HITS` block.
1309- hit_do! {
1310- SB_AB_INTER_HITS.with(|c| {
1311- let mut h = c.get();
1312- h[part64 - PARTITION_HORZ_A] += 1;
1313- c.set(h);
1314- });
1315- }
13161277 // lane-part32 r5 / class visit-order-changes-availability:
13171278 // only the two VERTICAL arms visit TL, BL, TR, BR, so only
13181279 // they switch libaom's `has_tr`/`has_bl` tables.
@@ -1749,9 +1710,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17491710 // covers 16x8/8x16 since this round).
17501711 let horz = part16 == PARTITION_HORZ;
17511712 if horz {
1752- hit!(INTER_LEAF16_HORZ_HITS);
17531713 } else {
1754- hit!(INTER_LEAF16_VERT_HITS);
17551714 }
17561715 let base_mi = sub16_to_mi(at16);
17571716 let (ww, wh) = if horz { (16, 8) } else { (8, 16) };
@@ -2035,9 +1994,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
20351994 bh
20361995 );
20371996 if horz {
2038- hit!(INTER16_HORZ4_HITS);
20391997 } else {
2040- hit!(INTER16_VERT4_HITS);
20411998 }
20421999 }
20432000 } else if part16 != PARTITION_SPLIT {
@@ -2045,9 +2002,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
20452002 "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4",
20462003 ));
20472004 } else {
2048- if has_cols16 && has_rows16 {
2049- hit!(INTER_SUB16_SPLIT_HITS);
2050- }
20512005 let (mi_row0, mi_col0) =
20522006 (sr as u32 * SUB_MI, sc as u32 * SUB_MI);
20532007 let leaf_positions: Vec<(u32, u32)> = (0..4)
@@ -2066,7 +2020,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
20662020 .dims(rf)
20672021 .is_some_and(|(w, _)| w != frame_width as usize)
20682022 }) {
2069- hit!(SCALED_LEAF8_HITS);
20702023 }
20712024 let mut prev_leaves: Vec<(
20722025 (usize, usize),
@@ -2281,19 +2234,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
22812234 }
22822235 }
22832236 PARTITION_HORZ_B => {
2284- // lane-warp r5: PARTITION_HORZ_B = 32x32 top strip +
2285- // 16x16 bottom-left + 16x16 bottom-right. aomenc
2286- // carves static regions into it; the strip is
2287- // decoded as a square 32x32 block: for a `skip`
2288- // block the symbol stream is identical to the true
2289- // 32x16 coding (no residual, no motion_mode/warp
2290- // symbol), and the square stamps it leaves over the
2291- // bottom half (neighbour arrays, skip/lf grids) are
2292- // re-stamped by the C/D leaves right after. The
2293- // mi-granular `left_side_mi` rows of a last-block-in-
2294- // tile strip leak 32-vs-16 only until the per-tile
2295- // `Neighbours::new` reset.
2296- hit!(EXTENDED_PARTITION_HITS);
22972237 let at32 = at;
22982238 decode_inter_block(
22992239 &mut dec,
@@ -2453,13 +2393,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
24532393 }
24542394 }
24552395 PARTITION_HORZ => {
2456- // lane-rect r2: two true 32x16 strips. Both read at
2457- // `side=BLOCK` (CDF/size-class selection stays square,
2458- // matching HORZ_B's accepted corner-cut) but bw4/bh4
2459- // (mvstack.rs, `motion_mode_eligible`) now derive from
2460- // `write_w`/`write_h`'s true 32x16 footprint -- the
2461- // pin's fix (r1's finding).
2462- hit!(RECT_PARTITION_HITS);
24632396 decode_inter_block(
24642397 &mut dec,
24652398 &mut cdfs,
@@ -2566,9 +2499,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
25662499 }
25672500 }
25682501 PARTITION_VERT => {
2569- // lane-rect r2: mirror of PARTITION_HORZ above with
2570- // width/height swapped.
2571- hit!(RECT_PARTITION_HITS);
25722502 decode_inter_block(
25732503 &mut dec,
25742504 &mut cdfs,
@@ -2675,10 +2605,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
26752605 }
26762606 }
26772607 PARTITION_HORZ_A => {
2678- // lane-partab r1: two 16x16 squares on top + a true
2679- // 32x16 strip below (libaom decode_partition
2680- // PARTITION_HORZ_A: TL, TR, bottom strip).
2681- hit!(PARTAB_HITS);
26822608 decode_inter_block(
26832609 &mut dec,
26842610 &mut cdfs,
@@ -2830,9 +2756,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
28302756 )?;
28312757 }
28322758 PARTITION_VERT_A => {
2833- // lane-partab r1: mirror of PARTITION_HORZ_A with
2834- // width/height swapped (TL, BL, right 16x32 strip).
2835- hit!(PARTAB_HITS);
28362759 let _vert_ab = crate::encode::Reach::vert_ab_partition();
28372760 decode_inter_block(
28382761 &mut dec,
@@ -2985,10 +2908,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
29852908 )?;
29862909 }
29872910 PARTITION_VERT_B => {
2988- // lane-partab r1: true 16x32 strip on the left + two
2989- // 16x16 squares on the right (libaom decode_partition
2990- // PARTITION_VERT_B: left strip, TR, BR).
2991- hit!(PARTAB_HITS);
29922911 let _vert_ab = crate::encode::Reach::vert_ab_partition();
29932912 decode_inter_block(
29942913 &mut dec,
@@ -3177,9 +3096,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
31773096 bh
31783097 );
31793098 if horz {
3180- hit!(RECT4_32_HORZ_INTER_HITS);
31813099 } else {
3182- hit!(RECT4_32_VERT_INTER_HITS);
31833100 }
31843101 }
31853102 }
@@ -3237,7 +3154,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
32373154 PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst)
32383155 );
32393156 }
3240- census_unwritten(&y, &u, &v);
32413157 // lane-av1fwd: the encoder scores ~25 filter candidates against this
32423158 // same coded tile ([`FilterReplay`]). Capture the reconstruction here,
32433159 // before either filter has touched it -- but only on the shape whose
crates/ec-av1/src/decode/inter_block.rsmodified+0 -125
@@ -135,7 +135,6 @@ pub(super) fn decode_inter_block(
135135 // exactly what it read before.
136136 let (rmi, cmi) = at;
137137 let (px, py) = (at.1 * MI, at.0 * MI);
138- census_inter_block_shape(side, write_w, write_h);
139138 // lane-inter16ab r2: a 16x4 / 4x16 inter strip's chroma is the PAIR's
140139 // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd
141140 // strip (`is_chroma_reference`); every other block keeps its own.
@@ -276,9 +275,6 @@ pub(super) fn decode_inter_block(
276275 dec.debug_bitpos()
277276 );
278277 }
279- if skip_mode {
280- hit!(SKIP_MODE_HITS);
281- }
282278
283279 let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]);
284280 let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;
@@ -526,9 +522,6 @@ pub(super) fn decode_inter_block(
526522 // `AOMMIN(mi_size_wide, mi_size_high) < 2` before it looks at any
527523 // model, so a 4-px-sided block still reads its interp filter.
528524 let gm_nontrans = gm_nontrans_models && bw4.min(bh4) >= 2;
529- if gm_nontrans_models && !gm_nontrans {
530- hit!(GM_NONTRANS_SMALL_SIDE_HITS);
531- }
532525 // lane-defer8: both slots' pictures are resolved inside the
533526 // prediction closure; the parse only needs their SIZES.
534527 // lane-cwarp r1: `is_global_mv_block` (blockd.h:421-429) is
@@ -553,10 +546,8 @@ pub(super) fn decode_inter_block(
553546 // engagement figure.
554547 if mi_row < mi_rows as usize / 2 {
555548 if is_globalmv {
556- TOP_HALF_COMPOUND_HITS.with(|c| c.set(c.get() + 1));
557549 }
558550 if is_global_mv0 || is_global_mv1 {
559- TOP_HALF_WARP_HITS.with(|c| c.set(c.get() + 1));
560551 }
561552 }
562553 // libaom `av1_init_warp_params` + `allow_warp`'s
@@ -595,7 +586,6 @@ pub(super) fn decode_inter_block(
595586 let warp0 = compound_warp(ref0, is_global_mv0).filter(|_| ref_unscaled(ref0));
596587 let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1));
597588 if warp0.is_some() || warp1.is_some() {
598- hit!(COMPOUND_WARP_HITS);
599589 // lane-av112bitw: the 12-bit refusal that stood here is
600590 // LIFTED with the compound-warp witness: the rotating-
601591 // mandelbrot 12-bit recipe refused exactly here pre-lift and
@@ -714,16 +704,6 @@ pub(super) fn decode_inter_block(
714704 // verified vs independent C dump (wedge.rs).
715705 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]);
716706 let wedge_sign = dec.literal(1);
717- hit!(WEDGE_HITS);
718- if let Some(k) = rect_wedge_slot(write_w, write_h) {
719- hit_do! {
720- RECT_WEDGE_HITS.with(|c| {
721- let mut a = c.get();
722- a[k] += 1;
723- c.set(a);
724- });
725- }
726- }
727707 // lane-inter16ab r5: the codebook row is this block's TRUE
728708 // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for
729709 // h>w, hltw for h<w, plus that bsize's own signflip row).
@@ -740,13 +720,6 @@ pub(super) fn decode_inter_block(
740720 // COMPOUND_DIFFWTD: `mask_type`, MAX_DIFFWTD_MASK_BITS==1.
741721 let mask_type = dec.literal(1);
742722 diffwtd_mask_type = Some(mask_type as u8);
743- if wedge_bsize.is_none() {
744- hit!(DIFFWTD_INFERRED_HITS);
745- }
746- }
747- hit!(MASKED_COMPOUND_HITS);
748- if write_w != write_h {
749- hit!(RECT_MASKED_COMPOUND_HITS);
750723 }
751724 }
752725 // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): r16/r17
@@ -970,10 +943,6 @@ pub(super) fn decode_inter_block(
970943 if idx == 1 {
971944 (8, 8, 1u8)
972945 } else {
973- // lane-av1distwtd: `idx == 0` is the
974- // distance-weighted arm -- the only branch whose
975- // weights are NOT the constant (8, 8) split.
976- hit!(DIST_WTD_COMP_HITS);
977946 let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign(
978947 order_hint_bits,
979948 order_hint,
@@ -1028,15 +997,9 @@ pub(super) fn decode_inter_block(
1028997 // stride-1 one, so the unscaled case is unchanged.
1029998 let scale0 = scale_of(ref_dims(ref0, refpix)?, frame_size);
1030999 let scale1 = scale_of(ref_dims(ref1, refpix)?, frame_size);
1031- if !scale0.is_unscaled() || !scale1.is_unscaled() {
1032- hit!(SCALED_COMPOUND_HITS);
1033- }
10341000 // lane-scaledref r2: the MIXED case -- one tap scaled, the other
10351001 // not -- is the one an all-frames-scaled recipe never produces,
10361002 // and the one a single shared scale factor would get wrong.
1037- if (scale0.is_unscaled()) != (scale1.is_unscaled()) {
1038- hit!(MIXED_SCALE_COMPOUND_HITS);
1039- }
10401003
10411004 // lane-wave4 (the compound arm's half): this block's whole
10421005 // prediction -- both references, the wedge/diffwtd/distance
@@ -1148,7 +1111,6 @@ pub(super) fn decode_inter_block(
11481111 // either way, only the mask source differs.
11491112 let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type {
11501113 diffwtd_mask_y = vec![0u8; side * side];
1151- hit!(DIFFWTD_HITS);
11521114 mc::diffwtd_mask(
11531115 &inter0_y,
11541116 &inter1_y,
@@ -1597,14 +1559,6 @@ pub(super) fn decode_inter_block(
15971559 fctx,
15981560 )?
15991561 } else {
1600- // lane-r14 r3: a 1:4 strip's `sub_tx_size_map`
1601- // sub-transform is RECTANGULAR (TX_64X16 ->
1602- // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is
1603- // read with the rect coefficient machinery, at its
1604- // own `txb_skip_ctx`/neighbour spans -- the unit is
1605- // smaller than its block, so `get_txb_ctx_general`'s
1606- // neighbour table applies, not the lone-TU 0.
1607- vartx_rect_leaf_hit(tw, th);
16081562 let tu_skip_ctx =
16091563 neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI);
16101564 let start = row * MI * side + col * MI;
@@ -1852,7 +1806,6 @@ pub(super) fn decode_inter_block(
18521806 plane_idx,
18531807 &cu_grid,
18541808 );
1855- hit!(CHROMA_SPLIT_TX_HITS);
18561809 mu_chroma = true;
18571810 // lane-av1muchunk422b: the allocation of this
18581811 // mu-chunk walk, counted per TX_32X32 UNIT.
@@ -1861,9 +1814,6 @@ pub(super) fn decode_inter_block(
18611814 // bump: `MU_CHUNK_COMPOUND_UNITS` names site 2
18621815 // and the single-reference twin (site 5) stays
18631816 // out of it.
1864- if is_compound {
1865- hit!(MU_CHUNK_COMPOUND_UNITS);
1866- }
18671817 let dst = mu_units(
18681818 if plane_idx == 1 {
18691819 &mut u_units
@@ -2068,12 +2018,6 @@ pub(super) fn decode_inter_block(
20682018 let cu_rel_mi = (cr * (cu_tx / MI), cc * (cu_tx / MI));
20692019 let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi)
20702020 .unwrap_or(luma_tx_type);
2071- if covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi).is_some() {
2072- hit!(CHROMA_QUAD_LEAF_TX_HITS);
2073- if cu_tx_type != luma_tx_type {
2074- hit!(CHROMA_QUAD_LEAF_TX_DIFF_HITS);
2075- }
2076- }
20772021 let cu_grid = read_inter_plane(
20782022 dec,
20792023 cdfs,
@@ -2099,7 +2043,6 @@ pub(super) fn decode_inter_block(
20992043 // this one's coefficients.
21002044 neighbours
21012045 .record_mi_chroma(cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid);
2102- hit!(CHROMA_SPLIT_TX_HITS);
21032046 // lane-av1-444 c8: the unit's levels must ALSO
21042047 // land in the block grid -- the block-tail mu
21052048 // re-stamp slices the per-unit states back out
@@ -2245,8 +2188,6 @@ pub(super) fn decode_inter_block(
22452188 tpl,
22462189 );
22472190 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
2248- if !not_new {
2249- }
22502191 let mut is_globalmv = false;
22512192 // lane-interbis r1: which single-ref mode this block resolved to,
22522193 // in the oracle's own numbering (NEARESTMV=13 .. NEWMV=16), for
@@ -2281,8 +2222,6 @@ pub(super) fn decode_inter_block(
22812222 )
22822223 } else {
22832224 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
2284- if !not_zero {
2285- }
22862225 is_globalmv = !not_zero;
22872226 let mv = if !not_zero {
22882227 // GLOBALMV: `gm_get_motion_vector` (spec 7.10.2.1), already
@@ -2398,16 +2337,6 @@ pub(super) fn decode_inter_block(
23982337 // NO sign symbol follows -- libaom fixes
23992338 // INTERINTRA_WEDGE_SIGN 0 (blockd.h).
24002339 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]);
2401- hit!(WII_HITS);
2402- if let Some(k) = rect_wedge_slot(write_w, write_h) {
2403- hit_do! {
2404- RECT_WII_HITS.with(|c| {
2405- let mut a = c.get();
2406- a[k] += 1;
2407- c.set(a);
2408- });
2409- }
2410- }
24112340 // lane-inter16ab r5: true-footprint codebook row,
24122341 // mask padded to stride `max(bw,bh) == side` -- see
24132342 // the compound site's own comment.
@@ -2418,7 +2347,6 @@ pub(super) fn decode_inter_block(
24182347 side,
24192348 ));
24202349 } else {
2421- hit!(INTERINTRA_HITS);
24222350 }
24232351 interintra_mode = Some(ii);
24242352 // The inter-intra predictor reads this block's neighbours as already
@@ -2556,12 +2484,6 @@ pub(super) fn decode_inter_block(
25562484 ) >= 1;
25572485 let warp_eligible =
25582486 allow_warped_motion && !ref_is_scaled && !force_integer_mv && proj_ok;
2559- if allow_warped_motion && proj_ok && ref_is_scaled {
2560- hit!(SCALED_WARP_SUPPRESSED_HITS);
2561- }
2562- if allow_warped_motion && proj_ok && !ref_is_scaled && force_integer_mv {
2563- hit!(FIMV_ALPHABET_HITS);
2564- }
25652487 if warp_eligible {
25662488 crate::msac::SymbolDecoder::set_symr_cdf("motion_mode");
25672489 let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]);
@@ -2569,11 +2491,9 @@ pub(super) fn decode_inter_block(
25692491 0 => {}
25702492 1 => {
25712493 obmc_selected = true;
2572- hit!(OBMC_HITS);
25732494 }
25742495 _ => {
25752496 warped_selected = true;
2576- hit!(WARP_SELECTED_HITS);
25772497 let mut samples = find_samples(
25782498 grid,
25792499 mi_row,
@@ -2636,9 +2556,6 @@ pub(super) fn decode_inter_block(
26362556 }
26372557 } else {
26382558 obmc_selected = dec.symbol(&mut cdfs.obmc[bsize_idx]) == 1;
2639- if obmc_selected {
2640- hit!(OBMC_HITS);
2641- }
26422559 }
26432560 // lane-t900 r9: which ALPHABET this block read (3-symbol
26442561 // motion_mode vs 2-symbol obmc) and the range after -- the
@@ -2676,15 +2593,9 @@ pub(super) fn decode_inter_block(
26762593 let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];
26772594 if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid {
26782595 warp_params = crate::warp::global_warp_params(gm_ref.params);
2679- if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine {
2680- hit!(AFFINE_GM_HITS);
2681- }
26822596 // lane-av1gwarp12: the ROTZOOM sibling -- the only
26832597 // >TRANSLATION model vanilla aomenc can emit for a single-ref
26842598 // global-motion block (encoder search pinned to ROTZOOM).
2685- if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Rotzoom {
2686- hit!(ROTZOOM_GM_WARP_HITS);
2687- }
26882599 }
26892600 // lane-av112bitw: a local `WARPED_CAUSAL` projection (set above)
26902601 // or a global warp model both land here with `warp_params` set --
@@ -2810,15 +2721,6 @@ pub(super) fn decode_inter_block(
28102721 // measured was the 16x4/4x16 strip's sub-8x8 chroma piece,
28112722 // which this file used to SKIP under a scaled reference
28122723 // (fixed in the same commit), not the warp fallback.
2813- if warp_params.is_some() {
2814- hit!(SCALED_WARP_FALLBACK_HITS);
2815- }
2816- if obmc_selected {
2817- hit!(SCALED_OBMC_HITS);
2818- }
2819- if interintra_mode.is_some() {
2820- hit!(SCALED_INTERINTRA_HITS);
2821- }
28222724 }
28232725
28242726 // lane-inter16ab r2: `is_sub8x8_inter`'s neighbour walk reads the
@@ -2835,7 +2737,6 @@ pub(super) fn decode_inter_block(
28352737 {
28362738 Some((horz, (prev_ref, prev_mv, prev_h, prev_v))) => {
28372739 let prev_dims = ref_dims(prev_ref, refpix)?;
2838- hit!(INTER16_SUB8_PIECE_HITS);
28392740 Some((
28402741 horz,
28412742 prev_ref,
@@ -3075,9 +2976,6 @@ pub(super) fn decode_inter_block(
30752976 // result, all planes (reconinter.c av1_build_interintra_predictor
30762977 // plane loop).
30772978 if let Some(ii) = interintra_mode {
3078- if write_w != write_h {
3079- hit!(INTERINTRA_RECT_HITS);
3080- }
30812979 interintra_blend(
30822980 y,
30832981 px,
@@ -3344,7 +3242,6 @@ pub(super) fn decode_inter_block(
33443242 // gate can prove it exercised this route (a 4:2:0 stream
33453243 // of the same content reads 0).
33463244 Some(_) if ss_x(fctx) == 0 => {
3347- hit!(RECT4_INTER_OWN_CHROMA444_HITS);
33483245 around
33493246 }
33503247 Some(s) if s.has_chroma => {
@@ -3425,14 +3322,6 @@ pub(super) fn decode_inter_block(
34253322 fctx,
34263323 )?
34273324 } else {
3428- // lane-r14 r3: a 1:4 strip's `sub_tx_size_map`
3429- // sub-transform is RECTANGULAR (TX_64X16 ->
3430- // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is
3431- // read with the rect coefficient machinery, at its
3432- // own `txb_skip_ctx`/neighbour spans -- the unit is
3433- // smaller than its block, so `get_txb_ctx_general`'s
3434- // neighbour table applies, not the lone-TU 0.
3435- vartx_rect_leaf_hit(tw, th);
34363325 let tu_skip_ctx =
34373326 neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI);
34383327 let start = row * MI * side + col * MI;
@@ -3666,7 +3555,6 @@ pub(super) fn decode_inter_block(
36663555 plane_idx,
36673556 &cu_grid,
36683557 );
3669- hit!(CHROMA_SPLIT_TX_HITS);
36703558 mu_chroma = true;
36713559 // lane-av1muchunk422b: the allocation of this
36723560 // mu-chunk walk, counted per TX_32X32 UNIT.
@@ -3675,9 +3563,6 @@ pub(super) fn decode_inter_block(
36753563 // bump: `MU_CHUNK_COMPOUND_UNITS` names site 2
36763564 // and the single-reference twin (site 5) stays
36773565 // out of it.
3678- if is_compound {
3679- hit!(MU_CHUNK_COMPOUND_UNITS);
3680- }
36813566 let dst = mu_units(
36823567 if plane_idx == 1 {
36833568 &mut u_units
@@ -3898,16 +3783,10 @@ pub(super) fn decode_inter_block(
38983783 let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi)
38993784 .unwrap_or(luma_tx_type);
39003785 if covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi).is_some() {
3901- hit!(CHROMA_QUAD_LEAF_TX_HITS);
3902- hit!(CHROMA_QUAD_LEAF_TX_SINGLEREF_HITS);
39033786 // lane-av1f9singleland: this arm's own
39043787 // non-vacuity number -- the shared
39053788 // DIFFERS counter below cannot say which
39063789 // arm changed an answer.
3907- if cu_tx_type != luma_tx_type {
3908- hit!(CHROMA_QUAD_LEAF_TX_DIFF_HITS);
3909- hit!(CHROMA_QUAD_LEAF_TX_SINGLEREF_DIFF_HITS);
3910- }
39113790 }
39123791 let cu_grid = read_inter_plane(
39133792 dec,
@@ -3934,7 +3813,6 @@ pub(super) fn decode_inter_block(
39343813 // this one's coefficients.
39353814 neighbours
39363815 .record_mi_chroma(cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid);
3937- hit!(CHROMA_SPLIT_TX_HITS);
39383816 // lane-av1-444 c8: the unit's levels must ALSO
39393817 // land in the block grid -- the block-tail mu
39403818 // re-stamp slices the per-unit states back out
@@ -4242,7 +4120,6 @@ pub(super) fn decode_inter_block(
42424120 palette_record.3,
42434121 );
42444122 let saved_chroma_ctx = (!has_chroma).then(|| {
4245- hit!(NON_CHROMA_REF_CTX_SKIP_HITS);
42464123 let (w_mi, h_mi) = (write_w / MI, write_h / MI);
42474124 let left: Vec<[Neighbour; 2]> = (0..h_mi)
42484125 .filter_map(|k| neighbours.left.get(at.0 + k).map(|s| [s[1], s[2]]))
@@ -4269,7 +4146,6 @@ pub(super) fn decode_inter_block(
42694146 // where aomdec reads 1, because the skipped 128x128 block at
42704147 // mi(32,32) never cleared `left[32..48]`.
42714148 if skip {
4272- hit!(SKIP_VARTX_LUMA_RESET_HITS);
42734149 neighbours.record_mi_luma_rect(at, write_w, write_h, &luma_grid);
42744150 }
42754151 // Plane 0 is already correct per transform unit
@@ -4366,7 +4242,6 @@ pub(super) fn decode_inter_block(
43664242 }
43674243 }
43684244 neighbours.record_uv_mode_mi(s.pair_mi.0, s.pair_mi.1, pw / MI, ph / MI, uv_predict_mode);
4369- hit!(INTER16_CHROMA_PAIR_HITS);
43704245 }
43714246 // lane-av1-444 c8: each unit stamps its OWN span (32 << ss px at
43724247 // TX_32X32, 8 px lossless) -- a 64x64 mu chunk at ss 0/0 holds four
crates/ec-av1/src/decode/inter_block8.rsmodified+0 -126
@@ -243,9 +243,6 @@ pub(super) fn decode_inter_block8(
243243 // leaf is always `BLOCK_8X8`, i.e. 2x2 mi.
244244 inter_segment_id(dec, cdfs, leaf_mi.0, leaf_mi.1, 2, 2, false, true, fctx);
245245 let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
246- if skip_mode {
247- hit!(SKIP_MODE_HITS);
248- }
249246
250247 let skip_ctx = usize::from(above_skip) + usize::from(left_skip);
251248 let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;
@@ -454,7 +451,6 @@ pub(super) fn decode_inter_block8(
454451 // leaf's own comment.
455452 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[3]);
456453 let wedge_sign = dec.literal(1);
457- hit!(WEDGE_HITS);
458454 wedge_mask = Some(
459455 crate::wedge::wedge_masks()
460456 .codebook(SIDE, SIDE)
@@ -464,7 +460,6 @@ pub(super) fn decode_inter_block8(
464460 let mask_type = dec.literal(1);
465461 diffwtd_mask_type = Some(mask_type as u8);
466462 }
467- hit!(MASKED_COMPOUND_HITS);
468463 }
469464 // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): same
470465 // reference-slot defect as the 16x16 leaf's own mask above
@@ -495,10 +490,6 @@ pub(super) fn decode_inter_block8(
495490 if idx == 1 {
496491 (8, 8, 1u8)
497492 } else {
498- // lane-av1distwtd: the 8x8 leaf's own
499- // distance-weighted arm, same counter as the
500- // 16x16+ site above.
501- hit!(DIST_WTD_COMP_HITS);
502493 let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign(
503494 order_hint_bits,
504495 order_hint,
@@ -570,17 +561,10 @@ pub(super) fn decode_inter_block8(
570561 true,
571562 );
572563 leaf_filter_syms = resolved_filter;
573- if interp_fixed.is_none() && !(gm_nontrans_c || skip_mode) {
574- hit!(COMPOUND8_FILTER_HITS);
575- }
576564
577565 // lane-defer8: both slots' SIZES at parse, pictures in the closure.
578566 let scale0 = scale_of(ref_dims(ref0, refpix)?, frame_size);
579567 let scale1 = scale_of(ref_dims(ref1, refpix)?, frame_size);
580- if !scale0.is_unscaled() || !scale1.is_unscaled() {
581- hit!(SCALED_COMPOUND_HITS);
582- hit!(SCALED_BLOCK8_HITS);
583- }
584568
585569 // lane-interp3 r2 (class twin-functions-drift): both slots
586570 // used to be stamped `false`, while [`decode_inter_block`]'s
@@ -635,10 +619,6 @@ pub(super) fn decode_inter_block8(
635619 leaf_compound_warp(ref0, is_global_mv0_c).filter(|_| leaf_ref_unscaled(ref0));
636620 let warp1_c =
637621 leaf_compound_warp(ref1, is_global_mv1_c).filter(|_| leaf_ref_unscaled(ref1));
638- if warp0_c.is_some() || warp1_c.is_some() {
639- hit!(COMPOUND_WARP_HITS);
640- hit!(COMPOUND_WARP_HITS_8);
641- }
642622 grid.fill_rect(
643623 mi_row,
644624 mi_col,
@@ -745,7 +725,6 @@ pub(super) fn decode_inter_block8(
745725 let mut diffwtd_mask_y;
746726 let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type {
747727 diffwtd_mask_y = vec![0u8; SIDE * SIDE];
748- hit!(DIFFWTD_HITS);
749728 mc::diffwtd_mask(
750729 &inter0_y,
751730 &inter1_y,
@@ -1323,13 +1302,6 @@ pub(super) fn decode_inter_block8(
13231302 neighbours.above[leaf_mi.1 + cell][0] = state;
13241303 }
13251304 }
1326- // lane-cdef r1: ... and the CDEF skip band too. `apply_cdef`'s
1327- // `is_8x8_block_skip` (libaom `cdef.c:29-38`) reads all four mi
1328- // cells of the 8x8; this leaf wrote none of them, so a 64x64
1329- // whose bottom-right 16x16 is an all-skip 8x8-leaf group kept
1330- // the PREVIOUS frame's flags and got filtered where libaom's
1331- // dlist excludes it (3 luma samples on a 192x128 inter frame).
1332- hit!(INTER8_SKIP_BAND_HITS);
13331305 neighbours.fill_skip_grid(leaf_mi, 2, skip);
13341306 // lane-sub8x4 r2: `split8` is this leaf's OWN var-tx split, so
13351307 // the deblock grid must publish the TX_4X4 leaves' width the
@@ -1418,8 +1390,6 @@ pub(super) fn decode_inter_block8(
14181390 }
14191391
14201392 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
1421- if !not_new {
1422- }
14231393 let mut is_globalmv = false;
14241394 let (mv, is_new_mv) = if !not_new {
14251395 // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0):
@@ -1450,14 +1420,8 @@ pub(super) fn decode_inter_block8(
14501420 )
14511421 } else {
14521422 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
1453- if !not_zero {
1454- }
14551423 is_globalmv = !not_zero;
14561424 let mv = if !not_zero {
1457- // lane-gmaffine r1: GLOBALMV (spec 7.10.2.1) -- the same
1458- // `gm_get_motion_vector` value the 16x16+ leaf reads out of
1459- // its own `gm_table`, computed at this block's centre.
1460- hit!(GLOBALMV_HITS_8);
14611425 gm_table[(ref_frame - LAST_FRAME) as usize]
14621426 } else {
14631427 let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;
@@ -1496,7 +1460,6 @@ pub(super) fn decode_inter_block8(
14961460 // lane-wii r2: same adapting `wedge_index` symbol as the
14971461 // 16/32 leaf, fixed sign 0 -- see that site's comment.
14981462 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[3]);
1499- hit!(WII_HITS);
15001463 wedge_mask = Some((
15011464 crate::wedge::wedge_masks()
15021465 .codebook(SIDE, SIDE)
@@ -1504,7 +1467,6 @@ pub(super) fn decode_inter_block8(
15041467 SIDE,
15051468 ));
15061469 } else {
1507- hit!(INTERINTRA_HITS);
15081470 }
15091471 interintra_mode = Some(ii);
15101472 // The inter-intra predictor reads this block's neighbours as already
@@ -1587,12 +1549,6 @@ pub(super) fn decode_inter_block8(
15871549 proj_ok as u8, warp_eligible as u8, allow_warped_motion as u8
15881550 );
15891551 }
1590- if allow_warped_motion && proj_ok && ref_is_scaled {
1591- hit!(SCALED_WARP_SUPPRESSED_HITS);
1592- }
1593- if allow_warped_motion && proj_ok && !ref_is_scaled && force_integer_mv {
1594- hit!(FIMV_ALPHABET_HITS);
1595- }
15961552 if warp_eligible {
15971553 crate::msac::SymbolDecoder::set_symr_cdf("motion_mode");
15981554 let mode = dec.symbol(&mut cdfs.motion_mode[0]);
@@ -1600,19 +1556,8 @@ pub(super) fn decode_inter_block8(
16001556 0 => {}
16011557 1 => {
16021558 obmc_selected = true;
1603- hit!(OBMC_HITS);
1604- hit!(OBMC_HITS_8);
16051559 }
16061560 _ => {
1607- // lane-gmaffine r1: WARPED_CAUSAL at the 8x8 leaf --
1608- // the same findSamples -> select_samples ->
1609- // av1_find_projection chain the 16x16+ leaf runs,
1610- // with BLOCK_8X8's own 8x8 model centre; an
1611- // unusable projection falls back to the block's
1612- // translational mv (libaom `av1_find_projection`
1613- // returning 1 leaves `wm_params` invalid and
1614- // `build_inter_predictors` skips the warp).
1615- hit!(WARP_SELECTED_HITS);
16161561 let mut samples = find_samples(
16171562 grid,
16181563 mi_row,
@@ -1637,18 +1582,11 @@ pub(super) fn decode_inter_block8(
16371582 mi_col as i32,
16381583 );
16391584 warped_selected = true;
1640- if warp_params.is_some() {
1641- hit!(WARP_HITS_8);
1642- }
16431585 }
16441586 }
16451587 } else {
16461588 // `default_obmc_cdf`'s own index: square bsize 8/16/32/64 -> 0/1/2/3.
16471589 obmc_selected = dec.symbol(&mut cdfs.obmc[0]) == 1;
1648- if obmc_selected {
1649- hit!(OBMC_HITS);
1650- hit!(OBMC_HITS_8);
1651- }
16521590 }
16531591 }
16541592 // lane-gmaffine r1: `read_mb_interp_filter` (spec 5.11.26) at the 8x8
@@ -1710,9 +1648,6 @@ pub(super) fn decode_inter_block8(
17101648 // size predicate baked into `is_global_mv_block`.
17111649 if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid {
17121650 warp_params = crate::warp::global_warp_params(gm_ref.params);
1713- if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine {
1714- hit!(AFFINE_GM_HITS);
1715- }
17161651 }
17171652 // lane-av112bitw: same lift as the 16x16+ leaf -- a local
17181653 // `WARPED_CAUSAL` projection or a global model both leave
@@ -1757,9 +1692,6 @@ pub(super) fn decode_inter_block8(
17571692 // (documented corner-cut above); under a scaled reference the same
17581693 // fixed kernel runs through spec 7.11.3.3's scaled walk instead.
17591694 let luma_scale = scale_of((ref_width, ref_height), frame_size);
1760- if !luma_scale.is_unscaled() {
1761- hit!(SCALED_BLOCK8_HITS);
1762- }
17631695 let obmc = if obmc_selected {
17641696 Some(obmc_plan(
17651697 grid,
@@ -2211,19 +2143,6 @@ pub(super) fn decode_inter_block8(
22112143 } else {
22122144 0
22132145 };
2214- if angle_delta_y != 0 {
2215- hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS);
2216- // lane-leaf8tx r1: `av1_use_angle_delta(BLOCK_8X8)` is true
2217- // (`bsize >= BLOCK_8X8`), so this leaf codes `angle_delta_y` off
2218- // `angle_delta_cdf[mode - V_PRED]` exactly as a key-frame block
2219- // does (libaom `read_intra_angle_info` inside
2220- // `read_intra_block_mode_info`, decodemv.c), and the delta feeds
2221- // the directional predictor + the edge filter/upsample decision
2222- // through the same `reconstruct` argument below. Counted
2223- // separately from the >=16x16 arm so the gate cannot be satisfied
2224- // by a bigger block.
2225- hit!(INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS);
2226- }
22272146 // lane-uv8 r1: the delta'd angle decides the intra edge filter, and a
22282147 // directional luma mode is already legal on this leaf -- the arm
22292148 // passed a hardcoded `false` where [`decode_leaf8`] reads the
@@ -2268,27 +2187,16 @@ pub(super) fn decode_inter_block8(
22682187 dec.debug_state().0
22692188 );
22702189 }
2271- if (9..=12).contains(&uv_mode) {
2272- hit!(SMOOTH_UV_HITS);
2273- hit!(INTRA_IN_INTER8_UV_SMOOTH_HITS);
2274- }
22752190 let alpha = if has_chroma && uv_mode == UV_CFL_PRED {
2276- hit!(INTRA_IN_INTER8_UV_CFL_HITS);
22772191 Some(read_cfl_alphas(dec, cdfs))
22782192 } else {
22792193 None
22802194 };
22812195 let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {
2282- hit!(DIRECTIONAL_UV_HITS);
2283- hit!(INTRA_IN_INTER8_UV_DIR_HITS);
22842196 read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
22852197 } else {
22862198 0
22872199 };
2288- if angle_delta_uv != 0 {
2289- hit!(UV_ANGLE_DELTA_HITS);
2290- hit!(INTRA_IN_INTER_ANGLE_DELTA_UV_HITS);
2291- }
22922200 // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED`.
22932201 uv_predict_mode = if uv_mode == UV_CFL_PRED {
22942202 DC_PRED
@@ -2378,8 +2286,6 @@ pub(super) fn decode_inter_block8(
23782286 );
23792287 }
23802288 if use_fi {
2381- hit!(FILTER_INTRA_HITS);
2382- hit!(INTRA_IN_INTER_FILTER_INTRA_HITS);
23832289 let fi = dec.symbol(&mut cdfs.filter_intra_mode);
23842290 if ec_istep8 {
23852291 eprintln!(
@@ -2404,15 +2310,6 @@ pub(super) fn decode_inter_block8(
24042310 palette_onscreen(rmi, cmi, SIDE, SIDE, fctx),
24052311 false,
24062312 );
2407- hit!(PALETTE_HITS);
2408- hit!(INTRA_IN_INTER_PALETTE_Y_HITS);
2409- hit_do! {
2410- INTER8_PALETTE_HITS.with(|c| {
2411- let mut v = c.get();
2412- v.0 += 1;
2413- c.set(v);
2414- });
2415- }
24162313 PaletteY {
24172314 size: n,
24182315 colors,
@@ -2430,15 +2327,6 @@ pub(super) fn decode_inter_block8(
24302327 (ss_x(fctx), ss_y(fctx)),
24312328 );
24322329 let map = decode_color_index_map_wh(dec, cdfs, n, chroma_w, chroma_h, on, true);
2433- hit!(PALETTE_UV_HITS);
2434- hit!(INTRA_IN_INTER_PALETTE_UV_HITS);
2435- hit_do! {
2436- INTER8_PALETTE_HITS.with(|c| {
2437- let mut v = c.get();
2438- v.1 += 1;
2439- c.set(v);
2440- });
2441- }
24422330 PaletteUv {
24432331 size: n,
24442332 u_colors,
@@ -2525,7 +2413,6 @@ pub(super) fn decode_inter_block8(
25252413 // (the whole-block buffer would be indexed at the wrong
25262414 // stride by the first unit).
25272415 if let Some(buf) = &palette_y_buf {
2528- hit!(PALETTE_SPLIT_TX_HITS);
25292416 let window: Vec<u16> = (0..tx_px)
25302417 .flat_map(|i| {
25312418 let base = (row * MI + i) * SIDE + col * MI;
@@ -2779,7 +2666,6 @@ pub(super) fn decode_inter_block8(
27792666 Grid::Own(vo)
27802667 };
27812668 chroma_stamped_per_unit = true;
2782- hit!(LLINTRA8_CHROMA_WALK_HITS);
27832669 } else {
27842670 if let Some((ub, _)) = &palette_uv_bufs {
27852671 set_palette_pred(ub.clone(), fctx);
@@ -2986,18 +2872,6 @@ pub(super) fn decode_inter_block8(
29862872 neighbours.above[leaf_mi.1 + cell][0] = state;
29872873 }
29882874 }
2989- // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference
2990- // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every
2991- // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test).
2992- // lane-cdef r1: the fall-through twin of the compound arm's skip-band
2993- // write above -- `skip` is one flag for the whole 8x8 leaf (read at
2994- // `decode.rs`'s `skip_ctx` site), `split8` only splits its transform.
2995- // lane-intersub8 r5: ... and it counts too. r1 incremented the counter in
2996- // the COMPOUND early-return arm only, so the gate's assert really read
2997- // "a COMPOUND 8x8 leaf wrote the band"; once main's inter16ab/r14 routing
2998- // landed, the 10-bit cq12 arm's leaves come through here instead and the
2999- // gate failed on an instrumentation gap, with the band written either way.
3000- hit!(INTER8_SKIP_BAND_HITS);
30012875 neighbours.fill_skip_grid(leaf_mi, 2, skip);
30022876 neighbours.fill_lf_grid(
30032877 leaf_mi,
crates/ec-av1/src/decode/inter_ctx.rsmodified+0 -51
@@ -83,9 +83,6 @@ pub(super) fn resolve_interp_filter(
8383 } else {
8484 sym0
8585 };
86- if enable_dual_filter && sym0 != sym1 {
87- hit!(DUAL_FILTER_DIFF_HITS);
88- }
8986 if crate::envflags::env_flag!("EC_TRACE_MODE") {
9087 eprintln!(
9188 "EC_IF ctx0={ctx0} above={above:?} left={left:?} sym0={sym0} sym1={sym1} rng={}",
@@ -484,8 +481,6 @@ pub(super) fn read_inter_plane(
484481 if plane_idx > 0 && mono(fctx) {
485482 return Ok((Grid::Zero(side * side), TxType::DctDct));
486483 }
487- // lane-av1readcensus: the units read from here on are this plane's.
488- set_census_plane(plane_idx);
489484 let skip_ctx = if plane_idx == 0 {
490485 luma_skip_ctx.unwrap_or(0)
491486 } else {
@@ -678,7 +673,6 @@ pub(super) fn read_intra_chroma_lossless(
678673 plane_idx,
679674 &cu_grid,
680675 );
681- hit!(CHROMA_SPLIT_TX_HITS);
682676 let dst = mu_units(
683677 if plane_idx == 1 {
684678 &mut *u_out
@@ -737,9 +731,6 @@ pub(super) fn mu_chunk_order(
737731 let mut order = identity.clone();
738732 order.sort_by_key(|&i| ((leaves[i].0 / 16) * nchunk + (leaves[i].1 / 16), i));
739733 let changed = order != identity;
740- if changed {
741- hit!(MU_CHUNK_ORDER_HITS);
742- }
743734 (order, changed)
744735 }
745736
@@ -788,9 +779,6 @@ pub(super) fn read_inter_chroma_lossless(
788779 // libaom walks one 64x64 mu chunk at a time. Counted so a gate can pin
789780 // the walk/unit totals exactly rather than as a floor on wrong output.
790781 let counted_128 = blk_w > 64 || blk_h > 64;
791- if counted_128 {
792- hit!(MU_CHUNK_WALKS);
793- }
794782 for plane_idx in 1..3 {
795783 for rr in 0..reg_h / 4 {
796784 for cc in 0..reg_w / 4 {
@@ -850,10 +838,6 @@ pub(super) fn read_inter_chroma_lossless(
850838 plane_idx,
851839 &cu_grid,
852840 );
853- hit!(CHROMA_SPLIT_TX_HITS);
854- if counted_128 {
855- hit!(MU_CHUNK_WALK_UNITS);
856- }
857841 let dst = mu_units(
858842 if plane_idx == 1 {
859843 &mut *u_out
@@ -1018,17 +1002,6 @@ pub(super) fn read_single_ref(
10181002 }
10191003 };
10201004 if ref_frame != LAST_FRAME {
1021- hit!(NON_LAST_REF_HITS);
1022- let c = match ref_frame {
1023- LAST2_FRAME => &LAST2_HITS,
1024- LAST3_FRAME => &LAST3_HITS,
1025- GOLDEN_FRAME => &GOLDEN_HITS,
1026- BWDREF_FRAME => &BWDREF_HITS,
1027- ALTREF2_FRAME => &ALTREF2_HITS,
1028- ALTREF_FRAME => &ALTREF_HITS,
1029- _ => unreachable!("read_single_ref only ever returns LAST_FRAME..=ALTREF_FRAME"),
1030- };
1031- hit_do! { c.with(|v| v.set(v.get() + 1)); }
10321005 }
10331006 ref_frame
10341007 }
@@ -1405,9 +1378,6 @@ pub(super) fn overlappable_above(
14051378 if let Some(info) = nb
14061379 && info.is_inter
14071380 {
1408- if src != col {
1409- hit!(OBMC_PAIR_FILTER_HITS);
1410- }
14111381 // lane-t900 r14: libaom passes `AOMMIN(xd->width, mi_step)`
14121382 // as `op_mi_size` -- the block's OWN width, never the
14131383 // frame-edge clamp `end_col` carries. Clamping here shrank the
@@ -1472,9 +1442,6 @@ pub(super) fn overlappable_left(
14721442 if let Some(info) = nb
14731443 && info.is_inter
14741444 {
1475- if src != row {
1476- hit!(OBMC_PAIR_FILTER_HITS);
1477- }
14781445 // lane-t900 r14: `AOMMIN(xd->height, mi_step)` -- see
14791446 // `overlappable_above`.
14801447 out.push((
@@ -1681,9 +1648,6 @@ pub(crate) fn find_samples(
16811648 // libaom reads the 2-symbol `obmc_cdf` (class
16821649 // wrong-alphabet-same-value).
16831650 let tr_reach = crate::mvstack::has_top_right(mi_row, mi_col, bw4, bh4, fctx);
1684- if do_tr && bw4 != bh4 && tr_reach != has_top_right(mi_row, mi_col, bw4, fctx) {
1685- hit!(TR_REACH_LONGER_SIDE_HITS);
1686- }
16871651 if do_tr && tr_reach {
16881652 let tr_col = mi_col + bw4;
16891653 if mi_row > 0
@@ -1784,7 +1748,6 @@ pub(super) fn neighbour_filter(
17841748 "an OBMC neighbour whose switchable interp filter was never recorded",
17851749 ));
17861750 }
1787- hit!(OBMC_FILTER_BAND_READS);
17881751 Ok((
17891752 mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize),
17901753 mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize),
@@ -2200,9 +2163,6 @@ pub(crate) fn obmc_plan(
22002163 // lane-inter4 r4: r3 refused OBMC on a 16x8/8x16 leaf; re-measured
22012164 // byte-exact against an instrumented aomdec, the refusal is gone and the
22022165 // counter below is what the gate's `--enable-obmc=1` arm reads.
2203- if matches!((write_w, write_h), (16, 8) | (8, 16)) {
2204- hit!(OBMC_RECT_LEAF_HITS);
2205- }
22062166 // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own
22072167 // half (`reconinter.c` 860/899), inert below 128.
22082168 let overlap_above = write_h.min(64) / 2;
@@ -2250,9 +2210,6 @@ pub(crate) fn obmc_plan(
22502210 "above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind,
22512211 );
22522212 let nb_dims = ref_dims(nb.ref_frame, refpix)?;
2253- if mi_col + off4 + span4 > mi_cols {
2254- hit!(OBMC_EDGE_SPAN_HITS);
2255- }
22562213 above.push(ObmcNb {
22572214 off4,
22582215 span4,
@@ -2286,9 +2243,6 @@ pub(crate) fn obmc_plan(
22862243 "left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind,
22872244 );
22882245 let nb_dims = ref_dims(nb.ref_frame, refpix)?;
2289- if mi_row + off4 + span4 > mi_rows {
2290- hit!(OBMC_EDGE_SPAN_HITS);
2291- }
22922246 left.push(ObmcNb {
22932247 off4,
22942248 span4,
@@ -2722,9 +2676,6 @@ pub(super) fn read_comp_mode(
27222676 dec.debug_state().0
27232677 );
27242678 }
2725- if compound {
2726- hit!(COMP_MODE_HITS);
2727- }
27282679 compound
27292680 }
27302681
@@ -2766,7 +2717,6 @@ pub(super) fn read_compound_ref_frames(
27662717 let type_ctx = comp_reference_type_ctx(above, left);
27672718 let unidir = dec.symbol(&mut cdfs.comp_ref_type[type_ctx]) == 0;
27682719 if unidir {
2769- hit!(UNI_COMP_HITS);
27702720 // uni_comp_ref (p0): forward vs. backward -- av1_get_pred_context_-
27712721 // uni_comp_ref_p is single_ref_p1's own forward/backward vote.
27722722 let bit = dec.symbol(&mut cdfs.uni_comp_ref[single_ref_p1_ctx(a, a1, l, l1)][0]);
@@ -2828,7 +2778,6 @@ pub(super) fn read_inter_compound_mode(
28282778 ref_mv_ctx: usize,
28292779 ) -> u8 {
28302780 let ctx = cdf::COMPOUND_MODE_CTX_MAP[ref_mv_ctx >> 1][new_mv_ctx.min(4)];
2831- hit!(COMPOUND_MODE_HITS);
28322781 dec.symbol(&mut cdfs.inter_compound_mode[ctx]) as u8
28332782 }
28342783
crates/ec-av1/src/decode/inter_intra_arm.rsmodified+0 -34
@@ -241,9 +241,6 @@ pub(super) fn decode_inter_block_intra_arm(
241241 } else {
242242 0
243243 };
244- if angle_delta_y != 0 {
245- hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS);
246- }
247244 // The delta'd angle decides whether the intra edge filter runs at
248245 // all, so this block needs the same luma edge-filter-type neighbour
249246 // check a key-frame block does (`get_intra_edge_filter_type`, spec
@@ -263,9 +260,6 @@ pub(super) fn decode_inter_block_intra_arm(
263260 // (libaom `decodemv.c:933`).
264261 let has_chroma = !mono(fctx);
265262 let cfl_allowed = has_chroma && cfl_allowed_px(write_w, write_h, fctx);
266- if !cfl_allowed {
267- hit!(NOCFL_UV_MODE_HITS);
268- }
269263 let uv_mode = if !has_chroma {
270264 DC_PRED
271265 } else if cfl_allowed {
@@ -275,9 +269,6 @@ pub(super) fn decode_inter_block_intra_arm(
275269 crate::msac::SymbolDecoder::set_symr_cdf("uv_mode");
276270 dec.symbol(&mut cdfs.uv_mode_no_cfl[mode])
277271 };
278- if (9..=12).contains(&uv_mode) {
279- hit!(SMOOTH_UV_HITS);
280- }
281272 let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED {
282273 Some(read_cfl_alphas(dec, cdfs))
283274 } else {
@@ -288,15 +279,10 @@ pub(super) fn decode_inter_block_intra_arm(
288279 // -- `uv_mode` (13) already falls outside `V_PRED..=D67_PRED` so the
289280 // `else` branch below is exact for it either way.
290281 let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {
291- hit!(DIRECTIONAL_UV_HITS);
292282 read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
293283 } else {
294284 0
295285 };
296- if angle_delta_uv != 0 {
297- hit!(UV_ANGLE_DELTA_HITS);
298- hit!(INTRA_IN_INTER_ANGLE_DELTA_UV_HITS);
299- }
300286 uv_predict_mode = if uv_mode == UV_CFL_PRED {
301287 DC_PRED
302288 } else {
@@ -379,8 +365,6 @@ pub(super) fn decode_inter_block_intra_arm(
379365 && let Some(class) = filter_intra_size_class_rect(write_w, write_h)
380366 && dec.symbol(&mut cdfs.filter_intra[class]) != 0
381367 {
382- hit!(FILTER_INTRA_HITS);
383- hit!(INTRA_IN_INTER_FILTER_INTRA_HITS);
384368 filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode));
385369 }
386370 // `av1_visit_palette`: the two colour-index maps, Y then the shared
@@ -395,8 +379,6 @@ pub(super) fn decode_inter_block_intra_arm(
395379 palette_onscreen(rmi, cmi, write_w, write_h, fctx),
396380 false,
397381 );
398- hit!(PALETTE_HITS);
399- hit!(INTRA_IN_INTER_PALETTE_Y_HITS);
400382 PaletteY {
401383 size: n,
402384 colors,
@@ -419,8 +401,6 @@ pub(super) fn decode_inter_block_intra_arm(
419401 (ss_x(fctx), ss_y(fctx)),
420402 );
421403 let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true);
422- hit!(PALETTE_UV_HITS);
423- hit!(INTRA_IN_INTER_PALETTE_UV_HITS);
424404 PaletteUv {
425405 size: n,
426406 u_colors,
@@ -516,7 +496,6 @@ pub(super) fn decode_inter_block_intra_arm(
516496 // (the whole-block buffer would be indexed at the wrong
517497 // stride by the first unit).
518498 if let Some(buf) = &palette_y_buf {
519- hit!(PALETTE_SPLIT_TX_HITS);
520499 let window: Vec<u16> = (0..tx_px)
521500 .flat_map(|i| {
522501 let base = (row * MI + i) * side + col * MI;
@@ -588,7 +567,6 @@ pub(super) fn decode_inter_block_intra_arm(
588567 continue;
589568 }
590569 let (cr, cc) = chunk;
591- hit!(INTRA_128_IN_INTER_MU_CHROMA_HITS);
592570 // The unit's CHROMA size, its LUMA footprint, the
593571 // CHUNK's chroma extent and the unit's ORIGIN inside the
594572 // chunk are four different quantities; this arm had the
@@ -785,7 +763,6 @@ pub(super) fn decode_inter_block_intra_arm(
785763 plane_idx,
786764 &cu_grid,
787765 );
788- hit!(CHROMA_SPLIT_TX_HITS);
789766 // lane-dpm1: the two INTER mu-chunk sites set
790767 // this and this INTRA-in-inter one did not, so
791768 // the whole-block chroma record below re-stamped
@@ -794,9 +771,6 @@ pub(super) fn decode_inter_block_intra_arm(
794771 // libaom never selects (class
795772 // `override-slot-on-one-arm`).
796773 mu_chroma = true;
797- // lane-av1muchunk422b: the allocation of the intra-in-inter
798- // mu-chunk walk (site 8), per TX_32X32 unit.
799- hit!(MU_CHUNK_INTRA_IN_INTER_UNITS);
800774 let dst = mu_units(
801775 if plane_idx == 1 {
802776 &mut u_units
@@ -846,7 +820,6 @@ pub(super) fn decode_inter_block_intra_arm(
846820 } else {
847821 Grid::Own(std::mem::take(&mut v_units))
848822 };
849- hit!(INTRA_128_IN_INTER_HITS);
850823 } else if skip {
851824 if !split_luma {
852825 if let Some(buf) = &palette_y_buf {
@@ -1072,7 +1045,6 @@ pub(super) fn decode_inter_block_intra_arm(
10721045 // coefficient context.
10731046 neighbours
10741047 .record_mi_chroma(cu_mi, chroma_tx, chroma_tx, plane_idx, &cu_grid);
1075- hit!(CHROMA_SPLIT_TX_HITS);
10761048 let acc = if plane_idx == 1 {
10771049 &mut u_acc
10781050 } else {
@@ -1181,7 +1153,6 @@ pub(super) fn decode_inter_block_intra_arm(
11811153 fctx,
11821154 );
11831155 }
1184- hit!(PALETTE_422_UNIT_WINDOW_HITS);
11851156 let cu_grid = read_plane(
11861157 dec,
11871158 cdfs,
@@ -1210,8 +1181,6 @@ pub(super) fn decode_inter_block_intra_arm(
12101181 smooth_neighbor_uv,
12111182 fctx,
12121183 )?;
1213- hit!(CHROMA_SPLIT_TX_HITS);
1214- hit!(CHROMA422_SQUARE_HITS);
12151184 // Immediately, so the next unit of this plane reads this
12161185 // one's coefficient context; the whole-block record below
12171186 // re-stamps the block over these and the tail's
@@ -1322,7 +1291,6 @@ pub(super) fn decode_inter_block_intra_arm(
13221291 fctx,
13231292 );
13241293 }
1325- hit!(PALETTE_422_UNIT_WINDOW_HITS);
13261294 let cu_grid = read_plane(
13271295 dec,
13281296 cdfs,
@@ -1348,8 +1316,6 @@ pub(super) fn decode_inter_block_intra_arm(
13481316 smooth_neighbor_uv,
13491317 fctx,
13501318 )?;
1351- hit!(CHROMA_SPLIT_TX_HITS);
1352- hit!(CHROMA422_SQUARE_HITS);
13531319 neighbours.record_mi_chroma(cu_mi, luma_span_x, luma_span_y, 2, &cu_grid);
13541320 for rr in 0..cu_h {
13551321 let start = (cu_row * cu_h + rr) * chroma_side;
crates/ec-av1/src/decode/inter_shapes.rsmodified+0 -61
@@ -107,9 +107,6 @@ pub(super) fn read_block_tx_size(
107107 let overwrote = !fctx.intra_only.with(std::cell::Cell::get)
108108 && (0..side_mi).any(|i| n.above_txfm.get(at_mi.1 + i) != Some(&pub_above));
109109 set_txfm_ctxs(n, at_mi, 4, side_mi, side_mi, skip && is_inter);
110- if overwrote {
111- hit!(LOSSLESS_SQ_TXFM_BAND_OVERWRITE_HITS);
112- }
113110 return Ok((4, Some(leaves)));
114111 }
115112 if !fctx.tx_select_inter.with(std::cell::Cell::get) {
@@ -194,13 +191,6 @@ pub(super) fn read_block_tx_size(
194191 leaves.push((row, col, tx, tx));
195192 }
196193 }
197- hit_do! {
198- INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| {
199- let mut h = c.get();
200- h[(side.trailing_zeros() as usize).saturating_sub(3).min(3)] += 1;
201- c.set(h);
202- });
203- }
204194 return Ok((tx, Some(leaves)));
205195 }
206196 Ok((tx, None))
@@ -674,7 +664,6 @@ pub(super) fn read_block_tx_size_rect(
674664 // transform, and `set_txfm_ctxs` records exactly what
675665 // `txfm_partition_update` would for that same unit.
676666 txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh));
677- hit!(RECT_INTER_TU_HITS);
678667 return Ok(None);
679668 }
680669 // lane-av1oddheightfork2: `above_px` / `left_px` are the two
@@ -686,7 +675,6 @@ pub(super) fn read_block_tx_size_rect(
686675 let (above_px, left_px) = (n.above_txfm[at_mi.1], n.left_txfm[at_mi.0]);
687676 let ctx = txfm_partition_ctx_rect(above_px, left_px, bw.max(bh), tx_w, tx_h);
688677 let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1;
689- hit!(TXFM_SPLIT_READS);
690678 if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
691679 let (rng, _) = dec.debug_state();
692680 eprintln!(
@@ -699,11 +687,8 @@ pub(super) fn read_block_tx_size_rect(
699687 }
700688 if !split {
701689 txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh));
702- hit!(RECT_INTER_TU_HITS);
703690 return Ok(None);
704691 }
705- hit!(TXFM_SPLIT_HITS);
706- hit!(RECT_INTER_TXSPLIT_HITS);
707692 // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays
708693 // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`,
709694 // `[TX_16X64] == TX_16X32` -- so the recursion below is the general
@@ -815,7 +800,6 @@ pub(super) fn read_inter_rect_chroma(
815800 // replay (the c8 re-stamp, at the strip's own tiling).
816801 let mut units: Vec<((usize, usize), usize, Grid, usize, usize)> = Vec::new();
817802 if multi {
818- hit!(CHROMA_SPLIT_TX_HITS);
819803 assembled = [
820804 vec![0i32; chroma_side * assembled_h],
821805 vec![0i32; chroma_side * assembled_h],
@@ -852,35 +836,8 @@ pub(super) fn read_inter_rect_chroma(
852836 let cu_pred = src.offset(cu_row * uh * chroma_side + cu_col * uw);
853837 let inherit_tx_type =
854838 if let Some(t) = covering_leaf_tx_type(leaf_tx_types, unit_rel_mi) {
855- hit!(CHROMA_RECT_LEAF_TX_HITS);
856- if Some(t) != Some(luma_tx_type) {
857- hit!(CHROMA_RECT_LEAF_TX_DIFF_HITS);
858- }
859839 Some(t)
860840 } else {
861- // lane-av1ichromatx: the ONE remaining site in
862- // `decode_inter_block` that can hand a chroma unit a
863- // BLOCK-level type on a split plane. `covering_leaf_tx_
864- // type` found nothing, i.e. no luma leaf covers this
865- // unit's own MI cell -- which is exactly the shape a
866- // block that coded a SINGLE luma transform has (its
867- // leaf list is empty, so every lookup misses). For
868- // that block `luma_tx_type` IS the type of the one
869- // luma unit whose stamp covers the whole plane, so the
870- // fallback is correct there.
871- //
872- // What is NOT correct is a fallback on a plane with
873- // `leaves` NON-empty: then some luma leaf does exist,
874- // it simply does not cover this unit's cell, and the
875- // block-level value is a DIFFERENT leaf's type. The
876- // assertion below is what closes that shape, so the
877- // fallback can never again be a silent mistype: the
878- // class is "block-level where the unit's own cell
879- // says otherwise", and this is its last site.
880- hit!(CHROMA_RECT_BLOCK_TX_FALLBACK);
881- if multi {
882- hit!(CHROMA_RECT_BLOCK_TX_FALLBACK_MULTI);
883- }
884841 debug_assert!(
885842 leaf_tx_types.is_empty(),
886843 "lane-av1ichromatx: a multi-unit rect chroma plane fell back to the \
@@ -911,9 +868,6 @@ pub(super) fn read_inter_rect_chroma(
911868 fctx,
912869 )?
913870 .0;
914- if invalid_ss_plane {
915- hit!(CHROMA422_CHUNK_HITS);
916- }
917871 if multi {
918872 // Immediately, so the next unit of this block reads this
919873 // one's coefficient context (libaom updates the chroma
@@ -975,8 +929,6 @@ pub(super) fn read_inter_plane_rect(
975929 if plane_idx > 0 && mono(fctx) {
976930 return Ok((Grid::Zero(w * h), TxType::DctDct));
977931 }
978- // lane-av1readcensus: the units read from here on are this plane's.
979- set_census_plane(plane_idx);
980932 let skip_ctx = if plane_idx == 0 {
981933 // `get_txb_ctx_general`: 0 only when this unit IS the whole plane
982934 // block; a var-tx leaf passes its own neighbour-table context.
@@ -1020,18 +972,6 @@ pub(super) fn read_inter_plane_rect(
1020972 // because `av1_nz_map_ctx_offset` is indexed by the real, un-adjusted
1021973 // rectangular shape (lane-sbpart r8).
1022974 let (cw, ch) = (w.min(32), h.min(32));
1023- if plane_idx == 0 && w.max(h) == 64 {
1024- hit!(RECT64_INTER_TU_HITS);
1025- }
1026- if plane_idx == 0 && (w, h) == (32, 8) || plane_idx == 0 && (w, h) == (8, 32) {
1027- hit_do! {
1028- RECT32X8_INTER_TU_HITS.with(|c| {
1029- let mut v = c.get();
1030- v[usize::from(w == 8)] += 1;
1031- c.set(v);
1032- });
1033- }
1034- }
1035975 let (corner, tx_type) = if (cw, ch) == (32, 32) {
1036976 let scan32 = default_scan(TX32);
1037977 read_coeffs(
@@ -1706,6 +1646,5 @@ pub(super) fn edge_params_body(
17061646 [4, 8, 14, 14, 14][dim]
17071647 };
17081648 let level = if cur_level != 0 { cur_level } else { pv_level };
1709- hit!(DEBLOCK_HITS);
17101649 Some((len, level))
17111650 }
crates/ec-av1/src/decode/key_tile.rsmodified+0 -75
@@ -328,26 +328,17 @@ pub(super) fn read_sb128_root(
328328 let ctx128 = neighbours.partition_ctx(at128, 128);
329329 let (has_cols128, has_rows128) = (mi_c128 + SB_MI < mi_cols, mi_r128 + SB_MI < mi_rows);
330330 let part128 = if has_cols128 && has_rows128 {
331- hit!(PART128_SYMBOLS);
332331 let p = dec.symbol(&mut cdfs.partition_w128[ctx128]);
333332 if crate::envflags::env_flag!("EC_AV1_TRACE") {
334333 eprintln!("TRACE partition_w128 ctx={ctx128} value={p}");
335334 }
336335 p
337336 } else {
338- // lane-sb128 r4: the gathered half-out-of-frame reads DECIDE the
339- // partition, they are not a forced split -- exactly the discarded-bit
340- // defect the 64 root carries a comment about at `partition_w64`'s
341- // gathered arm. Value 1 is SPLIT; 0 is HORZ (rows out of frame) or
342- // VERT (cols out of frame), which the refusal below then names
343- // instead of silently reconstructing a split.
344- hit!(PART128_GATHERED_SYMBOLS);
345337 match (has_cols128, has_rows128) {
346338 (true, false) => {
347339 if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 {
348340 PARTITION_SPLIT
349341 } else {
350- hit!(PART128_EDGE_HORZ_HITS);
351342 PARTITION_HORZ
352343 }
353344 }
@@ -355,7 +346,6 @@ pub(super) fn read_sb128_root(
355346 if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 {
356347 PARTITION_SPLIT
357348 } else {
358- hit!(PART128_EDGE_VERT_HITS);
359349 PARTITION_VERT
360350 }
361351 }
@@ -383,21 +373,10 @@ pub(super) fn read_sb128_root(
383373 // decoding untouched.
384374 refuse_invalid_subsize((128, 128), part128, fctx)?;
385375 match part128 {
386- PARTITION_SPLIT => hit!(PART128_SPLIT_HITS),
387- PARTITION_NONE => hit!(PART128_NONE_HITS),
388- PARTITION_HORZ => hit!(PART128_HORZ_HITS),
389- PARTITION_VERT => hit!(PART128_VERT_HITS),
390376 // lane-sb128c r9: the four AB shapes at the 128 root -- one
391377 // 128x64/64x128 half plus two 64x64 quadrants, decoded by both tile
392378 // paths below in libaom `decode_partition`'s own visit order.
393379 p if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&p) => {
394- hit_do! {
395- PART128_AB_HITS.with(|c| {
396- let mut h = c.get();
397- h[p - PARTITION_HORZ_A] += 1;
398- c.set(h);
399- });
400- }
401380 }
402381 _ => {
403382 return Err(unsupported(
@@ -633,7 +612,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
633612 ((mi_col1 as usize * 4) >> ss_x(fctx)).min(v.width),
634613 ((mi_row1 as usize * 4) >> ss_y(fctx)).min(v.height),
635614 );
636- hit!(TILE_HITS);
637615
638616 // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` --
639617 // its one block covers all four 64x64 quadrants, so the remaining three
@@ -1327,9 +1305,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13271305 // `Reach::vert_ab_partition()` (lane-part32 r5, cherry-picked here).
13281306 let arm = part16 - PARTITION_HORZ_A;
13291307 bump_ab16(arm);
1330- if part16 == PARTITION_VERT_B {
1331- hit!(VERT_B_INTRA_HITS);
1332- }
13331308 let _vert_guard = if part16 == PARTITION_VERT_A
13341309 || part16 == PARTITION_VERT_B
13351310 {
@@ -1448,7 +1423,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14481423 continue;
14491424 }
14501425 if part16 == PARTITION_HORZ {
1451- hit!(HORZ_VERT_INTRA_HITS);
14521426 let (mi_row0, mi_col0) =
14531427 (sr as u32 * SUB_MI, sc as u32 * SUB_MI);
14541428 let top = (mi_row0 as usize, mi_col0 as usize);
@@ -1496,7 +1470,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
14961470 continue;
14971471 }
14981472 if part16 == PARTITION_VERT {
1499- hit!(HORZ_VERT_INTRA_HITS);
15001473 let (mi_row0, mi_col0) =
15011474 (sr as u32 * SUB_MI, sc as u32 * SUB_MI);
15021475 let left = (mi_row0 as usize, mi_col0 as usize);
@@ -1815,19 +1788,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
18151788 // non-SPLIT edge arm actually decoded.
18161789 bump_edge_part(if edge_split == 1 { 3 } else { 2 });
18171790 if edge_split == 0 {
1818- // lane-oddh r1: the strip IS decodable
1819- // -- libaom's `decode_partition` codes
1820- // only the FIRST half of an edge
1821- // HORZ/VERT (the second call is
1822- // guarded by the same has_rows/
1823- // has_cols test that made the
1824- // partition non-square), so one
1825- // 16x8 (resp. 8x16) strip covers the
1826- // whole visible band of a frame whose
1827- // height (resp. width) is 8 mod 16 --
1828- // the user's 3840x1608 film.
1829- hit!(HORZ_VERT_INTRA_HITS);
1830- hit!(EDGE_RECT_STRIP_HITS);
18311791 // lane-av1subsizesweep: this arm is the ONE
18321792 // frame-edge partition read in the file that
18331793 // dispatches on its own symbol instead of
@@ -2131,11 +2091,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
21312091 }
21322092 }
21332093 PARTITION_HORZ_A => {
2134- // lane-part32 r1: two 16x16 squares on top +
2135- // a true 32x16 strip below (mirrors
2136- // decode_inter_block's cd6cb6d HORZ_A: TL,
2137- // TR, bottom strip).
2138- hit!(INTRA_HORZ_A_HITS);
21392094 decode_block(
21402095 &mut dec,
21412096 &mut cdfs,
@@ -2209,11 +2164,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
22092164 )?;
22102165 }
22112166 PARTITION_HORZ_B => {
2212- // lane-part32 r1: a true 32x16 strip on top +
2213- // two 16x16 squares below (mirrors HORZ_A
2214- // with the strip/squares order flipped, same
2215- // shape as libaom decode_partition's HORZ_B).
2216- hit!(INTRA_HORZ_B_HITS);
22172167 decode_block_rect(
22182168 &mut dec,
22192169 &mut cdfs,
@@ -2287,10 +2237,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
22872237 )?;
22882238 }
22892239 PARTITION_VERT_A => {
2290- // lane-part32 r1: mirror of HORZ_A with
2291- // width/height swapped (TL, BL, right 16x32
2292- // strip).
2293- hit!(INTRA_VERT_A_HITS);
22942240 let _vert_ab = crate::encode::Reach::vert_ab_partition();
22952241 decode_block(
22962242 &mut dec,
@@ -2365,11 +2311,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
23652311 )?;
23662312 }
23672313 PARTITION_VERT_B => {
2368- // lane-part32 r1: a true 16x32 strip on the
2369- // left + two 16x16 squares on the right
2370- // (libaom decode_partition VERT_B: left
2371- // strip, TR, BR).
2372- hit!(INTRA_VERT_B_HITS);
23732314 let _vert_ab = crate::encode::Reach::vert_ab_partition();
23742315 decode_block_rect(
23752316 &mut dec,
@@ -2585,21 +2526,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
25852526 }
25862527 }
25872528 PARTITION_HORZ_A | PARTITION_HORZ_B | PARTITION_VERT_A | PARTITION_VERT_B => {
2588- // lane-part32 r4: the four superblock-level AB arms, each
2589- // two 32x32 squares plus one 64x32/32x64 strip, in
2590- // libaom's own `decode_partition` order (decodeframe.c:
2591- // HORZ_A = TL, TR, bottom strip; HORZ_B = top strip, BL,
2592- // BR; VERT_A = TL, BL, right strip; VERT_B = left strip,
2593- // TR, BR). The pieces are exactly the ones already proven
2594- // by the `PARTITION_NONE`-under-SPLIT (32x32 square) and
2595- // `PARTITION_HORZ`/`VERT` (rect64 strip) arms above.
2596- hit_do! {
2597- SB_AB_HITS.with(|c| {
2598- let mut h = c.get();
2599- h[part - PARTITION_HORZ_A] += 1;
2600- c.set(h);
2601- });
2602- }
26032529 // lane-part32 r5: only the two VERTICAL arms reorder the
26042530 // square sub-blocks (TL, BL, TR, BR), so only they switch
26052531 // libaom's `has_tr`/`has_bl` tables.
@@ -2759,7 +2685,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
27592685 PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst)
27602686 );
27612687 }
2762- census_unwritten(&y, &u, &v);
27632688 // lane-av1fwd: the encoder's filter search re-decodes this same key
27642689 // frame tile per candidate -- capture it once (see [`FilterReplay`]),
27652690 // on the shape whose tail is the two filter calls and nothing else.
crates/ec-av1/src/decode/leaf8.rsmodified+0 -68
@@ -122,9 +122,6 @@ pub(super) fn decode_block_128rect(
122122 uv_mode
123123 };
124124 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
125- if smooth_neighbor {
126- hit!(SMOOTH_LUMA_HITS);
127- }
128125 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx);
129126 // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or
130127 // not. `bsize_to_tx_size_cat(BLOCK_128X64)` is 3 (see this fn's doc).
@@ -148,20 +145,7 @@ pub(super) fn decode_block_128rect(
148145 } else {
149146 0
150147 };
151- if depth != 0 {
152- hit!(TX_DEPTH_HITS);
153- }
154- hit_do! {
155- INTRA_SB128_DEPTH_HITS.with(|c| {
156- let mut h = c.get();
157- h[depth.min(2)] += 1;
158- c.set(h);
159- });
160- }
161148 let logical_tx = if lossless_frame { 4 } else { 64 >> depth };
162- if lossless_frame {
163- hit!(INTRA128_LOSSLESS_HITS);
164- }
165149 // A 64-point transform codes nothing past its low 32 coefficients.
166150 let coeff_tx_side = logical_tx.min(32);
167151 let luma_set = if lossless_frame {
@@ -425,9 +409,6 @@ pub(super) fn decode_block_128rect(
425409 }
426410 }
427411 }
428- if !skip {
429- hit!(CHROMA_SPLIT_TX_HITS);
430- }
431412 }
432413 }
433414 if skip {
@@ -467,12 +448,8 @@ pub(super) fn decode_block_128rect(
467448 // byte-exact against ffmpeg) -- that is the replay's own designed
468449 // 4:2:2 case, not a defect signature. Nothing here asserts the
469450 // mismatch is zero.
470- if luma_span != luma_span_h {
471- hit!(SB128RECT_REPLAY_SPAN_MISMATCH_HITS);
472- }
473451 for (plane, cu_mi, grid) in &units {
474452 neighbours.record_mi_chroma(*cu_mi, luma_span, luma_span_h, *plane, grid);
475- hit!(SB128RECT_CHROMA_REPLAY_HITS);
476453 }
477454 }
478455 // No palette exists at this size; the unconditional stamp clears any
@@ -500,17 +477,8 @@ pub(super) fn decode_block_128rect(
500477 txfm_partition_update_rect(neighbours, (mi_r, mi_c), (logical_tx, logical_tx), (bw, bh));
501478 }
502479 if in_inter {
503- hit_do! {
504- INTRA128_IN_INTER_HITS.with(|c| {
505- let mut h = c.get();
506- h[usize::from(bw < bh)] += 1;
507- c.set(h);
508- });
509- }
510480 } else if bw > bh {
511- hit!(INTRA_SB128_HORZ_HITS);
512481 } else {
513- hit!(INTRA_SB128_VERT_HITS);
514482 }
515483 Ok(())
516484 }
@@ -603,9 +571,6 @@ pub(super) fn decode_leaf8(
603571 // with the coarse [`SUB`] slot as the fallback when no block recorded
604572 // that exact mi cell.
605573 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c, fctx);
606- if smooth_neighbor {
607- hit!(SMOOTH_LUMA_HITS);
608- }
609574 // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec
610575 // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other
611576 // `decode_block` caller at 16x16 and up.
@@ -654,9 +619,6 @@ pub(super) fn decode_leaf8(
654619 // next symbol (class `wrong-alphabet-same-value`). Everything below
655620 // mirrors `decode_block`'s own intrabc handling at 16x16 and up.
656621 let intrabc_dv = fctx.intrabc_dv.with(|c| c.take());
657- if intrabc_dv.is_some() {
658- hit!(LEAF8_INTRABC_HITS);
659- }
660622 // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour
661623 // index map, mapped through the base colours, IS the block's prediction --
662624 // carried to the next `reconstruct`/`read_plane` through the same
@@ -676,9 +638,6 @@ pub(super) fn decode_leaf8(
676638 let (pal_uv_size, pal_uv_colors) = palette_uv
677639 .as_ref()
678640 .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
679- if palette_y.is_some() || palette_uv.is_some() {
680- hit!(PALETTE_LEAF8_HITS);
681- }
682641 let uv_predict_mode = if uv_mode == UV_CFL_PRED {
683642 DC_PRED
684643 } else {
@@ -722,7 +681,6 @@ pub(super) fn decode_leaf8(
722681 0,
723682 &mut leaves,
724683 );
725- hit!(INTRABC_VARTX_HITS);
726684 leaves.first().map_or(8, |l| l.2)
727685 } else if tx_select && intrabc_dv.is_none() {
728686 read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, fctx)
@@ -846,7 +804,6 @@ pub(super) fn decode_leaf8(
846804 // rule) -- so a palette leaf takes the single 8x8 reconstruct below
847805 // even when `tx_depth` resolved to TX_4X4.
848806 if resolved == 4 && palette_y_buf.is_none() {
849- hit!(SKIP_SPLIT_TX_HITS);
850807 for tu_row in 0..2 {
851808 for tu_col in 0..2 {
852809 let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4);
@@ -1400,9 +1357,6 @@ pub(super) fn decode_leaf8(
14001357 let tu_px = px + tu_col * 4;
14011358 let tu_py = py + tu_row * 4;
14021359 let tu_around = neighbours.around_mi(tu_mi, 4)[0];
1403- if crate::encode::Reach::in_vert_ab() {
1404- hit!(VERT_AB_TX4_HITS);
1405- }
14061360 let tu_reach = tu_reach(
14071361 8,
14081362 8,
@@ -1422,7 +1376,6 @@ pub(super) fn decode_leaf8(
14221376 // 16x16 and up) -- the whole-block buffer would be taken by
14231377 // the FIRST unit and indexed at the wrong stride.
14241378 if let Some(buf) = &palette_y_buf {
1425- hit!(PALETTE_SPLIT_TX_HITS);
14261379 let mut window = vec![0u16; 16];
14271380 for row in 0..4 {
14281381 let src = (tu_row * 4 + row) * 8 + tu_col * 4;
@@ -1505,9 +1458,6 @@ pub(super) fn decode_leaf8(
15051458 // lane-av1intrapred: the non-vacuity counter -- armed slot consulted
15061459 // by this arm's chroma reads means the frame-copy + inherited-type
15071460 // route ran; zero at gate time means the fixture stopped reaching it.
1508- if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() {
1509- hit!(INTRABC_TX4_CHROMA_COPY_HITS);
1510- }
15111461 if chroma_422 && !lossless(fctx) {
15121462 // lane-av1-422d: the chroma unit does NOT follow the luma var-tx
15131463 // split -- `uv_txsize` is `av1_get_max_uv_txsize` of the block,
@@ -1630,7 +1580,6 @@ pub(super) fn decode_leaf8(
16301580 } else {
16311581 Grid::Own(vo)
16321582 };
1633- hit!(CHROMA422_LOSSLESS_4X4_HITS);
16341583 } else if chroma_444 && lossless(fctx) {
16351584 // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster
16361585 // of TX_4X4 units per plane, PLANE-MAJOR (`av1_get_tx_size`:
@@ -1809,7 +1758,6 @@ pub(super) fn decode_leaf8(
18091758 neighbours.record_palette_y_rect(leaf_mi, 8, 8, pal_y_size, pal_y_colors);
18101759 neighbours.record_palette_uv_rect(leaf_mi, 8, 8, pal_uv_size, pal_uv_colors);
18111760 }
1812- hit!(INTER8_SKIP_BAND_HITS);
18131761 neighbours.fill_skip_grid(leaf_mi, 2, skip);
18141762 // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal
18151763 // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm &&
@@ -2067,15 +2015,6 @@ pub(super) fn read_intra_mode_sub8(
20672015 // `is_inter_block` counts an intrabc block), so the caller takes
20682016 // the frame-copy prediction + inter residual.
20692017 let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (seg_w_mi, seg_h_mi), fctx);
2070- // lane-av1txr: the DV travels back in the RETURN value -- it is
2071- // NOT published through `FrameCtx::intrabc_dv`. That slot is the
2072- // SQUARE paths' handoff (`decode_block`/`decode_leaf8` arm it,
2073- // then `take()` it in the same call), so a sub-8x8 leaf that
2074- // armed it left the vector standing for the NEXT >=8x8 block:
2075- // `warped.obu`'s (38,60) 8x8 intra block took it as its own
2076- // intrabc and read an inter var-tx `txfm_split` where libaom read
2077- // an intra `tx_depth` (class `stale-slot-handoff`).
2078- hit!(INTRABC_HITS);
20792018 return Ok((skip, DC_PRED, 0, None, None, Some(dv)));
20802019 }
20812020 }
@@ -2119,17 +2058,11 @@ pub(super) fn read_intra_mode_sub8(
21192058 dec.debug_state().0
21202059 );
21212060 }
2122- if (9..=12).contains(&uv_mode) {
2123- hit!(SMOOTH_UV_HITS);
2124- }
21252061 let alpha = if uv_mode == UV_CFL_PRED {
21262062 Some(read_cfl_alphas(dec, cdfs))
21272063 } else {
21282064 None
21292065 };
2130- if (V_PRED..=D67_PRED).contains(&uv_mode) {
2131- hit!(DIRECTIONAL_UV_HITS);
2132- }
21332066 // See the luma comment above: no angle delta below 8x8.
21342067 let angle_delta_uv = 0;
21352068 Some((uv_mode, angle_delta_uv, alpha))
@@ -2146,7 +2079,6 @@ pub(super) fn read_intra_mode_sub8(
21462079 );
21472080 }
21482081 if use_filter_intra {
2149- hit!(FILTER_INTRA_HITS);
21502082 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);
21512083 filter_intra = Some(fi_mode);
21522084 }
crates/ec-av1/src/decode/leaf_sub8.rsmodified+0 -59
@@ -94,7 +94,6 @@ pub(super) fn sub8_leaf_chroma444(
9494 &mut vb,
9595 fctx,
9696 );
97- hit!(SKIPPED_INTRABC_DV_COPY_HITS);
9897 let zeros = &ZERO_RESIDUAL[..bw * bh];
9998 if square {
10099 set_palette_pred(ub, fctx);
@@ -173,10 +172,6 @@ pub(super) fn sub8_leaf_chroma444(
173172 fctx,
174173 );
175174 }
176- // The same arm-without-clear route the 4:2:0 tails count: a skipped
177- // leaf reads no coefficient, so the inherited chroma `tx_type` is
178- // dropped unconsumed.
179- hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS);
180175 fctx.intrabc_chroma_tx.with(|c| c.set(None));
181176 (Grid::Zero(bw * bh), Grid::Zero(bw * bh), 4, 4)
182177 } else if skip {
@@ -257,7 +252,6 @@ pub(super) fn sub8_leaf_chroma444(
257252 // The same arm-without-clear route the 4:2:0 tails count: a skipped
258253 // leaf reads no coefficient, so an armed intrabc slot is dropped.
259254 if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() {
260- hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS);
261255 fctx.intrabc_chroma_tx.with(|c| c.set(None));
262256 }
263257 (Grid::Zero(bw * bh), Grid::Zero(bw * bh), 4, 4)
@@ -350,9 +344,6 @@ pub(super) fn sub8_leaf_chroma444(
350344 } else {
351345 // lane-av1-ibc444rect: the unskipped lossless chroma walk this
352346 // lane fixes (one rect unit -> per-4x4 Chroma4 units).
353- if lossless(fctx) {
354- hit!(INTRABC_RECT8_LOSSLESS_CHROMA_HITS);
355- }
356347 if lossless(fctx) {
357348 // lane-av1-ibc444rect: at lossless `read_tx_size` forces
358349 // TX_4X4 on EVERY plane (`av1_get_tx_size`'s lossless
@@ -409,7 +400,6 @@ pub(super) fn sub8_leaf_chroma444(
409400 if !square
410401 && unit_reach != Reach::of(4, upx, upy, y.width, y.height, fctx)
411402 {
412- hit!(SUB8_CHROMA444_LOSSLESS_TU_REACH_HITS);
413403 }
414404 let grid = read_plane(
415405 dec,
@@ -607,7 +597,6 @@ pub(super) fn sub8_leaf_chroma444(
607597 let unit_reach = Reach::of_tu(bw, bh, uc * 4, ur * 4, 4, 4, reach);
608598 if !square && unit_reach != Reach::of(4, upx, upy, y.width, y.height, fctx)
609599 {
610- hit!(SUB8_CHROMA444_LOSSLESS_TU_REACH_HITS);
611600 }
612601 let grid = read_plane(
613602 dec,
@@ -988,7 +977,6 @@ pub(super) fn sub8_leaf_chroma422(
988977 &mut ub,
989978 fctx,
990979 );
991- hit!(SKIPPED_INTRABC_DV_COPY_HITS);
992980 let zeros = &ZERO_RESIDUAL[..16];
993981 set_palette_pred(ub, fctx);
994982 push_intra(
@@ -1044,17 +1032,12 @@ pub(super) fn sub8_leaf_chroma422(
10441032 // [`sub8_leaf_chroma444`] count: a skipped leaf reads no coefficient,
10451033 // so the inherited chroma `tx_type` is dropped unconsumed.
10461034 if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() {
1047- hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS);
10481035 fctx.intrabc_chroma_tx.with(|c| c.set(None));
10491036 }
10501037 (Grid::Zero(16), Grid::Zero(16))
10511038 } else if skip {
10521039 // A skipped chroma-reference leaf still predicts (the CfL contribution
10531040 // survives a skip); no coefficient symbol exists.
1054- if alpha.is_some() {
1055- hit!(CHROMA_SKIP_CFL_HITS);
1056- hit!(SKIP_CFL_HITS);
1057- }
10581041 push_intra(
10591042 y,
10601043 u,
@@ -1092,12 +1075,10 @@ pub(super) fn sub8_leaf_chroma422(
10921075 // The same arm-without-clear route the 4:2:0 tails count: a skipped
10931076 // leaf reads no coefficient, so an armed intrabc slot is dropped.
10941077 if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() {
1095- hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS);
10961078 fctx.intrabc_chroma_tx.with(|c| c.set(None));
10971079 }
10981080 (Grid::Zero(16), Grid::Zero(16))
10991081 } else if let Some(dv) = intrabc_dv {
1100- hit!(CHROMA422_SUB8_HITS);
11011082 // Frame copy at the DV; the residual still reads the ordinary chroma
11021083 // tables with the inherited luma `tx_type` (see the 4:2:0 tails).
11031084 let mut ub = vec![0u16; 16];
@@ -1183,7 +1164,6 @@ pub(super) fn sub8_leaf_chroma422(
11831164 fctx.intrabc_chroma_tx.with(|c| c.set(None));
11841165 (ug, vg)
11851166 } else {
1186- hit!(CHROMA422_SUB8_HITS);
11871167 let ug = read_plane(
11881168 dec,
11891169 cdfs,
@@ -1286,7 +1266,6 @@ pub(super) fn decode_leaf_split4(
12861266 // one a neighbour to its RIGHT sees (its top-right 4x4, mi(row, col-1))., fctx: &crate::decode::FrameCtx
12871267 fctx: &crate::decode::FrameCtx,
12881268 ) -> Result<(usize, usize)> {
1289- hit!(SUB8_SPLIT_HITS);
12901269 let (r, c) = outer_at;
12911270 let mut above_mode = neighbours.above_mode[c];
12921271 let mut left_mode = neighbours.left_mode[r];
@@ -1378,9 +1357,6 @@ pub(super) fn decode_leaf_split4(
13781357 // same value).
13791358 set_txfm_ctxs(neighbours, lmi, 4, 1, 1, false);
13801359 let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left);
1381- if smooth_neighbor {
1382- hit!(SMOOTH_LUMA_HITS);
1383- }
13841360 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
13851361 let reach = Reach::of(4, px, py, y.width, y.height, fctx);
13861362 if let Some(dv) = intrabc {
@@ -1695,10 +1671,6 @@ pub(super) fn decode_leaf_split4(
16951671 // merge keeps one fix and feeds both lanes' counters so neither of
16961672 // their gates goes vacuous.
16971673 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
1698- if alpha.is_some() {
1699- hit!(CHROMA_SKIP_CFL_HITS);
1700- hit!(SKIP_CFL_HITS);
1701- }
17021674 push_intra(
17031675 y,
17041676 u,
@@ -1742,7 +1714,6 @@ pub(super) fn decode_leaf_split4(
17421714 // arm-without-clear-on-a-skip-route). Counted so a gate can tell a
17431715 // stream that reaches this route from one that never does.
17441716 if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() {
1745- hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS);
17461717 fctx.intrabc_chroma_tx.with(|c| c.set(None));
17471718 }
17481719 (Grid::Zero(16), Grid::Zero(16))
@@ -2073,9 +2044,6 @@ pub(super) fn decode_leaf_rect8(
20732044 if let Some(dv) = intrabc {
20742045 // lane-av1-ibc444rect: the unskipped lossless luma walk this lane
20752046 // fixes (one rect unit -> per-4x4 inter units).
2076- if !skip && lossless(fctx) {
2077- hit!(INTRABC_RECT8_LOSSLESS_LUMA_HITS);
2078- }
20792047 // lane-av1txr: an intrabc `BLOCK_4X8`/`BLOCK_8X4` leaf. The
20802048 // prediction is a frame copy at the DV and the residual reads the
20812049 // INTER `LumaRect8x4` set -- but with `TxMode::Select` the leaf
@@ -2127,7 +2095,6 @@ pub(super) fn decode_leaf_rect8(
21272095 0,
21282096 &mut luma_leaves,
21292097 );
2130- hit!(RECT_INTRABC_VARTX_HITS);
21312098 publish = None;
21322099 } else if lossless(fctx) && !skip {
21332100 // lane-av1-ibc444rect: `read_tx_size`'s lossless first line
@@ -2452,15 +2419,6 @@ pub(super) fn decode_leaf_rect8(
24522419 }
24532420 continue;
24542421 }
2455- if filter_intra.is_some() {
2456- // lane-fi8 r1: `predict_filter_intra` walks its 4x2 patches over
2457- // a true `bw`x`bh` block, so a 4x8/8x4 leaf predicts through the
2458- // same `reconstruct_rect`/`reconstruct` calls below -- and under
2459- // a split transform, per 4x4 unit with that unit's own edge,
2460- // which is exactly what the depth-1 loop already does.
2461- hit!(FILTER_INTRA_RECT_HITS);
2462- hit!(FILTER_INTRA_RECT_SUB8_HITS);
2463- }
24642422 // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4
24652423 // leaf too, and is read for every intra block, skipped or not. Its
24662424 // category is libaom's `bsize_to_tx_size_cat(BLOCK_4X8) == 0` --
@@ -2485,13 +2443,6 @@ pub(super) fn decode_leaf_rect8(
24852443 } else {
24862444 0
24872445 };
2488- if depth != 0 {
2489- hit!(TX_DEPTH_HITS);
2490- hit!(RECT8_SPLIT_TX_HITS);
2491- }
2492- if smooth_neighbor {
2493- hit!(SMOOTH_LUMA_HITS);
2494- }
24952446 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
24962447 let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx);
24972448 // `sub_tx_size_map[TX_4X8] == TX_4X4`: depth 1 splits the leaf into
@@ -2600,9 +2551,7 @@ pub(super) fn decode_leaf_rect8(
26002551 }
26012552 if done > 0 {
26022553 if vert {
2603- hit!(TX4X8_CODED_HITS);
26042554 } else {
2605- hit!(TX8X4_CODED_HITS);
26062555 }
26072556 }
26082557 neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip);
@@ -2716,9 +2665,7 @@ pub(super) fn decode_leaf_rect8(
27162665 )?;
27172666 if levels.iter().any(|&l| l != 0) {
27182667 if vert {
2719- hit!(TX4X8_CODED_HITS);
27202668 } else {
2721- hit!(TX8X4_CODED_HITS);
27222669 }
27232670 }
27242671 let residual = dequant_and_inverse_typed_wh(
@@ -2881,10 +2828,6 @@ pub(super) fn decode_leaf_rect8(
28812828 // merge keeps one fix and feeds both lanes' counters so neither of
28822829 // their gates goes vacuous.
28832830 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
2884- if alpha.is_some() {
2885- hit!(CHROMA_SKIP_CFL_HITS);
2886- hit!(SKIP_CFL_HITS);
2887- }
28882831 push_intra(
28892832 y,
28902833 u,
@@ -2928,7 +2871,6 @@ pub(super) fn decode_leaf_rect8(
29282871 // arm-without-clear-on-a-skip-route). Counted so a gate can tell a
29292872 // stream that reaches this route from one that never does.
29302873 if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() {
2931- hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS);
29322874 fctx.intrabc_chroma_tx.with(|c| c.set(None));
29332875 }
29342876 (Grid::Zero(16), Grid::Zero(16))
@@ -3005,7 +2947,6 @@ pub(super) fn decode_leaf_rect8(
30052947 &ZERO_RESIDUAL[..16],
30062948 fctx,
30072949 );
3008- hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS);
30092950 fctx.intrabc_chroma_tx.with(|c| c.set(None));
30102951 (Grid::Zero(16), Grid::Zero(16))
30112952 } else {
crates/ec-av1/src/decode/mod.rsmodified+0 -74
@@ -20,7 +20,6 @@
2020 //! inside one, forcing the gathered-CDF partial-superblock path, is round 2
2121 //! too). Anything outside that refuses with [`Error::unsupported`] rather than
2222 //! silently miscoding.
23-use crate::hits::{hit, hit_do};
2423
2524 use ec_av1_syntax::{
2625 CdefParams, DeltaParams, LoopFilterParams, LoopRestorationParams, MAX_SEGMENTS,
@@ -41,8 +40,6 @@ use ec_core::{Error, Result};
4140 // itself was lifted by lane-av112bitc before that (the combines absorb the
4241 // CONV_BUF gain drop, `INTER_POST_ROUND - delta`, see `mc::combine_compound`).
4342
44-mod counters;
45-pub use counters::*;
4643
4744 mod frame_tile;
4845
@@ -670,7 +667,6 @@ pub(crate) fn warp_plane_allowed(w: usize, h: usize) -> bool {
670667 if w >= 8 && h >= 8 {
671668 return true;
672669 }
673- hit!(WARP_PLANE_SUPPRESS_HITS);
674670 false
675671 }
676672
@@ -776,7 +772,6 @@ fn maybe_read_delta_q(
776772 }
777773 let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true };
778774 let reduced = if sign_negative { -abs } else { abs };
779- hit!(DELTA_Q_HITS);
780775 let res = fctx.delta_q_res.with(|c| c.get());
781776 fctx.current_q_idx
782777 .with(|c| c.set((c.get() + reduced * res).clamp(1, 255)));
@@ -832,7 +827,6 @@ fn maybe_read_delta_lf(
832827 let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true };
833828 let reduced = if sign_negative { -abs } else { abs };
834829 cur[i] = (cur[i] + reduced * res).clamp(-63, 63);
835- hit!(DELTA_LF_HITS);
836830 }
837831 fctx.current_delta_lf.with(|c| c.set(cur));
838832 }
@@ -860,7 +854,6 @@ fn maybe_read_cdef_idx(
860854 }
861855 let idx = dec.literal(u32::from(bits)) as u8;
862856 fctx.cdef_transmitted.with(|c| c.set(true));
863- hit!(CDEF_IDX_HITS);
864857 let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize);
865858 let sb_cols = fctx.cdef_sb_cols.with(|c| c.get());
866859 if sb_cols > 0 {
@@ -987,10 +980,6 @@ fn block_q_idx(fctx: &crate::decode::FrameCtx) -> i32 {
987980 if crate::envflags::env_flag!("EC_DQCOEFF") {
988981 eprintln!("OUR_Q base={base} seg={seg_id} q={q}");
989982 }
990- hit_do!(BLOCK_Q_SPAN.with(|c| {
991- let (lo, hi) = c.get();
992- c.set((lo.min(q), hi.max(q)));
993- }););
994983 q
995984 }
996985
@@ -1160,7 +1149,6 @@ fn read_segment_id(
11601149 return pred as u8;
11611150 }
11621151 let coded = dec.symbol(&mut cdfs.segment_id[ctx]) as i32;
1163- hit!(SEG_ID_HITS);
11641152 let last_active = fctx.seg.with(|s| i32::from(s.borrow().last_active_seg_id));
11651153 let id = neg_deinterleave(coded, pred, last_active + 1).clamp(0, last_active);
11661154 // Mirrors the oracle's own `EC_SEG mi_row=.. cdf=.. pred=.. coded=.. id=..`
@@ -1263,7 +1251,6 @@ fn inter_segment_id(
12631251 let id = if temporal_update {
12641252 let ctx = seg_pred_ctx(mi_r, mi_c, fctx);
12651253 let predicted = dec.symbol(&mut cdfs.segment_pred[ctx]) != 0;
1266- hit!(SEG_PRED_HITS);
12671254 stamp_seg_pred(mi_r, mi_c, w_mi, h_mi, u8::from(predicted), fctx);
12681255 if predicted {
12691256 predicted_segment_id(mi_r, mi_c, w_mi, h_mi, fctx)
@@ -1345,9 +1332,6 @@ fn tu_reach(
13451332 ) -> Reach {
13461333 let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, block);
13471334 let standalone = Reach::of(tx, px + col_off, py + row_off, width, height, fctx);
1348- if fixed != standalone {
1349- hit!(SPLIT_TU_REACH_FIX_HITS);
1350- }
13511335 fixed
13521336 }
13531337
@@ -1376,9 +1360,6 @@ fn tu_reach_rect(
13761360 let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx_w, tx_h, block);
13771361 if tx_w == tx_h {
13781362 let standalone = Reach::of(tx_w, px + col_off, py + row_off, width, height, fctx);
1379- if fixed != standalone {
1380- hit!(SPLIT_TU_REACH_FIX_HITS);
1381- }
13821363 }
13831364 fixed
13841365 }
@@ -1390,7 +1371,6 @@ static PREFILT_PICTURE_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::
13901371
13911372 /// Records one decoded forward keyframe (see [`FWD_KF_HITS`]).
13921373 pub(crate) fn note_fwd_kf() {
1393- hit!(FWD_KF_HITS);
13941374 }
13951375
13961376 thread_local! {
@@ -1420,34 +1400,13 @@ pub(crate) fn set_inter_tx_mode(
14201400 }
14211401
14221402 fn bump_ab16(arm: usize) {
1423- hit_do! {
1424- AB16_HITS.with(|c| {
1425- let mut v = c.get();
1426- v[arm] += 1;
1427- c.set(v);
1428- });
1429- }
14301403 }
14311404
14321405 /// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`].
14331406 pub(crate) fn bump_inter_edge_strip(idx: usize) {
1434- hit_do! {
1435- INTER_EDGE_STRIP_HITS.with(|c| {
1436- let mut v = c.get();
1437- v[idx] += 1;
1438- c.set(v);
1439- });
1440- }
14411407 }
14421408
14431409 fn bump_edge_both_cut(level: usize) {
1444- hit_do! {
1445- EDGE_BOTH_CUT_HITS.with(|c| {
1446- let mut v = c.get();
1447- v[level] += 1;
1448- c.set(v);
1449- });
1450- }
14511410 }
14521411
14531412 // lane-av1muchroma site 1: the total number of samples by which
@@ -1563,12 +1522,10 @@ pub(crate) fn frame_chroma_alloc_crop_shapes() -> usize {
15631522 /// numbers. A counter that recomputed `shape >> ss` beside the allocation
15641523 /// would have read the same value either way and proved nothing.
15651524 fn note_frame_chroma_alloc(shape: (usize, usize), alloc: (usize, usize), ss: (usize, usize)) {
1566- hit!(FRAME_CHROMA_ALLOC_CALLS);
15671525 let (need_w, need_h) = (round_ss(shape.0, ss.0), round_ss(shape.1, ss.1));
15681526 // Decidability: the floor and the crop are the same number on this frame,
15691527 // so the shortfall below is the same number the two forms would have given.
15701528 if (need_w, need_h) != (shape.0 >> ss.0, shape.1 >> ss.1) {
1571- hit!(FRAME_CHROMA_ALLOC_CROP_SHAPES);
15721529 if crate::envflags::env_flag!("EC_AV1_CHROMA_ALLOC_SWEEP") {
15731530 eprintln!(
15741531 "CHROMA_ALLOC luma={}x{} ss={:?} floor={}x{} round_ss={}x{} alloc={}x{}",
@@ -1586,9 +1543,6 @@ fn note_frame_chroma_alloc(shape: (usize, usize), alloc: (usize, usize), ss: (us
15861543 }
15871544 let want = need_w * need_h;
15881545 let got = alloc.0 * alloc.1;
1589- if want > got {
1590- hit_do!(FRAME_CHROMA_ALLOC_SHORT_SAMPLES.with(|c| c.set(c.get() + want - got)));
1591- }
15921546 }
15931547
15941548 /// lane-av1ibcfork: this decoder's half of the per-unit BIT INTERVAL -- the
@@ -2629,7 +2583,6 @@ fn record_intrabc_mi_rect(
26292583 /// Bump [`FIMV_FRAME_HITS`] -- called once per decoded frame header whose
26302584 /// `force_integer_mv` bit is set.
26312585 pub fn note_force_integer_mv_frame() {
2632- hit!(FIMV_FRAME_HITS);
26332586 }
26342587
26352588 // lane-t900 r27: OBMC blends that actually READ a recorded switchable filter
@@ -2700,13 +2653,6 @@ thread_local! {
27002653 }
27012654
27022655 fn bump_edge_part(slot: usize) {
2703- hit_do! {
2704- EDGE_PART_HITS.with(|c| {
2705- let mut h = c.get();
2706- h[slot] += 1;
2707- c.set(h);
2708- });
2709- }
27102656 }
27112657
27122658 /// [`bump_edge32`] of `base + bit`, returning the bit -- the gathered edge
@@ -2717,13 +2663,6 @@ fn bump_edge32_bit(base: usize, bit: usize) -> usize {
27172663 }
27182664
27192665 fn bump_edge32(slot: usize) {
2720- hit_do! {
2721- EDGE32_HITS.with(|c| {
2722- let mut h = c.get();
2723- h[slot] += 1;
2724- c.set(h)
2725- });
2726- }
27272666 }
27282667
27292668 /// One 16x4 / 4x16 inter strip's chroma situation, handed to
@@ -2750,13 +2689,6 @@ pub(crate) struct InterStripChroma {
27502689 /// The single-reference MC parameters of the inter block that decoded
27512690 /// last -- read by the next 1:4 strip to build its pair's chroma.
27522691 fn bump_ab16_inter(arm: usize) {
2753- hit_do! {
2754- AB16_INTER_HITS.with(|c| {
2755- let mut v = c.get();
2756- v[arm] += 1;
2757- c.set(v);
2758- });
2759- }
27602692 }
27612693
27622694 /// Everything [`decode_inter_block`] needs to fold temporal MV candidates
@@ -2939,17 +2871,11 @@ pub(crate) fn cdef_straddle_units() -> usize {
29392871 }
29402872
29412873 fn note_sub8_chroma_tx(first_sub: TxType, chroma_ref: TxType, coeffs: bool) {
2942- if coeffs && first_sub != chroma_ref {
2943- hit!(SUB8_CHROMA_TX_FROM_REF_HITS);
2944- }
29452874 }
29462875
29472876 /// Counts one [`CHROMA_EOB_CLASS1_HITS`] when `plane_idx`'s inherited
29482877 /// `tx_type` put this block's `eob_pt` on the class-1 row.
29492878 fn note_chroma_class1(plane_idx: usize, tx_type: TxType) {
2950- if plane_idx > 0 && TxClass::of(tx_type) != TxClass::TwoD {
2951- hit!(CHROMA_EOB_CLASS1_HITS);
2952- }
29532879 }
29542880
29552881 // Which plane the in-flight INTRA reconstruction is writing (0=Y, 1=U, 2=V).
crates/ec-av1/src/decode/post_filter.rsmodified+0 -1
@@ -164,7 +164,6 @@ pub(super) fn apply_cdef(
164164 if crate::envflags::env_flag!("EC_AV1_DEBUG_SKIP_CDEF") {
165165 return;
166166 }
167- cdef_scan_counters(skip_grid);
168167 // `cdef.bits == 0` still means "no filtering at all" whenever the single
169168 // (index 0) strength pair is all-zero -- the fast path every existing
170169 // gate stream takes. A `bits > 0` frame can still be all-zero-strength
crates/ec-av1/src/decode/rect.rsmodified+0 -207
@@ -92,7 +92,6 @@ pub(super) fn read_intra_mode_rect(
9292 // offer the 14-symbol CFL alphabet on a 64-axis block (class
9393 // wrong-alphabet-same-value: same value, wrong interval, silent desync).
9494 let cfl = if cfl && bw.max(bh) > 32 {
95- hit!(NOCFL_UV_MODE_HITS);
9695 false
9796 } else {
9897 cfl
@@ -134,10 +133,8 @@ pub(super) fn read_intra_mode_rect(
134133 // refused by name when it fires.
135134 if allow_intrabc_frame(fctx) {
136135 let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0;
137- hit!(RECT_INTRABC_READS);
138136 istep!("intrabc", use_intrabc as i32);
139137 if use_intrabc {
140- hit!(INTRABC_HITS);
141138 // libaom `read_intrabc_info`: the DV read, then an immediate
142139 // return out of the mode-info read -- no `y_mode`, no `uv_mode`,
143140 // no angle deltas, no palette, no filter intra. The caller owns
@@ -200,19 +197,12 @@ pub(super) fn read_intra_mode_rect(
200197 } else {
201198 None
202199 };
203- if has_chroma && (9..=12).contains(&uv_mode) {
204- hit!(SMOOTH_UV_HITS);
205- }
206200 let angle_delta_uv = if has_chroma && (V_PRED..=D67_PRED).contains(&uv_mode) {
207- hit!(DIRECTIONAL_UV_HITS);
208201 read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
209202 } else {
210203 0
211204 };
212205 istep!("angle_uv", angle_delta_uv);
213- if angle_delta_uv != 0 {
214- hit!(UV_ANGLE_DELTA_HITS);
215- }
216206 // `read_palette_mode_info` (spec 5.11.13), rect-generalised
217207 // (lane-palette2 r4): same bsize-ctx-gated read as [`read_intra_mode`],
218208 // just keyed by [`palette_bsize_ctx_wh`] instead of the square-only
@@ -223,10 +213,6 @@ pub(super) fn read_intra_mode_rect(
223213 let mut palette_y_pending: Option<(usize, [u16; 8])> = None;
224214 let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None;
225215 if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh) {
226- // r6: this is the exact site the removed blanket refusal used to
227- // guard -- reached for EVERY rect strip in a screen-content frame,
228- // independent of whether the block ends up using a palette.
229- hit!(RECT_SCREEN_CONTENT_HITS);
230216 let (mode_ctx, cache) = palette.unwrap_or((0, &[]));
231217 let use_palette_y =
232218 mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][mode_ctx]) != 0;
@@ -269,7 +255,6 @@ pub(super) fn read_intra_mode_rect(
269255 }
270256 istep!("use_filter_intra", use_filter_intra as i32);
271257 if use_filter_intra {
272- hit!(FILTER_INTRA_HITS);
273258 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);
274259 istep!("filter_intra_mode", fi_mode as i32);
275260 filter_intra = Some(fi_mode);
@@ -287,8 +272,6 @@ pub(super) fn read_intra_mode_rect(
287272 palette_onscreen(mi_r, mi_c, bw, bh, fctx),
288273 false,
289274 );
290- hit!(PALETTE_HITS);
291- hit!(PALETTE_RECT_HITS);
292275 PaletteY {
293276 size: n,
294277 colors,
@@ -309,7 +292,6 @@ pub(super) fn read_intra_mode_rect(
309292 (ss_x(fctx), ss_y(fctx)),
310293 );
311294 let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true);
312- hit!(PALETTE_UV_HITS);
313295 PaletteUv {
314296 size: n,
315297 u_colors,
@@ -618,13 +600,6 @@ pub(super) fn decode_rect_split(
618600 (4, 8) => Some(3),
619601 _ => None,
620602 } {
621- hit_do! {
622- RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| {
623- let mut hits = c.get();
624- hits[i] += 1;
625- c.set(hits);
626- });
627- }
628603 }
629604 if !m.skip && chroma.is_none() && !chroma_tiled {
630605 // Diagnostic for the next caller that lands here (class
@@ -648,10 +623,6 @@ pub(super) fn decode_rect_split(
648623 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
649624 ));
650625 }
651- hit!(RECT_SPLIT_TX_HITS);
652- if bw.max(bh) == 64 && bw / tx_w > 1 && bh / tx_h > 1 {
653- hit!(RECT_SPLIT_SB_INTERIOR_TU_HITS);
654- }
655626 // LUMA: `bw/tx` x `bh/tx` square transform units, raster order.
656627 // A square unit reads through the ordinary square [`read_plane`]; a rect
657628 // one (a 1:4 strip's first split) reads through [`read_coeffs_rect`] with
@@ -786,13 +757,6 @@ pub(super) fn decode_rect_split(
786757 if crate::envflags::env_flag!("EC_RECT64TU") {
787758 eprintln!("EC_RECT64TU mi={tu_mi:?} tx={tx_w}x{tx_h} mode={}", m.mode);
788759 }
789- hit_do! {
790- RECT64_CORNER_TU_HITS.with(|c| {
791- let mut v = c.get();
792- v[usize::from(tx_h > tx_w)] += 1;
793- c.set(v);
794- });
795- }
796760 let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0];
797761 let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra));
798762 let (corner, tu_tx_type) = read_coeffs(
@@ -1122,7 +1086,6 @@ pub(super) fn decode_rect_split(
11221086 // `REFUSED: unsupported: AV1 tile (a Golomb tail longer
11231087 // than this decoder reads)`.
11241088 if cpx + cu_col * 4 >= u.true_width || cpy + cu_row * 4 >= u.true_height {
1125- hit!(RECT_SPLIT_LOSSLESS_CHROMA_OFFTILE_HITS);
11261089 continue;
11271090 }
11281091 let cu_mi = (mi_r + cu_row * (span_y / MI), mi_c + cu_col * (span_x / MI));
@@ -1195,9 +1158,6 @@ pub(super) fn decode_rect_split(
11951158 m.smooth_neighbor_uv,
11961159 fctx,
11971160 )?;
1198- if span_x == 4 && span_y == 4 {
1199- hit!(RECT_SPLIT_LOSSLESS_CHROMA444_HITS);
1200- }
12011161 neighbours.record_mi_chroma(cu_mi, span_x, span_y, plane_idx, &grid);
12021162 ll_chroma_units.push((cu_mi, plane_idx, grid.clone(), span_x, span_y));
12031163 last[plane_idx - 1] = grid;
@@ -1229,12 +1189,6 @@ pub(super) fn decode_rect_split(
12291189 };
12301190 // lane-av1-422: the witness counter, keyed to ss (1,0) so only a 4:2:2
12311191 // frame's square chroma units count it.
1232- if uw == uh && ss_x(fctx) == 1 && ss_y(fctx) == 0 {
1233- hit!(CHROMA422_SQUARE_HITS);
1234- }
1235- if chroma_422_pair_wide {
1236- hit!(CHROMA422_PAIR_WIDE_HITS);
1237- }
12381192 let (nw, nh) = (chroma_block_w / uw, chroma_block_h / uh);
12391193 // lane-av1-422stripanchor: the pair's plane block is BLOCK_INVALID
12401194 // whatever the pair size (`num_pels_log2_lookup[255]` reads 0xff in
@@ -1363,14 +1317,6 @@ pub(super) fn decode_rect_split(
13631317 if cu_reach.above_right != reach.above_right
13641318 || cu_reach.below_left != reach.below_left
13651319 {
1366- hit!(RECT_TILED_CHROMA_UNIT_REACH_HITS);
1367- }
1368- if nw * nh > 1 {
1369- match (nw, nh) {
1370- (2, 1) => hit!(RECT_TILED_CHROMA_2X1_HITS),
1371- (1, 2) => hit!(RECT_TILED_CHROMA_1X2_HITS),
1372- _ => hit!(RECT_TILED_CHROMA_NXN_HITS),
1373- }
13741320 }
13751321 // 32x32 does not fit read_coeffs_rect's scratch (768). The
13761322 // square reader is the path every other 32x32 chroma unit uses.
@@ -1510,9 +1456,6 @@ pub(super) fn decode_rect_split(
15101456 // (lane-rectsplit r4: lifting the split-transform refusal moved
15111457 // superblock strips onto this path, so only counting there would
15121458 // leave the delta_q gate's counter silent for them).
1513- if bw.max(bh) == 64 && fctx.current_q_idx.with(|c| c.get()) != i32::from(base_q_idx) {
1514- hit!(RECT64_QIDX_DRIFT_HITS);
1515- }
15161459 let residual = dequant_and_inverse_typed_wh(
15171460 &levels,
15181461 chroma_w,
@@ -1985,14 +1928,6 @@ pub(super) fn decode_intra_rect_in_inter(
19851928 mi_r * MI
19861929 );
19871930 }
1988- hit_do! {
1989- INTRA16X4_IN_INTER_HITS.with(|h| {
1990- let mut v = h.get();
1991- v[usize::from(!horz)] += 1;
1992- v[2] += usize::from(has_chroma);
1993- h.set(v);
1994- });
1995- }
19961931 return Ok(());
19971932 }
19981933 // lane-inter128intra r1: the 128 superblock's PARTITION_HORZ/VERT half
@@ -2143,13 +2078,6 @@ pub(super) fn decode_intra_rect_in_inter(
21432078 (32, 8) => 2,
21442079 _ => 3,
21452080 };
2146- hit_do! {
2147- INTRA_RECT4_IN_INTER_HITS.with(|h| {
2148- let mut v = h.get();
2149- v[shape] += 1;
2150- h.set(v);
2151- });
2152- }
21532081 return Ok(());
21542082 }
21552083 crate::msac::SymbolDecoder::set_symr_cdf("y_mode");
@@ -2177,9 +2105,6 @@ pub(super) fn decode_intra_rect_in_inter(
21772105 } else {
21782106 0
21792107 };
2180- if angle_delta_y != 0 {
2181- hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS);
2182- }
21832108 // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the
21842109 // superblock-level strip reads the no-CFL alphabet -- the same split
21852110 // [`read_intra_mode_rect`] makes for [`decode_block_rect64`].
@@ -2204,9 +2129,6 @@ pub(super) fn decode_intra_rect_in_inter(
22042129 dec.debug_state().0
22052130 );
22062131 }
2207- if (9..=12).contains(&uv_mode) {
2208- hit!(SMOOTH_UV_HITS);
2209- }
22102132 let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED {
22112133 Some(read_cfl_alphas(dec, cdfs))
22122134 } else {
@@ -2218,15 +2140,10 @@ pub(super) fn decode_intra_rect_in_inter(
22182140 uv_mode
22192141 };
22202142 let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {
2221- hit!(DIRECTIONAL_UV_HITS);
22222143 read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
22232144 } else {
22242145 0
22252146 };
2226- if angle_delta_uv != 0 {
2227- hit!(UV_ANGLE_DELTA_HITS);
2228- hit!(INTRA_IN_INTER_ANGLE_DELTA_UV_HITS);
2229- }
22302147 // `read_palette_mode_info` (spec 5.11.13), in the position
22312148 // `read_intra_block_mode_info` writes it: after the chroma mode and
22322149 // before `filter_intra`. lane-t900 r21: a `--tune-content=screen` inter
@@ -2242,7 +2159,6 @@ pub(super) fn decode_intra_rect_in_inter(
22422159 let mut palette_y_pending: Option<(usize, [u16; 8])> = None;
22432160 let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None;
22442161 if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh) {
2245- hit!(INTRA_RECT_IN_INTER_SCREEN_HITS);
22462162 let use_palette_y =
22472163 mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0;
22482164 if use_palette_y {
@@ -2284,8 +2200,6 @@ pub(super) fn decode_intra_rect_in_inter(
22842200 && let Some(class) = filter_intra_size_class_rect(bw, bh)
22852201 && dec.symbol(&mut cdfs.filter_intra[class]) != 0
22862202 {
2287- hit!(FILTER_INTRA_HITS);
2288- hit!(INTRA_IN_INTER_FILTER_INTRA_HITS);
22892203 filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode));
22902204 }
22912205 // `av1_visit_palette`: Y's colour-index map then the shared chroma one.
@@ -2299,9 +2213,6 @@ pub(super) fn decode_intra_rect_in_inter(
22992213 palette_onscreen(mi_r, mi_c, bw, bh, fctx),
23002214 false,
23012215 );
2302- hit!(PALETTE_HITS);
2303- hit!(PALETTE_RECT_HITS);
2304- hit!(INTRA_IN_INTER_PALETTE_Y_HITS);
23052216 PaletteY {
23062217 size: n,
23072218 colors,
@@ -2317,8 +2228,6 @@ pub(super) fn decode_intra_rect_in_inter(
23172228 (ss_x(fctx), ss_y(fctx)),
23182229 );
23192230 let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true);
2320- hit!(PALETTE_UV_HITS);
2321- hit!(INTRA_IN_INTER_PALETTE_UV_HITS);
23222231 PaletteUv {
23232232 size: n,
23242233 u_colors,
@@ -2337,13 +2246,7 @@ pub(super) fn decode_intra_rect_in_inter(
23372246 // context-read-from-one-cell).
23382247 let coarse_pair = neighbours.modes_above_left(r, c);
23392248 let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left_mi(mi_r, mi_c, coarse_pair);
2340- if (nb_above_mode, nb_left_mode) != coarse_pair {
2341- hit!(EDGE_FILTER_MI_FIX_HITS);
2342- }
23432249 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
2344- if smooth_neighbor {
2345- hit!(SMOOTH_LUMA_HITS);
2346- }
23472250 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx);
23482251 // lane-av1mixloss: the lossless-segment early return (`decodeframe.c:1203`)
23492252 // precedes `TX_MODE_SELECT`, so a lossless-segment intra-rect block inside
@@ -2367,19 +2270,6 @@ pub(super) fn decode_intra_rect_in_inter(
23672270 } else {
23682271 0
23692272 };
2370- if depth != 0 || lossless(fctx) {
2371- hit!(TX_DEPTH_HITS);
2372- // lane-intrasplit r1: a split intra strip in an inter frame walks the
2373- // key frame's own per-TU path ([`decode_rect_split`] below); what was
2374- // wrong when this refusal was written was the depth SYMBOL, not the walk.
2375- hit_do! {
2376- INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(|h| {
2377- let mut v = h.get();
2378- v[depth.min(2)] += 1;
2379- h.set(v);
2380- });
2381- }
2382- }
23832273 // lane-intrasplit r3: print EVERY intra strip with its depth, not only the
23842274 // split ones -- a `depth=0`-only stream is a witness gap in the SOURCE, and
23852275 // the two are indistinguishable when the diagnostic fires on splits alone.
@@ -2467,13 +2357,6 @@ pub(super) fn decode_intra_rect_in_inter(
24672357 32 => 1,
24682358 _ => 2,
24692359 };
2470- hit_do! {
2471- INTRA_RECT_IN_INTER_HITS.with(|h| {
2472- let mut v = h.get();
2473- v[class] += 1;
2474- h.set(v);
2475- });
2476- }
24772360 Ok(())
24782361 }
24792362
@@ -2514,21 +2397,10 @@ pub(super) fn decode_intrabc_rect(
25142397 base_q_idx: u8,
25152398 fctx: &crate::decode::FrameCtx,
25162399 ) -> Result<()> {
2517- hit!(INTRABC_RECT_HITS);
25182400 // [horz, vert]: see `INTRABC_RECT_CODED_HITS` / `INTRABC_RECT_SKIPPED_HITS`.
25192401 let idx = usize::from(bh > bw);
25202402 if skip {
2521- INTRABC_RECT_SKIPPED_HITS.with(|c| {
2522- let mut seen = c.get();
2523- seen[idx] += 1;
2524- c.set(seen);
2525- });
25262403 } else {
2527- INTRABC_RECT_CODED_HITS.with(|c| {
2528- let mut seen = c.get();
2529- seen[idx] += 1;
2530- c.set(seen);
2531- });
25322404 }
25332405 let (px, py) = (mi_c * MI, mi_r * MI);
25342406 // lane-whtshape: a LOSSLESS block's chroma plane block is
@@ -2576,12 +2448,6 @@ pub(super) fn decode_intrabc_rect(
25762448 skip,
25772449 fctx,
25782450 )?;
2579- if leaves.is_some() {
2580- hit!(INTRABC_RECT_VARTX_HITS);
2581- }
2582- if ss_x(fctx) == 0 && ss_y(fctx) == 0 {
2583- hit!(IBC_RECT_CHROMA_FOOTPRINT_444_HITS);
2584- }
25852451 // lane-ibc444c: per-block geometry, for the chroma-tail attribution.
25862452 if crate::envflags::env_flag!("EC_IBCBLOCK") {
25872453 eprintln!(
@@ -2704,19 +2570,6 @@ pub(super) fn decode_intrabc_rect(
27042570 fctx,
27052571 );
27062572 if let Some(ls) = leaves.as_ref() {
2707- // lane-av1-loss64, merged: the same reset [`decode_intrabc_owned_rect`]'s
2708- // skip arm performs -- libaom `av1_reset_entropy_context`
2709- // (`if (mbmi->skip_txfm)`, decodeframe.c:1262 -> blockd.c:58): a
2710- // SKIPPED block zeroes its whole entropy-band footprint. This
2711- // helper serves `decode_block_rect4`'s 1:4 strips on this tree,
2712- // so a skipped lossless strip whose `leaves` resolved (every
2713- // lossless frame -- `read_block_tx_size_rect`'s lossless arm
2714- // returns the 4x4 grid before it looks at `skip`) left the
2715- // PREVIOUS occupant's luma bands standing and the NEXT block's
2716- // partition parse diverged from libaom's: the 320x242 lossless
2717- // sb128 gate read a phantom unskipped 8x32 intrabc strip at
2718- // mi(56,66) right after the skipped 8x16 one at mi(48,66).
2719- hit!(SKIP_LOSSLESS_BAND_RESET_HITS);
27202573 for &(row, col, tw, th) in ls {
27212574 neighbours.record_mi_luma_rect(
27222575 (mi_r + row, mi_c + col),
@@ -2898,21 +2751,6 @@ pub(super) fn decode_intrabc_rect(
28982751 around[2] = c[2];
28992752 }
29002753 if lossless(fctx) {
2901- // lane-whtshape: at lossless libaom codes TX_4X4 on EVERY
2902- // plane of a block -- `read_tx_size` returns `TX_4X4` for a
2903- // lossless block before it looks at a tree, `read_tx_mode`
2904- // already forced `ONLY_4X4` for the frame, and
2905- // `get_vartx_max_txsize` returns `TX_4X4` for every plane
2906- // -- so this block's chroma plane block is a
2907- // `(cw/4) * (ch/4)` raster of 4x4 units, PLANE-MAJOR
2908- // (`decode_token_recon_block`: every U unit, then every V
2909- // unit), not the single rect unit the two
2910- // `read_inter_plane_rect` calls below read. That single
2911- // 8x4 unit is what reached the lossless WHT with the wrong
2912- // shape (the `debug_assert_eq!((w, h), (4, 4))` this lane
2913- // replaced). Same helper, same walk, as the inter 8x8 and
2914- // 128 paths.
2915- hit!(INTRABC_RECT_LOSSLESS_CHROMA4_HITS);
29162754 let mut uo = vec![0i32; cside * cside];
29172755 let mut vo = vec![0i32; cside * cside];
29182756 read_inter_chroma_lossless(
@@ -3120,7 +2958,6 @@ pub(super) fn decode_intrabc_128rect(
31202958 base_q_idx: u8,
31212959 fctx: &crate::decode::FrameCtx,
31222960 ) -> Result<()> {
3123- hit!(INTRABC_128RECT_HITS);
31242961 if crate::envflags::env_flag!("EC_AV1_TRACE") {
31252962 let (rng, _) = dec.debug_state();
31262963 eprintln!(
@@ -3272,12 +3109,6 @@ pub(super) fn decode_intrabc_128rect(
32723109 fctx,
32733110 );
32743111 if let Some(ls) = leaves.as_ref() {
3275- // A LOSSLESS frame's `read_block_tx_size_rect` resolves the TX_4X4
3276- // grid before it looks at `skip`; the skipped block still zeroes
3277- // its entropy-band footprint over every unit (libaom
3278- // `av1_reset_entropy_context` under `if (mbmi->skip_txfm)`) --
3279- // the same arm [`decode_intrabc_rect`]'s loss64 merge added.
3280- hit!(SKIP_LOSSLESS_BAND_RESET_HITS);
32813112 for &(row, col, tw, th) in ls {
32823113 neighbours.record_mi_luma_rect(
32833114 (mi_r + row, mi_c + col),
@@ -3540,8 +3371,6 @@ pub(super) fn decode_intrabc_128rect(
35403371 st.dc, st.level
35413372 );
35423373 }
3543- hit!(CHROMA_SPLIT_TX_HITS);
3544- INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.set(c.get() + 1));
35453374 // lane-av1-ibcrect: per-unit chroma context -- the
35463375 // end-of-block record's composed-grid re-stamp
35473376 // must not stand (replayed below).
@@ -3826,9 +3655,6 @@ pub(super) fn decode_block_rect(
38263655 );
38273656 }
38283657 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
3829- if smooth_neighbor {
3830- hit!(SMOOTH_LUMA_HITS);
3831- }
38323658 // lane-chroma r3: chroma's own edge-filter-strength neighbour check
38333659 // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's
38343660 // `uv_mode`, not the luma one.
@@ -3839,9 +3665,6 @@ pub(super) fn decode_block_rect(
38393665 // rectangle just as happily), so a `use_filter_intra` strip at this level
38403666 // predicts instead of refusing. The below-16x16 leaf arm
38413667 // (`decode_leaf_rect`) keeps the refusal: it has no gate of its own.
3842- if filter_intra.is_some() {
3843- hit!(FILTER_INTRA_RECT_HITS);
3844- }
38453668 let uv_predict_mode = if uv_mode == UV_CFL_PRED {
38463669 DC_PRED
38473670 } else {
@@ -3889,7 +3712,6 @@ pub(super) fn decode_block_rect(
38893712 fctx,
38903713 );
38913714 if depth != 0 || lossless(fctx) {
3892- hit!(TX_DEPTH_HITS);
38933715 // lane-rectsplit r1: a split transform is predicted and reconstructed
38943716 // per transform unit, each unit taking its edges from the previous
38953717 // unit's reconstruction inside this same strip (spec 5.11.36) --
@@ -3922,9 +3744,6 @@ pub(super) fn decode_block_rect(
39223744 )
39233745 }),
39243746 };
3925- if palette_y.is_some() || palette_uv.is_some() {
3926- hit!(PALETTE_SPLIT_TX_HITS);
3927- }
39283747 decode_rect_split(
39293748 dec,
39303749 cdfs,
@@ -3957,7 +3776,6 @@ pub(super) fn decode_block_rect(
39573776 .as_ref()
39583777 .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
39593778 neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors);
3960- hit!(RECT_PARTITION_HITS);
39613779 return Ok(());
39623780 }
39633781 let (tx_w, tx_h) = (bw, bh);
@@ -4315,7 +4133,6 @@ pub(super) fn decode_block_rect(
43154133 uv_predict_mode,
43164134 &[&luma_levels[..], &u_levels[..], &v_levels[..]],
43174135 );
4318- hit!(RECT_COEFF_HITS);
43194136 }
43204137 }
43214138 let (py_size, py_colors) = palette_y
@@ -4336,7 +4153,6 @@ pub(super) fn decode_block_rect(
43364153 0,
43374154 fctx,
43384155 );
4339- hit!(RECT_PARTITION_HITS);
43404156 if crate::envflags::env_flag!("EC_AV1_TRACE") {
43414157 eprintln!("TRACE_RECT32_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh}");
43424158 }
@@ -4412,9 +4228,6 @@ pub(super) fn decode_leaf_rect(
44124228 let (above_mode, left_mode) =
44134229 neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode));
44144230 let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
4415- if smooth_neighbor {
4416- hit!(SMOOTH_LUMA_HITS);
4417- }
44184231 // The palette-Y mode CDF row is picked by the neighbours' palette use
44194232 // (`palette_ctx_and_cache`), so this sub-16x16 leaf must pass its own real
44204233 // ctx/cache -- reading `palette_y_mode` off row 0 when a neighbour did use
@@ -4478,9 +4291,6 @@ pub(super) fn decode_leaf_rect(
44784291 // lane-kf900 r4: palette prediction on this shape, the same colour-index
44794292 // map -> base colours buffer [`decode_block_rect`] hands each
44804293 // `reconstruct_rect` through [`set_palette_pred`].
4481- if palette_y.is_some() || palette_uv.is_some() {
4482- hit!(RECT4_PALETTE_HITS);
4483- }
44844294 let palette_y_buf: Option<Vec<u16>> = palette_y
44854295 .as_ref()
44864296 .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect());
@@ -4499,14 +4309,6 @@ pub(super) fn decode_leaf_rect(
44994309 if crate::envflags::env_flag!("EC_AV1_RECTX_TRACE") {
45004310 eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}");
45014311 }
4502- if filter_intra.is_some() {
4503- // lane-fistrip r1: `predict_filter_intra` already walks its 4x2
4504- // patches over a true `bw`x`bh` block (lane-rectsplit r1), so an
4505- // 8x16/16x8 strip predicts through the same call `reconstruct_rect`
4506- // below already makes; this refusal was square-only prose.
4507- hit!(FILTER_INTRA_RECT_HITS);
4508- hit!(FILTER_INTRA_RECT_SUB16_HITS);
4509- }
45104312 let uv_predict_mode = if uv_mode == UV_CFL_PRED {
45114313 DC_PRED
45124314 } else {
@@ -4566,11 +4368,6 @@ pub(super) fn decode_leaf_rect(
45664368 fctx,
45674369 );
45684370 if depth != 0 || lossless(fctx) {
4569- // The same per-transform-unit walk the bigger strips take
4570- // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at
4571- // depth 2), addressed at this leaf's own mi position.
4572- hit!(TX_DEPTH_HITS);
4573- hit!(SUB16_SPLIT_HITS);
45744371 let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx);
45754372 let modes = RectStripModes {
45764373 skip,
@@ -4588,9 +4385,6 @@ pub(super) fn decode_leaf_rect(
45884385 palette_y: palette_y_buf.clone(),
45894386 palette_uv: palette_uv_bufs.clone(),
45904387 };
4591- if palette_y.is_some() || palette_uv.is_some() {
4592- hit!(PALETTE_SPLIT_TX_HITS);
4593- }
45944388 decode_rect_split(
45954389 dec,
45964390 cdfs,
@@ -4908,7 +4702,6 @@ pub(super) fn decode_leaf_rect(
49084702 smooth_neighbor_uv,
49094703 fctx,
49104704 );
4911- hit!(RECT_LEAF_COEFF_HITS);
49124705 }
49134706 neighbours.record_mi_rect(
49144707 leaf_mi,
crates/ec-av1/src/decode/rect4.rsmodified+0 -142
@@ -117,9 +117,6 @@ pub(super) fn decode_block_rect4(
117117 // [`decode_block_rect`] does one aspect ratio up -- the colour-index map
118118 // mapped through the base colours IS the prediction (it reads no edge
119119 // pixels), handed to each `reconstruct_rect` through [`set_palette_pred`].
120- if palette_y.is_some() || palette_uv.is_some() {
121- hit!(RECT4_PALETTE_HITS);
122- }
123120 let palette_y_buf: Option<Vec<u16>> = palette_y
124121 .as_ref()
125122 .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect());
@@ -136,9 +133,6 @@ pub(super) fn decode_block_rect4(
136133 .as_ref()
137134 .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
138135 let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
139- if smooth_neighbor {
140- hit!(SMOOTH_LUMA_HITS);
141- }
142136 // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's
143137 // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so
144138 // `r * (SUB / MI)` names a different mi column and the chroma
@@ -147,11 +141,8 @@ pub(super) fn decode_block_rect4(
147141 // with luma bit-exact).
148142 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx);
149143 if filter_intra.is_some() {
150- hit!(FILTER_INTRA_RECT_HITS);
151144 if bw > bh {
152- hit!(FILTER_INTRA_RECT4_HORZ_HITS);
153145 } else {
154- hit!(FILTER_INTRA_RECT4_VERT_HITS);
155146 }
156147 }
157148 let uv_predict_mode = if uv_mode == UV_CFL_PRED {
@@ -192,24 +183,7 @@ pub(super) fn decode_block_rect4(
192183 fctx,
193184 );
194185 if depth != 0 || lossless(fctx) {
195- // lane-rectsplitx r1: the per-transform-unit walk, at this strip's
196- // real mi position (strips 1 and 3 of a HORZ_4 start 8 px into a
197- // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16
198- // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8;
199- // both interleave in every real stream.
200- hit!(TX_DEPTH_HITS);
201186 let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx);
202- // lane-rectsplitx r2: both depths ship together, as the r1 handoff
203- // predicted -- depth 1 fires FIRST in every attempt that splits at
204- // all, so a depth-2-only lift could never be gated. The r1 mismatch
205- // was never the rect unit: it was the neighbour MODE the strip reads
206- // (see `modes_above_left_mi`).
207- let which = if depth == 1 {
208- &RECT4_SPLIT_DEPTH1_HITS
209- } else {
210- &RECT4_SPLIT_DEPTH2_HITS
211- };
212- hit_do! { which.with(|c| c.set(c.get() + 1)); }
213187 let modes = RectStripModes {
214188 skip,
215189 mode,
@@ -223,9 +197,6 @@ pub(super) fn decode_block_rect4(
223197 palette_y: palette_y_buf.clone(),
224198 palette_uv: palette_uv_bufs.clone(),
225199 };
226- if palette_y.is_some() || palette_uv.is_some() {
227- hit!(PALETTE_SPLIT_TX_HITS);
228- }
229200 decode_rect_split(
230201 dec,
231202 cdfs,
@@ -254,12 +225,7 @@ pub(super) fn decode_block_rect4(
254225 pal_uv_colors,
255226 );
256227 if bw > bh {
257- hit!(RECT4_32_HORZ_HITS);
258228 } else {
259- hit!(RECT4_32_VERT_HITS);
260- }
261- if !skip {
262- hit!(RECT4_COEFF_HITS);
263229 }
264230 // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm,
265231 // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter
@@ -369,7 +335,6 @@ pub(super) fn decode_block_rect4(
369335 TxType::DctDct,
370336 0,
371337 )?;
372- hit!(RECT4_COEFF_HITS);
373338 let luma_residual = dequant_and_inverse_typed_wh(
374339 &luma_levels,
375340 bw,
@@ -499,9 +464,7 @@ pub(super) fn decode_block_rect4(
499464 pal_uv_colors,
500465 );
501466 if bw > bh {
502- hit!(RECT4_32_HORZ_HITS);
503467 } else {
504- hit!(RECT4_32_VERT_HITS);
505468 }
506469 // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm,
507470 // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter
@@ -568,7 +531,6 @@ pub(super) fn decode_block_rect4(
568531 }
569532 let (v_levels, v_tx_type) = planes.pop().expect("plane 2");
570533 let (u_levels, u_tx_type) = planes.pop().expect("plane 1");
571- hit!(RECT4_COEFF_HITS);
572534 let luma_residual = dequant_and_inverse_typed_wh(
573535 &luma_levels,
574536 bw,
@@ -658,9 +620,7 @@ pub(super) fn decode_block_rect4(
658620 pal_uv_colors,
659621 );
660622 if bw > bh {
661- hit!(RECT4_32_HORZ_HITS);
662623 } else {
663- hit!(RECT4_32_VERT_HITS);
664624 }
665625 // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm,
666626 // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter
@@ -805,9 +765,7 @@ pub(super) fn decode_block_rect4(
805765 pal_uv_colors,
806766 );
807767 if bw > bh {
808- hit!(RECT4_32_HORZ_HITS);
809768 } else {
810- hit!(RECT4_32_VERT_HITS);
811769 }
812770 // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm,
813771 // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter
@@ -982,9 +940,6 @@ pub(super) fn decode_intrabc_owned_rect(
982940 let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx));
983941 let side = bw.max(bh);
984942 let cside = cw.max(ch);
985- if ss_x(fctx) == 0 && ss_y(fctx) == 0 {
986- hit!(IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS);
987- }
988943 let saved_reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get);
989944 let saved_tx = fctx.tx_select_inter.with(std::cell::Cell::get);
990945 fctx.reduced_tx_set_inter.with(|c| c.set(reduced_tx_set));
@@ -1063,20 +1018,6 @@ pub(super) fn decode_intrabc_owned_rect(
10631018 fctx,
10641019 );
10651020 if let Some(ls) = leaves.as_ref() {
1066- // libaom `av1_reset_entropy_context` (`if (mbmi->skip_txfm)`,
1067- // decodeframe.c:1262 -> blockd.c:58): a SKIPPED block zeroes its
1068- // whole entropy-band footprint. The non-skip arm below writes
1069- // those bands per transform unit and the tail's
1070- // `record_split_luma_rect_mi` writes chroma only, so without
1071- // this walk a skipped strip whose `leaves` resolved (every
1072- // lossless frame -- `read_block_tx_size_rect`'s lossless arm
1073- // returns the 4x4 grid before it looks at `skip`) leaked the
1074- // PREVIOUS occupant's luma bands into the next block's
1075- // `txb_skip`/coefficient contexts (lane-av1-loss64: the skipped
1076- // 8x16 intrabc strip at mi(48,66) of the 320x242 lossless sb128
1077- // stream left a stale 7 in left[48] and mi(48,68)'s first
1078- // transform unit read `txb_skip_ctx` 3 where aomdec reads 1).
1079- hit!(SKIP_LOSSLESS_BAND_RESET_HITS);
10801021 for &(row, col, tw, th) in ls {
10811022 neighbours.record_mi_luma_rect(
10821023 (mi_r + row, mi_c + col),
@@ -1195,7 +1136,6 @@ pub(super) fn decode_intrabc_owned_rect(
11951136 // `TX_MODE_LARGEST`); the routing here is identical, so a future
11961137 // witness takes the same code.
11971138 let around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
1198- hit!(IBC_OWNED_RECT_422_PAIR_HITS);
11991139 neighbours.around_mi_422_chroma((mi_r, mi_c), bw, bh)
12001140 } else {
12011141 neighbours.around_mi_rect((mi_r, mi_c), bw, bh)
@@ -1295,7 +1235,6 @@ pub(super) fn decode_intrabc_owned_rect(
12951235 // agree -- `fixtures/ibc422_nonsplit_ctx.obu` is the stream where
12961236 // they do not).
12971237 let around_chroma = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
1298- hit!(IBC_OWNED_RECT_422_PAIR_HITS);
12991238 neighbours.around_mi_422_chroma((mi_r, mi_c), bw, bh)
13001239 } else {
13011240 around
@@ -1603,7 +1542,6 @@ pub(super) fn decode_rect4_16_intrabc(
16031542 fctx: &crate::decode::FrameCtx,
16041543 ) -> Result<(usize, Option<usize>, (usize, usize))> {
16051544 let _ = base_q_idx;
1606- hit!(RECT4_16_INTRABC_HITS);
16071545 let (bw, bh) = if horz { (16usize, 4usize) } else { (4, 16) };
16081546 let (mi_w, mi_h) = (bw / MI, bh / MI);
16091547 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
@@ -1670,15 +1608,9 @@ pub(super) fn decode_rect4_16_intrabc(
16701608 // [BLOCK_4X16][1][0]` is BLOCK_INVALID at 4:2:2, so only HORZ reaches it.
16711609 let own444 = ss_x(fctx) == 0 && ss_y(fctx) == 0;
16721610 let own422 = ss_x(fctx) == 1 && ss_y(fctx) == 0 && horz;
1673- if own422 && has_chroma {
1674- hit!(INTRABC_RECT4_OWN_CHROMA422_HITS);
1675- }
16761611 // One predicate for "this strip IS its own chroma reference": the strip's
16771612 // own mi position, its own luma extent, and per-axis subsampled sizes.
16781613 let own_chroma = own444 || own422;
1679- if ss_x(fctx) == 0 && ss_y(fctx) == 0 && has_chroma {
1680- hit!(INTRABC_RECT4_OWN_CHROMA444_HITS);
1681- }
16821614 let (pw, ph) = if own444 {
16831615 (bw, bh)
16841616 } else if horz {
@@ -2184,7 +2116,6 @@ pub(super) fn decode_rect4_16_intrabc(
21842116 }
21852117 let mut last_uv = None;
21862118 if has_chroma {
2187- hit!(RECT4_16_CHROMA_HITS);
21882119 // lane-av1422luma: the uv-mode publication and the left/above skip
21892120 // state below are the STRIP's own at 4:2:2 / 4:4:4 -- publishing the
21902121 // pair extent (one mi row off, `ph`/`pw`) is what the NEXT block's
@@ -2221,9 +2152,7 @@ pub(super) fn decode_rect4_16_intrabc(
22212152 last_uv = Some(DC_PRED);
22222153 }
22232154 if horz {
2224- hit!(RECT4_16_HORZ_HITS);
22252155 } else {
2226- hit!(RECT4_16_VERT_HITS);
22272156 }
22282157 record_strip_palette(neighbours, lmi, bw, bh, 0, [0u16; 8], 0, [0u16; 8]);
22292158 if leaves.is_none() {
@@ -2350,9 +2279,6 @@ pub(super) fn decode_rect4_16_strip(
23502279 fctx,
23512280 );
23522281 }
2353- if palette_y.is_some() || palette_uv.is_some() {
2354- hit!(RECT4_PALETTE_HITS);
2355- }
23562282 // The colour-index map through the base colours IS the prediction.
23572283 // Chroma's map is the PAIR's 8x4 (4x8) block, matching the one
23582284 // chroma transform this closing strip codes.
@@ -2366,12 +2292,6 @@ pub(super) fn decode_rect4_16_strip(
23662292 )
23672293 });
23682294 let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
2369- if smooth_neighbor {
2370- hit!(SMOOTH_LUMA_HITS);
2371- }
2372- if filter_intra.is_some() {
2373- hit!(FILTER_INTRA_RECT_HITS);
2374- }
23752295 // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is
23762296 // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the
23772297 // depth symbol is the 3-symbol `tx_size_cat1` -- not the 2-symbol
@@ -2397,10 +2317,6 @@ pub(super) fn decode_rect4_16_strip(
23972317 } else {
23982318 0
23992319 };
2400- if depth != 0 {
2401- hit!(TX_DEPTH_HITS);
2402- hit!(RECT4_16_SPLIT_HITS);
2403- }
24042320 let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx);
24052321 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
24062322 let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx);
@@ -2502,9 +2418,6 @@ pub(super) fn decode_rect4_16_strip(
25022418 smooth_neighbor,
25032419 fctx,
25042420 );
2505- if tu_grid.iter().any(|&l| l != 0) {
2506- hit!(RECT4_16_COEFF_HITS);
2507- }
25082421 neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid);
25092422 } else {
25102423 let tu_around = neighbours.around_mi(tu_mi, tx_w)[0];
@@ -2534,9 +2447,6 @@ pub(super) fn decode_rect4_16_strip(
25342447 smooth_neighbor,
25352448 fctx,
25362449 )?;
2537- if tu_grid.iter().any(|&l| l != 0) {
2538- hit!(RECT4_16_COEFF_HITS);
2539- }
25402450 neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid);
25412451 }
25422452 }
@@ -2620,7 +2530,6 @@ pub(super) fn decode_rect4_16_strip(
26202530 smooth_neighbor,
26212531 fctx,
26222532 );
2623- hit!(RECT4_16_COEFF_HITS);
26242533 levels
26252534 };
26262535 neighbours.record_mi_luma_rect(lmi, bw, bh, &levels);
@@ -2641,7 +2550,6 @@ pub(super) fn decode_rect4_16_strip(
26412550 }
26422551 }
26432552 if has_chroma {
2644- hit!(RECT4_16_CHROMA_HITS);
26452553 // lane-av1-444: at 4:4:4 there is no pair -- every strip is its
26462554 // own chroma reference and codes its own 16x4 / 4x16 chroma
26472555 // block. (`set_mi_offsets`'s chroma snap is the zero offset at
@@ -2687,9 +2595,6 @@ pub(super) fn decode_rect4_16_strip(
26872595 } else {
26882596 uv_mode
26892597 };
2690- if (V_PRED..=D67_PRED).contains(&uv_predict_mode) {
2691- hit!(RECT4_16_CHROMA_DIR_HITS);
2692- }
26932598 let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height, fctx);
26942599 // lane-kf1200 r1: the chroma edge-filter type reads the neighbours
26952600 // of the CHROMA block, which for a 16x4/4x16 pair is `pair_mi`'s
@@ -2728,7 +2633,6 @@ pub(super) fn decode_rect4_16_strip(
27282633 false,
27292634 )
27302635 {
2731- hit!(RECT4_16_UV_PAIR_FILT_HITS);
27322636 }
27332637 // lane-av1-rect14: a lossless frame forces TX_4X4 on every plane
27342638 // (`av1_get_tx_size`, blockd.h:1381). The pair's chroma block is
@@ -2739,7 +2643,6 @@ pub(super) fn decode_rect4_16_strip(
27392643 // mi(1,20) uv_mode matched, the following skip did not).
27402644 let lossless_pair = lossless(fctx);
27412645 let (u_levels, v_levels) = if lossless_pair {
2742- hit!(RECT4_16_LOSSLESS_CHROMA_HITS);
27432646 if skip {
27442647 for plane in 1..3usize {
27452648 for rr in 0..ch / 4 {
@@ -2910,7 +2813,6 @@ pub(super) fn decode_rect4_16_strip(
29102813 plane,
29112814 &cu_grid,
29122815 );
2913- hit!(CHROMA_SPLIT_TX_HITS);
29142816 let dst = if plane == 1 { &mut uo } else { &mut vo };
29152817 for row in 0..4 {
29162818 let start = (oy + row) * cw + ox;
@@ -2929,9 +2831,6 @@ pub(super) fn decode_rect4_16_strip(
29292831 // DC + alpha * luma-AC. Dropping the CfL term here left a
29302832 // chroma-only bounded box on ReelC's key frames.
29312833 let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph));
2932- if alpha.is_some() {
2933- hit!(CHROMA_SKIP_CFL_HITS);
2934- }
29352834 for plane in [1usize, 2] {
29362835 if chroma422_pair16 {
29372836 // lane-av1-422o: two TX_4X8 units, each predicted on
@@ -3116,7 +3015,6 @@ pub(super) fn decode_rect4_16_strip(
31163015 // a restored `/2 chroma height` lands on (8,4) and the
31173016 // counter reads 0.
31183017 (8, 8) => {
3119- hit!(CHROMA422_SQUARE_HITS);
31203018 (TxbSet::Chroma8, default_scan(8))
31213019 }
31223020 // lane-av1-422o: with the `chroma422_pair16` arm above,
@@ -3226,9 +3124,7 @@ pub(super) fn decode_rect4_16_strip(
32263124 last_uv_mode = Some(uv_predict_mode);
32273125 }
32283126 if horz {
3229- hit!(RECT4_16_HORZ_HITS);
32303127 } else {
3231- hit!(RECT4_16_VERT_HITS);
32323128 }
32333129 let (pal_y_size, pal_y_colors) = palette_y
32343130 .as_ref()
@@ -3354,17 +3250,7 @@ pub(super) fn decode_block_rect64(
33543250 fctx,
33553251 );
33563252 }
3357- if (palette_y.is_some() || palette_uv.is_some()) && !skip {
3358- // lane-t900 r34: a non-skip palette block on a superblock-level strip
3359- // -- counted so its gate cannot go vacuous (this was a refusal until
3360- // r34; see the gate `a_real_aomenc_palette_stream_with_8x8_leaves_
3361- // decodes_pixel_exact`).
3362- hit!(PALETTE_SB_STRIP_HITS);
3363- }
33643253 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
3365- if smooth_neighbor {
3366- hit!(SMOOTH_LUMA_HITS);
3367- }
33683254 let smooth_neighbor_uv =
33693255 neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c, fctx);
33703256 if filter_intra.is_some() {
@@ -3423,7 +3309,6 @@ pub(super) fn decode_block_rect64(
34233309 fctx,
34243310 );
34253311 if depth != 0 || lossless(fctx) {
3426- hit!(TX_DEPTH_HITS);
34273312 // lane-rectsplit r1/r4: the superblock-level strip splits its
34283313 // transform through the very same per-unit path as its 32x32-level
34293314 // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64
@@ -3431,12 +3316,6 @@ pub(super) fn decode_block_rect64(
34313316 // measured the old square formula mis-tiling exactly that strip).
34323317 let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx);
34333318 if bw.max(bh) / bw.min(bh) == 4 {
3434- let which = if depth == 1 {
3435- &RECT4_SPLIT_DEPTH1_HITS
3436- } else {
3437- &RECT4_SPLIT_DEPTH2_HITS
3438- };
3439- hit_do! { which.with(|c| c.set(c.get() + 1)); }
34403319 }
34413320 if crate::envflags::env_flag!("EC_SBPART_DUMP64") {
34423321 eprintln!(
@@ -3465,9 +3344,6 @@ pub(super) fn decode_block_rect64(
34653344 )
34663345 }),
34673346 };
3468- if palette_y.is_some() || palette_uv.is_some() {
3469- hit!(PALETTE_SPLIT_TX_HITS);
3470- }
34713347 decode_rect_split(
34723348 dec,
34733349 cdfs,
@@ -3506,8 +3382,6 @@ pub(super) fn decode_block_rect64(
35063382 // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The
35073383 // bands carry the SPLIT unit's size, not the block's.
35083384 txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh));
3509- hit!(RECT64_SPLIT_TXFM_PUBLISH_HITS);
3510- hit!(RECT_PARTITION_HITS);
35113385 return Ok(());
35123386 }
35133387 let (tx_w, tx_h) = (bw, bh);
@@ -3673,9 +3547,6 @@ pub(super) fn decode_block_rect64(
36733547 }
36743548 {
36753549 let cur = block_q_idx(fctx);
3676- if cur != i32::from(base_q_idx) {
3677- hit!(RECT64_QIDX_DRIFT_HITS);
3678- }
36793550 if crate::envflags::env_flag!("EC_AV1_TRACE") {
36803551 eprintln!(
36813552 "TRACE rect64_dequant plane=0 base_q_idx={base_q_idx} current_q_idx={cur}"
@@ -3813,9 +3684,6 @@ pub(super) fn decode_block_rect64(
38133684 // nothing. The `bigger` guard is what makes a hit PROOF
38143685 // that the tiled arm ran, rather than proof that some
38153686 // palette chroma block existed.
3816- if bigger {
3817- hit!(CHROMA_PALETTE_WINDOW_HITS);
3818- }
38193687 }
38203688 read_plane(
38213689 dec,
@@ -3883,9 +3751,6 @@ pub(super) fn decode_block_rect64(
38833751 // nothing. The `bigger` guard is what makes a hit PROOF
38843752 // that the tiled arm ran, rather than proof that some
38853753 // palette chroma block existed.
3886- if bigger {
3887- hit!(CHROMA_PALETTE_WINDOW_HITS);
3888- }
38893754 }
38903755 push_intra_rect(
38913756 y,
@@ -3949,7 +3814,6 @@ pub(super) fn decode_block_rect64(
39493814 for (cu_mi, plane, unit, span_w, span_h) in &tiled_chroma_units {
39503815 neighbours.record_mi_chroma(*cu_mi, *span_w, *span_h, *plane, unit);
39513816 }
3952- hit!(RECT_COEFF_HITS);
39533817 }
39543818 let (py_size, py_colors) = palette_y
39553819 .as_ref()
@@ -3980,12 +3844,6 @@ pub(super) fn decode_block_rect64(
39803844 // 3840x1608 10-bit stream's first silent wall, decode-order frame 33 at
39813845 // mi(16,480)). Same write as [`set_txfm_ctxs`], rect-aware.
39823846 txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh));
3983- hit!(SB_RECT_HITS);
3984- match (bw, bh) {
3985- (64, 16) => hit!(SB_RECT4_HORZ_HITS),
3986- (16, 64) => hit!(SB_RECT4_VERT_HITS),
3987- _ => {}
3988- }
39893847 if crate::envflags::env_flag!("EC_AV1_TRACE") {
39903848 let (rng, _) = dec.debug_state();
39913849 eprintln!("TRACE_RECT64_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} rng={rng}");
crates/ec-av1/src/decode/replay.rsmodified+0 -4
@@ -471,9 +471,6 @@ pub(super) fn cdef_band(
471471 while mi_r < r_hi {
472472 let mut mi_c = 0usize;
473473 while mi_c < skip_grid.mi_cols {
474- if skip_grid.is_skip_txfm(mi_r, mi_c) {
475- hit!(CDEF_SKIPPED_UNITS);
476- }
477474 if !skip_grid.is_skip_txfm(mi_r, mi_c) {
478475 let sidx = strength_idx(mi_r, mi_c);
479476 let (ox, oy) = (mi_c * 4, mi_r * 4);
@@ -524,7 +521,6 @@ pub(super) fn cdef_band(
524521 || cdef.uv_pri_strength[sidx] != 0
525522 || cdef.uv_sec_strength[sidx] != 0)
526523 {
527- hit!(CDEF_STRADDLE_UNITS);
528524 }
529525 if enable_primary || enable_secondary {
530526 cdef_filter_block(
crates/ec-av1/src/decode/sub8_inter.rsmodified+0 -92
@@ -62,7 +62,6 @@ pub(super) fn decode_inter_sub8_split4(
6262 ) -> Result<()> {
6363 const LAST_FRAME: i8 = 1;
6464 const B4: usize = 4;
65- hit!(SUB8_INTER_SPLIT_HITS);
6665 let (gr, gc) = group_mi;
6766 let (gpx, gpy) = (gc * MI, gr * MI);
6867 let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx));
@@ -143,17 +142,6 @@ pub(super) fn decode_inter_sub8_split4(
143142 fctx.tx_select_inter.with(std::cell::Cell::get),
144143 );
145144 }
146- // lane-sub8x4 r2: the refusal and its `EC_SUB8INTRA_DECODE` bypass
147- // are gone -- `a_real_aomenc_inter_sequence_with_intra_sub8x8_
148- // leaves_decodes_pixel_exact` (stream.rs) decodes 12 real aomenc
149- // streams carrying this arm pixel-exact vs ffmpeg.
150- hit_do! {
151- SUB8_INTRA_RECT_HITS.with(|h| {
152- let mut st = h.get();
153- st[4] += 1;
154- h.set(st);
155- });
156- }
157145 // lane-sub8intra: the `BLOCK_4X4` twin of the HORZ/VERT arm --
158146 // same [`decode_intra_sub8_leaf`], no tx-depth symbol, chroma on
159147 // the chroma-reference sub-blocks (`is_chroma_reference`: the
@@ -209,9 +197,6 @@ pub(super) fn decode_inter_sub8_split4(
209197 // each of the group's pieces (luma and its 2x2 chroma) carries its
210198 // OWN factor because each can name a different `ref_frame`.
211199 let luma_scale = scale_of((ref_width, ref_height), frame_size);
212- if !luma_scale.is_unscaled() {
213- hit!(SCALED_SUB8_HITS);
214- }
215200 let gm_table = build_gm_mv_table(
216201 global_motion,
217202 rmi,
@@ -245,8 +230,6 @@ pub(super) fn decode_inter_sub8_split4(
245230 tpl,
246231 );
247232 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
248- if !not_new {
249- }
250233 let mut is_globalmv = false;
251234 let (mv, is_new_mv) = if !not_new {
252235 let mut idx = 0usize;
@@ -271,8 +254,6 @@ pub(super) fn decode_inter_sub8_split4(
271254 )
272255 } else {
273256 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
274- if !not_zero {
275- }
276257 is_globalmv = !not_zero;
277258 let mv = if !not_zero {
278259 gm_table[(ref_frame - LAST_FRAME) as usize]
@@ -336,9 +317,6 @@ pub(super) fn decode_inter_sub8_split4(
336317 // `is_nontrans_global_motion` returns 0 for
337318 // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model --
338319 // so a GLOBALMV sub-block here always reads its interp filter.
339- if is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation {
340- hit!(GM_NONTRANS_SMALL_SIDE_HITS);
341- }
342320 let gm_nontrans = false;
343321 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
344322 dec,
@@ -744,7 +722,6 @@ pub(super) fn decode_inter_sub8_split4(
744722 neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]);
745723 neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]);
746724 } else {
747- hit!(CHROMA422_INTER_SUB8_HITS);
748725 let (ug, _) = read_inter_plane(
749726 dec,
750727 cdfs,
@@ -857,15 +834,6 @@ pub(super) fn decode_inter_sub8_split4(
857834 // mi of the group is intra: the group's 4x4 chroma is then predicted WHOLE
858835 // from the chroma-reference (last) sub-block's own mv, not in 2x2 pieces.
859836 let mixed = piece.iter().any(Option::is_none);
860- if mixed {
861- hit_do! {
862- SUB8_INTRA_RECT_HITS.with(|h| {
863- let mut st = h.get();
864- st[3] += 1;
865- h.set(st);
866- });
867- }
868- }
869837 // lane-sub8group: the group's chroma pieces, built where they are
870838 // written -- the pieces' refs/mvs/filters travel by value.
871839 let build = move |_y: &mut PlaneBuf<'static>,
@@ -1127,17 +1095,11 @@ pub(super) fn decode_intra_sub8_leaf(
11271095 dec.debug_state().0
11281096 );
11291097 }
1130- if (9..=12).contains(&uv_mode) {
1131- hit!(SMOOTH_UV_HITS);
1132- }
11331098 let alpha = if uv_mode == UV_CFL_PRED {
11341099 Some(read_cfl_alphas(dec, cdfs))
11351100 } else {
11361101 None
11371102 };
1138- if (V_PRED..=D67_PRED).contains(&uv_mode) {
1139- hit!(DIRECTIONAL_UV_HITS);
1140- }
11411103 (uv_mode, alpha)
11421104 } else {
11431105 (DC_PRED, None)
@@ -1160,9 +1122,6 @@ pub(super) fn decode_intra_sub8_leaf(
11601122 );
11611123 }
11621124 if use_fi != 0 {
1163- hit!(FILTER_INTRA_HITS);
1164- hit!(FILTER_INTRA_RECT_HITS);
1165- hit!(FILTER_INTRA_RECT_SUB8_HITS);
11661125 let fi = dec.symbol(&mut cdfs.filter_intra_mode);
11671126 if step {
11681127 eprintln!(
@@ -1201,10 +1160,6 @@ pub(super) fn decode_intra_sub8_leaf(
12011160 } else {
12021161 0
12031162 };
1204- if depth != 0 {
1205- hit!(TX_DEPTH_HITS);
1206- hit!(RECT8_SPLIT_TX_HITS);
1207- }
12081163 let split = depth != 0 || (lossless(fctx) && bw != bh);
12091164 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
12101165 let reach = if bw == bh {
@@ -1213,9 +1168,6 @@ pub(super) fn decode_intra_sub8_leaf(
12131168 Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx)
12141169 };
12151170 let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left);
1216- if smooth_neighbor {
1217- hit!(SMOOTH_LUMA_HITS);
1218- }
12191171 neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode);
12201172 let scan: &[u16] = if vert { &SCAN_4X8 } else { &SCAN_8X4 };
12211173 if split {
@@ -1481,14 +1433,6 @@ pub(super) fn decode_intra_sub8_leaf(
14811433 is_global_mv1: false,
14821434 },
14831435 );
1484- hit_do! {
1485- SUB8_INTRA_RECT_HITS.with(|h| {
1486- let mut s = h.get();
1487- s[usize::from(vert)] += 1;
1488- s[2] += usize::from(has_chroma);
1489- h.set(s);
1490- });
1491- }
14921436 // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map
14931437 // needs EVERY writer): a sub-8x8 group published no palette state, so
14941438 // once an 8x8 leaf of the same row can BE a palette block, the group
@@ -1608,10 +1552,6 @@ pub(super) fn decode_intra_sub8_leaf(
16081552 });
16091553 let mut chroma_stamped_per_unit = false;
16101554 let (u_grid, v_grid): (Grid, Grid) = if skip {
1611- if alpha.is_some() {
1612- hit!(CHROMA_SKIP_CFL_HITS);
1613- hit!(SKIP_CFL_HITS);
1614- }
16151555 if chroma_444 && bw != bh {
16161556 let zeros = Grid::Zero(bw * bh);
16171557 push_intra_rect(
@@ -1751,7 +1691,6 @@ pub(super) fn decode_intra_sub8_leaf(
17511691 // (`av1_set_contexts`); the tail's whole-leaf chroma
17521692 // stamp below is skipped for this shape.
17531693 neighbours.record_mi_chroma(tu_mi, 4, 4, plane_idx, &tu_grid);
1754- hit!(CHROMA_SPLIT_TX_HITS);
17551694 let dst = mu_units(if plane_idx == 1 { &mut uo } else { &mut vo }, bw * bh);
17561695 for row in 0..4 {
17571696 let start = (oy + row) * bw + ox;
@@ -1760,7 +1699,6 @@ pub(super) fn decode_intra_sub8_leaf(
17601699 }
17611700 }
17621701 chroma_stamped_per_unit = true;
1763- hit!(LLSUB8RECT444_CHROMA_WALK_HITS);
17641702 (
17651703 if uo.is_empty() {
17661704 Grid::Zero(bw * bh)
@@ -2001,13 +1939,6 @@ pub(super) fn decode_inter_sub8_rect2(
20011939 (8usize, 4usize)
20021940 };
20031941 let (w_mi, h_mi) = (bw / MI, bh / MI);
2004- hit_do! {
2005- SUB8_INTER_RECT_HITS.with(|c| {
2006- let mut h = c.get();
2007- h[usize::from(vert)] += 1;
2008- c.set(h);
2009- });
2010- }
20111942 let (gr, gc) = group_mi;
20121943 let (gpx, gpy) = (gc * MI, gr * MI);
20131944 let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx));
@@ -2155,9 +2086,6 @@ pub(super) fn decode_inter_sub8_rect2(
21552086 let (ref_width, ref_height) = ref_dims(ref_frame, refpix)?;
21562087 // lane-t900 r28: refusal lifted -- see the split arm above.
21572088 let luma_scale = scale_of((ref_width, ref_height), frame_size);
2158- if !luma_scale.is_unscaled() {
2159- hit!(SCALED_SUB8_HITS);
2160- }
21612089 let gm_table = build_gm_mv_table(
21622090 global_motion,
21632091 rmi,
@@ -2191,8 +2119,6 @@ pub(super) fn decode_inter_sub8_rect2(
21912119 tpl,
21922120 );
21932121 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
2194- if !not_new {
2195- }
21962122 let mut is_globalmv = false;
21972123 let (mv, is_new_mv) = if !not_new {
21982124 let mut idx = 0usize;
@@ -2217,8 +2143,6 @@ pub(super) fn decode_inter_sub8_rect2(
22172143 )
22182144 } else {
22192145 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
2220- if !not_zero {
2221- }
22222146 is_globalmv = !not_zero;
22232147 let mv = if !not_zero {
22242148 gm_table[(ref_frame - LAST_FRAME) as usize]
@@ -2266,9 +2190,6 @@ pub(super) fn decode_inter_sub8_rect2(
22662190 // `is_nontrans_global_motion` returns 0 for
22672191 // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model --
22682192 // so a GLOBALMV sub-block here always reads its interp filter.
2269- if is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation {
2270- hit!(GM_NONTRANS_SMALL_SIDE_HITS);
2271- }
22722193 let gm_nontrans = false;
22732194 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
22742195 dec,
@@ -2315,9 +2236,6 @@ pub(super) fn decode_inter_sub8_rect2(
23152236 // exactly that population -- so an unconditional hit proves only
23162237 // "a lossless sub-8 leaf was walked", not "the conjunct suppressed
23172238 // a tree". Guard it on the same term the conjunct uses.
2318- if fctx.tx_select_inter.with(std::cell::Cell::get) {
2319- hit!(SUB8_LOSSLESS_NO_VARTX);
2320- }
23212239 // lane-lossless2: `read_block_tx_size` returns TX_4X4 before it
23222240 // ever looks at `max_txsize_rect_lookup`, so an 8x4/4x8 leaf is
23232241 // TWO 4x4 units, not one rect one.
@@ -2845,7 +2763,6 @@ pub(super) fn decode_inter_sub8_rect2(
28452763 neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]);
28462764 neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]);
28472765 } else {
2848- hit!(CHROMA422_INTER_SUB8_HITS);
28492766 let (ug, _) = read_inter_plane(
28502767 dec,
28512768 cdfs,
@@ -2950,15 +2867,6 @@ pub(super) fn decode_inter_sub8_rect2(
29502867 // chroma-reference block's own mv, at the group's chroma origin
29512868 // (`row_start`/`col_start` shift `pre_x`/`pre_y` there either way).
29522869 let mixed = piece[0].is_none();
2953- if mixed {
2954- hit_do! {
2955- SUB8_INTRA_RECT_HITS.with(|h| {
2956- let mut s = h.get();
2957- s[3] += 1;
2958- h.set(s);
2959- });
2960- }
2961- }
29622870 let (piece_w, piece_h) = match (mixed, vert) {
29632871 (true, _) => (B4, B4),
29642872 (false, true) => (2usize, 4usize),
crates/ec-av1/src/encoder/tests.rsmodified+0 -11
@@ -1969,23 +1969,12 @@
19691969 };
19701970 let mut enc = Av1Encoder::new(config).unwrap();
19711971 let mut stream = Vec::new();
1972- let _ = crate::tile::take_sb128_root_hits();
19731972 for packet in encode_all(&mut enc, &sources) {
19741973 stream.extend_from_slice(&packet.data);
19751974 }
1976- let roots = crate::tile::take_sb128_root_hits();
1977- assert!(
1978- roots >= 4,
1979- "a 128x128-superblock clip coded {roots} superblock roots, wanted at least 4"
1980- );
1981- eprintln!("128x128 superblock roots: {roots}");
19821975
19831976 let ours = crate::stream::decode_stream(&stream).expect("our decoder");
19841977 assert_eq!(ours.len(), sources.len(), "our decoder's frames");
1985- assert!(
1986- crate::decode::part128_split_hits() >= 4,
1987- "our decoder read no 128x128 superblock root"
1988- );
19891978 let theirs = ffmpeg_decode_luma(&stream, width, height);
19901979 assert_eq!(theirs.len(), sources.len(), "ffmpeg's frames");
19911980 for (i, (a, b)) in ours.iter().zip(&theirs).enumerate() {
crates/ec-av1/src/film_grain.rsmodified+0 -16
@@ -22,7 +22,6 @@
2222 //! the frame it pushes onto its output `Vec<Picture>`, after saving the
2323 //! clean decode into the reference slot bank.
2424 use archmage::SimdToken;
25-use crate::hits::hit;
2625
2726 use crate::decode::WithRef;
2827 use crate::encode::Picture;
@@ -1440,14 +1439,9 @@ pub(crate) fn apply_grain(
14401439 ) -> Picture {
14411440 if !fg.apply_grain {
14421441 let clean = picture.clone();
1443- // lane-av1graincensus: this exit censuses too, so "the picture
1444- // `apply_grain` hands back is censused in its final form" is a property
1445- // of the FUNCTION rather than of one branch.
1446- crate::decode::census_unwritten_grained(&clean.y, &clean.u, &clean.v);
14471442 return clean;
14481443 }
14491444 fctx.grain_bit_depth.with(|c| c.set(bit_depth));
1450- hit!(GRAIN_HITS);
14511445 // lane-av1422grain: the chroma geometry is per-axis. `FrameCtx` already
14521446 // carries the sequence header's pair (`decode::set_subsampling`), and
14531447 // `apply_grain` runs inside the same frame context, so the chroma
@@ -2142,16 +2136,6 @@ pub(crate) fn apply_grain(
21422136 });
21432137 drop(parts);
21442138
2145- // lane-av1graincensus: the post-grain census, at the point the caller takes
2146- // the picture. `census_unwritten_final` runs in `stream.rs` BEFORE this
2147- // function, over the clean planes, and every filter writes in place into
2148- // that same buffer -- so the destination allocated above by `uninit_plane`
2149- // is the ONLY picture between that census and the caller that no census has
2150- // ever looked at. `lanes/unwritten-dep.report.md` §6/§8 declined to claim
2151- // anything about it; this measures it. `uninit_plane` poisons the buffer
2152- // under the same predicate, so the count is a measurement rather than a
2153- // coin flip on ambient garbage.
2154- crate::decode::census_unwritten_grained(&out.y, &out.u, &out.v);
21552139 out
21562140 }
21572141
crates/ec-av1/src/hits.rsdeleted+0 -47
@@ -1,47 +0,0 @@
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+0 -9
@@ -7,7 +7,6 @@
77 //! not this module's business -- the caller passes the samples it has, and the
88 //! edge is extended by repeating the last one, which is what the decoder does
99 //! with its own `BlockDecoded` bookkeeping (spec 7.11.2.2).
10-use crate::hits::hit;
1110
1211 /// The average of the neighbours (spec 7.11.2.5).
1312 pub const DC_PRED: u8 = 0;
@@ -283,13 +282,6 @@ pub(crate) fn predict(
283282 dst: &mut [u16], fctx: &crate::decode::FrameCtx,
284283 ) {
285284 assert_eq!(dst.len(), bw * bh, "the destination is the block");
286- match mode {
287- SMOOTH_PRED | SMOOTH_V_PRED | SMOOTH_H_PRED => {
288- hit!(SMOOTH_PRED_HITS);
289- }
290- PAETH_PRED => hit!(PAETH_PRED_HITS),
291- _ => {}
292- }
293285 let edges = Edges::build(above, left, corner, bw, bh, fctx);
294286 let is_directional = matches!(
295287 mode,
@@ -484,7 +476,6 @@ fn filter_intra_edge(buf: &mut [i32], strength: i32) {
484476 if strength == 0 {
485477 return;
486478 }
487- hit!(EDGE_FILTER_HITS);
488479 const KERNEL: [[i32; 5]; 3] = [[0, 4, 8, 4, 0], [0, 5, 6, 5, 0], [2, 4, 4, 4, 2]];
489480 let filt = usize::try_from(strength - 1).expect("a filter strength is never negative");
490481 let sz = buf.len() as i32;
crates/ec-av1/src/lib.rsmodified+0 -1
@@ -35,7 +35,6 @@ mod film_grain;
3535 pub use film_grain::apply_film_grain;
3636 mod filter_search;
3737 pub mod frame;
38-mod hits;
3938 pub mod intra;
4039 pub mod mc;
4140 pub mod motion;
crates/ec-av1/src/mc.rsmodified+0 -14
@@ -9,7 +9,6 @@
99 //! land on an even step; chroma vectors, once scaled for subsampling, can
1010 //! land on any of the 16.
1111 use archmage::SimdToken;
12-use crate::hits::hit;
1312
1413 /// `Round2` (spec 4.7): halves round up.
1514 fn round2(value: i32, shift: u32) -> i32 {
@@ -1473,7 +1472,6 @@ pub(crate) fn predict_with_filters_kern(
14731472 ) {
14741473 assert_eq!(dst.len(), block_w * block_h, "the destination is the block");
14751474 assert!(!reference.is_empty(), "a reference plane has samples");
1476- hit!(INTER_PRED_HITS);
14771475
14781476 #[cfg(test)]
14791477 let stage_t = crate::encode::stage_start();
@@ -1569,9 +1567,6 @@ pub(crate) fn predict_with_filters_kern(
15691567 // clamped read.
15701568 if xfrac != 0 || yfrac == 0 {
15711569 // fall through to the two-pass path
1572- if xfrac != 0 || yfrac != 0 {
1573- hit!(MC_SUBPEL_HITS);
1574- }
15751570 } else {
15761571 let top = y0 - 3;
15771572 if top >= 0
@@ -1761,9 +1756,6 @@ pub fn reset_rect_narrow_kern_hits() {
17611756 /// Bumps [`RECT_NARROW_KERN_HITS`] when the block's true dims pick a kernel
17621757 /// the destination buffer's dims would not have.
17631758 fn note_narrow_kern(block_w: usize, block_h: usize, kern_w: usize, kern_h: usize) {
1764- if (kern_w <= 4) != (block_w <= 4) || (kern_h <= 4) != (block_h <= 4) {
1765- hit!(RECT_NARROW_KERN_HITS);
1766- }
17671759 }
17681760
17691761 /// Current value of [`INTER_PRED_HITS`].
@@ -2052,8 +2044,6 @@ pub(crate) fn predict_scaled_kern(
20522044 ) {
20532045 assert_eq!(dst.len(), block_w * block_h, "the destination is the block");
20542046 assert!(!reference.is_empty(), "a reference plane has samples");
2055- hit!(INTER_PRED_HITS);
2056- hit!(PREDICT_SCALED_HITS);
20572047
20582048 let max = crate::decode::sample_max(fctx);
20592049 let (round0, round1) = round_pair(u32::from(crate::decode::bit_depth(fctx)));
@@ -2279,11 +2269,7 @@ pub(crate) fn predict_compound_intermediate_kern(
22792269 ) {
22802270 assert_eq!(dst.len(), block_w * block_h, "the destination is the block");
22812271 assert!(!reference.is_empty(), "a reference plane has samples");
2282- hit!(INTER_PRED_HITS);
22832272
2284- if !scale.is_unscaled() {
2285- hit!(PREDICT_SCALED_HITS);
2286- }
22872273 let x_scale_fp = scale.x;
22882274 if scale.y != REF_NO_SCALE {
22892275 let (round0, _) = round_pair(u32::from(crate::decode::bit_depth(fctx)));
crates/ec-av1/src/motion_field.rsmodified+0 -7
@@ -5,7 +5,6 @@
55 //! (`av1/common/mvref_common.c`) and the projection math `add_tpl_ref_mv`
66 //! (same file) applies a second time, per query block, against the block's
77 //! own single reference frame.
8-use crate::hits::hit;
98
109 use crate::mvstack::{ALTREF_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME};
1110
@@ -428,12 +427,6 @@ pub fn setup_motion_field<M: std::borrow::Borrow<MotionField>>(
428427 && slot_of(rf).is_some_and(|m| m.is_intra)
429428 })
430429 .count();
431- if intra_forward_refs >= 1 {
432- hit!(REFSTAMP_INTRA_FRAMES);
433- }
434- if intra_forward_refs >= 2 {
435- hit!(REFSTAMP_INTRA2_FRAMES);
436- }
437430
438431 if let Some(last) = slot_of(LAST_FRAME) {
439432 let alt_of_lst = last.ref_order_hints[(ALTREF_FRAME - LAST_FRAME) as usize];
crates/ec-av1/src/mvstack.rsmodified+0 -21
@@ -77,7 +77,6 @@
7777 //! added by the row/col scan), and the "extra search" that pads a short
7878 //! stack to two entries (spec 7.10.2.12) — this module's stack can be
7979 //! shorter than two candidates where libaom's never is.
80-use crate::hits::hit;
8180
8281 thread_local! {
8382 /// How many query blocks [`find_mv_stack_with_sign_bias`] has folded at
@@ -693,7 +692,6 @@ fn add_candidate(candidates: &mut StackVec, mv: (i32, i32), weight: u32) {
693692 if let Some(entry) = candidates.iter_mut().find(|e| e.mv == mv) {
694693 entry.weight += weight;
695694 } else if candidates.len() >= MAX_STACK_SIZE {
696- hit!(STACK_FULL_DROPS);
697695 } else {
698696 // libaom `add_ref_mv_candidate` (mvref_common.c:100) and
699697 // `add_tpl_ref_mv` (:388) only push when
@@ -1174,9 +1172,6 @@ fn clamp_mv_ref(
11741172 let (row, col) = mv;
11751173 let clamped_row = row.clamp(to_top - bh8 - MV_BORDER, to_bottom + bh8 + MV_BORDER);
11761174 let clamped_col = col.clamp(to_left - bw8 - MV_BORDER, to_right + bw8 + MV_BORDER);
1177- if clamped_row != row || clamped_col != col {
1178- hit!(MV_CLAMP_EDGE_OVERHANG_HITS);
1179- }
11801175 }
11811176
11821177 let (row, col) = mv;
@@ -1414,9 +1409,6 @@ pub fn find_mv_stack_with_sign_bias(
14141409 // (and so the stack ORDER) even though `MiGrid::get` already returns
14151410 // `None` for the cells outside the tile.
14161411 let (tile_row0, tile_col0) = grid.tile_origin();
1417- if tile_row0 > 0 || tile_col0 > 0 {
1418- hit!(TILE_REACH_CLIPS);
1419- }
14201412 let max_row_offset: isize = if mi_row > tile_row0 {
14211413 let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj);
14221414 reach.max(tile_row0 as isize - mi_row as isize)
@@ -1583,9 +1575,6 @@ pub fn find_mv_stack_with_sign_bias(
15831575 }
15841576 }
15851577 }
1586- if any_hit {
1587- hit!(TMV_HITS);
1588- }
15891578 zero_mv_ctx = usize::from(first_sample_missing || first_sample_far);
15901579 }
15911580
@@ -1931,7 +1920,6 @@ fn add_compound_candidate(
19311920 if let Some(entry) = candidates.iter_mut().find(|e| e.mv0 == mv0 && e.mv1 == mv1) {
19321921 entry.weight += weight;
19331922 } else if candidates.len() >= MAX_STACK_SIZE {
1934- hit!(STACK_FULL_DROPS);
19351923 } else {
19361924 // Same insertion cap as [`add_candidate`]: libaom's compound branch
19371925 // of `add_ref_mv_candidate` (mvref_common.c:128) and `add_tpl_ref_mv`
@@ -2215,9 +2203,6 @@ fn combine_compound_candidates(
22152203 .collect();
22162204 std::array::from_fn(|i| {
22172205 merged.get(i).copied().unwrap_or_else(|| {
2218- if gm_mv_candidates[side] != (0, 0) {
2219- hit!(COMP_GM_FILL_HITS);
2220- }
22212206 gm_mv_candidates[side]
22222207 })
22232208 })
@@ -2274,9 +2259,6 @@ pub fn find_mv_stack_compound(
22742259 // (and so the stack ORDER) even though `MiGrid::get` already returns
22752260 // `None` for the cells outside the tile.
22762261 let (tile_row0, tile_col0) = grid.tile_origin();
2277- if tile_row0 > 0 || tile_col0 > 0 {
2278- hit!(TILE_REACH_CLIPS);
2279- }
22802262 let max_row_offset: isize = if mi_row > tile_row0 {
22812263 let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj);
22822264 reach.max(tile_row0 as isize - mi_row as isize)
@@ -2441,9 +2423,6 @@ pub fn find_mv_stack_compound(
24412423 }
24422424 }
24432425 }
2444- if any_hit {
2445- hit!(TMV_HITS);
2446- }
24472426 zero_mv_ctx = usize::from(first_sample_missing || first_sample_far);
24482427 }
24492428
crates/ec-av1/src/quant.rsmodified+0 -6
@@ -216,7 +216,6 @@ pub fn dequant_coeff_wh(
216216 dq2.clamp(-bound, bound - 1) as i32
217217 }
218218
219-use crate::hits::hit_do;
220219
221220 thread_local! {
222221 /// lane-av1-qmatrix: transform units whose dequantisation actually
@@ -304,11 +303,6 @@ pub fn dequant_wh_into(
304303 let dq2 = sign * ((dq.abs() & 0xFF_FFFF) / denom);
305304 dq2.clamp(-bound, bound - 1) as i32
306305 };
307- hit_do! {
308- if qm.is_some() && levels.iter().any(|&l| l != 0) {
309- QM_SCALED_UNITS.with(|c| c.set(c.get() + 1));
310- }
311- }
312306 out.clear();
313307 out.reserve(levels.len());
314308 out.extend(
crates/ec-av1/src/restoration.rsmodified+0 -14
@@ -4,7 +4,6 @@
44 //! two pixel filters (Wiener, self-guided/SGR). See `lanes/lr.report.md` for
55 //! the full derivation (libaom `decodeframe.c`/`restoration.c` line refs).
66 use archmage::SimdToken;
7-use crate::hits::hit;
87
98 use crate::msac::SymbolDecoder;
109 use ec_av1_syntax::obu::floor_log2;
@@ -648,23 +647,19 @@ fn read_lr_unit(
648647 ) -> UnitFilter {
649648 match ftype {
650649 RestorationType::Switchable => {
651- hit!(SWITCHABLE_HITS);
652650 let t = dec.symbol(&mut cdfs.restore_switchable);
653651 match t {
654652 0 => UnitFilter::None,
655653 1 => {
656- hit!(WIENER_HITS);
657654 UnitFilter::Wiener(read_wiener_filter(dec, chroma, &mut reference.0))
658655 }
659656 _ => {
660- hit!(SGRPROJ_HITS);
661657 UnitFilter::Sgrproj(read_sgrproj_filter(dec, &mut reference.1))
662658 }
663659 }
664660 }
665661 RestorationType::Wiener => {
666662 if dec.symbol(&mut cdfs.restore_wiener) != 0 {
667- hit!(WIENER_HITS);
668663 UnitFilter::Wiener(read_wiener_filter(dec, chroma, &mut reference.0))
669664 } else {
670665 UnitFilter::None
@@ -673,7 +668,6 @@ fn read_lr_unit(
673668 RestorationType::Sgrproj => {
674669 let bit = dec.symbol(&mut cdfs.restore_sgrproj);
675670 if bit != 0 {
676- hit!(SGRPROJ_HITS);
677671 UnitFilter::Sgrproj(read_sgrproj_filter(dec, &mut reference.1))
678672 } else {
679673 UnitFilter::None
@@ -1508,14 +1502,6 @@ fn filter_restoration_unit(
15081502 let nominal_h = full_stripe_height - if frame_stripe == 0 { runit_offset } else { 0 };
15091503 let h = nominal_h.min(unit_h - i);
15101504 let stripe_v_end = stripe_v_start + h;
1511- if !matches!(filter, UnitFilter::None) {
1512- if stripe_v_start == 0 {
1513- hit!(LR_STRIPE0_HITS);
1514- }
1515- if stripe_v_end == plane_h && h < nominal_h {
1516- hit!(LR_LAST_STRIPE_HITS);
1517- }
1518- }
15191505 match filter {
15201506 UnitFilter::Wiener(info) => apply_wiener_stripe(
15211507 out,
crates/ec-av1/src/stream/mod.rsmodified+0 -380
@@ -38,314 +38,6 @@ fn no_grain() -> bool {
3838
3939
4040
41-/// 32x32-level 1:4 strip counters, for `decode_probe`'s fixture search:
42-/// (HORZ_4 strips, VERT_4 strips, strips that read coefficients).
43-/// lane-inter4 r1: the INTER-frame partition counters this lane's gates
44-/// assert -- `(32x8, 8x32, 64x32, 32x64, 64x16, 16x64)` strips decoded.
45-pub fn inter_rect_counters() -> (usize, usize, usize, usize, usize, usize) {
46- (
47- crate::decode::rect4_32_horz_inter_hits(),
48- crate::decode::rect4_32_vert_inter_hits(),
49- crate::decode::inter_sb_horz_hits(),
50- crate::decode::inter_sb_vert_hits(),
51- crate::decode::inter_sb_horz4_hits(),
52- crate::decode::inter_sb_vert4_hits(),
53- )
54-}
55-
56-/// lane-r14 r2: luma transform units of an inter strip with a 64-px axis,
57-/// coded as the truncated low-32 coefficient corner.
58-pub fn rect64_inter_tu_hits() -> usize {
59- crate::decode::rect64_inter_tu_hits()
60-}
61-
62-/// lane-rectres r1: whole-block luma transform units of a 32x32-level 1:4
63-/// inter strip (`TX_32X8`/`TX_8X32`), `[32x8, 8x32]`.
64-pub fn rect32x8_inter_tu_hits() -> [usize; 2] {
65- crate::decode::rect32x8_inter_tu_hits()
66-}
67-
68-/// lane-t900 r7: sub-8x8 inter groups whose one chroma unit inherited a
69-/// `tx_type` different from the group's FIRST sub-block, i.e. groups that can
70-/// only decode right under `av1_get_tx_type`'s chroma-reference rule.
71-pub fn sub8_chroma_tx_from_ref_hits() -> usize {
72- crate::decode::sub8_chroma_tx_from_ref_hits()
73-}
74-
75-/// lane-intra16x4: `(16x4, 4x16, chroma-reference)` INTRA strips decoded inside
76-/// an inter 16x16-level 1:4 partition.
77-pub fn intra16x4_in_inter_hits() -> (usize, usize, usize) {
78- crate::decode::intra16x4_in_inter_hits()
79-}
80-
81-/// lane-sub8intra: INTRA 8x4/4x8 leaves inside an inter frame's sub-8x8
82-/// HORZ/VERT partition, `(8x4, 4x8, chroma-reference, mixed groups, split
83-/// 4x4 leaves)`.
84-pub fn sub8_intra_rect_hits() -> (usize, usize, usize, usize, usize) {
85- crate::decode::sub8_intra_rect_hits()
86-}
87-
88-/// lane-r14 r3: RECTANGULAR var-tx leaf transform units, `[32x16, 16x32]` --
89-/// the leaves `sub_tx_size_map` produces when a 1:4 strip with a 64-px axis
90-/// splits its transform (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`).
91-pub fn vartx_rect_leaf_hits() -> [usize; 2] {
92- crate::decode::vartx_rect_leaf_hits()
93-}
94-
95-/// How many rect intra strips read the `use_intrabc` symbol on the last decode.
96-pub fn rect_intrabc_reads() -> usize {
97- crate::decode::rect_intrabc_reads()
98-}
99-
100-/// lane-av1-ibc444rect: unskipped intrabc 8x4/4x8 leaves whose luma a lossless
101-/// frame walked as per-4x4 inter units.
102-pub fn intrabc_rect8_lossless_luma_hits() -> usize {
103- crate::decode::intrabc_rect8_lossless_luma_hits()
104-}
105-
106-/// lane-av1-ibc444rect: unskipped intrabc 8x4/4x8 leaves whose chroma a
107-/// lossless 4:4:4 frame walked as per-4x4 `Chroma4` units.
108-pub fn intrabc_rect8_lossless_chroma_hits() -> usize {
109- crate::decode::intrabc_rect8_lossless_chroma_hits()
110-}
111-
112-/// Gate-side reset for the lane-av1-ibc444rect counters above.
113-pub fn reset_ibc444rect_hits() {
114- crate::decode::reset_ibc444rect_hits()
115-}
116-
117-/// lane-av1chromarect: 128-root intra-BC HORZ/VERT strips whose chroma plane
118-/// block was sized `bw >> ss_x` by `bh >> ss_y` rather than the hardcoded
119-/// 4:2:0 halving -- i.e. the 4:4:4 (and 4:4:0) cells, where
120-/// `av1_get_max_uv_txsize` (`ss_size_lookup[bsize]`, blockd.h:1372) applies no
121-/// halving of its own. At 4:2:0 the two forms are the same arithmetic, so a
122-/// `>= 1` witness can only come from a stream that is not 4:2:0. EXCLUSIVE to
123-/// `decode_intrabc_owned_rect`: no other caller sizes a 128-root intra-BC
124-/// strip's chroma plane block.
125-pub fn ibc_owned_rect_chroma_footprint_444_hits() -> usize {
126- crate::decode::ibc_owned_rect_chroma_footprint_444_hits()
127-}
128-
129-/// Gate-side reset for the lane-av1chromarect counter above.
130-pub fn reset_ibc_owned_rect_chroma_footprint_444_hits() {
131- crate::decode::reset_ibc_owned_rect_chroma_footprint_444_hits()
132-}
133-
134-/// lane-av1chromadc: chroma units of a skipped block whose intra-BC / UV
135-/// palette override had to be windowed to the unit's own extent -- `cn_cols *
136-/// cn_rows > 1`, which at 4:2:0 never happens and at 4:4:4 is every block of
137-/// 64 and above. Counts UNITS. EXCLUSIVE to `decode_block`'s skipped square
138-/// block chroma walk.
139-pub fn skip_chroma_override_window_hits() -> usize {
140- crate::decode::skip_chroma_override_window_hits()
141-}
142-
143-/// Gate-side reset for the lane-av1chromadc counter above.
144-pub fn reset_skip_chroma_override_window_hits() {
145- crate::decode::reset_skip_chroma_override_window_hits()
146-}
147-
148-/// lane-av1rectreach: the `chroma_tiled` walk's per-unit reach and grid-shape
149-/// counters, as `(unit_reach_differs_from_block, 2x1 units, 1x2 units, other
150-/// multi-unit units)`. See [`crate::decode::rect_tiled_chroma_grid_hits`].
151-pub fn rect_tiled_chroma_grid_hits() -> (usize, usize, usize, usize) {
152- crate::decode::rect_tiled_chroma_grid_hits()
153-}
154-
155-/// Gate-side reset for the lane-av1rectreach counters above.
156-pub fn reset_rect_tiled_chroma_grid_hits() {
157- crate::decode::reset_rect_tiled_chroma_grid_hits()
158-}
159-
160-/// `(y, uv)` palette blocks RECONSTRUCTED inside an inter frame (lane-t900
161-/// r22) -- the counter a screen-content witness gate reads to prove it
162-/// exercises the inter-frame palette path, not the key frame's.
163-pub fn intra_in_inter_palette_hits() -> (usize, usize) {
164- crate::decode::intra_in_inter_palette_hits()
165-}
166-
167-/// `(y, uv)` palette blocks reconstructed on an 8x8 LEAF inside an inter
168-/// frame (lane-t900 r23) -- the site-specific half of
169-/// [`intra_in_inter_palette_hits`], which a >=16 block also moves.
170-pub fn inter8_palette_hits() -> (usize, usize) {
171- crate::decode::inter8_palette_hits()
172-}
173-
174-/// lane-rect64port r1: coded 64-level HORZ/VERT intra strips whose luma
175-/// transform unit is the un-split TX_64X32 (orient 0) / TX_32X64 (orient 1).
176-pub fn rect64_corner_tu_hits(orient: usize) -> usize {
177- crate::decode::rect64_corner_tu_hits(orient)
178-}
179-
180-/// lane-inter16ab r4: RECTANGULAR var-tx leaves with a 4-px axis, `[8x4, 4x8]`
181-/// -- what `sub_tx_size_map[TX_16X4] == TX_8X4` produces when a 16x16-level
182-/// 1:4 inter strip splits its transform.
183-pub fn vartx_rect_leaf4_hits() -> [usize; 2] {
184- crate::decode::vartx_rect_leaf4_hits()
185-}
186-
187-/// lane-inter16ab r5: COMPOUND_WEDGE / wedge-INTERINTRA blocks that used a
188-/// RECTANGULAR wedge codebook row, per shape (`RECT_WEDGE_SHAPES` order:
189-/// 8x16, 16x8, 16x32, 32x16, 8x32, 32x8).
190-pub fn rect_wedge_hits() -> [usize; 6] {
191- crate::decode::rect_wedge_hits()
192-}
193-
194-/// lane-inter16ab r5: the wedge-interintra half of [`rect_wedge_hits`].
195-pub fn rect_wii_hits() -> [usize; 6] {
196- crate::decode::rect_wii_hits()
197-}
198-
199-/// lane-sb128c r7: the 128 root's rect arms -- (gathered edge HORZ, gathered
200-/// edge VERT, inter 128x64 blocks, inter 64x128 blocks).
201-pub fn sb128_rect_counters() -> (usize, usize, usize, usize) {
202- (
203- crate::decode::part128_edge_horz_hits(),
204- crate::decode::part128_edge_vert_hits(),
205- crate::decode::inter_sb128_horz_hits(),
206- crate::decode::inter_sb128_vert_hits(),
207- )
208-}
209-
210-/// lane-av1-ibcrect: the 128 root's interior partition arms plus the key-frame
211-/// intra 128-axis blocks -- (split, none, horz, vert, ab[4], intra_horz,
212-/// intra_vert). Non-zero horz/vert mean a stream carried real PARTITION_HORZ/
213-/// VERT at the 128 root, so an intrabc-rect hunt can tell "the partition was
214-/// never chosen" from "chosen and decoded intra (or refused)".
215-pub fn part128_census() -> (usize, usize, usize, usize, [usize; 4], usize, usize) {
216- (
217- crate::decode::part128_split_hits(),
218- crate::decode::part128_none_hits(),
219- crate::decode::part128_horz_hits(),
220- crate::decode::part128_vert_hits(),
221- crate::decode::part128_ab_hits(),
222- crate::decode::intra_sb128_hits().0,
223- crate::decode::intra_sb128_hits().1,
224- )
225-}
226-
227-/// lane-av1-ibcrect: `use_intrabc` blocks on a 128-root HORZ/VERT strip whose
228-/// reconstruction ([`crate::decode::decode_intrabc_128rect`]) ran -- the
229-/// engagement counter the sb128 intrabc-rect gate asserts on.
230-pub fn intrabc_128rect_hits() -> usize {
231- crate::decode::intrabc_128rect_hits()
232-}
233-
234-/// lane-av1-ibc128chunk: chroma transform units the 128-root intrabc strip's
235-/// mu-chunk walk read, one per `read_inter_plane` chroma call. At 4:2:2 a
236-/// 64x64 mu chunk's chroma plane block is 32x64 and holds TWO STACKED
237-/// TX_32X32 units per plane; the square-cut walk this gate witnesses read
238-/// one. Measured on the pinned witness: 8 before, 48 after.
239-pub fn intrabc_128rect_chroma_chunk_hits() -> usize {
240- crate::decode::intrabc_128rect_chroma_chunk_hits()
241-}
242-
243-/// lane-av1-ibc128chunk: the 128-root intrabc strip's per-axis chroma chunk
244-/// extents as `(64 >> ss_x) << 8 | (64 >> ss_y)` on the last chunk walked --
245-/// 32|32 at 4:2:0, 32|64 at 4:2:2, 64|64 at 4:4:4.
246-pub fn intrabc_128rect_chunk_shape() -> usize {
247- crate::decode::intrabc_128rect_chunk_shape()
248-}
249-
250-/// Blocks reconstructed with intra block copy at an 8x8 LEAF specifically
251-/// (lane-kf900 r7's shape); [`crate::decode::intrabc_hits`] counts every shape.
252-pub fn leaf8_intrabc_hits() -> usize {
253- crate::decode::leaf8_intrabc_hits()
254-}
255-
256-/// Blocks whose `use_intrabc` symbol came out 1 and took the DV path, at ANY
257-/// shape -- the engagement counter the intrabc gates assert on. It counts
258-/// "read a `use_intrabc` DV", not "reconstructed": a block the rect-strip
259-/// reader REFUSES for an unported shape bumps it too (the symbol and the DV
260-/// are parsed before the refusal). [`leaf8_intrabc_hits`] is its 8x8-leaf
261-/// subset.
262-pub fn intrabc_hits() -> usize {
263- crate::decode::intrabc_hits()
264-}
265-
266-/// lane-av1txbands: sub-8x8 group chroma-reference leaves that USED intrabc and
267-/// were SKIPPED -- the route that armed [`crate::decode::intrabc_hits`]'s chroma
268-/// transform slot and then read no chroma coefficient. A non-zero value is what
269-/// makes the disarm at that route load-bearing on a real stream.
270-pub fn skipped_intrabc_chroma_arm_hits() -> usize {
271- crate::decode::skipped_intrabc_chroma_arm_hits()
272-}
273-
274-/// lane-sb128c r8: the 128 root's INTRA (key-frame) rect arm -- (128x64
275-/// blocks, 64x128 blocks, blocks per resolved intra `tx_depth` 0/1/2).
276-pub fn intra_sb128_counters() -> (usize, usize, [usize; 3]) {
277- crate::decode::intra_sb128_hits()
278-}
279-
280-/// lane-inter128intra r1: the 128 root's HORZ/VERT half coded INTRA inside an
281-/// INTER frame -- (128x64 blocks, 64x128 blocks).
282-pub fn intra128_in_inter_counters() -> [usize; 2] {
283- crate::decode::intra128_in_inter_hits()
284-}
285-
286-/// lane-lossless128: intra 128-axis blocks decoded on a LOSSLESS frame, where
287-/// every plane is a TX_4X4 unit. The engagement counter for
288-/// `a_lossless_sb128_rect_intra_block_decodes_sample_exact`.
289-pub fn intra128_lossless_counters() -> usize {
290- crate::decode::intra128_lossless_hits()
291-}
292-
293-/// lane-av1-128rectspan: chroma transform units re-stamped by
294-/// `decode_block_128rect`'s end-of-block replay, and how many of those
295-/// replays stamped a height that was not the unit's own.
296-/// lane-av1422lift: the second half was described as "the 4:2:2 signature --
297-/// zero on every stream this decoder admits, since 4:2:2 is refused by name
298-/// at the sequence header", and that was TRUE. 4:2:2 is decoded now and the
299-/// mismatch is NOT zero: measured on this branch's tip, the two
300-/// `422_intrabc_sb128_strip*` pins each read `(72, 9)` while the other 19
301-/// committed 4:2:2 cells read `(0, 0)`. Those two pins are byte-exact
302-/// against ffmpeg, so the non-zero half counts the arm's own designed case
303-/// and is not a defect. lane-av1422mismatch9: the predicate is
304-/// `luma_span != luma_span_h` (`chroma_tx << ss_x` vs `<< ss_y`), true by
305-/// CONSTRUCTION at ss (1,0), and the replay re-stamps with the same per-axis
306-/// pair the in-loop walk used, so the counter is a 4:2:2 shape test, not a
307-/// divergence test (`record_mi_chroma` writes only the left/above context
308-/// arrays, never a pixel). One 4:2:2 gate now reads the pair and asserts the
309-/// measured `(72, 9)`:
310-/// `the_422_block_128rect_chroma_chunk_gather_stays_per_axis`; the other
311-/// reader is on a 4:4:4 stream, where the mismatch half is structurally zero.
312-pub fn sb128rect_chroma_replay_counters() -> (usize, usize) {
313- crate::decode::sb128rect_chroma_replay_hits()
314-}
315-
316-/// lane-sb128c r9: the four AB shapes at the 128 root, in `PARTITION_HORZ_A`,
317-/// `_HORZ_B`, `_VERT_A`, `_VERT_B` order (key and inter tile paths share the
318-/// counter -- it is bumped where the root symbol resolves).
319-pub fn sb128_ab_counters() -> [usize; 4] {
320- crate::decode::part128_ab_hits()
321-}
322-
323-/// lane-obmcrec r1: OBMC neighbours taken from the second half of a 1:4-strip
324-/// chroma pair -- the shape whose filter record the r1 fix re-sourced.
325-pub fn obmc_pair_filter_hits() -> usize {
326- crate::decode::obmc_pair_filter_hits()
327-}
328-
329-/// Gate counters for the 4x32/32x4 rectangular strips: `(horz, vert, coeff)` hits.
330-pub fn rect4_32_counters() -> (usize, usize, usize) {
331- (
332- crate::decode::rect4_32_horz_hits(),
333- crate::decode::rect4_32_vert_hits(),
334- crate::decode::rect4_coeff_hits(),
335- )
336-}
337-
338-/// lane-inter4 r4: rectangular inter transform units coded whole, rect
339-/// var-tx trees that split, and OBMC blends run on a 16x8/8x16 leaf -- the
340-/// three counters a recipe sweep needs to see from outside the crate.
341-pub fn rect_inter_tu_counters() -> (usize, usize, usize) {
342- (
343- crate::decode::rect_inter_tu_hits(),
344- crate::decode::rect_inter_txsplit_hits(),
345- crate::decode::obmc_rect_leaf_hits(),
346- )
347-}
348-
34941 /// Decode every frame in a raw AV1 OBU stream, in coding order.
35042 ///
35143 /// A key frame becomes the reference for the inter frames that follow it,
@@ -2249,14 +1941,6 @@ fn decode_frame(
22491941 // 4:2:0 one never inherits the wrong plane count.
22501942 crate::decode::set_mono(seq.mono_chrome, fctx);
22511943 crate::decode::set_subsampling(seq.subsampling_x, seq.subsampling_y, fctx);
2252- // lane-av1readcensus: the coefficient-unit census is armed here, off the
2253- // same sequence-header subsampling. lane-av1422census422 widened it from
2254- // 4:4:4-only to "any format with an unsubsampled luma axis", so a 4:2:2
2255- // cell's per-plane unit counts are readable and a 4:2:2 gate can assert
2256- // a non-vacuous walk; 4:2:0 still reads zero, so the 4:2:0 control in
2257- // `a_pixel_exact_444_stream_walks_the_same_coefficient_units_the_oracle_does`
2258- // keeps asserting exactly that.
2259- crate::decode::set_census_nonsub(seq.subsampling_x, seq.subsampling_y);
22601944 // lane-av1txr: spec 5.9.2 `disable_cdf_update` -- a frame that sets it
22611945 // codes every tile symbol against the CDFs it started with, so the tile
22621946 // readers must not adapt (libaom `decodeframe.c:2909`:
@@ -2503,46 +2187,6 @@ fn decode_frame(
25032187 // *initial* table into the slots it refreshes, not the adapted
25042188 // end-of-tile one.
25052189 let stored_cdfs = stored_cdfs_for(header, end_cdfs, started_from);
2506- // lane-hidden r1: the frame exactly as it is about to be stored into
2507- // the reference slots -- after deblock/CDEF/LR/superres, in DECODE
2508- // order, hidden (`show_frame == 0`) alt-ref frames included, and
2509- // bit-depth correct (8-bit as u8, 10/12-bit as u16 LE) unlike the
2510- // u8-narrowing diagnostic dumps above. Matches the instrumented
2511- // aomdec's own `EC_AV1_FINAL_DUMP` rung byte for byte
2512- // (scripts/instrument-aom-oracle.sh rung 12), which is what makes a
2513- // hidden frame's pixels comparable at all.
2514- // lane-unwritten-dep: the census AT the output point, beside the dump that
2515- // defines "the output" -- the same bytes, so the claim is about the frame the
2516- // caller receives rather than about an intermediate stage.
2517- //
2518- // WHAT THIS IS FOR, corrected: an earlier revision of this comment said the
2519- // pre-deblock plane was byte-identical plain-vs-sentinel and that deblock
2520- // creates the dependence. That was wrong, and it was `dump_stage16`'s fault:
2521- // it cropped chroma as `(fw/2, fh/2)`, a 4:2:0 assumption, so on a 64x64
2522- // 4:2:2 frame 2048 chroma samples appeared in no stage dump at all -- exactly
2523- // the region the difference lives in. With per-axis extents the corrected
2524- // measurement on `440_request_is_422` is that the PRE-DEBLOCK dump already
2525- // differs by 2158 bytes and an exact u16 census finds 224 unwritten samples
2526- // (U 112, V 112, rows 36..63) -- the same count `lanes/av1unwritten.report.md`
2527- // reports. The hole is present before any filter runs, and the pre-deblock
2528- // census SEES it.
2529- //
2530- // So this second census is not a patch for a blind pre-deblock scan. It is
2531- // the measurement taken where the reference-bank bytes are taken, which
2532- // covers the whole span from the tile walk to those bytes: every filter
2533- // writes IN PLACE into the very buffer this scans, so nothing a later
2534- // filter does can open a hole outside its extent.
2535- //
2536- // lane-av1graincensus, the scope correction this comment needed: "to the
2537- // caller's frame" was WRONG, and this call is not what makes it right.
2538- // `apply_grain` runs after this and ALLOCATES a fresh picture
2539- // (`film_grain::uninit_plane`, `with_capacity` + `set_len`, no fill), so
2540- // that destination never passes through here. The claim over the PRE-GRAIN
2541- // planes -- the bytes the reference bank stores and every later frame
2542- // predicts from -- is what this line supports; the grained picture the
2543- // caller receives is censused by `decode::census_unwritten_grained`, at
2544- // `apply_grain`'s own return, over its own counters.
2545- decode::census_unwritten_final(&picture.y, &picture.u, &picture.v);
25462190 if let Some(why) = fctx.corrupt.get() {
25472191 return Err(Error::corrupt(format!("AV1 frame {decode_idx}: {why}")));
25482192 }
@@ -2554,29 +2198,5 @@ fn decode_frame(
25542198 })
25552199 }
25562200
2557-/// lane-intra14 r1: INTRA-coded 1:4 strips decoded on the INTER block path
2558-/// (64x16, 16x64, 32x8, 8x32) -- the counters a recipe sweep needs from
2559-/// outside the crate.
2560-pub fn intra_rect4_in_inter_counters() -> (usize, usize, usize, usize) {
2561- (
2562- crate::decode::intra_rect4_strip_in_inter_hits(0),
2563- crate::decode::intra_rect4_strip_in_inter_hits(1),
2564- crate::decode::intra_rect4_strip_in_inter_hits(2),
2565- crate::decode::intra_rect4_strip_in_inter_hits(3),
2566- )
2567-}
2568-
2569-/// lane-av1recipehunt: the recipe sweep's view of the `delta_q` story from
2570-/// OUTSIDE the crate -- `(delta_q symbol groups read, rect64 dequant calls that
2571-/// saw `CURRENT_Q_IDX != base_q_idx`)`. A recipe that reads delta_q but never
2572-/// lands one inside a rect64 root is a different failure from one that reads
2573-/// neither, and the gate can only tell them apart with both numbers.
2574-pub fn rect64_qidx_drift_counters() -> (usize, usize) {
2575- (
2576- crate::decode::delta_q_hits(),
2577- crate::decode::rect64_qidx_drift_hits(),
2578- )
2579-}
2580-
25812201 #[cfg(test)]
25822202 pub(crate) mod tests;
crates/ec-av1/src/superres.rsmodified+0 -2
@@ -10,7 +10,6 @@
1010 //! Every constant and the 64x8 `av1_resize_filter_normative` coefficient
1111 //! table below is copied verbatim from libaom `aom_dsp/aom_filter.h` and
1212 //! `av1/common/resize.c` (`AOM_VERSION=v3.13.3`, `~/.cache/aom-oracle`).
13-use crate::hits::hit;
1413
1514 /// `RS_SUBPEL_BITS`.
1615 const RS_SUBPEL_BITS: u32 = 6;
@@ -185,7 +184,6 @@ pub(crate) fn superres_hits() -> usize {
185184
186185 /// Counts one whole upscaled picture (all three planes) for [`SUPERRES_HITS`].
187186 pub(crate) fn note_upscaled_picture() {
188- hit!(SUPERRES_HITS);
189187 }
190188
191189 #[cfg(test)]