#![deny(bare_trait_objects)]
#![allow(clippy::cast_lossless)]
#![allow(clippy::cast_ptr_alignment)]
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::verbose_bit_mask)]
#![allow(clippy::unreadable_literal)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::wrong_self_convention)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::comparison_chain)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::enum_variant_names)]
#![warn(clippy::linkedlist)]
#![warn(clippy::mutex_integer)]
#![warn(clippy::suboptimal_flops)]
#![warn(clippy::expl_impl_clone_on_copy)]
#![warn(clippy::mem_forget)]
#![warn(clippy::path_buf_push_overwrite)]
#![warn(clippy::map_flatten)]
#![warn(clippy::mut_mut)]
#![warn(clippy::needless_borrow)]
#![warn(clippy::needless_continue)]
#![warn(clippy::range_plus_one)]
#![warn(clippy::doc_markdown)]
#![warn(clippy::missing_errors_doc)]
#![warn(clippy::missing_panics_doc)]
#![allow(clippy::undocumented_unsafe_blocks)]
#[cfg(test)]
#[macro_use]
extern crate pretty_assertions;
#[macro_use]
extern crate log;
pub(crate) mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}
mod serialize {
cfg_if::cfg_if! {
if #[cfg(feature="serialize")] {
pub use serde::*;
} else {
pub use noop_proc_macro::{Deserialize, Serialize};
}
}
}
mod wasm_bindgen {
cfg_if::cfg_if! {
if #[cfg(feature="wasm")] {
pub use wasm_bindgen::prelude::*;
} else {
pub use noop_proc_macro::wasm_bindgen;
}
}
}
mod rayon {
cfg_if::cfg_if! {
if #[cfg(all(target_arch="wasm32", not(target_feature = "atomics")))] {
pub struct ThreadPoolBuilder ();
impl ThreadPoolBuilder {
pub fn new() -> ThreadPoolBuilder {
ThreadPoolBuilder()
}
pub fn build(self) -> Result<ThreadPool, ()> {
Ok(ThreadPool())
}
pub fn num_threads(self, _num_threads: usize) -> ThreadPoolBuilder {
ThreadPoolBuilder()
}
}
#[derive(Debug)]
pub struct ThreadPool ();
impl ThreadPool {
pub fn install<OP, R>(&self, op: OP) -> R where
OP: FnOnce() -> R + Send,
R: Send, {
op()
}
}
pub mod iter {
pub trait IntoParallelIterator {
type Iter: Iterator<Item = Self::Item>;
type Item: Send;
fn into_par_iter(self) -> Self::Iter;
}
impl<I: IntoIterator> IntoParallelIterator for I where
I::Item : Send {
type Item = I::Item;
type Iter = I::IntoIter;
fn into_par_iter(self) -> I::IntoIter {
self.into_iter()
}
}
pub trait IntoParallelRefMutIterator<'data> {
type Iter: IntoParallelIterator<Item = Self::Item>;
type Item: Send + 'data;
fn par_iter_mut(&'data mut self) -> Self::Iter;
}
impl<'data, I: 'data + ?Sized> IntoParallelRefMutIterator<'data> for I
where
&'data mut I: IntoParallelIterator,
{
type Iter = <&'data mut I as IntoParallelIterator>::Iter;
type Item = <&'data mut I as IntoParallelIterator>::Item;
fn par_iter_mut(&'data mut self) -> Self::Iter {
self.into_par_iter()
}
}
pub trait ParallelIterator: Iterator {
fn flat_map_iter<U, F>(self, f: F) -> std::iter::FlatMap<Self, U, F>
where
Self: Sized,
U: IntoIterator,
F: FnMut(<Self as Iterator>::Item) -> U,
{
self.flat_map(f)
}
}
impl<I: Iterator> ParallelIterator for I {}
}
pub mod slice {
pub trait ParallelSlice<T: Sync> {
fn par_chunks_exact(
&self, chunk_size: usize,
) -> std::slice::ChunksExact<'_, T>;
}
impl<T: Sync> ParallelSlice<T> for [T] {
#[inline]
fn par_chunks_exact(
&self, chunk_size: usize,
) -> std::slice::ChunksExact<'_, T> {
self.chunks_exact(chunk_size)
}
}
}
pub mod prelude {
pub use super::iter::*;
pub use super::slice::*;
}
pub fn join<A, B, RA, RB>(oper_a: A, oper_b: B) -> (RA, RB)
where
A: FnOnce() -> RA + Send,
B: FnOnce() -> RB + Send,
RA: Send,
RB: Send {
(oper_a(), oper_b())
}
use std::marker::PhantomData;
pub struct Scope<'scope>{
marker: PhantomData<Box<dyn FnOnce(&Scope<'scope>) + Send + Sync + 'scope>>,
}
impl<'scope> Scope<'scope> {
pub fn spawn<BODY>(&self, body: BODY)
where BODY: FnOnce(&Scope<'scope>) + Send + 'scope
{
body(self)
}
}
pub fn scope<'scope, OP, R>(op: OP) -> R
where OP: for<'s> FnOnce(&'s Scope<'scope>) -> R + 'scope + Send, R: Send,
{
op(&Scope { marker: PhantomData})
}
} else {
pub use rayon::*;
}
}
}
#[cfg(any(cargo_c, feature = "capi"))]
pub mod capi;
#[macro_use]
mod transform;
#[macro_use]
mod cpu_features;
mod activity;
pub(crate) mod asm;
mod dist;
mod ec;
mod partition;
mod predict;
mod quantize;
mod rdo;
mod rdo_tables;
#[macro_use]
mod util;
mod cdef;
#[doc(hidden)]
pub mod context;
mod deblock;
mod encoder;
mod entropymode;
mod levels;
mod lrf;
mod mc;
mod me;
mod rate;
mod recon_intra;
mod sad_plane;
mod scan_order;
#[cfg(feature = "scenechange")]
pub mod scenechange;
#[cfg(not(feature = "scenechange"))]
mod scenechange;
mod segmentation;
mod stats;
#[doc(hidden)]
pub mod tiling;
mod token_cdfs;
mod api;
mod frame;
mod header;
use crate::encoder::*;
pub use crate::api::{
Config, Context, EncoderConfig, EncoderStatus, InvalidConfig, Packet,
};
pub use crate::frame::Frame;
pub use crate::util::{CastFromPrimitive, Pixel, PixelType};
pub mod prelude {
pub use crate::api::*;
pub use crate::encoder::{Sequence, Tune};
pub use crate::frame::{
Frame, FrameParameters, FrameTypeOverride, Plane, PlaneConfig,
};
pub use crate::partition::BlockSize;
pub use crate::predict::PredictionMode;
pub use crate::transform::TxType;
pub use crate::util::{CastFromPrimitive, Pixel, PixelType};
}
pub mod data {
pub use crate::api::{
ChromaticityPoint, EncoderStatus, FrameType, Packet, Rational,
};
pub use crate::frame::{Frame, FrameParameters};
pub use crate::stats::EncoderStats;
pub use crate::util::{CastFromPrimitive, Pixel, PixelType};
}
pub use crate::api::color;
pub mod config {
pub use crate::api::config::{
GrainTableSegment, NoiseGenArgs, TransferFunction, NUM_UV_COEFFS,
NUM_UV_POINTS, NUM_Y_COEFFS, NUM_Y_POINTS,
};
pub use crate::api::{
Config, EncoderConfig, InvalidConfig, PredictionModesSetting,
RateControlConfig, RateControlError, RateControlSummary, SpeedSettings,
};
pub use crate::cpu_features::CpuFeatureLevel;
}
pub mod version {
pub fn major() -> u64 {
env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap()
}
pub fn minor() -> u64 {
env!("CARGO_PKG_VERSION_MINOR").parse().unwrap()
}
pub fn patch() -> u64 {
env!("CARGO_PKG_VERSION_PATCH").parse().unwrap()
}
pub fn short() -> String {
env!("CARGO_PKG_VERSION").to_string()
}
pub fn long() -> String {
let s = short();
let hash = hash();
if hash.is_empty() {
s
} else {
format!("{} - {}", s, hash)
}
}
cfg_if::cfg_if! {
if #[cfg(feature="git_version")] {
fn git_version() -> &'static str {
crate::built_info::GIT_VERSION.unwrap_or_default()
}
fn git_hash() -> &'static str {
crate::built_info::GIT_COMMIT_HASH.unwrap_or_default()
}
} else {
fn git_version() -> &'static str {
"UNKNOWN"
}
fn git_hash() -> &'static str {
"UNKNOWN"
}
}
}
pub fn hash() -> String {
git_hash().to_string()
}
pub fn full() -> String {
format!("{} ({})", short(), git_version(),)
}
}
#[cfg(all(
any(test, fuzzing),
any(feature = "decode_test", feature = "decode_test_dav1d")
))]
mod test_encode_decode;
#[cfg(feature = "bench")]
pub mod bench {
pub mod api {
pub use crate::api::*;
}
pub mod cdef {
pub use crate::cdef::*;
}
pub mod context {
pub use crate::context::*;
}
pub mod dist {
pub use crate::dist::*;
}
pub mod ec {
pub use crate::ec::*;
}
pub mod encoder {
pub use crate::encoder::*;
}
pub mod mc {
pub use crate::mc::*;
}
pub mod partition {
pub use crate::partition::*;
}
pub mod frame {
pub use crate::frame::*;
}
pub mod predict {
pub use crate::predict::*;
}
pub mod rdo {
pub use crate::rdo::*;
}
pub mod tiling {
pub use crate::tiling::*;
}
pub mod transform {
pub use crate::transform::*;
}
pub mod util {
pub use crate::util::*;
}
pub mod cpu_features {
pub use crate::cpu_features::*;
}
}
#[cfg(fuzzing)]
pub mod fuzzing;