if free_bits > cur_bits {
let mut tmp: [f32; BANDS] = [BITALLOC_LIMIT; BANDS];
- for band in 0..BANDS {
- if self.band_bits[band] != 6 {
- tmp[band] = f32::from(self.band_bits[band]) * -2.0 + ch_data.bit_est[band] - 0.415;
+ for (dst, (&band_bits, &bit_est)) in tmp.iter_mut()
+ .zip(self.band_bits.iter().zip(ch_data.bit_est.iter())) {
+ if band_bits != 6 {
+ *dst = f32::from(band_bits) * -2.0 + bit_est - 0.415;
}
}
let mut peak = 0.0;
while (peak > BITALLOC_LIMIT) && (cur_bits < free_bits) {
peak = BITALLOC_LIMIT;
let mut idx: Option<usize> = None;
- for band in 0..BANDS {
- if tmp[band] > peak {
- peak = tmp[band];
+ for (band, &level) in tmp.iter().enumerate() {
+ if level > peak {
+ peak = level;
idx = Some(band);
}
}
if cur_bits > free_bits {
let mut tmp: [f32; BANDS] = [BITALLOC_TOP_LIMIT; BANDS];
- for band in start..BANDS {
- if self.band_bits[band] != 0 {
- tmp[band] = f32::from(self.band_bits[band]) * -2.0 + ch_data.bit_est[band] - 0.415 + 2.0;
+ for (dst, (&band_bits, &bit_est)) in tmp.iter_mut()
+ .zip(self.band_bits.iter().zip(ch_data.bit_est.iter())).skip(start) {
+ if band_bits != 0 {
+ *dst = f32::from(band_bits) * -2.0 + bit_est - 0.415 + 2.0;
}
}
while free_bits < cur_bits {
let mut low = BITALLOC_TOP_LIMIT;
let mut idx = 0;
- for band in 0..BANDS {
- if tmp[band] < low {
- low = tmp[band];
+ for (band, &level) in tmp.iter().enumerate() {
+ if level < low {
+ low = level;
idx = band;
}
}
fn adjust_bit_allocation(&mut self, ch_data: &mut IMCChannel, free_bits: i32) {
let mut tmp: [f32; BANDS] = [BITALLOC_LIMIT; BANDS];
- for band in 0..BANDS {
- if self.band_bits[band] != 6 {
- tmp[band] = f32::from(self.band_bits[band]) * -2.0 + ch_data.bit_est[band] - 0.415;
+ for (dst, (&band_bits, &bit_est)) in tmp.iter_mut()
+ .zip(self.band_bits.iter().zip(ch_data.bit_est.iter())) {
+ if band_bits != 6 {
+ *dst = f32::from(band_bits) * -2.0 + bit_est - 0.415;
}
}
let mut used_bits: i32 = 0;
while (peak > BITALLOC_LIMIT) && (used_bits < free_bits) {
peak = BITALLOC_LIMIT;
let mut idx: Option<usize> = None;
- for band in 0..BANDS {
- if tmp[band] > peak {
- peak = tmp[band];
+ for (band, &level) in tmp.iter().enumerate() {
+ if level > peak {
+ peak = level;
idx = Some(band);
}
}
impl LUTs {
fn new() -> Self {
let mut exp_lev: [f32; 16] = [0.0; 16];
- for lev in 0..16 {
- exp_lev[lev] = 10.0f32.powf(-(lev as f32) * 0.4375);
+ for (lev, el) in exp_lev.iter_mut().enumerate() {
+ *el = 10.0f32.powf(-(lev as f32) * 0.4375);
}
let mut exp_10: [f32; 32] = [0.0; 32];
- for i in 0..32 {
- exp_10[i] = 10.0f32.powf(((i as f32) - 16.0) * 0.25);
+ for (i, el) in exp_10.iter_mut().enumerate() {
+ *el = 10.0f32.powf(((i as f32) - 16.0) * 0.25);
}
let mut sqrt_tab: [f32; 32] = [0.0; 32];
- for i in 0..32 {
- sqrt_tab[i] = (i as f32).sqrt();
+ for (i, el) in sqrt_tab.iter_mut().enumerate() {
+ *el = (i as f32).sqrt();
}
LUTs { exp_lev, exp_10, sqrt_tab }
freq_min[band] = tmp_freq;
}
- for band in 0..BANDS {
+ for (dst, &freq_max) in self.cycle1.iter_mut().zip(freq_max.iter()) {
let mut s_band = BANDS - 1;
- while s_band > 0 && freq_max[band] <= freq_mid[s_band] { s_band -= 1; }
- self.cycle1[band] = s_band + 1;
+ while s_band > 0 && freq_max <= freq_mid[s_band] { s_band -= 1; }
+ *dst = s_band + 1;
}
self.cycle2[0] = 0;
- for band in 1..BANDS {
+ for (dst, &freq_min) in self.cycle2.iter_mut().zip(freq_min.iter()).skip(1) {
let mut s_band = 0;
- while s_band < BANDS-1 && freq_min[band] >= freq_mid[s_band] { s_band += 1; }
- self.cycle2[band] = s_band - 1;
+ while s_band < BANDS-1 && freq_min >= freq_mid[s_band] { s_band += 1; }
+ *dst = s_band - 1;
}
}
let mut tmp2: [f32; BANDS+1] = [0.0; BANDS+1];
let mut tmp3: [f32; BANDS] = [0.0; BANDS];
- for band in 0..BANDS {
+ for (band, dst) in tmp3.iter_mut().enumerate() {
ch_data.mask_wght[band] = 0.0;
let val;
if self.ba.band_width[band] > 0 {
ch_data.log_floor2[band] = -30000.0;
}
let tmp = val * (self.ba.band_width[band] as f64) * 0.01;
- if val <= 1.0e-30 { tmp3[band] = 0.0; }
- else { tmp3[band] = tmp as f32; }
+ *dst = if val <= 1.0e-30 { 0.0 } else { tmp as f32 };
}
- for band in 0..BANDS {
- let next_band = self.cycle1[band];
- for band2 in band..next_band {
- ch_data.mask_wght[band2] += tmp3[band];
+ for (band, (&next_band, &add_val)) in self.cycle1.iter().zip(tmp3.iter()).enumerate() {
+ for el in ch_data.mask_wght[band..next_band].iter_mut() {
+ *el += add_val;
}
- tmp2[next_band] += tmp3[band];
+ tmp2[next_band] += add_val;
}
let mut accum = 0.0;
- for band in 1..BANDS {
- accum = (tmp2[band] + accum) * self.weights1[band - 1];
- ch_data.mask_wght[band] += accum;
+ for (mask_weight, (&val, &weight)) in ch_data.mask_wght[1..].iter_mut()
+ .zip(tmp2[1..].iter().zip(self.weights1.iter())) {
+ accum = (accum + val) * weight;
+ *mask_weight += accum;
}
let mut tmp2: [f32; BANDS] = [0.0; BANDS];
tmp2[0] = tmp3[0];
- for band in 1..BANDS {
- let prev_band = self.cycle2[band];
+ for (band, &prev_band) in self.cycle2.iter().enumerate().skip(1) {
for band2 in prev_band+1..band {
ch_data.mask_wght[band2] += tmp3[band];
}
} else {
start = 0;
}
- for i in start..BANDS {
- level[i] = br.read_cb(&self.codes[sel_idx][IMC_CB_SELECTOR[sel_idx][i]])? as i8;
- if level[i] == 17 {
- level[i] += br.read(4)? as i8;
+ for (i, (level, &code_idx)) in level.iter_mut()
+ .zip(IMC_CB_SELECTOR[sel_idx].iter()).enumerate().skip(start) {
+ *level = br.read_cb(&self.codes[sel_idx][code_idx])? as i8;
+ if *level == 17 {
+ *level += br.read(4)? as i8;
}
- self.ba.keep_flag[i] = level[i] == 16;
+ self.ba.keep_flag[i] = *level == 16;
}
if reset {
let ch_data = &mut self.ch_data[ch];
let (mut c1, mut c2) = calc_maxcoef(f32::from(level[0]));
ch_data.new_floor[0] = c1;
ch_data.log_floor[0] = c2;
- for i in 1..BANDS {
- if level[i] == 16 {
+ for (i, &level) in level.iter().enumerate().skip(1) {
+ if level == 16 {
ch_data.new_floor[i] = 1.0;
ch_data.log_floor[i] = 0.0;
} else {
- let lval;
- if level[i] < 17 {
- lval = level[i] - 7;
- } else if level[i] < 25 {
- lval = level[i] - 32;
- } else {
- lval = level[i] - 16;
- }
+ let lval = if level < 17 {
+ level - 7
+ } else if level < 25 {
+ level - 32
+ } else {
+ level - 16
+ };
c1 *= self.luts.exp_10[(lval + 16) as usize];
c2 += 0.83048 * f32::from(lval);
ch_data.new_floor[i] = c1;
}
} else {
let ch_data = &mut self.ch_data[ch];
- for i in 0..BANDS {
- if level[i] < 16 {
- let lval = level[i] - 7;
+ for (i, &level) in level.iter().enumerate() {
+ if level < 16 {
+ let lval = level - 7;
ch_data.new_floor[i] = self.luts.exp_10[(lval + 16) as usize] * ch_data.old_floor[i];
ch_data.log_floor[i] += f32::from(lval) * 0.83048;
} else {
ba.skip_flag[i] = true;
ba.skip_flag[i + 1] = true;
ba.skips_per_band[band] += 2;
+ } else if br.read_bool()? {
+ ba.skip_flag_bits[band] += 2;
+ ba.skip_flag[i] = false;
+ ba.skip_flag[i + 1] = true;
+ ba.skips_per_band[band] += 1;
} else {
- if br.read_bool()? {
- ba.skip_flag_bits[band] += 2;
- ba.skip_flag[i] = false;
- ba.skip_flag[i + 1] = true;
+ ba.skip_flag_bits[band] += 3;
+ if !br.read_bool()? {
+ ba.skip_flag[i] = true;
ba.skips_per_band[band] += 1;
} else {
- ba.skip_flag_bits[band] += 3;
- if !br.read_bool()? {
- ba.skip_flag[i] = true;
- ba.skips_per_band[band] += 1;
- } else {
- ba.skip_flag[i] = false;
- }
- ba.skip_flag[i + 1] = false;
+ ba.skip_flag[i] = false;
}
+ ba.skip_flag[i + 1] = false;
}
i += 2;
}
}
}
+ #[allow(clippy::collapsible_else_if)]
fn decode_block(&mut self, data: &[u8], ch: usize, dst: &mut [f32]) -> DecoderResult<()> {
let mut br = BitReader::new(&data[BLOCK_SIZE*ch..][..BLOCK_SIZE], BitReaderMode::LE16MSB);
let hdr = br.read(9)?;
self.ba.cw_len[i] = 5;
}
for band in 1..4 {
- let bits: u8;
- if raw_coeffs || !self.ba.keep_flag[band]{
- bits = 5;
- } else {
- bits = 0;
- }
+ let bits = if raw_coeffs || !self.ba.keep_flag[band] { 5 } else { 0 };
self.ba.band_bits[band] = bits;
for i in IMC_BANDS[band]..IMC_BANDS[band + 1] {
self.ba.cw_len[i] = bits;
frmmgr: HAMShuffler<u8>,
}
+#[allow(clippy::identity_op)]
impl Indeo2Decoder {
fn new() -> Self {
let dummy_info = NACodecInfo::new_dummy();
cell2.depth += 1;
(cell1, cell2)
}
+ #[allow(clippy::collapsible_else_if)]
fn split_v(&self, stripw: u8) -> (Self, Self) {
let w1 = if self.width > stripw {
if self.width > stripw * 2 { stripw * 2 } else { stripw }
Err(DecoderError::InvalidData)
}
}
+ #[allow(clippy::manual_range_contains)]
fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let src = pkt.get_buffer();
let mut mr = MemoryReader::new_read(&src);
cell2.h = h2;
(cell1, cell2)
}
+ #[allow(clippy::collapsible_else_if)]
fn split_v(&self, stripw: u8) -> (Self, Self) {
let w1 = if self.w > stripw {
if self.w > stripw * 2 { stripw * 2 } else { stripw }
}
impl IndeoXParser for Indeo4Parser {
-#[allow(unused_variables,unused_assignments)]
fn decode_picture_header(&mut self, br: &mut BitReader) -> DecoderResult<PictureHeader> {
let sync = br.read(18)?;
validate!(sync == 0x3FFF8);
let ftype = INDEO4_FRAME_TYPE[ftype_idx as usize];
let transparent = br.read_bool()?;
br.skip(1)?;
- let data_size;
- if br.read_bool()? {
- data_size = br.read(24)? as usize;
- } else {
- data_size = 0;
- }
+ let _data_size = if br.read_bool()? { br.read(24)? as usize } else { 0 };
if ftype.is_null() {
return Ok(PictureHeader::new_null(ftype));
}
_ => { return Err(DecoderError::InvalidData); }
};
let chroma_bands = if sc_idx == 2 { 4 } else { 1 };
- let frame_no;
- if br.read_bool()? {
- frame_no = br.read(20)?;
- } else {
- frame_no = 0;
- }
+ let _frame_no = if br.read_bool()? { br.read(20)? } else { 0 };
if br.read_bool()? {
br.skip(8)?; // decTimeEst
}
self.mb_cb = br.read_ivi_codebook_desc(true, desc_coded)?;
let desc_coded = br.read_bool()?;
self.blk_cb = br.read_ivi_codebook_desc(false, desc_coded)?;
- let rvmap = if br.read_bool()? { br.read(3)? as usize } else { 8 };
- let in_imf = br.read_bool()?;
+ let _rvmap = if br.read_bool()? { br.read(3)? as usize } else { 8 };
+ let _in_imf = br.read_bool()?;
let in_q = br.read_bool()?;
- let glob_q = br.read(5)? as u8;
+ let _glob_q = br.read(5)? as u8;
if br.read_bool()? {
br.skip(3)?;
}
- let checksum = if br.read_bool()? { br.read(16)? } else { 0 };
+ let _checksum = if br.read_bool()? { br.read(16)? } else { 0 };
if br.read_bool()? {
br.skip(8)?; // pic hdr extension
}
Ok(PictureHeader::new(ftype, width, height, slice_w, slice_h, transparent, luma_bands, chroma_bands, in_q))
}
-#[allow(unused_variables,unused_assignments)]
+ #[allow(clippy::manual_range_contains)]
fn decode_band_header(&mut self, br: &mut BitReader, pic_hdr: &PictureHeader, plane: usize, band: usize) -> DecoderResult<BandHeader> {
let plane_no = br.read(2)? as usize;
let band_no = br.read(4)? as usize;
br.align();
return Ok(BandHeader::new_empty(plane_no, band_no));
}
- let hdr_size;
- if br.read_bool()? {
- hdr_size = br.read(16)? as usize;
- } else {
- hdr_size = 32;
- }
+ let _hdr_size = if br.read_bool()? { br.read(16)? as usize } else { 32 };
let mv_mode = br.read(2)?;
validate!(mv_mode < 2);
if br.read_bool()? {
txtype = TxType::None;
}
- let blk_cb;
- if br.read_bool()? {
- blk_cb = br.read_ivi_codebook_desc(false, true)?;
- } else {
- blk_cb = self.blk_cb;
- }
- let rvmap_idx;
- if br.read_bool()? {
- rvmap_idx = br.read(3)? as usize;
- } else {
- rvmap_idx = 8;
- }
+ let blk_cb = if br.read_bool()? {
+ br.read_ivi_codebook_desc(false, true)?
+ } else {
+ self.blk_cb
+ };
+ let rvmap_idx = if br.read_bool()? { br.read(3)? as usize } else { 8 };
let num_corr;
let mut corr_map: [u8; CORR_MAP_SIZE] = [0; CORR_MAP_SIZE];
if br.read_bool()? {
num_corr = br.read(8)? as usize;
validate!(num_corr*2 <= CORR_MAP_SIZE);
- for i in 0..num_corr*2 {
- corr_map[i] = br.read(8)? as u8;
+ for el in corr_map[..num_corr*2].iter_mut() {
+ *el = br.read(8)? as u8;
}
} else {
num_corr = 0;
} else {
return Err(DecoderError::MissingReference);
}
+ } else if !pic_hdr.ftype.is_bidir() {
+ mb.mtype = if br.read_bool()? { MBType::Inter } else { MBType::Intra };
} else {
- if !pic_hdr.ftype.is_bidir() {
- mb.mtype = if br.read_bool()? { MBType::Inter } else { MBType::Intra };
- } else {
- mb.mtype = match br.read(2)? {
- 0 => { MBType::Intra },
- 1 => { MBType::Inter },
- 2 => { MBType::Backward },
- _ => { MBType::Bidir },
- };
- }
+ mb.mtype = match br.read(2)? {
+ 0 => { MBType::Intra },
+ 1 => { MBType::Inter },
+ 2 => { MBType::Backward },
+ _ => { MBType::Bidir },
+ };
}
if band.mb_size == band.blk_size {
mb.cbp = br.read(1)? as u8;
}
impl IndeoXParser for Indeo5Parser {
-#[allow(unused_variables)]
-#[allow(unused_assignments)]
fn decode_picture_header(&mut self, br: &mut BitReader) -> DecoderResult<PictureHeader> {
let sync = br.read(5)?;
validate!(sync == 0x1F);
let ftype_idx = br.read(3)?;
validate!(ftype_idx < 5);
let ftype = INDEO5_FRAME_TYPE[ftype_idx as usize];
- let fnum = br.read(8)?;
+ let _fnum = br.read(8)?;
if ftype == IVIFrameType::Intra {
let gop_flags = br.read(8)?;
- let hdr_size;
- if (gop_flags & 0x01) != 0 {
- hdr_size = br.read(16)?;
- } else {
- hdr_size = 0;
- }
+ let _hdr_size = if (gop_flags & 0x01) != 0 { br.read(16)? } else { 0 };
if (gop_flags & 0x20) != 0 {
br.skip(32)?; // lock word
}
return Ok(PictureHeader::new_null(ftype));
}
let flags = br.read(8)?;
- let size;
- if (flags & 0x01) != 0 {
- size = br.read(24)?;
- } else {
- size = 0;
- }
- let checksum;
- if (flags & 0x10) != 0 {
- checksum = br.read(16)?;
- } else {
- checksum = 0;
- }
+ let _size = if (flags & 0x01) != 0 { br.read(24)? } else { 0 };
+ let _checksum = if (flags & 0x10) != 0 { br.read(16)? } else { 0 };
if (flags & 0x20) != 0 {
skip_extension(br)?;
}
Ok(PictureHeader::new(ftype, self.width, self.height, self.tile_w, self.tile_h, false, self.luma_bands, self.chroma_bands, in_q))
}
-#[allow(unused_variables)]
- fn decode_band_header(&mut self, br: &mut BitReader, pic_hdr: &PictureHeader, plane_no: usize, band_no: usize) -> DecoderResult<BandHeader> {
+ fn decode_band_header(&mut self, br: &mut BitReader, _pic_hdr: &PictureHeader, plane_no: usize, band_no: usize) -> DecoderResult<BandHeader> {
let band_flags = br.read(8)?;
if (band_flags & 0x01) != 0 {
if (band_flags & 0x10) != 0 {
num_corr = br.read(8)? as usize;
validate!(num_corr*2 <= CORR_MAP_SIZE);
- for i in 0..num_corr*2 {
- corr_map[i] = br.read(8)? as u8;
+ for el in corr_map[..num_corr*2].iter_mut() {
+ *el = br.read(8)? as u8;
}
} else {
num_corr = 0;
}
- let rvmap_idx;
- if (band_flags & 0x40) != 0 {
- rvmap_idx = br.read(3)? as usize;
- } else {
- rvmap_idx = 8;
- }
+ let rvmap_idx = if (band_flags & 0x40) != 0 { br.read(3)? as usize } else { 8 };
let blk_cb = br.read_ivi_codebook_desc(false, (band_flags & 0x80) != 0)?;
if br.read_bool()? {
br.skip(16)?; // checksum
}
#[allow(clippy::cognitive_complexity)]
+ #[allow(clippy::collapsible_else_if)]
fn decode_mb_info(&mut self, br: &mut BitReader, pic_hdr: &PictureHeader, band: &BandHeader, tile: &mut IVITile, ref_tile: Option<&IVITile>, mv_scale: u8) -> DecoderResult<()> {
let mut mv_x = 0;
let mut mv_y = 0;
Ok(())
}
+ #[allow(clippy::identity_op)]
fn recombine_plane(&mut self, src: &[i16], sstride: usize, dst: &mut [u8], dstride: usize, w: usize, h: usize) {
let mut idx0 = 0;
let mut idx1 = w / 2;
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>,
cbpy_cb: Codebook<u8>,
rl_cb: Codebook<H263RLSym>,
- aic_rl_cb: Codebook<H263RLSym>,
mv_cb: Codebook<u8>,
}
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;
}
#[allow(clippy::erasing_op)]
+#[allow(clippy::identity_op)]
fn idct_col(blk: &mut [i16; 64], off: usize) {
let in0 = ((i32::from(blk[off + 0*8])) << 8) + (1 << (COL_SHIFT - 1));
let in1 = (i32::from(blk[off + 4*8])) << 8;
];
#[allow(clippy::erasing_op)]
+#[allow(clippy::identity_op)]
fn deblock_hor(buf: &mut NAVideoBuffer<u8>, comp: usize, strength: u8, off: usize) {
let stride = buf.get_stride(comp);
let dptr = buf.get_data_mut().unwrap();
}
}
+#[allow(clippy::identity_op)]
fn deblock_ver(buf: &mut NAVideoBuffer<u8>, comp: usize, strength: u8, off: usize) {
let stride = buf.get_stride(comp);
let dptr = buf.get_data_mut().unwrap();
fn copy_blocks8x8(&self, dst: &mut NAVideoBuffer<u8>, src: NAVideoBufferRef<u8>, xpos: usize, ypos: usize, mvs: &[MV; 4]) {
let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap();
- for i in 0..4 {
+ for (i, mv) in mvs.iter().enumerate() {
let xadd = (i & 1) * 8;
let yadd = (i & 2) * 4;
- let mode = ((mvs[i].x & 1) + (mvs[i].y & 1) * 2) as usize;
+ let mode = ((mv.x & 1) + (mv.y & 1) * 2) as usize;
- blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mvs[i].x >> 1, mvs[i].y >> 1, 8, 8, 0, 1, mode, H263_INTERP_FUNCS);
+ blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mv.x >> 1, mv.y >> 1, 8, 8, 0, 1, mode, H263_INTERP_FUNCS);
}
let sum_mv = mvs[0] + mvs[1] + mvs[2] + mvs[3];
fn avg_blocks8x8(&self, dst: &mut NAVideoBuffer<u8>, src: NAVideoBufferRef<u8>, xpos: usize, ypos: usize, mvs: &[MV; 4]) {
let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap();
- for i in 0..4 {
+ for (i, mv) in mvs.iter().enumerate() {
let xadd = (i & 1) * 8;
let yadd = (i & 2) * 4;
- let mode = ((mvs[i].x & 1) + (mvs[i].y & 1) * 2) as usize;
+ let mode = ((mv.x & 1) + (mv.y & 1) * 2) as usize;
- blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mvs[i].x >> 1, mvs[i].y >> 1, 8, 8, 0, 1, mode, H263_INTERP_AVG_FUNCS);
+ blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mv.x >> 1, mv.y >> 1, 8, 8, 0, 1, mode, H263_INTERP_AVG_FUNCS);
}
let sum_mv = mvs[0] + mvs[1] + mvs[2] + mvs[3];
impl<'a> BlockDecoder for Intel263BR<'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)?;
//println!("GOB gn {:X} id {} q {}", gn, gfid, gquant);
let ret = SliceInfo::new_gob(0, self.gob_no, gquant as u8);
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<()> {
+ 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)
}
- #[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)
}
let cbpy_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
let mut coderead = H263RLCodeReader::new(H263_RL_CODES);
let rl_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
- let mut coderead = H263RLCodeReader::new(H263_RL_CODES_AIC);
- let aic_rl_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
let mut coderead = H263ShortCodeReader::new(H263_MV);
let mv_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
let tables = Tables {
inter_mcbpc_cb,
cbpy_cb,
rl_cb,
- aic_rl_cb,
mv_cb,
};
}
}
-#[allow(dead_code)]
#[derive(Clone)]
pub struct TxParams4x4 {
pub quant_intra: &'static [u16; 16],
}
}
-#[allow(dead_code)]
#[derive(Clone)]
pub struct TxParams8x8 {
pub quant_intra: &'static [u16; 64],
}
impl BandHeader {
+ #[allow(clippy::identity_op)]
pub fn new(plane_no: usize, band_no: usize, mb_size: usize, blk_size: usize, halfpel: bool, inherit_mv: bool, has_qdelta: bool, inherit_qd: bool, quant: u32, rvmap_idx: usize, num_corr: usize, corr_map: [u8; CORR_MAP_SIZE], blk_cb: IVICodebook, tr: IVITransformType, ttype: TxType) -> Self {
let mut rvmap = IVI_RVMAPS[rvmap_idx].clone();
for i in 0..num_corr {
IVICodebook { len: 9, bits: [ 3, 4, 4, 5, 5, 5, 6, 5, 5, 0, 0, 0, 0, 0, 0, 0 ], offs: [0; 16] }
];
-#[allow(unused_variables)]
#[allow(clippy::many_single_char_names)]
fn read_trans_band_header(br: &mut BitReader, w: usize, h: usize, dst: &mut [i16], dstride: usize) -> DecoderResult<()> {
- let color_plane = br.read(2)?;
- let bit_depth = br.read(3)?;
+ let _color_plane = br.read(2)?;
+ let _bit_depth = br.read(3)?;
let dirty_rects = br.read(8)? as usize;
- for i in 0..dirty_rects {
- let x = br.read(16)?;
- let y = br.read(16)?;
- let l = br.read(16)?;
- let r = br.read(16)?;
+ for _ in 0..dirty_rects {
+ let _x = br.read(16)?;
+ let _y = br.read(16)?;
+ let _l = br.read(16)?;
+ let _r = br.read(16)?;
}
let has_trans_color = br.read_bool()?;
if has_trans_color {
- let r = br.read(8)?;
- let g = br.read(8)?;
- let b = br.read(8)?;
+ let _r = br.read(8)?;
+ let _g = br.read(8)?;
+ let _b = br.read(8)?;
}
br.skip(1)?;
let first_val = br.read_bool()?;
- let mut dec_size = 0;
+ let mut _dec_size = 0;
let mut x = 0;
let mut y = 0;
let mut fill = if !first_val { 255-128 } else { 0-128 };
while br.tell() < tile_end {
let code = br.read_ivi_cb(&cb)? as usize;
if code == 0 {
- dec_size += 255;
+ _dec_size += 255;
for _ in 0..255 {
if (x < w) && (y < h) {
dst[x + y * dstride] = fill;
}
}
} else {
- dec_size += code;
+ _dec_size += code;
for _ in 0..code {
if (x < w) && (y < h) {
dst[x + y * dstride] = fill;
Ok(())
}
-#[allow(clippy::cast_lossless)]
+#[allow(clippy::collapsible_else_if)]
fn decode_block8x8(br: &mut BitReader, blk_cb: &IVICodebook, rvmap: &RVMap, tables: &TxParams8x8, is_intra: bool, is_2d: bool, prev_dc: &mut i32, quant: u8, coeffs: &mut [i32; 64], transform: TrFunc) -> DecoderResult<()> {
let mut idx: isize = -1;
let quant_mat = if is_intra { tables.quant_intra } else { tables.quant_inter };
(transform)(coeffs);
Ok(())
}
-#[allow(clippy::cast_lossless)]
+
+#[allow(clippy::collapsible_else_if)]
fn decode_block4x4(br: &mut BitReader, blk_cb: &IVICodebook, rvmap: &RVMap, tables: &TxParams4x4, is_intra: bool, is_2d: bool, prev_dc: &mut i32, quant: u8, coeffs: &mut [i32; 64], transform: TrFunc) -> DecoderResult<()> {
let mut idx: isize = -1;
let quant_mat = if is_intra { tables.quant_intra } else { tables.quant_inter };
validate!(tile_end <= br.tell() + (br.left() as usize));
{
let ref_tile: Option<&IVITile>;
- let mv_scale;
- if (plane_no == 0) && (band_no == 0) {
- mv_scale = 0;
- } else {
- mv_scale = (((self.bands[0].mb_size >> 3) as i8) - ((band.mb_size >> 3) as i8)) as u8;
- }
+ let mv_scale = if (plane_no == 0) && (band_no == 0) { 0 } else {
+ (((self.bands[0].mb_size >> 3) as i8) - ((band.mb_size >> 3) as i8)) as u8
+ };
let (ref_tiles, cur_tiles) = self.tiles.split_at_mut(tile_no);
let tile = &mut cur_tiles[0];
if plane_no != 0 || band_no != 0 {
} else {
{
let ref_tile: Option<&IVITile>;
- let mv_scale;
- if (plane_no == 0) && (band_no == 0) {
- mv_scale = 0;
- } else {
- mv_scale = (((self.bands[0].mb_size >> 3) as i8) - ((band.mb_size >> 3) as i8)) as u8;
- }
+ let mv_scale = if (plane_no == 0) && (band_no == 0) { 0 } else {
+ (((self.bands[0].mb_size >> 3) as i8) - ((band.mb_size >> 3) as i8)) as u8
+ };
let (ref_tiles, cur_tiles) = self.tiles.split_at_mut(tile_no);
let tile = &mut cur_tiles[0];
if plane_no != 0 || band_no != 0 {
br.align();
Ok(())
}
+ #[allow(clippy::collapsible_else_if)]
fn decode_tile(&mut self, br: &mut BitReader, band: &BandHeader, tile_no: usize, tr: TrFunc, transform_dc: TrFuncDC) -> DecoderResult<()> {
let mut mb_idx = 0;
let mut prev_dc: i32 = 0;
let boff = (blk_no & 1) * band.blk_size + (blk_no >> 1) * band.blk_size * stride + mb_x * band.mb_size;
if !is_intra {
if mb.mtype != MBType::Bidir {
- let idx;
- if mb.mtype != MBType::Backward {
- idx = self.prev_frame;
- } else {
- idx = self.next_frame;
- }
+ let idx = if mb.mtype != MBType::Backward { self.prev_frame } else { self.next_frame };
let pf = &self.frames[idx];
do_mc(&mut dst[dstidx + boff..], stride,
&pf.plane_buf[band.plane_no], pf.plane_stride[band.plane_no],
let mut blk: [i32; 64] = [0; 64];
if !is_intra {
if mb.mtype != MBType::Bidir {
- let idx;
- if mb.mtype != MBType::Backward {
- idx = self.prev_frame;
- } else {
- idx = self.next_frame;
- }
+ let idx = if mb.mtype != MBType::Backward { self.prev_frame } else { self.next_frame };
let pf = &self.frames[idx];
do_mc(&mut dst[dstidx + mb_x * band.blk_size..], stride,
&pf.plane_buf[band.plane_no], pf.plane_stride[band.plane_no],
}
validate!((br.tell() & 31) == 0);
- for plane in 0..3 {
- for band in 0..num_bands[plane] {
- if bands_decoded[plane][band] || br.left() == 0 {
+ for (plane, &nbands) in num_bands.iter().enumerate() {
+ for (band, band_decoded) in bands_decoded[plane][..nbands].iter_mut().enumerate() {
+ if *band_decoded || br.left() == 0 {
continue;
}
self.decode_band(&pic_hdr, dec, br, plane, band)?;
- bands_decoded[plane][band] = true;
+ *band_decoded = true;
num_decoded += 1;
}
}
}
if let NABufferType::Video(ref mut vb) = buftype {
- for plane in 0..3 {
+ for (plane, &nbands) in num_bands.iter().enumerate() {
let mut frame = self.frames[self.cur_frame].clone();
- if num_bands[plane] == 1 {
+ if nbands == 1 {
frame.fill_plane(vb, plane);
} else {
let dplane = if (plane == 1) || (plane == 2) { plane ^ 3 } else { plane };
}
fn haar8x8_dc(blk: &mut[i32; 64], in0: i32) {
let dc = in0 >> 3;
- for i in 0..64 { blk[i] = dc; }
+ for el in blk.iter_mut() { *el = dc; }
}
fn haar4x4_2d(blk: &mut[i32; 64]) {
}
fn haar4x4_dc(blk: &mut[i32; 64], in0: i32) {
let dc = in0 >> 3;
- for i in 0..16 { blk[i] = dc; }
+ for el in blk[..16].iter_mut() { *el = dc; }
}
fn slant8x8_2d(blk: &mut[i32; 64]) {
}
fn slant8x8_2d_dc(blk: &mut[i32; 64], in0: i32) {
let dc = (in0 + 1) >> 1;
- for i in 0..64 { blk[i] = dc; }
+ for el in blk.iter_mut() { *el = dc; }
}
fn slant8x8_row(blk: &mut[i32; 64]) {
let pass = |x: i32| (x + 1) >> 1;
fn slant8x8_row_dc(blk: &mut[i32; 64], in0: i32) {
let dc = (in0 + 1) >> 1;
- for i in 0..8 { blk[i] = dc; }
- for i in 8..64 { blk[i] = 0; }
+ for el in blk[0..8].iter_mut() { *el = dc; }
+ for el in blk[8..].iter_mut() { *el = 0; }
}
fn slant8x8_col(blk: &mut[i32; 64]) {
let pass = |x: i32| (x + 1) >> 1;
}
fn slant4x4_2d_dc(blk: &mut[i32; 64], in0: i32) {
let dc = (in0 + 1) >> 1;
- for i in 0..16 { blk[i] = dc; }
+ for el in blk[..16].iter_mut() { *el = dc; }
}
fn slant4x4_row(blk: &mut[i32; 64]) {
let pass = |x: i32| (x + 1) >> 1;
fn slant4x4_row_dc(blk: &mut[i32; 64], in0: i32) {
let dc = (in0 + 1) >> 1;
- for i in 0..4 { blk[i] = dc; }
- for i in 4..16 { blk[i] = 0; }
+ for el in blk[0..4].iter_mut() { *el = dc; }
+ for el in blk[4..16].iter_mut() { *el = 0; }
}
fn slant4x4_col(blk: &mut[i32; 64]) {
let pass = |x: i32| (x + 1) >> 1;
}
}
-#[allow(unused_variables)]
-fn none8x8(blk: &mut[i32; 64]) {
+fn none8x8(_blk: &mut[i32; 64]) {
}
fn none8x8_dc(blk: &mut[i32; 64], dc: i32) {
- for i in 1..8 { blk[i] = dc; }
- for i in 8..64 { blk[i] = 0; }
+ for el in blk[1..8].iter_mut() { *el = dc; }
+ for el in blk[8..].iter_mut() { *el = 0; }
}
-#[allow(unused_variables)]
-fn none4x4(blk: &mut[i32; 64]) {
+fn none4x4(_blk: &mut[i32; 64]) {
}
fn none4x4_dc(blk: &mut[i32; 64], dc: i32) {
- for i in 1..4 { blk[i] = dc; }
- for i in 4..16 { blk[i] = 0; }
+ for el in blk[1..4].iter_mut() { *el = dc; }
+ for el in blk[4..16].iter_mut() { *el = 0; }
}
pub fn ivi_get_transform8x8_funcs(ttype: IVITransformType) -> (TrFunc, TrFuncDC) {
mod indeo5;
#[cfg(any(feature="decoder_indeo4", feature="decoder_indeo5"))]
+#[allow(clippy::too_many_arguments)]
mod ivi;
#[cfg(any(feature="decoder_indeo4", feature="decoder_indeo5"))]
+#[allow(clippy::too_many_arguments)]
mod ivibr;
#[cfg(any(feature="decoder_indeo4", feature="decoder_indeo5"))]
#[allow(clippy::erasing_op)]
+#[allow(clippy::identity_op)]
+#[allow(clippy::too_many_arguments)]
mod ividsp;
#[cfg(feature="decoder_imc")]
#[allow(clippy::excessive_precision)]
-#[allow(clippy::unreadable_literal)]
mod imc;
const INDEO_CODECS: &[DecoderInfo] = &[
extern crate nihav_core;
extern crate nihav_codec_support;
-#[allow(clippy::collapsible_if)]
-#[allow(clippy::collapsible_else_if)]
-#[allow(clippy::identity_op)]
-#[allow(clippy::needless_range_loop)]
-#[allow(clippy::needless_late_init)]
-#[allow(clippy::too_many_arguments)]
-#[allow(clippy::useless_let_if_seq)]
-#[allow(clippy::verbose_bit_mask)]
#[allow(clippy::upper_case_acronyms)]
-#[allow(clippy::manual_range_contains)]
mod codecs;
pub use crate::codecs::indeo_register_all_decoders;