diff --git a/crates/ec-av1/Cargo.toml b/crates/ec-av1/Cargo.toml index 923d67da..2bbf335b 100644 --- a/crates/ec-av1/Cargo.toml +++ b/crates/ec-av1/Cargo.toml @@ -12,13 +12,5 @@ ec-av1-syntax.workspace = true archmage = "=0.9.31-beta.1" bytemuck = "1" -[features] -default = ["gate-counters"] -# Compiles the ~550 `*_HITS` gate counters (see `src/hits.rs`). ON by default so -# every test gate and the probe's census see the same numbers they always have; -# a shipped decoder can build `--no-default-features` to drop the TLS bump on -# each counted path -- the `*_hits()` accessors still compile and return 0. -gate-counters = [] - [dev-dependencies] ec-testkit.workspace = true diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs deleted file mode 100644 index 6b33a90c..00000000 --- a/crates/ec-av1/examples/decode_probe.rs +++ /dev/null @@ -1,532 +0,0 @@ -//! Where does a real stream stop? Decode one AV1 file and print the answer. -//! -//! The gates in [`ec_av1::stream`] each pin one capability against one encoder -//! recipe. This asks the complementary question -- given a stream someone -//! actually produced, which refusal comes first -- and it is how the refusal -//! distribution in commit 2be815f was measured rather than reasoned about: -//! -//! ```text -//! aomenc --codec=av1 --obu -o s.obu --passes=1 --cpu-used=4 --limit=4 in.y4m -//! cargo run -p ec-av1 --example decode_probe -- s.obu -//! ``` -//! -//! Note `--obu`: [`ec_av1::stream::decode_stream`] takes a raw OBU stream, and -//! an IVF file decodes as zero frames rather than as an error. -//! -//! That run is also what disproved three refusal strings claiming an encoder -//! never writes a case it demonstrably writes, so this is a first-class -//! instrument, not a scratch file. -fn main() { - let Some(path) = std::env::args().nth(1) else { - eprintln!("usage: decode_probe "); - std::process::exit(2); - }; - let data = match std::fs::read(&path) { - Ok(data) => data, - Err(e) => { - eprintln!("{path}: {e}"); - std::process::exit(2); - } - }; - let report = || { - // lane-av1unwritten r6: the subsize-guard coverage table (per call - // site, per partition value, reached vs fired). Env-gated - // (`EC_AV1_SUBSIZE_GUARD_TRACE`), so it is empty unless asked for. - ec_av1::decode::dump_subsize_guard_scan(); - ec_av1::decode::dump_subsize_arm_scan(); - // The census below reads ec-av1's gate counters; without the crate's - // `gate-counters` feature every one of them is compiled out and reads 0. - if !cfg!(feature = "gate-counters") { - println!("counters disabled (built without the gate-counters feature)"); - } - let [a444, a422, s420, r420] = ec_av1::decode::cfl_ac_arm_hits(); - println!( - "cfl_ac: 444={a444} 422={a422} 420sq={s420} 420rect={r420} q3_at={}", - ec_av1::decode::cfl_ac_q3_at_hits() - ); - let (sc, dp) = ec_av1::decode::reelc_chroma_counters(); - println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}"); - println!( - "ibc128: mu_chroma={} intra128={}", - ec_av1::decode::intra_128_in_inter_mu_chroma_hits(), - ec_av1::decode::intra_128_in_inter_hits() - ); - println!( - "chroma422_square: {}", - ec_av1::decode::chroma422_square_hits() - ); - println!("chroma422_rect: {}", ec_av1::decode::chroma422_rect_hits()); - println!("chroma422_sub8: {}", ec_av1::decode::chroma422_sub8_hits()); - println!( - "chroma422_chunk: {}", - ec_av1::decode::chroma422_chunk_hits() - ); - println!( - "chroma422_pair_wide: {}", - ec_av1::decode::chroma422_pair_wide_hits() - ); - println!( - "uv_left_ss_y: reads={} mode_diff={} smooth_diff={} split1mi={}", - ec_av1::decode::uv_left_ss_y_reads(), - ec_av1::decode::uv_left_ss_y_mode_diff_hits(), - ec_av1::decode::uv_left_ss_y_smooth_diff_hits(), - ec_av1::decode::uv_left_1mi_split_hits(), - ); - let (h, v, c) = ec_av1::stream::rect4_32_counters(); - println!( - "rect4_16_uv_pair_filt: {}", - ec_av1::decode::rect4_16_uv_pair_filt_hits() - ); - println!("rect4_32: horz={h} vert={v} coded={c}"); - println!( - "rect_intrabc_reads: {}", - ec_av1::stream::rect_intrabc_reads() - ); - let (pal_y, pal_uv) = ec_av1::stream::intra_in_inter_palette_hits(); - println!("intra_in_inter_palette: y={pal_y} uv={pal_uv}"); - println!( - "palette_422_unit_window: {}", - ec_av1::decode::palette_422_unit_window_hits() - ); - println!( - "rect64_corner_tu: 64x32={} 32x64={}", - ec_av1::stream::rect64_corner_tu_hits(0), - ec_av1::stream::rect64_corner_tu_hits(1) - ); - println!( - "leaf8_intrabc_hits: {}", - ec_av1::stream::leaf8_intrabc_hits() - ); - println!("intrabc_hits: {}", ec_av1::stream::intrabc_hits()); - println!( - "intrabc_vartx_trees: {}", - ec_av1::decode::intrabc_vartx_hits() - ); - println!( - "intrabc_vartx_mixed_leaves: {}", - ec_av1::decode::intrabc_vartx_mixed_leaves_hits() - ); - println!( - "skipped_intrabc_chroma_arm_hits: {}", - ec_av1::stream::skipped_intrabc_chroma_arm_hits() - ); - println!( - "intrabc_rect: {} (var-tx tree: {})", - ec_av1::decode::intrabc_rect_hits(), - ec_av1::decode::intrabc_rect_vartx_hits() - ); - // lane-av1-ibcrect: `use_intrabc` on a 128-root HORZ/VERT strip -- - // the shape `decode_block_128rect` used to refuse. - println!( - "intrabc_128rect: {}", - ec_av1::stream::intrabc_128rect_hits() - ); - // lane-av1-ibc128chunk: the 128-root intrabc strip's per-axis chroma - // mu-chunk walk -- unit count and the `(64>>ss_x)|(64>>ss_y)` extent. - println!( - "intrabc_128rect_chroma_chunk: units={} shape=0x{:x}", - ec_av1::stream::intrabc_128rect_chroma_chunk_hits(), - ec_av1::stream::intrabc_128rect_chunk_shape() - ); - let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); - println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); - println!( - "sub8_inter_split: groups={}", - ec_av1::decode::sub8_inter_split_hits() - ); - println!( - "skip_split_tx_override: {}", - ec_av1::decode::skip_split_tx_override_hits() - ); - println!( - "interintra_rect: {}", - ec_av1::decode::interintra_rect_hits() - ); - println!( - "gm_nontrans_small_side: {}", - ec_av1::decode::gm_nontrans_small_side_hits() - ); - println!( - "tr_reach_longer_side: {}", - ec_av1::decode::tr_reach_longer_side_hits() - ); - println!( - "mv_clamp_edge_overhang: {}", - ec_av1::mvstack::mv_clamp_edge_overhang_hits() - ); - let (h84, h48) = ec_av1::decode::sub8_inter_rect_hits(); - println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}"); - println!( - "llintra8_chroma_walk: {}", - ec_av1::decode::llintra8_chroma_walk_hits() - ); - println!( - "sub8rect444_chroma_walk: {}", - ec_av1::decode::llsub8rect444_chroma_walk_hits() - ); - let si = ec_av1::stream::sub8_intra_rect_hits(); - println!( - "sub8_intra_rect: horz8x4={} vert4x8={} chroma_ref={} mixed={} split4x4={}", - si.0, si.1, si.2, si.3, si.4 - ); - let leaf = ec_av1::stream::vartx_rect_leaf_hits(); - println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]); - // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep - // can tell "aomenc never picked one" from "it did and we decoded it". - let ab = ec_av1::decode::ab16_inter_hits_by_arm(); - println!( - "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}", - ab[0], ab[1], ab[2], ab[3] - ); - // lane-kf900 r1: the counter the skipped-8x8-split-transform gate - // asserts -- printed here so a recipe sweep can see it fire without a - // test-binary rebuild. - println!("skip_split_tx: {}", ec_av1::decode::skip_split_tx_hits()); - let es = ec_av1::decode::inter_edge_strip_hits(); - println!( - "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}", - es[0], es[1], es[2], es[3], es[4], es[5] - ); - let (h4, v4, pairs, sub8) = ec_av1::decode::inter16_rect4_counters(); - println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}"); - let leaf4 = ec_av1::stream::vartx_rect_leaf4_hits(); - println!("vartx_rect_leaf4: 8x4={} 4x8={}", leaf4[0], leaf4[1]); - // lane-av1txr: intrabc 4x8/8x4 leaves that read the inter var-tx tree - // (the symbol whose absence desynced `warped.obu`). - println!( - "rect_intrabc_vartx: {}", - ec_av1::decode::rect_intrabc_vartx_hits() - ); - let rw = ec_av1::stream::rect_wedge_hits(); - let rwi = ec_av1::stream::rect_wii_hits(); - println!("rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}"); - // lane-inter128intra r1: the 128 root's HORZ/VERT half coded INTRA in - // an INTER frame -- the arm this round implemented. - let i128 = ec_av1::stream::intra128_in_inter_counters(); - println!("intra128_in_inter: 128x64={} 64x128={}", i128[0], i128[1]); - // lane-lossless128: intra 128-axis blocks on a LOSSLESS frame (every - // plane TX_4X4) -- the shape whose reconstruction used to panic. - println!( - "intra128_lossless: {}", - ec_av1::stream::intra128_lossless_counters() - ); - let sb = ec_av1::stream::sb128_rect_counters(); - println!( - "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}", - sb.0, sb.1, sb.2, sb.3 - ); - // lane-av1-ibcrect: the interior 128-root partition arms and the key - // frame's intra 128-axis blocks, so a recipe sweep can tell "the - // encoder never chose HORZ/VERT at the 128 root" from "it did". - let p128 = ec_av1::stream::part128_census(); - println!( - "part128: split={} none={} horz={} vert={} ab={:?} intra_horz={} intra_vert={}", - p128.0, p128.1, p128.2, p128.3, p128.4, p128.5, p128.6 - ); - // lane-sbab r1: the superblock-level inter AB arms. - let sbab = ec_av1::decode::sb_ab_inter_hits_by_arm(); - println!( - "inter_ab64: horz_a={} horz_b={} vert_a={} vert_b={}", - sbab[0], sbab[1], sbab[2], sbab[3] - ); - let i4 = ec_av1::stream::intra_rect4_in_inter_counters(); - println!( - "intra_rect4_in_inter: 64x16={} 16x64={} 32x8={} 8x32={}", - i4.0, i4.1, i4.2, i4.3 - ); - // lane-cdefstrip r1: 8x8 CDEF units whose skip band no coded block - // wrote this frame -- non-zero means a decode arm forgot - // `fill_skip_grid_rect`, and CDEF filtered a unit libaom may skip. - println!( - "cdef_unwritten_skip_units: {}", - ec_av1::decode::cdef_unwritten_skip_units() - ); - println!( - "cdef_band: rect_skip_writes={} mixed_skip_units={}", - ec_av1::decode::rect_skip_band_hits(), - ec_av1::decode::cdef_mixed_skip_units() - ); - let ir = ec_av1::stream::inter_rect_counters(); - println!( - "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", - ir.0, ir.1, ir.2, ir.3, ir.4, ir.5 - ); - // lane-rectres r1: how many of those 32x8/8x32 strips coded a real - // rectangular residual transform unit (a skipped one codes none). - println!( - "sub8_chroma_tx_from_ref: {}", - ec_av1::stream::sub8_chroma_tx_from_ref_hits() - ); - let r328 = ec_av1::stream::rect32x8_inter_tu_hits(); - println!("rect32x8_inter_tu: 32x8={} 8x32={}", r328[0], r328[1]); - // lane-intra16x4: INTRA strips of an inter 16x16-level 1:4 partition. - let i164 = ec_av1::stream::intra16x4_in_inter_hits(); - println!( - "intra16x4_in_inter: 16x4={} 4x16={} chroma_ref={}", - i164.0, i164.1, i164.2 - ); - println!( - "rect4_16_pair: lossless_chroma={} intrabc={}", - ec_av1::decode::rect4_16_lossless_chroma_hits(), - ec_av1::decode::rect4_16_intrabc_hits(), - ); - println!( - "loss64: chroma_edge_tu_clip={} skip_lossless_band_reset={}", - ec_av1::decode::chroma_edge_tu_clip_hits(), - ec_av1::decode::skip_lossless_band_reset_hits(), - ); - println!( - "llband: rect_split_lossless_chroma444={}", - ec_av1::decode::rect_split_lossless_chroma444_hits() - ); - // lane-t900 r12: chroma edge-filter neighbour answered from the mi-granular - // uv_mode grid instead of the coarse one-slot-per-column map. - println!( - "scaled: leaf8={} sub8={} warpfb={} predict_scaled={}", - ec_av1::decode::scaled_leaf8_hits(), - ec_av1::decode::scaled_sub8_hits(), - ec_av1::decode::scaled_warp_fallback_hits(), - ec_av1::mc::predict_scaled_hits() - ); - println!( - "uv_mode_grid_override: {}", - ec_av1::decode::uv_mode_grid_override_hits() - ); - // lane-thread2: proof the frame-parallel path actually fired (0 at - // the default EC_AV1_THREADS=1). - println!("frames_dispatched: {}", ec_av1::stream::frames_dispatched()); - // lane-av1recipehunt: `intra_rect4_in_inter` above already reports the - // 1:4-in-inter shapes; this is the `delta_q` half of the same story -- - // how many delta_q groups the stream really carried, and how many of - // them landed inside a rect64 dequant. - let (dq, dq_drift) = ec_av1::stream::rect64_qidx_drift_counters(); - println!("delta_q: groups_read={dq} rect64_qidx_drift={dq_drift}"); - // lane-av1422census422: the per-plane coefficient-unit census, armed - // for 4:4:4 and 4:2:2 (4:2:0 arms nothing, so a 4:2:0 recipe sweep - // reads `luma=0 u=0 v=0` BY DESIGN and must not read that as "the - // walk was empty" -- `units_total` is the UNCONDITIONAL per-frame - // total, so the two together say whether the census was armed at - // all). This is what makes a 4:2:2 non-vacuity requirement - // writable: before the widening every per-plane field read zero on a - // 4:2:2 cell BY CONSTRUCTION, so a byte-exact 4:2:2 gate could - // assert it and prove nothing about the stream it had decoded. - let cu = ec_av1::decode::census_nonsub_units(); - let cc = ec_av1::decode::census_nonsub_coded(); - println!( - "census_units: luma={} u={} v={} | coded: luma={} u={} v={} | units_total={}", - cu[0], - cu[1], - cu[2], - cc[0], - cc[1], - cc[2], - ec_av1::decode::census_unit_n(), - ); - }; - // lane-tiles: the tiling a real stream actually uses is a decision input - // (every gate in `stream.rs` picks its own `--tile-columns`), so report it - // from the frame headers before saying anything about pixels. - let mut parser = ec_av1_syntax::Av1Parser::new(); - let mut seen: Vec<(u32, u32, bool, u32)> = Vec::new(); - let mut pos = 0usize; - let mut frames_seen = 0usize; - // OBU at a time, so one unparseable OBU late in the stream still leaves - // every earlier frame header's tiling reported. - while pos < data.len() { - let Ok(obu) = parser.parse_obu(&data[pos..]) else { - break; - }; - pos += obu.total_size.max(1); - let header = match &obu.kind { - ec_av1_syntax::ObuKind::FrameHeader(h) => h, - ec_av1_syntax::ObuKind::Frame(h, _) => h, - _ => continue, - }; - frames_seen += 1; - // lane-frame36: `EC_PROBE_HDR=1` prints one line per frame header, so a - // silent wall can be triaged by "which header field is new at frame N" - // before any pixel work (class: a header field parsed then never consumed). - if std::env::var("EC_PROBE_HDR").is_ok() { - let h = header; - let gm: Vec = h - .global_motion - .iter() - .map(|w| format!("{:?}", w.model)) - .collect(); - println!( - "HDR {}: type={:?} show={} showable={} show_existing={}({}) intra={} \ - size={}x{} up={} superres={}/{} order_hint={} primary_ref={} refresh={:#04x} \ - refs={:?} order_hints={:?} sign_bias={:?} err_res={} disable_cdf={} \ - screen_tools={} int_mv={} intrabc={} hp_mv={} interp={:?} switchable_motion={} \ - ref_mvs={} base_q={} seg={} deltaq={} deltalf={} lf_level={:?} lf_deltas={:?}/{:?} \ - cdef_bits={} lr={:?} tx_mode={:?} ref_sel={} skip_mode={}({:?}) warp={} \ - reduced_tx={} gm={:?} grain={}/seed={} lossless={}", - frames_seen - 1, - h.frame_type, - h.show_frame, - h.showable_frame, - h.show_existing_frame, - h.frame_to_show_map_idx, - h.frame_is_intra, - h.frame_width, - h.frame_height, - h.upscaled_width, - h.use_superres, - h.superres_denom, - h.order_hint, - h.primary_ref_frame, - h.refresh_frame_flags, - h.ref_frame_idx, - h.order_hints, - h.ref_frame_sign_bias, - h.error_resilient_mode, - h.disable_cdf_update, - h.allow_screen_content_tools, - h.force_integer_mv, - h.allow_intrabc, - h.allow_high_precision_mv, - h.interpolation_filter, - h.is_motion_mode_switchable, - h.use_ref_frame_mvs, - h.quantization.base_q_idx, - h.segmentation.enabled, - h.delta.q_present, - h.delta.lf_present, - h.loop_filter.level, - h.loop_filter.ref_deltas, - h.loop_filter.mode_deltas, - h.cdef.bits, - h.loop_restoration.frame_restoration_type, - h.tx_mode, - h.reference_select, - h.skip_mode_present, - h.skip_mode_frame, - h.allow_warped_motion, - h.reduced_tx_set, - gm, - h.film_grain.apply_grain, - h.film_grain.grain_seed, - h.coded_lossless, - ); - } - let t = &header.tile_info; - let entry = (t.cols, t.rows, t.uniform_spacing, t.context_update_tile_id); - if !seen.contains(&entry) { - seen.push(entry); - } - } - println!("TILING: {frames_seen} frame headers parsed"); - // lane-sb128 r4: the superblock size decides the whole partition tree, so - // report it next to the tiling -- it is the first thing a film blocker - // triage needs. - if let Some(seq) = parser.sequence_header() { - println!( - "SEQ: use_128x128_superblock={} bit_depth={} mono_chrome={} max_frame={}x{}", - seq.use_128x128_superblock, - seq.color_config.bit_depth, - seq.color_config.mono_chrome, - seq.max_frame_width, - seq.max_frame_height - ); - } - for (cols, rows, uniform, ctx_id) in &seen { - println!( - "TILING: cols={cols} rows={rows} uniform_spacing={uniform} context_update_tile_id={ctx_id}" - ); - } - if seen.is_empty() { - println!("TILING: no frame header parsed"); - } - - // lane-streamsink r1: decode through the streaming entry point and write - // each shown frame out as it completes. The old path collected every - // picture in a Vec and then built a second full copy of the raw dump - // before one `fs::write`, so peak RSS was 2x the whole decoded segment (a - // 4K 8 s window needed >20 GiB, a whole film terabytes). Here at most one - // frame is held beyond the decoder's own DPB, and the printed lines are - // byte-identical to the old ones. - // `EC_PROBE_OUT16` is yuv420p10le (u16 LE); `EC_PROBE_OUT` / argv[2] is - // 8-bit (planes are u16, low byte taken). Either target may be a FIFO. - use std::io::Write; - let open = |path: &str| { - std::fs::OpenOptions::new() - .write(true) - .create(true) - .truncate(true) - .open(path) - .unwrap_or_else(|e| panic!("opening {path}: {e}")) - }; - let out16 = std::env::var("EC_PROBE_OUT16").ok(); - let out8 = std::env::args() - .nth(2) - .or_else(|| std::env::var("EC_PROBE_OUT").ok()); - let null16 = out16.as_deref() == Some("/dev/null"); - let mut f16 = out16.as_deref().map(open); - let mut f8 = out8.as_deref().map(open); - let mut written16 = 0usize; - let mut written8 = 0usize; - let mut shown = 0usize; - let mut dims = (0usize, 0usize); - let mut buf: Vec = Vec::new(); - // lane-av1mono: a monochrome stream is luma only, so the raw dump is a - // single plane -- exactly what `ffmpeg -pix_fmt gray -f rawvideo` writes. - let mono = parser - .sequence_header() - .is_some_and(|s| s.color_config.mono_chrome); - let result = ec_av1::stream::decode_stream_with(&data, |f, _idx, is_shown| { - if !is_shown { - return Ok(()); - } - shown += 1; - if shown == 1 { - dims = (f.width, f.height); - } - let planes: &[&Vec] = if mono { &[&f.y] } else { &[&f.y, &f.u, &f.v] }; - if let Some(w) = f16.as_mut() { - let n = 2 * planes.iter().map(|p| p.len()).sum::(); - if null16 { - // Timing runs point EC_PROBE_OUT16 at /dev/null; the u16->LE - // conversion was ~2% of the main thread for bytes nobody reads. - written16 += n; - } else { - buf.clear(); - buf.resize(n, 0); - let mut off = 0; - for p in planes { - let end = off + 2 * p.len(); - for (d, &s) in buf[off..end].as_chunks_mut::<2>().0.iter_mut().zip(p.iter()) { - d.copy_from_slice(&s.to_le_bytes()); - } - off = end; - } - w.write_all(&buf).expect("writing raw planes"); - written16 += buf.len(); - } - } - if let Some(w) = f8.as_mut() { - buf.clear(); - for p in planes { - buf.extend(p.iter().map(|&s| s as u8)); - } - w.write_all(&buf).expect("writing raw planes"); - written8 += buf.len(); - } - Ok(()) - }); - match result { - Ok(()) if shown == 0 => { - println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?"); - } - Ok(()) => { - if let Some(out) = &out16 { - println!("wrote {written16} bytes of yuv420p10le to {out}"); - } - if let Some(out) = &out8 { - println!("wrote {written8} bytes of yuv420p to {out}"); - } - println!("OK: {shown} frames decoded, {}x{}", dims.0, dims.1); - } - Err(e) => println!("REFUSED: {e}"), - } - report(); -} diff --git a/crates/ec-av1/src/decode/block.rs b/crates/ec-av1/src/decode/block.rs index 753f0894..e14ffbc9 100644 --- a/crates/ec-av1/src/decode/block.rs +++ b/crates/ec-av1/src/decode/block.rs @@ -72,7 +72,6 @@ pub(super) fn read_intra_mode( // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single // point every square caller routes through (see `read_intra_mode_rect`). let cfl = if cfl && side > 32 { - hit!(NOCFL_UV_MODE_HITS); false } else { cfl @@ -133,7 +132,6 @@ pub(super) fn read_intra_mode( eprintln!("TRACE intrabc dv={dv:?}"); } fctx.intrabc_dv.with(|c| c.set(Some(dv))); - hit!(INTRABC_HITS); // spec 5.11.13 / libaom `read_intra_frame_mode_info` returns the // moment `is_intrabc_block`: no y/uv mode, angle delta, palette, // CFL or filter-intra syntax follows. `YMode`/`UVMode` are forced @@ -199,24 +197,17 @@ pub(super) fn read_intra_mode( // 78 against ffmpeg, traced 2026-08-27) -- an existing, un-lane-touched // bug in that fallback this lane's own scope does not cover. Keep it // refused here rather than ship a silently-wrong decode. - if (9..=12).contains(&uv_mode) { - hit!(SMOOTH_UV_HITS); - } // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads // `angle_delta_uv` off `get_uv_mode(uv_mode)`, never off `uv_mode` raw, // so a CFL block (uv_mode==13, outside `V_PRED..=D67_PRED`) already takes // the `else` branch below and never reads one either way. let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { - hit!(DIRECTIONAL_UV_HITS); read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) } else { 0 }; istep!("angle_uv", angle_delta_uv); - if angle_delta_uv != 0 { - hit!(UV_ANGLE_DELTA_HITS); - } // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`): // gated by `av1_allow_palette` (blockd.h -- size bound only, @@ -322,7 +313,6 @@ pub(super) fn read_intra_mode( } istep!("use_filter_intra", use_filter_intra as i32); if use_filter_intra { - hit!(FILTER_INTRA_HITS); let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); if trace { eprintln!("TRACE filter_intra_mode value={fi_mode}"); @@ -342,7 +332,6 @@ pub(super) fn read_intra_mode( palette_onscreen(mi_r, mi_c, side, side, fctx), false, ); - hit!(PALETTE_HITS); if trace { eprintln!("TRACE palette_y size={n} colors={:?}", &colors[..n]); } @@ -372,7 +361,6 @@ pub(super) fn read_intra_mode( on, true, ); - hit!(PALETTE_UV_HITS); if trace { eprintln!( "TRACE palette_uv size={n} u_colors={:?} v_colors={:?}", @@ -412,7 +400,6 @@ pub(super) const UV_CFL_PRED: usize = 13; /// joint sign the same way. Returns each plane's final signed `alpha_q3` /// (`cfl_idx_to_alpha`, cfl.c): magnitude `idx + 1`, sign-zero collapsing to 0. pub(super) fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) { - hit!(CFL_BLOCK_HITS); let joint_sign = dec.symbol(&mut cdfs.cfl_sign) as i32; let sign_u = ((joint_sign + 1) * 11) >> 5; let sign_v = (joint_sign + 1) - 3 * sign_u; @@ -461,7 +448,6 @@ pub(super) fn cfl_ac_ss( ss_y: usize, ) -> Vec { if ss_x == 0 && ss_y == 0 { - hit!(CFL_AC_444_HITS); let mut ac = vec![0i32; bw * bh]; let mut sum = 0i32; for row in 0..bh { @@ -476,12 +462,6 @@ pub(super) fn cfl_ac_ss( ac.iter_mut().for_each(|v| *v -= avg); ac } else if ss_x == 1 && ss_y == 0 { - // lane-av1-422: `cfl_luma_subsampling_422_lbd_c` -- each chroma sample - // averages the HORIZONTAL luma pair above it, at full chroma height - // (`(a + b) >> 1` in Q3 is `(a + b) << 2`). A rect luma strip's chroma - // is square here, and the 4:2:0 rect/square helpers below would halve - // the height it must keep. - hit!(CFL_AC_422_HITS); let (cw, ch) = (bw >> 1, bh); let mut ac = vec![0i32; cw * ch]; let mut sum = 0i32; @@ -500,10 +480,8 @@ pub(super) fn cfl_ac_ss( ac.iter_mut().for_each(|v| *v -= avg); ac } else if bw == bh { - hit!(CFL_AC_420_SQ_HITS); cfl_ac_q3(y, px, py, bw) } else { - hit!(CFL_AC_420_RECT_HITS); cfl_ac_q3_rect(y, px, py, bw, bh) } } @@ -515,7 +493,6 @@ pub(crate) fn cfl_ac_q3_at( bh: usize, sample: impl Fn(usize, usize) -> i32, ) -> Vec { - hit!(CFL_AC_Q3_AT_HITS); if crate::envflags::env_flag!("EC_HALVSWEEP") { eprintln!("EC_HALV cfl_ac_q3_at px={px} py={py} bw={bw} bh={bh}"); } @@ -1216,12 +1193,6 @@ impl PlaneBuf<'_> { }); let corner = (x > self.tile_x0 && y > self.tile_y0).then(|| self.data[(y - 1) * self.width + x - 1]); - if matches!((bw, bh), (16, 8) | (8, 16)) { - hit!(RECT_STRIP_PRED_HITS); - if across > own_across || down > own_down { - hit!(RECT_STRIP_REACH_HITS); - } - } (above, left, corner) } @@ -1566,8 +1537,6 @@ pub(super) fn read_plane( if plane_idx > 0 && mono(fctx) { return Ok(Grid::Zero(side * side)); } - // lane-av1readcensus: the units read from here on are this plane's. - set_census_plane(plane_idx); let skip_ctx = if plane_idx == 0 { luma_skip_ctx.unwrap_or(0) } else { @@ -1848,9 +1817,6 @@ pub(super) fn read_rect_chroma_unit( smooth_neighbor_uv: bool, fctx: &crate::decode::FrameCtx, ) -> Result { - if ss_x(fctx) == 1 && ss_y(fctx) == 0 && w != h { - hit!(CHROMA422_RECT_HITS); - } // The same three cases as [`read_plane`], for the same reason: at 32 points // an INTER chroma unit's transform set is `EXT_TX_SET_DCT_IDTX` (the luma's // coded `IDTX` survives) where the intra set is `EXT_TX_SET_DCTONLY`, and @@ -1974,9 +1940,6 @@ pub(super) fn decode_block( c * (SUB / MI), fctx, )?; - if at_tile_left && palette_y.is_some() { - hit!(PALETTE_TILE_LEFT_HITS); - } // lane-lossless: a lossless BLOCK's transform is TX_4X4 on every plane // (libaom `read_tx_size`, `decodeframe.c`), so the caller's per-size // tables/scans are replaced by the 4x4 ones and the block always takes the @@ -2045,9 +2008,6 @@ pub(super) fn decode_block( uv_mode }; let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c, fctx); if crate::envflags::env_flag!("EC_AV1_TRACE") { @@ -2112,7 +2072,6 @@ pub(super) fn decode_block( ); } } - hit!(INTRABC_VARTX_HITS); // lane-t900 r33 census: the t900 recipes resolved every tree UNIFORM. // lane-av1-ibcvtx: a tree that resolved to mixed leaf sizes is no // longer refused -- the luma reconstruct below walks the tree's own @@ -2127,7 +2086,6 @@ pub(super) fn decode_block( .all(|l| (l.2, l.3) == (f.2, f.3) && l.2 == l.3) }); if !uniform { - hit!(INTRABC_VARTX_MIXED_LEAVES_HITS); if crate::envflags::env_flag!("EC_AV1_IBCVTX_DEBUG") { eprintln!( "IBCVTX mixed intrabc tree mi=({mi_r},{mi_c}) side={side} \ @@ -2151,9 +2109,6 @@ pub(super) fn decode_block( // single-unit path. (lossless_tx(side.min(64), fctx), luma_tx) }; - if tx_select && logical_tx < side && uv_mode != DC_PRED { - hit!(SQ_CHROMA_TX_HITS); - } let luma_set = if tx_select { txbset_for(logical_tx, reduced_tx_set) } else { @@ -2260,9 +2215,6 @@ pub(super) fn decode_block( // Counted on the SHAPE, not on the arm below, so a gate can tell a stream // that reaches this block apart from one that never does (class // gate-blind-to-feature). - if palette_y_buf.is_some() && skip && logical_tx < side { - hit!(SKIP_SPLIT_TX_OVERRIDE_HITS); - } if let Some(buf) = &palette_y_buf && (logical_tx == side || skip) { @@ -2313,9 +2265,6 @@ pub(super) fn decode_block( // narrower meaning (a READ split tx depth). let split_tx_skip = logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); if split_tx_skip { - if tx_select { - hit!(SKIP_SPLIT_TX_HITS); - } let n_axis = side / logical_tx; for tu_row in 0..n_axis { for tu_col in 0..n_axis { @@ -2440,9 +2389,6 @@ pub(super) fn decode_block( window }; if let Some((ub, _)) = &palette_uv_bufs { - if cn_cols * cn_rows > 1 { - hit!(SKIP_CHROMA_OVERRIDE_WINDOW_HITS); - } set_palette_pred(chroma_window(ub), fctx); } push_intra_unit( @@ -2513,10 +2459,6 @@ pub(super) fn decode_block( // the total stayed 0. let plane_block = chroma_side * chroma_height; let short = plane_block.saturating_sub(u_grid.len()); - hit_do!(SKIP_ARM_CHROMA_SHORT_SAMPLES.with(|c| c.set(c.get() + short))); - if chroma_side != chroma_height { - hit!(SKIP_ARM_CHROMA_RECT_SHAPES); - } neighbours.record( at, side, @@ -2785,10 +2727,6 @@ pub(super) fn decode_block( smooth_neighbor_uv, fctx, )?; - hit!(CHROMA_SPLIT_TX_HITS); - if ss_x(fctx) == 1 && ss_y(fctx) == 0 { - hit!(CHROMA422_SQUARE_HITS); - } // Immediately, so the next unit of this block reads this // one's coefficient context. `record` below stamps one // chroma state across the whole block; the replay after @@ -2943,7 +2881,6 @@ pub(super) fn decode_block( (luma_set, luma_scan) }; if let Some(buf) = &palette_y_buf { - hit!(PALETTE_SPLIT_TX_HITS); let mut window = vec![0u16; tu_tx * tu_tx]; for row in 0..tu_tx { let src = (tu_off_y + row) * side + tu_off_x; @@ -3070,7 +3007,6 @@ pub(super) fn decode_block( }; let (unit_w, unit_h) = (chroma_tx / 4, chroma_tx_h / 4); if cu_col * unit_w >= max_units_w || cu_row * unit_h >= max_units_h { - hit!(CHROMA_EDGE_TU_CLIP_HITS); continue; } // The chroma context arrays are indexed in LUMA mi, so this @@ -3182,10 +3118,6 @@ pub(super) fn decode_block( )? }; if cn_rows * cn_cols > 1 { - hit!(CHROMA_SPLIT_TX_HITS); - if ss_x(fctx) == 1 && ss_y(fctx) == 0 { - hit!(CHROMA422_SQUARE_HITS); - } // Immediately, so the NEXT unit of this same block reads // this one's coefficient context (libaom's chroma // `txb_skip_ctx` for the second quadrant is 11, i.e. base diff --git a/crates/ec-av1/src/decode/coeffs.rs b/crates/ec-av1/src/decode/coeffs.rs index ca5635a7..c1b979ad 100644 --- a/crates/ec-av1/src/decode/coeffs.rs +++ b/crates/ec-av1/src/decode/coeffs.rs @@ -90,17 +90,7 @@ pub(super) fn read_coeffs( ) -> Result<(Grid, TxType)> { let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); let side = coding.side; - // lane-av1readcensus: this unit's own entry state, so the census line - // carries the pre-read rng and pairs against the oracle's `EC_COEFF` - // (which prints `r->ec.rng` before the same `txb_skip` read). - let census_entry_rng = dec.debug_state().0; let (census_w, census_h) = rect_shape.unwrap_or((side, side)); - // lane-av1ibcfork: the per-unit BIT INTERVAL, the twin of the oracle's - // `EC_ECDUMP_IN` / `_OUT` / `_END`. The census plane, not a fresh label: - // it is the same source `census_unit` reads, so the interval line and the - // census line can never disagree about which plane a unit is on. - let iv_plane = CENSUS_PLANE.with(|c| c.get()).min(2); - let iv_bit = unit_iv_in(iv_plane, census_w, census_h, skip_ctx, dec); if crate::envflags::env_flag!("EC_AV1_EOBPT_CDF") { let (range, value) = dec.debug_state(); eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}"); @@ -123,9 +113,6 @@ pub(super) fn read_coeffs( 0 }; let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; - unit_iv_skip( - dec, iv_bit, iv_plane, census_w, census_h, skip_ctx, all_zero, - ); // lane-ibc444c: this reader logs an `all_zero` step even for a read that // consumes ZERO bits, so `post_bit == bit` means "no symbol was read" -- // filter on it before pairing anything against the oracle. @@ -161,18 +148,6 @@ pub(super) fn read_coeffs( eprintln!("EC_AV1_STATE_AFTER_TXBSKIP range={range} value={value}"); } if all_zero { - // lane-coefgrid: the all-zero unit (60% of the 4K segment's) names the - // shared zero grid instead of allocating and zeroing its own. - census_unit( - census_w, - census_h, - TxType::DctDct, - 0, - true, - census_entry_rng, - dec, - ); - unit_iv_end(dec, iv_plane, census_w, census_h, skip_ctx); return Ok((Grid::Zero(side * side), TxType::DctDct)); } let mut grid = vec![0i32; side * side]; @@ -209,10 +184,6 @@ pub(super) fn read_coeffs( } let class = TxClass::of(tx_type); - if class != TxClass::TwoD { - hit!(TX_CLASS1_HITS); - hit!(RECT_CLASS1_HITS); - } let eob = read_eob(dec, coding, class); if trace { eprintln!("TRACE eob value={eob}"); @@ -381,16 +352,6 @@ pub(super) fn read_coeffs( } grid[pos] = if negative { -level } else { level }; } - census_unit( - census_w, - census_h, - tx_type, - eob, - false, - census_entry_rng, - dec, - ); - unit_iv_end(dec, iv_plane, census_w, census_h, skip_ctx); Ok((Grid::Own(grid), tx_type)) } @@ -425,19 +386,10 @@ pub(super) fn read_coeffs_rect( plane: usize, ) -> Result<(Grid, TxType)> { let rect_trace = coeff_trace_on(); - let entry_rng = dec.debug_state().0; - // lane-av1readcensus: this reader is handed the real plane (lane-av1chrtx - // threaded it in for the `EC_COEFF_STEP` traces), so it stamps the census - // plane itself rather than inheriting whichever reader did last. The - // luma-only readers (`decode_rect_split`, `decode_block_rect64`, - // `read_inter_plane_rect`'s corner) are all plane 0 -- the stamp's initial - // value -- and the other plane-owning readers stamp on entry. - set_census_plane(plane); let ibctx_on = crate::envflags::env_flag!("EC_IBCTX"); let entry_bit = if ibctx_on { dec.debug_bitpos() } else { 0 }; - let iv_bit = unit_iv_in(plane, w, h, skip_ctx, dec); + let entry_rng = dec.debug_state().0; let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; - unit_iv_skip(dec, iv_bit, plane, w, h, skip_ctx, all_zero); if rect_trace { eprintln!( "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( ); } if all_zero { - census_unit(w, h, TxType::DctDct, 0, true, entry_rng, dec); - unit_iv_end(dec, plane, w, h, skip_ctx); return Ok((Grid::Zero(w * h), TxType::DctDct)); } let mut grid = vec![0i32; w * h]; - hit!(RECT_COEFF_TU_HITS); // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including // 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( } } let class = TxClass::of(tx_type); - if class != TxClass::TwoD { - hit!(TX_CLASS1_HITS); - } let eob = read_eob(dec, coding, class); if rect_trace { eprintln!( @@ -683,8 +629,6 @@ pub(super) fn read_coeffs_rect( nz.join(",") ); } - census_unit(w, h, tx_type, eob, false, entry_rng, dec); - unit_iv_end(dec, plane, w, h, skip_ctx); Ok((Grid::Own(grid), tx_type)) } @@ -1747,9 +1691,6 @@ impl Neighbours { /// [`Self::fill_skip_grid`] with independent row/col extents (lane-partitions r1). pub(super) fn fill_skip_grid_rect(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize, skip: bool) { let (mi_r, mi_c) = at_mi; - if skip && w_mi != h_mi { - hit!(RECT_SKIP_BAND_HITS); - } for rr in 0..h_mi { let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c; fill_span( @@ -2517,7 +2458,6 @@ impl Neighbours { if self.tile_row0_mi > 0 && !have_above && self.above_uv_mode[c] != DC_PRED || self.tile_col0_mi > 0 && !have_left && self.left_uv_mode[r] != DC_PRED { - hit!(UV_TILE_EDGE_SUPPRESSED_HITS); } // The mi grid is libaom's own read; the two maps below stay as the // fallback for cells no block has written (see [`Self::uv_mode_grid`]). @@ -2607,17 +2547,10 @@ impl Neighbours { // `lanes/av1leftref.report.md`, which is what makes the read change a // proven no-op on today's material rather than an unmeasured guess. if decode_path && have_left && ss_y > 0 { - hit!(UV_LEFT_SS_Y_READS); // The pre-lane read, kept as the counter's own-row arm: it is what // this decoder answered before the `+ss_y` term landed, and // comparing against it is what proves the term is load-bearing. let own_row = read_left(mi_r); - if own_row != left { - hit!(UV_LEFT_SS_Y_MODE_DIFF_HITS); - } - if is_smooth_mode(own_row) != is_smooth_mode(left) { - hit!(UV_LEFT_SS_Y_SMOOTH_DIFF_HITS); - } // lane-av1leftwit: the geometry the `+ss_y` term needs. The two // cells are one left mi column apart, so they are two different // blocks exactly when the left neighbour is 1 mi tall or shorter. @@ -2635,7 +2568,6 @@ impl Neighbours { .filter(|o| o & 0xff00_0000 == epoch) .unwrap_or(0); if own != 0 && down != 0 && own != down { - hit!(UV_LEFT_1MI_SPLIT_HITS); if crate::envflags::env_flag!("EC_LEFTSSY") { eprintln!( "EC_LEFTSSY epoch={} mi=({mi_r},{mi_c}) left_col={col} \ @@ -2654,18 +2586,13 @@ impl Neighbours { }) || have_left && cell(&self.uv_mode_grid, left_mi.0, left_mi.1).is_some_and(|m| { !matches!(self.uv_mode_row.get(left_mi.0), Some(&(col, cm)) if usize::from(col) == left_mi.1 && usize::from(cm) == m) }) { - hit!(UV_MODE_GRID_OVERRIDE_HITS); } // lane-cfl r1 counter: how often the mi-exact chroma neighbour differs // from the coarse [`SUB`] slot -- i.e. how often a chroma edge would // have been filtered at the wrong strength by the coarse map alone. - if above != self.above_uv_mode[c] || left != self.left_uv_mode[r] { - hit!(UV_MODE_MI_OVERRIDE_HITS); - } if (is_smooth_mode(self.above_uv_mode[c]) && !is_smooth_mode(above)) || (is_smooth_mode(self.left_uv_mode[r]) && !is_smooth_mode(left)) { - hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS); } is_smooth_mode(above) || is_smooth_mode(left) } @@ -2719,20 +2646,15 @@ impl Neighbours { let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); let (above, left) = self.modes_above_left_mi(mi_r, mi_c, (self.above_mode[c], self.left_mode[r])); - if above != self.above_mode[c] || left != self.left_mode[r] { - hit!(MODE_MI_OVERRIDE_HITS); - } if (is_smooth_mode(self.above_mode[c]) && !is_smooth_mode(above)) || (is_smooth_mode(self.left_mode[r]) && !is_smooth_mode(left)) { - hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS); } // A neighbour the coarse band offered where the tile edge makes it // unavailable -- must never happen (see `MODE_TILE_EDGE_COARSE_LEAKS`). if (mi_r <= self.tile_row0_mi && self.above_mode[c] != DC_PRED) || (mi_c <= self.tile_col0_mi && self.left_mode[r] != DC_PRED) { - hit!(MODE_TILE_EDGE_COARSE_LEAKS); } (above, left) } @@ -2935,13 +2857,6 @@ impl Neighbours { // the flags read the CALLER's origin, before the shadowing align below let (row_mid, col_mid) = (mi_r & (step_y - 1) != 0, mi_c & (step_x - 1) != 0); if row_mid || col_mid { - CHROMA_MIDCELL_PUB_HITS.with(|c| { - let mut v = c.get(); - v[0] += usize::from(row_mid); - v[1] += usize::from(col_mid); - v[2] += usize::from(row_mid && col_mid); - c.set(v); - }); } let (mi_r, mi_c) = (mi_r & !(step_y - 1), mi_c & !(step_x - 1)); let round_up_even = |n: usize| n.div_ceil(2) * 2; @@ -3571,9 +3486,6 @@ pub(super) fn decode_color_index_map_wh( ) -> Vec { let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); let (on_bw, on_bh) = (on.0.clamp(1, bw), on.1.clamp(1, bh)); - if on_bw < bw || on_bh < bh { - hit!(PALETTE_ONSCREEN_CUT_HITS); - } let mut map = vec![0u8; bw * bh]; if trace { let (rng, _) = dec.debug_state(); @@ -3642,9 +3554,6 @@ pub(crate) fn palette_replicate(map: &mut [u8], bw: usize, bh: usize, on: (usize /// it lands away from zero, for gate tests to prove a real stream fired one. pub(super) fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 { let symbol = dec.symbol(cdf); - if symbol != ANGLE_DELTA_ZERO { - hit!(ANGLE_DELTA_HITS); - } symbol as i32 - ANGLE_DELTA_ZERO as i32 } @@ -3777,7 +3686,6 @@ pub(super) fn tx_size_context_txfm_rect( own_h: usize, fctx: &crate::decode::FrameCtx, ) -> usize { - hit!(INTRA_IN_INTER_TXCTX_HITS); // `max_txsize_rect_lookup[bsize]` tops out at TX_64X64: no transform is // wider or taller than 64, so a block with a 128 side resolves against 64 // (lane-sb128b r1). @@ -3827,7 +3735,6 @@ pub(super) fn tx_size_context_txfm_rect( if band_above != (has_above && usize::from(above) != 0) || band_left != (has_left && usize::from(left) != 0) { - hit!(TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS); } } if crate::envflags::env_flag!("EC_TXCTX") { @@ -3861,9 +3768,6 @@ pub(super) fn tx_size_context_txfm_rect( { let stale = usize::from(has_above && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w) + usize::from(has_left && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h); - if ctx != stale { - hit!(TXCTX_DEBLOCK_DIVERGENCE_HITS); - } } ctx } @@ -3918,7 +3822,6 @@ pub(super) fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize), if band_above != (has_above && usize::from(above) != 0) || band_left != (has_left && usize::from(left) != 0) { - hit!(TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS); } } if crate::envflags::env_flag!("EC_TXCTX") { @@ -3990,9 +3893,6 @@ pub(super) fn read_tx_size( "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={depth} ctx={ctx} rng={rng}" ); } - if depth != 0 { - hit!(TX_DEPTH_HITS); - } max_tx >> depth } @@ -4408,7 +4308,6 @@ pub(super) fn read_var_tx_size( tx_h, ); let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; - hit!(TXFM_SPLIT_READS); if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { let (rng, _) = dec.debug_state(); eprintln!( @@ -4423,7 +4322,6 @@ pub(super) fn read_var_tx_size( txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h)); return; } - hit!(TXFM_SPLIT_HITS); let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h); if (sub_w, sub_h) == (4, 4) { // libaom's `sub_txs == TX_4X4` early return: every mi cell of the diff --git a/crates/ec-av1/src/decode/counters.rs b/crates/ec-av1/src/decode/counters.rs deleted file mode 100644 index 6d5d15ed..00000000 --- a/crates/ec-av1/src/decode/counters.rs +++ /dev/null @@ -1,4459 +0,0 @@ -//! Hit and census counters of the decode path: thread-local tallies bumped by the -//! `hit!` instrumentation and read back by the gate tests. Moved out of `decode/mod.rs` -//! by name (av1split D3); the items are unchanged except for `pub(super)` visibility. - -use super::*; - -// How many real 128-level partition symbols this decoder has read, and how -// many superblocks resolved to `PARTITION_SPLIT` (coded or forced) -- the -// gate's proof a `--sb-size=128` stream exercised the 128 partition root. -thread_local! { - pub(super) static PART128_SPLIT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`PART128_SPLIT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn part128_split_hits() -> usize { - PART128_SPLIT_HITS.with(|c| c.get()) -} - -// How many `use_filter_intra` symbols this decoder has read as `1`, across -// every call on the current thread -- the cheap counter [`filter_intra_hits`] gate -// tests read (before/after, not the absolute value) to prove a stream -// actually exercised the filter-intra predictor rather than silently -// skipping it. -thread_local! { - pub(super) static FILTER_INTRA_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`FILTER_INTRA_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn filter_intra_hits() -> usize { - FILTER_INTRA_HITS.with(|c| c.get()) -} - -// lane-fiinter r1: how many of those `use_filter_intra == 1` symbols belonged -// to an INTRA block inside an INTER frame (`read_intra_block_mode_info`'s own -// `read_filter_intra_mode_info` call), which no gate exercised before this -// round -- every inter gate recipe passed `--enable-filter-intra=0`. -thread_local! { - pub(super) static INTRA_IN_INTER_FILTER_INTRA_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTRA_IN_INTER_FILTER_INTRA_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_in_inter_filter_intra_hits() -> usize { - INTRA_IN_INTER_FILTER_INTRA_HITS.with(|c| c.get()) -} - -// lane-angleinter r1: how many INTRA blocks inside an INTER frame carried a -// nonzero `angle_delta_y` / `angle_delta_uv` (`read_intra_angle_info`). Both -// arms refused a nonzero luma delta before this round, and no inter gate -// enabled `--enable-angle-delta` (aomenc's own default is 1). -thread_local! { - pub(super) static INTRA_IN_INTER_ANGLE_DELTA_Y_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; - pub(super) static INTRA_IN_INTER_ANGLE_DELTA_UV_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTRA_IN_INTER_ANGLE_DELTA_Y_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_in_inter_angle_delta_y_hits() -> usize { - INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.get()) -} - -/// Current value of [`INTRA_IN_INTER_ANGLE_DELTA_UV_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_in_inter_angle_delta_uv_hits() -> usize { - INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|c| c.get()) -} - -// lane-uv8 r1: the three non-DC chroma mode classes an INTRA 8x8 leaf inside -// an INTER frame ([`decode_inter_block8`]'s intra arm) can carry -- the arm -// read `uv_mode` and then refused everything but `DC_PRED`. Counted here and -// nowhere else so the gate's assert cannot be satisfied by a >=16x16 block. -thread_local! { - pub(super) static INTRA_IN_INTER8_UV_DIR_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static INTRA_IN_INTER8_UV_SMOOTH_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static INTRA_IN_INTER8_UV_CFL_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -thread_local! { - pub(super) static INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Nonzero luma angle deltas coded by an intra 8x8 leaf inside an inter frame -/// (lane-leaf8tx r1) -- counted only in [`decode_inter_block8`]'s intra arm. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_in_inter8_angle_delta_y_hits() -> usize { - INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS.with(|c| c.get()) -} - -/// `(directional, smooth/paeth, CfL)` chroma modes coded by an intra 8x8 leaf -/// inside an inter frame -- see [`INTRA_IN_INTER8_UV_DIR_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_in_inter8_uv_hits() -> (usize, usize, usize) { - ( - INTRA_IN_INTER8_UV_DIR_HITS.with(|c| c.get()), - INTRA_IN_INTER8_UV_SMOOTH_HITS.with(|c| c.get()), - INTRA_IN_INTER8_UV_CFL_HITS.with(|c| c.get()), - ) -} - -// Whether this superblock's single CDEF unit (this decoder has no 128x128 -// SB, so the SB IS the CDEF unit) has already had its `cdef_idx` literal -// read -- reset to `false` at the top of each superblock in the two tile -// loops, spec `read_cdef`'s `cdef_transmitted[index]`. -// Number of superblock columns in the current tile's grid, so -// [`maybe_read_cdef_idx`] can turn an `(mi_r, mi_c)` into a flat index into -// [`CDEF_IDX_GRID`]. -// One resolved `cdef_idx` per superblock, read by [`apply_cdef`] to select -// which of the header's `1 << cdef.bits` strength pairs applies to that -// superblock's samples. -// How many real (`cdef.bits > 0`) `cdef_idx` literals [`maybe_read_cdef_idx`] -// has read, across every call on the current thread -- the gate's proof that a -// `cdef_bits > 0` stream actually reached the new reader rather than every -// superblock coincidentally being all-skip. -thread_local! { - pub(super) static CDEF_IDX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -// How many times a warp was suppressed for one PLANE because that plane's own -// block is narrower or shorter than 8 (`av1_init_warp_params`'s own bail-out, -// reconinter.c) -- the gate's proof that a stream really carries the shape, -// since the square `side`/`chroma_side` can be 8 or more while the plane's -// true block is 4 wide (an 8x16 luma block's 4x8 chroma). -thread_local! { - pub(super) static WARP_PLANE_SUPPRESS_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`WARP_PLANE_SUPPRESS_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn warp_plane_suppress_hits() -> usize { - WARP_PLANE_SUPPRESS_HITS.with(|c| c.get()) -} - -/// Current value of [`CDEF_IDX_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn cdef_idx_hits() -> usize { - CDEF_IDX_HITS.with(|c| c.get()) -} - -// lane-t900 r6: gate proof for the three r2-r4 root causes that shipped with no -// counter -- the in-inter tx-depth context (`tx_size_context_txfm_rect`), the -// non-chroma-reference block that must LEAVE its neighbours' chroma coefficient -// contexts alone, and the intra-edge filter neighbour pair taken mi-exact -// instead of from the coarse 16x16 cell. -thread_local! { - pub(super) static INTRA_IN_INTER_TXCTX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static NON_CHROMA_REF_CTX_SKIP_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static EDGE_FILTER_MI_FIX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTRA_IN_INTER_TXCTX_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_in_inter_txctx_hits() -> usize { - INTRA_IN_INTER_TXCTX_HITS.with(|c| c.get()) -} - -/// Current value of [`NON_CHROMA_REF_CTX_SKIP_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn non_chroma_ref_ctx_skip_hits() -> usize { - NON_CHROMA_REF_CTX_SKIP_HITS.with(|c| c.get()) -} - -/// Current value of [`EDGE_FILTER_MI_FIX_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn edge_filter_mi_fix_hits() -> usize { - EDGE_FILTER_MI_FIX_HITS.with(|c| c.get()) -} - -// lane-realworld r4: this frame's `delta.q_present` (spec 5.9.17) and its -// actual step (`1 << delta.q_res`, already the real multiplier, not the raw -// 2-bit field). `false`/`1` (the defaults) make [`maybe_read_delta_q`] a -// true no-op, matching every existing gate stream's `delta_q_present == 0` -// behaviour exactly, the same corner-cut [`CDEF_BITS`] takes above. -// The running quantizer index (spec `CurrentQIndex`, libaom -// `xd->current_base_qindex`) -- reset to the frame's own `base_q_idx` at the -// top of every tile (spec `decode_tile`), carried across superblocks within -// that tile, and mutated only by [`maybe_read_delta_q`]. Read back at the -// dequantization call sites instead of the frame-constant `base_q_idx`. -// This frame's own per-plane DC/AC quantizer-index deltas (lane-sbpart r11, -// spec 5.9.12/7.12.2, [`crate::quant::QuantDeltas`]) -- frame-constant (not -// per-superblock like [`CURRENT_Q_IDX`]), set once per frame decode and read -// back at every dequantization call site keyed on which plane it is doing. -// How many real `delta_q_present` symbol groups [`maybe_read_delta_q`] has -// read, across every call on the current thread -- the gate's proof that a -// `delta_q_present` stream actually reached the new reader. -thread_local! { - pub(super) static DELTA_Q_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`DELTA_Q_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn delta_q_hits() -> usize { - DELTA_Q_HITS.with(|c| c.get()) -} - -// lane-realworld r5: this frame's `delta.lf_present`/`lf_res`/`lf_multi` -// (spec 5.9.18) -- same no-op-by-default corner-cut as `DELTA_Q_PRESENT`. -// The running per-plane/direction loop-filter delta (spec `DeltaLF[i]`, -// `i` in `0..FRAME_LF_COUNT`) -- reset to `[0; 4]` at the top of every tile, -// mutated only by [`maybe_read_delta_lf`]. `!delta_lf_multi` mode only ever -// updates index 0 and every reader treats that as the value for all 4 -// indices (spec `read_delta_lf_params`'s own single-cdf branch). -// How many real `delta_lf_present` symbol groups [`maybe_read_delta_lf`] has -// read -- the gate's proof the reader fired, mirroring [`DELTA_Q_HITS`]. -thread_local! { - pub(super) static DELTA_LF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`DELTA_LF_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn delta_lf_hits() -> usize { - DELTA_LF_HITS.with(|c| c.get()) -} - -// --------------------------------------------------------------------------- -// lane-seg: segmentation. Header (spec 5.9.14) is parsed by `ec-av1-syntax`; -// this block is the per-block `segment_id` reader (spec 5.11.7-5.11.9) plus -// the two consumers a real stream exercises: the per-segment quantizer index -// (spec 7.12.2 `get_qindex`) and the per-segment loop-filter level -// (spec 7.14.4). Shapes follow libaom `decodemv.c:read_segment_id`/ -// `read_intra_segment_id`/`read_inter_segment_id` and -// `pred_common.h:av1_get_spatial_seg_pred` -- note libaom returns the SPATIAL -// PREDICTION (not 0) from `read_segment_id` when the block is `skip`, which -// is what the oracle every gate here compares against actually does. -thread_local! { - /// `CurrentSegmentIds`: this frame's own map, `mi_rows * mi_cols` entries - /// with stride `mi_cols` (NOT the padded `Neighbours` grid stride). - /// `PrevSegmentIds`: the primary reference frame's saved map, empty when - /// this frame has no primary reference (spec `load_previous_segment_ids`). - /// `(mi_rows, mi_cols)` for both maps above. - /// `AboveSegPredContext` (per mi column) / `LeftSegPredContext` (per mi - /// row) -- spec 5.11.9's own `seg_id_predicted` neighbour state, which - /// libaom keeps on the neighbouring `mbmi->seg_id_predicted` instead. - /// The block currently being decoded -- read back by [`block_q_idx`]. - /// The tile's own top-left mi position, for `AvailU`/`AvailL`. - /// How many real `segment_id` symbols were read, and the set of segment - /// ids any block ended up with -- the gate's proof the feature fired. - pub(super) static SEG_ID_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// How many `seg_id_predicted` symbols were read (temporal update). - pub(super) static SEG_PRED_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// How many `segment_id` symbols have been read (never reset per frame). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn segment_id_hits() -> usize { - SEG_ID_HITS.with(|c| c.get()) -} - -/// How many `seg_id_predicted` symbols have been read (temporal update). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn segment_pred_hits() -> usize { - SEG_PRED_HITS.with(|c| c.get()) -} - -/// Resets the segmentation hit counters (gate setup). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_segment_hits() { - SEG_ID_HITS.with(|c| c.set(0)); - SEG_IDS_SEEN.with(|c| c.set(0)); - SEG_PRED_HITS.with(|c| c.set(0)); - BLOCK_Q_SPAN.with(|c| c.set((i32::MAX, i32::MIN))); -} - -// How many key-frame luma blocks resolved `smooth_neighbor` (spec -// `get_intra_edge_filter_type`) to `true` -- lane-chroma r2's own before/after -// counter, proving a stream actually put a directional block next to a -// smooth-predicted neighbour rather than every block reading the (previously -// hardcoded `false`) edge-filter strength bucket unchanged. -thread_local! { - pub(super) static SMOOTH_LUMA_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`SMOOTH_LUMA_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn smooth_luma_hits() -> usize { - SMOOTH_LUMA_HITS.with(|c| c.get()) -} - -thread_local! { - /// lane-band46 r1: how many split-transform units answered their intra - /// reach DIFFERENTLY under libaom's per-unit rules ([`Reach::of_tu`], the - /// palette2 r12 fix) than the standalone-block lookup this decoder used to - /// apply to them (class reach-is-per-transform-unit). Every hit is a - /// transform unit whose above-right / below-left reference samples would - /// be wrong without that fix. - pub(super) static SPLIT_TU_REACH_FIX_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`SPLIT_TU_REACH_FIX_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn split_tu_reach_fix_hits() -> usize { - SPLIT_TU_REACH_FIX_HITS.with(|c| c.get()) -} - -// How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12), -// across every call on the current thread -- lane-chroma r3's own before/after -// counter, proving a stream actually exercised chroma's smooth/paeth -// predictor (the previously-refused round-2 gap) rather than every block -// landing on DC/CFL/directional. -thread_local! { - pub(super) static SMOOTH_UV_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`SMOOTH_UV_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn smooth_uv_hits() -> usize { - SMOOTH_UV_HITS.with(|c| c.get()) -} - -// How many tiles [`decode_key_frame_tile_with_cdfs`] has actually decoded a -// full superblock walk over, across every call on the current thread -- -// lane-tiles r2's own gate-blind-to-feature guard: a gate over a -// multi-tile stream must prove more than one tile actually fired, not just -// that the stream carried tile_info.cols > 1. -thread_local! { - pub(super) static TILE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`TILE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn tile_hits() -> usize { - TILE_HITS.with(|c| c.get()) -} - -// How many 4-pixel deblocking edge groups [`edge_params`] has actually -// selected for filtering, across every call on the current thread -- the same -// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream -// exercised `apply_deblock` rather than every edge landing on level 0. -thread_local! { - pub(super) static DEBLOCK_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`DEBLOCK_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn deblock_hits() -> usize { - DEBLOCK_HITS.with(|c| c.get()) -} - -// lane-defon r1: how many COMPOUND_REFERENCE blocks read a -// `UNIDIR_COMP_REFERENCE` pair (both references on the same temporal side, -// spec 5.11.25 `comp_reference_type == 0`) -- the gate's proof that a -// stream built with `--enable-onesided-comp=1` really exercised the -// `uni_comp_ref` alphabet rather than only bidirectional pairs. -thread_local! { - pub(super) static UNI_COMP_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`UNI_COMP_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn uni_comp_hits() -> usize { - UNI_COMP_HITS.with(|c| c.get()) -} - -// lane-defon r1: how many blocks blended through a `COMPOUND_DIFFWTD` mask -// (`mc::diffwtd_mask`) -- the narrower half of `MASKED_COMPOUND_HITS`, the -// gate's proof that `--enable-diff-wtd-comp=1` reached the difference-weighted -// blend and not only the wedge arm. -thread_local! { - pub(super) static DIFFWTD_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`DIFFWTD_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn diffwtd_hits() -> usize { - DIFFWTD_HITS.with(|c| c.get()) -} - -// lane-mcomp64 r1: how many blocks took the INFERRED `COMPOUND_DIFFWTD` arm -- -// a block size where `av1_is_wedge_used` is false (64x64 is the only such size -// this decoder's square inter path reaches), so no `compound_type` symbol is -// coded at all. Strictly narrower than `DIFFWTD_HITS`, which also counts the -// coded-symbol DIFFWTD blocks at 8x8/16x16/32x32. -thread_local! { - pub(super) static DIFFWTD_INFERRED_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`DIFFWTD_INFERRED_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn diffwtd_inferred_hits() -> usize { - DIFFWTD_INFERRED_HITS.with(|c| c.get()) -} - -// lane-defon r1: how many FORWARD KEYFRAMES were decoded -- a KEY frame coded -// with `show_frame == 0`, output later by a `show_existing_frame` header -// (aomenc `--enable-fwd-kf=1 --fwd-kf-dist=N`). Counted from -// `stream::decode_stream`, which is where the frame header is consumed; the -// gate's proof that the on-value really reached the bitstream rather than -// being dropped by the rate control. -thread_local! { - pub(super) static FWD_KF_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`FWD_KF_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn fwd_kf_hits() -> usize { - FWD_KF_HITS.with(|c| c.get()) -} - -// How many [`read_tx_size`] reads resolved a `tx_depth` strictly less than -// the block's own side, across every call on the current thread -- the same -// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream -// actually exercised a *split* transform under `TxMode::Select` rather than -// every block coincidentally resolving `depth=0` (indistinguishable from -// `TxMode::Largest` pixel-wise). -thread_local! { - pub(super) static TX_DEPTH_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -// How many plain SQUARE intra blocks (lane-sqchroma r1) resolved a luma -// transform smaller than their own side (`tx_depth != 0`) while coding a -// chroma prediction other than `DC_PRED` -- the pair the square path's chroma -// only exercises with aomenc's tx-size search left ON (its default), which -// every older recipe in this file pins off. Counted at the block, so a stream -// where RD happened to give every split-transform block a DC chroma mode -// reads as zero rather than silently passing for free. -thread_local! { - pub(super) static SQ_CHROMA_TX_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`SQ_CHROMA_TX_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn sq_chroma_tx_hits() -> usize { - SQ_CHROMA_TX_HITS.with(|c| c.get()) -} - -/// Current value of [`TX_DEPTH_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn tx_depth_hits() -> usize { - TX_DEPTH_HITS.with(|c| c.get()) -} - -// lane-txselect: how many `txfm_split` symbols an inter frame's var-tx tree -// read, and how many of those actually took the split, on the current thread -// -- the same before/after counter pattern as [`TX_DEPTH_HITS`], proving a -// stream exercised spec 5.11.17's `read_var_tx_size` rather than every block -// coincidentally coding one whole-block transform. -thread_local! { - pub(super) static TXFM_SPLIT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - // lane-inter4 r2: rectangular INTER residual coding -- how many rect - // strips coded one whole-block rect transform unit, and how many split - // their rect max transform into square sub-transforms. - pub(super) static RECT_INTER_TU_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static RECT_INTER_TXSPLIT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - // lane-r14 r2: luma transform units of an inter strip with a 64-px axis - // (64x32/32x64/64x16/16x64), whose coefficients are coded as the - // truncated low-32 corner. - pub(super) static RECT64_INTER_TU_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - // lane-rectres r1: whole-block luma transform units of a 32x32-level 1:4 - // inter strip, `[32x8, 8x32]`. - pub(super) static RECT32X8_INTER_TU_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; - // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32]. - pub(super) static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; - // lane-inter16ab r4: rectangular var-tx leaves with a 4-px axis, [8x4, 4x8] - // -- the `sub_tx_size_map[TX_16X4]` split leaves of a 16x16-level 1:4 strip. - pub(super) static VARTX_RECT_LEAF4_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; - // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter - // frame -- 16x8 and 8x16 inter leaves. - pub(super) static INTER_LEAF16_HORZ_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static INTER_LEAF16_VERT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - // This frame's own `tx_mode == TxMode::Select` and `reduced_tx_set` bits, - // set once per inter tile by [`decode_inter_frame_tile_with_cdfs`] -- - // `decode_inter_block` already carries forty parameters and both are - // frame-constant. - // lane-fiinter r1: this sequence header's own `enable_filter_intra` bit, - // frame-constant like the two above and stashed the same way -- an intra - // block inside an inter frame reads `use_filter_intra` under it. -} - -/// Current value of [`TXFM_SPLIT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn txfm_split_hits() -> usize { - TXFM_SPLIT_HITS.with(|c| c.get()) -} - -/// Current value of [`INTER_LEAF16_HORZ_HITS`] (lane-inter4 r3). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn inter_leaf16_horz_hits() -> usize { - INTER_LEAF16_HORZ_HITS.with(|c| c.get()) -} - -/// Current value of [`INTER_LEAF16_VERT_HITS`] (lane-inter4 r3). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn inter_leaf16_vert_hits() -> usize { - INTER_LEAF16_VERT_HITS.with(|c| c.get()) -} - -/// Current value of [`RECT_INTER_TU_HITS`] (lane-inter4 r2). -pub(crate) fn rect_inter_tu_hits() -> usize { - RECT_INTER_TU_HITS.with(|c| c.get()) -} - -/// Current value of [`RECT_INTER_TXSPLIT_HITS`] (lane-inter4 r2). -pub(crate) fn rect_inter_txsplit_hits() -> usize { - RECT_INTER_TXSPLIT_HITS.with(|c| c.get()) -} - -/// Current value of [`RECT64_INTER_TU_HITS`] (lane-r14 r2). -pub(crate) fn rect64_inter_tu_hits() -> usize { - RECT64_INTER_TU_HITS.with(|c| c.get()) -} - -/// Current value of [`RECT32X8_INTER_TU_HITS`] (lane-rectres r1): `[32x8, 8x32]` -/// whole-block luma units of a 32x32-level 1:4 inter strip. -pub(crate) fn rect32x8_inter_tu_hits() -> [usize; 2] { - RECT32X8_INTER_TU_HITS.with(|c| c.get()) -} - -/// Current value of [`VARTX_RECT_LEAF_HITS`] (lane-r14 r3): how many -/// rectangular var-tx leaf transform units were coded, `[32x16, 16x32]`. -pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] { - VARTX_RECT_LEAF_HITS.with(|c| c.get()) -} - -/// Current value of [`VARTX_RECT_LEAF4_HITS`] (lane-inter16ab r4): 8x4/4x8 -/// split leaves of a 16x4/4x16 strip, `[8x4, 4x8]`. -pub(crate) fn vartx_rect_leaf4_hits() -> [usize; 2] { - VARTX_RECT_LEAF4_HITS.with(|c| c.get()) -} - -/// Records one rectangular var-tx leaf. -pub(super) fn vartx_rect_leaf_hit(tw: usize, th: usize) { - if crate::envflags::env_flag!("EC_VARTXLEAF") { - eprintln!("EC_VARTXLEAF tw={tw} th={th}"); - } - let cell = if tw.min(th) == 4 { - &VARTX_RECT_LEAF4_HITS - } else { - &VARTX_RECT_LEAF_HITS - }; - cell.with(|c| { - let mut h = c.get(); - h[usize::from(th > tw)] += 1; - c.set(h); - }); -} - -// How many `partition_w16` reads (a 16x16 block's own partition symbol, key -// intra-frame path) resolved to `PARTITION_VERT_B` -- lane-rect16 r1: a -// plain default-settings aomenc run over lavfi mandelbrot hits this arm on -// frame 0's very first non-NONE/SPLIT `partition_w16` symbol (mi=(3,2)), not -// the plain HORZ/VERT this lane's charter assumed. Left rect (8x16, real -// `decode_block_rect`) + two 8x8 leaves stacked on the right (`decode_leaf8`, -// chained via `prev_leaf` exactly like the existing 16x16-SPLIT-into-4x8x8 -// path above). -thread_local! { - pub(super) static VERT_B_INTRA_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`VERT_B_INTRA_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn vert_b_intra_hits() -> usize { - VERT_B_INTRA_HITS.with(|c| c.get()) -} - -// lane-ab16 r1: how many 16x16-level AB partitions fired, per arm, in -// `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B` order. Each arm is two -// 8x8 squares (`decode_leaf8`) plus one 16x8/8x16 strip (`decode_leaf_rect`, -// the non-skip coefficient path lane-rectx proved); the gate hard-asserts -// every arm separately so a run where aomenc's RD only picked one cannot -// pass as proof of four. -thread_local! { - pub(super) static AB16_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; -} - -// [`AB16_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16). -thread_local! { - /// 4x4 transform units decoded inside an 8x8 square of a - /// `PARTITION_VERT_A`/`_B` -- the exact call that panicked before - /// [`crate::encode::Reach::of_tu`] (lane-ab16 r2), so the gate can prove - /// a real `--enable-tx-size-search=1` stream reaches it. - pub(super) static VERT_AB_TX4_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn vert_ab_tx4_hits() -> usize { - VERT_AB_TX4_HITS.with(std::cell::Cell::get) -} - -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn ab16_hits_by_arm() -> [usize; 4] { - AB16_HITS.with(std::cell::Cell::get) -} - -// How many `partition_w16` reads resolved to a plain `PARTITION_HORZ`/ -// `PARTITION_VERT` (lane-rect16 r2): re-measuring after the VERT_B fix above -// showed mandelbrot's real first-hit blocker is this plain arm at mi=(0,7), -// not VERT_B (`refusal-names-a-correlate`; the VERT_B write-up's "frame 0's -// very first non-NONE/SPLIT symbol" claim was about decode ORDER within one -// superblock's z-order recursion, not raster mi position). -thread_local! { - pub(super) static HORZ_VERT_INTRA_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`HORZ_VERT_INTRA_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn horz_vert_intra_hits() -> usize { - HORZ_VERT_INTRA_HITS.with(|c| c.get()) -} - -// How many blocks were decoded as a frame-edge rect strip -- the single -// coded half of a `PARTITION_HORZ`/`PARTITION_VERT` at the true frame edge -// (lane-oddh r1), i.e. a block living inside the 8px band of a frame whose -// height or width is 8 mod 16 (the user's 3840x1608 film). Intra and inter -// paths share the counter. -thread_local! { - pub(super) static EDGE_RECT_STRIP_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`EDGE_RECT_STRIP_HITS`]. -#[allow(dead_code)] // gate counter accessor with no reader yet; the counter itself is live -pub(crate) fn edge_rect_strip_hits() -> usize { - EDGE_RECT_STRIP_HITS.with(|c| c.get()) -} - -// lane-interedge r1: frame-edge half strips on the INTER path, per partition -// level (64/32/16) x axis (HORZ at a bottom edge, VERT at a right edge). The -// index is `level_idx * 2 + axis` with `level_idx` 0=64, 1=32, 2=16 and -// `axis` 0=HORZ (`!has_rows`), 1=VERT (`!has_cols`). Both of the user's films -// are height mod 16 == 8, so every inter frame crosses these nodes. -thread_local! { - pub(super) static INTER_EDGE_STRIP_HITS: std::cell::Cell<[usize; 6]> = - const { std::cell::Cell::new([0; 6]) }; -} - -// lane-edgeboth r1: how many partition nodes were coded as the BOTH-AXES-CUT -// forced split -- libaom `decode_partition` (decodeframe.c): -// `else if (!has_rows && !has_cols) partition = PARTITION_SPLIT;`, the one -// straddle case that reads NO symbol at all. Indexed by level: -// 0 = 16x16, 1 = 32x32, 2 = 64x64, 3 = 128x128; intra and inter share it. -thread_local! { - pub(super) static EDGE_BOTH_CUT_HITS: std::cell::Cell<[usize; 4]> = - const { std::cell::Cell::new([0; 4]) }; -} - -/// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`). -pub fn inter_edge_strip_hits() -> [usize; 6] { - INTER_EDGE_STRIP_HITS.with(|c| c.get()) -} - -/// Resets [`INTER_EDGE_STRIP_HITS`] -- a refused attempt must not carry hits -/// into the next one (class `counter-from-refused-stream`). -pub fn reset_inter_edge_strip_hits() { - INTER_EDGE_STRIP_HITS.with(|c| c.set([0; 6])); -} - -/// Current value of [`EDGE_BOTH_CUT_HITS`] (`[16, 32, 64, 128]` levels). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn edge_both_cut_hits() -> [usize; 4] { - EDGE_BOTH_CUT_HITS.with(|c| c.get()) -} - -/// Zeroes [`EDGE_BOTH_CUT_HITS`] so a gate can measure a per-attempt delta. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_edge_both_cut_hits() { - EDGE_BOTH_CUT_HITS.with(|c| c.set([0; 4])); -} - -// How many HORZ/VERT intra strips resolved a SPLIT luma transform -// (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) -- -// the case every rect path here refused by name before, and the first -// refusal the user's ReelB extract (600s in) stops at. -thread_local! { - pub(super) static RECT_SPLIT_TX_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT_SPLIT_TX_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_split_tx_hits() -> usize { - RECT_SPLIT_TX_HITS.with(|c| c.get()) -} - -// The subset of [`RECT_SPLIT_TX_HITS`] that is BOTH superblock-level (one -// side 64) AND split past the first depth, i.e. tiled more than one unit in -// each axis -- the only shape with a transform unit that has neighbours on -// two sides inside its own strip (`row_off > 0 && col_off > 0`), and the one -// no gate fired before lane-rectsplit r2 (the shared counter above also -// counts 32x32-level and depth-1 strips, so it cannot prove this case). -thread_local! { - pub(super) static RECT_SPLIT_SB_INTERIOR_TU_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT_SPLIT_SB_INTERIOR_TU_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_split_sb_interior_tu_hits() -> usize { - RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.get()) -} - -// Per-shape hit counts for the rect chroma transforms lane-rectchroma r1 -// wired into [`decode_rect_split`] -- the shapes a split-transform strip's -// chroma half takes that had no coefficient tables before (index order: -// 32x8, 8x32, 8x4, 4x8). One counter per shape because a gate that only -// proves the pair it happens to hit cannot catch a transposed scan/context -// table (class scan-weights-cross-axis). -thread_local! { - pub(super) static RECT_SPLIT_CHROMA_SHAPE_HITS: std::cell::Cell<[usize; 4]> = - const { std::cell::Cell::new([0; 4]) }; -} - -/// Current value of [`RECT_SPLIT_CHROMA_SHAPE_HITS`] (32x8, 8x32, 8x4, 4x8). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_split_chroma_shape_hits() -> [usize; 4] { - RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| c.get()) -} - -// lane-av1-422: how many SQUARE chroma coefficient units the strip path read -// on a 4:2:2 frame (ss 1,0) -- the half-width, unhalved-height shape whose -// tables only exist because of the square rows in the chroma_tiled arm. A -// 4:2:0 or 4:4:4 frame can never increment it (their rect strips' chroma is -// itself rect), and a restored `/2 chroma height` diverts 4:2:2 squares onto -// the rect rows, so the witness gate reads 0 there and fails. -thread_local! { - pub(super) static CHROMA422_SQUARE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`CHROMA422_SQUARE_HITS`]. -// lane-av1-422b: `pub` so `examples/decode_probe.rs` can census it the way -// it does every other capability counter. -pub fn chroma422_square_hits() -> usize { - CHROMA422_SQUARE_HITS.with(|c| c.get()) -} - -// lane-av1422tailskip: how many 4:2:2 (ss 1,0) intra-in-inter chroma TRANSFORM -// UNITS took their own window on the block-sized chroma palette prediction -- -// `decode_inter_block`'s `side == 64` TX_32X32 walk, where the plane block is -// 32x64 but codes two stacked square units per plane. Zero on a 4:2:0 or 4:4:4 -// frame (their chroma unit is the whole plane block, one window), and zero on -// a 4:2:2 block with no palette, so a witness gate reading 0 proves the arm -// never ran. -thread_local! { - pub(super) static PALETTE_422_UNIT_WINDOW_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`PALETTE_422_UNIT_WINDOW_HITS`]. -// lane-av1422tailskip: `pub` so `examples/decode_probe.rs` can census it the -// way it does every other capability counter. -pub fn palette_422_unit_window_hits() -> usize { - PALETTE_422_UNIT_WINDOW_HITS.with(|c| c.get()) -} - -// lane-av1-422f: how many RECT chroma coefficient units the square-block -// path read on a 4:2:2 frame (ss 1,0) -- TX_4X8 / TX_8X16 / TX_16X32, the -// plane block's own half-width, unhalved-height shape. A 4:2:0 or 4:4:4 -// frame never takes the rect branch (their units are square -// `chroma_tx == chroma_tx_h`), so a witness gate reading 0 here proves the -// model reverted to squares. -thread_local! { - pub(super) static CHROMA422_RECT_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`CHROMA422_RECT_HITS`]. -pub fn chroma422_rect_hits() -> usize { - CHROMA422_RECT_HITS.with(|c| c.get()) -} - -// lane-av1-422g: how many PER-LEAF TX_4X4 chroma coefficient units the -// sub-8x8 split4 path read on a 4:2:2 frame (ss 1,0) -- one per even-column -// leaf per plane (`is_chroma_reference`'s `!(mi_col & ss_x)`). A 4:2:0 frame -// codes no sub-8 chroma at all and 4:4:4 goes through `sub8_leaf_chroma444`, -// so a witness gate reading 0 here proves the per-leaf 4:2:2 arm never ran. -thread_local! { - pub(super) static CHROMA422_SUB8_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`CHROMA422_SUB8_HITS`]. -pub fn chroma422_sub8_hits() -> usize { - CHROMA422_SUB8_HITS.with(|c| c.get()) -} - -// lane-av1422llintra: how many 4:2:2 LOSSLESS chroma plane blocks -// (`decode_leaf8`) were walked as 4x4 units rather than as the one -// `av1_get_max_uv_txsize` rect that rule only reaches OUTSIDE a lossless -// frame. A 4:2:0 or 4:4:4 frame never takes the arm (its own lossless walk -// was already there), so a witness gate reading 0 here proves the model -// reverted to the rect unit. -thread_local! { - pub(super) static CHROMA422_LOSSLESS_4X4_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`CHROMA422_LOSSLESS_4X4_HITS`]. -pub fn chroma422_lossless_4x4_hits() -> usize { - CHROMA422_LOSSLESS_4X4_HITS.with(|c| c.get()) -} - -// lane-av1-422sub8rect: how many PER-PIECE TX_4X4 chroma coefficient units -// the INTER sub-8x8 split4 path read on a 4:2:2 frame (ss 1,0) -- one per -// non-skipped odd-column piece per plane (`is_chroma_reference`'s -// `mi_col & 0x01` at ss_x 1). 4:2:0 goes through the shared group unit and -// 4:4:4 through [`sub8_leaf_chroma444`]'s own per-piece twin, so a witness -// gate reading 0 here proves the inter 4:2:2 per-piece arm never ran. -thread_local! { - pub(super) static CHROMA422_INTER_SUB8_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`CHROMA422_INTER_SUB8_HITS`]. -pub fn chroma422_inter_sub8_hits() -> usize { - CHROMA422_INTER_SUB8_HITS.with(|c| c.get()) -} - -// lane-av1-422m: how many TX_4X4 chunk units the invalid-ss-size chroma arm -// read (the 8x32 luma block whose 4:2:2 plane has no `ss_size_lookup` block). -// A 4:2:0 or 4:4:4 frame cannot increment it, so a non-zero read proves the -// chunked 4:2:2 chroma really decoded. -thread_local! { - pub(super) static CHROMA422_CHUNK_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`CHROMA422_CHUNK_HITS`]. -pub fn chroma422_chunk_hits() -> usize { - CHROMA422_CHUNK_HITS.with(|c| c.get()) -} - -// lane-av1-422stripanchor: how many 4-wide-strip PAIR chroma units -// ([`decode_rect_split`]'s ported floored-pair anchor) decoded. A 4:2:0 or -// 4:4:4 frame cannot increment it (the arm is keyed to a 2-px-wide chroma -// block, which only a 1-mi-wide strip at ss (1, 0) produces), so a non-zero -// read proves a stream routed a 4-wide strip through the split path. -thread_local! { - pub(super) static CHROMA422_PAIR_WIDE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`CHROMA422_PAIR_WIDE_HITS`]. -pub fn chroma422_pair_wide_hits() -> usize { - CHROMA422_PAIR_WIDE_HITS.with(|c| c.get()) -} - -// How many HORZ/VERT intra strips actually predicted with filter intra -// (lane-rectsplit r1) -- the case `decode_block_rect` refused by name -// ("this decoder predicts square-only") until `predict_filter_intra` took -// `bw`x`bh`. -thread_local! { - pub(super) static FILTER_INTRA_RECT_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`FILTER_INTRA_RECT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn filter_intra_rect_hits() -> usize { - FILTER_INTRA_RECT_HITS.with(|c| c.get()) -} - -// As [`FILTER_INTRA_RECT_HITS`], counting only the 32x32-level 1:4 strips -// (32x8/8x32, lane-fi32x8 r1) -- the shapes whose `use_filter_intra` symbol -// was never read at all before that round, so a gate needs to prove the flag -// fired at THAT shape and not at a 16x8 one somewhere else in the frame. -// Split by ORIENTATION: rows 8 (32x8) and 9 (8x32) of `cdf::FILTER_INTRA` -// carry different probabilities (18101 vs 20229), so a transposed pair is -// only caught by a gate that sees the flag fire on BOTH shapes (class -// scan-weights-cross-axis). -thread_local! { - pub(super) static FILTER_INTRA_RECT4_HORZ_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; - pub(super) static FILTER_INTRA_RECT4_VERT_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`FILTER_INTRA_RECT4_HORZ_HITS`] (32x8 strips). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn filter_intra_rect4_horz_hits() -> usize { - FILTER_INTRA_RECT4_HORZ_HITS.with(|c| c.get()) -} - -/// Current value of [`FILTER_INTRA_RECT4_VERT_HITS`] (8x32 strips). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn filter_intra_rect4_vert_hits() -> usize { - FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.get()) -} - -// How many rectangular transform units actually coded coefficients through -// [`read_coeffs_rect`] (`all_zero == 0`) -- lane-rect1d's measure that a gate -// exercised the rect coefficient reader at all rather than passing on -// all-skip blocks. -thread_local! { - pub(super) static RECT_COEFF_TU_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static RECT_CLASS1_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT_COEFF_TU_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_coeff_tu_hits() -> usize { - RECT_COEFF_TU_HITS.with(|c| c.get()) -} - -/// Rectangular transform units whose resolved `tx_type` is a 1D class -/// (`V_DCT`/`H_DCT`) -- [`TX_CLASS1_HITS`]'s rect-only half, so a gate can -/// pin that the 1D-class-on-a-RECT-transform path fired rather than settling -/// for the square reader's own 1D types. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_class1_hits() -> usize { - RECT_CLASS1_HITS.with(|c| c.get()) -} - -// lane-av1readcensus: the PER-UNIT coefficient census -- one unit counted -// per `read_coeffs`/`read_coeffs_rect` call, i.e. per object this decoder -// actually walks, which is the unit the round-4 `av1444rect` count measured -// (636 square chroma reads against the oracle's 1086). -// -// lane-av1422census422 widened the arming. The counters used to be -// 4:4:4-ONLY (`CENSUS_444`), so at 4:2:2 -- a chroma format an AV1 -// `color_config` can carry and libaom's writer emits -- every -// `census_444_units()` / `census_444_coded()` read zero BY CONSTRUCTION: a -// byte-exact 4:2:2 gate asserting those counters would be asserting a -// literal, and would be green while proving nothing about that stream. The -// census is now armed for every chroma format that leaves at least one luma -// axis unsubsampled -- (0,0) 4:4:4 and (1,0) 4:2:2 -- and 4:2:0 (1,1) stays -// off, so the existing 4:4:4 exact counts and the 4:2:0 zero control are -// unmoved by the widening. The counters are per-PLANE, not per-format, so a -// 4:2:2 cell's `[luma, u, v]` split is directly comparable with a 4:4:4 -// cell's on the same walk shape. -thread_local! { - /// Per-plane unit counts, `[luma, u, v]`, at 4:4:4 and 4:2:2. - pub(super) static CENSUS_NONSUB_UNITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; - /// Of [`CENSUS_NONSUB_UNITS`], the units that coded at least one - /// coefficient (`txb_skip == 0`) -- the per-plane split is only - /// comparable against the oracle's when both sides count all-zero units - /// the same way. - pub(super) static CENSUS_NONSUB_CODED: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; - /// Sequential unit index, so a trace line names its own position in the - /// frame's walk rather than relying on line order alone. - pub(super) static CENSUS_UNIT_N: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// The plane the units read from here on belong to. A thread-local rather - /// than a `read_coeffs` parameter because the three luma call sites - /// (`decode_rect_split`, `decode_block_rect64`, `read_inter_plane_rect`) - /// are not this lane's to edit and would each grow an argument; the - /// plane-owning readers stamp it once on entry instead. - pub(super) static CENSUS_PLANE: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// At least one luma axis unsubsampled -- (0,0) 4:4:4 or (1,0) 4:2:2 -- - /// for the frame being decoded, set per frame from [`crate::stream`]. - /// 4:2:0 (1,1) arms nothing. - pub(super) static CENSUS_NONSUB: std::cell::Cell = const { std::cell::Cell::new(false) }; -} - -/// Current `[luma, u, v]` coefficient-unit counts, per plane. Zero at 4:2:0 -/// by design ([`set_census_nonsub`] arms nothing there). -pub fn census_nonsub_units() -> [usize; 3] { - CENSUS_NONSUB_UNITS.with(|c| c.get()) -} - -/// Current `[luma, u, v]` counts of units that coded coefficients. -pub fn census_nonsub_coded() -> [usize; 3] { - CENSUS_NONSUB_CODED.with(|c| c.get()) -} - -/// lane-av1readcensus: arms the coefficient-unit census for the frame about -/// to decode, called once per frame from [`crate::stream`]'s decode loop -/// beside [`set_subsampling`]. Armed for every chroma format with an -/// unsubsampled luma axis -- 4:4:4 (0,0) and 4:2:2 (1,0) -- and NOT for -/// 4:2:0 (1,1), where the walk-shape question this census answers does not -/// arise, so a 4:2:0 control can still assert exactly zero. -/// -/// lane-av1422census422 widened this from `(ss_x == 0 && ss_y == 0)`. The -/// old condition made 4:2:2 silently UNCUNTABLE rather than uncounted. The -/// two format pairs keep disjoint conditions, so neither the 4:4:4 exact -/// counts nor the 4:2:0 zero control can move because of this. -pub(crate) fn set_census_nonsub(ss_x: u8, ss_y: u8) { - CENSUS_NONSUB.with(|c| c.set(ss_x == 0 || ss_y == 0)); -} - -/// lane-av1readcensus: the plane the units read from here on belong to, -/// stamped by the plane-owning readers ([`read_plane`], [`read_inter_plane`], -/// [`read_inter_plane_rect`]) on entry. -pub(crate) fn set_census_plane(plane: usize) { - CENSUS_PLANE.with(|c| c.set(plane)); -} - -/// lane-av1readcensus: is the per-unit census trace on? Shares -/// [`coeff_trace_on`]'s per-frame narrowing so one frame's walk can be -/// dumped without the rest of the stream. -fn census_trace_on() -> bool { - if !crate::envflags::env_flag!("EC_CENSUS_UNIT") { - return false; - } - match COEFF_TRACE_FRAME.with(|c| c.get()) { - None => true, - Some(w) if w >= usize::MAX - 1 => true, - Some(w) => COEFF_TRACE_CUR.with(|c| c.get()) == w, - } -} - -/// lane-av1readcensus: one line per coefficient unit this decoder walks, the -/// twin of the oracle's `EC_COEFF` / `EC_COEFF_VAL` bracket around each -/// `av1_read_coeffs_txb` call. Pair the two sides by `post_rng` (or by `n`), -/// never by plane label or by walk position -- the walk order is exactly what -/// the census is measuring. -pub(super) fn census_unit( - w: usize, - h: usize, - tx_type: TxType, - eob: usize, - all_zero: bool, - entry_rng: u32, - dec: &SymbolDecoder, -) { - let plane = CENSUS_PLANE.with(|c| c.get()).min(2); - let coded = usize::from(!all_zero); - CENSUS_UNIT_N.with(|c| c.set(c.get() + 1)); - hit_do! { - CENSUS_NONSUB_UNITS.with(|c| { - if CENSUS_NONSUB.with(|on| on.get()) { - let mut v = c.get(); - v[plane] += 1; - c.set(v); - } - }); - CENSUS_NONSUB_CODED.with(|c| { - if CENSUS_NONSUB.with(|on| on.get()) { - let mut v = c.get(); - v[plane] += coded; - c.set(v); - } - }); - } - if !census_trace_on() { - return; - } - let n = CENSUS_UNIT_N.with(|c| c.get()) - 1; - let post_rng = dec.debug_state().0; - eprintln!( - "EC_CENSUS_UNIT side=ours n={n} plane={plane} w={w} h={h} tx={tx_type:?} eob={eob} \ - all_zero={all_zero} entry_rng={entry_rng} post_rng={post_rng}" - ); -} - -/// How many transform units this thread has read since the last -/// [`reset_census_unit_n`] (lane-av1offtile). The per-unit oracle twin is -/// `EC_ECDUMP_IN`, one line per `read_coeffs_txb` call, so this count IS -/// directly comparable with an oracle `EC_ECDUMP_IN` census -- which is what -/// makes "we walk N units where libaom walks M" a gated claim rather than an -/// inference from the desync's position. -pub fn census_unit_n() -> usize { - CENSUS_UNIT_N.with(|c| c.get()) -} - -/// Reset [`census_unit_n`] to zero (lane-av1offtile). -pub fn reset_census_unit_n() { - CENSUS_UNIT_N.with(|c| c.set(0)); -} - -// As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16 -// (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the -// shapes whose `use_filter_intra` symbol had no CDF class before this round. -// A gate asserting the wider counter would be satisfied by a 32x16 strip and -// prove nothing about the new shapes. -thread_local! { - pub(super) static FILTER_INTRA_RECT_SUB16_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`FILTER_INTRA_RECT_SUB16_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn filter_intra_rect_sub16_hits() -> usize { - FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get()) -} - -// As [`FILTER_INTRA_RECT_SUB16_HITS`], one partition level further down: -// 4x8/8x4 leaves of an 8x8 HORZ/VERT (lane-fi8 r1). A gate on the sub16 -// counter would be satisfied by a 16x8 strip and prove nothing here. -thread_local! { - pub(super) static FILTER_INTRA_RECT_SUB8_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`FILTER_INTRA_RECT_SUB8_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn filter_intra_rect_sub8_hits() -> usize { - FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.get()) -} - -// How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D` -// (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every -// call on the current thread -- the same before/after counter pattern as -// [`TX_DEPTH_HITS`], proving a stream actually exercised the class-split -// `eob_pt`/1D-neighbour context path rather than every block coincidentally -// landing on `DCT_DCT`. -thread_local! { - pub(super) static TX_CLASS1_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -// How many `uv_mode` reads resolved to a directional chroma mode (neither -// `DC_PRED` nor `UV_CFL_PRED`), across every call on the current thread -- the same -// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream -// actually exercised chroma's own directional predictor. -thread_local! { - pub(super) static DIRECTIONAL_UV_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`DIRECTIONAL_UV_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn directional_uv_hits() -> usize { - DIRECTIONAL_UV_HITS.with(|c| c.get()) -} - -// How many `angle_delta`/`angle_delta_uv` symbols this decoder has read as -// something other than [`ANGLE_DELTA_ZERO`], across every call in the -// process -- the same before/after counter pattern as [`FILTER_INTRA_HITS`], -// proving a stream actually exercised a nonzero angle delta. -thread_local! { - pub(super) static ANGLE_DELTA_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -// How many [`read_single_ref`] reads resolved to a reference other than -// `LAST_FRAME`, across every call on the current thread -- the same before/after -// counter pattern as [`FILTER_INTRA_HITS`], proving a stream actually -// exercised a non-`LAST_FRAME` reference (`GOLDEN_FRAME`, this decoder's -// only other supported one so far) rather than every block coincidentally -// resolving `LAST_FRAME`. -thread_local! { - pub(super) static NON_LAST_REF_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`NON_LAST_REF_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn non_last_ref_hits() -> usize { - NON_LAST_REF_HITS.with(|c| c.get()) -} - -// Per-reference [`NON_LAST_REF_HITS`] breakdown (lane-av1refs): one counter -// per `MV_REFERENCE_FRAME` past `LAST_FRAME`, so a gate targeting one -// specific reference (`LAST2`/`LAST3`/`GOLDEN`/`BWDREF`/`ALTREF2`/`ALTREF`) -// can prove THAT reference fired rather than any non-`LAST_FRAME` one -- -// `NON_LAST_REF_HITS` alone cannot tell a `LAST2_FRAME` gate from a -// `GOLDEN_FRAME` draw it did not ask for. -thread_local! { - pub(super) static LAST2_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -thread_local! { - pub(super) static LAST3_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -thread_local! { - pub(super) static GOLDEN_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -thread_local! { - pub(super) static BWDREF_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -thread_local! { - pub(super) static ALTREF2_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -thread_local! { - pub(super) static ALTREF_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -// How many [`read_comp_mode`] reads resolved `COMPOUND_REFERENCE` (lane-av1comp) -// -- proves a `reference_select` stream actually reached a block that picked -// compound, not just that the header bit was set. Every such block is -// refused after this fires ([`decode_inter_block`]/[`decode_inter_block8`]), -// so this only ever counts attempted reads, never a completed decode. -thread_local! { - pub(super) static COMP_MODE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`COMP_MODE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn comp_mode_hits() -> usize { - COMP_MODE_HITS.with(|c| c.get()) -} - -// How many blocks [`read_intra_mode`] decoded a real (nonzero-size) palette-Y -// use for, across every call on the current thread -- the same before/after -// counter pattern as [`FILTER_INTRA_HITS`], proving a stream actually -// exercised palette reconstruction rather than only reading and refusing the -// `palette_y_mode` symbol. -thread_local! { - pub(super) static PALETTE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`PALETTE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn palette_hits() -> usize { - PALETTE_HITS.with(|c| c.get()) -} - -// lane-tiles r12: of those, how many sat at their own TILE's left column -- -// exactly the blocks whose palette cache/ctx must NOT see the previous tile's -// colours (`av1_get_palette_cache`'s `xd->left_mbmi == NULL`). A multi-tile -// palette gate that never hits one proves nothing about the tile guard. -thread_local! { - pub(super) static PALETTE_TILE_LEFT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`PALETTE_TILE_LEFT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn palette_tile_left_hits() -> usize { - PALETTE_TILE_LEFT_HITS.with(|c| c.get()) -} - -// lane-palette2 r1: as [`PALETTE_HITS`], for a real (nonzero-size) chroma -// palette use -- proves a stream actually reconstructed UV palette pixels, -// not just read and refused the `palette_uv_mode` symbol. -thread_local! { - pub(super) static PALETTE_UV_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`PALETTE_UV_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn palette_uv_hits() -> usize { - PALETTE_UV_HITS.with(|c| c.get()) -} - -// lane-palette2 r1: how many HORZ/VERT rect intra strips ([`read_intra_mode_rect`]) -// decoded a real palette-Y use -- proves the rect strip's own palette syntax -// (not just the square path's) actually fired. -thread_local! { - pub(super) static PALETTE_RECT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`PALETTE_RECT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn palette_rect_hits() -> usize { - PALETTE_RECT_HITS.with(|c| c.get()) -} - -// lane-palette2 r6: how many HORZ/VERT rect intra strips ran the -// [`palette_bsize_ctx_wh`]-gated code path in [`read_intra_mode_rect`] -- -// i.e. `allow_screen_content_tools` was set and the strip's `bw`x`bh` was in -// range, so `palette_y_mode`/`palette_uv_mode` were actually read (and, per -// RD, almost always refused-on-use because the block doesn't end up USING a -// palette -- see r5's report). This is the site the removed refusal -// ("a HORZ/VERT intra strip in a screen-content frame") used to guard: it -// fired here whether or not the block picked a palette, so this is the -// counter that proves the case r5's narrower [`PALETTE_RECT_HITS`] almost -// never observes. -thread_local! { - pub(super) static RECT_SCREEN_CONTENT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT_SCREEN_CONTENT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_screen_content_hits() -> usize { - RECT_SCREEN_CONTENT_HITS.with(|c| c.get()) -} - -// lane-palette2 r1: how many palette-Y luma transform UNITS decoded under a -// split luma transform (`logical_tx != side`) -- proves the per-TU index-map -// windowing actually ran, not just that the whole-block path stayed exact. -// Counts units, not blocks (a 64x64 palette block split to 16x16 TUs adds 16); -// first actually incremented in r7, when the refusal it guarded was lifted. -thread_local! { - pub(super) static PALETTE_SPLIT_TX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -thread_local! { - /// lane-kf900 r4: rect intra strips that ACTUALLY use a palette -- the - /// 1:4 shapes (32x8/8x32, 16x4/4x16) and the sub-16x16 2:1 leaves - /// (16x8/8x16), the two shapes the lifted refusals named. - pub(super) static RECT4_PALETTE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT4_PALETTE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect4_palette_hits() -> usize { - RECT4_PALETTE_HITS.with(|c| c.get()) -} - -/// Current value of [`PALETTE_SPLIT_TX_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn palette_split_tx_hits() -> usize { - PALETTE_SPLIT_TX_HITS.with(|c| c.get()) -} - -thread_local! { - /// lane-av1444d10: chroma PREDICTION units on the 32-capped tiled chroma - /// walk (`decode_block_rect`'s `uw/uh = min(chroma, 32)` units) that were - /// handed a STRICT sub-slice of their block's palette buffer -- i.e. the - /// units of a block the 32-cap actually TILED (`nw * nh > 1`). - /// - /// CORRECTED 2026-09-30 after the refutation pass `lanes/refute-av1444d10` - /// read the numbers back: the previous comment claimed it counted "the - /// units that are NOT the block's top-left corner", which is not what the - /// code did -- the hit was unconditional, so a block's corner unit fired it - /// too AND a single-unit block (whose window is a pure re-stride copy of - /// the whole buffer) fired it as well. That made a hit prove only that some - /// palette chroma block existed, not that the tiled arm ran. The `bigger` - /// guard now makes the counter discriminate. On the pinned fixture the - /// measured value is unchanged at 4 (one block with nw = 1, nh = 2 x two - /// planes x two unit rows); a stream whose palette chroma blocks are all - /// single-unit now leaves it at zero. - /// - /// FURTHER CORRECTED the same day by the palette lane's refutation - /// (`lanes/av1444palw.report.md` + the arm-isolated mutation): the guard is - /// about TILING, not about `nw > 1` specifically. Isolating the two window - /// sites shows the RECT-unit arm alone reds the 10-bit cell, and the - /// SQUARE-unit arm alone reds the 12-bit cell *and* the 10-bit one -- so - /// windowing is load-bearing for every tiled block, and `nw > 1` is merely - /// the case the corpus could not reach. Do not read this counter as - /// evidence that only the horizontal term matters. - pub(super) static CHROMA_PALETTE_WINDOW_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`CHROMA_PALETTE_WINDOW_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn chroma_palette_window_hits() -> usize { - CHROMA_PALETTE_WINDOW_HITS.with(|c| c.get()) -} - -/// Zeroes [`CHROMA_PALETTE_WINDOW_HITS`] so a gate can read it as a DELTA -/// (it is process-wide, like every counter here). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_chroma_palette_window_hits() { - CHROMA_PALETTE_WINDOW_HITS.with(|c| c.set(0)); -} - -thread_local! { - /// lane-pal8 r1: square 8x8 LEAVES ([`decode_leaf8`]) that actually use a - /// palette (Y or UV) -- the shape every 8-bit `--tune-content=screen` - /// stream stopped on, since aomenc palettes square blocks at 8 bit and - /// `--min-partition-size=8` puts them on this leaf path. - pub(super) static PALETTE_LEAF8_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`PALETTE_LEAF8_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn palette_leaf8_hits() -> usize { - PALETTE_LEAF8_HITS.with(|c| c.get()) -} - -/// Zeroes [`PALETTE_LEAF8_HITS`] (per-attempt gate counting). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_palette_leaf8_hits() { - PALETTE_LEAF8_HITS.with(|c| c.set(0)); -} - -thread_local! { - /// lane-pal8 r1: NON-SKIP palette blocks on a superblock-level (64-level) - /// HORZ/VERT or 1:4 strip ([`decode_block_rect64`]) -- i.e. a palette - /// block that also carries a real, corner-cropped luma transform. - pub(super) static PALETTE_SB_STRIP_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`PALETTE_SB_STRIP_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn palette_sb_strip_hits() -> usize { - PALETTE_SB_STRIP_HITS.with(|c| c.get()) -} - -/// Zeroes [`PALETTE_SB_STRIP_HITS`] (per-attempt gate counting). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_palette_sb_strip_hits() { - PALETTE_SB_STRIP_HITS.with(|c| c.set(0)); -} - -thread_local! { - /// lane-av1rectreach: units of `decode_rect_split`'s `chroma_tiled` walk - /// whose PER-UNIT reach ([`tu_reach_rect`], libaom's per-unit - /// `has_top_right` / `has_bottom_left`) DIFFERS from the block-level - /// `reach` this walk used to hand every unit -- i.e. units for which the - /// two answers are not interchangeable. This is what a gate needs before - /// it compares the walk byte-exactly: if the two agreed everywhere, the - /// substitution could not change a single predicted sample and the - /// exactness assert would be measuring a witness the fix cannot touch. - /// - /// What it does NOT prove is that the argument handed to the unit reader - /// is the per-unit one -- the count is taken from the same expression - /// either way, so deleting the substitution reds the exactness assert - /// rather than this counter. That is the right way round: the assert is - /// the claim, this is only the floor under it. - pub(super) static RECT_TILED_CHROMA_UNIT_REACH_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; - /// Chroma units of the same walk whose grid is exactly 2x1 (a 4:4:4 - /// 64x32 chroma plane block as two 32x32 units). - pub(super) static RECT_TILED_CHROMA_2X1_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// Chroma units of the same walk whose grid is exactly 1x2 (4:4:4 32x64, - /// or 16x64 as two 16x32s). - pub(super) static RECT_TILED_CHROMA_1X2_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// Chroma units of the same walk in any other multi-unit grid (2x2 and - /// up). lane-av1422lift: this used to say "only reachable at 4:2:2, which - /// is refused, so this stays 0 on every admitted stream", and that was - /// true. 4:2:2 is decoded now, so the "cannot happen" is gone -- but the - /// arm is still UNWITNESSED: measured on this branch's tip over all 21 - /// committed 4:2:2 cells and over the 4:2:0 / 4:4:4 cells probed, it - /// reads 0 on every one of them. No committed gate reads it either (the - /// only readers of `rect_tiled_chroma_grid_hits()` are two 4:4:4 strip - /// gates, where `nxn` is interpolated into a failure message and never - /// asserted). Kept so the match above is exhaustive. - pub(super) static RECT_TILED_CHROMA_NXN_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current values of the four `RECT_TILED_CHROMA_*` counters, in the order -/// `(unit_reach_differs, 2x1, 1x2, other multi-unit)`. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_tiled_chroma_grid_hits() -> (usize, usize, usize, usize) { - ( - RECT_TILED_CHROMA_UNIT_REACH_HITS.with(|c| c.get()), - RECT_TILED_CHROMA_2X1_HITS.with(|c| c.get()), - RECT_TILED_CHROMA_1X2_HITS.with(|c| c.get()), - RECT_TILED_CHROMA_NXN_HITS.with(|c| c.get()), - ) -} - -/// Zeroes the four `RECT_TILED_CHROMA_*` counters (gate tests call this -/// before their own decode). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_rect_tiled_chroma_grid_hits() { - RECT_TILED_CHROMA_UNIT_REACH_HITS.with(|c| c.set(0)); - RECT_TILED_CHROMA_2X1_HITS.with(|c| c.set(0)); - RECT_TILED_CHROMA_1X2_HITS.with(|c| c.set(0)); - RECT_TILED_CHROMA_NXN_HITS.with(|c| c.set(0)); -} - -// lane-t900 r22: palette blocks reconstructed inside an INTER frame (the -// intra-in-inter path, `decode_inter_block`/`decode_inter_block8`) -- counted -// apart from [`PALETTE_HITS`] so a witness gate can prove the INTER-frame -// capability rather than the key frame's, which every screen stream also -// carries. -thread_local! { - pub(super) static INTRA_IN_INTER_PALETTE_Y_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static INTRA_IN_INTER_PALETTE_UV_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -// lane-t900 r23: as [`INTRA_IN_INTER_PALETTE_Y_HITS`], narrowed to the 8x8 -// LEAF site ([`decode_inter_block8`]'s intra arm) -- the >=16 site fires the -// shared counter too, so only this one proves a gate really reached the leaf -// where the refusal used to sit. -thread_local! { - pub(super) static INTER8_PALETTE_HITS: std::cell::Cell<(usize, usize)> = - const { std::cell::Cell::new((0, 0)) }; -} - -/// Current values of the 8x8-leaf intra-in-inter palette counters, `(y, uv)`. -pub(crate) fn inter8_palette_hits() -> (usize, usize) { - INTER8_PALETTE_HITS.with(std::cell::Cell::get) -} - -/// Current values of the two intra-in-inter palette counters, `(y, uv)`. -pub(crate) fn intra_in_inter_palette_hits() -> (usize, usize) { - ( - INTRA_IN_INTER_PALETTE_Y_HITS.with(|c| c.get()), - INTRA_IN_INTER_PALETTE_UV_HITS.with(|c| c.get()), - ) -} - -// lane-hgkf r2: SKIPPED intra blocks whose `tx_depth` split the luma transform -// and which are therefore predicted one transform unit at a time (a skipped -// block codes no coefficients, so nothing else in the stream witnesses this -// path -- only the pixels do). -thread_local! { - pub(super) static SKIP_SPLIT_TX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`SKIP_SPLIT_TX_HITS`] (blocks, not units). -pub fn skip_split_tx_hits() -> usize { - SKIP_SPLIT_TX_HITS.with(|c| c.get()) -} - -// lane-svt1: SKIPPED square blocks carrying a palette/intrabc prediction whose -// `tx_depth` split the luma transform -- the arm that predicted DC off the -// block edges before the fix. Like [`SKIP_SPLIT_TX_HITS`] only the pixels -// witness this path, so a gate that wants it needs the counter. -thread_local! { - pub(super) static SKIP_SPLIT_TX_OVERRIDE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1chromadc: chroma units of a skipped block whose intra-BC / - /// UV-palette override had to be WINDOWED to the unit's own extent -- - /// i.e. `cn_cols * cn_rows > 1`, which at 4:2:0 never happens (the chroma - /// plane block is one 32x32 unit) and at 4:4:4 is every block of 64 and - /// above. Counts UNITS, not blocks. EXCLUSIVE to this walk: the other two - /// override sites (the luma slot and `decode_intrabc_owned_rect`) have - /// their own windows. - pub(super) static SKIP_CHROMA_OVERRIDE_WINDOW_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`SKIP_SPLIT_TX_OVERRIDE_HITS`] (blocks). -pub fn skip_split_tx_override_hits() -> usize { - SKIP_SPLIT_TX_OVERRIDE_HITS.with(|c| c.get()) -} - -/// lane-av1chromadc: [`SKIP_CHROMA_OVERRIDE_WINDOW_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn skip_chroma_override_window_hits() -> usize { - SKIP_CHROMA_OVERRIDE_WINDOW_HITS.with(|c| c.get()) -} - -/// Zeroes [`SKIP_CHROMA_OVERRIDE_WINDOW_HITS`] before a gate's own decode. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn reset_skip_chroma_override_window_hits() { - SKIP_CHROMA_OVERRIDE_WINDOW_HITS.with(|c| c.set(0)); -} - -/// Zeroes [`SKIP_SPLIT_TX_OVERRIDE_HITS`] before a gate's own decode attempt. -pub fn reset_skip_split_tx_override_hits() { - SKIP_SPLIT_TX_OVERRIDE_HITS.with(|c| c.set(0)); -} - -// lane-svtinter: palette colour-index maps whose block is cut by the frame's -// bottom/right mi edge, so spec 5.11.50's `onscreenWidth`/`onscreenHeight` -// really are smaller than the block and FEWER symbols are read than the -// block has cells (class map-read-past-frame-edge). -thread_local! { - pub(super) static PALETTE_ONSCREEN_CUT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`PALETTE_ONSCREEN_CUT_HITS`] (colour-index maps). -pub fn palette_onscreen_cut_hits() -> usize { - PALETTE_ONSCREEN_CUT_HITS.with(|c| c.get()) -} - -/// Zeroes [`PALETTE_ONSCREEN_CUT_HITS`] before a gate's own decode attempt. -pub fn reset_palette_onscreen_cut_hits() { - PALETTE_ONSCREEN_CUT_HITS.with(|c| c.set(0)); -} - -/// Zeroes [`SKIP_SPLIT_TX_HITS`] before a gate's own decode attempt. -pub fn reset_skip_split_tx_hits() { - SKIP_SPLIT_TX_HITS.with(|c| c.set(0)); -} - -// lane-intrainter r1: intra blocks inside an INTER frame whose `tx_depth` -// symbol split their luma transform, bucketed by block side (8, 16, 32, 64) -- -// the gate's proof that the lifted path actually ran, per size. -thread_local! { - pub(super) static INTRA_IN_INTER_SPLIT_TX_HITS: std::cell::Cell<[usize; 4]> = - const { std::cell::Cell::new([0; 4]) }; -} - -/// Current value of [`INTRA_IN_INTER_SPLIT_TX_HITS`], indexed 8/16/32/64. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_in_inter_split_tx_hits() -> [usize; 4] { - INTRA_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get) -} - -thread_local! { - /// The current frame's `mi` grid, kept only while a frame header set - /// `allow_intrabc` -- an intrabc block's DV predictor is the ordinary - /// MV stack ([`crate::mvstack::find_mv_stack`]) built against - /// `INTRA_FRAME`, which needs the neighbour state a key frame otherwise - /// never keeps. `(grid, mi_cols, mi_rows)`; `None` on every frame that - /// does not allow intrabc (so nothing is paid for it). - /// - /// corner-cut: only [`decode_block`] (the square path) records into it, - /// so a frame mixing intrabc with rect/sub-8x8 leaves would predict off - /// an incomplete grid. Ceiling: the DV *value* (never the parse) would - /// be wrong there; upgrade = record from the rect/leaf paths too. - /// The block vector [`read_intra_mode`] just decoded, handed to - /// [`decode_block`] off the call stack (same idiom as [`PALETTE_PRED`], - /// which the alternative -- a tenth tuple member through every caller -- - /// already avoids). Always `.take()`n by the block that reads it. - /// How many blocks read `use_intrabc == 1` and took the DV path -- the - /// gate's hit counter. Bumped on the READ, before the rect-strip refusal - /// returns too, so it counts reads, not reconstructions (a refused block - /// is never reconstructed). - pub(super) static INTRABC_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Zeroes [`RECT_INTRABC_READS`] (gate tests call this before a decode). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_rect_intrabc_reads() { - RECT_INTRABC_READS.with(|c| c.set(0)); -} - -thread_local! { - /// Blocks that USED intrabc at an 8x8 LEAF (`decode_leaf8`) specifically - /// -- the shape lane-kf900 r7 fixed; [`INTRABC_HITS`] counts every shape. - pub(super) static LEAF8_INTRABC_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -thread_local! { - /// Chroma reads of an intrabc TX4-split leaf that consulted an ARMED - /// [`INTRABC_CHROMA_TX`] slot -- proof that the arm's frame-copy + - /// inherited-type route actually ran (lane-av1intrapred r2's non-vacuity - /// counter: zero means the gate's fixture no longer reaches the route). - pub(super) static INTRABC_TX4_CHROMA_COPY_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTRABC_TX4_CHROMA_COPY_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intrabc_tx4_chroma_copy_hits() -> usize { - INTRABC_TX4_CHROMA_COPY_HITS.with(|c| c.get()) -} - -/// Zeroes [`INTRABC_TX4_CHROMA_COPY_HITS`] (gate tests call this before a decode). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_intrabc_tx4_chroma_copy_hits() { - INTRABC_TX4_CHROMA_COPY_HITS.with(|c| c.set(0)); -} - -/// Current value of [`LEAF8_INTRABC_HITS`]. -pub(crate) fn leaf8_intrabc_hits() -> usize { - LEAF8_INTRABC_HITS.with(|c| c.get()) -} - -/// Zeroes [`LEAF8_INTRABC_HITS`] (gate tests call this before a decode). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_leaf8_intrabc_hits() { - LEAF8_INTRABC_HITS.with(|c| c.set(0)); -} - -/// Current value of [`INTRABC_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intrabc_hits() -> usize { - INTRABC_HITS.with(|c| c.get()) -} - -thread_local! { - /// An intrabc block that IS a sub-8x8 group's CHROMA REFERENCE and is - /// SKIPPED: the route that arms [`INTRABC_CHROMA_TX`] and then reads no - /// chroma coefficient at all, so the slot used to stay armed into the NEXT - /// block's chroma read. Both group shapes (4x4 split, 4x8/8x4 rect) count - /// here. A non-zero value is what makes the disarm below load-bearing. - pub(super) static SKIPPED_INTRABC_CHROMA_ARM_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`SKIPPED_INTRABC_CHROMA_ARM_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates and the probe -pub(crate) fn skipped_intrabc_chroma_arm_hits() -> usize { - SKIPPED_INTRABC_CHROMA_ARM_HITS.with(|c| c.get()) -} - -/// Zeroes [`SKIPPED_INTRABC_CHROMA_ARM_HITS`] (gate tests call this before a -/// decode). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_skipped_intrabc_chroma_arm_hits() { - SKIPPED_INTRABC_CHROMA_ARM_HITS.with(|c| c.set(0)); -} - -thread_local! { - /// lane-av1-ibcskip2: a sub-8x8 4:4:4 leaf that is BOTH intrabc AND - /// `skip` -- the arm whose chroma is the bare frame copy at the DV - /// (libaom `av1_build_inter_predictors_sb` runs regardless of `skip`). - /// Before the fix this route predicted intra-DC and every one of this - /// fixture's 150 such cells differed from the oracle on both chroma - /// planes. - pub(super) static SKIPPED_INTRABC_DV_COPY_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`SKIPPED_INTRABC_DV_COPY_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn skipped_intrabc_dv_copy_hits() -> usize { - SKIPPED_INTRABC_DV_COPY_HITS.with(|c| c.get()) -} - -/// Zeroes [`SKIPPED_INTRABC_DV_COPY_HITS`] (gate tests call this before a -/// decode). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_skipped_intrabc_dv_copy_hits() { - SKIPPED_INTRABC_DV_COPY_HITS.with(|c| c.set(0)); -} - -/// Zeroes [`INTRABC_HITS`] (gate tests call this before a decode). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_intrabc_hits() { - INTRABC_HITS.with(|c| c.set(0)); -} - -thread_local! { - /// lane-t900 r32: intrabc blocks whose transform size came off the INTER - /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability - /// that replaced the refusal "an intrabc block under TxMode::Select". - pub(super) static INTRABC_VARTX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-ibcvtx: intrabc var-tx trees that resolved to MIXED leaf - /// sizes (not one square size across every leaf) -- the engagement - /// counter proving a witness actually exercises the per-leaf reconstruct. - pub(super) static INTRABC_VARTX_MIXED_LEAVES_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1txr: as above for a `BLOCK_4X8`/`BLOCK_8X4` intrabc leaf -- - /// libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`, so these leaves - /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no - /// symbol here desynced `warped.obu` at the very next block. - pub(super) static RECT_INTRABC_VARTX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-intrabc: rect INTRABC blocks whose reconstruction - /// [`decode_intrabc_rect`] ran -- the engagement counter the rect-strip - /// gates assert on (a refused block bumps [`INTRABC_HITS`] but never - /// this one). - pub(super) static INTRABC_RECT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// Of those, how many read the INTER var-tx tree (unskipped, TX_MODE_SELECT). - pub(super) static INTRABC_RECT_VARTX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-intrabc r4: rect INTRABC blocks whose reconstruction - /// [`decode_intrabc_rect`] ran with `skip == 0` (a real residual read), - /// split by the strip's orientation -- `bw > bh` is a HORZ strip, - /// `bh > bw` a VERT one. The reviewer's unblock condition needs a CODED - /// witness in BOTH orientations, and the existing `INTRABC_RECT_HITS` - /// counts neither orientation nor the skip flag, so an arm that flipped - /// to an all-skip stream (no residual reader at all) would stay green. - pub(super) static INTRABC_RECT_CODED_HITS: std::cell::Cell<[usize; 2]> = - const { std::cell::Cell::new([0, 0]) }; - /// lane-av1-intrabc r5: the `skip == 1` twin of [`INTRABC_RECT_CODED_HITS`] - /// -- rect INTRABC blocks reconstructed as a bare prediction copy, split - /// by orientation. The r5 panic (residual stride `bw * bh` underrunning - /// `reconstruct_mc_rect`'s `row * side + w` index on a VERT strip) was - /// invisible to every gate because they only counted CODED strips. - pub(super) static INTRABC_RECT_SKIPPED_HITS: std::cell::Cell<[usize; 2]> = - const { std::cell::Cell::new([0, 0]) }; - /// lane-ibc444c: rect intra-BC blocks whose chroma plane block was sized - /// `bw >> ss_x` by `bh >> ss_y` -- the 4:4:4 and 4:4:0 cells, where - /// `av1_get_max_uv_txsize` (`ss_size_lookup[bsize]`, blockd.h) applies no - /// halving of its own. At 4:2:0 this is the same arithmetic as the halving, - /// so a `>= 1` witness can only come from a stream that is not 4:2:0. - /// EXCLUSIVE to this arm: no other caller sizes an intrabc rect block's - /// chroma plane block. - pub(super) static IBC_RECT_CHROMA_FOOTPRINT_444_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; - /// lane-whtshape: LOSSLESS rect intrabc blocks whose chroma plane block - /// [`decode_intrabc_rect`] walked as a `(cw/4) * (ch/4)` PLANE-MAJOR - /// raster of TX_4X4 units -- the shape libaom's lossless geometry codes - /// (`read_tx_size` returns `TX_4X4` for EVERY plane of a lossless block, - /// `get_vartx_max_txsize` likewise, and `read_tx_mode` forced the frame's - /// `ONLY_4X4`) -- instead of the single rect unit, which is what put a - /// non-4x4 unit on the lossless Walsh-Hadamard path. EXCLUSIVE to this arm: - /// no other caller walks a rect intrabc block's chroma, so `>= 1` cannot - /// be satisfied by any older route. - pub(super) static INTRABC_RECT_LOSSLESS_CHROMA4_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; - /// lane-av1chromarect: 128-root intra-BC HORZ/VERT strips - /// ([`decode_intrabc_owned_rect`]) whose chroma plane block was sized - /// `bw >> ss_x` by `bh >> ss_y` -- the 4:4:4 and 4:4:0 cells, where - /// `av1_get_max_uv_txsize` (`ss_size_lookup[bsize]`, blockd.h:1372) applies - /// no halving of its own. At 4:2:0 the two forms are the same arithmetic, - /// so a `>= 1` witness can only come from a stream that is not 4:2:0. - /// EXCLUSIVE to this arm: no other caller sizes a 128-root intra-BC - /// strip's chroma plane block. - pub(super) static IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; - /// lane-av1422ibctxsel: `decode_intrabc_owned_rect`'s NON-SPLIT chroma - /// gather taken through the 4:2:2 pair rule (`around_mi_422_chroma`) - /// under the ss (1, 0) guard -- both residual branches (the var-tx tree - /// and the no-leaves twin). `>= 1` can only come from a 4:2:2 stream - /// that reaches this function's non-split chroma arm; the 4:2:0/4:4:4 - /// arms keep the plain `around_mi_rect` gather (`ss_y != 0` / `ss_x == 0` - /// take the else), so the counter stays 0 for them. - pub(super) static IBC_OWNED_RECT_422_PAIR_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// lane-av1-intrabc r4: coded (`skip == 0`) rect intrabc blocks reconstructed, -/// as `[horz, vert]` -- see [`INTRABC_RECT_CODED_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn intrabc_rect_coded_hits() -> [usize; 2] { - INTRABC_RECT_CODED_HITS.with(std::cell::Cell::get) -} - -/// lane-av1-intrabc r5: skipped (`skip == 1`) rect intrabc blocks -/// reconstructed, as `[horz, vert]` -- see [`INTRABC_RECT_SKIPPED_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn intrabc_rect_skipped_hits() -> [usize; 2] { - INTRABC_RECT_SKIPPED_HITS.with(std::cell::Cell::get) -} - -/// Current value of [`INTRABC_RECT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn intrabc_rect_hits() -> usize { - INTRABC_RECT_HITS.with(|c| c.get()) -} - -/// Zeroes [`INTRABC_RECT_HITS`]/[`INTRABC_RECT_VARTX_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_intrabc_rect_hits() { - INTRABC_RECT_HITS.with(|c| c.set(0)); - INTRABC_RECT_VARTX_HITS.with(|c| c.set(0)); - INTRABC_RECT_CODED_HITS.with(|c| c.set([0, 0])); - INTRABC_RECT_SKIPPED_HITS.with(|c| c.set([0, 0])); -} - -/// lane-ibc444c: [`IBC_RECT_CHROMA_FOOTPRINT_444_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn ibc_rect_chroma_footprint_444_hits() -> usize { - IBC_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.get()) -} - -/// lane-ibc444c: zeroes [`IBC_RECT_CHROMA_FOOTPRINT_444_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_ibc_rect_chroma_footprint_444_hits() { - IBC_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.set(0)); -} - -/// lane-av1chromarect: [`IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn ibc_owned_rect_chroma_footprint_444_hits() -> usize { - IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.get()) -} - -/// lane-av1chromarect: zeroes [`IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_ibc_owned_rect_chroma_footprint_444_hits() { - IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.set(0)); -} - -/// lane-av1422ibctxsel: [`IBC_OWNED_RECT_422_PAIR_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn ibc_owned_rect_422_pair_hits() -> usize { - IBC_OWNED_RECT_422_PAIR_HITS.with(|c| c.get()) -} - -/// lane-av1422ibctxsel: zeroes [`IBC_OWNED_RECT_422_PAIR_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_ibc_owned_rect_422_pair_hits() { - IBC_OWNED_RECT_422_PAIR_HITS.with(|c| c.set(0)); -} - -/// lane-whtshape: [`INTRABC_RECT_LOSSLESS_CHROMA4_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn intrabc_rect_lossless_chroma4_hits() -> usize { - INTRABC_RECT_LOSSLESS_CHROMA4_HITS.with(|c| c.get()) -} - -/// lane-whtshape: zeroes [`INTRABC_RECT_LOSSLESS_CHROMA4_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_intrabc_rect_lossless_chroma4_hits() { - INTRABC_RECT_LOSSLESS_CHROMA4_HITS.with(|c| c.set(0)); -} - -/// Current value of [`INTRABC_RECT_VARTX_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn intrabc_rect_vartx_hits() -> usize { - INTRABC_RECT_VARTX_HITS.with(|c| c.get()) -} - -thread_local! { - /// lane-av1-ibcrect: `use_intrabc` blocks on a 128-root HORZ/VERT strip - /// (BLOCK_128X64 / BLOCK_64X128) whose reconstruction - /// [`decode_intrabc_128rect`] ran -- the shape the named refusal used to - /// guard (`decode_block_128rect`). A refused block bumps - /// [`INTRABC_HITS`] but never this one. - pub(super) static INTRABC_128RECT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-ibc128chunk: chroma transform units the 128-root intrabc - /// strip's mu-chunk walk read, one per `read_inter_plane` chroma call. - /// At 4:2:0 a 64x64 mu chunk's chroma plane block is 32x32, so one - /// TX_32X32 per plane per chunk; at 4:2:2 it is 32x64 and holds TWO - /// STACKED units per plane. The square-cut `chunk_chroma = cside * 64 / - /// side` model walked the 4:2:0 count on every axis, so this counter is - /// the reach/arm witness for the per-axis walk. - pub(super) static INTRABC_128RECT_CHROMA_CHUNK_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTRABC_128RECT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn intrabc_128rect_hits() -> usize { - INTRABC_128RECT_HITS.with(|c| c.get()) -} - -/// Zeroes [`INTRABC_128RECT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_intrabc_128rect_hits() { - INTRABC_128RECT_HITS.with(|c| c.set(0)); -} - -/// Current value of [`INTRABC_128RECT_CHROMA_CHUNK_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn intrabc_128rect_chroma_chunk_hits() -> usize { - INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.get()) -} - -/// Zeroes [`INTRABC_128RECT_CHROMA_CHUNK_HITS`] and -/// [`INTRABC_128RECT_CHUNK_SHAPE`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_intrabc_128rect_chroma_chunk_hits() { - INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.set(0)); - INTRABC_128RECT_CHUNK_SHAPE.with(|c| c.set(0)); -} - -/// Current value of [`INTRABC_VARTX_HITS`]. -pub fn intrabc_vartx_hits() -> usize { - INTRABC_VARTX_HITS.with(|c| c.get()) -} - -/// Current value of [`INTRABC_VARTX_MIXED_LEAVES_HITS`]. -pub fn intrabc_vartx_mixed_leaves_hits() -> usize { - INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.get()) -} - -/// Zeroes [`INTRABC_VARTX_HITS`] (gate tests call this before a decode). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_intrabc_vartx_hits() { - INTRABC_VARTX_HITS.with(|c| c.set(0)); -} - -/// Zeroes [`INTRABC_VARTX_MIXED_LEAVES_HITS`] (gate tests call this before a -/// decode). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_intrabc_vartx_mixed_leaves_hits() { - INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.set(0)); -} - -/// Current value of [`RECT_INTRABC_VARTX_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn rect_intrabc_vartx_hits() -> usize { - RECT_INTRABC_VARTX_HITS.with(|c| c.get()) -} - -// How many blocks decoded `skip_mode == 1` (lane-av1comp round 14) -- -// proves a real `skip_mode_present` stream actually reached a block that -// picked it, not just that the frame header bit was set. -thread_local! { - pub(super) static SKIP_MODE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`SKIP_MODE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn skip_mode_hits() -> usize { - SKIP_MODE_HITS.with(|c| c.get()) -} - -// lane-motionmode: how many blocks actually decoded `obmc_selected == true` -// (as opposed to just reaching an eligible `read_motion_mode` symbol read) -// -- the gate's own proof that a real aomenc `--enable-obmc=1` stream -// reached [`obmc_blend`], not just the header bit. -thread_local! { - pub(super) static OBMC_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -// lane-fimv r1 (class wrong-alphabet-same-value): how many blocks took the -// 2-symbol `obmc_cdf` alphabet *because* `force_integer_mv` (or a scaled -// reference) vetoed `WARPED_CAUSAL` in libaom `motion_mode_allowed`, while -// `allow_warped_motion == 1` and `num_proj_ref >= 1` would otherwise have -// picked the 3-symbol `motion_mode_cdf`. These are exactly the blocks this -// decoder used to read with the wrong alphabet, so a gate that asserts this -// counter advanced proves the fixed path fired (class -// `gate-blind-to-feature`). -thread_local! { - pub(super) static FIMV_ALPHABET_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`FIMV_ALPHABET_HITS`]. -pub fn fimv_alphabet_hits() -> usize { - FIMV_ALPHABET_HITS.with(|c| c.get()) -} - -// lane-fimv r1: how many frame headers this decoder has decoded with -// `force_integer_mv == 1` (bumped by `stream.rs` per frame). Lets a gate -// prove the encoder really produced the header state under test rather than -// assume it. -thread_local! { - pub(super) static FIMV_FRAME_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`FIMV_FRAME_HITS`]. -pub fn fimv_frame_hits() -> usize { - FIMV_FRAME_HITS.with(|c| c.get()) -} - -/// Current value of [`OBMC_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn obmc_hits() -> usize { - OBMC_HITS.with(|c| c.get()) -} - -// lane-scaledref r1: per-case firing counts for the scaled-reference gate -// (class `gate-blind-to-feature`) -- a pixel match under an UNSCALED -// reference would pass just as well and prove nothing, so the gate -// hard-asserts each combination this round lifts actually occurred: -// a compound block with a scaled tap, a warp block whose warp libaom -// suppresses because the reference is scaled, an OBMC block, an interintra -// block, and an 8x8 leaf. -thread_local! { - pub(super) static SCALED_COMPOUND_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static SCALED_WARP_FALLBACK_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static SCALED_OBMC_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static SCALED_INTERINTRA_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static SCALED_BLOCK8_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static SCALED_WARP_SUPPRESSED_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static MIXED_SCALE_COMPOUND_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`MIXED_SCALE_COMPOUND_HITS`]: compound blocks with one -/// scaled and one unscaled tap. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn mixed_scale_compound_hits() -> usize { - MIXED_SCALE_COMPOUND_HITS.with(|c| c.get()) -} - -/// Current value of [`SCALED_WARP_SUPPRESSED_HITS`]: blocks that would have -/// read the 3-symbol `motion_mode_cdf` but read the 2-symbol `obmc_cdf` -/// instead because their reference is scaled (libaom `motion_mode_allowed`, -/// `blockd.h:1484`). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn scaled_warp_suppressed_hits() -> usize { - SCALED_WARP_SUPPRESSED_HITS.with(|c| c.get()) -} - -/// Current value of [`SCALED_COMPOUND_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn scaled_compound_hits() -> usize { - SCALED_COMPOUND_HITS.with(|c| c.get()) -} - -/// Current value of [`SCALED_WARP_FALLBACK_HITS`]. -pub fn scaled_warp_fallback_hits() -> usize { - SCALED_WARP_FALLBACK_HITS.with(|c| c.get()) -} - -/// Current value of [`SCALED_OBMC_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn scaled_obmc_hits() -> usize { - SCALED_OBMC_HITS.with(|c| c.get()) -} - -/// Current value of [`SCALED_INTERINTRA_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn scaled_interintra_hits() -> usize { - SCALED_INTERINTRA_HITS.with(|c| c.get()) -} - -/// Current value of [`SCALED_BLOCK8_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn scaled_block8_hits() -> usize { - SCALED_BLOCK8_HITS.with(|c| c.get()) -} - -// lane-motionmode round 3: same proof as [`OBMC_HITS`], narrowed to -// `decode_inter_block8`'s own 8x8-leaf `read_motion_mode` -- a subset of -// [`OBMC_HITS`] (both fire together on an 8x8 hit), lets the gate tell an -// 8x8-leaf OBMC block apart from a 16x16+ one. -thread_local! { - pub(super) static OBMC_HITS_8: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -// lane-interp3 r1: how many inter blocks read a SWITCHABLE `interp_filter` -// pair whose two directions differ (`enable_dual_filter` only -- with dual -// filter off both directions take the single symbol, so this can never fire). -// A gate asserting it proves the stream really carries dual-filter blocks. -thread_local! { - pub(super) static DUAL_FILTER_DIFF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -// lane-interp3 r1: how many COMPOUND 8x8 leaves read their own -// `read_mb_interp_filter` symbol(s) -- the read this round added (the leaf -// used to skip it entirely, losing a symbol and stamping the `[3, 3]` -// no-filter sentinel that made a neighbouring OBMC block panic). -thread_local! { - pub(super) static COMPOUND8_FILTER_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`DUAL_FILTER_DIFF_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn dual_filter_diff_hits() -> usize { - DUAL_FILTER_DIFF_HITS.with(|c| c.get()) -} - -/// Current value of [`COMPOUND8_FILTER_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn compound8_filter_hits() -> usize { - COMPOUND8_FILTER_HITS.with(|c| c.get()) -} - -// lane-warp round 1: how many blocks resolved `motion_mode_allowed` to -// `WARPED_CAUSAL`-eligible (3-symbol read, `num_proj_ref >= 1` under -// `allow_warped_motion`) AND the symbol actually decoded to `WARPED_CAUSAL` -// -- the gate's proof that a fixture really exercises the alphabet this -// round changed, even though the block itself still refuses (warp -// estimation/filter not ported). -thread_local! { - pub(super) static WARP_SELECTED_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`WARP_SELECTED_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn warp_selected_hits() -> usize { - WARP_SELECTED_HITS.with(|c| c.get()) -} - -// lane-cwarp r1: how many COMPOUND_REFERENCE blocks had at least one -// reference predicted through the per-ref GLOBAL warp (`av1_warp_plane` -// into the compound intermediate) rather than translationally -- the -// gate's proof that a `GLOBAL_GLOBALMV` block under a ROTZOOM/AFFINE model -// really reached [`crate::warp::warp_affine_compound`]. -// lane-av1422warp: the 4:2:2 coverage witness has to show compound and warped -// motion firing ABOVE the vertical midpoint, and every pre-existing warp -// counter is frame-global. These two are the same arms restricted to blocks -// whose top mode-info row is in the frame's upper half, which is the half -// this lane's evidence covers. -thread_local! { - pub(super) static TOP_HALF_COMPOUND_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static TOP_HALF_WARP_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// How many `GLOBAL_GLOBALMV` (compound) inter blocks decoded in the frame's -/// upper half -- the block's top mode-info row is under `mi_rows / 2`. -/// -/// NO COMMITTED TEST READS THIS, and none can while the 4:2:2 header refusal -/// stands: the pinned 4:2:2 coverage gate asserts the byte pin and the -/// refusal by name, so nothing in the suite ever decodes a 4:2:2 stream. -/// The figure quoted for that fixture comes from a patch-run-restore build -/// with the `EC_AV1_ALLOW_422_PROBE` bypass applied and then reverted, which -/// is the same discipline every 4:2:2 lane in this family uses. -#[allow(dead_code)] -pub(crate) fn top_half_compound_hits() -> usize { - TOP_HALF_COMPOUND_HITS.with(std::cell::Cell::get) -} - -/// How many inter blocks in the frame's upper half satisfy libaom's -/// `is_global_mv_block` on at least one reference slot -- mode -/// `GLOBAL_GLOBALMV` AND block >= 8x8 AND that slot's own global-motion -/// model > `TRANSLATION`. This is the block set whose prediction goes -/// through `crate::warp`, and it is exactly `is_global_mv0 || is_global_mv1` -/// as computed at the increment site; it is NOT merely "some slot has a -/// non-TRANSLATION model", which also counts blocks that are not global-mv -/// blocks. -/// -/// Like [`top_half_compound_hits`], no committed test reads it: with the -/// 4:2:2 header refusal in force nothing in the suite decodes the stream -/// these numbers describe. -#[allow(dead_code)] -pub(crate) fn top_half_warp_hits() -> usize { - TOP_HALF_WARP_HITS.with(std::cell::Cell::get) -} - -thread_local! { - pub(super) static COMPOUND_WARP_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`COMPOUND_WARP_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn compound_warp_hits() -> usize { - COMPOUND_WARP_HITS.with(|c| c.get()) -} - -// lane-interp3 r3: the same proof narrowed to the 8x8 LEAF's own compound -// arm ([`decode_inter_block8`]) -- that arm predicted both taps -// translationally until r3, so a gate needs to tell a warped 8x8 compound -// leaf apart from a warped 16x16+ one (both bump [`COMPOUND_WARP_HITS`]). -thread_local! { - pub(super) static COMPOUND_WARP_HITS_8: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`COMPOUND_WARP_HITS_8`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn compound_warp_hits_8() -> usize { - COMPOUND_WARP_HITS_8.with(|c| c.get()) -} - -// lane-gmaffine r1: how many blocks built their prediction from a -// SIX-parameter (`AFFINE`) global-motion model through -// `crate::warp::global_warp_params` -- the gate's proof that a stream really -// carried an AFFINE `global_motion_params` AND that a block was predicted -// with it, not merely that the header parsed one. -thread_local! { - pub(super) static AFFINE_GM_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`AFFINE_GM_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn affine_gm_hits() -> usize { - AFFINE_GM_HITS.with(|c| c.get()) -} - -// lane-av1distwtd: how many blocks took the DISTANCE-WEIGHTED compound -// combine rather than the simple average -- `compound_idx == 0` under -// `enable_jnt_comp`, whose weights come from -// [`crate::compound::dist_wtd_comp_weight_assign`] instead of the constant -// `(8, 8)` split. Counting the `idx == 0` arm (not merely the -// `compound_idx` symbol read) is what makes this a witness of the TOOL: a -// stream that carries `enable_jnt_comp = true` in its sequence header but -// codes every compound block with `compound_idx == 1` leaves this at 0 and -// decoded identically without the whole distance-weight path. -thread_local! { - pub(super) static DIST_WTD_COMP_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`DIST_WTD_COMP_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn dist_wtd_comp_hits() -> usize { - DIST_WTD_COMP_HITS.with(|c| c.get()) -} - -/// Resets [`DIST_WTD_COMP_HITS`] to 0. -#[allow(dead_code)] // test-only -pub(crate) fn reset_dist_wtd_comp_hits() { - DIST_WTD_COMP_HITS.with(|c| c.set(0)); -} - -// lane-av1gwarp12: how many 16x16+ blocks built their SINGLE-reference -// prediction through `crate::warp::global_warp_params` with a FOUR-parameter -// (`ROTZOOM`) model. Vanilla aomenc pins its global-motion search to ROTZOOM -// (`global_motion_facade.c:24`), so this is the only >TRANSLATION single-ref -// global-warp arm a real aomenc stream can reach (AFFINE needs the widened -// side build and its own counter, [`AFFINE_GM_HITS`]). -thread_local! { - pub(super) static ROTZOOM_GM_WARP_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`ROTZOOM_GM_WARP_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rotzoom_gm_warp_hits() -> usize { - ROTZOOM_GM_WARP_HITS.with(|c| c.get()) -} - -// lane-t900 r9: rect blocks whose warp-sample top-right probe answers -// differently at the block's WIDTH than at libaom's -// `AOMMAX(xd->width, xd->height)` -- each one is a `num_proj_ref` that could -// pick the wrong motion_mode alphabet. -thread_local! { - pub(super) static TR_REACH_LONGER_SIDE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`TR_REACH_LONGER_SIDE_HITS`]. -pub fn tr_reach_longer_side_hits() -> usize { - TR_REACH_LONGER_SIDE_HITS.with(std::cell::Cell::get) -} - -// lane-t900 r9: libaom `is_nontrans_global_motion` (mvref_common.h) returns 0 -// for `AOMMIN(mi_size_wide[bsize], mi_size_high[bsize]) < 2`, i.e. any block -// with a 4-px side is NEVER "non-translational global" and therefore ALWAYS -// reads its interp-filter symbol. Counts the blocks where that guard flips -// our answer -- a GLOBALMV/GLOBAL_GLOBALMV block with a non-TRANSLATION model -// and a 4-px side, which we used to suppress the interp read on (a pre-mode -// entropy desync one symbol wide). -thread_local! { - pub(super) static GM_NONTRANS_SMALL_SIDE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`GM_NONTRANS_SMALL_SIDE_HITS`]. -pub fn gm_nontrans_small_side_hits() -> usize { - GM_NONTRANS_SMALL_SIDE_HITS.with(std::cell::Cell::get) -} - -// lane-gmaffine r1: 8x8-leaf-only counters -- how many `BLOCK_8X8` leaves -// coded `GLOBALMV` (`GLOBALMV_HITS_8`) and how many built a real -// `WARPED_CAUSAL` local-warp prediction there (`WARP_HITS_8`, incremented -// only once `find_projection` returned a usable model, unlike -// `WARP_SELECTED_HITS` which counts the symbol). Both are the 8x8 gates' -// proof that the leaf path itself fired, not the 16x16+ one. -thread_local! { - pub(super) static GLOBALMV_HITS_8: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static WARP_HITS_8: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`GLOBALMV_HITS_8`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn globalmv_hits_8() -> usize { - GLOBALMV_HITS_8.with(|c| c.get()) -} - -/// Current value of [`WARP_HITS_8`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn warp_hits_8() -> usize { - WARP_HITS_8.with(|c| c.get()) -} - -// How many blocks decoded `interintra == 1` with the non-wedge blended -// prediction applied (lane-interintra r1) -- the gate's proof that a -// stream actually exercised interintra. -thread_local! { - pub(super) static INTERINTRA_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTERINTRA_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn interintra_hits() -> usize { - INTERINTRA_HITS.with(|c| c.get()) -} - -// lane-midcut r1: of those, how many were RECTANGULAR (`write_w != write_h`) -// -- the shape `interintra_blend` used to build a square `side x side` intra -// predictor for, with `ii_size_scales`/`edges` taken at the square. Every -// pre-existing interintra gate passed with that bug, so the rect arm needs -// its own counter to stop being vacuous. -thread_local! { - pub(super) static INTERINTRA_RECT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTERINTRA_RECT_HITS`]. -pub fn interintra_rect_hits() -> usize { - INTERINTRA_RECT_HITS.with(|c| c.get()) -} - -// How many blocks decoded `comp_group_idx == 1` (masked COMPOUND_REFERENCE, -// wedge or diffwtd) and had `compound_type`/`wedge_idx`/`wedge_sign`/ -// `mask_type` consumed entropy-exact -- lane-maskcomp r1's proof that a -// gate fixture actually exercises this alphabet, even though the block -// still refuses (the mask blend itself is unported). -thread_local! { - pub(super) static MASKED_COMPOUND_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`MASKED_COMPOUND_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn masked_compound_hits() -> usize { - MASKED_COMPOUND_HITS.with(|c| c.get()) -} - -// lane-intersub8 r4/r5: the NON-SQUARE half of `MASKED_COMPOUND_HITS` -- a -// masked-compound block whose true footprint is rectangular, i.e. the case -// whose `compound_type`/`wedge_idx` CDF row r4 fixed (it used to read the -// square envelope's `BLOCK_SIZES_ALL` index). Square blocks cannot show that -// defect, so a gate asserting `masked_compound_hits` alone stays vacuous for it. -thread_local! { - pub(super) static RECT_MASKED_COMPOUND_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT_MASKED_COMPOUND_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_masked_compound_hits() -> usize { - RECT_MASKED_COMPOUND_HITS.with(|c| c.get()) -} - -// How many blocks decoded a real `COMPOUND_WEDGE` block (`comp_group_idx == -// 1`, `compound_type == 0`) -- lane-wedge r3's proof a gate fixture -// actually exercised the wedge blend, not just the DIFFWTD half of -// `MASKED_COMPOUND_HITS`. -thread_local! { - pub(super) static WEDGE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`WEDGE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn wedge_hits() -> usize { - WEDGE_HITS.with(|c| c.get()) -} - -// How many blocks decoded a real wedge-INTERINTRA block -// (`interintra == 1 && use_wedge_interintra == 1`) -- lane-wii r2's proof -// a gate fixture exercised the wedge blend (fixed sign 0), not just the -// smooth arm counted by `INTERINTRA_HITS`. -thread_local! { - pub(super) static WII_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`WII_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn wii_hits() -> usize { - WII_HITS.with(|c| c.get()) -} - -// lane-sbrect10 r1: how many INTRA blocks read `uv_mode` off the 13-symbol -// NO-CFL alphabet *because their size excludes CFL* (libaom `is_cfl_allowed`: -// wide <= 32 && high <= 32). The witness that a gate stream really carries a -// 64-axis intra block -- the shape whose 14-symbol read desynced every inter -// frame carrying one. -thread_local! { - pub(super) static NOCFL_UV_MODE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`NOCFL_UV_MODE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn nocfl_uv_mode_hits() -> usize { - NOCFL_UV_MODE_HITS.with(|c| c.get()) -} - -// lane-inter16ab r5: how many COMPOUND_WEDGE / wedge-INTERINTRA blocks used a -// RECTANGULAR codebook row (hgtw/hltw), per shape -- the gate's proof that -// the rect wedge masks lifted this round actually fired, not just the square -// ones already counted by `WEDGE_HITS`/`WII_HITS`. -thread_local! { - pub(super) static RECT_WEDGE_HITS: std::cell::Cell<[usize; 6]> = const { std::cell::Cell::new([0; 6]) }; - pub(super) static RECT_WII_HITS: std::cell::Cell<[usize; 6]> = const { std::cell::Cell::new([0; 6]) }; -} - -/// Current value of [`RECT_WEDGE_HITS`], indexed by [`RECT_WEDGE_SHAPES`]. -pub(crate) fn rect_wedge_hits() -> [usize; 6] { - RECT_WEDGE_HITS.with(|c| c.get()) -} - -/// Current value of [`RECT_WII_HITS`], indexed by [`RECT_WEDGE_SHAPES`]. -pub(crate) fn rect_wii_hits() -> [usize; 6] { - RECT_WII_HITS.with(|c| c.get()) -} - -// lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC -// blend -- the gate's proof that `--enable-obmc=1` reached this shape (the -// r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented -// aomdec, neighbour list included). -thread_local! { - pub(super) static OBMC_RECT_LEAF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`OBMC_RECT_LEAF_HITS`]. -pub(crate) fn obmc_rect_leaf_hits() -> usize { - OBMC_RECT_LEAF_HITS.with(|c| c.get()) -} - -// lane-obmcrec r1: how many OBMC neighbours were taken from the SECOND half of -// a 4-wide/4-tall (1:4 strip) chroma pair -- the case whose interp filter used -// to be read from the pair's FIRST mi, which is a different block and, when -// that half is intra, carries the `[3, 3]` "no filter" sentinel (the three -// 1080p 10-bit film cuts refused there). The gate's proof the shape fired. -thread_local! { - pub(super) static OBMC_PAIR_FILTER_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`OBMC_PAIR_FILTER_HITS`]. -pub(crate) fn obmc_pair_filter_hits() -> usize { - OBMC_PAIR_FILTER_HITS.with(|c| c.get()) -} - -// lane-t900 r14: how many OBMC neighbour predictions run PAST the frame edge -// -- libaom's `op_mi_size` is `AOMMIN(xd->width|height, mi_step)`, the block's -// own side, so a block overhanging the bottom/right still predicts the full -// neighbour strip (the destination write is what clips). We used to shrink the -// prediction to the visible part, which at 4 chroma rows/cols also swaps the -// vertical/horizontal kernel to the 4-tap one. The gate's proof the shape fired. -thread_local! { - pub(super) static OBMC_EDGE_SPAN_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`OBMC_EDGE_SPAN_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn obmc_edge_span_hits() -> usize { - OBMC_EDGE_SPAN_HITS.with(|c| c.get()) -} - -/// Current value of [`OBMC_HITS_8`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn obmc_hits_8() -> usize { - OBMC_HITS_8.with(|c| c.get()) -} - -// lane-rectgate r1: how many 32x32 quadrants actually decoded a -// `PARTITION_HORZ_B` split (the one extended/ab partition this decoder's -// inter-frame tile loop decodes -- `PARTITION_HORZ`/`VERT`/`HORZ_A`/`VERT_A`/ -// `VERT_B` all still fall into the generic "a partition type this encoder -// never writes" refusal below) -- the gate's proof that a free-partition -// aomenc stream actually exercised a non-`NONE`/`SPLIT` partition rather than -// coincidentally never selecting one. -thread_local! { - pub(super) static EXTENDED_PARTITION_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`EXTENDED_PARTITION_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn extended_partition_hits() -> usize { - EXTENDED_PARTITION_HITS.with(|c| c.get()) -} - -// lane-partitions r1: how many 32x32 quadrants decoded a real -// `PARTITION_HORZ`/`PARTITION_VERT` (two true rectangular strips, unlike -// `PARTITION_HORZ_B`'s square-context stand-in) -- the free-partition -// gate's proof this round's arms actually fired. -thread_local! { - pub(super) static RECT_PARTITION_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT_PARTITION_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_partition_hits() -> usize { - RECT_PARTITION_HITS.with(|c| c.get()) -} - -// lane-inter8 r1: how many superblocks an inter tile coded as a single -// whole-SB `PARTITION_NONE` 64x64 inter block (the case aomenc picks for -// static content, previously a named refusal). -thread_local! { - /// lane-sb128c r1: how many 128x128 `PARTITION_NONE` roots this INTER tile - /// path decoded as one whole block (its gate's own witness). - pub(crate) static INTER_SB128_NONE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// 128x64 / 64x128 INTER blocks decoded at the 128 root (lane-sb128c r7). - pub(crate) static INTER_SB128_HORZ_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(crate) static INTER_SB128_VERT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTER_SB128_HORZ_HITS`], for a gate's before/after delta. -pub(crate) fn inter_sb128_horz_hits() -> usize { - INTER_SB128_HORZ_HITS.with(std::cell::Cell::get) -} - -/// Current value of [`INTER_SB128_VERT_HITS`], for a gate's before/after delta. -pub(crate) fn inter_sb128_vert_hits() -> usize { - INTER_SB128_VERT_HITS.with(std::cell::Cell::get) -} - -/// Current value of [`INTER_SB128_NONE_HITS`], for a gate's before/after delta. -pub fn inter_sb128_none_hits() -> usize { - INTER_SB128_NONE_HITS.with(std::cell::Cell::get) -} - -thread_local! { - /// lane-sb128c r3: how many INTRA-coded 128x128 blocks inside an INTER - /// frame this decoder reconstructed (mu-chunk chroma, four TX_64X64 luma - /// units) -- the gate's witness that the lifted refusal's case fired. - pub(crate) static INTRA_128_IN_INTER_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTRA_128_IN_INTER_HITS`], for a gate's before/after delta. -pub fn intra_128_in_inter_hits() -> usize { - INTRA_128_IN_INTER_HITS.with(std::cell::Cell::get) -} - -thread_local! { - /// lane-av1ibc128arm: how many 64x64 mu-chunk CHROMA units the - /// intra-in-inter 128x128 root read (`decode_inter_block`'s - /// `side > 64` mu-chunk arm, the INTRA half of the inter pair). Every - /// unit is one `read_plane` on U and one on V, so the counter is the - /// gate's proof the arm ran at all -- no committed 4:4:4 fixture - /// reached it before this lane. - pub(crate) static INTRA_128_IN_INTER_MU_CHROMA_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTRA_128_IN_INTER_MU_CHROMA_HITS`], for a gate's -/// before/after delta. -pub fn intra_128_in_inter_mu_chroma_hits() -> usize { - INTRA_128_IN_INTER_MU_CHROMA_HITS.with(std::cell::Cell::get) -} - -thread_local! { - pub(super) static INTER_SB_NONE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTER_SB_NONE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn inter_sb_none_hits() -> usize { - INTER_SB_NONE_HITS.with(|c| c.get()) -} - -// lane-inter8 r1: how many INTERIOR (not frame-edge-straddling) 16x16 inter -// blocks coded a real `PARTITION_SPLIT` into four 8x8 leaves -- the straddle -// path has always run that loop, so only this counter proves the newly-lifted -// alphabet value fired. -thread_local! { - pub(super) static INTER_SUB16_SPLIT_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTER_SUB16_SPLIT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn inter_sub16_split_hits() -> usize { - INTER_SUB16_SPLIT_HITS.with(|c| c.get()) -} - -// lane-t900 r28: how many 16x16 inter splits reached their four 8x8 leaves -// while at least one reference picture was SCALED (superres) -- the counter -// behind the lifted "8x8 partition leaf under a scaled reference" refusal. -thread_local! { - pub(super) static SCALED_LEAF8_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`SCALED_LEAF8_HITS`]. -pub fn scaled_leaf8_hits() -> usize { - SCALED_LEAF8_HITS.with(|c| c.get()) -} - -// lane-t900 r28: how many sub-8x8 inter blocks (the 4x4 split and the 8x4/4x8 -// rect pair) were predicted from a SCALED reference -- the counter behind the -// lifted "sub-8x8 inter block under a scaled reference" refusal. -thread_local! { - pub(super) static SCALED_SUB8_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`SCALED_SUB8_HITS`]. -pub fn scaled_sub8_hits() -> usize { - SCALED_SUB8_HITS.with(|c| c.get()) -} - -// lane-rectwire r2: how many `PARTITION_HORZ`/`VERT` strips actually decoded -// real (non-skip) coefficients through [`read_coeffs_rect`] -- proves the -// rect coefficient reader itself fired, not just the strip-level partition -// symbol [`RECT_PARTITION_HITS`] already counts. -thread_local! { - pub(super) static RECT_COEFF_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT_COEFF_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_coeff_hits() -> usize { - RECT_COEFF_HITS.with(|c| c.get()) -} - -// lane-rectx r1: how many below-16x16 HORZ/VERT leaves ([`decode_leaf_rect`]) -// decoded real (non-skip) TX_16X8/TX_8X16 coefficients -- the counter the -// charter's real-aomenc gate hard-asserts. -thread_local! { - pub(super) static RECT_LEAF_COEFF_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT_LEAF_COEFF_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_leaf_coeff_hits() -> usize { - RECT_LEAF_COEFF_HITS.with(|c| c.get()) -} - -// lane-intrarect r1: how many intra-coded HORZ/VERT strips decoded on the -// INTER block path ([`decode_intra_rect_in_inter`]), per shape class -- -// [0] the superblock-level 64x32/32x64, [1] 32x16/16x32, [2] 16x8/8x16. -// Every one of them was the named refusal "an intra-coded HORZ/VERT strip -// needs rectangular intra prediction" before this round. -thread_local! { - pub(super) static INTRA_RECT_IN_INTER_HITS: std::cell::Cell<[usize; 3]> = - const { std::cell::Cell::new([0; 3]) }; -} - -/// Current value of [`INTRA_RECT_IN_INTER_HITS`] for one shape class -/// (0 = 64x32/32x64, 1 = 32x16/16x32, 2 = 16x8/8x16). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_rect_strip_in_inter_hits(class: usize) -> usize { - INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) -} - -// lane-rect64port r1 (ported by hand from lane-intra64split 5ffbaf3): coded -// (non-skip) 64-level HORZ/VERT intra strips whose luma transform is the -// un-split TX_64X32/TX_32X64 -- the corner-cropped 32x32 coefficient read of -// [`decode_rect_split`], the shape both 10-bit 3840x1608 film cuts stop on. -// Split by ORIENTATION (index 0 = 64x32 wide / HORZ, 1 = 32x64 tall / VERT): -// a single counter cannot tell an axis swap from a working arm -// (class [[scan-weights-cross-axis]]), so the gate asserts both cells. -thread_local! { - pub(super) static RECT64_CORNER_TU_HITS: std::cell::Cell<[usize; 2]> = - const { std::cell::Cell::new([0; 2]) }; -} - -/// Current value of [`RECT64_CORNER_TU_HITS`] for one orientation -/// (0 = 64x32, 1 = 32x64). -pub(crate) fn rect64_corner_tu_hits(orient: usize) -> usize { - RECT64_CORNER_TU_HITS.with(|c| c.get()[orient]) -} - -// lane-intrasplit r1: intra HORZ/VERT strips inside an INTER frame whose luma -// transform is SPLIT, bucketed by the read `tx_depth` (index 1 and 2; index 0 -// is never incremented) -- the gate's proof that the lifted path ran per depth. -thread_local! { - pub(super) static INTRA_RECT_IN_INTER_SPLIT_TX_HITS: std::cell::Cell<[usize; 3]> = - const { std::cell::Cell::new([0; 3]) }; -} - -// lane-t900 r21: rect intra strips inside an inter frame that read the -// screen-content palette syntax (`allow_screen_content_tools` set and the -// strip's own shape admitted by `palette_bsize_ctx_wh`) -- the site a blanket -// refusal used to guard, so this counter is what keeps its witness gate -// non-vacuous. -thread_local! { - pub(super) static INTRA_RECT_IN_INTER_SCREEN_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTRA_RECT_IN_INTER_SCREEN_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_rect_in_inter_screen_hits() -> usize { - INTRA_RECT_IN_INTER_SCREEN_HITS.with(std::cell::Cell::get) -} - -/// Resets [`INTRA_RECT_IN_INTER_SCREEN_HITS`] before a decode. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_intra_rect_in_inter_screen_hits() { - INTRA_RECT_IN_INTER_SCREEN_HITS.with(|c| c.set(0)); -} - -/// Current value of [`INTRA_RECT_IN_INTER_SPLIT_TX_HITS`], indexed by tx depth. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_rect_in_inter_split_tx_hits() -> [usize; 3] { - INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get) -} - -// lane-av1txbands: how many `tx_depth`/`txfm_split` reads the deblock-grid -// approximation would have resolved off a DIFFERENT CDF row than the real -// `TXFM_CONTEXT` bands do -- the exact blocks this band read fixes, on ANY -// frame (lane-midcut r2 had it inter-frame-only). A plain "rect/intra block" -// tally is green on the old code too (class gate-blind-to-feature). -thread_local! { - pub(super) static TXCTX_DEBLOCK_DIVERGENCE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`TXCTX_DEBLOCK_DIVERGENCE_HITS`]. -#[allow(dead_code)] // gate counter accessor with no reader yet; the counter itself is live -pub(crate) fn txctx_deblock_divergence_hits() -> usize { - TXCTX_DEBLOCK_DIVERGENCE_HITS.with(std::cell::Cell::get) -} - -// lane-av1txctxband: how many `get_tx_size_context` reads the per-CELL -// `is_inter_block` cover and the per-COLUMN `above_inter`/`left_inter` bands -// DISAGREE about -- i.e. exactly the reads whose CDF row the old code chose -// wrongly. Green on the old code too (a plain "some block was inter" tally -// would be), so this is the non-vacuity arm of the witness gate: it is 0 on -// every stream where the bands happened to be right and non-zero on the -// 4:4:4 lossy `--sb-size=128` cq-62 stream whose entropy forked at read 32813 -// on the 8x4 intra leaf at mi(57,52). -thread_local! { - pub(super) static TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gate -pub(crate) fn txctx_inter_cell_band_divergence_hits() -> usize { - TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS.with(std::cell::Cell::get) -} - -/// Zeroes [`TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gate -pub(crate) fn reset_txctx_inter_cell_band_divergence_hits() { - TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS.with(|c| c.set(0)); -} - -// lane-intra14 r1: how many intra-coded 1:4 strips decoded on the INTER -// block path, per shape -- [0] 64x16, [1] 16x64, [2] 32x8, [3] 8x32. Every -// one of them was the named refusal "an intra-coded 1:4 (or other non-2:1) -// rect strip on the inter block path" before this round. -thread_local! { - pub(super) static INTRA_RECT4_IN_INTER_HITS: std::cell::Cell<[usize; 4]> = - const { std::cell::Cell::new([0; 4]) }; -} - -/// Current value of [`INTRA_RECT4_IN_INTER_HITS`] for one shape -/// (0 = 64x16, 1 = 16x64, 2 = 32x8, 3 = 8x32). -pub(crate) fn intra_rect4_strip_in_inter_hits(shape: usize) -> usize { - INTRA_RECT4_IN_INTER_HITS.with(|c| c.get()[shape]) -} - -// lane-av1444rect: how many 1:4 inter strips at `ss_x == 0` read their chroma -// coefficient context over the STRIP'S OWN extent instead of the 4:2:0 pair's -// (see [`decode_inter_block`]'s `around_c`). `is_chroma_reference` -// (av1_common_int.h:1454) is unconditionally true at ss (0,0), so no pair -// exists there; the counter keeps a 4:4:4 1:4-strip gate from passing -// vacuously (a 4:2:0 stream of the same content leaves it at 0). It proves -// REACH only, never that the fix bites -- that is the gate's byte compare and -// its mutation, not this count (skill://ec-av1-pipeline-gate-counters). -thread_local! { - pub(super) static RECT4_INTER_OWN_CHROMA444_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT4_INTER_OWN_CHROMA444_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect4_inter_own_chroma444_hits() -> usize { - RECT4_INTER_OWN_CHROMA444_HITS.with(std::cell::Cell::get) -} - -/// Resets [`RECT4_INTER_OWN_CHROMA444_HITS`] before a decode. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_rect4_inter_own_chroma444_hits() { - RECT4_INTER_OWN_CHROMA444_HITS.with(|c| c.set(0)); -} - -// lane-av1444rect r2: how many intra-BC 1:4 strips at `ss (0,0)` took the -// own-chroma arm of [`decode_rect4_16_intrabc`]'s `own444`. A 4:2:0 / 4:2:2 -// stream of the same recipe leaves it at 0, which is what makes it the -// 4:4:4-only route. -// -// WHAT THIS COUNTER IS NOT: it is NOT evidence that the fix bites, and it -// never was. A route counter fires identically before and after a change that -// changes nothing downstream, so a non-zero count proves REACH and nothing -// more. On this lane it is also armed deliberately OUTSIDE the `own444` -// expression, so that the mutation (`own444 = false`) still increments it and -// the red comes from the pixel/entropy arm instead. The evidence that the ss -// gate bites is the measured fork move -- first entropy fork read 11750 -> -// 12465, luma first wrong sample 164416 -> 205264, 455240 -> 390380 total -- -// not this count. See skill://ec-av1-pipeline-gate-counters: a counter needs -// a DIFFERS-style assertion to carry a claim. -thread_local! { - pub(super) static INTRABC_RECT4_OWN_CHROMA444_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -// lane-av1422luma: the ss (1,0) twin of `INTRABC_RECT4_OWN_CHROMA444_HITS` -// -- how many intra-BC 1:4 strips at 4:2:2 took the own-chroma (no pair) -// route. Same caveat as the 4:4:4 counter: it proves REACH and nothing else. -// lane-av1422lift: 4:2:2 is DECODED, so this counter is no longer pinned -// behind a header refusal -- and it DOES fire: measured on this branch's tip, -// the six committed corpus cells each read 1 more than the cell before -// (`s422_320x246` 1, `s422_322x240` 2, `s422_322x246` 3, `s422_352x242_10b` -// 4, `s422_416x242_10b` 5, `s422_416x250_10b` 6), and every other committed -// 4:2:2 cell leaves it at 6. **No committed gate reads it**: the accessor -// below has no callers in the crate (the 4:4:4 twin is read at two -// `stream.rs` sites, this one nowhere). The honest sentence is therefore -// "no committed test reads this counter", which is what the 4:4:4 twin's -// doc says about itself -- it does NOT become "the corpus gate reads it". -thread_local! { - pub(super) static INTRABC_RECT4_OWN_CHROMA422_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTRABC_RECT4_OWN_CHROMA422_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intrabc_rect4_own_chroma422_hits() -> usize { - INTRABC_RECT4_OWN_CHROMA422_HITS.with(std::cell::Cell::get) -} - -/// Resets [`INTRABC_RECT4_OWN_CHROMA422_HITS`] before a decode. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_intrabc_rect4_own_chroma422_hits() { - INTRABC_RECT4_OWN_CHROMA422_HITS.with(|c| c.set(0)); -} - -/// Current value of [`INTRABC_RECT4_OWN_CHROMA444_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intrabc_rect4_own_chroma444_hits() -> usize { - INTRABC_RECT4_OWN_CHROMA444_HITS.with(std::cell::Cell::get) -} - -/// Resets [`INTRABC_RECT4_OWN_CHROMA444_HITS`] before a decode. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_intrabc_rect4_own_chroma444_hits() { - INTRABC_RECT4_OWN_CHROMA444_HITS.with(|c| c.set(0)); -} - -// lane-rectx r5: how many times a NON-strip `kf_y_mode` reader -// ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an -// above/left mode from the mi-exact map that DIFFERS from its coarse 16x16 -// slot -- i.e. how often the r5 defect would have picked the wrong CDF row. -thread_local! { - pub(super) static MODE_MI_OVERRIDE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`MODE_MI_OVERRIDE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn mode_mi_override_hits() -> usize { - MODE_MI_OVERRIDE_HITS.with(|c| c.get()) -} - -// lane-cfl r1: how many times a chroma intra-edge filter-type read -// (`get_filt_type`, libaom reconintra.c) took an above/left UV mode from the -// mi-exact map that DIFFERS from its coarse 16x16 slot -- i.e. how often the -// r1 defect would have filtered a chroma edge with the wrong strength. -thread_local! { - pub(super) static UV_MODE_MI_OVERRIDE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`UV_MODE_MI_OVERRIDE_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn uv_mode_mi_override_hits() -> usize { - UV_MODE_MI_OVERRIDE_HITS.with(|c| c.get()) -} - -// lane-t900 r12: how many chroma edge-filter-type reads took their above/left -// `uv_mode` from the mi GRID where the one-slot-per-column map would have -// answered differently -- the sub-8x8 pair case where the pair's own first -// half had already overwritten the column slot the chroma-ref half reads. -thread_local! { - pub(super) static UV_MODE_GRID_OVERRIDE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`UV_MODE_GRID_OVERRIDE_HITS`]. -pub fn uv_mode_grid_override_hits() -> usize { - UV_MODE_GRID_OVERRIDE_HITS.with(|c| c.get()) -} - -// lane-t900 r8: how many intra edge-filter-type reads (luma + chroma) the -// INTER neighbour stamp saved: the coarse SUB band still held a SMOOTH mode -// from an earlier block in that pixel row/column while the mi-exact map -- -// which an inter block only started writing this round -- correctly says the -// neighbour is not smooth (libaom `is_smooth`: an inter neighbour's `mode` is -// an INTER mode, and its `uv_mode` "is not set for inter blocks"). -thread_local! { - pub(super) static INTER_NEIGHBOUR_NOT_SMOOTH_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTER_NEIGHBOUR_NOT_SMOOTH_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn inter_neighbour_not_smooth_hits() -> usize { - INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|c| c.get()) -} - -// lane-mtfix r1: how many times a chroma intra-edge filter-type read was -// suppressed at a TILE edge that is not a frame edge -- the above/left -// `uv_mode` neighbour of a block on a tile's first mi row/column lives in -// another tile, so libaom's `above_mbmi`/`left_mbmi` are NULL there. The -// coarse [`SUB`] maps are frame-sized and (`above_uv_mode`) not cleared per -// tile, so without the guard in [`Neighbours::smooth_uv_neighbour`] the tile -// above would decide this tile's chroma edge filter strength. -thread_local! { - pub(super) static UV_TILE_EDGE_SUPPRESSED_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`UV_TILE_EDGE_SUPPRESSED_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn uv_tile_edge_suppressed_hits() -> usize { - UV_TILE_EDGE_SUPPRESSED_HITS.with(|c| c.get()) -} - -// lane-av1leftref: how many chroma intra-edge filter-type reads land on a -// left neighbour whose `uv_mode` at libaom's real read cell -// (`base_mi[ss_y * mi_stride - 1]` = row `+ss_y`, col `-1`) DIFFERS from the -// cell this decoder used to read (its own mi row). Two buckets: the raw mode -// value moved, and `is_smooth_mode` -- the boolean the read actually feeds -- -// flipped. The second is the one that can move pixels. -thread_local! { - pub(super) static UV_LEFT_SS_Y_MODE_DIFF_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; - pub(super) static UV_LEFT_SS_Y_SMOOTH_DIFF_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`UV_LEFT_SS_Y_MODE_DIFF_HITS`]. -pub fn uv_left_ss_y_mode_diff_hits() -> usize { - UV_LEFT_SS_Y_MODE_DIFF_HITS.with(|c| c.get()) -} - -/// Current value of [`UV_LEFT_SS_Y_SMOOTH_DIFF_HITS`]. -pub fn uv_left_ss_y_smooth_diff_hits() -> usize { - UV_LEFT_SS_Y_SMOOTH_DIFF_HITS.with(|c| c.get()) -} - -// lane-av1leftwit: decode-path chroma edge-filter-type reads at `ss_y > 0` -// whose left-neighbour COLUMN holds a run of length 1 -- the cell this -// decoder reads (its own mi row) and the cell libaom reads (one row down) -// were written by two DIFFERENT blocks, i.e. the left neighbour is at most -// 1 mi tall. That is the only geometry in which the `+ss_y` term can change -// the answer at all; `UV_LEFT_SS_Y_READS` alone proves nothing about it. -thread_local! { - pub(super) static UV_LEFT_1MI_SPLIT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`UV_LEFT_1MI_SPLIT_HITS`]. -pub fn uv_left_1mi_split_hits() -> usize { - UV_LEFT_1MI_SPLIT_HITS.with(|c| c.get()) -} - -// lane-cfl r1 gate counters: `UV_CFL_PRED` blocks (every `cfl_alpha_signs` -// read) and chroma blocks with a NONZERO `angle_delta_uv` -- the two block -// shapes the r1 chroma defect showed up on. -thread_local! { - pub(super) static CFL_BLOCK_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static UV_ANGLE_DELTA_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -// lane-av1cfl: which `cfl_ac_ss` arm ran, one bump per CfL block. The 4:4:4 -// arm is libaom `cfl_luma_subsampling_444_lbd_c` (1x1 luma per chroma sample) -// and the 4:2:2 arm is `cfl_luma_subsampling_422_lbd_c`; only the last two -// reach `cfl_ac_q3_at`'s 2x2 average, so these four are the reachability -// evidence for that function's format-blind extent. -thread_local! { - pub(super) static CFL_AC_444_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static CFL_AC_422_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static CFL_AC_420_SQ_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static CFL_AC_420_RECT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static CFL_AC_Q3_AT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// `[4:4:4, 4:2:2, 4:2:0 square, 4:2:0 rect]` [`cfl_ac_ss`] arm hits. -pub fn cfl_ac_arm_hits() -> [usize; 4] { - [ - CFL_AC_444_HITS.with(|c| c.get()), - CFL_AC_422_HITS.with(|c| c.get()), - CFL_AC_420_SQ_HITS.with(|c| c.get()), - CFL_AC_420_RECT_HITS.with(|c| c.get()), - ] -} - -/// Entries into [`cfl_ac_q3_at`] itself -- the one arm whose extent is -/// `bw / 2, bh / 2` and whose footprint is a 2x2 luma average. The gate -/// proves it is reached ONLY at 4:2:0. -pub fn cfl_ac_q3_at_hits() -> usize { - CFL_AC_Q3_AT_HITS.with(|c| c.get()) -} - -/// Current value of [`CFL_BLOCK_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn cfl_block_hits() -> usize { - CFL_BLOCK_HITS.with(|c| c.get()) -} - -/// Current value of [`UV_ANGLE_DELTA_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn uv_angle_delta_hits() -> usize { - UV_ANGLE_DELTA_HITS.with(|c| c.get()) -} - -// lane-sbpart r2: how many superblock-level `PARTITION_HORZ`/`PARTITION_VERT` -// blocks (two true 64x32/32x64 strips, [`decode_block_rect64`]) fired -- the -// gate's proof this round's arms actually reached a real block, not just -// that `partition_w64` read one of those two symbol values. -thread_local! { - pub(super) static SB_RECT_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -// Current value of [`SB_RECT_HITS`]. -// lane-hgkf r1: the frame-edge partition bit, one level each. Slot 0 = a -// 64-level gathered edge bit read as HORZ/VERT, 1 = the same bit read as -// SPLIT, 2/3 = the 32-level pair. A gate asserting slot 0 or 2 proves the -// non-SPLIT edge arm actually decoded (before this round the bit was read and -// thrown away, so that arm was unreachable). -thread_local! { - pub(super) static EDGE_PART_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; -} - -/// Current value of [`EDGE_PART_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn edge_part_hits() -> [usize; 4] { - EDGE_PART_HITS.with(|c| c.get()) -} - -/// Reset [`EDGE_PART_HITS`] (a gate counts one stream at a time). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn reset_edge_part_hits() { - EDGE_PART_HITS.with(|c| c.set([0; 4])); -} - -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn sb_rect_hits() -> usize { - SB_RECT_HITS.with(|c| c.get()) -} - -// lane-golomb r2: the 32x32-level FRAME-EDGE partition. Slot 0/1 = the -// gathered edge bit read as 0 (HORZ/VERT) / 1 (SPLIT); slot 2 = a 32-level -// PARTITION_HORZ decoded with `has_rows32 == false` (only the top 32x16 half -// is coded), slot 3 = a PARTITION_VERT with `has_cols32 == false`. Both tile -// paths (intra and inter) feed the same counter. -// -// lane-golomb r3: slots 4..7 are the same four facts one level up, at the -// SUPERBLOCK (64x64) edge -- 4/5 = the gathered 64-level bit read as -// HORZ/VERT / SPLIT, 6 = a 64x32 bottom-edge strip decoded with -// `has_rows == false`, 7 = a 32x64 right-edge strip. Real aomenc answers a -// bottom-edge superblock with the 64-level HORZ (measured: 192x80 flat-band, -// every SB of the last row), so the 32-level slots stay 0 on that content and -// only these prove the arm fired. -thread_local! { - pub(super) static EDGE32_HITS: std::cell::Cell<[usize; 8]> = - const { std::cell::Cell::new([0; 8]) }; -} - -/// Current value of [`EDGE32_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn edge32_hits() -> [usize; 8] { - EDGE32_HITS.with(|c| c.get()) -} - -// lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/ -// `_B`/`VERT_A`/`_B` at 64x64 -- two 32x32 squares plus one 64x32/32x64 -// strip) fired. Real aomenc picks these at 64 even with -// `--enable-ab-partitions=0` (lane-sbpart r2's own measurement), so this is -// the counter the gate hard-asserts. -thread_local! { - pub(super) static SB_AB_HITS: std::cell::Cell<[usize; 4]> = - const { std::cell::Cell::new([0; 4]) }; -} - -/// Current value of [`SB_AB_HITS`], summed over the four arms. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn sb_ab_hits() -> usize { - SB_AB_HITS.with(|c| c.get().iter().sum()) -} - -/// [`SB_AB_HITS`] split per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, -/// `_VERT_A`, `_VERT_B` order -- what the gate hard-asserts arm by arm, so a -/// run where aomenc's RD only ever picked (say) `HORZ_A` cannot pass off as -/// proof of all four. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn sb_ab_hits_by_arm() -> [usize; 4] { - SB_AB_HITS.with(std::cell::Cell::get) -} - -// lane-tx64x16: the two 1:4 superblock arms, counted per orientation -- -// `PARTITION_HORZ_4` (four 64x16 strips) and `PARTITION_VERT_4` (four 16x64 -// strips). Two counters, not one, because a gate that only proved "some 1:4 -// strip fired" would pass on a stream that never coded the other axis, and -// every scan/context table this round added comes in a transposed pair. -thread_local! { - pub(super) static SB_RECT4_HORZ_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static SB_RECT4_VERT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of `SB_RECT4_HORZ_HITS` (64x16 strips decoded). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn sb_rect4_horz_hits() -> usize { - SB_RECT4_HORZ_HITS.with(|c| c.get()) -} - -/// Current value of `SB_RECT4_VERT_HITS` (16x64 strips decoded). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn sb_rect4_vert_hits() -> usize { - SB_RECT4_VERT_HITS.with(|c| c.get()) -} - -// lane-tx64x16 r3: the 32x32-level 1:4 arms, counted per orientation -- -// `PARTITION_HORZ_4` (four 32x8 strips) and `PARTITION_VERT_4` (four 8x32 -// strips), the arms the ReelB mid-film extract stops at. -thread_local! { - pub(super) static RECT4_32_HORZ_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static RECT4_32_VERT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-inter4 r1: the INTER-frame twins of the two counters above -- - /// four 32x8 / 8x32 inter strips of a 32x32-level `PARTITION_HORZ_4` / - /// `PARTITION_VERT_4`. - pub(super) static RECT4_32_HORZ_INTER_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static RECT4_32_VERT_INTER_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-inter4 r1: superblock-level inter `PARTITION_HORZ`/`PARTITION_VERT` - /// strips (64x32 / 32x64) and their 1:4 pair (64x16 / 16x64). - pub(super) static INTER_SB_HORZ_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static INTER_SB_VERT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static INTER_SB_HORZ4_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static INTER_SB_VERT4_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -// How many 32x32-level 1:4 strips actually read coefficients (non-skip): -// a gate that only counted strips would pass on an all-skip stream, which -// exercises none of the new scan/context tables. -thread_local! { - pub(super) static RECT4_COEFF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -// lane-rectsplitx r1: 1:4 strips (32x8/8x32/64x16/16x64) decoded through the -// per-transform-unit split path, split by tx depth -- depth 1 is a 2:1 RECT -// unit (TX_16X8/TX_32X16), depth 2 a square one, and the two INTERLEAVE in -// every real stream, so a gate must prove both fired. `SUB16_SPLIT_HITS` -// counts the same for a 16x8/8x16 strip below 16x16. -thread_local! { - pub(super) static RECT4_SPLIT_DEPTH1_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static RECT4_SPLIT_DEPTH2_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static SUB16_SPLIT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current values of `RECT4_SPLIT_DEPTH1_HITS` / `RECT4_SPLIT_DEPTH2_HITS`. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect4_split_depth_hits() -> (usize, usize) { - ( - RECT4_SPLIT_DEPTH1_HITS.with(|c| c.get()), - RECT4_SPLIT_DEPTH2_HITS.with(|c| c.get()), - ) -} - -/// Current value of `SUB16_SPLIT_HITS`. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn sub16_split_hits() -> usize { - SUB16_SPLIT_HITS.with(|c| c.get()) -} - -// lane-frame36 r2: superblock-level strips ([`decode_block_rect64`]) whose -// luma transform is SPLIT and which therefore leave through that fn's early -// return -- the arm that published no `TXFM_CONTEXT` band until this round. -thread_local! { - pub(super) static RECT64_SPLIT_TXFM_PUBLISH_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of `RECT64_SPLIT_TXFM_PUBLISH_HITS`. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect64_split_txfm_publish_hits() -> usize { - RECT64_SPLIT_TXFM_PUBLISH_HITS.with(|c| c.get()) -} - -/// Current value of `RECT4_COEFF_HITS`. -pub(crate) fn rect4_coeff_hits() -> usize { - RECT4_COEFF_HITS.with(|c| c.get()) -} - -// lane-sbab r1: how many superblock-level (64x64) AB partitions fired IN AN -// INTER frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, -// `_VERT_B` order (the intra-frame counterpart is `SB_AB_HITS`). Each arm is -// two 32x32 inter squares plus one true 64x32/32x64 inter strip; the gate -// asserts the arms it proves separately so a run whose RD only picked one -// cannot pass as proof of the others. -thread_local! { - pub(super) static SB_AB_INTER_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; -} - -/// [`SB_AB_INTER_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 64x64 in an -/// inter frame). -pub fn sb_ab_inter_hits_by_arm() -> [usize; 4] { - SB_AB_INTER_HITS.with(std::cell::Cell::get) -} - -// lane-inter16ab r1: how many 16x16-level AB partitions fired IN AN INTER -// frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B` -// order (the intra-frame counterpart is `AB16_HITS`). Each arm is two 8x8 -// inter leaves (`decode_inter_block8`) plus one true 16x8/8x16 inter strip -// (`decode_inter_block` with `write_w`/`write_h`); the gate asserts every -// arm separately so a run whose RD only picked one cannot pass as proof of -// four. -thread_local! { - pub(super) static AB16_INTER_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; -} - -/// [`AB16_INTER_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16 in an -/// inter frame). -pub fn ab16_inter_hits_by_arm() -> [usize; 4] { - AB16_INTER_HITS.with(std::cell::Cell::get) -} - -// lane-inter16ab r2: the 16x16-level 1:4 pair as INTER blocks -- four 16x4 -// (`PARTITION_HORZ_4`) or 4x16 (`PARTITION_VERT_4`) strips. `CHROMA_PAIRS` -// counts the odd strips that close a 4:2:0 chroma pair -// (`is_chroma_reference`, av1_common_int.h:1454: bh == 1 mi => odd mi_row), -// `SUB8_PIECES` the pair chroma blocks whose TOP (LEFT) half was built from -// the PREVIOUS strip's own mv/ref/filters -- libaom -// `build_inter_predictors_sub8x8` (reconinter_template.inc:87-160), reached -// through `is_sub8x8_inter` (same file, :54). -thread_local! { - pub(super) static INTER16_HORZ4_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static INTER16_VERT4_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static INTER16_CHROMA_PAIR_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static INTER16_SUB8_PIECE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -// lane-arfchroma: chroma transform-unit publications whose block started -// MID-CELL -- the condition `record_mi_chroma`'s origin alignment exists for. -// A 4x4 chroma unit is `1 << ss` luma mi per axis, so a block whose mi origin -// is not step-aligned (a 16x4 / 4x16 1:4 strip at 4:2:0 has an ODD mi row or -// column) publishes a context cell whose origin is the step-aligned mi BELOW -// or RIGHT of its own. Counted per publication, `[row_misaligned, -// col_misaligned, both]`, so a gate can prove the witness really walks the -// realigned path instead of passing on a stream whose chroma units all happen -// to start on a cell boundary. -thread_local! { - pub(super) static CHROMA_MIDCELL_PUB_HITS: std::cell::Cell<[usize; 3]> = - const { std::cell::Cell::new([0; 3]) }; -} - -/// ChROMA publications that started mid-cell: `[row, col, both]`. See -/// [`CHROMA_MIDCELL_PUB_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn chroma_midcell_pub_hits() -> [usize; 3] { - CHROMA_MIDCELL_PUB_HITS.with(std::cell::Cell::get) -} - -/// Zeroes [`CHROMA_MIDCELL_PUB_HITS`] so a gate can measure its own decode. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub fn reset_chroma_midcell_pub_hits() { - CHROMA_MIDCELL_PUB_HITS.with(|c| c.set([0; 3])); -} - -// lane-intra16x4: INTRA-coded strips of an inter 16x16-level 1:4 partition -- -// [0] 16x4, [1] 4x16, [2] the odd (chroma-reference) ones, which carry the -// pair's single 8x4 (4x8) chroma unit for BOTH strips. -thread_local! { - pub(super) static INTRA16X4_IN_INTER_HITS: std::cell::Cell<[usize; 3]> = - const { std::cell::Cell::new([0; 3]) }; -} - -/// `(intra 16x4 strips, intra 4x16 strips, of which chroma-reference)` decoded -/// inside an INTER 16x16-level 1:4 partition (lane-intra16x4). -pub fn intra16x4_in_inter_hits() -> (usize, usize, usize) { - let v = INTRA16X4_IN_INTER_HITS.with(std::cell::Cell::get); - (v[0], v[1], v[2]) -} - -/// Current values of the inter 16x16-level 1:4 counters: `(16x4 strips, 4x16 -/// strips, chroma pairs closed, chroma pairs built from two different -/// strips' motion vectors)`. -pub fn inter16_rect4_counters() -> (usize, usize, usize, usize) { - ( - INTER16_HORZ4_HITS.with(std::cell::Cell::get), - INTER16_VERT4_HITS.with(std::cell::Cell::get), - INTER16_CHROMA_PAIR_HITS.with(std::cell::Cell::get), - INTER16_SUB8_PIECE_HITS.with(std::cell::Cell::get), - ) -} - -// lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or -// 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that -// close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual. -thread_local! { - pub(super) static RECT4_16_HORZ_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static RECT4_16_VERT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static RECT4_16_CHROMA_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static RECT4_16_COEFF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static RECT4_16_SPLIT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-kf1200: pairs whose chroma edge-filter type read from the PAIR's - /// base mi differs from what the strip's own (odd) mi would have said -- - /// the shape that made 4 chroma samples of the ReelB `-ss 1200` - /// key frame miss by 1. Zero here means a gate never exercised the fix. - pub(super) static RECT4_16_UV_PAIR_FILT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-rect14: lossless 16x4/4x16 chroma pairs walked as two TX_4X4s. - pub(super) static RECT4_16_LOSSLESS_CHROMA_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-rect14: intrabc reconstructions of a 16x4/4x16 pair strip. - pub(super) static RECT4_16_INTRABC_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-kf1200 r2: sub-8x8 chroma blocks that are `skip_txfm` AND - /// `UV_CFL_PRED` -- the arm that used to drop the CfL alpha entirely. - pub(super) static SKIP_CFL_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-loss64: chroma transform units the frame-edge clip skipped - /// (libaom `decode_reconstruct_tx`'s `max_blocks_wide/high` test) in - /// [`decode_block`]'s multi-transform-unit walk -- the units a lossless - /// block overhanging the frame does NOT code. - pub(super) static CHROMA_EDGE_TU_CLIP_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-loss64: skipped lossless intrabc rect strips whose luma - /// entropy bands were zeroed per unit (libaom `av1_reset_entropy_context`, - /// decodeframe.c:1262) instead of leaking the previous occupant's. - pub(super) static SKIP_LOSSLESS_BAND_RESET_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-llband: 4x4 chroma transform units a lossless HORZ/VERT strip - /// walked at subsampling 0/0 (one unit per mi cell -- the geometry the - /// hardcoded 4:2:0 span mis-stepped). - pub(super) static RECT_SPLIT_LOSSLESS_CHROMA444_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-ibc444rect: unskipped intrabc 8x4/4x8 leaves whose luma - /// coefficients a lossless frame walked as per-4x4 inter units (the walk - /// that replaced the single rect unit). - pub(super) static INTRABC_RECT8_LOSSLESS_LUMA_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-ibc444rect: unskipped intrabc 8x4/4x8 leaves whose chroma a - /// lossless 4:4:4 frame walked as per-4x4 [`TxbSet::Chroma4`] units. - pub(super) static INTRABC_RECT8_LOSSLESS_CHROMA_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1loss444kf: 4:4:4 lossless sub-8x8 RECT (8x4 / 4x8) leaf chroma - /// units whose libaom-faithful block-relative reach - /// ([`Reach::of_tu`] over the leaf's own bsize) differs from the - /// standalone-BLOCK_4X4 lookup that used to answer for them. Zero means - /// no stream reached a rect leaf where the two disagree -- a gate - /// asserting the reach fix must see this nonzero, or the fixture never - /// exercised the fixed path. - pub(super) static SUB8_CHROMA444_LOSSLESS_TU_REACH_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1offtile: 4x4 chroma units a lossless HORZ/VERT strip's plane- - /// major walk skipped because their top-left sample falls outside the - /// CHROMA plane. libaom bounds that walk per plane (`max_block_wide/high`, - /// av1_common_int.h:1565); this walk used to count the block's own - /// `chroma_w / 4` x `chroma_h / 4`. Zero means no stream decoded a - /// lossless strip overhanging the frame edge -- a gate asserting the - /// clip must see this nonzero. - pub(super) static RECT_SPLIT_LOSSLESS_CHROMA_OFFTILE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// How many skipped sub-8x8 chroma blocks carried a CfL alpha (the shape -/// that reconstructed as flat DC before lane-kf1200 r2). -pub fn skip_cfl_hits() -> usize { - SKIP_CFL_HITS.with(|c| c.get()) -} - -/// How many chroma transform units the frame-edge clip skipped in -/// [`decode_block`]'s multi-transform-unit walk (lane-av1-loss64). Zero on a -/// stream whose lossless blocks never overhang the frame -- a gate asserting -/// the clip fired must see this nonzero. -pub fn chroma_edge_tu_clip_hits() -> usize { - CHROMA_EDGE_TU_CLIP_HITS.with(|c| c.get()) -} - -/// How many skipped lossless intrabc rect strips had their luma entropy -/// bands zeroed per unit (lane-av1-loss64). -pub fn skip_lossless_band_reset_hits() -> usize { - SKIP_LOSSLESS_BAND_RESET_HITS.with(|c| c.get()) -} - -/// How many 4x4 chroma transform units a lossless HORZ/VERT strip walked at -/// subsampling 0/0 (lane-av1-llband). Zero means a stream never decoded the -/// 4:4:4 lossless unit walk this counter proves -- a gate asserting the fix -/// must see this nonzero. -pub fn rect_split_lossless_chroma444_hits() -> usize { - RECT_SPLIT_LOSSLESS_CHROMA444_HITS.with(|c| c.get()) -} - -/// How many 4x4 chroma units a lossless HORZ/VERT strip's plane-major walk -/// skipped for falling outside the chroma plane (lane-av1offtile). Zero means -/// no stream decoded a lossless strip overhanging the frame edge -- a gate -/// asserting the clip must see this nonzero. -pub fn rect_split_lossless_chroma_offtile_hits() -> usize { - RECT_SPLIT_LOSSLESS_CHROMA_OFFTILE_HITS.with(|c| c.get()) -} - -/// Reset [`rect_split_lossless_chroma_offtile_hits`] to zero (lane-av1offtile). -pub fn reset_rect_split_lossless_chroma_offtile_hits() { - RECT_SPLIT_LOSSLESS_CHROMA_OFFTILE_HITS.with(|c| c.set(0)); -} - -/// How many unskipped intrabc 8x4/4x8 leaves a lossless frame walked luma as -/// per-4x4 inter units (lane-av1-ibc444rect). -pub fn intrabc_rect8_lossless_luma_hits() -> usize { - INTRABC_RECT8_LOSSLESS_LUMA_HITS.with(|c| c.get()) -} - -/// How many unskipped intrabc 8x4/4x8 leaves a lossless 4:4:4 frame walked -/// chroma as per-4x4 [`TxbSet::Chroma4`] units (lane-av1-ibc444rect). -pub fn intrabc_rect8_lossless_chroma_hits() -> usize { - INTRABC_RECT8_LOSSLESS_CHROMA_HITS.with(|c| c.get()) -} - -/// How many 4:4:4 lossless sub-8x8 RECT leaf chroma units took the -/// block-relative reach libaom's `has_bottom_left` gives, where the -/// standalone-BLOCK_4X4 lookup that used to answer disagreed -/// (lane-av1loss444kf). Zero on a stream with no such leaf. -pub fn sub8_chroma444_lossless_tu_reach_hits() -> usize { - SUB8_CHROMA444_LOSSLESS_TU_REACH_HITS.with(|c| c.get()) -} - -/// Gate-side reset for [`SUB8_CHROMA444_LOSSLESS_TU_REACH_HITS`]. -pub fn reset_sub8_chroma444_tu_reach_hits() { - SUB8_CHROMA444_LOSSLESS_TU_REACH_HITS.with(|c| c.set(0)); -} - -/// Gate-side reset for the two lane-av1-ibc444rect counters above. -pub fn reset_ibc444rect_hits() { - INTRABC_RECT8_LOSSLESS_LUMA_HITS.with(|c| c.set(0)); - INTRABC_RECT8_LOSSLESS_CHROMA_HITS.with(|c| c.set(0)); -} - -/// Gate-side reset for the two lane-av1-loss64 counters above. -pub fn reset_loss64_hits() { - CHROMA_EDGE_TU_CLIP_HITS.with(|c| c.set(0)); - SKIP_LOSSLESS_BAND_RESET_HITS.with(|c| c.set(0)); -} - -/// How many 16x4/4x16 chroma pairs took a different `intra_edge_filter_type` -/// from the pair's base mi than the strip's own mi would have given. -pub fn rect4_16_uv_pair_filt_hits() -> usize { - RECT4_16_UV_PAIR_FILT_HITS.with(|c| c.get()) -} - -/// How many lossless 16x4/4x16 chroma pairs walked two TX_4X4s per plane. -pub fn rect4_16_lossless_chroma_hits() -> usize { - RECT4_16_LOSSLESS_CHROMA_HITS.with(|c| c.get()) -} - -/// How many 16x4/4x16 strips reconstructed as intra block copy. -pub fn rect4_16_intrabc_hits() -> usize { - RECT4_16_INTRABC_HITS.with(|c| c.get()) -} - -/// Zero the lane-av1-rect14 pair counters so a gate measures one stream. -pub fn reset_rect4_16_pair_hits() { - RECT4_16_LOSSLESS_CHROMA_HITS.with(|c| c.set(0)); - RECT4_16_INTRABC_HITS.with(|c| c.set(0)); -} - -// lane-reelckf r1: the two chroma defects ReelC's key frames exposed -- -// CHROMA_SKIP_CFL counts skipped intra blocks whose chroma is `UV_CFL_PRED` -// (prediction still runs, libaom `predict_and_reconstruct_intra_block`), and -// RECT4_16_CHROMA_DIR counts 1:4 chroma pairs predicted directionally (whose -// intra-edge filter type must come from the chroma-reference position). -thread_local! { - pub(super) static CHROMA_SKIP_CFL_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static RECT4_16_CHROMA_DIR_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// `(skipped UV_CFL_PRED blocks, directional 1:4 chroma pairs)` -- lane-reelckf. -pub fn reelc_chroma_counters() -> (usize, usize) { - ( - CHROMA_SKIP_CFL_HITS.with(|c| c.get()), - RECT4_16_CHROMA_DIR_HITS.with(|c| c.get()), - ) -} - -/// Current values of the 16x16-level 1:4 counters: `(16x4 strips, 4x16 -/// strips, chroma-reference strips, strips with a coded residual, strips -/// whose luma transform is split)`. -pub fn rect4_16_counters() -> (usize, usize, usize, usize, usize) { - ( - RECT4_16_HORZ_HITS.with(|c| c.get()), - RECT4_16_VERT_HITS.with(|c| c.get()), - RECT4_16_CHROMA_HITS.with(|c| c.get()), - RECT4_16_COEFF_HITS.with(|c| c.get()), - RECT4_16_SPLIT_HITS.with(|c| c.get()), - ) -} - -/// Current value of `RECT4_32_HORZ_HITS` (32x8 strips decoded). -pub(crate) fn rect4_32_horz_hits() -> usize { - RECT4_32_HORZ_HITS.with(|c| c.get()) -} - -/// Current value of `RECT4_32_VERT_HITS` (8x32 strips decoded). -pub(crate) fn rect4_32_vert_hits() -> usize { - RECT4_32_VERT_HITS.with(|c| c.get()) -} - -/// Current value of `RECT4_32_HORZ_INTER_HITS` (32x8 inter strips decoded). -pub(crate) fn rect4_32_horz_inter_hits() -> usize { - RECT4_32_HORZ_INTER_HITS.with(|c| c.get()) -} - -/// Current value of `RECT4_32_VERT_INTER_HITS` (8x32 inter strips decoded). -pub(crate) fn rect4_32_vert_inter_hits() -> usize { - RECT4_32_VERT_INTER_HITS.with(|c| c.get()) -} - -/// Current value of `INTER_SB_HORZ_HITS` (64x32 inter strips decoded). -pub(crate) fn inter_sb_horz_hits() -> usize { - INTER_SB_HORZ_HITS.with(|c| c.get()) -} - -/// Current value of `INTER_SB_VERT_HITS` (32x64 inter strips decoded). -pub(crate) fn inter_sb_vert_hits() -> usize { - INTER_SB_VERT_HITS.with(|c| c.get()) -} - -/// Current value of `INTER_SB_HORZ4_HITS` (64x16 inter strips decoded). -pub(crate) fn inter_sb_horz4_hits() -> usize { - INTER_SB_HORZ4_HITS.with(|c| c.get()) -} - -/// Current value of `INTER_SB_VERT4_HITS` (16x64 inter strips decoded). -pub(crate) fn inter_sb_vert4_hits() -> usize { - INTER_SB_VERT4_HITS.with(|c| c.get()) -} - -// lane-rect64q r1: how many of [`decode_block_rect64`]'s three per-plane -// dequant calls actually observed `CURRENT_Q_IDX != base_q_idx` -- proof the -// running-vs-stale-snapshot bug this round fixed is exercised by a gate, not -// just inert-compiled. Zero forever on a passing gate means that gate's -// stream never carries `delta_q_present=1` through a rect64 block. -thread_local! { - pub(super) static RECT64_QIDX_DRIFT_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT64_QIDX_DRIFT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect64_qidx_drift_hits() -> usize { - RECT64_QIDX_DRIFT_HITS.with(|c| c.get()) -} - -// lane-partab r1: how many 32x32 quadrants decoded an AB partition -// (PARTITION_HORZ_A / VERT_A / VERT_B -- two 16x16 squares plus one -// 16x32/32x16 strip). Like [`RECT_PARTITION_HITS`], this is the -// free-partition gate's proof this round's arms actually fired. -thread_local! { - pub(super) static PARTAB_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`PARTAB_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn partab_hits() -> usize { - PARTAB_HITS.with(|c| c.get()) -} - -// lane-part32 r1: how many 32x32 quadrants decoded each INTRA AB/4-way arm, -// one counter per arm rather than one shared total -- the gate hard-asserts -// each of these individually nonzero so a recipe that only ever fires -// HORZ_A can't silently stand in for the whole set. -thread_local! { - pub(super) static INTRA_HORZ_A_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; - pub(super) static INTRA_HORZ_B_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; - pub(super) static INTRA_VERT_A_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; - pub(super) static INTRA_VERT_B_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`INTRA_HORZ_A_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_horz_a_hits() -> usize { - INTRA_HORZ_A_HITS.with(|c| c.get()) -} - -/// Current value of [`INTRA_HORZ_B_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_horz_b_hits() -> usize { - INTRA_HORZ_B_HITS.with(|c| c.get()) -} - -/// Current value of [`INTRA_VERT_A_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_vert_a_hits() -> usize { - INTRA_VERT_A_HITS.with(|c| c.get()) -} - -/// Current value of [`INTRA_VERT_B_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn intra_vert_b_hits() -> usize { - INTRA_VERT_B_HITS.with(|c| c.get()) -} - -// How many [`read_inter_compound_mode`] reads actually happened -// (lane-av1comp) -- proves a `COMPOUND_REFERENCE` block reached its own -// `compound_mode` symbol (past `comp_mode`/`comp_ref` and the compound -// mvstack build), not just that `comp_mode` fired. Still refused right -// after (no MV assignment or MC wired), so this only counts attempted -// reads. -thread_local! { - pub(super) static COMPOUND_MODE_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`COMPOUND_MODE_HITS`]. -#[allow(dead_code)] // reader is test-only (the 12-bit compound witness); dead in non-test builds -pub(crate) fn compound_mode_hits() -> usize { - COMPOUND_MODE_HITS.with(|c| c.get()) -} - -/// How many query blocks folded in at least one temporal MV candidate -/// (spec 7.10.2.8's `add_tpl_ref_mv`) so far in this process -- the -/// temporal-MV gate's own firing counter (lane-av1tmvp). -/// -/// # HANDOFF (lane-av1tmvp): not yet wired to a live stream -/// [`crate::mvstack::find_mv_stack_with_sign_bias`]'s only call site in -/// this file (`decode_inter_block`) still passes `tpl: None` -- this -/// counter compiles and the projection math it counts is unit-tested -/// ([`crate::motion_field`]), but nothing in [`crate::stream::decode_stream`] -/// builds a per-DPB-slot [`crate::motion_field::MotionField`] or calls -/// [`crate::motion_field::setup_motion_field`] yet, so this will read `0` -/// against any real stream today. See the module doc on -/// `crate::motion_field` and this crate's ledger for the remaining wiring. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn tmv_hits() -> usize { - crate::mvstack::tmv_hits() -} - -/// Current value of [`crate::mc::inter_pred_hits`] -- inter predictions -/// produced on this thread, the 10-bit inter gate's firing proof. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn inter_pred_hits() -> usize { - crate::mc::inter_pred_hits() -} - -/// Current value of the counter for `ref_frame` (`LAST2_FRAME`..=`ALTREF_FRAME`; -/// panics on `LAST_FRAME`/`INTRA_FRAME`/`NONE`, which have no counter here). -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn ref_hits(ref_frame: i8) -> usize { - let c = match ref_frame { - LAST2_FRAME => &LAST2_HITS, - LAST3_FRAME => &LAST3_HITS, - GOLDEN_FRAME => &GOLDEN_HITS, - BWDREF_FRAME => &BWDREF_HITS, - ALTREF2_FRAME => &ALTREF2_HITS, - ALTREF_FRAME => &ALTREF_HITS, - other => panic!("ref_hits: no per-reference counter for ref_frame {other}"), - }; - c.with(|v| v.get()) -} - -/// Current value of [`ANGLE_DELTA_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn angle_delta_hits() -> usize { - ANGLE_DELTA_HITS.with(|c| c.get()) -} - -/// Current value of [`TX_CLASS1_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn tx_class1_hits() -> usize { - TX_CLASS1_HITS.with(|c| c.get()) -} - -// How many `PARTITION_SPLIT` decisions below an 8x8 block (four independent -// `BLOCK_4X4` leaves, spec `decode_partition`'s `bSize < BLOCK_8X8` recursion -// bottom) this thread's decode actually reconstructed -- the same -// before/after counter pattern as [`TX_CLASS1_HITS`], proving a stream -// genuinely exercised the sub-8x8 leaf path rather than every attempt -// coincidentally landing on `PARTITION_NONE`. -thread_local! { - pub(super) static SUB8_SPLIT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// How many 8x8 groups an INTER frame split into four BLOCK_4X4 inter - /// sub-blocks (lane-intersub8). - pub(super) static SUB8_INTER_SPLIT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// How many 8x8 groups an INTER frame split into two rectangular sub-8x8 - /// inter leaves (lane-intersub8 r3), indexed `[0] = HORZ` (two BLOCK_8X4), - /// `[1] = VERT` (two BLOCK_4X8). - pub(super) static SUB8_INTER_RECT_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; - /// lane-sub8intra: INTRA leaves decoded inside an inter frame's sub-8x8 - /// HORZ/VERT partition -- `[0]` 8x4, `[1]` 4x8, `[2]` of those that were - /// the chroma reference (so coded the group's 4x4 chroma intra), `[3]` - /// MIXED groups whose chroma reference is INTER while its sibling is - /// intra (the `is_sub8x8_inter` false path), `[4]` INTRA `BLOCK_4X4` - /// leaves of an inter frame's sub-8x8 `PARTITION_SPLIT` (lane-sub8x4 r2 -- - /// the second lifted refusal's own witness; `[0]`/`[1]` count those too, - /// so only this cell separates the split arm from the HORZ/VERT one). - pub(super) static SUB8_INTRA_RECT_HITS: std::cell::Cell<[usize; 5]> = const { std::cell::Cell::new([0; 5]) }; -} - -/// Current value of [`SUB8_INTRA_RECT_HITS`]: `(8x4, 4x8, chroma-reference, -/// mixed groups, split 4x4 leaves)`. -pub fn sub8_intra_rect_hits() -> (usize, usize, usize, usize, usize) { - SUB8_INTRA_RECT_HITS.with(|c| { - let h = c.get(); - (h[0], h[1], h[2], h[3], h[4]) - }) -} - -/// Current value of [`SUB8_INTER_RECT_HITS`]: `(8x4 groups, 4x8 groups)`. -pub fn sub8_inter_rect_hits() -> (usize, usize) { - SUB8_INTER_RECT_HITS.with(|c| { - let h = c.get(); - (h[0], h[1]) - }) -} - -// lane-cdef r1: (a) how many 8x8 CDEF units `apply_cdef` EXCLUDED because all -// four of their mi cells are `skip_txfm` (libaom `cdef.c:29-38` -// `is_8x8_block_skip` / `av1_cdef_compute_sb_list`'s dlist test), and (b) how -// many 8x8 inter leaves (`decode_inter_block8`) wrote that skip band at all. -// (b) was 0 for every stream before this round -- the leaf path never touched -// the band, so an all-skip 8x8 group kept the PREVIOUS frame's flags and got -// filtered where libaom skips it. A gate asserts both are non-zero. -thread_local! { - pub(super) static INTER8_SKIP_BAND_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - // lane-cdefstrip r1: (d) skip RECTANGULAR blocks (every strip arm: 32x8, - // 8x32, 16x8, 32x16, 64x16, AB/1:4 pieces...) that wrote the CDEF skip - // band, and (e) 8x8 CDEF units whose four mi cells do NOT agree on skip -- - // the shape libaom's `is_8x8_block_skip` (`cdef.c:29-38`) exists for: an - // 8-tall strip pair where only one half is skip must still be FILTERED. - pub(super) static RECT_SKIP_BAND_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of `RECT_SKIP_BAND_HITS`. -pub fn rect_skip_band_hits() -> usize { - RECT_SKIP_BAND_HITS.with(|c| c.get()) -} - -/// Current value of `INTER8_SKIP_BAND_HITS`. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn inter8_skip_band_hits() -> usize { - INTER8_SKIP_BAND_HITS.with(|c| c.get()) -} - -/// Current value of [`SUB8_SPLIT_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn sub8_split_hits() -> usize { - SUB8_SPLIT_HITS.with(|c| c.get()) -} - -/// Current value of [`SUB8_INTER_SPLIT_HITS`]. -pub fn sub8_inter_split_hits() -> usize { - SUB8_INTER_SPLIT_HITS.with(|c| c.get()) -} - -// lane-t900 r7: sub-8x8 inter groups whose one chroma unit inherits a -// `tx_type` DIFFERENT from the group's FIRST sub-block -- the only shape that -// tells the two rules apart (`av1_get_tx_type` indexes `xd->tx_type_map`, -// which `set_mi_offsets` re-points to the CHROMA-REFERENCE sub-block, so the -// first sub-block's type is never the one). Reading it off sub-block 0 -// inverted one 4x4 chroma unit on the wrong basis with the entropy stream -// perfectly in sync (no chroma `tx_type` symbol is coded), so a gate can only -// see this rule through this counter. -thread_local! { - pub(super) static SUB8_CHROMA_TX_FROM_REF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of `SUB8_CHROMA_TX_FROM_REF_HITS`. -pub fn sub8_chroma_tx_from_ref_hits() -> usize { - SUB8_CHROMA_TX_FROM_REF_HITS.with(|c| c.get()) -} - -// How many 4x8 / 8x4 leaves (lane-tx4x8's `PARTITION_VERT`/`PARTITION_HORZ` -// of an 8x8 block) this thread's decode reconstructed with REAL coefficients -// -- a skipped leaf exercises the prediction and the mi bookkeeping but never -// the rect transform, the 32-position `eob_pt` or the rect scan, so the gate -// asserts on these two rather than a plain leaf count. -thread_local! { - pub(super) static TX4X8_CODED_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(super) static TX8X4_CODED_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// Sub-8x8 rect leaves whose `tx_depth` symbol resolved to 1 -- the leaf's - /// two 4x4 transform units, predicted one after the other. A separate - /// counter from [`TX_DEPTH_HITS`] (which every square path also bumps) so - /// the gate can prove THIS path fired. - pub(super) static RECT8_SPLIT_TX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// 16x8/8x16 intra strips whose prediction actually read past the block's - /// own width (above-right) or height (below-left) -- the samples - /// `Reach::of_rect` decides on, and the only ones a wrong `has_tr_*`/ - /// `has_bl_*` table row can corrupt (lane-tx4x8 r3). - pub(super) static RECT_STRIP_REACH_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// Every 16x8/8x16 intra strip predicted, reaching or not -- the - /// denominator [`RECT_STRIP_REACH_HITS`] is a fraction of. - pub(super) static RECT_STRIP_PRED_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// Current value of [`RECT8_SPLIT_TX_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect8_split_tx_hits() -> usize { - RECT8_SPLIT_TX_HITS.with(|c| c.get()) -} - -/// Current value of [`RECT_STRIP_PRED_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_strip_pred_hits() -> usize { - RECT_STRIP_PRED_HITS.with(|c| c.get()) -} - -/// Current value of [`RECT_STRIP_REACH_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn rect_strip_reach_hits() -> usize { - RECT_STRIP_REACH_HITS.with(|c| c.get()) -} - -/// Current value of [`TX4X8_CODED_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn tx4x8_coded_hits() -> usize { - TX4X8_CODED_HITS.with(|c| c.get()) -} - -/// Current value of [`TX8X4_CODED_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn tx8x4_coded_hits() -> usize { - TX8X4_CODED_HITS.with(|c| c.get()) -} - -// How many CHROMA coefficient blocks read their `eob_pt` from the class-1 -// (`TX_CLASS_HORIZ`/`VERT`) row, across every call on the current thread. -// Chroma never codes a `tx_type` symbol -- it inherits the colocated luma -// type verbatim (`av1_get_tx_type`, `blockd.h:1291`) -- so this fires only on -// an inter leaf whose luma picked a 1D type, the path lane-eobc1 wired -// (`eob_pt_{16,64,128,256}_chroma_class1`). -thread_local! { - pub(super) static CHROMA_EOB_CLASS1_HITS: std::cell::Cell = - const { std::cell::Cell::new(0) }; -} - -/// Current value of [`CHROMA_EOB_CLASS1_HITS`]. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn chroma_eob_class1_hits() -> usize { - CHROMA_EOB_CLASS1_HITS.with(|c| c.get()) -} - -/// Enabled by `EC_AV1_PLANE_SENTINEL` (there is no separate flag for it): print -/// an EXACT census of the samples the tile walk never wrote -- with it, every -/// plane still holding [`plane_poison`] at this point is a sample no block -/// reconstructed, and no legal sample can equal the poison (reconstruction -/// clamps to `(1 << bit_depth) - 1`, at most 4095). -/// -/// Coverage, stated as the code has it: this census runs at TWO of the four -/// places [`apply_deblock`] is entered from -- the key-frame path and the -/// non-pipelined inter path, both immediately before that frame's deblock. The -/// two it does NOT cover are the encoder's filter search ([`replay_filters`], -/// which runs the filters over a CAPTURED copy, not a live decode) and the -/// pipelined inter branch, where deblock has already run band by band inside -/// `par` by the time this tail is reached. A zero count therefore means "no hole -/// on the paths that reach this call", not "no hole on any path". It is EXACT -/// over the extent it scans -- the scan itself reads every sample of that -/// extent, unlike the older [`dump_stage`] pair, which truncates to `as u8`. -/// -/// This is the shipped form of the four-line temporary scan the -/// `lane/av1422seed` census used: it replaces a wrong-sample diff (which says -/// where the OUTPUT is wrong, not whether the block was written at all) with a -/// direct count plus the coordinates of every hole, grouped into per-row -/// spans so a large hole stays readable. -/// -/// It scans TWO regions per plane, because they answer different questions and -/// the earlier revision only scanned one of them: -/// * the TRUE EXTENT -- each plane over its own `true_width` x `true_height`, -/// PER AXIS (`true_width.min(p.width)`), so a 4:2:2 frame's chroma is scanned -/// at its own `fw/2 x fh` shape rather than the 4:2:0 `div_ceil(2)` crop the -/// older [`dump_stage16`] used. A hole here can reach the caller, and it is -/// the region lane/av1unwritten's 224 samples sat in. -/// * the PADDED TAIL -- everything outside that extent, out to the block-aligned -/// coding surface -- counted separately into [`PAD_UNWRITTEN_SAMPLES`]. The -/// earlier revision's doc comment asserted "past that is the padded coding -/// surface's invented tail, which no decoder ever reads". That assertion is -/// exactly what a tail that is never written and never read looks like, so it -/// was self-certifying; the tail is now scanned and counted like any other -/// region. `EC_AV1_PLANE_ALLOC=padzero`/`extzero` attribute a read to one -/// side or the other (see [`fresh_plane`]). -pub(super) fn census_unwritten(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { - if !plane_sentinel_on() { - return; - } - let poison = plane_poison(); - let idx = PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst); - for (name, p) in [("Y", y), ("U", u), ("V", v)] { - let (w, h) = (p.true_width.min(p.width), p.true_height.min(p.height)); - let mut total = 0usize; - let mut spans: Vec<(usize, usize, usize)> = Vec::new(); - for row in 0..h { - let mut run: Option<(usize, usize)> = None; - for col in 0..w { - if p.data[row * p.width + col] == poison { - total += 1; - run = Some(match run { - None => (col, col), - Some((a, _)) => (a, col), - }); - } - if run.is_some() && (col + 1 == w || p.data[row * p.width + col + 1] != poison) { - let (a, b) = run.take().expect("a run is open here"); - spans.push((row, a, b)); - } - } - } - // The padded tail: columns `w..width` on rows `0..h`, plus every column - // on rows `h..height`. - let mut pad_total = 0usize; - let mut pad_scanned = 0usize; - for row in 0..p.height { - let (from, to) = if row < h { (w, p.width) } else { (0, p.width) }; - if from >= to { - continue; - } - pad_scanned += to - from; - pad_total += p.data[row * p.width + from..row * p.width + to] - .iter() - .filter(|&&s| s == poison) - .count(); - } - UNWRITTEN_SAMPLES.fetch_add(total, std::sync::atomic::Ordering::SeqCst); - CENSUS_SCANNED.fetch_add(w * h, std::sync::atomic::Ordering::SeqCst); - PAD_UNWRITTEN_SAMPLES.fetch_add(pad_total, std::sync::atomic::Ordering::SeqCst); - PAD_CENSUS_SCANNED.fetch_add(pad_scanned, std::sync::atomic::Ordering::SeqCst); - eprintln!( - "SENTINEL_CENSUS idx={idx} plane={name} surface={}x{} extent={w}x{h} \ - pad_scanned={pad_scanned} unwritten={total} pad_unwritten={pad_total}", - p.width, p.height, - ); - if total == 0 { - continue; - } - let body: Vec = spans - .iter() - .map(|&(r, a, b)| format!("y{r} x{a}..={b}")) - .collect(); - eprintln!( - "SENTINEL_CENSUS idx={idx} plane={name} surface={}x{} extent={w}x{h} \ - unwritten={total} spans={}: {}", - p.width, - p.height, - spans.len(), - body.join(" ") - ); - } -} - -/// Samples [`census_unwritten`] has looked at since the last -/// [`take_census_scanned`]. A gate that only asserts -/// [`take_unwritten_samples`] == 0 passes on a decode that never scanned -/// anything, so it reads THIS too: a census that scanned nothing has proved -/// nothing. -pub(super) static CENSUS_SCANNED: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); - -/// Reads and clears [`CENSUS_SCANNED`]; see [`take_unwritten_samples`] for the -/// pairing. -pub fn take_census_scanned() -> usize { - CENSUS_SCANNED.swap(0, std::sync::atomic::Ordering::SeqCst) -} - -/// Samples [`census_unwritten`] scanned in the padded tail, paired with -/// [`PAD_UNWRITTEN_SAMPLES`] for the same reason as [`CENSUS_SCANNED`]. -pub(super) static PAD_CENSUS_SCANNED: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); - -/// Reads and clears [`PAD_CENSUS_SCANNED`]. -pub fn take_pad_census_scanned() -> usize { - PAD_CENSUS_SCANNED.swap(0, std::sync::atomic::Ordering::SeqCst) -} - -/// Samples [`census_unwritten_final`] has looked at since the last -/// [`take_final_census_scanned`]. A gate that only asserts -/// [`take_final_unwritten_samples`] == 0 passes on a build whose census call was -/// deleted, so it reads THIS too -- the same pairing -/// [`CENSUS_SCANNED`] documents for the pre-deblock census. -pub(super) static FINAL_CENSUS_SCANNED: std::sync::atomic::AtomicUsize = - std::sync::atomic::AtomicUsize::new(0); - -/// Reads and clears [`FINAL_CENSUS_SCANNED`]; the pairing is the reason it -/// exists, exactly as for [`take_census_scanned`]. -pub fn take_final_census_scanned() -> usize { - FINAL_CENSUS_SCANNED.swap(0, std::sync::atomic::Ordering::SeqCst) -} - -/// lane-unwritten-dep: the census at the pipeline's last point. Counts, over each -/// plane, how many samples still hold [`PLANE_SENTINEL`] once every filter has -/// run, and records how many samples it LOOKED at in [`FINAL_CENSUS_SCANNED`]. -/// -/// SCOPE, which lane-av1graincensus did not change but had to be true about: -/// this runs BEFORE `apply_grain`, over the PRE-grain planes. It does NOT and -/// never did measure the grained picture the caller receives -- that is -/// [`census_unwritten_grained`], a separate counter over a separate buffer. -/// -/// Gated on [`plane_sentinel_on`] -- the SAME predicate as [`fresh_plane`] and as -/// the pre-deblock [`census_unwritten`]: the env flag OR the thread-local -/// [`set_plane_sentinel`] override. An earlier revision gated this on the raw env -/// var alone, which made the census silently inert for any in-process test using -/// the thread-local switch that the rest of the crate honours. The fill and both -/// censuses must agree on when they are live, or a "0" means nothing. -pub(crate) fn census_unwritten_final(y: &[u16], u: &[u16], v: &[u16]) { - let Some((scanned, total)) = census_sentinels(y, u, v) else { - return; - }; - FINAL_CENSUS_SCANNED.fetch_add(scanned, std::sync::atomic::Ordering::SeqCst); - FINAL_UNWRITTEN_SAMPLES.fetch_add(total, std::sync::atomic::Ordering::SeqCst); -} - -/// The `(scanned, unwritten)` pair both output-point censuses accumulate, or -/// `None` when the sentinel fill is not live. -/// -/// Shared so the two censuses cannot drift into disagreeing about what counts -/// as unwritten -- the failure this crate's other paired counters exist to -/// prevent. `None` (rather than `(0, 0)`) is what keeps a caller from -/// publishing a meaningless zero when the fill was off. -fn census_sentinels(y: &[u16], u: &[u16], v: &[u16]) -> Option<(usize, usize)> { - if !plane_sentinel_on() { - return None; - } - // Both callers pass planes cropped to the true extent (no padding past it - // reaches either point), so a flat count over each plane IS the - // true-extent count. - let (scanned, total): (usize, usize) = [y, u, v] - .iter() - .map(|p| (p.len(), p.iter().filter(|&&s| s == plane_poison()).count())) - .fold((0, 0), |(a, b), (c, d)| (a + c, b + d)); - Some((scanned, total)) -} - -/// The scanned half of the pairing for [`GRAINED_UNWRITTEN_SAMPLES`]. A gate -/// asserting only `== 0` passes on a build whose census call was deleted. -pub(super) static GRAINED_CENSUS_SCANNED: std::sync::atomic::AtomicUsize = - std::sync::atomic::AtomicUsize::new(0); - -/// Reads and clears [`GRAINED_CENSUS_SCANNED`]; the pairing is the reason it -/// exists, exactly as for [`take_final_census_scanned`]. -pub fn take_grained_census_scanned() -> usize { - GRAINED_CENSUS_SCANNED.swap(0, std::sync::atomic::Ordering::SeqCst) -} - -/// lane-av1graincensus: the SECOND output-point census -- the one -/// [`census_unwritten_final`] structurally cannot be. -/// -/// # WHY IT EXISTS -/// -/// `census_unwritten_final` runs at `stream.rs`'s `EC_AV1_FINAL_DUMP` site, which -/// is BEFORE `apply_grain`. Every filter (deblock/CDEF/LR/superres) writes in -/// place into the same buffer that census scanned, so those stages cannot open a -/// hole outside its extent. `apply_grain` is the ONE stage after it that -/// allocates a fresh picture -- `uninit_plane`, `Vec::with_capacity` + -/// `set_len`, no fill -- and whose soundness rests on a band row partition -/// rather than on the type system. Its destination therefore reaches the caller -/// having never been looked at by any census, and `lanes/unwritten-dep.report.md` -/// §6/§8 explicitly declines to claim otherwise. -/// -/// # WHAT IT IS WORTH ONLY IF THE FILL IS LIVE -/// -/// Counting `== plane_poison()` over an uninitialised buffer is a census that -/// can only ever report ~0: garbage is arbitrary, so a hole survives with -/// probability ~1/65536 rather than always. `uninit_plane` therefore fills with -/// the poison when [`plane_sentinel_on`] -- under the SAME predicate -/// [`fresh_plane`] honours -- so "the band copy wrote every sample" becomes a -/// measurement instead of an assumption. With the sentinel off (every shipped -/// build) nothing here runs and `uninit_plane` keeps its corner-cut. -pub(crate) fn census_unwritten_grained(y: &[u16], u: &[u16], v: &[u16]) { - let Some((scanned, total)) = census_sentinels(y, u, v) else { - return; - }; - GRAINED_CENSUS_SCANNED.fetch_add(scanned, std::sync::atomic::Ordering::SeqCst); - GRAINED_UNWRITTEN_SAMPLES.fetch_add(total, std::sync::atomic::Ordering::SeqCst); -} - -thread_local! { - /// lane-sb128c r8: INTRA (key-frame) 128x64 blocks decoded at the 128 - /// root's HORZ arm, and 64x128 ones at its VERT arm. - pub(crate) static INTRA_SB128_HORZ_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(crate) static INTRA_SB128_VERT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// Those blocks by resolved intra `tx_depth` (0 = TX_64X64 units, - /// 1 = TX_32X32, 2 = TX_16X16) -- proof the depth symbol is really read. - pub(crate) static INTRA_SB128_DEPTH_HITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; - /// lane-inter128intra r1: the same shapes decoded on the INTER block path - /// (an intra-coded PARTITION_HORZ/VERT half of a 128 superblock inside an - /// inter frame) -- (128x64, 64x128). - pub(crate) static INTRA128_IN_INTER_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; - /// lane-t900 r17: skipped INTER blocks whose `read_block_tx_size` still - /// handed back var-tx leaves, so the per-transform-unit luma publication - /// loop never ran and the block has to clear its own luma coefficient - /// contexts (libaom `av1_reset_entropy_context`). Every 128 root under - /// `TX_MODE_LARGEST` is one; the counter is what keeps that reset's gate - /// non-vacuous. - pub(crate) static SKIP_VARTX_LUMA_RESET_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-lossless128: an intra 128-axis (BLOCK_128X64/64X128) block decoded - /// on a LOSSLESS frame, where every plane is coded as TX_4X4 units (the - /// frame's `tx_mode` is forced `ONLY_4X4`). Keeps the gate that owns this - /// shape non-vacuous -- a stream that never codes one reads 0. - pub(crate) static INTRA128_LOSSLESS_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1-128rectspan: chroma transform units of a 128-root HORZ/VERT - /// intra block re-stamped by the end-of-block replay - /// (`record_split_luma_rect` clobbers the per-unit contexts the chroma - /// walk published, so every unit replays its own state after it). A - /// non-skip 128x64/64x128 block codes `nch_x * cn * 2 + nch_y * cn_h * 2` - /// of them, so this reads 0 on any stream that never codes one -- the - /// non-vacuity anchor for the replay's own gate. - pub(crate) static SB128RECT_CHROMA_REPLAY_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// ... and the number of non-skip 128-root rect BLOCKS whose two LUMA-MI - /// spans differ (`luma_span = chroma_tx << ss_x` vs - /// `luma_span_h = chroma_tx << ss_y`). lane-av1422lift: the doc here used - /// to read "Zero on every stream this decoder admits ... 4:2:2 ... is - /// refused by name at the sequence header", and that was TRUE. Admitting - /// 4:2:2 genuinely made this counter able to fire, and it does fire: - /// measured, `422_intrabc_sb128_strip.obu` and - /// `422_intrabc_sb128_strip_notxsearch.obu` each read - /// `replay = 72, mismatch = 9`; the other 19 committed 4:2:2 cells read 0. - /// - /// lane-av1422mismatch9: the predicate is the span DIFFERENCE, which at - /// ss (1, 0) is true BY CONSTRUCTION for every 128-root rect block -- so - /// this is a shape test ("a 4:2:2-shaped block replayed"), NOT a - /// divergence test, and it does not witness the lane-av1-128rectspan - /// defect it was named for (that defect passed `luma_span` to both axes; - /// the source-scan arm in - /// `the_422_block_128rect_chroma_chunk_gather_stays_per_axis` is what - /// pins the per-axis spelling). It is not a pixel-miss signature either: - /// the replay re-stamps with the same per-axis pair the in-loop walk - /// stamped with, and `record_mi_chroma` writes only the `left`/`above` - /// context arrays -- zero pixel samples. Both pins are byte-exact against - /// ffmpeg (`the_pinned_422_intrabc_sb128_strip_witnesses_decode_pixel_ - /// exact`, all five frames, every plane). - /// - /// **Nothing asserts zero here, and nothing should**: a zero assert would - /// red on a provably correct cell. The measured NINE is asserted instead, - /// in `the_422_block_128rect_chroma_chunk_gather_stays_per_axis` (with - /// this reasoning in its message), so a change in the count is a red gate - /// rather than a silent drift. - /// - /// The pair's other reader is `sb128rect_chroma_replay_hits` on a 4:4:4 - /// stream, where the unit's luma width and height are equal so the - /// mismatch half is structurally zero -- a zero that is a statement about - /// that stream, not about the format. - pub(crate) static SB128RECT_REPLAY_SPAN_MISMATCH_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// [`SKIP_VARTX_LUMA_RESET_HITS`], for a gate's own before/after delta. -pub fn skip_vartx_luma_reset_hits() -> usize { - SKIP_VARTX_LUMA_RESET_HITS.with(std::cell::Cell::get) -} - -/// [`INTRA128_LOSSLESS_HITS`], for a gate's own before/after delta. -pub(crate) fn intra128_lossless_hits() -> usize { - INTRA128_LOSSLESS_HITS.with(std::cell::Cell::get) -} - -/// [`INTRA128_IN_INTER_HITS`], for a gate's own before/after delta. -pub(crate) fn intra128_in_inter_hits() -> [usize; 2] { - INTRA128_IN_INTER_HITS.with(std::cell::Cell::get) -} - -/// [`INTRA_SB128_HORZ_HITS`] / [`INTRA_SB128_VERT_HITS`] / -/// [`INTRA_SB128_DEPTH_HITS`], for a gate's own before/after delta. -pub(crate) fn intra_sb128_hits() -> (usize, usize, [usize; 3]) { - ( - INTRA_SB128_HORZ_HITS.with(std::cell::Cell::get), - INTRA_SB128_VERT_HITS.with(std::cell::Cell::get), - INTRA_SB128_DEPTH_HITS.with(std::cell::Cell::get), - ) -} - -/// [`SB128RECT_CHROMA_REPLAY_HITS`] (chroma units re-stamped by -/// `decode_block_128rect`'s end-of-block replay) and -/// [`SB128RECT_REPLAY_SPAN_MISMATCH_HITS`] (replays whose stamped height was -/// not the unit's own), for a gate's own before/after delta. -pub(crate) fn sb128rect_chroma_replay_hits() -> (usize, usize) { - ( - SB128RECT_CHROMA_REPLAY_HITS.with(std::cell::Cell::get), - SB128RECT_REPLAY_SPAN_MISMATCH_HITS.with(std::cell::Cell::get), - ) -} - -/// Records one block's shape. The table is ordered by measured frequency over -/// the three witnesses the census gate decodes, so the common square shapes -/// leave the scan on their first comparison. -pub(super) fn census_inter_block_shape(side: usize, w: usize, h: usize) { - let bit = match INTER_BLOCK_SHAPES.iter().position(|&s| s == (side, w, h)) { - Some(i) => 1u32 << i, - None => INTER_BLOCK_SHAPE_UNLISTED, - }; - let seen = inter_block_shape_mask(); - if seen & bit == 0 { - INTER_BLOCK_SHAPE_MASK.with(|c| c.set(seen | bit)); - } -} - -/// lane-cdefstrip r1 instrument, run for every frame BEFORE either of -/// [`apply_cdef`]'s early returns. -pub(super) fn cdef_scan_counters(skip_grid: &Neighbours) { - let _ = skip_grid; - hit_do! { - let mut r = 0usize; - while r < skip_grid.mi_rows { - let mut c = 0usize; - while c < skip_grid.mi_cols { - if (0..2).any(|rr| { - (0..2).any(|cc| { - !skip_grid - .blk_grid - .get((r + rr) * skip_grid.skip_grid_cols_mi + (c + cc)) - .is_none_or(|x| x.written) - }) - }) { - hit!(CDEF_UNWRITTEN_SKIP_UNITS); - if crate::envflags::env_flag!("EC_AV1_DEBUG_CDEF_BAND") { - eprintln!("cdef band unwritten at mi ({r},{c}) px ({},{})", r * 4, c * 4); - } - } - let cell = |rr: usize, cc: usize| { - skip_grid - .blk_grid - .get((r + rr) * skip_grid.skip_grid_cols_mi + (c + cc)) - .is_some_and(|x| x.skip) - }; - let first = cell(0, 0); - if (0..2).any(|rr| (0..2).any(|cc| cell(rr, cc) != first)) { - hit!(CDEF_MIXED_SKIP_UNITS); - } - c += 2; - } - r += 2; - } - } -} - -// lane-sb128 r2: the 128x128 superblock root, shared by the key-frame and -// the inter tile loop. Its loop-restoration units are read once for the whole -// 128x128 (spec 5.11.57 is called with the superblock's own size), then one -// partition symbol off the `BLOCK_128X128` CDF (8 symbols, no HORZ_4/VERT_4) -// decides the root -- only SPLIT recurses into the four 64x64 quadrants this -// decoder codes, the other seven arms refuse by name. -thread_local! { - /// How many 128x128 superblock roots resolved to `PARTITION_NONE` -- one - /// whole 128x128 block (lane-sb128b r1's gate counter). - pub(crate) static PART128_NONE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// 128 roots that resolved to PARTITION_HORZ (two 128x64 pieces, or one - /// when the bottom half is out of frame) -- lane-sb128c r7. - pub(crate) static PART128_HORZ_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// 128 roots that resolved to PARTITION_VERT (two 64x128 pieces). - pub(crate) static PART128_VERT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// Of those, the ones decided by the GATHERED bit at a frame edge -- the - /// only shape a 1080p (mi_rows = 270) stream reaches. - pub(crate) static PART128_EDGE_HORZ_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - pub(crate) static PART128_EDGE_VERT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-sb128c r9: 128 roots that resolved to one of the four AB shapes, - /// in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B` order. - pub(crate) static PART128_AB_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; -} - -/// [`PART128_AB_HITS`], for a gate's own before/after delta. -pub(crate) fn part128_ab_hits() -> [usize; 4] { - PART128_AB_HITS.with(std::cell::Cell::get) -} - -/// [`PART128_NONE_HITS`], for a gate's own before/after delta. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn part128_none_hits() -> usize { - PART128_NONE_HITS.with(std::cell::Cell::get) -} - -/// [`PART128_HORZ_HITS`], for a gate's own before/after delta. -#[allow(dead_code)] // gate counter accessor with no reader yet; the counter itself is live -pub(crate) fn part128_horz_hits() -> usize { - PART128_HORZ_HITS.with(std::cell::Cell::get) -} - -/// [`PART128_VERT_HITS`], for a gate's own before/after delta. -#[allow(dead_code)] // gate counter accessor with no reader yet; the counter itself is live -pub(crate) fn part128_vert_hits() -> usize { - PART128_VERT_HITS.with(std::cell::Cell::get) -} - -/// [`PART128_EDGE_HORZ_HITS`] -- gathered-bit HORZ at the bottom frame edge. -pub(crate) fn part128_edge_horz_hits() -> usize { - PART128_EDGE_HORZ_HITS.with(std::cell::Cell::get) -} - -/// [`PART128_EDGE_VERT_HITS`] -- gathered-bit VERT at the right frame edge. -pub(crate) fn part128_edge_vert_hits() -> usize { - PART128_EDGE_VERT_HITS.with(std::cell::Cell::get) -} - -thread_local! { - /// How many CHROMA transform units were coded inside a block whose uv - /// plane block is more than one unit (lane-sb128b r2 -- only a 128x128 - /// block, four per plane). - pub(crate) static CHROMA_SPLIT_TX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -thread_local! { - /// lane-av1h5: how many blocks had their leaf walk actually PERMUTED into - /// libaom's chunk-major order by [`mu_chunk_order`] -- a block above 64 - /// whose sort was not a no-op. Deliberately not "took the order": a - /// no-op ordering change must read 0 so a gate cannot look armed. - pub(crate) static MU_CHUNK_ORDER_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; - /// lane-av1txctxband2: SQUARE lossless blocks on an INTER frame whose - /// `set_txfm_ctxs` publish CHANGED at least one above-band cell it covers - /// (the cell did not already hold the published size), so a later - /// `get_tx_size_context` / `txfm_partition_context` reader in the same - /// tile column reads a value this publish produced. Zero on an intra-only - /// frame (where `fill_lf_grid_rect_inner` publishes the same 4x4 value at - /// the same footprint). - /// - /// CORRECTED 2026-09-30 (refutation pass `lanes/refute-av1txctxband2`): - /// this doc previously claimed the hit meant "overwrote a size some - /// earlier block left" and that a wholly-lossless all-non-skip stream - /// leaves it at zero. MEASURED FALSE -- `420_lossless_tallinter_8x16.obu` - /// fires **48**, all of them first touches of a column still at - /// `TXFM_CTX_INIT`; `420_lossless_arf_1to4_320x240_5f.obu` fires 320, 53 of - /// them first touches. Of the pin's 944, **183 are first-touch**. The - /// predicate tests "the cell did not already hold this value", which is - /// the decision that matters (no reader, no intra-only frame, no unchanged - /// column still reads 0), but it is NOT the strictly narrower causal claim - /// the old text made. - pub(crate) static LOSSLESS_SQ_TXFM_BAND_OVERWRITE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// [`MU_CHUNK_ORDER_HITS`], for a gate's own before/after delta. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn mu_chunk_order_hits() -> usize { - MU_CHUNK_ORDER_HITS.with(std::cell::Cell::get) -} - -/// [`LOSSLESS_SQ_TXFM_BAND_OVERWRITE_HITS`] -- square lossless inter blocks -/// whose `set_txfm_ctxs` publish overwrote a size an earlier block of the -/// same frame had left in the above band, for a gate's own before/after -/// delta. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn lossless_sq_txfm_band_overwrite_hits() -> usize { - LOSSLESS_SQ_TXFM_BAND_OVERWRITE_HITS.with(std::cell::Cell::get) -} - -/// [`CHROMA_SPLIT_TX_HITS`], for a gate's own before/after delta. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn chroma_split_tx_hits() -> usize { - CHROMA_SPLIT_TX_HITS.with(std::cell::Cell::get) -} - -thread_local! { - /// How many INTRA leaves of an inter frame's 8x8 block ran the lossless - /// 4:4:4 chroma walk ([`read_intra_chroma_lossless`], lane-av1-llintra8) - /// -- one bump per leaf, four units per plane inside it. A gate proving - /// the arm must see this nonzero; CHROMA_SPLIT_TX_HITS alone cannot - /// attribute its bumps to THIS leaf. - pub(crate) static LLINTRA8_CHROMA_WALK_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// [`LLINTRA8_CHROMA_WALK_HITS`]: lossless 4:4:4 chroma walks through an -/// inter frame's 8x8 INTRA leaf. -pub fn llintra8_chroma_walk_hits() -> usize { - LLINTRA8_CHROMA_WALK_HITS.with(|c| c.get()) -} - -thread_local! { - /// lane-av1sub8rect444: how many of `decode_intra_sub8_leaf`'s 8x4/4x8 - /// INTRA leaves ran the lossless 4:4:4 per-unit chroma walk (two TX_4X4 - /// units per plane, plane-major) instead of one TX_8X4/TX_4X8 rect unit - /// -- the shape whose unit count AND skip ctx the rect read got wrong. - /// A gate proving the arm fired; CHROMA_SPLIT_TX_HITS cannot attribute - /// its bumps to THIS leaf. - pub(crate) static LLSUB8RECT444_CHROMA_WALK_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// [`LLSUB8RECT444_CHROMA_WALK_HITS`]: lossless 4:4:4 chroma walks through a -/// sub-8 8x4/4x8 INTRA leaf. -pub fn llsub8rect444_chroma_walk_hits() -> usize { - LLSUB8RECT444_CHROMA_WALK_HITS.with(|c| c.get()) -} - -thread_local! { - /// lane-av1444chr: how many chroma units resolved their `tx_type` from the - /// luma leaf covering their OWN quadrant instead of the block-level - /// (`first_tx_type`) one -- the route this lane corrected. - /// `CHROMA_SPLIT_TX_HITS` cannot attribute its bumps to it: every split - /// chroma unit bumps that one. - pub(crate) static CHROMA_QUAD_LEAF_TX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -thread_local! { - /// Of those, how many resolved a type that DIFFERS from the block-level one - /// -- the exact condition lane-av1444chr measured wrong: over a luma leaf - /// that coded nothing the map cell is `DCT_DCT` while the top-left leaf's - /// is `IDTX`. A gate proving the corrected route fired is NOT enough on - /// its own (a block whose four leaves agree changes zero pixels); this is - /// the number that says the route changed an answer. - pub(crate) static CHROMA_QUAD_LEAF_TX_DIFF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -thread_local! { - /// lane-av1f9singleland: the SINGLE-REFERENCE copy of - /// [`CHROMA_QUAD_LEAF_TX_HITS`], and the half of its - /// [`CHROMA_QUAD_LEAF_TX_DIFF_HITS`] that belongs to that arm. - /// - /// Why a separate pair rather than trusting the shared counters: the - /// shared ones are bumped from BOTH arms of the four-unit 4:4:4 chroma - /// arm, so a green witness on them says nothing about which arm produced - /// the hits. `decode_inter_block` has two textually parallel copies of - /// that arm -- the compound prediction arm (the `build` closure) and the - /// single-reference arm -- and a refactor can delete or revert either one - /// while the other keeps the shared total non-zero. Measured on the pinned - /// witness `fixtures/444_quad_leaf_tx_type.obu`: 96 units resolve through - /// the covering leaf, and 88 of them are the single-reference arm's, so - /// the shared counter is 92% single-reference and the compound arm alone - /// would be a 4-unit sample of the route it appears to witness. - pub(crate) static CHROMA_QUAD_LEAF_TX_SINGLEREF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -thread_local! { - /// Of [`CHROMA_QUAD_LEAF_TX_SINGLEREF_HITS`], how many resolved a type - /// that DIFFERS from the block-level one. This is the arm's own non-vacuity - /// bar: a route count alone stays green through a no-op resolve, because - /// on a block whose four luma leaves all agree the per-quadrant value and - /// the block-level one are the same answer. Mutating only the - /// single-reference arm's `Some(cu_tx_type)` back to `Some(luma_tx_type)` - /// turns the witness red with 777 bytes differing in decode-order frame 1. - pub(crate) static CHROMA_QUAD_LEAF_TX_SINGLEREF_DIFF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// [`CHROMA_QUAD_LEAF_TX_SINGLEREF_HITS`]: single-reference-arm chroma units -/// that took their type from the covering luma leaf. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn chroma_quad_leaf_tx_singleref_hits() -> usize { - CHROMA_QUAD_LEAF_TX_SINGLEREF_HITS.with(std::cell::Cell::get) -} - -/// [`CHROMA_QUAD_LEAF_TX_SINGLEREF_DIFF_HITS`]: of those, the units whose -/// covering leaf's type differs from the block-level one. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn chroma_quad_leaf_tx_singleref_diff_hits() -> usize { - CHROMA_QUAD_LEAF_TX_SINGLEREF_DIFF_HITS.with(std::cell::Cell::get) -} - -/// [`CHROMA_QUAD_LEAF_TX_HITS`]: chroma units that took their type from the -/// covering luma leaf. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn chroma_quad_leaf_tx_hits() -> usize { - CHROMA_QUAD_LEAF_TX_HITS.with(std::cell::Cell::get) -} - -/// [`CHROMA_QUAD_LEAF_TX_DIFF_HITS`]: chroma units whose covering leaf's type -/// differs from the block-level one. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn chroma_quad_leaf_tx_diff_hits() -> usize { - CHROMA_QUAD_LEAF_TX_DIFF_HITS.with(std::cell::Cell::get) -} - -thread_local! { - /// lane-av1chrtx: chroma units of a RECT inter block - /// ([`read_inter_rect_chroma`], the sibling of the 4:4:4 four-unit arms) - /// that resolved their `tx_type` from the luma leaf covering their OWN - /// quadrant instead of the block-level one. A SEPARATE counter from - /// [`CHROMA_QUAD_LEAF_TX_HITS`] on purpose: that one gates a 4:2:0 control - /// that must stay at exactly 0, and this route IS reachable at 4:2:0, so - /// sharing the counter would destroy that control's meaning. - pub(crate) static CHROMA_RECT_LEAF_TX_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -thread_local! { - /// Of those, how many resolved a type that DIFFERS from the block-level - /// one -- the condition that changes pixels. A route counter alone fires - /// on every multi-unit rect chroma read, including the blocks whose - /// leaves all agree (the exact shape a no-op fix looks green on). - pub(crate) static CHROMA_RECT_LEAF_TX_DIFF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; -} - -/// [`CHROMA_RECT_LEAF_TX_HITS`]: rect chroma units that took their type from -/// the covering luma leaf. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn chroma_rect_leaf_tx_hits() -> usize { - CHROMA_RECT_LEAF_TX_HITS.with(std::cell::Cell::get) -} - -/// [`CHROMA_RECT_LEAF_TX_DIFF_HITS`]: of those, the units whose covering -/// leaf's type differs from the block-level one. -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates -pub(crate) fn chroma_rect_leaf_tx_diff_hits() -> usize { - CHROMA_RECT_LEAF_TX_DIFF_HITS.with(std::cell::Cell::get) -} diff --git a/crates/ec-av1/src/decode/frame_tile.rs b/crates/ec-av1/src/decode/frame_tile.rs index 092539f1..8195b531 100644 --- a/crates/ec-av1/src/decode/frame_tile.rs +++ b/crates/ec-av1/src/decode/frame_tile.rs @@ -582,7 +582,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( mi_row1 as usize, mi_col1 as usize, ); - hit!(TILE_HITS); // lane-sb128 r2: at `sb_size == 128` the tile walks each 128x128 // superblock's four 64x64 quadrants in libaom `decode_partition` order @@ -985,9 +984,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( bh ); if horz { - hit!(INTER_SB128_HORZ_HITS); } else { - hit!(INTER_SB128_VERT_HITS); } } // 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( continue; } if sb128_none { - hit!(INTER_SB128_NONE_HITS); let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4); // lane-sb128c r3: `at128` is in SUB16 units like `sb_at`; // `decode_inter_block` takes MI. Unconverted it was (0,0) for @@ -1155,16 +1151,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( // see it. refuse_invalid_subsize((64, 64), part64, fctx)?; if part64 == PARTITION_NONE { - // lane-inter8 r1: the whole superblock as one 64x64 inter - // block. `SB`-sized syntax throughout (size_group 3, same as - // 32x32 -- `size_group_lookup[BLOCK_64X64] == 3`), luma - // coefficients through `TxbSet::Luma64` with the 32-point - // scan (TX_64X64 codes only its top-left corner, spec - // 5.11.40 -- `read_inter_plane` widens the corner back to - // 64x64 before the inverse transform), chroma as a plain - // 32x32 `TxbSet::Chroma32`. TX_64X64 carries no `tx_type` - // symbol at all, so the intra/inter luma sets coincide. - hit!(INTER_SB_NONE_HITS); decode_inter_block( &mut dec, &mut cdfs, @@ -1284,35 +1270,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( if !four && i == 0 && ((horz && !has_rows) || (!horz && !has_cols)) { bump_inter_edge_strip(if horz { 0 } else { 1 }); } - match (horz, four) { - (true, false) => hit!(INTER_SB_HORZ_HITS), - (false, false) => hit!(INTER_SB_VERT_HITS), - (true, true) => hit!(INTER_SB_HORZ4_HITS), - (false, true) => hit!(INTER_SB_VERT4_HITS), - } } continue; } if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part64) { - // lane-sbab r1: the four superblock-level AB arms on the - // INTER path -- two 32x32 inter squares plus one true - // 64x32/32x64 inter strip, in libaom `decode_partition`'s own - // order (decodeframe.c: HORZ_A = TL, TR, bottom strip; - // HORZ_B = top strip, BL, BR; VERT_A = TL, BL, right strip; - // VERT_B = left strip, TR, BR). Every piece is one this - // decoder already proves elsewhere: the 32x32 square is the - // `PARTITION_NONE`-under-SPLIT block below, the strip is the - // `PARTITION_HORZ`/`VERT` piece above (`inter_piece!`, which - // keeps `side = SB` for syntax/CDF and names its true - // footprint through `write_w`/`write_h`). The intra-frame - // twin of this arm is lane-part32 r4's `SB_AB_HITS` block. - hit_do! { - SB_AB_INTER_HITS.with(|c| { - let mut h = c.get(); - h[part64 - PARTITION_HORZ_A] += 1; - c.set(h); - }); - } // lane-part32 r5 / class visit-order-changes-availability: // only the two VERTICAL arms visit TL, BL, TR, BR, so only // they switch libaom's `has_tr`/`has_bl` tables. @@ -1749,9 +1710,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( // covers 16x8/8x16 since this round). let horz = part16 == PARTITION_HORZ; if horz { - hit!(INTER_LEAF16_HORZ_HITS); } else { - hit!(INTER_LEAF16_VERT_HITS); } let base_mi = sub16_to_mi(at16); let (ww, wh) = if horz { (16, 8) } else { (8, 16) }; @@ -2035,9 +1994,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( bh ); if horz { - hit!(INTER16_HORZ4_HITS); } else { - hit!(INTER16_VERT4_HITS); } } } else if part16 != PARTITION_SPLIT { @@ -2045,9 +2002,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4", )); } else { - if has_cols16 && has_rows16 { - hit!(INTER_SUB16_SPLIT_HITS); - } let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI); let leaf_positions: Vec<(u32, u32)> = (0..4) @@ -2066,7 +2020,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( .dims(rf) .is_some_and(|(w, _)| w != frame_width as usize) }) { - hit!(SCALED_LEAF8_HITS); } let mut prev_leaves: Vec<( (usize, usize), @@ -2281,19 +2234,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( } } PARTITION_HORZ_B => { - // lane-warp r5: PARTITION_HORZ_B = 32x32 top strip + - // 16x16 bottom-left + 16x16 bottom-right. aomenc - // carves static regions into it; the strip is - // decoded as a square 32x32 block: for a `skip` - // block the symbol stream is identical to the true - // 32x16 coding (no residual, no motion_mode/warp - // symbol), and the square stamps it leaves over the - // bottom half (neighbour arrays, skip/lf grids) are - // re-stamped by the C/D leaves right after. The - // mi-granular `left_side_mi` rows of a last-block-in- - // tile strip leak 32-vs-16 only until the per-tile - // `Neighbours::new` reset. - hit!(EXTENDED_PARTITION_HITS); let at32 = at; decode_inter_block( &mut dec, @@ -2453,13 +2393,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( } } PARTITION_HORZ => { - // lane-rect r2: two true 32x16 strips. Both read at - // `side=BLOCK` (CDF/size-class selection stays square, - // matching HORZ_B's accepted corner-cut) but bw4/bh4 - // (mvstack.rs, `motion_mode_eligible`) now derive from - // `write_w`/`write_h`'s true 32x16 footprint -- the - // pin's fix (r1's finding). - hit!(RECT_PARTITION_HITS); decode_inter_block( &mut dec, &mut cdfs, @@ -2566,9 +2499,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( } } PARTITION_VERT => { - // lane-rect r2: mirror of PARTITION_HORZ above with - // width/height swapped. - hit!(RECT_PARTITION_HITS); decode_inter_block( &mut dec, &mut cdfs, @@ -2675,10 +2605,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( } } PARTITION_HORZ_A => { - // lane-partab r1: two 16x16 squares on top + a true - // 32x16 strip below (libaom decode_partition - // PARTITION_HORZ_A: TL, TR, bottom strip). - hit!(PARTAB_HITS); decode_inter_block( &mut dec, &mut cdfs, @@ -2830,9 +2756,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( )?; } PARTITION_VERT_A => { - // lane-partab r1: mirror of PARTITION_HORZ_A with - // width/height swapped (TL, BL, right 16x32 strip). - hit!(PARTAB_HITS); let _vert_ab = crate::encode::Reach::vert_ab_partition(); decode_inter_block( &mut dec, @@ -2985,10 +2908,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( )?; } PARTITION_VERT_B => { - // lane-partab r1: true 16x32 strip on the left + two - // 16x16 squares on the right (libaom decode_partition - // PARTITION_VERT_B: left strip, TR, BR). - hit!(PARTAB_HITS); let _vert_ab = crate::encode::Reach::vert_ab_partition(); decode_inter_block( &mut dec, @@ -3177,9 +3096,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( bh ); if horz { - hit!(RECT4_32_HORZ_INTER_HITS); } else { - hit!(RECT4_32_VERT_INTER_HITS); } } } @@ -3237,7 +3154,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) ); } - census_unwritten(&y, &u, &v); // lane-av1fwd: the encoder scores ~25 filter candidates against this // same coded tile ([`FilterReplay`]). Capture the reconstruction here, // before either filter has touched it -- but only on the shape whose diff --git a/crates/ec-av1/src/decode/inter_block.rs b/crates/ec-av1/src/decode/inter_block.rs index d8cfd153..a4d83530 100644 --- a/crates/ec-av1/src/decode/inter_block.rs +++ b/crates/ec-av1/src/decode/inter_block.rs @@ -135,7 +135,6 @@ pub(super) fn decode_inter_block( // exactly what it read before. let (rmi, cmi) = at; let (px, py) = (at.1 * MI, at.0 * MI); - census_inter_block_shape(side, write_w, write_h); // lane-inter16ab r2: a 16x4 / 4x16 inter strip's chroma is the PAIR's // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd // strip (`is_chroma_reference`); every other block keeps its own. @@ -276,9 +275,6 @@ pub(super) fn decode_inter_block( dec.debug_bitpos() ); } - if skip_mode { - hit!(SKIP_MODE_HITS); - } let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; @@ -526,9 +522,6 @@ pub(super) fn decode_inter_block( // `AOMMIN(mi_size_wide, mi_size_high) < 2` before it looks at any // model, so a 4-px-sided block still reads its interp filter. let gm_nontrans = gm_nontrans_models && bw4.min(bh4) >= 2; - if gm_nontrans_models && !gm_nontrans { - hit!(GM_NONTRANS_SMALL_SIDE_HITS); - } // lane-defer8: both slots' pictures are resolved inside the // prediction closure; the parse only needs their SIZES. // lane-cwarp r1: `is_global_mv_block` (blockd.h:421-429) is @@ -553,10 +546,8 @@ pub(super) fn decode_inter_block( // engagement figure. if mi_row < mi_rows as usize / 2 { if is_globalmv { - TOP_HALF_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); } if is_global_mv0 || is_global_mv1 { - TOP_HALF_WARP_HITS.with(|c| c.set(c.get() + 1)); } } // libaom `av1_init_warp_params` + `allow_warp`'s @@ -595,7 +586,6 @@ pub(super) fn decode_inter_block( let warp0 = compound_warp(ref0, is_global_mv0).filter(|_| ref_unscaled(ref0)); let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1)); if warp0.is_some() || warp1.is_some() { - hit!(COMPOUND_WARP_HITS); // lane-av112bitw: the 12-bit refusal that stood here is // LIFTED with the compound-warp witness: the rotating- // mandelbrot 12-bit recipe refused exactly here pre-lift and @@ -714,16 +704,6 @@ pub(super) fn decode_inter_block( // verified vs independent C dump (wedge.rs). let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); let wedge_sign = dec.literal(1); - hit!(WEDGE_HITS); - if let Some(k) = rect_wedge_slot(write_w, write_h) { - hit_do! { - RECT_WEDGE_HITS.with(|c| { - let mut a = c.get(); - a[k] += 1; - c.set(a); - }); - } - } // lane-inter16ab r5: the codebook row is this block's TRUE // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for // h>w, hltw for h = if let Some(mask_type) = diffwtd_mask_type { diffwtd_mask_y = vec![0u8; side * side]; - hit!(DIFFWTD_HITS); mc::diffwtd_mask( &inter0_y, &inter1_y, @@ -1597,14 +1559,6 @@ pub(super) fn decode_inter_block( fctx, )? } else { - // lane-r14 r3: a 1:4 strip's `sub_tx_size_map` - // sub-transform is RECTANGULAR (TX_64X16 -> - // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is - // read with the rect coefficient machinery, at its - // own `txb_skip_ctx`/neighbour spans -- the unit is - // smaller than its block, so `get_txb_ctx_general`'s - // neighbour table applies, not the lone-TU 0. - vartx_rect_leaf_hit(tw, th); let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); let start = row * MI * side + col * MI; @@ -1852,7 +1806,6 @@ pub(super) fn decode_inter_block( plane_idx, &cu_grid, ); - hit!(CHROMA_SPLIT_TX_HITS); mu_chroma = true; // lane-av1muchunk422b: the allocation of this // mu-chunk walk, counted per TX_32X32 UNIT. @@ -1861,9 +1814,6 @@ pub(super) fn decode_inter_block( // bump: `MU_CHUNK_COMPOUND_UNITS` names site 2 // and the single-reference twin (site 5) stays // out of it. - if is_compound { - hit!(MU_CHUNK_COMPOUND_UNITS); - } let dst = mu_units( if plane_idx == 1 { &mut u_units @@ -2068,12 +2018,6 @@ pub(super) fn decode_inter_block( let cu_rel_mi = (cr * (cu_tx / MI), cc * (cu_tx / MI)); let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi) .unwrap_or(luma_tx_type); - if covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi).is_some() { - hit!(CHROMA_QUAD_LEAF_TX_HITS); - if cu_tx_type != luma_tx_type { - hit!(CHROMA_QUAD_LEAF_TX_DIFF_HITS); - } - } let cu_grid = read_inter_plane( dec, cdfs, @@ -2099,7 +2043,6 @@ pub(super) fn decode_inter_block( // this one's coefficients. neighbours .record_mi_chroma(cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid); - hit!(CHROMA_SPLIT_TX_HITS); // lane-av1-444 c8: the unit's levels must ALSO // land in the block grid -- the block-tail mu // re-stamp slices the per-unit states back out @@ -2245,8 +2188,6 @@ pub(super) fn decode_inter_block( tpl, ); let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; - if !not_new { - } let mut is_globalmv = false; // lane-interbis r1: which single-ref mode this block resolved to, // in the oracle's own numbering (NEARESTMV=13 .. NEWMV=16), for @@ -2281,8 +2222,6 @@ pub(super) fn decode_inter_block( ) } else { let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; - if !not_zero { - } is_globalmv = !not_zero; let mv = if !not_zero { // GLOBALMV: `gm_get_motion_vector` (spec 7.10.2.1), already @@ -2398,16 +2337,6 @@ pub(super) fn decode_inter_block( // NO sign symbol follows -- libaom fixes // INTERINTRA_WEDGE_SIGN 0 (blockd.h). let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); - hit!(WII_HITS); - if let Some(k) = rect_wedge_slot(write_w, write_h) { - hit_do! { - RECT_WII_HITS.with(|c| { - let mut a = c.get(); - a[k] += 1; - c.set(a); - }); - } - } // lane-inter16ab r5: true-footprint codebook row, // mask padded to stride `max(bw,bh) == side` -- see // the compound site's own comment. @@ -2418,7 +2347,6 @@ pub(super) fn decode_inter_block( side, )); } else { - hit!(INTERINTRA_HITS); } interintra_mode = Some(ii); // The inter-intra predictor reads this block's neighbours as already @@ -2556,12 +2484,6 @@ pub(super) fn decode_inter_block( ) >= 1; let warp_eligible = allow_warped_motion && !ref_is_scaled && !force_integer_mv && proj_ok; - if allow_warped_motion && proj_ok && ref_is_scaled { - hit!(SCALED_WARP_SUPPRESSED_HITS); - } - if allow_warped_motion && proj_ok && !ref_is_scaled && force_integer_mv { - hit!(FIMV_ALPHABET_HITS); - } if warp_eligible { crate::msac::SymbolDecoder::set_symr_cdf("motion_mode"); let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); @@ -2569,11 +2491,9 @@ pub(super) fn decode_inter_block( 0 => {} 1 => { obmc_selected = true; - hit!(OBMC_HITS); } _ => { warped_selected = true; - hit!(WARP_SELECTED_HITS); let mut samples = find_samples( grid, mi_row, @@ -2636,9 +2556,6 @@ pub(super) fn decode_inter_block( } } else { obmc_selected = dec.symbol(&mut cdfs.obmc[bsize_idx]) == 1; - if obmc_selected { - hit!(OBMC_HITS); - } } // lane-t900 r9: which ALPHABET this block read (3-symbol // motion_mode vs 2-symbol obmc) and the range after -- the @@ -2676,15 +2593,9 @@ pub(super) fn decode_inter_block( let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize]; if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { warp_params = crate::warp::global_warp_params(gm_ref.params); - if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine { - hit!(AFFINE_GM_HITS); - } // lane-av1gwarp12: the ROTZOOM sibling -- the only // >TRANSLATION model vanilla aomenc can emit for a single-ref // global-motion block (encoder search pinned to ROTZOOM). - if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Rotzoom { - hit!(ROTZOOM_GM_WARP_HITS); - } } // lane-av112bitw: a local `WARPED_CAUSAL` projection (set above) // or a global warp model both land here with `warp_params` set -- @@ -2810,15 +2721,6 @@ pub(super) fn decode_inter_block( // measured was the 16x4/4x16 strip's sub-8x8 chroma piece, // which this file used to SKIP under a scaled reference // (fixed in the same commit), not the warp fallback. - if warp_params.is_some() { - hit!(SCALED_WARP_FALLBACK_HITS); - } - if obmc_selected { - hit!(SCALED_OBMC_HITS); - } - if interintra_mode.is_some() { - hit!(SCALED_INTERINTRA_HITS); - } } // lane-inter16ab r2: `is_sub8x8_inter`'s neighbour walk reads the @@ -2835,7 +2737,6 @@ pub(super) fn decode_inter_block( { Some((horz, (prev_ref, prev_mv, prev_h, prev_v))) => { let prev_dims = ref_dims(prev_ref, refpix)?; - hit!(INTER16_SUB8_PIECE_HITS); Some(( horz, prev_ref, @@ -3075,9 +2976,6 @@ pub(super) fn decode_inter_block( // result, all planes (reconinter.c av1_build_interintra_predictor // plane loop). if let Some(ii) = interintra_mode { - if write_w != write_h { - hit!(INTERINTRA_RECT_HITS); - } interintra_blend( y, px, @@ -3344,7 +3242,6 @@ pub(super) fn decode_inter_block( // gate can prove it exercised this route (a 4:2:0 stream // of the same content reads 0). Some(_) if ss_x(fctx) == 0 => { - hit!(RECT4_INTER_OWN_CHROMA444_HITS); around } Some(s) if s.has_chroma => { @@ -3425,14 +3322,6 @@ pub(super) fn decode_inter_block( fctx, )? } else { - // lane-r14 r3: a 1:4 strip's `sub_tx_size_map` - // sub-transform is RECTANGULAR (TX_64X16 -> - // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is - // read with the rect coefficient machinery, at its - // own `txb_skip_ctx`/neighbour spans -- the unit is - // smaller than its block, so `get_txb_ctx_general`'s - // neighbour table applies, not the lone-TU 0. - vartx_rect_leaf_hit(tw, th); let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); let start = row * MI * side + col * MI; @@ -3666,7 +3555,6 @@ pub(super) fn decode_inter_block( plane_idx, &cu_grid, ); - hit!(CHROMA_SPLIT_TX_HITS); mu_chroma = true; // lane-av1muchunk422b: the allocation of this // mu-chunk walk, counted per TX_32X32 UNIT. @@ -3675,9 +3563,6 @@ pub(super) fn decode_inter_block( // bump: `MU_CHUNK_COMPOUND_UNITS` names site 2 // and the single-reference twin (site 5) stays // out of it. - if is_compound { - hit!(MU_CHUNK_COMPOUND_UNITS); - } let dst = mu_units( if plane_idx == 1 { &mut u_units @@ -3898,16 +3783,10 @@ pub(super) fn decode_inter_block( let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi) .unwrap_or(luma_tx_type); if covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi).is_some() { - hit!(CHROMA_QUAD_LEAF_TX_HITS); - hit!(CHROMA_QUAD_LEAF_TX_SINGLEREF_HITS); // lane-av1f9singleland: this arm's own // non-vacuity number -- the shared // DIFFERS counter below cannot say which // arm changed an answer. - if cu_tx_type != luma_tx_type { - hit!(CHROMA_QUAD_LEAF_TX_DIFF_HITS); - hit!(CHROMA_QUAD_LEAF_TX_SINGLEREF_DIFF_HITS); - } } let cu_grid = read_inter_plane( dec, @@ -3934,7 +3813,6 @@ pub(super) fn decode_inter_block( // this one's coefficients. neighbours .record_mi_chroma(cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid); - hit!(CHROMA_SPLIT_TX_HITS); // lane-av1-444 c8: the unit's levels must ALSO // land in the block grid -- the block-tail mu // re-stamp slices the per-unit states back out @@ -4242,7 +4120,6 @@ pub(super) fn decode_inter_block( palette_record.3, ); let saved_chroma_ctx = (!has_chroma).then(|| { - hit!(NON_CHROMA_REF_CTX_SKIP_HITS); let (w_mi, h_mi) = (write_w / MI, write_h / MI); let left: Vec<[Neighbour; 2]> = (0..h_mi) .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( // where aomdec reads 1, because the skipped 128x128 block at // mi(32,32) never cleared `left[32..48]`. if skip { - hit!(SKIP_VARTX_LUMA_RESET_HITS); neighbours.record_mi_luma_rect(at, write_w, write_h, &luma_grid); } // Plane 0 is already correct per transform unit @@ -4366,7 +4242,6 @@ pub(super) fn decode_inter_block( } } neighbours.record_uv_mode_mi(s.pair_mi.0, s.pair_mi.1, pw / MI, ph / MI, uv_predict_mode); - hit!(INTER16_CHROMA_PAIR_HITS); } // lane-av1-444 c8: each unit stamps its OWN span (32 << ss px at // TX_32X32, 8 px lossless) -- a 64x64 mu chunk at ss 0/0 holds four diff --git a/crates/ec-av1/src/decode/inter_block8.rs b/crates/ec-av1/src/decode/inter_block8.rs index 830431cd..805a6c8f 100644 --- a/crates/ec-av1/src/decode/inter_block8.rs +++ b/crates/ec-av1/src/decode/inter_block8.rs @@ -243,9 +243,6 @@ pub(super) fn decode_inter_block8( // leaf is always `BLOCK_8X8`, i.e. 2x2 mi. inter_segment_id(dec, cdfs, leaf_mi.0, leaf_mi.1, 2, 2, false, true, fctx); let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; - if skip_mode { - hit!(SKIP_MODE_HITS); - } let skip_ctx = usize::from(above_skip) + usize::from(left_skip); let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; @@ -454,7 +451,6 @@ pub(super) fn decode_inter_block8( // leaf's own comment. let wedge_index = dec.symbol(&mut cdfs.wedge_idx[3]); let wedge_sign = dec.literal(1); - hit!(WEDGE_HITS); wedge_mask = Some( crate::wedge::wedge_masks() .codebook(SIDE, SIDE) @@ -464,7 +460,6 @@ pub(super) fn decode_inter_block8( let mask_type = dec.literal(1); diffwtd_mask_type = Some(mask_type as u8); } - hit!(MASKED_COMPOUND_HITS); } // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): same // reference-slot defect as the 16x16 leaf's own mask above @@ -495,10 +490,6 @@ pub(super) fn decode_inter_block8( if idx == 1 { (8, 8, 1u8) } else { - // lane-av1distwtd: the 8x8 leaf's own - // distance-weighted arm, same counter as the - // 16x16+ site above. - hit!(DIST_WTD_COMP_HITS); let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign( order_hint_bits, order_hint, @@ -570,17 +561,10 @@ pub(super) fn decode_inter_block8( true, ); leaf_filter_syms = resolved_filter; - if interp_fixed.is_none() && !(gm_nontrans_c || skip_mode) { - hit!(COMPOUND8_FILTER_HITS); - } // lane-defer8: both slots' SIZES at parse, pictures in the closure. let scale0 = scale_of(ref_dims(ref0, refpix)?, frame_size); let scale1 = scale_of(ref_dims(ref1, refpix)?, frame_size); - if !scale0.is_unscaled() || !scale1.is_unscaled() { - hit!(SCALED_COMPOUND_HITS); - hit!(SCALED_BLOCK8_HITS); - } // lane-interp3 r2 (class twin-functions-drift): both slots // used to be stamped `false`, while [`decode_inter_block`]'s @@ -635,10 +619,6 @@ pub(super) fn decode_inter_block8( leaf_compound_warp(ref0, is_global_mv0_c).filter(|_| leaf_ref_unscaled(ref0)); let warp1_c = leaf_compound_warp(ref1, is_global_mv1_c).filter(|_| leaf_ref_unscaled(ref1)); - if warp0_c.is_some() || warp1_c.is_some() { - hit!(COMPOUND_WARP_HITS); - hit!(COMPOUND_WARP_HITS_8); - } grid.fill_rect( mi_row, mi_col, @@ -745,7 +725,6 @@ pub(super) fn decode_inter_block8( let mut diffwtd_mask_y; let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { diffwtd_mask_y = vec![0u8; SIDE * SIDE]; - hit!(DIFFWTD_HITS); mc::diffwtd_mask( &inter0_y, &inter1_y, @@ -1323,13 +1302,6 @@ pub(super) fn decode_inter_block8( neighbours.above[leaf_mi.1 + cell][0] = state; } } - // lane-cdef r1: ... and the CDEF skip band too. `apply_cdef`'s - // `is_8x8_block_skip` (libaom `cdef.c:29-38`) reads all four mi - // cells of the 8x8; this leaf wrote none of them, so a 64x64 - // whose bottom-right 16x16 is an all-skip 8x8-leaf group kept - // the PREVIOUS frame's flags and got filtered where libaom's - // dlist excludes it (3 luma samples on a 192x128 inter frame). - hit!(INTER8_SKIP_BAND_HITS); neighbours.fill_skip_grid(leaf_mi, 2, skip); // lane-sub8x4 r2: `split8` is this leaf's OWN var-tx split, so // the deblock grid must publish the TX_4X4 leaves' width the @@ -1418,8 +1390,6 @@ pub(super) fn decode_inter_block8( } let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; - if !not_new { - } let mut is_globalmv = false; let (mv, is_new_mv) = if !not_new { // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0): @@ -1450,14 +1420,8 @@ pub(super) fn decode_inter_block8( ) } else { let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; - if !not_zero { - } is_globalmv = !not_zero; let mv = if !not_zero { - // lane-gmaffine r1: GLOBALMV (spec 7.10.2.1) -- the same - // `gm_get_motion_vector` value the 16x16+ leaf reads out of - // its own `gm_table`, computed at this block's centre. - hit!(GLOBALMV_HITS_8); gm_table[(ref_frame - LAST_FRAME) as usize] } else { let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; @@ -1496,7 +1460,6 @@ pub(super) fn decode_inter_block8( // lane-wii r2: same adapting `wedge_index` symbol as the // 16/32 leaf, fixed sign 0 -- see that site's comment. let wedge_index = dec.symbol(&mut cdfs.wedge_idx[3]); - hit!(WII_HITS); wedge_mask = Some(( crate::wedge::wedge_masks() .codebook(SIDE, SIDE) @@ -1504,7 +1467,6 @@ pub(super) fn decode_inter_block8( SIDE, )); } else { - hit!(INTERINTRA_HITS); } interintra_mode = Some(ii); // The inter-intra predictor reads this block's neighbours as already @@ -1587,12 +1549,6 @@ pub(super) fn decode_inter_block8( proj_ok as u8, warp_eligible as u8, allow_warped_motion as u8 ); } - if allow_warped_motion && proj_ok && ref_is_scaled { - hit!(SCALED_WARP_SUPPRESSED_HITS); - } - if allow_warped_motion && proj_ok && !ref_is_scaled && force_integer_mv { - hit!(FIMV_ALPHABET_HITS); - } if warp_eligible { crate::msac::SymbolDecoder::set_symr_cdf("motion_mode"); let mode = dec.symbol(&mut cdfs.motion_mode[0]); @@ -1600,19 +1556,8 @@ pub(super) fn decode_inter_block8( 0 => {} 1 => { obmc_selected = true; - hit!(OBMC_HITS); - hit!(OBMC_HITS_8); } _ => { - // lane-gmaffine r1: WARPED_CAUSAL at the 8x8 leaf -- - // the same findSamples -> select_samples -> - // av1_find_projection chain the 16x16+ leaf runs, - // with BLOCK_8X8's own 8x8 model centre; an - // unusable projection falls back to the block's - // translational mv (libaom `av1_find_projection` - // returning 1 leaves `wm_params` invalid and - // `build_inter_predictors` skips the warp). - hit!(WARP_SELECTED_HITS); let mut samples = find_samples( grid, mi_row, @@ -1637,18 +1582,11 @@ pub(super) fn decode_inter_block8( mi_col as i32, ); warped_selected = true; - if warp_params.is_some() { - hit!(WARP_HITS_8); - } } } } else { // `default_obmc_cdf`'s own index: square bsize 8/16/32/64 -> 0/1/2/3. obmc_selected = dec.symbol(&mut cdfs.obmc[0]) == 1; - if obmc_selected { - hit!(OBMC_HITS); - hit!(OBMC_HITS_8); - } } } // lane-gmaffine r1: `read_mb_interp_filter` (spec 5.11.26) at the 8x8 @@ -1710,9 +1648,6 @@ pub(super) fn decode_inter_block8( // size predicate baked into `is_global_mv_block`. if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { warp_params = crate::warp::global_warp_params(gm_ref.params); - if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine { - hit!(AFFINE_GM_HITS); - } } // lane-av112bitw: same lift as the 16x16+ leaf -- a local // `WARPED_CAUSAL` projection or a global model both leave @@ -1757,9 +1692,6 @@ pub(super) fn decode_inter_block8( // (documented corner-cut above); under a scaled reference the same // fixed kernel runs through spec 7.11.3.3's scaled walk instead. let luma_scale = scale_of((ref_width, ref_height), frame_size); - if !luma_scale.is_unscaled() { - hit!(SCALED_BLOCK8_HITS); - } let obmc = if obmc_selected { Some(obmc_plan( grid, @@ -2211,19 +2143,6 @@ pub(super) fn decode_inter_block8( } else { 0 }; - if angle_delta_y != 0 { - hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS); - // lane-leaf8tx r1: `av1_use_angle_delta(BLOCK_8X8)` is true - // (`bsize >= BLOCK_8X8`), so this leaf codes `angle_delta_y` off - // `angle_delta_cdf[mode - V_PRED]` exactly as a key-frame block - // does (libaom `read_intra_angle_info` inside - // `read_intra_block_mode_info`, decodemv.c), and the delta feeds - // the directional predictor + the edge filter/upsample decision - // through the same `reconstruct` argument below. Counted - // separately from the >=16x16 arm so the gate cannot be satisfied - // by a bigger block. - hit!(INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS); - } // lane-uv8 r1: the delta'd angle decides the intra edge filter, and a // directional luma mode is already legal on this leaf -- the arm // passed a hardcoded `false` where [`decode_leaf8`] reads the @@ -2268,27 +2187,16 @@ pub(super) fn decode_inter_block8( dec.debug_state().0 ); } - if (9..=12).contains(&uv_mode) { - hit!(SMOOTH_UV_HITS); - hit!(INTRA_IN_INTER8_UV_SMOOTH_HITS); - } let alpha = if has_chroma && uv_mode == UV_CFL_PRED { - hit!(INTRA_IN_INTER8_UV_CFL_HITS); Some(read_cfl_alphas(dec, cdfs)) } else { None }; let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { - hit!(DIRECTIONAL_UV_HITS); - hit!(INTRA_IN_INTER8_UV_DIR_HITS); read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) } else { 0 }; - if angle_delta_uv != 0 { - hit!(UV_ANGLE_DELTA_HITS); - hit!(INTRA_IN_INTER_ANGLE_DELTA_UV_HITS); - } // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED`. uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED @@ -2378,8 +2286,6 @@ pub(super) fn decode_inter_block8( ); } if use_fi { - hit!(FILTER_INTRA_HITS); - hit!(INTRA_IN_INTER_FILTER_INTRA_HITS); let fi = dec.symbol(&mut cdfs.filter_intra_mode); if ec_istep8 { eprintln!( @@ -2404,15 +2310,6 @@ pub(super) fn decode_inter_block8( palette_onscreen(rmi, cmi, SIDE, SIDE, fctx), false, ); - hit!(PALETTE_HITS); - hit!(INTRA_IN_INTER_PALETTE_Y_HITS); - hit_do! { - INTER8_PALETTE_HITS.with(|c| { - let mut v = c.get(); - v.0 += 1; - c.set(v); - }); - } PaletteY { size: n, colors, @@ -2430,15 +2327,6 @@ pub(super) fn decode_inter_block8( (ss_x(fctx), ss_y(fctx)), ); let map = decode_color_index_map_wh(dec, cdfs, n, chroma_w, chroma_h, on, true); - hit!(PALETTE_UV_HITS); - hit!(INTRA_IN_INTER_PALETTE_UV_HITS); - hit_do! { - INTER8_PALETTE_HITS.with(|c| { - let mut v = c.get(); - v.1 += 1; - c.set(v); - }); - } PaletteUv { size: n, u_colors, @@ -2525,7 +2413,6 @@ pub(super) fn decode_inter_block8( // (the whole-block buffer would be indexed at the wrong // stride by the first unit). if let Some(buf) = &palette_y_buf { - hit!(PALETTE_SPLIT_TX_HITS); let window: Vec = (0..tx_px) .flat_map(|i| { let base = (row * MI + i) * SIDE + col * MI; @@ -2779,7 +2666,6 @@ pub(super) fn decode_inter_block8( Grid::Own(vo) }; chroma_stamped_per_unit = true; - hit!(LLINTRA8_CHROMA_WALK_HITS); } else { if let Some((ub, _)) = &palette_uv_bufs { set_palette_pred(ub.clone(), fctx); @@ -2986,18 +2872,6 @@ pub(super) fn decode_inter_block8( neighbours.above[leaf_mi.1 + cell][0] = state; } } - // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference - // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every - // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test). - // lane-cdef r1: the fall-through twin of the compound arm's skip-band - // write above -- `skip` is one flag for the whole 8x8 leaf (read at - // `decode.rs`'s `skip_ctx` site), `split8` only splits its transform. - // lane-intersub8 r5: ... and it counts too. r1 incremented the counter in - // the COMPOUND early-return arm only, so the gate's assert really read - // "a COMPOUND 8x8 leaf wrote the band"; once main's inter16ab/r14 routing - // landed, the 10-bit cq12 arm's leaves come through here instead and the - // gate failed on an instrumentation gap, with the band written either way. - hit!(INTER8_SKIP_BAND_HITS); neighbours.fill_skip_grid(leaf_mi, 2, skip); neighbours.fill_lf_grid( leaf_mi, diff --git a/crates/ec-av1/src/decode/inter_ctx.rs b/crates/ec-av1/src/decode/inter_ctx.rs index 9731874f..558130d6 100644 --- a/crates/ec-av1/src/decode/inter_ctx.rs +++ b/crates/ec-av1/src/decode/inter_ctx.rs @@ -83,9 +83,6 @@ pub(super) fn resolve_interp_filter( } else { sym0 }; - if enable_dual_filter && sym0 != sym1 { - hit!(DUAL_FILTER_DIFF_HITS); - } if crate::envflags::env_flag!("EC_TRACE_MODE") { eprintln!( "EC_IF ctx0={ctx0} above={above:?} left={left:?} sym0={sym0} sym1={sym1} rng={}", @@ -484,8 +481,6 @@ pub(super) fn read_inter_plane( if plane_idx > 0 && mono(fctx) { return Ok((Grid::Zero(side * side), TxType::DctDct)); } - // lane-av1readcensus: the units read from here on are this plane's. - set_census_plane(plane_idx); let skip_ctx = if plane_idx == 0 { luma_skip_ctx.unwrap_or(0) } else { @@ -678,7 +673,6 @@ pub(super) fn read_intra_chroma_lossless( plane_idx, &cu_grid, ); - hit!(CHROMA_SPLIT_TX_HITS); let dst = mu_units( if plane_idx == 1 { &mut *u_out @@ -737,9 +731,6 @@ pub(super) fn mu_chunk_order( let mut order = identity.clone(); order.sort_by_key(|&i| ((leaves[i].0 / 16) * nchunk + (leaves[i].1 / 16), i)); let changed = order != identity; - if changed { - hit!(MU_CHUNK_ORDER_HITS); - } (order, changed) } @@ -788,9 +779,6 @@ pub(super) fn read_inter_chroma_lossless( // libaom walks one 64x64 mu chunk at a time. Counted so a gate can pin // the walk/unit totals exactly rather than as a floor on wrong output. let counted_128 = blk_w > 64 || blk_h > 64; - if counted_128 { - hit!(MU_CHUNK_WALKS); - } for plane_idx in 1..3 { for rr in 0..reg_h / 4 { for cc in 0..reg_w / 4 { @@ -850,10 +838,6 @@ pub(super) fn read_inter_chroma_lossless( plane_idx, &cu_grid, ); - hit!(CHROMA_SPLIT_TX_HITS); - if counted_128 { - hit!(MU_CHUNK_WALK_UNITS); - } let dst = mu_units( if plane_idx == 1 { &mut *u_out @@ -1018,17 +1002,6 @@ pub(super) fn read_single_ref( } }; if ref_frame != LAST_FRAME { - hit!(NON_LAST_REF_HITS); - let c = match ref_frame { - LAST2_FRAME => &LAST2_HITS, - LAST3_FRAME => &LAST3_HITS, - GOLDEN_FRAME => &GOLDEN_HITS, - BWDREF_FRAME => &BWDREF_HITS, - ALTREF2_FRAME => &ALTREF2_HITS, - ALTREF_FRAME => &ALTREF_HITS, - _ => unreachable!("read_single_ref only ever returns LAST_FRAME..=ALTREF_FRAME"), - }; - hit_do! { c.with(|v| v.set(v.get() + 1)); } } ref_frame } @@ -1405,9 +1378,6 @@ pub(super) fn overlappable_above( if let Some(info) = nb && info.is_inter { - if src != col { - hit!(OBMC_PAIR_FILTER_HITS); - } // lane-t900 r14: libaom passes `AOMMIN(xd->width, mi_step)` // as `op_mi_size` -- the block's OWN width, never the // frame-edge clamp `end_col` carries. Clamping here shrank the @@ -1472,9 +1442,6 @@ pub(super) fn overlappable_left( if let Some(info) = nb && info.is_inter { - if src != row { - hit!(OBMC_PAIR_FILTER_HITS); - } // lane-t900 r14: `AOMMIN(xd->height, mi_step)` -- see // `overlappable_above`. out.push(( @@ -1681,9 +1648,6 @@ pub(crate) fn find_samples( // libaom reads the 2-symbol `obmc_cdf` (class // wrong-alphabet-same-value). let tr_reach = crate::mvstack::has_top_right(mi_row, mi_col, bw4, bh4, fctx); - if do_tr && bw4 != bh4 && tr_reach != has_top_right(mi_row, mi_col, bw4, fctx) { - hit!(TR_REACH_LONGER_SIDE_HITS); - } if do_tr && tr_reach { let tr_col = mi_col + bw4; if mi_row > 0 @@ -1784,7 +1748,6 @@ pub(super) fn neighbour_filter( "an OBMC neighbour whose switchable interp filter was never recorded", )); } - hit!(OBMC_FILTER_BAND_READS); Ok(( mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize), mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize), @@ -2200,9 +2163,6 @@ pub(crate) fn obmc_plan( // lane-inter4 r4: r3 refused OBMC on a 16x8/8x16 leaf; re-measured // byte-exact against an instrumented aomdec, the refusal is gone and the // counter below is what the gate's `--enable-obmc=1` arm reads. - if matches!((write_w, write_h), (16, 8) | (8, 16)) { - hit!(OBMC_RECT_LEAF_HITS); - } // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own // half (`reconinter.c` 860/899), inert below 128. let overlap_above = write_h.min(64) / 2; @@ -2250,9 +2210,6 @@ pub(crate) fn obmc_plan( "above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind, ); let nb_dims = ref_dims(nb.ref_frame, refpix)?; - if mi_col + off4 + span4 > mi_cols { - hit!(OBMC_EDGE_SPAN_HITS); - } above.push(ObmcNb { off4, span4, @@ -2286,9 +2243,6 @@ pub(crate) fn obmc_plan( "left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind, ); let nb_dims = ref_dims(nb.ref_frame, refpix)?; - if mi_row + off4 + span4 > mi_rows { - hit!(OBMC_EDGE_SPAN_HITS); - } left.push(ObmcNb { off4, span4, @@ -2722,9 +2676,6 @@ pub(super) fn read_comp_mode( dec.debug_state().0 ); } - if compound { - hit!(COMP_MODE_HITS); - } compound } @@ -2766,7 +2717,6 @@ pub(super) fn read_compound_ref_frames( let type_ctx = comp_reference_type_ctx(above, left); let unidir = dec.symbol(&mut cdfs.comp_ref_type[type_ctx]) == 0; if unidir { - hit!(UNI_COMP_HITS); // uni_comp_ref (p0): forward vs. backward -- av1_get_pred_context_- // uni_comp_ref_p is single_ref_p1's own forward/backward vote. 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( ref_mv_ctx: usize, ) -> u8 { let ctx = cdf::COMPOUND_MODE_CTX_MAP[ref_mv_ctx >> 1][new_mv_ctx.min(4)]; - hit!(COMPOUND_MODE_HITS); dec.symbol(&mut cdfs.inter_compound_mode[ctx]) as u8 } diff --git a/crates/ec-av1/src/decode/inter_intra_arm.rs b/crates/ec-av1/src/decode/inter_intra_arm.rs index b876dc98..6180532e 100644 --- a/crates/ec-av1/src/decode/inter_intra_arm.rs +++ b/crates/ec-av1/src/decode/inter_intra_arm.rs @@ -241,9 +241,6 @@ pub(super) fn decode_inter_block_intra_arm( } else { 0 }; - if angle_delta_y != 0 { - hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS); - } // The delta'd angle decides whether the intra edge filter runs at // all, so this block needs the same luma edge-filter-type neighbour // check a key-frame block does (`get_intra_edge_filter_type`, spec @@ -263,9 +260,6 @@ pub(super) fn decode_inter_block_intra_arm( // (libaom `decodemv.c:933`). let has_chroma = !mono(fctx); let cfl_allowed = has_chroma && cfl_allowed_px(write_w, write_h, fctx); - if !cfl_allowed { - hit!(NOCFL_UV_MODE_HITS); - } let uv_mode = if !has_chroma { DC_PRED } else if cfl_allowed { @@ -275,9 +269,6 @@ pub(super) fn decode_inter_block_intra_arm( crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) }; - if (9..=12).contains(&uv_mode) { - hit!(SMOOTH_UV_HITS); - } let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { Some(read_cfl_alphas(dec, cdfs)) } else { @@ -288,15 +279,10 @@ pub(super) fn decode_inter_block_intra_arm( // -- `uv_mode` (13) already falls outside `V_PRED..=D67_PRED` so the // `else` branch below is exact for it either way. let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { - hit!(DIRECTIONAL_UV_HITS); read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) } else { 0 }; - if angle_delta_uv != 0 { - hit!(UV_ANGLE_DELTA_HITS); - hit!(INTRA_IN_INTER_ANGLE_DELTA_UV_HITS); - } uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { @@ -379,8 +365,6 @@ pub(super) fn decode_inter_block_intra_arm( && let Some(class) = filter_intra_size_class_rect(write_w, write_h) && dec.symbol(&mut cdfs.filter_intra[class]) != 0 { - hit!(FILTER_INTRA_HITS); - hit!(INTRA_IN_INTER_FILTER_INTRA_HITS); filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); } // `av1_visit_palette`: the two colour-index maps, Y then the shared @@ -395,8 +379,6 @@ pub(super) fn decode_inter_block_intra_arm( palette_onscreen(rmi, cmi, write_w, write_h, fctx), false, ); - hit!(PALETTE_HITS); - hit!(INTRA_IN_INTER_PALETTE_Y_HITS); PaletteY { size: n, colors, @@ -419,8 +401,6 @@ pub(super) fn decode_inter_block_intra_arm( (ss_x(fctx), ss_y(fctx)), ); let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true); - hit!(PALETTE_UV_HITS); - hit!(INTRA_IN_INTER_PALETTE_UV_HITS); PaletteUv { size: n, u_colors, @@ -516,7 +496,6 @@ pub(super) fn decode_inter_block_intra_arm( // (the whole-block buffer would be indexed at the wrong // stride by the first unit). if let Some(buf) = &palette_y_buf { - hit!(PALETTE_SPLIT_TX_HITS); let window: Vec = (0..tx_px) .flat_map(|i| { let base = (row * MI + i) * side + col * MI; @@ -588,7 +567,6 @@ pub(super) fn decode_inter_block_intra_arm( continue; } let (cr, cc) = chunk; - hit!(INTRA_128_IN_INTER_MU_CHROMA_HITS); // The unit's CHROMA size, its LUMA footprint, the // CHUNK's chroma extent and the unit's ORIGIN inside the // chunk are four different quantities; this arm had the @@ -785,7 +763,6 @@ pub(super) fn decode_inter_block_intra_arm( plane_idx, &cu_grid, ); - hit!(CHROMA_SPLIT_TX_HITS); // lane-dpm1: the two INTER mu-chunk sites set // this and this INTRA-in-inter one did not, so // the whole-block chroma record below re-stamped @@ -794,9 +771,6 @@ pub(super) fn decode_inter_block_intra_arm( // libaom never selects (class // `override-slot-on-one-arm`). mu_chroma = true; - // lane-av1muchunk422b: the allocation of the intra-in-inter - // mu-chunk walk (site 8), per TX_32X32 unit. - hit!(MU_CHUNK_INTRA_IN_INTER_UNITS); let dst = mu_units( if plane_idx == 1 { &mut u_units @@ -846,7 +820,6 @@ pub(super) fn decode_inter_block_intra_arm( } else { Grid::Own(std::mem::take(&mut v_units)) }; - hit!(INTRA_128_IN_INTER_HITS); } else if skip { if !split_luma { if let Some(buf) = &palette_y_buf { @@ -1072,7 +1045,6 @@ pub(super) fn decode_inter_block_intra_arm( // coefficient context. neighbours .record_mi_chroma(cu_mi, chroma_tx, chroma_tx, plane_idx, &cu_grid); - hit!(CHROMA_SPLIT_TX_HITS); let acc = if plane_idx == 1 { &mut u_acc } else { @@ -1181,7 +1153,6 @@ pub(super) fn decode_inter_block_intra_arm( fctx, ); } - hit!(PALETTE_422_UNIT_WINDOW_HITS); let cu_grid = read_plane( dec, cdfs, @@ -1210,8 +1181,6 @@ pub(super) fn decode_inter_block_intra_arm( smooth_neighbor_uv, fctx, )?; - hit!(CHROMA_SPLIT_TX_HITS); - hit!(CHROMA422_SQUARE_HITS); // Immediately, so the next unit of this plane reads this // one's coefficient context; the whole-block record below // re-stamps the block over these and the tail's @@ -1322,7 +1291,6 @@ pub(super) fn decode_inter_block_intra_arm( fctx, ); } - hit!(PALETTE_422_UNIT_WINDOW_HITS); let cu_grid = read_plane( dec, cdfs, @@ -1348,8 +1316,6 @@ pub(super) fn decode_inter_block_intra_arm( smooth_neighbor_uv, fctx, )?; - hit!(CHROMA_SPLIT_TX_HITS); - hit!(CHROMA422_SQUARE_HITS); neighbours.record_mi_chroma(cu_mi, luma_span_x, luma_span_y, 2, &cu_grid); for rr in 0..cu_h { let start = (cu_row * cu_h + rr) * chroma_side; diff --git a/crates/ec-av1/src/decode/inter_shapes.rs b/crates/ec-av1/src/decode/inter_shapes.rs index 7f8731ef..38060db0 100644 --- a/crates/ec-av1/src/decode/inter_shapes.rs +++ b/crates/ec-av1/src/decode/inter_shapes.rs @@ -107,9 +107,6 @@ pub(super) fn read_block_tx_size( let overwrote = !fctx.intra_only.with(std::cell::Cell::get) && (0..side_mi).any(|i| n.above_txfm.get(at_mi.1 + i) != Some(&pub_above)); set_txfm_ctxs(n, at_mi, 4, side_mi, side_mi, skip && is_inter); - if overwrote { - hit!(LOSSLESS_SQ_TXFM_BAND_OVERWRITE_HITS); - } return Ok((4, Some(leaves))); } if !fctx.tx_select_inter.with(std::cell::Cell::get) { @@ -194,13 +191,6 @@ pub(super) fn read_block_tx_size( leaves.push((row, col, tx, tx)); } } - hit_do! { - INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| { - let mut h = c.get(); - h[(side.trailing_zeros() as usize).saturating_sub(3).min(3)] += 1; - c.set(h); - }); - } return Ok((tx, Some(leaves))); } Ok((tx, None)) @@ -674,7 +664,6 @@ pub(super) fn read_block_tx_size_rect( // transform, and `set_txfm_ctxs` records exactly what // `txfm_partition_update` would for that same unit. txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); - hit!(RECT_INTER_TU_HITS); return Ok(None); } // lane-av1oddheightfork2: `above_px` / `left_px` are the two @@ -686,7 +675,6 @@ pub(super) fn read_block_tx_size_rect( let (above_px, left_px) = (n.above_txfm[at_mi.1], n.left_txfm[at_mi.0]); let ctx = txfm_partition_ctx_rect(above_px, left_px, bw.max(bh), tx_w, tx_h); let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; - hit!(TXFM_SPLIT_READS); if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { let (rng, _) = dec.debug_state(); eprintln!( @@ -699,11 +687,8 @@ pub(super) fn read_block_tx_size_rect( } if !split { txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); - hit!(RECT_INTER_TU_HITS); return Ok(None); } - hit!(TXFM_SPLIT_HITS); - hit!(RECT_INTER_TXSPLIT_HITS); // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`, // `[TX_16X64] == TX_16X32` -- so the recursion below is the general @@ -815,7 +800,6 @@ pub(super) fn read_inter_rect_chroma( // replay (the c8 re-stamp, at the strip's own tiling). let mut units: Vec<((usize, usize), usize, Grid, usize, usize)> = Vec::new(); if multi { - hit!(CHROMA_SPLIT_TX_HITS); assembled = [ vec![0i32; chroma_side * assembled_h], vec![0i32; chroma_side * assembled_h], @@ -852,35 +836,8 @@ pub(super) fn read_inter_rect_chroma( let cu_pred = src.offset(cu_row * uh * chroma_side + cu_col * uw); let inherit_tx_type = if let Some(t) = covering_leaf_tx_type(leaf_tx_types, unit_rel_mi) { - hit!(CHROMA_RECT_LEAF_TX_HITS); - if Some(t) != Some(luma_tx_type) { - hit!(CHROMA_RECT_LEAF_TX_DIFF_HITS); - } Some(t) } else { - // lane-av1ichromatx: the ONE remaining site in - // `decode_inter_block` that can hand a chroma unit a - // BLOCK-level type on a split plane. `covering_leaf_tx_ - // type` found nothing, i.e. no luma leaf covers this - // unit's own MI cell -- which is exactly the shape a - // block that coded a SINGLE luma transform has (its - // leaf list is empty, so every lookup misses). For - // that block `luma_tx_type` IS the type of the one - // luma unit whose stamp covers the whole plane, so the - // fallback is correct there. - // - // What is NOT correct is a fallback on a plane with - // `leaves` NON-empty: then some luma leaf does exist, - // it simply does not cover this unit's cell, and the - // block-level value is a DIFFERENT leaf's type. The - // assertion below is what closes that shape, so the - // fallback can never again be a silent mistype: the - // class is "block-level where the unit's own cell - // says otherwise", and this is its last site. - hit!(CHROMA_RECT_BLOCK_TX_FALLBACK); - if multi { - hit!(CHROMA_RECT_BLOCK_TX_FALLBACK_MULTI); - } debug_assert!( leaf_tx_types.is_empty(), "lane-av1ichromatx: a multi-unit rect chroma plane fell back to the \ @@ -911,9 +868,6 @@ pub(super) fn read_inter_rect_chroma( fctx, )? .0; - if invalid_ss_plane { - hit!(CHROMA422_CHUNK_HITS); - } if multi { // Immediately, so the next unit of this block reads this // one's coefficient context (libaom updates the chroma @@ -975,8 +929,6 @@ pub(super) fn read_inter_plane_rect( if plane_idx > 0 && mono(fctx) { return Ok((Grid::Zero(w * h), TxType::DctDct)); } - // lane-av1readcensus: the units read from here on are this plane's. - set_census_plane(plane_idx); let skip_ctx = if plane_idx == 0 { // `get_txb_ctx_general`: 0 only when this unit IS the whole plane // block; a var-tx leaf passes its own neighbour-table context. @@ -1020,18 +972,6 @@ pub(super) fn read_inter_plane_rect( // because `av1_nz_map_ctx_offset` is indexed by the real, un-adjusted // rectangular shape (lane-sbpart r8). let (cw, ch) = (w.min(32), h.min(32)); - if plane_idx == 0 && w.max(h) == 64 { - hit!(RECT64_INTER_TU_HITS); - } - if plane_idx == 0 && (w, h) == (32, 8) || plane_idx == 0 && (w, h) == (8, 32) { - hit_do! { - RECT32X8_INTER_TU_HITS.with(|c| { - let mut v = c.get(); - v[usize::from(w == 8)] += 1; - c.set(v); - }); - } - } let (corner, tx_type) = if (cw, ch) == (32, 32) { let scan32 = default_scan(TX32); read_coeffs( @@ -1706,6 +1646,5 @@ pub(super) fn edge_params_body( [4, 8, 14, 14, 14][dim] }; let level = if cur_level != 0 { cur_level } else { pv_level }; - hit!(DEBLOCK_HITS); Some((len, level)) } diff --git a/crates/ec-av1/src/decode/key_tile.rs b/crates/ec-av1/src/decode/key_tile.rs index d201b4a1..0a8c42b2 100644 --- a/crates/ec-av1/src/decode/key_tile.rs +++ b/crates/ec-av1/src/decode/key_tile.rs @@ -328,26 +328,17 @@ pub(super) fn read_sb128_root( let ctx128 = neighbours.partition_ctx(at128, 128); let (has_cols128, has_rows128) = (mi_c128 + SB_MI < mi_cols, mi_r128 + SB_MI < mi_rows); let part128 = if has_cols128 && has_rows128 { - hit!(PART128_SYMBOLS); let p = dec.symbol(&mut cdfs.partition_w128[ctx128]); if crate::envflags::env_flag!("EC_AV1_TRACE") { eprintln!("TRACE partition_w128 ctx={ctx128} value={p}"); } p } else { - // lane-sb128 r4: the gathered half-out-of-frame reads DECIDE the - // partition, they are not a forced split -- exactly the discarded-bit - // defect the 64 root carries a comment about at `partition_w64`'s - // gathered arm. Value 1 is SPLIT; 0 is HORZ (rows out of frame) or - // VERT (cols out of frame), which the refusal below then names - // instead of silently reconstructing a split. - hit!(PART128_GATHERED_SYMBOLS); match (has_cols128, has_rows128) { (true, false) => { if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 { PARTITION_SPLIT } else { - hit!(PART128_EDGE_HORZ_HITS); PARTITION_HORZ } } @@ -355,7 +346,6 @@ pub(super) fn read_sb128_root( if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 { PARTITION_SPLIT } else { - hit!(PART128_EDGE_VERT_HITS); PARTITION_VERT } } @@ -383,21 +373,10 @@ pub(super) fn read_sb128_root( // decoding untouched. refuse_invalid_subsize((128, 128), part128, fctx)?; match part128 { - PARTITION_SPLIT => hit!(PART128_SPLIT_HITS), - PARTITION_NONE => hit!(PART128_NONE_HITS), - PARTITION_HORZ => hit!(PART128_HORZ_HITS), - PARTITION_VERT => hit!(PART128_VERT_HITS), // lane-sb128c r9: the four AB shapes at the 128 root -- one // 128x64/64x128 half plus two 64x64 quadrants, decoded by both tile // paths below in libaom `decode_partition`'s own visit order. p if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&p) => { - hit_do! { - PART128_AB_HITS.with(|c| { - let mut h = c.get(); - h[p - PARTITION_HORZ_A] += 1; - c.set(h); - }); - } } _ => { return Err(unsupported( @@ -633,7 +612,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( ((mi_col1 as usize * 4) >> ss_x(fctx)).min(v.width), ((mi_row1 as usize * 4) >> ss_y(fctx)).min(v.height), ); - hit!(TILE_HITS); // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` -- // 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( // `Reach::vert_ab_partition()` (lane-part32 r5, cherry-picked here). let arm = part16 - PARTITION_HORZ_A; bump_ab16(arm); - if part16 == PARTITION_VERT_B { - hit!(VERT_B_INTRA_HITS); - } let _vert_guard = if part16 == PARTITION_VERT_A || part16 == PARTITION_VERT_B { @@ -1448,7 +1423,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( continue; } if part16 == PARTITION_HORZ { - hit!(HORZ_VERT_INTRA_HITS); let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI); let top = (mi_row0 as usize, mi_col0 as usize); @@ -1496,7 +1470,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( continue; } if part16 == PARTITION_VERT { - hit!(HORZ_VERT_INTRA_HITS); let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI); let left = (mi_row0 as usize, mi_col0 as usize); @@ -1815,19 +1788,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( // non-SPLIT edge arm actually decoded. bump_edge_part(if edge_split == 1 { 3 } else { 2 }); if edge_split == 0 { - // lane-oddh r1: the strip IS decodable - // -- libaom's `decode_partition` codes - // only the FIRST half of an edge - // HORZ/VERT (the second call is - // guarded by the same has_rows/ - // has_cols test that made the - // partition non-square), so one - // 16x8 (resp. 8x16) strip covers the - // whole visible band of a frame whose - // height (resp. width) is 8 mod 16 -- - // the user's 3840x1608 film. - hit!(HORZ_VERT_INTRA_HITS); - hit!(EDGE_RECT_STRIP_HITS); // lane-av1subsizesweep: this arm is the ONE // frame-edge partition read in the file that // dispatches on its own symbol instead of @@ -2131,11 +2091,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( } } PARTITION_HORZ_A => { - // lane-part32 r1: two 16x16 squares on top + - // a true 32x16 strip below (mirrors - // decode_inter_block's cd6cb6d HORZ_A: TL, - // TR, bottom strip). - hit!(INTRA_HORZ_A_HITS); decode_block( &mut dec, &mut cdfs, @@ -2209,11 +2164,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( )?; } PARTITION_HORZ_B => { - // lane-part32 r1: a true 32x16 strip on top + - // two 16x16 squares below (mirrors HORZ_A - // with the strip/squares order flipped, same - // shape as libaom decode_partition's HORZ_B). - hit!(INTRA_HORZ_B_HITS); decode_block_rect( &mut dec, &mut cdfs, @@ -2287,10 +2237,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( )?; } PARTITION_VERT_A => { - // lane-part32 r1: mirror of HORZ_A with - // width/height swapped (TL, BL, right 16x32 - // strip). - hit!(INTRA_VERT_A_HITS); let _vert_ab = crate::encode::Reach::vert_ab_partition(); decode_block( &mut dec, @@ -2365,11 +2311,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( )?; } PARTITION_VERT_B => { - // lane-part32 r1: a true 16x32 strip on the - // left + two 16x16 squares on the right - // (libaom decode_partition VERT_B: left - // strip, TR, BR). - hit!(INTRA_VERT_B_HITS); let _vert_ab = crate::encode::Reach::vert_ab_partition(); decode_block_rect( &mut dec, @@ -2585,21 +2526,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( } } PARTITION_HORZ_A | PARTITION_HORZ_B | PARTITION_VERT_A | PARTITION_VERT_B => { - // lane-part32 r4: the four superblock-level AB arms, each - // two 32x32 squares plus one 64x32/32x64 strip, in - // libaom's own `decode_partition` order (decodeframe.c: - // HORZ_A = TL, TR, bottom strip; HORZ_B = top strip, BL, - // BR; VERT_A = TL, BL, right strip; VERT_B = left strip, - // TR, BR). The pieces are exactly the ones already proven - // by the `PARTITION_NONE`-under-SPLIT (32x32 square) and - // `PARTITION_HORZ`/`VERT` (rect64 strip) arms above. - hit_do! { - SB_AB_HITS.with(|c| { - let mut h = c.get(); - h[part - PARTITION_HORZ_A] += 1; - c.set(h); - }); - } // lane-part32 r5: only the two VERTICAL arms reorder the // square sub-blocks (TL, BL, TR, BR), so only they switch // libaom's `has_tr`/`has_bl` tables. @@ -2759,7 +2685,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) ); } - census_unwritten(&y, &u, &v); // lane-av1fwd: the encoder's filter search re-decodes this same key // frame tile per candidate -- capture it once (see [`FilterReplay`]), // on the shape whose tail is the two filter calls and nothing else. diff --git a/crates/ec-av1/src/decode/leaf8.rs b/crates/ec-av1/src/decode/leaf8.rs index be1da877..53f9f80f 100644 --- a/crates/ec-av1/src/decode/leaf8.rs +++ b/crates/ec-av1/src/decode/leaf8.rs @@ -122,9 +122,6 @@ pub(super) fn decode_block_128rect( uv_mode }; let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx); // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or // 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( } else { 0 }; - if depth != 0 { - hit!(TX_DEPTH_HITS); - } - hit_do! { - INTRA_SB128_DEPTH_HITS.with(|c| { - let mut h = c.get(); - h[depth.min(2)] += 1; - c.set(h); - }); - } let logical_tx = if lossless_frame { 4 } else { 64 >> depth }; - if lossless_frame { - hit!(INTRA128_LOSSLESS_HITS); - } // A 64-point transform codes nothing past its low 32 coefficients. let coeff_tx_side = logical_tx.min(32); let luma_set = if lossless_frame { @@ -425,9 +409,6 @@ pub(super) fn decode_block_128rect( } } } - if !skip { - hit!(CHROMA_SPLIT_TX_HITS); - } } } if skip { @@ -467,12 +448,8 @@ pub(super) fn decode_block_128rect( // byte-exact against ffmpeg) -- that is the replay's own designed // 4:2:2 case, not a defect signature. Nothing here asserts the // mismatch is zero. - if luma_span != luma_span_h { - hit!(SB128RECT_REPLAY_SPAN_MISMATCH_HITS); - } for (plane, cu_mi, grid) in &units { neighbours.record_mi_chroma(*cu_mi, luma_span, luma_span_h, *plane, grid); - hit!(SB128RECT_CHROMA_REPLAY_HITS); } } // No palette exists at this size; the unconditional stamp clears any @@ -500,17 +477,8 @@ pub(super) fn decode_block_128rect( txfm_partition_update_rect(neighbours, (mi_r, mi_c), (logical_tx, logical_tx), (bw, bh)); } if in_inter { - hit_do! { - INTRA128_IN_INTER_HITS.with(|c| { - let mut h = c.get(); - h[usize::from(bw < bh)] += 1; - c.set(h); - }); - } } else if bw > bh { - hit!(INTRA_SB128_HORZ_HITS); } else { - hit!(INTRA_SB128_VERT_HITS); } Ok(()) } @@ -603,9 +571,6 @@ pub(super) fn decode_leaf8( // with the coarse [`SUB`] slot as the fallback when no block recorded // that exact mi cell. let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c, fctx); - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other // `decode_block` caller at 16x16 and up. @@ -654,9 +619,6 @@ pub(super) fn decode_leaf8( // next symbol (class `wrong-alphabet-same-value`). Everything below // mirrors `decode_block`'s own intrabc handling at 16x16 and up. let intrabc_dv = fctx.intrabc_dv.with(|c| c.take()); - if intrabc_dv.is_some() { - hit!(LEAF8_INTRABC_HITS); - } // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour // index map, mapped through the base colours, IS the block's prediction -- // carried to the next `reconstruct`/`read_plane` through the same @@ -676,9 +638,6 @@ pub(super) fn decode_leaf8( let (pal_uv_size, pal_uv_colors) = palette_uv .as_ref() .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); - if palette_y.is_some() || palette_uv.is_some() { - hit!(PALETTE_LEAF8_HITS); - } let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { @@ -722,7 +681,6 @@ pub(super) fn decode_leaf8( 0, &mut leaves, ); - hit!(INTRABC_VARTX_HITS); leaves.first().map_or(8, |l| l.2) } else if tx_select && intrabc_dv.is_none() { read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, fctx) @@ -846,7 +804,6 @@ pub(super) fn decode_leaf8( // rule) -- so a palette leaf takes the single 8x8 reconstruct below // even when `tx_depth` resolved to TX_4X4. if resolved == 4 && palette_y_buf.is_none() { - hit!(SKIP_SPLIT_TX_HITS); for tu_row in 0..2 { for tu_col in 0..2 { let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4); @@ -1400,9 +1357,6 @@ pub(super) fn decode_leaf8( let tu_px = px + tu_col * 4; let tu_py = py + tu_row * 4; let tu_around = neighbours.around_mi(tu_mi, 4)[0]; - if crate::encode::Reach::in_vert_ab() { - hit!(VERT_AB_TX4_HITS); - } let tu_reach = tu_reach( 8, 8, @@ -1422,7 +1376,6 @@ pub(super) fn decode_leaf8( // 16x16 and up) -- the whole-block buffer would be taken by // the FIRST unit and indexed at the wrong stride. if let Some(buf) = &palette_y_buf { - hit!(PALETTE_SPLIT_TX_HITS); let mut window = vec![0u16; 16]; for row in 0..4 { let src = (tu_row * 4 + row) * 8 + tu_col * 4; @@ -1505,9 +1458,6 @@ pub(super) fn decode_leaf8( // lane-av1intrapred: the non-vacuity counter -- armed slot consulted // by this arm's chroma reads means the frame-copy + inherited-type // route ran; zero at gate time means the fixture stopped reaching it. - if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { - hit!(INTRABC_TX4_CHROMA_COPY_HITS); - } if chroma_422 && !lossless(fctx) { // lane-av1-422d: the chroma unit does NOT follow the luma var-tx // split -- `uv_txsize` is `av1_get_max_uv_txsize` of the block, @@ -1630,7 +1580,6 @@ pub(super) fn decode_leaf8( } else { Grid::Own(vo) }; - hit!(CHROMA422_LOSSLESS_4X4_HITS); } else if chroma_444 && lossless(fctx) { // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster // of TX_4X4 units per plane, PLANE-MAJOR (`av1_get_tx_size`: @@ -1809,7 +1758,6 @@ pub(super) fn decode_leaf8( neighbours.record_palette_y_rect(leaf_mi, 8, 8, pal_y_size, pal_y_colors); neighbours.record_palette_uv_rect(leaf_mi, 8, 8, pal_uv_size, pal_uv_colors); } - hit!(INTER8_SKIP_BAND_HITS); neighbours.fill_skip_grid(leaf_mi, 2, skip); // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm && @@ -2067,15 +2015,6 @@ pub(super) fn read_intra_mode_sub8( // `is_inter_block` counts an intrabc block), so the caller takes // the frame-copy prediction + inter residual. let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (seg_w_mi, seg_h_mi), fctx); - // lane-av1txr: the DV travels back in the RETURN value -- it is - // NOT published through `FrameCtx::intrabc_dv`. That slot is the - // SQUARE paths' handoff (`decode_block`/`decode_leaf8` arm it, - // then `take()` it in the same call), so a sub-8x8 leaf that - // armed it left the vector standing for the NEXT >=8x8 block: - // `warped.obu`'s (38,60) 8x8 intra block took it as its own - // intrabc and read an inter var-tx `txfm_split` where libaom read - // an intra `tx_depth` (class `stale-slot-handoff`). - hit!(INTRABC_HITS); return Ok((skip, DC_PRED, 0, None, None, Some(dv))); } } @@ -2119,17 +2058,11 @@ pub(super) fn read_intra_mode_sub8( dec.debug_state().0 ); } - if (9..=12).contains(&uv_mode) { - hit!(SMOOTH_UV_HITS); - } let alpha = if uv_mode == UV_CFL_PRED { Some(read_cfl_alphas(dec, cdfs)) } else { None }; - if (V_PRED..=D67_PRED).contains(&uv_mode) { - hit!(DIRECTIONAL_UV_HITS); - } // See the luma comment above: no angle delta below 8x8. let angle_delta_uv = 0; Some((uv_mode, angle_delta_uv, alpha)) @@ -2146,7 +2079,6 @@ pub(super) fn read_intra_mode_sub8( ); } if use_filter_intra { - hit!(FILTER_INTRA_HITS); let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); filter_intra = Some(fi_mode); } diff --git a/crates/ec-av1/src/decode/leaf_sub8.rs b/crates/ec-av1/src/decode/leaf_sub8.rs index c13bc7b5..74bf5218 100644 --- a/crates/ec-av1/src/decode/leaf_sub8.rs +++ b/crates/ec-av1/src/decode/leaf_sub8.rs @@ -94,7 +94,6 @@ pub(super) fn sub8_leaf_chroma444( &mut vb, fctx, ); - hit!(SKIPPED_INTRABC_DV_COPY_HITS); let zeros = &ZERO_RESIDUAL[..bw * bh]; if square { set_palette_pred(ub, fctx); @@ -173,10 +172,6 @@ pub(super) fn sub8_leaf_chroma444( fctx, ); } - // The same arm-without-clear route the 4:2:0 tails count: a skipped - // leaf reads no coefficient, so the inherited chroma `tx_type` is - // dropped unconsumed. - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); fctx.intrabc_chroma_tx.with(|c| c.set(None)); (Grid::Zero(bw * bh), Grid::Zero(bw * bh), 4, 4) } else if skip { @@ -257,7 +252,6 @@ pub(super) fn sub8_leaf_chroma444( // The same arm-without-clear route the 4:2:0 tails count: a skipped // leaf reads no coefficient, so an armed intrabc slot is dropped. if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); fctx.intrabc_chroma_tx.with(|c| c.set(None)); } (Grid::Zero(bw * bh), Grid::Zero(bw * bh), 4, 4) @@ -350,9 +344,6 @@ pub(super) fn sub8_leaf_chroma444( } else { // lane-av1-ibc444rect: the unskipped lossless chroma walk this // lane fixes (one rect unit -> per-4x4 Chroma4 units). - if lossless(fctx) { - hit!(INTRABC_RECT8_LOSSLESS_CHROMA_HITS); - } if lossless(fctx) { // lane-av1-ibc444rect: at lossless `read_tx_size` forces // TX_4X4 on EVERY plane (`av1_get_tx_size`'s lossless @@ -409,7 +400,6 @@ pub(super) fn sub8_leaf_chroma444( if !square && unit_reach != Reach::of(4, upx, upy, y.width, y.height, fctx) { - hit!(SUB8_CHROMA444_LOSSLESS_TU_REACH_HITS); } let grid = read_plane( dec, @@ -607,7 +597,6 @@ pub(super) fn sub8_leaf_chroma444( let unit_reach = Reach::of_tu(bw, bh, uc * 4, ur * 4, 4, 4, reach); if !square && unit_reach != Reach::of(4, upx, upy, y.width, y.height, fctx) { - hit!(SUB8_CHROMA444_LOSSLESS_TU_REACH_HITS); } let grid = read_plane( dec, @@ -988,7 +977,6 @@ pub(super) fn sub8_leaf_chroma422( &mut ub, fctx, ); - hit!(SKIPPED_INTRABC_DV_COPY_HITS); let zeros = &ZERO_RESIDUAL[..16]; set_palette_pred(ub, fctx); push_intra( @@ -1044,17 +1032,12 @@ pub(super) fn sub8_leaf_chroma422( // [`sub8_leaf_chroma444`] count: a skipped leaf reads no coefficient, // so the inherited chroma `tx_type` is dropped unconsumed. if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); fctx.intrabc_chroma_tx.with(|c| c.set(None)); } (Grid::Zero(16), Grid::Zero(16)) } else if skip { // A skipped chroma-reference leaf still predicts (the CfL contribution // survives a skip); no coefficient symbol exists. - if alpha.is_some() { - hit!(CHROMA_SKIP_CFL_HITS); - hit!(SKIP_CFL_HITS); - } push_intra( y, u, @@ -1092,12 +1075,10 @@ pub(super) fn sub8_leaf_chroma422( // The same arm-without-clear route the 4:2:0 tails count: a skipped // leaf reads no coefficient, so an armed intrabc slot is dropped. if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); fctx.intrabc_chroma_tx.with(|c| c.set(None)); } (Grid::Zero(16), Grid::Zero(16)) } else if let Some(dv) = intrabc_dv { - hit!(CHROMA422_SUB8_HITS); // Frame copy at the DV; the residual still reads the ordinary chroma // tables with the inherited luma `tx_type` (see the 4:2:0 tails). let mut ub = vec![0u16; 16]; @@ -1183,7 +1164,6 @@ pub(super) fn sub8_leaf_chroma422( fctx.intrabc_chroma_tx.with(|c| c.set(None)); (ug, vg) } else { - hit!(CHROMA422_SUB8_HITS); let ug = read_plane( dec, cdfs, @@ -1286,7 +1266,6 @@ pub(super) fn decode_leaf_split4( // one a neighbour to its RIGHT sees (its top-right 4x4, mi(row, col-1))., fctx: &crate::decode::FrameCtx fctx: &crate::decode::FrameCtx, ) -> Result<(usize, usize)> { - hit!(SUB8_SPLIT_HITS); let (r, c) = outer_at; let mut above_mode = neighbours.above_mode[c]; let mut left_mode = neighbours.left_mode[r]; @@ -1378,9 +1357,6 @@ pub(super) fn decode_leaf_split4( // same value). set_txfm_ctxs(neighbours, lmi, 4, 1, 1, false); let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } let (px, py) = (lmi.1 * MI, lmi.0 * MI); let reach = Reach::of(4, px, py, y.width, y.height, fctx); if let Some(dv) = intrabc { @@ -1695,10 +1671,6 @@ pub(super) fn decode_leaf_split4( // merge keeps one fix and feeds both lanes' counters so neither of // their gates goes vacuous. let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); - if alpha.is_some() { - hit!(CHROMA_SKIP_CFL_HITS); - hit!(SKIP_CFL_HITS); - } push_intra( y, u, @@ -1742,7 +1714,6 @@ pub(super) fn decode_leaf_split4( // arm-without-clear-on-a-skip-route). Counted so a gate can tell a // stream that reaches this route from one that never does. if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); fctx.intrabc_chroma_tx.with(|c| c.set(None)); } (Grid::Zero(16), Grid::Zero(16)) @@ -2073,9 +2044,6 @@ pub(super) fn decode_leaf_rect8( if let Some(dv) = intrabc { // lane-av1-ibc444rect: the unskipped lossless luma walk this lane // fixes (one rect unit -> per-4x4 inter units). - if !skip && lossless(fctx) { - hit!(INTRABC_RECT8_LOSSLESS_LUMA_HITS); - } // lane-av1txr: an intrabc `BLOCK_4X8`/`BLOCK_8X4` leaf. The // prediction is a frame copy at the DV and the residual reads the // INTER `LumaRect8x4` set -- but with `TxMode::Select` the leaf @@ -2127,7 +2095,6 @@ pub(super) fn decode_leaf_rect8( 0, &mut luma_leaves, ); - hit!(RECT_INTRABC_VARTX_HITS); publish = None; } else if lossless(fctx) && !skip { // lane-av1-ibc444rect: `read_tx_size`'s lossless first line @@ -2452,15 +2419,6 @@ pub(super) fn decode_leaf_rect8( } continue; } - if filter_intra.is_some() { - // lane-fi8 r1: `predict_filter_intra` walks its 4x2 patches over - // a true `bw`x`bh` block, so a 4x8/8x4 leaf predicts through the - // same `reconstruct_rect`/`reconstruct` calls below -- and under - // a split transform, per 4x4 unit with that unit's own edge, - // which is exactly what the depth-1 loop already does. - hit!(FILTER_INTRA_RECT_HITS); - hit!(FILTER_INTRA_RECT_SUB8_HITS); - } // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4 // leaf too, and is read for every intra block, skipped or not. Its // category is libaom's `bsize_to_tx_size_cat(BLOCK_4X8) == 0` -- @@ -2485,13 +2443,6 @@ pub(super) fn decode_leaf_rect8( } else { 0 }; - if depth != 0 { - hit!(TX_DEPTH_HITS); - hit!(RECT8_SPLIT_TX_HITS); - } - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } let (px, py) = (lmi.1 * MI, lmi.0 * MI); let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); // `sub_tx_size_map[TX_4X8] == TX_4X4`: depth 1 splits the leaf into @@ -2600,9 +2551,7 @@ pub(super) fn decode_leaf_rect8( } if done > 0 { if vert { - hit!(TX4X8_CODED_HITS); } else { - hit!(TX8X4_CODED_HITS); } } neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); @@ -2716,9 +2665,7 @@ pub(super) fn decode_leaf_rect8( )?; if levels.iter().any(|&l| l != 0) { if vert { - hit!(TX4X8_CODED_HITS); } else { - hit!(TX8X4_CODED_HITS); } } let residual = dequant_and_inverse_typed_wh( @@ -2881,10 +2828,6 @@ pub(super) fn decode_leaf_rect8( // merge keeps one fix and feeds both lanes' counters so neither of // their gates goes vacuous. let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); - if alpha.is_some() { - hit!(CHROMA_SKIP_CFL_HITS); - hit!(SKIP_CFL_HITS); - } push_intra( y, u, @@ -2928,7 +2871,6 @@ pub(super) fn decode_leaf_rect8( // arm-without-clear-on-a-skip-route). Counted so a gate can tell a // stream that reaches this route from one that never does. if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); fctx.intrabc_chroma_tx.with(|c| c.set(None)); } (Grid::Zero(16), Grid::Zero(16)) @@ -3005,7 +2947,6 @@ pub(super) fn decode_leaf_rect8( &ZERO_RESIDUAL[..16], fctx, ); - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); fctx.intrabc_chroma_tx.with(|c| c.set(None)); (Grid::Zero(16), Grid::Zero(16)) } else { diff --git a/crates/ec-av1/src/decode/mod.rs b/crates/ec-av1/src/decode/mod.rs index 6656567f..da8caf0e 100644 --- a/crates/ec-av1/src/decode/mod.rs +++ b/crates/ec-av1/src/decode/mod.rs @@ -20,7 +20,6 @@ //! inside one, forcing the gathered-CDF partial-superblock path, is round 2 //! too). Anything outside that refuses with [`Error::unsupported`] rather than //! silently miscoding. -use crate::hits::{hit, hit_do}; use ec_av1_syntax::{ CdefParams, DeltaParams, LoopFilterParams, LoopRestorationParams, MAX_SEGMENTS, @@ -41,8 +40,6 @@ use ec_core::{Error, Result}; // itself was lifted by lane-av112bitc before that (the combines absorb the // CONV_BUF gain drop, `INTER_POST_ROUND - delta`, see `mc::combine_compound`). -mod counters; -pub use counters::*; mod frame_tile; @@ -670,7 +667,6 @@ pub(crate) fn warp_plane_allowed(w: usize, h: usize) -> bool { if w >= 8 && h >= 8 { return true; } - hit!(WARP_PLANE_SUPPRESS_HITS); false } @@ -776,7 +772,6 @@ fn maybe_read_delta_q( } let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; let reduced = if sign_negative { -abs } else { abs }; - hit!(DELTA_Q_HITS); let res = fctx.delta_q_res.with(|c| c.get()); fctx.current_q_idx .with(|c| c.set((c.get() + reduced * res).clamp(1, 255))); @@ -832,7 +827,6 @@ fn maybe_read_delta_lf( let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; let reduced = if sign_negative { -abs } else { abs }; cur[i] = (cur[i] + reduced * res).clamp(-63, 63); - hit!(DELTA_LF_HITS); } fctx.current_delta_lf.with(|c| c.set(cur)); } @@ -860,7 +854,6 @@ fn maybe_read_cdef_idx( } let idx = dec.literal(u32::from(bits)) as u8; fctx.cdef_transmitted.with(|c| c.set(true)); - hit!(CDEF_IDX_HITS); let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize); let sb_cols = fctx.cdef_sb_cols.with(|c| c.get()); if sb_cols > 0 { @@ -987,10 +980,6 @@ fn block_q_idx(fctx: &crate::decode::FrameCtx) -> i32 { if crate::envflags::env_flag!("EC_DQCOEFF") { eprintln!("OUR_Q base={base} seg={seg_id} q={q}"); } - hit_do!(BLOCK_Q_SPAN.with(|c| { - let (lo, hi) = c.get(); - c.set((lo.min(q), hi.max(q))); - });); q } @@ -1160,7 +1149,6 @@ fn read_segment_id( return pred as u8; } let coded = dec.symbol(&mut cdfs.segment_id[ctx]) as i32; - hit!(SEG_ID_HITS); let last_active = fctx.seg.with(|s| i32::from(s.borrow().last_active_seg_id)); let id = neg_deinterleave(coded, pred, last_active + 1).clamp(0, last_active); // Mirrors the oracle's own `EC_SEG mi_row=.. cdf=.. pred=.. coded=.. id=..` @@ -1263,7 +1251,6 @@ fn inter_segment_id( let id = if temporal_update { let ctx = seg_pred_ctx(mi_r, mi_c, fctx); let predicted = dec.symbol(&mut cdfs.segment_pred[ctx]) != 0; - hit!(SEG_PRED_HITS); stamp_seg_pred(mi_r, mi_c, w_mi, h_mi, u8::from(predicted), fctx); if predicted { predicted_segment_id(mi_r, mi_c, w_mi, h_mi, fctx) @@ -1345,9 +1332,6 @@ fn tu_reach( ) -> Reach { let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, block); let standalone = Reach::of(tx, px + col_off, py + row_off, width, height, fctx); - if fixed != standalone { - hit!(SPLIT_TU_REACH_FIX_HITS); - } fixed } @@ -1376,9 +1360,6 @@ fn tu_reach_rect( let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx_w, tx_h, block); if tx_w == tx_h { let standalone = Reach::of(tx_w, px + col_off, py + row_off, width, height, fctx); - if fixed != standalone { - hit!(SPLIT_TU_REACH_FIX_HITS); - } } fixed } @@ -1390,7 +1371,6 @@ static PREFILT_PICTURE_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic:: /// Records one decoded forward keyframe (see [`FWD_KF_HITS`]). pub(crate) fn note_fwd_kf() { - hit!(FWD_KF_HITS); } thread_local! { @@ -1420,34 +1400,13 @@ pub(crate) fn set_inter_tx_mode( } fn bump_ab16(arm: usize) { - hit_do! { - AB16_HITS.with(|c| { - let mut v = c.get(); - v[arm] += 1; - c.set(v); - }); - } } /// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`]. pub(crate) fn bump_inter_edge_strip(idx: usize) { - hit_do! { - INTER_EDGE_STRIP_HITS.with(|c| { - let mut v = c.get(); - v[idx] += 1; - c.set(v); - }); - } } fn bump_edge_both_cut(level: usize) { - hit_do! { - EDGE_BOTH_CUT_HITS.with(|c| { - let mut v = c.get(); - v[level] += 1; - c.set(v); - }); - } } // lane-av1muchroma site 1: the total number of samples by which @@ -1563,12 +1522,10 @@ pub(crate) fn frame_chroma_alloc_crop_shapes() -> usize { /// numbers. A counter that recomputed `shape >> ss` beside the allocation /// would have read the same value either way and proved nothing. fn note_frame_chroma_alloc(shape: (usize, usize), alloc: (usize, usize), ss: (usize, usize)) { - hit!(FRAME_CHROMA_ALLOC_CALLS); let (need_w, need_h) = (round_ss(shape.0, ss.0), round_ss(shape.1, ss.1)); // Decidability: the floor and the crop are the same number on this frame, // so the shortfall below is the same number the two forms would have given. if (need_w, need_h) != (shape.0 >> ss.0, shape.1 >> ss.1) { - hit!(FRAME_CHROMA_ALLOC_CROP_SHAPES); if crate::envflags::env_flag!("EC_AV1_CHROMA_ALLOC_SWEEP") { eprintln!( "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 } let want = need_w * need_h; let got = alloc.0 * alloc.1; - if want > got { - hit_do!(FRAME_CHROMA_ALLOC_SHORT_SAMPLES.with(|c| c.set(c.get() + want - got))); - } } /// lane-av1ibcfork: this decoder's half of the per-unit BIT INTERVAL -- the @@ -2629,7 +2583,6 @@ fn record_intrabc_mi_rect( /// Bump [`FIMV_FRAME_HITS`] -- called once per decoded frame header whose /// `force_integer_mv` bit is set. pub fn note_force_integer_mv_frame() { - hit!(FIMV_FRAME_HITS); } // lane-t900 r27: OBMC blends that actually READ a recorded switchable filter @@ -2700,13 +2653,6 @@ thread_local! { } fn bump_edge_part(slot: usize) { - hit_do! { - EDGE_PART_HITS.with(|c| { - let mut h = c.get(); - h[slot] += 1; - c.set(h); - }); - } } /// [`bump_edge32`] of `base + bit`, returning the bit -- the gathered edge @@ -2717,13 +2663,6 @@ fn bump_edge32_bit(base: usize, bit: usize) -> usize { } fn bump_edge32(slot: usize) { - hit_do! { - EDGE32_HITS.with(|c| { - let mut h = c.get(); - h[slot] += 1; - c.set(h) - }); - } } /// One 16x4 / 4x16 inter strip's chroma situation, handed to @@ -2750,13 +2689,6 @@ pub(crate) struct InterStripChroma { /// The single-reference MC parameters of the inter block that decoded /// last -- read by the next 1:4 strip to build its pair's chroma. fn bump_ab16_inter(arm: usize) { - hit_do! { - AB16_INTER_HITS.with(|c| { - let mut v = c.get(); - v[arm] += 1; - c.set(v); - }); - } } /// Everything [`decode_inter_block`] needs to fold temporal MV candidates @@ -2939,17 +2871,11 @@ pub(crate) fn cdef_straddle_units() -> usize { } fn note_sub8_chroma_tx(first_sub: TxType, chroma_ref: TxType, coeffs: bool) { - if coeffs && first_sub != chroma_ref { - hit!(SUB8_CHROMA_TX_FROM_REF_HITS); - } } /// Counts one [`CHROMA_EOB_CLASS1_HITS`] when `plane_idx`'s inherited /// `tx_type` put this block's `eob_pt` on the class-1 row. fn note_chroma_class1(plane_idx: usize, tx_type: TxType) { - if plane_idx > 0 && TxClass::of(tx_type) != TxClass::TwoD { - hit!(CHROMA_EOB_CLASS1_HITS); - } } // Which plane the in-flight INTRA reconstruction is writing (0=Y, 1=U, 2=V). diff --git a/crates/ec-av1/src/decode/post_filter.rs b/crates/ec-av1/src/decode/post_filter.rs index 2c603e25..6f22b8d6 100644 --- a/crates/ec-av1/src/decode/post_filter.rs +++ b/crates/ec-av1/src/decode/post_filter.rs @@ -164,7 +164,6 @@ pub(super) fn apply_cdef( if crate::envflags::env_flag!("EC_AV1_DEBUG_SKIP_CDEF") { return; } - cdef_scan_counters(skip_grid); // `cdef.bits == 0` still means "no filtering at all" whenever the single // (index 0) strength pair is all-zero -- the fast path every existing // gate stream takes. A `bits > 0` frame can still be all-zero-strength diff --git a/crates/ec-av1/src/decode/rect.rs b/crates/ec-av1/src/decode/rect.rs index 1f08f489..142d99bd 100644 --- a/crates/ec-av1/src/decode/rect.rs +++ b/crates/ec-av1/src/decode/rect.rs @@ -92,7 +92,6 @@ pub(super) fn read_intra_mode_rect( // offer the 14-symbol CFL alphabet on a 64-axis block (class // wrong-alphabet-same-value: same value, wrong interval, silent desync). let cfl = if cfl && bw.max(bh) > 32 { - hit!(NOCFL_UV_MODE_HITS); false } else { cfl @@ -134,10 +133,8 @@ pub(super) fn read_intra_mode_rect( // refused by name when it fires. if allow_intrabc_frame(fctx) { let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; - hit!(RECT_INTRABC_READS); istep!("intrabc", use_intrabc as i32); if use_intrabc { - hit!(INTRABC_HITS); // libaom `read_intrabc_info`: the DV read, then an immediate // return out of the mode-info read -- no `y_mode`, no `uv_mode`, // no angle deltas, no palette, no filter intra. The caller owns @@ -200,19 +197,12 @@ pub(super) fn read_intra_mode_rect( } else { None }; - if has_chroma && (9..=12).contains(&uv_mode) { - hit!(SMOOTH_UV_HITS); - } let angle_delta_uv = if has_chroma && (V_PRED..=D67_PRED).contains(&uv_mode) { - hit!(DIRECTIONAL_UV_HITS); read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) } else { 0 }; istep!("angle_uv", angle_delta_uv); - if angle_delta_uv != 0 { - hit!(UV_ANGLE_DELTA_HITS); - } // `read_palette_mode_info` (spec 5.11.13), rect-generalised // (lane-palette2 r4): same bsize-ctx-gated read as [`read_intra_mode`], // just keyed by [`palette_bsize_ctx_wh`] instead of the square-only @@ -223,10 +213,6 @@ pub(super) fn read_intra_mode_rect( let mut palette_y_pending: Option<(usize, [u16; 8])> = None; let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh) { - // r6: this is the exact site the removed blanket refusal used to - // guard -- reached for EVERY rect strip in a screen-content frame, - // independent of whether the block ends up using a palette. - hit!(RECT_SCREEN_CONTENT_HITS); let (mode_ctx, cache) = palette.unwrap_or((0, &[])); let use_palette_y = 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( } istep!("use_filter_intra", use_filter_intra as i32); if use_filter_intra { - hit!(FILTER_INTRA_HITS); let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); istep!("filter_intra_mode", fi_mode as i32); filter_intra = Some(fi_mode); @@ -287,8 +272,6 @@ pub(super) fn read_intra_mode_rect( palette_onscreen(mi_r, mi_c, bw, bh, fctx), false, ); - hit!(PALETTE_HITS); - hit!(PALETTE_RECT_HITS); PaletteY { size: n, colors, @@ -309,7 +292,6 @@ pub(super) fn read_intra_mode_rect( (ss_x(fctx), ss_y(fctx)), ); let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true); - hit!(PALETTE_UV_HITS); PaletteUv { size: n, u_colors, @@ -618,13 +600,6 @@ pub(super) fn decode_rect_split( (4, 8) => Some(3), _ => None, } { - hit_do! { - RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| { - let mut hits = c.get(); - hits[i] += 1; - c.set(hits); - }); - } } if !m.skip && chroma.is_none() && !chroma_tiled { // Diagnostic for the next caller that lands here (class @@ -648,10 +623,6 @@ pub(super) fn decode_rect_split( "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", )); } - hit!(RECT_SPLIT_TX_HITS); - if bw.max(bh) == 64 && bw / tx_w > 1 && bh / tx_h > 1 { - hit!(RECT_SPLIT_SB_INTERIOR_TU_HITS); - } // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. // A square unit reads through the ordinary square [`read_plane`]; a rect // one (a 1:4 strip's first split) reads through [`read_coeffs_rect`] with @@ -786,13 +757,6 @@ pub(super) fn decode_rect_split( if crate::envflags::env_flag!("EC_RECT64TU") { eprintln!("EC_RECT64TU mi={tu_mi:?} tx={tx_w}x{tx_h} mode={}", m.mode); } - hit_do! { - RECT64_CORNER_TU_HITS.with(|c| { - let mut v = c.get(); - v[usize::from(tx_h > tx_w)] += 1; - c.set(v); - }); - } let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra)); let (corner, tu_tx_type) = read_coeffs( @@ -1122,7 +1086,6 @@ pub(super) fn decode_rect_split( // `REFUSED: unsupported: AV1 tile (a Golomb tail longer // than this decoder reads)`. if cpx + cu_col * 4 >= u.true_width || cpy + cu_row * 4 >= u.true_height { - hit!(RECT_SPLIT_LOSSLESS_CHROMA_OFFTILE_HITS); continue; } 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( m.smooth_neighbor_uv, fctx, )?; - if span_x == 4 && span_y == 4 { - hit!(RECT_SPLIT_LOSSLESS_CHROMA444_HITS); - } neighbours.record_mi_chroma(cu_mi, span_x, span_y, plane_idx, &grid); ll_chroma_units.push((cu_mi, plane_idx, grid.clone(), span_x, span_y)); last[plane_idx - 1] = grid; @@ -1229,12 +1189,6 @@ pub(super) fn decode_rect_split( }; // lane-av1-422: the witness counter, keyed to ss (1,0) so only a 4:2:2 // frame's square chroma units count it. - if uw == uh && ss_x(fctx) == 1 && ss_y(fctx) == 0 { - hit!(CHROMA422_SQUARE_HITS); - } - if chroma_422_pair_wide { - hit!(CHROMA422_PAIR_WIDE_HITS); - } let (nw, nh) = (chroma_block_w / uw, chroma_block_h / uh); // lane-av1-422stripanchor: the pair's plane block is BLOCK_INVALID // whatever the pair size (`num_pels_log2_lookup[255]` reads 0xff in @@ -1363,14 +1317,6 @@ pub(super) fn decode_rect_split( if cu_reach.above_right != reach.above_right || cu_reach.below_left != reach.below_left { - hit!(RECT_TILED_CHROMA_UNIT_REACH_HITS); - } - if nw * nh > 1 { - match (nw, nh) { - (2, 1) => hit!(RECT_TILED_CHROMA_2X1_HITS), - (1, 2) => hit!(RECT_TILED_CHROMA_1X2_HITS), - _ => hit!(RECT_TILED_CHROMA_NXN_HITS), - } } // 32x32 does not fit read_coeffs_rect's scratch (768). The // square reader is the path every other 32x32 chroma unit uses. @@ -1510,9 +1456,6 @@ pub(super) fn decode_rect_split( // (lane-rectsplit r4: lifting the split-transform refusal moved // superblock strips onto this path, so only counting there would // leave the delta_q gate's counter silent for them). - if bw.max(bh) == 64 && fctx.current_q_idx.with(|c| c.get()) != i32::from(base_q_idx) { - hit!(RECT64_QIDX_DRIFT_HITS); - } let residual = dequant_and_inverse_typed_wh( &levels, chroma_w, @@ -1985,14 +1928,6 @@ pub(super) fn decode_intra_rect_in_inter( mi_r * MI ); } - hit_do! { - INTRA16X4_IN_INTER_HITS.with(|h| { - let mut v = h.get(); - v[usize::from(!horz)] += 1; - v[2] += usize::from(has_chroma); - h.set(v); - }); - } return Ok(()); } // lane-inter128intra r1: the 128 superblock's PARTITION_HORZ/VERT half @@ -2143,13 +2078,6 @@ pub(super) fn decode_intra_rect_in_inter( (32, 8) => 2, _ => 3, }; - hit_do! { - INTRA_RECT4_IN_INTER_HITS.with(|h| { - let mut v = h.get(); - v[shape] += 1; - h.set(v); - }); - } return Ok(()); } crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); @@ -2177,9 +2105,6 @@ pub(super) fn decode_intra_rect_in_inter( } else { 0 }; - if angle_delta_y != 0 { - hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS); - } // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the // superblock-level strip reads the no-CFL alphabet -- the same split // [`read_intra_mode_rect`] makes for [`decode_block_rect64`]. @@ -2204,9 +2129,6 @@ pub(super) fn decode_intra_rect_in_inter( dec.debug_state().0 ); } - if (9..=12).contains(&uv_mode) { - hit!(SMOOTH_UV_HITS); - } let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { Some(read_cfl_alphas(dec, cdfs)) } else { @@ -2218,15 +2140,10 @@ pub(super) fn decode_intra_rect_in_inter( uv_mode }; let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { - hit!(DIRECTIONAL_UV_HITS); read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) } else { 0 }; - if angle_delta_uv != 0 { - hit!(UV_ANGLE_DELTA_HITS); - hit!(INTRA_IN_INTER_ANGLE_DELTA_UV_HITS); - } // `read_palette_mode_info` (spec 5.11.13), in the position // `read_intra_block_mode_info` writes it: after the chroma mode and // before `filter_intra`. lane-t900 r21: a `--tune-content=screen` inter @@ -2242,7 +2159,6 @@ pub(super) fn decode_intra_rect_in_inter( let mut palette_y_pending: Option<(usize, [u16; 8])> = None; let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh) { - hit!(INTRA_RECT_IN_INTER_SCREEN_HITS); let use_palette_y = mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0; if use_palette_y { @@ -2284,8 +2200,6 @@ pub(super) fn decode_intra_rect_in_inter( && let Some(class) = filter_intra_size_class_rect(bw, bh) && dec.symbol(&mut cdfs.filter_intra[class]) != 0 { - hit!(FILTER_INTRA_HITS); - hit!(INTRA_IN_INTER_FILTER_INTRA_HITS); filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); } // `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( palette_onscreen(mi_r, mi_c, bw, bh, fctx), false, ); - hit!(PALETTE_HITS); - hit!(PALETTE_RECT_HITS); - hit!(INTRA_IN_INTER_PALETTE_Y_HITS); PaletteY { size: n, colors, @@ -2317,8 +2228,6 @@ pub(super) fn decode_intra_rect_in_inter( (ss_x(fctx), ss_y(fctx)), ); let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true); - hit!(PALETTE_UV_HITS); - hit!(INTRA_IN_INTER_PALETTE_UV_HITS); PaletteUv { size: n, u_colors, @@ -2337,13 +2246,7 @@ pub(super) fn decode_intra_rect_in_inter( // context-read-from-one-cell). let coarse_pair = neighbours.modes_above_left(r, c); let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left_mi(mi_r, mi_c, coarse_pair); - if (nb_above_mode, nb_left_mode) != coarse_pair { - hit!(EDGE_FILTER_MI_FIX_HITS); - } let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx); // lane-av1mixloss: the lossless-segment early return (`decodeframe.c:1203`) // precedes `TX_MODE_SELECT`, so a lossless-segment intra-rect block inside @@ -2367,19 +2270,6 @@ pub(super) fn decode_intra_rect_in_inter( } else { 0 }; - if depth != 0 || lossless(fctx) { - hit!(TX_DEPTH_HITS); - // lane-intrasplit r1: a split intra strip in an inter frame walks the - // key frame's own per-TU path ([`decode_rect_split`] below); what was - // wrong when this refusal was written was the depth SYMBOL, not the walk. - hit_do! { - INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(|h| { - let mut v = h.get(); - v[depth.min(2)] += 1; - h.set(v); - }); - } - } // lane-intrasplit r3: print EVERY intra strip with its depth, not only the // split ones -- a `depth=0`-only stream is a witness gap in the SOURCE, and // the two are indistinguishable when the diagnostic fires on splits alone. @@ -2467,13 +2357,6 @@ pub(super) fn decode_intra_rect_in_inter( 32 => 1, _ => 2, }; - hit_do! { - INTRA_RECT_IN_INTER_HITS.with(|h| { - let mut v = h.get(); - v[class] += 1; - h.set(v); - }); - } Ok(()) } @@ -2514,21 +2397,10 @@ pub(super) fn decode_intrabc_rect( base_q_idx: u8, fctx: &crate::decode::FrameCtx, ) -> Result<()> { - hit!(INTRABC_RECT_HITS); // [horz, vert]: see `INTRABC_RECT_CODED_HITS` / `INTRABC_RECT_SKIPPED_HITS`. let idx = usize::from(bh > bw); if skip { - INTRABC_RECT_SKIPPED_HITS.with(|c| { - let mut seen = c.get(); - seen[idx] += 1; - c.set(seen); - }); } else { - INTRABC_RECT_CODED_HITS.with(|c| { - let mut seen = c.get(); - seen[idx] += 1; - c.set(seen); - }); } let (px, py) = (mi_c * MI, mi_r * MI); // lane-whtshape: a LOSSLESS block's chroma plane block is @@ -2576,12 +2448,6 @@ pub(super) fn decode_intrabc_rect( skip, fctx, )?; - if leaves.is_some() { - hit!(INTRABC_RECT_VARTX_HITS); - } - if ss_x(fctx) == 0 && ss_y(fctx) == 0 { - hit!(IBC_RECT_CHROMA_FOOTPRINT_444_HITS); - } // lane-ibc444c: per-block geometry, for the chroma-tail attribution. if crate::envflags::env_flag!("EC_IBCBLOCK") { eprintln!( @@ -2704,19 +2570,6 @@ pub(super) fn decode_intrabc_rect( fctx, ); if let Some(ls) = leaves.as_ref() { - // lane-av1-loss64, merged: the same reset [`decode_intrabc_owned_rect`]'s - // skip arm performs -- libaom `av1_reset_entropy_context` - // (`if (mbmi->skip_txfm)`, decodeframe.c:1262 -> blockd.c:58): a - // SKIPPED block zeroes its whole entropy-band footprint. This - // helper serves `decode_block_rect4`'s 1:4 strips on this tree, - // so a skipped lossless strip whose `leaves` resolved (every - // lossless frame -- `read_block_tx_size_rect`'s lossless arm - // returns the 4x4 grid before it looks at `skip`) left the - // PREVIOUS occupant's luma bands standing and the NEXT block's - // partition parse diverged from libaom's: the 320x242 lossless - // sb128 gate read a phantom unskipped 8x32 intrabc strip at - // mi(56,66) right after the skipped 8x16 one at mi(48,66). - hit!(SKIP_LOSSLESS_BAND_RESET_HITS); for &(row, col, tw, th) in ls { neighbours.record_mi_luma_rect( (mi_r + row, mi_c + col), @@ -2898,21 +2751,6 @@ pub(super) fn decode_intrabc_rect( around[2] = c[2]; } if lossless(fctx) { - // lane-whtshape: at lossless libaom codes TX_4X4 on EVERY - // plane of a block -- `read_tx_size` returns `TX_4X4` for a - // lossless block before it looks at a tree, `read_tx_mode` - // already forced `ONLY_4X4` for the frame, and - // `get_vartx_max_txsize` returns `TX_4X4` for every plane - // -- so this block's chroma plane block is a - // `(cw/4) * (ch/4)` raster of 4x4 units, PLANE-MAJOR - // (`decode_token_recon_block`: every U unit, then every V - // unit), not the single rect unit the two - // `read_inter_plane_rect` calls below read. That single - // 8x4 unit is what reached the lossless WHT with the wrong - // shape (the `debug_assert_eq!((w, h), (4, 4))` this lane - // replaced). Same helper, same walk, as the inter 8x8 and - // 128 paths. - hit!(INTRABC_RECT_LOSSLESS_CHROMA4_HITS); let mut uo = vec![0i32; cside * cside]; let mut vo = vec![0i32; cside * cside]; read_inter_chroma_lossless( @@ -3120,7 +2958,6 @@ pub(super) fn decode_intrabc_128rect( base_q_idx: u8, fctx: &crate::decode::FrameCtx, ) -> Result<()> { - hit!(INTRABC_128RECT_HITS); if crate::envflags::env_flag!("EC_AV1_TRACE") { let (rng, _) = dec.debug_state(); eprintln!( @@ -3272,12 +3109,6 @@ pub(super) fn decode_intrabc_128rect( fctx, ); if let Some(ls) = leaves.as_ref() { - // A LOSSLESS frame's `read_block_tx_size_rect` resolves the TX_4X4 - // grid before it looks at `skip`; the skipped block still zeroes - // its entropy-band footprint over every unit (libaom - // `av1_reset_entropy_context` under `if (mbmi->skip_txfm)`) -- - // the same arm [`decode_intrabc_rect`]'s loss64 merge added. - hit!(SKIP_LOSSLESS_BAND_RESET_HITS); for &(row, col, tw, th) in ls { neighbours.record_mi_luma_rect( (mi_r + row, mi_c + col), @@ -3540,8 +3371,6 @@ pub(super) fn decode_intrabc_128rect( st.dc, st.level ); } - hit!(CHROMA_SPLIT_TX_HITS); - INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.set(c.get() + 1)); // lane-av1-ibcrect: per-unit chroma context -- the // end-of-block record's composed-grid re-stamp // must not stand (replayed below). @@ -3826,9 +3655,6 @@ pub(super) fn decode_block_rect( ); } let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } // lane-chroma r3: chroma's own edge-filter-strength neighbour check // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's // `uv_mode`, not the luma one. @@ -3839,9 +3665,6 @@ pub(super) fn decode_block_rect( // rectangle just as happily), so a `use_filter_intra` strip at this level // predicts instead of refusing. The below-16x16 leaf arm // (`decode_leaf_rect`) keeps the refusal: it has no gate of its own. - if filter_intra.is_some() { - hit!(FILTER_INTRA_RECT_HITS); - } let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { @@ -3889,7 +3712,6 @@ pub(super) fn decode_block_rect( fctx, ); if depth != 0 || lossless(fctx) { - hit!(TX_DEPTH_HITS); // lane-rectsplit r1: a split transform is predicted and reconstructed // per transform unit, each unit taking its edges from the previous // unit's reconstruction inside this same strip (spec 5.11.36) -- @@ -3922,9 +3744,6 @@ pub(super) fn decode_block_rect( ) }), }; - if palette_y.is_some() || palette_uv.is_some() { - hit!(PALETTE_SPLIT_TX_HITS); - } decode_rect_split( dec, cdfs, @@ -3957,7 +3776,6 @@ pub(super) fn decode_block_rect( .as_ref() .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); - hit!(RECT_PARTITION_HITS); return Ok(()); } let (tx_w, tx_h) = (bw, bh); @@ -4315,7 +4133,6 @@ pub(super) fn decode_block_rect( uv_predict_mode, &[&luma_levels[..], &u_levels[..], &v_levels[..]], ); - hit!(RECT_COEFF_HITS); } } let (py_size, py_colors) = palette_y @@ -4336,7 +4153,6 @@ pub(super) fn decode_block_rect( 0, fctx, ); - hit!(RECT_PARTITION_HITS); if crate::envflags::env_flag!("EC_AV1_TRACE") { eprintln!("TRACE_RECT32_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh}"); } @@ -4412,9 +4228,6 @@ pub(super) fn decode_leaf_rect( let (above_mode, left_mode) = neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode)); let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } // The palette-Y mode CDF row is picked by the neighbours' palette use // (`palette_ctx_and_cache`), so this sub-16x16 leaf must pass its own real // ctx/cache -- reading `palette_y_mode` off row 0 when a neighbour did use @@ -4478,9 +4291,6 @@ pub(super) fn decode_leaf_rect( // lane-kf900 r4: palette prediction on this shape, the same colour-index // map -> base colours buffer [`decode_block_rect`] hands each // `reconstruct_rect` through [`set_palette_pred`]. - if palette_y.is_some() || palette_uv.is_some() { - hit!(RECT4_PALETTE_HITS); - } let palette_y_buf: Option> = palette_y .as_ref() .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect()); @@ -4499,14 +4309,6 @@ pub(super) fn decode_leaf_rect( if crate::envflags::env_flag!("EC_AV1_RECTX_TRACE") { eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}"); } - if filter_intra.is_some() { - // lane-fistrip r1: `predict_filter_intra` already walks its 4x2 - // patches over a true `bw`x`bh` block (lane-rectsplit r1), so an - // 8x16/16x8 strip predicts through the same call `reconstruct_rect` - // below already makes; this refusal was square-only prose. - hit!(FILTER_INTRA_RECT_HITS); - hit!(FILTER_INTRA_RECT_SUB16_HITS); - } let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { @@ -4566,11 +4368,6 @@ pub(super) fn decode_leaf_rect( fctx, ); if depth != 0 || lossless(fctx) { - // The same per-transform-unit walk the bigger strips take - // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at - // depth 2), addressed at this leaf's own mi position. - hit!(TX_DEPTH_HITS); - hit!(SUB16_SPLIT_HITS); let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); let modes = RectStripModes { skip, @@ -4588,9 +4385,6 @@ pub(super) fn decode_leaf_rect( palette_y: palette_y_buf.clone(), palette_uv: palette_uv_bufs.clone(), }; - if palette_y.is_some() || palette_uv.is_some() { - hit!(PALETTE_SPLIT_TX_HITS); - } decode_rect_split( dec, cdfs, @@ -4908,7 +4702,6 @@ pub(super) fn decode_leaf_rect( smooth_neighbor_uv, fctx, ); - hit!(RECT_LEAF_COEFF_HITS); } neighbours.record_mi_rect( leaf_mi, diff --git a/crates/ec-av1/src/decode/rect4.rs b/crates/ec-av1/src/decode/rect4.rs index 5a25d65f..f19a407d 100644 --- a/crates/ec-av1/src/decode/rect4.rs +++ b/crates/ec-av1/src/decode/rect4.rs @@ -117,9 +117,6 @@ pub(super) fn decode_block_rect4( // [`decode_block_rect`] does one aspect ratio up -- the colour-index map // mapped through the base colours IS the prediction (it reads no edge // pixels), handed to each `reconstruct_rect` through [`set_palette_pred`]. - if palette_y.is_some() || palette_uv.is_some() { - hit!(RECT4_PALETTE_HITS); - } let palette_y_buf: Option> = palette_y .as_ref() .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect()); @@ -136,9 +133,6 @@ pub(super) fn decode_block_rect4( .as_ref() .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so // `r * (SUB / MI)` names a different mi column and the chroma @@ -147,11 +141,8 @@ pub(super) fn decode_block_rect4( // with luma bit-exact). let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx); if filter_intra.is_some() { - hit!(FILTER_INTRA_RECT_HITS); if bw > bh { - hit!(FILTER_INTRA_RECT4_HORZ_HITS); } else { - hit!(FILTER_INTRA_RECT4_VERT_HITS); } } let uv_predict_mode = if uv_mode == UV_CFL_PRED { @@ -192,24 +183,7 @@ pub(super) fn decode_block_rect4( fctx, ); if depth != 0 || lossless(fctx) { - // lane-rectsplitx r1: the per-transform-unit walk, at this strip's - // real mi position (strips 1 and 3 of a HORZ_4 start 8 px into a - // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16 - // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8; - // both interleave in every real stream. - hit!(TX_DEPTH_HITS); let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); - // lane-rectsplitx r2: both depths ship together, as the r1 handoff - // predicted -- depth 1 fires FIRST in every attempt that splits at - // all, so a depth-2-only lift could never be gated. The r1 mismatch - // was never the rect unit: it was the neighbour MODE the strip reads - // (see `modes_above_left_mi`). - let which = if depth == 1 { - &RECT4_SPLIT_DEPTH1_HITS - } else { - &RECT4_SPLIT_DEPTH2_HITS - }; - hit_do! { which.with(|c| c.set(c.get() + 1)); } let modes = RectStripModes { skip, mode, @@ -223,9 +197,6 @@ pub(super) fn decode_block_rect4( palette_y: palette_y_buf.clone(), palette_uv: palette_uv_bufs.clone(), }; - if palette_y.is_some() || palette_uv.is_some() { - hit!(PALETTE_SPLIT_TX_HITS); - } decode_rect_split( dec, cdfs, @@ -254,12 +225,7 @@ pub(super) fn decode_block_rect4( pal_uv_colors, ); if bw > bh { - hit!(RECT4_32_HORZ_HITS); } else { - hit!(RECT4_32_VERT_HITS); - } - if !skip { - hit!(RECT4_COEFF_HITS); } // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter @@ -369,7 +335,6 @@ pub(super) fn decode_block_rect4( TxType::DctDct, 0, )?; - hit!(RECT4_COEFF_HITS); let luma_residual = dequant_and_inverse_typed_wh( &luma_levels, bw, @@ -499,9 +464,7 @@ pub(super) fn decode_block_rect4( pal_uv_colors, ); if bw > bh { - hit!(RECT4_32_HORZ_HITS); } else { - hit!(RECT4_32_VERT_HITS); } // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter @@ -568,7 +531,6 @@ pub(super) fn decode_block_rect4( } let (v_levels, v_tx_type) = planes.pop().expect("plane 2"); let (u_levels, u_tx_type) = planes.pop().expect("plane 1"); - hit!(RECT4_COEFF_HITS); let luma_residual = dequant_and_inverse_typed_wh( &luma_levels, bw, @@ -658,9 +620,7 @@ pub(super) fn decode_block_rect4( pal_uv_colors, ); if bw > bh { - hit!(RECT4_32_HORZ_HITS); } else { - hit!(RECT4_32_VERT_HITS); } // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter @@ -805,9 +765,7 @@ pub(super) fn decode_block_rect4( pal_uv_colors, ); if bw > bh { - hit!(RECT4_32_HORZ_HITS); } else { - hit!(RECT4_32_VERT_HITS); } // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter @@ -982,9 +940,6 @@ pub(super) fn decode_intrabc_owned_rect( let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); let side = bw.max(bh); let cside = cw.max(ch); - if ss_x(fctx) == 0 && ss_y(fctx) == 0 { - hit!(IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS); - } let saved_reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get); let saved_tx = fctx.tx_select_inter.with(std::cell::Cell::get); fctx.reduced_tx_set_inter.with(|c| c.set(reduced_tx_set)); @@ -1063,20 +1018,6 @@ pub(super) fn decode_intrabc_owned_rect( fctx, ); if let Some(ls) = leaves.as_ref() { - // libaom `av1_reset_entropy_context` (`if (mbmi->skip_txfm)`, - // decodeframe.c:1262 -> blockd.c:58): a SKIPPED block zeroes its - // whole entropy-band footprint. The non-skip arm below writes - // those bands per transform unit and the tail's - // `record_split_luma_rect_mi` writes chroma only, so without - // this walk a skipped strip whose `leaves` resolved (every - // lossless frame -- `read_block_tx_size_rect`'s lossless arm - // returns the 4x4 grid before it looks at `skip`) leaked the - // PREVIOUS occupant's luma bands into the next block's - // `txb_skip`/coefficient contexts (lane-av1-loss64: the skipped - // 8x16 intrabc strip at mi(48,66) of the 320x242 lossless sb128 - // stream left a stale 7 in left[48] and mi(48,68)'s first - // transform unit read `txb_skip_ctx` 3 where aomdec reads 1). - hit!(SKIP_LOSSLESS_BAND_RESET_HITS); for &(row, col, tw, th) in ls { neighbours.record_mi_luma_rect( (mi_r + row, mi_c + col), @@ -1195,7 +1136,6 @@ pub(super) fn decode_intrabc_owned_rect( // `TX_MODE_LARGEST`); the routing here is identical, so a future // witness takes the same code. let around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { - hit!(IBC_OWNED_RECT_422_PAIR_HITS); neighbours.around_mi_422_chroma((mi_r, mi_c), bw, bh) } else { neighbours.around_mi_rect((mi_r, mi_c), bw, bh) @@ -1295,7 +1235,6 @@ pub(super) fn decode_intrabc_owned_rect( // agree -- `fixtures/ibc422_nonsplit_ctx.obu` is the stream where // they do not). let around_chroma = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { - hit!(IBC_OWNED_RECT_422_PAIR_HITS); neighbours.around_mi_422_chroma((mi_r, mi_c), bw, bh) } else { around @@ -1603,7 +1542,6 @@ pub(super) fn decode_rect4_16_intrabc( fctx: &crate::decode::FrameCtx, ) -> Result<(usize, Option, (usize, usize))> { let _ = base_q_idx; - hit!(RECT4_16_INTRABC_HITS); let (bw, bh) = if horz { (16usize, 4usize) } else { (4, 16) }; let (mi_w, mi_h) = (bw / MI, bh / MI); let (px, py) = (lmi.1 * MI, lmi.0 * MI); @@ -1670,15 +1608,9 @@ pub(super) fn decode_rect4_16_intrabc( // [BLOCK_4X16][1][0]` is BLOCK_INVALID at 4:2:2, so only HORZ reaches it. let own444 = ss_x(fctx) == 0 && ss_y(fctx) == 0; let own422 = ss_x(fctx) == 1 && ss_y(fctx) == 0 && horz; - if own422 && has_chroma { - hit!(INTRABC_RECT4_OWN_CHROMA422_HITS); - } // One predicate for "this strip IS its own chroma reference": the strip's // own mi position, its own luma extent, and per-axis subsampled sizes. let own_chroma = own444 || own422; - if ss_x(fctx) == 0 && ss_y(fctx) == 0 && has_chroma { - hit!(INTRABC_RECT4_OWN_CHROMA444_HITS); - } let (pw, ph) = if own444 { (bw, bh) } else if horz { @@ -2184,7 +2116,6 @@ pub(super) fn decode_rect4_16_intrabc( } let mut last_uv = None; if has_chroma { - hit!(RECT4_16_CHROMA_HITS); // lane-av1422luma: the uv-mode publication and the left/above skip // state below are the STRIP's own at 4:2:2 / 4:4:4 -- publishing the // 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( last_uv = Some(DC_PRED); } if horz { - hit!(RECT4_16_HORZ_HITS); } else { - hit!(RECT4_16_VERT_HITS); } record_strip_palette(neighbours, lmi, bw, bh, 0, [0u16; 8], 0, [0u16; 8]); if leaves.is_none() { @@ -2350,9 +2279,6 @@ pub(super) fn decode_rect4_16_strip( fctx, ); } - if palette_y.is_some() || palette_uv.is_some() { - hit!(RECT4_PALETTE_HITS); - } // The colour-index map through the base colours IS the prediction. // Chroma's map is the PAIR's 8x4 (4x8) block, matching the one // chroma transform this closing strip codes. @@ -2366,12 +2292,6 @@ pub(super) fn decode_rect4_16_strip( ) }); let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } - if filter_intra.is_some() { - hit!(FILTER_INTRA_RECT_HITS); - } // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the // depth symbol is the 3-symbol `tx_size_cat1` -- not the 2-symbol @@ -2397,10 +2317,6 @@ pub(super) fn decode_rect4_16_strip( } else { 0 }; - if depth != 0 { - hit!(TX_DEPTH_HITS); - hit!(RECT4_16_SPLIT_HITS); - } let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); let (px, py) = (lmi.1 * MI, lmi.0 * MI); 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( smooth_neighbor, fctx, ); - if tu_grid.iter().any(|&l| l != 0) { - hit!(RECT4_16_COEFF_HITS); - } neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); } else { let tu_around = neighbours.around_mi(tu_mi, tx_w)[0]; @@ -2534,9 +2447,6 @@ pub(super) fn decode_rect4_16_strip( smooth_neighbor, fctx, )?; - if tu_grid.iter().any(|&l| l != 0) { - hit!(RECT4_16_COEFF_HITS); - } neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid); } } @@ -2620,7 +2530,6 @@ pub(super) fn decode_rect4_16_strip( smooth_neighbor, fctx, ); - hit!(RECT4_16_COEFF_HITS); levels }; neighbours.record_mi_luma_rect(lmi, bw, bh, &levels); @@ -2641,7 +2550,6 @@ pub(super) fn decode_rect4_16_strip( } } if has_chroma { - hit!(RECT4_16_CHROMA_HITS); // lane-av1-444: at 4:4:4 there is no pair -- every strip is its // own chroma reference and codes its own 16x4 / 4x16 chroma // block. (`set_mi_offsets`'s chroma snap is the zero offset at @@ -2687,9 +2595,6 @@ pub(super) fn decode_rect4_16_strip( } else { uv_mode }; - if (V_PRED..=D67_PRED).contains(&uv_predict_mode) { - hit!(RECT4_16_CHROMA_DIR_HITS); - } let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height, fctx); // lane-kf1200 r1: the chroma edge-filter type reads the neighbours // 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( false, ) { - hit!(RECT4_16_UV_PAIR_FILT_HITS); } // lane-av1-rect14: a lossless frame forces TX_4X4 on every plane // (`av1_get_tx_size`, blockd.h:1381). The pair's chroma block is @@ -2739,7 +2643,6 @@ pub(super) fn decode_rect4_16_strip( // mi(1,20) uv_mode matched, the following skip did not). let lossless_pair = lossless(fctx); let (u_levels, v_levels) = if lossless_pair { - hit!(RECT4_16_LOSSLESS_CHROMA_HITS); if skip { for plane in 1..3usize { for rr in 0..ch / 4 { @@ -2910,7 +2813,6 @@ pub(super) fn decode_rect4_16_strip( plane, &cu_grid, ); - hit!(CHROMA_SPLIT_TX_HITS); let dst = if plane == 1 { &mut uo } else { &mut vo }; for row in 0..4 { let start = (oy + row) * cw + ox; @@ -2929,9 +2831,6 @@ pub(super) fn decode_rect4_16_strip( // DC + alpha * luma-AC. Dropping the CfL term here left a // chroma-only bounded box on ReelC's key frames. let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph)); - if alpha.is_some() { - hit!(CHROMA_SKIP_CFL_HITS); - } for plane in [1usize, 2] { if chroma422_pair16 { // lane-av1-422o: two TX_4X8 units, each predicted on @@ -3116,7 +3015,6 @@ pub(super) fn decode_rect4_16_strip( // a restored `/2 chroma height` lands on (8,4) and the // counter reads 0. (8, 8) => { - hit!(CHROMA422_SQUARE_HITS); (TxbSet::Chroma8, default_scan(8)) } // lane-av1-422o: with the `chroma422_pair16` arm above, @@ -3226,9 +3124,7 @@ pub(super) fn decode_rect4_16_strip( last_uv_mode = Some(uv_predict_mode); } if horz { - hit!(RECT4_16_HORZ_HITS); } else { - hit!(RECT4_16_VERT_HITS); } let (pal_y_size, pal_y_colors) = palette_y .as_ref() @@ -3354,17 +3250,7 @@ pub(super) fn decode_block_rect64( fctx, ); } - if (palette_y.is_some() || palette_uv.is_some()) && !skip { - // lane-t900 r34: a non-skip palette block on a superblock-level strip - // -- counted so its gate cannot go vacuous (this was a refusal until - // r34; see the gate `a_real_aomenc_palette_stream_with_8x8_leaves_ - // decodes_pixel_exact`). - hit!(PALETTE_SB_STRIP_HITS); - } let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c, fctx); if filter_intra.is_some() { @@ -3423,7 +3309,6 @@ pub(super) fn decode_block_rect64( fctx, ); if depth != 0 || lossless(fctx) { - hit!(TX_DEPTH_HITS); // lane-rectsplit r1/r4: the superblock-level strip splits its // transform through the very same per-unit path as its 32x32-level // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 @@ -3431,12 +3316,6 @@ pub(super) fn decode_block_rect64( // measured the old square formula mis-tiling exactly that strip). let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); if bw.max(bh) / bw.min(bh) == 4 { - let which = if depth == 1 { - &RECT4_SPLIT_DEPTH1_HITS - } else { - &RECT4_SPLIT_DEPTH2_HITS - }; - hit_do! { which.with(|c| c.set(c.get() + 1)); } } if crate::envflags::env_flag!("EC_SBPART_DUMP64") { eprintln!( @@ -3465,9 +3344,6 @@ pub(super) fn decode_block_rect64( ) }), }; - if palette_y.is_some() || palette_uv.is_some() { - hit!(PALETTE_SPLIT_TX_HITS); - } decode_rect_split( dec, cdfs, @@ -3506,8 +3382,6 @@ pub(super) fn decode_block_rect64( // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The // bands carry the SPLIT unit's size, not the block's. txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); - hit!(RECT64_SPLIT_TXFM_PUBLISH_HITS); - hit!(RECT_PARTITION_HITS); return Ok(()); } let (tx_w, tx_h) = (bw, bh); @@ -3673,9 +3547,6 @@ pub(super) fn decode_block_rect64( } { let cur = block_q_idx(fctx); - if cur != i32::from(base_q_idx) { - hit!(RECT64_QIDX_DRIFT_HITS); - } if crate::envflags::env_flag!("EC_AV1_TRACE") { eprintln!( "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( // nothing. The `bigger` guard is what makes a hit PROOF // that the tiled arm ran, rather than proof that some // palette chroma block existed. - if bigger { - hit!(CHROMA_PALETTE_WINDOW_HITS); - } } read_plane( dec, @@ -3883,9 +3751,6 @@ pub(super) fn decode_block_rect64( // nothing. The `bigger` guard is what makes a hit PROOF // that the tiled arm ran, rather than proof that some // palette chroma block existed. - if bigger { - hit!(CHROMA_PALETTE_WINDOW_HITS); - } } push_intra_rect( y, @@ -3949,7 +3814,6 @@ pub(super) fn decode_block_rect64( for (cu_mi, plane, unit, span_w, span_h) in &tiled_chroma_units { neighbours.record_mi_chroma(*cu_mi, *span_w, *span_h, *plane, unit); } - hit!(RECT_COEFF_HITS); } let (py_size, py_colors) = palette_y .as_ref() @@ -3980,12 +3844,6 @@ pub(super) fn decode_block_rect64( // 3840x1608 10-bit stream's first silent wall, decode-order frame 33 at // mi(16,480)). Same write as [`set_txfm_ctxs`], rect-aware. txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); - hit!(SB_RECT_HITS); - match (bw, bh) { - (64, 16) => hit!(SB_RECT4_HORZ_HITS), - (16, 64) => hit!(SB_RECT4_VERT_HITS), - _ => {} - } if crate::envflags::env_flag!("EC_AV1_TRACE") { let (rng, _) = dec.debug_state(); eprintln!("TRACE_RECT64_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} rng={rng}"); diff --git a/crates/ec-av1/src/decode/replay.rs b/crates/ec-av1/src/decode/replay.rs index 0de1f51c..6c0fea65 100644 --- a/crates/ec-av1/src/decode/replay.rs +++ b/crates/ec-av1/src/decode/replay.rs @@ -471,9 +471,6 @@ pub(super) fn cdef_band( while mi_r < r_hi { let mut mi_c = 0usize; while mi_c < skip_grid.mi_cols { - if skip_grid.is_skip_txfm(mi_r, mi_c) { - hit!(CDEF_SKIPPED_UNITS); - } if !skip_grid.is_skip_txfm(mi_r, mi_c) { let sidx = strength_idx(mi_r, mi_c); let (ox, oy) = (mi_c * 4, mi_r * 4); @@ -524,7 +521,6 @@ pub(super) fn cdef_band( || cdef.uv_pri_strength[sidx] != 0 || cdef.uv_sec_strength[sidx] != 0) { - hit!(CDEF_STRADDLE_UNITS); } if enable_primary || enable_secondary { cdef_filter_block( diff --git a/crates/ec-av1/src/decode/sub8_inter.rs b/crates/ec-av1/src/decode/sub8_inter.rs index 9c3a403f..49368adc 100644 --- a/crates/ec-av1/src/decode/sub8_inter.rs +++ b/crates/ec-av1/src/decode/sub8_inter.rs @@ -62,7 +62,6 @@ pub(super) fn decode_inter_sub8_split4( ) -> Result<()> { const LAST_FRAME: i8 = 1; const B4: usize = 4; - hit!(SUB8_INTER_SPLIT_HITS); let (gr, gc) = group_mi; let (gpx, gpy) = (gc * MI, gr * MI); let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx)); @@ -143,17 +142,6 @@ pub(super) fn decode_inter_sub8_split4( fctx.tx_select_inter.with(std::cell::Cell::get), ); } - // lane-sub8x4 r2: the refusal and its `EC_SUB8INTRA_DECODE` bypass - // are gone -- `a_real_aomenc_inter_sequence_with_intra_sub8x8_ - // leaves_decodes_pixel_exact` (stream.rs) decodes 12 real aomenc - // streams carrying this arm pixel-exact vs ffmpeg. - hit_do! { - SUB8_INTRA_RECT_HITS.with(|h| { - let mut st = h.get(); - st[4] += 1; - h.set(st); - }); - } // lane-sub8intra: the `BLOCK_4X4` twin of the HORZ/VERT arm -- // same [`decode_intra_sub8_leaf`], no tx-depth symbol, chroma on // the chroma-reference sub-blocks (`is_chroma_reference`: the @@ -209,9 +197,6 @@ pub(super) fn decode_inter_sub8_split4( // each of the group's pieces (luma and its 2x2 chroma) carries its // OWN factor because each can name a different `ref_frame`. let luma_scale = scale_of((ref_width, ref_height), frame_size); - if !luma_scale.is_unscaled() { - hit!(SCALED_SUB8_HITS); - } let gm_table = build_gm_mv_table( global_motion, rmi, @@ -245,8 +230,6 @@ pub(super) fn decode_inter_sub8_split4( tpl, ); let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; - if !not_new { - } let mut is_globalmv = false; let (mv, is_new_mv) = if !not_new { let mut idx = 0usize; @@ -271,8 +254,6 @@ pub(super) fn decode_inter_sub8_split4( ) } else { let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; - if !not_zero { - } is_globalmv = !not_zero; let mv = if !not_zero { gm_table[(ref_frame - LAST_FRAME) as usize] @@ -336,9 +317,6 @@ pub(super) fn decode_inter_sub8_split4( // `is_nontrans_global_motion` returns 0 for // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model -- // so a GLOBALMV sub-block here always reads its interp filter. - if is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation { - hit!(GM_NONTRANS_SMALL_SIDE_HITS); - } let gm_nontrans = false; let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( dec, @@ -744,7 +722,6 @@ pub(super) fn decode_inter_sub8_split4( neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]); neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]); } else { - hit!(CHROMA422_INTER_SUB8_HITS); let (ug, _) = read_inter_plane( dec, cdfs, @@ -857,15 +834,6 @@ pub(super) fn decode_inter_sub8_split4( // mi of the group is intra: the group's 4x4 chroma is then predicted WHOLE // from the chroma-reference (last) sub-block's own mv, not in 2x2 pieces. let mixed = piece.iter().any(Option::is_none); - if mixed { - hit_do! { - SUB8_INTRA_RECT_HITS.with(|h| { - let mut st = h.get(); - st[3] += 1; - h.set(st); - }); - } - } // lane-sub8group: the group's chroma pieces, built where they are // written -- the pieces' refs/mvs/filters travel by value. let build = move |_y: &mut PlaneBuf<'static>, @@ -1127,17 +1095,11 @@ pub(super) fn decode_intra_sub8_leaf( dec.debug_state().0 ); } - if (9..=12).contains(&uv_mode) { - hit!(SMOOTH_UV_HITS); - } let alpha = if uv_mode == UV_CFL_PRED { Some(read_cfl_alphas(dec, cdfs)) } else { None }; - if (V_PRED..=D67_PRED).contains(&uv_mode) { - hit!(DIRECTIONAL_UV_HITS); - } (uv_mode, alpha) } else { (DC_PRED, None) @@ -1160,9 +1122,6 @@ pub(super) fn decode_intra_sub8_leaf( ); } if use_fi != 0 { - hit!(FILTER_INTRA_HITS); - hit!(FILTER_INTRA_RECT_HITS); - hit!(FILTER_INTRA_RECT_SUB8_HITS); let fi = dec.symbol(&mut cdfs.filter_intra_mode); if step { eprintln!( @@ -1201,10 +1160,6 @@ pub(super) fn decode_intra_sub8_leaf( } else { 0 }; - if depth != 0 { - hit!(TX_DEPTH_HITS); - hit!(RECT8_SPLIT_TX_HITS); - } let split = depth != 0 || (lossless(fctx) && bw != bh); let (px, py) = (lmi.1 * MI, lmi.0 * MI); let reach = if bw == bh { @@ -1213,9 +1168,6 @@ pub(super) fn decode_intra_sub8_leaf( Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx) }; let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); - if smooth_neighbor { - hit!(SMOOTH_LUMA_HITS); - } neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); let scan: &[u16] = if vert { &SCAN_4X8 } else { &SCAN_8X4 }; if split { @@ -1481,14 +1433,6 @@ pub(super) fn decode_intra_sub8_leaf( is_global_mv1: false, }, ); - hit_do! { - SUB8_INTRA_RECT_HITS.with(|h| { - let mut s = h.get(); - s[usize::from(vert)] += 1; - s[2] += usize::from(has_chroma); - h.set(s); - }); - } // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map // needs EVERY writer): a sub-8x8 group published no palette state, so // 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( }); let mut chroma_stamped_per_unit = false; let (u_grid, v_grid): (Grid, Grid) = if skip { - if alpha.is_some() { - hit!(CHROMA_SKIP_CFL_HITS); - hit!(SKIP_CFL_HITS); - } if chroma_444 && bw != bh { let zeros = Grid::Zero(bw * bh); push_intra_rect( @@ -1751,7 +1691,6 @@ pub(super) fn decode_intra_sub8_leaf( // (`av1_set_contexts`); the tail's whole-leaf chroma // stamp below is skipped for this shape. neighbours.record_mi_chroma(tu_mi, 4, 4, plane_idx, &tu_grid); - hit!(CHROMA_SPLIT_TX_HITS); let dst = mu_units(if plane_idx == 1 { &mut uo } else { &mut vo }, bw * bh); for row in 0..4 { let start = (oy + row) * bw + ox; @@ -1760,7 +1699,6 @@ pub(super) fn decode_intra_sub8_leaf( } } chroma_stamped_per_unit = true; - hit!(LLSUB8RECT444_CHROMA_WALK_HITS); ( if uo.is_empty() { Grid::Zero(bw * bh) @@ -2001,13 +1939,6 @@ pub(super) fn decode_inter_sub8_rect2( (8usize, 4usize) }; let (w_mi, h_mi) = (bw / MI, bh / MI); - hit_do! { - SUB8_INTER_RECT_HITS.with(|c| { - let mut h = c.get(); - h[usize::from(vert)] += 1; - c.set(h); - }); - } let (gr, gc) = group_mi; let (gpx, gpy) = (gc * MI, gr * MI); let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx)); @@ -2155,9 +2086,6 @@ pub(super) fn decode_inter_sub8_rect2( let (ref_width, ref_height) = ref_dims(ref_frame, refpix)?; // lane-t900 r28: refusal lifted -- see the split arm above. let luma_scale = scale_of((ref_width, ref_height), frame_size); - if !luma_scale.is_unscaled() { - hit!(SCALED_SUB8_HITS); - } let gm_table = build_gm_mv_table( global_motion, rmi, @@ -2191,8 +2119,6 @@ pub(super) fn decode_inter_sub8_rect2( tpl, ); let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; - if !not_new { - } let mut is_globalmv = false; let (mv, is_new_mv) = if !not_new { let mut idx = 0usize; @@ -2217,8 +2143,6 @@ pub(super) fn decode_inter_sub8_rect2( ) } else { let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; - if !not_zero { - } is_globalmv = !not_zero; let mv = if !not_zero { gm_table[(ref_frame - LAST_FRAME) as usize] @@ -2266,9 +2190,6 @@ pub(super) fn decode_inter_sub8_rect2( // `is_nontrans_global_motion` returns 0 for // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model -- // so a GLOBALMV sub-block here always reads its interp filter. - if is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation { - hit!(GM_NONTRANS_SMALL_SIDE_HITS); - } let gm_nontrans = false; let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( dec, @@ -2315,9 +2236,6 @@ pub(super) fn decode_inter_sub8_rect2( // exactly that population -- so an unconditional hit proves only // "a lossless sub-8 leaf was walked", not "the conjunct suppressed // a tree". Guard it on the same term the conjunct uses. - if fctx.tx_select_inter.with(std::cell::Cell::get) { - hit!(SUB8_LOSSLESS_NO_VARTX); - } // lane-lossless2: `read_block_tx_size` returns TX_4X4 before it // ever looks at `max_txsize_rect_lookup`, so an 8x4/4x8 leaf is // TWO 4x4 units, not one rect one. @@ -2845,7 +2763,6 @@ pub(super) fn decode_inter_sub8_rect2( neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]); neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]); } else { - hit!(CHROMA422_INTER_SUB8_HITS); let (ug, _) = read_inter_plane( dec, cdfs, @@ -2950,15 +2867,6 @@ pub(super) fn decode_inter_sub8_rect2( // chroma-reference block's own mv, at the group's chroma origin // (`row_start`/`col_start` shift `pre_x`/`pre_y` there either way). let mixed = piece[0].is_none(); - if mixed { - hit_do! { - SUB8_INTRA_RECT_HITS.with(|h| { - let mut s = h.get(); - s[3] += 1; - h.set(s); - }); - } - } let (piece_w, piece_h) = match (mixed, vert) { (true, _) => (B4, B4), (false, true) => (2usize, 4usize), diff --git a/crates/ec-av1/src/encoder/tests.rs b/crates/ec-av1/src/encoder/tests.rs index a21cf532..0a4de0b2 100644 --- a/crates/ec-av1/src/encoder/tests.rs +++ b/crates/ec-av1/src/encoder/tests.rs @@ -1969,23 +1969,12 @@ }; let mut enc = Av1Encoder::new(config).unwrap(); let mut stream = Vec::new(); - let _ = crate::tile::take_sb128_root_hits(); for packet in encode_all(&mut enc, &sources) { stream.extend_from_slice(&packet.data); } - let roots = crate::tile::take_sb128_root_hits(); - assert!( - roots >= 4, - "a 128x128-superblock clip coded {roots} superblock roots, wanted at least 4" - ); - eprintln!("128x128 superblock roots: {roots}"); let ours = crate::stream::decode_stream(&stream).expect("our decoder"); assert_eq!(ours.len(), sources.len(), "our decoder's frames"); - assert!( - crate::decode::part128_split_hits() >= 4, - "our decoder read no 128x128 superblock root" - ); let theirs = ffmpeg_decode_luma(&stream, width, height); assert_eq!(theirs.len(), sources.len(), "ffmpeg's frames"); for (i, (a, b)) in ours.iter().zip(&theirs).enumerate() { diff --git a/crates/ec-av1/src/film_grain.rs b/crates/ec-av1/src/film_grain.rs index 5f26850b..136cd118 100644 --- a/crates/ec-av1/src/film_grain.rs +++ b/crates/ec-av1/src/film_grain.rs @@ -22,7 +22,6 @@ //! the frame it pushes onto its output `Vec`, after saving the //! clean decode into the reference slot bank. use archmage::SimdToken; -use crate::hits::hit; use crate::decode::WithRef; use crate::encode::Picture; @@ -1440,14 +1439,9 @@ pub(crate) fn apply_grain( ) -> Picture { if !fg.apply_grain { let clean = picture.clone(); - // lane-av1graincensus: this exit censuses too, so "the picture - // `apply_grain` hands back is censused in its final form" is a property - // of the FUNCTION rather than of one branch. - crate::decode::census_unwritten_grained(&clean.y, &clean.u, &clean.v); return clean; } fctx.grain_bit_depth.with(|c| c.set(bit_depth)); - hit!(GRAIN_HITS); // lane-av1422grain: the chroma geometry is per-axis. `FrameCtx` already // carries the sequence header's pair (`decode::set_subsampling`), and // `apply_grain` runs inside the same frame context, so the chroma @@ -2142,16 +2136,6 @@ pub(crate) fn apply_grain( }); drop(parts); - // lane-av1graincensus: the post-grain census, at the point the caller takes - // the picture. `census_unwritten_final` runs in `stream.rs` BEFORE this - // function, over the clean planes, and every filter writes in place into - // that same buffer -- so the destination allocated above by `uninit_plane` - // is the ONLY picture between that census and the caller that no census has - // ever looked at. `lanes/unwritten-dep.report.md` §6/§8 declined to claim - // anything about it; this measures it. `uninit_plane` poisons the buffer - // under the same predicate, so the count is a measurement rather than a - // coin flip on ambient garbage. - crate::decode::census_unwritten_grained(&out.y, &out.u, &out.v); out } diff --git a/crates/ec-av1/src/hits.rs b/crates/ec-av1/src/hits.rs deleted file mode 100644 index 16d891fb..00000000 --- a/crates/ec-av1/src/hits.rs +++ /dev/null @@ -1,47 +0,0 @@ -//! Gate-counter bumps, compiled out when the `gate-counters` feature is off. -//! -//! The ~550 `*_HITS` thread-locals in this crate exist only so the test gates -//! (and the probe's census print) can prove a coding path fired; every bump is -//! a TLS access plus a `Cell` read-modify-write on the parse thread. Routing -//! all of them through [`hit!`]/[`hit_do!`] lets a shipped decoder drop them -//! (`--no-default-features`) while the accessors keep compiling and returning -//! whatever the counters hold (0 when the feature is off), so no caller needs -//! a `cfg`. - -/// Bumps counter `$name` by one -- nothing at all without `gate-counters`. -/// Usable in expression position (it evaluates to `()`). -#[cfg(feature = "gate-counters")] -macro_rules! hit { - ($name:ident) => {{ - $name.with(|c| c.set(c.get() + 1)); - }}; -} - -#[cfg(not(feature = "gate-counters"))] -macro_rules! hit { - ($name:ident) => {{}}; -} - -/// Same, for a bump that is not a plain `+= 1` (array/tuple buckets, the -/// `inter_last_mc` stamp, the counter-only scan loops): the whole statement -/// list disappears without `gate-counters`. -#[cfg(feature = "gate-counters")] -macro_rules! hit_do { - ($($t:tt)*) => {{ - $($t)* - }}; -} - -// Without the feature the statements stay type-checked but unreachable, so the -// values they read (bucket indices, filter kinds) still count as used and the -// optimiser drops the whole branch. -#[cfg(not(feature = "gate-counters"))] -macro_rules! hit_do { - ($($t:tt)*) => {{ - if false { - $($t)* - } - }}; -} - -pub(crate) use {hit, hit_do}; diff --git a/crates/ec-av1/src/intra.rs b/crates/ec-av1/src/intra.rs index a1d354d5..20d9c721 100644 --- a/crates/ec-av1/src/intra.rs +++ b/crates/ec-av1/src/intra.rs @@ -7,7 +7,6 @@ //! not this module's business -- the caller passes the samples it has, and the //! edge is extended by repeating the last one, which is what the decoder does //! with its own `BlockDecoded` bookkeeping (spec 7.11.2.2). -use crate::hits::hit; /// The average of the neighbours (spec 7.11.2.5). pub const DC_PRED: u8 = 0; @@ -283,13 +282,6 @@ pub(crate) fn predict( dst: &mut [u16], fctx: &crate::decode::FrameCtx, ) { assert_eq!(dst.len(), bw * bh, "the destination is the block"); - match mode { - SMOOTH_PRED | SMOOTH_V_PRED | SMOOTH_H_PRED => { - hit!(SMOOTH_PRED_HITS); - } - PAETH_PRED => hit!(PAETH_PRED_HITS), - _ => {} - } let edges = Edges::build(above, left, corner, bw, bh, fctx); let is_directional = matches!( mode, @@ -484,7 +476,6 @@ fn filter_intra_edge(buf: &mut [i32], strength: i32) { if strength == 0 { return; } - hit!(EDGE_FILTER_HITS); const KERNEL: [[i32; 5]; 3] = [[0, 4, 8, 4, 0], [0, 5, 6, 5, 0], [2, 4, 4, 4, 2]]; let filt = usize::try_from(strength - 1).expect("a filter strength is never negative"); let sz = buf.len() as i32; diff --git a/crates/ec-av1/src/lib.rs b/crates/ec-av1/src/lib.rs index d78b83c3..360a6707 100644 --- a/crates/ec-av1/src/lib.rs +++ b/crates/ec-av1/src/lib.rs @@ -35,7 +35,6 @@ mod film_grain; pub use film_grain::apply_film_grain; mod filter_search; pub mod frame; -mod hits; pub mod intra; pub mod mc; pub mod motion; diff --git a/crates/ec-av1/src/mc.rs b/crates/ec-av1/src/mc.rs index c1ba4578..8012c5e2 100644 --- a/crates/ec-av1/src/mc.rs +++ b/crates/ec-av1/src/mc.rs @@ -9,7 +9,6 @@ //! land on an even step; chroma vectors, once scaled for subsampling, can //! land on any of the 16. use archmage::SimdToken; -use crate::hits::hit; /// `Round2` (spec 4.7): halves round up. fn round2(value: i32, shift: u32) -> i32 { @@ -1473,7 +1472,6 @@ pub(crate) fn predict_with_filters_kern( ) { assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); assert!(!reference.is_empty(), "a reference plane has samples"); - hit!(INTER_PRED_HITS); #[cfg(test)] let stage_t = crate::encode::stage_start(); @@ -1569,9 +1567,6 @@ pub(crate) fn predict_with_filters_kern( // clamped read. if xfrac != 0 || yfrac == 0 { // fall through to the two-pass path - if xfrac != 0 || yfrac != 0 { - hit!(MC_SUBPEL_HITS); - } } else { let top = y0 - 3; if top >= 0 @@ -1761,9 +1756,6 @@ pub fn reset_rect_narrow_kern_hits() { /// Bumps [`RECT_NARROW_KERN_HITS`] when the block's true dims pick a kernel /// the destination buffer's dims would not have. fn note_narrow_kern(block_w: usize, block_h: usize, kern_w: usize, kern_h: usize) { - if (kern_w <= 4) != (block_w <= 4) || (kern_h <= 4) != (block_h <= 4) { - hit!(RECT_NARROW_KERN_HITS); - } } /// Current value of [`INTER_PRED_HITS`]. @@ -2052,8 +2044,6 @@ pub(crate) fn predict_scaled_kern( ) { assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); assert!(!reference.is_empty(), "a reference plane has samples"); - hit!(INTER_PRED_HITS); - hit!(PREDICT_SCALED_HITS); let max = crate::decode::sample_max(fctx); let (round0, round1) = round_pair(u32::from(crate::decode::bit_depth(fctx))); @@ -2279,11 +2269,7 @@ pub(crate) fn predict_compound_intermediate_kern( ) { assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); assert!(!reference.is_empty(), "a reference plane has samples"); - hit!(INTER_PRED_HITS); - if !scale.is_unscaled() { - hit!(PREDICT_SCALED_HITS); - } let x_scale_fp = scale.x; if scale.y != REF_NO_SCALE { let (round0, _) = round_pair(u32::from(crate::decode::bit_depth(fctx))); diff --git a/crates/ec-av1/src/motion_field.rs b/crates/ec-av1/src/motion_field.rs index 51a81ff1..2d9b51d5 100644 --- a/crates/ec-av1/src/motion_field.rs +++ b/crates/ec-av1/src/motion_field.rs @@ -5,7 +5,6 @@ //! (`av1/common/mvref_common.c`) and the projection math `add_tpl_ref_mv` //! (same file) applies a second time, per query block, against the block's //! own single reference frame. -use crate::hits::hit; use crate::mvstack::{ALTREF_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME}; @@ -428,12 +427,6 @@ pub fn setup_motion_field>( && slot_of(rf).is_some_and(|m| m.is_intra) }) .count(); - if intra_forward_refs >= 1 { - hit!(REFSTAMP_INTRA_FRAMES); - } - if intra_forward_refs >= 2 { - hit!(REFSTAMP_INTRA2_FRAMES); - } if let Some(last) = slot_of(LAST_FRAME) { let alt_of_lst = last.ref_order_hints[(ALTREF_FRAME - LAST_FRAME) as usize]; diff --git a/crates/ec-av1/src/mvstack.rs b/crates/ec-av1/src/mvstack.rs index 004832e8..09e9f607 100644 --- a/crates/ec-av1/src/mvstack.rs +++ b/crates/ec-av1/src/mvstack.rs @@ -77,7 +77,6 @@ //! added by the row/col scan), and the "extra search" that pads a short //! stack to two entries (spec 7.10.2.12) — this module's stack can be //! shorter than two candidates where libaom's never is. -use crate::hits::hit; thread_local! { /// 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) { if let Some(entry) = candidates.iter_mut().find(|e| e.mv == mv) { entry.weight += weight; } else if candidates.len() >= MAX_STACK_SIZE { - hit!(STACK_FULL_DROPS); } else { // libaom `add_ref_mv_candidate` (mvref_common.c:100) and // `add_tpl_ref_mv` (:388) only push when @@ -1174,9 +1172,6 @@ fn clamp_mv_ref( let (row, col) = mv; let clamped_row = row.clamp(to_top - bh8 - MV_BORDER, to_bottom + bh8 + MV_BORDER); let clamped_col = col.clamp(to_left - bw8 - MV_BORDER, to_right + bw8 + MV_BORDER); - if clamped_row != row || clamped_col != col { - hit!(MV_CLAMP_EDGE_OVERHANG_HITS); - } } let (row, col) = mv; @@ -1414,9 +1409,6 @@ pub fn find_mv_stack_with_sign_bias( // (and so the stack ORDER) even though `MiGrid::get` already returns // `None` for the cells outside the tile. let (tile_row0, tile_col0) = grid.tile_origin(); - if tile_row0 > 0 || tile_col0 > 0 { - hit!(TILE_REACH_CLIPS); - } let max_row_offset: isize = if mi_row > tile_row0 { let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj); reach.max(tile_row0 as isize - mi_row as isize) @@ -1583,9 +1575,6 @@ pub fn find_mv_stack_with_sign_bias( } } } - if any_hit { - hit!(TMV_HITS); - } zero_mv_ctx = usize::from(first_sample_missing || first_sample_far); } @@ -1931,7 +1920,6 @@ fn add_compound_candidate( if let Some(entry) = candidates.iter_mut().find(|e| e.mv0 == mv0 && e.mv1 == mv1) { entry.weight += weight; } else if candidates.len() >= MAX_STACK_SIZE { - hit!(STACK_FULL_DROPS); } else { // Same insertion cap as [`add_candidate`]: libaom's compound branch // of `add_ref_mv_candidate` (mvref_common.c:128) and `add_tpl_ref_mv` @@ -2215,9 +2203,6 @@ fn combine_compound_candidates( .collect(); std::array::from_fn(|i| { merged.get(i).copied().unwrap_or_else(|| { - if gm_mv_candidates[side] != (0, 0) { - hit!(COMP_GM_FILL_HITS); - } gm_mv_candidates[side] }) }) @@ -2274,9 +2259,6 @@ pub fn find_mv_stack_compound( // (and so the stack ORDER) even though `MiGrid::get` already returns // `None` for the cells outside the tile. let (tile_row0, tile_col0) = grid.tile_origin(); - if tile_row0 > 0 || tile_col0 > 0 { - hit!(TILE_REACH_CLIPS); - } let max_row_offset: isize = if mi_row > tile_row0 { let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj); reach.max(tile_row0 as isize - mi_row as isize) @@ -2441,9 +2423,6 @@ pub fn find_mv_stack_compound( } } } - if any_hit { - hit!(TMV_HITS); - } zero_mv_ctx = usize::from(first_sample_missing || first_sample_far); } diff --git a/crates/ec-av1/src/quant.rs b/crates/ec-av1/src/quant.rs index 87a0c037..95e7360f 100644 --- a/crates/ec-av1/src/quant.rs +++ b/crates/ec-av1/src/quant.rs @@ -216,7 +216,6 @@ pub fn dequant_coeff_wh( dq2.clamp(-bound, bound - 1) as i32 } -use crate::hits::hit_do; thread_local! { /// lane-av1-qmatrix: transform units whose dequantisation actually @@ -304,11 +303,6 @@ pub fn dequant_wh_into( let dq2 = sign * ((dq.abs() & 0xFF_FFFF) / denom); dq2.clamp(-bound, bound - 1) as i32 }; - hit_do! { - if qm.is_some() && levels.iter().any(|&l| l != 0) { - QM_SCALED_UNITS.with(|c| c.set(c.get() + 1)); - } - } out.clear(); out.reserve(levels.len()); out.extend( diff --git a/crates/ec-av1/src/restoration.rs b/crates/ec-av1/src/restoration.rs index 239dde13..c2e964d4 100644 --- a/crates/ec-av1/src/restoration.rs +++ b/crates/ec-av1/src/restoration.rs @@ -4,7 +4,6 @@ //! two pixel filters (Wiener, self-guided/SGR). See `lanes/lr.report.md` for //! the full derivation (libaom `decodeframe.c`/`restoration.c` line refs). use archmage::SimdToken; -use crate::hits::hit; use crate::msac::SymbolDecoder; use ec_av1_syntax::obu::floor_log2; @@ -648,23 +647,19 @@ fn read_lr_unit( ) -> UnitFilter { match ftype { RestorationType::Switchable => { - hit!(SWITCHABLE_HITS); let t = dec.symbol(&mut cdfs.restore_switchable); match t { 0 => UnitFilter::None, 1 => { - hit!(WIENER_HITS); UnitFilter::Wiener(read_wiener_filter(dec, chroma, &mut reference.0)) } _ => { - hit!(SGRPROJ_HITS); UnitFilter::Sgrproj(read_sgrproj_filter(dec, &mut reference.1)) } } } RestorationType::Wiener => { if dec.symbol(&mut cdfs.restore_wiener) != 0 { - hit!(WIENER_HITS); UnitFilter::Wiener(read_wiener_filter(dec, chroma, &mut reference.0)) } else { UnitFilter::None @@ -673,7 +668,6 @@ fn read_lr_unit( RestorationType::Sgrproj => { let bit = dec.symbol(&mut cdfs.restore_sgrproj); if bit != 0 { - hit!(SGRPROJ_HITS); UnitFilter::Sgrproj(read_sgrproj_filter(dec, &mut reference.1)) } else { UnitFilter::None @@ -1508,14 +1502,6 @@ fn filter_restoration_unit( let nominal_h = full_stripe_height - if frame_stripe == 0 { runit_offset } else { 0 }; let h = nominal_h.min(unit_h - i); let stripe_v_end = stripe_v_start + h; - if !matches!(filter, UnitFilter::None) { - if stripe_v_start == 0 { - hit!(LR_STRIPE0_HITS); - } - if stripe_v_end == plane_h && h < nominal_h { - hit!(LR_LAST_STRIPE_HITS); - } - } match filter { UnitFilter::Wiener(info) => apply_wiener_stripe( out, diff --git a/crates/ec-av1/src/stream/mod.rs b/crates/ec-av1/src/stream/mod.rs index fa6d5a92..6fd9177c 100644 --- a/crates/ec-av1/src/stream/mod.rs +++ b/crates/ec-av1/src/stream/mod.rs @@ -38,314 +38,6 @@ fn no_grain() -> bool { -/// 32x32-level 1:4 strip counters, for `decode_probe`'s fixture search: -/// (HORZ_4 strips, VERT_4 strips, strips that read coefficients). -/// lane-inter4 r1: the INTER-frame partition counters this lane's gates -/// assert -- `(32x8, 8x32, 64x32, 32x64, 64x16, 16x64)` strips decoded. -pub fn inter_rect_counters() -> (usize, usize, usize, usize, usize, usize) { - ( - crate::decode::rect4_32_horz_inter_hits(), - crate::decode::rect4_32_vert_inter_hits(), - crate::decode::inter_sb_horz_hits(), - crate::decode::inter_sb_vert_hits(), - crate::decode::inter_sb_horz4_hits(), - crate::decode::inter_sb_vert4_hits(), - ) -} - -/// lane-r14 r2: luma transform units of an inter strip with a 64-px axis, -/// coded as the truncated low-32 coefficient corner. -pub fn rect64_inter_tu_hits() -> usize { - crate::decode::rect64_inter_tu_hits() -} - -/// lane-rectres r1: whole-block luma transform units of a 32x32-level 1:4 -/// inter strip (`TX_32X8`/`TX_8X32`), `[32x8, 8x32]`. -pub fn rect32x8_inter_tu_hits() -> [usize; 2] { - crate::decode::rect32x8_inter_tu_hits() -} - -/// lane-t900 r7: sub-8x8 inter groups whose one chroma unit inherited a -/// `tx_type` different from the group's FIRST sub-block, i.e. groups that can -/// only decode right under `av1_get_tx_type`'s chroma-reference rule. -pub fn sub8_chroma_tx_from_ref_hits() -> usize { - crate::decode::sub8_chroma_tx_from_ref_hits() -} - -/// lane-intra16x4: `(16x4, 4x16, chroma-reference)` INTRA strips decoded inside -/// an inter 16x16-level 1:4 partition. -pub fn intra16x4_in_inter_hits() -> (usize, usize, usize) { - crate::decode::intra16x4_in_inter_hits() -} - -/// lane-sub8intra: INTRA 8x4/4x8 leaves inside an inter frame's sub-8x8 -/// HORZ/VERT partition, `(8x4, 4x8, chroma-reference, mixed groups, split -/// 4x4 leaves)`. -pub fn sub8_intra_rect_hits() -> (usize, usize, usize, usize, usize) { - crate::decode::sub8_intra_rect_hits() -} - -/// lane-r14 r3: RECTANGULAR var-tx leaf transform units, `[32x16, 16x32]` -- -/// the leaves `sub_tx_size_map` produces when a 1:4 strip with a 64-px axis -/// splits its transform (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`). -pub fn vartx_rect_leaf_hits() -> [usize; 2] { - crate::decode::vartx_rect_leaf_hits() -} - -/// How many rect intra strips read the `use_intrabc` symbol on the last decode. -pub fn rect_intrabc_reads() -> usize { - crate::decode::rect_intrabc_reads() -} - -/// lane-av1-ibc444rect: unskipped intrabc 8x4/4x8 leaves whose luma a lossless -/// frame walked as per-4x4 inter units. -pub fn intrabc_rect8_lossless_luma_hits() -> usize { - crate::decode::intrabc_rect8_lossless_luma_hits() -} - -/// lane-av1-ibc444rect: unskipped intrabc 8x4/4x8 leaves whose chroma a -/// lossless 4:4:4 frame walked as per-4x4 `Chroma4` units. -pub fn intrabc_rect8_lossless_chroma_hits() -> usize { - crate::decode::intrabc_rect8_lossless_chroma_hits() -} - -/// Gate-side reset for the lane-av1-ibc444rect counters above. -pub fn reset_ibc444rect_hits() { - crate::decode::reset_ibc444rect_hits() -} - -/// lane-av1chromarect: 128-root intra-BC HORZ/VERT strips whose chroma plane -/// block was sized `bw >> ss_x` by `bh >> ss_y` rather than the hardcoded -/// 4:2:0 halving -- i.e. the 4:4:4 (and 4:4:0) cells, where -/// `av1_get_max_uv_txsize` (`ss_size_lookup[bsize]`, blockd.h:1372) applies no -/// halving of its own. At 4:2:0 the two forms are the same arithmetic, so a -/// `>= 1` witness can only come from a stream that is not 4:2:0. EXCLUSIVE to -/// `decode_intrabc_owned_rect`: no other caller sizes a 128-root intra-BC -/// strip's chroma plane block. -pub fn ibc_owned_rect_chroma_footprint_444_hits() -> usize { - crate::decode::ibc_owned_rect_chroma_footprint_444_hits() -} - -/// Gate-side reset for the lane-av1chromarect counter above. -pub fn reset_ibc_owned_rect_chroma_footprint_444_hits() { - crate::decode::reset_ibc_owned_rect_chroma_footprint_444_hits() -} - -/// lane-av1chromadc: chroma units of a skipped block whose intra-BC / UV -/// palette override had to be windowed to the unit's own extent -- `cn_cols * -/// cn_rows > 1`, which at 4:2:0 never happens and at 4:4:4 is every block of -/// 64 and above. Counts UNITS. EXCLUSIVE to `decode_block`'s skipped square -/// block chroma walk. -pub fn skip_chroma_override_window_hits() -> usize { - crate::decode::skip_chroma_override_window_hits() -} - -/// Gate-side reset for the lane-av1chromadc counter above. -pub fn reset_skip_chroma_override_window_hits() { - crate::decode::reset_skip_chroma_override_window_hits() -} - -/// lane-av1rectreach: the `chroma_tiled` walk's per-unit reach and grid-shape -/// counters, as `(unit_reach_differs_from_block, 2x1 units, 1x2 units, other -/// multi-unit units)`. See [`crate::decode::rect_tiled_chroma_grid_hits`]. -pub fn rect_tiled_chroma_grid_hits() -> (usize, usize, usize, usize) { - crate::decode::rect_tiled_chroma_grid_hits() -} - -/// Gate-side reset for the lane-av1rectreach counters above. -pub fn reset_rect_tiled_chroma_grid_hits() { - crate::decode::reset_rect_tiled_chroma_grid_hits() -} - -/// `(y, uv)` palette blocks RECONSTRUCTED inside an inter frame (lane-t900 -/// r22) -- the counter a screen-content witness gate reads to prove it -/// exercises the inter-frame palette path, not the key frame's. -pub fn intra_in_inter_palette_hits() -> (usize, usize) { - crate::decode::intra_in_inter_palette_hits() -} - -/// `(y, uv)` palette blocks reconstructed on an 8x8 LEAF inside an inter -/// frame (lane-t900 r23) -- the site-specific half of -/// [`intra_in_inter_palette_hits`], which a >=16 block also moves. -pub fn inter8_palette_hits() -> (usize, usize) { - crate::decode::inter8_palette_hits() -} - -/// lane-rect64port r1: coded 64-level HORZ/VERT intra strips whose luma -/// transform unit is the un-split TX_64X32 (orient 0) / TX_32X64 (orient 1). -pub fn rect64_corner_tu_hits(orient: usize) -> usize { - crate::decode::rect64_corner_tu_hits(orient) -} - -/// lane-inter16ab r4: RECTANGULAR var-tx leaves with a 4-px axis, `[8x4, 4x8]` -/// -- what `sub_tx_size_map[TX_16X4] == TX_8X4` produces when a 16x16-level -/// 1:4 inter strip splits its transform. -pub fn vartx_rect_leaf4_hits() -> [usize; 2] { - crate::decode::vartx_rect_leaf4_hits() -} - -/// lane-inter16ab r5: COMPOUND_WEDGE / wedge-INTERINTRA blocks that used a -/// RECTANGULAR wedge codebook row, per shape (`RECT_WEDGE_SHAPES` order: -/// 8x16, 16x8, 16x32, 32x16, 8x32, 32x8). -pub fn rect_wedge_hits() -> [usize; 6] { - crate::decode::rect_wedge_hits() -} - -/// lane-inter16ab r5: the wedge-interintra half of [`rect_wedge_hits`]. -pub fn rect_wii_hits() -> [usize; 6] { - crate::decode::rect_wii_hits() -} - -/// lane-sb128c r7: the 128 root's rect arms -- (gathered edge HORZ, gathered -/// edge VERT, inter 128x64 blocks, inter 64x128 blocks). -pub fn sb128_rect_counters() -> (usize, usize, usize, usize) { - ( - crate::decode::part128_edge_horz_hits(), - crate::decode::part128_edge_vert_hits(), - crate::decode::inter_sb128_horz_hits(), - crate::decode::inter_sb128_vert_hits(), - ) -} - -/// lane-av1-ibcrect: the 128 root's interior partition arms plus the key-frame -/// intra 128-axis blocks -- (split, none, horz, vert, ab[4], intra_horz, -/// intra_vert). Non-zero horz/vert mean a stream carried real PARTITION_HORZ/ -/// VERT at the 128 root, so an intrabc-rect hunt can tell "the partition was -/// never chosen" from "chosen and decoded intra (or refused)". -pub fn part128_census() -> (usize, usize, usize, usize, [usize; 4], usize, usize) { - ( - crate::decode::part128_split_hits(), - crate::decode::part128_none_hits(), - crate::decode::part128_horz_hits(), - crate::decode::part128_vert_hits(), - crate::decode::part128_ab_hits(), - crate::decode::intra_sb128_hits().0, - crate::decode::intra_sb128_hits().1, - ) -} - -/// lane-av1-ibcrect: `use_intrabc` blocks on a 128-root HORZ/VERT strip whose -/// reconstruction ([`crate::decode::decode_intrabc_128rect`]) ran -- the -/// engagement counter the sb128 intrabc-rect gate asserts on. -pub fn intrabc_128rect_hits() -> usize { - crate::decode::intrabc_128rect_hits() -} - -/// lane-av1-ibc128chunk: chroma transform units the 128-root intrabc strip's -/// mu-chunk walk read, one per `read_inter_plane` chroma call. At 4:2:2 a -/// 64x64 mu chunk's chroma plane block is 32x64 and holds TWO STACKED -/// TX_32X32 units per plane; the square-cut walk this gate witnesses read -/// one. Measured on the pinned witness: 8 before, 48 after. -pub fn intrabc_128rect_chroma_chunk_hits() -> usize { - crate::decode::intrabc_128rect_chroma_chunk_hits() -} - -/// lane-av1-ibc128chunk: the 128-root intrabc strip's per-axis chroma chunk -/// extents as `(64 >> ss_x) << 8 | (64 >> ss_y)` on the last chunk walked -- -/// 32|32 at 4:2:0, 32|64 at 4:2:2, 64|64 at 4:4:4. -pub fn intrabc_128rect_chunk_shape() -> usize { - crate::decode::intrabc_128rect_chunk_shape() -} - -/// Blocks reconstructed with intra block copy at an 8x8 LEAF specifically -/// (lane-kf900 r7's shape); [`crate::decode::intrabc_hits`] counts every shape. -pub fn leaf8_intrabc_hits() -> usize { - crate::decode::leaf8_intrabc_hits() -} - -/// Blocks whose `use_intrabc` symbol came out 1 and took the DV path, at ANY -/// shape -- the engagement counter the intrabc gates assert on. It counts -/// "read a `use_intrabc` DV", not "reconstructed": a block the rect-strip -/// reader REFUSES for an unported shape bumps it too (the symbol and the DV -/// are parsed before the refusal). [`leaf8_intrabc_hits`] is its 8x8-leaf -/// subset. -pub fn intrabc_hits() -> usize { - crate::decode::intrabc_hits() -} - -/// lane-av1txbands: sub-8x8 group chroma-reference leaves that USED intrabc and -/// were SKIPPED -- the route that armed [`crate::decode::intrabc_hits`]'s chroma -/// transform slot and then read no chroma coefficient. A non-zero value is what -/// makes the disarm at that route load-bearing on a real stream. -pub fn skipped_intrabc_chroma_arm_hits() -> usize { - crate::decode::skipped_intrabc_chroma_arm_hits() -} - -/// lane-sb128c r8: the 128 root's INTRA (key-frame) rect arm -- (128x64 -/// blocks, 64x128 blocks, blocks per resolved intra `tx_depth` 0/1/2). -pub fn intra_sb128_counters() -> (usize, usize, [usize; 3]) { - crate::decode::intra_sb128_hits() -} - -/// lane-inter128intra r1: the 128 root's HORZ/VERT half coded INTRA inside an -/// INTER frame -- (128x64 blocks, 64x128 blocks). -pub fn intra128_in_inter_counters() -> [usize; 2] { - crate::decode::intra128_in_inter_hits() -} - -/// lane-lossless128: intra 128-axis blocks decoded on a LOSSLESS frame, where -/// every plane is a TX_4X4 unit. The engagement counter for -/// `a_lossless_sb128_rect_intra_block_decodes_sample_exact`. -pub fn intra128_lossless_counters() -> usize { - crate::decode::intra128_lossless_hits() -} - -/// lane-av1-128rectspan: chroma transform units re-stamped by -/// `decode_block_128rect`'s end-of-block replay, and how many of those -/// replays stamped a height that was not the unit's own. -/// lane-av1422lift: the second half was described as "the 4:2:2 signature -- -/// zero on every stream this decoder admits, since 4:2:2 is refused by name -/// at the sequence header", and that was TRUE. 4:2:2 is decoded now and the -/// mismatch is NOT zero: measured on this branch's tip, the two -/// `422_intrabc_sb128_strip*` pins each read `(72, 9)` while the other 19 -/// committed 4:2:2 cells read `(0, 0)`. Those two pins are byte-exact -/// against ffmpeg, so the non-zero half counts the arm's own designed case -/// and is not a defect. lane-av1422mismatch9: the predicate is -/// `luma_span != luma_span_h` (`chroma_tx << ss_x` vs `<< ss_y`), true by -/// CONSTRUCTION at ss (1,0), and the replay re-stamps with the same per-axis -/// pair the in-loop walk used, so the counter is a 4:2:2 shape test, not a -/// divergence test (`record_mi_chroma` writes only the left/above context -/// arrays, never a pixel). One 4:2:2 gate now reads the pair and asserts the -/// measured `(72, 9)`: -/// `the_422_block_128rect_chroma_chunk_gather_stays_per_axis`; the other -/// reader is on a 4:4:4 stream, where the mismatch half is structurally zero. -pub fn sb128rect_chroma_replay_counters() -> (usize, usize) { - crate::decode::sb128rect_chroma_replay_hits() -} - -/// lane-sb128c r9: the four AB shapes at the 128 root, in `PARTITION_HORZ_A`, -/// `_HORZ_B`, `_VERT_A`, `_VERT_B` order (key and inter tile paths share the -/// counter -- it is bumped where the root symbol resolves). -pub fn sb128_ab_counters() -> [usize; 4] { - crate::decode::part128_ab_hits() -} - -/// lane-obmcrec r1: OBMC neighbours taken from the second half of a 1:4-strip -/// chroma pair -- the shape whose filter record the r1 fix re-sourced. -pub fn obmc_pair_filter_hits() -> usize { - crate::decode::obmc_pair_filter_hits() -} - -/// Gate counters for the 4x32/32x4 rectangular strips: `(horz, vert, coeff)` hits. -pub fn rect4_32_counters() -> (usize, usize, usize) { - ( - crate::decode::rect4_32_horz_hits(), - crate::decode::rect4_32_vert_hits(), - crate::decode::rect4_coeff_hits(), - ) -} - -/// lane-inter4 r4: rectangular inter transform units coded whole, rect -/// var-tx trees that split, and OBMC blends run on a 16x8/8x16 leaf -- the -/// three counters a recipe sweep needs to see from outside the crate. -pub fn rect_inter_tu_counters() -> (usize, usize, usize) { - ( - crate::decode::rect_inter_tu_hits(), - crate::decode::rect_inter_txsplit_hits(), - crate::decode::obmc_rect_leaf_hits(), - ) -} - /// Decode every frame in a raw AV1 OBU stream, in coding order. /// /// A key frame becomes the reference for the inter frames that follow it, @@ -2249,14 +1941,6 @@ fn decode_frame( // 4:2:0 one never inherits the wrong plane count. crate::decode::set_mono(seq.mono_chrome, fctx); crate::decode::set_subsampling(seq.subsampling_x, seq.subsampling_y, fctx); - // lane-av1readcensus: the coefficient-unit census is armed here, off the - // same sequence-header subsampling. lane-av1422census422 widened it from - // 4:4:4-only to "any format with an unsubsampled luma axis", so a 4:2:2 - // cell's per-plane unit counts are readable and a 4:2:2 gate can assert - // a non-vacuous walk; 4:2:0 still reads zero, so the 4:2:0 control in - // `a_pixel_exact_444_stream_walks_the_same_coefficient_units_the_oracle_does` - // keeps asserting exactly that. - crate::decode::set_census_nonsub(seq.subsampling_x, seq.subsampling_y); // lane-av1txr: spec 5.9.2 `disable_cdf_update` -- a frame that sets it // codes every tile symbol against the CDFs it started with, so the tile // readers must not adapt (libaom `decodeframe.c:2909`: @@ -2503,46 +2187,6 @@ fn decode_frame( // *initial* table into the slots it refreshes, not the adapted // end-of-tile one. let stored_cdfs = stored_cdfs_for(header, end_cdfs, started_from); - // lane-hidden r1: the frame exactly as it is about to be stored into - // the reference slots -- after deblock/CDEF/LR/superres, in DECODE - // order, hidden (`show_frame == 0`) alt-ref frames included, and - // bit-depth correct (8-bit as u8, 10/12-bit as u16 LE) unlike the - // u8-narrowing diagnostic dumps above. Matches the instrumented - // aomdec's own `EC_AV1_FINAL_DUMP` rung byte for byte - // (scripts/instrument-aom-oracle.sh rung 12), which is what makes a - // hidden frame's pixels comparable at all. - // lane-unwritten-dep: the census AT the output point, beside the dump that - // defines "the output" -- the same bytes, so the claim is about the frame the - // caller receives rather than about an intermediate stage. - // - // WHAT THIS IS FOR, corrected: an earlier revision of this comment said the - // pre-deblock plane was byte-identical plain-vs-sentinel and that deblock - // creates the dependence. That was wrong, and it was `dump_stage16`'s fault: - // it cropped chroma as `(fw/2, fh/2)`, a 4:2:0 assumption, so on a 64x64 - // 4:2:2 frame 2048 chroma samples appeared in no stage dump at all -- exactly - // the region the difference lives in. With per-axis extents the corrected - // measurement on `440_request_is_422` is that the PRE-DEBLOCK dump already - // differs by 2158 bytes and an exact u16 census finds 224 unwritten samples - // (U 112, V 112, rows 36..63) -- the same count `lanes/av1unwritten.report.md` - // reports. The hole is present before any filter runs, and the pre-deblock - // census SEES it. - // - // So this second census is not a patch for a blind pre-deblock scan. It is - // the measurement taken where the reference-bank bytes are taken, which - // covers the whole span from the tile walk to those bytes: every filter - // writes IN PLACE into the very buffer this scans, so nothing a later - // filter does can open a hole outside its extent. - // - // lane-av1graincensus, the scope correction this comment needed: "to the - // caller's frame" was WRONG, and this call is not what makes it right. - // `apply_grain` runs after this and ALLOCATES a fresh picture - // (`film_grain::uninit_plane`, `with_capacity` + `set_len`, no fill), so - // that destination never passes through here. The claim over the PRE-GRAIN - // planes -- the bytes the reference bank stores and every later frame - // predicts from -- is what this line supports; the grained picture the - // caller receives is censused by `decode::census_unwritten_grained`, at - // `apply_grain`'s own return, over its own counters. - decode::census_unwritten_final(&picture.y, &picture.u, &picture.v); if let Some(why) = fctx.corrupt.get() { return Err(Error::corrupt(format!("AV1 frame {decode_idx}: {why}"))); } @@ -2554,29 +2198,5 @@ fn decode_frame( }) } -/// lane-intra14 r1: INTRA-coded 1:4 strips decoded on the INTER block path -/// (64x16, 16x64, 32x8, 8x32) -- the counters a recipe sweep needs from -/// outside the crate. -pub fn intra_rect4_in_inter_counters() -> (usize, usize, usize, usize) { - ( - crate::decode::intra_rect4_strip_in_inter_hits(0), - crate::decode::intra_rect4_strip_in_inter_hits(1), - crate::decode::intra_rect4_strip_in_inter_hits(2), - crate::decode::intra_rect4_strip_in_inter_hits(3), - ) -} - -/// lane-av1recipehunt: the recipe sweep's view of the `delta_q` story from -/// OUTSIDE the crate -- `(delta_q symbol groups read, rect64 dequant calls that -/// saw `CURRENT_Q_IDX != base_q_idx`)`. A recipe that reads delta_q but never -/// lands one inside a rect64 root is a different failure from one that reads -/// neither, and the gate can only tell them apart with both numbers. -pub fn rect64_qidx_drift_counters() -> (usize, usize) { - ( - crate::decode::delta_q_hits(), - crate::decode::rect64_qidx_drift_hits(), - ) -} - #[cfg(test)] pub(crate) mod tests; diff --git a/crates/ec-av1/src/superres.rs b/crates/ec-av1/src/superres.rs index 6859f38c..97b18c30 100644 --- a/crates/ec-av1/src/superres.rs +++ b/crates/ec-av1/src/superres.rs @@ -10,7 +10,6 @@ //! Every constant and the 64x8 `av1_resize_filter_normative` coefficient //! table below is copied verbatim from libaom `aom_dsp/aom_filter.h` and //! `av1/common/resize.c` (`AOM_VERSION=v3.13.3`, `~/.cache/aom-oracle`). -use crate::hits::hit; /// `RS_SUBPEL_BITS`. const RS_SUBPEL_BITS: u32 = 6; @@ -185,7 +184,6 @@ pub(crate) fn superres_hits() -> usize { /// Counts one whole upscaled picture (all three planes) for [`SUPERRES_HITS`]. pub(crate) fn note_upscaled_picture() { - hit!(SUPERRES_HITS); } #[cfg(test)]