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;
mod transform;
mod me;
use std::time::Duration;
use criterion::*;
use rav1e::*;
use rav1e::cdef::cdef_filter_frame;
use rav1e::context::*;
use rav1e::ec;
use rav1e::partition::*;
use rav1e::predict::*;
use rav1e::rdo::rdo_cfl_alpha;
use rav1e::*;
use transform::transform;
use criterion::*;
use std::time::Duration;
#[cfg(feature = "comparative_bench")]
mod comparative;
......
......@@ -8,9 +8,10 @@
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.
use comparative::libc;
use criterion::*;
use predict as predict_native;
use predict::*;
use criterion::*;
use rand::{ChaChaRng, Rng, SeedableRng};
extern {
......
......@@ -9,6 +9,7 @@
use criterion::*;
use partition::*;
use partition::BlockSize::*;
use plane::*;
use rand::{ChaChaRng, Rng, SeedableRng};
use rav1e::me;
......@@ -52,7 +53,6 @@ fn bench_get_sad(b: &mut Bencher, bs: &BlockSize) {
}
pub fn get_sad(c: &mut Criterion) {
use partition::BlockSize::*;
let blocks = vec![
BLOCK_4X4,
BLOCK_4X8,
......
......@@ -7,15 +7,16 @@
// 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.
use bitstream_io::*;
use encoder::*;
use metrics::calculate_frame_psnr;
use partition::*;
use scenechange::SceneChangeDetector;
use self::EncoderStatus::*;
use std::cmp;
use std::{cmp, fmt, io};
use std::collections::BTreeMap;
use std::fmt;
use std::sync::Arc;
use scenechange::SceneChangeDetector;
use metrics::calculate_frame_psnr;
// TODO: use the num crate?
#[derive(Clone, Copy, Debug)]
......@@ -173,7 +174,6 @@ pub struct Config {
impl Config {
pub fn parse(&mut self, key: &str, value: &str) -> Result<(), EncoderStatus> {
use self::EncoderStatus::*;
match key {
"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)?,
......
......@@ -9,11 +9,10 @@
use clap::{App, Arg, ArgMatches};
use rav1e::*;
use std::fmt;
use std::{fmt, io, slice};
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::slice;
use std::sync::Arc;
use std::time::Instant;
use y4m;
......
......@@ -13,10 +13,10 @@ extern crate y4m;
mod common;
use common::*;
use rav1e::*;
use std::io;
use std::io::Write;
use rav1e::*;
fn main() {
let mut cli = parse_cli();
......
......@@ -10,12 +10,11 @@
extern crate clap;
extern crate rustyline;
extern crate y4m;
extern crate rav1e;
mod common;
use common::*;
use common::*;
use rav1e::*;
use rustyline::error::ReadlineError;
......
......@@ -9,13 +9,13 @@
#![allow(safe_extern_statics)]
use std::cmp;
use context::*;
use plane::*;
use util::clamp;
use util::msb;
use FrameInvariants;
use Frame;
use FrameInvariants;
use plane::*;
use util::{clamp, msb};
use std::cmp;
pub struct CdefDirections {
dir: [[u8; 8]; 8],
......
......@@ -17,25 +17,20 @@
#![cfg_attr(feature = "cargo-clippy", allow(collapsible_if))]
use ec::Writer;
use encoder::{FrameInvariants, ReferenceMode};
use entropymode::*;
use lrf::{WIENER_TAPS_MID, SGR_XQD_MID};
use partition::*;
use partition::BlockSize::*;
use partition::PredictionMode::*;
use partition::TxSize::*;
use partition::TxType::*;
use partition::*;
use lrf::WIENER_TAPS_MID;
use lrf::SGR_XQD_MID;
use plane::*;
use util::clamp;
use util::msb;
use std::*;
use entropymode::*;
use token_cdfs::*;
use encoder::FrameInvariants;
use scan_order::*;
use encoder::ReferenceMode;
use token_cdfs::*;
use util::{clamp, msb};
use self::REF_CONTEXTS;
use self::SINGLE_REFS;
use std::*;
pub const PLANES: usize = 3;
......
......@@ -10,17 +10,16 @@
#![allow(safe_extern_statics)]
use context::*;
use partition::PredictionMode::*;
use partition::*;
use plane::*;
use quantize::*;
use std::cmp;
use util::clamp;
use util::ILog;
use DeblockState;
use FrameInvariants;
use FrameState;
use FrameType;
use partition::*;
use partition::PredictionMode::*;
use plane::*;
use quantize::*;
use std::cmp;
use util::{clamp, ILog};
fn deblock_adjusted_level(
deblock: &DeblockState, block: &Block, pli: usize, vertical: bool
......
......@@ -344,7 +344,6 @@ impl<S> WriterBase<S> {
#[cfg(debug)]
fn print_backtrace(&self, s: u32) {
use backtrace;
let mut depth = 3;
backtrace::trace(|frame| {
let ip = frame.ip();
......@@ -644,6 +643,7 @@ impl<W: io::Write> BCodeWriter for BitWriter<W, BigEndian> {
#[cfg(test)]
mod test {
use super::*;
const WINDOW_SIZE: i16 = 32;
const LOTS_OF_BITS: i16 = 0x4000;
......
......@@ -9,25 +9,25 @@
use api::*;
use cdef::*;
use lrf::*;
use context::*;
use deblock::*;
use segmentation::*;
use ec::*;
use lrf::*;
use me::*;
use partition::*;
use plane::*;
use quantize::*;
use rdo::*;
use std::fmt;
use segmentation::*;
use transform::*;
use util::*;
use me::*;
use bitstream_io::{BitWriter, BigEndian, LittleEndian};
use std;
use std::io;
use std::{fmt, io};
use std::io::Write;
use std::rc::Rc;
use std::sync::Arc;
extern {
pub fn av1_rtcd();
......@@ -399,8 +399,6 @@ impl Sequence {
}
}
use std::sync::Arc;
#[derive(Debug)]
pub struct FrameState {
pub input: Arc<Frame>,
......@@ -2758,9 +2756,10 @@ pub fn update_rec_buffer(fi: &mut FrameInvariants, fs: FrameState) {
#[cfg(test)]
mod test {
use super::*;
#[test]
fn frame_state_window() {
use super::*;
let config = EncoderConfig { ..Default::default() };
let fi = FrameInvariants::new(1024, 1024, config);
let mut fs = FrameState::new(&fi);
......
......@@ -7,21 +7,24 @@
// 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.
use context::BlockOffset;
use context::BLOCK_TO_PLANE_SHIFT;
use context::MI_SIZE;
use partition::*;
use plane::*;
#[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;
use context::{BlockOffset, BLOCK_TO_PLANE_SHIFT, MI_SIZE};
use FrameInvariants;
use FrameState;
use partition::*;
use plane::*;
use rdo::get_lambda_sqrt;
#[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
mod nasm {
use libc;
use plane::*;
use util::*;
use libc;
extern {
fn rav1e_sad_4x4_hbd_ssse3(
src: *const u16, src_stride: libc::ptrdiff_t, dst: *const u16,
......@@ -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) {
let border_w = 128 + blk_w as isize * 8;
let border_h = 128 + blk_h as isize * 8;
......@@ -421,6 +418,8 @@ pub fn estimate_motion_ss2(
#[cfg(test)]
pub mod test {
use super::*;
use partition::BlockSize;
use partition::BlockSize::*;
// Generate plane data for get_sad_same()
fn setup_sad() -> (Plane, Plane) {
......@@ -451,9 +450,6 @@ pub mod test {
// Regression and validation test for SAD computation
#[test]
fn get_sad_same() {
use partition::BlockSize;
use partition::BlockSize::*;
let blocks: Vec<(BlockSize, u32)> = vec![
(BLOCK_4X4, 1912),
(BLOCK_4X8, 3496),
......
......@@ -12,7 +12,11 @@
use self::BlockSize::*;
use self::TxSize::*;
use context::*;
use encoder::{ChromaSampling, FrameInvariants};
use plane::*;
use predict::*;
use util::*;
pub const NONE_FRAME: usize = 8;
pub const INTRA_FRAME: usize = 0;
......@@ -856,11 +860,6 @@ pub enum MvJointType {
MV_JOINT_HNZVNZ = 3 /* Both components nonzero */
}
use context::*;
use plane::*;
use predict::*;
use util::*;
impl PredictionMode {
pub fn predict_intra<'a>(
self, dst: &'a mut PlaneMutSlice<'a>, tx_size: TxSize, bit_depth: usize,
......
......@@ -9,6 +9,8 @@
#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))]
use std::iter::FusedIterator;
use util::*;
/// Plane-specific configuration.
......@@ -331,7 +333,6 @@ impl<'a> Iterator for IterWidth<'a> {
impl<'a> ExactSizeIterator for IterWidth<'a> { }
use std::iter::FusedIterator;
impl<'a> FusedIterator for IterWidth<'a> { }
impl<'a> PlaneSlice<'a> {
......
......@@ -11,22 +11,20 @@
#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))]
#![cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
#[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
use libc;
use num_traits::*;
use context::INTRA_MODES;
use context::MAX_TX_SIZE;
use context::{INTRA_MODES, MAX_TX_SIZE};
use partition::*;
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")]
use std::arch::x86::*;
#[cfg(target_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] = &[
PredictionMode::DC_PRED,
......@@ -767,6 +765,7 @@ pub trait Inter: Dim {}
pub mod test {
use super::*;
use rand::{ChaChaRng, Rng, SeedableRng};
use util::*;
const MAX_ITER: usize = 50000;
......@@ -1010,7 +1009,6 @@ pub mod test {
#[test]
fn pred_matches_u8() {
use util::*;
let mut edge_buf: AlignedArray<[u8; 2 * MAX_TX_SIZE + 1]> =
UninitializedAlignedArray();
for i in 0..edge_buf.array.len() {
......
......@@ -11,6 +11,7 @@
#![allow(non_upper_case_globals)]
use partition::TxSize;
use std::mem;
pub fn get_log_tx_scale(tx_size: TxSize) -> i32 {
......@@ -90,6 +91,7 @@ fn divu_pair(x: i32, d: (u32, u32, u32)) -> i32 {
mod test {
use super::*;
use partition::TxSize::*;
#[test]
fn test_divu_pair() {
for d in 1..1024 {
......
......@@ -11,34 +11,31 @@
#![allow(non_camel_case_types)]
#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))]
use api::PredictionModesSetting;
use cdef::*;
use context::*;
use me::*;
use ec::OD_BITRES;
use ec::Writer;
use ec::WriterCounter;
use luma_ac;
use ec::{OD_BITRES, Writer, WriterCounter};
use encoder::{ChromaSampling, ReferenceMode};
use encode_block_a;
use encode_block_b;
use Frame;
use FrameInvariants;
use FrameState;
use FrameType;
use luma_ac;
use me::*;
use motion_compensate;
use partition::*;
use plane::*;
use cdef::*;
use predict::{RAV1E_INTRA_MODES, RAV1E_INTRA_MODES_MINIMAL, RAV1E_INTER_MODES_MINIMAL, RAV1E_INTER_COMPOUND_MODES};
use quantize::dc_q;
use std;
use std::f64;
use std::vec::Vec;
use Sequence;
use Tune;
use write_tx_blocks;
use write_tx_tree;
use partition::BlockSize;
use Frame;
use FrameInvariants;
use FrameState;
use FrameType;
use Tune;
use Sequence;
use encoder::{ChromaSampling, ReferenceMode};
use api::PredictionModesSetting;
use std;
use std::vec::Vec;
#[derive(Clone)]
pub struct RDOOutput {
......
use encoder::Frame;
use api::FrameInfo;
use encoder::Frame;
use std::sync::Arc;
/// Detects fast cuts using changes in colour and intensity between frames.
......
......@@ -15,10 +15,10 @@
include!(concat!(env!("OUT_DIR"), "/aom.rs"));
use super::*;
use rand::{ChaChaRng, Rng, SeedableRng};
use std::{mem, ptr, slice};
use std::collections::VecDeque;
use std::mem;
use std::ffi::CStr;
use std::sync::Arc;
fn fill_frame(ra: &mut ChaChaRng, frame: &mut Frame) {
......@@ -225,7 +225,6 @@ fn compare_plane<T: Ord + std::fmt::Debug>(
}
fn compare_img(img: *const aom_image_t, frame: &Frame, bit_depth: usize, width: usize, height: usize) {
use std::slice;
let img = unsafe { *img };
let img_iter = img.planes.iter().zip(img.stride.iter());
......@@ -270,7 +269,6 @@ fn encode_decode(
w: usize, h: usize, speed: usize, quantizer: usize, limit: usize,
bit_depth: usize, min_keyint: u64, max_keyint: u64, low_latency: bool
) {
use std::ptr;
let mut ra = ChaChaRng::from_seed([0; 32]);
let mut dec = setup_decoder(w, h);
......@@ -313,7 +311,6 @@ fn encode_decode(
);
println!("Decoded. -> {}", ret);
if ret != 0 {
use std::ffi::CStr;
let error_msg = aom_codec_error(&mut dec.dec);
println!(
" Decode codec_decode failed: {}",
......@@ -345,7 +342,6 @@ fn encode_decode(
&mut corrupted
);
if ret != 0 {
use std::ffi::CStr;
let detail = aom_codec_error_detail(&mut dec.dec);
panic!(
"Decode codec_control failed {}",
......
......@@ -8,12 +8,10 @@
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.
use super::*;
use partition::{TxSize, TxType};
use std::cmp;
use partition::TxSize;
use partition::TxType;
const MAX_TXFM_STAGE_NUM: usize = 12;
const MAX_TXWH_IDX: usize = 5;
......
......@@ -8,11 +8,11 @@
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.
use super::*;
use std::cmp;
use util::clamp;
use num_traits::*;
use partition::TxType;
use util::clamp;
use std::cmp;
static COSPI_INV: [i32; 64] = [
4096, 4095, 4091, 4085, 4076, 4065, 4052, 4036, 4017, 3996, 3973, 3948,
......
......@@ -7,17 +7,12 @@
// 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.
use partition::TxSize;
use partition::TxType;
use partition::TX_TYPES;
use util::*;
pub use self::forward::*;
pub use self::inverse::*;
// Blocks
use partition::{TxSize, TxType, TX_TYPES};
use predict::*;
use util::*;
mod forward;
mod inverse;
......
......@@ -7,6 +7,12 @@
// 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.
use num_traits::*;
use std::mem;
use std::mem::size_of;
#[allow(deprecated, unused_imports)]
use ::std::ascii::AsciiExt;
// Imported from clap, to avoid to depend directly to the crate
macro_rules! _clap_count_exprs {
() => { 0 };
......@@ -23,8 +29,6 @@ macro_rules! arg_enum {
type Err = String;
fn from_str(s: &str) -> ::std::result::Result<Self,Self::Err> {
#[allow(deprecated, unused_imports)]
use ::std::ascii::AsciiExt;
match s {
$(stringify!($v) |
_ if s.eq_ignore_ascii_case(stringify!($v)) => Ok($e::$v)),+,
......@@ -156,7 +160,6 @@ pub fn AlignedArray<ARRAY>(array: ARRAY) -> AlignedArray<ARRAY> {
#[allow(non_snake_case)]
pub fn UninitializedAlignedArray<ARRAY>() -> AlignedArray<ARRAY> {
use std::mem;
AlignedArray(unsafe { mem::uninitialized() })
}
......@@ -207,9 +210,6 @@ pub fn clamp<T: PartialOrd>(input: T, min: T, max: T) -> T {
}
}
use num_traits::*;
use std::mem::size_of;
pub trait Pixel: PrimInt + Into<u32> + Into<i32> + AsPrimitive<i32> + 'static {}
impl Pixel for u8 {}
impl Pixel for u16 {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment