Merge branch 'simplify/u3' into simplify/w1b
Browse files at this commit56 changed files +843 -19192
- 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 +5 -21
- 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 +29 -20
- crates/ec-av1/src/encode/frame.rs +26 -13
- crates/ec-av1/src/encode/inter_search.rs +40 -35
- crates/ec-av1/src/encode/mod.rs +0 -50
- crates/ec-av1/src/encode/more_tests.rs +6 -691
- crates/ec-av1/src/encode/split.rs +32 -93
- crates/ec-av1/src/encode/tests.rs +21 -1262
- crates/ec-av1/src/encoder/tests.rs +29 -557
- crates/ec-av1/src/film_grain.rs +10 -46
- crates/ec-av1/src/hits.rs +0 -47
- crates/ec-av1/src/intra.rs +53 -47
- 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 +17 -57
- 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 | "ec-av1-syntax", | 423 | "ec-av1-syntax", |
| 424 | "ec-core", | 424 | "ec-core", |
| 425 | "ec-testkit", | 425 | "ec-testkit", |
| 426 | - "stats_alloc", | ||
| 427 | - "tracking-allocator", | ||
| 428 | ] | 426 | ] |
| 429 | 427 | ||
| 430 | [[package]] | 428 | [[package]] |
| @@ -1731,12 +1729,6 @@ version = "1.2.1" | |||
| 1731 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1729 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1732 | checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" | 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 | [[package]] | 1732 | [[package]] |
| 1741 | name = "strength_reduce" | 1733 | name = "strength_reduce" |
| 1742 | version = "0.2.4" | 1734 | version = "0.2.4" |
crates/ec-av1/Cargo.tomlmodified+0 -11
| @@ -12,16 +12,5 @@ ec-av1-syntax.workspace = true | |||
| 12 | archmage = "=0.9.31-beta.1" | 12 | archmage = "=0.9.31-beta.1" |
| 13 | bytemuck = "1" | 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 | [dev-dependencies] | 15 | [dev-dependencies] |
| 24 | ec-testkit.workspace = true | 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 | Option<PaletteY>, | 41 | Option<PaletteY>, |
| 42 | Option<PaletteUv>, | 42 | Option<PaletteUv>, |
| 43 | )> { | 43 | )> { |
| 44 | - let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); | ||
| 45 | // lane-tiny r2: EC_ISTEP-format trace (same "name=... val=... rng=..." | 44 | // lane-tiny r2: EC_ISTEP-format trace (same "name=... val=... rng=..." |
| 46 | // shape the oracle's own `ec_read_intra_frame_mode_info_impl` prints | 45 | // shape the oracle's own `ec_read_intra_frame_mode_info_impl` prints |
| 47 | // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for | 46 | // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for |
| 48 | // line against the instrumented aomdec, not just `tell()`. | 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 | macro_rules! istep { | 48 | macro_rules! istep { |
| 62 | - ($name:literal, $val:expr) => { | 49 | + ($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 | - }; | ||
| 71 | } | 50 | } |
| 72 | // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single | 51 | // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single |
| 73 | // point every square caller routes through (see `read_intra_mode_rect`). | 52 | // point every square caller routes through (see `read_intra_mode_rect`). |
| 74 | - let cfl = if cfl && side > 32 { | 53 | + let cfl = if cfl && side > 32 { false } else { cfl }; |
| 75 | - hit!(NOCFL_UV_MODE_HITS); | ||
| 76 | - false | ||
| 77 | - } else { | ||
| 78 | - cfl | ||
| 79 | - }; | ||
| 80 | // spec 5.11.6 `intra_frame_mode_info`: `intra_segment_id` is read BEFORE | 54 | // spec 5.11.6 `intra_frame_mode_info`: `intra_segment_id` is read BEFORE |
| 81 | // `skip` when `SegIdPreSkip`, and after it otherwise. | 55 | // `skip` when `SegIdPreSkip`, and after it otherwise. |
| 82 | let (seg_w_mi, seg_h_mi) = (side / 4, side / 4); | 56 | let (seg_w_mi, seg_h_mi) = (side / 4, side / 4); |
| @@ -84,13 +58,6 @@ pub(super) fn read_intra_mode( | |||
| 84 | intra_segment_id(dec, cdfs, mi_r, mi_c, seg_w_mi, seg_h_mi, false, fctx); | 58 | intra_segment_id(dec, cdfs, mi_r, mi_c, seg_w_mi, seg_h_mi, false, fctx); |
| 85 | } | 59 | } |
| 86 | let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0; | 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 | istep!("skip", skip as i32); | 61 | istep!("skip", skip as i32); |
| 95 | if !seg_id_pre_skip(fctx) { | 62 | if !seg_id_pre_skip(fctx) { |
| 96 | intra_segment_id(dec, cdfs, mi_r, mi_c, seg_w_mi, seg_h_mi, skip, fctx); | 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 | // that merely allows (but never uses) intrabc. | 84 | // that merely allows (but never uses) intrabc. |
| 118 | if allow_intrabc { | 85 | if allow_intrabc { |
| 119 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; | 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 | if use_intrabc { | 87 | if use_intrabc { |
| 131 | let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (side / MI, side / MI), fctx); | 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 | fctx.intrabc_dv.with(|c| c.set(Some(dv))); | 89 | fctx.intrabc_dv.with(|c| c.set(Some(dv))); |
| 136 | - hit!(INTRABC_HITS); | ||
| 137 | // spec 5.11.13 / libaom `read_intra_frame_mode_info` returns the | 90 | // spec 5.11.13 / libaom `read_intra_frame_mode_info` returns the |
| 138 | // moment `is_intrabc_block`: no y/uv mode, angle delta, palette, | 91 | // moment `is_intrabc_block`: no y/uv mode, angle delta, palette, |
| 139 | // CFL or filter-intra syntax follows. `YMode`/`UVMode` are forced | 92 | // CFL or filter-intra syntax follows. `YMode`/`UVMode` are forced |
| @@ -145,21 +98,9 @@ pub(super) fn read_intra_mode( | |||
| 145 | let above_ctx = INTRA_MODE_CTX[above_mode]; | 98 | let above_ctx = INTRA_MODE_CTX[above_mode]; |
| 146 | let left_ctx = INTRA_MODE_CTX[left_mode]; | 99 | let left_ctx = INTRA_MODE_CTX[left_mode]; |
| 147 | let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]); | 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 | istep!("mode", mode as i32); | 101 | istep!("mode", mode as i32); |
| 155 | let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { | 102 | let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { |
| 156 | let delta = read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]); | 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 | delta | 104 | delta |
| 164 | } else { | 105 | } else { |
| 165 | 0 | 106 | 0 |
| @@ -174,18 +115,10 @@ pub(super) fn read_intra_mode( | |||
| 174 | let uv_mode = if !has_chroma { | 115 | let uv_mode = if !has_chroma { |
| 175 | DC_PRED | 116 | DC_PRED |
| 176 | } else if cfl { | 117 | } else if cfl { |
| 177 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 178 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 118 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 179 | } else { | 119 | } else { |
| 180 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 181 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 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 | istep!("uv_mode", uv_mode as i32); | 122 | istep!("uv_mode", uv_mode as i32); |
| 190 | let alpha = if cfl && uv_mode == UV_CFL_PRED { | 123 | let alpha = if cfl && uv_mode == UV_CFL_PRED { |
| 191 | Some(read_cfl_alphas(dec, cdfs)) | 124 | Some(read_cfl_alphas(dec, cdfs)) |
| @@ -199,24 +132,17 @@ pub(super) fn read_intra_mode( | |||
| 199 | // 78 against ffmpeg, traced 2026-08-27) -- an existing, un-lane-touched | 132 | // 78 against ffmpeg, traced 2026-08-27) -- an existing, un-lane-touched |
| 200 | // bug in that fallback this lane's own scope does not cover. Keep it | 133 | // bug in that fallback this lane's own scope does not cover. Keep it |
| 201 | // refused here rather than ship a silently-wrong decode. | 134 | // refused here rather than ship a silently-wrong decode. |
| 202 | - if (9..=12).contains(&uv_mode) { | ||
| 203 | - hit!(SMOOTH_UV_HITS); | ||
| 204 | - } | ||
| 205 | // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the | 135 | // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the |
| 206 | // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads | 136 | // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads |
| 207 | // `angle_delta_uv` off `get_uv_mode(uv_mode)`, never off `uv_mode` raw, | 137 | // `angle_delta_uv` off `get_uv_mode(uv_mode)`, never off `uv_mode` raw, |
| 208 | // so a CFL block (uv_mode==13, outside `V_PRED..=D67_PRED`) already takes | 138 | // so a CFL block (uv_mode==13, outside `V_PRED..=D67_PRED`) already takes |
| 209 | // the `else` branch below and never reads one either way. | 139 | // the `else` branch below and never reads one either way. |
| 210 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { | 140 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 211 | - hit!(DIRECTIONAL_UV_HITS); | ||
| 212 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | 141 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 213 | } else { | 142 | } else { |
| 214 | 0 | 143 | 0 |
| 215 | }; | 144 | }; |
| 216 | istep!("angle_uv", angle_delta_uv); | 145 | istep!("angle_uv", angle_delta_uv); |
| 217 | - if angle_delta_uv != 0 { | ||
| 218 | - hit!(UV_ANGLE_DELTA_HITS); | ||
| 219 | - } | ||
| 220 | // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called | 146 | // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called |
| 221 | // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`): | 147 | // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`): |
| 222 | // gated by `av1_allow_palette` (blockd.h -- size bound only, | 148 | // gated by `av1_allow_palette` (blockd.h -- size bound only, |
| @@ -244,32 +170,11 @@ pub(super) fn read_intra_mode( | |||
| 244 | let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; | 170 | let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; |
| 245 | if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx(side) { | 171 | if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx(side) { |
| 246 | let (mode_ctx, cache) = palette.unwrap_or((0, &[])); | 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 | let use_palette_y = | 173 | let use_palette_y = |
| 254 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][mode_ctx]) != 0; | 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 | if use_palette_y { | 175 | if use_palette_y { |
| 263 | let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]); | 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 | let colors = read_palette_colors_y(dec, n, cache, fctx); | 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 | palette_y_pending = Some((n, colors)); | 178 | palette_y_pending = Some((n, colors)); |
| 274 | } | 179 | } |
| 275 | // `read_palette_mode_info`'s UV half (decodemv.c:588): read | 180 | // `read_palette_mode_info`'s UV half (decodemv.c:588): read |
| @@ -313,20 +218,9 @@ pub(super) fn read_intra_mode( | |||
| 313 | && let Some(class) = filter_intra_size_class(side) | 218 | && let Some(class) = filter_intra_size_class(side) |
| 314 | { | 219 | { |
| 315 | let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[class]) != 0; | 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 | istep!("use_filter_intra", use_filter_intra as i32); | 221 | istep!("use_filter_intra", use_filter_intra as i32); |
| 324 | if use_filter_intra { | 222 | if use_filter_intra { |
| 325 | - hit!(FILTER_INTRA_HITS); | ||
| 326 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); | 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 | istep!("filter_intra_mode", fi_mode as i32); | 224 | istep!("filter_intra_mode", fi_mode as i32); |
| 331 | filter_intra = Some(fi_mode); | 225 | filter_intra = Some(fi_mode); |
| 332 | } | 226 | } |
| @@ -342,10 +236,6 @@ pub(super) fn read_intra_mode( | |||
| 342 | palette_onscreen(mi_r, mi_c, side, side, fctx), | 236 | palette_onscreen(mi_r, mi_c, side, side, fctx), |
| 343 | false, | 237 | false, |
| 344 | ); | 238 | ); |
| 345 | - hit!(PALETTE_HITS); | ||
| 346 | - if trace { | ||
| 347 | - eprintln!("TRACE palette_y size={n} colors={:?}", &colors[..n]); | ||
| 348 | - } | ||
| 349 | PaletteY { | 239 | PaletteY { |
| 350 | size: n, | 240 | size: n, |
| 351 | colors, | 241 | colors, |
| @@ -372,14 +262,6 @@ pub(super) fn read_intra_mode( | |||
| 372 | on, | 262 | on, |
| 373 | true, | 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 | PaletteUv { | 265 | PaletteUv { |
| 384 | size: n, | 266 | size: n, |
| 385 | u_colors, | 267 | u_colors, |
| @@ -412,7 +294,6 @@ pub(super) const UV_CFL_PRED: usize = 13; | |||
| 412 | /// joint sign the same way. Returns each plane's final signed `alpha_q3` | 294 | /// joint sign the same way. Returns each plane's final signed `alpha_q3` |
| 413 | /// (`cfl_idx_to_alpha`, cfl.c): magnitude `idx + 1`, sign-zero collapsing to 0. | 295 | /// (`cfl_idx_to_alpha`, cfl.c): magnitude `idx + 1`, sign-zero collapsing to 0. |
| 414 | pub(super) fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) { | 296 | pub(super) fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) { |
| 415 | - hit!(CFL_BLOCK_HITS); | ||
| 416 | let joint_sign = dec.symbol(&mut cdfs.cfl_sign) as i32; | 297 | let joint_sign = dec.symbol(&mut cdfs.cfl_sign) as i32; |
| 417 | let sign_u = ((joint_sign + 1) * 11) >> 5; | 298 | let sign_u = ((joint_sign + 1) * 11) >> 5; |
| 418 | let sign_v = (joint_sign + 1) - 3 * sign_u; | 299 | let sign_v = (joint_sign + 1) - 3 * sign_u; |
| @@ -461,7 +342,6 @@ pub(super) fn cfl_ac_ss( | |||
| 461 | ss_y: usize, | 342 | ss_y: usize, |
| 462 | ) -> Vec<i32> { | 343 | ) -> Vec<i32> { |
| 463 | if ss_x == 0 && ss_y == 0 { | 344 | if ss_x == 0 && ss_y == 0 { |
| 464 | - hit!(CFL_AC_444_HITS); | ||
| 465 | let mut ac = vec![0i32; bw * bh]; | 345 | let mut ac = vec![0i32; bw * bh]; |
| 466 | let mut sum = 0i32; | 346 | let mut sum = 0i32; |
| 467 | for row in 0..bh { | 347 | for row in 0..bh { |
| @@ -476,12 +356,6 @@ pub(super) fn cfl_ac_ss( | |||
| 476 | ac.iter_mut().for_each(|v| *v -= avg); | 356 | ac.iter_mut().for_each(|v| *v -= avg); |
| 477 | ac | 357 | ac |
| 478 | } else if ss_x == 1 && ss_y == 0 { | 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 | let (cw, ch) = (bw >> 1, bh); | 359 | let (cw, ch) = (bw >> 1, bh); |
| 486 | let mut ac = vec![0i32; cw * ch]; | 360 | let mut ac = vec![0i32; cw * ch]; |
| 487 | let mut sum = 0i32; | 361 | let mut sum = 0i32; |
| @@ -500,10 +374,8 @@ pub(super) fn cfl_ac_ss( | |||
| 500 | ac.iter_mut().for_each(|v| *v -= avg); | 374 | ac.iter_mut().for_each(|v| *v -= avg); |
| 501 | ac | 375 | ac |
| 502 | } else if bw == bh { | 376 | } else if bw == bh { |
| 503 | - hit!(CFL_AC_420_SQ_HITS); | ||
| 504 | cfl_ac_q3(y, px, py, bw) | 377 | cfl_ac_q3(y, px, py, bw) |
| 505 | } else { | 378 | } else { |
| 506 | - hit!(CFL_AC_420_RECT_HITS); | ||
| 507 | cfl_ac_q3_rect(y, px, py, bw, bh) | 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 | bh: usize, | 387 | bh: usize, |
| 516 | sample: impl Fn(usize, usize) -> i32, | 388 | sample: impl Fn(usize, usize) -> i32, |
| 517 | ) -> Vec<i32> { | 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 | let (cw, ch) = (bw / 2, bh / 2); | 390 | let (cw, ch) = (bw / 2, bh / 2); |
| 523 | let mut ac = vec![0i32; cw * ch]; | 391 | let mut ac = vec![0i32; cw * ch]; |
| 524 | let mut sum = 0i32; | 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 | /// lane-av1unwritten: whether a subsize has a chroma PLANE BLOCK at this | 421 | /// lane-av1unwritten: whether a subsize has a chroma PLANE BLOCK at this |
| 823 | /// frame's subsampling -- libaom `av1_ss_size_lookup[bsize][ss_x][ss_y] != | 422 | /// frame's subsampling -- libaom `av1_ss_size_lookup[bsize][ss_x][ss_y] != |
| 824 | /// BLOCK_INVALID` (`common_data.c`), which `decode_partition` checks on every | 423 | /// BLOCK_INVALID` (`common_data.c`), which `decode_partition` checks on every |
| @@ -990,26 +589,6 @@ pub(super) fn refuse_invalid_subsize( | |||
| 990 | part: usize, | 589 | part: usize, |
| 991 | fctx: &crate::decode::FrameCtx, | 590 | fctx: &crate::decode::FrameCtx, |
| 992 | ) -> Result<()> { | 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 | let (bw, bh) = partition_subsize_dims(bsize, part); | 592 | let (bw, bh) = partition_subsize_dims(bsize, part); |
| 1014 | if chroma_plane_block_codable(bw, bh, ss_x(fctx), ss_y(fctx)) { | 593 | if chroma_plane_block_codable(bw, bh, ss_x(fctx), ss_y(fctx)) { |
| 1015 | Ok(()) | 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 | /// [`chroma_plane_block_codable`] as libaom's refusal: a returned error naming | 600 | /// [`chroma_plane_block_codable`] as libaom's refusal: a returned error naming |
| 1104 | /// the shape and the subsampling mode, never an `assert!` -- a partition symbol | 601 | /// the shape and the subsampling mode, never an `assert!` -- a partition symbol |
| 1105 | /// is stream data, so a hostile file can reach it. | 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 | /// A frame plane's own backing store, `n` samples, zero-filled. | 615 | /// A frame plane's own backing store, `n` samples, zero-filled. |
| 1177 | -/// | 616 | +pub(super) fn fresh_plane(n: usize) -> Vec<u16> { |
| 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 | - } | ||
| 1196 | vec![0u16; n] | 617 | vec![0u16; n] |
| 1197 | } | 618 | } |
| 1198 | 619 | ||
| @@ -1227,52 +648,6 @@ pub(super) struct PlaneBuf<'a> { | |||
| 1227 | pub(super) plane: u8, | 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 | impl PlaneBuf<'_> { | 651 | impl PlaneBuf<'_> { |
| 1277 | /// Sets this plane's own tile pixel origin ([`Self::tile_x0`]/ | 652 | /// Sets this plane's own tile pixel origin ([`Self::tile_x0`]/ |
| 1278 | /// [`Self::tile_y0`]) before that tile's own superblock walk. `x0`/`y0` | 653 | /// [`Self::tile_y0`]) before that tile's own superblock walk. `x0`/`y0` |
| @@ -1356,12 +731,6 @@ impl PlaneBuf<'_> { | |||
| 1356 | }); | 731 | }); |
| 1357 | let corner = | 732 | let corner = |
| 1358 | (x > self.tile_x0 && y > self.tile_y0).then(|| self.data[(y - 1) * self.width + x - 1]); | 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 | (above, left, corner) | 734 | (above, left, corner) |
| 1366 | } | 735 | } |
| 1367 | 736 | ||
| @@ -1398,18 +767,6 @@ impl PlaneBuf<'_> { | |||
| 1398 | buf | 767 | buf |
| 1399 | } else { | 768 | } else { |
| 1400 | let (above, left, corner) = self.edges_rect(x, y, bw, bh, reach); | 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 | let mut prediction = vec![0u16; bw * bh]; | 770 | let mut prediction = vec![0u16; bw * bh]; |
| 1414 | if let Some(fi_mode) = filter_intra { | 771 | if let Some(fi_mode) = filter_intra { |
| 1415 | crate::intra::predict_filter_intra( | 772 | crate::intra::predict_filter_intra( |
| @@ -1442,25 +799,7 @@ impl PlaneBuf<'_> { | |||
| 1442 | }; | 799 | }; |
| 1443 | // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's | 800 | // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's |
| 1444 | // EC_PRED/EC_PREDND rungs (x/y are this plane's pixel origin). | 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 | let residual = dense_residual(residual, bw * bh); | 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 | for row in 0..bh { | 803 | for row in 0..bh { |
| 1465 | // Same bottom/right frame-edge clip as [`Self::reconstruct`]'s | 804 | // Same bottom/right frame-edge clip as [`Self::reconstruct`]'s |
| 1466 | // (lane-sb128c r8) -- a 64x128 block at the right edge of a frame | 805 | // (lane-sb128c r8) -- a 64x128 block at the right edge of a frame |
| @@ -1481,16 +820,6 @@ impl PlaneBuf<'_> { | |||
| 1481 | base = (base + cfl_scaled(alpha_q3, ac)).clamp(0, sample_max(fctx)); | 820 | base = (base + cfl_scaled(alpha_q3, ac)).clamp(0, sample_max(fctx)); |
| 1482 | } | 821 | } |
| 1483 | let sample = (base + residual[idx]).clamp(0, sample_max(fctx)) as u16; | 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 | self.data.to_mut()[(y + row) * self.width + x + col] = sample; | 823 | self.data.to_mut()[(y + row) * self.width + x + col] = sample; |
| 1495 | } | 824 | } |
| 1496 | } | 825 | } |
| @@ -1498,15 +827,6 @@ impl PlaneBuf<'_> { | |||
| 1498 | // -- a block whose prediction matches the oracle's but whose written | 827 | // -- a block whose prediction matches the oracle's but whose written |
| 1499 | // samples do not is either a residual defect or a later overwrite, and | 828 | // samples do not is either a residual defect or a later overwrite, and |
| 1500 | // only this print separates the two. | 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 | /// Predicts under `mode` then adds `residual` (side*side, raster), | 832 | /// Predicts under `mode` then adds `residual` (side*side, raster), |
| @@ -1553,13 +873,6 @@ impl PlaneBuf<'_> { | |||
| 1553 | buf | 873 | buf |
| 1554 | } else { | 874 | } else { |
| 1555 | let (above, left, corner) = self.edges(x, y, side, reach); | 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 | let mut prediction = vec![0u16; side * side]; | 876 | let mut prediction = vec![0u16; side * side]; |
| 1564 | if let Some(fi_mode) = filter_intra { | 877 | if let Some(fi_mode) = filter_intra { |
| 1565 | crate::intra::predict_filter_intra( | 878 | crate::intra::predict_filter_intra( |
| @@ -1599,26 +912,7 @@ impl PlaneBuf<'_> { | |||
| 1599 | }; | 912 | }; |
| 1600 | // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's | 913 | // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's |
| 1601 | // EC_PRED/EC_PREDND rungs (x/y are this plane's pixel origin). | 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 | let residual = dense_residual(residual, side * side); | 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 | for row in 0..side { | 916 | for row in 0..side { |
| 1623 | // lane-sb128c r8: libaom's frame buffer is superblock | 917 | // lane-sb128c r8: libaom's frame buffer is superblock |
| 1624 | // aligned; ours is padded to 32 (`block_grid`), so a 64x64 | 918 | // aligned; ours is padded to 32 (`block_grid`), so a 64x64 |
| @@ -1644,16 +938,6 @@ impl PlaneBuf<'_> { | |||
| 1644 | base = (base + cfl_scaled(alpha_q3, ac)).clamp(0, sample_max(fctx)); | 938 | base = (base + cfl_scaled(alpha_q3, ac)).clamp(0, sample_max(fctx)); |
| 1645 | } | 939 | } |
| 1646 | let sample = (base + residual[idx]).clamp(0, sample_max(fctx)) as u16; | 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 | self.data.to_mut()[(y + row) * self.width + x + col] = sample; | 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 | scan: &[u16], | 954 | scan: &[u16], |
| 1671 | plane_idx: usize, | 955 | plane_idx: usize, |
| 1672 | around: (bool, bool, i32), | 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 | tx_mode: usize, | 957 | tx_mode: usize, |
| 1677 | predict_mode: usize, | 958 | predict_mode: usize, |
| 1678 | angle_delta: i32, | 959 | angle_delta: i32, |
| @@ -1684,17 +965,9 @@ pub(super) fn read_plane( | |||
| 1684 | cy: usize, | 965 | cy: usize, |
| 1685 | side: usize, | 966 | side: usize, |
| 1686 | tx_side: usize, | 967 | tx_side: usize, |
| 1687 | - base_q_idx: u8, | ||
| 1688 | cfl: Option<(i32, CflSrc)>, | 968 | cfl: Option<(i32, CflSrc)>, |
| 1689 | filter_intra: Option<usize>, | 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 | luma_skip_ctx: Option<usize>, | 970 | luma_skip_ctx: Option<usize>, |
| 1697 | - // See [`PlaneBuf::reconstruct`]'s own doc: caller's neighbour-smooth check. | ||
| 1698 | smooth_neighbor: bool, | 971 | smooth_neighbor: bool, |
| 1699 | fctx: &crate::decode::FrameCtx, | 972 | fctx: &crate::decode::FrameCtx, |
| 1700 | ) -> Result<Grid> { | 973 | ) -> Result<Grid> { |
| @@ -1706,8 +979,6 @@ pub(super) fn read_plane( | |||
| 1706 | if plane_idx > 0 && mono(fctx) { | 979 | if plane_idx > 0 && mono(fctx) { |
| 1707 | return Ok(Grid::Zero(side * side)); | 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 | let skip_ctx = if plane_idx == 0 { | 982 | let skip_ctx = if plane_idx == 0 { |
| 1712 | luma_skip_ctx.unwrap_or(0) | 983 | luma_skip_ctx.unwrap_or(0) |
| 1713 | } else { | 984 | } else { |
| @@ -1733,12 +1004,6 @@ pub(super) fn read_plane( | |||
| 1733 | // labelling its unit `plane=0`, and a sweep reading a second-luma-unit | 1004 | // labelling its unit `plane=0`, and a sweep reading a second-luma-unit |
| 1734 | // phantom out of that label (class `rung-mislabels-plane`). Diagnostic | 1005 | // phantom out of that label (class `rung-mislabels-plane`). Diagnostic |
| 1735 | // only: no gate asserts decode behaviour off this line. | 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 | let tx_mode = if plane_idx == 0 { | 1007 | let tx_mode = if plane_idx == 0 { |
| 1743 | fi_tx_row(tx_mode, filter_intra) | 1008 | fi_tx_row(tx_mode, filter_intra) |
| 1744 | } else { | 1009 | } else { |
| @@ -1813,7 +1078,6 @@ pub(super) fn read_plane( | |||
| 1813 | default_tx_type, | 1078 | default_tx_type, |
| 1814 | None, | 1079 | None, |
| 1815 | )?; | 1080 | )?; |
| 1816 | - note_chroma_class1(plane_idx, tx_type); | ||
| 1817 | if plane_idx == 0 { | 1081 | if plane_idx == 0 { |
| 1818 | fctx.luma_tx_type.with(|c| c.set(tx_type)); | 1082 | fctx.luma_tx_type.with(|c| c.set(tx_type)); |
| 1819 | } | 1083 | } |
| @@ -1840,13 +1104,6 @@ pub(super) fn read_plane( | |||
| 1840 | stride: 0, | 1104 | stride: 0, |
| 1841 | lossless: lossless(fctx), | 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 | push_intra_tx( | 1107 | push_intra_tx( |
| 1851 | y, | 1108 | y, |
| 1852 | u, | 1109 | u, |
| @@ -1988,9 +1245,6 @@ pub(super) fn read_rect_chroma_unit( | |||
| 1988 | smooth_neighbor_uv: bool, | 1245 | smooth_neighbor_uv: bool, |
| 1989 | fctx: &crate::decode::FrameCtx, | 1246 | fctx: &crate::decode::FrameCtx, |
| 1990 | ) -> Result<Grid> { | 1247 | ) -> Result<Grid> { |
| 1991 | - if ss_x(fctx) == 1 && ss_y(fctx) == 0 && w != h { | ||
| 1992 | - hit!(CHROMA422_RECT_HITS); | ||
| 1993 | - } | ||
| 1994 | // The same three cases as [`read_plane`], for the same reason: at 32 points | 1248 | // The same three cases as [`read_plane`], for the same reason: at 32 points |
| 1995 | // an INTER chroma unit's transform set is `EXT_TX_SET_DCT_IDTX` (the luma's | 1249 | // an INTER chroma unit's transform set is `EXT_TX_SET_DCT_IDTX` (the luma's |
| 1996 | // coded `IDTX` survives) where the intra set is `EXT_TX_SET_DCTONLY`, and | 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 | usize::from(around.0) + usize::from(around.1) + chroma_skip_offset.unwrap_or(0), | 1270 | usize::from(around.0) + usize::from(around.1) + chroma_skip_offset.unwrap_or(0), |
| 2017 | dc_sign_ctx(around.2), | 1271 | dc_sign_ctx(around.2), |
| 2018 | default_tx, | 1272 | default_tx, |
| 2019 | - plane_idx, | ||
| 2020 | )?; | 1273 | )?; |
| 2021 | let residual = dequant_and_inverse_typed_wh( | 1274 | let residual = dequant_and_inverse_typed_wh( |
| 2022 | &levels, | 1275 | &levels, |
| @@ -2086,7 +1339,6 @@ pub(super) fn decode_block( | |||
| 2086 | let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(at); | 1339 | let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(at); |
| 2087 | let palette_uv_cache = neighbours.palette_uv_cache(at); | 1340 | let palette_uv_cache = neighbours.palette_uv_cache(at); |
| 2088 | let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c); | 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 | let ( | 1342 | let ( |
| 2091 | skip, | 1343 | skip, |
| 2092 | mode, | 1344 | mode, |
| @@ -2114,9 +1366,6 @@ pub(super) fn decode_block( | |||
| 2114 | c * (SUB / MI), | 1366 | c * (SUB / MI), |
| 2115 | fctx, | 1367 | fctx, |
| 2116 | )?; | 1368 | )?; |
| 2117 | - if at_tile_left && palette_y.is_some() { | ||
| 2118 | - hit!(PALETTE_TILE_LEFT_HITS); | ||
| 2119 | - } | ||
| 2120 | // lane-lossless: a lossless BLOCK's transform is TX_4X4 on every plane | 1369 | // lane-lossless: a lossless BLOCK's transform is TX_4X4 on every plane |
| 2121 | // (libaom `read_tx_size`, `decodeframe.c`), so the caller's per-size | 1370 | // (libaom `read_tx_size`, `decodeframe.c`), so the caller's per-size |
| 2122 | // tables/scans are replaced by the 4x4 ones and the block always takes the | 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 | uv_mode | 1434 | uv_mode |
| 2186 | }; | 1435 | }; |
| 2187 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | 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 | let smooth_neighbor_uv = | 1437 | let smooth_neighbor_uv = |
| 2192 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c, fctx); | 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 | let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); | 1439 | let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); |
| 2200 | // `TxMode::Select`'s `tx_depth` (spec 5.11.16): read for every intra | 1440 | // `TxMode::Select`'s `tx_depth` (spec 5.11.16): read for every intra |
| 2201 | // block, skipped or not. `logical_tx` is what the loop filter's edge | 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 | // lane-t900 r33 census: the t900 recipes resolved every tree UNIFORM. | 1495 | // lane-t900 r33 census: the t900 recipes resolved every tree UNIFORM. |
| 2257 | // lane-av1-ibcvtx: a tree that resolved to mixed leaf sizes is no | 1496 | // lane-av1-ibcvtx: a tree that resolved to mixed leaf sizes is no |
| 2258 | // longer refused -- the luma reconstruct below walks the tree's own | 1497 | // longer refused -- the luma reconstruct below walks the tree's own |
| 2259 | // leaf list per leaf (libaom `decode_token_recon_block`, whose token | 1498 | // leaf list per leaf (libaom `decode_token_recon_block`, whose token |
| 2260 | // loop reconstructs whatever `read_tx_size_vartx` resolved, per | 1499 | // loop reconstructs whatever `read_tx_size_vartx` resolved, per |
| 2261 | // transform unit), so mixed sizes reconstruct at their own stride. | 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 | Some(leaves) | 1501 | Some(leaves) |
| 2279 | } else { | 1502 | } else { |
| 2280 | None | 1503 | None |
| @@ -2291,9 +1514,6 @@ pub(super) fn decode_block( | |||
| 2291 | // single-unit path. | 1514 | // single-unit path. |
| 2292 | (lossless_tx(side.min(64), fctx), luma_tx) | 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 | let luma_set = if tx_select { | 1517 | let luma_set = if tx_select { |
| 2298 | txbset_for(logical_tx, reduced_tx_set) | 1518 | txbset_for(logical_tx, reduced_tx_set) |
| 2299 | } else { | 1519 | } else { |
| @@ -2400,9 +1620,6 @@ pub(super) fn decode_block( | |||
| 2400 | // Counted on the SHAPE, not on the arm below, so a gate can tell a stream | 1620 | // Counted on the SHAPE, not on the arm below, so a gate can tell a stream |
| 2401 | // that reaches this block apart from one that never does (class | 1621 | // that reaches this block apart from one that never does (class |
| 2402 | // gate-blind-to-feature). | 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 | if let Some(buf) = &palette_y_buf | 1623 | if let Some(buf) = &palette_y_buf |
| 2407 | && (logical_tx == side || skip) | 1624 | && (logical_tx == side || skip) |
| 2408 | { | 1625 | { |
| @@ -2453,9 +1670,6 @@ pub(super) fn decode_block( | |||
| 2453 | // narrower meaning (a READ split tx depth). | 1670 | // narrower meaning (a READ split tx depth). |
| 2454 | let split_tx_skip = logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); | 1671 | let split_tx_skip = logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); |
| 2455 | if split_tx_skip { | 1672 | if split_tx_skip { |
| 2456 | - if tx_select { | ||
| 2457 | - hit!(SKIP_SPLIT_TX_HITS); | ||
| 2458 | - } | ||
| 2459 | let n_axis = side / logical_tx; | 1673 | let n_axis = side / logical_tx; |
| 2460 | for tu_row in 0..n_axis { | 1674 | for tu_row in 0..n_axis { |
| 2461 | for tu_col in 0..n_axis { | 1675 | for tu_col in 0..n_axis { |
| @@ -2471,11 +1685,6 @@ pub(super) fn decode_block( | |||
| 2471 | tu_row * logical_tx, | 1685 | tu_row * logical_tx, |
| 2472 | logical_tx, | 1686 | logical_tx, |
| 2473 | reach, | 1687 | reach, |
| 2474 | - px, | ||
| 2475 | - py, | ||
| 2476 | - y.width, | ||
| 2477 | - y.height, | ||
| 2478 | - fctx, | ||
| 2479 | ); | 1688 | ); |
| 2480 | push_intra( | 1689 | push_intra( |
| 2481 | y, | 1690 | y, |
| @@ -2540,11 +1749,6 @@ pub(super) fn decode_block( | |||
| 2540 | luma_span_x, | 1749 | luma_span_x, |
| 2541 | luma_span_y, | 1750 | luma_span_y, |
| 2542 | reach, | 1751 | reach, |
| 2543 | - px, | ||
| 2544 | - py, | ||
| 2545 | - y.width, | ||
| 2546 | - y.height, | ||
| 2547 | - fctx, | ||
| 2548 | ) | 1752 | ) |
| 2549 | }; | 1753 | }; |
| 2550 | let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx_h); | 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 | window | 1784 | window |
| 2581 | }; | 1785 | }; |
| 2582 | if let Some((ub, _)) = &palette_uv_bufs { | 1786 | if let Some((ub, _)) = &palette_uv_bufs { |
| 2583 | - if cn_cols * cn_rows > 1 { | ||
| 2584 | - hit!(SKIP_CHROMA_OVERRIDE_WINDOW_HITS); | ||
| 2585 | - } | ||
| 2586 | set_palette_pred(chroma_window(ub), fctx); | 1787 | set_palette_pred(chroma_window(ub), fctx); |
| 2587 | } | 1788 | } |
| 2588 | push_intra_unit( | 1789 | push_intra_unit( |
| @@ -2645,18 +1846,6 @@ pub(super) fn decode_block( | |||
| 2645 | // side`, so only 4:2:2 changes. | 1846 | // side`, so only 4:2:2 changes. |
| 2646 | let u_grid = vec![0i32; chroma_side * chroma_height]; | 1847 | let u_grid = vec![0i32; chroma_side * chroma_height]; |
| 2647 | let v_grid = vec![0i32; chroma_side * chroma_height]; | 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 | neighbours.record( | 1849 | neighbours.record( |
| 2661 | at, | 1850 | at, |
| 2662 | side, | 1851 | side, |
| @@ -2692,7 +1881,6 @@ pub(super) fn decode_block( | |||
| 2692 | py, | 1881 | py, |
| 2693 | side, | 1882 | side, |
| 2694 | coeff_tx_side, | 1883 | coeff_tx_side, |
| 2695 | - base_q_idx, | ||
| 2696 | None, | 1884 | None, |
| 2697 | filter_intra, | 1885 | filter_intra, |
| 2698 | None, | 1886 | None, |
| @@ -2745,19 +1933,12 @@ pub(super) fn decode_block( | |||
| 2745 | cpy, | 1933 | cpy, |
| 2746 | chroma_side, | 1934 | chroma_side, |
| 2747 | chroma_tx, | 1935 | chroma_tx, |
| 2748 | - base_q_idx, | ||
| 2749 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | 1936 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 2750 | None, | 1937 | None, |
| 2751 | None, | 1938 | None, |
| 2752 | smooth_neighbor_uv, | 1939 | smooth_neighbor_uv, |
| 2753 | fctx, | 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 | if let Some((_, vb)) = &palette_uv_bufs { | 1942 | if let Some((_, vb)) = &palette_uv_bufs { |
| 2762 | set_palette_pred(vb.clone(), fctx); | 1943 | set_palette_pred(vb.clone(), fctx); |
| 2763 | } | 1944 | } |
| @@ -2779,7 +1960,6 @@ pub(super) fn decode_block( | |||
| 2779 | cpy, | 1960 | cpy, |
| 2780 | chroma_side, | 1961 | chroma_side, |
| 2781 | chroma_tx, | 1962 | chroma_tx, |
| 2782 | - base_q_idx, | ||
| 2783 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | 1963 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 2784 | None, | 1964 | None, |
| 2785 | None, | 1965 | None, |
| @@ -2877,11 +2057,6 @@ pub(super) fn decode_block( | |||
| 2877 | luma_span_x, | 2057 | luma_span_x, |
| 2878 | luma_span_y, | 2058 | luma_span_y, |
| 2879 | reach, | 2059 | reach, |
| 2880 | - px, | ||
| 2881 | - py, | ||
| 2882 | - y.width, | ||
| 2883 | - y.height, | ||
| 2884 | - fctx, | ||
| 2885 | ); | 2060 | ); |
| 2886 | let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx_h); | 2061 | let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx_h); |
| 2887 | if let Some((ub, vb)) = &palette_uv_bufs { | 2062 | if let Some((ub, vb)) = &palette_uv_bufs { |
| @@ -2916,7 +2091,6 @@ pub(super) fn decode_block( | |||
| 2916 | cu_y, | 2091 | cu_y, |
| 2917 | chroma_tx, | 2092 | chroma_tx, |
| 2918 | chroma_tx, | 2093 | chroma_tx, |
| 2919 | - base_q_idx, | ||
| 2920 | alpha | 2094 | alpha |
| 2921 | .zip(ac) | 2095 | .zip(ac) |
| 2922 | .map(|((au, av), ac)| (if plane_pass == 1 { au } else { av }, ac)), | 2096 | .map(|((au, av), ac)| (if plane_pass == 1 { au } else { av }, ac)), |
| @@ -2925,10 +2099,6 @@ pub(super) fn decode_block( | |||
| 2925 | smooth_neighbor_uv, | 2099 | smooth_neighbor_uv, |
| 2926 | fctx, | 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 | // Immediately, so the next unit of this block reads this | 2102 | // Immediately, so the next unit of this block reads this |
| 2933 | // one's coefficient context. `record` below stamps one | 2103 | // one's coefficient context. `record` below stamps one |
| 2934 | // chroma state across the whole block; the replay after | 2104 | // chroma state across the whole block; the replay after |
| @@ -3054,10 +2224,7 @@ pub(super) fn decode_block( | |||
| 3054 | // top-right 8x8 unit of a 16x16 D203 block bottom-left | 2224 | // top-right 8x8 unit of a 16x16 D203 block bottom-left |
| 3055 | // pixels libaom refuses outright (`col_off > 0`), which is | 2225 | // pixels libaom refuses outright (`col_off > 0`), which is |
| 3056 | // the diagonal wedge seed 46 reconstructed wrong. | 2226 | // the diagonal wedge seed 46 reconstructed wrong. |
| 3057 | - let tu_reach = tu_reach( | 2227 | + let tu_reach = tu_reach(side, side, tu_off_x, tu_off_y, tu_tx, reach); |
| 3058 | - side, side, tu_off_x, tu_off_y, tu_tx, reach, px, py, y.width, y.height, | ||
| 3059 | - fctx, | ||
| 3060 | - ); | ||
| 3061 | // This transform unit's own bsize (`tu_tx`) is smaller | 2228 | // This transform unit's own bsize (`tu_tx`) is smaller |
| 3062 | // than the block it sits in (`side`), so `txb_skip_ctx` is | 2229 | // than the block it sits in (`side`), so `txb_skip_ctx` is |
| 3063 | // the neighbour-magnitude table, not the lone-TU 0 (spec | 2230 | // the neighbour-magnitude table, not the lone-TU 0 (spec |
| @@ -3083,7 +2250,6 @@ pub(super) fn decode_block( | |||
| 3083 | (luma_set, luma_scan) | 2250 | (luma_set, luma_scan) |
| 3084 | }; | 2251 | }; |
| 3085 | if let Some(buf) = &palette_y_buf { | 2252 | if let Some(buf) = &palette_y_buf { |
| 3086 | - hit!(PALETTE_SPLIT_TX_HITS); | ||
| 3087 | let mut window = vec![0u16; tu_tx * tu_tx]; | 2253 | let mut window = vec![0u16; tu_tx * tu_tx]; |
| 3088 | for row in 0..tu_tx { | 2254 | for row in 0..tu_tx { |
| 3089 | let src = (tu_off_y + row) * side + tu_off_x; | 2255 | let src = (tu_off_y + row) * side + tu_off_x; |
| @@ -3108,26 +2274,13 @@ pub(super) fn decode_block( | |||
| 3108 | tu_px, | 2274 | tu_px, |
| 3109 | tu_py, | 2275 | tu_py, |
| 3110 | tu_tx, | 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 | if tu_tx == 64 { 32 } else { tu_tx }, | 2277 | if tu_tx == 64 { 32 } else { tu_tx }, |
| 3116 | - base_q_idx, | ||
| 3117 | None, | 2278 | None, |
| 3118 | filter_intra, | 2279 | filter_intra, |
| 3119 | Some(tu_skip_ctx), | 2280 | Some(tu_skip_ctx), |
| 3120 | smooth_neighbor, | 2281 | smooth_neighbor, |
| 3121 | fctx, | 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 | neighbours.record_mi_luma(tu_mi, tu_tx, &tu_grid); | 2284 | neighbours.record_mi_luma(tu_mi, tu_tx, &tu_grid); |
| 3132 | if first_leaf_tx.is_none() { | 2285 | if first_leaf_tx.is_none() { |
| 3133 | first_leaf_tx = Some(fctx.luma_tx_type.with(std::cell::Cell::get)); | 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 | let (unit_w, unit_h) = (chroma_tx / 4, chroma_tx_h / 4); | 2364 | let (unit_w, unit_h) = (chroma_tx / 4, chroma_tx_h / 4); |
| 3212 | if cu_col * unit_w >= max_units_w || cu_row * unit_h >= max_units_h { | 2365 | if cu_col * unit_w >= max_units_w || cu_row * unit_h >= max_units_h { |
| 3213 | - hit!(CHROMA_EDGE_TU_CLIP_HITS); | ||
| 3214 | continue; | 2366 | continue; |
| 3215 | } | 2367 | } |
| 3216 | // The chroma context arrays are indexed in LUMA mi, so this | 2368 | // The chroma context arrays are indexed in LUMA mi, so this |
| @@ -3240,11 +2392,6 @@ pub(super) fn decode_block( | |||
| 3240 | luma_span_x, | 2392 | luma_span_x, |
| 3241 | luma_span_y, | 2393 | luma_span_y, |
| 3242 | reach, | 2394 | reach, |
| 3243 | - px, | ||
| 3244 | - py, | ||
| 3245 | - y.width, | ||
| 3246 | - y.height, | ||
| 3247 | - fctx, | ||
| 3248 | ) | 2395 | ) |
| 3249 | }; | 2396 | }; |
| 3250 | let (cu_x, cu_y) = | 2397 | let (cu_x, cu_y) = |
| @@ -3282,7 +2429,6 @@ pub(super) fn decode_block( | |||
| 3282 | cu_y, | 2429 | cu_y, |
| 3283 | chroma_tx, | 2430 | chroma_tx, |
| 3284 | chroma_tx, | 2431 | chroma_tx, |
| 3285 | - base_q_idx, | ||
| 3286 | alpha.zip(ac).map(|((au, av), ac)| { | 2432 | alpha.zip(ac).map(|((au, av), ac)| { |
| 3287 | (if plane_pass == 1 { au } else { av }, ac) | 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 | if cn_rows * cn_cols > 1 { | 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 | // Immediately, so the NEXT unit of this same block reads | 2471 | // Immediately, so the NEXT unit of this same block reads |
| 3330 | // this one's coefficient context (libaom's chroma | 2472 | // this one's coefficient context (libaom's chroma |
| 3331 | // `txb_skip_ctx` for the second quadrant is 11, i.e. base | 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 | use super::*; | 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 | // lane-ibc444c: see `read_coeffs_rect`'s `#[track_caller]`. | 5 | // lane-ibc444c: see `read_coeffs_rect`'s `#[track_caller]`. |
| 70 | #[track_caller] | 6 | #[track_caller] |
| 71 | pub(super) fn read_coeffs( | 7 | pub(super) fn read_coeffs( |
| @@ -88,91 +24,12 @@ pub(super) fn read_coeffs( | |||
| 88 | // caller's block genuinely is `side` x `side`. | 24 | // caller's block genuinely is `side` x `side`. |
| 89 | rect_shape: Option<(usize, usize)>, | 25 | rect_shape: Option<(usize, usize)>, |
| 90 | ) -> Result<(Grid, TxType)> { | 26 | ) -> Result<(Grid, TxType)> { |
| 91 | - let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); | ||
| 92 | let side = coding.side; | 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 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; | 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 | // lane-ibc444c: this reader logs an `all_zero` step even for a read that | 29 | // lane-ibc444c: this reader logs an `all_zero` step even for a read that |
| 130 | // consumes ZERO bits, so `post_bit == bit` means "no symbol was read" -- | 30 | // consumes ZERO bits, so `post_bit == bit` means "no symbol was read" -- |
| 131 | // filter on it before pairing anything against the oracle. | 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 | if all_zero { | 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 | return Ok((Grid::Zero(side * side), TxType::DctDct)); | 33 | return Ok((Grid::Zero(side * side), TxType::DctDct)); |
| 177 | } | 34 | } |
| 178 | let mut grid = vec![0i32; side * side]; | 35 | let mut grid = vec![0i32; side * side]; |
| @@ -187,47 +44,14 @@ pub(super) fn read_coeffs( | |||
| 187 | // share their symbol order with (`Tx_Type_Inter_Inv_Set3`'s two | 44 | // share their symbol order with (`Tx_Type_Inter_Inv_Set3`'s two |
| 188 | // members are a prefix of `Tx_Type_Intra_Inv_Set2`'s five). | 45 | // members are a prefix of `Tx_Type_Intra_Inv_Set2`'s five). |
| 189 | let len = tx_type_cdf.len(); | 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 | let t = dec.symbol(tx_type_cdf); | 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 | tx_type = tx_type_from_symbol(len, t).ok_or_else(|| { | 48 | tx_type = tx_type_from_symbol(len, t).ok_or_else(|| { |
| 208 | unsupported(format!("a tx_type symbol outside its CDF's own set: {t}")) | 49 | unsupported(format!("a tx_type symbol outside its CDF's own set: {t}")) |
| 209 | })?; | 50 | })?; |
| 210 | } | 51 | } |
| 211 | 52 | ||
| 212 | let class = TxClass::of(tx_type); | 53 | let class = TxClass::of(tx_type); |
| 213 | - if class != TxClass::TwoD { | ||
| 214 | - hit!(TX_CLASS1_HITS); | ||
| 215 | - hit!(RECT_CLASS1_HITS); | ||
| 216 | - } | ||
| 217 | let eob = read_eob(dec, coding, class); | 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 | let class_scan; | 55 | let class_scan; |
| 232 | let scan: &[u16] = if class == TxClass::TwoD { | 56 | let scan: &[u16] = if class == TxClass::TwoD { |
| 233 | scan | 57 | scan |
| @@ -268,9 +92,6 @@ pub(super) fn read_coeffs( | |||
| 268 | let level = if scan_idx == eob - 1 { | 92 | let level = if scan_idx == eob - 1 { |
| 269 | let ctx = eob_coeff_ctx(scan_idx, side * side); | 93 | let ctx = eob_coeff_ctx(scan_idx, side * side); |
| 270 | let v = dec.symbol(&mut coding.base_eob[ctx]) as i32 + 1; | 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 | v | 95 | v |
| 275 | } else { | 96 | } else { |
| 276 | let ctx = if class == TxClass::TwoD && rect_shape.is_none() { | 97 | let ctx = if class == TxClass::TwoD && rect_shape.is_none() { |
| @@ -284,14 +105,6 @@ pub(super) fn read_coeffs( | |||
| 284 | base_ctx(levels, stride, row, col, class, rect_shape) | 105 | base_ctx(levels, stride, row, col, class, rect_shape) |
| 285 | }; | 106 | }; |
| 286 | let v = dec.symbol(&mut coding.base[ctx]) as i32; | 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 | v | 108 | v |
| 296 | }; | 109 | }; |
| 297 | let level = if level > NUM_BASE_LEVELS { | 110 | let level = if level > NUM_BASE_LEVELS { |
| @@ -312,16 +125,6 @@ pub(super) fn read_coeffs( | |||
| 312 | let mut sent = 0; | 125 | let mut sent = 0; |
| 313 | loop { | 126 | loop { |
| 314 | let k = dec.symbol(&mut coding.br[ctx]) as i32; | 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 | level += k; | 128 | level += k; |
| 326 | sent += BR_STEP; | 129 | sent += BR_STEP; |
| 327 | if k < BR_STEP || sent >= COEFF_BASE_RANGE { | 130 | if k < BR_STEP || sent >= COEFF_BASE_RANGE { |
| @@ -332,9 +135,6 @@ pub(super) fn read_coeffs( | |||
| 332 | } else { | 135 | } else { |
| 333 | level | 136 | level |
| 334 | }; | 137 | }; |
| 335 | - if ec_trace_coeff && scan_idx == eob - 1 { | ||
| 336 | - coeff_step_base_eob_level(dec, level); | ||
| 337 | - } | ||
| 338 | // Every coded level here is a magnitude in `0..=15` (base <= 3 plus | 138 | // Every coded level here is a magnitude in `0..=15` (base <= 3 plus |
| 339 | // at most `COEFF_BASE_RANGE` from the `br` loop; the Golomb tail is | 139 | // at most `COEFF_BASE_RANGE` from the `br` loop; the Golomb tail is |
| 340 | // added in the sign pass below, straight into `grid`), so the context | 140 | // added in the sign pass below, straight into `grid`), so the context |
| @@ -347,10 +147,6 @@ pub(super) fn read_coeffs( | |||
| 347 | nz_n += 1; | 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 | for &packed in nz_buf[..nz_n].iter().rev() { | 151 | for &packed in nz_buf[..nz_n].iter().rev() { |
| 356 | let c = (packed >> 4) as usize; | 152 | let c = (packed >> 4) as usize; |
| @@ -358,40 +154,18 @@ pub(super) fn read_coeffs( | |||
| 358 | let level = (packed & 15) as i32; | 154 | let level = (packed & 15) as i32; |
| 359 | let negative = if pos == 0 { | 155 | let negative = if pos == 0 { |
| 360 | let v = dec.symbol(&mut coding.dc_sign[sign_ctx]) == 1; | 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 | v | 157 | v |
| 365 | } else { | 158 | } else { |
| 366 | dec.literal(1) == 1 | 159 | dec.literal(1) == 1 |
| 367 | }; | 160 | }; |
| 368 | - if ec_trace_coeff { | ||
| 369 | - coeff_step_sign(dec, c, negative); | ||
| 370 | - } | ||
| 371 | let level = if level > MAX_BR_LEVEL { | 161 | let level = if level > MAX_BR_LEVEL { |
| 372 | let g = read_golomb(dec)?; | 162 | let g = read_golomb(dec)?; |
| 373 | - if trace { | ||
| 374 | - eprintln!("TRACE golomb pos={pos} value={g}"); | ||
| 375 | - } | ||
| 376 | level + g as i32 | 163 | level + g as i32 |
| 377 | } else { | 164 | } else { |
| 378 | level | 165 | level |
| 379 | }; | 166 | }; |
| 380 | - if ec_trace_coeff { | ||
| 381 | - coeff_step_post_golomb(dec, c, level); | ||
| 382 | - } | ||
| 383 | grid[pos] = if negative { -level } else { level }; | 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 | Ok((Grid::Own(grid), tx_type)) | 169 | Ok((Grid::Own(grid), tx_type)) |
| 396 | } | 170 | } |
| 397 | 171 | ||
| @@ -419,54 +193,12 @@ pub(super) fn read_coeffs_rect( | |||
| 419 | skip_ctx: usize, | 193 | skip_ctx: usize, |
| 420 | sign_ctx: usize, | 194 | sign_ctx: usize, |
| 421 | default_tx_type: TxType, | 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 | ) -> Result<(Grid, TxType)> { | 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 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; | 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 | if all_zero { | 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 | return Ok((Grid::Zero(w * h), TxType::DctDct)); | 199 | return Ok((Grid::Zero(w * h), TxType::DctDct)); |
| 467 | } | 200 | } |
| 468 | let mut grid = vec![0i32; w * h]; | 201 | let mut grid = vec![0i32; w * h]; |
| 469 | - hit!(RECT_COEFF_TU_HITS); | ||
| 470 | // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is | 202 | // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is |
| 471 | // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including | 203 | // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including |
| 472 | // the `V_DCT`/`H_DCT` members whose 1D tx class needs its own scan and | 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 | if let Some(tx_type_cdf) = coding.tx_type.as_deref_mut() { | 209 | if let Some(tx_type_cdf) = coding.tx_type.as_deref_mut() { |
| 478 | let len = tx_type_cdf.len(); | 210 | let len = tx_type_cdf.len(); |
| 479 | let t = dec.symbol(tx_type_cdf); | 211 | let t = dec.symbol(tx_type_cdf); |
| 480 | - crate::census::tx_type(len, t); | ||
| 481 | tx_type = tx_type_from_symbol(len, t).ok_or_else(|| { | 212 | tx_type = tx_type_from_symbol(len, t).ok_or_else(|| { |
| 482 | unsupported(format!("a tx_type symbol outside its CDF's own set: {t}")) | 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 | let class = TxClass::of(tx_type); | 216 | let class = TxClass::of(tx_type); |
| 492 | - if class != TxClass::TwoD { | ||
| 493 | - hit!(TX_CLASS1_HITS); | ||
| 494 | - } | ||
| 495 | let eob = read_eob(dec, coding, class); | 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 | let class_scan; | 218 | let class_scan; |
| 503 | let scan: &[u16] = if class == TxClass::TwoD { | 219 | let scan: &[u16] = if class == TxClass::TwoD { |
| 504 | scan | 220 | scan |
| @@ -570,12 +286,6 @@ pub(super) fn read_coeffs_rect( | |||
| 570 | base_ctx_rect(levels, stride, w, h, row, col, class) | 286 | base_ctx_rect(levels, stride, w, h, row, col, class) |
| 571 | }; | 287 | }; |
| 572 | let v = dec.symbol(&mut coding.base[ctx]) as i32; | 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 | v | 289 | v |
| 580 | }; | 290 | }; |
| 581 | let level = if level > NUM_BASE_LEVELS { | 291 | let level = if level > NUM_BASE_LEVELS { |
| @@ -596,12 +306,6 @@ pub(super) fn read_coeffs_rect( | |||
| 596 | let mut sent = 0; | 306 | let mut sent = 0; |
| 597 | loop { | 307 | loop { |
| 598 | let k = dec.symbol(&mut coding.br[ctx]) as i32; | 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 | level += k; | 309 | level += k; |
| 606 | sent += BR_STEP; | 310 | sent += BR_STEP; |
| 607 | if k < BR_STEP || sent >= COEFF_BASE_RANGE { | 311 | if k < BR_STEP || sent >= COEFF_BASE_RANGE { |
| @@ -618,19 +322,6 @@ pub(super) fn read_coeffs_rect( | |||
| 618 | nz_buf[nz_n] = ((scan_idx as u16) << 4) | level as u16; | 322 | nz_buf[nz_n] = ((scan_idx as u16) << 4) | level as u16; |
| 619 | nz_n += 1; | 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 | for &packed in nz_buf[..nz_n].iter().rev() { | 326 | for &packed in nz_buf[..nz_n].iter().rev() { |
| 636 | let pos = scan[(packed >> 4) as usize] as usize; | 327 | let pos = scan[(packed >> 4) as usize] as usize; |
| @@ -640,53 +331,18 @@ pub(super) fn read_coeffs_rect( | |||
| 640 | } else { | 331 | } else { |
| 641 | dec.literal(1) == 1 | 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 | let level = if level > MAX_BR_LEVEL { | 334 | let level = if level > MAX_BR_LEVEL { |
| 651 | let g = read_golomb(dec)?; | 335 | let g = read_golomb(dec)?; |
| 652 | level + g as i32 | 336 | level + g as i32 |
| 653 | } else { | 337 | } else { |
| 654 | level | 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 | grid[pos] = if negative { -level } else { level }; | 340 | grid[pos] = if negative { -level } else { level }; |
| 671 | } | 341 | } |
| 672 | // lane-d792: the rect unit's LEVEL grid in row-major (w) order, the | 342 | // lane-d792: the rect unit's LEVEL grid in row-major (w) order, the |
| 673 | // twin of the oracle's `EC_DQCOEFF` rung -- a residual mismatch whose | 343 | // twin of the oracle's `EC_DQCOEFF` rung -- a residual mismatch whose |
| 674 | // grids differ is a reader defect, one whose grids agree is a transform | 344 | // grids differ is a reader defect, one whose grids agree is a transform |
| 675 | // defect. | 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 | Ok((Grid::Own(grid), tx_type)) | 346 | Ok((Grid::Own(grid), tx_type)) |
| 691 | } | 347 | } |
| 692 | 348 | ||
| @@ -718,25 +374,11 @@ pub(super) fn read_chroma_coeffs_rect( | |||
| 718 | sign_ctx: usize, | 374 | sign_ctx: usize, |
| 719 | default_tx_type: TxType, | 375 | default_tx_type: TxType, |
| 720 | fctx: &crate::decode::FrameCtx, | 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 | ) -> Result<(Grid, TxType)> { | 377 | ) -> Result<(Grid, TxType)> { |
| 726 | if mono(fctx) { | 378 | if mono(fctx) { |
| 727 | return Ok((Grid::Zero(w * h), TxType::DctDct)); | 379 | return Ok((Grid::Zero(w * h), TxType::DctDct)); |
| 728 | } | 380 | } |
| 729 | - read_coeffs_rect( | 381 | + read_coeffs_rect(dec, coding, scan, w, h, skip_ctx, sign_ctx, default_tx_type) |
| 730 | - dec, | ||
| 731 | - coding, | ||
| 732 | - scan, | ||
| 733 | - w, | ||
| 734 | - h, | ||
| 735 | - skip_ctx, | ||
| 736 | - sign_ctx, | ||
| 737 | - default_tx_type, | ||
| 738 | - plane, | ||
| 739 | - ) | ||
| 740 | } | 382 | } |
| 741 | 383 | ||
| 742 | /// What one coded block leaves behind for the blocks that read it as a | 384 | /// What one coded block leaves behind for the blocks that read it as a |
| @@ -1233,7 +875,13 @@ impl Neighbours { | |||
| 1233 | /// [`SUB`]-grid cell it covers on both the above and left edges -- | 875 | /// [`SUB`]-grid cell it covers on both the above and left edges -- |
| 1234 | /// mirrors [`Self::record_rect`]'s loop shape, square-only (this lane's | 876 | /// mirrors [`Self::record_rect`]'s loop shape, square-only (this lane's |
| 1235 | /// call sites are all square blocks). | 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 | self.record_palette_y_rect( | 885 | self.record_palette_y_rect( |
| 1238 | (at.0 * (SUB / MI), at.1 * (SUB / MI)), | 886 | (at.0 * (SUB / MI), at.1 * (SUB / MI)), |
| 1239 | side, | 887 | side, |
| @@ -1256,9 +904,6 @@ impl Neighbours { | |||
| 1256 | colors: [u16; 8], | 904 | colors: [u16; 8], |
| 1257 | ) { | 905 | ) { |
| 1258 | let (r, c) = mi; | 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 | // lane-kf900 r6: mi (4px) granularity, libaom's own -- `palette_size` | 907 | // lane-kf900 r6: mi (4px) granularity, libaom's own -- `palette_size` |
| 1263 | // lives per mi cell in `MB_MODE_INFO`, and `xd->left_mbmi` is the mi | 908 | // lives per mi cell in `MB_MODE_INFO`, and `xd->left_mbmi` is the mi |
| 1264 | // cell immediately left of the block, not its 16px [`SUB`] cell. The | 909 | // cell immediately left of the block, not its 16px [`SUB`] cell. The |
| @@ -1633,12 +1278,6 @@ impl Neighbours { | |||
| 1633 | // TX_32X32 -- independent of this block's luma `tx_depth`. | 1278 | // TX_32X32 -- independent of this block's luma `tx_depth`. |
| 1634 | let uv_tx_w = ((w_mi * MI) >> ss_x(fctx)).clamp(4, 32) as u8; | 1279 | let uv_tx_w = ((w_mi * MI) >> ss_x(fctx)).clamp(4, 32) as u8; |
| 1635 | let uv_tx_h = ((h_mi * MI) >> ss_y(fctx)).clamp(4, 32) as u8; | 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 | let cur = fctx.current_delta_lf.with(|c| c.get()); | 1281 | let cur = fctx.current_delta_lf.with(|c| c.get()); |
| 1643 | let snapshot: [i8; 4] = if fctx.delta_lf_multi.with(|c| c.get()) { | 1282 | let snapshot: [i8; 4] = if fctx.delta_lf_multi.with(|c| c.get()) { |
| 1644 | std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8) | 1283 | std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8) |
| @@ -1727,11 +1366,6 @@ impl Neighbours { | |||
| 1727 | tx_h_px: u8, | 1366 | tx_h_px: u8, |
| 1728 | ) { | 1367 | ) { |
| 1729 | let (mi_r, mi_c) = at_mi; | 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 | for rr in 0..h_mi { | 1369 | for rr in 0..h_mi { |
| 1736 | let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c; | 1370 | let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c; |
| 1737 | fill_span(&mut self.tx_grid, start, w_mi, tx_px); | 1371 | fill_span(&mut self.tx_grid, start, w_mi, tx_px); |
| @@ -1748,14 +1382,14 @@ impl Neighbours { | |||
| 1748 | } | 1382 | } |
| 1749 | 1383 | ||
| 1750 | /// [`Self::fill_skip_grid`] with independent row/col extents (lane-partitions r1). | 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 | let (mi_r, mi_c) = at_mi; | 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 | for rr in 0..h_mi { | 1393 | for rr in 0..h_mi { |
| 1760 | let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c; | 1394 | let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c; |
| 1761 | fill_span( | 1395 | fill_span( |
| @@ -1907,7 +1541,8 @@ impl Neighbours { | |||
| 1907 | /// "no neighbour"). `ref_frame` is `-1` for an intra block, else the | 1541 | /// "no neighbour"). `ref_frame` is `-1` for an intra block, else the |
| 1908 | /// `1..=7` reference it coded (lane-av1refs's `single_ref_p*_ctx` needs | 1542 | /// `1..=7` reference it coded (lane-av1refs's `single_ref_p*_ctx` needs |
| 1909 | /// the real value, not just `is_inter`). | 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 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. | 1546 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. |
| 1912 | #[allow(clippy::too_many_arguments)] | 1547 | #[allow(clippy::too_many_arguments)] |
| 1913 | pub(super) fn record_inter( | 1548 | pub(super) fn record_inter( |
| @@ -1971,7 +1606,6 @@ impl Neighbours { | |||
| 1971 | skip_mode: bool, | 1606 | skip_mode: bool, |
| 1972 | ) { | 1607 | ) { |
| 1973 | let (r, c) = at_mi; | 1608 | let (r, c) = at_mi; |
| 1974 | - crate::census::block(w_mi, h_mi, is_inter, ref_frame, skip); | ||
| 1975 | // lane-t900 r8 (class new-map-ignores-tile-edge's twin: a map NOBODY | 1609 | // lane-t900 r8 (class new-map-ignores-tile-edge's twin: a map NOBODY |
| 1976 | // writes for a whole block class): an INTER block left the luma mode | 1610 | // writes for a whole block class): an INTER block left the luma mode |
| 1977 | // map untouched, so a later intra block's `get_intra_edge_filter_type` | 1611 | // map untouched, so a later intra block's `get_intra_edge_filter_type` |
| @@ -2077,7 +1711,6 @@ impl Neighbours { | |||
| 2077 | compound_idx: u8, | 1711 | compound_idx: u8, |
| 2078 | ) { | 1712 | ) { |
| 2079 | let (r, c) = at_mi; | 1713 | let (r, c) = at_mi; |
| 2080 | - crate::census::compound(); | ||
| 2081 | for cell in 0..w_mi { | 1714 | for cell in 0..w_mi { |
| 2082 | self.above_ref1[c + cell] = Some(ref1); | 1715 | self.above_ref1[c + cell] = Some(ref1); |
| 2083 | self.above_comp_group_idx[c + cell] = comp_group_idx; | 1716 | self.above_comp_group_idx[c + cell] = comp_group_idx; |
| @@ -2118,7 +1751,11 @@ impl Neighbours { | |||
| 2118 | 1751 | ||
| 2119 | /// [`Self::around`] taking the block's position directly in 4x4 mode-info | 1752 | /// [`Self::around`] taking the block's position directly in 4x4 mode-info |
| 2120 | /// units, for the same reason [`Self::record_mi`] does. | 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 | let side_mi = side / MI; | 1759 | let side_mi = side / MI; |
| 2123 | // One pass over the cells accumulating all three planes, not one pass | 1760 | // One pass over the cells accumulating all three planes, not one pass |
| 2124 | // per plane: the three planes of a cell live in the same | 1761 | // per plane: the three planes of a cell live in the same |
| @@ -2183,45 +1820,18 @@ impl Neighbours { | |||
| 2183 | o.2 += dc_vote(left[plane].dc); | 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 | out | 1823 | out |
| 2219 | } | 1824 | } |
| 2220 | 1825 | ||
| 2221 | /// [`Self::around`] with independent above (`w`)/left (`h`) extents, in | 1826 | /// [`Self::around`] with independent above (`w`)/left (`h`) extents, in |
| 2222 | /// pixels -- lane-rectwire, mirrors [`Self::record_rect`]'s asymmetric | 1827 | /// pixels -- lane-rectwire, mirrors [`Self::record_rect`]'s asymmetric |
| 2223 | /// extent pattern for a true rectangular strip's own coefficient context. | 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 | self.around_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h) | 1835 | self.around_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h) |
| 2226 | } | 1836 | } |
| 2227 | 1837 | ||
| @@ -2252,34 +1862,6 @@ impl Neighbours { | |||
| 2252 | o.2 += dc_vote(left[plane].dc); | 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 | out | 1865 | out |
| 2284 | } | 1866 | } |
| 2285 | 1867 | ||
| @@ -2297,8 +1879,12 @@ impl Neighbours { | |||
| 2297 | /// [`Self::luma_skip_ctx`] with the unit's own width and height in mi | 1879 | /// [`Self::luma_skip_ctx`] with the unit's own width and height in mi |
| 2298 | /// units (lane-rectsplitx r1) -- `get_txb_ctx_general` ORs the above | 1880 | /// units (lane-rectsplitx r1) -- `get_txb_ctx_general` ORs the above |
| 2299 | /// context over `tx_size_wide` and the left one over `tx_size_high`. | 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 { | 1882 | + pub(super) fn luma_skip_ctx_rect( |
| 2301 | - let side_mi = w_mi; | 1883 | + &self, |
| 1884 | + (mi_r, mi_c): (usize, usize), | ||
| 1885 | + w_mi: usize, | ||
| 1886 | + h_mi: usize, | ||
| 1887 | + ) -> usize { | ||
| 2302 | let above_mi = w_mi.min(self.mi_cols.saturating_sub(mi_c)); | 1888 | let above_mi = w_mi.min(self.mi_cols.saturating_sub(mi_c)); |
| 2303 | let left_mi = h_mi.min(self.mi_rows.saturating_sub(mi_r)); | 1889 | let left_mi = h_mi.min(self.mi_rows.saturating_sub(mi_r)); |
| 2304 | let mut top = 0u8; | 1890 | let mut top = 0u8; |
| @@ -2310,35 +1896,6 @@ impl Neighbours { | |||
| 2310 | left |= self.left[mi_r + cell][0].level; | 1896 | left |= self.left[mi_r + cell][0].level; |
| 2311 | } | 1897 | } |
| 2312 | let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)]; | 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 | ctx | 1899 | ctx |
| 2343 | } | 1900 | } |
| 2344 | 1901 | ||
| @@ -2373,7 +1930,14 @@ impl Neighbours { | |||
| 2373 | /// block to the right reads via `mi(row, col-1)`). Only sub-8x8 leaves | 1930 | /// block to the right reads via `mi(row, col-1)`). Only sub-8x8 leaves |
| 2374 | /// read these back, and only when the recorded position is exactly their | 1931 | /// read these back, and only when the recorded position is exactly their |
| 2375 | /// own neighbour -- see [`Self::sub8_mode_col`]'s doc. | 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 | let (last_r, last_c) = ((mi_r + mi_h - 1) as u16, (mi_c + mi_w - 1) as u16); | 1941 | let (last_r, last_c) = ((mi_r + mi_h - 1) as u16, (mi_c + mi_w - 1) as u16); |
| 2378 | let mode = mode as u8; | 1942 | let mode = mode as u8; |
| 2379 | for cell in 0..mi_w { | 1943 | for cell in 0..mi_w { |
| @@ -2451,9 +2015,6 @@ impl Neighbours { | |||
| 2451 | for row in mi_r..=last_r { | 2015 | for row in mi_r..=last_r { |
| 2452 | fill_span(&mut self.uv_owner, row * stride + mi_c, n, owner); | 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 | /// Whether either mi-exact chroma neighbour of the block at `(mi_r, mi_c)` | 2020 | /// Whether either mi-exact chroma neighbour of the block at `(mi_r, mi_c)` |
| @@ -2503,7 +2064,6 @@ impl Neighbours { | |||
| 2503 | c, | 2064 | c, |
| 2504 | ss_x(fctx), | 2065 | ss_x(fctx), |
| 2505 | ss_y(fctx), | 2066 | ss_y(fctx), |
| 2506 | - true, | ||
| 2507 | ) | 2067 | ) |
| 2508 | } | 2068 | } |
| 2509 | 2069 | ||
| @@ -2512,18 +2072,6 @@ impl Neighbours { | |||
| 2512 | /// counter wants this: it measures how often the snap CHANGES the answer, | 2072 | /// counter wants this: it measures how often the snap CHANGES the answer, |
| 2513 | /// which is what the lane-kf1200/kf900 chroma-reference fix buys. Every | 2073 | /// which is what the lane-kf1200/kf900 chroma-reference fix buys. Every |
| 2514 | /// decode path uses the snapping form. | 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 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. | 2075 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. |
| 2528 | #[allow(clippy::too_many_arguments)] | 2076 | #[allow(clippy::too_many_arguments)] |
| 2529 | pub(super) fn smooth_uv_neighbour_unsnapped( | 2077 | pub(super) fn smooth_uv_neighbour_unsnapped( |
| @@ -2534,7 +2082,6 @@ impl Neighbours { | |||
| 2534 | c: usize, | 2082 | c: usize, |
| 2535 | ss_x: usize, | 2083 | ss_x: usize, |
| 2536 | ss_y: usize, | 2084 | ss_y: usize, |
| 2537 | - decode_path: bool, | ||
| 2538 | ) -> bool { | 2085 | ) -> bool { |
| 2539 | // lane-mtfix r1: availability is TILE-relative on BOTH axes and on the | 2086 | // lane-mtfix r1: availability is TILE-relative on BOTH axes and on the |
| 2540 | // coarse fallback too. `above_uv_mode` is a frame-wide [`SUB`]-grid | 2087 | // coarse fallback too. `above_uv_mode` is a frame-wide [`SUB`]-grid |
| @@ -2545,11 +2092,6 @@ impl Neighbours { | |||
| 2545 | // at chroma (120, 32), the top-right tile's first block). | 2092 | // at chroma (120, 32), the top-right tile's first block). |
| 2546 | let have_above = mi_r > self.tile_row0_mi; | 2093 | let have_above = mi_r > self.tile_row0_mi; |
| 2547 | let have_left = mi_c > self.tile_col0_mi; | 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 | // The mi grid is libaom's own read; the two maps below stay as the | 2095 | // The mi grid is libaom's own read; the two maps below stay as the |
| 2554 | // fallback for cells no block has written (see [`Self::uv_mode_grid`]). | 2096 | // fallback for cells no block has written (see [`Self::uv_mode_grid`]). |
| 2555 | let cell = |grid: &Vec<u8>, row: usize, col: usize| -> Option<usize> { | 2097 | let cell = |grid: &Vec<u8>, row: usize, col: usize| -> Option<usize> { |
| @@ -2637,67 +2179,6 @@ impl Neighbours { | |||
| 2637 | // every committed fixture and every one of the ~1000 encodes swept in | 2179 | // every committed fixture and every one of the ~1000 encodes swept in |
| 2638 | // `lanes/av1leftref.report.md`, which is what makes the read change a | 2180 | // `lanes/av1leftref.report.md`, which is what makes the read change a |
| 2639 | // proven no-op on today's material rather than an unmeasured guess. | 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 | is_smooth_mode(above) || is_smooth_mode(left) | 2182 | is_smooth_mode(above) || is_smooth_mode(left) |
| 2702 | } | 2183 | } |
| 2703 | 2184 | ||
| @@ -2750,21 +2231,6 @@ impl Neighbours { | |||
| 2750 | let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); | 2231 | let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); |
| 2751 | let (above, left) = | 2232 | let (above, left) = |
| 2752 | self.modes_above_left_mi(mi_r, mi_c, (self.above_mode[c], self.left_mode[r])); | 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 | (above, left) | 2234 | (above, left) |
| 2769 | } | 2235 | } |
| 2770 | 2236 | ||
| @@ -2864,16 +2330,16 @@ impl Neighbours { | |||
| 2864 | 2330 | ||
| 2865 | /// [`Self::record_mi`] with independent above (`w`)/left (`h`) extents, | 2331 | /// [`Self::record_mi`] with independent above (`w`)/left (`h`) extents, |
| 2866 | /// in pixels (lane-partitions r1, mirroring [`Self::record_rect`]). | 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 | let (mi_r, mi_c) = at_mi; | 2340 | let (mi_r, mi_c) = at_mi; |
| 2869 | let states: [Neighbour; 3] = std::array::from_fn(|plane| neighbour_state(grids[plane])); | 2341 | let states: [Neighbour; 3] = std::array::from_fn(|plane| neighbour_state(grids[plane])); |
| 2870 | let (w_mi, h_mi) = (w / MI, h / MI); | 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 | fill_span(&mut self.left_side_mi, mi_r, h_mi, h as u8); | 2343 | fill_span(&mut self.left_side_mi, mi_r, h_mi, h as u8); |
| 2878 | fill_span(&mut self.above_side_mi, mi_c, w_mi, w as u8); | 2344 | fill_span(&mut self.above_side_mi, mi_c, w_mi, w as u8); |
| 2879 | // A chroma 4x4 unit straddling the true luma edge is still whole in | 2345 | // A chroma 4x4 unit straddling the true luma edge is still whole in |
| @@ -2964,27 +2430,10 @@ impl Neighbours { | |||
| 2964 | // units rather than in luma mi. | 2430 | // units rather than in luma mi. |
| 2965 | let (step_x, step_y) = (w_px / MI, h_px / MI); | 2431 | let (step_x, step_y) = (w_px / MI, h_px / MI); |
| 2966 | // the flags read the CALLER's origin, before the shadowing align below | 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 | let (mi_r, mi_c) = (mi_r & !(step_y - 1), mi_c & !(step_x - 1)); | 2433 | let (mi_r, mi_c) = (mi_r & !(step_y - 1), mi_c & !(step_x - 1)); |
| 2978 | let round_up_even = |n: usize| n.div_ceil(2) * 2; | 2434 | let round_up_even = |n: usize| n.div_ceil(2) * 2; |
| 2979 | let (bound_h, bound_w) = (round_up_even(self.mi_rows), round_up_even(self.mi_cols)); | 2435 | let (bound_h, bound_w) = (round_up_even(self.mi_rows), round_up_even(self.mi_cols)); |
| 2980 | let state = neighbour_state(grid); | 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 | for cell in 0..(h_px / MI).min(bound_h.saturating_sub(mi_r)) { | 2437 | for cell in 0..(h_px / MI).min(bound_h.saturating_sub(mi_r)) { |
| 2989 | self.left[mi_r + cell][plane] = state; | 2438 | self.left[mi_r + cell][plane] = state; |
| 2990 | } | 2439 | } |
| @@ -3004,12 +2453,6 @@ impl Neighbours { | |||
| 3004 | grid: &[i32], | 2453 | grid: &[i32], |
| 3005 | ) { | 2454 | ) { |
| 3006 | let state = neighbour_state(grid); | 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 | for cell in 0..h_px / MI { | 2456 | for cell in 0..h_px / MI { |
| 3014 | if mi_r + cell < self.mi_rows { | 2457 | if mi_r + cell < self.mi_rows { |
| 3015 | self.left[mi_r + cell][0] = state; | 2458 | self.left[mi_r + cell][0] = state; |
| @@ -3600,21 +3043,9 @@ pub(super) fn decode_color_index_map_wh( | |||
| 3600 | on: (usize, usize), | 3043 | on: (usize, usize), |
| 3601 | uv: bool, | 3044 | uv: bool, |
| 3602 | ) -> Vec<u8> { | 3045 | ) -> Vec<u8> { |
| 3603 | - let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); | ||
| 3604 | let (on_bw, on_bh) = (on.0.clamp(1, bw), on.1.clamp(1, bh)); | 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 | let mut map = vec![0u8; bw * bh]; | 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 | map[0] = read_uniform(dec, n) as u8; | 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 | for i in 1..(on_bw + on_bh - 1) { | 3049 | for i in 1..(on_bw + on_bh - 1) { |
| 3619 | let j_hi = i.min(on_bw - 1); | 3050 | let j_hi = i.min(on_bw - 1); |
| 3620 | let j_lo = i.saturating_sub(on_bh - 1); | 3051 | let j_lo = i.saturating_sub(on_bh - 1); |
| @@ -3622,28 +3053,12 @@ pub(super) fn decode_color_index_map_wh( | |||
| 3622 | let row = i - j; | 3053 | let row = i - j; |
| 3623 | let col = j; | 3054 | let col = j; |
| 3624 | let (ctx, color_order) = palette_color_index_context(&map, bw, row, col, n); | 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 | let symbol = if uv { | 3056 | let symbol = if uv { |
| 3638 | dec.symbol(&mut cdfs.palette_uv_color_index[n - 2][ctx][..=n]) | 3057 | dec.symbol(&mut cdfs.palette_uv_color_index[n - 2][ctx][..=n]) |
| 3639 | } else { | 3058 | } else { |
| 3640 | dec.symbol(&mut cdfs.palette_y_color_index[n - 2][ctx][..=n]) | 3059 | dec.symbol(&mut cdfs.palette_y_color_index[n - 2][ctx][..=n]) |
| 3641 | }; | 3060 | }; |
| 3642 | map[row * bw + col] = color_order[symbol]; | 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 | palette_replicate(&mut map, bw, bh, on); | 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 | /// it lands away from zero, for gate tests to prove a real stream fired one. | 3088 | /// it lands away from zero, for gate tests to prove a real stream fired one. |
| 3674 | pub(super) fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 { | 3089 | pub(super) fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 { |
| 3675 | let symbol = dec.symbol(cdf); | 3090 | let symbol = dec.symbol(cdf); |
| 3676 | - if symbol != ANGLE_DELTA_ZERO { | ||
| 3677 | - hit!(ANGLE_DELTA_HITS); | ||
| 3678 | - } | ||
| 3679 | symbol as i32 - ANGLE_DELTA_ZERO as i32 | 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 | // lane-part32 r2 debug rung, env-gated: bisecting a widespread pixel | 3127 | // lane-part32 r2 debug rung, env-gated: bisecting a widespread pixel |
| 3716 | // mismatch between the raw reconstruction and post-filter output. | 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 | if lf.level[0] != 0 || lf.level[1] != 0 { | 3129 | if lf.level[0] != 0 || lf.level[1] != 0 { |
| 3721 | deblock_plane(y, 0, lf, n, frame_width, frame_height, fctx); | 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 | (mi_r, mi_c): (usize, usize), | 3215 | (mi_r, mi_c): (usize, usize), |
| 3807 | own_w: usize, | 3216 | own_w: usize, |
| 3808 | own_h: usize, | 3217 | own_h: usize, |
| 3809 | - fctx: &crate::decode::FrameCtx, | ||
| 3810 | ) -> usize { | 3218 | ) -> usize { |
| 3811 | - hit!(INTRA_IN_INTER_TXCTX_HITS); | ||
| 3812 | // `max_txsize_rect_lookup[bsize]` tops out at TX_64X64: no transform is | 3219 | // `max_txsize_rect_lookup[bsize]` tops out at TX_64X64: no transform is |
| 3813 | // wider or taller than 64, so a block with a 128 side resolves against 64 | 3220 | // wider or taller than 64, so a block with a 128 side resolves against 64 |
| 3814 | // (lane-sb128b r1). | 3221 | // (lane-sb128b r1). |
| @@ -3857,31 +3264,7 @@ pub(super) fn tx_size_context_txfm_rect( | |||
| 3857 | }; | 3264 | }; |
| 3858 | if band_above != (has_above && usize::from(above) != 0) | 3265 | if band_above != (has_above && usize::from(above) != 0) |
| 3859 | || band_left != (has_left && usize::from(left) != 0) | 3266 | || band_left != (has_left && usize::from(left) != 0) |
| 3860 | - { | 3267 | + {} |
| 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 | - ); | ||
| 3885 | } | 3268 | } |
| 3886 | let ctx = match (has_above, has_left) { | 3269 | let ctx = match (has_above, has_left) { |
| 3887 | (true, true) => usize::from(above) + usize::from(left), | 3270 | (true, true) => usize::from(above) + usize::from(left), |
| @@ -3889,13 +3272,6 @@ pub(super) fn tx_size_context_txfm_rect( | |||
| 3889 | (false, true) => usize::from(left), | 3272 | (false, true) => usize::from(left), |
| 3890 | (false, false) => 0, | 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 | ctx | 3275 | ctx |
| 3900 | } | 3276 | } |
| 3901 | 3277 | ||
| @@ -3905,7 +3281,11 @@ pub(super) fn tx_size_context_txfm_rect( | |||
| 3905 | /// override above fired on the wrong neighbour -- the first divergence of the | 3281 | /// override above fired on the wrong neighbour -- the first divergence of the |
| 3906 | /// 10-bit gate's stream was exactly this (`tx_depth` ctx 0 where libaom has 1, | 3282 | /// 10-bit gate's stream was exactly this (`tx_depth` ctx 0 where libaom has 1, |
| 3907 | /// at the intra block right of an inter one). | 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 | let has_above = mi_r > n.tile_row0_mi; | 3289 | let has_above = mi_r > n.tile_row0_mi; |
| 3910 | let has_left = mi_c > n.tile_col0_mi; | 3290 | let has_left = mi_c > n.tile_col0_mi; |
| 3911 | let mut above = usize::from(n.above_txfm[mi_c]) >= side; | 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 | if band_above != (has_above && usize::from(above) != 0) | 3329 | if band_above != (has_above && usize::from(above) != 0) |
| 3950 | || band_left != (has_left && usize::from(left) != 0) | 3330 | || band_left != (has_left && usize::from(left) != 0) |
| 3951 | - { | 3331 | + {} |
| 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 | - ); | ||
| 3971 | } | 3332 | } |
| 3972 | match (has_above, has_left) { | 3333 | match (has_above, has_left) { |
| 3973 | (true, true) => usize::from(above) + usize::from(left), | 3334 | (true, true) => usize::from(above) + usize::from(left), |
| @@ -4014,16 +3375,6 @@ pub(super) fn read_tx_size( | |||
| 4014 | 64 => dec.symbol(&mut cdfs.tx_size_cat3[ctx]), | 3375 | 64 => dec.symbol(&mut cdfs.tx_size_cat3[ctx]), |
| 4015 | _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64/128"), | 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 | max_tx >> depth | 3378 | max_tx >> depth |
| 4028 | } | 3379 | } |
| 4029 | 3380 | ||
| @@ -4033,7 +3384,12 @@ pub(super) fn read_tx_size( | |||
| 4033 | /// the two neighbour terms (whether the transform last written above/left of | 3384 | /// the two neighbour terms (whether the transform last written above/left of |
| 4034 | /// this unit is narrower/shorter than the unit itself). | 3385 | /// this unit is narrower/shorter than the unit itself). |
| 4035 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 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 | txfm_partition_ctx_rect(above_px, left_px, blk_max_px, tx_px, tx_px) | 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 | /// resolves, every mi cell its *parent* unit (`txb_px`) spans records the | 3422 | /// resolves, every mi cell its *parent* unit (`txb_px`) spans records the |
| 4067 | /// resolved transform's own size. | 3423 | /// resolved transform's own size. |
| 4068 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 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 | txfm_partition_update_rect(n, at_mi, (tx_px, tx_px), (txb_px, txb_px)); | 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 | (tx_w, tx_h): (usize, usize), | 3497 | (tx_w, tx_h): (usize, usize), |
| 4137 | (txb_w, txb_h): (usize, usize), | 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 | for i in 0..txb_h / MI { | 3500 | for i in 0..txb_h / MI { |
| 4146 | if let Some(cell) = n.left_txfm.get_mut(mi_r + i) { | 3501 | if let Some(cell) = n.left_txfm.get_mut(mi_r + i) { |
| 4147 | *cell = tx_h as u8; | 3502 | *cell = tx_h as u8; |
| @@ -4165,11 +3520,6 @@ pub(super) fn set_txfm_ctxs( | |||
| 4165 | h_mi: usize, | 3520 | h_mi: usize, |
| 4166 | skip_inter: bool, | 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 | let bw = if skip_inter { w_mi * MI } else { tx_px }; | 3523 | let bw = if skip_inter { w_mi * MI } else { tx_px }; |
| 4174 | let bh = if skip_inter { h_mi * MI } else { tx_px }; | 3524 | let bh = if skip_inter { h_mi * MI } else { tx_px }; |
| 4175 | for i in 0..w_mi { | 3525 | for i in 0..w_mi { |
| @@ -4439,22 +3789,11 @@ pub(super) fn read_var_tx_size( | |||
| 4439 | tx_h, | 3789 | tx_h, |
| 4440 | ); | 3790 | ); |
| 4441 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; | 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 | if !split { | 3792 | if !split { |
| 4453 | out.push((blk_row, blk_col, tx_w, tx_h)); | 3793 | out.push((blk_row, blk_col, tx_w, tx_h)); |
| 4454 | txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h)); | 3794 | txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h)); |
| 4455 | return; | 3795 | return; |
| 4456 | } | 3796 | } |
| 4457 | - hit!(TXFM_SPLIT_HITS); | ||
| 4458 | let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h); | 3797 | let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h); |
| 4459 | if (sub_w, sub_h) == (4, 4) { | 3798 | if (sub_w, sub_h) == (4, 4) { |
| 4460 | // libaom's `sub_txs == TX_4X4` early return: every mi cell of the | 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+5 -21
| @@ -1,7 +1,7 @@ | |||
| 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. | 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 | use super::*; | 3 | use super::*; |
| 4 | +use archmage::SimdToken; | ||
| 5 | 5 | ||
| 6 | /// `update_sharpness`'s per-level `(blimit, limit, hev_thr)` triple. | 6 | /// `update_sharpness`'s per-level `(blimit, limit, hev_thr)` triple. |
| 7 | fn deblock_thresholds(level: i32, sharpness: u8) -> (i32, i32, i32) { | 7 | fn deblock_thresholds(level: i32, sharpness: u8) -> (i32, i32, i32) { |
| @@ -463,12 +463,6 @@ pub(super) fn deblock_plane_span( | |||
| 463 | plane.true_height.min(ch), | 463 | plane.true_height.min(ch), |
| 464 | plane.width, | 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 | // lane-perf8: both passes iterate the edge's OWN direction innermost, so | 466 | // lane-perf8: both passes iterate the edge's OWN direction innermost, so |
| 473 | // 4 consecutive 4-sample groups (16 lines) can go through one AVX2 | 467 | // 4 consecutive 4-sample groups (16 lines) can go through one AVX2 |
| 474 | // kernel. The swap is order-preserving: a filtered group overlaps only | 468 | // kernel. The swap is order-preserving: a filtered group overlaps only |
| @@ -555,9 +549,6 @@ pub(super) fn deblock_plane_span( | |||
| 555 | continue; | 549 | continue; |
| 556 | } | 550 | } |
| 557 | if let Some((len, level)) = edge_params(&vctx, x0, y0) { | 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 | filter_edge( | 552 | filter_edge( |
| 562 | mine, | 553 | mine, |
| 563 | (y0 - y_lo) * stride + x0, | 554 | (y0 - y_lo) * stride + x0, |
| @@ -669,15 +660,6 @@ pub(super) fn deblock_plane_span( | |||
| 669 | continue; | 660 | continue; |
| 670 | } | 661 | } |
| 671 | if let Some((len, level)) = edge_params(&hctx, x0, y0) { | 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 | filter_edge( | 663 | filter_edge( |
| 682 | px, | 664 | px, |
| 683 | (y0 - r_lo) * w + (x0 - x_lo), | 665 | (y0 - r_lo) * w + (x0 - x_lo), |
| @@ -716,7 +698,8 @@ pub(super) fn deblock_plane_span( | |||
| 716 | /// every pool thread the decode ever created. One shared pool with a hard | 698 | /// every pool thread the decode ever created. One shared pool with a hard |
| 717 | /// entry cap bounds the retention at [`SCRATCH_CAP`] buffers no matter how | 699 | /// entry cap bounds the retention at [`SCRATCH_CAP`] buffers no matter how |
| 718 | /// many threads cycle through it; anything over the cap is freed. | 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 | /// Most buffers the shared pool keeps. ~3 whole-plane sets per in-flight 4K | 704 | /// Most buffers the shared pool keeps. ~3 whole-plane sets per in-flight 4K |
| 722 | /// frame at the shipped `EC_AV1_THREADS` ceiling; the frames actually in | 705 | /// frame at the shipped `EC_AV1_THREADS` ceiling; the frames actually in |
| @@ -877,7 +860,8 @@ pub(crate) fn arm_filter_replay() { | |||
| 877 | /// can hold the replay against the decode it stands in for | 860 | /// can hold the replay against the decode it stands in for |
| 878 | /// (`encoder::tests::filter_replay_codes_the_same_stream_as_a_full_decode`). | 861 | /// (`encoder::tests::filter_replay_codes_the_same_stream_as_a_full_decode`). |
| 879 | #[cfg(test)] | 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 | #[cfg(test)] | 866 | #[cfg(test)] |
| 883 | pub(crate) fn set_filter_replay_disabled(off: bool) { | 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 | let (width, height) = (cols as usize * BLOCK, rows as usize * BLOCK); | 417 | let (width, height) = (cols as usize * BLOCK, rows as usize * BLOCK); |
| 418 | 418 | ||
| 419 | let mut y = PlaneBuf { | 419 | let mut y = PlaneBuf { |
| 420 | - data: std::borrow::Cow::Owned(fresh_plane( | 420 | + data: std::borrow::Cow::Owned(fresh_plane(width * height)), |
| 421 | - width * height, | ||
| 422 | - true_width, | ||
| 423 | - true_height, | ||
| 424 | - width, | ||
| 425 | - height, | ||
| 426 | - )), | ||
| 427 | width, | 421 | width, |
| 428 | height, | 422 | height, |
| 429 | true_width, | 423 | true_width, |
| @@ -435,10 +429,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 435 | plane: 0, | 429 | plane: 0, |
| 436 | }; | 430 | }; |
| 437 | let (cw, ch) = (width >> ss_x(fctx), height >> ss_y(fctx)); | 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 | let (ctw, cth) = (true_width >> ss_x(fctx), true_height >> ss_y(fctx)); | 432 | let (ctw, cth) = (true_width >> ss_x(fctx), true_height >> ss_y(fctx)); |
| 440 | let mut u = PlaneBuf { | 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 | width: cw, | 435 | width: cw, |
| 443 | height: ch, | 436 | height: ch, |
| 444 | true_width: ctw, | 437 | true_width: ctw, |
| @@ -450,7 +443,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 450 | plane: 1, | 443 | plane: 1, |
| 451 | }; | 444 | }; |
| 452 | let mut v = PlaneBuf { | 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 | width: cw, | 447 | width: cw, |
| 455 | height: ch, | 448 | height: ch, |
| 456 | true_width: ctw, | 449 | true_width: ctw, |
| @@ -542,17 +535,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 542 | // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets | 535 | // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets |
| 543 | // it codes every symbol against the tables it started with. | 536 | // it codes every symbol against the tables it started with. |
| 544 | dec.set_cdf_update(!cdf_update_disabled(fctx)); | 537 | dec.set_cdf_update(!cdf_update_disabled(fctx)); |
| 545 | - crate::census::register_cdfs(&cdfs); | ||
| 546 | // lane-comppin r9: tile-entry range, the earliest point comparable | 538 | // lane-comppin r9: tile-entry range, the earliest point comparable |
| 547 | // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the | 539 | // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the |
| 548 | // first ladder rung before any symbol (partition or otherwise) is read. | 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 | neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize, fctx); | 541 | neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize, fctx); |
| 557 | y.set_tile_origin( | 542 | y.set_tile_origin( |
| 558 | mi_col0 as usize * 4, | 543 | mi_col0 as usize * 4, |
| @@ -583,7 +568,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 583 | mi_row1 as usize, | 568 | mi_row1 as usize, |
| 584 | mi_col1 as usize, | 569 | mi_col1 as usize, |
| 585 | ); | 570 | ); |
| 586 | - hit!(TILE_HITS); | ||
| 587 | 571 | ||
| 588 | // lane-sb128 r2: at `sb_size == 128` the tile walks each 128x128 | 572 | // lane-sb128 r2: at `sb_size == 128` the tile walks each 128x128 |
| 589 | // superblock's four 64x64 quadrants in libaom `decode_partition` order | 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 | bw, | 969 | bw, |
| 986 | bh | 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 | // One `cdef_idx` per BLOCK, copied to every 64x64 CDEF unit it | 973 | // One `cdef_idx` per BLOCK, copied to every 64x64 CDEF unit it |
| 995 | // covers -- both halves of the root read their own, and the | 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 | continue; | 1002 | continue; |
| 1024 | } | 1003 | } |
| 1025 | if sb128_none { | 1004 | if sb128_none { |
| 1026 | - hit!(INTER_SB128_NONE_HITS); | ||
| 1027 | let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4); | 1005 | let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4); |
| 1028 | // lane-sb128c r3: `at128` is in SUB16 units like `sb_at`; | 1006 | // lane-sb128c r3: `at128` is in SUB16 units like `sb_at`; |
| 1029 | // `decode_inter_block` takes MI. Unconverted it was (0,0) for | 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 | // instead of silently decoding as SPLIT and desyncing. | 1054 | // instead of silently decoding as SPLIT and desyncing. |
| 1077 | let part64 = match (has_cols, has_rows) { | 1055 | let part64 = match (has_cols, has_rows) { |
| 1078 | (true, true) => { | 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 | let p = dec.symbol(&mut cdfs.partition_w64[sb_ctx]); | 1057 | let p = dec.symbol(&mut cdfs.partition_w64[sb_ctx]); |
| 1090 | // lane-av1unwritten r6: the partition symbol is RESOLVED and about to be | 1058 | // lane-av1unwritten r6: the partition symbol is RESOLVED and about to be |
| 1091 | // dispatched. `partition_subsize_dims` is libaom's `get_partition_subsize` | 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 | // arm -- VERT, VERT_A / VERT_B, HORZ_4 and VERT_4 -- and the HORZ siblings | 1062 | // arm -- VERT, VERT_A / VERT_B, HORZ_4 and VERT_4 -- and the HORZ siblings |
| 1095 | // keep decoding because the helper is exact, not a heuristic. inter-frame 64x64 level; `p` is the symbol. | 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 | p | 1065 | p |
| 1105 | } | 1066 | } |
| 1106 | (true, false) => { | 1067 | (true, false) => { |
| 1107 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 1068 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered |
| 1108 | // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT | 1069 | // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT |
| 1109 | // (libaom `ec_read_partition_impl`). | 1070 | // (libaom `ec_read_partition_impl`). |
| 1110 | - if crate::envflags::env_flag!("EC_TRACE_PART") { | 1071 | + if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)) == 1 { |
| 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 | - { | ||
| 1124 | PARTITION_SPLIT | 1072 | PARTITION_SPLIT |
| 1125 | } else { | 1073 | } else { |
| 1126 | PARTITION_HORZ | 1074 | PARTITION_HORZ |
| @@ -1130,20 +1078,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 1130 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 1078 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered |
| 1131 | // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT | 1079 | // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT |
| 1132 | // (libaom `ec_read_partition_impl`). | 1080 | // (libaom `ec_read_partition_impl`). |
| 1133 | - if bump_edge32_bit( | 1081 | + if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)) == 1 { |
| 1134 | - 4, | ||
| 1135 | - dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)), | ||
| 1136 | - ) == 1 | ||
| 1137 | - { | ||
| 1138 | PARTITION_SPLIT | 1082 | PARTITION_SPLIT |
| 1139 | } else { | 1083 | } else { |
| 1140 | PARTITION_VERT | 1084 | PARTITION_VERT |
| 1141 | } | 1085 | } |
| 1142 | } | 1086 | } |
| 1143 | - (false, false) => { | 1087 | + (false, false) => PARTITION_SPLIT, |
| 1144 | - bump_edge_both_cut(2); | ||
| 1145 | - PARTITION_SPLIT | ||
| 1146 | - } | ||
| 1147 | }; | 1088 | }; |
| 1148 | // lane-av1unwritten r7: the symbol is RESOLVED (a full CDF | 1089 | // lane-av1unwritten r7: the symbol is RESOLVED (a full CDF |
| 1149 | // read or an edge `gather`) and about to be dispatched, so the | 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 | // see it. | 1097 | // see it. |
| 1157 | refuse_invalid_subsize((64, 64), part64, fctx)?; | 1098 | refuse_invalid_subsize((64, 64), part64, fctx)?; |
| 1158 | if part64 == PARTITION_NONE { | 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 | decode_inter_block( | 1100 | decode_inter_block( |
| 1170 | &mut dec, | 1101 | &mut dec, |
| 1171 | &mut cdfs, | 1102 | &mut cdfs, |
| @@ -1220,15 +1151,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 1220 | PARTITION_HORZ | PARTITION_VERT | PARTITION_HORZ_4 | PARTITION_VERT_4 | 1151 | PARTITION_HORZ | PARTITION_VERT | PARTITION_HORZ_4 | PARTITION_VERT_4 |
| 1221 | ) { | 1152 | ) { |
| 1222 | // lane-av1unwritten r6: arm census. | 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 | // lane-inter4 r1: the superblock-level rect + 1:4 pairs as | 1154 | // lane-inter4 r1: the superblock-level rect + 1:4 pairs as |
| 1233 | // inter blocks -- two 64x32 / 32x64 strips, or four 64x16 / | 1155 | // inter blocks -- two 64x32 / 32x64 strips, or four 64x16 / |
| 1234 | // 16x64 ones. Each piece keeps `side = SB` for every | 1156 | // 16x64 ones. Each piece keeps `side = SB` for every |
| @@ -1282,38 +1204,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 1282 | bw, | 1204 | bw, |
| 1283 | bh | 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 | continue; | 1208 | continue; |
| 1296 | } | 1209 | } |
| 1297 | if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part64) { | 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 | // lane-part32 r5 / class visit-order-changes-availability: | 1211 | // lane-part32 r5 / class visit-order-changes-availability: |
| 1318 | // only the two VERTICAL arms visit TL, BL, TR, BR, so only | 1212 | // only the two VERTICAL arms visit TL, BL, TR, BR, so only |
| 1319 | // they switch libaom's `has_tr`/`has_bl` tables. | 1213 | // they switch libaom's `has_tr`/`has_bl` tables. |
| @@ -1442,14 +1336,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 1442 | has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows), | 1336 | has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows), |
| 1443 | ); | 1337 | ); |
| 1444 | let part32 = if has_cols32 && has_rows32 { | 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 | // lane-av1tilerows: this rung printed the RAW 32-grid | 1339 | // lane-av1tilerows: this rung printed the RAW 32-grid |
| 1454 | // index (`r32`, `c32`) into its `mi_row=`/`mi_col=` | 1340 | // index (`r32`, `c32`) into its `mi_row=`/`mi_col=` |
| 1455 | // fields — a factor of `BLOCK_MI` (8) off — while the | 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 | // against libaom's per-level `EC_PART_VAL` dump, which | 1346 | // against libaom's per-level `EC_PART_VAL` dump, which |
| 1461 | // is the only way to locate a partition-walk | 1347 | // is the only way to locate a partition-walk |
| 1462 | // divergence. Behaviour-free: env-gated print only. | 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 | let p = dec.symbol(&mut cdfs.partition_w32[ctx32]); | 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 | p | 1350 | p |
| 1481 | } else { | 1351 | } else { |
| 1482 | match (has_cols32, has_rows32) { | 1352 | match (has_cols32, has_rows32) { |
| @@ -1484,21 +1354,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 1484 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 1354 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered |
| 1485 | // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT | 1355 | // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT |
| 1486 | // (libaom `ec_read_partition_impl`). | 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 | if { | 1357 | if { |
| 1497 | let b = dec.symbol_fixed(&gather( | 1358 | let b = dec.symbol_fixed(&gather( |
| 1498 | &cdfs.partition_w32[ctx32], | 1359 | &cdfs.partition_w32[ctx32], |
| 1499 | VERT_ALIKE, | 1360 | VERT_ALIKE, |
| 1500 | )); | 1361 | )); |
| 1501 | - bump_edge32(b.min(1)); | ||
| 1502 | b | 1362 | b |
| 1503 | } == 1 | 1363 | } == 1 |
| 1504 | { | 1364 | { |
| @@ -1516,7 +1376,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 1516 | &cdfs.partition_w32[ctx32], | 1376 | &cdfs.partition_w32[ctx32], |
| 1517 | HORZ_ALIKE, | 1377 | HORZ_ALIKE, |
| 1518 | )); | 1378 | )); |
| 1519 | - bump_edge32(b.min(1)); | ||
| 1520 | b | 1379 | b |
| 1521 | } == 1 | 1380 | } == 1 |
| 1522 | { | 1381 | { |
| @@ -1525,10 +1384,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 1525 | PARTITION_VERT | 1384 | PARTITION_VERT |
| 1526 | } | 1385 | } |
| 1527 | } | 1386 | } |
| 1528 | - _ => { | 1387 | + _ => PARTITION_SPLIT, |
| 1529 | - bump_edge_both_cut(1); | ||
| 1530 | - PARTITION_SPLIT | ||
| 1531 | - } | ||
| 1532 | } | 1388 | } |
| 1533 | }; | 1389 | }; |
| 1534 | // lane-av1unwritten r5: the partition symbol is RESOLVED (a full CDF read or | 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 | // inter leaves through the very same loop the | 1467 | // inter leaves through the very same loop the |
| 1612 | // straddling case has always used. | 1468 | // straddling case has always used. |
| 1613 | let part16 = if has_cols16 && has_rows16 { | 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 | let p = dec.symbol(&mut cdfs.partition_w16[ctx16]); | 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 | p | 1471 | p |
| 1633 | } else if !has_cols16 && !has_rows16 { | 1472 | } else if !has_cols16 && !has_rows16 { |
| 1634 | // lane-edgeboth r1: both axes cut by the true | 1473 | // lane-edgeboth r1: both axes cut by the true |
| @@ -1636,22 +1475,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 1636 | // forces PARTITION_SPLIT and reads NO symbol; | 1475 | // forces PARTITION_SPLIT and reads NO symbol; |
| 1637 | // the leaf loop below already drops the | 1476 | // the leaf loop below already drops the |
| 1638 | // out-of-frame quadrants. | 1477 | // out-of-frame quadrants. |
| 1639 | - bump_edge_both_cut(0); | ||
| 1640 | PARTITION_SPLIT | 1478 | PARTITION_SPLIT |
| 1641 | } else { | 1479 | } else { |
| 1642 | if has_cols16 { | 1480 | if has_cols16 { |
| 1643 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 1481 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered |
| 1644 | // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT | 1482 | // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT |
| 1645 | // (libaom `ec_read_partition_impl`). | 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 | if dec.symbol_fixed(&gather( | 1484 | if dec.symbol_fixed(&gather( |
| 1656 | &cdfs.partition_w16[ctx16], | 1485 | &cdfs.partition_w16[ctx16], |
| 1657 | VERT_ALIKE, | 1486 | VERT_ALIKE, |
| @@ -1749,11 +1578,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 1749 | // residual path (`rect_inter_residual_supported` | 1578 | // residual path (`rect_inter_residual_supported` |
| 1750 | // covers 16x8/8x16 since this round). | 1579 | // covers 16x8/8x16 since this round). |
| 1751 | let horz = part16 == PARTITION_HORZ; | 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 | let base_mi = sub16_to_mi(at16); | 1581 | let base_mi = sub16_to_mi(at16); |
| 1758 | let (ww, wh) = if horz { (16, 8) } else { (8, 16) }; | 1582 | let (ww, wh) = if horz { (16, 8) } else { (8, 16) }; |
| 1759 | for piece in 0..2 { | 1583 | for piece in 0..2 { |
| @@ -1768,7 +1592,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 1768 | && (piece_mi.0 >= mi_rows as usize | 1592 | && (piece_mi.0 >= mi_rows as usize |
| 1769 | || piece_mi.1 >= mi_cols as usize) | 1593 | || piece_mi.1 >= mi_cols as usize) |
| 1770 | { | 1594 | { |
| 1771 | - bump_inter_edge_strip(if horz { 4 } else { 5 }); | ||
| 1772 | break; | 1595 | break; |
| 1773 | } | 1596 | } |
| 1774 | decode_inter_block( | 1597 | decode_inter_block( |
| @@ -1861,7 +1684,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 1861 | // block_size_high >= 16, blockd.h) both hold | 1684 | // block_size_high >= 16, blockd.h) both hold |
| 1862 | // and the leaf/strip decoders' own gates | 1685 | // and the leaf/strip decoders' own gates |
| 1863 | // apply unchanged. | 1686 | // apply unchanged. |
| 1864 | - bump_ab16_inter(part16 - PARTITION_HORZ_A); | ||
| 1865 | let _vert_guard = if part16 == PARTITION_VERT_A | 1687 | let _vert_guard = if part16 == PARTITION_VERT_A |
| 1866 | || part16 == PARTITION_VERT_B | 1688 | || part16 == PARTITION_VERT_B |
| 1867 | { | 1689 | { |
| @@ -2035,20 +1857,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 2035 | bw, | 1857 | bw, |
| 2036 | bh | 1858 | bh |
| 2037 | ); | 1859 | ); |
| 2038 | - if horz { | ||
| 2039 | - hit!(INTER16_HORZ4_HITS); | ||
| 2040 | - } else { | ||
| 2041 | - hit!(INTER16_VERT4_HITS); | ||
| 2042 | - } | ||
| 2043 | } | 1860 | } |
| 2044 | } else if part16 != PARTITION_SPLIT { | 1861 | } else if part16 != PARTITION_SPLIT { |
| 2045 | return Err(unsupported( | 1862 | return Err(unsupported( |
| 2046 | "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4", | 1863 | "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4", |
| 2047 | )); | 1864 | )); |
| 2048 | } else { | 1865 | } else { |
| 2049 | - if has_cols16 && has_rows16 { | ||
| 2050 | - hit!(INTER_SUB16_SPLIT_HITS); | ||
| 2051 | - } | ||
| 2052 | let (mi_row0, mi_col0) = | 1866 | let (mi_row0, mi_col0) = |
| 2053 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | 1867 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 2054 | let leaf_positions: Vec<(u32, u32)> = (0..4) | 1868 | let leaf_positions: Vec<(u32, u32)> = (0..4) |
| @@ -2062,13 +1876,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 2062 | // 7.11.3.3's scaled walk. The counter is what | 1876 | // 7.11.3.3's scaled walk. The counter is what |
| 2063 | // proves a gate actually reached a scaled | 1877 | // proves a gate actually reached a scaled |
| 2064 | // leaf rather than a same-size reference. | 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 | let mut prev_leaves: Vec<( | 1879 | let mut prev_leaves: Vec<( |
| 2073 | (usize, usize), | 1880 | (usize, usize), |
| 2074 | bool, | 1881 | bool, |
| @@ -2079,16 +1886,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 2079 | for (mr, mc) in leaf_positions { | 1886 | for (mr, mc) in leaf_positions { |
| 2080 | let leaf_mi = (mr as usize, mc as usize); | 1887 | let leaf_mi = (mr as usize, mc as usize); |
| 2081 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); | 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 | let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); | 1889 | let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| 2093 | // lane-av1unwritten r6: the partition symbol is RESOLVED and about to be | 1890 | // lane-av1unwritten r6: the partition symbol is RESOLVED and about to be |
| 2094 | // dispatched. `partition_subsize_dims` is libaom's `get_partition_subsize` | 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 | // keep decoding because the helper is exact, not a heuristic. inter-frame 8x8 level. | 1895 | // keep decoding because the helper is exact, not a heuristic. inter-frame 8x8 level. |
| 2099 | refuse_invalid_subsize((8, 8), part8, fctx)?; | 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 | if part8 == PARTITION_SPLIT { | 1898 | if part8 == PARTITION_SPLIT { |
| 2109 | // lane-intersub8: four BLOCK_4X4 inter | 1899 | // lane-intersub8: four BLOCK_4X4 inter |
| 2110 | // sub-blocks, chroma once per 8x8. | 1900 | // sub-blocks, chroma once per 8x8. |
| @@ -2138,15 +1928,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 2138 | // lane-av1unwritten r6: arm census -- an | 1928 | // lane-av1unwritten r6: arm census -- an |
| 2139 | // 8x8-level VERT selects BLOCK_4X8, which | 1929 | // 8x8-level VERT selects BLOCK_4X8, which |
| 2140 | // is INVALID at 4:2:2. | 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 | if part8 == PARTITION_VERT || part8 == PARTITION_HORZ { | 1931 | if part8 == PARTITION_VERT || part8 == PARTITION_HORZ { |
| 2151 | // lane-intersub8 r3/r4/r5: two | 1932 | // lane-intersub8 r3/r4/r5: two |
| 2152 | // BLOCK_8X4 (HORZ) / BLOCK_4X8 (VERT) | 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 | PARTITION_HORZ_B => { | 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 | let at32 = at; | 2066 | let at32 = at; |
| 2299 | decode_inter_block( | 2067 | decode_inter_block( |
| 2300 | &mut dec, | 2068 | &mut dec, |
| @@ -2454,13 +2222,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 2454 | } | 2222 | } |
| 2455 | } | 2223 | } |
| 2456 | PARTITION_HORZ => { | 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 | decode_inter_block( | 2225 | decode_inter_block( |
| 2465 | &mut dec, | 2226 | &mut dec, |
| 2466 | &mut cdfs, | 2227 | &mut cdfs, |
| @@ -2508,9 +2269,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 2508 | (frame_width as usize, frame_height as usize), | 2269 | (frame_width as usize, frame_height as usize), |
| 2509 | fctx, | 2270 | fctx, |
| 2510 | )?; | 2271 | )?; |
| 2511 | - if !has_rows32 { | ||
| 2512 | - bump_edge32(2); | ||
| 2513 | - } | ||
| 2514 | // lane-golomb r2: at the frame edge only the first half of the | 2272 | // lane-golomb r2: at the frame edge only the first half of the |
| 2515 | // strip is coded (libaom `decode_partition` guards the second | 2273 | // strip is coded (libaom `decode_partition` guards the second |
| 2516 | // with the same has_rows32 test that made this partition non-square). | 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 | (frame_width as usize, frame_height as usize), | 2320 | (frame_width as usize, frame_height as usize), |
| 2563 | fctx, | 2321 | fctx, |
| 2564 | )?; | 2322 | )?; |
| 2565 | - } else { | ||
| 2566 | - bump_inter_edge_strip(2); | ||
| 2567 | } | 2323 | } |
| 2568 | } | 2324 | } |
| 2569 | PARTITION_VERT => { | 2325 | PARTITION_VERT => { |
| 2570 | - // lane-rect r2: mirror of PARTITION_HORZ above with | ||
| 2571 | - // width/height swapped. | ||
| 2572 | - hit!(RECT_PARTITION_HITS); | ||
| 2573 | decode_inter_block( | 2326 | decode_inter_block( |
| 2574 | &mut dec, | 2327 | &mut dec, |
| 2575 | &mut cdfs, | 2328 | &mut cdfs, |
| @@ -2617,9 +2370,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 2617 | (frame_width as usize, frame_height as usize), | 2370 | (frame_width as usize, frame_height as usize), |
| 2618 | fctx, | 2371 | fctx, |
| 2619 | )?; | 2372 | )?; |
| 2620 | - if !has_cols32 { | ||
| 2621 | - bump_edge32(3); | ||
| 2622 | - } | ||
| 2623 | // lane-golomb r2: at the frame edge only the first half of the | 2373 | // lane-golomb r2: at the frame edge only the first half of the |
| 2624 | // strip is coded (libaom `decode_partition` guards the second | 2374 | // strip is coded (libaom `decode_partition` guards the second |
| 2625 | // with the same has_cols32 test that made this partition non-square). | 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 | (frame_width as usize, frame_height as usize), | 2421 | (frame_width as usize, frame_height as usize), |
| 2672 | fctx, | 2422 | fctx, |
| 2673 | )?; | 2423 | )?; |
| 2674 | - } else { | ||
| 2675 | - bump_inter_edge_strip(3); | ||
| 2676 | } | 2424 | } |
| 2677 | } | 2425 | } |
| 2678 | PARTITION_HORZ_A => { | 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 | decode_inter_block( | 2427 | decode_inter_block( |
| 2684 | &mut dec, | 2428 | &mut dec, |
| 2685 | &mut cdfs, | 2429 | &mut cdfs, |
| @@ -2831,9 +2575,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 2831 | )?; | 2575 | )?; |
| 2832 | } | 2576 | } |
| 2833 | PARTITION_VERT_A => { | 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 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); | 2578 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 2838 | decode_inter_block( | 2579 | decode_inter_block( |
| 2839 | &mut dec, | 2580 | &mut dec, |
| @@ -2986,10 +2727,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 2986 | )?; | 2727 | )?; |
| 2987 | } | 2728 | } |
| 2988 | PARTITION_VERT_B => { | 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 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); | 2730 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 2994 | decode_inter_block( | 2731 | decode_inter_block( |
| 2995 | &mut dec, | 2732 | &mut dec, |
| @@ -3177,11 +2914,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 3177 | bw, | 2914 | bw, |
| 3178 | bh | 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 | // lane-av1fwd: the encoder scores ~25 filter candidates against this | 2963 | // lane-av1fwd: the encoder scores ~25 filter candidates against this |
| 3277 | // same coded tile ([`FilterReplay`]). Capture the reconstruction here, | 2964 | // same coded tile ([`FilterReplay`]). Capture the reconstruction here, |
| 3278 | // before either filter has touched it -- but only on the shape whose | 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 | plane_snapshot(&v, ss_y(fctx) as u32), | 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 | apply_cdef( | 3004 | apply_cdef( |
| 3332 | &mut y, | 3005 | &mut y, |
| 3333 | &mut u, | 3006 | &mut u, |
| 3334 | &mut v, | 3007 | &mut v, |
| 3335 | cdef, | 3008 | cdef, |
| 3336 | &neighbours, | 3009 | &neighbours, |
| 3337 | - (frame_width as usize, frame_height as usize), | ||
| 3338 | fctx, | 3010 | fctx, |
| 3339 | None, | 3011 | None, |
| 3340 | None, | 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 | capture_stages(&y, &u, &v, deblocked.as_ref(), fctx); | 3014 | capture_stages(&y, &u, &v, deblocked.as_ref(), fctx); |
| 3354 | // spec 7.16 (libaom `superres_post_decode`, decodeframe.c: called | 3015 | // spec 7.16 (libaom `superres_post_decode`, decodeframe.c: called |
| 3355 | // between `av1_cdef_frame` and `av1_loop_restoration_filter_frame`): | 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 | // Round 27: the per-read trace is the only instrument that reaches the inter | 123 | // Round 27: the per-read trace is the only instrument that reaches the inter |
| 124 | // path (the coefficient rungs stop well before the frame-3 divergence), | 124 | // path (the coefficient rungs stop well before the frame-3 divergence), |
| 125 | // so publish the phase and the block's mi for every read it makes. | 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 | // lane-inter4 r1: `at` is in MI units (4 px) so a 32-level 1:4 strip can | 126 | // lane-inter4 r1: `at` is in MI units (4 px) so a 32-level 1:4 strip can |
| 129 | // name an 8-px offset; `(r, c)` stays the enclosing 16-px cell for the | 127 | // name an 8-px offset; `(r, c)` stays the enclosing 16-px cell for the |
| 130 | // few 16-px-granular uses below. | 128 | // few 16-px-granular uses below. |
| @@ -135,7 +133,6 @@ pub(super) fn decode_inter_block( | |||
| 135 | // exactly what it read before. | 133 | // exactly what it read before. |
| 136 | let (rmi, cmi) = at; | 134 | let (rmi, cmi) = at; |
| 137 | let (px, py) = (at.1 * MI, at.0 * MI); | 135 | let (px, py) = (at.1 * MI, at.0 * MI); |
| 138 | - census_inter_block_shape(side, write_w, write_h); | ||
| 139 | // lane-inter16ab r2: a 16x4 / 4x16 inter strip's chroma is the PAIR's | 136 | // lane-inter16ab r2: a 16x4 / 4x16 inter strip's chroma is the PAIR's |
| 140 | // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd | 137 | // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd |
| 141 | // strip (`is_chroma_reference`); every other block keeps its own. | 138 | // strip (`is_chroma_reference`); every other block keeps its own. |
| @@ -233,30 +230,12 @@ pub(super) fn decode_inter_block( | |||
| 233 | // bails per PLANE at `block_width < 8 || block_height < 8` -- on the | 230 | // bails per PLANE at `block_width < 8 || block_height < 8` -- on the |
| 234 | // block's own dims, never on the square prediction buffer this reader | 231 | // block's own dims, never on the square prediction buffer this reader |
| 235 | // allocates. | 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 | let skip_mode_ctx = | 234 | let skip_mode_ctx = |
| 250 | usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]); | 235 | usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]); |
| 251 | // lane-comppin r3: skip_mode desync isolation -- dump ctx + the pre-read | 236 | // lane-comppin r3: skip_mode desync isolation -- dump ctx + the pre-read |
| 252 | // MSAC tell so it can be diffed against an equivalent hook in libaom's | 237 | // MSAC tell so it can be diffed against an equivalent hook in libaom's |
| 253 | // own `read_skip_mode`/`av1_get_skip_mode_context`. | 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 | // spec 5.11.5 `inter_frame_mode_info`: `inter_segment_id(1)` before | 239 | // spec 5.11.5 `inter_frame_mode_info`: `inter_segment_id(1)` before |
| 261 | // `skip_mode`/`skip`, `inter_segment_id(0)` after them. | 240 | // `skip_mode`/`skip`, `inter_segment_id(0)` after them. |
| 262 | let (seg_mi_r, seg_mi_c) = (rmi, cmi); | 241 | let (seg_mi_r, seg_mi_c) = (rmi, cmi); |
| @@ -270,15 +249,6 @@ pub(super) fn decode_inter_block( | |||
| 270 | let comp_allowed = write_w.min(write_h) >= 8; | 249 | let comp_allowed = write_w.min(write_h) >= 8; |
| 271 | let skip_mode = | 250 | let skip_mode = |
| 272 | skip_mode_present && comp_allowed && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; | 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 | let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); | 253 | let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); |
| 284 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; | 254 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; |
| @@ -303,16 +273,6 @@ pub(super) fn decode_inter_block( | |||
| 303 | // chunk). An INTRA block at that size inside an inter frame takes the | 273 | // chunk). An INTRA block at that size inside an inter frame takes the |
| 304 | // intra tail below, which still codes one whole-block chroma unit and one | 274 | // intra tail below, which still codes one whole-block chroma unit and one |
| 305 | // `read_tx_size` at 128 -- refuse by name instead of mis-decoding it. | 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 | // lane-warp r5: see `reject_residual` -- a square-block decode of a | 276 | // lane-warp r5: see `reject_residual` -- a square-block decode of a |
| 317 | // HORZ_B strip is symbol-exact only for `skip` (no residual, no | 277 | // HORZ_B strip is symbol-exact only for `skip` (no residual, no |
| 318 | // motion_mode/warp symbol). lane-intrarect r1 MOVED this gate from just | 278 | // motion_mode/warp symbol). lane-intrarect r1 MOVED this gate from just |
| @@ -332,26 +292,10 @@ pub(super) fn decode_inter_block( | |||
| 332 | && !rect_inter_residual_supported(write_w, write_h) | 292 | && !rect_inter_residual_supported(write_w, write_h) |
| 333 | && (is_inter || (write_w == side && write_h == side)) | 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 | return Err(unsupported( | 295 | return Err(unsupported( |
| 343 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | 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 | let mode_for_tx; | 300 | let mode_for_tx; |
| 357 | let uv_predict_mode; | 301 | let uv_predict_mode; |
| @@ -411,12 +355,6 @@ pub(super) fn decode_inter_block( | |||
| 411 | uni: neighbours.left_ref1[rmi] | 355 | uni: neighbours.left_ref1[rmi] |
| 412 | .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[rmi], r1)), | 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 | let is_compound = skip_mode | 358 | let is_compound = skip_mode |
| 421 | || (reference_select | 359 | || (reference_select |
| 422 | // `is_comp_ref_allowed` (blockd.h:65) gates the | 360 | // `is_comp_ref_allowed` (blockd.h:65) gates the |
| @@ -498,22 +436,6 @@ pub(super) fn decode_inter_block( | |||
| 498 | ), | 436 | ), |
| 499 | fctx, | 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 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV | 439 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV |
| 518 | // be non-TRANSLATION (IDENTITY counts) for the compound block's | 440 | // be non-TRANSLATION (IDENTITY counts) for the compound block's |
| 519 | // interp-filter read to be suppressed. | 441 | // interp-filter read to be suppressed. |
| @@ -526,9 +448,6 @@ pub(super) fn decode_inter_block( | |||
| 526 | // `AOMMIN(mi_size_wide, mi_size_high) < 2` before it looks at any | 448 | // `AOMMIN(mi_size_wide, mi_size_high) < 2` before it looks at any |
| 527 | // model, so a 4-px-sided block still reads its interp filter. | 449 | // model, so a 4-px-sided block still reads its interp filter. |
| 528 | let gm_nontrans = gm_nontrans_models && bw4.min(bh4) >= 2; | 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 | // lane-defer8: both slots' pictures are resolved inside the | 451 | // lane-defer8: both slots' pictures are resolved inside the |
| 533 | // prediction closure; the parse only needs their SIZES. | 452 | // prediction closure; the parse only needs their SIZES. |
| 534 | // lane-cwarp r1: `is_global_mv_block` (blockd.h:421-429) is | 453 | // lane-cwarp r1: `is_global_mv_block` (blockd.h:421-429) is |
| @@ -551,14 +470,6 @@ pub(super) fn decode_inter_block( | |||
| 551 | // alone, which counts blocks that are not global-mv blocks at | 470 | // alone, which counts blocks that are not global-mv blocks at |
| 552 | // all, so its number was an upper bound dressed up as an | 471 | // all, so its number was an upper bound dressed up as an |
| 553 | // engagement figure. | 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 | // libaom `av1_init_warp_params` + `allow_warp`'s | 473 | // libaom `av1_init_warp_params` + `allow_warp`'s |
| 563 | // `global_warp_allowed` branch, run once per reference for a | 474 | // `global_warp_allowed` branch, run once per reference for a |
| 564 | // compound block exactly as for a single-ref one (reconinter.c | 475 | // compound block exactly as for a single-ref one (reconinter.c |
| @@ -595,7 +506,6 @@ pub(super) fn decode_inter_block( | |||
| 595 | let warp0 = compound_warp(ref0, is_global_mv0).filter(|_| ref_unscaled(ref0)); | 506 | let warp0 = compound_warp(ref0, is_global_mv0).filter(|_| ref_unscaled(ref0)); |
| 596 | let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1)); | 507 | let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1)); |
| 597 | if warp0.is_some() || warp1.is_some() { | 508 | if warp0.is_some() || warp1.is_some() { |
| 598 | - hit!(COMPOUND_WARP_HITS); | ||
| 599 | // lane-av112bitw: the 12-bit refusal that stood here is | 509 | // lane-av112bitw: the 12-bit refusal that stood here is |
| 600 | // LIFTED with the compound-warp witness: the rotating- | 510 | // LIFTED with the compound-warp witness: the rotating- |
| 601 | // mandelbrot 12-bit recipe refused exactly here pre-lift and | 511 | // mandelbrot 12-bit recipe refused exactly here pre-lift and |
| @@ -668,17 +578,10 @@ pub(super) fn decode_inter_block( | |||
| 668 | && enable_masked_compound | 578 | && enable_masked_compound |
| 669 | && is_any_masked_compound_used_here(write_w, write_h) | 579 | && is_any_masked_compound_used_here(write_w, write_h) |
| 670 | { | 580 | { |
| 671 | - crate::msac::SymbolDecoder::set_symr_cdf("comp_group_idx"); | ||
| 672 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) | 581 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) |
| 673 | } else { | 582 | } else { |
| 674 | 0 | 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 | // lane-maskcomp r2 / lane-wedge r3: `Some(mask_type)` for a | 585 | // lane-maskcomp r2 / lane-wedge r3: `Some(mask_type)` for a |
| 683 | // `COMPOUND_DIFFWTD` block, `Some(mask)` (wedge codebook lookup) | 586 | // `COMPOUND_DIFFWTD` block, `Some(mask)` (wedge codebook lookup) |
| 684 | // for a `COMPOUND_WEDGE` block -- exactly one of the two is set | 587 | // for a `COMPOUND_WEDGE` block -- exactly one of the two is set |
| @@ -714,16 +617,6 @@ pub(super) fn decode_inter_block( | |||
| 714 | // verified vs independent C dump (wedge.rs). | 617 | // verified vs independent C dump (wedge.rs). |
| 715 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); | 618 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); |
| 716 | let wedge_sign = dec.literal(1); | 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 | // lane-inter16ab r5: the codebook row is this block's TRUE | 620 | // lane-inter16ab r5: the codebook row is this block's TRUE |
| 728 | // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for | 621 | // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for |
| 729 | // h>w, hltw for h<w, plus that bsize's own signflip row). | 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 | // COMPOUND_DIFFWTD: `mask_type`, MAX_DIFFWTD_MASK_BITS==1. | 633 | // COMPOUND_DIFFWTD: `mask_type`, MAX_DIFFWTD_MASK_BITS==1. |
| 741 | let mask_type = dec.literal(1); | 634 | let mask_type = dec.literal(1); |
| 742 | diffwtd_mask_type = Some(mask_type as u8); | 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 | // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): r16/r17 | 638 | // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): r16/r17 |
| @@ -959,21 +845,10 @@ pub(super) fn decode_inter_block( | |||
| 959 | ref_order_hints[(ref0 - LAST_FRAME) as usize], | 845 | ref_order_hints[(ref0 - LAST_FRAME) as usize], |
| 960 | ref_order_hints[(ref1 - LAST_FRAME) as usize], | 846 | ref_order_hints[(ref1 - LAST_FRAME) as usize], |
| 961 | ); | 847 | ); |
| 962 | - crate::msac::SymbolDecoder::set_symr_cdf("compound_idx"); | ||
| 963 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); | 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 | if idx == 1 { | 849 | if idx == 1 { |
| 971 | (8, 8, 1u8) | 850 | (8, 8, 1u8) |
| 972 | } else { | 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 | let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign( | 852 | let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign( |
| 978 | order_hint_bits, | 853 | order_hint_bits, |
| 979 | order_hint, | 854 | order_hint, |
| @@ -986,16 +861,6 @@ pub(super) fn decode_inter_block( | |||
| 986 | (8, 8, 1u8) | 861 | (8, 8, 1u8) |
| 987 | }; | 862 | }; |
| 988 | compound_ctx = Some((ref1, comp_group_idx as u8, compound_idx)); | 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 | // spec 5.11.19/libaom `decodemv.c` 1575: `read_mb_interp_filter` | 865 | // spec 5.11.19/libaom `decodemv.c` 1575: `read_mb_interp_filter` |
| 1001 | // comes AFTER `read_compound_type` (the `comp_group_idx`/ | 866 | // comes AFTER `read_compound_type` (the `comp_group_idx`/ |
| @@ -1028,15 +893,9 @@ pub(super) fn decode_inter_block( | |||
| 1028 | // stride-1 one, so the unscaled case is unchanged. | 893 | // stride-1 one, so the unscaled case is unchanged. |
| 1029 | let scale0 = scale_of(ref_dims(ref0, refpix)?, frame_size); | 894 | let scale0 = scale_of(ref_dims(ref0, refpix)?, frame_size); |
| 1030 | let scale1 = scale_of(ref_dims(ref1, refpix)?, frame_size); | 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 | // lane-scaledref r2: the MIXED case -- one tap scaled, the other | 896 | // lane-scaledref r2: the MIXED case -- one tap scaled, the other |
| 1035 | // not -- is the one an all-frames-scaled recipe never produces, | 897 | // not -- is the one an all-frames-scaled recipe never produces, |
| 1036 | // and the one a single shared scale factor would get wrong. | 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 | // lane-wave4 (the compound arm's half): this block's whole | 900 | // lane-wave4 (the compound arm's half): this block's whole |
| 1042 | // prediction -- both references, the wedge/diffwtd/distance | 901 | // prediction -- both references, the wedge/diffwtd/distance |
| @@ -1148,7 +1007,6 @@ pub(super) fn decode_inter_block( | |||
| 1148 | // either way, only the mask source differs. | 1007 | // either way, only the mask source differs. |
| 1149 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { | 1008 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { |
| 1150 | diffwtd_mask_y = vec![0u8; side * side]; | 1009 | diffwtd_mask_y = vec![0u8; side * side]; |
| 1151 | - hit!(DIFFWTD_HITS); | ||
| 1152 | mc::diffwtd_mask( | 1010 | mc::diffwtd_mask( |
| 1153 | &inter0_y, | 1011 | &inter0_y, |
| 1154 | &inter1_y, | 1012 | &inter1_y, |
| @@ -1415,7 +1273,23 @@ pub(super) fn decode_inter_block( | |||
| 1415 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); | 1273 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); |
| 1416 | let (sy, su, sv) = if pred_deferred(refpix) { | 1274 | let (sy, su, sv) = if pred_deferred(refpix) { |
| 1417 | push_pred(build); | 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 | } else { | 1293 | } else { |
| 1420 | let mut built: [Vec<u16>; 3] = Default::default(); | 1294 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 1421 | build(y, u, v, refpix, fctx, &mut built); | 1295 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -1597,14 +1471,6 @@ pub(super) fn decode_inter_block( | |||
| 1597 | fctx, | 1471 | fctx, |
| 1598 | )? | 1472 | )? |
| 1599 | } else { | 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 | let tu_skip_ctx = | 1474 | let tu_skip_ctx = |
| 1609 | neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); | 1475 | neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); |
| 1610 | let start = row * MI * side + col * MI; | 1476 | let start = row * MI * side + col * MI; |
| @@ -1852,7 +1718,6 @@ pub(super) fn decode_inter_block( | |||
| 1852 | plane_idx, | 1718 | plane_idx, |
| 1853 | &cu_grid, | 1719 | &cu_grid, |
| 1854 | ); | 1720 | ); |
| 1855 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 1856 | mu_chroma = true; | 1721 | mu_chroma = true; |
| 1857 | // lane-av1muchunk422b: the allocation of this | 1722 | // lane-av1muchunk422b: the allocation of this |
| 1858 | // mu-chunk walk, counted per TX_32X32 UNIT. | 1723 | // mu-chunk walk, counted per TX_32X32 UNIT. |
| @@ -1861,9 +1726,6 @@ pub(super) fn decode_inter_block( | |||
| 1861 | // bump: `MU_CHUNK_COMPOUND_UNITS` names site 2 | 1726 | // bump: `MU_CHUNK_COMPOUND_UNITS` names site 2 |
| 1862 | // and the single-reference twin (site 5) stays | 1727 | // and the single-reference twin (site 5) stays |
| 1863 | // out of it. | 1728 | // out of it. |
| 1864 | - if is_compound { | ||
| 1865 | - hit!(MU_CHUNK_COMPOUND_UNITS); | ||
| 1866 | - } | ||
| 1867 | let dst = mu_units( | 1729 | let dst = mu_units( |
| 1868 | if plane_idx == 1 { | 1730 | if plane_idx == 1 { |
| 1869 | &mut u_units | 1731 | &mut u_units |
| @@ -2068,12 +1930,6 @@ pub(super) fn decode_inter_block( | |||
| 2068 | let cu_rel_mi = (cr * (cu_tx / MI), cc * (cu_tx / MI)); | 1930 | let cu_rel_mi = (cr * (cu_tx / MI), cc * (cu_tx / MI)); |
| 2069 | let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi) | 1931 | let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi) |
| 2070 | .unwrap_or(luma_tx_type); | 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 | let cu_grid = read_inter_plane( | 1933 | let cu_grid = read_inter_plane( |
| 2078 | dec, | 1934 | dec, |
| 2079 | cdfs, | 1935 | cdfs, |
| @@ -2099,7 +1955,6 @@ pub(super) fn decode_inter_block( | |||
| 2099 | // this one's coefficients. | 1955 | // this one's coefficients. |
| 2100 | neighbours | 1956 | neighbours |
| 2101 | .record_mi_chroma(cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid); | 1957 | .record_mi_chroma(cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid); |
| 2102 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 2103 | // lane-av1-444 c8: the unit's levels must ALSO | 1958 | // lane-av1-444 c8: the unit's levels must ALSO |
| 2104 | // land in the block grid -- the block-tail mu | 1959 | // land in the block grid -- the block-tail mu |
| 2105 | // re-stamp slices the per-unit states back out | 1960 | // re-stamp slices the per-unit states back out |
| @@ -2177,14 +2032,6 @@ pub(super) fn decode_inter_block( | |||
| 2177 | neighbours.left_ref1[rmi], | 2032 | neighbours.left_ref1[rmi], |
| 2178 | ); | 2033 | ); |
| 2179 | ref_frame_for_lf = ref_frame; | 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 | // round 4-9 (lane-av1golden..lane-av1golden7): GOLDEN_FRAME's own | 2035 | // round 4-9 (lane-av1golden..lane-av1golden7): GOLDEN_FRAME's own |
| 2189 | // stacked defects (lf_level ref/mode-delta forwarding, the | 2036 | // stacked defects (lf_level ref/mode-delta forwarding, the |
| 2190 | // switchable_interp ref-frame ctx gate, and a film-grain synthesis | 2037 | // switchable_interp ref-frame ctx gate, and a film-grain synthesis |
| @@ -2245,14 +2092,10 @@ pub(super) fn decode_inter_block( | |||
| 2245 | tpl, | 2092 | tpl, |
| 2246 | ); | 2093 | ); |
| 2247 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; | 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 | let mut is_globalmv = false; | 2095 | let mut is_globalmv = false; |
| 2252 | // lane-interbis r1: which single-ref mode this block resolved to, | 2096 | // lane-interbis r1: which single-ref mode this block resolved to, |
| 2253 | // in the oracle's own numbering (NEARESTMV=13 .. NEWMV=16), for | 2097 | // in the oracle's own numbering (NEARESTMV=13 .. NEWMV=16), for |
| 2254 | // the `EC_MODE_VAL` value ladder below. | 2098 | // the `EC_MODE_VAL` value ladder below. |
| 2255 | - let mut dbg_mode = 16u32; | ||
| 2256 | let (mv, is_new_mv) = if !not_new { | 2099 | let (mv, is_new_mv) = if !not_new { |
| 2257 | // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0): | 2100 | // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0): |
| 2258 | // read at most two `drl_mode` bits, one per stack entry past the | 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 | } else { | 2126 | } else { |
| 2284 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; | 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 | is_globalmv = !not_zero; | 2128 | is_globalmv = !not_zero; |
| 2289 | let mv = if !not_zero { | 2129 | let mv = if !not_zero { |
| 2290 | // GLOBALMV: `gm_get_motion_vector` (spec 7.10.2.1), already | 2130 | // GLOBALMV: `gm_get_motion_vector` (spec 7.10.2.1), already |
| 2291 | // computed at this block's own position in `gm_table`. | 2131 | // computed at this block's own position in `gm_table`. |
| 2292 | - dbg_mode = 15; | ||
| 2293 | gm_table[(ref_frame - LAST_FRAME) as usize] | 2132 | gm_table[(ref_frame - LAST_FRAME) as usize] |
| 2294 | } else { | 2133 | } else { |
| 2295 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; | 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 | if nearest { | 2135 | if nearest { |
| 2299 | stack.nearest_mv | 2136 | stack.nearest_mv |
| 2300 | } else { | 2137 | } else { |
| @@ -2316,26 +2153,6 @@ pub(super) fn decode_inter_block( | |||
| 2316 | }; | 2153 | }; |
| 2317 | (mv, false) | 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 | // lane-gm r2: the two libaom predicates single-ref GLOBALMV | 2156 | // lane-gm r2: the two libaom predicates single-ref GLOBALMV |
| 2340 | // blocks need -- `is_global_mv_block` (blockd.h:421-429, mode | 2157 | // blocks need -- `is_global_mv_block` (blockd.h:421-429, mode |
| 2341 | // GLOBAL* AND model > TRANSLATION AND min(bw,bh) >= 8px, gating | 2158 | // GLOBAL* AND model > TRANSLATION AND min(bw,bh) >= 8px, gating |
| @@ -2348,13 +2165,6 @@ pub(super) fn decode_inter_block( | |||
| 2348 | let is_global_mv_block = is_globalmv && gm_model as u8 > 1 && min_bw_bh4 >= 2; | 2165 | let is_global_mv_block = is_globalmv && gm_model as u8 > 1 && min_bw_bh4 >= 2; |
| 2349 | let gm_nontrans = | 2166 | let gm_nontrans = |
| 2350 | is_globalmv && gm_model != ec_av1_syntax::WarpModel::Translation && min_bw_bh4 >= 2; | 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 | // lane-sb128 r4: `interintra` (spec 5.11.24; libaom | 2168 | // lane-sb128 r4: `interintra` (spec 5.11.24; libaom |
| 2359 | // `decodemv.c` read_inter_block_mode_info ~1490-1510), placed | 2169 | // `decodemv.c` read_inter_block_mode_info ~1490-1510), placed |
| 2360 | // right after `assign_mv` and before `read_motion_mode` below -- | 2170 | // right after `assign_mv` and before `read_motion_mode` below -- |
| @@ -2384,7 +2194,6 @@ pub(super) fn decode_inter_block( | |||
| 2384 | // TRUE footprint -- a 16x8 strip is group 1, a 32x16 strip | 2194 | // TRUE footprint -- a 16x8 strip is group 1, a 32x16 strip |
| 2385 | // group 2, not their square `side`'s 2/3. | 2195 | // group 2, not their square `side`'s 2/3. |
| 2386 | let bsize_group = size_group_wh(write_w, write_h); | 2196 | let bsize_group = size_group_wh(write_w, write_h); |
| 2387 | - crate::msac::SymbolDecoder::set_symr_cdf("interintra"); | ||
| 2388 | let interintra = dec.symbol(&mut cdfs.interintra[bsize_group]) == 1; | 2197 | let interintra = dec.symbol(&mut cdfs.interintra[bsize_group]) == 1; |
| 2389 | if interintra { | 2198 | if interintra { |
| 2390 | // lane-interintra r1 (decodemv.c 1540-1555): interintra_mode, | 2199 | // lane-interintra r1 (decodemv.c 1540-1555): interintra_mode, |
| @@ -2406,16 +2215,6 @@ pub(super) fn decode_inter_block( | |||
| 2406 | // NO sign symbol follows -- libaom fixes | 2215 | // NO sign symbol follows -- libaom fixes |
| 2407 | // INTERINTRA_WEDGE_SIGN 0 (blockd.h). | 2216 | // INTERINTRA_WEDGE_SIGN 0 (blockd.h). |
| 2408 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); | 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 | // lane-inter16ab r5: true-footprint codebook row, | 2218 | // lane-inter16ab r5: true-footprint codebook row, |
| 2420 | // mask padded to stride `max(bw,bh) == side` -- see | 2219 | // mask padded to stride `max(bw,bh) == side` -- see |
| 2421 | // the compound site's own comment. | 2220 | // the compound site's own comment. |
| @@ -2425,8 +2224,6 @@ pub(super) fn decode_inter_block( | |||
| 2425 | .mask(0, wedge_index), | 2224 | .mask(0, wedge_index), |
| 2426 | side, | 2225 | side, |
| 2427 | )); | 2226 | )); |
| 2428 | - } else { | ||
| 2429 | - hit!(INTERINTRA_HITS); | ||
| 2430 | } | 2227 | } |
| 2431 | interintra_mode = Some(ii); | 2228 | interintra_mode = Some(ii); |
| 2432 | // The inter-intra predictor reads this block's neighbours as already | 2229 | // The inter-intra predictor reads this block's neighbours as already |
| @@ -2434,13 +2231,6 @@ pub(super) fn decode_inter_block( | |||
| 2434 | super::wave::finish_tile(fctx, refpix, [&mut *y, &mut *u, &mut *v]); | 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 | // lane-motionmode round 1: `read_motion_mode` (spec 5.11.24; | 2234 | // lane-motionmode round 1: `read_motion_mode` (spec 5.11.24; |
| 2445 | // libaom `decodemv.c` read_inter_block_mode_info, ~1520-1528), | 2235 | // libaom `decodemv.c` read_inter_block_mode_info, ~1520-1528), |
| 2446 | // placed right after MV assignment and before the switchable | 2236 | // placed right after MV assignment and before the switchable |
| @@ -2483,20 +2273,6 @@ pub(super) fn decode_inter_block( | |||
| 2483 | // as aomdec's `EC_ISTEP2 name=motion_mode` -- an eligibility | 2273 | // as aomdec's `EC_ISTEP2 name=motion_mode` -- an eligibility |
| 2484 | // mismatch is otherwise invisible (a skipped symbol prints | 2274 | // mismatch is otherwise invisible (a skipped symbol prints |
| 2485 | // nothing). | 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 | let mut obmc_selected = false; | 2276 | let mut obmc_selected = false; |
| 2501 | // lane-warp round 2: `Some` when motion_mode == WARPED_CAUSAL | 2277 | // lane-warp round 2: `Some` when motion_mode == WARPED_CAUSAL |
| 2502 | // *and* the local warp estimate is valid (`!wm_params.invalid`, | 2278 | // *and* the local warp estimate is valid (`!wm_params.invalid`, |
| @@ -2564,24 +2340,15 @@ pub(super) fn decode_inter_block( | |||
| 2564 | ) >= 1; | 2340 | ) >= 1; |
| 2565 | let warp_eligible = | 2341 | let warp_eligible = |
| 2566 | allow_warped_motion && !ref_is_scaled && !force_integer_mv && proj_ok; | 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 | if warp_eligible { | 2343 | if warp_eligible { |
| 2574 | - crate::msac::SymbolDecoder::set_symr_cdf("motion_mode"); | ||
| 2575 | let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); | 2344 | let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); |
| 2576 | match mode { | 2345 | match mode { |
| 2577 | 0 => {} | 2346 | 0 => {} |
| 2578 | 1 => { | 2347 | 1 => { |
| 2579 | obmc_selected = true; | 2348 | obmc_selected = true; |
| 2580 | - hit!(OBMC_HITS); | ||
| 2581 | } | 2349 | } |
| 2582 | _ => { | 2350 | _ => { |
| 2583 | warped_selected = true; | 2351 | warped_selected = true; |
| 2584 | - hit!(WARP_SELECTED_HITS); | ||
| 2585 | let mut samples = find_samples( | 2352 | let mut samples = find_samples( |
| 2586 | grid, | 2353 | grid, |
| 2587 | mi_row, | 2354 | mi_row, |
| @@ -2593,18 +2360,6 @@ pub(super) fn decode_inter_block( | |||
| 2593 | ref_frame, | 2360 | ref_frame, |
| 2594 | fctx, | 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 | if samples.len() > 1 { | 2363 | if samples.len() > 1 { |
| 2609 | crate::warp::select_samples( | 2364 | crate::warp::select_samples( |
| 2610 | mv, | 2365 | mv, |
| @@ -2625,45 +2380,15 @@ pub(super) fn decode_inter_block( | |||
| 2625 | mi_row as i32, | 2380 | mi_row as i32, |
| 2626 | mi_col as i32, | 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 | } else { | 2385 | } else { |
| 2646 | obmc_selected = dec.symbol(&mut cdfs.obmc[bsize_idx]) == 1; | 2386 | obmc_selected = dec.symbol(&mut cdfs.obmc[bsize_idx]) == 1; |
| 2647 | - if obmc_selected { | ||
| 2648 | - hit!(OBMC_HITS); | ||
| 2649 | - } | ||
| 2650 | } | 2387 | } |
| 2651 | // lane-t900 r9: which ALPHABET this block read (3-symbol | 2388 | // lane-t900 r9: which ALPHABET this block read (3-symbol |
| 2652 | // motion_mode vs 2-symbol obmc) and the range after -- the | 2389 | // motion_mode vs 2-symbol obmc) and the range after -- the |
| 2653 | // two give the same value with a different narrowing (class | 2390 | // two give the same value with a different narrowing (class |
| 2654 | // wrong-alphabet-same-value). | 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 | // lane-gm r4: `allow_warp`'s `global_warp_allowed` branch | 2393 | // lane-gm r4: `allow_warp`'s `global_warp_allowed` branch |
| 2669 | // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` -- | 2394 | // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` -- |
| @@ -2684,15 +2409,9 @@ pub(super) fn decode_inter_block( | |||
| 2684 | let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize]; | 2409 | let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize]; |
| 2685 | if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { | 2410 | if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { |
| 2686 | warp_params = crate::warp::global_warp_params(gm_ref.params); | 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 | // lane-av1gwarp12: the ROTZOOM sibling -- the only | 2412 | // lane-av1gwarp12: the ROTZOOM sibling -- the only |
| 2691 | // >TRANSLATION model vanilla aomenc can emit for a single-ref | 2413 | // >TRANSLATION model vanilla aomenc can emit for a single-ref |
| 2692 | // global-motion block (encoder search pinned to ROTZOOM). | 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 | // lane-av112bitw: a local `WARPED_CAUSAL` projection (set above) | 2416 | // lane-av112bitw: a local `WARPED_CAUSAL` projection (set above) |
| 2698 | // or a global warp model both land here with `warp_params` set -- | 2417 | // or a global warp model both land here with `warp_params` set -- |
| @@ -2701,14 +2420,6 @@ pub(super) fn decode_inter_block( | |||
| 2701 | // (`warp::warp_round_0`, 5 at 12 bits) and the six-frame 12-bit | 2420 | // (`warp::warp_round_0`, 5 at 12 bits) and the six-frame 12-bit |
| 2702 | // warp stream decodes byte-exact vs ffmpeg | 2421 | // warp stream decodes byte-exact vs ffmpeg |
| 2703 | // (`a_12bit_warped_motion_stream_decodes_pixel_exact`). | 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 | // spec `get_ref_filter_type`: a neighbour's own filter only feeds | 2423 | // spec `get_ref_filter_type`: a neighbour's own filter only feeds |
| 2713 | // this block's switchable_interp context when that neighbour coded | 2424 | // this block's switchable_interp context when that neighbour coded |
| 2714 | // the SAME reference frame this block is about to read -- a | 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 | block_filter = resolved_filter; | 2458 | block_filter = resolved_filter; |
| 2748 | globalmv_for_lf = is_globalmv; | 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 | // lane-rect r2: see the compound path's matching comment above -- | 2460 | // lane-rect r2: see the compound path's matching comment above -- |
| 2770 | // `grid` must be stamped with the block's true bh4/bw4 span, not | 2461 | // `grid` must be stamped with the block's true bh4/bw4 span, not |
| 2771 | // a square `bw4`x`bw4` guess. | 2462 | // a square `bw4`x`bw4` guess. |
| @@ -2818,15 +2509,6 @@ pub(super) fn decode_inter_block( | |||
| 2818 | // measured was the 16x4/4x16 strip's sub-8x8 chroma piece, | 2509 | // measured was the 16x4/4x16 strip's sub-8x8 chroma piece, |
| 2819 | // which this file used to SKIP under a scaled reference | 2510 | // which this file used to SKIP under a scaled reference |
| 2820 | // (fixed in the same commit), not the warp fallback. | 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 | // lane-inter16ab r2: `is_sub8x8_inter`'s neighbour walk reads the | 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 | Some((horz, (prev_ref, prev_mv, prev_h, prev_v))) => { | 2526 | Some((horz, (prev_ref, prev_mv, prev_h, prev_v))) => { |
| 2845 | let prev_dims = ref_dims(prev_ref, refpix)?; | 2527 | let prev_dims = ref_dims(prev_ref, refpix)?; |
| 2846 | - hit!(INTER16_SUB8_PIECE_HITS); | ||
| 2847 | Some(( | 2528 | Some(( |
| 2848 | horz, | 2529 | horz, |
| 2849 | prev_ref, | 2530 | prev_ref, |
| @@ -3083,9 +2764,6 @@ pub(super) fn decode_inter_block( | |||
| 3083 | // result, all planes (reconinter.c av1_build_interintra_predictor | 2764 | // result, all planes (reconinter.c av1_build_interintra_predictor |
| 3084 | // plane loop). | 2765 | // plane loop). |
| 3085 | if let Some(ii) = interintra_mode { | 2766 | if let Some(ii) = interintra_mode { |
| 3086 | - if write_w != write_h { | ||
| 3087 | - hit!(INTERINTRA_RECT_HITS); | ||
| 3088 | - } | ||
| 3089 | interintra_blend( | 2767 | interintra_blend( |
| 3090 | y, | 2768 | y, |
| 3091 | px, | 2769 | px, |
| @@ -3186,7 +2864,23 @@ pub(super) fn decode_inter_block( | |||
| 3186 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); | 2864 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); |
| 3187 | let (sy, su, sv) = if pred_deferred(refpix) { | 2865 | let (sy, su, sv) = if pred_deferred(refpix) { |
| 3188 | push_pred(build); | 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 | } else { | 2884 | } else { |
| 3191 | let mut built: [Vec<u16>; 3] = Default::default(); | 2885 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 3192 | build(y, u, v, refpix, fctx, &mut built); | 2886 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -3351,10 +3045,7 @@ pub(super) fn decode_inter_block( | |||
| 3351 | // extent is the strip's own. Counted so a 4:4:4 1:4-strip | 3045 | // extent is the strip's own. Counted so a 4:4:4 1:4-strip |
| 3352 | // gate can prove it exercised this route (a 4:2:0 stream | 3046 | // gate can prove it exercised this route (a 4:2:0 stream |
| 3353 | // of the same content reads 0). | 3047 | // of the same content reads 0). |
| 3354 | - Some(_) if ss_x(fctx) == 0 => { | 3048 | + Some(_) if ss_x(fctx) == 0 => around, |
| 3355 | - hit!(RECT4_INTER_OWN_CHROMA444_HITS); | ||
| 3356 | - around | ||
| 3357 | - } | ||
| 3358 | Some(s) if s.has_chroma => { | 3049 | Some(s) if s.has_chroma => { |
| 3359 | let (pw, ph) = if s.horz { | 3050 | let (pw, ph) = if s.horz { |
| 3360 | if ss_y(fctx) == 0 { (16, 4) } else { (16, 8) } | 3051 | if ss_y(fctx) == 0 { (16, 4) } else { (16, 8) } |
| @@ -3433,14 +3124,6 @@ pub(super) fn decode_inter_block( | |||
| 3433 | fctx, | 3124 | fctx, |
| 3434 | )? | 3125 | )? |
| 3435 | } else { | 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 | let tu_skip_ctx = | 3127 | let tu_skip_ctx = |
| 3445 | neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); | 3128 | neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); |
| 3446 | let start = row * MI * side + col * MI; | 3129 | let start = row * MI * side + col * MI; |
| @@ -3674,7 +3357,6 @@ pub(super) fn decode_inter_block( | |||
| 3674 | plane_idx, | 3357 | plane_idx, |
| 3675 | &cu_grid, | 3358 | &cu_grid, |
| 3676 | ); | 3359 | ); |
| 3677 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 3678 | mu_chroma = true; | 3360 | mu_chroma = true; |
| 3679 | // lane-av1muchunk422b: the allocation of this | 3361 | // lane-av1muchunk422b: the allocation of this |
| 3680 | // mu-chunk walk, counted per TX_32X32 UNIT. | 3362 | // mu-chunk walk, counted per TX_32X32 UNIT. |
| @@ -3683,9 +3365,6 @@ pub(super) fn decode_inter_block( | |||
| 3683 | // bump: `MU_CHUNK_COMPOUND_UNITS` names site 2 | 3365 | // bump: `MU_CHUNK_COMPOUND_UNITS` names site 2 |
| 3684 | // and the single-reference twin (site 5) stays | 3366 | // and the single-reference twin (site 5) stays |
| 3685 | // out of it. | 3367 | // out of it. |
| 3686 | - if is_compound { | ||
| 3687 | - hit!(MU_CHUNK_COMPOUND_UNITS); | ||
| 3688 | - } | ||
| 3689 | let dst = mu_units( | 3368 | let dst = mu_units( |
| 3690 | if plane_idx == 1 { | 3369 | if plane_idx == 1 { |
| 3691 | &mut u_units | 3370 | &mut u_units |
| @@ -3906,16 +3585,10 @@ pub(super) fn decode_inter_block( | |||
| 3906 | let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi) | 3585 | let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi) |
| 3907 | .unwrap_or(luma_tx_type); | 3586 | .unwrap_or(luma_tx_type); |
| 3908 | if covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi).is_some() { | 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 | // lane-av1f9singleland: this arm's own | 3588 | // lane-av1f9singleland: this arm's own |
| 3912 | // non-vacuity number -- the shared | 3589 | // non-vacuity number -- the shared |
| 3913 | // DIFFERS counter below cannot say which | 3590 | // DIFFERS counter below cannot say which |
| 3914 | // arm changed an answer. | 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 | let cu_grid = read_inter_plane( | 3593 | let cu_grid = read_inter_plane( |
| 3921 | dec, | 3594 | dec, |
| @@ -3942,7 +3615,6 @@ pub(super) fn decode_inter_block( | |||
| 3942 | // this one's coefficients. | 3615 | // this one's coefficients. |
| 3943 | neighbours | 3616 | neighbours |
| 3944 | .record_mi_chroma(cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid); | 3617 | .record_mi_chroma(cu_mi, cu_tx, cu_tx, plane_idx, &cu_grid); |
| 3945 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 3946 | // lane-av1-444 c8: the unit's levels must ALSO | 3618 | // lane-av1-444 c8: the unit's levels must ALSO |
| 3947 | // land in the block grid -- the block-tail mu | 3619 | // land in the block grid -- the block-tail mu |
| 3948 | // re-stamp slices the per-unit states back out | 3620 | // re-stamp slices the per-unit states back out |
| @@ -4075,15 +3747,6 @@ pub(super) fn decode_inter_block( | |||
| 4075 | // equivalent post-content point (added at the matching call site) | 3747 | // equivalent post-content point (added at the matching call site) |
| 4076 | // narrows the ladder to this block's own tail instead of the next | 3748 | // narrows the ladder to this block's own tail instead of the next |
| 4077 | // block's partition read. | 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 | // lane-inter16ab r2: the pair's chroma coefficient context spans BOTH | 3750 | // lane-inter16ab r2: the pair's chroma coefficient context spans BOTH |
| 4088 | // strips (mirroring the intra `decode_rect4_16` path), and the even | 3751 | // strips (mirroring the intra `decode_rect4_16` path), and the even |
| 4089 | // strip's own record wrote empty chroma state over those cells -- this | 3752 | // strip's own record wrote empty chroma state over those cells -- this |
| @@ -4250,7 +3913,6 @@ pub(super) fn decode_inter_block( | |||
| 4250 | palette_record.3, | 3913 | palette_record.3, |
| 4251 | ); | 3914 | ); |
| 4252 | let saved_chroma_ctx = (!has_chroma).then(|| { | 3915 | let saved_chroma_ctx = (!has_chroma).then(|| { |
| 4253 | - hit!(NON_CHROMA_REF_CTX_SKIP_HITS); | ||
| 4254 | let (w_mi, h_mi) = (write_w / MI, write_h / MI); | 3916 | let (w_mi, h_mi) = (write_w / MI, write_h / MI); |
| 4255 | let left: Vec<[Neighbour; 2]> = (0..h_mi) | 3917 | let left: Vec<[Neighbour; 2]> = (0..h_mi) |
| 4256 | .filter_map(|k| neighbours.left.get(at.0 + k).map(|s| [s[1], s[2]])) | 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 | // where aomdec reads 1, because the skipped 128x128 block at | 3939 | // where aomdec reads 1, because the skipped 128x128 block at |
| 4278 | // mi(32,32) never cleared `left[32..48]`. | 3940 | // mi(32,32) never cleared `left[32..48]`. |
| 4279 | if skip { | 3941 | if skip { |
| 4280 | - hit!(SKIP_VARTX_LUMA_RESET_HITS); | ||
| 4281 | neighbours.record_mi_luma_rect(at, write_w, write_h, &luma_grid); | 3942 | neighbours.record_mi_luma_rect(at, write_w, write_h, &luma_grid); |
| 4282 | } | 3943 | } |
| 4283 | // Plane 0 is already correct per transform unit | 3944 | // Plane 0 is already correct per transform unit |
| @@ -4374,7 +4035,6 @@ pub(super) fn decode_inter_block( | |||
| 4374 | } | 4035 | } |
| 4375 | } | 4036 | } |
| 4376 | neighbours.record_uv_mode_mi(s.pair_mi.0, s.pair_mi.1, pw / MI, ph / MI, uv_predict_mode); | 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 | // lane-av1-444 c8: each unit stamps its OWN span (32 << ss px at | 4039 | // lane-av1-444 c8: each unit stamps its OWN span (32 << ss px at |
| 4380 | // TX_32X32, 8 px lossless) -- a 64x64 mu chunk at ss 0/0 holds four | 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 | // entry sets the same label from ITS `at`, which is a different block -- | 160 | // entry sets the same label from ITS `at`, which is a different block -- |
| 161 | // publishing from here is what makes the EC_SYMR mi trustworthy on the | 161 | // publishing from here is what makes the EC_SYMR mi trustworthy on the |
| 162 | // inter path, which is what round 22 got wrong by assuming it was not. | 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 | const LAST_FRAME: i8 = 1; | 163 | const LAST_FRAME: i8 = 1; |
| 166 | // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back | 164 | // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back |
| 167 | // so the caller stamps them into `Neighbours` instead of the `[3, 3]` | 165 | // so the caller stamps them into `Neighbours` instead of the `[3, 3]` |
| @@ -243,9 +241,6 @@ pub(super) fn decode_inter_block8( | |||
| 243 | // leaf is always `BLOCK_8X8`, i.e. 2x2 mi. | 241 | // leaf is always `BLOCK_8X8`, i.e. 2x2 mi. |
| 244 | inter_segment_id(dec, cdfs, leaf_mi.0, leaf_mi.1, 2, 2, false, true, fctx); | 242 | inter_segment_id(dec, cdfs, leaf_mi.0, leaf_mi.1, 2, 2, false, true, fctx); |
| 245 | let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; | 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 | let skip_ctx = usize::from(above_skip) + usize::from(left_skip); | 245 | let skip_ctx = usize::from(above_skip) + usize::from(left_skip); |
| 251 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; | 246 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; |
| @@ -264,14 +259,6 @@ pub(super) fn decode_inter_block8( | |||
| 264 | // lane-inter8 r1: mirrors the oracle's `EC_MODE` (instrument rung 4, | 259 | // lane-inter8 r1: mirrors the oracle's `EC_MODE` (instrument rung 4, |
| 265 | // `read_inter_block_mode_info`) so an 8x8 leaf's mode-info range ladder | 260 | // `read_inter_block_mode_info`) so an 8x8 leaf's mode-info range ladder |
| 266 | // diffs line for line against a real aomdec. | 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 | let mode_for_tx; | 263 | let mode_for_tx; |
| 277 | // lane-uv8 r1: this leaf's chroma prediction mode (`get_uv_mode` of the | 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 | comp_stack.ref_mv_ctx, | 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 | let (mv0, mv1) = assign_compound_mv( | 372 | let (mv0, mv1) = assign_compound_mv( |
| 398 | dec, | 373 | dec, |
| 399 | cdfs, | 374 | cdfs, |
| @@ -412,19 +387,6 @@ pub(super) fn decode_inter_block8( | |||
| 412 | // lane-inter8 r3: byte-format-identical to the oracle's | 387 | // lane-inter8 r3: byte-format-identical to the oracle's |
| 413 | // rung-4 `EC_MODE_VAL`, so the leaf's mode+mv VALUE ladder | 388 | // rung-4 `EC_MODE_VAL`, so the leaf's mode+mv VALUE ladder |
| 414 | // diffs line for line against a real aomdec. | 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 | // spec 5.11.25: same gating [`decode_inter_block`]'s own | 391 | // spec 5.11.25: same gating [`decode_inter_block`]'s own |
| 430 | // compound arm uses, keyed off `outer_at`'s [`SUB`]-grid | 392 | // compound arm uses, keyed off `outer_at`'s [`SUB`]-grid |
| @@ -435,7 +397,6 @@ pub(super) fn decode_inter_block8( | |||
| 435 | && enable_masked_compound | 397 | && enable_masked_compound |
| 436 | && is_any_masked_compound_used_here(SIDE, SIDE) | 398 | && is_any_masked_compound_used_here(SIDE, SIDE) |
| 437 | { | 399 | { |
| 438 | - crate::msac::SymbolDecoder::set_symr_cdf("comp_group_idx"); | ||
| 439 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) | 400 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) |
| 440 | } else { | 401 | } else { |
| 441 | 0 | 402 | 0 |
| @@ -454,7 +415,6 @@ pub(super) fn decode_inter_block8( | |||
| 454 | // leaf's own comment. | 415 | // leaf's own comment. |
| 455 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[3]); | 416 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[3]); |
| 456 | let wedge_sign = dec.literal(1); | 417 | let wedge_sign = dec.literal(1); |
| 457 | - hit!(WEDGE_HITS); | ||
| 458 | wedge_mask = Some( | 418 | wedge_mask = Some( |
| 459 | crate::wedge::wedge_masks() | 419 | crate::wedge::wedge_masks() |
| 460 | .codebook(SIDE, SIDE) | 420 | .codebook(SIDE, SIDE) |
| @@ -464,7 +424,6 @@ pub(super) fn decode_inter_block8( | |||
| 464 | let mask_type = dec.literal(1); | 424 | let mask_type = dec.literal(1); |
| 465 | diffwtd_mask_type = Some(mask_type as u8); | 425 | diffwtd_mask_type = Some(mask_type as u8); |
| 466 | } | 426 | } |
| 467 | - hit!(MASKED_COMPOUND_HITS); | ||
| 468 | } | 427 | } |
| 469 | // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): same | 428 | // corner-cut (lane-av1comp r16/r17, lane-av1blend r1): same |
| 470 | // reference-slot defect as the 16x16 leaf's own mask above | 429 | // reference-slot defect as the 16x16 leaf's own mask above |
| @@ -490,15 +449,10 @@ pub(super) fn decode_inter_block8( | |||
| 490 | ref_order_hints[(ref0 - LAST_FRAME) as usize], | 449 | ref_order_hints[(ref0 - LAST_FRAME) as usize], |
| 491 | ref_order_hints[(ref1 - LAST_FRAME) as usize], | 450 | ref_order_hints[(ref1 - LAST_FRAME) as usize], |
| 492 | ); | 451 | ); |
| 493 | - crate::msac::SymbolDecoder::set_symr_cdf("compound_idx"); | ||
| 494 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); | 452 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); |
| 495 | if idx == 1 { | 453 | if idx == 1 { |
| 496 | (8, 8, 1u8) | 454 | (8, 8, 1u8) |
| 497 | } else { | 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 | let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign( | 456 | let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign( |
| 503 | order_hint_bits, | 457 | order_hint_bits, |
| 504 | order_hint, | 458 | order_hint, |
| @@ -511,16 +465,6 @@ pub(super) fn decode_inter_block8( | |||
| 511 | (8, 8, 1u8) | 465 | (8, 8, 1u8) |
| 512 | }; | 466 | }; |
| 513 | compound_ctx8 = Some((ref0, ref1, comp_group_idx as u8, compound_idx)); | 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 | // lane-interp3 r1: `read_mb_interp_filter` (libaom | 469 | // lane-interp3 r1: `read_mb_interp_filter` (libaom |
| 526 | // `decodemv.c` 1575, the tail of | 470 | // `decodemv.c` 1575, the tail of |
| @@ -570,17 +514,10 @@ pub(super) fn decode_inter_block8( | |||
| 570 | true, | 514 | true, |
| 571 | ); | 515 | ); |
| 572 | leaf_filter_syms = resolved_filter; | 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 | // lane-defer8: both slots' SIZES at parse, pictures in the closure. | 518 | // lane-defer8: both slots' SIZES at parse, pictures in the closure. |
| 578 | let scale0 = scale_of(ref_dims(ref0, refpix)?, frame_size); | 519 | let scale0 = scale_of(ref_dims(ref0, refpix)?, frame_size); |
| 579 | let scale1 = scale_of(ref_dims(ref1, refpix)?, frame_size); | 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 | // lane-interp3 r2 (class twin-functions-drift): both slots | 522 | // lane-interp3 r2 (class twin-functions-drift): both slots |
| 586 | // used to be stamped `false`, while [`decode_inter_block`]'s | 523 | // used to be stamped `false`, while [`decode_inter_block`]'s |
| @@ -635,10 +572,6 @@ pub(super) fn decode_inter_block8( | |||
| 635 | leaf_compound_warp(ref0, is_global_mv0_c).filter(|_| leaf_ref_unscaled(ref0)); | 572 | leaf_compound_warp(ref0, is_global_mv0_c).filter(|_| leaf_ref_unscaled(ref0)); |
| 636 | let warp1_c = | 573 | let warp1_c = |
| 637 | leaf_compound_warp(ref1, is_global_mv1_c).filter(|_| leaf_ref_unscaled(ref1)); | 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 | grid.fill_rect( | 575 | grid.fill_rect( |
| 643 | mi_row, | 576 | mi_row, |
| 644 | mi_col, | 577 | mi_col, |
| @@ -745,7 +678,6 @@ pub(super) fn decode_inter_block8( | |||
| 745 | let mut diffwtd_mask_y; | 678 | let mut diffwtd_mask_y; |
| 746 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { | 679 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { |
| 747 | diffwtd_mask_y = vec![0u8; SIDE * SIDE]; | 680 | diffwtd_mask_y = vec![0u8; SIDE * SIDE]; |
| 748 | - hit!(DIFFWTD_HITS); | ||
| 749 | mc::diffwtd_mask( | 681 | mc::diffwtd_mask( |
| 750 | &inter0_y, | 682 | &inter0_y, |
| 751 | &inter1_y, | 683 | &inter1_y, |
| @@ -1002,7 +934,23 @@ pub(super) fn decode_inter_block8( | |||
| 1002 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); | 934 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); |
| 1003 | let (sy, su, sv) = if pred_deferred(refpix) { | 935 | let (sy, su, sv) = if pred_deferred(refpix) { |
| 1004 | push_pred(build); | 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 | } else { | 954 | } else { |
| 1007 | let mut built: [Vec<u16>; 3] = Default::default(); | 955 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 1008 | build(y, u, v, refpix, fctx, &mut built); | 956 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -1323,13 +1271,6 @@ pub(super) fn decode_inter_block8( | |||
| 1323 | neighbours.above[leaf_mi.1 + cell][0] = state; | 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 | neighbours.fill_skip_grid(leaf_mi, 2, skip); | 1274 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 1334 | // lane-sub8x4 r2: `split8` is this leaf's OWN var-tx split, so | 1275 | // lane-sub8x4 r2: `split8` is this leaf's OWN var-tx split, so |
| 1335 | // the deblock grid must publish the TX_4X4 leaves' width the | 1276 | // the deblock grid must publish the TX_4X4 leaves' width the |
| @@ -1408,19 +1349,8 @@ pub(super) fn decode_inter_block8( | |||
| 1408 | // lane-interp3 r2: same per-entry EC_STACK ladder | 1349 | // lane-interp3 r2: same per-entry EC_STACK ladder |
| 1409 | // [`decode_inter_block`]'s single-ref arm prints, so this leaf's stack | 1350 | // [`decode_inter_block`]'s single-ref arm prints, so this leaf's stack |
| 1410 | // diffs line for line against the oracle's. | 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 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; | 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 | let mut is_globalmv = false; | 1354 | let mut is_globalmv = false; |
| 1425 | let (mv, is_new_mv) = if !not_new { | 1355 | let (mv, is_new_mv) = if !not_new { |
| 1426 | // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0): | 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 | } else { | 1382 | } else { |
| 1453 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; | 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 | is_globalmv = !not_zero; | 1384 | is_globalmv = !not_zero; |
| 1458 | let mv = if !not_zero { | 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 | gm_table[(ref_frame - LAST_FRAME) as usize] | 1386 | gm_table[(ref_frame - LAST_FRAME) as usize] |
| 1464 | } else { | 1387 | } else { |
| 1465 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; | 1388 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; |
| 1466 | - crate::census::mode(if nearest { 2 } else { 3 }); | ||
| 1467 | if nearest { | 1389 | if nearest { |
| 1468 | stack.nearest_mv | 1390 | stack.nearest_mv |
| 1469 | } else { | 1391 | } else { |
| @@ -1487,7 +1409,6 @@ pub(super) fn decode_inter_block8( | |||
| 1487 | let mut interintra_mode: Option<u8> = None; | 1409 | let mut interintra_mode: Option<u8> = None; |
| 1488 | let mut wedge_mask: Option<(&'static [u8], usize)> = None; | 1410 | let mut wedge_mask: Option<(&'static [u8], usize)> = None; |
| 1489 | if enable_interintra_compound && !skip_mode { | 1411 | if enable_interintra_compound && !skip_mode { |
| 1490 | - crate::msac::SymbolDecoder::set_symr_cdf("interintra"); | ||
| 1491 | let interintra = dec.symbol(&mut cdfs.interintra[SIZE_GROUP_8]) == 1; | 1412 | let interintra = dec.symbol(&mut cdfs.interintra[SIZE_GROUP_8]) == 1; |
| 1492 | if interintra { | 1413 | if interintra { |
| 1493 | // lane-interintra r1: same read pair as the 16/32 site; | 1414 | // lane-interintra r1: same read pair as the 16/32 site; |
| @@ -1499,15 +1420,12 @@ pub(super) fn decode_inter_block8( | |||
| 1499 | // lane-wii r2: same adapting `wedge_index` symbol as the | 1420 | // lane-wii r2: same adapting `wedge_index` symbol as the |
| 1500 | // 16/32 leaf, fixed sign 0 -- see that site's comment. | 1421 | // 16/32 leaf, fixed sign 0 -- see that site's comment. |
| 1501 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[3]); | 1422 | let wedge_index = dec.symbol(&mut cdfs.wedge_idx[3]); |
| 1502 | - hit!(WII_HITS); | ||
| 1503 | wedge_mask = Some(( | 1423 | wedge_mask = Some(( |
| 1504 | crate::wedge::wedge_masks() | 1424 | crate::wedge::wedge_masks() |
| 1505 | .codebook(SIDE, SIDE) | 1425 | .codebook(SIDE, SIDE) |
| 1506 | .mask(0, wedge_index), | 1426 | .mask(0, wedge_index), |
| 1507 | SIDE, | 1427 | SIDE, |
| 1508 | )); | 1428 | )); |
| 1509 | - } else { | ||
| 1510 | - hit!(INTERINTRA_HITS); | ||
| 1511 | } | 1429 | } |
| 1512 | interintra_mode = Some(ii); | 1430 | interintra_mode = Some(ii); |
| 1513 | // The inter-intra predictor reads this block's neighbours as already | 1431 | // The inter-intra predictor reads this block's neighbours as already |
| @@ -1584,38 +1502,14 @@ pub(super) fn decode_inter_block8( | |||
| 1584 | let ref_is_scaled = !scale_of((ref_width, ref_height), frame_size).is_unscaled(); | 1502 | let ref_is_scaled = !scale_of((ref_width, ref_height), frame_size).is_unscaled(); |
| 1585 | let warp_eligible = | 1503 | let warp_eligible = |
| 1586 | allow_warped_motion && !ref_is_scaled && !force_integer_mv && proj_ok; | 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 | if warp_eligible { | 1505 | if warp_eligible { |
| 1600 | - crate::msac::SymbolDecoder::set_symr_cdf("motion_mode"); | ||
| 1601 | let mode = dec.symbol(&mut cdfs.motion_mode[0]); | 1506 | let mode = dec.symbol(&mut cdfs.motion_mode[0]); |
| 1602 | match mode { | 1507 | match mode { |
| 1603 | 0 => {} | 1508 | 0 => {} |
| 1604 | 1 => { | 1509 | 1 => { |
| 1605 | obmc_selected = true; | 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 | let mut samples = find_samples( | 1513 | let mut samples = find_samples( |
| 1620 | grid, | 1514 | grid, |
| 1621 | mi_row, | 1515 | mi_row, |
| @@ -1640,18 +1534,11 @@ pub(super) fn decode_inter_block8( | |||
| 1640 | mi_col as i32, | 1534 | mi_col as i32, |
| 1641 | ); | 1535 | ); |
| 1642 | warped_selected = true; | 1536 | warped_selected = true; |
| 1643 | - if warp_params.is_some() { | ||
| 1644 | - hit!(WARP_HITS_8); | ||
| 1645 | - } | ||
| 1646 | } | 1537 | } |
| 1647 | } | 1538 | } |
| 1648 | } else { | 1539 | } else { |
| 1649 | // `default_obmc_cdf`'s own index: square bsize 8/16/32/64 -> 0/1/2/3. | 1540 | // `default_obmc_cdf`'s own index: square bsize 8/16/32/64 -> 0/1/2/3. |
| 1650 | obmc_selected = dec.symbol(&mut cdfs.obmc[0]) == 1; | 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 | // lane-gmaffine r1: `read_mb_interp_filter` (spec 5.11.26) at the 8x8 | 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 | false, | 1582 | false, |
| 1696 | ); | 1583 | ); |
| 1697 | leaf_filter_syms = resolved_filter; | 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 | // lane-gmaffine r1: `allow_warp`'s `global_warp_allowed` branch | 1585 | // lane-gmaffine r1: `allow_warp`'s `global_warp_allowed` branch |
| 1710 | // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` -- | 1586 | // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` -- |
| 1711 | // see [`decode_inter_block`]'s own copy. A local WARPED_CAUSAL model | 1587 | // see [`decode_inter_block`]'s own copy. A local WARPED_CAUSAL model |
| @@ -1713,23 +1589,12 @@ pub(super) fn decode_inter_block8( | |||
| 1713 | // size predicate baked into `is_global_mv_block`. | 1589 | // size predicate baked into `is_global_mv_block`. |
| 1714 | if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { | 1590 | if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { |
| 1715 | warp_params = crate::warp::global_warp_params(gm_ref.params); | 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 | // lane-av112bitw: same lift as the 16x16+ leaf -- a local | 1593 | // lane-av112bitw: same lift as the 16x16+ leaf -- a local |
| 1721 | // `WARPED_CAUSAL` projection or a global model both leave | 1594 | // `WARPED_CAUSAL` projection or a global model both leave |
| 1722 | // `warp_params` set here; the 12-bit refusal that stood here is | 1595 | // `warp_params` set here; the 12-bit refusal that stood here is |
| 1723 | // lifted with the same witness (`warp::warp_round_0` moved the | 1596 | // lifted with the same witness (`warp::warp_round_0` moved the |
| 1724 | // filter's shifts; the same stream decodes byte-exact vs ffmpeg). | 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 | grid.fill_rect( | 1598 | grid.fill_rect( |
| 1734 | mi_row, | 1599 | mi_row, |
| 1735 | mi_col, | 1600 | mi_col, |
| @@ -1760,9 +1625,6 @@ pub(super) fn decode_inter_block8( | |||
| 1760 | // (documented corner-cut above); under a scaled reference the same | 1625 | // (documented corner-cut above); under a scaled reference the same |
| 1761 | // fixed kernel runs through spec 7.11.3.3's scaled walk instead. | 1626 | // fixed kernel runs through spec 7.11.3.3's scaled walk instead. |
| 1762 | let luma_scale = scale_of((ref_width, ref_height), frame_size); | 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 | let obmc = if obmc_selected { | 1628 | let obmc = if obmc_selected { |
| 1767 | Some(obmc_plan( | 1629 | Some(obmc_plan( |
| 1768 | grid, | 1630 | grid, |
| @@ -1972,7 +1834,23 @@ pub(super) fn decode_inter_block8( | |||
| 1972 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); | 1834 | let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>); |
| 1973 | let (sy, su, sv) = if pred_deferred(refpix) { | 1835 | let (sy, su, sv) = if pred_deferred(refpix) { |
| 1974 | push_pred(build); | 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 | } else { | 1854 | } else { |
| 1977 | // The interintra predictor reads this block's own above/left | 1855 | // The interintra predictor reads this block's own above/left |
| 1978 | // edges, which are already written at this point. | 1856 | // edges, which are already written at this point. |
| @@ -2194,7 +2072,6 @@ pub(super) fn decode_inter_block8( | |||
| 2194 | } | 2072 | } |
| 2195 | } | 2073 | } |
| 2196 | } else { | 2074 | } else { |
| 2197 | - crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | ||
| 2198 | let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]); | 2075 | let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]); |
| 2199 | if mode >= 13 { | 2076 | if mode >= 13 { |
| 2200 | return Err(unsupported( | 2077 | return Err(unsupported( |
| @@ -2214,19 +2091,6 @@ pub(super) fn decode_inter_block8( | |||
| 2214 | } else { | 2091 | } else { |
| 2215 | 0 | 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 | // lane-uv8 r1: the delta'd angle decides the intra edge filter, and a | 2094 | // lane-uv8 r1: the delta'd angle decides the intra edge filter, and a |
| 2231 | // directional luma mode is already legal on this leaf -- the arm | 2095 | // directional luma mode is already legal on this leaf -- the arm |
| 2232 | // passed a hardcoded `false` where [`decode_leaf8`] reads the | 2096 | // passed a hardcoded `false` where [`decode_leaf8`] reads the |
| @@ -2256,42 +2120,20 @@ pub(super) fn decode_inter_block8( | |||
| 2256 | let uv_mode = if !has_chroma { | 2120 | let uv_mode = if !has_chroma { |
| 2257 | DC_PRED | 2121 | DC_PRED |
| 2258 | } else if cfl_allowed_px(SIDE, SIDE, fctx) { | 2122 | } else if cfl_allowed_px(SIDE, SIDE, fctx) { |
| 2259 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 2260 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 2123 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 2261 | } else { | 2124 | } else { |
| 2262 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 2263 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 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 | let alpha = if has_chroma && uv_mode == UV_CFL_PRED { | 2127 | let alpha = if has_chroma && uv_mode == UV_CFL_PRED { |
| 2279 | - hit!(INTRA_IN_INTER8_UV_CFL_HITS); | ||
| 2280 | Some(read_cfl_alphas(dec, cdfs)) | 2128 | Some(read_cfl_alphas(dec, cdfs)) |
| 2281 | } else { | 2129 | } else { |
| 2282 | None | 2130 | None |
| 2283 | }; | 2131 | }; |
| 2284 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { | 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 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | 2133 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 2288 | } else { | 2134 | } else { |
| 2289 | 0 | 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 | // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED`. | 2137 | // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED`. |
| 2296 | uv_predict_mode = if uv_mode == UV_CFL_PRED { | 2138 | uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 2297 | DC_PRED | 2139 | DC_PRED |
| @@ -2333,16 +2175,6 @@ pub(super) fn decode_inter_block8( | |||
| 2333 | let use_palette_uv = has_chroma | 2175 | let use_palette_uv = has_chroma |
| 2334 | && uv_mode == DC_PRED | 2176 | && uv_mode == DC_PRED |
| 2335 | && dec.symbol(&mut cdfs.palette_uv_mode[usize::from(use_palette_y)]) != 0; | 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 | if use_palette_uv { | 2178 | if use_palette_uv { |
| 2347 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); | 2179 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); |
| 2348 | let (u_colors, v_colors) = read_palette_colors_uv(dec, n, &palette_uv_cache, fctx); | 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 | // prints `use_filter_intra` for an intra block inside an INTER frame | 2194 | // prints `use_filter_intra` for an intra block inside an INTER frame |
| 2363 | // and nothing else, so this leaf needs the same two lines for a | 2195 | // and nothing else, so this leaf needs the same two lines for a |
| 2364 | // range-ladder diff against it. | 2196 | // range-ladder diff against it. |
| 2365 | - let ec_istep8 = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); | ||
| 2366 | if mode == DC_PRED | 2197 | if mode == DC_PRED |
| 2367 | && fctx.enable_filter_intra_inter.with(std::cell::Cell::get) | 2198 | && fctx.enable_filter_intra_inter.with(std::cell::Cell::get) |
| 2368 | // `av1_filter_intra_allowed` (reconintra.h:77) excludes a | 2199 | // `av1_filter_intra_allowed` (reconintra.h:77) excludes a |
| @@ -2371,27 +2202,8 @@ pub(super) fn decode_inter_block8( | |||
| 2371 | && let Some(class) = filter_intra_size_class(SIDE) | 2202 | && let Some(class) = filter_intra_size_class(SIDE) |
| 2372 | { | 2203 | { |
| 2373 | let use_fi = dec.symbol(&mut cdfs.filter_intra[class]) != 0; | 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 | if use_fi { | 2205 | if use_fi { |
| 2384 | - hit!(FILTER_INTRA_HITS); | ||
| 2385 | - hit!(INTRA_IN_INTER_FILTER_INTRA_HITS); | ||
| 2386 | let fi = dec.symbol(&mut cdfs.filter_intra_mode); | 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 | filter_intra = Some(fi); | 2207 | filter_intra = Some(fi); |
| 2396 | } | 2208 | } |
| 2397 | } | 2209 | } |
| @@ -2407,15 +2219,6 @@ pub(super) fn decode_inter_block8( | |||
| 2407 | palette_onscreen(rmi, cmi, SIDE, SIDE, fctx), | 2219 | palette_onscreen(rmi, cmi, SIDE, SIDE, fctx), |
| 2408 | false, | 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 | PaletteY { | 2222 | PaletteY { |
| 2420 | size: n, | 2223 | size: n, |
| 2421 | colors, | 2224 | colors, |
| @@ -2433,15 +2236,6 @@ pub(super) fn decode_inter_block8( | |||
| 2433 | (ss_x(fctx), ss_y(fctx)), | 2236 | (ss_x(fctx), ss_y(fctx)), |
| 2434 | ); | 2237 | ); |
| 2435 | let map = decode_color_index_map_wh(dec, cdfs, n, chroma_w, chroma_h, on, true); | 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 | PaletteUv { | 2239 | PaletteUv { |
| 2446 | size: n, | 2240 | size: n, |
| 2447 | u_colors, | 2241 | u_colors, |
| @@ -2528,7 +2322,6 @@ pub(super) fn decode_inter_block8( | |||
| 2528 | // (the whole-block buffer would be indexed at the wrong | 2322 | // (the whole-block buffer would be indexed at the wrong |
| 2529 | // stride by the first unit). | 2323 | // stride by the first unit). |
| 2530 | if let Some(buf) = &palette_y_buf { | 2324 | if let Some(buf) = &palette_y_buf { |
| 2531 | - hit!(PALETTE_SPLIT_TX_HITS); | ||
| 2532 | let window: Vec<u16> = (0..tx_px) | 2325 | let window: Vec<u16> = (0..tx_px) |
| 2533 | .flat_map(|i| { | 2326 | .flat_map(|i| { |
| 2534 | let base = (row * MI + i) * SIDE + col * MI; | 2327 | let base = (row * MI + i) * SIDE + col * MI; |
| @@ -2564,10 +2357,6 @@ pub(super) fn decode_inter_block8( | |||
| 2564 | read_plane( | 2357 | read_plane( |
| 2565 | dec, | 2358 | dec, |
| 2566 | cdfs, | 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 | txbset_for(tx_px, reduced_tx_set), | 2360 | txbset_for(tx_px, reduced_tx_set), |
| 2572 | default_scan(tx_px), | 2361 | default_scan(tx_px), |
| 2573 | 0, | 2362 | 0, |
| @@ -2583,7 +2372,6 @@ pub(super) fn decode_inter_block8( | |||
| 2583 | tu_py, | 2372 | tu_py, |
| 2584 | tx_px, | 2373 | tx_px, |
| 2585 | tx_px, | 2374 | tx_px, |
| 2586 | - base_q_idx, | ||
| 2587 | None, | 2375 | None, |
| 2588 | filter_intra, | 2376 | filter_intra, |
| 2589 | Some(tu_skip_ctx), | 2377 | Some(tu_skip_ctx), |
| @@ -2682,14 +2470,6 @@ pub(super) fn decode_inter_block8( | |||
| 2682 | read_plane( | 2470 | read_plane( |
| 2683 | dec, | 2471 | dec, |
| 2684 | cdfs, | 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 | txbset_for(8, reduced_tx_set), | 2473 | txbset_for(8, reduced_tx_set), |
| 2694 | scan8, | 2474 | scan8, |
| 2695 | 0, | 2475 | 0, |
| @@ -2705,7 +2485,6 @@ pub(super) fn decode_inter_block8( | |||
| 2705 | py, | 2485 | py, |
| 2706 | SIDE, | 2486 | SIDE, |
| 2707 | TX8, | 2487 | TX8, |
| 2708 | - base_q_idx, | ||
| 2709 | None, | 2488 | None, |
| 2710 | filter_intra, | 2489 | filter_intra, |
| 2711 | None, | 2490 | None, |
| @@ -2752,7 +2531,6 @@ pub(super) fn decode_inter_block8( | |||
| 2752 | cdfs, | 2531 | cdfs, |
| 2753 | neighbours, | 2532 | neighbours, |
| 2754 | leaf_mi, | 2533 | leaf_mi, |
| 2755 | - (px, py), | ||
| 2756 | (cpx, cpy), | 2534 | (cpx, cpy), |
| 2757 | SIDE, | 2535 | SIDE, |
| 2758 | (chroma_w, chroma_h), | 2536 | (chroma_w, chroma_h), |
| @@ -2760,13 +2538,11 @@ pub(super) fn decode_inter_block8( | |||
| 2760 | (chroma_w, chroma_h), | 2538 | (chroma_w, chroma_h), |
| 2761 | chroma_w, | 2539 | chroma_w, |
| 2762 | reach, | 2540 | reach, |
| 2763 | - (y.width, y.height), | ||
| 2764 | mode, | 2541 | mode, |
| 2765 | uv_predict_mode, | 2542 | uv_predict_mode, |
| 2766 | angle_delta_uv, | 2543 | angle_delta_uv, |
| 2767 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), | 2544 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), |
| 2768 | smooth_neighbor_uv, | 2545 | smooth_neighbor_uv, |
| 2769 | - base_q_idx, | ||
| 2770 | &mut uo, | 2546 | &mut uo, |
| 2771 | &mut vo, | 2547 | &mut vo, |
| 2772 | fctx, | 2548 | fctx, |
| @@ -2782,7 +2558,6 @@ pub(super) fn decode_inter_block8( | |||
| 2782 | Grid::Own(vo) | 2558 | Grid::Own(vo) |
| 2783 | }; | 2559 | }; |
| 2784 | chroma_stamped_per_unit = true; | 2560 | chroma_stamped_per_unit = true; |
| 2785 | - hit!(LLINTRA8_CHROMA_WALK_HITS); | ||
| 2786 | } else { | 2561 | } else { |
| 2787 | if let Some((ub, _)) = &palette_uv_bufs { | 2562 | if let Some((ub, _)) = &palette_uv_bufs { |
| 2788 | set_palette_pred(ub.clone(), fctx); | 2563 | set_palette_pred(ub.clone(), fctx); |
| @@ -2830,7 +2605,6 @@ pub(super) fn decode_inter_block8( | |||
| 2830 | cpy, | 2605 | cpy, |
| 2831 | chroma_w, | 2606 | chroma_w, |
| 2832 | chroma_tx, | 2607 | chroma_tx, |
| 2833 | - base_q_idx, | ||
| 2834 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | 2608 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 2835 | None, | 2609 | None, |
| 2836 | None, | 2610 | None, |
| @@ -2884,7 +2658,6 @@ pub(super) fn decode_inter_block8( | |||
| 2884 | cpy, | 2658 | cpy, |
| 2885 | chroma_w, | 2659 | chroma_w, |
| 2886 | chroma_tx, | 2660 | chroma_tx, |
| 2887 | - base_q_idx, | ||
| 2888 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | 2661 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 2889 | None, | 2662 | None, |
| 2890 | None, | 2663 | None, |
| @@ -2989,18 +2762,6 @@ pub(super) fn decode_inter_block8( | |||
| 2989 | neighbours.above[leaf_mi.1 + cell][0] = state; | 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 | neighbours.fill_skip_grid(leaf_mi, 2, skip); | 2765 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 3005 | neighbours.fill_lf_grid( | 2766 | neighbours.fill_lf_grid( |
| 3006 | leaf_mi, | 2767 | leaf_mi, |
crates/ec-av1/src/decode/inter_ctx.rsmodified+4 -380
| @@ -64,34 +64,13 @@ pub(super) fn resolve_interp_filter( | |||
| 64 | // `h_kind`/`v_kind` argument order, which is why this function returns | 64 | // `h_kind`/`v_kind` argument order, which is why this function returns |
| 65 | // `(h, v, ..)` but reads `dir0` (`v`) before `dir1` (`h`). | 65 | // `(h, v, ..)` but reads `dir0` (`v`) before `dir1` (`h`). |
| 66 | let ctx0 = switchable_interp_ctx(above[0], left[0], 0, is_compound); | 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 | let sym0 = dec.symbol(&mut cdfs.switchable_interp[ctx0]) as u8; | 67 | let sym0 = dec.symbol(&mut cdfs.switchable_interp[ctx0]) as u8; |
| 74 | let sym1 = if enable_dual_filter { | 68 | let sym1 = if enable_dual_filter { |
| 75 | let ctx1 = switchable_interp_ctx(above[1], left[1], 1, is_compound); | 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 | dec.symbol(&mut cdfs.switchable_interp[ctx1]) as u8 | 70 | dec.symbol(&mut cdfs.switchable_interp[ctx1]) as u8 |
| 83 | } else { | 71 | } else { |
| 84 | sym0 | 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 | mc::InterpFilterKind::from_switchable_symbol(sym1 as usize), | 75 | mc::InterpFilterKind::from_switchable_symbol(sym1 as usize), |
| 97 | mc::InterpFilterKind::from_switchable_symbol(sym0 as usize), | 76 | mc::InterpFilterKind::from_switchable_symbol(sym0 as usize), |
| @@ -227,7 +206,6 @@ pub(super) fn read_mv( | |||
| 227 | mv.1.clamp(-MV_LIMIT + 1, MV_LIMIT - 1), | 206 | mv.1.clamp(-MV_LIMIT + 1, MV_LIMIT - 1), |
| 228 | ); | 207 | ); |
| 229 | } | 208 | } |
| 230 | - crate::census::mv(mv.0, mv.1); | ||
| 231 | mv | 209 | mv |
| 232 | } | 210 | } |
| 233 | 211 | ||
| @@ -297,13 +275,6 @@ pub(super) fn read_intrabc_dv( | |||
| 297 | true, | 275 | true, |
| 298 | fctx, | 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 | dv | 278 | dv |
| 308 | } | 279 | } |
| 309 | 280 | ||
| @@ -335,7 +306,6 @@ impl PlaneBuf<'_> { | |||
| 335 | &mut self, | 306 | &mut self, |
| 336 | x: usize, | 307 | x: usize, |
| 337 | y: usize, | 308 | y: usize, |
| 338 | - plane: usize, | ||
| 339 | side: usize, | 309 | side: usize, |
| 340 | w: usize, | 310 | w: usize, |
| 341 | h: usize, | 311 | h: usize, |
| @@ -363,13 +333,6 @@ impl PlaneBuf<'_> { | |||
| 363 | // prediction is byte-identical to the oracle's and whose committed | 333 | // prediction is byte-identical to the oracle's and whose committed |
| 364 | // samples are not can only be a DIFFERENT WRITE -- and this is the | 334 | // samples are not can only be a DIFFERENT WRITE -- and this is the |
| 365 | // only write path with no rung of its own. | 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 | // lane-av1444altref r2: EC_CPRED, the picture-independent twin of the | 336 | // lane-av1444altref r2: EC_CPRED, the picture-independent twin of the |
| 374 | // oracle's rung of the same name (aomdec's | 337 | // oracle's rung of the same name (aomdec's |
| 375 | // `dec_build_inter_predictor`). This is the ONE site every inter | 338 | // `dec_build_inter_predictor`). This is the ONE site every inter |
| @@ -380,33 +343,6 @@ impl PlaneBuf<'_> { | |||
| 380 | // pictures, so a rung line alone is ambiguous, but a geometry whose | 343 | // pictures, so a rung line alone is ambiguous, but a geometry whose |
| 381 | // samples differ by at most 1 is a unique match (any wrong pairing | 344 | // samples differ by at most 1 is a unique match (any wrong pairing |
| 382 | // differs by tens). | 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 | // lane-recoparse: an all-zero residual (60% of the units) is a plain | 346 | // lane-recoparse: an all-zero residual (60% of the units) is a plain |
| 411 | // prediction copy -- the same arithmetic with `r == 0`, without | 347 | // prediction copy -- the same arithmetic with `r == 0`, without |
| 412 | // reading `side * h` zeros out of [`ZERO_RESIDUAL`]. | 348 | // reading `side * h` zeros out of [`ZERO_RESIDUAL`]. |
| @@ -416,9 +352,8 @@ impl PlaneBuf<'_> { | |||
| 416 | let dst = (y + row) * self.width + x; | 352 | let dst = (y + row) * self.width + x; |
| 417 | let pred = &prediction[src..src + w]; | 353 | let pred = &prediction[src..src + w]; |
| 418 | let out = &mut self.data.to_mut()[dst..dst + w]; | 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 | let v = i32::from(p).clamp(0, max) as u16; | 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 | *o = v; | 357 | *o = v; |
| 423 | } | 358 | } |
| 424 | } | 359 | } |
| @@ -431,9 +366,8 @@ impl PlaneBuf<'_> { | |||
| 431 | let pred = &prediction[src..src + w]; | 366 | let pred = &prediction[src..src + w]; |
| 432 | let res = &residual[src..src + w]; | 367 | let res = &residual[src..src + w]; |
| 433 | let out = &mut self.data.to_mut()[dst..dst + w]; | 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 | let v = (i32::from(p) + r).clamp(0, max) as u16; | 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 | *o = v; | 371 | *o = v; |
| 438 | } | 372 | } |
| 439 | } | 373 | } |
| @@ -485,8 +419,6 @@ pub(super) fn read_inter_plane( | |||
| 485 | if plane_idx > 0 && mono(fctx) { | 419 | if plane_idx > 0 && mono(fctx) { |
| 486 | return Ok((Grid::Zero(side * side), TxType::DctDct)); | 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 | let skip_ctx = if plane_idx == 0 { | 422 | let skip_ctx = if plane_idx == 0 { |
| 491 | luma_skip_ctx.unwrap_or(0) | 423 | luma_skip_ctx.unwrap_or(0) |
| 492 | } else { | 424 | } else { |
| @@ -527,12 +459,6 @@ pub(super) fn read_inter_plane( | |||
| 527 | default_tx_type, | 459 | default_tx_type, |
| 528 | None, | 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 | // lane-inter8 r1: a 64-point transform covers the whole 64x64 area but | 462 | // lane-inter8 r1: a 64-point transform covers the whole 64x64 area but |
| 537 | // codes only its top-left 32x32 of frequencies (spec 5.11.40) -- the | 463 | // codes only its top-left 32x32 of frequencies (spec 5.11.40) -- the |
| 538 | // caller hands the 32-point `scan` there, and the coded corner goes into | 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 | cdfs: &mut Cdfs, | 504 | cdfs: &mut Cdfs, |
| 579 | neighbours: &mut Neighbours, | 505 | neighbours: &mut Neighbours, |
| 580 | at_mi: (usize, usize), | 506 | at_mi: (usize, usize), |
| 581 | - (px, py): (usize, usize), | ||
| 582 | (cpx, cpy): (usize, usize), | 507 | (cpx, cpy): (usize, usize), |
| 583 | side: usize, | 508 | side: usize, |
| 584 | (blk_w, blk_h): (usize, usize), | 509 | (blk_w, blk_h): (usize, usize), |
| @@ -586,13 +511,11 @@ pub(super) fn read_intra_chroma_lossless( | |||
| 586 | (reg_w, reg_h): (usize, usize), | 511 | (reg_w, reg_h): (usize, usize), |
| 587 | stride: usize, | 512 | stride: usize, |
| 588 | reach: Reach, | 513 | reach: Reach, |
| 589 | - (frame_w, frame_h): (usize, usize), | ||
| 590 | mode: usize, | 514 | mode: usize, |
| 591 | uv_predict_mode: usize, | 515 | uv_predict_mode: usize, |
| 592 | angle_delta_uv: i32, | 516 | angle_delta_uv: i32, |
| 593 | palette_uv_bufs: Option<(&[u16], &[u16])>, | 517 | palette_uv_bufs: Option<(&[u16], &[u16])>, |
| 594 | smooth_neighbor_uv: bool, | 518 | smooth_neighbor_uv: bool, |
| 595 | - base_q_idx: u8, | ||
| 596 | u_out: &mut Vec<i32>, | 519 | u_out: &mut Vec<i32>, |
| 597 | v_out: &mut Vec<i32>, | 520 | v_out: &mut Vec<i32>, |
| 598 | fctx: &crate::decode::FrameCtx, | 521 | fctx: &crate::decode::FrameCtx, |
| @@ -635,11 +558,6 @@ pub(super) fn read_intra_chroma_lossless( | |||
| 635 | 4 << ss_x(fctx), | 558 | 4 << ss_x(fctx), |
| 636 | 4 << ss_y(fctx), | 559 | 4 << ss_y(fctx), |
| 637 | reach, | 560 | reach, |
| 638 | - px, | ||
| 639 | - py, | ||
| 640 | - frame_w, | ||
| 641 | - frame_h, | ||
| 642 | - fctx, | ||
| 643 | ); | 561 | ); |
| 644 | if let Some((ub, vb)) = palette_uv_bufs { | 562 | if let Some((ub, vb)) = palette_uv_bufs { |
| 645 | let buf = if plane_idx == 1 { ub } else { vb }; | 563 | let buf = if plane_idx == 1 { ub } else { vb }; |
| @@ -663,7 +581,6 @@ pub(super) fn read_intra_chroma_lossless( | |||
| 663 | cpy + oy, | 581 | cpy + oy, |
| 664 | 4, | 582 | 4, |
| 665 | 4, | 583 | 4, |
| 666 | - base_q_idx, | ||
| 667 | None, | 584 | None, |
| 668 | None, | 585 | None, |
| 669 | offset, | 586 | offset, |
| @@ -679,7 +596,6 @@ pub(super) fn read_intra_chroma_lossless( | |||
| 679 | plane_idx, | 596 | plane_idx, |
| 680 | &cu_grid, | 597 | &cu_grid, |
| 681 | ); | 598 | ); |
| 682 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 683 | let dst = mu_units( | 599 | let dst = mu_units( |
| 684 | if plane_idx == 1 { | 600 | if plane_idx == 1 { |
| 685 | &mut *u_out | 601 | &mut *u_out |
| @@ -738,9 +654,6 @@ pub(super) fn mu_chunk_order( | |||
| 738 | let mut order = identity.clone(); | 654 | let mut order = identity.clone(); |
| 739 | order.sort_by_key(|&i| ((leaves[i].0 / 16) * nchunk + (leaves[i].1 / 16), i)); | 655 | order.sort_by_key(|&i| ((leaves[i].0 / 16) * nchunk + (leaves[i].1 / 16), i)); |
| 740 | let changed = order != identity; | 656 | let changed = order != identity; |
| 741 | - if changed { | ||
| 742 | - hit!(MU_CHUNK_ORDER_HITS); | ||
| 743 | - } | ||
| 744 | (order, changed) | 657 | (order, changed) |
| 745 | } | 658 | } |
| 746 | 659 | ||
| @@ -788,10 +701,6 @@ pub(super) fn read_inter_chroma_lossless( | |||
| 788 | // lane-av1h5: a plane block above 64 is the 128-root class, whose chroma | 701 | // lane-av1h5: a plane block above 64 is the 128-root class, whose chroma |
| 789 | // libaom walks one 64x64 mu chunk at a time. Counted so a gate can pin | 702 | // libaom walks one 64x64 mu chunk at a time. Counted so a gate can pin |
| 790 | // the walk/unit totals exactly rather than as a floor on wrong output. | 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 | for plane_idx in 1..3 { | 704 | for plane_idx in 1..3 { |
| 796 | for rr in 0..reg_h / 4 { | 705 | for rr in 0..reg_h / 4 { |
| 797 | for cc in 0..reg_w / 4 { | 706 | for cc in 0..reg_w / 4 { |
| @@ -851,10 +760,6 @@ pub(super) fn read_inter_chroma_lossless( | |||
| 851 | plane_idx, | 760 | plane_idx, |
| 852 | &cu_grid, | 761 | &cu_grid, |
| 853 | ); | 762 | ); |
| 854 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 855 | - if counted_128 { | ||
| 856 | - hit!(MU_CHUNK_WALK_UNITS); | ||
| 857 | - } | ||
| 858 | let dst = mu_units( | 763 | let dst = mu_units( |
| 859 | if plane_idx == 1 { | 764 | if plane_idx == 1 { |
| 860 | &mut *u_out | 765 | &mut *u_out |
| @@ -1018,19 +923,6 @@ pub(super) fn read_single_ref( | |||
| 1018 | if p4 == 1 { LAST2_FRAME } else { LAST_FRAME } | 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 | ref_frame | 926 | ref_frame |
| 1035 | } | 927 | } |
| 1036 | 928 | ||
| @@ -1070,9 +962,8 @@ pub(crate) struct RefPix<'p> { | |||
| 1070 | #[derive(Clone)] | 962 | #[derive(Clone)] |
| 1071 | pub(crate) struct SharedRefs { | 963 | pub(crate) struct SharedRefs { |
| 1072 | pub(crate) dims: [Option<(usize, usize)>; 8], | 964 | pub(crate) dims: [Option<(usize, usize)>; 8], |
| 1073 | - pub(crate) wait: std::sync::Arc< | 965 | + pub(crate) wait: |
| 1074 | - dyn Fn() -> Result<[Option<std::sync::Arc<Picture>>; 8]> + Send + Sync, | 966 | + std::sync::Arc<dyn Fn() -> Result<[Option<std::sync::Arc<Picture>>; 8]> + Send + Sync>, |
| 1075 | - >, | ||
| 1076 | } | 967 | } |
| 1077 | 968 | ||
| 1078 | /// Where a [`RefPix`] gets its pictures: already in hand, or behind a wait | 969 | /// Where a [`RefPix`] gets its pictures: already in hand, or behind a wait |
| @@ -1207,12 +1098,6 @@ impl<'p> RefPix<'p> { | |||
| 1207 | /// (lane-defer8). | 1098 | /// (lane-defer8). |
| 1208 | pub(super) fn ref_dims(ref_frame: i8, refpix: &RefPix<'_>) -> Result<(usize, usize)> { | 1099 | pub(super) fn ref_dims(ref_frame: i8, refpix: &RefPix<'_>) -> Result<(usize, usize)> { |
| 1209 | refpix.dims(ref_frame).ok_or_else(|| { | 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 | // lane-hdrlossless: libaom errors on the same stream | 1101 | // lane-hdrlossless: libaom errors on the same stream |
| 1217 | // (`decodeframe.c:5027`: `if (cm->ref_frame_map[ref] == NULL) | 1102 | // (`decodeframe.c:5027`: `if (cm->ref_frame_map[ref] == NULL) |
| 1218 | // aom_internal_error(... AOM_CODEC_CORRUPT_FRAME, "Inter frame | 1103 | // aom_internal_error(... AOM_CODEC_CORRUPT_FRAME, "Inter frame |
| @@ -1406,9 +1291,6 @@ pub(super) fn overlappable_above( | |||
| 1406 | if let Some(info) = nb | 1291 | if let Some(info) = nb |
| 1407 | && info.is_inter | 1292 | && info.is_inter |
| 1408 | { | 1293 | { |
| 1409 | - if src != col { | ||
| 1410 | - hit!(OBMC_PAIR_FILTER_HITS); | ||
| 1411 | - } | ||
| 1412 | // lane-t900 r14: libaom passes `AOMMIN(xd->width, mi_step)` | 1294 | // lane-t900 r14: libaom passes `AOMMIN(xd->width, mi_step)` |
| 1413 | // as `op_mi_size` -- the block's OWN width, never the | 1295 | // as `op_mi_size` -- the block's OWN width, never the |
| 1414 | // frame-edge clamp `end_col` carries. Clamping here shrank the | 1296 | // frame-edge clamp `end_col` carries. Clamping here shrank the |
| @@ -1473,9 +1355,6 @@ pub(super) fn overlappable_left( | |||
| 1473 | if let Some(info) = nb | 1355 | if let Some(info) = nb |
| 1474 | && info.is_inter | 1356 | && info.is_inter |
| 1475 | { | 1357 | { |
| 1476 | - if src != row { | ||
| 1477 | - hit!(OBMC_PAIR_FILTER_HITS); | ||
| 1478 | - } | ||
| 1479 | // lane-t900 r14: `AOMMIN(xd->height, mi_step)` -- see | 1358 | // lane-t900 r14: `AOMMIN(xd->height, mi_step)` -- see |
| 1480 | // `overlappable_above`. | 1359 | // `overlappable_above`. |
| 1481 | out.push(( | 1360 | out.push(( |
| @@ -1509,23 +1388,6 @@ pub(crate) fn has_overlappable_neighbour( | |||
| 1509 | || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, 1).is_empty() | 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 | /// `av1_findSamples` (`mvref_common.c`), full port: the up to | 1391 | /// `av1_findSamples` (`mvref_common.c`), full port: the up to |
| 1530 | /// `LEAST_SQUARES_SAMPLES_MAX` (8) above/left/top-left/top-right neighbour | 1392 | /// `LEAST_SQUARES_SAMPLES_MAX` (8) above/left/top-left/top-right neighbour |
| 1531 | /// samples (`record_samples`) that share this block's own single reference | 1393 | /// samples (`record_samples`) that share this block's own single reference |
| @@ -1557,16 +1419,8 @@ pub(crate) fn find_samples( | |||
| 1557 | // motion_mode alphabet over the 2-symbol obmc one. | 1419 | // motion_mode alphabet over the 2-symbol obmc one. |
| 1558 | // lane-alloc: the `format!` (and the map lookup's `String` clone) ran on | 1420 | // lane-alloc: the `format!` (and the map lookup's `String` clone) ran on |
| 1559 | // every warp block; the flag itself is a process constant. | 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 | let single_ref_match = |info: &MiInfo| { | 1422 | let single_ref_match = |info: &MiInfo| { |
| 1563 | let m = info.ref_frame == ref_frame && info.ref_frame1 == NO_REF1; | 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 | m | 1424 | m |
| 1571 | }; | 1425 | }; |
| 1572 | let mut do_tl = true; | 1426 | let mut do_tl = true; |
| @@ -1682,9 +1536,6 @@ pub(crate) fn find_samples( | |||
| 1682 | // libaom reads the 2-symbol `obmc_cdf` (class | 1536 | // libaom reads the 2-symbol `obmc_cdf` (class |
| 1683 | // wrong-alphabet-same-value). | 1537 | // wrong-alphabet-same-value). |
| 1684 | let tr_reach = crate::mvstack::has_top_right(mi_row, mi_col, bw4, bh4, fctx); | 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 | if do_tr && tr_reach { | 1539 | if do_tr && tr_reach { |
| 1689 | let tr_col = mi_col + bw4; | 1540 | let tr_col = mi_col + bw4; |
| 1690 | if mi_row > 0 | 1541 | if mi_row > 0 |
| @@ -1785,53 +1636,12 @@ pub(super) fn neighbour_filter( | |||
| 1785 | "an OBMC neighbour whose switchable interp filter was never recorded", | 1636 | "an OBMC neighbour whose switchable interp filter was never recorded", |
| 1786 | )); | 1637 | )); |
| 1787 | } | 1638 | } |
| 1788 | - hit!(OBMC_FILTER_BAND_READS); | ||
| 1789 | Ok(( | 1639 | Ok(( |
| 1790 | mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize), | 1640 | mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize), |
| 1791 | mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize), | 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 | /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh | 1645 | /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh |
| 1836 | /// against its own `mv`/reference/filter (libaom `av1_build_inter_predictor` | 1646 | /// against its own `mv`/reference/filter (libaom `av1_build_inter_predictor` |
| 1837 | /// under `av1_setup_build_prediction_by_{above,left}_pred`). | 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 | /// `av1_build_obmc_inter_prediction` (libaom `reconinter.c`): re-predicts | 1873 | /// `av1_build_obmc_inter_prediction` (libaom `reconinter.c`): re-predicts |
| 2129 | /// the overlap strip against each bordering above/left inter neighbour's own | 1874 | /// the overlap strip against each bordering above/left inter neighbour's own |
| 2130 | /// mv/ref/filter and blends it into this block's just-built single-reference | 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 | // lane-inter4 r4: r3 refused OBMC on a 16x8/8x16 leaf; re-measured | 1946 | // lane-inter4 r4: r3 refused OBMC on a 16x8/8x16 leaf; re-measured |
| 2202 | // byte-exact against an instrumented aomdec, the refusal is gone and the | 1947 | // byte-exact against an instrumented aomdec, the refusal is gone and the |
| 2203 | // counter below is what the gate's `--enable-obmc=1` arm reads. | 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 | // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own | 1949 | // lane-sb128c r1: libaom caps the overlap strip at a 64x64 block's own |
| 2208 | // half (`reconinter.c` 860/899), inert below 128. | 1950 | // half (`reconinter.c` 860/899), inert below 128. |
| 2209 | let overlap_above = write_h.min(64) / 2; | 1951 | let overlap_above = write_h.min(64) / 2; |
| @@ -2233,27 +1975,8 @@ pub(crate) fn obmc_plan( | |||
| 2233 | // `av1_setup_build_prediction_by_above_pred` reads | 1975 | // `av1_setup_build_prediction_by_above_pred` reads |
| 2234 | // `above_mbmi->interp_filters`). | 1976 | // `above_mbmi->interp_filters`). |
| 2235 | let above_syms = above_filter.get(mi_col + src4).copied().unwrap_or([3; 2]); | 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 | let (h_kind, v_kind) = neighbour_filter(interp_fixed, above_syms)?; | 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 | let nb_dims = ref_dims(nb.ref_frame, refpix)?; | 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 | above.push(ObmcNb { | 1980 | above.push(ObmcNb { |
| 2258 | off4, | 1981 | off4, |
| 2259 | span4, | 1982 | span4, |
| @@ -2269,27 +1992,8 @@ pub(crate) fn obmc_plan( | |||
| 2269 | overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) | 1992 | overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) |
| 2270 | { | 1993 | { |
| 2271 | let left_syms = left_filter.get(mi_row + src4).copied().unwrap_or([3; 2]); | 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 | let (h_kind, v_kind) = neighbour_filter(interp_fixed, left_syms)?; | 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 | let nb_dims = ref_dims(nb.ref_frame, refpix)?; | 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 | left.push(ObmcNb { | 1997 | left.push(ObmcNb { |
| 2294 | off4, | 1998 | off4, |
| 2295 | span4, | 1999 | span4, |
| @@ -2405,41 +2109,6 @@ pub(crate) fn obmc_run( | |||
| 2405 | // block, reused by every neighbour of the above and left passes. | 2109 | // block, reused by every neighbour of the above and left passes. |
| 2406 | let (mut tmp_y, mut tmp_u, mut tmp_v) = (Vec::new(), Vec::new(), Vec::new()); | 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 | for nb in &plan.above { | 2112 | for nb in &plan.above { |
| 2444 | let Some((ny, nu, nv)) = ref_planes_deferred(nb.ref_frame, refpix) else { | 2113 | let Some((ny, nu, nv)) = ref_planes_deferred(nb.ref_frame, refpix) else { |
| 2445 | return; | 2114 | return; |
| @@ -2547,16 +2216,6 @@ pub(crate) fn obmc_run( | |||
| 2547 | &mut tmp_u, | 2216 | &mut tmp_u, |
| 2548 | fctx, | 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 | let ch = cbh.min((write_h >> ss_y(fctx)) - coy); | 2219 | let ch = cbh.min((write_h >> ss_y(fctx)) - coy); |
| 2561 | obmc_blend_h(pred_u, chroma_stride, 0, coy, cbw, ch, &tmp_u); | 2220 | obmc_blend_h(pred_u, chroma_stride, 0, coy, cbw, ch, &tmp_u); |
| 2562 | obmc_neighbour_pred( | 2221 | obmc_neighbour_pred( |
| @@ -2575,13 +2234,6 @@ pub(crate) fn obmc_run( | |||
| 2575 | ); | 2234 | ); |
| 2576 | obmc_blend_h(pred_v, chroma_stride, 0, coy, cbw, ch, &tmp_v); | 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 | /// `is_any_masked_compound_used` (libaom `reconinter.h`), specialised to | 2239 | /// `is_any_masked_compound_used` (libaom `reconinter.h`), specialised to |
| @@ -2714,18 +2366,6 @@ pub(super) fn read_comp_mode( | |||
| 2714 | ) -> bool { | 2366 | ) -> bool { |
| 2715 | let ctx = reference_mode_ctx(above, left); | 2367 | let ctx = reference_mode_ctx(above, left); |
| 2716 | let compound = dec.symbol(&mut cdfs.comp_mode[ctx]) == 1; | 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 | compound | 2369 | compound |
| 2730 | } | 2370 | } |
| 2731 | 2371 | ||
| @@ -2767,7 +2407,6 @@ pub(super) fn read_compound_ref_frames( | |||
| 2767 | let type_ctx = comp_reference_type_ctx(above, left); | 2407 | let type_ctx = comp_reference_type_ctx(above, left); |
| 2768 | let unidir = dec.symbol(&mut cdfs.comp_ref_type[type_ctx]) == 0; | 2408 | let unidir = dec.symbol(&mut cdfs.comp_ref_type[type_ctx]) == 0; |
| 2769 | if unidir { | 2409 | if unidir { |
| 2770 | - hit!(UNI_COMP_HITS); | ||
| 2771 | // uni_comp_ref (p0): forward vs. backward -- av1_get_pred_context_- | 2410 | // uni_comp_ref (p0): forward vs. backward -- av1_get_pred_context_- |
| 2772 | // uni_comp_ref_p is single_ref_p1's own forward/backward vote. | 2411 | // uni_comp_ref_p is single_ref_p1's own forward/backward vote. |
| 2773 | let bit = dec.symbol(&mut cdfs.uni_comp_ref[single_ref_p1_ctx(a, a1, l, l1)][0]); | 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 | ref_mv_ctx: usize, | 2468 | ref_mv_ctx: usize, |
| 2830 | ) -> u8 { | 2469 | ) -> u8 { |
| 2831 | let ctx = cdf::COMPOUND_MODE_CTX_MAP[ref_mv_ctx >> 1][new_mv_ctx.min(4)]; | 2470 | let ctx = cdf::COMPOUND_MODE_CTX_MAP[ref_mv_ctx >> 1][new_mv_ctx.min(4)]; |
| 2832 | - hit!(COMPOUND_MODE_HITS); | ||
| 2833 | dec.symbol(&mut cdfs.inter_compound_mode[ctx]) as u8 | 2471 | dec.symbol(&mut cdfs.inter_compound_mode[ctx]) as u8 |
| 2834 | } | 2472 | } |
| 2835 | 2473 | ||
| @@ -3031,17 +2669,3 @@ thread_local! { | |||
| 3031 | /// chroma plane -- the non-vacuity bar for the assertion at that site. | 2669 | /// chroma plane -- the non-vacuity bar for the assertion at that site. |
| 3032 | pub(crate) static CHROMA_RECT_BLOCK_TX_FALLBACK_MULTI: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 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 | .filter(|_| write_w.min(write_h) == 4 && write_w.max(write_h) == 16) | 132 | .filter(|_| write_w.min(write_h) == 4 && write_w.max(write_h) == 16) |
| 133 | .map(|s| (s.horz, s.has_chroma)); | 133 | .map(|s| (s.horz, s.has_chroma)); |
| 134 | if write_w.min(write_h) < 8 && strip16.is_none() { | 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 | return Err(unsupported( | 135 | return Err(unsupported( |
| 155 | "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)", | 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 | return Ok(None); | 197 | return Ok(None); |
| 217 | } | 198 | } |
| 218 | - crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | ||
| 219 | let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]); | 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 | if mode >= 13 { | 200 | if mode >= 13 { |
| 227 | return Err(unsupported( | 201 | return Err(unsupported( |
| 228 | "an intra mode this decoder does not code (round 2)", | 202 | "an intra mode this decoder does not code (round 2)", |
| @@ -241,9 +215,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 241 | } else { | 215 | } else { |
| 242 | 0 | 216 | 0 |
| 243 | }; | 217 | }; |
| 244 | - if angle_delta_y != 0 { | ||
| 245 | - hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS); | ||
| 246 | - } | ||
| 247 | // The delta'd angle decides whether the intra edge filter runs at | 218 | // The delta'd angle decides whether the intra edge filter runs at |
| 248 | // all, so this block needs the same luma edge-filter-type neighbour | 219 | // all, so this block needs the same luma edge-filter-type neighbour |
| 249 | // check a key-frame block does (`get_intra_edge_filter_type`, spec | 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 | // (libaom `decodemv.c:933`). | 234 | // (libaom `decodemv.c:933`). |
| 264 | let has_chroma = !mono(fctx); | 235 | let has_chroma = !mono(fctx); |
| 265 | let cfl_allowed = has_chroma && cfl_allowed_px(write_w, write_h, fctx); | 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 | let uv_mode = if !has_chroma { | 237 | let uv_mode = if !has_chroma { |
| 270 | DC_PRED | 238 | DC_PRED |
| 271 | } else if cfl_allowed { | 239 | } else if cfl_allowed { |
| 272 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 273 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 240 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 274 | } else { | 241 | } else { |
| 275 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 276 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 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 | let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { | 244 | let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { |
| 282 | Some(read_cfl_alphas(dec, cdfs)) | 245 | Some(read_cfl_alphas(dec, cdfs)) |
| 283 | } else { | 246 | } else { |
| @@ -288,15 +251,10 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 288 | // -- `uv_mode` (13) already falls outside `V_PRED..=D67_PRED` so the | 251 | // -- `uv_mode` (13) already falls outside `V_PRED..=D67_PRED` so the |
| 289 | // `else` branch below is exact for it either way. | 252 | // `else` branch below is exact for it either way. |
| 290 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { | 253 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 291 | - hit!(DIRECTIONAL_UV_HITS); | ||
| 292 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | 254 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 293 | } else { | 255 | } else { |
| 294 | 0 | 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 | uv_predict_mode = if uv_mode == UV_CFL_PRED { | 258 | uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 301 | DC_PRED | 259 | DC_PRED |
| 302 | } else { | 260 | } else { |
| @@ -336,24 +294,9 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 336 | let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]); | 294 | let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]); |
| 337 | palette_y_pending = Some((n, read_palette_colors_y(dec, n, &palette_cache, fctx))); | 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 | let use_palette_uv = has_chroma | 297 | let use_palette_uv = has_chroma |
| 347 | && uv_mode == DC_PRED | 298 | && uv_mode == DC_PRED |
| 348 | && dec.symbol(&mut cdfs.palette_uv_mode[usize::from(use_palette_y)]) != 0; | 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 | if use_palette_uv { | 300 | if use_palette_uv { |
| 358 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); | 301 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); |
| 359 | let (u_colors, v_colors) = read_palette_colors_uv(dec, n, &palette_uv_cache, fctx); | 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 | && let Some(class) = filter_intra_size_class_rect(write_w, write_h) | 322 | && let Some(class) = filter_intra_size_class_rect(write_w, write_h) |
| 380 | && dec.symbol(&mut cdfs.filter_intra[class]) != 0 | 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 | filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); | 325 | filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); |
| 385 | } | 326 | } |
| 386 | // `av1_visit_palette`: the two colour-index maps, Y then the shared | 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 | palette_onscreen(rmi, cmi, write_w, write_h, fctx), | 336 | palette_onscreen(rmi, cmi, write_w, write_h, fctx), |
| 396 | false, | 337 | false, |
| 397 | ); | 338 | ); |
| 398 | - hit!(PALETTE_HITS); | ||
| 399 | - hit!(INTRA_IN_INTER_PALETTE_Y_HITS); | ||
| 400 | PaletteY { | 339 | PaletteY { |
| 401 | size: n, | 340 | size: n, |
| 402 | colors, | 341 | colors, |
| @@ -419,8 +358,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 419 | (ss_x(fctx), ss_y(fctx)), | 358 | (ss_x(fctx), ss_y(fctx)), |
| 420 | ); | 359 | ); |
| 421 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true); | 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 | PaletteUv { | 361 | PaletteUv { |
| 425 | size: n, | 362 | size: n, |
| 426 | u_colors, | 363 | u_colors, |
| @@ -516,7 +453,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 516 | // (the whole-block buffer would be indexed at the wrong | 453 | // (the whole-block buffer would be indexed at the wrong |
| 517 | // stride by the first unit). | 454 | // stride by the first unit). |
| 518 | if let Some(buf) = &palette_y_buf { | 455 | if let Some(buf) = &palette_y_buf { |
| 519 | - hit!(PALETTE_SPLIT_TX_HITS); | ||
| 520 | let window: Vec<u16> = (0..tx_px) | 456 | let window: Vec<u16> = (0..tx_px) |
| 521 | .flat_map(|i| { | 457 | .flat_map(|i| { |
| 522 | let base = (row * MI + i) * side + col * MI; | 458 | let base = (row * MI + i) * side + col * MI; |
| @@ -553,10 +489,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 553 | dec, | 489 | dec, |
| 554 | cdfs, | 490 | cdfs, |
| 555 | txbset_for(tx_px, reduced), | 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 | default_scan(tx_px.min(32)), | 492 | default_scan(tx_px.min(32)), |
| 561 | 0, | 493 | 0, |
| 562 | neighbours.around_mi(tu_mi, tx_px)[0], | 494 | neighbours.around_mi(tu_mi, tx_px)[0], |
| @@ -571,7 +503,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 571 | tu_py, | 503 | tu_py, |
| 572 | tx_px, | 504 | tx_px, |
| 573 | tx_px.min(32), | 505 | tx_px.min(32), |
| 574 | - base_q_idx, | ||
| 575 | None, | 506 | None, |
| 576 | filter_intra, | 507 | filter_intra, |
| 577 | Some(tu_skip_ctx), | 508 | Some(tu_skip_ctx), |
| @@ -588,7 +519,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 588 | continue; | 519 | continue; |
| 589 | } | 520 | } |
| 590 | let (cr, cc) = chunk; | 521 | let (cr, cc) = chunk; |
| 591 | - hit!(INTRA_128_IN_INTER_MU_CHROMA_HITS); | ||
| 592 | // The unit's CHROMA size, its LUMA footprint, the | 522 | // The unit's CHROMA size, its LUMA footprint, the |
| 593 | // CHUNK's chroma extent and the unit's ORIGIN inside the | 523 | // CHUNK's chroma extent and the unit's ORIGIN inside the |
| 594 | // chunk are four different quantities; this arm had the | 524 | // chunk are four different quantities; this arm had the |
| @@ -641,32 +571,18 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 641 | cdfs, | 571 | cdfs, |
| 642 | neighbours, | 572 | neighbours, |
| 643 | at_mi, | 573 | at_mi, |
| 644 | - (px, py), | ||
| 645 | (cpx, cpy), | 574 | (cpx, cpy), |
| 646 | side, | 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 | (chroma_stride, chroma_buf_h), | 576 | (chroma_stride, chroma_buf_h), |
| 659 | (cc * chunk_chroma_w, cr * chunk_chroma_h), | 577 | (cc * chunk_chroma_w, cr * chunk_chroma_h), |
| 660 | (chunk_chroma_w, chunk_chroma_h), | 578 | (chunk_chroma_w, chunk_chroma_h), |
| 661 | chroma_stride, | 579 | chroma_stride, |
| 662 | reach, | 580 | reach, |
| 663 | - (y.width, y.height), | ||
| 664 | mode, | 581 | mode, |
| 665 | uv_predict_mode, | 582 | uv_predict_mode, |
| 666 | angle_delta_uv, | 583 | angle_delta_uv, |
| 667 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), | 584 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), |
| 668 | smooth_neighbor_uv, | 585 | smooth_neighbor_uv, |
| 669 | - base_q_idx, | ||
| 670 | &mut u_units, | 586 | &mut u_units, |
| 671 | &mut v_units, | 587 | &mut v_units, |
| 672 | fctx, | 588 | fctx, |
| @@ -718,11 +634,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 718 | cr * chunk_luma + ur * unit_luma_h, | 634 | cr * chunk_luma + ur * unit_luma_h, |
| 719 | unit_luma_w, | 635 | unit_luma_w, |
| 720 | reach, | 636 | reach, |
| 721 | - px, | ||
| 722 | - py, | ||
| 723 | - y.width, | ||
| 724 | - y.height, | ||
| 725 | - fctx, | ||
| 726 | ); | 637 | ); |
| 727 | let cu_grid = if skip { | 638 | let cu_grid = if skip { |
| 728 | push_intra( | 639 | push_intra( |
| @@ -762,15 +673,8 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 762 | cu_y, | 673 | cu_y, |
| 763 | cu_tx, | 674 | cu_tx, |
| 764 | cu_tx, | 675 | cu_tx, |
| 765 | - base_q_idx, | ||
| 766 | - // CfL is refused above 32x32 | ||
| 767 | - // (`is_cfl_allowed`), so never here. | ||
| 768 | None, | 676 | None, |
| 769 | None, | 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 | Some(3), | 678 | Some(3), |
| 775 | smooth_neighbor_uv, | 679 | smooth_neighbor_uv, |
| 776 | fctx, | 680 | fctx, |
| @@ -785,7 +689,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 785 | plane_idx, | 689 | plane_idx, |
| 786 | &cu_grid, | 690 | &cu_grid, |
| 787 | ); | 691 | ); |
| 788 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 789 | // lane-dpm1: the two INTER mu-chunk sites set | 692 | // lane-dpm1: the two INTER mu-chunk sites set |
| 790 | // this and this INTRA-in-inter one did not, so | 693 | // this and this INTRA-in-inter one did not, so |
| 791 | // the whole-block chroma record below re-stamped | 694 | // the whole-block chroma record below re-stamped |
| @@ -794,9 +697,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 794 | // libaom never selects (class | 697 | // libaom never selects (class |
| 795 | // `override-slot-on-one-arm`). | 698 | // `override-slot-on-one-arm`). |
| 796 | mu_chroma = true; | 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 | let dst = mu_units( | 700 | let dst = mu_units( |
| 801 | if plane_idx == 1 { | 701 | if plane_idx == 1 { |
| 802 | &mut u_units | 702 | &mut u_units |
| @@ -846,7 +746,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 846 | } else { | 746 | } else { |
| 847 | Grid::Own(std::mem::take(&mut v_units)) | 747 | Grid::Own(std::mem::take(&mut v_units)) |
| 848 | }; | 748 | }; |
| 849 | - hit!(INTRA_128_IN_INTER_HITS); | ||
| 850 | } else if skip { | 749 | } else if skip { |
| 851 | if !split_luma { | 750 | if !split_luma { |
| 852 | if let Some(buf) = &palette_y_buf { | 751 | if let Some(buf) = &palette_y_buf { |
| @@ -945,7 +844,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 945 | py, | 844 | py, |
| 946 | side, | 845 | side, |
| 947 | luma_tx, | 846 | luma_tx, |
| 948 | - base_q_idx, | ||
| 949 | None, | 847 | None, |
| 950 | filter_intra, | 848 | filter_intra, |
| 951 | None, | 849 | None, |
| @@ -966,26 +864,18 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 966 | cdfs, | 864 | cdfs, |
| 967 | neighbours, | 865 | neighbours, |
| 968 | at_mi, | 866 | at_mi, |
| 969 | - (px, py), | ||
| 970 | (cpx, cpy), | 867 | (cpx, cpy), |
| 971 | side, | 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 | (chroma_stride, chroma_buf_h), | 869 | (chroma_stride, chroma_buf_h), |
| 978 | (0, 0), | 870 | (0, 0), |
| 979 | (chroma_stride, chroma_buf_h), | 871 | (chroma_stride, chroma_buf_h), |
| 980 | chroma_stride, | 872 | chroma_stride, |
| 981 | reach, | 873 | reach, |
| 982 | - (y.width, y.height), | ||
| 983 | mode, | 874 | mode, |
| 984 | uv_predict_mode, | 875 | uv_predict_mode, |
| 985 | angle_delta_uv, | 876 | angle_delta_uv, |
| 986 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), | 877 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), |
| 987 | smooth_neighbor_uv, | 878 | smooth_neighbor_uv, |
| 988 | - base_q_idx, | ||
| 989 | &mut uo, | 879 | &mut uo, |
| 990 | &mut vo, | 880 | &mut vo, |
| 991 | fctx, | 881 | fctx, |
| @@ -1035,11 +925,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 1035 | cu_row * chroma_tx, | 925 | cu_row * chroma_tx, |
| 1036 | chroma_tx, | 926 | chroma_tx, |
| 1037 | reach, | 927 | reach, |
| 1038 | - px, | ||
| 1039 | - py, | ||
| 1040 | - y.width, | ||
| 1041 | - y.height, | ||
| 1042 | - fctx, | ||
| 1043 | ); | 928 | ); |
| 1044 | let cu_grid = read_plane( | 929 | let cu_grid = read_plane( |
| 1045 | dec, | 930 | dec, |
| @@ -1059,9 +944,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 1059 | cpy + cu_row * chroma_tx, | 944 | cpy + cu_row * chroma_tx, |
| 1060 | chroma_tx, | 945 | chroma_tx, |
| 1061 | chroma_tx, | 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 | None, | 947 | None, |
| 1066 | None, | 948 | None, |
| 1067 | Some(3), | 949 | Some(3), |
| @@ -1072,7 +954,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 1072 | // coefficient context. | 954 | // coefficient context. |
| 1073 | neighbours | 955 | neighbours |
| 1074 | .record_mi_chroma(cu_mi, chroma_tx, chroma_tx, plane_idx, &cu_grid); | 956 | .record_mi_chroma(cu_mi, chroma_tx, chroma_tx, plane_idx, &cu_grid); |
| 1075 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 1076 | let acc = if plane_idx == 1 { | 957 | let acc = if plane_idx == 1 { |
| 1077 | &mut u_acc | 958 | &mut u_acc |
| 1078 | } else { | 959 | } else { |
| @@ -1123,7 +1004,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 1123 | cpy, | 1004 | cpy, |
| 1124 | chroma_side, | 1005 | chroma_side, |
| 1125 | chroma_tx, | 1006 | chroma_tx, |
| 1126 | - base_q_idx, | ||
| 1127 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | 1007 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1128 | None, | 1008 | None, |
| 1129 | None, | 1009 | None, |
| @@ -1161,11 +1041,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 1161 | luma_span_x, | 1041 | luma_span_x, |
| 1162 | luma_span_y, | 1042 | luma_span_y, |
| 1163 | reach, | 1043 | reach, |
| 1164 | - px, | ||
| 1165 | - py, | ||
| 1166 | - y.width, | ||
| 1167 | - y.height, | ||
| 1168 | - fctx, | ||
| 1169 | ); | 1044 | ); |
| 1170 | // The 4:2:2 plane block is `(chroma_w, chroma_h)` -- | 1045 | // The 4:2:2 plane block is `(chroma_w, chroma_h)` -- |
| 1171 | // 32x64 -- but codes TWO stacked TX_32X32 units, so | 1046 | // 32x64 -- but codes TWO stacked TX_32X32 units, so |
| @@ -1181,7 +1056,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 1181 | fctx, | 1056 | fctx, |
| 1182 | ); | 1057 | ); |
| 1183 | } | 1058 | } |
| 1184 | - hit!(PALETTE_422_UNIT_WINDOW_HITS); | ||
| 1185 | let cu_grid = read_plane( | 1059 | let cu_grid = read_plane( |
| 1186 | dec, | 1060 | dec, |
| 1187 | cdfs, | 1061 | cdfs, |
| @@ -1200,18 +1074,12 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 1200 | cpy + cu_row * cu_h, | 1074 | cpy + cu_row * cu_h, |
| 1201 | cu_w, | 1075 | cu_w, |
| 1202 | cu_w, | 1076 | cu_w, |
| 1203 | - base_q_idx, | ||
| 1204 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | 1077 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1205 | None, | 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 | Some(3), | 1079 | Some(3), |
| 1210 | smooth_neighbor_uv, | 1080 | smooth_neighbor_uv, |
| 1211 | fctx, | 1081 | fctx, |
| 1212 | )?; | 1082 | )?; |
| 1213 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 1214 | - hit!(CHROMA422_SQUARE_HITS); | ||
| 1215 | // Immediately, so the next unit of this plane reads this | 1083 | // Immediately, so the next unit of this plane reads this |
| 1216 | // one's coefficient context; the whole-block record below | 1084 | // one's coefficient context; the whole-block record below |
| 1217 | // re-stamps the block over these and the tail's | 1085 | // re-stamps the block over these and the tail's |
| @@ -1280,7 +1148,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 1280 | cpy, | 1148 | cpy, |
| 1281 | chroma_side, | 1149 | chroma_side, |
| 1282 | chroma_tx, | 1150 | chroma_tx, |
| 1283 | - base_q_idx, | ||
| 1284 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | 1151 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1285 | None, | 1152 | None, |
| 1286 | None, | 1153 | None, |
| @@ -1309,11 +1176,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 1309 | luma_span_x, | 1176 | luma_span_x, |
| 1310 | luma_span_y, | 1177 | luma_span_y, |
| 1311 | reach, | 1178 | reach, |
| 1312 | - px, | ||
| 1313 | - py, | ||
| 1314 | - y.width, | ||
| 1315 | - y.height, | ||
| 1316 | - fctx, | ||
| 1317 | ); | 1179 | ); |
| 1318 | // The V twin of the U arm's per-unit window above. | 1180 | // The V twin of the U arm's per-unit window above. |
| 1319 | if let Some((_, vb)) = &palette_uv_bufs { | 1181 | if let Some((_, vb)) = &palette_uv_bufs { |
| @@ -1322,7 +1184,6 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 1322 | fctx, | 1184 | fctx, |
| 1323 | ); | 1185 | ); |
| 1324 | } | 1186 | } |
| 1325 | - hit!(PALETTE_422_UNIT_WINDOW_HITS); | ||
| 1326 | let cu_grid = read_plane( | 1187 | let cu_grid = read_plane( |
| 1327 | dec, | 1188 | dec, |
| 1328 | cdfs, | 1189 | cdfs, |
| @@ -1341,15 +1202,12 @@ pub(super) fn decode_inter_block_intra_arm( | |||
| 1341 | cpy + cu_row * cu_h, | 1202 | cpy + cu_row * cu_h, |
| 1342 | cu_w, | 1203 | cu_w, |
| 1343 | cu_w, | 1204 | cu_w, |
| 1344 | - base_q_idx, | ||
| 1345 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | 1205 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1346 | None, | 1206 | None, |
| 1347 | Some(3), | 1207 | Some(3), |
| 1348 | smooth_neighbor_uv, | 1208 | smooth_neighbor_uv, |
| 1349 | fctx, | 1209 | fctx, |
| 1350 | )?; | 1210 | )?; |
| 1351 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 1352 | - hit!(CHROMA422_SQUARE_HITS); | ||
| 1353 | neighbours.record_mi_chroma(cu_mi, luma_span_x, luma_span_y, 2, &cu_grid); | 1211 | neighbours.record_mi_chroma(cu_mi, luma_span_x, luma_span_y, 2, &cu_grid); |
| 1354 | for rr in 0..cu_h { | 1212 | for rr in 0..cu_h { |
| 1355 | let start = (cu_row * cu_h + rr) * chroma_side; | 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 | // The RECT twin [`read_block_tx_size_rect`] has published on this arm | 82 | // The RECT twin [`read_block_tx_size_rect`] has published on this arm |
| 83 | // since lane-av1lm444loss; only the square arm had the hole. | 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 | // The gate's non-vacuity arm, on the DECISION, sampled BEFORE the | 84 | // The gate's non-vacuity arm, on the DECISION, sampled BEFORE the |
| 90 | // write: this publish CHANGES at least one of the above-band cells it | 85 | // write: this publish CHANGES at least one of the above-band cells it |
| 91 | // covers -- the cell did not already hold `pub_above`, so a later | 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 | // first-touch case. The count is still a decision (no reader, no | 99 | // first-touch case. The count is still a decision (no reader, no |
| 105 | // intra-only frame, no unchanged column), so the gate keeps its teeth; | 100 | // intra-only frame, no unchanged column), so the gate keeps its teeth; |
| 106 | // only the doc's stronger reading was wrong. | 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 | set_txfm_ctxs(n, at_mi, 4, side_mi, side_mi, skip && is_inter); | 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 | return Ok((4, Some(leaves))); | 103 | return Ok((4, Some(leaves))); |
| 114 | } | 104 | } |
| 115 | if !fctx.tx_select_inter.with(std::cell::Cell::get) { | 105 | if !fctx.tx_select_inter.with(std::cell::Cell::get) { |
| @@ -194,13 +184,6 @@ pub(super) fn read_block_tx_size( | |||
| 194 | leaves.push((row, col, tx, tx)); | 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 | return Ok((tx, Some(leaves))); | 187 | return Ok((tx, Some(leaves))); |
| 205 | } | 188 | } |
| 206 | Ok((tx, None)) | 189 | Ok((tx, None)) |
| @@ -261,6 +244,7 @@ pub(crate) fn rect_inter_residual_supported(w: usize, h: usize) -> bool { | |||
| 261 | // these triples are what decides whether those refusals can fire at all. Bit | 244 | // these triples are what decides whether those refusals can fire at all. Bit |
| 262 | // 31 is "a triple this table does not list", which is what makes the gate a | 245 | // 31 is "a triple this table does not list", which is what makes the gate a |
| 263 | // census rather than a restatement of its own table. | 246 | // census rather than a restatement of its own table. |
| 247 | +#[cfg(test)] | ||
| 264 | pub(crate) const INTER_BLOCK_SHAPES: [(usize, usize, usize); 18] = [ | 248 | pub(crate) const INTER_BLOCK_SHAPES: [(usize, usize, usize); 18] = [ |
| 265 | (16, 16, 16), | 249 | (16, 16, 16), |
| 266 | (32, 32, 32), | 250 | (32, 32, 32), |
| @@ -393,9 +377,6 @@ pub(super) fn rect_inter_chroma_set(w: usize, h: usize) -> Result<TxbSet> { | |||
| 393 | // (`av1_ss_size_lookup[BLOCK_8X32][1][0]`, common_data.c:38) and | 377 | // (`av1_ss_size_lookup[BLOCK_8X32][1][0]`, common_data.c:38) and |
| 394 | // for which no TX_4X32 exists -- that chroma is coded as a | 378 | // for which no TX_4X32 exists -- that chroma is coded as a |
| 395 | // TX_8X32-chunked merge, not a 4-px unit. | 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 | return Err(unsupported( | 380 | return Err(unsupported( |
| 400 | "a rectangular inter chroma transform unit whose shape has no coefficient table set here", | 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 | // the shape domain and, on its own, named NONE of the strings that domain | 489 | // the shape domain and, on its own, named NONE of the strings that domain |
| 509 | // was about -- under a real function boundary rather than a window that | 490 | // was about -- under a real function boundary rather than a window that |
| 510 | // ran into the next test, all three rows read as unanchored. | 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 | let fctx = &crate::decode::FrameCtx::new(); | 492 | let fctx = &crate::decode::FrameCtx::new(); |
| 522 | let corner_scan = |w: usize, h: usize| { | 493 | let corner_scan = |w: usize, h: usize| { |
| 523 | let (cw, ch) = (w.min(32), h.min(32)); | 494 | let (cw, ch) = (w.min(32), h.min(32)); |
| @@ -684,7 +655,6 @@ pub(super) fn read_block_tx_size_rect( | |||
| 684 | // transform, and `set_txfm_ctxs` records exactly what | 655 | // transform, and `set_txfm_ctxs` records exactly what |
| 685 | // `txfm_partition_update` would for that same unit. | 656 | // `txfm_partition_update` would for that same unit. |
| 686 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); | 657 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); |
| 687 | - hit!(RECT_INTER_TU_HITS); | ||
| 688 | return Ok(None); | 658 | return Ok(None); |
| 689 | } | 659 | } |
| 690 | // lane-av1oddheightfork2: `above_px` / `left_px` are the two | 660 | // lane-av1oddheightfork2: `above_px` / `left_px` are the two |
| @@ -696,24 +666,10 @@ pub(super) fn read_block_tx_size_rect( | |||
| 696 | let (above_px, left_px) = (n.above_txfm[at_mi.1], n.left_txfm[at_mi.0]); | 666 | let (above_px, left_px) = (n.above_txfm[at_mi.1], n.left_txfm[at_mi.0]); |
| 697 | let ctx = txfm_partition_ctx_rect(above_px, left_px, bw.max(bh), tx_w, tx_h); | 667 | let ctx = txfm_partition_ctx_rect(above_px, left_px, bw.max(bh), tx_w, tx_h); |
| 698 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; | 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 | if !split { | 669 | if !split { |
| 711 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); | 670 | txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); |
| 712 | - hit!(RECT_INTER_TU_HITS); | ||
| 713 | return Ok(None); | 671 | return Ok(None); |
| 714 | } | 672 | } |
| 715 | - hit!(TXFM_SPLIT_HITS); | ||
| 716 | - hit!(RECT_INTER_TXSPLIT_HITS); | ||
| 717 | // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays | 673 | // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays |
| 718 | // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`, | 674 | // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`, |
| 719 | // `[TX_16X64] == TX_16X32` -- so the recursion below is the general | 675 | // `[TX_16X64] == TX_16X32` -- so the recursion below is the general |
| @@ -825,7 +781,6 @@ pub(super) fn read_inter_rect_chroma( | |||
| 825 | // replay (the c8 re-stamp, at the strip's own tiling). | 781 | // replay (the c8 re-stamp, at the strip's own tiling). |
| 826 | let mut units: Vec<((usize, usize), usize, Grid, usize, usize)> = Vec::new(); | 782 | let mut units: Vec<((usize, usize), usize, Grid, usize, usize)> = Vec::new(); |
| 827 | if multi { | 783 | if multi { |
| 828 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 829 | assembled = [ | 784 | assembled = [ |
| 830 | vec![0i32; chroma_side * assembled_h], | 785 | vec![0i32; chroma_side * assembled_h], |
| 831 | vec![0i32; chroma_side * assembled_h], | 786 | vec![0i32; chroma_side * assembled_h], |
| @@ -862,35 +817,8 @@ pub(super) fn read_inter_rect_chroma( | |||
| 862 | let cu_pred = src.offset(cu_row * uh * chroma_side + cu_col * uw); | 817 | let cu_pred = src.offset(cu_row * uh * chroma_side + cu_col * uw); |
| 863 | let inherit_tx_type = | 818 | let inherit_tx_type = |
| 864 | if let Some(t) = covering_leaf_tx_type(leaf_tx_types, unit_rel_mi) { | 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 | Some(t) | 820 | Some(t) |
| 870 | } else { | 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 | debug_assert!( | 822 | debug_assert!( |
| 895 | leaf_tx_types.is_empty(), | 823 | leaf_tx_types.is_empty(), |
| 896 | "lane-av1ichromatx: a multi-unit rect chroma plane fell back to the \ | 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 | fctx, | 849 | fctx, |
| 922 | )? | 850 | )? |
| 923 | .0; | 851 | .0; |
| 924 | - if invalid_ss_plane { | ||
| 925 | - hit!(CHROMA422_CHUNK_HITS); | ||
| 926 | - } | ||
| 927 | if multi { | 852 | if multi { |
| 928 | // Immediately, so the next unit of this block reads this | 853 | // Immediately, so the next unit of this block reads this |
| 929 | // one's coefficient context (libaom updates the chroma | 854 | // one's coefficient context (libaom updates the chroma |
| @@ -985,8 +910,6 @@ pub(super) fn read_inter_plane_rect( | |||
| 985 | if plane_idx > 0 && mono(fctx) { | 910 | if plane_idx > 0 && mono(fctx) { |
| 986 | return Ok((Grid::Zero(w * h), TxType::DctDct)); | 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 | let skip_ctx = if plane_idx == 0 { | 913 | let skip_ctx = if plane_idx == 0 { |
| 991 | // `get_txb_ctx_general`: 0 only when this unit IS the whole plane | 914 | // `get_txb_ctx_general`: 0 only when this unit IS the whole plane |
| 992 | // block; a var-tx leaf passes its own neighbour-table context. | 915 | // block; a var-tx leaf passes its own neighbour-table context. |
| @@ -1030,18 +953,6 @@ pub(super) fn read_inter_plane_rect( | |||
| 1030 | // because `av1_nz_map_ctx_offset` is indexed by the real, un-adjusted | 953 | // because `av1_nz_map_ctx_offset` is indexed by the real, un-adjusted |
| 1031 | // rectangular shape (lane-sbpart r8). | 954 | // rectangular shape (lane-sbpart r8). |
| 1032 | let (cw, ch) = (w.min(32), h.min(32)); | 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 | let (corner, tx_type) = if (cw, ch) == (32, 32) { | 956 | let (corner, tx_type) = if (cw, ch) == (32, 32) { |
| 1046 | let scan32 = default_scan(TX32); | 957 | let scan32 = default_scan(TX32); |
| 1047 | read_coeffs( | 958 | read_coeffs( |
| @@ -1063,16 +974,10 @@ pub(super) fn read_inter_plane_rect( | |||
| 1063 | skip_ctx, | 974 | skip_ctx, |
| 1064 | dc_sign_ctx(around.2), | 975 | dc_sign_ctx(around.2), |
| 1065 | default_tx_type, | 976 | default_tx_type, |
| 1066 | - plane_idx, | ||
| 1067 | )? | 977 | )? |
| 1068 | }; | 978 | }; |
| 1069 | let grid = extend_corner(corner, cw, ch, w, h); | 979 | let grid = extend_corner(corner, cw, ch, w, h); |
| 1070 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx); | 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 | // `reconstruct_mc_rect` reads both buffers at the square prediction | 981 | // `reconstruct_mc_rect` reads both buffers at the square prediction |
| 1077 | // stride, so the dense `w x h` residual is re-laid at that stride | 982 | // stride, so the dense `w x h` residual is re-laid at that stride |
| 1078 | // (`TxParams::stride`) after the inverse transform. | 983 | // (`TxParams::stride`) after the inverse transform. |
| @@ -1716,6 +1621,5 @@ pub(super) fn edge_params_body( | |||
| 1716 | [4, 8, 14, 14, 14][dim] | 1621 | [4, 8, 14, 14, 14][dim] |
| 1717 | }; | 1622 | }; |
| 1718 | let level = if cur_level != 0 { cur_level } else { pv_level }; | 1623 | let level = if cur_level != 0 { cur_level } else { pv_level }; |
| 1719 | - hit!(DEBLOCK_HITS); | ||
| 1720 | Some((len, level)) | 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 | .map(|(picture, _)| picture) | 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 | /// [`decode_key_frame_tile`], threading a cross-frame CDF forward (spec | 100 | /// [`decode_key_frame_tile`], threading a cross-frame CDF forward (spec |
| 117 | /// 7.20's `load_cdfs`): `initial_cdfs` is the caller's forwarded state (from | 101 | /// 7.20's `load_cdfs`): `initial_cdfs` is the caller's forwarded state (from |
| 118 | /// a prior frame's saved reference slot) when set, or the spec 8.4 defaults | 102 | /// a prior frame's saved reference slot) when set, or the spec 8.4 defaults |
| @@ -252,38 +236,6 @@ thread_local! { | |||
| 252 | pub(crate) static SUB8_LOSSLESS_NO_VARTX: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 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 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. | 239 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. |
| 288 | #[allow(clippy::too_many_arguments)] | 240 | #[allow(clippy::too_many_arguments)] |
| 289 | pub(super) fn read_sb128_root( | 241 | pub(super) fn read_sb128_root( |
| @@ -328,26 +280,14 @@ pub(super) fn read_sb128_root( | |||
| 328 | let ctx128 = neighbours.partition_ctx(at128, 128); | 280 | let ctx128 = neighbours.partition_ctx(at128, 128); |
| 329 | let (has_cols128, has_rows128) = (mi_c128 + SB_MI < mi_cols, mi_r128 + SB_MI < mi_rows); | 281 | let (has_cols128, has_rows128) = (mi_c128 + SB_MI < mi_cols, mi_r128 + SB_MI < mi_rows); |
| 330 | let part128 = if has_cols128 && has_rows128 { | 282 | let part128 = if has_cols128 && has_rows128 { |
| 331 | - hit!(PART128_SYMBOLS); | ||
| 332 | let p = dec.symbol(&mut cdfs.partition_w128[ctx128]); | 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 | p | 284 | p |
| 337 | } else { | 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 | match (has_cols128, has_rows128) { | 286 | match (has_cols128, has_rows128) { |
| 346 | (true, false) => { | 287 | (true, false) => { |
| 347 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 { | 288 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 { |
| 348 | PARTITION_SPLIT | 289 | PARTITION_SPLIT |
| 349 | } else { | 290 | } else { |
| 350 | - hit!(PART128_EDGE_HORZ_HITS); | ||
| 351 | PARTITION_HORZ | 291 | PARTITION_HORZ |
| 352 | } | 292 | } |
| 353 | } | 293 | } |
| @@ -355,13 +295,11 @@ pub(super) fn read_sb128_root( | |||
| 355 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 { | 295 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 { |
| 356 | PARTITION_SPLIT | 296 | PARTITION_SPLIT |
| 357 | } else { | 297 | } else { |
| 358 | - hit!(PART128_EDGE_VERT_HITS); | ||
| 359 | PARTITION_VERT | 298 | PARTITION_VERT |
| 360 | } | 299 | } |
| 361 | } | 300 | } |
| 362 | _ => { | 301 | _ => { |
| 363 | PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() - 1)); | 302 | PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() - 1)); |
| 364 | - bump_edge_both_cut(3); | ||
| 365 | PARTITION_SPLIT | 303 | PARTITION_SPLIT |
| 366 | } | 304 | } |
| 367 | } | 305 | } |
| @@ -383,22 +321,10 @@ pub(super) fn read_sb128_root( | |||
| 383 | // decoding untouched. | 321 | // decoding untouched. |
| 384 | refuse_invalid_subsize((128, 128), part128, fctx)?; | 322 | refuse_invalid_subsize((128, 128), part128, fctx)?; |
| 385 | match part128 { | 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 | // lane-sb128c r9: the four AB shapes at the 128 root -- one | 324 | // lane-sb128c r9: the four AB shapes at the 128 root -- one |
| 391 | // 128x64/64x128 half plus two 64x64 quadrants, decoded by both tile | 325 | // 128x64/64x128 half plus two 64x64 quadrants, decoded by both tile |
| 392 | // paths below in libaom `decode_partition`'s own visit order. | 326 | // paths below in libaom `decode_partition`'s own visit order. |
| 393 | - p if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&p) => { | 327 | + 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 | - } | ||
| 402 | _ => { | 328 | _ => { |
| 403 | return Err(unsupported( | 329 | return Err(unsupported( |
| 404 | "a 128x128 superblock partition value outside the 8-symbol alphabet", | 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 | let (width, height) = (cols32 as usize * BLOCK, rows32 as usize * BLOCK); | 410 | let (width, height) = (cols32 as usize * BLOCK, rows32 as usize * BLOCK); |
| 485 | 411 | ||
| 486 | let mut y = PlaneBuf { | 412 | let mut y = PlaneBuf { |
| 487 | - data: std::borrow::Cow::Owned(fresh_plane( | 413 | + data: std::borrow::Cow::Owned(fresh_plane(width * height)), |
| 488 | - width * height, | ||
| 489 | - true_width, | ||
| 490 | - true_height, | ||
| 491 | - width, | ||
| 492 | - height, | ||
| 493 | - )), | ||
| 494 | width, | 414 | width, |
| 495 | height, | 415 | height, |
| 496 | true_width, | 416 | true_width, |
| @@ -502,10 +422,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 502 | plane: 0, | 422 | plane: 0, |
| 503 | }; | 423 | }; |
| 504 | let (cw, ch) = (width >> ss_x(fctx), height >> ss_y(fctx)); | 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 | let (ctw, cth) = (true_width >> ss_x(fctx), true_height >> ss_y(fctx)); | 425 | let (ctw, cth) = (true_width >> ss_x(fctx), true_height >> ss_y(fctx)); |
| 507 | let mut u = PlaneBuf { | 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 | width: cw, | 428 | width: cw, |
| 510 | height: ch, | 429 | height: ch, |
| 511 | true_width: ctw, | 430 | true_width: ctw, |
| @@ -517,7 +436,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 517 | plane: 1, | 436 | plane: 1, |
| 518 | }; | 437 | }; |
| 519 | let mut v = PlaneBuf { | 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 | width: cw, | 440 | width: cw, |
| 522 | height: ch, | 441 | height: ch, |
| 523 | true_width: ctw, | 442 | true_width: ctw, |
| @@ -603,18 +522,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 603 | fctx.current_q_idx.with(|c| c.set(i32::from(base_q_idx))); | 522 | fctx.current_q_idx.with(|c| c.set(i32::from(base_q_idx))); |
| 604 | fctx.quant_deltas.with(|c| c.set(deltas)); | 523 | fctx.quant_deltas.with(|c| c.set(deltas)); |
| 605 | fctx.current_delta_lf.with(|c| c.set([0; 4])); | 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 | let mut dec = SymbolDecoder::new(tile_bytes); | 525 | let mut dec = SymbolDecoder::new(tile_bytes); |
| 614 | // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets | 526 | // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets |
| 615 | // it codes every symbol against the tables it started with. | 527 | // it codes every symbol against the tables it started with. |
| 616 | dec.set_cdf_update(!cdf_update_disabled(fctx)); | 528 | dec.set_cdf_update(!cdf_update_disabled(fctx)); |
| 617 | - crate::census::register_cdfs(&cdfs); | ||
| 618 | neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize, fctx); | 529 | neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize, fctx); |
| 619 | y.set_tile_origin( | 530 | y.set_tile_origin( |
| 620 | mi_col0 as usize * 4, | 531 | mi_col0 as usize * 4, |
| @@ -634,7 +545,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 634 | ((mi_col1 as usize * 4) >> ss_x(fctx)).min(v.width), | 545 | ((mi_col1 as usize * 4) >> ss_x(fctx)).min(v.width), |
| 635 | ((mi_row1 as usize * 4) >> ss_y(fctx)).min(v.height), | 546 | ((mi_row1 as usize * 4) >> ss_y(fctx)).min(v.height), |
| 636 | ); | 547 | ); |
| 637 | - hit!(TILE_HITS); | ||
| 638 | 548 | ||
| 639 | // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` -- | 549 | // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` -- |
| 640 | // its one block covers all four 64x64 quadrants, so the remaining three | 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 | // mirroring [`crate::tile::sb_coeff_key_frame_tile`]'s own | 875 | // mirroring [`crate::tile::sb_coeff_key_frame_tile`]'s own |
| 966 | // three-way write exactly. | 876 | // three-way write exactly. |
| 967 | let part = if has_cols && has_rows { | 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 | let p = dec.symbol(&mut cdfs.partition_w64[ctx]); | 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 | p | 879 | p |
| 991 | } else { | 880 | } else { |
| 992 | // lane-hgkf r1 (class `parsed-then-discarded`, same finding as | 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 | // the first block of that row. | 887 | // the first block of that row. |
| 999 | match (has_cols, has_rows) { | 888 | match (has_cols, has_rows) { |
| 1000 | (true, false) => { | 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 | let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)); | 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 | if b == 1 { | 891 | if b == 1 { |
| 1012 | PARTITION_SPLIT | 892 | PARTITION_SPLIT |
| 1013 | } else { | 893 | } else { |
| @@ -1015,26 +895,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1015 | } | 895 | } |
| 1016 | } | 896 | } |
| 1017 | (false, true) => { | 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 | let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)); | 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 | if b == 1 { | 899 | if b == 1 { |
| 1029 | PARTITION_SPLIT | 900 | PARTITION_SPLIT |
| 1030 | } else { | 901 | } else { |
| 1031 | PARTITION_VERT | 902 | PARTITION_VERT |
| 1032 | } | 903 | } |
| 1033 | } | 904 | } |
| 1034 | - _ => { | 905 | + _ => PARTITION_SPLIT, |
| 1035 | - bump_edge_both_cut(2); | ||
| 1036 | - PARTITION_SPLIT | ||
| 1037 | - } | ||
| 1038 | } | 906 | } |
| 1039 | }; | 907 | }; |
| 1040 | // lane-av1unwritten r5: the partition symbol is RESOLVED (a full CDF read or | 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 | has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows), | 956 | has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows), |
| 1089 | ); | 957 | ); |
| 1090 | let part32 = if has_cols32 && has_rows32 { | 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 | let p = dec.symbol(&mut cdfs.partition_w32[ctx32]); | 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 | p | 960 | p |
| 1119 | } else { | 961 | } else { |
| 1120 | // lane-hgkf r1: the 32-level frame-edge bit is the | 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 | // superblock level above). | 964 | // superblock level above). |
| 1123 | match (has_cols32, has_rows32) { | 965 | match (has_cols32, has_rows32) { |
| 1124 | (true, false) => { | 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 | let b = dec.symbol_fixed(&gather( | 967 | let b = dec.symbol_fixed(&gather( |
| 1133 | &cdfs.partition_w32[ctx32], | 968 | &cdfs.partition_w32[ctx32], |
| 1134 | VERT_ALIKE, | 969 | VERT_ALIKE, |
| 1135 | )); | 970 | )); |
| 1136 | - bump_edge32(b.min(1)); | ||
| 1137 | - bump_edge_part(2 + b.min(1)); | ||
| 1138 | if b == 1 { | 971 | if b == 1 { |
| 1139 | PARTITION_SPLIT | 972 | PARTITION_SPLIT |
| 1140 | } else { | 973 | } else { |
| @@ -1142,29 +975,17 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1142 | } | 975 | } |
| 1143 | } | 976 | } |
| 1144 | (false, true) => { | 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 | let b = dec.symbol_fixed(&gather( | 978 | let b = dec.symbol_fixed(&gather( |
| 1153 | &cdfs.partition_w32[ctx32], | 979 | &cdfs.partition_w32[ctx32], |
| 1154 | HORZ_ALIKE, | 980 | HORZ_ALIKE, |
| 1155 | )); | 981 | )); |
| 1156 | - bump_edge32(b.min(1)); | ||
| 1157 | - bump_edge_part(2 + b.min(1)); | ||
| 1158 | if b == 1 { | 982 | if b == 1 { |
| 1159 | PARTITION_SPLIT | 983 | PARTITION_SPLIT |
| 1160 | } else { | 984 | } else { |
| 1161 | PARTITION_VERT | 985 | PARTITION_VERT |
| 1162 | } | 986 | } |
| 1163 | } | 987 | } |
| 1164 | - _ => { | 988 | + _ => PARTITION_SPLIT, |
| 1165 | - bump_edge_both_cut(1); | ||
| 1166 | - PARTITION_SPLIT | ||
| 1167 | - } | ||
| 1168 | } | 989 | } |
| 1169 | }; | 990 | }; |
| 1170 | // lane-av1unwritten r4: VERT on a 32x32 block selects | 991 | // lane-av1unwritten r4: VERT on a 32x32 block selects |
| @@ -1221,16 +1042,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1221 | let at16 = (sr, sc); | 1042 | let at16 = (sr, sc); |
| 1222 | let ctx16 = neighbours.partition_ctx(at16, SUB); | 1043 | let ctx16 = neighbours.partition_ctx(at16, SUB); |
| 1223 | if has_cols16 && has_rows16 { | 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 | let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]); | 1045 | let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]); |
| 1235 | // lane-av1unwritten r6: the partition symbol is RESOLVED and about to be | 1046 | // lane-av1unwritten r6: the partition symbol is RESOLVED and about to be |
| 1236 | // dispatched. `partition_subsize_dims` is libaom's `get_partition_subsize` | 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 | // keep decoding because the helper is exact, not a heuristic. key-frame 16x16 level. | 1051 | // keep decoding because the helper is exact, not a heuristic. key-frame 16x16 level. |
| 1241 | refuse_invalid_subsize((16, 16), part16, fctx)?; | 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 | if part16 == PARTITION_HORZ || part16 == PARTITION_VERT | 1054 | if part16 == PARTITION_HORZ || part16 == PARTITION_VERT |
| 1259 | { | 1055 | { |
| 1260 | let (bw, bh) = if part16 == PARTITION_HORZ { | 1056 | let (bw, bh) = if part16 == PARTITION_HORZ { |
| @@ -1326,11 +1122,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1326 | // rectangle: libaom switches those squares onto `has_tr_vert_*`/ | 1122 | // rectangle: libaom switches those squares onto `has_tr_vert_*`/ |
| 1327 | // `has_bl_vert_*` (`reconintra.c` `get_has_tr_table`), which is | 1123 | // `has_bl_vert_*` (`reconintra.c` `get_has_tr_table`), which is |
| 1328 | // `Reach::vert_ab_partition()` (lane-part32 r5, cherry-picked here). | 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 | let _vert_guard = if part16 == PARTITION_VERT_A | 1125 | let _vert_guard = if part16 == PARTITION_VERT_A |
| 1335 | || part16 == PARTITION_VERT_B | 1126 | || part16 == PARTITION_VERT_B |
| 1336 | { | 1127 | { |
| @@ -1353,7 +1144,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1353 | &mut y, | 1144 | &mut y, |
| 1354 | &mut u, | 1145 | &mut u, |
| 1355 | &mut v, | 1146 | &mut v, |
| 1356 | - base_q_idx, | ||
| 1357 | enable_filter_intra, | 1147 | enable_filter_intra, |
| 1358 | allow_screen_content_tools, | 1148 | allow_screen_content_tools, |
| 1359 | allow_intrabc, | 1149 | allow_intrabc, |
| @@ -1449,7 +1239,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1449 | continue; | 1239 | continue; |
| 1450 | } | 1240 | } |
| 1451 | if part16 == PARTITION_HORZ { | 1241 | if part16 == PARTITION_HORZ { |
| 1452 | - hit!(HORZ_VERT_INTRA_HITS); | ||
| 1453 | let (mi_row0, mi_col0) = | 1242 | let (mi_row0, mi_col0) = |
| 1454 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | 1243 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 1455 | let top = (mi_row0 as usize, mi_col0 as usize); | 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 | continue; | 1286 | continue; |
| 1498 | } | 1287 | } |
| 1499 | if part16 == PARTITION_VERT { | 1288 | if part16 == PARTITION_VERT { |
| 1500 | - hit!(HORZ_VERT_INTRA_HITS); | ||
| 1501 | let (mi_row0, mi_col0) = | 1289 | let (mi_row0, mi_col0) = |
| 1502 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | 1290 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 1503 | let left = (mi_row0 as usize, mi_col0 as usize); | 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 | // lane-av1unwritten r6: arm census -- | 1339 | // lane-av1unwritten r6: arm census -- |
| 1552 | // which partition values reach here. | 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 | decode_rect4_16( | 1341 | decode_rect4_16( |
| 1563 | &mut dec, | 1342 | &mut dec, |
| 1564 | &mut cdfs, | 1343 | &mut cdfs, |
| @@ -1631,16 +1410,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1631 | } | 1410 | } |
| 1632 | let leaf_ctx = | 1411 | let leaf_ctx = |
| 1633 | neighbours.partition_ctx_mi(leaf_mi, 8); | 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 | let part8 = | 1413 | let part8 = |
| 1645 | dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); | 1414 | dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| 1646 | // lane-av1unwritten r9: the | 1415 | // lane-av1unwritten r9: the |
| @@ -1649,17 +1418,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1649 | // r9 made sensitive to a second | 1418 | // r9 made sensitive to a second |
| 1650 | // site at an already covered level. | 1419 | // site at an already covered level. |
| 1651 | refuse_invalid_subsize((8, 8), part8, fctx)?; | 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 | if part8 == PARTITION_HORZ | 1421 | if part8 == PARTITION_HORZ |
| 1664 | || part8 == PARTITION_VERT | 1422 | || part8 == PARTITION_VERT |
| 1665 | { | 1423 | { |
| @@ -1693,7 +1451,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1693 | &mut y, | 1451 | &mut y, |
| 1694 | &mut u, | 1452 | &mut u, |
| 1695 | &mut v, | 1453 | &mut v, |
| 1696 | - base_q_idx, | ||
| 1697 | enable_filter_intra, | 1454 | enable_filter_intra, |
| 1698 | allow_screen_content_tools, | 1455 | allow_screen_content_tools, |
| 1699 | allow_intrabc, | 1456 | allow_intrabc, |
| @@ -1714,7 +1471,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1714 | &mut y, | 1471 | &mut y, |
| 1715 | &mut u, | 1472 | &mut u, |
| 1716 | &mut v, | 1473 | &mut v, |
| 1717 | - base_q_idx, | ||
| 1718 | enable_filter_intra, | 1474 | enable_filter_intra, |
| 1719 | allow_intrabc, | 1475 | allow_intrabc, |
| 1720 | reduced_tx_set, | 1476 | reduced_tx_set, |
| @@ -1734,7 +1490,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1734 | &mut y, | 1490 | &mut y, |
| 1735 | &mut u, | 1491 | &mut u, |
| 1736 | &mut v, | 1492 | &mut v, |
| 1737 | - base_q_idx, | ||
| 1738 | enable_filter_intra, | 1493 | enable_filter_intra, |
| 1739 | allow_intrabc, | 1494 | allow_intrabc, |
| 1740 | tx_select, | 1495 | tx_select, |
| @@ -1783,7 +1538,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1783 | // quadrants get no neighbour or tx-grid | 1538 | // quadrants get no neighbour or tx-grid |
| 1784 | // write. | 1539 | // write. |
| 1785 | if !has_cols16 && !has_rows16 { | 1540 | if !has_cols16 && !has_rows16 { |
| 1786 | - bump_edge_both_cut(0); | ||
| 1787 | } else { | 1541 | } else { |
| 1788 | // lane-golomb r1 (class | 1542 | // lane-golomb r1 (class |
| 1789 | // `parsed-then-discarded`): the gathered | 1543 | // `parsed-then-discarded`): the gathered |
| @@ -1793,13 +1547,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1793 | // This path can only walk the four SPLIT | 1547 | // This path can only walk the four SPLIT |
| 1794 | // leaves, so a 0 refuses by name instead | 1548 | // leaves, so a 0 refuses by name instead |
| 1795 | // of desyncing. | 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 | let edge_split = if has_cols16 { | 1550 | let edge_split = if has_cols16 { |
| 1804 | dec.symbol_fixed(&gather( | 1551 | dec.symbol_fixed(&gather( |
| 1805 | &cdfs.partition_w16[ctx16], | 1552 | &cdfs.partition_w16[ctx16], |
| @@ -1814,21 +1561,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1814 | // lane-hgkf r1: slots 2/3 of | 1561 | // lane-hgkf r1: slots 2/3 of |
| 1815 | // [`EDGE_PART_HITS`], the gate's proof the | 1562 | // [`EDGE_PART_HITS`], the gate's proof the |
| 1816 | // non-SPLIT edge arm actually decoded. | 1563 | // non-SPLIT edge arm actually decoded. |
| 1817 | - bump_edge_part(if edge_split == 1 { 3 } else { 2 }); | ||
| 1818 | if edge_split == 0 { | 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 | // lane-av1subsizesweep: this arm is the ONE | 1565 | // lane-av1subsizesweep: this arm is the ONE |
| 1833 | // frame-edge partition read in the file that | 1566 | // frame-edge partition read in the file that |
| 1834 | // dispatches on its own symbol instead of | 1567 | // dispatches on its own symbol instead of |
| @@ -1867,17 +1600,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1867 | refuse_invalid_subsize((16, 16), edge_part, fctx)?; | 1600 | refuse_invalid_subsize((16, 16), edge_part, fctx)?; |
| 1868 | // lane-av1unwritten r6: arm census -- which | 1601 | // lane-av1unwritten r6: arm census -- which |
| 1869 | // partition value reaches here. | 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 | let (mi_row0, mi_col0) = | 1603 | let (mi_row0, mi_col0) = |
| 1882 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | 1604 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 1883 | let (bw, bh) = | 1605 | let (bw, bh) = |
| @@ -1934,7 +1656,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1934 | neighbours.left_mode[sr] = right; | 1656 | neighbours.left_mode[sr] = right; |
| 1935 | } | 1657 | } |
| 1936 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); | 1658 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); |
| 1937 | - let pre8 = dec.debug_state().0; | ||
| 1938 | let part8 = | 1659 | let part8 = |
| 1939 | dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); | 1660 | dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| 1940 | // lane-av1unwritten r9: key-frame 8x8 | 1661 | // lane-av1unwritten r9: key-frame 8x8 |
| @@ -1948,11 +1669,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1948 | // than live pixels, and it is guarded | 1669 | // than live pixels, and it is guarded |
| 1949 | // anyway. | 1670 | // anyway. |
| 1950 | refuse_invalid_subsize((8, 8), part8, fctx)?; | 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 | let leaf_mode = if part8 == PARTITION_NONE { | 1672 | let leaf_mode = if part8 == PARTITION_NONE { |
| 1957 | decode_leaf8( | 1673 | decode_leaf8( |
| 1958 | &mut dec, | 1674 | &mut dec, |
| @@ -1965,7 +1681,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1965 | &mut y, | 1681 | &mut y, |
| 1966 | &mut u, | 1682 | &mut u, |
| 1967 | &mut v, | 1683 | &mut v, |
| 1968 | - base_q_idx, | ||
| 1969 | enable_filter_intra, | 1684 | enable_filter_intra, |
| 1970 | allow_screen_content_tools, | 1685 | allow_screen_content_tools, |
| 1971 | allow_intrabc, | 1686 | allow_intrabc, |
| @@ -1986,7 +1701,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 1986 | &mut y, | 1701 | &mut y, |
| 1987 | &mut u, | 1702 | &mut u, |
| 1988 | &mut v, | 1703 | &mut v, |
| 1989 | - base_q_idx, | ||
| 1990 | enable_filter_intra, | 1704 | enable_filter_intra, |
| 1991 | allow_intrabc, | 1705 | allow_intrabc, |
| 1992 | reduced_tx_set, | 1706 | reduced_tx_set, |
| @@ -2006,7 +1720,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2006 | &mut y, | 1720 | &mut y, |
| 2007 | &mut u, | 1721 | &mut u, |
| 2008 | &mut v, | 1722 | &mut v, |
| 2009 | - base_q_idx, | ||
| 2010 | enable_filter_intra, | 1723 | enable_filter_intra, |
| 2011 | allow_intrabc, | 1724 | allow_intrabc, |
| 2012 | tx_select, | 1725 | tx_select, |
| @@ -2059,9 +1772,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2059 | reduced_tx_set, | 1772 | reduced_tx_set, |
| 2060 | fctx, | 1773 | fctx, |
| 2061 | )?; | 1774 | )?; |
| 2062 | - if !has_rows32 { | ||
| 2063 | - bump_edge32(2); | ||
| 2064 | - } | ||
| 2065 | // lane-hgkf r1: at the frame edge only the first half of the strip is | 1775 | // lane-hgkf r1: at the frame edge only the first half of the strip is |
| 2066 | // coded (libaom `decode_partition` guards the second half with the same | 1776 | // coded (libaom `decode_partition` guards the second half with the same |
| 2067 | // test that made this partition non-square). | 1777 | // test that made this partition non-square). |
| @@ -2105,9 +1815,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2105 | reduced_tx_set, | 1815 | reduced_tx_set, |
| 2106 | fctx, | 1816 | fctx, |
| 2107 | )?; | 1817 | )?; |
| 2108 | - if !has_cols32 { | ||
| 2109 | - bump_edge32(3); | ||
| 2110 | - } | ||
| 2111 | // lane-hgkf r1: at the frame edge only the first half of the strip is | 1818 | // lane-hgkf r1: at the frame edge only the first half of the strip is |
| 2112 | // coded (libaom `decode_partition` guards the second half with the same | 1819 | // coded (libaom `decode_partition` guards the second half with the same |
| 2113 | // test that made this partition non-square). | 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 | PARTITION_HORZ_A => { | 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 | decode_block( | 1842 | decode_block( |
| 2141 | &mut dec, | 1843 | &mut dec, |
| 2142 | &mut cdfs, | 1844 | &mut cdfs, |
| @@ -2210,11 +1912,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2210 | )?; | 1912 | )?; |
| 2211 | } | 1913 | } |
| 2212 | PARTITION_HORZ_B => { | 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 | decode_block_rect( | 1915 | decode_block_rect( |
| 2219 | &mut dec, | 1916 | &mut dec, |
| 2220 | &mut cdfs, | 1917 | &mut cdfs, |
| @@ -2288,10 +1985,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2288 | )?; | 1985 | )?; |
| 2289 | } | 1986 | } |
| 2290 | PARTITION_VERT_A => { | 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 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); | 1988 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 2296 | decode_block( | 1989 | decode_block( |
| 2297 | &mut dec, | 1990 | &mut dec, |
| @@ -2366,11 +2059,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2366 | )?; | 2059 | )?; |
| 2367 | } | 2060 | } |
| 2368 | PARTITION_VERT_B => { | 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 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); | 2062 | let _vert_ab = crate::encode::Reach::vert_ab_partition(); |
| 2375 | decode_block_rect( | 2063 | decode_block_rect( |
| 2376 | &mut dec, | 2064 | &mut dec, |
| @@ -2513,9 +2201,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2513 | reduced_tx_set, | 2201 | reduced_tx_set, |
| 2514 | fctx, | 2202 | fctx, |
| 2515 | )?; | 2203 | )?; |
| 2516 | - if !has_rows { | ||
| 2517 | - bump_edge32(6); | ||
| 2518 | - } | ||
| 2519 | // lane-golomb r1: at the frame edge only the first half of the | 2204 | // lane-golomb r1: at the frame edge only the first half of the |
| 2520 | // strip is coded (libaom `decode_partition` guards the second | 2205 | // strip is coded (libaom `decode_partition` guards the second |
| 2521 | // with the same has_rows test that made this partition non-square). | 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 | reduced_tx_set, | 2244 | reduced_tx_set, |
| 2560 | fctx, | 2245 | fctx, |
| 2561 | )?; | 2246 | )?; |
| 2562 | - if !has_cols { | ||
| 2563 | - bump_edge32(7); | ||
| 2564 | - } | ||
| 2565 | // lane-golomb r1: at the frame edge only the first half of the | 2247 | // lane-golomb r1: at the frame edge only the first half of the |
| 2566 | // strip is coded (libaom `decode_partition` guards the second | 2248 | // strip is coded (libaom `decode_partition` guards the second |
| 2567 | // with the same has_cols test that made this partition non-square). | 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 | PARTITION_HORZ_A | PARTITION_HORZ_B | PARTITION_VERT_A | PARTITION_VERT_B => { | 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 | // lane-part32 r5: only the two VERTICAL arms reorder the | 2271 | // lane-part32 r5: only the two VERTICAL arms reorder the |
| 2605 | // square sub-blocks (TL, BL, TR, BR), so only they switch | 2272 | // square sub-blocks (TL, BL, TR, BR), so only they switch |
| 2606 | // libaom's `has_tr`/`has_bl` tables. | 2273 | // libaom's `has_tr`/`has_bl` tables. |
| @@ -2750,48 +2417,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2750 | } | 2417 | } |
| 2751 | crate::timeline::recon_done(); | 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 | // lane-av1fwd: the encoder's filter search re-decodes this same key | 2420 | // lane-av1fwd: the encoder's filter search re-decodes this same key |
| 2796 | // frame tile per candidate -- capture it once (see [`FilterReplay`]), | 2421 | // frame tile per candidate -- capture it once (see [`FilterReplay`]), |
| 2797 | // on the shape whose tail is the two filter calls and nothing else. | 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 | plane_snapshot(&v, ss_y(fctx) as u32), | 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 | apply_cdef( | 2476 | apply_cdef( |
| 2866 | &mut y, | 2477 | &mut y, |
| 2867 | &mut u, | 2478 | &mut u, |
| 2868 | &mut v, | 2479 | &mut v, |
| 2869 | cdef, | 2480 | cdef, |
| 2870 | &neighbours, | 2481 | &neighbours, |
| 2871 | - (frame_width as usize, frame_height as usize), | ||
| 2872 | fctx, | 2482 | fctx, |
| 2873 | None, | 2483 | None, |
| 2874 | None, | 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 | capture_stages(&y, &u, &v, deblocked.as_ref(), fctx); | 2486 | capture_stages(&y, &u, &v, deblocked.as_ref(), fctx); |
| 2888 | // spec 7.16 (libaom `superres_post_decode`, decodeframe.c: called | 2487 | // spec 7.16 (libaom `superres_post_decode`, decodeframe.c: called |
| 2889 | // between `av1_cdef_frame` and `av1_loop_restoration_filter_frame`): | 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 | fctx.last_frame_wide_margin.with(|m| { | 2608 | fctx.last_frame_wide_margin.with(|m| { |
| 3010 | *m.borrow_mut() = if true_width > fw || true_height > fh { | 2609 | *m.borrow_mut() = if true_width > fw || true_height > fh { |
| 3011 | let yc = crop(&y, true_width, true_height); | 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 | Some(Picture { | 2611 | Some(Picture { |
| 3031 | width: true_width, | 2612 | width: true_width, |
| 3032 | height: true_height, | 2613 | height: true_height, |
crates/ec-av1/src/decode/leaf8.rsmodified+8 -238
| @@ -122,9 +122,6 @@ pub(super) fn decode_block_128rect( | |||
| 122 | uv_mode | 122 | uv_mode |
| 123 | }; | 123 | }; |
| 124 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | 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 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx); | 125 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx); |
| 129 | // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or | 126 | // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or |
| 130 | // not. `bsize_to_tx_size_cat(BLOCK_128X64)` is 3 (see this fn's doc). | 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 | // lane-inter128intra r1: `get_tx_size_context` compares the bands | 140 | // lane-inter128intra r1: `get_tx_size_context` compares the bands |
| 144 | // against `tx_size_wide/high[max_txsize_rect_lookup[bsize]]` -- | 141 | // against `tx_size_wide/high[max_txsize_rect_lookup[bsize]]` -- |
| 145 | // TX_64X64 for every 128-axis block, hence the `min(64)`. | 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 | dec.symbol(&mut cdfs.tx_size_cat3[ctx]) | 144 | dec.symbol(&mut cdfs.tx_size_cat3[ctx]) |
| 148 | } else { | 145 | } else { |
| 149 | 0 | 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 | let logical_tx = if lossless_frame { 4 } else { 64 >> depth }; | 148 | let logical_tx = if lossless_frame { 4 } else { 64 >> depth }; |
| 162 | - if lossless_frame { | ||
| 163 | - hit!(INTRA128_LOSSLESS_HITS); | ||
| 164 | - } | ||
| 165 | // A 64-point transform codes nothing past its low 32 coefficients. | 149 | // A 64-point transform codes nothing past its low 32 coefficients. |
| 166 | let coeff_tx_side = logical_tx.min(32); | 150 | let coeff_tx_side = logical_tx.min(32); |
| 167 | let luma_set = if lossless_frame { | 151 | let luma_set = if lossless_frame { |
| @@ -239,11 +223,6 @@ pub(super) fn decode_block_128rect( | |||
| 239 | tu_row * logical_tx, | 223 | tu_row * logical_tx, |
| 240 | logical_tx, | 224 | logical_tx, |
| 241 | reach, | 225 | reach, |
| 242 | - px, | ||
| 243 | - py, | ||
| 244 | - y.width, | ||
| 245 | - y.height, | ||
| 246 | - fctx, | ||
| 247 | ); | 226 | ); |
| 248 | if skip { | 227 | if skip { |
| 249 | push_intra( | 228 | push_intra( |
| @@ -288,7 +267,6 @@ pub(super) fn decode_block_128rect( | |||
| 288 | tu_py, | 267 | tu_py, |
| 289 | logical_tx, | 268 | logical_tx, |
| 290 | coeff_tx_side, | 269 | coeff_tx_side, |
| 291 | - base_q_idx, | ||
| 292 | None, | 270 | None, |
| 293 | None, | 271 | None, |
| 294 | Some(tu_skip_ctx), | 272 | Some(tu_skip_ctx), |
| @@ -341,11 +319,6 @@ pub(super) fn decode_block_128rect( | |||
| 341 | luma_span, | 319 | luma_span, |
| 342 | luma_span_h, | 320 | luma_span_h, |
| 343 | reach, | 321 | reach, |
| 344 | - px, | ||
| 345 | - py, | ||
| 346 | - y.width, | ||
| 347 | - y.height, | ||
| 348 | - fctx, | ||
| 349 | ); | 322 | ); |
| 350 | if skip { | 323 | if skip { |
| 351 | push_intra( | 324 | push_intra( |
| @@ -402,7 +375,6 @@ pub(super) fn decode_block_128rect( | |||
| 402 | cu_y, | 375 | cu_y, |
| 403 | chroma_tx, | 376 | chroma_tx, |
| 404 | chroma_tx, | 377 | chroma_tx, |
| 405 | - base_q_idx, | ||
| 406 | None, | 378 | None, |
| 407 | None, | 379 | None, |
| 408 | Some(3), | 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 | if skip { | 402 | if skip { |
| @@ -467,12 +436,8 @@ pub(super) fn decode_block_128rect( | |||
| 467 | // byte-exact against ffmpeg) -- that is the replay's own designed | 436 | // byte-exact against ffmpeg) -- that is the replay's own designed |
| 468 | // 4:2:2 case, not a defect signature. Nothing here asserts the | 437 | // 4:2:2 case, not a defect signature. Nothing here asserts the |
| 469 | // mismatch is zero. | 438 | // mismatch is zero. |
| 470 | - if luma_span != luma_span_h { | ||
| 471 | - hit!(SB128RECT_REPLAY_SPAN_MISMATCH_HITS); | ||
| 472 | - } | ||
| 473 | for (plane, cu_mi, grid) in &units { | 439 | for (plane, cu_mi, grid) in &units { |
| 474 | neighbours.record_mi_chroma(*cu_mi, luma_span, luma_span_h, *plane, grid); | 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 | // No palette exists at this size; the unconditional stamp clears any | 443 | // No palette exists at this size; the unconditional stamp clears any |
| @@ -499,19 +464,6 @@ pub(super) fn decode_block_128rect( | |||
| 499 | // stamps here too -- lane-av1-intrabc r3. | 464 | // stamps here too -- lane-av1-intrabc r3. |
| 500 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (logical_tx, logical_tx), (bw, bh)); | 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 | Ok(()) | 467 | Ok(()) |
| 516 | } | 468 | } |
| 517 | 469 | ||
| @@ -563,7 +515,6 @@ pub(super) fn decode_leaf8( | |||
| 563 | y: &mut PlaneBuf<'static>, | 515 | y: &mut PlaneBuf<'static>, |
| 564 | u: &mut PlaneBuf<'static>, | 516 | u: &mut PlaneBuf<'static>, |
| 565 | v: &mut PlaneBuf<'static>, | 517 | v: &mut PlaneBuf<'static>, |
| 566 | - base_q_idx: u8, | ||
| 567 | enable_filter_intra: bool, | 518 | enable_filter_intra: bool, |
| 568 | allow_screen_content_tools: bool, | 519 | allow_screen_content_tools: bool, |
| 569 | allow_intrabc: bool, | 520 | allow_intrabc: bool, |
| @@ -603,9 +554,6 @@ pub(super) fn decode_leaf8( | |||
| 603 | // with the coarse [`SUB`] slot as the fallback when no block recorded | 554 | // with the coarse [`SUB`] slot as the fallback when no block recorded |
| 604 | // that exact mi cell. | 555 | // that exact mi cell. |
| 605 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c, fctx); | 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 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec | 557 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec |
| 610 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other | 558 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other |
| 611 | // `decode_block` caller at 16x16 and up. | 559 | // `decode_block` caller at 16x16 and up. |
| @@ -654,9 +602,6 @@ pub(super) fn decode_leaf8( | |||
| 654 | // next symbol (class `wrong-alphabet-same-value`). Everything below | 602 | // next symbol (class `wrong-alphabet-same-value`). Everything below |
| 655 | // mirrors `decode_block`'s own intrabc handling at 16x16 and up. | 603 | // mirrors `decode_block`'s own intrabc handling at 16x16 and up. |
| 656 | let intrabc_dv = fctx.intrabc_dv.with(|c| c.take()); | 604 | let intrabc_dv = fctx.intrabc_dv.with(|c| c.take()); |
| 657 | - if intrabc_dv.is_some() { | ||
| 658 | - hit!(LEAF8_INTRABC_HITS); | ||
| 659 | - } | ||
| 660 | // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour | 605 | // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour |
| 661 | // index map, mapped through the base colours, IS the block's prediction -- | 606 | // index map, mapped through the base colours, IS the block's prediction -- |
| 662 | // carried to the next `reconstruct`/`read_plane` through the same | 607 | // carried to the next `reconstruct`/`read_plane` through the same |
| @@ -676,9 +621,6 @@ pub(super) fn decode_leaf8( | |||
| 676 | let (pal_uv_size, pal_uv_colors) = palette_uv | 621 | let (pal_uv_size, pal_uv_colors) = palette_uv |
| 677 | .as_ref() | 622 | .as_ref() |
| 678 | .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 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 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { | 624 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 683 | DC_PRED | 625 | DC_PRED |
| 684 | } else { | 626 | } else { |
| @@ -722,7 +664,6 @@ pub(super) fn decode_leaf8( | |||
| 722 | 0, | 664 | 0, |
| 723 | &mut leaves, | 665 | &mut leaves, |
| 724 | ); | 666 | ); |
| 725 | - hit!(INTRABC_VARTX_HITS); | ||
| 726 | leaves.first().map_or(8, |l| l.2) | 667 | leaves.first().map_or(8, |l| l.2) |
| 727 | } else if tx_select && intrabc_dv.is_none() { | 668 | } else if tx_select && intrabc_dv.is_none() { |
| 728 | read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, fctx) | 669 | read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, fctx) |
| @@ -846,26 +787,13 @@ pub(super) fn decode_leaf8( | |||
| 846 | // rule) -- so a palette leaf takes the single 8x8 reconstruct below | 787 | // rule) -- so a palette leaf takes the single 8x8 reconstruct below |
| 847 | // even when `tx_depth` resolved to TX_4X4. | 788 | // even when `tx_depth` resolved to TX_4X4. |
| 848 | if resolved == 4 && palette_y_buf.is_none() { | 789 | if resolved == 4 && palette_y_buf.is_none() { |
| 849 | - hit!(SKIP_SPLIT_TX_HITS); | ||
| 850 | for tu_row in 0..2 { | 790 | for tu_row in 0..2 { |
| 851 | for tu_col in 0..2 { | 791 | for tu_col in 0..2 { |
| 852 | let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4); | 792 | let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4); |
| 853 | if tu_px >= y.true_width || tu_py >= y.true_height { | 793 | if tu_px >= y.true_width || tu_py >= y.true_height { |
| 854 | continue; | 794 | continue; |
| 855 | } | 795 | } |
| 856 | - let tu_reach = tu_reach( | 796 | + let tu_reach = tu_reach(8, 8, tu_col * 4, tu_row * 4, 4, 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 | - ); | ||
| 869 | push_intra( | 797 | push_intra( |
| 870 | y, | 798 | y, |
| 871 | u, | 799 | u, |
| @@ -989,19 +917,7 @@ pub(super) fn decode_leaf8( | |||
| 989 | if chroma_units_ll { | 917 | if chroma_units_ll { |
| 990 | for cu_row in 0..cu_shape.1 / 4 { | 918 | for cu_row in 0..cu_shape.1 / 4 { |
| 991 | for cu_col in 0..cu_shape.0 / 4 { | 919 | for cu_col in 0..cu_shape.0 / 4 { |
| 992 | - let cu_reach = tu_reach( | 920 | + let cu_reach = tu_reach(8, 8, cu_col * 4, cu_row * 4, 4, 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 | - ); | ||
| 1005 | push_intra( | 921 | push_intra( |
| 1006 | y, | 922 | y, |
| 1007 | u, | 923 | u, |
| @@ -1048,19 +964,7 @@ pub(super) fn decode_leaf8( | |||
| 1048 | for (buf, plane) in [(ub, 1usize), (vb, 2usize)] { | 964 | for (buf, plane) in [(ub, 1usize), (vb, 2usize)] { |
| 1049 | if let Some(buf) = buf { | 965 | if let Some(buf) = buf { |
| 1050 | for cu_row in 0..2 { | 966 | for cu_row in 0..2 { |
| 1051 | - let cu_reach = tu_reach( | 967 | + let cu_reach = tu_reach(8, 8, 0, cu_row * 4, 4, 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 | - ); | ||
| 1064 | set_palette_pred( | 968 | set_palette_pred( |
| 1065 | palette_window(&buf, cw, 0, cu_row * 4, 4, 4), | 969 | palette_window(&buf, cw, 0, cu_row * 4, 4, 4), |
| 1066 | fctx, | 970 | fctx, |
| @@ -1113,19 +1017,7 @@ pub(super) fn decode_leaf8( | |||
| 1113 | if chroma_units_ll { | 1017 | if chroma_units_ll { |
| 1114 | for cu_row in 0..cu_shape.1 / 4 { | 1018 | for cu_row in 0..cu_shape.1 / 4 { |
| 1115 | for cu_col in 0..cu_shape.0 / 4 { | 1019 | for cu_col in 0..cu_shape.0 / 4 { |
| 1116 | - let cu_reach = tu_reach( | 1020 | + let cu_reach = tu_reach(8, 8, cu_col * 4, cu_row * 4, 4, 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 | - ); | ||
| 1129 | push_intra( | 1021 | push_intra( |
| 1130 | y, | 1022 | y, |
| 1131 | u, | 1023 | u, |
| @@ -1158,19 +1050,7 @@ pub(super) fn decode_leaf8( | |||
| 1158 | .or_else(|| palette_uv_bufs.as_ref().map(|(_, vb)| vb.clone())); | 1050 | .or_else(|| palette_uv_bufs.as_ref().map(|(_, vb)| vb.clone())); |
| 1159 | if let Some(vb) = vb { | 1051 | if let Some(vb) = vb { |
| 1160 | for cu_row in 0..2 { | 1052 | for cu_row in 0..2 { |
| 1161 | - let cu_reach = tu_reach( | 1053 | + let cu_reach = tu_reach(8, 8, 0, cu_row * 4, 4, 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 | - ); | ||
| 1174 | set_palette_pred(palette_window(&vb, cw, 0, cu_row * 4, 4, 4), fctx); | 1054 | set_palette_pred(palette_window(&vb, cw, 0, cu_row * 4, 4, 4), fctx); |
| 1175 | push_intra( | 1055 | push_intra( |
| 1176 | y, | 1056 | y, |
| @@ -1257,7 +1137,6 @@ pub(super) fn decode_leaf8( | |||
| 1257 | py, | 1137 | py, |
| 1258 | 8, | 1138 | 8, |
| 1259 | TX8, | 1139 | TX8, |
| 1260 | - base_q_idx, | ||
| 1261 | None, | 1140 | None, |
| 1262 | filter_intra, | 1141 | filter_intra, |
| 1263 | None, | 1142 | None, |
| @@ -1344,7 +1223,6 @@ pub(super) fn decode_leaf8( | |||
| 1344 | cpy, | 1223 | cpy, |
| 1345 | csz, | 1224 | csz, |
| 1346 | csz, | 1225 | csz, |
| 1347 | - base_q_idx, | ||
| 1348 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | 1226 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1349 | None, | 1227 | None, |
| 1350 | None, | 1228 | None, |
| @@ -1374,7 +1252,6 @@ pub(super) fn decode_leaf8( | |||
| 1374 | cpy, | 1252 | cpy, |
| 1375 | csz, | 1253 | csz, |
| 1376 | csz, | 1254 | csz, |
| 1377 | - base_q_idx, | ||
| 1378 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | 1255 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1379 | None, | 1256 | None, |
| 1380 | None, | 1257 | None, |
| @@ -1400,29 +1277,13 @@ pub(super) fn decode_leaf8( | |||
| 1400 | let tu_px = px + tu_col * 4; | 1277 | let tu_px = px + tu_col * 4; |
| 1401 | let tu_py = py + tu_row * 4; | 1278 | let tu_py = py + tu_row * 4; |
| 1402 | let tu_around = neighbours.around_mi(tu_mi, 4)[0]; | 1279 | let tu_around = neighbours.around_mi(tu_mi, 4)[0]; |
| 1403 | - if crate::encode::Reach::in_vert_ab() { | 1280 | + let tu_reach = tu_reach(8, 8, tu_col * 4, tu_row * 4, 4, reach); |
| 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 | - ); | ||
| 1419 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); | 1281 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); |
| 1420 | // Each 4x4 unit predicts from its own window of the block's | 1282 | // Each 4x4 unit predicts from its own window of the block's |
| 1421 | // 8x8 colour-index map ([`decode_block`]'s per-TU slice at | 1283 | // 8x8 colour-index map ([`decode_block`]'s per-TU slice at |
| 1422 | // 16x16 and up) -- the whole-block buffer would be taken by | 1284 | // 16x16 and up) -- the whole-block buffer would be taken by |
| 1423 | // the FIRST unit and indexed at the wrong stride. | 1285 | // the FIRST unit and indexed at the wrong stride. |
| 1424 | if let Some(buf) = &palette_y_buf { | 1286 | if let Some(buf) = &palette_y_buf { |
| 1425 | - hit!(PALETTE_SPLIT_TX_HITS); | ||
| 1426 | let mut window = vec![0u16; 16]; | 1287 | let mut window = vec![0u16; 16]; |
| 1427 | for row in 0..4 { | 1288 | for row in 0..4 { |
| 1428 | let src = (tu_row * 4 + row) * 8 + tu_col * 4; | 1289 | let src = (tu_row * 4 + row) * 8 + tu_col * 4; |
| @@ -1454,21 +1315,12 @@ pub(super) fn decode_leaf8( | |||
| 1454 | tu_py, | 1315 | tu_py, |
| 1455 | 4, | 1316 | 4, |
| 1456 | 4, | 1317 | 4, |
| 1457 | - base_q_idx, | ||
| 1458 | None, | 1318 | None, |
| 1459 | filter_intra, | 1319 | filter_intra, |
| 1460 | Some(tu_skip_ctx), | 1320 | Some(tu_skip_ctx), |
| 1461 | smooth_neighbor, | 1321 | smooth_neighbor, |
| 1462 | fctx, | 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 | neighbours.record_mi_luma(tu_mi, 4, &tu_grid); | 1324 | neighbours.record_mi_luma(tu_mi, 4, &tu_grid); |
| 1473 | // The FIRST (top-left, co-located with this group's chroma) | 1325 | // The FIRST (top-left, co-located with this group's chroma) |
| 1474 | // TU's coded tx_type is what the group's chroma inherits -- | 1326 | // TU's coded tx_type is what the group's chroma inherits -- |
| @@ -1505,9 +1357,6 @@ pub(super) fn decode_leaf8( | |||
| 1505 | // lane-av1intrapred: the non-vacuity counter -- armed slot consulted | 1357 | // lane-av1intrapred: the non-vacuity counter -- armed slot consulted |
| 1506 | // by this arm's chroma reads means the frame-copy + inherited-type | 1358 | // by this arm's chroma reads means the frame-copy + inherited-type |
| 1507 | // route ran; zero at gate time means the fixture stopped reaching it. | 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 | if chroma_422 && !lossless(fctx) { | 1360 | if chroma_422 && !lossless(fctx) { |
| 1512 | // lane-av1-422d: the chroma unit does NOT follow the luma var-tx | 1361 | // lane-av1-422d: the chroma unit does NOT follow the luma var-tx |
| 1513 | // split -- `uv_txsize` is `av1_get_max_uv_txsize` of the block, | 1362 | // split -- `uv_txsize` is `av1_get_max_uv_txsize` of the block, |
| @@ -1601,7 +1450,6 @@ pub(super) fn decode_leaf8( | |||
| 1601 | cdfs, | 1450 | cdfs, |
| 1602 | neighbours, | 1451 | neighbours, |
| 1603 | leaf_mi, | 1452 | leaf_mi, |
| 1604 | - (px, py), | ||
| 1605 | (cpx, cpy), | 1453 | (cpx, cpy), |
| 1606 | 8, | 1454 | 8, |
| 1607 | (blk_w, blk_h), | 1455 | (blk_w, blk_h), |
| @@ -1609,13 +1457,11 @@ pub(super) fn decode_leaf8( | |||
| 1609 | (blk_w, blk_h), | 1457 | (blk_w, blk_h), |
| 1610 | blk_w, | 1458 | blk_w, |
| 1611 | reach, | 1459 | reach, |
| 1612 | - (y.width, y.height), | ||
| 1613 | mode, | 1460 | mode, |
| 1614 | uv_predict_mode, | 1461 | uv_predict_mode, |
| 1615 | angle_delta_uv, | 1462 | angle_delta_uv, |
| 1616 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), | 1463 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), |
| 1617 | smooth_neighbor_uv, | 1464 | smooth_neighbor_uv, |
| 1618 | - base_q_idx, | ||
| 1619 | &mut uo, | 1465 | &mut uo, |
| 1620 | &mut vo, | 1466 | &mut vo, |
| 1621 | fctx, | 1467 | fctx, |
| @@ -1630,7 +1476,6 @@ pub(super) fn decode_leaf8( | |||
| 1630 | } else { | 1476 | } else { |
| 1631 | Grid::Own(vo) | 1477 | Grid::Own(vo) |
| 1632 | }; | 1478 | }; |
| 1633 | - hit!(CHROMA422_LOSSLESS_4X4_HITS); | ||
| 1634 | } else if chroma_444 && lossless(fctx) { | 1479 | } else if chroma_444 && lossless(fctx) { |
| 1635 | // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster | 1480 | // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster |
| 1636 | // of TX_4X4 units per plane, PLANE-MAJOR (`av1_get_tx_size`: | 1481 | // of TX_4X4 units per plane, PLANE-MAJOR (`av1_get_tx_size`: |
| @@ -1651,7 +1496,6 @@ pub(super) fn decode_leaf8( | |||
| 1651 | cdfs, | 1496 | cdfs, |
| 1652 | neighbours, | 1497 | neighbours, |
| 1653 | leaf_mi, | 1498 | leaf_mi, |
| 1654 | - (px, py), | ||
| 1655 | (cpx, cpy), | 1499 | (cpx, cpy), |
| 1656 | 8, | 1500 | 8, |
| 1657 | (8, 8), | 1501 | (8, 8), |
| @@ -1659,13 +1503,11 @@ pub(super) fn decode_leaf8( | |||
| 1659 | (8, 8), | 1503 | (8, 8), |
| 1660 | 8, | 1504 | 8, |
| 1661 | reach, | 1505 | reach, |
| 1662 | - (y.width, y.height), | ||
| 1663 | mode, | 1506 | mode, |
| 1664 | uv_predict_mode, | 1507 | uv_predict_mode, |
| 1665 | angle_delta_uv, | 1508 | angle_delta_uv, |
| 1666 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), | 1509 | palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])), |
| 1667 | smooth_neighbor_uv, | 1510 | smooth_neighbor_uv, |
| 1668 | - base_q_idx, | ||
| 1669 | &mut uo, | 1511 | &mut uo, |
| 1670 | &mut vo, | 1512 | &mut vo, |
| 1671 | fctx, | 1513 | fctx, |
| @@ -1702,7 +1544,6 @@ pub(super) fn decode_leaf8( | |||
| 1702 | cpy, | 1544 | cpy, |
| 1703 | csz, | 1545 | csz, |
| 1704 | csz, | 1546 | csz, |
| 1705 | - base_q_idx, | ||
| 1706 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | 1547 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1707 | None, | 1548 | None, |
| 1708 | None, | 1549 | None, |
| @@ -1730,7 +1571,6 @@ pub(super) fn decode_leaf8( | |||
| 1730 | cpy, | 1571 | cpy, |
| 1731 | csz, | 1572 | csz, |
| 1732 | csz, | 1573 | csz, |
| 1733 | - base_q_idx, | ||
| 1734 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | 1574 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1735 | None, | 1575 | None, |
| 1736 | None, | 1576 | None, |
| @@ -1809,7 +1649,6 @@ pub(super) fn decode_leaf8( | |||
| 1809 | neighbours.record_palette_y_rect(leaf_mi, 8, 8, pal_y_size, pal_y_colors); | 1649 | neighbours.record_palette_y_rect(leaf_mi, 8, 8, pal_y_size, pal_y_colors); |
| 1810 | neighbours.record_palette_uv_rect(leaf_mi, 8, 8, pal_uv_size, pal_uv_colors); | 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 | neighbours.fill_skip_grid(leaf_mi, 2, skip); | 1652 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 1814 | // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal | 1653 | // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal |
| 1815 | // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm && | 1654 | // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm && |
| @@ -1924,7 +1763,6 @@ pub(super) fn leaf8_chroma422_unit( | |||
| 1924 | usize::from(around.0) + usize::from(around.1), | 1763 | usize::from(around.0) + usize::from(around.1), |
| 1925 | dc_sign_ctx(around.2), | 1764 | dc_sign_ctx(around.2), |
| 1926 | default_tx, | 1765 | default_tx, |
| 1927 | - plane_idx, | ||
| 1928 | )?; | 1766 | )?; |
| 1929 | let residual = dequant_and_inverse_typed_wh( | 1767 | let residual = dequant_and_inverse_typed_wh( |
| 1930 | &levels, | 1768 | &levels, |
| @@ -2001,28 +1839,10 @@ pub(super) fn read_intra_mode_sub8( | |||
| 2001 | // lane-av1mono: a monochrome leaf codes no chroma mode (libaom | 1839 | // lane-av1mono: a monochrome leaf codes no chroma mode (libaom |
| 2002 | // `decodemv.c:933`), so fold `NumPlanes == 1` into `has_chroma`. | 1840 | // `decodemv.c:933`), so fold `NumPlanes == 1` into `has_chroma`. |
| 2003 | let has_chroma = has_chroma && !mono(fctx); | 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 | // Same `EC_ISTEP` ladder the square/rect readers print, so a cross-decoder | 1842 | // Same `EC_ISTEP` ladder the square/rect readers print, so a cross-decoder |
| 2014 | // range diff lands on the ELEMENT inside a 4x4 leaf, not just the block. | 1843 | // range diff lands on the ELEMENT inside a 4x4 leaf, not just the block. |
| 2015 | macro_rules! istep { | 1844 | macro_rules! istep { |
| 2016 | - ($name:literal, $val:expr) => { | 1845 | + ($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 | - }; | ||
| 2026 | } | 1846 | } |
| 2027 | // lane-seg2: same `intra_segment_id` placement as the square and rect | 1847 | // lane-seg2: same `intra_segment_id` placement as the square and rect |
| 2028 | // readers (spec 5.11.6) -- a `BLOCK_4X4` leaf codes its own `segment_id` | 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 | intra_segment_id(dec, cdfs, mi_r, mi_c, seg_w_mi, seg_h_mi, false, fctx); | 1854 | intra_segment_id(dec, cdfs, mi_r, mi_c, seg_w_mi, seg_h_mi, false, fctx); |
| 2035 | } | 1855 | } |
| 2036 | let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0; | 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 | istep!("skip", skip as i32); | 1857 | istep!("skip", skip as i32); |
| 2045 | if !seg_id_pre_skip(fctx) { | 1858 | if !seg_id_pre_skip(fctx) { |
| 2046 | intra_segment_id(dec, cdfs, mi_r, mi_c, seg_w_mi, seg_h_mi, skip, fctx); | 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 | istep!("dq", 0); | 1865 | istep!("dq", 0); |
| 2053 | if allow_intrabc { | 1866 | if allow_intrabc { |
| 2054 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; | 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 | if use_intrabc { | 1868 | if use_intrabc { |
| 2063 | // lane-av1txr: `read_intrabc_info` (spec 5.11.13) reads the block | 1869 | // lane-av1txr: `read_intrabc_info` (spec 5.11.13) reads the block |
| 2064 | // vector right after the flag and RETURNS -- no y/uv mode, angle | 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 | // `is_inter_block` counts an intrabc block), so the caller takes | 1873 | // `is_inter_block` counts an intrabc block), so the caller takes |
| 2068 | // the frame-copy prediction + inter residual. | 1874 | // the frame-copy prediction + inter residual. |
| 2069 | let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (seg_w_mi, seg_h_mi), fctx); | 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 | return Ok((skip, DC_PRED, 0, None, None, Some(dv))); | 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 | let left_ctx = INTRA_MODE_CTX[left_mode]; | 1880 | let left_ctx = INTRA_MODE_CTX[left_mode]; |
| 2084 | let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]); | 1881 | let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]); |
| 2085 | istep!("mode", mode); | 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 | // No `angle_delta` at all below 8x8: spec 5.11.6's `intra_angle_info_y`/ | 1883 | // No `angle_delta` at all below 8x8: spec 5.11.6's `intra_angle_info_y`/ |
| 2093 | // `_uv` are gated on `MiSize >= BLOCK_8X8` (libaom `av1_use_angle_delta`, | 1884 | // `_uv` are gated on `MiSize >= BLOCK_8X8` (libaom `av1_use_angle_delta`, |
| 2094 | // blockd.h), so a directional mode on a `BLOCK_4X4` leaf carries no delta | 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 | // divergence at the rect leaf mi (8,16) of `ll444.obu`; class | 1898 | // divergence at the rect leaf mi (8,16) of `ll444.obu`; class |
| 2108 | // `wrong-alphabet-same-value`, lane-av1-llsub8). | 1899 | // `wrong-alphabet-same-value`, lane-av1-llsub8). |
| 2109 | let uv_mode = if cfl_allowed_px(seg_w_mi * MI, seg_h_mi * MI, fctx) { | 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 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 1901 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 2112 | } else { | 1902 | } else { |
| 2113 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 2114 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 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 | let alpha = if uv_mode == UV_CFL_PRED { | 1905 | let alpha = if uv_mode == UV_CFL_PRED { |
| 2126 | Some(read_cfl_alphas(dec, cdfs)) | 1906 | Some(read_cfl_alphas(dec, cdfs)) |
| 2127 | } else { | 1907 | } else { |
| 2128 | None | 1908 | None |
| 2129 | }; | 1909 | }; |
| 2130 | - if (V_PRED..=D67_PRED).contains(&uv_mode) { | ||
| 2131 | - hit!(DIRECTIONAL_UV_HITS); | ||
| 2132 | - } | ||
| 2133 | // See the luma comment above: no angle delta below 8x8. | 1910 | // See the luma comment above: no angle delta below 8x8. |
| 2134 | let angle_delta_uv = 0; | 1911 | let angle_delta_uv = 0; |
| 2135 | Some((uv_mode, angle_delta_uv, alpha)) | 1912 | Some((uv_mode, angle_delta_uv, alpha)) |
| @@ -2139,14 +1916,7 @@ pub(super) fn read_intra_mode_sub8( | |||
| 2139 | let mut filter_intra = None; | 1916 | let mut filter_intra = None; |
| 2140 | if mode == DC_PRED && enable_filter_intra { | 1917 | if mode == DC_PRED && enable_filter_intra { |
| 2141 | let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[fi_class]) != 0; | 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 | if use_filter_intra { | 1919 | if use_filter_intra { |
| 2149 | - hit!(FILTER_INTRA_HITS); | ||
| 2150 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); | 1920 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 2151 | filter_intra = Some(fi_mode); | 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 | u: &mut PlaneBuf<'static>, | 35 | u: &mut PlaneBuf<'static>, |
| 36 | v: &mut PlaneBuf<'static>, | 36 | v: &mut PlaneBuf<'static>, |
| 37 | scan4: &[u16], | 37 | scan4: &[u16], |
| 38 | - base_q_idx: u8, | ||
| 39 | smooth_neighbor_uv: bool, | 38 | smooth_neighbor_uv: bool, |
| 40 | fctx: &crate::decode::FrameCtx, | 39 | fctx: &crate::decode::FrameCtx, |
| 41 | ) -> Result<(Grid, Grid, usize, usize)> { | 40 | ) -> Result<(Grid, Grid, usize, usize)> { |
| @@ -94,7 +93,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 94 | &mut vb, | 93 | &mut vb, |
| 95 | fctx, | 94 | fctx, |
| 96 | ); | 95 | ); |
| 97 | - hit!(SKIPPED_INTRABC_DV_COPY_HITS); | ||
| 98 | let zeros = &ZERO_RESIDUAL[..bw * bh]; | 96 | let zeros = &ZERO_RESIDUAL[..bw * bh]; |
| 99 | if square { | 97 | if square { |
| 100 | set_palette_pred(ub, fctx); | 98 | set_palette_pred(ub, fctx); |
| @@ -173,10 +171,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 173 | fctx, | 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 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); | 174 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 181 | (Grid::Zero(bw * bh), Grid::Zero(bw * bh), 4, 4) | 175 | (Grid::Zero(bw * bh), Grid::Zero(bw * bh), 4, 4) |
| 182 | } else if skip { | 176 | } else if skip { |
| @@ -257,7 +251,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 257 | // The same arm-without-clear route the 4:2:0 tails count: a skipped | 251 | // The same arm-without-clear route the 4:2:0 tails count: a skipped |
| 258 | // leaf reads no coefficient, so an armed intrabc slot is dropped. | 252 | // leaf reads no coefficient, so an armed intrabc slot is dropped. |
| 259 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { | 253 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { |
| 260 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | ||
| 261 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); | 254 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 262 | } | 255 | } |
| 263 | (Grid::Zero(bw * bh), Grid::Zero(bw * bh), 4, 4) | 256 | (Grid::Zero(bw * bh), Grid::Zero(bw * bh), 4, 4) |
| @@ -313,7 +306,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 313 | py, | 306 | py, |
| 314 | 4, | 307 | 4, |
| 315 | TX4, | 308 | TX4, |
| 316 | - base_q_idx, | ||
| 317 | None, | 309 | None, |
| 318 | None, | 310 | None, |
| 319 | None, | 311 | None, |
| @@ -339,7 +331,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 339 | py, | 331 | py, |
| 340 | 4, | 332 | 4, |
| 341 | TX4, | 333 | TX4, |
| 342 | - base_q_idx, | ||
| 343 | None, | 334 | None, |
| 344 | None, | 335 | None, |
| 345 | None, | 336 | None, |
| @@ -350,9 +341,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 350 | } else { | 341 | } else { |
| 351 | // lane-av1-ibc444rect: the unskipped lossless chroma walk this | 342 | // lane-av1-ibc444rect: the unskipped lossless chroma walk this |
| 352 | // lane fixes (one rect unit -> per-4x4 Chroma4 units). | 343 | // lane fixes (one rect unit -> per-4x4 Chroma4 units). |
| 353 | - if lossless(fctx) { | ||
| 354 | - hit!(INTRABC_RECT8_LOSSLESS_CHROMA_HITS); | ||
| 355 | - } | ||
| 356 | if lossless(fctx) { | 344 | if lossless(fctx) { |
| 357 | // lane-av1-ibc444rect: at lossless `read_tx_size` forces | 345 | // lane-av1-ibc444rect: at lossless `read_tx_size` forces |
| 358 | // TX_4X4 on EVERY plane (`av1_get_tx_size`'s lossless | 346 | // TX_4X4 on EVERY plane (`av1_get_tx_size`'s lossless |
| @@ -406,11 +394,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 406 | // 4:2:2 twin of this arm was fixed the same way | 394 | // 4:2:2 twin of this arm was fixed the same way |
| 407 | // (lane-av1-422kf2); this is its 4:4:4 twin. | 395 | // (lane-av1-422kf2); this is its 4:4:4 twin. |
| 408 | let unit_reach = Reach::of_tu(bw, bh, uc * 4, ur * 4, 4, 4, reach); | 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 | let grid = read_plane( | 397 | let grid = read_plane( |
| 415 | dec, | 398 | dec, |
| 416 | cdfs, | 399 | cdfs, |
| @@ -429,7 +412,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 429 | upy, | 412 | upy, |
| 430 | 4, | 413 | 4, |
| 431 | TX4, | 414 | TX4, |
| 432 | - base_q_idx, | ||
| 433 | None, | 415 | None, |
| 434 | None, | 416 | None, |
| 435 | Some(3), | 417 | Some(3), |
| @@ -478,7 +460,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 478 | skip_ctx, | 460 | skip_ctx, |
| 479 | dc_sign_ctx(around[plane_idx].2), | 461 | dc_sign_ctx(around[plane_idx].2), |
| 480 | default_tx, | 462 | default_tx, |
| 481 | - plane_idx, | ||
| 482 | )?; | 463 | )?; |
| 483 | let residual = dequant_and_inverse_typed_wh( | 464 | let residual = dequant_and_inverse_typed_wh( |
| 484 | &levels, | 465 | &levels, |
| @@ -543,7 +524,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 543 | py, | 524 | py, |
| 544 | 4, | 525 | 4, |
| 545 | TX4, | 526 | TX4, |
| 546 | - base_q_idx, | ||
| 547 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | 527 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 548 | None, | 528 | None, |
| 549 | None, | 529 | None, |
| @@ -568,7 +548,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 568 | py, | 548 | py, |
| 569 | 4, | 549 | 4, |
| 570 | TX4, | 550 | TX4, |
| 571 | - base_q_idx, | ||
| 572 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | 551 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 573 | None, | 552 | None, |
| 574 | None, | 553 | None, |
| @@ -605,10 +584,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 605 | // position -- see the intrabc twin above for the | 584 | // position -- see the intrabc twin above for the |
| 606 | // libaom citation and the measured damage. | 585 | // libaom citation and the measured damage. |
| 607 | let unit_reach = Reach::of_tu(bw, bh, uc * 4, ur * 4, 4, 4, reach); | 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 | let grid = read_plane( | 587 | let grid = read_plane( |
| 613 | dec, | 588 | dec, |
| 614 | cdfs, | 589 | cdfs, |
| @@ -627,7 +602,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 627 | upy, | 602 | upy, |
| 628 | 4, | 603 | 4, |
| 629 | TX4, | 604 | TX4, |
| 630 | - base_q_idx, | ||
| 631 | None, | 605 | None, |
| 632 | None, | 606 | None, |
| 633 | Some(3), | 607 | Some(3), |
| @@ -677,7 +651,6 @@ pub(super) fn sub8_leaf_chroma444( | |||
| 677 | skip_ctx, | 651 | skip_ctx, |
| 678 | dc_sign_ctx(around[plane_idx].2), | 652 | dc_sign_ctx(around[plane_idx].2), |
| 679 | default_tx, | 653 | default_tx, |
| 680 | - plane_idx, | ||
| 681 | )?; | 654 | )?; |
| 682 | let residual = dequant_and_inverse_typed_wh( | 655 | let residual = dequant_and_inverse_typed_wh( |
| 683 | &levels, | 656 | &levels, |
| @@ -806,16 +779,7 @@ pub(super) fn sub8_leaf_chroma422( | |||
| 806 | u: &mut PlaneBuf<'static>, | 779 | u: &mut PlaneBuf<'static>, |
| 807 | v: &mut PlaneBuf<'static>, | 780 | v: &mut PlaneBuf<'static>, |
| 808 | scan4: &[u16], | 781 | scan4: &[u16], |
| 809 | - base_q_idx: u8, | ||
| 810 | smooth_neighbor_uv: bool, | 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 | leaf_shape: (usize, usize), | 783 | leaf_shape: (usize, usize), |
| 820 | fctx: &crate::decode::FrameCtx, | 784 | fctx: &crate::decode::FrameCtx, |
| 821 | ) -> Result<(Grid, Grid)> { | 785 | ) -> Result<(Grid, Grid)> { |
| @@ -988,7 +952,6 @@ pub(super) fn sub8_leaf_chroma422( | |||
| 988 | &mut ub, | 952 | &mut ub, |
| 989 | fctx, | 953 | fctx, |
| 990 | ); | 954 | ); |
| 991 | - hit!(SKIPPED_INTRABC_DV_COPY_HITS); | ||
| 992 | let zeros = &ZERO_RESIDUAL[..16]; | 955 | let zeros = &ZERO_RESIDUAL[..16]; |
| 993 | set_palette_pred(ub, fctx); | 956 | set_palette_pred(ub, fctx); |
| 994 | push_intra( | 957 | push_intra( |
| @@ -1044,17 +1007,12 @@ pub(super) fn sub8_leaf_chroma422( | |||
| 1044 | // [`sub8_leaf_chroma444`] count: a skipped leaf reads no coefficient, | 1007 | // [`sub8_leaf_chroma444`] count: a skipped leaf reads no coefficient, |
| 1045 | // so the inherited chroma `tx_type` is dropped unconsumed. | 1008 | // so the inherited chroma `tx_type` is dropped unconsumed. |
| 1046 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { | 1009 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { |
| 1047 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | ||
| 1048 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); | 1010 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 1049 | } | 1011 | } |
| 1050 | (Grid::Zero(16), Grid::Zero(16)) | 1012 | (Grid::Zero(16), Grid::Zero(16)) |
| 1051 | } else if skip { | 1013 | } else if skip { |
| 1052 | // A skipped chroma-reference leaf still predicts (the CfL contribution | 1014 | // A skipped chroma-reference leaf still predicts (the CfL contribution |
| 1053 | // survives a skip); no coefficient symbol exists. | 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 | push_intra( | 1016 | push_intra( |
| 1059 | y, | 1017 | y, |
| 1060 | u, | 1018 | u, |
| @@ -1092,12 +1050,10 @@ pub(super) fn sub8_leaf_chroma422( | |||
| 1092 | // The same arm-without-clear route the 4:2:0 tails count: a skipped | 1050 | // The same arm-without-clear route the 4:2:0 tails count: a skipped |
| 1093 | // leaf reads no coefficient, so an armed intrabc slot is dropped. | 1051 | // leaf reads no coefficient, so an armed intrabc slot is dropped. |
| 1094 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { | 1052 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { |
| 1095 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | ||
| 1096 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); | 1053 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 1097 | } | 1054 | } |
| 1098 | (Grid::Zero(16), Grid::Zero(16)) | 1055 | (Grid::Zero(16), Grid::Zero(16)) |
| 1099 | } else if let Some(dv) = intrabc_dv { | 1056 | } else if let Some(dv) = intrabc_dv { |
| 1100 | - hit!(CHROMA422_SUB8_HITS); | ||
| 1101 | // Frame copy at the DV; the residual still reads the ordinary chroma | 1057 | // Frame copy at the DV; the residual still reads the ordinary chroma |
| 1102 | // tables with the inherited luma `tx_type` (see the 4:2:0 tails). | 1058 | // tables with the inherited luma `tx_type` (see the 4:2:0 tails). |
| 1103 | let mut ub = vec![0u16; 16]; | 1059 | let mut ub = vec![0u16; 16]; |
| @@ -1147,7 +1103,6 @@ pub(super) fn sub8_leaf_chroma422( | |||
| 1147 | cpy, | 1103 | cpy, |
| 1148 | 4, | 1104 | 4, |
| 1149 | TX4, | 1105 | TX4, |
| 1150 | - base_q_idx, | ||
| 1151 | None, | 1106 | None, |
| 1152 | None, | 1107 | None, |
| 1153 | None, | 1108 | None, |
| @@ -1173,7 +1128,6 @@ pub(super) fn sub8_leaf_chroma422( | |||
| 1173 | cpy, | 1128 | cpy, |
| 1174 | 4, | 1129 | 4, |
| 1175 | TX4, | 1130 | TX4, |
| 1176 | - base_q_idx, | ||
| 1177 | None, | 1131 | None, |
| 1178 | None, | 1132 | None, |
| 1179 | None, | 1133 | None, |
| @@ -1183,7 +1137,6 @@ pub(super) fn sub8_leaf_chroma422( | |||
| 1183 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); | 1137 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 1184 | (ug, vg) | 1138 | (ug, vg) |
| 1185 | } else { | 1139 | } else { |
| 1186 | - hit!(CHROMA422_SUB8_HITS); | ||
| 1187 | let ug = read_plane( | 1140 | let ug = read_plane( |
| 1188 | dec, | 1141 | dec, |
| 1189 | cdfs, | 1142 | cdfs, |
| @@ -1202,7 +1155,6 @@ pub(super) fn sub8_leaf_chroma422( | |||
| 1202 | cpy, | 1155 | cpy, |
| 1203 | 4, | 1156 | 4, |
| 1204 | TX4, | 1157 | TX4, |
| 1205 | - base_q_idx, | ||
| 1206 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | 1158 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1207 | None, | 1159 | None, |
| 1208 | None, | 1160 | None, |
| @@ -1227,7 +1179,6 @@ pub(super) fn sub8_leaf_chroma422( | |||
| 1227 | cpy, | 1179 | cpy, |
| 1228 | 4, | 1180 | 4, |
| 1229 | TX4, | 1181 | TX4, |
| 1230 | - base_q_idx, | ||
| 1231 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | 1182 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1232 | None, | 1183 | None, |
| 1233 | None, | 1184 | None, |
| @@ -1277,16 +1228,11 @@ pub(super) fn decode_leaf_split4( | |||
| 1277 | y: &mut PlaneBuf<'static>, | 1228 | y: &mut PlaneBuf<'static>, |
| 1278 | u: &mut PlaneBuf<'static>, | 1229 | u: &mut PlaneBuf<'static>, |
| 1279 | v: &mut PlaneBuf<'static>, | 1230 | v: &mut PlaneBuf<'static>, |
| 1280 | - base_q_idx: u8, | ||
| 1281 | enable_filter_intra: bool, | 1231 | enable_filter_intra: bool, |
| 1282 | allow_intrabc: bool, | 1232 | allow_intrabc: bool, |
| 1283 | reduced_tx_set: bool, | 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 | fctx: &crate::decode::FrameCtx, | 1234 | fctx: &crate::decode::FrameCtx, |
| 1288 | ) -> Result<(usize, usize)> { | 1235 | ) -> Result<(usize, usize)> { |
| 1289 | - hit!(SUB8_SPLIT_HITS); | ||
| 1290 | let (r, c) = outer_at; | 1236 | let (r, c) = outer_at; |
| 1291 | let mut above_mode = neighbours.above_mode[c]; | 1237 | let mut above_mode = neighbours.above_mode[c]; |
| 1292 | let mut left_mode = neighbours.left_mode[r]; | 1238 | let mut left_mode = neighbours.left_mode[r]; |
| @@ -1378,9 +1324,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1378 | // same value). | 1324 | // same value). |
| 1379 | set_txfm_ctxs(neighbours, lmi, 4, 1, 1, false); | 1325 | set_txfm_ctxs(neighbours, lmi, 4, 1, 1, false); |
| 1380 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); | 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 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); | 1327 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 1385 | let reach = Reach::of(4, px, py, y.width, y.height, fctx); | 1328 | let reach = Reach::of(4, px, py, y.width, y.height, fctx); |
| 1386 | if let Some(dv) = intrabc { | 1329 | if let Some(dv) = intrabc { |
| @@ -1450,7 +1393,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1450 | py, | 1393 | py, |
| 1451 | 4, | 1394 | 4, |
| 1452 | 4, | 1395 | 4, |
| 1453 | - base_q_idx, | ||
| 1454 | None, | 1396 | None, |
| 1455 | None, | 1397 | None, |
| 1456 | None, | 1398 | None, |
| @@ -1488,7 +1430,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1488 | u, | 1430 | u, |
| 1489 | v, | 1431 | v, |
| 1490 | scan4, | 1432 | scan4, |
| 1491 | - base_q_idx, | ||
| 1492 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), | 1433 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 1493 | fctx, | 1434 | fctx, |
| 1494 | )?; | 1435 | )?; |
| @@ -1508,7 +1449,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1508 | u, | 1449 | u, |
| 1509 | v, | 1450 | v, |
| 1510 | scan4, | 1451 | scan4, |
| 1511 | - base_q_idx, | ||
| 1512 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), | 1452 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 1513 | (4, 4), | 1453 | (4, 4), |
| 1514 | fctx, | 1454 | fctx, |
| @@ -1579,7 +1519,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1579 | py, | 1519 | py, |
| 1580 | 4, | 1520 | 4, |
| 1581 | 4, | 1521 | 4, |
| 1582 | - base_q_idx, | ||
| 1583 | None, | 1522 | None, |
| 1584 | filter_intra, | 1523 | filter_intra, |
| 1585 | None, | 1524 | None, |
| @@ -1610,7 +1549,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1610 | u, | 1549 | u, |
| 1611 | v, | 1550 | v, |
| 1612 | scan4, | 1551 | scan4, |
| 1613 | - base_q_idx, | ||
| 1614 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), | 1552 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 1615 | fctx, | 1553 | fctx, |
| 1616 | )?; | 1554 | )?; |
| @@ -1636,7 +1574,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1636 | u, | 1574 | u, |
| 1637 | v, | 1575 | v, |
| 1638 | scan4, | 1576 | scan4, |
| 1639 | - base_q_idx, | ||
| 1640 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), | 1577 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 1641 | (4, 4), | 1578 | (4, 4), |
| 1642 | fctx, | 1579 | fctx, |
| @@ -1695,10 +1632,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1695 | // merge keeps one fix and feeds both lanes' counters so neither of | 1632 | // merge keeps one fix and feeds both lanes' counters so neither of |
| 1696 | // their gates goes vacuous. | 1633 | // their gates goes vacuous. |
| 1697 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); | 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 | push_intra( | 1635 | push_intra( |
| 1703 | y, | 1636 | y, |
| 1704 | u, | 1637 | u, |
| @@ -1742,7 +1675,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1742 | // arm-without-clear-on-a-skip-route). Counted so a gate can tell a | 1675 | // arm-without-clear-on-a-skip-route). Counted so a gate can tell a |
| 1743 | // stream that reaches this route from one that never does. | 1676 | // stream that reaches this route from one that never does. |
| 1744 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { | 1677 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { |
| 1745 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | ||
| 1746 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); | 1678 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 1747 | } | 1679 | } |
| 1748 | (Grid::Zero(16), Grid::Zero(16)) | 1680 | (Grid::Zero(16), Grid::Zero(16)) |
| @@ -1799,7 +1731,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1799 | cpy, | 1731 | cpy, |
| 1800 | 4, | 1732 | 4, |
| 1801 | TX4, | 1733 | TX4, |
| 1802 | - base_q_idx, | ||
| 1803 | None, | 1734 | None, |
| 1804 | None, | 1735 | None, |
| 1805 | None, | 1736 | None, |
| @@ -1825,7 +1756,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1825 | cpy, | 1756 | cpy, |
| 1826 | 4, | 1757 | 4, |
| 1827 | TX4, | 1758 | TX4, |
| 1828 | - base_q_idx, | ||
| 1829 | None, | 1759 | None, |
| 1830 | None, | 1760 | None, |
| 1831 | None, | 1761 | None, |
| @@ -1855,7 +1785,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1855 | cpy, | 1785 | cpy, |
| 1856 | 4, | 1786 | 4, |
| 1857 | TX4, | 1787 | TX4, |
| 1858 | - base_q_idx, | ||
| 1859 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | 1788 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1860 | None, | 1789 | None, |
| 1861 | None, | 1790 | None, |
| @@ -1880,7 +1809,6 @@ pub(super) fn decode_leaf_split4( | |||
| 1880 | cpy, | 1809 | cpy, |
| 1881 | 4, | 1810 | 4, |
| 1882 | TX4, | 1811 | TX4, |
| 1883 | - base_q_idx, | ||
| 1884 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | 1812 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1885 | None, | 1813 | None, |
| 1886 | None, | 1814 | None, |
| @@ -1989,7 +1917,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 1989 | y: &mut PlaneBuf<'static>, | 1917 | y: &mut PlaneBuf<'static>, |
| 1990 | u: &mut PlaneBuf<'static>, | 1918 | u: &mut PlaneBuf<'static>, |
| 1991 | v: &mut PlaneBuf<'static>, | 1919 | v: &mut PlaneBuf<'static>, |
| 1992 | - base_q_idx: u8, | ||
| 1993 | enable_filter_intra: bool, | 1920 | enable_filter_intra: bool, |
| 1994 | allow_intrabc: bool, | 1921 | allow_intrabc: bool, |
| 1995 | tx_select: bool, | 1922 | tx_select: bool, |
| @@ -2073,9 +2000,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2073 | if let Some(dv) = intrabc { | 2000 | if let Some(dv) = intrabc { |
| 2074 | // lane-av1-ibc444rect: the unskipped lossless luma walk this lane | 2001 | // lane-av1-ibc444rect: the unskipped lossless luma walk this lane |
| 2075 | // fixes (one rect unit -> per-4x4 inter units). | 2002 | // fixes (one rect unit -> per-4x4 inter units). |
| 2076 | - if !skip && lossless(fctx) { | ||
| 2077 | - hit!(INTRABC_RECT8_LOSSLESS_LUMA_HITS); | ||
| 2078 | - } | ||
| 2079 | // lane-av1txr: an intrabc `BLOCK_4X8`/`BLOCK_8X4` leaf. The | 2003 | // lane-av1txr: an intrabc `BLOCK_4X8`/`BLOCK_8X4` leaf. The |
| 2080 | // prediction is a frame copy at the DV and the residual reads the | 2004 | // prediction is a frame copy at the DV and the residual reads the |
| 2081 | // INTER `LumaRect8x4` set -- but with `TxMode::Select` the leaf | 2005 | // INTER `LumaRect8x4` set -- but with `TxMode::Select` the leaf |
| @@ -2127,7 +2051,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2127 | 0, | 2051 | 0, |
| 2128 | &mut luma_leaves, | 2052 | &mut luma_leaves, |
| 2129 | ); | 2053 | ); |
| 2130 | - hit!(RECT_INTRABC_VARTX_HITS); | ||
| 2131 | publish = None; | 2054 | publish = None; |
| 2132 | } else if lossless(fctx) && !skip { | 2055 | } else if lossless(fctx) && !skip { |
| 2133 | // lane-av1-ibc444rect: `read_tx_size`'s lossless first line | 2056 | // lane-av1-ibc444rect: `read_tx_size`'s lossless first line |
| @@ -2170,19 +2093,7 @@ pub(super) fn decode_leaf_rect8( | |||
| 2170 | let tu_reach = if single { | 2093 | let tu_reach = if single { |
| 2171 | reach | 2094 | reach |
| 2172 | } else { | 2095 | } else { |
| 2173 | - tu_reach( | 2096 | + tu_reach(bw, bh, tu_px - px, tu_py - py, tw, 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 | - ) | ||
| 2186 | }; | 2097 | }; |
| 2187 | let mut yb = vec![0u16; tw * th]; | 2098 | let mut yb = vec![0u16; tw * th]; |
| 2188 | mc::predict_with_filter( | 2099 | mc::predict_with_filter( |
| @@ -2285,7 +2196,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2285 | skip_ctx, | 2196 | skip_ctx, |
| 2286 | dc_sign_ctx(around.2), | 2197 | dc_sign_ctx(around.2), |
| 2287 | TxType::DctDct, | 2198 | TxType::DctDct, |
| 2288 | - 0, | ||
| 2289 | )?; | 2199 | )?; |
| 2290 | if li == 0 { | 2200 | if li == 0 { |
| 2291 | chroma_tx = tx_type; | 2201 | chroma_tx = tx_type; |
| @@ -2417,7 +2327,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2417 | u, | 2327 | u, |
| 2418 | v, | 2328 | v, |
| 2419 | scan4, | 2329 | scan4, |
| 2420 | - base_q_idx, | ||
| 2421 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), | 2330 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2422 | fctx, | 2331 | fctx, |
| 2423 | )?; | 2332 | )?; |
| @@ -2439,7 +2348,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2439 | u, | 2348 | u, |
| 2440 | v, | 2349 | v, |
| 2441 | scan4, | 2350 | scan4, |
| 2442 | - base_q_idx, | ||
| 2443 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), | 2351 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2444 | (bw, bh), | 2352 | (bw, bh), |
| 2445 | fctx, | 2353 | fctx, |
| @@ -2452,15 +2360,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2452 | } | 2360 | } |
| 2453 | continue; | 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 | // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4 | 2363 | // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4 |
| 2465 | // leaf too, and is read for every intra block, skipped or not. Its | 2364 | // leaf too, and is read for every intra block, skipped or not. Its |
| 2466 | // category is libaom's `bsize_to_tx_size_cat(BLOCK_4X8) == 0` -- | 2365 | // category is libaom's `bsize_to_tx_size_cat(BLOCK_4X8) == 0` -- |
| @@ -2480,18 +2379,11 @@ pub(super) fn decode_leaf_rect8( | |||
| 2480 | let depth = if tx_select && !lossless(fctx) { | 2379 | let depth = if tx_select && !lossless(fctx) { |
| 2481 | // lane-av1txbands: the `TXFM_CONTEXT` band read every other rect | 2380 | // lane-av1txbands: the `TXFM_CONTEXT` band read every other rect |
| 2482 | // reader already does. | 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 | dec.symbol(&mut cdfs.tx_size_cat0[ctx]) | 2383 | dec.symbol(&mut cdfs.tx_size_cat0[ctx]) |
| 2485 | } else { | 2384 | } else { |
| 2486 | 0 | 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 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); | 2387 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 2496 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); | 2388 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); |
| 2497 | // `sub_tx_size_map[TX_4X8] == TX_4X4`: depth 1 splits the leaf into | 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 | let (ctx_tx_w, ctx_tx_h) = if split { (4, 4) } else { (bw, bh) }; | 2403 | let (ctx_tx_w, ctx_tx_h) = if split { (4, 4) } else { (bw, bh) }; |
| 2512 | txfm_partition_update_rect(neighbours, lmi, (ctx_tx_w, ctx_tx_h), (bw, bh)); | 2404 | txfm_partition_update_rect(neighbours, lmi, (ctx_tx_w, ctx_tx_h), (bw, bh)); |
| 2513 | if split { | 2405 | if split { |
| 2514 | - let mut done = 0usize; | ||
| 2515 | for tu in 0..2usize { | 2406 | for tu in 0..2usize { |
| 2516 | let tu_mi = if vert { | 2407 | let tu_mi = if vert { |
| 2517 | (lmi.0 + tu, lmi.1) | 2408 | (lmi.0 + tu, lmi.1) |
| @@ -2524,19 +2415,7 @@ pub(super) fn decode_leaf_rect8( | |||
| 2524 | // (lane-palette2 r12): a transform unit inside a block is not | 2415 | // (lane-palette2 r12): a transform unit inside a block is not |
| 2525 | // a block at that position, so its reach comes from the | 2416 | // a block at that position, so its reach comes from the |
| 2526 | // block's own row, offset by the unit's position. | 2417 | // block's own row, offset by the unit's position. |
| 2527 | - let tu_reach = tu_reach( | 2418 | + let tu_reach = tu_reach(bw, bh, tu_px - px, tu_py - py, 4, 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 | - ); | ||
| 2540 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); | 2419 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); |
| 2541 | if skip { | 2420 | if skip { |
| 2542 | // A skipped leaf still predicts per transform unit: the | 2421 | // A skipped leaf still predicts per transform unit: the |
| @@ -2586,25 +2465,14 @@ pub(super) fn decode_leaf_rect8( | |||
| 2586 | tu_py, | 2465 | tu_py, |
| 2587 | 4, | 2466 | 4, |
| 2588 | TX4, | 2467 | TX4, |
| 2589 | - base_q_idx, | ||
| 2590 | None, | 2468 | None, |
| 2591 | filter_intra, | 2469 | filter_intra, |
| 2592 | Some(tu_skip_ctx), | 2470 | Some(tu_skip_ctx), |
| 2593 | smooth_neighbor, | 2471 | smooth_neighbor, |
| 2594 | fctx, | 2472 | fctx, |
| 2595 | )?; | 2473 | )?; |
| 2596 | - if tu_grid.iter().any(|&l| l != 0) { | ||
| 2597 | - done += 1; | ||
| 2598 | - } | ||
| 2599 | neighbours.record_mi_luma(tu_mi, 4, &tu_grid); | 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 | neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); | 2476 | neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); |
| 2609 | neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, 4, 4, 0, fctx); | 2477 | neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, 4, 4, 0, fctx); |
| 2610 | if has_chroma { | 2478 | if has_chroma { |
| @@ -2627,7 +2495,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2627 | u, | 2495 | u, |
| 2628 | v, | 2496 | v, |
| 2629 | scan4, | 2497 | scan4, |
| 2630 | - base_q_idx, | ||
| 2631 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), | 2498 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2632 | fctx, | 2499 | fctx, |
| 2633 | )?; | 2500 | )?; |
| @@ -2655,7 +2522,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2655 | u, | 2522 | u, |
| 2656 | v, | 2523 | v, |
| 2657 | scan4, | 2524 | scan4, |
| 2658 | - base_q_idx, | ||
| 2659 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), | 2525 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2660 | (bw, bh), | 2526 | (bw, bh), |
| 2661 | fctx, | 2527 | fctx, |
| @@ -2712,15 +2578,7 @@ pub(super) fn decode_leaf_rect8( | |||
| 2712 | 0, | 2578 | 0, |
| 2713 | dc_sign_ctx(around.2), | 2579 | dc_sign_ctx(around.2), |
| 2714 | TxType::DctDct, | 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 | let residual = dequant_and_inverse_typed_wh( | 2582 | let residual = dequant_and_inverse_typed_wh( |
| 2725 | &levels, | 2583 | &levels, |
| 2726 | bw, | 2584 | bw, |
| @@ -2791,7 +2649,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2791 | u, | 2649 | u, |
| 2792 | v, | 2650 | v, |
| 2793 | scan4, | 2651 | scan4, |
| 2794 | - base_q_idx, | ||
| 2795 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), | 2652 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2796 | fctx, | 2653 | fctx, |
| 2797 | )?; | 2654 | )?; |
| @@ -2822,7 +2679,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2822 | u, | 2679 | u, |
| 2823 | v, | 2680 | v, |
| 2824 | scan4, | 2681 | scan4, |
| 2825 | - base_q_idx, | ||
| 2826 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), | 2682 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 2827 | (bw, bh), | 2683 | (bw, bh), |
| 2828 | fctx, | 2684 | fctx, |
| @@ -2881,10 +2737,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2881 | // merge keeps one fix and feeds both lanes' counters so neither of | 2737 | // merge keeps one fix and feeds both lanes' counters so neither of |
| 2882 | // their gates goes vacuous. | 2738 | // their gates goes vacuous. |
| 2883 | let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); | 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 | push_intra( | 2740 | push_intra( |
| 2889 | y, | 2741 | y, |
| 2890 | u, | 2742 | u, |
| @@ -2928,7 +2780,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 2928 | // arm-without-clear-on-a-skip-route). Counted so a gate can tell a | 2780 | // arm-without-clear-on-a-skip-route). Counted so a gate can tell a |
| 2929 | // stream that reaches this route from one that never does. | 2781 | // stream that reaches this route from one that never does. |
| 2930 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { | 2782 | if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { |
| 2931 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | ||
| 2932 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); | 2783 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 2933 | } | 2784 | } |
| 2934 | (Grid::Zero(16), Grid::Zero(16)) | 2785 | (Grid::Zero(16), Grid::Zero(16)) |
| @@ -3005,7 +2856,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 3005 | &ZERO_RESIDUAL[..16], | 2856 | &ZERO_RESIDUAL[..16], |
| 3006 | fctx, | 2857 | fctx, |
| 3007 | ); | 2858 | ); |
| 3008 | - hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | ||
| 3009 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); | 2859 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 3010 | (Grid::Zero(16), Grid::Zero(16)) | 2860 | (Grid::Zero(16), Grid::Zero(16)) |
| 3011 | } else { | 2861 | } else { |
| @@ -3029,7 +2879,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 3029 | cpy, | 2879 | cpy, |
| 3030 | 4, | 2880 | 4, |
| 3031 | TX4, | 2881 | TX4, |
| 3032 | - base_q_idx, | ||
| 3033 | None, | 2882 | None, |
| 3034 | None, | 2883 | None, |
| 3035 | None, | 2884 | None, |
| @@ -3055,7 +2904,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 3055 | cpy, | 2904 | cpy, |
| 3056 | 4, | 2905 | 4, |
| 3057 | TX4, | 2906 | TX4, |
| 3058 | - base_q_idx, | ||
| 3059 | None, | 2907 | None, |
| 3060 | None, | 2908 | None, |
| 3061 | None, | 2909 | None, |
| @@ -3086,7 +2934,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 3086 | cpy, | 2934 | cpy, |
| 3087 | 4, | 2935 | 4, |
| 3088 | TX4, | 2936 | TX4, |
| 3089 | - base_q_idx, | ||
| 3090 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | 2937 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 3091 | None, | 2938 | None, |
| 3092 | None, | 2939 | None, |
| @@ -3111,7 +2958,6 @@ pub(super) fn decode_leaf_rect8( | |||
| 3111 | cpy, | 2958 | cpy, |
| 3112 | 4, | 2959 | 4, |
| 3113 | TX4, | 2960 | TX4, |
| 3114 | - base_q_idx, | ||
| 3115 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | 2961 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 3116 | None, | 2962 | None, |
| 3117 | None, | 2963 | None, |
crates/ec-av1/src/decode/mod.rsmodified+7 -522
| @@ -20,7 +20,6 @@ | |||
| 20 | //! inside one, forcing the gathered-CDF partial-superblock path, is round 2 | 20 | //! inside one, forcing the gathered-CDF partial-superblock path, is round 2 |
| 21 | //! too). Anything outside that refuses with [`Error::unsupported`] rather than | 21 | //! too). Anything outside that refuses with [`Error::unsupported`] rather than |
| 22 | //! silently miscoding. | 22 | //! silently miscoding. |
| 23 | -use crate::hits::{hit, hit_do}; | ||
| 24 | 23 | ||
| 25 | use ec_av1_syntax::{ | 24 | use ec_av1_syntax::{ |
| 26 | CdefParams, DeltaParams, LoopFilterParams, LoopRestorationParams, MAX_SEGMENTS, | 25 | CdefParams, DeltaParams, LoopFilterParams, LoopRestorationParams, MAX_SEGMENTS, |
| @@ -41,9 +40,6 @@ use ec_core::{Error, Result}; | |||
| 41 | // itself was lifted by lane-av112bitc before that (the combines absorb the | 40 | // itself was lifted by lane-av112bitc before that (the combines absorb the |
| 42 | // CONV_BUF gain drop, `INTER_POST_ROUND - delta`, see `mc::combine_compound`). | 41 | // CONV_BUF gain drop, `INTER_POST_ROUND - delta`, see `mc::combine_compound`). |
| 43 | 42 | ||
| 44 | -mod counters; | ||
| 45 | -pub use counters::*; | ||
| 46 | - | ||
| 47 | mod frame_tile; | 43 | mod frame_tile; |
| 48 | 44 | ||
| 49 | mod inter_block8; | 45 | mod inter_block8; |
| @@ -71,7 +67,7 @@ use rect4::*; | |||
| 71 | 67 | ||
| 72 | mod block; | 68 | mod block; |
| 73 | mod wave; | 69 | mod wave; |
| 74 | -pub use block::*; | 70 | +pub(crate) use block::*; |
| 75 | 71 | ||
| 76 | mod leaf8; | 72 | mod leaf8; |
| 77 | use leaf8::*; | 73 | use leaf8::*; |
| @@ -100,9 +96,6 @@ pub use key_tile::*; | |||
| 100 | mod inter_ctx; | 96 | mod inter_ctx; |
| 101 | pub(crate) use inter_ctx::*; | 97 | pub(crate) use inter_ctx::*; |
| 102 | 98 | ||
| 103 | -#[cfg(test)] | ||
| 104 | -mod obmc_skip_chroma_tests; | ||
| 105 | - | ||
| 106 | mod sub8_inter; | 99 | mod sub8_inter; |
| 107 | pub(crate) use frame_tile::*; | 100 | pub(crate) use frame_tile::*; |
| 108 | use sub8_inter::*; | 101 | use sub8_inter::*; |
| @@ -437,38 +430,6 @@ thread_local! { | |||
| 437 | static COEFF_TRACE_CUR: std::cell::Cell<usize> = const { std::cell::Cell::new(usize::MAX) }; | 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 | /// Sets [`SB128`] for this thread (called once per frame from `stream.rs`). | 433 | /// Sets [`SB128`] for this thread (called once per frame from `stream.rs`). |
| 473 | pub(crate) fn set_sb128(v: bool, fctx: &crate::decode::FrameCtx) { | 434 | pub(crate) fn set_sb128(v: bool, fctx: &crate::decode::FrameCtx) { |
| 474 | fctx.sb128_flag.with(|c| c.set(v)); | 435 | fctx.sb128_flag.with(|c| c.set(v)); |
| @@ -550,20 +511,6 @@ thread_local! { | |||
| 550 | static PART128_GATHERED_SYMBOLS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 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 | /// [`gather`] over an alphabet of any length -- the 128-level partition CDF | 514 | /// [`gather`] over an alphabet of any length -- the 128-level partition CDF |
| 568 | /// has 8 symbols (no `PARTITION_HORZ_4`/`_VERT_4` at `BLOCK_128X128`, spec | 515 | /// has 8 symbols (no `PARTITION_HORZ_4`/`_VERT_4` at `BLOCK_128X128`, spec |
| 569 | /// `partition_cdf_length`), so its forced-split gather sums 5 elements where | 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 | /// for a rectangular luma block (8x16, 16x8) or a PARTITION_HORZ/VERT strip is | 617 | /// for a rectangular luma block (8x16, 16x8) or a PARTITION_HORZ/VERT strip is |
| 671 | /// bigger than the real block in one axis. | 618 | /// bigger than the real block in one axis. |
| 672 | pub(crate) fn warp_plane_allowed(w: usize, h: usize) -> bool { | 619 | pub(crate) fn warp_plane_allowed(w: usize, h: usize) -> bool { |
| 673 | - if w >= 8 && h >= 8 { | 620 | + w >= 8 && h >= 8 |
| 674 | - return true; | ||
| 675 | - } | ||
| 676 | - hit!(WARP_PLANE_SUPPRESS_HITS); | ||
| 677 | - false | ||
| 678 | } | 621 | } |
| 679 | 622 | ||
| 680 | /// This frame's [`QUANT_DELTAS`] `(dc, ac)` pair for plane `plane_idx` (0 = | 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 | let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; | 723 | let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; |
| 781 | let reduced = if sign_negative { -abs } else { abs }; | 724 | let reduced = if sign_negative { -abs } else { abs }; |
| 782 | - hit!(DELTA_Q_HITS); | ||
| 783 | let res = fctx.delta_q_res.with(|c| c.get()); | 725 | let res = fctx.delta_q_res.with(|c| c.get()); |
| 784 | fctx.current_q_idx | 726 | fctx.current_q_idx |
| 785 | .with(|c| c.set((c.get() + reduced * res).clamp(1, 255))); | 727 | .with(|c| c.set((c.get() + reduced * res).clamp(1, 255))); |
| @@ -835,7 +777,6 @@ fn maybe_read_delta_lf( | |||
| 835 | let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; | 777 | let sign_negative = if abs != 0 { dec.literal(1) != 0 } else { true }; |
| 836 | let reduced = if sign_negative { -abs } else { abs }; | 778 | let reduced = if sign_negative { -abs } else { abs }; |
| 837 | cur[i] = (cur[i] + reduced * res).clamp(-63, 63); | 779 | cur[i] = (cur[i] + reduced * res).clamp(-63, 63); |
| 838 | - hit!(DELTA_LF_HITS); | ||
| 839 | } | 780 | } |
| 840 | fctx.current_delta_lf.with(|c| c.set(cur)); | 781 | fctx.current_delta_lf.with(|c| c.set(cur)); |
| 841 | } | 782 | } |
| @@ -863,7 +804,6 @@ fn maybe_read_cdef_idx( | |||
| 863 | } | 804 | } |
| 864 | let idx = dec.literal(u32::from(bits)) as u8; | 805 | let idx = dec.literal(u32::from(bits)) as u8; |
| 865 | fctx.cdef_transmitted.with(|c| c.set(true)); | 806 | fctx.cdef_transmitted.with(|c| c.set(true)); |
| 866 | - hit!(CDEF_IDX_HITS); | ||
| 867 | let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize); | 807 | let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize); |
| 868 | let sb_cols = fctx.cdef_sb_cols.with(|c| c.get()); | 808 | let sb_cols = fctx.cdef_sb_cols.with(|c| c.get()); |
| 869 | if sb_cols > 0 { | 809 | if sb_cols > 0 { |
| @@ -913,17 +853,6 @@ pub(crate) fn set_segmentation( | |||
| 913 | prev: Option<&[u8]>, | 853 | prev: Option<&[u8]>, |
| 914 | fctx: &crate::decode::FrameCtx, | 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 | fctx.seg.with(|s| *s.borrow_mut() = seg); | 856 | fctx.seg.with(|s| *s.borrow_mut() = seg); |
| 928 | fctx.seg_mi_dims.with(|c| c.set((mi_rows, mi_cols))); | 857 | fctx.seg_mi_dims.with(|c| c.set((mi_rows, mi_cols))); |
| 929 | fctx.seg_ids | 858 | fctx.seg_ids |
| @@ -950,19 +879,6 @@ pub(crate) fn take_segment_ids(fctx: &crate::decode::FrameCtx) -> Vec<u8> { | |||
| 950 | fctx.seg_ids.with(|m| m.borrow().clone()) | 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 | /// `seg_feature_active_idx(segment_id, feature)` for the frame currently | 882 | /// `seg_feature_active_idx(segment_id, feature)` for the frame currently |
| 967 | /// being decoded, with its `FeatureData` value. | 883 | /// being decoded, with its `FeatureData` value. |
| 968 | fn seg_feature(segment_id: usize, feature: usize, fctx: &crate::decode::FrameCtx) -> Option<i32> { | 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 | // lane-d792: which SEGMENT a block's quantizer came out of, beside the | 903 | // lane-d792: which SEGMENT a block's quantizer came out of, beside the |
| 988 | // `EC_DQCOEFF` grid rung -- a dequant that is too low with the levels | 904 | // `EC_DQCOEFF` grid rung -- a dequant that is too low with the levels |
| 989 | // already proven equal is a segment-id defect, not a quantizer one. | 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 | q | 906 | q |
| 998 | } | 907 | } |
| 999 | 908 | ||
| @@ -1163,17 +1072,10 @@ fn read_segment_id( | |||
| 1163 | return pred as u8; | 1072 | return pred as u8; |
| 1164 | } | 1073 | } |
| 1165 | let coded = dec.symbol(&mut cdfs.segment_id[ctx]) as i32; | 1074 | let coded = dec.symbol(&mut cdfs.segment_id[ctx]) as i32; |
| 1166 | - hit!(SEG_ID_HITS); | ||
| 1167 | let last_active = fctx.seg.with(|s| i32::from(s.borrow().last_active_seg_id)); | 1075 | let last_active = fctx.seg.with(|s| i32::from(s.borrow().last_active_seg_id)); |
| 1168 | let id = neg_deinterleave(coded, pred, last_active + 1).clamp(0, last_active); | 1076 | let id = neg_deinterleave(coded, pred, last_active + 1).clamp(0, last_active); |
| 1169 | // Mirrors the oracle's own `EC_SEG mi_row=.. cdf=.. pred=.. coded=.. id=..` | 1077 | // Mirrors the oracle's own `EC_SEG mi_row=.. cdf=.. pred=.. coded=.. id=..` |
| 1170 | // (libaom `decodemv.c:read_segment_id`), for a cross-decoder segment diff. | 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 | id as u8 | 1079 | id as u8 |
| 1178 | } | 1080 | } |
| 1179 | 1081 | ||
| @@ -1266,7 +1168,6 @@ fn inter_segment_id( | |||
| 1266 | let id = if temporal_update { | 1168 | let id = if temporal_update { |
| 1267 | let ctx = seg_pred_ctx(mi_r, mi_c, fctx); | 1169 | let ctx = seg_pred_ctx(mi_r, mi_c, fctx); |
| 1268 | let predicted = dec.symbol(&mut cdfs.segment_pred[ctx]) != 0; | 1170 | let predicted = dec.symbol(&mut cdfs.segment_pred[ctx]) != 0; |
| 1269 | - hit!(SEG_PRED_HITS); | ||
| 1270 | stamp_seg_pred(mi_r, mi_c, w_mi, h_mi, u8::from(predicted), fctx); | 1171 | stamp_seg_pred(mi_r, mi_c, w_mi, h_mi, u8::from(predicted), fctx); |
| 1271 | if predicted { | 1172 | if predicted { |
| 1272 | predicted_segment_id(mi_r, mi_c, w_mi, h_mi, fctx) | 1173 | predicted_segment_id(mi_r, mi_c, w_mi, h_mi, fctx) |
| @@ -1340,18 +1241,8 @@ fn tu_reach( | |||
| 1340 | row_off: usize, | 1241 | row_off: usize, |
| 1341 | tx: usize, | 1242 | tx: usize, |
| 1342 | block: Reach, | 1243 | block: Reach, |
| 1343 | - px: usize, | ||
| 1344 | - py: usize, | ||
| 1345 | - width: usize, | ||
| 1346 | - height: usize, | ||
| 1347 | - fctx: &crate::decode::FrameCtx, | ||
| 1348 | ) -> Reach { | 1244 | ) -> Reach { |
| 1349 | - let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, block); | 1245 | + 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 | ||
| 1355 | } | 1246 | } |
| 1356 | 1247 | ||
| 1357 | /// [`tu_reach`] for a unit whose LUMA footprint is a `tx_w` x `tx_h` rect | 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 | tx_w: usize, | 1261 | tx_w: usize, |
| 1371 | tx_h: usize, | 1262 | tx_h: usize, |
| 1372 | block: Reach, | 1263 | block: Reach, |
| 1373 | - px: usize, | ||
| 1374 | - py: usize, | ||
| 1375 | - width: usize, | ||
| 1376 | - height: usize, | ||
| 1377 | - fctx: &crate::decode::FrameCtx, | ||
| 1378 | ) -> Reach { | 1264 | ) -> Reach { |
| 1379 | - let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx_w, tx_h, block); | 1265 | + 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 | ||
| 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 | /// Records one decoded forward keyframe (see [`FWD_KF_HITS`]). | 1268 | /// Records one decoded forward keyframe (see [`FWD_KF_HITS`]). |
| 1395 | -pub(crate) fn note_fwd_kf() { | 1269 | +pub(crate) fn note_fwd_kf() {} |
| 1396 | - hit!(FWD_KF_HITS); | ||
| 1397 | -} | ||
| 1398 | 1270 | ||
| 1399 | thread_local! { | 1271 | thread_local! { |
| 1400 | static TXFM_SPLIT_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 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 | /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/ | 1275 | /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/ |
| 1410 | /// [`ENABLE_FILTER_INTRA_INTER`]. | 1276 | /// [`ENABLE_FILTER_INTRA_INTER`]. |
| 1411 | pub(crate) fn set_inter_tx_mode( | 1277 | pub(crate) fn set_inter_tx_mode( |
| @@ -1422,37 +1288,6 @@ pub(crate) fn set_inter_tx_mode( | |||
| 1422 | .with(|c| c.set(enable_filter_intra)); | 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 | // lane-av1muchroma site 1: the total number of samples by which | 1291 | // lane-av1muchroma site 1: the total number of samples by which |
| 1457 | // `decode_block`'s SKIP arm chroma bookkeeping grids fell SHORT of their own | 1292 | // `decode_block`'s SKIP arm chroma bookkeeping grids fell SHORT of their own |
| 1458 | // plane block, summed over every skipped block decoded. It reads the | 1293 | // plane block, summed over every skipped block decoded. It reads the |
| @@ -1467,12 +1302,6 @@ thread_local! { | |||
| 1467 | const { std::cell::Cell::new(0) }; | 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 | // Number of times `decode_block`'s SKIP arm ran at a shape where the | 1305 | // Number of times `decode_block`'s SKIP arm ran at a shape where the |
| 1477 | // per-axis and square chroma allocations DIFFER -- i.e. at 4:2:2, where | 1306 | // per-axis and square chroma allocations DIFFER -- i.e. at 4:2:2, where |
| 1478 | // the square is half the plane block. Zero on 4:2:0 and 4:4:4, where the | 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 | const { std::cell::Cell::new(0) }; | 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 | // lane-av1floorshift: the two FRAME chroma plane allocators | 1316 | // lane-av1floorshift: the two FRAME chroma plane allocators |
| 1494 | // (`decode_key_frame_tile_with_cdfs` and `decode_inter_tile`'s `PlaneBuf` trio) | 1317 | // (`decode_key_frame_tile_with_cdfs` and `decode_inter_tile`'s `PlaneBuf` trio) |
| 1495 | // size U and V as `(width >> ss_x) x (height >> ss_y)` with `width`/`height` | 1318 | // size U and V as `(width >> ss_x) x (height >> ss_y)` with `width`/`height` |
| @@ -1532,152 +1355,6 @@ thread_local! { | |||
| 1532 | const { std::cell::Cell::new(0) }; | 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 | /// A just-decoded palette-Y block's own predicted pixels | 1358 | /// A just-decoded palette-Y block's own predicted pixels |
| 1682 | /// (`side*side`, row-major, `colors[map[i]]`), consumed by | 1359 | /// (`side*side`, row-major, `colors[map[i]]`), consumed by |
| 1683 | /// [`PlaneBuf::reconstruct`]'s next call in place of `predict()` -- the | 1360 | /// [`PlaneBuf::reconstruct`]'s next call in place of `predict()` -- the |
| @@ -1724,27 +1401,12 @@ fn palette_window( | |||
| 1724 | /// `EC_DEBUG_PAL=1` traces every arm and every consumption with its call site. | 1401 | /// `EC_DEBUG_PAL=1` traces every arm and every consumption with its call site. |
| 1725 | #[track_caller] | 1402 | #[track_caller] |
| 1726 | fn set_palette_pred(buf: Vec<u16>, fctx: &crate::decode::FrameCtx) { | 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 | fctx.palette_pred.with(|c| *c.borrow_mut() = Some(buf)); | 1404 | fctx.palette_pred.with(|c| *c.borrow_mut() = Some(buf)); |
| 1736 | } | 1405 | } |
| 1737 | 1406 | ||
| 1738 | #[track_caller] | 1407 | #[track_caller] |
| 1739 | fn take_palette_pred(fctx: &crate::decode::FrameCtx) -> Option<Vec<u16>> { | 1408 | fn take_palette_pred(fctx: &crate::decode::FrameCtx) -> Option<Vec<u16>> { |
| 1740 | let got = fctx.palette_pred.with(|c| c.borrow_mut().take()); | 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 | got | 1410 | got |
| 1749 | } | 1411 | } |
| 1750 | 1412 | ||
| @@ -1809,13 +1471,6 @@ pub(crate) struct TxParams { | |||
| 1809 | /// ran on a frame that is NOT `CodedLossless`. | 1471 | /// ran on a frame that is NOT `CodedLossless`. |
| 1810 | static LOSSLESS_WHT_UNITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | 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 | /// lane-whtshape: 4x4 Walsh-Hadamard units reconstructed as part of a LOSSLESS | 1474 | /// lane-whtshape: 4x4 Walsh-Hadamard units reconstructed as part of a LOSSLESS |
| 1820 | /// transform unit that was itself NOT 4x4 -- a shape libaom cannot code. | 1475 | /// transform unit that was itself NOT 4x4 -- a shape libaom cannot code. |
| 1821 | /// `read_tx_mode` (`av1/decoder/decodeframe.c:140`) returns `ONLY_4X4` for a | 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 | static LOSSLESS_WHT_SPLIT_UNITS: std::sync::atomic::AtomicUsize = | 1487 | static LOSSLESS_WHT_SPLIT_UNITS: std::sync::atomic::AtomicUsize = |
| 1833 | std::sync::atomic::AtomicUsize::new(0); | 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 | impl TxParams { | 1490 | impl TxParams { |
| 1843 | /// The one copy of the produce-the-residual code. | 1491 | /// The one copy of the produce-the-residual code. |
| 1844 | fn run(self, grid: &[i32]) -> Vec<i32> { | 1492 | fn run(self, grid: &[i32]) -> Vec<i32> { |
| @@ -2179,14 +1827,6 @@ fn push_mc_rect( | |||
| 2179 | // localized a 4:4:4 intra-BC SKIP block committing its chroma plane block | 1827 | // localized a 4:4:4 intra-BC SKIP block committing its chroma plane block |
| 2180 | // at `(px/2, py/2)` instead of the ss origin, clobbering a neighbouring | 1828 | // at `(px/2, py/2)` instead of the ss origin, clobbering a neighbouring |
| 2181 | // block's reconstruction (lanes/av1ibcfork.report.md). | 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 | let Some((src, stride)) = prediction.inline(stride) else { | 1830 | let Some((src, stride)) = prediction.inline(stride) else { |
| 2191 | let Pred::Cur { | 1831 | let Pred::Cur { |
| 2192 | plane: sp, | 1832 | plane: sp, |
| @@ -2501,7 +2141,7 @@ fn exec_mc( | |||
| 2501 | 1 => &mut *u, | 2141 | 1 => &mut *u, |
| 2502 | _ => &mut *v, | 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 | // The `tx_type` the last plane-0 [`read_plane`] actually coded, kept so | 2147 | // The `tx_type` the last plane-0 [`read_plane`] actually coded, kept so |
| @@ -2532,11 +2172,6 @@ thread_local! { | |||
| 2532 | static RECT_INTRABC_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 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 | thread_local! { | 2175 | thread_local! { |
| 2541 | /// lane-av1-ibc128chunk: the mu-chunk walk's per-axis chroma extents, as | 2176 | /// lane-av1-ibc128chunk: the mu-chunk walk's per-axis chroma extents, as |
| 2542 | /// `(64 >> ss_x) << 8 | (64 >> ss_y)` on the LAST chunk -- the pair the | 2177 | /// `(64 >> ss_x) << 8 | (64 >> ss_y)` on the LAST chunk -- the pair the |
| @@ -2546,12 +2181,6 @@ thread_local! { | |||
| 2546 | const { std::cell::Cell::new(0) }; | 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 | /// Records one coded block into [`INTRABC_MI_GRID`]: every block contributes | 2184 | /// Records one coded block into [`INTRABC_MI_GRID`]: every block contributes |
| 2556 | /// its size (libaom's `scan_row_mbmi` advances `processed_rows` off any | 2185 | /// its size (libaom's `scan_row_mbmi` advances `processed_rows` off any |
| 2557 | /// candidate's `bsize`, ref-match or not), an intrabc one also its DV as an | 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 | /// Bump [`FIMV_FRAME_HITS`] -- called once per decoded frame header whose | 2261 | /// Bump [`FIMV_FRAME_HITS`] -- called once per decoded frame header whose |
| 2633 | /// `force_integer_mv` bit is set. | 2262 | /// `force_integer_mv` bit is set. |
| 2634 | -pub fn note_force_integer_mv_frame() { | 2263 | +pub fn note_force_integer_mv_frame() {} |
| 2635 | - hit!(FIMV_FRAME_HITS); | ||
| 2636 | -} | ||
| 2637 | 2264 | ||
| 2638 | // lane-t900 r27: OBMC blends that actually READ a recorded switchable filter | 2265 | // lane-t900 r27: OBMC blends that actually READ a recorded switchable filter |
| 2639 | // off the neighbour band -- the positive half of the proof for "an OBMC | 2266 | // off the neighbour band -- the positive half of the proof for "an OBMC |
| @@ -2645,48 +2272,6 @@ thread_local! { | |||
| 2645 | static OBMC_FILTER_BAND_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 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 | thread_local! { | 2275 | thread_local! { |
| 2691 | static UV_LEFT_SS_Y_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 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 | static UV_OWNER_EPOCH: std::cell::Cell<u32> = const { std::cell::Cell::new(0) }; | 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 | /// One 16x4 / 4x16 inter strip's chroma situation, handed to | 2290 | /// One 16x4 / 4x16 inter strip's chroma situation, handed to |
| 2733 | /// [`decode_inter_block`] out of band (the same one-shot thread-local idiom | 2291 | /// [`decode_inter_block`] out of band (the same one-shot thread-local idiom |
| 2734 | /// `REDUCED_TX_SET_INTER` uses) rather than through twenty-three call sites | 2292 | /// `REDUCED_TX_SET_INTER` uses) rather than through twenty-three call sites |
| @@ -2750,18 +2308,6 @@ pub(crate) struct InterStripChroma { | |||
| 2750 | prev: Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>, | 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 | /// Everything [`decode_inter_block`] needs to fold temporal MV candidates | 2311 | /// Everything [`decode_inter_block`] needs to fold temporal MV candidates |
| 2766 | /// (spec 7.10.2.8), threaded down from [`decode_inter_frame_tile_with_cdfs`]: | 2312 | /// (spec 7.10.2.8), threaded down from [`decode_inter_frame_tile_with_cdfs`]: |
| 2767 | /// the current frame's own projected field ([`crate::motion_field::setup_motion_field`]'s | 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 | crate::par::run_bands_mut(&bands, cols, fctx, cells, |r0, r1, mine, _| { | 2420 | crate::par::run_bands_mut(&bands, cols, fctx, cells, |r0, r1, mine, _| { |
| 2875 | fill(r0, r1, mine); | 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 | field | 2423 | field |
| 2884 | } | 2424 | } |
| 2885 | 2425 | ||
| @@ -2923,38 +2463,12 @@ pub fn cdef_mixed_skip_units() -> usize { | |||
| 2923 | CDEF_MIXED_SKIP_UNITS.with(|c| c.get()) | 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 | /// How many 8x8 CDEF units [`apply_cdef`] visited whose skip band no coded | 2466 | /// How many 8x8 CDEF units [`apply_cdef`] visited whose skip band no coded |
| 2933 | /// block wrote this frame -- a writer gap, always a defect (lane-cdefstrip r1). | 2467 | /// block wrote this frame -- a writer gap, always a defect (lane-cdefstrip r1). |
| 2934 | pub fn cdef_unwritten_skip_units() -> usize { | 2468 | pub fn cdef_unwritten_skip_units() -> usize { |
| 2935 | CDEF_UNWRITTEN_SKIP_UNITS.with(|c| c.get()) | 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 | // Which plane the in-flight INTRA reconstruction is writing (0=Y, 1=U, 2=V). | 2472 | // Which plane the in-flight INTRA reconstruction is writing (0=Y, 1=U, 2=V). |
| 2959 | // lane-av1cmpaudit: aomdec's `EC_PREDOUT8`/`EC_PREDND` print `plane=`, and | 2473 | // lane-av1cmpaudit: aomdec's `EC_PREDOUT8`/`EC_PREDND` print `plane=`, and |
| 2960 | // without the same field on our side an `EC_PREDOUT8` vs `OUR_PRED` diff of a | 2474 | // without the same field on our side an `EC_PREDOUT8` vs `OUR_PRED` diff of a |
| @@ -2966,11 +2480,6 @@ thread_local! { | |||
| 2966 | static RECON_PLANE: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 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 | /// Restores [`RECON_PLANE`] on drop, so `exec_intra` needs no cleanup path on | 2483 | /// Restores [`RECON_PLANE`] on drop, so `exec_intra` needs no cleanup path on |
| 2975 | /// either of its two early returns. | 2484 | /// either of its two early returns. |
| 2976 | struct PlaneGuard(usize); | 2485 | struct PlaneGuard(usize); |
| @@ -3030,12 +2539,6 @@ const MAX_BR_LEVEL: i32 = NUM_BASE_LEVELS + COEFF_BASE_RANGE; | |||
| 3030 | const VERT_ALIKE: [usize; 6] = [2, PARTITION_SPLIT, 4, 6, 7, 9]; | 2539 | const VERT_ALIKE: [usize; 6] = [2, PARTITION_SPLIT, 4, 6, 7, 9]; |
| 3031 | const HORZ_ALIKE: [usize; 6] = [1, PARTITION_SPLIT, 4, 5, 6, 8]; | 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 | fn element_prob(cdf: &[u16], element: usize) -> u16 { | 2542 | fn element_prob(cdf: &[u16], element: usize) -> u16 { |
| 3040 | cdf[element] - if element > 0 { cdf[element - 1] } else { 0 } | 2543 | cdf[element] - if element > 0 { cdf[element - 1] } else { 0 } |
| 3041 | } | 2544 | } |
| @@ -3241,9 +2744,6 @@ fn base_ctx( | |||
| 3241 | // once; `base_ctx_rect_offsets_match_the_transcribed_tables_over_the_whole_domain` | 2744 | // once; `base_ctx_rect_offsets_match_the_transcribed_tables_over_the_whole_domain` |
| 3242 | // pins the rule against the tables over their whole 5x5 domain. | 2745 | // pins the rule against the tables over their whole 5x5 domain. |
| 3243 | if let Some((w, h)) = rect_shape { | 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 | if w < h && row < 2 { | 2747 | if w < h && row < 2 { |
| 3248 | return ctx + 11; | 2748 | return ctx + 11; |
| 3249 | } | 2749 | } |
| @@ -3657,7 +3157,6 @@ fn read_eob(dec: &mut SymbolDecoder, coding: &mut TxbTables, class: TxClass) -> | |||
| 3657 | const GROUP_START: [usize; 12] = [0, 1, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513]; | 3157 | const GROUP_START: [usize; 12] = [0, 1, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513]; |
| 3658 | const OFFSET_BITS: [u32; 12] = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | 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 | // libaom's `eob_flag_cdf*` tables carry a second dimension the 2D scan | 3160 | // libaom's `eob_flag_cdf*` tables carry a second dimension the 2D scan |
| 3662 | // never touches: `TX_CLASS_HORIZ`/`TX_CLASS_VERT` (`V_DCT`/`H_DCT`) adapt | 3161 | // never touches: `TX_CLASS_HORIZ`/`TX_CLASS_VERT` (`V_DCT`/`H_DCT`) adapt |
| 3663 | // a wholly separate CDF from every other tx_type (`decodetxb.c`'s | 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 | (TxClass::TwoD, _) | (_, None) => coding.eob_pt, | 3167 | (TxClass::TwoD, _) | (_, None) => coding.eob_pt, |
| 3669 | (_, Some(class1)) => class1, | 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 | let group = dec.symbol(eob_pt) + 1; | 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 | let bits = OFFSET_BITS[group]; | 3171 | let bits = OFFSET_BITS[group]; |
| 3681 | let mut offset = 0u32; | 3172 | let mut offset = 0u32; |
| 3682 | if bits > 0 { | 3173 | if bits > 0 { |
| 3683 | let top = dec.symbol(&mut coding.eob_extra[group - 3]) as u32; | 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 | offset = top << (bits - 1); | 3175 | offset = top << (bits - 1); |
| 3688 | if bits > 1 { | 3176 | if bits > 1 { |
| 3689 | offset |= dec.literal(bits - 1); | 3177 | offset |= dec.literal(bits - 1); |
| @@ -3792,6 +3280,3 @@ pub(crate) fn decode_key_frame_tile( | |||
| 3792 | 3280 | ||
| 3793 | #[cfg(test)] | 3281 | #[cfg(test)] |
| 3794 | mod tests; | 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 | coeff_shift: i32, | 32 | coeff_shift: i32, |
| 33 | damping: i32, | 33 | damping: i32, |
| 34 | damping_uv: i32, | 34 | damping_uv: i32, |
| 35 | - (frame_w, frame_h): (usize, usize), | ||
| 36 | r_lo0: usize, | 35 | r_lo0: usize, |
| 37 | r_hi0: usize, | 36 | r_hi0: usize, |
| 38 | fctx: &crate::decode::FrameCtx, | 37 | fctx: &crate::decode::FrameCtx, |
| @@ -68,16 +67,16 @@ fn cdef_rows( | |||
| 68 | .enumerate() | 67 | .enumerate() |
| 69 | .map(|(k, &(a, b))| { | 68 | .map(|(k, &(a, b))| { |
| 70 | let start = row_of(a, p) * geom[p].stride; | 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 | (start, end) | 75 | (start, end) |
| 73 | }) | 76 | }) |
| 74 | .collect() | 77 | .collect() |
| 75 | }; | 78 | }; |
| 76 | - let (yd, ud, vd) = ( | 79 | + let (yd, ud, vd) = (y.data.to_mut(), u.data.to_mut(), v.data.to_mut()); |
| 77 | - y.data.to_mut(), | ||
| 78 | - u.data.to_mut(), | ||
| 79 | - v.data.to_mut(), | ||
| 80 | - ); | ||
| 81 | let (ry, ru, rv) = ( | 80 | let (ry, ru, rv) = ( |
| 82 | plane_ranges(0, yd.len()), | 81 | plane_ranges(0, yd.len()), |
| 83 | plane_ranges(1, ud.len()), | 82 | plane_ranges(1, ud.len()), |
| @@ -97,7 +96,10 @@ fn cdef_rows( | |||
| 97 | (start, end) | 96 | (start, end) |
| 98 | }) | 97 | }) |
| 99 | .collect(); | 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 | None => (0..n).map(|_| None).collect(), | 104 | None => (0..n).map(|_| None).collect(), |
| 103 | }; | 105 | }; |
| @@ -130,7 +132,6 @@ fn cdef_rows( | |||
| 130 | coeff_shift, | 132 | coeff_shift, |
| 131 | damping, | 133 | damping, |
| 132 | damping_uv, | 134 | damping_uv, |
| 133 | - (frame_w, frame_h), | ||
| 134 | fctx, | 135 | fctx, |
| 135 | ); | 136 | ); |
| 136 | }); | 137 | }); |
| @@ -144,9 +145,6 @@ pub(super) fn apply_cdef( | |||
| 144 | v: &mut PlaneBuf<'static>, | 145 | v: &mut PlaneBuf<'static>, |
| 145 | cdef: &CdefParams, | 146 | cdef: &CdefParams, |
| 146 | skip_grid: &Neighbours, | 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 | fctx: &crate::decode::FrameCtx, | 148 | fctx: &crate::decode::FrameCtx, |
| 151 | // lane-av1cap: every CDEF unit reads the PRE-CDEF planes, so the filter | 149 | // lane-av1cap: every CDEF unit reads the PRE-CDEF planes, so the filter |
| 152 | // starts by copying all three (~19 MB at 4K). The encoder's filter | 150 | // starts by copying all three (~19 MB at 4K). The encoder's filter |
| @@ -161,10 +159,6 @@ pub(super) fn apply_cdef( | |||
| 161 | wrote: Option<&mut [u8]>, | 159 | wrote: Option<&mut [u8]>, |
| 162 | ) { | 160 | ) { |
| 163 | // lane-part32 r2 debug rung, env-gated: see `apply_deblock`'s sibling. | 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 | // `cdef.bits == 0` still means "no filtering at all" whenever the single | 162 | // `cdef.bits == 0` still means "no filtering at all" whenever the single |
| 169 | // (index 0) strength pair is all-zero -- the fast path every existing | 163 | // (index 0) strength pair is all-zero -- the fast path every existing |
| 170 | // gate stream takes. A `bits > 0` frame can still be all-zero-strength | 164 | // gate stream takes. A `bits > 0` frame can still be all-zero-strength |
| @@ -215,7 +209,6 @@ pub(super) fn apply_cdef( | |||
| 215 | coeff_shift, | 209 | coeff_shift, |
| 216 | damping, | 210 | damping, |
| 217 | damping_uv, | 211 | damping_uv, |
| 218 | - (frame_w, frame_h), | ||
| 219 | 0, | 212 | 0, |
| 220 | skip_grid.mi_rows, | 213 | skip_grid.mi_rows, |
| 221 | fctx, | 214 | fctx, |
| @@ -296,9 +289,6 @@ pub(super) fn apply_loop_restoration( | |||
| 296 | fctx: &crate::decode::FrameCtx, | 289 | fctx: &crate::decode::FrameCtx, |
| 297 | ) { | 290 | ) { |
| 298 | // lane-svt1 debug rung, env-gated: see `apply_cdef`/`apply_deblock`'s siblings. | 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 | let mut out = scratch_empty(); | 292 | let mut out = scratch_empty(); |
| 303 | crate::restoration::apply_loop_restoration_plane( | 293 | crate::restoration::apply_loop_restoration_plane( |
| 304 | &y.data, | 294 | &y.data, |
crates/ec-av1/src/decode/rect.rsmodified+5 -506
| @@ -61,42 +61,15 @@ pub(super) fn read_intra_mode_rect( | |||
| 61 | // `palette_uv` even on a chroma-reference strip. Fold the plane count | 61 | // `palette_uv` even on a chroma-reference strip. Fold the plane count |
| 62 | // into the same `has_chroma` this reader already gates on. | 62 | // into the same `has_chroma` this reader already gates on. |
| 63 | let has_chroma = has_chroma && !mono(fctx); | 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 | macro_rules! istep { | 64 | macro_rules! istep { |
| 79 | - ($name:literal, $val:expr) => { | 65 | + ($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 | - }; | ||
| 88 | } | 66 | } |
| 89 | // lane-sbrect10 r1: libaom `is_cfl_allowed` (blockd.h) is | 67 | // lane-sbrect10 r1: libaom `is_cfl_allowed` (blockd.h) is |
| 90 | // `block_size_wide <= 32 && block_size_high <= 32` -- enforce it HERE, at | 68 | // `block_size_wide <= 32 && block_size_high <= 32` -- enforce it HERE, at |
| 91 | // the one point every rect caller routes through, so no call site can | 69 | // the one point every rect caller routes through, so no call site can |
| 92 | // offer the 14-symbol CFL alphabet on a 64-axis block (class | 70 | // offer the 14-symbol CFL alphabet on a 64-axis block (class |
| 93 | // wrong-alphabet-same-value: same value, wrong interval, silent desync). | 71 | // wrong-alphabet-same-value: same value, wrong interval, silent desync). |
| 94 | - let cfl = if cfl && bw.max(bh) > 32 { | 72 | + let cfl = if cfl && bw.max(bh) > 32 { false } else { cfl }; |
| 95 | - hit!(NOCFL_UV_MODE_HITS); | ||
| 96 | - false | ||
| 97 | - } else { | ||
| 98 | - cfl | ||
| 99 | - }; | ||
| 100 | // lane-intra14 r1: on the INTER block path everything up to and including | 73 | // lane-intra14 r1: on the INTER block path everything up to and including |
| 101 | // `is_inter` was already read by [`decode_inter_block`], so this reader | 74 | // `is_inter` was already read by [`decode_inter_block`], so this reader |
| 102 | // starts at the mode syntax with the `skip` that caller read. | 75 | // starts at the mode syntax with the `skip` that caller read. |
| @@ -134,10 +107,8 @@ pub(super) fn read_intra_mode_rect( | |||
| 134 | // refused by name when it fires. | 107 | // refused by name when it fires. |
| 135 | if allow_intrabc_frame(fctx) { | 108 | if allow_intrabc_frame(fctx) { |
| 136 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; | 109 | let use_intrabc = dec.symbol(&mut cdfs.intrabc) != 0; |
| 137 | - hit!(RECT_INTRABC_READS); | ||
| 138 | istep!("intrabc", use_intrabc as i32); | 110 | istep!("intrabc", use_intrabc as i32); |
| 139 | if use_intrabc { | 111 | if use_intrabc { |
| 140 | - hit!(INTRABC_HITS); | ||
| 141 | // libaom `read_intrabc_info`: the DV read, then an immediate | 112 | // libaom `read_intrabc_info`: the DV read, then an immediate |
| 142 | // return out of the mode-info read -- no `y_mode`, no `uv_mode`, | 113 | // return out of the mode-info read -- no `y_mode`, no `uv_mode`, |
| 143 | // no angle deltas, no palette, no filter intra. The caller owns | 114 | // no angle deltas, no palette, no filter intra. The caller owns |
| @@ -163,7 +134,6 @@ pub(super) fn read_intra_mode_rect( | |||
| 163 | // frame's `read_intra_frame_mode_info` (decodemv.c:1065 `read_intra_mode` | 134 | // frame's `read_intra_frame_mode_info` (decodemv.c:1065 `read_intra_mode` |
| 164 | // off `kf_y_mode_cdf[above][left]`). | 135 | // off `kf_y_mode_cdf[above][left]`). |
| 165 | let mode = if let Some((size_group, _)) = inter { | 136 | let mode = if let Some((size_group, _)) = inter { |
| 166 | - crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | ||
| 167 | dec.symbol(&mut cdfs.y_mode[size_group]) | 137 | dec.symbol(&mut cdfs.y_mode[size_group]) |
| 168 | } else { | 138 | } else { |
| 169 | let above_ctx = INTRA_MODE_CTX[above_mode]; | 139 | let above_ctx = INTRA_MODE_CTX[above_mode]; |
| @@ -188,10 +158,8 @@ pub(super) fn read_intra_mode_rect( | |||
| 188 | let uv_mode = if !has_chroma { | 158 | let uv_mode = if !has_chroma { |
| 189 | DC_PRED | 159 | DC_PRED |
| 190 | } else if cfl { | 160 | } else if cfl { |
| 191 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 192 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 161 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 193 | } else { | 162 | } else { |
| 194 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 195 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 163 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 196 | }; | 164 | }; |
| 197 | istep!("uv_mode", uv_mode as i32); | 165 | istep!("uv_mode", uv_mode as i32); |
| @@ -200,19 +168,12 @@ pub(super) fn read_intra_mode_rect( | |||
| 200 | } else { | 168 | } else { |
| 201 | None | 169 | None |
| 202 | }; | 170 | }; |
| 203 | - if has_chroma && (9..=12).contains(&uv_mode) { | ||
| 204 | - hit!(SMOOTH_UV_HITS); | ||
| 205 | - } | ||
| 206 | let angle_delta_uv = if has_chroma && (V_PRED..=D67_PRED).contains(&uv_mode) { | 171 | let angle_delta_uv = if has_chroma && (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 207 | - hit!(DIRECTIONAL_UV_HITS); | ||
| 208 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | 172 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 209 | } else { | 173 | } else { |
| 210 | 0 | 174 | 0 |
| 211 | }; | 175 | }; |
| 212 | istep!("angle_uv", angle_delta_uv); | 176 | istep!("angle_uv", angle_delta_uv); |
| 213 | - if angle_delta_uv != 0 { | ||
| 214 | - hit!(UV_ANGLE_DELTA_HITS); | ||
| 215 | - } | ||
| 216 | // `read_palette_mode_info` (spec 5.11.13), rect-generalised | 177 | // `read_palette_mode_info` (spec 5.11.13), rect-generalised |
| 217 | // (lane-palette2 r4): same bsize-ctx-gated read as [`read_intra_mode`], | 178 | // (lane-palette2 r4): same bsize-ctx-gated read as [`read_intra_mode`], |
| 218 | // just keyed by [`palette_bsize_ctx_wh`] instead of the square-only | 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 | let mut palette_y_pending: Option<(usize, [u16; 8])> = None; | 184 | let mut palette_y_pending: Option<(usize, [u16; 8])> = None; |
| 224 | let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; | 185 | let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; |
| 225 | if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh) { | 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 | let (mode_ctx, cache) = palette.unwrap_or((0, &[])); | 187 | let (mode_ctx, cache) = palette.unwrap_or((0, &[])); |
| 231 | let use_palette_y = | 188 | let use_palette_y = |
| 232 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][mode_ctx]) != 0; | 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 | let mut filter_intra = None; | 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 | // As the square path: `av1_filter_intra_allowed` excludes a palette-Y | 207 | // As the square path: `av1_filter_intra_allowed` excludes a palette-Y |
| 260 | // block (reconintra.h:77), so no `use_filter_intra` symbol exists there. | 208 | // block (reconintra.h:77), so no `use_filter_intra` symbol exists there. |
| 261 | if mode == DC_PRED | 209 | if mode == DC_PRED |
| @@ -264,12 +212,8 @@ pub(super) fn read_intra_mode_rect( | |||
| 264 | && let Some(class) = filter_intra_size_class_rect(bw, bh) | 212 | && let Some(class) = filter_intra_size_class_rect(bw, bh) |
| 265 | { | 213 | { |
| 266 | let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[class]) != 0; | 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 | istep!("use_filter_intra", use_filter_intra as i32); | 215 | istep!("use_filter_intra", use_filter_intra as i32); |
| 271 | if use_filter_intra { | 216 | if use_filter_intra { |
| 272 | - hit!(FILTER_INTRA_HITS); | ||
| 273 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); | 217 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 274 | istep!("filter_intra_mode", fi_mode as i32); | 218 | istep!("filter_intra_mode", fi_mode as i32); |
| 275 | filter_intra = Some(fi_mode); | 219 | filter_intra = Some(fi_mode); |
| @@ -287,8 +231,6 @@ pub(super) fn read_intra_mode_rect( | |||
| 287 | palette_onscreen(mi_r, mi_c, bw, bh, fctx), | 231 | palette_onscreen(mi_r, mi_c, bw, bh, fctx), |
| 288 | false, | 232 | false, |
| 289 | ); | 233 | ); |
| 290 | - hit!(PALETTE_HITS); | ||
| 291 | - hit!(PALETTE_RECT_HITS); | ||
| 292 | PaletteY { | 234 | PaletteY { |
| 293 | size: n, | 235 | size: n, |
| 294 | colors, | 236 | colors, |
| @@ -309,7 +251,6 @@ pub(super) fn read_intra_mode_rect( | |||
| 309 | (ss_x(fctx), ss_y(fctx)), | 251 | (ss_x(fctx), ss_y(fctx)), |
| 310 | ); | 252 | ); |
| 311 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true); | 253 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true); |
| 312 | - hit!(PALETTE_UV_HITS); | ||
| 313 | PaletteUv { | 254 | PaletteUv { |
| 314 | size: n, | 255 | size: n, |
| 315 | u_colors, | 256 | u_colors, |
| @@ -352,9 +293,6 @@ pub(super) fn record_strip_palette( | |||
| 352 | // the neighbour bands (`EC_PALPUB=1`) -- the rung that names which decode | 293 | // the neighbour bands (`EC_PALPUB=1`) -- the rung that names which decode |
| 353 | // path left a stale `left_palette_size` behind when | 294 | // path left a stale `left_palette_size` behind when |
| 354 | // `av1_get_palette_mode_ctx` disagrees with libaom's. | 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 | // lane-kf900 r6: the palette side bands are mi-granular now, so a strip | 296 | // lane-kf900 r6: the palette side bands are mi-granular now, so a strip |
| 359 | // writes its OWN span on BOTH axes -- the old `last` split-axis rule only | 297 | // writes its OWN span on BOTH axes -- the old `last` split-axis rule only |
| 360 | // existed because the 16px [`SUB`] cell held one slot for all the strips | 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 | at_mi: (usize, usize), | 459 | at_mi: (usize, usize), |
| 522 | bw: usize, | 460 | bw: usize, |
| 523 | bh: usize, | 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 | tx_w: usize, | 462 | tx_w: usize, |
| 529 | tx_h: usize, | 463 | tx_h: usize, |
| 530 | m: &RectStripModes, | 464 | m: &RectStripModes, |
| 531 | y: &mut PlaneBuf<'static>, | 465 | y: &mut PlaneBuf<'static>, |
| 532 | u: &mut PlaneBuf<'static>, | 466 | u: &mut PlaneBuf<'static>, |
| 533 | v: &mut PlaneBuf<'static>, | 467 | v: &mut PlaneBuf<'static>, |
| 534 | - base_q_idx: u8, | ||
| 535 | reduced_tx_set: bool, | 468 | reduced_tx_set: bool, |
| 536 | fctx: &crate::decode::FrameCtx, | 469 | fctx: &crate::decode::FrameCtx, |
| 537 | ) -> Result<()> { | 470 | ) -> Result<()> { |
| @@ -610,32 +543,6 @@ pub(super) fn decode_rect_split( | |||
| 610 | (chroma_w, chroma_h), | 543 | (chroma_w, chroma_h), |
| 611 | (64, 32) | (32, 64) | (64, 16) | (16, 64) | (32, 32) | (16, 16) | (8, 8) | 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 | // lane-rectsplit r2 (verifier finding): with both callers wired | 546 | // lane-rectsplit r2 (verifier finding): with both callers wired |
| 640 | // (`decode_block_rect`'s 32x16/16x32 and `decode_block_rect64`'s | 547 | // (`decode_block_rect`'s 32x16/16x32 and `decode_block_rect64`'s |
| 641 | // 64x32/32x64) every shape that reaches here has a table above, so this | 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 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", | 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 | // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. | 558 | // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. |
| 656 | // A square unit reads through the ordinary square [`read_plane`]; a rect | 559 | // A square unit reads through the ordinary square [`read_plane`]; a rect |
| 657 | // one (a 1:4 strip's first split) reads through [`read_coeffs_rect`] with | 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 | // (`av1_get_ext_tx_set_type` resolves EXT_TX_SET_DCTONLY once | 686 | // (`av1_get_ext_tx_set_type` resolves EXT_TX_SET_DCTONLY once |
| 784 | // the square-up size is TX_64X64), and this unit covers its | 687 | // the square-up size is TX_64X64), and this unit covers its |
| 785 | // whole block, so `get_txb_ctx` gives txb_skip ctx 0 flat. | 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 | let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; | 689 | let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; |
| 797 | let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra)); | 690 | let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra)); |
| 798 | let (corner, tu_tx_type) = read_coeffs( | 691 | let (corner, tu_tx_type) = read_coeffs( |
| @@ -870,7 +763,6 @@ pub(super) fn decode_rect_split( | |||
| 870 | tu_skip_ctx, | 763 | tu_skip_ctx, |
| 871 | dc_sign_ctx(tu_around.2), | 764 | dc_sign_ctx(tu_around.2), |
| 872 | TxType::DctDct, | 765 | TxType::DctDct, |
| 873 | - 0, | ||
| 874 | )?; | 766 | )?; |
| 875 | let residual = dequant_and_inverse_typed_wh( | 767 | let residual = dequant_and_inverse_typed_wh( |
| 876 | &tu_grid, | 768 | &tu_grid, |
| @@ -926,7 +818,6 @@ pub(super) fn decode_rect_split( | |||
| 926 | tu_py, | 818 | tu_py, |
| 927 | tx_w, | 819 | tx_w, |
| 928 | tx_w, | 820 | tx_w, |
| 929 | - base_q_idx, | ||
| 930 | None, | 821 | None, |
| 931 | m.filter_intra, | 822 | m.filter_intra, |
| 932 | Some(tu_skip_ctx), | 823 | Some(tu_skip_ctx), |
| @@ -1122,7 +1013,6 @@ pub(super) fn decode_rect_split( | |||
| 1122 | // `REFUSED: unsupported: AV1 tile (a Golomb tail longer | 1013 | // `REFUSED: unsupported: AV1 tile (a Golomb tail longer |
| 1123 | // than this decoder reads)`. | 1014 | // than this decoder reads)`. |
| 1124 | if cpx + cu_col * 4 >= u.true_width || cpy + cu_row * 4 >= u.true_height { | 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 | continue; | 1016 | continue; |
| 1127 | } | 1017 | } |
| 1128 | let cu_mi = (mi_r + cu_row * (span_y / MI), mi_c + cu_col * (span_x / MI)); | 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 | cu_row * span_y, | 1044 | cu_row * span_y, |
| 1155 | span_x, | 1045 | span_x, |
| 1156 | block_reach, | 1046 | block_reach, |
| 1157 | - px, | ||
| 1158 | - py, | ||
| 1159 | - y.width, | ||
| 1160 | - y.height, | ||
| 1161 | - fctx, | ||
| 1162 | ); | 1047 | ); |
| 1163 | let (cu_x, cu_y) = (cpx + cu_col * 4, cpy + cu_row * 4); | 1048 | let (cu_x, cu_y) = (cpx + cu_col * 4, cpy + cu_row * 4); |
| 1164 | if let Some((ub, vb)) = &m.palette_uv { | 1049 | if let Some((ub, vb)) = &m.palette_uv { |
| @@ -1186,7 +1071,6 @@ pub(super) fn decode_rect_split( | |||
| 1186 | cu_y, | 1071 | cu_y, |
| 1187 | 4, | 1072 | 4, |
| 1188 | 4, | 1073 | 4, |
| 1189 | - base_q_idx, | ||
| 1190 | m.alpha | 1074 | m.alpha |
| 1191 | .zip(ac) | 1075 | .zip(ac) |
| 1192 | .map(|((au, av), ac)| (if plane_idx == 1 { au } else { av }, ac)), | 1076 | .map(|((au, av), ac)| (if plane_idx == 1 { au } else { av }, ac)), |
| @@ -1195,9 +1079,6 @@ pub(super) fn decode_rect_split( | |||
| 1195 | m.smooth_neighbor_uv, | 1079 | m.smooth_neighbor_uv, |
| 1196 | fctx, | 1080 | fctx, |
| 1197 | )?; | 1081 | )?; |
| 1198 | - if span_x == 4 && span_y == 4 { | ||
| 1199 | - hit!(RECT_SPLIT_LOSSLESS_CHROMA444_HITS); | ||
| 1200 | - } | ||
| 1201 | neighbours.record_mi_chroma(cu_mi, span_x, span_y, plane_idx, &grid); | 1082 | neighbours.record_mi_chroma(cu_mi, span_x, span_y, plane_idx, &grid); |
| 1202 | ll_chroma_units.push((cu_mi, plane_idx, grid.clone(), span_x, span_y)); | 1083 | ll_chroma_units.push((cu_mi, plane_idx, grid.clone(), span_x, span_y)); |
| 1203 | last[plane_idx - 1] = grid; | 1084 | last[plane_idx - 1] = grid; |
| @@ -1229,12 +1110,6 @@ pub(super) fn decode_rect_split( | |||
| 1229 | }; | 1110 | }; |
| 1230 | // lane-av1-422: the witness counter, keyed to ss (1,0) so only a 4:2:2 | 1111 | // lane-av1-422: the witness counter, keyed to ss (1,0) so only a 4:2:2 |
| 1231 | // frame's square chroma units count it. | 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 | let (nw, nh) = (chroma_block_w / uw, chroma_block_h / uh); | 1113 | let (nw, nh) = (chroma_block_w / uw, chroma_block_h / uh); |
| 1239 | // lane-av1-422stripanchor: the pair's plane block is BLOCK_INVALID | 1114 | // lane-av1-422stripanchor: the pair's plane block is BLOCK_INVALID |
| 1240 | // whatever the pair size (`num_pels_log2_lookup[255]` reads 0xff in | 1115 | // whatever the pair size (`num_pels_log2_lookup[255]` reads 0xff in |
| @@ -1354,24 +1229,7 @@ pub(super) fn decode_rect_split( | |||
| 1354 | uw << ss_x(fctx), | 1229 | uw << ss_x(fctx), |
| 1355 | uh << ss_y(fctx), | 1230 | uh << ss_y(fctx), |
| 1356 | reach, | 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 | // 32x32 does not fit read_coeffs_rect's scratch (768). The | 1233 | // 32x32 does not fit read_coeffs_rect's scratch (768). The |
| 1376 | // square reader is the path every other 32x32 chroma unit uses. | 1234 | // square reader is the path every other 32x32 chroma unit uses. |
| 1377 | let levels = if uw == uh { | 1235 | let levels = if uw == uh { |
| @@ -1393,7 +1251,6 @@ pub(super) fn decode_rect_split( | |||
| 1393 | cu_y, | 1251 | cu_y, |
| 1394 | uw, | 1252 | uw, |
| 1395 | uw, | 1253 | uw, |
| 1396 | - base_q_idx, | ||
| 1397 | cfl, | 1254 | cfl, |
| 1398 | None, | 1255 | None, |
| 1399 | bigger.then_some(3), | 1256 | bigger.then_some(3), |
| @@ -1414,7 +1271,6 @@ pub(super) fn decode_rect_split( | |||
| 1414 | skip_ctx, | 1271 | skip_ctx, |
| 1415 | dc_sign_ctx(cu_around[plane_idx].2), | 1272 | dc_sign_ctx(cu_around[plane_idx].2), |
| 1416 | default_tx, | 1273 | default_tx, |
| 1417 | - plane_idx, | ||
| 1418 | )?; | 1274 | )?; |
| 1419 | let residual = dequant_and_inverse_typed_wh( | 1275 | let residual = dequant_and_inverse_typed_wh( |
| 1420 | &levels, | 1276 | &levels, |
| @@ -1504,15 +1360,11 @@ pub(super) fn decode_rect_split( | |||
| 1504 | skip_ctx, | 1360 | skip_ctx, |
| 1505 | dc_sign_ctx(around[plane_idx].2), | 1361 | dc_sign_ctx(around[plane_idx].2), |
| 1506 | default_tx, | 1362 | default_tx, |
| 1507 | - plane_idx, | ||
| 1508 | )?; | 1363 | )?; |
| 1509 | // The same delta_q proof the unsplit rect64 path records | 1364 | // The same delta_q proof the unsplit rect64 path records |
| 1510 | // (lane-rectsplit r4: lifting the split-transform refusal moved | 1365 | // (lane-rectsplit r4: lifting the split-transform refusal moved |
| 1511 | // superblock strips onto this path, so only counting there would | 1366 | // superblock strips onto this path, so only counting there would |
| 1512 | // leave the delta_q gate's counter silent for them). | 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 | let residual = dequant_and_inverse_typed_wh( | 1368 | let residual = dequant_and_inverse_typed_wh( |
| 1517 | &levels, | 1369 | &levels, |
| 1518 | chroma_w, | 1370 | chroma_w, |
| @@ -1584,13 +1436,6 @@ pub(super) fn decode_rect_split( | |||
| 1584 | 0, | 1436 | 0, |
| 1585 | fctx, | 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 | Ok(()) | 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 | // never said WHICH string the domain was about, so under a real function | 1502 | // never said WHICH string the domain was about, so under a real function |
| 1658 | // boundary -- rather than a window that ran into the next test -- the row | 1503 | // boundary -- rather than a window that ran into the next test -- the row |
| 1659 | // read as unanchored. | 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 | let mut checked = 0; | 1505 | let mut checked = 0; |
| 1666 | for &(side, w, h) in &INTER_BLOCK_SHAPES { | 1506 | for &(side, w, h) in &INTER_BLOCK_SHAPES { |
| 1667 | if (w, h) == (side, side) || w.min(h) < 8 || w.max(h) > 64 { | 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 | neighbours.above_side[c] = bw; | 1824 | neighbours.above_side[c] = bw; |
| 1985 | neighbours.left_side[r] = bh; | 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 | return Ok(()); | 1826 | return Ok(()); |
| 2002 | } | 1827 | } |
| 2003 | // lane-inter128intra r1: the 128 superblock's PARTITION_HORZ/VERT half | 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 | // palette_syntax`), so a 128-root half consumes no palette syntax and | 1860 | // palette_syntax`), so a 128-root half consumes no palette syntax and |
| 2036 | // a screen-content frame's half is syntactically identical to the | 1861 | // a screen-content frame's half is syntactically identical to the |
| 2037 | // non-screen one this arm already decodes byte-exact. | 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 | fctx.intra_in_inter_mode.with(|c| c.set(Some((3, skip)))); | 1863 | fctx.intra_in_inter_mode.with(|c| c.set(Some((3, skip)))); |
| 2046 | let res = decode_block_128rect( | 1864 | let res = decode_block_128rect( |
| 2047 | dec, | 1865 | dec, |
| @@ -2064,11 +1882,6 @@ pub(super) fn decode_intra_rect_in_inter( | |||
| 2064 | return res; | 1882 | return res; |
| 2065 | } | 1883 | } |
| 2066 | let Some((size_group, tx_cat)) = intra_in_inter_size_row(bw, bh) else { | 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 | // lane-obmcrec r1: the message used to name a 16x4/4x16 strip | 1885 | // lane-obmcrec r1: the message used to name a 16x4/4x16 strip |
| 2073 | // (class refusal-names-a-correlate). lane-t900 r20: the shapes that | 1886 | // (class refusal-names-a-correlate). lane-t900 r20: the shapes that |
| 2074 | // can arrive here are enumerated against the measured block-shape | 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 | fctx.intra_in_inter_mode.with(|c| c.set(None)); | 1956 | fctx.intra_in_inter_mode.with(|c| c.set(None)); |
| 2144 | res?; | 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 | return Ok(()); | 1958 | return Ok(()); |
| 2159 | } | 1959 | } |
| 2160 | - crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | ||
| 2161 | let mode = dec.symbol(&mut cdfs.y_mode[size_group]); | 1960 | let mode = dec.symbol(&mut cdfs.y_mode[size_group]); |
| 2162 | // lane-t900 r1: this arm read six mode symbols with no ladder rung of its | 1961 | // lane-t900 r1: this arm read six mode symbols with no ladder rung of its |
| 2163 | // own, so a cross-decoder bisection could only see the block's first | 1962 | // own, so a cross-decoder bisection could only see the block's first |
| 2164 | // coefficient. Same names/format as [`read_tx_size`]'s rung. | 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 | if mode >= 13 { | 1964 | if mode >= 13 { |
| 2173 | return Err(unsupported( | 1965 | return Err(unsupported( |
| 2174 | "an intra mode this decoder does not code (round 2)", | 1966 | "an intra mode this decoder does not code (round 2)", |
| @@ -2182,9 +1974,6 @@ pub(super) fn decode_intra_rect_in_inter( | |||
| 2182 | } else { | 1974 | } else { |
| 2183 | 0 | 1975 | 0 |
| 2184 | }; | 1976 | }; |
| 2185 | - if angle_delta_y != 0 { | ||
| 2186 | - hit!(INTRA_IN_INTER_ANGLE_DELTA_Y_HITS); | ||
| 2187 | - } | ||
| 2188 | // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the | 1977 | // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the |
| 2189 | // superblock-level strip reads the no-CFL alphabet -- the same split | 1978 | // superblock-level strip reads the no-CFL alphabet -- the same split |
| 2190 | // [`read_intra_mode_rect`] makes for [`decode_block_rect64`]. | 1979 | // [`read_intra_mode_rect`] makes for [`decode_block_rect64`]. |
| @@ -2196,22 +1985,10 @@ pub(super) fn decode_intra_rect_in_inter( | |||
| 2196 | let uv_mode = if !has_chroma { | 1985 | let uv_mode = if !has_chroma { |
| 2197 | DC_PRED | 1986 | DC_PRED |
| 2198 | } else if cfl_allowed { | 1987 | } else if cfl_allowed { |
| 2199 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 2200 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 1988 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 2201 | } else { | 1989 | } else { |
| 2202 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 2203 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 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 | let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { | 1992 | let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { |
| 2216 | Some(read_cfl_alphas(dec, cdfs)) | 1993 | Some(read_cfl_alphas(dec, cdfs)) |
| 2217 | } else { | 1994 | } else { |
| @@ -2223,15 +2000,10 @@ pub(super) fn decode_intra_rect_in_inter( | |||
| 2223 | uv_mode | 2000 | uv_mode |
| 2224 | }; | 2001 | }; |
| 2225 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { | 2002 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 2226 | - hit!(DIRECTIONAL_UV_HITS); | ||
| 2227 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | 2003 | read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) |
| 2228 | } else { | 2004 | } else { |
| 2229 | 0 | 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 | // `read_palette_mode_info` (spec 5.11.13), in the position | 2007 | // `read_palette_mode_info` (spec 5.11.13), in the position |
| 2236 | // `read_intra_block_mode_info` writes it: after the chroma mode and | 2008 | // `read_intra_block_mode_info` writes it: after the chroma mode and |
| 2237 | // before `filter_intra`. lane-t900 r21: a `--tune-content=screen` inter | 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 | let mut palette_y_pending: Option<(usize, [u16; 8])> = None; | 2019 | let mut palette_y_pending: Option<(usize, [u16; 8])> = None; |
| 2248 | let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; | 2020 | let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; |
| 2249 | if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh) { | 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 | let use_palette_y = | 2022 | let use_palette_y = |
| 2252 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0; | 2023 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0; |
| 2253 | if use_palette_y { | 2024 | if use_palette_y { |
| @@ -2261,14 +2032,6 @@ pub(super) fn decode_intra_rect_in_inter( | |||
| 2261 | let use_palette_uv = has_chroma | 2032 | let use_palette_uv = has_chroma |
| 2262 | && uv_mode == DC_PRED | 2033 | && uv_mode == DC_PRED |
| 2263 | && dec.symbol(&mut cdfs.palette_uv_mode[usize::from(use_palette_y)]) != 0; | 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 | if use_palette_uv { | 2035 | if use_palette_uv { |
| 2273 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); | 2036 | let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]); |
| 2274 | let (u_colors, v_colors) = read_palette_colors_uv(dec, n, &palette_uv_cache, fctx); | 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 | && let Some(class) = filter_intra_size_class_rect(bw, bh) | 2052 | && let Some(class) = filter_intra_size_class_rect(bw, bh) |
| 2290 | && dec.symbol(&mut cdfs.filter_intra[class]) != 0 | 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 | filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); | 2055 | filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); |
| 2295 | } | 2056 | } |
| 2296 | // `av1_visit_palette`: Y's colour-index map then the shared chroma one. | 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 | palette_onscreen(mi_r, mi_c, bw, bh, fctx), | 2065 | palette_onscreen(mi_r, mi_c, bw, bh, fctx), |
| 2305 | false, | 2066 | false, |
| 2306 | ); | 2067 | ); |
| 2307 | - hit!(PALETTE_HITS); | ||
| 2308 | - hit!(PALETTE_RECT_HITS); | ||
| 2309 | - hit!(INTRA_IN_INTER_PALETTE_Y_HITS); | ||
| 2310 | PaletteY { | 2068 | PaletteY { |
| 2311 | size: n, | 2069 | size: n, |
| 2312 | colors, | 2070 | colors, |
| @@ -2322,8 +2080,6 @@ pub(super) fn decode_intra_rect_in_inter( | |||
| 2322 | (ss_x(fctx), ss_y(fctx)), | 2080 | (ss_x(fctx), ss_y(fctx)), |
| 2323 | ); | 2081 | ); |
| 2324 | let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, on, true); | 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 | PaletteUv { | 2083 | PaletteUv { |
| 2328 | size: n, | 2084 | size: n, |
| 2329 | u_colors, | 2085 | u_colors, |
| @@ -2342,13 +2098,7 @@ pub(super) fn decode_intra_rect_in_inter( | |||
| 2342 | // context-read-from-one-cell). | 2098 | // context-read-from-one-cell). |
| 2343 | let coarse_pair = neighbours.modes_above_left(r, c); | 2099 | let coarse_pair = neighbours.modes_above_left(r, c); |
| 2344 | let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left_mi(mi_r, mi_c, coarse_pair); | 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 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | 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 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx); | 2102 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx); |
| 2353 | // lane-av1mixloss: the lossless-segment early return (`decodeframe.c:1203`) | 2103 | // lane-av1mixloss: the lossless-segment early return (`decodeframe.c:1203`) |
| 2354 | // precedes `TX_MODE_SELECT`, so a lossless-segment intra-rect block inside | 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 | // segment regardless of frame type; class sweep of the sub8 leaf's fix). | 2106 | // segment regardless of frame type; class sweep of the sub8 leaf's fix). |
| 2357 | let depth = if fctx.tx_select_inter.with(std::cell::Cell::get) && !lossless(fctx) { | 2107 | let depth = if fctx.tx_select_inter.with(std::cell::Cell::get) && !lossless(fctx) { |
| 2358 | // The frame's own `TXFM_CONTEXT` bands -- [`tx_size_context_txfm_rect`]. | 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 | let d = match tx_cat { | 2110 | let d = match tx_cat { |
| 2361 | 1 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), | 2111 | 1 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), |
| 2362 | 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), | 2112 | 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), |
| 2363 | _ => dec.symbol(&mut cdfs.tx_size_cat3[ctx]), | 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 | d | 2115 | d |
| 2372 | } else { | 2116 | } else { |
| 2373 | 0 | 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 | // lane-intrasplit r3: print EVERY intra strip with its depth, not only the | 2119 | // lane-intrasplit r3: print EVERY intra strip with its depth, not only the |
| 2389 | // split ones -- a `depth=0`-only stream is a witness gap in the SOURCE, and | 2120 | // split ones -- a `depth=0`-only stream is a witness gap in the SOURCE, and |
| 2390 | // the two are indistinguishable when the diagnostic fires on splits alone. | 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 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); | 2122 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 2395 | // lane-inter16ab r8: libaom runs `set_txfm_ctxs(tx_size, n4_w, n4_h, | 2123 | // lane-inter16ab r8: libaom runs `set_txfm_ctxs(tx_size, n4_w, n4_h, |
| 2396 | // skip && is_inter, xd)` (decodeframe.c `decode_block`) for EVERY block | 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 | y, | 2163 | y, |
| 2436 | u, | 2164 | u, |
| 2437 | v, | 2165 | v, |
| 2438 | - base_q_idx, | ||
| 2439 | fctx.reduced_tx_set_inter.with(std::cell::Cell::get), | 2166 | fctx.reduced_tx_set_inter.with(std::cell::Cell::get), |
| 2440 | fctx, | 2167 | fctx, |
| 2441 | )?; | 2168 | )?; |
| @@ -2467,18 +2194,6 @@ pub(super) fn decode_intra_rect_in_inter( | |||
| 2467 | palette_uv.as_ref().map_or(0, |p| p.size), | 2194 | palette_uv.as_ref().map_or(0, |p| p.size), |
| 2468 | palette_uv.as_ref().map_or([0u16; 8], |p| p.u_colors), | 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 | Ok(()) | 2197 | Ok(()) |
| 2483 | } | 2198 | } |
| 2484 | 2199 | ||
| @@ -2519,22 +2234,6 @@ pub(super) fn decode_intrabc_rect( | |||
| 2519 | base_q_idx: u8, | 2234 | base_q_idx: u8, |
| 2520 | fctx: &crate::decode::FrameCtx, | 2235 | fctx: &crate::decode::FrameCtx, |
| 2521 | ) -> Result<()> { | 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 | let (px, py) = (mi_c * MI, mi_r * MI); | 2237 | let (px, py) = (mi_c * MI, mi_r * MI); |
| 2539 | // lane-whtshape: a LOSSLESS block's chroma plane block is | 2238 | // lane-whtshape: a LOSSLESS block's chroma plane block is |
| 2540 | // `bw >> ss_x` by `bh >> ss_y` at its own origin -- `av1_get_max_uv_txsize` | 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 | skip, | 2280 | skip, |
| 2582 | fctx, | 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 | // lane-ibc444c: per-block geometry, for the chroma-tail attribution. | 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 | // The whole-block prediction: `predict_inter_block` runs once, before any | 2284 | // The whole-block prediction: `predict_inter_block` runs once, before any |
| 2598 | // coefficient is read. The source is this frame's own reconstruction, | 2285 | // coefficient is read. The source is this frame's own reconstruction, |
| 2599 | // which is already written. | 2286 | // which is already written. |
| @@ -2709,19 +2396,6 @@ pub(super) fn decode_intrabc_rect( | |||
| 2709 | fctx, | 2396 | fctx, |
| 2710 | ); | 2397 | ); |
| 2711 | if let Some(ls) = leaves.as_ref() { | 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 | for &(row, col, tw, th) in ls { | 2399 | for &(row, col, tw, th) in ls { |
| 2726 | neighbours.record_mi_luma_rect( | 2400 | neighbours.record_mi_luma_rect( |
| 2727 | (mi_r + row, mi_c + col), | 2401 | (mi_r + row, mi_c + col), |
| @@ -2903,21 +2577,6 @@ pub(super) fn decode_intrabc_rect( | |||
| 2903 | around[2] = c[2]; | 2577 | around[2] = c[2]; |
| 2904 | } | 2578 | } |
| 2905 | if lossless(fctx) { | 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 | let mut uo = vec![0i32; cside * cside]; | 2580 | let mut uo = vec![0i32; cside * cside]; |
| 2922 | let mut vo = vec![0i32; cside * cside]; | 2581 | let mut vo = vec![0i32; cside * cside]; |
| 2923 | read_inter_chroma_lossless( | 2582 | read_inter_chroma_lossless( |
| @@ -3125,13 +2784,6 @@ pub(super) fn decode_intrabc_128rect( | |||
| 3125 | base_q_idx: u8, | 2784 | base_q_idx: u8, |
| 3126 | fctx: &crate::decode::FrameCtx, | 2785 | fctx: &crate::decode::FrameCtx, |
| 3127 | ) -> Result<()> { | 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 | let (px, py) = (mi_c * MI, mi_r * MI); | 2787 | let (px, py) = (mi_c * MI, mi_r * MI); |
| 3136 | // lane-av1-ibc128chunk: the block's chroma PLANE BLOCK is per-axis | 2788 | // lane-av1-ibc128chunk: the block's chroma PLANE BLOCK is per-axis |
| 3137 | // `(bw >> ss_x) x (bh >> ss_y)` -- 4:2:0 halves both (this fn's | 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 | fctx, | 2929 | fctx, |
| 3278 | ); | 2930 | ); |
| 3279 | if let Some(ls) = leaves.as_ref() { | 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 | for &(row, col, tw, th) in ls { | 2932 | for &(row, col, tw, th) in ls { |
| 3287 | neighbours.record_mi_luma_rect( | 2933 | neighbours.record_mi_luma_rect( |
| 3288 | (mi_r + row, mi_c + col), | 2934 | (mi_r + row, mi_c + col), |
| @@ -3457,38 +3103,6 @@ pub(super) fn decode_intrabc_128rect( | |||
| 3457 | } else { | 3103 | } else { |
| 3458 | neighbours.around_mi_rect(unit_mi, unit_luma_w, unit_luma_h) | 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 | let (cu_x, cu_y) = ( | 3106 | let (cu_x, cu_y) = ( |
| 3493 | cpx + cc * chunk_chroma_w + uc * cu_tx, | 3107 | cpx + cc * chunk_chroma_w + uc * cu_tx, |
| 3494 | cpy + cr * chunk_chroma_h + ur * cu_tx, | 3108 | cpy + cr * chunk_chroma_h + ur * cu_tx, |
| @@ -3538,15 +3152,6 @@ pub(super) fn decode_intrabc_128rect( | |||
| 3538 | plane_idx, | 3152 | plane_idx, |
| 3539 | &cu_grid, | 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 | // lane-av1-ibcrect: per-unit chroma context -- the | 3155 | // lane-av1-ibcrect: per-unit chroma context -- the |
| 3551 | // end-of-block record's composed-grid re-stamp | 3156 | // end-of-block record's composed-grid re-stamp |
| 3552 | // must not stand (replayed below). | 3157 | // must not stand (replayed below). |
| @@ -3831,9 +3436,6 @@ pub(super) fn decode_block_rect( | |||
| 3831 | ); | 3436 | ); |
| 3832 | } | 3437 | } |
| 3833 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | 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 | // lane-chroma r3: chroma's own edge-filter-strength neighbour check | 3439 | // lane-chroma r3: chroma's own edge-filter-strength neighbour check |
| 3838 | // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's | 3440 | // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's |
| 3839 | // `uv_mode`, not the luma one. | 3441 | // `uv_mode`, not the luma one. |
| @@ -3844,9 +3446,6 @@ pub(super) fn decode_block_rect( | |||
| 3844 | // rectangle just as happily), so a `use_filter_intra` strip at this level | 3446 | // rectangle just as happily), so a `use_filter_intra` strip at this level |
| 3845 | // predicts instead of refusing. The below-16x16 leaf arm | 3447 | // predicts instead of refusing. The below-16x16 leaf arm |
| 3846 | // (`decode_leaf_rect`) keeps the refusal: it has no gate of its own. | 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 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { | 3449 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 3851 | DC_PRED | 3450 | DC_PRED |
| 3852 | } else { | 3451 | } else { |
| @@ -3872,14 +3471,8 @@ pub(super) fn decode_block_rect( | |||
| 3872 | // 1920x792 128-superblock stream, | 3471 | // 1920x792 128-superblock stream, |
| 3873 | // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read | 3472 | // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read |
| 3874 | // `tx_size_cat2` row 1 where libaom reads row 2. | 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 | let d = dec.symbol(&mut cdfs.tx_size_cat2[ctx]); | 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 | d | 3476 | d |
| 3884 | } else { | 3477 | } else { |
| 3885 | 0 | 3478 | 0 |
| @@ -3894,19 +3487,11 @@ pub(super) fn decode_block_rect( | |||
| 3894 | fctx, | 3487 | fctx, |
| 3895 | ); | 3488 | ); |
| 3896 | if depth != 0 || lossless(fctx) { | 3489 | if depth != 0 || lossless(fctx) { |
| 3897 | - hit!(TX_DEPTH_HITS); | ||
| 3898 | // lane-rectsplit r1: a split transform is predicted and reconstructed | 3490 | // lane-rectsplit r1: a split transform is predicted and reconstructed |
| 3899 | // per transform unit, each unit taking its edges from the previous | 3491 | // per transform unit, each unit taking its edges from the previous |
| 3900 | // unit's reconstruction inside this same strip (spec 5.11.36) -- | 3492 | // unit's reconstruction inside this same strip (spec 5.11.36) -- |
| 3901 | // [`decode_rect_split`], the unit named by [`depth_to_tx_wh`]. | 3493 | // [`decode_rect_split`], the unit named by [`depth_to_tx_wh`]. |
| 3902 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); | 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 | let modes = RectStripModes { | 3495 | let modes = RectStripModes { |
| 3911 | skip, | 3496 | skip, |
| 3912 | mode, | 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 | decode_rect_split( | 3515 | decode_rect_split( |
| 3934 | dec, | 3516 | dec, |
| 3935 | cdfs, | 3517 | cdfs, |
| @@ -3943,7 +3525,6 @@ pub(super) fn decode_block_rect( | |||
| 3943 | y, | 3525 | y, |
| 3944 | u, | 3526 | u, |
| 3945 | v, | 3527 | v, |
| 3946 | - base_q_idx, | ||
| 3947 | reduced_tx_set, | 3528 | reduced_tx_set, |
| 3948 | fctx, | 3529 | fctx, |
| 3949 | )?; | 3530 | )?; |
| @@ -3962,21 +3543,12 @@ pub(super) fn decode_block_rect( | |||
| 3962 | .as_ref() | 3543 | .as_ref() |
| 3963 | .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 3544 | .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 3964 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); | 3545 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); |
| 3965 | - hit!(RECT_PARTITION_HITS); | ||
| 3966 | return Ok(()); | 3546 | return Ok(()); |
| 3967 | } | 3547 | } |
| 3968 | let (tx_w, tx_h) = (bw, bh); | 3548 | let (tx_w, tx_h) = (bw, bh); |
| 3969 | let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); | 3549 | let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); |
| 3970 | let (chroma_w, chroma_h) = (bw >> ss_x(fctx), bh >> ss_y(fctx)); | 3550 | let (chroma_w, chroma_h) = (bw >> ss_x(fctx), bh >> ss_y(fctx)); |
| 3971 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); | 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 | // As [`decode_block`]'s own [`PALETTE_PRED`] wiring: a palette-Y/UV | 3552 | // As [`decode_block`]'s own [`PALETTE_PRED`] wiring: a palette-Y/UV |
| 3981 | // block's prediction is the reconstructed colour-index map, set fresh | 3553 | // block's prediction is the reconstructed colour-index map, set fresh |
| 3982 | // right before each `reconstruct_rect` call below (lane-palette2 r4). | 3554 | // right before each `reconstruct_rect` call below (lane-palette2 r4). |
| @@ -4174,12 +3746,7 @@ pub(super) fn decode_block_rect( | |||
| 4174 | 0, | 3746 | 0, |
| 4175 | dc_sign_ctx(around[0].2), | 3747 | dc_sign_ctx(around[0].2), |
| 4176 | TxType::DctDct, | 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 | let luma_residual = dequant_and_inverse_typed_wh( | 3750 | let luma_residual = dequant_and_inverse_typed_wh( |
| 4184 | &luma_levels, | 3751 | &luma_levels, |
| 4185 | bw, | 3752 | bw, |
| @@ -4226,12 +3793,7 @@ pub(super) fn decode_block_rect( | |||
| 4226 | dc_sign_ctx(around[1].2), | 3793 | dc_sign_ctx(around[1].2), |
| 4227 | u_default_tx, | 3794 | u_default_tx, |
| 4228 | fctx, | 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 | let u_residual = dequant_and_inverse_typed_wh( | 3797 | let u_residual = dequant_and_inverse_typed_wh( |
| 4236 | &u_levels, | 3798 | &u_levels, |
| 4237 | chroma_w, | 3799 | chroma_w, |
| @@ -4277,12 +3839,7 @@ pub(super) fn decode_block_rect( | |||
| 4277 | dc_sign_ctx(around[2].2), | 3839 | dc_sign_ctx(around[2].2), |
| 4278 | v_default_tx, | 3840 | v_default_tx, |
| 4279 | fctx, | 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 | let v_residual = dequant_and_inverse_typed_wh( | 3843 | let v_residual = dequant_and_inverse_typed_wh( |
| 4287 | &v_levels, | 3844 | &v_levels, |
| 4288 | chroma_w, | 3845 | chroma_w, |
| @@ -4320,7 +3877,6 @@ pub(super) fn decode_block_rect( | |||
| 4320 | uv_predict_mode, | 3877 | uv_predict_mode, |
| 4321 | &[&luma_levels[..], &u_levels[..], &v_levels[..]], | 3878 | &[&luma_levels[..], &u_levels[..], &v_levels[..]], |
| 4322 | ); | 3879 | ); |
| 4323 | - hit!(RECT_COEFF_HITS); | ||
| 4324 | } | 3880 | } |
| 4325 | } | 3881 | } |
| 4326 | let (py_size, py_colors) = palette_y | 3882 | let (py_size, py_colors) = palette_y |
| @@ -4341,10 +3897,6 @@ pub(super) fn decode_block_rect( | |||
| 4341 | 0, | 3897 | 0, |
| 4342 | fctx, | 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 | Ok(()) | 3900 | Ok(()) |
| 4349 | } | 3901 | } |
| 4350 | 3902 | ||
| @@ -4389,12 +3941,6 @@ pub(super) fn decode_leaf_rect( | |||
| 4389 | fctx: &crate::decode::FrameCtx, | 3941 | fctx: &crate::decode::FrameCtx, |
| 4390 | ) -> Result<usize> { | 3942 | ) -> Result<usize> { |
| 4391 | let _ = base_q_idx; | 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 | let (r, c) = outer_at; | 3944 | let (r, c) = outer_at; |
| 4399 | let mut above_mode = neighbours.above_mode[c]; | 3945 | let mut above_mode = neighbours.above_mode[c]; |
| 4400 | let mut left_mode = neighbours.left_mode[r]; | 3946 | let mut left_mode = neighbours.left_mode[r]; |
| @@ -4417,9 +3963,6 @@ pub(super) fn decode_leaf_rect( | |||
| 4417 | let (above_mode, left_mode) = | 3963 | let (above_mode, left_mode) = |
| 4418 | neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode)); | 3964 | neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode)); |
| 4419 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | 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 | // The palette-Y mode CDF row is picked by the neighbours' palette use | 3966 | // The palette-Y mode CDF row is picked by the neighbours' palette use |
| 4424 | // (`palette_ctx_and_cache`), so this sub-16x16 leaf must pass its own real | 3967 | // (`palette_ctx_and_cache`), so this sub-16x16 leaf must pass its own real |
| 4425 | // ctx/cache -- reading `palette_y_mode` off row 0 when a neighbour did use | 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 | // lane-kf900 r4: palette prediction on this shape, the same colour-index | 4026 | // lane-kf900 r4: palette prediction on this shape, the same colour-index |
| 4484 | // map -> base colours buffer [`decode_block_rect`] hands each | 4027 | // map -> base colours buffer [`decode_block_rect`] hands each |
| 4485 | // `reconstruct_rect` through [`set_palette_pred`]. | 4028 | // `reconstruct_rect` through [`set_palette_pred`]. |
| 4486 | - if palette_y.is_some() || palette_uv.is_some() { | ||
| 4487 | - hit!(RECT4_PALETTE_HITS); | ||
| 4488 | - } | ||
| 4489 | let palette_y_buf: Option<Vec<u16>> = palette_y | 4029 | let palette_y_buf: Option<Vec<u16>> = palette_y |
| 4490 | .as_ref() | 4030 | .as_ref() |
| 4491 | .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect()); | 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 | let (pal_uv_size, pal_uv_colors) = palette_uv | 4041 | let (pal_uv_size, pal_uv_colors) = palette_uv |
| 4502 | .as_ref() | 4042 | .as_ref() |
| 4503 | .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 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 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { | 4044 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 4516 | DC_PRED | 4045 | DC_PRED |
| 4517 | } else { | 4046 | } else { |
| @@ -4531,7 +4060,7 @@ pub(super) fn decode_leaf_rect( | |||
| 4531 | // The mixed frame's 16x8 leaf at mi(10,0) forked exactly here: ours | 4060 | // The mixed frame's 16x8 leaf at mi(10,0) forked exactly here: ours |
| 4532 | // read `tx_size_cat1` (rng 55700->49918) where the oracle's next | 4061 | // read `tx_size_cat1` (rng 55700->49918) where the oracle's next |
| 4533 | // read was the leaf's own txb_skip. | 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 | // lane-rectsplitx r1: `bsize_to_tx_size_cat` (libaom `blockd.h`, | 4064 | // lane-rectsplitx r1: `bsize_to_tx_size_cat` (libaom `blockd.h`, |
| 4536 | // `bsize_to_tx_size_depth_table`) is 2 for BLOCK_16X8/BLOCK_8X16, so | 4065 | // `bsize_to_tx_size_depth_table`) is 2 for BLOCK_16X8/BLOCK_8X16, so |
| 4537 | // the category is 1 -- NOT the 2 the 32x16 strips read. Same symbol | 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 | // symbol in the tile is read from the wrong place (class | 4078 | // symbol in the tile is read from the wrong place (class |
| 4550 | // `wrong-alphabet-same-value`, here same alphabet / wrong row). | 4079 | // `wrong-alphabet-same-value`, here same alphabet / wrong row). |
| 4551 | let d = dec.symbol(&mut cdfs.tx_size_cat1[ctx]); | 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 | d | 4081 | d |
| 4561 | } else { | 4082 | } else { |
| 4562 | 0 | 4083 | 0 |
| @@ -4571,11 +4092,6 @@ pub(super) fn decode_leaf_rect( | |||
| 4571 | fctx, | 4092 | fctx, |
| 4572 | ); | 4093 | ); |
| 4573 | if depth != 0 || lossless(fctx) { | 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 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); | 4095 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 4580 | let modes = RectStripModes { | 4096 | let modes = RectStripModes { |
| 4581 | skip, | 4097 | skip, |
| @@ -4593,9 +4109,6 @@ pub(super) fn decode_leaf_rect( | |||
| 4593 | palette_y: palette_y_buf.clone(), | 4109 | palette_y: palette_y_buf.clone(), |
| 4594 | palette_uv: palette_uv_bufs.clone(), | 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 | decode_rect_split( | 4112 | decode_rect_split( |
| 4600 | dec, | 4113 | dec, |
| 4601 | cdfs, | 4114 | cdfs, |
| @@ -4609,7 +4122,6 @@ pub(super) fn decode_leaf_rect( | |||
| 4609 | y, | 4122 | y, |
| 4610 | u, | 4123 | u, |
| 4611 | v, | 4124 | v, |
| 4612 | - base_q_idx, | ||
| 4613 | reduced_tx_set, | 4125 | reduced_tx_set, |
| 4614 | fctx, | 4126 | fctx, |
| 4615 | )?; | 4127 | )?; |
| @@ -4772,17 +4284,7 @@ pub(super) fn decode_leaf_rect( | |||
| 4772 | 0, | 4284 | 0, |
| 4773 | dc_sign_ctx(around[0].2), | 4285 | dc_sign_ctx(around[0].2), |
| 4774 | TxType::DctDct, | 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 | luma_levels = l_levels; | 4288 | luma_levels = l_levels; |
| 4787 | let luma_residual = dequant_and_inverse_typed_wh( | 4289 | let luma_residual = dequant_and_inverse_typed_wh( |
| 4788 | &luma_levels, | 4290 | &luma_levels, |
| @@ -4830,7 +4332,6 @@ pub(super) fn decode_leaf_rect( | |||
| 4830 | dc_sign_ctx(around[1].2), | 4332 | dc_sign_ctx(around[1].2), |
| 4831 | u_default_tx, | 4333 | u_default_tx, |
| 4832 | fctx, | 4334 | fctx, |
| 4833 | - 1, | ||
| 4834 | )?; | 4335 | )?; |
| 4835 | u_levels = u_l; | 4336 | u_levels = u_l; |
| 4836 | let u_residual = dequant_and_inverse_typed_wh( | 4337 | let u_residual = dequant_and_inverse_typed_wh( |
| @@ -4878,7 +4379,6 @@ pub(super) fn decode_leaf_rect( | |||
| 4878 | dc_sign_ctx(around[2].2), | 4379 | dc_sign_ctx(around[2].2), |
| 4879 | v_default_tx, | 4380 | v_default_tx, |
| 4880 | fctx, | 4381 | fctx, |
| 4881 | - 2, | ||
| 4882 | )?; | 4382 | )?; |
| 4883 | v_levels = v_l; | 4383 | v_levels = v_l; |
| 4884 | let v_residual = dequant_and_inverse_typed_wh( | 4384 | let v_residual = dequant_and_inverse_typed_wh( |
| @@ -4913,7 +4413,6 @@ pub(super) fn decode_leaf_rect( | |||
| 4913 | smooth_neighbor_uv, | 4413 | smooth_neighbor_uv, |
| 4914 | fctx, | 4414 | fctx, |
| 4915 | ); | 4415 | ); |
| 4916 | - hit!(RECT_LEAF_COEFF_HITS); | ||
| 4917 | } | 4416 | } |
| 4918 | neighbours.record_mi_rect( | 4417 | neighbours.record_mi_rect( |
| 4919 | leaf_mi, | 4418 | leaf_mi, |
crates/ec-av1/src/decode/rect4.rsmodified+8 -364
| @@ -117,9 +117,6 @@ pub(super) fn decode_block_rect4( | |||
| 117 | // [`decode_block_rect`] does one aspect ratio up -- the colour-index map | 117 | // [`decode_block_rect`] does one aspect ratio up -- the colour-index map |
| 118 | // mapped through the base colours IS the prediction (it reads no edge | 118 | // mapped through the base colours IS the prediction (it reads no edge |
| 119 | // pixels), handed to each `reconstruct_rect` through [`set_palette_pred`]. | 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 | let palette_y_buf: Option<Vec<u16>> = palette_y | 120 | let palette_y_buf: Option<Vec<u16>> = palette_y |
| 124 | .as_ref() | 121 | .as_ref() |
| 125 | .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect()); | 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 | .as_ref() | 133 | .as_ref() |
| 137 | .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 134 | .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 138 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | 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 | // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's | 136 | // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's |
| 143 | // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so | 137 | // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so |
| 144 | // `r * (SUB / MI)` names a different mi column and the chroma | 138 | // `r * (SUB / MI)` names a different mi column and the chroma |
| @@ -146,14 +140,6 @@ pub(super) fn decode_block_rect4( | |||
| 146 | // seed 43, the last 8x32 strip at luma (152,32), chroma-only mismatch | 140 | // seed 43, the last 8x32 strip at luma (152,32), chroma-only mismatch |
| 147 | // with luma bit-exact). | 141 | // with luma bit-exact). |
| 148 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c, fctx); | 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 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { | 143 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 158 | DC_PRED | 144 | DC_PRED |
| 159 | } else { | 145 | } else { |
| @@ -170,14 +156,8 @@ pub(super) fn decode_block_rect4( | |||
| 170 | // 1920x792 128-superblock stream, | 156 | // 1920x792 128-superblock stream, |
| 171 | // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read | 157 | // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read |
| 172 | // `tx_size_cat2` row 1 where libaom reads row 2. | 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 | let d = dec.symbol(&mut cdfs.tx_size_cat2[ctx]); | 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 | d | 161 | d |
| 182 | } else { | 162 | } else { |
| 183 | 0 | 163 | 0 |
| @@ -192,24 +172,7 @@ pub(super) fn decode_block_rect4( | |||
| 192 | fctx, | 172 | fctx, |
| 193 | ); | 173 | ); |
| 194 | if depth != 0 || lossless(fctx) { | 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 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); | 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 | let modes = RectStripModes { | 176 | let modes = RectStripModes { |
| 214 | skip, | 177 | skip, |
| 215 | mode, | 178 | mode, |
| @@ -223,9 +186,6 @@ pub(super) fn decode_block_rect4( | |||
| 223 | palette_y: palette_y_buf.clone(), | 186 | palette_y: palette_y_buf.clone(), |
| 224 | palette_uv: palette_uv_bufs.clone(), | 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 | decode_rect_split( | 189 | decode_rect_split( |
| 230 | dec, | 190 | dec, |
| 231 | cdfs, | 191 | cdfs, |
| @@ -239,7 +199,6 @@ pub(super) fn decode_block_rect4( | |||
| 239 | y, | 199 | y, |
| 240 | u, | 200 | u, |
| 241 | v, | 201 | v, |
| 242 | - base_q_idx, | ||
| 243 | false, | 202 | false, |
| 244 | fctx, | 203 | fctx, |
| 245 | )?; | 204 | )?; |
| @@ -253,14 +212,6 @@ pub(super) fn decode_block_rect4( | |||
| 253 | pal_uv_size, | 212 | pal_uv_size, |
| 254 | pal_uv_colors, | 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 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, | 215 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 265 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter | 216 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| 266 | // frame, so this 1:4 strip -- which is also the INTER frame's reader | 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 | 0, | 318 | 0, |
| 368 | dc_sign_ctx(around[0].2), | 319 | dc_sign_ctx(around[0].2), |
| 369 | TxType::DctDct, | 320 | TxType::DctDct, |
| 370 | - 0, | ||
| 371 | )?; | 321 | )?; |
| 372 | - hit!(RECT4_COEFF_HITS); | ||
| 373 | let luma_residual = dequant_and_inverse_typed_wh( | 322 | let luma_residual = dequant_and_inverse_typed_wh( |
| 374 | &luma_levels, | 323 | &luma_levels, |
| 375 | bw, | 324 | bw, |
| @@ -410,20 +359,7 @@ pub(super) fn decode_block_rect4( | |||
| 410 | for plane in [1usize, 2] { | 359 | for plane in [1usize, 2] { |
| 411 | for unit_row in 0..4usize { | 360 | for unit_row in 0..4usize { |
| 412 | let unit_mi = (mi_r + unit_row * 2, mi_c); | 361 | let unit_mi = (mi_r + unit_row * 2, mi_c); |
| 413 | - let unit_reach = tu_reach_rect( | 362 | + let unit_reach = tu_reach_rect(bw, bh, 0, unit_row * 8, 8, 8, reach); |
| 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 | - ); | ||
| 427 | if let Some((ub, vb)) = &palette_uv_bufs { | 363 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 428 | let pbuf = if plane == 1 { ub } else { vb }; | 364 | let pbuf = if plane == 1 { ub } else { vb }; |
| 429 | set_palette_pred(palette_window(pbuf, chroma_w, 0, unit_row * 8, 4, 8), fctx); | 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 | pal_uv_size, | 434 | pal_uv_size, |
| 499 | pal_uv_colors, | 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 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, | 437 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 507 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter | 438 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| 508 | // frame, so this 1:4 strip -- which is also the INTER frame's reader | 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 | 0, | 464 | 0, |
| 534 | dc_sign_ctx(around[0].2), | 465 | dc_sign_ctx(around[0].2), |
| 535 | TxType::DctDct, | 466 | TxType::DctDct, |
| 536 | - 0, | ||
| 537 | )?; | 467 | )?; |
| 538 | let mut planes = Vec::with_capacity(2); | 468 | let mut planes = Vec::with_capacity(2); |
| 539 | // Index loop mirrors the spec's per-position form over several offsets; an iterator would obscure it. | 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 | dc_sign_ctx(chroma_around[plane].2), | 492 | dc_sign_ctx(chroma_around[plane].2), |
| 563 | default_tx, | 493 | default_tx, |
| 564 | fctx, | 494 | fctx, |
| 565 | - plane, | ||
| 566 | )?; | 495 | )?; |
| 567 | planes.push((levels, tx_type)); | 496 | planes.push((levels, tx_type)); |
| 568 | } | 497 | } |
| 569 | let (v_levels, v_tx_type) = planes.pop().expect("plane 2"); | 498 | let (v_levels, v_tx_type) = planes.pop().expect("plane 2"); |
| 570 | let (u_levels, u_tx_type) = planes.pop().expect("plane 1"); | 499 | let (u_levels, u_tx_type) = planes.pop().expect("plane 1"); |
| 571 | - hit!(RECT4_COEFF_HITS); | ||
| 572 | let luma_residual = dequant_and_inverse_typed_wh( | 500 | let luma_residual = dequant_and_inverse_typed_wh( |
| 573 | &luma_levels, | 501 | &luma_levels, |
| 574 | bw, | 502 | bw, |
| @@ -657,11 +585,6 @@ pub(super) fn decode_block_rect4( | |||
| 657 | pal_uv_size, | 585 | pal_uv_size, |
| 658 | pal_uv_colors, | 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 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, | 588 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 666 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter | 589 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| 667 | // frame, so this 1:4 strip -- which is also the INTER frame's reader | 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 | // libaom's `set_entropy_context` leaves. | 625 | // libaom's `set_entropy_context` leaves. |
| 703 | for plane in [1usize, 2] { | 626 | for plane in [1usize, 2] { |
| 704 | for unit_row in 0..4usize { | 627 | for unit_row in 0..4usize { |
| 705 | - let unit_reach = tu_reach_rect( | 628 | + let unit_reach = tu_reach_rect(bw, bh, 0, unit_row * 8, 8, 8, reach); |
| 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 | - ); | ||
| 719 | if let Some((ub, vb)) = &palette_uv_bufs { | 629 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 720 | let pbuf = if plane == 1 { ub } else { vb }; | 630 | let pbuf = if plane == 1 { ub } else { vb }; |
| 721 | set_palette_pred(palette_window(pbuf, chroma_w, 0, unit_row * 8, 4, 8), fctx); | 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 | pal_uv_size, | 714 | pal_uv_size, |
| 805 | pal_uv_colors, | 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 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, | 717 | // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, |
| 813 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter | 718 | // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter |
| 814 | // frame, so this 1:4 strip -- which is also the INTER frame's reader | 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 | // 73501 V (f1) and 9216 U + 8192 V (f2) are wrong -- chroma-only, which is | 880 | // 73501 V (f1) and 9216 U + 8192 V (f2) are wrong -- chroma-only, which is |
| 976 | // what makes this a chroma-sizing defect and not a block-geometry one. | 881 | // what makes this a chroma-sizing defect and not a block-geometry one. |
| 977 | // Re-measured by this lane; see lanes/av1chromarect.report.md. | 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 | let (cw, ch) = (bw >> ss_x(fctx), bh >> ss_y(fctx)); | 883 | let (cw, ch) = (bw >> ss_x(fctx), bh >> ss_y(fctx)); |
| 982 | let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); | 884 | let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); |
| 983 | let side = bw.max(bh); | 885 | let side = bw.max(bh); |
| 984 | let cside = cw.max(ch); | 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 | let saved_reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get); | 887 | let saved_reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get); |
| 989 | let saved_tx = fctx.tx_select_inter.with(std::cell::Cell::get); | 888 | let saved_tx = fctx.tx_select_inter.with(std::cell::Cell::get); |
| 990 | fctx.reduced_tx_set_inter.with(|c| c.set(reduced_tx_set)); | 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 | fctx, | 962 | fctx, |
| 1064 | ); | 963 | ); |
| 1065 | if let Some(ls) = leaves.as_ref() { | 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 | for &(row, col, tw, th) in ls { | 965 | for &(row, col, tw, th) in ls { |
| 1081 | neighbours.record_mi_luma_rect( | 966 | neighbours.record_mi_luma_rect( |
| 1082 | (mi_r + row, mi_c + col), | 967 | (mi_r + row, mi_c + col), |
| @@ -1195,7 +1080,6 @@ pub(super) fn decode_intrabc_owned_rect( | |||
| 1195 | // `TX_MODE_LARGEST`); the routing here is identical, so a future | 1080 | // `TX_MODE_LARGEST`); the routing here is identical, so a future |
| 1196 | // witness takes the same code. | 1081 | // witness takes the same code. |
| 1197 | let around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { | 1082 | let around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { |
| 1198 | - hit!(IBC_OWNED_RECT_422_PAIR_HITS); | ||
| 1199 | neighbours.around_mi_422_chroma((mi_r, mi_c), bw, bh) | 1083 | neighbours.around_mi_422_chroma((mi_r, mi_c), bw, bh) |
| 1200 | } else { | 1084 | } else { |
| 1201 | neighbours.around_mi_rect((mi_r, mi_c), bw, bh) | 1085 | neighbours.around_mi_rect((mi_r, mi_c), bw, bh) |
| @@ -1295,7 +1179,6 @@ pub(super) fn decode_intrabc_owned_rect( | |||
| 1295 | // agree -- `fixtures/ibc422_nonsplit_ctx.obu` is the stream where | 1179 | // agree -- `fixtures/ibc422_nonsplit_ctx.obu` is the stream where |
| 1296 | // they do not). | 1180 | // they do not). |
| 1297 | let around_chroma = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { | 1181 | let around_chroma = if ss_x(fctx) == 1 && ss_y(fctx) == 0 { |
| 1298 | - hit!(IBC_OWNED_RECT_422_PAIR_HITS); | ||
| 1299 | neighbours.around_mi_422_chroma((mi_r, mi_c), bw, bh) | 1182 | neighbours.around_mi_422_chroma((mi_r, mi_c), bw, bh) |
| 1300 | } else { | 1183 | } else { |
| 1301 | around | 1184 | around |
| @@ -1603,7 +1486,6 @@ pub(super) fn decode_rect4_16_intrabc( | |||
| 1603 | fctx: &crate::decode::FrameCtx, | 1486 | fctx: &crate::decode::FrameCtx, |
| 1604 | ) -> Result<(usize, Option<usize>, (usize, usize))> { | 1487 | ) -> Result<(usize, Option<usize>, (usize, usize))> { |
| 1605 | let _ = base_q_idx; | 1488 | let _ = base_q_idx; |
| 1606 | - hit!(RECT4_16_INTRABC_HITS); | ||
| 1607 | let (bw, bh) = if horz { (16usize, 4usize) } else { (4, 16) }; | 1489 | let (bw, bh) = if horz { (16usize, 4usize) } else { (4, 16) }; |
| 1608 | let (mi_w, mi_h) = (bw / MI, bh / MI); | 1490 | let (mi_w, mi_h) = (bw / MI, bh / MI); |
| 1609 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); | 1491 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| @@ -1670,15 +1552,9 @@ pub(super) fn decode_rect4_16_intrabc( | |||
| 1670 | // [BLOCK_4X16][1][0]` is BLOCK_INVALID at 4:2:2, so only HORZ reaches it. | 1552 | // [BLOCK_4X16][1][0]` is BLOCK_INVALID at 4:2:2, so only HORZ reaches it. |
| 1671 | let own444 = ss_x(fctx) == 0 && ss_y(fctx) == 0; | 1553 | let own444 = ss_x(fctx) == 0 && ss_y(fctx) == 0; |
| 1672 | let own422 = ss_x(fctx) == 1 && ss_y(fctx) == 0 && horz; | 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 | // One predicate for "this strip IS its own chroma reference": the strip's | 1555 | // One predicate for "this strip IS its own chroma reference": the strip's |
| 1677 | // own mi position, its own luma extent, and per-axis subsampled sizes. | 1556 | // own mi position, its own luma extent, and per-axis subsampled sizes. |
| 1678 | let own_chroma = own444 || own422; | 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 | let (pw, ph) = if own444 { | 1558 | let (pw, ph) = if own444 { |
| 1683 | (bw, bh) | 1559 | (bw, bh) |
| 1684 | } else if horz { | 1560 | } else if horz { |
| @@ -1805,15 +1681,6 @@ pub(super) fn decode_rect4_16_intrabc( | |||
| 1805 | bh, | 1681 | bh, |
| 1806 | ); | 1682 | ); |
| 1807 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; | 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 | if !split { | 1684 | if !split { |
| 1818 | None | 1685 | None |
| 1819 | } else { | 1686 | } else { |
| @@ -2184,7 +2051,6 @@ pub(super) fn decode_rect4_16_intrabc( | |||
| 2184 | } | 2051 | } |
| 2185 | let mut last_uv = None; | 2052 | let mut last_uv = None; |
| 2186 | if has_chroma { | 2053 | if has_chroma { |
| 2187 | - hit!(RECT4_16_CHROMA_HITS); | ||
| 2188 | // lane-av1422luma: the uv-mode publication and the left/above skip | 2054 | // lane-av1422luma: the uv-mode publication and the left/above skip |
| 2189 | // state below are the STRIP's own at 4:2:2 / 4:4:4 -- publishing the | 2055 | // state below are the STRIP's own at 4:2:2 / 4:4:4 -- publishing the |
| 2190 | // pair extent (one mi row off, `ph`/`pw`) is what the NEXT block's | 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 | last_uv = Some(DC_PRED); | 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 | record_strip_palette(neighbours, lmi, bw, bh, 0, [0u16; 8], 0, [0u16; 8]); | 2089 | record_strip_palette(neighbours, lmi, bw, bh, 0, [0u16; 8], 0, [0u16; 8]); |
| 2229 | if leaves.is_none() { | 2090 | if leaves.is_none() { |
| 2230 | // Skip and TX_MODE_LARGEST publish the block size (`set_txfm_ctxs` | 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 | fctx, | 2211 | fctx, |
| 2351 | ); | 2212 | ); |
| 2352 | } | 2213 | } |
| 2353 | - if palette_y.is_some() || palette_uv.is_some() { | ||
| 2354 | - hit!(RECT4_PALETTE_HITS); | ||
| 2355 | - } | ||
| 2356 | // The colour-index map through the base colours IS the prediction. | 2214 | // The colour-index map through the base colours IS the prediction. |
| 2357 | // Chroma's map is the PAIR's 8x4 (4x8) block, matching the one | 2215 | // Chroma's map is the PAIR's 8x4 (4x8) block, matching the one |
| 2358 | // chroma transform this closing strip codes. | 2216 | // chroma transform this closing strip codes. |
| @@ -2366,12 +2224,6 @@ pub(super) fn decode_rect4_16_strip( | |||
| 2366 | ) | 2224 | ) |
| 2367 | }); | 2225 | }); |
| 2368 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | 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 | // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is | 2227 | // `bsize_to_tx_size_cat(BLOCK_16X4)`: `max_txsize_rect_lookup` is |
| 2376 | // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the | 2228 | // TX_16X4 and `sub_tx_size_map` reaches TX_4X4 in two steps, so the |
| 2377 | // depth symbol is the 3-symbol `tx_size_cat1` -- not the 2-symbol | 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 | let depth = if tx_select && !lossless(fctx) { | 2235 | let depth = if tx_select && !lossless(fctx) { |
| 2384 | // lane-av1txbands: every frame reads the real `TXFM_CONTEXT` bands | 2236 | // lane-av1txbands: every frame reads the real `TXFM_CONTEXT` bands |
| 2385 | // (`get_tx_size_context`, libaom `pred_common.h:342`). | 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 | let d = dec.symbol(&mut cdfs.tx_size_cat1[ctx]); | 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 | d | 2240 | d |
| 2397 | } else { | 2241 | } else { |
| 2398 | 0 | 2242 | 0 |
| 2399 | }; | 2243 | }; |
| 2400 | - if depth != 0 { | ||
| 2401 | - hit!(TX_DEPTH_HITS); | ||
| 2402 | - hit!(RECT4_16_SPLIT_HITS); | ||
| 2403 | - } | ||
| 2404 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); | 2244 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 2405 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); | 2245 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 2406 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); | 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 | tu_skip_ctx, | 2311 | tu_skip_ctx, |
| 2472 | dc_sign_ctx(tu_around.2), | 2312 | dc_sign_ctx(tu_around.2), |
| 2473 | TxType::DctDct, | 2313 | TxType::DctDct, |
| 2474 | - 0, | ||
| 2475 | )?; | 2314 | )?; |
| 2476 | let residual = dequant_and_inverse_typed_wh( | 2315 | let residual = dequant_and_inverse_typed_wh( |
| 2477 | &tu_grid, | 2316 | &tu_grid, |
| @@ -2502,9 +2341,6 @@ pub(super) fn decode_rect4_16_strip( | |||
| 2502 | smooth_neighbor, | 2341 | smooth_neighbor, |
| 2503 | fctx, | 2342 | fctx, |
| 2504 | ); | 2343 | ); |
| 2505 | - if tu_grid.iter().any(|&l| l != 0) { | ||
| 2506 | - hit!(RECT4_16_COEFF_HITS); | ||
| 2507 | - } | ||
| 2508 | neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); | 2344 | neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); |
| 2509 | } else { | 2345 | } else { |
| 2510 | let tu_around = neighbours.around_mi(tu_mi, tx_w)[0]; | 2346 | let tu_around = neighbours.around_mi(tu_mi, tx_w)[0]; |
| @@ -2527,16 +2363,12 @@ pub(super) fn decode_rect4_16_strip( | |||
| 2527 | tu_py, | 2363 | tu_py, |
| 2528 | tx_w, | 2364 | tx_w, |
| 2529 | tx_w, | 2365 | tx_w, |
| 2530 | - base_q_idx, | ||
| 2531 | None, | 2366 | None, |
| 2532 | filter_intra, | 2367 | filter_intra, |
| 2533 | Some(tu_skip_ctx), | 2368 | Some(tu_skip_ctx), |
| 2534 | smooth_neighbor, | 2369 | smooth_neighbor, |
| 2535 | fctx, | 2370 | fctx, |
| 2536 | )?; | 2371 | )?; |
| 2537 | - if tu_grid.iter().any(|&l| l != 0) { | ||
| 2538 | - hit!(RECT4_16_COEFF_HITS); | ||
| 2539 | - } | ||
| 2540 | neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid); | 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 | 0, | 2418 | 0, |
| 2587 | dc_sign_ctx(around.2), | 2419 | dc_sign_ctx(around.2), |
| 2588 | TxType::DctDct, | 2420 | TxType::DctDct, |
| 2589 | - 0, | ||
| 2590 | )?; | 2421 | )?; |
| 2591 | let residual = dequant_and_inverse_typed_wh( | 2422 | let residual = dequant_and_inverse_typed_wh( |
| 2592 | &levels, | 2423 | &levels, |
| @@ -2620,7 +2451,6 @@ pub(super) fn decode_rect4_16_strip( | |||
| 2620 | smooth_neighbor, | 2451 | smooth_neighbor, |
| 2621 | fctx, | 2452 | fctx, |
| 2622 | ); | 2453 | ); |
| 2623 | - hit!(RECT4_16_COEFF_HITS); | ||
| 2624 | levels | 2454 | levels |
| 2625 | }; | 2455 | }; |
| 2626 | neighbours.record_mi_luma_rect(lmi, bw, bh, &levels); | 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 | if has_chroma { | 2473 | if has_chroma { |
| 2644 | - hit!(RECT4_16_CHROMA_HITS); | ||
| 2645 | // lane-av1-444: at 4:4:4 there is no pair -- every strip is its | 2474 | // lane-av1-444: at 4:4:4 there is no pair -- every strip is its |
| 2646 | // own chroma reference and codes its own 16x4 / 4x16 chroma | 2475 | // own chroma reference and codes its own 16x4 / 4x16 chroma |
| 2647 | // block. (`set_mi_offsets`'s chroma snap is the zero offset at | 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 | } else { | 2516 | } else { |
| 2688 | uv_mode | 2517 | uv_mode |
| 2689 | }; | 2518 | }; |
| 2690 | - if (V_PRED..=D67_PRED).contains(&uv_predict_mode) { | ||
| 2691 | - hit!(RECT4_16_CHROMA_DIR_HITS); | ||
| 2692 | - } | ||
| 2693 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height, fctx); | 2519 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height, fctx); |
| 2694 | // lane-kf1200 r1: the chroma edge-filter type reads the neighbours | 2520 | // lane-kf1200 r1: the chroma edge-filter type reads the neighbours |
| 2695 | // of the CHROMA block, which for a 16x4/4x16 pair is `pair_mi`'s | 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 | // `av1_use_intra_edge_upsample` on (blk_wh 12 <= 16) for a | 2529 | // `av1_use_intra_edge_upsample` on (blk_wh 12 <= 16) for a |
| 2704 | // directional chroma strip, moving 4 samples by 1. | 2530 | // directional chroma strip, moving 4 samples by 1. |
| 2705 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c, fctx); | 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 | // lane-av1-rect14: a lossless frame forces TX_4X4 on every plane | 2532 | // lane-av1-rect14: a lossless frame forces TX_4X4 on every plane |
| 2734 | // (`av1_get_tx_size`, blockd.h:1381). The pair's chroma block is | 2533 | // (`av1_get_tx_size`, blockd.h:1381). The pair's chroma block is |
| 2735 | // 8x4 (HORZ_4) or 4x8 (VERT_4) -- two TX_4X4s, plane-major | 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 | // mi(1,20) uv_mode matched, the following skip did not). | 2538 | // mi(1,20) uv_mode matched, the following skip did not). |
| 2740 | let lossless_pair = lossless(fctx); | 2539 | let lossless_pair = lossless(fctx); |
| 2741 | let (u_levels, v_levels) = if lossless_pair { | 2540 | let (u_levels, v_levels) = if lossless_pair { |
| 2742 | - hit!(RECT4_16_LOSSLESS_CHROMA_HITS); | ||
| 2743 | if skip { | 2541 | if skip { |
| 2744 | for plane in 1..3usize { | 2542 | for plane in 1..3usize { |
| 2745 | for rr in 0..ch / 4 { | 2543 | for rr in 0..ch / 4 { |
| @@ -2773,11 +2571,6 @@ pub(super) fn decode_rect4_16_strip( | |||
| 2773 | 4 << ss_x(fctx), | 2571 | 4 << ss_x(fctx), |
| 2774 | 4 << ss_y(fctx), | 2572 | 4 << ss_y(fctx), |
| 2775 | pair_reach, | 2573 | pair_reach, |
| 2776 | - ppx, | ||
| 2777 | - ppy, | ||
| 2778 | - y.width, | ||
| 2779 | - y.height, | ||
| 2780 | - fctx, | ||
| 2781 | ); | 2574 | ); |
| 2782 | if let Some((ub, vb)) = &palette_uv_bufs { | 2575 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 2783 | let buf = if plane == 1 { ub } else { vb }; | 2576 | let buf = if plane == 1 { ub } else { vb }; |
| @@ -2868,11 +2661,6 @@ pub(super) fn decode_rect4_16_strip( | |||
| 2868 | 4 << ss_x(fctx), | 2661 | 4 << ss_x(fctx), |
| 2869 | 4 << ss_y(fctx), | 2662 | 4 << ss_y(fctx), |
| 2870 | pair_reach, | 2663 | pair_reach, |
| 2871 | - ppx, | ||
| 2872 | - ppy, | ||
| 2873 | - y.width, | ||
| 2874 | - y.height, | ||
| 2875 | - fctx, | ||
| 2876 | ); | 2664 | ); |
| 2877 | if let Some((ub, vb)) = &palette_uv_bufs { | 2665 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 2878 | let buf = if plane == 1 { ub } else { vb }; | 2666 | let buf = if plane == 1 { ub } else { vb }; |
| @@ -2896,7 +2684,6 @@ pub(super) fn decode_rect4_16_strip( | |||
| 2896 | cpy + oy, | 2684 | cpy + oy, |
| 2897 | 4, | 2685 | 4, |
| 2898 | 4, | 2686 | 4, |
| 2899 | - base_q_idx, | ||
| 2900 | None, | 2687 | None, |
| 2901 | None, | 2688 | None, |
| 2902 | offset, | 2689 | offset, |
| @@ -2910,7 +2697,6 @@ pub(super) fn decode_rect4_16_strip( | |||
| 2910 | plane, | 2697 | plane, |
| 2911 | &cu_grid, | 2698 | &cu_grid, |
| 2912 | ); | 2699 | ); |
| 2913 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 2914 | let dst = if plane == 1 { &mut uo } else { &mut vo }; | 2700 | let dst = if plane == 1 { &mut uo } else { &mut vo }; |
| 2915 | for row in 0..4 { | 2701 | for row in 0..4 { |
| 2916 | let start = (oy + row) * cw + ox; | 2702 | let start = (oy + row) * cw + ox; |
| @@ -2929,9 +2715,6 @@ pub(super) fn decode_rect4_16_strip( | |||
| 2929 | // DC + alpha * luma-AC. Dropping the CfL term here left a | 2715 | // DC + alpha * luma-AC. Dropping the CfL term here left a |
| 2930 | // chroma-only bounded box on ReelC's key frames. | 2716 | // chroma-only bounded box on ReelC's key frames. |
| 2931 | let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph)); | 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 | for plane in [1usize, 2] { | 2718 | for plane in [1usize, 2] { |
| 2936 | if chroma422_pair16 { | 2719 | if chroma422_pair16 { |
| 2937 | // lane-av1-422o: two TX_4X8 units, each predicted on | 2720 | // lane-av1-422o: two TX_4X8 units, each predicted on |
| @@ -2940,20 +2723,7 @@ pub(super) fn decode_rect4_16_strip( | |||
| 2940 | // `set_entropy_context` zeroed the block's own cells, | 2723 | // `set_entropy_context` zeroed the block's own cells, |
| 2941 | // so the pair-wide zero stamp below stays correct. | 2724 | // so the pair-wide zero stamp below stays correct. |
| 2942 | for unit_row in 0..2usize { | 2725 | for unit_row in 0..2usize { |
| 2943 | - let unit_reach = tu_reach_rect( | 2726 | + let unit_reach = tu_reach_rect(pw, ph, 0, unit_row * 8, 8, 8, pair_reach); |
| 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 | - ); | ||
| 2957 | if let Some((ub, vb)) = &palette_uv_bufs { | 2727 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 2958 | let pbuf = if plane == 1 { ub } else { vb }; | 2728 | let pbuf = if plane == 1 { ub } else { vb }; |
| 2959 | set_palette_pred(palette_window(pbuf, cw, 0, unit_row * 8, 4, 8), fctx); | 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 | for plane in [1usize, 2] { | 2799 | for plane in [1usize, 2] { |
| 3030 | for unit_row in 0..2usize { | 2800 | for unit_row in 0..2usize { |
| 3031 | let unit_mi = (pair_mi.0 + unit_row * 2, pair_mi.1); | 2801 | let unit_mi = (pair_mi.0 + unit_row * 2, pair_mi.1); |
| 3032 | - let unit_reach = tu_reach_rect( | 2802 | + let unit_reach = tu_reach_rect(pw, ph, 0, unit_row * 8, 8, 8, pair_reach); |
| 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 | - ); | ||
| 3046 | if let Some((ub, vb)) = &palette_uv_bufs { | 2803 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 3047 | let pbuf = if plane == 1 { ub } else { vb }; | 2804 | let pbuf = if plane == 1 { ub } else { vb }; |
| 3048 | set_palette_pred(palette_window(pbuf, cw, 0, unit_row * 8, 4, 8), fctx); | 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 | // row is unreachable there. It is also the witness arm: | 2872 | // row is unreachable there. It is also the witness arm: |
| 3116 | // a restored `/2 chroma height` lands on (8,4) and the | 2873 | // a restored `/2 chroma height` lands on (8,4) and the |
| 3117 | // counter reads 0. | 2874 | // counter reads 0. |
| 3118 | - (8, 8) => { | 2875 | + (8, 8) => (TxbSet::Chroma8, default_scan(8)), |
| 3119 | - hit!(CHROMA422_SQUARE_HITS); | ||
| 3120 | - (TxbSet::Chroma8, default_scan(8)) | ||
| 3121 | - } | ||
| 3122 | // lane-av1-422o: with the `chroma422_pair16` arm above, | 2876 | // lane-av1-422o: with the `chroma422_pair16` arm above, |
| 3123 | // the (2,16) own-strip shape and the 4:4:4 shapes are the | 2877 | // the (2,16) own-strip shape and the 4:4:4 shapes are the |
| 3124 | // only residents; anything else is a named-lane gap. | 2878 | // only residents; anything else is a named-lane gap. |
| @@ -3141,7 +2895,6 @@ pub(super) fn decode_rect4_16_strip( | |||
| 3141 | dc_sign_ctx(around[plane].2), | 2895 | dc_sign_ctx(around[plane].2), |
| 3142 | default_tx, | 2896 | default_tx, |
| 3143 | fctx, | 2897 | fctx, |
| 3144 | - plane, | ||
| 3145 | )?; | 2898 | )?; |
| 3146 | planes.push((levels, tx_type)); | 2899 | planes.push((levels, tx_type)); |
| 3147 | } | 2900 | } |
| @@ -3225,11 +2978,6 @@ pub(super) fn decode_rect4_16_strip( | |||
| 3225 | } | 2978 | } |
| 3226 | last_uv_mode = Some(uv_predict_mode); | 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 | let (pal_y_size, pal_y_colors) = palette_y | 2981 | let (pal_y_size, pal_y_colors) = palette_y |
| 3234 | .as_ref() | 2982 | .as_ref() |
| 3235 | .map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | 2983 | .map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| @@ -3354,17 +3102,7 @@ pub(super) fn decode_block_rect64( | |||
| 3354 | fctx, | 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 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | 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 | let smooth_neighbor_uv = | 3106 | let smooth_neighbor_uv = |
| 3369 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c, fctx); | 3107 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c, fctx); |
| 3370 | if filter_intra.is_some() { | 3108 | if filter_intra.is_some() { |
| @@ -3394,7 +3132,7 @@ pub(super) fn decode_block_rect64( | |||
| 3394 | // 1920x792 128-superblock stream, | 3132 | // 1920x792 128-superblock stream, |
| 3395 | // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read | 3133 | // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read |
| 3396 | // `tx_size_cat2` row 1 where libaom reads row 2. | 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 | // lane-rectsplit r1: `bsize_to_tx_size_cat` (libaom `decodemv.c`) | 3136 | // lane-rectsplit r1: `bsize_to_tx_size_cat` (libaom `decodemv.c`) |
| 3399 | // counts `sub_tx_size_map` steps from the block's own max rect | 3137 | // counts `sub_tx_size_map` steps from the block's own max rect |
| 3400 | // transform down to TX_4X4, minus one -- BLOCK_64X32's chain | 3138 | // transform down to TX_4X4, minus one -- BLOCK_64X32's chain |
| @@ -3403,12 +3141,6 @@ pub(super) fn decode_block_rect64( | |||
| 3403 | // block uses), not the 2 a 32x16 strip uses. Reading the cat-2 CDF | 3141 | // block uses), not the 2 a 32x16 strip uses. Reading the cat-2 CDF |
| 3404 | // here was a wrong-table read of a real symbol. | 3142 | // here was a wrong-table read of a real symbol. |
| 3405 | let d = dec.symbol(&mut cdfs.tx_size_cat3[ctx]); | 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 | d | 3144 | d |
| 3413 | } else { | 3145 | } else { |
| 3414 | 0 | 3146 | 0 |
| @@ -3423,28 +3155,12 @@ pub(super) fn decode_block_rect64( | |||
| 3423 | fctx, | 3155 | fctx, |
| 3424 | ); | 3156 | ); |
| 3425 | if depth != 0 || lossless(fctx) { | 3157 | if depth != 0 || lossless(fctx) { |
| 3426 | - hit!(TX_DEPTH_HITS); | ||
| 3427 | // lane-rectsplit r1/r4: the superblock-level strip splits its | 3158 | // lane-rectsplit r1/r4: the superblock-level strip splits its |
| 3428 | // transform through the very same per-unit path as its 32x32-level | 3159 | // transform through the very same per-unit path as its 32x32-level |
| 3429 | // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 | 3160 | // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 |
| 3430 | // 1:4 strip is the 2:1 rect TX_32X16 at depth 1 (lane-rectchroma r1 | 3161 | // 1:4 strip is the 2:1 rect TX_32X16 at depth 1 (lane-rectchroma r1 |
| 3431 | // measured the old square formula mis-tiling exactly that strip). | 3162 | // measured the old square formula mis-tiling exactly that strip). |
| 3432 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); | 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 | let modes = RectStripModes { | 3164 | let modes = RectStripModes { |
| 3449 | skip, | 3165 | skip, |
| 3450 | mode, | 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 | decode_rect_split( | 3184 | decode_rect_split( |
| 3472 | dec, | 3185 | dec, |
| 3473 | cdfs, | 3186 | cdfs, |
| @@ -3481,7 +3194,6 @@ pub(super) fn decode_block_rect64( | |||
| 3481 | y, | 3194 | y, |
| 3482 | u, | 3195 | u, |
| 3483 | v, | 3196 | v, |
| 3484 | - base_q_idx, | ||
| 3485 | reduced_tx_set, | 3197 | reduced_tx_set, |
| 3486 | fctx, | 3198 | fctx, |
| 3487 | )?; | 3199 | )?; |
| @@ -3506,8 +3218,6 @@ pub(super) fn decode_block_rect64( | |||
| 3506 | // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The | 3218 | // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The |
| 3507 | // bands carry the SPLIT unit's size, not the block's. | 3219 | // bands carry the SPLIT unit's size, not the block's. |
| 3508 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); | 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 | return Ok(()); | 3221 | return Ok(()); |
| 3512 | } | 3222 | } |
| 3513 | let (tx_w, tx_h) = (bw, bh); | 3223 | let (tx_w, tx_h) = (bw, bh); |
| @@ -3617,12 +3327,6 @@ pub(super) fn decode_block_rect64( | |||
| 3617 | // 32x16/16x32 under a 64x16/16x64 1:4 strip (lane-tx64x16). | 3327 | // 32x16/16x32 under a 64x16/16x64 1:4 strip (lane-tx64x16). |
| 3618 | let (luma_cw, luma_ch) = (bw.min(32), bh.min(32)); | 3328 | let (luma_cw, luma_ch) = (bw.min(32), bh.min(32)); |
| 3619 | let scan32 = default_scan(TX32); | 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 | let (luma_corner, luma_tx_type) = if (luma_cw, luma_ch) == (32, 32) { | 3330 | let (luma_corner, luma_tx_type) = if (luma_cw, luma_ch) == (32, 32) { |
| 3627 | let mut luma_coding = cdfs.txb(TxbSet::Luma64, mode); | 3331 | let mut luma_coding = cdfs.txb(TxbSet::Luma64, mode); |
| 3628 | read_coeffs( | 3332 | read_coeffs( |
| @@ -3659,29 +3363,13 @@ pub(super) fn decode_block_rect64( | |||
| 3659 | 0, | 3363 | 0, |
| 3660 | dc_sign_ctx(around[0].2), | 3364 | dc_sign_ctx(around[0].2), |
| 3661 | TxType::DctDct, | 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 | let mut luma_levels = vec![0i32; bw * bh]; | 3368 | let mut luma_levels = vec![0i32; bw * bh]; |
| 3670 | for row in 0..luma_ch { | 3369 | for row in 0..luma_ch { |
| 3671 | luma_levels[row * bw..][..luma_cw] | 3370 | luma_levels[row * bw..][..luma_cw] |
| 3672 | .copy_from_slice(&luma_corner[row * luma_cw..][..luma_cw]); | 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 | let luma_residual = dequant_and_inverse_typed_wh( | 3373 | let luma_residual = dequant_and_inverse_typed_wh( |
| 3686 | &luma_levels, | 3374 | &luma_levels, |
| 3687 | bw, | 3375 | bw, |
| @@ -3711,22 +3399,6 @@ pub(super) fn decode_block_rect64( | |||
| 3711 | smooth_neighbor, | 3399 | smooth_neighbor, |
| 3712 | fctx, | 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 | // CHROMA. At 4:2:0 the plane block is already one adjusted UV | 3402 | // CHROMA. At 4:2:0 the plane block is already one adjusted UV |
| 3731 | // transform (<=32 on each axis). At 4:4:4 a 64-axis strip's chroma | 3403 | // transform (<=32 on each axis). At 4:4:4 a 64-axis strip's chroma |
| 3732 | // is larger than that, so it is tiled into 32-capped units. | 3404 | // is larger than that, so it is tiled into 32-capped units. |
| @@ -3753,15 +3425,6 @@ pub(super) fn decode_block_rect64( | |||
| 3753 | // arm nothing had reached) from `nh >= 2` (the arm the corpus census | 3425 | // arm nothing had reached) from `nh >= 2` (the arm the corpus census |
| 3754 | // already covered), and can see WHY a candidate block did not fire. | 3426 | // already covered), and can see WHY a candidate block did not fire. |
| 3755 | // Diagnostic only; no decode behaviour depends on it. | 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 | let mut u_levels = vec![0i32; chroma_w * chroma_h]; | 3428 | let mut u_levels = vec![0i32; chroma_w * chroma_h]; |
| 3766 | let mut v_levels = vec![0i32; chroma_w * chroma_h]; | 3429 | let mut v_levels = vec![0i32; chroma_w * chroma_h]; |
| 3767 | // The tiled units below stamp their own coefficient context | 3430 | // The tiled units below stamp their own coefficient context |
| @@ -3813,9 +3476,6 @@ pub(super) fn decode_block_rect64( | |||
| 3813 | // nothing. The `bigger` guard is what makes a hit PROOF | 3476 | // nothing. The `bigger` guard is what makes a hit PROOF |
| 3814 | // that the tiled arm ran, rather than proof that some | 3477 | // that the tiled arm ran, rather than proof that some |
| 3815 | // palette chroma block existed. | 3478 | // palette chroma block existed. |
| 3816 | - if bigger { | ||
| 3817 | - hit!(CHROMA_PALETTE_WINDOW_HITS); | ||
| 3818 | - } | ||
| 3819 | } | 3479 | } |
| 3820 | read_plane( | 3480 | read_plane( |
| 3821 | dec, | 3481 | dec, |
| @@ -3835,7 +3495,6 @@ pub(super) fn decode_block_rect64( | |||
| 3835 | cpy + cu_row * uh, | 3495 | cpy + cu_row * uh, |
| 3836 | uw, | 3496 | uw, |
| 3837 | uw, | 3497 | uw, |
| 3838 | - base_q_idx, | ||
| 3839 | cfl, | 3498 | cfl, |
| 3840 | None, | 3499 | None, |
| 3841 | bigger.then_some(3), | 3500 | bigger.then_some(3), |
| @@ -3857,7 +3516,6 @@ pub(super) fn decode_block_rect64( | |||
| 3857 | dc_sign_ctx(cu_around[plane_idx].2), | 3516 | dc_sign_ctx(cu_around[plane_idx].2), |
| 3858 | TxType::DctDct, | 3517 | TxType::DctDct, |
| 3859 | fctx, | 3518 | fctx, |
| 3860 | - plane_idx, | ||
| 3861 | )?; | 3519 | )?; |
| 3862 | let residual = dequant_and_inverse_typed_wh( | 3520 | let residual = dequant_and_inverse_typed_wh( |
| 3863 | &levels, | 3521 | &levels, |
| @@ -3883,9 +3541,6 @@ pub(super) fn decode_block_rect64( | |||
| 3883 | // nothing. The `bigger` guard is what makes a hit PROOF | 3541 | // nothing. The `bigger` guard is what makes a hit PROOF |
| 3884 | // that the tiled arm ran, rather than proof that some | 3542 | // that the tiled arm ran, rather than proof that some |
| 3885 | // palette chroma block existed. | 3543 | // palette chroma block existed. |
| 3886 | - if bigger { | ||
| 3887 | - hit!(CHROMA_PALETTE_WINDOW_HITS); | ||
| 3888 | - } | ||
| 3889 | } | 3544 | } |
| 3890 | push_intra_rect( | 3545 | push_intra_rect( |
| 3891 | y, | 3546 | y, |
| @@ -3949,7 +3604,6 @@ pub(super) fn decode_block_rect64( | |||
| 3949 | for (cu_mi, plane, unit, span_w, span_h) in &tiled_chroma_units { | 3604 | for (cu_mi, plane, unit, span_w, span_h) in &tiled_chroma_units { |
| 3950 | neighbours.record_mi_chroma(*cu_mi, *span_w, *span_h, *plane, unit); | 3605 | neighbours.record_mi_chroma(*cu_mi, *span_w, *span_h, *plane, unit); |
| 3951 | } | 3606 | } |
| 3952 | - hit!(RECT_COEFF_HITS); | ||
| 3953 | } | 3607 | } |
| 3954 | let (py_size, py_colors) = palette_y | 3608 | let (py_size, py_colors) = palette_y |
| 3955 | .as_ref() | 3609 | .as_ref() |
| @@ -3980,15 +3634,5 @@ pub(super) fn decode_block_rect64( | |||
| 3980 | // 3840x1608 10-bit stream's first silent wall, decode-order frame 33 at | 3634 | // 3840x1608 10-bit stream's first silent wall, decode-order frame 33 at |
| 3981 | // mi(16,480)). Same write as [`set_txfm_ctxs`], rect-aware. | 3635 | // mi(16,480)). Same write as [`set_txfm_ctxs`], rect-aware. |
| 3982 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); | 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 | Ok(()) | 3637 | Ok(()) |
| 3994 | } | 3638 | } |
crates/ec-av1/src/decode/replay.rsmodified+0 -18
| @@ -179,7 +179,6 @@ fn replay_inner( | |||
| 179 | &mut v, | 179 | &mut v, |
| 180 | cdef, | 180 | cdef, |
| 181 | &r.neighbours, | 181 | &r.neighbours, |
| 182 | - (r.frame_width, r.frame_height), | ||
| 183 | fctx, | 182 | fctx, |
| 184 | pre, | 183 | pre, |
| 185 | Some(&mut wrote), | 184 | Some(&mut wrote), |
| @@ -449,7 +448,6 @@ pub(super) fn cdef_band( | |||
| 449 | coeff_shift: i32, | 448 | coeff_shift: i32, |
| 450 | damping: i32, | 449 | damping: i32, |
| 451 | damping_uv: i32, | 450 | damping_uv: i32, |
| 452 | - (frame_w, frame_h): (usize, usize), | ||
| 453 | fctx: &crate::decode::FrameCtx, | 451 | fctx: &crate::decode::FrameCtx, |
| 454 | ) { | 452 | ) { |
| 455 | let unit_cols = skip_grid.mi_cols.div_ceil(2); | 453 | let unit_cols = skip_grid.mi_cols.div_ceil(2); |
| @@ -471,9 +469,6 @@ pub(super) fn cdef_band( | |||
| 471 | while mi_r < r_hi { | 469 | while mi_r < r_hi { |
| 472 | let mut mi_c = 0usize; | 470 | let mut mi_c = 0usize; |
| 473 | while mi_c < skip_grid.mi_cols { | 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 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { | 472 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { |
| 478 | let sidx = strength_idx(mi_r, mi_c); | 473 | let sidx = strength_idx(mi_r, mi_c); |
| 479 | let (ox, oy) = (mi_c * 4, mi_r * 4); | 474 | let (ox, oy) = (mi_c * 4, mi_r * 4); |
| @@ -511,21 +506,8 @@ pub(super) fn cdef_band( | |||
| 511 | let y_dir = if y_pri_strength != 0 { dir } else { 0 }; | 506 | let y_dir = if y_pri_strength != 0 { dir } else { 0 }; |
| 512 | let t = cdef_adjust_strength(y_pri_strength, var); | 507 | let t = cdef_adjust_strength(y_pri_strength, var); |
| 513 | // lane-cdef r1 rung: one line per filtered 8x8 luma CDEF unit. | 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 | let enable_primary = t != 0; | 509 | let enable_primary = t != 0; |
| 520 | let enable_secondary = y_sec_strength != 0; | 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 | if enable_primary || enable_secondary { | 511 | if enable_primary || enable_secondary { |
| 530 | cdef_filter_block( | 512 | cdef_filter_block( |
| 531 | &win_y, | 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 | ) -> Result<()> { | 62 | ) -> Result<()> { |
| 63 | const LAST_FRAME: i8 = 1; | 63 | const LAST_FRAME: i8 = 1; |
| 64 | const B4: usize = 4; | 64 | const B4: usize = 4; |
| 65 | - hit!(SUB8_INTER_SPLIT_HITS); | ||
| 66 | let (gr, gc) = group_mi; | 65 | let (gr, gc) = group_mi; |
| 67 | let (gpx, gpy) = (gc * MI, gr * MI); | 66 | let (gpx, gpy) = (gc * MI, gr * MI); |
| 68 | let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx)); | 67 | let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx)); |
| @@ -72,7 +71,6 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 72 | let mut piece: [Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>; 4] = | 71 | let mut piece: [Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>; 4] = |
| 73 | [None; 4]; | 72 | [None; 4]; |
| 74 | let mut first_tx_type = TxType::DctDct; | 73 | let mut first_tx_type = TxType::DctDct; |
| 75 | - let mut sub0_tx_type = TxType::DctDct; | ||
| 76 | // This loop iteration's own sub-block luma `tx_type` (libaom `mbmi->tx_type` | 74 | // This loop iteration's own sub-block luma `tx_type` (libaom `mbmi->tx_type` |
| 77 | // after its `read_tx_type`): the per-piece 4:4:4 chroma units inherit it | 75 | // after its `read_tx_type`): the per-piece 4:4:4 chroma units inherit it |
| 78 | // (`av1_get_tx_type`, blockd.h -- inter chroma never codes its own symbol). | 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 | let skip_ctx = | 109 | let skip_ctx = |
| 112 | usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); | 110 | usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); |
| 113 | let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; | 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 | inter_segment_id(dec, cdfs, rmi, cmi, 1, 1, skip, false, fctx); | 112 | inter_segment_id(dec, cdfs, rmi, cmi, 1, 1, skip, false, fctx); |
| 120 | maybe_read_cdef_idx(dec, rmi, cmi, (2, 2), skip, fctx); | 113 | maybe_read_cdef_idx(dec, rmi, cmi, (2, 2), skip, fctx); |
| 121 | maybe_read_delta_q(dec, cdfs, rmi, cmi, false, skip, fctx); | 114 | maybe_read_delta_q(dec, cdfs, rmi, cmi, false, skip, fctx); |
| @@ -128,32 +121,7 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 128 | neighbours.left_inter[rmi], | 121 | neighbours.left_inter[rmi], |
| 129 | ); | 122 | ); |
| 130 | let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; | 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 | if !is_inter { | 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 | // lane-sub8intra: the `BLOCK_4X4` twin of the HORZ/VERT arm -- | 125 | // lane-sub8intra: the `BLOCK_4X4` twin of the HORZ/VERT arm -- |
| 158 | // same [`decode_intra_sub8_leaf`], no tx-depth symbol, chroma on | 126 | // same [`decode_intra_sub8_leaf`], no tx-depth symbol, chroma on |
| 159 | // the chroma-reference sub-blocks (`is_chroma_reference`: the | 127 | // the chroma-reference sub-blocks (`is_chroma_reference`: the |
| @@ -173,7 +141,6 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 173 | y, | 141 | y, |
| 174 | u, | 142 | u, |
| 175 | v, | 143 | v, |
| 176 | - base_q_idx, | ||
| 177 | fctx.enable_filter_intra_inter.with(std::cell::Cell::get), | 144 | fctx.enable_filter_intra_inter.with(std::cell::Cell::get), |
| 178 | fctx.tx_select_inter.with(std::cell::Cell::get), | 145 | fctx.tx_select_inter.with(std::cell::Cell::get), |
| 179 | reduced_tx_set, | 146 | reduced_tx_set, |
| @@ -187,12 +154,6 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 187 | // Same print point as the oracle's `EC_MODE` (entry of | 154 | // Same print point as the oracle's `EC_MODE` (entry of |
| 188 | // `read_inter_block_mode_info`, i.e. after skip / is_inter), so the | 155 | // `read_inter_block_mode_info`, i.e. after skip / is_inter), so the |
| 189 | // two range ladders line up element for element. | 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 | let ref_frame = read_single_ref( | 157 | let ref_frame = read_single_ref( |
| 197 | dec, | 158 | dec, |
| 198 | cdfs, | 159 | cdfs, |
| @@ -209,9 +170,6 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 209 | // each of the group's pieces (luma and its 2x2 chroma) carries its | 170 | // each of the group's pieces (luma and its 2x2 chroma) carries its |
| 210 | // OWN factor because each can name a different `ref_frame`. | 171 | // OWN factor because each can name a different `ref_frame`. |
| 211 | let luma_scale = scale_of((ref_width, ref_height), frame_size); | 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 | let gm_table = build_gm_mv_table( | 173 | let gm_table = build_gm_mv_table( |
| 216 | global_motion, | 174 | global_motion, |
| 217 | rmi, | 175 | rmi, |
| @@ -245,10 +203,6 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 245 | tpl, | 203 | tpl, |
| 246 | ); | 204 | ); |
| 247 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; | 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 | let (mv, is_new_mv) = if !not_new { | 206 | let (mv, is_new_mv) = if !not_new { |
| 253 | let mut idx = 0usize; | 207 | let mut idx = 0usize; |
| 254 | while idx < 2 && stack.entries.len() > idx + 1 { | 208 | while idx < 2 && stack.entries.len() > idx + 1 { |
| @@ -272,15 +226,10 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 272 | ) | 226 | ) |
| 273 | } else { | 227 | } else { |
| 274 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; | 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 | let mv = if !not_zero { | 229 | let mv = if !not_zero { |
| 280 | gm_table[(ref_frame - LAST_FRAME) as usize] | 230 | gm_table[(ref_frame - LAST_FRAME) as usize] |
| 281 | } else { | 231 | } else { |
| 282 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; | 232 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; |
| 283 | - crate::census::mode(if nearest { 2 } else { 3 }); | ||
| 284 | if nearest { | 233 | if nearest { |
| 285 | stack.nearest_mv | 234 | stack.nearest_mv |
| 286 | } else { | 235 | } else { |
| @@ -298,17 +247,8 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 298 | }; | 247 | }; |
| 299 | // Same print point as the oracle's `EC_MODE_MV` (right after | 248 | // Same print point as the oracle's `EC_MODE_MV` (right after |
| 300 | // `assign_mv`), the second rung of the sub-8x8 range ladder. | 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 | // No `interintra` and no `motion_mode`/`obmc` symbol below 8x8 (see | 250 | // No `interintra` and no `motion_mode`/`obmc` symbol below 8x8 (see |
| 310 | // this function's own doc); `read_mb_interp_filter` still runs. | 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 | let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame | 252 | let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame |
| 313 | || neighbours.above_ref1[cmi] == Some(ref_frame) | 253 | || neighbours.above_ref1[cmi] == Some(ref_frame) |
| 314 | { | 254 | { |
| @@ -323,25 +263,10 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 323 | } else { | 263 | } else { |
| 324 | [3, 3] | 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 | // lane-t900 r9: this reader's sub-blocks have a 4-px side, and libaom | 266 | // lane-t900 r9: this reader's sub-blocks have a 4-px side, and libaom |
| 339 | // `is_nontrans_global_motion` returns 0 for | 267 | // `is_nontrans_global_motion` returns 0 for |
| 340 | // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model -- | 268 | // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model -- |
| 341 | // so a GLOBALMV sub-block here always reads its interp filter. | 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 | let gm_nontrans = false; | 270 | let gm_nontrans = false; |
| 346 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( | 271 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( |
| 347 | dec, | 272 | dec, |
| @@ -353,16 +278,6 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 353 | left_filter_ctx, | 278 | left_filter_ctx, |
| 354 | false, | 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 | grid.set( | 281 | grid.set( |
| 367 | rmi, | 282 | rmi, |
| 368 | cmi, | 283 | cmi, |
| @@ -412,7 +327,11 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 412 | let pred_y: Vec<u16>; | 327 | let pred_y: Vec<u16>; |
| 413 | let sy = if pred_deferred(refpix) { | 328 | let sy = if pred_deferred(refpix) { |
| 414 | push_pred(build); | 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 | } else { | 335 | } else { |
| 417 | let mut built: [Vec<u16>; 3] = Default::default(); | 336 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 418 | build(y, u, v, refpix, fctx, &mut built); | 337 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -454,9 +373,6 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 454 | fctx, | 373 | fctx, |
| 455 | )?; | 374 | )?; |
| 456 | piece_tx_type = tx_type; | 375 | piece_tx_type = tx_type; |
| 457 | - if i == 0 { | ||
| 458 | - sub0_tx_type = tx_type; | ||
| 459 | - } | ||
| 460 | if i == 3 { | 376 | if i == 3 { |
| 461 | // `av1_get_tx_type`'s chroma tail scales `blk_row`/`blk_col` | 377 | // `av1_get_tx_type`'s chroma tail scales `blk_row`/`blk_col` |
| 462 | // back by the subsampling, but it indexes `xd->tx_type_map`, | 378 | // back by the subsampling, but it indexes `xd->tx_type_map`, |
| @@ -522,7 +438,18 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 522 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); | 438 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); |
| 523 | let (su, sv) = if pred_deferred(refpix) { | 439 | let (su, sv) = if pred_deferred(refpix) { |
| 524 | push_pred(build_c); | 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 | } else { | 453 | } else { |
| 527 | let mut built: [Vec<u16>; 3] = Default::default(); | 454 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 528 | build_c(y, u, v, refpix, fctx, &mut built); | 455 | build_c(y, u, v, refpix, fctx, &mut built); |
| @@ -706,7 +633,18 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 706 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); | 633 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); |
| 707 | let (su, sv) = if pred_deferred(refpix) { | 634 | let (su, sv) = if pred_deferred(refpix) { |
| 708 | push_pred(build_c); | 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 | } else { | 648 | } else { |
| 711 | let mut built: [Vec<u16>; 3] = Default::default(); | 649 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 712 | build_c(y, u, v, refpix, fctx, &mut built); | 650 | build_c(y, u, v, refpix, fctx, &mut built); |
| @@ -747,7 +685,6 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 747 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]); | 685 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]); |
| 748 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]); | 686 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]); |
| 749 | } else { | 687 | } else { |
| 750 | - hit!(CHROMA422_INTER_SUB8_HITS); | ||
| 751 | let (ug, _) = read_inter_plane( | 688 | let (ug, _) = read_inter_plane( |
| 752 | dec, | 689 | dec, |
| 753 | cdfs, | 690 | cdfs, |
| @@ -860,15 +797,6 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 860 | // mi of the group is intra: the group's 4x4 chroma is then predicted WHOLE | 797 | // mi of the group is intra: the group's 4x4 chroma is then predicted WHOLE |
| 861 | // from the chroma-reference (last) sub-block's own mv, not in 2x2 pieces. | 798 | // from the chroma-reference (last) sub-block's own mv, not in 2x2 pieces. |
| 862 | let mixed = piece.iter().any(Option::is_none); | 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 | // lane-sub8group: the group's chroma pieces, built where they are | 800 | // lane-sub8group: the group's chroma pieces, built where they are |
| 873 | // written -- the pieces' refs/mvs/filters travel by value. | 801 | // written -- the pieces' refs/mvs/filters travel by value. |
| 874 | let build = move |_y: &mut PlaneBuf<'static>, | 802 | let build = move |_y: &mut PlaneBuf<'static>, |
| @@ -934,7 +862,18 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 934 | let (pred_u, pred_v): (Vec<u16>, Vec<u16>); | 862 | let (pred_u, pred_v): (Vec<u16>, Vec<u16>); |
| 935 | let (su, sv) = if pred_deferred(refpix) { | 863 | let (su, sv) = if pred_deferred(refpix) { |
| 936 | push_pred(build); | 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 | } else { | 877 | } else { |
| 939 | let mut built: [Vec<u16>; 3] = Default::default(); | 878 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 940 | build(y, u, v, refpix, fctx, &mut built); | 879 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -1012,8 +951,6 @@ pub(super) fn decode_inter_sub8_split4( | |||
| 1012 | fctx, | 951 | fctx, |
| 1013 | )? | 952 | )? |
| 1014 | .0; | 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 | (ug, vg) | 954 | (ug, vg) |
| 1018 | }; | 955 | }; |
| 1019 | let round_up_even = |n: usize| n.div_ceil(2) * 2; | 956 | let round_up_even = |n: usize| n.div_ceil(2) * 2; |
| @@ -1066,7 +1003,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1066 | grid: &mut MiGrid, | 1003 | grid: &mut MiGrid, |
| 1067 | group_mi: (usize, usize), | 1004 | group_mi: (usize, usize), |
| 1068 | lmi: (usize, usize), | 1005 | lmi: (usize, usize), |
| 1069 | - // `(bw, bh)`: 8x4 / 4x8 under HORZ/VERT, 4x4 under SPLIT. | ||
| 1070 | (bw, bh): (usize, usize), | 1006 | (bw, bh): (usize, usize), |
| 1071 | has_chroma: bool, | 1007 | has_chroma: bool, |
| 1072 | skip: bool, | 1008 | skip: bool, |
| @@ -1074,7 +1010,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1074 | y: &mut PlaneBuf<'static>, | 1010 | y: &mut PlaneBuf<'static>, |
| 1075 | u: &mut PlaneBuf<'static>, | 1011 | u: &mut PlaneBuf<'static>, |
| 1076 | v: &mut PlaneBuf<'static>, | 1012 | v: &mut PlaneBuf<'static>, |
| 1077 | - base_q_idx: u8, | ||
| 1078 | enable_filter_intra: bool, | 1013 | enable_filter_intra: bool, |
| 1079 | tx_select: bool, | 1014 | tx_select: bool, |
| 1080 | reduced_tx_set: bool, | 1015 | reduced_tx_set: bool, |
| @@ -1090,19 +1025,9 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1090 | let (above_mode, left_mode) = neighbours.modes_above_left(r, c); | 1025 | let (above_mode, left_mode) = neighbours.modes_above_left(r, c); |
| 1091 | let leaf_above = neighbours.mode_above_mi(lmi.0, lmi.1).unwrap_or(above_mode); | 1026 | let leaf_above = neighbours.mode_above_mi(lmi.0, lmi.1).unwrap_or(above_mode); |
| 1092 | let leaf_left = neighbours.mode_left_mi(lmi.0, lmi.1).unwrap_or(left_mode); | 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 | // `size_group_lookup[BLOCK_8X4] == size_group_lookup[BLOCK_4X8] == 0` | 1028 | // `size_group_lookup[BLOCK_8X4] == size_group_lookup[BLOCK_4X8] == 0` |
| 1095 | // (libaom common_data.h:61). | 1029 | // (libaom common_data.h:61). |
| 1096 | - crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | ||
| 1097 | let mode = dec.symbol(&mut cdfs.y_mode[0]); | 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 | // No angle delta below 8x8 (`av1_use_angle_delta`), for luma or chroma. | 1031 | // No angle delta below 8x8 (`av1_use_angle_delta`), for luma or chroma. |
| 1107 | let angle_delta_y = 0; | 1032 | let angle_delta_y = 0; |
| 1108 | let (uv_mode, alpha) = if has_chroma { | 1033 | let (uv_mode, alpha) = if has_chroma { |
| @@ -1116,31 +1041,15 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1116 | // always 4x4-or-smaller, so the predicate stays true and this read | 1041 | // always 4x4-or-smaller, so the predicate stays true and this read |
| 1117 | // is unchanged. | 1042 | // is unchanged. |
| 1118 | let uv_mode = if cfl_allowed_px(bw, bh, fctx) { | 1043 | let uv_mode = if cfl_allowed_px(bw, bh, fctx) { |
| 1119 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 1120 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 1044 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 1121 | } else { | 1045 | } else { |
| 1122 | - crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 1123 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 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 | let alpha = if uv_mode == UV_CFL_PRED { | 1048 | let alpha = if uv_mode == UV_CFL_PRED { |
| 1137 | Some(read_cfl_alphas(dec, cdfs)) | 1049 | Some(read_cfl_alphas(dec, cdfs)) |
| 1138 | } else { | 1050 | } else { |
| 1139 | None | 1051 | None |
| 1140 | }; | 1052 | }; |
| 1141 | - if (V_PRED..=D67_PRED).contains(&uv_mode) { | ||
| 1142 | - hit!(DIRECTIONAL_UV_HITS); | ||
| 1143 | - } | ||
| 1144 | (uv_mode, alpha) | 1053 | (uv_mode, alpha) |
| 1145 | } else { | 1054 | } else { |
| 1146 | (DC_PRED, None) | 1055 | (DC_PRED, None) |
| @@ -1154,27 +1063,8 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1154 | .expect("BLOCK_4X8/BLOCK_8X4 are inside av1_filter_intra_allowed_bsize") | 1063 | .expect("BLOCK_4X8/BLOCK_8X4 are inside av1_filter_intra_allowed_bsize") |
| 1155 | }; | 1064 | }; |
| 1156 | let use_fi = dec.symbol(&mut cdfs.filter_intra[fi_class]); | 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 | if use_fi != 0 { | 1066 | if use_fi != 0 { |
| 1166 | - hit!(FILTER_INTRA_HITS); | ||
| 1167 | - hit!(FILTER_INTRA_RECT_HITS); | ||
| 1168 | - hit!(FILTER_INTRA_RECT_SUB8_HITS); | ||
| 1169 | let fi = dec.symbol(&mut cdfs.filter_intra_mode); | 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 | filter_intra = Some(fi); | 1068 | filter_intra = Some(fi); |
| 1179 | } | 1069 | } |
| 1180 | } | 1070 | } |
| @@ -1190,24 +1080,12 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1190 | // no depth symbol either (sweep of the class fixed at the key-frame pair | 1080 | // no depth symbol either (sweep of the class fixed at the key-frame pair |
| 1191 | // path). | 1081 | // path). |
| 1192 | let depth = if tx_select && bw != bh && !lossless(fctx) { | 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 | let d = dec.symbol(&mut cdfs.tx_size_cat0[ctx]); | 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 | d | 1085 | d |
| 1204 | } else { | 1086 | } else { |
| 1205 | 0 | 1087 | 0 |
| 1206 | }; | 1088 | }; |
| 1207 | - if depth != 0 { | ||
| 1208 | - hit!(TX_DEPTH_HITS); | ||
| 1209 | - hit!(RECT8_SPLIT_TX_HITS); | ||
| 1210 | - } | ||
| 1211 | let split = depth != 0 || (lossless(fctx) && bw != bh); | 1089 | let split = depth != 0 || (lossless(fctx) && bw != bh); |
| 1212 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); | 1090 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 1213 | let reach = if bw == bh { | 1091 | let reach = if bw == bh { |
| @@ -1216,9 +1094,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1216 | Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx) | 1094 | Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx) |
| 1217 | }; | 1095 | }; |
| 1218 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); | 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 | neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); | 1097 | neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); |
| 1223 | let scan: &[u16] = if vert { &SCAN_4X8 } else { &SCAN_8X4 }; | 1098 | let scan: &[u16] = if vert { &SCAN_4X8 } else { &SCAN_8X4 }; |
| 1224 | if split { | 1099 | if split { |
| @@ -1231,19 +1106,7 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1231 | (lmi.0, lmi.1 + tu) | 1106 | (lmi.0, lmi.1 + tu) |
| 1232 | }; | 1107 | }; |
| 1233 | let (tu_px, tu_py) = (tu_mi.1 * MI, tu_mi.0 * MI); | 1108 | let (tu_px, tu_py) = (tu_mi.1 * MI, tu_mi.0 * MI); |
| 1234 | - let tu_reach = tu_reach( | 1109 | + let tu_reach = tu_reach(bw, bh, tu_px - px, tu_py - py, 4, 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 | - ); | ||
| 1247 | if skip { | 1110 | if skip { |
| 1248 | let zeros = vec![0i32; 16]; | 1111 | let zeros = vec![0i32; 16]; |
| 1249 | push_intra( | 1112 | push_intra( |
| @@ -1290,7 +1153,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1290 | tu_py, | 1153 | tu_py, |
| 1291 | 4, | 1154 | 4, |
| 1292 | TX4, | 1155 | TX4, |
| 1293 | - base_q_idx, | ||
| 1294 | None, | 1156 | None, |
| 1295 | filter_intra, | 1157 | filter_intra, |
| 1296 | Some(tu_skip_ctx), | 1158 | Some(tu_skip_ctx), |
| @@ -1346,7 +1208,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1346 | py, | 1208 | py, |
| 1347 | 4, | 1209 | 4, |
| 1348 | TX4, | 1210 | TX4, |
| 1349 | - base_q_idx, | ||
| 1350 | None, | 1211 | None, |
| 1351 | filter_intra, | 1212 | filter_intra, |
| 1352 | None, | 1213 | None, |
| @@ -1396,7 +1257,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1396 | 0, | 1257 | 0, |
| 1397 | dc_sign_ctx(around.2), | 1258 | dc_sign_ctx(around.2), |
| 1398 | TxType::DctDct, | 1259 | TxType::DctDct, |
| 1399 | - 0, | ||
| 1400 | )?; | 1260 | )?; |
| 1401 | let residual = dequant_and_inverse_typed_wh( | 1261 | let residual = dequant_and_inverse_typed_wh( |
| 1402 | &levels, | 1262 | &levels, |
| @@ -1484,14 +1344,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1484 | is_global_mv1: false, | 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 | // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map | 1347 | // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map |
| 1496 | // needs EVERY writer): a sub-8x8 group published no palette state, so | 1348 | // needs EVERY writer): a sub-8x8 group published no palette state, so |
| 1497 | // once an 8x8 leaf of the same row can BE a palette block, the group | 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 | u, | 1396 | u, |
| 1545 | v, | 1397 | v, |
| 1546 | scan4, | 1398 | scan4, |
| 1547 | - base_q_idx, | ||
| 1548 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), | 1399 | neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c, fctx), |
| 1549 | (bw, bh), | 1400 | (bw, bh), |
| 1550 | fctx, | 1401 | fctx, |
| @@ -1611,10 +1462,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1611 | }); | 1462 | }); |
| 1612 | let mut chroma_stamped_per_unit = false; | 1463 | let mut chroma_stamped_per_unit = false; |
| 1613 | let (u_grid, v_grid): (Grid, Grid) = if skip { | 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 | if chroma_444 && bw != bh { | 1465 | if chroma_444 && bw != bh { |
| 1619 | let zeros = Grid::Zero(bw * bh); | 1466 | let zeros = Grid::Zero(bw * bh); |
| 1620 | push_intra_rect( | 1467 | push_intra_rect( |
| @@ -1718,8 +1565,7 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1718 | // At 4:4:4 a TX_4X4 chroma unit IS one mi cell. | 1565 | // At 4:4:4 a TX_4X4 chroma unit IS one mi cell. |
| 1719 | let tu_mi = (lmi.0 + oy / MI, lmi.1 + ox / MI); | 1566 | let tu_mi = (lmi.0 + oy / MI, lmi.1 + ox / MI); |
| 1720 | let tu_around = neighbours.around_mi(tu_mi, MI); | 1567 | let tu_around = neighbours.around_mi(tu_mi, MI); |
| 1721 | - let tu_r = | 1568 | + let tu_r = tu_reach(bw, bh, ox, oy, 4, reach_c); |
| 1722 | - tu_reach(bw, bh, ox, oy, 4, reach_c, px, py, y.width, y.height, fctx); | ||
| 1723 | // The plane block (8x4/4x8) is bigger than the TX_4X4 | 1569 | // The plane block (8x4/4x8) is bigger than the TX_4X4 |
| 1724 | // transform, so `get_txb_ctx`'s chroma ctx_offset is 10, | 1570 | // transform, so `get_txb_ctx`'s chroma ctx_offset is 10, |
| 1725 | // not 7 -- our chroma tables carry the offset-10 rows at | 1571 | // not 7 -- our chroma tables carry the offset-10 rows at |
| @@ -1743,7 +1589,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1743 | py + oy, | 1589 | py + oy, |
| 1744 | 4, | 1590 | 4, |
| 1745 | TX4, | 1591 | TX4, |
| 1746 | - base_q_idx, | ||
| 1747 | None, | 1592 | None, |
| 1748 | None, | 1593 | None, |
| 1749 | Some(3), | 1594 | Some(3), |
| @@ -1754,7 +1599,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1754 | // (`av1_set_contexts`); the tail's whole-leaf chroma | 1599 | // (`av1_set_contexts`); the tail's whole-leaf chroma |
| 1755 | // stamp below is skipped for this shape. | 1600 | // stamp below is skipped for this shape. |
| 1756 | neighbours.record_mi_chroma(tu_mi, 4, 4, plane_idx, &tu_grid); | 1601 | neighbours.record_mi_chroma(tu_mi, 4, 4, plane_idx, &tu_grid); |
| 1757 | - hit!(CHROMA_SPLIT_TX_HITS); | ||
| 1758 | let dst = mu_units(if plane_idx == 1 { &mut uo } else { &mut vo }, bw * bh); | 1602 | let dst = mu_units(if plane_idx == 1 { &mut uo } else { &mut vo }, bw * bh); |
| 1759 | for row in 0..4 { | 1603 | for row in 0..4 { |
| 1760 | let start = (oy + row) * bw + ox; | 1604 | let start = (oy + row) * bw + ox; |
| @@ -1763,7 +1607,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1763 | } | 1607 | } |
| 1764 | } | 1608 | } |
| 1765 | chroma_stamped_per_unit = true; | 1609 | chroma_stamped_per_unit = true; |
| 1766 | - hit!(LLSUB8RECT444_CHROMA_WALK_HITS); | ||
| 1767 | ( | 1610 | ( |
| 1768 | if uo.is_empty() { | 1611 | if uo.is_empty() { |
| 1769 | Grid::Zero(bw * bh) | 1612 | Grid::Zero(bw * bh) |
| @@ -1801,7 +1644,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1801 | skip_ctx, | 1644 | skip_ctx, |
| 1802 | dc_sign_ctx(around.2), | 1645 | dc_sign_ctx(around.2), |
| 1803 | uv_tx, | 1646 | uv_tx, |
| 1804 | - plane, | ||
| 1805 | )?; | 1647 | )?; |
| 1806 | let residual = dequant_and_inverse_typed_wh( | 1648 | let residual = dequant_and_inverse_typed_wh( |
| 1807 | &levels, | 1649 | &levels, |
| @@ -1861,7 +1703,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1861 | unit_y, | 1703 | unit_y, |
| 1862 | 4, | 1704 | 4, |
| 1863 | TX4, | 1705 | TX4, |
| 1864 | - base_q_idx, | ||
| 1865 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | 1706 | alpha.zip(ac).map(|((au, _), ac)| (au, ac)), |
| 1866 | None, | 1707 | None, |
| 1867 | None, | 1708 | None, |
| @@ -1886,7 +1727,6 @@ pub(super) fn decode_intra_sub8_leaf( | |||
| 1886 | unit_y, | 1727 | unit_y, |
| 1887 | 4, | 1728 | 4, |
| 1888 | TX4, | 1729 | TX4, |
| 1889 | - base_q_idx, | ||
| 1890 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | 1730 | alpha.zip(ac).map(|((_, av), ac)| (av, ac)), |
| 1891 | None, | 1731 | None, |
| 1892 | None, | 1732 | None, |
| @@ -2004,13 +1844,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2004 | (8usize, 4usize) | 1844 | (8usize, 4usize) |
| 2005 | }; | 1845 | }; |
| 2006 | let (w_mi, h_mi) = (bw / MI, bh / MI); | 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 | let (gr, gc) = group_mi; | 1847 | let (gr, gc) = group_mi; |
| 2015 | let (gpx, gpy) = (gc * MI, gr * MI); | 1848 | let (gpx, gpy) = (gc * MI, gr * MI); |
| 2016 | let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx)); | 1849 | let (cpx, cpy) = (gpx >> ss_x(fctx), gpy >> ss_y(fctx)); |
| @@ -2018,7 +1851,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2018 | let mut piece: [Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>; 2] = | 1851 | let mut piece: [Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>; 2] = |
| 2019 | [None; 2]; | 1852 | [None; 2]; |
| 2020 | let mut first_tx_type = TxType::DctDct; | 1853 | let mut first_tx_type = TxType::DctDct; |
| 2021 | - let mut sub0_tx_type = TxType::DctDct; | ||
| 2022 | // lane-av1-444: `is_chroma_reference` is unconditional at subsampling 0/0 | 1854 | // lane-av1-444: `is_chroma_reference` is unconditional at subsampling 0/0 |
| 2023 | // (av1_common_int.h:1459), so every 8x4/4x8 piece is its own chroma | 1855 | // (av1_common_int.h:1459), so every 8x4/4x8 piece is its own chroma |
| 2024 | // reference and codes its own 8x4/4x8 U/V units right after its luma -- | 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 | let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; | 1932 | let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; |
| 2101 | if !is_inter { | 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 | // lane-sub8x4 r2: refusal and bypass lifted -- see the split arm's | 1934 | // lane-sub8x4 r2: refusal and bypass lifted -- see the split arm's |
| 2112 | // note above for the gate that proves this leaf. | 1935 | // note above for the gate that proves this leaf. |
| 2113 | // Its chroma rule is `is_sub8x8_inter`'s: when the | 1936 | // Its chroma rule is `is_sub8x8_inter`'s: when the |
| @@ -2128,7 +1951,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2128 | y, | 1951 | y, |
| 2129 | u, | 1952 | u, |
| 2130 | v, | 1953 | v, |
| 2131 | - base_q_idx, | ||
| 2132 | fctx.enable_filter_intra_inter.with(std::cell::Cell::get), | 1954 | fctx.enable_filter_intra_inter.with(std::cell::Cell::get), |
| 2133 | fctx.tx_select_inter.with(std::cell::Cell::get), | 1955 | fctx.tx_select_inter.with(std::cell::Cell::get), |
| 2134 | reduced_tx_set, | 1956 | reduced_tx_set, |
| @@ -2139,12 +1961,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2139 | } | 1961 | } |
| 2140 | continue; | 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 | let ref_frame = read_single_ref( | 1964 | let ref_frame = read_single_ref( |
| 2149 | dec, | 1965 | dec, |
| 2150 | cdfs, | 1966 | cdfs, |
| @@ -2158,9 +1974,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2158 | let (ref_width, ref_height) = ref_dims(ref_frame, refpix)?; | 1974 | let (ref_width, ref_height) = ref_dims(ref_frame, refpix)?; |
| 2159 | // lane-t900 r28: refusal lifted -- see the split arm above. | 1975 | // lane-t900 r28: refusal lifted -- see the split arm above. |
| 2160 | let luma_scale = scale_of((ref_width, ref_height), frame_size); | 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 | let gm_table = build_gm_mv_table( | 1977 | let gm_table = build_gm_mv_table( |
| 2165 | global_motion, | 1978 | global_motion, |
| 2166 | rmi, | 1979 | rmi, |
| @@ -2194,10 +2007,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2194 | tpl, | 2007 | tpl, |
| 2195 | ); | 2008 | ); |
| 2196 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; | 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 | let (mv, is_new_mv) = if !not_new { | 2010 | let (mv, is_new_mv) = if !not_new { |
| 2202 | let mut idx = 0usize; | 2011 | let mut idx = 0usize; |
| 2203 | while idx < 2 && stack.entries.len() > idx + 1 { | 2012 | while idx < 2 && stack.entries.len() > idx + 1 { |
| @@ -2221,15 +2030,10 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2221 | ) | 2030 | ) |
| 2222 | } else { | 2031 | } else { |
| 2223 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; | 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 | let mv = if !not_zero { | 2033 | let mv = if !not_zero { |
| 2229 | gm_table[(ref_frame - LAST_FRAME) as usize] | 2034 | gm_table[(ref_frame - LAST_FRAME) as usize] |
| 2230 | } else { | 2035 | } else { |
| 2231 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; | 2036 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; |
| 2232 | - crate::census::mode(if nearest { 2 } else { 3 }); | ||
| 2233 | if nearest { | 2037 | if nearest { |
| 2234 | stack.nearest_mv | 2038 | stack.nearest_mv |
| 2235 | } else { | 2039 | } else { |
| @@ -2245,15 +2049,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2245 | }; | 2049 | }; |
| 2246 | (mv, false) | 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 | let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame | 2052 | let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame |
| 2258 | || neighbours.above_ref1[cmi] == Some(ref_frame) | 2053 | || neighbours.above_ref1[cmi] == Some(ref_frame) |
| 2259 | { | 2054 | { |
| @@ -2272,9 +2067,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2272 | // `is_nontrans_global_motion` returns 0 for | 2067 | // `is_nontrans_global_motion` returns 0 for |
| 2273 | // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model -- | 2068 | // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model -- |
| 2274 | // so a GLOBALMV sub-block here always reads its interp filter. | 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 | let gm_nontrans = false; | 2070 | let gm_nontrans = false; |
| 2279 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( | 2071 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( |
| 2280 | dec, | 2072 | dec, |
| @@ -2321,9 +2113,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2321 | // exactly that population -- so an unconditional hit proves only | 2113 | // exactly that population -- so an unconditional hit proves only |
| 2322 | // "a lossless sub-8 leaf was walked", not "the conjunct suppressed | 2114 | // "a lossless sub-8 leaf was walked", not "the conjunct suppressed |
| 2323 | // a tree". Guard it on the same term the conjunct uses. | 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 | // lane-lossless2: `read_block_tx_size` returns TX_4X4 before it | 2116 | // lane-lossless2: `read_block_tx_size` returns TX_4X4 before it |
| 2328 | // ever looks at `max_txsize_rect_lookup`, so an 8x4/4x8 leaf is | 2117 | // ever looks at `max_txsize_rect_lookup`, so an 8x4/4x8 leaf is |
| 2329 | // TWO 4x4 units, not one rect one. | 2118 | // TWO 4x4 units, not one rect one. |
| @@ -2337,17 +2126,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2337 | leaves.push((0, 0, bw, bh)); | 2126 | leaves.push((0, 0, bw, bh)); |
| 2338 | set_txfm_ctxs(neighbours, lmi, bw.max(bh), w_mi, h_mi, skip); | 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 | grid_stamp_rect(grid, rmi, cmi, w_mi, h_mi, ref_frame, mv, is_new_mv); | 2129 | grid_stamp_rect(grid, rmi, cmi, w_mi, h_mi, ref_frame, mv, is_new_mv); |
| 2352 | piece[i] = Some((ref_frame, mv, h_filter, v_filter)); | 2130 | piece[i] = Some((ref_frame, mv, h_filter, v_filter)); |
| 2353 | // Prediction over the leaf's true footprint, laid out at the group's | 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 | let pred_y: Vec<u16>; | 2167 | let pred_y: Vec<u16>; |
| 2390 | let sy = if pred_deferred(refpix) { | 2168 | let sy = if pred_deferred(refpix) { |
| 2391 | push_pred(build); | 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 | } else { | 2175 | } else { |
| 2394 | let mut built: [Vec<u16>; 3] = Default::default(); | 2176 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 2395 | build(y, u, v, refpix, fctx, &mut built); | 2177 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -2492,9 +2274,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2492 | if idx == 0 { | 2274 | if idx == 0 { |
| 2493 | piece_tx_type = tu_tx_type; | 2275 | piece_tx_type = tu_tx_type; |
| 2494 | } | 2276 | } |
| 2495 | - if idx == 0 && i == 0 { | ||
| 2496 | - sub0_tx_type = tu_tx_type; | ||
| 2497 | - } | ||
| 2498 | if idx == 0 && i == 1 { | 2277 | if idx == 0 && i == 1 { |
| 2499 | // `av1_get_tx_type` indexes `xd->tx_type_map`, which | 2278 | // `av1_get_tx_type` indexes `xd->tx_type_map`, which |
| 2500 | // `set_mi_offsets` (av1_common_int.h:1679) re-points to the | 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 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); | 2342 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); |
| 2564 | let (su, sv) = if pred_deferred(refpix) { | 2343 | let (su, sv) = if pred_deferred(refpix) { |
| 2565 | push_pred(build_c); | 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 | } else { | 2357 | } else { |
| 2568 | let mut built: [Vec<u16>; 3] = Default::default(); | 2358 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 2569 | build_c(y, u, v, refpix, fctx, &mut built); | 2359 | build_c(y, u, v, refpix, fctx, &mut built); |
| @@ -2813,7 +2603,18 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2813 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); | 2603 | let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); |
| 2814 | let (su, sv) = if pred_deferred(refpix) { | 2604 | let (su, sv) = if pred_deferred(refpix) { |
| 2815 | push_pred(build_c); | 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 | } else { | 2618 | } else { |
| 2818 | let mut built: [Vec<u16>; 3] = Default::default(); | 2619 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 2819 | build_c(y, u, v, refpix, fctx, &mut built); | 2620 | build_c(y, u, v, refpix, fctx, &mut built); |
| @@ -2851,7 +2652,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2851 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]); | 2652 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]); |
| 2852 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]); | 2653 | neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]); |
| 2853 | } else { | 2654 | } else { |
| 2854 | - hit!(CHROMA422_INTER_SUB8_HITS); | ||
| 2855 | let (ug, _) = read_inter_plane( | 2655 | let (ug, _) = read_inter_plane( |
| 2856 | dec, | 2656 | dec, |
| 2857 | cdfs, | 2657 | cdfs, |
| @@ -2956,15 +2756,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 2956 | // chroma-reference block's own mv, at the group's chroma origin | 2756 | // chroma-reference block's own mv, at the group's chroma origin |
| 2957 | // (`row_start`/`col_start` shift `pre_x`/`pre_y` there either way). | 2757 | // (`row_start`/`col_start` shift `pre_x`/`pre_y` there either way). |
| 2958 | let mixed = piece[0].is_none(); | 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 | let (piece_w, piece_h) = match (mixed, vert) { | 2759 | let (piece_w, piece_h) = match (mixed, vert) { |
| 2969 | (true, _) => (B4, B4), | 2760 | (true, _) => (B4, B4), |
| 2970 | (false, true) => (2usize, 4usize), | 2761 | (false, true) => (2usize, 4usize), |
| @@ -3038,7 +2829,18 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 3038 | let (pred_u, pred_v): (Vec<u16>, Vec<u16>); | 2829 | let (pred_u, pred_v): (Vec<u16>, Vec<u16>); |
| 3039 | let (su, sv) = if pred_deferred(refpix) { | 2830 | let (su, sv) = if pred_deferred(refpix) { |
| 3040 | push_pred(build); | 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 | } else { | 2844 | } else { |
| 3043 | let mut built: [Vec<u16>; 3] = Default::default(); | 2845 | let mut built: [Vec<u16>; 3] = Default::default(); |
| 3044 | build(y, u, v, refpix, fctx, &mut built); | 2846 | build(y, u, v, refpix, fctx, &mut built); |
| @@ -3116,8 +2918,6 @@ pub(super) fn decode_inter_sub8_rect2( | |||
| 3116 | fctx, | 2918 | fctx, |
| 3117 | )? | 2919 | )? |
| 3118 | .0; | 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 | (ug, vg) | 2921 | (ug, vg) |
| 3122 | }; | 2922 | }; |
| 3123 | let round_up_even = |n: usize| n.div_ceil(2) * 2; | 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 | /// lane-av1unwritten: the port is a TRANSCRIPTION, and this is the artefact | 1 | /// lane-av1unwritten: the port is a TRANSCRIPTION, and this is the artefact |
| 328 | /// that makes it checkable. It re-writes `av1_ss_size_lookup`'s 22 rows | 2 | /// that makes it checkable. It re-writes `av1_ss_size_lookup`'s 22 rows |
| 329 | /// (`common_data.c:17-41`) literally -- every shape, every subsampling | 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 | /// lane-av1chrtx: [`covering_leaf_tx_type`] resolves a chroma unit's | 131 | /// lane-av1chrtx: [`covering_leaf_tx_type`] resolves a chroma unit's |
| 1338 | /// `tx_type` from the luma leaf covering the unit's OWN quadrant, and | 132 | /// `tx_type` from the luma leaf covering the unit's OWN quadrant, and |
| 1339 | /// reports "no leaf there" as `None` so the caller can fall back to the | 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 | if let Some(t) = archmage::X64V3Token::summon() { | 544 | if let Some(t) = archmage::X64V3Token::summon() { |
| 1751 | return super::cdef_simd::filter_block_avx2( | 545 | return super::cdef_simd::filter_block_avx2( |
| 1752 | - t, src, dst, stride, ox, oy, bw, bh, pri_strength, sec_strength, dir, | 546 | + t, |
| 1753 | - pri_damping, sec_damping, enable_primary, enable_secondary, coeff_shift, smax, | 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 | super::cdef_filter_block_scalar( | 565 | super::cdef_filter_block_scalar( |
| 1757 | - src, dst, stride, ox, oy, bw, bh, pri_strength, sec_strength, dir, | 566 | + src, |
| 1758 | - pri_damping, sec_damping, enable_primary, enable_secondary, coeff_shift, smax, | 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 | use super::*; | 922 | use super::*; |
| 923 | +use archmage::SimdToken; | ||
| 2101 | 924 | ||
| 2102 | /// lane-tx64x16 r3: the two new 4:1 chroma scans are a TRANSPOSED PAIR -- | 925 | /// lane-tx64x16 r3: the two new 4:1 chroma scans are a TRANSPOSED PAIR -- |
| 2103 | /// `SCAN_4X16[i]` must name the transpose of the position | 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 | /// lane-t900 r27, negative gate for "a reference frame selected with no | 1241 | /// lane-t900 r27, negative gate for "a reference frame selected with no |
| 2497 | /// picture at this frame's own ref_frame_idx slot for it": every | 1242 | /// picture at this frame's own ref_frame_idx slot for it": every |
| 2498 | /// non-`LAST_FRAME` reference resolves through `ref_planes`, and an empty | 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 | DC_PRED, | 1542 | DC_PRED, |
| 2798 | &mut cdfs.kf_y_mode[INTRA_MODE_CTX[DC_PRED]][INTRA_MODE_CTX[DC_PRED]], | 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 | enc.symbol(DC_PRED, &mut cdfs.uv_mode_no_cfl[DC_PRED]); | 1545 | enc.symbol(DC_PRED, &mut cdfs.uv_mode_no_cfl[DC_PRED]); |
| 2802 | let data = enc.finish(); | 1546 | let data = enc.finish(); |
| 2803 | let decoded = decode_key_frame_tile( | 1547 | let decoded = decode_key_frame_tile( |
| @@ -2842,7 +1586,6 @@ fn a_skipped_block_decodes_to_pure_prediction() { | |||
| 2842 | #[test] | 1586 | #[test] |
| 2843 | fn a_skipped_intrabc_chroma_reference_leaf_disarms_the_inherited_chroma_tx() { | 1587 | fn a_skipped_intrabc_chroma_reference_leaf_disarms_the_inherited_chroma_tx() { |
| 2844 | let fctx = &crate::decode::FrameCtx::new(); | 1588 | let fctx = &crate::decode::FrameCtx::new(); |
| 2845 | - reset_skipped_intrabc_chroma_arm_hits(); | ||
| 2846 | use crate::msac::SymbolEncoder; | 1589 | use crate::msac::SymbolEncoder; |
| 2847 | let mut cdfs = Cdfs::new(q_ctx_of(40)); | 1590 | let mut cdfs = Cdfs::new(q_ctx_of(40)); |
| 2848 | let mut enc = SymbolEncoder::new(); | 1591 | let mut enc = SymbolEncoder::new(); |
| @@ -2883,10 +1626,6 @@ fn a_skipped_intrabc_chroma_reference_leaf_disarms_the_inherited_chroma_tx() { | |||
| 2883 | true, | 1626 | true, |
| 2884 | fctx, | 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 | assert!( | 1629 | assert!( |
| 2891 | fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_none(), | 1630 | fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_none(), |
| 2892 | "the inherited chroma transform slot must be disarmed when its block's chroma \ | 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 | #[test] | 1640 | #[test] |
| 2902 | fn a_skipped_intrabc_rect_chroma_reference_leaf_disarms_the_inherited_chroma_tx() { | 1641 | fn a_skipped_intrabc_rect_chroma_reference_leaf_disarms_the_inherited_chroma_tx() { |
| 2903 | let fctx = &crate::decode::FrameCtx::new(); | 1642 | let fctx = &crate::decode::FrameCtx::new(); |
| 2904 | - reset_skipped_intrabc_chroma_arm_hits(); | ||
| 2905 | use crate::msac::SymbolEncoder; | 1643 | use crate::msac::SymbolEncoder; |
| 2906 | let mut cdfs = Cdfs::new(q_ctx_of(40)); | 1644 | let mut cdfs = Cdfs::new(q_ctx_of(40)); |
| 2907 | let mut enc = SymbolEncoder::new(); | 1645 | let mut enc = SymbolEncoder::new(); |
| @@ -2934,10 +1672,6 @@ fn a_skipped_intrabc_rect_chroma_reference_leaf_disarms_the_inherited_chroma_tx( | |||
| 2934 | true, | 1672 | true, |
| 2935 | fctx, | 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 | assert!( | 1675 | assert!( |
| 2942 | fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_none(), | 1676 | fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_none(), |
| 2943 | "the inherited chroma transform slot must be disarmed when its block's chroma \ | 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 | // helpers are `#[cfg(test)]`-private to it). | 1746 | // helpers are `#[cfg(test)]`-private to it). |
| 3013 | use crate::probe::run_with_stdin; | 1747 | use crate::probe::run_with_stdin; |
| 3014 | 1748 | ||
| 3015 | - | ||
| 3016 | /// Decodes one AV1 OBU stream with ffmpeg and hands back its one 4:2:0 | 1749 | /// Decodes one AV1 OBU stream with ffmpeg and hands back its one 4:2:0 |
| 3017 | /// frame's planes, at ffmpeg's own (coded, block-padded) size. | 1750 | /// frame's planes, at ffmpeg's own (coded, block-padded) size. |
| 3018 | fn ffmpeg_decode(stream: &[u8], width: usize, height: usize) -> Picture { | 1751 | fn ffmpeg_decode(stream: &[u8], width: usize, height: usize) -> Picture { |
| @@ -3124,7 +1857,8 @@ fn ffprobe_size(stream: &[u8]) -> (u32, u32) { | |||
| 3124 | "-of", | 1857 | "-of", |
| 3125 | "csv=p=0", | 1858 | "csv=p=0", |
| 3126 | ]) | 1859 | ]) |
| 3127 | - .arg(&path).output() | 1860 | + .arg(&path) |
| 1861 | + .output() | ||
| 3128 | .expect("ffprobe failed to run"); | 1862 | .expect("ffprobe failed to run"); |
| 3129 | let _ = std::fs::remove_file(&path); | 1863 | let _ = std::fs::remove_file(&path); |
| 3130 | assert!( | 1864 | assert!( |
| @@ -3216,7 +1950,6 @@ fn a_filter_intra_key_frame_decodes_pixel_exact_through_ffmpeg() { | |||
| 3216 | } | 1950 | } |
| 3217 | let encoded = crate::encode::encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap(); | 1951 | let encoded = crate::encode::encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap(); |
| 3218 | let (coded_w, coded_h) = ffprobe_size(&encoded.stream); | 1952 | let (coded_w, coded_h) = ffprobe_size(&encoded.stream); |
| 3219 | - let before = filter_intra_hits(); | ||
| 3220 | let ours = decode_key_frame_tile_lr( | 1953 | let ours = decode_key_frame_tile_lr( |
| 3221 | &encoded.tile, | 1954 | &encoded.tile, |
| 3222 | encoded.mi_cols, | 1955 | encoded.mi_cols, |
| @@ -3235,12 +1968,6 @@ fn a_filter_intra_key_frame_decodes_pixel_exact_through_ffmpeg() { | |||
| 3235 | fctx, | 1968 | fctx, |
| 3236 | ) | 1969 | ) |
| 3237 | .unwrap(); | 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 | let ffmpeg_decoded = ffmpeg_decode(&encoded.stream, coded_w as usize, coded_h as usize); | 1971 | let ffmpeg_decoded = ffmpeg_decode(&encoded.stream, coded_w as usize, coded_h as usize); |
| 3245 | assert_eq!(ours.y, ffmpeg_decoded.y, "luma vs ffmpeg"); | 1972 | assert_eq!(ours.y, ffmpeg_decoded.y, "luma vs ffmpeg"); |
| 3246 | assert_eq!(ours.u, ffmpeg_decoded.u, "U vs ffmpeg"); | 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+29 -20
| @@ -962,7 +962,13 @@ impl Plane<'_> { | |||
| 962 | } | 962 | } |
| 963 | 963 | ||
| 964 | /// Puts a snapshot back. | 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 | for row in 0..side { | 972 | for row in 0..side { |
| 967 | self.reconstruction[(y + row) * self.width + x..][..side] | 973 | self.reconstruction[(y + row) * self.width + x..][..side] |
| 968 | .copy_from_slice(&saved.0[row * side..][..side]); | 974 | .copy_from_slice(&saved.0[row * side..][..side]); |
| @@ -1080,7 +1086,8 @@ impl Plane<'_> { | |||
| 1080 | }) | 1086 | }) |
| 1081 | .collect(); | 1087 | .collect(); |
| 1082 | if let Some(k) = search.top_k | 1088 | if let Some(k) = search.top_k |
| 1083 | - && k < scored.len() { | 1089 | + && k < scored.len() |
| 1090 | + { | ||
| 1084 | let dc_pos = scored.iter().position(|&(_, mode, _)| mode == DC_PRED); | 1091 | let dc_pos = scored.iter().position(|&(_, mode, _)| mode == DC_PRED); |
| 1085 | let dc_entry = dc_pos.map(|i| scored.remove(i)); | 1092 | 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")); | 1093 | scored.sort_by(|a, b| a.0.partial_cmp(&b.0).expect("scores are finite")); |
| @@ -1179,8 +1186,6 @@ impl Plane<'_> { | |||
| 1179 | trial = candidate; | 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 | // lane-txset: the block's own transform type, searched on the mode | 1190 | // lane-txset: the block's own transform type, searched on the mode |
| 1186 | // and angle the trials above settled -- the same ordering the angle | 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 | /// `has_bl_8x16` (`reconintra.c`), transcribed verbatim: 16 bytes, row stride 16 bits (`128 / 8`). | 1410 | /// `has_bl_8x16` (`reconintra.c`), transcribed verbatim: 16 bytes, row stride 16 bits (`128 / 8`). |
| 1406 | pub(super) const HAS_BL_8X16: [u8; 16] = [16, 17, 0, 1, 16, 17, 0, 0, 16, 17, 0, 1, 16, 17, 0, 0]; | 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 | /// `has_tr_16x8` (`reconintra.c`), transcribed verbatim: 16 bytes, row stride 8 bits (`128 / 16`). | 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 | /// `has_bl_16x8` (`reconintra.c`), transcribed verbatim: 16 bytes, row stride 8 bits (`128 / 16`). | 1415 | /// `has_bl_16x8` (`reconintra.c`), transcribed verbatim: 16 bytes, row stride 8 bits (`128 / 16`). |
| 1410 | pub(super) const HAS_BL_16X8: [u8; 16] = [ | 1416 | pub(super) const HAS_BL_16X8: [u8; 16] = [ |
| 1411 | 254, 84, 254, 16, 254, 84, 254, 0, 254, 84, 254, 16, 254, 84, 254, 0, | 1417 | 254, 84, 254, 16, 254, 84, 254, 0, 254, 84, 254, 16, 254, 84, 254, 0, |
| @@ -1785,18 +1791,6 @@ impl Reach { | |||
| 1785 | Self::bit(table, Self::rect_table_index(bw_log2, blk_row, blk_col)) | 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 | pub(crate) fn vert_ab_partition() -> VertAbGuard { | 1794 | pub(crate) fn vert_ab_partition() -> VertAbGuard { |
| 1801 | VertAbGuard(VERT_AB_PARTITION.with(|c| c.replace(true))) | 1795 | VertAbGuard(VERT_AB_PARTITION.with(|c| c.replace(true))) |
| 1802 | } | 1796 | } |
| @@ -1814,7 +1808,12 @@ impl Reach { | |||
| 1814 | /// row of a superblock reads into the superblock above, which is decoded; | 1808 | /// row of a superblock reads into the superblock above, which is decoded; |
| 1815 | /// the rightmost column would read into the superblock to the right, which | 1809 | /// the rightmost column would read into the superblock to the right, which |
| 1816 | /// is not; and everything between is the table's to answer. | 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 | let (row, col, per_side) = Self::position(side, x, y, fctx); | 1817 | let (row, col, per_side) = Self::position(side, x, y, fctx); |
| 1819 | if row == 0 { | 1818 | if row == 0 { |
| 1820 | return true; | 1819 | return true; |
| @@ -1851,7 +1850,12 @@ impl Reach { | |||
| 1851 | /// reads into the superblock to its left, which is decoded only as far | 1850 | /// reads into the superblock to its left, which is decoded only as far |
| 1852 | /// down as its own bottom; the bottom row would read into the superblock | 1851 | /// down as its own bottom; the bottom row would read into the superblock |
| 1853 | /// below, which is not decoded at all; and the table answers the rest. | 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 | let (row, col, per_side) = Self::position(side, x, y, fctx); | 1859 | let (row, col, per_side) = Self::position(side, x, y, fctx); |
| 1856 | if col == 0 { | 1860 | if col == 0 { |
| 1857 | return row * side + side < reach_sb_px(fctx); | 1861 | return row * side + side < reach_sb_px(fctx); |
| @@ -2032,7 +2036,12 @@ pub(super) fn obmc_min_side() -> usize { | |||
| 2032 | /// 2-symbol `obmc` one. Both sides of every motion-mode comparison in the | 2036 | /// 2-symbol `obmc` one. Both sides of every motion-mode comparison in the |
| 2033 | /// search pay it, so the alphabet cancels out of a comparison and only its | 2037 | /// search pay it, so the alphabet cancels out of a comparison and only its |
| 2034 | /// per-value spread decides. | 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 | let Some(row) = crate::decode::motion_mode_cdf_row(write_w, write_h) else { | 2045 | let Some(row) = crate::decode::motion_mode_cdf_row(write_w, write_h) else { |
| 2037 | return 0.0; | 2046 | return 0.0; |
| 2038 | }; | 2047 | }; |
crates/ec-av1/src/encode/frame.rsmodified+26 -13
| @@ -52,7 +52,8 @@ pub(super) fn deltaq_res_log2() -> Option<u8> { | |||
| 52 | /// sets it holds [`crate::speed::knob_write`], the same exclusive lock the | 52 | /// sets it holds [`crate::speed::knob_write`], the same exclusive lock the |
| 53 | /// speed presets take, because the streams every other test pins move under | 53 | /// speed presets take, because the streams every other test pins move under |
| 54 | /// it (the shipped default is OFF, see [`crate::speed::DELTAQ_RES`]). | 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 | /// Sets [`DELTAQ_OVERRIDE`]; `None` clears it. | 58 | /// Sets [`DELTAQ_OVERRIDE`]; `None` clears it. |
| 58 | #[allow(dead_code)] // set only from the `#[cfg(test)]` gates | 59 | #[allow(dead_code)] // set only from the `#[cfg(test)]` gates |
| @@ -270,13 +271,8 @@ pub(super) fn dq_summary(offsets: &[i32]) -> String { | |||
| 270 | /// grid that is one flat value, i.e. on no delta_q at all). Process-global | 271 | /// grid that is one flat value, i.e. on no delta_q at all). Process-global |
| 271 | /// like [`TX_DEPTH_HITS`], and read through [`take_deltaq_levels`], which | 272 | /// like [`TX_DEPTH_HITS`], and read through [`take_deltaq_levels`], which |
| 272 | /// keeps the LARGEST count seen since the last read. | 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 | +pub(super) static DELTAQ_LEVELS: std::sync::atomic::AtomicUsize = |
| 274 | - | 275 | + std::sync::atomic::AtomicUsize::new(0); |
| 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 | -} | ||
| 280 | 276 | ||
| 281 | /// This superblock's search state: the quantizer it is coded at, and the | 277 | /// This superblock's search state: the quantizer it is coded at, and the |
| 282 | /// lambda that quantizer implies. RD lambda goes as the square of the step, | 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 | /// the left/above winners, first-best tie-break. Built once on the frame's | 400 | /// the left/above winners, first-best tie-break. Built once on the frame's |
| 405 | /// own thread and read-only afterwards, so it cannot make a tile's bytes | 401 | /// own thread and read-only afterwards, so it cannot make a tile's bytes |
| 406 | /// depend on the thread count. | 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 | let (cells_x, cells_y) = (width / 16, height / 16); | 409 | let (cells_x, cells_y) = (width / 16, height / 16); |
| 409 | let sad = |bx: usize, by: usize, (mx, my): (i32, i32)| -> u32 { | 410 | let sad = |bx: usize, by: usize, (mx, my): (i32, i32)| -> u32 { |
| 410 | let (sx, sy) = (bx as i32 + mx, by as i32 + my); | 411 | let (sx, sy) = (bx as i32 + mx, by as i32 + my); |
| @@ -823,7 +824,8 @@ pub(crate) fn arf_temporal_filter(src: &Picture, window: &[Picture], strength: f | |||
| 823 | ] { | 824 | ] { |
| 824 | let mv = (from.0 + dy * step, from.1 + dx * step); | 825 | let mv = (from.0 + dy * step, from.1 + dx * step); |
| 825 | if let Some(s) = sad(r, bx, by, mv) | 826 | if let Some(s) = sad(r, bx, by, mv) |
| 826 | - && s.0 < best.0 { | 827 | + && s.0 < best.0 |
| 828 | + { | ||
| 827 | best = s; | 829 | best = s; |
| 828 | centre = mv; | 830 | centre = mv; |
| 829 | } | 831 | } |
| @@ -1288,7 +1290,8 @@ pub(crate) fn encode_inter_frame( | |||
| 1288 | // the frame codes any delta syntax (`deltaq_res` is `None` with the lever | 1290 | // the frame codes any delta syntax (`deltaq_res` is `None` with the lever |
| 1289 | // off, and the census then prices the default `res = 4` grid). | 1291 | // off, and the census then prices the default `res = 4` grid). |
| 1290 | if dq_census() | 1292 | if dq_census() |
| 1291 | - && let Some(f) = &tpl_factors { | 1293 | + && let Some(f) = &tpl_factors |
| 1294 | + { | ||
| 1292 | let res = deltaq_res.unwrap_or(4); | 1295 | let res = deltaq_res.unwrap_or(4); |
| 1293 | let off = |libaom: Option<f64>| -> Vec<i32> { | 1296 | let off = |libaom: Option<f64>| -> Vec<i32> { |
| 1294 | (0..sb_cols * _sb_rows) | 1297 | (0..sb_cols * _sb_rows) |
| @@ -2332,9 +2335,19 @@ pub(crate) fn encode_inter_frame( | |||
| 2332 | // rectangles partition the frame, so the order does not change the bytes). | 2335 | // rectangles partition the frame, so the order does not change the bytes). |
| 2333 | let mut searched_blocks = Vec::new(); | 2336 | let mut searched_blocks = Vec::new(); |
| 2334 | for (tile_blocks, pixels) in search_tiles(layout.count(), fctx, search_tile)? { | 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 | for (plane, bytes) in chroma.iter_mut().zip(&pixels.chroma) { | 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 | searched_blocks.push(tile_blocks); | 2352 | searched_blocks.push(tile_blocks); |
| 2340 | } | 2353 | } |
crates/ec-av1/src/encode/inter_search.rsmodified+40 -35
| @@ -212,7 +212,8 @@ pub(super) fn arfmode() -> u8 { | |||
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | /// [`ARFMODE_OVERRIDE`]: `u8::MAX` clears it. | 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 | /// Sets [`ARFMODE_OVERRIDE`]; `None` clears it. Test-only: the env is a | 218 | /// Sets [`ARFMODE_OVERRIDE`]; `None` clears it. Test-only: the env is a |
| 218 | /// process constant ([`crate::envflags`]), so an in-process witness needs | 219 | /// process constant ([`crate::envflags`]), so an in-process witness needs |
| @@ -279,11 +280,6 @@ thread_local! { | |||
| 279 | const { std::cell::Cell::new(None) }; | 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 | /// The default: unpruned, thirteen full trials per block, same as before this | 283 | /// The default: unpruned, thirteen full trials per block, same as before this |
| 288 | /// lever. Set from the sweep in the lane report if the quality gate clears it. | 284 | /// lever. Set from the sweep in the lane report if the quality gate clears it. |
| 289 | pub(crate) const PRUNE_TOP_K: Option<usize> = None; | 285 | pub(crate) const PRUNE_TOP_K: Option<usize> = None; |
| @@ -317,11 +313,6 @@ thread_local! { | |||
| 317 | const { std::cell::Cell::new(None) }; | 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 | /// The inter path's default `top_k`: `Some(3)`, from `prune_k_quality_sweep_inter` | 316 | /// The inter path's default `top_k`: `Some(3)`, from `prune_k_quality_sweep_inter` |
| 326 | /// (three real clips, q 60 and 150) -- every `K` in {3, 4, 6} cleared the | 317 | /// (three real clips, q 60 and 150) -- every `K` in {3, 4, 6} cleared the |
| 327 | /// same rule the key-frame lever uses (every PSNR delta <0.05dB, bytes | 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 | STAGE_NS.with(|c| c[bucket].set(c[bucket].get() + dur.as_nanos() as u64)); | 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 | /// One mode's coding of one block, before it is committed. | 368 | /// One mode's coding of one block, before it is committed. |
| 393 | #[derive(Clone)] | 369 | #[derive(Clone)] |
| 394 | pub(super) struct Trial { | 370 | pub(super) struct Trial { |
| @@ -526,7 +502,11 @@ where | |||
| 526 | /// The `FrameCtx` copy is made on the calling thread (`&FrameCtx` is `!Sync` | 502 | /// The `FrameCtx` copy is made on the calling thread (`&FrameCtx` is `!Sync` |
| 527 | /// by design) and moved into the worker, exactly as the decoder's filter bands | 503 | /// by design) and moved into the worker, exactly as the decoder's filter bands |
| 528 | /// do it through [`crate::par::scope`]. | 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 | where | 510 | where |
| 531 | T: Send, | 511 | T: Send, |
| 532 | F: Fn(usize, &crate::decode::FrameCtx) -> Result<T> + Sync, | 512 | F: Fn(usize, &crate::decode::FrameCtx) -> Result<T> + Sync, |
| @@ -600,7 +580,11 @@ pub(super) struct TilePixels { | |||
| 600 | 580 | ||
| 601 | /// The rectangle `[x0, x1) x [y0, y1)` of a plane with `stride`, copied out as | 581 | /// The rectangle `[x0, x1) x [y0, y1)` of a plane with `stride`, copied out as |
| 602 | /// its rows back to back. | 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 | let mut out = Vec::with_capacity((x1 - x0) * (y1 - y0)); | 588 | let mut out = Vec::with_capacity((x1 - x0) * (y1 - y0)); |
| 605 | for y in y0..y1 { | 589 | for y in y0..y1 { |
| 606 | out.extend_from_slice(&plane[y * stride + x0..y * stride + x1]); | 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 | /// The inverse of [`take_rect`]: writes `rows` (as `take_rect` produced them) | 595 | /// The inverse of [`take_rect`]: writes `rows` (as `take_rect` produced them) |
| 612 | /// back into the rectangle of `plane`. | 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 | let w = x1 - x0; | 603 | let w = x1 - x0; |
| 615 | for (row, y) in (y0..y1).enumerate() { | 604 | for (row, y) in (y0..y1).enumerate() { |
| 616 | plane[y * stride + x0..y * stride + x1].copy_from_slice(&rows[row * w..(row + 1) * w]); | 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 | /// tables the frame stores (spec 7.20), which is what | 611 | /// tables the frame stores (spec 7.20), which is what |
| 623 | /// [`crate::tile::TileLayout::largest_tile`] picks and what the tile loops | 612 | /// [`crate::tile::TileLayout::largest_tile`] picks and what the tile loops |
| 624 | /// below publish. | 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 | ec_av1_syntax::TileInfo { | 618 | ec_av1_syntax::TileInfo { |
| 627 | uniform_spacing: true, | 619 | uniform_spacing: true, |
| 628 | cols: layout.cols(), | 620 | cols: layout.cols(), |
| @@ -1380,9 +1372,19 @@ pub(crate) fn encode_key_frame_inner( | |||
| 1380 | let searched = search_tiles(layout.count(), fctx, search_tile)?; | 1372 | let searched = search_tiles(layout.count(), fctx, search_tile)?; |
| 1381 | let mut searched_coded = Vec::with_capacity(searched.len()); | 1373 | let mut searched_coded = Vec::with_capacity(searched.len()); |
| 1382 | for (coded, pixels) in searched { | 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 | for (plane, bytes) in chroma.iter_mut().zip(&pixels.chroma) { | 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 | searched_coded.push(coded); | 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 | /// always), the shape [`set_frame_interp`] has: the witness that has to see | 2106 | /// always), the shape [`set_frame_interp`] has: the witness that has to see |
| 2105 | /// `mv_hp` symbols coded turns it on through this while holding | 2107 | /// `mv_hp` symbols coded turns it on through this while holding |
| 2106 | /// [`crate::speed::knob_write`]. | 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 | /// Sets [`HP_MV_OVERRIDE`]; `None` clears it. | 2112 | /// Sets [`HP_MV_OVERRIDE`]; `None` clears it. |
| 2110 | #[allow(dead_code)] // set only from the `#[cfg(test)]` gates | 2113 | #[allow(dead_code)] // set only from the `#[cfg(test)]` gates |
| @@ -4448,7 +4451,8 @@ pub(super) fn search_inter_block( | |||
| 4448 | planes, | 4451 | planes, |
| 4449 | (reference.width, reference.height), | 4452 | (reference.width, reference.height), |
| 4450 | fctx, | 4453 | fctx, |
| 4451 | - ) { | 4454 | + ) |
| 4455 | + { | ||
| 4452 | candidates.push((1, pred)); | 4456 | candidates.push((1, pred)); |
| 4453 | } | 4457 | } |
| 4454 | if warp_alphabet | 4458 | if warp_alphabet |
| @@ -4462,7 +4466,8 @@ pub(super) fn search_inter_block( | |||
| 4462 | info.ref_frame, | 4466 | info.ref_frame, |
| 4463 | planes, | 4467 | planes, |
| 4464 | fctx, | 4468 | fctx, |
| 4465 | - ) { | 4469 | + ) |
| 4470 | + { | ||
| 4466 | candidates.push((2, pred)); | 4471 | candidates.push((2, pred)); |
| 4467 | } | 4472 | } |
| 4468 | for (motion, pred) in candidates { | 4473 | for (motion, pred) in candidates { |
crates/ec-av1/src/encode/mod.rsmodified+0 -50
| @@ -821,12 +821,6 @@ fn rectres() -> bool { | |||
| 821 | static FORCE_B128_RECTRES: std::sync::atomic::AtomicBool = | 821 | static FORCE_B128_RECTRES: std::sync::atomic::AtomicBool = |
| 822 | std::sync::atomic::AtomicBool::new(false); | 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 | /// How many rect/AB pieces the search left WITH a residual rather than | 824 | /// How many rect/AB pieces the search left WITH a residual rather than |
| 831 | /// skipped, since the last [`take_b128_rectres_hits`] (class | 825 | /// skipped, since the last [`take_b128_rectres_hits`] (class |
| 832 | /// `gate-blind-to-feature`). | 826 | /// `gate-blind-to-feature`). |
| @@ -981,12 +975,6 @@ pub fn take_b128_vert_hits() -> usize { | |||
| 981 | /// RD there prefers one whole block; the gate census is the unforced count. | 975 | /// RD there prefers one whole block; the gate census is the unforced count. |
| 982 | static FORCE_B128_RECT: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(0); | 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 | /// lane-ab128: whether the 128 superblock root offers its four AB shapes -- | 978 | /// lane-ab128: whether the 128 superblock root offers its four AB shapes -- |
| 991 | /// `PARTITION_HORZ_A` (two 64x64 on top, one 128x64 below), `_HORZ_B` (one | 979 | /// `PARTITION_HORZ_A` (two 64x64 on top, one 128x64 below), `_HORZ_B` (one |
| 992 | /// 128x64 on top, two 64x64 below), `_VERT_A` (two 64x64 left, one 64x128 | 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 | /// prefers one whole block). | 1017 | /// prefers one whole block). |
| 1030 | static FORCE_B128_AB: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(0); | 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 | /// lane-ab128: the three pieces of an AB shape at a 128 root, in the order | 1020 | /// lane-ab128: the three pieces of an AB shape at a 128 root, in the order |
| 1039 | /// libaom's `decode_partition` codes them and decode.rs' `sb128_ab` arm | 1021 | /// libaom's `decode_partition` codes them and decode.rs' `sb128_ab` arm |
| 1040 | /// reads them (decode.rs ~35269) -- HORZ_A = TL, TR, bottom half; HORZ_B = | 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 | /// for content on which the root also wins its own comparison. | 1055 | /// for content on which the root also wins its own comparison. |
| 1074 | static FORCE_B128_ROOT: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); | 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 | /// How many 128 roots came out cheaper WITH a residual than skipped, since | 1058 | /// How many 128 roots came out cheaper WITH a residual than skipped, since |
| 1091 | /// the last [`take_b128_residual_hits`] (class `gate-blind-to-feature`). | 1059 | /// the last [`take_b128_residual_hits`] (class `gate-blind-to-feature`). |
| 1092 | static B128_RESIDUAL_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | 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 | PARTITION_HITS[which].fetch_add(1, std::sync::atomic::Ordering::Relaxed); | 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 | /// Whether the trial-set census (`EC_AV1_CENSUS=1`) is on: how many full | 1446 | /// Whether the trial-set census (`EC_AV1_CENSUS=1`) is on: how many full |
| 1485 | /// rate-distortion trials the block search actually runs, by kind, and where | 1447 | /// rate-distortion trials the block search actually runs, by kind, and where |
| 1486 | /// the winner sat in the cheap SAD ranking the pruning levers rank by. Off by | 1448 | /// the winner sat in the cheap SAD ranking the pruning levers rank by. Off by |
| @@ -2002,12 +1964,6 @@ thread_local! { | |||
| 2002 | static IBC_SHARE: std::cell::Cell<f64> = const { std::cell::Cell::new(0.0) }; | 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 | thread_local! { | 1967 | thread_local! { |
| 2012 | /// This SEQUENCE's `seq_force_screen_content_tools`: whether the sequence | 1968 | /// This SEQUENCE's `seq_force_screen_content_tools`: whether the sequence |
| 2013 | /// header offers the per-frame `allow_screen_content_tools` bit at all. | 1969 | /// header offers the per-frame `allow_screen_content_tools` bit at all. |
| @@ -2043,12 +1999,6 @@ thread_local! { | |||
| 2043 | const { std::cell::Cell::new(None) }; | 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 | #[cfg(test)] | 2002 | #[cfg(test)] |
| 2053 | pub(crate) fn force_screen(value: Option<bool>) { | 2003 | pub(crate) fn force_screen(value: Option<bool>) { |
| 2054 | SCREEN_FORCE.with(|c| c.set(value)); | 2004 | SCREEN_FORCE.with(|c| c.set(value)); |
crates/ec-av1/src/encode/more_tests.rsmodified+6 -691
| @@ -1,115 +1,5 @@ | |||
| 1 | -use super::*; | ||
| 2 | use super::tests::*; | 1 | use super::tests::*; |
| 3 | - | 2 | +use super::*; |
| 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 | - ); | ||
| 112 | - } | ||
| 113 | 3 | ||
| 114 | #[test] | 4 | #[test] |
| 115 | fn every_frame_of_a_sequence_decodes_through_our_own_decoder() { | 5 | fn every_frame_of_a_sequence_decodes_through_our_own_decoder() { |
| @@ -282,50 +172,6 @@ use super::tests::*; | |||
| 282 | ); | 172 | ); |
| 283 | } | 173 | } |
| 284 | 174 | ||
| 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 | - ); | ||
| 320 | - } | ||
| 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 | ||
| 325 | - ); | ||
| 326 | - assert!(written_all > 0.0); | ||
| 327 | - } | ||
| 328 | - | ||
| 329 | /// Low motion has to actually buy something: at least one inter frame of | 175 | /// 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 | 176 | /// 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 -- | 177 | /// starts it, and the inter-block share it prints has to be non-zero -- |
| @@ -412,147 +258,14 @@ use super::tests::*; | |||
| 412 | // agreeing with our encoder proves nothing about the bitstream. | 258 | // agreeing with our encoder proves nothing about the bitstream. |
| 413 | // ----------------------------------------------------------------------- | 259 | // ----------------------------------------------------------------------- |
| 414 | 260 | ||
| 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); | ||
| 523 | - } | ||
| 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 | 261 | /// First differing sample between two pictures, as |
| 552 | /// `(plane, index, left, right)` -- so a gate failure names the plane and | 262 | /// `(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 | 263 | /// 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. | 264 | /// 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)> { | 265 | +pub(super) fn first_plane_mismatch( |
| 266 | + a: &Picture, | ||
| 267 | + b: &Picture, | ||
| 268 | +) -> 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)] { | 269 | 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) { | 270 | 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]))); | 271 | return Some((plane, i, i64::from(l[i]), i64::from(r[i]))); |
| @@ -564,193 +277,6 @@ use super::tests::*; | |||
| 564 | None | 277 | None |
| 565 | } | 278 | } |
| 566 | 279 | ||
| 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) | ||
| 657 | - } | ||
| 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"); | ||
| 728 | - 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 | 280 | /// Byte-exactness gate for encoder work that is meant to change only |
| 755 | /// how long the encoder takes. | 281 | /// how long the encoder takes. |
| 756 | /// | 282 | /// |
| @@ -920,215 +446,6 @@ use super::tests::*; | |||
| 920 | } | 446 | } |
| 921 | } | 447 | } |
| 922 | 448 | ||
| 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:?}" | ||
| 930 | - ); | ||
| 931 | - } | ||
| 932 | - } | ||
| 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 | - ); | ||
| 1022 | - } | ||
| 1023 | - } | ||
| 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 | - }; | ||
| 1109 | - 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" | ||
| 1122 | - ); | ||
| 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 | 449 | /// 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 | 450 | /// 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, | 451 | /// SMOOTH or SHARP frame even if the header had said so -- the search, |
| @@ -1220,9 +537,7 @@ use super::tests::*; | |||
| 1220 | ); | 537 | ); |
| 1221 | for (i, e) in encoded.frames.iter().enumerate() { | 538 | for (i, e) in encoded.frames.iter().enumerate() { |
| 1222 | for (who, got) in [("ffmpeg", &decoded[i]), ("our decoder", &ours[i])] { | 539 | for (who, got) in [("ffmpeg", &decoded[i]), ("our decoder", &ours[i])] { |
| 1223 | - if let Some((plane, s, got, want)) = | 540 | + if let Some((plane, s, got, want)) = first_plane_mismatch(got, &e.reconstruction) { |
| 1224 | - first_plane_mismatch(got, &e.reconstruction) | ||
| 1225 | - { | ||
| 1226 | panic!( | 541 | panic!( |
| 1227 | "hp={hp} frame {i} plane {plane} sample {s}: {who} decoded {got}, \ | 542 | "hp={hp} frame {i} plane {plane} sample {s}: {who} decoded {got}, \ |
| 1228 | the encoder reconstructed {want}" | 543 | the encoder reconstructed {want}" |
crates/ec-av1/src/encode/split.rsmodified+32 -93
| @@ -312,13 +312,6 @@ pub(crate) static TXRD_STATS: [std::sync::atomic::AtomicU64; 7] = [ | |||
| 312 | std::sync::atomic::AtomicU64::new(0), | 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 | /// Reads [`INTER_TX_TYPE_HITS`] and zeroes it. | 315 | /// Reads [`INTER_TX_TYPE_HITS`] and zeroes it. |
| 323 | #[cfg(test)] | 316 | #[cfg(test)] |
| 324 | pub(crate) fn take_inter_tx_type_hits() -> [usize; 16] { | 317 | pub(crate) fn take_inter_tx_type_hits() -> [usize; 16] { |
| @@ -969,7 +962,15 @@ thread_local! { | |||
| 969 | static INTRABC_FORCE: std::cell::Cell<Option<bool>> = const { std::cell::Cell::new(None) }; | 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 | pub(crate) fn force_intrabc(value: Option<bool>) { | 974 | pub(crate) fn force_intrabc(value: Option<bool>) { |
| 974 | INTRABC_FORCE.with(|c| c.set(value)); | 975 | INTRABC_FORCE.with(|c| c.set(value)); |
| 975 | } | 976 | } |
| @@ -1059,7 +1060,12 @@ pub(super) fn ibc_index( | |||
| 1059 | /// `allow_intrabc` -- the share of its 16-aligned 16x16 blocks whose exact | 1060 | /// `allow_intrabc` -- the share of its 16-aligned 16x16 blocks whose exact |
| 1060 | /// content appears at some other position, against [`intrabc_pct`]. Returns | 1061 | /// content appears at some other position, against [`intrabc_pct`]. Returns |
| 1061 | /// the share as well, for the gate's own print. | 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 | if true_width < 4 * 64 || true_height < 2 * 64 { | 1069 | if true_width < 4 * 64 || true_height < 2 * 64 { |
| 1064 | return (false, 0.0); | 1070 | return (false, 0.0); |
| 1065 | } | 1071 | } |
| @@ -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 | /// [`crate::tile::write_dv_component`]'s static price -- the same shape as | 1216 | /// [`crate::tile::write_dv_component`]'s static price -- the same shape as |
| 1218 | /// [`mv_component_bits`] without the `mv_fr` symbol, which `force_integer_mv` | 1217 | /// [`mv_component_bits`] without the `mv_fr` symbol, which `force_integer_mv` |
| 1219 | /// infers rather than codes. | 1218 | /// infers rather than codes. |
| @@ -1667,7 +1666,8 @@ pub(super) fn code_square( | |||
| 1667 | if let Some(ibc) = ibc | 1666 | if let Some(ibc) = ibc |
| 1668 | && let Some((dv, cost_ibc, src)) = | 1667 | && let Some((dv, cost_ibc, src)) = |
| 1669 | ibc_search(ibc, luma, chroma, (x, y), side, search.lambda) | 1668 | ibc_search(ibc, luma, chroma, (x, y), side, search.lambda) |
| 1670 | - && cost_ibc < cost { | 1669 | + && cost_ibc < cost |
| 1670 | + { | ||
| 1671 | ibc_commit(luma, chroma, (x, y), src, side); | 1671 | ibc_commit(luma, chroma, (x, y), src, side); |
| 1672 | ibc.last_dv = Some(dv); | 1672 | ibc.last_dv = Some(dv); |
| 1673 | ibc.hits += 1; | 1673 | ibc.hits += 1; |
| @@ -1722,53 +1722,6 @@ pub(super) const CHROMA_MODES: [u8; 7] = [ | |||
| 1722 | PAETH_PRED, | 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 | /// Whether the chroma search offers `UV_CFL_PRED` at all (`EC_AV1_CFL=0` | 1725 | /// Whether the chroma search offers `UV_CFL_PRED` at all (`EC_AV1_CFL=0` |
| 1773 | /// switches it off, which is how the lane measured its own on/off pair). | 1726 | /// switches it off, which is how the lane measured its own on/off pair). |
| 1774 | pub(super) fn cfl_on() -> bool { | 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 | /// The luma loop-restoration unit size this sequence codes: a 128 superblock | 1790 | /// The luma loop-restoration unit size this sequence codes: a 128 superblock |
| 1846 | /// cannot signal the 64 unit at all (spec `lr_params` reads ONE bit there, | 1791 | /// cannot signal the 64 unit at all (spec `lr_params` reads ONE bit there, |
| 1847 | /// `RESTORATION_TILESIZE_MAX >> (2 - (shift + 1))`, so the smallest unit is | 1792 | /// `RESTORATION_TILESIZE_MAX >> (2 - (shift + 1))`, so the smallest unit is |
| @@ -1863,13 +1808,6 @@ pub(crate) fn filter_intra_on() -> bool { | |||
| 1863 | ENV.unwrap_or_else(|| crate::speed::at(&crate::speed::FILTER_INTRA)) | 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 | /// Searches both chroma planes over [`CHROMA_MODES`] under one shared mode -- | 1811 | /// Searches both chroma planes over [`CHROMA_MODES`] under one shared mode -- |
| 1874 | /// `uv_mode` is a single symbol covering U and V -- and commits the cheapest. | 1812 | /// `uv_mode` is a single symbol covering U and V -- and commits the cheapest. |
| 1875 | /// Returns each plane's levels, the mode, and what the pair cost (squared | 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 | let mut v_colors = [0u16; 8]; | 1990 | let mut v_colors = [0u16; 8]; |
| 2053 | for k in 0..n { | 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 | let candidate = crate::tile::PaletteUv { | 1996 | let candidate = crate::tile::PaletteUv { |
| 2057 | size: pal.size, | 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 | if census_on() { | 2172 | if census_on() { |
| 2239 | CHROMA_RANK[sad_rank(&ranking, mode).min(6)] | 2173 | CHROMA_RANK[sad_rank(&ranking, mode).min(6)] |
| 2240 | .fetch_add(1, std::sync::atomic::Ordering::Relaxed); | 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 | chroma[0].commit(at.x, at.y, at.side, &u); | 2176 | chroma[0].commit(at.x, at.y, at.side, &u); |
| 2244 | chroma[1].commit(at.x, at.y, at.side, &v); | 2177 | chroma[1].commit(at.x, at.y, at.side, &v); |
| 2245 | ( | 2178 | ( |
| @@ -2871,7 +2804,8 @@ pub(super) fn code_square_inter( | |||
| 2871 | } | 2804 | } |
| 2872 | } | 2805 | } |
| 2873 | if let Some(new_mv) = searched_new | 2806 | if let Some(new_mv) = searched_new |
| 2874 | - && let Some(b0) = mv_residual_bits(new_mv, cbase.0) { | 2807 | + && let Some(b0) = mv_residual_bits(new_mv, cbase.0) |
| 2808 | + { | ||
| 2875 | ccands.push(( | 2809 | ccands.push(( |
| 2876 | (new_mv, cstack.nearest_mv.1), | 2810 | (new_mv, cstack.nearest_mv.1), |
| 2877 | mode_bits_of(3) + b0, | 2811 | mode_bits_of(3) + b0, |
| @@ -2888,7 +2822,8 @@ pub(super) fn code_square_inter( | |||
| 2888 | // `NEAREST_NEWMV` and `NEW_NEWMV`: the NEW halves are the two | 2822 | // `NEAREST_NEWMV` and `NEW_NEWMV`: the NEW halves are the two |
| 2889 | // searches this leaf ran, each residual priced against `cbase`. | 2823 | // searches this leaf ran, each residual priced against `cbase`. |
| 2890 | if let Some(mv1) = second_new | 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 | + { | ||
| 2892 | ccands.push(( | 2827 | ccands.push(( |
| 2893 | (cstack.nearest_mv.0, mv1), | 2828 | (cstack.nearest_mv.0, mv1), |
| 2894 | mode_bits_of(2) + b1, | 2829 | mode_bits_of(2) + b1, |
| @@ -3040,7 +2975,8 @@ pub(super) fn code_square_inter( | |||
| 3040 | ) >= 1; | 2975 | ) >= 1; |
| 3041 | let mm = |m: u8| motion_mode_bits(side, side, m, warp_alphabet); | 2976 | let mm = |m: u8| motion_mode_bits(side, side, m, warp_alphabet); |
| 3042 | let mut candidates: Vec<(u8, [Vec<u8>; 3])> = Vec::new(); | 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 | && let Some(pred) = obmc_prediction( | 2980 | && let Some(pred) = obmc_prediction( |
| 3045 | grid, | 2981 | grid, |
| 3046 | (mi_row, mi_col), | 2982 | (mi_row, mi_col), |
| @@ -3052,7 +2988,8 @@ pub(super) fn code_square_inter( | |||
| 3052 | planes, | 2988 | planes, |
| 3053 | (reference.width, reference.height), | 2989 | (reference.width, reference.height), |
| 3054 | fctx, | 2990 | fctx, |
| 3055 | - ) { | 2991 | + ) |
| 2992 | + { | ||
| 3056 | candidates.push((1, pred)); | 2993 | candidates.push((1, pred)); |
| 3057 | } | 2994 | } |
| 3058 | if warp_alphabet | 2995 | if warp_alphabet |
| @@ -3066,7 +3003,8 @@ pub(super) fn code_square_inter( | |||
| 3066 | info.ref_frame, | 3003 | info.ref_frame, |
| 3067 | planes, | 3004 | planes, |
| 3068 | fctx, | 3005 | fctx, |
| 3069 | - ) { | 3006 | + ) |
| 3007 | + { | ||
| 3070 | candidates.push((2, pred)); | 3008 | candidates.push((2, pred)); |
| 3071 | } | 3009 | } |
| 3072 | for (motion, pred) in candidates { | 3010 | for (motion, pred) in candidates { |
| @@ -3125,7 +3063,8 @@ pub(super) fn code_square_inter( | |||
| 3125 | } | 3063 | } |
| 3126 | 3064 | ||
| 3127 | if let (cost, Some((luma_new, u_new, v_new, skip_new, info))) = best | 3065 | if let (cost, Some((luma_new, u_new, v_new, skip_new, info))) = best |
| 3128 | - && cost < intra_cost { | 3066 | + && cost < intra_cost |
| 3067 | + { | ||
| 3129 | // A compound winner commits the flat trial it was priced from: | 3068 | // A compound winner commits the flat trial it was priced from: |
| 3130 | // `commit_inter_luma`'s var-tx trial set is single-reference | 3069 | // `commit_inter_luma`'s var-tx trial set is single-reference |
| 3131 | // (`mc_trial`), so a compound leaf codes `tx_depth = 0`. | 3070 | // (`mc_trial`), so a compound leaf codes `tx_depth = 0`. |
crates/ec-av1/src/encode/tests.rsmodified+21 -1262
| @@ -1,26 +1,4 @@ | |||
| 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 | - } | ||
| 20 | - } | ||
| 21 | - assert_eq!(seen.len(), 16); | ||
| 22 | - } | ||
| 23 | - | ||
| 24 | /// An [`crate::mvstack::MvStack`] with every context at zero and no | 2 | /// 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 | 3 | /// neighbours, for the pricer tests below to fill the one band each of |
| 26 | /// them is about. | 4 | /// them is about. |
| @@ -141,9 +119,9 @@ | |||
| 141 | use crate::encode::symbol_bits as b; | 119 | use crate::encode::symbol_bits as b; |
| 142 | use crate::mvstack::{ | 120 | use crate::mvstack::{ |
| 143 | ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, | 121 | ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, |
| 144 | - LAST3_FRAME, NeighbourRef, comp_reference_type_ctx, reference_mode_ctx, | 122 | + LAST3_FRAME, NeighbourRef, comp_reference_type_ctx, reference_mode_ctx, single_ref_p1_ctx, |
| 145 | - single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, | 123 | + single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx, |
| 146 | - single_ref_p5_ctx, single_ref_p6_ctx, uni_comp_ref_p1_ctx, | 124 | + single_ref_p6_ctx, uni_comp_ref_p1_ctx, |
| 147 | }; | 125 | }; |
| 148 | // (pair, unidirectional?, the tree's symbols as (table, p index, | 126 | // (pair, unidirectional?, the tree's symbols as (table, p index, |
| 149 | // context selector, value)) -- transcribed from the writer. | 127 | // context selector, value)) -- transcribed from the writer. |
| @@ -385,8 +363,7 @@ | |||
| 385 | let mut want: f64 = symbols.iter().map(|&(p, v)| b(&SR[ctx_of(p)][p], v)).sum(); | 363 | let mut want: f64 = symbols.iter().map(|&(p, v)| b(&SR[ctx_of(p)][p], v)).sum(); |
| 386 | if super::reference_select() { | 364 | if super::reference_select() { |
| 387 | want += b( | 365 | want += b( |
| 388 | - &crate::cdf::COMP_MODE | 366 | + &crate::cdf::COMP_MODE[crate::mvstack::reference_mode_ctx(above_nbr, left_nbr)], |
| 389 | - [crate::mvstack::reference_mode_ctx(above_nbr, left_nbr)], | ||
| 390 | 0, | 367 | 0, |
| 391 | ); | 368 | ); |
| 392 | } | 369 | } |
| @@ -495,9 +472,8 @@ | |||
| 495 | max | 472 | max |
| 496 | ); | 473 | ); |
| 497 | // A stronger `k` never moves less than a weaker one. | 474 | // A stronger `k` never moves less than a weaker one. |
| 498 | - let d = |k: f64| { | 475 | + let d = |
| 499 | - (i32::from(super::deltaq_libaom(base, 8.0, rf, k, res)) - i32::from(base)).abs() | 476 | + |k: f64| (i32::from(super::deltaq_libaom(base, 8.0, rf, k, res)) - i32::from(base)).abs(); |
| 500 | - }; | ||
| 501 | assert!( | 477 | assert!( |
| 502 | d(0.5) <= d(1.0) && d(1.0) <= d(1.5), | 478 | d(0.5) <= d(1.0) && d(1.0) <= d(1.5), |
| 503 | "strength must be monotone: {} {} {}", | 479 | "strength must be monotone: {} {} {}", |
| @@ -837,8 +813,7 @@ | |||
| 837 | } else { | 813 | } else { |
| 838 | 0.0 | 814 | 0.0 |
| 839 | }; | 815 | }; |
| 840 | - picture.y[y * width + x] = | 816 | + picture.y[y * width + x] = (20.0 + gradient + ripple + edge).clamp(0.0, 255.0) as u16; |
| 841 | - (20.0 + gradient + ripple + edge).clamp(0.0, 255.0) as u16; | ||
| 842 | } | 817 | } |
| 843 | } | 818 | } |
| 844 | for y in 0..height / 2 { | 819 | for y in 0..height / 2 { |
| @@ -1130,241 +1105,6 @@ | |||
| 1130 | ); | 1105 | ); |
| 1131 | } | 1106 | } |
| 1132 | 1107 | ||
| 1133 | - /// lane-av1paletteuv: the census for `crate::tile::palette_uv_side`, the | ||
| 1134 | - /// `(side / 2).max(4)` named in `lanes/av1subsizesweep.report.md` as a | ||
| 1135 | - /// "4:2:2/4:4:0 palette map mis-sized" site. | ||
| 1136 | - /// | ||
| 1137 | - /// **What the site computes.** libaom reads the plane-1 colour-index map | ||
| 1138 | - /// at `av1_get_block_dimensions(bsize, 1, xd)` (blockd.h:1512): per axis, | ||
| 1139 | - /// `plane_block = block >> ss`, then `+2` when that came out under 4 | ||
| 1140 | - /// (the chroma sub-8x8 bump, blockd.h:1533-1541). For a SQUARE 4:2:0 | ||
| 1141 | - /// block both axes carry `ss = 1`, so both come to `side / 2` with the | ||
| 1142 | - /// bump -- which is exactly `(side / 2).max(4)`. The value is right. | ||
| 1143 | - /// | ||
| 1144 | - /// **What it is not.** At 4:2:2 the correct map is `(side >> 1) x side` | ||
| 1145 | - /// and at 4:4:4 it is `side x side` -- neither is square. So the value is | ||
| 1146 | - /// 4:2:0-only BY CONSTRUCTION, and this gate is what keeps it that way: | ||
| 1147 | - /// if an encoder that can emit another chroma shape ever appears, this | ||
| 1148 | - /// reds rather than the writer silently writing a half-height map. | ||
| 1149 | - /// | ||
| 1150 | - /// The three arms are (1) the value matches libaom's own per-axis | ||
| 1151 | - /// formula at 4:2:0 over every side the palette syntax admits, (2) no | ||
| 1152 | - /// reachable writer path can be handed another chroma shape, (3) a real | ||
| 1153 | - /// encode really fires chroma palettes, so arm 1 is not arithmetic on a | ||
| 1154 | - /// function nothing calls (class `gate-blind-to-feature`). | ||
| 1155 | - #[test] | ||
| 1156 | - fn the_chroma_palette_map_side_is_the_420_plane_block_and_nothing_else_reaches_it() { | ||
| 1157 | - const NAME: &str = | ||
| 1158 | - "the_chroma_palette_map_side_is_the_420_plane_block_and_nothing_else_reaches_it"; | ||
| 1159 | - let encode_src = crate::test_source::module_source("encode"); | ||
| 1160 | - | ||
| 1161 | - // ---- arm 1: the value, against libaom's formula -------------------- | ||
| 1162 | - // blockd.h:1530-1541, transcribed. A plane_block under 4 gains 2. | ||
| 1163 | - let libaom_plane1 = |block: usize, ss: usize| { | ||
| 1164 | - let plane_block = block >> ss; | ||
| 1165 | - plane_block + 2 * usize::from(plane_block < 4) | ||
| 1166 | - }; | ||
| 1167 | - let mut admitted = 0usize; | ||
| 1168 | - for side in 4usize..=64 { | ||
| 1169 | - // `palette_bsize_ctx`'s own domain: both sides <= 64 and | ||
| 1170 | - // bw * bh >= 64 (`av1_allow_palette`). A side outside it codes no | ||
| 1171 | - // palette syntax at all, so its map size is unobservable. | ||
| 1172 | - if side > 64 || side * side < 64 { | ||
| 1173 | - continue; | ||
| 1174 | - } | ||
| 1175 | - admitted += 1; | ||
| 1176 | - let want_x = libaom_plane1(side, 1); | ||
| 1177 | - let want_y = libaom_plane1(side, 1); | ||
| 1178 | - assert_eq!(want_x, want_y, "{NAME}: 4:2:0 arms the libaom formula"); | ||
| 1179 | - assert_eq!( | ||
| 1180 | - crate::tile::palette_uv_side(side), | ||
| 1181 | - want_x, | ||
| 1182 | - "{NAME}: side {side} -- palette_uv_side disagrees with libaom's plane-1 block" | ||
| 1183 | - ); | ||
| 1184 | - } | ||
| 1185 | - assert_eq!( | ||
| 1186 | - admitted, 57, | ||
| 1187 | - "{NAME}: the sweep admitted {admitted} sides, expected 57 (every integer 8..=64 -- \ | ||
| 1188 | - `palette_bsize_ctx`'s whole square domain, not just the powers of two a real block \ | ||
| 1189 | - takes) -- it must cover that domain, or it is not measuring it" | ||
| 1190 | - ); | ||
| 1191 | - | ||
| 1192 | - // Why `.max(4)` cannot fire, stated as a measurement rather than left | ||
| 1193 | - // for a reader to assume: `palette_bsize_ctx` refuses `bw * bh < 64`, | ||
| 1194 | - // so the smallest admitted square side is 8, whose halved plane block | ||
| 1195 | - // is already 4. The floor's only reachable input would be a side | ||
| 1196 | - // under 8, and libaom's own chroma sub-8x8 bump (+2) is likewise | ||
| 1197 | - // unreachable there. Dropping the floor is therefore NOT a witness | ||
| 1198 | - // mutation for this gate -- the mutation that bites is dropping the | ||
| 1199 | - // halving (measured, see the lane report) -- and this arm says why, | ||
| 1200 | - // so nobody later mistakes a green floor mutation for coverage. | ||
| 1201 | - for side in [8usize, 16, 32, 64] { | ||
| 1202 | - assert!( | ||
| 1203 | - side / 2 >= 4 && libaom_plane1(side, 1) == side / 2, | ||
| 1204 | - "{NAME}: side {side} -- the admitted domain moved, so `.max(4)` may now be \ | ||
| 1205 | - reachable and the floor needs a witness mutation of its own" | ||
| 1206 | - ); | ||
| 1207 | - } | ||
| 1208 | - | ||
| 1209 | - // The claim the gate rests on, stated as arithmetic so a future | ||
| 1210 | - // reader cannot mistake "correct" for "correct at any shape": at | ||
| 1211 | - // these shapes the per-axis answer is NOT this square. | ||
| 1212 | - for side in [8usize, 16, 32, 64] { | ||
| 1213 | - let square = crate::tile::palette_uv_side(side); | ||
| 1214 | - let want_422 = (libaom_plane1(side, 1), libaom_plane1(side, 0)); | ||
| 1215 | - let want_444 = (libaom_plane1(side, 0), libaom_plane1(side, 0)); | ||
| 1216 | - assert_ne!( | ||
| 1217 | - (square, square), | ||
| 1218 | - want_422, | ||
| 1219 | - "{NAME}: side {side} -- a square map IS the 4:2:2 map, so this gate's premise \ | ||
| 1220 | - (the site is 4:2:0-only) is wrong" | ||
| 1221 | - ); | ||
| 1222 | - assert_ne!( | ||
| 1223 | - (square, square), | ||
| 1224 | - want_444, | ||
| 1225 | - "{NAME}: side {side} -- a square map IS the 4:4:4 map" | ||
| 1226 | - ); | ||
| 1227 | - } | ||
| 1228 | - | ||
| 1229 | - // ---- arm 2: nothing can hand the writer another shape -------------- | ||
| 1230 | - // (a) Every non-test `ColorConfig` literal in the encoder names | ||
| 1231 | - // subsampling (1, 1). These are the two constructors the whole | ||
| 1232 | - // encoder reaches its colour config through; the test-module copies | ||
| 1233 | - // are excluded by scanning only the pre-`mod tests` prefix. The cut | ||
| 1234 | - // matches an inline `mod tests {` body only, so a `mod tests;` file | ||
| 1235 | - // declaration does not truncate the production files after it. | ||
| 1236 | - fn head(src: &str) -> &str { | ||
| 1237 | - let cut = src.find("\nmod tests {").unwrap_or(src.len()); | ||
| 1238 | - &src[..cut] | ||
| 1239 | - } | ||
| 1240 | - for (label, src) in [ | ||
| 1241 | - ("encode.rs", head(crate::test_source::module_production_source("encode"))), | ||
| 1242 | - ("encoder.rs", head(crate::test_source::module_production_source("encoder"))), | ||
| 1243 | - ] { | ||
| 1244 | - // Every `subsampling_*` the non-test encoder names, counted: a | ||
| 1245 | - // `(0, y)` or `(1, 0)` here is a chroma shape | ||
| 1246 | - // `palette_uv_side` cannot express. The one value allowed is 1 | ||
| 1247 | - // -- 4:2:0, the shape the square map is the right size for. | ||
| 1248 | - let mut shapes: std::collections::BTreeSet<(usize, usize)> = Default::default(); | ||
| 1249 | - for (sx, _) in src.match_indices("subsampling_x:") { | ||
| 1250 | - let rest = &src[sx + "subsampling_x:".len()..]; | ||
| 1251 | - let digits = |s: &str| { | ||
| 1252 | - s.trim_start() | ||
| 1253 | - .split(|c: char| !c.is_ascii_digit()) | ||
| 1254 | - .next() | ||
| 1255 | - .and_then(|d| d.parse::<usize>().ok()) | ||
| 1256 | - .unwrap_or(usize::MAX) | ||
| 1257 | - }; | ||
| 1258 | - let x = digits(rest); | ||
| 1259 | - let y = rest | ||
| 1260 | - .find("subsampling_y:") | ||
| 1261 | - .map(|y| digits(&rest[y + "subsampling_y:".len()..])) | ||
| 1262 | - .unwrap_or(usize::MAX); | ||
| 1263 | - shapes.insert((x, y)); | ||
| 1264 | - } | ||
| 1265 | - assert_eq!( | ||
| 1266 | - shapes, | ||
| 1267 | - std::collections::BTreeSet::from([(1usize, 1usize)]), | ||
| 1268 | - "{NAME}: the non-test {label} names chroma shapes {shapes:?} -- any shape other \ | ||
| 1269 | - than 4:2:0 is one palette_uv_side's square map cannot express (at 4:2:2 the \ | ||
| 1270 | - map is (side >> 1) x side, at 4:4:4 side x side)" | ||
| 1271 | - ); | ||
| 1272 | - } | ||
| 1273 | - | ||
| 1274 | - // (b) `key_frame_headers_colour` is the only PUBLIC entry that takes | ||
| 1275 | - // a caller-chosen ColorConfig -- it is how a 4:2:2 or 4:4:4 header is | ||
| 1276 | - // written at all -- so it is the one door a non-4:2:0 shape comes | ||
| 1277 | - // through. It builds HEADERS only: no tile writer is reachable from | ||
| 1278 | - // its body. (Its own doc says so; this measures it.) | ||
| 1279 | - let headers_at = encode_src | ||
| 1280 | - .find("pub fn key_frame_headers_colour(") | ||
| 1281 | - .expect("key_frame_headers_colour is gone -- re-derive this arm's scan anchor"); | ||
| 1282 | - let body_end = encode_src[headers_at..] | ||
| 1283 | - .find("\npub fn ") | ||
| 1284 | - .map(|n| headers_at + n) | ||
| 1285 | - .unwrap_or(encode_src.len()); | ||
| 1286 | - let headers_body = &encode_src[headers_at..body_end]; | ||
| 1287 | - for writer in [ | ||
| 1288 | - "write_palette_syntax", | ||
| 1289 | - "write_color_index_map", | ||
| 1290 | - "encode_key_frame_inner", | ||
| 1291 | - "tile::", | ||
| 1292 | - ] { | ||
| 1293 | - assert!( | ||
| 1294 | - !headers_body.contains(writer), | ||
| 1295 | - "{NAME}: key_frame_headers_colour now reaches {writer} -- a caller can pair a \ | ||
| 1296 | - 4:2:2/4:4:4 header with a tile, and palette_uv_side writes a square map into \ | ||
| 1297 | - the per-axis slot libaom reads as (side >> ss_x) x (side >> ss_y)" | ||
| 1298 | - ); | ||
| 1299 | - } | ||
| 1300 | - | ||
| 1301 | - // (c) Every tile-producing entry point goes through | ||
| 1302 | - // `encode_key_frame_inner`, whose five non-test call sites all pass | ||
| 1303 | - // one of the two 4:2:0 constructors above. Counted over the | ||
| 1304 | - // non-test source only, so a new road is a red rather than a line | ||
| 1305 | - // somebody has to notice. | ||
| 1306 | - let inner_calls = head(crate::test_source::module_production_source("encode")).matches("encode_key_frame_inner(").count() | ||
| 1307 | - + head(crate::test_source::module_production_source("encoder")).matches("encode_key_frame_inner(").count() | ||
| 1308 | - - 1; // the definition itself | ||
| 1309 | - assert_eq!( | ||
| 1310 | - inner_calls, 5, | ||
| 1311 | - "{NAME}: encode_key_frame_inner has {inner_calls} non-test call sites, expected 5 -- \ | ||
| 1312 | - a new one must pass a colour config this gate has read" | ||
| 1313 | - ); | ||
| 1314 | - | ||
| 1315 | - // (d) The picture itself is 4:2:0-shaped at the door, so a 4:2:2 or | ||
| 1316 | - // 4:4:4 frame cannot even be handed to an encode entry. Measured by | ||
| 1317 | - // calling `check`, not by reading it. | ||
| 1318 | - for (label, divisor) in [("4:2:2", 2usize), ("4:4:4", 1)] { | ||
| 1319 | - let p = Picture { | ||
| 1320 | - width: 64, | ||
| 1321 | - height: 64, | ||
| 1322 | - y: vec![0; 64 * 64], | ||
| 1323 | - u: vec![0; 64 * 64 / divisor], | ||
| 1324 | - v: vec![0; 64 * 64 / divisor], | ||
| 1325 | - }; | ||
| 1326 | - assert!( | ||
| 1327 | - p.check().is_err(), | ||
| 1328 | - "{NAME}: Picture::check accepted a {label}-shaped picture -- if the encoder can be \ | ||
| 1329 | - fed one, palette_uv_side's square map is wrong by construction" | ||
| 1330 | - ); | ||
| 1331 | - } | ||
| 1332 | - | ||
| 1333 | - // ---- arm 3: the site really fires --------------------------------- | ||
| 1334 | - // Without this, arms 1 and 2 are arithmetic and a source scan over a | ||
| 1335 | - // function no encode reaches (class `gate-blind-to-feature`). | ||
| 1336 | - // | ||
| 1337 | - // The fire count is the DECODER's thread-local one, not the writer's | ||
| 1338 | - // process-global `tile::take_palette_uv_hits`: that one is a | ||
| 1339 | - // swap-to-zero, so a parallel sibling test's encode steals this test's | ||
| 1340 | - // count (measured: it read `[0; 9]` under `cargo test palette`, and | ||
| 1341 | - // passed alone). Round-tripping the stream instead also proves the | ||
| 1342 | - // stronger half -- the reader took the map at the extent the WRITER | ||
| 1343 | - // sized, which is what makes the square value right rather than merely | ||
| 1344 | - // unchallenged. | ||
| 1345 | - let _knobs = crate::speed::knob_read(); | ||
| 1346 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | ||
| 1347 | - let before = crate::decode::palette_uv_hits(); | ||
| 1348 | - let encoded = encode_key_frame_with_ctx(&screen_card(192, 96), 100, 0.5, fctx).unwrap(); | ||
| 1349 | - let decoded = crate::stream::decode_stream(&encoded.stream) | ||
| 1350 | - .unwrap_or_else(|e| panic!("{NAME}: our own stream refused: {e}")); | ||
| 1351 | - let fired = crate::decode::palette_uv_hits() - before; | ||
| 1352 | - assert!( | ||
| 1353 | - fired > 0, | ||
| 1354 | - "{NAME}: no block took a chroma palette -- palette_uv_side was never exercised, so \ | ||
| 1355 | - this gate measures nothing" | ||
| 1356 | - ); | ||
| 1357 | - assert_eq!( | ||
| 1358 | - decoded[0].u, encoded.reconstruction.u, | ||
| 1359 | - "{NAME}: the decoder did not read the chroma map at the extent the writer sized it" | ||
| 1360 | - ); | ||
| 1361 | - assert_eq!( | ||
| 1362 | - decoded[0].v, encoded.reconstruction.v, | ||
| 1363 | - "{NAME}: the decoder did not read the chroma map at the extent the writer sized it" | ||
| 1364 | - ); | ||
| 1365 | - eprintln!("{NAME}: {fired} chroma palette block(s) round-tripped"); | ||
| 1366 | - } | ||
| 1367 | - | ||
| 1368 | /// lane-av1ibc's own end-to-end check: a repeated-pattern screen card | 1108 | /// lane-av1ibc's own end-to-end check: a repeated-pattern screen card |
| 1369 | /// sets `allow_intrabc` (so every in-loop filter is off), blocks really | 1109 | /// sets `allow_intrabc` (so every in-loop filter is off), blocks really |
| 1370 | /// take a block vector (fire count + DV histogram, class | 1110 | /// take a block vector (fire count + DV histogram, class |
| @@ -1380,7 +1120,6 @@ | |||
| 1380 | // above the blocks that copy from it. | 1120 | // above the blocks that copy from it. |
| 1381 | let (width, height) = (512usize, 256usize); | 1121 | let (width, height) = (512usize, 256usize); |
| 1382 | let picture = screen_card(width, height); | 1122 | let picture = screen_card(width, height); |
| 1383 | - let _ = crate::tile::take_intrabc_hits(); | ||
| 1384 | // The default is OFF (it measured worse on the real screen capture -- | 1123 | // The default is OFF (it measured worse on the real screen capture -- |
| 1385 | // see [`intrabc_enabled`]); this gate proves the SYNTAX, so it turns | 1124 | // see [`intrabc_enabled`]); this gate proves the SYNTAX, so it turns |
| 1386 | // the arm on for its own encode and puts it back straight after. | 1125 | // the arm on for its own encode and puts it back straight after. |
| @@ -1389,24 +1128,7 @@ | |||
| 1389 | force_intrabc(None); | 1128 | force_intrabc(None); |
| 1390 | assert!( | 1129 | assert!( |
| 1391 | encoded.allow_intrabc, | 1130 | encoded.allow_intrabc, |
| 1392 | - "allow_intrabc was not set on a fully periodic screen card (source repeat share {:.1}%)", | 1131 | + "allow_intrabc was not set on a fully periodic screen card" |
| 1393 | - intrabc_source_share() * 100.0 | ||
| 1394 | - ); | ||
| 1395 | - let hits = crate::tile::take_intrabc_hits(); | ||
| 1396 | - eprintln!( | ||
| 1397 | - "intrabc blocks {} DV magnitude histogram (1,2,4,8,16,32+ px) {:?}, source repeat share {:.1}%", | ||
| 1398 | - hits[0], | ||
| 1399 | - &hits[1..], | ||
| 1400 | - intrabc_source_share() * 100.0 | ||
| 1401 | - ); | ||
| 1402 | - let search = take_intrabc_search(); | ||
| 1403 | - eprintln!( | ||
| 1404 | - "intrabc searches {} found-valid {} won-RD {}", | ||
| 1405 | - search[0], search[1], search[2] | ||
| 1406 | - ); | ||
| 1407 | - assert!( | ||
| 1408 | - hits[0] > 0, | ||
| 1409 | - "no block took a block vector -- the `use_intrabc` syntax is unproven: {hits:?}" | ||
| 1410 | ); | 1132 | ); |
| 1411 | let via_us = crate::stream::decode_stream(&encoded.stream).unwrap(); | 1133 | let via_us = crate::stream::decode_stream(&encoded.stream).unwrap(); |
| 1412 | assert_eq!(via_us[0].y, encoded.reconstruction.y, "our decoder: luma"); | 1134 | assert_eq!(via_us[0].y, encoded.reconstruction.y, "our decoder: luma"); |
| @@ -1538,7 +1260,8 @@ | |||
| 1538 | "-of", | 1260 | "-of", |
| 1539 | "csv=p=0", | 1261 | "csv=p=0", |
| 1540 | ]) | 1262 | ]) |
| 1541 | - .arg(&path).output() | 1263 | + .arg(&path) |
| 1264 | + .output() | ||
| 1542 | .expect("ffprobe failed to run"); | 1265 | .expect("ffprobe failed to run"); |
| 1543 | let _ = std::fs::remove_file(&path); | 1266 | let _ = std::fs::remove_file(&path); |
| 1544 | assert!( | 1267 | assert!( |
| @@ -2105,152 +1828,6 @@ | |||
| 2105 | } | 1828 | } |
| 2106 | } | 1829 | } |
| 2107 | 1830 | ||
| 2108 | - /// One frame of a real clip, scaled to a whole number of 32x32 blocks. | ||
| 2109 | - pub(super) fn clip_frame(clip: &str, skip: &str, width: usize, height: usize) -> Picture { | ||
| 2110 | - let out = ec_testkit::ffmpeg() | ||
| 2111 | - .args(["-v", "error", "-ss", skip, "-i", clip, "-frames:v", "1"]) | ||
| 2112 | - .args(["-vf", &format!("scale={width}:{height}")]) | ||
| 2113 | - .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"]).output() | ||
| 2114 | - .expect("ffmpeg failed to run"); | ||
| 2115 | - assert!( | ||
| 2116 | - out.status.success(), | ||
| 2117 | - "ffmpeg: {}", | ||
| 2118 | - String::from_utf8_lossy(&out.stderr) | ||
| 2119 | - ); | ||
| 2120 | - let (luma, chroma) = (width * height, width * height / 4); | ||
| 2121 | - assert_eq!( | ||
| 2122 | - out.stdout.len(), | ||
| 2123 | - luma + 2 * chroma, | ||
| 2124 | - "expected one 4:2:0 frame" | ||
| 2125 | - ); | ||
| 2126 | - Picture { | ||
| 2127 | - width, | ||
| 2128 | - height, | ||
| 2129 | - y: out.stdout[..luma].iter().map(|&v| u16::from(v)).collect(), | ||
| 2130 | - u: out.stdout[luma..luma + chroma] | ||
| 2131 | - .iter() | ||
| 2132 | - .map(|&v| u16::from(v)) | ||
| 2133 | - .collect(), | ||
| 2134 | - v: out.stdout[luma + chroma..] | ||
| 2135 | - .iter() | ||
| 2136 | - .map(|&v| u16::from(v)) | ||
| 2137 | - .collect(), | ||
| 2138 | - } | ||
| 2139 | - } | ||
| 2140 | - | ||
| 2141 | - /// Prints what the mode search saves over DC prediction alone, for the | ||
| 2142 | - /// synthetic pictures and for whatever clips `EC_AV1_CLIPS` names, so the | ||
| 2143 | - /// weight the search puts on rate can be swept. | ||
| 2144 | - #[test] | ||
| 2145 | - #[ignore = "a sweep, not a gate"] | ||
| 2146 | - fn probe_lambda() { | ||
| 2147 | - let _knobs = crate::speed::knob_read(); | ||
| 2148 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | ||
| 2149 | - let mut pictures = vec![ | ||
| 2150 | - ("test card".to_string(), test_card(160, 96)), | ||
| 2151 | - ("stripes".to_string(), stripes(160, 96, true)), | ||
| 2152 | - ]; | ||
| 2153 | - if let Ok(clips) = std::env::var("EC_AV1_CLIPS") { | ||
| 2154 | - for entry in clips.split(':').filter(|e| !e.is_empty()) { | ||
| 2155 | - let (path, skip) = entry.split_once('@').unwrap_or((entry, "0")); | ||
| 2156 | - let name = path.rsplit('/').next().unwrap_or(path).to_string(); | ||
| 2157 | - pictures.push((name, clip_frame(path, skip, 640, 352))); | ||
| 2158 | - } | ||
| 2159 | - } | ||
| 2160 | - for (name, picture) in pictures { | ||
| 2161 | - let dc = ladder(&picture, &[DC_PRED], fctx); | ||
| 2162 | - let searched = ladder(&picture, &NON_DIRECTIONAL, fctx); | ||
| 2163 | - println!( | ||
| 2164 | - "{name}: {:+.1}% rate against DC alone, {:.0}B/{:.2}dB against {:.0}B/{:.2}dB at the middle point", | ||
| 2165 | - bd_rate(&dc, &searched) * 100.0, | ||
| 2166 | - 10f64.powf(searched[1].1), | ||
| 2167 | - searched[1].0, | ||
| 2168 | - 10f64.powf(dc[1].1), | ||
| 2169 | - dc[1].0, | ||
| 2170 | - ); | ||
| 2171 | - } | ||
| 2172 | - } | ||
| 2173 | - | ||
| 2174 | - /// Prints the whole mode-search ladder, so two builds of the search can be | ||
| 2175 | - /// compared against each other rather than each against its own baseline. | ||
| 2176 | - #[test] | ||
| 2177 | - #[ignore = "a sweep, not a gate"] | ||
| 2178 | - fn probe_ladder() { | ||
| 2179 | - let _knobs = crate::speed::knob_read(); | ||
| 2180 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | ||
| 2181 | - for (name, picture) in sweep_pictures() { | ||
| 2182 | - let all = ladder(&picture, &KEY_FRAME_MODES, fctx); | ||
| 2183 | - let points = all | ||
| 2184 | - .iter() | ||
| 2185 | - .map(|&(db, log_bytes)| format!("{:.0}@{db:.3}", 10f64.powf(log_bytes))) | ||
| 2186 | - .collect::<Vec<_>>() | ||
| 2187 | - .join(" "); | ||
| 2188 | - println!("ladder {name}: {points}"); | ||
| 2189 | - } | ||
| 2190 | - } | ||
| 2191 | - | ||
| 2192 | - /// Splitting a 32x32 block into four 16x16 ones, measured both ways over | ||
| 2193 | - /// the sweep pictures and whatever clips `EC_AV1_CLIPS` names. This is what | ||
| 2194 | - /// sets [`SPLIT_BLOCKS`]; the table it prints is in the lane report. | ||
| 2195 | - #[test] | ||
| 2196 | - // ROBUST-RED on this tree, and the red is in the MEASURE, not the codec: | ||
| 2197 | - // the `stripes` picture codes LOSSLESSLY at q110/90/70, so both ladders | ||
| 2198 | - // come back as three identical `(inf, 1.8260748027008264)` points and | ||
| 2199 | - // `bd_rate` has an empty trapezoid to integrate, which panics with | ||
| 2200 | - // "the two ladders have to overlap in PSNR". Row 1 (`test card`) still | ||
| 2201 | - // prints its number before the panic. Point `EC_AV1_CLIPS` at a real lossy | ||
| 2202 | - // clip, or read only row 1. | ||
| 2203 | - #[ignore = "a sweep, not a gate; PANICS on its own lossless synthetic rows (stripes is lossless at q110/90/70, so bd_rate has no PSNR overlap) -- point EC_AV1_CLIPS at a lossy clip"] | ||
| 2204 | - pub(super) fn probe_split() { | ||
| 2205 | - let _knobs = crate::speed::knob_read(); | ||
| 2206 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | ||
| 2207 | - for (name, picture) in sweep_pictures() { | ||
| 2208 | - let ladder = |split: bool| { | ||
| 2209 | - let mut points: Vec<(f64, f64)> = [110u8, 90, 70] | ||
| 2210 | - .iter() | ||
| 2211 | - .map(|&q| { | ||
| 2212 | - let encoded = encode_key_frame_inner( | ||
| 2213 | - &picture, | ||
| 2214 | - q, | ||
| 2215 | - 0.5, | ||
| 2216 | - &KEY_FRAME_MODES, | ||
| 2217 | - split, | ||
| 2218 | - (picture.width, picture.height), | ||
| 2219 | - unspecified_color_config(), | ||
| 2220 | - fctx, | ||
| 2221 | - ) | ||
| 2222 | - .unwrap(); | ||
| 2223 | - ( | ||
| 2224 | - psnr(&encoded.reconstruction.y, picture.y.as_slice()), | ||
| 2225 | - (encoded.stream.len() as f64).log10(), | ||
| 2226 | - ) | ||
| 2227 | - }) | ||
| 2228 | - .collect(); | ||
| 2229 | - points.sort_by(|a, b| a.0.total_cmp(&b.0)); | ||
| 2230 | - points | ||
| 2231 | - }; | ||
| 2232 | - let (whole, split) = (ladder(false), ladder(true)); | ||
| 2233 | - let blocks = encode_key_frame_inner( | ||
| 2234 | - &picture, | ||
| 2235 | - 90, | ||
| 2236 | - 0.5, | ||
| 2237 | - &KEY_FRAME_MODES, | ||
| 2238 | - true, | ||
| 2239 | - (picture.width, picture.height), | ||
| 2240 | - unspecified_color_config(), | ||
| 2241 | - fctx, | ||
| 2242 | - ) | ||
| 2243 | - .unwrap() | ||
| 2244 | - .modes | ||
| 2245 | - .len(); | ||
| 2246 | - let quadrants = (picture.width / BLOCK) * (picture.height / BLOCK); | ||
| 2247 | - println!( | ||
| 2248 | - "split {name}: {:+.2}% rate, {blocks} blocks for {quadrants} quadrants at q90", | ||
| 2249 | - bd_rate(&whole, &split) * 100.0 | ||
| 2250 | - ); | ||
| 2251 | - } | ||
| 2252 | - } | ||
| 2253 | - | ||
| 2254 | /// A striped picture, running one way or the other. The stripes are what | 1831 | /// A striped picture, running one way or the other. The stripes are what |
| 2255 | /// separates a vertical predictor from a horizontal one: a mode search | 1832 | /// separates a vertical predictor from a horizontal one: a mode search |
| 2256 | /// reading a transposed edge would pick the wrong one of the pair, which no | 1833 | /// reading a transposed edge would pick the wrong one of the pair, which no |
| @@ -2311,8 +1888,7 @@ | |||
| 2311 | let picture = test_card(width, height); | 1888 | let picture = test_card(width, height); |
| 2312 | for mode in KEY_FRAME_MODES { | 1889 | for mode in KEY_FRAME_MODES { |
| 2313 | let encoded = | 1890 | let encoded = |
| 2314 | - encode_key_frame_with_modes_with_ctx(&picture, 100, 0.5, &[mode], fctx) | 1891 | + encode_key_frame_with_modes_with_ctx(&picture, 100, 0.5, &[mode], fctx).unwrap(); |
| 2315 | - .unwrap(); | ||
| 2316 | let decoded = ffmpeg_decode(&encoded.stream, width, height); | 1892 | let decoded = ffmpeg_decode(&encoded.stream, width, height); |
| 2317 | for (plane, ours, theirs, stride) in [ | 1893 | for (plane, ours, theirs, stride) in [ |
| 2318 | ("luma", &encoded.reconstruction.y, &decoded.y, width), | 1894 | ("luma", &encoded.reconstruction.y, &decoded.y, width), |
| @@ -2419,7 +1995,11 @@ | |||
| 2419 | 1995 | ||
| 2420 | /// A ladder of (luma PSNR, log10 bytes) for one mode set, ordered by | 1996 | /// A ladder of (luma PSNR, log10 bytes) for one mode set, ordered by |
| 2421 | /// fidelity. | 1997 | /// fidelity. |
| 2422 | - pub(super) fn ladder(picture: &Picture, modes: &[u8], fctx: &crate::decode::FrameCtx) -> Vec<(f64, f64)> { | 1998 | +pub(super) fn ladder( |
| 1999 | + picture: &Picture, | ||
| 2000 | + modes: &[u8], | ||
| 2001 | + fctx: &crate::decode::FrameCtx, | ||
| 2002 | +) -> Vec<(f64, f64)> { | ||
| 2423 | // A mode ablation measures the MODE search: the palette would code | 2003 | // A mode ablation measures the MODE search: the palette would code |
| 2424 | // these synthetic two-colour pictures losslessly under every arm and | 2004 | // these synthetic two-colour pictures losslessly under every arm and |
| 2425 | // leave nothing to compare (see [`force_screen`]). | 2005 | // leave nothing to compare (see [`force_screen`]). |
| @@ -2468,63 +2048,6 @@ | |||
| 2468 | } | 2048 | } |
| 2469 | } | 2049 | } |
| 2470 | 2050 | ||
| 2471 | - /// The pictures a sweep is measured over: two synthetic ones, plus a frame | ||
| 2472 | - /// from each clip named in `EC_AV1_CLIPS` as `path@skip`, colon separated. | ||
| 2473 | - pub(super) fn sweep_pictures() -> Vec<(String, Picture)> { | ||
| 2474 | - let mut pictures = vec![ | ||
| 2475 | - ("test card".to_string(), test_card(160, 96)), | ||
| 2476 | - ("stripes".to_string(), stripes(160, 96, true)), | ||
| 2477 | - ("diagonal".to_string(), diagonal(160, 96, true)), | ||
| 2478 | - ]; | ||
| 2479 | - if let Ok(clips) = std::env::var("EC_AV1_CLIPS") { | ||
| 2480 | - for entry in clips.split(':').filter(|e| !e.is_empty()) { | ||
| 2481 | - let (path, skip) = entry.split_once('@').unwrap_or((entry, "0")); | ||
| 2482 | - let name = path.rsplit('/').next().unwrap_or(path).to_string(); | ||
| 2483 | - pictures.push((name, clip_frame(path, skip, 640, 352))); | ||
| 2484 | - } | ||
| 2485 | - } | ||
| 2486 | - pictures | ||
| 2487 | - } | ||
| 2488 | - | ||
| 2489 | - /// What the six directional modes are worth, per picture, at whatever | ||
| 2490 | - /// `LAMBDA_SCALE` currently is: the rate they save over the seven that read | ||
| 2491 | - /// no further, and how often the search picks one. | ||
| 2492 | - #[test] | ||
| 2493 | - #[ignore = "a sweep, not a gate"] | ||
| 2494 | - fn probe_directional() { | ||
| 2495 | - let _knobs = crate::speed::knob_write(); | ||
| 2496 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | ||
| 2497 | - for (name, picture) in sweep_pictures() { | ||
| 2498 | - let dc = ladder(&picture, &[DC_PRED], fctx); | ||
| 2499 | - let flat = ladder(&picture, &NON_DIRECTIONAL, fctx); | ||
| 2500 | - let all = ladder(&picture, &KEY_FRAME_MODES, fctx); | ||
| 2501 | - let encoded = encode_key_frame_with_ctx(&picture, 90, 0.5, fctx).unwrap(); | ||
| 2502 | - let directional = encoded | ||
| 2503 | - .modes | ||
| 2504 | - .iter() | ||
| 2505 | - .filter(|&&m| (3..=8).contains(&m)) | ||
| 2506 | - .count(); | ||
| 2507 | - // A picture whose ladders sit at different fidelities altogether | ||
| 2508 | - // has no BD-rate to report -- see the flat-sample-window class. | ||
| 2509 | - let overlap = |a: &[(f64, f64)], b: &[(f64, f64)]| { | ||
| 2510 | - a[0].0.max(b[0].0) < a[a.len() - 1].0.min(b[b.len() - 1].0) | ||
| 2511 | - }; | ||
| 2512 | - let against = |a: &[(f64, f64)], b: &[(f64, f64)]| { | ||
| 2513 | - if overlap(a, b) { | ||
| 2514 | - format!("{:+.2}%", bd_rate(a, b) * 100.0) | ||
| 2515 | - } else { | ||
| 2516 | - "no overlap".to_string() | ||
| 2517 | - } | ||
| 2518 | - }; | ||
| 2519 | - println!( | ||
| 2520 | - "{name}: {} against the seven, {} against DC alone, {directional} of {} blocks directional", | ||
| 2521 | - against(&flat, &all), | ||
| 2522 | - against(&dc, &all), | ||
| 2523 | - encoded.modes.len(), | ||
| 2524 | - ); | ||
| 2525 | - } | ||
| 2526 | - } | ||
| 2527 | - | ||
| 2528 | /// A picture whose stripes run along a diagonal, one way or the other. | 2051 | /// A picture whose stripes run along a diagonal, one way or the other. |
| 2529 | /// This is to the directional modes what [`stripes`] is to the vertical and | 2052 | /// This is to the directional modes what [`stripes`] is to the vertical and |
| 2530 | /// horizontal pair: a predictor that walked the edge in the wrong direction | 2053 | /// horizontal pair: a predictor that walked the edge in the wrong direction |
| @@ -2542,7 +2065,10 @@ | |||
| 2542 | 2065 | ||
| 2543 | /// The mode picked by the most blocks of a picture, ignoring the first | 2066 | /// The mode picked by the most blocks of a picture, ignoring the first |
| 2544 | /// block, which has no neighbours to tell the modes apart with. | 2067 | /// block, which has no neighbours to tell the modes apart with. |
| 2545 | - pub(super) fn favourite_mode(picture: &Picture, fctx: &crate::decode::FrameCtx) -> (u8, usize, usize) { | 2068 | +pub(super) fn favourite_mode( |
| 2069 | + picture: &Picture, | ||
| 2070 | + fctx: &crate::decode::FrameCtx, | ||
| 2071 | +) -> (u8, usize, usize) { | ||
| 2546 | // A mode ablation measures the MODE search: the palette would code | 2072 | // A mode ablation measures the MODE search: the palette would code |
| 2547 | // these synthetic two-colour pictures losslessly under every arm and | 2073 | // these synthetic two-colour pictures losslessly under every arm and |
| 2548 | // leave nothing to compare (see [`force_screen`]). | 2074 | // leave nothing to compare (see [`force_screen`]). |
| @@ -2879,8 +2405,7 @@ | |||
| 2879 | } else { | 2405 | } else { |
| 2880 | 0.0 | 2406 | 0.0 |
| 2881 | }; | 2407 | }; |
| 2882 | - picture.y[y * width + x] = | 2408 | + picture.y[y * width + x] = (20.0 + gradient + ripple + edge).clamp(0.0, 255.0) as u16; |
| 2883 | - (20.0 + gradient + ripple + edge).clamp(0.0, 255.0) as u16; | ||
| 2884 | } | 2409 | } |
| 2885 | } | 2410 | } |
| 2886 | for y in 0..height / 2 { | 2411 | for y in 0..height / 2 { |
| @@ -3015,769 +2540,3 @@ | |||
| 3015 | // signal, so no clip can provoke it (lane-av1recipehunt: 153 attempts, 0; | 2540 | // signal, so no clip can provoke it (lane-av1recipehunt: 153 attempts, 0; |
| 3016 | // widening the pricer to `0..5` fires the counter immediately, reverting | 2541 | // widening the pricer to `0..5` fires the counter immediately, reverting |
| 3017 | // silences it). `drl_clamp_hits` is kept as the tripwire for that fix. | 2542 | // silences it). `drl_clamp_hits` is kept as the tripwire for that fix. |
| 3018 | - | ||
| 3019 | - /// lane-b128: the 128x128 `PARTITION_NONE` root -- one block, one mode | ||
| 3020 | - /// and one motion vector where the four 64x64 roots below spend four of | ||
| 3021 | - /// each (cen3's L1). The counter is the gate on the fixture (class | ||
| 3022 | - /// `gate-blind-to-feature`): a green round trip on a clip that never | ||
| 3023 | - /// codes a 128x128 block proves nothing. RED before the search existed | ||
| 3024 | - /// (zero such blocks coded, `tile::write_sb128_root` wrote SPLIT at every | ||
| 3025 | - /// root by construction). | ||
| 3026 | - /// | ||
| 3027 | - /// Both readers: our own decoder sample-exact against the encoder's | ||
| 3028 | - /// reconstruction (a writer/reader desync surfaces as a pixel miss or a | ||
| 3029 | - /// refusal here, not in the BD gate) AND ffmpeg as the bitstream oracle. | ||
| 3030 | - /// | ||
| 3031 | - /// `#[ignore]`: [`force_sb128`] moves a process-global. | ||
| 3032 | - /// | ||
| 3033 | - /// Runs only inside `superblock_size_global_suite`. | ||
| 3034 | - fn a_128_superblock_clip_whose_root_search_codes_128x128_blocks_decodes_exact() { | ||
| 3035 | - let _knobs = crate::speed::knob_write(); | ||
| 3036 | - force_sb128(true); | ||
| 3037 | - let dir = std::env::temp_dir().join(format!("ec-av1-b128-{}", std::process::id())); | ||
| 3038 | - std::fs::create_dir_all(&dir).unwrap(); | ||
| 3039 | - let clip = dir.join("smpte-1280x768.y4m"); | ||
| 3040 | - // A slow horizontal pan over a still pattern: whole 128x128 regions | ||
| 3041 | - // share one motion vector, which is exactly what a 128 root can code | ||
| 3042 | - // as one block and four 64 roots cannot. | ||
| 3043 | - let ok = ec_testkit::ffmpeg() | ||
| 3044 | - .args(["-v", "error", "-y", "-f", "lavfi"]) | ||
| 3045 | - .args(["-i", "smptebars=size=1600x768:rate=24"]) | ||
| 3046 | - .args(["-vf", "crop=1280:768:'min(n*2,300)':0", "-frames:v", "8"]) | ||
| 3047 | - .args(["-pix_fmt", "yuv420p"]) | ||
| 3048 | - .arg(&clip) | ||
| 3049 | - .status() | ||
| 3050 | - .expect("ffmpeg failed to run") | ||
| 3051 | - .success(); | ||
| 3052 | - assert!(ok, "ffmpeg could not write the synthetic clip"); | ||
| 3053 | - let (width, height) = (1280usize, 768usize); | ||
| 3054 | - let pictures = crate::probe::source(clip.to_str().unwrap(), "0", "null", width, height, 8); | ||
| 3055 | - let _ = take_b128_none_hits(); | ||
| 3056 | - let _ = crate::tile::take_sb128_none_hits(); | ||
| 3057 | - let encoded = encode_sequence(&pictures, 150, 0.5).unwrap(); | ||
| 3058 | - let (won, coded) = (take_b128_none_hits(), crate::tile::take_sb128_none_hits()); | ||
| 3059 | - eprintln!("128x128 PARTITION_NONE blocks: search won {won}, writer coded {coded}"); | ||
| 3060 | - assert!( | ||
| 3061 | - coded > 0, | ||
| 3062 | - "no 128x128 block was coded on this clip, so it cannot witness the root search", | ||
| 3063 | - ); | ||
| 3064 | - assert_eq!( | ||
| 3065 | - won, coded, | ||
| 3066 | - "every 128x128 root the search took must be coded as one" | ||
| 3067 | - ); | ||
| 3068 | - let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | ||
| 3069 | - assert_eq!(decoded.len(), encoded.frames.len(), "frame count"); | ||
| 3070 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() { | ||
| 3071 | - let recon = &frame.reconstruction; | ||
| 3072 | - for (plane, got, want) in [ | ||
| 3073 | - ("luma", &dec.y, &recon.y), | ||
| 3074 | - ("U", &dec.u, &recon.u), | ||
| 3075 | - ("V", &dec.v, &recon.v), | ||
| 3076 | - ] { | ||
| 3077 | - let differ = got.iter().zip(want.iter()).filter(|(a, b)| a != b).count(); | ||
| 3078 | - assert_eq!( | ||
| 3079 | - differ, | ||
| 3080 | - 0, | ||
| 3081 | - "frame {i}: {plane} -- {differ} of {} samples differ from the encoder's \ | ||
| 3082 | - own reconstruction", | ||
| 3083 | - got.len() | ||
| 3084 | - ); | ||
| 3085 | - assert_eq!( | ||
| 3086 | - got.len(), | ||
| 3087 | - want.len(), | ||
| 3088 | - "frame {i}: {plane} is {} samples, the reconstruction's is {}", | ||
| 3089 | - got.len(), | ||
| 3090 | - want.len() | ||
| 3091 | - ); | ||
| 3092 | - } | ||
| 3093 | - } | ||
| 3094 | - let ff = ffmpeg_decode_sequence(&encoded.stream, width, height, pictures.len()); | ||
| 3095 | - assert_eq!( | ||
| 3096 | - encoded.frames.len(), | ||
| 3097 | - ff.len(), | ||
| 3098 | - "frame count: ours vs ffmpeg" | ||
| 3099 | - ); | ||
| 3100 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&ff).enumerate() { | ||
| 3101 | - assert_eq!(dec.y, frame.reconstruction.y, "frame {i}: ffmpeg luma"); | ||
| 3102 | - assert_eq!(dec.u, frame.reconstruction.u, "frame {i}: ffmpeg U"); | ||
| 3103 | - assert_eq!(dec.v, frame.reconstruction.v, "frame {i}: ffmpeg V"); | ||
| 3104 | - } | ||
| 3105 | - } | ||
| 3106 | - | ||
| 3107 | - /// lane-b128r: the 128 root's own RESIDUAL arm -- four TX_64X64 luma | ||
| 3108 | - /// units interleaved with a TX_32X32 chroma pair per 64x64 mu chunk. The | ||
| 3109 | - /// same pan the skip-only witness above uses, with the arm FORCED | ||
| 3110 | - /// ([`force_b128_residual`]): on synthetic bars the RD picks the residual | ||
| 3111 | - /// about once per frame, which witnesses the shape but not every context | ||
| 3112 | - /// it reads, and forcing codes all 420 roots of the clip through it. RED | ||
| 3113 | - /// before this lane by construction (`write_inter_block_128` refused | ||
| 3114 | - /// every non-skip 128 block, so no such block existed to decode), and RED | ||
| 3115 | - /// again on the first draft of the writer, whose neighbour band recorded | ||
| 3116 | - /// `skip = true` for a block that carries a residual -- the next root's | ||
| 3117 | - /// `skip` symbol then took CDF row 1 where the reader takes row 0. | ||
| 3118 | - /// | ||
| 3119 | - /// lane-b128res: the fixture's q moved 150 -> 60. The forced arm replaces | ||
| 3120 | - /// the skip arm's cost unconditionally (that is what makes the writer see | ||
| 3121 | - /// the residual), and the cost model moved under it since lane-b128r -- | ||
| 3122 | - /// lane-rectdq made every non-skipped root pay its delta_q group and the | ||
| 3123 | - /// pyramid re-prices the leaves -- so at q=150, then q=90, the NONE root | ||
| 3124 | - /// lost its partition at ALL 420 roots and the writer coded none. q=60 | ||
| 3125 | - /// puts 52 written blocks back on this clip; the `coded > 0` assert below | ||
| 3126 | - /// is the guard that catches the next such drift. | ||
| 3127 | - /// | ||
| 3128 | - /// Runs only inside `superblock_size_global_suite`. | ||
| 3129 | - fn a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders() { | ||
| 3130 | - let _knobs = crate::speed::knob_write(); | ||
| 3131 | - force_sb128(true); | ||
| 3132 | - let dir = std::env::temp_dir().join(format!("ec-av1-b128r-{}", std::process::id())); | ||
| 3133 | - std::fs::create_dir_all(&dir).unwrap(); | ||
| 3134 | - let clip = dir.join("smpte-pan-1280x768.y4m"); | ||
| 3135 | - let ok = ec_testkit::ffmpeg() | ||
| 3136 | - .args(["-v", "error", "-y", "-f", "lavfi"]) | ||
| 3137 | - .args(["-i", "smptebars=size=1600x768:rate=24"]) | ||
| 3138 | - .args(["-vf", "crop=1280:768:'min(n*2,300)':0", "-frames:v", "8"]) | ||
| 3139 | - .args(["-pix_fmt", "yuv420p"]) | ||
| 3140 | - .arg(&clip) | ||
| 3141 | - .status() | ||
| 3142 | - .expect("ffmpeg failed to run") | ||
| 3143 | - .success(); | ||
| 3144 | - assert!(ok, "ffmpeg could not write the synthetic clip"); | ||
| 3145 | - let (width, height) = (1280usize, 768usize); | ||
| 3146 | - let pictures = crate::probe::source(clip.to_str().unwrap(), "0", "null", width, height, 8); | ||
| 3147 | - let _ = take_b128_residual_hits(); | ||
| 3148 | - let _ = crate::tile::take_sb128_residual_hits(); | ||
| 3149 | - force_b128_residual(true); | ||
| 3150 | - let encoded = encode_sequence(&pictures, 60, 0.5).unwrap(); | ||
| 3151 | - let (won, coded) = ( | ||
| 3152 | - take_b128_residual_hits(), | ||
| 3153 | - crate::tile::take_sb128_residual_hits(), | ||
| 3154 | - ); | ||
| 3155 | - eprintln!("128x128 blocks WITH a residual: search won {won}, writer coded {coded}"); | ||
| 3156 | - assert!( | ||
| 3157 | - coded > 0, | ||
| 3158 | - "no 128x128 block carried a residual on this clip, so it cannot witness the arm", | ||
| 3159 | - ); | ||
| 3160 | - let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | ||
| 3161 | - assert_eq!(decoded.len(), encoded.frames.len(), "frame count"); | ||
| 3162 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() { | ||
| 3163 | - let recon = &frame.reconstruction; | ||
| 3164 | - for (plane, got, want) in [ | ||
| 3165 | - ("luma", &dec.y, &recon.y), | ||
| 3166 | - ("U", &dec.u, &recon.u), | ||
| 3167 | - ("V", &dec.v, &recon.v), | ||
| 3168 | - ] { | ||
| 3169 | - let differ = got.iter().zip(want.iter()).filter(|(a, b)| a != b).count(); | ||
| 3170 | - assert_eq!( | ||
| 3171 | - differ, | ||
| 3172 | - 0, | ||
| 3173 | - "frame {i}: {plane} -- {differ} of {} samples differ from the encoder's \ | ||
| 3174 | - own reconstruction", | ||
| 3175 | - got.len() | ||
| 3176 | - ); | ||
| 3177 | - assert_eq!( | ||
| 3178 | - got.len(), | ||
| 3179 | - want.len(), | ||
| 3180 | - "frame {i}: {plane} is {} samples, the reconstruction's is {}", | ||
| 3181 | - got.len(), | ||
| 3182 | - want.len() | ||
| 3183 | - ); | ||
| 3184 | - } | ||
| 3185 | - } | ||
| 3186 | - let ff = ffmpeg_decode_sequence(&encoded.stream, width, height, pictures.len()); | ||
| 3187 | - assert_eq!( | ||
| 3188 | - encoded.frames.len(), | ||
| 3189 | - ff.len(), | ||
| 3190 | - "frame count: ours vs ffmpeg" | ||
| 3191 | - ); | ||
| 3192 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&ff).enumerate() { | ||
| 3193 | - assert_eq!(dec.y, frame.reconstruction.y, "frame {i}: ffmpeg luma"); | ||
| 3194 | - assert_eq!(dec.u, frame.reconstruction.u, "frame {i}: ffmpeg U"); | ||
| 3195 | - assert_eq!(dec.v, frame.reconstruction.v, "frame {i}: ffmpeg V"); | ||
| 3196 | - } | ||
| 3197 | - } | ||
| 3198 | - | ||
| 3199 | - /// lane-edge128: a 128x128 root block WITH a residual on a clip whose | ||
| 3200 | - /// CDEF search codes a per-64x64 `cdef_idx` list. `read_cdef` (spec | ||
| 3201 | - /// 5.11.56) codes ONE literal for the block that first reaches a unit and | ||
| 3202 | - /// copies it over every unit the block SPANS, so the four units of a 128 | ||
| 3203 | - /// root share one index -- while the encoder's CDEF search prices a | ||
| 3204 | - /// preset per unit and its filter replay applied all four. Only the first | ||
| 3205 | - /// reached the stream, so every decoder filtered the other three with the | ||
| 3206 | - /// origin's strengths and the encoder's reconstruction (the picture the | ||
| 3207 | - /// next frame predicts from) was a filter apart from what a decoder | ||
| 3208 | - /// produces. RED before this lane on the native BD gate's bars 2160p row | ||
| 3209 | - /// (`EC_AV1_B128RES=1`, q=90, frame 11: 8 luma and 702 chroma samples, | ||
| 3210 | - /// the rows above the 128 superblock's own edge); the stream itself was | ||
| 3211 | - /// always right -- ffmpeg and our own decoder agreed with each other and | ||
| 3212 | - /// disagreed with the encoder. | ||
| 3213 | - /// | ||
| 3214 | - /// `take_cdef_covered_units` is the gate on the fixture (class | ||
| 3215 | - /// `gate-blind-to-feature`): a clip whose CDEF picks one strength pair | ||
| 3216 | - /// for the whole frame codes no literal at all and witnesses nothing. | ||
| 3217 | - /// | ||
| 3218 | - /// Runs only inside `superblock_size_global_suite`. | ||
| 3219 | - fn a_128_root_residual_block_under_a_per_unit_cdef_list_decodes_exact() { | ||
| 3220 | - let _knobs = crate::speed::knob_write(); | ||
| 3221 | - force_sb128(true); | ||
| 3222 | - let dir = std::env::temp_dir().join(format!("ec-av1-edge128-{}", std::process::id())); | ||
| 3223 | - std::fs::create_dir_all(&dir).unwrap(); | ||
| 3224 | - let clip = dir.join("testsrc2-1280x768.y4m"); | ||
| 3225 | - // Detailed synthetic content: its CDEF search spends more than one | ||
| 3226 | - // strength pair, which is what puts a `cdef_idx` literal in the tile. | ||
| 3227 | - let ok = ec_testkit::ffmpeg() | ||
| 3228 | - .args(["-v", "error", "-y", "-f", "lavfi"]) | ||
| 3229 | - .args(["-i", "testsrc2=size=1280x768:rate=24"]) | ||
| 3230 | - .args(["-frames:v", "12", "-pix_fmt", "yuv420p"]) | ||
| 3231 | - .arg(&clip) | ||
| 3232 | - .status() | ||
| 3233 | - .expect("ffmpeg failed to run") | ||
| 3234 | - .success(); | ||
| 3235 | - assert!(ok, "ffmpeg could not write the synthetic clip"); | ||
| 3236 | - let (width, height) = (1280usize, 768usize); | ||
| 3237 | - let pictures = crate::probe::source(clip.to_str().unwrap(), "0", "null", width, height, 12); | ||
| 3238 | - force_b128_root(true); | ||
| 3239 | - force_b128_residual(true); | ||
| 3240 | - let _ = crate::tile::take_sb128_residual_hits(); | ||
| 3241 | - let _ = crate::filter_search::take_cdef_covered_units(); | ||
| 3242 | - let encoded = encode_sequence(&pictures, 90, 0.5).unwrap(); | ||
| 3243 | - let coded = crate::tile::take_sb128_residual_hits(); | ||
| 3244 | - let covered = crate::filter_search::take_cdef_covered_units(); | ||
| 3245 | - eprintln!( | ||
| 3246 | - "128x128 blocks WITH a residual: writer coded {coded}; 64x64 CDEF units taking \ | ||
| 3247 | - another unit's literal: {covered}" | ||
| 3248 | - ); | ||
| 3249 | - assert!( | ||
| 3250 | - coded > 0, | ||
| 3251 | - "no 128x128 block carried a residual on this clip" | ||
| 3252 | - ); | ||
| 3253 | - assert!( | ||
| 3254 | - covered > 0, | ||
| 3255 | - "no 64x64 unit took a non-zero preset from another unit's literal, so this clip \ | ||
| 3256 | - cannot witness the rule", | ||
| 3257 | - ); | ||
| 3258 | - let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | ||
| 3259 | - assert_eq!(decoded.len(), encoded.frames.len(), "frame count"); | ||
| 3260 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() { | ||
| 3261 | - for (plane, got, want) in [ | ||
| 3262 | - ("luma", &dec.y, &frame.reconstruction.y), | ||
| 3263 | - ("U", &dec.u, &frame.reconstruction.u), | ||
| 3264 | - ("V", &dec.v, &frame.reconstruction.v), | ||
| 3265 | - ] { | ||
| 3266 | - let differ = got.iter().zip(want.iter()).filter(|(a, b)| a != b).count(); | ||
| 3267 | - assert_eq!(differ, 0, "frame {i}: {plane} -- {differ} samples differ"); | ||
| 3268 | - assert_eq!( | ||
| 3269 | - got.len(), | ||
| 3270 | - want.len(), | ||
| 3271 | - "frame {i}: {plane} is {} samples, the reconstruction's is {}", | ||
| 3272 | - got.len(), | ||
| 3273 | - want.len() | ||
| 3274 | - ); | ||
| 3275 | - } | ||
| 3276 | - } | ||
| 3277 | - let ff = ffmpeg_decode_sequence(&encoded.stream, width, height, pictures.len()); | ||
| 3278 | - assert_eq!( | ||
| 3279 | - encoded.frames.len(), | ||
| 3280 | - ff.len(), | ||
| 3281 | - "frame count: ours vs ffmpeg" | ||
| 3282 | - ); | ||
| 3283 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&ff).enumerate() { | ||
| 3284 | - assert_eq!(dec.y, frame.reconstruction.y, "frame {i}: ffmpeg luma"); | ||
| 3285 | - assert_eq!(dec.u, frame.reconstruction.u, "frame {i}: ffmpeg U"); | ||
| 3286 | - assert_eq!(dec.v, frame.reconstruction.v, "frame {i}: ffmpeg V"); | ||
| 3287 | - } | ||
| 3288 | - } | ||
| 3289 | - | ||
| 3290 | - /// lane-rectres: a `PARTITION_HORZ` 128 root whose two 128x64 halves | ||
| 3291 | - /// CARRY A RESIDUAL -- the mu-chunk shape (one TX_64X64 luma unit plus a | ||
| 3292 | - /// TX_32X32 chroma pair per chunk) `write_inter_block_128_rect` now | ||
| 3293 | - /// codes under `EC_AV1_RECTRES`, at the footprint the decoder's own | ||
| 3294 | - /// mu-chunk loop reads. The arm is FORCED ([`force_b128_rectres`], the | ||
| 3295 | - /// rect partition with [`force_b128_rect`]) so every inter root of the | ||
| 3296 | - /// clip goes through it; the `coded > 0` assert is the guard that catches | ||
| 3297 | - /// the next fixture drift (the whole-128 twin of this witness went RED | ||
| 3298 | - /// twice that way). | ||
| 3299 | - /// | ||
| 3300 | - /// Runs only inside `superblock_size_global_suite`. | ||
| 3301 | - fn a_rect128_half_with_a_real_residual_decodes_exact_through_both_decoders() { | ||
| 3302 | - let _knobs = crate::speed::knob_write(); | ||
| 3303 | - force_sb128(true); | ||
| 3304 | - let dir = std::env::temp_dir().join(format!("ec-av1-rectres-{}", std::process::id())); | ||
| 3305 | - std::fs::create_dir_all(&dir).unwrap(); | ||
| 3306 | - let clip = dir.join("smpte-pan-1280x768.y4m"); | ||
| 3307 | - let ok = ec_testkit::ffmpeg() | ||
| 3308 | - .args(["-v", "error", "-y", "-f", "lavfi"]) | ||
| 3309 | - .args(["-i", "smptebars=size=1600x768:rate=24"]) | ||
| 3310 | - .args(["-vf", "crop=1280:768:'min(n*2,300)':0", "-frames:v", "8"]) | ||
| 3311 | - .args(["-pix_fmt", "yuv420p"]) | ||
| 3312 | - .arg(&clip) | ||
| 3313 | - .status() | ||
| 3314 | - .expect("ffmpeg failed to run") | ||
| 3315 | - .success(); | ||
| 3316 | - assert!(ok, "ffmpeg could not write the synthetic clip"); | ||
| 3317 | - let (width, height) = (1280usize, 768usize); | ||
| 3318 | - let pictures = crate::probe::source(clip.to_str().unwrap(), "0", "null", width, height, 8); | ||
| 3319 | - force_b128_rect(1); | ||
| 3320 | - force_b128_rectres(true); | ||
| 3321 | - let _ = take_b128_rectres_hits(); | ||
| 3322 | - let _ = crate::tile::take_sb128_rectres_hits(); | ||
| 3323 | - let encoded = encode_sequence(&pictures, 60, 0.5).unwrap(); | ||
| 3324 | - let (won, coded) = ( | ||
| 3325 | - take_b128_rectres_hits(), | ||
| 3326 | - crate::tile::take_sb128_rectres_hits(), | ||
| 3327 | - ); | ||
| 3328 | - eprintln!("rect halves WITH a residual: search won {won}, writer coded {coded}"); | ||
| 3329 | - assert!( | ||
| 3330 | - coded > 0, | ||
| 3331 | - "no 128x64 half carried a residual on this clip, so it cannot witness the arm", | ||
| 3332 | - ); | ||
| 3333 | - let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | ||
| 3334 | - assert_eq!(decoded.len(), encoded.frames.len(), "frame count"); | ||
| 3335 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() { | ||
| 3336 | - let recon = &frame.reconstruction; | ||
| 3337 | - for (plane, got, want) in [ | ||
| 3338 | - ("luma", &dec.y, &recon.y), | ||
| 3339 | - ("U", &dec.u, &recon.u), | ||
| 3340 | - ("V", &dec.v, &recon.v), | ||
| 3341 | - ] { | ||
| 3342 | - let differ = got.iter().zip(want.iter()).filter(|(a, b)| a != b).count(); | ||
| 3343 | - assert_eq!( | ||
| 3344 | - differ, | ||
| 3345 | - 0, | ||
| 3346 | - "frame {i}: {plane} -- {differ} of {} samples differ from the encoder's \ | ||
| 3347 | - own reconstruction", | ||
| 3348 | - got.len() | ||
| 3349 | - ); | ||
| 3350 | - assert_eq!( | ||
| 3351 | - got.len(), | ||
| 3352 | - want.len(), | ||
| 3353 | - "frame {i}: {plane} is {} samples, the reconstruction's is {}", | ||
| 3354 | - got.len(), | ||
| 3355 | - want.len() | ||
| 3356 | - ); | ||
| 3357 | - } | ||
| 3358 | - } | ||
| 3359 | - let ff = ffmpeg_decode_sequence(&encoded.stream, width, height, pictures.len()); | ||
| 3360 | - assert_eq!( | ||
| 3361 | - encoded.frames.len(), | ||
| 3362 | - ff.len(), | ||
| 3363 | - "frame count: ours vs ffmpeg" | ||
| 3364 | - ); | ||
| 3365 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&ff).enumerate() { | ||
| 3366 | - assert_eq!(dec.y, frame.reconstruction.y, "frame {i}: ffmpeg luma"); | ||
| 3367 | - assert_eq!(dec.u, frame.reconstruction.u, "frame {i}: ffmpeg U"); | ||
| 3368 | - assert_eq!(dec.v, frame.reconstruction.v, "frame {i}: ffmpeg V"); | ||
| 3369 | - } | ||
| 3370 | - } | ||
| 3371 | - | ||
| 3372 | - /// lane-rectres: an AB shape (`PARTITION_HORZ_A` forced) whose THREE | ||
| 3373 | - /// pieces carry residuals -- the 128x64 half through the two-chunk arm, | ||
| 3374 | - /// the two 64x64 squares through the one-chunk arm (the shape libaom's | ||
| 3375 | - /// own AB partitions earn their keep with). testsrc2 at 12 frames, the | ||
| 3376 | - /// shipped AB witness's own recipe: an 8-frame clip parks an ARF whose | ||
| 3377 | - /// reference picture the GOP has not produced yet, which refuses before | ||
| 3378 | - /// any AB root is coded. | ||
| 3379 | - /// | ||
| 3380 | - /// Runs only inside `superblock_size_global_suite`. | ||
| 3381 | - fn an_ab128_piece_with_a_real_residual_decodes_exact_through_both_decoders() { | ||
| 3382 | - let _knobs = crate::speed::knob_write(); | ||
| 3383 | - force_sb128(true); | ||
| 3384 | - let dir = std::env::temp_dir().join(format!("ec-av1-rectres-ab-{}", std::process::id())); | ||
| 3385 | - std::fs::create_dir_all(&dir).unwrap(); | ||
| 3386 | - let clip = dir.join("testsrc2-1280x768.y4m"); | ||
| 3387 | - let ok = ec_testkit::ffmpeg() | ||
| 3388 | - .args(["-v", "error", "-y", "-f", "lavfi"]) | ||
| 3389 | - .args(["-i", "testsrc2=size=1280x768:rate=24"]) | ||
| 3390 | - .args(["-frames:v", "12", "-pix_fmt", "yuv420p"]) | ||
| 3391 | - .arg(&clip) | ||
| 3392 | - .status() | ||
| 3393 | - .expect("ffmpeg failed to run") | ||
| 3394 | - .success(); | ||
| 3395 | - assert!(ok, "ffmpeg could not write the synthetic clip"); | ||
| 3396 | - let (width, height) = (1280usize, 768usize); | ||
| 3397 | - let pictures = crate::probe::source(clip.to_str().unwrap(), "0", "null", width, height, 12); | ||
| 3398 | - force_b128_ab(4); | ||
| 3399 | - force_b128_rectres(true); | ||
| 3400 | - let _ = take_b128_rectres_hits(); | ||
| 3401 | - let _ = crate::tile::take_sb128_rectres_hits(); | ||
| 3402 | - let encoded = encode_sequence(&pictures, 60, 0.5).unwrap(); | ||
| 3403 | - let (won, coded) = ( | ||
| 3404 | - take_b128_rectres_hits(), | ||
| 3405 | - crate::tile::take_sb128_rectres_hits(), | ||
| 3406 | - ); | ||
| 3407 | - eprintln!("AB pieces WITH a residual: search won {won}, writer coded {coded}"); | ||
| 3408 | - assert!( | ||
| 3409 | - coded > 0, | ||
| 3410 | - "no AB piece carried a residual on this clip, so it cannot witness the arm", | ||
| 3411 | - ); | ||
| 3412 | - let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | ||
| 3413 | - assert_eq!(decoded.len(), encoded.frames.len(), "frame count"); | ||
| 3414 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() { | ||
| 3415 | - let recon = &frame.reconstruction; | ||
| 3416 | - for (plane, got, want) in [ | ||
| 3417 | - ("luma", &dec.y, &recon.y), | ||
| 3418 | - ("U", &dec.u, &recon.u), | ||
| 3419 | - ("V", &dec.v, &recon.v), | ||
| 3420 | - ] { | ||
| 3421 | - let differ = got.iter().zip(want.iter()).filter(|(a, b)| a != b).count(); | ||
| 3422 | - assert_eq!( | ||
| 3423 | - differ, | ||
| 3424 | - 0, | ||
| 3425 | - "frame {i}: {plane} -- {differ} of {} samples differ from the encoder's \ | ||
| 3426 | - own reconstruction", | ||
| 3427 | - got.len() | ||
| 3428 | - ); | ||
| 3429 | - assert_eq!( | ||
| 3430 | - got.len(), | ||
| 3431 | - want.len(), | ||
| 3432 | - "frame {i}: {plane} is {} samples, the reconstruction's is {}", | ||
| 3433 | - got.len(), | ||
| 3434 | - want.len() | ||
| 3435 | - ); | ||
| 3436 | - } | ||
| 3437 | - } | ||
| 3438 | - let ff = ffmpeg_decode_sequence(&encoded.stream, width, height, pictures.len()); | ||
| 3439 | - assert_eq!( | ||
| 3440 | - encoded.frames.len(), | ||
| 3441 | - ff.len(), | ||
| 3442 | - "frame count: ours vs ffmpeg" | ||
| 3443 | - ); | ||
| 3444 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&ff).enumerate() { | ||
| 3445 | - assert_eq!(dec.y, frame.reconstruction.y, "frame {i}: ffmpeg luma"); | ||
| 3446 | - assert_eq!(dec.u, frame.reconstruction.u, "frame {i}: ffmpeg U"); | ||
| 3447 | - assert_eq!(dec.v, frame.reconstruction.v, "frame {i}: ffmpeg V"); | ||
| 3448 | - } | ||
| 3449 | - } | ||
| 3450 | - | ||
| 3451 | - /// lane-rectres, lane-edge128's interaction on the rect shapes: a HORZ | ||
| 3452 | - /// half WITH a residual under a clip whose CDEF search codes a | ||
| 3453 | - /// per-64x64 `cdef_idx` list. The half codes ONE literal at its origin | ||
| 3454 | - /// and the decoder stamps BOTH units it spans with it, so the owner map | ||
| 3455 | - /// ([`crate::tile::cdef_unit_owner`], now extended past Whole128) has to | ||
| 3456 | - /// collapse the pair -- exactly the bug class that broke bars 2160p at | ||
| 3457 | - /// the whole-128 root. RED before this lane by construction: no rect | ||
| 3458 | - /// piece could carry a residual, so no such literal existed. | ||
| 3459 | - /// | ||
| 3460 | - /// Runs only inside `superblock_size_global_suite`. | ||
| 3461 | - fn a_rect128_residual_half_under_a_per_unit_cdef_list_decodes_exact() { | ||
| 3462 | - let _knobs = crate::speed::knob_write(); | ||
| 3463 | - force_sb128(true); | ||
| 3464 | - let dir = std::env::temp_dir().join(format!("ec-av1-rectres-cdef-{}", std::process::id())); | ||
| 3465 | - std::fs::create_dir_all(&dir).unwrap(); | ||
| 3466 | - let clip = dir.join("testsrc2-1280x768.y4m"); | ||
| 3467 | - // Detailed synthetic content: its CDEF search spends more than one | ||
| 3468 | - // strength pair, which is what puts a `cdef_idx` literal in the tile. | ||
| 3469 | - let ok = ec_testkit::ffmpeg() | ||
| 3470 | - .args(["-v", "error", "-y", "-f", "lavfi"]) | ||
| 3471 | - .args(["-i", "testsrc2=size=1280x768:rate=24"]) | ||
| 3472 | - .args(["-frames:v", "12", "-pix_fmt", "yuv420p"]) | ||
| 3473 | - .arg(&clip) | ||
| 3474 | - .status() | ||
| 3475 | - .expect("ffmpeg failed to run") | ||
| 3476 | - .success(); | ||
| 3477 | - assert!(ok, "ffmpeg could not write the synthetic clip"); | ||
| 3478 | - let (width, height) = (1280usize, 768usize); | ||
| 3479 | - let pictures = crate::probe::source(clip.to_str().unwrap(), "0", "null", width, height, 12); | ||
| 3480 | - force_b128_rect(1); | ||
| 3481 | - force_b128_rectres(true); | ||
| 3482 | - let _ = crate::tile::take_sb128_rectres_hits(); | ||
| 3483 | - let _ = crate::filter_search::take_cdef_covered_units(); | ||
| 3484 | - let encoded = encode_sequence(&pictures, 90, 0.5).unwrap(); | ||
| 3485 | - let coded = crate::tile::take_sb128_rectres_hits(); | ||
| 3486 | - let covered = crate::filter_search::take_cdef_covered_units(); | ||
| 3487 | - eprintln!( | ||
| 3488 | - "rect halves WITH a residual: writer coded {coded}; 64x64 CDEF units taking \ | ||
| 3489 | - another unit's literal: {covered}" | ||
| 3490 | - ); | ||
| 3491 | - assert!(coded > 0, "no 128x64 half carried a residual on this clip"); | ||
| 3492 | - assert!( | ||
| 3493 | - covered > 0, | ||
| 3494 | - "no 64x64 unit took a non-zero preset from another unit's literal, so this clip \ | ||
| 3495 | - cannot witness the rule", | ||
| 3496 | - ); | ||
| 3497 | - let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | ||
| 3498 | - assert_eq!(decoded.len(), encoded.frames.len(), "frame count"); | ||
| 3499 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() { | ||
| 3500 | - for (plane, got, want) in [ | ||
| 3501 | - ("luma", &dec.y, &frame.reconstruction.y), | ||
| 3502 | - ("U", &dec.u, &frame.reconstruction.u), | ||
| 3503 | - ("V", &dec.v, &frame.reconstruction.v), | ||
| 3504 | - ] { | ||
| 3505 | - let differ = got.iter().zip(want.iter()).filter(|(a, b)| a != b).count(); | ||
| 3506 | - assert_eq!(differ, 0, "frame {i}: {plane} -- {differ} samples differ"); | ||
| 3507 | - assert_eq!( | ||
| 3508 | - got.len(), | ||
| 3509 | - want.len(), | ||
| 3510 | - "frame {i}: {plane} is {} samples, the reconstruction's is {}", | ||
| 3511 | - got.len(), | ||
| 3512 | - want.len() | ||
| 3513 | - ); | ||
| 3514 | - } | ||
| 3515 | - } | ||
| 3516 | - let ff = ffmpeg_decode_sequence(&encoded.stream, width, height, pictures.len()); | ||
| 3517 | - assert_eq!( | ||
| 3518 | - encoded.frames.len(), | ||
| 3519 | - ff.len(), | ||
| 3520 | - "frame count: ours vs ffmpeg" | ||
| 3521 | - ); | ||
| 3522 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&ff).enumerate() { | ||
| 3523 | - assert_eq!(dec.y, frame.reconstruction.y, "frame {i}: ffmpeg luma"); | ||
| 3524 | - assert_eq!(dec.u, frame.reconstruction.u, "frame {i}: ffmpeg U"); | ||
| 3525 | - assert_eq!(dec.v, frame.reconstruction.v, "frame {i}: ffmpeg V"); | ||
| 3526 | - } | ||
| 3527 | - } | ||
| 3528 | - | ||
| 3529 | - /// lane-b128r: the COMPOUND arm at the 128 root -- one 128x128 block | ||
| 3530 | - /// naming `LAST` plus `GOLDEN`/`ALTREF`, through the same | ||
| 3531 | - /// `write_compound_block` chain every smaller compound block takes, at a | ||
| 3532 | - /// window it had never been exercised at. RED before this lane: the | ||
| 3533 | - /// search passed an empty compound list at the 128 root, so the count was | ||
| 3534 | - /// 0 and no such block existed to decode. | ||
| 3535 | - /// | ||
| 3536 | - /// Runs only inside `superblock_size_global_suite`. | ||
| 3537 | - fn a_128_root_compound_block_decodes_exact_through_both_decoders() { | ||
| 3538 | - let _knobs = crate::speed::knob_write(); | ||
| 3539 | - force_sb128(true); | ||
| 3540 | - let dir = std::env::temp_dir().join(format!("ec-av1-b128c-{}", std::process::id())); | ||
| 3541 | - std::fs::create_dir_all(&dir).unwrap(); | ||
| 3542 | - let clip = dir.join("testsrc2-1280x768.y4m"); | ||
| 3543 | - // Moving objects that occlude each other: a pan is coded by one | ||
| 3544 | - // reference outright, and a compound pair only pays where the two | ||
| 3545 | - // references disagree. | ||
| 3546 | - let ok = ec_testkit::ffmpeg() | ||
| 3547 | - .args(["-v", "error", "-y", "-f", "lavfi"]) | ||
| 3548 | - .args(["-i", "testsrc2=size=1280x768:rate=24"]) | ||
| 3549 | - .args(["-frames:v", "12", "-pix_fmt", "yuv420p"]) | ||
| 3550 | - .arg(&clip) | ||
| 3551 | - .status() | ||
| 3552 | - .expect("ffmpeg failed to run") | ||
| 3553 | - .success(); | ||
| 3554 | - assert!(ok, "ffmpeg could not write the synthetic clip"); | ||
| 3555 | - let (width, height) = (1280usize, 768usize); | ||
| 3556 | - let pictures = crate::probe::source(clip.to_str().unwrap(), "0", "null", width, height, 12); | ||
| 3557 | - // The compound candidate wins the 128 block's own search on this pan | ||
| 3558 | - // but the root then loses to its four cells, so the root is forced | ||
| 3559 | - // (the residual arm is left at its default, off). | ||
| 3560 | - force_b128_root(true); | ||
| 3561 | - let _ = take_b128_compound_hits(); | ||
| 3562 | - let _ = crate::tile::take_sb128_compound_hits(); | ||
| 3563 | - let encoded = encode_sequence(&pictures, 150, 0.5).unwrap(); | ||
| 3564 | - let (won, coded) = ( | ||
| 3565 | - take_b128_compound_hits(), | ||
| 3566 | - crate::tile::take_sb128_compound_hits(), | ||
| 3567 | - ); | ||
| 3568 | - eprintln!("COMPOUND 128x128 blocks: search won {won}, writer coded {coded}"); | ||
| 3569 | - assert!( | ||
| 3570 | - coded > 0, | ||
| 3571 | - "no compound 128x128 block was coded on this clip" | ||
| 3572 | - ); | ||
| 3573 | - let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | ||
| 3574 | - assert_eq!(decoded.len(), encoded.frames.len(), "frame count"); | ||
| 3575 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() { | ||
| 3576 | - for (plane, got, want) in [ | ||
| 3577 | - ("luma", &dec.y, &frame.reconstruction.y), | ||
| 3578 | - ("U", &dec.u, &frame.reconstruction.u), | ||
| 3579 | - ("V", &dec.v, &frame.reconstruction.v), | ||
| 3580 | - ] { | ||
| 3581 | - let differ = got.iter().zip(want.iter()).filter(|(a, b)| a != b).count(); | ||
| 3582 | - assert_eq!(differ, 0, "frame {i}: {plane} -- {differ} samples differ"); | ||
| 3583 | - assert_eq!( | ||
| 3584 | - got.len(), | ||
| 3585 | - want.len(), | ||
| 3586 | - "frame {i}: {plane} is {} samples, the reconstruction's is {}", | ||
| 3587 | - got.len(), | ||
| 3588 | - want.len() | ||
| 3589 | - ); | ||
| 3590 | - } | ||
| 3591 | - } | ||
| 3592 | - let ff = ffmpeg_decode_sequence(&encoded.stream, width, height, pictures.len()); | ||
| 3593 | - assert_eq!( | ||
| 3594 | - encoded.frames.len(), | ||
| 3595 | - ff.len(), | ||
| 3596 | - "frame count: ours vs ffmpeg" | ||
| 3597 | - ); | ||
| 3598 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&ff).enumerate() { | ||
| 3599 | - assert_eq!(dec.y, frame.reconstruction.y, "frame {i}: ffmpeg luma"); | ||
| 3600 | - assert_eq!(dec.u, frame.reconstruction.u, "frame {i}: ffmpeg U"); | ||
| 3601 | - assert_eq!(dec.v, frame.reconstruction.v, "frame {i}: ffmpeg V"); | ||
| 3602 | - } | ||
| 3603 | - } | ||
| 3604 | - | ||
| 3605 | - /// lane-b128hv: the 128 root's `PARTITION_HORZ` and `PARTITION_VERT` | ||
| 3606 | - /// arms -- two 128x64 / 64x128 inter blocks where the NONE arm codes one | ||
| 3607 | - /// square. Three passes over one `testsrc2` clip: | ||
| 3608 | - /// | ||
| 3609 | - /// * HORZ forced at every root ([`force_b128_rect`]), so every context | ||
| 3610 | - /// the 128x64 shape reads is exercised rather than the handful the RD | ||
| 3611 | - /// would pick; | ||
| 3612 | - /// * VERT forced the same way; | ||
| 3613 | - /// * UNFORCED, which is the count the gate rows are read against -- the | ||
| 3614 | - /// same clip with the RD free to choose among NONE / HORZ / VERT / | ||
| 3615 | - /// four superblocks. | ||
| 3616 | - /// | ||
| 3617 | - /// Each pass is sample-exact against the encoder's own reconstruction | ||
| 3618 | - /// through `decode_stream` AND through ffmpeg; a writer/reader mismatch | ||
| 3619 | - /// surfaces here as a refusal or a pixel miss, never in the BD gate. RED | ||
| 3620 | - /// before this lane by construction: `write_sb128_root` could only name | ||
| 3621 | - /// `PARTITION_NONE` or `PARTITION_SPLIT`, so the count was 0 on all three. | ||
| 3622 | - /// | ||
| 3623 | - /// Runs only inside `superblock_size_global_suite`. | ||
| 3624 | - fn a_128_root_horz_and_vert_halves_decode_exact_through_both_decoders() { | ||
| 3625 | - let _knobs = crate::speed::knob_write(); | ||
| 3626 | - force_sb128(true); | ||
| 3627 | - let dir = std::env::temp_dir().join(format!("ec-av1-b128hv-{}", std::process::id())); | ||
| 3628 | - std::fs::create_dir_all(&dir).unwrap(); | ||
| 3629 | - let clip = dir.join("testsrc2-1280x768.y4m"); | ||
| 3630 | - let ok = ec_testkit::ffmpeg() | ||
| 3631 | - .args(["-v", "error", "-y", "-f", "lavfi"]) | ||
| 3632 | - .args(["-i", "testsrc2=size=1280x768:rate=24"]) | ||
| 3633 | - .args(["-frames:v", "12", "-pix_fmt", "yuv420p"]) | ||
| 3634 | - .arg(&clip) | ||
| 3635 | - .status() | ||
| 3636 | - .expect("ffmpeg failed to run") | ||
| 3637 | - .success(); | ||
| 3638 | - assert!(ok, "ffmpeg could not write the synthetic clip"); | ||
| 3639 | - let (width, height) = (1280usize, 768usize); | ||
| 3640 | - let pictures = crate::probe::source(clip.to_str().unwrap(), "0", "null", width, height, 12); | ||
| 3641 | - let mut unforced = (0usize, 0usize); | ||
| 3642 | - for (label, force) in [("HORZ", 1u8), ("VERT", 2), ("unforced", 0)] { | ||
| 3643 | - force_b128_rect(force); | ||
| 3644 | - let _ = take_b128_horz_hits(); | ||
| 3645 | - let _ = take_b128_vert_hits(); | ||
| 3646 | - let _ = crate::tile::take_sb128_horz_hits(); | ||
| 3647 | - let _ = crate::tile::take_sb128_vert_hits(); | ||
| 3648 | - let encoded = encode_sequence(&pictures, 150, 0.5).unwrap(); | ||
| 3649 | - let (won_h, won_v) = (take_b128_horz_hits(), take_b128_vert_hits()); | ||
| 3650 | - let (coded_h, coded_v) = ( | ||
| 3651 | - crate::tile::take_sb128_horz_hits(), | ||
| 3652 | - crate::tile::take_sb128_vert_hits(), | ||
| 3653 | - ); | ||
| 3654 | - eprintln!( | ||
| 3655 | - "{label}: search won {won_h} HORZ + {won_v} VERT roots, writer coded \ | ||
| 3656 | - {coded_h} 128x64 + {coded_v} 64x128 halves" | ||
| 3657 | - ); | ||
| 3658 | - match force { | ||
| 3659 | - 1 => assert!(coded_h > 0, "no 128x64 half was coded with HORZ forced"), | ||
| 3660 | - 2 => assert!(coded_v > 0, "no 64x128 half was coded with VERT forced"), | ||
| 3661 | - // The unforced count is REPORTED, not asserted: it is the | ||
| 3662 | - // number the gate is read against, and a zero here would be | ||
| 3663 | - // an RD result, not a defect (the forced passes already prove | ||
| 3664 | - // the writer and the reader agree on the shape). | ||
| 3665 | - _ => unforced = (won_h, won_v), | ||
| 3666 | - } | ||
| 3667 | - let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder"); | ||
| 3668 | - assert_eq!(decoded.len(), encoded.frames.len(), "{label}: frame count"); | ||
| 3669 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() { | ||
| 3670 | - for (plane, got, want) in [ | ||
| 3671 | - ("luma", &dec.y, &frame.reconstruction.y), | ||
| 3672 | - ("U", &dec.u, &frame.reconstruction.u), | ||
| 3673 | - ("V", &dec.v, &frame.reconstruction.v), | ||
| 3674 | - ] { | ||
| 3675 | - let differ = got.iter().zip(want.iter()).filter(|(a, b)| a != b).count(); | ||
| 3676 | - assert_eq!( | ||
| 3677 | - differ, 0, | ||
| 3678 | - "{label} frame {i}: {plane} -- {differ} samples differ" | ||
| 3679 | - ); | ||
| 3680 | - assert_eq!( | ||
| 3681 | - got.len(), | ||
| 3682 | - want.len(), | ||
| 3683 | - "{label} frame {i}: {plane} is {} samples, the reconstruction's is {}", | ||
| 3684 | - got.len(), | ||
| 3685 | - want.len() | ||
| 3686 | - ); | ||
| 3687 | - } | ||
| 3688 | - } | ||
| 3689 | - let ff = ffmpeg_decode_sequence(&encoded.stream, width, height, pictures.len()); | ||
| 3690 | - assert_eq!( | ||
| 3691 | - encoded.frames.len(), | ||
| 3692 | - ff.len(), | ||
| 3693 | - "{label}: frame count: ours vs ffmpeg" | ||
| 3694 | - ); | ||
| 3695 | - for (i, (frame, dec)) in encoded.frames.iter().zip(&ff).enumerate() { | ||
| 3696 | - assert_eq!( | ||
| 3697 | - dec.y, frame.reconstruction.y, | ||
| 3698 | - "{label} frame {i}: ffmpeg luma" | ||
| 3699 | - ); | ||
| 3700 | - assert_eq!(dec.u, frame.reconstruction.u, "{label} frame {i}: ffmpeg U"); | ||
| 3701 | - assert_eq!(dec.v, frame.reconstruction.v, "{label} frame {i}: ffmpeg V"); | ||
| 3702 | - } | ||
| 3703 | - } | ||
| 3704 | - force_b128_rect(0); | ||
| 3705 | - eprintln!( | ||
| 3706 | - "unforced on testsrc2: {} HORZ + {} VERT roots over 12 frames", | ||
| 3707 | - unforced.0, unforced.1 | ||
| 3708 | - ); | ||
| 3709 | - } | ||
| 3710 | - | ||
| 3711 | -/// Restores the process-global 128-superblock state the folded cases move: | ||
| 3712 | -/// the sb128 mode back to its prior value, and every `force_b128_*` arm back | ||
| 3713 | -/// to off, so one case cannot leak into the next. | ||
| 3714 | -fn restore_superblock_globals(prior_sb128: u8) { | ||
| 3715 | - super::split::ENC_SB128.store(prior_sb128, std::sync::atomic::Ordering::Relaxed); | ||
| 3716 | - force_b128_residual(false); | ||
| 3717 | - force_b128_root(false); | ||
| 3718 | - force_b128_rectres(false); | ||
| 3719 | - force_b128_rect(0); | ||
| 3720 | - force_b128_ab(0); | ||
| 3721 | -} | ||
| 3722 | - | ||
| 3723 | -/// The ten cases that set the process-global superblock size, folded into | ||
| 3724 | -/// one ignored test so they never share a process with another such test. | ||
| 3725 | -/// Each case runs under `catch_unwind`; every failing name is reported. | ||
| 3726 | -/// | ||
| 3727 | -/// cargo test -p ec-av1 --release --lib -- --ignored \ | ||
| 3728 | -/// superblock_size_global_suite --nocapture | ||
| 3729 | -#[test] | ||
| 3730 | -#[ignore = "sets the process-global superblock size: run it alone"] | ||
| 3731 | -fn superblock_size_global_suite() { | ||
| 3732 | - let prior = super::split::ENC_SB128.load(std::sync::atomic::Ordering::Relaxed); | ||
| 3733 | - let cases: [(&str, fn()); 10] = [ | ||
| 3734 | - ( | ||
| 3735 | - "a_128_superblock_clip_whose_root_search_codes_128x128_blocks_decodes_exact", | ||
| 3736 | - a_128_superblock_clip_whose_root_search_codes_128x128_blocks_decodes_exact, | ||
| 3737 | - ), | ||
| 3738 | - ( | ||
| 3739 | - "a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders", | ||
| 3740 | - a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders, | ||
| 3741 | - ), | ||
| 3742 | - ( | ||
| 3743 | - "a_128_root_residual_block_under_a_per_unit_cdef_list_decodes_exact", | ||
| 3744 | - a_128_root_residual_block_under_a_per_unit_cdef_list_decodes_exact, | ||
| 3745 | - ), | ||
| 3746 | - ( | ||
| 3747 | - "a_rect128_half_with_a_real_residual_decodes_exact_through_both_decoders", | ||
| 3748 | - a_rect128_half_with_a_real_residual_decodes_exact_through_both_decoders, | ||
| 3749 | - ), | ||
| 3750 | - ( | ||
| 3751 | - "an_ab128_piece_with_a_real_residual_decodes_exact_through_both_decoders", | ||
| 3752 | - an_ab128_piece_with_a_real_residual_decodes_exact_through_both_decoders, | ||
| 3753 | - ), | ||
| 3754 | - ( | ||
| 3755 | - "a_rect128_residual_half_under_a_per_unit_cdef_list_decodes_exact", | ||
| 3756 | - a_rect128_residual_half_under_a_per_unit_cdef_list_decodes_exact, | ||
| 3757 | - ), | ||
| 3758 | - ( | ||
| 3759 | - "a_128_root_compound_block_decodes_exact_through_both_decoders", | ||
| 3760 | - a_128_root_compound_block_decodes_exact_through_both_decoders, | ||
| 3761 | - ), | ||
| 3762 | - ( | ||
| 3763 | - "a_128_root_horz_and_vert_halves_decode_exact_through_both_decoders", | ||
| 3764 | - a_128_root_horz_and_vert_halves_decode_exact_through_both_decoders, | ||
| 3765 | - ), | ||
| 3766 | - ( | ||
| 3767 | - "a_128_root_ab_shapes_decode_exact_through_both_decoders", | ||
| 3768 | - super::more_tests::a_128_root_ab_shapes_decode_exact_through_both_decoders, | ||
| 3769 | - ), | ||
| 3770 | - ( | ||
| 3771 | - "a_static_clip_codes_128x128_superblock_roots_and_decodes_sample_exact", | ||
| 3772 | - crate::encoder::tests::a_static_clip_codes_128x128_superblock_roots_and_decodes_sample_exact, | ||
| 3773 | - ), | ||
| 3774 | - ]; | ||
| 3775 | - let mut failures = Vec::new(); | ||
| 3776 | - for (name, case) in cases { | ||
| 3777 | - if std::panic::catch_unwind(std::panic::AssertUnwindSafe(case)).is_err() { | ||
| 3778 | - failures.push(name); | ||
| 3779 | - } | ||
| 3780 | - restore_superblock_globals(prior); | ||
| 3781 | - } | ||
| 3782 | - assert!(failures.is_empty(), "failed cases: {failures:?}"); | ||
| 3783 | -} | ||
crates/ec-av1/src/encoder/tests.rsmodified+29 -557
Diff too large; view file
| @@ -1,3 +1,4 @@ | |||
| 1 | + | ||
| 1 | use super::*; | 2 | use super::*; |
| 2 | 3 | ||
| 3 | fn test_card(width: usize, height: usize, shift: usize) -> Picture { | 4 | fn test_card(width: usize, height: usize, shift: usize) -> Picture { |
| @@ -147,8 +148,7 @@ | |||
| 147 | "leaf target {:.3} is not the exact remainder {want:.3} (naive division would \ | 148 | "leaf target {:.3} is not the exact remainder {want:.3} (naive division would \ |
| 148 | give {:.3})", | 149 | give {:.3})", |
| 149 | rl.target[2], | 150 | rl.target[2], |
| 150 | - (run_bytes - key_bytes - arf_bytes) | 151 | + (run_bytes - key_bytes - arf_bytes) / (leaves as f64 + hidden_weight - rl.weight(offset)) |
| 151 | - / (leaves as f64 + hidden_weight - rl.weight(offset)) | ||
| 152 | ); | 152 | ); |
| 153 | // And the re-plan stays BOUNDED: hidden levels that spend nothing at | 153 | // And the re-plan stays BOUNDED: hidden levels that spend nothing at |
| 154 | // all cannot run the leaves' target away. | 154 | // all cannot run the leaves' target away. |
| @@ -308,8 +308,7 @@ | |||
| 308 | fn the_facade_codes_the_same_bytes_as_encode_sequence() { | 308 | fn the_facade_codes_the_same_bytes_as_encode_sequence() { |
| 309 | let _knobs = crate::speed::knob_read(); | 309 | let _knobs = crate::speed::knob_read(); |
| 310 | let frames = 12usize; | 310 | let frames = 12usize; |
| 311 | - let film = h264_clip_frames(640, 384, frames) | 311 | + let film = h264_clip_frames(640, 384, frames).unwrap_or_else(|| { |
| 312 | - .unwrap_or_else(|| { | ||
| 313 | // The probe inside already printed the ONE line naming the | 312 | // The probe inside already printed the ONE line naming the |
| 314 | // resolved path and the escape hatch, so this is a note about | 313 | // resolved path and the escape hatch, so this is a note about |
| 315 | // what runs instead — not a second SKIP. | 314 | // what runs instead — not a second SKIP. |
| @@ -478,7 +477,8 @@ | |||
| 478 | "-of", | 477 | "-of", |
| 479 | "csv=p=0", | 478 | "csv=p=0", |
| 480 | ]) | 479 | ]) |
| 481 | - .arg(&path).output() | 480 | + .arg(&path) |
| 481 | + .output() | ||
| 482 | .expect("ffprobe failed to run"); | 482 | .expect("ffprobe failed to run"); |
| 483 | let _ = std::fs::remove_file(&path); | 483 | let _ = std::fs::remove_file(&path); |
| 484 | assert!( | 484 | assert!( |
| @@ -518,7 +518,8 @@ | |||
| 518 | "-of", | 518 | "-of", |
| 519 | "csv=p=0", | 519 | "csv=p=0", |
| 520 | ]) | 520 | ]) |
| 521 | - .arg(&path).output() | 521 | + .arg(&path) |
| 522 | + .output() | ||
| 522 | .expect("ffprobe failed to run"); | 523 | .expect("ffprobe failed to run"); |
| 523 | let _ = std::fs::remove_file(&path); | 524 | let _ = std::fs::remove_file(&path); |
| 524 | assert!( | 525 | assert!( |
| @@ -668,11 +669,7 @@ | |||
| 668 | /// to this facade's own input size, and re-coded through the facade so the | 669 | /// to this facade's own input size, and re-coded through the facade so the |
| 669 | /// rate-target surface is exercised at the entry point a caller actually | 670 | /// rate-target surface is exercised at the entry point a caller actually |
| 670 | /// drives. | 671 | /// drives. |
| 671 | - fn h264_clip_frames( | 672 | +fn h264_clip_frames(width: usize, height: usize, frames: usize) -> Option<Vec<Picture>> { |
| 672 | - width: usize, | ||
| 673 | - height: usize, | ||
| 674 | - frames: usize, | ||
| 675 | - ) -> Option<Vec<Picture>> { | ||
| 676 | h264_clip_frames_at(20, width, height, frames) | 673 | h264_clip_frames_at(20, width, height, frames) |
| 677 | } | 674 | } |
| 678 | 675 | ||
| @@ -703,10 +700,18 @@ | |||
| 703 | // therefore `return` on `None` WITHOUT printing a second one -- the | 700 | // therefore `return` on `None` WITHOUT printing a second one -- the |
| 704 | // second "no fixture" line per gate was the noise that hid this defect. | 701 | // second "no fixture" line per gate was the noise that hid this defect. |
| 705 | let out = ec_testkit::ffmpeg() | 702 | let out = ec_testkit::ffmpeg() |
| 706 | - .args(["-v", "error", "-ss", &start.to_string(), "-i", clip.to_str().unwrap()]) | 703 | + .args([ |
| 704 | + "-v", | ||
| 705 | + "error", | ||
| 706 | + "-ss", | ||
| 707 | + &start.to_string(), | ||
| 708 | + "-i", | ||
| 709 | + clip.to_str().unwrap(), | ||
| 710 | + ]) | ||
| 707 | .args(["-frames:v", &frames.to_string()]) | 711 | .args(["-frames:v", &frames.to_string()]) |
| 708 | .args(["-vf", &format!("scale={width}:{height}")]) | 712 | .args(["-vf", &format!("scale={width}:{height}")]) |
| 709 | - .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"]).output() | 713 | + .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"]) |
| 714 | + .output() | ||
| 710 | .expect("ffmpeg failed to run"); | 715 | .expect("ffmpeg failed to run"); |
| 711 | assert!( | 716 | assert!( |
| 712 | out.status.success(), | 717 | out.status.success(), |
| @@ -749,10 +754,7 @@ | |||
| 749 | #[test] | 754 | #[test] |
| 750 | fn bytes_per_frame_target_settles_within_20_percent() { | 755 | fn bytes_per_frame_target_settles_within_20_percent() { |
| 751 | let _knobs = crate::speed::knob_read(); | 756 | let _knobs = crate::speed::knob_read(); |
| 752 | - let Some(pictures) = h264_clip_frames(640, | 757 | + let Some(pictures) = h264_clip_frames(640, 384, 24) else { |
| 753 | - 384, | ||
| 754 | - 24, | ||
| 755 | - ) else { | ||
| 756 | return; | 758 | return; |
| 757 | }; | 759 | }; |
| 758 | let target_bytes = 4_000u32; | 760 | let target_bytes = 4_000u32; |
| @@ -905,8 +907,7 @@ | |||
| 905 | .expect("with_rate_target") | 907 | .expect("with_rate_target") |
| 906 | .rate_loop | 908 | .rate_loop |
| 907 | .is_some(); | 909 | .is_some(); |
| 908 | - let pyr = | 910 | + let pyr = Av1Encoder::with_pyramid_and_rate_target(config, Pyramid::default(), rate) |
| 909 | - Av1Encoder::with_pyramid_and_rate_target(config, Pyramid::default(), rate) | ||
| 910 | .expect("with_pyramid_and_rate_target") | 911 | .expect("with_pyramid_and_rate_target") |
| 911 | .pyramid | 912 | .pyramid |
| 912 | .is_some(); | 913 | .is_some(); |
| @@ -930,10 +931,7 @@ | |||
| 930 | fn bitrate_target_lands_within_5_percent_over_48_frames() { | 931 | fn bitrate_target_lands_within_5_percent_over_48_frames() { |
| 931 | let _knobs = crate::speed::knob_read(); | 932 | let _knobs = crate::speed::knob_read(); |
| 932 | let (width, height, frames) = (640usize, 384usize, 48usize); | 933 | let (width, height, frames) = (640usize, 384usize, 48usize); |
| 933 | - let Some(pictures) = h264_clip_frames_at(CLEAN_START, width, | 934 | + let Some(pictures) = h264_clip_frames_at(CLEAN_START, width, height, frames) else { |
| 934 | - height, | ||
| 935 | - frames, | ||
| 936 | - ) else { | ||
| 937 | return; | 935 | return; |
| 938 | }; | 936 | }; |
| 939 | let fps = 24.0; | 937 | let fps = 24.0; |
| @@ -965,9 +963,7 @@ | |||
| 965 | let worker = std::thread::spawn(move || { | 963 | let worker = std::thread::spawn(move || { |
| 966 | let mut enc = match pyramid { | 964 | let mut enc = match pyramid { |
| 967 | None => Av1Encoder::with_rate_target(config, rate).unwrap(), | 965 | None => Av1Encoder::with_rate_target(config, rate).unwrap(), |
| 968 | - Some(p) => { | 966 | + Some(p) => Av1Encoder::with_pyramid_and_rate_target(config, p, rate).unwrap(), |
| 969 | - Av1Encoder::with_pyramid_and_rate_target(config, p, rate).unwrap() | ||
| 970 | - } | ||
| 971 | }; | 967 | }; |
| 972 | let targets = enc.rate_loop.as_ref().unwrap().target; | 968 | let targets = enc.rate_loop.as_ref().unwrap().target; |
| 973 | let mut out = ArmResult { | 969 | let mut out = ArmResult { |
| @@ -1045,10 +1041,7 @@ | |||
| 1045 | #[test] | 1041 | #[test] |
| 1046 | fn bytes_per_frame_controller_never_oscillates_past_its_clamp() { | 1042 | fn bytes_per_frame_controller_never_oscillates_past_its_clamp() { |
| 1047 | let _knobs = crate::speed::knob_read(); | 1043 | let _knobs = crate::speed::knob_read(); |
| 1048 | - let Some(pictures) = h264_clip_frames(640, | 1044 | + let Some(pictures) = h264_clip_frames(640, 384, 24) else { |
| 1049 | - 384, | ||
| 1050 | - 24, | ||
| 1051 | - ) else { | ||
| 1052 | return; | 1045 | return; |
| 1053 | }; | 1046 | }; |
| 1054 | let config = EncoderConfig { | 1047 | let config = EncoderConfig { |
| @@ -1060,8 +1053,7 @@ | |||
| 1060 | tile_cols_log2: 0, | 1053 | tile_cols_log2: 0, |
| 1061 | tile_rows_log2: 0, | 1054 | tile_rows_log2: 0, |
| 1062 | }; | 1055 | }; |
| 1063 | - let mut enc = | 1056 | + let mut enc = Av1Encoder::with_rate_target(config, RateTarget::BytesPerFrame(4_000)).unwrap(); |
| 1064 | - Av1Encoder::with_rate_target(config, RateTarget::BytesPerFrame(4_000)).unwrap(); | ||
| 1065 | let mut prev_q = enc.rate_loop.as_ref().unwrap().q_idx(Level::Leaf); | 1057 | let mut prev_q = enc.rate_loop.as_ref().unwrap().q_idx(Level::Leaf); |
| 1066 | // The first frame this encoder EMITS is several `encode_frames` calls | 1058 | // The first frame this encoder EMITS is several `encode_frames` calls |
| 1067 | // in (the lookahead queue holds the earlier ones), so the seeding | 1059 | // in (the lookahead queue holds the earlier ones), so the seeding |
| @@ -1123,7 +1115,8 @@ | |||
| 1123 | let out = ec_testkit::ffmpeg() | 1115 | let out = ec_testkit::ffmpeg() |
| 1124 | .args(["-v", "error", "-f", "obu", "-i"]) | 1116 | .args(["-v", "error", "-f", "obu", "-i"]) |
| 1125 | .arg(&path) | 1117 | .arg(&path) |
| 1126 | - .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"]).output() | 1118 | + .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"]) |
| 1119 | + .output() | ||
| 1127 | .expect("ffmpeg failed to run"); | 1120 | .expect("ffmpeg failed to run"); |
| 1128 | let _ = std::fs::remove_file(&path); | 1121 | let _ = std::fs::remove_file(&path); |
| 1129 | assert!( | 1122 | assert!( |
| @@ -1932,68 +1925,6 @@ | |||
| 1932 | // the one that catches a tile boundary the writer respected and the | 1925 | // the one that catches a tile boundary the writer respected and the |
| 1933 | // spec does not, and the parser half catches the reverse. | 1926 | // spec does not, and the parser half catches the reverse. |
| 1934 | 1927 | ||
| 1935 | - /// A STATIC clip: every inter frame predicts perfectly from the last, so | ||
| 1936 | - /// the search takes the 64x64 root ([`crate::encode::B64_ROOT`]) instead | ||
| 1937 | - /// of coding four 32x32 quadrants, and the stream both decoders | ||
| 1938 | - /// reconstruct is still sample-exact against the encoder's own | ||
| 1939 | - /// reconstruction. The counter is the point (class | ||
| 1940 | - /// `gate-blind-to-feature`): without it a green three-way compare says | ||
| 1941 | - /// nothing about whether a single 64x64 block was ever written. | ||
| 1942 | - /// lane-sb128 step 1: the same static clip under a 128x128 SUPERBLOCK. | ||
| 1943 | - /// Every partition decision below the root is the one the 64-superblock | ||
| 1944 | - /// encoder makes -- the root itself is always `PARTITION_SPLIT` into the | ||
| 1945 | - /// four 64x64 superblocks -- so the only thing this proves is the | ||
| 1946 | - /// structural syntax: the root's own partition symbol, its loop | ||
| 1947 | - /// restoration read once over the 128 span at the 128 unit size, and | ||
| 1948 | - /// libaom's TL/TR/BL/BR visit order. 256x128 is 2x1 128x128 superblocks | ||
| 1949 | - /// per frame over three frames, so the root fires 6 times. | ||
| 1950 | - /// | ||
| 1951 | - /// `#[ignore]`: [`crate::encode::force_sb128`] moves a process-global | ||
| 1952 | - /// (the superblock size is a sequence field), so this gate runs alone: | ||
| 1953 | - /// | ||
| 1954 | - /// Runs only inside `superblock_size_global_suite`. | ||
| 1955 | - pub(crate) fn a_static_clip_codes_128x128_superblock_roots_and_decodes_sample_exact() { | ||
| 1956 | - let _knobs = crate::speed::knob_write(); | ||
| 1957 | - crate::encode::force_sb128(true); | ||
| 1958 | - let (width, height) = (256usize, 128usize); | ||
| 1959 | - let still = test_card(width, height, 0); | ||
| 1960 | - let sources: Vec<Picture> = (0..3).map(|_| still.clone()).collect(); | ||
| 1961 | - let config = EncoderConfig { | ||
| 1962 | - width, | ||
| 1963 | - height, | ||
| 1964 | - base_q_idx: 120, | ||
| 1965 | - gop: 8, | ||
| 1966 | - colour: Colour::Bt709Limited, | ||
| 1967 | - tile_cols_log2: 0, | ||
| 1968 | - tile_rows_log2: 0, | ||
| 1969 | - }; | ||
| 1970 | - let mut enc = Av1Encoder::new(config).unwrap(); | ||
| 1971 | - let mut stream = Vec::new(); | ||
| 1972 | - let _ = crate::tile::take_sb128_root_hits(); | ||
| 1973 | - for packet in encode_all(&mut enc, &sources) { | ||
| 1974 | - stream.extend_from_slice(&packet.data); | ||
| 1975 | - } | ||
| 1976 | - let roots = crate::tile::take_sb128_root_hits(); | ||
| 1977 | - assert!( | ||
| 1978 | - roots >= 4, | ||
| 1979 | - "a 128x128-superblock clip coded {roots} superblock roots, wanted at least 4" | ||
| 1980 | - ); | ||
| 1981 | - eprintln!("128x128 superblock roots: {roots}"); | ||
| 1982 | - | ||
| 1983 | - let ours = crate::stream::decode_stream(&stream).expect("our decoder"); | ||
| 1984 | - assert_eq!(ours.len(), sources.len(), "our decoder's frames"); | ||
| 1985 | - assert!( | ||
| 1986 | - crate::decode::part128_split_hits() >= 4, | ||
| 1987 | - "our decoder read no 128x128 superblock root" | ||
| 1988 | - ); | ||
| 1989 | - let theirs = ffmpeg_decode_luma(&stream, width, height); | ||
| 1990 | - assert_eq!(theirs.len(), sources.len(), "ffmpeg's frames"); | ||
| 1991 | - for (i, (a, b)) in ours.iter().zip(&theirs).enumerate() { | ||
| 1992 | - let got: Vec<u8> = a.y.iter().map(|&v| v as u8).collect(); | ||
| 1993 | - assert_eq!(&got, b, "frame {i}: ffmpeg and our decoder disagree"); | ||
| 1994 | - } | ||
| 1995 | - } | ||
| 1996 | - | ||
| 1997 | #[test] | 1928 | #[test] |
| 1998 | fn a_static_clip_codes_64x64_roots_and_decodes_sample_exact() { | 1929 | fn a_static_clip_codes_64x64_roots_and_decodes_sample_exact() { |
| 1999 | let _knobs = crate::speed::knob_write(); | 1930 | let _knobs = crate::speed::knob_write(); |
| @@ -2501,23 +2432,10 @@ | |||
| 2501 | tile_rows_log2: 0, | 2432 | tile_rows_log2: 0, |
| 2502 | }; | 2433 | }; |
| 2503 | let mut enc = Av1Encoder::new(config).unwrap(); | 2434 | let mut enc = Av1Encoder::new(config).unwrap(); |
| 2504 | - let _ = crate::encode::take_deltaq_levels(); | ||
| 2505 | let mut stream = Vec::new(); | 2435 | let mut stream = Vec::new(); |
| 2506 | for packet in encode_all(&mut enc, &sources) { | 2436 | for packet in encode_all(&mut enc, &sources) { |
| 2507 | stream.extend_from_slice(&packet.data); | 2437 | stream.extend_from_slice(&packet.data); |
| 2508 | } | 2438 | } |
| 2509 | - let levels = crate::encode::take_deltaq_levels(); | ||
| 2510 | - // The quantizer grid rides the tpl map, and `speed::TPL_DEPTH` cuts | ||
| 2511 | - // the lookahead window to one picture at the top presets, so there IS | ||
| 2512 | - // no map -- and no delta_q syntax -- there. The exactness half below | ||
| 2513 | - // still runs; only the fire count needs a window (lane-tplwin: the | ||
| 2514 | - // predicate is the window, not preset 0, since presets 1..6 have one). | ||
| 2515 | - if crate::speed::at(&crate::speed::TPL_DEPTH) > 1 { | ||
| 2516 | - assert!( | ||
| 2517 | - levels >= 2, | ||
| 2518 | - "the quantizer grid was flat ({levels} level(s)): no delta_qindex was coded" | ||
| 2519 | - ); | ||
| 2520 | - } | ||
| 2521 | let ours = crate::stream::decode_stream(&stream).expect("our decoder"); | 2439 | let ours = crate::stream::decode_stream(&stream).expect("our decoder"); |
| 2522 | assert_eq!(ours.len(), sources.len(), "our decoder's frames"); | 2440 | assert_eq!(ours.len(), sources.len(), "our decoder's frames"); |
| 2523 | { | 2441 | { |
| @@ -2544,10 +2462,6 @@ | |||
| 2544 | } | 2462 | } |
| 2545 | } | 2463 | } |
| 2546 | crate::encode::set_deltaq_res(None); | 2464 | crate::encode::set_deltaq_res(None); |
| 2547 | - eprintln!( | ||
| 2548 | - "delta_q witness: {levels} quantizer levels, {} bytes", | ||
| 2549 | - stream.len() | ||
| 2550 | - ); | ||
| 2551 | } | 2465 | } |
| 2552 | 2466 | ||
| 2553 | /// lane-txset's witness: a clip of hard directional edges makes the intra | 2467 | /// lane-txset's witness: a clip of hard directional edges makes the intra |
| @@ -2970,140 +2884,6 @@ | |||
| 2970 | } | 2884 | } |
| 2971 | } | 2885 | } |
| 2972 | 2886 | ||
| 2973 | - /// Every SHIPPED SPEED PRESET codes a stream both decoders reconstruct | ||
| 2974 | - /// sample-exact -- ours and ffmpeg's -- and codes a DIFFERENT stream from | ||
| 2975 | - /// its neighbour (a preset that changes no byte is a preset that buys no | ||
| 2976 | - /// wall: class `gate-blind-to-feature`). Preset 0's bytes are the | ||
| 2977 | - /// full-search ones, which is the cheap in-suite statement of the byte | ||
| 2978 | - /// pins' rule. | ||
| 2979 | - /// | ||
| 2980 | - /// Ignored by default because the preset is PROCESS-GLOBAL | ||
| 2981 | - /// ([`crate::speed`]): flipping it while the suite's other tests encode | ||
| 2982 | - /// in parallel would move their bytes under them. Run it on its own: | ||
| 2983 | - /// `cargo test -p ec-av1 --release -- --ignored every_speed_preset`. | ||
| 2984 | - #[test] | ||
| 2985 | - #[ignore = "sets the process-global speed preset: run it alone"] | ||
| 2986 | - fn every_speed_preset_decodes_sample_exact_through_both_decoders() { | ||
| 2987 | - let _knobs = crate::speed::knob_write(); | ||
| 2988 | - let (width, height) = (640usize, 384usize); | ||
| 2989 | - let sources: Vec<Picture> = (0..4).map(|t| test_card(width, height, t * 3)).collect(); | ||
| 2990 | - let mut sizes: Vec<(u8, usize)> = Vec::new(); | ||
| 2991 | - for speed in [0u8, 3, 6, 10] { | ||
| 2992 | - let config = EncoderConfig { | ||
| 2993 | - width, | ||
| 2994 | - height, | ||
| 2995 | - base_q_idx: 120, | ||
| 2996 | - gop: 4, | ||
| 2997 | - colour: Colour::Bt709Limited, | ||
| 2998 | - tile_cols_log2: 1, | ||
| 2999 | - tile_rows_log2: 0, | ||
| 3000 | - }; | ||
| 3001 | - let mut enc = Av1Encoder::with_speed(config, speed).unwrap(); | ||
| 3002 | - let mut stream = Vec::new(); | ||
| 3003 | - for packet in encode_all(&mut enc, &sources) { | ||
| 3004 | - stream.extend_from_slice(&packet.data); | ||
| 3005 | - } | ||
| 3006 | - let ours = crate::stream::decode_stream(&stream).expect("our decoder"); | ||
| 3007 | - assert_eq!( | ||
| 3008 | - ours.len(), | ||
| 3009 | - sources.len(), | ||
| 3010 | - "speed {speed}: our decoder's frames" | ||
| 3011 | - ); | ||
| 3012 | - { | ||
| 3013 | - let theirs = ffmpeg_decode_luma(&stream, width, height); | ||
| 3014 | - assert_eq!( | ||
| 3015 | - theirs.len(), | ||
| 3016 | - sources.len(), | ||
| 3017 | - "speed {speed}: ffmpeg's frames" | ||
| 3018 | - ); | ||
| 3019 | - for (i, (a, b)) in ours.iter().zip(&theirs).enumerate() { | ||
| 3020 | - let got: Vec<u8> = a.y.iter().map(|&v| v as u8).collect(); | ||
| 3021 | - if let Some(at) = got.iter().zip(b).position(|(x, y)| x != y) { | ||
| 3022 | - panic!( | ||
| 3023 | - "speed {speed} frame {i}: luma differs first at ({}, {}): \ | ||
| 3024 | - ours {} vs ffmpeg {}", | ||
| 3025 | - at % width, | ||
| 3026 | - at / width, | ||
| 3027 | - got[at], | ||
| 3028 | - b[at], | ||
| 3029 | - ); | ||
| 3030 | - } | ||
| 3031 | - assert_eq!( | ||
| 3032 | - got.len(), | ||
| 3033 | - b.len(), | ||
| 3034 | - "speed {speed} frame {i}: luma is {} samples, ffmpeg's is {}", | ||
| 3035 | - got.len(), | ||
| 3036 | - b.len() | ||
| 3037 | - ); | ||
| 3038 | - } | ||
| 3039 | - } | ||
| 3040 | - eprintln!( | ||
| 3041 | - "speed {speed}: {} bytes [{}]", | ||
| 3042 | - stream.len(), | ||
| 3043 | - crate::speed::levers(speed).join(", ") | ||
| 3044 | - ); | ||
| 3045 | - sizes.push((speed, stream.len())); | ||
| 3046 | - } | ||
| 3047 | - crate::speed::set_speed(0); | ||
| 3048 | - for w in sizes.windows(2) { | ||
| 3049 | - assert_ne!( | ||
| 3050 | - w[0].1, w[1].1, | ||
| 3051 | - "speed {} and {} coded the same bytes: the preset changed no decision", | ||
| 3052 | - w[0].0, w[1].0 | ||
| 3053 | - ); | ||
| 3054 | - } | ||
| 3055 | - } | ||
| 3056 | - | ||
| 3057 | - /// What tiles and tile threads are worth at the size the editor exports | ||
| 3058 | - /// at: 1920x1080, eight real pictures, two passes per cell (ABAB), wall | ||
| 3059 | - /// per cell. Ignored by default (minutes). | ||
| 3060 | - #[test] | ||
| 3061 | - #[ignore = "wall table, 16 cells x 2 passes at 1080p: 27 min measured; needs a host with >=8 cores"] | ||
| 3062 | - fn tile_wall_table_at_1080p() { | ||
| 3063 | - let _knobs = crate::speed::knob_write(); | ||
| 3064 | - let (width, height) = (1920usize, 1080usize); | ||
| 3065 | - let Some(sources) = h264_clip_frames(width, height, 8) else { | ||
| 3066 | - return; | ||
| 3067 | - }; | ||
| 3068 | - let layouts = [(0u32, 0u32), (1, 0), (1, 1), (2, 1)]; | ||
| 3069 | - let threadings = [1usize, 2, 4, 8]; | ||
| 3070 | - let mut table: Vec<(String, usize, f64, usize)> = Vec::new(); | ||
| 3071 | - for pass in 0..2 { | ||
| 3072 | - for &(cols_log2, rows_log2) in &layouts { | ||
| 3073 | - for &threads in &threadings { | ||
| 3074 | - crate::par::set_tile_threads(threads); | ||
| 3075 | - let config = EncoderConfig { | ||
| 3076 | - width, | ||
| 3077 | - height, | ||
| 3078 | - base_q_idx: 120, | ||
| 3079 | - gop: 8, | ||
| 3080 | - colour: Colour::Bt709Limited, | ||
| 3081 | - tile_cols_log2: cols_log2, | ||
| 3082 | - tile_rows_log2: rows_log2, | ||
| 3083 | - }; | ||
| 3084 | - let mut enc = Av1Encoder::new(config).unwrap(); | ||
| 3085 | - let start = std::time::Instant::now(); | ||
| 3086 | - let mut bytes = 0usize; | ||
| 3087 | - for packet in encode_all(&mut enc, &sources) { | ||
| 3088 | - bytes += packet.data.len(); | ||
| 3089 | - } | ||
| 3090 | - let wall = start.elapsed().as_secs_f64(); | ||
| 3091 | - let name = format!("{}x{}", 1 << cols_log2, 1 << rows_log2); | ||
| 3092 | - match table.iter_mut().find(|r| r.0 == name && r.1 == threads) { | ||
| 3093 | - Some(row) => row.2 = row.2.min(wall), | ||
| 3094 | - None => table.push((name, threads, wall, bytes)), | ||
| 3095 | - } | ||
| 3096 | - let _ = pass; | ||
| 3097 | - } | ||
| 3098 | - } | ||
| 3099 | - } | ||
| 3100 | - crate::par::set_tile_threads(1); | ||
| 3101 | - eprintln!("| tiles | threads | wall (s, best of 2) | bytes |"); | ||
| 3102 | - for (name, threads, wall, bytes) in &table { | ||
| 3103 | - eprintln!("| {name} | {threads} | {wall:.2} | {bytes} |"); | ||
| 3104 | - } | ||
| 3105 | - } | ||
| 3106 | - | ||
| 3107 | /// The tiles of a frame are entropy-independent, so the bytes must not | 2887 | /// The tiles of a frame are entropy-independent, so the bytes must not |
| 3108 | /// depend on how many workers wrote them: the same stream at one tile | 2888 | /// depend on how many workers wrote them: the same stream at one tile |
| 3109 | /// thread and at four, per layout. | 2889 | /// thread and at four, per layout. |
| @@ -3146,42 +2926,6 @@ | |||
| 3146 | crate::par::set_tile_threads(1); | 2926 | crate::par::set_tile_threads(1); |
| 3147 | } | 2927 | } |
| 3148 | 2928 | ||
| 3149 | - /// What the per-tile search (lane-av1tsearch) is worth in wall and in | ||
| 3150 | - /// frames per second at the editor's own export sizes: every tile layout | ||
| 3151 | - /// crossed with every tile-thread count, plus librav1e at the matching | ||
| 3152 | - /// `tile_cols`/`tile_rows`/`threads` as the reference point. Two passes | ||
| 3153 | - /// over the whole table (A,B,A,B... rather than AA,BB) with the best of | ||
| 3154 | - /// the two kept, so a thermal drift cannot order the rows. | ||
| 3155 | - /// | ||
| 3156 | - /// Measurement, not a pass/fail gate: it asserts only that every cell | ||
| 3157 | - /// produced a stream. | ||
| 3158 | - #[test] | ||
| 3159 | - // MEASURED 1243 s in release on a 12-core workstation. A 4-core server | ||
| 3160 | - // cannot finish it at all: the same run TIMED OUT at 2400 s there | ||
| 3161 | - // (12 frames x 2 passes x 12 cells), so the 8- and 12-thread rows are | ||
| 3162 | - // only meaningful on a host with the cores to run them. Do not schedule | ||
| 3163 | - // it on a 4-core fleet box. | ||
| 3164 | - #[ignore = "wall measurement: 20 min at 1080p and it TIMES OUT on a 4-core host -- run it on >=8 cores"] | ||
| 3165 | - fn tile_search_wall_1080p() { | ||
| 3166 | - let _knobs = crate::speed::knob_write(); | ||
| 3167 | - tile_search_wall( | ||
| 3168 | - 1920, | ||
| 3169 | - 1080, | ||
| 3170 | - 12, | ||
| 3171 | - &[(0, 0), (1, 0), (1, 1), (2, 1)], | ||
| 3172 | - &[1, 2, 4, 8], | ||
| 3173 | - ); | ||
| 3174 | - } | ||
| 3175 | - | ||
| 3176 | - /// The same table at the 4K frame size the editor exports (3840x1608), | ||
| 3177 | - /// at the two layouts with enough tiles to fill this box. | ||
| 3178 | - #[test] | ||
| 3179 | - #[ignore = "wall measurement: 12 min at 4K (732 s measured); run it with --ignored --nocapture"] | ||
| 3180 | - fn tile_search_wall_4k() { | ||
| 3181 | - let _knobs = crate::speed::knob_write(); | ||
| 3182 | - tile_search_wall(3840, 1608, 6, &[(2, 1), (3, 2)], &[1, 8, 12]); | ||
| 3183 | - } | ||
| 3184 | - | ||
| 3185 | /// lane-av1fpar: the frame-level FILTER stage is banded across the same | 2929 | /// lane-av1fpar: the frame-level FILTER stage is banded across the same |
| 3186 | /// workers the tile search uses (`par::override_filter_threads`), so the | 2930 | /// workers the tile search uses (`par::override_filter_threads`), so the |
| 3187 | /// deblock/CDEF replays, the per-64 SSE and the plane copies all run in | 2931 | /// deblock/CDEF replays, the per-64 SSE and the plane copies all run in |
| @@ -3308,271 +3052,6 @@ | |||
| 3308 | crate::decode::set_verify_final_replay(false); | 3052 | crate::decode::set_verify_final_replay(false); |
| 3309 | } | 3053 | } |
| 3310 | 3054 | ||
| 3311 | - /// lane-av1fpar: where a frame's wall actually goes, stage by stage -- | ||
| 3312 | - /// the per-tile search, the tile write, the frame-level filter search | ||
| 3313 | - /// (with its deblock/CDEF replay and per-64 SSE inside it), the capture | ||
| 3314 | - /// decode the loop-restoration search rides on, and that search itself. | ||
| 3315 | - /// Measurement, not a pass/fail gate. | ||
| 3316 | - #[test] | ||
| 3317 | - #[ignore = "wall measurement: 36 s at 1080p; run it with --ignored --nocapture"] | ||
| 3318 | - fn filter_stage_wall_1080p() { | ||
| 3319 | - let _knobs = crate::speed::knob_write(); | ||
| 3320 | - filter_stage_wall(1920, 1080, 8, (2, 1), &[8]); | ||
| 3321 | - } | ||
| 3322 | - | ||
| 3323 | - #[test] | ||
| 3324 | - #[ignore = "wall measurement: 62 s at 4K; run it with --ignored --nocapture"] | ||
| 3325 | - fn filter_stage_wall_4k() { | ||
| 3326 | - let _knobs = crate::speed::knob_write(); | ||
| 3327 | - filter_stage_wall(3840, 1608, 4, (2, 1), &[8, 12]); | ||
| 3328 | - } | ||
| 3329 | - | ||
| 3330 | - /// The same breakdown at the real films' own crop size. With | ||
| 3331 | - /// `EC_AV1_WALL_CLIP` pointing at a film window this is the film row; with | ||
| 3332 | - /// it unset it is the colour-bar fixture at the same size, which is what | ||
| 3333 | - /// makes the pair a comparison rather than a number. | ||
| 3334 | - #[test] | ||
| 3335 | - // MEASURED 16 s WITHOUT `EC_AV1_WALL_CLIP`, and what it measures then is | ||
| 3336 | - // the COLOUR-BAR fixture, not a film: `h264_clip_frames` falls back to | ||
| 3337 | - // `fixtures/video/h264-1080p-23.976-8bit.mp4` when the var is unset. A | ||
| 3338 | - // reader who takes the name for the content reads a bars number as a | ||
| 3339 | - // film number, so the precondition belongs in the reason. | ||
| 3340 | - #[ignore = "wall measurement: 16 s; MEASURES THE BARS FIXTURE unless EC_AV1_WALL_CLIP names a real film window"] | ||
| 3341 | - fn filter_stage_wall_film() { | ||
| 3342 | - let _knobs = crate::speed::knob_write(); | ||
| 3343 | - filter_stage_wall(1920, 768, 4, (2, 1), &[8]); | ||
| 3344 | - } | ||
| 3345 | - | ||
| 3346 | - fn filter_stage_wall( | ||
| 3347 | - width: usize, | ||
| 3348 | - height: usize, | ||
| 3349 | - frames: usize, | ||
| 3350 | - (cols_log2, rows_log2): (u32, u32), | ||
| 3351 | - threads: &[usize], | ||
| 3352 | - ) { | ||
| 3353 | - let Some(sources) = h264_clip_frames(width, height, frames) | ||
| 3354 | - else { | ||
| 3355 | - return; | ||
| 3356 | - }; | ||
| 3357 | - crate::par::set_stage_times(true); | ||
| 3358 | - for &t in threads { | ||
| 3359 | - crate::par::set_tile_threads(t); | ||
| 3360 | - let config = EncoderConfig { | ||
| 3361 | - width, | ||
| 3362 | - height, | ||
| 3363 | - base_q_idx: 120, | ||
| 3364 | - gop: frames, | ||
| 3365 | - colour: Colour::Bt709Limited, | ||
| 3366 | - tile_cols_log2: cols_log2, | ||
| 3367 | - tile_rows_log2: rows_log2, | ||
| 3368 | - }; | ||
| 3369 | - let mut enc = Av1Encoder::new(config).unwrap(); | ||
| 3370 | - let _ = crate::par::take_stage_ns(); | ||
| 3371 | - let start = std::time::Instant::now(); | ||
| 3372 | - for packet in encode_all(&mut enc, &sources) { | ||
| 3373 | - assert!(!packet.data.is_empty()); | ||
| 3374 | - } | ||
| 3375 | - let wall = start.elapsed().as_secs_f64(); | ||
| 3376 | - let ns = crate::par::take_stage_ns(); | ||
| 3377 | - let ms = |i: usize| ns[i] as f64 / 1e6; | ||
| 3378 | - eprintln!( | ||
| 3379 | - "\n{width}x{height}, {frames} frames, {}x{} tiles, {t} tile threads: \ | ||
| 3380 | - {wall:.2}s wall, {:.2} fps", | ||
| 3381 | - 1 << cols_log2, | ||
| 3382 | - 1 << rows_log2, | ||
| 3383 | - frames as f64 / wall, | ||
| 3384 | - ); | ||
| 3385 | - eprintln!("| stage | ms | ms/frame | % of wall |"); | ||
| 3386 | - for (i, name) in crate::par::STAGES.iter().enumerate() { | ||
| 3387 | - eprintln!( | ||
| 3388 | - "| {name} | {:.0} | {:.1} | {:.1}% |", | ||
| 3389 | - ms(i), | ||
| 3390 | - ms(i) / frames as f64, | ||
| 3391 | - 100.0 * ms(i) / (wall * 1e3), | ||
| 3392 | - ); | ||
| 3393 | - } | ||
| 3394 | - // Top-level stages only (the deblock/CDEF/SSE rows are inside | ||
| 3395 | - // the filter-search total); the rest is per-frame setup, the | ||
| 3396 | - // source conversion and the splice. | ||
| 3397 | - let top: f64 = [ | ||
| 3398 | - crate::par::S_TILE_SEARCH, | ||
| 3399 | - crate::par::S_TILE_WRITE, | ||
| 3400 | - crate::par::S_FILTER, | ||
crates/ec-av1/src/film_grain.rsmodified+10 -46
Diff too large; view file
crates/ec-av1/src/hits.rsdeleted+0 -47
Diff too large; view file
crates/ec-av1/src/intra.rsmodified+53 -47
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+17 -57
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