Skip to content

Commit 38a1054

Browse files
committed
Fix clippy lints
1 parent 77c7a69 commit 38a1054

12 files changed

+19
-29
lines changed

src/api/config/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,7 @@ impl Config {
422422
if config.height > AV1_LEVEL_MAX_V_SIZE[level_idx as usize] {
423423
return Err(LevelConstraintsExceeded);
424424
}
425-
if ((config.width * config.height) as u64 * config.time_base.num
426-
+ config.time_base.den
427-
- 1)
428-
/ config.time_base.den
425+
if ((config.width * config.height) as u64 * config.time_base.num).div_ceil(config.time_base.den)
429426
> AV1_LEVEL_MAX_DISPLAY_RATE[level_idx as usize] as u64
430427
{
431428
return Err(LevelConstraintsExceeded);

src/context/block_unit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ impl IndexMut<PlaneBlockOffset> for FrameBlocks {
676676
}
677677
}
678678

679-
impl<'a> ContextWriter<'a> {
679+
impl ContextWriter<'_> {
680680
pub fn get_cdf_intra_mode_kf(
681681
&self, bo: TileBlockOffset,
682682
) -> &[u16; INTRA_MODES] {

src/context/frame_header.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl CDFContext {
4545
}
4646
}
4747

48-
impl<'a> ContextWriter<'a> {
48+
impl ContextWriter<'_> {
4949
fn get_ref_frame_ctx_b0(&self, bo: TileBlockOffset) -> usize {
5050
let ref_counts = self.bc.blocks[bo].neighbors_ref_counts;
5151

src/context/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub fn get_mv_class(z: u32) -> (usize, u32) {
177177
(c, offset)
178178
}
179179

180-
impl<'a> ContextWriter<'a> {
180+
impl ContextWriter<'_> {
181181
/// # Panics
182182
///
183183
/// - If the `comp` is 0

src/context/partition_unit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl CFLParams {
127127
}
128128
}
129129

130-
impl<'a> ContextWriter<'a> {
130+
impl ContextWriter<'_> {
131131
fn partition_gather_horz_alike(
132132
out: &mut [u16; 2], cdf_in: &[u16], _bsize: BlockSize,
133133
) {
@@ -409,7 +409,7 @@ impl<'a> ContextWriter<'a> {
409409
}
410410
}
411411

412-
impl<'a> BlockContext<'a> {
412+
impl BlockContext<'_> {
413413
/// # Panics
414414
///
415415
/// - If called with a non-square `bsize`

src/context/transform_unit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ pub struct TXB_CTX {
523523
pub dc_sign_ctx: usize,
524524
}
525525

526-
impl<'a> ContextWriter<'a> {
526+
impl ContextWriter<'_> {
527527
/// # Panics
528528
///
529529
/// - If an invalid combination of `tx_type` and `tx_size` is passed

src/ec.rs

-1
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,6 @@ where
761761
/// - `n`: size of interval
762762
/// - `k`: "parameter"
763763
/// - `r`: reference
764-
765764
fn count_signed_subexp_with_ref(
766765
&self, v: i32, low: i32, high: i32, k: u8, r: i32,
767766
) -> u32 {

src/rdo.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ pub fn sse_wxh<T: Pixel, F: Fn(Area, BlockSize) -> DistortionScale>(
189189

190190
let imp_bsize = BlockSize::from_width_and_height(imp_block_w, imp_block_h);
191191

192-
let n_imp_blocks_w = (w + CHUNK_SIZE - 1) / CHUNK_SIZE;
193-
let n_imp_blocks_h = (h + CHUNK_SIZE - 1) / CHUNK_SIZE;
192+
let n_imp_blocks_w = w.div_ceil(CHUNK_SIZE);
193+
let n_imp_blocks_h = h.div_ceil(CHUNK_SIZE);
194194

195195
// TODO: Copying biases into a buffer is slow. It would be best if biases were
196196
// passed directly. To do this, we would need different versions of the
@@ -223,6 +223,8 @@ pub fn sse_wxh<T: Pixel, F: Fn(Area, BlockSize) -> DistortionScale>(
223223
))
224224
}
225225

226+
// TODO consider saturating_sub later
227+
#[allow(clippy::implicit_saturating_sub)]
226228
pub const fn clip_visible_bsize(
227229
frame_w: usize, frame_h: usize, bsize: BlockSize, x: usize, y: usize,
228230
) -> (usize, usize) {

src/tiling/plane_region.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ macro_rules! plane_region_common {
423423
plane_region_common!(PlaneRegion, as_ptr);
424424
plane_region_common!(PlaneRegionMut, as_mut_ptr, mut);
425425

426-
impl<'a, T: Pixel> PlaneRegionMut<'a, T> {
426+
impl<T: Pixel> PlaneRegionMut<'_, T> {
427427
#[inline(always)]
428428
pub fn data_ptr_mut(&mut self) -> *mut T {
429429
self.data

src/tiling/tile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ macro_rules! tile_common {
203203
tile_common!(Tile, PlaneRegion, iter);
204204
tile_common!(TileMut, PlaneRegionMut, iter_mut, mut);
205205

206-
impl<'a, T: Pixel> TileMut<'a, T> {
206+
impl<T: Pixel> TileMut<'_, T> {
207207
#[inline(always)]
208208
pub fn as_const(&self) -> Tile<'_, T> {
209209
Tile {

src/tiling/tile_restoration_state.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ tile_restoration_plane_common!(
277277
mut
278278
);
279279

280-
impl<'a> TileRestorationPlaneMut<'a> {
280+
impl TileRestorationPlaneMut<'_> {
281281
#[inline(always)]
282282
pub fn restoration_unit_mut(
283283
&mut self, sbo: TileSuperBlockOffset,
@@ -412,7 +412,7 @@ tile_restoration_state_common!(
412412
mut
413413
);
414414

415-
impl<'a> TileRestorationStateMut<'a> {
415+
impl TileRestorationStateMut<'_> {
416416
#[inline(always)]
417417
pub const fn as_const(&self) -> TileRestorationState {
418418
TileRestorationState {

src/tiling/tiler.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -115,29 +115,21 @@ impl TilingInfo {
115115
tile_width_sb_pre
116116
};
117117

118-
let cols = (frame_width_sb + tile_width_sb - 1) / tile_width_sb;
118+
let cols = frame_width_sb.div_ceil(tile_width_sb);
119119

120120
// Adjust tile_cols_log2 in case of rounding tile_width_sb to even.
121121
let tile_cols_log2 = Self::tile_log2(1, cols).unwrap();
122122
assert!(tile_cols_log2 >= min_tile_cols_log2);
123123

124-
let min_tile_rows_log2 = if min_tiles_log2 > tile_cols_log2 {
125-
min_tiles_log2 - tile_cols_log2
126-
} else {
127-
0
128-
};
124+
let min_tile_rows_log2 = min_tiles_log2.saturating_sub(tile_cols_log2);
129125
let min_tile_rows_ratelimit_log2 =
130-
if min_tiles_ratelimit_log2 > tile_cols_log2 {
131-
min_tiles_ratelimit_log2 - tile_cols_log2
132-
} else {
133-
0
134-
};
126+
min_tiles_ratelimit_log2.saturating_sub(tile_cols_log2);
135127
let tile_rows_log2 = tile_rows_log2
136128
.max(min_tile_rows_log2)
137129
.clamp(min_tile_rows_ratelimit_log2, max_tile_rows_log2);
138130
let tile_height_sb = sb_rows.align_power_of_two_and_shift(tile_rows_log2);
139131

140-
let rows = (frame_height_sb + tile_height_sb - 1) / tile_height_sb;
132+
let rows = frame_height_sb.div_ceil(tile_height_sb);
141133

142134
Self {
143135
frame_width,

0 commit comments

Comments
 (0)