Consolidate import style in rustfmt.toml (#619)

This commit is contained in:
redzic 2022-04-20 21:24:55 +01:00 committed by GitHub
parent fc4bf94278
commit 270b3ba3cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 188 additions and 218 deletions

View file

@ -1,31 +1,24 @@
use ::ffmpeg::format::Pixel;
use ansi_term::{Color, Style};
use anyhow::{anyhow, Context};
use anyhow::{bail, ensure};
use av1an_core::progress_bar::{get_first_multi_progress_bar, get_progress_bar};
use av1an_core::settings::{InputPixelFormat, PixelFormat};
use av1an_core::util::read_in_dir;
use av1an_core::ScenecutMethod;
use av1an_core::{ffmpeg, into_vec};
use av1an_core::{ChunkOrdering, Input};
use flexi_logger::writers::LogWriter;
use flexi_logger::{FileSpec, Level, LevelFilter, LogSpecBuilder, Logger};
use path_abs::{PathAbs, PathInfo};
use std::io::{self, Write}; use std::io::{self, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::exit; use std::process::exit;
use clap::{AppSettings, Parser}; use ::ffmpeg::format::Pixel;
use ansi_term::{Color, Style};
use anyhow::{anyhow, bail, ensure, Context};
use av1an_core::concat::ConcatMethod;
use av1an_core::encoder::Encoder;
use av1an_core::progress_bar::{get_first_multi_progress_bar, get_progress_bar};
use av1an_core::settings::{EncodeArgs, InputPixelFormat, PixelFormat};
use av1an_core::util::read_in_dir;
use av1an_core::{ use av1an_core::{
encoder::Encoder, ffmpeg, hash_path, into_vec, vapoursynth, ChunkMethod, ChunkOrdering, Input, ScenecutMethod,
hash_path, SplitMethod, Verbosity,
settings::EncodeArgs,
vapoursynth, Verbosity,
{concat::ConcatMethod, ChunkMethod, SplitMethod},
}; };
use clap::{AppSettings, Parser};
use flexi_logger::writers::LogWriter;
use flexi_logger::{FileSpec, Level, LevelFilter, LogSpecBuilder, Logger};
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use path_abs::{PathAbs, PathInfo};
// needs to be static, runtime allocated string to avoid evil hacks to // needs to be static, runtime allocated string to avoid evil hacks to
// concatenate non-trivial strings at compile-time // concatenate non-trivial strings at compile-time

View file

@ -1,28 +1,25 @@
use crate::progress_bar::update_progress_bar_estimates; use std::fmt::{Debug, Display};
use crate::util::printable_base10_digits; use std::fs::File;
use crate::DoneChunk; use std::io::Write;
use crate::{ use std::path::Path;
finish_multi_progress_bar, finish_progress_bar, get_done, use std::process::ExitStatus;
progress_bar::{dec_bar, dec_mp_bar},
settings::EncodeArgs,
Chunk, Encoder, Instant, TargetQuality, Verbosity,
};
use std::sync::atomic::{self, AtomicU64}; use std::sync::atomic::{self, AtomicU64};
use std::sync::mpsc::Sender;
use std::sync::Arc; use std::sync::Arc;
use std::{
fmt::{Debug, Display},
fs::File,
io::Write,
path::Path,
process::ExitStatus,
sync::mpsc::Sender,
};
use cfg_if::cfg_if; use cfg_if::cfg_if;
use memchr::memmem; use memchr::memmem;
use smallvec::SmallVec; use smallvec::SmallVec;
use thiserror::Error; use thiserror::Error;
use crate::progress_bar::{dec_bar, dec_mp_bar, update_progress_bar_estimates};
use crate::settings::EncodeArgs;
use crate::util::printable_base10_digits;
use crate::{
finish_multi_progress_bar, finish_progress_bar, get_done, Chunk, DoneChunk, Encoder, Instant,
TargetQuality, Verbosity,
};
pub struct Broker<'a> { pub struct Broker<'a> {
pub max_tries: usize, pub max_tries: usize,
pub chunk_queue: Vec<Chunk>, pub chunk_queue: Vec<Chunk>,

View file

@ -1,6 +1,9 @@
use crate::scenes::ZoneOptions; use std::ffi::OsString;
use std::path::Path;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{ffi::OsString, path::Path};
use crate::scenes::ZoneOptions;
#[derive(Debug, Clone, Default, Serialize, Deserialize)] #[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Chunk { pub struct Chunk {

View file

@ -1,25 +1,21 @@
use std::fmt::{Display, Write as FmtWrite};
use std::fs::{self, DirEntry, File};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::sync::Arc;
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use av_format::{ use av_format::buffer::AccReader;
buffer::AccReader, use av_format::demuxer::{Context as DemuxerContext, Event};
demuxer::{Context as DemuxerContext, Event}, use av_format::muxer::Context as MuxerContext;
muxer::Context as MuxerContext, use av_ivf::demuxer::IvfDemuxer;
}; use av_ivf::muxer::IvfMuxer;
use av_ivf::{demuxer::IvfDemuxer, muxer::IvfMuxer}; use path_abs::{PathAbs, PathInfo};
use path_abs::PathAbs;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{
fmt::Display,
fmt::Write as FmtWrite,
fs::{self, DirEntry, File},
io::Write,
path::{Path, PathBuf},
process::{Command, Stdio},
sync::Arc,
};
use path_abs::PathInfo; use crate::encoder::Encoder;
use crate::util::read_in_dir;
use crate::{encoder::Encoder, util::read_in_dir};
#[derive( #[derive(
PartialEq, Eq, Copy, Clone, Serialize, Deserialize, Debug, strum::EnumString, strum::IntoStaticStr, PartialEq, Eq, Copy, Clone, Serialize, Deserialize, Debug, strum::EnumString, strum::IntoStaticStr,

View file

@ -1,14 +1,20 @@
use crate::{ffmpeg::compose_ffmpeg_pipe, inplace_vec, into_array, into_vec, list_index}; use std::borrow::Cow;
use std::cmp;
use std::fmt::Display;
use std::iter::Iterator;
use std::path::PathBuf;
use std::process::Command;
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use cfg_if::cfg_if; use cfg_if::cfg_if;
use ffmpeg::format::Pixel; use ffmpeg::format::Pixel;
use itertools::chain; use itertools::chain;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{borrow::Cow, cmp, fmt::Display, path::PathBuf, process::Command};
use thiserror::Error; use thiserror::Error;
use std::iter::Iterator; use crate::ffmpeg::compose_ffmpeg_pipe;
use crate::{inplace_vec, into_array, into_vec, list_index};
const NULL: &str = if cfg!(windows) { "nul" } else { "/dev/null" }; const NULL: &str = if cfg!(windows) { "nul" } else { "/dev/null" };

View file

@ -1,15 +1,14 @@
use crate::{into_array, into_vec}; use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use ffmpeg::color::TransferCharacteristic; use ffmpeg::color::TransferCharacteristic;
use ffmpeg::format::{input, Pixel}; use ffmpeg::format::{input, Pixel};
use ffmpeg::media::Type as MediaType; use ffmpeg::media::Type as MediaType;
use ffmpeg::Error::StreamNotFound; use ffmpeg::Error::StreamNotFound;
use path_abs::{PathAbs, PathInfo}; use path_abs::{PathAbs, PathInfo};
use std::path::PathBuf;
use std::{ use crate::{into_array, into_vec};
ffi::OsStr,
path::Path,
process::{Command, Stdio},
};
pub fn compose_ffmpeg_pipe<S: Into<String>>( pub fn compose_ffmpeg_pipe<S: Into<String>>(
params: impl IntoIterator<Item = S>, params: impl IntoIterator<Item = S>,

View file

@ -1,8 +1,6 @@
use std::{ use std::fs::File;
fs::File, use std::io::{BufWriter, Write};
io::{BufWriter, Write}, use std::path::Path;
path::Path,
};
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct NoiseGenArgs { pub struct NoiseGenArgs {

View file

@ -20,11 +20,17 @@
#[macro_use] #[macro_use]
extern crate log; extern crate log;
use crate::{ use std::cmp::max;
encoder::Encoder, use std::collections::hash_map::DefaultHasher;
progress_bar::{finish_multi_progress_bar, finish_progress_bar}, use std::fs;
target_quality::TargetQuality, use std::fs::File;
}; use std::hash::{Hash, Hasher};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::string::ToString;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::time::Instant;
use ::ffmpeg::color::TransferCharacteristic; use ::ffmpeg::color::TransferCharacteristic;
use anyhow::Context; use anyhow::Context;
use chunk::Chunk; use chunk::Chunk;
@ -32,21 +38,12 @@ use dashmap::DashMap;
use grain::TransferFunction; use grain::TransferFunction;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{ use strum::{Display, EnumString, IntoStaticStr};
cmp::max,
collections::hash_map::DefaultHasher,
fs,
fs::File,
hash::{Hash, Hasher},
io::Write,
path::{Path, PathBuf},
string::ToString,
sync::atomic::{AtomicBool, AtomicUsize},
time::Instant,
};
use sysinfo::SystemExt; use sysinfo::SystemExt;
use strum::{Display, EnumString, IntoStaticStr}; use crate::encoder::Encoder;
use crate::progress_bar::{finish_multi_progress_bar, finish_progress_bar};
use crate::target_quality::TargetQuality;
pub mod broker; pub mod broker;
pub mod chunk; pub mod chunk;

View file

@ -4,7 +4,8 @@
//! runtime detection that the corresponding feature //! runtime detection that the corresponding feature
//! set is available before calling them. //! set is available before calling them.
use std::{borrow::Cow, collections::HashSet}; use std::borrow::Cow;
use std::collections::HashSet;
use crate::encoder::Encoder; use crate::encoder::Encoder;
@ -78,7 +79,6 @@ pub unsafe fn parse_aom_vpx_frames_sse41(s: &[u8]) -> Option<u64> {
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::transmute; use std::mem::transmute;
// This implementation matches the *second* number in the output. Ex: // This implementation matches the *second* number in the output. Ex:

View file

@ -1,10 +1,8 @@
use crate::get_done; use indicatif::{HumanBytes, MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
use crate::Verbosity;
use indicatif::HumanBytes;
use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use crate::util::printable_base10_digits; use crate::util::printable_base10_digits;
use crate::{get_done, Verbosity};
const INDICATIF_PROGRESS_TEMPLATE: &str = if cfg!(windows) { const INDICATIF_PROGRESS_TEMPLATE: &str = if cfg!(windows) {
// Do not use a spinner on Windows since the default console cannot display // Do not use a spinner on Windows since the default console cannot display

View file

@ -1,15 +1,16 @@
use crate::scenes::Scene; use std::io::Read;
use crate::Encoder; use std::process::{Command, Stdio};
use crate::{into_smallvec, progress_bar, Input, ScenecutMethod, Verbosity}; use std::thread;
use ansi_term::Style; use ansi_term::Style;
use anyhow::bail; use anyhow::bail;
use av_scenechange::{detect_scene_changes, DetectionOptions, SceneDetectionSpeed}; use av_scenechange::{detect_scene_changes, DetectionOptions, SceneDetectionSpeed};
use ffmpeg::format::Pixel; use ffmpeg::format::Pixel;
use itertools::Itertools; use itertools::Itertools;
use smallvec::{smallvec, SmallVec}; use smallvec::{smallvec, SmallVec};
use std::io::Read;
use std::process::{Command, Stdio}; use crate::scenes::Scene;
use std::thread; use crate::{into_smallvec, progress_bar, Encoder, Input, ScenecutMethod, Verbosity};
pub fn av_scenechange_detect( pub fn av_scenechange_detect(
input: &Input, input: &Input,

View file

@ -1,8 +1,8 @@
use crate::parse::valid_params; use std::collections::HashMap;
use crate::settings::{invalid_params, suggest_fix, EncodeArgs}; use std::process::{exit, Command};
use crate::Encoder; use std::str::FromStr;
use anyhow::Result;
use anyhow::{anyhow, bail}; use anyhow::{anyhow, bail, Result};
use itertools::Itertools; use itertools::Itertools;
use nom::branch::alt; use nom::branch::alt;
use nom::bytes::complete::{tag, take_till, take_while}; use nom::bytes::complete::{tag, take_till, take_while};
@ -11,9 +11,10 @@ use nom::combinator::{map, map_res, opt, recognize, rest};
use nom::multi::{many1, separated_list0}; use nom::multi::{many1, separated_list0};
use nom::sequence::{preceded, tuple}; use nom::sequence::{preceded, tuple};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::process::{exit, Command}; use crate::parse::valid_params;
use std::str::FromStr; use crate::settings::{invalid_params, suggest_fix, EncodeArgs};
use crate::Encoder;
#[derive(Deserialize, Serialize, Debug, Clone)] #[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Scene { pub struct Scene {
@ -248,11 +249,10 @@ fn get_test_args() -> EncodeArgs {
use ffmpeg::format::Pixel; use ffmpeg::format::Pixel;
use crate::concat::ConcatMethod;
use crate::settings::{InputPixelFormat, PixelFormat};
use crate::{ use crate::{
concat::ConcatMethod, into_vec, ChunkMethod, ChunkOrdering, Input, ScenecutMethod, SplitMethod, Verbosity,
into_vec,
settings::{InputPixelFormat, PixelFormat},
ChunkMethod, ChunkOrdering, Input, ScenecutMethod, SplitMethod, Verbosity,
}; };
EncodeArgs { EncodeArgs {

View file

@ -1,63 +1,47 @@
use crate::ffmpeg::num_frames; use std::borrow::{Borrow, Cow};
use crate::grain::create_film_grain_file; use std::cmp::{Ordering, Reverse};
use crate::parse::valid_params; use std::collections::{BTreeSet, HashSet};
use crate::progress_bar::{reset_bar_at, reset_mp_bar_at}; use std::convert::TryInto;
use crate::progress_bar::{update_mp_chunk, update_progress_bar_estimates}; use std::ffi::OsString;
use crate::vapoursynth::{is_ffms2_installed, is_lsmash_installed}; use std::fs::File;
use crate::ChunkOrdering; use std::io::Write;
use crate::{ use std::path::{Path, PathBuf};
broker::{Broker, EncoderCrash}, use std::process::{exit, Command, Stdio};
chunk::Chunk, use std::sync::atomic::{self, AtomicBool, AtomicU64, AtomicUsize};
concat::{self, ConcatMethod}, use std::sync::{mpsc, Arc};
create_dir, determine_workers, use std::{cmp, fs, iter, thread};
ffmpeg::compose_ffmpeg_pipe,
finish_multi_progress_bar, get_done, init_done, into_vec, use ansi_term::{Color, Style};
progress_bar::{
finish_progress_bar, inc_bar, inc_mp_bar, init_multi_progress_bar, init_progress_bar,
update_mp_msg,
},
read_chunk_queue, save_chunk_queue,
scene_detect::av_scenechange_detect,
split::{extra_splits, segment, write_scenes_to_file},
vapoursynth::create_vs_file,
vmaf::{self, validate_libvmaf},
ChunkMethod, DashMap, DoneJson, Encoder, Input, ScenecutMethod, SplitMethod, TargetQuality,
Verbosity,
};
use anyhow::{bail, ensure, Context}; use anyhow::{bail, ensure, Context};
use crossbeam_utils; use crossbeam_utils;
use ffmpeg::format::Pixel; use ffmpeg::format::Pixel;
use itertools::Itertools; use itertools::Itertools;
use rand::prelude::SliceRandom; use rand::prelude::SliceRandom;
use rand::thread_rng; use rand::thread_rng;
use std::borrow::Borrow;
use std::cmp::Ordering;
use std::collections::BTreeSet;
use std::sync::atomic::AtomicUsize;
use std::thread;
use std::{
borrow::Cow,
cmp,
cmp::Reverse,
collections::HashSet,
convert::TryInto,
ffi::OsString,
fs,
fs::File,
io::Write,
iter,
path::{Path, PathBuf},
process::{exit, Command, Stdio},
sync::atomic::{self, AtomicBool, AtomicU64},
sync::{mpsc, Arc},
};
use ansi_term::{Color, Style};
use crate::scenes::{Scene, ZoneOptions};
use tokio::io::{AsyncBufReadExt, BufReader}; use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::process::ChildStderr; use tokio::process::ChildStderr;
use crate::broker::{Broker, EncoderCrash};
use crate::chunk::Chunk;
use crate::concat::{self, ConcatMethod};
use crate::ffmpeg::{compose_ffmpeg_pipe, num_frames};
use crate::grain::create_film_grain_file;
use crate::parse::valid_params;
use crate::progress_bar::{
finish_progress_bar, inc_bar, inc_mp_bar, init_multi_progress_bar, init_progress_bar,
reset_bar_at, reset_mp_bar_at, update_mp_chunk, update_mp_msg, update_progress_bar_estimates,
};
use crate::scene_detect::av_scenechange_detect;
use crate::scenes::{Scene, ZoneOptions};
use crate::split::{extra_splits, segment, write_scenes_to_file};
use crate::vapoursynth::{create_vs_file, is_ffms2_installed, is_lsmash_installed};
use crate::vmaf::{self, validate_libvmaf};
use crate::{
create_dir, determine_workers, finish_multi_progress_bar, get_done, init_done, into_vec,
read_chunk_queue, save_chunk_queue, ChunkMethod, ChunkOrdering, DashMap, DoneJson, Encoder,
Input, ScenecutMethod, SplitMethod, TargetQuality, Verbosity,
};
pub struct PixelFormat { pub struct PixelFormat {
pub format: Pixel, pub format: Pixel,
pub bit_depth: usize, pub bit_depth: usize,

View file

@ -1,14 +1,14 @@
use crate::scenes::Scene; use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
use std::process::{Command, Stdio};
use std::string::ToString;
use anyhow::Context; use anyhow::Context;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{
fs::File, use crate::scenes::Scene;
io::prelude::*,
io::BufReader,
path::Path,
process::{Command, Stdio},
string::ToString,
};
pub fn segment(input: impl AsRef<Path>, temp: impl AsRef<Path>, segments: &[usize]) { pub fn segment(input: impl AsRef<Path>, temp: impl AsRef<Path>, segments: &[usize]) {
let input = input.as_ref(); let input = input.as_ref();
@ -139,9 +139,10 @@ pub fn read_scenes_from_file(scene_path: &Path) -> anyhow::Result<(Vec<Scene>, u
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{encoder::Encoder, into_vec, scenes::ZoneOptions};
use super::*; use super::*;
use crate::encoder::Encoder;
use crate::into_vec;
use crate::scenes::ZoneOptions;
#[test] #[test]
fn test_extra_split_no_segments() { fn test_extra_split_no_segments() {

View file

@ -1,20 +1,18 @@
use crate::{ use std::cmp;
broker::EncoderCrash, use std::cmp::Ordering;
chunk::Chunk, use std::convert::TryInto;
settings::EncodeArgs, use std::fmt::Error;
vmaf::{self, read_weighted_vmaf}, use std::path::{Path, PathBuf};
Encoder, use std::process::Stdio;
};
use ffmpeg::format::Pixel; use ffmpeg::format::Pixel;
use splines::{Interpolation, Key, Spline}; use splines::{Interpolation, Key, Spline};
use std::{
cmp, use crate::broker::EncoderCrash;
cmp::Ordering, use crate::chunk::Chunk;
convert::TryInto, use crate::settings::EncodeArgs;
fmt::Error, use crate::vmaf::{self, read_weighted_vmaf};
path::{Path, PathBuf}, use crate::Encoder;
process::Stdio,
};
const VMAF_PERCENTILE: f64 = 0.25; const VMAF_PERCENTILE: f64 = 0.25;

View file

@ -1,18 +1,15 @@
use std::{ use std::collections::HashSet;
collections::HashSet, use std::fs::File;
fs::File, use std::io::Write;
io::Write, use std::path::{Path, PathBuf};
path::{Path, PathBuf},
};
use vapoursynth::video_info::VideoInfo;
use once_cell::sync::Lazy;
use super::ChunkMethod;
use path_abs::PathAbs;
use vapoursynth::prelude::*;
use anyhow::{anyhow, bail}; use anyhow::{anyhow, bail};
use once_cell::sync::Lazy;
use path_abs::PathAbs;
use vapoursynth::prelude::*;
use vapoursynth::video_info::VideoInfo;
use super::ChunkMethod;
static VAPOURSYNTH_PLUGINS: Lazy<HashSet<String>> = Lazy::new(|| { static VAPOURSYNTH_PLUGINS: Lazy<HashSet<String>> = Lazy::new(|| {
let environment = Environment::new().expect("Failed to initialize VapourSynth environment"); let environment = Environment::new().expect("Failed to initialize VapourSynth environment");

View file

@ -1,18 +1,17 @@
use crate::broker::EncoderCrash; use std::cmp::Ordering;
use crate::util::printable_base10_digits; use std::ffi::OsStr;
use crate::{ffmpeg, ref_smallvec, Input}; use std::path::Path;
use anyhow::anyhow; use std::process::{Command, Stdio};
use anyhow::Context; use std::usize;
use anyhow::{anyhow, Context};
use plotters::prelude::*; use plotters::prelude::*;
use serde::Deserialize; use serde::Deserialize;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{
cmp::Ordering, use crate::broker::EncoderCrash;
ffi::OsStr, use crate::util::printable_base10_digits;
path::Path, use crate::{ffmpeg, ref_smallvec, Input};
process::{Command, Stdio},
usize,
};
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
struct VmafScore { struct VmafScore {

View file

@ -1,2 +1,5 @@
edition = "2021" edition = "2021"
tab_spaces = 2 tab_spaces = 2
reorder_imports = true
group_imports = "StdExternalCrate"
imports_granularity = "Module"