From 9037cf6b83ce135243522ec154cd7ffb35f8c816 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 1 Feb 2018 12:07:06 +0100 Subject: [PATCH] fix let mut foo = &mut bar warning --- src/codecs/blockdsp.rs | 4 ++-- src/codecs/gremlinvideo.rs | 2 +- src/codecs/h263/code.rs | 4 ++-- src/codecs/h263/intel263.rs | 8 ++++---- src/codecs/h263/rv10.rs | 6 +++--- src/codecs/h263/rv20.rs | 6 +++--- src/codecs/indeo/imc.rs | 12 ++++++------ src/codecs/indeo/indeo2.rs | 4 ++-- src/codecs/indeo/indeo3.rs | 28 ++++++++++++++-------------- src/demuxers/gdv.rs | 2 +- src/demuxers/mod.rs | 2 +- src/demuxers/realmedia.rs | 2 +- src/io/byteio.rs | 2 +- 13 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/codecs/blockdsp.rs b/src/codecs/blockdsp.rs index 2f02b84..ed47284 100644 --- a/src/codecs/blockdsp.rs +++ b/src/codecs/blockdsp.rs @@ -9,7 +9,7 @@ pub fn put_blocks(buf: &mut NAVideoBuffer, xpos: usize, ypos: usize, blk: &[ let mut idxv = buf.get_offset(2) + xpos * 8 + ypos * 8 * stridev; let mut data = buf.get_data_mut(); - let mut framebuf: &mut [u8] = data.as_mut_slice(); + let framebuf: &mut [u8] = data.as_mut_slice(); for j in 0..8 { for k in 0..8 { @@ -63,7 +63,7 @@ pub fn add_blocks(buf: &mut NAVideoBuffer, xpos: usize, ypos: usize, blk: &[ let mut idxv = buf.get_offset(2) + xpos * 8 + ypos * 8 * stridev; let mut data = buf.get_data_mut(); - let mut framebuf: &mut [u8] = data.as_mut_slice(); + let framebuf: &mut [u8] = data.as_mut_slice(); for j in 0..8 { for k in 0..8 { diff --git a/src/codecs/gremlinvideo.rs b/src/codecs/gremlinvideo.rs index 2c0a75d..24d7a53 100644 --- a/src/codecs/gremlinvideo.rs +++ b/src/codecs/gremlinvideo.rs @@ -138,7 +138,7 @@ impl GremlinVideoDecoder { let paloff = buf.get_offset(1); let stride = buf.get_stride(0); let mut data = buf.get_data_mut(); - let mut dst = data.as_mut_slice(); + let dst = data.as_mut_slice(); let mut sidx = PREAMBLE_SIZE; let mut didx = 0; diff --git a/src/codecs/h263/code.rs b/src/codecs/h263/code.rs index 83831db..1a29373 100644 --- a/src/codecs/h263/code.rs +++ b/src/codecs/h263/code.rs @@ -348,7 +348,7 @@ impl H263BlockDSP { fn deblock_hor(buf: &mut NAVideoBuffer, comp: usize, q: u8, off: usize) { let stride = buf.get_stride(comp); let mut dptr = buf.get_data_mut(); - let mut buf = dptr.as_mut_slice(); + let buf = dptr.as_mut_slice(); for x in 0..8 { let a = buf[off - 2 * stride + x] as i16; let b = buf[off - 1 * stride + x] as i16; @@ -378,7 +378,7 @@ fn deblock_hor(buf: &mut NAVideoBuffer, comp: usize, q: u8, off: usize) { fn deblock_ver(buf: &mut NAVideoBuffer, comp: usize, q: u8, off: usize) { let stride = buf.get_stride(comp); let mut dptr = buf.get_data_mut(); - let mut buf = dptr.as_mut_slice(); + let buf = dptr.as_mut_slice(); for y in 0..8 { let a = buf[off - 2 + y * stride] as i16; let b = buf[off - 1 + y * stride] as i16; diff --git a/src/codecs/h263/intel263.rs b/src/codecs/h263/intel263.rs index 14ddeac..e47073d 100644 --- a/src/codecs/h263/intel263.rs +++ b/src/codecs/h263/intel263.rs @@ -50,7 +50,7 @@ impl<'a> Intel263BR<'a> { } fn decode_block(&mut self, quant: u8, intra: bool, coded: bool, blk: &mut [i16; 64]) -> DecoderResult<()> { - let mut br = &mut self.br; + let br = &mut self.br; let mut idx = 0; if intra { let mut dc = br.read(8)?; @@ -137,7 +137,7 @@ impl<'a> BlockDecoder for Intel263BR<'a> { #[allow(unused_variables)] fn decode_pichdr(&mut self) -> DecoderResult { - let mut br = &mut self.br; + let br = &mut self.br; let syncw = br.read(22)?; validate!(syncw == 0x000020); let tr = (br.read(8)? << 8) as u16; @@ -212,7 +212,7 @@ impl<'a> BlockDecoder for Intel263BR<'a> { #[allow(unused_variables)] fn decode_slice_header(&mut self, info: &PicInfo) -> DecoderResult { - let mut br = &mut self.br; + let br = &mut self.br; let gbsc = br.read(17)?; validate!(gbsc == 1); let gn = br.read(5)?; @@ -226,7 +226,7 @@ impl<'a> BlockDecoder for Intel263BR<'a> { #[allow(unused_variables)] fn decode_block_header(&mut self, info: &PicInfo, slice: &SliceInfo, sstate: &SliceState) -> DecoderResult { - let mut br = &mut self.br; + let br = &mut self.br; let mut q = slice.get_quant(); match info.get_mode() { Type::I => { diff --git a/src/codecs/h263/rv10.rs b/src/codecs/h263/rv10.rs index efca754..202d757 100644 --- a/src/codecs/h263/rv10.rs +++ b/src/codecs/h263/rv10.rs @@ -90,7 +90,7 @@ impl<'a> RealVideo10BR<'a> { #[allow(unused_variables)] fn decode_block(&mut self, sstate: &SliceState, quant: u8, intra: bool, coded: bool, blk: &mut [i16; 64], plane_no: usize) -> DecoderResult<()> { - let mut br = &mut self.br; + let br = &mut self.br; let mut idx = 0; if intra { let mut dc; @@ -240,7 +240,7 @@ println!("decoding picture header size {}", if self.num_slices > 1 { self.slice_ } fn decode_block_header(&mut self, info: &PicInfo, slice: &SliceInfo, sstate: &SliceState) -> DecoderResult { - let mut br = &mut self.br; + let br = &mut self.br; let mut q = slice.get_quant(); match info.get_mode() { Type::I => { @@ -321,7 +321,7 @@ impl<'a> RealVideo10BR<'a> { fn read_slice_header(&mut self) -> DecoderResult { validate!(self.slice_no < self.num_slices); - let mut br = &mut self.br; + let br = &mut self.br; br.seek(self.slice_off[self.slice_no] * 8)?; let marker = br.read(1)?; diff --git a/src/codecs/h263/rv20.rs b/src/codecs/h263/rv20.rs index 177b6f1..3298fab 100644 --- a/src/codecs/h263/rv20.rs +++ b/src/codecs/h263/rv20.rs @@ -112,7 +112,7 @@ impl<'a> RealVideo20BR<'a> { #[allow(unused_variables)] fn decode_block(&mut self, sstate: &SliceState, quant: u8, intra: bool, coded: bool, blk: &mut [i16; 64], plane_no: usize, acpred: ACPredMode) -> DecoderResult<()> { - let mut br = &mut self.br; + let br = &mut self.br; let mut idx = 0; if !sstate.is_iframe && intra { let mut dc = br.read(8)? as i16; @@ -227,7 +227,7 @@ println!("slice ends @ {}\n", self.br.tell()); } fn decode_block_header(&mut self, info: &PicInfo, slice: &SliceInfo, sstate: &SliceState) -> DecoderResult { - let mut br = &mut self.br; + let br = &mut self.br; let mut q = slice.get_quant(); match info.get_mode() { Type::I => { @@ -362,7 +362,7 @@ impl<'a> RealVideo20BR<'a> { fn read_slice_header(&mut self) -> DecoderResult { validate!(self.slice_no < self.num_slices); - let mut br = &mut self.br; + let br = &mut self.br; br.seek(self.slice_off[self.slice_no] * 8)?; //println!(" slice at off {}", br.tell()); diff --git a/src/codecs/indeo/imc.rs b/src/codecs/indeo/imc.rs index b6b679f..5ba1575 100644 --- a/src/codecs/indeo/imc.rs +++ b/src/codecs/indeo/imc.rs @@ -434,7 +434,7 @@ impl IMCDecoder { } fn read_level_coeffs_raw(&mut self, br: &mut BitReader, ch: usize) -> DecoderResult<()> { - let mut ch_data = &mut self.ch_data[ch]; + let ch_data = &mut self.ch_data[ch]; let maxc_pos = br.read(5)? as usize; let max_coef = br.read(7)? as u8; @@ -458,7 +458,7 @@ impl IMCDecoder { } fn calculate_channel_values(&mut self, ch: usize) { - let mut ch_data = &mut self.ch_data[ch]; + let ch_data = &mut self.ch_data[ch]; let mut tmp2: [f32; BANDS+1] = [0.0; BANDS+1]; let mut tmp3: [f32; BANDS] = [0.0; BANDS]; @@ -526,7 +526,7 @@ impl IMCDecoder { self.ba.keep_flag[i] = level[i] == 16; } if reset { - let mut ch_data = &mut self.ch_data[ch]; + let ch_data = &mut self.ch_data[ch]; let (mut c1, mut c2) = calc_maxcoef(level[0] as f32); ch_data.new_floor[0] = c1; ch_data.log_floor[0] = c2; @@ -550,7 +550,7 @@ impl IMCDecoder { } } } else { - let mut ch_data = &mut self.ch_data[ch]; + let ch_data = &mut self.ch_data[ch]; for i in 0..BANDS { if level[i] < 16 { let lval = level[i] - 7; @@ -582,7 +582,7 @@ impl IMCDecoder { } fn read_skip_flags(&mut self, br: &mut BitReader) -> DecoderResult<()> { - let mut ba = &mut self.ba; + let ba = &mut self.ba; for band in 0..BANDS { if !ba.band_present[band] || ba.band_width[band] == 0 { continue; } @@ -697,7 +697,7 @@ impl IMCDecoder { fn inv_quant(&mut self, ch: usize, raw_coeffs: bool) { let qidx: usize = if raw_coeffs { 1 } else { 0 }; - let mut ch_data = &mut self.ch_data[ch]; + let ch_data = &mut self.ch_data[ch]; for band in 0..BANDS { for i in IMC_BANDS[band]..IMC_BANDS[band + 1] { ch_data.cw[i] = 0.0; diff --git a/src/codecs/indeo/indeo2.rs b/src/codecs/indeo/indeo2.rs index 35201b2..4f7abdd 100644 --- a/src/codecs/indeo/indeo2.rs +++ b/src/codecs/indeo/indeo2.rs @@ -206,7 +206,7 @@ impl Indeo2Decoder { let cb = &self.cb; let mut data = buf.get_data_mut(); - let mut framebuf: &mut [u8] = data.as_mut_slice(); + let framebuf: &mut [u8] = data.as_mut_slice(); let table = &INDEO2_DELTA_TABLE[tableno]; @@ -269,7 +269,7 @@ impl Indeo2Decoder { let cb = &self.cb; let mut data = buf.get_data_mut(); - let mut framebuf: &mut [u8] = data.as_mut_slice(); + let framebuf: &mut [u8] = data.as_mut_slice(); let table = &INDEO2_DELTA_TABLE[tableno]; diff --git a/src/codecs/indeo/indeo3.rs b/src/codecs/indeo/indeo3.rs index 2f8f2b2..abbff67 100644 --- a/src/codecs/indeo/indeo3.rs +++ b/src/codecs/indeo/indeo3.rs @@ -122,16 +122,16 @@ impl Buffers { #[allow(unused_variables)] fn apply_delta4x4(bufs: &mut Buffers, off: usize, stride: usize, deltas: &[u8], topline: bool, first_line: bool) { - let mut dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 4)] } - else { &mut bufs.buf2[off..(off + 4)] }; + let dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 4)] } + else { &mut bufs.buf2[off..(off + 4)] }; for i in 0..4 { dst[i] = dst[i].wrapping_add(deltas[i]) & 0x7F; } } #[allow(unused_variables)] fn apply_delta4x8(bufs: &mut Buffers, off: usize, stride: usize, deltas: &[u8], topline: bool, first_line: bool) { - let mut dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 4 + stride)] } - else { &mut bufs.buf2[off..(off + 4 + stride)] }; + let dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 4 + stride)] } + else { &mut bufs.buf2[off..(off + 4 + stride)] }; for i in 0..4 { dst[i + stride] = dst[i].wrapping_add(deltas[i]) & 0x7F; } if !topline { for i in 0..4 { dst[i] = (dst[i + stride] + dst[i]) >> 1; } @@ -143,8 +143,8 @@ fn apply_delta4x8(bufs: &mut Buffers, off: usize, stride: usize, #[allow(unused_variables)] fn apply_delta4x8m11(bufs: &mut Buffers, off: usize, stride: usize, deltas: &[u8], topline: bool, first_line: bool) { - let mut dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 4 + stride)] } - else { &mut bufs.buf2[off..(off + 4 + stride)] }; + let dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 4 + stride)] } + else { &mut bufs.buf2[off..(off + 4 + stride)] }; for i in 0..4 { dst[i] = dst[i] .wrapping_add(deltas[i]) & 0x7F; } for i in 0..4 { dst[i + stride] = dst[i + stride].wrapping_add(deltas[i]) & 0x7F; } } @@ -152,16 +152,16 @@ fn apply_delta4x8m11(bufs: &mut Buffers, off: usize, stride: usize, #[allow(unused_variables)] fn apply_delta8x8p(bufs: &mut Buffers, off: usize, stride: usize, deltas: &[u8], topline: bool, first_line: bool) { - let mut dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 8 + stride)] } - else { &mut bufs.buf2[off..(off + 8 + stride)] }; + let dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 8 + stride)] } + else { &mut bufs.buf2[off..(off + 8 + stride)] }; for i in 0..8 { dst[i] = dst[i] .wrapping_add(deltas[i >> 1]) & 0x7F; } for i in 0..8 { dst[i + stride] = dst[i + stride].wrapping_add(deltas[i >> 1]) & 0x7F; } } fn apply_delta8x8i(bufs: &mut Buffers, off: usize, stride: usize, deltas: &[u8], topline: bool, firstline: bool) { - let mut dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 8 + stride)] } - else { &mut bufs.buf2[off..(off + 8 + stride)] }; + let dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 8 + stride)] } + else { &mut bufs.buf2[off..(off + 8 + stride)] }; if !firstline { for i in 0..8 { dst[i + stride] = dst[i ].wrapping_add(deltas[i >> 1]) & 0x7F; } } else { @@ -183,8 +183,8 @@ fn copy_line_top(bufs: &mut Buffers, off: usize, stride: usize, bw: usize, topli } else { for i in 0..bw { buf[i] = DEFAULT_PIXEL; } } - let mut dst = if bufs.fbuf { &mut bufs.buf1[off..(off + bw)] } - else { &mut bufs.buf2[off..(off + bw)] }; + let dst = if bufs.fbuf { &mut bufs.buf1[off..(off + bw)] } + else { &mut bufs.buf2[off..(off + bw)] }; for i in 0..bw { dst[i] = buf[i]; } } @@ -206,8 +206,8 @@ fn copy_line_top8x8(bufs: &mut Buffers, off: usize, stride: usize, topline: bool } else { for i in 0..8 { buf[i] = DEFAULT_PIXEL; } } - let mut dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 8)] } - else { &mut bufs.buf2[off..(off + 8)] }; + let dst = if bufs.fbuf { &mut bufs.buf1[off..(off + 8)] } + else { &mut bufs.buf2[off..(off + 8)] }; for i in 0..8 {dst[i] = buf[i]; } } diff --git a/src/demuxers/gdv.rs b/src/demuxers/gdv.rs index cf04140..16eae33 100644 --- a/src/demuxers/gdv.rs +++ b/src/demuxers/gdv.rs @@ -147,7 +147,7 @@ pktdta: Vec::new(), fn read_vchunk(&mut self, strmgr: &mut StreamManager) -> DemuxerResult { let str = strmgr.get_stream(self.v_id.unwrap()).unwrap(); - let mut src = &mut self.src; + let src = &mut self.src; let magic = src.read_u16be()?; if magic != 0x0513 { return Err(DemuxerError::InvalidData); } let size = (src.read_u16le()? as usize) + 4; diff --git a/src/demuxers/mod.rs b/src/demuxers/mod.rs index dad9246..c122a03 100644 --- a/src/demuxers/mod.rs +++ b/src/demuxers/mod.rs @@ -38,7 +38,7 @@ impl<'a> NAPacketReader for ByteReader<'a> { } fn fill_packet(&mut self, pkt: &mut NAPacket) -> DemuxerResult<()> { let mut refbuf = pkt.get_buffer(); - let mut buf = Rc::make_mut(&mut refbuf); + let buf = Rc::make_mut(&mut refbuf); let res = self.read_buf(buf.as_mut_slice()); if let Err(_) = res { return Err(DemuxerError::IOError); } Ok(()) diff --git a/src/demuxers/realmedia.rs b/src/demuxers/realmedia.rs index 144153b..042b903 100644 --- a/src/demuxers/realmedia.rs +++ b/src/demuxers/realmedia.rs @@ -45,7 +45,7 @@ impl RMVideoStream { } fn add_slice(&mut self, slice_no: usize, data: &[u8]) { self.write_slice_info(slice_no); - let mut dslice = &mut self.frame[self.hdr_size + self.frame_pos..][..data.len()]; + let dslice = &mut self.frame[self.hdr_size + self.frame_pos..][..data.len()]; dslice.copy_from_slice(data); self.frame_pos += data.len(); } diff --git a/src/io/byteio.rs b/src/io/byteio.rs index f481693..ca591ac 100644 --- a/src/io/byteio.rs +++ b/src/io/byteio.rs @@ -166,7 +166,7 @@ impl<'a> ByteReader<'a> { } else { let mut ssize = len; let mut buf : [u8; 16] = [0; 16]; - let mut bref = &mut buf; + let bref = &mut buf; while ssize > bref.len() { self.io.read_buf(bref)?; ssize -= bref.len(); -- 2.39.5