for (i, subframe) in self.subframe.iter_mut().enumerate() {
subframe.gen_fcb_excitation(&mut self.excitation[exc_start..], self.is_6300, FCB_MAX_POS[i], if (i & 1) == 0 { 6 } else { 5 });
subframe.gen_acb_excitation(&mut acb_vector, &self.excitation[SUBFRAME_LEN * i..], self.is_6300);
- for i in 0..SUBFRAME_LEN {
- let val = self.excitation[exc_start + i];
- self.excitation[exc_start + i] = val.saturating_add(val).saturating_add(acb_vector[i]);
+ for (exc, &acb) in self.excitation[exc_start..][..SUBFRAME_LEN].iter_mut()
+ .zip(acb_vector.iter()) {
+ *exc = exc.saturating_add(*exc).saturating_add(acb);
}
exc_start += SUBFRAME_LEN;
}
subframe.acb_lag = ADAPTIVE_LAG[i];
}
- let mut off = [0; 4];
+ let mut off = [0; SUBFRAMES];
let mut signs = [[0; 11]; 2];
for i in (0..4).step_by(2) {
let t = self.cng_rnd.next_range(1 << 13);
let mut pos = [0; 11 * SUBFRAMES];
let mut pidx = 0;
let mut tmp = [0; SUBFRAME_LEN / 2];
- for i in 0..SUBFRAMES {
+ for (i, &offset) in off.iter().enumerate() {
let npulses = if (i & 1) == 0 { 6 } else { 5 };
for j in 0..npulses {
let idx = self.cng_rnd.next_range(SUBFRAME_LEN / 2 - j);
- pos[pidx] = tmp[idx] * 2 + off[i];
+ pos[pidx] = tmp[idx] * 2 + offset;
pidx += 1;
tmp[idx] = tmp[SUBFRAME_LEN / 2 - 1 - j];
}
self.subframe[i + 1].gen_acb_excitation(&mut acb_vec, &buf[SUBFRAME_LEN..], self.is_6300);
buf[SUBFRAME_LEN..][..SUBFRAME_LEN].copy_from_slice(&acb_vec);
- let mut max = 0;
- for j in 0..SUBFRAME_LEN*2 {
- max |= i32::from(buf[j]).abs();
- }
+ let max = buf[..SUBFRAME_LEN * 2].iter().fold(0i32, |acc, &a| acc | i32::from(a).abs());
let shift = if max == 0 { 0 } else {
(-10 + (32 - max.min(0x7FFF).leading_zeros()) as i32).max(-2)
};
}
fn gain_scale(pf_gain: &mut i32, buf: &mut [i16], energy: i32) {
let mut den = 0i32;
- for i in 0..SUBFRAME_LEN {
- let val = i32::from(buf[i] >> 2);
+ for &samp in buf[..SUBFRAME_LEN].iter() {
+ let val = i32::from(samp >> 2);
den = den.saturating_add(val * val).saturating_add(val * val);
}
let mut num = energy;
gain = 1 << 12;
}
- for i in 0..SUBFRAME_LEN {
+ for val in buf[..SUBFRAME_LEN].iter_mut() {
*pf_gain = (15 * *pf_gain + gain + (1 << 3)) >> 4;
- buf[i] = clip16((i32::from(buf[i]) * (*pf_gain + (*pf_gain >> 4)) + (1 << 10)) >> 11);
+ *val = clip16((i32::from(*val) * (*pf_gain + (*pf_gain >> 4)) + (1 << 10)) >> 11);
}
}
}
}
#[cfg(any(feature="decoder_vivo1", feature="decoder_vivo2"))]
-#[allow(clippy::useless_let_if_seq)]
mod vivo;
#[cfg(feature="decoder_g723_1")]
-#[allow(clippy::needless_range_loop)]
-#[allow(clippy::unreadable_literal)]
-#[allow(clippy::useless_let_if_seq)]
mod g723_1;
#[cfg(feature="decoder_siren")]
#[allow(clippy::approx_constant)]
-#[allow(clippy::needless_range_loop)]
mod siren;
const VIVO_CODECS: &[DecoderInfo] = &[
generate_window(WindowType::Sine, 1.0 / 320.0 / 64.0, SAMPLES, true, &mut window);
let mut quant_tab = [0.0; 64];
- for i in 0..64 {
- quant_tab[i] = 2.0f32.powf((((i as i32) - 24) as f32) / 2.0);
+ for (i, quant) in quant_tab.iter_mut().enumerate() {
+ *quant = 2.0f32.powf((((i as i32) - 24) as f32) / 2.0);
}
SirenDecoder {
} else {
let mut min_value = 99;
let mut max_idx = 0;
- for reg in 0..NUM_REGIONS {
- if max_rate_cat[reg] == 0 { continue; }
- let val = offset - self.pow_index[reg] - 2 * (max_rate_cat[reg] as i32);
+ for (reg, (&max_rate, &pow_index)) in max_rate_cat.iter()
+ .zip(self.pow_index.iter()).enumerate() {
+ if max_rate == 0 { continue; }
+ let val = offset - pow_index - 2 * (max_rate as i32);
if min_value > val {
min_value = val;
max_idx = reg;
use nihav_codec_support::codecs::h263::decoder::*;
use nihav_codec_support::codecs::h263::data::*;
-#[allow(dead_code)]
struct Tables {
intra_mcbpc_cb: Codebook<u8>,
inter_mcbpc_cb: Codebook<u8>,
impl<'a> BlockDecoder for VivoBR<'a> {
-#[allow(unused_variables)]
-#[allow(clippy::unreadable_literal)]
fn decode_pichdr(&mut self) -> DecoderResult<PicInfo> {
let br = &mut self.br;
let syncw = br.read(22)?;
let cpm = br.read_bool()?;
validate!(!cpm);
- let pbinfo;
- if self.is_pb {
- let trb = br.read(3)?;
- let dbquant = br.read(2)?;
- pbinfo = Some(PBInfo::new(trb as u8, dbquant as u8, pbplus));
- } else {
- pbinfo = None;
- }
+ let pbinfo = if self.is_pb {
+ let trb = br.read(3)?;
+ let dbquant = br.read(2)?;
+ Some(PBInfo::new(trb as u8, dbquant as u8, pbplus))
+ } else { None };
while br.read_bool()? { // skip PEI
br.read(8)?;
}
Ok(picinfo)
}
- #[allow(unused_variables)]
- fn decode_slice_header(&mut self, info: &PicInfo) -> DecoderResult<SliceInfo> {
+ fn decode_slice_header(&mut self, _info: &PicInfo) -> DecoderResult<SliceInfo> {
let br = &mut self.br;
let gbsc = br.read(17)?;
validate!(gbsc == 1);
- let gn = br.read(5)?;
- let gfid = br.read(2)?;
+ let _gn = br.read(5)?;
+ let _gfid = br.read(2)?;
let gquant = br.read(5)?;
let ret = SliceInfo::new_gob(0, self.gob_no, gquant as u8);
self.gob_no += 1;
Ok(ret)
}
- #[allow(unused_variables)]
- fn decode_block_header(&mut self, info: &PicInfo, slice: &SliceInfo, sstate: &SliceState) -> DecoderResult<BlockInfo> {
+ fn decode_block_header(&mut self, info: &PicInfo, slice: &SliceInfo, _sstate: &SliceState) -> DecoderResult<BlockInfo> {
let br = &mut self.br;
let mut q = slice.get_quant();
match info.get_mode() {
}
}
- #[allow(unused_variables)]
fn decode_block_intra(&mut self, info: &BlockInfo, _sstate: &SliceState, quant: u8, no: usize, coded: bool, blk: &mut [i16; 64]) -> DecoderResult<()> {
self.decode_block(quant, true, coded, blk, if no < 4 { 0 } else { no - 3 }, info.get_acpred())
}
- #[allow(unused_variables)]
- fn decode_block_inter(&mut self, info: &BlockInfo, _sstate: &SliceState, quant: u8, no: usize, coded: bool, blk: &mut [i16; 64]) -> DecoderResult<()> {
+ fn decode_block_inter(&mut self, _info: &BlockInfo, _sstate: &SliceState, quant: u8, no: usize, coded: bool, blk: &mut [i16; 64]) -> DecoderResult<()> {
self.decode_block(quant, false, coded, blk, if no < 4 { 0 } else { no - 3 }, ACPredMode::None)
}
extern crate nihav_codec_support;
#[allow(clippy::upper_case_acronyms)]
-#[allow(clippy::needless_late_init)]
mod codecs;
mod demuxers;