tmp: [0.0; 2048], ew_buf: [0.0; 1152],
}
}
+ #[allow(clippy::cyclomatic_complexity)]
fn synth(&mut self, coeffs: &[f32; 1024], delay: &mut [f32; 1024], seq: u8, window_shape: bool, prev_window_shape: bool, dst: &mut [f32]) {
let long_win = if window_shape { &self.kbd_long_win } else { &self.sine_long_win };
let short_win = if window_shape { &self.kbd_short_win } else { &self.sine_short_win };
tmp: [f32; ATRAC3_FRAME_SIZE + 64],
}
+#[allow(clippy::manual_memcpy)]
impl DSP {
fn new() -> Self {
let mut gain_tab: [f32; 16] = [0.0; 16];
}
impl CodebookDescReader<u8> for Atrac3CodebookReader {
fn bits(&mut self, idx: usize) -> u8 { self.bits[idx] }
- fn code(&mut self, idx: usize) -> u32 { self.codes[idx] as u32 }
+ fn code(&mut self, idx: usize) -> u32 { u32::from(self.codes[idx]) }
fn sym (&mut self, idx: usize) -> u8 { idx as u8 }
fn len(&mut self) -> usize { self.bits.len() }
}
scalefactors,
}
}
+ #[allow(clippy::identity_op)]
fn rev_matrix(&mut self) {
for i in 0..4 {
let c0 = self.mci_prev[i];
MedianCut,
}
-impl QuantMode {
+impl std::string::ToString for QuantMode {
fn to_string(&self) -> String {
match *self {
QuantMode::ELBG => "elbg".to_string(),
for _ in (start..end).step_by(4) {
for x in (0..width).step_by(4) {
if cur_bit == 0 {
- if !intra || self.v1_idx.len() > 0 {
+ if !intra || !self.v1_idx.is_empty() {
cur_mask = *miter.next().unwrap();
} else {
cur_mask = 0xFFFFFFFF;
self.render_stripe(true, start_line, end_line);
- if self.v4_idx.len() == 0 {
+ if self.v4_idx.is_empty() {
bw.write_byte(0x32)?;
bw.write_u24be((self.v1_idx.len() + 4) as u32)?;
bw.write_buf(self.v1_idx.as_slice())?;
ofmt.format = NACodecTypeInfo::Video(NAVideoInfo::new(0, 0, true, YUV420_FORMAT));
Ok(ofmt)
},
- NACodecTypeInfo::Audio(_) => return Err(EncoderError::FormatError),
+ NACodecTypeInfo::Audio(_) => Err(EncoderError::FormatError),
NACodecTypeInfo::Video(vinfo) => {
let pix_fmt = if vinfo.format == GRAY_FORMAT { GRAY_FORMAT } else { YUV420_FORMAT };
let outinfo = NAVideoInfo::new((vinfo.width + 3) & !3, (vinfo.height + 3) & !3, true, pix_fmt);
}
let out_info = NAVideoInfo::new(vinfo.width, vinfo.height, false, vinfo.format);
- let info = NACodecInfo::new("cinepak", NACodecTypeInfo::Video(out_info.clone()), None);
+ let info = NACodecInfo::new("cinepak", NACodecTypeInfo::Video(out_info), None);
let mut stream = NAStream::new(StreamType::Video, stream_id, info, encinfo.tb_num, encinfo.tb_den);
stream.set_num(stream_id as usize);
let stream = stream.into_ref();
}
impl NADecoder for ClearVideoDecoder {
+ #[allow(clippy::or_fun_call)]
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
let w = vinfo.get_width();
mod clearvideo;
#[cfg(feature="decoder_aac")]
+#[allow(clippy::manual_memcpy)]
+#[allow(clippy::useless_let_if_seq)]
mod aac;
#[cfg(feature="decoder_atrac3")]
+#[allow(clippy::identity_op)]
+#[allow(clippy::useless_let_if_seq)]
mod atrac3;
#[cfg(any(feature="decoder_pcm",feature="encoder_pcm"))]
mod pcm;
#[cfg(feature="decoder_sipro")]
+#[allow(clippy::collapsible_if)]
+#[allow(clippy::identity_op)]
+#[allow(clippy::manual_memcpy)]
mod sipro;
#[cfg(feature="decoder_ts102366")]
mod ts102366;
ofmt.format = NACodecTypeInfo::Audio(NAAudioInfo::new(0, 0, SND_S16P_FORMAT, 0));
Ok(ofmt)
},
- NACodecTypeInfo::Video(_) => return Err(EncoderError::FormatError),
+ NACodecTypeInfo::Video(_) => Err(EncoderError::FormatError),
NACodecTypeInfo::Audio(_) => {
Ok(*encinfo)
}
newfilt[i] = filter[i] + 0.33 * self.lsf_hist[i] + SIPRO_MEAN_LSF_LBR[i];
}
for i in 0..8 { // maybe it's just bubble sort?
- for j in (0..i+1).rev() {
+ for j in (0..=i).rev() {
if newfilt[j] <= newfilt[j + 1] { break; }
- let tmp = newfilt[j];
- newfilt[j] = newfilt[j + 1];
- newfilt[j + 1] = tmp;
+ newfilt.swap(j, j + 1);
}
}
self.fix_vec = [0.0; 80];
let pitch_frac = SIPRO_GAIN_PITCH_CB_16K[self.gp_index[sf]].min(1.0);
for i in 0..10 {
- let mut scale = self.pulse_data[i * 2 + 1] as f32;
+ let mut scale = f32::from(self.pulse_data[i * 2 + 1]);
let off = self.pulse_data[i * 2 + 0] as usize;
for j in (off..80).step_by(self.prev_pitch) {
self.fix_vec[j] += scale;
}
self.unpack_pulses_common();
}
+ #[allow(clippy::cast_lossless)]
fn unpack_pulses_common(&mut self) {
for i in 0..48 {
self.fix_vec[i] = 0.0;
poly[1] = -2.0 * f64::from(lsp[0]);
for i in 1..order {
poly[i + 1] = -2.0 * f64::from(lsp[2 * i]) * poly[i] + 2.0 * poly[i - 1];
- for j in (2..i+1).rev() {
+ for j in (2..=i).rev() {
poly[j] += -2.0 * f64::from(lsp[2 * i]) * poly[j - 1] + poly[j - 2];
}
poly[1] += -2.0 * f64::from(lsp[2 * i]);
bap_buf_fill: [0; 3],
}
}
+ #[allow(clippy::cyclomatic_complexity)]
fn read(&mut self, br: &mut BitReader, bsi: &BSI, fscod: usize, blk_no: usize) -> DecoderResult<bool> {
let channels = bsi.acmod.get_num_channels();
let is_stereo = bsi.acmod == ACMode::Stereo;
let soniton = NASoniton::new(bits_per_sample as u8, SONITON_FLAG_SIGNED);
let ahdr = NAAudioInfo::new(samplespersec, channels as u8, soniton, block_align as usize);
- let edata;
- if size > 16 {
- let edata_size = dmx.src.read_u16le()? as usize;
- validate!(edata_size + 18 == size);
- edata = dmx.read_extradata(size - 18)?;
- } else {
- edata = None;
- }
+ let edata = if size > 16 {
+ let edata_size = dmx.src.read_u16le()? as usize;
+ validate!(edata_size + 18 == size);
+ dmx.read_extradata(size - 18)?
+ } else {
+ None
+ };
let cname = match register::find_codec_from_wav_twocc(w_format_tag) {
None => "unknown",
Some(name) => name,
Ok(size)
}
+#[allow(clippy::verbose_bit_mask)]
fn parse_idx1(src: &mut ByteReader, strmgr: &mut StreamManager, seek_idx: &mut SeekIndex, size: usize, movi_pos: u64, key_offs: &mut Vec<u64>) -> DemuxerResult<usize> {
validate!((size & 15) == 0);
let mut tag = [0u8; 4];
#[allow(clippy::cast_lossless)]
mod avi;
#[cfg(feature="demuxer_mov")]
+#[allow(clippy::cast_lossless)]
mod mov;
#[cfg(feature="demuxer_wav")]
mod wav;
let _flags = br.read_u24be()?;
let entries = br.read_u32be()?;
validate!(entries > 0);
- let esize = br.read_u32be()? as u64;
+ let esize = u64::from(br.read_u32be()?);
validate!(esize + 8 <= size);
let mut fcc = [0u8; 4];
br.read_buf(&mut fcc)?;
let format = if depth > 8 { RGB24_FORMAT } else { PAL8_FORMAT };
let mut vhdr = NAVideoInfo::new(width, height, false, format);
vhdr.bits = depth as u8;
- let edata;
- if br.tell() - start_pos + 4 < size {
+ let edata = if br.tell() - start_pos + 4 < size {
//todo skip various common atoms
- let edata_size = br.read_u32be()? as usize;
- let mut buf = vec![0; edata_size];
+ let edata_size = br.read_u32be()? as usize;
+ let mut buf = vec![0; edata_size];
br.read_buf(buf.as_mut_slice())?;
- edata = Some(buf);
- } else {
- edata = None;
- }
+ Some(buf)
+ } else {
+ None
+ };
codec_info = NACodecInfo::new(cname, NACodecTypeInfo::Video(vhdr), edata);
},
StreamType::Audio => {
read_chunk_list!(track; "minf", read_minf, MINF_CHUNK_HANDLERS);
read_chunk_list!(track; "stbl", read_stbl, STBL_CHUNK_HANDLERS);
fn fill_seek_index(&self, seek_index: &mut SeekIndex) {
- if self.keyframes.len() > 0 {
+ if !self.keyframes.is_empty() {
seek_index.mode = SeekIndexMode::Present;
}
for kf_time in self.keyframes.iter() {
}
}
fn get_size(&self, sample_no: usize) -> usize {
- if self.chunk_sizes.len() > 0 {
+ if !self.chunk_sizes.is_empty() {
self.chunk_sizes[sample_no] as usize
- } else if self.sample_map.len() > 0 {
+ } else if !self.sample_map.is_empty() {
let mut nsamp = 0;
for (idx, samples) in self.sample_map.iter() {
if *idx as usize <= self.cur_chunk {
self.samples_left = 0;
if self.stream_type == StreamType::Audio {
self.cur_chunk = self.cur_sample;
- } else if self.chunk_offsets.len() != self.chunk_sizes.len() && self.sample_map.len() > 0{
+ } else if self.chunk_offsets.len() != self.chunk_sizes.len() && !self.sample_map.is_empty() {
let mut csamp = 0;
self.cur_chunk = 0;
let mut cmap = self.sample_map.iter();
fn open(&mut self, strmgr: &mut StreamManager, seek_index: &mut SeekIndex) -> DemuxerResult<()> {
self.read_root(strmgr)?;
validate!(self.mdat_pos > 0);
- validate!(self.tracks.len() > 0);
+ validate!(!self.tracks.is_empty());
for track in self.tracks.iter() {
track.fill_seek_index(seek_index);
}
}
fn get_frame(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> {
- if self.tracks.len() == 0 {
+ if self.tracks.is_empty() {
return Err(DemuxerError::EOF);
}
for _ in 0..self.tracks.len() {
return Ok(pkt);
}
}
- return Err(DemuxerError::EOF);
+ Err(DemuxerError::EOF)
}
fn seek(&mut self, time: u64, seek_index: &SeekIndex) -> DemuxerResult<()> {
macro_rules! mktag {
($a:expr, $b:expr, $c:expr, $d:expr) => {
- (($a as u32) << 24) | (($b as u32) << 16) | (($c as u32) << 8) | ($d as u32)
+ (u32::from($a) << 24) | (u32::from($b) << 16) | (u32::from($c) << 8) | u32::from($d)
};
($arr:expr) => {
- (($arr[0] as u32) << 24) | (($arr[1] as u32) << 16) | (($arr[2] as u32) << 8) | ($arr[3] as u32)
+ (u32::from($arr[0]) << 24) | (u32::from($arr[1]) << 16) | (u32::from($arr[2]) << 8) | u32::from($arr[3])
};
}
let bits_per_sample = if csize >= 16 { self.src.read_u16le()? } else { 8 };
validate!(channels < 256);
- let edata;
- if csize > 16 {
- validate!(csize >= 18);
- let cb_size = self.src.read_u16le()? as usize;
- let mut buf = vec![0; cb_size];
+ let edata = if csize > 16 {
+ validate!(csize >= 18);
+ let cb_size = self.src.read_u16le()? as usize;
+ let mut buf = vec![0; cb_size];
self.src.read_buf(buf.as_mut_slice())?;
- edata = Some(buf);
- } else {
- edata = None;
- }
+ Some(buf)
+ } else {
+ None
+ };
let cname = register::find_codec_from_wav_twocc(format_tag).unwrap_or("unknown");
let soniton = if cname == "pcm" {
extern crate nihav_registry;
#[cfg(feature="decoders")]
+#[allow(clippy::needless_range_loop)]
+#[allow(clippy::single_match)]
#[allow(clippy::unreadable_literal)]
#[allow(clippy::too_many_arguments)]
#[allow(clippy::excessive_precision)]
}
impl<'a> MuxCore<'a> for AVIMuxer<'a> {
+ #[allow(clippy::unreadable_literal)]
+ #[allow(clippy::cast_lossless)]
fn create(&mut self, strmgr: &StreamManager) -> MuxerResult<()> {
if strmgr.get_num_streams() == 0 {
return Err(MuxerError::InvalidArgument);
// unimplemented!();
self.bw.write_u32le(0)?; // total colors
self.bw.write_u32le(0)?; // important colors
+println!("pal?");
} else {
self.bw.write_u32le(0)?; // total colors
self.bw.write_u32le(0)?; // important colors
}
fn end(&mut self) -> MuxerResult<()> {
patch_size(&mut self.bw, self.data_pos)?;
- if self.index.len() > 0 {
+ if !self.index.is_empty() {
self.bw.write_buf(b"idx1")?;
self.bw.write_u32le((self.index.len() * 16) as u32)?;
for item in self.index.iter() {
twocc.unwrap_or(0)
};
let avg_bytes_per_sec = if stream.get_info().get_name() == "pcm" {
- u32::from(ainfo.channels) * ainfo.sample_rate * u32::from(ainfo.format.bits) >> 3
+ (u32::from(ainfo.channels) * ainfo.sample_rate * u32::from(ainfo.format.bits)) >> 3
} else {
0
};
self.bw.write_buf(b"RIFF\0\0\0\0WAVEfmt ")?;
self.bw.write_u32le(if edata_len == 0 { 16 } else { 18 + edata_len } as u32)?;
self.bw.write_u16le(twocc)?;
- self.bw.write_u16le(ainfo.channels as u16)?;
+ self.bw.write_u16le(u16::from(ainfo.channels))?;
self.bw.write_u32le(ainfo.sample_rate)?;
self.bw.write_u32le(avg_bytes_per_sec)?;
self.bw.write_u16le(ainfo.block_len as u16)?;
- self.bw.write_u16le(ainfo.format.bits as u16)?;
+ self.bw.write_u16le(u16::from(ainfo.format.bits))?;
if let Some(ref buf) = stream.get_info().get_extradata() {
self.bw.write_u16le(edata_len as u16)?;
self.bw.write_buf(buf.as_slice())?;