diff --git a/.github/workflows/rav1e.yml b/.github/workflows/rav1e.yml index d2706a7309..08089504e4 100644 --- a/.github/workflows/rav1e.yml +++ b/.github/workflows/rav1e.yml @@ -27,7 +27,7 @@ jobs: - name: Run clippy uses: clechasseur/rs-clippy-check@v3 with: - args: -- -D warnings --verbose -A clippy::wrong-self-convention -A clippy::many_single_char_names -A clippy::upper-case-acronyms + args: -- -D warnings msrv: runs-on: ubuntu-22.04 diff --git a/Cargo.toml b/Cargo.toml index 1a34692089..200924fec7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -211,3 +211,15 @@ members = [".", "ivf"] [package.metadata.docs.rs] no-default-features = true + +[lints.clippy] +doc_link_with_quotes = "warn" +doc_markdown = "warn" +missing_errors_doc = "warn" +missing_panics_doc = "warn" +missing_safety_doc = "warn" +comparison_chain = "allow" +enum_variant_names = "allow" +needless_range_loop = "allow" +too_many_arguments = "allow" +upper_case_acronyms = "allow" \ No newline at end of file diff --git a/ivf/Cargo.toml b/ivf/Cargo.toml index 27e17a781b..7c36adecf0 100644 --- a/ivf/Cargo.toml +++ b/ivf/Cargo.toml @@ -9,3 +9,15 @@ homepage = "https://github.com/xiph/rav1e" [dependencies] bitstream-io = "2" + +[lints.clippy] +doc_link_with_quotes = "warn" +doc_markdown = "warn" +missing_errors_doc = "warn" +missing_panics_doc = "warn" +missing_safety_doc = "warn" +comparison_chain = "allow" +enum_variant_names = "allow" +needless_range_loop = "allow" +too_many_arguments = "allow" +upper_case_acronyms = "allow" \ No newline at end of file diff --git a/ivf/src/lib.rs b/ivf/src/lib.rs index 116db23f57..bccebfc65e 100644 --- a/ivf/src/lib.rs +++ b/ivf/src/lib.rs @@ -8,40 +8,12 @@ // Media Patent License 1.0 was not distributed with this source code in the // PATENTS file, you can obtain it at www.aomedia.org/license/patent. -#![deny(bare_trait_objects)] -#![allow(clippy::cast_lossless)] -#![allow(clippy::cast_ptr_alignment)] -#![allow(clippy::cognitive_complexity)] -#![allow(clippy::needless_range_loop)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::verbose_bit_mask)] -#![allow(clippy::unreadable_literal)] -#![allow(clippy::many_single_char_names)] -// Performance lints -#![warn(clippy::linkedlist)] -#![warn(clippy::missing_const_for_fn)] -#![warn(clippy::mutex_integer)] -#![warn(clippy::suboptimal_flops)] -// Correctness lints -#![warn(clippy::expl_impl_clone_on_copy)] -#![warn(clippy::mem_forget)] -#![warn(clippy::path_buf_push_overwrite)] -// Clarity/formatting lints -#![warn(clippy::map_flatten)] -#![warn(clippy::mut_mut)] -#![warn(clippy::needless_borrow)] -#![warn(clippy::needless_continue)] -#![warn(clippy::range_plus_one)] -// Documentation lints -#![warn(clippy::doc_markdown)] -#![warn(clippy::missing_errors_doc)] -#![warn(clippy::missing_panics_doc)] - -/// Simple ivf muxer -/// -use bitstream_io::{BitRead, BitReader, BitWrite, BitWriter, LittleEndian}; +//! Simple ivf muxer + use std::io; +use bitstream_io::{BitRead, BitReader, BitWrite, BitWriter, LittleEndian}; + /// # Panics /// /// - If header cannot be written to output file. @@ -137,9 +109,10 @@ pub fn read_packet(r: &mut dyn io::Read) -> io::Result { #[cfg(test)] mod tests { - use crate::{read_header, read_packet}; use std::io::{BufReader, ErrorKind::InvalidData}; + use crate::{read_header, read_packet}; + #[test] fn read_invalid_headers() { // Invalid magic. diff --git a/src/api/context.rs b/src/api/context.rs index eec840d337..0d41ead48d 100644 --- a/src/api/context.rs +++ b/src/api/context.rs @@ -8,21 +8,20 @@ // PATENTS file, you can obtain it at www.aomedia.org/license/patent. #![deny(missing_docs)] +use std::fmt; +use std::io; +use std::sync::Arc; + +use bitstream_io::*; + use crate::api::color::*; use crate::api::config::*; use crate::api::internal::*; use crate::api::util::*; - -use bitstream_io::*; - use crate::encoder::*; use crate::frame::*; use crate::util::Pixel; -use std::fmt; -use std::io; -use std::sync::Arc; - /// The encoder context. /// /// Contains the encoding state. @@ -122,8 +121,8 @@ impl Context { || (self.inner.config.still_picture && self.inner.frame_count > 0) { return Err(EncoderStatus::EnoughData); - // The rate control can process at most std::i32::MAX frames - } else if self.inner.frame_count == std::i32::MAX as u64 - 1 { + // The rate control can process at most i32::MAX frames + } else if self.inner.frame_count == i32::MAX as u64 - 1 { self.inner.limit = Some(self.inner.frame_count); self.is_flushing = true; } diff --git a/src/asm/x86/sad_plane.rs b/src/asm/x86/sad_plane.rs index a3ad0584a7..df0efcbb0f 100644 --- a/src/asm/x86/sad_plane.rs +++ b/src/asm/x86/sad_plane.rs @@ -7,13 +7,13 @@ // Media Patent License 1.0 was not distributed with this source code in the // PATENTS file, you can obtain it at www.aomedia.org/license/patent. -use crate::cpu_features::CpuFeatureLevel; -use crate::sad_plane::*; -use crate::util::{Pixel, PixelType}; +use std::mem; use v_frame::plane::Plane; -use std::mem; +use crate::cpu_features::CpuFeatureLevel; +use crate::sad_plane::*; +use crate::util::{Pixel, PixelType}; macro_rules! decl_sad_plane_fn { ($($f:ident),+) => { @@ -46,8 +46,12 @@ pub(crate) fn sad_plane_internal( // SAFETY: Calls Assembly code. unsafe { let result = $func( - mem::transmute(src.data_origin().as_ptr()), - mem::transmute(dst.data_origin().as_ptr()), + mem::transmute::<*const T, *const u8>( + src.data_origin().as_ptr(), + ), + mem::transmute::<*const T, *const u8>( + dst.data_origin().as_ptr(), + ), src.cfg.stride, src.cfg.width, src.cfg.height, diff --git a/src/bin/common.rs b/src/bin/common.rs index f2764e9ac8..320d4dc71b 100644 --- a/src/bin/common.rs +++ b/src/bin/common.rs @@ -342,6 +342,7 @@ pub struct ParsedCliOptions { pub metrics_enabled: MetricsEnabled, pub pass1file_name: Option, pub pass2file_name: Option, + #[cfg(feature = "serialize")] pub save_config: Option, pub photon_noise: u8, #[cfg(feature = "unstable")] @@ -390,6 +391,7 @@ fn build_speed_long_help() -> Option<&'static str> { pub fn parse_cli() -> Result { let matches = CliOptions::parse(); + #[cfg(feature = "serialize")] let mut save_config_path = None; let mut enc = None; @@ -489,6 +491,7 @@ pub fn parse_cli() -> Result { threads: matches.threads, pass1file_name: matches.first_pass.clone(), pass2file_name: matches.second_pass.clone(), + #[cfg(feature = "serialize")] save_config: save_config_path, photon_noise: matches.photon_noise, force_highbitdepth: matches.high_bitdepth, diff --git a/src/bin/decoder/mod.rs b/src/bin/decoder/mod.rs index 9855a67cf0..9af870311e 100644 --- a/src/bin/decoder/mod.rs +++ b/src/bin/decoder/mod.rs @@ -9,7 +9,6 @@ // PATENTS file, you can obtain it at www.aomedia.org/license/patent. use rav1e::prelude::*; -use std::io; pub mod y4m; @@ -25,13 +24,12 @@ pub trait Decoder: Send { } #[derive(Debug)] -#[allow(clippy::upper_case_acronyms)] pub enum DecodeError { EOF, BadInput, UnknownColorspace, ParseError, - IoError(io::Error), + IoError, MemoryLimitExceeded, } diff --git a/src/bin/decoder/y4m.rs b/src/bin/decoder/y4m.rs index 667d7ae05b..57056b0b6f 100644 --- a/src/bin/decoder/y4m.rs +++ b/src/bin/decoder/y4m.rs @@ -83,7 +83,7 @@ impl From for DecodeError { y4m::Error::BadInput => DecodeError::BadInput, y4m::Error::UnknownColorspace => DecodeError::UnknownColorspace, y4m::Error::ParseError(_) => DecodeError::ParseError, - y4m::Error::IoError(e) => DecodeError::IoError(e), + y4m::Error::IoError(_) => DecodeError::IoError, // Note that this error code has nothing to do with the system running out of memory, // it means the y4m decoder has exceeded its memory allocation limit. y4m::Error::OutOfMemory => DecodeError::MemoryLimitExceeded, diff --git a/src/bin/rav1e-ch.rs b/src/bin/rav1e-ch.rs index 274ded4a13..8708b56717 100644 --- a/src/bin/rav1e-ch.rs +++ b/src/bin/rav1e-ch.rs @@ -7,80 +7,6 @@ // Media Patent License 1.0 was not distributed with this source code in the // PATENTS file, you can obtain it at www.aomedia.org/license/patent. -// Safety lints -#![deny(bare_trait_objects)] -#![deny(clippy::as_ptr_cast_mut)] -#![deny(clippy::large_stack_arrays)] -// Performance lints -#![warn(clippy::inefficient_to_string)] -#![warn(clippy::invalid_upcast_comparisons)] -#![warn(clippy::iter_with_drain)] -#![warn(clippy::linkedlist)] -#![warn(clippy::mutex_integer)] -#![warn(clippy::naive_bytecount)] -#![warn(clippy::needless_bitwise_bool)] -#![warn(clippy::needless_collect)] -#![warn(clippy::or_fun_call)] -#![warn(clippy::stable_sort_primitive)] -#![warn(clippy::suboptimal_flops)] -#![warn(clippy::trivial_regex)] -#![warn(clippy::trivially_copy_pass_by_ref)] -#![warn(clippy::unnecessary_join)] -#![warn(clippy::unused_async)] -#![warn(clippy::zero_sized_map_values)] -// Correctness lints -#![deny(clippy::case_sensitive_file_extension_comparisons)] -#![deny(clippy::copy_iterator)] -#![deny(clippy::expl_impl_clone_on_copy)] -#![deny(clippy::float_cmp)] -#![warn(clippy::imprecise_flops)] -#![deny(clippy::manual_instant_elapsed)] -#![deny(clippy::mem_forget)] -#![deny(clippy::path_buf_push_overwrite)] -#![deny(clippy::same_functions_in_if_condition)] -#![deny(clippy::unchecked_duration_subtraction)] -#![deny(clippy::unicode_not_nfc)] -// Clarity/formatting lints -#![warn(clippy::checked_conversions)] -#![allow(clippy::comparison_chain)] -#![warn(clippy::derive_partial_eq_without_eq)] -#![allow(clippy::enum_variant_names)] -#![warn(clippy::explicit_deref_methods)] -#![warn(clippy::filter_map_next)] -#![warn(clippy::flat_map_option)] -#![warn(clippy::fn_params_excessive_bools)] -#![warn(clippy::implicit_clone)] -#![warn(clippy::iter_not_returning_iterator)] -#![warn(clippy::iter_on_empty_collections)] -#![warn(clippy::macro_use_imports)] -#![warn(clippy::manual_clamp)] -#![warn(clippy::manual_let_else)] -#![warn(clippy::manual_ok_or)] -#![warn(clippy::manual_string_new)] -#![warn(clippy::map_flatten)] -#![warn(clippy::match_bool)] -#![warn(clippy::mut_mut)] -#![warn(clippy::needless_borrow)] -#![warn(clippy::needless_continue)] -#![allow(clippy::needless_range_loop)] -#![allow(clippy::too_many_arguments)] -#![warn(clippy::range_minus_one)] -#![warn(clippy::range_plus_one)] -#![warn(clippy::ref_binding_to_reference)] -#![warn(clippy::ref_option_ref)] -#![warn(clippy::trait_duplication_in_bounds)] -#![warn(clippy::unused_peekable)] -#![warn(clippy::unused_rounding)] -#![warn(clippy::unused_self)] -#![allow(clippy::upper_case_acronyms)] -#![warn(clippy::verbose_bit_mask)] -#![warn(clippy::verbose_file_reads)] -// Documentation lints -#![warn(clippy::doc_link_with_quotes)] -#![warn(clippy::doc_markdown)] -#![warn(clippy::missing_errors_doc)] -#![warn(clippy::missing_panics_doc)] - #[macro_use] extern crate log; diff --git a/src/bin/rav1e.rs b/src/bin/rav1e.rs index da7c3cae02..bf1e970773 100644 --- a/src/bin/rav1e.rs +++ b/src/bin/rav1e.rs @@ -7,80 +7,6 @@ // Media Patent License 1.0 was not distributed with this source code in the // PATENTS file, you can obtain it at www.aomedia.org/license/patent. -// Safety lints -#![deny(bare_trait_objects)] -#![deny(clippy::as_ptr_cast_mut)] -#![deny(clippy::large_stack_arrays)] -// Performance lints -#![warn(clippy::inefficient_to_string)] -#![warn(clippy::invalid_upcast_comparisons)] -#![warn(clippy::iter_with_drain)] -#![warn(clippy::linkedlist)] -#![warn(clippy::mutex_integer)] -#![warn(clippy::naive_bytecount)] -#![warn(clippy::needless_bitwise_bool)] -#![warn(clippy::needless_collect)] -#![warn(clippy::or_fun_call)] -#![warn(clippy::stable_sort_primitive)] -#![warn(clippy::suboptimal_flops)] -#![warn(clippy::trivial_regex)] -#![warn(clippy::trivially_copy_pass_by_ref)] -#![warn(clippy::unnecessary_join)] -#![warn(clippy::unused_async)] -#![warn(clippy::zero_sized_map_values)] -// Correctness lints -#![deny(clippy::case_sensitive_file_extension_comparisons)] -#![deny(clippy::copy_iterator)] -#![deny(clippy::expl_impl_clone_on_copy)] -#![deny(clippy::float_cmp)] -#![warn(clippy::imprecise_flops)] -#![deny(clippy::manual_instant_elapsed)] -#![deny(clippy::mem_forget)] -#![deny(clippy::path_buf_push_overwrite)] -#![deny(clippy::same_functions_in_if_condition)] -#![deny(clippy::unchecked_duration_subtraction)] -#![deny(clippy::unicode_not_nfc)] -// Clarity/formatting lints -#![warn(clippy::checked_conversions)] -#![allow(clippy::comparison_chain)] -#![warn(clippy::derive_partial_eq_without_eq)] -#![allow(clippy::enum_variant_names)] -#![warn(clippy::explicit_deref_methods)] -#![warn(clippy::filter_map_next)] -#![warn(clippy::flat_map_option)] -#![warn(clippy::fn_params_excessive_bools)] -#![warn(clippy::implicit_clone)] -#![warn(clippy::iter_not_returning_iterator)] -#![warn(clippy::iter_on_empty_collections)] -#![warn(clippy::macro_use_imports)] -#![warn(clippy::manual_clamp)] -#![warn(clippy::manual_let_else)] -#![warn(clippy::manual_ok_or)] -#![warn(clippy::manual_string_new)] -#![warn(clippy::map_flatten)] -#![warn(clippy::match_bool)] -#![warn(clippy::mut_mut)] -#![warn(clippy::needless_borrow)] -#![warn(clippy::needless_continue)] -#![allow(clippy::needless_range_loop)] -#![allow(clippy::too_many_arguments)] -#![warn(clippy::range_minus_one)] -#![warn(clippy::range_plus_one)] -#![warn(clippy::ref_binding_to_reference)] -#![warn(clippy::ref_option_ref)] -#![warn(clippy::trait_duplication_in_bounds)] -#![warn(clippy::unused_peekable)] -#![warn(clippy::unused_rounding)] -#![warn(clippy::unused_self)] -#![allow(clippy::upper_case_acronyms)] -#![warn(clippy::verbose_bit_mask)] -#![warn(clippy::verbose_file_reads)] -// Documentation lints -#![warn(clippy::doc_link_with_quotes)] -#![warn(clippy::doc_markdown)] -#![warn(clippy::missing_errors_doc)] -#![warn(clippy::missing_panics_doc)] - #[macro_use] extern crate log; diff --git a/src/encoder.rs b/src/encoder.rs index 864665e319..89b4ca0322 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -7,6 +7,17 @@ // Media Patent License 1.0 was not distributed with this source code in the // PATENTS file, you can obtain it at www.aomedia.org/license/patent. +use std::collections::VecDeque; +use std::io::Write; +use std::mem::MaybeUninit; +use std::sync::Arc; +use std::{fmt, io, mem}; + +use arg_enum_proc_macro::ArgEnum; +use arrayvec::*; +use bitstream_io::{BigEndian, BitWrite, BitWriter}; +use rayon::iter::*; + use crate::activity::*; use crate::api::*; use crate::cdef::*; @@ -37,17 +48,6 @@ use crate::transform::*; use crate::util::*; use crate::wasm_bindgen::*; -use arg_enum_proc_macro::ArgEnum; -use arrayvec::*; -use bitstream_io::{BigEndian, BitWrite, BitWriter}; -use rayon::iter::*; - -use std::collections::VecDeque; -use std::io::Write; -use std::mem::MaybeUninit; -use std::sync::Arc; -use std::{fmt, io, mem}; - #[allow(dead_code)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum CDEFSearchMethod { @@ -2638,8 +2638,8 @@ fn encode_partition_bottomup( inter_cfg: &InterConfig, enc_stats: &mut EncoderStats, ) -> PartitionGroupParameters { let rdo_type = RDOType::PixelDistRealRate; - let mut rd_cost = std::f64::MAX; - let mut best_rd = std::f64::MAX; + let mut rd_cost = f64::MAX; + let mut best_rd = f64::MAX; let mut rdo_output = PartitionGroupParameters { rd_cost, part_type: PartitionType::PARTITION_INVALID, @@ -2817,13 +2817,13 @@ fn encode_partition_bottomup( let cost = child_rdo_output.rd_cost; assert!(cost >= 0.0); - if cost != std::f64::MAX { + if cost != f64::MAX { rd_cost += cost; if !must_split && fi.enable_early_exit && (rd_cost >= best_rd || rd_cost >= ref_rd_cost) { - assert!(cost != std::f64::MAX); + assert!(cost != f64::MAX); early_exit = true; break; } else if partition != PartitionType::PARTITION_SPLIT { @@ -2948,7 +2948,7 @@ fn encode_partition_topdown( let mut rdo_output = block_output.clone().unwrap_or_else(|| PartitionGroupParameters { part_type: PartitionType::PARTITION_INVALID, - rd_cost: std::f64::MAX, + rd_cost: f64::MAX, part_modes: ArrayVec::new(), }); @@ -3520,7 +3520,7 @@ fn encode_tile<'a, T: Pixel>( &mut sbs_qe.w_post_cdef, BlockSize::BLOCK_64X64, tile_bo, - std::f64::MAX, + f64::MAX, inter_cfg, &mut enc_stats, ); diff --git a/src/lib.rs b/src/lib.rs index 7575b1f118..f266f916de 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,89 +34,19 @@ //! [`Context`]: struct.Context.html //! [`Context::receive_packet`]: struct.Context.html#method.receive_packet -// Safety lints -#![deny(bare_trait_objects)] -#![deny(clippy::as_ptr_cast_mut)] -#![deny(clippy::large_stack_arrays)] -// Performance lints -#![warn(clippy::inefficient_to_string)] -#![warn(clippy::invalid_upcast_comparisons)] -#![warn(clippy::iter_with_drain)] -#![warn(clippy::linkedlist)] -#![warn(clippy::mutex_integer)] -#![warn(clippy::naive_bytecount)] -#![warn(clippy::needless_bitwise_bool)] -#![warn(clippy::needless_collect)] -#![warn(clippy::or_fun_call)] -#![warn(clippy::stable_sort_primitive)] -#![warn(clippy::suboptimal_flops)] -#![warn(clippy::trivial_regex)] -#![warn(clippy::trivially_copy_pass_by_ref)] -#![warn(clippy::unnecessary_join)] -#![warn(clippy::unused_async)] -#![warn(clippy::zero_sized_map_values)] -// Correctness lints -#![deny(clippy::case_sensitive_file_extension_comparisons)] -#![deny(clippy::copy_iterator)] -#![deny(clippy::expl_impl_clone_on_copy)] -#![deny(clippy::float_cmp)] -#![warn(clippy::imprecise_flops)] -#![deny(clippy::manual_instant_elapsed)] -#![deny(clippy::mem_forget)] -#![deny(clippy::path_buf_push_overwrite)] -#![deny(clippy::same_functions_in_if_condition)] -#![deny(clippy::unchecked_duration_subtraction)] -#![deny(clippy::unicode_not_nfc)] -// Clarity/formatting lints -#![warn(clippy::checked_conversions)] -#![allow(clippy::comparison_chain)] -#![warn(clippy::derive_partial_eq_without_eq)] -#![allow(clippy::enum_variant_names)] -#![warn(clippy::explicit_deref_methods)] -#![warn(clippy::filter_map_next)] -#![warn(clippy::flat_map_option)] -#![warn(clippy::fn_params_excessive_bools)] -#![warn(clippy::implicit_clone)] -#![warn(clippy::iter_not_returning_iterator)] -#![warn(clippy::iter_on_empty_collections)] -#![warn(clippy::macro_use_imports)] -#![warn(clippy::manual_clamp)] -#![warn(clippy::manual_let_else)] -#![warn(clippy::manual_ok_or)] -#![warn(clippy::manual_string_new)] -#![warn(clippy::map_flatten)] -#![warn(clippy::match_bool)] -#![warn(clippy::mut_mut)] -#![warn(clippy::needless_borrow)] -#![warn(clippy::needless_continue)] -#![allow(clippy::needless_range_loop)] -#![allow(clippy::too_many_arguments)] -#![warn(clippy::range_minus_one)] -#![warn(clippy::range_plus_one)] -#![warn(clippy::ref_binding_to_reference)] -#![warn(clippy::ref_option_ref)] -#![warn(clippy::trait_duplication_in_bounds)] -#![warn(clippy::unused_peekable)] -#![warn(clippy::unused_rounding)] -#![warn(clippy::unused_self)] -#![allow(clippy::upper_case_acronyms)] -#![warn(clippy::verbose_bit_mask)] -#![warn(clippy::verbose_file_reads)] -// Documentation lints -#![warn(clippy::doc_link_with_quotes)] -#![warn(clippy::doc_markdown)] -#![warn(clippy::missing_errors_doc)] -#![warn(clippy::missing_panics_doc)] -// FIXME: We should fix instances of this lint and change it to `warn` -#![allow(clippy::missing_safety_doc)] - -// Override assert! and assert_eq! in tests +#[macro_use] +extern crate log; // Override assert! and assert_eq! in tests #[cfg(test)] #[macro_use] extern crate pretty_assertions; -#[macro_use] -extern crate log; +pub use crate::api::color; +pub use crate::api::{ + Config, Context, EncoderConfig, EncoderStatus, InvalidConfig, Packet, +}; +use crate::encoder::*; +pub use crate::frame::Frame; +pub use crate::util::{CastFromPrimitive, Pixel, PixelType}; pub(crate) mod built_info { // The file has been placed there by the build script. @@ -190,14 +120,6 @@ mod api; mod frame; mod header; -use crate::encoder::*; - -pub use crate::api::{ - Config, Context, EncoderConfig, EncoderStatus, InvalidConfig, Packet, -}; -pub use crate::frame::Frame; -pub use crate::util::{CastFromPrimitive, Pixel, PixelType}; - /// Commonly used types and traits. pub mod prelude { pub use crate::api::*; @@ -221,8 +143,6 @@ pub mod data { pub use crate::util::{CastFromPrimitive, Pixel, PixelType}; } -pub use crate::api::color; - /// Encoder configuration and settings pub mod config { pub use crate::api::config::{ diff --git a/src/lrf.rs b/src/lrf.rs index fc663bf2ff..99ef5f6b0c 100644 --- a/src/lrf.rs +++ b/src/lrf.rs @@ -7,13 +7,9 @@ // Media Patent License 1.0 was not distributed with this source code in the // PATENTS file, you can obtain it at www.aomedia.org/license/patent. -cfg_if::cfg_if! { - if #[cfg(nasm_x86_64)] { - use crate::asm::x86::lrf::*; - } else { - use self::rust::*; - } -} +use std::cmp; +use std::iter::FusedIterator; +use std::ops::{Index, IndexMut}; use crate::api::SGRComplexityLevel; use crate::color::ChromaSampling::Cs400; @@ -24,9 +20,14 @@ use crate::frame::{ }; use crate::tiling::{Area, PlaneRegion, PlaneRegionMut, Rect}; use crate::util::{clamp, CastFromPrimitive, ILog, Pixel}; -use std::cmp; -use std::iter::FusedIterator; -use std::ops::{Index, IndexMut}; + +cfg_if::cfg_if! { + if #[cfg(nasm_x86_64)] { + use crate::asm::x86::lrf::*; + } else { + use self::rust::*; + } +} pub const RESTORATION_TILESIZE_MAX_LOG2: usize = 8; @@ -1265,12 +1266,6 @@ pub struct RestorationPlane { pub units: FrameRestorationUnits, } -#[derive(Clone, Default)] -pub struct RestorationPlaneOffset { - pub row: usize, - pub col: usize, -} - impl RestorationPlane { pub fn new( lrf_type: u8, unit_size: usize, sb_h_shift: usize, sb_v_shift: usize, diff --git a/src/rate.rs b/src/rate.rs index 2116725d1b..09304e8379 100644 --- a/src/rate.rs +++ b/src/rate.rs @@ -7,6 +7,8 @@ // Media Patent License 1.0 was not distributed with this source code in the // PATENTS file, you can obtain it at www.aomedia.org/license/patent. +use std::cmp; + use crate::api::color::ChromaSampling; use crate::api::ContextInner; use crate::encoder::TEMPORAL_DELIMITER; @@ -14,7 +16,6 @@ use crate::quantize::{ac_q, dc_q, select_ac_qi, select_dc_qi}; use crate::util::{ bexp64, bexp_q24, blog64, clamp, q24_to_q57, q57, q57_to_q24, Pixel, }; -use std::cmp; // The number of frame sub-types for which we track distinct parameters. // This does not include FRAME_SUBTYPE_SEF, because we don't need to do any @@ -1205,7 +1206,7 @@ impl RCState { } if !trial { // Increment the frame count for filter adaptation purposes. - if !trial && self.nframes[fti] < ::std::i32::MAX { + if !trial && self.nframes[fti] < i32::MAX { self.nframes[fti] += 1; } self.reservoir_fullness -= bits; @@ -1302,7 +1303,7 @@ impl RCState { } // If we have encoded too many frames, prevent us from reaching the // ready state required to encode more. - if self.nencoded_frames + self.nsef_frames >= std::i32::MAX as i64 { + if self.nencoded_frames + self.nsef_frames >= i32::MAX as i64 { None? } cur_pos = self.buffer_val( diff --git a/src/rdo.rs b/src/rdo.rs index c2410adfd0..4d82bf5d80 100644 --- a/src/rdo.rs +++ b/src/rdo.rs @@ -10,6 +10,12 @@ #![allow(non_camel_case_types)] +use std::fmt; +use std::mem::MaybeUninit; + +use arrayvec::*; +use itertools::izip; + use crate::api::*; use crate::cdef::*; use crate::context::*; @@ -43,11 +49,6 @@ use crate::write_tx_tree; use crate::Tune; use crate::{encode_block_post_cdef, encode_block_pre_cdef}; -use arrayvec::*; -use itertools::izip; -use std::fmt; -use std::mem::MaybeUninit; - #[derive(Copy, Clone, PartialEq, Eq)] pub enum RDOType { PixelDistRealRate, @@ -105,7 +106,7 @@ pub struct PartitionParameters { impl Default for PartitionParameters { fn default() -> Self { PartitionParameters { - rd_cost: std::f64::MAX, + rd_cost: f64::MAX, bo: TileBlockOffset::default(), bsize: BlockSize::BLOCK_32X32, pred_mode_luma: PredictionMode::default(), @@ -734,7 +735,7 @@ pub fn rdo_tx_size_type( let mut best_tx_type = TxType::DCT_DCT; let mut best_tx_size = tx_size; - let mut best_rd = std::f64::MAX; + let mut best_rd = f64::MAX; let do_rdo_tx_size = fi.tx_mode_select && fi.config.speed_settings.transform.rdo_tx_decision @@ -1703,7 +1704,7 @@ pub fn rdo_tx_type_decision( tx_types: &[TxType], cur_best_rd: f64, ) -> (TxType, f64) { let mut best_type = TxType::DCT_DCT; - let mut best_rd = std::f64::MAX; + let mut best_rd = f64::MAX; let PlaneConfig { xdec, ydec, .. } = ts.input.planes[1].cfg; let is_chroma_block = @@ -1928,7 +1929,7 @@ fn rdo_partition_simple( ); child_modes.push(mode_decision); } else { - //rd_cost_sum += std::f64::MAX; + //rd_cost_sum += f64::MAX; return None; } } diff --git a/src/scenechange/mod.rs b/src/scenechange/mod.rs index 6974a03468..8d8621fea8 100644 --- a/src/scenechange/mod.rs +++ b/src/scenechange/mod.rs @@ -7,8 +7,10 @@ // Media Patent License 1.0 was not distributed with this source code in the // PATENTS file, you can obtain it at www.aomedia.org/license/patent. -mod fast; -mod standard; +use std::cmp; +use std::collections::BTreeMap; +use std::num::NonZeroUsize; +use std::sync::Arc; use crate::api::{EncoderConfig, SceneDetectionSpeed}; use crate::cpu_features::CpuFeatureLevel; @@ -16,13 +18,12 @@ use crate::encoder::Sequence; use crate::frame::*; use crate::me::RefMEStats; use crate::util::Pixel; -use std::collections::BTreeMap; -use std::num::NonZeroUsize; -use std::sync::Arc; -use std::{cmp, u64}; use self::fast::{detect_scale_factor, FAST_THRESHOLD}; +mod fast; +mod standard; + /// Experiments have determined this to be an optimal threshold const IMP_BLOCK_DIFF_THRESHOLD: f64 = 7.0;