From 379524159c95f1c3639976ccf35f9d47cd9732ac Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 29 Oct 2021 14:40:07 +0200 Subject: [PATCH] replace vec.truncate(0) with vec.clear() --- nihav-codec-support/src/codecs/h263/decoder.rs | 10 +++++----- nihav-codec-support/src/codecs/h263/mod.rs | 4 ++-- nihav-codec-support/src/data/mod.rs | 2 +- nihav-codec-support/src/vq/generic_elbg.rs | 6 +++--- nihav-commonfmt/src/codecs/cinepakenc.rs | 16 ++++++++-------- nihav-commonfmt/src/codecs/zmbvenc.rs | 12 ++++++------ nihav-commonfmt/src/demuxers/mov.rs | 4 ++-- nihav-commonfmt/src/muxers/avi.rs | 2 +- nihav-duck/src/codecs/truemotion1.rs | 2 +- nihav-duck/src/codecs/truemotion2.rs | 2 +- nihav-game/src/demuxers/q.rs | 2 +- nihav-indeo/src/codecs/indeo3.rs | 8 ++++---- nihav-indeo/src/codecs/ivibr.rs | 6 +++--- nihav-itu/src/codecs/h264/mod.rs | 2 +- nihav-itu/src/codecs/h264/pic_ref.rs | 12 ++++++------ nihav-itu/src/codecs/h264/test/raw_demux.rs | 4 ++-- nihav-llaudio/src/codecs/ape.rs | 2 +- nihav-ms/src/codecs/msadpcm.rs | 2 +- nihav-qt/src/codecs/qdmc.rs | 2 +- nihav-qt/src/codecs/svq1.rs | 2 +- nihav-qt/src/codecs/svq3.rs | 10 +++++----- nihav-rad/src/demuxers/smacker.rs | 2 +- nihav-realmedia/src/codecs/ralf.rs | 2 +- nihav-realmedia/src/codecs/rv3040.rs | 10 +++++----- nihav-realmedia/src/codecs/rv60.rs | 4 ++-- nihav-realmedia/src/demuxers/realmedia.rs | 2 +- 26 files changed, 66 insertions(+), 66 deletions(-) diff --git a/nihav-codec-support/src/codecs/h263/decoder.rs b/nihav-codec-support/src/codecs/h263/decoder.rs index e1af173..bba8c04 100644 --- a/nihav-codec-support/src/codecs/h263/decoder.rs +++ b/nihav-codec-support/src/codecs/h263/decoder.rs @@ -538,16 +538,16 @@ impl H263BaseDecoder { if capacity < self.num_mb { self.obmc_blk.reserve(self.num_mb - capacity); } - self.obmc_blk.truncate(0); + self.obmc_blk.clear(); } if self.has_b { - self.mv_data.truncate(0); + self.mv_data.clear(); } let save_b_data = pinfo.mode.is_ref() && self.may_have_b_frames; if save_b_data { - self.mv_data.truncate(0); + self.mv_data.clear(); } let is_b = pinfo.mode == Type::B; @@ -580,7 +580,7 @@ impl H263BaseDecoder { let mut mb_pos = 0; let apply_acpred = /*(pinfo.mode == Type::I) && */pinfo.plusinfo.is_some() && pinfo.plusinfo.unwrap().aic; if apply_acpred { - self.pred_coeffs.truncate(0); + self.pred_coeffs.clear(); if !self.pred_quant { self.pred_coeffs.resize(self.mb_w * self.mb_h, ZERO_PRED_COEFFS); } else { @@ -796,7 +796,7 @@ impl H263BaseDecoder { recon_b_frame(b_buf, bck_buf.clone(), fwd_buf.clone(), self.mb_w, self.mb_h, self.b_data.as_slice(), bdsp); } - self.b_data.truncate(0); + self.b_data.clear(); Ok(bufinfo) } } diff --git a/nihav-codec-support/src/codecs/h263/mod.rs b/nihav-codec-support/src/codecs/h263/mod.rs index 0ddfed5..e357778 100644 --- a/nihav-codec-support/src/codecs/h263/mod.rs +++ b/nihav-codec-support/src/codecs/h263/mod.rs @@ -358,9 +358,9 @@ impl CBPInfo { fn new() -> Self { CBPInfo{ cbp: Vec::new(), q: Vec::new(), mb_w: 0 } } fn reset(&mut self, mb_w: usize) { self.mb_w = mb_w; - self.cbp.truncate(0); + self.cbp.clear(); self.cbp.resize(self.mb_w * 2, 0); - self.q.truncate(0); + self.q.clear(); self.q.resize(self.mb_w * 2, 0); } fn update_row(&mut self) { diff --git a/nihav-codec-support/src/data/mod.rs b/nihav-codec-support/src/data/mod.rs index 2ad6b8c..eba0299 100644 --- a/nihav-codec-support/src/data/mod.rs +++ b/nihav-codec-support/src/data/mod.rs @@ -54,7 +54,7 @@ impl GenericCache { pub fn full_size(&self) -> usize { self.stride * (self.height + 1) + 1 } /// Resets the cache state. pub fn reset(&mut self) { - self.data.truncate(0); + self.data.clear(); let size = self.full_size(); self.data.resize(size, self.default); self.xpos = self.stride + 1; diff --git a/nihav-codec-support/src/vq/generic_elbg.rs b/nihav-codec-support/src/vq/generic_elbg.rs index 32cbb82..d6c30d2 100644 --- a/nihav-codec-support/src/vq/generic_elbg.rs +++ b/nihav-codec-support/src/vq/generic_elbg.rs @@ -199,7 +199,7 @@ impl> ELBG { } // put points into the nearest clusters - indices.truncate(0); + indices.clear(); for entry in entries.iter() { let mut bestidx = 0; let mut bestdist = std::u32::MAX; @@ -230,8 +230,8 @@ impl> ELBG { } let dmean = dist / (dst.len() as u64); - low_u.truncate(0); - high_u.truncate(0); + low_u.clear(); + high_u.clear(); let mut used = vec![false; dst.len()]; for (i, cluster) in self.clusters.iter().enumerate() { if cluster.dist < dmean { diff --git a/nihav-commonfmt/src/codecs/cinepakenc.rs b/nihav-commonfmt/src/codecs/cinepakenc.rs index 01e5714..ddf2584 100644 --- a/nihav-commonfmt/src/codecs/cinepakenc.rs +++ b/nihav-commonfmt/src/codecs/cinepakenc.rs @@ -169,7 +169,7 @@ impl MaskWriter { } } fn reset(&mut self) { - self.masks.truncate(0); + self.masks.clear(); self.mask = 0; self.pos = 0; } @@ -303,8 +303,8 @@ impl CinepakEncoder { let mut voff = in_frm.get_offset(2) + start / 2 * vstride; let (width, _) = in_frm.get_dimensions(0); let data = in_frm.get_data(); - self.v1_entries.truncate(0); - self.v4_entries.truncate(0); + self.v1_entries.clear(); + self.v4_entries.clear(); for _ in (start..end).step_by(4) { for x in (0..width).step_by(4) { let mut yblk = [0; 16]; @@ -530,7 +530,7 @@ impl CinepakEncoder { } } fn calc_skip_dist(&mut self, in_frm: &NAVideoBuffer, start: usize, end: usize) { - self.skip_dist.truncate(0); + self.skip_dist.clear(); if let Some(ref ref_frm) = self.lastfrm { let rystride = ref_frm.get_stride(0); let mut ryoff = ref_frm.get_offset(0) + start * rystride; @@ -677,8 +677,8 @@ impl CinepakEncoder { } } - self.v1_idx.truncate(0); - self.v4_idx.truncate(0); + self.v1_idx.clear(); + self.v4_idx.clear(); self.masks.reset(); for (v1_entry, v4_entries) in self.v1_entries.iter().zip(self.v4_entries.chunks(4)) { @@ -810,8 +810,8 @@ impl CinepakEncoder { } } - self.v1_idx.truncate(0); - self.v4_idx.truncate(0); + self.v1_idx.clear(); + self.v4_idx.clear(); self.masks.reset(); let mut skip_iter = self.skip_dist.iter(); diff --git a/nihav-commonfmt/src/codecs/zmbvenc.rs b/nihav-commonfmt/src/codecs/zmbvenc.rs index 0e053fe..ee40f49 100644 --- a/nihav-commonfmt/src/codecs/zmbvenc.rs +++ b/nihav-commonfmt/src/codecs/zmbvenc.rs @@ -184,7 +184,7 @@ impl ZMBVEncoder { } bw.write_buf(&self.frm1[..self.width * self.height * bm])?; } else { - self.tmp_buf.truncate(0); + self.tmp_buf.clear(); if bpp == 8 { self.tmp_buf.extend_from_slice(&self.pal); } @@ -193,7 +193,7 @@ impl ZMBVEncoder { let mut db = Vec::new(); std::mem::swap(&mut db, &mut self.zbuf); - db.truncate(0); + db.clear(); let mut wr = DeflateWriter::new(db); self.compr.write_zlib_header(&mut wr); self.compr.compress(&self.tmp_buf, &mut wr); @@ -211,7 +211,7 @@ impl ZMBVEncoder { self.frm1.copy_from_slice(&self.frm2); bw.write_byte(0)?; - self.tmp_buf.truncate(0); + self.tmp_buf.clear(); let tile_w = (self.width + self.tile_w - 1) / self.tile_w; let tile_h = (self.height + self.tile_h - 1) / self.tile_h; let mv_size = (tile_w * tile_h * 2 + 3) & !3; @@ -224,7 +224,7 @@ impl ZMBVEncoder { let mut db = Vec::new(); std::mem::swap(&mut db, &mut self.zbuf); - db.truncate(0); + db.clear(); let mut wr = DeflateWriter::new(db); self.compr.compress(&self.tmp_buf, &mut wr); self.compr.compress_flush(&mut wr); @@ -240,7 +240,7 @@ impl ZMBVEncoder { return Err(EncoderError::FormatError); } - self.tmp_buf.truncate(0); + self.tmp_buf.clear(); if let (NABufferType::Video(ref vbuf), true) = (&buf, bpp == 8) { let mut npal = [0; 768]; let off = vbuf.get_offset(1); @@ -356,7 +356,7 @@ impl ZMBVEncoder { let mut db = Vec::new(); std::mem::swap(&mut db, &mut self.zbuf); - db.truncate(0); + db.clear(); let mut wr = DeflateWriter::new(db); self.compr.compress(&self.tmp_buf, &mut wr); self.compr.compress_flush(&mut wr); diff --git a/nihav-commonfmt/src/demuxers/mov.rs b/nihav-commonfmt/src/demuxers/mov.rs index 4a11758..90ca6c5 100644 --- a/nihav-commonfmt/src/demuxers/mov.rs +++ b/nihav-commonfmt/src/demuxers/mov.rs @@ -791,7 +791,7 @@ fn read_stts(track: &mut Track, br: &mut ByteReader, size: u64) -> DemuxerResult validate!(tb_num != 0); track.rescale(tb_num); } else { - track.time_to_sample.truncate(0); + track.time_to_sample.clear(); track.time_to_sample.reserve(entries); for _ in 0..entries { let count = br.read_u32be()?; @@ -1148,7 +1148,7 @@ struct RLESearcher { impl RLESearcher { fn new() -> Self { Self::default() } fn resize(&mut self, size: usize) { - self.array.truncate(0); + self.array.clear(); self.array.reserve(size); } fn reserve(&mut self, size: usize) { diff --git a/nihav-commonfmt/src/muxers/avi.rs b/nihav-commonfmt/src/muxers/avi.rs index 00b3e6d..cd75942 100644 --- a/nihav-commonfmt/src/muxers/avi.rs +++ b/nihav-commonfmt/src/muxers/avi.rs @@ -109,7 +109,7 @@ impl<'a> MuxCore<'a> for AVIMuxer<'a> { self.bw.write_u32le(0)?; // reserved self.bw.write_u32le(0)?; // reserved - self.pal_pos.truncate(0); + self.pal_pos.clear(); self.pal_pos.resize(strmgr.get_num_streams(), 0); for (strno, str) in strmgr.iter().enumerate() { let strl_pos = self.bw.tell() + 8; diff --git a/nihav-duck/src/codecs/truemotion1.rs b/nihav-duck/src/codecs/truemotion1.rs index e1d0557..9f5546f 100644 --- a/nihav-duck/src/codecs/truemotion1.rs +++ b/nihav-duck/src/codecs/truemotion1.rs @@ -599,7 +599,7 @@ impl NADecoder for TM1Decoder { let mask_bits = &src[hdr_size..][..mask_size]; let index_bytes = &src[hdr_size+mask_size..]; validate!(src.len() >= hdr_size + mask_size); - self.vert_pred.truncate(0); + self.vert_pred.clear(); self.vert_pred.resize(out_width, 0); if is_intra || is_sprite { diff --git a/nihav-duck/src/codecs/truemotion2.rs b/nihav-duck/src/codecs/truemotion2.rs index bf8aa7d..0c9e004 100644 --- a/nihav-duck/src/codecs/truemotion2.rs +++ b/nihav-duck/src/codecs/truemotion2.rs @@ -102,7 +102,7 @@ impl Default for TM2Stream { impl TM2Stream { fn read_header(&mut self, src: &[u8], br: &mut ByteReader) -> DecoderResult<()> { - self.tokens.truncate(0); + self.tokens.clear(); self.pos = 0; let len = br.read_u32le()? as usize; diff --git a/nihav-game/src/demuxers/q.rs b/nihav-game/src/demuxers/q.rs index 3f38ef7..0b154e9 100644 --- a/nihav-game/src/demuxers/q.rs +++ b/nihav-game/src/demuxers/q.rs @@ -67,7 +67,7 @@ impl<'a> DemuxCore<'a> for QDemuxer<'a> { } self.apts = 0; self.vpts = 0; - self.side_data.truncate(0); + self.side_data.clear(); Ok(()) } diff --git a/nihav-indeo/src/codecs/indeo3.rs b/nihav-indeo/src/codecs/indeo3.rs index 4048385..9e0ee11 100644 --- a/nihav-indeo/src/codecs/indeo3.rs +++ b/nihav-indeo/src/codecs/indeo3.rs @@ -31,8 +31,8 @@ impl Buffers { fn reset(&mut self) { self.width = 0; self.height = 0; - self.sbuf.truncate(0); - self.dbuf.truncate(0); + self.sbuf.clear(); + self.dbuf.clear(); } fn alloc(&mut self, w: usize, h: usize) { self.width = w; @@ -635,7 +635,7 @@ impl Indeo3Decoder { let nvec = br.read_u32le()?; validate!(nvec == 0); // for intra there should be no mc_vecs - self.mvs.truncate(0); + self.mvs.clear(); for _ in 0..nvec { let x = br.read_byte()? as i8; let y = br.read_byte()? as i8; @@ -662,7 +662,7 @@ impl Indeo3Decoder { let nvec = br.read_u32le()?; validate!(nvec <= 256); // for intra there should be no mc_vecs - self.mvs.truncate(0); + self.mvs.clear(); for _ in 0..nvec { let y = br.read_byte()? as i8; let x = br.read_byte()? as i8; diff --git a/nihav-indeo/src/codecs/ivibr.rs b/nihav-indeo/src/codecs/ivibr.rs index 141200c..8ce4d1b 100644 --- a/nihav-indeo/src/codecs/ivibr.rs +++ b/nihav-indeo/src/codecs/ivibr.rs @@ -510,8 +510,8 @@ impl IVIDecoder { fn realloc(&mut self, pic_hdr: &PictureHeader) -> DecoderResult<()> { let planes = if pic_hdr.transparent { 4 } else { 3 }; - //self.bands.truncate(0); - self.tiles.truncate(0); + //self.bands.clear(); + self.tiles.clear(); self.num_tiles = [[0; 4]; 4]; self.tile_start = [[0; 4]; 4]; let mut tstart: usize = 0; @@ -582,7 +582,7 @@ impl IVIDecoder { let mb_h = (tile.h + mb_size - 1) / mb_size; tile.mb_w = mb_w; tile.mb_h = mb_h; - tile.mb.truncate(0); + tile.mb.clear(); tile.mb.resize(mb_w * mb_h, MB::new(0, 0)); } diff --git a/nihav-itu/src/codecs/h264/mod.rs b/nihav-itu/src/codecs/h264/mod.rs index 803087c..e23d909 100644 --- a/nihav-itu/src/codecs/h264/mod.rs +++ b/nihav-itu/src/codecs/h264/mod.rs @@ -194,7 +194,7 @@ struct H264Decoder { fn unescape_nal(src: &[u8], dst: &mut Vec) -> usize { let mut off = 0; let mut zrun = 0; - dst.truncate(0); + dst.clear(); dst.reserve(src.len()); while off < src.len() { dst.push(src[off]); diff --git a/nihav-itu/src/codecs/h264/pic_ref.rs b/nihav-itu/src/codecs/h264/pic_ref.rs index d75d889..17a1b3b 100644 --- a/nihav-itu/src/codecs/h264/pic_ref.rs +++ b/nihav-itu/src/codecs/h264/pic_ref.rs @@ -200,8 +200,8 @@ impl FrameRefs { self.long_term.resize(arg1 as usize, None); }, 5 => { - self.ref_pics.truncate(0); - self.long_term.truncate(0); + self.ref_pics.clear(); + self.long_term.clear(); }, 6 => { // assign an long term index to current pic - done elsewhere @@ -212,13 +212,13 @@ impl FrameRefs { Ok(()) } pub fn clear_refs(&mut self) { - self.ref_pics.truncate(0); - self.long_term.truncate(0); + self.ref_pics.clear(); + self.long_term.clear(); } #[allow(clippy::cognitive_complexity)] pub fn select_refs(&mut self, sps: &SeqParameterSet, slice_hdr: &SliceHeader, cur_id: u32) { - self.ref_list0.truncate(0); - self.ref_list1.truncate(0); + self.ref_list0.clear(); + self.ref_list1.clear(); let pic_num_mask = if sps.log2_max_frame_num == 16 { 0xFFFF } else { diff --git a/nihav-itu/src/codecs/h264/test/raw_demux.rs b/nihav-itu/src/codecs/h264/test/raw_demux.rs index 3bdbd90..857016d 100644 --- a/nihav-itu/src/codecs/h264/test/raw_demux.rs +++ b/nihav-itu/src/codecs/h264/test/raw_demux.rs @@ -10,7 +10,7 @@ struct RawH264Demuxer<'a> { } fn read_nal(src: &mut ByteReader, dst: &mut Vec) -> DemuxerResult<()> { - dst.truncate(0); + dst.clear(); loop { let b = src.read_byte()?; if b == 0 { @@ -124,7 +124,7 @@ impl<'a> DemuxCore<'a> for RawH264Demuxer<'a> { let mut buf: Vec = Vec::with_capacity(65536); if !self.frame_buf.is_empty() { put_nal(&mut buf, &self.frame_buf); - self.frame_buf.truncate(0); + self.frame_buf.clear(); } let strres = strmgr.get_stream(0); if strres.is_none() { diff --git a/nihav-llaudio/src/codecs/ape.rs b/nihav-llaudio/src/codecs/ape.rs index c80dab2..8a9073d 100644 --- a/nihav-llaudio/src/codecs/ape.rs +++ b/nihav-llaudio/src/codecs/ape.rs @@ -126,7 +126,7 @@ impl NADecoder for APEDecoder { validate!(nblocks > 0); let bits = u32::from(pktbuf[4]); validate!(bits < 32); - self.data.truncate(0); + self.data.clear(); self.data.reserve((pktbuf.len() & !3) + 2); for word in pktbuf[8..].chunks_exact(4) { self.data.push(word[3]); diff --git a/nihav-ms/src/codecs/msadpcm.rs b/nihav-ms/src/codecs/msadpcm.rs index 7bf1015..a63f4e5 100644 --- a/nihav-ms/src/codecs/msadpcm.rs +++ b/nihav-ms/src/codecs/msadpcm.rs @@ -68,7 +68,7 @@ impl NADecoder for MSADPCMDecoder { self.block_samps = (self.block_len / channels - 7) * 2 + 2; self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(), channels as u8, SND_S16P_FORMAT, self.block_samps); self.chmap = NAChannelMap::from_str(if channels == 1 { "C" } else { "L,R" }).unwrap(); - self.adapt_coeffs.truncate(0); + self.adapt_coeffs.clear(); if let Some(ref buf) = info.get_extradata() { validate!(buf.len() >= 6); validate!((buf.len() & 3) == 0); diff --git a/nihav-qt/src/codecs/qdmc.rs b/nihav-qt/src/codecs/qdmc.rs index f8aaecd..cebf637 100644 --- a/nihav-qt/src/codecs/qdmc.rs +++ b/nihav-qt/src/codecs/qdmc.rs @@ -138,7 +138,7 @@ impl QdmcDecoder { } fn read_wave_data(&mut self, br: &mut BitReader) -> DecoderResult<()> { for tone in self.tones.iter_mut() { - tone.truncate(0); + tone.clear(); } for group in 0..5 { let group_size = 1 << (self.frame_bits - group - 1); diff --git a/nihav-qt/src/codecs/svq1.rs b/nihav-qt/src/codecs/svq1.rs index d63a927..4b5d8cd 100644 --- a/nihav-qt/src/codecs/svq1.rs +++ b/nihav-qt/src/codecs/svq1.rs @@ -291,7 +291,7 @@ impl SVQ1Decoder { ((self.width / 4 + 15) & !15, (self.height / 4 + 15) & !15) }; let mvstride = w / 8; - self.mvs.truncate(0); + self.mvs.clear(); self.mvs.resize(mvstride * (h / 8), ZERO_MV); let mut mv_idx = 0; diff --git a/nihav-qt/src/codecs/svq3.rs b/nihav-qt/src/codecs/svq3.rs index 46480f5..d2cd385 100644 --- a/nihav-qt/src/codecs/svq3.rs +++ b/nihav-qt/src/codecs/svq3.rs @@ -140,13 +140,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 >> 4, false); - self.has_b.truncate(0); + self.has_b.clear(); self.has_b.resize(size >> 4, false); } fn fill(&mut self, mb_x: usize, mb_y: usize, fwd: bool, mv: MV) { @@ -518,7 +518,7 @@ unimplemented!(); }; let slice_len = length + llen + 1; validate!(src.len() >= slice_len); - self.slice_buf.truncate(0); + self.slice_buf.clear(); if llen > 1 { self.slice_buf.extend_from_slice(&src[slice_len - llen + 1..][..llen - 1]); } diff --git a/nihav-rad/src/demuxers/smacker.rs b/nihav-rad/src/demuxers/smacker.rs index 340af85..3a45826 100644 --- a/nihav-rad/src/demuxers/smacker.rs +++ b/nihav-rad/src/demuxers/smacker.rs @@ -294,7 +294,7 @@ impl<'a> SmackerVideoDemuxer<'a> { } } fn reset_state(&mut self) { - self.queued_packets.truncate(0); + self.queued_packets.clear(); } } diff --git a/nihav-realmedia/src/codecs/ralf.rs b/nihav-realmedia/src/codecs/ralf.rs index be256b3..7e832de 100644 --- a/nihav-realmedia/src/codecs/ralf.rs +++ b/nihav-realmedia/src/codecs/ralf.rs @@ -426,7 +426,7 @@ impl NADecoder for RALFDecoder { let table_bits = ((self.pkt_buf[0] as usize) << 8) | (self.pkt_buf[1] as usize); let table_bytes = (table_bits + 7) >> 3; validate!(src_len > table_bytes + 3); - self.blocks.truncate(0); + self.blocks.clear(); { let mut br = BitReader::new(&self.pkt_buf[2..][..table_bytes], BitReaderMode::BE); while br.tell() < table_bits { diff --git a/nihav-realmedia/src/codecs/rv3040.rs b/nihav-realmedia/src/codecs/rv3040.rs index 9e8c68a..762d054 100644 --- a/nihav-realmedia/src/codecs/rv3040.rs +++ b/nihav-realmedia/src/codecs/rv3040.rs @@ -326,13 +326,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 +511,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); } diff --git a/nihav-realmedia/src/codecs/rv60.rs b/nihav-realmedia/src/codecs/rv60.rs index 5574cb4..c786b71 100644 --- a/nihav-realmedia/src/codecs/rv60.rs +++ b/nihav-realmedia/src/codecs/rv60.rs @@ -123,7 +123,7 @@ impl FrameHeader { signs.push(sign); } validate!(signs[0]); - sizes.truncate(0); + sizes.clear(); let mut sum = 0; let first_size = br.read(nbits)? as usize; validate!(first_size > 0); @@ -1506,7 +1506,7 @@ println!("???"); self.pu_stride = cu_w << 3; self.pu_info.resize(self.pu_stride * (cu_h << 3), PUInfo::default()); self.blk_stride = cu_w << 4; - self.blk_info.truncate(0); + self.blk_info.clear(); self.blk_info.resize(self.blk_stride * (cu_h << 4), BlockInfo::default()); if hdr.deblock { self.dblk.reinit(hdr.width, hdr.height); diff --git a/nihav-realmedia/src/demuxers/realmedia.rs b/nihav-realmedia/src/demuxers/realmedia.rs index 248fa6c..ad28fca 100644 --- a/nihav-realmedia/src/demuxers/realmedia.rs +++ b/nihav-realmedia/src/demuxers/realmedia.rs @@ -44,7 +44,7 @@ impl RMVideoStream { } } fn flush(&mut self) { - self.frame.truncate(0); + self.frame.clear(); self.frame_size = 0; self.frame_pos = 0; } -- 2.39.5