forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

lib.rs66 lines, 2.1 KiBHistoryRawDownload
1//! Native VP8 (RFC 6386) decoder — the future replacement for edith's
2//! runtime-dlopen'd libvpx seat.
3//!
4//! The crate is written from the specification ([RFC 6386]) alone; libvpx's
5//! output is used only as a test oracle (sample-exactness witnesses), never
6//! as code to port. Every module documents the spec section it implements.
7//!
8//! [RFC 6386]: https://www.rfc-editor.org/rfc/rfc6386
9//!
10//! # Safety
11//!
12//! Every SIMD kernel is a safe `#[arcane]` function taking a `X64V3Token`
13//! proof of AVX2, obtained at runtime; the crate-level `forbid` below keeps it so.
14
15#![forbid(unsafe_code)]
16#![warn(missing_docs)]
17
18pub mod bool;
19pub mod decode;
20pub mod frame;
21pub mod header;
22pub mod intra;
23pub mod loopfilter;
24mod mc;
25pub mod modes;
26pub mod stream;
27pub mod tables;
28pub mod tokens;
29pub mod transform;
30
31pub use ec_core::{Error, Result};
32pub use header::PersistedState;
33
34/// Whether `EC_VP8_TRACE` decision tracing is enabled, resolved once per
35/// process. A `var_os` per bool read was 46% of the decode profile (each
36/// call locks std's ENV lock and allocates); `OnceLock::get_or_init` was
37/// no better, so the hot path is a single relaxed atomic load.
38pub(crate) fn trace_enabled() -> bool {
39 use std::sync::atomic::{AtomicU8, Ordering};
40 static STATE: AtomicU8 = AtomicU8::new(0);
41 match STATE.load(Ordering::Relaxed) {
42 0 => {
43 let on = std::env::var_os("EC_VP8_TRACE").is_some();
44 STATE.store(if on { 2 } else { 1 }, Ordering::Relaxed);
45 on
46 }
47 1 => false,
48 _ => true,
49 }
50}
51
52/// Whether `EC_VP8_DEBUG` per-macroblock dumps are enabled (same shape as
53/// [`trace_enabled`]; the check sits in the per-MB reconstruct path).
54pub(crate) fn debug_enabled() -> bool {
55 use std::sync::atomic::{AtomicU8, Ordering};
56 static STATE: AtomicU8 = AtomicU8::new(0);
57 match STATE.load(Ordering::Relaxed) {
58 0 => {
59 let on = std::env::var_os("EC_VP8_DEBUG").is_some();
60 STATE.store(if on { 2 } else { 1 }, Ordering::Relaxed);
61 on
62 }
63 1 => false,
64 _ => true,
65 }
66}