let mut state = [TrellisNode::default(); 16];
for ch in 0..self.channels {
self.nodes.clear();
- for i in 0..16 {
+ for (i, state) in state.iter_mut().enumerate() {
let step = (((self.first[ch].step + i) as isize) - 8).max(0).min(IMA_MAX_STEP as isize) as usize;
- state[i].state.predictor = self.first[ch].predictor;
- state[i].state.step = step;
- state[i].error = 0;
- state[i].nib = step as u8;
+ state.state.predictor = self.first[ch].predictor;
+ state.state.step = step;
+ state.error = 0;
+ state.nib = step as u8;
}
self.nodes.push(state);
let mut sidx = ch + step;
}
#[cfg(feature="encoder_msvideo1")]
-#[allow(clippy::collapsible_else_if)]
pub mod msvideo1enc;
const MS_ENCODERS: &[EncoderInfo] = &[
for blk in pktbuf.chunks(self.block_len) {
let mut mr = MemoryReader::new_read(blk);
let mut br = ByteReader::new(&mut mr);
- for ch in 0..channels {
+ for p in pred[..channels].iter_mut() {
let coef_idx = br.read_byte()? as usize;
validate!(coef_idx < self.adapt_coeffs.len());
- pred[ch].coef1 = self.adapt_coeffs[coef_idx][0];
- pred[ch].coef2 = self.adapt_coeffs[coef_idx][1];
+ p.coef1 = self.adapt_coeffs[coef_idx][0];
+ p.coef2 = self.adapt_coeffs[coef_idx][1];
}
- for ch in 0..channels {
- pred[ch].delta = i32::from(br.read_u16le()?);
+ for p in pred[..channels].iter_mut() {
+ p.delta = i32::from(br.read_u16le()?);
}
- for ch in 0..channels {
+ for p in pred[..channels].iter_mut() {
let samp = br.read_u16le()? as i16;
- pred[ch].sample1 = i32::from(samp);
+ p.sample1 = i32::from(samp);
}
- for ch in 0..channels {
+ for p in pred[..channels].iter_mut() {
let samp = br.read_u16le()? as i16;
- pred[ch].sample2 = i32::from(samp);
+ p.sample2 = i32::from(samp);
}
for ch in 0..channels {
dst[off[ch]] = pred[ch].sample2 as i16;
let mut bw = ByteWriter::new(&mut mw);
let mut best_idx = [0usize; 2];
- for ch in 0..self.channels {
+ for (ch, best_idx) in best_idx[..self.channels].iter_mut().enumerate() {
let mut best_dist = std::i64::MAX;
for i in 0..ADAPT_COEFFS.len() {
let dist = self.calc_dist(ch, i, len);
if dist < best_dist {
best_dist = dist;
- best_idx[ch] = i;
+ *best_idx = i;
}
}
- bw.write_byte(best_idx[ch] as u8)?;
+ bw.write_byte(*best_idx as u8)?;
}
let mut dec = [Predictor::default(), Predictor::default()];
for ch in 0..self.channels {
dec[ch].delta = 16;
}
}
- for ch in 0..self.channels {
- bw.write_u16le(dec[ch].delta as u16)?;
+ for d in dec[..self.channels].iter() {
+ bw.write_u16le(d.delta as u16)?;
}
- for ch in 0..self.channels {
- bw.write_u16le(dec[ch].sample1 as u16)?;
+ for d in dec[..self.channels].iter() {
+ bw.write_u16le(d.sample1 as u16)?;
}
- for ch in 0..self.channels {
- bw.write_u16le(dec[ch].sample2 as u16)?;
+ for d in dec[..self.channels].iter() {
+ bw.write_u16le(d.sample2 as u16)?;
}
if self.channels == 1 {
for samps in self.samples.chunks(2).skip(1).take(len/2 - 1) {
let mut mr = MemoryReader::new_read(src.as_slice());
let mut br = ByteReader::new(&mut mr);
- let ftype;
let bufret = self.hams.clone_ref();
let mut buf;
if let Some(bbuf) = bufret {
buf = self.hams.get_output_frame().unwrap();
}
let mut frm = NASimpleVideoFrame::from_video_buf(&mut buf).unwrap();
- if !self.is_4bit {
- ftype = self.decode_8bit(&mut br, &mut frm)?;
- } else {
- ftype = self.decode_4bit(&mut br, &mut frm)?;
- }
+ let ftype = if !self.is_4bit {
+ self.decode_8bit(&mut br, &mut frm)?
+ } else {
+ self.decode_4bit(&mut br, &mut frm)?
+ };
let paloff = frm.offset[1];
let dpal = &mut frm.data[paloff..];
for sd in pkt.side_data.iter() {
fn find_index(&self, pix: UnpackedPixel) -> u8 { self.ls.search(pix) as u8 }
fn put_fill(&self, bstate: &BlockState, dst: &mut [u8], dstride: usize) -> u8 {
let fill_val = self.find_index(bstate.fill_val);
- for line in dst.chunks_mut(dstride) {
- for i in 0..4 {
- line[i] = fill_val;
+ for line in dst.chunks_mut(dstride).take(4) {
+ for pix in line[..4].iter_mut() {
+ *pix = fill_val;
}
}
fill_val
}
fn put_clr2(&self, bstate: &BlockState, dst: &mut [u8], dstride: usize) -> [u8; 2] {
let clr2 = [self.find_index(bstate.clr2[0]), self.find_index(bstate.clr2[1])];
- for j in 0..4 {
- for i in 0..4 {
+ for (j, dline) in dst.chunks_mut(dstride).take(4).enumerate() {
+ for (i, pix) in dline[..4].iter_mut().enumerate() {
if (bstate.clr2_flags & (1 << (i + j * 4))) == 0 {
- dst[i + j * dstride] = clr2[0];
+ *pix = clr2[0];
} else {
- dst[i + j * dstride] = clr2[1];
+ *pix = clr2[1];
}
}
}
fn put_fill(&self, bstate: &BlockState, dst: &mut [u16], dstride: usize) -> u16 {
let fill_val = pack_rgb555(bstate.fill_val);
for line in dst.chunks_mut(dstride) {
- for i in 0..4 {
- line[i] = fill_val;
+ for pix in line[..4].iter_mut() {
+ *pix = fill_val;
}
}
fill_val
}
fn put_clr2(&self, bstate: &BlockState, dst: &mut [u16], dstride: usize) -> [u16; 2] {
let clr2 = [pack_rgb555(bstate.clr2[0]), pack_rgb555(bstate.clr2[1])];
- for j in 0..4 {
- for i in 0..4 {
+ for (j, dline) in dst.chunks_mut(dstride).take(4).enumerate() {
+ for (i, pix) in dline[..4].iter_mut().enumerate() {
if (bstate.clr2_flags & (1 << (i + j * 4))) == 0 {
- dst[i + j * dstride] = clr2[0];
+ *pix = clr2[0];
} else {
- dst[i + j * dstride] = clr2[1];
+ *pix = clr2[1];
}
}
}
}
}
fn get_capabilities(&self) -> u64 { ENC_CAPS_SKIPFRAME }
+ #[allow(clippy::collapsible_else_if)]
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
extern crate nihav_core;
extern crate nihav_codec_support;
-#[allow(clippy::needless_range_loop)]
-#[allow(clippy::needless_late_init)]
#[allow(clippy::single_match)]
-#[allow(clippy::verbose_bit_mask)]
mod codecs;
pub use crate::codecs::ms_register_all_decoders;
pub use crate::codecs::ms_register_all_encoders;