diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2022-09-22 17:53:58 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2022-09-22 17:53:58 +0200 |
commit | 6f2630992fe340ad1a122ec10c649f756e478185 (patch) | |
tree | c8c95d46546cd71e2cd5e15faef02ca9acd2b70b /nihav-realmedia | |
parent | f44bddc9b5520507c7571b89763de668238d790a (diff) | |
download | nihav-6f2630992fe340ad1a122ec10c649f756e478185.tar.gz |
fix some clippy warnings
Diffstat (limited to 'nihav-realmedia')
-rw-r--r-- | nihav-realmedia/src/codecs/ralf.rs | 2 | ||||
-rw-r--r-- | nihav-realmedia/src/codecs/rv3040.rs | 18 | ||||
-rw-r--r-- | nihav-realmedia/src/codecs/rv60.rs | 74 | ||||
-rw-r--r-- | nihav-realmedia/src/demuxers/realmedia.rs | 35 |
4 files changed, 47 insertions, 82 deletions
diff --git a/nihav-realmedia/src/codecs/ralf.rs b/nihav-realmedia/src/codecs/ralf.rs index 94443a9..154b80c 100644 --- a/nihav-realmedia/src/codecs/ralf.rs +++ b/nihav-realmedia/src/codecs/ralf.rs @@ -370,7 +370,7 @@ impl NADecoder for RALFDecoder { let _bits = br.read_u16be().unwrap(); let sample_rate = br.read_u32be().unwrap(); let max_frame_size = br.read_u32be().unwrap(); - validate!((channels == 1 || channels == 2) && (sample_rate >= 8000 && sample_rate <= 96000)); + validate!((channels == 1 || channels == 2) && (8000..=96000).contains(&sample_rate)); self.max_frame_size = max_frame_size.max(sample_rate) as usize; let ainfo = NAAudioInfo::new(ainfo.get_sample_rate(), channels as u8, diff --git a/nihav-realmedia/src/codecs/rv3040.rs b/nihav-realmedia/src/codecs/rv3040.rs index 762d054..bbaabdf 100644 --- a/nihav-realmedia/src/codecs/rv3040.rs +++ b/nihav-realmedia/src/codecs/rv3040.rs @@ -91,18 +91,13 @@ impl MBType { } } pub fn is_fwd(self) -> bool { - match self { + matches!(self, MBType::MBP16x16 | MBType::MBP16x16Mix | MBType::MBP16x8 | MBType::MBP8x16 | MBType::MBP8x8 | - MBType::MBForward => true, - _ => false, - } + MBType::MBForward) } pub fn is_bwd(self) -> bool { - match self { - MBType::MBBidir | MBType::MBBackward => true, - _ => false, - } + matches!(self, MBType::MBBidir | MBType::MBBackward) } pub fn has_mv_dir(self, fwd: bool) -> bool { match self { @@ -113,10 +108,7 @@ impl MBType { } } pub fn is_nomv(self) -> bool { - match self { - MBType::MBIntra | MBType::MBIntra16 | MBType::MBSkip | MBType::MBDirect => true, - _ => false, - } + matches!(self, MBType::MBIntra | MBType::MBIntra16 | MBType::MBSkip | MBType::MBDirect) } /*pub fn is_16x16(self) -> bool { match self { @@ -1057,7 +1049,7 @@ impl RV34Decoder { } Ok(()) } - fn fill_deblock_flags(&self, sstate: &SState, mb_pos: usize, mbinfo: &mut Vec<RV34MBInfo>) { + fn fill_deblock_flags(&self, sstate: &SState, mb_pos: usize, mbinfo: &mut [RV34MBInfo]) { let mbt = mbinfo[mb_pos].mbtype; let mut hmvmask = 0; let mut vmvmask = 0; diff --git a/nihav-realmedia/src/codecs/rv60.rs b/nihav-realmedia/src/codecs/rv60.rs index 55faf03..bedebc9 100644 --- a/nihav-realmedia/src/codecs/rv60.rs +++ b/nihav-realmedia/src/codecs/rv60.rs @@ -306,16 +306,10 @@ impl PUType { } } fn has_hor_split(self) -> bool { - match self { - PUType::N2Hor | PUType::N4Hor | PUType::N34Hor | PUType::Quarters => true, - _ => false, - } + matches!(self, PUType::N2Hor | PUType::N4Hor | PUType::N34Hor | PUType::Quarters) } fn has_ver_split(self) -> bool { - match self { - PUType::N2Ver | PUType::N4Ver | PUType::N34Ver | PUType::Quarters => true, - _ => false, - } + matches!(self, PUType::N2Ver | PUType::N4Ver | PUType::N34Ver | PUType::Quarters) } } @@ -368,22 +362,13 @@ impl MVRef { } } fn is_ref0(self) -> bool { - match self { - MVRef::Ref0 | MVRef::Ref0AndBRef => true, - _ => false, - } + matches!(self, MVRef::Ref0 | MVRef::Ref0AndBRef) } fn is_fwd(self) -> bool { - match self { - MVRef::Ref0 | MVRef::Ref1 | MVRef::Ref0AndBRef => true, - _ => false, - } + matches!(self, MVRef::Ref0 | MVRef::Ref1 | MVRef::Ref0AndBRef) } fn is_bwd(self) -> bool { - match self { - MVRef::BRef | MVRef::Ref0AndBRef => true, - _ => false, - } + matches!(self, MVRef::BRef | MVRef::Ref0AndBRef) } } @@ -692,7 +677,7 @@ impl RealVideo60Decoder { let cu_w = hdr.get_width_cu(); let dqp = hdr.read_line_qp_offset(&mut br)?; let qps = (hdr.qp as i8) + dqp; - validate!((qps >= 0) && (qps < 32)); + validate!((0..32).contains(&qps)); let qp = qps as u8; self.qp = qp; self.sel_qp = match hdr.osvquant { @@ -765,9 +750,9 @@ println!(" left {} bits", br.left()); let dstride = buf.stride[comp]; let soff = buf.offset[comp]; let off = soff + (xpos >> 1) + (ypos >> 1) * dstride; - let mut dst = &mut buf.data; + let dst = &mut buf.data; self.populate_ipred(hdr, dst, soff, dstride, 0, 0, size >> 1, false); - self.ipred.pred_angle(&mut dst, off, dstride, size >> 1, itype as usize, false); + self.ipred.pred_angle(dst, off, dstride, size >> 1, itype as usize, false); } }, _ => { @@ -866,8 +851,8 @@ println!(" left {} bits", br.left()); self.dsp.transform4x4(&mut self.y_coeffs[i * 16..][..16]); let dstride = buf.stride[0]; let off = xpos + x * 4 + (ypos + y * 4) * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, &self.y_coeffs[i*16..][..16], 4); + let dst = &mut buf.data; + self.dsp.add_block(dst, off, dstride, &self.y_coeffs[i*16..][..16], 4); } } } @@ -880,15 +865,15 @@ println!(" left {} bits", br.left()); self.dsp.transform4x4(&mut self.u_coeffs[i * 16..][..16]); let dstride = buf.stride[1]; let off = buf.offset[1] + xoff + yoff * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, &self.u_coeffs[i * 16..][..16], 4); + let dst = &mut buf.data; + self.dsp.add_block(dst, off, dstride, &self.u_coeffs[i * 16..][..16], 4); } if ((cbp16 >> (20 + i)) & 1) != 0 { self.dsp.transform4x4(&mut self.v_coeffs[i * 16..][..16]); let dstride = buf.stride[2]; let off = buf.offset[2] + xoff + yoff * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, &self.v_coeffs[i * 16..][..16], 4); + let dst = &mut buf.data; + self.dsp.add_block(dst, off, dstride, &self.v_coeffs[i * 16..][..16], 4); } } } @@ -905,10 +890,10 @@ println!(" left {} bits", br.left()); if split_i4x4 { let dstride = buf.stride[0]; let off = xpos + xoff + (ypos + yoff) * dstride; - let mut dst = &mut buf.data; + let dst = &mut buf.data; self.populate_ipred(hdr, dst, 0, dstride, xoff, yoff, 4, true); let itype = self.blk_info[self.blk_pos + (i & 1) + (i >> 1) * self.blk_stride].imode; - self.ipred.pred_angle(&mut dst, off, dstride, 4, itype as usize, false); + self.ipred.pred_angle(dst, off, dstride, 4, itype as usize, false); } if ((cbp8 >> i) & 1) != 0 { let blk = &mut self.y_coeffs[i * 16..][..16]; @@ -916,8 +901,7 @@ println!(" left {} bits", br.left()); let dstride = buf.stride[0]; let soff = buf.offset[0]; let off = soff + xpos + xoff + (ypos + yoff) * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, blk, 4); + self.dsp.add_block(buf.data, off, dstride, blk, 4); } } if ((cbp8 >> 4) & 1) != 0 { @@ -925,16 +909,14 @@ println!(" left {} bits", br.left()); let dstride = buf.stride[1]; let soff = buf.offset[1]; let off = soff + (xpos >> 1) + (ypos >> 1) * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, &self.u_coeffs, 4); + self.dsp.add_block(buf.data, off, dstride, &self.u_coeffs, 4); } if ((cbp8 >> 5) & 1) != 0 { self.dsp.transform4x4(&mut self.v_coeffs); let dstride = buf.stride[2]; let soff = buf.offset[2]; let off = soff + (xpos >> 1) + (ypos >> 1) * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, &self.v_coeffs, 4); + self.dsp.add_block(buf.data, off, dstride, &self.v_coeffs, 4); } } }, @@ -948,24 +930,21 @@ println!(" left {} bits", br.left()); self.dsp.transform8x8(&mut self.y_coeffs); let dstride = buf.stride[0]; let off = xpos + ypos * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, &self.y_coeffs, 8); + self.dsp.add_block(buf.data, off, dstride, &self.y_coeffs, 8); } if ((cbp8 >> 4) & 1) != 0 { self.dsp.transform4x4(&mut self.u_coeffs); let dstride = buf.stride[1]; let soff = buf.offset[1]; let off = soff + (xpos >> 1) + (ypos >> 1) * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, &self.u_coeffs, 4); + self.dsp.add_block(buf.data, off, dstride, &self.u_coeffs, 4); } if ((cbp8 >> 5) & 1) != 0 { self.dsp.transform4x4(&mut self.v_coeffs); let dstride = buf.stride[2]; let soff = buf.offset[2]; let off = soff + (xpos >> 1) + (ypos >> 1) * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, &self.v_coeffs, 4); + self.dsp.add_block(buf.data, off, dstride, &self.v_coeffs, 4); } } }, @@ -990,24 +969,21 @@ println!(" left {} bits", br.left()); self.dsp.transform16x16(&mut self.y_coeffs); let dstride = buf.stride[0]; let off = xpos + x * 16 + (ypos + y * 16) * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, &self.y_coeffs, 16); + self.dsp.add_block(buf.data, off, dstride, &self.y_coeffs, 16); } if ((super_cbp >> 16) & 0xF) != 0 { self.dsp.transform8x8(&mut self.u_coeffs); let dstride = buf.stride[1]; let soff = buf.offset[1]; let off = soff + (xpos >> 1) + x * 8 + ((ypos >> 1) + y * 8) * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, &self.u_coeffs, 8); + self.dsp.add_block(buf.data, off, dstride, &self.u_coeffs, 8); } if ((super_cbp >> 20) & 0xF) != 0 { self.dsp.transform8x8(&mut self.v_coeffs); let dstride = buf.stride[2]; let soff = buf.offset[2]; let off = soff + (xpos >> 1) + x * 8 + ((ypos >> 1) + y * 8) * dstride; - let mut dst = &mut buf.data; - self.dsp.add_block(&mut dst, off, dstride, &self.v_coeffs, 8); + self.dsp.add_block(buf.data, off, dstride, &self.v_coeffs, 8); } } } diff --git a/nihav-realmedia/src/demuxers/realmedia.rs b/nihav-realmedia/src/demuxers/realmedia.rs index f508c6a..f889284 100644 --- a/nihav-realmedia/src/demuxers/realmedia.rs +++ b/nihav-realmedia/src/demuxers/realmedia.rs @@ -154,8 +154,8 @@ impl RMAudioStream { let bsize = iinfo.block_size as usize; let ppos = self.sub_packet; for sb in 0..halffact { - let mut dst = &mut self.buf[sb * 2 * fsize + ppos * bsize..][..bsize]; - src.read_buf(&mut dst)?; + let dst = &mut self.buf[sb * 2 * fsize + ppos * bsize..][..bsize]; + src.read_buf(dst)?; } self.sub_packet += 1; if self.sub_packet == factor { @@ -175,8 +175,8 @@ impl RMAudioStream { for sb in 0..factor2 { let sb_pos = factor * sb + ((factor + 1) >> 1) * (ppos & 1) + (ppos >> 1); - let mut dst = &mut self.buf[bsize * sb_pos..][..bsize]; - src.read_buf(&mut dst)?; + let dst = &mut self.buf[bsize * sb_pos..][..bsize]; + src.read_buf(dst)?; } }, Deinterleaver::Sipro => { @@ -184,8 +184,8 @@ impl RMAudioStream { let fsize = iinfo.frame_size as usize; let ppos = self.sub_packet; - let mut dst = &mut self.buf[fsize * ppos..][..fsize]; - src.read_buf(&mut dst)?; + let dst = &mut self.buf[fsize * ppos..][..fsize]; + src.read_buf(dst)?; }, Deinterleaver::VBR => { validate!(payload_size >= 5); @@ -731,7 +731,7 @@ impl<'a> DemuxCore<'a> for RealMediaDemuxer<'a> { //todo skip unwanted packet let keyframe = (flags & KEYFRAME_FLAG) != 0; - let ret = RMDemuxCommon::parse_packet_payload(&mut self.src, &mut self.str_data.streams[str_id], stream, &mut self.slice_buf, &mut self.queued_pkts, keyframe, ts, payload_size); + let ret = RMDemuxCommon::parse_packet_payload(self.src, &mut self.str_data.streams[str_id], stream, &mut self.slice_buf, &mut self.queued_pkts, keyframe, ts, payload_size); if let Err(DemuxerError::TryAgain) = ret { continue; } else { @@ -1210,13 +1210,13 @@ impl<'a> DemuxCore<'a> for RealAudioDemuxer<'a> { let ver = self.src.read_u16be()?; let ainfo = match ver { 3 => { - parse_aformat3(&mut self.src)? + parse_aformat3(self.src)? }, 4 => { - parse_aformat4(&mut self.src)? + parse_aformat4(self.src)? }, 5 => { - parse_aformat5(&mut self.src)? + parse_aformat5(self.src)? }, _ => { println!("unknown version {}", ver); @@ -1266,7 +1266,7 @@ println!(" got ainfo {:?}", ainfo); let stream = streamres.unwrap(); if let Some(ref mut astr) = self.stream { loop { - let ret = astr.read_apackets(&mut self.queued_pkts, &mut self.src, stream.clone(), 0, false, self.blk_size); + let ret = astr.read_apackets(&mut self.queued_pkts, self.src, stream.clone(), 0, false, self.blk_size); if let Err(DemuxerError::TryAgain) = ret { continue; } @@ -1371,10 +1371,7 @@ impl IVRRecord { } } fn is_data_start(&self) -> bool { - match *self { - IVRRecord::DataStart => true, - _ => false, - } + matches!(*self, IVRRecord::DataStart) } } @@ -1560,13 +1557,13 @@ impl<'a> DemuxCore<'a> for RealIVRDemuxer<'a> { let magic = self.src.peek_u32be()?; if magic == mktag!(b".REC") { let mut rec = RecordDemuxer::new(0, 0); - rec.parse_header(&mut self.src, strmgr, &mut self.str_data)?; + rec.parse_header(self.src, strmgr, &mut self.str_data)?; self.recs.push(rec); } else if magic == mktag!(b".R1M") { println!("R1M kind"); self.src.read_skip(4)?; // magic self.src.read_skip(3)?; // always 0, 1, 1 ? - let _name = IVRRecord::read_string(&mut self.src)?; + let _name = IVRRecord::read_string(self.src)?; self.src.read_skip(1)?; // always 0? let len1 = self.src.read_u32be()? as u64; let off1 = self.src.read_u64be()?; @@ -1587,7 +1584,7 @@ println!("R1M kind"); if len > 0x20 { let num_streams = self.str_data.streams.len() as u32; let mut rec = RecordDemuxer::new(pos + 12, num_streams); - rec.parse_header(&mut self.src, strmgr, &mut self.str_data)?; + rec.parse_header(self.src, strmgr, &mut self.str_data)?; self.recs.push(rec); } self.src.seek(SeekFrom::Start(pos + len))?; @@ -1618,7 +1615,7 @@ println!("R1M kind"); } loop { if self.cur_rec >= self.recs.len() { return Err(DemuxerError::EOF); } - let res = self.recs[self.cur_rec].get_packet(&mut self.src, &mut self.str_data, strmgr, &mut self.queued_pkts, &mut self.slice_buf); + let res = self.recs[self.cur_rec].get_packet(self.src, &mut self.str_data, strmgr, &mut self.queued_pkts, &mut self.slice_buf); if let Err(DemuxerError::EOF) = res { self.cur_rec += 1; } else { |