Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various dependency updates and cleanup #679

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
696 changes: 390 additions & 306 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = "https://github.com/master-of-zen/Av1an"
keywords = ["video"]
categories = ["command-line-utilities"]
license = "GPL-3.0"
rust-version = "1.59"
rust-version = "1.63"
edition = "2021"

[[bin]]
Expand Down Expand Up @@ -48,5 +48,5 @@ debug-assertions = true
overflow-checks = true

[patch.crates-io]
av-scenechange = { git = "https://github.com/rust-av/av-scenechange", rev = "4804462f2b6ae6209609cd95b5d9739264bf614f" }
av-scenechange = { git = "https://github.com/rust-av/av-scenechange", rev = "2f91ec1b4224dccc7195bdabefdfa171e981ca60" }
console = { git = "https://github.com/console-rs/console", rev = "5484ea9d9f6884f6685349708e27bf08fab7703c" }
2 changes: 1 addition & 1 deletion av1an-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = "https://github.com/master-of-zen/Av1an"
keywords = ["video"]
categories = ["command-line-utilities"]
license = "GPL-3.0"
rust-version = "1.59"
rust-version = "1.63"
edition = "2021"

[dependencies]
Expand Down
12 changes: 6 additions & 6 deletions av1an-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "av1an-core"
version = "0.3.2"
rust-version = "1.59"
rust-version = "1.63"
edition = "2021"
authors = ["Zen <[email protected]>"]
description = """
Expand All @@ -18,9 +18,9 @@ license = "GPL-3.0"
log = "0.4.14"
arrayvec = "0.7.2"
atty = "0.2.14"
av-format = "0.3.1"
av-ivf = "0.2.2"
av1-grain = { version = "0.1.1", default-features = false, features = [
av-format = "0.7.0"
av-ivf = "0.5.0"
av1-grain = { version = "0.2.1", default-features = false, features = [
"create",
] }
memchr = "2.4.1"
Expand All @@ -30,7 +30,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sysinfo = "0.23.0"
splines = "4.0.0"
indicatif = "=0.17.0-rc.4"
indicatif = "0.17.2"
once_cell = "1.8.0"
strum = { version = "0.24.0", features = ["derive"] }
itertools = "0.10.1"
Expand All @@ -40,7 +40,7 @@ crossbeam-channel = "0.5.1"
crossbeam-utils = "0.8.5"
textwrap = "0.15.0"
path_abs = "0.5.1"
av-scenechange = { version = "0.7.2", default-features = false }
av-scenechange = { version = "0.8.0", default-features = false }
y4m = "0.7.0"
thiserror = "1.0.30"
paste = "1.0.5"
Expand Down
2 changes: 1 addition & 1 deletion av1an-core/src/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl<'a> Broker<'a> {
worker_id: usize,
frame_rate: f64,
audio_size_bytes: Arc<AtomicU64>,
) -> Result<(), EncoderCrash> {
) -> Result<(), Box<EncoderCrash>> {
let st_time = Instant::now();

// space padding at the beginning to align with "finished chunk"
Expand Down
12 changes: 6 additions & 6 deletions av1an-core/src/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::Arc;
use anyhow::{anyhow, Context};
use av_format::buffer::AccReader;
use av_format::demuxer::{Context as DemuxerContext, Event};
use av_format::muxer::Context as MuxerContext;
use av_format::muxer::{Context as MuxerContext, Writer};
use av_ivf::demuxer::IvfDemuxer;
use av_ivf::muxer::IvfMuxer;
use path_abs::{PathAbs, PathInfo};
Expand Down Expand Up @@ -57,11 +57,11 @@ pub fn ivf(input: &Path, out: &Path) -> anyhow::Result<()> {

let output = File::create(out)?;

let mut muxer = MuxerContext::new(Box::new(IvfMuxer::new()), Box::new(output));
let mut muxer = MuxerContext::new(IvfMuxer::new(), Writer::new(output));

let global_info = {
let acc = AccReader::new(std::fs::File::open(&files[0]).unwrap());
let mut demuxer = DemuxerContext::new(Box::new(IvfDemuxer::new()), Box::new(acc));
let mut demuxer = DemuxerContext::new(IvfDemuxer::new(), acc);

demuxer.read_headers().unwrap();

Expand All @@ -72,7 +72,7 @@ pub fn ivf(input: &Path, out: &Path) -> anyhow::Result<()> {
.skip(1)
.filter_map(|file| {
let acc = AccReader::new(std::fs::File::open(file).unwrap());
let mut demuxer = DemuxerContext::new(Box::new(IvfDemuxer::new()), Box::new(acc));
let mut demuxer = DemuxerContext::new(IvfDemuxer::new(), acc);

demuxer.read_headers().unwrap();
demuxer.info.duration
Expand All @@ -96,7 +96,7 @@ pub fn ivf(input: &Path, out: &Path) -> anyhow::Result<()> {

let acc = AccReader::new(input);

let mut demuxer = DemuxerContext::new(Box::new(IvfDemuxer::new()), Box::new(acc));
let mut demuxer = DemuxerContext::new(IvfDemuxer::new(), acc);
demuxer.read_headers()?;

trace!("global info: {:#?}", demuxer.info);
Expand Down Expand Up @@ -138,7 +138,7 @@ pub fn ivf(input: &Path, out: &Path) -> anyhow::Result<()> {

fn read_encoded_chunks(encode_dir: &Path) -> anyhow::Result<Vec<DirEntry>> {
Ok(
fs::read_dir(&encode_dir)
fs::read_dir(encode_dir)
.with_context(|| format!("Failed to read encoded chunks from {:?}", &encode_dir))?
.collect::<Result<Vec<_>, _>>()?,
)
Expand Down
61 changes: 41 additions & 20 deletions av1an-core/src/progress_bar.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use indicatif::{HumanBytes, MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
use std::fmt::Write;
use std::time::Duration;

use indicatif::{
HumanBytes, MultiProgress, ProgressBar, ProgressDrawTarget, ProgressState, ProgressStyle,
};
use once_cell::sync::OnceCell;

use crate::util::printable_base10_digits;
Expand Down Expand Up @@ -31,27 +36,39 @@ pub fn get_progress_bar() -> Option<&'static ProgressBar> {
fn pretty_progress_style() -> ProgressStyle {
ProgressStyle::default_bar()
.template(INDICATIF_PROGRESS_TEMPLATE)
.with_key("fps", |state| match state.per_sec() {
fps if fps.abs() < f64::EPSILON => "0 fps".into(),
fps if fps < 1.0 => format!("{:.2} s/fr", 1.0 / fps),
fps => format!("{:.2} fps", fps),
.unwrap()
.with_key(
"fps",
|state: &ProgressState, w: &mut dyn Write| match state.per_sec() {
fps if fps.abs() < f64::EPSILON => write!(w, "0 fps").unwrap(),
fps if fps < 1.0 => write!(w, "{:.2} s/fr", 1.0 / fps).unwrap(),
fps => write!(w, "{:.2} fps", fps).unwrap(),
},
)
.with_key("pos", |state: &ProgressState, w: &mut dyn Write| {
write!(w, "{}/{}", state.pos(), state.len().unwrap_or(0)).unwrap();
})
.with_key("pos", |state| format!("{}/{}", state.pos, state.len))
.with_key("percent", |state| {
format!("{:>3.0}%", state.fraction() * 100_f32)
.with_key("percent", |state: &ProgressState, w: &mut dyn Write| {
write!(w, "{:>3.0}%", state.fraction() * 100_f32).unwrap();
})
.progress_chars(PROGRESS_CHARS)
}

fn spinner_style() -> ProgressStyle {
ProgressStyle::default_spinner()
.template(INDICATIF_SPINNER_TEMPLATE)
.with_key("fps", |state| match state.per_sec() {
fps if fps.abs() < f64::EPSILON => "0 fps".into(),
fps if fps < 1.0 => format!("{:.2} s/fr", 1.0 / fps),
fps => format!("{:.2} fps", fps),
.unwrap()
.with_key(
"fps",
|state: &ProgressState, w: &mut dyn Write| match state.per_sec() {
fps if fps.abs() < f64::EPSILON => write!(w, "0 fps").unwrap(),
fps if fps < 1.0 => write!(w, "{:.2} s/fr", 1.0 / fps).unwrap(),
fps => write!(w, "{:.2} fps", fps).unwrap(),
},
)
.with_key("pos", |state: &ProgressState, w: &mut dyn Write| {
write!(w, "{}", state.pos()).unwrap();
})
.with_key("pos", |state| format!("{}", state.pos))
.progress_chars(PROGRESS_CHARS)
}

Expand All @@ -66,7 +83,7 @@ pub fn init_progress_bar(len: u64) {
PROGRESS_BAR.get_or_init(|| ProgressBar::new(len).with_style(spinner_style()))
};
pb.set_draw_target(ProgressDrawTarget::stderr_with_hz(60));
pb.enable_steady_tick(100);
pb.enable_steady_tick(Duration::from_millis(100));
pb.reset();
pb.reset_eta();
pb.reset_elapsed();
Expand Down Expand Up @@ -155,18 +172,22 @@ pub fn init_multi_progress_bar(len: u64, workers: usize, total_chunks: usize) {
for _ in 1..=workers {
let pb = ProgressBar::hidden()
// no spinner on windows, so we remove the prefix to line up with the progress bar
.with_style(ProgressStyle::default_spinner().template(if cfg!(windows) {
"{prefix:.dim} {msg}"
} else {
" {prefix:.dim} {msg}"
}));
.with_style(
ProgressStyle::default_spinner()
.template(if cfg!(windows) {
"{prefix:.dim} {msg}"
} else {
" {prefix:.dim} {msg}"
})
.unwrap(),
);
pb.set_prefix(format!("[Idle {width:width$}]", width = digits));
pbs.push(mpb.add(pb));
}

let pb = ProgressBar::hidden();
pb.set_style(pretty_progress_style());
pb.enable_steady_tick(100);
pb.enable_steady_tick(Duration::from_millis(100));
pb.reset_elapsed();
pb.reset_eta();
pb.set_position(0);
Expand Down
20 changes: 10 additions & 10 deletions av1an-core/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::{cmp, fs, iter, thread};

use ansi_term::{Color, Style};
use anyhow::{bail, ensure, Context};
use av1_grain::{generate_grain_params, write_grain_table, NoiseGenArgs, TransferFunction};
use av1_grain::{generate_photon_noise_params, write_grain_table, NoiseGenArgs, TransferFunction};
use crossbeam_utils;
use ffmpeg::format::Pixel;
use itertools::Itertools;
Expand Down Expand Up @@ -192,7 +192,7 @@ impl EncodeArgs {
}

fn read_queue_files(source_path: &Path) -> anyhow::Result<Vec<PathBuf>> {
let mut queue_files = fs::read_dir(&source_path)
let mut queue_files = fs::read_dir(source_path)
.with_context(|| {
format!(
"Failed to read queue files from source path {:?}",
Expand Down Expand Up @@ -220,7 +220,7 @@ impl EncodeArgs {
worker_id: usize,
padding: usize,
tpl_crash_workaround: bool,
) -> Result<(), (EncoderCrash, u64)> {
) -> Result<(), (Box<EncoderCrash>, u64)> {
update_mp_chunk(worker_id, chunk.index, padding);

let fpf_file = Path::new(&chunk.temp)
Expand Down Expand Up @@ -418,13 +418,13 @@ impl EncodeArgs {

if !enc_output.status.success() {
return Err((
EncoderCrash {
Box::new(EncoderCrash {
exit_status: enc_output.status,
source_pipe_stderr: source_pipe_stderr.into(),
ffmpeg_pipe_stderr: ffmpeg_pipe_stderr.map(Into::into),
stderr: enc_stderr.into(),
stdout: enc_output.stdout.into(),
},
}),
frame,
));
}
Expand All @@ -446,13 +446,13 @@ impl EncodeArgs {

if let Some(err_str) = err_str {
return Err((
EncoderCrash {
Box::new(EncoderCrash {
exit_status: enc_output.status,
source_pipe_stderr: source_pipe_stderr.into(),
ffmpeg_pipe_stderr: ffmpeg_pipe_stderr.map(Into::into),
stderr: enc_stderr.into(),
stdout: err_str.into(),
},
}),
frame,
));
}
Expand Down Expand Up @@ -751,7 +751,7 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin
fn parse_zones(&self) -> anyhow::Result<Vec<Scene>> {
let mut zones = Vec::new();
if let Some(ref zones_file) = self.zones {
let input = fs::read_to_string(&zones_file)?;
let input = fs::read_to_string(zones_file)?;
for zone_line in input.lines().map(str::trim).filter(|line| !line.is_empty()) {
zones.push(Scene::parse_from_zone(zone_line, self)?);
}
Expand Down Expand Up @@ -1154,7 +1154,7 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin
let transfer_function = self
.input
.transfer_function_params_adjusted(&self.video_params)?;
let params = generate_grain_params(
let params = generate_photon_noise_params(
0,
u64::MAX,
NoiseGenArgs {
Expand Down Expand Up @@ -1190,7 +1190,7 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin
let transfer_function = self
.input
.transfer_function_params_adjusted(&self.video_params)?;
let params = generate_grain_params(
let params = generate_photon_noise_params(
0,
u64::MAX,
NoiseGenArgs {
Expand Down
2 changes: 1 addition & 1 deletion av1an-core/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn segment(input: impl AsRef<Path>, temp: impl AsRef<Path>, segments: &[usiz
.collect::<Vec<String>>();
let segments_joined = segments_to_string.join(",");

cmd.args(&["-f", "segment", "-segment_frames", &segments_joined]);
cmd.args(["-f", "segment", "-segment_frames", &segments_joined]);
let split_path = Path::new(temp).join("split").join("%05d.mkv");
cmd.arg(split_path);
}
Expand Down
9 changes: 6 additions & 3 deletions av1an-core/src/target_quality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'a> TargetQuality<'a> {
}
}

fn per_shot_target_quality(&self, chunk: &Chunk) -> Result<u32, EncoderCrash> {
fn per_shot_target_quality(&self, chunk: &Chunk) -> Result<u32, Box<EncoderCrash>> {
let mut vmaf_cq = vec![];
let frames = chunk.frames;

Expand Down Expand Up @@ -165,7 +165,7 @@ impl<'a> TargetQuality<'a> {
Ok(q as u32)
}

fn vmaf_probe(&self, chunk: &Chunk, q: usize) -> Result<PathBuf, EncoderCrash> {
fn vmaf_probe(&self, chunk: &Chunk, q: usize) -> Result<PathBuf, Box<EncoderCrash>> {
let vmaf_threads = if self.vmaf_threads == 0 {
vmaf_auto_threads(self.workers)
} else {
Expand Down Expand Up @@ -283,7 +283,10 @@ impl<'a> TargetQuality<'a> {
Ok(fl_path)
}

pub fn per_shot_target_quality_routine(&self, chunk: &mut Chunk) -> Result<(), EncoderCrash> {
pub fn per_shot_target_quality_routine(
&self,
chunk: &mut Chunk,
) -> Result<(), Box<EncoderCrash>> {
chunk.tq_cq = Some(self.per_shot_target_quality(chunk)?);
Ok(())
}
Expand Down
6 changes: 2 additions & 4 deletions av1an-core/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,13 @@ pub(crate) fn printable_base10_digits(x: usize) -> u32 {
pub fn read_in_dir(path: &Path) -> anyhow::Result<impl Iterator<Item = PathBuf>> {
let dir = std::fs::read_dir(path)?;
Ok(dir.into_iter().filter_map(Result::ok).filter_map(|d| {
if let Ok(file_type) = d.file_type() {
d.file_type().map_or(None, |file_type| {
if file_type.is_file() {
Some(d.path())
} else {
None
}
} else {
None
}
})
}))
}

Expand Down
Loading