Skip to content

Commit

Permalink
Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zero committed Dec 24, 2024
1 parent 77c7a69 commit 38a1054
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 29 deletions.
5 changes: 1 addition & 4 deletions src/api/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/context/block_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ impl IndexMut<PlaneBlockOffset> for FrameBlocks {
}
}

impl<'a> ContextWriter<'a> {
impl ContextWriter<'_> {
pub fn get_cdf_intra_mode_kf(
&self, bo: TileBlockOffset,
) -> &[u16; INTRA_MODES] {
Expand Down
2 changes: 1 addition & 1 deletion src/context/frame_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/context/partition_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
Expand Down Expand Up @@ -409,7 +409,7 @@ impl<'a> ContextWriter<'a> {
}
}

impl<'a> BlockContext<'a> {
impl BlockContext<'_> {
/// # Panics
///
/// - If called with a non-square `bsize`
Expand Down
2 changes: 1 addition & 1 deletion src/context/transform_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions src/rdo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ pub fn sse_wxh<T: Pixel, F: Fn(Area, BlockSize) -> 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
Expand Down Expand Up @@ -223,6 +223,8 @@ pub fn sse_wxh<T: Pixel, F: Fn(Area, BlockSize) -> 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) {
Expand Down
2 changes: 1 addition & 1 deletion src/tiling/plane_region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Pixel> PlaneRegionMut<'_, T> {
#[inline(always)]
pub fn data_ptr_mut(&mut self) -> *mut T {
self.data
Expand Down
2 changes: 1 addition & 1 deletion src/tiling/tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Pixel> TileMut<'_, T> {
#[inline(always)]
pub fn as_const(&self) -> Tile<'_, T> {
Tile {
Expand Down
4 changes: 2 additions & 2 deletions src/tiling/tile_restoration_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 4 additions & 12 deletions src/tiling/tiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 38a1054

Please sign in to comment.