}
Ok(())
}
+ #[allow(clippy::comparison_chain)]
fn lpc_pred(&mut self, samps: &mut [i32], bits: u8) {
if self.mode == 15 || self.order == 31 {
for i in 1..samps.len() {
kb: 0,
}
}
- #[allow(clippy::collapsible_if)]
+ #[allow(clippy::collapsible_else_if)]
fn decode_elem(&mut self, br: &mut BitReader, stereo: bool) -> DecoderResult<()> {
let _element_instance = br.read(4)?;
br.skip(12)?;
mod svq1data;
#[cfg(feature="decoder_svq3")]
-#[allow(clippy::collapsible_if)]
-#[allow(clippy::identity_op)]
-#[allow(clippy::needless_range_loop)]
#[allow(clippy::too_many_arguments)]
-#[allow(clippy::verbose_bit_mask)]
mod svq3;
#[cfg(feature="decoder_svq3")]
-#[allow(clippy::collapsible_if)]
+#[allow(clippy::collapsible_else_if)]
#[allow(clippy::erasing_op)]
#[allow(clippy::identity_op)]
#[allow(clippy::many_single_char_names)]
-#[allow(clippy::needless_range_loop)]
-#[allow(clippy::unreadable_literal)]
mod svq3dsp;
#[cfg(feature="decoder_alac")]
mod mace;
#[cfg(any(feature="decoder_qdm",feature="decoder_qdm2"))]
-#[allow(clippy::unreadable_literal)]
mod qdmcommon;
#[cfg(feature="decoder_qdm")]
-#[allow(clippy::needless_range_loop)]
-#[allow(clippy::unreadable_literal)]
mod qdmc;
#[cfg(feature="decoder_qdm2")]
-#[allow(clippy::needless_range_loop)]
#[allow(clippy::excessive_precision)]
-#[allow(clippy::unreadable_literal)]
mod qdm2fft;
#[cfg(feature="decoder_qdm2")]
-#[allow(clippy::needless_range_loop)]
#[allow(clippy::excessive_precision)]
-#[allow(clippy::unreadable_literal)]
mod qdm2qmf;
#[cfg(feature="decoder_qdm2")]
#[allow(clippy::excessive_precision)]
-#[allow(clippy::unreadable_literal)]
mod qdm2;
const QT_CODECS: &[DecoderInfo] = &[
16 => {
if br.left() >= 10 {
if zero_coding {
- for i in 0..5 {
+ for (i, dst) in samples[..5].iter_mut().enumerate() {
if idx + i >= 128 { break; }
- samples[i] = if br.read_bool() {
+ *dst = if br.read_bool() {
let ix = (br.read(1) as usize) * 2;
QUANT_1BIT[jstereo as usize][ix]
} else { 0.0 };
} else {
let idx = br.read(8) as usize;
validate!(idx < self.tables.mod3.len());
- for i in 0..5 {
- let k = self.tables.mod3[idx][i] as usize;
- samples[i] = QUANT_1BIT[jstereo as usize][k];
+ for (dst, &k) in samples.iter_mut().zip(self.tables.mod3[idx].iter()) {
+ *dst = QUANT_1BIT[jstereo as usize][k as usize];
}
}
} else {
if br.left() >= 7 {
let idx = br.read(7) as usize;
validate!(idx < self.tables.mod5.len());
- for i in 0..3 {
- let k = self.tables.mod5[idx][i] as usize;
- samples[i] = ((k as f32) - 2.0) * 0.5;
+ for (dst, &k) in samples.iter_mut().zip(self.tables.mod5[idx].iter()) {
+ *dst = ((k as f32) - 2.0) * 0.5;
}
} else {
for el in samples.iter_mut().take(3) {
let next = noise_bands[band + 2];
let noise = &mut self.noise_tab[band];
- for i in prev..cur {
- noise[i] = ((i - prev) as f32) / ((cur - prev) as f32);
+ for (i, el) in noise[prev..cur].iter_mut().enumerate() {
+ *el = (i as f32) / ((cur - prev) as f32);
}
+ #[allow(clippy::needless_range_loop)]
for i in cur..next {
noise[i] = ((next - i) as f32) / ((next - cur) as f32);
}
let start = noise_bands[band];
let end = noise_bands[band + 2].min(self.sf_len);
let linscale = &self.noise_tab[band];
- for i in start..end {
- self.tmp[i] += scale * linscale[i];
+ for (el, &add) in self.tmp[start..end].iter_mut().zip(linscale[start..end].iter()) {
+ *el += scale * add;
}
}
}
}
fn add_tones(&mut self, sf: usize, start_idx: &mut [usize; 5]) {
- for group in 0..5 {
+ for (group, group_start) in start_idx.iter_mut().enumerate() {
let group_bits = 4 - group;
let group_size = (1 << (group_bits + 1)) - 1;
- for tone in self.tones[group].iter().skip(start_idx[group]) {
+ for tone in self.tones[group].iter().skip(*group_start) {
if (tone.offset as usize) > sf {
break;
}
- start_idx[group] += 1;
+ *group_start += 1;
let pos = (tone.freq >> group_bits) as usize;
let scale = SCALES[(tone.amp_idx & 0x3F) as usize] / 32768.0;
}
#[allow(clippy::identity_op)]
-#[allow(dead_code)]
impl<'a> QdmBitReader<'a> {
pub fn new(src: &'a [u8]) -> Self {
Self{ cache: 0, pos: 0, bits: 0, src }
}
- pub fn tell(&self) -> usize {
+ /*pub fn tell(&self) -> usize {
self.pos * 8 - (self.bits as usize)
- }
+ }*/
pub fn left(&self) -> isize {
((self.src.len() as isize) - (self.pos as isize)) * 8 + (self.bits as isize)
}
}
impl<'a, S: Copy> CodebookReader<S> for QdmBitReader<'a> {
- #[allow(unused_variables)]
fn read_cb(&mut self, cb: &Codebook<S>) -> CodebookResult<S> {
let mut esc = true;
let mut idx = 0;
depth: u8,
}
-#[allow(clippy::needless_range_loop)]
fn unpack_mono(src: u16, dst: &mut [u8; 16]) {
- for i in 0..16 {
- dst[i] = ((src >> (15 - i)) & 1) as u8;
+ for (i, el) in dst.iter_mut().enumerate() {
+ *el = ((src >> (15 - i)) & 1) as u8;
}
}
-#[allow(clippy::needless_range_loop)]
fn unpack_pixels(src: u32, dst: &mut [u8; 16], depth: u8) {
let depth = depth as usize;
let mask = (1 << depth) - 1;
- for i in 0..32 / depth {
- dst[i] = ((src >> (32 - depth - i * depth)) & mask) as u8;
+ for (i, el) in dst[..32 / depth].iter_mut().enumerate() {
+ *el = ((src >> (32 - depth - i * depth)) & mask) as u8;
}
}
}
impl SVQ1Decoder {
- #[allow(clippy::needless_range_loop)]
fn new() -> Self {
let mut intra_stages_cb = Vec::with_capacity(6);
- for i in 0..6 {
- let mut cbd = SVQ1DescReader { table: &SVQ_INTRA_STAGE_CODES[i], bias: -1 };
+ for table in SVQ_INTRA_STAGE_CODES.iter() {
+ let mut cbd = SVQ1DescReader { table, bias: -1 };
let cb = Codebook::new(&mut cbd, CodebookMode::MSB).unwrap();
intra_stages_cb.push(cb);
}
let mut inter_stages_cb = Vec::with_capacity(6);
- for i in 0..6 {
- let mut cbd = SVQ1DescReader { table: &SVQ_INTER_STAGE_CODES[i], bias: -1 };
+ for table in SVQ_INTER_STAGE_CODES.iter() {
+ let mut cbd = SVQ1DescReader { table, bias: -1 };
let cb = Codebook::new(&mut cbd, CodebookMode::MSB).unwrap();
inter_stages_cb.push(cb);
}
Err(DecoderError::InvalidData)
}
}
- #[allow(clippy::collapsible_if)]
+ #[allow(clippy::collapsible_else_if)]
fn decode(&mut self, supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let src = pkt.get_buffer();
validate!(src.len() >= 2);
if val == 0 { break; }
let sign = (val & 1) == 0;
let val = (val + 1) >> 1;
- let (run, level) = if val < 3 {
- (0, val as i16)
- } else if val == 3 {
- (1, 1)
- } else {
- ((val & 3) as usize, (((val + 9) >> 2) - (val & 3)) as i16)
+ let (run, level) = match val {
+ 0..=2 => (0, val as i16),
+ 3 => (1, 1),
+ _ => ((val & 3) as usize, (((val + 9) >> 2) - (val & 3)) as i16)
};
idx += run;
validate!(idx < blk.len());
}
}
}
- for comp in 0..2 {
- for i in 0..4 {
+ for (comp, cdcs) in cdcs.iter().enumerate() {
+ for (i, &c_dc) in cdcs.iter().enumerate() {
let blk_idx = 16 + comp * 4 + i;
- self.coeffs[blk_idx][0] = cdcs[comp][i];
- self.dc_only[blk_idx] = cdcs[comp][i] != 0;
+ self.coeffs[blk_idx][0] = c_dc;
+ self.dc_only[blk_idx] = c_dc != 0;
idct(&mut self.coeffs[blk_idx], SVQ3_CHROMA_QUANT[sstate.q as usize], true);
}
}
Ok(())
}
+ #[allow(clippy::identity_op)]
fn do_mc_p(&mut self, br: &mut BitReader, mb_type: usize, sstate: &mut SState, dframe: &mut NASimpleVideoFrame<u8>) -> DecoderResult<()> {
if mb_type == 0 {
self.mvi.fill(self.mb_x, self.mb_y, true, ZERO_MV);
}
}
}
- for comp in 0..2 {
- for i in 0..4 {
+ for (comp, cdcs) in cdcs.iter().enumerate() {
+ for (i, &c_dc) in cdcs.iter().enumerate() {
let blk_idx = 16 + comp * 4 + i;
- self.coeffs[blk_idx][0] = cdcs[comp][i];
- self.dc_only[blk_idx] = cdcs[comp][i] != 0;
+ self.coeffs[blk_idx][0] = c_dc;
+ self.dc_only[blk_idx] = c_dc != 0;
idct(&mut self.coeffs[blk_idx], SVQ3_CHROMA_QUANT[sstate.q as usize], true);
}
}
}
}
}
+ #[allow(clippy::field_reassign_with_default)]
fn decode_slice(&mut self, br: &mut BitReader, hdr: &SVQ3Header, dframe: &mut NASimpleVideoFrame<u8>) -> DecoderResult<()> {
let mut mb_idx = self.mb_x + self.mb_y * self.mb_w;
let mbs = self.mb_w * self.mb_h;
sstate.has_tr = false;
}
- if br.left() < 8 {
- if (br.tell() & 7) == 0 && br.peek(8) == 0 {
- return Ok(());
- }
+ if br.left() < 8 && (br.tell() & 7) == 0 && br.peek(8) == 0 {
+ return Ok(());
}
let mut mb_type = br.read_code(UintCodeType::Gamma)? as usize;
if hdr.ftype == FrameType::I {
use nihav_codec_support::codecs::blockdsp::*;
-#[allow(dead_code)]
#[derive(Debug,Clone,Copy)]
pub enum PredType4x4 {
Ver,
DC128,
}
-#[allow(dead_code)]
#[derive(Debug,Clone,Copy)]
pub enum PredType8x8 {
DC,
extern crate nihav_core;
extern crate nihav_codec_support;
-#[allow(clippy::comparison_chain)]
#[allow(clippy::single_match)]
-#[allow(clippy::field_reassign_with_default)]
#[allow(clippy::upper_case_acronyms)]
-#[allow(clippy::collapsible_else_if)]
mod codecs;
pub use crate::codecs::qt_register_all_decoders;