From: Kostya Shishkov Date: Thu, 7 Nov 2024 17:49:36 +0000 (+0100) Subject: nihav_commonfmt: fix and update clippy warnings X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=ba8718ff6adae7fb7adbb8e23a179da1a1bff8a1;p=nihav.git nihav_commonfmt: fix and update clippy warnings --- diff --git a/nihav-commonfmt/src/codecs/atrac3.rs b/nihav-commonfmt/src/codecs/atrac3.rs index ee93a63..323090a 100644 --- a/nihav-commonfmt/src/codecs/atrac3.rs +++ b/nihav-commonfmt/src/codecs/atrac3.rs @@ -98,8 +98,8 @@ impl Channel { for _ in 0..self.components { let mut flags: [bool; 4] = [false; 4]; - for band in 0..self.bands { - flags[band] = br.read_bool()?; + for flag in flags[..self.bands].iter_mut() { + *flag = br.read_bool()?; } let nvals = br.read(3)? as usize; let quant = br.read(3)? as usize; @@ -129,8 +129,8 @@ impl Channel { let mut scf: [usize; 32] = [0; 32]; self.subbands = (br.read(5)? as usize) + 1; let mode0 = br.read_bool()?; - for i in 0..self.subbands { - quants[i] = br.read(3)? as usize; + for quant in quants[..self.subbands].iter_mut() { + *quant = br.read(3)? as usize; } for i in 0..self.subbands { if quants[i] == 0 { continue; } @@ -260,22 +260,21 @@ struct DSP { tmp: [f32; ATRAC3_FRAME_SIZE + 64], } -#[allow(clippy::manual_memcpy)] impl DSP { fn new() -> Self { let mut gain_tab: [f32; 16] = [0.0; 16]; let mut gain_tab2: [f32; 32] = [0.0; 32]; - for i in 0..16 { - gain_tab[i] = 2.0f32.powf(4.0 - (i as f32)); + for (i, el) in gain_tab.iter_mut().enumerate() { + *el = 2.0f32.powf(4.0 - (i as f32)); } - for i in 0..32 { - gain_tab2[i] = 2.0f32.powf(((i as f32) - 15.0) * -0.125); + for (i, el) in gain_tab2.iter_mut().enumerate() { + *el = 2.0f32.powf(((i as f32) - 15.0) * -0.125); } let mut tmpw: [f32; 256] = [0.0; 256]; - for i in 0..tmpw.len() { - tmpw[i] = (((((i as f32) + 0.5) / 256.0 - 0.5) * consts::PI).sin() + 1.0) * 0.5; + for (i, el) in tmpw.iter_mut().enumerate() { + *el = (((((i as f32) + 0.5) / 256.0 - 0.5) * consts::PI).sin() + 1.0) * 0.5; } let mut window: [f32; 512] = [0.0; 512]; @@ -294,8 +293,8 @@ impl DSP { fn synth_band(&mut self, src: &[f32]) { let dst = &mut self.tmp; self.imdct.imdct(src, dst); - for i in 0..512 { - dst[i] *= self.window[i]; + for (sample, &win) in dst.iter_mut().zip(self.window.iter()) { + *sample *= win; } } fn apply_gains(&mut self, dst: &mut [f32], delay: &[f32], gain_data: &mut [GainData; 2], block_no: usize, band: usize) { @@ -338,9 +337,7 @@ impl DSP { } } fn qmf_prepare(&mut self, src: &[f32], delay: &[f32], size: usize, swap: bool) { - for i in 0..46 { - self.tmp[i] = delay[i]; - } + self.tmp[..46].copy_from_slice(&delay[..46]); let (s0, s1) = if !swap { (&src[0..], &src[size/2..]) } else { @@ -369,16 +366,12 @@ impl DSP { fn do_qmf(&mut self, dst: &mut [f32], delay: &mut [f32], swap: bool) { self.qmf_prepare(dst, delay, 512, swap); self.qmf_synth(dst, 512); - for i in 0..46 { - delay[i] = self.tmp[512 + i]; - } + delay[..46].copy_from_slice(&self.tmp[512..][..46]); } fn do_qmf_out(&mut self, dst: &mut [f32], src: &[f32], delay: &mut [f32]) { self.qmf_prepare(src, delay, 1024, false); self.qmf_synth(dst, 1024); - for i in 0..46 { - delay[i] = self.tmp[1024 + i]; - } + delay[..46].copy_from_slice(&self.tmp[1024..][..46]); } } @@ -418,8 +411,8 @@ impl CodebookDescReader for Atrac3CodebookReader { impl Atrac3Decoder { fn new() -> Self { let mut scalefactors: [f32; 64] = [0.0; 64]; - for i in 0..scalefactors.len() { - scalefactors[i] = 2.0f32.powf(((i as f32) - 15.0) / 3.0); + for (i, scf) in scalefactors.iter_mut().enumerate() { + *scf = 2.0f32.powf(((i as f32) - 15.0) / 3.0); } let mut cb0 = Atrac3CodebookReader { codes: ATRAC3_HUFF_CODES[0], bits: ATRAC3_HUFF_BITS[0] }; diff --git a/nihav-commonfmt/src/codecs/cinepak.rs b/nihav-commonfmt/src/codecs/cinepak.rs index d7a80dc..c3f31ce 100644 --- a/nihav-commonfmt/src/codecs/cinepak.rs +++ b/nihav-commonfmt/src/codecs/cinepak.rs @@ -69,14 +69,14 @@ impl CinepakDecoder { let cb_size = (size - 4) / cb_elem; validate!(size - 4 == cb_size * cb_elem); validate!(cb_size <= 256); - for i in 0..cb_size { - br.read_buf(&mut cb[i][..cb_elem])?; + for cb_entry in cb[..cb_size].iter_mut() { + br.read_buf(&mut cb_entry[..cb_elem])?; if !is_yuv { - cb[i][4] = 0x80; - cb[i][5] = 0x80; + cb_entry[4] = 0x80; + cb_entry[5] = 0x80; } else { - cb[i][4] ^= 0x80; - cb[i][5] ^= 0x80; + cb_entry[4] ^= 0x80; + cb_entry[5] ^= 0x80; } } Ok(()) @@ -105,6 +105,7 @@ impl CinepakDecoder { validate!(br.tell() == end); Ok(()) } + #[allow(clippy::too_many_arguments)] fn decode_strip(&mut self, src: &[u8], sno: usize, is_intra: bool, is_intra_strip: bool, xoff: usize, yoff: usize, xend: usize, yend: usize, frm: &mut NASimpleVideoFrame) -> DecoderResult<()> { let mut mr = MemoryReader::new_read(src); let mut br = ByteReader::new(&mut mr); diff --git a/nihav-commonfmt/src/codecs/cinepakenc.rs b/nihav-commonfmt/src/codecs/cinepakenc.rs index 6905e42..216ccca 100644 --- a/nihav-commonfmt/src/codecs/cinepakenc.rs +++ b/nihav-commonfmt/src/codecs/cinepakenc.rs @@ -332,6 +332,7 @@ fn quant_fast(bins: &mut [Vec; 4], entries: &[YUVCode], codebook: &mut offset } +#[allow(clippy::collapsible_else_if)] impl CinepakEncoder { fn new() -> Self { Self { diff --git a/nihav-commonfmt/src/codecs/clearvideo.rs b/nihav-commonfmt/src/codecs/clearvideo.rs index 50794ab..5f1405e 100644 --- a/nihav-commonfmt/src/codecs/clearvideo.rs +++ b/nihav-commonfmt/src/codecs/clearvideo.rs @@ -38,7 +38,6 @@ impl CodebookDescReader for CLVSym16CodeReader { fn len(&mut self) -> usize { self.bits.len() } } -#[allow(dead_code)] struct LevelCodes { flags_cb: Option>, mv_cb: Option>, @@ -532,7 +531,6 @@ impl WFrame { } } -#[allow(dead_code)] struct ClearVideoDecoder { info: NACodecInfoRef, dc_cb: Codebook, @@ -878,7 +876,6 @@ fn generate_weights(weights: &mut Vec<[Vec; 9]>, depth: u8) { } impl NADecoder for ClearVideoDecoder { - #[allow(clippy::or_fun_call)] fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> { if let NACodecTypeInfo::Video(vinfo) = info.get_properties() { let mut w = vinfo.get_width(); diff --git a/nihav-commonfmt/src/codecs/jpeg.rs b/nihav-commonfmt/src/codecs/jpeg.rs index 08f30a7..267e633 100644 --- a/nihav-commonfmt/src/codecs/jpeg.rs +++ b/nihav-commonfmt/src/codecs/jpeg.rs @@ -15,7 +15,6 @@ const W8: i32 = 181; const ROW_SHIFT: u8 = 8; const COL_SHIFT: u8 = 14; -#[allow(clippy::erasing_op)] fn idct_row(row: &mut [i16]) { let in0 = ((i32::from(row[0])) << 11) + (1 << (ROW_SHIFT - 1)); let in1 = (i32::from(row[4])) << 11; @@ -131,7 +130,6 @@ struct ComponentInfo { } #[derive(Debug,PartialEq)] -#[allow(dead_code)] enum JPEGType { None, Baseline, @@ -141,7 +139,7 @@ enum JPEGType { Differential, DiffProgressive, DiffLossless, - JPEGLS, + //JPEGLS, } struct JPEGDecoder { @@ -237,7 +235,6 @@ impl JPEGDecoder { self.depth = 0; } - #[allow(clippy::many_single_char_names)] fn parse_sof(&mut self, br: &mut ByteReader) -> DecoderResult { validate!(self.width == 0); @@ -380,6 +377,7 @@ impl JPEGDecoder { put_block(&blocks[1], &mut frm.data[offs[i] + x * 8 + frm.stride[i] * 8..], frm.stride[i]); }, 0x22 => { + #[allow(clippy::needless_range_loop)] for j in 0..4 { put_block(&blocks[j], &mut frm.data[offs[i] + x * 16 + (j & 1) * 8 + (j >> 1) * 8 * frm.stride[i]..], frm.stride[i]); } diff --git a/nihav-commonfmt/src/codecs/mod.rs b/nihav-commonfmt/src/codecs/mod.rs index 686ba4f..96ec016 100644 --- a/nihav-commonfmt/src/codecs/mod.rs +++ b/nihav-commonfmt/src/codecs/mod.rs @@ -12,10 +12,12 @@ macro_rules! validate { #[cfg(feature="decoder_cinepak")] mod cinepak; #[cfg(feature="decoder_clearvideo")] +#[allow(clippy::too_many_arguments)] mod clearvideo; #[cfg(feature="decoder_gif")] mod gif; #[cfg(feature="decoder_jpeg")] +#[allow(clippy::manual_range_contains)] mod jpeg; #[cfg(feature="decoder_rawvideo")] mod rawvideo; @@ -25,18 +27,17 @@ mod rawvideo_ms; mod zmbv; #[cfg(feature="decoder_atrac3")] +#[allow(clippy::excessive_precision)] #[allow(clippy::identity_op)] -#[allow(clippy::useless_let_if_seq)] mod atrac3; #[cfg(any(feature="decoder_pcm",feature="encoder_pcm"))] mod pcm; #[cfg(feature="decoder_sipro")] -#[allow(clippy::collapsible_if)] -#[allow(clippy::collapsible_else_if)] +#[allow(clippy::excessive_precision)] #[allow(clippy::identity_op)] -#[allow(clippy::manual_memcpy)] mod sipro; #[cfg(feature="decoder_ts102366")] +#[allow(clippy::needless_range_loop)] mod ts102366; #[cfg(feature="decoders")] diff --git a/nihav-commonfmt/src/codecs/pcm.rs b/nihav-commonfmt/src/codecs/pcm.rs index c0ef5d3..3021b18 100644 --- a/nihav-commonfmt/src/codecs/pcm.rs +++ b/nihav-commonfmt/src/codecs/pcm.rs @@ -158,7 +158,7 @@ impl PCMEncoder { } } -#[allow(unused_macros)] +#[cfg(feature="encoder_pcm")] macro_rules! write_buffer { ($abuf: expr, $dvec: expr, $write_be: ident, $write_le: ident, $dtype: tt) => { let info = $abuf.get_info(); diff --git a/nihav-commonfmt/src/codecs/rawvideo.rs b/nihav-commonfmt/src/codecs/rawvideo.rs index c0cf103..f7e970c 100644 --- a/nihav-commonfmt/src/codecs/rawvideo.rs +++ b/nihav-commonfmt/src/codecs/rawvideo.rs @@ -42,16 +42,16 @@ impl NADecoder for RawDecoder { } } let mut off = 0; - for i in 0..ncomp { + for (comp_id, &comp_size) in sizes[..ncomp].iter().enumerate() { for (cno, chr) in vinfo.format.comp_info[..ncomp].iter().enumerate() { if let Some(chromaton) = chr { let comp_off = chromaton.comp_offs as usize; validate!(comp_off < ncomp); - if comp_off != i { + if comp_off != comp_id { continue; } offs[cno] = off; - off += sizes[i]; + off += comp_size; } } } diff --git a/nihav-commonfmt/src/codecs/rawvideo_ms.rs b/nihav-commonfmt/src/codecs/rawvideo_ms.rs index 8261e3e..7e54578 100644 --- a/nihav-commonfmt/src/codecs/rawvideo_ms.rs +++ b/nihav-commonfmt/src/codecs/rawvideo_ms.rs @@ -38,9 +38,7 @@ impl NADecoder for RawDecoder { match *sd { NASideData::Palette(_, ref pal) => { for (dst, src) in self.pal.chunks_mut(3).zip(pal.chunks(4)) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; + dst.copy_from_slice(&src[..3]); } break; }, diff --git a/nihav-commonfmt/src/codecs/sipro.rs b/nihav-commonfmt/src/codecs/sipro.rs index eeab619..9626e04 100644 --- a/nihav-commonfmt/src/codecs/sipro.rs +++ b/nihav-commonfmt/src/codecs/sipro.rs @@ -164,30 +164,25 @@ impl SiproDecoder { newfilt[i] = 0.88 * filter[i] + 0.12 * self.lsf_hist[i] + SIPRO_MEAN_LSF_16K[i]; } } - for i in 0..filter.len() { - self.lsf_hist[i] = filter[i]; - } + self.lsf_hist[..filter.len()].copy_from_slice(&filter); let mut prev: f32 = 0.0; - for i in 0..newfilt.len() { - newfilt[i] = newfilt[i].max(prev + SIPRO_LSF_MIN_DIST/2.0); - prev = newfilt[i]; - filter[i] = newfilt[i].cos(); + for (filt, nf) in filter.iter_mut().zip(newfilt.iter_mut()) { + *nf = nf.max(prev + SIPRO_LSF_MIN_DIST/2.0); + prev = *nf; + *filt = nf.cos(); } - for i in 0..lsp.len() { - lsp[i] = (filter[i] + self.lsp_hist[i]) * 0.5; + for (lsp, (&filter, &lsp_hist)) in lsp.iter_mut() + .zip(filter.iter().zip(self.lsp_hist.iter())) { + *lsp = (filter + lsp_hist) * 0.5; } lsp2lpc_16k(&mut self.sf_filter[0], &lsp); lsp2lpc_16k(&mut self.sf_filter[1], &filter); - for i in 0..filter.len() { - self.lsp_hist[i] = filter[i]; - } + self.lsp_hist[..filter.len()].copy_from_slice(&filter); - for i in 0..16 { - self.synth[i] = self.synth_hist[i]; - } + self.synth[..16].copy_from_slice(&self.synth_hist); } fn decode_lsf_lbr(&mut self) { let mut filter: [f32; 10] = [0.0; 10]; @@ -209,17 +204,15 @@ impl SiproDecoder { } let mut prev: f32 = 0.0; - for i in 0..9 { - newfilt[i] = newfilt[i].max(prev + SIPRO_LSF_MIN_DIST); - prev = newfilt[i]; + for nf in newfilt[..9].iter_mut() { + *nf = nf.max(prev + SIPRO_LSF_MIN_DIST); + prev = *nf; } newfilt[9] = newfilt[9].min(prev + SIPRO_LSF_MIN_DIST_LAST); - for i in 0..filter.len() { - self.lsf_hist[i] = filter[i]; - } + self.lsf_hist[..filter.len()].copy_from_slice(&filter); - for i in 0..9 { - newfilt[i] = newfilt[i].cos(); + for nf in newfilt[..9].iter_mut() { + *nf = nf.cos(); } newfilt[9] *= 6.153848 / PI; @@ -231,14 +224,13 @@ impl SiproDecoder { lsp2lpc_lbr(&mut self.sf_filter[sf], &filter); interp += 1.0 / (self.mode.subframes as f32); } - for i in 0..newfilt.len() { - self.lsp_hist[i] = newfilt[i]; - } + self.lsp_hist[..newfilt.len()].copy_from_slice(&newfilt); for i in 0..10 { self.synth[i] = self.synth_hist[i]; } } + #[allow(clippy::collapsible_else_if)] fn calc_pitch_16k(&mut self, sf: usize) { let idx = self.pitch_delay[sf]; let pitch_idx = if sf == 0 { @@ -362,7 +354,6 @@ impl SiproDecoder { } self.unpack_pulses_common(); } - #[allow(clippy::cast_lossless)] fn unpack_pulses_common(&mut self) { for i in 0..48 { self.fix_vec[i] = 0.0; @@ -401,8 +392,8 @@ impl SiproDecoder { self.energy_hist[0] = SIPRO_GAIN_DB_CB_16K[self.gc_index[sf]]; let exc = &mut self.excitation[EXCITATION_OFFSET + sf * 80..][..80]; - for i in 0..80 { - exc[i] = exc[i] * SIPRO_GAIN_PITCH_CB_16K[self.gp_index[sf]] + self.fix_vec[i] * gain; + for (exc_val, &fix_vec) in exc.iter_mut().zip(self.fix_vec.iter()) { + *exc_val = *exc_val * SIPRO_GAIN_PITCH_CB_16K[self.gp_index[sf]] + fix_vec * gain; } } fn update_gain_lbr(&mut self, sf: usize) { @@ -416,10 +407,8 @@ impl SiproDecoder { } self.avg_energy /= 48.0; - let mut sum: f32 = -56.30899869919435856603; - for i in 0..4 { - sum += self.energy_hist[i] * SIPRO_GAIN_PRED[i]; - } + let sum = self.energy_hist.iter().zip(SIPRO_GAIN_PRED.iter()) + .fold(-56.30899869919435856603f32, |acc, (&a, &b)| acc + a * b); for i in 0..3 { self.energy_hist[i] = self.energy_hist[i + 1]; } @@ -427,8 +416,8 @@ impl SiproDecoder { let gain = (f64::from(gain1) * (f64::from(sum) * (10.0f64).ln() * 0.05).exp() / f64::from(self.avg_energy).sqrt()) as f32; let exc = &mut self.excitation[EXCITATION_OFFSET + sf * 48..][..48]; - for i in 0..48 { - exc[i] = exc[i] * gain0 + self.fix_vec[i] * gain; + for (exc_val, &fix_vec) in exc.iter_mut().zip(self.fix_vec.iter()) { + *exc_val = *exc_val * gain0 + fix_vec * gain; } let pitch_gain = (0.5 * gain0 * gain0).min(0.4); @@ -436,8 +425,8 @@ impl SiproDecoder { let gain = gain * self.gain_mem; - for i in 0..48 { - self.fix_vec[i] = exc[i] - gain * self.fix_vec[i]; + for (fix_vec, &exc_val) in self.fix_vec.iter_mut().zip(exc.iter()) { + *fix_vec = exc_val - gain * *fix_vec; } } fn synth_subframe_16k(&mut self, sf: usize) { @@ -452,14 +441,13 @@ impl SiproDecoder { fn postfilter_16k(&mut self) { let mut filt: [f32; 16] = [0.0; 16]; - for i in 0..filt.len() { - filt[i] = self.postfilt_16k_filt_prev[i] * SIPRO_POW_0_5[i]; + for (filt, (&prev, &pow)) in filt.iter_mut() + .zip(self.postfilt_16k_filt_prev.iter().zip(SIPRO_POW_0_5.iter())) { + *filt = prev * pow; } let mut tmp: [f32; 64] = [0.0; 64]; - for i in 0..16 { - tmp[i] = self.postfilt_16k_preemph[i]; - } + tmp[..16].copy_from_slice(&self.postfilt_16k_preemph[..16]); synth_filter(&mut tmp, 16, &self.postfilt_16k_filt, &self.synth[16..], 30, 16); for i in 0..16 { self.synth[i] = self.postfilt_16k_preemph[i]; @@ -491,13 +479,9 @@ impl SiproDecoder { } let mut tmp: [f32; 48 + 10] = [0.0; 48 + 10]; - for i in 0..10 { - tmp[i] = self.postfilt_5k_mem1[i]; - } + tmp[..10].copy_from_slice(&self.postfilt_5k_mem1[..10]); synth_filter(&mut tmp, 10, &d, &self.fix_vec, 48, 10); - for i in 0..10 { - self.postfilt_5k_mem1[i] = tmp[i + 48]; - } + self.postfilt_5k_mem1[..10].copy_from_slice(&tmp[48..]); let tilt = tmp[48 + 10 - 1]; for i in (10+1..48+10).rev() { @@ -506,12 +490,8 @@ impl SiproDecoder { tmp[10] -= 0.4 * self.postfilt_5k_tilt; self.postfilt_5k_tilt = tilt; - for i in 0..10 { - tmp[i] = self.postfilt_5k_mem2[i]; - } - for i in 0..10 { - self.postfilt_5k_mem2[i] = tmp[i + 48]; - } + tmp[..10].copy_from_slice(&self.postfilt_5k_mem2[..10]); + self.postfilt_5k_mem2[..10].copy_from_slice(&tmp[48..]); for i in 0..48 { // almost but not exactly like synth_filter(fix_vec, 0, -n, tmp, 48, 10) self.fix_vec[i] = tmp[i + 10]; @@ -559,9 +539,7 @@ impl SiproDecoder { self.excitation[i] = self.excitation[80 * 2 + i]; } self.postfilter_16k(); - for i in 0..80 * 2 { - dst[i] = self.postfilt_16k_buf[i]; - } + dst[..80 * 2].copy_from_slice(&self.postfilt_16k_buf[..80 * 2]); } fn output_lbr(&mut self, dst: &mut [f32]) { let out_size = self.mode.subframe_len * self.mode.subframes; @@ -574,12 +552,12 @@ impl SiproDecoder { for i in 0..EXCITATION_OFFSET { self.excitation[i] = self.excitation[i + out_size]; } - for i in 0..out_size { - let x = 0.939805806 * self.synth[i + 10] + 1.93307352 * self.iir_state[0] - 0.935891986 * self.iir_state[1]; + for (sample, &synth) in dst[..out_size].iter_mut().zip(self.synth[10..].iter()) { + let x = 0.939805806 * synth + 1.93307352 * self.iir_state[0] - 0.935891986 * self.iir_state[1]; let y = x - 1.99997 * self.iir_state[0] + self.iir_state[1]; self.iir_state[1] = self.iir_state[0]; self.iir_state[0] = x; - dst[i] = y; + *sample = y; } } } diff --git a/nihav-commonfmt/src/codecs/ts102366.rs b/nihav-commonfmt/src/codecs/ts102366.rs index a2ee21c..399f231 100644 --- a/nihav-commonfmt/src/codecs/ts102366.rs +++ b/nihav-commonfmt/src/codecs/ts102366.rs @@ -574,6 +574,7 @@ impl ChannelData { if lastbin >= end { break; } } } + #[allow(clippy::too_many_arguments)] fn compute_mask(&mut self, mask: &mut [i32; MAX_BANDS], fscod: usize, sgain: u16, fdecay: u8, sdecay: u8, dbknee: u16, cplfleak: u16, cplsleak: u16, shift: u8) { let fgain = i32::from(TS102366_FAST_GAIN[self.fgaincod]); diff --git a/nihav-commonfmt/src/codecs/zmbv.rs b/nihav-commonfmt/src/codecs/zmbv.rs index 471f47e..660244a 100644 --- a/nihav-commonfmt/src/codecs/zmbv.rs +++ b/nihav-commonfmt/src/codecs/zmbv.rs @@ -167,7 +167,6 @@ const RGB24_0_FORMAT: NAPixelFormaton = NAPixelFormaton { model: ColorModel::RGB elem_size: 4, be: false, alpha: false, palette: false }; impl NADecoder for ZMBVDecoder { - #[allow(clippy::or_fun_call)] fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> { if let NACodecTypeInfo::Video(vinfo) = info.get_properties() { self.pparms.width = vinfo.get_width(); diff --git a/nihav-commonfmt/src/demuxers/avi.rs b/nihav-commonfmt/src/demuxers/avi.rs index 0db514d..c0f54b4 100644 --- a/nihav-commonfmt/src/demuxers/avi.rs +++ b/nihav-commonfmt/src/demuxers/avi.rs @@ -58,7 +58,6 @@ impl RIFFSegment { } } -#[allow(dead_code)] struct AVIDemuxer<'a> { src: &'a mut ByteReader<'a>, cur_frame: Vec, @@ -523,13 +522,11 @@ fn is_list_tag(tag: u32) -> bool { false } -#[allow(unused_variables)] -fn parse_hdrl(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize) -> DemuxerResult { +fn parse_hdrl(_dmx: &mut AVIDemuxer, _strmgr: &mut StreamManager, _size: usize) -> DemuxerResult { Ok(0) } -#[allow(unused_variables)] -fn parse_strl(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize) -> DemuxerResult { +fn parse_strl(_dmx: &mut AVIDemuxer, _strmgr: &mut StreamManager, _size: usize) -> DemuxerResult { Ok(0) } @@ -542,11 +539,10 @@ fn parse_rec(_dmx: &mut AVIDemuxer, _strmgr: &mut StreamManager, _size: usize) - Ok(0) } -#[allow(unused_variables)] -fn parse_strh(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize) -> DemuxerResult { +fn parse_strh(dmx: &mut AVIDemuxer, _strmgr: &mut StreamManager, size: usize) -> DemuxerResult { if size < 0x38 { return Err(InvalidData); } let tag = dmx.src.read_u32be()?; //stream type - let fcc = dmx.src.read_u32be()?; //handler(fourcc) + let _fcc = dmx.src.read_u32be()?; //handler(fourcc) dmx.src.read_u32le()?; //flags dmx.src.read_skip(2)?; //priority dmx.src.read_skip(2)?; //language @@ -558,10 +554,10 @@ fn parse_strh(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize) -> dmx.src.read_skip(4)?; //buf size dmx.src.read_skip(4)?; //quality dmx.src.read_skip(4)?; //sample size - let a = dmx.src.read_u16le()?; - let b = dmx.src.read_u16le()?; - let c = dmx.src.read_u16le()?; - let d = dmx.src.read_u16le()?; + let _a = dmx.src.read_u16le()?; + let _b = dmx.src.read_u16le()?; + let _c = dmx.src.read_u16le()?; + let _d = dmx.src.read_u16le()?; dmx.src.read_skip(size - 0x38)?; @@ -594,7 +590,6 @@ fn parse_strf(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize) -> } } -#[allow(unused_variables)] fn parse_strf_vids(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize) -> DemuxerResult { if size < 40 { return Err(InvalidData); } let bi_size = dmx.src.read_u32le()?; @@ -605,12 +600,12 @@ fn parse_strf_vids(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize let bitcount = dmx.src.read_u16le()?; let mut compression: [u8; 4] = [0; 4]; dmx.src.read_buf(&mut compression)?; - let img_size = dmx.src.read_u32le()?; - let xdpi = dmx.src.read_u32le()?; - let ydpi = dmx.src.read_u32le()?; + let _img_size = dmx.src.read_u32le()?; + let _xdpi = dmx.src.read_u32le()?; + let _ydpi = dmx.src.read_u32le()?; let colors = dmx.src.read_u32le()?; validate!(colors <= 256); - let imp_colors = dmx.src.read_u32le()?; + let _imp_colors = dmx.src.read_u32le()?; let flip = height < 0; let format = if bitcount > 8 { RGB24_FORMAT } else { PAL8_FORMAT }; @@ -692,13 +687,12 @@ fn find_raw_yuv_fmt(compr: &[u8; 4], vhdr: &mut NAVideoInfo) -> bool { } } -#[allow(unused_variables)] fn parse_strf_auds(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize) -> DemuxerResult { if size < 16 { return Err(InvalidData); } let w_format_tag = dmx.src.read_u16le()?; let channels = dmx.src.read_u16le()?; let samplespersec = dmx.src.read_u32le()?; - let avgbytespersec = dmx.src.read_u32le()?; + let _avgbytespersec = dmx.src.read_u32le()?; let block_align = dmx.src.read_u16le()?; let bits_per_sample = dmx.src.read_u16le()?; @@ -732,22 +726,21 @@ fn parse_strf_xxxx(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize Ok(size) } -#[allow(unused_variables)] -fn parse_avih(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize) -> DemuxerResult { +fn parse_avih(dmx: &mut AVIDemuxer, _strmgr: &mut StreamManager, size: usize) -> DemuxerResult { if size < 0x38 { return Err(InvalidData); } - let timebase = dmx.src.read_u32le()?; //microsec per frame + let _timebase = dmx.src.read_u32le()?; //microsec per frame dmx.src.read_skip(4)?; //max frame size dmx.src.read_skip(4)?; //padding dmx.src.read_u32le()?; //flags - let frames = dmx.src.read_u32le()?; //frames + let _frames = dmx.src.read_u32le()?; //frames dmx.src.read_skip(4)?; //initial frames let streams = dmx.src.read_u32le()?; //streams if streams > 100 { return Err(InvalidData); } dmx.num_streams = streams as u8; dmx.src.read_skip(4)?; //buf size - let width = dmx.src.read_u32le()?; //width - let height = dmx.src.read_u32le()? as i32; //height + let _width = dmx.src.read_u32le()?; //width + let _height = dmx.src.read_u32le()? as i32; //height dmx.src.read_skip(16)?; //reserved dmx.cur_frame.resize(streams as usize, 0); @@ -780,13 +773,11 @@ fn parse_indx(dmx: &mut AVIDemuxer, _strmgr: &mut StreamManager, size: usize) -> Ok(size) } -#[allow(unused_variables)] -fn parse_junk(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize) -> DemuxerResult { +fn parse_junk(dmx: &mut AVIDemuxer, _strmgr: &mut StreamManager, size: usize) -> DemuxerResult { dmx.src.read_skip(size)?; Ok(size) } -#[allow(clippy::verbose_bit_mask)] fn parse_idx1(src: &mut ByteReader, strmgr: &mut StreamManager, seek_idx: &mut SeekIndex, size: usize, movi_pos: u64, key_offs: &mut Vec) -> DemuxerResult { validate!((size & 15) == 0); let mut tag = [0u8; 4]; diff --git a/nihav-commonfmt/src/demuxers/mod.rs b/nihav-commonfmt/src/demuxers/mod.rs index 42d1f11..b64ce59 100644 --- a/nihav-commonfmt/src/demuxers/mod.rs +++ b/nihav-commonfmt/src/demuxers/mod.rs @@ -12,12 +12,10 @@ macro_rules! validate { } #[cfg(feature="demuxer_avi")] -#[allow(clippy::cast_lossless)] mod avi; #[cfg(feature="demuxer_gif")] mod gif; #[cfg(feature="demuxer_mov")] -#[allow(clippy::cast_lossless)] mod mov; #[cfg(feature="demuxer_wav")] mod wav; diff --git a/nihav-commonfmt/src/demuxers/mov.rs b/nihav-commonfmt/src/demuxers/mov.rs index aa84a20..b92f496 100644 --- a/nihav-commonfmt/src/demuxers/mov.rs +++ b/nihav-commonfmt/src/demuxers/mov.rs @@ -1410,8 +1410,6 @@ impl Track { self.bsize } } - #[allow(clippy::collapsible_if)] - #[allow(clippy::collapsible_else_if)] fn seek(&mut self, pts: u64, tpoint: NATimePoint) -> DemuxerResult { self.cur_sample = pts as usize; self.samples_left = 0; @@ -1439,14 +1437,12 @@ impl Track { } self.raw_apos = apos; apos += (cur_samps / self.frame_samples) as u64; - if apos > exp_pts { - if cur_samps == self.frame_samples || apos > exp_pts + 1 { - if self.cur_chunk >= self.chunk_offsets.len() { - return Err(DemuxerError::SeekError); - } - self.last_offset = self.chunk_offsets[self.cur_chunk]; - break; + if apos > exp_pts && (cur_samps == self.frame_samples || apos > exp_pts + 1) { + if self.cur_chunk >= self.chunk_offsets.len() { + return Err(DemuxerError::SeekError); } + self.last_offset = self.chunk_offsets[self.cur_chunk]; + break; } self.cur_chunk += 1; } diff --git a/nihav-commonfmt/src/lib.rs b/nihav-commonfmt/src/lib.rs index cdd2cd9..beda083 100644 --- a/nihav-commonfmt/src/lib.rs +++ b/nihav-commonfmt/src/lib.rs @@ -4,14 +4,8 @@ extern crate nihav_codec_support; extern crate nihav_registry; #[cfg(any(feature="decoders", feature="encoders"))] -#[allow(clippy::needless_range_loop)] #[allow(clippy::single_match)] -#[allow(clippy::unreadable_literal)] -#[allow(clippy::too_many_arguments)] -#[allow(clippy::excessive_precision)] #[allow(clippy::upper_case_acronyms)] -#[allow(clippy::manual_range_contains)] -#[allow(clippy::collapsible_else_if)] mod codecs; #[cfg(feature="decoders")] diff --git a/nihav-commonfmt/src/muxers/avi.rs b/nihav-commonfmt/src/muxers/avi.rs index d8e1f73..136d255 100644 --- a/nihav-commonfmt/src/muxers/avi.rs +++ b/nihav-commonfmt/src/muxers/avi.rs @@ -64,8 +64,6 @@ fn write_chunk_hdr(bw: &mut ByteWriter, stype: StreamType, str_no: u32) -> Muxer } impl<'a> MuxCore<'a> for AVIMuxer<'a> { - #[allow(clippy::unreadable_literal)] - #[allow(clippy::cast_lossless)] fn create(&mut self, strmgr: &StreamManager) -> MuxerResult<()> { if strmgr.get_num_streams() == 0 { return Err(MuxerError::InvalidArgument);