//! Native VP9 decoder: all four profiles, 8/10/12-bit, and every coded //! subsampling (4:2:0, 4:2:2, 4:4:0, 4:4:4). //! //! The crate implements the VP9 bitstream specification directly //! ([spec]); libvpx's output is used only as a test oracle //! (sample-exactness witnesses against ffmpeg's libvpx-based decoder), //! never as code linked at runtime. Every module documents the spec //! section it implements. Inter frames decode through motion compensation, //! residual reconstruction and the loop filter; intra-only frames and //! scaled references are supported too. //! //! Planes are stored as `u16` for every depth ([`Sample`]); kernels take the //! frame's `bd` and clamp with `clip_pixel_bd`, so one decode walk serves //! every depth and subsampling. The only depth-dependent bitstream element is //! the CAT6 coefficient token (14 bits/`vp9_cat6_prob` at 8-bit, 16 bits/ //! `vp9_cat6_prob_high12 + 2` at 10-bit, 18 bits/`vp9_cat6_prob_high12` at //! 12-bit). //! //! [spec]: https://www.webmproject.org/docs/vp9/ //! //! # Unsafe //! //! This crate contains no `unsafe` code. #![forbid(unsafe_code)] #![warn(missing_docs)] // Spec-transcription lints: the DSP, loop-filter and mode-info kernels mirror // libvpx argument lists and index-driven pseudo-code, kept as written so each // line stays checkable against the spec. Byte-exact paths are not restructured. #![allow( clippy::too_many_arguments, clippy::type_complexity, clippy::needless_range_loop, clippy::neg_multiply, clippy::collapsible_if, clippy::ptr_arg )] pub(crate) mod adapt; pub mod bool; pub mod decode; pub mod header; pub(crate) mod inter; pub mod intra; pub mod loopfilter; pub(crate) mod mc; pub mod modes; pub mod stream; pub mod tables; pub mod tokens; pub mod transform; pub use ec_core::{Error, Result}; /// A reconstructed sample. Planes are stored as `u16` for EVERY bit depth /// (8-bit values occupy the low byte), so profile-0 and profile-2 frames share /// one representation and one decode walk; the kernels take the frame's /// `bd` and clamp with [`clip_pixel_bd`]. pub type Sample = u16; /// `clip_pixel_highbd` (`vpx_dsp/vpx_dsp_common.h`): clamp to `[0, (1< Sample { v.clamp(0, (1i32 << bd) - 1) as Sample } /// `ROUND_POWER_OF_TWO(v, n)` (`vpx_dsp/txfm_common.h`, arithmetic shift). #[inline] pub(crate) fn round_pow2(v: i32, n: i32) -> i32 { (v + (1 << (n - 1))) >> n }