Commit 5311eeea authored by Raphaël Zumer's avatar Raphaël Zumer

Organize use statements

* Move use statements to the heads of their modules
* Split local and external module use statements
* Reorder use statements alphabetically by module name
parent 4d226d8d
...@@ -15,18 +15,17 @@ mod predict; ...@@ -15,18 +15,17 @@ mod predict;
mod transform; mod transform;
mod me; mod me;
use std::time::Duration; use rav1e::*;
use criterion::*;
use rav1e::cdef::cdef_filter_frame; use rav1e::cdef::cdef_filter_frame;
use rav1e::context::*; use rav1e::context::*;
use rav1e::ec;
use rav1e::partition::*; use rav1e::partition::*;
use rav1e::predict::*; use rav1e::predict::*;
use rav1e::rdo::rdo_cfl_alpha; use rav1e::rdo::rdo_cfl_alpha;
use rav1e::*;
use transform::transform; use transform::transform;
use criterion::*;
use std::time::Duration;
#[cfg(feature = "comparative_bench")] #[cfg(feature = "comparative_bench")]
mod comparative; mod comparative;
......
...@@ -8,9 +8,10 @@ ...@@ -8,9 +8,10 @@
// PATENTS file, you can obtain it at www.aomedia.org/license/patent. // PATENTS file, you can obtain it at www.aomedia.org/license/patent.
use comparative::libc; use comparative::libc;
use criterion::*;
use predict as predict_native; use predict as predict_native;
use predict::*; use predict::*;
use criterion::*;
use rand::{ChaChaRng, Rng, SeedableRng}; use rand::{ChaChaRng, Rng, SeedableRng};
extern { extern {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use criterion::*; use criterion::*;
use partition::*; use partition::*;
use partition::BlockSize::*;
use plane::*; use plane::*;
use rand::{ChaChaRng, Rng, SeedableRng}; use rand::{ChaChaRng, Rng, SeedableRng};
use rav1e::me; use rav1e::me;
...@@ -52,7 +53,6 @@ fn bench_get_sad(b: &mut Bencher, bs: &BlockSize) { ...@@ -52,7 +53,6 @@ fn bench_get_sad(b: &mut Bencher, bs: &BlockSize) {
} }
pub fn get_sad(c: &mut Criterion) { pub fn get_sad(c: &mut Criterion) {
use partition::BlockSize::*;
let blocks = vec![ let blocks = vec![
BLOCK_4X4, BLOCK_4X4,
BLOCK_4X8, BLOCK_4X8,
......
...@@ -7,15 +7,16 @@ ...@@ -7,15 +7,16 @@
// Media Patent License 1.0 was not distributed with this source code in the // Media Patent License 1.0 was not distributed with this source code in the
// PATENTS file, you can obtain it at www.aomedia.org/license/patent. // PATENTS file, you can obtain it at www.aomedia.org/license/patent.
use bitstream_io::*;
use encoder::*; use encoder::*;
use metrics::calculate_frame_psnr;
use partition::*; use partition::*;
use scenechange::SceneChangeDetector;
use self::EncoderStatus::*;
use std::cmp; use std::{cmp, fmt, io};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::fmt;
use std::sync::Arc; use std::sync::Arc;
use scenechange::SceneChangeDetector;
use metrics::calculate_frame_psnr;
// TODO: use the num crate? // TODO: use the num crate?
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
...@@ -173,7 +174,6 @@ pub struct Config { ...@@ -173,7 +174,6 @@ pub struct Config {
impl Config { impl Config {
pub fn parse(&mut self, key: &str, value: &str) -> Result<(), EncoderStatus> { pub fn parse(&mut self, key: &str, value: &str) -> Result<(), EncoderStatus> {
use self::EncoderStatus::*;
match key { match key {
"low_latency" => self.enc.low_latency = value.parse().map_err(|_e| ParseError)?, "low_latency" => self.enc.low_latency = value.parse().map_err(|_e| ParseError)?,
"min_key_frame_interval" => self.enc.min_key_frame_interval = value.parse().map_err(|_e| ParseError)?, "min_key_frame_interval" => self.enc.min_key_frame_interval = value.parse().map_err(|_e| ParseError)?,
......
...@@ -9,11 +9,10 @@ ...@@ -9,11 +9,10 @@
use clap::{App, Arg, ArgMatches}; use clap::{App, Arg, ArgMatches};
use rav1e::*; use rav1e::*;
use std::fmt;
use std::{fmt, io, slice};
use std::fs::File; use std::fs::File;
use std::io;
use std::io::prelude::*; use std::io::prelude::*;
use std::slice;
use std::sync::Arc; use std::sync::Arc;
use std::time::Instant; use std::time::Instant;
use y4m; use y4m;
......
...@@ -13,10 +13,10 @@ extern crate y4m; ...@@ -13,10 +13,10 @@ extern crate y4m;
mod common; mod common;
use common::*; use common::*;
use rav1e::*;
use std::io; use std::io;
use std::io::Write; use std::io::Write;
use rav1e::*;
fn main() { fn main() {
let mut cli = parse_cli(); let mut cli = parse_cli();
......
...@@ -10,12 +10,11 @@ ...@@ -10,12 +10,11 @@
extern crate clap; extern crate clap;
extern crate rustyline; extern crate rustyline;
extern crate y4m; extern crate y4m;
extern crate rav1e; extern crate rav1e;
mod common; mod common;
use common::*;
use common::*;
use rav1e::*; use rav1e::*;
use rustyline::error::ReadlineError; use rustyline::error::ReadlineError;
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
#![allow(safe_extern_statics)] #![allow(safe_extern_statics)]
use std::cmp;
use context::*; use context::*;
use plane::*;
use util::clamp;
use util::msb;
use FrameInvariants;
use Frame; use Frame;
use FrameInvariants;
use plane::*;
use util::{clamp, msb};
use std::cmp;
pub struct CdefDirections { pub struct CdefDirections {
dir: [[u8; 8]; 8], dir: [[u8; 8]; 8],
......
...@@ -17,25 +17,20 @@ ...@@ -17,25 +17,20 @@
#![cfg_attr(feature = "cargo-clippy", allow(collapsible_if))] #![cfg_attr(feature = "cargo-clippy", allow(collapsible_if))]
use ec::Writer; use ec::Writer;
use encoder::{FrameInvariants, ReferenceMode};
use entropymode::*;
use lrf::{WIENER_TAPS_MID, SGR_XQD_MID};
use partition::*;
use partition::BlockSize::*; use partition::BlockSize::*;
use partition::PredictionMode::*; use partition::PredictionMode::*;
use partition::TxSize::*; use partition::TxSize::*;
use partition::TxType::*; use partition::TxType::*;
use partition::*;
use lrf::WIENER_TAPS_MID;
use lrf::SGR_XQD_MID;
use plane::*; use plane::*;
use util::clamp;
use util::msb;
use std::*;
use entropymode::*;
use token_cdfs::*;
use encoder::FrameInvariants;
use scan_order::*; use scan_order::*;
use encoder::ReferenceMode; use token_cdfs::*;
use util::{clamp, msb};
use self::REF_CONTEXTS; use std::*;
use self::SINGLE_REFS;
pub const PLANES: usize = 3; pub const PLANES: usize = 3;
......
...@@ -10,17 +10,16 @@ ...@@ -10,17 +10,16 @@
#![allow(safe_extern_statics)] #![allow(safe_extern_statics)]
use context::*; use context::*;
use partition::PredictionMode::*;
use partition::*;
use plane::*;
use quantize::*;
use std::cmp;
use util::clamp;
use util::ILog;
use DeblockState; use DeblockState;
use FrameInvariants; use FrameInvariants;
use FrameState; use FrameState;
use FrameType; use FrameType;
use partition::*;
use partition::PredictionMode::*;
use plane::*;
use quantize::*;
use std::cmp;
use util::{clamp, ILog};
fn deblock_adjusted_level( fn deblock_adjusted_level(
deblock: &DeblockState, block: &Block, pli: usize, vertical: bool deblock: &DeblockState, block: &Block, pli: usize, vertical: bool
......
...@@ -344,7 +344,6 @@ impl<S> WriterBase<S> { ...@@ -344,7 +344,6 @@ impl<S> WriterBase<S> {
#[cfg(debug)] #[cfg(debug)]
fn print_backtrace(&self, s: u32) { fn print_backtrace(&self, s: u32) {
use backtrace;
let mut depth = 3; let mut depth = 3;
backtrace::trace(|frame| { backtrace::trace(|frame| {
let ip = frame.ip(); let ip = frame.ip();
...@@ -644,6 +643,7 @@ impl<W: io::Write> BCodeWriter for BitWriter<W, BigEndian> { ...@@ -644,6 +643,7 @@ impl<W: io::Write> BCodeWriter for BitWriter<W, BigEndian> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
const WINDOW_SIZE: i16 = 32; const WINDOW_SIZE: i16 = 32;
const LOTS_OF_BITS: i16 = 0x4000; const LOTS_OF_BITS: i16 = 0x4000;
......
...@@ -9,25 +9,25 @@ ...@@ -9,25 +9,25 @@
use api::*; use api::*;
use cdef::*; use cdef::*;
use lrf::*;
use context::*; use context::*;
use deblock::*; use deblock::*;
use segmentation::*;
use ec::*; use ec::*;
use lrf::*;
use me::*;
use partition::*; use partition::*;
use plane::*; use plane::*;
use quantize::*; use quantize::*;
use rdo::*; use rdo::*;
use std::fmt; use segmentation::*;
use transform::*; use transform::*;
use util::*; use util::*;
use me::*;
use bitstream_io::{BitWriter, BigEndian, LittleEndian}; use bitstream_io::{BitWriter, BigEndian, LittleEndian};
use std; use std;
use std::io; use std::{fmt, io};
use std::io::Write; use std::io::Write;
use std::rc::Rc; use std::rc::Rc;
use std::sync::Arc;
extern { extern {
pub fn av1_rtcd(); pub fn av1_rtcd();
...@@ -399,8 +399,6 @@ impl Sequence { ...@@ -399,8 +399,6 @@ impl Sequence {
} }
} }
use std::sync::Arc;
#[derive(Debug)] #[derive(Debug)]
pub struct FrameState { pub struct FrameState {
pub input: Arc<Frame>, pub input: Arc<Frame>,
...@@ -2758,9 +2756,10 @@ pub fn update_rec_buffer(fi: &mut FrameInvariants, fs: FrameState) { ...@@ -2758,9 +2756,10 @@ pub fn update_rec_buffer(fi: &mut FrameInvariants, fs: FrameState) {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*;
#[test] #[test]
fn frame_state_window() { fn frame_state_window() {
use super::*;
let config = EncoderConfig { ..Default::default() }; let config = EncoderConfig { ..Default::default() };
let fi = FrameInvariants::new(1024, 1024, config); let fi = FrameInvariants::new(1024, 1024, config);
let mut fs = FrameState::new(&fi); let mut fs = FrameState::new(&fi);
......
...@@ -7,21 +7,24 @@ ...@@ -7,21 +7,24 @@
// Media Patent License 1.0 was not distributed with this source code in the // Media Patent License 1.0 was not distributed with this source code in the
// PATENTS file, you can obtain it at www.aomedia.org/license/patent. // PATENTS file, you can obtain it at www.aomedia.org/license/patent.
use context::BlockOffset; #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
use context::BLOCK_TO_PLANE_SHIFT; pub use self::nasm::get_sad;
use context::MI_SIZE; #[cfg(any(not(target_arch = "x86_64"), windows, not(feature = "nasm")))]
use partition::*; pub use self::native::get_sad;
use plane::*; use context::{BlockOffset, BLOCK_TO_PLANE_SHIFT, MI_SIZE};
use FrameInvariants; use FrameInvariants;
use FrameState; use FrameState;
use partition::*;
use plane::*;
use rdo::get_lambda_sqrt; use rdo::get_lambda_sqrt;
#[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
mod nasm { mod nasm {
use libc;
use plane::*; use plane::*;
use util::*; use util::*;
use libc;
extern { extern {
fn rav1e_sad_4x4_hbd_ssse3( fn rav1e_sad_4x4_hbd_ssse3(
src: *const u16, src_stride: libc::ptrdiff_t, dst: *const u16, src: *const u16, src_stride: libc::ptrdiff_t, dst: *const u16,
...@@ -129,12 +132,6 @@ mod native { ...@@ -129,12 +132,6 @@ mod native {
} }
} }
#[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
pub use self::nasm::get_sad;
#[cfg(any(not(target_arch = "x86_64"), windows, not(feature = "nasm")))]
pub use self::native::get_sad;
fn get_mv_range(fi: &FrameInvariants, bo: &BlockOffset, blk_w: usize, blk_h: usize) -> (isize, isize, isize, isize) { fn get_mv_range(fi: &FrameInvariants, bo: &BlockOffset, blk_w: usize, blk_h: usize) -> (isize, isize, isize, isize) {
let border_w = 128 + blk_w as isize * 8; let border_w = 128 + blk_w as isize * 8;
let border_h = 128 + blk_h as isize * 8; let border_h = 128 + blk_h as isize * 8;
...@@ -421,6 +418,8 @@ pub fn estimate_motion_ss2( ...@@ -421,6 +418,8 @@ pub fn estimate_motion_ss2(
#[cfg(test)] #[cfg(test)]
pub mod test { pub mod test {
use super::*; use super::*;
use partition::BlockSize;
use partition::BlockSize::*;
// Generate plane data for get_sad_same() // Generate plane data for get_sad_same()
fn setup_sad() -> (Plane, Plane) { fn setup_sad() -> (Plane, Plane) {
...@@ -451,9 +450,6 @@ pub mod test { ...@@ -451,9 +450,6 @@ pub mod test {
// Regression and validation test for SAD computation // Regression and validation test for SAD computation
#[test] #[test]
fn get_sad_same() { fn get_sad_same() {
use partition::BlockSize;
use partition::BlockSize::*;
let blocks: Vec<(BlockSize, u32)> = vec![ let blocks: Vec<(BlockSize, u32)> = vec![
(BLOCK_4X4, 1912), (BLOCK_4X4, 1912),
(BLOCK_4X8, 3496), (BLOCK_4X8, 3496),
......
...@@ -12,7 +12,11 @@ ...@@ -12,7 +12,11 @@
use self::BlockSize::*; use self::BlockSize::*;
use self::TxSize::*; use self::TxSize::*;
use context::*;
use encoder::{ChromaSampling, FrameInvariants}; use encoder::{ChromaSampling, FrameInvariants};
use plane::*;
use predict::*;
use util::*;
pub const NONE_FRAME: usize = 8; pub const NONE_FRAME: usize = 8;
pub const INTRA_FRAME: usize = 0; pub const INTRA_FRAME: usize = 0;
...@@ -856,11 +860,6 @@ pub enum MvJointType { ...@@ -856,11 +860,6 @@ pub enum MvJointType {
MV_JOINT_HNZVNZ = 3 /* Both components nonzero */ MV_JOINT_HNZVNZ = 3 /* Both components nonzero */
} }
use context::*;
use plane::*;
use predict::*;
use util::*;
impl PredictionMode { impl PredictionMode {
pub fn predict_intra<'a>( pub fn predict_intra<'a>(
self, dst: &'a mut PlaneMutSlice<'a>, tx_size: TxSize, bit_depth: usize, self, dst: &'a mut PlaneMutSlice<'a>, tx_size: TxSize, bit_depth: usize,
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))] #![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))]
use std::iter::FusedIterator;
use util::*; use util::*;
/// Plane-specific configuration. /// Plane-specific configuration.
...@@ -331,7 +333,6 @@ impl<'a> Iterator for IterWidth<'a> { ...@@ -331,7 +333,6 @@ impl<'a> Iterator for IterWidth<'a> {
impl<'a> ExactSizeIterator for IterWidth<'a> { } impl<'a> ExactSizeIterator for IterWidth<'a> { }
use std::iter::FusedIterator;
impl<'a> FusedIterator for IterWidth<'a> { } impl<'a> FusedIterator for IterWidth<'a> { }
impl<'a> PlaneSlice<'a> { impl<'a> PlaneSlice<'a> {
......
...@@ -11,22 +11,20 @@ ...@@ -11,22 +11,20 @@
#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))] #![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))]
#![cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))] #![cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
#[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))] use context::{INTRA_MODES, MAX_TX_SIZE};
use libc;
use num_traits::*;
use context::INTRA_MODES;
use context::MAX_TX_SIZE;
use partition::*; use partition::*;
use util::*; use util::*;
use std::mem::*;
#[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
use std::ptr;
#[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
use libc;
use num_traits::*;
#[cfg(target_arch = "x86")] #[cfg(target_arch = "x86")]
use std::arch::x86::*; use std::arch::x86::*;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*; use std::arch::x86_64::*;
use std::mem::*;
#[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
use std::ptr;
pub static RAV1E_INTRA_MODES: &'static [PredictionMode] = &[ pub static RAV1E_INTRA_MODES: &'static [PredictionMode] = &[
PredictionMode::DC_PRED, PredictionMode::DC_PRED,
...@@ -767,6 +765,7 @@ pub trait Inter: Dim {} ...@@ -767,6 +765,7 @@ pub trait Inter: Dim {}
pub mod test { pub mod test {
use super::*; use super::*;
use rand::{ChaChaRng, Rng, SeedableRng}; use rand::{ChaChaRng, Rng, SeedableRng};
use util::*;
const MAX_ITER: usize = 50000; const MAX_ITER: usize = 50000;
...@@ -1010,7 +1009,6 @@ pub mod test { ...@@ -1010,7 +1009,6 @@ pub mod test {
#[test] #[test]
fn pred_matches_u8() { fn pred_matches_u8() {
use util::*;
let mut edge_buf: AlignedArray<[u8; 2 * MAX_TX_SIZE + 1]> = let mut edge_buf: AlignedArray<[u8; 2 * MAX_TX_SIZE + 1]> =
UninitializedAlignedArray(); UninitializedAlignedArray();
for i in 0..edge_buf.array.len() { for i in 0..edge_buf.array.len() {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#![allow(non_upper_case_globals)] #![allow(non_upper_case_globals)]
use partition::TxSize; use partition::TxSize;
use std::mem; use std::mem;
pub fn get_log_tx_scale(tx_size: TxSize) -> i32 { pub fn get_log_tx_scale(tx_size: TxSize) -> i32 {
...@@ -90,6 +91,7 @@ fn divu_pair(x: i32, d: (u32, u32, u32)) -> i32 { ...@@ -90,6 +91,7 @@ fn divu_pair(x: i32, d: (u32, u32, u32)) -> i32 {
mod test { mod test {
use super::*; use super::*;
use partition::TxSize::*; use partition::TxSize::*;
#[test] #[test]
fn test_divu_pair() { fn test_divu_pair() {
for d in 1..1024 { for d in 1..1024 {
......
...@@ -11,34 +11,31 @@ ...@@ -11,34 +11,31 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))] #![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))]
use api::PredictionModesSetting;
use cdef::*;
use context::*; use context::*;
use me::*; use ec::{OD_BITRES, Writer, WriterCounter};
use ec::OD_BITRES; use encoder::{ChromaSampling, ReferenceMode};
use ec::Writer;
use ec::WriterCounter;
use luma_ac;
use encode_block_a; use encode_block_a;
use encode_block_b; use encode_block_b;
use Frame;
use FrameInvariants;
use FrameState;
use FrameType;
use luma_ac;
use me::*;
use motion_compensate; use motion_compensate;
use partition::*; use partition::*;
use plane::*; use plane::*;
use cdef::*;
use predict::{RAV1E_INTRA_MODES, RAV1E_INTRA_MODES_MINIMAL, RAV1E_INTER_MODES_MINIMAL, RAV1E_INTER_COMPOUND_MODES}; use predict::{RAV1E_INTRA_MODES, RAV1E_INTRA_MODES_MINIMAL, RAV1E_INTER_MODES_MINIMAL, RAV1E_INTER_COMPOUND_MODES};
use quantize::dc_q; use quantize::dc_q;
use std; use Sequence;
use std::f64; use Tune;
use std::vec::Vec;
use write_tx_blocks; use write_tx_blocks;
use write_tx_tree; use write_tx_tree;
use partition::BlockSize;
use Frame; use std;
use FrameInvariants; use std::vec::Vec;
use FrameState;
use FrameType;
use Tune;
use Sequence;
use encoder::{ChromaSampling, ReferenceMode};
use api::PredictionModesSetting;
#[derive(Clone)] #[derive(Clone)]
pub struct RDOOutput { pub struct RDOOutput {
......
use encoder::Frame;
use api::FrameInfo; use api::FrameInfo;
use encoder::Frame;
use std::sync::Arc; use std::sync::Arc;
/// Detects fast cuts using changes in colour and intensity between frames. /// Detects fast cuts using changes in colour and intensity between frames.
......
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
include!(concat!(env!("OUT_DIR"), "/aom.rs")); include!(concat!(env!("OUT_DIR"), "/aom.rs"));
use super::*; use super::*;
use rand::{ChaChaRng, Rng, SeedableRng}; use rand::{ChaChaRng, Rng, SeedableRng};
use std::{mem, ptr, slice};
use std::collections::VecDeque; use std::collections::VecDeque;
use std::mem; use std::ffi::CStr;
use std::sync::Arc; use std::sync::Arc;
fn fill_frame(ra: &mut ChaChaRng, frame: &mut Frame) { fn fill_frame(ra: &mut ChaChaRng, frame: &mut Frame) {
...@@ -225,7 +225,6 @@ fn compare_plane<T: Ord + std::fmt::Debug>( ...@@ -225,7 +225,6 @@ fn compare_plane<T: Ord + std::fmt::Debug>(
} }