Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
astraw committed Dec 6, 2024
1 parent e70b8c3 commit c1dd3de
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
17 changes: 8 additions & 9 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/nal_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions src/ycbcr_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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, _, _)) => {
Expand All @@ -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),
Expand Down

0 comments on commit c1dd3de

Please sign in to comment.