Skip to content

Commit

Permalink
chore: Fix various stable/beta/nightly Clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
torokati44 authored and kmeisthax committed Aug 26, 2023
1 parent 5faa069 commit 1670066
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion deblock/src/deblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 5 additions & 6 deletions h263/src/decoder/picture.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Decoded picture type

use std::vec;

use crate::types::{Picture, SourceFormat};

/// A decoded picture.
Expand Down Expand Up @@ -37,16 +39,13 @@ impl DecodedPicture {
pub fn new(picture_header: Picture, format: SourceFormat) -> Option<Self> {
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,
Expand Down
2 changes: 1 addition & 1 deletion h263/src/parser/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions h263/src/parser/macroblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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));
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions h263/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand Down

0 comments on commit 1670066

Please sign in to comment.