diff --git a/Cargo.toml b/Cargo.toml index c5f102c..e167252 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,3 @@ [workspace] -members = [ - "av1an-core", - "av1an-pyo3", -] +members = ["av1an-core", "av1an-pyo3", "av1an-scene-detection"] diff --git a/av1an-core/src/file_validation.rs b/av1an-core/src/file_validation.rs index 83d5066..03dd242 100644 --- a/av1an-core/src/file_validation.rs +++ b/av1an-core/src/file_validation.rs @@ -37,7 +37,7 @@ fn process_inputs(inputs: Vec<&Path>) -> Vec<&Path> { // Process all inputs (folders and files) // into single path vector - for fl in inputs { + for fl in inputs.clone() { if fl.is_dir() { for file in fl { let path_file = Path::new(file); @@ -58,6 +58,12 @@ fn process_inputs(inputs: Vec<&Path>) -> Vec<&Path> { .filter(|x| match_file_type(*x)) .collect(); + if result.is_empty() { + println!("Not valid inputs"); + println!("{:#?}", inputs); + exit(1); + } + result } diff --git a/av1an-core/src/lib.rs b/av1an-core/src/lib.rs index cd28891..ac230f3 100644 --- a/av1an-core/src/lib.rs +++ b/av1an-core/src/lib.rs @@ -14,7 +14,6 @@ use std::str::FromStr; use std::{fs::File, io::Write}; use sysinfo::SystemExt; -pub mod aom_kf; pub mod concat; pub mod ffmpeg; pub mod file_validation; diff --git a/av1an-scene-detection/Cargo.toml b/av1an-scene-detection/Cargo.toml new file mode 100644 index 0000000..263dd96 --- /dev/null +++ b/av1an-scene-detection/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "av1an-scene-detection" +version = "0.1.0" +edition = "2018" + + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/av1an-core/src/aom_kf.rs b/av1an-scene-detection/src/aom_kf.rs similarity index 62% rename from av1an-core/src/aom_kf.rs rename to av1an-scene-detection/src/aom_kf.rs index b6b9a09..9c3d9d6 100644 --- a/av1an-core/src/aom_kf.rs +++ b/av1an-scene-detection/src/aom_kf.rs @@ -1,3 +1,5 @@ +use core::f64; + struct AomFirstPassStats { frame: u64, // Frame number weight: u64, // Weight assigned to this frame @@ -27,3 +29,16 @@ struct AomFirstPassStats { noise_var: u64, cor_coeff: u64, } + +fn get_second_ref_usage_thresh(frame_count_so_far: u64) -> f64 { + let adapt_upto = 32.0; + let min_second_ref_usage_thresh = 0.085; + let second_ref_usage_thresh_max_delta = 0.035; + + if frame_count_so_far as f64 >= adapt_upto { + return min_second_ref_usage_thresh + second_ref_usage_thresh_max_delta; + } else { + min_second_ref_usage_thresh + + (frame_count_so_far as f64 / (adapt_upto - 1.0)) * second_ref_usage_thresh_max_delta + } +} diff --git a/av1an-scene-detection/src/lib.rs b/av1an-scene-detection/src/lib.rs new file mode 100644 index 0000000..42fdf1f --- /dev/null +++ b/av1an-scene-detection/src/lib.rs @@ -0,0 +1,3 @@ +#![allow(unused)] + +pub mod aom_kf;