Merge branch 'simplify/u3' into simplify/w1b
Browse files at this commit56 changed files +6851 -25200
- Cargo.lock +0 -8
- crates/ec-av1/Cargo.toml +0 -11
- crates/ec-av1/examples/alloc_probe.rs +0 -96
- crates/ec-av1/examples/decode_probe.rs +0 -532
- crates/ec-av1/examples/syntax_census.rs +0 -375
- crates/ec-av1/src/census.rs +0 -314
- crates/ec-av1/src/decode/block.rs +4 -862
- crates/ec-av1/src/decode/coeffs.rs +68 -729
- crates/ec-av1/src/decode/counters.rs +0 -4459
- crates/ec-av1/src/decode/deblock.rs +33 -49
- crates/ec-av1/src/decode/frame_tile.rs +7 -346
- crates/ec-av1/src/decode/inter_block.rs +35 -375
- crates/ec-av1/src/decode/inter_block8.rs +34 -273
- crates/ec-av1/src/decode/inter_ctx.rs +4 -380
- crates/ec-av1/src/decode/inter_intra_arm.rs +0 -142
- crates/ec-av1/src/decode/inter_shapes.rs +1 -97
- crates/ec-av1/src/decode/key_tile.rs +6 -425
- crates/ec-av1/src/decode/leaf8.rs +8 -238
- crates/ec-av1/src/decode/leaf_sub8.rs +3 -157
- crates/ec-av1/src/decode/mod.rs +7 -522
- crates/ec-av1/src/decode/obmc_skip_chroma_tests.rs +0 -27
- crates/ec-av1/src/decode/post_filter.rs +10 -20
- crates/ec-av1/src/decode/rect.rs +5 -506
- crates/ec-av1/src/decode/rect4.rs +8 -364
- crates/ec-av1/src/decode/replay.rs +0 -18
- crates/ec-av1/src/decode/sub8_inter.rs +85 -285
- crates/ec-av1/src/decode/tests.rs +36 -1309
- crates/ec-av1/src/decode/tx4x8_table_tests.rs +0 -89
- crates/ec-av1/src/dumpio.rs +0 -568
- crates/ec-av1/src/encode/coef.rs +40 -31
- crates/ec-av1/src/encode/frame.rs +50 -37
- crates/ec-av1/src/encode/inter_search.rs +44 -39
- crates/ec-av1/src/encode/mod.rs +0 -50
- crates/ec-av1/src/encode/more_tests.rs +546 -1231
- crates/ec-av1/src/encode/split.rs +206 -267
- crates/ec-av1/src/encode/tests.rs +2377 -3618
- crates/ec-av1/src/encoder/tests.rs +2879 -3407
- crates/ec-av1/src/film_grain.rs +18 -54
- crates/ec-av1/src/hits.rs +0 -47
- crates/ec-av1/src/intra.rs +55 -49
- crates/ec-av1/src/lib.rs +0 -6
- crates/ec-av1/src/mc.rs +32 -25
- crates/ec-av1/src/motion_field.rs +23 -59
- crates/ec-av1/src/msac.rs +2 -286
- crates/ec-av1/src/mvstack.rs +171 -119
- crates/ec-av1/src/par.rs +9 -31
- crates/ec-av1/src/probe.rs +0 -41
- crates/ec-av1/src/quant.rs +0 -19
- crates/ec-av1/src/restoration.rs +28 -68
- crates/ec-av1/src/stack_budget.rs +0 -990
- crates/ec-av1/src/stream/mod.rs +6 -545
- crates/ec-av1/src/superres.rs +0 -2
- crates/ec-av1/src/test_source.rs +0 -103
- crates/ec-av1/src/tile/blocks.rs +10 -161
- crates/ec-av1/src/tile/mod.rs +1 -52
- crates/ec-av1/tests/real_library.rs +0 -287
Cargo.lockmodified+0 -8
| @@ -423,8 +423,6 @@ dependencies = [ | ||
| 423 | 423 | "ec-av1-syntax", |
| 424 | 424 | "ec-core", |
| 425 | 425 | "ec-testkit", |
| 426 | - "stats_alloc", | |
| 427 | - "tracking-allocator", | |
| 428 | 426 | ] |
| 429 | 427 | |
| 430 | 428 | [[package]] |
| @@ -1731,12 +1729,6 @@ version = "1.2.1" | ||
| 1731 | 1729 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1732 | 1730 | checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" |
| 1733 | 1731 | |
| 1734 | -[[package]] | |
| 1735 | -name = "stats_alloc" | |
| 1736 | -version = "0.1.10" | |
| 1737 | -source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1738 | -checksum = "5c0e04424e733e69714ca1bbb9204c1a57f09f5493439520f9f68c132ad25eec" | |
| 1739 | - | |
| 1740 | 1732 | [[package]] |
| 1741 | 1733 | name = "strength_reduce" |
| 1742 | 1734 | version = "0.2.4" |
crates/ec-av1/Cargo.tomlmodified+0 -11
| @@ -12,16 +12,5 @@ ec-av1-syntax.workspace = true | ||
| 12 | 12 | archmage = "=0.9.31-beta.1" |
| 13 | 13 | bytemuck = "1" |
| 14 | 14 | |
| 15 | -[features] | |
| 16 | -default = ["gate-counters"] | |
| 17 | -# Compiles the ~550 `*_HITS` gate counters (see `src/hits.rs`). ON by default so | |
| 18 | -# every test gate and the probe's census see the same numbers they always have; | |
| 19 | -# a shipped decoder can build `--no-default-features` to drop the TLS bump on | |
| 20 | -# each counted path -- the `*_hits()` accessors still compile and return 0. | |
| 21 | -gate-counters = [] | |
| 22 | - | |
| 23 | 15 | [dev-dependencies] |
| 24 | 16 | ec-testkit.workspace = true |
| 25 | -# `nightly` only makes StatsAlloc::new const, so it can be a #[global_allocator] static. | |
| 26 | -stats_alloc = { version = "0.1.10", features = ["nightly"] } | |
| 27 | -tracking-allocator = "0.4.0" |
crates/ec-av1/examples/alloc_probe.rsdeleted+0 -96
| @@ -1,96 +0,0 @@ | ||
| 1 | -//! Temporary lane-alloc instrument: count allocations and sample backtraces. | |
| 2 | -//! | |
| 3 | -//! Allocation totals come from `stats_alloc`. The per-size histogram and the | |
| 4 | -//! sampled backtraces come from `tracking-allocator`, which calls back into a | |
| 5 | -//! tracker on every allocation. Neither crate needs `unsafe` in this file. | |
| 6 | -//! Reallocs are excluded from totals and histogram, as the old hand-written | |
| 7 | -//! allocator did. | |
| 8 | -use std::alloc::System; | |
| 9 | -use std::collections::HashMap; | |
| 10 | -use std::sync::Mutex; | |
| 11 | -use std::sync::atomic::{AtomicUsize, Ordering}; | |
| 12 | - | |
| 13 | -use stats_alloc::StatsAlloc; | |
| 14 | -use tracking_allocator::{AllocationGroupId, AllocationRegistry, AllocationTracker, Allocator}; | |
| 15 | - | |
| 16 | -static SIZES: [AtomicUsize; 24] = [const { AtomicUsize::new(0) }; 24]; | |
| 17 | -static TRACES: Mutex<Option<HashMap<String, usize>>> = Mutex::new(None); | |
| 18 | -/// `reallocations` as of the last tracked allocation. A realloc bumps that counter | |
| 19 | -/// and then reaches the tracker as an allocation, so a bump means "not a new alloc". | |
| 20 | -static SEEN_REALLOCS: AtomicUsize = AtomicUsize::new(0); | |
| 21 | - | |
| 22 | -struct Track; | |
| 23 | -impl AllocationTracker for Track { | |
| 24 | - fn allocated(&self, _addr: usize, object_size: usize, _wrapped: usize, _g: AllocationGroupId) { | |
| 25 | - let st = A.stats(); | |
| 26 | - if st.reallocations != SEEN_REALLOCS.swap(st.reallocations, Ordering::Relaxed) { | |
| 27 | - return; | |
| 28 | - } | |
| 29 | - // `allocations` already includes this allocation; index it from 0 like the old counter. | |
| 30 | - let n = st.allocations - 1; | |
| 31 | - let cls = (usize::BITS - object_size.leading_zeros()) as usize; | |
| 32 | - SIZES[cls.min(23)].fetch_add(1, Ordering::Relaxed); | |
| 33 | - if n.is_multiple_of(512) { | |
| 34 | - let bt = format!("{}", std::backtrace::Backtrace::force_capture()); | |
| 35 | - let mut key: Vec<String> = Vec::new(); | |
| 36 | - let lines: Vec<&str> = bt.lines().collect(); | |
| 37 | - for (i, l) in lines.iter().enumerate() { | |
| 38 | - if l.contains("ec_av1::") && key.len() < 6 { | |
| 39 | - let at = lines | |
| 40 | - .get(i + 1) | |
| 41 | - .filter(|n| n.trim_start().starts_with("at ")) | |
| 42 | - .map(|n| n.trim().to_string()) | |
| 43 | - .unwrap_or_default(); | |
| 44 | - key.push(format!("{} {}", l.trim(), at)); | |
| 45 | - } | |
| 46 | - } | |
| 47 | - let mut g = TRACES.lock().unwrap(); | |
| 48 | - *g.get_or_insert_with(HashMap::new).entry(key.join(" <- ")).or_insert(0) += 1; | |
| 49 | - // The capture's own reallocs were not tracked; skip them too. | |
| 50 | - SEEN_REALLOCS.store(A.stats().reallocations, Ordering::Relaxed); | |
| 51 | - } | |
| 52 | - } | |
| 53 | - fn deallocated( | |
| 54 | - &self, | |
| 55 | - _addr: usize, | |
| 56 | - _object_size: usize, | |
| 57 | - _wrapped: usize, | |
| 58 | - _source: AllocationGroupId, | |
| 59 | - _current: AllocationGroupId, | |
| 60 | - ) { | |
| 61 | - } | |
| 62 | -} | |
| 63 | - | |
| 64 | -#[global_allocator] | |
| 65 | -static A: StatsAlloc<Allocator<System>> = StatsAlloc::new(Allocator::system()); | |
| 66 | - | |
| 67 | -fn main() { | |
| 68 | - AllocationRegistry::set_global_tracker(Track).expect("tracker"); | |
| 69 | - AllocationRegistry::enable_tracking(); | |
| 70 | - let path = std::env::args().nth(1).expect("usage: alloc_probe <stream.obu>"); | |
| 71 | - let data = std::fs::read(&path).expect("read"); | |
| 72 | - let mut shown = 0usize; | |
| 73 | - let r = ec_av1::stream::decode_stream_with(&data, |_f, _i, s| { | |
| 74 | - if s { | |
| 75 | - shown += 1; | |
| 76 | - } | |
| 77 | - Ok(()) | |
| 78 | - }); | |
| 79 | - println!("shown={shown} result={:?}", r.is_ok()); | |
| 80 | - let st = A.stats(); | |
| 81 | - println!("allocs={} bytes={}", st.allocations, st.bytes_allocated); | |
| 82 | - for (i, c) in SIZES.iter().enumerate() { | |
| 83 | - let v = c.load(Ordering::Relaxed); | |
| 84 | - if v > 0 { | |
| 85 | - println!("size 2^{i} : {v}"); | |
| 86 | - } | |
| 87 | - } | |
| 88 | - let g = TRACES.lock().unwrap(); | |
| 89 | - if let Some(m) = g.as_ref() { | |
| 90 | - let mut v: Vec<_> = m.iter().collect(); | |
| 91 | - v.sort_by_key(|(_, c)| std::cmp::Reverse(**c)); | |
| 92 | - for (k, c) in v.into_iter().take(30) { | |
| 93 | - println!("{c:6} {k}"); | |
| 94 | - } | |
| 95 | - } | |
| 96 | -} |
crates/ec-av1/examples/decode_probe.rsdeleted+0 -532
| @@ -1,532 +0,0 @@ | ||
| 1 | -//! Where does a real stream stop? Decode one AV1 file and print the answer. | |
| 2 | -//! | |
| 3 | -//! The gates in [`ec_av1::stream`] each pin one capability against one encoder | |
| 4 | -//! recipe. This asks the complementary question -- given a stream someone | |
| 5 | -//! actually produced, which refusal comes first -- and it is how the refusal | |
| 6 | -//! distribution in commit 2be815f was measured rather than reasoned about: | |
| 7 | -//! | |
| 8 | -//! ```text | |
| 9 | -//! aomenc --codec=av1 --obu -o s.obu --passes=1 --cpu-used=4 --limit=4 in.y4m | |
| 10 | -//! cargo run -p ec-av1 --example decode_probe -- s.obu | |
| 11 | -//! ``` | |
| 12 | -//! | |
| 13 | -//! Note `--obu`: [`ec_av1::stream::decode_stream`] takes a raw OBU stream, and | |
| 14 | -//! an IVF file decodes as zero frames rather than as an error. | |
| 15 | -//! | |
| 16 | -//! That run is also what disproved three refusal strings claiming an encoder | |
| 17 | -//! never writes a case it demonstrably writes, so this is a first-class | |
| 18 | -//! instrument, not a scratch file. | |
| 19 | -fn main() { | |
| 20 | - let Some(path) = std::env::args().nth(1) else { | |
| 21 | - eprintln!("usage: decode_probe <stream.obu>"); | |
| 22 | - std::process::exit(2); | |
| 23 | - }; | |
| 24 | - let data = match std::fs::read(&path) { | |
| 25 | - Ok(data) => data, | |
| 26 | - Err(e) => { | |
| 27 | - eprintln!("{path}: {e}"); | |
| 28 | - std::process::exit(2); | |
| 29 | - } | |
| 30 | - }; | |
| 31 | - let report = || { | |
| 32 | - // lane-av1unwritten r6: the subsize-guard coverage table (per call | |
| 33 | - // site, per partition value, reached vs fired). Env-gated | |
| 34 | - // (`EC_AV1_SUBSIZE_GUARD_TRACE`), so it is empty unless asked for. | |
| 35 | - ec_av1::decode::dump_subsize_guard_scan(); | |
| 36 | - ec_av1::decode::dump_subsize_arm_scan(); | |
| 37 | - // The census below reads ec-av1's gate counters; without the crate's | |
| 38 | - // `gate-counters` feature every one of them is compiled out and reads 0. | |
| 39 | - if !cfg!(feature = "gate-counters") { | |
| 40 | - println!("counters disabled (built without the gate-counters feature)"); | |
| 41 | - } | |
| 42 | - let [a444, a422, s420, r420] = ec_av1::decode::cfl_ac_arm_hits(); | |
| 43 | - println!( | |
| 44 | - "cfl_ac: 444={a444} 422={a422} 420sq={s420} 420rect={r420} q3_at={}", | |
| 45 | - ec_av1::decode::cfl_ac_q3_at_hits() | |
| 46 | - ); | |
| 47 | - let (sc, dp) = ec_av1::decode::reelc_chroma_counters(); | |
| 48 | - println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}"); | |
| 49 | - println!( | |
| 50 | - "ibc128: mu_chroma={} intra128={}", | |
| 51 | - ec_av1::decode::intra_128_in_inter_mu_chroma_hits(), | |
| 52 | - ec_av1::decode::intra_128_in_inter_hits() | |
| 53 | - ); | |
| 54 | - println!( | |
| 55 | - "chroma422_square: {}", | |
| 56 | - ec_av1::decode::chroma422_square_hits() | |
| 57 | - ); | |
| 58 | - println!("chroma422_rect: {}", ec_av1::decode::chroma422_rect_hits()); | |
| 59 | - println!("chroma422_sub8: {}", ec_av1::decode::chroma422_sub8_hits()); | |
| 60 | - println!( | |
| 61 | - "chroma422_chunk: {}", | |
| 62 | - ec_av1::decode::chroma422_chunk_hits() | |
| 63 | - ); | |
| 64 | - println!( | |
| 65 | - "chroma422_pair_wide: {}", | |
| 66 | - ec_av1::decode::chroma422_pair_wide_hits() | |
| 67 | - ); | |
| 68 | - println!( | |
| 69 | - "uv_left_ss_y: reads={} mode_diff={} smooth_diff={} split1mi={}", | |
| 70 | - ec_av1::decode::uv_left_ss_y_reads(), | |
| 71 | - ec_av1::decode::uv_left_ss_y_mode_diff_hits(), | |
| 72 | - ec_av1::decode::uv_left_ss_y_smooth_diff_hits(), | |
| 73 | - ec_av1::decode::uv_left_1mi_split_hits(), | |
| 74 | - ); | |
| 75 | - let (h, v, c) = ec_av1::stream::rect4_32_counters(); | |
| 76 | - println!( | |
| 77 | - "rect4_16_uv_pair_filt: {}", | |
| 78 | - ec_av1::decode::rect4_16_uv_pair_filt_hits() | |
| 79 | - ); | |
| 80 | - println!("rect4_32: horz={h} vert={v} coded={c}"); | |
| 81 | - println!( | |
| 82 | - "rect_intrabc_reads: {}", | |
| 83 | - ec_av1::stream::rect_intrabc_reads() | |
| 84 | - ); | |
| 85 | - let (pal_y, pal_uv) = ec_av1::stream::intra_in_inter_palette_hits(); | |
| 86 | - println!("intra_in_inter_palette: y={pal_y} uv={pal_uv}"); | |
| 87 | - println!( | |
| 88 | - "palette_422_unit_window: {}", | |
| 89 | - ec_av1::decode::palette_422_unit_window_hits() | |
| 90 | - ); | |
| 91 | - println!( | |
| 92 | - "rect64_corner_tu: 64x32={} 32x64={}", | |
| 93 | - ec_av1::stream::rect64_corner_tu_hits(0), | |
| 94 | - ec_av1::stream::rect64_corner_tu_hits(1) | |
| 95 | - ); | |
| 96 | - println!( | |
| 97 | - "leaf8_intrabc_hits: {}", | |
| 98 | - ec_av1::stream::leaf8_intrabc_hits() | |
| 99 | - ); | |
| 100 | - println!("intrabc_hits: {}", ec_av1::stream::intrabc_hits()); | |
| 101 | - println!( | |
| 102 | - "intrabc_vartx_trees: {}", | |
| 103 | - ec_av1::decode::intrabc_vartx_hits() | |
| 104 | - ); | |
| 105 | - println!( | |
| 106 | - "intrabc_vartx_mixed_leaves: {}", | |
| 107 | - ec_av1::decode::intrabc_vartx_mixed_leaves_hits() | |
| 108 | - ); | |
| 109 | - println!( | |
| 110 | - "skipped_intrabc_chroma_arm_hits: {}", | |
| 111 | - ec_av1::stream::skipped_intrabc_chroma_arm_hits() | |
| 112 | - ); | |
| 113 | - println!( | |
| 114 | - "intrabc_rect: {} (var-tx tree: {})", | |
| 115 | - ec_av1::decode::intrabc_rect_hits(), | |
| 116 | - ec_av1::decode::intrabc_rect_vartx_hits() | |
| 117 | - ); | |
| 118 | - // lane-av1-ibcrect: `use_intrabc` on a 128-root HORZ/VERT strip -- | |
| 119 | - // the shape `decode_block_128rect` used to refuse. | |
| 120 | - println!( | |
| 121 | - "intrabc_128rect: {}", | |
| 122 | - ec_av1::stream::intrabc_128rect_hits() | |
| 123 | - ); | |
| 124 | - // lane-av1-ibc128chunk: the 128-root intrabc strip's per-axis chroma | |
| 125 | - // mu-chunk walk -- unit count and the `(64>>ss_x)|(64>>ss_y)` extent. | |
| 126 | - println!( | |
| 127 | - "intrabc_128rect_chroma_chunk: units={} shape=0x{:x}", | |
| 128 | - ec_av1::stream::intrabc_128rect_chroma_chunk_hits(), | |
| 129 | - ec_av1::stream::intrabc_128rect_chunk_shape() | |
| 130 | - ); | |
| 131 | - let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); | |
| 132 | - println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); | |
| 133 | - println!( | |
| 134 | - "sub8_inter_split: groups={}", | |
| 135 | - ec_av1::decode::sub8_inter_split_hits() | |
| 136 | - ); | |
| 137 | - println!( | |
| 138 | - "skip_split_tx_override: {}", | |
| 139 | - ec_av1::decode::skip_split_tx_override_hits() | |
| 140 | - ); | |
| 141 | - println!( | |
| 142 | - "interintra_rect: {}", | |
| 143 | - ec_av1::decode::interintra_rect_hits() | |
| 144 | - ); | |
| 145 | - println!( | |
| 146 | - "gm_nontrans_small_side: {}", | |
| 147 | - ec_av1::decode::gm_nontrans_small_side_hits() | |
| 148 | - ); | |
| 149 | - println!( | |
| 150 | - "tr_reach_longer_side: {}", | |
| 151 | - ec_av1::decode::tr_reach_longer_side_hits() | |
| 152 | - ); | |
| 153 | - println!( | |
| 154 | - "mv_clamp_edge_overhang: {}", | |
| 155 | - ec_av1::mvstack::mv_clamp_edge_overhang_hits() | |
| 156 | - ); | |
| 157 | - let (h84, h48) = ec_av1::decode::sub8_inter_rect_hits(); | |
| 158 | - println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}"); | |
| 159 | - println!( | |
| 160 | - "llintra8_chroma_walk: {}", | |
| 161 | - ec_av1::decode::llintra8_chroma_walk_hits() | |
| 162 | - ); | |
| 163 | - println!( | |
| 164 | - "sub8rect444_chroma_walk: {}", | |
| 165 | - ec_av1::decode::llsub8rect444_chroma_walk_hits() | |
| 166 | - ); | |
| 167 | - let si = ec_av1::stream::sub8_intra_rect_hits(); | |
| 168 | - println!( | |
| 169 | - "sub8_intra_rect: horz8x4={} vert4x8={} chroma_ref={} mixed={} split4x4={}", | |
| 170 | - si.0, si.1, si.2, si.3, si.4 | |
| 171 | - ); | |
| 172 | - let leaf = ec_av1::stream::vartx_rect_leaf_hits(); | |
| 173 | - println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]); | |
| 174 | - // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep | |
| 175 | - // can tell "aomenc never picked one" from "it did and we decoded it". | |
| 176 | - let ab = ec_av1::decode::ab16_inter_hits_by_arm(); | |
| 177 | - println!( | |
| 178 | - "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}", | |
| 179 | - ab[0], ab[1], ab[2], ab[3] | |
| 180 | - ); | |
| 181 | - // lane-kf900 r1: the counter the skipped-8x8-split-transform gate | |
| 182 | - // asserts -- printed here so a recipe sweep can see it fire without a | |
| 183 | - // test-binary rebuild. | |
| 184 | - println!("skip_split_tx: {}", ec_av1::decode::skip_split_tx_hits()); | |
| 185 | - let es = ec_av1::decode::inter_edge_strip_hits(); | |
| 186 | - println!( | |
| 187 | - "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}", | |
| 188 | - es[0], es[1], es[2], es[3], es[4], es[5] | |
| 189 | - ); | |
| 190 | - let (h4, v4, pairs, sub8) = ec_av1::decode::inter16_rect4_counters(); | |
| 191 | - println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}"); | |
| 192 | - let leaf4 = ec_av1::stream::vartx_rect_leaf4_hits(); | |
| 193 | - println!("vartx_rect_leaf4: 8x4={} 4x8={}", leaf4[0], leaf4[1]); | |
| 194 | - // lane-av1txr: intrabc 4x8/8x4 leaves that read the inter var-tx tree | |
| 195 | - // (the symbol whose absence desynced `warped.obu`). | |
| 196 | - println!( | |
| 197 | - "rect_intrabc_vartx: {}", | |
| 198 | - ec_av1::decode::rect_intrabc_vartx_hits() | |
| 199 | - ); | |
| 200 | - let rw = ec_av1::stream::rect_wedge_hits(); | |
| 201 | - let rwi = ec_av1::stream::rect_wii_hits(); | |
| 202 | - println!("rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}"); | |
| 203 | - // lane-inter128intra r1: the 128 root's HORZ/VERT half coded INTRA in | |
| 204 | - // an INTER frame -- the arm this round implemented. | |
| 205 | - let i128 = ec_av1::stream::intra128_in_inter_counters(); | |
| 206 | - println!("intra128_in_inter: 128x64={} 64x128={}", i128[0], i128[1]); | |
| 207 | - // lane-lossless128: intra 128-axis blocks on a LOSSLESS frame (every | |
| 208 | - // plane TX_4X4) -- the shape whose reconstruction used to panic. | |
| 209 | - println!( | |
| 210 | - "intra128_lossless: {}", | |
| 211 | - ec_av1::stream::intra128_lossless_counters() | |
| 212 | - ); | |
| 213 | - let sb = ec_av1::stream::sb128_rect_counters(); | |
| 214 | - println!( | |
| 215 | - "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}", | |
| 216 | - sb.0, sb.1, sb.2, sb.3 | |
| 217 | - ); | |
| 218 | - // lane-av1-ibcrect: the interior 128-root partition arms and the key | |
| 219 | - // frame's intra 128-axis blocks, so a recipe sweep can tell "the | |
| 220 | - // encoder never chose HORZ/VERT at the 128 root" from "it did". | |
| 221 | - let p128 = ec_av1::stream::part128_census(); | |
| 222 | - println!( | |
| 223 | - "part128: split={} none={} horz={} vert={} ab={:?} intra_horz={} intra_vert={}", | |
| 224 | - p128.0, p128.1, p128.2, p128.3, p128.4, p128.5, p128.6 | |
| 225 | - ); | |
| 226 | - // lane-sbab r1: the superblock-level inter AB arms. | |
| 227 | - let sbab = ec_av1::decode::sb_ab_inter_hits_by_arm(); | |
| 228 | - println!( | |
| 229 | - "inter_ab64: horz_a={} horz_b={} vert_a={} vert_b={}", | |
| 230 | - sbab[0], sbab[1], sbab[2], sbab[3] | |
| 231 | - ); | |
| 232 | - let i4 = ec_av1::stream::intra_rect4_in_inter_counters(); | |
| 233 | - println!( | |
| 234 | - "intra_rect4_in_inter: 64x16={} 16x64={} 32x8={} 8x32={}", | |
| 235 | - i4.0, i4.1, i4.2, i4.3 | |
| 236 | - ); | |
| 237 | - // lane-cdefstrip r1: 8x8 CDEF units whose skip band no coded block | |
| 238 | - // wrote this frame -- non-zero means a decode arm forgot | |
| 239 | - // `fill_skip_grid_rect`, and CDEF filtered a unit libaom may skip. | |
| 240 | - println!( | |
| 241 | - "cdef_unwritten_skip_units: {}", | |
| 242 | - ec_av1::decode::cdef_unwritten_skip_units() | |
| 243 | - ); | |
| 244 | - println!( | |
| 245 | - "cdef_band: rect_skip_writes={} mixed_skip_units={}", | |
| 246 | - ec_av1::decode::rect_skip_band_hits(), | |
| 247 | - ec_av1::decode::cdef_mixed_skip_units() | |
| 248 | - ); | |
| 249 | - let ir = ec_av1::stream::inter_rect_counters(); | |
| 250 | - println!( | |
| 251 | - "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", | |
| 252 | - ir.0, ir.1, ir.2, ir.3, ir.4, ir.5 | |
| 253 | - ); | |
| 254 | - // lane-rectres r1: how many of those 32x8/8x32 strips coded a real | |
| 255 | - // rectangular residual transform unit (a skipped one codes none). | |
| 256 | - println!( | |
| 257 | - "sub8_chroma_tx_from_ref: {}", | |
| 258 | - ec_av1::stream::sub8_chroma_tx_from_ref_hits() | |
| 259 | - ); | |
| 260 | - let r328 = ec_av1::stream::rect32x8_inter_tu_hits(); | |
| 261 | - println!("rect32x8_inter_tu: 32x8={} 8x32={}", r328[0], r328[1]); | |
| 262 | - // lane-intra16x4: INTRA strips of an inter 16x16-level 1:4 partition. | |
| 263 | - let i164 = ec_av1::stream::intra16x4_in_inter_hits(); | |
| 264 | - println!( | |
| 265 | - "intra16x4_in_inter: 16x4={} 4x16={} chroma_ref={}", | |
| 266 | - i164.0, i164.1, i164.2 | |
| 267 | - ); | |
| 268 | - println!( | |
| 269 | - "rect4_16_pair: lossless_chroma={} intrabc={}", | |
| 270 | - ec_av1::decode::rect4_16_lossless_chroma_hits(), | |
| 271 | - ec_av1::decode::rect4_16_intrabc_hits(), | |
| 272 | - ); | |
| 273 | - println!( | |
| 274 | - "loss64: chroma_edge_tu_clip={} skip_lossless_band_reset={}", | |
| 275 | - ec_av1::decode::chroma_edge_tu_clip_hits(), | |
| 276 | - ec_av1::decode::skip_lossless_band_reset_hits(), | |
| 277 | - ); | |
| 278 | - println!( | |
| 279 | - "llband: rect_split_lossless_chroma444={}", | |
| 280 | - ec_av1::decode::rect_split_lossless_chroma444_hits() | |
| 281 | - ); | |
| 282 | - // lane-t900 r12: chroma edge-filter neighbour answered from the mi-granular | |
| 283 | - // uv_mode grid instead of the coarse one-slot-per-column map. | |
| 284 | - println!( | |
| 285 | - "scaled: leaf8={} sub8={} warpfb={} predict_scaled={}", | |
| 286 | - ec_av1::decode::scaled_leaf8_hits(), | |
| 287 | - ec_av1::decode::scaled_sub8_hits(), | |
| 288 | - ec_av1::decode::scaled_warp_fallback_hits(), | |
| 289 | - ec_av1::mc::predict_scaled_hits() | |
| 290 | - ); | |
| 291 | - println!( | |
| 292 | - "uv_mode_grid_override: {}", | |
| 293 | - ec_av1::decode::uv_mode_grid_override_hits() | |
| 294 | - ); | |
| 295 | - // lane-thread2: proof the frame-parallel path actually fired (0 at | |
| 296 | - // the default EC_AV1_THREADS=1). | |
| 297 | - println!("frames_dispatched: {}", ec_av1::stream::frames_dispatched()); | |
| 298 | - // lane-av1recipehunt: `intra_rect4_in_inter` above already reports the | |
| 299 | - // 1:4-in-inter shapes; this is the `delta_q` half of the same story -- | |
| 300 | - // how many delta_q groups the stream really carried, and how many of | |
| 301 | - // them landed inside a rect64 dequant. | |
| 302 | - let (dq, dq_drift) = ec_av1::stream::rect64_qidx_drift_counters(); | |
| 303 | - println!("delta_q: groups_read={dq} rect64_qidx_drift={dq_drift}"); | |
| 304 | - // lane-av1422census422: the per-plane coefficient-unit census, armed | |
| 305 | - // for 4:4:4 and 4:2:2 (4:2:0 arms nothing, so a 4:2:0 recipe sweep | |
| 306 | - // reads `luma=0 u=0 v=0` BY DESIGN and must not read that as "the | |
| 307 | - // walk was empty" -- `units_total` is the UNCONDITIONAL per-frame | |
| 308 | - // total, so the two together say whether the census was armed at | |
| 309 | - // all). This is what makes a 4:2:2 non-vacuity requirement | |
| 310 | - // writable: before the widening every per-plane field read zero on a | |
| 311 | - // 4:2:2 cell BY CONSTRUCTION, so a byte-exact 4:2:2 gate could | |
| 312 | - // assert it and prove nothing about the stream it had decoded. | |
| 313 | - let cu = ec_av1::decode::census_nonsub_units(); | |
| 314 | - let cc = ec_av1::decode::census_nonsub_coded(); | |
| 315 | - println!( | |
| 316 | - "census_units: luma={} u={} v={} | coded: luma={} u={} v={} | units_total={}", | |
| 317 | - cu[0], | |
| 318 | - cu[1], | |
| 319 | - cu[2], | |
| 320 | - cc[0], | |
| 321 | - cc[1], | |
| 322 | - cc[2], | |
| 323 | - ec_av1::decode::census_unit_n(), | |
| 324 | - ); | |
| 325 | - }; | |
| 326 | - // lane-tiles: the tiling a real stream actually uses is a decision input | |
| 327 | - // (every gate in `stream.rs` picks its own `--tile-columns`), so report it | |
| 328 | - // from the frame headers before saying anything about pixels. | |
| 329 | - let mut parser = ec_av1_syntax::Av1Parser::new(); | |
| 330 | - let mut seen: Vec<(u32, u32, bool, u32)> = Vec::new(); | |
| 331 | - let mut pos = 0usize; | |
| 332 | - let mut frames_seen = 0usize; | |
| 333 | - // OBU at a time, so one unparseable OBU late in the stream still leaves | |
| 334 | - // every earlier frame header's tiling reported. | |
| 335 | - while pos < data.len() { | |
| 336 | - let Ok(obu) = parser.parse_obu(&data[pos..]) else { | |
| 337 | - break; | |
| 338 | - }; | |
| 339 | - pos += obu.total_size.max(1); | |
| 340 | - let header = match &obu.kind { | |
| 341 | - ec_av1_syntax::ObuKind::FrameHeader(h) => h, | |
| 342 | - ec_av1_syntax::ObuKind::Frame(h, _) => h, | |
| 343 | - _ => continue, | |
| 344 | - }; | |
| 345 | - frames_seen += 1; | |
| 346 | - // lane-frame36: `EC_PROBE_HDR=1` prints one line per frame header, so a | |
| 347 | - // silent wall can be triaged by "which header field is new at frame N" | |
| 348 | - // before any pixel work (class: a header field parsed then never consumed). | |
| 349 | - if std::env::var("EC_PROBE_HDR").is_ok() { | |
| 350 | - let h = header; | |
| 351 | - let gm: Vec<String> = h | |
| 352 | - .global_motion | |
| 353 | - .iter() | |
| 354 | - .map(|w| format!("{:?}", w.model)) | |
| 355 | - .collect(); | |
| 356 | - println!( | |
| 357 | - "HDR {}: type={:?} show={} showable={} show_existing={}({}) intra={} \ | |
| 358 | - size={}x{} up={} superres={}/{} order_hint={} primary_ref={} refresh={:#04x} \ | |
| 359 | - refs={:?} order_hints={:?} sign_bias={:?} err_res={} disable_cdf={} \ | |
| 360 | - screen_tools={} int_mv={} intrabc={} hp_mv={} interp={:?} switchable_motion={} \ | |
| 361 | - ref_mvs={} base_q={} seg={} deltaq={} deltalf={} lf_level={:?} lf_deltas={:?}/{:?} \ | |
| 362 | - cdef_bits={} lr={:?} tx_mode={:?} ref_sel={} skip_mode={}({:?}) warp={} \ | |
| 363 | - reduced_tx={} gm={:?} grain={}/seed={} lossless={}", | |
| 364 | - frames_seen - 1, | |
| 365 | - h.frame_type, | |
| 366 | - h.show_frame, | |
| 367 | - h.showable_frame, | |
| 368 | - h.show_existing_frame, | |
| 369 | - h.frame_to_show_map_idx, | |
| 370 | - h.frame_is_intra, | |
| 371 | - h.frame_width, | |
| 372 | - h.frame_height, | |
| 373 | - h.upscaled_width, | |
| 374 | - h.use_superres, | |
| 375 | - h.superres_denom, | |
| 376 | - h.order_hint, | |
| 377 | - h.primary_ref_frame, | |
| 378 | - h.refresh_frame_flags, | |
| 379 | - h.ref_frame_idx, | |
| 380 | - h.order_hints, | |
| 381 | - h.ref_frame_sign_bias, | |
| 382 | - h.error_resilient_mode, | |
| 383 | - h.disable_cdf_update, | |
| 384 | - h.allow_screen_content_tools, | |
| 385 | - h.force_integer_mv, | |
| 386 | - h.allow_intrabc, | |
| 387 | - h.allow_high_precision_mv, | |
| 388 | - h.interpolation_filter, | |
| 389 | - h.is_motion_mode_switchable, | |
| 390 | - h.use_ref_frame_mvs, | |
| 391 | - h.quantization.base_q_idx, | |
| 392 | - h.segmentation.enabled, | |
| 393 | - h.delta.q_present, | |
| 394 | - h.delta.lf_present, | |
| 395 | - h.loop_filter.level, | |
| 396 | - h.loop_filter.ref_deltas, | |
| 397 | - h.loop_filter.mode_deltas, | |
| 398 | - h.cdef.bits, | |
| 399 | - h.loop_restoration.frame_restoration_type, | |
| 400 | - h.tx_mode, | |
| 401 | - h.reference_select, | |
| 402 | - h.skip_mode_present, | |
| 403 | - h.skip_mode_frame, | |
| 404 | - h.allow_warped_motion, | |
| 405 | - h.reduced_tx_set, | |
| 406 | - gm, | |
| 407 | - h.film_grain.apply_grain, | |
| 408 | - h.film_grain.grain_seed, | |
| 409 | - h.coded_lossless, | |
| 410 | - ); | |
| 411 | - } | |
| 412 | - let t = &header.tile_info; | |
| 413 | - let entry = (t.cols, t.rows, t.uniform_spacing, t.context_update_tile_id); | |
| 414 | - if !seen.contains(&entry) { | |
| 415 | - seen.push(entry); | |
| 416 | - } | |
| 417 | - } | |
| 418 | - println!("TILING: {frames_seen} frame headers parsed"); | |
| 419 | - // lane-sb128 r4: the superblock size decides the whole partition tree, so | |
| 420 | - // report it next to the tiling -- it is the first thing a film blocker | |
| 421 | - // triage needs. | |
| 422 | - if let Some(seq) = parser.sequence_header() { | |
| 423 | - println!( | |
| 424 | - "SEQ: use_128x128_superblock={} bit_depth={} mono_chrome={} max_frame={}x{}", | |
| 425 | - seq.use_128x128_superblock, | |
| 426 | - seq.color_config.bit_depth, | |
| 427 | - seq.color_config.mono_chrome, | |
| 428 | - seq.max_frame_width, | |
| 429 | - seq.max_frame_height | |
| 430 | - ); | |
| 431 | - } | |
| 432 | - for (cols, rows, uniform, ctx_id) in &seen { | |
| 433 | - println!( | |
| 434 | - "TILING: cols={cols} rows={rows} uniform_spacing={uniform} context_update_tile_id={ctx_id}" | |
| 435 | - ); | |
| 436 | - } | |
| 437 | - if seen.is_empty() { | |
| 438 | - println!("TILING: no frame header parsed"); | |
| 439 | - } | |
| 440 | - | |
| 441 | - // lane-streamsink r1: decode through the streaming entry point and write | |
| 442 | - // each shown frame out as it completes. The old path collected every | |
| 443 | - // picture in a Vec and then built a second full copy of the raw dump | |
| 444 | - // before one `fs::write`, so peak RSS was 2x the whole decoded segment (a | |
| 445 | - // 4K 8 s window needed >20 GiB, a whole film terabytes). Here at most one | |
| 446 | - // frame is held beyond the decoder's own DPB, and the printed lines are | |
| 447 | - // byte-identical to the old ones. | |
| 448 | - // `EC_PROBE_OUT16` is yuv420p10le (u16 LE); `EC_PROBE_OUT` / argv[2] is | |
| 449 | - // 8-bit (planes are u16, low byte taken). Either target may be a FIFO. | |
| 450 | - use std::io::Write; | |
| 451 | - let open = |path: &str| { | |
| 452 | - std::fs::OpenOptions::new() | |
| 453 | - .write(true) | |
| 454 | - .create(true) | |
| 455 | - .truncate(true) | |
| 456 | - .open(path) | |
| 457 | - .unwrap_or_else(|e| panic!("opening {path}: {e}")) | |
| 458 | - }; | |
| 459 | - let out16 = std::env::var("EC_PROBE_OUT16").ok(); | |
| 460 | - let out8 = std::env::args() | |
| 461 | - .nth(2) | |
| 462 | - .or_else(|| std::env::var("EC_PROBE_OUT").ok()); | |
| 463 | - let null16 = out16.as_deref() == Some("/dev/null"); | |
| 464 | - let mut f16 = out16.as_deref().map(open); | |
| 465 | - let mut f8 = out8.as_deref().map(open); | |
| 466 | - let mut written16 = 0usize; | |
| 467 | - let mut written8 = 0usize; | |
| 468 | - let mut shown = 0usize; | |
| 469 | - let mut dims = (0usize, 0usize); | |
| 470 | - let mut buf: Vec<u8> = Vec::new(); | |
| 471 | - // lane-av1mono: a monochrome stream is luma only, so the raw dump is a | |
| 472 | - // single plane -- exactly what `ffmpeg -pix_fmt gray -f rawvideo` writes. | |
| 473 | - let mono = parser | |
| 474 | - .sequence_header() | |
| 475 | - .is_some_and(|s| s.color_config.mono_chrome); | |
| 476 | - let result = ec_av1::stream::decode_stream_with(&data, |f, _idx, is_shown| { | |
| 477 | - if !is_shown { | |
| 478 | - return Ok(()); | |
| 479 | - } | |
| 480 | - shown += 1; | |
| 481 | - if shown == 1 { | |
| 482 | - dims = (f.width, f.height); | |
| 483 | - } | |
| 484 | - let planes: &[&Vec<u16>] = if mono { &[&f.y] } else { &[&f.y, &f.u, &f.v] }; | |
| 485 | - if let Some(w) = f16.as_mut() { | |
| 486 | - let n = 2 * planes.iter().map(|p| p.len()).sum::<usize>(); | |
| 487 | - if null16 { | |
| 488 | - // Timing runs point EC_PROBE_OUT16 at /dev/null; the u16->LE | |
| 489 | - // conversion was ~2% of the main thread for bytes nobody reads. | |
| 490 | - written16 += n; | |
| 491 | - } else { | |
| 492 | - buf.clear(); | |
| 493 | - buf.resize(n, 0); | |
| 494 | - let mut off = 0; | |
| 495 | - for p in planes { | |
| 496 | - let end = off + 2 * p.len(); | |
| 497 | - for (d, &s) in buf[off..end].as_chunks_mut::<2>().0.iter_mut().zip(p.iter()) { | |
| 498 | - d.copy_from_slice(&s.to_le_bytes()); | |
| 499 | - } | |
| 500 | - off = end; | |
| 501 | - } | |
| 502 | - w.write_all(&buf).expect("writing raw planes"); | |
| 503 | - written16 += buf.len(); | |
| 504 | - } | |
| 505 | - } | |
| 506 | - if let Some(w) = f8.as_mut() { | |
| 507 | - buf.clear(); | |
| 508 | - for p in planes { | |
| 509 | - buf.extend(p.iter().map(|&s| s as u8)); | |
| 510 | - } | |
| 511 | - w.write_all(&buf).expect("writing raw planes"); | |
| 512 | - written8 += buf.len(); | |
| 513 | - } | |
| 514 | - Ok(()) | |
| 515 | - }); | |
| 516 | - match result { | |
| 517 | - Ok(()) if shown == 0 => { | |
| 518 | - println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?"); | |
| 519 | - } | |
| 520 | - Ok(()) => { | |
| 521 | - if let Some(out) = &out16 { | |
| 522 | - println!("wrote {written16} bytes of yuv420p10le to {out}"); | |
| 523 | - } | |
| 524 | - if let Some(out) = &out8 { | |
| 525 | - println!("wrote {written8} bytes of yuv420p to {out}"); | |
| 526 | - } | |
| 527 | - println!("OK: {shown} frames decoded, {}x{}", dims.0, dims.1); | |
| 528 | - } | |
| 529 | - Err(e) => println!("REFUSED: {e}"), | |
| 530 | - } | |
| 531 | - report(); | |
| 532 | -} |
crates/ec-av1/examples/syntax_census.rsdeleted+0 -375
| @@ -1,375 +0,0 @@ | ||
| 1 | -//! Syntax census of one AV1 stream: what it actually codes, per frame type. | |
| 2 | -//! | |
| 3 | -//! `EC_AV1_BITCENSUS=1 cargo run --release -p ec-av1 --example syntax_census \ | |
| 4 | -//! -- stream.obu [source.yuv]` | |
| 5 | -//! | |
| 6 | -//! The stream may be a raw OBU stream or an IVF file (unwrapped here). The | |
| 7 | -//! optional second argument is the ENCODER'S INPUT as planar 8-bit yuv420p at | |
| 8 | -//! the coded size, and turns on a per-displayed-frame PSNR -- computed here, | |
| 9 | -//! against the decoded pictures, because ffmpeg's own PSNR of an OBU stream | |
| 10 | -//! reads a constant ~28.8 dB (no timing in an OBU stream; ledger dead-end). | |
| 11 | -//! | |
| 12 | -//! Every number comes from `ec_av1::census`, i.e. from the decoder, so our | |
| 13 | -//! stream and any other encoder's stream are measured by the same reader. | |
| 14 | - | |
| 15 | -use ec_av1::census::Frame; | |
| 16 | -use std::collections::BTreeMap; | |
| 17 | - | |
| 18 | -/// The payloads of an IVF file's frames concatenated, or the data unchanged | |
| 19 | -/// when it is already a raw OBU stream. | |
| 20 | -fn unwrap_ivf(data: &[u8]) -> Vec<u8> { | |
| 21 | - if data.len() < 32 || &data[..4] != b"DKIF" { | |
| 22 | - return data.to_vec(); | |
| 23 | - } | |
| 24 | - let header = u16::from_le_bytes([data[6], data[7]]) as usize; | |
| 25 | - let (mut pos, mut out) = (header, Vec::new()); | |
| 26 | - while pos + 12 <= data.len() { | |
| 27 | - let len = u32::from_le_bytes([data[pos], data[pos + 1], data[pos + 2], data[pos + 3]]) | |
| 28 | - as usize; | |
| 29 | - pos += 12; | |
| 30 | - if pos + len > data.len() { | |
| 31 | - break; | |
| 32 | - } | |
| 33 | - out.extend_from_slice(&data[pos..pos + len]); | |
| 34 | - pos += len; | |
| 35 | - } | |
| 36 | - out | |
| 37 | -} | |
| 38 | - | |
| 39 | -fn psnr(a: &[u16], b: &[u16]) -> f64 { | |
| 40 | - let se: f64 = a | |
| 41 | - .iter() | |
| 42 | - .zip(b) | |
| 43 | - .map(|(&x, &y)| { | |
| 44 | - let d = f64::from(x) - f64::from(y); | |
| 45 | - d * d | |
| 46 | - }) | |
| 47 | - .sum(); | |
| 48 | - match se { | |
| 49 | - 0.0 => 99.0, | |
| 50 | - _ => 10.0 * (255.0 * 255.0 * a.len() as f64 / se).log10(), | |
| 51 | - } | |
| 52 | -} | |
| 53 | - | |
| 54 | -/// Which broad syntax family a CDF table belongs to. | |
| 55 | -fn family_group(name: &str) -> &'static str { | |
| 56 | - const COEFF: [&str; 7] = | |
| 57 | - ["txb_skip", "eob_pt", "eob_extra", "base_", "base_eob", "br_", "dc_sign"]; | |
| 58 | - if name.contains("tx_type") { | |
| 59 | - return "txtype"; | |
| 60 | - } | |
| 61 | - if COEFF.iter().any(|p| name.starts_with(p)) { | |
| 62 | - return "coeff"; | |
| 63 | - } | |
| 64 | - if name.starts_with("mv_") || name.starts_with("dv_") { | |
| 65 | - return "mv"; | |
| 66 | - } | |
| 67 | - if name.starts_with("partition") || name.starts_with("txfm_partition") { | |
| 68 | - return "partition"; | |
| 69 | - } | |
| 70 | - if name.starts_with("tx_size") { | |
| 71 | - return "txsize"; | |
| 72 | - } | |
| 73 | - if name == "literal" || name == "unregistered" { | |
| 74 | - return "literal"; | |
| 75 | - } | |
| 76 | - "mode" | |
| 77 | -} | |
| 78 | - | |
| 79 | -/// Sums a set of frames into one row's worth of census. | |
| 80 | -fn merge(frames: &[&Frame]) -> Frame { | |
| 81 | - let mut out = Frame::default(); | |
| 82 | - for f in frames { | |
| 83 | - out.bytes += f.bytes; | |
| 84 | - for (k, v) in &f.blocks { | |
| 85 | - *out.blocks.entry(*k).or_default() += v; | |
| 86 | - } | |
| 87 | - for (k, v) in &f.tx { | |
| 88 | - *out.tx.entry(*k).or_default() += v; | |
| 89 | - } | |
| 90 | - for (k, v) in &f.tx_type { | |
| 91 | - *out.tx_type.entry(*k).or_default() += v; | |
| 92 | - } | |
| 93 | - for (k, v) in &f.families { | |
| 94 | - let e = out.families.entry(k).or_default(); | |
| 95 | - e.0 += v.0; | |
| 96 | - e.1 += v.1; | |
| 97 | - } | |
| 98 | - for i in 0..3 { | |
| 99 | - out.area[i] += f.area[i]; | |
| 100 | - } | |
| 101 | - for i in 0..8 { | |
| 102 | - out.refs[i] += f.refs[i]; | |
| 103 | - } | |
| 104 | - for i in 0..4 { | |
| 105 | - out.modes[i] += f.modes[i]; | |
| 106 | - } | |
| 107 | - for i in 0..6 { | |
| 108 | - out.mv[i] += f.mv[i]; | |
| 109 | - } | |
| 110 | - out.skip_area += f.skip_area; | |
| 111 | - } | |
| 112 | - out | |
| 113 | -} | |
| 114 | - | |
| 115 | -fn pct(n: u64, total: u64) -> String { | |
| 116 | - format!("{:.1}%", 100.0 * n as f64 / total.max(1) as f64) | |
| 117 | -} | |
| 118 | - | |
| 119 | -const REFS: [&str; 8] = | |
| 120 | - ["INTRA", "LAST", "LAST2", "LAST3", "GOLDEN", "BWDREF", "ALTREF2", "ALTREF"]; | |
| 121 | - | |
| 122 | -fn report(label: &str, f: &Frame, frames: usize) { | |
| 123 | - let area = f.area.iter().sum::<u64>().max(1); | |
| 124 | - println!("\n== {label} ({frames} frames, {} bytes) ==", f.bytes); | |
| 125 | - println!( | |
| 126 | - " area: intra {} single-ref {} compound {} | skip {}", | |
| 127 | - pct(f.area[0], area), | |
| 128 | - pct(f.area[1], area), | |
| 129 | - pct(f.area[2], area), | |
| 130 | - pct(f.skip_area, area), | |
| 131 | - ); | |
| 132 | - println!( | |
| 133 | - " refs (area): {}", | |
| 134 | - REFS.iter() | |
| 135 | - .enumerate() | |
| 136 | - .filter(|(i, _)| f.refs[*i] > 0) | |
| 137 | - .map(|(i, n)| format!("{n} {}", pct(f.refs[i], area))) | |
| 138 | - .collect::<Vec<_>>() | |
| 139 | - .join(" "), | |
| 140 | - ); | |
| 141 | - let modes = f.modes.iter().sum::<u64>(); | |
| 142 | - println!( | |
| 143 | - " single-ref modes: NEW {} GLOBAL {} NEAREST {} NEAR {} (of {modes})", | |
| 144 | - pct(f.modes[0], modes), | |
| 145 | - pct(f.modes[1], modes), | |
| 146 | - pct(f.modes[2], modes), | |
| 147 | - pct(f.modes[3], modes), | |
| 148 | - ); | |
| 149 | - let mvs = f.mv.iter().sum::<u64>(); | |
| 150 | - println!( | |
| 151 | - " coded mv |max| (1/8 pel): 0 {} <=8 {} <=32 {} <=128 {} <=512 {} >512 {} (of {mvs})", | |
| 152 | - pct(f.mv[0], mvs), | |
| 153 | - pct(f.mv[1], mvs), | |
| 154 | - pct(f.mv[2], mvs), | |
| 155 | - pct(f.mv[3], mvs), | |
| 156 | - pct(f.mv[4], mvs), | |
| 157 | - pct(f.mv[5], mvs), | |
| 158 | - ); | |
| 159 | - let blocks: u64 = f.blocks.values().sum(); | |
| 160 | - let mut by_size: Vec<_> = f.blocks.iter().collect(); | |
| 161 | - by_size.sort_by_key(|(_, n)| std::cmp::Reverse(**n)); | |
| 162 | - println!( | |
| 163 | - " blocks ({blocks} total): {}", | |
| 164 | - by_size | |
| 165 | - .iter() | |
| 166 | - .take(10) | |
| 167 | - .map(|((w, h), n)| format!("{w}x{h} {}", pct(**n, blocks))) | |
| 168 | - .collect::<Vec<_>>() | |
| 169 | - .join(" "), | |
| 170 | - ); | |
| 171 | - let txs: u64 = f.tx.values().sum(); | |
| 172 | - let mut by_tx: Vec<_> = f.tx.iter().collect(); | |
| 173 | - by_tx.sort_by_key(|(_, n)| std::cmp::Reverse(**n)); | |
| 174 | - println!( | |
| 175 | - " published luma tx ({txs}): {}", | |
| 176 | - by_tx | |
| 177 | - .iter() | |
| 178 | - .take(8) | |
| 179 | - .map(|((w, h), n)| format!("{w}x{h} {}", pct(**n, txs))) | |
| 180 | - .collect::<Vec<_>>() | |
| 181 | - .join(" "), | |
| 182 | - ); | |
| 183 | - let tts: u64 = f.tx_type.values().sum(); | |
| 184 | - println!( | |
| 185 | - " tx_type symbols ({tts}): {}", | |
| 186 | - f.tx_type | |
| 187 | - .iter() | |
| 188 | - .map(|((len, sym), n)| format!("set{len}/{sym} {}", pct(*n, tts))) | |
| 189 | - .collect::<Vec<_>>() | |
| 190 | - .join(" "), | |
| 191 | - ); | |
| 192 | - // lane-libcen: the coding TOOLS, by name, so a level row says which of | |
| 193 | - // them the stream codes at all -- a table absent here is a tool this | |
| 194 | - // encoder never wrote (class `gate-blind-to-feature`). | |
| 195 | - const TOOLS: [&str; 16] = [ | |
| 196 | - "motion_mode", | |
| 197 | - "obmc", | |
| 198 | - "interintra", | |
| 199 | - "wedge_interintra", | |
| 200 | - "wedge_idx", | |
| 201 | - "compound_type", | |
| 202 | - "comp_group_idx", | |
| 203 | - "compound_idx", | |
| 204 | - "switchable_interp", | |
| 205 | - "palette_y_mode", | |
| 206 | - "palette_uv_mode", | |
| 207 | - "intrabc", | |
| 208 | - "filter_intra", | |
| 209 | - "cfl_alpha", | |
| 210 | - "delta_q", | |
| 211 | - "segment_id", | |
| 212 | - ]; | |
| 213 | - println!( | |
| 214 | - " tools (symbols/bits): {}", | |
| 215 | - TOOLS | |
| 216 | - .iter() | |
| 217 | - .map(|t| { | |
| 218 | - let (n, bits) = f.families.get(t).copied().unwrap_or((0, 0.0)); | |
| 219 | - format!("{t} {n}/{bits:.0}") | |
| 220 | - }) | |
| 221 | - .collect::<Vec<_>>() | |
| 222 | - .join(" "), | |
| 223 | - ); | |
| 224 | - | |
| 225 | - // Bits by family group, then the ten biggest tables inside them. | |
| 226 | - let mut groups: BTreeMap<&str, (u64, f64)> = BTreeMap::new(); | |
| 227 | - for (name, (n, bits)) in &f.families { | |
| 228 | - let e = groups.entry(family_group(name)).or_default(); | |
| 229 | - e.0 += n; | |
| 230 | - e.1 += bits; | |
| 231 | - } | |
| 232 | - let total_bits: f64 = groups.values().map(|g| g.1).sum(); | |
| 233 | - println!(" bits by family (census total {:.0} bits vs {} payload bits):", total_bits, f.bytes * 8); | |
| 234 | - for (g, (n, bits)) in &groups { | |
| 235 | - println!( | |
| 236 | - " {g:<10} {:>12.0} bits {:>6} ({n} symbols)", | |
| 237 | - bits, | |
| 238 | - format!("{:.1}%", 100.0 * bits / total_bits.max(1.0)) | |
| 239 | - ); | |
| 240 | - } | |
| 241 | - let mut tables: Vec<_> = f.families.iter().collect(); | |
| 242 | - tables.sort_by(|a, b| b.1 .1.total_cmp(&a.1 .1)); | |
| 243 | - // lane-cen3: how many tables the row names. The default 8 hides the | |
| 244 | - // mode family's own split (a level can spend 40% of its bits on `mode` | |
| 245 | - // with no mode table in its top 8), so a census that has to rank | |
| 246 | - // per-table gaps between two encoders sets `EC_CENSUS_TABLES`. | |
| 247 | - let top = std::env::var("EC_CENSUS_TABLES") | |
| 248 | - .ok() | |
| 249 | - .and_then(|v| v.parse().ok()) | |
| 250 | - .unwrap_or(8usize); | |
| 251 | - println!( | |
| 252 | - " top tables: {}", | |
| 253 | - tables | |
| 254 | - .iter() | |
| 255 | - .take(top) | |
| 256 | - .map(|(name, (_, bits))| format!("{name} {:.1}%", 100.0 * bits / total_bits.max(1.0))) | |
| 257 | - .collect::<Vec<_>>() | |
| 258 | - .join(" "), | |
| 259 | - ); | |
| 260 | -} | |
| 261 | - | |
| 262 | -fn main() { | |
| 263 | - let args: Vec<String> = std::env::args().skip(1).collect(); | |
| 264 | - let Some(path) = args.first() else { | |
| 265 | - eprintln!("usage: syntax_census <stream.obu|stream.ivf> [source.yuv]"); | |
| 266 | - std::process::exit(2); | |
| 267 | - }; | |
| 268 | - assert!(ec_av1::census::on(), "set EC_AV1_BITCENSUS=1"); | |
| 269 | - let data = unwrap_ivf(&std::fs::read(path).expect("stream")); | |
| 270 | - let pictures = ec_av1::stream::decode_stream(&data).expect("decode"); | |
| 271 | - let frames = ec_av1::census::take(); | |
| 272 | - | |
| 273 | - println!("# syntax census of {path} ({} bytes)", data.len()); | |
| 274 | - println!("\n| frame | kind | q | bytes | lf | cdef bits/y/uv | lr | dq | seg |"); | |
| 275 | - println!("|---|---|---|---|---|---|---|---|---|"); | |
| 276 | - for f in &frames { | |
| 277 | - println!( | |
| 278 | - "| {} | {} | {} | {} | {}/{} | {}/{}/{} | {:?} | {} | {} |", | |
| 279 | - f.idx, | |
| 280 | - f.kind, | |
| 281 | - f.qindex, | |
| 282 | - f.bytes, | |
| 283 | - f.lf[0], | |
| 284 | - f.lf[1], | |
| 285 | - f.cdef[0], | |
| 286 | - f.cdef[1], | |
| 287 | - f.cdef[2], | |
| 288 | - f.lr, | |
| 289 | - u8::from(f.delta_q), | |
| 290 | - u8::from(f.segmentation), | |
| 291 | - ); | |
| 292 | - } | |
| 293 | - // PSNR is per DISPLAYED picture, in display order, which is not the order | |
| 294 | - // the frames above are coded in (a pyramid codes a hidden ARF ahead of the | |
| 295 | - // leaves that predict from it, and re-outputs it later with | |
| 296 | - // `show_existing_frame`) -- so it is its own table rather than a column. | |
| 297 | - let mut psnrs: Vec<(f64, f64, f64)> = Vec::new(); | |
| 298 | - if let Some(src) = args.get(1).map(|p| std::fs::read(p).expect("source")) { | |
| 299 | - let mut sum = 0.0; | |
| 300 | - let mut rows = Vec::new(); | |
| 301 | - for (i, pic) in pictures.iter().enumerate() { | |
| 302 | - let (luma, chroma) = (pic.width * pic.height, pic.width * pic.height / 4); | |
| 303 | - let frame_len = luma + 2 * chroma; | |
| 304 | - let Some(b) = src.get(i * frame_len..(i + 1) * frame_len) else { break }; | |
| 305 | - let want: Vec<u16> = b[..luma].iter().map(|&v| u16::from(v)).collect(); | |
| 306 | - // lane-arfpred: the chroma planes too -- an anchor's byte gap can | |
| 307 | - // sit in a plane the luma-only line cannot see (class | |
| 308 | - // `metric blind to a plane`). | |
| 309 | - let wu: Vec<u16> = b[luma..luma + chroma].iter().map(|&v| u16::from(v)).collect(); | |
| 310 | - let wv: Vec<u16> = b[luma + chroma..frame_len].iter().map(|&v| u16::from(v)).collect(); | |
| 311 | - let p = psnr(&pic.y, &want); | |
| 312 | - psnrs.push((p, psnr(&pic.u, &wu), psnr(&pic.v, &wv))); | |
| 313 | - sum += p; | |
| 314 | - rows.push(format!("{i}:{p:.2}")); | |
| 315 | - } | |
| 316 | - println!( | |
| 317 | - "\nPSNR-Y display order ({} pictures): {}\nPSNR-Y mean {:.3} dB over {} pictures", | |
| 318 | - pictures.len(), | |
| 319 | - rows.join(" "), | |
| 320 | - sum / rows.len() as f64, | |
| 321 | - rows.len(), | |
| 322 | - ); | |
| 323 | - } | |
| 324 | - | |
| 325 | - // lane-arfcen: one full report PER CODED FRAME, so an ARF of ours can be | |
| 326 | - // put next to the reference encoder's ARF at the same display position. | |
| 327 | - if std::env::var("EC_CENSUS_PERFRAME").as_deref() == Ok("1") { | |
| 328 | - for f in &frames { | |
| 329 | - let (p, pu, pv) = | |
| 330 | - psnrs.get(f.order_hint as usize).copied().unwrap_or((f64::NAN, f64::NAN, f64::NAN)); | |
| 331 | - let refs: Vec<String> = (0..7) | |
| 332 | - .filter(|i| f.refs[i + 1] > 0) | |
| 333 | - .map(|i| { | |
| 334 | - format!( | |
| 335 | - "{}@{:+}", | |
| 336 | - REFS[i + 1], | |
| 337 | - i64::from(f.ref_hints[i]) - i64::from(f.order_hint), | |
| 338 | - ) | |
| 339 | - }) | |
| 340 | - .collect(); | |
| 341 | - report( | |
| 342 | - &format!( | |
| 343 | - "frame {} {} hint {} q {} PSNR-Y {p:.2} U {pu:.2} V {pv:.2} dB refs [{}]", | |
| 344 | - f.idx, | |
| 345 | - f.kind, | |
| 346 | - f.order_hint, | |
| 347 | - f.qindex, | |
| 348 | - refs.join(" "), | |
| 349 | - ), | |
| 350 | - f, | |
| 351 | - 1, | |
| 352 | - ); | |
| 353 | - } | |
| 354 | - } | |
| 355 | - | |
| 356 | - for kind in ["key", "arf", "leaf"] { | |
| 357 | - let set: Vec<&Frame> = frames.iter().filter(|f| f.kind == kind).collect(); | |
| 358 | - if !set.is_empty() { | |
| 359 | - report(kind, &merge(&set), set.len()); | |
| 360 | - } | |
| 361 | - } | |
| 362 | - report("ALL", &merge(&frames.iter().collect::<Vec<_>>()), frames.len()); | |
| 363 | - // The self-check: every coded block is published exactly once, so the | |
| 364 | - // censused area must be the frame's own mi area (a funnel that misses a | |
| 365 | - // block class would silently under-count every share above). | |
| 366 | - if let Some(pic) = pictures.first() { | |
| 367 | - let all = merge(&frames.iter().collect::<Vec<_>>()); | |
| 368 | - let want = (pic.width.div_ceil(4) * pic.height.div_ceil(4) * frames.len()) as u64; | |
| 369 | - let got = all.area.iter().sum::<u64>(); | |
| 370 | - println!( | |
| 371 | - "\ncoverage: censused block area {got} of {want} mi ({:.2}%)", | |
| 372 | - 100.0 * got as f64 / want as f64 | |
| 373 | - ); | |
| 374 | - } | |
| 375 | -} |
crates/ec-av1/src/census.rsdeleted+0 -314
| @@ -1,314 +0,0 @@ | ||
| 1 | -//! Syntax census: what a stream actually codes, per frame, read off the | |
| 2 | -//! decoder itself (`EC_AV1_BITCENSUS=1`). | |
| 3 | -//! | |
| 4 | -//! Every number here is a decode-side observation, so OUR stream and any | |
| 5 | -//! other encoder's stream are measured by the same reader -- which is the | |
| 6 | -//! whole point: a BD-rate gap says our stream is bigger, it never says which | |
| 7 | -//! syntax it is bigger in. The accountant is off by default and costs one | |
| 8 | -//! relaxed atomic load per symbol when off. | |
| 9 | -//! | |
| 10 | -//! Bits are charged per CDF TABLE, not per hand-labelled call site: a tile | |
| 11 | -//! registers the address range of every field of its `Cdfs` (see | |
| 12 | -//! [`register_cdfs`]), and [`charge`] maps the table a symbol read to that | |
| 13 | -//! field's name. So a new coding tool joins the census the day its CDF joins | |
| 14 | -//! the struct, with no call-site edits (class `gate-blind-to-feature`). | |
| 15 | -//! | |
| 16 | -//! Run it through `examples/syntax_census.rs`; `EC_AV1_THREADS` must be 1 | |
| 17 | -//! (the default) so the frame the counters attribute to is the frame being | |
| 18 | -//! parsed. | |
| 19 | - | |
| 20 | -use std::collections::BTreeMap; | |
| 21 | -use std::sync::atomic::{AtomicBool, Ordering}; | |
| 22 | -use std::sync::{Mutex, OnceLock}; | |
| 23 | - | |
| 24 | -static ON: AtomicBool = AtomicBool::new(false); | |
| 25 | - | |
| 26 | -/// Whether the accountant is armed (`EC_AV1_BITCENSUS=1`, read once). | |
| 27 | -#[inline] | |
| 28 | -pub fn on() -> bool { | |
| 29 | - static INIT: OnceLock<bool> = OnceLock::new(); | |
| 30 | - | |
| 31 | - *INIT.get_or_init(|| { | |
| 32 | - let armed = crate::envflags::var("EC_AV1_BITCENSUS").ok().as_deref() == Some("1"); | |
| 33 | - ON.store(armed, Ordering::Relaxed); | |
| 34 | - armed | |
| 35 | - }) | |
| 36 | -} | |
| 37 | - | |
| 38 | -/// The per-symbol fast path: one relaxed load, nothing else, when off. | |
| 39 | -#[inline] | |
| 40 | -pub(crate) fn armed() -> bool { | |
| 41 | - ON.load(Ordering::Relaxed) | |
| 42 | -} | |
| 43 | - | |
| 44 | -/// One coded frame's census. | |
| 45 | -#[derive(Default, Debug, Clone)] | |
| 46 | -pub struct Frame { | |
| 47 | - /// Decode-order index. | |
| 48 | - pub idx: usize, | |
| 49 | - /// `key` (intra), `arf` (coded but not shown) or `leaf` (coded and shown). | |
| 50 | - pub kind: &'static str, | |
| 51 | - /// `base_q_idx`. | |
| 52 | - pub qindex: u8, | |
| 53 | - /// `OrderHint` of this frame, i.e. its display position (lane-arfcen). | |
| 54 | - pub order_hint: u32, | |
| 55 | - /// `OrderHints[LAST..=ALTREF]`, so a row can name its references' display | |
| 56 | - /// distance rather than only which slot it read (lane-arfcen). | |
| 57 | - pub ref_hints: [u32; 7], | |
| 58 | - /// Tile payload bytes of this frame. | |
| 59 | - pub bytes: usize, | |
| 60 | - /// `delta_q_present`. | |
| 61 | - pub delta_q: bool, | |
| 62 | - /// `segmentation_enabled`. | |
| 63 | - pub segmentation: bool, | |
| 64 | - /// `loop_filter_level[0..2]`. | |
| 65 | - pub lf: [u8; 2], | |
| 66 | - /// `cdef_bits`, `cdef_y_pri_strength[0]`, `cdef_uv_pri_strength[0]`. | |
| 67 | - pub cdef: [u8; 3], | |
| 68 | - /// `FrameRestorationType` per plane. | |
| 69 | - pub lr: [u8; 3], | |
| 70 | - /// Coded block shapes: (width, height) in pixels -> block count. | |
| 71 | - pub blocks: BTreeMap<(u16, u16), u64>, | |
| 72 | - /// Luma area (in 4x4 units) coded intra / single-ref inter / compound. | |
| 73 | - pub area: [u64; 3], | |
| 74 | - /// Luma area per reference frame slot (index 0 = intra, 1..=7 = | |
| 75 | - /// LAST..ALTREF as `ref_frame` names them). | |
| 76 | - pub refs: [u64; 8], | |
| 77 | - /// Luma area with `skip` set. | |
| 78 | - pub skip_area: u64, | |
| 79 | - /// NEWMV / GLOBALMV / NEARESTMV / NEARMV blocks (single-ref reads). | |
| 80 | - pub modes: [u64; 4], | |
| 81 | - /// Coded motion vectors bucketed by max(|x|,|y|) in eighth-pel: | |
| 82 | - /// 0, <=8 (1px), <=32, <=128, <=512, >512. | |
| 83 | - pub mv: [u64; 6], | |
| 84 | - /// Published luma transform shapes: (width, height) in pixels -> count. | |
| 85 | - pub tx: BTreeMap<(u16, u16), u64>, | |
| 86 | - /// Coded `tx_type` symbols: (CDF row length, symbol) -> count. The row | |
| 87 | - /// length names the transform SET (17 = all 16 types, 13, 8, 6 = the | |
| 88 | - /// reduced sets); symbol 0 is that set's first inverse-table entry. | |
| 89 | - pub tx_type: BTreeMap<(u8, u8), u64>, | |
| 90 | - /// Per-CDF-table (symbol count, bits). | |
| 91 | - pub families: BTreeMap<&'static str, (u64, f64)>, | |
| 92 | -} | |
| 93 | - | |
| 94 | -#[derive(Default)] | |
| 95 | -struct State { | |
| 96 | - frames: Vec<Frame>, | |
| 97 | - /// Sorted (start address, end address, field name) of the live tile's | |
| 98 | - /// `Cdfs`. | |
| 99 | - tables: Vec<(usize, usize, &'static str)>, | |
| 100 | - /// Area of the block most recently published, so `compound` can move it. | |
| 101 | - last_block_area: u64, | |
| 102 | -} | |
| 103 | - | |
| 104 | -fn state() -> &'static Mutex<State> { | |
| 105 | - static S: OnceLock<Mutex<State>> = OnceLock::new(); | |
| 106 | - S.get_or_init(|| Mutex::new(State::default())) | |
| 107 | -} | |
| 108 | - | |
| 109 | -fn with<R>(f: impl FnOnce(&mut State) -> R) -> R { | |
| 110 | - f(&mut state().lock().unwrap_or_else(std::sync::PoisonError::into_inner)) | |
| 111 | -} | |
| 112 | - | |
| 113 | -fn cur(s: &mut State) -> &mut Frame { | |
| 114 | - if s.frames.is_empty() { | |
| 115 | - s.frames.push(Frame::default()); | |
| 116 | - } | |
| 117 | - s.frames.last_mut().expect("pushed above") | |
| 118 | -} | |
| 119 | - | |
| 120 | -/// Every frame censused since the last call, and clears the record. | |
| 121 | -pub fn take() -> Vec<Frame> { | |
| 122 | - with(|s| std::mem::take(&mut s.frames)) | |
| 123 | -} | |
| 124 | - | |
| 125 | -/// Opens a new frame's row -- called once per coded frame, before its tiles. | |
| 126 | -pub(crate) fn frame_start(header: &ec_av1_syntax::FrameHeader, bytes: usize, idx: usize) { | |
| 127 | - if !armed() { | |
| 128 | - return; | |
| 129 | - } | |
| 130 | - let kind = match (header.frame_is_intra, header.show_frame) { | |
| 131 | - (true, _) => "key", | |
| 132 | - (false, false) => "arf", | |
| 133 | - (false, true) => "leaf", | |
| 134 | - }; | |
| 135 | - with(|s| { | |
| 136 | - s.frames.push(Frame { | |
| 137 | - idx, | |
| 138 | - kind, | |
| 139 | - qindex: header.quantization.base_q_idx, | |
| 140 | - order_hint: header.order_hint, | |
| 141 | - ref_hints: header.order_hints, | |
| 142 | - bytes, | |
| 143 | - delta_q: header.delta.q_present, | |
| 144 | - segmentation: header.segmentation.enabled, | |
| 145 | - lf: [header.loop_filter.level[0], header.loop_filter.level[1]], | |
| 146 | - cdef: [ | |
| 147 | - header.cdef.bits, | |
| 148 | - header.cdef.y_pri_strength[0], | |
| 149 | - header.cdef.uv_pri_strength[0], | |
| 150 | - ], | |
| 151 | - lr: [ | |
| 152 | - header.loop_restoration.frame_restoration_type[0] as u8, | |
| 153 | - header.loop_restoration.frame_restoration_type[1] as u8, | |
| 154 | - header.loop_restoration.frame_restoration_type[2] as u8, | |
| 155 | - ], | |
| 156 | - ..Frame::default() | |
| 157 | - }); | |
| 158 | - }); | |
| 159 | -} | |
| 160 | - | |
| 161 | -/// Registers the address range of every CDF table of the tile's own `Cdfs`, | |
| 162 | -/// so [`charge`] can name the family a symbol was read with. Called once per | |
| 163 | -/// tile, right where the tile's symbol decoder is built. | |
| 164 | -pub(crate) fn register_cdfs(c: &crate::cdf_state::Cdfs) { | |
| 165 | - if !armed() { | |
| 166 | - return; | |
| 167 | - } | |
| 168 | - macro_rules! ranges { | |
| 169 | - ($($name:ident),* $(,)?) => { | |
| 170 | - vec![$({ | |
| 171 | - let start = std::ptr::addr_of!(c.$name) as usize; | |
| 172 | - (start, start + std::mem::size_of_val(&c.$name), stringify!($name)) | |
| 173 | - }),*] | |
| 174 | - }; | |
| 175 | - } | |
| 176 | - let mut tables: Vec<(usize, usize, &'static str)> = ranges![ | |
| 177 | - partition_w128, partition_w64, partition_w32, txfm_partition, skip, kf_y_mode, | |
| 178 | - uv_mode_no_cfl, uv_mode_cfl, cfl_sign, cfl_alpha, angle_delta, txb_skip_luma_16, | |
| 179 | - txb_skip_luma_8, txb_skip_luma_4, txb_skip_chroma_8, txb_skip_chroma_4, eob_pt_256_luma, eob_pt_64_luma, | |
| 180 | - eob_pt_64_chroma, eob_pt_16_chroma, eob_pt_16_luma, eob_pt_16_luma_class1, eob_pt_64_luma_class1, eob_pt_16_chroma_class1, | |
| 181 | - eob_pt_64_chroma_class1, eob_pt_128_chroma_class1, eob_pt_128_luma_class1, eob_pt_32_chroma_class1, eob_pt_256_luma_class1, eob_pt_256_chroma_class1, | |
| 182 | - eob_pt_512_luma_class1, eob_pt_512_chroma_class1, eob_pt_1024_luma_class1, eob_pt_1024_chroma_class1, eob_pt_32_luma, eob_pt_32_luma_class1, | |
| 183 | - eob_extra_luma_16, eob_extra_luma_8, eob_extra_luma_4, eob_extra_chroma_8, eob_extra_chroma_4, base_luma_16, | |
| 184 | - base_luma_8, base_luma_4, base_chroma_8, base_chroma_4, base_eob_luma_16, base_eob_luma_8, | |
| 185 | - base_eob_luma_4, base_eob_chroma_8, base_eob_chroma_4, br_luma_16, br_luma_8, br_luma_4, | |
| 186 | - br_chroma_8, br_chroma_4, partition_w16, partition_w8, txb_skip_luma_32, txb_skip_luma_64, | |
| 187 | - txb_skip_chroma_16, txb_skip_chroma_32, eob_pt_1024_luma, eob_pt_1024_chroma, eob_pt_256_chroma, eob_pt_512_luma, | |
| 188 | - eob_pt_128_chroma, eob_pt_512_chroma, eob_pt_128_luma, eob_pt_32_chroma, eob_extra_luma_32, eob_extra_luma_64, | |
| 189 | - eob_extra_chroma_16, eob_extra_chroma_32, base_luma_32, base_luma_64, base_chroma_16, base_chroma_32, | |
| 190 | - base_eob_luma_32, base_eob_luma_64, base_eob_chroma_16, base_eob_chroma_32, br_luma_32, br_chroma_16, | |
| 191 | - br_chroma_32, dc_sign_luma, intra_tx_type_16, intra_tx_type_8, intra_tx_type_8_set1, intra_tx_type_4, | |
| 192 | - intra_tx_type_4_set1, inter_tx_type_32, inter_tx_type_16, inter_tx_type_8, inter_tx_type_16_set2, inter_tx_type_8_set1, | |
| 193 | - inter_tx_type_4, inter_tx_type_4_set1, dc_sign_chroma, intra_inter, single_ref, comp_mode, | |
| 194 | - skip_mode, obmc, motion_mode, interintra, interintra_mode, wedge_interintra, | |
| 195 | - compound_type, wedge_idx, inter_compound_mode, comp_ref_type, uni_comp_ref, comp_ref, | |
| 196 | - comp_bwdref, comp_group_idx, compound_idx, y_mode, new_mv, zero_mv, | |
| 197 | - ref_mv, drl_mode, mv_joint, mv_comp, dv_joint, dv_comp, | |
| 198 | - filter_intra, filter_intra_mode, tx_size_cat0, tx_size_cat1, tx_size_cat2, tx_size_cat3, | |
| 199 | - switchable_interp, palette_y_mode, palette_y_size, palette_uv_mode, palette_uv_size, palette_y_color_index, | |
| 200 | - palette_uv_color_index, intrabc, restore_wiener, restore_sgrproj, restore_switchable, segment_id, | |
| 201 | - segment_pred, delta_q, delta_lf, delta_lf_multi | |
| 202 | - ]; | |
| 203 | - tables.sort_unstable(); | |
| 204 | - with(|s| s.tables = tables); | |
| 205 | -} | |
| 206 | - | |
| 207 | -/// Charges `bits` to whichever CDF table `addr` falls inside. | |
| 208 | -pub(crate) fn charge(addr: usize, bits: f64) { | |
| 209 | - with(|s| { | |
| 210 | - let name = match s.tables.partition_point(|t| t.0 <= addr) { | |
| 211 | - 0 => "unregistered", | |
| 212 | - i if s.tables[i - 1].1 > addr => s.tables[i - 1].2, | |
| 213 | - _ => "unregistered", | |
| 214 | - }; | |
| 215 | - let e = cur(s).families.entry(name).or_default(); | |
| 216 | - e.0 += 1; | |
| 217 | - e.1 += bits; | |
| 218 | - }); | |
| 219 | -} | |
| 220 | - | |
| 221 | -/// Charges raw (equiprobable) bits, which no CDF names. | |
| 222 | -pub(crate) fn charge_literal(bits: u32) { | |
| 223 | - with(|s| { | |
| 224 | - let e = cur(s).families.entry("literal").or_default(); | |
| 225 | - e.0 += u64::from(bits); | |
| 226 | - e.1 += f64::from(bits); | |
| 227 | - }); | |
| 228 | -} | |
| 229 | - | |
| 230 | -/// One coded block, from the neighbour publisher every block routes through. | |
| 231 | -pub(crate) fn block(w_mi: usize, h_mi: usize, is_inter: bool, ref_frame: i8, skip: bool) { | |
| 232 | - if !armed() { | |
| 233 | - return; | |
| 234 | - } | |
| 235 | - let area = (w_mi * h_mi) as u64; | |
| 236 | - with(|s| { | |
| 237 | - s.last_block_area = area; | |
| 238 | - let f = cur(s); | |
| 239 | - *f.blocks.entry(((w_mi * 4) as u16, (h_mi * 4) as u16)).or_default() += 1; | |
| 240 | - f.area[usize::from(is_inter)] += area; | |
| 241 | - f.refs[(ref_frame.max(0) as usize).min(7)] += area; | |
| 242 | - if skip { | |
| 243 | - f.skip_area += area; | |
| 244 | - } | |
| 245 | - }); | |
| 246 | -} | |
| 247 | - | |
| 248 | -/// The block just published is compound (two references) -- called from the | |
| 249 | -/// compound-context publisher, which runs right after [`block`]. | |
| 250 | -pub(crate) fn compound() { | |
| 251 | - if !armed() { | |
| 252 | - return; | |
| 253 | - } | |
| 254 | - with(|s| { | |
| 255 | - let area = s.last_block_area; | |
| 256 | - let f = cur(s); | |
| 257 | - f.area[1] = f.area[1].saturating_sub(area); | |
| 258 | - f.area[2] += area; | |
| 259 | - }); | |
| 260 | -} | |
| 261 | - | |
| 262 | -/// One block's published luma transform shape. | |
| 263 | -pub(crate) fn tx(w_px: u8, h_px: u8) { | |
| 264 | - if !armed() { | |
| 265 | - return; | |
| 266 | - } | |
| 267 | - with(|s| *cur(s).tx.entry((u16::from(w_px), u16::from(h_px))).or_default() += 1); | |
| 268 | -} | |
| 269 | - | |
| 270 | -/// One coded motion vector (a NEWMV read). | |
| 271 | -pub(crate) fn mv(x: i32, y: i32) { | |
| 272 | - if !armed() { | |
| 273 | - return; | |
| 274 | - } | |
| 275 | - let m = x.abs().max(y.abs()); | |
| 276 | - let bucket = match m { | |
| 277 | - 0 => 0, | |
| 278 | - 1..=8 => 1, | |
| 279 | - 9..=32 => 2, | |
| 280 | - 33..=128 => 3, | |
| 281 | - 129..=512 => 4, | |
| 282 | - _ => 5, | |
| 283 | - }; | |
| 284 | - with(|s| cur(s).mv[bucket] += 1); | |
| 285 | -} | |
| 286 | - | |
| 287 | -/// One single-ref inter mode decision: 0 NEWMV, 1 GLOBALMV, 2 NEARESTMV, | |
| 288 | -/// 3 NEARMV. | |
| 289 | -pub(crate) fn mode(which: usize) { | |
| 290 | - if !armed() { | |
| 291 | - return; | |
| 292 | - } | |
| 293 | - with(|s| cur(s).modes[which] += 1); | |
| 294 | -} | |
| 295 | - | |
| 296 | -/// One coded `tx_type` symbol, with the CDF row length that names its set. | |
| 297 | -pub(crate) fn tx_type(len: usize, symbol: usize) { | |
| 298 | - if !armed() { | |
| 299 | - return; | |
| 300 | - } | |
| 301 | - with(|s| *cur(s).tx_type.entry((len as u8, symbol as u8)).or_default() += 1); | |
| 302 | -} | |
| 303 | - | |
| 304 | -/// One coded block of an INTRA frame, from the `blk_grid` publisher every | |
| 305 | -/// block writes -- a no-op on an inter frame, where [`block`] (the inter | |
| 306 | -/// neighbour publisher, which knows the reference) counts instead. | |
| 307 | -pub(crate) fn block_intra_frame(w_mi: usize, h_mi: usize, skip: bool) { | |
| 308 | - if !armed() { | |
| 309 | - return; | |
| 310 | - } | |
| 311 | - if with(|s| cur(s).kind == "key") { | |
| 312 | - block(w_mi, h_mi, false, 0, skip); | |
| 313 | - } | |
| 314 | -} |
crates/ec-av1/src/decode/block.rsmodified+4 -862
| @@ -41,42 +41,16 @@ pub(super) fn read_intra_mode( | ||
| 41 | 41 | Option<PaletteY>, |
| 42 | 42 | Option<PaletteUv>, |
| 43 | 43 | )> { |
| 44 | - let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); | |
| 45 | 44 | // lane-tiny r2: EC_ISTEP-format trace (same "name=... val=... rng=..." |
| 46 | 45 | // shape the oracle's own `ec_read_intra_frame_mode_info_impl` prints |
| 47 | 46 | // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for |
| 48 | 47 | // line against the instrumented aomdec, not just `tell()`. |
| 49 | - crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64); | |
| 50 | - let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); | |
| 51 | - if ec_istep { | |
| 52 | - // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line | |
| 53 | - // (decodemv.c:818), printed at the same point: before the first | |
| 54 | - // mode-info symbol of the block, so a cross-decoder range ladder can | |
| 55 | - // be keyed on the BLOCK, not just on the symbol sequence. | |
| 56 | - eprintln!( | |
| 57 | - "EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sq side={side} rng={}", | |
| 58 | - dec.debug_state().0 | |
| 59 | - ); | |
| 60 | - } | |
| 61 | 48 | macro_rules! istep { |
| 62 | - ($name:literal, $val:expr) => { | |
| 63 | - if ec_istep { | |
| 64 | - let (rng, _) = dec.debug_state(); | |
| 65 | - eprintln!( | |
| 66 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name={} val={} rng={rng}", | |
| 67 | - $name, $val | |
| 68 | - ); | |
| 69 | - } | |
| 70 | - }; | |
| 49 | + ($name:literal, $val:expr) => {}; | |
| 71 | 50 | } |
| 72 | 51 | // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single |
| 73 | 52 | // point every square caller routes through (see `read_intra_mode_rect`). |
| 74 | - let cfl = if cfl && side > 32 { | |
| 75 | - hit!(NOCFL_UV_MODE_HITS); | |
| 76 | - false | |
| 77 | - } else { | |
| 78 | - cfl | |
| 79 | - }; | |
| 53 | + let cfl = if cfl && side > 32 { false } else { cfl }; | |
| 80 | 54 | // spec 5.11.6 `intra_frame_mode_info`: `intra_segment_id` is read BEFORE |
| 81 | 55 | // `skip` when `SegIdPreSkip`, and after it otherwise. |
| 82 | 56 | let (seg_w_mi, seg_h_mi) = (side / 4, side / 4); |
| @@ -84,13 +58,6 @@ pub(super) fn read_intra_mode( | ||
| 84 | 58 | intra_segment_id(dec, cdfs, mi_r, mi_c, seg_w_mi, seg_h_mi, false, fctx); |
| 85 | 59 | } |
| 86 | 60 | let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0; |
| 87 | - if trace { | |
| 88 | - eprintln!( | |
| 89 | - "TRACE skip value={} rng={}", | |
| 90 | - skip as i32, | |
| 91 | - dec.debug_state().0 | |
| 92 | - ); | |
| 93 | - } | |
| 94 | 61 | istep!("skip", skip as i32); |
| 95 | 62 | if !seg_id_pre_skip(fctx) { |
| 96 | 63 | intra_segment_id(dec, cdfs, mi_r, mi_c, seg_w_mi, seg_h_mi, skip, fctx); |
| @@ -117,23 +84,9 @@ pub(super) fn read_intra_mode( | ||
| 117 | 84 | // that merely allows (but never uses) intrabc. |
| 118 | 85 | if allow_intrabc { |
| 119 | 86 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; |
| 120 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 121 | - eprintln!( | |
| 122 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=intrabc val={} rng={}", | |
| 123 | - u8::from(use_intrabc), | |
| 124 | - dec.debug_state().0 | |
| 125 | - ); | |
| 126 | - } | |
| 127 | - if trace { | |
| 128 | - eprintln!("TRACE use_intrabc value={}", use_intrabc as i32); | |
| 129 | - } | |
| 130 | 87 | if use_intrabc { |
| 131 | 88 | let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (side / MI, side / MI), fctx); |
| 132 | - if trace { | |
| 133 | - eprintln!("TRACE intrabc dv={dv:?}"); | |
| 134 | - } | |
| 135 | 89 | fctx.intrabc_dv.with(|c| c.set(Some(dv))); |
| 136 | - hit!(INTRABC_HITS); | |
| 137 | 90 | // spec 5.11.13 / libaom `read_intra_frame_mode_info` returns the |
| 138 | 91 | // moment `is_intrabc_block`: no y/uv mode, angle delta, palette, |
| 139 | 92 | // CFL or filter-intra syntax follows. `YMode`/`UVMode` are forced |
| @@ -145,21 +98,9 @@ pub(super) fn read_intra_mode( | ||
| 145 | 98 | let above_ctx = INTRA_MODE_CTX[above_mode]; |
| 146 | 99 | let left_ctx = INTRA_MODE_CTX[left_mode]; |
| 147 | 100 | let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]); |
| 148 | - if trace { | |
| 149 | - eprintln!( | |
| 150 | - "TRACE y_mode ctx=({above_ctx},{left_ctx}) value={mode} rng={}", | |
| 151 | - dec.debug_state().0 | |
| 152 | - ); | |
| 153 | - } | |
| 154 | 101 | istep!("mode", mode as i32); |
| 155 | 102 | let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { |
| 156 | 103 | let delta = read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]); |
| 157 | - if trace { | |
| 158 | - eprintln!( | |
| 159 | - "TRACE angle_delta value={}", | |
| 160 | - delta + ANGLE_DELTA_ZERO as i32 | |
| 161 | - ); | |
| 162 | - } | |
| 163 | 104 | delta |
| 164 | 105 | } else { |
| 165 | 106 | 0 |
| @@ -174,18 +115,10 @@ pub(super) fn read_intra_mode( | ||
| 174 | 115 | let uv_mode = if !has_chroma { |
| 175 | 116 | DC_PRED |
| 176 | 117 | } else if cfl { |
| 177 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 178 | 118 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 179 | 119 | } else { |
| 180 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 181 | 120 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 182 | 121 | }; |
| 183 | - if trace { | |
| 184 | - eprintln!( | |
| 185 | - "TRACE uv_mode cfl={cfl} y_mode={mode} value={uv_mode} rng={}", | |
| 186 | - dec.debug_state().0 | |
| 187 | - ); | |
| 188 | - } | |
| 189 | 122 | istep!("uv_mode", uv_mode as i32); |
| 190 | 123 | let alpha = if cfl && uv_mode == UV_CFL_PRED { |
| 191 | 124 | Some(read_cfl_alphas(dec, cdfs)) |
| @@ -199,24 +132,17 @@ pub(super) fn read_intra_mode( | ||
| 199 | 132 | // 78 against ffmpeg, traced 2026-08-27) -- an existing, un-lane-touched |
| 200 | 133 | // bug in that fallback this lane's own scope does not cover. Keep it |
| 201 | 134 | // refused here rather than ship a silently-wrong decode. |
| 202 | - if (9..=12).contains(&uv_mode) { | |
| 203 | - hit!(SMOOTH_UV_HITS); | |
| 204 | - } | |
| 205 | 135 | // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the |
| 206 | 136 | // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads |
| 207 | 137 | // `angle_delta_uv` off `get_uv_mode(uv_mode)`, never off `uv_mode` raw, |
| 208 | 138 | // so a CFL block (uv_mode==13, outside `V_PRED..=D67_PRED`) already takes |
| 209 | 139 | // the `else` branch below and never reads one either way. |
| 210 | 140 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 211 | - hit!(DIRECTIONAL_UV_HITS); | |
| 212 | 141 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 213 | 142 | } else { |
| 214 | 143 | 0 |
| 215 | 144 | }; |
| 216 | 145 | istep!("angle_uv", angle_delta_uv); |
| 217 | - if angle_delta_uv != 0 { | |
| 218 | - hit!(UV_ANGLE_DELTA_HITS); | |
| 219 | - } | |
| 220 | 146 | // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called |
| 221 | 147 | // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`): |
| 222 | 148 | // gated by `av1_allow_palette` (blockd.h -- size bound only, |
| @@ -244,32 +170,11 @@ pub(super) fn read_intra_mode( | ||
| 244 | 170 | let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; |
| 245 | 171 | if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx(side) { |
| 246 | 172 | let (mode_ctx, cache) = palette.unwrap_or((0, &[])); |
| 247 | - if mode == DC_PRED && trace { | |
| 248 | - let (rng, _) = dec.debug_state(); | |
| 249 | - eprintln!( | |
| 250 | - "TRACE pre_palette_y_mode bsize_ctx={bsize_ctx} mode_ctx={mode_ctx} rng={rng}" | |
| 251 | - ); | |
| 252 | - } | |
| 253 | 173 | let use_palette_y = |
| 254 | 174 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][mode_ctx]) != 0; |
| 255 | - if mode == DC_PRED && trace { | |
| 256 | - let (rng, _) = dec.debug_state(); | |
| 257 | - eprintln!( | |
| 258 | - "TRACE palette_y_mode value={} rng={rng}", | |
| 259 | - use_palette_y as i32 | |
| 260 | - ); | |
| 261 | - } | |
| 262 | 175 | if use_palette_y { |
| 263 | 176 | let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]); |
| 264 | - if trace { | |
| 265 | - let (rng, _) = dec.debug_state(); | |
| 266 | - eprintln!("TRACE palette_y_size n={n} rng={rng}"); | |
| 267 | - } | |
| 268 | 177 | let colors = read_palette_colors_y(dec, n, cache, fctx); |
| 269 | - if trace { | |
| 270 | - let (rng, _) = dec.debug_state(); | |
| 271 | - eprintln!("TRACE palette_y_colors colors={:?} rng={rng}", &colors[..n]); | |
| 272 | - } | |
| 273 | 178 | palette_y_pending = Some((n, colors)); |
| 274 | 179 | } |
| 275 | 180 | // `read_palette_mode_info`'s UV half (decodemv.c:588): read |
| @@ -313,20 +218,9 @@ pub(super) fn read_intra_mode( | ||
| 313 | 218 | && let Some(class) = filter_intra_size_class(side) |
| 314 | 219 | { |
| 315 | 220 | let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[class]) != 0; |
| 316 | - if trace { | |
| 317 | - eprintln!( | |
| 318 | - "TRACE use_filter_intra side={side} rng={} value={}", | |
| 319 | - dec.debug_state().0, | |
| 320 | - use_filter_intra as i32 | |
| 321 | - ); | |
| 322 | - } | |
| 323 | 221 | istep!("use_filter_intra", use_filter_intra as i32); |
| 324 | 222 | if use_filter_intra { |
| 325 | - hit!(FILTER_INTRA_HITS); | |
| 326 | 223 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 327 | - if trace { | |
| 328 | - eprintln!("TRACE filter_intra_mode value={fi_mode}"); | |
| 329 | - } | |
| 330 | 224 | istep!("filter_intra_mode", fi_mode as i32); |
| 331 | 225 | filter_intra = Some(fi_mode); |
| 332 | 226 | } |
| @@ -342,10 +236,6 @@ pub(super) fn read_intra_mode( | ||
| 342 | 236 | palette_onscreen(mi_r, mi_c, side, side, fctx), |
| 343 | 237 | false, |
| 344 | 238 | ); |
| 345 | - hit!(PALETTE_HITS); | |
| 346 | - if trace { | |
| 347 | - eprintln!("TRACE palette_y size={n} colors={:?}", &colors[..n]); | |
| 348 | - } | |
| 349 | 239 | PaletteY { |
| 350 | 240 | size: n, |
| 351 | 241 | colors, |
| @@ -372,14 +262,6 @@ pub(super) fn read_intra_mode( | ||
| 372 | 262 | on, |
| 373 | 263 | true, |
| 374 | 264 | ); |
| 375 | - hit!(PALETTE_UV_HITS); | |
| 376 | - if trace { | |
| 377 | - eprintln!( | |
| 378 | - "TRACE palette_uv size={n} u_colors={:?} v_colors={:?}", | |
| 379 | - &u_colors[..n], | |
| 380 | - &v_colors[..n] | |
| 381 | - ); | |
| 382 | - } | |
| 383 | 265 | PaletteUv { |
| 384 | 266 | size: n, |
| 385 | 267 | u_colors, |
| @@ -412,7 +294,6 @@ pub(super) const UV_CFL_PRED: usize = 13; | ||
| 412 | 294 | /// joint sign the same way. Returns each plane's final signed `alpha_q3` |
| 413 | 295 | /// (`cfl_idx_to_alpha`, cfl.c): magnitude `idx + 1`, sign-zero collapsing to 0. |
| 414 | 296 | pub(super) fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) { |
| 415 | - hit!(CFL_BLOCK_HITS); | |
| 416 | 297 | let joint_sign = dec.symbol(&mut cdfs.cfl_sign) as i32; |
| 417 | 298 | let sign_u = ((joint_sign + 1) * 11) >> 5; |
| 418 | 299 | let sign_v = (joint_sign + 1) - 3 * sign_u; |
| @@ -461,7 +342,6 @@ pub(super) fn cfl_ac_ss( | ||
| 461 | 342 | ss_y: usize, |
| 462 | 343 | ) -> Vec<i32> { |
| 463 | 344 | if ss_x == 0 && ss_y == 0 { |
| 464 | - hit!(CFL_AC_444_HITS); | |
| 465 | 345 | let mut ac = vec![0i32; bw * bh]; |
| 466 | 346 | let mut sum = 0i32; |
| 467 | 347 | for row in 0..bh { |
| @@ -476,12 +356,6 @@ pub(super) fn cfl_ac_ss( | ||
| 476 | 356 | ac.iter_mut().for_each(|v| *v -= avg); |
| 477 | 357 | ac |
| 478 | 358 | } else if ss_x == 1 && ss_y == 0 { |
| 479 | - // lane-av1-422: `cfl_luma_subsampling_422_lbd_c` -- each chroma sample | |
| 480 | - // averages the HORIZONTAL luma pair above it, at full chroma height | |
| 481 | - // (`(a + b) >> 1` in Q3 is `(a + b) << 2`). A rect luma strip's chroma | |
| 482 | - // is square here, and the 4:2:0 rect/square helpers below would halve | |
| 483 | - // the height it must keep. | |
| 484 | - hit!(CFL_AC_422_HITS); | |
| 485 | 359 | let (cw, ch) = (bw >> 1, bh); |
| 486 | 360 | let mut ac = vec![0i32; cw * ch]; |
| 487 | 361 | let mut sum = 0i32; |
| @@ -500,10 +374,8 @@ pub(super) fn cfl_ac_ss( | ||
| 500 | 374 | ac.iter_mut().for_each(|v| *v -= avg); |
| 501 | 375 | ac |
| 502 | 376 | } else if bw == bh { |
| 503 | - hit!(CFL_AC_420_SQ_HITS); | |
| 504 | 377 | cfl_ac_q3(y, px, py, bw) |
| 505 | 378 | } else { |
| 506 | - hit!(CFL_AC_420_RECT_HITS); | |
| 507 | 379 | cfl_ac_q3_rect(y, px, py, bw, bh) |
| 508 | 380 | } |
| 509 | 381 | } |
| @@ -515,10 +387,6 @@ pub(crate) fn cfl_ac_q3_at( | ||
| 515 | 387 | bh: usize, |
| 516 | 388 | sample: impl Fn(usize, usize) -> i32, |
| 517 | 389 | ) -> Vec<i32> { |
| 518 | - hit!(CFL_AC_Q3_AT_HITS); | |
| 519 | - if crate::envflags::env_flag!("EC_HALVSWEEP") { | |
| 520 | - eprintln!("EC_HALV cfl_ac_q3_at px={px} py={py} bw={bw} bh={bh}"); | |
| 521 | - } | |
| 522 | 390 | let (cw, ch) = (bw / 2, bh / 2); |
| 523 | 391 | let mut ac = vec![0i32; cw * ch]; |
| 524 | 392 | let mut sum = 0i32; |
| @@ -550,275 +418,6 @@ pub(crate) fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 { | ||
| 550 | 418 | } |
| 551 | 419 | } |
| 552 | 420 | |
| 553 | -/// One plane's reconstruction buffer, `width * height` samples, and the | |
| 554 | -/// prediction/residual reads and writes into it — the decode-side twin of | |
| 555 | -/// [`crate::encode`]'s private `Plane`, whose `edges` this mirrors exactly | |
| 556 | -/// (own-edge and reach clamps both), passing what it gathers straight to | |
| 557 | -/// [`crate::intra::predict`] instead of hand-rolling `DC_PRED` alone. | |
| 558 | -/// lane-tiny r4: raw padded-plane dump for filter-stage bisection, written | |
| 559 | -/// only when `var` names a path. Same byte shape as `EC_AV1_PREFILT_DUMP`. | |
| 560 | -/// lane-hgkf r2: 16-bit cropped stage dump, the high-bitdepth twin of | |
| 561 | -/// [`dump_stage`] (whose `as u8` truncation hides |delta| <= 2 defects). | |
| 562 | -/// lane-unwritten-dep: this doc previously said the dump "matches aomdec's own | |
| 563 | -/// `ec_dump16` rung byte for byte (crop dims, u16 LE)", which was true only of | |
| 564 | -/// the 4:2:0 crop it then used. The crop is now PER-AXIS, which is what the | |
| 565 | -/// oracle's rung 1 actually does -- it writes `y_crop_width` x `y_crop_height`, | |
| 566 | -/// `uv_crop_width` x `uv_crop_height`, `uv_crop_width` x `uv_crop_height` (the | |
| 567 | -/// libaom `YV12_BUFFER_CONFIG` fields, each already per-axis). Byte shape per | |
| 568 | -/// subsampling, `fw x fh` luma then both chroma planes, u16 LE, so: | |
| 569 | -/// | |
| 570 | -/// ```text | |
| 571 | -/// ss_x ss_y format luma chroma (each) | |
| 572 | -/// 0 0 4:4:4 fw x fh fw x fh fw*fh*3 samples | |
| 573 | -/// 1 1 4:2:0 fw x fh fw/2 x fh/2 fw*fh*3/2 samples | |
| 574 | -/// 1 0 4:2:2 fw x fh fw/2 x fh fw*fh*2 samples | |
| 575 | -/// 0 1 4:4:0 fw x fh fw x fh/2 fw*fh*3/2 samples | |
| 576 | -/// ``` | |
| 577 | -/// | |
| 578 | -/// (`round_ss` is the rounding the decoder's own plane extents use; at ss = 1 it | |
| 579 | -/// is `div_ceil(2)`, so every 4:2:0 dump is byte-for-byte unchanged by this.) | |
| 580 | -/// lane-mc64 r1: the file name is keyed on [`dump_stage_idx`], a per-var | |
| 581 | -/// decode-order counter -- both dumps used to write `.f0` unconditionally, so | |
| 582 | -/// every frame overwrote the previous one and only the LAST frame survived, | |
| 583 | -/// which silently defeats any per-frame filter-stage bisection (ledger, class | |
| 584 | -/// stale-output-faked-measurement). A sibling accessor `stage_dump_idx()`, which | |
| 585 | -/// derived the same number from `PREFILT_PICTURE_IDX`, had no caller and was | |
| 586 | -/// deleted: `PREFILT_PICTURE_IDX` is bumped after this point, not before it, so | |
| 587 | -/// the counter that names these files is the per-var map. | |
| 588 | -// Signature mirrors the spec's per-call inputs; a parameter struct would only move them. | |
| 589 | -#[allow(clippy::too_many_arguments)] | |
| 590 | -pub(super) fn dump_stage16( | |
| 591 | - var: &str, | |
| 592 | - y: &PlaneBuf<'_>, | |
| 593 | - u: &PlaneBuf<'_>, | |
| 594 | - v: &PlaneBuf<'_>, | |
| 595 | - fw: usize, | |
| 596 | - fh: usize, | |
| 597 | - ss_x: usize, | |
| 598 | - ss_y: usize, | |
| 599 | -) { | |
| 600 | - // lane-sbrect10 r2 / lane-cdef r1 (one shared helper): index the dump by | |
| 601 | - // decode-order picture like EC_AV1_PREFILT_DUMP already does -- a fixed | |
| 602 | - // `.f0` name kept only the LAST frame, so a mid-sequence divergence could | |
| 603 | - // not be read at all. | |
| 604 | - // | |
| 605 | - // lane-unwritten-dep: the chroma extent is PER-AXIS subsampling, not | |
| 606 | - // `div_ceil(2)` on both. The hardcoded pair was a 4:2:0 assumption and it | |
| 607 | - // was load-bearing: on a 64x64 4:2:2 frame (ss_x = 1, ss_y = 0) it wrote | |
| 608 | - // 32x32 chroma per plane where the frame carries 32x64, so HALF of each | |
| 609 | - // chroma plane appeared in NO stage dump at all. A stage bisect that reads | |
| 610 | - // "identical pre-deblock, differs post-deblock" off these dumps is then | |
| 611 | - // measuring the dump's blind spot, not the pipeline's: the samples it could | |
| 612 | - // not see are exactly the region where the 4:2:2 witness's output diverges | |
| 613 | - // (chroma rows 32..63 -- the old `fh.div_ceil(2)` crop wrote 32 of 64 rows, | |
| 614 | - // so everything from row 32 up was invisible; 2048 samples). `round_ss` is | |
| 615 | - // the same rounding the | |
| 616 | - // decoder's own plane extents use, and it matches the oracle's | |
| 617 | - // `uv_crop_width` / `uv_crop_height` per axis. | |
| 618 | - // | |
| 619 | - // ONE file per frame: `dump_stage_idx` advances on every call, so creating | |
| 620 | - // the file inside the plane loop would write three files per frame and | |
| 621 | - // shift every later frame's index. | |
| 622 | - // | |
| 623 | - // lane-av1dumploud: this used to be `let _ = f.write_all(&bytes)` per row, so | |
| 624 | - // a full filesystem left a SHORT file that no reader could tell from a | |
| 625 | - // complete one. `LoudDump` is given the exact expected length this function | |
| 626 | - // knows -- `(fw*fh + 2*cw*ch) * 2`, u16 LE -- and checks it against the file | |
| 627 | - // on disk; a shortfall aborts the decode instead of leaving a plausible | |
| 628 | - // artefact behind. | |
| 629 | - if let Ok(path) = crate::envflags::var(var) { | |
| 630 | - let cw = round_ss(fw, ss_x); | |
| 631 | - let ch = round_ss(fh, ss_y); | |
| 632 | - let expected = (fw * fh + 2 * cw * ch) * 2; | |
| 633 | - let mut d = crate::dumpio::LoudDump::create( | |
| 634 | - var, | |
| 635 | - format!("{path}.f{}", dump_stage_idx(var)), | |
| 636 | - expected, | |
| 637 | - ); | |
| 638 | - for (p, w, h) in [(y, fw, fh), (u, cw, ch), (v, cw, ch)] { | |
| 639 | - for row in 0..h { | |
| 640 | - let mut bytes = Vec::with_capacity(w * 2); | |
| 641 | - for &s in &p.data[row * p.width..][..w] { | |
| 642 | - bytes.extend_from_slice(&s.to_le_bytes()); | |
| 643 | - } | |
| 644 | - d.write(&bytes); | |
| 645 | - } | |
| 646 | - } | |
| 647 | - d.finish(); | |
| 648 | - } | |
| 649 | -} | |
| 650 | - | |
| 651 | -/// Decode-order index of the next [`dump_stage`]/[`dump_stage16`] file for a | |
| 652 | -/// given env var -- lane-cdef r1: both used to write `.f0` unconditionally, so | |
| 653 | -/// every frame overwrote the previous one and only the LAST frame survived, | |
| 654 | -/// which silently defeats any per-frame filter-stage bisection. | |
| 655 | -fn dump_stage_idx(var: &str) -> usize { | |
| 656 | - use std::collections::HashMap; | |
| 657 | - use std::sync::{Mutex, OnceLock}; | |
| 658 | - static IDX: OnceLock<Mutex<HashMap<String, usize>>> = OnceLock::new(); | |
| 659 | - let mut m = IDX | |
| 660 | - .get_or_init(|| Mutex::new(HashMap::new())) | |
| 661 | - .lock() | |
| 662 | - .unwrap(); | |
| 663 | - let e = m.entry(var.to_string()).or_insert(0); | |
| 664 | - let i = *e; | |
| 665 | - *e += 1; | |
| 666 | - i | |
| 667 | -} | |
| 668 | - | |
| 669 | -pub(super) fn dump_stage(var: &str, y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { | |
| 670 | - // lane-av1dumploud: loud on a short write (see [`crate::dumpio::LoudDump`]). | |
| 671 | - // The expected length is the three planes' own data lengths -- the writer | |
| 672 | - // iterates exactly `p.data`, so this is the same extent, not a re-derivation | |
| 673 | - // that could disagree with it. | |
| 674 | - if let Ok(path) = crate::envflags::var(var) { | |
| 675 | - let narrow = |p: &PlaneBuf<'_>| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() }; | |
| 676 | - crate::dumpio::write_planes( | |
| 677 | - var, | |
| 678 | - format!("{path}.f{}", dump_stage_idx(var)), | |
| 679 | - &[&narrow(y), &narrow(u), &narrow(v)], | |
| 680 | - ); | |
| 681 | - } | |
| 682 | -} | |
| 683 | - | |
| 684 | -/// `EC_AV1_PREFILT_WIDE_DUMP=<prefix>` -> `<prefix>.f<N>`, the pre-loop-filter | |
| 685 | -/// reconstruction cropped to each plane's mi-ALIGNED true extent, byte for | |
| 686 | -/// byte the shape aomdec's own rung 7 writes (`y_width`/`y_height`, | |
| 687 | -/// `uv_width`/`uv_height`), so the two can be diffed directly. | |
| 688 | -/// | |
| 689 | -/// lane-av1444edge: this used to be an inline block in the KEY-frame tile path | |
| 690 | -/// only, with a FUNCTION-LOCAL `static IDX2` as its counter. Both facts were | |
| 691 | -/// measurement traps, and the second one is why the first went unnoticed: | |
| 692 | -/// the inter-frame path (`decode_inter_frame_tile_with_cdfs`) had no wide | |
| 693 | -/// prefilter dump at all, so every 4:4:4 lossy divergence localized to an | |
| 694 | -/// inter frame had no pre-filter rung to compare against and got attributed to | |
| 695 | -/// reconstruction when the oracle could not see it. The `static` also restarted | |
| 696 | -/// per monomorphisation, so every frame after the first overwrote `.f0` -- a | |
| 697 | -/// per-frame bisection silently compared the LAST decoded frame. The counter | |
| 698 | -/// is now the shared per-var [`dump_stage_idx`] map, and the call also sits on | |
| 699 | -/// the inter path (skipped when the filter pipeline is active, which has | |
| 700 | -/// already deblocked by the time the tile tail runs -- same condition | |
| 701 | -/// `capture_filter_replay` guards itself with). | |
| 702 | -pub(super) fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { | |
| 703 | - let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_WIDE_DUMP") else { | |
| 704 | - return; | |
| 705 | - }; | |
| 706 | - // lane-av1dumploud: loud on a short write. Expected length is | |
| 707 | - // `sum(true_width * true_height)` over the three planes -- the crop the | |
| 708 | - // writer itself builds, so the check cannot disagree with the bytes. | |
| 709 | - let idx = dump_stage_idx("EC_AV1_PREFILT_WIDE_DUMP"); | |
| 710 | - let crop = |plane: &PlaneBuf<'_>| -> Vec<u8> { | |
| 711 | - let mut out = Vec::with_capacity(plane.true_width * plane.true_height); | |
| 712 | - for row in 0..plane.true_height { | |
| 713 | - out.extend( | |
| 714 | - plane.data[row * plane.width..][..plane.true_width] | |
| 715 | - .iter() | |
| 716 | - .map(|&s| s as u8), | |
| 717 | - ); | |
| 718 | - } | |
| 719 | - out | |
| 720 | - }; | |
| 721 | - let (cy, cu, cv) = (crop(y), crop(u), crop(v)); | |
| 722 | - crate::dumpio::write_planes( | |
| 723 | - "EC_AV1_PREFILT_WIDE_DUMP", | |
| 724 | - format!("{path}.f{idx}"), | |
| 725 | - &[&cy, &cu, &cv], | |
| 726 | - ); | |
| 727 | -} | |
| 728 | - | |
| 729 | -/// Unwritten samples [`census_unwritten`] has counted since the last | |
| 730 | -/// [`take_unwritten_samples`] -- process-global (not thread-local) because the | |
| 731 | -/// gate reads it after the decode, from a different thread than the one that | |
| 732 | -/// scanned the plane. | |
| 733 | -pub(super) static UNWRITTEN_SAMPLES: std::sync::atomic::AtomicUsize = | |
| 734 | - std::sync::atomic::AtomicUsize::new(0); | |
| 735 | - | |
| 736 | -/// Turns [`PLANE_SENTINEL`] filling on for the CALLING thread, independently | |
| 737 | -/// of `EC_AV1_PLANE_SENTINEL`. A gate cannot set a process-constant env var | |
| 738 | -/// (see [`crate::envflags`]), and the census is the only honest way to ask | |
| 739 | -/// "did the tile walk write every sample it was handed" -- a wrong-sample diff | |
| 740 | -/// cannot tell an unwritten sample from a mis-predicted one. | |
| 741 | -pub fn set_plane_sentinel(on: bool) { | |
| 742 | - PLANE_SENTINEL_ON.with(|c| c.set(on)); | |
| 743 | -} | |
| 744 | - | |
| 745 | -/// Reads and clears [`UNWRITTEN_SAMPLES`]: the number of samples the decode | |
| 746 | -/// just handed to the tile walk never wrote, summed over every frame and | |
| 747 | -/// plane. Zero is the only acceptable answer for a decoder whose output must | |
| 748 | -/// not depend on its allocator. | |
| 749 | -pub fn take_unwritten_samples() -> usize { | |
| 750 | - UNWRITTEN_SAMPLES.swap(0, std::sync::atomic::Ordering::SeqCst) | |
| 751 | -} | |
| 752 | - | |
| 753 | -/// Samples in the PADDED TAIL -- every sample of each plane outside its own | |
| 754 | -/// `true_width` x `true_height` extent -- that still holds [`plane_poison`] at | |
| 755 | -/// the pre-deblock point. [`census_unwritten`] scans that region too, because | |
| 756 | -/// "past the true extent nothing is ever read" was an ASSUMPTION the tail's | |
| 757 | -/// census was built to avoid checking; this counter is the measurement. | |
| 758 | -pub(super) static PAD_UNWRITTEN_SAMPLES: std::sync::atomic::AtomicUsize = | |
| 759 | - std::sync::atomic::AtomicUsize::new(0); | |
| 760 | - | |
| 761 | -/// Reads and clears [`PAD_UNWRITTEN_SAMPLES`]. | |
| 762 | -pub fn take_pad_unwritten_samples() -> usize { | |
| 763 | - PAD_UNWRITTEN_SAMPLES.swap(0, std::sync::atomic::Ordering::SeqCst) | |
| 764 | -} | |
| 765 | - | |
| 766 | -/// The largest value reconstruction can produce, `(1 << 12) - 1`: the highest | |
| 767 | -/// bit depth this decoder carries is 12. A sentinel at or below this could be | |
| 768 | -/// a LEGAL sample, which would make the whole census vacuous -- every | |
| 769 | -/// unwritten sample would look like an ordinary one. | |
| 770 | -pub(super) const MAX_LEGAL_SAMPLE: u16 = 4095; | |
| 771 | - | |
| 772 | -/// The value [`fresh_plane`] fills with when the sentinel is on. | |
| 773 | -/// | |
| 774 | -/// [`PLANE_SENTINEL`] unless `EC_AV1_PLANE_SENTINEL` names a different one in | |
| 775 | -/// hex. Two different poisons are what turns the sentinel from "did a hole | |
| 776 | -/// survive into the output" into "did the output depend on the buffer's | |
| 777 | -/// initial content": a hole whose value reaches the picture changes the hash | |
| 778 | -/// when the poison changes, and one that does not cannot have influenced | |
| 779 | -/// anything. A value at or below [`MAX_LEGAL_SAMPLE`] is REFUSED (falls back | |
| 780 | -/// to [`PLANE_SENTINEL`]) because the census's soundness rests on the sentinel | |
| 781 | -/// being impossible. `EC_AV1_PLANE_SENTINEL=1` -- the spelling every existing | |
| 782 | -/// caller and gate uses, and `env_flag!`'s mere presence test -- keeps | |
| 783 | -/// [`PLANE_SENTINEL`]. | |
| 784 | -/// `pub(crate)` for lane-av1graincensus: `film_grain::uninit_plane` fills its | |
| 785 | -/// destination with the SAME poison `fresh_plane` does, and | |
| 786 | -/// [`census_unwritten_grained`] counts the same value. The fill and the census | |
| 787 | -/// must agree on both the value and the predicate, or a "0" means nothing. | |
| 788 | -pub(crate) fn plane_poison() -> u16 { | |
| 789 | - static V: std::sync::LazyLock<u16> = std::sync::LazyLock::new(|| { | |
| 790 | - let Ok(raw) = crate::envflags::var("EC_AV1_PLANE_SENTINEL") else { | |
| 791 | - return PLANE_SENTINEL; | |
| 792 | - }; | |
| 793 | - let t = raw.trim(); | |
| 794 | - if t.is_empty() || t == "1" { | |
| 795 | - return PLANE_SENTINEL; | |
| 796 | - } | |
| 797 | - let hex = t | |
| 798 | - .strip_prefix("0x") | |
| 799 | - .or_else(|| t.strip_prefix("0X")) | |
| 800 | - .unwrap_or(t); | |
| 801 | - match u16::from_str_radix(hex, 16) { | |
| 802 | - Ok(v) if v > MAX_LEGAL_SAMPLE => v, | |
| 803 | - _ => PLANE_SENTINEL, | |
| 804 | - } | |
| 805 | - }); | |
| 806 | - *V | |
| 807 | -} | |
| 808 | - | |
| 809 | -thread_local! { | |
| 810 | - /// The [`set_plane_sentinel`] override; `EC_AV1_PLANE_SENTINEL` is the | |
| 811 | - /// process-wide default. | |
| 812 | - static PLANE_SENTINEL_ON: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; | |
| 813 | -} | |
| 814 | - | |
| 815 | -/// Whether freshly allocated planes are [`PLANE_SENTINEL`]-filled. | |
| 816 | -/// `pub(crate)` for the same reason as [`plane_poison`]. | |
| 817 | -pub(crate) fn plane_sentinel_on() -> bool { | |
| 818 | - crate::envflags::env_flag!("EC_AV1_PLANE_SENTINEL") | |
| 819 | - || PLANE_SENTINEL_ON.with(std::cell::Cell::get) | |
| 820 | -} | |
| 821 | - | |
| 822 | 421 | /// lane-av1unwritten: whether a subsize has a chroma PLANE BLOCK at this |
| 823 | 422 | /// frame's subsampling -- libaom `av1_ss_size_lookup[bsize][ss_x][ss_y] != |
| 824 | 423 | /// BLOCK_INVALID` (`common_data.c`), which `decode_partition` checks on every |
| @@ -990,26 +589,6 @@ pub(super) fn refuse_invalid_subsize( | ||
| 990 | 589 | part: usize, |
| 991 | 590 | fctx: &crate::decode::FrameCtx, |
| 992 | 591 | ) -> Result<()> { |
| 993 | - // lane-av1unwritten r6: the coverage artefact. A guard that sits INSIDE a | |
| 994 | - // `PARTITION_HORZ_A..=PARTITION_VERT_B` arm can only ever observe 4..=7, so | |
| 995 | - // "the guard is present" is not evidence that an offending value is caught -- | |
| 996 | - // which is exactly how r5's three misplaced guards read as coverage. This | |
| 997 | - // records, per CALL SITE and per partition value, how often the guard was | |
| 998 | - // reached and how often it fired, so a site that never sees an offending | |
| 999 | - // value is visible instead of assumed covered. | |
| 1000 | - if crate::envflags::env_flag!("EC_AV1_SUBSIZE_GUARD_TRACE") { | |
| 1001 | - note_subsize_guard( | |
| 1002 | - std::panic::Location::caller(), | |
| 1003 | - bsize, | |
| 1004 | - part, | |
| 1005 | - chroma_plane_block_codable( | |
| 1006 | - partition_subsize_dims(bsize, part).0, | |
| 1007 | - partition_subsize_dims(bsize, part).1, | |
| 1008 | - ss_x(fctx), | |
| 1009 | - ss_y(fctx), | |
| 1010 | - ), | |
| 1011 | - ); | |
| 1012 | - } | |
| 1013 | 592 | let (bw, bh) = partition_subsize_dims(bsize, part); |
| 1014 | 593 | if chroma_plane_block_codable(bw, bh, ss_x(fctx), ss_y(fctx)) { |
| 1015 | 594 | Ok(()) |
| @@ -1018,88 +597,6 @@ pub(super) fn refuse_invalid_subsize( | ||
| 1018 | 597 | } |
| 1019 | 598 | } |
| 1020 | 599 | |
| 1021 | -/// lane-av1unwritten r6: the OTHER half of the coverage artefact. The guard | |
| 1022 | -/// table says what the guards see; this says what each DISPATCH ARM sees, so a | |
| 1023 | -/// dispatch reached with an offending partition value and no guard above it is a | |
| 1024 | -/// visible hole rather than an absence nobody noticed. `decode_probe` calls | |
| 1025 | -/// [`dump_subsize_arm_scan`] at exit under `EC_AV1_SUBSIZE_ARM_TRACE`. | |
| 1026 | -pub(super) static SUBSIZE_ARM: std::sync::LazyLock< | |
| 1027 | - std::sync::Mutex<std::collections::BTreeMap<(&'static str, usize), usize>>, | |
| 1028 | -> = std::sync::LazyLock::new(|| std::sync::Mutex::new(Default::default())); | |
| 1029 | - | |
| 1030 | -#[track_caller] | |
| 1031 | -pub(crate) fn note_subsize_arm(part: usize, codable: bool) { | |
| 1032 | - if !crate::envflags::env_flag!("EC_AV1_SUBSIZE_ARM_TRACE") { | |
| 1033 | - return; | |
| 1034 | - } | |
| 1035 | - let site = std::panic::Location::caller(); | |
| 1036 | - let key = ( | |
| 1037 | - format!("{}:{}", site.file(), site.line()).leak() as &'static str, | |
| 1038 | - part * 2 + usize::from(codable), | |
| 1039 | - ); | |
| 1040 | - if let Ok(mut m) = SUBSIZE_ARM.lock() { | |
| 1041 | - *m.entry(key).or_insert(0) += 1; | |
| 1042 | - } | |
| 1043 | -} | |
| 1044 | - | |
| 1045 | -/// Prints and clears the [`note_subsize_arm`] table. | |
| 1046 | -pub fn dump_subsize_arm_scan() { | |
| 1047 | - let Ok(mut m) = SUBSIZE_ARM.lock() else { | |
| 1048 | - return; | |
| 1049 | - }; | |
| 1050 | - for ((site, k), n) in m.iter() { | |
| 1051 | - eprintln!( | |
| 1052 | - "SUBSIZE_ARM site={site} part={} codable={} reached={n}", | |
| 1053 | - k / 2, | |
| 1054 | - if k % 2 == 1 { "true" } else { "false" }, | |
| 1055 | - ); | |
| 1056 | - } | |
| 1057 | - m.clear(); | |
| 1058 | -} | |
| 1059 | - | |
| 1060 | -/// Per-site, per-value counters for [`refuse_invalid_subsize`], plus the dump | |
| 1061 | -/// that makes the reach/guard split readable. `EC_AV1_SUBSIZE_GUARD_TRACE` | |
| 1062 | -/// records; `dump_subsize_guard_scan` prints (and clears) the table. | |
| 1063 | -pub(super) static SUBSIZE_GUARD: std::sync::LazyLock< | |
| 1064 | - std::sync::Mutex<std::collections::BTreeMap<(&'static str, usize, usize, bool), usize>>, | |
| 1065 | -> = std::sync::LazyLock::new(|| std::sync::Mutex::new(Default::default())); | |
| 1066 | - | |
| 1067 | -fn note_subsize_guard( | |
| 1068 | - site: &'static std::panic::Location<'static>, | |
| 1069 | - bsize: (usize, usize), | |
| 1070 | - part: usize, | |
| 1071 | - codable: bool, | |
| 1072 | -) { | |
| 1073 | - let key = ( | |
| 1074 | - format!("{}:{}", site.file(), site.line()).leak() as &'static str, | |
| 1075 | - bsize.0 * 256 + bsize.1, | |
| 1076 | - part, | |
| 1077 | - codable, | |
| 1078 | - ); | |
| 1079 | - if let Ok(mut m) = SUBSIZE_GUARD.lock() { | |
| 1080 | - *m.entry(key).or_insert(0) += 1; | |
| 1081 | - } | |
| 1082 | -} | |
| 1083 | - | |
| 1084 | -/// Prints and clears the [`refuse_invalid_subsize`] table: one line per | |
| 1085 | -/// (site, block, partition value) with the times reached and whether the guard | |
| 1086 | -/// fired. `decode_probe` calls this at exit. | |
| 1087 | -pub fn dump_subsize_guard_scan() { | |
| 1088 | - let Ok(mut m) = SUBSIZE_GUARD.lock() else { | |
| 1089 | - return; | |
| 1090 | - }; | |
| 1091 | - for ((site, bsize, part, codable), n) in m.iter() { | |
| 1092 | - eprintln!( | |
| 1093 | - "SUBSIZE_GUARD site={site} bsize={}x{} part={part} codable={codable} \ | |
| 1094 | - reached={n}{}", | |
| 1095 | - bsize / 256, | |
| 1096 | - bsize % 256, | |
| 1097 | - if *codable { "" } else { " FIRED" }, | |
| 1098 | - ); | |
| 1099 | - } | |
| 1100 | - m.clear(); | |
| 1101 | -} | |
| 1102 | - | |
| 1103 | 600 | /// [`chroma_plane_block_codable`] as libaom's refusal: a returned error naming |
| 1104 | 601 | /// the shape and the subsampling mode, never an `assert!` -- a partition symbol |
| 1105 | 602 | /// is stream data, so a hostile file can reach it. |
| @@ -1115,84 +612,8 @@ pub(super) fn refuse_invalid_plane_block( | ||
| 1115 | 612 | ) |
| 1116 | 613 | } |
| 1117 | 614 | |
| 1118 | -/// The value [`fresh_plane`] fills with under `EC_AV1_PLANE_SENTINEL`: no | |
| 1119 | -/// legal sample can equal it (reconstruction clamps to `(1 << bit_depth) - 1`, | |
| 1120 | -/// at most 4095), so a decode that hashes identically under the flag proves | |
| 1121 | -/// the output does not depend on the plane buffer's initial content. | |
| 1122 | -pub(super) const PLANE_SENTINEL: u16 = 0xDEAD; | |
| 1123 | - | |
| 1124 | -/// lane-unwritten-dep: the census count at the LAST point of the pipeline, on the | |
| 1125 | -/// exact bytes `EC_AV1_FINAL_DUMP` writes. | |
| 1126 | -/// | |
| 1127 | -/// WHY A SECOND COUNT, and what it is actually for -- the justification this | |
| 1128 | -/// comment originally carried was WRONG and is corrected here, because a reader | |
| 1129 | -/// would otherwise re-derive the wrong conclusion. An earlier revision of this | |
| 1130 | -/// lane claimed the pre-deblock plane was byte-identical plain-vs-sentinel and | |
| 1131 | -/// that "deblock creates the dependence". That reading came from | |
| 1132 | -/// [`dump_stage16`], which cropped chroma as `(fw/2, fh/2)` -- a 4:2:0 | |
| 1133 | -/// assumption. On a 64x64 4:2:2 frame (ss_x=1, ss_y=0) that wrote 32x32 chroma | |
| 1134 | -/// where the frame carries 32x64, so 2048 chroma samples appeared in NO stage | |
| 1135 | -/// dump, and they are exactly the region where the difference lives. | |
| 1136 | -/// | |
| 1137 | -/// With per-axis extents the corrected measurement on `440_request_is_422` is: | |
| 1138 | -/// the PRE-DEBLOCK dump already DIFFERS by 2158 bytes plain-vs-sentinel, and an | |
| 1139 | -/// exact u16 whole-plane census finds 224 unwritten samples (U 112, V 112, | |
| 1140 | -/// rows 36..63, whole 4x4 groups) -- the same number | |
| 1141 | -/// `lanes/av1unwritten.report.md` reports. **The hole is present before any | |
| 1142 | -/// filter runs, and the pre-deblock census sees it.** This comment previously | |
| 1143 | -/// said the opposite; that was the instrument's blind spot read as a property of | |
| 1144 | -/// the pipeline. | |
| 1145 | -/// | |
| 1146 | -/// So what this second count is FOR, stated honestly: it is not there because the | |
| 1147 | -/// pre-deblock census misses holes. It is there because it is the measurement | |
| 1148 | -/// taken where the OUTPUT is taken -- the bytes stored into the reference slots | |
| 1149 | -/// and handed to the caller. A hole can be created after reconstruction (a | |
| 1150 | -/// filter stage, a superres step, a second pass) and be invisible to a scan taken | |
| 1151 | -/// before it; this one cannot. It is a check on the whole span from the tile walk | |
| 1152 | -/// to the caller's frame, not a claim that the pre-deblock scan is insufficient. | |
| 1153 | -pub(super) static FINAL_UNWRITTEN_SAMPLES: std::sync::atomic::AtomicUsize = | |
| 1154 | - std::sync::atomic::AtomicUsize::new(0); | |
| 1155 | - | |
| 1156 | -/// lane-unwritten-dep: reads and clears [`FINAL_UNWRITTEN_SAMPLES`] -- unwritten | |
| 1157 | -/// samples still present in the frame as handed to the caller, summed over every | |
| 1158 | -/// frame and plane. Process-global, like the pre-deblock census's counter, so a | |
| 1159 | -/// gate can read it after the decode from a different thread than the one that | |
| 1160 | -/// scanned. | |
| 1161 | -pub fn take_final_unwritten_samples() -> usize { | |
| 1162 | - FINAL_UNWRITTEN_SAMPLES.swap(0, std::sync::atomic::Ordering::SeqCst) | |
| 1163 | -} | |
| 1164 | - | |
| 1165 | -/// lane-av1graincensus: samples still holding the poison after film grain, over | |
| 1166 | -/// the picture [`crate::film_grain::apply_grain`] RETURNS -- i.e. the picture the | |
| 1167 | -/// caller receives on a grained frame. | |
| 1168 | -pub(super) static GRAINED_UNWRITTEN_SAMPLES: std::sync::atomic::AtomicUsize = | |
| 1169 | - std::sync::atomic::AtomicUsize::new(0); | |
| 1170 | - | |
| 1171 | -/// Reads and clears [`GRAINED_UNWRITTEN_SAMPLES`]. | |
| 1172 | -pub fn take_grained_unwritten_samples() -> usize { | |
| 1173 | - GRAINED_UNWRITTEN_SAMPLES.swap(0, std::sync::atomic::Ordering::SeqCst) | |
| 1174 | -} | |
| 1175 | - | |
| 1176 | 615 | /// A frame plane's own backing store, `n` samples, zero-filled. |
| 1177 | -/// | |
| 1178 | -/// The `true_width`/`true_height`/`width`/`height` arguments are kept for the | |
| 1179 | -/// call sites' shape and the sentinel's poison fill; the zero fill itself reads | |
| 1180 | -/// none of them. The former `EC_AV1_PLANE_ALLOC=uninit|padzero|extzero` arms | |
| 1181 | -/// (uninitialised allocation for memcheck census) are gone: they needed | |
| 1182 | -/// `set_len` over uninitialised memory, which the crate no longer contains. The | |
| 1183 | -/// shipped default was already the zeroed arm (`lanes/av1uballoc.report.md` §1); | |
| 1184 | -/// the poison sentinel (`EC_AV1_PLANE_SENTINEL`) still catches any read of the | |
| 1185 | -/// initial content. | |
| 1186 | -pub(super) fn fresh_plane( | |
| 1187 | - n: usize, | |
| 1188 | - _true_width: usize, | |
| 1189 | - _true_height: usize, | |
| 1190 | - _width: usize, | |
| 1191 | - _height: usize, | |
| 1192 | -) -> Vec<u16> { | |
| 1193 | - if plane_sentinel_on() { | |
| 1194 | - return vec![plane_poison(); n]; | |
| 1195 | - } | |
| 616 | +pub(super) fn fresh_plane(n: usize) -> Vec<u16> { | |
| 1196 | 617 | vec![0u16; n] |
| 1197 | 618 | } |
| 1198 | 619 | |
| @@ -1227,52 +648,6 @@ pub(super) struct PlaneBuf<'a> { | ||
| 1227 | 648 | pub(super) plane: u8, |
| 1228 | 649 | } |
| 1229 | 650 | |
| 1230 | -/// One entry per `MV_REFERENCE_FRAME` (index 0/1 unused -- `NONE`/ | |
| 1231 | -/// `INTRA_FRAME`/`LAST_FRAME` all resolve elsewhere), `Some` when this | |
| 1232 | -/// frame's own `ref_frame_idx` names a DPB slot that has a picture in it | |
| 1233 | -/// (lane-av1refs: the same "empty slot" case `GOLDEN_FRAME` already | |
| 1234 | -/// refused by name, now generic across `LAST2`/`LAST3`/`GOLDEN`/`BWDREF`/ | |
| 1235 | -/// `ALTREF2`/`ALTREF`). | |
| 1236 | -// lane-av1pixprobe: env-gated one-sample write probe -- `EC_AV1_PIXPROBE=x,y` | |
| 1237 | -// prints one PIXWRITE line per reconstruction store landing on that sample, | |
| 1238 | -// naming the store site, the value it replaces and the one it leaves. Re-anchored | |
| 1239 | -// from `lane-av1-ibcwrite` @ 25f5c729 onto the main-shape sites (the two mc stores | |
| 1240 | -// now live in `reconstruct_mc_rect`). | |
| 1241 | -pub(super) static PIXPROBE_ON: std::sync::LazyLock<bool> = | |
| 1242 | - std::sync::LazyLock::new(|| std::env::var_os("EC_AV1_PIXPROBE").is_some()); | |
| 1243 | - | |
| 1244 | -pub(super) static PIXPROBE: std::sync::LazyLock<Option<(usize, usize)>> = | |
| 1245 | - std::sync::LazyLock::new(|| { | |
| 1246 | - crate::envflags::var("EC_AV1_PIXPROBE").ok().and_then(|v| { | |
| 1247 | - let (x, y) = v.split_once(',')?; | |
| 1248 | - Some(( | |
| 1249 | - x.trim().parse::<usize>().ok()?, | |
| 1250 | - y.trim().parse::<usize>().ok()?, | |
| 1251 | - )) | |
| 1252 | - }) | |
| 1253 | - }); | |
| 1254 | - | |
| 1255 | -#[inline] | |
| 1256 | -// Signature mirrors the spec's per-call inputs; a parameter struct would only move them. | |
| 1257 | -#[allow(clippy::too_many_arguments)] | |
| 1258 | -pub(super) fn pix_write( | |
| 1259 | - site: &str, | |
| 1260 | - bx: usize, | |
| 1261 | - by: usize, | |
| 1262 | - bside: usize, | |
| 1263 | - x: usize, | |
| 1264 | - y: usize, | |
| 1265 | - prev: u16, | |
| 1266 | - val: u16, | |
| 1267 | -) { | |
| 1268 | - if *PIXPROBE_ON && Some((x, y)) == *PIXPROBE { | |
| 1269 | - eprintln!( | |
| 1270 | - "PIXWRITE {site} block=({bx},{by})+{bside} px=({x},{y}) prev={prev} val={val} at {}", | |
| 1271 | - std::panic::Location::caller() | |
| 1272 | - ); | |
| 1273 | - } | |
| 1274 | -} | |
| 1275 | - | |
| 1276 | 651 | impl PlaneBuf<'_> { |
| 1277 | 652 | /// Sets this plane's own tile pixel origin ([`Self::tile_x0`]/ |
| 1278 | 653 | /// [`Self::tile_y0`]) before that tile's own superblock walk. `x0`/`y0` |
| @@ -1356,12 +731,6 @@ impl PlaneBuf<'_> { | ||
| 1356 | 731 | }); |
| 1357 | 732 | let corner = |
| 1358 | 733 | (x > self.tile_x0 && y > self.tile_y0).then(|| self.data[(y - 1) * self.width + x - 1]); |
| 1359 | - if matches!((bw, bh), (16, 8) | (8, 16)) { | |
| 1360 | - hit!(RECT_STRIP_PRED_HITS); | |
| 1361 | - if across > own_across || down > own_down { | |
| 1362 | - hit!(RECT_STRIP_REACH_HITS); | |
| 1363 | - } | |
| 1364 | - } | |
| 1365 | 734 | (above, left, corner) |
| 1366 | 735 | } |
| 1367 | 736 | |
| @@ -1398,18 +767,6 @@ impl PlaneBuf<'_> { | ||
| 1398 | 767 | buf |
| 1399 | 768 | } else { |
| 1400 | 769 | let (above, left, corner) = self.edges_rect(x, y, bw, bh, reach); |
| 1401 | - if crate::envflags::env_flag!("EC_DEBUG_EDGES") { | |
| 1402 | - eprintln!( | |
| 1403 | - "EDGES x={x} y={y} bw={bw} bh={bh} mode={mode} above={:?} left_len={:?} left0={:?} corner={corner:?} tx0={} ty0={} truew={} trueh={}", | |
| 1404 | - above.as_ref().map(|a| (a.len(), a[0])), | |
| 1405 | - left.as_ref().map(|l| l.len()), | |
| 1406 | - left.as_ref().map(|l| l[0]), | |
| 1407 | - self.tile_x0, | |
| 1408 | - self.tile_y0, | |
| 1409 | - self.true_width, | |
| 1410 | - self.true_height | |
| 1411 | - ); | |
| 1412 | - } | |
| 1413 | 770 | let mut prediction = vec![0u16; bw * bh]; |
| 1414 | 771 | if let Some(fi_mode) = filter_intra { |
| 1415 | 772 | crate::intra::predict_filter_intra( |
| @@ -1442,25 +799,7 @@ impl PlaneBuf<'_> { | ||
| 1442 | 799 | }; |
| 1443 | 800 | // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's |
| 1444 | 801 | // EC_PRED/EC_PREDND rungs (x/y are this plane's pixel origin). |
| 1445 | - if crate::envflags::env_flag!("EC_PRED") { | |
| 1446 | - let sum: i64 = prediction.iter().map(|&v| i64::from(v)).sum(); | |
| 1447 | - let row0: Vec<u16> = prediction[..bw.min(8)].to_vec(); | |
| 1448 | - let col0: Vec<u16> = (0..bh.min(8)).map(|r| prediction[r * bw]).collect(); | |
| 1449 | - eprintln!( | |
| 1450 | - "@{} OUR_PRED x={x} y={y} plane={} bw={bw} bh={bh} mode={mode} ad={angle_delta} ft={} sum={sum} row0={row0:?} col0={col0:?}", | |
| 1451 | - std::panic::Location::caller(), | |
| 1452 | - recon_plane(), | |
| 1453 | - i32::from(smooth_neighbor) | |
| 1454 | - ); | |
| 1455 | - } | |
| 1456 | 802 | let residual = dense_residual(residual, bw * bh); |
| 1457 | - if crate::envflags::env_flag!("EC_DBG192") && y == 168 && (x == 224 || x == 232) { | |
| 1458 | - let res0: Vec<i32> = residual[..bw.min(8)].to_vec(); | |
| 1459 | - let pred0: Vec<u16> = prediction[..bw.min(8)].to_vec(); | |
| 1460 | - eprintln!( | |
| 1461 | - "DBG192 rect x={x} y={y} bw={bw} bh={bh} mode={mode} pred0={pred0:?} res0={res0:?}" | |
| 1462 | - ); | |
| 1463 | - } | |
| 1464 | 803 | for row in 0..bh { |
| 1465 | 804 | // Same bottom/right frame-edge clip as [`Self::reconstruct`]'s |
| 1466 | 805 | // (lane-sb128c r8) -- a 64x128 block at the right edge of a frame |
| @@ -1481,16 +820,6 @@ impl PlaneBuf<'_> { | ||
| 1481 | 820 | base = (base + cfl_scaled(alpha_q3, ac)).clamp(0, sample_max(fctx)); |
| 1482 | 821 | } |
| 1483 | 822 | let sample = (base + residual[idx]).clamp(0, sample_max(fctx)) as u16; |
| 1484 | - pix_write( | |
| 1485 | - "reconstruct_rect", | |
| 1486 | - x, | |
| 1487 | - y, | |
| 1488 | - bw, | |
| 1489 | - x + col, | |
| 1490 | - y + row, | |
| 1491 | - self.data[(y + row) * self.width + x + col], | |
| 1492 | - sample, | |
| 1493 | - ); | |
| 1494 | 823 | self.data.to_mut()[(y + row) * self.width + x + col] = sample; |
| 1495 | 824 | } |
| 1496 | 825 | } |
| @@ -1498,15 +827,6 @@ impl PlaneBuf<'_> { | ||
| 1498 | 827 | // -- a block whose prediction matches the oracle's but whose written |
| 1499 | 828 | // samples do not is either a residual defect or a later overwrite, and |
| 1500 | 829 | // only this print separates the two. |
| 1501 | - if crate::envflags::env_flag!("EC_PRED") { | |
| 1502 | - let row0: Vec<u16> = (0..bw.min(8)) | |
| 1503 | - .map(|c| self.data[y * self.width + x + c]) | |
| 1504 | - .collect(); | |
| 1505 | - let col0: Vec<u16> = (0..bh.min(8)) | |
| 1506 | - .map(|r| self.data[(y + r) * self.width + x]) | |
| 1507 | - .collect(); | |
| 1508 | - eprintln!("OUR_RECON x={x} y={y} bw={bw} bh={bh} row0={row0:?} col0={col0:?}"); | |
| 1509 | - } | |
| 1510 | 830 | } |
| 1511 | 831 | |
| 1512 | 832 | /// Predicts under `mode` then adds `residual` (side*side, raster), |
| @@ -1553,13 +873,6 @@ impl PlaneBuf<'_> { | ||
| 1553 | 873 | buf |
| 1554 | 874 | } else { |
| 1555 | 875 | let (above, left, corner) = self.edges(x, y, side, reach); |
| 1556 | - if crate::envflags::env_flag!("EC_DEBUG_EDGES") { | |
| 1557 | - eprintln!( | |
| 1558 | - "EDGES_SQ x={x} y={y} side={side} mode={mode} above={:?} left={:?} corner={corner:?}", | |
| 1559 | - above.as_deref(), | |
| 1560 | - left.as_deref(), | |
| 1561 | - ); | |
| 1562 | - } | |
| 1563 | 876 | let mut prediction = vec![0u16; side * side]; |
| 1564 | 877 | if let Some(fi_mode) = filter_intra { |
| 1565 | 878 | crate::intra::predict_filter_intra( |
| @@ -1599,26 +912,7 @@ impl PlaneBuf<'_> { | ||
| 1599 | 912 | }; |
| 1600 | 913 | // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's |
| 1601 | 914 | // EC_PRED/EC_PREDND rungs (x/y are this plane's pixel origin). |
| 1602 | - if crate::envflags::env_flag!("EC_PRED") { | |
| 1603 | - let sum: i64 = prediction.iter().map(|&v| i64::from(v)).sum(); | |
| 1604 | - let row0: Vec<u16> = prediction[..side.min(8)].to_vec(); | |
| 1605 | - let col0: Vec<u16> = (0..side.min(8)).map(|r| prediction[r * side]).collect(); | |
| 1606 | - eprintln!( | |
| 1607 | - "@{} OUR_PRED x={x} y={y} plane={} side={side} side={side} mode={mode} ad={angle_delta} ft={} sum={sum} row0={row0:?} col0={col0:?}", | |
| 1608 | - std::panic::Location::caller(), | |
| 1609 | - recon_plane(), | |
| 1610 | - i32::from(smooth_neighbor) | |
| 1611 | - ); | |
| 1612 | - } | |
| 1613 | 915 | let residual = dense_residual(residual, side * side); |
| 1614 | - if crate::envflags::env_flag!("EC_DBG192") && y == 168 && (x == 224 || x == 232) { | |
| 1615 | - let res0: Vec<i32> = residual[..side.min(8)].to_vec(); | |
| 1616 | - let pred0: Vec<u16> = prediction[..side.min(8)].to_vec(); | |
| 1617 | - eprintln!( | |
| 1618 | - "DBG192 sq x={x} y={y} side={side} mode={mode} cfl={} pred0={pred0:?} res0={res0:?}", | |
| 1619 | - cfl.is_some() | |
| 1620 | - ); | |
| 1621 | - } | |
| 1622 | 916 | for row in 0..side { |
| 1623 | 917 | // lane-sb128c r8: libaom's frame buffer is superblock |
| 1624 | 918 | // aligned; ours is padded to 32 (`block_grid`), so a 64x64 |
| @@ -1644,16 +938,6 @@ impl PlaneBuf<'_> { | ||
| 1644 | 938 | base = (base + cfl_scaled(alpha_q3, ac)).clamp(0, sample_max(fctx)); |
| 1645 | 939 | } |
| 1646 | 940 | let sample = (base + residual[idx]).clamp(0, sample_max(fctx)) as u16; |
| 1647 | - pix_write( | |
| 1648 | - "reconstruct", | |
| 1649 | - x, | |
| 1650 | - y, | |
| 1651 | - side, | |
| 1652 | - x + col, | |
| 1653 | - y + row, | |
| 1654 | - self.data[(y + row) * self.width + x + col], | |
| 1655 | - sample, | |
| 1656 | - ); | |
| 1657 | 941 | self.data.to_mut()[(y + row) * self.width + x + col] = sample; |
| 1658 | 942 | } |
| 1659 | 943 | } |
| @@ -1670,9 +954,6 @@ pub(super) fn read_plane( | ||
| 1670 | 954 | scan: &[u16], |
| 1671 | 955 | plane_idx: usize, |
| 1672 | 956 | around: (bool, bool, i32), |
| 1673 | - // The block's own luma mode — [`crate::tile::write_block_planes`] passes | |
| 1674 | - // it for every plane's `txb` lookup (it is what an intra transform type's | |
| 1675 | - // CDF is indexed by, spec 9.3), never the plane's own predicted mode. | |
| 1676 | 957 | tx_mode: usize, |
| 1677 | 958 | predict_mode: usize, |
| 1678 | 959 | angle_delta: i32, |
| @@ -1684,17 +965,9 @@ pub(super) fn read_plane( | ||
| 1684 | 965 | cy: usize, |
| 1685 | 966 | side: usize, |
| 1686 | 967 | tx_side: usize, |
| 1687 | - base_q_idx: u8, | |
| 1688 | 968 | cfl: Option<(i32, CflSrc)>, |
| 1689 | 969 | filter_intra: Option<usize>, |
| 1690 | - // Only meaningful for `plane_idx == 0`: `Some` when this transform unit is | |
| 1691 | - // smaller than its own block (spec `get_txb_ctx_general`'s | |
| 1692 | - // `plane_bsize != tx_size` branch), carrying the already-looked-up | |
| 1693 | - // `SKIP_CONTEXTS` value; `None` everywhere else (a lone luma TU, or any | |
| 1694 | - // chroma plane), where `txb_skip_ctx` is 0 or the usual OR-of-neighbours | |
| 1695 | - // formula below. | |
| 1696 | 970 | luma_skip_ctx: Option<usize>, |
| 1697 | - // See [`PlaneBuf::reconstruct`]'s own doc: caller's neighbour-smooth check. | |
| 1698 | 971 | smooth_neighbor: bool, |
| 1699 | 972 | fctx: &crate::decode::FrameCtx, |
| 1700 | 973 | ) -> Result<Grid> { |
| @@ -1706,8 +979,6 @@ pub(super) fn read_plane( | ||
| 1706 | 979 | if plane_idx > 0 && mono(fctx) { |
| 1707 | 980 | return Ok(Grid::Zero(side * side)); |
| 1708 | 981 | } |
| 1709 | - // lane-av1readcensus: the units read from here on are this plane's. | |
| 1710 | - set_census_plane(plane_idx); | |
| 1711 | 982 | let skip_ctx = if plane_idx == 0 { |
| 1712 | 983 | luma_skip_ctx.unwrap_or(0) |
| 1713 | 984 | } else { |
| @@ -1733,12 +1004,6 @@ pub(super) fn read_plane( | ||
| 1733 | 1004 | // labelling its unit `plane=0`, and a sweep reading a second-luma-unit |
| 1734 | 1005 | // phantom out of that label (class `rung-mislabels-plane`). Diagnostic |
| 1735 | 1006 | // only: no gate asserts decode behaviour off this line. |
| 1736 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 1737 | - eprintln!( | |
| 1738 | - "OUR_MODE plane={plane_idx} x={x} y={cy} side={side} mode={predict_mode} \ | |
| 1739 | - ad={angle_delta} fi={filter_intra:?} reach={reach:?}" | |
| 1740 | - ); | |
| 1741 | - } | |
| 1742 | 1007 | let tx_mode = if plane_idx == 0 { |
| 1743 | 1008 | fi_tx_row(tx_mode, filter_intra) |
| 1744 | 1009 | } else { |
| @@ -1813,7 +1078,6 @@ pub(super) fn read_plane( | ||
| 1813 | 1078 | default_tx_type, |
| 1814 | 1079 | None, |
| 1815 | 1080 | )?; |
| 1816 | - note_chroma_class1(plane_idx, tx_type); | |
| 1817 | 1081 | if plane_idx == 0 { |
| 1818 | 1082 | fctx.luma_tx_type.with(|c| c.set(tx_type)); |
| 1819 | 1083 | } |
| @@ -1840,13 +1104,6 @@ pub(super) fn read_plane( | ||
| 1840 | 1104 | stride: 0, |
| 1841 | 1105 | lossless: lossless(fctx), |
| 1842 | 1106 | }; |
| 1843 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 1844 | - let residual = tx.run(&levels); | |
| 1845 | - eprintln!( | |
| 1846 | - "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={:?} residual={residual:?}", | |
| 1847 | - &*levels, | |
| 1848 | - ); | |
| 1849 | - } | |
| 1850 | 1107 | push_intra_tx( |
| 1851 | 1108 | y, |
| 1852 | 1109 | u, |
| @@ -1988,9 +1245,6 @@ pub(super) fn read_rect_chroma_unit( | ||
| 1988 | 1245 | smooth_neighbor_uv: bool, |
| 1989 | 1246 | fctx: &crate::decode::FrameCtx, |
| 1990 | 1247 | ) -> Result<Grid> { |
| 1991 | - if ss_x(fctx) == 1 && ss_y(fctx) == 0 && w != h { | |
| 1992 | - hit!(CHROMA422_RECT_HITS); | |
| 1993 | - } | |
| 1994 | 1248 | // The same three cases as [`read_plane`], for the same reason: at 32 points |
| 1995 | 1249 | // an INTER chroma unit's transform set is `EXT_TX_SET_DCT_IDTX` (the luma's |
| 1996 | 1250 | // coded `IDTX` survives) where the intra set is `EXT_TX_SET_DCTONLY`, and |
| @@ -2016,7 +1270,6 @@ pub(super) fn read_rect_chroma_unit( | ||
| 2016 | 1270 | usize::from(around.0) + usize::from(around.1) + chroma_skip_offset.unwrap_or(0), |
| 2017 | 1271 | dc_sign_ctx(around.2), |
| 2018 | 1272 | default_tx, |
| 2019 | - plane_idx, | |
| 2020 | 1273 | )?; |
| 2021 | 1274 | let residual = dequant_and_inverse_typed_wh( |
| 2022 | 1275 | &levels, |
| @@ -2086,7 +1339,6 @@ pub(super) fn decode_block( | ||
| 2086 | 1339 | let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(at); |
| 2087 | 1340 | let palette_uv_cache = neighbours.palette_uv_cache(at); |
| 2088 | 1341 | let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c); |
| 2089 | - let at_tile_left = c == neighbours.tile_col0_mi / (SUB / MI); | |
| 2090 | 1342 | let ( |
| 2091 | 1343 | skip, |
| 2092 | 1344 | mode, |
| @@ -2114,9 +1366,6 @@ pub(super) fn decode_block( | ||
| 2114 | 1366 | c * (SUB / MI), |
| 2115 | 1367 | fctx, |
| 2116 | 1368 | )?; |
| 2117 | - if at_tile_left && palette_y.is_some() { | |
| 2118 | - hit!(PALETTE_TILE_LEFT_HITS); | |
| 2119 | - } | |
| 2120 | 1369 | // lane-lossless: a lossless BLOCK's transform is TX_4X4 on every plane |
| 2121 | 1370 | // (libaom `read_tx_size`, `decodeframe.c`), so the caller's per-size |
| 2122 | 1371 | // tables/scans are replaced by the 4x4 ones and the block always takes the |
| @@ -2185,17 +1434,8 @@ pub(super) fn decode_block( | ||
| 2185 | 1434 | uv_mode |
| 2186 | 1435 | }; |
| 2187 | 1436 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 2188 | - if smooth_neighbor { | |
| 2189 | - hit!(SMOOTH_LUMA_HITS); | |
| 2190 | - } | |
| 2191 | 1437 | let smooth_neighbor_uv = |
| 2192 | 1438 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c, fctx); |
| 2193 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 2194 | - eprintln!( | |
| 2195 | - "TRACE block px={px} py={py} side={side} mode={mode} uv_mode={uv_mode} \ | |
| 2196 | - angle_delta_uv={angle_delta_uv}" | |
| 2197 | - ); | |
| 2198 | - } | |
| 2199 | 1439 | let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); |
| 2200 | 1440 | // `TxMode::Select`'s `tx_depth` (spec 5.11.16): read for every intra |
| 2201 | 1441 | // block, skipped or not. `logical_tx` is what the loop filter's edge |
| @@ -2252,29 +1492,12 @@ pub(super) fn decode_block( | ||
| 2252 | 1492 | ); |
| 2253 | 1493 | } |
| 2254 | 1494 | } |
| 2255 | - hit!(INTRABC_VARTX_HITS); | |
| 2256 | 1495 | // lane-t900 r33 census: the t900 recipes resolved every tree UNIFORM. |
| 2257 | 1496 | // lane-av1-ibcvtx: a tree that resolved to mixed leaf sizes is no |
| 2258 | 1497 | // longer refused -- the luma reconstruct below walks the tree's own |
| 2259 | 1498 | // leaf list per leaf (libaom `decode_token_recon_block`, whose token |
| 2260 | 1499 | // loop reconstructs whatever `read_tx_size_vartx` resolved, per |
| 2261 | 1500 | // transform unit), so mixed sizes reconstruct at their own stride. |
| 2262 | - // The counter marks the shape so a gate can prove a witness actually | |
| 2263 | - // carries a mixed tree and not merely another uniform one. | |
| 2264 | - let uniform = leaves.first().is_some_and(|f| { | |
| 2265 | - leaves | |
| 2266 | - .iter() | |
| 2267 | - .all(|l| (l.2, l.3) == (f.2, f.3) && l.2 == l.3) | |
| 2268 | - }); | |
| 2269 | - if !uniform { | |
| 2270 | - hit!(INTRABC_VARTX_MIXED_LEAVES_HITS); | |
| 2271 | - if crate::envflags::env_flag!("EC_AV1_IBCVTX_DEBUG") { | |
| 2272 | - eprintln!( | |
| 2273 | - "IBCVTX mixed intrabc tree mi=({mi_r},{mi_c}) side={side} \ | |
| 2274 | - dv={intrabc_dv:?} leaves={leaves:?}" | |
| 2275 | - ); | |
| 2276 | - } | |
| 2277 | - } | |
| 2278 | 1501 | Some(leaves) |
| 2279 | 1502 | } else { |
| 2280 | 1503 | None |
| @@ -2291,9 +1514,6 @@ pub(super) fn decode_block( | ||
| 2291 | 1514 | // single-unit path. |
| 2292 | 1515 | (lossless_tx(side.min(64), fctx), luma_tx) |
| 2293 | 1516 | }; |
| 2294 | - if tx_select && logical_tx < side && uv_mode != DC_PRED { | |
| 2295 | - hit!(SQ_CHROMA_TX_HITS); | |
| 2296 | - } | |
| 2297 | 1517 | let luma_set = if tx_select { |
| 2298 | 1518 | txbset_for(logical_tx, reduced_tx_set) |
| 2299 | 1519 | } else { |
| @@ -2400,9 +1620,6 @@ pub(super) fn decode_block( | ||
| 2400 | 1620 | // Counted on the SHAPE, not on the arm below, so a gate can tell a stream |
| 2401 | 1621 | // that reaches this block apart from one that never does (class |
| 2402 | 1622 | // gate-blind-to-feature). |
| 2403 | - if palette_y_buf.is_some() && skip && logical_tx < side { | |
| 2404 | - hit!(SKIP_SPLIT_TX_OVERRIDE_HITS); | |
| 2405 | - } | |
| 2406 | 1623 | if let Some(buf) = &palette_y_buf |
| 2407 | 1624 | && (logical_tx == side || skip) |
| 2408 | 1625 | { |
| @@ -2453,9 +1670,6 @@ pub(super) fn decode_block( | ||
| 2453 | 1670 | // narrower meaning (a READ split tx depth). |
| 2454 | 1671 | let split_tx_skip = logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); |
| 2455 | 1672 | if split_tx_skip { |
| 2456 | - if tx_select { | |
| 2457 | - hit!(SKIP_SPLIT_TX_HITS); | |
| 2458 | - } | |
| 2459 | 1673 | let n_axis = side / logical_tx; |
| 2460 | 1674 | for tu_row in 0..n_axis { |
| 2461 | 1675 | for tu_col in 0..n_axis { |
| @@ -2471,11 +1685,6 @@ pub(super) fn decode_block( | ||
| 2471 | 1685 | tu_row * logical_tx, |
| 2472 | 1686 | logical_tx, |
| 2473 | 1687 | reach, |
| 2474 | - px, | |
| 2475 | - py, | |
| 2476 | - y.width, | |
| 2477 | - y.height, | |
| 2478 | - fctx, | |
| 2479 | 1688 | ); |
| 2480 | 1689 | push_intra( |
| 2481 | 1690 | y, |
| @@ -2540,11 +1749,6 @@ pub(super) fn decode_block( | ||
| 2540 | 1749 | luma_span_x, |
| 2541 | 1750 | luma_span_y, |
| 2542 | 1751 | reach, |
| 2543 | - px, | |
| 2544 | - py, | |
| 2545 | - y.width, | |
| 2546 | - y.height, | |
| 2547 | - fctx, | |
| 2548 | 1752 | ) |
| 2549 | 1753 | }; |
| 2550 | 1754 | let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx_h); |
| @@ -2580,9 +1784,6 @@ pub(super) fn decode_block( | ||
| 2580 | 1784 | window |
| 2581 | 1785 | }; |
| 2582 | 1786 | if let Some((ub, _)) = &palette_uv_bufs { |
| 2583 | - if cn_cols * cn_rows > 1 { | |
| 2584 | - hit!(SKIP_CHROMA_OVERRIDE_WINDOW_HITS); | |
| 2585 | - } | |
| 2586 | 1787 | set_palette_pred(chroma_window(ub), fctx); |
| 2587 | 1788 | } |
| 2588 | 1789 | push_intra_unit( |
| @@ -2645,18 +1846,6 @@ pub(super) fn decode_block( | ||
| 2645 | 1846 | // side`, so only 4:2:2 changes. |
| 2646 | 1847 | let u_grid = vec![0i32; chroma_side * chroma_height]; |
| 2647 | 1848 | let v_grid = vec![0i32; chroma_side * chroma_height]; |
| 2648 | - // The measured arm, not a proxy: how many samples this block's | |
| 2649 | - // chroma bookkeeping grid is SHORT of its own plane block. The | |
| 2650 | - // square form this lane removed is `chroma_side * chroma_side`, | |
| 2651 | - // which at 4:2:2 is half the plane block; restoring it makes this | |
| 2652 | - // non-zero on every 4:2:2 skip block, and the witness gate asserts | |
| 2653 | - // the total stayed 0. | |
| 2654 | - let plane_block = chroma_side * chroma_height; | |
| 2655 | - let short = plane_block.saturating_sub(u_grid.len()); | |
| 2656 | - hit_do!(SKIP_ARM_CHROMA_SHORT_SAMPLES.with(|c| c.set(c.get() + short))); | |
| 2657 | - if chroma_side != chroma_height { | |
| 2658 | - hit!(SKIP_ARM_CHROMA_RECT_SHAPES); | |
| 2659 | - } | |
| 2660 | 1849 | neighbours.record( |
| 2661 | 1850 | at, |
| 2662 | 1851 | side, |
| @@ -2692,7 +1881,6 @@ pub(super) fn decode_block( | ||
| 2692 | 1881 | py, |
| 2693 | 1882 | side, |
| 2694 | 1883 | coeff_tx_side, |
| 2695 | - base_q_idx, | |
| 2696 | 1884 | None, |
| 2697 | 1885 | filter_intra, |
| 2698 | 1886 | None, |
| @@ -2745,19 +1933,12 @@ pub(super) fn decode_block( | ||
| 2745 | 1933 | cpy, |
| 2746 | 1934 | chroma_side, |
| 2747 | 1935 | chroma_tx, |
| 2748 | - base_q_idx, | |
| 2749 | 1936 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 2750 | 1937 | None, |
| 2751 | 1938 | None, |
| 2752 | 1939 | smooth_neighbor_uv, |
| 2753 | 1940 | fctx, |
| 2754 | 1941 | )?; |
| 2755 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 2756 | - eprintln!( | |
| 2757 | - "TRACE u-write cpx={cpx} cpy={cpy} chroma_side={chroma_side} row0={:?}", | |
| 2758 | - &u.data[cpy * u.width + cpx..][..chroma_side] | |
| 2759 | - ); | |
| 2760 | - } | |
| 2761 | 1942 | if let Some((_, vb)) = &palette_uv_bufs { |
| 2762 | 1943 | set_palette_pred(vb.clone(), fctx); |
| 2763 | 1944 | } |
| @@ -2779,7 +1960,6 @@ pub(super) fn decode_block( | ||
| 2779 | 1960 | cpy, |
| 2780 | 1961 | chroma_side, |
| 2781 | 1962 | chroma_tx, |
| 2782 | - base_q_idx, | |
| 2783 | 1963 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 2784 | 1964 | None, |
| 2785 | 1965 | None, |
| @@ -2877,11 +2057,6 @@ pub(super) fn decode_block( | ||
| 2877 | 2057 | luma_span_x, |
| 2878 | 2058 | luma_span_y, |
| 2879 | 2059 | reach, |
| 2880 | - px, | |
| 2881 | - py, | |
| 2882 | - y.width, | |
| 2883 | - y.height, | |
| 2884 | - fctx, | |
| 2885 | 2060 | ); |
| 2886 | 2061 | let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx_h); |
| 2887 | 2062 | if let Some((ub, vb)) = &palette_uv_bufs { |
| @@ -2916,7 +2091,6 @@ pub(super) fn decode_block( | ||
| 2916 | 2091 | cu_y, |
| 2917 | 2092 | chroma_tx, |
| 2918 | 2093 | chroma_tx, |
| 2919 | - base_q_idx, | |
| 2920 | 2094 | alpha |
| 2921 | 2095 | .zip(ac) |
| 2922 | 2096 | .map(|((au, av), ac)| (if plane_pass == 1 { au } else { av }, ac)), |
| @@ -2925,10 +2099,6 @@ pub(super) fn decode_block( | ||
| 2925 | 2099 | smooth_neighbor_uv, |
| 2926 | 2100 | fctx, |
| 2927 | 2101 | )?; |
| 2928 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 2929 | - if ss_x(fctx) == 1 && ss_y(fctx) == 0 { | |
| 2930 | - hit!(CHROMA422_SQUARE_HITS); | |
| 2931 | - } | |
| 2932 | 2102 | // Immediately, so the next unit of this block reads this |
| 2933 | 2103 | // one's coefficient context. `record` below stamps one |
| 2934 | 2104 | // chroma state across the whole block; the replay after |
| @@ -3054,10 +2224,7 @@ pub(super) fn decode_block( | ||
| 3054 | 2224 | // top-right 8x8 unit of a 16x16 D203 block bottom-left |
| 3055 | 2225 | // pixels libaom refuses outright (`col_off > 0`), which is |
| 3056 | 2226 | // the diagonal wedge seed 46 reconstructed wrong. |
| 3057 | - let tu_reach = tu_reach( | |
| 3058 | - side, side, tu_off_x, tu_off_y, tu_tx, reach, px, py, y.width, y.height, | |
| 3059 | - fctx, | |
| 3060 | - ); | |
| 2227 | + let tu_reach = tu_reach(side, side, tu_off_x, tu_off_y, tu_tx, reach); | |
| 3061 | 2228 | // This transform unit's own bsize (`tu_tx`) is smaller |
| 3062 | 2229 | // than the block it sits in (`side`), so `txb_skip_ctx` is |
| 3063 | 2230 | // the neighbour-magnitude table, not the lone-TU 0 (spec |
| @@ -3083,7 +2250,6 @@ pub(super) fn decode_block( | ||
| 3083 | 2250 | (luma_set, luma_scan) |
| 3084 | 2251 | }; |
| 3085 | 2252 | if let Some(buf) = &palette_y_buf { |
| 3086 | - hit!(PALETTE_SPLIT_TX_HITS); | |
| 3087 | 2253 | let mut window = vec![0u16; tu_tx * tu_tx]; |
| 3088 | 2254 | for row in 0..tu_tx { |
| 3089 | 2255 | let src = (tu_off_y + row) * side + tu_off_x; |
| @@ -3108,26 +2274,13 @@ pub(super) fn decode_block( | ||
| 3108 | 2274 | tu_px, |
| 3109 | 2275 | tu_py, |
| 3110 | 2276 | tu_tx, |
| 3111 | - // The unit's own COEFFICIENT grid, half its side at | |
| 3112 | - // TX_64X64 (a 64-point transform codes nothing past 32); | |
| 3113 | - // identical to `tu_tx` at every smaller size | |
| 3114 | - // (lane-sb128b r1). | |
| 3115 | 2277 | if tu_tx == 64 { 32 } else { tu_tx }, |
| 3116 | - base_q_idx, | |
| 3117 | 2278 | None, |
| 3118 | 2279 | filter_intra, |
| 3119 | 2280 | Some(tu_skip_ctx), |
| 3120 | 2281 | smooth_neighbor, |
| 3121 | 2282 | fctx, |
| 3122 | 2283 | )?; |
| 3123 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 3124 | - eprintln!( | |
| 3125 | - "TRACE tu_bitpos mi=({},{}) tell={}", | |
| 3126 | - tu_mi.0, | |
| 3127 | - tu_mi.1, | |
| 3128 | - dec.debug_bitpos() | |
| 3129 | - ); | |
| 3130 | - } | |
| 3131 | 2284 | neighbours.record_mi_luma(tu_mi, tu_tx, &tu_grid); |
| 3132 | 2285 | if first_leaf_tx.is_none() { |
| 3133 | 2286 | first_leaf_tx = Some(fctx.luma_tx_type.with(std::cell::Cell::get)); |
| @@ -3210,7 +2363,6 @@ pub(super) fn decode_block( | ||
| 3210 | 2363 | }; |
| 3211 | 2364 | let (unit_w, unit_h) = (chroma_tx / 4, chroma_tx_h / 4); |
| 3212 | 2365 | if cu_col * unit_w >= max_units_w || cu_row * unit_h >= max_units_h { |
| 3213 | - hit!(CHROMA_EDGE_TU_CLIP_HITS); | |
| 3214 | 2366 | continue; |
| 3215 | 2367 | } |
| 3216 | 2368 | // The chroma context arrays are indexed in LUMA mi, so this |
| @@ -3240,11 +2392,6 @@ pub(super) fn decode_block( | ||
| 3240 | 2392 | luma_span_x, |
| 3241 | 2393 | luma_span_y, |
| 3242 | 2394 | reach, |
| 3243 | - px, | |
| 3244 | - py, | |
| 3245 | - y.width, | |
| 3246 | - y.height, | |
| 3247 | - fctx, | |
| 3248 | 2395 | ) |
| 3249 | 2396 | }; |
| 3250 | 2397 | let (cu_x, cu_y) = |
| @@ -3282,7 +2429,6 @@ pub(super) fn decode_block( | ||
| 3282 | 2429 | cu_y, |
| 3283 | 2430 | chroma_tx, |
| 3284 | 2431 | chroma_tx, |
| 3285 | - base_q_idx, | |
| 3286 | 2432 | alpha.zip(ac).map(|((au, av), ac)| { |
| 3287 | 2433 | (if plane_pass == 1 { au } else { av }, ac) |
| 3288 | 2434 | }), |
| @@ -3322,10 +2468,6 @@ pub(super) fn decode_block( | ||
| 3322 | 2468 | )? |
| 3323 | 2469 | }; |
| 3324 | 2470 | if cn_rows * cn_cols > 1 { |
| 3325 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 3326 | - if ss_x(fctx) == 1 && ss_y(fctx) == 0 { | |
| 3327 | - hit!(CHROMA422_SQUARE_HITS); | |
| 3328 | - } | |
| 3329 | 2471 | // Immediately, so the NEXT unit of this same block reads |
| 3330 | 2472 | // this one's coefficient context (libaom's chroma |
| 3331 | 2473 | // `txb_skip_ctx` for the second quadrant is 11, i.e. base |
crates/ec-av1/src/decode/coeffs.rsmodified+68 -729
| @@ -2,70 +2,6 @@ | ||
| 2 | 2 | |
| 3 | 3 | use super::*; |
| 4 | 4 | |
| 5 | -/// lane-coefread: the per-coefficient trace sites, one `#[cold]` call each. | |
| 6 | -/// `eprintln!` builds its `fmt::Arguments` on the stack AT THE CALL SITE, so | |
| 7 | -/// nine of them inside the base/sign loops pinned nine sets of values in the | |
| 8 | -/// hot loop's frame (the annotated profile was full of `mov ...(%rsp)` spill | |
| 9 | -/// traffic). Out of line, the loop keeps its values in registers and the | |
| 10 | -/// trace output is character-for-character what it was. | |
| 11 | -#[cold] | |
| 12 | -#[inline(never)] | |
| 13 | -fn trace_base_eob(scan_idx: usize, pos: usize, row: usize, col: usize, ctx: usize, v: i32) { | |
| 14 | - eprintln!( | |
| 15 | - "TRACE base_eob scan_idx={scan_idx} pos={pos} row={row} col={col} ctx={ctx} value={v}" | |
| 16 | - ); | |
| 17 | -} | |
| 18 | - | |
| 19 | -#[cold] | |
| 20 | -#[inline(never)] | |
| 21 | -fn trace_base(scan_idx: usize, pos: usize, row: usize, col: usize, ctx: usize, v: i32) { | |
| 22 | - eprintln!("TRACE base scan_idx={scan_idx} pos={pos} row={row} col={col} ctx={ctx} value={v}"); | |
| 23 | -} | |
| 24 | - | |
| 25 | -#[cold] | |
| 26 | -#[inline(never)] | |
| 27 | -fn trace_br(scan_idx: usize, pos: usize, row: usize, col: usize, ctx: usize, k: i32) { | |
| 28 | - eprintln!("TRACE br scan_idx={scan_idx} pos={pos} row={row} col={col} ctx={ctx} value={k}"); | |
| 29 | -} | |
| 30 | - | |
| 31 | -#[cold] | |
| 32 | -#[inline(never)] | |
| 33 | -fn coeff_step_base(dec: &SymbolDecoder, scan_idx: usize, apos: usize, ctx: usize, v: i32) { | |
| 34 | - let (rng, _) = dec.debug_state(); | |
| 35 | - eprintln!("EC_COEFF_STEP tag=base c={scan_idx} pos={apos} ctx={ctx} level={v} rng={rng}"); | |
| 36 | -} | |
| 37 | - | |
| 38 | -#[cold] | |
| 39 | -#[inline(never)] | |
| 40 | -fn coeff_step_br(dec: &SymbolDecoder, scan_idx: usize, apos: usize, ctx: usize, k: i32) { | |
| 41 | - let (rng, _) = dec.debug_state(); | |
| 42 | - eprintln!("EC_COEFF_STEP tag=br c={scan_idx} pos={apos} ctx={ctx} k={k} rng={rng}"); | |
| 43 | -} | |
| 44 | - | |
| 45 | -#[cold] | |
| 46 | -#[inline(never)] | |
| 47 | -fn coeff_step_sign(dec: &SymbolDecoder, c: usize, negative: bool) { | |
| 48 | - let (rng, _) = dec.debug_state(); | |
| 49 | - eprintln!( | |
| 50 | - "EC_COEFF_STEP tag=sign c={c} sign={} rng={rng}", | |
| 51 | - negative as i32 | |
| 52 | - ); | |
| 53 | -} | |
| 54 | - | |
| 55 | -#[cold] | |
| 56 | -#[inline(never)] | |
| 57 | -fn coeff_step_post_golomb(dec: &SymbolDecoder, c: usize, level: i32) { | |
| 58 | - let (rng, _) = dec.debug_state(); | |
| 59 | - eprintln!("EC_COEFF_STEP tag=post_golomb c={c} level={level} rng={rng}"); | |
| 60 | -} | |
| 61 | - | |
| 62 | -#[cold] | |
| 63 | -#[inline(never)] | |
| 64 | -fn coeff_step_base_eob_level(dec: &SymbolDecoder, level: i32) { | |
| 65 | - let (rng, _) = dec.debug_state(); | |
| 66 | - eprintln!("EC_COEFF_STEP tag=base_eob level={level} rng={rng}"); | |
| 67 | -} | |
| 68 | - | |
| 69 | 5 | // lane-ibc444c: see `read_coeffs_rect`'s `#[track_caller]`. |
| 70 | 6 | #[track_caller] |
| 71 | 7 | pub(super) fn read_coeffs( |
| @@ -88,91 +24,12 @@ pub(super) fn read_coeffs( | ||
| 88 | 24 | // caller's block genuinely is `side` x `side`. |
| 89 | 25 | rect_shape: Option<(usize, usize)>, |
| 90 | 26 | ) -> Result<(Grid, TxType)> { |
| 91 | - let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); | |
| 92 | 27 | let side = coding.side; |
| 93 | - // lane-av1readcensus: this unit's own entry state, so the census line | |
| 94 | - // carries the pre-read rng and pairs against the oracle's `EC_COEFF` | |
| 95 | - // (which prints `r->ec.rng` before the same `txb_skip` read). | |
| 96 | - let census_entry_rng = dec.debug_state().0; | |
| 97 | - let (census_w, census_h) = rect_shape.unwrap_or((side, side)); | |
| 98 | - // lane-av1ibcfork: the per-unit BIT INTERVAL, the twin of the oracle's | |
| 99 | - // `EC_ECDUMP_IN` / `_OUT` / `_END`. The census plane, not a fresh label: | |
| 100 | - // it is the same source `census_unit` reads, so the interval line and the | |
| 101 | - // census line can never disagree about which plane a unit is on. | |
| 102 | - let iv_plane = CENSUS_PLANE.with(|c| c.get()).min(2); | |
| 103 | - let iv_bit = unit_iv_in(iv_plane, census_w, census_h, skip_ctx, dec); | |
| 104 | - if crate::envflags::env_flag!("EC_AV1_EOBPT_CDF") { | |
| 105 | - let (range, value) = dec.debug_state(); | |
| 106 | - eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}"); | |
| 107 | - } | |
| 108 | - if crate::envflags::env_flag!("EC_ECDUMP_IN") { | |
| 109 | - let (range, value) = dec.debug_state(); | |
| 110 | - let bit = dec.debug_bitpos(); | |
| 111 | - eprintln!( | |
| 112 | - "EC_ECDUMP_IN side={side} ctx={skip_ctx} dcctx={sign_ctx} ECIN=({value},{range},{bit})" | |
| 113 | - ); | |
| 114 | - } | |
| 115 | - let dbg_txbskip = if coeff_trace_on() { | |
| 116 | - coding.txb_skip[skip_ctx] | |
| 117 | - } else { | |
| 118 | - [0; 3] | |
| 119 | - }; | |
| 120 | - let sq_bit = if coeff_trace_on() { | |
| 121 | - dec.debug_bitpos() | |
| 122 | - } else { | |
| 123 | - 0 | |
| 124 | - }; | |
| 125 | 28 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; |
| 126 | - unit_iv_skip( | |
| 127 | - dec, iv_bit, iv_plane, census_w, census_h, skip_ctx, all_zero, | |
| 128 | - ); | |
| 129 | 29 | // lane-ibc444c: this reader logs an `all_zero` step even for a read that |
| 130 | 30 | // consumes ZERO bits, so `post_bit == bit` means "no symbol was read" -- |
| 131 | 31 | // filter on it before pairing anything against the oracle. |
| 132 | - if crate::envflags::env_flag!("EC_IBCTX") { | |
| 133 | - eprintln!( | |
| 134 | - "EC_IBCTX2 side={} skip_ctx={skip_ctx} sign_ctx={sign_ctx} bit={sq_bit} at {}", | |
| 135 | - coding.side, | |
| 136 | - std::panic::Location::caller(), | |
| 137 | - ); | |
| 138 | - } | |
| 139 | - if coeff_trace_on() { | |
| 140 | - let (rng, _) = dec.debug_state(); | |
| 141 | - eprintln!( | |
| 142 | - "EC_COEFF_STEP tag=all_zero side={} ctx={skip_ctx} dcctx={sign_ctx} cdf={dbg_txbskip:?} all_zero={} rng={rng} bit={sq_bit} post_bit={}", | |
| 143 | - coding.side, | |
| 144 | - all_zero as i32, | |
| 145 | - dec.debug_bitpos() | |
| 146 | - ); | |
| 147 | - } | |
| 148 | - if crate::envflags::env_flag!("EC_AV1_TELL") { | |
| 149 | - eprintln!( | |
| 150 | - "TELL label=post_txb_skip ctx={skip_ctx} all_zero={} tell={} range={}", | |
| 151 | - all_zero as u8, | |
| 152 | - dec.debug_bitpos(), | |
| 153 | - dec.debug_state().0 | |
| 154 | - ); | |
| 155 | - } | |
| 156 | - if trace { | |
| 157 | - eprintln!("TRACE all_zero ctx={skip_ctx} value={}", all_zero as i32); | |
| 158 | - } | |
| 159 | - if crate::envflags::env_flag!("EC_AV1_EOBPT_CDF") { | |
| 160 | - let (range, value) = dec.debug_state(); | |
| 161 | - eprintln!("EC_AV1_STATE_AFTER_TXBSKIP range={range} value={value}"); | |
| 162 | - } | |
| 163 | 32 | if all_zero { |
| 164 | - // lane-coefgrid: the all-zero unit (60% of the 4K segment's) names the | |
| 165 | - // shared zero grid instead of allocating and zeroing its own. | |
| 166 | - census_unit( | |
| 167 | - census_w, | |
| 168 | - census_h, | |
| 169 | - TxType::DctDct, | |
| 170 | - 0, | |
| 171 | - true, | |
| 172 | - census_entry_rng, | |
| 173 | - dec, | |
| 174 | - ); | |
| 175 | - unit_iv_end(dec, iv_plane, census_w, census_h, skip_ctx); | |
| 176 | 33 | return Ok((Grid::Zero(side * side), TxType::DctDct)); |
| 177 | 34 | } |
| 178 | 35 | let mut grid = vec![0i32; side * side]; |
| @@ -187,47 +44,14 @@ pub(super) fn read_coeffs( | ||
| 187 | 44 | // share their symbol order with (`Tx_Type_Inter_Inv_Set3`'s two |
| 188 | 45 | // members are a prefix of `Tx_Type_Intra_Inv_Set2`'s five). |
| 189 | 46 | let len = tx_type_cdf.len(); |
| 190 | - if crate::envflags::env_flag!("EC_AV1_EOBPT_CDF") && len == 3 { | |
| 191 | - eprintln!("EC_AV1_TXTYPE32_CDF {tx_type_cdf:?}"); | |
| 192 | - } | |
| 193 | - crate::msac::SymbolDecoder::set_symr_cdf("tx_type"); | |
| 194 | 47 | let t = dec.symbol(tx_type_cdf); |
| 195 | - crate::census::tx_type(len, t); | |
| 196 | - if coeff_trace_on() { | |
| 197 | - let (rng, _) = dec.debug_state(); | |
| 198 | - eprintln!("EC_COEFF_STEP tag=tx_type len={len} rng={rng}"); | |
| 199 | - } | |
| 200 | - if crate::envflags::env_flag!("EC_AV1_EOBPT_CDF") { | |
| 201 | - let (range, value) = dec.debug_state(); | |
| 202 | - eprintln!("EC_AV1_STATE_AFTER_TXTYPE range={range} value={value}"); | |
| 203 | - } | |
| 204 | - if trace { | |
| 205 | - eprintln!("TRACE tx_type value={t} len={len}"); | |
| 206 | - } | |
| 207 | 48 | tx_type = tx_type_from_symbol(len, t).ok_or_else(|| { |
| 208 | 49 | unsupported(format!("a tx_type symbol outside its CDF's own set: {t}")) |
| 209 | 50 | })?; |
| 210 | 51 | } |
| 211 | 52 | |
| 212 | 53 | let class = TxClass::of(tx_type); |
| 213 | - if class != TxClass::TwoD { | |
| 214 | - hit!(TX_CLASS1_HITS); | |
| 215 | - hit!(RECT_CLASS1_HITS); | |
| 216 | - } | |
| 217 | 54 | let eob = read_eob(dec, coding, class); |
| 218 | - if trace { | |
| 219 | - eprintln!("TRACE eob value={eob}"); | |
| 220 | - } | |
| 221 | - let ec_trace_coeff = coeff_trace_on(); | |
| 222 | - if ec_trace_coeff { | |
| 223 | - let (rng, _) = dec.debug_state(); | |
| 224 | - let cls = match class { | |
| 225 | - TxClass::TwoD => "2d", | |
| 226 | - TxClass::Horiz => "horiz", | |
| 227 | - TxClass::Vert => "vert", | |
| 228 | - }; | |
| 229 | - eprintln!("EC_COEFF_STEP tag=eob eob={eob} tx={tx_type:?} class={cls} rng={rng}"); | |
| 230 | - } | |
| 231 | 55 | let class_scan; |
| 232 | 56 | let scan: &[u16] = if class == TxClass::TwoD { |
| 233 | 57 | scan |
| @@ -268,9 +92,6 @@ pub(super) fn read_coeffs( | ||
| 268 | 92 | let level = if scan_idx == eob - 1 { |
| 269 | 93 | let ctx = eob_coeff_ctx(scan_idx, side * side); |
| 270 | 94 | let v = dec.symbol(&mut coding.base_eob[ctx]) as i32 + 1; |
| 271 | - if trace { | |
| 272 | - trace_base_eob(scan_idx, pos, row, col, ctx, v); | |
| 273 | - } | |
| 274 | 95 | v |
| 275 | 96 | } else { |
| 276 | 97 | let ctx = if class == TxClass::TwoD && rect_shape.is_none() { |
| @@ -284,14 +105,6 @@ pub(super) fn read_coeffs( | ||
| 284 | 105 | base_ctx(levels, stride, row, col, class, rect_shape) |
| 285 | 106 | }; |
| 286 | 107 | let v = dec.symbol(&mut coding.base[ctx]) as i32; |
| 287 | - if ec_trace_coeff { | |
| 288 | - // `pos` in libaom's column-major `coeff_idx` convention, so | |
| 289 | - // the ladder lines up with instrumented `aomdec`. | |
| 290 | - coeff_step_base(dec, scan_idx, col * side + row, ctx, v); | |
| 291 | - } | |
| 292 | - if trace { | |
| 293 | - trace_base(scan_idx, pos, row, col, ctx, v); | |
| 294 | - } | |
| 295 | 108 | v |
| 296 | 109 | }; |
| 297 | 110 | let level = if level > NUM_BASE_LEVELS { |
| @@ -312,16 +125,6 @@ pub(super) fn read_coeffs( | ||
| 312 | 125 | let mut sent = 0; |
| 313 | 126 | loop { |
| 314 | 127 | let k = dec.symbol(&mut coding.br[ctx]) as i32; |
| 315 | - if ec_trace_coeff { | |
| 316 | - // lane-leaf8tx r3: the `br` rung was missing from THIS | |
| 317 | - // path's trace, so the cross-decoder range ladder was | |
| 318 | - // blind to every base-range symbol and mis-reported the | |
| 319 | - // first divergence (class [[gate-blind-to-feature]]). | |
| 320 | - coeff_step_br(dec, scan_idx, col * side + row, ctx, k); | |
| 321 | - } | |
| 322 | - if trace { | |
| 323 | - trace_br(scan_idx, pos, row, col, ctx, k); | |
| 324 | - } | |
| 325 | 128 | level += k; |
| 326 | 129 | sent += BR_STEP; |
| 327 | 130 | if k < BR_STEP || sent >= COEFF_BASE_RANGE { |
| @@ -332,9 +135,6 @@ pub(super) fn read_coeffs( | ||
| 332 | 135 | } else { |
| 333 | 136 | level |
| 334 | 137 | }; |
| 335 | - if ec_trace_coeff && scan_idx == eob - 1 { | |
| 336 | - coeff_step_base_eob_level(dec, level); | |
| 337 | - } | |
| 338 | 138 | // Every coded level here is a magnitude in `0..=15` (base <= 3 plus |
| 339 | 139 | // at most `COEFF_BASE_RANGE` from the `br` loop; the Golomb tail is |
| 340 | 140 | // added in the sign pass below, straight into `grid`), so the context |
| @@ -347,10 +147,6 @@ pub(super) fn read_coeffs( | ||
| 347 | 147 | nz_n += 1; |
| 348 | 148 | } |
| 349 | 149 | } |
| 350 | - if ec_trace_coeff { | |
| 351 | - let (rng, _) = dec.debug_state(); | |
| 352 | - eprintln!("EC_COEFF_STEP tag=after_bases rng={rng}"); | |
| 353 | - } | |
| 354 | 150 | |
| 355 | 151 | for &packed in nz_buf[..nz_n].iter().rev() { |
| 356 | 152 | let c = (packed >> 4) as usize; |
| @@ -358,40 +154,18 @@ pub(super) fn read_coeffs( | ||
| 358 | 154 | let level = (packed & 15) as i32; |
| 359 | 155 | let negative = if pos == 0 { |
| 360 | 156 | let v = dec.symbol(&mut coding.dc_sign[sign_ctx]) == 1; |
| 361 | - if trace { | |
| 362 | - eprintln!("TRACE dc_sign ctx={sign_ctx} value={}", v as i32); | |
| 363 | - } | |
| 364 | 157 | v |
| 365 | 158 | } else { |
| 366 | 159 | dec.literal(1) == 1 |
| 367 | 160 | }; |
| 368 | - if ec_trace_coeff { | |
| 369 | - coeff_step_sign(dec, c, negative); | |
| 370 | - } | |
| 371 | 161 | let level = if level > MAX_BR_LEVEL { |
| 372 | 162 | let g = read_golomb(dec)?; |
| 373 | - if trace { | |
| 374 | - eprintln!("TRACE golomb pos={pos} value={g}"); | |
| 375 | - } | |
| 376 | 163 | level + g as i32 |
| 377 | 164 | } else { |
| 378 | 165 | level |
| 379 | 166 | }; |
| 380 | - if ec_trace_coeff { | |
| 381 | - coeff_step_post_golomb(dec, c, level); | |
| 382 | - } | |
| 383 | 167 | grid[pos] = if negative { -level } else { level }; |
| 384 | 168 | } |
| 385 | - census_unit( | |
| 386 | - census_w, | |
| 387 | - census_h, | |
| 388 | - tx_type, | |
| 389 | - eob, | |
| 390 | - false, | |
| 391 | - census_entry_rng, | |
| 392 | - dec, | |
| 393 | - ); | |
| 394 | - unit_iv_end(dec, iv_plane, census_w, census_h, skip_ctx); | |
| 395 | 169 | Ok((Grid::Own(grid), tx_type)) |
| 396 | 170 | } |
| 397 | 171 | |
| @@ -419,54 +193,12 @@ pub(super) fn read_coeffs_rect( | ||
| 419 | 193 | skip_ctx: usize, |
| 420 | 194 | sign_ctx: usize, |
| 421 | 195 | default_tx_type: TxType, |
| 422 | - // lane-av1chrtx: the plane this unit belongs to (0 luma, 1 U, 2 V) -- | |
| 423 | - // printed by the two `EC_COEFF_STEP` traces below, which hardcoded | |
| 424 | - // `plane=0` and so mis-attributed a CHROMA read as a luma one in two | |
| 425 | - // independent lane reports. | |
| 426 | - plane: usize, | |
| 427 | 196 | ) -> Result<(Grid, TxType)> { |
| 428 | - let rect_trace = coeff_trace_on(); | |
| 429 | - let entry_rng = dec.debug_state().0; | |
| 430 | - // lane-av1readcensus: this reader is handed the real plane (lane-av1chrtx | |
| 431 | - // threaded it in for the `EC_COEFF_STEP` traces), so it stamps the census | |
| 432 | - // plane itself rather than inheriting whichever reader did last. The | |
| 433 | - // luma-only readers (`decode_rect_split`, `decode_block_rect64`, | |
| 434 | - // `read_inter_plane_rect`'s corner) are all plane 0 -- the stamp's initial | |
| 435 | - // value -- and the other plane-owning readers stamp on entry. | |
| 436 | - set_census_plane(plane); | |
| 437 | - let ibctx_on = crate::envflags::env_flag!("EC_IBCTX"); | |
| 438 | - let entry_bit = if ibctx_on { dec.debug_bitpos() } else { 0 }; | |
| 439 | - let iv_bit = unit_iv_in(plane, w, h, skip_ctx, dec); | |
| 440 | 197 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; |
| 441 | - unit_iv_skip(dec, iv_bit, plane, w, h, skip_ctx, all_zero); | |
| 442 | - if rect_trace { | |
| 443 | - eprintln!( | |
| 444 | - "EC_COEFF_STEP tag=all_zero plane={plane} ctx={skip_ctx} entry={entry_rng} all_zero={} rng={} bit={entry_bit} post_bit={}", | |
| 445 | - all_zero as i32, | |
| 446 | - dec.debug_state().0, | |
| 447 | - dec.debug_bitpos() | |
| 448 | - ); | |
| 449 | - } | |
| 450 | - if ibctx_on { | |
| 451 | - // lane-ibc444c. `bit`/`post_bit` are the STREAM POSITION, not the coder | |
| 452 | - // range: the only collision-free key for pairing this unit against the | |
| 453 | - // oracle's `EC_ECDUMP_IN`. And `post_bit != bit` is how a caller tells | |
| 454 | - // a real symbol read from a 0-bit one -- the SQUARE reader logs a step | |
| 455 | - // either way, which is exactly the artifact that made an earlier | |
| 456 | - // round of this lane claim a false exactness. | |
| 457 | - eprintln!( | |
| 458 | - "EC_IBCTX w={w} h={h} skip_ctx={skip_ctx} sign_ctx={sign_ctx} bit={entry_bit} post_bit={} at {}", | |
| 459 | - dec.debug_bitpos(), | |
| 460 | - std::panic::Location::caller(), | |
| 461 | - ); | |
| 462 | - } | |
| 463 | 198 | if all_zero { |
| 464 | - census_unit(w, h, TxType::DctDct, 0, true, entry_rng, dec); | |
| 465 | - unit_iv_end(dec, plane, w, h, skip_ctx); | |
| 466 | 199 | return Ok((Grid::Zero(w * h), TxType::DctDct)); |
| 467 | 200 | } |
| 468 | 201 | let mut grid = vec![0i32; w * h]; |
| 469 | - hit!(RECT_COEFF_TU_HITS); | |
| 470 | 202 | // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is |
| 471 | 203 | // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including |
| 472 | 204 | // the `V_DCT`/`H_DCT` members whose 1D tx class needs its own scan and |
| @@ -477,28 +209,12 @@ pub(super) fn read_coeffs_rect( | ||
| 477 | 209 | if let Some(tx_type_cdf) = coding.tx_type.as_deref_mut() { |
| 478 | 210 | let len = tx_type_cdf.len(); |
| 479 | 211 | let t = dec.symbol(tx_type_cdf); |
| 480 | - crate::census::tx_type(len, t); | |
| 481 | 212 | tx_type = tx_type_from_symbol(len, t).ok_or_else(|| { |
| 482 | 213 | unsupported(format!("a tx_type symbol outside its CDF's own set: {t}")) |
| 483 | 214 | })?; |
| 484 | - if rect_trace { | |
| 485 | - eprintln!( | |
| 486 | - "EC_COEFF_STEP tag=tx_type plane={plane} rng={}", | |
| 487 | - dec.debug_state().0 | |
| 488 | - ); | |
| 489 | - } | |
| 490 | 215 | } |
| 491 | 216 | let class = TxClass::of(tx_type); |
| 492 | - if class != TxClass::TwoD { | |
| 493 | - hit!(TX_CLASS1_HITS); | |
| 494 | - } | |
| 495 | 217 | let eob = read_eob(dec, coding, class); |
| 496 | - if rect_trace { | |
| 497 | - eprintln!( | |
| 498 | - "EC_COEFF_STEP tag=eob eob={eob} rng={}", | |
| 499 | - dec.debug_state().0 | |
| 500 | - ); | |
| 501 | - } | |
| 502 | 218 | let class_scan; |
| 503 | 219 | let scan: &[u16] = if class == TxClass::TwoD { |
| 504 | 220 | scan |
| @@ -570,12 +286,6 @@ pub(super) fn read_coeffs_rect( | ||
| 570 | 286 | base_ctx_rect(levels, stride, w, h, row, col, class) |
| 571 | 287 | }; |
| 572 | 288 | let v = dec.symbol(&mut coding.base[ctx]) as i32; |
| 573 | - if rect_trace { | |
| 574 | - eprintln!( | |
| 575 | - "EC_COEFF_STEP tag=base c={scan_idx} pos={pos} ctx={ctx} level={v} rng={}", | |
| 576 | - dec.debug_state().0 | |
| 577 | - ); | |
| 578 | - } | |
| 579 | 289 | v |
| 580 | 290 | }; |
| 581 | 291 | let level = if level > NUM_BASE_LEVELS { |
| @@ -596,12 +306,6 @@ pub(super) fn read_coeffs_rect( | ||
| 596 | 306 | let mut sent = 0; |
| 597 | 307 | loop { |
| 598 | 308 | let k = dec.symbol(&mut coding.br[ctx]) as i32; |
| 599 | - if rect_trace { | |
| 600 | - eprintln!( | |
| 601 | - "EC_COEFF_STEP tag=br c={scan_idx} pos={pos} ctx={ctx} k={k} rng={}", | |
| 602 | - dec.debug_state().0 | |
| 603 | - ); | |
| 604 | - } | |
| 605 | 309 | level += k; |
| 606 | 310 | sent += BR_STEP; |
| 607 | 311 | if k < BR_STEP || sent >= COEFF_BASE_RANGE { |
| @@ -618,19 +322,6 @@ pub(super) fn read_coeffs_rect( | ||
| 618 | 322 | nz_buf[nz_n] = ((scan_idx as u16) << 4) | level as u16; |
| 619 | 323 | nz_n += 1; |
| 620 | 324 | } |
| 621 | - if rect_trace && scan_idx == eob - 1 { | |
| 622 | - // the oracle's `tag=base_eob`: POST-br level, POST-br rng, with the | |
| 623 | - // same `get_lower_levels_ctx_eob` ctx (the same `eob_coeff_ctx`). | |
| 624 | - let ctx = eob_coeff_ctx(scan_idx, w * h); | |
| 625 | - let (rng, _) = dec.debug_state(); | |
| 626 | - eprintln!( | |
| 627 | - "EC_COEFF_STEP tag=base_eob c={scan_idx} pos={pos} ctx={ctx} level={level} rng={rng}" | |
| 628 | - ); | |
| 629 | - } | |
| 630 | - } | |
| 631 | - if rect_trace { | |
| 632 | - let (rng, _) = dec.debug_state(); | |
| 633 | - eprintln!("EC_COEFF_STEP tag=after_bases rng={rng}"); | |
| 634 | 325 | } |
| 635 | 326 | for &packed in nz_buf[..nz_n].iter().rev() { |
| 636 | 327 | let pos = scan[(packed >> 4) as usize] as usize; |
| @@ -640,53 +331,18 @@ pub(super) fn read_coeffs_rect( | ||
| 640 | 331 | } else { |
| 641 | 332 | dec.literal(1) == 1 |
| 642 | 333 | }; |
| 643 | - if rect_trace { | |
| 644 | - let (rng, _) = dec.debug_state(); | |
| 645 | - eprintln!( | |
| 646 | - "EC_COEFF_STEP tag=sign_rect pos={pos} sign={} dcctx={sign_ctx} rng={rng}", | |
| 647 | - u8::from(negative) | |
| 648 | - ); | |
| 649 | - } | |
| 650 | 334 | let level = if level > MAX_BR_LEVEL { |
| 651 | 335 | let g = read_golomb(dec)?; |
| 652 | 336 | level + g as i32 |
| 653 | 337 | } else { |
| 654 | 338 | level |
| 655 | 339 | }; |
| 656 | - if rect_trace { | |
| 657 | - // lane-av1oddheightfork2: the twin of the square reader's | |
| 658 | - // `coeff_step_post_golomb`. The oracle's `EC_COEFF_STEP | |
| 659 | - // tag=post_golomb` (decodetxb.c, after read_golomb) fires for a RECT | |
| 660 | - // unit exactly as it does for a square one, but this reader had no | |
| 661 | - // rung for it, so every rect unit's ladder was one step short and | |
| 662 | - // the pairing had to guess whether a golomb had been read. This | |
| 663 | - // rung reads no bits: it prints the state after the read it labels. | |
| 664 | - let (rng, _) = dec.debug_state(); | |
| 665 | - eprintln!( | |
| 666 | - "EC_COEFF_STEP tag=post_golomb c={} pos={pos} level={level} rng={rng}", | |
| 667 | - (packed >> 4) | |
| 668 | - ); | |
| 669 | - } | |
| 670 | 340 | grid[pos] = if negative { -level } else { level }; |
| 671 | 341 | } |
| 672 | 342 | // lane-d792: the rect unit's LEVEL grid in row-major (w) order, the |
| 673 | 343 | // twin of the oracle's `EC_DQCOEFF` rung -- a residual mismatch whose |
| 674 | 344 | // grids differ is a reader defect, one whose grids agree is a transform |
| 675 | 345 | // defect. |
| 676 | - if crate::envflags::env_flag!("EC_DQCOEFF") { | |
| 677 | - let nz: Vec<String> = grid | |
| 678 | - .iter() | |
| 679 | - .enumerate() | |
| 680 | - .filter(|&(_, &v)| v != 0) | |
| 681 | - .map(|(i, &v)| format!("{}/{}:{v}", i / w, i % w)) | |
| 682 | - .collect(); | |
| 683 | - eprintln!( | |
| 684 | - "OUR_LEVELS w={w} h={h} eob={eob} tx={tx_type:?} nz={}", | |
| 685 | - nz.join(",") | |
| 686 | - ); | |
| 687 | - } | |
| 688 | - census_unit(w, h, tx_type, eob, false, entry_rng, dec); | |
| 689 | - unit_iv_end(dec, plane, w, h, skip_ctx); | |
| 690 | 346 | Ok((Grid::Own(grid), tx_type)) |
| 691 | 347 | } |
| 692 | 348 | |
| @@ -718,25 +374,11 @@ pub(super) fn read_chroma_coeffs_rect( | ||
| 718 | 374 | sign_ctx: usize, |
| 719 | 375 | default_tx_type: TxType, |
| 720 | 376 | fctx: &crate::decode::FrameCtx, |
| 721 | - // lane-av1chrtx: the plane index, threaded to `read_coeffs_rect`'s | |
| 722 | - // `EC_COEFF_STEP` traces (they used to print a hardcoded `plane=0`, so a | |
| 723 | - // V-plane read was indistinguishable from a luma one in the log). | |
| 724 | - plane: usize, | |
| 725 | 377 | ) -> Result<(Grid, TxType)> { |
| 726 | 378 | if mono(fctx) { |
| 727 | 379 | return Ok((Grid::Zero(w * h), TxType::DctDct)); |
| 728 | 380 | } |
| 729 | - read_coeffs_rect( | |
| 730 | - dec, | |
| 731 | - coding, | |
| 732 | - scan, | |
| 733 | - w, | |
| 734 | - h, | |
| 735 | - skip_ctx, | |
| 736 | - sign_ctx, | |
| 737 | - default_tx_type, | |
| 738 | - plane, | |
| 739 | - ) | |
| 381 | + read_coeffs_rect(dec, coding, scan, w, h, skip_ctx, sign_ctx, default_tx_type) | |
| 740 | 382 | } |
| 741 | 383 | |
| 742 | 384 | /// What one coded block leaves behind for the blocks that read it as a |
| @@ -1233,7 +875,13 @@ impl Neighbours { | ||
| 1233 | 875 | /// [`SUB`]-grid cell it covers on both the above and left edges -- |
| 1234 | 876 | /// mirrors [`Self::record_rect`]'s loop shape, square-only (this lane's |
| 1235 | 877 | /// call sites are all square blocks). |
| 1236 | - pub(super) fn record_palette_y(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) { | |
| 878 | + pub(super) fn record_palette_y( | |
| 879 | + &mut self, | |
| 880 | + at: (usize, usize), | |
| 881 | + side: usize, | |
| 882 | + size: usize, | |
| 883 | + colors: [u16; 8], | |
| 884 | + ) { | |
| 1237 | 885 | self.record_palette_y_rect( |
| 1238 | 886 | (at.0 * (SUB / MI), at.1 * (SUB / MI)), |
| 1239 | 887 | side, |
| @@ -1256,9 +904,6 @@ impl Neighbours { | ||
| 1256 | 904 | colors: [u16; 8], |
| 1257 | 905 | ) { |
| 1258 | 906 | let (r, c) = mi; |
| 1259 | - if crate::envflags::env_flag!("EC_PALPUB") { | |
| 1260 | - eprintln!("EC_PALPUB yrect mi={r},{c} bw={w} bh={h} y={size}"); | |
| 1261 | - } | |
| 1262 | 907 | // lane-kf900 r6: mi (4px) granularity, libaom's own -- `palette_size` |
| 1263 | 908 | // lives per mi cell in `MB_MODE_INFO`, and `xd->left_mbmi` is the mi |
| 1264 | 909 | // cell immediately left of the block, not its 16px [`SUB`] cell. The |
| @@ -1633,12 +1278,6 @@ impl Neighbours { | ||
| 1633 | 1278 | // TX_32X32 -- independent of this block's luma `tx_depth`. |
| 1634 | 1279 | let uv_tx_w = ((w_mi * MI) >> ss_x(fctx)).clamp(4, 32) as u8; |
| 1635 | 1280 | let uv_tx_h = ((h_mi * MI) >> ss_y(fctx)).clamp(4, 32) as u8; |
| 1636 | - if crate::envflags::env_flag!("EC_TXGRID_TRACE") { | |
| 1637 | - eprintln!( | |
| 1638 | - "EC_LFGRID mi_row={mi_r} mi_col={mi_c} w_mi={w_mi} h_mi={h_mi} tx_px={tx_px} tx_h_px={tx_h_px}" | |
| 1639 | - ); | |
| 1640 | - } | |
| 1641 | - crate::census::tx(tx_px, tx_h_px); | |
| 1642 | 1281 | let cur = fctx.current_delta_lf.with(|c| c.get()); |
| 1643 | 1282 | let snapshot: [i8; 4] = if fctx.delta_lf_multi.with(|c| c.get()) { |
| 1644 | 1283 | std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8) |
| @@ -1727,11 +1366,6 @@ impl Neighbours { | ||
| 1727 | 1366 | tx_h_px: u8, |
| 1728 | 1367 | ) { |
| 1729 | 1368 | let (mi_r, mi_c) = at_mi; |
| 1730 | - if crate::envflags::env_flag!("EC_TXGRID_TRACE") { | |
| 1731 | - eprintln!( | |
| 1732 | - "EC_LFLEAF mi_row={mi_r} mi_col={mi_c} w_mi={w_mi} h_mi={h_mi} tx_px={tx_px} tx_h_px={tx_h_px}" | |
| 1733 | - ); | |
| 1734 | - } | |
| 1735 | 1369 | for rr in 0..h_mi { |
| 1736 | 1370 | let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c; |
| 1737 | 1371 | fill_span(&mut self.tx_grid, start, w_mi, tx_px); |
| @@ -1748,14 +1382,14 @@ impl Neighbours { | ||
| 1748 | 1382 | } |
| 1749 | 1383 | |
| 1750 | 1384 | /// [`Self::fill_skip_grid`] with independent row/col extents (lane-partitions r1). |
| 1751 | - pub(super) fn fill_skip_grid_rect(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize, skip: bool) { | |
| 1385 | + pub(super) fn fill_skip_grid_rect( | |
| 1386 | + &mut self, | |
| 1387 | + at_mi: (usize, usize), | |
| 1388 | + w_mi: usize, | |
| 1389 | + h_mi: usize, | |
| 1390 | + skip: bool, | |
| 1391 | + ) { | |
| 1752 | 1392 | let (mi_r, mi_c) = at_mi; |
| 1753 | - if skip && w_mi != h_mi { | |
| 1754 | - hit!(RECT_SKIP_BAND_HITS); | |
| 1755 | - } | |
| 1756 | - // lane-census: an INTRA frame's blocks never reach the inter | |
| 1757 | - // publisher, and this one is what every coded block writes. | |
| 1758 | - crate::census::block_intra_frame(w_mi, h_mi, skip); | |
| 1759 | 1393 | for rr in 0..h_mi { |
| 1760 | 1394 | let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c; |
| 1761 | 1395 | fill_span( |
| @@ -1907,7 +1541,8 @@ impl Neighbours { | ||
| 1907 | 1541 | /// "no neighbour"). `ref_frame` is `-1` for an intra block, else the |
| 1908 | 1542 | /// `1..=7` reference it coded (lane-av1refs's `single_ref_p*_ctx` needs |
| 1909 | 1543 | /// the real value, not just `is_inter`). |
| 1910 | - #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1544 | + #[allow(dead_code)] | |
| 1545 | + // read only from the `#[cfg(test)]` gates | |
| 1911 | 1546 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. |
| 1912 | 1547 | #[allow(clippy::too_many_arguments)] |
| 1913 | 1548 | pub(super) fn record_inter( |
| @@ -1971,7 +1606,6 @@ impl Neighbours { | ||
| 1971 | 1606 | skip_mode: bool, |
| 1972 | 1607 | ) { |
| 1973 | 1608 | let (r, c) = at_mi; |
| 1974 | - crate::census::block(w_mi, h_mi, is_inter, ref_frame, skip); | |
| 1975 | 1609 | // lane-t900 r8 (class new-map-ignores-tile-edge's twin: a map NOBODY |
| 1976 | 1610 | // writes for a whole block class): an INTER block left the luma mode |
| 1977 | 1611 | // map untouched, so a later intra block's `get_intra_edge_filter_type` |
| @@ -2077,7 +1711,6 @@ impl Neighbours { | ||
| 2077 | 1711 | compound_idx: u8, |
| 2078 | 1712 | ) { |
| 2079 | 1713 | let (r, c) = at_mi; |
| 2080 | - crate::census::compound(); | |
| 2081 | 1714 | for cell in 0..w_mi { |
| 2082 | 1715 | self.above_ref1[c + cell] = Some(ref1); |
| 2083 | 1716 | self.above_comp_group_idx[c + cell] = comp_group_idx; |
| @@ -2118,7 +1751,11 @@ impl Neighbours { | ||
| 2118 | 1751 | |
| 2119 | 1752 | /// [`Self::around`] taking the block's position directly in 4x4 mode-info |
| 2120 | 1753 | /// units, for the same reason [`Self::record_mi`] does. |
| 2121 | - pub(super) fn around_mi(&self, (mi_r, mi_c): (usize, usize), side: usize) -> [(bool, bool, i32); 3] { | |
| 1754 | + pub(super) fn around_mi( | |
| 1755 | + &self, | |
| 1756 | + (mi_r, mi_c): (usize, usize), | |
| 1757 | + side: usize, | |
| 1758 | + ) -> [(bool, bool, i32); 3] { | |
| 2122 | 1759 | let side_mi = side / MI; |
| 2123 | 1760 | // One pass over the cells accumulating all three planes, not one pass |
| 2124 | 1761 | // per plane: the three planes of a cell live in the same |
| @@ -2183,45 +1820,18 @@ impl Neighbours { | ||
| 2183 | 1820 | o.2 += dc_vote(left[plane].dc); |
| 2184 | 1821 | } |
| 2185 | 1822 | } |
| 2186 | - if crate::envflags::env_flag!("EC_DCDUMP") { | |
| 2187 | - // lane-av1422mi24: same dump [`Self::around_mi_rect`] prints, so | |
| 2188 | - // a rerouted 4:2:2 chroma gather stays visible under EC_DCDUMP=1. | |
| 2189 | - // The above rows are the SAMPLED (every-second) cells. | |
| 2190 | - for (plane, o) in out.iter().enumerate() { | |
| 2191 | - let vote = o.2; | |
| 2192 | - let ab: Vec<String> = (0..above_mi) | |
| 2193 | - .step_by(2) | |
| 2194 | - .map(|k| { | |
| 2195 | - format!( | |
| 2196 | - "{:?}/{}", | |
| 2197 | - self.above[mi_c + k][plane].dc, | |
| 2198 | - self.above[mi_c + k][plane].level | |
| 2199 | - ) | |
| 2200 | - }) | |
| 2201 | - .collect(); | |
| 2202 | - let lf: Vec<String> = (0..left_mi) | |
| 2203 | - .map(|k| { | |
| 2204 | - format!( | |
| 2205 | - "{:?}/{}", | |
| 2206 | - self.left[mi_r + k][plane].dc, | |
| 2207 | - self.left[mi_r + k][plane].level | |
| 2208 | - ) | |
| 2209 | - }) | |
| 2210 | - .collect(); | |
| 2211 | - eprintln!( | |
| 2212 | - "EC_DCDUMP422 mi=({mi_r},{mi_c}) plane={plane} wh=({w},{h}) vote={vote} above=[{}] left=[{}]", | |
| 2213 | - ab.join(","), | |
| 2214 | - lf.join(",") | |
| 2215 | - ); | |
| 2216 | - } | |
| 2217 | - } | |
| 2218 | 1823 | out |
| 2219 | 1824 | } |
| 2220 | 1825 | |
| 2221 | 1826 | /// [`Self::around`] with independent above (`w`)/left (`h`) extents, in |
| 2222 | 1827 | /// pixels -- lane-rectwire, mirrors [`Self::record_rect`]'s asymmetric |
| 2223 | 1828 | /// extent pattern for a true rectangular strip's own coefficient context. |
| 2224 | - pub(super) fn around_rect(&self, (r, c): (usize, usize), w: usize, h: usize) -> [(bool, bool, i32); 3] { | |
| 1829 | + pub(super) fn around_rect( | |
| 1830 | + &self, | |
| 1831 | + (r, c): (usize, usize), | |
| 1832 | + w: usize, | |
| 1833 | + h: usize, | |
| 1834 | + ) -> [(bool, bool, i32); 3] { | |
| 2225 | 1835 | self.around_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h) |
| 2226 | 1836 | } |
| 2227 | 1837 | |
| @@ -2252,34 +1862,6 @@ impl Neighbours { | ||
| 2252 | 1862 | o.2 += dc_vote(left[plane].dc); |
| 2253 | 1863 | } |
| 2254 | 1864 | } |
| 2255 | - if crate::envflags::env_flag!("EC_DCDUMP") { | |
| 2256 | - for (plane, o) in out.iter().enumerate() { | |
| 2257 | - let vote = o.2; | |
| 2258 | - let ab: Vec<String> = (0..above_mi) | |
| 2259 | - .map(|k| { | |
| 2260 | - format!( | |
| 2261 | - "{:?}/{}", | |
| 2262 | - self.above[mi_c + k][plane].dc, | |
| 2263 | - self.above[mi_c + k][plane].level | |
| 2264 | - ) | |
| 2265 | - }) | |
| 2266 | - .collect(); | |
| 2267 | - let lf: Vec<String> = (0..left_mi) | |
| 2268 | - .map(|k| { | |
| 2269 | - format!( | |
| 2270 | - "{:?}/{}", | |
| 2271 | - self.left[mi_r + k][plane].dc, | |
| 2272 | - self.left[mi_r + k][plane].level | |
| 2273 | - ) | |
| 2274 | - }) | |
| 2275 | - .collect(); | |
| 2276 | - eprintln!( | |
| 2277 | - "EC_DCDUMP mi=({mi_r},{mi_c}) plane={plane} wh=({w},{h}) vote={vote} above=[{}] left=[{}]", | |
| 2278 | - ab.join(","), | |
| 2279 | - lf.join(",") | |
| 2280 | - ); | |
| 2281 | - } | |
| 2282 | - } | |
| 2283 | 1865 | out |
| 2284 | 1866 | } |
| 2285 | 1867 | |
| @@ -2297,8 +1879,12 @@ impl Neighbours { | ||
| 2297 | 1879 | /// [`Self::luma_skip_ctx`] with the unit's own width and height in mi |
| 2298 | 1880 | /// units (lane-rectsplitx r1) -- `get_txb_ctx_general` ORs the above |
| 2299 | 1881 | /// context over `tx_size_wide` and the left one over `tx_size_high`. |
| 2300 | - pub(super) fn luma_skip_ctx_rect(&self, (mi_r, mi_c): (usize, usize), w_mi: usize, h_mi: usize) -> usize { | |
| 2301 | - let side_mi = w_mi; | |
| 1882 | + pub(super) fn luma_skip_ctx_rect( | |
| 1883 | + &self, | |
| 1884 | + (mi_r, mi_c): (usize, usize), | |
| 1885 | + w_mi: usize, | |
| 1886 | + h_mi: usize, | |
| 1887 | + ) -> usize { | |
| 2302 | 1888 | let above_mi = w_mi.min(self.mi_cols.saturating_sub(mi_c)); |
| 2303 | 1889 | let left_mi = h_mi.min(self.mi_rows.saturating_sub(mi_r)); |
| 2304 | 1890 | let mut top = 0u8; |
| @@ -2310,35 +1896,6 @@ impl Neighbours { | ||
| 2310 | 1896 | left |= self.left[mi_r + cell][0].level; |
| 2311 | 1897 | } |
| 2312 | 1898 | let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)]; |
| 2313 | - if crate::envflags::env_flag!("EC_ECDUMP") { | |
| 2314 | - let ab: Vec<String> = (0..above_mi) | |
| 2315 | - .map(|k| self.above[mi_c + k][0].level.to_string()) | |
| 2316 | - .collect(); | |
| 2317 | - let lf: Vec<String> = (0..left_mi) | |
| 2318 | - .map(|k| self.left[mi_r + k][0].level.to_string()) | |
| 2319 | - .collect(); | |
| 2320 | - // lane-av1mix: the last few msac register states, so the | |
| 2321 | - // byte-position of the `all_zero` read can be matched against | |
| 2322 | - // aomdec's `EC=(value,rng,bytepos)` dump (decodetxb.c) without a | |
| 2323 | - // second run. | |
| 2324 | - let recent = crate::msac::symtrace::ecdump_recent(4) | |
| 2325 | - .iter() | |
| 2326 | - .map(|(_low, value, rng, bytepos)| format!("({value},{rng},{bytepos})")) | |
| 2327 | - .collect::<Vec<_>>() | |
| 2328 | - .join(" "); | |
| 2329 | - eprintln!( | |
| 2330 | - "EC_ECDUMP plane=0 mi=({mi_r},{mi_c}) wh=({w_mi},{h_mi}) ctx={ctx} above=[{},] left=[{},] recentEC=[{}]", | |
| 2331 | - ab.join(","), | |
| 2332 | - lf.join(","), | |
| 2333 | - recent | |
| 2334 | - ); | |
| 2335 | - } | |
| 2336 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 2337 | - eprintln!( | |
| 2338 | - "TRACE luma_skip_ctx mi=({mi_r},{mi_c}) side_mi={side_mi} top={top} left={left} ctx={ctx} band={:?}", | |
| 2339 | - self.left.iter().map(|e| e[0].level).collect::<Vec<_>>() | |
| 2340 | - ); | |
| 2341 | - } | |
| 2342 | 1899 | ctx |
| 2343 | 1900 | } |
| 2344 | 1901 | |
| @@ -2373,7 +1930,14 @@ impl Neighbours { | ||
| 2373 | 1930 | /// block to the right reads via `mi(row, col-1)`). Only sub-8x8 leaves |
| 2374 | 1931 | /// read these back, and only when the recorded position is exactly their |
| 2375 | 1932 | /// own neighbour -- see [`Self::sub8_mode_col`]'s doc. |
| 2376 | - pub(super) fn record_mode_mi(&mut self, mi_r: usize, mi_c: usize, mi_w: usize, mi_h: usize, mode: usize) { | |
| 1933 | + pub(super) fn record_mode_mi( | |
| 1934 | + &mut self, | |
| 1935 | + mi_r: usize, | |
| 1936 | + mi_c: usize, | |
| 1937 | + mi_w: usize, | |
| 1938 | + mi_h: usize, | |
| 1939 | + mode: usize, | |
| 1940 | + ) { | |
| 2377 | 1941 | let (last_r, last_c) = ((mi_r + mi_h - 1) as u16, (mi_c + mi_w - 1) as u16); |
| 2378 | 1942 | let mode = mode as u8; |
| 2379 | 1943 | for cell in 0..mi_w { |
| @@ -2451,9 +2015,6 @@ impl Neighbours { | ||
| 2451 | 2015 | for row in mi_r..=last_r { |
| 2452 | 2016 | fill_span(&mut self.uv_owner, row * stride + mi_c, n, owner); |
| 2453 | 2017 | } |
| 2454 | - if crate::envflags::env_flag!("EC_LEFTSSY") { | |
| 2455 | - eprintln!("EC_LEAF mi=({mi_r},{mi_c}) wh=({mi_w},{mi_h}) uv_mode={uv_mode}"); | |
| 2456 | - } | |
| 2457 | 2018 | } |
| 2458 | 2019 | |
| 2459 | 2020 | /// Whether either mi-exact chroma neighbour of the block at `(mi_r, mi_c)` |
| @@ -2503,7 +2064,6 @@ impl Neighbours { | ||
| 2503 | 2064 | c, |
| 2504 | 2065 | ss_x(fctx), |
| 2505 | 2066 | ss_y(fctx), |
| 2506 | - true, | |
| 2507 | 2067 | ) |
| 2508 | 2068 | } |
| 2509 | 2069 | |
| @@ -2512,18 +2072,6 @@ impl Neighbours { | ||
| 2512 | 2072 | /// counter wants this: it measures how often the snap CHANGES the answer, |
| 2513 | 2073 | /// which is what the lane-kf1200/kf900 chroma-reference fix buys. Every |
| 2514 | 2074 | /// decode path uses the snapping form. |
| 2515 | - /// `decode_path` is `true` only for the snapping form every decode call | |
| 2516 | - /// site uses; the 16x4/4x16 pair witness's mirror passes `false`, so the | |
| 2517 | - /// `+ss_y` counters measure a read that actually filters a chroma edge and | |
| 2518 | - /// not the counter-only one. | |
| 2519 | - /// | |
| 2520 | - /// lane-av1leftwit: the mirror's justification used to be "no committed | |
| 2521 | - /// fixture reaches the shape on the decode path", and that was false -- | |
| 2522 | - /// `UV_LEFT_1MI_SPLIT_HITS` fires on five of them. The flag stays (a | |
| 2523 | - /// counter-only mirror at an ODD mi row is still not a decode-path read, | |
| 2524 | - /// and its result feeds only `RECT4_16_UV_PAIR_FILT_HITS`), but it is no | |
| 2525 | - /// longer evidence about the `+ss_y` term, and nothing may cite it as such. | |
| 2526 | - /// The decode path's own reach is `uv_left_1mi_split_hits()`. | |
| 2527 | 2075 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. |
| 2528 | 2076 | #[allow(clippy::too_many_arguments)] |
| 2529 | 2077 | pub(super) fn smooth_uv_neighbour_unsnapped( |
| @@ -2534,7 +2082,6 @@ impl Neighbours { | ||
| 2534 | 2082 | c: usize, |
| 2535 | 2083 | ss_x: usize, |
| 2536 | 2084 | ss_y: usize, |
| 2537 | - decode_path: bool, | |
| 2538 | 2085 | ) -> bool { |
| 2539 | 2086 | // lane-mtfix r1: availability is TILE-relative on BOTH axes and on the |
| 2540 | 2087 | // coarse fallback too. `above_uv_mode` is a frame-wide [`SUB`]-grid |
| @@ -2545,11 +2092,6 @@ impl Neighbours { | ||
| 2545 | 2092 | // at chroma (120, 32), the top-right tile's first block). |
| 2546 | 2093 | let have_above = mi_r > self.tile_row0_mi; |
| 2547 | 2094 | let have_left = mi_c > self.tile_col0_mi; |
| 2548 | - if self.tile_row0_mi > 0 && !have_above && self.above_uv_mode[c] != DC_PRED | |
| 2549 | - || self.tile_col0_mi > 0 && !have_left && self.left_uv_mode[r] != DC_PRED | |
| 2550 | - { | |
| 2551 | - hit!(UV_TILE_EDGE_SUPPRESSED_HITS); | |
| 2552 | - } | |
| 2553 | 2095 | // The mi grid is libaom's own read; the two maps below stay as the |
| 2554 | 2096 | // fallback for cells no block has written (see [`Self::uv_mode_grid`]). |
| 2555 | 2097 | let cell = |grid: &Vec<u8>, row: usize, col: usize| -> Option<usize> { |
| @@ -2637,67 +2179,6 @@ impl Neighbours { | ||
| 2637 | 2179 | // every committed fixture and every one of the ~1000 encodes swept in |
| 2638 | 2180 | // `lanes/av1leftref.report.md`, which is what makes the read change a |
| 2639 | 2181 | // proven no-op on today's material rather than an unmeasured guess. |
| 2640 | - if decode_path && have_left && ss_y > 0 { | |
| 2641 | - hit!(UV_LEFT_SS_Y_READS); | |
| 2642 | - // The pre-lane read, kept as the counter's own-row arm: it is what | |
| 2643 | - // this decoder answered before the `+ss_y` term landed, and | |
| 2644 | - // comparing against it is what proves the term is load-bearing. | |
| 2645 | - let own_row = read_left(mi_r); | |
| 2646 | - if own_row != left { | |
| 2647 | - hit!(UV_LEFT_SS_Y_MODE_DIFF_HITS); | |
| 2648 | - } | |
| 2649 | - if is_smooth_mode(own_row) != is_smooth_mode(left) { | |
| 2650 | - hit!(UV_LEFT_SS_Y_SMOOTH_DIFF_HITS); | |
| 2651 | - } | |
| 2652 | - // lane-av1leftwit: the geometry the `+ss_y` term needs. The two | |
| 2653 | - // cells are one left mi column apart, so they are two different | |
| 2654 | - // blocks exactly when the left neighbour is 1 mi tall or shorter. | |
| 2655 | - let col = left_mi.1; | |
| 2656 | - let epoch = UV_OWNER_EPOCH.with(|c| c.get()) & 0xff00_0000; | |
| 2657 | - let own = (col < self.uv_grid_cols) | |
| 2658 | - .then(|| self.uv_owner.get(mi_r * self.uv_grid_cols + col).copied()) | |
| 2659 | - .flatten() | |
| 2660 | - .filter(|o| o & 0xff00_0000 == epoch) | |
| 2661 | - .unwrap_or(0); | |
| 2662 | - let down = self | |
| 2663 | - .uv_owner | |
| 2664 | - .get((mi_r + ss_y) * self.uv_grid_cols + col) | |
| 2665 | - .copied() | |
| 2666 | - .filter(|o| o & 0xff00_0000 == epoch) | |
| 2667 | - .unwrap_or(0); | |
| 2668 | - if own != 0 && down != 0 && own != down { | |
| 2669 | - hit!(UV_LEFT_1MI_SPLIT_HITS); | |
| 2670 | - if crate::envflags::env_flag!("EC_LEFTSSY") { | |
| 2671 | - eprintln!( | |
| 2672 | - "EC_LEFTSSY epoch={} mi=({mi_r},{mi_c}) left_col={col} \ | |
| 2673 | - owners=({},{})->({},{}) modes={own_row}/{left}", | |
| 2674 | - epoch >> 24, | |
| 2675 | - own >> 12 & 0xfff, | |
| 2676 | - own & 0xfff, | |
| 2677 | - down >> 12 & 0xfff, | |
| 2678 | - down & 0xfff, | |
| 2679 | - ); | |
| 2680 | - } | |
| 2681 | - } | |
| 2682 | - } | |
| 2683 | - if have_above && cell(&self.uv_mode_grid, mi_r - 1, mi_c).is_some_and(|m| { | |
| 2684 | - !matches!(self.uv_mode_col.get(mi_c), Some(&(row, cm)) if usize::from(row) == mi_r - 1 && usize::from(cm) == m) | |
| 2685 | - }) || have_left && cell(&self.uv_mode_grid, left_mi.0, left_mi.1).is_some_and(|m| { | |
| 2686 | - !matches!(self.uv_mode_row.get(left_mi.0), Some(&(col, cm)) if usize::from(col) == left_mi.1 && usize::from(cm) == m) | |
| 2687 | - }) { | |
| 2688 | - hit!(UV_MODE_GRID_OVERRIDE_HITS); | |
| 2689 | - } | |
| 2690 | - // lane-cfl r1 counter: how often the mi-exact chroma neighbour differs | |
| 2691 | - // from the coarse [`SUB`] slot -- i.e. how often a chroma edge would | |
| 2692 | - // have been filtered at the wrong strength by the coarse map alone. | |
| 2693 | - if above != self.above_uv_mode[c] || left != self.left_uv_mode[r] { | |
| 2694 | - hit!(UV_MODE_MI_OVERRIDE_HITS); | |
| 2695 | - } | |
| 2696 | - if (is_smooth_mode(self.above_uv_mode[c]) && !is_smooth_mode(above)) | |
| 2697 | - || (is_smooth_mode(self.left_uv_mode[r]) && !is_smooth_mode(left)) | |
| 2698 | - { | |
| 2699 | - hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS); | |
| 2700 | - } | |
| 2701 | 2182 | is_smooth_mode(above) || is_smooth_mode(left) |
| 2702 | 2183 | } |
| 2703 | 2184 | |
| @@ -2750,21 +2231,6 @@ impl Neighbours { | ||
| 2750 | 2231 | let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); |
| 2751 | 2232 | let (above, left) = |
| 2752 | 2233 | self.modes_above_left_mi(mi_r, mi_c, (self.above_mode[c], self.left_mode[r])); |
| 2753 | - if above != self.above_mode[c] || left != self.left_mode[r] { | |
| 2754 | - hit!(MODE_MI_OVERRIDE_HITS); | |
| 2755 | - } | |
| 2756 | - if (is_smooth_mode(self.above_mode[c]) && !is_smooth_mode(above)) | |
| 2757 | - || (is_smooth_mode(self.left_mode[r]) && !is_smooth_mode(left)) | |
| 2758 | - { | |
| 2759 | - hit!(INTER_NEIGHBOUR_NOT_SMOOTH_HITS); | |
| 2760 | - } | |
| 2761 | - // A neighbour the coarse band offered where the tile edge makes it | |
| 2762 | - // unavailable -- must never happen (see `MODE_TILE_EDGE_COARSE_LEAKS`). | |
| 2763 | - if (mi_r <= self.tile_row0_mi && self.above_mode[c] != DC_PRED) | |
| 2764 | - || (mi_c <= self.tile_col0_mi && self.left_mode[r] != DC_PRED) | |
| 2765 | - { | |
| 2766 | - hit!(MODE_TILE_EDGE_COARSE_LEAKS); | |
| 2767 | - } | |
| 2768 | 2234 | (above, left) |
| 2769 | 2235 | } |
| 2770 | 2236 | |
| @@ -2864,16 +2330,16 @@ impl Neighbours { | ||
| 2864 | 2330 | |
| 2865 | 2331 | /// [`Self::record_mi`] with independent above (`w`)/left (`h`) extents, |
| 2866 | 2332 | /// in pixels (lane-partitions r1, mirroring [`Self::record_rect`]). |
| 2867 | - pub(super) fn record_mi_rect(&mut self, at_mi: (usize, usize), w: usize, h: usize, grids: &[&[i32]; 3]) { | |
| 2333 | + pub(super) fn record_mi_rect( | |
| 2334 | + &mut self, | |
| 2335 | + at_mi: (usize, usize), | |
| 2336 | + w: usize, | |
| 2337 | + h: usize, | |
| 2338 | + grids: &[&[i32]; 3], | |
| 2339 | + ) { | |
| 2868 | 2340 | let (mi_r, mi_c) = at_mi; |
| 2869 | 2341 | let states: [Neighbour; 3] = std::array::from_fn(|plane| neighbour_state(grids[plane])); |
| 2870 | 2342 | let (w_mi, h_mi) = (w / MI, h / MI); |
| 2871 | - if crate::envflags::env_flag!("EC_ECPUB") { | |
| 2872 | - eprintln!( | |
| 2873 | - "EC_ECPUB blk mi=({mi_r},{mi_c}) wh=({w},{h}) lvl={}", | |
| 2874 | - states[0].level | |
| 2875 | - ); | |
| 2876 | - } | |
| 2877 | 2343 | fill_span(&mut self.left_side_mi, mi_r, h_mi, h as u8); |
| 2878 | 2344 | fill_span(&mut self.above_side_mi, mi_c, w_mi, w as u8); |
| 2879 | 2345 | // A chroma 4x4 unit straddling the true luma edge is still whole in |
| @@ -2964,27 +2430,10 @@ impl Neighbours { | ||
| 2964 | 2430 | // units rather than in luma mi. |
| 2965 | 2431 | let (step_x, step_y) = (w_px / MI, h_px / MI); |
| 2966 | 2432 | // the flags read the CALLER's origin, before the shadowing align below |
| 2967 | - let (row_mid, col_mid) = (mi_r & (step_y - 1) != 0, mi_c & (step_x - 1) != 0); | |
| 2968 | - if row_mid || col_mid { | |
| 2969 | - CHROMA_MIDCELL_PUB_HITS.with(|c| { | |
| 2970 | - let mut v = c.get(); | |
| 2971 | - v[0] += usize::from(row_mid); | |
| 2972 | - v[1] += usize::from(col_mid); | |
| 2973 | - v[2] += usize::from(row_mid && col_mid); | |
| 2974 | - c.set(v); | |
| 2975 | - }); | |
| 2976 | - } | |
| 2977 | 2433 | let (mi_r, mi_c) = (mi_r & !(step_y - 1), mi_c & !(step_x - 1)); |
| 2978 | 2434 | let round_up_even = |n: usize| n.div_ceil(2) * 2; |
| 2979 | 2435 | let (bound_h, bound_w) = (round_up_even(self.mi_rows), round_up_even(self.mi_cols)); |
| 2980 | 2436 | let state = neighbour_state(grid); |
| 2981 | - if crate::envflags::env_flag!("EC_CHROMA_PUB") { | |
| 2982 | - eprintln!( | |
| 2983 | - "EC_CHROMA_PUB plane={plane} mi=({mi_r},{mi_c}) wh=({w_px},{h_px}) lvl={} dc={}", | |
| 2984 | - state.level, | |
| 2985 | - state.dc.map_or(-1, i32::from) | |
| 2986 | - ); | |
| 2987 | - } | |
| 2988 | 2437 | for cell in 0..(h_px / MI).min(bound_h.saturating_sub(mi_r)) { |
| 2989 | 2438 | self.left[mi_r + cell][plane] = state; |
| 2990 | 2439 | } |
| @@ -3004,12 +2453,6 @@ impl Neighbours { | ||
| 3004 | 2453 | grid: &[i32], |
| 3005 | 2454 | ) { |
| 3006 | 2455 | let state = neighbour_state(grid); |
| 3007 | - if crate::envflags::env_flag!("EC_ECPUB") { | |
| 3008 | - eprintln!( | |
| 3009 | - "EC_ECPUB tu mi=({mi_r},{mi_c}) wh=({w_px},{h_px}) lvl={}", | |
| 3010 | - state.level | |
| 3011 | - ); | |
| 3012 | - } | |
| 3013 | 2456 | for cell in 0..h_px / MI { |
| 3014 | 2457 | if mi_r + cell < self.mi_rows { |
| 3015 | 2458 | self.left[mi_r + cell][0] = state; |
| @@ -3600,21 +3043,9 @@ pub(super) fn decode_color_index_map_wh( | ||
| 3600 | 3043 | on: (usize, usize), |
| 3601 | 3044 | uv: bool, |
| 3602 | 3045 | ) -> Vec<u8> { |
| 3603 | - let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); | |
| 3604 | 3046 | let (on_bw, on_bh) = (on.0.clamp(1, bw), on.1.clamp(1, bh)); |
| 3605 | - if on_bw < bw || on_bh < bh { | |
| 3606 | - hit!(PALETTE_ONSCREEN_CUT_HITS); | |
| 3607 | - } | |
| 3608 | 3047 | let mut map = vec![0u8; bw * bh]; |
| 3609 | - if trace { | |
| 3610 | - let (rng, _) = dec.debug_state(); | |
| 3611 | - eprintln!("EC_PAL row=0 col=0 ctx=-1 n={n} rng={rng}"); | |
| 3612 | - } | |
| 3613 | 3048 | map[0] = read_uniform(dec, n) as u8; |
| 3614 | - if trace { | |
| 3615 | - let (rng, _) = dec.debug_state(); | |
| 3616 | - eprintln!("EC_PAL_VAL row=0 col=0 color_idx={} rng={rng}", map[0]); | |
| 3617 | - } | |
| 3618 | 3049 | for i in 1..(on_bw + on_bh - 1) { |
| 3619 | 3050 | let j_hi = i.min(on_bw - 1); |
| 3620 | 3051 | let j_lo = i.saturating_sub(on_bh - 1); |
| @@ -3622,28 +3053,12 @@ pub(super) fn decode_color_index_map_wh( | ||
| 3622 | 3053 | let row = i - j; |
| 3623 | 3054 | let col = j; |
| 3624 | 3055 | let (ctx, color_order) = palette_color_index_context(&map, bw, row, col, n); |
| 3625 | - if trace { | |
| 3626 | - let (rng, _) = dec.debug_state(); | |
| 3627 | - let row_cdf = if uv { | |
| 3628 | - &cdfs.palette_uv_color_index[n - 2][ctx] | |
| 3629 | - } else { | |
| 3630 | - &cdfs.palette_y_color_index[n - 2][ctx] | |
| 3631 | - }; | |
| 3632 | - eprintln!( | |
| 3633 | - "EC_PAL row={row} col={col} ctx={ctx} n={n} cdf0={} cnt={} rng={rng}", | |
| 3634 | - row_cdf[0], row_cdf[n] | |
| 3635 | - ); | |
| 3636 | - } | |
| 3637 | 3056 | let symbol = if uv { |
| 3638 | 3057 | dec.symbol(&mut cdfs.palette_uv_color_index[n - 2][ctx][..=n]) |
| 3639 | 3058 | } else { |
| 3640 | 3059 | dec.symbol(&mut cdfs.palette_y_color_index[n - 2][ctx][..=n]) |
| 3641 | 3060 | }; |
| 3642 | 3061 | map[row * bw + col] = color_order[symbol]; |
| 3643 | - if trace { | |
| 3644 | - let (rng, _) = dec.debug_state(); | |
| 3645 | - eprintln!("EC_PAL_VAL row={row} col={col} color_idx={symbol} rng={rng}"); | |
| 3646 | - } | |
| 3647 | 3062 | } |
| 3648 | 3063 | } |
| 3649 | 3064 | palette_replicate(&mut map, bw, bh, on); |
| @@ -3673,9 +3088,6 @@ pub(crate) fn palette_replicate(map: &mut [u8], bw: usize, bh: usize, on: (usize | ||
| 3673 | 3088 | /// it lands away from zero, for gate tests to prove a real stream fired one. |
| 3674 | 3089 | pub(super) fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 { |
| 3675 | 3090 | let symbol = dec.symbol(cdf); |
| 3676 | - if symbol != ANGLE_DELTA_ZERO { | |
| 3677 | - hit!(ANGLE_DELTA_HITS); | |
| 3678 | - } | |
| 3679 | 3091 | symbol as i32 - ANGLE_DELTA_ZERO as i32 |
| 3680 | 3092 | } |
| 3681 | 3093 | |
| @@ -3714,9 +3126,6 @@ pub(super) fn apply_deblock( | ||
| 3714 | 3126 | ) { |
| 3715 | 3127 | // lane-part32 r2 debug rung, env-gated: bisecting a widespread pixel |
| 3716 | 3128 | // mismatch between the raw reconstruction and post-filter output. |
| 3717 | - if crate::envflags::env_flag!("EC_AV1_DEBUG_SKIP_DEBLOCK") { | |
| 3718 | - return; | |
| 3719 | - } | |
| 3720 | 3129 | if lf.level[0] != 0 || lf.level[1] != 0 { |
| 3721 | 3130 | deblock_plane(y, 0, lf, n, frame_width, frame_height, fctx); |
| 3722 | 3131 | } |
| @@ -3806,9 +3215,7 @@ pub(super) fn tx_size_context_txfm_rect( | ||
| 3806 | 3215 | (mi_r, mi_c): (usize, usize), |
| 3807 | 3216 | own_w: usize, |
| 3808 | 3217 | own_h: usize, |
| 3809 | - fctx: &crate::decode::FrameCtx, | |
| 3810 | 3218 | ) -> usize { |
| 3811 | - hit!(INTRA_IN_INTER_TXCTX_HITS); | |
| 3812 | 3219 | // `max_txsize_rect_lookup[bsize]` tops out at TX_64X64: no transform is |
| 3813 | 3220 | // wider or taller than 64, so a block with a 128 side resolves against 64 |
| 3814 | 3221 | // (lane-sb128b r1). |
| @@ -3857,31 +3264,7 @@ pub(super) fn tx_size_context_txfm_rect( | ||
| 3857 | 3264 | }; |
| 3858 | 3265 | if band_above != (has_above && usize::from(above) != 0) |
| 3859 | 3266 | || band_left != (has_left && usize::from(left) != 0) |
| 3860 | - { | |
| 3861 | - hit!(TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS); | |
| 3862 | - } | |
| 3863 | - } | |
| 3864 | - if crate::envflags::env_flag!("EC_TXCTX") { | |
| 3865 | - eprintln!( | |
| 3866 | - "EC_TXCTX mi={mi_r},{mi_c} own={own_w}x{own_h} ha={has_above} hl={has_left} \ | |
| 3867 | - intra_only={} above_txfm={} left_txfm={} above_inter={} left_inter={} \ | |
| 3868 | - above_side={} left_side={} above={above} left={left} \ | |
| 3869 | - | cell_inter ab={} lb={} ab_side={} lb_side={}", | |
| 3870 | - fctx.intra_only.with(std::cell::Cell::get), | |
| 3871 | - n.above_txfm[mi_c], | |
| 3872 | - n.left_txfm[mi_r], | |
| 3873 | - n.above_inter[mi_c], | |
| 3874 | - n.left_inter[mi_r], | |
| 3875 | - n.above_side_mi[mi_c], | |
| 3876 | - n.left_side_mi[mi_r], | |
| 3877 | - // lane-av1txctxband: the per-CELL terms this read now uses, next to | |
| 3878 | - // the per-column bands it used to use, so a divergence names which | |
| 3879 | - // of the two disagreed. | |
| 3880 | - if has_above { n.inter_at(mi_r - 1, mi_c) } else { false }, | |
| 3881 | - if has_left { n.inter_at(mi_r, mi_c - 1) } else { false }, | |
| 3882 | - if has_above { n.blk_side_at(mi_r - 1, mi_c).0 } else { 0 }, | |
| 3883 | - if has_left { n.blk_side_at(mi_r, mi_c - 1).1 } else { 0 }, | |
| 3884 | - ); | |
| 3267 | + {} | |
| 3885 | 3268 | } |
| 3886 | 3269 | let ctx = match (has_above, has_left) { |
| 3887 | 3270 | (true, true) => usize::from(above) + usize::from(left), |
| @@ -3889,13 +3272,6 @@ pub(super) fn tx_size_context_txfm_rect( | ||
| 3889 | 3272 | (false, true) => usize::from(left), |
| 3890 | 3273 | (false, false) => 0, |
| 3891 | 3274 | }; |
| 3892 | - { | |
| 3893 | - let stale = usize::from(has_above && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w) | |
| 3894 | - + usize::from(has_left && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h); | |
| 3895 | - if ctx != stale { | |
| 3896 | - hit!(TXCTX_DEBLOCK_DIVERGENCE_HITS); | |
| 3897 | - } | |
| 3898 | - } | |
| 3899 | 3275 | ctx |
| 3900 | 3276 | } |
| 3901 | 3277 | |
| @@ -3905,7 +3281,11 @@ pub(super) fn tx_size_context_txfm_rect( | ||
| 3905 | 3281 | /// override above fired on the wrong neighbour -- the first divergence of the |
| 3906 | 3282 | /// 10-bit gate's stream was exactly this (`tx_depth` ctx 0 where libaom has 1, |
| 3907 | 3283 | /// at the intra block right of an inter one). |
| 3908 | -pub(super) fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize), side: usize) -> usize { | |
| 3284 | +pub(super) fn tx_size_context_txfm( | |
| 3285 | + n: &Neighbours, | |
| 3286 | + (mi_r, mi_c): (usize, usize), | |
| 3287 | + side: usize, | |
| 3288 | +) -> usize { | |
| 3909 | 3289 | let has_above = mi_r > n.tile_row0_mi; |
| 3910 | 3290 | let has_left = mi_c > n.tile_col0_mi; |
| 3911 | 3291 | let mut above = usize::from(n.above_txfm[mi_c]) >= side; |
| @@ -3948,26 +3328,7 @@ pub(super) fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize), | ||
| 3948 | 3328 | }; |
| 3949 | 3329 | if band_above != (has_above && usize::from(above) != 0) |
| 3950 | 3330 | || band_left != (has_left && usize::from(left) != 0) |
| 3951 | - { | |
| 3952 | - hit!(TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS); | |
| 3953 | - } | |
| 3954 | - } | |
| 3955 | - if crate::envflags::env_flag!("EC_TXCTX") { | |
| 3956 | - eprintln!( | |
| 3957 | - "EC_TXCTX mi={mi_r},{mi_c} own={side} ha={has_above} hl={has_left} \ | |
| 3958 | - above_txfm={} left_txfm={} above_inter={} left_inter={} above_side={} left_side={} \ | |
| 3959 | - above={above} left={left} | cell_inter ab={} lb={} ab_side={} lb_side={}", | |
| 3960 | - n.above_txfm[mi_c], | |
| 3961 | - n.left_txfm[mi_r], | |
| 3962 | - n.above_inter[mi_c], | |
| 3963 | - n.left_inter[mi_r], | |
| 3964 | - n.above_side_mi[mi_c], | |
| 3965 | - n.left_side_mi[mi_r], | |
| 3966 | - if has_above { n.inter_at(mi_r - 1, mi_c) } else { false }, | |
| 3967 | - if has_left { n.inter_at(mi_r, mi_c - 1) } else { false }, | |
| 3968 | - if has_above { n.blk_side_at(mi_r - 1, mi_c).0 } else { 0 }, | |
| 3969 | - if has_left { n.blk_side_at(mi_r, mi_c - 1).1 } else { 0 }, | |
| 3970 | - ); | |
| 3331 | + {} | |
| 3971 | 3332 | } |
| 3972 | 3333 | match (has_above, has_left) { |
| 3973 | 3334 | (true, true) => usize::from(above) + usize::from(left), |
| @@ -4014,16 +3375,6 @@ pub(super) fn read_tx_size( | ||
| 4014 | 3375 | 64 => dec.symbol(&mut cdfs.tx_size_cat3[ctx]), |
| 4015 | 3376 | _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64/128"), |
| 4016 | 3377 | }; |
| 4017 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 4018 | - let (rng, _) = dec.debug_state(); | |
| 4019 | - let (mi_r, mi_c) = at_mi; | |
| 4020 | - eprintln!( | |
| 4021 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={depth} ctx={ctx} rng={rng}" | |
| 4022 | - ); | |
| 4023 | - } | |
| 4024 | - if depth != 0 { | |
| 4025 | - hit!(TX_DEPTH_HITS); | |
| 4026 | - } | |
| 4027 | 3378 | max_tx >> depth |
| 4028 | 3379 | } |
| 4029 | 3380 | |
| @@ -4033,7 +3384,12 @@ pub(super) fn read_tx_size( | ||
| 4033 | 3384 | /// the two neighbour terms (whether the transform last written above/left of |
| 4034 | 3385 | /// this unit is narrower/shorter than the unit itself). |
| 4035 | 3386 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| 4036 | -pub(super) fn txfm_partition_ctx(above_px: u8, left_px: u8, blk_max_px: usize, tx_px: usize) -> usize { | |
| 3387 | +pub(super) fn txfm_partition_ctx( | |
| 3388 | + above_px: u8, | |
| 3389 | + left_px: u8, | |
| 3390 | + blk_max_px: usize, | |
| 3391 | + tx_px: usize, | |
| 3392 | +) -> usize { | |
| 4037 | 3393 | txfm_partition_ctx_rect(above_px, left_px, blk_max_px, tx_px, tx_px) |
| 4038 | 3394 | } |
| 4039 | 3395 | |
| @@ -4066,7 +3422,12 @@ pub(crate) fn txfm_partition_ctx_rect( | ||
| 4066 | 3422 | /// resolves, every mi cell its *parent* unit (`txb_px`) spans records the |
| 4067 | 3423 | /// resolved transform's own size. |
| 4068 | 3424 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| 4069 | -pub(super) fn txfm_partition_update(n: &mut Neighbours, at_mi: (usize, usize), tx_px: usize, txb_px: usize) { | |
| 3425 | +pub(super) fn txfm_partition_update( | |
| 3426 | + n: &mut Neighbours, | |
| 3427 | + at_mi: (usize, usize), | |
| 3428 | + tx_px: usize, | |
| 3429 | + txb_px: usize, | |
| 3430 | +) { | |
| 4070 | 3431 | txfm_partition_update_rect(n, at_mi, (tx_px, tx_px), (txb_px, txb_px)); |
| 4071 | 3432 | } |
| 4072 | 3433 | |
| @@ -4136,12 +3497,6 @@ pub(super) fn txfm_partition_update_rect( | ||
| 4136 | 3497 | (tx_w, tx_h): (usize, usize), |
| 4137 | 3498 | (txb_w, txb_h): (usize, usize), |
| 4138 | 3499 | ) { |
| 4139 | - if crate::envflags::env_flag!("EC_TXUPD") { | |
| 4140 | - eprintln!( | |
| 4141 | - "EC_TXUPD rect mi=({},{}) tx=({tx_w},{tx_h}) txb=({txb_w},{txb_h})", | |
| 4142 | - mi_r, mi_c | |
| 4143 | - ); | |
| 4144 | - } | |
| 4145 | 3500 | for i in 0..txb_h / MI { |
| 4146 | 3501 | if let Some(cell) = n.left_txfm.get_mut(mi_r + i) { |
| 4147 | 3502 | *cell = tx_h as u8; |
| @@ -4165,11 +3520,6 @@ pub(super) fn set_txfm_ctxs( | ||
| 4165 | 3520 | h_mi: usize, |
| 4166 | 3521 | skip_inter: bool, |
| 4167 | 3522 | ) { |
| 4168 | - if crate::envflags::env_flag!("EC_TXUPD") { | |
| 4169 | - eprintln!( | |
| 4170 | - "EC_TXUPD ctxs mi=({mi_r},{mi_c}) tx={tx_px} wh=({w_mi},{h_mi}) skip_inter={skip_inter}" | |
| 4171 | - ); | |
| 4172 | - } | |
| 4173 | 3523 | let bw = if skip_inter { w_mi * MI } else { tx_px }; |
| 4174 | 3524 | let bh = if skip_inter { h_mi * MI } else { tx_px }; |
| 4175 | 3525 | for i in 0..w_mi { |
| @@ -4439,22 +3789,11 @@ pub(super) fn read_var_tx_size( | ||
| 4439 | 3789 | tx_h, |
| 4440 | 3790 | ); |
| 4441 | 3791 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; |
| 4442 | - hit!(TXFM_SPLIT_READS); | |
| 4443 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 4444 | - let (rng, _) = dec.debug_state(); | |
| 4445 | - eprintln!( | |
| 4446 | - "EC_ISTEP mi_row={} mi_col={} name=txfm_split val={} ctx={ctx} rng={rng}", | |
| 4447 | - unit.0, | |
| 4448 | - unit.1, | |
| 4449 | - u8::from(split) | |
| 4450 | - ); | |
| 4451 | - } | |
| 4452 | 3792 | if !split { |
| 4453 | 3793 | out.push((blk_row, blk_col, tx_w, tx_h)); |
| 4454 | 3794 | txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h)); |
| 4455 | 3795 | return; |
| 4456 | 3796 | } |
| 4457 | - hit!(TXFM_SPLIT_HITS); | |
| 4458 | 3797 | let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h); |
| 4459 | 3798 | if (sub_w, sub_h) == (4, 4) { |
| 4460 | 3799 | // libaom's `sub_txs == TX_4X4` early return: every mi cell of the |
crates/ec-av1/src/decode/counters.rsdeleted+0 -4459
Diff too large; view file
| @@ -1,4459 +0,0 @@ | ||
| 1 | -//! Hit and census counters of the decode path: thread-local tallies bumped by the | |
| 2 | -//! `hit!` instrumentation and read back by the gate tests. Moved out of `decode/mod.rs` | |
| 3 | -//! by name (av1split D3); the items are unchanged except for `pub(super)` visibility. | |
| 4 | - | |
| 5 | -use super::*; | |
| 6 | - | |
| 7 | -// How many real 128-level partition symbols this decoder has read, and how | |
| 8 | -// many superblocks resolved to `PARTITION_SPLIT` (coded or forced) -- the | |
| 9 | -// gate's proof a `--sb-size=128` stream exercised the 128 partition root. | |
| 10 | -thread_local! { | |
| 11 | - pub(super) static PART128_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 12 | -} | |
| 13 | - | |
| 14 | -/// Current value of [`PART128_SPLIT_HITS`]. | |
| 15 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 16 | -pub(crate) fn part128_split_hits() -> usize { | |
| 17 | - PART128_SPLIT_HITS.with(|c| c.get()) | |
| 18 | -} | |
| 19 | - | |
| 20 | -// How many `use_filter_intra` symbols this decoder has read as `1`, across | |
| 21 | -// every call on the current thread -- the cheap counter [`filter_intra_hits`] gate | |
| 22 | -// tests read (before/after, not the absolute value) to prove a stream | |
| 23 | -// actually exercised the filter-intra predictor rather than silently | |
| 24 | -// skipping it. | |
| 25 | -thread_local! { | |
| 26 | - pub(super) static FILTER_INTRA_HITS: std::cell::Cell<usize> = | |
| 27 | - const { std::cell::Cell::new(0) }; | |
| 28 | -} | |
| 29 | - | |
| 30 | -/// Current value of [`FILTER_INTRA_HITS`]. | |
| 31 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 32 | -pub(crate) fn filter_intra_hits() -> usize { | |
| 33 | - FILTER_INTRA_HITS.with(|c| c.get()) | |
| 34 | -} | |
| 35 | - | |
| 36 | -// lane-fiinter r1: how many of those `use_filter_intra == 1` symbols belonged | |
| 37 | -// to an INTRA block inside an INTER frame (`read_intra_block_mode_info`'s own | |
| 38 | -// `read_filter_intra_mode_info` call), which no gate exercised before this | |
| 39 | -// round -- every inter gate recipe passed `--enable-filter-intra=0`. | |
| 40 | -thread_local! { | |
| 41 | - pub(super) static INTRA_IN_INTER_FILTER_INTRA_HITS: std::cell::Cell<usize> = | |
| 42 | - const { std::cell::Cell::new(0) }; | |
| 43 | -} | |
| 44 | - | |
| 45 | -/// Current value of [`INTRA_IN_INTER_FILTER_INTRA_HITS`]. | |
| 46 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 47 | -pub(crate) fn intra_in_inter_filter_intra_hits() -> usize { | |
| 48 | - INTRA_IN_INTER_FILTER_INTRA_HITS.with(|c| c.get()) | |
| 49 | -} | |
| 50 | - | |
| 51 | -// lane-angleinter r1: how many INTRA blocks inside an INTER frame carried a | |
| 52 | -// nonzero `angle_delta_y` / `angle_delta_uv` (`read_intra_angle_info`). Both | |
| 53 | -// arms refused a nonzero luma delta before this round, and no inter gate | |
| 54 | -// enabled `--enable-angle-delta` (aomenc's own default is 1). | |
| 55 | -thread_local! { | |
| 56 | - pub(super) static INTRA_IN_INTER_ANGLE_DELTA_Y_HITS: std::cell::Cell<usize> = | |
| 57 | - const { std::cell::Cell::new(0) }; | |
| 58 | - pub(super) static INTRA_IN_INTER_ANGLE_DELTA_UV_HITS: std::cell::Cell<usize> = | |
| 59 | - const { std::cell::Cell::new(0) }; | |
| 60 | -} | |
| 61 | - | |
| 62 | -/// Current value of [`INTRA_IN_INTER_ANGLE_DELTA_Y_HITS`]. | |
| 63 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 64 | -pub(crate) fn intra_in_inter_angle_delta_y_hits() -> usize { | |
| 65 | - INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.get()) | |
| 66 | -} | |
| 67 | - | |
| 68 | -/// Current value of [`INTRA_IN_INTER_ANGLE_DELTA_UV_HITS`]. | |
| 69 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 70 | -pub(crate) fn intra_in_inter_angle_delta_uv_hits() -> usize { | |
| 71 | - INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|c| c.get()) | |
| 72 | -} | |
| 73 | - | |
| 74 | -// lane-uv8 r1: the three non-DC chroma mode classes an INTRA 8x8 leaf inside | |
| 75 | -// an INTER frame ([`decode_inter_block8`]'s intra arm) can carry -- the arm | |
| 76 | -// read `uv_mode` and then refused everything but `DC_PRED`. Counted here and | |
| 77 | -// nowhere else so the gate's assert cannot be satisfied by a >=16x16 block. | |
| 78 | -thread_local! { | |
| 79 | - pub(super) static INTRA_IN_INTER8_UV_DIR_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 80 | - pub(super) static INTRA_IN_INTER8_UV_SMOOTH_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 81 | - pub(super) static INTRA_IN_INTER8_UV_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 82 | -} | |
| 83 | - | |
| 84 | -thread_local! { | |
| 85 | - pub(super) static INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 86 | -} | |
| 87 | - | |
| 88 | -/// Nonzero luma angle deltas coded by an intra 8x8 leaf inside an inter frame | |
| 89 | -/// (lane-leaf8tx r1) -- counted only in [`decode_inter_block8`]'s intra arm. | |
| 90 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 91 | -pub(crate) fn intra_in_inter8_angle_delta_y_hits() -> usize { | |
| 92 | - INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS.with(|c| c.get()) | |
| 93 | -} | |
| 94 | - | |
| 95 | -/// `(directional, smooth/paeth, CfL)` chroma modes coded by an intra 8x8 leaf | |
| 96 | -/// inside an inter frame -- see [`INTRA_IN_INTER8_UV_DIR_HITS`]. | |
| 97 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 98 | -pub(crate) fn intra_in_inter8_uv_hits() -> (usize, usize, usize) { | |
| 99 | - ( | |
| 100 | - INTRA_IN_INTER8_UV_DIR_HITS.with(|c| c.get()), | |
| 101 | - INTRA_IN_INTER8_UV_SMOOTH_HITS.with(|c| c.get()), | |
| 102 | - INTRA_IN_INTER8_UV_CFL_HITS.with(|c| c.get()), | |
| 103 | - ) | |
| 104 | -} | |
| 105 | - | |
| 106 | -// Whether this superblock's single CDEF unit (this decoder has no 128x128 | |
| 107 | -// SB, so the SB IS the CDEF unit) has already had its `cdef_idx` literal | |
| 108 | -// read -- reset to `false` at the top of each superblock in the two tile | |
| 109 | -// loops, spec `read_cdef`'s `cdef_transmitted[index]`. | |
| 110 | -// Number of superblock columns in the current tile's grid, so | |
| 111 | -// [`maybe_read_cdef_idx`] can turn an `(mi_r, mi_c)` into a flat index into | |
| 112 | -// [`CDEF_IDX_GRID`]. | |
| 113 | -// One resolved `cdef_idx` per superblock, read by [`apply_cdef`] to select | |
| 114 | -// which of the header's `1 << cdef.bits` strength pairs applies to that | |
| 115 | -// superblock's samples. | |
| 116 | -// How many real (`cdef.bits > 0`) `cdef_idx` literals [`maybe_read_cdef_idx`] | |
| 117 | -// has read, across every call on the current thread -- the gate's proof that a | |
| 118 | -// `cdef_bits > 0` stream actually reached the new reader rather than every | |
| 119 | -// superblock coincidentally being all-skip. | |
| 120 | -thread_local! { | |
| 121 | - pub(super) static CDEF_IDX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 122 | -} | |
| 123 | - | |
| 124 | -// How many times a warp was suppressed for one PLANE because that plane's own | |
| 125 | -// block is narrower or shorter than 8 (`av1_init_warp_params`'s own bail-out, | |
| 126 | -// reconinter.c) -- the gate's proof that a stream really carries the shape, | |
| 127 | -// since the square `side`/`chroma_side` can be 8 or more while the plane's | |
| 128 | -// true block is 4 wide (an 8x16 luma block's 4x8 chroma). | |
| 129 | -thread_local! { | |
| 130 | - pub(super) static WARP_PLANE_SUPPRESS_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 131 | -} | |
| 132 | - | |
| 133 | -/// Current value of [`WARP_PLANE_SUPPRESS_HITS`]. | |
| 134 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 135 | -pub(crate) fn warp_plane_suppress_hits() -> usize { | |
| 136 | - WARP_PLANE_SUPPRESS_HITS.with(|c| c.get()) | |
| 137 | -} | |
| 138 | - | |
| 139 | -/// Current value of [`CDEF_IDX_HITS`]. | |
| 140 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 141 | -pub(crate) fn cdef_idx_hits() -> usize { | |
| 142 | - CDEF_IDX_HITS.with(|c| c.get()) | |
| 143 | -} | |
| 144 | - | |
| 145 | -// lane-t900 r6: gate proof for the three r2-r4 root causes that shipped with no | |
| 146 | -// counter -- the in-inter tx-depth context (`tx_size_context_txfm_rect`), the | |
| 147 | -// non-chroma-reference block that must LEAVE its neighbours' chroma coefficient | |
| 148 | -// contexts alone, and the intra-edge filter neighbour pair taken mi-exact | |
| 149 | -// instead of from the coarse 16x16 cell. | |
| 150 | -thread_local! { | |
| 151 | - pub(super) static INTRA_IN_INTER_TXCTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 152 | - pub(super) static NON_CHROMA_REF_CTX_SKIP_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 153 | - pub(super) static EDGE_FILTER_MI_FIX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 154 | -} | |
| 155 | - | |
| 156 | -/// Current value of [`INTRA_IN_INTER_TXCTX_HITS`]. | |
| 157 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 158 | -pub(crate) fn intra_in_inter_txctx_hits() -> usize { | |
| 159 | - INTRA_IN_INTER_TXCTX_HITS.with(|c| c.get()) | |
| 160 | -} | |
| 161 | - | |
| 162 | -/// Current value of [`NON_CHROMA_REF_CTX_SKIP_HITS`]. | |
| 163 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 164 | -pub(crate) fn non_chroma_ref_ctx_skip_hits() -> usize { | |
| 165 | - NON_CHROMA_REF_CTX_SKIP_HITS.with(|c| c.get()) | |
| 166 | -} | |
| 167 | - | |
| 168 | -/// Current value of [`EDGE_FILTER_MI_FIX_HITS`]. | |
| 169 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 170 | -pub(crate) fn edge_filter_mi_fix_hits() -> usize { | |
| 171 | - EDGE_FILTER_MI_FIX_HITS.with(|c| c.get()) | |
| 172 | -} | |
| 173 | - | |
| 174 | -// lane-realworld r4: this frame's `delta.q_present` (spec 5.9.17) and its | |
| 175 | -// actual step (`1 << delta.q_res`, already the real multiplier, not the raw | |
| 176 | -// 2-bit field). `false`/`1` (the defaults) make [`maybe_read_delta_q`] a | |
| 177 | -// true no-op, matching every existing gate stream's `delta_q_present == 0` | |
| 178 | -// behaviour exactly, the same corner-cut [`CDEF_BITS`] takes above. | |
| 179 | -// The running quantizer index (spec `CurrentQIndex`, libaom | |
| 180 | -// `xd->current_base_qindex`) -- reset to the frame's own `base_q_idx` at the | |
| 181 | -// top of every tile (spec `decode_tile`), carried across superblocks within | |
| 182 | -// that tile, and mutated only by [`maybe_read_delta_q`]. Read back at the | |
| 183 | -// dequantization call sites instead of the frame-constant `base_q_idx`. | |
| 184 | -// This frame's own per-plane DC/AC quantizer-index deltas (lane-sbpart r11, | |
| 185 | -// spec 5.9.12/7.12.2, [`crate::quant::QuantDeltas`]) -- frame-constant (not | |
| 186 | -// per-superblock like [`CURRENT_Q_IDX`]), set once per frame decode and read | |
| 187 | -// back at every dequantization call site keyed on which plane it is doing. | |
| 188 | -// How many real `delta_q_present` symbol groups [`maybe_read_delta_q`] has | |
| 189 | -// read, across every call on the current thread -- the gate's proof that a | |
| 190 | -// `delta_q_present` stream actually reached the new reader. | |
| 191 | -thread_local! { | |
| 192 | - pub(super) static DELTA_Q_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 193 | -} | |
| 194 | - | |
| 195 | -/// Current value of [`DELTA_Q_HITS`]. | |
| 196 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 197 | -pub(crate) fn delta_q_hits() -> usize { | |
| 198 | - DELTA_Q_HITS.with(|c| c.get()) | |
| 199 | -} | |
| 200 | - | |
| 201 | -// lane-realworld r5: this frame's `delta.lf_present`/`lf_res`/`lf_multi` | |
| 202 | -// (spec 5.9.18) -- same no-op-by-default corner-cut as `DELTA_Q_PRESENT`. | |
| 203 | -// The running per-plane/direction loop-filter delta (spec `DeltaLF[i]`, | |
| 204 | -// `i` in `0..FRAME_LF_COUNT`) -- reset to `[0; 4]` at the top of every tile, | |
| 205 | -// mutated only by [`maybe_read_delta_lf`]. `!delta_lf_multi` mode only ever | |
| 206 | -// updates index 0 and every reader treats that as the value for all 4 | |
| 207 | -// indices (spec `read_delta_lf_params`'s own single-cdf branch). | |
| 208 | -// How many real `delta_lf_present` symbol groups [`maybe_read_delta_lf`] has | |
| 209 | -// read -- the gate's proof the reader fired, mirroring [`DELTA_Q_HITS`]. | |
| 210 | -thread_local! { | |
| 211 | - pub(super) static DELTA_LF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 212 | -} | |
| 213 | - | |
| 214 | -/// Current value of [`DELTA_LF_HITS`]. | |
| 215 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 216 | -pub(crate) fn delta_lf_hits() -> usize { | |
| 217 | - DELTA_LF_HITS.with(|c| c.get()) | |
| 218 | -} | |
| 219 | - | |
| 220 | -// --------------------------------------------------------------------------- | |
| 221 | -// lane-seg: segmentation. Header (spec 5.9.14) is parsed by `ec-av1-syntax`; | |
| 222 | -// this block is the per-block `segment_id` reader (spec 5.11.7-5.11.9) plus | |
| 223 | -// the two consumers a real stream exercises: the per-segment quantizer index | |
| 224 | -// (spec 7.12.2 `get_qindex`) and the per-segment loop-filter level | |
| 225 | -// (spec 7.14.4). Shapes follow libaom `decodemv.c:read_segment_id`/ | |
| 226 | -// `read_intra_segment_id`/`read_inter_segment_id` and | |
| 227 | -// `pred_common.h:av1_get_spatial_seg_pred` -- note libaom returns the SPATIAL | |
| 228 | -// PREDICTION (not 0) from `read_segment_id` when the block is `skip`, which | |
| 229 | -// is what the oracle every gate here compares against actually does. | |
| 230 | -thread_local! { | |
| 231 | - /// `CurrentSegmentIds`: this frame's own map, `mi_rows * mi_cols` entries | |
| 232 | - /// with stride `mi_cols` (NOT the padded `Neighbours` grid stride). | |
| 233 | - /// `PrevSegmentIds`: the primary reference frame's saved map, empty when | |
| 234 | - /// this frame has no primary reference (spec `load_previous_segment_ids`). | |
| 235 | - /// `(mi_rows, mi_cols)` for both maps above. | |
| 236 | - /// `AboveSegPredContext` (per mi column) / `LeftSegPredContext` (per mi | |
| 237 | - /// row) -- spec 5.11.9's own `seg_id_predicted` neighbour state, which | |
| 238 | - /// libaom keeps on the neighbouring `mbmi->seg_id_predicted` instead. | |
| 239 | - /// The block currently being decoded -- read back by [`block_q_idx`]. | |
| 240 | - /// The tile's own top-left mi position, for `AvailU`/`AvailL`. | |
| 241 | - /// How many real `segment_id` symbols were read, and the set of segment | |
| 242 | - /// ids any block ended up with -- the gate's proof the feature fired. | |
| 243 | - pub(super) static SEG_ID_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 244 | - /// How many `seg_id_predicted` symbols were read (temporal update). | |
| 245 | - pub(super) static SEG_PRED_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 246 | -} | |
| 247 | - | |
| 248 | -/// How many `segment_id` symbols have been read (never reset per frame). | |
| 249 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 250 | -pub(crate) fn segment_id_hits() -> usize { | |
| 251 | - SEG_ID_HITS.with(|c| c.get()) | |
| 252 | -} | |
| 253 | - | |
| 254 | -/// How many `seg_id_predicted` symbols have been read (temporal update). | |
| 255 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 256 | -pub(crate) fn segment_pred_hits() -> usize { | |
| 257 | - SEG_PRED_HITS.with(|c| c.get()) | |
| 258 | -} | |
| 259 | - | |
| 260 | -/// Resets the segmentation hit counters (gate setup). | |
| 261 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 262 | -pub(crate) fn reset_segment_hits() { | |
| 263 | - SEG_ID_HITS.with(|c| c.set(0)); | |
| 264 | - SEG_IDS_SEEN.with(|c| c.set(0)); | |
| 265 | - SEG_PRED_HITS.with(|c| c.set(0)); | |
| 266 | - BLOCK_Q_SPAN.with(|c| c.set((i32::MAX, i32::MIN))); | |
| 267 | -} | |
| 268 | - | |
| 269 | -// How many key-frame luma blocks resolved `smooth_neighbor` (spec | |
| 270 | -// `get_intra_edge_filter_type`) to `true` -- lane-chroma r2's own before/after | |
| 271 | -// counter, proving a stream actually put a directional block next to a | |
| 272 | -// smooth-predicted neighbour rather than every block reading the (previously | |
| 273 | -// hardcoded `false`) edge-filter strength bucket unchanged. | |
| 274 | -thread_local! { | |
| 275 | - pub(super) static SMOOTH_LUMA_HITS: std::cell::Cell<usize> = | |
| 276 | - const { std::cell::Cell::new(0) }; | |
| 277 | -} | |
| 278 | - | |
| 279 | -/// Current value of [`SMOOTH_LUMA_HITS`]. | |
| 280 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 281 | -pub(crate) fn smooth_luma_hits() -> usize { | |
| 282 | - SMOOTH_LUMA_HITS.with(|c| c.get()) | |
| 283 | -} | |
| 284 | - | |
| 285 | -thread_local! { | |
| 286 | - /// lane-band46 r1: how many split-transform units answered their intra | |
| 287 | - /// reach DIFFERENTLY under libaom's per-unit rules ([`Reach::of_tu`], the | |
| 288 | - /// palette2 r12 fix) than the standalone-block lookup this decoder used to | |
| 289 | - /// apply to them (class reach-is-per-transform-unit). Every hit is a | |
| 290 | - /// transform unit whose above-right / below-left reference samples would | |
| 291 | - /// be wrong without that fix. | |
| 292 | - pub(super) static SPLIT_TU_REACH_FIX_HITS: std::cell::Cell<usize> = | |
| 293 | - const { std::cell::Cell::new(0) }; | |
| 294 | -} | |
| 295 | - | |
| 296 | -/// Current value of [`SPLIT_TU_REACH_FIX_HITS`]. | |
| 297 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 298 | -pub(crate) fn split_tu_reach_fix_hits() -> usize { | |
| 299 | - SPLIT_TU_REACH_FIX_HITS.with(|c| c.get()) | |
| 300 | -} | |
| 301 | - | |
| 302 | -// How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12), | |
| 303 | -// across every call on the current thread -- lane-chroma r3's own before/after | |
| 304 | -// counter, proving a stream actually exercised chroma's smooth/paeth | |
| 305 | -// predictor (the previously-refused round-2 gap) rather than every block | |
| 306 | -// landing on DC/CFL/directional. | |
| 307 | -thread_local! { | |
| 308 | - pub(super) static SMOOTH_UV_HITS: std::cell::Cell<usize> = | |
| 309 | - const { std::cell::Cell::new(0) }; | |
| 310 | -} | |
| 311 | - | |
| 312 | -/// Current value of [`SMOOTH_UV_HITS`]. | |
| 313 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 314 | -pub(crate) fn smooth_uv_hits() -> usize { | |
| 315 | - SMOOTH_UV_HITS.with(|c| c.get()) | |
| 316 | -} | |
| 317 | - | |
| 318 | -// How many tiles [`decode_key_frame_tile_with_cdfs`] has actually decoded a | |
| 319 | -// full superblock walk over, across every call on the current thread -- | |
| 320 | -// lane-tiles r2's own gate-blind-to-feature guard: a gate over a | |
| 321 | -// multi-tile stream must prove more than one tile actually fired, not just | |
| 322 | -// that the stream carried tile_info.cols > 1. | |
| 323 | -thread_local! { | |
| 324 | - pub(super) static TILE_HITS: std::cell::Cell<usize> = | |
| 325 | - const { std::cell::Cell::new(0) }; | |
| 326 | -} | |
| 327 | - | |
| 328 | -/// Current value of [`TILE_HITS`]. | |
| 329 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 330 | -pub(crate) fn tile_hits() -> usize { | |
| 331 | - TILE_HITS.with(|c| c.get()) | |
| 332 | -} | |
| 333 | - | |
| 334 | -// How many 4-pixel deblocking edge groups [`edge_params`] has actually | |
| 335 | -// selected for filtering, across every call on the current thread -- the same | |
| 336 | -// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream | |
| 337 | -// exercised `apply_deblock` rather than every edge landing on level 0. | |
| 338 | -thread_local! { | |
| 339 | - pub(super) static DEBLOCK_HITS: std::cell::Cell<usize> = | |
| 340 | - const { std::cell::Cell::new(0) }; | |
| 341 | -} | |
| 342 | - | |
| 343 | -/// Current value of [`DEBLOCK_HITS`]. | |
| 344 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 345 | -pub(crate) fn deblock_hits() -> usize { | |
| 346 | - DEBLOCK_HITS.with(|c| c.get()) | |
| 347 | -} | |
| 348 | - | |
| 349 | -// lane-defon r1: how many COMPOUND_REFERENCE blocks read a | |
| 350 | -// `UNIDIR_COMP_REFERENCE` pair (both references on the same temporal side, | |
| 351 | -// spec 5.11.25 `comp_reference_type == 0`) -- the gate's proof that a | |
| 352 | -// stream built with `--enable-onesided-comp=1` really exercised the | |
| 353 | -// `uni_comp_ref` alphabet rather than only bidirectional pairs. | |
| 354 | -thread_local! { | |
| 355 | - pub(super) static UNI_COMP_HITS: std::cell::Cell<usize> = | |
| 356 | - const { std::cell::Cell::new(0) }; | |
| 357 | -} | |
| 358 | - | |
| 359 | -/// Current value of [`UNI_COMP_HITS`]. | |
| 360 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 361 | -pub(crate) fn uni_comp_hits() -> usize { | |
| 362 | - UNI_COMP_HITS.with(|c| c.get()) | |
| 363 | -} | |
| 364 | - | |
| 365 | -// lane-defon r1: how many blocks blended through a `COMPOUND_DIFFWTD` mask | |
| 366 | -// (`mc::diffwtd_mask`) -- the narrower half of `MASKED_COMPOUND_HITS`, the | |
| 367 | -// gate's proof that `--enable-diff-wtd-comp=1` reached the difference-weighted | |
| 368 | -// blend and not only the wedge arm. | |
| 369 | -thread_local! { | |
| 370 | - pub(super) static DIFFWTD_HITS: std::cell::Cell<usize> = | |
| 371 | - const { std::cell::Cell::new(0) }; | |
| 372 | -} | |
| 373 | - | |
| 374 | -/// Current value of [`DIFFWTD_HITS`]. | |
| 375 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 376 | -pub(crate) fn diffwtd_hits() -> usize { | |
| 377 | - DIFFWTD_HITS.with(|c| c.get()) | |
| 378 | -} | |
| 379 | - | |
| 380 | -// lane-mcomp64 r1: how many blocks took the INFERRED `COMPOUND_DIFFWTD` arm -- | |
| 381 | -// a block size where `av1_is_wedge_used` is false (64x64 is the only such size | |
| 382 | -// this decoder's square inter path reaches), so no `compound_type` symbol is | |
| 383 | -// coded at all. Strictly narrower than `DIFFWTD_HITS`, which also counts the | |
| 384 | -// coded-symbol DIFFWTD blocks at 8x8/16x16/32x32. | |
| 385 | -thread_local! { | |
| 386 | - pub(super) static DIFFWTD_INFERRED_HITS: std::cell::Cell<usize> = | |
| 387 | - const { std::cell::Cell::new(0) }; | |
| 388 | -} | |
| 389 | - | |
| 390 | -/// Current value of [`DIFFWTD_INFERRED_HITS`]. | |
| 391 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 392 | -pub(crate) fn diffwtd_inferred_hits() -> usize { | |
| 393 | - DIFFWTD_INFERRED_HITS.with(|c| c.get()) | |
| 394 | -} | |
| 395 | - | |
| 396 | -// lane-defon r1: how many FORWARD KEYFRAMES were decoded -- a KEY frame coded | |
| 397 | -// with `show_frame == 0`, output later by a `show_existing_frame` header | |
| 398 | -// (aomenc `--enable-fwd-kf=1 --fwd-kf-dist=N`). Counted from | |
| 399 | -// `stream::decode_stream`, which is where the frame header is consumed; the | |
| 400 | -// gate's proof that the on-value really reached the bitstream rather than | |
| 401 | -// being dropped by the rate control. | |
| 402 | -thread_local! { | |
| 403 | - pub(super) static FWD_KF_HITS: std::cell::Cell<usize> = | |
| 404 | - const { std::cell::Cell::new(0) }; | |
| 405 | -} | |
| 406 | - | |
| 407 | -/// Current value of [`FWD_KF_HITS`]. | |
| 408 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 409 | -pub(crate) fn fwd_kf_hits() -> usize { | |
| 410 | - FWD_KF_HITS.with(|c| c.get()) | |
| 411 | -} | |
| 412 | - | |
| 413 | -// How many [`read_tx_size`] reads resolved a `tx_depth` strictly less than | |
| 414 | -// the block's own side, across every call on the current thread -- the same | |
| 415 | -// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream | |
| 416 | -// actually exercised a *split* transform under `TxMode::Select` rather than | |
| 417 | -// every block coincidentally resolving `depth=0` (indistinguishable from | |
| 418 | -// `TxMode::Largest` pixel-wise). | |
| 419 | -thread_local! { | |
| 420 | - pub(super) static TX_DEPTH_HITS: std::cell::Cell<usize> = | |
| 421 | - const { std::cell::Cell::new(0) }; | |
| 422 | -} | |
| 423 | - | |
| 424 | -// How many plain SQUARE intra blocks (lane-sqchroma r1) resolved a luma | |
| 425 | -// transform smaller than their own side (`tx_depth != 0`) while coding a | |
| 426 | -// chroma prediction other than `DC_PRED` -- the pair the square path's chroma | |
| 427 | -// only exercises with aomenc's tx-size search left ON (its default), which | |
| 428 | -// every older recipe in this file pins off. Counted at the block, so a stream | |
| 429 | -// where RD happened to give every split-transform block a DC chroma mode | |
| 430 | -// reads as zero rather than silently passing for free. | |
| 431 | -thread_local! { | |
| 432 | - pub(super) static SQ_CHROMA_TX_HITS: std::cell::Cell<usize> = | |
| 433 | - const { std::cell::Cell::new(0) }; | |
| 434 | -} | |
| 435 | - | |
| 436 | -/// Current value of [`SQ_CHROMA_TX_HITS`]. | |
| 437 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 438 | -pub(crate) fn sq_chroma_tx_hits() -> usize { | |
| 439 | - SQ_CHROMA_TX_HITS.with(|c| c.get()) | |
| 440 | -} | |
| 441 | - | |
| 442 | -/// Current value of [`TX_DEPTH_HITS`]. | |
| 443 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 444 | -pub(crate) fn tx_depth_hits() -> usize { | |
| 445 | - TX_DEPTH_HITS.with(|c| c.get()) | |
| 446 | -} | |
| 447 | - | |
| 448 | -// lane-txselect: how many `txfm_split` symbols an inter frame's var-tx tree | |
| 449 | -// read, and how many of those actually took the split, on the current thread | |
| 450 | -// -- the same before/after counter pattern as [`TX_DEPTH_HITS`], proving a | |
| 451 | -// stream exercised spec 5.11.17's `read_var_tx_size` rather than every block | |
| 452 | -// coincidentally coding one whole-block transform. | |
| 453 | -thread_local! { | |
| 454 | - pub(super) static TXFM_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 455 | - // lane-inter4 r2: rectangular INTER residual coding -- how many rect | |
| 456 | - // strips coded one whole-block rect transform unit, and how many split | |
| 457 | - // their rect max transform into square sub-transforms. | |
| 458 | - pub(super) static RECT_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 459 | - pub(super) static RECT_INTER_TXSPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 460 | - // lane-r14 r2: luma transform units of an inter strip with a 64-px axis | |
| 461 | - // (64x32/32x64/64x16/16x64), whose coefficients are coded as the | |
| 462 | - // truncated low-32 corner. | |
| 463 | - pub(super) static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 464 | - // lane-rectres r1: whole-block luma transform units of a 32x32-level 1:4 | |
| 465 | - // inter strip, `[32x8, 8x32]`. | |
| 466 | - pub(super) static RECT32X8_INTER_TU_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; | |
| 467 | - // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32]. | |
| 468 | - pub(super) static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; | |
| 469 | - // lane-inter16ab r4: rectangular var-tx leaves with a 4-px axis, [8x4, 4x8] | |
| 470 | - // -- the `sub_tx_size_map[TX_16X4]` split leaves of a 16x16-level 1:4 strip. | |
| 471 | - pub(super) static VARTX_RECT_LEAF4_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; | |
| 472 | - // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter | |
| 473 | - // frame -- 16x8 and 8x16 inter leaves. | |
| 474 | - pub(super) static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 475 | - pub(super) static INTER_LEAF16_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 476 | - // This frame's own `tx_mode == TxMode::Select` and `reduced_tx_set` bits, | |
| 477 | - // set once per inter tile by [`decode_inter_frame_tile_with_cdfs`] -- | |
| 478 | - // `decode_inter_block` already carries forty parameters and both are | |
| 479 | - // frame-constant. | |
| 480 | - // lane-fiinter r1: this sequence header's own `enable_filter_intra` bit, | |
| 481 | - // frame-constant like the two above and stashed the same way -- an intra | |
| 482 | - // block inside an inter frame reads `use_filter_intra` under it. | |
| 483 | -} | |
| 484 | - | |
| 485 | -/// Current value of [`TXFM_SPLIT_HITS`]. | |
| 486 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 487 | -pub(crate) fn txfm_split_hits() -> usize { | |
| 488 | - TXFM_SPLIT_HITS.with(|c| c.get()) | |
| 489 | -} | |
| 490 | - | |
| 491 | -/// Current value of [`INTER_LEAF16_HORZ_HITS`] (lane-inter4 r3). | |
| 492 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 493 | -pub(crate) fn inter_leaf16_horz_hits() -> usize { | |
| 494 | - INTER_LEAF16_HORZ_HITS.with(|c| c.get()) | |
| 495 | -} | |
| 496 | - | |
| 497 | -/// Current value of [`INTER_LEAF16_VERT_HITS`] (lane-inter4 r3). | |
| 498 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 499 | -pub(crate) fn inter_leaf16_vert_hits() -> usize { | |
| 500 | - INTER_LEAF16_VERT_HITS.with(|c| c.get()) | |
| 501 | -} | |
| 502 | - | |
| 503 | -/// Current value of [`RECT_INTER_TU_HITS`] (lane-inter4 r2). | |
| 504 | -pub(crate) fn rect_inter_tu_hits() -> usize { | |
| 505 | - RECT_INTER_TU_HITS.with(|c| c.get()) | |
| 506 | -} | |
| 507 | - | |
| 508 | -/// Current value of [`RECT_INTER_TXSPLIT_HITS`] (lane-inter4 r2). | |
| 509 | -pub(crate) fn rect_inter_txsplit_hits() -> usize { | |
| 510 | - RECT_INTER_TXSPLIT_HITS.with(|c| c.get()) | |
| 511 | -} | |
| 512 | - | |
| 513 | -/// Current value of [`RECT64_INTER_TU_HITS`] (lane-r14 r2). | |
| 514 | -pub(crate) fn rect64_inter_tu_hits() -> usize { | |
| 515 | - RECT64_INTER_TU_HITS.with(|c| c.get()) | |
| 516 | -} | |
| 517 | - | |
| 518 | -/// Current value of [`RECT32X8_INTER_TU_HITS`] (lane-rectres r1): `[32x8, 8x32]` | |
| 519 | -/// whole-block luma units of a 32x32-level 1:4 inter strip. | |
| 520 | -pub(crate) fn rect32x8_inter_tu_hits() -> [usize; 2] { | |
| 521 | - RECT32X8_INTER_TU_HITS.with(|c| c.get()) | |
| 522 | -} | |
| 523 | - | |
| 524 | -/// Current value of [`VARTX_RECT_LEAF_HITS`] (lane-r14 r3): how many | |
| 525 | -/// rectangular var-tx leaf transform units were coded, `[32x16, 16x32]`. | |
| 526 | -pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] { | |
| 527 | - VARTX_RECT_LEAF_HITS.with(|c| c.get()) | |
| 528 | -} | |
| 529 | - | |
| 530 | -/// Current value of [`VARTX_RECT_LEAF4_HITS`] (lane-inter16ab r4): 8x4/4x8 | |
| 531 | -/// split leaves of a 16x4/4x16 strip, `[8x4, 4x8]`. | |
| 532 | -pub(crate) fn vartx_rect_leaf4_hits() -> [usize; 2] { | |
| 533 | - VARTX_RECT_LEAF4_HITS.with(|c| c.get()) | |
| 534 | -} | |
| 535 | - | |
| 536 | -/// Records one rectangular var-tx leaf. | |
| 537 | -pub(super) fn vartx_rect_leaf_hit(tw: usize, th: usize) { | |
| 538 | - if crate::envflags::env_flag!("EC_VARTXLEAF") { | |
| 539 | - eprintln!("EC_VARTXLEAF tw={tw} th={th}"); | |
| 540 | - } | |
| 541 | - let cell = if tw.min(th) == 4 { | |
| 542 | - &VARTX_RECT_LEAF4_HITS | |
| 543 | - } else { | |
| 544 | - &VARTX_RECT_LEAF_HITS | |
| 545 | - }; | |
| 546 | - cell.with(|c| { | |
| 547 | - let mut h = c.get(); | |
| 548 | - h[usize::from(th > tw)] += 1; | |
| 549 | - c.set(h); | |
| 550 | - }); | |
| 551 | -} | |
| 552 | - | |
| 553 | -// How many `partition_w16` reads (a 16x16 block's own partition symbol, key | |
| 554 | -// intra-frame path) resolved to `PARTITION_VERT_B` -- lane-rect16 r1: a | |
| 555 | -// plain default-settings aomenc run over lavfi mandelbrot hits this arm on | |
| 556 | -// frame 0's very first non-NONE/SPLIT `partition_w16` symbol (mi=(3,2)), not | |
| 557 | -// the plain HORZ/VERT this lane's charter assumed. Left rect (8x16, real | |
| 558 | -// `decode_block_rect`) + two 8x8 leaves stacked on the right (`decode_leaf8`, | |
| 559 | -// chained via `prev_leaf` exactly like the existing 16x16-SPLIT-into-4x8x8 | |
| 560 | -// path above). | |
| 561 | -thread_local! { | |
| 562 | - pub(super) static VERT_B_INTRA_HITS: std::cell::Cell<usize> = | |
| 563 | - const { std::cell::Cell::new(0) }; | |
| 564 | -} | |
| 565 | - | |
| 566 | -/// Current value of [`VERT_B_INTRA_HITS`]. | |
| 567 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 568 | -pub(crate) fn vert_b_intra_hits() -> usize { | |
| 569 | - VERT_B_INTRA_HITS.with(|c| c.get()) | |
| 570 | -} | |
| 571 | - | |
| 572 | -// lane-ab16 r1: how many 16x16-level AB partitions fired, per arm, in | |
| 573 | -// `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B` order. Each arm is two | |
| 574 | -// 8x8 squares (`decode_leaf8`) plus one 16x8/8x16 strip (`decode_leaf_rect`, | |
| 575 | -// the non-skip coefficient path lane-rectx proved); the gate hard-asserts | |
| 576 | -// every arm separately so a run where aomenc's RD only picked one cannot | |
| 577 | -// pass as proof of four. | |
| 578 | -thread_local! { | |
| 579 | - pub(super) static AB16_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; | |
| 580 | -} | |
| 581 | - | |
| 582 | -// [`AB16_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16). | |
| 583 | -thread_local! { | |
| 584 | - /// 4x4 transform units decoded inside an 8x8 square of a | |
| 585 | - /// `PARTITION_VERT_A`/`_B` -- the exact call that panicked before | |
| 586 | - /// [`crate::encode::Reach::of_tu`] (lane-ab16 r2), so the gate can prove | |
| 587 | - /// a real `--enable-tx-size-search=1` stream reaches it. | |
| 588 | - pub(super) static VERT_AB_TX4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 589 | -} | |
| 590 | - | |
| 591 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 592 | -pub(crate) fn vert_ab_tx4_hits() -> usize { | |
| 593 | - VERT_AB_TX4_HITS.with(std::cell::Cell::get) | |
| 594 | -} | |
| 595 | - | |
| 596 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 597 | -pub(crate) fn ab16_hits_by_arm() -> [usize; 4] { | |
| 598 | - AB16_HITS.with(std::cell::Cell::get) | |
| 599 | -} | |
| 600 | - | |
| 601 | -// How many `partition_w16` reads resolved to a plain `PARTITION_HORZ`/ | |
| 602 | -// `PARTITION_VERT` (lane-rect16 r2): re-measuring after the VERT_B fix above | |
| 603 | -// showed mandelbrot's real first-hit blocker is this plain arm at mi=(0,7), | |
| 604 | -// not VERT_B (`refusal-names-a-correlate`; the VERT_B write-up's "frame 0's | |
| 605 | -// very first non-NONE/SPLIT symbol" claim was about decode ORDER within one | |
| 606 | -// superblock's z-order recursion, not raster mi position). | |
| 607 | -thread_local! { | |
| 608 | - pub(super) static HORZ_VERT_INTRA_HITS: std::cell::Cell<usize> = | |
| 609 | - const { std::cell::Cell::new(0) }; | |
| 610 | -} | |
| 611 | - | |
| 612 | -/// Current value of [`HORZ_VERT_INTRA_HITS`]. | |
| 613 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 614 | -pub(crate) fn horz_vert_intra_hits() -> usize { | |
| 615 | - HORZ_VERT_INTRA_HITS.with(|c| c.get()) | |
| 616 | -} | |
| 617 | - | |
| 618 | -// How many blocks were decoded as a frame-edge rect strip -- the single | |
| 619 | -// coded half of a `PARTITION_HORZ`/`PARTITION_VERT` at the true frame edge | |
| 620 | -// (lane-oddh r1), i.e. a block living inside the 8px band of a frame whose | |
| 621 | -// height or width is 8 mod 16 (the user's 3840x1608 film). Intra and inter | |
| 622 | -// paths share the counter. | |
| 623 | -thread_local! { | |
| 624 | - pub(super) static EDGE_RECT_STRIP_HITS: std::cell::Cell<usize> = | |
| 625 | - const { std::cell::Cell::new(0) }; | |
| 626 | -} | |
| 627 | - | |
| 628 | -/// Current value of [`EDGE_RECT_STRIP_HITS`]. | |
| 629 | -#[allow(dead_code)] // gate counter accessor with no reader yet; the counter itself is live | |
| 630 | -pub(crate) fn edge_rect_strip_hits() -> usize { | |
| 631 | - EDGE_RECT_STRIP_HITS.with(|c| c.get()) | |
| 632 | -} | |
| 633 | - | |
| 634 | -// lane-interedge r1: frame-edge half strips on the INTER path, per partition | |
| 635 | -// level (64/32/16) x axis (HORZ at a bottom edge, VERT at a right edge). The | |
| 636 | -// index is `level_idx * 2 + axis` with `level_idx` 0=64, 1=32, 2=16 and | |
| 637 | -// `axis` 0=HORZ (`!has_rows`), 1=VERT (`!has_cols`). Both of the user's films | |
| 638 | -// are height mod 16 == 8, so every inter frame crosses these nodes. | |
| 639 | -thread_local! { | |
| 640 | - pub(super) static INTER_EDGE_STRIP_HITS: std::cell::Cell<[usize; 6]> = | |
| 641 | - const { std::cell::Cell::new([0; 6]) }; | |
| 642 | -} | |
| 643 | - | |
| 644 | -// lane-edgeboth r1: how many partition nodes were coded as the BOTH-AXES-CUT | |
| 645 | -// forced split -- libaom `decode_partition` (decodeframe.c): | |
| 646 | -// `else if (!has_rows && !has_cols) partition = PARTITION_SPLIT;`, the one | |
| 647 | -// straddle case that reads NO symbol at all. Indexed by level: | |
| 648 | -// 0 = 16x16, 1 = 32x32, 2 = 64x64, 3 = 128x128; intra and inter share it. | |
| 649 | -thread_local! { | |
| 650 | - pub(super) static EDGE_BOTH_CUT_HITS: std::cell::Cell<[usize; 4]> = | |
| 651 | - const { std::cell::Cell::new([0; 4]) }; | |
| 652 | -} | |
| 653 | - | |
| 654 | -/// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`). | |
| 655 | -pub fn inter_edge_strip_hits() -> [usize; 6] { | |
| 656 | - INTER_EDGE_STRIP_HITS.with(|c| c.get()) | |
| 657 | -} | |
| 658 | - | |
| 659 | -/// Resets [`INTER_EDGE_STRIP_HITS`] -- a refused attempt must not carry hits | |
| 660 | -/// into the next one (class `counter-from-refused-stream`). | |
| 661 | -pub fn reset_inter_edge_strip_hits() { | |
| 662 | - INTER_EDGE_STRIP_HITS.with(|c| c.set([0; 6])); | |
| 663 | -} | |
| 664 | - | |
| 665 | -/// Current value of [`EDGE_BOTH_CUT_HITS`] (`[16, 32, 64, 128]` levels). | |
| 666 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 667 | -pub(crate) fn edge_both_cut_hits() -> [usize; 4] { | |
| 668 | - EDGE_BOTH_CUT_HITS.with(|c| c.get()) | |
| 669 | -} | |
| 670 | - | |
| 671 | -/// Zeroes [`EDGE_BOTH_CUT_HITS`] so a gate can measure a per-attempt delta. | |
| 672 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 673 | -pub(crate) fn reset_edge_both_cut_hits() { | |
| 674 | - EDGE_BOTH_CUT_HITS.with(|c| c.set([0; 4])); | |
| 675 | -} | |
| 676 | - | |
| 677 | -// How many HORZ/VERT intra strips resolved a SPLIT luma transform | |
| 678 | -// (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) -- | |
| 679 | -// the case every rect path here refused by name before, and the first | |
| 680 | -// refusal the user's ReelB extract (600s in) stops at. | |
| 681 | -thread_local! { | |
| 682 | - pub(super) static RECT_SPLIT_TX_HITS: std::cell::Cell<usize> = | |
| 683 | - const { std::cell::Cell::new(0) }; | |
| 684 | -} | |
| 685 | - | |
| 686 | -/// Current value of [`RECT_SPLIT_TX_HITS`]. | |
| 687 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 688 | -pub(crate) fn rect_split_tx_hits() -> usize { | |
| 689 | - RECT_SPLIT_TX_HITS.with(|c| c.get()) | |
| 690 | -} | |
| 691 | - | |
| 692 | -// The subset of [`RECT_SPLIT_TX_HITS`] that is BOTH superblock-level (one | |
| 693 | -// side 64) AND split past the first depth, i.e. tiled more than one unit in | |
| 694 | -// each axis -- the only shape with a transform unit that has neighbours on | |
| 695 | -// two sides inside its own strip (`row_off > 0 && col_off > 0`), and the one | |
| 696 | -// no gate fired before lane-rectsplit r2 (the shared counter above also | |
| 697 | -// counts 32x32-level and depth-1 strips, so it cannot prove this case). | |
| 698 | -thread_local! { | |
| 699 | - pub(super) static RECT_SPLIT_SB_INTERIOR_TU_HITS: std::cell::Cell<usize> = | |
| 700 | - const { std::cell::Cell::new(0) }; | |
| 701 | -} | |
| 702 | - | |
| 703 | -/// Current value of [`RECT_SPLIT_SB_INTERIOR_TU_HITS`]. | |
| 704 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 705 | -pub(crate) fn rect_split_sb_interior_tu_hits() -> usize { | |
| 706 | - RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.get()) | |
| 707 | -} | |
| 708 | - | |
| 709 | -// Per-shape hit counts for the rect chroma transforms lane-rectchroma r1 | |
| 710 | -// wired into [`decode_rect_split`] -- the shapes a split-transform strip's | |
| 711 | -// chroma half takes that had no coefficient tables before (index order: | |
| 712 | -// 32x8, 8x32, 8x4, 4x8). One counter per shape because a gate that only | |
| 713 | -// proves the pair it happens to hit cannot catch a transposed scan/context | |
| 714 | -// table (class scan-weights-cross-axis). | |
| 715 | -thread_local! { | |
| 716 | - pub(super) static RECT_SPLIT_CHROMA_SHAPE_HITS: std::cell::Cell<[usize; 4]> = | |
| 717 | - const { std::cell::Cell::new([0; 4]) }; | |
| 718 | -} | |
| 719 | - | |
| 720 | -/// Current value of [`RECT_SPLIT_CHROMA_SHAPE_HITS`] (32x8, 8x32, 8x4, 4x8). | |
| 721 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 722 | -pub(crate) fn rect_split_chroma_shape_hits() -> [usize; 4] { | |
| 723 | - RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| c.get()) | |
| 724 | -} | |
| 725 | - | |
| 726 | -// lane-av1-422: how many SQUARE chroma coefficient units the strip path read | |
| 727 | -// on a 4:2:2 frame (ss 1,0) -- the half-width, unhalved-height shape whose | |
| 728 | -// tables only exist because of the square rows in the chroma_tiled arm. A | |
| 729 | -// 4:2:0 or 4:4:4 frame can never increment it (their rect strips' chroma is | |
| 730 | -// itself rect), and a restored `/2 chroma height` diverts 4:2:2 squares onto | |
| 731 | -// the rect rows, so the witness gate reads 0 there and fails. | |
| 732 | -thread_local! { | |
| 733 | - pub(super) static CHROMA422_SQUARE_HITS: std::cell::Cell<usize> = | |
| 734 | - const { std::cell::Cell::new(0) }; | |
| 735 | -} | |
| 736 | - | |
| 737 | -/// Current value of [`CHROMA422_SQUARE_HITS`]. | |
| 738 | -// lane-av1-422b: `pub` so `examples/decode_probe.rs` can census it the way | |
| 739 | -// it does every other capability counter. | |
| 740 | -pub fn chroma422_square_hits() -> usize { | |
| 741 | - CHROMA422_SQUARE_HITS.with(|c| c.get()) | |
| 742 | -} | |
| 743 | - | |
| 744 | -// lane-av1422tailskip: how many 4:2:2 (ss 1,0) intra-in-inter chroma TRANSFORM | |
| 745 | -// UNITS took their own window on the block-sized chroma palette prediction -- | |
| 746 | -// `decode_inter_block`'s `side == 64` TX_32X32 walk, where the plane block is | |
| 747 | -// 32x64 but codes two stacked square units per plane. Zero on a 4:2:0 or 4:4:4 | |
| 748 | -// frame (their chroma unit is the whole plane block, one window), and zero on | |
| 749 | -// a 4:2:2 block with no palette, so a witness gate reading 0 proves the arm | |
| 750 | -// never ran. | |
| 751 | -thread_local! { | |
| 752 | - pub(super) static PALETTE_422_UNIT_WINDOW_HITS: std::cell::Cell<usize> = | |
| 753 | - const { std::cell::Cell::new(0) }; | |
| 754 | -} | |
| 755 | - | |
| 756 | -/// Current value of [`PALETTE_422_UNIT_WINDOW_HITS`]. | |
| 757 | -// lane-av1422tailskip: `pub` so `examples/decode_probe.rs` can census it the | |
| 758 | -// way it does every other capability counter. | |
| 759 | -pub fn palette_422_unit_window_hits() -> usize { | |
| 760 | - PALETTE_422_UNIT_WINDOW_HITS.with(|c| c.get()) | |
| 761 | -} | |
| 762 | - | |
| 763 | -// lane-av1-422f: how many RECT chroma coefficient units the square-block | |
| 764 | -// path read on a 4:2:2 frame (ss 1,0) -- TX_4X8 / TX_8X16 / TX_16X32, the | |
| 765 | -// plane block's own half-width, unhalved-height shape. A 4:2:0 or 4:4:4 | |
| 766 | -// frame never takes the rect branch (their units are square | |
| 767 | -// `chroma_tx == chroma_tx_h`), so a witness gate reading 0 here proves the | |
| 768 | -// model reverted to squares. | |
| 769 | -thread_local! { | |
| 770 | - pub(super) static CHROMA422_RECT_HITS: std::cell::Cell<usize> = | |
| 771 | - const { std::cell::Cell::new(0) }; | |
| 772 | -} | |
| 773 | - | |
| 774 | -/// Current value of [`CHROMA422_RECT_HITS`]. | |
| 775 | -pub fn chroma422_rect_hits() -> usize { | |
| 776 | - CHROMA422_RECT_HITS.with(|c| c.get()) | |
| 777 | -} | |
| 778 | - | |
| 779 | -// lane-av1-422g: how many PER-LEAF TX_4X4 chroma coefficient units the | |
| 780 | -// sub-8x8 split4 path read on a 4:2:2 frame (ss 1,0) -- one per even-column | |
| 781 | -// leaf per plane (`is_chroma_reference`'s `!(mi_col & ss_x)`). A 4:2:0 frame | |
| 782 | -// codes no sub-8 chroma at all and 4:4:4 goes through `sub8_leaf_chroma444`, | |
| 783 | -// so a witness gate reading 0 here proves the per-leaf 4:2:2 arm never ran. | |
| 784 | -thread_local! { | |
| 785 | - pub(super) static CHROMA422_SUB8_HITS: std::cell::Cell<usize> = | |
| 786 | - const { std::cell::Cell::new(0) }; | |
| 787 | -} | |
| 788 | - | |
| 789 | -/// Current value of [`CHROMA422_SUB8_HITS`]. | |
| 790 | -pub fn chroma422_sub8_hits() -> usize { | |
| 791 | - CHROMA422_SUB8_HITS.with(|c| c.get()) | |
| 792 | -} | |
| 793 | - | |
| 794 | -// lane-av1422llintra: how many 4:2:2 LOSSLESS chroma plane blocks | |
| 795 | -// (`decode_leaf8`) were walked as 4x4 units rather than as the one | |
| 796 | -// `av1_get_max_uv_txsize` rect that rule only reaches OUTSIDE a lossless | |
| 797 | -// frame. A 4:2:0 or 4:4:4 frame never takes the arm (its own lossless walk | |
| 798 | -// was already there), so a witness gate reading 0 here proves the model | |
| 799 | -// reverted to the rect unit. | |
| 800 | -thread_local! { | |
| 801 | - pub(super) static CHROMA422_LOSSLESS_4X4_HITS: std::cell::Cell<usize> = | |
| 802 | - const { std::cell::Cell::new(0) }; | |
| 803 | -} | |
| 804 | - | |
| 805 | -/// Current value of [`CHROMA422_LOSSLESS_4X4_HITS`]. | |
| 806 | -pub fn chroma422_lossless_4x4_hits() -> usize { | |
| 807 | - CHROMA422_LOSSLESS_4X4_HITS.with(|c| c.get()) | |
| 808 | -} | |
| 809 | - | |
| 810 | -// lane-av1-422sub8rect: how many PER-PIECE TX_4X4 chroma coefficient units | |
| 811 | -// the INTER sub-8x8 split4 path read on a 4:2:2 frame (ss 1,0) -- one per | |
| 812 | -// non-skipped odd-column piece per plane (`is_chroma_reference`'s | |
| 813 | -// `mi_col & 0x01` at ss_x 1). 4:2:0 goes through the shared group unit and | |
| 814 | -// 4:4:4 through [`sub8_leaf_chroma444`]'s own per-piece twin, so a witness | |
| 815 | -// gate reading 0 here proves the inter 4:2:2 per-piece arm never ran. | |
| 816 | -thread_local! { | |
| 817 | - pub(super) static CHROMA422_INTER_SUB8_HITS: std::cell::Cell<usize> = | |
| 818 | - const { std::cell::Cell::new(0) }; | |
| 819 | -} | |
| 820 | - | |
| 821 | -/// Current value of [`CHROMA422_INTER_SUB8_HITS`]. | |
| 822 | -pub fn chroma422_inter_sub8_hits() -> usize { | |
| 823 | - CHROMA422_INTER_SUB8_HITS.with(|c| c.get()) | |
| 824 | -} | |
| 825 | - | |
| 826 | -// lane-av1-422m: how many TX_4X4 chunk units the invalid-ss-size chroma arm | |
| 827 | -// read (the 8x32 luma block whose 4:2:2 plane has no `ss_size_lookup` block). | |
| 828 | -// A 4:2:0 or 4:4:4 frame cannot increment it, so a non-zero read proves the | |
| 829 | -// chunked 4:2:2 chroma really decoded. | |
| 830 | -thread_local! { | |
| 831 | - pub(super) static CHROMA422_CHUNK_HITS: std::cell::Cell<usize> = | |
| 832 | - const { std::cell::Cell::new(0) }; | |
| 833 | -} | |
| 834 | - | |
| 835 | -/// Current value of [`CHROMA422_CHUNK_HITS`]. | |
| 836 | -pub fn chroma422_chunk_hits() -> usize { | |
| 837 | - CHROMA422_CHUNK_HITS.with(|c| c.get()) | |
| 838 | -} | |
| 839 | - | |
| 840 | -// lane-av1-422stripanchor: how many 4-wide-strip PAIR chroma units | |
| 841 | -// ([`decode_rect_split`]'s ported floored-pair anchor) decoded. A 4:2:0 or | |
| 842 | -// 4:4:4 frame cannot increment it (the arm is keyed to a 2-px-wide chroma | |
| 843 | -// block, which only a 1-mi-wide strip at ss (1, 0) produces), so a non-zero | |
| 844 | -// read proves a stream routed a 4-wide strip through the split path. | |
| 845 | -thread_local! { | |
| 846 | - pub(super) static CHROMA422_PAIR_WIDE_HITS: std::cell::Cell<usize> = | |
| 847 | - const { std::cell::Cell::new(0) }; | |
| 848 | -} | |
| 849 | - | |
| 850 | -/// Current value of [`CHROMA422_PAIR_WIDE_HITS`]. | |
| 851 | -pub fn chroma422_pair_wide_hits() -> usize { | |
| 852 | - CHROMA422_PAIR_WIDE_HITS.with(|c| c.get()) | |
| 853 | -} | |
| 854 | - | |
| 855 | -// How many HORZ/VERT intra strips actually predicted with filter intra | |
| 856 | -// (lane-rectsplit r1) -- the case `decode_block_rect` refused by name | |
| 857 | -// ("this decoder predicts square-only") until `predict_filter_intra` took | |
| 858 | -// `bw`x`bh`. | |
| 859 | -thread_local! { | |
| 860 | - pub(super) static FILTER_INTRA_RECT_HITS: std::cell::Cell<usize> = | |
| 861 | - const { std::cell::Cell::new(0) }; | |
| 862 | -} | |
| 863 | - | |
| 864 | -/// Current value of [`FILTER_INTRA_RECT_HITS`]. | |
| 865 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 866 | -pub(crate) fn filter_intra_rect_hits() -> usize { | |
| 867 | - FILTER_INTRA_RECT_HITS.with(|c| c.get()) | |
| 868 | -} | |
| 869 | - | |
| 870 | -// As [`FILTER_INTRA_RECT_HITS`], counting only the 32x32-level 1:4 strips | |
| 871 | -// (32x8/8x32, lane-fi32x8 r1) -- the shapes whose `use_filter_intra` symbol | |
| 872 | -// was never read at all before that round, so a gate needs to prove the flag | |
| 873 | -// fired at THAT shape and not at a 16x8 one somewhere else in the frame. | |
| 874 | -// Split by ORIENTATION: rows 8 (32x8) and 9 (8x32) of `cdf::FILTER_INTRA` | |
| 875 | -// carry different probabilities (18101 vs 20229), so a transposed pair is | |
| 876 | -// only caught by a gate that sees the flag fire on BOTH shapes (class | |
| 877 | -// scan-weights-cross-axis). | |
| 878 | -thread_local! { | |
| 879 | - pub(super) static FILTER_INTRA_RECT4_HORZ_HITS: std::cell::Cell<usize> = | |
| 880 | - const { std::cell::Cell::new(0) }; | |
| 881 | - pub(super) static FILTER_INTRA_RECT4_VERT_HITS: std::cell::Cell<usize> = | |
| 882 | - const { std::cell::Cell::new(0) }; | |
| 883 | -} | |
| 884 | - | |
| 885 | -/// Current value of [`FILTER_INTRA_RECT4_HORZ_HITS`] (32x8 strips). | |
| 886 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 887 | -pub(crate) fn filter_intra_rect4_horz_hits() -> usize { | |
| 888 | - FILTER_INTRA_RECT4_HORZ_HITS.with(|c| c.get()) | |
| 889 | -} | |
| 890 | - | |
| 891 | -/// Current value of [`FILTER_INTRA_RECT4_VERT_HITS`] (8x32 strips). | |
| 892 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 893 | -pub(crate) fn filter_intra_rect4_vert_hits() -> usize { | |
| 894 | - FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.get()) | |
| 895 | -} | |
| 896 | - | |
| 897 | -// How many rectangular transform units actually coded coefficients through | |
| 898 | -// [`read_coeffs_rect`] (`all_zero == 0`) -- lane-rect1d's measure that a gate | |
| 899 | -// exercised the rect coefficient reader at all rather than passing on | |
| 900 | -// all-skip blocks. | |
| 901 | -thread_local! { | |
| 902 | - pub(super) static RECT_COEFF_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 903 | - pub(super) static RECT_CLASS1_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 904 | -} | |
| 905 | - | |
| 906 | -/// Current value of [`RECT_COEFF_TU_HITS`]. | |
| 907 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 908 | -pub(crate) fn rect_coeff_tu_hits() -> usize { | |
| 909 | - RECT_COEFF_TU_HITS.with(|c| c.get()) | |
| 910 | -} | |
| 911 | - | |
| 912 | -/// Rectangular transform units whose resolved `tx_type` is a 1D class | |
| 913 | -/// (`V_DCT`/`H_DCT`) -- [`TX_CLASS1_HITS`]'s rect-only half, so a gate can | |
| 914 | -/// pin that the 1D-class-on-a-RECT-transform path fired rather than settling | |
| 915 | -/// for the square reader's own 1D types. | |
| 916 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 917 | -pub(crate) fn rect_class1_hits() -> usize { | |
| 918 | - RECT_CLASS1_HITS.with(|c| c.get()) | |
| 919 | -} | |
| 920 | - | |
| 921 | -// lane-av1readcensus: the PER-UNIT coefficient census -- one unit counted | |
| 922 | -// per `read_coeffs`/`read_coeffs_rect` call, i.e. per object this decoder | |
| 923 | -// actually walks, which is the unit the round-4 `av1444rect` count measured | |
| 924 | -// (636 square chroma reads against the oracle's 1086). | |
| 925 | -// | |
| 926 | -// lane-av1422census422 widened the arming. The counters used to be | |
| 927 | -// 4:4:4-ONLY (`CENSUS_444`), so at 4:2:2 -- a chroma format an AV1 | |
| 928 | -// `color_config` can carry and libaom's writer emits -- every | |
| 929 | -// `census_444_units()` / `census_444_coded()` read zero BY CONSTRUCTION: a | |
| 930 | -// byte-exact 4:2:2 gate asserting those counters would be asserting a | |
| 931 | -// literal, and would be green while proving nothing about that stream. The | |
| 932 | -// census is now armed for every chroma format that leaves at least one luma | |
| 933 | -// axis unsubsampled -- (0,0) 4:4:4 and (1,0) 4:2:2 -- and 4:2:0 (1,1) stays | |
| 934 | -// off, so the existing 4:4:4 exact counts and the 4:2:0 zero control are | |
| 935 | -// unmoved by the widening. The counters are per-PLANE, not per-format, so a | |
| 936 | -// 4:2:2 cell's `[luma, u, v]` split is directly comparable with a 4:4:4 | |
| 937 | -// cell's on the same walk shape. | |
| 938 | -thread_local! { | |
| 939 | - /// Per-plane unit counts, `[luma, u, v]`, at 4:4:4 and 4:2:2. | |
| 940 | - pub(super) static CENSUS_NONSUB_UNITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; | |
| 941 | - /// Of [`CENSUS_NONSUB_UNITS`], the units that coded at least one | |
| 942 | - /// coefficient (`txb_skip == 0`) -- the per-plane split is only | |
| 943 | - /// comparable against the oracle's when both sides count all-zero units | |
| 944 | - /// the same way. | |
| 945 | - pub(super) static CENSUS_NONSUB_CODED: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; | |
| 946 | - /// Sequential unit index, so a trace line names its own position in the | |
| 947 | - /// frame's walk rather than relying on line order alone. | |
| 948 | - pub(super) static CENSUS_UNIT_N: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 949 | - /// The plane the units read from here on belong to. A thread-local rather | |
| 950 | - /// than a `read_coeffs` parameter because the three luma call sites | |
| 951 | - /// (`decode_rect_split`, `decode_block_rect64`, `read_inter_plane_rect`) | |
| 952 | - /// are not this lane's to edit and would each grow an argument; the | |
| 953 | - /// plane-owning readers stamp it once on entry instead. | |
| 954 | - pub(super) static CENSUS_PLANE: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 955 | - /// At least one luma axis unsubsampled -- (0,0) 4:4:4 or (1,0) 4:2:2 -- | |
| 956 | - /// for the frame being decoded, set per frame from [`crate::stream`]. | |
| 957 | - /// 4:2:0 (1,1) arms nothing. | |
| 958 | - pub(super) static CENSUS_NONSUB: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; | |
| 959 | -} | |
| 960 | - | |
| 961 | -/// Current `[luma, u, v]` coefficient-unit counts, per plane. Zero at 4:2:0 | |
| 962 | -/// by design ([`set_census_nonsub`] arms nothing there). | |
| 963 | -pub fn census_nonsub_units() -> [usize; 3] { | |
| 964 | - CENSUS_NONSUB_UNITS.with(|c| c.get()) | |
| 965 | -} | |
| 966 | - | |
| 967 | -/// Current `[luma, u, v]` counts of units that coded coefficients. | |
| 968 | -pub fn census_nonsub_coded() -> [usize; 3] { | |
| 969 | - CENSUS_NONSUB_CODED.with(|c| c.get()) | |
| 970 | -} | |
| 971 | - | |
| 972 | -/// lane-av1readcensus: arms the coefficient-unit census for the frame about | |
| 973 | -/// to decode, called once per frame from [`crate::stream`]'s decode loop | |
| 974 | -/// beside [`set_subsampling`]. Armed for every chroma format with an | |
| 975 | -/// unsubsampled luma axis -- 4:4:4 (0,0) and 4:2:2 (1,0) -- and NOT for | |
| 976 | -/// 4:2:0 (1,1), where the walk-shape question this census answers does not | |
| 977 | -/// arise, so a 4:2:0 control can still assert exactly zero. | |
| 978 | -/// | |
| 979 | -/// lane-av1422census422 widened this from `(ss_x == 0 && ss_y == 0)`. The | |
| 980 | -/// old condition made 4:2:2 silently UNCUNTABLE rather than uncounted. The | |
| 981 | -/// two format pairs keep disjoint conditions, so neither the 4:4:4 exact | |
| 982 | -/// counts nor the 4:2:0 zero control can move because of this. | |
| 983 | -pub(crate) fn set_census_nonsub(ss_x: u8, ss_y: u8) { | |
| 984 | - CENSUS_NONSUB.with(|c| c.set(ss_x == 0 || ss_y == 0)); | |
| 985 | -} | |
| 986 | - | |
| 987 | -/// lane-av1readcensus: the plane the units read from here on belong to, | |
| 988 | -/// stamped by the plane-owning readers ([`read_plane`], [`read_inter_plane`], | |
| 989 | -/// [`read_inter_plane_rect`]) on entry. | |
| 990 | -pub(crate) fn set_census_plane(plane: usize) { | |
| 991 | - CENSUS_PLANE.with(|c| c.set(plane)); | |
| 992 | -} | |
| 993 | - | |
| 994 | -/// lane-av1readcensus: is the per-unit census trace on? Shares | |
| 995 | -/// [`coeff_trace_on`]'s per-frame narrowing so one frame's walk can be | |
| 996 | -/// dumped without the rest of the stream. | |
| 997 | -fn census_trace_on() -> bool { | |
| 998 | - if !crate::envflags::env_flag!("EC_CENSUS_UNIT") { | |
| 999 | - return false; | |
| 1000 | - } | |
| 1001 | - match COEFF_TRACE_FRAME.with(|c| c.get()) { | |
| 1002 | - None => true, | |
| 1003 | - Some(w) if w >= usize::MAX - 1 => true, | |
| 1004 | - Some(w) => COEFF_TRACE_CUR.with(|c| c.get()) == w, | |
| 1005 | - } | |
| 1006 | -} | |
| 1007 | - | |
| 1008 | -/// lane-av1readcensus: one line per coefficient unit this decoder walks, the | |
| 1009 | -/// twin of the oracle's `EC_COEFF` / `EC_COEFF_VAL` bracket around each | |
| 1010 | -/// `av1_read_coeffs_txb` call. Pair the two sides by `post_rng` (or by `n`), | |
| 1011 | -/// never by plane label or by walk position -- the walk order is exactly what | |
| 1012 | -/// the census is measuring. | |
| 1013 | -pub(super) fn census_unit( | |
| 1014 | - w: usize, | |
| 1015 | - h: usize, | |
| 1016 | - tx_type: TxType, | |
| 1017 | - eob: usize, | |
| 1018 | - all_zero: bool, | |
| 1019 | - entry_rng: u32, | |
| 1020 | - dec: &SymbolDecoder, | |
| 1021 | -) { | |
| 1022 | - let plane = CENSUS_PLANE.with(|c| c.get()).min(2); | |
| 1023 | - let coded = usize::from(!all_zero); | |
| 1024 | - CENSUS_UNIT_N.with(|c| c.set(c.get() + 1)); | |
| 1025 | - hit_do! { | |
| 1026 | - CENSUS_NONSUB_UNITS.with(|c| { | |
| 1027 | - if CENSUS_NONSUB.with(|on| on.get()) { | |
| 1028 | - let mut v = c.get(); | |
| 1029 | - v[plane] += 1; | |
| 1030 | - c.set(v); | |
| 1031 | - } | |
| 1032 | - }); | |
| 1033 | - CENSUS_NONSUB_CODED.with(|c| { | |
| 1034 | - if CENSUS_NONSUB.with(|on| on.get()) { | |
| 1035 | - let mut v = c.get(); | |
| 1036 | - v[plane] += coded; | |
| 1037 | - c.set(v); | |
| 1038 | - } | |
| 1039 | - }); | |
| 1040 | - } | |
| 1041 | - if !census_trace_on() { | |
| 1042 | - return; | |
| 1043 | - } | |
| 1044 | - let n = CENSUS_UNIT_N.with(|c| c.get()) - 1; | |
| 1045 | - let post_rng = dec.debug_state().0; | |
| 1046 | - eprintln!( | |
| 1047 | - "EC_CENSUS_UNIT side=ours n={n} plane={plane} w={w} h={h} tx={tx_type:?} eob={eob} \ | |
| 1048 | - all_zero={all_zero} entry_rng={entry_rng} post_rng={post_rng}" | |
| 1049 | - ); | |
| 1050 | -} | |
| 1051 | - | |
| 1052 | -/// How many transform units this thread has read since the last | |
| 1053 | -/// [`reset_census_unit_n`] (lane-av1offtile). The per-unit oracle twin is | |
| 1054 | -/// `EC_ECDUMP_IN`, one line per `read_coeffs_txb` call, so this count IS | |
| 1055 | -/// directly comparable with an oracle `EC_ECDUMP_IN` census -- which is what | |
| 1056 | -/// makes "we walk N units where libaom walks M" a gated claim rather than an | |
| 1057 | -/// inference from the desync's position. | |
| 1058 | -pub fn census_unit_n() -> usize { | |
| 1059 | - CENSUS_UNIT_N.with(|c| c.get()) | |
| 1060 | -} | |
| 1061 | - | |
| 1062 | -/// Reset [`census_unit_n`] to zero (lane-av1offtile). | |
| 1063 | -pub fn reset_census_unit_n() { | |
| 1064 | - CENSUS_UNIT_N.with(|c| c.set(0)); | |
| 1065 | -} | |
| 1066 | - | |
| 1067 | -// As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16 | |
| 1068 | -// (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the | |
| 1069 | -// shapes whose `use_filter_intra` symbol had no CDF class before this round. | |
| 1070 | -// A gate asserting the wider counter would be satisfied by a 32x16 strip and | |
| 1071 | -// prove nothing about the new shapes. | |
| 1072 | -thread_local! { | |
| 1073 | - pub(super) static FILTER_INTRA_RECT_SUB16_HITS: std::cell::Cell<usize> = | |
| 1074 | - const { std::cell::Cell::new(0) }; | |
| 1075 | -} | |
| 1076 | - | |
| 1077 | -/// Current value of [`FILTER_INTRA_RECT_SUB16_HITS`]. | |
| 1078 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1079 | -pub(crate) fn filter_intra_rect_sub16_hits() -> usize { | |
| 1080 | - FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get()) | |
| 1081 | -} | |
| 1082 | - | |
| 1083 | -// As [`FILTER_INTRA_RECT_SUB16_HITS`], one partition level further down: | |
| 1084 | -// 4x8/8x4 leaves of an 8x8 HORZ/VERT (lane-fi8 r1). A gate on the sub16 | |
| 1085 | -// counter would be satisfied by a 16x8 strip and prove nothing here. | |
| 1086 | -thread_local! { | |
| 1087 | - pub(super) static FILTER_INTRA_RECT_SUB8_HITS: std::cell::Cell<usize> = | |
| 1088 | - const { std::cell::Cell::new(0) }; | |
| 1089 | -} | |
| 1090 | - | |
| 1091 | -/// Current value of [`FILTER_INTRA_RECT_SUB8_HITS`]. | |
| 1092 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1093 | -pub(crate) fn filter_intra_rect_sub8_hits() -> usize { | |
| 1094 | - FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.get()) | |
| 1095 | -} | |
| 1096 | - | |
| 1097 | -// How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D` | |
| 1098 | -// (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every | |
| 1099 | -// call on the current thread -- the same before/after counter pattern as | |
| 1100 | -// [`TX_DEPTH_HITS`], proving a stream actually exercised the class-split | |
| 1101 | -// `eob_pt`/1D-neighbour context path rather than every block coincidentally | |
| 1102 | -// landing on `DCT_DCT`. | |
| 1103 | -thread_local! { | |
| 1104 | - pub(super) static TX_CLASS1_HITS: std::cell::Cell<usize> = | |
| 1105 | - const { std::cell::Cell::new(0) }; | |
| 1106 | -} | |
| 1107 | - | |
| 1108 | -// How many `uv_mode` reads resolved to a directional chroma mode (neither | |
| 1109 | -// `DC_PRED` nor `UV_CFL_PRED`), across every call on the current thread -- the same | |
| 1110 | -// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream | |
| 1111 | -// actually exercised chroma's own directional predictor. | |
| 1112 | -thread_local! { | |
| 1113 | - pub(super) static DIRECTIONAL_UV_HITS: std::cell::Cell<usize> = | |
| 1114 | - const { std::cell::Cell::new(0) }; | |
| 1115 | -} | |
| 1116 | - | |
| 1117 | -/// Current value of [`DIRECTIONAL_UV_HITS`]. | |
| 1118 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1119 | -pub(crate) fn directional_uv_hits() -> usize { | |
| 1120 | - DIRECTIONAL_UV_HITS.with(|c| c.get()) | |
| 1121 | -} | |
| 1122 | - | |
| 1123 | -// How many `angle_delta`/`angle_delta_uv` symbols this decoder has read as | |
| 1124 | -// something other than [`ANGLE_DELTA_ZERO`], across every call in the | |
| 1125 | -// process -- the same before/after counter pattern as [`FILTER_INTRA_HITS`], | |
| 1126 | -// proving a stream actually exercised a nonzero angle delta. | |
| 1127 | -thread_local! { | |
| 1128 | - pub(super) static ANGLE_DELTA_HITS: std::cell::Cell<usize> = | |
| 1129 | - const { std::cell::Cell::new(0) }; | |
| 1130 | -} | |
| 1131 | - | |
| 1132 | -// How many [`read_single_ref`] reads resolved to a reference other than | |
| 1133 | -// `LAST_FRAME`, across every call on the current thread -- the same before/after | |
| 1134 | -// counter pattern as [`FILTER_INTRA_HITS`], proving a stream actually | |
| 1135 | -// exercised a non-`LAST_FRAME` reference (`GOLDEN_FRAME`, this decoder's | |
| 1136 | -// only other supported one so far) rather than every block coincidentally | |
| 1137 | -// resolving `LAST_FRAME`. | |
| 1138 | -thread_local! { | |
| 1139 | - pub(super) static NON_LAST_REF_HITS: std::cell::Cell<usize> = | |
| 1140 | - const { std::cell::Cell::new(0) }; | |
| 1141 | -} | |
| 1142 | - | |
| 1143 | -/// Current value of [`NON_LAST_REF_HITS`]. | |
| 1144 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1145 | -pub(crate) fn non_last_ref_hits() -> usize { | |
| 1146 | - NON_LAST_REF_HITS.with(|c| c.get()) | |
| 1147 | -} | |
| 1148 | - | |
| 1149 | -// Per-reference [`NON_LAST_REF_HITS`] breakdown (lane-av1refs): one counter | |
| 1150 | -// per `MV_REFERENCE_FRAME` past `LAST_FRAME`, so a gate targeting one | |
| 1151 | -// specific reference (`LAST2`/`LAST3`/`GOLDEN`/`BWDREF`/`ALTREF2`/`ALTREF`) | |
| 1152 | -// can prove THAT reference fired rather than any non-`LAST_FRAME` one -- | |
| 1153 | -// `NON_LAST_REF_HITS` alone cannot tell a `LAST2_FRAME` gate from a | |
| 1154 | -// `GOLDEN_FRAME` draw it did not ask for. | |
| 1155 | -thread_local! { | |
| 1156 | - pub(super) static LAST2_HITS: std::cell::Cell<usize> = | |
| 1157 | - const { std::cell::Cell::new(0) }; | |
| 1158 | -} | |
| 1159 | - | |
| 1160 | -thread_local! { | |
| 1161 | - pub(super) static LAST3_HITS: std::cell::Cell<usize> = | |
| 1162 | - const { std::cell::Cell::new(0) }; | |
| 1163 | -} | |
| 1164 | - | |
| 1165 | -thread_local! { | |
| 1166 | - pub(super) static GOLDEN_HITS: std::cell::Cell<usize> = | |
| 1167 | - const { std::cell::Cell::new(0) }; | |
| 1168 | -} | |
| 1169 | - | |
| 1170 | -thread_local! { | |
| 1171 | - pub(super) static BWDREF_HITS: std::cell::Cell<usize> = | |
| 1172 | - const { std::cell::Cell::new(0) }; | |
| 1173 | -} | |
| 1174 | - | |
| 1175 | -thread_local! { | |
| 1176 | - pub(super) static ALTREF2_HITS: std::cell::Cell<usize> = | |
| 1177 | - const { std::cell::Cell::new(0) }; | |
| 1178 | -} | |
| 1179 | - | |
| 1180 | -thread_local! { | |
| 1181 | - pub(super) static ALTREF_HITS: std::cell::Cell<usize> = | |
| 1182 | - const { std::cell::Cell::new(0) }; | |
| 1183 | -} | |
| 1184 | - | |
| 1185 | -// How many [`read_comp_mode`] reads resolved `COMPOUND_REFERENCE` (lane-av1comp) | |
| 1186 | -// -- proves a `reference_select` stream actually reached a block that picked | |
| 1187 | -// compound, not just that the header bit was set. Every such block is | |
| 1188 | -// refused after this fires ([`decode_inter_block`]/[`decode_inter_block8`]), | |
| 1189 | -// so this only ever counts attempted reads, never a completed decode. | |
| 1190 | -thread_local! { | |
| 1191 | - pub(super) static COMP_MODE_HITS: std::cell::Cell<usize> = | |
| 1192 | - const { std::cell::Cell::new(0) }; | |
| 1193 | -} | |
| 1194 | - | |
| 1195 | -/// Current value of [`COMP_MODE_HITS`]. | |
| 1196 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1197 | -pub(crate) fn comp_mode_hits() -> usize { | |
| 1198 | - COMP_MODE_HITS.with(|c| c.get()) | |
| 1199 | -} | |
| 1200 | - | |
| 1201 | -// How many blocks [`read_intra_mode`] decoded a real (nonzero-size) palette-Y | |
| 1202 | -// use for, across every call on the current thread -- the same before/after | |
| 1203 | -// counter pattern as [`FILTER_INTRA_HITS`], proving a stream actually | |
| 1204 | -// exercised palette reconstruction rather than only reading and refusing the | |
| 1205 | -// `palette_y_mode` symbol. | |
| 1206 | -thread_local! { | |
| 1207 | - pub(super) static PALETTE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1208 | -} | |
| 1209 | - | |
| 1210 | -/// Current value of [`PALETTE_HITS`]. | |
| 1211 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1212 | -pub(crate) fn palette_hits() -> usize { | |
| 1213 | - PALETTE_HITS.with(|c| c.get()) | |
| 1214 | -} | |
| 1215 | - | |
| 1216 | -// lane-tiles r12: of those, how many sat at their own TILE's left column -- | |
| 1217 | -// exactly the blocks whose palette cache/ctx must NOT see the previous tile's | |
| 1218 | -// colours (`av1_get_palette_cache`'s `xd->left_mbmi == NULL`). A multi-tile | |
| 1219 | -// palette gate that never hits one proves nothing about the tile guard. | |
| 1220 | -thread_local! { | |
| 1221 | - pub(super) static PALETTE_TILE_LEFT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1222 | -} | |
| 1223 | - | |
| 1224 | -/// Current value of [`PALETTE_TILE_LEFT_HITS`]. | |
| 1225 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1226 | -pub(crate) fn palette_tile_left_hits() -> usize { | |
| 1227 | - PALETTE_TILE_LEFT_HITS.with(|c| c.get()) | |
| 1228 | -} | |
| 1229 | - | |
| 1230 | -// lane-palette2 r1: as [`PALETTE_HITS`], for a real (nonzero-size) chroma | |
| 1231 | -// palette use -- proves a stream actually reconstructed UV palette pixels, | |
| 1232 | -// not just read and refused the `palette_uv_mode` symbol. | |
| 1233 | -thread_local! { | |
| 1234 | - pub(super) static PALETTE_UV_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1235 | -} | |
| 1236 | - | |
| 1237 | -/// Current value of [`PALETTE_UV_HITS`]. | |
| 1238 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1239 | -pub(crate) fn palette_uv_hits() -> usize { | |
| 1240 | - PALETTE_UV_HITS.with(|c| c.get()) | |
| 1241 | -} | |
| 1242 | - | |
| 1243 | -// lane-palette2 r1: how many HORZ/VERT rect intra strips ([`read_intra_mode_rect`]) | |
| 1244 | -// decoded a real palette-Y use -- proves the rect strip's own palette syntax | |
| 1245 | -// (not just the square path's) actually fired. | |
| 1246 | -thread_local! { | |
| 1247 | - pub(super) static PALETTE_RECT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1248 | -} | |
| 1249 | - | |
| 1250 | -/// Current value of [`PALETTE_RECT_HITS`]. | |
| 1251 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1252 | -pub(crate) fn palette_rect_hits() -> usize { | |
| 1253 | - PALETTE_RECT_HITS.with(|c| c.get()) | |
| 1254 | -} | |
| 1255 | - | |
| 1256 | -// lane-palette2 r6: how many HORZ/VERT rect intra strips ran the | |
| 1257 | -// [`palette_bsize_ctx_wh`]-gated code path in [`read_intra_mode_rect`] -- | |
| 1258 | -// i.e. `allow_screen_content_tools` was set and the strip's `bw`x`bh` was in | |
| 1259 | -// range, so `palette_y_mode`/`palette_uv_mode` were actually read (and, per | |
| 1260 | -// RD, almost always refused-on-use because the block doesn't end up USING a | |
| 1261 | -// palette -- see r5's report). This is the site the removed refusal | |
| 1262 | -// ("a HORZ/VERT intra strip in a screen-content frame") used to guard: it | |
| 1263 | -// fired here whether or not the block picked a palette, so this is the | |
| 1264 | -// counter that proves the case r5's narrower [`PALETTE_RECT_HITS`] almost | |
| 1265 | -// never observes. | |
| 1266 | -thread_local! { | |
| 1267 | - pub(super) static RECT_SCREEN_CONTENT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1268 | -} | |
| 1269 | - | |
| 1270 | -/// Current value of [`RECT_SCREEN_CONTENT_HITS`]. | |
| 1271 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1272 | -pub(crate) fn rect_screen_content_hits() -> usize { | |
| 1273 | - RECT_SCREEN_CONTENT_HITS.with(|c| c.get()) | |
| 1274 | -} | |
| 1275 | - | |
| 1276 | -// lane-palette2 r1: how many palette-Y luma transform UNITS decoded under a | |
| 1277 | -// split luma transform (`logical_tx != side`) -- proves the per-TU index-map | |
| 1278 | -// windowing actually ran, not just that the whole-block path stayed exact. | |
| 1279 | -// Counts units, not blocks (a 64x64 palette block split to 16x16 TUs adds 16); | |
| 1280 | -// first actually incremented in r7, when the refusal it guarded was lifted. | |
| 1281 | -thread_local! { | |
| 1282 | - pub(super) static PALETTE_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1283 | -} | |
| 1284 | - | |
| 1285 | -thread_local! { | |
| 1286 | - /// lane-kf900 r4: rect intra strips that ACTUALLY use a palette -- the | |
| 1287 | - /// 1:4 shapes (32x8/8x32, 16x4/4x16) and the sub-16x16 2:1 leaves | |
| 1288 | - /// (16x8/8x16), the two shapes the lifted refusals named. | |
| 1289 | - pub(super) static RECT4_PALETTE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1290 | -} | |
| 1291 | - | |
| 1292 | -/// Current value of [`RECT4_PALETTE_HITS`]. | |
| 1293 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1294 | -pub(crate) fn rect4_palette_hits() -> usize { | |
| 1295 | - RECT4_PALETTE_HITS.with(|c| c.get()) | |
| 1296 | -} | |
| 1297 | - | |
| 1298 | -/// Current value of [`PALETTE_SPLIT_TX_HITS`]. | |
| 1299 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1300 | -pub(crate) fn palette_split_tx_hits() -> usize { | |
| 1301 | - PALETTE_SPLIT_TX_HITS.with(|c| c.get()) | |
| 1302 | -} | |
| 1303 | - | |
| 1304 | -thread_local! { | |
| 1305 | - /// lane-av1444d10: chroma PREDICTION units on the 32-capped tiled chroma | |
| 1306 | - /// walk (`decode_block_rect`'s `uw/uh = min(chroma, 32)` units) that were | |
| 1307 | - /// handed a STRICT sub-slice of their block's palette buffer -- i.e. the | |
| 1308 | - /// units of a block the 32-cap actually TILED (`nw * nh > 1`). | |
| 1309 | - /// | |
| 1310 | - /// CORRECTED 2026-09-30 after the refutation pass `lanes/refute-av1444d10` | |
| 1311 | - /// read the numbers back: the previous comment claimed it counted "the | |
| 1312 | - /// units that are NOT the block's top-left corner", which is not what the | |
| 1313 | - /// code did -- the hit was unconditional, so a block's corner unit fired it | |
| 1314 | - /// too AND a single-unit block (whose window is a pure re-stride copy of | |
| 1315 | - /// the whole buffer) fired it as well. That made a hit prove only that some | |
| 1316 | - /// palette chroma block existed, not that the tiled arm ran. The `bigger` | |
| 1317 | - /// guard now makes the counter discriminate. On the pinned fixture the | |
| 1318 | - /// measured value is unchanged at 4 (one block with nw = 1, nh = 2 x two | |
| 1319 | - /// planes x two unit rows); a stream whose palette chroma blocks are all | |
| 1320 | - /// single-unit now leaves it at zero. | |
| 1321 | - /// | |
| 1322 | - /// FURTHER CORRECTED the same day by the palette lane's refutation | |
| 1323 | - /// (`lanes/av1444palw.report.md` + the arm-isolated mutation): the guard is | |
| 1324 | - /// about TILING, not about `nw > 1` specifically. Isolating the two window | |
| 1325 | - /// sites shows the RECT-unit arm alone reds the 10-bit cell, and the | |
| 1326 | - /// SQUARE-unit arm alone reds the 12-bit cell *and* the 10-bit one -- so | |
| 1327 | - /// windowing is load-bearing for every tiled block, and `nw > 1` is merely | |
| 1328 | - /// the case the corpus could not reach. Do not read this counter as | |
| 1329 | - /// evidence that only the horizontal term matters. | |
| 1330 | - pub(super) static CHROMA_PALETTE_WINDOW_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1331 | -} | |
| 1332 | - | |
| 1333 | -/// Current value of [`CHROMA_PALETTE_WINDOW_HITS`]. | |
| 1334 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1335 | -pub(crate) fn chroma_palette_window_hits() -> usize { | |
| 1336 | - CHROMA_PALETTE_WINDOW_HITS.with(|c| c.get()) | |
| 1337 | -} | |
| 1338 | - | |
| 1339 | -/// Zeroes [`CHROMA_PALETTE_WINDOW_HITS`] so a gate can read it as a DELTA | |
| 1340 | -/// (it is process-wide, like every counter here). | |
| 1341 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1342 | -pub(crate) fn reset_chroma_palette_window_hits() { | |
| 1343 | - CHROMA_PALETTE_WINDOW_HITS.with(|c| c.set(0)); | |
| 1344 | -} | |
| 1345 | - | |
| 1346 | -thread_local! { | |
| 1347 | - /// lane-pal8 r1: square 8x8 LEAVES ([`decode_leaf8`]) that actually use a | |
| 1348 | - /// palette (Y or UV) -- the shape every 8-bit `--tune-content=screen` | |
| 1349 | - /// stream stopped on, since aomenc palettes square blocks at 8 bit and | |
| 1350 | - /// `--min-partition-size=8` puts them on this leaf path. | |
| 1351 | - pub(super) static PALETTE_LEAF8_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1352 | -} | |
| 1353 | - | |
| 1354 | -/// Current value of [`PALETTE_LEAF8_HITS`]. | |
| 1355 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1356 | -pub(crate) fn palette_leaf8_hits() -> usize { | |
| 1357 | - PALETTE_LEAF8_HITS.with(|c| c.get()) | |
| 1358 | -} | |
| 1359 | - | |
| 1360 | -/// Zeroes [`PALETTE_LEAF8_HITS`] (per-attempt gate counting). | |
| 1361 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1362 | -pub(crate) fn reset_palette_leaf8_hits() { | |
| 1363 | - PALETTE_LEAF8_HITS.with(|c| c.set(0)); | |
| 1364 | -} | |
| 1365 | - | |
| 1366 | -thread_local! { | |
| 1367 | - /// lane-pal8 r1: NON-SKIP palette blocks on a superblock-level (64-level) | |
| 1368 | - /// HORZ/VERT or 1:4 strip ([`decode_block_rect64`]) -- i.e. a palette | |
| 1369 | - /// block that also carries a real, corner-cropped luma transform. | |
| 1370 | - pub(super) static PALETTE_SB_STRIP_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1371 | -} | |
| 1372 | - | |
| 1373 | -/// Current value of [`PALETTE_SB_STRIP_HITS`]. | |
| 1374 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1375 | -pub(crate) fn palette_sb_strip_hits() -> usize { | |
| 1376 | - PALETTE_SB_STRIP_HITS.with(|c| c.get()) | |
| 1377 | -} | |
| 1378 | - | |
| 1379 | -/// Zeroes [`PALETTE_SB_STRIP_HITS`] (per-attempt gate counting). | |
| 1380 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1381 | -pub(crate) fn reset_palette_sb_strip_hits() { | |
| 1382 | - PALETTE_SB_STRIP_HITS.with(|c| c.set(0)); | |
| 1383 | -} | |
| 1384 | - | |
| 1385 | -thread_local! { | |
| 1386 | - /// lane-av1rectreach: units of `decode_rect_split`'s `chroma_tiled` walk | |
| 1387 | - /// whose PER-UNIT reach ([`tu_reach_rect`], libaom's per-unit | |
| 1388 | - /// `has_top_right` / `has_bottom_left`) DIFFERS from the block-level | |
| 1389 | - /// `reach` this walk used to hand every unit -- i.e. units for which the | |
| 1390 | - /// two answers are not interchangeable. This is what a gate needs before | |
| 1391 | - /// it compares the walk byte-exactly: if the two agreed everywhere, the | |
| 1392 | - /// substitution could not change a single predicted sample and the | |
| 1393 | - /// exactness assert would be measuring a witness the fix cannot touch. | |
| 1394 | - /// | |
| 1395 | - /// What it does NOT prove is that the argument handed to the unit reader | |
| 1396 | - /// is the per-unit one -- the count is taken from the same expression | |
| 1397 | - /// either way, so deleting the substitution reds the exactness assert | |
| 1398 | - /// rather than this counter. That is the right way round: the assert is | |
| 1399 | - /// the claim, this is only the floor under it. | |
| 1400 | - pub(super) static RECT_TILED_CHROMA_UNIT_REACH_HITS: std::cell::Cell<usize> = | |
| 1401 | - const { std::cell::Cell::new(0) }; | |
| 1402 | - /// Chroma units of the same walk whose grid is exactly 2x1 (a 4:4:4 | |
| 1403 | - /// 64x32 chroma plane block as two 32x32 units). | |
| 1404 | - pub(super) static RECT_TILED_CHROMA_2X1_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1405 | - /// Chroma units of the same walk whose grid is exactly 1x2 (4:4:4 32x64, | |
| 1406 | - /// or 16x64 as two 16x32s). | |
| 1407 | - pub(super) static RECT_TILED_CHROMA_1X2_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1408 | - /// Chroma units of the same walk in any other multi-unit grid (2x2 and | |
| 1409 | - /// up). lane-av1422lift: this used to say "only reachable at 4:2:2, which | |
| 1410 | - /// is refused, so this stays 0 on every admitted stream", and that was | |
| 1411 | - /// true. 4:2:2 is decoded now, so the "cannot happen" is gone -- but the | |
| 1412 | - /// arm is still UNWITNESSED: measured on this branch's tip over all 21 | |
| 1413 | - /// committed 4:2:2 cells and over the 4:2:0 / 4:4:4 cells probed, it | |
| 1414 | - /// reads 0 on every one of them. No committed gate reads it either (the | |
| 1415 | - /// only readers of `rect_tiled_chroma_grid_hits()` are two 4:4:4 strip | |
| 1416 | - /// gates, where `nxn` is interpolated into a failure message and never | |
| 1417 | - /// asserted). Kept so the match above is exhaustive. | |
| 1418 | - pub(super) static RECT_TILED_CHROMA_NXN_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1419 | -} | |
| 1420 | - | |
| 1421 | -/// Current values of the four `RECT_TILED_CHROMA_*` counters, in the order | |
| 1422 | -/// `(unit_reach_differs, 2x1, 1x2, other multi-unit)`. | |
| 1423 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1424 | -pub(crate) fn rect_tiled_chroma_grid_hits() -> (usize, usize, usize, usize) { | |
| 1425 | - ( | |
| 1426 | - RECT_TILED_CHROMA_UNIT_REACH_HITS.with(|c| c.get()), | |
| 1427 | - RECT_TILED_CHROMA_2X1_HITS.with(|c| c.get()), | |
| 1428 | - RECT_TILED_CHROMA_1X2_HITS.with(|c| c.get()), | |
| 1429 | - RECT_TILED_CHROMA_NXN_HITS.with(|c| c.get()), | |
| 1430 | - ) | |
| 1431 | -} | |
| 1432 | - | |
| 1433 | -/// Zeroes the four `RECT_TILED_CHROMA_*` counters (gate tests call this | |
| 1434 | -/// before their own decode). | |
| 1435 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1436 | -pub(crate) fn reset_rect_tiled_chroma_grid_hits() { | |
| 1437 | - RECT_TILED_CHROMA_UNIT_REACH_HITS.with(|c| c.set(0)); | |
| 1438 | - RECT_TILED_CHROMA_2X1_HITS.with(|c| c.set(0)); | |
| 1439 | - RECT_TILED_CHROMA_1X2_HITS.with(|c| c.set(0)); | |
| 1440 | - RECT_TILED_CHROMA_NXN_HITS.with(|c| c.set(0)); | |
| 1441 | -} | |
| 1442 | - | |
| 1443 | -// lane-t900 r22: palette blocks reconstructed inside an INTER frame (the | |
| 1444 | -// intra-in-inter path, `decode_inter_block`/`decode_inter_block8`) -- counted | |
| 1445 | -// apart from [`PALETTE_HITS`] so a witness gate can prove the INTER-frame | |
| 1446 | -// capability rather than the key frame's, which every screen stream also | |
| 1447 | -// carries. | |
| 1448 | -thread_local! { | |
| 1449 | - pub(super) static INTRA_IN_INTER_PALETTE_Y_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1450 | - pub(super) static INTRA_IN_INTER_PALETTE_UV_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1451 | -} | |
| 1452 | - | |
| 1453 | -// lane-t900 r23: as [`INTRA_IN_INTER_PALETTE_Y_HITS`], narrowed to the 8x8 | |
| 1454 | -// LEAF site ([`decode_inter_block8`]'s intra arm) -- the >=16 site fires the | |
| 1455 | -// shared counter too, so only this one proves a gate really reached the leaf | |
| 1456 | -// where the refusal used to sit. | |
| 1457 | -thread_local! { | |
| 1458 | - pub(super) static INTER8_PALETTE_HITS: std::cell::Cell<(usize, usize)> = | |
| 1459 | - const { std::cell::Cell::new((0, 0)) }; | |
| 1460 | -} | |
| 1461 | - | |
| 1462 | -/// Current values of the 8x8-leaf intra-in-inter palette counters, `(y, uv)`. | |
| 1463 | -pub(crate) fn inter8_palette_hits() -> (usize, usize) { | |
| 1464 | - INTER8_PALETTE_HITS.with(std::cell::Cell::get) | |
| 1465 | -} | |
| 1466 | - | |
| 1467 | -/// Current values of the two intra-in-inter palette counters, `(y, uv)`. | |
| 1468 | -pub(crate) fn intra_in_inter_palette_hits() -> (usize, usize) { | |
| 1469 | - ( | |
| 1470 | - INTRA_IN_INTER_PALETTE_Y_HITS.with(|c| c.get()), | |
| 1471 | - INTRA_IN_INTER_PALETTE_UV_HITS.with(|c| c.get()), | |
| 1472 | - ) | |
| 1473 | -} | |
| 1474 | - | |
| 1475 | -// lane-hgkf r2: SKIPPED intra blocks whose `tx_depth` split the luma transform | |
| 1476 | -// and which are therefore predicted one transform unit at a time (a skipped | |
| 1477 | -// block codes no coefficients, so nothing else in the stream witnesses this | |
| 1478 | -// path -- only the pixels do). | |
| 1479 | -thread_local! { | |
| 1480 | - pub(super) static SKIP_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1481 | -} | |
| 1482 | - | |
| 1483 | -/// Current value of [`SKIP_SPLIT_TX_HITS`] (blocks, not units). | |
| 1484 | -pub fn skip_split_tx_hits() -> usize { | |
| 1485 | - SKIP_SPLIT_TX_HITS.with(|c| c.get()) | |
| 1486 | -} | |
| 1487 | - | |
| 1488 | -// lane-svt1: SKIPPED square blocks carrying a palette/intrabc prediction whose | |
| 1489 | -// `tx_depth` split the luma transform -- the arm that predicted DC off the | |
| 1490 | -// block edges before the fix. Like [`SKIP_SPLIT_TX_HITS`] only the pixels | |
| 1491 | -// witness this path, so a gate that wants it needs the counter. | |
| 1492 | -thread_local! { | |
| 1493 | - pub(super) static SKIP_SPLIT_TX_OVERRIDE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1494 | - /// lane-av1chromadc: chroma units of a skipped block whose intra-BC / | |
| 1495 | - /// UV-palette override had to be WINDOWED to the unit's own extent -- | |
| 1496 | - /// i.e. `cn_cols * cn_rows > 1`, which at 4:2:0 never happens (the chroma | |
| 1497 | - /// plane block is one 32x32 unit) and at 4:4:4 is every block of 64 and | |
| 1498 | - /// above. Counts UNITS, not blocks. EXCLUSIVE to this walk: the other two | |
| 1499 | - /// override sites (the luma slot and `decode_intrabc_owned_rect`) have | |
| 1500 | - /// their own windows. | |
| 1501 | - pub(super) static SKIP_CHROMA_OVERRIDE_WINDOW_HITS: std::cell::Cell<usize> = | |
| 1502 | - const { std::cell::Cell::new(0) }; | |
| 1503 | -} | |
| 1504 | - | |
| 1505 | -/// Current value of [`SKIP_SPLIT_TX_OVERRIDE_HITS`] (blocks). | |
| 1506 | -pub fn skip_split_tx_override_hits() -> usize { | |
| 1507 | - SKIP_SPLIT_TX_OVERRIDE_HITS.with(|c| c.get()) | |
| 1508 | -} | |
| 1509 | - | |
| 1510 | -/// lane-av1chromadc: [`SKIP_CHROMA_OVERRIDE_WINDOW_HITS`]. | |
| 1511 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1512 | -pub fn skip_chroma_override_window_hits() -> usize { | |
| 1513 | - SKIP_CHROMA_OVERRIDE_WINDOW_HITS.with(|c| c.get()) | |
| 1514 | -} | |
| 1515 | - | |
| 1516 | -/// Zeroes [`SKIP_CHROMA_OVERRIDE_WINDOW_HITS`] before a gate's own decode. | |
| 1517 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1518 | -pub fn reset_skip_chroma_override_window_hits() { | |
| 1519 | - SKIP_CHROMA_OVERRIDE_WINDOW_HITS.with(|c| c.set(0)); | |
| 1520 | -} | |
| 1521 | - | |
| 1522 | -/// Zeroes [`SKIP_SPLIT_TX_OVERRIDE_HITS`] before a gate's own decode attempt. | |
| 1523 | -pub fn reset_skip_split_tx_override_hits() { | |
| 1524 | - SKIP_SPLIT_TX_OVERRIDE_HITS.with(|c| c.set(0)); | |
| 1525 | -} | |
| 1526 | - | |
| 1527 | -// lane-svtinter: palette colour-index maps whose block is cut by the frame's | |
| 1528 | -// bottom/right mi edge, so spec 5.11.50's `onscreenWidth`/`onscreenHeight` | |
| 1529 | -// really are smaller than the block and FEWER symbols are read than the | |
| 1530 | -// block has cells (class map-read-past-frame-edge). | |
| 1531 | -thread_local! { | |
| 1532 | - pub(super) static PALETTE_ONSCREEN_CUT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1533 | -} | |
| 1534 | - | |
| 1535 | -/// Current value of [`PALETTE_ONSCREEN_CUT_HITS`] (colour-index maps). | |
| 1536 | -pub fn palette_onscreen_cut_hits() -> usize { | |
| 1537 | - PALETTE_ONSCREEN_CUT_HITS.with(|c| c.get()) | |
| 1538 | -} | |
| 1539 | - | |
| 1540 | -/// Zeroes [`PALETTE_ONSCREEN_CUT_HITS`] before a gate's own decode attempt. | |
| 1541 | -pub fn reset_palette_onscreen_cut_hits() { | |
| 1542 | - PALETTE_ONSCREEN_CUT_HITS.with(|c| c.set(0)); | |
| 1543 | -} | |
| 1544 | - | |
| 1545 | -/// Zeroes [`SKIP_SPLIT_TX_HITS`] before a gate's own decode attempt. | |
| 1546 | -pub fn reset_skip_split_tx_hits() { | |
| 1547 | - SKIP_SPLIT_TX_HITS.with(|c| c.set(0)); | |
| 1548 | -} | |
| 1549 | - | |
| 1550 | -// lane-intrainter r1: intra blocks inside an INTER frame whose `tx_depth` | |
| 1551 | -// symbol split their luma transform, bucketed by block side (8, 16, 32, 64) -- | |
| 1552 | -// the gate's proof that the lifted path actually ran, per size. | |
| 1553 | -thread_local! { | |
| 1554 | - pub(super) static INTRA_IN_INTER_SPLIT_TX_HITS: std::cell::Cell<[usize; 4]> = | |
| 1555 | - const { std::cell::Cell::new([0; 4]) }; | |
| 1556 | -} | |
| 1557 | - | |
| 1558 | -/// Current value of [`INTRA_IN_INTER_SPLIT_TX_HITS`], indexed 8/16/32/64. | |
| 1559 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1560 | -pub(crate) fn intra_in_inter_split_tx_hits() -> [usize; 4] { | |
| 1561 | - INTRA_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get) | |
| 1562 | -} | |
| 1563 | - | |
| 1564 | -thread_local! { | |
| 1565 | - /// The current frame's `mi` grid, kept only while a frame header set | |
| 1566 | - /// `allow_intrabc` -- an intrabc block's DV predictor is the ordinary | |
| 1567 | - /// MV stack ([`crate::mvstack::find_mv_stack`]) built against | |
| 1568 | - /// `INTRA_FRAME`, which needs the neighbour state a key frame otherwise | |
| 1569 | - /// never keeps. `(grid, mi_cols, mi_rows)`; `None` on every frame that | |
| 1570 | - /// does not allow intrabc (so nothing is paid for it). | |
| 1571 | - /// | |
| 1572 | - /// corner-cut: only [`decode_block`] (the square path) records into it, | |
| 1573 | - /// so a frame mixing intrabc with rect/sub-8x8 leaves would predict off | |
| 1574 | - /// an incomplete grid. Ceiling: the DV *value* (never the parse) would | |
| 1575 | - /// be wrong there; upgrade = record from the rect/leaf paths too. | |
| 1576 | - /// The block vector [`read_intra_mode`] just decoded, handed to | |
| 1577 | - /// [`decode_block`] off the call stack (same idiom as [`PALETTE_PRED`], | |
| 1578 | - /// which the alternative -- a tenth tuple member through every caller -- | |
| 1579 | - /// already avoids). Always `.take()`n by the block that reads it. | |
| 1580 | - /// How many blocks read `use_intrabc == 1` and took the DV path -- the | |
| 1581 | - /// gate's hit counter. Bumped on the READ, before the rect-strip refusal | |
| 1582 | - /// returns too, so it counts reads, not reconstructions (a refused block | |
| 1583 | - /// is never reconstructed). | |
| 1584 | - pub(super) static INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1585 | -} | |
| 1586 | - | |
| 1587 | -/// Zeroes [`RECT_INTRABC_READS`] (gate tests call this before a decode). | |
| 1588 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1589 | -pub(crate) fn reset_rect_intrabc_reads() { | |
| 1590 | - RECT_INTRABC_READS.with(|c| c.set(0)); | |
| 1591 | -} | |
| 1592 | - | |
| 1593 | -thread_local! { | |
| 1594 | - /// Blocks that USED intrabc at an 8x8 LEAF (`decode_leaf8`) specifically | |
| 1595 | - /// -- the shape lane-kf900 r7 fixed; [`INTRABC_HITS`] counts every shape. | |
| 1596 | - pub(super) static LEAF8_INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1597 | -} | |
| 1598 | - | |
| 1599 | -thread_local! { | |
| 1600 | - /// Chroma reads of an intrabc TX4-split leaf that consulted an ARMED | |
| 1601 | - /// [`INTRABC_CHROMA_TX`] slot -- proof that the arm's frame-copy + | |
| 1602 | - /// inherited-type route actually ran (lane-av1intrapred r2's non-vacuity | |
| 1603 | - /// counter: zero means the gate's fixture no longer reaches the route). | |
| 1604 | - pub(super) static INTRABC_TX4_CHROMA_COPY_HITS: std::cell::Cell<usize> = | |
| 1605 | - const { std::cell::Cell::new(0) }; | |
| 1606 | -} | |
| 1607 | - | |
| 1608 | -/// Current value of [`INTRABC_TX4_CHROMA_COPY_HITS`]. | |
| 1609 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1610 | -pub(crate) fn intrabc_tx4_chroma_copy_hits() -> usize { | |
| 1611 | - INTRABC_TX4_CHROMA_COPY_HITS.with(|c| c.get()) | |
| 1612 | -} | |
| 1613 | - | |
| 1614 | -/// Zeroes [`INTRABC_TX4_CHROMA_COPY_HITS`] (gate tests call this before a decode). | |
| 1615 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1616 | -pub(crate) fn reset_intrabc_tx4_chroma_copy_hits() { | |
| 1617 | - INTRABC_TX4_CHROMA_COPY_HITS.with(|c| c.set(0)); | |
| 1618 | -} | |
| 1619 | - | |
| 1620 | -/// Current value of [`LEAF8_INTRABC_HITS`]. | |
| 1621 | -pub(crate) fn leaf8_intrabc_hits() -> usize { | |
| 1622 | - LEAF8_INTRABC_HITS.with(|c| c.get()) | |
| 1623 | -} | |
| 1624 | - | |
| 1625 | -/// Zeroes [`LEAF8_INTRABC_HITS`] (gate tests call this before a decode). | |
| 1626 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1627 | -pub(crate) fn reset_leaf8_intrabc_hits() { | |
| 1628 | - LEAF8_INTRABC_HITS.with(|c| c.set(0)); | |
| 1629 | -} | |
| 1630 | - | |
| 1631 | -/// Current value of [`INTRABC_HITS`]. | |
| 1632 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1633 | -pub(crate) fn intrabc_hits() -> usize { | |
| 1634 | - INTRABC_HITS.with(|c| c.get()) | |
| 1635 | -} | |
| 1636 | - | |
| 1637 | -thread_local! { | |
| 1638 | - /// An intrabc block that IS a sub-8x8 group's CHROMA REFERENCE and is | |
| 1639 | - /// SKIPPED: the route that arms [`INTRABC_CHROMA_TX`] and then reads no | |
| 1640 | - /// chroma coefficient at all, so the slot used to stay armed into the NEXT | |
| 1641 | - /// block's chroma read. Both group shapes (4x4 split, 4x8/8x4 rect) count | |
| 1642 | - /// here. A non-zero value is what makes the disarm below load-bearing. | |
| 1643 | - pub(super) static SKIPPED_INTRABC_CHROMA_ARM_HITS: std::cell::Cell<usize> = | |
| 1644 | - const { std::cell::Cell::new(0) }; | |
| 1645 | -} | |
| 1646 | - | |
| 1647 | -/// Current value of [`SKIPPED_INTRABC_CHROMA_ARM_HITS`]. | |
| 1648 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates and the probe | |
| 1649 | -pub(crate) fn skipped_intrabc_chroma_arm_hits() -> usize { | |
| 1650 | - SKIPPED_INTRABC_CHROMA_ARM_HITS.with(|c| c.get()) | |
| 1651 | -} | |
| 1652 | - | |
| 1653 | -/// Zeroes [`SKIPPED_INTRABC_CHROMA_ARM_HITS`] (gate tests call this before a | |
| 1654 | -/// decode). | |
| 1655 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1656 | -pub(crate) fn reset_skipped_intrabc_chroma_arm_hits() { | |
| 1657 | - SKIPPED_INTRABC_CHROMA_ARM_HITS.with(|c| c.set(0)); | |
| 1658 | -} | |
| 1659 | - | |
| 1660 | -thread_local! { | |
| 1661 | - /// lane-av1-ibcskip2: a sub-8x8 4:4:4 leaf that is BOTH intrabc AND | |
| 1662 | - /// `skip` -- the arm whose chroma is the bare frame copy at the DV | |
| 1663 | - /// (libaom `av1_build_inter_predictors_sb` runs regardless of `skip`). | |
| 1664 | - /// Before the fix this route predicted intra-DC and every one of this | |
| 1665 | - /// fixture's 150 such cells differed from the oracle on both chroma | |
| 1666 | - /// planes. | |
| 1667 | - pub(super) static SKIPPED_INTRABC_DV_COPY_HITS: std::cell::Cell<usize> = | |
| 1668 | - const { std::cell::Cell::new(0) }; | |
| 1669 | -} | |
| 1670 | - | |
| 1671 | -/// Current value of [`SKIPPED_INTRABC_DV_COPY_HITS`]. | |
| 1672 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1673 | -pub(crate) fn skipped_intrabc_dv_copy_hits() -> usize { | |
| 1674 | - SKIPPED_INTRABC_DV_COPY_HITS.with(|c| c.get()) | |
| 1675 | -} | |
| 1676 | - | |
| 1677 | -/// Zeroes [`SKIPPED_INTRABC_DV_COPY_HITS`] (gate tests call this before a | |
| 1678 | -/// decode). | |
| 1679 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1680 | -pub(crate) fn reset_skipped_intrabc_dv_copy_hits() { | |
| 1681 | - SKIPPED_INTRABC_DV_COPY_HITS.with(|c| c.set(0)); | |
| 1682 | -} | |
| 1683 | - | |
| 1684 | -/// Zeroes [`INTRABC_HITS`] (gate tests call this before a decode). | |
| 1685 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1686 | -pub(crate) fn reset_intrabc_hits() { | |
| 1687 | - INTRABC_HITS.with(|c| c.set(0)); | |
| 1688 | -} | |
| 1689 | - | |
| 1690 | -thread_local! { | |
| 1691 | - /// lane-t900 r32: intrabc blocks whose transform size came off the INTER | |
| 1692 | - /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability | |
| 1693 | - /// that replaced the refusal "an intrabc block under TxMode::Select". | |
| 1694 | - pub(super) static INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1695 | - /// lane-av1-ibcvtx: intrabc var-tx trees that resolved to MIXED leaf | |
| 1696 | - /// sizes (not one square size across every leaf) -- the engagement | |
| 1697 | - /// counter proving a witness actually exercises the per-leaf reconstruct. | |
| 1698 | - pub(super) static INTRABC_VARTX_MIXED_LEAVES_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1699 | - /// lane-av1txr: as above for a `BLOCK_4X8`/`BLOCK_8X4` intrabc leaf -- | |
| 1700 | - /// libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`, so these leaves | |
| 1701 | - /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no | |
| 1702 | - /// symbol here desynced `warped.obu` at the very next block. | |
| 1703 | - pub(super) static RECT_INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1704 | - /// lane-av1-intrabc: rect INTRABC blocks whose reconstruction | |
| 1705 | - /// [`decode_intrabc_rect`] ran -- the engagement counter the rect-strip | |
| 1706 | - /// gates assert on (a refused block bumps [`INTRABC_HITS`] but never | |
| 1707 | - /// this one). | |
| 1708 | - pub(super) static INTRABC_RECT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1709 | - /// Of those, how many read the INTER var-tx tree (unskipped, TX_MODE_SELECT). | |
| 1710 | - pub(super) static INTRABC_RECT_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1711 | - /// lane-av1-intrabc r4: rect INTRABC blocks whose reconstruction | |
| 1712 | - /// [`decode_intrabc_rect`] ran with `skip == 0` (a real residual read), | |
| 1713 | - /// split by the strip's orientation -- `bw > bh` is a HORZ strip, | |
| 1714 | - /// `bh > bw` a VERT one. The reviewer's unblock condition needs a CODED | |
| 1715 | - /// witness in BOTH orientations, and the existing `INTRABC_RECT_HITS` | |
| 1716 | - /// counts neither orientation nor the skip flag, so an arm that flipped | |
| 1717 | - /// to an all-skip stream (no residual reader at all) would stay green. | |
| 1718 | - pub(super) static INTRABC_RECT_CODED_HITS: std::cell::Cell<[usize; 2]> = | |
| 1719 | - const { std::cell::Cell::new([0, 0]) }; | |
| 1720 | - /// lane-av1-intrabc r5: the `skip == 1` twin of [`INTRABC_RECT_CODED_HITS`] | |
| 1721 | - /// -- rect INTRABC blocks reconstructed as a bare prediction copy, split | |
| 1722 | - /// by orientation. The r5 panic (residual stride `bw * bh` underrunning | |
| 1723 | - /// `reconstruct_mc_rect`'s `row * side + w` index on a VERT strip) was | |
| 1724 | - /// invisible to every gate because they only counted CODED strips. | |
| 1725 | - pub(super) static INTRABC_RECT_SKIPPED_HITS: std::cell::Cell<[usize; 2]> = | |
| 1726 | - const { std::cell::Cell::new([0, 0]) }; | |
| 1727 | - /// lane-ibc444c: rect intra-BC blocks whose chroma plane block was sized | |
| 1728 | - /// `bw >> ss_x` by `bh >> ss_y` -- the 4:4:4 and 4:4:0 cells, where | |
| 1729 | - /// `av1_get_max_uv_txsize` (`ss_size_lookup[bsize]`, blockd.h) applies no | |
| 1730 | - /// halving of its own. At 4:2:0 this is the same arithmetic as the halving, | |
| 1731 | - /// so a `>= 1` witness can only come from a stream that is not 4:2:0. | |
| 1732 | - /// EXCLUSIVE to this arm: no other caller sizes an intrabc rect block's | |
| 1733 | - /// chroma plane block. | |
| 1734 | - pub(super) static IBC_RECT_CHROMA_FOOTPRINT_444_HITS: std::cell::Cell<usize> = | |
| 1735 | - const { std::cell::Cell::new(0) }; | |
| 1736 | - /// lane-whtshape: LOSSLESS rect intrabc blocks whose chroma plane block | |
| 1737 | - /// [`decode_intrabc_rect`] walked as a `(cw/4) * (ch/4)` PLANE-MAJOR | |
| 1738 | - /// raster of TX_4X4 units -- the shape libaom's lossless geometry codes | |
| 1739 | - /// (`read_tx_size` returns `TX_4X4` for EVERY plane of a lossless block, | |
| 1740 | - /// `get_vartx_max_txsize` likewise, and `read_tx_mode` forced the frame's | |
| 1741 | - /// `ONLY_4X4`) -- instead of the single rect unit, which is what put a | |
| 1742 | - /// non-4x4 unit on the lossless Walsh-Hadamard path. EXCLUSIVE to this arm: | |
| 1743 | - /// no other caller walks a rect intrabc block's chroma, so `>= 1` cannot | |
| 1744 | - /// be satisfied by any older route. | |
| 1745 | - pub(super) static INTRABC_RECT_LOSSLESS_CHROMA4_HITS: std::cell::Cell<usize> = | |
| 1746 | - const { std::cell::Cell::new(0) }; | |
| 1747 | - /// lane-av1chromarect: 128-root intra-BC HORZ/VERT strips | |
| 1748 | - /// ([`decode_intrabc_owned_rect`]) whose chroma plane block was sized | |
| 1749 | - /// `bw >> ss_x` by `bh >> ss_y` -- the 4:4:4 and 4:4:0 cells, where | |
| 1750 | - /// `av1_get_max_uv_txsize` (`ss_size_lookup[bsize]`, blockd.h:1372) applies | |
| 1751 | - /// no halving of its own. At 4:2:0 the two forms are the same arithmetic, | |
| 1752 | - /// so a `>= 1` witness can only come from a stream that is not 4:2:0. | |
| 1753 | - /// EXCLUSIVE to this arm: no other caller sizes a 128-root intra-BC | |
| 1754 | - /// strip's chroma plane block. | |
| 1755 | - pub(super) static IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS: std::cell::Cell<usize> = | |
| 1756 | - const { std::cell::Cell::new(0) }; | |
| 1757 | - /// lane-av1422ibctxsel: `decode_intrabc_owned_rect`'s NON-SPLIT chroma | |
| 1758 | - /// gather taken through the 4:2:2 pair rule (`around_mi_422_chroma`) | |
| 1759 | - /// under the ss (1, 0) guard -- both residual branches (the var-tx tree | |
| 1760 | - /// and the no-leaves twin). `>= 1` can only come from a 4:2:2 stream | |
| 1761 | - /// that reaches this function's non-split chroma arm; the 4:2:0/4:4:4 | |
| 1762 | - /// arms keep the plain `around_mi_rect` gather (`ss_y != 0` / `ss_x == 0` | |
| 1763 | - /// take the else), so the counter stays 0 for them. | |
| 1764 | - pub(super) static IBC_OWNED_RECT_422_PAIR_HITS: std::cell::Cell<usize> = | |
| 1765 | - const { std::cell::Cell::new(0) }; | |
| 1766 | -} | |
| 1767 | - | |
| 1768 | -/// lane-av1-intrabc r4: coded (`skip == 0`) rect intrabc blocks reconstructed, | |
| 1769 | -/// as `[horz, vert]` -- see [`INTRABC_RECT_CODED_HITS`]. | |
| 1770 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1771 | -pub fn intrabc_rect_coded_hits() -> [usize; 2] { | |
| 1772 | - INTRABC_RECT_CODED_HITS.with(std::cell::Cell::get) | |
| 1773 | -} | |
| 1774 | - | |
| 1775 | -/// lane-av1-intrabc r5: skipped (`skip == 1`) rect intrabc blocks | |
| 1776 | -/// reconstructed, as `[horz, vert]` -- see [`INTRABC_RECT_SKIPPED_HITS`]. | |
| 1777 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1778 | -pub fn intrabc_rect_skipped_hits() -> [usize; 2] { | |
| 1779 | - INTRABC_RECT_SKIPPED_HITS.with(std::cell::Cell::get) | |
| 1780 | -} | |
| 1781 | - | |
| 1782 | -/// Current value of [`INTRABC_RECT_HITS`]. | |
| 1783 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1784 | -pub fn intrabc_rect_hits() -> usize { | |
| 1785 | - INTRABC_RECT_HITS.with(|c| c.get()) | |
| 1786 | -} | |
| 1787 | - | |
| 1788 | -/// Zeroes [`INTRABC_RECT_HITS`]/[`INTRABC_RECT_VARTX_HITS`]. | |
| 1789 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1790 | -pub(crate) fn reset_intrabc_rect_hits() { | |
| 1791 | - INTRABC_RECT_HITS.with(|c| c.set(0)); | |
| 1792 | - INTRABC_RECT_VARTX_HITS.with(|c| c.set(0)); | |
| 1793 | - INTRABC_RECT_CODED_HITS.with(|c| c.set([0, 0])); | |
| 1794 | - INTRABC_RECT_SKIPPED_HITS.with(|c| c.set([0, 0])); | |
| 1795 | -} | |
| 1796 | - | |
| 1797 | -/// lane-ibc444c: [`IBC_RECT_CHROMA_FOOTPRINT_444_HITS`]. | |
| 1798 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1799 | -pub fn ibc_rect_chroma_footprint_444_hits() -> usize { | |
| 1800 | - IBC_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.get()) | |
| 1801 | -} | |
| 1802 | - | |
| 1803 | -/// lane-ibc444c: zeroes [`IBC_RECT_CHROMA_FOOTPRINT_444_HITS`]. | |
| 1804 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1805 | -pub(crate) fn reset_ibc_rect_chroma_footprint_444_hits() { | |
| 1806 | - IBC_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.set(0)); | |
| 1807 | -} | |
| 1808 | - | |
| 1809 | -/// lane-av1chromarect: [`IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS`]. | |
| 1810 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1811 | -pub fn ibc_owned_rect_chroma_footprint_444_hits() -> usize { | |
| 1812 | - IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.get()) | |
| 1813 | -} | |
| 1814 | - | |
| 1815 | -/// lane-av1chromarect: zeroes [`IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS`]. | |
| 1816 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1817 | -pub(crate) fn reset_ibc_owned_rect_chroma_footprint_444_hits() { | |
| 1818 | - IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS.with(|c| c.set(0)); | |
| 1819 | -} | |
| 1820 | - | |
| 1821 | -/// lane-av1422ibctxsel: [`IBC_OWNED_RECT_422_PAIR_HITS`]. | |
| 1822 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1823 | -pub fn ibc_owned_rect_422_pair_hits() -> usize { | |
| 1824 | - IBC_OWNED_RECT_422_PAIR_HITS.with(|c| c.get()) | |
| 1825 | -} | |
| 1826 | - | |
| 1827 | -/// lane-av1422ibctxsel: zeroes [`IBC_OWNED_RECT_422_PAIR_HITS`]. | |
| 1828 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1829 | -pub(crate) fn reset_ibc_owned_rect_422_pair_hits() { | |
| 1830 | - IBC_OWNED_RECT_422_PAIR_HITS.with(|c| c.set(0)); | |
| 1831 | -} | |
| 1832 | - | |
| 1833 | -/// lane-whtshape: [`INTRABC_RECT_LOSSLESS_CHROMA4_HITS`]. | |
| 1834 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1835 | -pub fn intrabc_rect_lossless_chroma4_hits() -> usize { | |
| 1836 | - INTRABC_RECT_LOSSLESS_CHROMA4_HITS.with(|c| c.get()) | |
| 1837 | -} | |
| 1838 | - | |
| 1839 | -/// lane-whtshape: zeroes [`INTRABC_RECT_LOSSLESS_CHROMA4_HITS`]. | |
| 1840 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1841 | -pub(crate) fn reset_intrabc_rect_lossless_chroma4_hits() { | |
| 1842 | - INTRABC_RECT_LOSSLESS_CHROMA4_HITS.with(|c| c.set(0)); | |
| 1843 | -} | |
| 1844 | - | |
| 1845 | -/// Current value of [`INTRABC_RECT_VARTX_HITS`]. | |
| 1846 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1847 | -pub fn intrabc_rect_vartx_hits() -> usize { | |
| 1848 | - INTRABC_RECT_VARTX_HITS.with(|c| c.get()) | |
| 1849 | -} | |
| 1850 | - | |
| 1851 | -thread_local! { | |
| 1852 | - /// lane-av1-ibcrect: `use_intrabc` blocks on a 128-root HORZ/VERT strip | |
| 1853 | - /// (BLOCK_128X64 / BLOCK_64X128) whose reconstruction | |
| 1854 | - /// [`decode_intrabc_128rect`] ran -- the shape the named refusal used to | |
| 1855 | - /// guard (`decode_block_128rect`). A refused block bumps | |
| 1856 | - /// [`INTRABC_HITS`] but never this one. | |
| 1857 | - pub(super) static INTRABC_128RECT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1858 | - /// lane-av1-ibc128chunk: chroma transform units the 128-root intrabc | |
| 1859 | - /// strip's mu-chunk walk read, one per `read_inter_plane` chroma call. | |
| 1860 | - /// At 4:2:0 a 64x64 mu chunk's chroma plane block is 32x32, so one | |
| 1861 | - /// TX_32X32 per plane per chunk; at 4:2:2 it is 32x64 and holds TWO | |
| 1862 | - /// STACKED units per plane. The square-cut `chunk_chroma = cside * 64 / | |
| 1863 | - /// side` model walked the 4:2:0 count on every axis, so this counter is | |
| 1864 | - /// the reach/arm witness for the per-axis walk. | |
| 1865 | - pub(super) static INTRABC_128RECT_CHROMA_CHUNK_HITS: std::cell::Cell<usize> = | |
| 1866 | - const { std::cell::Cell::new(0) }; | |
| 1867 | -} | |
| 1868 | - | |
| 1869 | -/// Current value of [`INTRABC_128RECT_HITS`]. | |
| 1870 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1871 | -pub fn intrabc_128rect_hits() -> usize { | |
| 1872 | - INTRABC_128RECT_HITS.with(|c| c.get()) | |
| 1873 | -} | |
| 1874 | - | |
| 1875 | -/// Zeroes [`INTRABC_128RECT_HITS`]. | |
| 1876 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1877 | -pub(crate) fn reset_intrabc_128rect_hits() { | |
| 1878 | - INTRABC_128RECT_HITS.with(|c| c.set(0)); | |
| 1879 | -} | |
| 1880 | - | |
| 1881 | -/// Current value of [`INTRABC_128RECT_CHROMA_CHUNK_HITS`]. | |
| 1882 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1883 | -pub fn intrabc_128rect_chroma_chunk_hits() -> usize { | |
| 1884 | - INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.get()) | |
| 1885 | -} | |
| 1886 | - | |
| 1887 | -/// Zeroes [`INTRABC_128RECT_CHROMA_CHUNK_HITS`] and | |
| 1888 | -/// [`INTRABC_128RECT_CHUNK_SHAPE`]. | |
| 1889 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1890 | -pub(crate) fn reset_intrabc_128rect_chroma_chunk_hits() { | |
| 1891 | - INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.set(0)); | |
| 1892 | - INTRABC_128RECT_CHUNK_SHAPE.with(|c| c.set(0)); | |
| 1893 | -} | |
| 1894 | - | |
| 1895 | -/// Current value of [`INTRABC_VARTX_HITS`]. | |
| 1896 | -pub fn intrabc_vartx_hits() -> usize { | |
| 1897 | - INTRABC_VARTX_HITS.with(|c| c.get()) | |
| 1898 | -} | |
| 1899 | - | |
| 1900 | -/// Current value of [`INTRABC_VARTX_MIXED_LEAVES_HITS`]. | |
| 1901 | -pub fn intrabc_vartx_mixed_leaves_hits() -> usize { | |
| 1902 | - INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.get()) | |
| 1903 | -} | |
| 1904 | - | |
| 1905 | -/// Zeroes [`INTRABC_VARTX_HITS`] (gate tests call this before a decode). | |
| 1906 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1907 | -pub(crate) fn reset_intrabc_vartx_hits() { | |
| 1908 | - INTRABC_VARTX_HITS.with(|c| c.set(0)); | |
| 1909 | -} | |
| 1910 | - | |
| 1911 | -/// Zeroes [`INTRABC_VARTX_MIXED_LEAVES_HITS`] (gate tests call this before a | |
| 1912 | -/// decode). | |
| 1913 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1914 | -pub(crate) fn reset_intrabc_vartx_mixed_leaves_hits() { | |
| 1915 | - INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.set(0)); | |
| 1916 | -} | |
| 1917 | - | |
| 1918 | -/// Current value of [`RECT_INTRABC_VARTX_HITS`]. | |
| 1919 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1920 | -pub fn rect_intrabc_vartx_hits() -> usize { | |
| 1921 | - RECT_INTRABC_VARTX_HITS.with(|c| c.get()) | |
| 1922 | -} | |
| 1923 | - | |
| 1924 | -// How many blocks decoded `skip_mode == 1` (lane-av1comp round 14) -- | |
| 1925 | -// proves a real `skip_mode_present` stream actually reached a block that | |
| 1926 | -// picked it, not just that the frame header bit was set. | |
| 1927 | -thread_local! { | |
| 1928 | - pub(super) static SKIP_MODE_HITS: std::cell::Cell<usize> = | |
| 1929 | - const { std::cell::Cell::new(0) }; | |
| 1930 | -} | |
| 1931 | - | |
| 1932 | -/// Current value of [`SKIP_MODE_HITS`]. | |
| 1933 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1934 | -pub(crate) fn skip_mode_hits() -> usize { | |
| 1935 | - SKIP_MODE_HITS.with(|c| c.get()) | |
| 1936 | -} | |
| 1937 | - | |
| 1938 | -// lane-motionmode: how many blocks actually decoded `obmc_selected == true` | |
| 1939 | -// (as opposed to just reaching an eligible `read_motion_mode` symbol read) | |
| 1940 | -// -- the gate's own proof that a real aomenc `--enable-obmc=1` stream | |
| 1941 | -// reached [`obmc_blend`], not just the header bit. | |
| 1942 | -thread_local! { | |
| 1943 | - pub(super) static OBMC_HITS: std::cell::Cell<usize> = | |
| 1944 | - const { std::cell::Cell::new(0) }; | |
| 1945 | -} | |
| 1946 | - | |
| 1947 | -// lane-fimv r1 (class wrong-alphabet-same-value): how many blocks took the | |
| 1948 | -// 2-symbol `obmc_cdf` alphabet *because* `force_integer_mv` (or a scaled | |
| 1949 | -// reference) vetoed `WARPED_CAUSAL` in libaom `motion_mode_allowed`, while | |
| 1950 | -// `allow_warped_motion == 1` and `num_proj_ref >= 1` would otherwise have | |
| 1951 | -// picked the 3-symbol `motion_mode_cdf`. These are exactly the blocks this | |
| 1952 | -// decoder used to read with the wrong alphabet, so a gate that asserts this | |
| 1953 | -// counter advanced proves the fixed path fired (class | |
| 1954 | -// `gate-blind-to-feature`). | |
| 1955 | -thread_local! { | |
| 1956 | - pub(super) static FIMV_ALPHABET_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1957 | -} | |
| 1958 | - | |
| 1959 | -/// Current value of [`FIMV_ALPHABET_HITS`]. | |
| 1960 | -pub fn fimv_alphabet_hits() -> usize { | |
| 1961 | - FIMV_ALPHABET_HITS.with(|c| c.get()) | |
| 1962 | -} | |
| 1963 | - | |
| 1964 | -// lane-fimv r1: how many frame headers this decoder has decoded with | |
| 1965 | -// `force_integer_mv == 1` (bumped by `stream.rs` per frame). Lets a gate | |
| 1966 | -// prove the encoder really produced the header state under test rather than | |
| 1967 | -// assume it. | |
| 1968 | -thread_local! { | |
| 1969 | - pub(super) static FIMV_FRAME_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1970 | -} | |
| 1971 | - | |
| 1972 | -/// Current value of [`FIMV_FRAME_HITS`]. | |
| 1973 | -pub fn fimv_frame_hits() -> usize { | |
| 1974 | - FIMV_FRAME_HITS.with(|c| c.get()) | |
| 1975 | -} | |
| 1976 | - | |
| 1977 | -/// Current value of [`OBMC_HITS`]. | |
| 1978 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1979 | -pub(crate) fn obmc_hits() -> usize { | |
| 1980 | - OBMC_HITS.with(|c| c.get()) | |
| 1981 | -} | |
| 1982 | - | |
| 1983 | -// lane-scaledref r1: per-case firing counts for the scaled-reference gate | |
| 1984 | -// (class `gate-blind-to-feature`) -- a pixel match under an UNSCALED | |
| 1985 | -// reference would pass just as well and prove nothing, so the gate | |
| 1986 | -// hard-asserts each combination this round lifts actually occurred: | |
| 1987 | -// a compound block with a scaled tap, a warp block whose warp libaom | |
| 1988 | -// suppresses because the reference is scaled, an OBMC block, an interintra | |
| 1989 | -// block, and an 8x8 leaf. | |
| 1990 | -thread_local! { | |
| 1991 | - pub(super) static SCALED_COMPOUND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1992 | - pub(super) static SCALED_WARP_FALLBACK_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1993 | - pub(super) static SCALED_OBMC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1994 | - pub(super) static SCALED_INTERINTRA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1995 | - pub(super) static SCALED_BLOCK8_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1996 | - pub(super) static SCALED_WARP_SUPPRESSED_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1997 | - pub(super) static MIXED_SCALE_COMPOUND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1998 | -} | |
| 1999 | - | |
| 2000 | -/// Current value of [`MIXED_SCALE_COMPOUND_HITS`]: compound blocks with one |
crates/ec-av1/src/decode/deblock.rsmodified+33 -49
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | //! Deblocking filters: the edge filters, the deblock plane drivers, the filter-replay capture and the pooled plane scratch. Moved out of `decode/mod.rs` (av1split D12); the items are unchanged apart from visibility. |
| 2 | 2 | |
| 3 | -use archmage::SimdToken; | |
| 4 | 3 | use super::*; |
| 4 | +use archmage::SimdToken; | |
| 5 | 5 | |
| 6 | 6 | /// `update_sharpness`'s per-level `(blimit, limit, hev_thr)` triple. |
| 7 | 7 | fn deblock_thresholds(level: i32, sharpness: u8) -> (i32, i32, i32) { |
| @@ -463,12 +463,6 @@ pub(super) fn deblock_plane_span( | ||
| 463 | 463 | plane.true_height.min(ch), |
| 464 | 464 | plane.width, |
| 465 | 465 | ); |
| 466 | - if crate::envflags::env_flag!("EC_AV1_DEBLOCK_TRACE_V") { | |
| 467 | - eprintln!( | |
| 468 | - "DEBLOCK plane={plane_idx} tw={tw} th={th} stride={stride} true={}x{} crop={cw}x{ch}", | |
| 469 | - plane.true_width, plane.true_height | |
| 470 | - ); | |
| 471 | - } | |
| 472 | 466 | // lane-perf8: both passes iterate the edge's OWN direction innermost, so |
| 473 | 467 | // 4 consecutive 4-sample groups (16 lines) can go through one AVX2 |
| 474 | 468 | // kernel. The swap is order-preserving: a filtered group overlaps only |
| @@ -523,20 +517,20 @@ pub(super) fn deblock_plane_span( | ||
| 523 | 517 | std::array::from_fn(|k| edge_params(&vctx, x0, y0 + 4 * k)); |
| 524 | 518 | if let Some((len, level)) = ps[0] |
| 525 | 519 | && ps.iter().all(|p| *p == ps[0]) |
| 526 | - && filter_edge16( | |
| 527 | - mine, | |
| 528 | - (y0 - y_lo) * stride + x0, | |
| 529 | - stride, | |
| 530 | - true, | |
| 531 | - len, | |
| 532 | - level, | |
| 533 | - lf.sharpness, | |
| 534 | - fctx, | |
| 535 | - ) | |
| 536 | - { | |
| 537 | - y0 += 16; | |
| 538 | - continue; | |
| 539 | - } | |
| 520 | + && filter_edge16( | |
| 521 | + mine, | |
| 522 | + (y0 - y_lo) * stride + x0, | |
| 523 | + stride, | |
| 524 | + true, | |
| 525 | + len, | |
| 526 | + level, | |
| 527 | + lf.sharpness, | |
| 528 | + fctx, | |
| 529 | + ) | |
| 530 | + { | |
| 531 | + y0 += 16; | |
| 532 | + continue; | |
| 533 | + } | |
| 540 | 534 | for (k, p) in ps.iter().enumerate() { |
| 541 | 535 | if let Some((len, level)) = *p { |
| 542 | 536 | filter_edge( |
| @@ -555,9 +549,6 @@ pub(super) fn deblock_plane_span( | ||
| 555 | 549 | continue; |
| 556 | 550 | } |
| 557 | 551 | if let Some((len, level)) = edge_params(&vctx, x0, y0) { |
| 558 | - if crate::envflags::env_flag!("EC_AV1_DEBLOCK_TRACE_V") && plane_idx == 0 { | |
| 559 | - eprintln!("VEDGE x0={x0} y0={y0} len={len} level={level}"); | |
| 560 | - } | |
| 561 | 552 | filter_edge( |
| 562 | 553 | mine, |
| 563 | 554 | (y0 - y_lo) * stride + x0, |
| @@ -637,20 +628,20 @@ pub(super) fn deblock_plane_span( | ||
| 637 | 628 | std::array::from_fn(|k| edge_params(&hctx, x0 + 4 * k, y0)); |
| 638 | 629 | if let Some((len, level)) = ps[0] |
| 639 | 630 | && ps.iter().all(|p| *p == ps[0]) |
| 640 | - && filter_edge16( | |
| 641 | - px, | |
| 642 | - (y0 - r_lo) * w + (x0 - x_lo), | |
| 643 | - w, | |
| 644 | - false, | |
| 645 | - len, | |
| 646 | - level, | |
| 647 | - lf.sharpness, | |
| 648 | - fctx, | |
| 649 | - ) | |
| 650 | - { | |
| 651 | - x0 += 16; | |
| 652 | - continue; | |
| 653 | - } | |
| 631 | + && filter_edge16( | |
| 632 | + px, | |
| 633 | + (y0 - r_lo) * w + (x0 - x_lo), | |
| 634 | + w, | |
| 635 | + false, | |
| 636 | + len, | |
| 637 | + level, | |
| 638 | + lf.sharpness, | |
| 639 | + fctx, | |
| 640 | + ) | |
| 641 | + { | |
| 642 | + x0 += 16; | |
| 643 | + continue; | |
| 644 | + } | |
| 654 | 645 | for (k, p) in ps.iter().enumerate() { |
| 655 | 646 | if let Some((len, level)) = *p { |
| 656 | 647 | filter_edge( |
| @@ -669,15 +660,6 @@ pub(super) fn deblock_plane_span( | ||
| 669 | 660 | continue; |
| 670 | 661 | } |
| 671 | 662 | if let Some((len, level)) = edge_params(&hctx, x0, y0) { |
| 672 | - if crate::envflags::env_flag!("EC_AV1_DEBLOCK_TRACE") | |
| 673 | - && plane_idx == 0 | |
| 674 | - && x0 == 44 | |
| 675 | - { | |
| 676 | - eprintln!( | |
| 677 | - "HEDGE x0={x0} y0={y0} len={len} level={level} sharpness={}", | |
| 678 | - lf.sharpness | |
| 679 | - ); | |
| 680 | - } | |
| 681 | 663 | filter_edge( |
| 682 | 664 | px, |
| 683 | 665 | (y0 - r_lo) * w + (x0 - x_lo), |
| @@ -716,7 +698,8 @@ pub(super) fn deblock_plane_span( | ||
| 716 | 698 | /// every pool thread the decode ever created. One shared pool with a hard |
| 717 | 699 | /// entry cap bounds the retention at [`SCRATCH_CAP`] buffers no matter how |
| 718 | 700 | /// many threads cycle through it; anything over the cap is freed. |
| 719 | -pub(super) static PLANE_SCRATCH: std::sync::Mutex<Vec<Vec<u16>>> = std::sync::Mutex::new(Vec::new()); | |
| 701 | +pub(super) static PLANE_SCRATCH: std::sync::Mutex<Vec<Vec<u16>>> = | |
| 702 | + std::sync::Mutex::new(Vec::new()); | |
| 720 | 703 | |
| 721 | 704 | /// Most buffers the shared pool keeps. ~3 whole-plane sets per in-flight 4K |
| 722 | 705 | /// frame at the shipped `EC_AV1_THREADS` ceiling; the frames actually in |
| @@ -877,7 +860,8 @@ pub(crate) fn arm_filter_replay() { | ||
| 877 | 860 | /// can hold the replay against the decode it stands in for |
| 878 | 861 | /// (`encoder::tests::filter_replay_codes_the_same_stream_as_a_full_decode`). |
| 879 | 862 | #[cfg(test)] |
| 880 | -pub(super) static REPLAY_DISABLED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); | |
| 863 | +pub(super) static REPLAY_DISABLED: std::sync::atomic::AtomicBool = | |
| 864 | + std::sync::atomic::AtomicBool::new(false); | |
| 881 | 865 | |
| 882 | 866 | #[cfg(test)] |
| 883 | 867 | pub(crate) fn set_filter_replay_disabled(off: bool) { |
crates/ec-av1/src/decode/frame_tile.rsmodified+7 -346
| @@ -417,13 +417,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 417 | 417 | let (width, height) = (cols as usize * BLOCK, rows as usize * BLOCK); |
| 418 | 418 | |
| 419 | 419 | let mut y = PlaneBuf { |
| 420 | - data: std::borrow::Cow::Owned(fresh_plane( | |
| 421 | - width * height, | |
| 422 | - true_width, | |
| 423 | - true_height, | |
| 424 | - width, | |
| 425 | - height, | |
| 426 | - )), | |
| 420 | + data: std::borrow::Cow::Owned(fresh_plane(width * height)), | |
| 427 | 421 | width, |
| 428 | 422 | height, |
| 429 | 423 | true_width, |
| @@ -435,10 +429,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 435 | 429 | plane: 0, |
| 436 | 430 | }; |
| 437 | 431 | let (cw, ch) = (width >> ss_x(fctx), height >> ss_y(fctx)); |
| 438 | - note_frame_chroma_alloc((width, height), (cw, ch), (ss_x(fctx), ss_y(fctx))); | |
| 439 | 432 | let (ctw, cth) = (true_width >> ss_x(fctx), true_height >> ss_y(fctx)); |
| 440 | 433 | let mut u = PlaneBuf { |
| 441 | - data: std::borrow::Cow::Owned(fresh_plane(cw * ch, ctw, cth, cw, ch)), | |
| 434 | + data: std::borrow::Cow::Owned(fresh_plane(cw * ch)), | |
| 442 | 435 | width: cw, |
| 443 | 436 | height: ch, |
| 444 | 437 | true_width: ctw, |
| @@ -450,7 +443,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 450 | 443 | plane: 1, |
| 451 | 444 | }; |
| 452 | 445 | let mut v = PlaneBuf { |
| 453 | - data: std::borrow::Cow::Owned(fresh_plane(cw * ch, ctw, cth, cw, ch)), | |
| 446 | + data: std::borrow::Cow::Owned(fresh_plane(cw * ch)), | |
| 454 | 447 | width: cw, |
| 455 | 448 | height: ch, |
| 456 | 449 | true_width: ctw, |
| @@ -542,17 +535,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 542 | 535 | // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets |
| 543 | 536 | // it codes every symbol against the tables it started with. |
| 544 | 537 | dec.set_cdf_update(!cdf_update_disabled(fctx)); |
| 545 | - crate::census::register_cdfs(&cdfs); | |
| 546 | 538 | // lane-comppin r9: tile-entry range, the earliest point comparable |
| 547 | 539 | // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the |
| 548 | 540 | // first ladder rung before any symbol (partition or otherwise) is read. |
| 549 | - if crate::envflags::env_flag!("EC_AV1_TELL") { | |
| 550 | - eprintln!( | |
| 551 | - "TELL label=tile_init tell={} range={}", | |
| 552 | - dec.debug_bitpos(), | |
| 553 | - dec.debug_state().0 | |
| 554 | - ); | |
| 555 | - } | |
| 556 | 541 | neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize, fctx); |
| 557 | 542 | y.set_tile_origin( |
| 558 | 543 | mi_col0 as usize * 4, |
| @@ -583,7 +568,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 583 | 568 | mi_row1 as usize, |
| 584 | 569 | mi_col1 as usize, |
| 585 | 570 | ); |
| 586 | - hit!(TILE_HITS); | |
| 587 | 571 | |
| 588 | 572 | // lane-sb128 r2: at `sb_size == 128` the tile walks each 128x128 |
| 589 | 573 | // superblock's four 64x64 quadrants in libaom `decode_partition` order |
| @@ -985,11 +969,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 985 | 969 | bw, |
| 986 | 970 | bh |
| 987 | 971 | ); |
| 988 | - if horz { | |
| 989 | - hit!(INTER_SB128_HORZ_HITS); | |
| 990 | - } else { | |
| 991 | - hit!(INTER_SB128_VERT_HITS); | |
| 992 | - } | |
| 993 | 972 | } |
| 994 | 973 | // One `cdef_idx` per BLOCK, copied to every 64x64 CDEF unit it |
| 995 | 974 | // covers -- both halves of the root read their own, and the |
| @@ -1023,7 +1002,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1023 | 1002 | continue; |
| 1024 | 1003 | } |
| 1025 | 1004 | if sb128_none { |
| 1026 | - hit!(INTER_SB128_NONE_HITS); | |
| 1027 | 1005 | let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4); |
| 1028 | 1006 | // lane-sb128c r3: `at128` is in SUB16 units like `sb_at`; |
| 1029 | 1007 | // `decode_inter_block` takes MI. Unconverted it was (0,0) for |
| @@ -1076,16 +1054,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1076 | 1054 | // instead of silently decoding as SPLIT and desyncing. |
| 1077 | 1055 | let part64 = match (has_cols, has_rows) { |
| 1078 | 1056 | (true, true) => { |
| 1079 | - let pre_rng = dec.debug_state().0; | |
| 1080 | - if crate::envflags::env_flag!("EC_TRACE_PART") { | |
| 1081 | - eprintln!( | |
| 1082 | - "EC_PART mi_row={} mi_col={} bsize=12 ctx={} rng={}", | |
| 1083 | - sb_r as usize * SB_MI as usize, | |
| 1084 | - sb_c as usize * SB_MI as usize, | |
| 1085 | - sb_ctx, | |
| 1086 | - dec.debug_state().0 | |
| 1087 | - ); | |
| 1088 | - } | |
| 1089 | 1057 | let p = dec.symbol(&mut cdfs.partition_w64[sb_ctx]); |
| 1090 | 1058 | // lane-av1unwritten r6: the partition symbol is RESOLVED and about to be |
| 1091 | 1059 | // dispatched. `partition_subsize_dims` is libaom's `get_partition_subsize` |
| @@ -1094,33 +1062,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1094 | 1062 | // arm -- VERT, VERT_A / VERT_B, HORZ_4 and VERT_4 -- and the HORZ siblings |
| 1095 | 1063 | // keep decoding because the helper is exact, not a heuristic. inter-frame 64x64 level; `p` is the symbol. |
| 1096 | 1064 | |
| 1097 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 1098 | - eprintln!( | |
| 1099 | - "TRACE partition_w64 mi=({},{}) ctx={sb_ctx} value={p} pre_rng={pre_rng}", | |
| 1100 | - sb_r * SB_MI, | |
| 1101 | - sb_c * SB_MI | |
| 1102 | - ); | |
| 1103 | - } | |
| 1104 | 1065 | p |
| 1105 | 1066 | } |
| 1106 | 1067 | (true, false) => { |
| 1107 | 1068 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered |
| 1108 | 1069 | // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT |
| 1109 | 1070 | // (libaom `ec_read_partition_impl`). |
| 1110 | - if crate::envflags::env_flag!("EC_TRACE_PART") { | |
| 1111 | - eprintln!( | |
| 1112 | - "EC_PARTG mi_row={} mi_col={} bsize=12 ctx={} rng={}", | |
| 1113 | - sb_r as usize * SB_MI as usize, | |
| 1114 | - sb_c as usize * SB_MI as usize, | |
| 1115 | - sb_ctx, | |
| 1116 | - dec.debug_state().0 | |
| 1117 | - ); | |
| 1118 | - } | |
| 1119 | - if bump_edge32_bit( | |
| 1120 | - 4, | |
| 1121 | - dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)), | |
| 1122 | - ) == 1 | |
| 1123 | - { | |
| 1071 | + if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)) == 1 { | |
| 1124 | 1072 | PARTITION_SPLIT |
| 1125 | 1073 | } else { |
| 1126 | 1074 | PARTITION_HORZ |
| @@ -1130,20 +1078,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1130 | 1078 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered |
| 1131 | 1079 | // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT |
| 1132 | 1080 | // (libaom `ec_read_partition_impl`). |
| 1133 | - if bump_edge32_bit( | |
| 1134 | - 4, | |
| 1135 | - dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)), | |
| 1136 | - ) == 1 | |
| 1137 | - { | |
| 1081 | + if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)) == 1 { | |
| 1138 | 1082 | PARTITION_SPLIT |
| 1139 | 1083 | } else { |
| 1140 | 1084 | PARTITION_VERT |
| 1141 | 1085 | } |
| 1142 | 1086 | } |
| 1143 | - (false, false) => { | |
| 1144 | - bump_edge_both_cut(2); | |
| 1145 | - PARTITION_SPLIT | |
| 1146 | - } | |
| 1087 | + (false, false) => PARTITION_SPLIT, | |
| 1147 | 1088 | }; |
| 1148 | 1089 | // lane-av1unwritten r7: the symbol is RESOLVED (a full CDF |
| 1149 | 1090 | // read or an edge `gather`) and about to be dispatched, so the |
| @@ -1156,16 +1097,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1156 | 1097 | // see it. |
| 1157 | 1098 | refuse_invalid_subsize((64, 64), part64, fctx)?; |
| 1158 | 1099 | if part64 == PARTITION_NONE { |
| 1159 | - // lane-inter8 r1: the whole superblock as one 64x64 inter | |
| 1160 | - // block. `SB`-sized syntax throughout (size_group 3, same as | |
| 1161 | - // 32x32 -- `size_group_lookup[BLOCK_64X64] == 3`), luma | |
| 1162 | - // coefficients through `TxbSet::Luma64` with the 32-point | |
| 1163 | - // scan (TX_64X64 codes only its top-left corner, spec | |
| 1164 | - // 5.11.40 -- `read_inter_plane` widens the corner back to | |
| 1165 | - // 64x64 before the inverse transform), chroma as a plain | |
| 1166 | - // 32x32 `TxbSet::Chroma32`. TX_64X64 carries no `tx_type` | |
| 1167 | - // symbol at all, so the intra/inter luma sets coincide. | |
| 1168 | - hit!(INTER_SB_NONE_HITS); | |
| 1169 | 1100 | decode_inter_block( |
| 1170 | 1101 | &mut dec, |
| 1171 | 1102 | &mut cdfs, |
| @@ -1220,15 +1151,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1220 | 1151 | PARTITION_HORZ | PARTITION_VERT | PARTITION_HORZ_4 | PARTITION_VERT_4 |
| 1221 | 1152 | ) { |
| 1222 | 1153 | // lane-av1unwritten r6: arm census. |
| 1223 | - note_subsize_arm( | |
| 1224 | - part64, | |
| 1225 | - chroma_plane_block_codable( | |
| 1226 | - partition_subsize_dims((64, 64), part64).0, | |
| 1227 | - partition_subsize_dims((64, 64), part64).1, | |
| 1228 | - ss_x(fctx), | |
| 1229 | - ss_y(fctx), | |
| 1230 | - ), | |
| 1231 | - ); | |
| 1232 | 1154 | // lane-inter4 r1: the superblock-level rect + 1:4 pairs as |
| 1233 | 1155 | // inter blocks -- two 64x32 / 32x64 strips, or four 64x16 / |
| 1234 | 1156 | // 16x64 ones. Each piece keeps `side = SB` for every |
| @@ -1282,38 +1204,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1282 | 1204 | bw, |
| 1283 | 1205 | bh |
| 1284 | 1206 | ); |
| 1285 | - if !four && i == 0 && ((horz && !has_rows) || (!horz && !has_cols)) { | |
| 1286 | - bump_inter_edge_strip(if horz { 0 } else { 1 }); | |
| 1287 | - } | |
| 1288 | - match (horz, four) { | |
| 1289 | - (true, false) => hit!(INTER_SB_HORZ_HITS), | |
| 1290 | - (false, false) => hit!(INTER_SB_VERT_HITS), | |
| 1291 | - (true, true) => hit!(INTER_SB_HORZ4_HITS), | |
| 1292 | - (false, true) => hit!(INTER_SB_VERT4_HITS), | |
| 1293 | - } | |
| 1294 | 1207 | } |
| 1295 | 1208 | continue; |
| 1296 | 1209 | } |
| 1297 | 1210 | if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part64) { |
| 1298 | - // lane-sbab r1: the four superblock-level AB arms on the | |
| 1299 | - // INTER path -- two 32x32 inter squares plus one true | |
| 1300 | - // 64x32/32x64 inter strip, in libaom `decode_partition`'s own | |
| 1301 | - // order (decodeframe.c: HORZ_A = TL, TR, bottom strip; | |
| 1302 | - // HORZ_B = top strip, BL, BR; VERT_A = TL, BL, right strip; | |
| 1303 | - // VERT_B = left strip, TR, BR). Every piece is one this | |
| 1304 | - // decoder already proves elsewhere: the 32x32 square is the | |
| 1305 | - // `PARTITION_NONE`-under-SPLIT block below, the strip is the | |
| 1306 | - // `PARTITION_HORZ`/`VERT` piece above (`inter_piece!`, which | |
| 1307 | - // keeps `side = SB` for syntax/CDF and names its true | |
| 1308 | - // footprint through `write_w`/`write_h`). The intra-frame | |
| 1309 | - // twin of this arm is lane-part32 r4's `SB_AB_HITS` block. | |
| 1310 | - hit_do! { | |
| 1311 | - SB_AB_INTER_HITS.with(|c| { | |
| 1312 | - let mut h = c.get(); | |
| 1313 | - h[part64 - PARTITION_HORZ_A] += 1; | |
| 1314 | - c.set(h); | |
| 1315 | - }); | |
| 1316 | - } | |
| 1317 | 1211 | // lane-part32 r5 / class visit-order-changes-availability: |
| 1318 | 1212 | // only the two VERTICAL arms visit TL, BL, TR, BR, so only |
| 1319 | 1213 | // they switch libaom's `has_tr`/`has_bl` tables. |
| @@ -1442,14 +1336,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1442 | 1336 | has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows), |
| 1443 | 1337 | ); |
| 1444 | 1338 | let part32 = if has_cols32 && has_rows32 { |
| 1445 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 1446 | - eprintln!( | |
| 1447 | - "TRACE part32_pre mi=({},{}) rng={}", | |
| 1448 | - r32 * BLOCK_MI, | |
| 1449 | - c32 * BLOCK_MI, | |
| 1450 | - dec.debug_state().0 | |
| 1451 | - ); | |
| 1452 | - } | |
| 1453 | 1339 | // lane-av1tilerows: this rung printed the RAW 32-grid |
| 1454 | 1340 | // index (`r32`, `c32`) into its `mi_row=`/`mi_col=` |
| 1455 | 1341 | // fields — a factor of `BLOCK_MI` (8) off — while the |
| @@ -1460,23 +1346,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1460 | 1346 | // against libaom's per-level `EC_PART_VAL` dump, which |
| 1461 | 1347 | // is the only way to locate a partition-walk |
| 1462 | 1348 | // divergence. Behaviour-free: env-gated print only. |
| 1463 | - if crate::envflags::env_flag!("EC_TRACE_PART") { | |
| 1464 | - eprintln!( | |
| 1465 | - "EC_PART mi_row={} mi_col={} bsize=9 ctx={} rng={}", | |
| 1466 | - r32 * BLOCK_MI, | |
| 1467 | - c32 * BLOCK_MI, | |
| 1468 | - ctx32, | |
| 1469 | - dec.debug_state().0 | |
| 1470 | - ); | |
| 1471 | - } | |
| 1472 | 1349 | let p = dec.symbol(&mut cdfs.partition_w32[ctx32]); |
| 1473 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 1474 | - eprintln!( | |
| 1475 | - "TRACE partition_w32 mi=({},{}) ctx={ctx32} value={p}", | |
| 1476 | - r32 * BLOCK_MI, | |
| 1477 | - c32 * BLOCK_MI | |
| 1478 | - ); | |
| 1479 | - } | |
| 1480 | 1350 | p |
| 1481 | 1351 | } else { |
| 1482 | 1352 | match (has_cols32, has_rows32) { |
| @@ -1484,21 +1354,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1484 | 1354 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered |
| 1485 | 1355 | // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT |
| 1486 | 1356 | // (libaom `ec_read_partition_impl`). |
| 1487 | - if crate::envflags::env_flag!("EC_TRACE_PART") { | |
| 1488 | - eprintln!( | |
| 1489 | - "EC_PARTG mi_row={} mi_col={} bsize=9 ctx={} rng={}", | |
| 1490 | - r32 as usize * BLOCK_MI as usize, | |
| 1491 | - c32 as usize * BLOCK_MI as usize, | |
| 1492 | - ctx32, | |
| 1493 | - dec.debug_state().0 | |
| 1494 | - ); | |
| 1495 | - } | |
| 1496 | 1357 | if { |
| 1497 | 1358 | let b = dec.symbol_fixed(&gather( |
| 1498 | 1359 | &cdfs.partition_w32[ctx32], |
| 1499 | 1360 | VERT_ALIKE, |
| 1500 | 1361 | )); |
| 1501 | - bump_edge32(b.min(1)); | |
| 1502 | 1362 | b |
| 1503 | 1363 | } == 1 |
| 1504 | 1364 | { |
| @@ -1516,7 +1376,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1516 | 1376 | &cdfs.partition_w32[ctx32], |
| 1517 | 1377 | HORZ_ALIKE, |
| 1518 | 1378 | )); |
| 1519 | - bump_edge32(b.min(1)); | |
| 1520 | 1379 | b |
| 1521 | 1380 | } == 1 |
| 1522 | 1381 | { |
| @@ -1525,10 +1384,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1525 | 1384 | PARTITION_VERT |
| 1526 | 1385 | } |
| 1527 | 1386 | } |
| 1528 | - _ => { | |
| 1529 | - bump_edge_both_cut(1); | |
| 1530 | - PARTITION_SPLIT | |
| 1531 | - } | |
| 1387 | + _ => PARTITION_SPLIT, | |
| 1532 | 1388 | } |
| 1533 | 1389 | }; |
| 1534 | 1390 | // lane-av1unwritten r5: the partition symbol is RESOLVED (a full CDF read or |
| @@ -1611,24 +1467,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1611 | 1467 | // inter leaves through the very same loop the |
| 1612 | 1468 | // straddling case has always used. |
| 1613 | 1469 | let part16 = if has_cols16 && has_rows16 { |
| 1614 | - if crate::envflags::env_flag!("EC_TRACE_PART") { | |
| 1615 | - eprintln!( | |
| 1616 | - "EC_PART mi_row={} mi_col={} bsize=6 ctx={} rng={}", | |
| 1617 | - (sr * SUB_MI as usize), | |
| 1618 | - (sc * SUB_MI as usize), | |
| 1619 | - ctx16, | |
| 1620 | - dec.debug_state().0 | |
| 1621 | - ); | |
| 1622 | - } | |
| 1623 | 1470 | let p = dec.symbol(&mut cdfs.partition_w16[ctx16]); |
| 1624 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 1625 | - let (rng, _) = dec.debug_state(); | |
| 1626 | - eprintln!( | |
| 1627 | - "TRACE partition_w16 mi=({},{}) ctx={ctx16} value={p} rng={rng}", | |
| 1628 | - sr as u32 * SUB_MI, | |
| 1629 | - sc as u32 * SUB_MI | |
| 1630 | - ); | |
| 1631 | - } | |
| 1632 | 1471 | p |
| 1633 | 1472 | } else if !has_cols16 && !has_rows16 { |
| 1634 | 1473 | // lane-edgeboth r1: both axes cut by the true |
| @@ -1636,22 +1475,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1636 | 1475 | // forces PARTITION_SPLIT and reads NO symbol; |
| 1637 | 1476 | // the leaf loop below already drops the |
| 1638 | 1477 | // out-of-frame quadrants. |
| 1639 | - bump_edge_both_cut(0); | |
| 1640 | 1478 | PARTITION_SPLIT |
| 1641 | 1479 | } else { |
| 1642 | 1480 | if has_cols16 { |
| 1643 | 1481 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered |
| 1644 | 1482 | // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT |
| 1645 | 1483 | // (libaom `ec_read_partition_impl`). |
| 1646 | - if crate::envflags::env_flag!("EC_TRACE_PART") { | |
| 1647 | - eprintln!( | |
| 1648 | - "EC_PARTG mi_row={} mi_col={} bsize=6 ctx={} rng={}", | |
| 1649 | - sr * SUB_MI as usize, | |
| 1650 | - sc * SUB_MI as usize, | |
| 1651 | - ctx16, | |
| 1652 | - dec.debug_state().0 | |
| 1653 | - ); | |
| 1654 | - } | |
| 1655 | 1484 | if dec.symbol_fixed(&gather( |
| 1656 | 1485 | &cdfs.partition_w16[ctx16], |
| 1657 | 1486 | VERT_ALIKE, |
| @@ -1749,11 +1578,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1749 | 1578 | // residual path (`rect_inter_residual_supported` |
| 1750 | 1579 | // covers 16x8/8x16 since this round). |
| 1751 | 1580 | let horz = part16 == PARTITION_HORZ; |
| 1752 | - if horz { | |
| 1753 | - hit!(INTER_LEAF16_HORZ_HITS); | |
| 1754 | - } else { | |
| 1755 | - hit!(INTER_LEAF16_VERT_HITS); | |
| 1756 | - } | |
| 1757 | 1581 | let base_mi = sub16_to_mi(at16); |
| 1758 | 1582 | let (ww, wh) = if horz { (16, 8) } else { (8, 16) }; |
| 1759 | 1583 | for piece in 0..2 { |
| @@ -1768,7 +1592,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1768 | 1592 | && (piece_mi.0 >= mi_rows as usize |
| 1769 | 1593 | || piece_mi.1 >= mi_cols as usize) |
| 1770 | 1594 | { |
| 1771 | - bump_inter_edge_strip(if horz { 4 } else { 5 }); | |
| 1772 | 1595 | break; |
| 1773 | 1596 | } |
| 1774 | 1597 | decode_inter_block( |
| @@ -1861,7 +1684,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 1861 | 1684 | // block_size_high >= 16, blockd.h) both hold |
| 1862 | 1685 | // and the leaf/strip decoders' own gates |
| 1863 | 1686 | // apply unchanged. |
| 1864 | - bump_ab16_inter(part16 - PARTITION_HORZ_A); | |
| 1865 | 1687 | let _vert_guard = if part16 == PARTITION_VERT_A |
| 1866 | 1688 | || part16 == PARTITION_VERT_B |
| 1867 | 1689 | { |
| @@ -2035,20 +1857,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2035 | 1857 | bw, |
| 2036 | 1858 | bh |
| 2037 | 1859 | ); |
| 2038 | - if horz { | |
| 2039 | - hit!(INTER16_HORZ4_HITS); | |
| 2040 | - } else { | |
| 2041 | - hit!(INTER16_VERT4_HITS); | |
| 2042 | - } | |
| 2043 | 1860 | } |
| 2044 | 1861 | } else if part16 != PARTITION_SPLIT { |
| 2045 | 1862 | return Err(unsupported( |
| 2046 | 1863 | "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4", |
| 2047 | 1864 | )); |
| 2048 | 1865 | } else { |
| 2049 | - if has_cols16 && has_rows16 { | |
| 2050 | - hit!(INTER_SUB16_SPLIT_HITS); | |
| 2051 | - } | |
| 2052 | 1866 | let (mi_row0, mi_col0) = |
| 2053 | 1867 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 2054 | 1868 | let leaf_positions: Vec<(u32, u32)> = (0..4) |
| @@ -2062,13 +1876,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2062 | 1876 | // 7.11.3.3's scaled walk. The counter is what |
| 2063 | 1877 | // proves a gate actually reached a scaled |
| 2064 | 1878 | // leaf rather than a same-size reference. |
| 2065 | - if (1..8).any(|rf| { | |
| 2066 | - refpix | |
| 2067 | - .dims(rf) | |
| 2068 | - .is_some_and(|(w, _)| w != frame_width as usize) | |
| 2069 | - }) { | |
| 2070 | - hit!(SCALED_LEAF8_HITS); | |
| 2071 | - } | |
| 2072 | 1879 | let mut prev_leaves: Vec<( |
| 2073 | 1880 | (usize, usize), |
| 2074 | 1881 | bool, |
| @@ -2079,16 +1886,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2079 | 1886 | for (mr, mc) in leaf_positions { |
| 2080 | 1887 | let leaf_mi = (mr as usize, mc as usize); |
| 2081 | 1888 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); |
| 2082 | - if crate::envflags::env_flag!("EC_TRACE_PART") { | |
| 2083 | - eprintln!( | |
| 2084 | - "EC_PART mi_row={} mi_col={} bsize=3 ctx={} rng={}", | |
| 2085 | - leaf_mi.0, | |
| 2086 | - leaf_mi.1, | |
| 2087 | - leaf_ctx, | |
| 2088 | - dec.debug_state().0 | |
| 2089 | - ); | |
| 2090 | - } | |
| 2091 | - let ec_dbg_pre = dec.debug_state().0; | |
| 2092 | 1889 | let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| 2093 | 1890 | // lane-av1unwritten r6: the partition symbol is RESOLVED and about to be |
| 2094 | 1891 | // dispatched. `partition_subsize_dims` is libaom's `get_partition_subsize` |
| @@ -2098,13 +1895,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2098 | 1895 | // keep decoding because the helper is exact, not a heuristic. inter-frame 8x8 level. |
| 2099 | 1896 | refuse_invalid_subsize((8, 8), part8, fctx)?; |
| 2100 | 1897 | |
| 2101 | - if std::env::var_os("EC_DBG_SUB8").is_some() { | |
| 2102 | - let ec_dbg_post = dec.debug_state().0; | |
| 2103 | - eprintln!( | |
| 2104 | - "EC_DBG b8 mi=({},{}) ctx={leaf_ctx} val={part8} pre={ec_dbg_pre} post={ec_dbg_post}", | |
| 2105 | - leaf_mi.0, leaf_mi.1 | |
| 2106 | - ); | |
| 2107 | - } | |
| 2108 | 1898 | if part8 == PARTITION_SPLIT { |
| 2109 | 1899 | // lane-intersub8: four BLOCK_4X4 inter |
| 2110 | 1900 | // sub-blocks, chroma once per 8x8. |
| @@ -2138,15 +1928,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2138 | 1928 | // lane-av1unwritten r6: arm census -- an |
| 2139 | 1929 | // 8x8-level VERT selects BLOCK_4X8, which |
| 2140 | 1930 | // is INVALID at 4:2:2. |
| 2141 | - note_subsize_arm( | |
| 2142 | - part8, | |
| 2143 | - chroma_plane_block_codable( | |
| 2144 | - partition_subsize_dims((8, 8), part8).0, | |
| 2145 | - partition_subsize_dims((8, 8), part8).1, | |
| 2146 | - ss_x(fctx), | |
| 2147 | - ss_y(fctx), | |
| 2148 | - ), | |
| 2149 | - ); | |
| 2150 | 1931 | if part8 == PARTITION_VERT || part8 == PARTITION_HORZ { |
| 2151 | 1932 | // lane-intersub8 r3/r4/r5: two |
| 2152 | 1933 | // BLOCK_8X4 (HORZ) / BLOCK_4X8 (VERT) |
| @@ -2282,19 +2063,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2282 | 2063 | } |
| 2283 | 2064 | } |
| 2284 | 2065 | PARTITION_HORZ_B => { |
| 2285 | - // lane-warp r5: PARTITION_HORZ_B = 32x32 top strip + | |
| 2286 | - // 16x16 bottom-left + 16x16 bottom-right. aomenc | |
| 2287 | - // carves static regions into it; the strip is | |
| 2288 | - // decoded as a square 32x32 block: for a `skip` | |
| 2289 | - // block the symbol stream is identical to the true | |
| 2290 | - // 32x16 coding (no residual, no motion_mode/warp | |
| 2291 | - // symbol), and the square stamps it leaves over the | |
| 2292 | - // bottom half (neighbour arrays, skip/lf grids) are | |
| 2293 | - // re-stamped by the C/D leaves right after. The | |
| 2294 | - // mi-granular `left_side_mi` rows of a last-block-in- | |
| 2295 | - // tile strip leak 32-vs-16 only until the per-tile | |
| 2296 | - // `Neighbours::new` reset. | |
| 2297 | - hit!(EXTENDED_PARTITION_HITS); | |
| 2298 | 2066 | let at32 = at; |
| 2299 | 2067 | decode_inter_block( |
| 2300 | 2068 | &mut dec, |
| @@ -2454,13 +2222,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2454 | 2222 | } |
| 2455 | 2223 | } |
| 2456 | 2224 | PARTITION_HORZ => { |
| 2457 | - // lane-rect r2: two true 32x16 strips. Both read at | |
| 2458 | - // `side=BLOCK` (CDF/size-class selection stays square, | |
| 2459 | - // matching HORZ_B's accepted corner-cut) but bw4/bh4 | |
| 2460 | - // (mvstack.rs, `motion_mode_eligible`) now derive from | |
| 2461 | - // `write_w`/`write_h`'s true 32x16 footprint -- the | |
| 2462 | - // pin's fix (r1's finding). | |
| 2463 | - hit!(RECT_PARTITION_HITS); | |
| 2464 | 2225 | decode_inter_block( |
| 2465 | 2226 | &mut dec, |
| 2466 | 2227 | &mut cdfs, |
| @@ -2508,9 +2269,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2508 | 2269 | (frame_width as usize, frame_height as usize), |
| 2509 | 2270 | fctx, |
| 2510 | 2271 | )?; |
| 2511 | - if !has_rows32 { | |
| 2512 | - bump_edge32(2); | |
| 2513 | - } | |
| 2514 | 2272 | // lane-golomb r2: at the frame edge only the first half of the |
| 2515 | 2273 | // strip is coded (libaom `decode_partition` guards the second |
| 2516 | 2274 | // with the same has_rows32 test that made this partition non-square). |
| @@ -2562,14 +2320,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2562 | 2320 | (frame_width as usize, frame_height as usize), |
| 2563 | 2321 | fctx, |
| 2564 | 2322 | )?; |
| 2565 | - } else { | |
| 2566 | - bump_inter_edge_strip(2); | |
| 2567 | 2323 | } |
| 2568 | 2324 | } |
| 2569 | 2325 | PARTITION_VERT => { |
| 2570 | - // lane-rect r2: mirror of PARTITION_HORZ above with | |
| 2571 | - // width/height swapped. | |
| 2572 | - hit!(RECT_PARTITION_HITS); | |
| 2573 | 2326 | decode_inter_block( |
| 2574 | 2327 | &mut dec, |
| 2575 | 2328 | &mut cdfs, |
| @@ -2617,9 +2370,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2617 | 2370 | (frame_width as usize, frame_height as usize), |
| 2618 | 2371 | fctx, |
| 2619 | 2372 | )?; |
| 2620 | - if !has_cols32 { | |
| 2621 | - bump_edge32(3); | |
| 2622 | - } | |
| 2623 | 2373 | // lane-golomb r2: at the frame edge only the first half of the |
| 2624 | 2374 | // strip is coded (libaom `decode_partition` guards the second |
| 2625 | 2375 | // with the same has_cols32 test that made this partition non-square). |
| @@ -2671,15 +2421,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2671 | 2421 | (frame_width as usize, frame_height as usize), |
| 2672 | 2422 | fctx, |
| 2673 | 2423 | )?; |
| 2674 | - } else { | |
| 2675 | - bump_inter_edge_strip(3); | |
| 2676 | 2424 | } |
| 2677 | 2425 | } |
| 2678 | 2426 | PARTITION_HORZ_A => { |
| 2679 | - // lane-partab r1: two 16x16 squares on top + a true | |
| 2680 | - // 32x16 strip below (libaom decode_partition | |
| 2681 | - // PARTITION_HORZ_A: TL, TR, bottom strip). | |
| 2682 | - hit!(PARTAB_HITS); | |
| 2683 | 2427 | decode_inter_block( |
| 2684 | 2428 | &mut dec, |
| 2685 | 2429 | &mut cdfs, |
| @@ -2831,9 +2575,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2831 | 2575 | )?; |
| 2832 | 2576 | } |
| 2833 | 2577 | PARTITION_VERT_A => { |
| 2834 | - // lane-partab r1: mirror of PARTITION_HORZ_A with | |
| 2835 | - // width/height swapped (TL, BL, right 16x32 strip). | |
| 2836 | - hit!(PARTAB_HITS); | |
| 2837 | 2578 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 2838 | 2579 | decode_inter_block( |
| 2839 | 2580 | &mut dec, |
| @@ -2986,10 +2727,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 2986 | 2727 | )?; |
| 2987 | 2728 | } |
| 2988 | 2729 | PARTITION_VERT_B => { |
| 2989 | - // lane-partab r1: true 16x32 strip on the left + two | |
| 2990 | - // 16x16 squares on the right (libaom decode_partition | |
| 2991 | - // PARTITION_VERT_B: left strip, TR, BR). | |
| 2992 | - hit!(PARTAB_HITS); | |
| 2993 | 2730 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 2994 | 2731 | decode_inter_block( |
| 2995 | 2732 | &mut dec, |
| @@ -3177,11 +2914,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 3177 | 2914 | bw, |
| 3178 | 2915 | bh |
| 3179 | 2916 | ); |
| 3180 | - if horz { | |
| 3181 | - hit!(RECT4_32_HORZ_INTER_HITS); | |
| 3182 | - } else { | |
| 3183 | - hit!(RECT4_32_VERT_INTER_HITS); | |
| 3184 | - } | |
| 3185 | 2917 | } |
| 3186 | 2918 | } |
| 3187 | 2919 | _ => { |
| @@ -3228,51 +2960,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 3228 | 2960 | ); |
| 3229 | 2961 | } |
| 3230 | 2962 | |
| 3231 | - // lane-comppin r4: pre-loop-filter decode-order dump, matching aomdec's | |
| 3232 | - // own EC_AV1_PREFILT_DUMP shape (decodeframe.c ~5451) -- diffs against | |
| 3233 | - // that isolate whether a decode-order frame's mismatch already exists | |
| 3234 | - // in reconstruction (this dump) vs is introduced by the loop filter | |
| 3235 | - // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). | |
| 3236 | - // Decode-order frame marker for the EC_OBMC / EC_TRACE_MODE ladders. | |
| 3237 | - if crate::envflags::env_flag!("EC_OBMC") | |
| 3238 | - || crate::envflags::env_flag!("EC_TRACE_MODE") | |
| 3239 | - || crate::envflags::env_flag!("EC_PRED") | |
| 3240 | - { | |
| 3241 | - eprintln!( | |
| 3242 | - "EC_PICT idx={}", | |
| 3243 | - PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) | |
| 3244 | - ); | |
| 3245 | - } | |
| 3246 | - dump_stage16( | |
| 3247 | - "EC_AV1_PREFILT_DUMP16", | |
| 3248 | - &y, | |
| 3249 | - &u, | |
| 3250 | - &v, | |
| 3251 | - frame_width as usize, | |
| 3252 | - frame_height as usize, | |
| 3253 | - ss_x(fctx), | |
| 3254 | - ss_y(fctx), | |
| 3255 | - ); | |
| 3256 | - census_unwritten(&y, &u, &v); | |
| 3257 | - if let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_DUMP") { | |
| 3258 | - // lane-av1dumploud: loud on a short write (see the key-frame twin | |
| 3259 | - // above -- same file, same shape, same three planes). | |
| 3260 | - let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | |
| 3261 | - let narrow = |p: &PlaneBuf<'_>| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() }; | |
| 3262 | - crate::dumpio::write_planes( | |
| 3263 | - "EC_AV1_PREFILT_DUMP", | |
| 3264 | - format!("{path}.f{idx}"), | |
| 3265 | - &[&narrow(&y), &narrow(&u), &narrow(&v)], | |
| 3266 | - ); | |
| 3267 | - } else { | |
| 3268 | - PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | |
| 3269 | - } | |
| 3270 | - // lane-av1444edge: the inter-frame path's mi-aligned pre-loop-filter | |
| 3271 | - // dump, the rung the key-frame path has always had (see | |
| 3272 | - // `dump_prefilter_wide`). Placed beside the padded `EC_AV1_PREFILT_DUMP` | |
| 3273 | - // above, i.e. before the loop filters run, so the two agree on the point | |
| 3274 | - // in the sequence they sample. | |
| 3275 | - dump_prefilter_wide(&y, &u, &v); | |
| 3276 | 2963 | // lane-av1fwd: the encoder scores ~25 filter candidates against this |
| 3277 | 2964 | // same coded tile ([`FilterReplay`]). Capture the reconstruction here, |
| 3278 | 2965 | // before either filter has touched it -- but only on the shape whose |
| @@ -3314,42 +3001,16 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 3314 | 3001 | plane_snapshot(&v, ss_y(fctx) as u32), |
| 3315 | 3002 | ) |
| 3316 | 3003 | }); |
| 3317 | - // lane-tiny r4: post-deblock / post-CDEF dumps mirroring aomdec's own | |
| 3318 | - // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter | |
| 3319 | - // dump above these bisect WHICH filter stage introduced a mismatch. | |
| 3320 | - dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); | |
| 3321 | - dump_stage16( | |
| 3322 | - "EC_AV1_POSTDEBLOCK_DUMP16", | |
| 3323 | - &y, | |
| 3324 | - &u, | |
| 3325 | - &v, | |
| 3326 | - frame_width as usize, | |
| 3327 | - frame_height as usize, | |
| 3328 | - ss_x(fctx), | |
| 3329 | - ss_y(fctx), | |
| 3330 | - ); | |
| 3331 | 3004 | apply_cdef( |
| 3332 | 3005 | &mut y, |
| 3333 | 3006 | &mut u, |
| 3334 | 3007 | &mut v, |
| 3335 | 3008 | cdef, |
| 3336 | 3009 | &neighbours, |
| 3337 | - (frame_width as usize, frame_height as usize), | |
| 3338 | 3010 | fctx, |
| 3339 | 3011 | None, |
| 3340 | 3012 | None, |
| 3341 | 3013 | ); |
| 3342 | - dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); | |
| 3343 | - dump_stage16( | |
| 3344 | - "EC_AV1_POSTCDEF_DUMP16", | |
| 3345 | - &y, | |
| 3346 | - &u, | |
| 3347 | - &v, | |
| 3348 | - frame_width as usize, | |
| 3349 | - frame_height as usize, | |
| 3350 | - ss_x(fctx), | |
| 3351 | - ss_y(fctx), | |
| 3352 | - ); | |
| 3353 | 3014 | capture_stages(&y, &u, &v, deblocked.as_ref(), fctx); |
| 3354 | 3015 | // spec 7.16 (libaom `superres_post_decode`, decodeframe.c: called |
| 3355 | 3016 | // between `av1_cdef_frame` and `av1_loop_restoration_filter_frame`): |
crates/ec-av1/src/decode/inter_block.rsmodified+35 -375
| @@ -123,8 +123,6 @@ pub(super) fn decode_inter_block( | ||
| 123 | 123 | // Round 27: the per-read trace is the only instrument that reaches the inter |
| 124 | 124 | // path (the coefficient rungs stop well before the frame-3 divergence), |
| 125 | 125 | // so publish the phase and the block's mi for every read it makes. |
| 126 | - crate::msac::SymbolDecoder::set_symr_phase("inter"); | |
| 127 | - crate::msac::SymbolDecoder::set_symr_mi(at.0 as i64, at.1 as i64); | |
| 128 | 126 | // lane-inter4 r1: `at` is in MI units (4 px) so a 32-level 1:4 strip can |
| 129 | 127 | // name an 8-px offset; `(r, c)` stays the enclosing 16-px cell for the |
| 130 | 128 | // few 16-px-granular uses below. |
| @@ -135,7 +133,6 @@ pub(super) fn decode_inter_block( | ||
| 135 | 133 | // exactly what it read before. |
| 136 | 134 | let (rmi, cmi) = at; |
| 137 | 135 | let (px, py) = (at.1 * MI, at.0 * MI); |
| 138 | - census_inter_block_shape(side, write_w, write_h); | |
| 139 | 136 | // lane-inter16ab r2: a 16x4 / 4x16 inter strip's chroma is the PAIR's |
| 140 | 137 | // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd |
| 141 | 138 | // strip (`is_chroma_reference`); every other block keeps its own. |
| @@ -233,30 +230,12 @@ pub(super) fn decode_inter_block( | ||
| 233 | 230 | // bails per PLANE at `block_width < 8 || block_height < 8` -- on the |
| 234 | 231 | // block's own dims, never on the square prediction buffer this reader |
| 235 | 232 | // allocates. |
| 236 | - if crate::envflags::env_flag!("EC_MC_TRACE") { | |
| 237 | - eprintln!("EC_IB px={px} py={py} side={side} w={write_w} h={write_h}"); | |
| 238 | - } | |
| 239 | 233 | |
| 240 | - if crate::envflags::env_flag!("EC_AV1_TELL") { | |
| 241 | - eprintln!( | |
| 242 | - "TELL mi_row={} mi_col={} label=block_entry side={side} tell={} range={}", | |
| 243 | - rmi, | |
| 244 | - cmi, | |
| 245 | - dec.debug_bitpos(), | |
| 246 | - dec.debug_state().0 | |
| 247 | - ); | |
| 248 | - } | |
| 249 | 234 | let skip_mode_ctx = |
| 250 | 235 | usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]); |
| 251 | 236 | // lane-comppin r3: skip_mode desync isolation -- dump ctx + the pre-read |
| 252 | 237 | // MSAC tell so it can be diffed against an equivalent hook in libaom's |
| 253 | 238 | // own `read_skip_mode`/`av1_get_skip_mode_context`. |
| 254 | - if crate::envflags::env_flag!("EC_AV1_SKIPMODE_DUMP") { | |
| 255 | - eprintln!( | |
| 256 | - "EC_SKIPMODE r={r} c={c} ctx={skip_mode_ctx} skip_mode_present={skip_mode_present} tell_before={}", | |
| 257 | - dec.debug_bitpos() | |
| 258 | - ); | |
| 259 | - } | |
| 260 | 239 | // spec 5.11.5 `inter_frame_mode_info`: `inter_segment_id(1)` before |
| 261 | 240 | // `skip_mode`/`skip`, `inter_segment_id(0)` after them. |
| 262 | 241 | let (seg_mi_r, seg_mi_c) = (rmi, cmi); |
| @@ -270,15 +249,6 @@ pub(super) fn decode_inter_block( | ||
| 270 | 249 | let comp_allowed = write_w.min(write_h) >= 8; |
| 271 | 250 | let skip_mode = |
| 272 | 251 | skip_mode_present && comp_allowed && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; |
| 273 | - if crate::envflags::env_flag!("EC_AV1_SKIPMODE_DUMP") { | |
| 274 | - eprintln!( | |
| 275 | - "EC_SKIPMODE r={r} c={c} result={skip_mode} tell_after={}", | |
| 276 | - dec.debug_bitpos() | |
| 277 | - ); | |
| 278 | - } | |
| 279 | - if skip_mode { | |
| 280 | - hit!(SKIP_MODE_HITS); | |
| 281 | - } | |
| 282 | 252 | |
| 283 | 253 | let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); |
| 284 | 254 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; |
| @@ -303,16 +273,6 @@ pub(super) fn decode_inter_block( | ||
| 303 | 273 | // chunk). An INTRA block at that size inside an inter frame takes the |
| 304 | 274 | // intra tail below, which still codes one whole-block chroma unit and one |
| 305 | 275 | // `read_tx_size` at 128 -- refuse by name instead of mis-decoding it. |
| 306 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 307 | - eprintln!( | |
| 308 | - "EC_MODE mi_row={} mi_col={} rng={} is_inter={} skip={} side={side}", | |
| 309 | - rmi, | |
| 310 | - cmi, | |
| 311 | - dec.debug_state().0, | |
| 312 | - u8::from(is_inter), | |
| 313 | - u8::from(skip) | |
| 314 | - ); | |
| 315 | - } | |
| 316 | 276 | // lane-warp r5: see `reject_residual` -- a square-block decode of a |
| 317 | 277 | // HORZ_B strip is symbol-exact only for `skip` (no residual, no |
| 318 | 278 | // motion_mode/warp symbol). lane-intrarect r1 MOVED this gate from just |
| @@ -332,26 +292,10 @@ pub(super) fn decode_inter_block( | ||
| 332 | 292 | && !rect_inter_residual_supported(write_w, write_h) |
| 333 | 293 | && (is_inter || (write_w == side && write_h == side)) |
| 334 | 294 | { |
| 335 | - if crate::envflags::env_flag!("EC_RECTRES") { | |
| 336 | - eprintln!( | |
| 337 | - "EC_RECTRES w={write_w} h={write_h} side={side} skip={} is_inter={} mi_row={rmi} mi_col={cmi}", | |
| 338 | - u8::from(skip), | |
| 339 | - u8::from(is_inter) | |
| 340 | - ); | |
| 341 | - } | |
| 342 | 295 | return Err(unsupported( |
| 343 | 296 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", |
| 344 | 297 | )); |
| 345 | 298 | } |
| 346 | - if crate::envflags::env_flag!("EC_AV1_TELL") { | |
| 347 | - eprintln!( | |
| 348 | - "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}", | |
| 349 | - rmi, | |
| 350 | - cmi, | |
| 351 | - dec.debug_bitpos(), | |
| 352 | - dec.debug_state().0 | |
| 353 | - ); | |
| 354 | - } | |
| 355 | 299 | |
| 356 | 300 | let mode_for_tx; |
| 357 | 301 | let uv_predict_mode; |
| @@ -411,12 +355,6 @@ pub(super) fn decode_inter_block( | ||
| 411 | 355 | uni: neighbours.left_ref1[rmi] |
| 412 | 356 | .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[rmi], r1)), |
| 413 | 357 | }); |
| 414 | - if crate::envflags::env_flag!("EC_AV1_COMPIDX_DUMP") { | |
| 415 | - eprintln!( | |
| 416 | - "EC_PRECOMP r={r} c={c} skip_mode={skip_mode} skip={skip} reference_select={reference_select} tell={}", | |
| 417 | - dec.debug_bitpos() | |
| 418 | - ); | |
| 419 | - } | |
| 420 | 358 | let is_compound = skip_mode |
| 421 | 359 | || (reference_select |
| 422 | 360 | // `is_comp_ref_allowed` (blockd.h:65) gates the |
| @@ -498,22 +436,6 @@ pub(super) fn decode_inter_block( | ||
| 498 | 436 | ), |
| 499 | 437 | fctx, |
| 500 | 438 | ); |
| 501 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 502 | - eprintln!( | |
| 503 | - "EC_MODE_VAL mi_row={mi_row} mi_col={mi_col} mode={} ref0={ref0} ref1={ref1} mv0=({},{}) stack={} rng={}", | |
| 504 | - compound_mode + 17, | |
| 505 | - mv0.0, | |
| 506 | - mv0.1, | |
| 507 | - comp_stack.entries.len(), | |
| 508 | - dec.debug_state().0 | |
| 509 | - ); | |
| 510 | - for (i, e) in comp_stack.entries.iter().enumerate() { | |
| 511 | - eprintln!( | |
| 512 | - "EC_STACK mi_row={mi_row} mi_col={mi_col} i={i} this=({},{}) comp=({},{}) w={}", | |
| 513 | - e.mv0.0, e.mv0.1, e.mv1.0, e.mv1.1, e.weight | |
| 514 | - ); | |
| 515 | - } | |
| 516 | - } | |
| 517 | 439 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV |
| 518 | 440 | // be non-TRANSLATION (IDENTITY counts) for the compound block's |
| 519 | 441 | // interp-filter read to be suppressed. |
| @@ -526,9 +448,6 @@ pub(super) fn decode_inter_block( | ||
| 526 | 448 | // `AOMMIN(mi_size_wide, mi_size_high) < 2` before it looks at any |
| 527 | 449 | // model, so a 4-px-sided block still reads its interp filter. |
| 528 | 450 | let gm_nontrans = gm_nontrans_models && bw4.min(bh4) >= 2; |
| 529 | - if gm_nontrans_models && !gm_nontrans { | |
| 530 | - hit!(GM_NONTRANS_SMALL_SIDE_HITS); | |
| 531 | - } | |
| 532 | 451 | // lane-defer8: both slots' pictures are resolved inside the |
| 533 | 452 | // prediction closure; the parse only needs their SIZES. |
| 534 | 453 | // lane-cwarp r1: `is_global_mv_block` (blockd.h:421-429) is |
| @@ -551,14 +470,6 @@ pub(super) fn decode_inter_block( | ||
| 551 | 470 | // alone, which counts blocks that are not global-mv blocks at |
| 552 | 471 | // all, so its number was an upper bound dressed up as an |
| 553 | 472 | // engagement figure. |
| 554 | - if mi_row < mi_rows as usize / 2 { | |
| 555 | - if is_globalmv { | |
| 556 | - TOP_HALF_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); | |
| 557 | - } | |
| 558 | - if is_global_mv0 || is_global_mv1 { | |
| 559 | - TOP_HALF_WARP_HITS.with(|c| c.set(c.get() + 1)); | |
| 560 | - } | |
| 561 | - } | |
| 562 | 473 | // libaom `av1_init_warp_params` + `allow_warp`'s |
| 563 | 474 | // `global_warp_allowed` branch, run once per reference for a |
| 564 | 475 | // compound block exactly as for a single-ref one (reconinter.c |
| @@ -595,7 +506,6 @@ pub(super) fn decode_inter_block( | ||
| 595 | 506 | let warp0 = compound_warp(ref0, is_global_mv0).filter(|_| ref_unscaled(ref0)); |
| 596 | 507 | let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1)); |
| 597 | 508 | if warp0.is_some() || warp1.is_some() { |
| 598 | - hit!(COMPOUND_WARP_HITS); | |
| 599 | 509 | // lane-av112bitw: the 12-bit refusal that stood here is |
| 600 | 510 | // LIFTED with the compound-warp witness: the rotating- |
| 601 | 511 | // mandelbrot 12-bit recipe refused exactly here pre-lift and |
| @@ -668,17 +578,10 @@ pub(super) fn decode_inter_block( | ||
| 668 | 578 | && enable_masked_compound |
| 669 | 579 | && is_any_masked_compound_used_here(write_w, write_h) |
| 670 | 580 | { |
| 671 | - crate::msac::SymbolDecoder::set_symr_cdf("comp_group_idx"); | |
| 672 | 581 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) |
| 673 | 582 | } else { |
| 674 | 583 | 0 |
| 675 | 584 | }; |
| 676 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 677 | - eprintln!( | |
| 678 | - "EC_CGI mi_row={rmi} mi_col={cmi} ctx={group_ctx} val={comp_group_idx} rng={}", | |
| 679 | - dec.debug_state().0 | |
| 680 | - ); | |
| 681 | - } | |
| 682 | 585 | // lane-maskcomp r2 / lane-wedge r3: `Some(mask_type)` for a |
| 683 | 586 | // `COMPOUND_DIFFWTD` block, `Some(mask)` (wedge codebook lookup) |
| 684 | 587 | // for a `COMPOUND_WEDGE` block -- exactly one of the two is set |
| @@ -714,16 +617,6 @@ pub(super) fn decode_inter_block( | ||
| 714 | 617 | // verified vs independent C dump (wedge.rs). |
| 715 | 618 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); |
| 716 | 619 | let wedge_sign = dec.literal(1); |
| 717 | - hit!(WEDGE_HITS); | |
| 718 | - if let Some(k) = rect_wedge_slot(write_w, write_h) { | |
| 719 | - hit_do! { | |
| 720 | - RECT_WEDGE_HITS.with(|c| { | |
| 721 | - let mut a = c.get(); | |
| 722 | - a[k] += 1; | |
| 723 | - c.set(a); | |
| 724 | - }); | |
| 725 | - } | |
| 726 | - } | |
| 727 | 620 | // lane-inter16ab r5: the codebook row is this block's TRUE |
| 728 | 621 | // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for |
| 729 | 622 | // h>w, hltw for h<w, plus that bsize's own signflip row). |
| @@ -740,13 +633,6 @@ pub(super) fn decode_inter_block( | ||
| 740 | 633 | // COMPOUND_DIFFWTD: `mask_type`, MAX_DIFFWTD_MASK_BITS==1. |
| 741 | 634 | let mask_type = dec.literal(1); |
| 742 | 635 | diffwtd_mask_type = Some(mask_type as u8); |
| 743 | - if wedge_bsize.is_none() { | |
| 744 | - hit!(DIFFWTD_INFERRED_HITS); | |
| 745 | - } | |
| 746 | - } | |
| 747 | - hit!(MASKED_COMPOUND_HITS); | |
| 748 | - if write_w != write_h { | |
| 749 | - hit!(RECT_MASKED_COMPOUND_HITS); | |
| 750 | 636 | } |
| 751 | 637 | } |
| 752 | 638 | // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): r16/r17 |
| @@ -959,21 +845,10 @@ pub(super) fn decode_inter_block( | ||
| 959 | 845 | ref_order_hints[(ref0 - LAST_FRAME) as usize], |
| 960 | 846 | ref_order_hints[(ref1 - LAST_FRAME) as usize], |
| 961 | 847 | ); |
| 962 | - crate::msac::SymbolDecoder::set_symr_cdf("compound_idx"); | |
| 963 | 848 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); |
| 964 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 965 | - eprintln!( | |
| 966 | - "EC_CIDX mi_row={rmi} mi_col={cmi} ctx={idx_ctx} val={idx} rng={}", | |
| 967 | - dec.debug_state().0 | |
| 968 | - ); | |
| 969 | - } | |
| 970 | 849 | if idx == 1 { |
| 971 | 850 | (8, 8, 1u8) |
| 972 | 851 | } else { |
| 973 | - // lane-av1distwtd: `idx == 0` is the | |
| 974 | - // distance-weighted arm -- the only branch whose | |
| 975 | - // weights are NOT the constant (8, 8) split. | |
| 976 | - hit!(DIST_WTD_COMP_HITS); | |
| 977 | 852 | let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign( |
| 978 | 853 | order_hint_bits, |
| 979 | 854 | order_hint, |
| @@ -986,16 +861,6 @@ pub(super) fn decode_inter_block( | ||
| 986 | 861 | (8, 8, 1u8) |
| 987 | 862 | }; |
| 988 | 863 | compound_ctx = Some((ref1, comp_group_idx as u8, compound_idx)); |
| 989 | - if crate::envflags::env_flag!("EC_AV1_COMPIDX_DUMP") { | |
| 990 | - eprintln!( | |
| 991 | - "EC_COMPIDX mi_row={mi_row} mi_col={mi_col} bsize={side} mode={compound_mode} mv0=({},{}) mv1=({},{}) ref0={ref0} ref1={ref1} comp_group_idx={comp_group_idx} compound_idx={compound_idx} tell={}", | |
| 992 | - mv0.0, | |
| 993 | - mv0.1, | |
| 994 | - mv1.0, | |
| 995 | - mv1.1, | |
| 996 | - dec.debug_bitpos() | |
| 997 | - ); | |
| 998 | - } | |
| 999 | 864 | |
| 1000 | 865 | // spec 5.11.19/libaom `decodemv.c` 1575: `read_mb_interp_filter` |
| 1001 | 866 | // comes AFTER `read_compound_type` (the `comp_group_idx`/ |
| @@ -1028,15 +893,9 @@ pub(super) fn decode_inter_block( | ||
| 1028 | 893 | // stride-1 one, so the unscaled case is unchanged. |
| 1029 | 894 | let scale0 = scale_of(ref_dims(ref0, refpix)?, frame_size); |
| 1030 | 895 | let scale1 = scale_of(ref_dims(ref1, refpix)?, frame_size); |
| 1031 | - if !scale0.is_unscaled() || !scale1.is_unscaled() { | |
| 1032 | - hit!(SCALED_COMPOUND_HITS); | |
| 1033 | - } | |
| 1034 | 896 | // lane-scaledref r2: the MIXED case -- one tap scaled, the other |
| 1035 | 897 | // not -- is the one an all-frames-scaled recipe never produces, |
| 1036 | 898 | // and the one a single shared scale factor would get wrong. |
| 1037 | - if (scale0.is_unscaled()) != (scale1.is_unscaled()) { | |
| 1038 | - hit!(MIXED_SCALE_COMPOUND_HITS); | |
| 1039 | - } | |
| 1040 | 899 | |
| 1041 | 900 | // lane-wave4 (the compound arm's half): this block's whole |
| 1042 | 901 | // prediction -- both references, the wedge/diffwtd/distance |
| @@ -1148,7 +1007,6 @@ pub(super) fn decode_inter_block( | ||
| 1148 | 1007 | // either way, only the mask source differs. |
| 1149 | 1008 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { |
| 1150 | 1009 | diffwtd_mask_y = vec![0u8; side * side]; |
| 1151 | - hit!(DIFFWTD_HITS); | |
| 1152 | 1010 | mc::diffwtd_mask( |
| 1153 | 1011 | &inter0_y, |
| 1154 | 1012 | &inter1_y, |
| @@ -1415,7 +1273,23 @@ pub(super) fn decode_inter_block( | ||
| 1415 | 1273 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); |
| 1416 | 1274 | let (sy, su, sv) = if pred_deferred(refpix) { |
| 1417 | 1275 | push_pred(build); |
| 1418 | - (Pred::Cur { plane: 0, stride: side, off: 0 }, Pred::Cur { plane: 1, stride: chroma_stride, off: 0 }, Pred::Cur { plane: 2, stride: chroma_stride, off: 0 }) | |
| 1276 | + ( | |
| 1277 | + Pred::Cur { | |
| 1278 | + plane: 0, | |
| 1279 | + stride: side, | |
| 1280 | + off: 0, | |
| 1281 | + }, | |
| 1282 | + Pred::Cur { | |
| 1283 | + plane: 1, | |
| 1284 | + stride: chroma_stride, | |
| 1285 | + off: 0, | |
| 1286 | + }, | |
| 1287 | + Pred::Cur { | |
| 1288 | + plane: 2, | |
| 1289 | + stride: chroma_stride, | |
| 1290 | + off: 0, | |
| 1291 | + }, | |
| 1292 | + ) | |
| 1419 | 1293 | } else { |
| 1420 | 1294 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 1421 | 1295 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -1597,14 +1471,6 @@ pub(super) fn decode_inter_block( | ||
| 1597 | 1471 | fctx, |
| 1598 | 1472 | )? |
| 1599 | 1473 | } else { |
| 1600 | - // lane-r14 r3: a 1:4 strip's `sub_tx_size_map` | |
| 1601 | - // sub-transform is RECTANGULAR (TX_64X16 -> | |
| 1602 | - // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is | |
| 1603 | - // read with the rect coefficient machinery, at its | |
| 1604 | - // own `txb_skip_ctx`/neighbour spans -- the unit is | |
| 1605 | - // smaller than its block, so `get_txb_ctx_general`'s | |
| 1606 | - // neighbour table applies, not the lone-TU 0. | |
| 1607 | - vartx_rect_leaf_hit(tw, th); | |
| 1608 | 1474 | let tu_skip_ctx = |
| 1609 | 1475 | neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); |
| 1610 | 1476 | let start = row * MI * side + col * MI; |
| @@ -1852,7 +1718,6 @@ pub(super) fn decode_inter_block( | ||
| 1852 | 1718 | plane_idx, |
| 1853 | 1719 | &cu_grid, |
| 1854 | 1720 | ); |
| 1855 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 1856 | 1721 | mu_chroma = true; |
| 1857 | 1722 | // lane-av1muchunk422b: the allocation of this |
| 1858 | 1723 | // mu-chunk walk, counted per TX_32X32 UNIT. |
| @@ -1861,9 +1726,6 @@ pub(super) fn decode_inter_block( | ||
| 1861 | 1726 | // bump: `MU_CHUNK_COMPOUND_UNITS` names site 2 |
| 1862 | 1727 | // and the single-reference twin (site 5) stays |
| 1863 | 1728 | // out of it. |
| 1864 | - if is_compound { | |
| 1865 | - hit!(MU_CHUNK_COMPOUND_UNITS); | |
| 1866 | - } | |
| 1867 | 1729 | let dst = mu_units( |
| 1868 | 1730 | if plane_idx == 1 { |
| 1869 | 1731 | &mut u_units |
| @@ -2068,12 +1930,6 @@ pub(super) fn decode_inter_block( | ||
| 2068 | 1930 | let cu_rel_mi = (cr * (cu_tx / MI), cc * (cu_tx / MI)); |
| 2069 | 1931 | let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi) |
| 2070 | 1932 | .unwrap_or(luma_tx_type); |
| 2071 | - if covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi).is_some() { | |
| 2072 | - hit!(CHROMA_QUAD_LEAF_TX_HITS); | |
| 2073 | - if cu_tx_type != luma_tx_type { | |
| 2074 | - hit!(CHROMA_QUAD_LEAF_TX_DIFF_HITS); | |
| 2075 | - } | |
| 2076 | - } | |
| 2077 | 1933 | let cu_grid = read_inter_plane( |
| 2078 | 1934 | dec, |
| 2079 | 1935 | cdfs, |
| @@ -2099,7 +1955,6 @@ pub(super) fn decode_inter_block( | ||
| 2099 | 1955 | // this one's coefficients. |
| 2100 | 1956 | neighbours |
| 2101 | 1957 | .record_mi_chroma(cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid); |
| 2102 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 2103 | 1958 | // lane-av1-444 c8: the unit's levels must ALSO |
| 2104 | 1959 | // land in the block grid -- the block-tail mu |
| 2105 | 1960 | // re-stamp slices the per-unit states back out |
| @@ -2177,14 +2032,6 @@ pub(super) fn decode_inter_block( | ||
| 2177 | 2032 | neighbours.left_ref1[rmi], |
| 2178 | 2033 | ); |
| 2179 | 2034 | ref_frame_for_lf = ref_frame; |
| 2180 | - if crate::envflags::env_flag!("EC_AV1_TELL") { | |
| 2181 | - let (mi_row, mi_col) = (rmi, cmi); | |
| 2182 | - eprintln!( | |
| 2183 | - "TELL mi_row={mi_row} mi_col={mi_col} label=post_ref_frame ref={ref_frame} tell={} range={}", | |
| 2184 | - dec.debug_bitpos(), | |
| 2185 | - dec.debug_state().0 | |
| 2186 | - ); | |
| 2187 | - } | |
| 2188 | 2035 | // round 4-9 (lane-av1golden..lane-av1golden7): GOLDEN_FRAME's own |
| 2189 | 2036 | // stacked defects (lf_level ref/mode-delta forwarding, the |
| 2190 | 2037 | // switchable_interp ref-frame ctx gate, and a film-grain synthesis |
| @@ -2245,14 +2092,10 @@ pub(super) fn decode_inter_block( | ||
| 2245 | 2092 | tpl, |
| 2246 | 2093 | ); |
| 2247 | 2094 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| 2248 | - if !not_new { | |
| 2249 | - crate::census::mode(0); | |
| 2250 | - } | |
| 2251 | 2095 | let mut is_globalmv = false; |
| 2252 | 2096 | // lane-interbis r1: which single-ref mode this block resolved to, |
| 2253 | 2097 | // in the oracle's own numbering (NEARESTMV=13 .. NEWMV=16), for |
| 2254 | 2098 | // the `EC_MODE_VAL` value ladder below. |
| 2255 | - let mut dbg_mode = 16u32; | |
| 2256 | 2099 | let (mv, is_new_mv) = if !not_new { |
| 2257 | 2100 | // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0): |
| 2258 | 2101 | // read at most two `drl_mode` bits, one per stack entry past the |
| @@ -2282,19 +2125,13 @@ pub(super) fn decode_inter_block( | ||
| 2282 | 2125 | ) |
| 2283 | 2126 | } else { |
| 2284 | 2127 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; |
| 2285 | - if !not_zero { | |
| 2286 | - crate::census::mode(1); | |
| 2287 | - } | |
| 2288 | 2128 | is_globalmv = !not_zero; |
| 2289 | 2129 | let mv = if !not_zero { |
| 2290 | 2130 | // GLOBALMV: `gm_get_motion_vector` (spec 7.10.2.1), already |
| 2291 | 2131 | // computed at this block's own position in `gm_table`. |
| 2292 | - dbg_mode = 15; | |
| 2293 | 2132 | gm_table[(ref_frame - LAST_FRAME) as usize] |
| 2294 | 2133 | } else { |
| 2295 | 2134 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; |
| 2296 | - crate::census::mode(if nearest { 2 } else { 3 }); | |
| 2297 | - dbg_mode = if nearest { 13 } else { 14 }; | |
| 2298 | 2135 | if nearest { |
| 2299 | 2136 | stack.nearest_mv |
| 2300 | 2137 | } else { |
| @@ -2316,26 +2153,6 @@ pub(super) fn decode_inter_block( | ||
| 2316 | 2153 | }; |
| 2317 | 2154 | (mv, false) |
| 2318 | 2155 | }; |
| 2319 | - if crate::msac::symtrace::dir().is_some() { | |
| 2320 | - crate::msac::symtrace::note(&format!( | |
| 2321 | - " MODE mi=({mi_row},{mi_col}) dbg={dbg_mode} mv={mv:?}" | |
| 2322 | - )); | |
| 2323 | - } | |
| 2324 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 2325 | - for (i, e) in stack.entries.iter().enumerate() { | |
| 2326 | - eprintln!( | |
| 2327 | - "EC_STACK mi_row={mi_row} mi_col={mi_col} ref={ref_frame} i={i} this=({},{}) comp=(0,0) w={}", | |
| 2328 | - e.mv.0, e.mv.1, e.weight | |
| 2329 | - ); | |
| 2330 | - } | |
| 2331 | - eprintln!( | |
| 2332 | - "EC_MODE_VAL mi_row={mi_row} mi_col={mi_col} mode={dbg_mode} ref0={ref_frame} ref1=-1 mv0=({},{}) stack={} rng={}", | |
| 2333 | - mv.0, | |
| 2334 | - mv.1, | |
| 2335 | - stack.entries.len(), | |
| 2336 | - dec.debug_state().0 | |
| 2337 | - ); | |
| 2338 | - } | |
| 2339 | 2156 | // lane-gm r2: the two libaom predicates single-ref GLOBALMV |
| 2340 | 2157 | // blocks need -- `is_global_mv_block` (blockd.h:421-429, mode |
| 2341 | 2158 | // GLOBAL* AND model > TRANSLATION AND min(bw,bh) >= 8px, gating |
| @@ -2348,13 +2165,6 @@ pub(super) fn decode_inter_block( | ||
| 2348 | 2165 | let is_global_mv_block = is_globalmv && gm_model as u8 > 1 && min_bw_bh4 >= 2; |
| 2349 | 2166 | let gm_nontrans = |
| 2350 | 2167 | is_globalmv && gm_model != ec_av1_syntax::WarpModel::Translation && min_bw_bh4 >= 2; |
| 2351 | - if crate::envflags::env_flag!("EC_AV1_TELL") { | |
| 2352 | - eprintln!( | |
| 2353 | - "TELL mi_row={mi_row} mi_col={mi_col} label=post_assign_mv tell={} range={}", | |
| 2354 | - dec.debug_bitpos(), | |
| 2355 | - dec.debug_state().0 | |
| 2356 | - ); | |
| 2357 | - } | |
| 2358 | 2168 | // lane-sb128 r4: `interintra` (spec 5.11.24; libaom |
| 2359 | 2169 | // `decodemv.c` read_inter_block_mode_info ~1490-1510), placed |
| 2360 | 2170 | // right after `assign_mv` and before `read_motion_mode` below -- |
| @@ -2384,7 +2194,6 @@ pub(super) fn decode_inter_block( | ||
| 2384 | 2194 | // TRUE footprint -- a 16x8 strip is group 1, a 32x16 strip |
| 2385 | 2195 | // group 2, not their square `side`'s 2/3. |
| 2386 | 2196 | let bsize_group = size_group_wh(write_w, write_h); |
| 2387 | - crate::msac::SymbolDecoder::set_symr_cdf("interintra"); | |
| 2388 | 2197 | let interintra = dec.symbol(&mut cdfs.interintra[bsize_group]) == 1; |
| 2389 | 2198 | if interintra { |
| 2390 | 2199 | // lane-interintra r1 (decodemv.c 1540-1555): interintra_mode, |
| @@ -2406,16 +2215,6 @@ pub(super) fn decode_inter_block( | ||
| 2406 | 2215 | // NO sign symbol follows -- libaom fixes |
| 2407 | 2216 | // INTERINTRA_WEDGE_SIGN 0 (blockd.h). |
| 2408 | 2217 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); |
| 2409 | - hit!(WII_HITS); | |
| 2410 | - if let Some(k) = rect_wedge_slot(write_w, write_h) { | |
| 2411 | - hit_do! { | |
| 2412 | - RECT_WII_HITS.with(|c| { | |
| 2413 | - let mut a = c.get(); | |
| 2414 | - a[k] += 1; | |
| 2415 | - c.set(a); | |
| 2416 | - }); | |
| 2417 | - } | |
| 2418 | - } | |
| 2419 | 2218 | // lane-inter16ab r5: true-footprint codebook row, |
| 2420 | 2219 | // mask padded to stride `max(bw,bh) == side` -- see |
| 2421 | 2220 | // the compound site's own comment. |
| @@ -2425,8 +2224,6 @@ pub(super) fn decode_inter_block( | ||
| 2425 | 2224 | .mask(0, wedge_index), |
| 2426 | 2225 | side, |
| 2427 | 2226 | )); |
| 2428 | - } else { | |
| 2429 | - hit!(INTERINTRA_HITS); | |
| 2430 | 2227 | } |
| 2431 | 2228 | interintra_mode = Some(ii); |
| 2432 | 2229 | // The inter-intra predictor reads this block's neighbours as already |
| @@ -2434,13 +2231,6 @@ pub(super) fn decode_inter_block( | ||
| 2434 | 2231 | super::wave::finish_tile(fctx, refpix, [&mut *y, &mut *u, &mut *v]); |
| 2435 | 2232 | } |
| 2436 | 2233 | } |
| 2437 | - if crate::envflags::env_flag!("EC_AV1_TELL") { | |
| 2438 | - eprintln!( | |
| 2439 | - "TELL mi_row={mi_row} mi_col={mi_col} label=post_interintra tell={} range={}", | |
| 2440 | - dec.debug_bitpos(), | |
| 2441 | - dec.debug_state().0 | |
| 2442 | - ); | |
| 2443 | - } | |
| 2444 | 2234 | // lane-motionmode round 1: `read_motion_mode` (spec 5.11.24; |
| 2445 | 2235 | // libaom `decodemv.c` read_inter_block_mode_info, ~1520-1528), |
| 2446 | 2236 | // placed right after MV assignment and before the switchable |
| @@ -2483,20 +2273,6 @@ pub(super) fn decode_inter_block( | ||
| 2483 | 2273 | // as aomdec's `EC_ISTEP2 name=motion_mode` -- an eligibility |
| 2484 | 2274 | // mismatch is otherwise invisible (a skipped symbol prints |
| 2485 | 2275 | // nothing). |
| 2486 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 2487 | - eprintln!( | |
| 2488 | - "EC_MM mi_row={mi_row} mi_col={mi_col} w={write_w} h={write_h} elig={} \ | |
| 2489 | - ab={} lf={} sw={} skipmode={} ii={} gmb={} rng={}", | |
| 2490 | - motion_mode_eligible as u8, | |
| 2491 | - overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).len(), | |
| 2492 | - overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1).len(), | |
| 2493 | - switchable_motion_mode as u8, | |
| 2494 | - skip_mode as u8, | |
| 2495 | - interintra_mode.is_some() as u8, | |
| 2496 | - is_global_mv_block as u8, | |
| 2497 | - dec.debug_state().0, | |
| 2498 | - ); | |
| 2499 | - } | |
| 2500 | 2276 | let mut obmc_selected = false; |
| 2501 | 2277 | // lane-warp round 2: `Some` when motion_mode == WARPED_CAUSAL |
| 2502 | 2278 | // *and* the local warp estimate is valid (`!wm_params.invalid`, |
| @@ -2564,24 +2340,15 @@ pub(super) fn decode_inter_block( | ||
| 2564 | 2340 | ) >= 1; |
| 2565 | 2341 | let warp_eligible = |
| 2566 | 2342 | allow_warped_motion && !ref_is_scaled && !force_integer_mv && proj_ok; |
| 2567 | - if allow_warped_motion && proj_ok && ref_is_scaled { | |
| 2568 | - hit!(SCALED_WARP_SUPPRESSED_HITS); | |
| 2569 | - } | |
| 2570 | - if allow_warped_motion && proj_ok && !ref_is_scaled && force_integer_mv { | |
| 2571 | - hit!(FIMV_ALPHABET_HITS); | |
| 2572 | - } | |
| 2573 | 2343 | if warp_eligible { |
| 2574 | - crate::msac::SymbolDecoder::set_symr_cdf("motion_mode"); | |
| 2575 | 2344 | let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); |
| 2576 | 2345 | match mode { |
| 2577 | 2346 | 0 => {} |
| 2578 | 2347 | 1 => { |
| 2579 | 2348 | obmc_selected = true; |
| 2580 | - hit!(OBMC_HITS); | |
| 2581 | 2349 | } |
| 2582 | 2350 | _ => { |
| 2583 | 2351 | warped_selected = true; |
| 2584 | - hit!(WARP_SELECTED_HITS); | |
| 2585 | 2352 | let mut samples = find_samples( |
| 2586 | 2353 | grid, |
| 2587 | 2354 | mi_row, |
| @@ -2593,18 +2360,6 @@ pub(super) fn decode_inter_block( | ||
| 2593 | 2360 | ref_frame, |
| 2594 | 2361 | fctx, |
| 2595 | 2362 | ); |
| 2596 | - if crate::envflags::env_flag!("EC_WARP_DEBUG") { | |
| 2597 | - eprintln!( | |
| 2598 | - "EC_WARP_DEBUG findSamples mi_row={mi_row} mi_col={mi_col} bsize={side} num_proj_ref={}", | |
| 2599 | - samples.len() | |
| 2600 | - ); | |
| 2601 | - for (i, s) in samples.iter().enumerate() { | |
| 2602 | - eprintln!( | |
| 2603 | - "EC_WARP_DEBUG sample[{i}] pts={:?} pts_inref={:?}", | |
| 2604 | - s.pts1, s.pts2 | |
| 2605 | - ); | |
| 2606 | - } | |
| 2607 | - } | |
| 2608 | 2363 | if samples.len() > 1 { |
| 2609 | 2364 | crate::warp::select_samples( |
| 2610 | 2365 | mv, |
| @@ -2625,45 +2380,15 @@ pub(super) fn decode_inter_block( | ||
| 2625 | 2380 | mi_row as i32, |
| 2626 | 2381 | mi_col as i32, |
| 2627 | 2382 | ); |
| 2628 | - if crate::envflags::env_flag!("EC_WARP_DEBUG") { | |
| 2629 | - eprintln!( | |
| 2630 | - "EC_WARP_DEBUG projection mi_row={mi_row} mi_col={mi_col} num_proj_ref(final)={} mv=({},{}) params={:?}", | |
| 2631 | - samples.len(), | |
| 2632 | - mv.0, | |
| 2633 | - mv.1, | |
| 2634 | - warp_params | |
| 2635 | - ); | |
| 2636 | - for (i, s) in samples.iter().enumerate() { | |
| 2637 | - eprintln!( | |
| 2638 | - "EC_WARP_DEBUG sample_used[{i}] pts={:?} pts_inref={:?}", | |
| 2639 | - s.pts1, s.pts2 | |
| 2640 | - ); | |
| 2641 | - } | |
| 2642 | - } | |
| 2643 | 2383 | } |
| 2644 | 2384 | } |
| 2645 | 2385 | } else { |
| 2646 | 2386 | obmc_selected = dec.symbol(&mut cdfs.obmc[bsize_idx]) == 1; |
| 2647 | - if obmc_selected { | |
| 2648 | - hit!(OBMC_HITS); | |
| 2649 | - } | |
| 2650 | 2387 | } |
| 2651 | 2388 | // lane-t900 r9: which ALPHABET this block read (3-symbol |
| 2652 | 2389 | // motion_mode vs 2-symbol obmc) and the range after -- the |
| 2653 | 2390 | // two give the same value with a different narrowing (class |
| 2654 | 2391 | // wrong-alphabet-same-value). |
| 2655 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 2656 | - eprintln!( | |
| 2657 | - "EC_MM2 mi_row={mi_row} mi_col={mi_col} row={bsize_idx} warp_elig={} \ | |
| 2658 | - scaled={} fimv={} obmc={} warped={} rng={}", | |
| 2659 | - warp_eligible as u8, | |
| 2660 | - ref_is_scaled as u8, | |
| 2661 | - force_integer_mv as u8, | |
| 2662 | - obmc_selected as u8, | |
| 2663 | - warped_selected as u8, | |
| 2664 | - dec.debug_state().0, | |
| 2665 | - ); | |
| 2666 | - } | |
| 2667 | 2392 | } |
| 2668 | 2393 | // lane-gm r4: `allow_warp`'s `global_warp_allowed` branch |
| 2669 | 2394 | // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` -- |
| @@ -2684,15 +2409,9 @@ pub(super) fn decode_inter_block( | ||
| 2684 | 2409 | let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize]; |
| 2685 | 2410 | if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { |
| 2686 | 2411 | warp_params = crate::warp::global_warp_params(gm_ref.params); |
| 2687 | - if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine { | |
| 2688 | - hit!(AFFINE_GM_HITS); | |
| 2689 | - } | |
| 2690 | 2412 | // lane-av1gwarp12: the ROTZOOM sibling -- the only |
| 2691 | 2413 | // >TRANSLATION model vanilla aomenc can emit for a single-ref |
| 2692 | 2414 | // global-motion block (encoder search pinned to ROTZOOM). |
| 2693 | - if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Rotzoom { | |
| 2694 | - hit!(ROTZOOM_GM_WARP_HITS); | |
| 2695 | - } | |
| 2696 | 2415 | } |
| 2697 | 2416 | // lane-av112bitw: a local `WARPED_CAUSAL` projection (set above) |
| 2698 | 2417 | // or a global warp model both land here with `warp_params` set -- |
| @@ -2701,14 +2420,6 @@ pub(super) fn decode_inter_block( | ||
| 2701 | 2420 | // (`warp::warp_round_0`, 5 at 12 bits) and the six-frame 12-bit |
| 2702 | 2421 | // warp stream decodes byte-exact vs ffmpeg |
| 2703 | 2422 | // (`a_12bit_warped_motion_stream_decodes_pixel_exact`). |
| 2704 | - if crate::envflags::env_flag!("EC_AV1_TELL") { | |
| 2705 | - eprintln!( | |
| 2706 | - "TELL mi_row={mi_row} mi_col={mi_col} label=post_motion_mode eligible={} tell={} range={}", | |
| 2707 | - motion_mode_eligible as u8, | |
| 2708 | - dec.debug_bitpos(), | |
| 2709 | - dec.debug_state().0 | |
| 2710 | - ); | |
| 2711 | - } | |
| 2712 | 2423 | // spec `get_ref_filter_type`: a neighbour's own filter only feeds |
| 2713 | 2424 | // this block's switchable_interp context when that neighbour coded |
| 2714 | 2425 | // the SAME reference frame this block is about to read -- a |
| @@ -2746,26 +2457,6 @@ pub(super) fn decode_inter_block( | ||
| 2746 | 2457 | ); |
| 2747 | 2458 | block_filter = resolved_filter; |
| 2748 | 2459 | globalmv_for_lf = is_globalmv; |
| 2749 | - if crate::envflags::env_flag!("EC_AV1_TELL") { | |
| 2750 | - eprintln!( | |
| 2751 | - "TELL mi_row={mi_row} mi_col={mi_col} label=post_interp_filter tell={} range={}", | |
| 2752 | - dec.debug_bitpos(), | |
| 2753 | - dec.debug_state().0 | |
| 2754 | - ); | |
| 2755 | - } | |
| 2756 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 2757 | - eprintln!( | |
| 2758 | - "EC_TRACE mi_row={mi_row} mi_col={mi_col} skip={} is_inter=1 mv=({},{}) is_new_mv={is_new_mv} bsize={side} ref={ref_frame} filter={:?} motion_mode_eligible={} obmc_selected={} warped={} tell={}", | |
| 2759 | - skip as u8, | |
| 2760 | - mv.0, | |
| 2761 | - mv.1, | |
| 2762 | - block_filter, | |
| 2763 | - motion_mode_eligible as u8, | |
| 2764 | - obmc_selected as u8, | |
| 2765 | - warp_params.is_some() as u8, | |
| 2766 | - dec.debug_bitpos() | |
| 2767 | - ); | |
| 2768 | - } | |
| 2769 | 2460 | // lane-rect r2: see the compound path's matching comment above -- |
| 2770 | 2461 | // `grid` must be stamped with the block's true bh4/bw4 span, not |
| 2771 | 2462 | // a square `bw4`x`bw4` guess. |
| @@ -2818,15 +2509,6 @@ pub(super) fn decode_inter_block( | ||
| 2818 | 2509 | // measured was the 16x4/4x16 strip's sub-8x8 chroma piece, |
| 2819 | 2510 | // which this file used to SKIP under a scaled reference |
| 2820 | 2511 | // (fixed in the same commit), not the warp fallback. |
| 2821 | - if warp_params.is_some() { | |
| 2822 | - hit!(SCALED_WARP_FALLBACK_HITS); | |
| 2823 | - } | |
| 2824 | - if obmc_selected { | |
| 2825 | - hit!(SCALED_OBMC_HITS); | |
| 2826 | - } | |
| 2827 | - if interintra_mode.is_some() { | |
| 2828 | - hit!(SCALED_INTERINTRA_HITS); | |
| 2829 | - } | |
| 2830 | 2512 | } |
| 2831 | 2513 | |
| 2832 | 2514 | // lane-inter16ab r2: `is_sub8x8_inter`'s neighbour walk reads the |
| @@ -2843,7 +2525,6 @@ pub(super) fn decode_inter_block( | ||
| 2843 | 2525 | { |
| 2844 | 2526 | Some((horz, (prev_ref, prev_mv, prev_h, prev_v))) => { |
| 2845 | 2527 | let prev_dims = ref_dims(prev_ref, refpix)?; |
| 2846 | - hit!(INTER16_SUB8_PIECE_HITS); | |
| 2847 | 2528 | Some(( |
| 2848 | 2529 | horz, |
| 2849 | 2530 | prev_ref, |
| @@ -3083,9 +2764,6 @@ pub(super) fn decode_inter_block( | ||
| 3083 | 2764 | // result, all planes (reconinter.c av1_build_interintra_predictor |
| 3084 | 2765 | // plane loop). |
| 3085 | 2766 | if let Some(ii) = interintra_mode { |
| 3086 | - if write_w != write_h { | |
| 3087 | - hit!(INTERINTRA_RECT_HITS); | |
| 3088 | - } | |
| 3089 | 2767 | interintra_blend( |
| 3090 | 2768 | y, |
| 3091 | 2769 | px, |
| @@ -3186,7 +2864,23 @@ pub(super) fn decode_inter_block( | ||
| 3186 | 2864 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); |
| 3187 | 2865 | let (sy, su, sv) = if pred_deferred(refpix) { |
| 3188 | 2866 | push_pred(build); |
| 3189 | - (Pred::Cur { plane: 0, stride: side, off: 0 }, Pred::Cur { plane: 1, stride: chroma_stride, off: 0 }, Pred::Cur { plane: 2, stride: chroma_stride, off: 0 }) | |
| 2867 | + ( | |
| 2868 | + Pred::Cur { | |
| 2869 | + plane: 0, | |
| 2870 | + stride: side, | |
| 2871 | + off: 0, | |
| 2872 | + }, | |
| 2873 | + Pred::Cur { | |
| 2874 | + plane: 1, | |
| 2875 | + stride: chroma_stride, | |
| 2876 | + off: 0, | |
| 2877 | + }, | |
| 2878 | + Pred::Cur { | |
| 2879 | + plane: 2, | |
| 2880 | + stride: chroma_stride, | |
| 2881 | + off: 0, | |
| 2882 | + }, | |
| 2883 | + ) | |
| 3190 | 2884 | } else { |
| 3191 | 2885 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 3192 | 2886 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -3351,10 +3045,7 @@ pub(super) fn decode_inter_block( | ||
| 3351 | 3045 | // extent is the strip's own. Counted so a 4:4:4 1:4-strip |
| 3352 | 3046 | // gate can prove it exercised this route (a 4:2:0 stream |
| 3353 | 3047 | // of the same content reads 0). |
| 3354 | - Some(_) if ss_x(fctx) == 0 => { | |
| 3355 | - hit!(RECT4_INTER_OWN_CHROMA444_HITS); | |
| 3356 | - around | |
| 3357 | - } | |
| 3048 | + Some(_) if ss_x(fctx) == 0 => around, | |
| 3358 | 3049 | Some(s) if s.has_chroma => { |
| 3359 | 3050 | let (pw, ph) = if s.horz { |
| 3360 | 3051 | if ss_y(fctx) == 0 { (16, 4) } else { (16, 8) } |
| @@ -3433,14 +3124,6 @@ pub(super) fn decode_inter_block( | ||
| 3433 | 3124 | fctx, |
| 3434 | 3125 | )? |
| 3435 | 3126 | } else { |
| 3436 | - // lane-r14 r3: a 1:4 strip's `sub_tx_size_map` | |
| 3437 | - // sub-transform is RECTANGULAR (TX_64X16 -> | |
| 3438 | - // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is | |
| 3439 | - // read with the rect coefficient machinery, at its | |
| 3440 | - // own `txb_skip_ctx`/neighbour spans -- the unit is | |
| 3441 | - // smaller than its block, so `get_txb_ctx_general`'s | |
| 3442 | - // neighbour table applies, not the lone-TU 0. | |
| 3443 | - vartx_rect_leaf_hit(tw, th); | |
| 3444 | 3127 | let tu_skip_ctx = |
| 3445 | 3128 | neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); |
| 3446 | 3129 | let start = row * MI * side + col * MI; |
| @@ -3674,7 +3357,6 @@ pub(super) fn decode_inter_block( | ||
| 3674 | 3357 | plane_idx, |
| 3675 | 3358 | &cu_grid, |
| 3676 | 3359 | ); |
| 3677 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 3678 | 3360 | mu_chroma = true; |
| 3679 | 3361 | // lane-av1muchunk422b: the allocation of this |
| 3680 | 3362 | // mu-chunk walk, counted per TX_32X32 UNIT. |
| @@ -3683,9 +3365,6 @@ pub(super) fn decode_inter_block( | ||
| 3683 | 3365 | // bump: `MU_CHUNK_COMPOUND_UNITS` names site 2 |
| 3684 | 3366 | // and the single-reference twin (site 5) stays |
| 3685 | 3367 | // out of it. |
| 3686 | - if is_compound { | |
| 3687 | - hit!(MU_CHUNK_COMPOUND_UNITS); | |
| 3688 | - } | |
| 3689 | 3368 | let dst = mu_units( |
| 3690 | 3369 | if plane_idx == 1 { |
| 3691 | 3370 | &mut u_units |
| @@ -3906,16 +3585,10 @@ pub(super) fn decode_inter_block( | ||
| 3906 | 3585 | let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi) |
| 3907 | 3586 | .unwrap_or(luma_tx_type); |
| 3908 | 3587 | if covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi).is_some() { |
| 3909 | - hit!(CHROMA_QUAD_LEAF_TX_HITS); | |
| 3910 | - hit!(CHROMA_QUAD_LEAF_TX_SINGLEREF_HITS); | |
| 3911 | 3588 | // lane-av1f9singleland: this arm's own |
| 3912 | 3589 | // non-vacuity number -- the shared |
| 3913 | 3590 | // DIFFERS counter below cannot say which |
| 3914 | 3591 | // arm changed an answer. |
| 3915 | - if cu_tx_type != luma_tx_type { | |
| 3916 | - hit!(CHROMA_QUAD_LEAF_TX_DIFF_HITS); | |
| 3917 | - hit!(CHROMA_QUAD_LEAF_TX_SINGLEREF_DIFF_HITS); | |
| 3918 | - } | |
| 3919 | 3592 | } |
| 3920 | 3593 | let cu_grid = read_inter_plane( |
| 3921 | 3594 | dec, |
| @@ -3942,7 +3615,6 @@ pub(super) fn decode_inter_block( | ||
| 3942 | 3615 | // this one's coefficients. |
| 3943 | 3616 | neighbours |
| 3944 | 3617 | .record_mi_chroma(cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid); |
| 3945 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 3946 | 3618 | // lane-av1-444 c8: the unit's levels must ALSO |
| 3947 | 3619 | // land in the block grid -- the block-tail mu |
| 3948 | 3620 | // re-stamp slices the per-unit states back out |
| @@ -4075,15 +3747,6 @@ pub(super) fn decode_inter_block( | ||
| 4075 | 3747 | // equivalent post-content point (added at the matching call site) |
| 4076 | 3748 | // narrows the ladder to this block's own tail instead of the next |
| 4077 | 3749 | // block's partition read. |
| 4078 | - if crate::envflags::env_flag!("EC_AV1_TELL") { | |
| 4079 | - eprintln!( | |
| 4080 | - "TELL mi_row={} mi_col={} label=block_end tell={} range={}", | |
| 4081 | - rmi, | |
| 4082 | - cmi, | |
| 4083 | - dec.debug_bitpos(), | |
| 4084 | - dec.debug_state().0 | |
| 4085 | - ); | |
| 4086 | - } | |
| 4087 | 3750 | // lane-inter16ab r2: the pair's chroma coefficient context spans BOTH |
| 4088 | 3751 | // strips (mirroring the intra `decode_rect4_16` path), and the even |
| 4089 | 3752 | // strip's own record wrote empty chroma state over those cells -- this |
| @@ -4250,7 +3913,6 @@ pub(super) fn decode_inter_block( | ||
| 4250 | 3913 | palette_record.3, |
| 4251 | 3914 | ); |
| 4252 | 3915 | let saved_chroma_ctx = (!has_chroma).then(|| { |
| 4253 | - hit!(NON_CHROMA_REF_CTX_SKIP_HITS); | |
| 4254 | 3916 | let (w_mi, h_mi) = (write_w / MI, write_h / MI); |
| 4255 | 3917 | let left: Vec<[Neighbour; 2]> = (0..h_mi) |
| 4256 | 3918 | .filter_map(|k| neighbours.left.get(at.0 + k).map(|s| [s[1], s[2]])) |
| @@ -4277,7 +3939,6 @@ pub(super) fn decode_inter_block( | ||
| 4277 | 3939 | // where aomdec reads 1, because the skipped 128x128 block at |
| 4278 | 3940 | // mi(32,32) never cleared `left[32..48]`. |
| 4279 | 3941 | if skip { |
| 4280 | - hit!(SKIP_VARTX_LUMA_RESET_HITS); | |
| 4281 | 3942 | neighbours.record_mi_luma_rect(at, write_w, write_h, &luma_grid); |
| 4282 | 3943 | } |
| 4283 | 3944 | // Plane 0 is already correct per transform unit |
| @@ -4374,7 +4035,6 @@ pub(super) fn decode_inter_block( | ||
| 4374 | 4035 | } |
| 4375 | 4036 | } |
| 4376 | 4037 | neighbours.record_uv_mode_mi(s.pair_mi.0, s.pair_mi.1, pw / MI, ph / MI, uv_predict_mode); |
| 4377 | - hit!(INTER16_CHROMA_PAIR_HITS); | |
| 4378 | 4038 | } |
| 4379 | 4039 | // lane-av1-444 c8: each unit stamps its OWN span (32 << ss px at |
| 4380 | 4040 | // TX_32X32, 8 px lossless) -- a 64x64 mu chunk at ss 0/0 holds four |
crates/ec-av1/src/decode/inter_block8.rsmodified+34 -273
| @@ -160,8 +160,6 @@ pub(super) fn decode_inter_block8( | ||
| 160 | 160 | // entry sets the same label from ITS `at`, which is a different block -- |
| 161 | 161 | // publishing from here is what makes the EC_SYMR mi trustworthy on the |
| 162 | 162 | // inter path, which is what round 22 got wrong by assuming it was not. |
| 163 | - crate::msac::SymbolDecoder::set_symr_phase("inter8"); | |
| 164 | - crate::msac::SymbolDecoder::set_symr_mi(leaf_mi.0 as i64, leaf_mi.1 as i64); | |
| 165 | 163 | const LAST_FRAME: i8 = 1; |
| 166 | 164 | // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back |
| 167 | 165 | // so the caller stamps them into `Neighbours` instead of the `[3, 3]` |
| @@ -243,9 +241,6 @@ pub(super) fn decode_inter_block8( | ||
| 243 | 241 | // leaf is always `BLOCK_8X8`, i.e. 2x2 mi. |
| 244 | 242 | inter_segment_id(dec, cdfs, leaf_mi.0, leaf_mi.1, 2, 2, false, true, fctx); |
| 245 | 243 | let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; |
| 246 | - if skip_mode { | |
| 247 | - hit!(SKIP_MODE_HITS); | |
| 248 | - } | |
| 249 | 244 | |
| 250 | 245 | let skip_ctx = usize::from(above_skip) + usize::from(left_skip); |
| 251 | 246 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; |
| @@ -264,14 +259,6 @@ pub(super) fn decode_inter_block8( | ||
| 264 | 259 | // lane-inter8 r1: mirrors the oracle's `EC_MODE` (instrument rung 4, |
| 265 | 260 | // `read_inter_block_mode_info`) so an 8x8 leaf's mode-info range ladder |
| 266 | 261 | // diffs line for line against a real aomdec. |
| 267 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 268 | - eprintln!( | |
| 269 | - "EC_MODE mi_row={} mi_col={} rng={}", | |
| 270 | - leaf_mi.0, | |
| 271 | - leaf_mi.1, | |
| 272 | - dec.debug_state().0 | |
| 273 | - ); | |
| 274 | - } | |
| 275 | 262 | |
| 276 | 263 | let mode_for_tx; |
| 277 | 264 | // lane-uv8 r1: this leaf's chroma prediction mode (`get_uv_mode` of the |
| @@ -382,18 +369,6 @@ pub(super) fn decode_inter_block8( | ||
| 382 | 369 | comp_stack.ref_mv_ctx, |
| 383 | 370 | ) |
| 384 | 371 | }; |
| 385 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 386 | - eprintln!( | |
| 387 | - "EC_LEAFMODE mi_row={} mi_col={} cmode={} stack={} newmv_ctx={} refmv_ctx={} rng={}", | |
| 388 | - leaf_mi.0, | |
| 389 | - leaf_mi.1, | |
| 390 | - compound_mode + 17, | |
| 391 | - comp_stack.entries.len(), | |
| 392 | - comp_stack.new_mv_ctx, | |
| 393 | - comp_stack.ref_mv_ctx, | |
| 394 | - dec.debug_state().0 | |
| 395 | - ); | |
| 396 | - } | |
| 397 | 372 | let (mv0, mv1) = assign_compound_mv( |
| 398 | 373 | dec, |
| 399 | 374 | cdfs, |
| @@ -412,19 +387,6 @@ pub(super) fn decode_inter_block8( | ||
| 412 | 387 | // lane-inter8 r3: byte-format-identical to the oracle's |
| 413 | 388 | // rung-4 `EC_MODE_VAL`, so the leaf's mode+mv VALUE ladder |
| 414 | 389 | // diffs line for line against a real aomdec. |
| 415 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 416 | - eprintln!( | |
| 417 | - "EC_MODE_VAL mi_row={} mi_col={} mode={} ref0={} ref1={} mv0=({},{}) rng={}", | |
| 418 | - leaf_mi.0, | |
| 419 | - leaf_mi.1, | |
| 420 | - compound_mode + 17, | |
| 421 | - ref0, | |
| 422 | - ref1, | |
| 423 | - mv0.0, | |
| 424 | - mv0.1, | |
| 425 | - dec.debug_state().0 | |
| 426 | - ); | |
| 427 | - } | |
| 428 | 390 | |
| 429 | 391 | // spec 5.11.25: same gating [`decode_inter_block`]'s own |
| 430 | 392 | // compound arm uses, keyed off `outer_at`'s [`SUB`]-grid |
| @@ -435,7 +397,6 @@ pub(super) fn decode_inter_block8( | ||
| 435 | 397 | && enable_masked_compound |
| 436 | 398 | && is_any_masked_compound_used_here(SIDE, SIDE) |
| 437 | 399 | { |
| 438 | - crate::msac::SymbolDecoder::set_symr_cdf("comp_group_idx"); | |
| 439 | 400 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) |
| 440 | 401 | } else { |
| 441 | 402 | 0 |
| @@ -454,7 +415,6 @@ pub(super) fn decode_inter_block8( | ||
| 454 | 415 | // leaf's own comment. |
| 455 | 416 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[3]); |
| 456 | 417 | let wedge_sign = dec.literal(1); |
| 457 | - hit!(WEDGE_HITS); | |
| 458 | 418 | wedge_mask = Some( |
| 459 | 419 | crate::wedge::wedge_masks() |
| 460 | 420 | .codebook(SIDE, SIDE) |
| @@ -464,7 +424,6 @@ pub(super) fn decode_inter_block8( | ||
| 464 | 424 | let mask_type = dec.literal(1); |
| 465 | 425 | diffwtd_mask_type = Some(mask_type as u8); |
| 466 | 426 | } |
| 467 | - hit!(MASKED_COMPOUND_HITS); | |
| 468 | 427 | } |
| 469 | 428 | // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): same |
| 470 | 429 | // reference-slot defect as the 16x16 leaf's own mask above |
| @@ -490,15 +449,10 @@ pub(super) fn decode_inter_block8( | ||
| 490 | 449 | ref_order_hints[(ref0 - LAST_FRAME) as usize], |
| 491 | 450 | ref_order_hints[(ref1 - LAST_FRAME) as usize], |
| 492 | 451 | ); |
| 493 | - crate::msac::SymbolDecoder::set_symr_cdf("compound_idx"); | |
| 494 | 452 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); |
| 495 | 453 | if idx == 1 { |
| 496 | 454 | (8, 8, 1u8) |
| 497 | 455 | } else { |
| 498 | - // lane-av1distwtd: the 8x8 leaf's own | |
| 499 | - // distance-weighted arm, same counter as the | |
| 500 | - // 16x16+ site above. | |
| 501 | - hit!(DIST_WTD_COMP_HITS); | |
| 502 | 456 | let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign( |
| 503 | 457 | order_hint_bits, |
| 504 | 458 | order_hint, |
| @@ -511,16 +465,6 @@ pub(super) fn decode_inter_block8( | ||
| 511 | 465 | (8, 8, 1u8) |
| 512 | 466 | }; |
| 513 | 467 | compound_ctx8 = Some((ref0, ref1, comp_group_idx as u8, compound_idx)); |
| 514 | - if crate::envflags::env_flag!("EC_AV1_COMPIDX_DUMP") { | |
| 515 | - eprintln!( | |
| 516 | - "EC_COMPIDX mi_row={mi_row} mi_col={mi_col} bsize=8 mode={compound_mode} mv0=({},{}) mv1=({},{}) ref0={ref0} ref1={ref1} comp_group_idx={comp_group_idx} compound_idx={compound_idx} tell={}", | |
| 517 | - mv0.0, | |
| 518 | - mv0.1, | |
| 519 | - mv1.0, | |
| 520 | - mv1.1, | |
| 521 | - dec.debug_bitpos() | |
| 522 | - ); | |
| 523 | - } | |
| 524 | 468 | |
| 525 | 469 | // lane-interp3 r1: `read_mb_interp_filter` (libaom |
| 526 | 470 | // `decodemv.c` 1575, the tail of |
| @@ -570,17 +514,10 @@ pub(super) fn decode_inter_block8( | ||
| 570 | 514 | true, |
| 571 | 515 | ); |
| 572 | 516 | leaf_filter_syms = resolved_filter; |
| 573 | - if interp_fixed.is_none() && !(gm_nontrans_c || skip_mode) { | |
| 574 | - hit!(COMPOUND8_FILTER_HITS); | |
| 575 | - } | |
| 576 | 517 | |
| 577 | 518 | // lane-defer8: both slots' SIZES at parse, pictures in the closure. |
| 578 | 519 | let scale0 = scale_of(ref_dims(ref0, refpix)?, frame_size); |
| 579 | 520 | let scale1 = scale_of(ref_dims(ref1, refpix)?, frame_size); |
| 580 | - if !scale0.is_unscaled() || !scale1.is_unscaled() { | |
| 581 | - hit!(SCALED_COMPOUND_HITS); | |
| 582 | - hit!(SCALED_BLOCK8_HITS); | |
| 583 | - } | |
| 584 | 521 | |
| 585 | 522 | // lane-interp3 r2 (class twin-functions-drift): both slots |
| 586 | 523 | // used to be stamped `false`, while [`decode_inter_block`]'s |
| @@ -635,10 +572,6 @@ pub(super) fn decode_inter_block8( | ||
| 635 | 572 | leaf_compound_warp(ref0, is_global_mv0_c).filter(|_| leaf_ref_unscaled(ref0)); |
| 636 | 573 | let warp1_c = |
| 637 | 574 | leaf_compound_warp(ref1, is_global_mv1_c).filter(|_| leaf_ref_unscaled(ref1)); |
| 638 | - if warp0_c.is_some() || warp1_c.is_some() { | |
| 639 | - hit!(COMPOUND_WARP_HITS); | |
| 640 | - hit!(COMPOUND_WARP_HITS_8); | |
| 641 | - } | |
| 642 | 575 | grid.fill_rect( |
| 643 | 576 | mi_row, |
| 644 | 577 | mi_col, |
| @@ -745,7 +678,6 @@ pub(super) fn decode_inter_block8( | ||
| 745 | 678 | let mut diffwtd_mask_y; |
| 746 | 679 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { |
| 747 | 680 | diffwtd_mask_y = vec![0u8; SIDE * SIDE]; |
| 748 | - hit!(DIFFWTD_HITS); | |
| 749 | 681 | mc::diffwtd_mask( |
| 750 | 682 | &inter0_y, |
| 751 | 683 | &inter1_y, |
| @@ -1002,7 +934,23 @@ pub(super) fn decode_inter_block8( | ||
| 1002 | 934 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); |
| 1003 | 935 | let (sy, su, sv) = if pred_deferred(refpix) { |
| 1004 | 936 | push_pred(build); |
| 1005 | - (Pred::Cur { plane: 0, stride: SIDE, off: 0 }, Pred::Cur { plane: 1, stride: chroma_w, off: 0 }, Pred::Cur { plane: 2, stride: chroma_w, off: 0 }) | |
| 937 | + ( | |
| 938 | + Pred::Cur { | |
| 939 | + plane: 0, | |
| 940 | + stride: SIDE, | |
| 941 | + off: 0, | |
| 942 | + }, | |
| 943 | + Pred::Cur { | |
| 944 | + plane: 1, | |
| 945 | + stride: chroma_w, | |
| 946 | + off: 0, | |
| 947 | + }, | |
| 948 | + Pred::Cur { | |
| 949 | + plane: 2, | |
| 950 | + stride: chroma_w, | |
| 951 | + off: 0, | |
| 952 | + }, | |
| 953 | + ) | |
| 1006 | 954 | } else { |
| 1007 | 955 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 1008 | 956 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -1323,13 +1271,6 @@ pub(super) fn decode_inter_block8( | ||
| 1323 | 1271 | neighbours.above[leaf_mi.1 + cell][0] = state; |
| 1324 | 1272 | } |
| 1325 | 1273 | } |
| 1326 | - // lane-cdef r1: ... and the CDEF skip band too. `apply_cdef`'s | |
| 1327 | - // `is_8x8_block_skip` (libaom `cdef.c:29-38`) reads all four mi | |
| 1328 | - // cells of the 8x8; this leaf wrote none of them, so a 64x64 | |
| 1329 | - // whose bottom-right 16x16 is an all-skip 8x8-leaf group kept | |
| 1330 | - // the PREVIOUS frame's flags and got filtered where libaom's | |
| 1331 | - // dlist excludes it (3 luma samples on a 192x128 inter frame). | |
| 1332 | - hit!(INTER8_SKIP_BAND_HITS); | |
| 1333 | 1274 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 1334 | 1275 | // lane-sub8x4 r2: `split8` is this leaf's OWN var-tx split, so |
| 1335 | 1276 | // the deblock grid must publish the TX_4X4 leaves' width the |
| @@ -1408,19 +1349,8 @@ pub(super) fn decode_inter_block8( | ||
| 1408 | 1349 | // lane-interp3 r2: same per-entry EC_STACK ladder |
| 1409 | 1350 | // [`decode_inter_block`]'s single-ref arm prints, so this leaf's stack |
| 1410 | 1351 | // diffs line for line against the oracle's. |
| 1411 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 1412 | - for (i, e) in stack.entries.iter().enumerate() { | |
| 1413 | - eprintln!( | |
| 1414 | - "EC_STACK mi_row={mi_row} mi_col={mi_col} ref={ref_frame} i={i} this=({},{}) comp=(0,0) w={}", | |
| 1415 | - e.mv.0, e.mv.1, e.weight | |
| 1416 | - ); | |
| 1417 | - } | |
| 1418 | - } | |
| 1419 | 1352 | |
| 1420 | 1353 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| 1421 | - if !not_new { | |
| 1422 | - crate::census::mode(0); | |
| 1423 | - } | |
| 1424 | 1354 | let mut is_globalmv = false; |
| 1425 | 1355 | let (mv, is_new_mv) = if !not_new { |
| 1426 | 1356 | // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0): |
| @@ -1451,19 +1381,11 @@ pub(super) fn decode_inter_block8( | ||
| 1451 | 1381 | ) |
| 1452 | 1382 | } else { |
| 1453 | 1383 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; |
| 1454 | - if !not_zero { | |
| 1455 | - crate::census::mode(1); | |
| 1456 | - } | |
| 1457 | 1384 | is_globalmv = !not_zero; |
| 1458 | 1385 | let mv = if !not_zero { |
| 1459 | - // lane-gmaffine r1: GLOBALMV (spec 7.10.2.1) -- the same | |
| 1460 | - // `gm_get_motion_vector` value the 16x16+ leaf reads out of | |
| 1461 | - // its own `gm_table`, computed at this block's centre. | |
| 1462 | - hit!(GLOBALMV_HITS_8); | |
| 1463 | 1386 | gm_table[(ref_frame - LAST_FRAME) as usize] |
| 1464 | 1387 | } else { |
| 1465 | 1388 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; |
| 1466 | - crate::census::mode(if nearest { 2 } else { 3 }); | |
| 1467 | 1389 | if nearest { |
| 1468 | 1390 | stack.nearest_mv |
| 1469 | 1391 | } else { |
| @@ -1487,7 +1409,6 @@ pub(super) fn decode_inter_block8( | ||
| 1487 | 1409 | let mut interintra_mode: Option<u8> = None; |
| 1488 | 1410 | let mut wedge_mask: Option<(&'static [u8], usize)> = None; |
| 1489 | 1411 | if enable_interintra_compound && !skip_mode { |
| 1490 | - crate::msac::SymbolDecoder::set_symr_cdf("interintra"); | |
| 1491 | 1412 | let interintra = dec.symbol(&mut cdfs.interintra[SIZE_GROUP_8]) == 1; |
| 1492 | 1413 | if interintra { |
| 1493 | 1414 | // lane-interintra r1: same read pair as the 16/32 site; |
| @@ -1499,15 +1420,12 @@ pub(super) fn decode_inter_block8( | ||
| 1499 | 1420 | // lane-wii r2: same adapting `wedge_index` symbol as the |
| 1500 | 1421 | // 16/32 leaf, fixed sign 0 -- see that site's comment. |
| 1501 | 1422 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[3]); |
| 1502 | - hit!(WII_HITS); | |
| 1503 | 1423 | wedge_mask = Some(( |
| 1504 | 1424 | crate::wedge::wedge_masks() |
| 1505 | 1425 | .codebook(SIDE, SIDE) |
| 1506 | 1426 | .mask(0, wedge_index), |
| 1507 | 1427 | SIDE, |
| 1508 | 1428 | )); |
| 1509 | - } else { | |
| 1510 | - hit!(INTERINTRA_HITS); | |
| 1511 | 1429 | } |
| 1512 | 1430 | interintra_mode = Some(ii); |
| 1513 | 1431 | // The inter-intra predictor reads this block's neighbours as already |
| @@ -1584,38 +1502,14 @@ pub(super) fn decode_inter_block8( | ||
| 1584 | 1502 | let ref_is_scaled = !scale_of((ref_width, ref_height), frame_size).is_unscaled(); |
| 1585 | 1503 | let warp_eligible = |
| 1586 | 1504 | allow_warped_motion && !ref_is_scaled && !force_integer_mv && proj_ok; |
| 1587 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 1588 | - eprintln!( | |
| 1589 | - "EC_MM8 mi_row={mi_row} mi_col={mi_col} proj={} warp_elig={} awm={}", | |
| 1590 | - proj_ok as u8, warp_eligible as u8, allow_warped_motion as u8 | |
| 1591 | - ); | |
| 1592 | - } | |
| 1593 | - if allow_warped_motion && proj_ok && ref_is_scaled { | |
| 1594 | - hit!(SCALED_WARP_SUPPRESSED_HITS); | |
| 1595 | - } | |
| 1596 | - if allow_warped_motion && proj_ok && !ref_is_scaled && force_integer_mv { | |
| 1597 | - hit!(FIMV_ALPHABET_HITS); | |
| 1598 | - } | |
| 1599 | 1505 | if warp_eligible { |
| 1600 | - crate::msac::SymbolDecoder::set_symr_cdf("motion_mode"); | |
| 1601 | 1506 | let mode = dec.symbol(&mut cdfs.motion_mode[0]); |
| 1602 | 1507 | match mode { |
| 1603 | 1508 | 0 => {} |
| 1604 | 1509 | 1 => { |
| 1605 | 1510 | obmc_selected = true; |
| 1606 | - hit!(OBMC_HITS); | |
| 1607 | - hit!(OBMC_HITS_8); | |
| 1608 | 1511 | } |
| 1609 | 1512 | _ => { |
| 1610 | - // lane-gmaffine r1: WARPED_CAUSAL at the 8x8 leaf -- | |
| 1611 | - // the same findSamples -> select_samples -> | |
| 1612 | - // av1_find_projection chain the 16x16+ leaf runs, | |
| 1613 | - // with BLOCK_8X8's own 8x8 model centre; an | |
| 1614 | - // unusable projection falls back to the block's | |
| 1615 | - // translational mv (libaom `av1_find_projection` | |
| 1616 | - // returning 1 leaves `wm_params` invalid and | |
| 1617 | - // `build_inter_predictors` skips the warp). | |
| 1618 | - hit!(WARP_SELECTED_HITS); | |
| 1619 | 1513 | let mut samples = find_samples( |
| 1620 | 1514 | grid, |
| 1621 | 1515 | mi_row, |
| @@ -1640,18 +1534,11 @@ pub(super) fn decode_inter_block8( | ||
| 1640 | 1534 | mi_col as i32, |
| 1641 | 1535 | ); |
| 1642 | 1536 | warped_selected = true; |
| 1643 | - if warp_params.is_some() { | |
| 1644 | - hit!(WARP_HITS_8); | |
| 1645 | - } | |
| 1646 | 1537 | } |
| 1647 | 1538 | } |
| 1648 | 1539 | } else { |
| 1649 | 1540 | // `default_obmc_cdf`'s own index: square bsize 8/16/32/64 -> 0/1/2/3. |
| 1650 | 1541 | obmc_selected = dec.symbol(&mut cdfs.obmc[0]) == 1; |
| 1651 | - if obmc_selected { | |
| 1652 | - hit!(OBMC_HITS); | |
| 1653 | - hit!(OBMC_HITS_8); | |
| 1654 | - } | |
| 1655 | 1542 | } |
| 1656 | 1543 | } |
| 1657 | 1544 | // lane-gmaffine r1: `read_mb_interp_filter` (spec 5.11.26) at the 8x8 |
| @@ -1695,17 +1582,6 @@ pub(super) fn decode_inter_block8( | ||
| 1695 | 1582 | false, |
| 1696 | 1583 | ); |
| 1697 | 1584 | leaf_filter_syms = resolved_filter; |
| 1698 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 1699 | - eprintln!( | |
| 1700 | - "EC_MODE_VAL8 mi_row={} mi_col={} newmv={is_new_mv} globalmv={is_globalmv} ref0={ref_frame} mv0=({},{}) stack={} rng={}", | |
| 1701 | - leaf_mi.0, | |
| 1702 | - leaf_mi.1, | |
| 1703 | - mv.0, | |
| 1704 | - mv.1, | |
| 1705 | - stack.entries.len(), | |
| 1706 | - dec.debug_state().0 | |
| 1707 | - ); | |
| 1708 | - } | |
| 1709 | 1585 | // lane-gmaffine r1: `allow_warp`'s `global_warp_allowed` branch |
| 1710 | 1586 | // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` -- |
| 1711 | 1587 | // see [`decode_inter_block`]'s own copy. A local WARPED_CAUSAL model |
| @@ -1713,23 +1589,12 @@ pub(super) fn decode_inter_block8( | ||
| 1713 | 1589 | // size predicate baked into `is_global_mv_block`. |
| 1714 | 1590 | if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { |
| 1715 | 1591 | warp_params = crate::warp::global_warp_params(gm_ref.params); |
| 1716 | - if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine { | |
| 1717 | - hit!(AFFINE_GM_HITS); | |
| 1718 | - } | |
| 1719 | 1592 | } |
| 1720 | 1593 | // lane-av112bitw: same lift as the 16x16+ leaf -- a local |
| 1721 | 1594 | // `WARPED_CAUSAL` projection or a global model both leave |
| 1722 | 1595 | // `warp_params` set here; the 12-bit refusal that stood here is |
| 1723 | 1596 | // lifted with the same witness (`warp::warp_round_0` moved the |
| 1724 | 1597 | // filter's shifts; the same stream decodes byte-exact vs ffmpeg). |
| 1725 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 1726 | - eprintln!( | |
| 1727 | - "EC_WARP8 mi_row={} mi_col={} warp={} globalblk={is_global_mv_block}", | |
| 1728 | - leaf_mi.0, | |
| 1729 | - leaf_mi.1, | |
| 1730 | - warp_params.is_some(), | |
| 1731 | - ); | |
| 1732 | - } | |
| 1733 | 1598 | grid.fill_rect( |
| 1734 | 1599 | mi_row, |
| 1735 | 1600 | mi_col, |
| @@ -1760,9 +1625,6 @@ pub(super) fn decode_inter_block8( | ||
| 1760 | 1625 | // (documented corner-cut above); under a scaled reference the same |
| 1761 | 1626 | // fixed kernel runs through spec 7.11.3.3's scaled walk instead. |
| 1762 | 1627 | let luma_scale = scale_of((ref_width, ref_height), frame_size); |
| 1763 | - if !luma_scale.is_unscaled() { | |
| 1764 | - hit!(SCALED_BLOCK8_HITS); | |
| 1765 | - } | |
| 1766 | 1628 | let obmc = if obmc_selected { |
| 1767 | 1629 | Some(obmc_plan( |
| 1768 | 1630 | grid, |
| @@ -1972,7 +1834,23 @@ pub(super) fn decode_inter_block8( | ||
| 1972 | 1834 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); |
| 1973 | 1835 | let (sy, su, sv) = if pred_deferred(refpix) { |
| 1974 | 1836 | push_pred(build); |
| 1975 | - (Pred::Cur { plane: 0, stride: SIDE, off: 0 }, Pred::Cur { plane: 1, stride: chroma_w, off: 0 }, Pred::Cur { plane: 2, stride: chroma_w, off: 0 }) | |
| 1837 | + ( | |
| 1838 | + Pred::Cur { | |
| 1839 | + plane: 0, | |
| 1840 | + stride: SIDE, | |
| 1841 | + off: 0, | |
| 1842 | + }, | |
| 1843 | + Pred::Cur { | |
| 1844 | + plane: 1, | |
| 1845 | + stride: chroma_w, | |
| 1846 | + off: 0, | |
| 1847 | + }, | |
| 1848 | + Pred::Cur { | |
| 1849 | + plane: 2, | |
| 1850 | + stride: chroma_w, | |
| 1851 | + off: 0, | |
| 1852 | + }, | |
| 1853 | + ) | |
| 1976 | 1854 | } else { |
| 1977 | 1855 | // The interintra predictor reads this block's own above/left |
| 1978 | 1856 | // edges, which are already written at this point. |
| @@ -2194,7 +2072,6 @@ pub(super) fn decode_inter_block8( | ||
| 2194 | 2072 | } |
| 2195 | 2073 | } |
| 2196 | 2074 | } else { |
| 2197 | - crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | |
| 2198 | 2075 | let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]); |
| 2199 | 2076 | if mode >= 13 { |
| 2200 | 2077 | return Err(unsupported( |
| @@ -2214,19 +2091,6 @@ pub(super) fn decode_inter_block8( | ||
| 2214 | 2091 | } else { |
| 2215 | 2092 | 0 |
| 2216 | 2093 | }; |
| 2217 | - if angle_delta_y != 0 { | |
| 2218 | - hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS); | |
| 2219 | - // lane-leaf8tx r1: `av1_use_angle_delta(BLOCK_8X8)` is true | |
| 2220 | - // (`bsize >= BLOCK_8X8`), so this leaf codes `angle_delta_y` off | |
| 2221 | - // `angle_delta_cdf[mode - V_PRED]` exactly as a key-frame block | |
| 2222 | - // does (libaom `read_intra_angle_info` inside | |
| 2223 | - // `read_intra_block_mode_info`, decodemv.c), and the delta feeds | |
| 2224 | - // the directional predictor + the edge filter/upsample decision | |
| 2225 | - // through the same `reconstruct` argument below. Counted | |
| 2226 | - // separately from the >=16x16 arm so the gate cannot be satisfied | |
| 2227 | - // by a bigger block. | |
| 2228 | - hit!(INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS); | |
| 2229 | - } | |
| 2230 | 2094 | // lane-uv8 r1: the delta'd angle decides the intra edge filter, and a |
| 2231 | 2095 | // directional luma mode is already legal on this leaf -- the arm |
| 2232 | 2096 | // passed a hardcoded `false` where [`decode_leaf8`] reads the |
| @@ -2256,42 +2120,20 @@ pub(super) fn decode_inter_block8( | ||
| 2256 | 2120 | let uv_mode = if !has_chroma { |
| 2257 | 2121 | DC_PRED |
| 2258 | 2122 | } else if cfl_allowed_px(SIDE, SIDE, fctx) { |
| 2259 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 2260 | 2123 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 2261 | 2124 | } else { |
| 2262 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 2263 | 2125 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 2264 | 2126 | }; |
| 2265 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 2266 | - eprintln!( | |
| 2267 | - "EC_ISTEP8 mi_row={} mi_col={} name=modes y={mode} uv={uv_mode} fi_enabled={} rng={}", | |
| 2268 | - leaf_mi.0, | |
| 2269 | - leaf_mi.1, | |
| 2270 | - fctx.enable_filter_intra_inter.with(std::cell::Cell::get), | |
| 2271 | - dec.debug_state().0 | |
| 2272 | - ); | |
| 2273 | - } | |
| 2274 | - if (9..=12).contains(&uv_mode) { | |
| 2275 | - hit!(SMOOTH_UV_HITS); | |
| 2276 | - hit!(INTRA_IN_INTER8_UV_SMOOTH_HITS); | |
| 2277 | - } | |
| 2278 | 2127 | let alpha = if has_chroma && uv_mode == UV_CFL_PRED { |
| 2279 | - hit!(INTRA_IN_INTER8_UV_CFL_HITS); | |
| 2280 | 2128 | Some(read_cfl_alphas(dec, cdfs)) |
| 2281 | 2129 | } else { |
| 2282 | 2130 | None |
| 2283 | 2131 | }; |
| 2284 | 2132 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 2285 | - hit!(DIRECTIONAL_UV_HITS); | |
| 2286 | - hit!(INTRA_IN_INTER8_UV_DIR_HITS); | |
| 2287 | 2133 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 2288 | 2134 | } else { |
| 2289 | 2135 | 0 |
| 2290 | 2136 | }; |
| 2291 | - if angle_delta_uv != 0 { | |
| 2292 | - hit!(UV_ANGLE_DELTA_HITS); | |
| 2293 | - hit!(INTRA_IN_INTER_ANGLE_DELTA_UV_HITS); | |
| 2294 | - } | |
| 2295 | 2137 | // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED`. |
| 2296 | 2138 | uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 2297 | 2139 | DC_PRED |
| @@ -2333,16 +2175,6 @@ pub(super) fn decode_inter_block8( | ||
| 2333 | 2175 | let use_palette_uv = has_chroma |
| 2334 | 2176 | && uv_mode == DC_PRED |
| 2335 | 2177 | && dec.symbol(&mut cdfs.palette_uv_mode[usize::from(use_palette_y)]) != 0; |
| 2336 | - if crate::envflags::env_flag!("EC_PALSYN") { | |
| 2337 | - eprintln!( | |
| 2338 | - "EC_PALSYN leaf8 mi={},{} bw=8 bh=8 mode={mode} uv={uv_mode} ctx={palette_ctx} y={} uv={} rng={}", | |
| 2339 | - leaf_mi.0, | |
| 2340 | - leaf_mi.1, | |
| 2341 | - palette_y_pending.map_or(0, |(n, _)| n), | |
| 2342 | - u8::from(use_palette_uv), | |
| 2343 | - dec.debug_state().0 | |
| 2344 | - ); | |
| 2345 | - } | |
| 2346 | 2178 | if use_palette_uv { |
| 2347 | 2179 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); |
| 2348 | 2180 | let (u_colors, v_colors) = read_palette_colors_uv(dec, n, &palette_uv_cache, fctx); |
| @@ -2362,7 +2194,6 @@ pub(super) fn decode_inter_block8( | ||
| 2362 | 2194 | // prints `use_filter_intra` for an intra block inside an INTER frame |
| 2363 | 2195 | // and nothing else, so this leaf needs the same two lines for a |
| 2364 | 2196 | // range-ladder diff against it. |
| 2365 | - let ec_istep8 = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); | |
| 2366 | 2197 | if mode == DC_PRED |
| 2367 | 2198 | && fctx.enable_filter_intra_inter.with(std::cell::Cell::get) |
| 2368 | 2199 | // `av1_filter_intra_allowed` (reconintra.h:77) excludes a |
| @@ -2371,27 +2202,8 @@ pub(super) fn decode_inter_block8( | ||
| 2371 | 2202 | && let Some(class) = filter_intra_size_class(SIDE) |
| 2372 | 2203 | { |
| 2373 | 2204 | let use_fi = dec.symbol(&mut cdfs.filter_intra[class]) != 0; |
| 2374 | - if ec_istep8 { | |
| 2375 | - eprintln!( | |
| 2376 | - "EC_ISTEP mi_row={} mi_col={} name=use_filter_intra val={} rng={}", | |
| 2377 | - leaf_mi.0, | |
| 2378 | - leaf_mi.1, | |
| 2379 | - u8::from(use_fi), | |
| 2380 | - dec.debug_state().0 | |
| 2381 | - ); | |
| 2382 | - } | |
| 2383 | 2205 | if use_fi { |
| 2384 | - hit!(FILTER_INTRA_HITS); | |
| 2385 | - hit!(INTRA_IN_INTER_FILTER_INTRA_HITS); | |
| 2386 | 2206 | let fi = dec.symbol(&mut cdfs.filter_intra_mode); |
| 2387 | - if ec_istep8 { | |
| 2388 | - eprintln!( | |
| 2389 | - "EC_ISTEP mi_row={} mi_col={} name=filter_intra_mode val={fi} rng={}", | |
| 2390 | - leaf_mi.0, | |
| 2391 | - leaf_mi.1, | |
| 2392 | - dec.debug_state().0 | |
| 2393 | - ); | |
| 2394 | - } | |
| 2395 | 2207 | filter_intra = Some(fi); |
| 2396 | 2208 | } |
| 2397 | 2209 | } |
| @@ -2407,15 +2219,6 @@ pub(super) fn decode_inter_block8( | ||
| 2407 | 2219 | palette_onscreen(rmi, cmi, SIDE, SIDE, fctx), |
| 2408 | 2220 | false, |
| 2409 | 2221 | ); |
| 2410 | - hit!(PALETTE_HITS); | |
| 2411 | - hit!(INTRA_IN_INTER_PALETTE_Y_HITS); | |
| 2412 | - hit_do! { | |
| 2413 | - INTER8_PALETTE_HITS.with(|c| { | |
| 2414 | - let mut v = c.get(); | |
| 2415 | - v.0 += 1; | |
| 2416 | - c.set(v); | |
| 2417 | - }); | |
| 2418 | - } | |
| 2419 | 2222 | PaletteY { |
| 2420 | 2223 | size: n, |
| 2421 | 2224 | colors, |
| @@ -2433,15 +2236,6 @@ pub(super) fn decode_inter_block8( | ||
| 2433 | 2236 | (ss_x(fctx), ss_y(fctx)), |
| 2434 | 2237 | ); |
| 2435 | 2238 | let map = decode_color_index_map_wh(dec, cdfs, n, chroma_w, chroma_h, on, true); |
| 2436 | - hit!(PALETTE_UV_HITS); | |
| 2437 | - hit!(INTRA_IN_INTER_PALETTE_UV_HITS); | |
| 2438 | - hit_do! { | |
| 2439 | - INTER8_PALETTE_HITS.with(|c| { | |
| 2440 | - let mut v = c.get(); | |
| 2441 | - v.1 += 1; | |
| 2442 | - c.set(v); | |
| 2443 | - }); | |
| 2444 | - } | |
| 2445 | 2239 | PaletteUv { |
| 2446 | 2240 | size: n, |
| 2447 | 2241 | u_colors, |
| @@ -2528,7 +2322,6 @@ pub(super) fn decode_inter_block8( | ||
| 2528 | 2322 | // (the whole-block buffer would be indexed at the wrong |
| 2529 | 2323 | // stride by the first unit). |
| 2530 | 2324 | if let Some(buf) = &palette_y_buf { |
| 2531 | - hit!(PALETTE_SPLIT_TX_HITS); | |
| 2532 | 2325 | let window: Vec<u16> = (0..tx_px) |
| 2533 | 2326 | .flat_map(|i| { |
| 2534 | 2327 | let base = (row * MI + i) * SIDE + col * MI; |
| @@ -2564,10 +2357,6 @@ pub(super) fn decode_inter_block8( | ||
| 2564 | 2357 | read_plane( |
| 2565 | 2358 | dec, |
| 2566 | 2359 | cdfs, |
| 2567 | - // Intra 4x4 luma: seven-type | |
| 2568 | - // `EXT_TX_SET_DTT4_IDTX_1DDCT` unless reduced, whose | |
| 2569 | - // CDF row is the intra dir (`fi_tx_row` inside | |
| 2570 | - // `read_plane` maps a filter-intra block's). | |
| 2571 | 2360 | txbset_for(tx_px, reduced_tx_set), |
| 2572 | 2361 | default_scan(tx_px), |
| 2573 | 2362 | 0, |
| @@ -2583,7 +2372,6 @@ pub(super) fn decode_inter_block8( | ||
| 2583 | 2372 | tu_py, |
| 2584 | 2373 | tx_px, |
| 2585 | 2374 | tx_px, |
| 2586 | - base_q_idx, | |
| 2587 | 2375 | None, |
| 2588 | 2376 | filter_intra, |
| 2589 | 2377 | Some(tu_skip_ctx), |
| @@ -2682,14 +2470,6 @@ pub(super) fn decode_inter_block8( | ||
| 2682 | 2470 | read_plane( |
| 2683 | 2471 | dec, |
| 2684 | 2472 | cdfs, |
| 2685 | - // lane-uv8 r3: an intra leaf inside an inter frame is | |
| 2686 | - // `is_inter == 0` in `av1_get_ext_tx_set_type`, so its 8x8 | |
| 2687 | - // luma reads the INTRA set -- seven-type | |
| 2688 | - // `EXT_TX_SET_DTT4_IDTX_1DDCT` when `reduced_tx_set == 0`, | |
| 2689 | - // five-type `EXT_TX_SET_DTT4_IDTX` when it is 1. Hardcoding | |
| 2690 | - // the reduced set read the wrong ALPHABET (class | |
| 2691 | - // [[wrong-alphabet-same-value]]) and desynced at the leaf's | |
| 2692 | - // first `tx_type`. | |
| 2693 | 2473 | txbset_for(8, reduced_tx_set), |
| 2694 | 2474 | scan8, |
| 2695 | 2475 | 0, |
| @@ -2705,7 +2485,6 @@ pub(super) fn decode_inter_block8( | ||
| 2705 | 2485 | py, |
| 2706 | 2486 | SIDE, |
| 2707 | 2487 | TX8, |
| 2708 | - base_q_idx, | |
| 2709 | 2488 | None, |
| 2710 | 2489 | filter_intra, |
| 2711 | 2490 | None, |
| @@ -2752,7 +2531,6 @@ pub(super) fn decode_inter_block8( | ||
| 2752 | 2531 | cdfs, |
| 2753 | 2532 | neighbours, |
| 2754 | 2533 | leaf_mi, |
| 2755 | - (px, py), | |
| 2756 | 2534 | (cpx, cpy), |
| 2757 | 2535 | SIDE, |
| 2758 | 2536 | (chroma_w, chroma_h), |
| @@ -2760,13 +2538,11 @@ pub(super) fn decode_inter_block8( | ||
| 2760 | 2538 | (chroma_w, chroma_h), |
| 2761 | 2539 | chroma_w, |
| 2762 | 2540 | reach, |
| 2763 | - (y.width, y.height), | |
| 2764 | 2541 | mode, |
| 2765 | 2542 | uv_predict_mode, |
| 2766 | 2543 | angle_delta_uv, |
| 2767 | 2544 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), |
| 2768 | 2545 | smooth_neighbor_uv, |
| 2769 | - base_q_idx, | |
| 2770 | 2546 | &mut uo, |
| 2771 | 2547 | &mut vo, |
| 2772 | 2548 | fctx, |
| @@ -2782,7 +2558,6 @@ pub(super) fn decode_inter_block8( | ||
| 2782 | 2558 | Grid::Own(vo) |
| 2783 | 2559 | }; |
| 2784 | 2560 | chroma_stamped_per_unit = true; |
| 2785 | - hit!(LLINTRA8_CHROMA_WALK_HITS); | |
| 2786 | 2561 | } else { |
| 2787 | 2562 | if let Some((ub, _)) = &palette_uv_bufs { |
| 2788 | 2563 | set_palette_pred(ub.clone(), fctx); |
| @@ -2830,7 +2605,6 @@ pub(super) fn decode_inter_block8( | ||
| 2830 | 2605 | cpy, |
| 2831 | 2606 | chroma_w, |
| 2832 | 2607 | chroma_tx, |
| 2833 | - base_q_idx, | |
| 2834 | 2608 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 2835 | 2609 | None, |
| 2836 | 2610 | None, |
| @@ -2884,7 +2658,6 @@ pub(super) fn decode_inter_block8( | ||
| 2884 | 2658 | cpy, |
| 2885 | 2659 | chroma_w, |
| 2886 | 2660 | chroma_tx, |
| 2887 | - base_q_idx, | |
| 2888 | 2661 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 2889 | 2662 | None, |
| 2890 | 2663 | None, |
| @@ -2989,18 +2762,6 @@ pub(super) fn decode_inter_block8( | ||
| 2989 | 2762 | neighbours.above[leaf_mi.1 + cell][0] = state; |
| 2990 | 2763 | } |
| 2991 | 2764 | } |
| 2992 | - // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference | |
| 2993 | - // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every | |
| 2994 | - // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test). | |
| 2995 | - // lane-cdef r1: the fall-through twin of the compound arm's skip-band | |
| 2996 | - // write above -- `skip` is one flag for the whole 8x8 leaf (read at | |
| 2997 | - // `decode.rs`'s `skip_ctx` site), `split8` only splits its transform. | |
| 2998 | - // lane-intersub8 r5: ... and it counts too. r1 incremented the counter in | |
| 2999 | - // the COMPOUND early-return arm only, so the gate's assert really read | |
| 3000 | - // "a COMPOUND 8x8 leaf wrote the band"; once main's inter16ab/r14 routing | |
| 3001 | - // landed, the 10-bit cq12 arm's leaves come through here instead and the | |
| 3002 | - // gate failed on an instrumentation gap, with the band written either way. | |
| 3003 | - hit!(INTER8_SKIP_BAND_HITS); | |
| 3004 | 2765 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 3005 | 2766 | neighbours.fill_lf_grid( |
| 3006 | 2767 | leaf_mi, |
crates/ec-av1/src/decode/inter_ctx.rsmodified+4 -380
| @@ -64,34 +64,13 @@ pub(super) fn resolve_interp_filter( | ||
| 64 | 64 | // `h_kind`/`v_kind` argument order, which is why this function returns |
| 65 | 65 | // `(h, v, ..)` but reads `dir0` (`v`) before `dir1` (`h`). |
| 66 | 66 | let ctx0 = switchable_interp_ctx(above[0], left[0], 0, is_compound); |
| 67 | - if crate::envflags::env_flag!("EC_AV1_IFDBG") { | |
| 68 | - eprintln!( | |
| 69 | - "IFDBG dir=0 ctx={ctx0} above={above:?} left={left:?} cdf={:?}", | |
| 70 | - &cdfs.switchable_interp[ctx0][..3] | |
| 71 | - ); | |
| 72 | - } | |
| 73 | 67 | let sym0 = dec.symbol(&mut cdfs.switchable_interp[ctx0]) as u8; |
| 74 | 68 | let sym1 = if enable_dual_filter { |
| 75 | 69 | let ctx1 = switchable_interp_ctx(above[1], left[1], 1, is_compound); |
| 76 | - if crate::envflags::env_flag!("EC_AV1_IFDBG") { | |
| 77 | - eprintln!( | |
| 78 | - "IFDBG dir=1 ctx={ctx1} above={above:?} left={left:?} cdf={:?} sym0={sym0}", | |
| 79 | - &cdfs.switchable_interp[ctx1][..3] | |
| 80 | - ); | |
| 81 | - } | |
| 82 | 70 | dec.symbol(&mut cdfs.switchable_interp[ctx1]) as u8 |
| 83 | 71 | } else { |
| 84 | 72 | sym0 |
| 85 | 73 | }; |
| 86 | - if enable_dual_filter && sym0 != sym1 { | |
| 87 | - hit!(DUAL_FILTER_DIFF_HITS); | |
| 88 | - } | |
| 89 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 90 | - eprintln!( | |
| 91 | - "EC_IF ctx0={ctx0} above={above:?} left={left:?} sym0={sym0} sym1={sym1} rng={}", | |
| 92 | - dec.debug_state().0 | |
| 93 | - ); | |
| 94 | - } | |
| 95 | 74 | ( |
| 96 | 75 | mc::InterpFilterKind::from_switchable_symbol(sym1 as usize), |
| 97 | 76 | mc::InterpFilterKind::from_switchable_symbol(sym0 as usize), |
| @@ -227,7 +206,6 @@ pub(super) fn read_mv( | ||
| 227 | 206 | mv.1.clamp(-MV_LIMIT + 1, MV_LIMIT - 1), |
| 228 | 207 | ); |
| 229 | 208 | } |
| 230 | - crate::census::mv(mv.0, mv.1); | |
| 231 | 209 | mv |
| 232 | 210 | } |
| 233 | 211 | |
| @@ -297,13 +275,6 @@ pub(super) fn read_intrabc_dv( | ||
| 297 | 275 | true, |
| 298 | 276 | fctx, |
| 299 | 277 | ); |
| 300 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 301 | - let (rng, _) = dec.debug_state(); | |
| 302 | - eprintln!( | |
| 303 | - "EC_DV mi_row={mi_r} mi_col={mi_c} dv_col={} dv_row={} rng={rng}", | |
| 304 | - dv.1, dv.0 | |
| 305 | - ); | |
| 306 | - } | |
| 307 | 278 | dv |
| 308 | 279 | } |
| 309 | 280 | |
| @@ -335,7 +306,6 @@ impl PlaneBuf<'_> { | ||
| 335 | 306 | &mut self, |
| 336 | 307 | x: usize, |
| 337 | 308 | y: usize, |
| 338 | - plane: usize, | |
| 339 | 309 | side: usize, |
| 340 | 310 | w: usize, |
| 341 | 311 | h: usize, |
| @@ -363,13 +333,6 @@ impl PlaneBuf<'_> { | ||
| 363 | 333 | // prediction is byte-identical to the oracle's and whose committed |
| 364 | 334 | // samples are not can only be a DIFFERENT WRITE -- and this is the |
| 365 | 335 | // only write path with no rung of its own. |
| 366 | - if crate::envflags::env_flag!("EC_MCWR") { | |
| 367 | - eprintln!( | |
| 368 | - "EC_MCWR x={x} y={y} side={side} w={w} h={h} empty_res={} at {}", | |
| 369 | - residual.is_empty(), | |
| 370 | - std::panic::Location::caller() | |
| 371 | - ); | |
| 372 | - } | |
| 373 | 336 | // lane-av1444altref r2: EC_CPRED, the picture-independent twin of the |
| 374 | 337 | // oracle's rung of the same name (aomdec's |
| 375 | 338 | // `dec_build_inter_predictor`). This is the ONE site every inter |
| @@ -380,33 +343,6 @@ impl PlaneBuf<'_> { | ||
| 380 | 343 | // pictures, so a rung line alone is ambiguous, but a geometry whose |
| 381 | 344 | // samples differ by at most 1 is a unique match (any wrong pairing |
| 382 | 345 | // differs by tens). |
| 383 | - // Env: EC_CPRED="x:y" (plane-absolute origin; -1 for either = any). | |
| 384 | - if let Ok(spec) = crate::envflags::var("EC_CPRED") { | |
| 385 | - let (fx, fy): (i64, i64) = spec | |
| 386 | - .split_once(':') | |
| 387 | - .and_then(|(a, b)| Some((a.trim().parse().ok()?, b.trim().parse().ok()?))) | |
| 388 | - .unwrap_or((-1, -1)); | |
| 389 | - let hit = (fx < 0 || fx == x as i64) && (fy < 0 || fy == y as i64); | |
| 390 | - if hit { | |
| 391 | - // `PREFILT_PICTURE_IDX` is bumped once per frame just AFTER | |
| 392 | - // that frame's last block, so it still reads this frame's own | |
| 393 | - // decode-order index here -- the same numbering the oracle's | |
| 394 | - // `aom_ec_pict_idx` and the `.fN` prefilter dumps use. | |
| 395 | - let pict = PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst); | |
| 396 | - eprintln!( | |
| 397 | - "OUR_CPRED pict={pict} plane={plane} x={x} y={y} w={w} h={h} side={side}" | |
| 398 | - ); | |
| 399 | - for row in 0..h { | |
| 400 | - let src = &prediction[row * side..row * side + w]; | |
| 401 | - let mut line = String::with_capacity(w * 4); | |
| 402 | - for v in src { | |
| 403 | - line.push(' '); | |
| 404 | - line.push_str(&v.to_string()); | |
| 405 | - } | |
| 406 | - eprintln!("OUR_CPROW{row}:{line}"); | |
| 407 | - } | |
| 408 | - } | |
| 409 | - } | |
| 410 | 346 | // lane-recoparse: an all-zero residual (60% of the units) is a plain |
| 411 | 347 | // prediction copy -- the same arithmetic with `r == 0`, without |
| 412 | 348 | // reading `side * h` zeros out of [`ZERO_RESIDUAL`]. |
| @@ -416,9 +352,8 @@ impl PlaneBuf<'_> { | ||
| 416 | 352 | let dst = (y + row) * self.width + x; |
| 417 | 353 | let pred = &prediction[src..src + w]; |
| 418 | 354 | let out = &mut self.data.to_mut()[dst..dst + w]; |
| 419 | - for (col, (o, &p)) in out.iter_mut().zip(pred).enumerate() { | |
| 355 | + for (o, &p) in out.iter_mut().zip(pred) { | |
| 420 | 356 | let v = i32::from(p).clamp(0, max) as u16; |
| 421 | - pix_write("mc_copy", x, y, w, x + col, y + row, *o, v); | |
| 422 | 357 | *o = v; |
| 423 | 358 | } |
| 424 | 359 | } |
| @@ -431,9 +366,8 @@ impl PlaneBuf<'_> { | ||
| 431 | 366 | let pred = &prediction[src..src + w]; |
| 432 | 367 | let res = &residual[src..src + w]; |
| 433 | 368 | let out = &mut self.data.to_mut()[dst..dst + w]; |
| 434 | - for (col, ((o, &p), &r)) in out.iter_mut().zip(pred).zip(res).enumerate() { | |
| 369 | + for ((o, &p), &r) in out.iter_mut().zip(pred).zip(res) { | |
| 435 | 370 | let v = (i32::from(p) + r).clamp(0, max) as u16; |
| 436 | - pix_write("mc_add", x, y, w, x + col, y + row, *o, v); | |
| 437 | 371 | *o = v; |
| 438 | 372 | } |
| 439 | 373 | } |
| @@ -485,8 +419,6 @@ pub(super) fn read_inter_plane( | ||
| 485 | 419 | if plane_idx > 0 && mono(fctx) { |
| 486 | 420 | return Ok((Grid::Zero(side * side), TxType::DctDct)); |
| 487 | 421 | } |
| 488 | - // lane-av1readcensus: the units read from here on are this plane's. | |
| 489 | - set_census_plane(plane_idx); | |
| 490 | 422 | let skip_ctx = if plane_idx == 0 { |
| 491 | 423 | luma_skip_ctx.unwrap_or(0) |
| 492 | 424 | } else { |
| @@ -527,12 +459,6 @@ pub(super) fn read_inter_plane( | ||
| 527 | 459 | default_tx_type, |
| 528 | 460 | None, |
| 529 | 461 | )?; |
| 530 | - note_chroma_class1(plane_idx, tx_type); | |
| 531 | - if crate::envflags::env_flag!("EC_TRACE_TXTYPE") { | |
| 532 | - eprintln!( | |
| 533 | - "OUR_TXTYPE plane={plane_idx} x={x} y={cy} side={side} tx_type={tx_type:?} inh={inherited_luma_tx_type:?}" | |
| 534 | - ); | |
| 535 | - } | |
| 536 | 462 | // lane-inter8 r1: a 64-point transform covers the whole 64x64 area but |
| 537 | 463 | // codes only its top-left 32x32 of frequencies (spec 5.11.40) -- the |
| 538 | 464 | // caller hands the 32-point `scan` there, and the coded corner goes into |
| @@ -578,7 +504,6 @@ pub(super) fn read_intra_chroma_lossless( | ||
| 578 | 504 | cdfs: &mut Cdfs, |
| 579 | 505 | neighbours: &mut Neighbours, |
| 580 | 506 | at_mi: (usize, usize), |
| 581 | - (px, py): (usize, usize), | |
| 582 | 507 | (cpx, cpy): (usize, usize), |
| 583 | 508 | side: usize, |
| 584 | 509 | (blk_w, blk_h): (usize, usize), |
| @@ -586,13 +511,11 @@ pub(super) fn read_intra_chroma_lossless( | ||
| 586 | 511 | (reg_w, reg_h): (usize, usize), |
| 587 | 512 | stride: usize, |
| 588 | 513 | reach: Reach, |
| 589 | - (frame_w, frame_h): (usize, usize), | |
| 590 | 514 | mode: usize, |
| 591 | 515 | uv_predict_mode: usize, |
| 592 | 516 | angle_delta_uv: i32, |
| 593 | 517 | palette_uv_bufs: Option<(&[u16], &[u16])>, |
| 594 | 518 | smooth_neighbor_uv: bool, |
| 595 | - base_q_idx: u8, | |
| 596 | 519 | u_out: &mut Vec<i32>, |
| 597 | 520 | v_out: &mut Vec<i32>, |
| 598 | 521 | fctx: &crate::decode::FrameCtx, |
| @@ -635,11 +558,6 @@ pub(super) fn read_intra_chroma_lossless( | ||
| 635 | 558 | 4 << ss_x(fctx), |
| 636 | 559 | 4 << ss_y(fctx), |
| 637 | 560 | reach, |
| 638 | - px, | |
| 639 | - py, | |
| 640 | - frame_w, | |
| 641 | - frame_h, | |
| 642 | - fctx, | |
| 643 | 561 | ); |
| 644 | 562 | if let Some((ub, vb)) = palette_uv_bufs { |
| 645 | 563 | let buf = if plane_idx == 1 { ub } else { vb }; |
| @@ -663,7 +581,6 @@ pub(super) fn read_intra_chroma_lossless( | ||
| 663 | 581 | cpy + oy, |
| 664 | 582 | 4, |
| 665 | 583 | 4, |
| 666 | - base_q_idx, | |
| 667 | 584 | None, |
| 668 | 585 | None, |
| 669 | 586 | offset, |
| @@ -679,7 +596,6 @@ pub(super) fn read_intra_chroma_lossless( | ||
| 679 | 596 | plane_idx, |
| 680 | 597 | &cu_grid, |
| 681 | 598 | ); |
| 682 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 683 | 599 | let dst = mu_units( |
| 684 | 600 | if plane_idx == 1 { |
| 685 | 601 | &mut *u_out |
| @@ -738,9 +654,6 @@ pub(super) fn mu_chunk_order( | ||
| 738 | 654 | let mut order = identity.clone(); |
| 739 | 655 | order.sort_by_key(|&i| ((leaves[i].0 / 16) * nchunk + (leaves[i].1 / 16), i)); |
| 740 | 656 | let changed = order != identity; |
| 741 | - if changed { | |
| 742 | - hit!(MU_CHUNK_ORDER_HITS); | |
| 743 | - } | |
| 744 | 657 | (order, changed) |
| 745 | 658 | } |
| 746 | 659 | |
| @@ -788,10 +701,6 @@ pub(super) fn read_inter_chroma_lossless( | ||
| 788 | 701 | // lane-av1h5: a plane block above 64 is the 128-root class, whose chroma |
| 789 | 702 | // libaom walks one 64x64 mu chunk at a time. Counted so a gate can pin |
| 790 | 703 | // the walk/unit totals exactly rather than as a floor on wrong output. |
| 791 | - let counted_128 = blk_w > 64 || blk_h > 64; | |
| 792 | - if counted_128 { | |
| 793 | - hit!(MU_CHUNK_WALKS); | |
| 794 | - } | |
| 795 | 704 | for plane_idx in 1..3 { |
| 796 | 705 | for rr in 0..reg_h / 4 { |
| 797 | 706 | for cc in 0..reg_w / 4 { |
| @@ -851,10 +760,6 @@ pub(super) fn read_inter_chroma_lossless( | ||
| 851 | 760 | plane_idx, |
| 852 | 761 | &cu_grid, |
| 853 | 762 | ); |
| 854 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 855 | - if counted_128 { | |
| 856 | - hit!(MU_CHUNK_WALK_UNITS); | |
| 857 | - } | |
| 858 | 763 | let dst = mu_units( |
| 859 | 764 | if plane_idx == 1 { |
| 860 | 765 | &mut *u_out |
| @@ -1018,19 +923,6 @@ pub(super) fn read_single_ref( | ||
| 1018 | 923 | if p4 == 1 { LAST2_FRAME } else { LAST_FRAME } |
| 1019 | 924 | } |
| 1020 | 925 | }; |
| 1021 | - if ref_frame != LAST_FRAME { | |
| 1022 | - hit!(NON_LAST_REF_HITS); | |
| 1023 | - let c = match ref_frame { | |
| 1024 | - LAST2_FRAME => &LAST2_HITS, | |
| 1025 | - LAST3_FRAME => &LAST3_HITS, | |
| 1026 | - GOLDEN_FRAME => &GOLDEN_HITS, | |
| 1027 | - BWDREF_FRAME => &BWDREF_HITS, | |
| 1028 | - ALTREF2_FRAME => &ALTREF2_HITS, | |
| 1029 | - ALTREF_FRAME => &ALTREF_HITS, | |
| 1030 | - _ => unreachable!("read_single_ref only ever returns LAST_FRAME..=ALTREF_FRAME"), | |
| 1031 | - }; | |
| 1032 | - hit_do! { c.with(|v| v.set(v.get() + 1)); } | |
| 1033 | - } | |
| 1034 | 926 | ref_frame |
| 1035 | 927 | } |
| 1036 | 928 | |
| @@ -1070,9 +962,8 @@ pub(crate) struct RefPix<'p> { | ||
| 1070 | 962 | #[derive(Clone)] |
| 1071 | 963 | pub(crate) struct SharedRefs { |
| 1072 | 964 | pub(crate) dims: [Option<(usize, usize)>; 8], |
| 1073 | - pub(crate) wait: std::sync::Arc< | |
| 1074 | - dyn Fn() -> Result<[Option<std::sync::Arc<Picture>>; 8]> + Send + Sync, | |
| 1075 | - >, | |
| 965 | + pub(crate) wait: | |
| 966 | + std::sync::Arc<dyn Fn() -> Result<[Option<std::sync::Arc<Picture>>; 8]> + Send + Sync>, | |
| 1076 | 967 | } |
| 1077 | 968 | |
| 1078 | 969 | /// Where a [`RefPix`] gets its pictures: already in hand, or behind a wait |
| @@ -1207,12 +1098,6 @@ impl<'p> RefPix<'p> { | ||
| 1207 | 1098 | /// (lane-defer8). |
| 1208 | 1099 | pub(super) fn ref_dims(ref_frame: i8, refpix: &RefPix<'_>) -> Result<(usize, usize)> { |
| 1209 | 1100 | refpix.dims(ref_frame).ok_or_else(|| { |
| 1210 | - if crate::envflags::env_flag!("EC_AV1_REFPROBE") { | |
| 1211 | - eprintln!( | |
| 1212 | - "EC_REFPROBE missing ref {ref_frame}\n{}", | |
| 1213 | - std::backtrace::Backtrace::force_capture() | |
| 1214 | - ); | |
| 1215 | - } | |
| 1216 | 1101 | // lane-hdrlossless: libaom errors on the same stream |
| 1217 | 1102 | // (`decodeframe.c:5027`: `if (cm->ref_frame_map[ref] == NULL) |
| 1218 | 1103 | // aom_internal_error(... AOM_CODEC_CORRUPT_FRAME, "Inter frame |
| @@ -1406,9 +1291,6 @@ pub(super) fn overlappable_above( | ||
| 1406 | 1291 | if let Some(info) = nb |
| 1407 | 1292 | && info.is_inter |
| 1408 | 1293 | { |
| 1409 | - if src != col { | |
| 1410 | - hit!(OBMC_PAIR_FILTER_HITS); | |
| 1411 | - } | |
| 1412 | 1294 | // lane-t900 r14: libaom passes `AOMMIN(xd->width, mi_step)` |
| 1413 | 1295 | // as `op_mi_size` -- the block's OWN width, never the |
| 1414 | 1296 | // frame-edge clamp `end_col` carries. Clamping here shrank the |
| @@ -1473,9 +1355,6 @@ pub(super) fn overlappable_left( | ||
| 1473 | 1355 | if let Some(info) = nb |
| 1474 | 1356 | && info.is_inter |
| 1475 | 1357 | { |
| 1476 | - if src != row { | |
| 1477 | - hit!(OBMC_PAIR_FILTER_HITS); | |
| 1478 | - } | |
| 1479 | 1358 | // lane-t900 r14: `AOMMIN(xd->height, mi_step)` -- see |
| 1480 | 1359 | // `overlappable_above`. |
| 1481 | 1360 | out.push(( |
| @@ -1509,23 +1388,6 @@ pub(crate) fn has_overlappable_neighbour( | ||
| 1509 | 1388 | || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, 1).is_empty() |
| 1510 | 1389 | } |
| 1511 | 1390 | |
| 1512 | -/// The warp-sample gather's own `has_top_right` probe (libaom `av1_findSamples` | |
| 1513 | -/// calls the same `mvref_common.c` function the MV stack does). lane-sb128 r2: | |
| 1514 | -/// this used to hardcode `SB_MI` (a 64x64 superblock) -- at `sb_size == 128` | |
| 1515 | -/// libaom's mask loop runs one level further and strips the top-right sample | |
| 1516 | -/// off blocks whose neighbour IS decoded, so a warped 128-superblock frame | |
| 1517 | -/// picked up wrong warp parameters (frame 6 of the 128 inter gate). Delegates | |
| 1518 | -/// to the single sb-aware port in [`crate::mvstack::has_top_right`]; `bs` is | |
| 1519 | -/// the block's own side in 4x4 (`mi`) units (square inter leaves only here). | |
| 1520 | -pub(super) fn has_top_right( | |
| 1521 | - mi_row: usize, | |
| 1522 | - mi_col: usize, | |
| 1523 | - bs: usize, | |
| 1524 | - fctx: &crate::decode::FrameCtx, | |
| 1525 | -) -> bool { | |
| 1526 | - crate::mvstack::has_top_right(mi_row, mi_col, bs, bs, fctx) | |
| 1527 | -} | |
| 1528 | - | |
| 1529 | 1391 | /// `av1_findSamples` (`mvref_common.c`), full port: the up to |
| 1530 | 1392 | /// `LEAST_SQUARES_SAMPLES_MAX` (8) above/left/top-left/top-right neighbour |
| 1531 | 1393 | /// samples (`record_samples`) that share this block's own single reference |
| @@ -1557,16 +1419,8 @@ pub(crate) fn find_samples( | ||
| 1557 | 1419 | // motion_mode alphabet over the 2-symbol obmc one. |
| 1558 | 1420 | // lane-alloc: the `format!` (and the map lookup's `String` clone) ran on |
| 1559 | 1421 | // every warp block; the flag itself is a process constant. |
| 1560 | - let proj_dbg = crate::envflags::env_flag!("EC_PROJ_MI") | |
| 1561 | - && crate::envflags::var("EC_PROJ_MI").is_ok_and(|v| v == format!("{mi_row},{mi_col}")); | |
| 1562 | 1422 | let single_ref_match = |info: &MiInfo| { |
| 1563 | 1423 | let m = info.ref_frame == ref_frame && info.ref_frame1 == NO_REF1; |
| 1564 | - if proj_dbg { | |
| 1565 | - eprintln!( | |
| 1566 | - "EC_PROJ cand ref={} ref1={:?} size={} size_h={} is_inter={} want={ref_frame} match={m}", | |
| 1567 | - info.ref_frame, info.ref_frame1, info.size, info.size_h, info.is_inter | |
| 1568 | - ); | |
| 1569 | - } | |
| 1570 | 1424 | m |
| 1571 | 1425 | }; |
| 1572 | 1426 | let mut do_tl = true; |
| @@ -1682,9 +1536,6 @@ pub(crate) fn find_samples( | ||
| 1682 | 1536 | // libaom reads the 2-symbol `obmc_cdf` (class |
| 1683 | 1537 | // wrong-alphabet-same-value). |
| 1684 | 1538 | let tr_reach = crate::mvstack::has_top_right(mi_row, mi_col, bw4, bh4, fctx); |
| 1685 | - if do_tr && bw4 != bh4 && tr_reach != has_top_right(mi_row, mi_col, bw4, fctx) { | |
| 1686 | - hit!(TR_REACH_LONGER_SIDE_HITS); | |
| 1687 | - } | |
| 1688 | 1539 | if do_tr && tr_reach { |
| 1689 | 1540 | let tr_col = mi_col + bw4; |
| 1690 | 1541 | if mi_row > 0 |
| @@ -1785,53 +1636,12 @@ pub(super) fn neighbour_filter( | ||
| 1785 | 1636 | "an OBMC neighbour whose switchable interp filter was never recorded", |
| 1786 | 1637 | )); |
| 1787 | 1638 | } |
| 1788 | - hit!(OBMC_FILTER_BAND_READS); | |
| 1789 | 1639 | Ok(( |
| 1790 | 1640 | mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize), |
| 1791 | 1641 | mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize), |
| 1792 | 1642 | )) |
| 1793 | 1643 | } |
| 1794 | 1644 | |
| 1795 | -/// lane-obmcrec r1 MEASUREMENT rung (`EC_OBMCREC=1`): every OBMC neighbour whose | |
| 1796 | -/// recorded switchable-filter symbols are the `[3, 3]` "never recorded" sentinel | |
| 1797 | -/// -- names the neighbour's own position/shape/reference so the decode path that | |
| 1798 | -/// failed to record its filter can be identified. Read-only, off by default. | |
| 1799 | -#[allow(clippy::too_many_arguments)] | |
| 1800 | -fn obmcrec_probe( | |
| 1801 | - dir: &str, | |
| 1802 | - mi_row: usize, | |
| 1803 | - mi_col: usize, | |
| 1804 | - write_w: usize, | |
| 1805 | - write_h: usize, | |
| 1806 | - off4: usize, | |
| 1807 | - span4: usize, | |
| 1808 | - nb: &MiInfo, | |
| 1809 | - syms: [u8; 2], | |
| 1810 | - cell: Option<MiInfo>, | |
| 1811 | - fixed: bool, | |
| 1812 | -) { | |
| 1813 | - if (syms[0] <= 2 && syms[1] <= 2) || !crate::envflags::env_flag!("EC_OBMCREC") { | |
| 1814 | - return; | |
| 1815 | - } | |
| 1816 | - eprintln!( | |
| 1817 | - "OBMCREC {dir} cur_mi=({mi_row},{mi_col}) cur_wh=({write_w}x{write_h}) off4={off4} \ | |
| 1818 | -span4={span4} syms={syms:?} fixed={fixed} nb_size=({}x{}) nb_ref={} nb_ref1={:?} nb_mv=({},{}) \ | |
| 1819 | -nb_newmv={} cell_size={:?} cell_inter={:?} cell_ref={:?} sb_row_off={} sb_col_off={}", | |
| 1820 | - nb.size * 4, | |
| 1821 | - nb.size_h * 4, | |
| 1822 | - nb.ref_frame, | |
| 1823 | - nb.ref_frame1, | |
| 1824 | - nb.mv.0, | |
| 1825 | - nb.mv.1, | |
| 1826 | - nb.is_new_mv, | |
| 1827 | - cell.map(|c| (c.size * 4, c.size_h * 4)), | |
| 1828 | - cell.map(|c| c.is_inter), | |
| 1829 | - cell.map(|c| c.ref_frame), | |
| 1830 | - mi_row % 32, | |
| 1831 | - mi_col % 32, | |
| 1832 | - ); | |
| 1833 | -} | |
| 1834 | - | |
| 1835 | 1645 | /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh |
| 1836 | 1646 | /// against its own `mv`/reference/filter (libaom `av1_build_inter_predictor` |
| 1837 | 1647 | /// under `av1_setup_build_prediction_by_{above,left}_pred`). |
| @@ -2060,71 +1870,6 @@ fn obmc_blend_h( | ||
| 2060 | 1870 | } |
| 2061 | 1871 | } |
| 2062 | 1872 | |
| 2063 | -/// libaom's own `BLOCK_SIZE` enum index for a `w4`x`h4` (mi-unit) block -- | |
| 2064 | -/// only for the `EC_OBMC` trace rung below, so it reads byte-identical to | |
| 2065 | -/// the instrumented aomdec's `backup_mbmi.bsize`. | |
| 2066 | -fn ec_obmc_bsize(w4: usize, h4: usize) -> i32 { | |
| 2067 | - match (w4, h4) { | |
| 2068 | - (1, 1) => 0, | |
| 2069 | - (1, 2) => 1, | |
| 2070 | - (2, 1) => 2, | |
| 2071 | - (2, 2) => 3, | |
| 2072 | - (2, 4) => 4, | |
| 2073 | - (4, 2) => 5, | |
| 2074 | - (4, 4) => 6, | |
| 2075 | - (4, 8) => 7, | |
| 2076 | - (8, 4) => 8, | |
| 2077 | - (8, 8) => 9, | |
| 2078 | - (8, 16) => 10, | |
| 2079 | - (16, 8) => 11, | |
| 2080 | - (16, 16) => 12, | |
| 2081 | - (1, 4) => 16, | |
| 2082 | - (4, 1) => 17, | |
| 2083 | - (2, 8) => 18, | |
| 2084 | - (8, 2) => 19, | |
| 2085 | - (4, 16) => 20, | |
| 2086 | - (16, 4) => 21, | |
| 2087 | - _ => -1, | |
| 2088 | - } | |
| 2089 | -} | |
| 2090 | - | |
| 2091 | -/// The `EC_OBMC` rung: one line per blended neighbour, in the instrumented | |
| 2092 | -/// aomdec's own byte format (`decodeframe.c` | |
| 2093 | -/// `dec_build_prediction_by_{above,left}_pred`), so the two decoders' OBMC | |
| 2094 | -/// neighbour lists diff line for line. `filt` is libaom's packed | |
| 2095 | -/// `interp_filters.as_int` = `y_filter | (x_filter << 16)`. | |
| 2096 | -#[allow(clippy::too_many_arguments)] | |
| 2097 | -fn ec_obmc_trace( | |
| 2098 | - dir: &str, | |
| 2099 | - mi_row: usize, | |
| 2100 | - mi_col: usize, | |
| 2101 | - write_w: usize, | |
| 2102 | - write_h: usize, | |
| 2103 | - rel: usize, | |
| 2104 | - op: usize, | |
| 2105 | - nb: &MiInfo, | |
| 2106 | - h_kind: mc::InterpFilterKind, | |
| 2107 | - v_kind: mc::InterpFilterKind, | |
| 2108 | -) { | |
| 2109 | - if !crate::envflags::env_flag!("EC_OBMC") { | |
| 2110 | - return; | |
| 2111 | - } | |
| 2112 | - let sym = |k: mc::InterpFilterKind| match k { | |
| 2113 | - mc::InterpFilterKind::Smooth => 1u32, | |
| 2114 | - mc::InterpFilterKind::Sharp => 2, | |
| 2115 | - _ => 0, | |
| 2116 | - }; | |
| 2117 | - eprintln!( | |
| 2118 | - "EC_OBMC {dir} mi=({mi_row},{mi_col}) wh=({write_w}x{write_h}) rel={rel} op={op} \ | |
| 2119 | -nbmv=({},{}) nbref={} nbbsize={} filt={}", | |
| 2120 | - nb.mv.0, | |
| 2121 | - nb.mv.1, | |
| 2122 | - nb.ref_frame, | |
| 2123 | - ec_obmc_bsize(nb.size as usize, nb.size_h as usize), | |
| 2124 | - sym(v_kind) | (sym(h_kind) << 16), | |
| 2125 | - ); | |
| 2126 | -} | |
| 2127 | - | |
| 2128 | 1873 | /// `av1_build_obmc_inter_prediction` (libaom `reconinter.c`): re-predicts |
| 2129 | 1874 | /// the overlap strip against each bordering above/left inter neighbour's own |
| 2130 | 1875 | /// mv/ref/filter and blends it into this block's just-built single-reference |
| @@ -2201,9 +1946,6 @@ pub(crate) fn obmc_plan( | ||
| 2201 | 1946 | // lane-inter4 r4: r3 refused OBMC on a 16x8/8x16 leaf; re-measured |
| 2202 | 1947 | // byte-exact against an instrumented aomdec, the refusal is gone and the |
| 2203 | 1948 | // counter below is what the gate's `--enable-obmc=1` arm reads. |
| 2204 | - if matches!((write_w, write_h), (16, 8) | (8, 16)) { | |
| 2205 | - hit!(OBMC_RECT_LEAF_HITS); | |
| 2206 | - } | |
| 2207 | 1949 | // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own |
| 2208 | 1950 | // half (`reconinter.c` 860/899), inert below 128. |
| 2209 | 1951 | let overlap_above = write_h.min(64) / 2; |
| @@ -2233,27 +1975,8 @@ pub(crate) fn obmc_plan( | ||
| 2233 | 1975 | // `av1_setup_build_prediction_by_above_pred` reads |
| 2234 | 1976 | // `above_mbmi->interp_filters`). |
| 2235 | 1977 | let above_syms = above_filter.get(mi_col + src4).copied().unwrap_or([3; 2]); |
| 2236 | - obmcrec_probe( | |
| 2237 | - "above", | |
| 2238 | - mi_row, | |
| 2239 | - mi_col, | |
| 2240 | - write_w, | |
| 2241 | - write_h, | |
| 2242 | - off4, | |
| 2243 | - span4, | |
| 2244 | - &nb, | |
| 2245 | - above_syms, | |
| 2246 | - grid.get(mi_row - 1, mi_col + src4), | |
| 2247 | - interp_fixed.is_some(), | |
| 2248 | - ); | |
| 2249 | 1978 | let (h_kind, v_kind) = neighbour_filter(interp_fixed, above_syms)?; |
| 2250 | - ec_obmc_trace( | |
| 2251 | - "above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind, | |
| 2252 | - ); | |
| 2253 | 1979 | let nb_dims = ref_dims(nb.ref_frame, refpix)?; |
| 2254 | - if mi_col + off4 + span4 > mi_cols { | |
| 2255 | - hit!(OBMC_EDGE_SPAN_HITS); | |
| 2256 | - } | |
| 2257 | 1980 | above.push(ObmcNb { |
| 2258 | 1981 | off4, |
| 2259 | 1982 | span4, |
| @@ -2269,27 +1992,8 @@ pub(crate) fn obmc_plan( | ||
| 2269 | 1992 | overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) |
| 2270 | 1993 | { |
| 2271 | 1994 | let left_syms = left_filter.get(mi_row + src4).copied().unwrap_or([3; 2]); |
| 2272 | - obmcrec_probe( | |
| 2273 | - "left", | |
| 2274 | - mi_row, | |
| 2275 | - mi_col, | |
| 2276 | - write_w, | |
| 2277 | - write_h, | |
| 2278 | - off4, | |
| 2279 | - span4, | |
| 2280 | - &nb, | |
| 2281 | - left_syms, | |
| 2282 | - grid.get(mi_row + src4, mi_col - 1), | |
| 2283 | - interp_fixed.is_some(), | |
| 2284 | - ); | |
| 2285 | 1995 | let (h_kind, v_kind) = neighbour_filter(interp_fixed, left_syms)?; |
| 2286 | - ec_obmc_trace( | |
| 2287 | - "left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind, | |
| 2288 | - ); | |
| 2289 | 1996 | let nb_dims = ref_dims(nb.ref_frame, refpix)?; |
| 2290 | - if mi_row + off4 + span4 > mi_rows { | |
| 2291 | - hit!(OBMC_EDGE_SPAN_HITS); | |
| 2292 | - } | |
| 2293 | 1997 | left.push(ObmcNb { |
| 2294 | 1998 | off4, |
| 2295 | 1999 | span4, |
| @@ -2405,41 +2109,6 @@ pub(crate) fn obmc_run( | ||
| 2405 | 2109 | // block, reused by every neighbour of the above and left passes. |
| 2406 | 2110 | let (mut tmp_y, mut tmp_u, mut tmp_v) = (Vec::new(), Vec::new(), Vec::new()); |
| 2407 | 2111 | |
| 2408 | - // lane-t900 r13 rung: EC_MCB="<plane>:<px>:<py>[:<frame>]" (chroma plane | |
| 2409 | - // 1 only; <px>:<py> are chroma-plane pixels, the oracle's own dump | |
| 2410 | - // window) prints this block's chroma prediction rows before and after the | |
| 2411 | - // OBMC blend, matching the instrumented aomdec's EC_MCB dump. | |
| 2412 | - let ec_mcb: Option<(usize, usize, i64)> = crate::envflags::env_flag!("EC_MCB") | |
| 2413 | - .then(|| crate::envflags::var("EC_MCB").ok()) | |
| 2414 | - .flatten() | |
| 2415 | - .and_then(|v| { | |
| 2416 | - let f: Vec<&str> = v.split(':').collect(); | |
| 2417 | - if f.len() < 3 || f[0] != "1" { | |
| 2418 | - return None; | |
| 2419 | - } | |
| 2420 | - let (x, y) = (f[1].parse::<usize>().ok()?, f[2].parse::<usize>().ok()?); | |
| 2421 | - let fr = f.get(3).and_then(|s| s.parse::<i64>().ok()).unwrap_or(-1); | |
| 2422 | - let idx = PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) as i64; | |
| 2423 | - // lane-av1ecmcb: the window is the CHROMA plane's own write region -- | |
| 2424 | - // the oracle's EC_MCB spans are plane pixels, and at 4:4:4 (ss 0/0) | |
| 2425 | - // the chroma block is full-size, so nothing halves. The old | |
| 2426 | - // `write_w / 2` was a 4:2:0-era assumption that quartered the window | |
| 2427 | - // (and the dumps below) at ss 0/0. | |
| 2428 | - let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); | |
| 2429 | - if x >= cpx && x < cpx + cw && y >= cpy && y < cpy + ch && (fr < 0 || fr == idx) { | |
| 2430 | - Some((x, y, idx)) | |
| 2431 | - } else { | |
| 2432 | - None | |
| 2433 | - } | |
| 2434 | - }); | |
| 2435 | - if let Some((_, _, idx)) = ec_mcb { | |
| 2436 | - let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); | |
| 2437 | - eprintln!("OUR_MCB pre f={idx} cpx={cpx} cpy={cpy} cw={cw} ch={ch}"); | |
| 2438 | - for r in 0..ch { | |
| 2439 | - let row: Vec<u16> = (0..cw).map(|c| pred_u[r * chroma_stride + c]).collect(); | |
| 2440 | - eprintln!("OUR_MCB prerow{r}: {row:?}"); | |
| 2441 | - } | |
| 2442 | - } | |
| 2443 | 2112 | for nb in &plan.above { |
| 2444 | 2113 | let Some((ny, nu, nv)) = ref_planes_deferred(nb.ref_frame, refpix) else { |
| 2445 | 2114 | return; |
| @@ -2547,16 +2216,6 @@ pub(crate) fn obmc_run( | ||
| 2547 | 2216 | &mut tmp_u, |
| 2548 | 2217 | fctx, |
| 2549 | 2218 | ); |
| 2550 | - if let Some((_, _, idx)) = ec_mcb { | |
| 2551 | - eprintln!( | |
| 2552 | - "OUR_MCB left f={idx} off4={} span4={} cbw={cbw} cbh={cbh} coy={coy} mv=({},{}) ref0={}", | |
| 2553 | - nb.off4, nb.span4, nb.mv.0, nb.mv.1, nb.ref_frame | |
| 2554 | - ); | |
| 2555 | - for r in 0..cbh { | |
| 2556 | - let row: Vec<u16> = (0..cbw).map(|c| tmp_u[r * cbw + c]).collect(); | |
| 2557 | - eprintln!("OUR_MCB lrow{r}: {row:?}"); | |
| 2558 | - } | |
| 2559 | - } | |
| 2560 | 2219 | let ch = cbh.min((write_h >> ss_y(fctx)) - coy); |
| 2561 | 2220 | obmc_blend_h(pred_u, chroma_stride, 0, coy, cbw, ch, &tmp_u); |
| 2562 | 2221 | obmc_neighbour_pred( |
| @@ -2575,13 +2234,6 @@ pub(crate) fn obmc_run( | ||
| 2575 | 2234 | ); |
| 2576 | 2235 | obmc_blend_h(pred_v, chroma_stride, 0, coy, cbw, ch, &tmp_v); |
| 2577 | 2236 | } |
| 2578 | - if let Some((_, _, idx)) = ec_mcb { | |
| 2579 | - let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); | |
| 2580 | - for r in 0..ch { | |
| 2581 | - let row: Vec<u16> = (0..cw).map(|c| pred_u[r * chroma_stride + c]).collect(); | |
| 2582 | - eprintln!("OUR_MCB post f={idx} row{r}: {row:?}"); | |
| 2583 | - } | |
| 2584 | - } | |
| 2585 | 2237 | } |
| 2586 | 2238 | |
| 2587 | 2239 | /// `is_any_masked_compound_used` (libaom `reconinter.h`), specialised to |
| @@ -2714,18 +2366,6 @@ pub(super) fn read_comp_mode( | ||
| 2714 | 2366 | ) -> bool { |
| 2715 | 2367 | let ctx = reference_mode_ctx(above, left); |
| 2716 | 2368 | let compound = dec.symbol(&mut cdfs.comp_mode[ctx]) == 1; |
| 2717 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 2718 | - eprintln!( | |
| 2719 | - "EC_RCM ctx={ctx} val={} a={:?} l={:?} rng={}", | |
| 2720 | - usize::from(compound), | |
| 2721 | - above.map(|n| (n.is_inter, n.ref0, n.ref1)), | |
| 2722 | - left.map(|n| (n.is_inter, n.ref0, n.ref1)), | |
| 2723 | - dec.debug_state().0 | |
| 2724 | - ); | |
| 2725 | - } | |
| 2726 | - if compound { | |
| 2727 | - hit!(COMP_MODE_HITS); | |
| 2728 | - } | |
| 2729 | 2369 | compound |
| 2730 | 2370 | } |
| 2731 | 2371 | |
| @@ -2767,7 +2407,6 @@ pub(super) fn read_compound_ref_frames( | ||
| 2767 | 2407 | let type_ctx = comp_reference_type_ctx(above, left); |
| 2768 | 2408 | let unidir = dec.symbol(&mut cdfs.comp_ref_type[type_ctx]) == 0; |
| 2769 | 2409 | if unidir { |
| 2770 | - hit!(UNI_COMP_HITS); | |
| 2771 | 2410 | // uni_comp_ref (p0): forward vs. backward -- av1_get_pred_context_- |
| 2772 | 2411 | // uni_comp_ref_p is single_ref_p1's own forward/backward vote. |
| 2773 | 2412 | let bit = dec.symbol(&mut cdfs.uni_comp_ref[single_ref_p1_ctx(a, a1, l, l1)][0]); |
| @@ -2829,7 +2468,6 @@ pub(super) fn read_inter_compound_mode( | ||
| 2829 | 2468 | ref_mv_ctx: usize, |
| 2830 | 2469 | ) -> u8 { |
| 2831 | 2470 | let ctx = cdf::COMPOUND_MODE_CTX_MAP[ref_mv_ctx >> 1][new_mv_ctx.min(4)]; |
| 2832 | - hit!(COMPOUND_MODE_HITS); | |
| 2833 | 2471 | dec.symbol(&mut cdfs.inter_compound_mode[ctx]) as u8 |
| 2834 | 2472 | } |
| 2835 | 2473 | |
| @@ -3031,17 +2669,3 @@ thread_local! { | ||
| 3031 | 2669 | /// chroma plane -- the non-vacuity bar for the assertion at that site. |
| 3032 | 2670 | pub(crate) static CHROMA_RECT_BLOCK_TX_FALLBACK_MULTI: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 3033 | 2671 | } |
| 3034 | - | |
| 3035 | -/// [`CHROMA_RECT_BLOCK_TX_FALLBACK`]: rect chroma units handed the block-level | |
| 3036 | -/// type because no luma leaf covered their own MI cell. | |
| 3037 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 3038 | -pub(crate) fn chroma_rect_block_tx_fallback() -> usize { | |
| 3039 | - CHROMA_RECT_BLOCK_TX_FALLBACK.with(std::cell::Cell::get) | |
| 3040 | -} | |
| 3041 | - | |
| 3042 | -/// [`CHROMA_RECT_BLOCK_TX_FALLBACK_MULTI`]: of those, the ones whose chroma | |
| 3043 | -/// plane had more than one unit. | |
| 3044 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 3045 | -pub(crate) fn chroma_rect_block_tx_fallback_multi() -> usize { | |
| 3046 | - CHROMA_RECT_BLOCK_TX_FALLBACK_MULTI.with(std::cell::Cell::get) | |
| 3047 | -} |
crates/ec-av1/src/decode/inter_intra_arm.rsmodified+0 -142
| @@ -132,25 +132,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 132 | 132 | .filter(|_| write_w.min(write_h) == 4 && write_w.max(write_h) == 16) |
| 133 | 133 | .map(|s| (s.horz, s.has_chroma)); |
| 134 | 134 | if write_w.min(write_h) < 8 && strip16.is_none() { |
| 135 | - if crate::envflags::env_flag!("EC_INTRA16X4") { | |
| 136 | - let (idx, hc, prev_inter) = match strip_chroma { | |
| 137 | - Some(s) => ( | |
| 138 | - if s.horz { | |
| 139 | - rmi - s.pair_mi.0 | |
| 140 | - } else { | |
| 141 | - cmi - s.pair_mi.1 | |
| 142 | - }, | |
| 143 | - s.has_chroma, | |
| 144 | - s.prev.is_some(), | |
| 145 | - ), | |
| 146 | - None => (9, true, false), | |
| 147 | - }; | |
| 148 | - eprintln!( | |
| 149 | - "EC_INTRA16X4 w={write_w} h={write_h} pair_parity={idx} has_chroma={hc} prev_single_inter={prev_inter} skip={skip} mi={rmi},{cmi} tx_select={} scr={}", | |
| 150 | - fctx.tx_select_inter.with(std::cell::Cell::get), | |
| 151 | - allow_screen_content_tools, | |
| 152 | - ); | |
| 153 | - } | |
| 154 | 135 | return Err(unsupported( |
| 155 | 136 | "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)", |
| 156 | 137 | )); |
| @@ -215,14 +196,7 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 215 | 196 | ); |
| 216 | 197 | return Ok(None); |
| 217 | 198 | } |
| 218 | - crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | |
| 219 | 199 | let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]); |
| 220 | - if crate::envflags::env_flag!("EC_IIS") { | |
| 221 | - eprintln!( | |
| 222 | - "TRACE iis px={px} py={py} side={side} w={write_w} h={write_h} sg={} mode={mode} skip={skip}", | |
| 223 | - size_group_wh(write_w, write_h) | |
| 224 | - ); | |
| 225 | - } | |
| 226 | 200 | if mode >= 13 { |
| 227 | 201 | return Err(unsupported( |
| 228 | 202 | "an intra mode this decoder does not code (round 2)", |
| @@ -241,9 +215,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 241 | 215 | } else { |
| 242 | 216 | 0 |
| 243 | 217 | }; |
| 244 | - if angle_delta_y != 0 { | |
| 245 | - hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS); | |
| 246 | - } | |
| 247 | 218 | // The delta'd angle decides whether the intra edge filter runs at |
| 248 | 219 | // all, so this block needs the same luma edge-filter-type neighbour |
| 249 | 220 | // check a key-frame block does (`get_intra_edge_filter_type`, spec |
| @@ -263,21 +234,13 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 263 | 234 | // (libaom `decodemv.c:933`). |
| 264 | 235 | let has_chroma = !mono(fctx); |
| 265 | 236 | let cfl_allowed = has_chroma && cfl_allowed_px(write_w, write_h, fctx); |
| 266 | - if !cfl_allowed { | |
| 267 | - hit!(NOCFL_UV_MODE_HITS); | |
| 268 | - } | |
| 269 | 237 | let uv_mode = if !has_chroma { |
| 270 | 238 | DC_PRED |
| 271 | 239 | } else if cfl_allowed { |
| 272 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 273 | 240 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 274 | 241 | } else { |
| 275 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 276 | 242 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 277 | 243 | }; |
| 278 | - if (9..=12).contains(&uv_mode) { | |
| 279 | - hit!(SMOOTH_UV_HITS); | |
| 280 | - } | |
| 281 | 244 | let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { |
| 282 | 245 | Some(read_cfl_alphas(dec, cdfs)) |
| 283 | 246 | } else { |
| @@ -288,15 +251,10 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 288 | 251 | // -- `uv_mode` (13) already falls outside `V_PRED..=D67_PRED` so the |
| 289 | 252 | // `else` branch below is exact for it either way. |
| 290 | 253 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 291 | - hit!(DIRECTIONAL_UV_HITS); | |
| 292 | 254 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 293 | 255 | } else { |
| 294 | 256 | 0 |
| 295 | 257 | }; |
| 296 | - if angle_delta_uv != 0 { | |
| 297 | - hit!(UV_ANGLE_DELTA_HITS); | |
| 298 | - hit!(INTRA_IN_INTER_ANGLE_DELTA_UV_HITS); | |
| 299 | - } | |
| 300 | 258 | uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 301 | 259 | DC_PRED |
| 302 | 260 | } else { |
| @@ -336,24 +294,9 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 336 | 294 | let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]); |
| 337 | 295 | palette_y_pending = Some((n, read_palette_colors_y(dec, n, &palette_cache, fctx))); |
| 338 | 296 | } |
| 339 | - if crate::envflags::env_flag!("EC_PALSYN") { | |
| 340 | - eprintln!( | |
| 341 | - "EC_PALSYN_PRE sq mi={rmi},{cmi} bw={write_w} bh={write_h} mode={mode} uv={uv_mode} ctx={palette_ctx} y={} rng={}", | |
| 342 | - palette_y_pending.map_or(0, |(n, _)| n), | |
| 343 | - dec.debug_state().0 | |
| 344 | - ); | |
| 345 | - } | |
| 346 | 297 | let use_palette_uv = has_chroma |
| 347 | 298 | && uv_mode == DC_PRED |
| 348 | 299 | && dec.symbol(&mut cdfs.palette_uv_mode[usize::from(use_palette_y)]) != 0; |
| 349 | - if crate::envflags::env_flag!("EC_PALSYN") { | |
| 350 | - eprintln!( | |
| 351 | - "EC_PALSYN sq mi={rmi},{cmi} bw={write_w} bh={write_h} mode={mode} uv={uv_mode} ctx={palette_ctx} y={} uv={} rng={}", | |
| 352 | - use_palette_y as i32, | |
| 353 | - use_palette_uv as i32, | |
| 354 | - dec.debug_state().0 | |
| 355 | - ); | |
| 356 | - } | |
| 357 | 300 | if use_palette_uv { |
| 358 | 301 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); |
| 359 | 302 | let (u_colors, v_colors) = read_palette_colors_uv(dec, n, &palette_uv_cache, fctx); |
| @@ -379,8 +322,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 379 | 322 | && let Some(class) = filter_intra_size_class_rect(write_w, write_h) |
| 380 | 323 | && dec.symbol(&mut cdfs.filter_intra[class]) != 0 |
| 381 | 324 | { |
| 382 | - hit!(FILTER_INTRA_HITS); | |
| 383 | - hit!(INTRA_IN_INTER_FILTER_INTRA_HITS); | |
| 384 | 325 | filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); |
| 385 | 326 | } |
| 386 | 327 | // `av1_visit_palette`: the two colour-index maps, Y then the shared |
| @@ -395,8 +336,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 395 | 336 | palette_onscreen(rmi, cmi, write_w, write_h, fctx), |
| 396 | 337 | false, |
| 397 | 338 | ); |
| 398 | - hit!(PALETTE_HITS); | |
| 399 | - hit!(INTRA_IN_INTER_PALETTE_Y_HITS); | |
| 400 | 339 | PaletteY { |
| 401 | 340 | size: n, |
| 402 | 341 | colors, |
| @@ -419,8 +358,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 419 | 358 | (ss_x(fctx), ss_y(fctx)), |
| 420 | 359 | ); |
| 421 | 360 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true); |
| 422 | - hit!(PALETTE_UV_HITS); | |
| 423 | - hit!(INTRA_IN_INTER_PALETTE_UV_HITS); | |
| 424 | 361 | PaletteUv { |
| 425 | 362 | size: n, |
| 426 | 363 | u_colors, |
| @@ -516,7 +453,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 516 | 453 | // (the whole-block buffer would be indexed at the wrong |
| 517 | 454 | // stride by the first unit). |
| 518 | 455 | if let Some(buf) = &palette_y_buf { |
| 519 | - hit!(PALETTE_SPLIT_TX_HITS); | |
| 520 | 456 | let window: Vec<u16> = (0..tx_px) |
| 521 | 457 | .flat_map(|i| { |
| 522 | 458 | let base = (row * MI + i) * side + col * MI; |
| @@ -553,10 +489,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 553 | 489 | dec, |
| 554 | 490 | cdfs, |
| 555 | 491 | txbset_for(tx_px, reduced), |
| 556 | - // lane-sb128c r5: a TX_64X64 unit codes only its | |
| 557 | - // top-left 32x32 of frequencies (spec 5.11.40), so | |
| 558 | - // the scan and `tx_side` are the CODED corner while | |
| 559 | - // `side` stays the transform's true 64. | |
| 560 | 492 | default_scan(tx_px.min(32)), |
| 561 | 493 | 0, |
| 562 | 494 | neighbours.around_mi(tu_mi, tx_px)[0], |
| @@ -571,7 +503,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 571 | 503 | tu_py, |
| 572 | 504 | tx_px, |
| 573 | 505 | tx_px.min(32), |
| 574 | - base_q_idx, | |
| 575 | 506 | None, |
| 576 | 507 | filter_intra, |
| 577 | 508 | Some(tu_skip_ctx), |
| @@ -588,7 +519,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 588 | 519 | continue; |
| 589 | 520 | } |
| 590 | 521 | let (cr, cc) = chunk; |
| 591 | - hit!(INTRA_128_IN_INTER_MU_CHROMA_HITS); | |
| 592 | 522 | // The unit's CHROMA size, its LUMA footprint, the |
| 593 | 523 | // CHUNK's chroma extent and the unit's ORIGIN inside the |
| 594 | 524 | // chunk are four different quantities; this arm had the |
| @@ -641,32 +571,18 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 641 | 571 | cdfs, |
| 642 | 572 | neighbours, |
| 643 | 573 | at_mi, |
| 644 | - (px, py), | |
| 645 | 574 | (cpx, cpy), |
| 646 | 575 | side, |
| 647 | - // lane-av1422lpf site 6 (the intra-in-inter twin of | |
| 648 | - // site 5 at 41572): the plane block's own per-axis | |
| 649 | - // shape and stride, never the enclosing square. | |
| 650 | - // `palette_uv_bufs` is the decoded colour-index map | |
| 651 | - // at `(write_w >> ss_x, write_h >> ss_y)` (44144), | |
| 652 | - // i.e. per-axis already, and the lossless walk | |
| 653 | - // windows it at this `stride` -- at 4:2:2 a | |
| 654 | - // 16-wide square stride over an 8-wide map put the | |
| 655 | - // third unit row at index 180 of 128 samples | |
| 656 | - // (`palette_window`, decode.rs:2946; measured on | |
| 657 | - // `Y_intrabc_10b.obu`). | |
| 658 | 576 | (chroma_stride, chroma_buf_h), |
| 659 | 577 | (cc * chunk_chroma_w, cr * chunk_chroma_h), |
| 660 | 578 | (chunk_chroma_w, chunk_chroma_h), |
| 661 | 579 | chroma_stride, |
| 662 | 580 | reach, |
| 663 | - (y.width, y.height), | |
| 664 | 581 | mode, |
| 665 | 582 | uv_predict_mode, |
| 666 | 583 | angle_delta_uv, |
| 667 | 584 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), |
| 668 | 585 | smooth_neighbor_uv, |
| 669 | - base_q_idx, | |
| 670 | 586 | &mut u_units, |
| 671 | 587 | &mut v_units, |
| 672 | 588 | fctx, |
| @@ -718,11 +634,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 718 | 634 | cr * chunk_luma + ur * unit_luma_h, |
| 719 | 635 | unit_luma_w, |
| 720 | 636 | reach, |
| 721 | - px, | |
| 722 | - py, | |
| 723 | - y.width, | |
| 724 | - y.height, | |
| 725 | - fctx, | |
| 726 | 637 | ); |
| 727 | 638 | let cu_grid = if skip { |
| 728 | 639 | push_intra( |
| @@ -762,15 +673,8 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 762 | 673 | cu_y, |
| 763 | 674 | cu_tx, |
| 764 | 675 | cu_tx, |
| 765 | - base_q_idx, | |
| 766 | - // CfL is refused above 32x32 | |
| 767 | - // (`is_cfl_allowed`), so never here. | |
| 768 | 676 | None, |
| 769 | 677 | None, |
| 770 | - // The uv plane block is larger than | |
| 771 | - // the unit: `get_txb_ctx`'s offset-10 | |
| 772 | - // rows, +3 on the `txb_skip_chroma_32` | |
| 773 | - // table (lane-sb128b r3). | |
| 774 | 678 | Some(3), |
| 775 | 679 | smooth_neighbor_uv, |
| 776 | 680 | fctx, |
| @@ -785,7 +689,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 785 | 689 | plane_idx, |
| 786 | 690 | &cu_grid, |
| 787 | 691 | ); |
| 788 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 789 | 692 | // lane-dpm1: the two INTER mu-chunk sites set |
| 790 | 693 | // this and this INTRA-in-inter one did not, so |
| 791 | 694 | // the whole-block chroma record below re-stamped |
| @@ -794,9 +697,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 794 | 697 | // libaom never selects (class |
| 795 | 698 | // `override-slot-on-one-arm`). |
| 796 | 699 | mu_chroma = true; |
| 797 | - // lane-av1muchunk422b: the allocation of the intra-in-inter | |
| 798 | - // mu-chunk walk (site 8), per TX_32X32 unit. | |
| 799 | - hit!(MU_CHUNK_INTRA_IN_INTER_UNITS); | |
| 800 | 700 | let dst = mu_units( |
| 801 | 701 | if plane_idx == 1 { |
| 802 | 702 | &mut u_units |
| @@ -846,7 +746,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 846 | 746 | } else { |
| 847 | 747 | Grid::Own(std::mem::take(&mut v_units)) |
| 848 | 748 | }; |
| 849 | - hit!(INTRA_128_IN_INTER_HITS); | |
| 850 | 749 | } else if skip { |
| 851 | 750 | if !split_luma { |
| 852 | 751 | if let Some(buf) = &palette_y_buf { |
| @@ -945,7 +844,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 945 | 844 | py, |
| 946 | 845 | side, |
| 947 | 846 | luma_tx, |
| 948 | - base_q_idx, | |
| 949 | 847 | None, |
| 950 | 848 | filter_intra, |
| 951 | 849 | None, |
| @@ -966,26 +864,18 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 966 | 864 | cdfs, |
| 967 | 865 | neighbours, |
| 968 | 866 | at_mi, |
| 969 | - (px, py), | |
| 970 | 867 | (cpx, cpy), |
| 971 | 868 | side, |
| 972 | - // lane-av1422lpf site 6 (the whole-block twin of the mu | |
| 973 | - // chunk fix at 44374): the plane block's own per-axis shape | |
| 974 | - // and its own stride, never the enclosing square | |
| 975 | - // `chroma_side`. At 4:2:0 and 4:4:4 all three are the same | |
| 976 | - // number. | |
| 977 | 869 | (chroma_stride, chroma_buf_h), |
| 978 | 870 | (0, 0), |
| 979 | 871 | (chroma_stride, chroma_buf_h), |
| 980 | 872 | chroma_stride, |
| 981 | 873 | reach, |
| 982 | - (y.width, y.height), | |
| 983 | 874 | mode, |
| 984 | 875 | uv_predict_mode, |
| 985 | 876 | angle_delta_uv, |
| 986 | 877 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), |
| 987 | 878 | smooth_neighbor_uv, |
| 988 | - base_q_idx, | |
| 989 | 879 | &mut uo, |
| 990 | 880 | &mut vo, |
| 991 | 881 | fctx, |
| @@ -1035,11 +925,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 1035 | 925 | cu_row * chroma_tx, |
| 1036 | 926 | chroma_tx, |
| 1037 | 927 | reach, |
| 1038 | - px, | |
| 1039 | - py, | |
| 1040 | - y.width, | |
| 1041 | - y.height, | |
| 1042 | - fctx, | |
| 1043 | 928 | ); |
| 1044 | 929 | let cu_grid = read_plane( |
| 1045 | 930 | dec, |
| @@ -1059,9 +944,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 1059 | 944 | cpy + cu_row * chroma_tx, |
| 1060 | 945 | chroma_tx, |
| 1061 | 946 | chroma_tx, |
| 1062 | - base_q_idx, | |
| 1063 | - // CfL is capped at 32x32 (`is_cfl_allowed`), | |
| 1064 | - // so a block this size never carries alpha. | |
| 1065 | 947 | None, |
| 1066 | 948 | None, |
| 1067 | 949 | Some(3), |
| @@ -1072,7 +954,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 1072 | 954 | // coefficient context. |
| 1073 | 955 | neighbours |
| 1074 | 956 | .record_mi_chroma(cu_mi, chroma_tx, chroma_tx, plane_idx, &cu_grid); |
| 1075 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 1076 | 957 | let acc = if plane_idx == 1 { |
| 1077 | 958 | &mut u_acc |
| 1078 | 959 | } else { |
| @@ -1123,7 +1004,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 1123 | 1004 | cpy, |
| 1124 | 1005 | chroma_side, |
| 1125 | 1006 | chroma_tx, |
| 1126 | - base_q_idx, | |
| 1127 | 1007 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1128 | 1008 | None, |
| 1129 | 1009 | None, |
| @@ -1161,11 +1041,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 1161 | 1041 | luma_span_x, |
| 1162 | 1042 | luma_span_y, |
| 1163 | 1043 | reach, |
| 1164 | - px, | |
| 1165 | - py, | |
| 1166 | - y.width, | |
| 1167 | - y.height, | |
| 1168 | - fctx, | |
| 1169 | 1044 | ); |
| 1170 | 1045 | // The 4:2:2 plane block is `(chroma_w, chroma_h)` -- |
| 1171 | 1046 | // 32x64 -- but codes TWO stacked TX_32X32 units, so |
| @@ -1181,7 +1056,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 1181 | 1056 | fctx, |
| 1182 | 1057 | ); |
| 1183 | 1058 | } |
| 1184 | - hit!(PALETTE_422_UNIT_WINDOW_HITS); | |
| 1185 | 1059 | let cu_grid = read_plane( |
| 1186 | 1060 | dec, |
| 1187 | 1061 | cdfs, |
| @@ -1200,18 +1074,12 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 1200 | 1074 | cpy + cu_row * cu_h, |
| 1201 | 1075 | cu_w, |
| 1202 | 1076 | cu_w, |
| 1203 | - base_q_idx, | |
| 1204 | 1077 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1205 | 1078 | None, |
| 1206 | - // The uv plane block (32x64) is larger than the unit | |
| 1207 | - // (32x32): `get_txb_ctx`'s offset-10 rows, +3 on the | |
| 1208 | - // `txb_skip_chroma_32` table (lane-sb128b r3). | |
| 1209 | 1079 | Some(3), |
| 1210 | 1080 | smooth_neighbor_uv, |
| 1211 | 1081 | fctx, |
| 1212 | 1082 | )?; |
| 1213 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 1214 | - hit!(CHROMA422_SQUARE_HITS); | |
| 1215 | 1083 | // Immediately, so the next unit of this plane reads this |
| 1216 | 1084 | // one's coefficient context; the whole-block record below |
| 1217 | 1085 | // re-stamps the block over these and the tail's |
| @@ -1280,7 +1148,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 1280 | 1148 | cpy, |
| 1281 | 1149 | chroma_side, |
| 1282 | 1150 | chroma_tx, |
| 1283 | - base_q_idx, | |
| 1284 | 1151 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1285 | 1152 | None, |
| 1286 | 1153 | None, |
| @@ -1309,11 +1176,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 1309 | 1176 | luma_span_x, |
| 1310 | 1177 | luma_span_y, |
| 1311 | 1178 | reach, |
| 1312 | - px, | |
| 1313 | - py, | |
| 1314 | - y.width, | |
| 1315 | - y.height, | |
| 1316 | - fctx, | |
| 1317 | 1179 | ); |
| 1318 | 1180 | // The V twin of the U arm's per-unit window above. |
| 1319 | 1181 | if let Some((_, vb)) = &palette_uv_bufs { |
| @@ -1322,7 +1184,6 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 1322 | 1184 | fctx, |
| 1323 | 1185 | ); |
| 1324 | 1186 | } |
| 1325 | - hit!(PALETTE_422_UNIT_WINDOW_HITS); | |
| 1326 | 1187 | let cu_grid = read_plane( |
| 1327 | 1188 | dec, |
| 1328 | 1189 | cdfs, |
| @@ -1341,15 +1202,12 @@ pub(super) fn decode_inter_block_intra_arm( | ||
| 1341 | 1202 | cpy + cu_row * cu_h, |
| 1342 | 1203 | cu_w, |
| 1343 | 1204 | cu_w, |
| 1344 | - base_q_idx, | |
| 1345 | 1205 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1346 | 1206 | None, |
| 1347 | 1207 | Some(3), |
| 1348 | 1208 | smooth_neighbor_uv, |
| 1349 | 1209 | fctx, |
| 1350 | 1210 | )?; |
| 1351 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 1352 | - hit!(CHROMA422_SQUARE_HITS); | |
| 1353 | 1211 | neighbours.record_mi_chroma(cu_mi, luma_span_x, luma_span_y, 2, &cu_grid); |
| 1354 | 1212 | for rr in 0..cu_h { |
| 1355 | 1213 | let start = (cu_row * cu_h + rr) * chroma_side; |
crates/ec-av1/src/decode/inter_shapes.rsmodified+1 -97
| @@ -81,11 +81,6 @@ pub(super) fn read_block_tx_size( | ||
| 81 | 81 | // |
| 82 | 82 | // The RECT twin [`read_block_tx_size_rect`] has published on this arm |
| 83 | 83 | // since lane-av1lm444loss; only the square arm had the hole. |
| 84 | - let pub_above: u8 = if skip && is_inter { | |
| 85 | - (side_mi * MI) as u8 | |
| 86 | - } else { | |
| 87 | - 4 | |
| 88 | - }; | |
| 89 | 84 | // The gate's non-vacuity arm, on the DECISION, sampled BEFORE the |
| 90 | 85 | // write: this publish CHANGES at least one of the above-band cells it |
| 91 | 86 | // covers -- the cell did not already hold `pub_above`, so a later |
| @@ -104,12 +99,7 @@ pub(super) fn read_block_tx_size( | ||
| 104 | 99 | // first-touch case. The count is still a decision (no reader, no |
| 105 | 100 | // intra-only frame, no unchanged column), so the gate keeps its teeth; |
| 106 | 101 | // only the doc's stronger reading was wrong. |
| 107 | - let overwrote = !fctx.intra_only.with(std::cell::Cell::get) | |
| 108 | - && (0..side_mi).any(|i| n.above_txfm.get(at_mi.1 + i) != Some(&pub_above)); | |
| 109 | 102 | set_txfm_ctxs(n, at_mi, 4, side_mi, side_mi, skip && is_inter); |
| 110 | - if overwrote { | |
| 111 | - hit!(LOSSLESS_SQ_TXFM_BAND_OVERWRITE_HITS); | |
| 112 | - } | |
| 113 | 103 | return Ok((4, Some(leaves))); |
| 114 | 104 | } |
| 115 | 105 | if !fctx.tx_select_inter.with(std::cell::Cell::get) { |
| @@ -194,13 +184,6 @@ pub(super) fn read_block_tx_size( | ||
| 194 | 184 | leaves.push((row, col, tx, tx)); |
| 195 | 185 | } |
| 196 | 186 | } |
| 197 | - hit_do! { | |
| 198 | - INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| { | |
| 199 | - let mut h = c.get(); | |
| 200 | - h[(side.trailing_zeros() as usize).saturating_sub(3).min(3)] += 1; | |
| 201 | - c.set(h); | |
| 202 | - }); | |
| 203 | - } | |
| 204 | 187 | return Ok((tx, Some(leaves))); |
| 205 | 188 | } |
| 206 | 189 | Ok((tx, None)) |
| @@ -261,6 +244,7 @@ pub(crate) fn rect_inter_residual_supported(w: usize, h: usize) -> bool { | ||
| 261 | 244 | // these triples are what decides whether those refusals can fire at all. Bit |
| 262 | 245 | // 31 is "a triple this table does not list", which is what makes the gate a |
| 263 | 246 | // census rather than a restatement of its own table. |
| 247 | +#[cfg(test)] | |
| 264 | 248 | pub(crate) const INTER_BLOCK_SHAPES: [(usize, usize, usize); 18] = [ |
| 265 | 249 | (16, 16, 16), |
| 266 | 250 | (32, 32, 32), |
| @@ -393,9 +377,6 @@ pub(super) fn rect_inter_chroma_set(w: usize, h: usize) -> Result<TxbSet> { | ||
| 393 | 377 | // (`av1_ss_size_lookup[BLOCK_8X32][1][0]`, common_data.c:38) and |
| 394 | 378 | // for which no TX_4X32 exists -- that chroma is coded as a |
| 395 | 379 | // TX_8X32-chunked merge, not a 4-px unit. |
| 396 | - if crate::envflags::env_flag!("EC_AV1_TRACE_422") { | |
| 397 | - eprintln!("EC_422 rect_inter_chroma_set missing (w,h)=({w},{h})"); | |
| 398 | - } | |
| 399 | 380 | return Err(unsupported( |
| 400 | 381 | "a rectangular inter chroma transform unit whose shape has no coefficient table set here", |
| 401 | 382 | )); |
| @@ -508,16 +489,6 @@ fn every_rect_transform_shape_the_census_lists_has_a_coefficient_table_and_scan( | ||
| 508 | 489 | // the shape domain and, on its own, named NONE of the strings that domain |
| 509 | 490 | // was about -- under a real function boundary rather than a window that |
| 510 | 491 | // ran into the next test, all three rows read as unanchored. |
| 511 | - for refusal in [ | |
| 512 | - "a rectangular inter luma transform unit whose shape has no coefficient table set here", | |
| 513 | - "a rectangular inter chroma transform unit whose shape has no coefficient table set here", | |
| 514 | - "a rectangular transform unit whose shape has no coefficient scan table here", | |
| 515 | - ] { | |
| 516 | - assert!( | |
| 517 | - crate::test_source::module_source("decode").contains(refusal), | |
| 518 | - "this gate proves {refusal:?}, but that string is no longer in decode.rs" | |
| 519 | - ); | |
| 520 | - } | |
| 521 | 492 | let fctx = &crate::decode::FrameCtx::new(); |
| 522 | 493 | let corner_scan = |w: usize, h: usize| { |
| 523 | 494 | let (cw, ch) = (w.min(32), h.min(32)); |
| @@ -684,7 +655,6 @@ pub(super) fn read_block_tx_size_rect( | ||
| 684 | 655 | // transform, and `set_txfm_ctxs` records exactly what |
| 685 | 656 | // `txfm_partition_update` would for that same unit. |
| 686 | 657 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); |
| 687 | - hit!(RECT_INTER_TU_HITS); | |
| 688 | 658 | return Ok(None); |
| 689 | 659 | } |
| 690 | 660 | // lane-av1oddheightfork2: `above_px` / `left_px` are the two |
| @@ -696,24 +666,10 @@ pub(super) fn read_block_tx_size_rect( | ||
| 696 | 666 | let (above_px, left_px) = (n.above_txfm[at_mi.1], n.left_txfm[at_mi.0]); |
| 697 | 667 | let ctx = txfm_partition_ctx_rect(above_px, left_px, bw.max(bh), tx_w, tx_h); |
| 698 | 668 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; |
| 699 | - hit!(TXFM_SPLIT_READS); | |
| 700 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 701 | - let (rng, _) = dec.debug_state(); | |
| 702 | - eprintln!( | |
| 703 | - "EC_ISTEP mi_row={} mi_col={} name=txfm_split_rect val={} ctx={ctx} above={above_px} left={left_px} maxblk={} tx={tx_w}x{tx_h} rng={rng}", | |
| 704 | - at_mi.0, | |
| 705 | - at_mi.1, | |
| 706 | - u8::from(split), | |
| 707 | - bw.max(bh), | |
| 708 | - ); | |
| 709 | - } | |
| 710 | 669 | if !split { |
| 711 | 670 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); |
| 712 | - hit!(RECT_INTER_TU_HITS); | |
| 713 | 671 | return Ok(None); |
| 714 | 672 | } |
| 715 | - hit!(TXFM_SPLIT_HITS); | |
| 716 | - hit!(RECT_INTER_TXSPLIT_HITS); | |
| 717 | 673 | // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays |
| 718 | 674 | // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`, |
| 719 | 675 | // `[TX_16X64] == TX_16X32` -- so the recursion below is the general |
| @@ -825,7 +781,6 @@ pub(super) fn read_inter_rect_chroma( | ||
| 825 | 781 | // replay (the c8 re-stamp, at the strip's own tiling). |
| 826 | 782 | let mut units: Vec<((usize, usize), usize, Grid, usize, usize)> = Vec::new(); |
| 827 | 783 | if multi { |
| 828 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 829 | 784 | assembled = [ |
| 830 | 785 | vec![0i32; chroma_side * assembled_h], |
| 831 | 786 | vec![0i32; chroma_side * assembled_h], |
| @@ -862,35 +817,8 @@ pub(super) fn read_inter_rect_chroma( | ||
| 862 | 817 | let cu_pred = src.offset(cu_row * uh * chroma_side + cu_col * uw); |
| 863 | 818 | let inherit_tx_type = |
| 864 | 819 | if let Some(t) = covering_leaf_tx_type(leaf_tx_types, unit_rel_mi) { |
| 865 | - hit!(CHROMA_RECT_LEAF_TX_HITS); | |
| 866 | - if Some(t) != Some(luma_tx_type) { | |
| 867 | - hit!(CHROMA_RECT_LEAF_TX_DIFF_HITS); | |
| 868 | - } | |
| 869 | 820 | Some(t) |
| 870 | 821 | } else { |
| 871 | - // lane-av1ichromatx: the ONE remaining site in | |
| 872 | - // `decode_inter_block` that can hand a chroma unit a | |
| 873 | - // BLOCK-level type on a split plane. `covering_leaf_tx_ | |
| 874 | - // type` found nothing, i.e. no luma leaf covers this | |
| 875 | - // unit's own MI cell -- which is exactly the shape a | |
| 876 | - // block that coded a SINGLE luma transform has (its | |
| 877 | - // leaf list is empty, so every lookup misses). For | |
| 878 | - // that block `luma_tx_type` IS the type of the one | |
| 879 | - // luma unit whose stamp covers the whole plane, so the | |
| 880 | - // fallback is correct there. | |
| 881 | - // | |
| 882 | - // What is NOT correct is a fallback on a plane with | |
| 883 | - // `leaves` NON-empty: then some luma leaf does exist, | |
| 884 | - // it simply does not cover this unit's cell, and the | |
| 885 | - // block-level value is a DIFFERENT leaf's type. The | |
| 886 | - // assertion below is what closes that shape, so the | |
| 887 | - // fallback can never again be a silent mistype: the | |
| 888 | - // class is "block-level where the unit's own cell | |
| 889 | - // says otherwise", and this is its last site. | |
| 890 | - hit!(CHROMA_RECT_BLOCK_TX_FALLBACK); | |
| 891 | - if multi { | |
| 892 | - hit!(CHROMA_RECT_BLOCK_TX_FALLBACK_MULTI); | |
| 893 | - } | |
| 894 | 822 | debug_assert!( |
| 895 | 823 | leaf_tx_types.is_empty(), |
| 896 | 824 | "lane-av1ichromatx: a multi-unit rect chroma plane fell back to the \ |
| @@ -921,9 +849,6 @@ pub(super) fn read_inter_rect_chroma( | ||
| 921 | 849 | fctx, |
| 922 | 850 | )? |
| 923 | 851 | .0; |
| 924 | - if invalid_ss_plane { | |
| 925 | - hit!(CHROMA422_CHUNK_HITS); | |
| 926 | - } | |
| 927 | 852 | if multi { |
| 928 | 853 | // Immediately, so the next unit of this block reads this |
| 929 | 854 | // one's coefficient context (libaom updates the chroma |
| @@ -985,8 +910,6 @@ pub(super) fn read_inter_plane_rect( | ||
| 985 | 910 | if plane_idx > 0 && mono(fctx) { |
| 986 | 911 | return Ok((Grid::Zero(w * h), TxType::DctDct)); |
| 987 | 912 | } |
| 988 | - // lane-av1readcensus: the units read from here on are this plane's. | |
| 989 | - set_census_plane(plane_idx); | |
| 990 | 913 | let skip_ctx = if plane_idx == 0 { |
| 991 | 914 | // `get_txb_ctx_general`: 0 only when this unit IS the whole plane |
| 992 | 915 | // block; a var-tx leaf passes its own neighbour-table context. |
| @@ -1030,18 +953,6 @@ pub(super) fn read_inter_plane_rect( | ||
| 1030 | 953 | // because `av1_nz_map_ctx_offset` is indexed by the real, un-adjusted |
| 1031 | 954 | // rectangular shape (lane-sbpart r8). |
| 1032 | 955 | let (cw, ch) = (w.min(32), h.min(32)); |
| 1033 | - if plane_idx == 0 && w.max(h) == 64 { | |
| 1034 | - hit!(RECT64_INTER_TU_HITS); | |
| 1035 | - } | |
| 1036 | - if plane_idx == 0 && (w, h) == (32, 8) || plane_idx == 0 && (w, h) == (8, 32) { | |
| 1037 | - hit_do! { | |
| 1038 | - RECT32X8_INTER_TU_HITS.with(|c| { | |
| 1039 | - let mut v = c.get(); | |
| 1040 | - v[usize::from(w == 8)] += 1; | |
| 1041 | - c.set(v); | |
| 1042 | - }); | |
| 1043 | - } | |
| 1044 | - } | |
| 1045 | 956 | let (corner, tx_type) = if (cw, ch) == (32, 32) { |
| 1046 | 957 | let scan32 = default_scan(TX32); |
| 1047 | 958 | read_coeffs( |
| @@ -1063,16 +974,10 @@ pub(super) fn read_inter_plane_rect( | ||
| 1063 | 974 | skip_ctx, |
| 1064 | 975 | dc_sign_ctx(around.2), |
| 1065 | 976 | default_tx_type, |
| 1066 | - plane_idx, | |
| 1067 | 977 | )? |
| 1068 | 978 | }; |
| 1069 | 979 | let grid = extend_corner(corner, cw, ch, w, h); |
| 1070 | 980 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx); |
| 1071 | - if crate::envflags::env_flag!("EC_TRACE_TXTYPE") { | |
| 1072 | - eprintln!( | |
| 1073 | - "OUR_TXTYPE plane={plane_idx} x={x} y={cy} w={w} h={h} tx_type={tx_type:?} inh={inherited_luma_tx_type:?}" | |
| 1074 | - ); | |
| 1075 | - } | |
| 1076 | 981 | // `reconstruct_mc_rect` reads both buffers at the square prediction |
| 1077 | 982 | // stride, so the dense `w x h` residual is re-laid at that stride |
| 1078 | 983 | // (`TxParams::stride`) after the inverse transform. |
| @@ -1716,6 +1621,5 @@ pub(super) fn edge_params_body( | ||
| 1716 | 1621 | [4, 8, 14, 14, 14][dim] |
| 1717 | 1622 | }; |
| 1718 | 1623 | let level = if cur_level != 0 { cur_level } else { pv_level }; |
| 1719 | - hit!(DEBLOCK_HITS); | |
| 1720 | 1624 | Some((len, level)) |
| 1721 | 1625 | } |
crates/ec-av1/src/decode/key_tile.rsmodified+6 -425
| @@ -97,22 +97,6 @@ pub(crate) fn decode_key_frame_tiles_lr( | ||
| 97 | 97 | .map(|(picture, _)| picture) |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | -/// lane-superres r3: the real decoded margin beyond `frame_width` up to | |
| 101 | -/// the mi-aligned `true_width`, set by the most recent | |
| 102 | -/// [`decode_key_frame_tile_with_cdfs`] OR (lane-superres r10) | |
| 103 | -/// [`decode_inter_frame_tile_with_cdfs`] call -- both frame kinds crop | |
| 104 | -/// their reconstructed buffer down from the same mi-aligned extent, so | |
| 105 | -/// they share this one slot. See each function's own comment at its | |
| 106 | -/// write site. `None` when there was no margin to save. | |
| 107 | -/// The margin the most recent key- or inter-frame tile decode stashed | |
| 108 | -/// (see [`LAST_FRAME_WIDE_MARGIN`]) -- `stream.rs`'s superres path | |
| 109 | -/// reads this immediately after the call, before any other frame | |
| 110 | -/// decode can overwrite it. | |
| 111 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 112 | -pub(crate) fn take_last_frame_wide_margin(fctx: &crate::decode::FrameCtx) -> Option<Picture> { | |
| 113 | - fctx.last_frame_wide_margin.with(|m| m.borrow_mut().take()) | |
| 114 | -} | |
| 115 | - | |
| 116 | 100 | /// [`decode_key_frame_tile`], threading a cross-frame CDF forward (spec |
| 117 | 101 | /// 7.20's `load_cdfs`): `initial_cdfs` is the caller's forwarded state (from |
| 118 | 102 | /// a prior frame's saved reference slot) when set, or the spec 8.4 defaults |
| @@ -252,38 +236,6 @@ thread_local! { | ||
| 252 | 236 | pub(crate) static SUB8_LOSSLESS_NO_VARTX: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 253 | 237 | } |
| 254 | 238 | |
| 255 | -/// [`MU_CHUNK_WALKS`], for a gate's own before/after delta. | |
| 256 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 257 | -pub(crate) fn mu_chunk_walks() -> usize { | |
| 258 | - MU_CHUNK_WALKS.with(std::cell::Cell::get) | |
| 259 | -} | |
| 260 | - | |
| 261 | -/// [`MU_CHUNK_WALK_UNITS`], for a gate's own before/after delta. | |
| 262 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 263 | -pub(crate) fn mu_chunk_walk_units() -> usize { | |
| 264 | - MU_CHUNK_WALK_UNITS.with(std::cell::Cell::get) | |
| 265 | -} | |
| 266 | - | |
| 267 | -/// [`LOSSLESS_EDGE_CLIPPED`] -- lossless blocks whose TX grid the frame-edge | |
| 268 | -/// clip shortened, for a gate's own before/after delta. | |
| 269 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 270 | -pub(crate) fn lossless_edge_clipped() -> usize { | |
| 271 | - LOSSLESS_EDGE_CLIPPED.with(std::cell::Cell::get) | |
| 272 | -} | |
| 273 | - | |
| 274 | -/// [`LOSSLESS_EDGE_CLIP_UNITS`] -- transform units the clip removed, i.e. the | |
| 275 | -/// ones the unclipped pre-fix walk read past the frame edge. | |
| 276 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 277 | -pub(crate) fn lossless_edge_clip_units() -> usize { | |
| 278 | - LOSSLESS_EDGE_CLIP_UNITS.with(std::cell::Cell::get) | |
| 279 | -} | |
| 280 | -/// [`SUB8_LOSSLESS_NO_VARTX`] -- sub-8 inter leaves on a lossless segment that | |
| 281 | -/// read no var-tx symbol, for a gate's own before/after delta. | |
| 282 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 283 | -pub(crate) fn sub8_lossless_no_vartx() -> usize { | |
| 284 | - SUB8_LOSSLESS_NO_VARTX.with(std::cell::Cell::get) | |
| 285 | -} | |
| 286 | - | |
| 287 | 239 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. |
| 288 | 240 | #[allow(clippy::too_many_arguments)] |
| 289 | 241 | pub(super) fn read_sb128_root( |
| @@ -328,26 +280,14 @@ pub(super) fn read_sb128_root( | ||
| 328 | 280 | let ctx128 = neighbours.partition_ctx(at128, 128); |
| 329 | 281 | let (has_cols128, has_rows128) = (mi_c128 + SB_MI < mi_cols, mi_r128 + SB_MI < mi_rows); |
| 330 | 282 | let part128 = if has_cols128 && has_rows128 { |
| 331 | - hit!(PART128_SYMBOLS); | |
| 332 | 283 | let p = dec.symbol(&mut cdfs.partition_w128[ctx128]); |
| 333 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 334 | - eprintln!("TRACE partition_w128 ctx={ctx128} value={p}"); | |
| 335 | - } | |
| 336 | 284 | p |
| 337 | 285 | } else { |
| 338 | - // lane-sb128 r4: the gathered half-out-of-frame reads DECIDE the | |
| 339 | - // partition, they are not a forced split -- exactly the discarded-bit | |
| 340 | - // defect the 64 root carries a comment about at `partition_w64`'s | |
| 341 | - // gathered arm. Value 1 is SPLIT; 0 is HORZ (rows out of frame) or | |
| 342 | - // VERT (cols out of frame), which the refusal below then names | |
| 343 | - // instead of silently reconstructing a split. | |
| 344 | - hit!(PART128_GATHERED_SYMBOLS); | |
| 345 | 286 | match (has_cols128, has_rows128) { |
| 346 | 287 | (true, false) => { |
| 347 | 288 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 { |
| 348 | 289 | PARTITION_SPLIT |
| 349 | 290 | } else { |
| 350 | - hit!(PART128_EDGE_HORZ_HITS); | |
| 351 | 291 | PARTITION_HORZ |
| 352 | 292 | } |
| 353 | 293 | } |
| @@ -355,13 +295,11 @@ pub(super) fn read_sb128_root( | ||
| 355 | 295 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 { |
| 356 | 296 | PARTITION_SPLIT |
| 357 | 297 | } else { |
| 358 | - hit!(PART128_EDGE_VERT_HITS); | |
| 359 | 298 | PARTITION_VERT |
| 360 | 299 | } |
| 361 | 300 | } |
| 362 | 301 | _ => { |
| 363 | 302 | PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() - 1)); |
| 364 | - bump_edge_both_cut(3); | |
| 365 | 303 | PARTITION_SPLIT |
| 366 | 304 | } |
| 367 | 305 | } |
| @@ -383,22 +321,10 @@ pub(super) fn read_sb128_root( | ||
| 383 | 321 | // decoding untouched. |
| 384 | 322 | refuse_invalid_subsize((128, 128), part128, fctx)?; |
| 385 | 323 | match part128 { |
| 386 | - PARTITION_SPLIT => hit!(PART128_SPLIT_HITS), | |
| 387 | - PARTITION_NONE => hit!(PART128_NONE_HITS), | |
| 388 | - PARTITION_HORZ => hit!(PART128_HORZ_HITS), | |
| 389 | - PARTITION_VERT => hit!(PART128_VERT_HITS), | |
| 390 | 324 | // lane-sb128c r9: the four AB shapes at the 128 root -- one |
| 391 | 325 | // 128x64/64x128 half plus two 64x64 quadrants, decoded by both tile |
| 392 | 326 | // paths below in libaom `decode_partition`'s own visit order. |
| 393 | - p if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&p) => { | |
| 394 | - hit_do! { | |
| 395 | - PART128_AB_HITS.with(|c| { | |
| 396 | - let mut h = c.get(); | |
| 397 | - h[p - PARTITION_HORZ_A] += 1; | |
| 398 | - c.set(h); | |
| 399 | - }); | |
| 400 | - } | |
| 401 | - } | |
| 327 | + p if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&p) => {} | |
| 402 | 328 | _ => { |
| 403 | 329 | return Err(unsupported( |
| 404 | 330 | "a 128x128 superblock partition value outside the 8-symbol alphabet", |
| @@ -484,13 +410,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 484 | 410 | let (width, height) = (cols32 as usize * BLOCK, rows32 as usize * BLOCK); |
| 485 | 411 | |
| 486 | 412 | let mut y = PlaneBuf { |
| 487 | - data: std::borrow::Cow::Owned(fresh_plane( | |
| 488 | - width * height, | |
| 489 | - true_width, | |
| 490 | - true_height, | |
| 491 | - width, | |
| 492 | - height, | |
| 493 | - )), | |
| 413 | + data: std::borrow::Cow::Owned(fresh_plane(width * height)), | |
| 494 | 414 | width, |
| 495 | 415 | height, |
| 496 | 416 | true_width, |
| @@ -502,10 +422,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 502 | 422 | plane: 0, |
| 503 | 423 | }; |
| 504 | 424 | let (cw, ch) = (width >> ss_x(fctx), height >> ss_y(fctx)); |
| 505 | - note_frame_chroma_alloc((width, height), (cw, ch), (ss_x(fctx), ss_y(fctx))); | |
| 506 | 425 | let (ctw, cth) = (true_width >> ss_x(fctx), true_height >> ss_y(fctx)); |
| 507 | 426 | let mut u = PlaneBuf { |
| 508 | - data: std::borrow::Cow::Owned(fresh_plane(cw * ch, ctw, cth, cw, ch)), | |
| 427 | + data: std::borrow::Cow::Owned(fresh_plane(cw * ch)), | |
| 509 | 428 | width: cw, |
| 510 | 429 | height: ch, |
| 511 | 430 | true_width: ctw, |
| @@ -517,7 +436,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 517 | 436 | plane: 1, |
| 518 | 437 | }; |
| 519 | 438 | let mut v = PlaneBuf { |
| 520 | - data: std::borrow::Cow::Owned(fresh_plane(cw * ch, ctw, cth, cw, ch)), | |
| 439 | + data: std::borrow::Cow::Owned(fresh_plane(cw * ch)), | |
| 521 | 440 | width: cw, |
| 522 | 441 | height: ch, |
| 523 | 442 | true_width: ctw, |
| @@ -603,18 +522,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 603 | 522 | fctx.current_q_idx.with(|c| c.set(i32::from(base_q_idx))); |
| 604 | 523 | fctx.quant_deltas.with(|c| c.set(deltas)); |
| 605 | 524 | fctx.current_delta_lf.with(|c| c.set([0; 4])); |
| 606 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 607 | - eprintln!( | |
| 608 | - "TRACE key_tile_bytes tile={tile_num} len={} first8={:02x?} base_q_idx={base_q_idx} mi_cols={mi_cols} mi_rows={mi_rows}", | |
| 609 | - tile_bytes.len(), | |
| 610 | - &tile_bytes[..tile_bytes.len().min(8)] | |
| 611 | - ); | |
| 612 | - } | |
| 613 | 525 | let mut dec = SymbolDecoder::new(tile_bytes); |
| 614 | 526 | // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets |
| 615 | 527 | // it codes every symbol against the tables it started with. |
| 616 | 528 | dec.set_cdf_update(!cdf_update_disabled(fctx)); |
| 617 | - crate::census::register_cdfs(&cdfs); | |
| 618 | 529 | neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize, fctx); |
| 619 | 530 | y.set_tile_origin( |
| 620 | 531 | mi_col0 as usize * 4, |
| @@ -634,7 +545,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 634 | 545 | ((mi_col1 as usize * 4) >> ss_x(fctx)).min(v.width), |
| 635 | 546 | ((mi_row1 as usize * 4) >> ss_y(fctx)).min(v.height), |
| 636 | 547 | ); |
| 637 | - hit!(TILE_HITS); | |
| 638 | 548 | |
| 639 | 549 | // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` -- |
| 640 | 550 | // its one block covers all four 64x64 quadrants, so the remaining three |
| @@ -965,28 +875,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 965 | 875 | // mirroring [`crate::tile::sb_coeff_key_frame_tile`]'s own |
| 966 | 876 | // three-way write exactly. |
| 967 | 877 | let part = if has_cols && has_rows { |
| 968 | - if crate::envflags::env_flag!("EC_TRACE") { | |
| 969 | - eprintln!( | |
| 970 | - "EC_PART mi_row={} mi_col={} bsize=12 ctx={} tell={} rng={}", | |
| 971 | - sb_r * SB_MI, | |
| 972 | - sb_c * SB_MI, | |
| 973 | - ctx, | |
| 974 | - dec.debug_bitpos(), | |
| 975 | - dec.debug_state().0 | |
| 976 | - ); | |
| 977 | - } | |
| 978 | 878 | let p = dec.symbol(&mut cdfs.partition_w64[ctx]); |
| 979 | - if crate::envflags::env_flag!("EC_TRACE") { | |
| 980 | - eprintln!( | |
| 981 | - "EC_PART_VAL mi_row={} mi_col={} bsize=12 value={}", | |
| 982 | - sb_r * SB_MI, | |
| 983 | - sb_c * SB_MI, | |
| 984 | - p | |
| 985 | - ); | |
| 986 | - } | |
| 987 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 988 | - eprintln!("TRACE partition_w64 ctx={ctx} value={p}"); | |
| 989 | - } | |
| 990 | 879 | p |
| 991 | 880 | } else { |
| 992 | 881 | // lane-hgkf r1 (class `parsed-then-discarded`, same finding as |
| @@ -998,16 +887,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 998 | 887 | // the first block of that row. |
| 999 | 888 | match (has_cols, has_rows) { |
| 1000 | 889 | (true, false) => { |
| 1001 | - trace_edge( | |
| 1002 | - (sb_r * SB_MI) as usize, | |
| 1003 | - (sb_c * SB_MI) as usize, | |
| 1004 | - 12, | |
| 1005 | - ctx, | |
| 1006 | - dec.debug_state().0, | |
| 1007 | - ); | |
| 1008 | 890 | let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)); |
| 1009 | - bump_edge32(4 + b.min(1)); | |
| 1010 | - bump_edge_part(b.min(1)); | |
| 1011 | 891 | if b == 1 { |
| 1012 | 892 | PARTITION_SPLIT |
| 1013 | 893 | } else { |
| @@ -1015,26 +895,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1015 | 895 | } |
| 1016 | 896 | } |
| 1017 | 897 | (false, true) => { |
| 1018 | - trace_edge( | |
| 1019 | - (sb_r * SB_MI) as usize, | |
| 1020 | - (sb_c * SB_MI) as usize, | |
| 1021 | - 12, | |
| 1022 | - ctx, | |
| 1023 | - dec.debug_state().0, | |
| 1024 | - ); | |
| 1025 | 898 | let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)); |
| 1026 | - bump_edge32(4 + b.min(1)); | |
| 1027 | - bump_edge_part(b.min(1)); | |
| 1028 | 899 | if b == 1 { |
| 1029 | 900 | PARTITION_SPLIT |
| 1030 | 901 | } else { |
| 1031 | 902 | PARTITION_VERT |
| 1032 | 903 | } |
| 1033 | 904 | } |
| 1034 | - _ => { | |
| 1035 | - bump_edge_both_cut(2); | |
| 1036 | - PARTITION_SPLIT | |
| 1037 | - } | |
| 905 | + _ => PARTITION_SPLIT, | |
| 1038 | 906 | } |
| 1039 | 907 | }; |
| 1040 | 908 | // lane-av1unwritten r5: the partition symbol is RESOLVED (a full CDF read or |
| @@ -1088,33 +956,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1088 | 956 | has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows), |
| 1089 | 957 | ); |
| 1090 | 958 | let part32 = if has_cols32 && has_rows32 { |
| 1091 | - if crate::envflags::env_flag!("EC_TRACE") { | |
| 1092 | - eprintln!( | |
| 1093 | - "EC_PART mi_row={} mi_col={} bsize=9 ctx={} tell={} rng={}", | |
| 1094 | - r32 * BLOCK_MI, | |
| 1095 | - c32 * BLOCK_MI, | |
| 1096 | - ctx32, | |
| 1097 | - dec.debug_bitpos(), | |
| 1098 | - dec.debug_state().0 | |
| 1099 | - ); | |
| 1100 | - } | |
| 1101 | 959 | let p = dec.symbol(&mut cdfs.partition_w32[ctx32]); |
| 1102 | - if crate::envflags::env_flag!("EC_TRACE") { | |
| 1103 | - eprintln!( | |
| 1104 | - "EC_PART_VAL mi_row={} mi_col={} bsize=9 value={}", | |
| 1105 | - r32 * BLOCK_MI, | |
| 1106 | - c32 * BLOCK_MI, | |
| 1107 | - p | |
| 1108 | - ); | |
| 1109 | - } | |
| 1110 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 1111 | - let (rng, _) = dec.debug_state(); | |
| 1112 | - eprintln!( | |
| 1113 | - "TRACE partition_w32 mi=({},{}) ctx={ctx32} value={p} rng={rng}", | |
| 1114 | - r32 * BLOCK_MI, | |
| 1115 | - c32 * BLOCK_MI | |
| 1116 | - ); | |
| 1117 | - } | |
| 1118 | 960 | p |
| 1119 | 961 | } else { |
| 1120 | 962 | // lane-hgkf r1: the 32-level frame-edge bit is the |
| @@ -1122,19 +964,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1122 | 964 | // superblock level above). |
| 1123 | 965 | match (has_cols32, has_rows32) { |
| 1124 | 966 | (true, false) => { |
| 1125 | - trace_edge( | |
| 1126 | - (r32 * BLOCK_MI) as usize, | |
| 1127 | - (c32 * BLOCK_MI) as usize, | |
| 1128 | - 9, | |
| 1129 | - ctx32, | |
| 1130 | - dec.debug_state().0, | |
| 1131 | - ); | |
| 1132 | 967 | let b = dec.symbol_fixed(&gather( |
| 1133 | 968 | &cdfs.partition_w32[ctx32], |
| 1134 | 969 | VERT_ALIKE, |
| 1135 | 970 | )); |
| 1136 | - bump_edge32(b.min(1)); | |
| 1137 | - bump_edge_part(2 + b.min(1)); | |
| 1138 | 971 | if b == 1 { |
| 1139 | 972 | PARTITION_SPLIT |
| 1140 | 973 | } else { |
| @@ -1142,29 +975,17 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1142 | 975 | } |
| 1143 | 976 | } |
| 1144 | 977 | (false, true) => { |
| 1145 | - trace_edge( | |
| 1146 | - (r32 * BLOCK_MI) as usize, | |
| 1147 | - (c32 * BLOCK_MI) as usize, | |
| 1148 | - 9, | |
| 1149 | - ctx32, | |
| 1150 | - dec.debug_state().0, | |
| 1151 | - ); | |
| 1152 | 978 | let b = dec.symbol_fixed(&gather( |
| 1153 | 979 | &cdfs.partition_w32[ctx32], |
| 1154 | 980 | HORZ_ALIKE, |
| 1155 | 981 | )); |
| 1156 | - bump_edge32(b.min(1)); | |
| 1157 | - bump_edge_part(2 + b.min(1)); | |
| 1158 | 982 | if b == 1 { |
| 1159 | 983 | PARTITION_SPLIT |
| 1160 | 984 | } else { |
| 1161 | 985 | PARTITION_VERT |
| 1162 | 986 | } |
| 1163 | 987 | } |
| 1164 | - _ => { | |
| 1165 | - bump_edge_both_cut(1); | |
| 1166 | - PARTITION_SPLIT | |
| 1167 | - } | |
| 988 | + _ => PARTITION_SPLIT, | |
| 1168 | 989 | } |
| 1169 | 990 | }; |
| 1170 | 991 | // lane-av1unwritten r4: VERT on a 32x32 block selects |
| @@ -1221,16 +1042,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1221 | 1042 | let at16 = (sr, sc); |
| 1222 | 1043 | let ctx16 = neighbours.partition_ctx(at16, SUB); |
| 1223 | 1044 | if has_cols16 && has_rows16 { |
| 1224 | - if crate::envflags::env_flag!("EC_TRACE") { | |
| 1225 | - eprintln!( | |
| 1226 | - "EC_PART mi_row={} mi_col={} bsize=6 ctx={} tell={} rng={}", | |
| 1227 | - sr * SUB_MI as usize, | |
| 1228 | - sc * SUB_MI as usize, | |
| 1229 | - ctx16, | |
| 1230 | - dec.debug_bitpos(), | |
| 1231 | - dec.debug_state().0 | |
| 1232 | - ); | |
| 1233 | - } | |
| 1234 | 1045 | let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]); |
| 1235 | 1046 | // lane-av1unwritten r6: the partition symbol is RESOLVED and about to be |
| 1236 | 1047 | // dispatched. `partition_subsize_dims` is libaom's `get_partition_subsize` |
| @@ -1240,21 +1051,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1240 | 1051 | // keep decoding because the helper is exact, not a heuristic. key-frame 16x16 level. |
| 1241 | 1052 | refuse_invalid_subsize((16, 16), part16, fctx)?; |
| 1242 | 1053 | |
| 1243 | - if crate::envflags::env_flag!("EC_TRACE") { | |
| 1244 | - eprintln!( | |
| 1245 | - "EC_PART_VAL mi_row={} mi_col={} bsize=6 value={}", | |
| 1246 | - sr * SUB_MI as usize, | |
| 1247 | - sc * SUB_MI as usize, | |
| 1248 | - part16 | |
| 1249 | - ); | |
| 1250 | - } | |
| 1251 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 1252 | - eprintln!( | |
| 1253 | - "TRACE partition_w16 mi=({},{}) ctx={ctx16} value={part16}", | |
| 1254 | - sr * SUB_MI as usize, | |
| 1255 | - sc * SUB_MI as usize | |
| 1256 | - ); | |
| 1257 | - } | |
| 1258 | 1054 | if part16 == PARTITION_HORZ || part16 == PARTITION_VERT |
| 1259 | 1055 | { |
| 1260 | 1056 | let (bw, bh) = if part16 == PARTITION_HORZ { |
| @@ -1326,11 +1122,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1326 | 1122 | // rectangle: libaom switches those squares onto `has_tr_vert_*`/ |
| 1327 | 1123 | // `has_bl_vert_*` (`reconintra.c` `get_has_tr_table`), which is |
| 1328 | 1124 | // `Reach::vert_ab_partition()` (lane-part32 r5, cherry-picked here). |
| 1329 | - let arm = part16 - PARTITION_HORZ_A; | |
| 1330 | - bump_ab16(arm); | |
| 1331 | - if part16 == PARTITION_VERT_B { | |
| 1332 | - hit!(VERT_B_INTRA_HITS); | |
| 1333 | - } | |
| 1334 | 1125 | let _vert_guard = if part16 == PARTITION_VERT_A |
| 1335 | 1126 | || part16 == PARTITION_VERT_B |
| 1336 | 1127 | { |
| @@ -1353,7 +1144,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1353 | 1144 | &mut y, |
| 1354 | 1145 | &mut u, |
| 1355 | 1146 | &mut v, |
| 1356 | - base_q_idx, | |
| 1357 | 1147 | enable_filter_intra, |
| 1358 | 1148 | allow_screen_content_tools, |
| 1359 | 1149 | allow_intrabc, |
| @@ -1449,7 +1239,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1449 | 1239 | continue; |
| 1450 | 1240 | } |
| 1451 | 1241 | if part16 == PARTITION_HORZ { |
| 1452 | - hit!(HORZ_VERT_INTRA_HITS); | |
| 1453 | 1242 | let (mi_row0, mi_col0) = |
| 1454 | 1243 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 1455 | 1244 | let top = (mi_row0 as usize, mi_col0 as usize); |
| @@ -1497,7 +1286,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1497 | 1286 | continue; |
| 1498 | 1287 | } |
| 1499 | 1288 | if part16 == PARTITION_VERT { |
| 1500 | - hit!(HORZ_VERT_INTRA_HITS); | |
| 1501 | 1289 | let (mi_row0, mi_col0) = |
| 1502 | 1290 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 1503 | 1291 | let left = (mi_row0 as usize, mi_col0 as usize); |
| @@ -1550,15 +1338,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1550 | 1338 | { |
| 1551 | 1339 | // lane-av1unwritten r6: arm census -- |
| 1552 | 1340 | // which partition values reach here. |
| 1553 | - note_subsize_arm( | |
| 1554 | - part16, | |
| 1555 | - chroma_plane_block_codable( | |
| 1556 | - partition_subsize_dims((16, 16), part16).0, | |
| 1557 | - partition_subsize_dims((16, 16), part16).1, | |
| 1558 | - ss_x(fctx), | |
| 1559 | - ss_y(fctx), | |
| 1560 | - ), | |
| 1561 | - ); | |
| 1562 | 1341 | decode_rect4_16( |
| 1563 | 1342 | &mut dec, |
| 1564 | 1343 | &mut cdfs, |
| @@ -1631,16 +1410,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1631 | 1410 | } |
| 1632 | 1411 | let leaf_ctx = |
| 1633 | 1412 | neighbours.partition_ctx_mi(leaf_mi, 8); |
| 1634 | - if crate::envflags::env_flag!("EC_TRACE") { | |
| 1635 | - eprintln!( | |
| 1636 | - "EC_PART mi_row={} mi_col={} bsize=3 ctx={} tell={} rng={}", | |
| 1637 | - leaf_mi.0, | |
| 1638 | - leaf_mi.1, | |
| 1639 | - leaf_ctx, | |
| 1640 | - dec.debug_bitpos(), | |
| 1641 | - dec.debug_state().0 | |
| 1642 | - ); | |
| 1643 | - } | |
| 1644 | 1413 | let part8 = |
| 1645 | 1414 | dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| 1646 | 1415 | // lane-av1unwritten r9: the |
| @@ -1649,17 +1418,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1649 | 1418 | // r9 made sensitive to a second |
| 1650 | 1419 | // site at an already covered level. |
| 1651 | 1420 | refuse_invalid_subsize((8, 8), part8, fctx)?; |
| 1652 | - if crate::envflags::env_flag!("EC_TRACE") { | |
| 1653 | - eprintln!( | |
| 1654 | - "EC_PART_VAL mi_row={} mi_col={} bsize=3 value={}", | |
| 1655 | - leaf_mi.0, leaf_mi.1, part8 | |
| 1656 | - ); | |
| 1657 | - } | |
| 1658 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 1659 | - eprintln!( | |
| 1660 | - "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}" | |
| 1661 | - ); | |
| 1662 | - } | |
| 1663 | 1421 | if part8 == PARTITION_HORZ |
| 1664 | 1422 | || part8 == PARTITION_VERT |
| 1665 | 1423 | { |
| @@ -1693,7 +1451,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1693 | 1451 | &mut y, |
| 1694 | 1452 | &mut u, |
| 1695 | 1453 | &mut v, |
| 1696 | - base_q_idx, | |
| 1697 | 1454 | enable_filter_intra, |
| 1698 | 1455 | allow_screen_content_tools, |
| 1699 | 1456 | allow_intrabc, |
| @@ -1714,7 +1471,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1714 | 1471 | &mut y, |
| 1715 | 1472 | &mut u, |
| 1716 | 1473 | &mut v, |
| 1717 | - base_q_idx, | |
| 1718 | 1474 | enable_filter_intra, |
| 1719 | 1475 | allow_intrabc, |
| 1720 | 1476 | reduced_tx_set, |
| @@ -1734,7 +1490,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1734 | 1490 | &mut y, |
| 1735 | 1491 | &mut u, |
| 1736 | 1492 | &mut v, |
| 1737 | - base_q_idx, | |
| 1738 | 1493 | enable_filter_intra, |
| 1739 | 1494 | allow_intrabc, |
| 1740 | 1495 | tx_select, |
| @@ -1783,7 +1538,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1783 | 1538 | // quadrants get no neighbour or tx-grid |
| 1784 | 1539 | // write. |
| 1785 | 1540 | if !has_cols16 && !has_rows16 { |
| 1786 | - bump_edge_both_cut(0); | |
| 1787 | 1541 | } else { |
| 1788 | 1542 | // lane-golomb r1 (class |
| 1789 | 1543 | // `parsed-then-discarded`): the gathered |
| @@ -1793,13 +1547,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1793 | 1547 | // This path can only walk the four SPLIT |
| 1794 | 1548 | // leaves, so a 0 refuses by name instead |
| 1795 | 1549 | // of desyncing. |
| 1796 | - trace_edge( | |
| 1797 | - sr * SUB_MI as usize, | |
| 1798 | - sc * SUB_MI as usize, | |
| 1799 | - 6, | |
| 1800 | - ctx16, | |
| 1801 | - dec.debug_state().0, | |
| 1802 | - ); | |
| 1803 | 1550 | let edge_split = if has_cols16 { |
| 1804 | 1551 | dec.symbol_fixed(&gather( |
| 1805 | 1552 | &cdfs.partition_w16[ctx16], |
| @@ -1814,21 +1561,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1814 | 1561 | // lane-hgkf r1: slots 2/3 of |
| 1815 | 1562 | // [`EDGE_PART_HITS`], the gate's proof the |
| 1816 | 1563 | // non-SPLIT edge arm actually decoded. |
| 1817 | - bump_edge_part(if edge_split == 1 { 3 } else { 2 }); | |
| 1818 | 1564 | if edge_split == 0 { |
| 1819 | - // lane-oddh r1: the strip IS decodable | |
| 1820 | - // -- libaom's `decode_partition` codes | |
| 1821 | - // only the FIRST half of an edge | |
| 1822 | - // HORZ/VERT (the second call is | |
| 1823 | - // guarded by the same has_rows/ | |
| 1824 | - // has_cols test that made the | |
| 1825 | - // partition non-square), so one | |
| 1826 | - // 16x8 (resp. 8x16) strip covers the | |
| 1827 | - // whole visible band of a frame whose | |
| 1828 | - // height (resp. width) is 8 mod 16 -- | |
| 1829 | - // the user's 3840x1608 film. | |
| 1830 | - hit!(HORZ_VERT_INTRA_HITS); | |
| 1831 | - hit!(EDGE_RECT_STRIP_HITS); | |
| 1832 | 1565 | // lane-av1subsizesweep: this arm is the ONE |
| 1833 | 1566 | // frame-edge partition read in the file that |
| 1834 | 1567 | // dispatches on its own symbol instead of |
| @@ -1867,17 +1600,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1867 | 1600 | refuse_invalid_subsize((16, 16), edge_part, fctx)?; |
| 1868 | 1601 | // lane-av1unwritten r6: arm census -- which |
| 1869 | 1602 | // partition value reaches here. |
| 1870 | - note_subsize_arm( | |
| 1871 | - edge_part, | |
| 1872 | - chroma_plane_block_codable( | |
| 1873 | - partition_subsize_dims((16, 16), edge_part) | |
| 1874 | - .0, | |
| 1875 | - partition_subsize_dims((16, 16), edge_part) | |
| 1876 | - .1, | |
| 1877 | - ss_x(fctx), | |
| 1878 | - ss_y(fctx), | |
| 1879 | - ), | |
| 1880 | - ); | |
| 1881 | 1603 | let (mi_row0, mi_col0) = |
| 1882 | 1604 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 1883 | 1605 | let (bw, bh) = |
| @@ -1934,7 +1656,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1934 | 1656 | neighbours.left_mode[sr] = right; |
| 1935 | 1657 | } |
| 1936 | 1658 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); |
| 1937 | - let pre8 = dec.debug_state().0; | |
| 1938 | 1659 | let part8 = |
| 1939 | 1660 | dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| 1940 | 1661 | // lane-av1unwritten r9: key-frame 8x8 |
| @@ -1948,11 +1669,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1948 | 1669 | // than live pixels, and it is guarded |
| 1949 | 1670 | // anyway. |
| 1950 | 1671 | refuse_invalid_subsize((8, 8), part8, fctx)?; |
| 1951 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 1952 | - eprintln!( | |
| 1953 | - "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8} pre_rng={pre8}" | |
| 1954 | - ); | |
| 1955 | - } | |
| 1956 | 1672 | let leaf_mode = if part8 == PARTITION_NONE { |
| 1957 | 1673 | decode_leaf8( |
| 1958 | 1674 | &mut dec, |
| @@ -1965,7 +1681,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1965 | 1681 | &mut y, |
| 1966 | 1682 | &mut u, |
| 1967 | 1683 | &mut v, |
| 1968 | - base_q_idx, | |
| 1969 | 1684 | enable_filter_intra, |
| 1970 | 1685 | allow_screen_content_tools, |
| 1971 | 1686 | allow_intrabc, |
| @@ -1986,7 +1701,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 1986 | 1701 | &mut y, |
| 1987 | 1702 | &mut u, |
| 1988 | 1703 | &mut v, |
| 1989 | - base_q_idx, | |
| 1990 | 1704 | enable_filter_intra, |
| 1991 | 1705 | allow_intrabc, |
| 1992 | 1706 | reduced_tx_set, |
| @@ -2006,7 +1720,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2006 | 1720 | &mut y, |
| 2007 | 1721 | &mut u, |
| 2008 | 1722 | &mut v, |
| 2009 | - base_q_idx, | |
| 2010 | 1723 | enable_filter_intra, |
| 2011 | 1724 | allow_intrabc, |
| 2012 | 1725 | tx_select, |
| @@ -2059,9 +1772,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2059 | 1772 | reduced_tx_set, |
| 2060 | 1773 | fctx, |
| 2061 | 1774 | )?; |
| 2062 | - if !has_rows32 { | |
| 2063 | - bump_edge32(2); | |
| 2064 | - } | |
| 2065 | 1775 | // lane-hgkf r1: at the frame edge only the first half of the strip is |
| 2066 | 1776 | // coded (libaom `decode_partition` guards the second half with the same |
| 2067 | 1777 | // test that made this partition non-square). |
| @@ -2105,9 +1815,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2105 | 1815 | reduced_tx_set, |
| 2106 | 1816 | fctx, |
| 2107 | 1817 | )?; |
| 2108 | - if !has_cols32 { | |
| 2109 | - bump_edge32(3); | |
| 2110 | - } | |
| 2111 | 1818 | // lane-hgkf r1: at the frame edge only the first half of the strip is |
| 2112 | 1819 | // coded (libaom `decode_partition` guards the second half with the same |
| 2113 | 1820 | // test that made this partition non-square). |
| @@ -2132,11 +1839,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2132 | 1839 | } |
| 2133 | 1840 | } |
| 2134 | 1841 | PARTITION_HORZ_A => { |
| 2135 | - // lane-part32 r1: two 16x16 squares on top + | |
| 2136 | - // a true 32x16 strip below (mirrors | |
| 2137 | - // decode_inter_block's cd6cb6d HORZ_A: TL, | |
| 2138 | - // TR, bottom strip). | |
| 2139 | - hit!(INTRA_HORZ_A_HITS); | |
| 2140 | 1842 | decode_block( |
| 2141 | 1843 | &mut dec, |
| 2142 | 1844 | &mut cdfs, |
| @@ -2210,11 +1912,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2210 | 1912 | )?; |
| 2211 | 1913 | } |
| 2212 | 1914 | PARTITION_HORZ_B => { |
| 2213 | - // lane-part32 r1: a true 32x16 strip on top + | |
| 2214 | - // two 16x16 squares below (mirrors HORZ_A | |
| 2215 | - // with the strip/squares order flipped, same | |
| 2216 | - // shape as libaom decode_partition's HORZ_B). | |
| 2217 | - hit!(INTRA_HORZ_B_HITS); | |
| 2218 | 1915 | decode_block_rect( |
| 2219 | 1916 | &mut dec, |
| 2220 | 1917 | &mut cdfs, |
| @@ -2288,10 +1985,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2288 | 1985 | )?; |
| 2289 | 1986 | } |
| 2290 | 1987 | PARTITION_VERT_A => { |
| 2291 | - // lane-part32 r1: mirror of HORZ_A with | |
| 2292 | - // width/height swapped (TL, BL, right 16x32 | |
| 2293 | - // strip). | |
| 2294 | - hit!(INTRA_VERT_A_HITS); | |
| 2295 | 1988 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 2296 | 1989 | decode_block( |
| 2297 | 1990 | &mut dec, |
| @@ -2366,11 +2059,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2366 | 2059 | )?; |
| 2367 | 2060 | } |
| 2368 | 2061 | PARTITION_VERT_B => { |
| 2369 | - // lane-part32 r1: a true 16x32 strip on the | |
| 2370 | - // left + two 16x16 squares on the right | |
| 2371 | - // (libaom decode_partition VERT_B: left | |
| 2372 | - // strip, TR, BR). | |
| 2373 | - hit!(INTRA_VERT_B_HITS); | |
| 2374 | 2062 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 2375 | 2063 | decode_block_rect( |
| 2376 | 2064 | &mut dec, |
| @@ -2513,9 +2201,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2513 | 2201 | reduced_tx_set, |
| 2514 | 2202 | fctx, |
| 2515 | 2203 | )?; |
| 2516 | - if !has_rows { | |
| 2517 | - bump_edge32(6); | |
| 2518 | - } | |
| 2519 | 2204 | // lane-golomb r1: at the frame edge only the first half of the |
| 2520 | 2205 | // strip is coded (libaom `decode_partition` guards the second |
| 2521 | 2206 | // with the same has_rows test that made this partition non-square). |
| @@ -2559,9 +2244,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2559 | 2244 | reduced_tx_set, |
| 2560 | 2245 | fctx, |
| 2561 | 2246 | )?; |
| 2562 | - if !has_cols { | |
| 2563 | - bump_edge32(7); | |
| 2564 | - } | |
| 2565 | 2247 | // lane-golomb r1: at the frame edge only the first half of the |
| 2566 | 2248 | // strip is coded (libaom `decode_partition` guards the second |
| 2567 | 2249 | // with the same has_cols test that made this partition non-square). |
| @@ -2586,21 +2268,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2586 | 2268 | } |
| 2587 | 2269 | } |
| 2588 | 2270 | PARTITION_HORZ_A | PARTITION_HORZ_B | PARTITION_VERT_A | PARTITION_VERT_B => { |
| 2589 | - // lane-part32 r4: the four superblock-level AB arms, each | |
| 2590 | - // two 32x32 squares plus one 64x32/32x64 strip, in | |
| 2591 | - // libaom's own `decode_partition` order (decodeframe.c: | |
| 2592 | - // HORZ_A = TL, TR, bottom strip; HORZ_B = top strip, BL, | |
| 2593 | - // BR; VERT_A = TL, BL, right strip; VERT_B = left strip, | |
| 2594 | - // TR, BR). The pieces are exactly the ones already proven | |
| 2595 | - // by the `PARTITION_NONE`-under-SPLIT (32x32 square) and | |
| 2596 | - // `PARTITION_HORZ`/`VERT` (rect64 strip) arms above. | |
| 2597 | - hit_do! { | |
| 2598 | - SB_AB_HITS.with(|c| { | |
| 2599 | - let mut h = c.get(); | |
| 2600 | - h[part - PARTITION_HORZ_A] += 1; | |
| 2601 | - c.set(h); | |
| 2602 | - }); | |
| 2603 | - } | |
| 2604 | 2271 | // lane-part32 r5: only the two VERTICAL arms reorder the |
| 2605 | 2272 | // square sub-blocks (TL, BL, TR, BR), so only they switch |
| 2606 | 2273 | // libaom's `has_tr`/`has_bl` tables. |
| @@ -2750,48 +2417,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2750 | 2417 | } |
| 2751 | 2418 | crate::timeline::recon_done(); |
| 2752 | 2419 | |
| 2753 | - // lane-comppin r4: pre-loop-filter decode-order dump, matching aomdec's | |
| 2754 | - // own EC_AV1_PREFILT_DUMP shape (decodeframe.c ~5451) -- diffs against | |
| 2755 | - // that isolate whether a decode-order frame's mismatch already exists | |
| 2756 | - // in reconstruction (this dump) vs is introduced by the loop filter | |
| 2757 | - // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). | |
| 2758 | - // Decode-order frame marker for the EC_OBMC / EC_TRACE_MODE ladders. | |
| 2759 | - if crate::envflags::env_flag!("EC_OBMC") | |
| 2760 | - || crate::envflags::env_flag!("EC_TRACE_MODE") | |
| 2761 | - || crate::envflags::env_flag!("EC_PRED") | |
| 2762 | - { | |
| 2763 | - eprintln!( | |
| 2764 | - "EC_PICT idx={}", | |
| 2765 | - PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) | |
| 2766 | - ); | |
| 2767 | - } | |
| 2768 | - dump_stage16( | |
| 2769 | - "EC_AV1_PREFILT_DUMP16", | |
| 2770 | - &y, | |
| 2771 | - &u, | |
| 2772 | - &v, | |
| 2773 | - frame_width as usize, | |
| 2774 | - frame_height as usize, | |
| 2775 | - ss_x(fctx), | |
| 2776 | - ss_y(fctx), | |
| 2777 | - ); | |
| 2778 | - census_unwritten(&y, &u, &v); | |
| 2779 | - if let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_DUMP") { | |
| 2780 | - // lane-av1dumploud: loud on a short write (three discarded | |
| 2781 | - // `write_all` results before). Expected length = the three planes' own | |
| 2782 | - // data lengths: this dump is the PADDED plane, not a crop, so the | |
| 2783 | - // writer's extent is `p.data` itself. | |
| 2784 | - let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | |
| 2785 | - let narrow = |p: &PlaneBuf<'_>| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() }; | |
| 2786 | - crate::dumpio::write_planes( | |
| 2787 | - "EC_AV1_PREFILT_DUMP", | |
| 2788 | - format!("{path}.f{idx}"), | |
| 2789 | - &[&narrow(&y), &narrow(&u), &narrow(&v)], | |
| 2790 | - ); | |
| 2791 | - } else { | |
| 2792 | - PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | |
| 2793 | - } | |
| 2794 | - dump_prefilter_wide(&y, &u, &v); | |
| 2795 | 2420 | // lane-av1fwd: the encoder's filter search re-decodes this same key |
| 2796 | 2421 | // frame tile per candidate -- capture it once (see [`FilterReplay`]), |
| 2797 | 2422 | // on the shape whose tail is the two filter calls and nothing else. |
| @@ -2848,42 +2473,16 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 2848 | 2473 | plane_snapshot(&v, ss_y(fctx) as u32), |
| 2849 | 2474 | ) |
| 2850 | 2475 | }); |
| 2851 | - // lane-tiny r4: post-deblock / post-CDEF dumps mirroring aomdec's own | |
| 2852 | - // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter | |
| 2853 | - // dump above these bisect WHICH filter stage introduced a mismatch. | |
| 2854 | - dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); | |
| 2855 | - dump_stage16( | |
| 2856 | - "EC_AV1_POSTDEBLOCK_DUMP16", | |
| 2857 | - &y, | |
| 2858 | - &u, | |
| 2859 | - &v, | |
| 2860 | - frame_width as usize, | |
| 2861 | - frame_height as usize, | |
| 2862 | - ss_x(fctx), | |
| 2863 | - ss_y(fctx), | |
| 2864 | - ); | |
| 2865 | 2476 | apply_cdef( |
| 2866 | 2477 | &mut y, |
| 2867 | 2478 | &mut u, |
| 2868 | 2479 | &mut v, |
| 2869 | 2480 | cdef, |
| 2870 | 2481 | &neighbours, |
| 2871 | - (frame_width as usize, frame_height as usize), | |
| 2872 | 2482 | fctx, |
| 2873 | 2483 | None, |
| 2874 | 2484 | None, |
| 2875 | 2485 | ); |
| 2876 | - dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); | |
| 2877 | - dump_stage16( | |
| 2878 | - "EC_AV1_POSTCDEF_DUMP16", | |
| 2879 | - &y, | |
| 2880 | - &u, | |
| 2881 | - &v, | |
| 2882 | - frame_width as usize, | |
| 2883 | - frame_height as usize, | |
| 2884 | - ss_x(fctx), | |
| 2885 | - ss_y(fctx), | |
| 2886 | - ); | |
| 2887 | 2486 | capture_stages(&y, &u, &v, deblocked.as_ref(), fctx); |
| 2888 | 2487 | // spec 7.16 (libaom `superres_post_decode`, decodeframe.c: called |
| 2889 | 2488 | // between `av1_cdef_frame` and `av1_loop_restoration_filter_frame`): |
| @@ -3009,24 +2608,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 3009 | 2608 | fctx.last_frame_wide_margin.with(|m| { |
| 3010 | 2609 | *m.borrow_mut() = if true_width > fw || true_height > fh { |
| 3011 | 2610 | let yc = crop(&y, true_width, true_height); |
| 3012 | - if let Ok(path) = crate::envflags::var("EC_AV1_MARGIN_DUMP") { | |
| 3013 | - static IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | |
| 3014 | - let idx = IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | |
| 3015 | - // corner-cut: this diagnostic dump stays 8-bit-narrowed | |
| 3016 | - // regardless of the stream's real bit depth (debug-only, | |
| 3017 | - // never read by a gate); widen if a >8-bit margin dump | |
| 3018 | - // is ever needed. | |
| 3019 | - // | |
| 3020 | - // lane-av1dumploud: loud on a short write. Expected length is | |
| 3021 | - // `true_width * true_height` -- the crop this dump is exactly, | |
| 3022 | - // not a re-derived geometry. | |
| 3023 | - let narrow: Vec<u8> = yc.iter().map(|&s| s as u8).collect(); | |
| 3024 | - crate::dumpio::write_planes( | |
| 3025 | - "EC_AV1_MARGIN_DUMP", | |
| 3026 | - format!("{path}.f{idx}"), | |
| 3027 | - &[&narrow], | |
| 3028 | - ); | |
| 3029 | - } | |
| 3030 | 2611 | Some(Picture { |
| 3031 | 2612 | width: true_width, |
| 3032 | 2613 | height: true_height, |
crates/ec-av1/src/decode/leaf8.rsmodified+8 -238
| @@ -122,9 +122,6 @@ pub(super) fn decode_block_128rect( | ||
| 122 | 122 | uv_mode |
| 123 | 123 | }; |
| 124 | 124 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 125 | - if smooth_neighbor { | |
| 126 | - hit!(SMOOTH_LUMA_HITS); | |
| 127 | - } | |
| 128 | 125 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx); |
| 129 | 126 | // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or |
| 130 | 127 | // not. `bsize_to_tx_size_cat(BLOCK_128X64)` is 3 (see this fn's doc). |
| @@ -143,25 +140,12 @@ pub(super) fn decode_block_128rect( | ||
| 143 | 140 | // lane-inter128intra r1: `get_tx_size_context` compares the bands |
| 144 | 141 | // against `tx_size_wide/high[max_txsize_rect_lookup[bsize]]` -- |
| 145 | 142 | // TX_64X64 for every 128-axis block, hence the `min(64)`. |
| 146 | - let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw.min(64), bh.min(64), fctx); | |
| 143 | + let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw.min(64), bh.min(64)); | |
| 147 | 144 | dec.symbol(&mut cdfs.tx_size_cat3[ctx]) |
| 148 | 145 | } else { |
| 149 | 146 | 0 |
| 150 | 147 | }; |
| 151 | - if depth != 0 { | |
| 152 | - hit!(TX_DEPTH_HITS); | |
| 153 | - } | |
| 154 | - hit_do! { | |
| 155 | - INTRA_SB128_DEPTH_HITS.with(|c| { | |
| 156 | - let mut h = c.get(); | |
| 157 | - h[depth.min(2)] += 1; | |
| 158 | - c.set(h); | |
| 159 | - }); | |
| 160 | - } | |
| 161 | 148 | let logical_tx = if lossless_frame { 4 } else { 64 >> depth }; |
| 162 | - if lossless_frame { | |
| 163 | - hit!(INTRA128_LOSSLESS_HITS); | |
| 164 | - } | |
| 165 | 149 | // A 64-point transform codes nothing past its low 32 coefficients. |
| 166 | 150 | let coeff_tx_side = logical_tx.min(32); |
| 167 | 151 | let luma_set = if lossless_frame { |
| @@ -239,11 +223,6 @@ pub(super) fn decode_block_128rect( | ||
| 239 | 223 | tu_row * logical_tx, |
| 240 | 224 | logical_tx, |
| 241 | 225 | reach, |
| 242 | - px, | |
| 243 | - py, | |
| 244 | - y.width, | |
| 245 | - y.height, | |
| 246 | - fctx, | |
| 247 | 226 | ); |
| 248 | 227 | if skip { |
| 249 | 228 | push_intra( |
| @@ -288,7 +267,6 @@ pub(super) fn decode_block_128rect( | ||
| 288 | 267 | tu_py, |
| 289 | 268 | logical_tx, |
| 290 | 269 | coeff_tx_side, |
| 291 | - base_q_idx, | |
| 292 | 270 | None, |
| 293 | 271 | None, |
| 294 | 272 | Some(tu_skip_ctx), |
| @@ -341,11 +319,6 @@ pub(super) fn decode_block_128rect( | ||
| 341 | 319 | luma_span, |
| 342 | 320 | luma_span_h, |
| 343 | 321 | reach, |
| 344 | - px, | |
| 345 | - py, | |
| 346 | - y.width, | |
| 347 | - y.height, | |
| 348 | - fctx, | |
| 349 | 322 | ); |
| 350 | 323 | if skip { |
| 351 | 324 | push_intra( |
| @@ -402,7 +375,6 @@ pub(super) fn decode_block_128rect( | ||
| 402 | 375 | cu_y, |
| 403 | 376 | chroma_tx, |
| 404 | 377 | chroma_tx, |
| 405 | - base_q_idx, | |
| 406 | 378 | None, |
| 407 | 379 | None, |
| 408 | 380 | Some(3), |
| @@ -425,9 +397,6 @@ pub(super) fn decode_block_128rect( | ||
| 425 | 397 | } |
| 426 | 398 | } |
| 427 | 399 | } |
| 428 | - if !skip { | |
| 429 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 430 | - } | |
| 431 | 400 | } |
| 432 | 401 | } |
| 433 | 402 | if skip { |
| @@ -467,12 +436,8 @@ pub(super) fn decode_block_128rect( | ||
| 467 | 436 | // byte-exact against ffmpeg) -- that is the replay's own designed |
| 468 | 437 | // 4:2:2 case, not a defect signature. Nothing here asserts the |
| 469 | 438 | // mismatch is zero. |
| 470 | - if luma_span != luma_span_h { | |
| 471 | - hit!(SB128RECT_REPLAY_SPAN_MISMATCH_HITS); | |
| 472 | - } | |
| 473 | 439 | for (plane, cu_mi, grid) in &units { |
| 474 | 440 | neighbours.record_mi_chroma(*cu_mi, luma_span, luma_span_h, *plane, grid); |
| 475 | - hit!(SB128RECT_CHROMA_REPLAY_HITS); | |
| 476 | 441 | } |
| 477 | 442 | } |
| 478 | 443 | // No palette exists at this size; the unconditional stamp clears any |
| @@ -499,19 +464,6 @@ pub(super) fn decode_block_128rect( | ||
| 499 | 464 | // stamps here too -- lane-av1-intrabc r3. |
| 500 | 465 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (logical_tx, logical_tx), (bw, bh)); |
| 501 | 466 | } |
| 502 | - if in_inter { | |
| 503 | - hit_do! { | |
| 504 | - INTRA128_IN_INTER_HITS.with(|c| { | |
| 505 | - let mut h = c.get(); | |
| 506 | - h[usize::from(bw < bh)] += 1; | |
| 507 | - c.set(h); | |
| 508 | - }); | |
| 509 | - } | |
| 510 | - } else if bw > bh { | |
| 511 | - hit!(INTRA_SB128_HORZ_HITS); | |
| 512 | - } else { | |
| 513 | - hit!(INTRA_SB128_VERT_HITS); | |
| 514 | - } | |
| 515 | 467 | Ok(()) |
| 516 | 468 | } |
| 517 | 469 | |
| @@ -563,7 +515,6 @@ pub(super) fn decode_leaf8( | ||
| 563 | 515 | y: &mut PlaneBuf<'static>, |
| 564 | 516 | u: &mut PlaneBuf<'static>, |
| 565 | 517 | v: &mut PlaneBuf<'static>, |
| 566 | - base_q_idx: u8, | |
| 567 | 518 | enable_filter_intra: bool, |
| 568 | 519 | allow_screen_content_tools: bool, |
| 569 | 520 | allow_intrabc: bool, |
| @@ -603,9 +554,6 @@ pub(super) fn decode_leaf8( | ||
| 603 | 554 | // with the coarse [`SUB`] slot as the fallback when no block recorded |
| 604 | 555 | // that exact mi cell. |
| 605 | 556 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c, fctx); |
| 606 | - if smooth_neighbor { | |
| 607 | - hit!(SMOOTH_LUMA_HITS); | |
| 608 | - } | |
| 609 | 557 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec |
| 610 | 558 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other |
| 611 | 559 | // `decode_block` caller at 16x16 and up. |
| @@ -654,9 +602,6 @@ pub(super) fn decode_leaf8( | ||
| 654 | 602 | // next symbol (class `wrong-alphabet-same-value`). Everything below |
| 655 | 603 | // mirrors `decode_block`'s own intrabc handling at 16x16 and up. |
| 656 | 604 | let intrabc_dv = fctx.intrabc_dv.with(|c| c.take()); |
| 657 | - if intrabc_dv.is_some() { | |
| 658 | - hit!(LEAF8_INTRABC_HITS); | |
| 659 | - } | |
| 660 | 605 | // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour |
| 661 | 606 | // index map, mapped through the base colours, IS the block's prediction -- |
| 662 | 607 | // carried to the next `reconstruct`/`read_plane` through the same |
| @@ -676,9 +621,6 @@ pub(super) fn decode_leaf8( | ||
| 676 | 621 | let (pal_uv_size, pal_uv_colors) = palette_uv |
| 677 | 622 | .as_ref() |
| 678 | 623 | .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 679 | - if palette_y.is_some() || palette_uv.is_some() { | |
| 680 | - hit!(PALETTE_LEAF8_HITS); | |
| 681 | - } | |
| 682 | 624 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 683 | 625 | DC_PRED |
| 684 | 626 | } else { |
| @@ -722,7 +664,6 @@ pub(super) fn decode_leaf8( | ||
| 722 | 664 | 0, |
| 723 | 665 | &mut leaves, |
| 724 | 666 | ); |
| 725 | - hit!(INTRABC_VARTX_HITS); | |
| 726 | 667 | leaves.first().map_or(8, |l| l.2) |
| 727 | 668 | } else if tx_select && intrabc_dv.is_none() { |
| 728 | 669 | read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, fctx) |
| @@ -846,26 +787,13 @@ pub(super) fn decode_leaf8( | ||
| 846 | 787 | // rule) -- so a palette leaf takes the single 8x8 reconstruct below |
| 847 | 788 | // even when `tx_depth` resolved to TX_4X4. |
| 848 | 789 | if resolved == 4 && palette_y_buf.is_none() { |
| 849 | - hit!(SKIP_SPLIT_TX_HITS); | |
| 850 | 790 | for tu_row in 0..2 { |
| 851 | 791 | for tu_col in 0..2 { |
| 852 | 792 | let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4); |
| 853 | 793 | if tu_px >= y.true_width || tu_py >= y.true_height { |
| 854 | 794 | continue; |
| 855 | 795 | } |
| 856 | - let tu_reach = tu_reach( | |
| 857 | - 8, | |
| 858 | - 8, | |
| 859 | - tu_col * 4, | |
| 860 | - tu_row * 4, | |
| 861 | - 4, | |
| 862 | - reach, | |
| 863 | - px, | |
| 864 | - py, | |
| 865 | - y.width, | |
| 866 | - y.height, | |
| 867 | - fctx, | |
| 868 | - ); | |
| 796 | + let tu_reach = tu_reach(8, 8, tu_col * 4, tu_row * 4, 4, reach); | |
| 869 | 797 | push_intra( |
| 870 | 798 | y, |
| 871 | 799 | u, |
| @@ -989,19 +917,7 @@ pub(super) fn decode_leaf8( | ||
| 989 | 917 | if chroma_units_ll { |
| 990 | 918 | for cu_row in 0..cu_shape.1 / 4 { |
| 991 | 919 | for cu_col in 0..cu_shape.0 / 4 { |
| 992 | - let cu_reach = tu_reach( | |
| 993 | - 8, | |
| 994 | - 8, | |
| 995 | - cu_col * 4, | |
| 996 | - cu_row * 4, | |
| 997 | - 4, | |
| 998 | - reach, | |
| 999 | - px, | |
| 1000 | - py, | |
| 1001 | - y.width, | |
| 1002 | - y.height, | |
| 1003 | - fctx, | |
| 1004 | - ); | |
| 920 | + let cu_reach = tu_reach(8, 8, cu_col * 4, cu_row * 4, 4, reach); | |
| 1005 | 921 | push_intra( |
| 1006 | 922 | y, |
| 1007 | 923 | u, |
| @@ -1048,19 +964,7 @@ pub(super) fn decode_leaf8( | ||
| 1048 | 964 | for (buf, plane) in [(ub, 1usize), (vb, 2usize)] { |
| 1049 | 965 | if let Some(buf) = buf { |
| 1050 | 966 | for cu_row in 0..2 { |
| 1051 | - let cu_reach = tu_reach( | |
| 1052 | - 8, | |
| 1053 | - 8, | |
| 1054 | - 0, | |
| 1055 | - cu_row * 4, | |
| 1056 | - 4, | |
| 1057 | - reach, | |
| 1058 | - px, | |
| 1059 | - py, | |
| 1060 | - y.width, | |
| 1061 | - y.height, | |
| 1062 | - fctx, | |
| 1063 | - ); | |
| 967 | + let cu_reach = tu_reach(8, 8, 0, cu_row * 4, 4, reach); | |
| 1064 | 968 | set_palette_pred( |
| 1065 | 969 | palette_window(&buf, cw, 0, cu_row * 4, 4, 4), |
| 1066 | 970 | fctx, |
| @@ -1113,19 +1017,7 @@ pub(super) fn decode_leaf8( | ||
| 1113 | 1017 | if chroma_units_ll { |
| 1114 | 1018 | for cu_row in 0..cu_shape.1 / 4 { |
| 1115 | 1019 | for cu_col in 0..cu_shape.0 / 4 { |
| 1116 | - let cu_reach = tu_reach( | |
| 1117 | - 8, | |
| 1118 | - 8, | |
| 1119 | - cu_col * 4, | |
| 1120 | - cu_row * 4, | |
| 1121 | - 4, | |
| 1122 | - reach, | |
| 1123 | - px, | |
| 1124 | - py, | |
| 1125 | - y.width, | |
| 1126 | - y.height, | |
| 1127 | - fctx, | |
| 1128 | - ); | |
| 1020 | + let cu_reach = tu_reach(8, 8, cu_col * 4, cu_row * 4, 4, reach); | |
| 1129 | 1021 | push_intra( |
| 1130 | 1022 | y, |
| 1131 | 1023 | u, |
| @@ -1158,19 +1050,7 @@ pub(super) fn decode_leaf8( | ||
| 1158 | 1050 | .or_else(|| palette_uv_bufs.as_ref().map(|(_, vb)| vb.clone())); |
| 1159 | 1051 | if let Some(vb) = vb { |
| 1160 | 1052 | for cu_row in 0..2 { |
| 1161 | - let cu_reach = tu_reach( | |
| 1162 | - 8, | |
| 1163 | - 8, | |
| 1164 | - 0, | |
| 1165 | - cu_row * 4, | |
| 1166 | - 4, | |
| 1167 | - reach, | |
| 1168 | - px, | |
| 1169 | - py, | |
| 1170 | - y.width, | |
| 1171 | - y.height, | |
| 1172 | - fctx, | |
| 1173 | - ); | |
| 1053 | + let cu_reach = tu_reach(8, 8, 0, cu_row * 4, 4, reach); | |
| 1174 | 1054 | set_palette_pred(palette_window(&vb, cw, 0, cu_row * 4, 4, 4), fctx); |
| 1175 | 1055 | push_intra( |
| 1176 | 1056 | y, |
| @@ -1257,7 +1137,6 @@ pub(super) fn decode_leaf8( | ||
| 1257 | 1137 | py, |
| 1258 | 1138 | 8, |
| 1259 | 1139 | TX8, |
| 1260 | - base_q_idx, | |
| 1261 | 1140 | None, |
| 1262 | 1141 | filter_intra, |
| 1263 | 1142 | None, |
| @@ -1344,7 +1223,6 @@ pub(super) fn decode_leaf8( | ||
| 1344 | 1223 | cpy, |
| 1345 | 1224 | csz, |
| 1346 | 1225 | csz, |
| 1347 | - base_q_idx, | |
| 1348 | 1226 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1349 | 1227 | None, |
| 1350 | 1228 | None, |
| @@ -1374,7 +1252,6 @@ pub(super) fn decode_leaf8( | ||
| 1374 | 1252 | cpy, |
| 1375 | 1253 | csz, |
| 1376 | 1254 | csz, |
| 1377 | - base_q_idx, | |
| 1378 | 1255 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1379 | 1256 | None, |
| 1380 | 1257 | None, |
| @@ -1400,29 +1277,13 @@ pub(super) fn decode_leaf8( | ||
| 1400 | 1277 | let tu_px = px + tu_col * 4; |
| 1401 | 1278 | let tu_py = py + tu_row * 4; |
| 1402 | 1279 | let tu_around = neighbours.around_mi(tu_mi, 4)[0]; |
| 1403 | - if crate::encode::Reach::in_vert_ab() { | |
| 1404 | - hit!(VERT_AB_TX4_HITS); | |
| 1405 | - } | |
| 1406 | - let tu_reach = tu_reach( | |
| 1407 | - 8, | |
| 1408 | - 8, | |
| 1409 | - tu_col * 4, | |
| 1410 | - tu_row * 4, | |
| 1411 | - 4, | |
| 1412 | - reach, | |
| 1413 | - px, | |
| 1414 | - py, | |
| 1415 | - y.width, | |
| 1416 | - y.height, | |
| 1417 | - fctx, | |
| 1418 | - ); | |
| 1280 | + let tu_reach = tu_reach(8, 8, tu_col * 4, tu_row * 4, 4, reach); | |
| 1419 | 1281 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); |
| 1420 | 1282 | // Each 4x4 unit predicts from its own window of the block's |
| 1421 | 1283 | // 8x8 colour-index map ([`decode_block`]'s per-TU slice at |
| 1422 | 1284 | // 16x16 and up) -- the whole-block buffer would be taken by |
| 1423 | 1285 | // the FIRST unit and indexed at the wrong stride. |
| 1424 | 1286 | if let Some(buf) = &palette_y_buf { |
| 1425 | - hit!(PALETTE_SPLIT_TX_HITS); | |
| 1426 | 1287 | let mut window = vec![0u16; 16]; |
| 1427 | 1288 | for row in 0..4 { |
| 1428 | 1289 | let src = (tu_row * 4 + row) * 8 + tu_col * 4; |
| @@ -1454,21 +1315,12 @@ pub(super) fn decode_leaf8( | ||
| 1454 | 1315 | tu_py, |
| 1455 | 1316 | 4, |
| 1456 | 1317 | 4, |
| 1457 | - base_q_idx, | |
| 1458 | 1318 | None, |
| 1459 | 1319 | filter_intra, |
| 1460 | 1320 | Some(tu_skip_ctx), |
| 1461 | 1321 | smooth_neighbor, |
| 1462 | 1322 | fctx, |
| 1463 | 1323 | )?; |
| 1464 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 1465 | - eprintln!( | |
| 1466 | - "TRACE tu_bitpos mi=({},{}) tell={}", | |
| 1467 | - tu_mi.0, | |
| 1468 | - tu_mi.1, | |
| 1469 | - dec.debug_bitpos() | |
| 1470 | - ); | |
| 1471 | - } | |
| 1472 | 1324 | neighbours.record_mi_luma(tu_mi, 4, &tu_grid); |
| 1473 | 1325 | // The FIRST (top-left, co-located with this group's chroma) |
| 1474 | 1326 | // TU's coded tx_type is what the group's chroma inherits -- |
| @@ -1505,9 +1357,6 @@ pub(super) fn decode_leaf8( | ||
| 1505 | 1357 | // lane-av1intrapred: the non-vacuity counter -- armed slot consulted |
| 1506 | 1358 | // by this arm's chroma reads means the frame-copy + inherited-type |
| 1507 | 1359 | // route ran; zero at gate time means the fixture stopped reaching it. |
| 1508 | - if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { | |
| 1509 | - hit!(INTRABC_TX4_CHROMA_COPY_HITS); | |
| 1510 | - } | |
| 1511 | 1360 | if chroma_422 && !lossless(fctx) { |
| 1512 | 1361 | // lane-av1-422d: the chroma unit does NOT follow the luma var-tx |
| 1513 | 1362 | // split -- `uv_txsize` is `av1_get_max_uv_txsize` of the block, |
| @@ -1601,7 +1450,6 @@ pub(super) fn decode_leaf8( | ||
| 1601 | 1450 | cdfs, |
| 1602 | 1451 | neighbours, |
| 1603 | 1452 | leaf_mi, |
| 1604 | - (px, py), | |
| 1605 | 1453 | (cpx, cpy), |
| 1606 | 1454 | 8, |
| 1607 | 1455 | (blk_w, blk_h), |
| @@ -1609,13 +1457,11 @@ pub(super) fn decode_leaf8( | ||
| 1609 | 1457 | (blk_w, blk_h), |
| 1610 | 1458 | blk_w, |
| 1611 | 1459 | reach, |
| 1612 | - (y.width, y.height), | |
| 1613 | 1460 | mode, |
| 1614 | 1461 | uv_predict_mode, |
| 1615 | 1462 | angle_delta_uv, |
| 1616 | 1463 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), |
| 1617 | 1464 | smooth_neighbor_uv, |
| 1618 | - base_q_idx, | |
| 1619 | 1465 | &mut uo, |
| 1620 | 1466 | &mut vo, |
| 1621 | 1467 | fctx, |
| @@ -1630,7 +1476,6 @@ pub(super) fn decode_leaf8( | ||
| 1630 | 1476 | } else { |
| 1631 | 1477 | Grid::Own(vo) |
| 1632 | 1478 | }; |
| 1633 | - hit!(CHROMA422_LOSSLESS_4X4_HITS); | |
| 1634 | 1479 | } else if chroma_444 && lossless(fctx) { |
| 1635 | 1480 | // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster |
| 1636 | 1481 | // of TX_4X4 units per plane, PLANE-MAJOR (`av1_get_tx_size`: |
| @@ -1651,7 +1496,6 @@ pub(super) fn decode_leaf8( | ||
| 1651 | 1496 | cdfs, |
| 1652 | 1497 | neighbours, |
| 1653 | 1498 | leaf_mi, |
| 1654 | - (px, py), | |
| 1655 | 1499 | (cpx, cpy), |
| 1656 | 1500 | 8, |
| 1657 | 1501 | (8, 8), |
| @@ -1659,13 +1503,11 @@ pub(super) fn decode_leaf8( | ||
| 1659 | 1503 | (8, 8), |
| 1660 | 1504 | 8, |
| 1661 | 1505 | reach, |
| 1662 | - (y.width, y.height), | |
| 1663 | 1506 | mode, |
| 1664 | 1507 | uv_predict_mode, |
| 1665 | 1508 | angle_delta_uv, |
| 1666 | 1509 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), |
| 1667 | 1510 | smooth_neighbor_uv, |
| 1668 | - base_q_idx, | |
| 1669 | 1511 | &mut uo, |
| 1670 | 1512 | &mut vo, |
| 1671 | 1513 | fctx, |
| @@ -1702,7 +1544,6 @@ pub(super) fn decode_leaf8( | ||
| 1702 | 1544 | cpy, |
| 1703 | 1545 | csz, |
| 1704 | 1546 | csz, |
| 1705 | - base_q_idx, | |
| 1706 | 1547 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1707 | 1548 | None, |
| 1708 | 1549 | None, |
| @@ -1730,7 +1571,6 @@ pub(super) fn decode_leaf8( | ||
| 1730 | 1571 | cpy, |
| 1731 | 1572 | csz, |
| 1732 | 1573 | csz, |
| 1733 | - base_q_idx, | |
| 1734 | 1574 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1735 | 1575 | None, |
| 1736 | 1576 | None, |
| @@ -1809,7 +1649,6 @@ pub(super) fn decode_leaf8( | ||
| 1809 | 1649 | neighbours.record_palette_y_rect(leaf_mi, 8, 8, pal_y_size, pal_y_colors); |
| 1810 | 1650 | neighbours.record_palette_uv_rect(leaf_mi, 8, 8, pal_uv_size, pal_uv_colors); |
| 1811 | 1651 | } |
| 1812 | - hit!(INTER8_SKIP_BAND_HITS); | |
| 1813 | 1652 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 1814 | 1653 | // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal |
| 1815 | 1654 | // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm && |
| @@ -1924,7 +1763,6 @@ pub(super) fn leaf8_chroma422_unit( | ||
| 1924 | 1763 | usize::from(around.0) + usize::from(around.1), |
| 1925 | 1764 | dc_sign_ctx(around.2), |
| 1926 | 1765 | default_tx, |
| 1927 | - plane_idx, | |
| 1928 | 1766 | )?; |
| 1929 | 1767 | let residual = dequant_and_inverse_typed_wh( |
| 1930 | 1768 | &levels, |
| @@ -2001,28 +1839,10 @@ pub(super) fn read_intra_mode_sub8( | ||
| 2001 | 1839 | // lane-av1mono: a monochrome leaf codes no chroma mode (libaom |
| 2002 | 1840 | // `decodemv.c:933`), so fold `NumPlanes == 1` into `has_chroma`. |
| 2003 | 1841 | let has_chroma = has_chroma && !mono(fctx); |
| 2004 | - let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); | |
| 2005 | - let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); | |
| 2006 | - crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64); | |
| 2007 | - if ec_istep { | |
| 2008 | - eprintln!( | |
| 2009 | - "EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sub8 rng={}", | |
| 2010 | - dec.debug_state().0 | |
| 2011 | - ); | |
| 2012 | - } | |
| 2013 | 1842 | // Same `EC_ISTEP` ladder the square/rect readers print, so a cross-decoder |
| 2014 | 1843 | // range diff lands on the ELEMENT inside a 4x4 leaf, not just the block. |
| 2015 | 1844 | macro_rules! istep { |
| 2016 | - ($name:literal, $val:expr) => { | |
| 2017 | - if ec_istep { | |
| 2018 | - eprintln!( | |
| 2019 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name={} val={} rng={}", | |
| 2020 | - $name, | |
| 2021 | - $val, | |
| 2022 | - dec.debug_state().0 | |
| 2023 | - ); | |
| 2024 | - } | |
| 2025 | - }; | |
| 1845 | + ($name:literal, $val:expr) => {}; | |
| 2026 | 1846 | } |
| 2027 | 1847 | // lane-seg2: same `intra_segment_id` placement as the square and rect |
| 2028 | 1848 | // readers (spec 5.11.6) -- a `BLOCK_4X4` leaf codes its own `segment_id` |
| @@ -2034,13 +1854,6 @@ pub(super) fn read_intra_mode_sub8( | ||
| 2034 | 1854 | intra_segment_id(dec, cdfs, mi_r, mi_c, seg_w_mi, seg_h_mi, false, fctx); |
| 2035 | 1855 | } |
| 2036 | 1856 | let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0; |
| 2037 | - if trace { | |
| 2038 | - eprintln!( | |
| 2039 | - "TRACE sub8 skip mi=({mi_r},{mi_c}) ctx={skip_ctx} value={} rng={}", | |
| 2040 | - skip as i32, | |
| 2041 | - dec.debug_state().0 | |
| 2042 | - ); | |
| 2043 | - } | |
| 2044 | 1857 | istep!("skip", skip as i32); |
| 2045 | 1858 | if !seg_id_pre_skip(fctx) { |
| 2046 | 1859 | intra_segment_id(dec, cdfs, mi_r, mi_c, seg_w_mi, seg_h_mi, skip, fctx); |
| @@ -2052,13 +1865,6 @@ pub(super) fn read_intra_mode_sub8( | ||
| 2052 | 1865 | istep!("dq", 0); |
| 2053 | 1866 | if allow_intrabc { |
| 2054 | 1867 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; |
| 2055 | - if ec_istep { | |
| 2056 | - eprintln!( | |
| 2057 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=intrabc val={} rng={}", | |
| 2058 | - u8::from(use_intrabc), | |
| 2059 | - dec.debug_state().0 | |
| 2060 | - ); | |
| 2061 | - } | |
| 2062 | 1868 | if use_intrabc { |
| 2063 | 1869 | // lane-av1txr: `read_intrabc_info` (spec 5.11.13) reads the block |
| 2064 | 1870 | // vector right after the flag and RETURNS -- no y/uv mode, angle |
| @@ -2067,15 +1873,6 @@ pub(super) fn read_intra_mode_sub8( | ||
| 2067 | 1873 | // `is_inter_block` counts an intrabc block), so the caller takes |
| 2068 | 1874 | // the frame-copy prediction + inter residual. |
| 2069 | 1875 | let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (seg_w_mi, seg_h_mi), fctx); |
| 2070 | - // lane-av1txr: the DV travels back in the RETURN value -- it is | |
| 2071 | - // NOT published through `FrameCtx::intrabc_dv`. That slot is the | |
| 2072 | - // SQUARE paths' handoff (`decode_block`/`decode_leaf8` arm it, | |
| 2073 | - // then `take()` it in the same call), so a sub-8x8 leaf that | |
| 2074 | - // armed it left the vector standing for the NEXT >=8x8 block: | |
| 2075 | - // `warped.obu`'s (38,60) 8x8 intra block took it as its own | |
| 2076 | - // intrabc and read an inter var-tx `txfm_split` where libaom read | |
| 2077 | - // an intra `tx_depth` (class `stale-slot-handoff`). | |
| 2078 | - hit!(INTRABC_HITS); | |
| 2079 | 1876 | return Ok((skip, DC_PRED, 0, None, None, Some(dv))); |
| 2080 | 1877 | } |
| 2081 | 1878 | } |
| @@ -2083,12 +1880,6 @@ pub(super) fn read_intra_mode_sub8( | ||
| 2083 | 1880 | let left_ctx = INTRA_MODE_CTX[left_mode]; |
| 2084 | 1881 | let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]); |
| 2085 | 1882 | istep!("mode", mode); |
| 2086 | - if trace { | |
| 2087 | - eprintln!( | |
| 2088 | - "TRACE sub8 y_mode mi=({mi_r},{mi_c}) ctx=({above_ctx},{left_ctx}) value={mode} rng={}", | |
| 2089 | - dec.debug_state().0 | |
| 2090 | - ); | |
| 2091 | - } | |
| 2092 | 1883 | // No `angle_delta` at all below 8x8: spec 5.11.6's `intra_angle_info_y`/ |
| 2093 | 1884 | // `_uv` are gated on `MiSize >= BLOCK_8X8` (libaom `av1_use_angle_delta`, |
| 2094 | 1885 | // blockd.h), so a directional mode on a `BLOCK_4X4` leaf carries no delta |
| @@ -2107,29 +1898,15 @@ pub(super) fn read_intra_mode_sub8( | ||
| 2107 | 1898 | // divergence at the rect leaf mi (8,16) of `ll444.obu`; class |
| 2108 | 1899 | // `wrong-alphabet-same-value`, lane-av1-llsub8). |
| 2109 | 1900 | let uv_mode = if cfl_allowed_px(seg_w_mi * MI, seg_h_mi * MI, fctx) { |
| 2110 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 2111 | 1901 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 2112 | 1902 | } else { |
| 2113 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 2114 | 1903 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 2115 | 1904 | }; |
| 2116 | - if trace { | |
| 2117 | - eprintln!( | |
| 2118 | - "TRACE sub8 uv_mode value={uv_mode} rng={}", | |
| 2119 | - dec.debug_state().0 | |
| 2120 | - ); | |
| 2121 | - } | |
| 2122 | - if (9..=12).contains(&uv_mode) { | |
| 2123 | - hit!(SMOOTH_UV_HITS); | |
| 2124 | - } | |
| 2125 | 1905 | let alpha = if uv_mode == UV_CFL_PRED { |
| 2126 | 1906 | Some(read_cfl_alphas(dec, cdfs)) |
| 2127 | 1907 | } else { |
| 2128 | 1908 | None |
| 2129 | 1909 | }; |
| 2130 | - if (V_PRED..=D67_PRED).contains(&uv_mode) { | |
| 2131 | - hit!(DIRECTIONAL_UV_HITS); | |
| 2132 | - } | |
| 2133 | 1910 | // See the luma comment above: no angle delta below 8x8. |
| 2134 | 1911 | let angle_delta_uv = 0; |
| 2135 | 1912 | Some((uv_mode, angle_delta_uv, alpha)) |
| @@ -2139,14 +1916,7 @@ pub(super) fn read_intra_mode_sub8( | ||
| 2139 | 1916 | let mut filter_intra = None; |
| 2140 | 1917 | if mode == DC_PRED && enable_filter_intra { |
| 2141 | 1918 | let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[fi_class]) != 0; |
| 2142 | - if trace { | |
| 2143 | - eprintln!( | |
| 2144 | - "TRACE sub8 use_filter_intra value={}", | |
| 2145 | - use_filter_intra as i32 | |
| 2146 | - ); | |
| 2147 | - } | |
| 2148 | 1919 | if use_filter_intra { |
| 2149 | - hit!(FILTER_INTRA_HITS); | |
| 2150 | 1920 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 2151 | 1921 | filter_intra = Some(fi_mode); |
| 2152 | 1922 | } |
crates/ec-av1/src/decode/leaf_sub8.rsmodified+3 -157
| @@ -35,7 +35,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 35 | 35 | u: &mut PlaneBuf<'static>, |
| 36 | 36 | v: &mut PlaneBuf<'static>, |
| 37 | 37 | scan4: &[u16], |
| 38 | - base_q_idx: u8, | |
| 39 | 38 | smooth_neighbor_uv: bool, |
| 40 | 39 | fctx: &crate::decode::FrameCtx, |
| 41 | 40 | ) -> Result<(Grid, Grid, usize, usize)> { |
| @@ -94,7 +93,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 94 | 93 | &mut vb, |
| 95 | 94 | fctx, |
| 96 | 95 | ); |
| 97 | - hit!(SKIPPED_INTRABC_DV_COPY_HITS); | |
| 98 | 96 | let zeros = &ZERO_RESIDUAL[..bw * bh]; |
| 99 | 97 | if square { |
| 100 | 98 | set_palette_pred(ub, fctx); |
| @@ -173,10 +171,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 173 | 171 | fctx, |
| 174 | 172 | ); |
| 175 | 173 | } |
| 176 | - // The same arm-without-clear route the 4:2:0 tails count: a skipped | |
| 177 | - // leaf reads no coefficient, so the inherited chroma `tx_type` is | |
| 178 | - // dropped unconsumed. | |
| 179 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | |
| 180 | 174 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 181 | 175 | (Grid::Zero(bw * bh), Grid::Zero(bw * bh), 4, 4) |
| 182 | 176 | } else if skip { |
| @@ -257,7 +251,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 257 | 251 | // The same arm-without-clear route the 4:2:0 tails count: a skipped |
| 258 | 252 | // leaf reads no coefficient, so an armed intrabc slot is dropped. |
| 259 | 253 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { |
| 260 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | |
| 261 | 254 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 262 | 255 | } |
| 263 | 256 | (Grid::Zero(bw * bh), Grid::Zero(bw * bh), 4, 4) |
| @@ -313,7 +306,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 313 | 306 | py, |
| 314 | 307 | 4, |
| 315 | 308 | TX4, |
| 316 | - base_q_idx, | |
| 317 | 309 | None, |
| 318 | 310 | None, |
| 319 | 311 | None, |
| @@ -339,7 +331,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 339 | 331 | py, |
| 340 | 332 | 4, |
| 341 | 333 | TX4, |
| 342 | - base_q_idx, | |
| 343 | 334 | None, |
| 344 | 335 | None, |
| 345 | 336 | None, |
| @@ -350,9 +341,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 350 | 341 | } else { |
| 351 | 342 | // lane-av1-ibc444rect: the unskipped lossless chroma walk this |
| 352 | 343 | // lane fixes (one rect unit -> per-4x4 Chroma4 units). |
| 353 | - if lossless(fctx) { | |
| 354 | - hit!(INTRABC_RECT8_LOSSLESS_CHROMA_HITS); | |
| 355 | - } | |
| 356 | 344 | if lossless(fctx) { |
| 357 | 345 | // lane-av1-ibc444rect: at lossless `read_tx_size` forces |
| 358 | 346 | // TX_4X4 on EVERY plane (`av1_get_tx_size`'s lossless |
| @@ -406,11 +394,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 406 | 394 | // 4:2:2 twin of this arm was fixed the same way |
| 407 | 395 | // (lane-av1-422kf2); this is its 4:4:4 twin. |
| 408 | 396 | let unit_reach = Reach::of_tu(bw, bh, uc * 4, ur * 4, 4, 4, reach); |
| 409 | - if !square | |
| 410 | - && unit_reach != Reach::of(4, upx, upy, y.width, y.height, fctx) | |
| 411 | - { | |
| 412 | - hit!(SUB8_CHROMA444_LOSSLESS_TU_REACH_HITS); | |
| 413 | - } | |
| 414 | 397 | let grid = read_plane( |
| 415 | 398 | dec, |
| 416 | 399 | cdfs, |
| @@ -429,7 +412,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 429 | 412 | upy, |
| 430 | 413 | 4, |
| 431 | 414 | TX4, |
| 432 | - base_q_idx, | |
| 433 | 415 | None, |
| 434 | 416 | None, |
| 435 | 417 | Some(3), |
| @@ -478,7 +460,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 478 | 460 | skip_ctx, |
| 479 | 461 | dc_sign_ctx(around[plane_idx].2), |
| 480 | 462 | default_tx, |
| 481 | - plane_idx, | |
| 482 | 463 | )?; |
| 483 | 464 | let residual = dequant_and_inverse_typed_wh( |
| 484 | 465 | &levels, |
| @@ -543,7 +524,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 543 | 524 | py, |
| 544 | 525 | 4, |
| 545 | 526 | TX4, |
| 546 | - base_q_idx, | |
| 547 | 527 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 548 | 528 | None, |
| 549 | 529 | None, |
| @@ -568,7 +548,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 568 | 548 | py, |
| 569 | 549 | 4, |
| 570 | 550 | TX4, |
| 571 | - base_q_idx, | |
| 572 | 551 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 573 | 552 | None, |
| 574 | 553 | None, |
| @@ -605,10 +584,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 605 | 584 | // position -- see the intrabc twin above for the |
| 606 | 585 | // libaom citation and the measured damage. |
| 607 | 586 | let unit_reach = Reach::of_tu(bw, bh, uc * 4, ur * 4, 4, 4, reach); |
| 608 | - if !square && unit_reach != Reach::of(4, upx, upy, y.width, y.height, fctx) | |
| 609 | - { | |
| 610 | - hit!(SUB8_CHROMA444_LOSSLESS_TU_REACH_HITS); | |
| 611 | - } | |
| 612 | 587 | let grid = read_plane( |
| 613 | 588 | dec, |
| 614 | 589 | cdfs, |
| @@ -627,7 +602,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 627 | 602 | upy, |
| 628 | 603 | 4, |
| 629 | 604 | TX4, |
| 630 | - base_q_idx, | |
| 631 | 605 | None, |
| 632 | 606 | None, |
| 633 | 607 | Some(3), |
| @@ -677,7 +651,6 @@ pub(super) fn sub8_leaf_chroma444( | ||
| 677 | 651 | skip_ctx, |
| 678 | 652 | dc_sign_ctx(around[plane_idx].2), |
| 679 | 653 | default_tx, |
| 680 | - plane_idx, | |
| 681 | 654 | )?; |
| 682 | 655 | let residual = dequant_and_inverse_typed_wh( |
| 683 | 656 | &levels, |
| @@ -806,16 +779,7 @@ pub(super) fn sub8_leaf_chroma422( | ||
| 806 | 779 | u: &mut PlaneBuf<'static>, |
| 807 | 780 | v: &mut PlaneBuf<'static>, |
| 808 | 781 | scan4: &[u16], |
| 809 | - base_q_idx: u8, | |
| 810 | 782 | smooth_neighbor_uv: bool, |
| 811 | - // The owning luma leaf's own shape (`(4, 4)` for a split leaf, `(8, 4)` / | |
| 812 | - // `(4, 8)` for a rect pair's strip): libaom's `has_top_right` / | |
| 813 | - // `has_bottom_left` answer for this chroma TX_4X4 unit comes from the | |
| 814 | - // LEAF's own rect table row at the leaf's mi (`bsize` is the leaf, the | |
| 815 | - // unit covers it whole), never the standalone square-4x4 table the old | |
| 816 | - // `Reach::of(4, ..)` lookup used -- that said 1 where `has_tr_8x4` says 0 | |
| 817 | - // at mi(27,44) (the oracle's own EC_PRED prints `n_tr=0` there), so the | |
| 818 | - // D45 unit read undecoded pixels to its upper right. | |
| 819 | 783 | leaf_shape: (usize, usize), |
| 820 | 784 | fctx: &crate::decode::FrameCtx, |
| 821 | 785 | ) -> Result<(Grid, Grid)> { |
| @@ -988,7 +952,6 @@ pub(super) fn sub8_leaf_chroma422( | ||
| 988 | 952 | &mut ub, |
| 989 | 953 | fctx, |
| 990 | 954 | ); |
| 991 | - hit!(SKIPPED_INTRABC_DV_COPY_HITS); | |
| 992 | 955 | let zeros = &ZERO_RESIDUAL[..16]; |
| 993 | 956 | set_palette_pred(ub, fctx); |
| 994 | 957 | push_intra( |
| @@ -1044,17 +1007,12 @@ pub(super) fn sub8_leaf_chroma422( | ||
| 1044 | 1007 | // [`sub8_leaf_chroma444`] count: a skipped leaf reads no coefficient, |
| 1045 | 1008 | // so the inherited chroma `tx_type` is dropped unconsumed. |
| 1046 | 1009 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { |
| 1047 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | |
| 1048 | 1010 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 1049 | 1011 | } |
| 1050 | 1012 | (Grid::Zero(16), Grid::Zero(16)) |
| 1051 | 1013 | } else if skip { |
| 1052 | 1014 | // A skipped chroma-reference leaf still predicts (the CfL contribution |
| 1053 | 1015 | // survives a skip); no coefficient symbol exists. |
| 1054 | - if alpha.is_some() { | |
| 1055 | - hit!(CHROMA_SKIP_CFL_HITS); | |
| 1056 | - hit!(SKIP_CFL_HITS); | |
| 1057 | - } | |
| 1058 | 1016 | push_intra( |
| 1059 | 1017 | y, |
| 1060 | 1018 | u, |
| @@ -1092,12 +1050,10 @@ pub(super) fn sub8_leaf_chroma422( | ||
| 1092 | 1050 | // The same arm-without-clear route the 4:2:0 tails count: a skipped |
| 1093 | 1051 | // leaf reads no coefficient, so an armed intrabc slot is dropped. |
| 1094 | 1052 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { |
| 1095 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | |
| 1096 | 1053 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 1097 | 1054 | } |
| 1098 | 1055 | (Grid::Zero(16), Grid::Zero(16)) |
| 1099 | 1056 | } else if let Some(dv) = intrabc_dv { |
| 1100 | - hit!(CHROMA422_SUB8_HITS); | |
| 1101 | 1057 | // Frame copy at the DV; the residual still reads the ordinary chroma |
| 1102 | 1058 | // tables with the inherited luma `tx_type` (see the 4:2:0 tails). |
| 1103 | 1059 | let mut ub = vec![0u16; 16]; |
| @@ -1147,7 +1103,6 @@ pub(super) fn sub8_leaf_chroma422( | ||
| 1147 | 1103 | cpy, |
| 1148 | 1104 | 4, |
| 1149 | 1105 | TX4, |
| 1150 | - base_q_idx, | |
| 1151 | 1106 | None, |
| 1152 | 1107 | None, |
| 1153 | 1108 | None, |
| @@ -1173,7 +1128,6 @@ pub(super) fn sub8_leaf_chroma422( | ||
| 1173 | 1128 | cpy, |
| 1174 | 1129 | 4, |
| 1175 | 1130 | TX4, |
| 1176 | - base_q_idx, | |
| 1177 | 1131 | None, |
| 1178 | 1132 | None, |
| 1179 | 1133 | None, |
| @@ -1183,7 +1137,6 @@ pub(super) fn sub8_leaf_chroma422( | ||
| 1183 | 1137 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 1184 | 1138 | (ug, vg) |
| 1185 | 1139 | } else { |
| 1186 | - hit!(CHROMA422_SUB8_HITS); | |
| 1187 | 1140 | let ug = read_plane( |
| 1188 | 1141 | dec, |
| 1189 | 1142 | cdfs, |
| @@ -1202,7 +1155,6 @@ pub(super) fn sub8_leaf_chroma422( | ||
| 1202 | 1155 | cpy, |
| 1203 | 1156 | 4, |
| 1204 | 1157 | TX4, |
| 1205 | - base_q_idx, | |
| 1206 | 1158 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1207 | 1159 | None, |
| 1208 | 1160 | None, |
| @@ -1227,7 +1179,6 @@ pub(super) fn sub8_leaf_chroma422( | ||
| 1227 | 1179 | cpy, |
| 1228 | 1180 | 4, |
| 1229 | 1181 | TX4, |
| 1230 | - base_q_idx, | |
| 1231 | 1182 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1232 | 1183 | None, |
| 1233 | 1184 | None, |
| @@ -1277,16 +1228,11 @@ pub(super) fn decode_leaf_split4( | ||
| 1277 | 1228 | y: &mut PlaneBuf<'static>, |
| 1278 | 1229 | u: &mut PlaneBuf<'static>, |
| 1279 | 1230 | v: &mut PlaneBuf<'static>, |
| 1280 | - base_q_idx: u8, | |
| 1281 | 1231 | enable_filter_intra: bool, |
| 1282 | 1232 | allow_intrabc: bool, |
| 1283 | 1233 | reduced_tx_set: bool, |
| 1284 | - // Returns `(below_mode, right_mode)`: the mode a neighbour BELOW this 8x8 | |
| 1285 | - // group sees (its bottom-left 4x4, libaom reads mi(row-1, col)) and the | |
| 1286 | - // one a neighbour to its RIGHT sees (its top-right 4x4, mi(row, col-1))., fctx: &crate::decode::FrameCtx | |
| 1287 | 1234 | fctx: &crate::decode::FrameCtx, |
| 1288 | 1235 | ) -> Result<(usize, usize)> { |
| 1289 | - hit!(SUB8_SPLIT_HITS); | |
| 1290 | 1236 | let (r, c) = outer_at; |
| 1291 | 1237 | let mut above_mode = neighbours.above_mode[c]; |
| 1292 | 1238 | let mut left_mode = neighbours.left_mode[r]; |
| @@ -1378,9 +1324,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1378 | 1324 | // same value). |
| 1379 | 1325 | set_txfm_ctxs(neighbours, lmi, 4, 1, 1, false); |
| 1380 | 1326 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); |
| 1381 | - if smooth_neighbor { | |
| 1382 | - hit!(SMOOTH_LUMA_HITS); | |
| 1383 | - } | |
| 1384 | 1327 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 1385 | 1328 | let reach = Reach::of(4, px, py, y.width, y.height, fctx); |
| 1386 | 1329 | if let Some(dv) = intrabc { |
| @@ -1450,7 +1393,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1450 | 1393 | py, |
| 1451 | 1394 | 4, |
| 1452 | 1395 | 4, |
| 1453 | - base_q_idx, | |
| 1454 | 1396 | None, |
| 1455 | 1397 | None, |
| 1456 | 1398 | None, |
| @@ -1488,7 +1430,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1488 | 1430 | u, |
| 1489 | 1431 | v, |
| 1490 | 1432 | scan4, |
| 1491 | - base_q_idx, | |
| 1492 | 1433 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 1493 | 1434 | fctx, |
| 1494 | 1435 | )?; |
| @@ -1508,7 +1449,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1508 | 1449 | u, |
| 1509 | 1450 | v, |
| 1510 | 1451 | scan4, |
| 1511 | - base_q_idx, | |
| 1512 | 1452 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 1513 | 1453 | (4, 4), |
| 1514 | 1454 | fctx, |
| @@ -1579,7 +1519,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1579 | 1519 | py, |
| 1580 | 1520 | 4, |
| 1581 | 1521 | 4, |
| 1582 | - base_q_idx, | |
| 1583 | 1522 | None, |
| 1584 | 1523 | filter_intra, |
| 1585 | 1524 | None, |
| @@ -1610,7 +1549,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1610 | 1549 | u, |
| 1611 | 1550 | v, |
| 1612 | 1551 | scan4, |
| 1613 | - base_q_idx, | |
| 1614 | 1552 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 1615 | 1553 | fctx, |
| 1616 | 1554 | )?; |
| @@ -1636,7 +1574,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1636 | 1574 | u, |
| 1637 | 1575 | v, |
| 1638 | 1576 | scan4, |
| 1639 | - base_q_idx, | |
| 1640 | 1577 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 1641 | 1578 | (4, 4), |
| 1642 | 1579 | fctx, |
| @@ -1695,10 +1632,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1695 | 1632 | // merge keeps one fix and feeds both lanes' counters so neither of |
| 1696 | 1633 | // their gates goes vacuous. |
| 1697 | 1634 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); |
| 1698 | - if alpha.is_some() { | |
| 1699 | - hit!(CHROMA_SKIP_CFL_HITS); | |
| 1700 | - hit!(SKIP_CFL_HITS); | |
| 1701 | - } | |
| 1702 | 1635 | push_intra( |
| 1703 | 1636 | y, |
| 1704 | 1637 | u, |
| @@ -1742,7 +1675,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1742 | 1675 | // arm-without-clear-on-a-skip-route). Counted so a gate can tell a |
| 1743 | 1676 | // stream that reaches this route from one that never does. |
| 1744 | 1677 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { |
| 1745 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | |
| 1746 | 1678 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 1747 | 1679 | } |
| 1748 | 1680 | (Grid::Zero(16), Grid::Zero(16)) |
| @@ -1799,7 +1731,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1799 | 1731 | cpy, |
| 1800 | 1732 | 4, |
| 1801 | 1733 | TX4, |
| 1802 | - base_q_idx, | |
| 1803 | 1734 | None, |
| 1804 | 1735 | None, |
| 1805 | 1736 | None, |
| @@ -1825,7 +1756,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1825 | 1756 | cpy, |
| 1826 | 1757 | 4, |
| 1827 | 1758 | TX4, |
| 1828 | - base_q_idx, | |
| 1829 | 1759 | None, |
| 1830 | 1760 | None, |
| 1831 | 1761 | None, |
| @@ -1855,7 +1785,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1855 | 1785 | cpy, |
| 1856 | 1786 | 4, |
| 1857 | 1787 | TX4, |
| 1858 | - base_q_idx, | |
| 1859 | 1788 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1860 | 1789 | None, |
| 1861 | 1790 | None, |
| @@ -1880,7 +1809,6 @@ pub(super) fn decode_leaf_split4( | ||
| 1880 | 1809 | cpy, |
| 1881 | 1810 | 4, |
| 1882 | 1811 | TX4, |
| 1883 | - base_q_idx, | |
| 1884 | 1812 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1885 | 1813 | None, |
| 1886 | 1814 | None, |
| @@ -1989,7 +1917,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 1989 | 1917 | y: &mut PlaneBuf<'static>, |
| 1990 | 1918 | u: &mut PlaneBuf<'static>, |
| 1991 | 1919 | v: &mut PlaneBuf<'static>, |
| 1992 | - base_q_idx: u8, | |
| 1993 | 1920 | enable_filter_intra: bool, |
| 1994 | 1921 | allow_intrabc: bool, |
| 1995 | 1922 | tx_select: bool, |
| @@ -2073,9 +2000,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2073 | 2000 | if let Some(dv) = intrabc { |
| 2074 | 2001 | // lane-av1-ibc444rect: the unskipped lossless luma walk this lane |
| 2075 | 2002 | // fixes (one rect unit -> per-4x4 inter units). |
| 2076 | - if !skip && lossless(fctx) { | |
| 2077 | - hit!(INTRABC_RECT8_LOSSLESS_LUMA_HITS); | |
| 2078 | - } | |
| 2079 | 2003 | // lane-av1txr: an intrabc `BLOCK_4X8`/`BLOCK_8X4` leaf. The |
| 2080 | 2004 | // prediction is a frame copy at the DV and the residual reads the |
| 2081 | 2005 | // INTER `LumaRect8x4` set -- but with `TxMode::Select` the leaf |
| @@ -2127,7 +2051,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2127 | 2051 | 0, |
| 2128 | 2052 | &mut luma_leaves, |
| 2129 | 2053 | ); |
| 2130 | - hit!(RECT_INTRABC_VARTX_HITS); | |
| 2131 | 2054 | publish = None; |
| 2132 | 2055 | } else if lossless(fctx) && !skip { |
| 2133 | 2056 | // lane-av1-ibc444rect: `read_tx_size`'s lossless first line |
| @@ -2170,19 +2093,7 @@ pub(super) fn decode_leaf_rect8( | ||
| 2170 | 2093 | let tu_reach = if single { |
| 2171 | 2094 | reach |
| 2172 | 2095 | } else { |
| 2173 | - tu_reach( | |
| 2174 | - bw, | |
| 2175 | - bh, | |
| 2176 | - tu_px - px, | |
| 2177 | - tu_py - py, | |
| 2178 | - tw, | |
| 2179 | - reach, | |
| 2180 | - px, | |
| 2181 | - py, | |
| 2182 | - y.width, | |
| 2183 | - y.height, | |
| 2184 | - fctx, | |
| 2185 | - ) | |
| 2096 | + tu_reach(bw, bh, tu_px - px, tu_py - py, tw, reach) | |
| 2186 | 2097 | }; |
| 2187 | 2098 | let mut yb = vec![0u16; tw * th]; |
| 2188 | 2099 | mc::predict_with_filter( |
| @@ -2285,7 +2196,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2285 | 2196 | skip_ctx, |
| 2286 | 2197 | dc_sign_ctx(around.2), |
| 2287 | 2198 | TxType::DctDct, |
| 2288 | - 0, | |
| 2289 | 2199 | )?; |
| 2290 | 2200 | if li == 0 { |
| 2291 | 2201 | chroma_tx = tx_type; |
| @@ -2417,7 +2327,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2417 | 2327 | u, |
| 2418 | 2328 | v, |
| 2419 | 2329 | scan4, |
| 2420 | - base_q_idx, | |
| 2421 | 2330 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2422 | 2331 | fctx, |
| 2423 | 2332 | )?; |
| @@ -2439,7 +2348,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2439 | 2348 | u, |
| 2440 | 2349 | v, |
| 2441 | 2350 | scan4, |
| 2442 | - base_q_idx, | |
| 2443 | 2351 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2444 | 2352 | (bw, bh), |
| 2445 | 2353 | fctx, |
| @@ -2452,15 +2360,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2452 | 2360 | } |
| 2453 | 2361 | continue; |
| 2454 | 2362 | } |
| 2455 | - if filter_intra.is_some() { | |
| 2456 | - // lane-fi8 r1: `predict_filter_intra` walks its 4x2 patches over | |
| 2457 | - // a true `bw`x`bh` block, so a 4x8/8x4 leaf predicts through the | |
| 2458 | - // same `reconstruct_rect`/`reconstruct` calls below -- and under | |
| 2459 | - // a split transform, per 4x4 unit with that unit's own edge, | |
| 2460 | - // which is exactly what the depth-1 loop already does. | |
| 2461 | - hit!(FILTER_INTRA_RECT_HITS); | |
| 2462 | - hit!(FILTER_INTRA_RECT_SUB8_HITS); | |
| 2463 | - } | |
| 2464 | 2363 | // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4 |
| 2465 | 2364 | // leaf too, and is read for every intra block, skipped or not. Its |
| 2466 | 2365 | // category is libaom's `bsize_to_tx_size_cat(BLOCK_4X8) == 0` -- |
| @@ -2480,18 +2379,11 @@ pub(super) fn decode_leaf_rect8( | ||
| 2480 | 2379 | let depth = if tx_select && !lossless(fctx) { |
| 2481 | 2380 | // lane-av1txbands: the `TXFM_CONTEXT` band read every other rect |
| 2482 | 2381 | // reader already does. |
| 2483 | - let ctx = tx_size_context_txfm_rect(neighbours, lmi, bw, bh, fctx); | |
| 2382 | + let ctx = tx_size_context_txfm_rect(neighbours, lmi, bw, bh); | |
| 2484 | 2383 | dec.symbol(&mut cdfs.tx_size_cat0[ctx]) |
| 2485 | 2384 | } else { |
| 2486 | 2385 | 0 |
| 2487 | 2386 | }; |
| 2488 | - if depth != 0 { | |
| 2489 | - hit!(TX_DEPTH_HITS); | |
| 2490 | - hit!(RECT8_SPLIT_TX_HITS); | |
| 2491 | - } | |
| 2492 | - if smooth_neighbor { | |
| 2493 | - hit!(SMOOTH_LUMA_HITS); | |
| 2494 | - } | |
| 2495 | 2387 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 2496 | 2388 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); |
| 2497 | 2389 | // `sub_tx_size_map[TX_4X8] == TX_4X4`: depth 1 splits the leaf into |
| @@ -2511,7 +2403,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2511 | 2403 | let (ctx_tx_w, ctx_tx_h) = if split { (4, 4) } else { (bw, bh) }; |
| 2512 | 2404 | txfm_partition_update_rect(neighbours, lmi, (ctx_tx_w, ctx_tx_h), (bw, bh)); |
| 2513 | 2405 | if split { |
| 2514 | - let mut done = 0usize; | |
| 2515 | 2406 | for tu in 0..2usize { |
| 2516 | 2407 | let tu_mi = if vert { |
| 2517 | 2408 | (lmi.0 + tu, lmi.1) |
| @@ -2524,19 +2415,7 @@ pub(super) fn decode_leaf_rect8( | ||
| 2524 | 2415 | // (lane-palette2 r12): a transform unit inside a block is not |
| 2525 | 2416 | // a block at that position, so its reach comes from the |
| 2526 | 2417 | // block's own row, offset by the unit's position. |
| 2527 | - let tu_reach = tu_reach( | |
| 2528 | - bw, | |
| 2529 | - bh, | |
| 2530 | - tu_px - px, | |
| 2531 | - tu_py - py, | |
| 2532 | - 4, | |
| 2533 | - reach, | |
| 2534 | - px, | |
| 2535 | - py, | |
| 2536 | - y.width, | |
| 2537 | - y.height, | |
| 2538 | - fctx, | |
| 2539 | - ); | |
| 2418 | + let tu_reach = tu_reach(bw, bh, tu_px - px, tu_py - py, 4, reach); | |
| 2540 | 2419 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); |
| 2541 | 2420 | if skip { |
| 2542 | 2421 | // A skipped leaf still predicts per transform unit: the |
| @@ -2586,25 +2465,14 @@ pub(super) fn decode_leaf_rect8( | ||
| 2586 | 2465 | tu_py, |
| 2587 | 2466 | 4, |
| 2588 | 2467 | TX4, |
| 2589 | - base_q_idx, | |
| 2590 | 2468 | None, |
| 2591 | 2469 | filter_intra, |
| 2592 | 2470 | Some(tu_skip_ctx), |
| 2593 | 2471 | smooth_neighbor, |
| 2594 | 2472 | fctx, |
| 2595 | 2473 | )?; |
| 2596 | - if tu_grid.iter().any(|&l| l != 0) { | |
| 2597 | - done += 1; | |
| 2598 | - } | |
| 2599 | 2474 | neighbours.record_mi_luma(tu_mi, 4, &tu_grid); |
| 2600 | 2475 | } |
| 2601 | - if done > 0 { | |
| 2602 | - if vert { | |
| 2603 | - hit!(TX4X8_CODED_HITS); | |
| 2604 | - } else { | |
| 2605 | - hit!(TX8X4_CODED_HITS); | |
| 2606 | - } | |
| 2607 | - } | |
| 2608 | 2476 | neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); |
| 2609 | 2477 | neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, 4, 4, 0, fctx); |
| 2610 | 2478 | if has_chroma { |
| @@ -2627,7 +2495,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2627 | 2495 | u, |
| 2628 | 2496 | v, |
| 2629 | 2497 | scan4, |
| 2630 | - base_q_idx, | |
| 2631 | 2498 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2632 | 2499 | fctx, |
| 2633 | 2500 | )?; |
| @@ -2655,7 +2522,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2655 | 2522 | u, |
| 2656 | 2523 | v, |
| 2657 | 2524 | scan4, |
| 2658 | - base_q_idx, | |
| 2659 | 2525 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2660 | 2526 | (bw, bh), |
| 2661 | 2527 | fctx, |
| @@ -2712,15 +2578,7 @@ pub(super) fn decode_leaf_rect8( | ||
| 2712 | 2578 | 0, |
| 2713 | 2579 | dc_sign_ctx(around.2), |
| 2714 | 2580 | TxType::DctDct, |
| 2715 | - 0, | |
| 2716 | 2581 | )?; |
| 2717 | - if levels.iter().any(|&l| l != 0) { | |
| 2718 | - if vert { | |
| 2719 | - hit!(TX4X8_CODED_HITS); | |
| 2720 | - } else { | |
| 2721 | - hit!(TX8X4_CODED_HITS); | |
| 2722 | - } | |
| 2723 | - } | |
| 2724 | 2582 | let residual = dequant_and_inverse_typed_wh( |
| 2725 | 2583 | &levels, |
| 2726 | 2584 | bw, |
| @@ -2791,7 +2649,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2791 | 2649 | u, |
| 2792 | 2650 | v, |
| 2793 | 2651 | scan4, |
| 2794 | - base_q_idx, | |
| 2795 | 2652 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2796 | 2653 | fctx, |
| 2797 | 2654 | )?; |
| @@ -2822,7 +2679,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2822 | 2679 | u, |
| 2823 | 2680 | v, |
| 2824 | 2681 | scan4, |
| 2825 | - base_q_idx, | |
| 2826 | 2682 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2827 | 2683 | (bw, bh), |
| 2828 | 2684 | fctx, |
| @@ -2881,10 +2737,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2881 | 2737 | // merge keeps one fix and feeds both lanes' counters so neither of |
| 2882 | 2738 | // their gates goes vacuous. |
| 2883 | 2739 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); |
| 2884 | - if alpha.is_some() { | |
| 2885 | - hit!(CHROMA_SKIP_CFL_HITS); | |
| 2886 | - hit!(SKIP_CFL_HITS); | |
| 2887 | - } | |
| 2888 | 2740 | push_intra( |
| 2889 | 2741 | y, |
| 2890 | 2742 | u, |
| @@ -2928,7 +2780,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 2928 | 2780 | // arm-without-clear-on-a-skip-route). Counted so a gate can tell a |
| 2929 | 2781 | // stream that reaches this route from one that never does. |
| 2930 | 2782 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { |
| 2931 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | |
| 2932 | 2783 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 2933 | 2784 | } |
| 2934 | 2785 | (Grid::Zero(16), Grid::Zero(16)) |
| @@ -3005,7 +2856,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 3005 | 2856 | &ZERO_RESIDUAL[..16], |
| 3006 | 2857 | fctx, |
| 3007 | 2858 | ); |
| 3008 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | |
| 3009 | 2859 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 3010 | 2860 | (Grid::Zero(16), Grid::Zero(16)) |
| 3011 | 2861 | } else { |
| @@ -3029,7 +2879,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 3029 | 2879 | cpy, |
| 3030 | 2880 | 4, |
| 3031 | 2881 | TX4, |
| 3032 | - base_q_idx, | |
| 3033 | 2882 | None, |
| 3034 | 2883 | None, |
| 3035 | 2884 | None, |
| @@ -3055,7 +2904,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 3055 | 2904 | cpy, |
| 3056 | 2905 | 4, |
| 3057 | 2906 | TX4, |
| 3058 | - base_q_idx, | |
| 3059 | 2907 | None, |
| 3060 | 2908 | None, |
| 3061 | 2909 | None, |
| @@ -3086,7 +2934,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 3086 | 2934 | cpy, |
| 3087 | 2935 | 4, |
| 3088 | 2936 | TX4, |
| 3089 | - base_q_idx, | |
| 3090 | 2937 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 3091 | 2938 | None, |
| 3092 | 2939 | None, |
| @@ -3111,7 +2958,6 @@ pub(super) fn decode_leaf_rect8( | ||
| 3111 | 2958 | cpy, |
| 3112 | 2959 | 4, |
| 3113 | 2960 | TX4, |
| 3114 | - base_q_idx, | |
| 3115 | 2961 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 3116 | 2962 | None, |
| 3117 | 2963 | None, |
crates/ec-av1/src/decode/mod.rsmodified+7 -522
| @@ -20,7 +20,6 @@ | ||
| 20 | 20 | //! inside one, forcing the gathered-CDF partial-superblock path, is round 2 |
| 21 | 21 | //! too). Anything outside that refuses with [`Error::unsupported`] rather than |
| 22 | 22 | //! silently miscoding. |
| 23 | -use crate::hits::{hit, hit_do}; | |
| 24 | 23 | |
| 25 | 24 | use ec_av1_syntax::{ |
| 26 | 25 | CdefParams, DeltaParams, LoopFilterParams, LoopRestorationParams, MAX_SEGMENTS, |
| @@ -41,9 +40,6 @@ use ec_core::{Error, Result}; | ||
| 41 | 40 | // itself was lifted by lane-av112bitc before that (the combines absorb the |
| 42 | 41 | // CONV_BUF gain drop, `INTER_POST_ROUND - delta`, see `mc::combine_compound`). |
| 43 | 42 | |
| 44 | -mod counters; | |
| 45 | -pub use counters::*; | |
| 46 | - | |
| 47 | 43 | mod frame_tile; |
| 48 | 44 | |
| 49 | 45 | mod inter_block8; |
| @@ -71,7 +67,7 @@ use rect4::*; | ||
| 71 | 67 | |
| 72 | 68 | mod block; |
| 73 | 69 | mod wave; |
| 74 | -pub use block::*; | |
| 70 | +pub(crate) use block::*; | |
| 75 | 71 | |
| 76 | 72 | mod leaf8; |
| 77 | 73 | use leaf8::*; |
| @@ -100,9 +96,6 @@ pub use key_tile::*; | ||
| 100 | 96 | mod inter_ctx; |
| 101 | 97 | pub(crate) use inter_ctx::*; |
| 102 | 98 | |
| 103 | -#[cfg(test)] | |
| 104 | -mod obmc_skip_chroma_tests; | |
| 105 | - | |
| 106 | 99 | mod sub8_inter; |
| 107 | 100 | pub(crate) use frame_tile::*; |
| 108 | 101 | use sub8_inter::*; |
| @@ -437,38 +430,6 @@ thread_local! { | ||
| 437 | 430 | static COEFF_TRACE_CUR: std::cell::Cell<usize> = const { std::cell::Cell::new(usize::MAX) }; |
| 438 | 431 | } |
| 439 | 432 | |
| 440 | -/// Called by [`crate::stream::decode_stream`] before each frame's tiles with | |
| 441 | -/// that frame's DECODE-order index. | |
| 442 | -pub fn set_coeff_trace_frame(idx: usize) { | |
| 443 | - COEFF_TRACE_FRAME.with(|c| { | |
| 444 | - if c.get().is_none() { | |
| 445 | - let want = match crate::envflags::var("EC_TRACE_COEFF_FRAME") { | |
| 446 | - Ok(v) => v.parse::<usize>().unwrap_or(usize::MAX), | |
| 447 | - // unset: keep tracing every frame, as before this rung existed | |
| 448 | - Err(_) => usize::MAX - 1, | |
| 449 | - }; | |
| 450 | - c.set(Some(want)); | |
| 451 | - } | |
| 452 | - }); | |
| 453 | - COEFF_TRACE_CUR.with(|c| c.set(idx)); | |
| 454 | - if crate::envflags::env_flag!("EC_TRACE_COEFF") { | |
| 455 | - eprintln!("EC_COEFF_FRAME decode_idx={idx}"); | |
| 456 | - } | |
| 457 | -} | |
| 458 | - | |
| 459 | -pub(crate) fn coeff_trace_on() -> bool { | |
| 460 | - if !crate::envflags::env_flag!("EC_TRACE_COEFF") { | |
| 461 | - return false; | |
| 462 | - } | |
| 463 | - match COEFF_TRACE_FRAME.with(|c| c.get()) { | |
| 464 | - // no `set_coeff_trace_frame` caller (direct tile-decode tests), or the | |
| 465 | - // env var unset: trace every frame. | |
| 466 | - None => true, | |
| 467 | - Some(w) if w >= usize::MAX - 1 => true, | |
| 468 | - Some(w) => COEFF_TRACE_CUR.with(|c| c.get()) == w, | |
| 469 | - } | |
| 470 | -} | |
| 471 | - | |
| 472 | 433 | /// Sets [`SB128`] for this thread (called once per frame from `stream.rs`). |
| 473 | 434 | pub(crate) fn set_sb128(v: bool, fctx: &crate::decode::FrameCtx) { |
| 474 | 435 | fctx.sb128_flag.with(|c| c.set(v)); |
| @@ -550,20 +511,6 @@ thread_local! { | ||
| 550 | 511 | static PART128_GATHERED_SYMBOLS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 551 | 512 | } |
| 552 | 513 | |
| 553 | -/// Current value of `PART128_GATHERED_SYMBOLS`: 128 roots that read the | |
| 554 | -/// half-out-of-frame gathered split_or_horz/split_or_vert symbol (spec | |
| 555 | -/// 5.11.4), which this decoder used to read and throw away. | |
| 556 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 557 | -pub(crate) fn part128_gathered_symbols() -> usize { | |
| 558 | - PART128_GATHERED_SYMBOLS.with(|c| c.get()) | |
| 559 | -} | |
| 560 | - | |
| 561 | -/// Current value of [`PART128_SYMBOLS`]. | |
| 562 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 563 | -pub(crate) fn part128_symbols() -> usize { | |
| 564 | - PART128_SYMBOLS.with(|c| c.get()) | |
| 565 | -} | |
| 566 | - | |
| 567 | 514 | /// [`gather`] over an alphabet of any length -- the 128-level partition CDF |
| 568 | 515 | /// has 8 symbols (no `PARTITION_HORZ_4`/`_VERT_4` at `BLOCK_128X128`, spec |
| 569 | 516 | /// `partition_cdf_length`), so its forced-split gather sums 5 elements where |
| @@ -670,11 +617,7 @@ pub(crate) fn superres(fctx: &crate::decode::FrameCtx) -> Option<(u32, u32)> { | ||
| 670 | 617 | /// for a rectangular luma block (8x16, 16x8) or a PARTITION_HORZ/VERT strip is |
| 671 | 618 | /// bigger than the real block in one axis. |
| 672 | 619 | pub(crate) fn warp_plane_allowed(w: usize, h: usize) -> bool { |
| 673 | - if w >= 8 && h >= 8 { | |
| 674 | - return true; | |
| 675 | - } | |
| 676 | - hit!(WARP_PLANE_SUPPRESS_HITS); | |
| 677 | - false | |
| 620 | + w >= 8 && h >= 8 | |
| 678 | 621 | } |
| 679 | 622 | |
| 680 | 623 | /// This frame's [`QUANT_DELTAS`] `(dc, ac)` pair for plane `plane_idx` (0 = |
| @@ -779,7 +722,6 @@ fn maybe_read_delta_q( | ||
| 779 | 722 | } |
| 780 | 723 | let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; |
| 781 | 724 | let reduced = if sign_negative { -abs } else { abs }; |
| 782 | - hit!(DELTA_Q_HITS); | |
| 783 | 725 | let res = fctx.delta_q_res.with(|c| c.get()); |
| 784 | 726 | fctx.current_q_idx |
| 785 | 727 | .with(|c| c.set((c.get() + reduced * res).clamp(1, 255))); |
| @@ -835,7 +777,6 @@ fn maybe_read_delta_lf( | ||
| 835 | 777 | let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; |
| 836 | 778 | let reduced = if sign_negative { -abs } else { abs }; |
| 837 | 779 | cur[i] = (cur[i] + reduced * res).clamp(-63, 63); |
| 838 | - hit!(DELTA_LF_HITS); | |
| 839 | 780 | } |
| 840 | 781 | fctx.current_delta_lf.with(|c| c.set(cur)); |
| 841 | 782 | } |
| @@ -863,7 +804,6 @@ fn maybe_read_cdef_idx( | ||
| 863 | 804 | } |
| 864 | 805 | let idx = dec.literal(u32::from(bits)) as u8; |
| 865 | 806 | fctx.cdef_transmitted.with(|c| c.set(true)); |
| 866 | - hit!(CDEF_IDX_HITS); | |
| 867 | 807 | let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize); |
| 868 | 808 | let sb_cols = fctx.cdef_sb_cols.with(|c| c.get()); |
| 869 | 809 | if sb_cols > 0 { |
| @@ -913,17 +853,6 @@ pub(crate) fn set_segmentation( | ||
| 913 | 853 | prev: Option<&[u8]>, |
| 914 | 854 | fctx: &crate::decode::FrameCtx, |
| 915 | 855 | ) { |
| 916 | - if crate::envflags::env_flag!("EC_HDR") { | |
| 917 | - eprintln!( | |
| 918 | - "EC_SEGHDR enabled={} update_map={} temporal={} preskip={} last_active={} data={:?}", | |
| 919 | - seg.enabled, | |
| 920 | - seg.update_map, | |
| 921 | - seg.temporal_update, | |
| 922 | - seg.seg_id_pre_skip, | |
| 923 | - seg.last_active_seg_id, | |
| 924 | - seg.feature_data | |
| 925 | - ); | |
| 926 | - } | |
| 927 | 856 | fctx.seg.with(|s| *s.borrow_mut() = seg); |
| 928 | 857 | fctx.seg_mi_dims.with(|c| c.set((mi_rows, mi_cols))); |
| 929 | 858 | fctx.seg_ids |
| @@ -950,19 +879,6 @@ pub(crate) fn take_segment_ids(fctx: &crate::decode::FrameCtx) -> Vec<u8> { | ||
| 950 | 879 | fctx.seg_ids.with(|m| m.borrow().clone()) |
| 951 | 880 | } |
| 952 | 881 | |
| 953 | -/// How many distinct segment ids any decoded block has carried. | |
| 954 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 955 | -pub(crate) fn segment_ids_seen() -> usize { | |
| 956 | - SEG_IDS_SEEN.with(|c| c.get().count_ones() as usize) | |
| 957 | -} | |
| 958 | - | |
| 959 | -/// The lowest and highest quantizer index any decoded block was dequantized | |
| 960 | -/// with (`(i32::MAX, i32::MIN)` when nothing decoded). | |
| 961 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 962 | -pub(crate) fn block_q_span() -> (i32, i32) { | |
| 963 | - BLOCK_Q_SPAN.with(|c| c.get()) | |
| 964 | -} | |
| 965 | - | |
| 966 | 882 | /// `seg_feature_active_idx(segment_id, feature)` for the frame currently |
| 967 | 883 | /// being decoded, with its `FeatureData` value. |
| 968 | 884 | fn seg_feature(segment_id: usize, feature: usize, fctx: &crate::decode::FrameCtx) -> Option<i32> { |
| @@ -987,13 +903,6 @@ fn block_q_idx(fctx: &crate::decode::FrameCtx) -> i32 { | ||
| 987 | 903 | // lane-d792: which SEGMENT a block's quantizer came out of, beside the |
| 988 | 904 | // `EC_DQCOEFF` grid rung -- a dequant that is too low with the levels |
| 989 | 905 | // already proven equal is a segment-id defect, not a quantizer one. |
| 990 | - if crate::envflags::env_flag!("EC_DQCOEFF") { | |
| 991 | - eprintln!("OUR_Q base={base} seg={seg_id} q={q}"); | |
| 992 | - } | |
| 993 | - hit_do!(BLOCK_Q_SPAN.with(|c| { | |
| 994 | - let (lo, hi) = c.get(); | |
| 995 | - c.set((lo.min(q), hi.max(q))); | |
| 996 | - });); | |
| 997 | 906 | q |
| 998 | 907 | } |
| 999 | 908 | |
| @@ -1163,17 +1072,10 @@ fn read_segment_id( | ||
| 1163 | 1072 | return pred as u8; |
| 1164 | 1073 | } |
| 1165 | 1074 | let coded = dec.symbol(&mut cdfs.segment_id[ctx]) as i32; |
| 1166 | - hit!(SEG_ID_HITS); | |
| 1167 | 1075 | let last_active = fctx.seg.with(|s| i32::from(s.borrow().last_active_seg_id)); |
| 1168 | 1076 | let id = neg_deinterleave(coded, pred, last_active + 1).clamp(0, last_active); |
| 1169 | 1077 | // Mirrors the oracle's own `EC_SEG mi_row=.. cdf=.. pred=.. coded=.. id=..` |
| 1170 | 1078 | // (libaom `decodemv.c:read_segment_id`), for a cross-decoder segment diff. |
| 1171 | - if crate::envflags::env_flag!("EC_TRACE_SEG") { | |
| 1172 | - eprintln!( | |
| 1173 | - "EC_SEG mi_row={mi_r} mi_col={mi_c} cdf={ctx} pred={pred} coded={coded} id={id} rng={}", | |
| 1174 | - dec.debug_state().0 | |
| 1175 | - ); | |
| 1176 | - } | |
| 1177 | 1079 | id as u8 |
| 1178 | 1080 | } |
| 1179 | 1081 | |
| @@ -1266,7 +1168,6 @@ fn inter_segment_id( | ||
| 1266 | 1168 | let id = if temporal_update { |
| 1267 | 1169 | let ctx = seg_pred_ctx(mi_r, mi_c, fctx); |
| 1268 | 1170 | let predicted = dec.symbol(&mut cdfs.segment_pred[ctx]) != 0; |
| 1269 | - hit!(SEG_PRED_HITS); | |
| 1270 | 1171 | stamp_seg_pred(mi_r, mi_c, w_mi, h_mi, u8::from(predicted), fctx); |
| 1271 | 1172 | if predicted { |
| 1272 | 1173 | predicted_segment_id(mi_r, mi_c, w_mi, h_mi, fctx) |
| @@ -1340,18 +1241,8 @@ fn tu_reach( | ||
| 1340 | 1241 | row_off: usize, |
| 1341 | 1242 | tx: usize, |
| 1342 | 1243 | block: Reach, |
| 1343 | - px: usize, | |
| 1344 | - py: usize, | |
| 1345 | - width: usize, | |
| 1346 | - height: usize, | |
| 1347 | - fctx: &crate::decode::FrameCtx, | |
| 1348 | 1244 | ) -> Reach { |
| 1349 | - let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, block); | |
| 1350 | - let standalone = Reach::of(tx, px + col_off, py + row_off, width, height, fctx); | |
| 1351 | - if fixed != standalone { | |
| 1352 | - hit!(SPLIT_TU_REACH_FIX_HITS); | |
| 1353 | - } | |
| 1354 | - fixed | |
| 1245 | + Reach::of_tu(bw, bh, col_off, row_off, tx, tx, block) | |
| 1355 | 1246 | } |
| 1356 | 1247 | |
| 1357 | 1248 | /// [`tu_reach`] for a unit whose LUMA footprint is a `tx_w` x `tx_h` rect |
| @@ -1370,42 +1261,17 @@ fn tu_reach_rect( | ||
| 1370 | 1261 | tx_w: usize, |
| 1371 | 1262 | tx_h: usize, |
| 1372 | 1263 | block: Reach, |
| 1373 | - px: usize, | |
| 1374 | - py: usize, | |
| 1375 | - width: usize, | |
| 1376 | - height: usize, | |
| 1377 | - fctx: &crate::decode::FrameCtx, | |
| 1378 | 1264 | ) -> Reach { |
| 1379 | - let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx_w, tx_h, block); | |
| 1380 | - if tx_w == tx_h { | |
| 1381 | - let standalone = Reach::of(tx_w, px + col_off, py + row_off, width, height, fctx); | |
| 1382 | - if fixed != standalone { | |
| 1383 | - hit!(SPLIT_TU_REACH_FIX_HITS); | |
| 1384 | - } | |
| 1385 | - } | |
| 1386 | - fixed | |
| 1265 | + Reach::of_tu(bw, bh, col_off, row_off, tx_w, tx_h, block) | |
| 1387 | 1266 | } |
| 1388 | 1267 | |
| 1389 | -/// lane-comppin r4: decode-order picture counter for `EC_AV1_PREFILT_DUMP`, | |
| 1390 | -/// mirroring stream.rs's `pictures_decoded` so the two dumps index | |
| 1391 | -/// identically against aomdec's own `ec_frame_idx` in decodeframe.c. | |
| 1392 | -static PREFILT_PICTURE_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | |
| 1393 | - | |
| 1394 | 1268 | /// Records one decoded forward keyframe (see [`FWD_KF_HITS`]). |
| 1395 | -pub(crate) fn note_fwd_kf() { | |
| 1396 | - hit!(FWD_KF_HITS); | |
| 1397 | -} | |
| 1269 | +pub(crate) fn note_fwd_kf() {} | |
| 1398 | 1270 | |
| 1399 | 1271 | thread_local! { |
| 1400 | 1272 | static TXFM_SPLIT_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1401 | 1273 | } |
| 1402 | 1274 | |
| 1403 | -/// Current value of [`TXFM_SPLIT_READS`]. | |
| 1404 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1405 | -pub(crate) fn txfm_split_reads() -> usize { | |
| 1406 | - TXFM_SPLIT_READS.with(|c| c.get()) | |
| 1407 | -} | |
| 1408 | - | |
| 1409 | 1275 | /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/ |
| 1410 | 1276 | /// [`ENABLE_FILTER_INTRA_INTER`]. |
| 1411 | 1277 | pub(crate) fn set_inter_tx_mode( |
| @@ -1422,37 +1288,6 @@ pub(crate) fn set_inter_tx_mode( | ||
| 1422 | 1288 | .with(|c| c.set(enable_filter_intra)); |
| 1423 | 1289 | } |
| 1424 | 1290 | |
| 1425 | -fn bump_ab16(arm: usize) { | |
| 1426 | - hit_do! { | |
| 1427 | - AB16_HITS.with(|c| { | |
| 1428 | - let mut v = c.get(); | |
| 1429 | - v[arm] += 1; | |
| 1430 | - c.set(v); | |
| 1431 | - }); | |
| 1432 | - } | |
| 1433 | -} | |
| 1434 | - | |
| 1435 | -/// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`]. | |
| 1436 | -pub(crate) fn bump_inter_edge_strip(idx: usize) { | |
| 1437 | - hit_do! { | |
| 1438 | - INTER_EDGE_STRIP_HITS.with(|c| { | |
| 1439 | - let mut v = c.get(); | |
| 1440 | - v[idx] += 1; | |
| 1441 | - c.set(v); | |
| 1442 | - }); | |
| 1443 | - } | |
| 1444 | -} | |
| 1445 | - | |
| 1446 | -fn bump_edge_both_cut(level: usize) { | |
| 1447 | - hit_do! { | |
| 1448 | - EDGE_BOTH_CUT_HITS.with(|c| { | |
| 1449 | - let mut v = c.get(); | |
| 1450 | - v[level] += 1; | |
| 1451 | - c.set(v); | |
| 1452 | - }); | |
| 1453 | - } | |
| 1454 | -} | |
| 1455 | - | |
| 1456 | 1291 | // lane-av1muchroma site 1: the total number of samples by which |
| 1457 | 1292 | // `decode_block`'s SKIP arm chroma bookkeeping grids fell SHORT of their own |
| 1458 | 1293 | // plane block, summed over every skipped block decoded. It reads the |
| @@ -1467,12 +1302,6 @@ thread_local! { | ||
| 1467 | 1302 | const { std::cell::Cell::new(0) }; |
| 1468 | 1303 | } |
| 1469 | 1304 | |
| 1470 | -/// Current value of [`SKIP_ARM_CHROMA_SHORT_SAMPLES`]. | |
| 1471 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1472 | -pub(crate) fn skip_arm_chroma_short_samples() -> usize { | |
| 1473 | - SKIP_ARM_CHROMA_SHORT_SAMPLES.with(|c| c.get()) | |
| 1474 | -} | |
| 1475 | - | |
| 1476 | 1305 | // Number of times `decode_block`'s SKIP arm ran at a shape where the |
| 1477 | 1306 | // per-axis and square chroma allocations DIFFER -- i.e. at 4:2:2, where |
| 1478 | 1307 | // the square is half the plane block. Zero on 4:2:0 and 4:4:4, where the |
| @@ -1484,12 +1313,6 @@ thread_local! { | ||
| 1484 | 1313 | const { std::cell::Cell::new(0) }; |
| 1485 | 1314 | } |
| 1486 | 1315 | |
| 1487 | -/// Current value of [`SKIP_ARM_CHROMA_RECT_SHAPES`]. | |
| 1488 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1489 | -pub(crate) fn skip_arm_chroma_rect_shapes() -> usize { | |
| 1490 | - SKIP_ARM_CHROMA_RECT_SHAPES.with(|c| c.get()) | |
| 1491 | -} | |
| 1492 | - | |
| 1493 | 1316 | // lane-av1floorshift: the two FRAME chroma plane allocators |
| 1494 | 1317 | // (`decode_key_frame_tile_with_cdfs` and `decode_inter_tile`'s `PlaneBuf` trio) |
| 1495 | 1318 | // size U and V as `(width >> ss_x) x (height >> ss_y)` with `width`/`height` |
| @@ -1532,152 +1355,6 @@ thread_local! { | ||
| 1532 | 1355 | const { std::cell::Cell::new(0) }; |
| 1533 | 1356 | } |
| 1534 | 1357 | |
| 1535 | -/// Current value of [`FRAME_CHROMA_ALLOC_CALLS`]. | |
| 1536 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1537 | -pub(crate) fn frame_chroma_alloc_calls() -> usize { | |
| 1538 | - FRAME_CHROMA_ALLOC_CALLS.with(|c| c.get()) | |
| 1539 | -} | |
| 1540 | - | |
| 1541 | -/// Current value of [`FRAME_CHROMA_ALLOC_SHORT_SAMPLES`]. | |
| 1542 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1543 | -pub(crate) fn frame_chroma_alloc_short_samples() -> usize { | |
| 1544 | - FRAME_CHROMA_ALLOC_SHORT_SAMPLES.with(|c| c.get()) | |
| 1545 | -} | |
| 1546 | - | |
| 1547 | -/// Current value of [`FRAME_CHROMA_ALLOC_CROP_SHAPES`]. | |
| 1548 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1549 | -pub(crate) fn frame_chroma_alloc_crop_shapes() -> usize { | |
| 1550 | - FRAME_CHROMA_ALLOC_CROP_SHAPES.with(|c| c.get()) | |
| 1551 | -} | |
| 1552 | - | |
| 1553 | -/// The census both frame chroma plane allocators share. `shape` is the frame's | |
| 1554 | -/// own 32-aligned coded `(width, height)`, `ss` its `(ss_x, ss_y)`. | |
| 1555 | -/// | |
| 1556 | -/// `round_ss` is libaom's chroma CROP (`av1_round_shift`), the extent the | |
| 1557 | -/// committed reference planes are stored at and the bound every chroma walk | |
| 1558 | -/// inside the tile is clamped against. | |
| 1559 | -/// | |
| 1560 | -/// `alloc` is the allocator's OWN `(cw, ch)` -- the numbers that size the | |
| 1561 | -/// `PlaneBuf` -- not a recomputation of them. That is what makes the gate | |
| 1562 | -/// bite: the shortfall is a difference between what was allocated and what the | |
| 1563 | -/// tile may address, so replacing the shift with a bare `>> 1` (the 4:2:0-only | |
| 1564 | -/// form this lane's target class is made of) moves it on the 4:2:2 and 4:4:4 | |
| 1565 | -/// witnesses, where the correct shift and the hardcoded one are different | |
| 1566 | -/// numbers. A counter that recomputed `shape >> ss` beside the allocation | |
| 1567 | -/// would have read the same value either way and proved nothing. | |
| 1568 | -fn note_frame_chroma_alloc(shape: (usize, usize), alloc: (usize, usize), ss: (usize, usize)) { | |
| 1569 | - hit!(FRAME_CHROMA_ALLOC_CALLS); | |
| 1570 | - let (need_w, need_h) = (round_ss(shape.0, ss.0), round_ss(shape.1, ss.1)); | |
| 1571 | - // Decidability: the floor and the crop are the same number on this frame, | |
| 1572 | - // so the shortfall below is the same number the two forms would have given. | |
| 1573 | - if (need_w, need_h) != (shape.0 >> ss.0, shape.1 >> ss.1) { | |
| 1574 | - hit!(FRAME_CHROMA_ALLOC_CROP_SHAPES); | |
| 1575 | - if crate::envflags::env_flag!("EC_AV1_CHROMA_ALLOC_SWEEP") { | |
| 1576 | - eprintln!( | |
| 1577 | - "CHROMA_ALLOC luma={}x{} ss={:?} floor={}x{} round_ss={}x{} alloc={}x{}", | |
| 1578 | - shape.0, | |
| 1579 | - shape.1, | |
| 1580 | - ss, | |
| 1581 | - shape.0 >> ss.0, | |
| 1582 | - shape.1 >> ss.1, | |
| 1583 | - need_w, | |
| 1584 | - need_h, | |
| 1585 | - alloc.0, | |
| 1586 | - alloc.1, | |
| 1587 | - ); | |
| 1588 | - } | |
| 1589 | - } | |
| 1590 | - let want = need_w * need_h; | |
| 1591 | - let got = alloc.0 * alloc.1; | |
| 1592 | - if want > got { | |
| 1593 | - hit_do!(FRAME_CHROMA_ALLOC_SHORT_SAMPLES.with(|c| c.set(c.get() + want - got))); | |
| 1594 | - } | |
| 1595 | -} | |
| 1596 | - | |
| 1597 | -/// lane-av1ibcfork: this decoder's half of the per-unit BIT INTERVAL -- the | |
| 1598 | -/// exact mirror of the oracle's `EC_ECDUMP_IN` / `EC_ECDUMP_OUT` / | |
| 1599 | -/// `EC_ECDUMP_END` triple (`aom-oracle2/src/av1/decoder/decodetxb.c`: one | |
| 1600 | -/// print in `read_coeffs_txb` before and after its `aom_read_symbol`, one in | |
| 1601 | -/// the single caller `av1_read_coeffs_txb` after the whole unit). | |
| 1602 | -/// | |
| 1603 | -/// Why three prints and not one `EC_CENSUS_UNIT`: a COUNT is not a key. The | |
| 1604 | -/// two sides can walk a different NUMBER of units and still be paired, because | |
| 1605 | -/// the interval is what a unit CONSUMED. Entry position alone drifts the moment | |
| 1606 | -/// one side consumes a different number of bits, and list index is invalid the | |
| 1607 | -/// moment one side misses a unit -- both were measured here and both | |
| 1608 | -/// mis-attribute. `post_bit` after the `txb_skip` read is the same | |
| 1609 | -/// `aom_reader_tell` the oracle prints there; `end_bit` is the end of the whole | |
| 1610 | -/// unit including the optional luma `tx_type`, the eob, the base/BR passes and | |
| 1611 | -/// the sign/Golomb loop, so a unit that reads the right symbols in the wrong | |
| 1612 | -/// ORDER is caught too. | |
| 1613 | -/// | |
| 1614 | -/// `bit` counts the bits this decoder has pulled out of its window, so it sits | |
| 1615 | -/// at a CONSTANT offset from the oracle's tell (the OBU header libaom counts | |
| 1616 | -/// before `aom_reader_init`). The offset is measured per fixture, never | |
| 1617 | -/// assumed: +14 on `444_intrabc_rect4_witness.obu`. | |
| 1618 | -#[inline] | |
| 1619 | -fn unit_iv_on() -> bool { | |
| 1620 | - crate::envflags::env_flag!("EC_UNITIV") | |
| 1621 | -} | |
| 1622 | - | |
| 1623 | -/// The unit's ENTRY position. Returns it so the caller can pass the same value | |
| 1624 | -/// to [`unit_iv_skip`] and [`unit_iv_end`] without reading the decoder again. | |
| 1625 | -#[inline] | |
| 1626 | -#[track_caller] | |
| 1627 | -fn unit_iv_in(plane: usize, w: usize, h: usize, ctx: usize, dec: &SymbolDecoder) -> usize { | |
| 1628 | - if !unit_iv_on() { | |
| 1629 | - return 0; | |
| 1630 | - } | |
| 1631 | - let bit = dec.debug_bitpos(); | |
| 1632 | - let (mi_r, mi_c) = SymbolDecoder::symr_mi(); | |
| 1633 | - eprintln!( | |
| 1634 | - "EC_UNITIV_IN side=ours plane={plane} mi=({mi_r},{mi_c}) w={w} h={h} ctx={ctx} bit={bit} at {}", | |
| 1635 | - std::panic::Location::caller() | |
| 1636 | - ); | |
| 1637 | - bit | |
| 1638 | -} | |
| 1639 | - | |
| 1640 | -/// The position immediately after this unit's `txb_skip` read. `bit_in == | |
| 1641 | -/// post_bit` means the read consumed ZERO bits (a CDF row already at a | |
| 1642 | -/// boundary), so this is also the real-read filter: the reader logs a step | |
| 1643 | -/// either way, and counting raw lines overstates the symbol count ~2x (measured | |
| 1644 | -/// on `444_intrabc_rect4_witness.obu`: 2395 lines, 512 real reads, against the | |
| 1645 | -/// oracle's 513 -- not the "~1069 fewer" an earlier round reported). | |
| 1646 | -#[inline] | |
| 1647 | -fn unit_iv_skip( | |
| 1648 | - dec: &SymbolDecoder, | |
| 1649 | - bit_in: usize, | |
| 1650 | - plane: usize, | |
| 1651 | - w: usize, | |
| 1652 | - h: usize, | |
| 1653 | - ctx: usize, | |
| 1654 | - all_zero: bool, | |
| 1655 | -) { | |
| 1656 | - if !unit_iv_on() { | |
| 1657 | - return; | |
| 1658 | - } | |
| 1659 | - let (mi_r, mi_c) = SymbolDecoder::symr_mi(); | |
| 1660 | - eprintln!( | |
| 1661 | - "EC_UNITIV_SKIP side=ours plane={plane} mi=({mi_r},{mi_c}) w={w} h={h} ctx={ctx} az={} bit={bit_in} post_bit={}", | |
| 1662 | - all_zero as i32, | |
| 1663 | - dec.debug_bitpos() | |
| 1664 | - ); | |
| 1665 | -} | |
| 1666 | - | |
| 1667 | -/// The position after the WHOLE unit. One call per successful read, on both | |
| 1668 | -/// the all-zero early return and the full coefficient walk. | |
| 1669 | -#[inline] | |
| 1670 | -fn unit_iv_end(dec: &SymbolDecoder, plane: usize, w: usize, h: usize, ctx: usize) { | |
| 1671 | - if !unit_iv_on() { | |
| 1672 | - return; | |
| 1673 | - } | |
| 1674 | - let (mi_r, mi_c) = SymbolDecoder::symr_mi(); | |
| 1675 | - eprintln!( | |
| 1676 | - "EC_UNITIV_END side=ours plane={plane} mi=({mi_r},{mi_c}) w={w} h={h} ctx={ctx} end_bit={}", | |
| 1677 | - dec.debug_bitpos() | |
| 1678 | - ); | |
| 1679 | -} | |
| 1680 | - | |
| 1681 | 1358 | /// A just-decoded palette-Y block's own predicted pixels |
| 1682 | 1359 | /// (`side*side`, row-major, `colors[map[i]]`), consumed by |
| 1683 | 1360 | /// [`PlaneBuf::reconstruct`]'s next call in place of `predict()` -- the |
| @@ -1724,27 +1401,12 @@ fn palette_window( | ||
| 1724 | 1401 | /// `EC_DEBUG_PAL=1` traces every arm and every consumption with its call site. |
| 1725 | 1402 | #[track_caller] |
| 1726 | 1403 | fn set_palette_pred(buf: Vec<u16>, fctx: &crate::decode::FrameCtx) { |
| 1727 | - if crate::envflags::env_flag!("EC_DEBUG_PAL") { | |
| 1728 | - let stale = fctx.palette_pred.with(|c| c.borrow().is_some()); | |
| 1729 | - eprintln!( | |
| 1730 | - "PALSET len={} stale={stale} at {}", | |
| 1731 | - buf.len(), | |
| 1732 | - std::panic::Location::caller() | |
| 1733 | - ); | |
| 1734 | - } | |
| 1735 | 1404 | fctx.palette_pred.with(|c| *c.borrow_mut() = Some(buf)); |
| 1736 | 1405 | } |
| 1737 | 1406 | |
| 1738 | 1407 | #[track_caller] |
| 1739 | 1408 | fn take_palette_pred(fctx: &crate::decode::FrameCtx) -> Option<Vec<u16>> { |
| 1740 | 1409 | let got = fctx.palette_pred.with(|c| c.borrow_mut().take()); |
| 1741 | - if crate::envflags::env_flag!("EC_DEBUG_PAL") { | |
| 1742 | - eprintln!( | |
| 1743 | - "PALTAKE len={:?} at {}", | |
| 1744 | - got.as_ref().map(Vec::len), | |
| 1745 | - std::panic::Location::caller() | |
| 1746 | - ); | |
| 1747 | - } | |
| 1748 | 1410 | got |
| 1749 | 1411 | } |
| 1750 | 1412 | |
| @@ -1809,13 +1471,6 @@ pub(crate) struct TxParams { | ||
| 1809 | 1471 | /// ran on a frame that is NOT `CodedLossless`. |
| 1810 | 1472 | static LOSSLESS_WHT_UNITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); |
| 1811 | 1473 | |
| 1812 | -/// [`LOSSLESS_WHT_UNITS`] -- total over the process, read as a before/after | |
| 1813 | -/// delta around one decode. | |
| 1814 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1815 | -pub(crate) fn lossless_wht_units() -> usize { | |
| 1816 | - LOSSLESS_WHT_UNITS.load(std::sync::atomic::Ordering::Relaxed) | |
| 1817 | -} | |
| 1818 | - | |
| 1819 | 1474 | /// lane-whtshape: 4x4 Walsh-Hadamard units reconstructed as part of a LOSSLESS |
| 1820 | 1475 | /// transform unit that was itself NOT 4x4 -- a shape libaom cannot code. |
| 1821 | 1476 | /// `read_tx_mode` (`av1/decoder/decodeframe.c:140`) returns `ONLY_4X4` for a |
| @@ -1832,13 +1487,6 @@ pub(crate) fn lossless_wht_units() -> usize { | ||
| 1832 | 1487 | static LOSSLESS_WHT_SPLIT_UNITS: std::sync::atomic::AtomicUsize = |
| 1833 | 1488 | std::sync::atomic::AtomicUsize::new(0); |
| 1834 | 1489 | |
| 1835 | -/// [`LOSSLESS_WHT_SPLIT_UNITS`] -- total over the process, read as a | |
| 1836 | -/// before/after delta around one decode. | |
| 1837 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1838 | -pub(crate) fn lossless_wht_split_units() -> usize { | |
| 1839 | - LOSSLESS_WHT_SPLIT_UNITS.load(std::sync::atomic::Ordering::Relaxed) | |
| 1840 | -} | |
| 1841 | - | |
| 1842 | 1490 | impl TxParams { |
| 1843 | 1491 | /// The one copy of the produce-the-residual code. |
| 1844 | 1492 | fn run(self, grid: &[i32]) -> Vec<i32> { |
| @@ -2179,14 +1827,6 @@ fn push_mc_rect( | ||
| 2179 | 1827 | // localized a 4:4:4 intra-BC SKIP block committing its chroma plane block |
| 2180 | 1828 | // at `(px/2, py/2)` instead of the ss origin, clobbering a neighbouring |
| 2181 | 1829 | // block's reconstruction (lanes/av1ibcfork.report.md). |
| 2182 | - if crate::envflags::env_flag!("EC_MCPUSH") { | |
| 2183 | - eprintln!( | |
| 2184 | - "EC_MCPUSH plane={plane} x={x} y={cy} stride={stride} w={w} h={h} \ | |
| 2185 | - res_len={} at {}", | |
| 2186 | - residual.len(), | |
| 2187 | - std::panic::Location::caller() | |
| 2188 | - ); | |
| 2189 | - } | |
| 2190 | 1830 | let Some((src, stride)) = prediction.inline(stride) else { |
| 2191 | 1831 | let Pred::Cur { |
| 2192 | 1832 | plane: sp, |
| @@ -2501,7 +2141,7 @@ fn exec_mc( | ||
| 2501 | 2141 | 1 => &mut *u, |
| 2502 | 2142 | _ => &mut *v, |
| 2503 | 2143 | }; |
| 2504 | - target.reconstruct_mc_rect(x, oy, plane, stride, w, h, prediction, residual, fctx); | |
| 2144 | + target.reconstruct_mc_rect(x, oy, stride, w, h, prediction, residual, fctx); | |
| 2505 | 2145 | } |
| 2506 | 2146 | |
| 2507 | 2147 | // The `tx_type` the last plane-0 [`read_plane`] actually coded, kept so |
| @@ -2532,11 +2172,6 @@ thread_local! { | ||
| 2532 | 2172 | static RECT_INTRABC_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2533 | 2173 | } |
| 2534 | 2174 | |
| 2535 | -/// Current value of [`RECT_INTRABC_READS`]. | |
| 2536 | -pub(crate) fn rect_intrabc_reads() -> usize { | |
| 2537 | - RECT_INTRABC_READS.with(|c| c.get()) | |
| 2538 | -} | |
| 2539 | - | |
| 2540 | 2175 | thread_local! { |
| 2541 | 2176 | /// lane-av1-ibc128chunk: the mu-chunk walk's per-axis chroma extents, as |
| 2542 | 2177 | /// `(64 >> ss_x) << 8 | (64 >> ss_y)` on the LAST chunk -- the pair the |
| @@ -2546,12 +2181,6 @@ thread_local! { | ||
| 2546 | 2181 | const { std::cell::Cell::new(0) }; |
| 2547 | 2182 | } |
| 2548 | 2183 | |
| 2549 | -/// Current value of [`INTRABC_128RECT_CHUNK_SHAPE`]. | |
| 2550 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 2551 | -pub fn intrabc_128rect_chunk_shape() -> usize { | |
| 2552 | - INTRABC_128RECT_CHUNK_SHAPE.with(|c| c.get()) | |
| 2553 | -} | |
| 2554 | - | |
| 2555 | 2184 | /// Records one coded block into [`INTRABC_MI_GRID`]: every block contributes |
| 2556 | 2185 | /// its size (libaom's `scan_row_mbmi` advances `processed_rows` off any |
| 2557 | 2186 | /// candidate's `bsize`, ref-match or not), an intrabc one also its DV as an |
| @@ -2631,9 +2260,7 @@ fn record_intrabc_mi_rect( | ||
| 2631 | 2260 | |
| 2632 | 2261 | /// Bump [`FIMV_FRAME_HITS`] -- called once per decoded frame header whose |
| 2633 | 2262 | /// `force_integer_mv` bit is set. |
| 2634 | -pub fn note_force_integer_mv_frame() { | |
| 2635 | - hit!(FIMV_FRAME_HITS); | |
| 2636 | -} | |
| 2263 | +pub fn note_force_integer_mv_frame() {} | |
| 2637 | 2264 | |
| 2638 | 2265 | // lane-t900 r27: OBMC blends that actually READ a recorded switchable filter |
| 2639 | 2266 | // off the neighbour band -- the positive half of the proof for "an OBMC |
| @@ -2645,48 +2272,6 @@ thread_local! { | ||
| 2645 | 2272 | static OBMC_FILTER_BAND_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2646 | 2273 | } |
| 2647 | 2274 | |
| 2648 | -/// Current value of [`OBMC_FILTER_BAND_READS`]. | |
| 2649 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 2650 | -pub(crate) fn obmc_filter_band_reads() -> usize { | |
| 2651 | - OBMC_FILTER_BAND_READS.with(|c| c.get()) | |
| 2652 | -} | |
| 2653 | - | |
| 2654 | -/// lane-inter16ab r5: the six RECTANGULAR wedge shapes, in this order -- | |
| 2655 | -/// the counter slots of [`RECT_WEDGE_HITS`]/[`RECT_WII_HITS`]. | |
| 2656 | -pub(crate) const RECT_WEDGE_SHAPES: [(usize, usize); 6] = | |
| 2657 | - [(8, 16), (16, 8), (16, 32), (32, 16), (8, 32), (32, 8)]; | |
| 2658 | - | |
| 2659 | -fn rect_wedge_slot(bw: usize, bh: usize) -> Option<usize> { | |
| 2660 | - RECT_WEDGE_SHAPES.iter().position(|&s| s == (bw, bh)) | |
| 2661 | -} | |
| 2662 | - | |
| 2663 | -// lane-intra14 r1: set while an INTRA block of an INTER frame is decoded | |
| 2664 | -// through one of the key-frame rect readers ([`decode_block_rect4`], | |
| 2665 | -// [`decode_block_rect64`]). `Some((size_group, skip))` tells | |
| 2666 | -// [`read_intra_mode_rect`] that (a) `skip`/segment id/cdef/delta-q were | |
| 2667 | -// already read by [`decode_inter_block`] and (b) the luma mode comes off | |
| 2668 | -// `y_mode_cdf[size_group_lookup[bsize]]` (libaom `read_intra_block_mode_info`, | |
| 2669 | -// decodemv.c:1189), never the key frame's above/left `kf_y_mode` pair. | |
| 2670 | - | |
| 2671 | -// lane-modectx r1: how many times a `kf_y_mode`/`y_mode` neighbour read at a | |
| 2672 | -// TILE edge found its coarse fallback band holding a NON-DC mode -- i.e. a | |
| 2673 | -// mode from the previous tile, where libaom's `up_available`/`left_available` | |
| 2674 | -// make the neighbour DC_PRED. Measured 0 over 20 two-tile-column streams: | |
| 2675 | -// `above_mode` is cleared per tile in `Neighbours::start_tile` and `left_mode` | |
| 2676 | -// per superblock row in `start_row`, so the luma fallback cannot leak the way | |
| 2677 | -// lane-mtfix's `above_uv_mode` one did. The gate asserts it stays 0 -- this is | |
| 2678 | -// the invariant that makes the coarse fallback safe. | |
| 2679 | -thread_local! { | |
| 2680 | - static MODE_TILE_EDGE_COARSE_LEAKS: std::cell::Cell<usize> = | |
| 2681 | - const { std::cell::Cell::new(0) }; | |
| 2682 | -} | |
| 2683 | - | |
| 2684 | -/// Current value of [`MODE_TILE_EDGE_COARSE_LEAKS`]. | |
| 2685 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 2686 | -pub(crate) fn mode_tile_edge_coarse_leaks() -> usize { | |
| 2687 | - MODE_TILE_EDGE_COARSE_LEAKS.with(|c| c.get()) | |
| 2688 | -} | |
| 2689 | - | |
| 2690 | 2275 | thread_local! { |
| 2691 | 2276 | static UV_LEFT_SS_Y_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2692 | 2277 | } |
| @@ -2702,33 +2287,6 @@ thread_local! { | ||
| 2702 | 2287 | static UV_OWNER_EPOCH: std::cell::Cell<u32> = const { std::cell::Cell::new(0) }; |
| 2703 | 2288 | } |
| 2704 | 2289 | |
| 2705 | -fn bump_edge_part(slot: usize) { | |
| 2706 | - hit_do! { | |
| 2707 | - EDGE_PART_HITS.with(|c| { | |
| 2708 | - let mut h = c.get(); | |
| 2709 | - h[slot] += 1; | |
| 2710 | - c.set(h); | |
| 2711 | - }); | |
| 2712 | - } | |
| 2713 | -} | |
| 2714 | - | |
| 2715 | -/// [`bump_edge32`] of `base + bit`, returning the bit -- the gathered edge | |
| 2716 | -/// reads are `if`-conditions, so the counter has to ride the expression. | |
| 2717 | -fn bump_edge32_bit(base: usize, bit: usize) -> usize { | |
| 2718 | - bump_edge32(base + bit.min(1)); | |
| 2719 | - bit | |
| 2720 | -} | |
| 2721 | - | |
| 2722 | -fn bump_edge32(slot: usize) { | |
| 2723 | - hit_do! { | |
| 2724 | - EDGE32_HITS.with(|c| { | |
| 2725 | - let mut h = c.get(); | |
| 2726 | - h[slot] += 1; | |
| 2727 | - c.set(h) | |
| 2728 | - }); | |
| 2729 | - } | |
| 2730 | -} | |
| 2731 | - | |
| 2732 | 2290 | /// One 16x4 / 4x16 inter strip's chroma situation, handed to |
| 2733 | 2291 | /// [`decode_inter_block`] out of band (the same one-shot thread-local idiom |
| 2734 | 2292 | /// `REDUCED_TX_SET_INTER` uses) rather than through twenty-three call sites |
| @@ -2750,18 +2308,6 @@ pub(crate) struct InterStripChroma { | ||
| 2750 | 2308 | prev: Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>, |
| 2751 | 2309 | } |
| 2752 | 2310 | |
| 2753 | -/// The single-reference MC parameters of the inter block that decoded | |
| 2754 | -/// last -- read by the next 1:4 strip to build its pair's chroma. | |
| 2755 | -fn bump_ab16_inter(arm: usize) { | |
| 2756 | - hit_do! { | |
| 2757 | - AB16_INTER_HITS.with(|c| { | |
| 2758 | - let mut v = c.get(); | |
| 2759 | - v[arm] += 1; | |
| 2760 | - c.set(v); | |
| 2761 | - }); | |
| 2762 | - } | |
| 2763 | -} | |
| 2764 | - | |
| 2765 | 2311 | /// Everything [`decode_inter_block`] needs to fold temporal MV candidates |
| 2766 | 2312 | /// (spec 7.10.2.8), threaded down from [`decode_inter_frame_tile_with_cdfs`]: |
| 2767 | 2313 | /// the current frame's own projected field ([`crate::motion_field::setup_motion_field`]'s |
| @@ -2874,12 +2420,6 @@ pub(crate) fn build_motion_field( | ||
| 2874 | 2420 | crate::par::run_bands_mut(&bands, cols, fctx, cells, |r0, r1, mine, _| { |
| 2875 | 2421 | fill(r0, r1, mine); |
| 2876 | 2422 | }); |
| 2877 | - if crate::envflags::env_flag!("EC_TRACE_TPL") { | |
| 2878 | - eprintln!("EC_TPL_SAVED oh={order_hint}"); | |
| 2879 | - for (r, row) in field.occupancy().iter().enumerate() { | |
| 2880 | - eprintln!("EC_TPL_SAVED r{r} {row}"); | |
| 2881 | - } | |
| 2882 | - } | |
| 2883 | 2423 | field |
| 2884 | 2424 | } |
| 2885 | 2425 | |
| @@ -2923,38 +2463,12 @@ pub fn cdef_mixed_skip_units() -> usize { | ||
| 2923 | 2463 | CDEF_MIXED_SKIP_UNITS.with(|c| c.get()) |
| 2924 | 2464 | } |
| 2925 | 2465 | |
| 2926 | -/// Current value of `CDEF_SKIPPED_UNITS`. | |
| 2927 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 2928 | -pub(crate) fn cdef_skipped_units() -> usize { | |
| 2929 | - CDEF_SKIPPED_UNITS.with(|c| c.get()) | |
| 2930 | -} | |
| 2931 | - | |
| 2932 | 2466 | /// How many 8x8 CDEF units [`apply_cdef`] visited whose skip band no coded |
| 2933 | 2467 | /// block wrote this frame -- a writer gap, always a defect (lane-cdefstrip r1). |
| 2934 | 2468 | pub fn cdef_unwritten_skip_units() -> usize { |
| 2935 | 2469 | CDEF_UNWRITTEN_SKIP_UNITS.with(|c| c.get()) |
| 2936 | 2470 | } |
| 2937 | 2471 | |
| 2938 | -/// Current value of `CDEF_STRADDLE_UNITS`. | |
| 2939 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 2940 | -pub(crate) fn cdef_straddle_units() -> usize { | |
| 2941 | - CDEF_STRADDLE_UNITS.with(|c| c.get()) | |
| 2942 | -} | |
| 2943 | - | |
| 2944 | -fn note_sub8_chroma_tx(first_sub: TxType, chroma_ref: TxType, coeffs: bool) { | |
| 2945 | - if coeffs && first_sub != chroma_ref { | |
| 2946 | - hit!(SUB8_CHROMA_TX_FROM_REF_HITS); | |
| 2947 | - } | |
| 2948 | -} | |
| 2949 | - | |
| 2950 | -/// Counts one [`CHROMA_EOB_CLASS1_HITS`] when `plane_idx`'s inherited | |
| 2951 | -/// `tx_type` put this block's `eob_pt` on the class-1 row. | |
| 2952 | -fn note_chroma_class1(plane_idx: usize, tx_type: TxType) { | |
| 2953 | - if plane_idx > 0 && TxClass::of(tx_type) != TxClass::TwoD { | |
| 2954 | - hit!(CHROMA_EOB_CLASS1_HITS); | |
| 2955 | - } | |
| 2956 | -} | |
| 2957 | - | |
| 2958 | 2472 | // Which plane the in-flight INTRA reconstruction is writing (0=Y, 1=U, 2=V). |
| 2959 | 2473 | // lane-av1cmpaudit: aomdec's `EC_PREDOUT8`/`EC_PREDND` print `plane=`, and |
| 2960 | 2474 | // without the same field on our side an `EC_PREDOUT8` vs `OUR_PRED` diff of a |
| @@ -2966,11 +2480,6 @@ thread_local! { | ||
| 2966 | 2480 | static RECON_PLANE: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2967 | 2481 | } |
| 2968 | 2482 | |
| 2969 | -/// The plane index the `EC_PRED` rung prints as `plane=`. | |
| 2970 | -fn recon_plane() -> usize { | |
| 2971 | - RECON_PLANE.with(std::cell::Cell::get) | |
| 2972 | -} | |
| 2973 | - | |
| 2974 | 2483 | /// Restores [`RECON_PLANE`] on drop, so `exec_intra` needs no cleanup path on |
| 2975 | 2484 | /// either of its two early returns. |
| 2976 | 2485 | struct PlaneGuard(usize); |
| @@ -3030,12 +2539,6 @@ const MAX_BR_LEVEL: i32 = NUM_BASE_LEVELS + COEFF_BASE_RANGE; | ||
| 3030 | 2539 | const VERT_ALIKE: [usize; 6] = [2, PARTITION_SPLIT, 4, 6, 7, 9]; |
| 3031 | 2540 | const HORZ_ALIKE: [usize; 6] = [1, PARTITION_SPLIT, 4, 5, 6, 8]; |
| 3032 | 2541 | |
| 3033 | -fn trace_edge(mi_r: usize, mi_c: usize, bsize: u32, ctx: usize, rng: u32) { | |
| 3034 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 3035 | - eprintln!("OUR_PART mi_row={mi_r} mi_col={mi_c} bsize={bsize} ctx={ctx} rng={rng}"); | |
| 3036 | - } | |
| 3037 | -} | |
| 3038 | - | |
| 3039 | 2542 | fn element_prob(cdf: &[u16], element: usize) -> u16 { |
| 3040 | 2543 | cdf[element] - if element > 0 { cdf[element - 1] } else { 0 } |
| 3041 | 2544 | } |
| @@ -3241,9 +2744,6 @@ fn base_ctx( | ||
| 3241 | 2744 | // once; `base_ctx_rect_offsets_match_the_transcribed_tables_over_the_whole_domain` |
| 3242 | 2745 | // pins the rule against the tables over their whole 5x5 domain. |
| 3243 | 2746 | if let Some((w, h)) = rect_shape { |
| 3244 | - if crate::envflags::env_flag!("EC_NZOFF_DUMP") { | |
| 3245 | - eprintln!("NZOFF stride={stride} shape={w}x{h} row={row} col={col}"); | |
| 3246 | - } | |
| 3247 | 2747 | if w < h && row < 2 { |
| 3248 | 2748 | return ctx + 11; |
| 3249 | 2749 | } |
| @@ -3657,7 +3157,6 @@ fn read_eob(dec: &mut SymbolDecoder, coding: &mut TxbTables, class: TxClass) -> | ||
| 3657 | 3157 | const GROUP_START: [usize; 12] = [0, 1, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513]; |
| 3658 | 3158 | const OFFSET_BITS: [u32; 12] = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
| 3659 | 3159 | |
| 3660 | - let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); | |
| 3661 | 3160 | // libaom's `eob_flag_cdf*` tables carry a second dimension the 2D scan |
| 3662 | 3161 | // never touches: `TX_CLASS_HORIZ`/`TX_CLASS_VERT` (`V_DCT`/`H_DCT`) adapt |
| 3663 | 3162 | // a wholly separate CDF from every other tx_type (`decodetxb.c`'s |
| @@ -3668,22 +3167,11 @@ fn read_eob(dec: &mut SymbolDecoder, coding: &mut TxbTables, class: TxClass) -> | ||
| 3668 | 3167 | (TxClass::TwoD, _) | (_, None) => coding.eob_pt, |
| 3669 | 3168 | (_, Some(class1)) => class1, |
| 3670 | 3169 | }; |
| 3671 | - if crate::envflags::env_flag!("EC_AV1_EOBPT_CDF") { | |
| 3672 | - let (range, value) = dec.debug_state(); | |
| 3673 | - eprintln!("EC_AV1_EOBPT_CDF {eob_pt:?} range={range} value={value}"); | |
| 3674 | - } | |
| 3675 | - crate::msac::SymbolDecoder::set_symr_cdf("eob_pt"); | |
| 3676 | 3170 | let group = dec.symbol(eob_pt) + 1; |
| 3677 | - if trace { | |
| 3678 | - eprintln!("TRACE eob_pt value={group} rng={}", dec.debug_state().0); | |
| 3679 | - } | |
| 3680 | 3171 | let bits = OFFSET_BITS[group]; |
| 3681 | 3172 | let mut offset = 0u32; |
| 3682 | 3173 | if bits > 0 { |
| 3683 | 3174 | let top = dec.symbol(&mut coding.eob_extra[group - 3]) as u32; |
| 3684 | - if trace { | |
| 3685 | - eprintln!("TRACE eob_extra ctx={} value={top}", group - 3); | |
| 3686 | - } | |
| 3687 | 3175 | offset = top << (bits - 1); |
| 3688 | 3176 | if bits > 1 { |
| 3689 | 3177 | offset |= dec.literal(bits - 1); |
| @@ -3792,6 +3280,3 @@ pub(crate) fn decode_key_frame_tile( | ||
| 3792 | 3280 | |
| 3793 | 3281 | #[cfg(test)] |
| 3794 | 3282 | mod tests; |
| 3795 | - | |
| 3796 | -#[cfg(test)] | |
| 3797 | -mod tx4x8_table_tests; |
crates/ec-av1/src/decode/obmc_skip_chroma_tests.rsdeleted+0 -27
| @@ -1,27 +0,0 @@ | ||
| 1 | -use super::obmc_skip_chroma_above; | |
| 2 | - | |
| 3 | -/// lane-av1-llpred2: the above-chroma skip keys off the PLANE block | |
| 4 | -/// under the frame's own ss pair. At 4:2:0 a 16x8/8x16 rect strip's | |
| 5 | -/// plane block is 8x4/4x8 and MUST still skip (the old `chroma_side` | |
| 6 | -/// ratio read ss=(1,0) off a 16x8 strip and made it blend); at 4:4:4 | |
| 7 | -/// the plane block is the luma block, so only true 4-wide/high shapes | |
| 8 | -/// skip and the shift never leaves `usize` range (the old ratio's | |
| 9 | -/// `trailing_zeros(0)` = 64 panicked a debug build). | |
| 10 | -#[test] | |
| 11 | -fn rect_strips_skip_above_chroma_at_420_and_shift_never_overflows() { | |
| 12 | - // 4:2:0 (ss 1,1): 8x8 -> 4x4, 16x8 -> 8x4, 8x16 -> 4x8 all skip. | |
| 13 | - assert!(obmc_skip_chroma_above(8, 8, 1, 1)); | |
| 14 | - assert!(obmc_skip_chroma_above(16, 8, 1, 1)); | |
| 15 | - assert!(obmc_skip_chroma_above(8, 16, 1, 1)); | |
| 16 | - // ... larger plane blocks blend, exactly libaom's own list. | |
| 17 | - assert!(!obmc_skip_chroma_above(16, 16, 1, 1)); | |
| 18 | - assert!(!obmc_skip_chroma_above(32, 16, 1, 1)); | |
| 19 | - assert!(!obmc_skip_chroma_above(16, 32, 1, 1)); | |
| 20 | - // 4:4:4 (ss 0,0): the plane block is the luma block itself. | |
| 21 | - assert!(obmc_skip_chroma_above(4, 4, 0, 0)); | |
| 22 | - assert!(obmc_skip_chroma_above(8, 4, 0, 0)); | |
| 23 | - assert!(obmc_skip_chroma_above(4, 8, 0, 0)); | |
| 24 | - assert!(!obmc_skip_chroma_above(8, 8, 0, 0)); | |
| 25 | - assert!(!obmc_skip_chroma_above(16, 8, 0, 0)); | |
| 26 | - assert!(!obmc_skip_chroma_above(8, 16, 0, 0)); | |
| 27 | -} |
crates/ec-av1/src/decode/post_filter.rsmodified+10 -20
| @@ -32,7 +32,6 @@ fn cdef_rows( | ||
| 32 | 32 | coeff_shift: i32, |
| 33 | 33 | damping: i32, |
| 34 | 34 | damping_uv: i32, |
| 35 | - (frame_w, frame_h): (usize, usize), | |
| 36 | 35 | r_lo0: usize, |
| 37 | 36 | r_hi0: usize, |
| 38 | 37 | fctx: &crate::decode::FrameCtx, |
| @@ -68,16 +67,16 @@ fn cdef_rows( | ||
| 68 | 67 | .enumerate() |
| 69 | 68 | .map(|(k, &(a, b))| { |
| 70 | 69 | let start = row_of(a, p) * geom[p].stride; |
| 71 | - let end = if k == last { len } else { row_of(b, p) * geom[p].stride }; | |
| 70 | + let end = if k == last { | |
| 71 | + len | |
| 72 | + } else { | |
| 73 | + row_of(b, p) * geom[p].stride | |
| 74 | + }; | |
| 72 | 75 | (start, end) |
| 73 | 76 | }) |
| 74 | 77 | .collect() |
| 75 | 78 | }; |
| 76 | - let (yd, ud, vd) = ( | |
| 77 | - y.data.to_mut(), | |
| 78 | - u.data.to_mut(), | |
| 79 | - v.data.to_mut(), | |
| 80 | - ); | |
| 79 | + let (yd, ud, vd) = (y.data.to_mut(), u.data.to_mut(), v.data.to_mut()); | |
| 81 | 80 | let (ry, ru, rv) = ( |
| 82 | 81 | plane_ranges(0, yd.len()), |
| 83 | 82 | plane_ranges(1, ud.len()), |
| @@ -97,7 +96,10 @@ fn cdef_rows( | ||
| 97 | 96 | (start, end) |
| 98 | 97 | }) |
| 99 | 98 | .collect(); |
| 100 | - crate::par::carve_ranges(w, &ranges).into_iter().map(Some).collect() | |
| 99 | + crate::par::carve_ranges(w, &ranges) | |
| 100 | + .into_iter() | |
| 101 | + .map(Some) | |
| 102 | + .collect() | |
| 101 | 103 | } |
| 102 | 104 | None => (0..n).map(|_| None).collect(), |
| 103 | 105 | }; |
| @@ -130,7 +132,6 @@ fn cdef_rows( | ||
| 130 | 132 | coeff_shift, |
| 131 | 133 | damping, |
| 132 | 134 | damping_uv, |
| 133 | - (frame_w, frame_h), | |
| 134 | 135 | fctx, |
| 135 | 136 | ); |
| 136 | 137 | }); |
| @@ -144,9 +145,6 @@ pub(super) fn apply_cdef( | ||
| 144 | 145 | v: &mut PlaneBuf<'static>, |
| 145 | 146 | cdef: &CdefParams, |
| 146 | 147 | skip_grid: &Neighbours, |
| 147 | - // This frame header's own CROPPED luma size, for the straddling-unit | |
| 148 | - // counter only -- CDEF itself walks the mi-rounded plane. | |
| 149 | - (frame_w, frame_h): (usize, usize), | |
| 150 | 148 | fctx: &crate::decode::FrameCtx, |
| 151 | 149 | // lane-av1cap: every CDEF unit reads the PRE-CDEF planes, so the filter |
| 152 | 150 | // starts by copying all three (~19 MB at 4K). The encoder's filter |
| @@ -161,10 +159,6 @@ pub(super) fn apply_cdef( | ||
| 161 | 159 | wrote: Option<&mut [u8]>, |
| 162 | 160 | ) { |
| 163 | 161 | // lane-part32 r2 debug rung, env-gated: see `apply_deblock`'s sibling. |
| 164 | - if crate::envflags::env_flag!("EC_AV1_DEBUG_SKIP_CDEF") { | |
| 165 | - return; | |
| 166 | - } | |
| 167 | - cdef_scan_counters(skip_grid); | |
| 168 | 162 | // `cdef.bits == 0` still means "no filtering at all" whenever the single |
| 169 | 163 | // (index 0) strength pair is all-zero -- the fast path every existing |
| 170 | 164 | // gate stream takes. A `bits > 0` frame can still be all-zero-strength |
| @@ -215,7 +209,6 @@ pub(super) fn apply_cdef( | ||
| 215 | 209 | coeff_shift, |
| 216 | 210 | damping, |
| 217 | 211 | damping_uv, |
| 218 | - (frame_w, frame_h), | |
| 219 | 212 | 0, |
| 220 | 213 | skip_grid.mi_rows, |
| 221 | 214 | fctx, |
| @@ -296,9 +289,6 @@ pub(super) fn apply_loop_restoration( | ||
| 296 | 289 | fctx: &crate::decode::FrameCtx, |
| 297 | 290 | ) { |
| 298 | 291 | // lane-svt1 debug rung, env-gated: see `apply_cdef`/`apply_deblock`'s siblings. |
| 299 | - if crate::envflags::env_flag!("EC_AV1_DEBUG_SKIP_LR") { | |
| 300 | - return; | |
| 301 | - } | |
| 302 | 292 | let mut out = scratch_empty(); |
| 303 | 293 | crate::restoration::apply_loop_restoration_plane( |
| 304 | 294 | &y.data, |
crates/ec-av1/src/decode/rect.rsmodified+5 -506
| @@ -61,42 +61,15 @@ pub(super) fn read_intra_mode_rect( | ||
| 61 | 61 | // `palette_uv` even on a chroma-reference strip. Fold the plane count |
| 62 | 62 | // into the same `has_chroma` this reader already gates on. |
| 63 | 63 | let has_chroma = has_chroma && !mono(fctx); |
| 64 | - crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64); | |
| 65 | - let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); | |
| 66 | - if ec_istep { | |
| 67 | - // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line | |
| 68 | - // (decodemv.c:818), printed at the same point: before the first | |
| 69 | - // mode-info symbol of the block, so a cross-decoder range ladder can | |
| 70 | - // be keyed on the BLOCK, not just on the symbol sequence. | |
| 71 | - eprintln!( | |
| 72 | - "EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=rect bw={bw} bh={bh} efi={} cls={:?} rng={}", | |
| 73 | - enable_filter_intra as i32, | |
| 74 | - filter_intra_size_class_rect(bw, bh), | |
| 75 | - dec.debug_state().0 | |
| 76 | - ); | |
| 77 | - } | |
| 78 | 64 | macro_rules! istep { |
| 79 | - ($name:literal, $val:expr) => { | |
| 80 | - if ec_istep { | |
| 81 | - let (rng, _) = dec.debug_state(); | |
| 82 | - eprintln!( | |
| 83 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name={} val={} rng={rng}", | |
| 84 | - $name, $val | |
| 85 | - ); | |
| 86 | - } | |
| 87 | - }; | |
| 65 | + ($name:literal, $val:expr) => {}; | |
| 88 | 66 | } |
| 89 | 67 | // lane-sbrect10 r1: libaom `is_cfl_allowed` (blockd.h) is |
| 90 | 68 | // `block_size_wide <= 32 && block_size_high <= 32` -- enforce it HERE, at |
| 91 | 69 | // the one point every rect caller routes through, so no call site can |
| 92 | 70 | // offer the 14-symbol CFL alphabet on a 64-axis block (class |
| 93 | 71 | // wrong-alphabet-same-value: same value, wrong interval, silent desync). |
| 94 | - let cfl = if cfl && bw.max(bh) > 32 { | |
| 95 | - hit!(NOCFL_UV_MODE_HITS); | |
| 96 | - false | |
| 97 | - } else { | |
| 98 | - cfl | |
| 99 | - }; | |
| 72 | + let cfl = if cfl && bw.max(bh) > 32 { false } else { cfl }; | |
| 100 | 73 | // lane-intra14 r1: on the INTER block path everything up to and including |
| 101 | 74 | // `is_inter` was already read by [`decode_inter_block`], so this reader |
| 102 | 75 | // starts at the mode syntax with the `skip` that caller read. |
| @@ -134,10 +107,8 @@ pub(super) fn read_intra_mode_rect( | ||
| 134 | 107 | // refused by name when it fires. |
| 135 | 108 | if allow_intrabc_frame(fctx) { |
| 136 | 109 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; |
| 137 | - hit!(RECT_INTRABC_READS); | |
| 138 | 110 | istep!("intrabc", use_intrabc as i32); |
| 139 | 111 | if use_intrabc { |
| 140 | - hit!(INTRABC_HITS); | |
| 141 | 112 | // libaom `read_intrabc_info`: the DV read, then an immediate |
| 142 | 113 | // return out of the mode-info read -- no `y_mode`, no `uv_mode`, |
| 143 | 114 | // no angle deltas, no palette, no filter intra. The caller owns |
| @@ -163,7 +134,6 @@ pub(super) fn read_intra_mode_rect( | ||
| 163 | 134 | // frame's `read_intra_frame_mode_info` (decodemv.c:1065 `read_intra_mode` |
| 164 | 135 | // off `kf_y_mode_cdf[above][left]`). |
| 165 | 136 | let mode = if let Some((size_group, _)) = inter { |
| 166 | - crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | |
| 167 | 137 | dec.symbol(&mut cdfs.y_mode[size_group]) |
| 168 | 138 | } else { |
| 169 | 139 | let above_ctx = INTRA_MODE_CTX[above_mode]; |
| @@ -188,10 +158,8 @@ pub(super) fn read_intra_mode_rect( | ||
| 188 | 158 | let uv_mode = if !has_chroma { |
| 189 | 159 | DC_PRED |
| 190 | 160 | } else if cfl { |
| 191 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 192 | 161 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 193 | 162 | } else { |
| 194 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 195 | 163 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 196 | 164 | }; |
| 197 | 165 | istep!("uv_mode", uv_mode as i32); |
| @@ -200,19 +168,12 @@ pub(super) fn read_intra_mode_rect( | ||
| 200 | 168 | } else { |
| 201 | 169 | None |
| 202 | 170 | }; |
| 203 | - if has_chroma && (9..=12).contains(&uv_mode) { | |
| 204 | - hit!(SMOOTH_UV_HITS); | |
| 205 | - } | |
| 206 | 171 | let angle_delta_uv = if has_chroma && (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 207 | - hit!(DIRECTIONAL_UV_HITS); | |
| 208 | 172 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 209 | 173 | } else { |
| 210 | 174 | 0 |
| 211 | 175 | }; |
| 212 | 176 | istep!("angle_uv", angle_delta_uv); |
| 213 | - if angle_delta_uv != 0 { | |
| 214 | - hit!(UV_ANGLE_DELTA_HITS); | |
| 215 | - } | |
| 216 | 177 | // `read_palette_mode_info` (spec 5.11.13), rect-generalised |
| 217 | 178 | // (lane-palette2 r4): same bsize-ctx-gated read as [`read_intra_mode`], |
| 218 | 179 | // just keyed by [`palette_bsize_ctx_wh`] instead of the square-only |
| @@ -223,10 +184,6 @@ pub(super) fn read_intra_mode_rect( | ||
| 223 | 184 | let mut palette_y_pending: Option<(usize, [u16; 8])> = None; |
| 224 | 185 | let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; |
| 225 | 186 | if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh) { |
| 226 | - // r6: this is the exact site the removed blanket refusal used to | |
| 227 | - // guard -- reached for EVERY rect strip in a screen-content frame, | |
| 228 | - // independent of whether the block ends up using a palette. | |
| 229 | - hit!(RECT_SCREEN_CONTENT_HITS); | |
| 230 | 187 | let (mode_ctx, cache) = palette.unwrap_or((0, &[])); |
| 231 | 188 | let use_palette_y = |
| 232 | 189 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][mode_ctx]) != 0; |
| @@ -247,15 +204,6 @@ pub(super) fn read_intra_mode_rect( | ||
| 247 | 204 | } |
| 248 | 205 | } |
| 249 | 206 | let mut filter_intra = None; |
| 250 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 251 | - let (rng, _) = dec.debug_state(); | |
| 252 | - eprintln!( | |
| 253 | - "TRACE_RECT_PREFI mode={mode} uv_mode={uv_mode} enable_filter_intra={} \ | |
| 254 | - class={:?} rng={rng}", | |
| 255 | - enable_filter_intra as i32, | |
| 256 | - filter_intra_size_class_rect(bw, bh) | |
| 257 | - ); | |
| 258 | - } | |
| 259 | 207 | // As the square path: `av1_filter_intra_allowed` excludes a palette-Y |
| 260 | 208 | // block (reconintra.h:77), so no `use_filter_intra` symbol exists there. |
| 261 | 209 | if mode == DC_PRED |
| @@ -264,12 +212,8 @@ pub(super) fn read_intra_mode_rect( | ||
| 264 | 212 | && let Some(class) = filter_intra_size_class_rect(bw, bh) |
| 265 | 213 | { |
| 266 | 214 | let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[class]) != 0; |
| 267 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 268 | - eprintln!("TRACE_RECT_USEFI value={}", use_filter_intra as i32); | |
| 269 | - } | |
| 270 | 215 | istep!("use_filter_intra", use_filter_intra as i32); |
| 271 | 216 | if use_filter_intra { |
| 272 | - hit!(FILTER_INTRA_HITS); | |
| 273 | 217 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 274 | 218 | istep!("filter_intra_mode", fi_mode as i32); |
| 275 | 219 | filter_intra = Some(fi_mode); |
| @@ -287,8 +231,6 @@ pub(super) fn read_intra_mode_rect( | ||
| 287 | 231 | palette_onscreen(mi_r, mi_c, bw, bh, fctx), |
| 288 | 232 | false, |
| 289 | 233 | ); |
| 290 | - hit!(PALETTE_HITS); | |
| 291 | - hit!(PALETTE_RECT_HITS); | |
| 292 | 234 | PaletteY { |
| 293 | 235 | size: n, |
| 294 | 236 | colors, |
| @@ -309,7 +251,6 @@ pub(super) fn read_intra_mode_rect( | ||
| 309 | 251 | (ss_x(fctx), ss_y(fctx)), |
| 310 | 252 | ); |
| 311 | 253 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true); |
| 312 | - hit!(PALETTE_UV_HITS); | |
| 313 | 254 | PaletteUv { |
| 314 | 255 | size: n, |
| 315 | 256 | u_colors, |
| @@ -352,9 +293,6 @@ pub(super) fn record_strip_palette( | ||
| 352 | 293 | // the neighbour bands (`EC_PALPUB=1`) -- the rung that names which decode |
| 353 | 294 | // path left a stale `left_palette_size` behind when |
| 354 | 295 | // `av1_get_palette_mode_ctx` disagrees with libaom's. |
| 355 | - if crate::envflags::env_flag!("EC_PALPUB") { | |
| 356 | - eprintln!("EC_PALPUB strip mi={r},{c} bw={bw} bh={bh} y={y_size} uv={uv_size}"); | |
| 357 | - } | |
| 358 | 296 | // lane-kf900 r6: the palette side bands are mi-granular now, so a strip |
| 359 | 297 | // writes its OWN span on BOTH axes -- the old `last` split-axis rule only |
| 360 | 298 | // existed because the 16px [`SUB`] cell held one slot for all the strips |
| @@ -521,17 +459,12 @@ pub(super) fn decode_rect_split( | ||
| 521 | 459 | at_mi: (usize, usize), |
| 522 | 460 | bw: usize, |
| 523 | 461 | bh: usize, |
| 524 | - // The transform unit's own width and height in pixels. Square for every | |
| 525 | - // 2:1 strip from the first split on, but a 1:4 strip's FIRST split is | |
| 526 | - // still a 2:1 RECT unit (`sub_tx_size_map[TX_32X8] == TX_16X8`, | |
| 527 | - // `[TX_64X16] == TX_32X16`) -- see [`depth_to_tx_wh`]. | |
| 528 | 462 | tx_w: usize, |
| 529 | 463 | tx_h: usize, |
| 530 | 464 | m: &RectStripModes, |
| 531 | 465 | y: &mut PlaneBuf<'static>, |
| 532 | 466 | u: &mut PlaneBuf<'static>, |
| 533 | 467 | v: &mut PlaneBuf<'static>, |
| 534 | - base_q_idx: u8, | |
| 535 | 468 | reduced_tx_set: bool, |
| 536 | 469 | fctx: &crate::decode::FrameCtx, |
| 537 | 470 | ) -> Result<()> { |
| @@ -610,32 +543,6 @@ pub(super) fn decode_rect_split( | ||
| 610 | 543 | (chroma_w, chroma_h), |
| 611 | 544 | (64, 32) | (32, 64) | (64, 16) | (16, 64) | (32, 32) | (16, 16) | (8, 8) |
| 612 | 545 | ); |
| 613 | - if !m.skip { | |
| 614 | - if let Some(i) = match (chroma_w, chroma_h) { | |
| 615 | - (32, 8) => Some(0), | |
| 616 | - (8, 32) => Some(1), | |
| 617 | - (8, 4) => Some(2), | |
| 618 | - (4, 8) => Some(3), | |
| 619 | - _ => None, | |
| 620 | - } { | |
| 621 | - hit_do! { | |
| 622 | - RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| { | |
| 623 | - let mut hits = c.get(); | |
| 624 | - hits[i] += 1; | |
| 625 | - c.set(hits); | |
| 626 | - }); | |
| 627 | - } | |
| 628 | - } | |
| 629 | - if !m.skip && chroma.is_none() && !chroma_tiled { | |
| 630 | - // Diagnostic for the next caller that lands here (class | |
| 631 | - // refusal-names-a-correlate: the message names the tool, not the | |
| 632 | - // shape); the refusal below keeps its inventory-pinned wording. | |
| 633 | - eprintln!( | |
| 634 | - "EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx_w}x{tx_h} \ | |
| 635 | - chroma={chroma_w}x{chroma_h}" | |
| 636 | - ); | |
| 637 | - } | |
| 638 | - } | |
| 639 | 546 | // lane-rectsplit r2 (verifier finding): with both callers wired |
| 640 | 547 | // (`decode_block_rect`'s 32x16/16x32 and `decode_block_rect64`'s |
| 641 | 548 | // 64x32/32x64) every shape that reaches here has a table above, so this |
| @@ -648,10 +555,6 @@ pub(super) fn decode_rect_split( | ||
| 648 | 555 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 649 | 556 | )); |
| 650 | 557 | } |
| 651 | - hit!(RECT_SPLIT_TX_HITS); | |
| 652 | - if bw.max(bh) == 64 && bw / tx_w > 1 && bh / tx_h > 1 { | |
| 653 | - hit!(RECT_SPLIT_SB_INTERIOR_TU_HITS); | |
| 654 | - } | |
| 655 | 558 | // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. |
| 656 | 559 | // A square unit reads through the ordinary square [`read_plane`]; a rect |
| 657 | 560 | // one (a 1:4 strip's first split) reads through [`read_coeffs_rect`] with |
| @@ -783,16 +686,6 @@ pub(super) fn decode_rect_split( | ||
| 783 | 686 | // (`av1_get_ext_tx_set_type` resolves EXT_TX_SET_DCTONLY once |
| 784 | 687 | // the square-up size is TX_64X64), and this unit covers its |
| 785 | 688 | // whole block, so `get_txb_ctx` gives txb_skip ctx 0 flat. |
| 786 | - if crate::envflags::env_flag!("EC_RECT64TU") { | |
| 787 | - eprintln!("EC_RECT64TU mi={tu_mi:?} tx={tx_w}x{tx_h} mode={}", m.mode); | |
| 788 | - } | |
| 789 | - hit_do! { | |
| 790 | - RECT64_CORNER_TU_HITS.with(|c| { | |
| 791 | - let mut v = c.get(); | |
| 792 | - v[usize::from(tx_h > tx_w)] += 1; | |
| 793 | - c.set(v); | |
| 794 | - }); | |
| 795 | - } | |
| 796 | 689 | let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; |
| 797 | 690 | let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra)); |
| 798 | 691 | let (corner, tu_tx_type) = read_coeffs( |
| @@ -870,7 +763,6 @@ pub(super) fn decode_rect_split( | ||
| 870 | 763 | tu_skip_ctx, |
| 871 | 764 | dc_sign_ctx(tu_around.2), |
| 872 | 765 | TxType::DctDct, |
| 873 | - 0, | |
| 874 | 766 | )?; |
| 875 | 767 | let residual = dequant_and_inverse_typed_wh( |
| 876 | 768 | &tu_grid, |
| @@ -926,7 +818,6 @@ pub(super) fn decode_rect_split( | ||
| 926 | 818 | tu_py, |
| 927 | 819 | tx_w, |
| 928 | 820 | tx_w, |
| 929 | - base_q_idx, | |
| 930 | 821 | None, |
| 931 | 822 | m.filter_intra, |
| 932 | 823 | Some(tu_skip_ctx), |
| @@ -1122,7 +1013,6 @@ pub(super) fn decode_rect_split( | ||
| 1122 | 1013 | // `REFUSED: unsupported: AV1 tile (a Golomb tail longer |
| 1123 | 1014 | // than this decoder reads)`. |
| 1124 | 1015 | if cpx + cu_col * 4 >= u.true_width || cpy + cu_row * 4 >= u.true_height { |
| 1125 | - hit!(RECT_SPLIT_LOSSLESS_CHROMA_OFFTILE_HITS); | |
| 1126 | 1016 | continue; |
| 1127 | 1017 | } |
| 1128 | 1018 | let cu_mi = (mi_r + cu_row * (span_y / MI), mi_c + cu_col * (span_x / MI)); |
| @@ -1154,11 +1044,6 @@ pub(super) fn decode_rect_split( | ||
| 1154 | 1044 | cu_row * span_y, |
| 1155 | 1045 | span_x, |
| 1156 | 1046 | block_reach, |
| 1157 | - px, | |
| 1158 | - py, | |
| 1159 | - y.width, | |
| 1160 | - y.height, | |
| 1161 | - fctx, | |
| 1162 | 1047 | ); |
| 1163 | 1048 | let (cu_x, cu_y) = (cpx + cu_col * 4, cpy + cu_row * 4); |
| 1164 | 1049 | if let Some((ub, vb)) = &m.palette_uv { |
| @@ -1186,7 +1071,6 @@ pub(super) fn decode_rect_split( | ||
| 1186 | 1071 | cu_y, |
| 1187 | 1072 | 4, |
| 1188 | 1073 | 4, |
| 1189 | - base_q_idx, | |
| 1190 | 1074 | m.alpha |
| 1191 | 1075 | .zip(ac) |
| 1192 | 1076 | .map(|((au, av), ac)| (if plane_idx == 1 { au } else { av }, ac)), |
| @@ -1195,9 +1079,6 @@ pub(super) fn decode_rect_split( | ||
| 1195 | 1079 | m.smooth_neighbor_uv, |
| 1196 | 1080 | fctx, |
| 1197 | 1081 | )?; |
| 1198 | - if span_x == 4 && span_y == 4 { | |
| 1199 | - hit!(RECT_SPLIT_LOSSLESS_CHROMA444_HITS); | |
| 1200 | - } | |
| 1201 | 1082 | neighbours.record_mi_chroma(cu_mi, span_x, span_y, plane_idx, &grid); |
| 1202 | 1083 | ll_chroma_units.push((cu_mi, plane_idx, grid.clone(), span_x, span_y)); |
| 1203 | 1084 | last[plane_idx - 1] = grid; |
| @@ -1229,12 +1110,6 @@ pub(super) fn decode_rect_split( | ||
| 1229 | 1110 | }; |
| 1230 | 1111 | // lane-av1-422: the witness counter, keyed to ss (1,0) so only a 4:2:2 |
| 1231 | 1112 | // frame's square chroma units count it. |
| 1232 | - if uw == uh && ss_x(fctx) == 1 && ss_y(fctx) == 0 { | |
| 1233 | - hit!(CHROMA422_SQUARE_HITS); | |
| 1234 | - } | |
| 1235 | - if chroma_422_pair_wide { | |
| 1236 | - hit!(CHROMA422_PAIR_WIDE_HITS); | |
| 1237 | - } | |
| 1238 | 1113 | let (nw, nh) = (chroma_block_w / uw, chroma_block_h / uh); |
| 1239 | 1114 | // lane-av1-422stripanchor: the pair's plane block is BLOCK_INVALID |
| 1240 | 1115 | // whatever the pair size (`num_pels_log2_lookup[255]` reads 0xff in |
| @@ -1354,24 +1229,7 @@ pub(super) fn decode_rect_split( | ||
| 1354 | 1229 | uw << ss_x(fctx), |
| 1355 | 1230 | uh << ss_y(fctx), |
| 1356 | 1231 | reach, |
| 1357 | - px, | |
| 1358 | - py, | |
| 1359 | - y.width, | |
| 1360 | - y.height, | |
| 1361 | - fctx, | |
| 1362 | 1232 | ); |
| 1363 | - if cu_reach.above_right != reach.above_right | |
| 1364 | - || cu_reach.below_left != reach.below_left | |
| 1365 | - { | |
| 1366 | - hit!(RECT_TILED_CHROMA_UNIT_REACH_HITS); | |
| 1367 | - } | |
| 1368 | - if nw * nh > 1 { | |
| 1369 | - match (nw, nh) { | |
| 1370 | - (2, 1) => hit!(RECT_TILED_CHROMA_2X1_HITS), | |
| 1371 | - (1, 2) => hit!(RECT_TILED_CHROMA_1X2_HITS), | |
| 1372 | - _ => hit!(RECT_TILED_CHROMA_NXN_HITS), | |
| 1373 | - } | |
| 1374 | - } | |
| 1375 | 1233 | // 32x32 does not fit read_coeffs_rect's scratch (768). The |
| 1376 | 1234 | // square reader is the path every other 32x32 chroma unit uses. |
| 1377 | 1235 | let levels = if uw == uh { |
| @@ -1393,7 +1251,6 @@ pub(super) fn decode_rect_split( | ||
| 1393 | 1251 | cu_y, |
| 1394 | 1252 | uw, |
| 1395 | 1253 | uw, |
| 1396 | - base_q_idx, | |
| 1397 | 1254 | cfl, |
| 1398 | 1255 | None, |
| 1399 | 1256 | bigger.then_some(3), |
| @@ -1414,7 +1271,6 @@ pub(super) fn decode_rect_split( | ||
| 1414 | 1271 | skip_ctx, |
| 1415 | 1272 | dc_sign_ctx(cu_around[plane_idx].2), |
| 1416 | 1273 | default_tx, |
| 1417 | - plane_idx, | |
| 1418 | 1274 | )?; |
| 1419 | 1275 | let residual = dequant_and_inverse_typed_wh( |
| 1420 | 1276 | &levels, |
| @@ -1504,15 +1360,11 @@ pub(super) fn decode_rect_split( | ||
| 1504 | 1360 | skip_ctx, |
| 1505 | 1361 | dc_sign_ctx(around[plane_idx].2), |
| 1506 | 1362 | default_tx, |
| 1507 | - plane_idx, | |
| 1508 | 1363 | )?; |
| 1509 | 1364 | // The same delta_q proof the unsplit rect64 path records |
| 1510 | 1365 | // (lane-rectsplit r4: lifting the split-transform refusal moved |
| 1511 | 1366 | // superblock strips onto this path, so only counting there would |
| 1512 | 1367 | // leave the delta_q gate's counter silent for them). |
| 1513 | - if bw.max(bh) == 64 && fctx.current_q_idx.with(|c| c.get()) != i32::from(base_q_idx) { | |
| 1514 | - hit!(RECT64_QIDX_DRIFT_HITS); | |
| 1515 | - } | |
| 1516 | 1368 | let residual = dequant_and_inverse_typed_wh( |
| 1517 | 1369 | &levels, |
| 1518 | 1370 | chroma_w, |
| @@ -1584,13 +1436,6 @@ pub(super) fn decode_rect_split( | ||
| 1584 | 1436 | 0, |
| 1585 | 1437 | fctx, |
| 1586 | 1438 | ); |
| 1587 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 1588 | - let (rng, _) = dec.debug_state(); | |
| 1589 | - eprintln!( | |
| 1590 | - "TRACE_RECT_SPLIT mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} \ | |
| 1591 | - tx={tx_w}x{tx_h} rng={rng}" | |
| 1592 | - ); | |
| 1593 | - } | |
| 1594 | 1439 | Ok(()) |
| 1595 | 1440 | } |
| 1596 | 1441 | |
| @@ -1657,11 +1502,6 @@ fn every_intra_in_inter_shape_the_census_lists_has_a_size_group_row() { | ||
| 1657 | 1502 | // never said WHICH string the domain was about, so under a real function |
| 1658 | 1503 | // boundary -- rather than a window that ran into the next test -- the row |
| 1659 | 1504 | // read as unanchored. |
| 1660 | - const REFUSAL: &str = "an intra-coded {bw}x{bh} block on the inter block path (no size-group/tx-category row for that shape here)"; | |
| 1661 | - assert!( | |
| 1662 | - crate::test_source::module_source("decode").contains(REFUSAL), | |
| 1663 | - "this gate proves {REFUSAL:?}, but that string is no longer in decode.rs" | |
| 1664 | - ); | |
| 1665 | 1505 | let mut checked = 0; |
| 1666 | 1506 | for &(side, w, h) in &INTER_BLOCK_SHAPES { |
| 1667 | 1507 | if (w, h) == (side, side) || w.min(h) < 8 || w.max(h) > 64 { |
| @@ -1983,21 +1823,6 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 1983 | 1823 | } |
| 1984 | 1824 | neighbours.above_side[c] = bw; |
| 1985 | 1825 | neighbours.left_side[r] = bh; |
| 1986 | - if crate::envflags::env_flag!("EC_INTRA16X4") { | |
| 1987 | - eprintln!( | |
| 1988 | - "EC_INTRA16X4 decoded mi={mi_r},{mi_c} px={},{} horz={horz} has_chroma={has_chroma} skip={skip} mode={mode} uv={uv:?}", | |
| 1989 | - mi_c * MI, | |
| 1990 | - mi_r * MI | |
| 1991 | - ); | |
| 1992 | - } | |
| 1993 | - hit_do! { | |
| 1994 | - INTRA16X4_IN_INTER_HITS.with(|h| { | |
| 1995 | - let mut v = h.get(); | |
| 1996 | - v[usize::from(!horz)] += 1; | |
| 1997 | - v[2] += usize::from(has_chroma); | |
| 1998 | - h.set(v); | |
| 1999 | - }); | |
| 2000 | - } | |
| 2001 | 1826 | return Ok(()); |
| 2002 | 1827 | } |
| 2003 | 1828 | // lane-inter128intra r1: the 128 superblock's PARTITION_HORZ/VERT half |
| @@ -2035,13 +1860,6 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2035 | 1860 | // palette_syntax`), so a 128-root half consumes no palette syntax and |
| 2036 | 1861 | // a screen-content frame's half is syntactically identical to the |
| 2037 | 1862 | // non-screen one this arm already decodes byte-exact. |
| 2038 | - if coeff_trace_on() { | |
| 2039 | - // lane-t900 r16: which decode-order frame this arm fires in -- | |
| 2040 | - // interleaved with the `EC_COEFF_FRAME` markers, this is what | |
| 2041 | - // proves the hit is counted out of a frame that compares exact | |
| 2042 | - // (class `counter-from-refused-stream`). | |
| 2043 | - eprintln!("EC_INTRA128 mi_row={r} mi_col={c} bw={bw} bh={bh}"); | |
| 2044 | - } | |
| 2045 | 1863 | fctx.intra_in_inter_mode.with(|c| c.set(Some((3, skip)))); |
| 2046 | 1864 | let res = decode_block_128rect( |
| 2047 | 1865 | dec, |
| @@ -2064,11 +1882,6 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2064 | 1882 | return res; |
| 2065 | 1883 | } |
| 2066 | 1884 | let Some((size_group, tx_cat)) = intra_in_inter_size_row(bw, bh) else { |
| 2067 | - if crate::envflags::env_flag!("EC_OBMCREC") { | |
| 2068 | - eprintln!( | |
| 2069 | - "OBMCREC intra-in-inter shape bw={bw} bh={bh} mi=({mi_r},{mi_c}) skip={skip}" | |
| 2070 | - ); | |
| 2071 | - } | |
| 2072 | 1885 | // lane-obmcrec r1: the message used to name a 16x4/4x16 strip |
| 2073 | 1886 | // (class refusal-names-a-correlate). lane-t900 r20: the shapes that |
| 2074 | 1887 | // can arrive here are enumerated against the measured block-shape |
| @@ -2142,33 +1955,12 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2142 | 1955 | }; |
| 2143 | 1956 | fctx.intra_in_inter_mode.with(|c| c.set(None)); |
| 2144 | 1957 | res?; |
| 2145 | - let shape = match (bw, bh) { | |
| 2146 | - (64, 16) => 0, | |
| 2147 | - (16, 64) => 1, | |
| 2148 | - (32, 8) => 2, | |
| 2149 | - _ => 3, | |
| 2150 | - }; | |
| 2151 | - hit_do! { | |
| 2152 | - INTRA_RECT4_IN_INTER_HITS.with(|h| { | |
| 2153 | - let mut v = h.get(); | |
| 2154 | - v[shape] += 1; | |
| 2155 | - h.set(v); | |
| 2156 | - }); | |
| 2157 | - } | |
| 2158 | 1958 | return Ok(()); |
| 2159 | 1959 | } |
| 2160 | - crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | |
| 2161 | 1960 | let mode = dec.symbol(&mut cdfs.y_mode[size_group]); |
| 2162 | 1961 | // lane-t900 r1: this arm read six mode symbols with no ladder rung of its |
| 2163 | 1962 | // own, so a cross-decoder bisection could only see the block's first |
| 2164 | 1963 | // coefficient. Same names/format as [`read_tx_size`]'s rung. |
| 2165 | - let step_trace = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); | |
| 2166 | - if step_trace { | |
| 2167 | - eprintln!( | |
| 2168 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=y_mode val={mode} grp={size_group} rng={}", | |
| 2169 | - dec.debug_state().0 | |
| 2170 | - ); | |
| 2171 | - } | |
| 2172 | 1964 | if mode >= 13 { |
| 2173 | 1965 | return Err(unsupported( |
| 2174 | 1966 | "an intra mode this decoder does not code (round 2)", |
| @@ -2182,9 +1974,6 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2182 | 1974 | } else { |
| 2183 | 1975 | 0 |
| 2184 | 1976 | }; |
| 2185 | - if angle_delta_y != 0 { | |
| 2186 | - hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS); | |
| 2187 | - } | |
| 2188 | 1977 | // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the |
| 2189 | 1978 | // superblock-level strip reads the no-CFL alphabet -- the same split |
| 2190 | 1979 | // [`read_intra_mode_rect`] makes for [`decode_block_rect64`]. |
| @@ -2196,22 +1985,10 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2196 | 1985 | let uv_mode = if !has_chroma { |
| 2197 | 1986 | DC_PRED |
| 2198 | 1987 | } else if cfl_allowed { |
| 2199 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 2200 | 1988 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 2201 | 1989 | } else { |
| 2202 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 2203 | 1990 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 2204 | 1991 | }; |
| 2205 | - if step_trace { | |
| 2206 | - eprintln!( | |
| 2207 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=uv_mode val={uv_mode} cfl={} rng={}", | |
| 2208 | - u8::from(cfl_allowed), | |
| 2209 | - dec.debug_state().0 | |
| 2210 | - ); | |
| 2211 | - } | |
| 2212 | - if (9..=12).contains(&uv_mode) { | |
| 2213 | - hit!(SMOOTH_UV_HITS); | |
| 2214 | - } | |
| 2215 | 1992 | let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { |
| 2216 | 1993 | Some(read_cfl_alphas(dec, cdfs)) |
| 2217 | 1994 | } else { |
| @@ -2223,15 +2000,10 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2223 | 2000 | uv_mode |
| 2224 | 2001 | }; |
| 2225 | 2002 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 2226 | - hit!(DIRECTIONAL_UV_HITS); | |
| 2227 | 2003 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 2228 | 2004 | } else { |
| 2229 | 2005 | 0 |
| 2230 | 2006 | }; |
| 2231 | - if angle_delta_uv != 0 { | |
| 2232 | - hit!(UV_ANGLE_DELTA_HITS); | |
| 2233 | - hit!(INTRA_IN_INTER_ANGLE_DELTA_UV_HITS); | |
| 2234 | - } | |
| 2235 | 2007 | // `read_palette_mode_info` (spec 5.11.13), in the position |
| 2236 | 2008 | // `read_intra_block_mode_info` writes it: after the chroma mode and |
| 2237 | 2009 | // before `filter_intra`. lane-t900 r21: a `--tune-content=screen` inter |
| @@ -2247,7 +2019,6 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2247 | 2019 | let mut palette_y_pending: Option<(usize, [u16; 8])> = None; |
| 2248 | 2020 | let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; |
| 2249 | 2021 | if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh) { |
| 2250 | - hit!(INTRA_RECT_IN_INTER_SCREEN_HITS); | |
| 2251 | 2022 | let use_palette_y = |
| 2252 | 2023 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0; |
| 2253 | 2024 | if use_palette_y { |
| @@ -2261,14 +2032,6 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2261 | 2032 | let use_palette_uv = has_chroma |
| 2262 | 2033 | && uv_mode == DC_PRED |
| 2263 | 2034 | && dec.symbol(&mut cdfs.palette_uv_mode[usize::from(use_palette_y)]) != 0; |
| 2264 | - if crate::envflags::env_flag!("EC_PALSYN") { | |
| 2265 | - eprintln!( | |
| 2266 | - "EC_PALSYN rect mi={mi_r},{mi_c} bw={bw} bh={bh} mode={mode} uv={uv_mode} ctx={palette_ctx} y={} uv={} rng={}", | |
| 2267 | - use_palette_y as i32, | |
| 2268 | - use_palette_uv as i32, | |
| 2269 | - dec.debug_state().0 | |
| 2270 | - ); | |
| 2271 | - } | |
| 2272 | 2035 | if use_palette_uv { |
| 2273 | 2036 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); |
| 2274 | 2037 | let (u_colors, v_colors) = read_palette_colors_uv(dec, n, &palette_uv_cache, fctx); |
| @@ -2289,8 +2052,6 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2289 | 2052 | && let Some(class) = filter_intra_size_class_rect(bw, bh) |
| 2290 | 2053 | && dec.symbol(&mut cdfs.filter_intra[class]) != 0 |
| 2291 | 2054 | { |
| 2292 | - hit!(FILTER_INTRA_HITS); | |
| 2293 | - hit!(INTRA_IN_INTER_FILTER_INTRA_HITS); | |
| 2294 | 2055 | filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); |
| 2295 | 2056 | } |
| 2296 | 2057 | // `av1_visit_palette`: Y's colour-index map then the shared chroma one. |
| @@ -2304,9 +2065,6 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2304 | 2065 | palette_onscreen(mi_r, mi_c, bw, bh, fctx), |
| 2305 | 2066 | false, |
| 2306 | 2067 | ); |
| 2307 | - hit!(PALETTE_HITS); | |
| 2308 | - hit!(PALETTE_RECT_HITS); | |
| 2309 | - hit!(INTRA_IN_INTER_PALETTE_Y_HITS); | |
| 2310 | 2068 | PaletteY { |
| 2311 | 2069 | size: n, |
| 2312 | 2070 | colors, |
| @@ -2322,8 +2080,6 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2322 | 2080 | (ss_x(fctx), ss_y(fctx)), |
| 2323 | 2081 | ); |
| 2324 | 2082 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true); |
| 2325 | - hit!(PALETTE_UV_HITS); | |
| 2326 | - hit!(INTRA_IN_INTER_PALETTE_UV_HITS); | |
| 2327 | 2083 | PaletteUv { |
| 2328 | 2084 | size: n, |
| 2329 | 2085 | u_colors, |
| @@ -2342,13 +2098,7 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2342 | 2098 | // context-read-from-one-cell). |
| 2343 | 2099 | let coarse_pair = neighbours.modes_above_left(r, c); |
| 2344 | 2100 | let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left_mi(mi_r, mi_c, coarse_pair); |
| 2345 | - if (nb_above_mode, nb_left_mode) != coarse_pair { | |
| 2346 | - hit!(EDGE_FILTER_MI_FIX_HITS); | |
| 2347 | - } | |
| 2348 | 2101 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 2349 | - if smooth_neighbor { | |
| 2350 | - hit!(SMOOTH_LUMA_HITS); | |
| 2351 | - } | |
| 2352 | 2102 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx); |
| 2353 | 2103 | // lane-av1mixloss: the lossless-segment early return (`decodeframe.c:1203`) |
| 2354 | 2104 | // precedes `TX_MODE_SELECT`, so a lossless-segment intra-rect block inside |
| @@ -2356,41 +2106,19 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2356 | 2106 | // segment regardless of frame type; class sweep of the sub8 leaf's fix). |
| 2357 | 2107 | let depth = if fctx.tx_select_inter.with(std::cell::Cell::get) && !lossless(fctx) { |
| 2358 | 2108 | // The frame's own `TXFM_CONTEXT` bands -- [`tx_size_context_txfm_rect`]. |
| 2359 | - let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw.min(64), bh.min(64), fctx); | |
| 2109 | + let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw.min(64), bh.min(64)); | |
| 2360 | 2110 | let d = match tx_cat { |
| 2361 | 2111 | 1 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), |
| 2362 | 2112 | 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), |
| 2363 | 2113 | _ => dec.symbol(&mut cdfs.tx_size_cat3[ctx]), |
| 2364 | 2114 | }; |
| 2365 | - if step_trace { | |
| 2366 | - eprintln!( | |
| 2367 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat={tx_cat} rng={}", | |
| 2368 | - dec.debug_state().0 | |
| 2369 | - ); | |
| 2370 | - } | |
| 2371 | 2115 | d |
| 2372 | 2116 | } else { |
| 2373 | 2117 | 0 |
| 2374 | 2118 | }; |
| 2375 | - if depth != 0 || lossless(fctx) { | |
| 2376 | - hit!(TX_DEPTH_HITS); | |
| 2377 | - // lane-intrasplit r1: a split intra strip in an inter frame walks the | |
| 2378 | - // key frame's own per-TU path ([`decode_rect_split`] below); what was | |
| 2379 | - // wrong when this refusal was written was the depth SYMBOL, not the walk. | |
| 2380 | - hit_do! { | |
| 2381 | - INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(|h| { | |
| 2382 | - let mut v = h.get(); | |
| 2383 | - v[depth.min(2)] += 1; | |
| 2384 | - h.set(v); | |
| 2385 | - }); | |
| 2386 | - } | |
| 2387 | - } | |
| 2388 | 2119 | // lane-intrasplit r3: print EVERY intra strip with its depth, not only the |
| 2389 | 2120 | // split ones -- a `depth=0`-only stream is a witness gap in the SOURCE, and |
| 2390 | 2121 | // the two are indistinguishable when the diagnostic fires on splits alone. |
| 2391 | - if crate::envflags::env_flag!("EC_SPLITSTRIP") { | |
| 2392 | - eprintln!("EC_SPLITSTRIP mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} depth={depth}"); | |
| 2393 | - } | |
| 2394 | 2122 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 2395 | 2123 | // lane-inter16ab r8: libaom runs `set_txfm_ctxs(tx_size, n4_w, n4_h, |
| 2396 | 2124 | // skip && is_inter, xd)` (decodeframe.c `decode_block`) for EVERY block |
| @@ -2435,7 +2163,6 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2435 | 2163 | y, |
| 2436 | 2164 | u, |
| 2437 | 2165 | v, |
| 2438 | - base_q_idx, | |
| 2439 | 2166 | fctx.reduced_tx_set_inter.with(std::cell::Cell::get), |
| 2440 | 2167 | fctx, |
| 2441 | 2168 | )?; |
| @@ -2467,18 +2194,6 @@ pub(super) fn decode_intra_rect_in_inter( | ||
| 2467 | 2194 | palette_uv.as_ref().map_or(0, |p| p.size), |
| 2468 | 2195 | palette_uv.as_ref().map_or([0u16; 8], |p| p.u_colors), |
| 2469 | 2196 | ); |
| 2470 | - let class = match bw.max(bh) { | |
| 2471 | - 64 => 0, | |
| 2472 | - 32 => 1, | |
| 2473 | - _ => 2, | |
| 2474 | - }; | |
| 2475 | - hit_do! { | |
| 2476 | - INTRA_RECT_IN_INTER_HITS.with(|h| { | |
| 2477 | - let mut v = h.get(); | |
| 2478 | - v[class] += 1; | |
| 2479 | - h.set(v); | |
| 2480 | - }); | |
| 2481 | - } | |
| 2482 | 2197 | Ok(()) |
| 2483 | 2198 | } |
| 2484 | 2199 | |
| @@ -2519,22 +2234,6 @@ pub(super) fn decode_intrabc_rect( | ||
| 2519 | 2234 | base_q_idx: u8, |
| 2520 | 2235 | fctx: &crate::decode::FrameCtx, |
| 2521 | 2236 | ) -> Result<()> { |
| 2522 | - hit!(INTRABC_RECT_HITS); | |
| 2523 | - // [horz, vert]: see `INTRABC_RECT_CODED_HITS` / `INTRABC_RECT_SKIPPED_HITS`. | |
| 2524 | - let idx = usize::from(bh > bw); | |
| 2525 | - if skip { | |
| 2526 | - INTRABC_RECT_SKIPPED_HITS.with(|c| { | |
| 2527 | - let mut seen = c.get(); | |
| 2528 | - seen[idx] += 1; | |
| 2529 | - c.set(seen); | |
| 2530 | - }); | |
| 2531 | - } else { | |
| 2532 | - INTRABC_RECT_CODED_HITS.with(|c| { | |
| 2533 | - let mut seen = c.get(); | |
| 2534 | - seen[idx] += 1; | |
| 2535 | - c.set(seen); | |
| 2536 | - }); | |
| 2537 | - } | |
| 2538 | 2237 | let (px, py) = (mi_c * MI, mi_r * MI); |
| 2539 | 2238 | // lane-whtshape: a LOSSLESS block's chroma plane block is |
| 2540 | 2239 | // `bw >> ss_x` by `bh >> ss_y` at its own origin -- `av1_get_max_uv_txsize` |
| @@ -2581,19 +2280,7 @@ pub(super) fn decode_intrabc_rect( | ||
| 2581 | 2280 | skip, |
| 2582 | 2281 | fctx, |
| 2583 | 2282 | )?; |
| 2584 | - if leaves.is_some() { | |
| 2585 | - hit!(INTRABC_RECT_VARTX_HITS); | |
| 2586 | - } | |
| 2587 | - if ss_x(fctx) == 0 && ss_y(fctx) == 0 { | |
| 2588 | - hit!(IBC_RECT_CHROMA_FOOTPRINT_444_HITS); | |
| 2589 | - } | |
| 2590 | 2283 | // lane-ibc444c: per-block geometry, for the chroma-tail attribution. |
| 2591 | - if crate::envflags::env_flag!("EC_IBCBLOCK") { | |
| 2592 | - eprintln!( | |
| 2593 | - "EC_IBCBLOCK mi=({mi_r},{mi_c}) bw={bw} bh={bh} cpx={cpx} cpy={cpy} \ | |
| 2594 | - cw={cw} ch={ch} cside={cside} skip={skip}" | |
| 2595 | - ); | |
| 2596 | - } | |
| 2597 | 2284 | // The whole-block prediction: `predict_inter_block` runs once, before any |
| 2598 | 2285 | // coefficient is read. The source is this frame's own reconstruction, |
| 2599 | 2286 | // which is already written. |
| @@ -2709,19 +2396,6 @@ pub(super) fn decode_intrabc_rect( | ||
| 2709 | 2396 | fctx, |
| 2710 | 2397 | ); |
| 2711 | 2398 | if let Some(ls) = leaves.as_ref() { |
| 2712 | - // lane-av1-loss64, merged: the same reset [`decode_intrabc_owned_rect`]'s | |
| 2713 | - // skip arm performs -- libaom `av1_reset_entropy_context` | |
| 2714 | - // (`if (mbmi->skip_txfm)`, decodeframe.c:1262 -> blockd.c:58): a | |
| 2715 | - // SKIPPED block zeroes its whole entropy-band footprint. This | |
| 2716 | - // helper serves `decode_block_rect4`'s 1:4 strips on this tree, | |
| 2717 | - // so a skipped lossless strip whose `leaves` resolved (every | |
| 2718 | - // lossless frame -- `read_block_tx_size_rect`'s lossless arm | |
| 2719 | - // returns the 4x4 grid before it looks at `skip`) left the | |
| 2720 | - // PREVIOUS occupant's luma bands standing and the NEXT block's | |
| 2721 | - // partition parse diverged from libaom's: the 320x242 lossless | |
| 2722 | - // sb128 gate read a phantom unskipped 8x32 intrabc strip at | |
| 2723 | - // mi(56,66) right after the skipped 8x16 one at mi(48,66). | |
| 2724 | - hit!(SKIP_LOSSLESS_BAND_RESET_HITS); | |
| 2725 | 2399 | for &(row, col, tw, th) in ls { |
| 2726 | 2400 | neighbours.record_mi_luma_rect( |
| 2727 | 2401 | (mi_r + row, mi_c + col), |
| @@ -2903,21 +2577,6 @@ pub(super) fn decode_intrabc_rect( | ||
| 2903 | 2577 | around[2] = c[2]; |
| 2904 | 2578 | } |
| 2905 | 2579 | if lossless(fctx) { |
| 2906 | - // lane-whtshape: at lossless libaom codes TX_4X4 on EVERY | |
| 2907 | - // plane of a block -- `read_tx_size` returns `TX_4X4` for a | |
| 2908 | - // lossless block before it looks at a tree, `read_tx_mode` | |
| 2909 | - // already forced `ONLY_4X4` for the frame, and | |
| 2910 | - // `get_vartx_max_txsize` returns `TX_4X4` for every plane | |
| 2911 | - // -- so this block's chroma plane block is a | |
| 2912 | - // `(cw/4) * (ch/4)` raster of 4x4 units, PLANE-MAJOR | |
| 2913 | - // (`decode_token_recon_block`: every U unit, then every V | |
| 2914 | - // unit), not the single rect unit the two | |
| 2915 | - // `read_inter_plane_rect` calls below read. That single | |
| 2916 | - // 8x4 unit is what reached the lossless WHT with the wrong | |
| 2917 | - // shape (the `debug_assert_eq!((w, h), (4, 4))` this lane | |
| 2918 | - // replaced). Same helper, same walk, as the inter 8x8 and | |
| 2919 | - // 128 paths. | |
| 2920 | - hit!(INTRABC_RECT_LOSSLESS_CHROMA4_HITS); | |
| 2921 | 2580 | let mut uo = vec![0i32; cside * cside]; |
| 2922 | 2581 | let mut vo = vec![0i32; cside * cside]; |
| 2923 | 2582 | read_inter_chroma_lossless( |
| @@ -3125,13 +2784,6 @@ pub(super) fn decode_intrabc_128rect( | ||
| 3125 | 2784 | base_q_idx: u8, |
| 3126 | 2785 | fctx: &crate::decode::FrameCtx, |
| 3127 | 2786 | ) -> Result<()> { |
| 3128 | - hit!(INTRABC_128RECT_HITS); | |
| 3129 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 3130 | - let (rng, _) = dec.debug_state(); | |
| 3131 | - eprintln!( | |
| 3132 | - "EC_IBC128 mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} skip={skip} dv=({dv_row},{dv_col}) rng={rng}" | |
| 3133 | - ); | |
| 3134 | - } | |
| 3135 | 2787 | let (px, py) = (mi_c * MI, mi_r * MI); |
| 3136 | 2788 | // lane-av1-ibc128chunk: the block's chroma PLANE BLOCK is per-axis |
| 3137 | 2789 | // `(bw >> ss_x) x (bh >> ss_y)` -- 4:2:0 halves both (this fn's |
| @@ -3277,12 +2929,6 @@ pub(super) fn decode_intrabc_128rect( | ||
| 3277 | 2929 | fctx, |
| 3278 | 2930 | ); |
| 3279 | 2931 | if let Some(ls) = leaves.as_ref() { |
| 3280 | - // A LOSSLESS frame's `read_block_tx_size_rect` resolves the TX_4X4 | |
| 3281 | - // grid before it looks at `skip`; the skipped block still zeroes | |
| 3282 | - // its entropy-band footprint over every unit (libaom | |
| 3283 | - // `av1_reset_entropy_context` under `if (mbmi->skip_txfm)`) -- | |
| 3284 | - // the same arm [`decode_intrabc_rect`]'s loss64 merge added. | |
| 3285 | - hit!(SKIP_LOSSLESS_BAND_RESET_HITS); | |
| 3286 | 2932 | for &(row, col, tw, th) in ls { |
| 3287 | 2933 | neighbours.record_mi_luma_rect( |
| 3288 | 2934 | (mi_r + row, mi_c + col), |
| @@ -3457,38 +3103,6 @@ pub(super) fn decode_intrabc_128rect( | ||
| 3457 | 3103 | } else { |
| 3458 | 3104 | neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h) |
| 3459 | 3105 | }; |
| 3460 | - if crate::envflags::env_flag!("EC_ECDUMP") { | |
| 3461 | - // Index loop mirrors the spec's per-position form over several offsets; an iterator would obscure it. | |
| 3462 | - #[allow(clippy::needless_range_loop)] | |
| 3463 | - for p in 1..3 { | |
| 3464 | - let ab: Vec<String> = (0..unit_luma_w / MI) | |
| 3465 | - .map(|k| { | |
| 3466 | - format!( | |
| 3467 | - "{:?}/{}", | |
| 3468 | - neighbours.above[unit_mi.1 + k][p].dc, | |
| 3469 | - neighbours.above[unit_mi.1 + k][p].level | |
| 3470 | - ) | |
| 3471 | - }) | |
| 3472 | - .collect(); | |
| 3473 | - let lf: Vec<String> = (0..unit_luma_h / MI) | |
| 3474 | - .map(|k| { | |
| 3475 | - format!( | |
| 3476 | - "{:?}/{}", | |
| 3477 | - neighbours.left[unit_mi.0 + k][p].dc, | |
| 3478 | - neighbours.left[unit_mi.0 + k][p].level | |
| 3479 | - ) | |
| 3480 | - }) | |
| 3481 | - .collect(); | |
| 3482 | - eprintln!( | |
| 3483 | - "EC_IBC128_BANDS mi=({mi_r},{mi_c}) unit=({cr},{cc}) plane={p} ctx=({},{},{}) above=[{}] left=[{}]", | |
| 3484 | - cu_around[p].0, | |
| 3485 | - cu_around[p].1, | |
| 3486 | - cu_around[p].2, | |
| 3487 | - ab.join(","), | |
| 3488 | - lf.join(",") | |
| 3489 | - ); | |
| 3490 | - } | |
| 3491 | - } | |
| 3492 | 3106 | let (cu_x, cu_y) = ( |
| 3493 | 3107 | cpx + cc * chunk_chroma_w + uc * cu_tx, |
| 3494 | 3108 | cpy + cr * chunk_chroma_h + ur * cu_tx, |
| @@ -3538,15 +3152,6 @@ pub(super) fn decode_intrabc_128rect( | ||
| 3538 | 3152 | plane_idx, |
| 3539 | 3153 | &cu_grid, |
| 3540 | 3154 | ); |
| 3541 | - if crate::envflags::env_flag!("EC_ECDUMP") { | |
| 3542 | - let st = crate::decode::neighbour_state(&cu_grid); | |
| 3543 | - eprintln!( | |
| 3544 | - "EC_IBC128_STAMP mi=({mi_r},{mi_c}) unit=({cr},{cc}) plane={plane_idx} state=({:?},{})", | |
| 3545 | - st.dc, st.level | |
| 3546 | - ); | |
| 3547 | - } | |
| 3548 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 3549 | - INTRABC_128RECT_CHROMA_CHUNK_HITS.with(|c| c.set(c.get() + 1)); | |
| 3550 | 3155 | // lane-av1-ibcrect: per-unit chroma context -- the |
| 3551 | 3156 | // end-of-block record's composed-grid re-stamp |
| 3552 | 3157 | // must not stand (replayed below). |
| @@ -3831,9 +3436,6 @@ pub(super) fn decode_block_rect( | ||
| 3831 | 3436 | ); |
| 3832 | 3437 | } |
| 3833 | 3438 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 3834 | - if smooth_neighbor { | |
| 3835 | - hit!(SMOOTH_LUMA_HITS); | |
| 3836 | - } | |
| 3837 | 3439 | // lane-chroma r3: chroma's own edge-filter-strength neighbour check |
| 3838 | 3440 | // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's |
| 3839 | 3441 | // `uv_mode`, not the luma one. |
| @@ -3844,9 +3446,6 @@ pub(super) fn decode_block_rect( | ||
| 3844 | 3446 | // rectangle just as happily), so a `use_filter_intra` strip at this level |
| 3845 | 3447 | // predicts instead of refusing. The below-16x16 leaf arm |
| 3846 | 3448 | // (`decode_leaf_rect`) keeps the refusal: it has no gate of its own. |
| 3847 | - if filter_intra.is_some() { | |
| 3848 | - hit!(FILTER_INTRA_RECT_HITS); | |
| 3849 | - } | |
| 3850 | 3449 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 3851 | 3450 | DC_PRED |
| 3852 | 3451 | } else { |
| @@ -3872,14 +3471,8 @@ pub(super) fn decode_block_rect( | ||
| 3872 | 3471 | // 1920x792 128-superblock stream, |
| 3873 | 3472 | // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read |
| 3874 | 3473 | // `tx_size_cat2` row 1 where libaom reads row 2. |
| 3875 | - let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh, fctx); | |
| 3474 | + let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh); | |
| 3876 | 3475 | let d = dec.symbol(&mut cdfs.tx_size_cat2[ctx]); |
| 3877 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 3878 | - eprintln!( | |
| 3879 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat=2 rng={}", | |
| 3880 | - dec.debug_state().0 | |
| 3881 | - ); | |
| 3882 | - } | |
| 3883 | 3476 | d |
| 3884 | 3477 | } else { |
| 3885 | 3478 | 0 |
| @@ -3894,19 +3487,11 @@ pub(super) fn decode_block_rect( | ||
| 3894 | 3487 | fctx, |
| 3895 | 3488 | ); |
| 3896 | 3489 | if depth != 0 || lossless(fctx) { |
| 3897 | - hit!(TX_DEPTH_HITS); | |
| 3898 | 3490 | // lane-rectsplit r1: a split transform is predicted and reconstructed |
| 3899 | 3491 | // per transform unit, each unit taking its edges from the previous |
| 3900 | 3492 | // unit's reconstruction inside this same strip (spec 5.11.36) -- |
| 3901 | 3493 | // [`decode_rect_split`], the unit named by [`depth_to_tx_wh`]. |
| 3902 | 3494 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 3903 | - if crate::envflags::env_flag!("EC_SBPART_DUMP64") { | |
| 3904 | - eprintln!( | |
| 3905 | - "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ | |
| 3906 | - depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \ | |
| 3907 | - angle_y={angle_delta_y}" | |
| 3908 | - ); | |
| 3909 | - } | |
| 3910 | 3495 | let modes = RectStripModes { |
| 3911 | 3496 | skip, |
| 3912 | 3497 | mode, |
| @@ -3927,9 +3512,6 @@ pub(super) fn decode_block_rect( | ||
| 3927 | 3512 | ) |
| 3928 | 3513 | }), |
| 3929 | 3514 | }; |
| 3930 | - if palette_y.is_some() || palette_uv.is_some() { | |
| 3931 | - hit!(PALETTE_SPLIT_TX_HITS); | |
| 3932 | - } | |
| 3933 | 3515 | decode_rect_split( |
| 3934 | 3516 | dec, |
| 3935 | 3517 | cdfs, |
| @@ -3943,7 +3525,6 @@ pub(super) fn decode_block_rect( | ||
| 3943 | 3525 | y, |
| 3944 | 3526 | u, |
| 3945 | 3527 | v, |
| 3946 | - base_q_idx, | |
| 3947 | 3528 | reduced_tx_set, |
| 3948 | 3529 | fctx, |
| 3949 | 3530 | )?; |
| @@ -3962,21 +3543,12 @@ pub(super) fn decode_block_rect( | ||
| 3962 | 3543 | .as_ref() |
| 3963 | 3544 | .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 3964 | 3545 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); |
| 3965 | - hit!(RECT_PARTITION_HITS); | |
| 3966 | 3546 | return Ok(()); |
| 3967 | 3547 | } |
| 3968 | 3548 | let (tx_w, tx_h) = (bw, bh); |
| 3969 | 3549 | let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); |
| 3970 | 3550 | let (chroma_w, chroma_h) = (bw >> ss_x(fctx), bh >> ss_y(fctx)); |
| 3971 | 3551 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); |
| 3972 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 3973 | - let (rng, _) = dec.debug_state(); | |
| 3974 | - eprintln!( | |
| 3975 | - "TRACE_RECT_IMODE mi_row={mi_r} mi_col={mi_c} mode={mode} uv_mode={uv_mode} \ | |
| 3976 | - skip={} tx={depth} rng={rng}", | |
| 3977 | - skip as i32 | |
| 3978 | - ); | |
| 3979 | - } | |
| 3980 | 3552 | // As [`decode_block`]'s own [`PALETTE_PRED`] wiring: a palette-Y/UV |
| 3981 | 3553 | // block's prediction is the reconstructed colour-index map, set fresh |
| 3982 | 3554 | // right before each `reconstruct_rect` call below (lane-palette2 r4). |
| @@ -4174,12 +3746,7 @@ pub(super) fn decode_block_rect( | ||
| 4174 | 3746 | 0, |
| 4175 | 3747 | dc_sign_ctx(around[0].2), |
| 4176 | 3748 | TxType::DctDct, |
| 4177 | - 0, | |
| 4178 | 3749 | )?; |
| 4179 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 4180 | - let (rng, _) = dec.debug_state(); | |
| 4181 | - eprintln!("TRACE_RECT_COEFF plane=0 mi_row={mi_r} mi_col={mi_c} rng={rng}"); | |
| 4182 | - } | |
| 4183 | 3750 | let luma_residual = dequant_and_inverse_typed_wh( |
| 4184 | 3751 | &luma_levels, |
| 4185 | 3752 | bw, |
| @@ -4226,12 +3793,7 @@ pub(super) fn decode_block_rect( | ||
| 4226 | 3793 | dc_sign_ctx(around[1].2), |
| 4227 | 3794 | u_default_tx, |
| 4228 | 3795 | fctx, |
| 4229 | - 1, | |
| 4230 | 3796 | )?; |
| 4231 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 4232 | - let (rng, _) = dec.debug_state(); | |
| 4233 | - eprintln!("TRACE_RECT_COEFF plane=1 mi_row={mi_r} mi_col={mi_c} rng={rng}"); | |
| 4234 | - } | |
| 4235 | 3797 | let u_residual = dequant_and_inverse_typed_wh( |
| 4236 | 3798 | &u_levels, |
| 4237 | 3799 | chroma_w, |
| @@ -4277,12 +3839,7 @@ pub(super) fn decode_block_rect( | ||
| 4277 | 3839 | dc_sign_ctx(around[2].2), |
| 4278 | 3840 | v_default_tx, |
| 4279 | 3841 | fctx, |
| 4280 | - 2, | |
| 4281 | 3842 | )?; |
| 4282 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 4283 | - let (rng, _) = dec.debug_state(); | |
| 4284 | - eprintln!("TRACE_RECT_COEFF plane=2 mi_row={mi_r} mi_col={mi_c} rng={rng}"); | |
| 4285 | - } | |
| 4286 | 3843 | let v_residual = dequant_and_inverse_typed_wh( |
| 4287 | 3844 | &v_levels, |
| 4288 | 3845 | chroma_w, |
| @@ -4320,7 +3877,6 @@ pub(super) fn decode_block_rect( | ||
| 4320 | 3877 | uv_predict_mode, |
| 4321 | 3878 | &[&luma_levels[..], &u_levels[..], &v_levels[..]], |
| 4322 | 3879 | ); |
| 4323 | - hit!(RECT_COEFF_HITS); | |
| 4324 | 3880 | } |
| 4325 | 3881 | } |
| 4326 | 3882 | let (py_size, py_colors) = palette_y |
| @@ -4341,10 +3897,6 @@ pub(super) fn decode_block_rect( | ||
| 4341 | 3897 | 0, |
| 4342 | 3898 | fctx, |
| 4343 | 3899 | ); |
| 4344 | - hit!(RECT_PARTITION_HITS); | |
| 4345 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 4346 | - eprintln!("TRACE_RECT32_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh}"); | |
| 4347 | - } | |
| 4348 | 3900 | Ok(()) |
| 4349 | 3901 | } |
| 4350 | 3902 | |
| @@ -4389,12 +3941,6 @@ pub(super) fn decode_leaf_rect( | ||
| 4389 | 3941 | fctx: &crate::decode::FrameCtx, |
| 4390 | 3942 | ) -> Result<usize> { |
| 4391 | 3943 | let _ = base_q_idx; |
| 4392 | - if crate::envflags::env_flag!("EC_AV1_RECTX_TRACE") { | |
| 4393 | - eprintln!( | |
| 4394 | - "decode_leaf_rect: leaf_mi={leaf_mi:?} bw={bw} bh={bh} outer_at={outer_at:?} rng={}", | |
| 4395 | - dec.debug_state().0 | |
| 4396 | - ); | |
| 4397 | - } | |
| 4398 | 3944 | let (r, c) = outer_at; |
| 4399 | 3945 | let mut above_mode = neighbours.above_mode[c]; |
| 4400 | 3946 | let mut left_mode = neighbours.left_mode[r]; |
| @@ -4417,9 +3963,6 @@ pub(super) fn decode_leaf_rect( | ||
| 4417 | 3963 | let (above_mode, left_mode) = |
| 4418 | 3964 | neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode)); |
| 4419 | 3965 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 4420 | - if smooth_neighbor { | |
| 4421 | - hit!(SMOOTH_LUMA_HITS); | |
| 4422 | - } | |
| 4423 | 3966 | // The palette-Y mode CDF row is picked by the neighbours' palette use |
| 4424 | 3967 | // (`palette_ctx_and_cache`), so this sub-16x16 leaf must pass its own real |
| 4425 | 3968 | // ctx/cache -- reading `palette_y_mode` off row 0 when a neighbour did use |
| @@ -4483,9 +4026,6 @@ pub(super) fn decode_leaf_rect( | ||
| 4483 | 4026 | // lane-kf900 r4: palette prediction on this shape, the same colour-index |
| 4484 | 4027 | // map -> base colours buffer [`decode_block_rect`] hands each |
| 4485 | 4028 | // `reconstruct_rect` through [`set_palette_pred`]. |
| 4486 | - if palette_y.is_some() || palette_uv.is_some() { | |
| 4487 | - hit!(RECT4_PALETTE_HITS); | |
| 4488 | - } | |
| 4489 | 4029 | let palette_y_buf: Option<Vec<u16>> = palette_y |
| 4490 | 4030 | .as_ref() |
| 4491 | 4031 | .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect()); |
| @@ -4501,17 +4041,6 @@ pub(super) fn decode_leaf_rect( | ||
| 4501 | 4041 | let (pal_uv_size, pal_uv_colors) = palette_uv |
| 4502 | 4042 | .as_ref() |
| 4503 | 4043 | .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 4504 | - if crate::envflags::env_flag!("EC_AV1_RECTX_TRACE") { | |
| 4505 | - eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}"); | |
| 4506 | - } | |
| 4507 | - if filter_intra.is_some() { | |
| 4508 | - // lane-fistrip r1: `predict_filter_intra` already walks its 4x2 | |
| 4509 | - // patches over a true `bw`x`bh` block (lane-rectsplit r1), so an | |
| 4510 | - // 8x16/16x8 strip predicts through the same call `reconstruct_rect` | |
| 4511 | - // below already makes; this refusal was square-only prose. | |
| 4512 | - hit!(FILTER_INTRA_RECT_HITS); | |
| 4513 | - hit!(FILTER_INTRA_RECT_SUB16_HITS); | |
| 4514 | - } | |
| 4515 | 4044 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 4516 | 4045 | DC_PRED |
| 4517 | 4046 | } else { |
| @@ -4531,7 +4060,7 @@ pub(super) fn decode_leaf_rect( | ||
| 4531 | 4060 | // The mixed frame's 16x8 leaf at mi(10,0) forked exactly here: ours |
| 4532 | 4061 | // read `tx_size_cat1` (rng 55700->49918) where the oracle's next |
| 4533 | 4062 | // read was the leaf's own txb_skip. |
| 4534 | - let ctx = tx_size_context_txfm_rect(neighbours, leaf_mi, bw, bh, fctx); | |
| 4063 | + let ctx = tx_size_context_txfm_rect(neighbours, leaf_mi, bw, bh); | |
| 4535 | 4064 | // lane-rectsplitx r1: `bsize_to_tx_size_cat` (libaom `blockd.h`, |
| 4536 | 4065 | // `bsize_to_tx_size_depth_table`) is 2 for BLOCK_16X8/BLOCK_8X16, so |
| 4537 | 4066 | // the category is 1 -- NOT the 2 the 32x16 strips read. Same symbol |
| @@ -4549,14 +4078,6 @@ pub(super) fn decode_leaf_rect( | ||
| 4549 | 4078 | // symbol in the tile is read from the wrong place (class |
| 4550 | 4079 | // `wrong-alphabet-same-value`, here same alphabet / wrong row). |
| 4551 | 4080 | let d = dec.symbol(&mut cdfs.tx_size_cat1[ctx]); |
| 4552 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 4553 | - eprintln!( | |
| 4554 | - "EC_ISTEP mi_row={} mi_col={} name=tx_depth val={d} ctx={ctx} cat=1 rng={}", | |
| 4555 | - leaf_mi.0, | |
| 4556 | - leaf_mi.1, | |
| 4557 | - dec.debug_state().0 | |
| 4558 | - ); | |
| 4559 | - } | |
| 4560 | 4081 | d |
| 4561 | 4082 | } else { |
| 4562 | 4083 | 0 |
| @@ -4571,11 +4092,6 @@ pub(super) fn decode_leaf_rect( | ||
| 4571 | 4092 | fctx, |
| 4572 | 4093 | ); |
| 4573 | 4094 | if depth != 0 || lossless(fctx) { |
| 4574 | - // The same per-transform-unit walk the bigger strips take | |
| 4575 | - // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at | |
| 4576 | - // depth 2), addressed at this leaf's own mi position. | |
| 4577 | - hit!(TX_DEPTH_HITS); | |
| 4578 | - hit!(SUB16_SPLIT_HITS); | |
| 4579 | 4095 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 4580 | 4096 | let modes = RectStripModes { |
| 4581 | 4097 | skip, |
| @@ -4593,9 +4109,6 @@ pub(super) fn decode_leaf_rect( | ||
| 4593 | 4109 | palette_y: palette_y_buf.clone(), |
| 4594 | 4110 | palette_uv: palette_uv_bufs.clone(), |
| 4595 | 4111 | }; |
| 4596 | - if palette_y.is_some() || palette_uv.is_some() { | |
| 4597 | - hit!(PALETTE_SPLIT_TX_HITS); | |
| 4598 | - } | |
| 4599 | 4112 | decode_rect_split( |
| 4600 | 4113 | dec, |
| 4601 | 4114 | cdfs, |
| @@ -4609,7 +4122,6 @@ pub(super) fn decode_leaf_rect( | ||
| 4609 | 4122 | y, |
| 4610 | 4123 | u, |
| 4611 | 4124 | v, |
| 4612 | - base_q_idx, | |
| 4613 | 4125 | reduced_tx_set, |
| 4614 | 4126 | fctx, |
| 4615 | 4127 | )?; |
| @@ -4772,17 +4284,7 @@ pub(super) fn decode_leaf_rect( | ||
| 4772 | 4284 | 0, |
| 4773 | 4285 | dc_sign_ctx(around[0].2), |
| 4774 | 4286 | TxType::DctDct, |
| 4775 | - 0, | |
| 4776 | 4287 | )?; |
| 4777 | - if crate::envflags::env_flag!("EC_AV1_RECTX_TRACE") { | |
| 4778 | - let nz: Vec<(usize, i32)> = l_levels | |
| 4779 | - .iter() | |
| 4780 | - .copied() | |
| 4781 | - .enumerate() | |
| 4782 | - .filter(|(_, v)| *v != 0) | |
| 4783 | - .collect(); | |
| 4784 | - eprintln!(" luma_tx_type={luma_tx_type:?} nz_levels={nz:?}"); | |
| 4785 | - } | |
| 4786 | 4288 | luma_levels = l_levels; |
| 4787 | 4289 | let luma_residual = dequant_and_inverse_typed_wh( |
| 4788 | 4290 | &luma_levels, |
| @@ -4830,7 +4332,6 @@ pub(super) fn decode_leaf_rect( | ||
| 4830 | 4332 | dc_sign_ctx(around[1].2), |
| 4831 | 4333 | u_default_tx, |
| 4832 | 4334 | fctx, |
| 4833 | - 1, | |
| 4834 | 4335 | )?; |
| 4835 | 4336 | u_levels = u_l; |
| 4836 | 4337 | let u_residual = dequant_and_inverse_typed_wh( |
| @@ -4878,7 +4379,6 @@ pub(super) fn decode_leaf_rect( | ||
| 4878 | 4379 | dc_sign_ctx(around[2].2), |
| 4879 | 4380 | v_default_tx, |
| 4880 | 4381 | fctx, |
| 4881 | - 2, | |
| 4882 | 4382 | )?; |
| 4883 | 4383 | v_levels = v_l; |
| 4884 | 4384 | let v_residual = dequant_and_inverse_typed_wh( |
| @@ -4913,7 +4413,6 @@ pub(super) fn decode_leaf_rect( | ||
| 4913 | 4413 | smooth_neighbor_uv, |
| 4914 | 4414 | fctx, |
| 4915 | 4415 | ); |
| 4916 | - hit!(RECT_LEAF_COEFF_HITS); | |
| 4917 | 4416 | } |
| 4918 | 4417 | neighbours.record_mi_rect( |
| 4919 | 4418 | leaf_mi, |
crates/ec-av1/src/decode/rect4.rsmodified+8 -364
| @@ -117,9 +117,6 @@ pub(super) fn decode_block_rect4( | ||
| 117 | 117 | // [`decode_block_rect`] does one aspect ratio up -- the colour-index map |
| 118 | 118 | // mapped through the base colours IS the prediction (it reads no edge |
| 119 | 119 | // pixels), handed to each `reconstruct_rect` through [`set_palette_pred`]. |
| 120 | - if palette_y.is_some() || palette_uv.is_some() { | |
| 121 | - hit!(RECT4_PALETTE_HITS); | |
| 122 | - } | |
| 123 | 120 | let palette_y_buf: Option<Vec<u16>> = palette_y |
| 124 | 121 | .as_ref() |
| 125 | 122 | .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect()); |
| @@ -136,9 +133,6 @@ pub(super) fn decode_block_rect4( | ||
| 136 | 133 | .as_ref() |
| 137 | 134 | .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 138 | 135 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 139 | - if smooth_neighbor { | |
| 140 | - hit!(SMOOTH_LUMA_HITS); | |
| 141 | - } | |
| 142 | 136 | // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's |
| 143 | 137 | // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so |
| 144 | 138 | // `r * (SUB / MI)` names a different mi column and the chroma |
| @@ -146,14 +140,6 @@ pub(super) fn decode_block_rect4( | ||
| 146 | 140 | // seed 43, the last 8x32 strip at luma (152,32), chroma-only mismatch |
| 147 | 141 | // with luma bit-exact). |
| 148 | 142 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx); |
| 149 | - if filter_intra.is_some() { | |
| 150 | - hit!(FILTER_INTRA_RECT_HITS); | |
| 151 | - if bw > bh { | |
| 152 | - hit!(FILTER_INTRA_RECT4_HORZ_HITS); | |
| 153 | - } else { | |
| 154 | - hit!(FILTER_INTRA_RECT4_VERT_HITS); | |
| 155 | - } | |
| 156 | - } | |
| 157 | 143 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 158 | 144 | DC_PRED |
| 159 | 145 | } else { |
| @@ -170,14 +156,8 @@ pub(super) fn decode_block_rect4( | ||
| 170 | 156 | // 1920x792 128-superblock stream, |
| 171 | 157 | // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read |
| 172 | 158 | // `tx_size_cat2` row 1 where libaom reads row 2. |
| 173 | - let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh, fctx); | |
| 159 | + let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh); | |
| 174 | 160 | let d = dec.symbol(&mut cdfs.tx_size_cat2[ctx]); |
| 175 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 176 | - eprintln!( | |
| 177 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat=2 rng={}", | |
| 178 | - dec.debug_state().0 | |
| 179 | - ); | |
| 180 | - } | |
| 181 | 161 | d |
| 182 | 162 | } else { |
| 183 | 163 | 0 |
| @@ -192,24 +172,7 @@ pub(super) fn decode_block_rect4( | ||
| 192 | 172 | fctx, |
| 193 | 173 | ); |
| 194 | 174 | if depth != 0 || lossless(fctx) { |
| 195 | - // lane-rectsplitx r1: the per-transform-unit walk, at this strip's | |
| 196 | - // real mi position (strips 1 and 3 of a HORZ_4 start 8 px into a | |
| 197 | - // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16 | |
| 198 | - // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8; | |
| 199 | - // both interleave in every real stream. | |
| 200 | - hit!(TX_DEPTH_HITS); | |
| 201 | 175 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 202 | - // lane-rectsplitx r2: both depths ship together, as the r1 handoff | |
| 203 | - // predicted -- depth 1 fires FIRST in every attempt that splits at | |
| 204 | - // all, so a depth-2-only lift could never be gated. The r1 mismatch | |
| 205 | - // was never the rect unit: it was the neighbour MODE the strip reads | |
| 206 | - // (see `modes_above_left_mi`). | |
| 207 | - let which = if depth == 1 { | |
| 208 | - &RECT4_SPLIT_DEPTH1_HITS | |
| 209 | - } else { | |
| 210 | - &RECT4_SPLIT_DEPTH2_HITS | |
| 211 | - }; | |
| 212 | - hit_do! { which.with(|c| c.set(c.get() + 1)); } | |
| 213 | 176 | let modes = RectStripModes { |
| 214 | 177 | skip, |
| 215 | 178 | mode, |
| @@ -223,9 +186,6 @@ pub(super) fn decode_block_rect4( | ||
| 223 | 186 | palette_y: palette_y_buf.clone(), |
| 224 | 187 | palette_uv: palette_uv_bufs.clone(), |
| 225 | 188 | }; |
| 226 | - if palette_y.is_some() || palette_uv.is_some() { | |
| 227 | - hit!(PALETTE_SPLIT_TX_HITS); | |
| 228 | - } | |
| 229 | 189 | decode_rect_split( |
| 230 | 190 | dec, |
| 231 | 191 | cdfs, |
| @@ -239,7 +199,6 @@ pub(super) fn decode_block_rect4( | ||
| 239 | 199 | y, |
| 240 | 200 | u, |
| 241 | 201 | v, |
| 242 | - base_q_idx, | |
| 243 | 202 | false, |
| 244 | 203 | fctx, |
| 245 | 204 | )?; |
| @@ -253,14 +212,6 @@ pub(super) fn decode_block_rect4( | ||
| 253 | 212 | pal_uv_size, |
| 254 | 213 | pal_uv_colors, |
| 255 | 214 | ); |
| 256 | - if bw > bh { | |
| 257 | - hit!(RECT4_32_HORZ_HITS); | |
| 258 | - } else { | |
| 259 | - hit!(RECT4_32_VERT_HITS); | |
| 260 | - } | |
| 261 | - if !skip { | |
| 262 | - hit!(RECT4_COEFF_HITS); | |
| 263 | - } | |
| 264 | 215 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 265 | 216 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| 266 | 217 | // frame, so this 1:4 strip -- which is also the INTER frame's reader |
| @@ -367,9 +318,7 @@ pub(super) fn decode_block_rect4( | ||
| 367 | 318 | 0, |
| 368 | 319 | dc_sign_ctx(around[0].2), |
| 369 | 320 | TxType::DctDct, |
| 370 | - 0, | |
| 371 | 321 | )?; |
| 372 | - hit!(RECT4_COEFF_HITS); | |
| 373 | 322 | let luma_residual = dequant_and_inverse_typed_wh( |
| 374 | 323 | &luma_levels, |
| 375 | 324 | bw, |
| @@ -410,20 +359,7 @@ pub(super) fn decode_block_rect4( | ||
| 410 | 359 | for plane in [1usize, 2] { |
| 411 | 360 | for unit_row in 0..4usize { |
| 412 | 361 | let unit_mi = (mi_r + unit_row * 2, mi_c); |
| 413 | - let unit_reach = tu_reach_rect( | |
| 414 | - bw, | |
| 415 | - bh, | |
| 416 | - 0, | |
| 417 | - unit_row * 8, | |
| 418 | - 8, | |
| 419 | - 8, | |
| 420 | - reach, | |
| 421 | - px, | |
| 422 | - py, | |
| 423 | - y.width, | |
| 424 | - y.height, | |
| 425 | - fctx, | |
| 426 | - ); | |
| 362 | + let unit_reach = tu_reach_rect(bw, bh, 0, unit_row * 8, 8, 8, reach); | |
| 427 | 363 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 428 | 364 | let pbuf = if plane == 1 { ub } else { vb }; |
| 429 | 365 | set_palette_pred(palette_window(pbuf, chroma_w, 0, unit_row * 8, 4, 8), fctx); |
| @@ -498,11 +434,6 @@ pub(super) fn decode_block_rect4( | ||
| 498 | 434 | pal_uv_size, |
| 499 | 435 | pal_uv_colors, |
| 500 | 436 | ); |
| 501 | - if bw > bh { | |
| 502 | - hit!(RECT4_32_HORZ_HITS); | |
| 503 | - } else { | |
| 504 | - hit!(RECT4_32_VERT_HITS); | |
| 505 | - } | |
| 506 | 437 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 507 | 438 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| 508 | 439 | // frame, so this 1:4 strip -- which is also the INTER frame's reader |
| @@ -533,7 +464,6 @@ pub(super) fn decode_block_rect4( | ||
| 533 | 464 | 0, |
| 534 | 465 | dc_sign_ctx(around[0].2), |
| 535 | 466 | TxType::DctDct, |
| 536 | - 0, | |
| 537 | 467 | )?; |
| 538 | 468 | let mut planes = Vec::with_capacity(2); |
| 539 | 469 | // Index loop mirrors the spec's per-position form over several offsets; an iterator would obscure it. |
| @@ -562,13 +492,11 @@ pub(super) fn decode_block_rect4( | ||
| 562 | 492 | dc_sign_ctx(chroma_around[plane].2), |
| 563 | 493 | default_tx, |
| 564 | 494 | fctx, |
| 565 | - plane, | |
| 566 | 495 | )?; |
| 567 | 496 | planes.push((levels, tx_type)); |
| 568 | 497 | } |
| 569 | 498 | let (v_levels, v_tx_type) = planes.pop().expect("plane 2"); |
| 570 | 499 | let (u_levels, u_tx_type) = planes.pop().expect("plane 1"); |
| 571 | - hit!(RECT4_COEFF_HITS); | |
| 572 | 500 | let luma_residual = dequant_and_inverse_typed_wh( |
| 573 | 501 | &luma_levels, |
| 574 | 502 | bw, |
| @@ -657,11 +585,6 @@ pub(super) fn decode_block_rect4( | ||
| 657 | 585 | pal_uv_size, |
| 658 | 586 | pal_uv_colors, |
| 659 | 587 | ); |
| 660 | - if bw > bh { | |
| 661 | - hit!(RECT4_32_HORZ_HITS); | |
| 662 | - } else { | |
| 663 | - hit!(RECT4_32_VERT_HITS); | |
| 664 | - } | |
| 665 | 588 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 666 | 589 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| 667 | 590 | // frame, so this 1:4 strip -- which is also the INTER frame's reader |
| @@ -702,20 +625,7 @@ pub(super) fn decode_block_rect4( | ||
| 702 | 625 | // libaom's `set_entropy_context` leaves. |
| 703 | 626 | for plane in [1usize, 2] { |
| 704 | 627 | for unit_row in 0..4usize { |
| 705 | - let unit_reach = tu_reach_rect( | |
| 706 | - bw, | |
| 707 | - bh, | |
| 708 | - 0, | |
| 709 | - unit_row * 8, | |
| 710 | - 8, | |
| 711 | - 8, | |
| 712 | - reach, | |
| 713 | - px, | |
| 714 | - py, | |
| 715 | - y.width, | |
| 716 | - y.height, | |
| 717 | - fctx, | |
| 718 | - ); | |
| 628 | + let unit_reach = tu_reach_rect(bw, bh, 0, unit_row * 8, 8, 8, reach); | |
| 719 | 629 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 720 | 630 | let pbuf = if plane == 1 { ub } else { vb }; |
| 721 | 631 | set_palette_pred(palette_window(pbuf, chroma_w, 0, unit_row * 8, 4, 8), fctx); |
| @@ -804,11 +714,6 @@ pub(super) fn decode_block_rect4( | ||
| 804 | 714 | pal_uv_size, |
| 805 | 715 | pal_uv_colors, |
| 806 | 716 | ); |
| 807 | - if bw > bh { | |
| 808 | - hit!(RECT4_32_HORZ_HITS); | |
| 809 | - } else { | |
| 810 | - hit!(RECT4_32_VERT_HITS); | |
| 811 | - } | |
| 812 | 717 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 813 | 718 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| 814 | 719 | // frame, so this 1:4 strip -- which is also the INTER frame's reader |
| @@ -975,16 +880,10 @@ pub(super) fn decode_intrabc_owned_rect( | ||
| 975 | 880 | // 73501 V (f1) and 9216 U + 8192 V (f2) are wrong -- chroma-only, which is |
| 976 | 881 | // what makes this a chroma-sizing defect and not a block-geometry one. |
| 977 | 882 | // Re-measured by this lane; see lanes/av1chromarect.report.md. |
| 978 | - if crate::envflags::env_flag!("EC_HALVSWEEP") { | |
| 979 | - eprintln!("EC_HALV ibc_owned mi=({mi_r},{mi_c}) bw={bw} bh={bh} skip={skip}"); | |
| 980 | - } | |
| 981 | 883 | let (cw, ch) = (bw >> ss_x(fctx), bh >> ss_y(fctx)); |
| 982 | 884 | let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); |
| 983 | 885 | let side = bw.max(bh); |
| 984 | 886 | let cside = cw.max(ch); |
| 985 | - if ss_x(fctx) == 0 && ss_y(fctx) == 0 { | |
| 986 | - hit!(IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS); | |
| 987 | - } | |
| 988 | 887 | let saved_reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get); |
| 989 | 888 | let saved_tx = fctx.tx_select_inter.with(std::cell::Cell::get); |
| 990 | 889 | fctx.reduced_tx_set_inter.with(|c| c.set(reduced_tx_set)); |
| @@ -1063,20 +962,6 @@ pub(super) fn decode_intrabc_owned_rect( | ||
| 1063 | 962 | fctx, |
| 1064 | 963 | ); |
| 1065 | 964 | if let Some(ls) = leaves.as_ref() { |
| 1066 | - // libaom `av1_reset_entropy_context` (`if (mbmi->skip_txfm)`, | |
| 1067 | - // decodeframe.c:1262 -> blockd.c:58): a SKIPPED block zeroes its | |
| 1068 | - // whole entropy-band footprint. The non-skip arm below writes | |
| 1069 | - // those bands per transform unit and the tail's | |
| 1070 | - // `record_split_luma_rect_mi` writes chroma only, so without | |
| 1071 | - // this walk a skipped strip whose `leaves` resolved (every | |
| 1072 | - // lossless frame -- `read_block_tx_size_rect`'s lossless arm | |
| 1073 | - // returns the 4x4 grid before it looks at `skip`) leaked the | |
| 1074 | - // PREVIOUS occupant's luma bands into the next block's | |
| 1075 | - // `txb_skip`/coefficient contexts (lane-av1-loss64: the skipped | |
| 1076 | - // 8x16 intrabc strip at mi(48,66) of the 320x242 lossless sb128 | |
| 1077 | - // stream left a stale 7 in left[48] and mi(48,68)'s first | |
| 1078 | - // transform unit read `txb_skip_ctx` 3 where aomdec reads 1). | |
| 1079 | - hit!(SKIP_LOSSLESS_BAND_RESET_HITS); | |
| 1080 | 965 | for &(row, col, tw, th) in ls { |
| 1081 | 966 | neighbours.record_mi_luma_rect( |
| 1082 | 967 | (mi_r + row, mi_c + col), |
| @@ -1195,7 +1080,6 @@ pub(super) fn decode_intrabc_owned_rect( | ||
| 1195 | 1080 | // `TX_MODE_LARGEST`); the routing here is identical, so a future |
| 1196 | 1081 | // witness takes the same code. |
| 1197 | 1082 | let around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { |
| 1198 | - hit!(IBC_OWNED_RECT_422_PAIR_HITS); | |
| 1199 | 1083 | neighbours.around_mi_422_chroma((mi_r, mi_c), bw, bh) |
| 1200 | 1084 | } else { |
| 1201 | 1085 | neighbours.around_mi_rect((mi_r, mi_c), bw, bh) |
| @@ -1295,7 +1179,6 @@ pub(super) fn decode_intrabc_owned_rect( | ||
| 1295 | 1179 | // agree -- `fixtures/ibc422_nonsplit_ctx.obu` is the stream where |
| 1296 | 1180 | // they do not). |
| 1297 | 1181 | let around_chroma = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { |
| 1298 | - hit!(IBC_OWNED_RECT_422_PAIR_HITS); | |
| 1299 | 1182 | neighbours.around_mi_422_chroma((mi_r, mi_c), bw, bh) |
| 1300 | 1183 | } else { |
| 1301 | 1184 | around |
| @@ -1603,7 +1486,6 @@ pub(super) fn decode_rect4_16_intrabc( | ||
| 1603 | 1486 | fctx: &crate::decode::FrameCtx, |
| 1604 | 1487 | ) -> Result<(usize, Option<usize>, (usize, usize))> { |
| 1605 | 1488 | let _ = base_q_idx; |
| 1606 | - hit!(RECT4_16_INTRABC_HITS); | |
| 1607 | 1489 | let (bw, bh) = if horz { (16usize, 4usize) } else { (4, 16) }; |
| 1608 | 1490 | let (mi_w, mi_h) = (bw / MI, bh / MI); |
| 1609 | 1491 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| @@ -1670,15 +1552,9 @@ pub(super) fn decode_rect4_16_intrabc( | ||
| 1670 | 1552 | // [BLOCK_4X16][1][0]` is BLOCK_INVALID at 4:2:2, so only HORZ reaches it. |
| 1671 | 1553 | let own444 = ss_x(fctx) == 0 && ss_y(fctx) == 0; |
| 1672 | 1554 | let own422 = ss_x(fctx) == 1 && ss_y(fctx) == 0 && horz; |
| 1673 | - if own422 && has_chroma { | |
| 1674 | - hit!(INTRABC_RECT4_OWN_CHROMA422_HITS); | |
| 1675 | - } | |
| 1676 | 1555 | // One predicate for "this strip IS its own chroma reference": the strip's |
| 1677 | 1556 | // own mi position, its own luma extent, and per-axis subsampled sizes. |
| 1678 | 1557 | let own_chroma = own444 || own422; |
| 1679 | - if ss_x(fctx) == 0 && ss_y(fctx) == 0 && has_chroma { | |
| 1680 | - hit!(INTRABC_RECT4_OWN_CHROMA444_HITS); | |
| 1681 | - } | |
| 1682 | 1558 | let (pw, ph) = if own444 { |
| 1683 | 1559 | (bw, bh) |
| 1684 | 1560 | } else if horz { |
| @@ -1805,15 +1681,6 @@ pub(super) fn decode_rect4_16_intrabc( | ||
| 1805 | 1681 | bh, |
| 1806 | 1682 | ); |
| 1807 | 1683 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; |
| 1808 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 1809 | - let (rng, _) = dec.debug_state(); | |
| 1810 | - eprintln!( | |
| 1811 | - "EC_ISTEP mi_row={} mi_col={} name=txfm_split_rect val={} ctx={ctx} rng={rng}", | |
| 1812 | - lmi.0, | |
| 1813 | - lmi.1, | |
| 1814 | - u8::from(split) | |
| 1815 | - ); | |
| 1816 | - } | |
| 1817 | 1684 | if !split { |
| 1818 | 1685 | None |
| 1819 | 1686 | } else { |
| @@ -2184,7 +2051,6 @@ pub(super) fn decode_rect4_16_intrabc( | ||
| 2184 | 2051 | } |
| 2185 | 2052 | let mut last_uv = None; |
| 2186 | 2053 | if has_chroma { |
| 2187 | - hit!(RECT4_16_CHROMA_HITS); | |
| 2188 | 2054 | // lane-av1422luma: the uv-mode publication and the left/above skip |
| 2189 | 2055 | // state below are the STRIP's own at 4:2:2 / 4:4:4 -- publishing the |
| 2190 | 2056 | // pair extent (one mi row off, `ph`/`pw`) is what the NEXT block's |
| @@ -2220,11 +2086,6 @@ pub(super) fn decode_rect4_16_intrabc( | ||
| 2220 | 2086 | } |
| 2221 | 2087 | last_uv = Some(DC_PRED); |
| 2222 | 2088 | } |
| 2223 | - if horz { | |
| 2224 | - hit!(RECT4_16_HORZ_HITS); | |
| 2225 | - } else { | |
| 2226 | - hit!(RECT4_16_VERT_HITS); | |
| 2227 | - } | |
| 2228 | 2089 | record_strip_palette(neighbours, lmi, bw, bh, 0, [0u16; 8], 0, [0u16; 8]); |
| 2229 | 2090 | if leaves.is_none() { |
| 2230 | 2091 | // Skip and TX_MODE_LARGEST publish the block size (`set_txfm_ctxs` |
| @@ -2350,9 +2211,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2350 | 2211 | fctx, |
| 2351 | 2212 | ); |
| 2352 | 2213 | } |
| 2353 | - if palette_y.is_some() || palette_uv.is_some() { | |
| 2354 | - hit!(RECT4_PALETTE_HITS); | |
| 2355 | - } | |
| 2356 | 2214 | // The colour-index map through the base colours IS the prediction. |
| 2357 | 2215 | // Chroma's map is the PAIR's 8x4 (4x8) block, matching the one |
| 2358 | 2216 | // chroma transform this closing strip codes. |
| @@ -2366,12 +2224,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2366 | 2224 | ) |
| 2367 | 2225 | }); |
| 2368 | 2226 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 2369 | - if smooth_neighbor { | |
| 2370 | - hit!(SMOOTH_LUMA_HITS); | |
| 2371 | - } | |
| 2372 | - if filter_intra.is_some() { | |
| 2373 | - hit!(FILTER_INTRA_RECT_HITS); | |
| 2374 | - } | |
| 2375 | 2227 | // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is |
| 2376 | 2228 | // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the |
| 2377 | 2229 | // depth symbol is the 3-symbol `tx_size_cat1` -- not the 2-symbol |
| @@ -2383,24 +2235,12 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2383 | 2235 | let depth = if tx_select && !lossless(fctx) { |
| 2384 | 2236 | // lane-av1txbands: every frame reads the real `TXFM_CONTEXT` bands |
| 2385 | 2237 | // (`get_tx_size_context`, libaom `pred_common.h:342`). |
| 2386 | - let ctx = tx_size_context_txfm_rect(neighbours, lmi, bw, bh, fctx); | |
| 2238 | + let ctx = tx_size_context_txfm_rect(neighbours, lmi, bw, bh); | |
| 2387 | 2239 | let d = dec.symbol(&mut cdfs.tx_size_cat1[ctx]); |
| 2388 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 2389 | - eprintln!( | |
| 2390 | - "EC_ISTEP mi_row={} mi_col={} name=tx_depth val={d} ctx={ctx} cat=1 rng={}", | |
| 2391 | - lmi.0, | |
| 2392 | - lmi.1, | |
| 2393 | - dec.debug_state().0 | |
| 2394 | - ); | |
| 2395 | - } | |
| 2396 | 2240 | d |
| 2397 | 2241 | } else { |
| 2398 | 2242 | 0 |
| 2399 | 2243 | }; |
| 2400 | - if depth != 0 { | |
| 2401 | - hit!(TX_DEPTH_HITS); | |
| 2402 | - hit!(RECT4_16_SPLIT_HITS); | |
| 2403 | - } | |
| 2404 | 2244 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 2405 | 2245 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 2406 | 2246 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); |
| @@ -2471,7 +2311,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2471 | 2311 | tu_skip_ctx, |
| 2472 | 2312 | dc_sign_ctx(tu_around.2), |
| 2473 | 2313 | TxType::DctDct, |
| 2474 | - 0, | |
| 2475 | 2314 | )?; |
| 2476 | 2315 | let residual = dequant_and_inverse_typed_wh( |
| 2477 | 2316 | &tu_grid, |
| @@ -2502,9 +2341,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2502 | 2341 | smooth_neighbor, |
| 2503 | 2342 | fctx, |
| 2504 | 2343 | ); |
| 2505 | - if tu_grid.iter().any(|&l| l != 0) { | |
| 2506 | - hit!(RECT4_16_COEFF_HITS); | |
| 2507 | - } | |
| 2508 | 2344 | neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); |
| 2509 | 2345 | } else { |
| 2510 | 2346 | let tu_around = neighbours.around_mi(tu_mi, tx_w)[0]; |
| @@ -2527,16 +2363,12 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2527 | 2363 | tu_py, |
| 2528 | 2364 | tx_w, |
| 2529 | 2365 | tx_w, |
| 2530 | - base_q_idx, | |
| 2531 | 2366 | None, |
| 2532 | 2367 | filter_intra, |
| 2533 | 2368 | Some(tu_skip_ctx), |
| 2534 | 2369 | smooth_neighbor, |
| 2535 | 2370 | fctx, |
| 2536 | 2371 | )?; |
| 2537 | - if tu_grid.iter().any(|&l| l != 0) { | |
| 2538 | - hit!(RECT4_16_COEFF_HITS); | |
| 2539 | - } | |
| 2540 | 2372 | neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid); |
| 2541 | 2373 | } |
| 2542 | 2374 | } |
| @@ -2586,7 +2418,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2586 | 2418 | 0, |
| 2587 | 2419 | dc_sign_ctx(around.2), |
| 2588 | 2420 | TxType::DctDct, |
| 2589 | - 0, | |
| 2590 | 2421 | )?; |
| 2591 | 2422 | let residual = dequant_and_inverse_typed_wh( |
| 2592 | 2423 | &levels, |
| @@ -2620,7 +2451,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2620 | 2451 | smooth_neighbor, |
| 2621 | 2452 | fctx, |
| 2622 | 2453 | ); |
| 2623 | - hit!(RECT4_16_COEFF_HITS); | |
| 2624 | 2454 | levels |
| 2625 | 2455 | }; |
| 2626 | 2456 | neighbours.record_mi_luma_rect(lmi, bw, bh, &levels); |
| @@ -2641,7 +2471,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2641 | 2471 | } |
| 2642 | 2472 | } |
| 2643 | 2473 | if has_chroma { |
| 2644 | - hit!(RECT4_16_CHROMA_HITS); | |
| 2645 | 2474 | // lane-av1-444: at 4:4:4 there is no pair -- every strip is its |
| 2646 | 2475 | // own chroma reference and codes its own 16x4 / 4x16 chroma |
| 2647 | 2476 | // block. (`set_mi_offsets`'s chroma snap is the zero offset at |
| @@ -2687,9 +2516,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2687 | 2516 | } else { |
| 2688 | 2517 | uv_mode |
| 2689 | 2518 | }; |
| 2690 | - if (V_PRED..=D67_PRED).contains(&uv_predict_mode) { | |
| 2691 | - hit!(RECT4_16_CHROMA_DIR_HITS); | |
| 2692 | - } | |
| 2693 | 2519 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height, fctx); |
| 2694 | 2520 | // lane-kf1200 r1: the chroma edge-filter type reads the neighbours |
| 2695 | 2521 | // of the CHROMA block, which for a 16x4/4x16 pair is `pair_mi`'s |
| @@ -2703,33 +2529,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2703 | 2529 | // `av1_use_intra_edge_upsample` on (blk_wh 12 <= 16) for a |
| 2704 | 2530 | // directional chroma strip, moving 4 samples by 1. |
| 2705 | 2531 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c, fctx); |
| 2706 | - // lane-av1422warp: `smooth_uv_neighbour_unsnapped` now takes the | |
| 2707 | - // frame's own `ss_x` -- the unsnapped read is the pair-merge witness | |
| 2708 | - // counter's mirror of the snapping form, and the shipped read offsets | |
| 2709 | - // the above COLUMN by `+ss_x` (libaom's `chroma_above_mi`). | |
| 2710 | - // | |
| 2711 | - // lane-av1leftwit: this mirror is NOT evidence about the left read's | |
| 2712 | - // `+ss_y` term, whatever a report once said. It reads the leaf's own | |
| 2713 | - // (odd) mi row, which no decode call site does -- every one of them | |
| 2714 | - // uses the snapping form, whose base row is even -- and its result | |
| 2715 | - // feeds `RECT4_16_UV_PAIR_FILT_HITS` only. What it measures is real | |
| 2716 | - // and worth keeping (the pair's chroma-reference read against the | |
| 2717 | - // leaf's own row: 51/24/121/0/1 hits on the five fixtures censused), | |
| 2718 | - // so it stays; the decode path's own reach for the `+ss_y` term is | |
| 2719 | - // `uv_left_1mi_split_hits()`. | |
| 2720 | - if smooth_neighbor_uv | |
| 2721 | - != neighbours.smooth_uv_neighbour_unsnapped( | |
| 2722 | - lmi.0, | |
| 2723 | - lmi.1, | |
| 2724 | - r, | |
| 2725 | - c, | |
| 2726 | - ss_x(fctx), | |
| 2727 | - ss_y(fctx), | |
| 2728 | - false, | |
| 2729 | - ) | |
| 2730 | - { | |
| 2731 | - hit!(RECT4_16_UV_PAIR_FILT_HITS); | |
| 2732 | - } | |
| 2733 | 2532 | // lane-av1-rect14: a lossless frame forces TX_4X4 on every plane |
| 2734 | 2533 | // (`av1_get_tx_size`, blockd.h:1381). The pair's chroma block is |
| 2735 | 2534 | // 8x4 (HORZ_4) or 4x8 (VERT_4) -- two TX_4X4s, plane-major |
| @@ -2739,7 +2538,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2739 | 2538 | // mi(1,20) uv_mode matched, the following skip did not). |
| 2740 | 2539 | let lossless_pair = lossless(fctx); |
| 2741 | 2540 | let (u_levels, v_levels) = if lossless_pair { |
| 2742 | - hit!(RECT4_16_LOSSLESS_CHROMA_HITS); | |
| 2743 | 2541 | if skip { |
| 2744 | 2542 | for plane in 1..3usize { |
| 2745 | 2543 | for rr in 0..ch / 4 { |
| @@ -2773,11 +2571,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2773 | 2571 | 4 << ss_x(fctx), |
| 2774 | 2572 | 4 << ss_y(fctx), |
| 2775 | 2573 | pair_reach, |
| 2776 | - ppx, | |
| 2777 | - ppy, | |
| 2778 | - y.width, | |
| 2779 | - y.height, | |
| 2780 | - fctx, | |
| 2781 | 2574 | ); |
| 2782 | 2575 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 2783 | 2576 | let buf = if plane == 1 { ub } else { vb }; |
| @@ -2868,11 +2661,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2868 | 2661 | 4 << ss_x(fctx), |
| 2869 | 2662 | 4 << ss_y(fctx), |
| 2870 | 2663 | pair_reach, |
| 2871 | - ppx, | |
| 2872 | - ppy, | |
| 2873 | - y.width, | |
| 2874 | - y.height, | |
| 2875 | - fctx, | |
| 2876 | 2664 | ); |
| 2877 | 2665 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 2878 | 2666 | let buf = if plane == 1 { ub } else { vb }; |
| @@ -2896,7 +2684,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2896 | 2684 | cpy + oy, |
| 2897 | 2685 | 4, |
| 2898 | 2686 | 4, |
| 2899 | - base_q_idx, | |
| 2900 | 2687 | None, |
| 2901 | 2688 | None, |
| 2902 | 2689 | offset, |
| @@ -2910,7 +2697,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2910 | 2697 | plane, |
| 2911 | 2698 | &cu_grid, |
| 2912 | 2699 | ); |
| 2913 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 2914 | 2700 | let dst = if plane == 1 { &mut uo } else { &mut vo }; |
| 2915 | 2701 | for row in 0..4 { |
| 2916 | 2702 | let start = (oy + row) * cw + ox; |
| @@ -2929,9 +2715,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2929 | 2715 | // DC + alpha * luma-AC. Dropping the CfL term here left a |
| 2930 | 2716 | // chroma-only bounded box on ReelC's key frames. |
| 2931 | 2717 | let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph)); |
| 2932 | - if alpha.is_some() { | |
| 2933 | - hit!(CHROMA_SKIP_CFL_HITS); | |
| 2934 | - } | |
| 2935 | 2718 | for plane in [1usize, 2] { |
| 2936 | 2719 | if chroma422_pair16 { |
| 2937 | 2720 | // lane-av1-422o: two TX_4X8 units, each predicted on |
| @@ -2940,20 +2723,7 @@ pub(super) fn decode_rect4_16_strip( | ||
| 2940 | 2723 | // `set_entropy_context` zeroed the block's own cells, |
| 2941 | 2724 | // so the pair-wide zero stamp below stays correct. |
| 2942 | 2725 | for unit_row in 0..2usize { |
| 2943 | - let unit_reach = tu_reach_rect( | |
| 2944 | - pw, | |
| 2945 | - ph, | |
| 2946 | - 0, | |
| 2947 | - unit_row * 8, | |
| 2948 | - 8, | |
| 2949 | - 8, | |
| 2950 | - pair_reach, | |
| 2951 | - ppx, | |
| 2952 | - ppy, | |
| 2953 | - y.width, | |
| 2954 | - y.height, | |
| 2955 | - fctx, | |
| 2956 | - ); | |
| 2726 | + let unit_reach = tu_reach_rect(pw, ph, 0, unit_row * 8, 8, 8, pair_reach); | |
| 2957 | 2727 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 2958 | 2728 | let pbuf = if plane == 1 { ub } else { vb }; |
| 2959 | 2729 | set_palette_pred(palette_window(pbuf, cw, 0, unit_row * 8, 4, 8), fctx); |
| @@ -3029,20 +2799,7 @@ pub(super) fn decode_rect4_16_strip( | ||
| 3029 | 2799 | for plane in [1usize, 2] { |
| 3030 | 2800 | for unit_row in 0..2usize { |
| 3031 | 2801 | let unit_mi = (pair_mi.0 + unit_row * 2, pair_mi.1); |
| 3032 | - let unit_reach = tu_reach_rect( | |
| 3033 | - pw, | |
| 3034 | - ph, | |
| 3035 | - 0, | |
| 3036 | - unit_row * 8, | |
| 3037 | - 8, | |
| 3038 | - 8, | |
| 3039 | - pair_reach, | |
| 3040 | - ppx, | |
| 3041 | - ppy, | |
| 3042 | - y.width, | |
| 3043 | - y.height, | |
| 3044 | - fctx, | |
| 3045 | - ); | |
| 2802 | + let unit_reach = tu_reach_rect(pw, ph, 0, unit_row * 8, 8, 8, pair_reach); | |
| 3046 | 2803 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 3047 | 2804 | let pbuf = if plane == 1 { ub } else { vb }; |
| 3048 | 2805 | set_palette_pred(palette_window(pbuf, cw, 0, unit_row * 8, 4, 8), fctx); |
| @@ -3115,10 +2872,7 @@ pub(super) fn decode_rect4_16_strip( | ||
| 3115 | 2872 | // row is unreachable there. It is also the witness arm: |
| 3116 | 2873 | // a restored `/2 chroma height` lands on (8,4) and the |
| 3117 | 2874 | // counter reads 0. |
| 3118 | - (8, 8) => { | |
| 3119 | - hit!(CHROMA422_SQUARE_HITS); | |
| 3120 | - (TxbSet::Chroma8, default_scan(8)) | |
| 3121 | - } | |
| 2875 | + (8, 8) => (TxbSet::Chroma8, default_scan(8)), | |
| 3122 | 2876 | // lane-av1-422o: with the `chroma422_pair16` arm above, |
| 3123 | 2877 | // the (2,16) own-strip shape and the 4:4:4 shapes are the |
| 3124 | 2878 | // only residents; anything else is a named-lane gap. |
| @@ -3141,7 +2895,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 3141 | 2895 | dc_sign_ctx(around[plane].2), |
| 3142 | 2896 | default_tx, |
| 3143 | 2897 | fctx, |
| 3144 | - plane, | |
| 3145 | 2898 | )?; |
| 3146 | 2899 | planes.push((levels, tx_type)); |
| 3147 | 2900 | } |
| @@ -3225,11 +2978,6 @@ pub(super) fn decode_rect4_16_strip( | ||
| 3225 | 2978 | } |
| 3226 | 2979 | last_uv_mode = Some(uv_predict_mode); |
| 3227 | 2980 | } |
| 3228 | - if horz { | |
| 3229 | - hit!(RECT4_16_HORZ_HITS); | |
| 3230 | - } else { | |
| 3231 | - hit!(RECT4_16_VERT_HITS); | |
| 3232 | - } | |
| 3233 | 2981 | let (pal_y_size, pal_y_colors) = palette_y |
| 3234 | 2982 | .as_ref() |
| 3235 | 2983 | .map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| @@ -3354,17 +3102,7 @@ pub(super) fn decode_block_rect64( | ||
| 3354 | 3102 | fctx, |
| 3355 | 3103 | ); |
| 3356 | 3104 | } |
| 3357 | - if (palette_y.is_some() || palette_uv.is_some()) && !skip { | |
| 3358 | - // lane-t900 r34: a non-skip palette block on a superblock-level strip | |
| 3359 | - // -- counted so its gate cannot go vacuous (this was a refusal until | |
| 3360 | - // r34; see the gate `a_real_aomenc_palette_stream_with_8x8_leaves_ | |
| 3361 | - // decodes_pixel_exact`). | |
| 3362 | - hit!(PALETTE_SB_STRIP_HITS); | |
| 3363 | - } | |
| 3364 | 3105 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 3365 | - if smooth_neighbor { | |
| 3366 | - hit!(SMOOTH_LUMA_HITS); | |
| 3367 | - } | |
| 3368 | 3106 | let smooth_neighbor_uv = |
| 3369 | 3107 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c, fctx); |
| 3370 | 3108 | if filter_intra.is_some() { |
| @@ -3394,7 +3132,7 @@ pub(super) fn decode_block_rect64( | ||
| 3394 | 3132 | // 1920x792 128-superblock stream, |
| 3395 | 3133 | // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read |
| 3396 | 3134 | // `tx_size_cat2` row 1 where libaom reads row 2. |
| 3397 | - let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh, fctx); | |
| 3135 | + let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh); | |
| 3398 | 3136 | // lane-rectsplit r1: `bsize_to_tx_size_cat` (libaom `decodemv.c`) |
| 3399 | 3137 | // counts `sub_tx_size_map` steps from the block's own max rect |
| 3400 | 3138 | // transform down to TX_4X4, minus one -- BLOCK_64X32's chain |
| @@ -3403,12 +3141,6 @@ pub(super) fn decode_block_rect64( | ||
| 3403 | 3141 | // block uses), not the 2 a 32x16 strip uses. Reading the cat-2 CDF |
| 3404 | 3142 | // here was a wrong-table read of a real symbol. |
| 3405 | 3143 | let d = dec.symbol(&mut cdfs.tx_size_cat3[ctx]); |
| 3406 | - if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | |
| 3407 | - eprintln!( | |
| 3408 | - "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat=3 rng={}", | |
| 3409 | - dec.debug_state().0 | |
| 3410 | - ); | |
| 3411 | - } | |
| 3412 | 3144 | d |
| 3413 | 3145 | } else { |
| 3414 | 3146 | 0 |
| @@ -3423,28 +3155,12 @@ pub(super) fn decode_block_rect64( | ||
| 3423 | 3155 | fctx, |
| 3424 | 3156 | ); |
| 3425 | 3157 | if depth != 0 || lossless(fctx) { |
| 3426 | - hit!(TX_DEPTH_HITS); | |
| 3427 | 3158 | // lane-rectsplit r1/r4: the superblock-level strip splits its |
| 3428 | 3159 | // transform through the very same per-unit path as its 32x32-level |
| 3429 | 3160 | // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 |
| 3430 | 3161 | // 1:4 strip is the 2:1 rect TX_32X16 at depth 1 (lane-rectchroma r1 |
| 3431 | 3162 | // measured the old square formula mis-tiling exactly that strip). |
| 3432 | 3163 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 3433 | - if bw.max(bh) / bw.min(bh) == 4 { | |
| 3434 | - let which = if depth == 1 { | |
| 3435 | - &RECT4_SPLIT_DEPTH1_HITS | |
| 3436 | - } else { | |
| 3437 | - &RECT4_SPLIT_DEPTH2_HITS | |
| 3438 | - }; | |
| 3439 | - hit_do! { which.with(|c| c.set(c.get() + 1)); } | |
| 3440 | - } | |
| 3441 | - if crate::envflags::env_flag!("EC_SBPART_DUMP64") { | |
| 3442 | - eprintln!( | |
| 3443 | - "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ | |
| 3444 | - depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \ | |
| 3445 | - angle_y={angle_delta_y}" | |
| 3446 | - ); | |
| 3447 | - } | |
| 3448 | 3164 | let modes = RectStripModes { |
| 3449 | 3165 | skip, |
| 3450 | 3166 | mode, |
| @@ -3465,9 +3181,6 @@ pub(super) fn decode_block_rect64( | ||
| 3465 | 3181 | ) |
| 3466 | 3182 | }), |
| 3467 | 3183 | }; |
| 3468 | - if palette_y.is_some() || palette_uv.is_some() { | |
| 3469 | - hit!(PALETTE_SPLIT_TX_HITS); | |
| 3470 | - } | |
| 3471 | 3184 | decode_rect_split( |
| 3472 | 3185 | dec, |
| 3473 | 3186 | cdfs, |
| @@ -3481,7 +3194,6 @@ pub(super) fn decode_block_rect64( | ||
| 3481 | 3194 | y, |
| 3482 | 3195 | u, |
| 3483 | 3196 | v, |
| 3484 | - base_q_idx, | |
| 3485 | 3197 | reduced_tx_set, |
| 3486 | 3198 | fctx, |
| 3487 | 3199 | )?; |
| @@ -3506,8 +3218,6 @@ pub(super) fn decode_block_rect64( | ||
| 3506 | 3218 | // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The |
| 3507 | 3219 | // bands carry the SPLIT unit's size, not the block's. |
| 3508 | 3220 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); |
| 3509 | - hit!(RECT64_SPLIT_TXFM_PUBLISH_HITS); | |
| 3510 | - hit!(RECT_PARTITION_HITS); | |
| 3511 | 3221 | return Ok(()); |
| 3512 | 3222 | } |
| 3513 | 3223 | let (tx_w, tx_h) = (bw, bh); |
| @@ -3617,12 +3327,6 @@ pub(super) fn decode_block_rect64( | ||
| 3617 | 3327 | // 32x16/16x32 under a 64x16/16x64 1:4 strip (lane-tx64x16). |
| 3618 | 3328 | let (luma_cw, luma_ch) = (bw.min(32), bh.min(32)); |
| 3619 | 3329 | let scan32 = default_scan(TX32); |
| 3620 | - if coeff_trace_on() { | |
| 3621 | - let (rng, _) = dec.debug_state(); | |
| 3622 | - eprintln!( | |
| 3623 | - "EC_COEFF plane=0 row={mi_r} col={mi_c} tx_size={luma_cw}x{luma_ch} rng={rng}" | |
| 3624 | - ); | |
| 3625 | - } | |
| 3626 | 3330 | let (luma_corner, luma_tx_type) = if (luma_cw, luma_ch) == (32, 32) { |
| 3627 | 3331 | let mut luma_coding = cdfs.txb(TxbSet::Luma64, mode); |
| 3628 | 3332 | read_coeffs( |
| @@ -3659,29 +3363,13 @@ pub(super) fn decode_block_rect64( | ||
| 3659 | 3363 | 0, |
| 3660 | 3364 | dc_sign_ctx(around[0].2), |
| 3661 | 3365 | TxType::DctDct, |
| 3662 | - 0, | |
| 3663 | 3366 | )? |
| 3664 | 3367 | }; |
| 3665 | - if coeff_trace_on() { | |
| 3666 | - let (rng, _) = dec.debug_state(); | |
| 3667 | - eprintln!("EC_COEFF_VAL plane=0 row={mi_r} col={mi_c} rng={rng}"); | |
| 3668 | - } | |
| 3669 | 3368 | let mut luma_levels = vec![0i32; bw * bh]; |
| 3670 | 3369 | for row in 0..luma_ch { |
| 3671 | 3370 | luma_levels[row * bw..][..luma_cw] |
| 3672 | 3371 | .copy_from_slice(&luma_corner[row * luma_cw..][..luma_cw]); |
| 3673 | 3372 | } |
| 3674 | - { | |
| 3675 | - let cur = block_q_idx(fctx); | |
| 3676 | - if cur != i32::from(base_q_idx) { | |
| 3677 | - hit!(RECT64_QIDX_DRIFT_HITS); | |
| 3678 | - } | |
| 3679 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 3680 | - eprintln!( | |
| 3681 | - "TRACE rect64_dequant plane=0 base_q_idx={base_q_idx} current_q_idx={cur}" | |
| 3682 | - ); | |
| 3683 | - } | |
| 3684 | - } | |
| 3685 | 3373 | let luma_residual = dequant_and_inverse_typed_wh( |
| 3686 | 3374 | &luma_levels, |
| 3687 | 3375 | bw, |
| @@ -3711,22 +3399,6 @@ pub(super) fn decode_block_rect64( | ||
| 3711 | 3399 | smooth_neighbor, |
| 3712 | 3400 | fctx, |
| 3713 | 3401 | ); |
| 3714 | - if crate::envflags::env_flag!("EC_SBPART_DUMP64") { | |
| 3715 | - let leftcol: Vec<u16> = if px > 0 { | |
| 3716 | - (py..py + bh) | |
| 3717 | - .map(|row| y.data[row * y.width + px - 1]) | |
| 3718 | - .collect() | |
| 3719 | - } else { | |
| 3720 | - vec![] | |
| 3721 | - }; | |
| 3722 | - eprintln!( | |
| 3723 | - "DUMP64 mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} mode={mode} \ | |
| 3724 | - skip={skip} eob_nonzero={} row0={:?} leftcol={:?}", | |
| 3725 | - luma_corner.iter().any(|&v| v != 0), | |
| 3726 | - &y.data[py * y.width + px..][..bw], | |
| 3727 | - leftcol, | |
| 3728 | - ); | |
| 3729 | - } | |
| 3730 | 3402 | // CHROMA. At 4:2:0 the plane block is already one adjusted UV |
| 3731 | 3403 | // transform (<=32 on each axis). At 4:4:4 a 64-axis strip's chroma |
| 3732 | 3404 | // is larger than that, so it is tiled into 32-capped units. |
| @@ -3753,15 +3425,6 @@ pub(super) fn decode_block_rect64( | ||
| 3753 | 3425 | // arm nothing had reached) from `nh >= 2` (the arm the corpus census |
| 3754 | 3426 | // already covered), and can see WHY a candidate block did not fire. |
| 3755 | 3427 | // Diagnostic only; no decode behaviour depends on it. |
| 3756 | - if crate::envflags::env_flag!("EC_PALWALK") { | |
| 3757 | - eprintln!( | |
| 3758 | - "EC_PALWALK mi={r},{c} px={px} py={py} bw={bw} bh={bh} cw={chroma_w} \ | |
| 3759 | - ch={chroma_h} uw={uw} uh={uh} nw={nw} nh={nh} ast={allow_screen_content_tools} \ | |
| 3760 | - puv={} py_pal={}", | |
| 3761 | - palette_uv.is_some() as i32, | |
| 3762 | - palette_y.is_some() as i32 | |
| 3763 | - ); | |
| 3764 | - } | |
| 3765 | 3428 | let mut u_levels = vec![0i32; chroma_w * chroma_h]; |
| 3766 | 3429 | let mut v_levels = vec![0i32; chroma_w * chroma_h]; |
| 3767 | 3430 | // The tiled units below stamp their own coefficient context |
| @@ -3813,9 +3476,6 @@ pub(super) fn decode_block_rect64( | ||
| 3813 | 3476 | // nothing. The `bigger` guard is what makes a hit PROOF |
| 3814 | 3477 | // that the tiled arm ran, rather than proof that some |
| 3815 | 3478 | // palette chroma block existed. |
| 3816 | - if bigger { | |
| 3817 | - hit!(CHROMA_PALETTE_WINDOW_HITS); | |
| 3818 | - } | |
| 3819 | 3479 | } |
| 3820 | 3480 | read_plane( |
| 3821 | 3481 | dec, |
| @@ -3835,7 +3495,6 @@ pub(super) fn decode_block_rect64( | ||
| 3835 | 3495 | cpy + cu_row * uh, |
| 3836 | 3496 | uw, |
| 3837 | 3497 | uw, |
| 3838 | - base_q_idx, | |
| 3839 | 3498 | cfl, |
| 3840 | 3499 | None, |
| 3841 | 3500 | bigger.then_some(3), |
| @@ -3857,7 +3516,6 @@ pub(super) fn decode_block_rect64( | ||
| 3857 | 3516 | dc_sign_ctx(cu_around[plane_idx].2), |
| 3858 | 3517 | TxType::DctDct, |
| 3859 | 3518 | fctx, |
| 3860 | - plane_idx, | |
| 3861 | 3519 | )?; |
| 3862 | 3520 | let residual = dequant_and_inverse_typed_wh( |
| 3863 | 3521 | &levels, |
| @@ -3883,9 +3541,6 @@ pub(super) fn decode_block_rect64( | ||
| 3883 | 3541 | // nothing. The `bigger` guard is what makes a hit PROOF |
| 3884 | 3542 | // that the tiled arm ran, rather than proof that some |
| 3885 | 3543 | // palette chroma block existed. |
| 3886 | - if bigger { | |
| 3887 | - hit!(CHROMA_PALETTE_WINDOW_HITS); | |
| 3888 | - } | |
| 3889 | 3544 | } |
| 3890 | 3545 | push_intra_rect( |
| 3891 | 3546 | y, |
| @@ -3949,7 +3604,6 @@ pub(super) fn decode_block_rect64( | ||
| 3949 | 3604 | for (cu_mi, plane, unit, span_w, span_h) in &tiled_chroma_units { |
| 3950 | 3605 | neighbours.record_mi_chroma(*cu_mi, *span_w, *span_h, *plane, unit); |
| 3951 | 3606 | } |
| 3952 | - hit!(RECT_COEFF_HITS); | |
| 3953 | 3607 | } |
| 3954 | 3608 | let (py_size, py_colors) = palette_y |
| 3955 | 3609 | .as_ref() |
| @@ -3980,15 +3634,5 @@ pub(super) fn decode_block_rect64( | ||
| 3980 | 3634 | // 3840x1608 10-bit stream's first silent wall, decode-order frame 33 at |
| 3981 | 3635 | // mi(16,480)). Same write as [`set_txfm_ctxs`], rect-aware. |
| 3982 | 3636 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); |
| 3983 | - hit!(SB_RECT_HITS); | |
| 3984 | - match (bw, bh) { | |
| 3985 | - (64, 16) => hit!(SB_RECT4_HORZ_HITS), | |
| 3986 | - (16, 64) => hit!(SB_RECT4_VERT_HITS), | |
| 3987 | - _ => {} | |
| 3988 | - } | |
| 3989 | - if crate::envflags::env_flag!("EC_AV1_TRACE") { | |
| 3990 | - let (rng, _) = dec.debug_state(); | |
| 3991 | - eprintln!("TRACE_RECT64_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} rng={rng}"); | |
| 3992 | - } | |
| 3993 | 3637 | Ok(()) |
| 3994 | 3638 | } |
crates/ec-av1/src/decode/replay.rsmodified+0 -18
| @@ -179,7 +179,6 @@ fn replay_inner( | ||
| 179 | 179 | &mut v, |
| 180 | 180 | cdef, |
| 181 | 181 | &r.neighbours, |
| 182 | - (r.frame_width, r.frame_height), | |
| 183 | 182 | fctx, |
| 184 | 183 | pre, |
| 185 | 184 | Some(&mut wrote), |
| @@ -449,7 +448,6 @@ pub(super) fn cdef_band( | ||
| 449 | 448 | coeff_shift: i32, |
| 450 | 449 | damping: i32, |
| 451 | 450 | damping_uv: i32, |
| 452 | - (frame_w, frame_h): (usize, usize), | |
| 453 | 451 | fctx: &crate::decode::FrameCtx, |
| 454 | 452 | ) { |
| 455 | 453 | let unit_cols = skip_grid.mi_cols.div_ceil(2); |
| @@ -471,9 +469,6 @@ pub(super) fn cdef_band( | ||
| 471 | 469 | while mi_r < r_hi { |
| 472 | 470 | let mut mi_c = 0usize; |
| 473 | 471 | while mi_c < skip_grid.mi_cols { |
| 474 | - if skip_grid.is_skip_txfm(mi_r, mi_c) { | |
| 475 | - hit!(CDEF_SKIPPED_UNITS); | |
| 476 | - } | |
| 477 | 472 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { |
| 478 | 473 | let sidx = strength_idx(mi_r, mi_c); |
| 479 | 474 | let (ox, oy) = (mi_c * 4, mi_r * 4); |
| @@ -511,21 +506,8 @@ pub(super) fn cdef_band( | ||
| 511 | 506 | let y_dir = if y_pri_strength != 0 { dir } else { 0 }; |
| 512 | 507 | let t = cdef_adjust_strength(y_pri_strength, var); |
| 513 | 508 | // lane-cdef r1 rung: one line per filtered 8x8 luma CDEF unit. |
| 514 | - if crate::envflags::env_flag!("EC_AV1_CDEF_DBG") { | |
| 515 | - eprintln!( | |
| 516 | - "EC_CDEF mi_r={mi_r} mi_c={mi_c} x={ox} y={oy} sidx={sidx} dir={dir} var={var} t={t} pri={y_pri_strength} sec={y_sec_strength} damp={damping}" | |
| 517 | - ); | |
| 518 | - } | |
| 519 | 509 | let enable_primary = t != 0; |
| 520 | 510 | let enable_secondary = y_sec_strength != 0; |
| 521 | - if (ox + 8 > frame_w || oy + 8 > frame_h) | |
| 522 | - && (enable_primary | |
| 523 | - || enable_secondary | |
| 524 | - || cdef.uv_pri_strength[sidx] != 0 | |
| 525 | - || cdef.uv_sec_strength[sidx] != 0) | |
| 526 | - { | |
| 527 | - hit!(CDEF_STRADDLE_UNITS); | |
| 528 | - } | |
| 529 | 511 | if enable_primary || enable_secondary { |
| 530 | 512 | cdef_filter_block( |
| 531 | 513 | &win_y, |
crates/ec-av1/src/decode/sub8_inter.rsmodified+85 -285
| @@ -62,7 +62,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 62 | 62 | ) -> Result<()> { |
| 63 | 63 | const LAST_FRAME: i8 = 1; |
| 64 | 64 | const B4: usize = 4; |
| 65 | - hit!(SUB8_INTER_SPLIT_HITS); | |
| 66 | 65 | let (gr, gc) = group_mi; |
| 67 | 66 | let (gpx, gpy) = (gc * MI, gr * MI); |
| 68 | 67 | let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx)); |
| @@ -72,7 +71,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 72 | 71 | let mut piece: [Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>; 4] = |
| 73 | 72 | [None; 4]; |
| 74 | 73 | let mut first_tx_type = TxType::DctDct; |
| 75 | - let mut sub0_tx_type = TxType::DctDct; | |
| 76 | 74 | // This loop iteration's own sub-block luma `tx_type` (libaom `mbmi->tx_type` |
| 77 | 75 | // after its `read_tx_type`): the per-piece 4:4:4 chroma units inherit it |
| 78 | 76 | // (`av1_get_tx_type`, blockd.h -- inter chroma never codes its own symbol). |
| @@ -111,11 +109,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 111 | 109 | let skip_ctx = |
| 112 | 110 | usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); |
| 113 | 111 | let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; |
| 114 | - let ec_skip_post = if std::env::var_os("EC_DBG_SUB8").is_some() { | |
| 115 | - Some(dec.debug_state().0) | |
| 116 | - } else { | |
| 117 | - None | |
| 118 | - }; | |
| 119 | 112 | inter_segment_id(dec, cdfs, rmi, cmi, 1, 1, skip, false, fctx); |
| 120 | 113 | maybe_read_cdef_idx(dec, rmi, cmi, (2, 2), skip, fctx); |
| 121 | 114 | maybe_read_delta_q(dec, cdfs, rmi, cmi, false, skip, fctx); |
| @@ -128,32 +121,7 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 128 | 121 | neighbours.left_inter[rmi], |
| 129 | 122 | ); |
| 130 | 123 | let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; |
| 131 | - if std::env::var_os("EC_DBG_SUB8").is_some() { | |
| 132 | - eprintln!( | |
| 133 | - "EC_DBG piece mi=({rmi},{cmi}) skip={skip} skipctx={skip_ctx} skip_post={:?} is_inter={is_inter} iictx={ii_ctx} post={}", | |
| 134 | - ec_skip_post, | |
| 135 | - dec.debug_state().0 | |
| 136 | - ); | |
| 137 | - } | |
| 138 | 124 | if !is_inter { |
| 139 | - if crate::envflags::env_flag!("EC_SUB8INTRA") { | |
| 140 | - eprintln!( | |
| 141 | - "EC_SUB8INTRA shape=4x4 sub={i} has_chroma={} skip={skip} mi={rmi},{cmi} tx_select={}", | |
| 142 | - i == 3, | |
| 143 | - fctx.tx_select_inter.with(std::cell::Cell::get), | |
| 144 | - ); | |
| 145 | - } | |
| 146 | - // lane-sub8x4 r2: the refusal and its `EC_SUB8INTRA_DECODE` bypass | |
| 147 | - // are gone -- `a_real_aomenc_inter_sequence_with_intra_sub8x8_ | |
| 148 | - // leaves_decodes_pixel_exact` (stream.rs) decodes 12 real aomenc | |
| 149 | - // streams carrying this arm pixel-exact vs ffmpeg. | |
| 150 | - hit_do! { | |
| 151 | - SUB8_INTRA_RECT_HITS.with(|h| { | |
| 152 | - let mut st = h.get(); | |
| 153 | - st[4] += 1; | |
| 154 | - h.set(st); | |
| 155 | - }); | |
| 156 | - } | |
| 157 | 125 | // lane-sub8intra: the `BLOCK_4X4` twin of the HORZ/VERT arm -- |
| 158 | 126 | // same [`decode_intra_sub8_leaf`], no tx-depth symbol, chroma on |
| 159 | 127 | // the chroma-reference sub-blocks (`is_chroma_reference`: the |
| @@ -173,7 +141,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 173 | 141 | y, |
| 174 | 142 | u, |
| 175 | 143 | v, |
| 176 | - base_q_idx, | |
| 177 | 144 | fctx.enable_filter_intra_inter.with(std::cell::Cell::get), |
| 178 | 145 | fctx.tx_select_inter.with(std::cell::Cell::get), |
| 179 | 146 | reduced_tx_set, |
| @@ -187,12 +154,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 187 | 154 | // Same print point as the oracle's `EC_MODE` (entry of |
| 188 | 155 | // `read_inter_block_mode_info`, i.e. after skip / is_inter), so the |
| 189 | 156 | // two range ladders line up element for element. |
| 190 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 191 | - eprintln!( | |
| 192 | - "EC_MODE mi_row={rmi} mi_col={cmi} rng={}", | |
| 193 | - dec.debug_state().0 | |
| 194 | - ); | |
| 195 | - } | |
| 196 | 157 | let ref_frame = read_single_ref( |
| 197 | 158 | dec, |
| 198 | 159 | cdfs, |
| @@ -209,9 +170,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 209 | 170 | // each of the group's pieces (luma and its 2x2 chroma) carries its |
| 210 | 171 | // OWN factor because each can name a different `ref_frame`. |
| 211 | 172 | let luma_scale = scale_of((ref_width, ref_height), frame_size); |
| 212 | - if !luma_scale.is_unscaled() { | |
| 213 | - hit!(SCALED_SUB8_HITS); | |
| 214 | - } | |
| 215 | 173 | let gm_table = build_gm_mv_table( |
| 216 | 174 | global_motion, |
| 217 | 175 | rmi, |
| @@ -245,10 +203,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 245 | 203 | tpl, |
| 246 | 204 | ); |
| 247 | 205 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| 248 | - if !not_new { | |
| 249 | - crate::census::mode(0); | |
| 250 | - } | |
| 251 | - let mut is_globalmv = false; | |
| 252 | 206 | let (mv, is_new_mv) = if !not_new { |
| 253 | 207 | let mut idx = 0usize; |
| 254 | 208 | while idx < 2 && stack.entries.len() > idx + 1 { |
| @@ -272,15 +226,10 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 272 | 226 | ) |
| 273 | 227 | } else { |
| 274 | 228 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; |
| 275 | - if !not_zero { | |
| 276 | - crate::census::mode(1); | |
| 277 | - } | |
| 278 | - is_globalmv = !not_zero; | |
| 279 | 229 | let mv = if !not_zero { |
| 280 | 230 | gm_table[(ref_frame - LAST_FRAME) as usize] |
| 281 | 231 | } else { |
| 282 | 232 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; |
| 283 | - crate::census::mode(if nearest { 2 } else { 3 }); | |
| 284 | 233 | if nearest { |
| 285 | 234 | stack.nearest_mv |
| 286 | 235 | } else { |
| @@ -298,17 +247,8 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 298 | 247 | }; |
| 299 | 248 | // Same print point as the oracle's `EC_MODE_MV` (right after |
| 300 | 249 | // `assign_mv`), the second rung of the sub-8x8 range ladder. |
| 301 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 302 | - eprintln!( | |
| 303 | - "EC_MODE_MV mi_row={rmi} mi_col={cmi} mv0=({},{}) rng={}", | |
| 304 | - mv.0, | |
| 305 | - mv.1, | |
| 306 | - dec.debug_state().0 | |
| 307 | - ); | |
| 308 | - } | |
| 309 | 250 | // No `interintra` and no `motion_mode`/`obmc` symbol below 8x8 (see |
| 310 | 251 | // this function's own doc); `read_mb_interp_filter` still runs. |
| 311 | - let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize]; | |
| 312 | 252 | let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame |
| 313 | 253 | || neighbours.above_ref1[cmi] == Some(ref_frame) |
| 314 | 254 | { |
| @@ -323,25 +263,10 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 323 | 263 | } else { |
| 324 | 264 | [3, 3] |
| 325 | 265 | }; |
| 326 | - if crate::envflags::env_flag!("EC_AV1_IFDBG") { | |
| 327 | - eprintln!( | |
| 328 | - "IFDBG4 mi=({rmi},{cmi}) ref={ref_frame} above_ref={} above_ref1={:?} \ | |
| 329 | - above_filt={:?} left_ref={} left_ref1={:?} left_filt={:?}", | |
| 330 | - neighbours.above_ref[cmi], | |
| 331 | - neighbours.above_ref1[cmi], | |
| 332 | - neighbours.above_filter[cmi], | |
| 333 | - neighbours.left_ref[rmi], | |
| 334 | - neighbours.left_ref1[rmi], | |
| 335 | - neighbours.left_filter[rmi], | |
| 336 | - ); | |
| 337 | - } | |
| 338 | 266 | // lane-t900 r9: this reader's sub-blocks have a 4-px side, and libaom |
| 339 | 267 | // `is_nontrans_global_motion` returns 0 for |
| 340 | 268 | // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model -- |
| 341 | 269 | // so a GLOBALMV sub-block here always reads its interp filter. |
| 342 | - if is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation { | |
| 343 | - hit!(GM_NONTRANS_SMALL_SIDE_HITS); | |
| 344 | - } | |
| 345 | 270 | let gm_nontrans = false; |
| 346 | 271 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( |
| 347 | 272 | dec, |
| @@ -353,16 +278,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 353 | 278 | left_filter_ctx, |
| 354 | 279 | false, |
| 355 | 280 | ); |
| 356 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 357 | - eprintln!( | |
| 358 | - "EC_MODE_VAL4 mi_row={rmi} mi_col={cmi} newmv={is_new_mv} globalmv={is_globalmv} \ | |
| 359 | - ref0={ref_frame} mv0=({},{}) stack={} rng={}", | |
| 360 | - mv.0, | |
| 361 | - mv.1, | |
| 362 | - stack.entries.len(), | |
| 363 | - dec.debug_state().0 | |
| 364 | - ); | |
| 365 | - } | |
| 366 | 281 | grid.set( |
| 367 | 282 | rmi, |
| 368 | 283 | cmi, |
| @@ -412,7 +327,11 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 412 | 327 | let pred_y: Vec<u16>; |
| 413 | 328 | let sy = if pred_deferred(refpix) { |
| 414 | 329 | push_pred(build); |
| 415 | - Pred::Cur { plane: 0, stride: B4, off: 0 } | |
| 330 | + Pred::Cur { | |
| 331 | + plane: 0, | |
| 332 | + stride: B4, | |
| 333 | + off: 0, | |
| 334 | + } | |
| 416 | 335 | } else { |
| 417 | 336 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 418 | 337 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -454,9 +373,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 454 | 373 | fctx, |
| 455 | 374 | )?; |
| 456 | 375 | piece_tx_type = tx_type; |
| 457 | - if i == 0 { | |
| 458 | - sub0_tx_type = tx_type; | |
| 459 | - } | |
| 460 | 376 | if i == 3 { |
| 461 | 377 | // `av1_get_tx_type`'s chroma tail scales `blk_row`/`blk_col` |
| 462 | 378 | // back by the subsampling, but it indexes `xd->tx_type_map`, |
| @@ -522,7 +438,18 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 522 | 438 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); |
| 523 | 439 | let (su, sv) = if pred_deferred(refpix) { |
| 524 | 440 | push_pred(build_c); |
| 525 | - (Pred::Cur { plane: 1, stride: B4, off: 0 }, Pred::Cur { plane: 2, stride: B4, off: 0 }) | |
| 441 | + ( | |
| 442 | + Pred::Cur { | |
| 443 | + plane: 1, | |
| 444 | + stride: B4, | |
| 445 | + off: 0, | |
| 446 | + }, | |
| 447 | + Pred::Cur { | |
| 448 | + plane: 2, | |
| 449 | + stride: B4, | |
| 450 | + off: 0, | |
| 451 | + }, | |
| 452 | + ) | |
| 526 | 453 | } else { |
| 527 | 454 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 528 | 455 | build_c(y, u, v, refpix, fctx, &mut built); |
| @@ -706,7 +633,18 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 706 | 633 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); |
| 707 | 634 | let (su, sv) = if pred_deferred(refpix) { |
| 708 | 635 | push_pred(build_c); |
| 709 | - (Pred::Cur { plane: 1, stride: B4, off: 0 }, Pred::Cur { plane: 2, stride: B4, off: 0 }) | |
| 636 | + ( | |
| 637 | + Pred::Cur { | |
| 638 | + plane: 1, | |
| 639 | + stride: B4, | |
| 640 | + off: 0, | |
| 641 | + }, | |
| 642 | + Pred::Cur { | |
| 643 | + plane: 2, | |
| 644 | + stride: B4, | |
| 645 | + off: 0, | |
| 646 | + }, | |
| 647 | + ) | |
| 710 | 648 | } else { |
| 711 | 649 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 712 | 650 | build_c(y, u, v, refpix, fctx, &mut built); |
| @@ -747,7 +685,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 747 | 685 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]); |
| 748 | 686 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]); |
| 749 | 687 | } else { |
| 750 | - hit!(CHROMA422_INTER_SUB8_HITS); | |
| 751 | 688 | let (ug, _) = read_inter_plane( |
| 752 | 689 | dec, |
| 753 | 690 | cdfs, |
| @@ -860,15 +797,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 860 | 797 | // mi of the group is intra: the group's 4x4 chroma is then predicted WHOLE |
| 861 | 798 | // from the chroma-reference (last) sub-block's own mv, not in 2x2 pieces. |
| 862 | 799 | let mixed = piece.iter().any(Option::is_none); |
| 863 | - if mixed { | |
| 864 | - hit_do! { | |
| 865 | - SUB8_INTRA_RECT_HITS.with(|h| { | |
| 866 | - let mut st = h.get(); | |
| 867 | - st[3] += 1; | |
| 868 | - h.set(st); | |
| 869 | - }); | |
| 870 | - } | |
| 871 | - } | |
| 872 | 800 | // lane-sub8group: the group's chroma pieces, built where they are |
| 873 | 801 | // written -- the pieces' refs/mvs/filters travel by value. |
| 874 | 802 | let build = move |_y: &mut PlaneBuf<'static>, |
| @@ -934,7 +862,18 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 934 | 862 | let (pred_u, pred_v): (Vec<u16>, Vec<u16>); |
| 935 | 863 | let (su, sv) = if pred_deferred(refpix) { |
| 936 | 864 | push_pred(build); |
| 937 | - (Pred::Cur { plane: 1, stride: B4, off: 0 }, Pred::Cur { plane: 2, stride: B4, off: 0 }) | |
| 865 | + ( | |
| 866 | + Pred::Cur { | |
| 867 | + plane: 1, | |
| 868 | + stride: B4, | |
| 869 | + off: 0, | |
| 870 | + }, | |
| 871 | + Pred::Cur { | |
| 872 | + plane: 2, | |
| 873 | + stride: B4, | |
| 874 | + off: 0, | |
| 875 | + }, | |
| 876 | + ) | |
| 938 | 877 | } else { |
| 939 | 878 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 940 | 879 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -1012,8 +951,6 @@ pub(super) fn decode_inter_sub8_split4( | ||
| 1012 | 951 | fctx, |
| 1013 | 952 | )? |
| 1014 | 953 | .0; |
| 1015 | - let coded = ug.iter().chain(vg.iter()).any(|&c| c != 0); | |
| 1016 | - note_sub8_chroma_tx(sub0_tx_type, first_tx_type, coded); | |
| 1017 | 954 | (ug, vg) |
| 1018 | 955 | }; |
| 1019 | 956 | let round_up_even = |n: usize| n.div_ceil(2) * 2; |
| @@ -1066,7 +1003,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1066 | 1003 | grid: &mut MiGrid, |
| 1067 | 1004 | group_mi: (usize, usize), |
| 1068 | 1005 | lmi: (usize, usize), |
| 1069 | - // `(bw, bh)`: 8x4 / 4x8 under HORZ/VERT, 4x4 under SPLIT. | |
| 1070 | 1006 | (bw, bh): (usize, usize), |
| 1071 | 1007 | has_chroma: bool, |
| 1072 | 1008 | skip: bool, |
| @@ -1074,7 +1010,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1074 | 1010 | y: &mut PlaneBuf<'static>, |
| 1075 | 1011 | u: &mut PlaneBuf<'static>, |
| 1076 | 1012 | v: &mut PlaneBuf<'static>, |
| 1077 | - base_q_idx: u8, | |
| 1078 | 1013 | enable_filter_intra: bool, |
| 1079 | 1014 | tx_select: bool, |
| 1080 | 1015 | reduced_tx_set: bool, |
| @@ -1090,19 +1025,9 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1090 | 1025 | let (above_mode, left_mode) = neighbours.modes_above_left(r, c); |
| 1091 | 1026 | let leaf_above = neighbours.mode_above_mi(lmi.0, lmi.1).unwrap_or(above_mode); |
| 1092 | 1027 | let leaf_left = neighbours.mode_left_mi(lmi.0, lmi.1).unwrap_or(left_mode); |
| 1093 | - let step = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); | |
| 1094 | 1028 | // `size_group_lookup[BLOCK_8X4] == size_group_lookup[BLOCK_4X8] == 0` |
| 1095 | 1029 | // (libaom common_data.h:61). |
| 1096 | - crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | |
| 1097 | 1030 | let mode = dec.symbol(&mut cdfs.y_mode[0]); |
| 1098 | - if step { | |
| 1099 | - eprintln!( | |
| 1100 | - "EC_ISTEP mi_row={} mi_col={} name=mode val={mode} rng={}", | |
| 1101 | - lmi.0, | |
| 1102 | - lmi.1, | |
| 1103 | - dec.debug_state().0 | |
| 1104 | - ); | |
| 1105 | - } | |
| 1106 | 1031 | // No angle delta below 8x8 (`av1_use_angle_delta`), for luma or chroma. |
| 1107 | 1032 | let angle_delta_y = 0; |
| 1108 | 1033 | let (uv_mode, alpha) = if has_chroma { |
| @@ -1116,31 +1041,15 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1116 | 1041 | // always 4x4-or-smaller, so the predicate stays true and this read |
| 1117 | 1042 | // is unchanged. |
| 1118 | 1043 | let uv_mode = if cfl_allowed_px(bw, bh, fctx) { |
| 1119 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 1120 | 1044 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 1121 | 1045 | } else { |
| 1122 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 1123 | 1046 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 1124 | 1047 | }; |
| 1125 | - if step { | |
| 1126 | - eprintln!( | |
| 1127 | - "EC_ISTEP mi_row={} mi_col={} name=uv_mode val={uv_mode} rng={}", | |
| 1128 | - lmi.0, | |
| 1129 | - lmi.1, | |
| 1130 | - dec.debug_state().0 | |
| 1131 | - ); | |
| 1132 | - } | |
| 1133 | - if (9..=12).contains(&uv_mode) { | |
| 1134 | - hit!(SMOOTH_UV_HITS); | |
| 1135 | - } | |
| 1136 | 1048 | let alpha = if uv_mode == UV_CFL_PRED { |
| 1137 | 1049 | Some(read_cfl_alphas(dec, cdfs)) |
| 1138 | 1050 | } else { |
| 1139 | 1051 | None |
| 1140 | 1052 | }; |
| 1141 | - if (V_PRED..=D67_PRED).contains(&uv_mode) { | |
| 1142 | - hit!(DIRECTIONAL_UV_HITS); | |
| 1143 | - } | |
| 1144 | 1053 | (uv_mode, alpha) |
| 1145 | 1054 | } else { |
| 1146 | 1055 | (DC_PRED, None) |
| @@ -1154,27 +1063,8 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1154 | 1063 | .expect("BLOCK_4X8/BLOCK_8X4 are inside av1_filter_intra_allowed_bsize") |
| 1155 | 1064 | }; |
| 1156 | 1065 | let use_fi = dec.symbol(&mut cdfs.filter_intra[fi_class]); |
| 1157 | - if step { | |
| 1158 | - eprintln!( | |
| 1159 | - "EC_ISTEP mi_row={} mi_col={} name=use_filter_intra val={use_fi} rng={}", | |
| 1160 | - lmi.0, | |
| 1161 | - lmi.1, | |
| 1162 | - dec.debug_state().0 | |
| 1163 | - ); | |
| 1164 | - } | |
| 1165 | 1066 | if use_fi != 0 { |
| 1166 | - hit!(FILTER_INTRA_HITS); | |
| 1167 | - hit!(FILTER_INTRA_RECT_HITS); | |
| 1168 | - hit!(FILTER_INTRA_RECT_SUB8_HITS); | |
| 1169 | 1067 | let fi = dec.symbol(&mut cdfs.filter_intra_mode); |
| 1170 | - if step { | |
| 1171 | - eprintln!( | |
| 1172 | - "EC_ISTEP mi_row={} mi_col={} name=filter_intra_mode val={fi} rng={}", | |
| 1173 | - lmi.0, | |
| 1174 | - lmi.1, | |
| 1175 | - dec.debug_state().0 | |
| 1176 | - ); | |
| 1177 | - } | |
| 1178 | 1068 | filter_intra = Some(fi); |
| 1179 | 1069 | } |
| 1180 | 1070 | } |
| @@ -1190,24 +1080,12 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1190 | 1080 | // no depth symbol either (sweep of the class fixed at the key-frame pair |
| 1191 | 1081 | // path). |
| 1192 | 1082 | let depth = if tx_select && bw != bh && !lossless(fctx) { |
| 1193 | - let ctx = tx_size_context_txfm_rect(neighbours, lmi, bw, bh, fctx); | |
| 1083 | + let ctx = tx_size_context_txfm_rect(neighbours, lmi, bw, bh); | |
| 1194 | 1084 | let d = dec.symbol(&mut cdfs.tx_size_cat0[ctx]); |
| 1195 | - if step { | |
| 1196 | - eprintln!( | |
| 1197 | - "EC_ISTEP mi_row={} mi_col={} name=tx_depth val={d} ctx={ctx} cat=0 rng={}", | |
| 1198 | - lmi.0, | |
| 1199 | - lmi.1, | |
| 1200 | - dec.debug_state().0 | |
| 1201 | - ); | |
| 1202 | - } | |
| 1203 | 1085 | d |
| 1204 | 1086 | } else { |
| 1205 | 1087 | 0 |
| 1206 | 1088 | }; |
| 1207 | - if depth != 0 { | |
| 1208 | - hit!(TX_DEPTH_HITS); | |
| 1209 | - hit!(RECT8_SPLIT_TX_HITS); | |
| 1210 | - } | |
| 1211 | 1089 | let split = depth != 0 || (lossless(fctx) && bw != bh); |
| 1212 | 1090 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 1213 | 1091 | let reach = if bw == bh { |
| @@ -1216,9 +1094,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1216 | 1094 | Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx) |
| 1217 | 1095 | }; |
| 1218 | 1096 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); |
| 1219 | - if smooth_neighbor { | |
| 1220 | - hit!(SMOOTH_LUMA_HITS); | |
| 1221 | - } | |
| 1222 | 1097 | neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); |
| 1223 | 1098 | let scan: &[u16] = if vert { &SCAN_4X8 } else { &SCAN_8X4 }; |
| 1224 | 1099 | if split { |
| @@ -1231,19 +1106,7 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1231 | 1106 | (lmi.0, lmi.1 + tu) |
| 1232 | 1107 | }; |
| 1233 | 1108 | let (tu_px, tu_py) = (tu_mi.1 * MI, tu_mi.0 * MI); |
| 1234 | - let tu_reach = tu_reach( | |
| 1235 | - bw, | |
| 1236 | - bh, | |
| 1237 | - tu_px - px, | |
| 1238 | - tu_py - py, | |
| 1239 | - 4, | |
| 1240 | - reach, | |
| 1241 | - px, | |
| 1242 | - py, | |
| 1243 | - y.width, | |
| 1244 | - y.height, | |
| 1245 | - fctx, | |
| 1246 | - ); | |
| 1109 | + let tu_reach = tu_reach(bw, bh, tu_px - px, tu_py - py, 4, reach); | |
| 1247 | 1110 | if skip { |
| 1248 | 1111 | let zeros = vec![0i32; 16]; |
| 1249 | 1112 | push_intra( |
| @@ -1290,7 +1153,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1290 | 1153 | tu_py, |
| 1291 | 1154 | 4, |
| 1292 | 1155 | TX4, |
| 1293 | - base_q_idx, | |
| 1294 | 1156 | None, |
| 1295 | 1157 | filter_intra, |
| 1296 | 1158 | Some(tu_skip_ctx), |
| @@ -1346,7 +1208,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1346 | 1208 | py, |
| 1347 | 1209 | 4, |
| 1348 | 1210 | TX4, |
| 1349 | - base_q_idx, | |
| 1350 | 1211 | None, |
| 1351 | 1212 | filter_intra, |
| 1352 | 1213 | None, |
| @@ -1396,7 +1257,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1396 | 1257 | 0, |
| 1397 | 1258 | dc_sign_ctx(around.2), |
| 1398 | 1259 | TxType::DctDct, |
| 1399 | - 0, | |
| 1400 | 1260 | )?; |
| 1401 | 1261 | let residual = dequant_and_inverse_typed_wh( |
| 1402 | 1262 | &levels, |
| @@ -1484,14 +1344,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1484 | 1344 | is_global_mv1: false, |
| 1485 | 1345 | }, |
| 1486 | 1346 | ); |
| 1487 | - hit_do! { | |
| 1488 | - SUB8_INTRA_RECT_HITS.with(|h| { | |
| 1489 | - let mut s = h.get(); | |
| 1490 | - s[usize::from(vert)] += 1; | |
| 1491 | - s[2] += usize::from(has_chroma); | |
| 1492 | - h.set(s); | |
| 1493 | - }); | |
| 1494 | - } | |
| 1495 | 1347 | // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map |
| 1496 | 1348 | // needs EVERY writer): a sub-8x8 group published no palette state, so |
| 1497 | 1349 | // once an 8x8 leaf of the same row can BE a palette block, the group |
| @@ -1544,7 +1396,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1544 | 1396 | u, |
| 1545 | 1397 | v, |
| 1546 | 1398 | scan4, |
| 1547 | - base_q_idx, | |
| 1548 | 1399 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 1549 | 1400 | (bw, bh), |
| 1550 | 1401 | fctx, |
| @@ -1611,10 +1462,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1611 | 1462 | }); |
| 1612 | 1463 | let mut chroma_stamped_per_unit = false; |
| 1613 | 1464 | let (u_grid, v_grid): (Grid, Grid) = if skip { |
| 1614 | - if alpha.is_some() { | |
| 1615 | - hit!(CHROMA_SKIP_CFL_HITS); | |
| 1616 | - hit!(SKIP_CFL_HITS); | |
| 1617 | - } | |
| 1618 | 1465 | if chroma_444 && bw != bh { |
| 1619 | 1466 | let zeros = Grid::Zero(bw * bh); |
| 1620 | 1467 | push_intra_rect( |
| @@ -1718,8 +1565,7 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1718 | 1565 | // At 4:4:4 a TX_4X4 chroma unit IS one mi cell. |
| 1719 | 1566 | let tu_mi = (lmi.0 + oy / MI, lmi.1 + ox / MI); |
| 1720 | 1567 | let tu_around = neighbours.around_mi(tu_mi, MI); |
| 1721 | - let tu_r = | |
| 1722 | - tu_reach(bw, bh, ox, oy, 4, reach_c, px, py, y.width, y.height, fctx); | |
| 1568 | + let tu_r = tu_reach(bw, bh, ox, oy, 4, reach_c); | |
| 1723 | 1569 | // The plane block (8x4/4x8) is bigger than the TX_4X4 |
| 1724 | 1570 | // transform, so `get_txb_ctx`'s chroma ctx_offset is 10, |
| 1725 | 1571 | // not 7 -- our chroma tables carry the offset-10 rows at |
| @@ -1743,7 +1589,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1743 | 1589 | py + oy, |
| 1744 | 1590 | 4, |
| 1745 | 1591 | TX4, |
| 1746 | - base_q_idx, | |
| 1747 | 1592 | None, |
| 1748 | 1593 | None, |
| 1749 | 1594 | Some(3), |
| @@ -1754,7 +1599,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1754 | 1599 | // (`av1_set_contexts`); the tail's whole-leaf chroma |
| 1755 | 1600 | // stamp below is skipped for this shape. |
| 1756 | 1601 | neighbours.record_mi_chroma(tu_mi, 4, 4, plane_idx, &tu_grid); |
| 1757 | - hit!(CHROMA_SPLIT_TX_HITS); | |
| 1758 | 1602 | let dst = mu_units(if plane_idx == 1 { &mut uo } else { &mut vo }, bw * bh); |
| 1759 | 1603 | for row in 0..4 { |
| 1760 | 1604 | let start = (oy + row) * bw + ox; |
| @@ -1763,7 +1607,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1763 | 1607 | } |
| 1764 | 1608 | } |
| 1765 | 1609 | chroma_stamped_per_unit = true; |
| 1766 | - hit!(LLSUB8RECT444_CHROMA_WALK_HITS); | |
| 1767 | 1610 | ( |
| 1768 | 1611 | if uo.is_empty() { |
| 1769 | 1612 | Grid::Zero(bw * bh) |
| @@ -1801,7 +1644,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1801 | 1644 | skip_ctx, |
| 1802 | 1645 | dc_sign_ctx(around.2), |
| 1803 | 1646 | uv_tx, |
| 1804 | - plane, | |
| 1805 | 1647 | )?; |
| 1806 | 1648 | let residual = dequant_and_inverse_typed_wh( |
| 1807 | 1649 | &levels, |
| @@ -1861,7 +1703,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1861 | 1703 | unit_y, |
| 1862 | 1704 | 4, |
| 1863 | 1705 | TX4, |
| 1864 | - base_q_idx, | |
| 1865 | 1706 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1866 | 1707 | None, |
| 1867 | 1708 | None, |
| @@ -1886,7 +1727,6 @@ pub(super) fn decode_intra_sub8_leaf( | ||
| 1886 | 1727 | unit_y, |
| 1887 | 1728 | 4, |
| 1888 | 1729 | TX4, |
| 1889 | - base_q_idx, | |
| 1890 | 1730 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1891 | 1731 | None, |
| 1892 | 1732 | None, |
| @@ -2004,13 +1844,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2004 | 1844 | (8usize, 4usize) |
| 2005 | 1845 | }; |
| 2006 | 1846 | let (w_mi, h_mi) = (bw / MI, bh / MI); |
| 2007 | - hit_do! { | |
| 2008 | - SUB8_INTER_RECT_HITS.with(|c| { | |
| 2009 | - let mut h = c.get(); | |
| 2010 | - h[usize::from(vert)] += 1; | |
| 2011 | - c.set(h); | |
| 2012 | - }); | |
| 2013 | - } | |
| 2014 | 1847 | let (gr, gc) = group_mi; |
| 2015 | 1848 | let (gpx, gpy) = (gc * MI, gr * MI); |
| 2016 | 1849 | let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx)); |
| @@ -2018,7 +1851,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2018 | 1851 | let mut piece: [Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>; 2] = |
| 2019 | 1852 | [None; 2]; |
| 2020 | 1853 | let mut first_tx_type = TxType::DctDct; |
| 2021 | - let mut sub0_tx_type = TxType::DctDct; | |
| 2022 | 1854 | // lane-av1-444: `is_chroma_reference` is unconditional at subsampling 0/0 |
| 2023 | 1855 | // (av1_common_int.h:1459), so every 8x4/4x8 piece is its own chroma |
| 2024 | 1856 | // reference and codes its own 8x4/4x8 U/V units right after its luma -- |
| @@ -2099,15 +1931,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2099 | 1931 | ); |
| 2100 | 1932 | let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; |
| 2101 | 1933 | if !is_inter { |
| 2102 | - if crate::envflags::env_flag!("EC_SUB8INTRA") { | |
| 2103 | - eprintln!( | |
| 2104 | - "EC_SUB8INTRA shape={}x{} sub={i} has_chroma={} skip={skip} mi={rmi},{cmi} tx_select={}", | |
| 2105 | - bw, | |
| 2106 | - bh, | |
| 2107 | - piece_is_chroma_ref(i), | |
| 2108 | - fctx.tx_select_inter.with(std::cell::Cell::get), | |
| 2109 | - ); | |
| 2110 | - } | |
| 2111 | 1934 | // lane-sub8x4 r2: refusal and bypass lifted -- see the split arm's |
| 2112 | 1935 | // note above for the gate that proves this leaf. |
| 2113 | 1936 | // Its chroma rule is `is_sub8x8_inter`'s: when the |
| @@ -2128,7 +1951,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2128 | 1951 | y, |
| 2129 | 1952 | u, |
| 2130 | 1953 | v, |
| 2131 | - base_q_idx, | |
| 2132 | 1954 | fctx.enable_filter_intra_inter.with(std::cell::Cell::get), |
| 2133 | 1955 | fctx.tx_select_inter.with(std::cell::Cell::get), |
| 2134 | 1956 | reduced_tx_set, |
| @@ -2139,12 +1961,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2139 | 1961 | } |
| 2140 | 1962 | continue; |
| 2141 | 1963 | } |
| 2142 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 2143 | - eprintln!( | |
| 2144 | - "EC_MODE mi_row={rmi} mi_col={cmi} rng={}", | |
| 2145 | - dec.debug_state().0 | |
| 2146 | - ); | |
| 2147 | - } | |
| 2148 | 1964 | let ref_frame = read_single_ref( |
| 2149 | 1965 | dec, |
| 2150 | 1966 | cdfs, |
| @@ -2158,9 +1974,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2158 | 1974 | let (ref_width, ref_height) = ref_dims(ref_frame, refpix)?; |
| 2159 | 1975 | // lane-t900 r28: refusal lifted -- see the split arm above. |
| 2160 | 1976 | let luma_scale = scale_of((ref_width, ref_height), frame_size); |
| 2161 | - if !luma_scale.is_unscaled() { | |
| 2162 | - hit!(SCALED_SUB8_HITS); | |
| 2163 | - } | |
| 2164 | 1977 | let gm_table = build_gm_mv_table( |
| 2165 | 1978 | global_motion, |
| 2166 | 1979 | rmi, |
| @@ -2194,10 +2007,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2194 | 2007 | tpl, |
| 2195 | 2008 | ); |
| 2196 | 2009 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| 2197 | - if !not_new { | |
| 2198 | - crate::census::mode(0); | |
| 2199 | - } | |
| 2200 | - let mut is_globalmv = false; | |
| 2201 | 2010 | let (mv, is_new_mv) = if !not_new { |
| 2202 | 2011 | let mut idx = 0usize; |
| 2203 | 2012 | while idx < 2 && stack.entries.len() > idx + 1 { |
| @@ -2221,15 +2030,10 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2221 | 2030 | ) |
| 2222 | 2031 | } else { |
| 2223 | 2032 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; |
| 2224 | - if !not_zero { | |
| 2225 | - crate::census::mode(1); | |
| 2226 | - } | |
| 2227 | - is_globalmv = !not_zero; | |
| 2228 | 2033 | let mv = if !not_zero { |
| 2229 | 2034 | gm_table[(ref_frame - LAST_FRAME) as usize] |
| 2230 | 2035 | } else { |
| 2231 | 2036 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; |
| 2232 | - crate::census::mode(if nearest { 2 } else { 3 }); | |
| 2233 | 2037 | if nearest { |
| 2234 | 2038 | stack.nearest_mv |
| 2235 | 2039 | } else { |
| @@ -2245,15 +2049,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2245 | 2049 | }; |
| 2246 | 2050 | (mv, false) |
| 2247 | 2051 | }; |
| 2248 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 2249 | - eprintln!( | |
| 2250 | - "EC_MODE_MV mi_row={rmi} mi_col={cmi} mv0=({},{}) rng={}", | |
| 2251 | - mv.0, | |
| 2252 | - mv.1, | |
| 2253 | - dec.debug_state().0 | |
| 2254 | - ); | |
| 2255 | - } | |
| 2256 | - let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize]; | |
| 2257 | 2052 | let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame |
| 2258 | 2053 | || neighbours.above_ref1[cmi] == Some(ref_frame) |
| 2259 | 2054 | { |
| @@ -2272,9 +2067,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2272 | 2067 | // `is_nontrans_global_motion` returns 0 for |
| 2273 | 2068 | // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model -- |
| 2274 | 2069 | // so a GLOBALMV sub-block here always reads its interp filter. |
| 2275 | - if is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation { | |
| 2276 | - hit!(GM_NONTRANS_SMALL_SIDE_HITS); | |
| 2277 | - } | |
| 2278 | 2070 | let gm_nontrans = false; |
| 2279 | 2071 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( |
| 2280 | 2072 | dec, |
| @@ -2321,9 +2113,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2321 | 2113 | // exactly that population -- so an unconditional hit proves only |
| 2322 | 2114 | // "a lossless sub-8 leaf was walked", not "the conjunct suppressed |
| 2323 | 2115 | // a tree". Guard it on the same term the conjunct uses. |
| 2324 | - if fctx.tx_select_inter.with(std::cell::Cell::get) { | |
| 2325 | - hit!(SUB8_LOSSLESS_NO_VARTX); | |
| 2326 | - } | |
| 2327 | 2116 | // lane-lossless2: `read_block_tx_size` returns TX_4X4 before it |
| 2328 | 2117 | // ever looks at `max_txsize_rect_lookup`, so an 8x4/4x8 leaf is |
| 2329 | 2118 | // TWO 4x4 units, not one rect one. |
| @@ -2337,17 +2126,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2337 | 2126 | leaves.push((0, 0, bw, bh)); |
| 2338 | 2127 | set_txfm_ctxs(neighbours, lmi, bw.max(bh), w_mi, h_mi, skip); |
| 2339 | 2128 | } |
| 2340 | - if crate::envflags::env_flag!("EC_TRACE_MODE") { | |
| 2341 | - eprintln!( | |
| 2342 | - "EC_MODE_VALR mi_row={rmi} mi_col={cmi} newmv={is_new_mv} globalmv={is_globalmv} \ | |
| 2343 | - ref0={ref_frame} mv0=({},{}) stack={} leaves={} rng={}", | |
| 2344 | - mv.0, | |
| 2345 | - mv.1, | |
| 2346 | - stack.entries.len(), | |
| 2347 | - leaves.len(), | |
| 2348 | - dec.debug_state().0 | |
| 2349 | - ); | |
| 2350 | - } | |
| 2351 | 2129 | grid_stamp_rect(grid, rmi, cmi, w_mi, h_mi, ref_frame, mv, is_new_mv); |
| 2352 | 2130 | piece[i] = Some((ref_frame, mv, h_filter, v_filter)); |
| 2353 | 2131 | // Prediction over the leaf's true footprint, laid out at the group's |
| @@ -2389,7 +2167,11 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2389 | 2167 | let pred_y: Vec<u16>; |
| 2390 | 2168 | let sy = if pred_deferred(refpix) { |
| 2391 | 2169 | push_pred(build); |
| 2392 | - Pred::Cur { plane: 0, stride: SIDE, off: 0 } | |
| 2170 | + Pred::Cur { | |
| 2171 | + plane: 0, | |
| 2172 | + stride: SIDE, | |
| 2173 | + off: 0, | |
| 2174 | + } | |
| 2393 | 2175 | } else { |
| 2394 | 2176 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 2395 | 2177 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -2492,9 +2274,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2492 | 2274 | if idx == 0 { |
| 2493 | 2275 | piece_tx_type = tu_tx_type; |
| 2494 | 2276 | } |
| 2495 | - if idx == 0 && i == 0 { | |
| 2496 | - sub0_tx_type = tu_tx_type; | |
| 2497 | - } | |
| 2498 | 2277 | if idx == 0 && i == 1 { |
| 2499 | 2278 | // `av1_get_tx_type` indexes `xd->tx_type_map`, which |
| 2500 | 2279 | // `set_mi_offsets` (av1_common_int.h:1679) re-points to the |
| @@ -2563,7 +2342,18 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2563 | 2342 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); |
| 2564 | 2343 | let (su, sv) = if pred_deferred(refpix) { |
| 2565 | 2344 | push_pred(build_c); |
| 2566 | - (Pred::Cur { plane: 1, stride: SIDE, off: 0 }, Pred::Cur { plane: 2, stride: SIDE, off: 0 }) | |
| 2345 | + ( | |
| 2346 | + Pred::Cur { | |
| 2347 | + plane: 1, | |
| 2348 | + stride: SIDE, | |
| 2349 | + off: 0, | |
| 2350 | + }, | |
| 2351 | + Pred::Cur { | |
| 2352 | + plane: 2, | |
| 2353 | + stride: SIDE, | |
| 2354 | + off: 0, | |
| 2355 | + }, | |
| 2356 | + ) | |
| 2567 | 2357 | } else { |
| 2568 | 2358 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 2569 | 2359 | build_c(y, u, v, refpix, fctx, &mut built); |
| @@ -2813,7 +2603,18 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2813 | 2603 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); |
| 2814 | 2604 | let (su, sv) = if pred_deferred(refpix) { |
| 2815 | 2605 | push_pred(build_c); |
| 2816 | - (Pred::Cur { plane: 1, stride: B4, off: 0 }, Pred::Cur { plane: 2, stride: B4, off: 0 }) | |
| 2606 | + ( | |
| 2607 | + Pred::Cur { | |
| 2608 | + plane: 1, | |
| 2609 | + stride: B4, | |
| 2610 | + off: 0, | |
| 2611 | + }, | |
| 2612 | + Pred::Cur { | |
| 2613 | + plane: 2, | |
| 2614 | + stride: B4, | |
| 2615 | + off: 0, | |
| 2616 | + }, | |
| 2617 | + ) | |
| 2817 | 2618 | } else { |
| 2818 | 2619 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 2819 | 2620 | build_c(y, u, v, refpix, fctx, &mut built); |
| @@ -2851,7 +2652,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2851 | 2652 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]); |
| 2852 | 2653 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]); |
| 2853 | 2654 | } else { |
| 2854 | - hit!(CHROMA422_INTER_SUB8_HITS); | |
| 2855 | 2655 | let (ug, _) = read_inter_plane( |
| 2856 | 2656 | dec, |
| 2857 | 2657 | cdfs, |
| @@ -2956,15 +2756,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 2956 | 2756 | // chroma-reference block's own mv, at the group's chroma origin |
| 2957 | 2757 | // (`row_start`/`col_start` shift `pre_x`/`pre_y` there either way). |
| 2958 | 2758 | let mixed = piece[0].is_none(); |
| 2959 | - if mixed { | |
| 2960 | - hit_do! { | |
| 2961 | - SUB8_INTRA_RECT_HITS.with(|h| { | |
| 2962 | - let mut s = h.get(); | |
| 2963 | - s[3] += 1; | |
| 2964 | - h.set(s); | |
| 2965 | - }); | |
| 2966 | - } | |
| 2967 | - } | |
| 2968 | 2759 | let (piece_w, piece_h) = match (mixed, vert) { |
| 2969 | 2760 | (true, _) => (B4, B4), |
| 2970 | 2761 | (false, true) => (2usize, 4usize), |
| @@ -3038,7 +2829,18 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 3038 | 2829 | let (pred_u, pred_v): (Vec<u16>, Vec<u16>); |
| 3039 | 2830 | let (su, sv) = if pred_deferred(refpix) { |
| 3040 | 2831 | push_pred(build); |
| 3041 | - (Pred::Cur { plane: 1, stride: B4, off: 0 }, Pred::Cur { plane: 2, stride: B4, off: 0 }) | |
| 2832 | + ( | |
| 2833 | + Pred::Cur { | |
| 2834 | + plane: 1, | |
| 2835 | + stride: B4, | |
| 2836 | + off: 0, | |
| 2837 | + }, | |
| 2838 | + Pred::Cur { | |
| 2839 | + plane: 2, | |
| 2840 | + stride: B4, | |
| 2841 | + off: 0, | |
| 2842 | + }, | |
| 2843 | + ) | |
| 3042 | 2844 | } else { |
| 3043 | 2845 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 3044 | 2846 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -3116,8 +2918,6 @@ pub(super) fn decode_inter_sub8_rect2( | ||
| 3116 | 2918 | fctx, |
| 3117 | 2919 | )? |
| 3118 | 2920 | .0; |
| 3119 | - let coded = ug.iter().chain(vg.iter()).any(|&c| c != 0); | |
| 3120 | - note_sub8_chroma_tx(sub0_tx_type, first_tx_type, coded); | |
| 3121 | 2921 | (ug, vg) |
| 3122 | 2922 | }; |
| 3123 | 2923 | let round_up_even = |n: usize| n.div_ceil(2) * 2; |
crates/ec-av1/src/decode/tests.rsmodified+36 -1309
| @@ -1,329 +1,3 @@ | ||
| 1 | -/// lane-av1unwritten r7: the STRUCTURAL invariant that r5 and r6 both broke. | |
| 2 | -/// | |
| 3 | -/// r5 put guards inside `PARTITION_HORZ_A..=PARTITION_VERT_B` arms, so they | |
| 4 | -/// could only ever see values 4..=7. r6 deleted the inter-16 guard and did not | |
| 5 | -/// replace it. r7's fix was mechanical at both sites and the failure mode was | |
| 6 | -/// always the same: a guard exists somewhere, and nothing says it sits between | |
| 7 | -/// a symbol's RESOLUTION and every dispatch of it. | |
| 8 | -/// | |
| 9 | -/// So the invariant is stated over the dispatch structure, not over a list. | |
| 10 | -/// Counts in the tree this was written against, re-derived per line rather | |
| 11 | -/// than grepped: `refuse_invalid_subsize((` occurs **18 times** in this file — | |
| 12 | -/// **11 guard call sites** in the decode body (35588, 36278, 36406, 36472, | |
| 13 | -/// 36882, 37132, 53985, 54222, 54606, 54752, 55164), **5** in this test's own | |
| 14 | -/// string literals and comparisons, **2** in doc comments; the definition's | |
| 15 | -/// signature line does not match `((` at all. The scan finds **10 resolutions**: | |
| 16 | -/// the eleventh guard is the inter-frame 128 one, whose resolution lives in | |
| 17 | -/// the shared `read_sb128_root`, so a guard has no resolution of its own here. | |
| 18 | -/// What is asserted, exactly: | |
| 19 | -/// | |
| 20 | -/// * every `partition_w<N>[` level in the file appears among the resolutions | |
| 21 | -/// this scan finds -- a new level cannot be added without a guard check; | |
| 22 | -/// * each resolution is followed, within 220 lines, by a | |
| 23 | -/// `refuse_invalid_subsize((N, N), …)` for its OWN level (matched on the | |
| 24 | -/// level, not the variable, because the symbol is often bound to a | |
| 25 | -/// short-lived inner name `p` and dispatched by an outer `part64`); | |
| 26 | -/// * where that window contains a `match part…` dispatch, the guard precedes | |
| 27 | -/// it -- the bound r7's COMMENT claimed and r8 implements; | |
| 28 | -/// * no guard sits inside a `PARTITION_HORZ_A..=PARTITION_VERT_B` arm. | |
| 29 | -/// | |
| 30 | -/// It does NOT prove a guard is at the exact dispatch point: the window is a | |
| 31 | -/// window. And the two cross-checks are weaker than they look — cross-check 1 | |
| 32 | -/// is level PRESENCE only, cross-check 2 is `>=` — so a SECOND unguarded site | |
| 33 | -/// at an already-covered level is caught ONLY by the per-site 220-line window, | |
| 34 | -/// which is a window and not a dispatch bound. That limit is why the AB-arm | |
| 35 | -/// invariant exists separately, and why `EC_AV1_SUBSIZE_GUARD_TRACE` records | |
| 36 | -/// what each site really sees over the corpus. | |
| 37 | -#[test] | |
| 38 | -fn every_partition_symbol_resolution_is_guarded_before_it_dispatches() { | |
| 39 | - let src = crate::test_source::module_source("decode"); | |
| 40 | - // Every partition-symbol RESOLUTION in the file, with the level read off | |
| 41 | - // the CDF name on the line itself. Two independent counts are compared, so | |
| 42 | - // a site lost to line wrapping reds instead of silently vanishing: the | |
| 43 | - // Every partition-symbol RESOLUTION in the file. The window is the line | |
| 44 | - // BEFORE as well as the line itself and the one after (r9), because a | |
| 45 | - // `let <var> =` on one line with `dec.symbol(&mut cdfs.partition_w8[..])` | |
| 46 | - // on the next is a real shape in this file -- and r9's own ungated site at | |
| 47 | - // 37115 was invisible for exactly that reason. | |
| 48 | - let lines: Vec<&str> = src.lines().collect(); | |
| 49 | - let mut sites: Vec<(usize, String, usize)> = Vec::new(); | |
| 50 | - // Occurrences of `partition_w<N>[` per level, counted from the FILE, used as | |
| 51 | - // the cross-check below. | |
| 52 | - let mut file_occurrences: std::collections::BTreeMap<usize, usize> = Default::default(); | |
| 53 | - // Only the DECODE body: the test module below also builds `partition_w8` | |
| 54 | - // CDFs (an encoder round-trip at 58464/58521), and counting those would | |
| 55 | - // demand a guard for a site that does not exist. | |
| 56 | - let production = crate::test_source::module_production_source("decode"); | |
| 57 | - let decode_body = match production.find("\n#[cfg(test)]\nmod tests {") { | |
| 58 | - Some(i) => &production[..i], | |
| 59 | - None => production, | |
| 60 | - }; | |
| 61 | - { | |
| 62 | - let mut rest = decode_body; | |
| 63 | - while let Some(i) = rest.find("partition_w") { | |
| 64 | - let after = &rest[i + "partition_w".len()..]; | |
| 65 | - let digits: String = after.chars().take_while(char::is_ascii_digit).collect(); | |
| 66 | - rest = after; | |
| 67 | - if digits.is_empty() { | |
| 68 | - continue; // `partition_wide`, or any other word starting the same way | |
| 69 | - } | |
| 70 | - if after[digits.len()..].starts_with('[') { | |
| 71 | - *file_occurrences | |
| 72 | - .entry(digits.parse().expect("digits")) | |
| 73 | - .or_insert(0) += 1; | |
| 74 | - } | |
| 75 | - } | |
| 76 | - } | |
| 77 | - // r11 (lane-av1subsizesweep): a partition-symbol READ is a `dec.<name>(..)` | |
| 78 | - // call whose OWN ARGUMENT LIST names a `partition_w<N>[` CDF. That is the | |
| 79 | - // whole definition, and it is why the read spellings need no hand-list: | |
| 80 | - // `dec.symbol(..partition_w..)` qualifies, the frame-edge gather's | |
| 81 | - // `dec.symbol_fixed(&gather(..partition_w..))` qualifies, and | |
| 82 | - // `dec.debug_state()` does not -- it never names a partition CDF. A third | |
| 83 | - // spelling is covered the day somebody writes it. | |
| 84 | - // | |
| 85 | - // r11's hole was a SPELLING gap, not a shape gap: the old matcher named | |
| 86 | - // `dec.symbol(` literally, and `dec.symbol(` is not a substring of | |
| 87 | - // `dec.symbol_fixed(`. So the key-frame 16-level frame-edge arm -- which | |
| 88 | - // dispatches `decode_leaf_rect` straight off a gathered `edge_split` onto | |
| 89 | - // a BLOCK_8X16 chroma walk -- was never a site at all. | |
| 90 | - let is_partition_read = |window: &str| -> bool { | |
| 91 | - let mut at = 0usize; | |
| 92 | - while let Some(rel) = window[at..].find("dec.") { | |
| 93 | - let call = at + rel + "dec.".len(); | |
| 94 | - at = call; | |
| 95 | - let name: String = window[call..] | |
| 96 | - .chars() | |
| 97 | - .take_while(|c| c.is_ascii_alphanumeric() || *c == '_') | |
| 98 | - .collect(); | |
| 99 | - if name.is_empty() { | |
| 100 | - continue; | |
| 101 | - } | |
| 102 | - let Some(open) = window[call + name.len()..].find('(') else { | |
| 103 | - continue; | |
| 104 | - }; | |
| 105 | - let arg_from = call + name.len() + open + 1; | |
| 106 | - let mut depth = 1usize; | |
| 107 | - let mut stop = None; | |
| 108 | - for (i, c) in window[arg_from..].char_indices() { | |
| 109 | - match c { | |
| 110 | - '(' => depth += 1, | |
| 111 | - ')' => { | |
| 112 | - depth -= 1; | |
| 113 | - if depth == 0 { | |
| 114 | - stop = Some(arg_from + i); | |
| 115 | - break; | |
| 116 | - } | |
| 117 | - } | |
| 118 | - _ => {} | |
| 119 | - } | |
| 120 | - } | |
| 121 | - let Some(stop) = stop else { continue }; | |
| 122 | - if window[arg_from..stop].contains("partition_w") { | |
| 123 | - return true; | |
| 124 | - } | |
| 125 | - } | |
| 126 | - false | |
| 127 | - }; | |
| 128 | - for (n, line) in lines.iter().enumerate() { | |
| 129 | - let t = line.trim_start(); | |
| 130 | - // A doc comment quoting the shape is not a site, and neither is the | |
| 131 | - // test's own example strings further down the file. | |
| 132 | - if t.starts_with("//") || !line.contains("partition_w") || n > 56000 { | |
| 133 | - continue; | |
| 134 | - } | |
| 135 | - let lo = n.saturating_sub(1); | |
| 136 | - let hi = (n + 2).min(lines.len()); | |
| 137 | - let window = lines[lo..hi].join(" "); | |
| 138 | - // r11: the read test is the DERIVED predicate above, not a spelling | |
| 139 | - // literal. Naming `dec.symbol(` here is what hid the frame-edge arm. | |
| 140 | - if !is_partition_read(&window) { | |
| 141 | - continue; | |
| 142 | - } | |
| 143 | - let Some(i) = window.find("partition_w") else { | |
| 144 | - continue; | |
| 145 | - }; | |
| 146 | - let after = &window[i + "partition_w".len()..]; | |
| 147 | - let digits: String = after.chars().take_while(char::is_ascii_digit).collect(); | |
| 148 | - if digits.is_empty() { | |
| 149 | - continue; | |
| 150 | - } | |
| 151 | - let level: usize = digits.parse().expect("digits"); | |
| 152 | - // The bound variable is the token after `let `, looked for in the two | |
| 153 | - // lines the binding can occupy (r9: it may be the line above). | |
| 154 | - // r10: scan BACKWARDS from the closest line and take the nearest `let` | |
| 155 | - // whose binding is the one followed by this symbol read -- taking the | |
| 156 | - // first `let` upward named an unrelated binding above it. | |
| 157 | - let mut var = None; | |
| 158 | - for cand in (lo..=n).rev() { | |
| 159 | - let ct = lines[cand].trim_start(); | |
| 160 | - if ct.starts_with("//") { | |
| 161 | - continue; | |
| 162 | - } | |
| 163 | - let Some(v) = ct.strip_prefix("let ") else { | |
| 164 | - continue; | |
| 165 | - }; | |
| 166 | - let name = v | |
| 167 | - .split(|c: char| !(c.is_alphanumeric() || c == '_')) | |
| 168 | - .next() | |
| 169 | - .unwrap_or("") | |
| 170 | - .to_string(); | |
| 171 | - if name.is_empty() { | |
| 172 | - continue; | |
| 173 | - } | |
| 174 | - // This binding is followed by the symbol read if the SAME line | |
| 175 | - // completes `let <name> = dec.<spelling>(`, or if the next line | |
| 176 | - // starts the call. That is what separates `let part8 =` from an | |
| 177 | - // unrelated `let ec_dbg_pre =` two lines above it. | |
| 178 | - let next = lines.get(cand + 1).copied().unwrap_or(""); | |
| 179 | - let binds_here = ct.contains("= dec.") || next.contains("dec."); | |
| 180 | - if binds_here || cand == n { | |
| 181 | - var = Some(name); | |
| 182 | - break; | |
| 183 | - } | |
| 184 | - } | |
| 185 | - let Some(var) = var else { continue }; | |
| 186 | - // r11: the edge `gather` reads are SITES now, not skips. r10 skipped | |
| 187 | - // them on the reasoning that "the site is guarded at the level's own | |
| 188 | - // resolution instead" -- true for every arm that resolves into a | |
| 189 | - // `partN`, and FALSE for the one that does not: the key-frame 16-level | |
| 190 | - // frame-edge arm dispatches `decode_leaf_rect` straight off `edge_split`, | |
| 191 | - // and `BLOCK_8X16` is BLOCK_INVALID at 4:2:2. Every site therefore has | |
| 192 | - // to carry a guard for its OWN level between the read and the first | |
| 193 | - // chroma-walking dispatch after it -- see the per-site check below. | |
| 194 | - sites.push((n, var, level)); | |
| 195 | - } | |
| 196 | - | |
| 197 | - // ---- cross-check 1: every `partition_w<N>` LEVEL in the decode body has | |
| 198 | - // at least one guarded resolution. r9: this is level PRESENCE, and it is | |
| 199 | - // stated as such -- it cannot catch a SECOND unguarded site at an already | |
| 200 | - // covered level. What does catch that is cross-check 2 below (the exact | |
| 201 | - // guard/resolution count) together with the per-site assertion. | |
| 202 | - let mut covered: std::collections::BTreeSet<usize> = Default::default(); | |
| 203 | - for (_, _, level) in &sites { | |
| 204 | - covered.insert(*level); | |
| 205 | - } | |
| 206 | - for level in file_occurrences.keys() { | |
| 207 | - assert!( | |
| 208 | - covered.contains(level), | |
| 209 | - "level {level} names a `partition_w{level}[` CDF in the decode body but this \ | |
| 210 | - scan finds no guarded resolution for it (r9)" | |
| 211 | - ); | |
| 212 | - } | |
| 213 | - | |
| 214 | - // ---- cross-check 2: an EXACT count derived from the scan, never a floor. | |
| 215 | - // Counted by CALL SHAPE -- a line whose first token is the call -- so a | |
| 216 | - // multi-line assert string mentioning the function is not counted, and the | |
| 217 | - // definition is not either. | |
| 218 | - let guarded_sites = decode_body | |
| 219 | - .lines() | |
| 220 | - .filter(|l| l.trim_start().starts_with("refuse_invalid_subsize((")) | |
| 221 | - .count(); | |
| 222 | - // r9: was `assert_eq!`, which the tree's own counts disagree on (the scan | |
| 223 | - // sees 10 resolutions against 11 guards), and a hard-equal on two numbers the | |
| 224 | - // scan itself computes is a claim about the SCANNER, not about coverage. It | |
| 225 | - // is `>=` plus the per-site assertion below: a resolution with no guard reds | |
| 226 | - // on its own line, which is the property that matters, and a guard with no | |
| 227 | - // resolution behind it is redundant rather than harmful. | |
| 228 | - assert!( | |
| 229 | - guarded_sites >= sites.len(), | |
| 230 | - "the decode body has {sites_len} partition resolutions but only {guarded_sites} \ | |
| 231 | - guard sites -- fewer guards than resolutions (r9)", | |
| 232 | - sites_len = sites.len() | |
| 233 | - ); | |
| 234 | - | |
| 235 | - for (line_no, var, level) in &sites { | |
| 236 | - // Two properties, both stated exactly: | |
| 237 | - // | |
| 238 | - // (a) a guard for THIS LEVEL appears after the binding, within a | |
| 239 | - // 220-line window -- matched on the level, not the variable name, | |
| 240 | - // because the symbol is often bound to a short-lived inner name | |
| 241 | - // (`p`) and dispatched by an outer one (`part64`); | |
| 242 | - // (b) where the window contains a `match part…` dispatch, the guard | |
| 243 | - // precedes it. | |
| 244 | - let window: Vec<&str> = lines[line_no + 1..(line_no + 221).min(lines.len())].to_vec(); | |
| 245 | - let guard_at = window | |
| 246 | - .iter() | |
| 247 | - .position(|l| l.contains(&format!("refuse_invalid_subsize(({level}, {level})"))); | |
| 248 | - assert!( | |
| 249 | - guard_at.is_some(), | |
| 250 | - "{} (decode.rs:{}) resolves a {level}x{level} partition symbol with NO \ | |
| 251 | - refuse_invalid_subsize(({level}, {level})) within 220 lines after it -- a \ | |
| 252 | - subsize libaom refuses can walk straight through", | |
| 253 | - var, | |
| 254 | - line_no + 1 | |
| 255 | - ); | |
| 256 | - let dispatch_at = window.iter().position(|l| { | |
| 257 | - let t = l.trim_start(); | |
| 258 | - !t.starts_with("//") && t.starts_with("match part") | |
| 259 | - }); | |
| 260 | - if let Some(d) = dispatch_at { | |
| 261 | - assert!( | |
| 262 | - guard_at.expect("checked above") < d, | |
| 263 | - "{} (decode.rs:{}) is DISPATCHED at window line {d} BEFORE its \ | |
| 264 | - refuse_invalid_subsize(({level}, {level})) -- the guard can never \ | |
| 265 | - observe that dispatch", | |
| 266 | - var, | |
| 267 | - line_no + 1 | |
| 268 | - ); | |
| 269 | - } | |
| 270 | - } | |
| 271 | - | |
| 272 | - // The r5 defect, as its own invariant: a guard must never sit INSIDE a | |
| 273 | - // `PARTITION_HORZ_A..=PARTITION_VERT_B` arm. Such an arm can only carry | |
| 274 | - // partition values 4..=7, and the offending values are PARTITION_VERT (2) | |
| 275 | - // and PARTITION_VERT_4 (9). Tracked by INDENTATION, because brace counting | |
| 276 | - // over a file full of comments and macro bodies drifts. | |
| 277 | - let indent_of = |l: &str| l.len() - l.trim_start().len(); | |
| 278 | - // (arm indent, arm BODY indent). r9: the tracker used to self-clear on the | |
| 279 | - // `{` line, because that line carries the SAME indent as the `if` -- so a | |
| 280 | - // guard placed INSIDE an arm body was invisible and r5's defect reproduced | |
| 281 | - // green in the checker. Now the arm's body indent is one level deeper than | |
| 282 | - // the opener's, and the tracker clears only below THAT, or on a closing | |
| 283 | - // brace at the opener's own indent. | |
| 284 | - let mut ab_arm: Option<(usize, bool)> = None; | |
| 285 | - for (n, line) in src.lines().enumerate() { | |
| 286 | - let t = line.trim_start(); | |
| 287 | - if t.starts_with("//") { | |
| 288 | - continue; | |
| 289 | - } | |
| 290 | - let ind = indent_of(line); | |
| 291 | - // r9: the arm's `{` sits on a LATER line than the condition, and the | |
| 292 | - // condition itself wraps, so clearing on the first line back at the | |
| 293 | - // opener's indent self-cleared BEFORE the body -- which is why moving | |
| 294 | - // the kf-16 guard back inside an arm stayed GREEN. Now: arm at the | |
| 295 | - // condition, ENTER the body one level deeper, clear only after having | |
| 296 | - // been inside it. | |
| 297 | - if line.contains("PARTITION_HORZ_A..=PARTITION_VERT_B") { | |
| 298 | - ab_arm = Some((ind + 4, false)); | |
| 299 | - } else if t == "{" { | |
| 300 | - // r10: the arm's own brace carries the OPENER's indent, not the | |
| 301 | - // body's, so treating it as "backed out" cleared the arm before a | |
| 302 | - // single body statement was seen -- which is why the mutation that | |
| 303 | - // moves a guard INSIDE an arm stayed GREEN at r8 AND r9. A lone `{` | |
| 304 | - // never changes the state. | |
| 305 | - } else if let Some((body, entered)) = ab_arm { | |
| 306 | - if !entered { | |
| 307 | - if ind >= body { | |
| 308 | - ab_arm = Some((body, true)); | |
| 309 | - } | |
| 310 | - } else if ind < body { | |
| 311 | - ab_arm = None; | |
| 312 | - } | |
| 313 | - } | |
| 314 | - if line.contains("refuse_invalid_subsize((") { | |
| 315 | - assert!( | |
| 316 | - ab_arm.is_none_or(|_| false), | |
| 317 | - "decode.rs:{} puts a refuse_invalid_subsize inside a \ | |
| 318 | - PARTITION_HORZ_A..=PARTITION_VERT_B arm (values 4..=7 only); the \ | |
| 319 | - offending values are PARTITION_VERT (2) and PARTITION_VERT_4 (9), which \ | |
| 320 | - that arm can never observe -- r5's defect", | |
| 321 | - n + 1 | |
| 322 | - ); | |
| 323 | - } | |
| 324 | - } | |
| 325 | -} | |
| 326 | - | |
| 327 | 1 | /// lane-av1unwritten: the port is a TRANSCRIPTION, and this is the artefact |
| 328 | 2 | /// that makes it checkable. It re-writes `av1_ss_size_lookup`'s 22 rows |
| 329 | 3 | /// (`common_data.c:17-41`) literally -- every shape, every subsampling |
| @@ -454,886 +128,6 @@ fn chroma_plane_block_codable_matches_the_libaom_table() { | ||
| 454 | 128 | ); |
| 455 | 129 | } |
| 456 | 130 | |
| 457 | -/// lane-av1subsizesweep: the CENSUS, as an invariant. | |
| 458 | -/// | |
| 459 | -/// The merged `lane/av1unwritten` lane covers partition SYMBOLS: every | |
| 460 | -/// `dec.symbol(&mut cdfs.partition_w<N>[..])` gets a | |
| 461 | -/// [`refuse_invalid_subsize`] within 220 lines, and | |
| 462 | -/// [`every_partition_symbol_resolution_is_guarded_before_it_dispatches`] | |
| 463 | -/// holds that shape against the source. Its own stated limit is exactly | |
| 464 | -/// the hole this lane found: the scan matches on `dec.symbol(`, so the | |
| 465 | -/// frame-edge GATHER reads (`dec.symbol_fixed(&gather(..))`) are invisible | |
| 466 | -/// to it, and its site list names RESOLUTIONS, not the chroma-plane WALKS | |
| 467 | -/// those resolutions descend into. | |
| 468 | -/// | |
| 469 | -/// So this test states the other half, over the WALK sites instead of the | |
| 470 | -/// symbol sites: | |
| 471 | -/// | |
| 472 | -/// * every `decode_*` call that walks a chroma plane is enumerated, with | |
| 473 | -/// the luma shape(s) it can be handed -- derived from the enclosing | |
| 474 | -/// dispatch, not typed in by hand; | |
| 475 | -/// * for each shape that libaom marks BLOCK_INVALID at some subsampling | |
| 476 | -/// mode, the walk must have a [`refuse_invalid_subsize`] for its OWN | |
| 477 | -/// level on its path -- either at the level that dispatched it | |
| 478 | -/// (`PARTITION_*` arms resolve into a `partN`) or at the dispatch site | |
| 479 | -/// itself; | |
| 480 | -/// * a walk reachable ONLY through a level whose guard already refuses the | |
| 481 | -/// offending subsize is CLOSED, and the reason is the level's own guard | |
| 482 | -/// line -- asserted, not commented. | |
| 483 | -/// | |
| 484 | -/// The residue the merged lane named, [`decode_rect4_16_intrabc`], is the | |
| 485 | -/// second case: it is reachable only from the 16x16-level 1:4 arms, and | |
| 486 | -/// `partition_subsize_dims((16,16), PARTITION_VERT_4) == (4,16)`, which is | |
| 487 | -/// in `PLANE_BLOCK_INVALID_422`. Both of its callers' guards refuse that | |
| 488 | -/// before the call, so it is CLOSED rather than guarded a third time -- | |
| 489 | -/// and this test is what makes that a checked claim instead of a comment. | |
| 490 | -#[test] | |
| 491 | -fn every_chroma_walking_leaf_dispatch_is_guarded_or_closed_with_a_reason() { | |
| 492 | - let src = crate::test_source::module_source("decode"); | |
| 493 | - // r2: `decode_body` is hoisted to the top of the test because the per-row | |
| 494 | - // guard check below needs it BEFORE the walk census it sits under, and a | |
| 495 | - // reader who has to hunt for a binding is a reader who will not notice | |
| 496 | - // when it is scoped to the wrong thing. | |
| 497 | - let production = crate::test_source::module_production_source("decode"); | |
| 498 | - let decode_body = match production.find("\n#[cfg(test)]\nmod tests {") { | |
| 499 | - Some(i) => &production[..i], | |
| 500 | - None => production, | |
| 501 | - }; | |
| 502 | - // (a) The shapes libaom cannot code, transcribed from the same | |
| 503 | - // `av1_ss_size_lookup` cells `PLANE_BLOCK_INVALID_422` carries. A walk | |
| 504 | - // handed one of these at the matching subsampling mode is the defect. | |
| 505 | - let invalid_at = | |
| 506 | - |bw: usize, bh: usize, sx: usize, sy: usize| !chroma_plane_block_codable(bw, bh, sx, sy); | |
| 507 | - | |
| 508 | - // (b) The CENSUS: every chroma-plane walk in the decode body, with the | |
| 509 | - // luma footprint(s) each dispatch can hand it. `guarded_by` names the | |
| 510 | - // mechanism, which is what a reader has to be able to check: | |
| 511 | - // | |
| 512 | - // * `refuse_invalid_subsize` at the DISPATCH -- the guard sits on | |
| 513 | - // the walk's own path (the hole this lane fixed, and the 8x8 / | |
| 514 | - // 16-level sites); | |
| 515 | - // * `refuse_invalid_subsize` at the RESOLUTION -- the dispatch is a | |
| 516 | - // `PARTITION_*` arm, so the level's guard saw the symbol that | |
| 517 | - // selected this shape before the call; | |
| 518 | - // * `unreachable` -- proven-uncodable at every subsampling mode a | |
| 519 | - // `color_config` can select, closed with an assertion instead of | |
| 520 | - // a guard. | |
| 521 | - // | |
| 522 | - // Each row is (walk, shapes, mechanism). | |
| 523 | - // | |
| 524 | - // r2 (Main's review, and it was right): `AtResolution` used to assert | |
| 525 | - // only that SOME shape the walk handles is BLOCK_INVALID, which | |
| 526 | - // restates the libaom table and never mentions a guard -- deleting the | |
| 527 | - // inter 32-level guard left it green. So a resolution row now CARRIES | |
| 528 | - // the guard it depends on: `(walk, fn-scope, level)`, and the check | |
| 529 | - // below looks for `refuse_invalid_subsize((level, level))` inside that | |
| 530 | - // function and before the walk's first call site in it. A row that | |
| 531 | - // cannot be checked that way says so with `Prose` instead. | |
| 532 | - enum Mech { | |
| 533 | - AtDispatch, | |
| 534 | - /// Protected by `refuse_invalid_subsize((L, L))` in the named | |
| 535 | - /// function, above the walk's first call site there. | |
| 536 | - AtResolution(&'static str, usize), | |
| 537 | - /// The walk is reached INDIRECTLY -- this row's guard is asserted to | |
| 538 | - /// exist in `fscope`, and the ordering is asserted by the per-route | |
| 539 | - /// loop further down (which scopes to the enclosing function and | |
| 540 | - /// names this walk's real caller chain). Used only where the walk's | |
| 541 | - /// call site is not in the guard's own function. | |
| 542 | - AtResolutionVia(&'static str, usize), | |
| 543 | - Unreachable(&'static str), | |
| 544 | - } | |
| 545 | - // The key-frame tile decoder and the inter tile decoder. Every | |
| 546 | - // resolution guard lives in one of the two, which is what makes "the | |
| 547 | - // guard for THIS row" a scoped lookup rather than a global one. | |
| 548 | - const KF: &str = "decode_key_frame_tile_with_cdfs"; | |
| 549 | - const INTER: &str = "decode_inter_frame_tile_with_cdfs"; | |
| 550 | - let census: &[(&str, &[(usize, usize)], Mech)] = &[ | |
| 551 | - // ---- the residue the merged lane named ------------------- | |
| 552 | - // | |
| 553 | - // `decode_rect4_16_intrabc` reconstructs one 16x4 or 4x16 strip. | |
| 554 | - // It has exactly ONE caller (`decode_rect4_16_strip`, decode.rs | |
| 555 | - // 18934), which has exactly two (17595 from `decode_rect4_16`, | |
| 556 | - // 13810 from `decode_intra_rect_in_inter`), which have one each | |
| 557 | - // (36793 key frame, 45447 inter). BOTH are 16x16-level 1:4 arms, so | |
| 558 | - // both sit under a `refuse_invalid_subsize((16, 16), part16)`. | |
| 559 | - // | |
| 560 | - // The offending subsize is the VERT_4 one and ONLY that one: | |
| 561 | - // `partition_subsize_dims((16,16), PARTITION_VERT_4) == (4,16)`, | |
| 562 | - // and (4,16) is in `PLANE_BLOCK_INVALID_422`, while HORZ_4 gives | |
| 563 | - // (16,4) whose (1,0) cell is BLOCK_8X4 and is legal. So the | |
| 564 | - // 16x16-level guard refuses exactly the shape that would be | |
| 565 | - // BLOCK_INVALID, and the strip that survives -- 16x4 -- is the one | |
| 566 | - // this decoder's `own422` arm is written for. Part (d) below | |
| 567 | - // re-derives that split and part (f) pins the caller count, so the | |
| 568 | - // closure is checked rather than asserted in prose. | |
| 569 | - ( | |
| 570 | - "decode_rect4_16_intrabc", | |
| 571 | - &[(16, 4), (4, 16)], | |
| 572 | - Mech::AtResolutionVia(KF, 16), | |
| 573 | - ), | |
| 574 | - // ---- 1:4 and 2:1 rect walks, all resolved-symbol guarded -- | |
| 575 | - ( | |
| 576 | - "decode_rect4_16", | |
| 577 | - &[(16, 4), (4, 16)], | |
| 578 | - Mech::AtResolution(KF, 16), | |
| 579 | - ), | |
| 580 | - ( | |
| 581 | - "decode_rect4_16_strip", | |
| 582 | - &[(16, 4), (4, 16)], | |
| 583 | - Mech::AtResolutionVia(KF, 16), | |
| 584 | - ), | |
| 585 | - ( | |
| 586 | - "decode_block_rect", | |
| 587 | - &[(32, 16), (16, 32)], | |
| 588 | - Mech::AtResolution(KF, 32), | |
| 589 | - ), | |
| 590 | - ( | |
| 591 | - "decode_block_rect4", | |
| 592 | - &[(32, 8), (8, 32)], | |
| 593 | - Mech::AtResolution(KF, 32), | |
| 594 | - ), | |
| 595 | - ( | |
| 596 | - "decode_block_rect64", | |
| 597 | - &[(64, 16), (16, 64)], | |
| 598 | - Mech::AtResolution(KF, 64), | |
| 599 | - ), | |
| 600 | - // The 128-root guard lives in `read_sb128_root`, the shared | |
| 601 | - // resolver both tile decoders call -- not in the walker's own | |
| 602 | - // function. | |
| 603 | - ( | |
| 604 | - "decode_block_128rect", | |
| 605 | - &[(128, 64), (64, 128)], | |
| 606 | - Mech::AtResolutionVia("read_sb128_root", 128), | |
| 607 | - ), | |
| 608 | - // `decode_rect_split` is called from inside decode_block_rect / | |
| 609 | - // decode_leaf_rect / decode_block_rect4 / decode_block_rect64, none of | |
| 610 | - // which is the tile decoder -- so the guard it inherits is checked on | |
| 611 | - // its own callers' rows, not here. | |
| 612 | - ( | |
| 613 | - "decode_rect_split", | |
| 614 | - &[(64, 16), (16, 64), (32, 16), (16, 32)], | |
| 615 | - Mech::AtResolutionVia(KF, 32), | |
| 616 | - ), | |
| 617 | - ( | |
| 618 | - "decode_leaf_rect", | |
| 619 | - &[(16, 8), (8, 16)], | |
| 620 | - Mech::AtResolution(KF, 16), | |
| 621 | - ), | |
| 622 | - // ---- the INTER-side rect walks ----------------------------- | |
| 623 | - // | |
| 624 | - // r2: without these three rows the inter 32- and 64-level guards | |
| 625 | - // were claimed by NOTHING, and deleting either left the census | |
| 626 | - // green. They are load-bearing -- `decode_intra_rect_in_inter` | |
| 627 | - // dispatches `decode_block_rect4` on 32x8/8x32 (8x32 is | |
| 628 | - // BLOCK_INVALID at 4:2:2) and `decode_block_rect64` on | |
| 629 | - // 64x16/16x64 (16x64 likewise) -- so each gets its own row naming | |
| 630 | - // the guard that stands in front of it. | |
| 631 | - // | |
| 632 | - // These are `AtResolutionVia`, not `AtResolution`: the walk is | |
| 633 | - // dispatched from `decode_intra_rect_in_inter`, a helper, not from | |
| 634 | - // the tile decoder the guard lives in. The check is therefore guard | |
| 635 | - // EXISTENCE in that decoder -- which is what reds when the guard | |
| 636 | - // is deleted -- and the linkage is stated here rather than derived. | |
| 637 | - ( | |
| 638 | - "decode_block_rect4[inter]", | |
| 639 | - &[(32, 8), (8, 32)], | |
| 640 | - Mech::AtResolutionVia(INTER, 32), | |
| 641 | - ), | |
| 642 | - ( | |
| 643 | - "decode_block_rect64[inter]", | |
| 644 | - &[(64, 16), (16, 64)], | |
| 645 | - Mech::AtResolutionVia(INTER, 64), | |
| 646 | - ), | |
| 647 | - ( | |
| 648 | - "decode_intra_rect_in_inter", | |
| 649 | - &[(16, 8), (8, 16), (16, 4), (4, 16)], | |
| 650 | - Mech::AtResolutionVia(INTER, 16), | |
| 651 | - ), | |
| 652 | - // ---- sub-8 walks ------------------------------------------ | |
| 653 | - // (8,4) is legal at 4:2:2 (`av1_ss_size_lookup[8x4][1][0]` is | |
| 654 | - // BLOCK_4X4); (4,8) is BLOCK_INVALID there. Both come off a raw | |
| 655 | - // `part8`, and both 8x8 resolution sites carry the guard -- plus | |
| 656 | - // the redundant inline `chroma_plane_block_codable` check the | |
| 657 | - // merged lane left at 36904. | |
| 658 | - ( | |
| 659 | - "decode_leaf_rect8", | |
| 660 | - &[(8, 4), (4, 8)], | |
| 661 | - Mech::AtResolution(KF, 8), | |
| 662 | - ), | |
| 663 | - ( | |
| 664 | - "decode_inter_sub8_rect2", | |
| 665 | - &[(8, 4), (4, 8)], | |
| 666 | - Mech::AtResolution(INTER, 8), | |
| 667 | - ), | |
| 668 | - ( | |
| 669 | - "decode_leaf_split4", | |
| 670 | - &[(4, 4)], | |
| 671 | - Mech::Unreachable("4x4's plane block is 4x4 at EVERY subsampling cell"), | |
| 672 | - ), | |
| 673 | - ( | |
| 674 | - "decode_inter_sub8_split4", | |
| 675 | - &[(4, 4)], | |
| 676 | - Mech::Unreachable("4x4's plane block is 4x4 at EVERY subsampling cell"), | |
| 677 | - ), | |
| 678 | - ( | |
| 679 | - "decode_leaf8", | |
| 680 | - &[(8, 8)], | |
| 681 | - Mech::Unreachable("8x8's plane block is 8x8 / 4x8 / 4x4, never BLOCK_INVALID"), | |
| 682 | - ), | |
| 683 | - // The square walks take only square footprints, and every square | |
| 684 | - // in `BLOCK_SIZES_ALL` has a valid plane block at EVERY selectable | |
| 685 | - // mode (the whole BLOCK_INVALID column is 4x8 / 8x4 / 4x16 / 8x16 | |
| 686 | - // / ... -- all rect). So no guard is needed for them, and the | |
| 687 | - // level guards that exist protect the SYMBOL that would have to | |
| 688 | - // select one of those rect shapes, not the square decode itself. | |
| 689 | - ( | |
| 690 | - "decode_block", | |
| 691 | - &[(128, 128), (64, 64), (32, 32), (16, 16), (8, 8)], | |
| 692 | - Mech::Unreachable( | |
| 693 | - "every SQUARE footprint's plane block is valid at every selectable \ | |
| 694 | - subsampling mode; the whole BLOCK_INVALID column is rect", | |
| 695 | - ), | |
| 696 | - ), | |
| 697 | - ( | |
| 698 | - "decode_inter_block", | |
| 699 | - &[(128, 128), (64, 64), (32, 32), (16, 16), (8, 8)], | |
| 700 | - Mech::Unreachable( | |
| 701 | - "every SQUARE footprint's plane block is valid at every selectable \ | |
| 702 | - subsampling mode; the whole BLOCK_INVALID column is rect", | |
| 703 | - ), | |
| 704 | - ), | |
| 705 | - ( | |
| 706 | - "decode_inter_block8", | |
| 707 | - &[(8, 8)], | |
| 708 | - Mech::Unreachable("8x8's plane block is 8x8 / 4x8 / 4x4, never BLOCK_INVALID"), | |
| 709 | - ), | |
| 710 | - // ---- THE HOLE THIS LANE FIXED --------------------------- | |
| 711 | - // | |
| 712 | - // `decode_leaf_rect`'s key-frame FRAME-EDGE caller (the one | |
| 713 | - // `decode_leaf_rect`'s row above does not cover, because that arm | |
| 714 | - // dispatches on a gathered `edge_split` instead of resolving into | |
| 715 | - // `part16`). It is 8x16 when the COLUMN is short -- BLOCK_INVALID | |
| 716 | - // at 4:2:2 -- and 16x8 when the ROW is, which is legal and must | |
| 717 | - // keep decoding. Before this lane nothing sat on that path. | |
| 718 | - ( | |
| 719 | - "decode_leaf_rect[16-edge]", | |
| 720 | - &[(16, 8), (8, 16)], | |
| 721 | - Mech::AtDispatch, | |
| 722 | - ), | |
| 723 | - ]; | |
| 724 | - | |
| 725 | - // (c) Every row's mechanism must be a REAL one. This is what stops | |
| 726 | - // the census from being a list of good intentions: each claim is | |
| 727 | - // re-derived here, and the file is checked for the site it names. | |
| 728 | - for (walk, shapes, mech) in census { | |
| 729 | - let name = walk.split('[').next().expect("walk name"); | |
| 730 | - assert!( | |
| 731 | - src.contains(&format!("fn {name}(")), | |
| 732 | - "the census names `{name}`, which is not a function in this file -- the \ | |
| 733 | - walk was renamed or removed and this row is stale" | |
| 734 | - ); | |
| 735 | - // Only subsampling modes a `color_config` can actually SELECT | |
| 736 | - // count. `(0, 1)` 4:4:0 is excluded on libaom's own authority -- | |
| 737 | - // it asserts `subsampling_y == 0` whenever `subsampling_x == 0` | |
| 738 | - // (`color_config`, av1_decoder.c), so no frame in existence is | |
| 739 | - // 4:4:0 and `PLANE_BLOCK_INVALID_440` is transcribed only to keep | |
| 740 | - // the cell table whole. Counting it here would make `16x4` look | |
| 741 | - // like a shape that needs a guard at a mode no stream can carry | |
| 742 | - // -- the same class as the merged lane's r2, which refused a legal | |
| 743 | - // 4:2:2 shape by testing a cell no `color_config` can request. | |
| 744 | - let offending: Vec<(usize, usize, usize, usize)> = shapes | |
| 745 | - .iter() | |
| 746 | - .flat_map(|&(bw, bh)| { | |
| 747 | - [(1, 0), (1, 1), (0, 0)] | |
| 748 | - .into_iter() | |
| 749 | - .filter_map(move |(sx, sy)| { | |
| 750 | - invalid_at(bw, bh, sx, sy).then_some((bw, bh, sx, sy)) | |
| 751 | - }) | |
| 752 | - }) | |
| 753 | - .collect(); | |
| 754 | - match mech { | |
| 755 | - // A dispatch-time guard has to reduce to the SAME shape the | |
| 756 | - // dispatch hands the walk -- this is the claim that made the | |
| 757 | - // hole a hole, stated as an assertion. | |
| 758 | - Mech::AtDispatch => { | |
| 759 | - assert!( | |
| 760 | - !offending.is_empty(), | |
| 761 | - "{walk} is listed AtDispatch but libaom codes every shape it \ | |
| 762 | - walks at every subsampling mode -- then it needs no guard" | |
| 763 | - ); | |
| 764 | - for &(bw, bh, sx, sy) in &offending { | |
| 765 | - assert!( | |
| 766 | - invalid_at(bw, bh, sx, sy), | |
| 767 | - "{walk} is not actually handed {bw}x{bh} at ({sx},{sy})" | |
| 768 | - ); | |
| 769 | - } | |
| 770 | - } | |
| 771 | - // r2: the guard THIS row depends on, scoped to the function it | |
| 772 | - // lives in and ordered before the walk's first call there. | |
| 773 | - // Deleting that one guard -- and only that one -- reds this row, | |
| 774 | - // which is what r2's review showed the previous version could | |
| 775 | - // not do. | |
| 776 | - Mech::AtResolution(fscope, level) => { | |
| 777 | - assert!( | |
| 778 | - !offending.is_empty(), | |
| 779 | - "{walk} is listed AtResolution but no shape it walks is BLOCK_INVALID \ | |
| 780 | - -- then the level's guard is not what protects it" | |
| 781 | - ); | |
| 782 | - let fstart = decode_body | |
| 783 | - .find(&format!("\nfn {fscope}(")) | |
| 784 | - .or_else(|| decode_body.find(&format!("\npub(crate) fn {fscope}("))) | |
| 785 | - .or_else(|| decode_body.find(&format!("\npub fn {fscope}("))) | |
| 786 | - .unwrap_or_else(|| { | |
| 787 | - panic!("the census names `{fscope}`, which is not a function here") | |
| 788 | - }); | |
| 789 | - let fend = ["\nfn ", "\npub fn ", "\npub(crate) fn "] | |
| 790 | - .iter() | |
| 791 | - .filter_map(|pat| decode_body[fstart + 1..].find(pat).map(|i| fstart + 1 + i)) | |
| 792 | - .min() | |
| 793 | - .unwrap_or(decode_body.len()); | |
| 794 | - let body = &decode_body[fstart..fend]; | |
| 795 | - let guard = format!("refuse_invalid_subsize(({level}, {level})"); | |
| 796 | - let gpos = body.find(&guard).unwrap_or_else(|| { | |
| 797 | - panic!( | |
| 798 | - "{walk} claims refuse_invalid_subsize(({level}, {level})) guards it, \ | |
| 799 | - but there is NO such guard in `{fscope}` -- the row's mechanism is \ | |
| 800 | - prose, not a check; re-derive it or mark the row Prose" | |
| 801 | - ) | |
| 802 | - }); | |
| 803 | - let call = body.find(&format!("{name}(")).unwrap_or_else(|| { | |
| 804 | - panic!("{walk} has no call site inside `{fscope}` to order the guard against") | |
| 805 | - }); | |
| 806 | - assert!( | |
| 807 | - gpos < call, | |
| 808 | - "{walk}: in `{fscope}` the ({level}, {level}) guard is at {gpos} and the \ | |
| 809 | - walk is dispatched at {call} -- a guard BELOW the dispatch can never \ | |
| 810 | - observe it" | |
| 811 | - ); | |
| 812 | - } | |
| 813 | - Mech::AtResolutionVia(fscope, level) => { | |
| 814 | - assert!( | |
| 815 | - !offending.is_empty(), | |
| 816 | - "{walk} is listed AtResolutionVia but no shape it walks is \ | |
| 817 | - BLOCK_INVALID" | |
| 818 | - ); | |
| 819 | - let fstart = decode_body | |
| 820 | - .find(&format!("\nfn {fscope}(")) | |
| 821 | - .or_else(|| decode_body.find(&format!("\npub(crate) fn {fscope}("))) | |
| 822 | - .or_else(|| decode_body.find(&format!("\npub fn {fscope}("))) | |
| 823 | - .unwrap_or_else(|| { | |
| 824 | - panic!("the census names `{fscope}`, which is not a function here") | |
| 825 | - }); | |
| 826 | - let fend = ["\nfn ", "\npub fn ", "\npub(crate) fn "] | |
| 827 | - .iter() | |
| 828 | - .filter_map(|pat| decode_body[fstart + 1..].find(pat).map(|i| fstart + 1 + i)) | |
| 829 | - .min() | |
| 830 | - .unwrap_or(decode_body.len()); | |
| 831 | - assert!( | |
| 832 | - decode_body[fstart..fend] | |
| 833 | - .contains(&format!("refuse_invalid_subsize(({level}, {level})")), | |
| 834 | - "{walk} claims refuse_invalid_subsize(({level}, {level})) in `{fscope}` \ | |
| 835 | - guards it, but there is NO such guard there" | |
| 836 | - ); | |
| 837 | - } | |
| 838 | - Mech::Unreachable(reason) => { | |
| 839 | - assert!( | |
| 840 | - offending.is_empty(), | |
| 841 | - "{walk} claims it is unreachable, but libaom marks {} \ | |
| 842 | - BLOCK_INVALID -- the claim is stale", | |
| 843 | - offending | |
| 844 | - .iter() | |
| 845 | - .map(|(bw, bh, sx, sy)| format!("{bw}x{bh}@({sx},{sy})")) | |
| 846 | - .collect::<Vec<_>>() | |
| 847 | - .join(", ") | |
| 848 | - ); | |
| 849 | - assert!( | |
| 850 | - reason.len() > 40, | |
| 851 | - "{walk}'s Unreachable reason is too short to name the symbol \ | |
| 852 | - or caller that makes it unreachable" | |
| 853 | - ); | |
| 854 | - } | |
| 855 | - } | |
| 856 | - } | |
| 857 | - | |
| 858 | - // (d) The residue's closure, derived rather than asserted in prose: | |
| 859 | - // the ONLY subsize its callers can hand it that libaom refuses at | |
| 860 | - // 4:2:2 is the 16x16-level VERT_4 one, and the level's own guard | |
| 861 | - // refuses exactly that. If either half stops holding -- a new caller | |
| 862 | - // at another level, or a change to `partition_subsize_dims` -- this | |
| 863 | - // reds instead of the comment going stale. | |
| 864 | - for &(part, want) in &[ | |
| 865 | - (PARTITION_HORZ_4, (16usize, 4usize)), | |
| 866 | - (PARTITION_VERT_4, (4, 16)), | |
| 867 | - ] { | |
| 868 | - let (bw, bh) = partition_subsize_dims((16, 16), part); | |
| 869 | - assert_eq!( | |
| 870 | - (bw, bh), | |
| 871 | - want, | |
| 872 | - "get_partition_subsize(BLOCK_16X16, {part}) moved" | |
| 873 | - ); | |
| 874 | - assert_eq!( | |
| 875 | - chroma_plane_block_codable(bw, bh, 1, 0), | |
| 876 | - part == PARTITION_HORZ_4, | |
| 877 | - "the 16x16 1:4 pair's (1,0) cells moved: HORZ_4 -> {bw}x{bh}, \ | |
| 878 | - VERT_4 -> {bw}x{bh}. decode_rect4_16_intrabc's Unreachable row \ | |
| 879 | - is written against exactly this split" | |
| 880 | - ); | |
| 881 | - } | |
| 882 | - // (e) The AtDispatch row, checked where it actually bites. This is | |
| 883 | - // the hole the merged lane's scan cannot see: its 220-line window is | |
| 884 | - // keyed on `dec.symbol(`, and the frame-edge arm reads | |
| 885 | - // `dec.symbol_fixed(&gather(..))` into `edge_split` and dispatches on | |
| 886 | - // THAT. The claim to check is ordering -- the guard has to sit between | |
| 887 | - // the read and the `decode_leaf_rect` it protects, which is r5's | |
| 888 | - // defect in a new place if it ever moves below. | |
| 889 | - let edge_read = src | |
| 890 | - .find("let edge_split = if has_cols16") | |
| 891 | - .expect("the key-frame 16-level frame-edge arm reads a gathered bit"); | |
| 892 | - let guard_at = src[edge_read..] | |
| 893 | - .find("refuse_invalid_subsize((16, 16)") | |
| 894 | - .map(|i| edge_read + i) | |
| 895 | - .expect( | |
| 896 | - "the key-frame 16-level frame-edge arm dispatches decode_leaf_rect on an \ | |
| 897 | - 8x16 strip (BLOCK_INVALID at 4:2:2) with NO refuse_invalid_subsize on its \ | |
| 898 | - path -- every sibling edge arm resolves into a guarded partN, this one does not", | |
| 899 | - ); | |
| 900 | - let walk_at = src[edge_read..] | |
| 901 | - .find("decode_leaf_rect(") | |
| 902 | - .map(|i| edge_read + i) | |
| 903 | - .expect("the frame-edge arm's decode_leaf_rect call"); | |
| 904 | - assert!( | |
| 905 | - guard_at < walk_at, | |
| 906 | - "the 16-level frame-edge guard (offset {guard_at}) sits AFTER the \ | |
| 907 | - decode_leaf_rect it protects (offset {walk_at}) -- it can never observe it" | |
| 908 | - ); | |
| 909 | - | |
| 910 | - // (f) The residue's closure, by CALLER COUNT rather than by prose: a | |
| 911 | - // third caller at another level is what would make the residue row | |
| 912 | - // stale, and a count reds on that where a comment cannot. Counted over | |
| 913 | - // the DECODE BODY only -- this test's own string literals name the same | |
| 914 | - // functions, and the merged lane's own scan hit exactly that (five of | |
| 915 | - // its eighteen `refuse_invalid_subsize((` matches are its own). | |
| 916 | - for (name, calls) in [ | |
| 917 | - ("decode_rect4_16_intrabc", 1usize), | |
| 918 | - ("decode_rect4_16_strip", 2), | |
| 919 | - ("decode_rect4_16", 1), | |
| 920 | - ("decode_intra_rect_in_inter", 1), | |
| 921 | - ] { | |
| 922 | - let needle = format!("{name}("); | |
| 923 | - let decl = format!("fn {name}("); | |
| 924 | - // A doc-comment mention (`[`name`](..)`) is prose, not a call, so | |
| 925 | - // comment lines are dropped before counting. | |
| 926 | - let body: String = decode_body | |
| 927 | - .lines() | |
| 928 | - .filter(|l| !l.trim_start().starts_with("//")) | |
| 929 | - .collect::<Vec<_>>() | |
| 930 | - .join("\n"); | |
| 931 | - let found = body.matches(&needle).count() - usize::from(body.contains(&decl)); | |
| 932 | - assert_eq!( | |
| 933 | - found, calls, | |
| 934 | - "{name} has {found} call site(s) in the decode body, the census expects \ | |
| 935 | - {calls}. A new caller is not automatically wrong, but it is not \ | |
| 936 | - automatically covered either: re-derive which level's guard it sits \ | |
| 937 | - under before this row stays green" | |
| 938 | - ); | |
| 939 | - } | |
| 940 | - // Both callers reach the 1:4 strips by a DIFFERENT route, so the | |
| 941 | - // closure is checked per route -- and per route it is the same shape: | |
| 942 | - // the 16x16-level guard must sit ABOVE the test that names VERT_4. | |
| 943 | - // | |
| 944 | - // key frame: `decode_rect4_16(...)` at 36793, inside an arm testing | |
| 945 | - // `part16 == PARTITION_HORZ_4 || part16 == PARTITION_VERT_4`. | |
| 946 | - // inter: the 1:4 strips reach `decode_intra_rect_in_inter` | |
| 947 | - // through `fctx.inter_strip_chroma`, whose ONLY writer is the inter | |
| 948 | - // 16-level 1:4 arm (55068) -- `strip16` is `None` without it. | |
| 949 | - // | |
| 950 | - // Ordering is the property (a guard BELOW the 1:4 test cannot observe | |
| 951 | - // it), which is why each pair is compared rather than merely counted. | |
| 952 | - for (what, test, call) in [ | |
| 953 | - ( | |
| 954 | - "the key-frame decode_rect4_16 caller", | |
| 955 | - "if part16 == PARTITION_HORZ_4", | |
| 956 | - "decode_rect4_16(", | |
| 957 | - ), | |
| 958 | - ( | |
| 959 | - "the inter-frame inter_strip_chroma writer", | |
| 960 | - "let horz = part16 == PARTITION_HORZ_4;", | |
| 961 | - "c.set(Some(InterStripChroma {", | |
| 962 | - ), | |
| 963 | - ] { | |
| 964 | - let fn_scope = |at: usize| -> std::ops::Range<usize> { | |
| 965 | - let head = ["\nfn ", "\npub fn ", "\npub(crate) fn "] | |
| 966 | - .iter() | |
| 967 | - .filter_map(|pat| decode_body[..at].rfind(pat)) | |
| 968 | - .max() | |
| 969 | - .unwrap_or(0); | |
| 970 | - let tail = ["\nfn ", "\npub fn ", "\npub(crate) fn "] | |
| 971 | - .iter() | |
| 972 | - .filter_map(|pat| decode_body[at..].find(pat).map(|i| at + i)) | |
| 973 | - .min() | |
| 974 | - .unwrap_or(decode_body.len()); | |
| 975 | - head..tail | |
| 976 | - }; | |
| 977 | - // The first occurrence of the test text can sit in another function (the files are | |
| 978 | - // concatenated in path order), so take the first occurrence whose own function holds | |
| 979 | - // the dispatch. The guard, the test and the dispatch must then share that function. | |
| 980 | - let (test_at, _, call_at) = decode_body | |
| 981 | - .match_indices(test) | |
| 982 | - .find_map(|(t, _)| { | |
| 983 | - let sc = fn_scope(t); | |
| 984 | - decode_body[sc.clone()] | |
| 985 | - .rfind(call) | |
| 986 | - .map(|i| (t, sc.clone(), sc.start + i)) | |
| 987 | - }) | |
| 988 | - .unwrap_or_else(|| panic!("the 1:4 arm test {test:?} for {what} is gone, or no function holds its dispatch {call:?}")); | |
| 989 | - // The dispatch is searched inside the 1:4 test's own function: the files are | |
| 990 | - // concatenated in path order, so the last occurrence in the whole text is no longer | |
| 991 | - // the key-frame call. The guard, test and dispatch must share that function. | |
| 992 | - // `decode_rect4_16(` also matches the DEFINITION, which is the | |
| 993 | - // first occurrence -- the call is the last one. | |
| 994 | - // r2 (Main's review, and it was right): the guard search is SCOPED | |
| 995 | - // to the anchor's own enclosing function. `find()` over the whole | |
| 996 | - // decode body returns the FIRST `refuse_invalid_subsize((16, 16)` -- | |
| 997 | - // the KEY-FRAME one -- so the inter pair's comparison was satisfied | |
| 998 | - // by a guard three quarters of the file away, and deleting the inter | |
| 999 | - // 16-level guard left this test green. Both routes live in | |
| 1000 | - // different `fn` bodies (`decode_key_frame_tile_with_cdfs` and the | |
| 1001 | - // inter tile decoder), so the enclosing function is the scope that | |
| 1002 | - // tells the two apart. | |
| 1003 | - let scope = fn_scope(test_at); | |
| 1004 | - let guard_at = decode_body[scope.clone()] | |
| 1005 | - .find("refuse_invalid_subsize((16, 16)") | |
| 1006 | - .map(|i| scope.start + i) | |
| 1007 | - .unwrap_or_else(|| { | |
| 1008 | - panic!( | |
| 1009 | - "{what}: there is NO refuse_invalid_subsize((16, 16)) in the function \ | |
| 1010 | - enclosing the 1:4 arm test -- so nothing refuses the VERT_4 symbol \ | |
| 1011 | - this arm dispatches on, and decode_rect4_16_intrabc's closure is gone" | |
| 1012 | - ) | |
| 1013 | - }); | |
| 1014 | - assert!( | |
| 1015 | - guard_at < test_at && test_at < call_at, | |
| 1016 | - "{what}: guard at {guard_at} (function scope {scope:?}), 1:4 arm test at \ | |
| 1017 | - {test_at}, dispatch at {call_at}. The guard has to sit ABOVE the 1:4 arm \ | |
| 1018 | - test INSIDE THE SAME FUNCTION, or the VERT_4 symbol it refuses has already \ | |
| 1019 | - been dispatched on" | |
| 1020 | - ); | |
| 1021 | - assert!( | |
| 1022 | - scope.contains(&guard_at) && scope.contains(&test_at) && scope.contains(&call_at), | |
| 1023 | - "{what}: guard, 1:4 test and dispatch must share one enclosing function" | |
| 1024 | - ); | |
| 1025 | - } | |
| 1026 | - // And the inter route really is the only one: `strip16` is built from | |
| 1027 | - // `strip_chroma`, which is `inter_strip_chroma.take()`, so a missing | |
| 1028 | - // writer would silently drop the arm rather than expose it. | |
| 1029 | - assert_eq!( | |
| 1030 | - decode_body.matches("inter_strip_chroma.with(|c| {").count(), | |
| 1031 | - 1, | |
| 1032 | - "inter_strip_chroma gained a second writer -- the inter 1:4 strips can now \ | |
| 1033 | - come from a level whose guard this census has not checked" | |
| 1034 | - ); | |
| 1035 | - | |
| 1036 | - // (g) PER-SITE rows. Everything above claims a guard by LEVEL -- | |
| 1037 | - // "there is a `refuse_invalid_subsize((8, 8))` somewhere in the | |
| 1038 | - // key-frame tile decoder" -- and that is exactly what makes two | |
| 1039 | - // guards deletable: the key-frame 8x8 level has TWO resolution | |
| 1040 | - // sites (37322 and 37621) and the walk census's `decode_leaf_rect8` | |
| 1041 | - // row is satisfied by the first one, so deleting the SECOND left the | |
| 1042 | - // test green; the inter decoder carries its OWN 128-root guard | |
| 1043 | - // (54495) while the `decode_block_128rect` row names | |
| 1044 | - // `read_sb128_root`, so deleting the inter copy also left it green. | |
| 1045 | - // The merged scan's count cross-check is what reds them, and a | |
| 1046 | - // count is not a location. | |
| 1047 | - // | |
| 1048 | - // So each row below names an ANCHOR that is unique in the decode | |
| 1049 | - // body -- the code the site hangs off -- and requires the level's | |
| 1050 | - // guard to sit between that anchor and the dispatch the site | |
| 1051 | - // feeds, within the same function. A level guard elsewhere in that | |
| 1052 | - // function cannot stand in, because the search starts AT the | |
| 1053 | - // anchor. Deleting the named guard finds no guard after the anchor | |
| 1054 | - // and reds; moving it below the dispatch reds the ordering assert. | |
| 1055 | - // | |
| 1056 | - // Row shape: (site label, guard's function, level, unique anchor, | |
| 1057 | - // dispatch token the guard must precede, shapes the site walks). | |
| 1058 | - let body_of = |name: &str| -> &str { | |
| 1059 | - let start = decode_body | |
| 1060 | - .find(&format!("\nfn {name}(")) | |
| 1061 | - .or_else(|| decode_body.find(&format!("\npub(crate) fn {name}("))) | |
| 1062 | - .or_else(|| decode_body.find(&format!("\npub fn {name}("))) | |
| 1063 | - .unwrap_or_else(|| panic!("{name} is not a function in this file")); | |
| 1064 | - let end = ["\nfn ", "\npub fn ", "\npub(crate) fn "] | |
| 1065 | - .iter() | |
| 1066 | - .filter_map(|pat| decode_body[start + 1..].find(pat).map(|i| start + 1 + i)) | |
| 1067 | - .min() | |
| 1068 | - .unwrap_or(decode_body.len()); | |
| 1069 | - &decode_body[start..end] | |
| 1070 | - }; | |
| 1071 | - let site_rows: &[(&str, &str, usize, &str, &str, &[(usize, usize)])] = &[ | |
| 1072 | - // The key-frame 8x8 level resolves TWICE (37322 for the frame | |
| 1073 | - // interior, 37621 for the `pre8` probe path). Both feed | |
| 1074 | - // `decode_leaf_rect8` on a raw `part8`, whose VERT shape is 4x8 -- | |
| 1075 | - // BLOCK_INVALID at 4:2:2. The anchor `let pre8 = ...` is what | |
| 1076 | - // makes this row about the SECOND site: with `find()` scoped to | |
| 1077 | - // the function alone the search would return 37322 and never | |
| 1078 | - // look here. | |
| 1079 | - ( | |
| 1080 | - "the key-frame 8x8 SECOND resolution", | |
| 1081 | - KF, | |
| 1082 | - 8, | |
| 1083 | - "let pre8 = dec.debug_state().0;", | |
| 1084 | - "decode_leaf_rect8(", | |
| 1085 | - &[(8, 4), (4, 8)], | |
| 1086 | - ), | |
| 1087 | - // The inter decoder resolves its own 128 root at 54495 rather | |
| 1088 | - // than routing through `read_sb128_root` (which is where the | |
| 1089 | - // `decode_block_128rect` row's guard lives). The dispatch token | |
| 1090 | - // is the `half128_inter!` arm that descends into a 128x64 / | |
| 1091 | - // 64x128 rect -- both BLOCK_INVALID at 4:2:2 in | |
| 1092 | - // `PLANE_BLOCK_INVALID_422`. `macro_rules! half128_inter` is | |
| 1093 | - // unique in the file, so this row cannot drift onto the other | |
| 1094 | - // one. | |
| 1095 | - ( | |
| 1096 | - "the inter decoder's own 128-root guard", | |
| 1097 | - INTER, | |
| 1098 | - 128, | |
| 1099 | - "macro_rules! half128_inter", | |
| 1100 | - "half128_inter!((br_mi, base_mi.1), 128, 64,", | |
| 1101 | - &[(128, 64), (64, 128)], | |
| 1102 | - ), | |
| 1103 | - ]; | |
| 1104 | - for (label, fscope, level, anchor, dispatch, shapes) in site_rows { | |
| 1105 | - assert_eq!( | |
| 1106 | - decode_body.matches(anchor).count(), | |
| 1107 | - 1, | |
| 1108 | - "{label}: the site anchor {anchor:?} is not unique in the decode body, so it \ | |
| 1109 | - cannot name one site -- re-derive the anchor for this row" | |
| 1110 | - ); | |
| 1111 | - // Why the site needs a guard at all: something it dispatches is | |
| 1112 | - // BLOCK_INVALID at a mode a `color_config` can select. (0, 1) is | |
| 1113 | - // excluded for the same reason as the walk census above. | |
| 1114 | - let offending: Vec<(usize, usize, usize, usize)> = shapes | |
| 1115 | - .iter() | |
| 1116 | - .flat_map(|&(bw, bh)| { | |
| 1117 | - [(1, 0), (1, 1), (0, 0)] | |
| 1118 | - .into_iter() | |
| 1119 | - .filter_map(move |(sx, sy)| { | |
| 1120 | - invalid_at(bw, bh, sx, sy).then_some((bw, bh, sx, sy)) | |
| 1121 | - }) | |
| 1122 | - }) | |
| 1123 | - .collect(); | |
| 1124 | - assert!( | |
| 1125 | - !offending.is_empty(), | |
| 1126 | - "{label} claims a guard but libaom codes every shape it walks at every \ | |
| 1127 | - selectable subsampling mode -- then it needs none" | |
| 1128 | - ); | |
| 1129 | - let body = body_of(fscope); | |
| 1130 | - let a = body.find(anchor).unwrap_or_else(|| { | |
| 1131 | - panic!( | |
| 1132 | - "{label}: the anchor {anchor:?} is not inside `{fscope}` -- the guard \ | |
| 1133 | - moved to another function, and the row's scope is stale" | |
| 1134 | - ) | |
| 1135 | - }); | |
| 1136 | - let gpat = format!("refuse_invalid_subsize(({level}, {level})"); | |
| 1137 | - let g = body[a..].find(&gpat).map(|i| a + i).unwrap_or_else(|| { | |
| 1138 | - panic!( | |
| 1139 | - "{label}: `{fscope}` has NO {gpat} at or after the site anchor {anchor:?} \ | |
| 1140 | - -- this site's guard is gone. The level claim elsewhere in this test is \ | |
| 1141 | - still satisfied by the OTHER {level}x{level} guard in the file, which is \ | |
| 1142 | - precisely why this row exists" | |
| 1143 | - ) | |
| 1144 | - }); | |
| 1145 | - let gap = body[a..g].lines().count(); | |
| 1146 | - assert!( | |
| 1147 | - gap <= 40, | |
| 1148 | - "{label}: the {gpat} sits {gap} lines below its own anchor {anchor:?} -- that is \ | |
| 1149 | - a different site, so this row has stopped naming what it claims to name" | |
| 1150 | - ); | |
| 1151 | - let d = body[g..].find(dispatch).map(|i| g + i).unwrap_or_else(|| { | |
| 1152 | - panic!( | |
| 1153 | - "{label}: `{fscope}` dispatches {dispatch:?} nowhere AFTER its {gpat} -- \ | |
| 1154 | - either the dispatch moved above the guard or the site was rewritten" | |
| 1155 | - ) | |
| 1156 | - }); | |
| 1157 | - assert!( | |
| 1158 | - g < d, | |
| 1159 | - "{label}: guard at {g} sits at or after the dispatch at {d} -- a guard BELOW \ | |
| 1160 | - the dispatch can never observe it" | |
| 1161 | - ); | |
| 1162 | - } | |
| 1163 | -} | |
| 1164 | - | |
| 1165 | -/// lane/av1422rect4dead: the `(pw / 2, ph / 2)` / `MI / 2` origin `else` | |
| 1166 | -/// arm of [`decode_rect4_16_intrabc`] is the 4:2:0 PAIR geometry. It is | |
| 1167 | -/// still LIVE at ss (1, 1) -- a 1:4 strip's chroma lies inside its | |
| 1168 | -/// 4:2:0 pair there -- so the arm is not deleted; it is CLOSED at ss | |
| 1169 | -/// (1, 0), where it would run on a 4x16 VERT_4 strip whose chroma plane | |
| 1170 | -/// block is BLOCK_INVALID, and where libaom's own | |
| 1171 | -/// `is_chroma_reference` (av1_common_int.h:1454, `|| !subsampling_y`) | |
| 1172 | -/// makes every strip its own chroma reference anyway (the `own422` arm | |
| 1173 | -/// handles that). The proof: the sole caller `decode_rect4_16_strip` is | |
| 1174 | -/// reached only via the two 16x16-level 1:4 arms, each under | |
| 1175 | -/// `refuse_invalid_subsize((16, 16), part16)` -- at ss (1, 0) that guard | |
| 1176 | -/// refuses `partition_subsize_dims((16, 16), PARTITION_VERT_4) == (4, 16)` | |
| 1177 | -/// (in `PLANE_BLOCK_INVALID_422`), and the surviving HORZ_4 16x4 strip | |
| 1178 | -/// takes `own422`. This test re-derives that chain from the file so it | |
| 1179 | -/// REDS when any half stops holding: deleting the in-arm assertion, a | |
| 1180 | -/// caller moving under a level whose guard does not refuse (4, 16) at | |
| 1181 | -/// ss (1, 0), or the `(pw / 2, ph / 2)` form drifting. 4:2:0 and 4:4:4 | |
| 1182 | -/// behaviour are unchanged: the gate runs only the file scan and the | |
| 1183 | -/// closed cell's arithmetic, no decode. | |
| 1184 | -#[test] | |
| 1185 | -fn decode_rect4_16_intrabc_else_arm_stays_closed_at_422() { | |
| 1186 | - let production = crate::test_source::module_production_source("decode"); | |
| 1187 | - let decode_body = match production.find("\n#[cfg(test)]\nmod tests {") { | |
| 1188 | - Some(i) => &production[..i], | |
| 1189 | - None => production, | |
| 1190 | - }; | |
| 1191 | - | |
| 1192 | - // (a) The closure assertion must exist INSIDE the function, in the | |
| 1193 | - // `else` arm of the `(cw, ch)` select, naming the shape and the | |
| 1194 | - // subsampling. Deleting it -- or re-adding the bare halving without | |
| 1195 | - // it -- reds here. | |
| 1196 | - let fstart = decode_body | |
| 1197 | - .find("\nfn decode_rect4_16_intrabc(") | |
| 1198 | - .expect("decode_rect4_16_intrabc is gone -- this gate guards its else arm"); | |
| 1199 | - let fend = ["\nfn ", "\npub fn ", "\npub(crate) fn "] | |
| 1200 | - .iter() | |
| 1201 | - .filter_map(|pat| decode_body[fstart + 1..].find(pat).map(|i| fstart + 1 + i)) | |
| 1202 | - .min() | |
| 1203 | - .unwrap_or(decode_body.len()); | |
| 1204 | - let body = &decode_body[fstart..fend]; | |
| 1205 | - let else_arm = body | |
| 1206 | - .find(" let (cw, ch) = if own_chroma {") | |
| 1207 | - .expect("the (cw, ch) select moved out of decode_rect4_16_intrabc"); | |
| 1208 | - let closure = &body[else_arm..]; | |
| 1209 | - assert!( | |
| 1210 | - closure.contains("assert!(") && closure.contains("ss_x(fctx) == 1 && ss_y(fctx) == 0"), | |
| 1211 | - "the decode_rect4_16_intrabc else arm's ss (1, 0) closure assertion is \ | |
| 1212 | - GONE -- the 4:2:0 pair geometry is unreachable at ss (1, 0) only while \ | |
| 1213 | - that assert (and the guards below) stand; re-add it" | |
| 1214 | - ); | |
| 1215 | - | |
| 1216 | - // (b) The sole-caller chain, re-derived from the file: exactly one | |
| 1217 | - // call to `decode_rect4_16_intrabc(` outside its own definition, in | |
| 1218 | - // `decode_rect4_16_strip`; exactly two calls to | |
| 1219 | - // `decode_rect4_16_strip(` from the two 1:4 routes. | |
| 1220 | - let code_lines: String = decode_body | |
| 1221 | - .lines() | |
| 1222 | - .filter(|l| !l.trim_start().starts_with("//")) | |
| 1223 | - .collect::<Vec<_>>() | |
| 1224 | - .join("\n"); | |
| 1225 | - let count_calls = |name: &str| -> usize { | |
| 1226 | - code_lines.matches(&format!("{name}(")).count() | |
| 1227 | - - usize::from(code_lines.contains(&format!("fn {name}("))) | |
| 1228 | - }; | |
| 1229 | - assert_eq!( | |
| 1230 | - count_calls("decode_rect4_16_intrabc"), | |
| 1231 | - 1, | |
| 1232 | - "decode_rect4_16_intrabc gained a caller -- re-derive whether the new route \ | |
| 1233 | - sits under a guard that refuses (4, 16) at ss (1, 0) before this gate \ | |
| 1234 | - stays green" | |
| 1235 | - ); | |
| 1236 | - assert_eq!( | |
| 1237 | - count_calls("decode_rect4_16_strip"), | |
| 1238 | - 2, | |
| 1239 | - "decode_rect4_16_strip's caller set moved -- both routes must be \ | |
| 1240 | - 16x16-level 1:4 arms under a (16, 16) guard that refuses (4, 16) at \ | |
| 1241 | - ss (1, 0)" | |
| 1242 | - ); | |
| 1243 | - | |
| 1244 | - // (c) Both routes sit under a `refuse_invalid_subsize((16, 16), ...)`: | |
| 1245 | - // the key-frame arm's guard ordered above the arm test, the inter | |
| 1246 | - // arm's guard in the inter decoder above its own 1:4 test. Scoped to | |
| 1247 | - // the enclosing function so the other decoder's guard cannot stand in | |
| 1248 | - // (the r2 class this file already fixed once). | |
| 1249 | - let fn_scope = |at: usize| -> std::ops::Range<usize> { | |
| 1250 | - let head = ["\nfn ", "\npub fn ", "\npub(crate) fn "] | |
| 1251 | - .iter() | |
| 1252 | - .filter_map(|pat| decode_body[..at].rfind(pat)) | |
| 1253 | - .max() | |
| 1254 | - .unwrap_or(0); | |
| 1255 | - let tail = ["\nfn ", "\npub fn ", "\npub(crate) fn "] | |
| 1256 | - .iter() | |
| 1257 | - .filter_map(|pat| decode_body[at..].find(pat).map(|i| at + i)) | |
| 1258 | - .min() | |
| 1259 | - .unwrap_or(decode_body.len()); | |
| 1260 | - head..tail | |
| 1261 | - }; | |
| 1262 | - let kf_test = decode_body | |
| 1263 | - .find("if part16 == PARTITION_HORZ_4") | |
| 1264 | - .expect("the key-frame 16-level 1:4 arm test is gone"); | |
| 1265 | - let kf_scope = fn_scope(kf_test); | |
| 1266 | - let kf_guard = decode_body[kf_scope.clone()] | |
| 1267 | - .find("refuse_invalid_subsize((16, 16)") | |
| 1268 | - .map(|i| kf_scope.start + i) | |
| 1269 | - .unwrap_or_else(|| { | |
| 1270 | - panic!( | |
| 1271 | - "the key-frame 16-level 1:4 arm has NO \ | |
| 1272 | - refuse_invalid_subsize((16, 16)) above it in its own \ | |
| 1273 | - function -- the VERT_4 (4, 16) refusal that closed \ | |
| 1274 | - decode_rect4_16_intrabc's else arm at ss (1, 0) is gone" | |
| 1275 | - ) | |
| 1276 | - }); | |
| 1277 | - assert!( | |
| 1278 | - kf_guard < kf_test, | |
| 1279 | - "the key-frame (16, 16) guard sits below the 1:4 arm test -- it can never \ | |
| 1280 | - observe the VERT_4 symbol that must be refused before \ | |
| 1281 | - decode_rect4_16_intrabc's else arm can run at ss (1, 0)" | |
| 1282 | - ); | |
| 1283 | - let inter_writer = decode_body | |
| 1284 | - .find("let horz = part16 == PARTITION_HORZ_4;") | |
| 1285 | - .expect("the inter 16-level 1:4 arm is gone"); | |
| 1286 | - let inter_scope = fn_scope(inter_writer); | |
| 1287 | - let inter_guard = decode_body[inter_scope.clone()] | |
| 1288 | - .find("refuse_invalid_subsize((16, 16)") | |
| 1289 | - .map(|i| inter_scope.start + i) | |
| 1290 | - .unwrap_or_else(|| { | |
| 1291 | - panic!( | |
| 1292 | - "the inter-frame 16-level 1:4 arm has NO \ | |
| 1293 | - refuse_invalid_subsize((16, 16)) in its function -- the VERT_4 \ | |
| 1294 | - (4, 16) refusal that closed decode_rect4_16_intrabc's else arm \ | |
| 1295 | - at ss (1, 0) is gone" | |
| 1296 | - ) | |
| 1297 | - }); | |
| 1298 | - assert!( | |
| 1299 | - inter_guard < inter_writer, | |
| 1300 | - "the inter (16, 16) guard sits below the 1:4 arm test -- it can never \ | |
| 1301 | - observe the VERT_4 symbol that must be refused before \ | |
| 1302 | - decode_rect4_16_intrabc's else arm can run at ss (1, 0)" | |
| 1303 | - ); | |
| 1304 | - | |
| 1305 | - // (d) The shape/subsampling cells the closure is written against, | |
| 1306 | - // re-executed: (4, 16) must still be BLOCK_INVALID at ss (1, 0) while | |
| 1307 | - // (16, 4) stays codable there, and at ss (1, 1) BOTH are codable -- | |
| 1308 | - // which is what keeps the arm live at 4:2:0 and the assertion inert | |
| 1309 | - // there. At ss (0, 0) everything is codable, so `own444` (and the | |
| 1310 | - // assertion) never see the else arm. | |
| 1311 | - assert!( | |
| 1312 | - !chroma_plane_block_codable(4, 16, 1, 0), | |
| 1313 | - "(4, 16) left PLANE_BLOCK_INVALID_422 -- the else arm is now REACHABLE at \ | |
| 1314 | - ss (1, 0) with the halved pair geometry, which is a real defect, not a \ | |
| 1315 | - closure: re-derive the whole chain, then fix the halving instead of the \ | |
| 1316 | - assert" | |
| 1317 | - ); | |
| 1318 | - assert!( | |
| 1319 | - chroma_plane_block_codable(16, 4, 1, 0), | |
| 1320 | - "(16, 4) became BLOCK_INVALID at ss (1, 0) -- the surviving HORZ_4 strip \ | |
| 1321 | - takes own422, and the closure assert would fire on a legal shape; \ | |
| 1322 | - re-derive" | |
| 1323 | - ); | |
| 1324 | - assert!( | |
| 1325 | - chroma_plane_block_codable(4, 16, 1, 1) && chroma_plane_block_codable(16, 4, 1, 1), | |
| 1326 | - "a 1:4 strip's plane block moved at ss (1, 1) -- the else arm is LIVE there \ | |
| 1327 | - and the pair geometry is what decodes it; the assertion must stay inert at \ | |
| 1328 | - 4:2:0" | |
| 1329 | - ); | |
| 1330 | - assert!( | |
| 1331 | - chroma_plane_block_codable(4, 16, 0, 0) && chroma_plane_block_codable(16, 4, 0, 0), | |
| 1332 | - "a 1:4 strip's plane block became invalid at ss (0, 0) -- the assertion sits \ | |
| 1333 | - after the own444 arm and must never fire at 4:4:4; re-derive" | |
| 1334 | - ); | |
| 1335 | -} | |
| 1336 | - | |
| 1337 | 131 | /// lane-av1chrtx: [`covering_leaf_tx_type`] resolves a chroma unit's |
| 1338 | 132 | /// `tx_type` from the luma leaf covering the unit's OWN quadrant, and |
| 1339 | 133 | /// reports "no leaf there" as `None` so the caller can fall back to the |
| @@ -1749,13 +543,42 @@ fn cdef_filter_block_under_test( | ||
| 1749 | 543 | ) { |
| 1750 | 544 | if let Some(t) = archmage::X64V3Token::summon() { |
| 1751 | 545 | return super::cdef_simd::filter_block_avx2( |
| 1752 | - t, src, dst, stride, ox, oy, bw, bh, pri_strength, sec_strength, dir, | |
| 1753 | - pri_damping, sec_damping, enable_primary, enable_secondary, coeff_shift, smax, | |
| 546 | + t, | |
| 547 | + src, | |
| 548 | + dst, | |
| 549 | + stride, | |
| 550 | + ox, | |
| 551 | + oy, | |
| 552 | + bw, | |
| 553 | + bh, | |
| 554 | + pri_strength, | |
| 555 | + sec_strength, | |
| 556 | + dir, | |
| 557 | + pri_damping, | |
| 558 | + sec_damping, | |
| 559 | + enable_primary, | |
| 560 | + enable_secondary, | |
| 561 | + coeff_shift, | |
| 562 | + smax, | |
| 1754 | 563 | ); |
| 1755 | 564 | } |
| 1756 | 565 | super::cdef_filter_block_scalar( |
| 1757 | - src, dst, stride, ox, oy, bw, bh, pri_strength, sec_strength, dir, | |
| 1758 | - pri_damping, sec_damping, enable_primary, enable_secondary, coeff_shift, smax, | |
| 566 | + src, | |
| 567 | + dst, | |
| 568 | + stride, | |
| 569 | + ox, | |
| 570 | + oy, | |
| 571 | + bw, | |
| 572 | + bh, | |
| 573 | + pri_strength, | |
| 574 | + sec_strength, | |
| 575 | + dir, | |
| 576 | + pri_damping, | |
| 577 | + sec_damping, | |
| 578 | + enable_primary, | |
| 579 | + enable_secondary, | |
| 580 | + coeff_shift, | |
| 581 | + smax, | |
| 1759 | 582 | ) |
| 1760 | 583 | } |
| 1761 | 584 | |
| @@ -2096,8 +919,8 @@ fn filter_intra_classes_carry_their_own_libaom_default_row() { | ||
| 2096 | 919 | ); |
| 2097 | 920 | } |
| 2098 | 921 | } |
| 2099 | -use archmage::SimdToken; | |
| 2100 | 922 | use super::*; |
| 923 | +use archmage::SimdToken; | |
| 2101 | 924 | |
| 2102 | 925 | /// lane-tx64x16 r3: the two new 4:1 chroma scans are a TRANSPOSED PAIR -- |
| 2103 | 926 | /// `SCAN_4X16[i]` must name the transpose of the position |
| @@ -2415,84 +1238,6 @@ fn an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking() { | ||
| 2415 | 1238 | ); |
| 2416 | 1239 | } |
| 2417 | 1240 | |
| 2418 | -/// lane-t900 r27, structural audit for "an OBMC neighbour whose switchable | |
| 2419 | -/// interp filter was never recorded": the `[3, 3]` sentinel is only ever | |
| 2420 | -/// PUBLISHED for a cell an OBMC blend cannot pick up. | |
| 2421 | -/// | |
| 2422 | -/// `Neighbours::record_inter_rect_mi` is the single writer of | |
| 2423 | -/// `above_filter`/`left_filter` (every other recorder routes through it), | |
| 2424 | -/// so the whole domain of published values is its call sites' 7th | |
| 2425 | -/// argument. Two publications are safe: an INTRA cell (`is_inter = false`, | |
| 2426 | -/// skipped by `overlappable_above`/`overlappable_left`'s own `is_inter` | |
| 2427 | -/// gate) and a fixed-filter frame (`resolve_interp_filter` returns the | |
| 2428 | -/// sentinel when `interp_fixed` is `Some`, which `neighbour_filter` | |
| 2429 | -/// answers before ever looking at the symbols). What this scans for is the | |
| 2430 | -/// third case -- an INTER cell stamped with a literal sentinel, which is | |
| 2431 | -/// what the refusal actually fires on. Arguments are tokenised | |
| 2432 | -/// positionally, never `contains()`d. | |
| 2433 | -#[test] | |
| 2434 | -fn every_inter_record_publishes_an_obmc_readable_filter() { | |
| 2435 | - let src = crate::test_source::module_source("decode"); | |
| 2436 | - let mut calls = 0usize; | |
| 2437 | - for (start, _) in src.match_indices("record_inter_rect_mi(") { | |
| 2438 | - // Skip the definition and the wrapper's own forwarding call. | |
| 2439 | - let line_start = src[..start].rfind('\n').map_or(0, |i| i + 1); | |
| 2440 | - let head = &src[line_start..start]; | |
| 2441 | - // The definition, the wrapper's own forwarding call, and this | |
| 2442 | - // test's own mentions of the name (doc comment, scan pattern, | |
| 2443 | - // assert message) are not publication sites. | |
| 2444 | - if head.contains("fn ") || head.contains("///") || head.ends_with('"') { | |
| 2445 | - continue; | |
| 2446 | - } | |
| 2447 | - let mut i = start + "record_inter_rect_mi(".len(); | |
| 2448 | - let (mut depth, mut arg, mut args) = (0i32, String::new(), Vec::new()); | |
| 2449 | - let bytes = src.as_bytes(); | |
| 2450 | - while i < bytes.len() { | |
| 2451 | - let c = bytes[i] as char; | |
| 2452 | - match c { | |
| 2453 | - '(' | '[' => depth += 1, | |
| 2454 | - ')' | ']' if depth == 0 && c == ')' => break, | |
| 2455 | - ')' | ']' => depth -= 1, | |
| 2456 | - ',' if depth == 0 => { | |
| 2457 | - args.push(std::mem::take(&mut arg)); | |
| 2458 | - i += 1; | |
| 2459 | - continue; | |
| 2460 | - } | |
| 2461 | - _ => {} | |
| 2462 | - } | |
| 2463 | - arg.push(c); | |
| 2464 | - i += 1; | |
| 2465 | - } | |
| 2466 | - if !arg.trim().is_empty() { | |
| 2467 | - args.push(arg); | |
| 2468 | - } | |
| 2469 | - assert_eq!( | |
| 2470 | - args.len(), | |
| 2471 | - 8, | |
| 2472 | - "record_inter_rect_mi gained an argument -- re-index this audit: {args:?}" | |
| 2473 | - ); | |
| 2474 | - calls += 1; | |
| 2475 | - let (is_inter, filter) = (args[4].trim(), args[6].trim()); | |
| 2476 | - if filter.starts_with('[') { | |
| 2477 | - assert_eq!( | |
| 2478 | - filter.replace(' ', ""), | |
| 2479 | - "[3,3]", | |
| 2480 | - "a literal filter other than the sentinel is published at call {calls}" | |
| 2481 | - ); | |
| 2482 | - assert_eq!( | |
| 2483 | - is_inter, "false", | |
| 2484 | - "an INTER cell is stamped with the [3, 3] sentinel (call {calls}): an OBMC \ | |
| 2485 | - blend picking it up refuses by name. Publish the block's own resolved \ | |
| 2486 | - switchable symbols instead." | |
| 2487 | - ); | |
| 2488 | - } | |
| 2489 | - } | |
| 2490 | - assert!( | |
| 2491 | - calls >= 6, | |
| 2492 | - "the audit found only {calls} publication sites -- it is broken, not the decoder" | |
| 2493 | - ); | |
| 2494 | -} | |
| 2495 | - | |
| 2496 | 1241 | /// lane-t900 r27, negative gate for "a reference frame selected with no |
| 2497 | 1242 | /// picture at this frame's own ref_frame_idx slot for it": every |
| 2498 | 1243 | /// non-`LAST_FRAME` reference resolves through `ref_planes`, and an empty |
| @@ -2797,7 +1542,6 @@ fn a_skipped_block_decodes_to_pure_prediction() { | ||
| 2797 | 1542 | DC_PRED, |
| 2798 | 1543 | &mut cdfs.kf_y_mode[INTRA_MODE_CTX[DC_PRED]][INTRA_MODE_CTX[DC_PRED]], |
| 2799 | 1544 | ); |
| 2800 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | |
| 2801 | 1545 | enc.symbol(DC_PRED, &mut cdfs.uv_mode_no_cfl[DC_PRED]); |
| 2802 | 1546 | let data = enc.finish(); |
| 2803 | 1547 | let decoded = decode_key_frame_tile( |
| @@ -2842,7 +1586,6 @@ fn a_skipped_block_decodes_to_pure_prediction() { | ||
| 2842 | 1586 | #[test] |
| 2843 | 1587 | fn a_skipped_intrabc_chroma_reference_leaf_disarms_the_inherited_chroma_tx() { |
| 2844 | 1588 | let fctx = &crate::decode::FrameCtx::new(); |
| 2845 | - reset_skipped_intrabc_chroma_arm_hits(); | |
| 2846 | 1589 | use crate::msac::SymbolEncoder; |
| 2847 | 1590 | let mut cdfs = Cdfs::new(q_ctx_of(40)); |
| 2848 | 1591 | let mut enc = SymbolEncoder::new(); |
| @@ -2883,10 +1626,6 @@ fn a_skipped_intrabc_chroma_reference_leaf_disarms_the_inherited_chroma_tx() { | ||
| 2883 | 1626 | true, |
| 2884 | 1627 | fctx, |
| 2885 | 1628 | ); |
| 2886 | - assert!( | |
| 2887 | - skipped_intrabc_chroma_arm_hits() >= 1, | |
| 2888 | - "the hand-written tile never reached the skipped-intrabc chroma-reference route" | |
| 2889 | - ); | |
| 2890 | 1629 | assert!( |
| 2891 | 1630 | fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_none(), |
| 2892 | 1631 | "the inherited chroma transform slot must be disarmed when its block's chroma \ |
| @@ -2901,7 +1640,6 @@ fn a_skipped_intrabc_chroma_reference_leaf_disarms_the_inherited_chroma_tx() { | ||
| 2901 | 1640 | #[test] |
| 2902 | 1641 | fn a_skipped_intrabc_rect_chroma_reference_leaf_disarms_the_inherited_chroma_tx() { |
| 2903 | 1642 | let fctx = &crate::decode::FrameCtx::new(); |
| 2904 | - reset_skipped_intrabc_chroma_arm_hits(); | |
| 2905 | 1643 | use crate::msac::SymbolEncoder; |
| 2906 | 1644 | let mut cdfs = Cdfs::new(q_ctx_of(40)); |
| 2907 | 1645 | let mut enc = SymbolEncoder::new(); |
| @@ -2934,10 +1672,6 @@ fn a_skipped_intrabc_rect_chroma_reference_leaf_disarms_the_inherited_chroma_tx( | ||
| 2934 | 1672 | true, |
| 2935 | 1673 | fctx, |
| 2936 | 1674 | ); |
| 2937 | - assert!( | |
| 2938 | - skipped_intrabc_chroma_arm_hits() >= 1, | |
| 2939 | - "the hand-written tile never reached the skipped-intrabc rect chroma-reference route" | |
| 2940 | - ); | |
| 2941 | 1675 | assert!( |
| 2942 | 1676 | fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_none(), |
| 2943 | 1677 | "the inherited chroma transform slot must be disarmed when its block's chroma \ |
| @@ -3012,7 +1746,6 @@ fn a_non_split_inter_sb_partition_refuses_by_name_instead_of_desyncing() { | ||
| 3012 | 1746 | // helpers are `#[cfg(test)]`-private to it). |
| 3013 | 1747 | use crate::probe::run_with_stdin; |
| 3014 | 1748 | |
| 3015 | - | |
| 3016 | 1749 | /// Decodes one AV1 OBU stream with ffmpeg and hands back its one 4:2:0 |
| 3017 | 1750 | /// frame's planes, at ffmpeg's own (coded, block-padded) size. |
| 3018 | 1751 | fn ffmpeg_decode(stream: &[u8], width: usize, height: usize) -> Picture { |
| @@ -3124,7 +1857,8 @@ fn ffprobe_size(stream: &[u8]) -> (u32, u32) { | ||
| 3124 | 1857 | "-of", |
| 3125 | 1858 | "csv=p=0", |
| 3126 | 1859 | ]) |
| 3127 | - .arg(&path).output() | |
| 1860 | + .arg(&path) | |
| 1861 | + .output() | |
| 3128 | 1862 | .expect("ffprobe failed to run"); |
| 3129 | 1863 | let _ = std::fs::remove_file(&path); |
| 3130 | 1864 | assert!( |
| @@ -3216,7 +1950,6 @@ fn a_filter_intra_key_frame_decodes_pixel_exact_through_ffmpeg() { | ||
| 3216 | 1950 | } |
| 3217 | 1951 | let encoded = crate::encode::encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap(); |
| 3218 | 1952 | let (coded_w, coded_h) = ffprobe_size(&encoded.stream); |
| 3219 | - let before = filter_intra_hits(); | |
| 3220 | 1953 | let ours = decode_key_frame_tile_lr( |
| 3221 | 1954 | &encoded.tile, |
| 3222 | 1955 | encoded.mi_cols, |
| @@ -3235,12 +1968,6 @@ fn a_filter_intra_key_frame_decodes_pixel_exact_through_ffmpeg() { | ||
| 3235 | 1968 | fctx, |
| 3236 | 1969 | ) |
| 3237 | 1970 | .unwrap(); |
| 3238 | - let fired = filter_intra_hits() - before; | |
| 3239 | - assert!( | |
| 3240 | - fired > 0, | |
| 3241 | - "no block took filter intra -- the gate is blind to the feature" | |
| 3242 | - ); | |
| 3243 | - eprintln!("a_filter_intra_key_frame: {fired} filter-intra blocks"); | |
| 3244 | 1971 | let ffmpeg_decoded = ffmpeg_decode(&encoded.stream, coded_w as usize, coded_h as usize); |
| 3245 | 1972 | assert_eq!(ours.y, ffmpeg_decoded.y, "luma vs ffmpeg"); |
| 3246 | 1973 | assert_eq!(ours.u, ffmpeg_decoded.u, "U vs ffmpeg"); |
crates/ec-av1/src/decode/tx4x8_table_tests.rsdeleted+0 -89
| @@ -1,89 +0,0 @@ | ||
| 1 | -use super::*; | |
| 2 | - | |
| 3 | -/// Asymmetric gate on the two new scan tables (class | |
| 4 | -/// `reference-layout-not-spec`): a transposed pair of tables passes any | |
| 5 | -/// "is a permutation" check, so this pins the pair AGAINST each other -- | |
| 6 | -/// `SCAN_8X4[k]` must be `SCAN_4X8[k]` reflected across the diagonal, and | |
| 7 | -/// both must be bijections of `0..32` in our own row-major indexing. | |
| 8 | -#[test] | |
| 9 | -fn the_rect_4x8_scans_are_each_other_transposed() { | |
| 10 | - let mut seen_a = [false; 32]; | |
| 11 | - let mut seen_b = [false; 32]; | |
| 12 | - for k in 0..32usize { | |
| 13 | - let a = SCAN_4X8[k] as usize; | |
| 14 | - let b = SCAN_8X4[k] as usize; | |
| 15 | - assert!(!seen_a[a] && !seen_b[b], "scan position {k} repeats"); | |
| 16 | - seen_a[a] = true; | |
| 17 | - seen_b[b] = true; | |
| 18 | - let (row, col) = (a / 4, a % 4); | |
| 19 | - assert_eq!( | |
| 20 | - b, | |
| 21 | - col * 8 + row, | |
| 22 | - "SCAN_8X4[{k}] is not SCAN_4X8[{k}] transposed" | |
| 23 | - ); | |
| 24 | - } | |
| 25 | - assert!(seen_a.iter().all(|&s| s) && seen_b.iter().all(|&s| s)); | |
| 26 | -} | |
| 27 | - | |
| 28 | -/// `mrow_scan_4x8`/`mcol_scan_4x8`/`mrow_scan_8x4`/`mcol_scan_8x4` | |
| 29 | -/// (libaom `scan.c`), converted out of their column-major encoding by | |
| 30 | -/// `(p % h) * w + p / h` -- the head of each, pinned so the rect | |
| 31 | -/// `V_DCT`/`H_DCT` walk cannot silently transpose. | |
| 32 | -#[test] | |
| 33 | -fn the_rect_class1_scans_match_libaom() { | |
| 34 | - assert_eq!( | |
| 35 | - class_scan_table_wh(4, 8, TxClass::Vert), | |
| 36 | - (0..32u16).collect::<Vec<_>>() | |
| 37 | - ); | |
| 38 | - assert_eq!( | |
| 39 | - &class_scan_table_wh(4, 8, TxClass::Horiz)[..8], | |
| 40 | - &[0u16, 4, 8, 12, 16, 20, 24, 28] | |
| 41 | - ); | |
| 42 | - assert_eq!( | |
| 43 | - class_scan_table_wh(8, 4, TxClass::Vert), | |
| 44 | - (0..32u16).collect::<Vec<_>>() | |
| 45 | - ); | |
| 46 | - assert_eq!( | |
| 47 | - &class_scan_table_wh(8, 4, TxClass::Horiz)[..8], | |
| 48 | - &[0u16, 8, 16, 24, 1, 9, 17, 25] | |
| 49 | - ); | |
| 50 | -} | |
| 51 | - | |
| 52 | -/// The 32-position `eob_pt` alphabet: six symbols (one more than the | |
| 53 | -/// 16-position table, one fewer than the 64-position one), strictly | |
| 54 | -/// increasing, terminated at 32768 with the adaptation counter after it. | |
| 55 | -#[test] | |
| 56 | -fn the_32_position_eob_tables_are_well_formed() { | |
| 57 | - for table in [ | |
| 58 | - &cdf::EOB_PT_32_LUMA_Q0, | |
| 59 | - &cdf::EOB_PT_32_LUMA_Q1, | |
| 60 | - &cdf::EOB_PT_32_LUMA, | |
| 61 | - &cdf::EOB_PT_32_LUMA_Q3, | |
| 62 | - &cdf::EOB_PT_32_LUMA_CLASS1_Q0, | |
| 63 | - &cdf::EOB_PT_32_LUMA_CLASS1_Q1, | |
| 64 | - &cdf::EOB_PT_32_LUMA_CLASS1, | |
| 65 | - &cdf::EOB_PT_32_LUMA_CLASS1_Q3, | |
| 66 | - ] { | |
| 67 | - assert_eq!(table.len(), 7); | |
| 68 | - assert_eq!(table[5], 32768); | |
| 69 | - assert_eq!(table[6], 0); | |
| 70 | - for w in table[..6].windows(2) { | |
| 71 | - assert!(w[0] < w[1], "{table:?} is not increasing"); | |
| 72 | - } | |
| 73 | - } | |
| 74 | -} | |
| 75 | - | |
| 76 | -/// `Reach::of_rect` must read libaom's own `has_tr_4x8`/`has_tr_8x4` | |
| 77 | -/// rows, not the 32x16 pair the two existing rect strips use: the two | |
| 78 | -/// shapes disagree at a position inside the superblock, which is what | |
| 79 | -/// makes this an asymmetric check rather than a tautology. | |
| 80 | -#[test] | |
| 81 | -fn the_sub8_rect_reach_tables_are_shape_specific() { | |
| 82 | - let fctx = &crate::decode::FrameCtx::new(); | |
| 83 | - let a = Reach::of_rect(4, 8, 4, 8, 64, 64, fctx); | |
| 84 | - let b = Reach::of_rect(8, 4, 8, 4, 64, 64, fctx); | |
| 85 | - assert!( | |
| 86 | - a.above_right != b.above_right || a.below_left != b.below_left, | |
| 87 | - "4x8 and 8x4 reach identically at mirrored positions -- one table is unused" | |
| 88 | - ); | |
| 89 | -} |
crates/ec-av1/src/dumpio.rsdeleted+0 -568
| @@ -1,568 +0,0 @@ | ||
| 1 | -//! Loud dump writing: a dump that cannot hold every byte it claims to hold is | |
| 2 | -//! a failure, not a diagnostic artefact. | |
| 3 | -//! | |
| 4 | -//! lane-av1dumploud: every dump site in this crate wrote through | |
| 5 | -//! `let _ = f.write_all(..)`. A full filesystem, an `RLIMIT_FSIZE`, or any other | |
| 6 | -//! `ENOSPC`/`EFBIG` therefore left a SHORT file on disk and nothing said so. | |
| 7 | -//! Measured consequence, twice in one day: a sentinel-vs-plain hash difference | |
| 8 | -//! that read as decoder nondeterminism reproduced bit-for-bit as a truncated | |
| 9 | -//! dump (`lanes/unwritten-dep.report.md`: frames 0..4 complete plus 13 320 192 | |
| 10 | -//! bytes of frame 5, with `EC_AV1_FINAL_DUMP`'s discarded write error), and an | |
| 11 | -//! empty dump read as instability. That artefact started a whole defect class, | |
| 12 | -//! and a silently wrong diagnostic is worse than a loud one, so every dump site | |
| 13 | -//! goes through [`LoudDump`]: the caller states the expected byte count from the | |
| 14 | -//! geometry it already has, the writer checks that count twice -- once against | |
| 15 | -//! the bytes it was handed, once against the file's own length on disk -- and | |
| 16 | -//! any shortfall aborts the decode with the file, the counts, and the OS error. | |
| 17 | -//! | |
| 18 | -//! The success path is byte-identical to the old `write_all` loop: same bytes, | |
| 19 | -//! same order, same file names. | |
| 20 | -//! | |
| 21 | -//! The failure path is a panic, not a returned `Result`: the dump sites sit in | |
| 22 | -//! the middle of `fn decode_*` functions with no error channel for them, and a | |
| 23 | -//! dump that failed IS a decode failure (the run's measurement is void). This | |
| 24 | -//! is a debug instrument -- it only runs when its env var is set -- so the | |
| 25 | -//! panic cannot affect a normal decode. | |
| 26 | - | |
| 27 | -use std::fs::{File, OpenOptions}; | |
| 28 | -use std::io::Write; | |
| 29 | -use std::path::{Path, PathBuf}; | |
| 30 | - | |
| 31 | -/// One dump file, with the byte count it owes accounted for as it goes. | |
| 32 | -pub struct LoudDump { | |
| 33 | - /// Human-readable label for the failure line: the env var, or | |
| 34 | - /// `VAR.suffix` when the file names something the var alone does not. | |
| 35 | - site: String, | |
| 36 | - path: PathBuf, | |
| 37 | - file: Option<File>, | |
| 38 | - written: usize, | |
| 39 | - /// `None` only for a stream whose total length is genuinely unknowable at | |
| 40 | - /// open time (an append-mode text table). Short-write detection still | |
| 41 | - /// applies -- `write_all` reports a short write as `Err` -- but the failure | |
| 42 | - /// line then carries no expected count, because inventing one would be a | |
| 43 | - /// guess. | |
| 44 | - expected: Option<usize>, | |
| 45 | -} | |
| 46 | - | |
| 47 | -impl LoudDump { | |
| 48 | - /// Open `path` for `site`, expecting exactly `expected` bytes in total. | |
| 49 | - /// | |
| 50 | - /// Failing to CREATE is loud too: a requested dump that does not exist is | |
| 51 | - /// the same silent hole as one that is short (the reader sees no file, or | |
| 52 | - /// an empty one), and it is the more common of the two (a missing parent | |
| 53 | - /// directory, a path a sweep reused as a directory). | |
| 54 | - pub fn create(site: &str, path: impl AsRef<Path>, expected: usize) -> Self { | |
| 55 | - let path = path.as_ref().to_path_buf(); | |
| 56 | - let file = File::create(&path).unwrap_or_else(|e| { | |
| 57 | - abort( | |
| 58 | - site, | |
| 59 | - &path, | |
| 60 | - 0, | |
| 61 | - Some(expected), | |
| 62 | - &format!("could not create the dump file: {e}"), | |
| 63 | - ) | |
| 64 | - }); | |
| 65 | - Self { | |
| 66 | - site: site.to_string(), | |
| 67 | - path, | |
| 68 | - file: Some(file), | |
| 69 | - written: 0, | |
| 70 | - expected: Some(expected), | |
| 71 | - } | |
| 72 | - } | |
| 73 | - | |
| 74 | - /// Open `path` for `site` in APPEND mode with no knowable total length -- | |
| 75 | - /// the CDF-table text dump, whose file spans every frame of a run. Write | |
| 76 | - /// errors are still fatal; the length check is simply absent (see | |
| 77 | - /// [`LoudDump::expected`]). | |
| 78 | - pub fn append_unknown(site: &str, path: impl AsRef<Path>) -> Self { | |
| 79 | - let path = path.as_ref().to_path_buf(); | |
| 80 | - let file = OpenOptions::new() | |
| 81 | - .create(true) | |
| 82 | - .append(true) | |
| 83 | - .open(&path) | |
| 84 | - .unwrap_or_else(|e| { | |
| 85 | - abort( | |
| 86 | - site, | |
| 87 | - &path, | |
| 88 | - 0, | |
| 89 | - None, | |
| 90 | - &format!("could not open the dump file: {e}"), | |
| 91 | - ) | |
| 92 | - }); | |
| 93 | - Self { | |
| 94 | - site: site.to_string(), | |
| 95 | - path, | |
| 96 | - file: Some(file), | |
| 97 | - written: 0, | |
| 98 | - expected: None, | |
| 99 | - } | |
| 100 | - } | |
| 101 | - | |
| 102 | - /// Hand `chunk` to the file. Overrunning `expected` is a caller bug (the | |
| 103 | - /// count and the writer disagree) and aborts just as loudly as a short | |
| 104 | - /// write, because one of the two is certainly lying. | |
| 105 | - pub fn write(&mut self, chunk: &[u8]) { | |
| 106 | - if let Some(exp) = self.expected | |
| 107 | - && self.written + chunk.len() > exp | |
| 108 | - { | |
| 109 | - abort( | |
| 110 | - &self.site, | |
| 111 | - &self.path, | |
| 112 | - self.written, | |
| 113 | - Some(exp), | |
| 114 | - &format!( | |
| 115 | - "the writer was handed {} bytes but only {} remained of the {} it declared", | |
| 116 | - chunk.len(), | |
| 117 | - exp - self.written, | |
| 118 | - exp | |
| 119 | - ), | |
| 120 | - ); | |
| 121 | - } | |
| 122 | - let r = self.file.as_mut().expect("live dump").write_all(chunk); | |
| 123 | - if let Err(e) = r { | |
| 124 | - // MEASURED, do not assume: under `RLIMIT_FSIZE` the kernel stores | |
| 125 | - // everything up to the cap and THEN returns `EFBIG` (measured: | |
| 126 | - // a 49 152 B frame under caps of 4 KiB / 10 KiB / 30 KiB left | |
| 127 | - // 4 096 / 10 240 / 30 720 B on disk, with `write_all` confirming | |
| 128 | - // none of it). So "bytes written" on this line is the file's real | |
| 129 | - // length, not the count `write_all` got to acknowledge -- the | |
| 130 | - // acknowledged count rides along in the reason. | |
| 131 | - let f = self.file.as_ref().expect("live dump"); | |
| 132 | - let on_disk = f | |
| 133 | - .metadata() | |
| 134 | - .map(|m| m.len() as usize) | |
| 135 | - .unwrap_or(self.written); | |
| 136 | - abort( | |
| 137 | - &self.site, | |
| 138 | - &self.path, | |
| 139 | - on_disk, | |
| 140 | - self.expected, | |
| 141 | - &format!( | |
| 142 | - "write failed with {} bytes confirmed in hand: {e}", | |
| 143 | - self.written | |
| 144 | - ), | |
| 145 | - ); | |
| 146 | - } | |
| 147 | - self.written += chunk.len(); | |
| 148 | - } | |
| 149 | - | |
| 150 | - /// Close the dump: flush, then check the file's own length on disk. | |
| 151 | - /// | |
| 152 | - /// The on-disk check is not redundant with the write loop. `write_all` | |
| 153 | - /// reports what the FILE ACCEPTED, and the reader's question is what the | |
| 154 | - /// filesystem ended up holding -- a sparse/short final flush, a quota, or a | |
| 155 | - /// filesystem-level reservation failure all land here rather than in | |
| 156 | - /// `write`. | |
| 157 | - pub fn finish(mut self) { | |
| 158 | - let Some(mut file) = self.file.take() else { | |
| 159 | - return; | |
| 160 | - }; | |
| 161 | - if let Err(e) = file.flush() { | |
| 162 | - abort( | |
| 163 | - &self.site, | |
| 164 | - &self.path, | |
| 165 | - self.written, | |
| 166 | - self.expected, | |
| 167 | - &format!("flush failed after {} bytes: {e}", self.written), | |
| 168 | - ); | |
| 169 | - } | |
| 170 | - let Some(exp) = self.expected else { | |
| 171 | - return; | |
| 172 | - }; | |
| 173 | - let on_disk = match file.metadata() { | |
| 174 | - Ok(m) => m.len() as usize, | |
| 175 | - Err(e) => abort( | |
| 176 | - &self.site, | |
| 177 | - &self.path, | |
| 178 | - self.written, | |
| 179 | - Some(exp), | |
| 180 | - &format!("could not stat the finished dump: {e}"), | |
| 181 | - ), | |
| 182 | - }; | |
| 183 | - if on_disk != exp { | |
| 184 | - abort( | |
| 185 | - &self.site, | |
| 186 | - &self.path, | |
| 187 | - on_disk, | |
| 188 | - Some(exp), | |
| 189 | - "the file on disk is not the length the writer declared", | |
| 190 | - ); | |
| 191 | - } | |
| 192 | - } | |
| 193 | -} | |
| 194 | - | |
| 195 | -/// The single failure line every short dump now ends on. `site`, the path, the | |
| 196 | -/// bytes on disk vs the bytes owed, and the reason. | |
| 197 | -fn abort(site: &str, path: &Path, got: usize, expected: Option<usize>, why: &str) -> ! { | |
| 198 | - panic!("{}", failure_line(site, path, got, expected, why)); | |
| 199 | -} | |
| 200 | - | |
| 201 | -/// The failure line itself, so the fatal and the reporting shapes cannot | |
| 202 | -/// drift apart. | |
| 203 | -fn failure_line(site: &str, path: &Path, got: usize, expected: Option<usize>, why: &str) -> String { | |
| 204 | - let owed = match expected { | |
| 205 | - Some(e) => format!("{e}"), | |
| 206 | - None => "an unknown number of".to_string(), | |
| 207 | - }; | |
| 208 | - format!( | |
| 209 | - "ec-av1 dump FAILED [{}] {}: wrote {} of {} bytes: {}", | |
| 210 | - site, | |
| 211 | - path.display(), | |
| 212 | - got, | |
| 213 | - owed, | |
| 214 | - why | |
| 215 | - ) | |
| 216 | -} | |
| 217 | - | |
| 218 | -/// Write `bytes` to `path` as a FATAL pin: [`pin`] IS a wrapper -- three | |
| 219 | -/// [`LoudDump`] calls (`create`/`write`/`finish`), so it inherits the flush and | |
| 220 | -/// the flush-then-stat ordering for free. | |
| 221 | -/// | |
| 222 | -/// lane-av1pinloud: the test-pin sites in `stream.rs` wrote with | |
| 223 | -/// `let _ = std::fs::write(..)` and then named the path in the panic that | |
| 224 | -/// followed ("stream pinned at {}"), so an `ENOSPC`/`EFBIG` left a TRUNCATED | |
| 225 | -/// stream at exactly the path the reader was told to replay -- the same | |
| 226 | -/// silent-truncation class as the dump path, one hop later. Success path is | |
| 227 | -/// byte-identical: same bytes, same path, truncate-then-write. | |
| 228 | -pub fn pin(site: &str, path: impl AsRef<Path>, bytes: &[u8]) { | |
| 229 | - let mut d = LoudDump::create(site, path, bytes.len()); | |
| 230 | - d.write(bytes); | |
| 231 | - d.finish(); | |
| 232 | -} | |
| 233 | - | |
| 234 | -/// [`pin`]'s NON-FATAL twin, for a site that must not die on a failed pin -- a | |
| 235 | -/// gate whose real failure is the assert that comes after the pin attempt, and | |
| 236 | -/// whose comment says so. | |
| 237 | -/// | |
| 238 | -/// This one RE-IMPLEMENTS the check rather than wrapping [`LoudDump`], whose | |
| 239 | -/// failure channel is `panic!`: it cannot report instead of dying. So it does | |
| 240 | -/// `fs::write` + `metadata` itself. Only the failure LINE is shared, via | |
| 241 | -/// [`failure_line`] -- the ordering (flush-then-stat) and the | |
| 242 | -/// write-error-handling are not shared with [`LoudDump`], and a reader must not | |
| 243 | -/// assume they are. | |
| 244 | -/// | |
| 245 | -/// Non-fatal, but not silent: a shortfall comes back as the very same failure | |
| 246 | -/// line [`pin`] would have panicked with, expected-vs-on-disk counts included, | |
| 247 | -/// for the caller to print as a warning. | |
| 248 | -#[cfg(test)] // only the self-test below calls it; keeps the non-test build free of dead code | |
| 249 | -pub fn pin_reporting(site: &str, path: impl AsRef<Path>, bytes: &[u8]) -> Result<(), String> { | |
| 250 | - let path = path.as_ref(); | |
| 251 | - let expected = bytes.len(); | |
| 252 | - if let Err(e) = std::fs::write(path, bytes) { | |
| 253 | - let on_disk = std::fs::metadata(path) | |
| 254 | - .map(|m| m.len() as usize) | |
| 255 | - .unwrap_or(0); | |
| 256 | - return Err(failure_line( | |
| 257 | - site, | |
| 258 | - path, | |
| 259 | - on_disk, | |
| 260 | - Some(expected), | |
| 261 | - &format!("could not write the pin: {e}"), | |
| 262 | - )); | |
| 263 | - } | |
| 264 | - let on_disk = match std::fs::metadata(path) { | |
| 265 | - Ok(m) => m.len() as usize, | |
| 266 | - Err(e) => { | |
| 267 | - return Err(failure_line( | |
| 268 | - site, | |
| 269 | - path, | |
| 270 | - expected, | |
| 271 | - Some(expected), | |
| 272 | - &format!("could not stat the written pin: {e}"), | |
| 273 | - )); | |
| 274 | - } | |
| 275 | - }; | |
| 276 | - if on_disk != expected { | |
| 277 | - return Err(failure_line( | |
| 278 | - site, | |
| 279 | - path, | |
| 280 | - on_disk, | |
| 281 | - Some(expected), | |
| 282 | - "the pinned file on disk is not the length of the stream", | |
| 283 | - )); | |
| 284 | - } | |
| 285 | - Ok(()) | |
| 286 | -} | |
| 287 | - | |
| 288 | -/// Write `planes` (already narrowed to their dump's sample width) as ONE dump | |
| 289 | -/// file, failing loudly on any shortfall. `expected` is the sum of the plane | |
| 290 | -/// lengths -- the same extents the writer iterates, so a plane that is shorter | |
| 291 | -/// than its geometry claims cannot hide here. | |
| 292 | -pub fn write_planes(site: &str, path: impl AsRef<Path>, planes: &[&[u8]]) { | |
| 293 | - let expected: usize = planes.iter().map(|p| p.len()).sum(); | |
| 294 | - let mut d = LoudDump::create(site, path, expected); | |
| 295 | - for p in planes { | |
| 296 | - d.write(p); | |
| 297 | - } | |
| 298 | - d.finish(); | |
| 299 | -} | |
| 300 | - | |
| 301 | -#[cfg(test)] | |
| 302 | -mod tests { | |
| 303 | - use super::*; | |
| 304 | - use std::process::Command; | |
| 305 | - | |
| 306 | - fn scratch(tag: &str) -> PathBuf { | |
| 307 | - let p = std::env::temp_dir().join(format!("ec-av1-dumpio-{tag}-{}", std::process::id())); | |
| 308 | - let _ = std::fs::remove_file(&p); | |
| 309 | - p | |
| 310 | - } | |
| 311 | - | |
| 312 | - fn caught(f: impl FnOnce() + std::panic::UnwindSafe) -> String { | |
| 313 | - let prev = std::panic::take_hook(); | |
| 314 | - std::panic::set_hook(Box::new(|_| {})); | |
| 315 | - let r = std::panic::catch_unwind(f); | |
| 316 | - std::panic::set_hook(prev); | |
| 317 | - let e = r.expect_err("the short dump must abort"); | |
| 318 | - e.downcast_ref::<String>() | |
| 319 | - .cloned() | |
| 320 | - .or_else(|| e.downcast_ref::<&str>().map(|s| (*s).to_string())) | |
| 321 | - .expect("panic payload is a string") | |
| 322 | - } | |
| 323 | - | |
| 324 | - #[test] | |
| 325 | - fn success_path_is_byte_identical_to_the_old_write_all_loop() { | |
| 326 | - let p = scratch("ok"); | |
| 327 | - let planes: [&[u8]; 3] = [b"abc", b"", b"de"]; | |
| 328 | - write_planes("T", &p, &planes); | |
| 329 | - assert_eq!(std::fs::read(&p).unwrap(), b"abcde"); | |
| 330 | - let _ = std::fs::remove_file(&p); | |
| 331 | - } | |
| 332 | - | |
| 333 | - /// `/dev/full` accepts an `open` for write and returns `ENOSPC` from every | |
| 334 | - /// write -- the hermetic stand-in for the full filesystem that produced the | |
| 335 | - /// 13 320 192-byte truncated frame in `lanes/unwritten-dep.report.md`. | |
| 336 | - #[test] | |
| 337 | - #[cfg(unix)] | |
| 338 | - fn full_device_short_write_is_loud() { | |
| 339 | - let msg = caught(|| write_planes("EC_AV1_FINAL_DUMP", "/dev/full", &[b"abc", b"de"])); | |
| 340 | - assert!( | |
| 341 | - msg.starts_with("ec-av1 dump FAILED [EC_AV1_FINAL_DUMP] /dev/full: wrote "), | |
| 342 | - "{msg}" | |
| 343 | - ); | |
| 344 | - assert!(msg.contains("No space left on device"), "{msg}"); | |
| 345 | - // The counts must be there, or the line does not say what was lost. | |
| 346 | - assert!(msg.contains(" of 5 bytes"), "{msg}"); | |
| 347 | - } | |
| 348 | - | |
| 349 | - #[test] | |
| 350 | - fn uncreatable_dump_is_loud() { | |
| 351 | - let p = std::env::temp_dir().join(format!("ec-av1-nodir-{}/x", std::process::id())); | |
| 352 | - let msg = caught(|| write_planes("T", &p, &[b"abc"])); | |
| 353 | - assert!(msg.contains("could not create the dump file"), "{msg}"); | |
| 354 | - } | |
| 355 | - | |
| 356 | - /// A writer that under-declares its own expected length is the same silent | |
| 357 | - /// hole: the reader gets a file the site believes is complete. | |
| 358 | - #[test] | |
| 359 | - fn under_declared_expected_length_is_loud() { | |
| 360 | - let p = scratch("under"); | |
| 361 | - let msg = caught(|| { | |
| 362 | - let mut d = LoudDump::create("T", &p, 2); | |
| 363 | - d.write(b"abcdef"); | |
| 364 | - d.finish(); | |
| 365 | - }); | |
| 366 | - assert!( | |
| 367 | - msg.contains("was handed 6 bytes but only 2 remained of the 2 it declared"), | |
| 368 | - "{msg}" | |
| 369 | - ); | |
| 370 | - let _ = std::fs::remove_file(&p); | |
| 371 | - } | |
| 372 | - | |
| 373 | - #[test] | |
| 374 | - fn append_unknown_takes_no_length_claim() { | |
| 375 | - let p = scratch("append"); | |
| 376 | - { | |
| 377 | - let mut a = LoudDump::append_unknown("T", &p); | |
| 378 | - a.write(b"x"); | |
| 379 | - a.finish(); | |
| 380 | - let mut b = LoudDump::append_unknown("T", &p); | |
| 381 | - b.write(b"y"); | |
| 382 | - b.finish(); | |
| 383 | - } | |
| 384 | - assert_eq!(std::fs::read(&p).unwrap(), b"xy"); | |
| 385 | - let msg = caught(|| { | |
| 386 | - let mut a = LoudDump::append_unknown("T", "/dev/full"); | |
| 387 | - a.write(b"x"); | |
| 388 | - a.finish(); | |
| 389 | - }); | |
| 390 | - assert!(msg.contains("of an unknown number of bytes"), "{msg}"); | |
| 391 | - let _ = std::fs::remove_file(&p); | |
| 392 | - } | |
| 393 | - /// THE reproduction of the incident this module exists for: a real decode, | |
| 394 | - /// a real `RLIMIT_FSIZE`, a real truncated `EC_AV1_FINAL_DUMP` file left | |
| 395 | - /// on disk -- and the run stopping with the bytes-vs-bytes line instead of | |
| 396 | - /// carrying on to a measurement built on the fragment. | |
| 397 | - /// | |
| 398 | - /// `/dev/full` (the unit test above) proves the writer's check works but | |
| 399 | - /// never leaves a partial file behind, because `create` on it succeeds and | |
| 400 | - /// nothing is ever stored. `RLIMIT_FSIZE` is the shape | |
| 401 | - /// `lanes/unwritten-dep.report.md` actually measured: frames 0..4 complete | |
| 402 | - /// plus 13 320 192 bytes of frame 5. `SIGXFSZ` is IGNORED (`trap "" XFSZ`) | |
| 403 | - /// so the limit surfaces as `write`'s `EFBIG` -- exactly what a full | |
| 404 | - /// filesystem's `ENOSPC` does -- instead of killing the child outright. | |
| 405 | - #[test] | |
| 406 | - #[cfg(unix)] | |
| 407 | - fn a_real_decode_under_a_file_size_cap_fails_loudly() { | |
| 408 | - let dir = std::env::temp_dir().join(format!("ec-av1-dumpio-cap-{}", std::process::id())); | |
| 409 | - let _ = std::fs::remove_dir_all(&dir); | |
| 410 | - std::fs::create_dir_all(&dir).unwrap(); | |
| 411 | - let prefix = dir.join("ours"); | |
| 412 | - // 8 blocks of 512 B = 4096 B: far below one 256x128 4:2:0 8-bit frame | |
| 413 | - // (49 152 B), far above the file header, so the write lands and fails | |
| 414 | - // PART way rather than at create. | |
| 415 | - let out = Command::new("bash") | |
| 416 | - .args([ | |
| 417 | - "-c", | |
| 418 | - "ulimit -f 8; trap \"\" XFSZ; exec \"$0\" \"$@\"", | |
| 419 | - // $0 for `bash -c` is the test binary itself. | |
| 420 | - std::env::current_exe().unwrap().to_str().unwrap(), | |
| 421 | - "--exact", | |
| 422 | - "dumpio::tests::dumpio_child_decode", | |
| 423 | - "--nocapture", | |
| 424 | - ]) | |
| 425 | - .env("EC_AV1_DUMPLOUD_CHILD", "1") | |
| 426 | - .env("EC_AV1_FINAL_DUMP", &prefix) | |
| 427 | - // One thread, so the dump panic lands on the main thread and the | |
| 428 | - // child's exit status is the decode's own. | |
| 429 | - .env("EC_AV1_THREADS", "1") | |
| 430 | - .output() | |
| 431 | - .expect("spawning the capped child"); | |
| 432 | - let stderr = String::from_utf8_lossy(&out.stderr); | |
| 433 | - assert!( | |
| 434 | - !out.status.success(), | |
| 435 | - "the decode must FAIL under a file-size cap, not finish with a truncated dump\n{stderr}" | |
| 436 | - ); | |
| 437 | - assert!( | |
| 438 | - stderr.contains("ec-av1 dump FAILED [EC_AV1_FINAL_DUMP]"), | |
| 439 | - "the failure line must name the dump site\n{stderr}" | |
| 440 | - ); | |
| 441 | - assert!( | |
| 442 | - stderr.contains("File too large"), | |
| 443 | - "the failure line must carry the OS error\n{stderr}" | |
| 444 | - ); | |
| 445 | - // One 256x128 4:2:0 8-bit frame is 256*128*3/2 = 49 152 B, and the | |
| 446 | - // failure line's "wrote N of 49152" must name the file's REAL length, | |
| 447 | - // not the count `write_all` managed to acknowledge: a line that | |
| 448 | - // under-reports is a line that sends the reader back to the dump to | |
| 449 | - // measure it themselves. | |
| 450 | - let frag = std::fs::metadata(format!("{}.f0", prefix.display())) | |
| 451 | - .unwrap() | |
| 452 | - .len(); | |
| 453 | - assert!( | |
| 454 | - frag < 49152, | |
| 455 | - "the capped child left a {frag}-byte frame where 49152 B was owed" | |
| 456 | - ); | |
| 457 | - assert!( | |
| 458 | - stderr.contains(&format!("wrote {frag} of 49152 bytes")), | |
| 459 | - "the failure line's written count must be the file's actual length ({frag})\n{stderr}" | |
| 460 | - ); | |
| 461 | - let _ = std::fs::remove_dir_all(&dir); | |
| 462 | - } | |
| 463 | - | |
| 464 | - /// Child half of [`a_real_decode_under_a_file_size_cap_fails_loudly`]. It is | |
| 465 | - /// not a gate: with no `EC_AV1_DUMPLOUD_CHILD` guard it decodes nothing and | |
| 466 | - /// asserts nothing, so a plain `cargo test` run is unaffected. | |
| 467 | - #[test] | |
| 468 | - fn dumpio_child_decode() { | |
| 469 | - if std::env::var("EC_AV1_DUMPLOUD_CHILD").is_err() { | |
| 470 | - return; | |
| 471 | - } | |
| 472 | - let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 473 | - .join("fixtures/420_mixll_256x128_6f.obu"); | |
| 474 | - let bytes = std::fs::read(&path).expect("the pinned fixture"); | |
| 475 | - let _ = crate::stream::decode_stream(&bytes); | |
| 476 | - } | |
| 477 | - | |
| 478 | - #[test] | |
| 479 | - fn pin_success_path_is_byte_identical() { | |
| 480 | - let p = scratch("pin-ok"); | |
| 481 | - pin("TEST_PIN", &p, b"stream bytes"); | |
| 482 | - assert_eq!(std::fs::read(&p).unwrap(), b"stream bytes"); | |
| 483 | - let _ = std::fs::remove_file(&p); | |
| 484 | - } | |
| 485 | - | |
| 486 | - #[test] | |
| 487 | - #[cfg(unix)] | |
| 488 | - fn pin_to_a_full_device_is_loud() { | |
| 489 | - let msg = caught(|| pin("TEST_PIN", "/dev/full", b"stream bytes")); | |
| 490 | - assert!( | |
| 491 | - msg.starts_with("ec-av1 dump FAILED [TEST_PIN] /dev/full: wrote "), | |
| 492 | - "{msg}" | |
| 493 | - ); | |
| 494 | - assert!(msg.contains("No space left on device"), "{msg}"); | |
| 495 | - assert!(msg.contains(" of 12 bytes"), "{msg}"); | |
| 496 | - } | |
| 497 | - | |
| 498 | - /// The reporting shape: same failure line, returned instead of panicked, | |
| 499 | - /// so a gate whose real failure is the assert after the pin keeps that | |
| 500 | - /// assert -- but the reader still learns the pin is short. | |
| 501 | - #[test] | |
| 502 | - #[cfg(unix)] | |
| 503 | - fn pin_reporting_is_loud_but_not_fatal() { | |
| 504 | - let line = pin_reporting("TEST_PIN", "/dev/full", b"stream bytes").unwrap_err(); | |
| 505 | - assert!( | |
| 506 | - line.contains("ec-av1 dump FAILED [TEST_PIN] /dev/full"), | |
| 507 | - "{line}" | |
| 508 | - ); | |
| 509 | - assert!(line.contains(" of 12 bytes"), "{line}"); | |
| 510 | - let p = scratch("pin-reporting-ok"); | |
| 511 | - pin_reporting("TEST_PIN", &p, b"stream bytes").expect("a healthy pin reports nothing"); | |
| 512 | - assert_eq!(std::fs::read(&p).unwrap(), b"stream bytes"); | |
| 513 | - let _ = std::fs::remove_file(&p); | |
| 514 | - } | |
| 515 | - | |
| 516 | - /// The pin path's own reproduction: a real `RLIMIT_FSIZE` leaves a real | |
| 517 | - /// truncated stream at the path the panic names. Without the check the | |
| 518 | - /// reader replays the fragment and blames the decoder. | |
| 519 | - #[test] | |
| 520 | - #[cfg(unix)] | |
| 521 | - fn a_pin_under_a_file_size_cap_fails_loudly() { | |
| 522 | - let dir = std::env::temp_dir().join(format!("ec-av1-pin-cap-{}", std::process::id())); | |
| 523 | - let _ = std::fs::remove_dir_all(&dir); | |
| 524 | - std::fs::create_dir_all(&dir).unwrap(); | |
| 525 | - let out = Command::new("bash") | |
| 526 | - .args([ | |
| 527 | - "-c", | |
| 528 | - "ulimit -f 8; trap \"\" XFSZ; exec \"$0\" \"$@\"", | |
| 529 | - std::env::current_exe().unwrap().to_str().unwrap(), | |
| 530 | - "--exact", | |
| 531 | - "dumpio::tests::pin_child_under_cap", | |
| 532 | - "--nocapture", | |
| 533 | - ]) | |
| 534 | - .env("EC_AV1_PINLOUD_CHILD", &dir) | |
| 535 | - .output() | |
| 536 | - .expect("spawning the capped child"); | |
| 537 | - let stderr = String::from_utf8_lossy(&out.stderr); | |
| 538 | - assert!(!out.status.success(), "a short pin must fail\n{stderr}"); | |
| 539 | - assert!(stderr.contains("ec-av1 dump FAILED [TEST_PIN]"), "{stderr}"); | |
| 540 | - assert!(stderr.contains("File too large"), "{stderr}"); | |
| 541 | - let frag = std::fs::metadata(dir.join("cap-pinned.obu")).unwrap().len(); | |
| 542 | - assert!( | |
| 543 | - frag < 32768, | |
| 544 | - "the capped child left {frag} bytes where 32768 B was owed" | |
| 545 | - ); | |
| 546 | - assert!( | |
| 547 | - stderr.contains(&format!("wrote {frag} of 32768 bytes")), | |
| 548 | - "{stderr}" | |
| 549 | - ); | |
| 550 | - let _ = std::fs::remove_dir_all(&dir); | |
| 551 | - } | |
| 552 | - | |
| 553 | - /// Child half of [`a_pin_under_a_file_size_cap_fails_loudly`]. Not a gate: | |
| 554 | - /// with no `EC_AV1_PINLOUD_CHILD` set it writes nothing and asserts nothing. | |
| 555 | - #[test] | |
| 556 | - fn pin_child_under_cap() { | |
| 557 | - let Ok(dir) = std::env::var("EC_AV1_PINLOUD_CHILD") else { | |
| 558 | - return; | |
| 559 | - }; | |
| 560 | - // `ulimit -f 8` is 8 KiB, so 4x that is guaranteed to run PAST the cap | |
| 561 | - // (a write of exactly the cap size succeeds) and land a fragment. | |
| 562 | - pin( | |
| 563 | - "TEST_PIN", | |
| 564 | - Path::new(&dir).join("cap-pinned.obu"), | |
| 565 | - &[7u8; 32768], | |
| 566 | - ); | |
| 567 | - } | |
| 568 | -} |
crates/ec-av1/src/encode/coef.rsmodified+40 -31
| @@ -962,7 +962,13 @@ impl Plane<'_> { | ||
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | /// Puts a snapshot back. |
| 965 | - pub(super) fn restore(&mut self, x: usize, y: usize, side: usize, saved: &(Vec<u8>, Vec<CoefCtx>)) { | |
| 965 | + pub(super) fn restore( | |
| 966 | + &mut self, | |
| 967 | + x: usize, | |
| 968 | + y: usize, | |
| 969 | + side: usize, | |
| 970 | + saved: &(Vec<u8>, Vec<CoefCtx>), | |
| 971 | + ) { | |
| 966 | 972 | for row in 0..side { |
| 967 | 973 | self.reconstruction[(y + row) * self.width + x..][..side] |
| 968 | 974 | .copy_from_slice(&saved.0[row * side..][..side]); |
| @@ -1080,19 +1086,20 @@ impl Plane<'_> { | ||
| 1080 | 1086 | }) |
| 1081 | 1087 | .collect(); |
| 1082 | 1088 | if let Some(k) = search.top_k |
| 1083 | - && k < scored.len() { | |
| 1084 | - let dc_pos = scored.iter().position(|&(_, mode, _)| mode == DC_PRED); | |
| 1085 | - let dc_entry = dc_pos.map(|i| scored.remove(i)); | |
| 1086 | - scored.sort_by(|a, b| a.0.partial_cmp(&b.0).expect("scores are finite")); | |
| 1087 | - scored.truncate(if dc_entry.is_some() { | |
| 1088 | - k.saturating_sub(1) | |
| 1089 | - } else { | |
| 1090 | - k | |
| 1091 | - }); | |
| 1092 | - if let Some(dc_entry) = dc_entry { | |
| 1093 | - scored.push(dc_entry); | |
| 1094 | - } | |
| 1089 | + && k < scored.len() | |
| 1090 | + { | |
| 1091 | + let dc_pos = scored.iter().position(|&(_, mode, _)| mode == DC_PRED); | |
| 1092 | + let dc_entry = dc_pos.map(|i| scored.remove(i)); | |
| 1093 | + scored.sort_by(|a, b| a.0.partial_cmp(&b.0).expect("scores are finite")); | |
| 1094 | + scored.truncate(if dc_entry.is_some() { | |
| 1095 | + k.saturating_sub(1) | |
| 1096 | + } else { | |
| 1097 | + k | |
| 1098 | + }); | |
| 1099 | + if let Some(dc_entry) = dc_entry { | |
| 1100 | + scored.push(dc_entry); | |
| 1095 | 1101 | } |
| 1102 | + } | |
| 1096 | 1103 | let ranking: Vec<(f64, u8)> = if census_on() { |
| 1097 | 1104 | scored |
| 1098 | 1105 | .iter() |
| @@ -1179,8 +1186,6 @@ impl Plane<'_> { | ||
| 1179 | 1186 | trial = candidate; |
| 1180 | 1187 | } |
| 1181 | 1188 | } |
| 1182 | - ANGLE_DELTA_HITS[(crate::tile::ANGLE_DELTA_ZERO as i32 + angle_delta) as usize] | |
| 1183 | - .fetch_add(1, std::sync::atomic::Ordering::Relaxed); | |
| 1184 | 1189 | } |
| 1185 | 1190 | // lane-txset: the block's own transform type, searched on the mode |
| 1186 | 1191 | // and angle the trials above settled -- the same ordering the angle |
| @@ -1405,7 +1410,8 @@ pub(super) const HAS_TR_8X16: [u8; 16] = [ | ||
| 1405 | 1410 | /// `has_bl_8x16` (`reconintra.c`), transcribed verbatim: 16 bytes, row stride 16 bits (`128 / 8`). |
| 1406 | 1411 | pub(super) const HAS_BL_8X16: [u8; 16] = [16, 17, 0, 1, 16, 17, 0, 0, 16, 17, 0, 1, 16, 17, 0, 0]; |
| 1407 | 1412 | /// `has_tr_16x8` (`reconintra.c`), transcribed verbatim: 16 bytes, row stride 8 bits (`128 / 16`). |
| 1408 | -pub(super) const HAS_TR_16X8: [u8; 16] = [255, 0, 85, 0, 119, 0, 85, 0, 127, 0, 85, 0, 119, 0, 85, 0]; | |
| 1413 | +pub(super) const HAS_TR_16X8: [u8; 16] = | |
| 1414 | + [255, 0, 85, 0, 119, 0, 85, 0, 127, 0, 85, 0, 119, 0, 85, 0]; | |
| 1409 | 1415 | /// `has_bl_16x8` (`reconintra.c`), transcribed verbatim: 16 bytes, row stride 8 bits (`128 / 16`). |
| 1410 | 1416 | pub(super) const HAS_BL_16X8: [u8; 16] = [ |
| 1411 | 1417 | 254, 84, 254, 16, 254, 84, 254, 0, 254, 84, 254, 16, 254, 84, 254, 0, |
| @@ -1785,18 +1791,6 @@ impl Reach { | ||
| 1785 | 1791 | Self::bit(table, Self::rect_table_index(bw_log2, blk_row, blk_col)) |
| 1786 | 1792 | } |
| 1787 | 1793 | |
| 1788 | - /// Marks every [`Reach::of`] made until the returned guard drops as being | |
| 1789 | - /// inside a `PARTITION_VERT_A`/`_B` (libaom's `get_has_tr_table` / | |
| 1790 | - /// `get_has_bl_table` partition argument). Rectangular sub-blocks are | |
| 1791 | - /// unaffected: libaom's own comment says vertical rectangles keep their | |
| 1792 | - /// non-vert table, which is what [`Reach::of_rect`] already reads. | |
| 1793 | - /// Whether a `PARTITION_VERT_A`/`_B`'s sub-blocks are being decoded | |
| 1794 | - /// right now ([`Self::vert_ab_partition`]'s guard is alive), so a caller | |
| 1795 | - /// can count the sub-block work that partition creates (lane-ab16). | |
| 1796 | - pub(crate) fn in_vert_ab() -> bool { | |
| 1797 | - VERT_AB_PARTITION.with(std::cell::Cell::get) | |
| 1798 | - } | |
| 1799 | - | |
| 1800 | 1794 | pub(crate) fn vert_ab_partition() -> VertAbGuard { |
| 1801 | 1795 | VertAbGuard(VERT_AB_PARTITION.with(|c| c.replace(true))) |
| 1802 | 1796 | } |
| @@ -1814,7 +1808,12 @@ impl Reach { | ||
| 1814 | 1808 | /// row of a superblock reads into the superblock above, which is decoded; |
| 1815 | 1809 | /// the rightmost column would read into the superblock to the right, which |
| 1816 | 1810 | /// is not; and everything between is the table's to answer. |
| 1817 | - pub(super) fn top_right(side: usize, x: usize, y: usize, fctx: &crate::decode::FrameCtx) -> bool { | |
| 1811 | + pub(super) fn top_right( | |
| 1812 | + side: usize, | |
| 1813 | + x: usize, | |
| 1814 | + y: usize, | |
| 1815 | + fctx: &crate::decode::FrameCtx, | |
| 1816 | + ) -> bool { | |
| 1818 | 1817 | let (row, col, per_side) = Self::position(side, x, y, fctx); |
| 1819 | 1818 | if row == 0 { |
| 1820 | 1819 | return true; |
| @@ -1851,7 +1850,12 @@ impl Reach { | ||
| 1851 | 1850 | /// reads into the superblock to its left, which is decoded only as far |
| 1852 | 1851 | /// down as its own bottom; the bottom row would read into the superblock |
| 1853 | 1852 | /// below, which is not decoded at all; and the table answers the rest. |
| 1854 | - pub(super) fn bottom_left(side: usize, x: usize, y: usize, fctx: &crate::decode::FrameCtx) -> bool { | |
| 1853 | + pub(super) fn bottom_left( | |
| 1854 | + side: usize, | |
| 1855 | + x: usize, | |
| 1856 | + y: usize, | |
| 1857 | + fctx: &crate::decode::FrameCtx, | |
| 1858 | + ) -> bool { | |
| 1855 | 1859 | let (row, col, per_side) = Self::position(side, x, y, fctx); |
| 1856 | 1860 | if col == 0 { |
| 1857 | 1861 | return row * side + side < reach_sb_px(fctx); |
| @@ -2032,7 +2036,12 @@ pub(super) fn obmc_min_side() -> usize { | ||
| 2032 | 2036 | /// 2-symbol `obmc` one. Both sides of every motion-mode comparison in the |
| 2033 | 2037 | /// search pay it, so the alphabet cancels out of a comparison and only its |
| 2034 | 2038 | /// per-value spread decides. |
| 2035 | -pub(super) fn motion_mode_bits(write_w: usize, write_h: usize, motion: u8, warp_alphabet: bool) -> f64 { | |
| 2039 | +pub(super) fn motion_mode_bits( | |
| 2040 | + write_w: usize, | |
| 2041 | + write_h: usize, | |
| 2042 | + motion: u8, | |
| 2043 | + warp_alphabet: bool, | |
| 2044 | +) -> f64 { | |
| 2036 | 2045 | let Some(row) = crate::decode::motion_mode_cdf_row(write_w, write_h) else { |
| 2037 | 2046 | return 0.0; |
| 2038 | 2047 | }; |
crates/ec-av1/src/encode/frame.rsmodified+50 -37
| @@ -52,7 +52,8 @@ pub(super) fn deltaq_res_log2() -> Option<u8> { | ||
| 52 | 52 | /// sets it holds [`crate::speed::knob_write`], the same exclusive lock the |
| 53 | 53 | /// speed presets take, because the streams every other test pins move under |
| 54 | 54 | /// it (the shipped default is OFF, see [`crate::speed::DELTAQ_RES`]). |
| 55 | -pub(super) static DELTAQ_OVERRIDE: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(u8::MAX); | |
| 55 | +pub(super) static DELTAQ_OVERRIDE: std::sync::atomic::AtomicU8 = | |
| 56 | + std::sync::atomic::AtomicU8::new(u8::MAX); | |
| 56 | 57 | |
| 57 | 58 | /// Sets [`DELTAQ_OVERRIDE`]; `None` clears it. |
| 58 | 59 | #[allow(dead_code)] // set only from the `#[cfg(test)]` gates |
| @@ -270,13 +271,8 @@ pub(super) fn dq_summary(offsets: &[i32]) -> String { | ||
| 270 | 271 | /// grid that is one flat value, i.e. on no delta_q at all). Process-global |
| 271 | 272 | /// like [`TX_DEPTH_HITS`], and read through [`take_deltaq_levels`], which |
| 272 | 273 | /// keeps the LARGEST count seen since the last read. |
| 273 | -pub(super) static DELTAQ_LEVELS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | |
| 274 | - | |
| 275 | -/// [`DELTAQ_LEVELS`], reset to 0. | |
| 276 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 277 | -pub(crate) fn take_deltaq_levels() -> usize { | |
| 278 | - DELTAQ_LEVELS.swap(0, std::sync::atomic::Ordering::Relaxed) | |
| 279 | -} | |
| 274 | +pub(super) static DELTAQ_LEVELS: std::sync::atomic::AtomicUsize = | |
| 275 | + std::sync::atomic::AtomicUsize::new(0); | |
| 280 | 276 | |
| 281 | 277 | /// This superblock's search state: the quantizer it is coded at, and the |
| 282 | 278 | /// lambda that quantizer implies. RD lambda goes as the square of the step, |
| @@ -404,7 +400,12 @@ pub(super) static TPL_NANOS: std::sync::atomic::AtomicU64 = std::sync::atomic::A | ||
| 404 | 400 | /// the left/above winners, first-best tie-break. Built once on the frame's |
| 405 | 401 | /// own thread and read-only afterwards, so it cannot make a tile's bytes |
| 406 | 402 | /// depend on the thread count. |
| 407 | -pub(super) fn tpl_coarse_pass(cur: &[u8], next: &[u8], width: usize, height: usize) -> Vec<((i32, i32), u32)> { | |
| 403 | +pub(super) fn tpl_coarse_pass( | |
| 404 | + cur: &[u8], | |
| 405 | + next: &[u8], | |
| 406 | + width: usize, | |
| 407 | + height: usize, | |
| 408 | +) -> Vec<((i32, i32), u32)> { | |
| 408 | 409 | let (cells_x, cells_y) = (width / 16, height / 16); |
| 409 | 410 | let sad = |bx: usize, by: usize, (mx, my): (i32, i32)| -> u32 { |
| 410 | 411 | let (sx, sy) = (bx as i32 + mx, by as i32 + my); |
| @@ -823,10 +824,11 @@ pub(crate) fn arf_temporal_filter(src: &Picture, window: &[Picture], strength: f | ||
| 823 | 824 | ] { |
| 824 | 825 | let mv = (from.0 + dy * step, from.1 + dx * step); |
| 825 | 826 | if let Some(s) = sad(r, bx, by, mv) |
| 826 | - && s.0 < best.0 { | |
| 827 | - best = s; | |
| 828 | - centre = mv; | |
| 829 | - } | |
| 827 | + && s.0 < best.0 | |
| 828 | + { | |
| 829 | + best = s; | |
| 830 | + centre = mv; | |
| 831 | + } | |
| 830 | 832 | } |
| 831 | 833 | step /= 2; |
| 832 | 834 | } |
| @@ -1288,28 +1290,29 @@ pub(crate) fn encode_inter_frame( | ||
| 1288 | 1290 | // the frame codes any delta syntax (`deltaq_res` is `None` with the lever |
| 1289 | 1291 | // off, and the census then prices the default `res = 4` grid). |
| 1290 | 1292 | if dq_census() |
| 1291 | - && let Some(f) = &tpl_factors { | |
| 1292 | - let res = deltaq_res.unwrap_or(4); | |
| 1293 | - let off = |libaom: Option<f64>| -> Vec<i32> { | |
| 1294 | - (0..sb_cols * _sb_rows) | |
| 1295 | - .map(|sb| i32::from(sb_qindex(f, res, sb, libaom)) - i32::from(base_q_idx)) | |
| 1296 | - .collect() | |
| 1297 | - }; | |
| 1298 | - let strength = dq_tpl_strength(dq_level); | |
| 1299 | - let (ours, aom) = (off(None), off(Some(strength.unwrap_or(1.0)))); | |
| 1300 | - let coded = match (deltaq_res.is_some(), strength) { | |
| 1301 | - (false, _) => "none".to_string(), | |
| 1302 | - (true, None) => "ours".to_string(), | |
| 1303 | - (true, Some(k)) => format!("libaom k={k}"), | |
| 1304 | - }; | |
| 1305 | - eprintln!( | |
| 1306 | - "dq census: level={dq_level:?} base={base_q_idx} res={res} sbs={} coded={coded} r_frame={:.4}\n ours {}\n libaom {}", | |
| 1307 | - sb_cols * _sb_rows, | |
| 1308 | - r_frame.unwrap_or(f64::NAN), | |
| 1309 | - dq_summary(&ours), | |
| 1310 | - dq_summary(&aom), | |
| 1311 | - ); | |
| 1312 | - } | |
| 1293 | + && let Some(f) = &tpl_factors | |
| 1294 | + { | |
| 1295 | + let res = deltaq_res.unwrap_or(4); | |
| 1296 | + let off = |libaom: Option<f64>| -> Vec<i32> { | |
| 1297 | + (0..sb_cols * _sb_rows) | |
| 1298 | + .map(|sb| i32::from(sb_qindex(f, res, sb, libaom)) - i32::from(base_q_idx)) | |
| 1299 | + .collect() | |
| 1300 | + }; | |
| 1301 | + let strength = dq_tpl_strength(dq_level); | |
| 1302 | + let (ours, aom) = (off(None), off(Some(strength.unwrap_or(1.0)))); | |
| 1303 | + let coded = match (deltaq_res.is_some(), strength) { | |
| 1304 | + (false, _) => "none".to_string(), | |
| 1305 | + (true, None) => "ours".to_string(), | |
| 1306 | + (true, Some(k)) => format!("libaom k={k}"), | |
| 1307 | + }; | |
| 1308 | + eprintln!( | |
| 1309 | + "dq census: level={dq_level:?} base={base_q_idx} res={res} sbs={} coded={coded} r_frame={:.4}\n ours {}\n libaom {}", | |
| 1310 | + sb_cols * _sb_rows, | |
| 1311 | + r_frame.unwrap_or(f64::NAN), | |
| 1312 | + dq_summary(&ours), | |
| 1313 | + dq_summary(&aom), | |
| 1314 | + ); | |
| 1315 | + } | |
| 1313 | 1316 | if let Some(res) = deltaq_res.filter(|_| sb_q.is_some()) { |
| 1314 | 1317 | header.delta.q_present = true; |
| 1315 | 1318 | header.delta.q_res = res.trailing_zeros() as u8; |
| @@ -2332,9 +2335,19 @@ pub(crate) fn encode_inter_frame( | ||
| 2332 | 2335 | // rectangles partition the frame, so the order does not change the bytes). |
| 2333 | 2336 | let mut searched_blocks = Vec::new(); |
| 2334 | 2337 | for (tile_blocks, pixels) in search_tiles(layout.count(), fctx, search_tile)? { |
| 2335 | - put_rect(&mut luma.reconstruction, frame_width, pixels.luma_rect, &pixels.luma); | |
| 2338 | + put_rect( | |
| 2339 | + &mut luma.reconstruction, | |
| 2340 | + frame_width, | |
| 2341 | + pixels.luma_rect, | |
| 2342 | + &pixels.luma, | |
| 2343 | + ); | |
| 2336 | 2344 | for (plane, bytes) in chroma.iter_mut().zip(&pixels.chroma) { |
| 2337 | - put_rect(&mut plane.reconstruction, frame_width / 2, pixels.chroma_rect, bytes); | |
| 2345 | + put_rect( | |
| 2346 | + &mut plane.reconstruction, | |
| 2347 | + frame_width / 2, | |
| 2348 | + pixels.chroma_rect, | |
| 2349 | + bytes, | |
| 2350 | + ); | |
| 2338 | 2351 | } |
| 2339 | 2352 | searched_blocks.push(tile_blocks); |
| 2340 | 2353 | } |
crates/ec-av1/src/encode/inter_search.rsmodified+44 -39
| @@ -212,7 +212,8 @@ pub(super) fn arfmode() -> u8 { | ||
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /// [`ARFMODE_OVERRIDE`]: `u8::MAX` clears it. |
| 215 | -pub(super) static ARFMODE_OVERRIDE: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(u8::MAX); | |
| 215 | +pub(super) static ARFMODE_OVERRIDE: std::sync::atomic::AtomicU8 = | |
| 216 | + std::sync::atomic::AtomicU8::new(u8::MAX); | |
| 216 | 217 | |
| 217 | 218 | /// Sets [`ARFMODE_OVERRIDE`]; `None` clears it. Test-only: the env is a |
| 218 | 219 | /// process constant ([`crate::envflags`]), so an in-process witness needs |
| @@ -279,11 +280,6 @@ thread_local! { | ||
| 279 | 280 | const { std::cell::Cell::new(None) }; |
| 280 | 281 | } |
| 281 | 282 | |
| 282 | -#[cfg(test)] | |
| 283 | -pub(super) fn set_test_top_k_override(value: Option<usize>) { | |
| 284 | - TEST_TOP_K_OVERRIDE.with(|cell| cell.set(Some(value))); | |
| 285 | -} | |
| 286 | - | |
| 287 | 283 | /// The default: unpruned, thirteen full trials per block, same as before this |
| 288 | 284 | /// lever. Set from the sweep in the lane report if the quality gate clears it. |
| 289 | 285 | pub(crate) const PRUNE_TOP_K: Option<usize> = None; |
| @@ -317,11 +313,6 @@ thread_local! { | ||
| 317 | 313 | const { std::cell::Cell::new(None) }; |
| 318 | 314 | } |
| 319 | 315 | |
| 320 | -#[cfg(test)] | |
| 321 | -pub(super) fn set_test_top_k_override_inter(value: Option<usize>) { | |
| 322 | - TEST_TOP_K_OVERRIDE_INTER.with(|cell| cell.set(Some(value))); | |
| 323 | -} | |
| 324 | - | |
| 325 | 316 | /// The inter path's default `top_k`: `Some(3)`, from `prune_k_quality_sweep_inter` |
| 326 | 317 | /// (three real clips, q 60 and 150) -- every `K` in {3, 4, 6} cleared the |
| 327 | 318 | /// same rule the key-frame lever uses (every PSNR delta <0.05dB, bytes |
| @@ -374,21 +365,6 @@ pub(crate) fn stage_add(bucket: usize, dur: std::time::Duration) { | ||
| 374 | 365 | STAGE_NS.with(|c| c[bucket].set(c[bucket].get() + dur.as_nanos() as u64)); |
| 375 | 366 | } |
| 376 | 367 | |
| 377 | -#[cfg(test)] | |
| 378 | -pub(super) fn stage_reset() { | |
| 379 | - crate::par::set_stage_times(true); | |
| 380 | - STAGE_NS.with(|c| c.iter().for_each(|cell| cell.set(0))); | |
| 381 | -} | |
| 382 | - | |
| 383 | -#[cfg(test)] | |
| 384 | -pub(super) fn stage_read() -> [std::time::Duration; 4] { | |
| 385 | - crate::par::set_stage_times(false); | |
| 386 | - STAGE_NS.with(|c| { | |
| 387 | - c.each_ref() | |
| 388 | - .map(|cell| std::time::Duration::from_nanos(cell.get())) | |
| 389 | - }) | |
| 390 | -} | |
| 391 | - | |
| 392 | 368 | /// One mode's coding of one block, before it is committed. |
| 393 | 369 | #[derive(Clone)] |
| 394 | 370 | pub(super) struct Trial { |
| @@ -526,7 +502,11 @@ where | ||
| 526 | 502 | /// The `FrameCtx` copy is made on the calling thread (`&FrameCtx` is `!Sync` |
| 527 | 503 | /// by design) and moved into the worker, exactly as the decoder's filter bands |
| 528 | 504 | /// do it through [`crate::par::scope`]. |
| 529 | -pub(super) fn search_tiles<T, F>(tiles: usize, fctx: &crate::decode::FrameCtx, job: F) -> Result<Vec<T>> | |
| 505 | +pub(super) fn search_tiles<T, F>( | |
| 506 | + tiles: usize, | |
| 507 | + fctx: &crate::decode::FrameCtx, | |
| 508 | + job: F, | |
| 509 | +) -> Result<Vec<T>> | |
| 530 | 510 | where |
| 531 | 511 | T: Send, |
| 532 | 512 | F: Fn(usize, &crate::decode::FrameCtx) -> Result<T> + Sync, |
| @@ -600,7 +580,11 @@ pub(super) struct TilePixels { | ||
| 600 | 580 | |
| 601 | 581 | /// The rectangle `[x0, x1) x [y0, y1)` of a plane with `stride`, copied out as |
| 602 | 582 | /// its rows back to back. |
| 603 | -pub(super) fn take_rect(plane: &[u8], stride: usize, (x0, y0, x1, y1): (usize, usize, usize, usize)) -> Vec<u8> { | |
| 583 | +pub(super) fn take_rect( | |
| 584 | + plane: &[u8], | |
| 585 | + stride: usize, | |
| 586 | + (x0, y0, x1, y1): (usize, usize, usize, usize), | |
| 587 | +) -> Vec<u8> { | |
| 604 | 588 | let mut out = Vec::with_capacity((x1 - x0) * (y1 - y0)); |
| 605 | 589 | for y in y0..y1 { |
| 606 | 590 | out.extend_from_slice(&plane[y * stride + x0..y * stride + x1]); |
| @@ -610,7 +594,12 @@ pub(super) fn take_rect(plane: &[u8], stride: usize, (x0, y0, x1, y1): (usize, u | ||
| 610 | 594 | |
| 611 | 595 | /// The inverse of [`take_rect`]: writes `rows` (as `take_rect` produced them) |
| 612 | 596 | /// back into the rectangle of `plane`. |
| 613 | -pub(super) fn put_rect(plane: &mut [u8], stride: usize, (x0, y0, x1, y1): (usize, usize, usize, usize), rows: &[u8]) { | |
| 597 | +pub(super) fn put_rect( | |
| 598 | + plane: &mut [u8], | |
| 599 | + stride: usize, | |
| 600 | + (x0, y0, x1, y1): (usize, usize, usize, usize), | |
| 601 | + rows: &[u8], | |
| 602 | +) { | |
| 614 | 603 | let w = x1 - x0; |
| 615 | 604 | for (row, y) in (y0..y1).enumerate() { |
| 616 | 605 | plane[y * stride + x0..y * stride + x1].copy_from_slice(&rows[row * w..(row + 1) * w]); |
| @@ -622,7 +611,10 @@ pub(super) fn put_rect(plane: &mut [u8], stride: usize, (x0, y0, x1, y1): (usize | ||
| 622 | 611 | /// tables the frame stores (spec 7.20), which is what |
| 623 | 612 | /// [`crate::tile::TileLayout::largest_tile`] picks and what the tile loops |
| 624 | 613 | /// below publish. |
| 625 | -pub(super) fn tile_info_of(layout: &crate::tile::TileLayout, tile_size_bytes: u32) -> ec_av1_syntax::TileInfo { | |
| 614 | +pub(super) fn tile_info_of( | |
| 615 | + layout: &crate::tile::TileLayout, | |
| 616 | + tile_size_bytes: u32, | |
| 617 | +) -> ec_av1_syntax::TileInfo { | |
| 626 | 618 | ec_av1_syntax::TileInfo { |
| 627 | 619 | uniform_spacing: true, |
| 628 | 620 | cols: layout.cols(), |
| @@ -1380,9 +1372,19 @@ pub(crate) fn encode_key_frame_inner( | ||
| 1380 | 1372 | let searched = search_tiles(layout.count(), fctx, search_tile)?; |
| 1381 | 1373 | let mut searched_coded = Vec::with_capacity(searched.len()); |
| 1382 | 1374 | for (coded, pixels) in searched { |
| 1383 | - put_rect(&mut luma.reconstruction, frame_width, pixels.luma_rect, &pixels.luma); | |
| 1375 | + put_rect( | |
| 1376 | + &mut luma.reconstruction, | |
| 1377 | + frame_width, | |
| 1378 | + pixels.luma_rect, | |
| 1379 | + &pixels.luma, | |
| 1380 | + ); | |
| 1384 | 1381 | for (plane, bytes) in chroma.iter_mut().zip(&pixels.chroma) { |
| 1385 | - put_rect(&mut plane.reconstruction, frame_width / 2, pixels.chroma_rect, bytes); | |
| 1382 | + put_rect( | |
| 1383 | + &mut plane.reconstruction, | |
| 1384 | + frame_width / 2, | |
| 1385 | + pixels.chroma_rect, | |
| 1386 | + bytes, | |
| 1387 | + ); | |
| 1386 | 1388 | } |
| 1387 | 1389 | searched_coded.push(coded); |
| 1388 | 1390 | } |
| @@ -2104,7 +2106,8 @@ pub(super) fn mv_residual_bits(mv: (i32, i32), pred: (i32, i32)) -> Option<f64> | ||
| 2104 | 2106 | /// always), the shape [`set_frame_interp`] has: the witness that has to see |
| 2105 | 2107 | /// `mv_hp` symbols coded turns it on through this while holding |
| 2106 | 2108 | /// [`crate::speed::knob_write`]. |
| 2107 | -pub(super) static HP_MV_OVERRIDE: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(u8::MAX); | |
| 2109 | +pub(super) static HP_MV_OVERRIDE: std::sync::atomic::AtomicU8 = | |
| 2110 | + std::sync::atomic::AtomicU8::new(u8::MAX); | |
| 2108 | 2111 | |
| 2109 | 2112 | /// Sets [`HP_MV_OVERRIDE`]; `None` clears it. |
| 2110 | 2113 | #[allow(dead_code)] // set only from the `#[cfg(test)]` gates |
| @@ -4448,9 +4451,10 @@ pub(super) fn search_inter_block( | ||
| 4448 | 4451 | planes, |
| 4449 | 4452 | (reference.width, reference.height), |
| 4450 | 4453 | fctx, |
| 4451 | - ) { | |
| 4452 | - candidates.push((1, pred)); | |
| 4453 | - } | |
| 4454 | + ) | |
| 4455 | + { | |
| 4456 | + candidates.push((1, pred)); | |
| 4457 | + } | |
| 4454 | 4458 | if warp_alphabet |
| 4455 | 4459 | && let Some(pred) = warp_prediction( |
| 4456 | 4460 | grid, |
| @@ -4462,9 +4466,10 @@ pub(super) fn search_inter_block( | ||
| 4462 | 4466 | info.ref_frame, |
| 4463 | 4467 | planes, |
| 4464 | 4468 | fctx, |
| 4465 | - ) { | |
| 4466 | - candidates.push((2, pred)); | |
| 4467 | - } | |
| 4469 | + ) | |
| 4470 | + { | |
| 4471 | + candidates.push((2, pred)); | |
| 4472 | + } | |
| 4468 | 4473 | for (motion, pred) in candidates { |
| 4469 | 4474 | let luma_trial = luma.code_from_prediction( |
| 4470 | 4475 | x, |
crates/ec-av1/src/encode/mod.rsmodified+0 -50
| @@ -821,12 +821,6 @@ fn rectres() -> bool { | ||
| 821 | 821 | static FORCE_B128_RECTRES: std::sync::atomic::AtomicBool = |
| 822 | 822 | std::sync::atomic::AtomicBool::new(false); |
| 823 | 823 | |
| 824 | -/// Arms [`FORCE_B128_RECTRES`] for the rest of the process. | |
| 825 | -#[cfg(test)] | |
| 826 | -pub(crate) fn force_b128_rectres(on: bool) { | |
| 827 | - FORCE_B128_RECTRES.store(on, std::sync::atomic::Ordering::Relaxed); | |
| 828 | -} | |
| 829 | - | |
| 830 | 824 | /// How many rect/AB pieces the search left WITH a residual rather than |
| 831 | 825 | /// skipped, since the last [`take_b128_rectres_hits`] (class |
| 832 | 826 | /// `gate-blind-to-feature`). |
| @@ -981,12 +975,6 @@ pub fn take_b128_vert_hits() -> usize { | ||
| 981 | 975 | /// RD there prefers one whole block; the gate census is the unforced count. |
| 982 | 976 | static FORCE_B128_RECT: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(0); |
| 983 | 977 | |
| 984 | -/// Arms [`FORCE_B128_RECT`] for the rest of the process (0 / 1 HORZ / 2 VERT). | |
| 985 | -#[cfg(test)] | |
| 986 | -pub(crate) fn force_b128_rect(which: u8) { | |
| 987 | - FORCE_B128_RECT.store(which, std::sync::atomic::Ordering::Relaxed); | |
| 988 | -} | |
| 989 | - | |
| 990 | 978 | /// lane-ab128: whether the 128 superblock root offers its four AB shapes -- |
| 991 | 979 | /// `PARTITION_HORZ_A` (two 64x64 on top, one 128x64 below), `_HORZ_B` (one |
| 992 | 980 | /// 128x64 on top, two 64x64 below), `_VERT_A` (two 64x64 left, one 64x128 |
| @@ -1029,12 +1017,6 @@ pub fn take_b128_ab_hits() -> [usize; 4] { | ||
| 1029 | 1017 | /// prefers one whole block). |
| 1030 | 1018 | static FORCE_B128_AB: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(0); |
| 1031 | 1019 | |
| 1032 | -/// Arms [`FORCE_B128_AB`] for the rest of the process (0 off, else 4..=7). | |
| 1033 | -#[cfg(test)] | |
| 1034 | -pub(crate) fn force_b128_ab(which: u8) { | |
| 1035 | - FORCE_B128_AB.store(which, std::sync::atomic::Ordering::Relaxed); | |
| 1036 | -} | |
| 1037 | - | |
| 1038 | 1020 | /// lane-ab128: the three pieces of an AB shape at a 128 root, in the order |
| 1039 | 1021 | /// libaom's `decode_partition` codes them and decode.rs' `sb128_ab` arm |
| 1040 | 1022 | /// reads them (decode.rs ~35269) -- HORZ_A = TL, TR, bottom half; HORZ_B = |
| @@ -1073,20 +1055,6 @@ static FORCE_B128_RESIDUAL: std::sync::atomic::AtomicBool = | ||
| 1073 | 1055 | /// for content on which the root also wins its own comparison. |
| 1074 | 1056 | static FORCE_B128_ROOT: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); |
| 1075 | 1057 | |
| 1076 | -/// Arms [`FORCE_B128_RESIDUAL`] -- and with it [`FORCE_B128_ROOT`], since a | |
| 1077 | -/// forced residual block only reaches the writer if its root is taken. | |
| 1078 | -#[cfg(test)] | |
| 1079 | -pub(crate) fn force_b128_residual(on: bool) { | |
| 1080 | - FORCE_B128_RESIDUAL.store(on, std::sync::atomic::Ordering::Relaxed); | |
| 1081 | - force_b128_root(on); | |
| 1082 | -} | |
| 1083 | - | |
| 1084 | -/// Arms [`FORCE_B128_ROOT`] for the rest of the process. | |
| 1085 | -#[cfg(test)] | |
| 1086 | -pub(crate) fn force_b128_root(on: bool) { | |
| 1087 | - FORCE_B128_ROOT.store(on, std::sync::atomic::Ordering::Relaxed); | |
| 1088 | -} | |
| 1089 | - | |
| 1090 | 1058 | /// How many 128 roots came out cheaper WITH a residual than skipped, since |
| 1091 | 1059 | /// the last [`take_b128_residual_hits`] (class `gate-blind-to-feature`). |
| 1092 | 1060 | static B128_RESIDUAL_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); |
| @@ -1475,12 +1443,6 @@ fn partition_hit(which: usize) { | ||
| 1475 | 1443 | PARTITION_HITS[which].fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 1476 | 1444 | } |
| 1477 | 1445 | |
| 1478 | -/// Takes (and clears) the counts. | |
| 1479 | -#[cfg(test)] | |
| 1480 | -pub(crate) fn take_partition_hits() -> [usize; 4] { | |
| 1481 | - [0, 1, 2, 3].map(|i| PARTITION_HITS[i].swap(0, std::sync::atomic::Ordering::Relaxed)) | |
| 1482 | -} | |
| 1483 | - | |
| 1484 | 1446 | /// Whether the trial-set census (`EC_AV1_CENSUS=1`) is on: how many full |
| 1485 | 1447 | /// rate-distortion trials the block search actually runs, by kind, and where |
| 1486 | 1448 | /// the winner sat in the cheap SAD ranking the pruning levers rank by. Off by |
| @@ -2002,12 +1964,6 @@ thread_local! { | ||
| 2002 | 1964 | static IBC_SHARE: std::cell::Cell<f64> = const { std::cell::Cell::new(0.0) }; |
| 2003 | 1965 | } |
| 2004 | 1966 | |
| 2005 | -/// [`IBC_SHARE`] for the last key frame encoded on this thread. | |
| 2006 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 2007 | -pub(crate) fn intrabc_source_share() -> f64 { | |
| 2008 | - IBC_SHARE.with(std::cell::Cell::get) | |
| 2009 | -} | |
| 2010 | - | |
| 2011 | 1967 | thread_local! { |
| 2012 | 1968 | /// This SEQUENCE's `seq_force_screen_content_tools`: whether the sequence |
| 2013 | 1969 | /// header offers the per-frame `allow_screen_content_tools` bit at all. |
| @@ -2043,12 +1999,6 @@ thread_local! { | ||
| 2043 | 1999 | const { std::cell::Cell::new(None) }; |
| 2044 | 2000 | } |
| 2045 | 2001 | |
| 2046 | -/// The pyramid the last sequence coded on this thread was EFFECTIVELY under. | |
| 2047 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 2048 | -pub(crate) fn last_sequence_pyramid() -> Option<crate::encoder::Pyramid> { | |
| 2049 | - LAST_SEQ_PYRAMID.with(std::cell::Cell::get) | |
| 2050 | -} | |
| 2051 | - | |
| 2052 | 2002 | #[cfg(test)] |
| 2053 | 2003 | pub(crate) fn force_screen(value: Option<bool>) { |
| 2054 | 2004 | SCREEN_FORCE.with(|c| c.set(value)); |
crates/ec-av1/src/encode/more_tests.rsmodified+546 -1231
| @@ -1,1260 +1,575 @@ | ||
| 1 | -use super::*; | |
| 2 | 1 | use super::tests::*; |
| 2 | +use super::*; | |
| 3 | 3 | |
| 4 | - | |
| 5 | - | |
| 6 | - /// lane-ab128: the 128 root's four AB shapes -- `PARTITION_HORZ_A` (two | |
| 7 | - /// 64x64 on top, one 128x64 below), `_HORZ_B`, `_VERT_A`, `_VERT_B`. | |
| 8 | - /// Five passes over the same `testsrc2` clip | |
| 9 | - /// `a_128_root_horz_and_vert_halves_decode_exact_through_both_decoders` | |
| 10 | - /// uses: each shape forced at every root ([`force_b128_ab`]), so every | |
| 11 | - /// context and every visit order the shape reads is exercised rather than | |
| 12 | - /// the handful the RD would pick, and then an UNFORCED pass whose | |
| 13 | - /// per-shape count is REPORTED (it is the number the gate rows are read | |
| 14 | - /// against). | |
| 15 | - /// | |
| 16 | - /// Each pass is sample-exact against the encoder's own reconstruction | |
| 17 | - /// through `decode_stream` AND through ffmpeg; a writer/reader mismatch | |
| 18 | - /// surfaces here as a refusal or a pixel miss, never in the BD gate. RED | |
| 19 | - /// before this lane by construction: `write_sb128_root` could only name | |
| 20 | - /// NONE / HORZ / VERT / SPLIT, so all four counts were 0. | |
| 21 | - /// | |
| 22 | - /// Runs only inside `superblock_size_global_suite`. | |
| 23 | - pub(super) fn a_128_root_ab_shapes_decode_exact_through_both_decoders() { | |
| 24 | - let _knobs = crate::speed::knob_write(); | |
| 25 | - force_sb128(true); | |
| 26 | - let dir = std::env::temp_dir().join(format!("ec-av1-ab128-{}", std::process::id())); | |
| 27 | - std::fs::create_dir_all(&dir).unwrap(); | |
| 28 | - let clip = dir.join("testsrc2-1280x768.y4m"); | |
| 29 | - let ok = ec_testkit::ffmpeg() | |
| 30 | - .args(["-v", "error", "-y", "-f", "lavfi"]) | |
| 31 | - .args(["-i", "testsrc2=size=1280x768:rate=24"]) | |
| 32 | - .args(["-frames:v", "12", "-pix_fmt", "yuv420p"]) | |
| 33 | - .arg(&clip) | |
| 34 | - .status() | |
| 35 | - .expect("ffmpeg failed to run") | |
| 36 | - .success(); | |
| 37 | - assert!(ok, "ffmpeg could not write the synthetic clip"); | |
| 38 | - let (width, height) = (1280usize, 768usize); | |
| 39 | - let pictures = crate::probe::source(clip.to_str().unwrap(), "0", "null", width, height, 12); | |
| 40 | - let names = ["HORZ_A", "HORZ_B", "VERT_A", "VERT_B"]; | |
| 41 | - let mut unforced = [0usize; 4]; | |
| 42 | - for force in [4u8, 5, 6, 7, 0] { | |
| 43 | - force_b128_ab(force); | |
| 44 | - let label = if force == 0 { | |
| 45 | - "unforced" | |
| 46 | - } else { | |
| 47 | - names[usize::from(force) - 4] | |
| 48 | - }; | |
| 49 | - let _ = take_b128_ab_hits(); | |
| 50 | - let _ = crate::tile::take_sb128_ab_hits(); | |
| 51 | - let encoded = encode_sequence(&pictures, 150, 0.5).unwrap(); | |
| 52 | - let won = take_b128_ab_hits(); | |
| 53 | - let coded = crate::tile::take_sb128_ab_hits(); | |
| 54 | - eprintln!( | |
| 55 | - "{label}: search won {won:?} AB roots, writer coded {coded:?} \ | |
| 56 | - (HORZ_A/HORZ_B/VERT_A/VERT_B)" | |
| 57 | - ); | |
| 58 | - if force == 0 { | |
| 59 | - // The unforced counts are REPORTED, not asserted: a zero here | |
| 60 | - // would be an RD result, not a defect (the four forced passes | |
| 61 | - // already prove the writer and the reader agree on the shape). | |
| 62 | - unforced = won; | |
| 63 | - } else { | |
| 64 | - let i = usize::from(force) - 4; | |
| 65 | - assert!( | |
| 66 | - coded[i] > 0, | |
| 67 | - "no {label} root was coded with {label} forced" | |
| 68 | - ); | |
| 69 | - } | |
| 70 | - let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | |
| 71 | - assert_eq!(decoded.len(), encoded.frames.len(), "{label}: frame count"); | |
| 72 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() { | |
| 73 | - for (plane, got, want) in [ | |
| 74 | - ("luma", &dec.y, &frame.reconstruction.y), | |
| 75 | - ("U", &dec.u, &frame.reconstruction.u), | |
| 76 | - ("V", &dec.v, &frame.reconstruction.v), | |
| 77 | - ] { | |
| 78 | - let differ = got.iter().zip(want.iter()).filter(|(a, b)| a != b).count(); | |
| 79 | - assert_eq!( | |
| 80 | - differ, 0, | |
| 81 | - "{label} frame {i}: {plane} -- {differ} samples differ" | |
| 82 | - ); | |
| 83 | - assert_eq!( | |
| 84 | - got.len(), | |
| 85 | - want.len(), | |
| 86 | - "{label} frame {i}: {plane} is {} samples, the reconstruction's is {}", | |
| 87 | - got.len(), | |
| 88 | - want.len() | |
| 89 | - ); | |
| 90 | - } | |
| 91 | - } | |
| 92 | - let ff = ffmpeg_decode_sequence(&encoded.stream, width, height, pictures.len()); | |
| 93 | - assert_eq!( | |
| 94 | - encoded.frames.len(), | |
| 95 | - ff.len(), | |
| 96 | - "{label}: frame count: ours vs ffmpeg" | |
| 97 | - ); | |
| 98 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&ff).enumerate() { | |
| 99 | - assert_eq!( | |
| 100 | - dec.y, frame.reconstruction.y, | |
| 101 | - "{label} frame {i}: ffmpeg luma" | |
| 102 | - ); | |
| 103 | - assert_eq!(dec.u, frame.reconstruction.u, "{label} frame {i}: ffmpeg U"); | |
| 104 | - assert_eq!(dec.v, frame.reconstruction.v, "{label} frame {i}: ffmpeg V"); | |
| 105 | - } | |
| 106 | - } | |
| 107 | - force_b128_ab(0); | |
| 108 | - eprintln!( | |
| 109 | - "unforced on testsrc2 over 12 frames: {} HORZ_A + {} HORZ_B + {} VERT_A + {} VERT_B", | |
| 110 | - unforced[0], unforced[1], unforced[2], unforced[3], | |
| 111 | - ); | |
| 4 | +#[test] | |
| 5 | +fn every_frame_of_a_sequence_decodes_through_our_own_decoder() { | |
| 6 | + let _knobs = crate::speed::knob_read(); | |
| 7 | + let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 8 | + // 256x128, not the 128x64 this started at: once a leaf could search | |
| 9 | + // its second reference (lane-av1comp4) the small card's every | |
| 10 | + // eligible block went to a compound winner, which commits its flat | |
| 11 | + // transform, and the split below stopped firing on content that | |
| 12 | + // still splits at every larger size ([[gate-blind-to-feature]] -- | |
| 13 | + // the guard is right, the fixture had shrunk under it). | |
| 14 | + let (width, height) = (256usize, 128usize); | |
| 15 | + let pictures: Vec<Picture> = (0..5) | |
| 16 | + .map(|i| panned_test_card(width, height, i * 3)) | |
| 17 | + .collect(); | |
| 18 | + let _ = take_inter_tx_split_hits(); | |
| 19 | + let encoded = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx).unwrap(); | |
| 20 | + let raw = take_inter_tx_split_hits(); | |
| 21 | + // Summed over the four block classes the census keys on (leaf/32x32 x | |
| 22 | + // single/compound): this assert is about the split firing at all. | |
| 23 | + let split = [ | |
| 24 | + raw.iter().step_by(2).sum::<usize>(), | |
| 25 | + raw.iter().skip(1).step_by(2).sum::<usize>(), | |
| 26 | + ]; | |
| 27 | + eprintln!("inter var-tx: {} blocks flat, {} split", split[0], split[1]); | |
| 28 | + // [[gate-blind-to-feature]]: with inter `TxMode::Select` on, this | |
| 29 | + // content splits -- a green round trip in which the split never fires | |
| 30 | + // would prove only the flat path. | |
| 31 | + if tx_select() && tx_select_inter() { | |
| 32 | + assert!(split[1] > 0, "the inter var-tx split never fired"); | |
| 112 | 33 | } |
| 113 | - | |
| 114 | - #[test] | |
| 115 | - fn every_frame_of_a_sequence_decodes_through_our_own_decoder() { | |
| 116 | - let _knobs = crate::speed::knob_read(); | |
| 117 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 118 | - // 256x128, not the 128x64 this started at: once a leaf could search | |
| 119 | - // its second reference (lane-av1comp4) the small card's every | |
| 120 | - // eligible block went to a compound winner, which commits its flat | |
| 121 | - // transform, and the split below stopped firing on content that | |
| 122 | - // still splits at every larger size ([[gate-blind-to-feature]] -- | |
| 123 | - // the guard is right, the fixture had shrunk under it). | |
| 124 | - let (width, height) = (256usize, 128usize); | |
| 125 | - let pictures: Vec<Picture> = (0..5) | |
| 126 | - .map(|i| panned_test_card(width, height, i * 3)) | |
| 127 | - .collect(); | |
| 128 | - let _ = take_inter_tx_split_hits(); | |
| 129 | - let encoded = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx).unwrap(); | |
| 130 | - let raw = take_inter_tx_split_hits(); | |
| 131 | - // Summed over the four block classes the census keys on (leaf/32x32 x | |
| 132 | - // single/compound): this assert is about the split firing at all. | |
| 133 | - let split = [ | |
| 134 | - raw.iter().step_by(2).sum::<usize>(), | |
| 135 | - raw.iter().skip(1).step_by(2).sum::<usize>(), | |
| 136 | - ]; | |
| 137 | - eprintln!("inter var-tx: {} blocks flat, {} split", split[0], split[1]); | |
| 138 | - // [[gate-blind-to-feature]]: with inter `TxMode::Select` on, this | |
| 139 | - // content splits -- a green round trip in which the split never fires | |
| 140 | - // would prove only the flat path. | |
| 141 | - if tx_select() && tx_select_inter() { | |
| 142 | - assert!(split[1] > 0, "the inter var-tx split never fired"); | |
| 143 | - } | |
| 144 | - let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | |
| 145 | - assert_eq!(decoded.len(), encoded.frames.len(), "frame count"); | |
| 146 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() { | |
| 147 | - let recon = &frame.reconstruction; | |
| 148 | - for (plane, got, want, stride) in [ | |
| 149 | - ("luma", &dec.y, &recon.y, width), | |
| 150 | - ("U", &dec.u, &recon.u, width / 2), | |
| 151 | - ("V", &dec.v, &recon.v, width / 2), | |
| 152 | - ] { | |
| 153 | - assert_eq!(got.len(), want.len(), "frame {i}: {plane} size"); | |
| 154 | - if let Some(at) = got.iter().zip(want).position(|(a, b)| a != b) { | |
| 155 | - panic!( | |
| 156 | - "frame {i}: {plane} differs first at ({}, {}): decoded {} vs \ | |
| 34 | + let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | |
| 35 | + assert_eq!(decoded.len(), encoded.frames.len(), "frame count"); | |
| 36 | + for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() { | |
| 37 | + let recon = &frame.reconstruction; | |
| 38 | + for (plane, got, want, stride) in [ | |
| 39 | + ("luma", &dec.y, &recon.y, width), | |
| 40 | + ("U", &dec.u, &recon.u, width / 2), | |
| 41 | + ("V", &dec.v, &recon.v, width / 2), | |
| 42 | + ] { | |
| 43 | + assert_eq!(got.len(), want.len(), "frame {i}: {plane} size"); | |
| 44 | + if let Some(at) = got.iter().zip(want).position(|(a, b)| a != b) { | |
| 45 | + panic!( | |
| 46 | + "frame {i}: {plane} differs first at ({}, {}): decoded {} vs \ | |
| 157 | 47 | reconstruction {} ({} of {} samples differ)", |
| 158 | - at % stride, | |
| 159 | - at / stride, | |
| 160 | - got[at], | |
| 161 | - want[at], | |
| 162 | - got.iter().zip(want).filter(|(a, b)| a != b).count(), | |
| 163 | - got.len(), | |
| 164 | - ); | |
| 165 | - } | |
| 166 | - } | |
| 167 | - } | |
| 168 | - } | |
| 169 | - | |
| 170 | - /// The rate term the mode search ranks every decision by has to be the | |
| 171 | - /// rate the writer then spends. The search prices a block's coefficients | |
| 172 | - /// through `tile::coeff_bits` -- the writer's own symbol chain, but | |
| 173 | - /// against the default CDFs a tile starts from and the contexts of a | |
| 174 | - /// block whose neighbours coded nothing -- while the tile writer codes | |
| 175 | - /// them against a state that has been adapting all frame (the | |
| 176 | - /// price-the-narrowing class). This measures that drift: the sum of what | |
| 177 | - /// the search paid for the coefficients it kept, against the bytes the | |
| 178 | - /// writer actually emitted for the whole tile (which also carries the | |
| 179 | - /// partition/mode/skip/mv syntax the sum leaves out, so the writer is | |
| 180 | - /// expected to be the larger of the two). | |
| 181 | - #[test] | |
| 182 | - fn predicted_coeff_bits_track_the_tile_the_writer_wrote() { | |
| 183 | - let _knobs = crate::speed::knob_read(); | |
| 184 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 185 | - let (width, height) = (256usize, 128usize); | |
| 186 | - let pictures: Vec<Picture> = (0..5) | |
| 187 | - .map(|i| panned_test_card(width, height, i * 2)) | |
| 188 | - .collect(); | |
| 189 | - let _ = take_predicted_bits(); | |
| 190 | - let encoded = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx).unwrap(); | |
| 191 | - let predicted = take_predicted_bits(); | |
| 192 | - assert_eq!(predicted.len(), encoded.frames.len()); | |
| 193 | - | |
| 194 | - eprintln!("frame predicted bits written bits drift"); | |
| 195 | - // Split by sign: a NEGATIVE drift is the search OVER-pricing (the | |
| 196 | - // defect this gate exists to catch), a positive one is the written | |
| 197 | - // side carrying syntax the coefficient sum leaves out -- and since | |
| 198 | - // lane-av1mv an extra reference's `NEWMV` puts a whole MV residual | |
| 199 | - // on that side, so the two directions no longer share a bound. | |
| 200 | - let mut worst_over: f64 = 0.0; | |
| 201 | - let mut worst_under: f64 = 0.0; | |
| 202 | - // The census is per CODED frame, so it is zipped in coding order -- | |
| 203 | - // which is not display order under a pyramid. | |
| 204 | - let coded: Vec<&Encoded> = encoded | |
| 205 | - .coding_order | |
| 206 | - .iter() | |
| 207 | - .map(|&i| &encoded.frames[i]) | |
| 208 | - .collect(); | |
| 209 | - for (i, (frame, &bits)) in coded.into_iter().zip(&predicted).enumerate() { | |
| 210 | - let written = frame.tile.len() as f64 * 8.0; | |
| 211 | - let drift = (written - bits) / written; | |
| 212 | - worst_over = worst_over.max(-drift); | |
| 213 | - // lane-av1pyrdef: a pyramid LEAF codes almost no coefficients at | |
| 214 | - // all (150-250 bits of tile, nearly all of it partition/mode/mv | |
| 215 | - // syntax the coefficient sum never counts), so its ratio measures | |
| 216 | - // that floor rather than any drift. Frames under 512 written bits | |
| 217 | - // are left out of the under-price bound for that reason; the | |
| 218 | - // over-price bound -- the defect direction, where the search pays | |
| 219 | - // MORE than the writer -- still covers every frame. | |
| 220 | - if written >= 512.0 { | |
| 221 | - worst_under = worst_under.max(drift); | |
| 48 | + at % stride, | |
| 49 | + at / stride, | |
| 50 | + got[at], | |
| 51 | + want[at], | |
| 52 | + got.iter().zip(want).filter(|(a, b)| a != b).count(), | |
| 53 | + got.len(), | |
| 54 | + ); | |
| 222 | 55 | } |
| 223 | - eprintln!( | |
| 224 | - "{i:5} {bits:14.0} {written:12.0} {:+6.2}%", | |
| 225 | - drift * 100.0 | |
| 226 | - ); | |
| 227 | 56 | } |
| 228 | - // Measured 2026-09-06 on this sequence: -13.5% at the key frame, | |
| 229 | - // -8.1%, -3.8%, -2.1%, +1.8% down the inter frames. The search | |
| 230 | - // over-prices every frame but the last (its sum EXCLUDES the | |
| 231 | - // partition/mode/skip/mv syntax the written side carries, so the true | |
| 232 | - // coefficient over-price is larger still): the writer's CDFs adapt to | |
| 233 | - // the content while the search's stay at the defaults. The bound is | |
| 234 | - // set just above the worst measured point -- a widening drift is the | |
| 235 | - // thing this gate exists to catch. | |
| 236 | - assert!( | |
| 237 | - worst_over <= 0.16, | |
| 238 | - "the search's rate term OVER-priced by {:.2}% against the bits the writer spent", | |
| 239 | - worst_over * 100.0 | |
| 240 | - ); | |
| 241 | - // Measured 2026-09-06 with the extra-reference `NEWMV` in: +18.9% at | |
| 242 | - // the worst inter frame, where nearly every block now codes an MV | |
| 243 | - // residual and a reference the coefficient sum never counts. Re-measured | |
| 244 | - // at +29.6% once the encoder's grid published compound blocks properly | |
| 245 | - // (compound share 8.8% -> 11.5%): a compound block carries a second | |
| 246 | - // reference tree, a compound mode symbol and -- for the half-new modes | |
| 247 | - // -- an MV residual, none of which the coefficient sum counts. | |
| 248 | - // lane-av1txbits: pricing against the tables the frame's writer really | |
| 249 | - // starts from collapses the over-price above to nothing, so the whole | |
| 250 | - // remaining gap is the syntax the coefficient sum leaves out. That is | |
| 251 | - // the default on a non-screen frame since lane-av1price2 (this | |
| 252 | - // fixture is one), and it reads +32.6% here. | |
| 253 | - // lane-av1obmc: every eligible single-reference inter block now also | |
| 254 | - // carries a `motion_mode` symbol the coefficient sum never counts, | |
| 255 | - // and an OBMC block carries the more expensive of the two values -- | |
| 256 | - // re-measured at +35.0% here with `EC_AV1_OBMC=1`. Like | |
| 257 | - // `EC_AV1_PRICE_FRAME_CDFS=1` before it, that knob changes encoder | |
| 258 | - // decisions, so this bound and the byte pins above FAIL BY DESIGN | |
| 259 | - // under it; the default path (no motion_mode syntax at all) is the | |
| 260 | - // one they are measured on. | |
| 261 | - // lane-av1pyrdef: `encode_sequence` codes this fixture under the | |
| 262 | - // coding pyramid now, so the five frames are a key frame, a hidden | |
| 263 | - // ALTREF at q-16 and three leaves at q+8: +2.6% / +6.9% (the two | |
| 264 | - // frames over the 512-bit floor) and +44.7 / +74.4 / +74.4 on the | |
| 265 | - // near-empty leaves below it. Both bounds stand where they were. | |
| 266 | - // lane-av1rejudge: local warp is ON by default now, so every eligible | |
| 267 | - // single-reference block carries that same `motion_mode` symbol (a | |
| 268 | - // 3-value alphabet where a warp sample exists) on the DEFAULT path -- | |
| 269 | - // +34.9% here, one point past the OBMC reading above. The bound moves | |
| 270 | - // with it; `EC_AV1_WARP=0` restores the +32.6% no-motion_mode number. | |
| 271 | - // lane-av1cfl: a `UV_CFL_PRED` block carries a `cfl_alpha_signs` | |
| 272 | - // symbol and one or two magnitude symbols, none of which the | |
| 273 | - // coefficient sum counts either -- +36.9% here against the same | |
| 274 | - // fixture's +34.9% with `EC_AV1_CFL=0`. | |
| 275 | - // ... and a directional block whose `angle_delta_y` is no longer | |
| 276 | - // always ZERO codes a costlier symbol off the same CDF -- +39.1%. | |
| 277 | - assert!( | |
| 278 | - worst_under <= 0.40, | |
| 279 | - "the writer spent {:.2}% more than the search priced -- more than \ | |
| 280 | - the mode/mv syntax outside the coefficient sum explains", | |
| 281 | - worst_under * 100.0 | |
| 282 | - ); | |
| 283 | 57 | } |
| 284 | - | |
| 285 | - /// The census behind step (1) of the pricer lane: for every transform | |
| 286 | - /// block the writer really codes, what the search priced those levels at | |
| 287 | - /// against what the writer spent on them, split by table set and non-zero | |
| 288 | - /// count. One average hides the interesting part -- the classes the | |
| 289 | - /// estimate is systematically wrong about (all-zero blocks, the | |
| 290 | - /// one-coefficient blocks the inter search lives on) -- so the split is | |
| 291 | - /// printed and only the total is asserted on. | |
| 292 | - #[test] | |
| 293 | - fn pricer_error_census_by_block_class() { | |
| 294 | - let _knobs = crate::speed::knob_read(); | |
| 295 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 296 | - let (width, height) = (256usize, 128usize); | |
| 297 | - let pictures: Vec<Picture> = (0..5) | |
| 298 | - .map(|i| panned_test_card(width, height, i * 2)) | |
| 299 | - .collect(); | |
| 300 | - crate::tile::pricer_census_on(); | |
| 301 | - let _ = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx).unwrap(); | |
| 302 | - let rows = crate::tile::take_pricer_census(); | |
| 303 | - assert!(!rows.is_empty(), "the census saw no transform block"); | |
| 304 | - | |
| 305 | - println!("| set | nz | blocks | priced bits | written bits | error |"); | |
| 306 | - println!("|---|---|---|---|---|---|"); | |
| 307 | - let (mut priced_all, mut written_all) = (0.0, 0.0); | |
| 308 | - for ((set, bucket), (blocks, priced, written)) in &rows { | |
| 309 | - priced_all += priced; | |
| 310 | - written_all += written; | |
| 311 | - println!( | |
| 312 | - "| {set} | {} | {blocks} | {priced:.0} | {written:.0} | {:+.1}% |", | |
| 313 | - crate::tile::census_bucket_label(*bucket), | |
| 314 | - if *written > 0.0 { | |
| 315 | - (priced - written) / written * 100.0 | |
| 316 | - } else { | |
| 317 | - 0.0 | |
| 318 | - } | |
| 319 | - ); | |
| 58 | +} | |
| 59 | + | |
| 60 | +/// The rate term the mode search ranks every decision by has to be the | |
| 61 | +/// rate the writer then spends. The search prices a block's coefficients | |
| 62 | +/// through `tile::coeff_bits` -- the writer's own symbol chain, but | |
| 63 | +/// against the default CDFs a tile starts from and the contexts of a | |
| 64 | +/// block whose neighbours coded nothing -- while the tile writer codes | |
| 65 | +/// them against a state that has been adapting all frame (the | |
| 66 | +/// price-the-narrowing class). This measures that drift: the sum of what | |
| 67 | +/// the search paid for the coefficients it kept, against the bytes the | |
| 68 | +/// writer actually emitted for the whole tile (which also carries the | |
| 69 | +/// partition/mode/skip/mv syntax the sum leaves out, so the writer is | |
| 70 | +/// expected to be the larger of the two). | |
| 71 | +#[test] | |
| 72 | +fn predicted_coeff_bits_track_the_tile_the_writer_wrote() { | |
| 73 | + let _knobs = crate::speed::knob_read(); | |
| 74 | + let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 75 | + let (width, height) = (256usize, 128usize); | |
| 76 | + let pictures: Vec<Picture> = (0..5) | |
| 77 | + .map(|i| panned_test_card(width, height, i * 2)) | |
| 78 | + .collect(); | |
| 79 | + let _ = take_predicted_bits(); | |
| 80 | + let encoded = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx).unwrap(); | |
| 81 | + let predicted = take_predicted_bits(); | |
| 82 | + assert_eq!(predicted.len(), encoded.frames.len()); | |
| 83 | + | |
| 84 | + eprintln!("frame predicted bits written bits drift"); | |
| 85 | + // Split by sign: a NEGATIVE drift is the search OVER-pricing (the | |
| 86 | + // defect this gate exists to catch), a positive one is the written | |
| 87 | + // side carrying syntax the coefficient sum leaves out -- and since | |
| 88 | + // lane-av1mv an extra reference's `NEWMV` puts a whole MV residual | |
| 89 | + // on that side, so the two directions no longer share a bound. | |
| 90 | + let mut worst_over: f64 = 0.0; | |
| 91 | + let mut worst_under: f64 = 0.0; | |
| 92 | + // The census is per CODED frame, so it is zipped in coding order -- | |
| 93 | + // which is not display order under a pyramid. | |
| 94 | + let coded: Vec<&Encoded> = encoded | |
| 95 | + .coding_order | |
| 96 | + .iter() | |
| 97 | + .map(|&i| &encoded.frames[i]) | |
| 98 | + .collect(); | |
| 99 | + for (i, (frame, &bits)) in coded.into_iter().zip(&predicted).enumerate() { | |
| 100 | + let written = frame.tile.len() as f64 * 8.0; | |
| 101 | + let drift = (written - bits) / written; | |
| 102 | + worst_over = worst_over.max(-drift); | |
| 103 | + // lane-av1pyrdef: a pyramid LEAF codes almost no coefficients at | |
| 104 | + // all (150-250 bits of tile, nearly all of it partition/mode/mv | |
| 105 | + // syntax the coefficient sum never counts), so its ratio measures | |
| 106 | + // that floor rather than any drift. Frames under 512 written bits | |
| 107 | + // are left out of the under-price bound for that reason; the | |
| 108 | + // over-price bound -- the defect direction, where the search pays | |
| 109 | + // MORE than the writer -- still covers every frame. | |
| 110 | + if written >= 512.0 { | |
| 111 | + worst_under = worst_under.max(drift); | |
| 320 | 112 | } |
| 321 | - println!( | |
| 322 | - "| ALL | | {} | {priced_all:.0} | {written_all:.0} | {:+.1}% |", | |
| 323 | - rows.values().map(|r| r.0).sum::<u64>(), | |
| 324 | - (priced_all - written_all) / written_all * 100.0 | |
| 113 | + eprintln!( | |
| 114 | + "{i:5} {bits:14.0} {written:12.0} {:+6.2}%", | |
| 115 | + drift * 100.0 | |
| 325 | 116 | ); |
| 326 | - assert!(written_all > 0.0); | |
| 327 | 117 | } |
| 328 | - | |
| 329 | - /// Low motion has to actually buy something: at least one inter frame of | |
| 330 | - /// a panning sequence has to cost fewer bytes than the key frame that | |
| 331 | - /// starts it, and the inter-block share it prints has to be non-zero -- | |
| 332 | - /// a search that never picks an inter mode would still pass a rate gate | |
| 333 | - /// on a picture with no motion in it (the class this repo calls | |
| 334 | - /// gate-blind-to-feature), so the share is printed even though it is not | |
| 335 | - /// asserted on beyond being reachable at all. | |
| 336 | - #[test] | |
| 337 | - fn low_motion_makes_an_inter_frame_smaller_than_the_key_frame() { | |
| 338 | - let _knobs = crate::speed::knob_read(); | |
| 339 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 340 | - let (width, height) = (256usize, 128usize); | |
| 341 | - let pictures: Vec<Picture> = (0..5) | |
| 342 | - .map(|i| panned_test_card(width, height, i * 2)) | |
| 343 | - .collect(); | |
| 344 | - let encoded = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx).unwrap(); | |
| 345 | - | |
| 346 | - let key_bytes = encoded.frames[0].stream.len(); | |
| 347 | - eprintln!("frame bytes inter share"); | |
| 348 | - for (i, frame) in encoded.frames.iter().enumerate() { | |
| 349 | - eprintln!( | |
| 350 | - "{i:5} {:5} {:11.2}", | |
| 351 | - frame.stream.len(), | |
| 352 | - frame.inter_block_share | |
| 353 | - ); | |
| 354 | - } | |
| 355 | - assert!( | |
| 356 | - encoded.frames[1..] | |
| 357 | - .iter() | |
| 358 | - .any(|f| f.stream.len() < key_bytes), | |
| 359 | - "no inter frame of a panning sequence beat the key frame's {key_bytes} bytes" | |
| 360 | - ); | |
| 361 | - assert!( | |
| 362 | - encoded.frames[1..] | |
| 363 | - .iter() | |
| 364 | - .any(|f| f.inter_block_share > 0.0), | |
| 365 | - "no inter frame coded a single inter block -- the search never fired" | |
| 118 | + // Measured 2026-09-06 on this sequence: -13.5% at the key frame, | |
| 119 | + // -8.1%, -3.8%, -2.1%, +1.8% down the inter frames. The search | |
| 120 | + // over-prices every frame but the last (its sum EXCLUDES the | |
| 121 | + // partition/mode/skip/mv syntax the written side carries, so the true | |
| 122 | + // coefficient over-price is larger still): the writer's CDFs adapt to | |
| 123 | + // the content while the search's stay at the defaults. The bound is | |
| 124 | + // set just above the worst measured point -- a widening drift is the | |
| 125 | + // thing this gate exists to catch. | |
| 126 | + assert!( | |
| 127 | + worst_over <= 0.16, | |
| 128 | + "the search's rate term OVER-priced by {:.2}% against the bits the writer spent", | |
| 129 | + worst_over * 100.0 | |
| 130 | + ); | |
| 131 | + // Measured 2026-09-06 with the extra-reference `NEWMV` in: +18.9% at | |
| 132 | + // the worst inter frame, where nearly every block now codes an MV | |
| 133 | + // residual and a reference the coefficient sum never counts. Re-measured | |
| 134 | + // at +29.6% once the encoder's grid published compound blocks properly | |
| 135 | + // (compound share 8.8% -> 11.5%): a compound block carries a second | |
| 136 | + // reference tree, a compound mode symbol and -- for the half-new modes | |
| 137 | + // -- an MV residual, none of which the coefficient sum counts. | |
| 138 | + // lane-av1txbits: pricing against the tables the frame's writer really | |
| 139 | + // starts from collapses the over-price above to nothing, so the whole | |
| 140 | + // remaining gap is the syntax the coefficient sum leaves out. That is | |
| 141 | + // the default on a non-screen frame since lane-av1price2 (this | |
| 142 | + // fixture is one), and it reads +32.6% here. | |
| 143 | + // lane-av1obmc: every eligible single-reference inter block now also | |
| 144 | + // carries a `motion_mode` symbol the coefficient sum never counts, | |
| 145 | + // and an OBMC block carries the more expensive of the two values -- | |
| 146 | + // re-measured at +35.0% here with `EC_AV1_OBMC=1`. Like | |
| 147 | + // `EC_AV1_PRICE_FRAME_CDFS=1` before it, that knob changes encoder | |
| 148 | + // decisions, so this bound and the byte pins above FAIL BY DESIGN | |
| 149 | + // under it; the default path (no motion_mode syntax at all) is the | |
| 150 | + // one they are measured on. | |
| 151 | + // lane-av1pyrdef: `encode_sequence` codes this fixture under the | |
| 152 | + // coding pyramid now, so the five frames are a key frame, a hidden | |
| 153 | + // ALTREF at q-16 and three leaves at q+8: +2.6% / +6.9% (the two | |
| 154 | + // frames over the 512-bit floor) and +44.7 / +74.4 / +74.4 on the | |
| 155 | + // near-empty leaves below it. Both bounds stand where they were. | |
| 156 | + // lane-av1rejudge: local warp is ON by default now, so every eligible | |
| 157 | + // single-reference block carries that same `motion_mode` symbol (a | |
| 158 | + // 3-value alphabet where a warp sample exists) on the DEFAULT path -- | |
| 159 | + // +34.9% here, one point past the OBMC reading above. The bound moves | |
| 160 | + // with it; `EC_AV1_WARP=0` restores the +32.6% no-motion_mode number. | |
| 161 | + // lane-av1cfl: a `UV_CFL_PRED` block carries a `cfl_alpha_signs` | |
| 162 | + // symbol and one or two magnitude symbols, none of which the | |
| 163 | + // coefficient sum counts either -- +36.9% here against the same | |
| 164 | + // fixture's +34.9% with `EC_AV1_CFL=0`. | |
| 165 | + // ... and a directional block whose `angle_delta_y` is no longer | |
| 166 | + // always ZERO codes a costlier symbol off the same CDF -- +39.1%. | |
| 167 | + assert!( | |
| 168 | + worst_under <= 0.40, | |
| 169 | + "the writer spent {:.2}% more than the search priced -- more than \ | |
| 170 | + the mode/mv syntax outside the coefficient sum explains", | |
| 171 | + worst_under * 100.0 | |
| 172 | + ); | |
| 173 | +} | |
| 174 | + | |
| 175 | +/// Low motion has to actually buy something: at least one inter frame of | |
| 176 | +/// a panning sequence has to cost fewer bytes than the key frame that | |
| 177 | +/// starts it, and the inter-block share it prints has to be non-zero -- | |
| 178 | +/// a search that never picks an inter mode would still pass a rate gate | |
| 179 | +/// on a picture with no motion in it (the class this repo calls | |
| 180 | +/// gate-blind-to-feature), so the share is printed even though it is not | |
| 181 | +/// asserted on beyond being reachable at all. | |
| 182 | +#[test] | |
| 183 | +fn low_motion_makes_an_inter_frame_smaller_than_the_key_frame() { | |
| 184 | + let _knobs = crate::speed::knob_read(); | |
| 185 | + let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 186 | + let (width, height) = (256usize, 128usize); | |
| 187 | + let pictures: Vec<Picture> = (0..5) | |
| 188 | + .map(|i| panned_test_card(width, height, i * 2)) | |
| 189 | + .collect(); | |
| 190 | + let encoded = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx).unwrap(); | |
| 191 | + | |
| 192 | + let key_bytes = encoded.frames[0].stream.len(); | |
| 193 | + eprintln!("frame bytes inter share"); | |
| 194 | + for (i, frame) in encoded.frames.iter().enumerate() { | |
| 195 | + eprintln!( | |
| 196 | + "{i:5} {:5} {:11.2}", | |
| 197 | + frame.stream.len(), | |
| 198 | + frame.inter_block_share | |
| 366 | 199 | ); |
| 367 | 200 | } |
| 368 | - | |
| 369 | - /// `frames` consecutive pictures out of a real clip, scaled to a whole | |
| 370 | - /// number of 32x32 blocks. Generalizes [`clip_frame`]/[`clip_frame_pair`] | |
| 371 | - /// to an arbitrary count for the fixture regression gate below. | |
| 372 | - pub(super) fn clip_frames( | |
| 373 | - clip: &str, | |
| 374 | - skip: &str, | |
| 375 | - width: usize, | |
| 376 | - height: usize, | |
| 377 | - frames: usize, | |
| 378 | - ) -> Vec<Picture> { | |
| 379 | - clip_frames_vf( | |
| 380 | - clip, | |
| 381 | - skip, | |
| 382 | - &format!("scale={width}:{height}"), | |
| 383 | - width, | |
| 384 | - height, | |
| 385 | - frames, | |
| 386 | - ) | |
| 387 | - } | |
| 388 | - | |
| 389 | - /// [`clip_frames`] with the filter chain spelled out, so a caller can ask | |
| 390 | - /// for a native-resolution CROP instead of a downscale (the downscale is | |
| 391 | - /// what destroys a screen capture's exact repeats -- class | |
| 392 | - /// `gate-recipe-confound`). `width`/`height` must be what `vf` produces. | |
| 393 | - pub(super) fn clip_frames_vf( | |
| 394 | - clip: &str, | |
| 395 | - skip: &str, | |
| 396 | - vf: &str, | |
| 397 | - width: usize, | |
| 398 | - height: usize, | |
| 399 | - frames: usize, | |
| 400 | - ) -> Vec<Picture> { | |
| 401 | - // ONE definition of the gate's loader recipe, shared with | |
| 402 | - // `examples/enc_probe` so the instrument cannot arm a different source | |
| 403 | - // than the gate it reports on (class `instrument disagrees with the | |
| 404 | - // gate`; lane-probe). | |
| 405 | - crate::probe::source(clip, skip, vf, width, height, frames) | |
| 406 | - } | |
| 407 | - | |
| 408 | - // ----------------------------------------------------------------------- | |
| 409 | - // The encoder's standing BD-rate baseline against libaom and rav1e. | |
| 410 | - // Every PSNR below is measured on FFMPEG-DECODED pixels, never on an | |
| 411 | - // encoder's own reconstruction ([[shared-oracle-blindness]]): our decoder | |
| 412 | - // agreeing with our encoder proves nothing about the bitstream. | |
| 413 | - // ----------------------------------------------------------------------- | |
| 414 | - | |
| 415 | - /// All-plane PSNR of a decoded picture against its source, on the same | |
| 416 | - /// 8-bit scale [`psnr`] uses. | |
| 417 | - pub(super) fn psnr_all(decoded: &Picture, source: &Picture) -> f64 { | |
| 418 | - let cat = |p: &Picture| { | |
| 419 | - let mut v = Vec::with_capacity(p.y.len() + p.u.len() + p.v.len()); | |
| 420 | - v.extend_from_slice(&p.y); | |
| 421 | - v.extend_from_slice(&p.u); | |
| 422 | - v.extend_from_slice(&p.v); | |
| 423 | - v | |
| 424 | - }; | |
| 425 | - psnr(&cat(decoded), &cat(source)) | |
| 426 | - } | |
| 427 | - | |
| 428 | - /// The pictures back as the planar 8-bit bytes an encoder reads. | |
| 429 | - pub(super) fn raw_yuv420p(source: &[Picture]) -> Vec<u8> { | |
| 430 | - let mut raw = Vec::new(); | |
| 431 | - for p in source { | |
| 432 | - for plane in [&p.y, &p.u, &p.v] { | |
| 433 | - raw.extend(plane.iter().map(|&s| s as u8)); | |
| 434 | - } | |
| 435 | - } | |
| 436 | - raw | |
| 437 | - } | |
| 438 | - | |
| 439 | - /// A (all-plane PSNR, log10 bytes) ladder from another AV1 encoder driven | |
| 440 | - /// through ffmpeg: one point per entry of `points`, each a quality flag | |
| 441 | - /// set. Returns the ladder ordered by fidelity and the total encode wall | |
| 442 | - /// clock. The stream is decoded back through [`ffmpeg_decode_sequence`], | |
| 443 | - /// so both curves are measured by the same decoder. | |
| 444 | - pub(super) fn external_ladder( | |
| 445 | - source: &[Picture], | |
| 446 | - width: usize, | |
| 447 | - height: usize, | |
| 448 | - encoder: &str, | |
| 449 | - points: &[Vec<String>], | |
| 450 | - ) -> (Vec<(f64, f64)>, f64) { | |
| 451 | - // [[pid-keyed-temp-path]]: parallel test binaries must not share a name. | |
| 452 | - let dir = std::env::temp_dir(); | |
| 453 | - let raw_path = dir.join(format!("ec-av1-bd-{}-{encoder}.yuv", std::process::id())); | |
| 454 | - std::fs::write(&raw_path, raw_yuv420p(source)).expect("raw source"); | |
| 455 | - let mut ladder = Vec::new(); | |
| 456 | - let mut wall = 0.0; | |
| 457 | - for (i, params) in points.iter().enumerate() { | |
| 458 | - let obu = dir.join(format!( | |
| 459 | - "ec-av1-bd-{}-{encoder}-{i}.obu", | |
| 460 | - std::process::id() | |
| 461 | - )); | |
| 462 | - let start = std::time::Instant::now(); | |
| 463 | - let out = ec_testkit::ffmpeg() | |
| 464 | - .args(["-v", "error", "-y", "-f", "rawvideo", "-pix_fmt", "yuv420p"]) | |
| 465 | - .args(["-s", &format!("{width}x{height}"), "-r", "24", "-i"]) | |
| 466 | - .arg(&raw_path) | |
| 467 | - .args(["-an", "-threads", "1"]) | |
| 468 | - .args(["-g", &source.len().to_string(), "-c:v", encoder]) | |
| 469 | - .args(params) | |
| 470 | - .args(["-f", "obu"]) | |
| 471 | - .arg(&obu).output() | |
| 472 | - .expect("ffmpeg failed to run"); | |
| 473 | - wall += start.elapsed().as_secs_f64(); | |
| 474 | - assert!( | |
| 475 | - out.status.success(), | |
| 476 | - "{encoder} {params:?}: {}", | |
| 477 | - String::from_utf8_lossy(&out.stderr) | |
| 478 | - ); | |
| 479 | - let stream = std::fs::read(&obu).expect("reference stream"); | |
| 480 | - let decoded = ffmpeg_decode_sequence(&stream, width, height, source.len()); | |
| 481 | - // lane-dkey: every reference point must also decode through OUR | |
| 482 | - // decoder, sample-exact against ffmpeg's decode of the same bytes. | |
| 483 | - // A BD table computed off streams we cannot read is a table about | |
| 484 | - // an encoder we cannot check; this is the assertion that would | |
| 485 | - // have caught the `force_integer_mv` defect (its stream decoded to | |
| 486 | - // 25 dB garbage while this gate stayed green) and the crf-5 key | |
| 487 | - // frame desync. A failure names the encoder, the point's flags and | |
| 488 | - // the first differing frame/plane/sample. | |
| 489 | - // lane-dpm1: a failing reference point is COLLECTED, not panicked | |
| 490 | - // on, so one run still prints the whole BD table and names every | |
| 491 | - // bad point instead of stopping at the first. The collection is | |
| 492 | - // asserted empty by [`assert_ladder_decodes`] at the end of each | |
| 493 | - // gate. | |
| 494 | - match crate::stream::decode_stream(&stream) { | |
| 495 | - Ok(ours) if ours.len() != decoded.len() => note_ladder_failure(format!( | |
| 496 | - "{encoder} {params:?}: our decoder returned {} shown frames, ffmpeg {}", | |
| 497 | - ours.len(), | |
| 498 | - decoded.len(), | |
| 499 | - )), | |
| 500 | - Ok(ours) => { | |
| 501 | - for (f, (o, d)) in ours.iter().zip(&decoded).enumerate() { | |
| 502 | - if let Some((plane, s, got, want)) = first_plane_mismatch(o, d) { | |
| 503 | - note_ladder_failure(format!( | |
| 504 | - "{encoder} {params:?} frame {f} plane {plane} sample {s}: our \ | |
| 505 | - decoder decoded {got}, ffmpeg {want}" | |
| 506 | - )); | |
| 507 | - break; | |
| 508 | - } | |
| 509 | - } | |
| 510 | - } | |
| 511 | - Err(e) => note_ladder_failure(format!( | |
| 512 | - "{encoder} {params:?}: our decoder refused the stream ({e})" | |
| 513 | - )), | |
| 514 | - } | |
| 515 | - let mean: f64 = decoded | |
| 516 | - .iter() | |
| 517 | - .zip(source) | |
| 518 | - .map(|(d, s)| psnr_all(d, s)) | |
| 519 | - .sum::<f64>() | |
| 520 | - / source.len() as f64; | |
| 521 | - ladder.push((mean, (stream.len() as f64).log10())); | |
| 522 | - let _ = std::fs::remove_file(&obu); | |
| 201 | + assert!( | |
| 202 | + encoded.frames[1..] | |
| 203 | + .iter() | |
| 204 | + .any(|f| f.stream.len() < key_bytes), | |
| 205 | + "no inter frame of a panning sequence beat the key frame's {key_bytes} bytes" | |
| 206 | + ); | |
| 207 | + assert!( | |
| 208 | + encoded.frames[1..] | |
| 209 | + .iter() | |
| 210 | + .any(|f| f.inter_block_share > 0.0), | |
| 211 | + "no inter frame coded a single inter block -- the search never fired" | |
| 212 | + ); | |
| 213 | +} | |
| 214 | + | |
| 215 | +/// `frames` consecutive pictures out of a real clip, scaled to a whole | |
| 216 | +/// number of 32x32 blocks. Generalizes [`clip_frame`]/[`clip_frame_pair`] | |
| 217 | +/// to an arbitrary count for the fixture regression gate below. | |
| 218 | +pub(super) fn clip_frames( | |
| 219 | + clip: &str, | |
| 220 | + skip: &str, | |
| 221 | + width: usize, | |
| 222 | + height: usize, | |
| 223 | + frames: usize, | |
| 224 | +) -> Vec<Picture> { | |
| 225 | + clip_frames_vf( | |
| 226 | + clip, | |
| 227 | + skip, | |
| 228 | + &format!("scale={width}:{height}"), | |
| 229 | + width, | |
| 230 | + height, | |
| 231 | + frames, | |
| 232 | + ) | |
| 233 | +} | |
| 234 | + | |
| 235 | +/// [`clip_frames`] with the filter chain spelled out, so a caller can ask | |
| 236 | +/// for a native-resolution CROP instead of a downscale (the downscale is | |
| 237 | +/// what destroys a screen capture's exact repeats -- class | |
| 238 | +/// `gate-recipe-confound`). `width`/`height` must be what `vf` produces. | |
| 239 | +pub(super) fn clip_frames_vf( | |
| 240 | + clip: &str, | |
| 241 | + skip: &str, | |
| 242 | + vf: &str, | |
| 243 | + width: usize, | |
| 244 | + height: usize, | |
| 245 | + frames: usize, | |
| 246 | +) -> Vec<Picture> { | |
| 247 | + // ONE definition of the gate's loader recipe, shared with | |
| 248 | + // `examples/enc_probe` so the instrument cannot arm a different source | |
| 249 | + // than the gate it reports on (class `instrument disagrees with the | |
| 250 | + // gate`; lane-probe). | |
| 251 | + crate::probe::source(clip, skip, vf, width, height, frames) | |
| 252 | +} | |
| 253 | + | |
| 254 | +// ----------------------------------------------------------------------- | |
| 255 | +// The encoder's standing BD-rate baseline against libaom and rav1e. | |
| 256 | +// Every PSNR below is measured on FFMPEG-DECODED pixels, never on an | |
| 257 | +// encoder's own reconstruction ([[shared-oracle-blindness]]): our decoder | |
| 258 | +// agreeing with our encoder proves nothing about the bitstream. | |
| 259 | +// ----------------------------------------------------------------------- | |
| 260 | + | |
| 261 | +/// First differing sample between two pictures, as | |
| 262 | +/// `(plane, index, left, right)` -- so a gate failure names the plane and | |
| 263 | +/// the sample instead of just "differs". A length difference counts as a | |
| 264 | +/// mismatch of that plane at the first index past the shorter one. | |
| 265 | +pub(super) fn first_plane_mismatch( | |
| 266 | + a: &Picture, | |
| 267 | + b: &Picture, | |
| 268 | +) -> Option<(&'static str, usize, i64, i64)> { | |
| 269 | + for (plane, l, r) in [("Y", &a.y, &b.y), ("U", &a.u, &b.u), ("V", &a.v, &b.v)] { | |
| 270 | + if let Some(i) = l.iter().zip(r.iter()).position(|(x, y)| x != y) { | |
| 271 | + return Some((plane, i, i64::from(l[i]), i64::from(r[i]))); | |
| 523 | 272 | } |
| 524 | - let _ = std::fs::remove_file(&raw_path); | |
| 525 | - ladder.sort_by(|a, b| a.0.total_cmp(&b.0)); | |
| 526 | - (ladder, wall) | |
| 527 | - } | |
| 528 | - | |
| 529 | - /// Every reference ladder point that did not decode sample-exactly | |
| 530 | - /// through our own decoder, collected across a whole gate run so the BD | |
| 531 | - /// table still prints and EVERY bad point is named | |
| 532 | - /// (`encoder params frame plane sample`) instead of only the first. | |
| 533 | - static LADDER_FAILURES: std::sync::Mutex<Vec<String>> = std::sync::Mutex::new(Vec::new()); | |
| 534 | - | |
| 535 | - pub(super) fn note_ladder_failure(msg: String) { | |
| 536 | - eprintln!("LADDER DECODE FAILURE: {msg}"); | |
| 537 | - LADDER_FAILURES.lock().expect("ladder failures").push(msg); | |
| 538 | - } | |
| 539 | - | |
| 540 | - /// Fail the gate at its END on everything [`external_ladder`] collected. | |
| 541 | - pub(super) fn assert_ladder_decodes() { | |
| 542 | - let failures = std::mem::take(&mut *LADDER_FAILURES.lock().expect("ladder failures")); | |
| 543 | - assert!( | |
| 544 | - failures.is_empty(), | |
| 545 | - "{} reference ladder point(s) did not decode exactly through our decoder:\n{}", | |
| 546 | - failures.len(), | |
| 547 | - failures.join("\n"), | |
| 548 | - ); | |
| 549 | - } | |
| 550 | - | |
| 551 | - /// First differing sample between two pictures, as | |
| 552 | - /// `(plane, index, left, right)` -- so a gate failure names the plane and | |
| 553 | - /// the sample instead of just "differs". A length difference counts as a | |
| 554 | - /// mismatch of that plane at the first index past the shorter one. | |
| 555 | - pub(super) fn first_plane_mismatch(a: &Picture, b: &Picture) -> Option<(&'static str, usize, i64, i64)> { | |
| 556 | - for (plane, l, r) in [("Y", &a.y, &b.y), ("U", &a.u, &b.u), ("V", &a.v, &b.v)] { | |
| 557 | - if let Some(i) = l.iter().zip(r.iter()).position(|(x, y)| x != y) { | |
| 558 | - return Some((plane, i, i64::from(l[i]), i64::from(r[i]))); | |
| 559 | - } | |
| 560 | - if l.len() != r.len() { | |
| 561 | - return Some((plane, l.len().min(r.len()), l.len() as i64, r.len() as i64)); | |
| 562 | - } | |
| 273 | + if l.len() != r.len() { | |
| 274 | + return Some((plane, l.len().min(r.len()), l.len() as i64, r.len() as i64)); | |
| 563 | 275 | } |
| 564 | - None | |
| 565 | 276 | } |
| 566 | - | |
| 567 | - /// The same ladder for this encoder, at four `base_q_idx` points. The PSNR | |
| 568 | - /// comes from ffmpeg's decode of our own stream, and at EVERY point the | |
| 569 | - /// stream is decoded twice -- by ffmpeg and by our own | |
| 570 | - /// [`crate::stream::decode_stream`] -- and all three pictures (encoder | |
| 571 | - /// reconstruction, ffmpeg's decode, our decode) are asserted sample-exact | |
| 572 | - /// in Y, U and V over every shown frame in display order. That is itself | |
| 573 | - /// a gate: it proves the bitstream says what the encoder thinks, in the | |
| 574 | - /// only two decoders that read it. | |
| 575 | - pub(super) fn our_ladder( | |
| 576 | - name: &str, | |
| 577 | - source: &[Picture], | |
| 578 | - width: usize, | |
| 579 | - height: usize, | |
| 580 | - fctx: &crate::decode::FrameCtx, | |
| 581 | - ) -> (Vec<(f64, f64)>, f64) { | |
| 582 | - let mut ladder = Vec::new(); | |
| 583 | - let mut wall = 0.0; | |
| 584 | - for &q in &[150u8, 120, 90, 60] { | |
| 585 | - let start = std::time::Instant::now(); | |
| 586 | - // lane-rdoq: the deadzone was fitted WITHOUT the RDOQ pass, so | |
| 587 | - // the gate has to be able to re-sweep it. 0.5 is the shipped one | |
| 588 | - // (`crate::encoder::DEADZONE`). | |
| 589 | - let deadzone = std::env::var("EC_AV1_DEADZONE") | |
| 590 | - .ok() | |
| 591 | - .and_then(|v| v.parse().ok()) | |
| 592 | - .unwrap_or(0.5); | |
| 593 | - let encoded = encode_sequence_with_ctx(source, q, deadzone, fctx).unwrap(); | |
| 594 | - wall += start.elapsed().as_secs_f64(); | |
| 595 | - let decoded = ffmpeg_decode_sequence(&encoded.stream, width, height, source.len()); | |
| 596 | - let ours = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | |
| 597 | - assert_eq!( | |
| 598 | - ours.len(), | |
| 599 | - source.len(), | |
| 600 | - "{name} q={q}: our decoder's display-order frame count" | |
| 601 | - ); | |
| 602 | - for (i, (d, e)) in decoded.iter().zip(&encoded.frames).enumerate() { | |
| 603 | - if let Some((plane, s, got, want)) = first_plane_mismatch(d, &e.reconstruction) { | |
| 604 | - panic!( | |
| 605 | - "{name} q={q} frame {i} plane {plane} sample {s}: ffmpeg decoded \ | |
| 606 | - {got}, the encoder reconstructed {want}" | |
| 607 | - ); | |
| 608 | - } | |
| 609 | - } | |
| 610 | - for (i, (o, e)) in ours.iter().zip(&encoded.frames).enumerate() { | |
| 611 | - if let Some((plane, s, got, want)) = first_plane_mismatch(o, &e.reconstruction) { | |
| 612 | - panic!( | |
| 613 | - "{name} q={q} frame {i} plane {plane} sample {s}: our decoder decoded \ | |
| 614 | - {got}, the encoder reconstructed {want}" | |
| 615 | - ); | |
| 616 | - } | |
| 617 | - } | |
| 618 | - let per_frame: Vec<f64> = decoded | |
| 619 | - .iter() | |
| 620 | - .zip(source) | |
| 621 | - .map(|(d, s)| psnr_all(d, s)) | |
| 622 | - .collect(); | |
| 623 | - // lane-txrd: does a tool's loss start at the FIRST inter frame | |
| 624 | - // (a local mispricing) or grow down the GOP (propagation into | |
| 625 | - // the reference chain)? One line per q point answers it. | |
| 626 | - if crate::envflags::env_flag!("EC_AV1_FRAME_PSNR") { | |
| 627 | - let row: Vec<String> = per_frame.iter().map(|p| format!("{p:.2}")).collect(); | |
| 628 | - eprintln!("{name}: q={q} per-frame PSNR {}", row.join(" ")); | |
| 629 | - // lane-txrd: per PLANE, because an all-plane mean hides a | |
| 630 | - // collapse in one of them (class `metric blind to a plane`). | |
| 631 | - let plane = |pick: fn(&Picture) -> &Vec<u16>| -> String { | |
| 632 | - let v: Vec<String> = decoded | |
| 633 | - .iter() | |
| 634 | - .zip(source) | |
| 635 | - .map(|(d, s)| format!("{:.2}", psnr(pick(d), pick(s)))) | |
| 636 | - .collect(); | |
| 637 | - v.join(" ") | |
| 638 | - }; | |
| 639 | - eprintln!("{name}: q={q} Y {}", plane(|p| &p.y)); | |
| 640 | - eprintln!("{name}: q={q} U {}", plane(|p| &p.u)); | |
| 641 | - eprintln!("{name}: q={q} V {}", plane(|p| &p.v)); | |
| 642 | - } | |
| 643 | - let mean: f64 = per_frame.iter().sum::<f64>() / source.len() as f64; | |
| 644 | - ladder.push((mean, (encoded.stream.len() as f64).log10())); | |
| 645 | - } | |
| 646 | - // What this clip asked for and what the content gate left it coding | |
| 647 | - // under: a screen clip requests a pyramid and codes flat, and that | |
| 648 | - // difference is what keeps its row identical to the flat baseline | |
| 649 | - // (class `gate-blind-to-feature`). | |
| 650 | - eprintln!( | |
| 651 | - "{name}: sequence, pyramid requested {:?} effective {:?}", | |
| 652 | - crate::encoder::Pyramid::from_env(), | |
| 653 | - last_sequence_pyramid(), | |
| 654 | - ); | |
| 655 | - ladder.sort_by(|a, b| a.0.total_cmp(&b.0)); | |
| 656 | - (ladder, wall) | |
| 277 | + None | |
| 278 | +} | |
| 279 | + | |
| 280 | +/// Byte-exactness gate for encoder work that is meant to change only | |
| 281 | +/// how long the encoder takes. | |
| 282 | +/// | |
| 283 | +/// The BD gate above measures quality, which a speed lane can move by a | |
| 284 | +/// hair without failing anything; this pins the streams themselves. | |
| 285 | +/// Re-measured on the lane-av1lr merge with main d5fc99e0 (per-64x64 | |
| 286 | +/// `cdef_idx` literals and per-unit loop restoration syntax are new bits | |
| 287 | +/// in the tile) and again on lane-av1mv's merge of it: an extra | |
| 288 | +/// reference's `NEWMV` is a coded-bits change too, judged by the BD gate | |
| 289 | +/// above, not by this pin. Re-pinned on lane-av1price2: the search now | |
| 290 | +/// prices coefficients against the tables the frame's writer really | |
| 291 | +/// starts from on every non-screen frame (`tile::arm_pricing_cdfs`), a | |
| 292 | +/// decision change the BD gate judges. Re-pinned again on | |
| 293 | +/// lane-av1skipctx: the search now prices `txb_skip`/`dc_sign` at the | |
| 294 | +/// real neighbour contexts ([`Plane::coef_ctx`]) instead of zero, which | |
| 295 | +/// is the same kind of decision change. Re-pinned on lane-av1lambda: | |
| 296 | +/// [`LAMBDA_SCALE`] moved 0.1 -> 0.05, so every RD decision in the | |
| 297 | +/// search moved with it. Re-pinned on lane-av1rejudge: local warp is on | |
| 298 | +/// by default ([`warp_on`], a sequence/frame header bit and a new | |
| 299 | +/// motion_mode symbol on eligible blocks) and | |
| 300 | +/// [`LEAF_SECOND_NEW_MARGIN`] moved 0.8 -> 1.2. Re-pinned on lane-av1tpl: | |
| 301 | +/// every inter frame's superblocks now code at their own lambda | |
| 302 | +/// ([`TPL_STRENGTH`]), so every RD decision in an inter frame moved. | |
| 303 | +/// Re-pinned on lane-av1resweep: [`LAMBDA_SCALE`] moved 0.05 -> 0.0275 | |
| 304 | +/// and the two var-tx depth searches ([`tx32_depth_search`], | |
| 305 | +/// [`compound_var_tx`]) are on by default, all three re-judged on the | |
| 306 | +/// native gate's real film rows. | |
| 307 | +/// Re-pinned on lane-av1cfl: the chroma search offers `UV_CFL_PRED`, so | |
| 308 | +/// every block whose chroma takes it codes a different mode symbol, two | |
| 309 | +/// alpha symbols and different chroma coefficients. `EC_AV1_CFL=0` | |
| 310 | +/// restores the previous streams. Re-pinned again in the same lane once | |
| 311 | +/// directional luma winners searched their `angle_delta_y` | |
| 312 | +/// (`EC_AV1_ANGLE=0` restores that half). | |
| 313 | +#[test] | |
| 314 | +fn the_encoders_own_streams_are_byte_identical_to_their_pins() { | |
| 315 | + // These are DEFAULT-PRESET pins: a speed preset switches search levers | |
| 316 | + // off, so it legitimately moves every byte. Encode at speed 0 whatever | |
| 317 | + // `EC_AV1_SPEED` says (write guard: the preset is process-global). | |
| 318 | + let _knobs = crate::speed::knob_write(); | |
| 319 | + let was = crate::speed::speed(); | |
| 320 | + crate::speed::set_speed(0); | |
| 321 | + // lane-av1clipprobe: the bare `clip.exists()` -> SKIP had no env escape, | |
| 322 | + // so a tree with no root `fixtures/` reported this gate green having | |
| 323 | + // compared nothing at all. | |
| 324 | + let clip = ec_testkit::fixture("open/sintel_trailer-1080p.mp4"); | |
| 325 | + let source = clip_frames(clip.to_str().unwrap(), "20", 640, 384, 4); | |
| 326 | + // FNV-1a over the stream: a witness that every coded bit is where it | |
| 327 | + // was, which a byte count alone is not. | |
| 328 | + let fnv = |b: &[u8]| { | |
| 329 | + b.iter().fold(0xcbf2_9ce4_8422_2325u64, |h, &v| { | |
| 330 | + (h ^ u64::from(v)).wrapping_mul(0x0000_0100_0000_01b3) | |
| 331 | + }) | |
| 332 | + }; | |
| 333 | + // Re-taken on lane-av1pyrdef: `encode_sequence` codes this (non-screen) | |
| 334 | + // clip under the coding pyramid now -- one hidden ALTREF per mini-GOP | |
| 335 | + // of 4, its leaves at q+8 and a `show_existing_frame` header per | |
| 336 | + // group. 7299 -> 8194 bytes at q=150 and 26804 -> 28285 at q=60 over | |
| 337 | + // four frames; four pictures is one short mini-GOP, which is the | |
| 338 | + // shape that pays least (the ARF's own quality has no later group to | |
| 339 | + // carry it), so this is not the BD gate's number. | |
| 340 | + // Re-taken again on lane-av1cfl: the chroma search offers | |
| 341 | + // `UV_CFL_PRED` and directional luma winners search `angle_delta_y`, | |
| 342 | + // so every block taking either codes different syntax and different | |
| 343 | + // coefficients -- 8194 -> 7321 at q=150 and 28285 -> 27285 at q=60. | |
| 344 | + // `EC_AV1_CFL=0` / `EC_AV1_ANGLE=0` restore each half. | |
| 345 | + // Re-taken on lane-pyr3: the mini-GOP of the default pyramid is 16 | |
| 346 | + // pictures at `q-24` / `q+16` now (the sweep in [`Pyramid::default`]), | |
| 347 | + // so these four pictures code as one truncated group -- a hidden | |
| 348 | + // ALTREF at `q-24` and three leaves at `q+16` -- instead of one | |
| 349 | + // mini-GOP of 4 at `q-16` / `q+8`: 7373 -> 8076 at q=150 and | |
| 350 | + // 27074 -> 27585 at q=60. `EC_AV1_PYRAMID=4:-16:8` restores these. | |
| 351 | + // Re-taken on lane-fintra: the sequence header sets | |
| 352 | + // `enable_filter_intra`, so every DC_PRED intra block of at most | |
| 353 | + // 32x32 without a luma palette carries a `use_filter_intra` flag and | |
| 354 | + // the blocks that take one code a filter-intra mode, a different | |
| 355 | + // prediction and different coefficients -- 7321 -> 7373 at q=150 and | |
| 356 | + // 27285 -> 27074 at q=60. `EC_AV1_FILTER_INTRA=0` restores these. | |
| 357 | + // Re-taken on lane-b64 (64x64 skip root), at the lane-pyr4 merge | |
| 358 | + // (default pyramid `8:-32:16`, one truncated group of 8 with its | |
| 359 | + // hidden ALTREF at `q-32`), and at the lane-tx64 merge: the 64x64 | |
| 360 | + // root can code a REAL residual now (one TX_64X64 luma transform and | |
| 361 | + // two TX_32X32 chroma ones). `EC_AV1_B64RES=0` restores 8446 / 28548; | |
| 362 | + // `EC_AV1_B64=0` gives the pre-root bytes under this pyramid. | |
| 363 | + // Re-taken on lane-keyq: the pyramid codes its KEY FRAME at | |
| 364 | + // `base_q - 48` now ([`crate::encoder::Pyramid::key_q_offset`]), and | |
| 365 | + // one of these four pictures is the key -- 8590 -> 9778 at q=150 and | |
| 366 | + // 28535 -> 35450 at q=60. `EC_AV1_PYRAMID=8:-32:16:-8:0` restores these. | |
| 367 | + // Re-taken on lane-arfq: the leaves are coded 12 quantizer steps above | |
| 368 | + // base now, not 16 ([`crate::encoder::Pyramid::leaf_q_offset`]) -- 9778 | |
| 369 | + // -> 9835 at q=150 and 35450 -> 35798 at q=60. | |
| 370 | + // `EC_AV1_PYRAMID=8:-32:16:-8:-48` restores these. | |
| 371 | + // Re-taken at the lane-b64b merge, the lane-rdoq merge (`EC_AV1_RDOQ=0` | |
| 372 | + // gave 9808 / 35791) and the lane-i64 merge: the KEY frame -- one of | |
| 373 | + // these four pictures -- offers every superblock a 64x64 intra root | |
| 374 | + // now. `EC_AV1_I64=0` restores 8557 / 33345. | |
| 375 | + // Re-taken on lane-pricer: the inter RD search prices a single | |
| 376 | + // reference through the tree and the neighbour contexts the writer | |
| 377 | + // really codes it with, so every inter picture's reference decisions | |
| 378 | + // move -- 8562 -> 8535 at q=150 and 33357 -> 33221 at q=60. | |
| 379 | + // Re-taken on lane-ctx: the RD pricer reads the writer's own contexts | |
| 380 | + // for `skip`/`is_inter` and for the whole compound reference tree, so | |
| 381 | + // every inter block's cost -- and with it the skip and reference | |
| 382 | + // decisions -- moved: 8535 -> 8311 bytes at q=150 and 33221 -> 33087 | |
| 383 | + // at q=60. Re-taken on lane-ctx2: a single-reference candidate now | |
| 384 | + // pays the `comp_mode = 0` symbol the writer codes ahead of it, so | |
| 385 | + // single and compound are priced against the same syntax -- 8311 -> | |
| 386 | + // 8325 bytes at q=150 and 33087 -> 33014 at q=60. | |
| 387 | + // Re-taken on lane-newmv: the motion search charges its own rate term | |
| 388 | + // at half the block RD lambda ([`crate::motion::MV_SEARCH_LAMBDA`]) | |
| 389 | + // and each subpel stage re-runs from its own winner | |
| 390 | + // ([`crate::motion::MV_SUBPEL_ITERS`]), so every inter block's vector | |
| 391 | + // -- and with it its residual -- moved: 8325 -> 8288 bytes at q=150 | |
| 392 | + // and 33014 -> 33090 at q=60. | |
| 393 | + // Re-taken on lane-dq: preset 0 codes a per-superblock `delta_qindex` | |
| 394 | + // from libaom's objective tpl mapping, so every inter picture's | |
| 395 | + // quantizer grid -- and every decision priced against it -- moved | |
| 396 | + // (8325 -> 8419 / 33014 -> 33029 on its own base); re-taken once more | |
| 397 | + // at the merge of both lanes. | |
| 398 | + // Re-taken on lane-arfq: the top ARF of a mini-GOP codes its | |
| 399 | + // per-superblock `delta_qindex` at 1.5x the preset's strength | |
| 400 | + // ([`crate::speed::DQ_LEVEL_K`]), so the hidden frames' quantizer | |
| 401 | + // grids -- and every decision priced against them -- moved: | |
| 402 | + // 8252 -> 8269 bytes at q=150 and 33053 -> 33044 at q=60. | |
| 403 | + // Re-taken on lane-arfpred: the top ARF is coded from a temporally | |
| 404 | + // FILTERED source ([`crate::speed::ARF_TF`]), so every hidden frame's | |
| 405 | + // pixels -- and the leaves that predict from them -- moved: | |
| 406 | + // 8269 -> 8218 bytes at q=150 and 33044 -> 33017 at q=60. | |
| 407 | + // NOT re-taken on lane-b128: [`SB128_DEFAULT`] stayed off there, so | |
| 408 | + // the shipped stream did not move. | |
| 409 | + // Re-taken on lane-b128m, which flips [`SB128_DEFAULT`] on: every | |
| 410 | + // picture is coded in 128x128 superblocks now, the inter ones | |
| 411 | + // offering the 128 root's own `PARTITION_NONE` block -- 8327 bytes at | |
| 412 | + // q=150 and 33194 at q=60. `EC_AV1_SB128=0` restores 8252 / 33053. | |
| 413 | + // Re-taken at the merge of lane-b128m onto main (128 superblocks on | |
| 414 | + // by default, on top of the ARF temporal filter). | |
| 415 | + // Re-taken on lane-b128r: the 128 root now offers the COMPOUND | |
| 416 | + // candidates the 64 root already did ([`b128_compound`]), so every | |
| 417 | + // inter frame that carries `reference_select` codes different blocks | |
| 418 | + // -- 8354 -> 8364 bytes at q=150 and 33222 -> 33257 at q=60. | |
| 419 | + // `EC_AV1_B128COMP=0` restores 8354 / 33222 exactly. | |
| 420 | + // Re-taken on lane-arftf: that filter's strength swept on the deciding | |
| 421 | + // gate lands at 2, not 3 ([`crate::speed::ARF_TF`]), so the filtered | |
| 422 | + // anchors' pixels moved once more: 8218 -> 8307 bytes at q=150 and | |
| 423 | + // 33017 at q=60 (the same LENGTH, different bytes). | |
| 424 | + // Re-taken at the merge of lane-arftf (ARF filter strength 2) and | |
| 425 | + // lane-rlclamp onto the 128 compound default. | |
| 426 | + // Re-taken on lane-b128hv: the 128 root now also offers PARTITION_HORZ | |
| 427 | + // and PARTITION_VERT ([`b128_rect`]), two 128x64 / 64x128 skip blocks, | |
| 428 | + // so every inter frame whose RD takes one codes a different partition | |
| 429 | + // -- 8290 -> 8291 bytes at q=150. The q=60 pin does NOT move: at that | |
| 430 | + // quantizer the rect cut never wins its own comparison on this clip. | |
| 431 | + // `EC_AV1_B128HV=0` restores 8290 exactly. | |
| 432 | + let pins: [(u8, usize, u64); 2] = [ | |
| 433 | + (150, 23666, 11535713837929557386), | |
| 434 | + (60, 102035, 3886390906684528357), | |
| 435 | + ]; | |
| 436 | + let coded: Vec<(u8, usize, u64)> = pins | |
| 437 | + .iter() | |
| 438 | + .map(|&(q, _, _)| { | |
| 439 | + let e = encode_sequence(&source, q, 0.5).unwrap(); | |
| 440 | + (q, e.stream.len(), fnv(&e.stream)) | |
| 441 | + }) | |
| 442 | + .collect(); | |
| 443 | + crate::speed::set_speed(was); | |
| 444 | + for (&(q, bytes, hash), &got) in pins.iter().zip(&coded) { | |
| 445 | + assert_eq!(got, (q, bytes, hash), "q={q}: the encoder's stream moved"); | |
| 657 | 446 | } |
| 658 | - | |
| 659 | - /// [`our_ladder`] through the streaming facade — the surface the editor's | |
| 660 | - /// export drives (`EC_AV1_GATE_FACADE=1`). With a [`crate::encoder::Pyramid`] | |
| 661 | - /// each stream is also reordered (hidden `ALTREF` first, | |
| 662 | - /// `show_existing_frame` last per group) and each level is coded at its | |
| 663 | - /// own quantizer offset; without one it is the flat ladder, which | |
| 664 | - /// `encoder::tests::the_facade_codes_the_same_bytes_as_encode_sequence` | |
| 665 | - /// pins byte-identical to [`our_ladder`]'s, so this arm must print the | |
| 666 | - /// same BD numbers. Returns the ladder, the wall, per pyramid level over | |
| 667 | - /// the whole ladder how many frames and how many bytes it spent, and the | |
| 668 | - /// pyramid the streams were EFFECTIVELY coded under — the content gate in | |
| 669 | - /// `Av1Encoder::encode_frames` drops a screen-content clip back to the | |
| 670 | - /// flat path, so a requested pyramid can come back `None` here. | |
| 671 | - pub(super) fn our_ladder_facade( | |
| 672 | - name: &str, | |
| 673 | - source: &[Picture], | |
| 674 | - width: usize, | |
| 675 | - height: usize, | |
| 676 | - pyramid: Option<crate::encoder::Pyramid>, | |
| 677 | - ) -> ( | |
| 678 | - Vec<(f64, f64)>, | |
| 679 | - f64, | |
| 680 | - [usize; 4], | |
| 681 | - [usize; 4], | |
| 682 | - Option<crate::encoder::Pyramid>, | |
| 683 | - ) { | |
| 684 | - use crate::encoder::{Av1Encoder, Colour, EncoderConfig, Level}; | |
| 685 | - let slot = |l: Level| match l { | |
| 686 | - Level::Key => 0, | |
| 687 | - Level::Arf => 1, | |
| 688 | - Level::Leaf => 2, | |
| 689 | - Level::ShowExisting => 3, | |
| 690 | - }; | |
| 691 | - let mut ladder = Vec::new(); | |
| 692 | - let mut wall = 0.0; | |
| 693 | - let mut effective = None; | |
| 694 | - let (mut counts, mut bytes) = ([0usize; 4], [0usize; 4]); | |
| 695 | - for &q in &[150u8, 120, 90, 60] { | |
| 696 | - let config = EncoderConfig { | |
| 697 | - width, | |
| 698 | - height, | |
| 699 | - base_q_idx: q, | |
| 700 | - gop: source.len(), | |
| 701 | - colour: Colour::Unspecified, | |
| 702 | - tile_cols_log2: 0, | |
| 703 | - tile_rows_log2: 0, | |
| 704 | - }; | |
| 705 | - let start = std::time::Instant::now(); | |
| 706 | - let mut enc = match pyramid { | |
| 707 | - None => Av1Encoder::new(config).unwrap(), | |
| 708 | - Some(p) => Av1Encoder::with_pyramid(config, p).unwrap(), | |
| 709 | - }; | |
| 710 | - let mut packets = Vec::new(); | |
| 711 | - for picture in source { | |
| 712 | - packets.extend(enc.encode_frames(picture).unwrap()); | |
| 713 | - } | |
| 714 | - packets.extend(enc.flush().unwrap()); | |
| 715 | - wall += start.elapsed().as_secs_f64(); | |
| 716 | - effective = enc.pyramid(); | |
| 717 | - let mut stream = Vec::new(); | |
| 718 | - for p in &packets { | |
| 719 | - counts[slot(p.level)] += 1; | |
| 720 | - bytes[slot(p.level)] += p.data.len(); | |
| 721 | - stream.extend_from_slice(&p.data); | |
| 722 | - } | |
| 723 | - // [[gate-blind-to-hidden-frames]]: a reordered stream is only | |
| 724 | - // correct if the DISPLAY-order output still has one frame per | |
| 725 | - // source picture, in the right order -- checked against our own | |
| 726 | - // decoder as well as ffmpeg's, both below. | |
| 727 | - let ours = crate::stream::decode_stream(&stream).expect("our decoder"); | |
| 447 | +} | |
| 448 | + | |
| 449 | +/// lane-refs: THE FRAME FILTER REACHES THE PIXELS. `mc::predict` used to | |
| 450 | +/// hardwire the REGULAR kernel, so the encoder could not have coded a | |
| 451 | +/// SMOOTH or SHARP frame even if the header had said so -- the search, | |
| 452 | +/// the trials, the recon and the frame header now all read | |
| 453 | +/// `FrameCtx::interp_filter`. Each of the three kernels codes its own | |
| 454 | +/// distinct stream (a filter that never reached the prediction would code | |
| 455 | +/// the same bytes as REGULAR, class `symbol consumption gap`), and ffmpeg | |
| 456 | +/// reconstructs every frame of each of them exactly, which is what proves | |
| 457 | +/// the header and the prediction agree. | |
| 458 | +#[test] | |
| 459 | +fn each_frame_interpolation_filter_codes_its_own_stream_ffmpeg_decodes_exactly() { | |
| 460 | + let _knobs = crate::speed::knob_write(); | |
| 461 | + let (width, height) = (256usize, 128usize); | |
| 462 | + // A HALF-PEL pan: an integer-pel one reads no filter tap at all, so | |
| 463 | + // all three kernels would code the same bytes and the test would pass | |
| 464 | + // on a wiring that does nothing (class `fixture proves the symbol, not | |
| 465 | + // the signal`). `panned_test_card` shifts by whole pixels, so the | |
| 466 | + // search finds the sub-pel positions off the reconstruction instead: | |
| 467 | + // three frames of a slow diagonal pan. | |
| 468 | + let pictures: Vec<Picture> = (0..3) | |
| 469 | + .map(|i| panned_test_card(width, height, i * 3)) | |
| 470 | + .collect(); | |
| 471 | + let mut streams = Vec::new(); | |
| 472 | + for filter in [ | |
| 473 | + ec_av1_syntax::InterpolationFilter::Eighttap, | |
| 474 | + ec_av1_syntax::InterpolationFilter::EighttapSmooth, | |
| 475 | + ec_av1_syntax::InterpolationFilter::EighttapSharp, | |
| 476 | + ] { | |
| 477 | + set_frame_interp(Some(filter)); | |
| 478 | + let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 479 | + let encoded = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx) | |
| 480 | + .unwrap_or_else(|e| panic!("{filter:?}: {e}")); | |
| 481 | + let decoded = ffmpeg_decode_sequence(&encoded.stream, width, height, 3); | |
| 482 | + assert_eq!(decoded.len(), 3, "{filter:?}: decoded frame count"); | |
| 483 | + for (i, (frame, decoded)) in encoded.frames.iter().zip(&decoded).enumerate() { | |
| 728 | 484 | assert_eq!( |
| 729 | - ours.len(), | |
| 730 | - source.len(), | |
| 731 | - "{name} q={q}: our display-order count" | |
| 732 | - ); | |
| 733 | - let decoded = ffmpeg_decode_sequence(&stream, width, height, source.len()); | |
| 734 | - for (i, (d, o)) in decoded.iter().zip(&ours).enumerate() { | |
| 735 | - if let Some((plane, s, got, want)) = first_plane_mismatch(d, o) { | |
| 736 | - panic!( | |
| 737 | - "{name} q={q} display frame {i} plane {plane} sample {s}: ffmpeg \ | |
| 738 | - decoded {got}, our decoder decoded {want}" | |
| 739 | - ); | |
| 740 | - } | |
| 741 | - } | |
| 742 | - let mean: f64 = decoded | |
| 743 | - .iter() | |
| 744 | - .zip(source) | |
| 745 | - .map(|(d, s)| psnr_all(d, s)) | |
| 746 | - .sum::<f64>() | |
| 747 | - / source.len() as f64; | |
| 748 | - ladder.push((mean, (stream.len() as f64).log10())); | |
| 749 | - } | |
| 750 | - ladder.sort_by(|a, b| a.0.total_cmp(&b.0)); | |
| 751 | - (ladder, wall, counts, bytes, effective) | |
| 752 | - } | |
| 753 | - | |
| 754 | - /// Byte-exactness gate for encoder work that is meant to change only | |
| 755 | - /// how long the encoder takes. | |
| 756 | - /// | |
| 757 | - /// The BD gate above measures quality, which a speed lane can move by a | |
| 758 | - /// hair without failing anything; this pins the streams themselves. | |
| 759 | - /// Re-measured on the lane-av1lr merge with main d5fc99e0 (per-64x64 | |
| 760 | - /// `cdef_idx` literals and per-unit loop restoration syntax are new bits | |
| 761 | - /// in the tile) and again on lane-av1mv's merge of it: an extra | |
| 762 | - /// reference's `NEWMV` is a coded-bits change too, judged by the BD gate | |
| 763 | - /// above, not by this pin. Re-pinned on lane-av1price2: the search now | |
| 764 | - /// prices coefficients against the tables the frame's writer really | |
| 765 | - /// starts from on every non-screen frame (`tile::arm_pricing_cdfs`), a | |
| 766 | - /// decision change the BD gate judges. Re-pinned again on | |
| 767 | - /// lane-av1skipctx: the search now prices `txb_skip`/`dc_sign` at the | |
| 768 | - /// real neighbour contexts ([`Plane::coef_ctx`]) instead of zero, which | |
| 769 | - /// is the same kind of decision change. Re-pinned on lane-av1lambda: | |
| 770 | - /// [`LAMBDA_SCALE`] moved 0.1 -> 0.05, so every RD decision in the | |
| 771 | - /// search moved with it. Re-pinned on lane-av1rejudge: local warp is on | |
| 772 | - /// by default ([`warp_on`], a sequence/frame header bit and a new | |
| 773 | - /// motion_mode symbol on eligible blocks) and | |
| 774 | - /// [`LEAF_SECOND_NEW_MARGIN`] moved 0.8 -> 1.2. Re-pinned on lane-av1tpl: | |
| 775 | - /// every inter frame's superblocks now code at their own lambda | |
| 776 | - /// ([`TPL_STRENGTH`]), so every RD decision in an inter frame moved. | |
| 777 | - /// Re-pinned on lane-av1resweep: [`LAMBDA_SCALE`] moved 0.05 -> 0.0275 | |
| 778 | - /// and the two var-tx depth searches ([`tx32_depth_search`], | |
| 779 | - /// [`compound_var_tx`]) are on by default, all three re-judged on the | |
| 780 | - /// native gate's real film rows. | |
| 781 | - /// Re-pinned on lane-av1cfl: the chroma search offers `UV_CFL_PRED`, so | |
| 782 | - /// every block whose chroma takes it codes a different mode symbol, two | |
| 783 | - /// alpha symbols and different chroma coefficients. `EC_AV1_CFL=0` | |
| 784 | - /// restores the previous streams. Re-pinned again in the same lane once | |
| 785 | - /// directional luma winners searched their `angle_delta_y` | |
| 786 | - /// (`EC_AV1_ANGLE=0` restores that half). | |
| 787 | - #[test] | |
| 788 | - fn the_encoders_own_streams_are_byte_identical_to_their_pins() { | |
| 789 | - // These are DEFAULT-PRESET pins: a speed preset switches search levers | |
| 790 | - // off, so it legitimately moves every byte. Encode at speed 0 whatever | |
| 791 | - // `EC_AV1_SPEED` says (write guard: the preset is process-global). | |
| 792 | - let _knobs = crate::speed::knob_write(); | |
| 793 | - let was = crate::speed::speed(); | |
| 794 | - crate::speed::set_speed(0); | |
| 795 | - // lane-av1clipprobe: the bare `clip.exists()` -> SKIP had no env escape, | |
| 796 | - // so a tree with no root `fixtures/` reported this gate green having | |
| 797 | - // compared nothing at all. | |
| 798 | - let clip = ec_testkit::fixture("open/sintel_trailer-1080p.mp4"); | |
| 799 | - let source = clip_frames(clip.to_str().unwrap(), "20", 640, 384, 4); | |
| 800 | - // FNV-1a over the stream: a witness that every coded bit is where it | |
| 801 | - // was, which a byte count alone is not. | |
| 802 | - let fnv = |b: &[u8]| { | |
| 803 | - b.iter().fold(0xcbf2_9ce4_8422_2325u64, |h, &v| { | |
| 804 | - (h ^ u64::from(v)).wrapping_mul(0x0000_0100_0000_01b3) | |
| 805 | - }) | |
| 806 | - }; | |
| 807 | - // Re-taken on lane-av1pyrdef: `encode_sequence` codes this (non-screen) | |
| 808 | - // clip under the coding pyramid now -- one hidden ALTREF per mini-GOP | |
| 809 | - // of 4, its leaves at q+8 and a `show_existing_frame` header per | |
| 810 | - // group. 7299 -> 8194 bytes at q=150 and 26804 -> 28285 at q=60 over | |
| 811 | - // four frames; four pictures is one short mini-GOP, which is the | |
| 812 | - // shape that pays least (the ARF's own quality has no later group to | |
| 813 | - // carry it), so this is not the BD gate's number. | |
| 814 | - // Re-taken again on lane-av1cfl: the chroma search offers | |
| 815 | - // `UV_CFL_PRED` and directional luma winners search `angle_delta_y`, | |
| 816 | - // so every block taking either codes different syntax and different | |
| 817 | - // coefficients -- 8194 -> 7321 at q=150 and 28285 -> 27285 at q=60. | |
| 818 | - // `EC_AV1_CFL=0` / `EC_AV1_ANGLE=0` restore each half. | |
| 819 | - // Re-taken on lane-pyr3: the mini-GOP of the default pyramid is 16 | |
| 820 | - // pictures at `q-24` / `q+16` now (the sweep in [`Pyramid::default`]), | |
| 821 | - // so these four pictures code as one truncated group -- a hidden | |
| 822 | - // ALTREF at `q-24` and three leaves at `q+16` -- instead of one | |
| 823 | - // mini-GOP of 4 at `q-16` / `q+8`: 7373 -> 8076 at q=150 and | |
| 824 | - // 27074 -> 27585 at q=60. `EC_AV1_PYRAMID=4:-16:8` restores these. | |
| 825 | - // Re-taken on lane-fintra: the sequence header sets | |
| 826 | - // `enable_filter_intra`, so every DC_PRED intra block of at most | |
| 827 | - // 32x32 without a luma palette carries a `use_filter_intra` flag and | |
| 828 | - // the blocks that take one code a filter-intra mode, a different | |
| 829 | - // prediction and different coefficients -- 7321 -> 7373 at q=150 and | |
| 830 | - // 27285 -> 27074 at q=60. `EC_AV1_FILTER_INTRA=0` restores these. | |
| 831 | - // Re-taken on lane-b64 (64x64 skip root), at the lane-pyr4 merge | |
| 832 | - // (default pyramid `8:-32:16`, one truncated group of 8 with its | |
| 833 | - // hidden ALTREF at `q-32`), and at the lane-tx64 merge: the 64x64 | |
| 834 | - // root can code a REAL residual now (one TX_64X64 luma transform and | |
| 835 | - // two TX_32X32 chroma ones). `EC_AV1_B64RES=0` restores 8446 / 28548; | |
| 836 | - // `EC_AV1_B64=0` gives the pre-root bytes under this pyramid. | |
| 837 | - // Re-taken on lane-keyq: the pyramid codes its KEY FRAME at | |
| 838 | - // `base_q - 48` now ([`crate::encoder::Pyramid::key_q_offset`]), and | |
| 839 | - // one of these four pictures is the key -- 8590 -> 9778 at q=150 and | |
| 840 | - // 28535 -> 35450 at q=60. `EC_AV1_PYRAMID=8:-32:16:-8:0` restores these. | |
| 841 | - // Re-taken on lane-arfq: the leaves are coded 12 quantizer steps above | |
| 842 | - // base now, not 16 ([`crate::encoder::Pyramid::leaf_q_offset`]) -- 9778 | |
| 843 | - // -> 9835 at q=150 and 35450 -> 35798 at q=60. | |
| 844 | - // `EC_AV1_PYRAMID=8:-32:16:-8:-48` restores these. | |
| 845 | - // Re-taken at the lane-b64b merge, the lane-rdoq merge (`EC_AV1_RDOQ=0` | |
| 846 | - // gave 9808 / 35791) and the lane-i64 merge: the KEY frame -- one of | |
| 847 | - // these four pictures -- offers every superblock a 64x64 intra root | |
| 848 | - // now. `EC_AV1_I64=0` restores 8557 / 33345. | |
| 849 | - // Re-taken on lane-pricer: the inter RD search prices a single | |
| 850 | - // reference through the tree and the neighbour contexts the writer | |
| 851 | - // really codes it with, so every inter picture's reference decisions | |
| 852 | - // move -- 8562 -> 8535 at q=150 and 33357 -> 33221 at q=60. | |
| 853 | - // Re-taken on lane-ctx: the RD pricer reads the writer's own contexts | |
| 854 | - // for `skip`/`is_inter` and for the whole compound reference tree, so | |
| 855 | - // every inter block's cost -- and with it the skip and reference | |
| 856 | - // decisions -- moved: 8535 -> 8311 bytes at q=150 and 33221 -> 33087 | |
| 857 | - // at q=60. Re-taken on lane-ctx2: a single-reference candidate now | |
| 858 | - // pays the `comp_mode = 0` symbol the writer codes ahead of it, so | |
| 859 | - // single and compound are priced against the same syntax -- 8311 -> | |
| 860 | - // 8325 bytes at q=150 and 33087 -> 33014 at q=60. | |
| 861 | - // Re-taken on lane-newmv: the motion search charges its own rate term | |
| 862 | - // at half the block RD lambda ([`crate::motion::MV_SEARCH_LAMBDA`]) | |
| 863 | - // and each subpel stage re-runs from its own winner | |
| 864 | - // ([`crate::motion::MV_SUBPEL_ITERS`]), so every inter block's vector | |
| 865 | - // -- and with it its residual -- moved: 8325 -> 8288 bytes at q=150 | |
| 866 | - // and 33014 -> 33090 at q=60. | |
| 867 | - // Re-taken on lane-dq: preset 0 codes a per-superblock `delta_qindex` | |
| 868 | - // from libaom's objective tpl mapping, so every inter picture's | |
| 869 | - // quantizer grid -- and every decision priced against it -- moved | |
| 870 | - // (8325 -> 8419 / 33014 -> 33029 on its own base); re-taken once more | |
| 871 | - // at the merge of both lanes. | |
| 872 | - // Re-taken on lane-arfq: the top ARF of a mini-GOP codes its | |
| 873 | - // per-superblock `delta_qindex` at 1.5x the preset's strength | |
| 874 | - // ([`crate::speed::DQ_LEVEL_K`]), so the hidden frames' quantizer | |
| 875 | - // grids -- and every decision priced against them -- moved: | |
| 876 | - // 8252 -> 8269 bytes at q=150 and 33053 -> 33044 at q=60. | |
| 877 | - // Re-taken on lane-arfpred: the top ARF is coded from a temporally | |
| 878 | - // FILTERED source ([`crate::speed::ARF_TF`]), so every hidden frame's | |
| 879 | - // pixels -- and the leaves that predict from them -- moved: | |
| 880 | - // 8269 -> 8218 bytes at q=150 and 33044 -> 33017 at q=60. | |
| 881 | - // NOT re-taken on lane-b128: [`SB128_DEFAULT`] stayed off there, so | |
| 882 | - // the shipped stream did not move. | |
| 883 | - // Re-taken on lane-b128m, which flips [`SB128_DEFAULT`] on: every | |
| 884 | - // picture is coded in 128x128 superblocks now, the inter ones | |
| 885 | - // offering the 128 root's own `PARTITION_NONE` block -- 8327 bytes at | |
| 886 | - // q=150 and 33194 at q=60. `EC_AV1_SB128=0` restores 8252 / 33053. | |
| 887 | - // Re-taken at the merge of lane-b128m onto main (128 superblocks on | |
| 888 | - // by default, on top of the ARF temporal filter). | |
| 889 | - // Re-taken on lane-b128r: the 128 root now offers the COMPOUND | |
| 890 | - // candidates the 64 root already did ([`b128_compound`]), so every | |
| 891 | - // inter frame that carries `reference_select` codes different blocks | |
| 892 | - // -- 8354 -> 8364 bytes at q=150 and 33222 -> 33257 at q=60. | |
| 893 | - // `EC_AV1_B128COMP=0` restores 8354 / 33222 exactly. | |
| 894 | - // Re-taken on lane-arftf: that filter's strength swept on the deciding | |
| 895 | - // gate lands at 2, not 3 ([`crate::speed::ARF_TF`]), so the filtered | |
| 896 | - // anchors' pixels moved once more: 8218 -> 8307 bytes at q=150 and | |
| 897 | - // 33017 at q=60 (the same LENGTH, different bytes). | |
| 898 | - // Re-taken at the merge of lane-arftf (ARF filter strength 2) and | |
| 899 | - // lane-rlclamp onto the 128 compound default. | |
| 900 | - // Re-taken on lane-b128hv: the 128 root now also offers PARTITION_HORZ | |
| 901 | - // and PARTITION_VERT ([`b128_rect`]), two 128x64 / 64x128 skip blocks, | |
| 902 | - // so every inter frame whose RD takes one codes a different partition | |
| 903 | - // -- 8290 -> 8291 bytes at q=150. The q=60 pin does NOT move: at that | |
| 904 | - // quantizer the rect cut never wins its own comparison on this clip. | |
| 905 | - // `EC_AV1_B128HV=0` restores 8290 exactly. | |
| 906 | - let pins: [(u8, usize, u64); 2] = [ | |
| 907 | - (150, 23666, 11535713837929557386), | |
| 908 | - (60, 102035, 3886390906684528357), | |
| 909 | - ]; | |
| 910 | - let coded: Vec<(u8, usize, u64)> = pins | |
| 911 | - .iter() | |
| 912 | - .map(|&(q, _, _)| { | |
| 913 | - let e = encode_sequence(&source, q, 0.5).unwrap(); | |
| 914 | - (q, e.stream.len(), fnv(&e.stream)) | |
| 915 | - }) | |
| 916 | - .collect(); | |
| 917 | - crate::speed::set_speed(was); | |
| 918 | - for (&(q, bytes, hash), &got) in pins.iter().zip(&coded) { | |
| 919 | - assert_eq!(got, (q, bytes, hash), "q={q}: the encoder's stream moved"); | |
| 920 | - } | |
| 921 | - } | |
| 922 | - | |
| 923 | - /// A ladder is only a ladder if both axes rise together. | |
| 924 | - pub(super) fn assert_monotone(name: &str, ladder: &[(f64, f64)]) { | |
| 925 | - assert_eq!(ladder.len(), 4, "{name}: wanted four quality points"); | |
| 926 | - for w in ladder.windows(2) { | |
| 927 | - assert!( | |
| 928 | - w[1].0 > w[0].0 && w[1].1 > w[0].1, | |
| 929 | - "{name}: not monotone, {ladder:?}" | |
| 485 | + decoded.y, frame.reconstruction.y, | |
| 486 | + "{filter:?} frame {i}: luma" | |
| 930 | 487 | ); |
| 488 | + assert_eq!(decoded.u, frame.reconstruction.u, "{filter:?} frame {i}: U"); | |
| 489 | + assert_eq!(decoded.v, frame.reconstruction.v, "{filter:?} frame {i}: V"); | |
| 931 | 490 | } |
| 491 | + streams.push((filter, encoded.stream)); | |
| 932 | 492 | } |
| 933 | - | |
| 934 | - /// Which var-tx depth this clip's INTER blocks resolved to (lane-av1tx2, | |
| 935 | - /// split by block class in lane-av1txdepth): depth 0 is one transform over | |
| 936 | - /// the whole block, 1 its four halves; the classes are the 16x16/8x8 | |
| 937 | - /// leaves and the 32x32 root, each single-reference or compound. A class | |
| 938 | - /// with no counts at all never reached `commit_inter_luma` -- which is | |
| 939 | - /// what its knob being off looks like (class `gate-blind-to-feature`). | |
| 940 | - pub(super) fn print_inter_tx_census(name: &str) { | |
| 941 | - let splits = take_inter_tx_split_hits(); | |
| 942 | - let total: usize = splits.iter().sum(); | |
| 943 | - let row = |label: &str, base: usize| { | |
| 944 | - let (n0, n1) = (splits[base], splits[base + 1]); | |
| 945 | - format!( | |
| 946 | - "{label} 0={n0} 1={n1} ({:.1}% split)", | |
| 947 | - 100.0 * n1 as f64 / (n0 + n1).max(1) as f64 | |
| 948 | - ) | |
| 949 | - }; | |
| 950 | - eprintln!( | |
| 951 | - "{name}: inter var-tx depths of {total} blocks -- {} | {} | {} | {}", | |
| 952 | - row("leaf single", 0), | |
| 953 | - row("leaf compound", 2), | |
| 954 | - row("32x32 single", 4), | |
| 955 | - row("32x32 compound", 6), | |
| 956 | - ); | |
| 957 | - // lane-txrd: which types the two searches actually COMMITTED over | |
| 958 | - // this row's four encodes -- the gate could not say whether a type | |
| 959 | - // search fired at all (class `gate-blind-to-feature`). | |
| 960 | - const NAMES: [&str; 16] = [ | |
| 961 | - "IDTX", | |
| 962 | - "DCT_DCT", | |
| 963 | - "ADST_ADST", | |
| 964 | - "ADST_DCT", | |
| 965 | - "DCT_ADST", | |
| 966 | - "V_DCT", | |
| 967 | - "H_DCT", | |
| 968 | - "FLIPADST_DCT", | |
| 969 | - "DCT_FLIPADST", | |
| 970 | - "FLIPADST_FLIPADST", | |
| 971 | - "ADST_FLIPADST", | |
| 972 | - "FLIPADST_ADST", | |
| 973 | - "V_ADST", | |
| 974 | - "H_ADST", | |
| 975 | - "V_FLIPADST", | |
| 976 | - "H_FLIPADST", | |
| 977 | - ]; | |
| 978 | - let name_of = |t: usize| NAMES[t]; | |
| 979 | - for (label, hits) in [ | |
| 980 | - ("inter", take_inter_tx_type_hits()), | |
| 981 | - ("intra", take_tx_type_hits()), | |
| 982 | - ] { | |
| 983 | - let total: usize = hits.iter().sum(); | |
| 984 | - let live: Vec<String> = hits | |
| 985 | - .iter() | |
| 986 | - .enumerate() | |
| 987 | - .filter(|&(_, &n)| n > 0) | |
| 988 | - .map(|(t, &n)| { | |
| 989 | - format!( | |
| 990 | - "{}={n} ({:.1}%)", | |
| 991 | - name_of(t), | |
| 992 | - 100.0 * n as f64 / total.max(1) as f64 | |
| 993 | - ) | |
| 994 | - }) | |
| 995 | - .collect(); | |
| 996 | - eprintln!( | |
| 997 | - "{name}: {label} tx_type of {total} units -- {}", | |
| 998 | - live.join(" ") | |
| 999 | - ); | |
| 1000 | - } | |
| 1001 | - let t = take_txrd_stats(); | |
| 1002 | - if t[0] > 0 { | |
| 1003 | - eprintln!( | |
| 1004 | - "{name}: txrd flat decisions={} chosen sse={} bits={:.0} | DCT_DCT sse={} \ | |
| 1005 | - bits={:.0} (dsse {:+.2}%, dbits {:+.2}%)", | |
| 1006 | - t[0], | |
| 1007 | - t[1], | |
| 1008 | - t[3] as f64 / 64.0, | |
| 1009 | - t[2], | |
| 1010 | - t[4] as f64 / 64.0, | |
| 1011 | - 100.0 * (t[1] as f64 - t[2] as f64) / t[2].max(1) as f64, | |
| 1012 | - 100.0 * (t[3] as f64 - t[4] as f64) / t[4].max(1) as f64, | |
| 1013 | - ); | |
| 1014 | - eprintln!( | |
| 1015 | - "{name}: txrd DCT_DCT re-predicted HERE sse={} bits={:.0} (vs the passed-in \ | |
| 1016 | - flat: dsse {:+.2}%, dbits {:+.2}%)", | |
| 1017 | - t[5], | |
| 1018 | - t[6] as f64 / 64.0, | |
| 1019 | - 100.0 * (t[5] as f64 - t[2] as f64) / t[2].max(1) as f64, | |
| 1020 | - 100.0 * (t[6] as f64 - t[4] as f64) / t[4].max(1) as f64, | |
| 1021 | - ); | |
| 493 | + set_frame_interp(None); | |
| 494 | + for (i, (fa, a)) in streams.iter().enumerate() { | |
| 495 | + for (fb, b) in &streams[i + 1..] { | |
| 496 | + assert_ne!(a, b, "{fa:?} and {fb:?} coded the same bytes"); | |
| 1022 | 497 | } |
| 1023 | 498 | } |
| 1024 | - | |
| 1025 | - /// The video stream's coded size, from ffprobe. | |
| 1026 | - pub(super) fn probe_dims(clip: &str) -> Option<(usize, usize)> { | |
| 1027 | - crate::probe::dims(clip) | |
| 1028 | - } | |
| 1029 | - | |
| 1030 | - /// `EC_AV1_NATIVE_CROP=<width>x<height>`: the native gate's window at a | |
| 1031 | - /// size of the reader's choosing instead of [`crate::probe::gate_crop`]'s | |
| 1032 | - /// superblock-aligned one, still centred and still even for 4:2:0. | |
| 1033 | - /// | |
| 1034 | - /// WHY IT EXISTS (lane-sse): `gate_crop` rounds DOWN to whole 128-wide | |
| 1035 | - /// superblocks by design, so no default gate row has a block the frame | |
| 1036 | - /// edge cuts through -- while every arbitrary export size does (3840x1608 | |
| 1037 | - /// is 25.1 superblock rows, 1920x1080 is 8.4). `EC_AV1_NATIVE_CROP= | |
| 1038 | - /// 1920x1080` is the straddling arm the edge-clipped distortion score is | |
| 1039 | - /// read on. | |
| 1040 | - pub(super) fn native_crop_override(clip: &str) -> Option<(String, usize, usize)> { | |
| 1041 | - let spec = std::env::var("EC_AV1_NATIVE_CROP").ok()?; | |
| 1042 | - let (w, h) = spec | |
| 1043 | - .split_once('x') | |
| 1044 | - .expect("EC_AV1_NATIVE_CROP is <width>x<height>"); | |
| 1045 | - let (cw, ch): (usize, usize) = ( | |
| 1046 | - w.parse().expect("crop width"), | |
| 1047 | - h.parse().expect("crop height"), | |
| 1048 | - ); | |
| 1049 | - let (nw, nh) = crate::probe::dims(clip)?; | |
| 1050 | - assert!(cw <= nw && ch <= nh, "{cw}x{ch} does not fit in {nw}x{nh}"); | |
| 1051 | - let (x, y) = (((nw - cw) / 2) & !1, ((nh - ch) / 2) & !1); | |
| 1052 | - Some((format!("crop={cw}:{ch}:{x}:{y}"), cw, ch)) | |
| 1053 | - } | |
| 1054 | - | |
| 1055 | - /// The probe arms the gate's source (lane-probe, class `instrument | |
| 1056 | - /// disagrees with the gate`). `examples/enc_probe` built its own ffmpeg | |
| 1057 | - /// command line and had no `-ss`, so it read film B from frame 0 -- a | |
| 1058 | - /// black leader -- and coded 59 kB where the gate's own ladder point | |
| 1059 | - /// coded 89 kB of the same title; every census taken through it was | |
| 1060 | - /// probe-relative. Both now call [`crate::probe::source`]; this pins that | |
| 1061 | - /// the shared loader honours the seek (arming the probe's way and the | |
| 1062 | - /// gate's way gives byte-identical streams, and dropping the seek does | |
| 1063 | - /// not), on a synthetic clip whose content moves over time. | |
| 1064 | - #[test] | |
| 1065 | - fn the_probe_arms_the_gates_source() { | |
| 1066 | - let _knobs = crate::speed::knob_write(); | |
| 1067 | - let dir = std::env::temp_dir().join(format!("ec-av1-probe-{}", std::process::id())); | |
| 1068 | - std::fs::create_dir_all(&dir).unwrap(); | |
| 1069 | - let clip = dir.join("testsrc2.y4m"); | |
| 1070 | - // 384x202: neither side is a multiple of 128, so the gate's centre | |
| 1071 | - // window is a real derivation and not the frame itself -- exactly the | |
| 1072 | - // shape film B has (3840x1608, never 3840x2160). | |
| 1073 | - let ok = ec_testkit::ffmpeg() | |
| 1074 | - .args([ | |
| 1075 | - "-v", | |
| 1076 | - "error", | |
| 1077 | - "-y", | |
| 1078 | - "-f", | |
| 1079 | - "lavfi", | |
| 1080 | - "-i", | |
| 1081 | - "testsrc2=size=384x202:rate=10", | |
| 1082 | - ]) | |
| 1083 | - .args(["-frames:v", "20", "-pix_fmt", "yuv420p"]) | |
| 1084 | - .arg(&clip) | |
| 1085 | - .status() | |
| 1086 | - .expect("ffmpeg failed to run") | |
| 1087 | - .success(); | |
| 1088 | - assert!(ok, "ffmpeg could not write the synthetic clip"); | |
| 1089 | - let path = clip.to_str().unwrap(); | |
| 1090 | - | |
| 1091 | - // The window: superblock-aligned, centred, even offsets. | |
| 1092 | - let (vf, w, h) = crate::probe::gate_crop(path); | |
| 1093 | - assert_eq!((vf.as_str(), w, h), ("crop=384:128:0:36", 384, 128)); | |
| 1094 | - | |
| 1095 | - let (seek, q) = ("00:00:01", 150u8); | |
| 1096 | - let gate = clip_frames_vf(path, seek, &vf, w, h, 6); | |
| 1097 | - let probe = crate::probe::source(path, seek, &vf, w, h, 6); | |
| 1098 | - assert!( | |
| 1099 | - gate.iter() | |
| 1100 | - .zip(&probe) | |
| 1101 | - .all(|(a, b)| a.y == b.y && a.u == b.u && a.v == b.v), | |
| 1102 | - "the probe's source differs from the gate's at the same window" | |
| 1103 | - ); | |
| 1104 | - let bytes = |src: &[Picture]| { | |
| 1105 | - encode_sequence_with_ctx(src, q, 0.5, &crate::decode::FrameCtx::for_encoder()) | |
| 1106 | - .unwrap() | |
| 1107 | - .stream | |
| 1108 | - }; | |
| 499 | +} | |
| 500 | + | |
| 501 | +/// lane-hpmv: THE EIGHTH-PEL VECTOR REACHES THE STREAM. With | |
| 502 | +/// `allow_high_precision_mv` off the writer refuses an odd eighth-pel | |
| 503 | +/// residual outright (`round_to_valid_mv` rounds it away first), so the | |
| 504 | +/// finest vector the encoder could commit to was a quarter pel. With the | |
| 505 | +/// header bit on, the writer codes an `mv_hp`/`mv_class0_hp` symbol per | |
| 506 | +/// non-zero component and the search's fourth stage refines to the | |
| 507 | +/// eighth: this asserts ZERO hp symbols in the off arm, non-zero in the | |
| 508 | +/// on arm, and -- the part that makes it a signal rather than a symbol | |
| 509 | +/// count (class `fixture proves the symbol, not the signal`) -- that some | |
| 510 | +/// of them come out ZERO, i.e. name a vector the off arm cannot code at | |
| 511 | +/// all. Both streams are decoded by ffmpeg AND by this crate's own | |
| 512 | +/// decoder and asserted sample-exact against the encoder's own | |
| 513 | +/// reconstruction, which is what proves the header bit and the symbols | |
| 514 | +/// agree. | |
| 515 | +#[test] | |
| 516 | +fn a_high_precision_frame_codes_eighth_pel_motion_vectors_both_decoders_read() { | |
| 517 | + let _knobs = crate::speed::knob_write(); | |
| 518 | + let (width, height) = (256usize, 128usize); | |
| 519 | + let pictures: Vec<Picture> = (0..3) | |
| 520 | + .map(|i| panned_test_card(width, height, i * 3)) | |
| 521 | + .collect(); | |
| 522 | + let mut arms = Vec::new(); | |
| 523 | + for hp in [false, true] { | |
| 524 | + set_high_precision_mv(Some(hp)); | |
| 525 | + let _ = crate::tile::take_hp_symbols(); | |
| 526 | + let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 527 | + let encoded = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx) | |
| 528 | + .unwrap_or_else(|e| panic!("hp={hp}: {e}")); | |
| 529 | + let (symbols, eighth) = crate::tile::take_hp_symbols(); | |
| 530 | + let decoded = ffmpeg_decode_sequence(&encoded.stream, width, height, pictures.len()); | |
| 531 | + let ours = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | |
| 532 | + assert_eq!(decoded.len(), pictures.len(), "hp={hp}: ffmpeg frame count"); | |
| 1109 | 533 | assert_eq!( |
| 1110 | - bytes(&gate), | |
| 1111 | - bytes(&probe), | |
| 1112 | - "probe and gate code different bytes" | |
| 1113 | - ); | |
| 1114 | - // The two witnesses that both halves of the arming reach ffmpeg: the | |
| 1115 | - // seek, and the crop's own offset (the film-B defect in miniature -- | |
| 1116 | - // the probe was reading `crop=..:568` of a 1608-high frame). | |
| 1117 | - let unseeked = crate::probe::source(path, "0", &vf, w, h, 6); | |
| 1118 | - assert_ne!( | |
| 1119 | - bytes(&gate), | |
| 1120 | - bytes(&unseeked), | |
| 1121 | - "seeked and unseeked arming coded the same bytes -- the seek is inert" | |
| 534 | + ours.len(), | |
| 535 | + pictures.len(), | |
| 536 | + "hp={hp}: our decoder frame count" | |
| 1122 | 537 | ); |
| 1123 | - let offset = crate::probe::source(path, seek, "crop=384:128:0:0", w, h, 6); | |
| 1124 | - assert_ne!( | |
| 1125 | - bytes(&gate), | |
| 1126 | - bytes(&offset), | |
| 1127 | - "centred and top-aligned windows coded the same bytes -- the crop is inert" | |
| 1128 | - ); | |
| 1129 | - std::fs::remove_dir_all(&dir).ok(); | |
| 1130 | - } | |
| 1131 | - | |
| 1132 | - /// lane-refs: THE FRAME FILTER REACHES THE PIXELS. `mc::predict` used to | |
| 1133 | - /// hardwire the REGULAR kernel, so the encoder could not have coded a | |
| 1134 | - /// SMOOTH or SHARP frame even if the header had said so -- the search, | |
| 1135 | - /// the trials, the recon and the frame header now all read | |
| 1136 | - /// `FrameCtx::interp_filter`. Each of the three kernels codes its own | |
| 1137 | - /// distinct stream (a filter that never reached the prediction would code | |
| 1138 | - /// the same bytes as REGULAR, class `symbol consumption gap`), and ffmpeg | |
| 1139 | - /// reconstructs every frame of each of them exactly, which is what proves | |
| 1140 | - /// the header and the prediction agree. | |
| 1141 | - #[test] | |
| 1142 | - fn each_frame_interpolation_filter_codes_its_own_stream_ffmpeg_decodes_exactly() { | |
| 1143 | - let _knobs = crate::speed::knob_write(); | |
| 1144 | - let (width, height) = (256usize, 128usize); | |
| 1145 | - // A HALF-PEL pan: an integer-pel one reads no filter tap at all, so | |
| 1146 | - // all three kernels would code the same bytes and the test would pass | |
| 1147 | - // on a wiring that does nothing (class `fixture proves the symbol, not | |
| 1148 | - // the signal`). `panned_test_card` shifts by whole pixels, so the | |
| 1149 | - // search finds the sub-pel positions off the reconstruction instead: | |
| 1150 | - // three frames of a slow diagonal pan. | |
| 1151 | - let pictures: Vec<Picture> = (0..3) | |
| 1152 | - .map(|i| panned_test_card(width, height, i * 3)) | |
| 1153 | - .collect(); | |
| 1154 | - let mut streams = Vec::new(); | |
| 1155 | - for filter in [ | |
| 1156 | - ec_av1_syntax::InterpolationFilter::Eighttap, | |
| 1157 | - ec_av1_syntax::InterpolationFilter::EighttapSmooth, | |
| 1158 | - ec_av1_syntax::InterpolationFilter::EighttapSharp, | |
| 1159 | - ] { | |
| 1160 | - set_frame_interp(Some(filter)); | |
| 1161 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 1162 | - let encoded = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx) | |
| 1163 | - .unwrap_or_else(|e| panic!("{filter:?}: {e}")); | |
| 1164 | - let decoded = ffmpeg_decode_sequence(&encoded.stream, width, height, 3); | |
| 1165 | - assert_eq!(decoded.len(), 3, "{filter:?}: decoded frame count"); | |
| 1166 | - for (i, (frame, decoded)) in encoded.frames.iter().zip(&decoded).enumerate() { | |
| 1167 | - assert_eq!( | |
| 1168 | - decoded.y, frame.reconstruction.y, | |
| 1169 | - "{filter:?} frame {i}: luma" | |
| 1170 | - ); | |
| 1171 | - assert_eq!(decoded.u, frame.reconstruction.u, "{filter:?} frame {i}: U"); | |
| 1172 | - assert_eq!(decoded.v, frame.reconstruction.v, "{filter:?} frame {i}: V"); | |
| 1173 | - } | |
| 1174 | - streams.push((filter, encoded.stream)); | |
| 1175 | - } | |
| 1176 | - set_frame_interp(None); | |
| 1177 | - for (i, (fa, a)) in streams.iter().enumerate() { | |
| 1178 | - for (fb, b) in &streams[i + 1..] { | |
| 1179 | - assert_ne!(a, b, "{fa:?} and {fb:?} coded the same bytes"); | |
| 1180 | - } | |
| 1181 | - } | |
| 1182 | - } | |
| 1183 | - | |
| 1184 | - /// lane-hpmv: THE EIGHTH-PEL VECTOR REACHES THE STREAM. With | |
| 1185 | - /// `allow_high_precision_mv` off the writer refuses an odd eighth-pel | |
| 1186 | - /// residual outright (`round_to_valid_mv` rounds it away first), so the | |
| 1187 | - /// finest vector the encoder could commit to was a quarter pel. With the | |
| 1188 | - /// header bit on, the writer codes an `mv_hp`/`mv_class0_hp` symbol per | |
| 1189 | - /// non-zero component and the search's fourth stage refines to the | |
| 1190 | - /// eighth: this asserts ZERO hp symbols in the off arm, non-zero in the | |
| 1191 | - /// on arm, and -- the part that makes it a signal rather than a symbol | |
| 1192 | - /// count (class `fixture proves the symbol, not the signal`) -- that some | |
| 1193 | - /// of them come out ZERO, i.e. name a vector the off arm cannot code at | |
| 1194 | - /// all. Both streams are decoded by ffmpeg AND by this crate's own | |
| 1195 | - /// decoder and asserted sample-exact against the encoder's own | |
| 1196 | - /// reconstruction, which is what proves the header bit and the symbols | |
| 1197 | - /// agree. | |
| 1198 | - #[test] | |
| 1199 | - fn a_high_precision_frame_codes_eighth_pel_motion_vectors_both_decoders_read() { | |
| 1200 | - let _knobs = crate::speed::knob_write(); | |
| 1201 | - let (width, height) = (256usize, 128usize); | |
| 1202 | - let pictures: Vec<Picture> = (0..3) | |
| 1203 | - .map(|i| panned_test_card(width, height, i * 3)) | |
| 1204 | - .collect(); | |
| 1205 | - let mut arms = Vec::new(); | |
| 1206 | - for hp in [false, true] { | |
| 1207 | - set_high_precision_mv(Some(hp)); | |
| 1208 | - let _ = crate::tile::take_hp_symbols(); | |
| 1209 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 1210 | - let encoded = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx) | |
| 1211 | - .unwrap_or_else(|e| panic!("hp={hp}: {e}")); | |
| 1212 | - let (symbols, eighth) = crate::tile::take_hp_symbols(); | |
| 1213 | - let decoded = ffmpeg_decode_sequence(&encoded.stream, width, height, pictures.len()); | |
| 1214 | - let ours = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | |
| 1215 | - assert_eq!(decoded.len(), pictures.len(), "hp={hp}: ffmpeg frame count"); | |
| 1216 | - assert_eq!( | |
| 1217 | - ours.len(), | |
| 1218 | - pictures.len(), | |
| 1219 | - "hp={hp}: our decoder frame count" | |
| 1220 | - ); | |
| 1221 | - for (i, e) in encoded.frames.iter().enumerate() { | |
| 1222 | - for (who, got) in [("ffmpeg", &decoded[i]), ("our decoder", &ours[i])] { | |
| 1223 | - if let Some((plane, s, got, want)) = | |
| 1224 | - first_plane_mismatch(got, &e.reconstruction) | |
| 1225 | - { | |
| 1226 | - panic!( | |
| 1227 | - "hp={hp} frame {i} plane {plane} sample {s}: {who} decoded {got}, \ | |
| 538 | + for (i, e) in encoded.frames.iter().enumerate() { | |
| 539 | + for (who, got) in [("ffmpeg", &decoded[i]), ("our decoder", &ours[i])] { | |
| 540 | + if let Some((plane, s, got, want)) = first_plane_mismatch(got, &e.reconstruction) { | |
| 541 | + panic!( | |
| 542 | + "hp={hp} frame {i} plane {plane} sample {s}: {who} decoded {got}, \ | |
| 1228 | 543 | the encoder reconstructed {want}" |
| 1229 | - ); | |
| 1230 | - } | |
| 544 | + ); | |
| 1231 | 545 | } |
| 1232 | 546 | } |
| 1233 | - arms.push((symbols, eighth, encoded.stream)); | |
| 1234 | 547 | } |
| 1235 | - set_high_precision_mv(None); | |
| 1236 | - let (off, on) = (&arms[0], &arms[1]); | |
| 1237 | - assert_eq!( | |
| 1238 | - off.0, 0, | |
| 1239 | - "a frame without the header bit codes no hp symbol" | |
| 1240 | - ); | |
| 1241 | - assert!( | |
| 1242 | - on.0 > 0, | |
| 1243 | - "a high-precision frame codes hp symbols (got {})", | |
| 1244 | - on.0 | |
| 1245 | - ); | |
| 1246 | - assert!( | |
| 1247 | - on.1 > 0, | |
| 1248 | - "a high-precision frame codes eighth-pel vectors ({} hp symbols, none of them zero)", | |
| 1249 | - on.0 | |
| 1250 | - ); | |
| 1251 | - assert_ne!(off.2, on.2, "the two arms coded the same bytes"); | |
| 1252 | - println!( | |
| 1253 | - "hp witness: off {} hp symbols / {} B, on {} hp symbols ({} eighth-pel) / {} B", | |
| 1254 | - off.0, | |
| 1255 | - off.2.len(), | |
| 1256 | - on.0, | |
| 1257 | - on.1, | |
| 1258 | - on.2.len() | |
| 1259 | - ); | |
| 548 | + arms.push((symbols, eighth, encoded.stream)); | |
| 1260 | 549 | } |
| 550 | + set_high_precision_mv(None); | |
| 551 | + let (off, on) = (&arms[0], &arms[1]); | |
| 552 | + assert_eq!( | |
| 553 | + off.0, 0, | |
| 554 | + "a frame without the header bit codes no hp symbol" | |
| 555 | + ); | |
| 556 | + assert!( | |
| 557 | + on.0 > 0, | |
| 558 | + "a high-precision frame codes hp symbols (got {})", | |
| 559 | + on.0 | |
| 560 | + ); | |
| 561 | + assert!( | |
| 562 | + on.1 > 0, | |
| 563 | + "a high-precision frame codes eighth-pel vectors ({} hp symbols, none of them zero)", | |
| 564 | + on.0 | |
| 565 | + ); | |
| 566 | + assert_ne!(off.2, on.2, "the two arms coded the same bytes"); | |
| 567 | + println!( | |
| 568 | + "hp witness: off {} hp symbols / {} B, on {} hp symbols ({} eighth-pel) / {} B", | |
| 569 | + off.0, | |
| 570 | + off.2.len(), | |
| 571 | + on.0, | |
| 572 | + on.1, | |
| 573 | + on.2.len() | |
| 574 | + ); | |
| 575 | +} |
crates/ec-av1/src/encode/split.rsmodified+206 -267
| @@ -312,13 +312,6 @@ pub(crate) static TXRD_STATS: [std::sync::atomic::AtomicU64; 7] = [ | ||
| 312 | 312 | std::sync::atomic::AtomicU64::new(0), |
| 313 | 313 | ]; |
| 314 | 314 | |
| 315 | -/// Reads [`TXRD_STATS`] and zeroes it. Only the gate reads it, so the lib | |
| 316 | -/// build would warn `dead_code` (class from lane-txset2's `coeff_bits`). | |
| 317 | -#[cfg(test)] | |
| 318 | -pub(crate) fn take_txrd_stats() -> [u64; 7] { | |
| 319 | - std::array::from_fn(|i| TXRD_STATS[i].swap(0, std::sync::atomic::Ordering::Relaxed)) | |
| 320 | -} | |
| 321 | - | |
| 322 | 315 | /// Reads [`INTER_TX_TYPE_HITS`] and zeroes it. |
| 323 | 316 | #[cfg(test)] |
| 324 | 317 | pub(crate) fn take_inter_tx_type_hits() -> [usize; 16] { |
| @@ -969,7 +962,15 @@ thread_local! { | ||
| 969 | 962 | static INTRABC_FORCE: std::cell::Cell<Option<bool>> = const { std::cell::Cell::new(None) }; |
| 970 | 963 | } |
| 971 | 964 | |
| 972 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 965 | +/// Whether the luma search refines a directional winner's `angle_delta_y` | |
| 966 | +/// (`EC_AV1_ANGLE=0` switches it off, the lane's own on/off pair). | |
| 967 | +pub(super) fn angle_delta_on() -> bool { | |
| 968 | + static ENV: std::sync::LazyLock<Option<bool>> = | |
| 969 | + std::sync::LazyLock::new(|| crate::envflags::var("EC_AV1_ANGLE").ok().map(|v| v != "0")); | |
| 970 | + ENV.unwrap_or_else(|| crate::speed::at(&crate::speed::ANGLE)) | |
| 971 | +} | |
| 972 | + | |
| 973 | +#[cfg(test)] | |
| 973 | 974 | pub(crate) fn force_intrabc(value: Option<bool>) { |
| 974 | 975 | INTRABC_FORCE.with(|c| c.set(value)); |
| 975 | 976 | } |
| @@ -1059,7 +1060,12 @@ pub(super) fn ibc_index( | ||
| 1059 | 1060 | /// `allow_intrabc` -- the share of its 16-aligned 16x16 blocks whose exact |
| 1060 | 1061 | /// content appears at some other position, against [`intrabc_pct`]. Returns |
| 1061 | 1062 | /// the share as well, for the gate's own print. |
| 1062 | -pub(super) fn intrabc_worth_it(y: &[u8], width: usize, true_width: usize, true_height: usize) -> (bool, f64) { | |
| 1063 | +pub(super) fn intrabc_worth_it( | |
| 1064 | + y: &[u8], | |
| 1065 | + width: usize, | |
| 1066 | + true_width: usize, | |
| 1067 | + true_height: usize, | |
| 1068 | +) -> (bool, f64) { | |
| 1063 | 1069 | if true_width < 4 * 64 || true_height < 2 * 64 { |
| 1064 | 1070 | return (false, 0.0); |
| 1065 | 1071 | } |
| @@ -1075,9 +1081,9 @@ pub(super) fn intrabc_worth_it(y: &[u8], width: usize, true_width: usize, true_h | ||
| 1075 | 1081 | && hits |
| 1076 | 1082 | .iter() |
| 1077 | 1083 | .any(|&(hx, hy)| (hx as usize, hy as usize) != (bx, by)) |
| 1078 | - { | |
| 1079 | - matched += 1; | |
| 1080 | - } | |
| 1084 | + { | |
| 1085 | + matched += 1; | |
| 1086 | + } | |
| 1081 | 1087 | bx += IBC_HASH; |
| 1082 | 1088 | } |
| 1083 | 1089 | by += IBC_HASH; |
| @@ -1207,13 +1213,6 @@ impl Drop for Ibc { | ||
| 1207 | 1213 | } |
| 1208 | 1214 | } |
| 1209 | 1215 | |
| 1210 | -/// Reads [`IBC_SEARCH`] and zeroes it, so a gate can attribute the counts to | |
| 1211 | -/// its own encode. | |
| 1212 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 1213 | -pub(crate) fn take_intrabc_search() -> [usize; 3] { | |
| 1214 | - std::array::from_fn(|i| IBC_SEARCH[i].swap(0, std::sync::atomic::Ordering::Relaxed)) | |
| 1215 | -} | |
| 1216 | - | |
| 1217 | 1216 | /// [`crate::tile::write_dv_component`]'s static price -- the same shape as |
| 1218 | 1217 | /// [`mv_component_bits`] without the `mv_fr` symbol, which `force_integer_mv` |
| 1219 | 1218 | /// infers rather than codes. |
| @@ -1667,19 +1666,20 @@ pub(super) fn code_square( | ||
| 1667 | 1666 | if let Some(ibc) = ibc |
| 1668 | 1667 | && let Some((dv, cost_ibc, src)) = |
| 1669 | 1668 | ibc_search(ibc, luma, chroma, (x, y), side, search.lambda) |
| 1670 | - && cost_ibc < cost { | |
| 1671 | - ibc_commit(luma, chroma, (x, y), src, side); | |
| 1672 | - ibc.last_dv = Some(dv); | |
| 1673 | - ibc.hits += 1; | |
| 1674 | - return ( | |
| 1675 | - BlockCoeffs { | |
| 1676 | - skip: true, | |
| 1677 | - dv: Some(dv), | |
| 1678 | - ..BlockCoeffs::default() | |
| 1679 | - }, | |
| 1680 | - cost_ibc, | |
| 1681 | - ); | |
| 1682 | - } | |
| 1669 | + && cost_ibc < cost | |
| 1670 | + { | |
| 1671 | + ibc_commit(luma, chroma, (x, y), src, side); | |
| 1672 | + ibc.last_dv = Some(dv); | |
| 1673 | + ibc.hits += 1; | |
| 1674 | + return ( | |
| 1675 | + BlockCoeffs { | |
| 1676 | + skip: true, | |
| 1677 | + dv: Some(dv), | |
| 1678 | + ..BlockCoeffs::default() | |
| 1679 | + }, | |
| 1680 | + cost_ibc, | |
| 1681 | + ); | |
| 1682 | + } | |
| 1683 | 1683 | // A palette or filter-intra block's luma was recoded through `DCT_DCT` |
| 1684 | 1684 | // (its levels came from `code_from_prediction`), so the searched types |
| 1685 | 1685 | // belong to a block this one no longer is. |
| @@ -1722,53 +1722,6 @@ pub(super) const CHROMA_MODES: [u8; 7] = [ | ||
| 1722 | 1722 | PAETH_PRED, |
| 1723 | 1723 | ]; |
| 1724 | 1724 | |
| 1725 | -/// The thirteen intra mode names, for the chroma fire count's print. | |
| 1726 | -#[cfg(test)] | |
| 1727 | -pub(super) const UV_MODE_NAMES: [&str; 14] = [ | |
| 1728 | - "DC", "V", "H", "D45", "D135", "D113", "D157", "D203", "D67", "SMOOTH", "SMOOTH_V", "SMOOTH_H", | |
| 1729 | - "PAETH", "CFL", | |
| 1730 | -]; | |
| 1731 | - | |
| 1732 | -/// How many blocks each chroma mode has won, indexed by the mode itself -- | |
| 1733 | -/// the fire count that says whether the search below reaches its candidates | |
| 1734 | -/// at all (the `gate-blind-to-feature` class), printed once per gate run. | |
| 1735 | -pub(super) static UV_MODE_HITS: [std::sync::atomic::AtomicUsize; 14] = | |
| 1736 | - [const { std::sync::atomic::AtomicUsize::new(0) }; 14]; | |
| 1737 | - | |
| 1738 | -/// How many blocks each CfL alpha magnitude (`1..=16`, indexed `mag - 1`) has | |
| 1739 | -/// won, summed over both chroma planes -- the alpha histogram the gate prints | |
| 1740 | -/// beside the CfL share (`gate-blind-to-feature`: a tool that fires at one | |
| 1741 | -/// magnitude only is a search that never left its first candidate). | |
| 1742 | -pub(super) static CFL_ALPHA_HITS: [std::sync::atomic::AtomicUsize; 17] = | |
| 1743 | - [const { std::sync::atomic::AtomicUsize::new(0) }; 17]; | |
| 1744 | - | |
| 1745 | -/// Reads [`CFL_ALPHA_HITS`] and zeroes it. Index 0 is "this plane took alpha | |
| 1746 | -/// zero on a CfL block", `1..=16` the magnitudes. | |
| 1747 | -#[cfg(test)] | |
| 1748 | -pub(crate) fn take_cfl_alpha_hits() -> [usize; 17] { | |
| 1749 | - std::array::from_fn(|m| CFL_ALPHA_HITS[m].swap(0, std::sync::atomic::Ordering::Relaxed)) | |
| 1750 | -} | |
| 1751 | - | |
| 1752 | -/// How many directional luma blocks won at each `angle_delta_y`, indexed | |
| 1753 | -/// `delta + 3` -- the histogram that says whether the refinement below ever | |
| 1754 | -/// leaves zero (`gate-blind-to-feature`). | |
| 1755 | -pub(super) static ANGLE_DELTA_HITS: [std::sync::atomic::AtomicUsize; 7] = | |
| 1756 | - [const { std::sync::atomic::AtomicUsize::new(0) }; 7]; | |
| 1757 | - | |
| 1758 | -/// Reads [`ANGLE_DELTA_HITS`] and zeroes it. | |
| 1759 | -#[cfg(test)] | |
| 1760 | -pub(crate) fn take_angle_delta_hits() -> [usize; 7] { | |
| 1761 | - std::array::from_fn(|d| ANGLE_DELTA_HITS[d].swap(0, std::sync::atomic::Ordering::Relaxed)) | |
| 1762 | -} | |
| 1763 | - | |
| 1764 | -/// Whether the luma search refines a directional winner's `angle_delta_y` | |
| 1765 | -/// (`EC_AV1_ANGLE=0` switches it off, the lane's own on/off pair). | |
| 1766 | -pub(super) fn angle_delta_on() -> bool { | |
| 1767 | - static ENV: std::sync::LazyLock<Option<bool>> = | |
| 1768 | - std::sync::LazyLock::new(|| crate::envflags::var("EC_AV1_ANGLE").ok().map(|v| v != "0")); | |
| 1769 | - ENV.unwrap_or_else(|| crate::speed::at(&crate::speed::ANGLE)) | |
| 1770 | -} | |
| 1771 | - | |
| 1772 | 1725 | /// Whether the chroma search offers `UV_CFL_PRED` at all (`EC_AV1_CFL=0` |
| 1773 | 1726 | /// switches it off, which is how the lane measured its own on/off pair). |
| 1774 | 1727 | pub(super) fn cfl_on() -> bool { |
| @@ -1834,14 +1787,6 @@ pub(crate) fn sb128_on() -> bool { | ||
| 1834 | 1787 | } |
| 1835 | 1788 | } |
| 1836 | 1789 | |
| 1837 | -/// Forces [`sb128_on`] for the rest of the process -- the superblock size is | |
| 1838 | -/// a SEQUENCE field, so a gate that flips it must run alone (`#[ignore]`), | |
| 1839 | -/// exactly like the speed-preset gates. | |
| 1840 | -#[cfg(test)] | |
| 1841 | -pub(crate) fn force_sb128(on: bool) { | |
| 1842 | - ENC_SB128.store(u8::from(on), std::sync::atomic::Ordering::Relaxed); | |
| 1843 | -} | |
| 1844 | - | |
| 1845 | 1790 | /// The luma loop-restoration unit size this sequence codes: a 128 superblock |
| 1846 | 1791 | /// cannot signal the 64 unit at all (spec `lr_params` reads ONE bit there, |
| 1847 | 1792 | /// `RESTORATION_TILESIZE_MAX >> (2 - (shift + 1))`, so the smallest unit is |
| @@ -1863,13 +1808,6 @@ pub(crate) fn filter_intra_on() -> bool { | ||
| 1863 | 1808 | ENV.unwrap_or_else(|| crate::speed::at(&crate::speed::FILTER_INTRA)) |
| 1864 | 1809 | } |
| 1865 | 1810 | |
| 1866 | -/// Reads [`UV_MODE_HITS`] and zeroes it, so a gate can attribute the counts | |
| 1867 | -/// to its own encode. | |
| 1868 | -#[cfg(test)] | |
| 1869 | -pub(crate) fn take_uv_mode_hits() -> [usize; 14] { | |
| 1870 | - std::array::from_fn(|m| UV_MODE_HITS[m].swap(0, std::sync::atomic::Ordering::Relaxed)) | |
| 1871 | -} | |
| 1872 | - | |
| 1873 | 1811 | /// Searches both chroma planes over [`CHROMA_MODES`] under one shared mode -- |
| 1874 | 1812 | /// `uv_mode` is a single symbol covering U and V -- and commits the cheapest. |
| 1875 | 1813 | /// Returns each plane's levels, the mode, and what the pair cost (squared |
| @@ -2051,7 +1989,9 @@ pub(super) fn search_chroma( | ||
| 2051 | 1989 | } |
| 2052 | 1990 | let mut v_colors = [0u16; 8]; |
| 2053 | 1991 | for k in 0..n { |
| 2054 | - v_colors[k] = (sums[k] + counts[k] / 2).checked_div(counts[k]).unwrap_or(0) as u16; | |
| 1992 | + v_colors[k] = (sums[k] + counts[k] / 2) | |
| 1993 | + .checked_div(counts[k]) | |
| 1994 | + .unwrap_or(0) as u16; | |
| 2055 | 1995 | } |
| 2056 | 1996 | let candidate = crate::tile::PaletteUv { |
| 2057 | 1997 | size: pal.size, |
| @@ -2229,17 +2169,10 @@ pub(super) fn search_chroma( | ||
| 2229 | 2169 | } |
| 2230 | 2170 | } |
| 2231 | 2171 | } |
| 2232 | - if let Some((alpha_u, alpha_v)) = cfl_alphas { | |
| 2233 | - for alpha in [alpha_u, alpha_v] { | |
| 2234 | - CFL_ALPHA_HITS[alpha.unsigned_abs() as usize] | |
| 2235 | - .fetch_add(1, std::sync::atomic::Ordering::Relaxed); | |
| 2236 | - } | |
| 2237 | - } | |
| 2238 | 2172 | if census_on() { |
| 2239 | 2173 | CHROMA_RANK[sad_rank(&ranking, mode).min(6)] |
| 2240 | 2174 | .fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 2241 | 2175 | } |
| 2242 | - UV_MODE_HITS[usize::from(mode)].fetch_add(1, std::sync::atomic::Ordering::Relaxed); | |
| 2243 | 2176 | chroma[0].commit(at.x, at.y, at.side, &u); |
| 2244 | 2177 | chroma[1].commit(at.x, at.y, at.side, &v); |
| 2245 | 2178 | ( |
| @@ -2871,53 +2804,55 @@ pub(super) fn code_square_inter( | ||
| 2871 | 2804 | } |
| 2872 | 2805 | } |
| 2873 | 2806 | if let Some(new_mv) = searched_new |
| 2874 | - && let Some(b0) = mv_residual_bits(new_mv, cbase.0) { | |
| 2875 | - ccands.push(( | |
| 2876 | - (new_mv, cstack.nearest_mv.1), | |
| 2877 | - mode_bits_of(3) + b0, | |
| 2878 | - InterInfo { | |
| 2879 | - ref_frame: crate::mvstack::LAST_FRAME, | |
| 2880 | - mode: InterMode::NewNearestMv, | |
| 2881 | - mv: new_mv, | |
| 2882 | - mv1: cstack.nearest_mv.1, | |
| 2883 | - ref1: Some(ref1), | |
| 2884 | - ref_mv_idx: 0, | |
| 2885 | - }, | |
| 2886 | - )); | |
| 2887 | - } | |
| 2807 | + && let Some(b0) = mv_residual_bits(new_mv, cbase.0) | |
| 2808 | + { | |
| 2809 | + ccands.push(( | |
| 2810 | + (new_mv, cstack.nearest_mv.1), | |
| 2811 | + mode_bits_of(3) + b0, | |
| 2812 | + InterInfo { | |
| 2813 | + ref_frame: crate::mvstack::LAST_FRAME, | |
| 2814 | + mode: InterMode::NewNearestMv, | |
| 2815 | + mv: new_mv, | |
| 2816 | + mv1: cstack.nearest_mv.1, | |
| 2817 | + ref1: Some(ref1), | |
| 2818 | + ref_mv_idx: 0, | |
| 2819 | + }, | |
| 2820 | + )); | |
| 2821 | + } | |
| 2888 | 2822 | // `NEAREST_NEWMV` and `NEW_NEWMV`: the NEW halves are the two |
| 2889 | 2823 | // searches this leaf ran, each residual priced against `cbase`. |
| 2890 | 2824 | if let Some(mv1) = second_new |
| 2891 | - && let Some(b1) = mv_residual_bits(mv1, cbase.1) { | |
| 2825 | + && let Some(b1) = mv_residual_bits(mv1, cbase.1) | |
| 2826 | + { | |
| 2827 | + ccands.push(( | |
| 2828 | + (cstack.nearest_mv.0, mv1), | |
| 2829 | + mode_bits_of(2) + b1, | |
| 2830 | + InterInfo { | |
| 2831 | + ref_frame: crate::mvstack::LAST_FRAME, | |
| 2832 | + mode: InterMode::NearestNewMv, | |
| 2833 | + mv: cstack.nearest_mv.0, | |
| 2834 | + mv1, | |
| 2835 | + ref1: Some(ref1), | |
| 2836 | + ref_mv_idx: 0, | |
| 2837 | + }, | |
| 2838 | + )); | |
| 2839 | + if let Some((new_mv, b0)) = | |
| 2840 | + searched_new.and_then(|m| mv_residual_bits(m, cbase.0).map(|b| (m, b))) | |
| 2841 | + { | |
| 2892 | 2842 | ccands.push(( |
| 2893 | - (cstack.nearest_mv.0, mv1), | |
| 2894 | - mode_bits_of(2) + b1, | |
| 2843 | + (new_mv, mv1), | |
| 2844 | + mode_bits_of(7) + b0 + b1, | |
| 2895 | 2845 | InterInfo { |
| 2896 | 2846 | ref_frame: crate::mvstack::LAST_FRAME, |
| 2897 | - mode: InterMode::NearestNewMv, | |
| 2898 | - mv: cstack.nearest_mv.0, | |
| 2847 | + mode: InterMode::NewNewMv, | |
| 2848 | + mv: new_mv, | |
| 2899 | 2849 | mv1, |
| 2900 | 2850 | ref1: Some(ref1), |
| 2901 | 2851 | ref_mv_idx: 0, |
| 2902 | 2852 | }, |
| 2903 | 2853 | )); |
| 2904 | - if let Some((new_mv, b0)) = | |
| 2905 | - searched_new.and_then(|m| mv_residual_bits(m, cbase.0).map(|b| (m, b))) | |
| 2906 | - { | |
| 2907 | - ccands.push(( | |
| 2908 | - (new_mv, mv1), | |
| 2909 | - mode_bits_of(7) + b0 + b1, | |
| 2910 | - InterInfo { | |
| 2911 | - ref_frame: crate::mvstack::LAST_FRAME, | |
| 2912 | - mode: InterMode::NewNewMv, | |
| 2913 | - mv: new_mv, | |
| 2914 | - mv1, | |
| 2915 | - ref1: Some(ref1), | |
| 2916 | - ref_mv_idx: 0, | |
| 2917 | - }, | |
| 2918 | - )); | |
| 2919 | - } | |
| 2920 | 2854 | } |
| 2855 | + } | |
| 2921 | 2856 | ccands.sort_by(|a, b| a.0.cmp(&b.0).then(a.1.total_cmp(&b.1))); |
| 2922 | 2857 | ccands.dedup_by_key(|c| c.0); |
| 2923 | 2858 | let g_luma = (g.y.as_slice(), g.width, luma.true_width, luma.true_height); |
| @@ -3040,7 +2975,8 @@ pub(super) fn code_square_inter( | ||
| 3040 | 2975 | ) >= 1; |
| 3041 | 2976 | let mm = |m: u8| motion_mode_bits(side, side, m, warp_alphabet); |
| 3042 | 2977 | let mut candidates: Vec<(u8, [Vec<u8>; 3])> = Vec::new(); |
| 3043 | - if crate::envflags::env_flag!("EC_AV1_OBMC") && side >= obmc_min_side() | |
| 2978 | + if crate::envflags::env_flag!("EC_AV1_OBMC") | |
| 2979 | + && side >= obmc_min_side() | |
| 3044 | 2980 | && let Some(pred) = obmc_prediction( |
| 3045 | 2981 | grid, |
| 3046 | 2982 | (mi_row, mi_col), |
| @@ -3052,9 +2988,10 @@ pub(super) fn code_square_inter( | ||
| 3052 | 2988 | planes, |
| 3053 | 2989 | (reference.width, reference.height), |
| 3054 | 2990 | fctx, |
| 3055 | - ) { | |
| 3056 | - candidates.push((1, pred)); | |
| 3057 | - } | |
| 2991 | + ) | |
| 2992 | + { | |
| 2993 | + candidates.push((1, pred)); | |
| 2994 | + } | |
| 3058 | 2995 | if warp_alphabet |
| 3059 | 2996 | && let Some(pred) = warp_prediction( |
| 3060 | 2997 | grid, |
| @@ -3066,9 +3003,10 @@ pub(super) fn code_square_inter( | ||
| 3066 | 3003 | info.ref_frame, |
| 3067 | 3004 | planes, |
| 3068 | 3005 | fctx, |
| 3069 | - ) { | |
| 3070 | - candidates.push((2, pred)); | |
| 3071 | - } | |
| 3006 | + ) | |
| 3007 | + { | |
| 3008 | + candidates.push((2, pred)); | |
| 3009 | + } | |
| 3072 | 3010 | for (motion, pred) in candidates { |
| 3073 | 3011 | let luma_o = luma.code_from_prediction( |
| 3074 | 3012 | x, |
| @@ -3125,136 +3063,137 @@ pub(super) fn code_square_inter( | ||
| 3125 | 3063 | } |
| 3126 | 3064 | |
| 3127 | 3065 | if let (cost, Some((luma_new, u_new, v_new, skip_new, info))) = best |
| 3128 | - && cost < intra_cost { | |
| 3129 | - // A compound winner commits the flat trial it was priced from: | |
| 3130 | - // `commit_inter_luma`'s var-tx trial set is single-reference | |
| 3131 | - // (`mc_trial`), so a compound leaf codes `tx_depth = 0`. | |
| 3132 | - // lane-av1comp4 BUILT that upgrade (a `commit_inter_luma` | |
| 3133 | - // predicting each half-side trial from BOTH references, verified | |
| 3134 | - // byte-identical to this when its split is disabled) and MEASURED | |
| 3135 | - // it a loss: vs libaom +83.5/+99.7/+54.9 at no margin against the | |
| 3136 | - // +83.0/+99.9/+54.5 here, and +83.3/+100.2/+54.9, +83.8/+99.5/ | |
| 3137 | - // +54.9, +83.3/+100.0/+54.9 at split margins 0.02/0.05/0.15. A | |
| 3138 | - // compound block's residual is small enough that the four extra | |
| 3139 | - // per-unit txb_skip/eob symbols cost more ladder bytes than this | |
| 3140 | - // encoder's static-CDF estimate prices them at, so the local RD | |
| 3141 | - // win does not convert. lane-av1txbits REBUILT it on top of a | |
| 3142 | - // search that prices against the tables the frame is really | |
| 3143 | - // written with (`tile::arm_pricing_cdfs`, the estimate error on | |
| 3144 | - // these very blocks measured down from +31% to +3%) and measured | |
| 3145 | - // it neutral-to-worse again: +78.8/+95.0/+54.5 and +36.5/+56.3/ | |
| 3146 | - // +1.4 against the +78.8/+95.1/+54.5 and +36.1/+56.4/+1.4 of the | |
| 3147 | - // same build without it. The static-CDF estimate was NOT what | |
| 3148 | - // held the compound var-tx trial back. The flat trial stays. | |
| 3149 | - // An OBMC winner commits the flat trial too: `commit_inter_luma` | |
| 3150 | - // re-predicts each var-tx unit by plain translation, which is not | |
| 3151 | - // the prediction this candidate was priced from. | |
| 3152 | - // lane-av1txdepth REBUILT the compound trial set at LAMBDA_SCALE | |
| 3153 | - // 0.05 (both rejections above were measured at 0.1, the weight | |
| 3154 | - // the lambda lane showed was 2x too heavy): a compound winner is | |
| 3155 | - // offered the same var-tx split, its units predicted from BOTH | |
| 3156 | - // references (`mc_trial_compound`). RE-MEASURED native: film | |
| 3157 | - // 1080p +16.0/-1.1, film 2160p +46.6/+18.8, screen +51.4/-14.4 | |
| 3158 | - // against the +16.2/-1.1, +46.6/+18.8, +51.3/-14.4 with it off -- | |
| 3159 | - // one row 0.2 down, two flat, short of the two-down-one-flat keep | |
| 3160 | - // rule, so it stays behind `EC_AV1_COMP_VARTX` (default OFF) | |
| 3161 | - // rather than change the default on a single 0.2 row. It fires: | |
| 3162 | - // 37.0% / 11.1% / 32.9% of the compound blocks split. 640x384 for | |
| 3163 | - // the record: +70.5/+84.0/+48.9 and +28.9/+46.2/-3.7 against | |
| 3164 | - // +70.4/+85.3/+48.5 and +28.4/+47.4/-4.0 -- the 4K film row is | |
| 3165 | - // 1.3/1.2 down there, which is where the upgrade path is if this | |
| 3166 | - // is picked up again. | |
| 3167 | - let second = info.ref1.filter(|_| motion_won == 0).and_then(|r| { | |
| 3168 | - refs[r as usize].map(|g| { | |
| 3169 | - ( | |
| 3170 | - info.mv1, | |
| 3171 | - (g.y.as_slice(), g.width, luma.true_width, luma.true_height), | |
| 3172 | - ) | |
| 3173 | - }) | |
| 3174 | - }); | |
| 3175 | - let (levels, tx_depth, dcost, luma_tx_types) = | |
| 3176 | - if motion_won != 0 || (info.ref1.is_some() && second.is_none()) { | |
| 3177 | - luma.commit(x, y, side, &luma_new); | |
| 3178 | - (luma_new.levels.clone(), 0, 0.0, Vec::new()) | |
| 3179 | - } else { | |
| 3180 | - commit_inter_luma( | |
| 3181 | - luma, | |
| 3182 | - (x, y), | |
| 3183 | - side, | |
| 3184 | - info.mv, | |
| 3185 | - (ref_luma.0.as_slice(), ref_luma.1, ref_luma.2, ref_luma.3), | |
| 3186 | - search, | |
| 3187 | - &luma_new, | |
| 3188 | - skip_new, | |
| 3189 | - second, | |
| 3190 | - fctx, | |
| 3191 | - ) | |
| 3192 | - }; | |
| 3193 | - // lane-txrd: chroma follows the luma type the search just chose. | |
| 3194 | - let [u_new, v_new] = match luma_tx_types.first().copied() { | |
| 3195 | - Some(t) => recode_inter_chroma( | |
| 3196 | - chroma, | |
| 3066 | + && cost < intra_cost | |
| 3067 | + { | |
| 3068 | + // A compound winner commits the flat trial it was priced from: | |
| 3069 | + // `commit_inter_luma`'s var-tx trial set is single-reference | |
| 3070 | + // (`mc_trial`), so a compound leaf codes `tx_depth = 0`. | |
| 3071 | + // lane-av1comp4 BUILT that upgrade (a `commit_inter_luma` | |
| 3072 | + // predicting each half-side trial from BOTH references, verified | |
| 3073 | + // byte-identical to this when its split is disabled) and MEASURED | |
| 3074 | + // it a loss: vs libaom +83.5/+99.7/+54.9 at no margin against the | |
| 3075 | + // +83.0/+99.9/+54.5 here, and +83.3/+100.2/+54.9, +83.8/+99.5/ | |
| 3076 | + // +54.9, +83.3/+100.0/+54.9 at split margins 0.02/0.05/0.15. A | |
| 3077 | + // compound block's residual is small enough that the four extra | |
| 3078 | + // per-unit txb_skip/eob symbols cost more ladder bytes than this | |
| 3079 | + // encoder's static-CDF estimate prices them at, so the local RD | |
| 3080 | + // win does not convert. lane-av1txbits REBUILT it on top of a | |
| 3081 | + // search that prices against the tables the frame is really | |
| 3082 | + // written with (`tile::arm_pricing_cdfs`, the estimate error on | |
| 3083 | + // these very blocks measured down from +31% to +3%) and measured | |
| 3084 | + // it neutral-to-worse again: +78.8/+95.0/+54.5 and +36.5/+56.3/ | |
| 3085 | + // +1.4 against the +78.8/+95.1/+54.5 and +36.1/+56.4/+1.4 of the | |
| 3086 | + // same build without it. The static-CDF estimate was NOT what | |
| 3087 | + // held the compound var-tx trial back. The flat trial stays. | |
| 3088 | + // An OBMC winner commits the flat trial too: `commit_inter_luma` | |
| 3089 | + // re-predicts each var-tx unit by plain translation, which is not | |
| 3090 | + // the prediction this candidate was priced from. | |
| 3091 | + // lane-av1txdepth REBUILT the compound trial set at LAMBDA_SCALE | |
| 3092 | + // 0.05 (both rejections above were measured at 0.1, the weight | |
| 3093 | + // the lambda lane showed was 2x too heavy): a compound winner is | |
| 3094 | + // offered the same var-tx split, its units predicted from BOTH | |
| 3095 | + // references (`mc_trial_compound`). RE-MEASURED native: film | |
| 3096 | + // 1080p +16.0/-1.1, film 2160p +46.6/+18.8, screen +51.4/-14.4 | |
| 3097 | + // against the +16.2/-1.1, +46.6/+18.8, +51.3/-14.4 with it off -- | |
| 3098 | + // one row 0.2 down, two flat, short of the two-down-one-flat keep | |
| 3099 | + // rule, so it stays behind `EC_AV1_COMP_VARTX` (default OFF) | |
| 3100 | + // rather than change the default on a single 0.2 row. It fires: | |
| 3101 | + // 37.0% / 11.1% / 32.9% of the compound blocks split. 640x384 for | |
| 3102 | + // the record: +70.5/+84.0/+48.9 and +28.9/+46.2/-3.7 against | |
| 3103 | + // +70.4/+85.3/+48.5 and +28.4/+47.4/-4.0 -- the 4K film row is | |
| 3104 | + // 1.3/1.2 down there, which is where the upgrade path is if this | |
| 3105 | + // is picked up again. | |
| 3106 | + let second = info.ref1.filter(|_| motion_won == 0).and_then(|r| { | |
| 3107 | + refs[r as usize].map(|g| { | |
| 3108 | + ( | |
| 3109 | + info.mv1, | |
| 3110 | + (g.y.as_slice(), g.width, luma.true_width, luma.true_height), | |
| 3111 | + ) | |
| 3112 | + }) | |
| 3113 | + }); | |
| 3114 | + let (levels, tx_depth, dcost, luma_tx_types) = | |
| 3115 | + if motion_won != 0 || (info.ref1.is_some() && second.is_none()) { | |
| 3116 | + luma.commit(x, y, side, &luma_new); | |
| 3117 | + (luma_new.levels.clone(), 0, 0.0, Vec::new()) | |
| 3118 | + } else { | |
| 3119 | + commit_inter_luma( | |
| 3120 | + luma, | |
| 3197 | 3121 | (x, y), |
| 3198 | 3122 | side, |
| 3199 | 3123 | info.mv, |
| 3200 | - [ | |
| 3201 | - (ref_u.0.as_slice(), ref_u.1, ref_u.2, ref_u.3), | |
| 3202 | - (ref_v.0.as_slice(), ref_v.1, ref_v.2, ref_v.3), | |
| 3203 | - ], | |
| 3204 | - info.ref1.filter(|_| motion_won == 0).and_then(|r| { | |
| 3205 | - refs[r as usize].map(|g| { | |
| 3206 | - ( | |
| 3207 | - info.mv1, | |
| 3208 | - [ | |
| 3209 | - ( | |
| 3210 | - g.u.as_slice(), | |
| 3211 | - g.width / 2, | |
| 3212 | - chroma[0].true_width, | |
| 3213 | - chroma[0].true_height, | |
| 3214 | - ), | |
| 3215 | - ( | |
| 3216 | - g.v.as_slice(), | |
| 3217 | - g.width / 2, | |
| 3218 | - chroma[1].true_width, | |
| 3219 | - chroma[1].true_height, | |
| 3220 | - ), | |
| 3221 | - ], | |
| 3222 | - ) | |
| 3223 | - }) | |
| 3224 | - }), | |
| 3124 | + (ref_luma.0.as_slice(), ref_luma.1, ref_luma.2, ref_luma.3), | |
| 3225 | 3125 | search, |
| 3226 | - chroma_set, | |
| 3227 | - t, | |
| 3126 | + &luma_new, | |
| 3127 | + skip_new, | |
| 3128 | + second, | |
| 3228 | 3129 | fctx, |
| 3229 | 3130 | ) |
| 3230 | - .unwrap_or([u_new, v_new]), | |
| 3231 | - None => [u_new, v_new], | |
| 3232 | 3131 | }; |
| 3233 | - chroma[0].commit(x / 2, y / 2, side / 2, &u_new); | |
| 3234 | - chroma[1].commit(x / 2, y / 2, side / 2, &v_new); | |
| 3235 | - return ( | |
| 3236 | - BlockCoeffs { | |
| 3237 | - angle_delta_y: 0, | |
| 3238 | - cfl_alphas: None, | |
| 3239 | - filter_intra: None, | |
| 3240 | - luma: coeffs(&levels, side), | |
| 3241 | - u: coeffs(&u_new.levels, side / 2), | |
| 3242 | - v: coeffs(&v_new.levels, side / 2), | |
| 3243 | - mode: DC_PRED, | |
| 3244 | - uv_mode: DC_PRED, | |
| 3245 | - skip: skip_new, | |
| 3246 | - eight: None, | |
| 3247 | - dv: None, | |
| 3248 | - palette: None, | |
| 3249 | - palette_uv: None, | |
| 3250 | - tx_depth, | |
| 3251 | - luma_tx_types, | |
| 3252 | - inter: Some(info), | |
| 3253 | - motion_mode: motion_won, | |
| 3254 | - }, | |
| 3255 | - cost + dcost, | |
| 3256 | - ); | |
| 3257 | - } | |
| 3132 | + // lane-txrd: chroma follows the luma type the search just chose. | |
| 3133 | + let [u_new, v_new] = match luma_tx_types.first().copied() { | |
| 3134 | + Some(t) => recode_inter_chroma( | |
| 3135 | + chroma, | |
| 3136 | + (x, y), | |
| 3137 | + side, | |
| 3138 | + info.mv, | |
| 3139 | + [ | |
| 3140 | + (ref_u.0.as_slice(), ref_u.1, ref_u.2, ref_u.3), | |
| 3141 | + (ref_v.0.as_slice(), ref_v.1, ref_v.2, ref_v.3), | |
| 3142 | + ], | |
| 3143 | + info.ref1.filter(|_| motion_won == 0).and_then(|r| { | |
| 3144 | + refs[r as usize].map(|g| { | |
| 3145 | + ( | |
| 3146 | + info.mv1, | |
| 3147 | + [ | |
| 3148 | + ( | |
| 3149 | + g.u.as_slice(), | |
| 3150 | + g.width / 2, | |
| 3151 | + chroma[0].true_width, | |
| 3152 | + chroma[0].true_height, | |
| 3153 | + ), | |
| 3154 | + ( | |
| 3155 | + g.v.as_slice(), | |
| 3156 | + g.width / 2, | |
| 3157 | + chroma[1].true_width, | |
| 3158 | + chroma[1].true_height, | |
| 3159 | + ), | |
| 3160 | + ], | |
| 3161 | + ) | |
| 3162 | + }) | |
| 3163 | + }), | |
| 3164 | + search, | |
| 3165 | + chroma_set, | |
| 3166 | + t, | |
| 3167 | + fctx, | |
| 3168 | + ) | |
| 3169 | + .unwrap_or([u_new, v_new]), | |
| 3170 | + None => [u_new, v_new], | |
| 3171 | + }; | |
| 3172 | + chroma[0].commit(x / 2, y / 2, side / 2, &u_new); | |
| 3173 | + chroma[1].commit(x / 2, y / 2, side / 2, &v_new); | |
| 3174 | + return ( | |
| 3175 | + BlockCoeffs { | |
| 3176 | + angle_delta_y: 0, | |
| 3177 | + cfl_alphas: None, | |
| 3178 | + filter_intra: None, | |
| 3179 | + luma: coeffs(&levels, side), | |
| 3180 | + u: coeffs(&u_new.levels, side / 2), | |
| 3181 | + v: coeffs(&v_new.levels, side / 2), | |
| 3182 | + mode: DC_PRED, | |
| 3183 | + uv_mode: DC_PRED, | |
| 3184 | + skip: skip_new, | |
| 3185 | + eight: None, | |
| 3186 | + dv: None, | |
| 3187 | + palette: None, | |
| 3188 | + palette_uv: None, | |
| 3189 | + tx_depth, | |
| 3190 | + luma_tx_types, | |
| 3191 | + inter: Some(info), | |
| 3192 | + motion_mode: motion_won, | |
| 3193 | + }, | |
| 3194 | + cost + dcost, | |
| 3195 | + ); | |
| 3196 | + } | |
| 3258 | 3197 | |
| 3259 | 3198 | census_add(8, 1); |
| 3260 | 3199 | if skip { |
crates/ec-av1/src/encode/tests.rsmodified+2377 -3618
Diff too large; view file
| @@ -1,3783 +1,2542 @@ | ||
| 1 | 1 | |
| 2 | - /// Every (site, frame type, block side) the census can be called with | |
| 3 | - /// lands in its own ten-counter bucket, inside the array (class | |
| 4 | - /// `enumerate-table-domain`: an off-by-one here would silently add two | |
| 5 | - /// sites' trials together). | |
| 6 | - #[test] | |
| 7 | - fn the_split_census_buckets_are_distinct_and_in_bounds() { | |
| 8 | - let mut seen = std::collections::BTreeSet::new(); | |
| 9 | - for site in 0..2 { | |
| 10 | - for key in [true, false] { | |
| 11 | - for side in [8usize, 16, 32, 64] { | |
| 12 | - let base = super::split_census_base(site, key, side); | |
| 13 | - assert!( | |
| 14 | - base + 10 <= super::SPLIT_CENSUS.len(), | |
| 15 | - "{site} {key} {side}" | |
| 16 | - ); | |
| 17 | - assert!(seen.insert(base), "{site} {key} {side} collides"); | |
| 18 | - } | |
| 19 | - } | |
| 2 | +/// An [`crate::mvstack::MvStack`] with every context at zero and no | |
| 3 | +/// neighbours, for the pricer tests below to fill the one band each of | |
| 4 | +/// them is about. | |
| 5 | +/// lane-b128 task 0: every `ref_mv_idx` the `NEWMV`/`NEARMV` pricer | |
| 6 | +/// offers must be one [`crate::tile::write_drl_idx`] can really SIGNAL | |
| 7 | +/// against the same stack -- an offer the writer clamps prices the | |
| 8 | +/// residual against a predictor the decoder never derives, which is the | |
| 9 | +/// silent MV drift lane-sb128b root-caused (there fixed on the WRITER | |
| 10 | +/// side, so the stream stays legal; here the pricer's own offer set is | |
| 11 | +/// enumerated, class `enumerate-table-domain`). | |
| 12 | +/// | |
| 13 | +/// **This is the coverage claim for the drl-clamp cell** (lane-av1recipehunt | |
| 14 | +/// r2, 2026-09-29). It replaces the clip gate | |
| 15 | +/// `a_128_superblock_clip_whose_drl_index_the_write_time_stack_cannot_carry_decodes_exact`, | |
| 16 | +/// deleted in `3e8c65e6`+r2: that gate asserted `drl_clamp_hits() > 0` on a | |
| 17 | +/// real 1280x768 sb128 clip, but `DRL_CLAMP_HITS` is provably unreachable | |
| 18 | +/// while the invariant above holds, so no recipe could ever satisfy it. | |
| 19 | +/// Deletion loses no coverage on either half: | |
| 20 | +/// * the clamp half -- this test IS the coverage, and it is strictly | |
| 21 | +/// stronger than any clip gate: it enumerates the pricer's whole offer | |
| 22 | +/// set against the writer's rule for every stack size 0..=4, and larger | |
| 23 | +/// stacks add entries the pricers never offer (`best_new_mv_syntax` | |
| 24 | +/// breaks at `entries.len() <= idx` for `idx > 0`, so indices 3/4 are | |
| 25 | +/// unreachable at ANY stack size), which is why 0..=4 bounds the | |
| 26 | +/// domain rather than sampling it; | |
| 27 | +/// * the pixel half -- the deleted gate's own decode-vs-encoder- | |
| 28 | +/// reconstruction compare on a 1280x768 sb128 sequence is already made | |
| 29 | +/// four times over, by `a_128_superblock_clip_whose_root_search_codes_ | |
| 30 | +/// 128x128_blocks_decodes_exact`, | |
| 31 | +/// `a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders`, | |
| 32 | +/// `a_128_root_residual_block_under_a_per_unit_cdef_list_decodes_exact` | |
| 33 | +/// and `a_rect128_half_with_a_real_residual_decodes_exact_through_both_decoders` | |
| 34 | +/// (same geometry, same `force_sb128(true)`, same own-reconstruction AND | |
| 35 | +/// ffmpeg compare). | |
| 36 | +/// | |
| 37 | +/// MEASURED before deleting (153 clip x size x frame-count x q combinations, | |
| 38 | +/// `enc_probe`): `tile::drl_clamp_hits()` = 0 on every one. MUTATION PROOF | |
| 39 | +/// the clip was never the variable: widening `best_new_mv_syntax`'s offer | |
| 40 | +/// set to `0..5` fires the counter immediately (9/2/2/1 on | |
| 41 | +/// mandelbrot 640x384x8, mandelbrot 320x192x8, mosaic 320x192x8, | |
| 42 | +/// testsrc2 640x384x8) and the same clips read 0 on revert. `note_drl_clamp` | |
| 43 | +/// and `DRL_CLAMP_HITS` are KEPT as the tripwire for the owning fix | |
| 44 | +/// (`deferred(unblock: the DRL owner widens the pricer past the writer's | |
| 45 | +/// `start + 2` ceiling, or retires the counter)`) -- this test will go red | |
| 46 | +/// the moment either happens, which is the signal to re-open the cell. | |
| 47 | +/// | |
| 48 | +/// cargo test -p ec-av1 --lib -- every_drl_index_the_new_mv_pricer | |
| 49 | +#[test] | |
| 50 | +fn every_drl_index_the_new_mv_pricer_offers_is_one_the_writer_can_signal() { | |
| 51 | + for n in 0..=4usize { | |
| 52 | + let mut stack = bare_stack(); | |
| 53 | + for i in 0..n { | |
| 54 | + stack.entries.push(crate::mvstack::StackEntry { | |
| 55 | + mv: (8 * (i as i32 + 1), -8 * (i as i32 + 1)), | |
| 56 | + weight: 1, | |
| 57 | + }); | |
| 58 | + stack.drl_ctx.push(0); | |
| 59 | + } | |
| 60 | + stack.nearest_mv = stack.entries.first().map_or((0, 0), |e| e.mv); | |
| 61 | + stack.near_mv = stack.entries.get(1).map_or((0, 0), |e| e.mv); | |
| 62 | + stack.pred_mv = stack.nearest_mv; | |
| 63 | + // Aim the vector at each entry in turn, so every index the offer | |
| 64 | + // set holds is the one that wins at least once. | |
| 65 | + for target in 0..n.max(1) { | |
| 66 | + let mv = stack.entries.get(target).map_or(stack.pred_mv, |e| e.mv); | |
| 67 | + let (_, idx) = | |
| 68 | + best_new_mv_syntax(&stack, mv).expect("a zero residual is always codable"); | |
| 69 | + let idx = usize::from(idx); | |
| 70 | + assert_eq!( | |
| 71 | + crate::tile::signalled_drl_idx(n, 0, idx), | |
| 72 | + idx, | |
| 73 | + "NEWMV: a {n}-entry stack cannot signal the offered drl index {idx}", | |
| 74 | + ); | |
| 20 | 75 | } |
| 21 | - assert_eq!(seen.len(), 16); | |
| 22 | - } | |
| 23 | - | |
| 24 | - /// An [`crate::mvstack::MvStack`] with every context at zero and no | |
| 25 | - /// neighbours, for the pricer tests below to fill the one band each of | |
| 26 | - /// them is about. | |
| 27 | - /// lane-b128 task 0: every `ref_mv_idx` the `NEWMV`/`NEARMV` pricer | |
| 28 | - /// offers must be one [`crate::tile::write_drl_idx`] can really SIGNAL | |
| 29 | - /// against the same stack -- an offer the writer clamps prices the | |
| 30 | - /// residual against a predictor the decoder never derives, which is the | |
| 31 | - /// silent MV drift lane-sb128b root-caused (there fixed on the WRITER | |
| 32 | - /// side, so the stream stays legal; here the pricer's own offer set is | |
| 33 | - /// enumerated, class `enumerate-table-domain`). | |
| 34 | - /// | |
| 35 | - /// **This is the coverage claim for the drl-clamp cell** (lane-av1recipehunt | |
| 36 | - /// r2, 2026-09-29). It replaces the clip gate | |
| 37 | - /// `a_128_superblock_clip_whose_drl_index_the_write_time_stack_cannot_carry_decodes_exact`, | |
| 38 | - /// deleted in `3e8c65e6`+r2: that gate asserted `drl_clamp_hits() > 0` on a | |
| 39 | - /// real 1280x768 sb128 clip, but `DRL_CLAMP_HITS` is provably unreachable | |
| 40 | - /// while the invariant above holds, so no recipe could ever satisfy it. | |
| 41 | - /// Deletion loses no coverage on either half: | |
| 42 | - /// * the clamp half -- this test IS the coverage, and it is strictly | |
| 43 | - /// stronger than any clip gate: it enumerates the pricer's whole offer | |
| 44 | - /// set against the writer's rule for every stack size 0..=4, and larger | |
| 45 | - /// stacks add entries the pricers never offer (`best_new_mv_syntax` | |
| 46 | - /// breaks at `entries.len() <= idx` for `idx > 0`, so indices 3/4 are | |
| 47 | - /// unreachable at ANY stack size), which is why 0..=4 bounds the | |
| 48 | - /// domain rather than sampling it; | |
| 49 | - /// * the pixel half -- the deleted gate's own decode-vs-encoder- | |
| 50 | - /// reconstruction compare on a 1280x768 sb128 sequence is already made | |
| 51 | - /// four times over, by `a_128_superblock_clip_whose_root_search_codes_ | |
| 52 | - /// 128x128_blocks_decodes_exact`, | |
| 53 | - /// `a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders`, | |
| 54 | - /// `a_128_root_residual_block_under_a_per_unit_cdef_list_decodes_exact` | |
| 55 | - /// and `a_rect128_half_with_a_real_residual_decodes_exact_through_both_decoders` | |
| 56 | - /// (same geometry, same `force_sb128(true)`, same own-reconstruction AND | |
| 57 | - /// ffmpeg compare). | |
| 58 | - /// | |
| 59 | - /// MEASURED before deleting (153 clip x size x frame-count x q combinations, | |
| 60 | - /// `enc_probe`): `tile::drl_clamp_hits()` = 0 on every one. MUTATION PROOF | |
| 61 | - /// the clip was never the variable: widening `best_new_mv_syntax`'s offer | |
| 62 | - /// set to `0..5` fires the counter immediately (9/2/2/1 on | |
| 63 | - /// mandelbrot 640x384x8, mandelbrot 320x192x8, mosaic 320x192x8, | |
| 64 | - /// testsrc2 640x384x8) and the same clips read 0 on revert. `note_drl_clamp` | |
| 65 | - /// and `DRL_CLAMP_HITS` are KEPT as the tripwire for the owning fix | |
| 66 | - /// (`deferred(unblock: the DRL owner widens the pricer past the writer's | |
| 67 | - /// `start + 2` ceiling, or retires the counter)`) -- this test will go red | |
| 68 | - /// the moment either happens, which is the signal to re-open the cell. | |
| 69 | - /// | |
| 70 | - /// cargo test -p ec-av1 --lib -- every_drl_index_the_new_mv_pricer | |
| 71 | - #[test] | |
| 72 | - fn every_drl_index_the_new_mv_pricer_offers_is_one_the_writer_can_signal() { | |
| 73 | - for n in 0..=4usize { | |
| 74 | - let mut stack = bare_stack(); | |
| 75 | - for i in 0..n { | |
| 76 | - stack.entries.push(crate::mvstack::StackEntry { | |
| 77 | - mv: (8 * (i as i32 + 1), -8 * (i as i32 + 1)), | |
| 78 | - weight: 1, | |
| 79 | - }); | |
| 80 | - stack.drl_ctx.push(0); | |
| 81 | - } | |
| 82 | - stack.nearest_mv = stack.entries.first().map_or((0, 0), |e| e.mv); | |
| 83 | - stack.near_mv = stack.entries.get(1).map_or((0, 0), |e| e.mv); | |
| 84 | - stack.pred_mv = stack.nearest_mv; | |
| 85 | - // Aim the vector at each entry in turn, so every index the offer | |
| 86 | - // set holds is the one that wins at least once. | |
| 87 | - for target in 0..n.max(1) { | |
| 88 | - let mv = stack.entries.get(target).map_or(stack.pred_mv, |e| e.mv); | |
| 89 | - let (_, idx) = | |
| 90 | - best_new_mv_syntax(&stack, mv).expect("a zero residual is always codable"); | |
| 91 | - let idx = usize::from(idx); | |
| 76 | + // The NEARMV arm's own offer set (`search_inter_block`, | |
| 77 | + // `search_skip_64`): indices 1 and 2, offered only when the stack | |
| 78 | + // really holds that entry. | |
| 79 | + for idx in 1..=2usize { | |
| 80 | + if stack.entries.get(idx).is_some() { | |
| 92 | 81 | assert_eq!( |
| 93 | - crate::tile::signalled_drl_idx(n, 0, idx), | |
| 82 | + crate::tile::signalled_drl_idx(n, 1, idx), | |
| 94 | 83 | idx, |
| 95 | - "NEWMV: a {n}-entry stack cannot signal the offered drl index {idx}", | |
| 84 | + "NEARMV: a {n}-entry stack cannot signal the offered drl index {idx}", | |
| 96 | 85 | ); |
| 97 | 86 | } |
| 98 | - // The NEARMV arm's own offer set (`search_inter_block`, | |
| 99 | - // `search_skip_64`): indices 1 and 2, offered only when the stack | |
| 100 | - // really holds that entry. | |
| 101 | - for idx in 1..=2usize { | |
| 102 | - if stack.entries.get(idx).is_some() { | |
| 103 | - assert_eq!( | |
| 104 | - crate::tile::signalled_drl_idx(n, 1, idx), | |
| 105 | - idx, | |
| 106 | - "NEARMV: a {n}-entry stack cannot signal the offered drl index {idx}", | |
| 107 | - ); | |
| 108 | - } | |
| 109 | - } | |
| 110 | 87 | } |
| 111 | 88 | } |
| 89 | +} | |
| 112 | 90 | |
| 113 | - pub(super) fn bare_stack() -> crate::mvstack::MvStack { | |
| 114 | - crate::mvstack::MvStack { | |
| 115 | - entries: Default::default(), | |
| 116 | - nearest_mv: (0, 0), | |
| 117 | - near_mv: (0, 0), | |
| 118 | - pred_mv: (0, 0), | |
| 119 | - new_mv_ctx: 0, | |
| 120 | - ref_mv_ctx: 0, | |
| 121 | - zero_mv_ctx: 0, | |
| 122 | - drl_ctx: Default::default(), | |
| 123 | - above_refs: (None, None), | |
| 124 | - left_refs: (None, None), | |
| 125 | - above_nbr: None, | |
| 126 | - left_nbr: None, | |
| 127 | - above_skip: false, | |
| 128 | - left_skip: false, | |
| 129 | - } | |
| 91 | +pub(super) fn bare_stack() -> crate::mvstack::MvStack { | |
| 92 | + crate::mvstack::MvStack { | |
| 93 | + entries: Default::default(), | |
| 94 | + nearest_mv: (0, 0), | |
| 95 | + near_mv: (0, 0), | |
| 96 | + pred_mv: (0, 0), | |
| 97 | + new_mv_ctx: 0, | |
| 98 | + ref_mv_ctx: 0, | |
| 99 | + zero_mv_ctx: 0, | |
| 100 | + drl_ctx: Default::default(), | |
| 101 | + above_refs: (None, None), | |
| 102 | + left_refs: (None, None), | |
| 103 | + above_nbr: None, | |
| 104 | + left_nbr: None, | |
| 105 | + above_skip: false, | |
| 106 | + left_skip: false, | |
| 130 | 107 | } |
| 108 | +} | |
| 131 | 109 | |
| 132 | - /// [`super::compound_ref_bits`] pays exactly the symbols tile.rs' | |
| 133 | - /// `write_compound_ref_frames` codes for a pair, each at that symbol's | |
| 134 | - /// own neighbour-derived context. Red before lane-ctx, where the pricer | |
| 135 | - /// spent four constants at CDF row 0 that assumed the pair was | |
| 136 | - /// LAST+GOLDEN or LAST+ALTREF -- so a LAST+BWDREF pair was priced as | |
| 137 | - /// LAST+ALTREF with its `comp_bwdref` p6 symbol missing entirely. | |
| 138 | - #[test] | |
| 139 | - fn the_compound_ref_pricer_pays_the_writers_own_symbol_sequence() { | |
| 140 | - use crate::cdf::{COMP_BWDREF, COMP_MODE, COMP_REF, COMP_REF_TYPE, UNI_COMP_REF}; | |
| 141 | - use crate::encode::symbol_bits as b; | |
| 142 | - use crate::mvstack::{ | |
| 143 | - ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, | |
| 144 | - LAST3_FRAME, NeighbourRef, comp_reference_type_ctx, reference_mode_ctx, | |
| 145 | - single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, | |
| 146 | - single_ref_p5_ctx, single_ref_p6_ctx, uni_comp_ref_p1_ctx, | |
| 110 | +/// [`super::compound_ref_bits`] pays exactly the symbols tile.rs' | |
| 111 | +/// `write_compound_ref_frames` codes for a pair, each at that symbol's | |
| 112 | +/// own neighbour-derived context. Red before lane-ctx, where the pricer | |
| 113 | +/// spent four constants at CDF row 0 that assumed the pair was | |
| 114 | +/// LAST+GOLDEN or LAST+ALTREF -- so a LAST+BWDREF pair was priced as | |
| 115 | +/// LAST+ALTREF with its `comp_bwdref` p6 symbol missing entirely. | |
| 116 | +#[test] | |
| 117 | +fn the_compound_ref_pricer_pays_the_writers_own_symbol_sequence() { | |
| 118 | + use crate::cdf::{COMP_BWDREF, COMP_MODE, COMP_REF, COMP_REF_TYPE, UNI_COMP_REF}; | |
| 119 | + use crate::encode::symbol_bits as b; | |
| 120 | + use crate::mvstack::{ | |
| 121 | + ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, | |
| 122 | + LAST3_FRAME, NeighbourRef, comp_reference_type_ctx, reference_mode_ctx, single_ref_p1_ctx, | |
| 123 | + single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx, | |
| 124 | + single_ref_p6_ctx, uni_comp_ref_p1_ctx, | |
| 125 | + }; | |
| 126 | + // (pair, unidirectional?, the tree's symbols as (table, p index, | |
| 127 | + // context selector, value)) -- transcribed from the writer. | |
| 128 | + // selector: 1..=6 are `single_ref_p*_ctx`, 7 is `uni_comp_ref_p1_ctx`. | |
| 129 | + type Sym = (char, usize, usize, usize); | |
| 130 | + let cases: [((i8, i8), bool, &[Sym]); 7] = [ | |
| 131 | + ( | |
| 132 | + (LAST_FRAME, LAST2_FRAME), | |
| 133 | + true, | |
| 134 | + &[('u', 0, 1, 0), ('u', 1, 7, 0)], | |
| 135 | + ), | |
| 136 | + ( | |
| 137 | + (LAST_FRAME, LAST3_FRAME), | |
| 138 | + true, | |
| 139 | + &[('u', 0, 1, 0), ('u', 1, 7, 1), ('u', 2, 5, 0)], | |
| 140 | + ), | |
| 141 | + ( | |
| 142 | + (LAST_FRAME, GOLDEN_FRAME), | |
| 143 | + true, | |
| 144 | + &[('u', 0, 1, 0), ('u', 1, 7, 1), ('u', 2, 5, 1)], | |
| 145 | + ), | |
| 146 | + ((BWDREF_FRAME, ALTREF_FRAME), true, &[('u', 0, 1, 1)]), | |
| 147 | + ( | |
| 148 | + (LAST_FRAME, ALTREF_FRAME), | |
| 149 | + false, | |
| 150 | + &[('c', 0, 3, 0), ('c', 1, 4, 0), ('b', 0, 2, 1)], | |
| 151 | + ), | |
| 152 | + ( | |
| 153 | + (LAST_FRAME, BWDREF_FRAME), | |
| 154 | + false, | |
| 155 | + &[ | |
| 156 | + ('c', 0, 3, 0), | |
| 157 | + ('c', 1, 4, 0), | |
| 158 | + ('b', 0, 2, 0), | |
| 159 | + ('b', 1, 6, 0), | |
| 160 | + ], | |
| 161 | + ), | |
| 162 | + ( | |
| 163 | + (LAST_FRAME, ALTREF2_FRAME), | |
| 164 | + false, | |
| 165 | + &[ | |
| 166 | + ('c', 0, 3, 0), | |
| 167 | + ('c', 1, 4, 0), | |
| 168 | + ('b', 0, 2, 0), | |
| 169 | + ('b', 1, 6, 1), | |
| 170 | + ], | |
| 171 | + ), | |
| 172 | + ]; |
crates/ec-av1/src/encoder/tests.rsmodified+2879 -3407
Diff too large; view file
crates/ec-av1/src/film_grain.rsmodified+18 -54
Diff too large; view file
crates/ec-av1/src/hits.rsdeleted+0 -47
Diff too large; view file
crates/ec-av1/src/intra.rsmodified+55 -49
Diff too large; view file
crates/ec-av1/src/lib.rsmodified+0 -6
Diff too large; view file
crates/ec-av1/src/mc.rsmodified+32 -25
Diff too large; view file
crates/ec-av1/src/motion_field.rsmodified+23 -59
Diff too large; view file
crates/ec-av1/src/msac.rsmodified+2 -286
Diff too large; view file
crates/ec-av1/src/mvstack.rsmodified+171 -119
Diff too large; view file
crates/ec-av1/src/par.rsmodified+9 -31
Diff too large; view file
crates/ec-av1/src/probe.rsmodified+0 -41
Diff too large; view file
crates/ec-av1/src/quant.rsmodified+0 -19
Diff too large; view file
crates/ec-av1/src/restoration.rsmodified+28 -68
Diff too large; view file
crates/ec-av1/src/stack_budget.rsdeleted+0 -990
Diff too large; view file
crates/ec-av1/src/stream/mod.rsmodified+6 -545
Diff too large; view file
crates/ec-av1/src/superres.rsmodified+0 -2
Diff too large; view file
crates/ec-av1/src/test_source.rsdeleted+0 -103
Diff too large; view file
crates/ec-av1/src/tile/blocks.rsmodified+10 -161
Diff too large; view file
crates/ec-av1/src/tile/mod.rsmodified+1 -52
Diff too large; view file
crates/ec-av1/tests/real_library.rsdeleted+0 -287
Diff too large; view file