Skip to content

Commit

Permalink
Fix a variety of clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
shssoichiro committed Dec 6, 2023
1 parent aa7058c commit 4c20196
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = ["av1an-core", "av1an"]
resolver = "2"

[profile.dev.package.av-scenechange]
opt-level = 3
Expand Down
2 changes: 1 addition & 1 deletion av1an-core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl Av1anContext {

// Queue::encoding_loop only sends a message if there was an error (meaning a chunk crashed)
// more than MAX_TRIES. So, we have to explicitly exit the program if that happens.
while rx.recv().is_ok() {
if rx.recv().is_ok() {
exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion av1an-core/src/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub fn finish_progress_bar() {
}

if let Some((_, pbs)) = MULTI_PROGRESS_BAR.get() {
for pb in pbs.iter() {
for pb in pbs {
pb.finish();
}
}
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 @@ -63,7 +63,7 @@ pub fn extra_splits(scenes: &[Scene], total_frames: usize, split_size: usize) ->
);
}

for scene in scenes.iter() {
for scene in scenes {
let distance = scene.end_frame - scene.start_frame;
let split_size = scene
.zone_overrides
Expand Down
2 changes: 1 addition & 1 deletion av1an-core/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ macro_rules! into_smallvec {
macro_rules! create_dir {
($loc:expr) => {
match std::fs::create_dir(&$loc) {
Ok(_) => Ok(()),
Ok(()) => Ok(()),
Err(e) => match e.kind() {
std::io::ErrorKind::AlreadyExists => Ok(()),
_ => {
Expand Down
30 changes: 14 additions & 16 deletions av1an-core/src/vapoursynth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn best_available_chunk_method() -> ChunkMethod {
}
}

fn get_clip_info(env: &mut Environment) -> VideoInfo {
fn get_clip_info(env: &Environment) -> VideoInfo {
// Get the output node.
const OUTPUT_INDEX: i32 = 0;

Expand All @@ -88,7 +88,7 @@ fn get_clip_info(env: &mut Environment) -> VideoInfo {

/// Get the number of frames from an environment that has already been
/// evaluated on a script.
fn get_num_frames(env: &mut Environment) -> anyhow::Result<usize> {
fn get_num_frames(env: &Environment) -> anyhow::Result<usize> {
let info = get_clip_info(env);

let num_frames = {
Expand Down Expand Up @@ -123,7 +123,7 @@ fn get_num_frames(env: &mut Environment) -> anyhow::Result<usize> {
Ok(num_frames)
}

fn get_frame_rate(env: &mut Environment) -> anyhow::Result<f64> {
fn get_frame_rate(env: &Environment) -> anyhow::Result<f64> {
let info = get_clip_info(env);

match info.framerate {
Expand All @@ -134,7 +134,7 @@ fn get_frame_rate(env: &mut Environment) -> anyhow::Result<f64> {

/// Get the bit depth from an environment that has already been
/// evaluated on a script.
fn get_bit_depth(env: &mut Environment) -> anyhow::Result<usize> {
fn get_bit_depth(env: &Environment) -> anyhow::Result<usize> {
let info = get_clip_info(env);

let bits_per_sample = {
Expand All @@ -151,7 +151,7 @@ fn get_bit_depth(env: &mut Environment) -> anyhow::Result<usize> {

/// Get the resolution from an environment that has already been
/// evaluated on a script.
fn get_resolution(env: &mut Environment) -> anyhow::Result<(u32, u32)> {
fn get_resolution(env: &Environment) -> anyhow::Result<(u32, u32)> {
let info = get_clip_info(env);

let resolution = {
Expand All @@ -168,7 +168,7 @@ fn get_resolution(env: &mut Environment) -> anyhow::Result<(u32, u32)> {

/// Get the transfer characteristics from an environment that has already been
/// evaluated on a script.
fn get_transfer(env: &mut Environment) -> anyhow::Result<u8> {
fn get_transfer(env: &Environment) -> anyhow::Result<u8> {
// Get the output node.
const OUTPUT_INDEX: i32 = 0;

Expand Down Expand Up @@ -227,8 +227,7 @@ pub fn create_vs_file(
format!(
"from vapoursynth import core\n\
core.max_cache_size=1024\n\
core.dgdecodenv.DGSource(source={:?}).set_output()",
dgindex_path
core.dgdecodenv.DGSource(source={dgindex_path:?}).set_output()"
)
.as_bytes(),
)?;
Expand All @@ -237,8 +236,7 @@ pub fn create_vs_file(
format!(
"from vapoursynth import core\n\
core.max_cache_size=1024\n\
core.bs.VideoSource({:?}, cachepath={:?}).set_output()",
source, cache_file
core.bs.VideoSource({source:?}, cachepath={cache_file:?}).set_output()"
)
.as_bytes(),
)?;
Expand Down Expand Up @@ -273,7 +271,7 @@ pub fn num_frames(source: &Path) -> anyhow::Result<usize> {
.eval_file(source, EvalFlags::SetWorkingDir)
.unwrap();

get_num_frames(&mut environment)
get_num_frames(&environment)
}

pub fn bit_depth(source: &Path) -> anyhow::Result<usize> {
Expand All @@ -285,7 +283,7 @@ pub fn bit_depth(source: &Path) -> anyhow::Result<usize> {
.eval_file(source, EvalFlags::SetWorkingDir)
.unwrap();

get_bit_depth(&mut environment)
get_bit_depth(&environment)
}

pub fn frame_rate(source: &Path) -> anyhow::Result<f64> {
Expand All @@ -297,7 +295,7 @@ pub fn frame_rate(source: &Path) -> anyhow::Result<f64> {
.eval_file(source, EvalFlags::SetWorkingDir)
.unwrap();

get_frame_rate(&mut environment)
get_frame_rate(&environment)
}

pub fn resolution(source: &Path) -> anyhow::Result<(u32, u32)> {
Expand All @@ -309,7 +307,7 @@ pub fn resolution(source: &Path) -> anyhow::Result<(u32, u32)> {
.eval_file(source, EvalFlags::SetWorkingDir)
.unwrap();

get_resolution(&mut environment)
get_resolution(&environment)
}

/// Transfer characteristics as specified in ITU-T H.265 Table E.4.
Expand All @@ -322,7 +320,7 @@ pub fn transfer_characteristics(source: &Path) -> anyhow::Result<u8> {
.eval_file(source, EvalFlags::SetWorkingDir)
.unwrap();

get_transfer(&mut environment)
get_transfer(&environment)
}

pub fn pixel_format(source: &Path) -> anyhow::Result<String> {
Expand All @@ -334,7 +332,7 @@ pub fn pixel_format(source: &Path) -> anyhow::Result<String> {
.eval_file(source, EvalFlags::SetWorkingDir)
.unwrap();

let info = get_clip_info(&mut environment);
let info = get_clip_info(&environment);
match info.format {
Property::Variable => bail!("Variable pixel format not supported"),
Property::Constant(x) => Ok(x.name().to_string()),
Expand Down

0 comments on commit 4c20196

Please sign in to comment.