Commit 42d96a36 authored by Romain Vimont's avatar Romain Vimont Committed by Luca Barbato

Make BlockOffset derive Copy

BlockOffset has a size of 128 bits (the same as a slice), and is
trivially copyable, so make it derive Copy.

Once it derives Copy, clippy suggests to never pass it by reference:
<https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref>

So pass it by value everywhere to simplify usage.

In particular, this avoids lifetimes bounds where not necessary (e.g.
in get_sub_partitions()).

See <https://github.com/xiph/rav1e/pull/1126#issuecomment-474532123>.
parent a3499ef0
......@@ -77,7 +77,7 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
&mut cw,
&mut w,
p,
&bo,
bo,
mode,
tx_size,
tx_type,
......@@ -143,7 +143,7 @@ fn cfl_rdo_bench(b: &mut Bencher, bsize: BlockSize) {
let fi = FrameInvariants::<u16>::new(config, sequence);
let mut fs = FrameState::new(&fi);
let offset = BlockOffset { x: 1, y: 1 };
b.iter(|| rdo_cfl_alpha(&mut fs, &offset, bsize, fi.sequence.bit_depth, fi.sequence.chroma_sampling))
b.iter(|| rdo_cfl_alpha(&mut fs, offset, bsize, fi.sequence.bit_depth, fi.sequence.chroma_sampling))
}
criterion_group!(intra_prediction, predict::pred_bench,);
......
......@@ -221,10 +221,10 @@ pub fn cdef_analyze_superblock<T: Pixel>(
// in the main frame.
let global_block_offset = sbo_global.block_offset(bx<<1, by<<1);
if global_block_offset.x < bc_global.cols && global_block_offset.y < bc_global.rows {
let skip = bc_global.at(&global_block_offset).skip
& bc_global.at(&sbo_global.block_offset(2*bx+1, 2*by)).skip
& bc_global.at(&sbo_global.block_offset(2*bx, 2*by+1)).skip
& bc_global.at(&sbo_global.block_offset(2*bx+1, 2*by+1)).skip;
let skip = bc_global.at(global_block_offset).skip
& bc_global.at(sbo_global.block_offset(2*bx+1, 2*by)).skip
& bc_global.at(sbo_global.block_offset(2*bx, 2*by+1)).skip
& bc_global.at(sbo_global.block_offset(2*bx+1, 2*by+1)).skip;
if !skip {
let mut var: i32 = 0;
......@@ -358,10 +358,10 @@ pub fn cdef_filter_superblock<T: Pixel>(
for bx in 0..8 {
let global_block_offset = sbo_global.block_offset(bx<<1, by<<1);
if global_block_offset.x < bc_global.cols && global_block_offset.y < bc_global.rows {
let skip = bc_global.at(&global_block_offset).skip
& bc_global.at(&sbo_global.block_offset(2*bx+1, 2*by)).skip
& bc_global.at(&sbo_global.block_offset(2*bx, 2*by+1)).skip
& bc_global.at(&sbo_global.block_offset(2*bx+1, 2*by+1)).skip;
let skip = bc_global.at(global_block_offset).skip
& bc_global.at(sbo_global.block_offset(2*bx+1, 2*by)).skip
& bc_global.at(sbo_global.block_offset(2*bx, 2*by+1)).skip
& bc_global.at(sbo_global.block_offset(2*bx+1, 2*by+1)).skip;
if !skip {
let dir = cdef_dirs.dir[bx][by];
let var = cdef_dirs.var[bx][by];
......@@ -480,7 +480,7 @@ pub fn cdef_filter_frame<T: Pixel>(fi: &FrameInvariants<T>, rec: &mut Frame<T>,
for fby in 0..fb_height {
for fbx in 0..fb_width {
let sbo = SuperBlockOffset { x: fbx, y: fby };
let cdef_index = bc.at(&sbo.block_offset(0, 0)).cdef_index;
let cdef_index = bc.at(sbo.block_offset(0, 0)).cdef_index;
let cdef_dirs = cdef_analyze_superblock(&cdef_frame, bc, &sbo, &sbo, fi.sequence.bit_depth);
cdef_filter_superblock(fi, &cdef_frame, rec, bc, &sbo, &sbo, cdef_index, &cdef_dirs);
}
......
This diff is collapsed.
......@@ -82,7 +82,7 @@ fn deblock_adjusted_level(
}
fn deblock_left<'a, T: Pixel>(
bc: &'a BlockContext, in_bo: &BlockOffset, p: &Plane<T>
bc: &'a BlockContext, in_bo: BlockOffset, p: &Plane<T>
) -> &'a Block {
let xdec = p.cfg.xdec;
let ydec = p.cfg.ydec;
......@@ -92,11 +92,11 @@ fn deblock_left<'a, T: Pixel>(
let bo = BlockOffset { x: in_bo.x | xdec, y: in_bo.y | ydec };
// We already know we're not at the upper/left corner, so prev_block is in frame
bc.at(&bo.with_offset(-1 << xdec, 0))
bc.at(bo.with_offset(-1 << xdec, 0))
}
fn deblock_up<'a, T: Pixel>(
bc: &'a BlockContext, in_bo: &BlockOffset, p: &Plane<T>
bc: &'a BlockContext, in_bo: BlockOffset, p: &Plane<T>
) -> &'a Block {
let xdec = p.cfg.xdec;
let ydec = p.cfg.ydec;
......@@ -106,7 +106,7 @@ fn deblock_up<'a, T: Pixel>(
let bo = BlockOffset { x: in_bo.x | xdec, y: in_bo.y | ydec };
// We already know we're not at the upper/left corner, so prev_block is in frame
bc.at(&bo.with_offset(0, -1 << ydec))
bc.at(bo.with_offset(0, -1 << ydec))
}
// Must be called on a tx edge, and not on a frame edge. This is enforced above the call.
......@@ -1022,10 +1022,10 @@ fn sse_size14<T: Pixel>(
}
fn filter_v_edge<T: Pixel>(
deblock: &DeblockState, bc: &BlockContext, bo: &BlockOffset, p: &mut Plane<T>,
deblock: &DeblockState, bc: &BlockContext, bo: BlockOffset, p: &mut Plane<T>,
pli: usize, bd: usize
) {
let block = bc.at(&bo);
let block = bc.at(bo);
let tx_edge = bo.x & (block.tx_w - 1) == 0;
if tx_edge {
let prev_block = deblock_left(bc, bo, p);
......@@ -1059,10 +1059,10 @@ fn filter_v_edge<T: Pixel>(
}
fn sse_v_edge<T: Pixel>(
bc: &BlockContext, bo: &BlockOffset, rec_plane: &Plane<T>, src_plane: &Plane<T>,
bc: &BlockContext, bo: BlockOffset, rec_plane: &Plane<T>, src_plane: &Plane<T>,
tally: &mut [i64; MAX_LOOP_FILTER + 2], pli: usize, bd: usize
) {
let block = bc.at(&bo);
let block = bc.at(bo);
let tx_edge = bo.x & (block.tx_w - 1) == 0;
if tx_edge {
let prev_block = deblock_left(bc, bo, rec_plane);
......@@ -1125,10 +1125,10 @@ fn sse_v_edge<T: Pixel>(
}
fn filter_h_edge<T: Pixel>(
deblock: &DeblockState, bc: &BlockContext, bo: &BlockOffset, p: &mut Plane<T>,
deblock: &DeblockState, bc: &BlockContext, bo: BlockOffset, p: &mut Plane<T>,
pli: usize, bd: usize
) {
let block = bc.at(&bo);
let block = bc.at(bo);
let tx_edge = bo.y & (block.tx_h - 1) == 0;
if tx_edge {
let prev_block = deblock_up(bc, bo, p);
......@@ -1162,10 +1162,10 @@ fn filter_h_edge<T: Pixel>(
}
fn sse_h_edge<T: Pixel>(
bc: &BlockContext, bo: &BlockOffset, rec_plane: &Plane<T>, src_plane: &Plane<T>,
bc: &BlockContext, bo: BlockOffset, rec_plane: &Plane<T>, src_plane: &Plane<T>,
tally: &mut [i64; MAX_LOOP_FILTER + 2], pli: usize, bd: usize
) {
let block = bc.at(&bo);
let block = bc.at(bo);
let tx_edge = bo.y & (block.tx_h - 1) == 0;
if tx_edge {
let prev_block = deblock_up(bc, bo, rec_plane);
......@@ -1256,14 +1256,14 @@ pub fn deblock_plane<T: Pixel>(
// edge). Unroll to avoid corner-cases.
if bc.rows > 0 {
for x in (1 << xdec..bc.cols).step_by(1 << xdec) {
filter_v_edge(deblock, bc, &BlockOffset { x, y: 0 }, p, pli, bd);
filter_v_edge(deblock, bc, BlockOffset { x, y: 0 }, p, pli, bd);
}
if bc.rows > 1 << ydec {
for x in (1 << xdec..bc.cols).step_by(1 << xdec) {
filter_v_edge(
deblock,
bc,
&BlockOffset { x, y: 1 << ydec },
BlockOffset { x, y: 1 << ydec },
p,
pli,
bd
......@@ -1277,16 +1277,16 @@ pub fn deblock_plane<T: Pixel>(
for y in ((2 << ydec)..bc.rows).step_by(1 << ydec) {
// Check for vertical edge at first MI block boundary on this row
if 1 << xdec < bc.cols {
filter_v_edge(deblock, bc, &BlockOffset { x: 1 << xdec, y }, p, pli, bd);
filter_v_edge(deblock, bc, BlockOffset { x: 1 << xdec, y }, p, pli, bd);
}
// run the rest of the row with both vertical and horizontal edge filtering.
// Horizontal lags vertical edge by one row and two columns.
for x in (2 << xdec..bc.cols).step_by(1 << xdec) {
filter_v_edge(deblock, bc, &BlockOffset { x, y }, p, pli, bd);
filter_v_edge(deblock, bc, BlockOffset { x, y }, p, pli, bd);
filter_h_edge(
deblock,
bc,
&BlockOffset { x: x - (2 << xdec), y: y - (1 << ydec) },
BlockOffset { x: x - (2 << xdec), y: y - (1 << ydec) },
p,
pli,
bd
......@@ -1297,7 +1297,7 @@ pub fn deblock_plane<T: Pixel>(
filter_h_edge(
deblock,
bc,
&BlockOffset { x: bc.cols - (2 << xdec), y: y - (1 << ydec) },
BlockOffset { x: bc.cols - (2 << xdec), y: y - (1 << ydec) },
p,
pli,
bd
......@@ -1306,7 +1306,7 @@ pub fn deblock_plane<T: Pixel>(
filter_h_edge(
deblock,
bc,
&BlockOffset { x: bc.cols - (1 << xdec), y: y - (1 << ydec) },
BlockOffset { x: bc.cols - (1 << xdec), y: y - (1 << ydec) },
p,
pli,
bd
......@@ -1321,7 +1321,7 @@ pub fn deblock_plane<T: Pixel>(
filter_h_edge(
deblock,
bc,
&BlockOffset { x, y: bc.rows - (1 << ydec) },
BlockOffset { x, y: bc.rows - (1 << ydec) },
p,
pli,
bd
......@@ -1341,7 +1341,7 @@ fn sse_plane<T: Pixel>(
// No horizontal edge filtering along top of frame
for x in (1 << xdec..bc.cols).step_by(1 << xdec) {
sse_v_edge(bc, &BlockOffset { x, y: 0 }, rec, src, v_sse, pli, bd);
sse_v_edge(bc, BlockOffset { x, y: 0 }, rec, src, v_sse, pli, bd);
}
// Unlike actual filtering, we're counting horizontal and vertical
......@@ -1349,10 +1349,10 @@ fn sse_plane<T: Pixel>(
// behind vertical.
for y in (1 << ydec..bc.rows).step_by(1 << ydec) {
// No vertical filtering along left edge of frame
sse_h_edge(bc, &BlockOffset { x: 0, y }, rec, src, h_sse, pli, bd);
sse_h_edge(bc, BlockOffset { x: 0, y }, rec, src, h_sse, pli, bd);
for x in (1 << xdec..bc.cols).step_by(1 << xdec) {
sse_v_edge(bc, &BlockOffset { x, y }, rec, src, v_sse, pli, bd);
sse_h_edge(bc, &BlockOffset { x, y }, rec, src, h_sse, pli, bd);
sse_v_edge(bc, BlockOffset { x, y }, rec, src, v_sse, pli, bd);
sse_h_edge(bc, BlockOffset { x, y }, rec, src, h_sse, pli, bd);
}
}
}
......
This diff is collapsed.
......@@ -250,7 +250,7 @@ impl IndexMut<usize> for FrameMotionVectors {
}
fn get_mv_range(
w_in_b: usize, h_in_b: usize, bo: &BlockOffset, blk_w: usize, blk_h: usize
w_in_b: usize, h_in_b: usize, bo: BlockOffset, blk_w: usize, blk_h: usize
) -> (isize, isize, isize, isize) {
let border_w = 128 + blk_w as isize * 8;
let border_h = 128 + blk_h as isize * 8;
......@@ -263,7 +263,7 @@ fn get_mv_range(
}
pub fn get_subset_predictors<T: Pixel>(
bo: &BlockOffset, cmv: MotionVector,
bo: BlockOffset, cmv: MotionVector,
w_in_b: usize, h_in_b: usize,
frame_mvs: &FrameMotionVectors, frame_ref_opt: &Option<Arc<ReferenceFrame<T>>>,
ref_frame_id: usize
......@@ -338,7 +338,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,
bo: &BlockOffset, lambda: u32,
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,
......@@ -347,7 +347,7 @@ pub trait MotionEstimation {
fn sub_pixel_me<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, rec: &Arc<ReferenceFrame<T>>, po: &PlaneOffset,
bo: &BlockOffset, lambda: u32, pmv: [MotionVector; 2],
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,
......@@ -356,7 +356,7 @@ pub trait MotionEstimation {
fn motion_estimation<T: Pixel> (
fi: &FrameInvariants<T>, fs: &FrameState<T>, bsize: BlockSize,
bo: &BlockOffset, ref_frame: usize, cmv: MotionVector,
bo: BlockOffset, ref_frame: usize, cmv: MotionVector,
pmv: [MotionVector; 2]
) -> MotionVector {
match fi.rec_buffer.frames[fi.ref_frames[ref_frame - LAST_FRAME] as usize]
......@@ -398,7 +398,7 @@ pub trait MotionEstimation {
fn estimate_motion_ss2<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, bsize: BlockSize, ref_idx: usize,
bo: &BlockOffset, pmvs: &[Option<MotionVector>; 3], ref_frame: usize
bo: BlockOffset, pmvs: &[Option<MotionVector>; 3], ref_frame: usize
) -> Option<MotionVector> {
if let Some(ref rec) = fi.rec_buffer.frames[ref_idx] {
let blk_w = bsize.width();
......@@ -409,7 +409,7 @@ pub trait MotionEstimation {
x: (bo_adj.x as isize) << BLOCK_TO_PLANE_SHIFT >> 1,
y: (bo_adj.y as isize) << BLOCK_TO_PLANE_SHIFT >> 1
};
let (mvx_min, mvx_max, mvy_min, mvy_max) = get_mv_range(fi.w_in_b, fi.h_in_b, &bo_adj, blk_w, blk_h);
let (mvx_min, mvx_max, mvy_min, mvy_max) = get_mv_range(fi.w_in_b, fi.h_in_b, bo_adj, blk_w, blk_h);
let global_mv = [MotionVector{row: 0, col: 0}; 2];
let frame_mvs = &fs.frame_mvs[ref_frame];
......@@ -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
......@@ -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,
......@@ -529,7 +529,7 @@ impl MotionEstimation for DiamondSearch {
for omv in pmvs.iter() {
if let Some(pmv) = omv {
let mut predictors = get_subset_predictors::<T>(
&bo_adj_h,
bo_adj_h,
MotionVector{row: pmv.row, col: pmv.col},
fi.w_in_b, fi.h_in_b,
&frame_mvs, frame_ref_opt, 0
......@@ -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
......@@ -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,
......@@ -920,7 +920,7 @@ fn full_search<T: Pixel>(
}
// Adjust block offset such that entire block lies within frame boundaries
fn adjust_bo<T: Pixel>(bo: &BlockOffset, fi: &FrameInvariants<T>, blk_w: usize, blk_h: usize) -> BlockOffset {
fn adjust_bo<T: Pixel>(bo: BlockOffset, fi: &FrameInvariants<T>, blk_w: usize, blk_h: usize) -> BlockOffset {
BlockOffset {
x: (bo.x as isize).min(fi.w_in_b as isize - blk_w as isize / 4).max(0) as usize,
y: (bo.y as isize).min(fi.h_in_b as isize - blk_h as isize / 4).max(0) as usize
......@@ -944,7 +944,7 @@ fn get_mv_rate(a: MotionVector, b: MotionVector, allow_high_precision_mv: bool)
pub fn estimate_motion_ss4<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, bsize: BlockSize, ref_idx: usize,
bo: &BlockOffset
bo: BlockOffset
) -> Option<MotionVector> {
if let Some(ref rec) = fi.rec_buffer.frames[ref_idx] {
let blk_w = bsize.width();
......@@ -957,7 +957,7 @@ pub fn estimate_motion_ss4<T: Pixel>(
let range_x = 192 * fi.me_range_scale as isize;
let range_y = 64 * fi.me_range_scale as isize;
let (mvx_min, mvx_max, mvy_min, mvy_max) = get_mv_range(fi.w_in_b, fi.h_in_b, &bo_adj, blk_w, blk_h);
let (mvx_min, mvx_max, mvy_min, mvy_max) = get_mv_range(fi.w_in_b, fi.h_in_b, bo_adj, blk_w, blk_h);
let x_lo = po.x + (((-range_x).max(mvx_min / 8)) >> 2);
let x_hi = po.x + (((range_x).min(mvx_max / 8)) >> 2);
let y_lo = po.y + (((-range_y).max(mvy_min / 8)) >> 2);
......
......@@ -921,7 +921,7 @@ pub fn get_intra_edges<T: Pixel>(
tx_size.height() << plane_cfg.ydec
);
let num_avail = if top_edge != 0 && has_tr(&bo, bsize) {
let num_avail = if top_edge != 0 && has_tr(bo, bsize) {
tx_size.width().min(plane_cfg.width - x - tx_size.width())
} else {
0
......@@ -952,7 +952,7 @@ pub fn get_intra_edges<T: Pixel>(
tx_size.height() << plane_cfg.ydec
);
let num_avail = if left_edge != 0 && has_bl(&bo, bsize) {
let num_avail = if left_edge != 0 && has_bl(bo, bsize) {
tx_size.height().min(plane_cfg.height - y - tx_size.height())
} else {
0
......@@ -1232,7 +1232,7 @@ pub enum TxSet {
TX_SET_ALL16
}
pub fn has_tr(bo: &BlockOffset, bsize: BlockSize) -> bool {
pub fn has_tr(bo: BlockOffset, bsize: BlockSize) -> bool {
let sb_mi_size = BLOCK_64X64.width_mi(); /* Assume 64x64 for now */
let mask_row = bo.y & LOCAL_BLOCK_MASK;
let mask_col = bo.x & LOCAL_BLOCK_MASK;
......@@ -1289,7 +1289,7 @@ pub fn has_tr(bo: &BlockOffset, bsize: BlockSize) -> bool {
has_tr
}
pub fn has_bl(bo: &BlockOffset, bsize: BlockSize) -> bool {
pub fn has_bl(bo: BlockOffset, bsize: BlockSize) -> bool {
let sb_mi_size = BLOCK_64X64.width_mi(); /* Assume 64x64 for now */
let mask_row = bo.y & LOCAL_BLOCK_MASK;
let mask_col = bo.x & LOCAL_BLOCK_MASK;
......
......@@ -250,7 +250,7 @@ pub fn sse_wxh<T: Pixel>(
// Compute the pixel-domain distortion for an encode
fn compute_distortion<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, w_y: usize, h_y: usize,
is_chroma_block: bool, bo: &BlockOffset,
is_chroma_block: bool, bo: BlockOffset,
luma_only: bool
) -> u64 {
let po = bo.plane_offset(&fs.input.planes[0].cfg);
......@@ -306,7 +306,7 @@ fn compute_distortion<T: Pixel>(
// Compute the transform-domain distortion for an encode
fn compute_tx_distortion<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, w_y: usize, h_y: usize,
is_chroma_block: bool, bo: &BlockOffset, tx_dist: i64,
is_chroma_block: bool, bo: BlockOffset, tx_dist: i64,
skip: bool, luma_only: bool
) -> u64 {
assert!(fi.config.tune == Tune::Psnr);
......@@ -360,7 +360,7 @@ fn compute_rd_cost<T: Pixel>(fi: &FrameInvariants<T>, rate: u32, distortion: u64
pub fn rdo_tx_size_type<T: Pixel>(
fi: &FrameInvariants<T>, fs: &mut FrameState<T>,
cw: &mut ContextWriter, bsize: BlockSize, bo: &BlockOffset,
cw: &mut ContextWriter, bsize: BlockSize, bo: BlockOffset,
luma_mode: PredictionMode, ref_frames: [usize; 2], mvs: [MotionVector; 2], skip: bool
) -> (TxSize, TxType) {
// these rules follow TX_MODE_LARGEST
......@@ -444,7 +444,7 @@ impl Default for EncodingSettings {
// RDO-based mode decision
pub fn rdo_mode_decision<T: Pixel>(
fi: &FrameInvariants<T>, fs: &mut FrameState<T>,
cw: &mut ContextWriter, bsize: BlockSize, bo: &BlockOffset,
cw: &mut ContextWriter, bsize: BlockSize, bo: BlockOffset,
pmvs: &[Option<MotionVector>]
) -> RDOPartitionOutput {
let mut best = EncodingSettings::default();
......@@ -877,7 +877,7 @@ pub fn rdo_mode_decision<T: Pixel>(
assert!(best.rd >= 0_f64);
RDOPartitionOutput {
bo: bo.clone(),
bo,
bsize,
pred_mode_luma: best.mode_luma,
pred_mode_chroma: best.mode_chroma,
......@@ -892,7 +892,7 @@ pub fn rdo_mode_decision<T: Pixel>(
}
pub fn rdo_cfl_alpha<T: Pixel>(
fs: &mut FrameState<T>, bo: &BlockOffset, bsize: BlockSize, bit_depth: usize,
fs: &mut FrameState<T>, bo: BlockOffset, bsize: BlockSize, bit_depth: usize,
chroma_sampling: ChromaSampling
) -> Option<CFLParams> {
let uv_tx_size = bsize.largest_uv_tx_size(chroma_sampling);
......@@ -941,7 +941,7 @@ pub fn rdo_cfl_alpha<T: Pixel>(
pub fn rdo_tx_type_decision<T: Pixel>(
fi: &FrameInvariants<T>, fs: &mut FrameState<T>, cw: &mut ContextWriter,
mode: PredictionMode, ref_frames: [usize; 2], mvs: [MotionVector; 2],
bsize: BlockSize, bo: &BlockOffset, tx_size: TxSize, tx_set: TxSet
bsize: BlockSize, bo: BlockOffset, tx_size: TxSize, tx_set: TxSet
) -> TxType {
let mut best_type = TxType::DCT_DCT;
let mut best_rd = std::f64::MAX;
......@@ -1037,8 +1037,8 @@ pub fn rdo_tx_type_decision<T: Pixel>(
best_type
}
pub fn get_sub_partitions<'a>(four_partitions: &[&'a BlockOffset; 4],
partition: PartitionType) -> Vec<&'a BlockOffset> {
pub fn get_sub_partitions(four_partitions: &[BlockOffset; 4],
partition: PartitionType) -> Vec<BlockOffset> {
let mut partitions = vec![ four_partitions[0] ];
if partition == PARTITION_NONE {
......@@ -1057,12 +1057,12 @@ pub fn get_sub_partitions<'a>(four_partitions: &[&'a BlockOffset; 4],
partitions
}
pub fn get_sub_partitions_with_border_check<'a, T: Pixel>(
four_partitions: &[&'a BlockOffset; 4],
pub fn get_sub_partitions_with_border_check<T: Pixel>(
four_partitions: &[BlockOffset; 4],
partition: PartitionType,
fi: &FrameInvariants<T>,
subsize: BlockSize
) -> Vec<&'a BlockOffset> {
) -> Vec<BlockOffset> {
let mut partitions = vec![ four_partitions[0] ];
if partition == PARTITION_NONE {
......@@ -1094,7 +1094,7 @@ pub fn get_sub_partitions_with_border_check<'a, T: Pixel>(
pub fn rdo_partition_decision<T: Pixel>(
fi: &FrameInvariants<T>, fs: &mut FrameState<T>,
cw: &mut ContextWriter, w_pre_cdef: &mut dyn Writer, w_post_cdef: &mut dyn Writer,
bsize: BlockSize, bo: &BlockOffset,
bsize: BlockSize, bo: BlockOffset,
cached_block: &RDOOutput, pmvs: &[[Option<MotionVector>; REF_FRAMES]; 5],
partition_types: &[PartitionType], rdo_type: RDOType
) -> RDOOutput {
......@@ -1149,9 +1149,9 @@ pub fn rdo_partition_decision<T: Pixel>(
let hbsh = subsize.height_mi(); // Half the block size height in blocks
let four_partitions = [
bo,
&BlockOffset{ x: bo.x + hbsw as usize, y: bo.y },
&BlockOffset{ x: bo.x, y: bo.y + hbsh as usize },
&BlockOffset{ x: bo.x + hbsw as usize, y: bo.y + hbsh as usize }
BlockOffset{ x: bo.x + hbsw as usize, y: bo.y },
BlockOffset{ x: bo.x, y: bo.y + hbsh as usize },
BlockOffset{ x: bo.x + hbsw as usize, y: bo.y + hbsh as usize }
];
let partitions = get_sub_partitions_with_border_check(&four_partitions, partition, fi, subsize);
......@@ -1172,9 +1172,9 @@ pub fn rdo_partition_decision<T: Pixel>(
}
let mut rd_cost_sum = 0.0;
for (offset, pmv_idx) in partitions.iter().zip(pmv_idxs) {
for (&offset, pmv_idx) in partitions.iter().zip(pmv_idxs) {
let mode_decision =
rdo_mode_decision(fi, fs, cw, subsize, &offset,
rdo_mode_decision(fi, fs, cw, subsize, offset,
&pmvs[pmv_idx]);
rd_cost_sum += mode_decision.rd_cost;
......@@ -1233,7 +1233,7 @@ fn rdo_loop_plane_error<T: Pixel>(sbo: &SuperBlockOffset, fi: &FrameInvariants<T
for bx in 0..sb_blocks {
let bo = sbo.block_offset(bx<<1, by<<1);
if bo.x < bc.cols && bo.y < bc.rows {
let skip = bc.at(&bo).skip;
let skip = bc.at(bo).skip;
if !skip {
let in_plane = &fs.input.planes[pli];
let in_po = sbo.block_offset(bx<<1, by<<1).plane_offset(&in_plane.cfg);
......
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