From 7bcd5412d18954a9b0efd288f1ef43bc62c59d3a Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Tue, 12 Sep 2023 15:44:22 +0200 Subject: [PATCH] Address new clippy lints --- src/activity.rs | 2 +- src/asm/aarch64/cdef.rs | 6 +++--- src/asm/aarch64/dist.rs | 1 + src/asm/aarch64/mc.rs | 6 +++--- src/asm/aarch64/predict.rs | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/activity.rs b/src/activity.rs index ae29826538..79344434cf 100644 --- a/src/activity.rs +++ b/src/activity.rs @@ -215,7 +215,7 @@ mod ssim_boost_tests { const C3: f64 = 12338f64; const RATIO: f64 = C1 / C3; - RATIO * (svar + dvar + C2) / f64::sqrt(C1 * C1 + svar * dvar) + RATIO * (svar + dvar + C2) / f64::sqrt(C1.mul_add(C1, svar * dvar)) } /// Test that `ssim_boost` has sufficient accuracy. diff --git a/src/asm/aarch64/cdef.rs b/src/asm/aarch64/cdef.rs index 2fe70e1248..7ef61e83a9 100644 --- a/src/asm/aarch64/cdef.rs +++ b/src/asm/aarch64/cdef.rs @@ -100,7 +100,7 @@ pub(crate) unsafe fn cdef_filter_block( CDEF_FILTER_FNS[cpu.as_index()][decimate_index(xdec, ydec)], ) { (Some(pad), Some(func)) => { - let h = if ydec == 1 { 4 } else { 8 } as i32; + let h = if ydec == 1 { 4 } else { 8 }; let tmpstride = if xdec == 1 { 8 } else { 16 } as isize; const MAXTMPSTRIDE: isize = 16; const TMPSIZE: usize = (12 * MAXTMPSTRIDE + 8) as usize; @@ -167,7 +167,7 @@ pub(crate) unsafe fn cdef_filter_block( // clause using Rust macros. See comments above for // indexing/addressing notes. (Some(pad), Some(func)) => { - let h = if ydec == 1 { 4 } else { 8 } as i32; + let h = if ydec == 1 { 4 } else { 8 }; let tmpstride = if xdec == 1 { 8 } else { 16 } as isize; const MAXTMPSTRIDE: isize = 16; const TMPSIZE: usize = (12 * MAXTMPSTRIDE + 8) as usize; @@ -370,7 +370,7 @@ pub(crate) fn cdef_find_dir( img.as_ptr() as *const _, T::to_asm_stride(img.plane.cfg.stride), var as *mut u32, - (1 << coeff_shift + 8) - 1, + (1 << (coeff_shift + 8)) - 1, ) } } else { diff --git a/src/asm/aarch64/dist.rs b/src/asm/aarch64/dist.rs index 64cf0f1766..d5898717bf 100644 --- a/src/asm/aarch64/dist.rs +++ b/src/asm/aarch64/dist.rs @@ -109,6 +109,7 @@ pub fn get_sad( } #[inline(always)] +#[allow(clippy::let_and_return)] pub fn get_satd( src: &PlaneRegion<'_, T>, dst: &PlaneRegion<'_, T>, w: usize, h: usize, bit_depth: usize, cpu: CpuFeatureLevel, diff --git a/src/asm/aarch64/mc.rs b/src/asm/aarch64/mc.rs index bed48b769d..c64d616fb4 100644 --- a/src/asm/aarch64/mc.rs +++ b/src/asm/aarch64/mc.rs @@ -105,7 +105,7 @@ pub fn put_8tap( // SAFETY: The assembly only supports even heights and valid uncropped // widths assert_eq!(height & 1, 0); - assert!(width.is_power_of_two() && 2 <= width && width <= 128); + assert!(width.is_power_of_two() && (2..=128).contains(&width)); // SAFETY: Check bounds of dst assert!(dst.rect().width >= width && dst.rect().height >= height); @@ -188,7 +188,7 @@ pub fn prep_8tap( // SAFETY: The assembly only supports even heights and valid uncropped // widths assert_eq!(height & 1, 0); - assert!(width.is_power_of_two() && 2 <= width && width <= 128); + assert!(width.is_power_of_two() && (2..=128).contains(&width)); // SAFETY: Check length of tmp assert!(tmp.len() >= width * height); @@ -256,7 +256,7 @@ pub fn mc_avg( // SAFETY: The assembly only supports even heights and valid uncropped // widths assert_eq!(height & 1, 0); - assert!(width.is_power_of_two() && 2 <= width && width <= 128); + assert!(width.is_power_of_two() && (2..=128).contains(&width)); // SAFETY: Check bounds of dst assert!(dst.rect().width >= width && dst.rect().height >= height); diff --git a/src/asm/aarch64/predict.rs b/src/asm/aarch64/predict.rs index cd584c2429..1db55eed2f 100644 --- a/src/asm/aarch64/predict.rs +++ b/src/asm/aarch64/predict.rs @@ -385,7 +385,7 @@ unsafe fn ipred_z2( let mut out = [MaybeUninit::::uninit(); 3 * (MAX_TX_SIZE * 4 + 1)]; let out = out.as_mut_ptr() as *mut T; let left = out.add(2 * (64 + 1)); - let top = out.add(1 * (64 + 1)); + let top = out.add(64 + 1); let flipped = out; if us_above { ipred_z2_upsample_edge(top, w, src, bd_max); @@ -586,7 +586,7 @@ pub fn dispatch_predict_intra( let smooth_filter = ief_params .map(IntraEdgeFilterParameters::use_smooth_filter) .unwrap_or_default(); - if angle >= 90 && angle <= 180 { + if (90..=180).contains(&angle) { // From dav1d, bw and bh are the frame width and height rounded to 8px units let (bw, bh) = ( ((dst.plane_cfg.width + 7) >> 3) << 3,