X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-realmedia%2Fsrc%2Fcodecs%2Frv3040.rs;h=bbaabdf87b738c12fe444b79067176e2b4269090;hb=f5c7ce011fd64da390862e4a12c0b74d94018adf;hp=f9a1817ec677eafcc7f4979d9f8afcca5ac1cb90;hpb=fa57381ec2a3b8c441aa1388492b9ca037cfcf78;p=nihav.git diff --git a/nihav-realmedia/src/codecs/rv3040.rs b/nihav-realmedia/src/codecs/rv3040.rs index f9a1817..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 { @@ -326,13 +318,13 @@ impl MVInfo { } fn reset(&mut self) { let size = self.w * self.h; - self.mv_f.truncate(0); + self.mv_f.clear(); self.mv_f.resize(size, ZERO_MV); - self.mv_b.truncate(0); + self.mv_b.clear(); self.mv_b.resize(size, ZERO_MV); - self.has_f.truncate(0); + self.has_f.clear(); self.has_f.resize(size >> 2, false); - self.has_b.truncate(0); + self.has_b.clear(); self.has_b.resize(size >> 2, false); } fn fill(&mut self, mb_x: usize, mb_y: usize, fwd: bool, mv: MV) { @@ -511,7 +503,7 @@ pub trait RV34DSP { fn parse_slice_offsets(src: &[u8], offsets: &mut Vec) -> DecoderResult<()> { let num_slices = (src[0] as usize) + 1; let ini_off = num_slices * 8 + 1; - offsets.truncate(0); + offsets.clear(); if ini_off >= src.len() { return Err(DecoderError::ShortData); } @@ -532,7 +524,7 @@ fn parse_slice_offsets(src: &[u8], offsets: &mut Vec) -> DecoderResult<() Ok(()) } -fn decode_slice_header(br: &mut BitReader, bd: &mut RV34BitstreamDecoder, slice_no: usize, slice_offs: &[usize], old_width: usize, old_height: usize) -> DecoderResult { +fn decode_slice_header(br: &mut BitReader, bd: &mut dyn RV34BitstreamDecoder, slice_no: usize, slice_offs: &[usize], old_width: usize, old_height: usize) -> DecoderResult { validate!(slice_no < slice_offs.len()); br.seek((slice_offs[slice_no] * 8) as u32)?; let mut shdr = bd.decode_slice_header(br, old_width, old_height)?; @@ -777,7 +769,7 @@ impl RV34Decoder { base_ts: 0, } } - fn decode_mb_header_intra(&mut self, bd: &mut RV34BitstreamDecoder, br: &mut BitReader, is_i16: bool, im: &mut IntraModeState, q: u8, has_top: bool, has_dq: bool) -> DecoderResult { + fn decode_mb_header_intra(&mut self, bd: &mut dyn RV34BitstreamDecoder, br: &mut BitReader, is_i16: bool, im: &mut IntraModeState, q: u8, has_top: bool, has_dq: bool) -> DecoderResult { if is_i16 { let imode = br.read(2)? as i8; im.fill_block(imode); @@ -793,7 +785,7 @@ impl RV34Decoder { Ok(MBInfo { mbtype: MBType::MBIntra, skip_run: 0, dquant: dq }) } } - fn decode_mb_header_inter(&mut self, bd: &mut RV34BitstreamDecoder, br: &mut BitReader, ftype: FrameType, mbtype: MBType, im: &mut IntraModeState, q: u8, has_top: bool) -> DecoderResult { + fn decode_mb_header_inter(&mut self, bd: &mut dyn RV34BitstreamDecoder, br: &mut BitReader, ftype: FrameType, mbtype: MBType, im: &mut IntraModeState, q: u8, has_top: bool) -> DecoderResult { let hdr = bd.decode_inter_mb_hdr(br, ftype, mbtype)?; validate!(hdr.mbtype != MBType::Invalid); if hdr.dquant { @@ -1057,7 +1049,7 @@ impl RV34Decoder { } Ok(()) } - fn fill_deblock_flags(&self, sstate: &SState, mb_pos: usize, mbinfo: &mut Vec) { + 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; @@ -1095,8 +1087,8 @@ impl RV34Decoder { } } - #[allow(clippy::cyclomatic_complexity)] - pub fn parse_frame(&mut self, supp: &mut NADecoderSupport, src: &[u8], bd: &mut RV34BitstreamDecoder) -> DecoderResult<(NABufferType, FrameType, u64)> { + #[allow(clippy::cognitive_complexity)] + pub fn parse_frame(&mut self, supp: &mut NADecoderSupport, src: &[u8], bd: &mut dyn RV34BitstreamDecoder) -> DecoderResult<(NABufferType, FrameType, u64)> { let mut slice_offs: Vec = Vec::new(); parse_slice_offsets(src, &mut slice_offs)?; let ini_off = slice_offs.len() * 8 + 1;