From 16700664e2b3334f0a930f99af86011aebee14cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=96R=C3=96K=20Attila?= Date: Fri, 25 Aug 2023 23:37:40 +0200 Subject: [PATCH] chore: Fix various stable/beta/nightly Clippy lints --- deblock/src/deblock.rs | 2 +- h263/src/decoder/picture.rs | 11 +++++------ h263/src/parser/block.rs | 2 +- h263/src/parser/macroblock.rs | 10 +++++----- h263/src/types.rs | 4 ++-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/deblock/src/deblock.rs b/deblock/src/deblock.rs index d26c532..f12c96e 100644 --- a/deblock/src/deblock.rs +++ b/deblock/src/deblock.rs @@ -77,7 +77,7 @@ mod simd_impl { /// Utility to upcast and convert a slice of 8 `u8` values into a `i16x8` vector. #[inline] - fn into_simd16(a: &mut [u8]) -> i16x8 { + fn into_simd16(a: &[u8]) -> i16x8 { debug_assert!(a.len() == 8); // might even help the optimizer in release mode...? i16x8::from([ a[0] as i16, diff --git a/h263/src/decoder/picture.rs b/h263/src/decoder/picture.rs index e9276db..4b5053c 100644 --- a/h263/src/decoder/picture.rs +++ b/h263/src/decoder/picture.rs @@ -1,5 +1,7 @@ //! Decoded picture type +use std::vec; + use crate::types::{Picture, SourceFormat}; /// A decoded picture. @@ -37,16 +39,13 @@ impl DecodedPicture { pub fn new(picture_header: Picture, format: SourceFormat) -> Option { let (w, h) = format.into_width_and_height()?; let luma_samples = w as usize * h as usize; - let mut luma = Vec::new(); - luma.resize(luma_samples, 0); + let luma = vec![0; luma_samples]; let chroma_w = (w as f32 / 2.0).ceil() as usize; let chroma_h = (h as f32 / 2.0).ceil() as usize; let chroma_samples = chroma_w * chroma_h; - let mut chroma_b = Vec::new(); - chroma_b.resize(chroma_samples, 0); - let mut chroma_r = Vec::new(); - chroma_r.resize(chroma_samples, 0); + let chroma_b = vec![0; chroma_samples]; + let chroma_r = vec![0; chroma_samples]; Some(Self { picture_header, diff --git a/h263/src/parser/block.rs b/h263/src/parser/block.rs index f269553..af686f8 100644 --- a/h263/src/parser/block.rs +++ b/h263/src/parser/block.rs @@ -766,7 +766,7 @@ mod tests { #[test] #[allow(clippy::inconsistent_digit_grouping)] fn tcoef_table() { - let bit_pattern = vec![ + let bit_pattern = &[ 0b10_1111_01, 0b0101_0010, 0b111_00011, diff --git a/h263/src/parser/macroblock.rs b/h263/src/parser/macroblock.rs index 350137d..f9ee686 100644 --- a/h263/src/parser/macroblock.rs +++ b/h263/src/parser/macroblock.rs @@ -559,7 +559,7 @@ mod tests { #[test] #[allow(clippy::inconsistent_digit_grouping)] fn macroblock_mcbpc_iframe() { - let bit_pattern = vec![ + let bit_pattern = &[ 0b1_001_010_0, 0b11_0001_00, 0b0001_0000, @@ -614,7 +614,7 @@ mod tests { #[test] #[allow(clippy::inconsistent_digit_grouping)] fn macroblock_mcbpc_pframe() { - let bit_pattern = vec![ + let bit_pattern = &[ 0b1_0011_001, 0b0_000101_0, 0b11_000011, @@ -752,7 +752,7 @@ mod tests { #[test] #[allow(clippy::inconsistent_digit_grouping)] fn macroblock_modb_table() { - let bit_pattern = vec![0b0_10_11_000]; + let bit_pattern = &[0b0_10_11_000]; let mut reader = H263Reader::from_source(&bit_pattern[..]); assert_eq!(reader.read_vlc(&MODB_TABLE).unwrap(), (false, false)); @@ -763,7 +763,7 @@ mod tests { #[test] #[allow(clippy::inconsistent_digit_grouping)] fn macroblock_cbpy_table() { - let bit_pattern = vec![ + let bit_pattern = &[ 0b0011_0010, 0b1_00100_10, 0b01_00011_0, @@ -848,7 +848,7 @@ mod tests { #[test] #[allow(clippy::inconsistent_digit_grouping)] fn macroblock_mvd_table() { - let bit_pattern = vec![ + let bit_pattern = &[ 0b00000000, 0b00101_000, 0b00000001, diff --git a/h263/src/types.rs b/h263/src/types.rs index 7e19a9c..073293a 100644 --- a/h263/src/types.rs +++ b/h263/src/types.rs @@ -759,8 +759,8 @@ impl HalfPel { let frac = self.0 & 0x0F; match frac { - 0 | 1 | 2 => Self(whole), - 14 | 15 => Self(whole + 2), + 0..=2 => Self(whole), + 14..=15 => Self(whole + 2), _ => Self(whole + 1), } }