long_screen/kernels/mod.rs
1//! The reconstruction algorithms: features and motion evidence, region and layer learning, tracking, the pose
2//! graph, compositing with temporal conflicts, reveal, framing and the preview pyramid, plus the YUV→RGBA and PNG
3//! row kernels.
4//!
5//! Every pixel algorithm lives here, with no FFI and no I/O. The browser reaches it through the `extern "C"`
6//! exports of `long-screen-wasm` (rust/wasm), compiled three ways: scalar, SIMD128 and SIMD128 + shared-memory
7//! threads (see scripts/build-core.sh). The TypeScript side owns browser APIs only (decoding, storage, UI); it must
8//! not reimplement anything this module provides.
9//!
10//! This is an implementation layer, used by the [`engine`](crate::engine), the driver and the web page; most users
11//! want the driver at the crate root. Its API follows what those layers need and may change in minor versions.
12//! With the `rayon` feature, `pool::par_for` chunks run on rayon's thread pool; results do not depend on the thread
13//! count, and the WebAssembly builds leave it off.
14//!
15//! Check a candidate motion between two grayscale frames: the second frame is the first one scrolled up by 8
16//! pixels, and the retained block error is near zero only for the right displacement.
17//!
18//! ```
19//! use long_screen::kernels::motion::{verify_translation, Gray};
20//!
21//! let (width, height) = (192, 192);
22//! let texture = |x: usize, y: usize| ((x * 37 + y * 101 + (x * y) % 23) % 251) as u8;
23//! let a: Vec<u8> = (0..height).flat_map(|y| (0..width).map(move |x| texture(x, y))).collect();
24//! let b: Vec<u8> = (0..height).flat_map(|y| (0..width).map(move |x| texture(x, y + 8))).collect();
25//! let a = Gray { width, height, data: &a };
26//! let b = Gray { width, height, data: &b };
27//!
28//! let right = verify_translation(a, b, 0.0, 8.0, None);
29//! let wrong = verify_translation(a, b, 0.0, 0.0, None);
30//! println!("error at the right shift {right:.2}, without it {wrong:.2}");
31//! assert!(right < wrong);
32//! ```
33
34pub mod chrome;
35pub mod compositor;
36pub mod consistency;
37pub mod features;
38pub mod fixed_history;
39pub mod framing;
40pub mod geometry;
41pub mod layers;
42pub mod motion;
43pub mod overscroll;
44pub mod png;
45pub mod pool;
46pub mod pose_graph;
47pub mod pyramid;
48pub mod raster;
49pub mod region;
50pub mod regions;
51pub mod reveal;
52pub mod temporal;
53pub mod track;
54pub mod voting;
55pub mod yuv;