is_intra: false,
}
}
+ #[allow(clippy::identity_op)]
fn decode_frame(&mut self, br: &mut ByteReader) -> DecoderResult<()> {
let mut idx = 0;
loop {
}
}
+#[allow(clippy::identity_op)]
fn decode_block(mode: u8, src: &[u8], dst: &mut [i16], mut pred: i16) -> i16 {
let steps = &BMV_AUDIO_STEPS[mode as usize];
let mut val2 = 0;
let mut sidx = PREAMBLE_SIZE;
let mut didx = 0;
- for i in 0..768 { dst[paloff + i] = self.pal[i]; }
+ dst[paloff..][..768].copy_from_slice(&self.pal);
if !self.scale_v && !self.scale_h {
for _ in 0..h {
- for x in 0..w { dst[didx + x] = self.frame[sidx + x]; }
+ dst[didx..][..w].copy_from_slice(&self.frame[sidx..][..w]);
sidx += w;
didx += stride;
}
} else {
for y in 0..h {
if !self.scale_v {
- for x in 0..w { dst[didx + x] = self.frame[sidx + x]; }
+ dst[didx..][..w].copy_from_slice(&self.frame[sidx..][..w]);
} else {
for x in 0..w { dst[didx + x] = self.frame[sidx + x/2]; }
}
Ok(())
}
+ #[allow(clippy::identity_op)]
fn decode_method68(&mut self, br: &mut ByteReader,
skip: usize, use8: bool) -> DecoderResult<()> {
let mut bits = Bits32::new();
}
Ok(())
}
+ #[allow(clippy::identity_op)]
fn unpack_samples(&mut self, br: &mut BitReader) -> DecoderResult<()> {
for grp in 0..3 {
for gr in 0..4 {
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(), 1, SND_F32P_FORMAT, CODEC_SAMPLES);
- self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo.clone()));
+ self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo));
self.chmap = NAChannelMap::from_str("C").unwrap();
Ok(())
} else {
let mut dpos = 0;
let end = src.len();
while spos < end {
- let oplo = src[spos] as u16;
+ let oplo = u16::from(src[spos]);
spos += 1;
if spos >= end { return Err(DecoderError::ShortData); }
- let ophi = src[spos] as u16;
+ let ophi = u16::from(src[spos]);
spos += 1;
let mut op = (ophi << 8) | oplo;
for _ in 0..16 {
Ok(())
}
+#[allow(clippy::identity_op)]
fn decode_frame(frm: &mut NASimpleVideoFrame<u8>, src: &[u8], width: usize, height: usize) -> DecoderResult<bool> {
validate!(src.len() > 8);
let num_vec = read_u16le(&src[0..])? as usize;
}
fn dequant(val: i16, q: i16) -> i32 {
- (val as i32) * (q as i32)
+ i32::from(val) * i32::from(q)
}
fn scale_coef(val: i32, scale: i16) -> i32 {
- ((val as i32) * (scale as i32)) >> 8
+ (val * i32::from(scale)) >> 8
}
macro_rules! idct_1d {
}
}
+#[allow(clippy::erasing_op)]
+#[allow(clippy::identity_op)]
fn idct(blk: &mut [i32; 64]) {
for i in 0..8 {
idct_1d!(blk[i + 0 * 8], blk[i + 1 * 8], blk[i + 2 * 8], blk[i + 3 * 8],
idct_1d!(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7]);
}
for el in blk.iter_mut() {
- *el = *el >> 5;
+ *el >>= 5;
}
}
let dc = dequant(coeffs[0], qmat[0]) >> 5;
for line in dst.chunks_mut(stride).take(8) {
for el in line.iter_mut().take(8) {
- *el = ((*el as i32) + dc).max(0).min(255) as u8;
+ *el = (i32::from(*el) + dc).max(0).min(255) as u8;
}
}
},
idct(&mut blk);
for (line, row) in dst.chunks_mut(stride).zip(blk.chunks(8)).take(8) {
for (dst, coef) in line.iter_mut().zip(row.iter()).take(8) {
- *dst = (*dst as i32 + *coef).max(0).min(255) as u8;
+ *dst = (i32::from(*dst) + *coef).max(0).min(255) as u8;
}
}
},
idct(&mut blk);
for (line, row) in dst.chunks_mut(stride).zip(blk.chunks(8)).take(8) {
for (dst, coef) in line.iter_mut().zip(row.iter()).take(8) {
- *dst = (*dst as i32 + *coef).max(0).min(255) as u8;
+ *dst = (i32::from(*dst) + *coef).max(0).min(255) as u8;
}
}
},
fn init_quant(qmat: &mut [i16; 64], base_qmat: &[u8; 64], quant: u8) {
let q = if quant < 50 {
- 5000 / (quant.max(1) as i32)
+ 5000 / i32::from(quant.max(1))
} else {
- ((100 - quant.min(100)) * 2) as i32
+ i32::from((100 - quant.min(100)) * 2)
};
for (inq, (outq, scale)) in base_qmat.iter().zip(qmat.iter_mut().zip(QUANT_MATRIX.iter())) {
- let val = (((*inq as i32) * q + 50) / 100).max(1).min(0x7FFF);
- *outq = ((val * (*scale as i32) + 0x800) >> 12) as i16;
+ let val = ((i32::from(*inq) * q + 50) / 100).max(1).min(0x7FFF);
+ *outq = ((val * i32::from(*scale) + 0x800) >> 12) as i16;
}
}
let edata = info.get_extradata();
let flags = if let Some(ref buf) = edata {
validate!(buf.len() >= 2);
- (buf[0] as u16) | ((buf[1] as u16) << 8)
+ u16::from(buf[0]) | (u16::from(buf[1]) << 8)
} else {
0
};
}
};
self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(), ainfo.get_channels(), fmt, ainfo.get_block_len());
- self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo.clone()));
+ self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo));
self.chmap = NAChannelMap::from_str(if channels == 1 { "C" } else { "L,R" }).unwrap();
Ok(())
} else {
Err(DecoderError::InvalidData)
}
}
+ #[allow(clippy::identity_op)]
+ #[allow(clippy::cyclomatic_complexity)]
fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
impl<'a> DemuxCore<'a> for BMV3Demuxer<'a> {
#[allow(unused_variables)]
+ #[allow(clippy::cast_lossless)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_index: &mut SeekIndex) -> DemuxerResult<()> {
let src = &mut self.src;
let is_video = cur_frame.chtype == CHTYPE_VIDEO;
let mut buf: Vec<u8> = Vec::with_capacity(FRAME_HDR_SIZE + (cur_frame.size as usize));
- if !(is_video && self.is_indeo) && !(!is_video && self.is_lhaud) {
+ if !((is_video && self.is_indeo) || (!is_video && self.is_lhaud)) {
buf.extend_from_slice(&cur_frame.hdr);
buf.resize(FRAME_HDR_SIZE + (cur_frame.size as usize), 0);
self.src.read_buf(&mut buf[FRAME_HDR_SIZE..])?;
extern crate nihav_core;
extern crate nihav_codec_support;
+#[allow(clippy::collapsible_if)]
+#[allow(clippy::excessive_precision)]
+#[allow(clippy::needless_range_loop)]
+#[allow(clippy::unreadable_literal)]
+#[allow(clippy::useless_let_if_seq)]
mod codecs;
pub use crate::codecs::game_register_all_codecs;
+#[allow(clippy::collapsible_if)]
+#[allow(clippy::needless_range_loop)]
+#[allow(clippy::unreadable_literal)]
mod demuxers;
-pub use crate::demuxers::game_register_all_demuxers;
\ No newline at end of file
+pub use crate::demuxers::game_register_all_demuxers;