forge
Explore
Log in

Don't you dare go Hollow

U3: delete the syntax census (census.rs, its example and its call sites in decode, msac, stream); no output path reads it

Browse files at this commit

94ba585cb5daea184059207b0d5715fc0a514199Ahmet Kaan GümüşParent: a9468ad
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/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/coeffs.rsmodified+0 -8
@@ -192,7 +192,6 @@ pub(super) fn read_coeffs(
192 }192 }
193 crate::msac::SymbolDecoder::set_symr_cdf("tx_type");193 crate::msac::SymbolDecoder::set_symr_cdf("tx_type");
194 let t = dec.symbol(tx_type_cdf);194 let t = dec.symbol(tx_type_cdf);
195- crate::census::tx_type(len, t);
196 if coeff_trace_on() {195 if coeff_trace_on() {
197 let (rng, _) = dec.debug_state();196 let (rng, _) = dec.debug_state();
198 eprintln!("EC_COEFF_STEP tag=tx_type len={len} rng={rng}");197 eprintln!("EC_COEFF_STEP tag=tx_type len={len} rng={rng}");
@@ -477,7 +476,6 @@ pub(super) fn read_coeffs_rect(
477 if let Some(tx_type_cdf) = coding.tx_type.as_deref_mut() {476 if let Some(tx_type_cdf) = coding.tx_type.as_deref_mut() {
478 let len = tx_type_cdf.len();477 let len = tx_type_cdf.len();
479 let t = dec.symbol(tx_type_cdf);478 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(|| {479 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}"))480 unsupported(format!("a tx_type symbol outside its CDF's own set: {t}"))
483 })?;481 })?;
@@ -1638,7 +1636,6 @@ impl Neighbours {
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}"1636 "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 );1637 );
1640 }1638 }
1641- crate::census::tx(tx_px, tx_h_px);
1642 let cur = fctx.current_delta_lf.with(|c| c.get());1639 let cur = fctx.current_delta_lf.with(|c| c.get());
1643 let snapshot: [i8; 4] = if fctx.delta_lf_multi.with(|c| c.get()) {1640 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)1641 std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8)
@@ -1753,9 +1750,6 @@ impl Neighbours {
1753 if skip && w_mi != h_mi {1750 if skip && w_mi != h_mi {
1754 hit!(RECT_SKIP_BAND_HITS);1751 hit!(RECT_SKIP_BAND_HITS);
1755 }1752 }
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 {1753 for rr in 0..h_mi {
1760 let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c;1754 let start = (mi_r + rr) * self.skip_grid_cols_mi + mi_c;
1761 fill_span(1755 fill_span(
@@ -1971,7 +1965,6 @@ impl Neighbours {
1971 skip_mode: bool,1965 skip_mode: bool,
1972 ) {1966 ) {
1973 let (r, c) = at_mi;1967 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 NOBODY1968 // 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 mode1969 // 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`1970 // map untouched, so a later intra block's `get_intra_edge_filter_type`
@@ -2077,7 +2070,6 @@ impl Neighbours {
2077 compound_idx: u8,2070 compound_idx: u8,
2078 ) {2071 ) {
2079 let (r, c) = at_mi;2072 let (r, c) = at_mi;
2080- crate::census::compound();
2081 for cell in 0..w_mi {2073 for cell in 0..w_mi {
2082 self.above_ref1[c + cell] = Some(ref1);2074 self.above_ref1[c + cell] = Some(ref1);
2083 self.above_comp_group_idx[c + cell] = comp_group_idx;2075 self.above_comp_group_idx[c + cell] = comp_group_idx;
crates/ec-av1/src/decode/frame_tile.rsmodified+0 -1
@@ -542,7 +542,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
542 // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets542 // 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.543 // it codes every symbol against the tables it started with.
544 dec.set_cdf_update(!cdf_update_disabled(fctx));544 dec.set_cdf_update(!cdf_update_disabled(fctx));
545- crate::census::register_cdfs(&cdfs);
546 // lane-comppin r9: tile-entry range, the earliest point comparable545 // lane-comppin r9: tile-entry range, the earliest point comparable
547 // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the546 // 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.547 // first ladder rung before any symbol (partition or otherwise) is read.
crates/ec-av1/src/decode/inter_block.rsmodified+0 -3
@@ -2246,7 +2246,6 @@ pub(super) fn decode_inter_block(
2246 );2246 );
2247 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;2247 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
2248 if !not_new {2248 if !not_new {
2249- crate::census::mode(0);
2250 }2249 }
2251 let mut is_globalmv = false;2250 let mut is_globalmv = false;
2252 // lane-interbis r1: which single-ref mode this block resolved to,2251 // lane-interbis r1: which single-ref mode this block resolved to,
@@ -2283,7 +2282,6 @@ pub(super) fn decode_inter_block(
2283 } else {2282 } else {
2284 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;2283 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
2285 if !not_zero {2284 if !not_zero {
2286- crate::census::mode(1);
2287 }2285 }
2288 is_globalmv = !not_zero;2286 is_globalmv = !not_zero;
2289 let mv = if !not_zero {2287 let mv = if !not_zero {
@@ -2293,7 +2291,6 @@ pub(super) fn decode_inter_block(
2293 gm_table[(ref_frame - LAST_FRAME) as usize]2291 gm_table[(ref_frame - LAST_FRAME) as usize]
2294 } else {2292 } else {
2295 let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;2293 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 };2294 dbg_mode = if nearest { 13 } else { 14 };
2298 if nearest {2295 if nearest {
2299 stack.nearest_mv2296 stack.nearest_mv
crates/ec-av1/src/decode/inter_block8.rsmodified+0 -3
@@ -1419,7 +1419,6 @@ pub(super) fn decode_inter_block8(
1419 1419
1420 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;1420 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
1421 if !not_new {1421 if !not_new {
1422- crate::census::mode(0);
1423 }1422 }
1424 let mut is_globalmv = false;1423 let mut is_globalmv = false;
1425 let (mv, is_new_mv) = if !not_new {1424 let (mv, is_new_mv) = if !not_new {
@@ -1452,7 +1451,6 @@ pub(super) fn decode_inter_block8(
1452 } else {1451 } else {
1453 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;1452 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
1454 if !not_zero {1453 if !not_zero {
1455- crate::census::mode(1);
1456 }1454 }
1457 is_globalmv = !not_zero;1455 is_globalmv = !not_zero;
1458 let mv = if !not_zero {1456 let mv = if !not_zero {
@@ -1463,7 +1461,6 @@ pub(super) fn decode_inter_block8(
1463 gm_table[(ref_frame - LAST_FRAME) as usize]1461 gm_table[(ref_frame - LAST_FRAME) as usize]
1464 } else {1462 } else {
1465 let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;1463 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 {1464 if nearest {
1468 stack.nearest_mv1465 stack.nearest_mv
1469 } else {1466 } else {
crates/ec-av1/src/decode/inter_ctx.rsmodified+0 -1
@@ -227,7 +227,6 @@ pub(super) fn read_mv(
227 mv.1.clamp(-MV_LIMIT + 1, MV_LIMIT - 1),227 mv.1.clamp(-MV_LIMIT + 1, MV_LIMIT - 1),
228 );228 );
229 }229 }
230- crate::census::mv(mv.0, mv.1);
231 mv230 mv
232 }231 }
233 232
crates/ec-av1/src/decode/key_tile.rsmodified+0 -1
@@ -614,7 +614,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
614 // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets614 // 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.615 // it codes every symbol against the tables it started with.
616 dec.set_cdf_update(!cdf_update_disabled(fctx));616 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);617 neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize, fctx);
619 y.set_tile_origin(618 y.set_tile_origin(
620 mi_col0 as usize * 4,619 mi_col0 as usize * 4,
crates/ec-av1/src/decode/sub8_inter.rsmodified+0 -6
@@ -246,7 +246,6 @@ pub(super) fn decode_inter_sub8_split4(
246 );246 );
247 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;247 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
248 if !not_new {248 if !not_new {
249- crate::census::mode(0);
250 }249 }
251 let mut is_globalmv = false;250 let mut is_globalmv = false;
252 let (mv, is_new_mv) = if !not_new {251 let (mv, is_new_mv) = if !not_new {
@@ -273,14 +272,12 @@ pub(super) fn decode_inter_sub8_split4(
273 } else {272 } else {
274 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;273 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
275 if !not_zero {274 if !not_zero {
276- crate::census::mode(1);
277 }275 }
278 is_globalmv = !not_zero;276 is_globalmv = !not_zero;
279 let mv = if !not_zero {277 let mv = if !not_zero {
280 gm_table[(ref_frame - LAST_FRAME) as usize]278 gm_table[(ref_frame - LAST_FRAME) as usize]
281 } else {279 } else {
282 let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;280 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 {281 if nearest {
285 stack.nearest_mv282 stack.nearest_mv
286 } else {283 } else {
@@ -2195,7 +2192,6 @@ pub(super) fn decode_inter_sub8_rect2(
2195 );2192 );
2196 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;2193 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
2197 if !not_new {2194 if !not_new {
2198- crate::census::mode(0);
2199 }2195 }
2200 let mut is_globalmv = false;2196 let mut is_globalmv = false;
2201 let (mv, is_new_mv) = if !not_new {2197 let (mv, is_new_mv) = if !not_new {
@@ -2222,14 +2218,12 @@ pub(super) fn decode_inter_sub8_rect2(
2222 } else {2218 } else {
2223 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;2219 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
2224 if !not_zero {2220 if !not_zero {
2225- crate::census::mode(1);
2226 }2221 }
2227 is_globalmv = !not_zero;2222 is_globalmv = !not_zero;
2228 let mv = if !not_zero {2223 let mv = if !not_zero {
2229 gm_table[(ref_frame - LAST_FRAME) as usize]2224 gm_table[(ref_frame - LAST_FRAME) as usize]
2230 } else {2225 } else {
2231 let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;2226 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 {2227 if nearest {
2234 stack.nearest_mv2228 stack.nearest_mv
2235 } else {2229 } else {
crates/ec-av1/src/lib.rsmodified+0 -1
@@ -24,7 +24,6 @@ pub mod bits;
24 mod autothreads;24 mod autothreads;
25 pub mod cdf;25 pub mod cdf;
26 mod cdf_state;26 mod cdf_state;
27-pub mod census;
28 mod compound;27 mod compound;
29 pub mod decode;28 pub mod decode;
30 pub mod encode;29 pub mod encode;
crates/ec-av1/src/msac.rsmodified+0 -15
@@ -458,15 +458,6 @@ impl<'a> SymbolDecoder<'a> {
458 let symr = crate::envflags::env_flag!("EC_SYMR");458 let symr = crate::envflags::env_flag!("EC_SYMR");
459 let (pre_value, pre_range, pre_bit) = (self.value, self.range, self.bit);459 let (pre_value, pre_range, pre_bit) = (self.value, self.range, self.bit);
460 let pre_cdf0 = cdf.first().copied().unwrap_or(0);460 let pre_cdf0 = cdf.first().copied().unwrap_or(0);
461- // lane-census: the syntax census charges this symbol's bits to the
462- // TABLE it read, so every coding tool is accounted without a
463- // per-call-site label. Off (`EC_AV1_BITCENSUS` unset) this is one
464- // relaxed load.
465- let t0 = if crate::census::armed() {
466- self.tell_bits()
467- } else {
468- 0.0
469- };
470 let s = self.symbol_fixed(cdf);461 let s = self.symbol_fixed(cdf);
471 // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets462 // lane-av1txr: spec 5.9.2's `disable_cdf_update` -- a frame that sets
472 // it codes every symbol against the tables it started with, so this463 // it codes every symbol against the tables it started with, so this
@@ -476,9 +467,6 @@ impl<'a> SymbolDecoder<'a> {
476 if self.adapt {467 if self.adapt {
477 update_cdf(cdf, s);468 update_cdf(cdf, s);
478 }469 }
479- if crate::census::armed() {
480- crate::census::charge(cdf.as_ptr() as usize, self.tell_bits() - t0);
481- }
482 if symr {470 if symr {
483 eprintln!(471 eprintln!(
484 "EC_SYMR ph={} cdf={} mi=({},{}) pre=({},{},{}) cdf0={} n={} s={} post_rng={}",472 "EC_SYMR ph={} cdf={} mi=({},{}) pre=({},{},{}) cdf0={} n={} s={} post_rng={}",
@@ -605,9 +593,6 @@ impl<'a> SymbolDecoder<'a> {
605 /// the coefficient sign pass and the Golomb tail read one bit at a time.593 /// the coefficient sign pass and the Golomb tail read one bit at a time.
606 #[inline]594 #[inline]
607 pub fn literal(&mut self, bits: u32) -> u32 {595 pub fn literal(&mut self, bits: u32) -> u32 {
608- if crate::census::armed() {
609- crate::census::charge_literal(bits);
610- }
611 let mut v = 0;596 let mut v = 0;
612 for _ in 0..bits {597 for _ in 0..bits {
613 // `EQUIPROBABLE`'s single boundary: `f >> EC_PROB_SHIFT` is 256, so598 // `EQUIPROBABLE`'s single boundary: `f >> EC_PROB_SHIFT` is 256, so
crates/ec-av1/src/stream/mod.rsmodified+0 -1
@@ -1884,7 +1884,6 @@ fn decode_frame(
1884 // lane-twostage: see `decode_inter_frame_tile_with_cdfs`'s own `stage1`.1884 // lane-twostage: see `decode_inter_frame_tile_with_cdfs`'s own `stage1`.
1885 stage1: Option<&dyn Fn(Cdfs, crate::motion_field::MotionField, usize, usize)>,1885 stage1: Option<&dyn Fn(Cdfs, crate::motion_field::MotionField, usize, usize)>,
1886 ) -> Result<FrameOutput> {1886 ) -> Result<FrameOutput> {
1887- crate::census::frame_start(header, tile_bufs.iter().map(|t| t.len()).sum(), decode_idx);
1888 if header.segmentation.enabled {1887 if header.segmentation.enabled {
1889 // lane-hdrlossless: libaom IMPLEMENTS these three -- they rewrite a1888 // lane-hdrlossless: libaom IMPLEMENTS these three -- they rewrite a
1890 // block's reference / skip / mode BEFORE the symbols are read1889 // block's reference / skip / mode BEFORE the symbols are read