Commit d9158388 authored by Raphaël Zumer's avatar Raphaël Zumer

Remove unnecessary "mut"s

parent dd4ec230
......@@ -229,7 +229,7 @@ pub fn cdef_analyze_superblock(in_frame: &mut Frame,
if !skip {
let mut var: i32 = 0;
let mut in_plane = &mut in_frame.planes[0];
let in_plane = &mut in_frame.planes[0];
let in_po = sbo.plane_offset(&in_plane.cfg);
let in_stride = in_plane.cfg.stride;
let in_slice = &in_plane.mut_slice(&in_po);
......@@ -282,13 +282,13 @@ pub fn cdef_sb_padded_frame_copy(fi: &FrameInvariants, sbo: &SuperBlockOffset,
let offset = sbo.plane_offset(&f.planes[p].cfg);
for y in 0..((sb_size>>ydec) + pad*2) as isize {
let mut out_slice = out.planes[p].mut_slice(&PlaneOffset {x:0, y});
let mut out_row = out_slice.as_mut_slice();
let out_row = out_slice.as_mut_slice();
if offset.y + y < ipad || offset.y+y >= h + ipad {
// above or below the frame, fill with flag
for x in 0..(sb_size>>xdec) + pad*2 { out_row[x] = CDEF_VERY_LARGE; }
} else {
let mut in_slice = f.planes[p].slice(&PlaneOffset {x:0, y:offset.y + y - ipad});
let mut in_row = in_slice.as_slice();
let in_slice = f.planes[p].slice(&PlaneOffset {x:0, y:offset.y + y - ipad});
let in_row = in_slice.as_slice();
// are we guaranteed to be all in frame this row?
if offset.x < ipad || offset.x + (sb_size as isize >>xdec) + ipad >= w {
// No; do it the hard way. off left or right edge, fill with flag.
......@@ -350,9 +350,9 @@ pub fn cdef_filter_superblock(fi: &FrameInvariants,
let dir = cdef_dirs.dir[bx][by];
let var = cdef_dirs.var[bx][by];
for p in 0..3 {
let mut out_plane = &mut out_frame.planes[p];
let out_plane = &mut out_frame.planes[p];
let out_po = sbo.plane_offset(&out_plane.cfg);
let mut in_plane = &mut in_frame.planes[p];
let in_plane = &mut in_frame.planes[p];
let in_po = sbo.plane_offset(&in_plane.cfg);
let xdec = in_plane.cfg.xdec;
let ydec = in_plane.cfg.ydec;
......@@ -360,12 +360,12 @@ pub fn cdef_filter_superblock(fi: &FrameInvariants,
let in_stride = in_plane.cfg.stride;
let in_slice = &in_plane.mut_slice(&in_po);
let out_stride = out_plane.cfg.stride;
let mut out_slice = &mut out_plane.mut_slice(&out_po);
let out_slice = &mut out_plane.mut_slice(&out_po);
let mut local_pri_strength;
let mut local_sec_strength;
let local_pri_strength;
let local_sec_strength;
let mut local_damping: i32 = cdef_damping + coeff_shift;
let mut local_dir: usize;
let local_dir: usize;
if p==0 {
local_pri_strength = adjust_strength(cdef_pri_y_strength << coeff_shift, var);
......@@ -427,14 +427,14 @@ pub fn cdef_filter_frame(fi: &FrameInvariants, rec: &mut Frame, bc: &mut BlockCo
// pad first two elements of current row
{
let mut cdef_slice = cdef_frame.planes[p].mut_slice(&PlaneOffset { x: 0, y: row as isize });
let mut cdef_row = &mut cdef_slice.as_mut_slice()[..2];
let cdef_row = &mut cdef_slice.as_mut_slice()[..2];
cdef_row[0] = CDEF_VERY_LARGE;
cdef_row[1] = CDEF_VERY_LARGE;
}
// pad out end of current row
{
let mut cdef_slice = cdef_frame.planes[p].mut_slice(&PlaneOffset { x: rec_w as isize + 2, y: row as isize });
let mut cdef_row = &mut cdef_slice.as_mut_slice()[..padded_px[p][0]-rec_w-2];
let cdef_row = &mut cdef_slice.as_mut_slice()[..padded_px[p][0]-rec_w-2];
for x in cdef_row {
*x = CDEF_VERY_LARGE;
}
......@@ -442,7 +442,7 @@ pub fn cdef_filter_frame(fi: &FrameInvariants, rec: &mut Frame, bc: &mut BlockCo
// copy current row from rec if we're in data, or pad if we're in first two rows/last N rows
{
let mut cdef_slice = cdef_frame.planes[p].mut_slice(&PlaneOffset { x: 2, y: row as isize });
let mut cdef_row = &mut cdef_slice.as_mut_slice()[..rec_w];
let cdef_row = &mut cdef_slice.as_mut_slice()[..rec_w];
if row < 2 || row >= rec_h+2 {
for x in cdef_row {
*x = CDEF_VERY_LARGE;
......
......@@ -806,13 +806,13 @@ impl CDFContext {
($field:expr) => (let r = $field.last_mut().unwrap(); *r = 0;)
}
macro_rules! reset_2d {
($field:expr) => (for mut x in $field.iter_mut() { reset_1d!(x); })
($field:expr) => (for x in $field.iter_mut() { reset_1d!(x); })
}
macro_rules! reset_3d {
($field:expr) => (for mut x in $field.iter_mut() { reset_2d!(x); })
($field:expr) => (for x in $field.iter_mut() { reset_2d!(x); })
}
macro_rules! reset_4d {
($field:expr) => (for mut x in $field.iter_mut() { reset_3d!(x); })
($field:expr) => (for x in $field.iter_mut() { reset_3d!(x); })
}
for i in 0..4 { self.partition_cdf[i][4] = 0; }
......
......@@ -87,7 +87,7 @@ fn sgrproj_box_ab(af: &mut[i32; 64+2],
let mut b:i32 = 0;
for yi in stripe_y+row-r..=stripe_y+row+r {
let mut src_plane: &Plane;
let src_plane: &Plane;
let ly;
if yi < stripe_y {
ly = cmp::max(cmp::max(yi, 0), stripe_y - 2) as usize;
......@@ -208,11 +208,11 @@ fn sgrproj_stripe_rdu(set: u8, xqd: [i8; 2], fi: &FrameInvariants,
stripe_x as isize, stripe_y,
cdeffed, deblocked, fi.sequence.bit_depth);
}
/* iterate by column */
let start = cmp::max(0, -stripe_y) as usize;
let cdeffed_slice = cdeffed.slice(&PlaneOffset{x: stripe_x as isize, y: stripe_y});
let outstride = out.cfg.stride;
let outstride = out.cfg.stride;
let mut out_slice = out.mut_slice(&PlaneOffset{x: stripe_x as isize, y: stripe_y});
let out_data = out_slice.as_mut_slice();
for xi in 0..stripe_w {
......@@ -267,7 +267,7 @@ fn sgrproj_stripe_rdu(set: u8, xqd: [i8; 2], fi: &FrameInvariants,
let v = w*u + w2*f1[yi];
let s = v + (1 << SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS >> 1) >> SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS;
out_data[xi + yi*outstride] = clamp(s as u16, 0, (1 << bit_depth) - 1);
}
}
}
}
}
......@@ -282,7 +282,7 @@ fn wiener_stripe_rdu(coeffs: [[i8; 3]; 2], fi: &FrameInvariants,
let round_v = if bit_depth == 12 {9} else {11};
let offset = 1 << bit_depth + WIENER_BITS - round_h - 1;
let limit = (1 << bit_depth + 1 + WIENER_BITS - round_h) - 1;
let mut work: [i32; MAX_SB_SIZE+7] = [0; MAX_SB_SIZE+7];
let vfilter: [i32; 7] = [ coeffs[0][0] as i32,
coeffs[0][1] as i32,
......@@ -312,7 +312,7 @@ fn wiener_stripe_rdu(coeffs: [[i8; 3]; 2], fi: &FrameInvariants,
} else {
stripe_h - start_wi as isize
}) as usize;
let stride = out.cfg.stride;
let mut out_slice = out.mut_slice(&PlaneOffset{x: 0, y: start_yi as isize});
let out_data = out_slice.as_mut_slice();
......@@ -320,7 +320,7 @@ fn wiener_stripe_rdu(coeffs: [[i8; 3]; 2], fi: &FrameInvariants,
for xi in stripe_x..stripe_x+stripe_w {
let n = cmp::min(7, crop_w as isize + 3 - xi as isize);
for yi in stripe_y-3..stripe_y+stripe_h+4 {
let mut src_plane: &Plane;
let src_plane: &Plane;
let mut acc = 0;
let ly;
if yi < stripe_y {
......@@ -333,7 +333,7 @@ fn wiener_stripe_rdu(coeffs: [[i8; 3]; 2], fi: &FrameInvariants,
ly = cmp::min(clamp(yi, 0, crop_h as isize - 1), stripe_y + stripe_h + 1) as usize;
src_plane = deblocked;
}
for i in 0..3 - xi as isize {
acc += hfilter[i as usize] * src_plane.p(0, ly) as i32;
}
......@@ -343,7 +343,7 @@ fn wiener_stripe_rdu(coeffs: [[i8; 3]; 2], fi: &FrameInvariants,
for i in n..7 {
acc += hfilter[i as usize] * src_plane.p(crop_w - 1, ly) as i32;
}
acc = acc + (1 << round_h >> 1) >> round_h;
work[(yi-stripe_y+3) as usize] = clamp(acc, -offset, limit-offset);
}
......@@ -498,7 +498,7 @@ impl RestorationState {
pub fn lrf_filter_frame(&mut self, out: &mut Frame, pre_cdef: &Frame,
fi: &FrameInvariants) {
let cdeffed = out.clone();
// unlike the other loop filters that operate over the padded
// frame dimensions, restoration filtering and source pixel
// accesses are clipped to the original frame dimensions
......@@ -506,19 +506,19 @@ impl RestorationState {
// number of stripes (counted according to colocated Y luma position)
let stripe_n = (fi.height + 7) / 64 + 1;
for pli in 0..PLANES {
let rp = &self.plane[pli];
let xdec = out.planes[pli].cfg.xdec;
let ydec = out.planes[pli].cfg.ydec;
let crop_w = fi.width + (1 << xdec >> 1) >> xdec;
let crop_h = fi.height + (1 << ydec >> 1) >> ydec;
for si in 0..stripe_n {
// stripe y pixel locations must be able to overspan the frame
let stripe_start_y = si as isize * 64 - 8 >> ydec;
let stripe_size = 64 >> ydec; // one past, unlike spec
// horizontally, go rdu-by-rdu
for rux in 0..rp.cols {
// stripe x pixel locations must be clipped to frame, last may need to stretch
......@@ -530,7 +530,7 @@ impl RestorationState {
};
let ru = rp.restoration_unit_by_stripe(si, rux);
match ru.filter {
RestorationFilter::Wiener{coeffs} => {
RestorationFilter::Wiener{coeffs} => {
wiener_stripe_rdu(coeffs, fi,
crop_w, crop_h,
ru_size, stripe_size,
......@@ -552,6 +552,6 @@ impl RestorationState {
}
}
}
}
}
}
}
......@@ -194,7 +194,7 @@ impl Plane {
for row in 0..height {
let mut dst_slice = self.mut_slice(&PlaneOffset{ x: 0, y: row as isize });
let mut dst = dst_slice.as_mut_slice();
let dst = dst_slice.as_mut_slice();
for col in 0..width {
let mut sum = 0;
......
......@@ -717,7 +717,7 @@ pub fn rdo_mode_decision(fi: &FrameInvariants, fs: &mut FrameState,
);
cw.rollback(&cw_checkpoint);
if let Some(cfl) = rdo_cfl_alpha(fs, bo, bsize, fi.sequence.bit_depth, fi.sequence.chroma_sampling) {
let mut wr: &mut dyn Writer = &mut WriterCounter::new();
let wr: &mut dyn Writer = &mut WriterCounter::new();
let tell = wr.tell_frac();
encode_block_a(&fi.sequence, fs, cw, wr, bsize, bo, best.skip);
......@@ -864,7 +864,7 @@ pub fn rdo_tx_type_decision(
motion_compensate(fi, fs, cw, mode, ref_frames, mvs, bsize, bo, true);
}
let mut wr: &mut dyn Writer = &mut WriterCounter::new();
let wr: &mut dyn Writer = &mut WriterCounter::new();
let tell = wr.tell_frac();
let tx_dist = if is_inter {
write_tx_tree(
......@@ -1129,11 +1129,11 @@ pub fn rdo_cdef_decision(sbo: &SuperBlockOffset, fi: &FrameInvariants,
let skip = bc.at(&bo).skip;
if !skip {
for p in 0..3 {
let mut in_plane = &fs.input.planes[p];
let in_plane = &fs.input.planes[p];
let in_po = sbo.block_offset(bx<<1, by<<1).plane_offset(&in_plane.cfg);
let in_slice = in_plane.slice(&in_po);
let mut out_plane = &mut cdef_output.planes[p];
let out_plane = &mut cdef_output.planes[p];
let out_po = sbo_0.block_offset(bx<<1, by<<1).plane_offset(&out_plane.cfg);
let out_slice = &out_plane.slice(&out_po);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment