diff --git a/src/api/config/mod.rs b/src/api/config/mod.rs index 21eff85bd0..474b7be64f 100644 --- a/src/api/config/mod.rs +++ b/src/api/config/mod.rs @@ -422,10 +422,7 @@ impl Config { if config.height > AV1_LEVEL_MAX_V_SIZE[level_idx as usize] { return Err(LevelConstraintsExceeded); } - if ((config.width * config.height) as u64 * config.time_base.num - + config.time_base.den - - 1) - / config.time_base.den + if ((config.width * config.height) as u64 * config.time_base.num).div_ceil(config.time_base.den) > AV1_LEVEL_MAX_DISPLAY_RATE[level_idx as usize] as u64 { return Err(LevelConstraintsExceeded); diff --git a/src/context/block_unit.rs b/src/context/block_unit.rs index fc8ff0185e..410953ad98 100644 --- a/src/context/block_unit.rs +++ b/src/context/block_unit.rs @@ -676,7 +676,7 @@ impl IndexMut for FrameBlocks { } } -impl<'a> ContextWriter<'a> { +impl ContextWriter<'_> { pub fn get_cdf_intra_mode_kf( &self, bo: TileBlockOffset, ) -> &[u16; INTRA_MODES] { diff --git a/src/context/frame_header.rs b/src/context/frame_header.rs index 26ad60ad24..391057d389 100644 --- a/src/context/frame_header.rs +++ b/src/context/frame_header.rs @@ -45,7 +45,7 @@ impl CDFContext { } } -impl<'a> ContextWriter<'a> { +impl ContextWriter<'_> { fn get_ref_frame_ctx_b0(&self, bo: TileBlockOffset) -> usize { let ref_counts = self.bc.blocks[bo].neighbors_ref_counts; diff --git a/src/context/mod.rs b/src/context/mod.rs index de23198e6c..700fd66c9e 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -177,7 +177,7 @@ pub fn get_mv_class(z: u32) -> (usize, u32) { (c, offset) } -impl<'a> ContextWriter<'a> { +impl ContextWriter<'_> { /// # Panics /// /// - If the `comp` is 0 diff --git a/src/context/partition_unit.rs b/src/context/partition_unit.rs index 8a8b3f2753..64f4a57638 100644 --- a/src/context/partition_unit.rs +++ b/src/context/partition_unit.rs @@ -127,7 +127,7 @@ impl CFLParams { } } -impl<'a> ContextWriter<'a> { +impl ContextWriter<'_> { fn partition_gather_horz_alike( out: &mut [u16; 2], cdf_in: &[u16], _bsize: BlockSize, ) { @@ -409,7 +409,7 @@ impl<'a> ContextWriter<'a> { } } -impl<'a> BlockContext<'a> { +impl BlockContext<'_> { /// # Panics /// /// - If called with a non-square `bsize` diff --git a/src/context/transform_unit.rs b/src/context/transform_unit.rs index a19f58aa05..09013d3f25 100644 --- a/src/context/transform_unit.rs +++ b/src/context/transform_unit.rs @@ -523,7 +523,7 @@ pub struct TXB_CTX { pub dc_sign_ctx: usize, } -impl<'a> ContextWriter<'a> { +impl ContextWriter<'_> { /// # Panics /// /// - If an invalid combination of `tx_type` and `tx_size` is passed diff --git a/src/ec.rs b/src/ec.rs index a6c9563ff7..f84f2a07db 100644 --- a/src/ec.rs +++ b/src/ec.rs @@ -761,7 +761,6 @@ where /// - `n`: size of interval /// - `k`: "parameter" /// - `r`: reference - fn count_signed_subexp_with_ref( &self, v: i32, low: i32, high: i32, k: u8, r: i32, ) -> u32 { diff --git a/src/rdo.rs b/src/rdo.rs index 4d82bf5d80..aca95cad0b 100644 --- a/src/rdo.rs +++ b/src/rdo.rs @@ -189,8 +189,8 @@ pub fn sse_wxh DistortionScale>( let imp_bsize = BlockSize::from_width_and_height(imp_block_w, imp_block_h); - let n_imp_blocks_w = (w + CHUNK_SIZE - 1) / CHUNK_SIZE; - let n_imp_blocks_h = (h + CHUNK_SIZE - 1) / CHUNK_SIZE; + let n_imp_blocks_w = w.div_ceil(CHUNK_SIZE); + let n_imp_blocks_h = h.div_ceil(CHUNK_SIZE); // TODO: Copying biases into a buffer is slow. It would be best if biases were // passed directly. To do this, we would need different versions of the @@ -223,6 +223,8 @@ pub fn sse_wxh DistortionScale>( )) } +// TODO consider saturating_sub later +#[allow(clippy::implicit_saturating_sub)] pub const fn clip_visible_bsize( frame_w: usize, frame_h: usize, bsize: BlockSize, x: usize, y: usize, ) -> (usize, usize) { diff --git a/src/tiling/plane_region.rs b/src/tiling/plane_region.rs index 168b1edeb4..6f43b9dd6b 100644 --- a/src/tiling/plane_region.rs +++ b/src/tiling/plane_region.rs @@ -423,7 +423,7 @@ macro_rules! plane_region_common { plane_region_common!(PlaneRegion, as_ptr); plane_region_common!(PlaneRegionMut, as_mut_ptr, mut); -impl<'a, T: Pixel> PlaneRegionMut<'a, T> { +impl PlaneRegionMut<'_, T> { #[inline(always)] pub fn data_ptr_mut(&mut self) -> *mut T { self.data diff --git a/src/tiling/tile.rs b/src/tiling/tile.rs index 82f9761a8b..16f4a6f256 100644 --- a/src/tiling/tile.rs +++ b/src/tiling/tile.rs @@ -203,7 +203,7 @@ macro_rules! tile_common { tile_common!(Tile, PlaneRegion, iter); tile_common!(TileMut, PlaneRegionMut, iter_mut, mut); -impl<'a, T: Pixel> TileMut<'a, T> { +impl TileMut<'_, T> { #[inline(always)] pub fn as_const(&self) -> Tile<'_, T> { Tile { diff --git a/src/tiling/tile_restoration_state.rs b/src/tiling/tile_restoration_state.rs index b56ce496a7..73e6c8c4aa 100644 --- a/src/tiling/tile_restoration_state.rs +++ b/src/tiling/tile_restoration_state.rs @@ -277,7 +277,7 @@ tile_restoration_plane_common!( mut ); -impl<'a> TileRestorationPlaneMut<'a> { +impl TileRestorationPlaneMut<'_> { #[inline(always)] pub fn restoration_unit_mut( &mut self, sbo: TileSuperBlockOffset, @@ -412,7 +412,7 @@ tile_restoration_state_common!( mut ); -impl<'a> TileRestorationStateMut<'a> { +impl TileRestorationStateMut<'_> { #[inline(always)] pub const fn as_const(&self) -> TileRestorationState { TileRestorationState { diff --git a/src/tiling/tiler.rs b/src/tiling/tiler.rs index 0d74a3a2a5..9d6b28a078 100644 --- a/src/tiling/tiler.rs +++ b/src/tiling/tiler.rs @@ -115,29 +115,21 @@ impl TilingInfo { tile_width_sb_pre }; - let cols = (frame_width_sb + tile_width_sb - 1) / tile_width_sb; + let cols = frame_width_sb.div_ceil(tile_width_sb); // Adjust tile_cols_log2 in case of rounding tile_width_sb to even. let tile_cols_log2 = Self::tile_log2(1, cols).unwrap(); assert!(tile_cols_log2 >= min_tile_cols_log2); - let min_tile_rows_log2 = if min_tiles_log2 > tile_cols_log2 { - min_tiles_log2 - tile_cols_log2 - } else { - 0 - }; + let min_tile_rows_log2 = min_tiles_log2.saturating_sub(tile_cols_log2); let min_tile_rows_ratelimit_log2 = - if min_tiles_ratelimit_log2 > tile_cols_log2 { - min_tiles_ratelimit_log2 - tile_cols_log2 - } else { - 0 - }; + min_tiles_ratelimit_log2.saturating_sub(tile_cols_log2); let tile_rows_log2 = tile_rows_log2 .max(min_tile_rows_log2) .clamp(min_tile_rows_ratelimit_log2, max_tile_rows_log2); let tile_height_sb = sb_rows.align_power_of_two_and_shift(tile_rows_log2); - let rows = (frame_height_sb + tile_height_sb - 1) / tile_height_sb; + let rows = frame_height_sb.div_ceil(tile_height_sb); Self { frame_width,