diff --git a/CHANGELOG.md b/CHANGELOG.md index 164d7d0..d6bb0af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## Version 0.8.0 + +- Upgrade clap to 4.0 +- Add frame limit arg to API +- [Breaking] Change `progress_callback` to take a &dyn Fn +- Misc improvements including some speedups from rav1e +- Update to Rust edition 2021 + ## Version 0.7.2 - Bump to the final release of rav1e 0.5 diff --git a/Cargo.lock b/Cargo.lock index 256b94c..e6bfbbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,7 +62,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "av-scenechange" -version = "0.7.2" +version = "0.8.0" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 8b9524c..29fc502 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "av-scenechange" -version = "0.7.2" +version = "0.8.0" authors = ["Josh Holmer "] -edition = "2018" +edition = "2021" description = "Estimates frames in a video where a scenecut would be ideal" license = "MIT" repository = "https://github.com/rust-av/av-scenechange" diff --git a/src/lib.rs b/src/lib.rs index bf296b6..e391d0d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,44 @@ +#![deny(clippy::all)] +#![warn(clippy::nursery)] +#![warn(clippy::pedantic)] +#![allow(clippy::cast_possible_truncation)] +#![allow(clippy::cast_possible_wrap)] +#![allow(clippy::cast_precision_loss)] +#![allow(clippy::cast_sign_loss)] +#![allow(clippy::default_trait_access)] +#![allow(clippy::inconsistent_struct_constructor)] +#![allow(clippy::inline_always)] +#![allow(clippy::module_name_repetitions)] +#![allow(clippy::redundant_closure_for_method_calls)] +#![allow(clippy::similar_names)] +#![allow(clippy::struct_excessive_bools)] +#![allow(clippy::use_self)] +#![warn(clippy::clone_on_ref_ptr)] +#![warn(clippy::create_dir)] +#![warn(clippy::dbg_macro)] +#![warn(clippy::default_numeric_fallback)] +#![warn(clippy::exit)] +#![warn(clippy::filetype_is_file)] +#![warn(clippy::float_cmp_const)] +#![warn(clippy::if_then_some_else_none)] +#![warn(clippy::lossy_float_literal)] +#![warn(clippy::map_err_ignore)] +#![warn(clippy::mem_forget)] +#![warn(clippy::mod_module_files)] +#![warn(clippy::multiple_inherent_impl)] +#![warn(clippy::pattern_type_mismatch)] +#![warn(clippy::rc_buffer)] +#![warn(clippy::rc_mutex)] +#![warn(clippy::rest_pat_in_fully_bound_structs)] +#![warn(clippy::same_name_method)] +#![warn(clippy::str_to_string)] +#![warn(clippy::string_to_string)] +#![warn(clippy::undocumented_unsafe_blocks)] +#![warn(clippy::unnecessary_self_imports)] +#![warn(clippy::unneeded_field_pattern)] +#![warn(clippy::use_debug)] +#![warn(clippy::verbose_file_reads)] + mod y4m; use std::{ @@ -112,6 +153,10 @@ pub fn new_detector( /// is analyzed. Arguments passed in will be, in order, the number of frames /// analyzed, and the number of keyframes detected. This is generally useful /// for displaying progress, etc. +/// +/// # Panics +/// +/// - If `opts.lookahead_distance` is 0. #[allow(clippy::needless_pass_by_value)] pub fn detect_scene_changes( dec: &mut Decoder, diff --git a/src/main.rs b/src/main.rs index 2807378..26616aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,47 @@ +#![deny(clippy::all)] +#![warn(clippy::nursery)] +#![warn(clippy::pedantic)] +#![allow(clippy::cast_possible_truncation)] +#![allow(clippy::cast_possible_wrap)] +#![allow(clippy::cast_precision_loss)] +#![allow(clippy::cast_sign_loss)] +#![allow(clippy::default_trait_access)] +#![allow(clippy::inconsistent_struct_constructor)] +#![allow(clippy::inline_always)] +#![allow(clippy::module_name_repetitions)] +#![allow(clippy::redundant_closure_for_method_calls)] +#![allow(clippy::similar_names)] +#![allow(clippy::struct_excessive_bools)] +#![allow(clippy::use_self)] +#![warn(clippy::clone_on_ref_ptr)] +#![warn(clippy::create_dir)] +#![warn(clippy::dbg_macro)] +#![warn(clippy::default_numeric_fallback)] +#![warn(clippy::exit)] +#![warn(clippy::filetype_is_file)] +#![warn(clippy::float_cmp_const)] +#![warn(clippy::if_then_some_else_none)] +#![warn(clippy::lossy_float_literal)] +#![warn(clippy::map_err_ignore)] +#![warn(clippy::mem_forget)] +#![warn(clippy::mod_module_files)] +#![warn(clippy::multiple_inherent_impl)] +#![warn(clippy::pattern_type_mismatch)] +#![warn(clippy::rc_buffer)] +#![warn(clippy::rc_mutex)] +#![warn(clippy::rest_pat_in_fully_bound_structs)] +#![warn(clippy::same_name_method)] +#![warn(clippy::str_to_string)] +#![warn(clippy::string_to_string)] +#![warn(clippy::undocumented_unsafe_blocks)] +#![warn(clippy::unnecessary_self_imports)] +#![warn(clippy::unneeded_field_pattern)] +#![warn(clippy::use_debug)] +#![warn(clippy::verbose_file_reads)] +// For binary-only crates +#![allow(clippy::missing_errors_doc)] +#![allow(clippy::missing_panics_doc)] + use std::{ fs::File, io::{self, BufReader, Read, Write}, diff --git a/src/y4m.rs b/src/y4m.rs index 9496582..a0b5526 100644 --- a/src/y4m.rs +++ b/src/y4m.rs @@ -2,7 +2,7 @@ use std::io::Read; use rav1e::prelude::{ChromaSamplePosition, ChromaSampling, Frame, Pixel, Rational}; -pub(crate) fn get_video_details(dec: &y4m::Decoder) -> VideoDetails { +pub fn get_video_details(dec: &y4m::Decoder) -> VideoDetails { let width = dec.get_width(); let height = dec.get_height(); let color_space = dec.get_colorspace(); @@ -24,9 +24,12 @@ pub(crate) fn get_video_details(dec: &y4m::Decoder) -> VideoDetails const fn map_y4m_color_space( color_space: y4m::Colorspace, ) -> (ChromaSampling, ChromaSamplePosition) { - use y4m::Colorspace::*; - use ChromaSamplePosition::*; - use ChromaSampling::*; + use y4m::Colorspace::{ + C420jpeg, C420mpeg2, C420p10, C420p12, C420paldv, C422p10, C422p12, C444p10, C444p12, + Cmono, C420, C422, C444, + }; + use ChromaSamplePosition::{Colocated, Unknown, Vertical}; + use ChromaSampling::{Cs400, Cs420, Cs422, Cs444}; match color_space { Cmono => (Cs400, Unknown), C420jpeg | C420paldv => (Cs420, Unknown),