From: Kostya Shishkov Date: Thu, 7 Nov 2024 18:30:29 +0000 (+0100) Subject: nihav_duck: refresh and fix clippy warnings X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=20b5a55f4dd5dada969e22a0a98a59f122ff4b9b;p=nihav.git nihav_duck: refresh and fix clippy warnings --- diff --git a/nihav-duck/src/codecs/dkadpcm.rs b/nihav-duck/src/codecs/dkadpcm.rs index cdd58b6..5de91d5 100644 --- a/nihav-duck/src/codecs/dkadpcm.rs +++ b/nihav-duck/src/codecs/dkadpcm.rs @@ -42,6 +42,7 @@ impl NADecoder for DuckADPCMDecoder { Err(DecoderError::InvalidData) } } + #[allow(clippy::identity_op)] fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult { let info = pkt.get_stream().get_info(); if let NACodecTypeInfo::Audio(_) = info.get_properties() { diff --git a/nihav-duck/src/codecs/mod.rs b/nihav-duck/src/codecs/mod.rs index 63e899f..3afef90 100644 --- a/nihav-duck/src/codecs/mod.rs +++ b/nihav-duck/src/codecs/mod.rs @@ -16,39 +16,30 @@ mod truemotion1data; #[cfg(feature="decoder_truemotionrt")] mod truemotionrt; #[cfg(feature="decoder_truemotion2")] -#[allow(clippy::needless_range_loop)] mod truemotion2; #[cfg(feature="decoder_truemotion2x")] mod truemotion2x; #[cfg(any(feature="decoder_vp3", feature="decoder_vp4", feature="decoder_vp5", feature="decoder_vp6", feature="decoder_vp7"))] #[macro_use] #[allow(clippy::erasing_op)] -#[allow(clippy::needless_range_loop)] +#[allow(clippy::identity_op)] #[allow(clippy::too_many_arguments)] -#[allow(clippy::useless_let_if_seq)] mod vpcommon; #[cfg(any(feature="decoder_vp3", feature="decoder_vp4"))] -#[allow(clippy::needless_range_loop)] #[allow(clippy::too_many_arguments)] mod vp3; #[cfg(any(feature="decoder_vp5", feature="decoder_vp6"))] -#[allow(clippy::needless_range_loop)] -#[allow(clippy::useless_let_if_seq)] #[allow(clippy::too_many_arguments)] mod vp56; #[cfg(feature="decoder_vp5")] -#[allow(clippy::needless_range_loop)] mod vp5; #[cfg(any(feature="decoder_vp6", feature="encoder_vp6"))] mod vp6data; #[cfg(any(feature="decoder_vp6", feature="encoder_vp6"))] mod vp6dsp; #[cfg(feature="decoder_vp6")] -#[allow(clippy::needless_range_loop)] mod vp6; #[cfg(feature="decoder_vp7")] -#[allow(clippy::needless_range_loop)] -#[allow(clippy::useless_let_if_seq)] mod vp7; #[cfg(any(feature="decoder_vp7", feature="encoder_vp7"))] mod vp7data; @@ -56,38 +47,32 @@ mod vp7data; mod vp78data; #[cfg(feature="decoder_vp7")] #[allow(clippy::erasing_op)] -#[allow(clippy::needless_range_loop)] +#[allow(clippy::identity_op)] #[allow(clippy::too_many_arguments)] -#[allow(clippy::useless_let_if_seq)] mod vp7dsp; #[cfg(any(feature="decoder_vp7", feature="decoder_vp8", feature="encoder_vp7"))] #[allow(clippy::needless_range_loop)] -#[allow(clippy::useless_let_if_seq)] mod vp78; #[cfg(any(feature="decoder_vp7", feature="decoder_vp8", feature="encoder_vp7"))] #[allow(clippy::erasing_op)] -#[allow(clippy::needless_range_loop)] +#[allow(clippy::identity_op)] #[allow(clippy::too_many_arguments)] -#[allow(clippy::useless_let_if_seq)] mod vp78dsp; #[cfg(feature="decoder_vp8")] -#[allow(clippy::needless_range_loop)] -#[allow(clippy::useless_let_if_seq)] mod vp8; #[cfg(feature="decoder_vp8")] #[allow(clippy::erasing_op)] -#[allow(clippy::needless_range_loop)] +#[allow(clippy::identity_op)] #[allow(clippy::too_many_arguments)] mod vp8dsp; #[cfg(any(feature="decoder_dk3_adpcm", feature="decoder_dk4_adpcm"))] mod dkadpcm; #[cfg(feature="decoder_on2avc")] -#[allow(clippy::manual_memcpy)] -#[allow(clippy::needless_range_loop)] #[allow(clippy::too_many_arguments)] mod on2avc; #[cfg(feature="decoder_on2avc")] +#[allow(clippy::excessive_precision)] mod on2avcdata; const DUCK_CODECS: &[DecoderInfo] = &[ @@ -141,10 +126,8 @@ mod truemotionrtenc; #[macro_use] mod vpenc; #[cfg(feature="encoder_vp6")] -#[allow(clippy::needless_range_loop)] mod vp6enc; #[cfg(feature="encoder_vp7")] -#[allow(clippy::needless_range_loop)] mod vp7enc; const DUCK_ENCODERS: &[EncoderInfo] = &[ diff --git a/nihav-duck/src/codecs/on2avc.rs b/nihav-duck/src/codecs/on2avc.rs index 9a0e0cd..6cbf2b3 100644 --- a/nihav-duck/src/codecs/on2avc.rs +++ b/nihav-duck/src/codecs/on2avc.rs @@ -368,30 +368,20 @@ impl AVCDecoder { self.imdct_short.imdct(ain, aout); } self.ew_buf = [0.0; 1152]; - for i in 0..128 { - self.ew_buf[i] = self.tmp[i]; - } + self.ew_buf[..128].copy_from_slice(&self.tmp[..128]); for w in 0..7 { overlap(&mut self.ew_buf[(w + 1) * 128..][..128], &self.tmp[(w + 1) * 256..][..128], &self.tmp[w * 256 + 128..][..128], AVC_WIN_SHORT); } - for i in 0..128 { - self.ew_buf[1024 + i] = self.tmp[7 * 256 + 128 + i]; - } - for i in 0..SHORT_WIN_POINT0 { - dst[i] = delay[i]; - } + self.ew_buf[1024..][..128].copy_from_slice(&self.tmp[7 * 256 + 128..][..128]); + dst[..SHORT_WIN_POINT0].copy_from_slice(&delay[..SHORT_WIN_POINT0]); overlap(&mut dst[SHORT_WIN_POINT0..SHORT_WIN_POINT1], &self.ew_buf[0..128], &delay[SHORT_WIN_POINT0..SHORT_WIN_POINT1], AVC_WIN_SHORT); - for i in SHORT_WIN_POINT1..COEFFS { - dst[i] = self.ew_buf[i - SHORT_WIN_POINT1 + 128]; - } - for i in 0..SHORT_WIN_POINT1 { - delay[i] = self.ew_buf[SHORT_WIN_POINT1 + i]; - } + dst[SHORT_WIN_POINT1..COEFFS].copy_from_slice(&self.ew_buf[128..][..COEFFS-SHORT_WIN_POINT1]); + delay[..SHORT_WIN_POINT1].copy_from_slice(&self.ew_buf[SHORT_WIN_POINT1..][..SHORT_WIN_POINT1]); for i in COEFFS/2..COEFFS { delay[i] = delay[COEFFS - 1 - i]; } @@ -422,18 +412,12 @@ impl AVCDecoder { _ => unreachable!(), }; if (self.cur_win == 2) || (self.cur_win >= 4) { - for i in 0..SHORT_WIN_POINT0 { - dst[i] = delay[i]; - } + dst[..SHORT_WIN_POINT0].copy_from_slice(&delay[..SHORT_WIN_POINT0]); overlap_half(&mut dst[SHORT_WIN_POINT0..SHORT_WIN_POINT1], &self.ew_buf[0..64], &delay[SHORT_WIN_POINT0..SHORT_WIN_POINT1], AVC_WIN_SHORT); - for i in SHORT_WIN_POINT1..COEFFS { - dst[i] = self.ew_buf[i - SHORT_WIN_POINT1 + 64]; - } - for i in 0..COEFFS/2 { - delay[i] = self.ew_buf[COEFFS/2 + i]; - } + dst[SHORT_WIN_POINT1..COEFFS].copy_from_slice(&self.ew_buf[64..][..COEFFS-SHORT_WIN_POINT1]); + delay[..COEFFS/2].copy_from_slice(&self.ew_buf[COEFFS/2..COEFFS]); for i in COEFFS/2..COEFFS { delay[i] = delay[COEFFS - 1 - i]; } @@ -521,6 +505,7 @@ fn zero_some(buf: &mut [FFTComplex], p0: usize, p1: usize) } } +#[allow(clippy::identity_op)] fn merge_bands(src: &[FFTComplex], dst: &mut [FFTComplex], size: usize) { let step = if size == 512 { 2 } else { 4 }; let (s01, s23) = src.split_at(size / 2); diff --git a/nihav-duck/src/codecs/truemotion1.rs b/nihav-duck/src/codecs/truemotion1.rs index 858ef3d..dbcbcfb 100644 --- a/nihav-duck/src/codecs/truemotion1.rs +++ b/nihav-duck/src/codecs/truemotion1.rs @@ -174,6 +174,7 @@ struct TM1Decoder { lastframe: FrameBuf, } +#[allow(clippy::identity_op)] impl TM1Decoder { fn new() -> Self { Self::default() } fn set_delta_tables(&mut self, delta_set: usize, table_idx: usize, is_24bit: bool) { diff --git a/nihav-duck/src/codecs/truemotion1enc.rs b/nihav-duck/src/codecs/truemotion1enc.rs index d582d1e..4adc3bf 100644 --- a/nihav-duck/src/codecs/truemotion1enc.rs +++ b/nihav-duck/src/codecs/truemotion1enc.rs @@ -882,6 +882,7 @@ panic!("end"); } // fat deltas for 15-bit mode +#[allow(clippy::identity_op)] #[allow(clippy::neg_multiply)] const DUCK_Y_DELTAS_5: [[i32; 8]; 4] = [ [ 0, -1 * 5, 1 * 5, -3 * 5, 3 * 5, -6 * 5, 6 * 5, -6 * 5 ], @@ -889,6 +890,7 @@ const DUCK_Y_DELTAS_5: [[i32; 8]; 4] = [ [ 2 * 5, -3 * 5, 10 * 5, -10 * 5, 23 * 5, -23 * 5, 47 * 5, -47 * 5 ], [ 0, -2 * 5, 2 * 5, -8 * 5, 8 * 5, -18 * 5, 18 * 5, -40 * 5 ] ]; +#[allow(clippy::identity_op)] #[allow(clippy::neg_multiply)] const DUCK_C_DELTAS_5: [[i32; 8]; 4] = [ [ 0, -1 * 5, 1 * 5, -2 * 5, 3 * 5, -4 * 5, 5 * 5, -4 * 5 ], diff --git a/nihav-duck/src/codecs/truemotion2.rs b/nihav-duck/src/codecs/truemotion2.rs index 4020e73..08115f6 100644 --- a/nihav-duck/src/codecs/truemotion2.rs +++ b/nihav-duck/src/codecs/truemotion2.rs @@ -57,6 +57,7 @@ struct HuffDef { } impl HuffDef { + #[allow(clippy::identity_op)] fn read(&mut self, br: &mut BitReader, codes: &mut Vec>, prefix: u32, len: u8) -> DecoderResult<()> { validate!(len <= self.max_bits); if !br.read_bool()? { @@ -224,6 +225,7 @@ struct DeltaState { } #[allow(clippy::erasing_op)] +#[allow(clippy::identity_op)] impl DeltaState { fn apply_y(&mut self, dst: &mut [u8], mut yoff: usize, ystride: usize, ydeltas: &[i32; 16], last: &mut [i32]) { for y in 0..4 { @@ -336,7 +338,6 @@ struct TM2Decoder { impl TM2Decoder { fn new() -> Self { Self::default() } - #[allow(clippy::manual_memcpy)] fn decode_blocks(&mut self) -> DecoderResult { let ydst = &mut self.cur_frame.ydata; let udst = &mut self.cur_frame.udata; @@ -369,8 +370,8 @@ impl TM2Decoder { } dstate.apply_c(udst, offs[1] + bx * 2, cstride, &cdeltas[0], 0, &mut lastu[bx*2+1..]); dstate.apply_c(vdst, offs[1] + bx * 2, cstride, &cdeltas[1], 1, &mut lastv[bx*2+1..]); - for i in 0..4*4 { - ydeltas[i] = self.streams[TM2StreamType::LHigh as usize].get_token()?; + for yd in ydeltas.iter_mut() { + *yd = self.streams[TM2StreamType::LHigh as usize].get_token()?; } dstate.apply_y(ydst, offs[0] + bx * 4, ystride, &ydeltas, &mut lasty[bx*4+1..]); }, @@ -382,8 +383,8 @@ impl TM2Decoder { dstate.apply_c(udst, offs[1] + bx * 2, cstride, &cdeltas[0], 0, &mut lastu[bx*2+1..]); dstate.interpolate_c(1, &mut lastv[bx*2..]); dstate.apply_c(vdst, offs[1] + bx * 2, cstride, &cdeltas[1], 1, &mut lastv[bx*2+1..]); - for i in 0..4*4 { - ydeltas[i] = self.streams[TM2StreamType::LHigh as usize].get_token()?; + for yd in ydeltas.iter_mut() { + *yd = self.streams[TM2StreamType::LHigh as usize].get_token()?; } dstate.apply_y(ydst, offs[0] + bx * 4, ystride, &ydeltas, &mut lasty[bx*4+1..]); }, @@ -444,27 +445,23 @@ impl TM2Decoder { TM2BlockType::Still => { is_intra = false; - let mut coff = offs[1] + bx * 2; - let usrc = &self.prev_frame.udata; - let vsrc = &self.prev_frame.vdata; - for _ in 0..2 { - for x in 0..2 { - udst[coff + x] = usrc[coff + x]; - vdst[coff + x] = vsrc[coff + x]; - } - coff += cstride; + let coff = offs[1] + bx * 2; + for (dline, sline) in udst[coff..].chunks_mut(cstride) + .zip(self.prev_frame.udata[coff..].chunks(cstride)).take(2) { + dline[..2].copy_from_slice(&sline[..2]); } - dstate.recalc_c(udst, offs[1] + bx * 2, cstride, 0, &mut lastu[bx*2+1..]); - dstate.recalc_c(vdst, offs[1] + bx * 2, cstride, 1, &mut lastv[bx*2+1..]); - let mut yoff = offs[0] + bx * 4; - let ysrc = &self.prev_frame.ydata; - for _ in 0..4 { - for x in 0..4 { - ydst[yoff + x] = ysrc[yoff + x]; - } - yoff += ystride; + for (dline, sline) in vdst[coff..].chunks_mut(cstride) + .zip(self.prev_frame.vdata[coff..].chunks(cstride)).take(2) { + dline[..2].copy_from_slice(&sline[..2]); } - dstate.recalc_y(ydst, offs[0] + bx * 4, ystride, &mut lasty[bx*4+1..]); + dstate.recalc_c(udst, coff, cstride, 0, &mut lastu[bx*2+1..]); + dstate.recalc_c(vdst, coff, cstride, 1, &mut lastv[bx*2+1..]); + let yoff = offs[0] + bx * 4; + for (dline, sline) in ydst[yoff..].chunks_mut(ystride) + .zip(self.prev_frame.ydata[yoff..].chunks(ystride)).take(4) { + dline[..4].copy_from_slice(&sline[..4]); + } + dstate.recalc_y(ydst, yoff, ystride, &mut lasty[bx*4+1..]); }, TM2BlockType::Motion => { is_intra = false; @@ -473,31 +470,25 @@ impl TM2Decoder { let my = self.streams[TM2StreamType::Motion as usize].get_token()?; let xpos = (((bx as i32) * 4) + mx).max(0).min((self.width - 4) as i32) as usize; let ypos = (((by as i32) * 4) + my).max(0).min((self.height - 4) as i32) as usize; - let mut coff = offs[1] + bx * 2; - let mut csoff = (xpos >> 1) + (ypos >> 1) * cstride; - let usrc = &self.prev_frame.udata; - let vsrc = &self.prev_frame.vdata; - for _ in 0..2 { - for x in 0..2 { - udst[coff + x] = usrc[csoff + x]; - vdst[coff + x] = vsrc[csoff + x]; - } - coff += cstride; - csoff += cstride; + let coff = offs[1] + bx * 2; + let csoff = (xpos >> 1) + (ypos >> 1) * cstride; + for (dline, sline) in udst[coff..].chunks_mut(cstride) + .zip(self.prev_frame.udata[csoff..].chunks(cstride)).take(2) { + dline[..2].copy_from_slice(&sline[..2]); } - dstate.recalc_c(udst, offs[1] + bx * 2, cstride, 0, &mut lastu[bx*2+1..]); - dstate.recalc_c(vdst, offs[1] + bx * 2, cstride, 1, &mut lastv[bx*2+1..]); - let mut yoff = offs[0] + bx * 4; - let mut ysoff = xpos + ypos * ystride; - let ysrc = &self.prev_frame.ydata; - for _ in 0..4 { - for x in 0..4 { - ydst[yoff + x] = ysrc[ysoff + x]; - } - yoff += ystride; - ysoff += ystride; + for (dline, sline) in vdst[coff..].chunks_mut(cstride) + .zip(self.prev_frame.vdata[csoff..].chunks(cstride)).take(2) { + dline[..2].copy_from_slice(&sline[..2]); } - dstate.recalc_y(ydst, offs[0] + bx * 4, ystride, &mut lasty[bx*4+1..]); + dstate.recalc_c(udst, coff, cstride, 0, &mut lastu[bx*2+1..]); + dstate.recalc_c(vdst, coff, cstride, 1, &mut lastv[bx*2+1..]); + let yoff = offs[0] + bx * 4; + let ysoff = xpos + ypos * ystride; + for (dline, sline) in ydst[yoff..].chunks_mut(ystride) + .zip(self.prev_frame.ydata[ysoff..].chunks(ystride)).take(4) { + dline[..4].copy_from_slice(&sline[..4]); + } + dstate.recalc_y(ydst, yoff, ystride, &mut lasty[bx*4+1..]); }, }; } diff --git a/nihav-duck/src/codecs/truemotion2x.rs b/nihav-duck/src/codecs/truemotion2x.rs index 2e31829..3e57b55 100644 --- a/nihav-duck/src/codecs/truemotion2x.rs +++ b/nihav-duck/src/codecs/truemotion2x.rs @@ -275,9 +275,8 @@ impl TM2XDecoder { Ok(()) } - #[allow(clippy::int_plus_one)] - #[allow(clippy::manual_memcpy)] #[allow(clippy::cognitive_complexity)] + #[allow(clippy::identity_op)] fn decode_frame(&mut self, src: &[u8]) -> DecoderResult<()> { let mut mr = MemoryReader::new_read(src); let mut br = ByteReader::new(&mut mr); @@ -531,17 +530,16 @@ impl TM2XDecoder { upred = 0; vpred = 0; }, + #[allow(clippy::int_plus_one)] CPARAM_MV => { let src_x = (bx as i16) * 8 + self.blk_info[x].mv_x; let src_y = ((by * 8 + line) as i16) + self.blk_info[x].mv_y; validate!(src_x >= 0 && (src_x as usize) + 8 <= self.width); validate!(src_y >= 0 && (src_y as usize) + 1 <= self.height); let ref_off = (src_x as usize) + ((src_y + 1) as usize) * stride; - for i in 0..8 { - ydata[cur_off + i] = self.ref_frame.ydata[ref_off + i]; - udata[cur_off + i] = self.ref_frame.udata[ref_off + i]; - vdata[cur_off + i] = self.ref_frame.vdata[ref_off + i]; - } + ydata[cur_off..][..8].copy_from_slice(&self.ref_frame.ydata[ref_off..][..8]); + udata[cur_off..][..8].copy_from_slice(&self.ref_frame.udata[ref_off..][..8]); + vdata[cur_off..][..8].copy_from_slice(&self.ref_frame.vdata[ref_off..][..8]); ypred = ydata[cur_off + 7] - ydata[cur_off + 7 - stride]; upred = udata[cur_off + 7] - udata[cur_off + 7 - stride]; vpred = vdata[cur_off + 7] - vdata[cur_off + 7 - stride]; diff --git a/nihav-duck/src/codecs/truemotionrt.rs b/nihav-duck/src/codecs/truemotionrt.rs index 157f8be..182cf05 100644 --- a/nihav-duck/src/codecs/truemotionrt.rs +++ b/nihav-duck/src/codecs/truemotionrt.rs @@ -55,7 +55,7 @@ impl NADecoder for TMRTDecoder { hdr[i - 1] = src[i] ^ src[i + 1]; } let dbits = hdr[1]; - validate!(dbits >= 2 && dbits <= 4); + validate!((2..=4).contains(&dbits)); let hscale = hdr[3] != 0; let width = (hdr[7] as usize) | ((hdr[8] as usize) << 8); let height = (hdr[5] as usize) | ((hdr[6] as usize) << 8); diff --git a/nihav-duck/src/codecs/vp3.rs b/nihav-duck/src/codecs/vp3.rs index 08bfd1a..86e512f 100644 --- a/nihav-duck/src/codecs/vp3.rs +++ b/nihav-duck/src/codecs/vp3.rs @@ -307,16 +307,16 @@ fn vp30_read_coded_run1(br: &mut BitReader) -> DecoderResult { let sym = (VP30_CRUN1_LUT[idx] >> 4) as usize; let bits = VP30_CRUN1_LUT[idx] & 0xF; br.skip(u32::from(bits))?; - if sym < 7 { - Ok(sym) - } else if sym == 7 { - Ok(7 + (br.read(3)? as usize)) - } else { - let len = br.read_code(UintCodeType::Unary012)?; - match len { - 0 => Ok(15 + (br.read(5)? as usize)), - 1 => Ok(47 + (br.read(8)? as usize)), - _ => Ok(303 + (br.read(16)? as usize)), + match sym { + 0..=6 => Ok(sym), + 7 => Ok(7 + (br.read(3)? as usize)), + _ => { + let len = br.read_code(UintCodeType::Unary012)?; + match len { + 0 => Ok(15 + (br.read(5)? as usize)), + 1 => Ok(47 + (br.read(8)? as usize)), + _ => Ok(303 + (br.read(16)? as usize)), + } } } } @@ -723,17 +723,17 @@ impl VP34Decoder { let nblks = *nblk as usize; if *coded { let mut cb = [false; 4]; - for j in 0..nblks { + for cb in cb[..nblks].iter_mut() { if run == 0 { bit = !bit; run = if bit { vp30_read_coded_run1(br)? } else { vp30_read_coded_run0(br)? }; } run -= 1; - cb[j] = bit; + *cb = bit; } - for j in 0..nblks { - let addr = self.blk_addr[cur_blk + j] >> 2; - self.blocks[addr].coded = cb[j]; + for (&cb, &blk_addr) in cb.iter() + .zip(self.blk_addr[cur_blk..].iter()).take(nblks) { + self.blocks[blk_addr >> 2].coded = cb; } } cur_blk += nblks; @@ -975,6 +975,7 @@ impl VP34Decoder { } Ok(()) } + #[allow(clippy::identity_op)] fn vp31_unpack_mv_info(&mut self, br: &mut BitReader) -> DecoderResult<()> { let mut last_mv = ZERO_MV; let mut last2_mv = ZERO_MV; @@ -1119,8 +1120,8 @@ impl VP34Decoder { } } } - for i in 0..nblks { - self.blocks[addrs[i]].coded = (pat & 8) != 0; + for &addr in addrs[..nblks].iter() { + self.blocks[addr].coded = (pat & 8) != 0; pat <<= 1; cur_blk += 1; } @@ -1464,9 +1465,9 @@ impl VP34Decoder { } if pp == 0 { return self.last_dc[ref_id as usize]; } let mut pred = 0i32; - for i in 0..4 { + for (i, (&pred_val, &dc_weight)) in preds.iter().zip(VP31_DC_WEIGHTS[pp].iter()).enumerate() { if (pp & (1 << i)) != 0 { - pred += preds[i] * i32::from(VP31_DC_WEIGHTS[pp][i]); + pred += pred_val * i32::from(dc_weight); } } pred /= i32::from(VP31_DC_WEIGHTS[pp][4]); @@ -1477,6 +1478,7 @@ impl VP34Decoder { } pred as i16 } + #[allow(clippy::identity_op)] fn vp40_predict_dc(&self, bx: usize, by: usize, bw: usize, bh: usize, blk_idx: usize, mask: usize, is_luma: bool) -> i16 { let mut preds = [0i32; 4]; let mut pp: usize = 0; @@ -1499,9 +1501,9 @@ impl VP34Decoder { if pp == 0 { return self.last_dc[ref_id as usize]; } let mut pred = 0i32; let mut npred = 0; - for i in 0..4 { + for (i, &pred_val) in preds.iter().enumerate() { if (pp & (1 << i)) != 0 { - pred += preds[i]; + pred += pred_val; npred += 1; if npred == 2 { return (pred / 2) as i16; @@ -1569,6 +1571,7 @@ impl VP34Decoder { } } #[allow(clippy::cognitive_complexity)] + #[allow(clippy::collapsible_else_if)] fn output_blocks_inter(&mut self, frm: &mut NASimpleVideoFrame) { let mut blk_idx = 0; let bstride = self.mb_w * 2; @@ -1586,17 +1589,17 @@ impl VP34Decoder { mv_sum.y = (mv_sum.y + 2) >> 2; let src = self.shuf.get_last().unwrap(); - for i in 0..4 { + for (i, mv) in mvs.iter().enumerate() { let xoff = (i & 1) * 8; let yoff = (i >> 1) * 8; - let mode = vp3_mv_mode(mvs[i].x, mvs[i].y); + let mode = vp3_mv_mode(mv.x, mv.y); if self.version != 4 { copy_block(frm, src.clone(), 0, bx * 8 + xoff, by * 8 + yoff, - mvs[i].x >> 1, mvs[i].y >> 1, 8, 8, 0, 1, mode, VP3_INTERP_FUNCS); + mv.x >> 1, mv.y >> 1, 8, 8, 0, 1, mode, VP3_INTERP_FUNCS); } else { vp_copy_block(frm, src.clone(), 0, bx * 8 + xoff, by * 8 + yoff, - mvs[i].x >> 1, mvs[i].y >> 1, 0, 1, self.loop_str, + mv.x >> 1, mv.y >> 1, 0, 1, self.loop_str, mode, VP3_INTERP_FUNCS, self.mc_buf.clone()); } } @@ -1795,9 +1798,9 @@ impl VP34Decoder { self.sb_mbs.push(nmbs); let mut nblocks = 0; - for blk_no in 0..16 { - let bx = x * 4 + HILBERT_ORDER[blk_no][0]; - let by = y * 4 + HILBERT_ORDER[blk_no][1]; + for (blk_no, order) in HILBERT_ORDER.iter().enumerate() { + let bx = x * 4 + order[0]; + let by = y * 4 + order[1]; if (bx >= blk_w) || (by >= blk_h) { continue; } let idx = base_idx + bx + by * blk_w; self.blk_addr.push(idx * 4 + plane); @@ -1839,6 +1842,7 @@ impl NADecoder for VP34Decoder { Err(DecoderError::InvalidData) } } + #[allow(clippy::collapsible_else_if)] fn decode(&mut self, supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult { let src = pkt.get_buffer(); validate!(src.len() > 0); diff --git a/nihav-duck/src/codecs/vp5.rs b/nihav-duck/src/codecs/vp5.rs index 0b7062e..a58ce1b 100644 --- a/nihav-duck/src/codecs/vp5.rs +++ b/nihav-duck/src/codecs/vp5.rs @@ -102,6 +102,7 @@ impl VP56Parser for VP5BR { } Ok(()) } + #[allow(clippy::needless_range_loop)] fn decode_coeff_models(&self, bc: &mut BoolCoder, models: &mut VP56Models, is_intra: bool) -> DecoderResult<()> { const COEF_PROBS: [[u8; 11]; 2] = [ [ 146, 197, 181, 207, 232, 243, 238, 251, 244, 250, 249 ], @@ -109,13 +110,14 @@ impl VP56Parser for VP5BR { ]; let mut def_prob = [128u8; 11]; - for plane in 0..2 { - for i in 0..11 { - if bc.read_prob(COEF_PROBS[plane][i]) { - def_prob[i] = bc.read_probability(); - models.coeff_models[plane].dc_value_probs[i] = def_prob[i]; + for (coef_mdl, coef_probs) in models.coeff_models.iter_mut().zip(COEF_PROBS.iter()) { + for ((dc_prob, def_prob), &coef_prob) in coef_mdl.dc_value_probs.iter_mut() + .zip(def_prob.iter_mut()).zip(coef_probs.iter()) { + if bc.read_prob(coef_prob) { + *def_prob = bc.read_probability(); + *dc_prob = *def_prob; } else if is_intra { - models.coeff_models[plane].dc_value_probs[i] = def_prob[i]; + *dc_prob = *def_prob; } } } @@ -133,8 +135,7 @@ impl VP56Parser for VP5BR { } } } - for plane in 0..2 { - let mdl = &mut models.coeff_models[plane]; + for mdl in models.coeff_models.iter_mut() { for i in 0..6 { for j in 0..6 { for k in 0..5 { diff --git a/nihav-duck/src/codecs/vp56.rs b/nihav-duck/src/codecs/vp56.rs index 5abea84..52de1c9 100644 --- a/nihav-duck/src/codecs/vp56.rs +++ b/nihav-duck/src/codecs/vp56.rs @@ -7,7 +7,6 @@ pub const TOKEN_LARGE: u8 = 5; pub const TOKEN_EOB: u8 = 42; #[derive(Clone,Copy,Debug,Default)] -#[allow(dead_code)] pub struct VP56Header { pub is_intra: bool, pub is_golden: bool, @@ -78,6 +77,7 @@ fn prob2weight(a: u8, b: u8) -> u8 { } } +#[allow(clippy::identity_op)] impl VP6Huff { fn build_codes(&mut self, probs: &[u8; 11]) { let mut weights = [0u8; 12]; @@ -134,8 +134,8 @@ impl VP6Huff { for w in weights.iter().rev() { let weight = u16::from(*w); let mut pos = nlen; - for i in 0..nlen { - if nodes[i].weight > weight { + for (i, node) in nodes[..nlen].iter().enumerate() { + if node.weight > weight { pos = i; break; } @@ -470,6 +470,7 @@ impl VP56Decoder { pub fn flush(&mut self) { self.shuf.clear(); } + #[allow(clippy::collapsible_else_if)] pub fn decode_frame(&mut self, supp: &mut NADecoderSupport, src: &[u8], br: &mut dyn VP56Parser) -> DecoderResult<(NABufferType, FrameType)> { let aoffset; let mut bc; @@ -647,11 +648,11 @@ impl VP56Decoder { self.models.prob_xmitted.copy_from_slice(&DEFAULT_XMITTED_PROBS); } fn decode_mode_prob_models(&mut self, bc: &mut BoolCoder) -> DecoderResult<()> { - for ctx in 0..3 { + for (prob_xmitted, vq_modes) in self.models.prob_xmitted.iter_mut().zip(VP56_MODE_VQ.iter()) { if bc.read_prob(174) { let idx = bc.read_bits(4) as usize; - for i in 0..20 { - self.models.prob_xmitted[ctx][i ^ 1] = VP56_MODE_VQ[ctx][idx][i]; + for (i, &vq_mode) in vq_modes[idx].iter().enumerate() { + prob_xmitted[i ^ 1] = vq_mode; } } if bc.read_prob(254) { @@ -673,20 +674,19 @@ impl VP56Decoder { validate!(diff < 256); let diff = diff as u8; if !sign { - validate!(self.models.prob_xmitted[ctx][set ^ 1] <= 255 - diff); - self.models.prob_xmitted[ctx][set ^ 1] += diff; + validate!(prob_xmitted[set ^ 1] <= 255 - diff); + prob_xmitted[set ^ 1] += diff; } else { - validate!(self.models.prob_xmitted[ctx][set ^ 1] >= diff); - self.models.prob_xmitted[ctx][set ^ 1] -= diff; + validate!(prob_xmitted[set ^ 1] >= diff); + prob_xmitted[set ^ 1] -= diff; } } } } } - for ctx in 0..3 { - let prob_xmitted = &self.models.prob_xmitted[ctx]; - for mode in 0..10 { - let mdl = &mut self.models.mbtype_models[ctx][mode]; + for (prob_xmitted, mbtype_models) in self.models.prob_xmitted.iter() + .zip(self.models.mbtype_models.iter_mut()) { + for (mode, mdl) in mbtype_models.iter_mut().enumerate() { let mut cnt = [0u32; 10]; let mut total = 0; for i in 0..10 { @@ -787,6 +787,7 @@ impl VP56Decoder { Ok(self.last_mbt) } #[allow(clippy::cognitive_complexity)] + #[allow(clippy::collapsible_else_if)] fn decode_mb(&mut self, frm: &mut NASimpleVideoFrame, bc: &mut BoolCoder, cr: &mut CoeffReader, br: &mut dyn VP56Parser, hdr: &VP56Header, alpha: bool) -> DecoderResult<()> { const FOURMV_SUB_TYPE: [VPMBType; 4] = [ VPMBType::InterNoMV, VPMBType::InterMV, VPMBType::InterNearest, VPMBType::InterNear ]; @@ -835,21 +836,21 @@ impl VP56Decoder { self.mb_info[mb_pos].mv = near_mv; }, VPMBType::InterFourMV => { - for i in 0..4 { - four_mbt[i] = FOURMV_SUB_TYPE[bc.read_bits(2) as usize]; + for mbt in four_mbt.iter_mut() { + *mbt = FOURMV_SUB_TYPE[bc.read_bits(2) as usize]; } - for i in 0..4 { - match four_mbt[i] { + for (&mbt, mv) in four_mbt.iter().zip(four_mv.iter_mut()) { + match mbt { VPMBType::InterNoMV => {}, VPMBType::InterMV => { let diff_mv = self.decode_mv(bc, br); - four_mv[i] = pred_mv + diff_mv; + *mv = pred_mv + diff_mv; }, VPMBType::InterNearest => { - four_mv[i] = nearest_mv; + *mv = nearest_mv; }, VPMBType::InterNear => { - four_mv[i] = near_mv; + *mv = near_mv; }, _ => unreachable!(), }; @@ -962,6 +963,7 @@ impl VP56Decoder { } Ok(()) } + #[allow(clippy::identity_op)] fn do_mc(&mut self, br: &dyn VP56Parser, frm: &mut NASimpleVideoFrame, mb_type: VPMBType, mv: MV, alpha: bool) { let x = self.fstate.mb_x * 16; let y = self.fstate.mb_y * 16; @@ -988,10 +990,10 @@ impl VP56Decoder { let y = self.fstate.mb_y * 16; let plane = if !alpha { 0 } else { 3 }; let src = self.shuf.get_last().unwrap(); - for blk_no in 0..4 { + for (blk_no, &mv) in mvs.iter().enumerate() { br.mc_block(frm, self.mc_buf.clone(), src.clone(), plane, x + (blk_no & 1) * 8, y + (blk_no & 2) * 4, - mvs[blk_no], self.loop_thr); + mv, self.loop_thr); } if !alpha { let x = self.fstate.mb_x * 8; diff --git a/nihav-duck/src/codecs/vp6.rs b/nihav-duck/src/codecs/vp6.rs index 916711c..131e26e 100644 --- a/nihav-duck/src/codecs/vp6.rs +++ b/nihav-duck/src/codecs/vp6.rs @@ -165,6 +165,7 @@ impl VP56Parser for VP6BR { } Ok(()) } + #[allow(clippy::needless_range_loop)] fn decode_coeff_models(&self, bc: &mut BoolCoder, models: &mut VP56Models, is_intra: bool) -> DecoderResult<()> { let mut def_prob = [128u8; 11]; for plane in 0..2 { @@ -211,8 +212,7 @@ impl VP56Parser for VP6BR { } } } - for plane in 0..2 { - let mdl = &mut models.coeff_models[plane]; + for mdl in models.coeff_models.iter_mut() { for i in 0..3 { for k in 0..5 { mdl.dc_token_probs[0][i][k] = rescale_prob(mdl.dc_value_probs[k], &VP6_DC_WEIGHTS[k][i], 255); diff --git a/nihav-duck/src/codecs/vp6dsp.rs b/nihav-duck/src/codecs/vp6dsp.rs index 5a2b47f..4167b00 100644 --- a/nihav-duck/src/codecs/vp6dsp.rs +++ b/nihav-duck/src/codecs/vp6dsp.rs @@ -51,7 +51,6 @@ macro_rules! mc_filter { } } -//#[allow(snake_case)] #[cfg(not(target_arch = "x86_64"))] pub fn mc_bilinear(dst: &mut [u8], dstride: usize, src: &[u8], mut soff: usize, sstride: usize, mx: u16, my: u16) { if my == 0 { @@ -167,7 +166,6 @@ pub fn mc_bilinear(dst: &mut [u8], dstride: usize, src: &[u8], soff: usize, sstr } } -#[allow(clippy::trivially_copy_pass_by_ref)] pub fn mc_bicubic(dst: &mut [u8], dstride: usize, src: &[u8], mut soff: usize, sstride: usize, coeffs_w: &[i16; 4], coeffs_h: &[i16; 4]) { if coeffs_h[1] == 128 { for dline in dst.chunks_mut(dstride).take(8) { diff --git a/nihav-duck/src/codecs/vp6enc/coder.rs b/nihav-duck/src/codecs/vp6enc/coder.rs index a88b0e2..1fc6659 100644 --- a/nihav-duck/src/codecs/vp6enc/coder.rs +++ b/nihav-duck/src/codecs/vp6enc/coder.rs @@ -390,6 +390,7 @@ pub fn encode_mv_models(bc: &mut BoolEncoder, models: &[VP56MVModel; 2], pmodels Ok(()) } +#[allow(clippy::needless_range_loop)] pub fn encode_coeff_models(bc: &mut BoolEncoder, models: &mut VP56Models, pmodels: &VP56Models, is_intra: bool, interlaced: bool) -> EncoderResult<()> { let mut def_prob = [128u8; 11]; for plane in 0..2 { diff --git a/nihav-duck/src/codecs/vp6enc/dsp.rs b/nihav-duck/src/codecs/vp6enc/dsp.rs index 90c76b9..ced33b1 100644 --- a/nihav-duck/src/codecs/vp6enc/dsp.rs +++ b/nihav-duck/src/codecs/vp6enc/dsp.rs @@ -87,6 +87,7 @@ impl MVSearchModeCreate for MVSearchMode { const MAX_DIST: u32 = std::u32::MAX; const DIST_THRESH: u32 = 256; +#[allow(clippy::wrong_self_convention)] trait FromPixels { fn from_pixels(self) -> Self; } diff --git a/nihav-duck/src/codecs/vp6enc/mod.rs b/nihav-duck/src/codecs/vp6enc/mod.rs index 9eea91d..4c18d54 100644 --- a/nihav-duck/src/codecs/vp6enc/mod.rs +++ b/nihav-duck/src/codecs/vp6enc/mod.rs @@ -5,10 +5,13 @@ use super::vpcommon::*; mod coder; use coder::*; +#[allow(clippy::identity_op)] +#[allow(clippy::needless_range_loop)] mod dsp; use dsp::MVSearchMode; mod huff; use huff::*; +#[allow(clippy::needless_range_loop)] mod mb; use mb::*; mod models; @@ -320,51 +323,47 @@ impl VP6Encoder { fn determine_coeff_runs_luma(&self, hstate: &mut HuffState, mb_pos: usize, blk: usize) { let mb = self.fenc.get_mb(mb_pos); - if !hstate.dc_zr_coded[0] { - if mb.coeffs[blk].no_dc() { - hstate.dc_zero_run[0] = 0; - let mut blk_no = (blk + 1) & 3; - let mut mb_no = mb_pos + ((blk + 1) >> 2); - let mut cmb = mb; - let mut last_mb_no = mb_pos; - while (hstate.dc_zero_run[0] < MAX_EOB_RUN) && (mb_no < self.mb_w * self.mb_h) { - if mb_no != last_mb_no { - cmb = self.fenc.get_mb(mb_no); - last_mb_no = mb_no; - } - if !cmb.coeffs[blk_no].no_dc() { - break; - } - hstate.dc_zero_run[0] += 1; - blk_no += 1; - if blk_no == 4 { - blk_no = 0; - mb_no += 1; - } + if !hstate.dc_zr_coded[0] && mb.coeffs[blk].no_dc() { + hstate.dc_zero_run[0] = 0; + let mut blk_no = (blk + 1) & 3; + let mut mb_no = mb_pos + ((blk + 1) >> 2); + let mut cmb = mb; + let mut last_mb_no = mb_pos; + while (hstate.dc_zero_run[0] < MAX_EOB_RUN) && (mb_no < self.mb_w * self.mb_h) { + if mb_no != last_mb_no { + cmb = self.fenc.get_mb(mb_no); + last_mb_no = mb_no; + } + if !cmb.coeffs[blk_no].no_dc() { + break; + } + hstate.dc_zero_run[0] += 1; + blk_no += 1; + if blk_no == 4 { + blk_no = 0; + mb_no += 1; } } } - if !hstate.ac_zr_coded[0] { - if mb.coeffs[blk].no_ac() { - hstate.ac_zero_run[0] = 0; - let mut blk_no = (blk + 1) & 3; - let mut mb_no = mb_pos + ((blk + 1) >> 2); - let mut cmb = mb; - let mut last_mb_no = mb_pos; - while (hstate.ac_zero_run[0] < MAX_EOB_RUN) && (mb_no < self.mb_w * self.mb_h) { - if mb_no != last_mb_no { - cmb = self.fenc.get_mb(mb_no); - last_mb_no = mb_no; - } - if !cmb.coeffs[blk_no].no_ac() { - break; - } - hstate.ac_zero_run[0] += 1; - blk_no += 1; - if blk_no == 4 { - blk_no = 0; - mb_no += 1; - } + if !hstate.ac_zr_coded[0] && mb.coeffs[blk].no_ac() { + hstate.ac_zero_run[0] = 0; + let mut blk_no = (blk + 1) & 3; + let mut mb_no = mb_pos + ((blk + 1) >> 2); + let mut cmb = mb; + let mut last_mb_no = mb_pos; + while (hstate.ac_zero_run[0] < MAX_EOB_RUN) && (mb_no < self.mb_w * self.mb_h) { + if mb_no != last_mb_no { + cmb = self.fenc.get_mb(mb_no); + last_mb_no = mb_no; + } + if !cmb.coeffs[blk_no].no_ac() { + break; + } + hstate.ac_zero_run[0] += 1; + blk_no += 1; + if blk_no == 4 { + blk_no = 0; + mb_no += 1; } } } @@ -373,41 +372,37 @@ impl VP6Encoder { let mb = self.fenc.get_mb(mb_pos); let blk = plane + 3; - if !hstate.dc_zr_coded[1] { - if mb.coeffs[blk].no_dc() { - hstate.dc_zero_run[1] = 0; - let mut blk_no = if blk == 4 { 5 } else { 4 }; - let mut mb_no = mb_pos + if blk == 4 { 0 } else { 1 }; - while (hstate.dc_zero_run[1] < MAX_EOB_RUN) && (mb_no < self.mb_w * self.mb_h) { - let mb = self.fenc.get_mb(mb_no); - if !mb.coeffs[blk_no].no_dc() { - break; - } - hstate.dc_zero_run[1] += 1; - blk_no += 1; - if blk_no == 6 { - blk_no = 4; - mb_no += 1; - } + if !hstate.dc_zr_coded[1] && mb.coeffs[blk].no_dc() { + hstate.dc_zero_run[1] = 0; + let mut blk_no = if blk == 4 { 5 } else { 4 }; + let mut mb_no = mb_pos + if blk == 4 { 0 } else { 1 }; + while (hstate.dc_zero_run[1] < MAX_EOB_RUN) && (mb_no < self.mb_w * self.mb_h) { + let mb = self.fenc.get_mb(mb_no); + if !mb.coeffs[blk_no].no_dc() { + break; + } + hstate.dc_zero_run[1] += 1; + blk_no += 1; + if blk_no == 6 { + blk_no = 4; + mb_no += 1; } } } - if !hstate.ac_zr_coded[1] { - if mb.coeffs[blk].no_ac() { - hstate.ac_zero_run[1] = 0; - let mut blk_no = if blk == 4 { 5 } else { 4 }; - let mut mb_no = mb_pos + if blk == 4 { 0 } else { 1 }; - while (hstate.ac_zero_run[1] < MAX_EOB_RUN) && (mb_no < self.mb_w * self.mb_h) { - let mb = self.fenc.get_mb(mb_no); - if !mb.coeffs[blk_no].no_ac() { - break; - } - hstate.ac_zero_run[1] += 1; - blk_no += 1; - if blk_no == 6 { - blk_no = 4; - mb_no += 1; - } + if !hstate.ac_zr_coded[1] && mb.coeffs[blk].no_ac() { + hstate.ac_zero_run[1] = 0; + let mut blk_no = if blk == 4 { 5 } else { 4 }; + let mut mb_no = mb_pos + if blk == 4 { 0 } else { 1 }; + while (hstate.ac_zero_run[1] < MAX_EOB_RUN) && (mb_no < self.mb_w * self.mb_h) { + let mb = self.fenc.get_mb(mb_no); + if !mb.coeffs[blk_no].no_ac() { + break; + } + hstate.ac_zero_run[1] += 1; + blk_no += 1; + if blk_no == 6 { + blk_no = 4; + mb_no += 1; } } } diff --git a/nihav-duck/src/codecs/vp6enc/models.rs b/nihav-duck/src/codecs/vp6enc/models.rs index 7a0da4a..fe2416e 100644 --- a/nihav-duck/src/codecs/vp6enc/models.rs +++ b/nihav-duck/src/codecs/vp6enc/models.rs @@ -55,6 +55,7 @@ fn prob2weight(a: u8, b: u8) -> u8 { } } +#[allow(clippy::identity_op)] impl VP6Huff { pub fn build_codes(&mut self, probs: &[u8; 11]) { let mut weights = [0u8; 12]; @@ -111,8 +112,8 @@ impl VP6Huff { for w in weights.iter().rev() { let weight = u16::from(*w); let mut pos = nlen; - for i in 0..nlen { - if nodes[i].weight > weight { + for (i, node) in nodes[..nlen].iter().enumerate() { + if node.weight > weight { pos = i; break; } diff --git a/nihav-duck/src/codecs/vp7.rs b/nihav-duck/src/codecs/vp7.rs index 3b2d854..782135d 100644 --- a/nihav-duck/src/codecs/vp7.rs +++ b/nihav-duck/src/codecs/vp7.rs @@ -239,12 +239,12 @@ impl VP7Decoder { Ok(()) } fn read_dct_coef_prob_upd(&mut self, bc: &mut BoolCoder) -> DecoderResult<()> { - for i in 0..4 { - for j in 0..8 { - for k in 0..3 { - for l in 0..11 { - if bc.read_prob(DCT_UPDATE_PROBS[i][j][k][l]) { - self.dstate.coef_probs[i][j][k][l] = bc.read_byte(); + for (probs, upd_probs) in self.dstate.coef_probs.iter_mut().zip(DCT_UPDATE_PROBS.iter()) { + for (probs, upd_probs) in probs.iter_mut().zip(upd_probs.iter()) { + for (probs, upd_probs) in probs.iter_mut().zip(upd_probs.iter()) { + for (prob, &upd_prob) in probs.iter_mut().zip(upd_probs.iter()) { + if bc.read_prob(upd_prob) { + *prob = bc.read_byte(); } } } @@ -253,10 +253,10 @@ impl VP7Decoder { Ok(()) } fn read_mv_prob_upd(&mut self, bc: &mut BoolCoder) -> DecoderResult<()> { - for comp in 0..2 { - for i in 0..17 { - if bc.read_prob(MV_UPDATE_PROBS[comp][i]) { - self.dstate.mv_probs[comp][i] = bc.read_probability(); + for (probs, upd_probs) in self.dstate.mv_probs.iter_mut().zip(MV_UPDATE_PROBS.iter()) { + for (prob, &upd_prob) in probs.iter_mut().zip(upd_probs.iter()) { + if bc.read_prob(upd_prob) { + *prob = bc.read_probability(); } } } @@ -313,42 +313,45 @@ impl VP7Decoder { } sbparams.scan = &self.scan; sbparams.qmat = &self.qmat[qmat_idx][0]; - for i in 0..16 { + let (y_coeffs, c_coeffs) = self.coeffs.split_at_mut(16); + for (i, (coeffs, y_has_ac)) in y_coeffs.iter_mut().zip(has_ac.iter_mut()).enumerate() { let bx = i & 3; let by = i >> 2; let pred = &self.pcache.y_pred; let pidx = pred.xpos + mb_x * 4 + bx + by * pred.stride; let pctx = self.pcache.y_pred_left[by] + pred.data[pidx - pred.stride]; - let has_nz = decode_subblock(bc, &mut self.coeffs[i], ytype, pctx, &sbparams); + let has_nz = decode_subblock(bc, coeffs, ytype, pctx, &sbparams); self.pcache.y_pred.data[pidx] = has_nz; self.pcache.y_pred_left[by] = has_nz; - has_ac[i] = has_nz > 0; + *y_has_ac = has_nz > 0; } sbparams.qmat = &self.qmat[qmat_idx][1]; - for i in 16..20 { + let (u_coeffs, v_coeffs) = c_coeffs.split_at_mut(4); + let (u_has_ac, v_has_ac) = has_ac[16..24].split_at_mut(4); + for (i, (coeffs, u_has_ac)) in u_coeffs.iter_mut().zip(u_has_ac.iter_mut()).enumerate() { let bx = i & 1; let by = (i >> 1) & 1; let pred = &self.pcache.u_pred; let pidx = pred.xpos + mb_x * 2 + bx + by * pred.stride; let pctx = self.pcache.u_pred_left[by] + pred.data[pidx - pred.stride]; - let has_nz = decode_subblock(bc, &mut self.coeffs[i], 2, pctx, &sbparams); + let has_nz = decode_subblock(bc, coeffs, 2, pctx, &sbparams); self.pcache.u_pred.data[pidx] = has_nz; self.pcache.u_pred_left[by] = has_nz; - has_ac[i] = has_nz > 0; + *u_has_ac = has_nz > 0; } - for i in 20..24 { + for (i, (coeffs, v_has_ac)) in v_coeffs.iter_mut().zip(v_has_ac.iter_mut()).enumerate() { let bx = i & 1; let by = (i >> 1) & 1; let pred = &self.pcache.v_pred; let pidx = pred.xpos + mb_x * 2 + bx + by * pred.stride; let pctx = self.pcache.v_pred_left[by] + pred.data[pidx - pred.stride]; - let has_nz = decode_subblock(bc, &mut self.coeffs[i], 2, pctx, &sbparams); + let has_nz = decode_subblock(bc, coeffs, 2, pctx, &sbparams); self.pcache.v_pred.data[pidx] = has_nz; self.pcache.v_pred_left[by] = has_nz; - has_ac[i] = has_nz > 0; + *v_has_ac = has_nz > 0; } if self.dstate.has_y2 { @@ -378,11 +381,11 @@ impl VP7Decoder { self.coeffs[i][0] = self.coeffs[24][i]; } } - for i in 0..24 { - if has_ac[i] { - idct4x4(&mut self.coeffs[i]); - } else if self.coeffs[i][0] != 0 { - idct4x4_dc(&mut self.coeffs[i]); + for (&has_ac, coeffs) in has_ac.iter().zip(self.coeffs.iter_mut()).take(24) { + if has_ac { + idct4x4(coeffs); + } else if coeffs[0] != 0 { + idct4x4_dc(coeffs); } } } @@ -474,6 +477,7 @@ impl VP7Decoder { } ct[idx] += weight; } + #[allow(clippy::collapsible_else_if)] let pred_mv = if ct[1] > ct[2] { if ct[1] >= ct[0] { nearest_mv } else { ZERO_MV } } else { @@ -529,6 +533,7 @@ impl VP7Decoder { mvidx += self.mv_stride; } }, + #[allow(clippy::identity_op)] MVSplitMode::LeftRight => { let left_mv = self.get_split_mv(bc, mb_x, mb_y, 0, 0, pred_mv); self.mvs[mvidx + 1] = left_mv; @@ -672,7 +677,7 @@ impl VP7Decoder { let oidx = x + y * 4 + 4; for i in 0..4 { for j in 0..4 { - tmpblock[i * 8 + 0 + j] = self.coeffs[eidx][i * 4 + j]; + tmpblock[i * 8 + j] = self.coeffs[eidx][i * 4 + j]; tmpblock[i * 8 + 4 + j] = self.coeffs[oidx][i * 4 + j]; } } @@ -761,6 +766,7 @@ impl VP7Decoder { self.add_residue(dframe, mb_x, mb_y, is_normal, pitch_mode); Ok(()) } + #[allow(clippy::collapsible_else_if)] fn recon_inter_mb(&mut self, dframe: &mut NASimpleVideoFrame, mb_x: usize, mb_y: usize, use_last: bool) { let pitch = self.dstate.force_pitch.unwrap_or(0); let pitch_dmode = (pitch >> 3) & 3; @@ -932,6 +938,7 @@ impl NADecoder for VP7Decoder { } } #[allow(clippy::cognitive_complexity)] + #[allow(clippy::collapsible_else_if)] fn decode(&mut self, supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult { let src = pkt.get_buffer(); diff --git a/nihav-duck/src/codecs/vp78.rs b/nihav-duck/src/codecs/vp78.rs index 4ec79d1..e7546fe 100644 --- a/nihav-duck/src/codecs/vp78.rs +++ b/nihav-duck/src/codecs/vp78.rs @@ -71,6 +71,7 @@ impl PredMode { } #[derive(Clone,Copy,PartialEq)] +#[allow(clippy::upper_case_acronyms)] pub enum DCTToken { Zero, One, @@ -87,21 +88,20 @@ pub enum DCTToken { } pub fn expand_token(bc: &mut BoolCoder, token: DCTToken) -> i16 { - let cat; - match token { - DCTToken::Zero => return 0, - DCTToken::One => return if bc.read_bool() { -1 } else { 1 }, - DCTToken::Two => return if bc.read_bool() { -2 } else { 2 }, - DCTToken::Three => return if bc.read_bool() { -3 } else { 3 }, - DCTToken::Four => return if bc.read_bool() { -4 } else { 4 }, - DCTToken::Cat1 => cat = 0, - DCTToken::Cat2 => cat = 1, - DCTToken::Cat3 => cat = 2, - DCTToken::Cat4 => cat = 3, - DCTToken::Cat5 => cat = 4, - DCTToken::Cat6 => cat = 5, - _ => unreachable!(), - }; + let cat = match token { + DCTToken::Zero => return 0, + DCTToken::One => return if bc.read_bool() { -1 } else { 1 }, + DCTToken::Two => return if bc.read_bool() { -2 } else { 2 }, + DCTToken::Three => return if bc.read_bool() { -3 } else { 3 }, + DCTToken::Four => return if bc.read_bool() { -4 } else { 4 }, + DCTToken::Cat1 => 0, + DCTToken::Cat2 => 1, + DCTToken::Cat3 => 2, + DCTToken::Cat4 => 3, + DCTToken::Cat5 => 4, + DCTToken::Cat6 => 5, + _ => unreachable!(), + }; let mut add = 0i16; let add_probs = &VP56_COEF_ADD_PROBS[cat]; for prob in add_probs.iter() { diff --git a/nihav-duck/src/codecs/vp78dsp.rs b/nihav-duck/src/codecs/vp78dsp.rs index 9d68616..9487c16 100644 --- a/nihav-duck/src/codecs/vp78dsp.rs +++ b/nihav-duck/src/codecs/vp78dsp.rs @@ -1,3 +1,4 @@ +use std::cmp::Ordering; use nihav_core::frame::*; use nihav_codec_support::codecs::blockdsp::edge_emu; @@ -72,6 +73,7 @@ pub fn add_coeffs16x1(dst: &mut [u8], off: usize, coeffs: &[i16; 16]) { pub trait IntraPred { const SIZE: usize; + #[allow(clippy::needless_late_init)] fn ipred_dc(dst: &mut [u8], mut off: usize, stride: usize, ipred: &IPredContext) { let dc; if !ipred.has_left && !ipred.has_top { @@ -264,15 +266,14 @@ impl IPred4x4 { off += stride; } } - pub fn ipred_he(dst: &mut [u8], mut off: usize, stride: usize, ipred: &IPredContext) { + pub fn ipred_he(dst: &mut [u8], off: usize, stride: usize, ipred: &IPredContext) { let (p0, p1, p2, _) = load_pred4!(left; ipred); let p3 = ((u16::from(ipred.left[2]) + u16::from(ipred.left[3]) * 3 + 2) >> 2) as u8; let hor_pred = [p0, p1, p2, p3]; - for m in 0..4 { - for n in 0..4 { - dst[off + n] = hor_pred[m]; + for (dline, &pred) in dst[off..].chunks_mut(stride).zip(hor_pred.iter()) { + for el in dline[..4].iter_mut() { + *el = pred; } - off += stride; } } pub fn ipred_ld(dst: &mut [u8], mut off: usize, stride: usize, ipred: &IPredContext) { @@ -494,10 +495,10 @@ pub fn mc_block_special(dst: &mut [u8], doff: usize, dstride: usize, xpos: usize let ha = if plane == 0 { (h + 15) & !15 } else { (h + 7) & !7 } as isize; let mut start_x = (xpos as isize) + ((mvx >> 3) as isize) - (EDGE_PRE as isize); let mut end_x = (xpos as isize) + ((mvx >> 3) as isize) + ((size + EDGE_POST) as isize); - if xstep < 0 { - start_x -= (size + EDGE_POST) as isize; - } else if xstep > 0 { - end_x += (size as isize) * xstep; + match xstep.cmp(&0) { + Ordering::Less => start_x -= (size + EDGE_POST) as isize, + Ordering::Greater => end_x += (size as isize) * xstep, + Ordering::Equal => {}, } let mut start_y = (ypos as isize) + ((mvy >> 3) as isize) - (EDGE_PRE as isize) * ymul; let mut end_y = (ypos as isize) + ((mvy >> 3) as isize) + ((size + EDGE_POST) as isize) * ymul; diff --git a/nihav-duck/src/codecs/vp7enc/blocks.rs b/nihav-duck/src/codecs/vp7enc/blocks.rs index 7a18d48..4f4b451 100644 --- a/nihav-duck/src/codecs/vp7enc/blocks.rs +++ b/nihav-duck/src/codecs/vp7enc/blocks.rs @@ -670,11 +670,10 @@ impl PredContext { self.dc_last_saved = self.dc_last; self.dc_count_saved = self.dc_count; } - #[allow(dead_code)] - pub fn restore_dc_pred(&mut self) { + /*pub fn restore_dc_pred(&mut self) { self.dc_last = self.dc_last_saved; self.dc_count = self.dc_count_saved; - } + }*/ pub fn update_mb_row(&mut self) { self.left_y = [0x80; 16]; self.left_u = [0x80; 16]; @@ -844,6 +843,7 @@ impl PredContext { } ct[idx] += weight; } + #[allow(clippy::collapsible_else_if)] let pred_mv = if ct[1] > ct[2] { if ct[1] >= ct[0] { nearest_mv } else { ZERO_MV } } else { diff --git a/nihav-duck/src/codecs/vp7enc/mod.rs b/nihav-duck/src/codecs/vp7enc/mod.rs index a73a571..e3f6bec 100644 --- a/nihav-duck/src/codecs/vp7enc/mod.rs +++ b/nihav-duck/src/codecs/vp7enc/mod.rs @@ -21,7 +21,6 @@ enum EncodingState { JustEncode, } -#[allow(dead_code)] struct VP7Encoder { stream: Option, pkt: Option, diff --git a/nihav-duck/src/codecs/vp7enc/motion_est.rs b/nihav-duck/src/codecs/vp7enc/motion_est.rs index 882e3e7..8241397 100644 --- a/nihav-duck/src/codecs/vp7enc/motion_est.rs +++ b/nihav-duck/src/codecs/vp7enc/motion_est.rs @@ -25,6 +25,7 @@ const MAX_DIST: u32 = std::u32::MAX; const DIST_THRESH: u32 = 256; pub const LARGE_BLK8_DIST: u32 = 256; +#[allow(clippy::wrong_self_convention)] trait FromPixels { fn from_pixels(self) -> Self; } @@ -62,10 +63,10 @@ impl EliminationSearch { } } let mut chroma_avg = [0; 2]; - for chroma in 0..1 { + for (chroma, avg_val) in chroma_avg.iter_mut().enumerate() { for row in self.msa[chroma + 1][chroma_off..].chunks(self.stride[1]).take(8).step_by(Self::BLOCK_SIZE) { for &el in row.iter().take(8).step_by(Self::BLOCK_SIZE) { - chroma_avg[chroma] += el; + *avg_val += el; } } } @@ -433,7 +434,6 @@ pub struct MVEstimator { count: usize, } -#[allow(dead_code)] impl MVEstimator { pub fn new(ref_frame: NAVideoBufferRef, mc_buf: NAVideoBufferRef, mv_range: i16) -> Self { Self { @@ -451,13 +451,13 @@ count: 0, mc_block8x8(&mut dst.chroma[0], 0, 8, mb_x * 8, mb_y * 8, cur_mv.x, cur_mv.y, self.ref_frame.clone(), 1, tmp_blk); mc_block8x8(&mut dst.chroma[1], 0, 8, mb_x * 8, mb_y * 8, cur_mv.x, cur_mv.y, self.ref_frame.clone(), 2, tmp_blk); } - pub fn get_blk8(&mut self, dst: &mut [u8; 64], plane: usize, x: usize, y: usize, mut cur_mv: MV) { + /*pub fn get_blk8(&mut self, dst: &mut [u8; 64], plane: usize, x: usize, y: usize, mut cur_mv: MV) { if plane == 0 { cur_mv.x *= 2; cur_mv.y *= 2; } mc_block8x8(dst, 0, 8, x, y, cur_mv.x, cur_mv.y, self.ref_frame.clone(), plane, self.mc_buf.get_data_mut().unwrap()); - } + }*/ fn sad_blk8(&mut self, refblk: &[u8; 64], x: usize, y: usize, cur_mv: MV, _best_dist: u32) -> u32 { mc_block8x8(&mut self.blk8, 0, 8, x, y, cur_mv.x * 2, cur_mv.y * 2, self.ref_frame.clone(), 0, self.mc_buf.get_data_mut().unwrap()); self.count += 1; diff --git a/nihav-duck/src/codecs/vp7enc/rdo.rs b/nihav-duck/src/codecs/vp7enc/rdo.rs index d91cee4..50ace94 100644 --- a/nihav-duck/src/codecs/vp7enc/rdo.rs +++ b/nihav-duck/src/codecs/vp7enc/rdo.rs @@ -127,13 +127,13 @@ impl BitRateControl { (false, _) => 800.0 - (fq - 8.0).ln() * 155.0, } } - #[allow(dead_code)] // todo use for refining maybe - pub fn predict_size(&self, is_intra: bool, q: usize) -> u32 { + /*pub fn predict_size(&self, is_intra: bool, q: usize) -> u32 { let min_size = if is_intra { 200 * 8 } else { 50 * 8 }; let nits_per_mb = Self::pred_nits_per_mb(is_intra, q); ((nits_per_mb * (self.num_mb as f32) / 8.0) as u32).max(min_size) - } + }*/ + #[allow(clippy::collapsible_else_if)] pub fn get_frame_quant(&self, is_intra: bool) -> usize { if let Some(q) = self.force_q { q diff --git a/nihav-duck/src/codecs/vp8.rs b/nihav-duck/src/codecs/vp8.rs index 6e34f59..83539b6 100644 --- a/nihav-duck/src/codecs/vp8.rs +++ b/nihav-duck/src/codecs/vp8.rs @@ -328,6 +328,7 @@ impl VP8Decoder { } Ok(()) } + #[allow(clippy::collapsible_if)] fn mb_lf_adjustments(&mut self, bc: &mut BoolCoder) -> DecoderResult<()> { self.dstate.lf_delta = bc.read_bool(); if self.dstate.lf_delta { @@ -374,12 +375,12 @@ impl VP8Decoder { Ok(()) } fn read_dct_coef_prob_upd(&mut self, bc: &mut BoolCoder) -> DecoderResult<()> { - for i in 0..4 { - for j in 0..8 { - for k in 0..3 { - for l in 0..11 { - if bc.read_prob(DCT_UPDATE_PROBS[i][j][k][l]) { - self.dstate.coef_probs[i][j][k][l] = bc.read_byte(); + for (probs, upd_probs) in self.dstate.coef_probs.iter_mut().zip(DCT_UPDATE_PROBS.iter()) { + for (probs, upd_probs) in probs.iter_mut().zip(upd_probs.iter()) { + for (probs, upd_probs) in probs.iter_mut().zip(upd_probs.iter()) { + for (prob, &upd_prob) in probs.iter_mut().zip(upd_probs.iter()) { + if bc.read_prob(upd_prob) { + *prob = bc.read_byte(); } } } @@ -392,10 +393,11 @@ impl VP8Decoder { [ 237, 246, 253, 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 250, 250, 252, 254, 254 ], [ 231, 243, 245, 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 251, 251, 254, 254, 254 ] ]; - for comp in 0..2 { - for i in 0..19 { - if bc.read_prob(MV_UPDATE_PROBS[comp][i]) { - self.dstate.mv_probs[comp][i] = bc.read_probability(); + for (prob_row, upd_row) in self.dstate.mv_probs.iter_mut() + .zip(MV_UPDATE_PROBS.iter()) { + for (prob, &upd_prob) in prob_row.iter_mut().zip(upd_row.iter()) { + if bc.read_prob(upd_prob) { + *prob = bc.read_probability(); } } } @@ -447,45 +449,48 @@ impl VP8Decoder { ytype = 3; } sbparams.qmat = &self.qmat[qmat_idx][0]; - for i in 0..16 { + let (y_coeffs, c_coeffs) = self.coeffs.split_at_mut(16); + for (i, (coeffs, y_has_ac)) in y_coeffs.iter_mut().zip(has_ac.iter_mut()).enumerate() { let bx = i & 3; let by = i >> 2; let pred = &self.pcache.y_pred; let pidx = pred.xpos + mb_x * 4 + bx + by * pred.stride; let pctx = self.pcache.y_pred_left[by] + pred.data[pidx - pred.stride]; - let has_nz = decode_subblock(bc, &mut self.coeffs[i], ytype, pctx, &sbparams); + let has_nz = decode_subblock(bc, coeffs, ytype, pctx, &sbparams); self.pcache.y_pred.data[pidx] = has_nz; self.pcache.y_pred_left[by] = has_nz; - has_ac[i] = has_nz > 0; - coded |= has_ac[i] | (self.coeffs[i][0] != 0); + *y_has_ac = has_nz > 0; + coded |= *y_has_ac | (coeffs[0] != 0); } sbparams.qmat = &self.qmat[qmat_idx][1]; - for i in 16..20 { + let (u_coeffs, v_coeffs) = c_coeffs.split_at_mut(4); + let (u_has_ac, v_has_ac) = has_ac[16..24].split_at_mut(4); + for (i, (coeffs, u_has_ac)) in u_coeffs.iter_mut().zip(u_has_ac.iter_mut()).enumerate() { let bx = i & 1; let by = (i >> 1) & 1; let pred = &self.pcache.u_pred; let pidx = pred.xpos + mb_x * 2 + bx + by * pred.stride; let pctx = self.pcache.u_pred_left[by] + pred.data[pidx - pred.stride]; - let has_nz = decode_subblock(bc, &mut self.coeffs[i], 2, pctx, &sbparams); + let has_nz = decode_subblock(bc, coeffs, 2, pctx, &sbparams); self.pcache.u_pred.data[pidx] = has_nz; self.pcache.u_pred_left[by] = has_nz; - has_ac[i] = has_nz > 0; - coded |= has_ac[i] | (self.coeffs[i][0] != 0); + *u_has_ac = has_nz > 0; + coded |= *u_has_ac | (coeffs[0] != 0); } - for i in 20..24 { + for (i, (coeffs, v_has_ac)) in v_coeffs.iter_mut().zip(v_has_ac.iter_mut()).enumerate() { let bx = i & 1; let by = (i >> 1) & 1; let pred = &self.pcache.v_pred; let pidx = pred.xpos + mb_x * 2 + bx + by * pred.stride; let pctx = self.pcache.v_pred_left[by] + pred.data[pidx - pred.stride]; - let has_nz = decode_subblock(bc, &mut self.coeffs[i], 2, pctx, &sbparams); + let has_nz = decode_subblock(bc, coeffs, 2, pctx, &sbparams); self.pcache.v_pred.data[pidx] = has_nz; self.pcache.v_pred_left[by] = has_nz; - has_ac[i] = has_nz > 0; - coded |= has_ac[i] | (self.coeffs[i][0] != 0); + *v_has_ac = has_nz > 0; + coded |= *v_has_ac | (coeffs[0] != 0); } if self.dstate.has_y2 { @@ -499,11 +504,11 @@ impl VP8Decoder { self.coeffs[i][0] = self.coeffs[24][i]; } } - for i in 0..24 { - if has_ac[i] { - idct4x4(&mut self.coeffs[i]); - } else if self.coeffs[i][0] != 0 { - idct4x4_dc(&mut self.coeffs[i]); + for (&has_ac, coeffs) in has_ac.iter().zip(self.coeffs.iter_mut()).take(24) { + if has_ac { + idct4x4(coeffs); + } else if coeffs[0] != 0 { + idct4x4_dc(coeffs); } } @@ -736,6 +741,7 @@ impl VP8Decoder { }, } } + #[allow(clippy::identity_op)] fn do_split_mv(&mut self, bc: &mut BoolCoder, mb_x: usize, mb_y: usize, pred_mv: MV) -> DecoderResult<()> { let split_mode = bc.read_tree(MV_SPLIT_MODE_TREE, &MV_SPLIT_MODE_PROBS); let mut mvidx = mb_x * 4 + mb_y * 4 * self.mv_stride; @@ -1144,6 +1150,7 @@ impl NADecoder for VP8Decoder { } } #[allow(clippy::cognitive_complexity)] + #[allow(clippy::collapsible_else_if)] fn decode(&mut self, supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult { let src = pkt.get_buffer(); validate!(src.len() > 4); diff --git a/nihav-duck/src/codecs/vpcommon.rs b/nihav-duck/src/codecs/vpcommon.rs index eb84f4e..7ab7a07 100644 --- a/nihav-duck/src/codecs/vpcommon.rs +++ b/nihav-duck/src/codecs/vpcommon.rs @@ -18,7 +18,6 @@ pub const VP_YUVA420_FORMAT: NAPixelFormaton = NAPixelFormaton{ }; #[derive(Clone,Copy,Debug,PartialEq,Default)] -#[allow(dead_code)] pub enum VPMBType { #[default] Intra, @@ -36,7 +35,6 @@ pub enum VPMBType { pub const VP_REF_INTER: u8 = 1; pub const VP_REF_GOLDEN: u8 = 2; -#[allow(dead_code)] impl VPMBType { pub fn is_intra(self) -> bool { self == VPMBType::Intra } pub fn get_ref_id(self) -> u8 { @@ -88,7 +86,6 @@ pub const VP56_COEF_ADD_PROBS: [[u8; 12]; 6] = [ [ 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 128 ], ]; -#[allow(dead_code)] pub struct BoolCoder<'a> { pub src: &'a [u8], pos: usize, @@ -97,7 +94,6 @@ pub struct BoolCoder<'a> { bits: i32, } -#[allow(dead_code)] impl<'a> BoolCoder<'a> { pub fn new(src: &'a [u8]) -> DecoderResult { if src.len() < 3 { return Err(DecoderError::ShortData); } @@ -183,7 +179,6 @@ impl<'a> BoolCoder<'a> { } #[allow(dead_code)] -#[allow(clippy::trivially_copy_pass_by_ref)] pub fn rescale_prob(prob: u8, weights: &[i16; 2], maxval: i32) -> u8 { (((i32::from(prob) * i32::from(weights[0]) + 128) >> 8) + i32::from(weights[1])).min(maxval).max(1) as u8 } @@ -263,8 +258,8 @@ pub fn vp_idct(coeffs: &mut [i16; 64]) { pub fn vp_idct_dc(coeffs: &mut [i16; 64]) { let dc = ((mul16(C4S4, mul16(C4S4, i32::from(coeffs[0]))) + 8) >> 4) as i16; - for i in 0..64 { - coeffs[i] = dc; + for coef in coeffs.iter_mut() { + *coef = dc; } } diff --git a/nihav-duck/src/codecs/vpenc/coder.rs b/nihav-duck/src/codecs/vpenc/coder.rs index 60b1fd3..d6715fa 100644 --- a/nihav-duck/src/codecs/vpenc/coder.rs +++ b/nihav-duck/src/codecs/vpenc/coder.rs @@ -157,7 +157,6 @@ impl<'a, 'b> BoolEncoder<'a, 'b> { pub struct Estimator {} -#[allow(dead_code)] impl Estimator { pub fn new() -> Self { Self{} } pub fn write_el(&self, el: T, tree: &[TokenSeq], probs: &mut [ProbCounter]) { diff --git a/nihav-duck/src/codecs/vpenc/mod.rs b/nihav-duck/src/codecs/vpenc/mod.rs index 410d6e4..29cb6ed 100644 --- a/nihav-duck/src/codecs/vpenc/mod.rs +++ b/nihav-duck/src/codecs/vpenc/mod.rs @@ -2,4 +2,5 @@ pub mod coder; pub mod models; #[macro_use] +#[allow(clippy::upper_case_acronyms)] pub mod motion_est; diff --git a/nihav-duck/src/codecs/vpenc/models.rs b/nihav-duck/src/codecs/vpenc/models.rs index c2c2235..b70d362 100644 --- a/nihav-duck/src/codecs/vpenc/models.rs +++ b/nihav-duck/src/codecs/vpenc/models.rs @@ -54,7 +54,7 @@ impl ProbCounter { 128 } } - pub fn to_prob_worthy(&self, old_prob: u8) -> u8 { + pub fn to_prob_worthy(self, old_prob: u8) -> u8 { if self.total > 0 { let new_prob = self.to_prob(); let new_bits = Self::est_bits(new_prob, self.zeroes, self.total); diff --git a/nihav-duck/src/codecs/vpenc/motion_est.rs b/nihav-duck/src/codecs/vpenc/motion_est.rs index 31d2989..149588d 100644 --- a/nihav-duck/src/codecs/vpenc/motion_est.rs +++ b/nihav-duck/src/codecs/vpenc/motion_est.rs @@ -3,7 +3,6 @@ use nihav_codec_support::codecs::{MV, ZERO_MV}; use std::str::FromStr; #[derive(Debug,Clone,Copy,PartialEq,Default)] -#[allow(dead_code)] pub enum MVSearchMode { Full, SEA, @@ -18,7 +17,6 @@ pub struct ParseError{} impl FromStr for MVSearchMode { type Err = ParseError; - #[allow(clippy::single_match)] fn from_str(s: &str) -> Result { match s { "full" => Ok(MVSearchMode::Full), @@ -43,6 +41,7 @@ impl std::fmt::Display for MVSearchMode { } } +#[allow(clippy::wrong_self_convention)] trait FromPixels { fn from_pixels(self) -> Self; }