Commit 93151ecc authored by Romain Vimont's avatar Romain Vimont Committed by Luca Barbato

Make PlaneOffset derive Copy

Like previous commits did for BlockOffset and SuperBlockOffset.
parent 32effc32
......@@ -82,7 +82,7 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
tx_size,
tx_type,
tx_size.block_size(),
&po,
po,
false,
ac,
0,
......
......@@ -44,8 +44,8 @@ fn bench_get_sad(b: &mut Bencher, bs: &BlockSize) {
let rec_plane = new_plane::<u16>(&mut ra, w, h);
let po = PlaneOffset { x: 0, y: 0 };
let plane_org = input_plane.slice(&po);
let plane_ref = rec_plane.slice(&po);
let plane_org = input_plane.slice(po);
let plane_ref = rec_plane.slice(po);
b.iter(|| {
let _ =
......
......@@ -230,7 +230,7 @@ pub fn cdef_analyze_superblock<T: Pixel>(
let mut var: i32 = 0;
let in_plane = &in_frame.planes[0];
let in_po = sbo.plane_offset(&in_plane.cfg);
let in_slice = in_plane.slice(&in_po);
let in_slice = in_plane.slice(in_po);
dir.dir[bx][by] = cdef_find_dir(&in_slice.reslice(8 * bx as isize + 2,
8 * by as isize + 2),
&mut var, coeff_shift) as u8;
......@@ -290,7 +290,7 @@ pub fn cdef_sb_padded_frame_copy<T: Pixel>(
out_row[x] = CDEF_VERY_LARGE;
}
} else {
let in_slice = f.planes[p].slice(&PlaneOffset {x:0, y:offset.y - ipad});
let in_slice = f.planes[p].slice(PlaneOffset {x:0, y:offset.y - ipad});
let in_row = &in_slice[y as usize];
// are we guaranteed to be all in frame this row?
if offset.x < ipad || offset.x + (sb_size as isize >>xdec) + ipad >= w {
......@@ -374,9 +374,9 @@ pub fn cdef_filter_superblock<T: Pixel>(
let ydec = in_plane.cfg.ydec;
let in_stride = in_plane.cfg.stride;
let in_slice = &in_plane.slice(&in_po);
let in_slice = &in_plane.slice(in_po);
let out_stride = out_plane.cfg.stride;
let out_slice = &mut out_plane.mut_slice(&out_po);
let out_slice = &mut out_plane.mut_slice(out_po);
let local_pri_strength;
let local_sec_strength;
......
......@@ -1036,7 +1036,7 @@ fn filter_v_edge<T: Pixel>(
let level = deblock_level(deblock, block, prev_block, pli, true);
if level > 0 {
let po = bo.plane_offset(&p.cfg);
let mut plane_slice = p.mut_slice(&po);
let mut plane_slice = p.mut_slice(po);
plane_slice.x -= (filter_size >> 1) as isize;
match filter_size {
4 => {
......@@ -1075,8 +1075,8 @@ fn sse_v_edge<T: Pixel>(
po.x -= (filter_size >> 1) as isize;
po
};
let rec_slice = rec_plane.slice(&po);
let src_slice = src_plane.slice(&po);
let rec_slice = rec_plane.slice(po);
let src_slice = src_plane.slice(po);
match filter_size {
4 => {
sse_size4(
......@@ -1139,7 +1139,7 @@ fn filter_h_edge<T: Pixel>(
let level = deblock_level(deblock, block, prev_block, pli, false);
if level > 0 {
let po = bo.plane_offset(&p.cfg);
let mut plane_slice = p.mut_slice(&po);
let mut plane_slice = p.mut_slice(po);
plane_slice.y -= (filter_size >> 1) as isize;
match filter_size {
4 => {
......@@ -1178,8 +1178,8 @@ fn sse_h_edge<T: Pixel>(
po.x -= (filter_size >> 1) as isize;
po
};
let rec_slice = rec_plane.slice(&po);
let src_slice = src_plane.slice(&po);
let rec_slice = rec_plane.slice(po);
let src_slice = src_plane.slice(po);
match filter_size {
4 => {
sse_size4(
......
......@@ -953,7 +953,7 @@ fn get_qidx<T: Pixel>(fi: &FrameInvariants<T>, fs: &FrameState<T>, cw: &ContextW
pub fn encode_tx_block<T: Pixel>(
fi: &FrameInvariants<T>, fs: &mut FrameState<T>, cw: &mut ContextWriter,
w: &mut dyn Writer, p: usize, bo: BlockOffset, mode: PredictionMode,
tx_size: TxSize, tx_type: TxType, plane_bsize: BlockSize, po: &PlaneOffset,
tx_size: TxSize, tx_type: TxType, plane_bsize: BlockSize, po: PlaneOffset,
skip: bool, ac: &[i16], alpha: i16, rdo_type: RDOType, for_rdo_use: bool
) -> (bool, i64) {
let qidx = get_qidx(fi, fs, cw, bo);
......@@ -1068,7 +1068,7 @@ pub fn motion_compensate<T: Pixel>(
some_use_intra |= cw.bc.at(bo.with_offset(-1,-1)).mode.is_intra(); };
if some_use_intra {
luma_mode.predict_inter(fi, p, &po, &mut rec.mut_slice(&po), plane_bsize.width(),
luma_mode.predict_inter(fi, p, po, &mut rec.mut_slice(po), plane_bsize.width(),
plane_bsize.height(), ref_frames, mvs);
} else {
assert!(xdec == 1 && ydec == 1);
......@@ -1083,28 +1083,28 @@ pub fn motion_compensate<T: Pixel>(
let rf2 = cw.bc.at(bo.with_offset(-1,0)).ref_frames;
let po2 = PlaneOffset { x: po.x, y: po.y+2 };
let po3 = PlaneOffset { x: po.x+2, y: po.y+2 };
luma_mode.predict_inter(fi, p, &po, &mut rec.mut_slice(&po), 2, 2, rf0, mv0);
luma_mode.predict_inter(fi, p, &po1, &mut rec.mut_slice(&po1), 2, 2, rf1, mv1);
luma_mode.predict_inter(fi, p, &po2, &mut rec.mut_slice(&po2), 2, 2, rf2, mv2);
luma_mode.predict_inter(fi, p, &po3, &mut rec.mut_slice(&po3), 2, 2, ref_frames, mvs);
luma_mode.predict_inter(fi, p, po, &mut rec.mut_slice(po), 2, 2, rf0, mv0);
luma_mode.predict_inter(fi, p, po1, &mut rec.mut_slice(po1), 2, 2, rf1, mv1);
luma_mode.predict_inter(fi, p, po2, &mut rec.mut_slice(po2), 2, 2, rf2, mv2);
luma_mode.predict_inter(fi, p, po3, &mut rec.mut_slice(po3), 2, 2, ref_frames, mvs);
}
if bsize == BlockSize::BLOCK_8X4 {
let mv1 = cw.bc.at(bo.with_offset(0,-1)).mv;
let rf1 = cw.bc.at(bo.with_offset(0,-1)).ref_frames;
luma_mode.predict_inter(fi, p, &po, &mut rec.mut_slice(&po), 4, 2, rf1, mv1);
luma_mode.predict_inter(fi, p, po, &mut rec.mut_slice(po), 4, 2, rf1, mv1);
let po3 = PlaneOffset { x: po.x, y: po.y+2 };
luma_mode.predict_inter(fi, p, &po3, &mut rec.mut_slice(&po3), 4, 2, ref_frames, mvs);
luma_mode.predict_inter(fi, p, po3, &mut rec.mut_slice(po3), 4, 2, ref_frames, mvs);
}
if bsize == BlockSize::BLOCK_4X8 {
let mv2 = cw.bc.at(bo.with_offset(-1,0)).mv;
let rf2 = cw.bc.at(bo.with_offset(-1,0)).ref_frames;
luma_mode.predict_inter(fi, p, &po, &mut rec.mut_slice(&po), 2, 4, rf2, mv2);
luma_mode.predict_inter(fi, p, po, &mut rec.mut_slice(po), 2, 4, rf2, mv2);
let po3 = PlaneOffset { x: po.x+2, y: po.y };
luma_mode.predict_inter(fi, p, &po3, &mut rec.mut_slice(&po3), 2, 4, ref_frames, mvs);
luma_mode.predict_inter(fi, p, po3, &mut rec.mut_slice(po3), 2, 4, ref_frames, mvs);
}
}
} else {
luma_mode.predict_inter(fi, p, &po, &mut rec.mut_slice(&po), plane_bsize.width(),
luma_mode.predict_inter(fi, p, po, &mut rec.mut_slice(po), plane_bsize.width(),
plane_bsize.height(), ref_frames, mvs);
}
}
......@@ -1306,7 +1306,7 @@ pub fn luma_ac<T: Pixel>(
bo.plane_offset(&fs.input.planes[0].cfg)
};
let rec = &fs.rec.planes[0];
let luma = &rec.slice(&po);
let luma = &rec.slice(po);
let mut sum: i32 = 0;
for sub_y in 0..plane_bsize.height() {
......@@ -1359,7 +1359,7 @@ pub fn write_tx_blocks<T: Pixel>(
let po = tx_bo.plane_offset(&fs.input.planes[0].cfg);
let (_, dist) =
encode_tx_block(
fi, fs, cw, w, 0, tx_bo, luma_mode, tx_size, tx_type, bsize, &po,
fi, fs, cw, w, 0, tx_bo, luma_mode, tx_size, tx_type, bsize, po,
skip, &ac.array, 0, rdo_type, for_rdo_use
);
assert!(!fi.use_tx_domain_distortion || !for_rdo_use || skip || dist >= 0);
......@@ -1413,7 +1413,7 @@ pub fn write_tx_blocks<T: Pixel>(
po.y += (by * uv_tx_size.height()) as isize;
let (_, dist) =
encode_tx_block(fi, fs, cw, w, p, tx_bo, chroma_mode, uv_tx_size, uv_tx_type,
plane_bsize, &po, skip, &ac.array, alpha, rdo_type, for_rdo_use);
plane_bsize, po, skip, &ac.array, alpha, rdo_type, for_rdo_use);
assert!(!fi.use_tx_domain_distortion || !for_rdo_use || skip || dist >= 0);
tx_dist += dist;
}
......@@ -1444,7 +1444,7 @@ pub fn write_tx_tree<T: Pixel>(
let po = bo.plane_offset(&fs.input.planes[0].cfg);
let (has_coeff, dist) = encode_tx_block(
fi, fs, cw, w, 0, bo, luma_mode, tx_size, tx_type, bsize, &po, skip, ac, 0, rdo_type, for_rdo_use
fi, fs, cw, w, 0, bo, luma_mode, tx_size, tx_type, bsize, po, skip, ac, 0, rdo_type, for_rdo_use
);
assert!(!fi.use_tx_domain_distortion || !for_rdo_use || skip || dist >= 0);
tx_dist += dist;
......@@ -1479,7 +1479,7 @@ pub fn write_tx_tree<T: Pixel>(
let po = bo.plane_offset(&fs.input.planes[p].cfg);
let (_, dist) =
encode_tx_block(fi, fs, cw, w, p, tx_bo, luma_mode, uv_tx_size, uv_tx_type,
plane_bsize, &po, skip, ac, 0, rdo_type, for_rdo_use);
plane_bsize, po, skip, ac, 0, rdo_type, for_rdo_use);
assert!(!fi.use_tx_domain_distortion || !for_rdo_use || skip || dist >= 0);
tx_dist += dist;
}
......
......@@ -732,7 +732,7 @@ fn wiener_stripe_filter<T: Pixel>(coeffs: [[i8; 3]; 2], fi: &FrameInvariants<T>,
stripe_h as isize - start_wi as isize
}) as usize;
let mut out_slice = out.mut_slice(&PlaneOffset{x: 0, y: start_yi as isize});
let mut out_slice = out.mut_slice(PlaneOffset{x: 0, y: start_yi as isize});
for xi in stripe_x..stripe_x+stripe_w {
let n = cmp::min(7, crop_w as isize + 3 - xi as isize);
......@@ -958,11 +958,11 @@ impl RestorationState {
crop_w - x,
(crop_h as isize - stripe_start_y) as usize,
size, stripe_size,
&cdeffed.planes[pli].slice(&PlaneOffset{x: x as isize,
&cdeffed.planes[pli].slice(PlaneOffset{x: x as isize,
y: stripe_start_y}),
&pre_cdef.planes[pli].slice(&PlaneOffset{x: x as isize,
&pre_cdef.planes[pli].slice(PlaneOffset{x: x as isize,
y: stripe_start_y}),
&mut out.planes[pli].mut_slice(&PlaneOffset{x: x as isize,
&mut out.planes[pli].mut_slice(PlaneOffset{x: x as isize,
y: stripe_start_y}));
},
RestorationFilter::None => {
......
......@@ -337,7 +337,7 @@ pub fn get_subset_predictors<T: Pixel>(
pub trait MotionEstimation {
fn full_pixel_me<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, rec: &Arc<ReferenceFrame<T>>, po: &PlaneOffset,
fi: &FrameInvariants<T>, fs: &FrameState<T>, rec: &Arc<ReferenceFrame<T>>, po: PlaneOffset,
bo: BlockOffset, lambda: u32,
cmv: MotionVector, pmv: [MotionVector; 2],
mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize,
......@@ -346,7 +346,7 @@ pub trait MotionEstimation {
);
fn sub_pixel_me<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, rec: &Arc<ReferenceFrame<T>>, po: &PlaneOffset,
fi: &FrameInvariants<T>, fs: &FrameState<T>, rec: &Arc<ReferenceFrame<T>>, po: PlaneOffset,
bo: BlockOffset, lambda: u32, pmv: [MotionVector; 2],
mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize,
blk_w: usize, blk_h: usize, best_mv: &mut MotionVector,
......@@ -379,12 +379,12 @@ pub trait MotionEstimation {
let mut lowest_cost = std::u64::MAX;
let mut best_mv = MotionVector::default();
Self::full_pixel_me(fi, fs, rec, &po, bo, lambda, cmv, pmv,
Self::full_pixel_me(fi, fs, rec, po, bo, lambda, cmv, pmv,
mvx_min, mvx_max, mvy_min, mvy_max, blk_w, blk_h,
&mut best_mv, &mut lowest_cost, ref_frame);
let tmp_plane = Plane::new(blk_w, blk_h, 0, 0, 0, 0);
Self::sub_pixel_me(fi, fs, rec, &po, bo, lambda, pmv,
Self::sub_pixel_me(fi, fs, rec, po, bo, lambda, pmv,
mvx_min, mvx_max, mvy_min, mvy_max, blk_w, blk_h,
&mut best_mv, &mut lowest_cost, ref_frame,
tmp_plane, bsize);
......@@ -452,7 +452,7 @@ pub struct FullSearch {}
impl MotionEstimation for DiamondSearch {
fn full_pixel_me<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, rec: &Arc<ReferenceFrame<T>>,
po: &PlaneOffset, bo: BlockOffset, lambda: u32,
po: PlaneOffset, bo: BlockOffset, lambda: u32,
cmv: MotionVector, pmv: [MotionVector; 2], mvx_min: isize, mvx_max: isize,
mvy_min: isize, mvy_max: isize, blk_w: usize, blk_h: usize,
best_mv: &mut MotionVector, lowest_cost: &mut u64, ref_frame: usize
......@@ -464,7 +464,7 @@ impl MotionEstimation for DiamondSearch {
diamond_me_search(
fi,
&po,
po,
&fs.input.planes[0],
&rec.frame.planes[0],
&predictors,
......@@ -486,7 +486,7 @@ impl MotionEstimation for DiamondSearch {
fn sub_pixel_me<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, rec: &Arc<ReferenceFrame<T>>,
po: &PlaneOffset, _bo: BlockOffset, lambda: u32,
po: PlaneOffset, _bo: BlockOffset, lambda: u32,
pmv: [MotionVector; 2], mvx_min: isize, mvx_max: isize,
mvy_min: isize, mvy_max: isize, blk_w: usize, blk_h: usize,
best_mv: &mut MotionVector, lowest_cost: &mut u64, ref_frame: usize,
......@@ -496,7 +496,7 @@ impl MotionEstimation for DiamondSearch {
let predictors = vec![*best_mv];
diamond_me_search(
fi,
&po,
po,
&fs.input.planes[0],
&rec.frame.planes[0],
&predictors,
......@@ -541,7 +541,7 @@ impl MotionEstimation for DiamondSearch {
}
diamond_me_search(
fi, &po,
fi, po,
&fs.input_hres, &rec.input_hres,
&predictors, fi.sequence.bit_depth,
global_mv, lambda,
......@@ -558,7 +558,7 @@ impl MotionEstimation for DiamondSearch {
impl MotionEstimation for FullSearch {
fn full_pixel_me<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, rec: &Arc<ReferenceFrame<T>>,
po: &PlaneOffset, _bo: BlockOffset, lambda: u32,
po: PlaneOffset, _bo: BlockOffset, lambda: u32,
cmv: MotionVector, pmv: [MotionVector; 2], mvx_min: isize, mvx_max: isize,
mvy_min: isize, mvy_max: isize, blk_w: usize, blk_h: usize,
best_mv: &mut MotionVector, lowest_cost: &mut u64, _ref_frame: usize
......@@ -584,7 +584,7 @@ impl MotionEstimation for FullSearch {
&rec.frame.planes[0],
best_mv,
lowest_cost,
&po,
po,
2,
fi.sequence.bit_depth,
lambda,
......@@ -595,7 +595,7 @@ impl MotionEstimation for FullSearch {
fn sub_pixel_me<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, _rec: &Arc<ReferenceFrame<T>>,
po: &PlaneOffset, _bo: BlockOffset, lambda: u32,
po: PlaneOffset, _bo: BlockOffset, lambda: u32,
pmv: [MotionVector; 2], mvx_min: isize, mvx_max: isize,
mvy_min: isize, mvy_max: isize, _blk_w: usize, _blk_h: usize,
best_mv: &mut MotionVector, lowest_cost: &mut u64, ref_frame: usize,
......@@ -606,7 +606,7 @@ impl MotionEstimation for FullSearch {
fi,
fs,
bsize,
&po,
po,
lambda,
ref_frame,
pmv,
......@@ -648,7 +648,7 @@ impl MotionEstimation for FullSearch {
&rec.input_hres,
best_mv,
lowest_cost,
&po,
po,
1,
fi.sequence.bit_depth,
lambda,
......@@ -662,7 +662,7 @@ impl MotionEstimation for FullSearch {
fn get_best_predictor<T: Pixel>(
fi: &FrameInvariants<T>,
po: &PlaneOffset, p_org: &Plane<T>, p_ref: &Plane<T>,
po: PlaneOffset, p_org: &Plane<T>, p_ref: &Plane<T>,
predictors: &[MotionVector],
bit_depth: usize, pmv: [MotionVector; 2], lambda: u32,
mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize,
......@@ -687,7 +687,7 @@ fn get_best_predictor<T: Pixel>(
fn diamond_me_search<T: Pixel>(
fi: &FrameInvariants<T>,
po: &PlaneOffset, p_org: &Plane<T>, p_ref: &Plane<T>,
po: PlaneOffset, p_org: &Plane<T>, p_ref: &Plane<T>,
predictors: &[MotionVector],
bit_depth: usize, pmv: [MotionVector; 2], lambda: u32,
mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize,
......@@ -724,7 +724,7 @@ fn diamond_me_search<T: Pixel>(
};
let rd_cost = get_mv_rd_cost(
fi, &po, p_org, p_ref, bit_depth,
fi, po, p_org, p_ref, bit_depth,
pmv, lambda, mvx_min, mvx_max, mvy_min, mvy_max,
blk_w, blk_h, cand_mv, tmp_plane_opt, ref_frame);
......@@ -752,7 +752,7 @@ fn diamond_me_search<T: Pixel>(
fn get_mv_rd_cost<T: Pixel>(
fi: &FrameInvariants<T>,
po: &PlaneOffset, p_org: &Plane<T>, p_ref: &Plane<T>, bit_depth: usize,
po: PlaneOffset, p_org: &Plane<T>, p_ref: &Plane<T>, bit_depth: usize,
pmv: [MotionVector; 2], lambda: u32,
mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize,
blk_w: usize, blk_h: usize,
......@@ -769,25 +769,25 @@ fn get_mv_rd_cost<T: Pixel>(
let plane_org = p_org.slice(po);
if let Some(ref mut tmp_plane) = tmp_plane_opt {
let mut tmp_slice = &mut tmp_plane.mut_slice(&PlaneOffset { x: 0, y: 0 });
let mut tmp_slice = &mut tmp_plane.mut_slice(PlaneOffset { x: 0, y: 0 });
PredictionMode::NEWMV.predict_inter(
fi,
0,
&po,
po,
&mut tmp_slice,
blk_w,
blk_h,
[ref_frame, NONE_FRAME],
[cand_mv, MotionVector { row: 0, col: 0 }]
);
let plane_ref = tmp_plane.slice(&PlaneOffset { x: 0, y: 0 });
let plane_ref = tmp_plane.slice(PlaneOffset { x: 0, y: 0 });
compute_mv_rd_cost(
fi, pmv, lambda, bit_depth, blk_w, blk_h, cand_mv,
&plane_org, &plane_ref
)
} else {
// Full pixel motion vector
let plane_ref = p_ref.slice(&PlaneOffset {
let plane_ref = p_ref.slice(PlaneOffset {
x: po.x + (cand_mv.col / 8) as isize,
y: po.y + (cand_mv.row / 8) as isize
});
......@@ -815,7 +815,7 @@ fn compute_mv_rd_cost<T: Pixel>(
}
fn telescopic_subpel_search<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, bsize: BlockSize, po: &PlaneOffset,
fi: &FrameInvariants<T>, fs: &FrameState<T>, bsize: BlockSize, po: PlaneOffset,
lambda: u32, ref_frame: usize, pmv: [MotionVector; 2],
mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize,
tmp_plane: &mut Plane<T>, best_mv: &mut MotionVector, lowest_cost: &mut u64
......@@ -853,12 +853,12 @@ fn telescopic_subpel_search<T: Pixel>(
{
let tmp_slice =
&mut tmp_plane.mut_slice(&PlaneOffset { x: 0, y: 0 });
&mut tmp_plane.mut_slice(PlaneOffset { x: 0, y: 0 });
mode.predict_inter(
fi,
0,
&po,
po,
tmp_slice,
blk_w,
blk_h,
......@@ -867,8 +867,8 @@ fn telescopic_subpel_search<T: Pixel>(
);
}
let plane_org = fs.input.planes[0].slice(&po);
let plane_ref = tmp_plane.slice(&PlaneOffset { x: 0, y: 0 });
let plane_org = fs.input.planes[0].slice(po);
let plane_ref = tmp_plane.slice(PlaneOffset { x: 0, y: 0 });
let sad = get_sad(&plane_org, &plane_ref, blk_h, blk_w, fi.sequence.bit_depth);
......@@ -889,7 +889,7 @@ fn telescopic_subpel_search<T: Pixel>(
fn full_search<T: Pixel>(
x_lo: isize, x_hi: isize, y_lo: isize, y_hi: isize, blk_h: usize,
blk_w: usize, p_org: &Plane<T>, p_ref: &Plane<T>, best_mv: &mut MotionVector,
lowest_cost: &mut u64, po: &PlaneOffset, step: usize, bit_depth: usize,
lowest_cost: &mut u64, po: PlaneOffset, step: usize, bit_depth: usize,
lambda: u32, pmv: [MotionVector; 2], allow_high_precision_mv: bool
) {
let search_range_y = (y_lo..=y_hi).step_by(step);
......@@ -898,7 +898,7 @@ fn full_search<T: Pixel>(
let (cost, mv) = search_area.map(|(y, x)| {
let plane_org = p_org.slice(po);
let plane_ref = p_ref.slice(&PlaneOffset { x, y });
let plane_ref = p_ref.slice(PlaneOffset { x, y });
let sad = get_sad(&plane_org, &plane_ref, blk_h, blk_w, bit_depth);
......@@ -980,7 +980,7 @@ pub fn estimate_motion_ss4<T: Pixel>(
&rec.input_qres,
&mut best_mv,
&mut lowest_cost,
&po,
po,
1,
fi.sequence.bit_depth,
lambda,
......@@ -1063,8 +1063,8 @@ pub mod test {
let bsh = block.0.height();
let po = PlaneOffset { x: 32, y: 40 };
let mut input_slice = input_plane.slice(&po);
let mut rec_slice = rec_plane.slice(&po);
let mut input_slice = input_plane.slice(po);
let mut rec_slice = rec_plane.slice(po);
assert_eq!(
block.1,
......
......@@ -1133,7 +1133,7 @@ impl PredictionMode {
}
pub fn predict_inter<T: Pixel>(
self, fi: &FrameInvariants<T>, p: usize, po: &PlaneOffset,
self, fi: &FrameInvariants<T>, p: usize, po: PlaneOffset,
dst: &mut PlaneMutSlice<'_, T>, width: usize, height: usize,
ref_frames: [usize; 2], mvs: [MotionVector; 2]
) {
......@@ -1144,7 +1144,7 @@ impl PredictionMode {
ref_frames[1] > INTRA_FRAME && ref_frames[1] != NONE_FRAME;
fn get_params<'a, T: Pixel>(
rec_plane: &'a Plane<T>, po: &PlaneOffset, mv: MotionVector
rec_plane: &'a Plane<T>, po: PlaneOffset, mv: MotionVector
) -> (i32, i32, PlaneSlice<'a, T>) {
let rec_cfg = &rec_plane.cfg;
let shift_row = 3 + rec_cfg.ydec;
......@@ -1159,7 +1159,7 @@ impl PredictionMode {
x: po.x + col_offset as isize - 3,
y: po.y + row_offset as isize - 3
};
(row_frac, col_frac, rec_plane.slice(&qo).clamp().subslice(3, 3))
(row_frac, col_frac, rec_plane.slice(qo).clamp().subslice(3, 3))
};
if !is_compound {
......
......@@ -32,7 +32,7 @@ pub struct PlaneConfig {
}
/// Absolute offset in pixels inside a plane
#[derive(Debug)]
#[derive(Clone, Copy, Debug)]
pub struct PlaneOffset {
pub x: isize,
pub y: isize
......@@ -248,24 +248,24 @@ impl<T: Pixel> Plane<T> {
}
}
pub fn slice(&self, po: &PlaneOffset) -> PlaneSlice<'_, T> {
pub fn slice(&self, po: PlaneOffset) -> PlaneSlice<'_, T> {
PlaneSlice { plane: self, x: po.x, y: po.y }
}
pub fn mut_slice(&mut self, po: &PlaneOffset) -> PlaneMutSlice<'_, T> {
pub fn mut_slice(&mut self, po: PlaneOffset) -> PlaneMutSlice<'_, T> {
PlaneMutSlice { plane: self, x: po.x, y: po.y }
}
pub fn as_slice(&self) -> PlaneSlice<'_, T> {
self.slice(&PlaneOffset { x: 0, y: 0 })
self.slice(PlaneOffset { x: 0, y: 0 })
}
pub fn as_mut_slice(&mut self) -> PlaneMutSlice<'_, T> {
self.mut_slice(&PlaneOffset { x: 0, y: 0 })
self.mut_slice(PlaneOffset { x: 0, y: 0 })
}
#[inline]
pub fn edged_slice(&self, po: &PlaneOffset, left_edge: usize, top_edge: usize) -> EdgedPlaneSlice<'_, T> {
pub fn edged_slice(&self, po: PlaneOffset, left_edge: usize, top_edge: usize) -> EdgedPlaneSlice<'_, T> {
debug_assert!(po.x >= 0);
debug_assert!(po.y >= 0);
let left_edge = left_edge.min(po.x as usize);
......@@ -274,7 +274,7 @@ impl<T: Pixel> Plane<T> {
x: po.x - left_edge as isize,
y: po.y - top_edge as isize,
};
EdgedPlaneSlice { ps: self.slice(&edged_po), left_edge, top_edge }
EdgedPlaneSlice { ps: self.slice(edged_po), left_edge, top_edge }
}
#[inline]
......
......@@ -257,8 +257,8 @@ fn compute_distortion<T: Pixel>(
let mut distortion = match fi.config.tune {
Tune::Psychovisual if w_y >= 8 && h_y >= 8 => {
cdef_dist_wxh(
&fs.input.planes[0].slice(&po),
&fs.rec.planes[0].slice(&po),
&fs.input.planes[0].slice(po),
&fs.rec.planes[0].slice(po),
w_y,
h_y,
fi.sequence.bit_depth
......@@ -266,8 +266,8 @@ fn compute_distortion<T: Pixel>(
}
Tune::Psnr | Tune::Psychovisual => {
sse_wxh(
&fs.input.planes[0].slice(&po),
&fs.rec.planes[0].slice(&po),
&fs.input.planes[0].slice(po),
&fs.rec.planes[0].slice(po),
w_y,
h_y
)
......@@ -292,8 +292,8 @@ fn compute_distortion<T: Pixel>(
let po = bo.plane_offset(&fs.input.planes[p].cfg);
distortion += sse_wxh(
&fs.input.planes[p].slice(&po),
&fs.rec.planes[p].slice(&po),
&fs.input.planes[p].slice(po),
&fs.rec.planes[p].slice(po),
w_uv,
h_uv
);
......@@ -314,8 +314,8 @@ fn compute_tx_distortion<T: Pixel>(
let po = bo.plane_offset(&fs.input.planes[0].cfg);
sse_wxh(
&fs.input.planes[0].slice(&po),
&fs.rec.planes[0].slice(&po),
&fs.input.planes[0].slice(po),
&fs.rec.planes[0].slice(po),
w_y,
h_y
)
......@@ -342,8 +342,8 @@ fn compute_tx_distortion<T: Pixel>(
let po = bo.plane_offset(&fs.input.planes[p].cfg);
distortion += sse_wxh(
&fs.input.planes[p].slice(&po),
&fs.rec.planes[p].slice(&po),
&fs.input.planes[p].slice(po),
&fs.rec.planes[p].slice(po),
w_uv,
h_uv
);
......@@ -722,7 +722,7 @@ pub fn rdo_mode_decision<T: Pixel>(
let rec = &mut fs.rec.planes[0];
let po = bo.plane_offset(&rec.cfg);
get_intra_edges(
&rec.edged_slice(&po, 1, 1),
&rec.edged_slice(po, 1, 1),
tx_size,
fi.sequence.bit_depth,
&fs.input.planes[0].cfg,
......@@ -735,7 +735,7 @@ pub fn rdo_mode_decision<T: Pixel>(
let rec = &mut fs.rec.planes[0];
let po = bo.plane_offset(&rec.cfg);
luma_mode.predict_intra(
&mut rec.mut_slice(&po),
&mut rec.mut_slice(po),
tx_size,
fi.sequence.bit_depth,
&[0i16; 2],
......@@ -743,8 +743,8 @@ pub fn rdo_mode_decision<T: Pixel>(
&edge_buf
);
let plane_org = fs.input.planes[0].slice(&po);
let plane_ref = rec.slice(&po);
let plane_org = fs.input.planes[0].slice(po);
let plane_ref = rec.slice(po);
(
luma_mode,
......@@ -907,14 +907,14 @@ pub fn rdo_cfl_alpha<T: Pixel>(
(-16i16..17i16)