From c1dd3de5a593c1ceb85240b8cc8f765029af2a1c Mon Sep 17 00:00:00 2001 From: Andrew Straw Date: Fri, 6 Dec 2024 09:23:27 +0100 Subject: [PATCH] clippy fixes --- src/encoder.rs | 17 ++++++++--------- src/lib.rs | 4 ++-- src/nal_unit.rs | 2 +- src/ycbcr_image.rs | 6 +++--- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/encoder.rs b/src/encoder.rs index 88b24f7..a4ceb7b 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -38,15 +38,14 @@ impl LessEncoder { let bit_depth = y4m_frame.luma_bit_depth(); - match (&y4m_frame.planes, &bit_depth, width % 4 == 0) { - (Planes::YCbCr(_), BitDepth::Depth12, false) => { - return Err(Error::DataShapeProblem { - msg: "for bit depth 12 color, width must be divisible by 4", - #[cfg(feature = "backtrace")] - backtrace: Backtrace::capture(), - }); - } - _ => {} + if let (Planes::YCbCr(_), BitDepth::Depth12, false) = + (&y4m_frame.planes, &bit_depth, width % 4 == 0) + { + return Err(Error::DataShapeProblem { + msg: "for bit depth 12 color, width must be divisible by 4", + #[cfg(feature = "backtrace")] + backtrace: Backtrace::capture(), + }); } match (&y4m_frame.planes, &bit_depth, width % 2 == 0) { diff --git a/src/lib.rs b/src/lib.rs index 8e753ee..7abaa6f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -326,8 +326,8 @@ impl ProfileIdc { let bit_depth_luma_minus8 = bit_depth.num_bits() - 8; let bit_depth_chroma_minus8 = bit_depth.num_bits() - 8; - bv.extend_exp_golomb(bit_depth_luma_minus8.try_into().unwrap()); - bv.extend_exp_golomb(bit_depth_chroma_minus8.try_into().unwrap()); + bv.extend_exp_golomb(bit_depth_luma_minus8.into()); + bv.extend_exp_golomb(bit_depth_chroma_minus8.into()); // qpprime_y_zero_transform_bypass_flag 0 bv.push(false); diff --git a/src/nal_unit.rs b/src/nal_unit.rs index ffe7a84..742a506 100644 --- a/src/nal_unit.rs +++ b/src/nal_unit.rs @@ -130,7 +130,7 @@ pub(crate) fn rbsp_to_ebsp(rbsp_buf: &[u8], nal_buf: &mut [u8]) -> usize { #[inline] /// Returns true if byte is 0x00, 0x01, 0x02 or 0x03. fn needs_protecting_in_pos3(byte: u8) -> bool { - matches!(byte, 0x00 | 0x01 | 0x02 | 0x03) + matches!(byte, 0x00..=0x03) } #[test] diff --git a/src/ycbcr_image.rs b/src/ycbcr_image.rs index c8cc6bf..3c1f908 100644 --- a/src/ycbcr_image.rs +++ b/src/ycbcr_image.rs @@ -25,7 +25,7 @@ pub struct YCbCrImage<'a> { pub height: u32, } -impl<'a> YCbCrImage<'a> { +impl YCbCrImage<'_> { pub(crate) fn luma_bit_depth(&self) -> BitDepth { match &self.planes { Planes::Mono(y) => y.bit_depth, @@ -54,7 +54,7 @@ pub struct DataPlane<'a> { pub bit_depth: BitDepth, } -impl<'a> YCbCrImage<'a> { +impl YCbCrImage<'_> { pub(crate) fn check_sizes(&self) -> Result<()> { match &self.planes { Planes::Mono(y_plane) | Planes::YCbCr((y_plane, _, _)) => { @@ -74,7 +74,7 @@ impl<'a> YCbCrImage<'a> { } } -impl<'a> DataPlane<'a> { +impl DataPlane<'_> { pub(crate) fn check_sizes(&self, width: u32, height: u32, mb_sz: u32) -> Result<()> { let (width_factor_num, width_factor_denom) = match self.bit_depth { BitDepth::Depth8 => (1, 1),