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) { ...@@ -77,7 +77,7 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
&mut cw, &mut cw,
&mut w, &mut w,
p, p,
&bo, bo,
mode, mode,
tx_size, tx_size,
tx_type, tx_type,
...@@ -143,7 +143,7 @@ fn cfl_rdo_bench(b: &mut Bencher, bsize: BlockSize) { ...@@ -143,7 +143,7 @@ fn cfl_rdo_bench(b: &mut Bencher, bsize: BlockSize) {
let fi = FrameInvariants::<u16>::new(config, sequence); let fi = FrameInvariants::<u16>::new(config, sequence);
let mut fs = FrameState::new(&fi); let mut fs = FrameState::new(&fi);
let offset = BlockOffset { x: 1, y: 1 }; 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,); criterion_group!(intra_prediction, predict::pred_bench,);
......
...@@ -221,10 +221,10 @@ pub fn cdef_analyze_superblock<T: Pixel>( ...@@ -221,10 +221,10 @@ pub fn cdef_analyze_superblock<T: Pixel>(
// in the main frame. // in the main frame.
let global_block_offset = sbo_global.block_offset(bx<<1, by<<1); 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 { if global_block_offset.x < bc_global.cols && global_block_offset.y < bc_global.rows {
let skip = bc_global.at(&global_block_offset).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+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, 2*by+1)).skip
& bc_global.at(&sbo_global.block_offset(2*bx+1, 2*by+1)).skip; & bc_global.at(sbo_global.block_offset(2*bx+1, 2*by+1)).skip;
if !skip { if !skip {
let mut var: i32 = 0; let mut var: i32 = 0;
...@@ -358,10 +358,10 @@ pub fn cdef_filter_superblock<T: Pixel>( ...@@ -358,10 +358,10 @@ pub fn cdef_filter_superblock<T: Pixel>(
for bx in 0..8 { for bx in 0..8 {
let global_block_offset = sbo_global.block_offset(bx<<1, by<<1); 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 { if global_block_offset.x < bc_global.cols && global_block_offset.y < bc_global.rows {
let skip = bc_global.at(&global_block_offset).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+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, 2*by+1)).skip
& bc_global.at(&sbo_global.block_offset(2*bx+1, 2*by+1)).skip; & bc_global.at(sbo_global.block_offset(2*bx+1, 2*by+1)).skip;
if !skip { if !skip {
let dir = cdef_dirs.dir[bx][by]; let dir = cdef_dirs.dir[bx][by];
let var = cdef_dirs.var[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>, ...@@ -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 fby in 0..fb_height {
for fbx in 0..fb_width { for fbx in 0..fb_width {
let sbo = SuperBlockOffset { x: fbx, y: fby }; 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); 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); 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( ...@@ -82,7 +82,7 @@ fn deblock_adjusted_level(
} }
fn deblock_left<'a, T: Pixel>( 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 { ) -> &'a Block {
let xdec = p.cfg.xdec; let xdec = p.cfg.xdec;
let ydec = p.cfg.ydec; let ydec = p.cfg.ydec;
...@@ -92,11 +92,11 @@ fn deblock_left<'a, T: Pixel>( ...@@ -92,11 +92,11 @@ fn deblock_left<'a, T: Pixel>(
let bo = BlockOffset { x: in_bo.x | xdec, y: in_bo.y | ydec }; 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 // 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>( 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 { ) -> &'a Block {
let xdec = p.cfg.xdec; let xdec = p.cfg.xdec;
let ydec = p.cfg.ydec; let ydec = p.cfg.ydec;
...@@ -106,7 +106,7 @@ fn deblock_up<'a, T: Pixel>( ...@@ -106,7 +106,7 @@ fn deblock_up<'a, T: Pixel>(
let bo = BlockOffset { x: in_bo.x | xdec, y: in_bo.y | ydec }; 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 // 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. // 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>( ...@@ -1022,10 +1022,10 @@ fn sse_size14<T: Pixel>(
} }
fn filter_v_edge<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 pli: usize, bd: usize
) { ) {
let block = bc.at(&bo); let block = bc.at(bo);
let tx_edge = bo.x & (block.tx_w - 1) == 0; let tx_edge = bo.x & (block.tx_w - 1) == 0;
if tx_edge { if tx_edge {
let prev_block = deblock_left(bc, bo, p); let prev_block = deblock_left(bc, bo, p);
...@@ -1059,10 +1059,10 @@ fn filter_v_edge<T: Pixel>( ...@@ -1059,10 +1059,10 @@ fn filter_v_edge<T: Pixel>(
} }
fn sse_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 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; let tx_edge = bo.x & (block.tx_w - 1) == 0;
if tx_edge { if tx_edge {
let prev_block = deblock_left(bc, bo, rec_plane); let prev_block = deblock_left(bc, bo, rec_plane);
...@@ -1125,10 +1125,10 @@ fn sse_v_edge<T: Pixel>( ...@@ -1125,10 +1125,10 @@ fn sse_v_edge<T: Pixel>(
} }
fn filter_h_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 pli: usize, bd: usize
) { ) {
let block = bc.at(&bo); let block = bc.at(bo);
let tx_edge = bo.y & (block.tx_h - 1) == 0; let tx_edge = bo.y & (block.tx_h - 1) == 0;
if tx_edge { if tx_edge {
let prev_block = deblock_up(bc, bo, p); let prev_block = deblock_up(bc, bo, p);
...@@ -1162,10 +1162,10 @@ fn filter_h_edge<T: Pixel>( ...@@ -1162,10 +1162,10 @@ fn filter_h_edge<T: Pixel>(
} }
fn sse_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 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; let tx_edge = bo.y & (block.tx_h - 1) == 0;
if tx_edge { if tx_edge {
let prev_block = deblock_up(bc, bo, rec_plane); let prev_block = deblock_up(bc, bo, rec_plane);
...@@ -1256,14 +1256,14 @@ pub fn deblock_plane<T: Pixel>( ...@@ -1256,14 +1256,14 @@ pub fn deblock_plane<T: Pixel>(
// edge). Unroll to avoid corner-cases. // edge). Unroll to avoid corner-cases.
if bc.rows > 0 { if bc.rows > 0 {
for x in (1 << xdec..bc.cols).step_by(1 << xdec) { 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 { if bc.rows > 1 << ydec {
for x in (1 << xdec..bc.cols).step_by(1 << xdec) { for x in (1 << xdec..bc.cols).step_by(1 << xdec) {
filter_v_edge( filter_v_edge(
deblock, deblock,
bc, bc,
&BlockOffset { x, y: 1 << ydec }, BlockOffset { x, y: 1 << ydec },
p, p,
pli, pli,
bd bd
...@@ -1277,16 +1277,16 @@ pub fn deblock_plane<T: Pixel>( ...@@ -1277,16 +1277,16 @@ pub fn deblock_plane<T: Pixel>(
for y in ((2 << ydec)..bc.rows).step_by(1 << ydec) { for y in ((2 << ydec)..bc.rows).step_by(1 << ydec) {
// Check for vertical edge at first MI block boundary on this row // Check for vertical edge at first MI block boundary on this row
if 1 << xdec < bc.cols { 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. // run the rest of the row with both vertical and horizontal edge filtering.
// Horizontal lags vertical edge by one row and two columns. // Horizontal lags vertical edge by one row and two columns.
for x in (2 << xdec..bc.cols).step_by(1 << xdec) { 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( filter_h_edge(
deblock, deblock,
bc, bc,
&BlockOffset { x: x - (2 << xdec), y: y - (1 << ydec) }, BlockOffset { x: x - (2 << xdec), y: y - (1 << ydec) },
p, p,
pli, pli,
bd bd
...@@ -1297,7 +1297,7 @@ pub fn deblock_plane<T: Pixel>( ...@@ -1297,7 +1297,7 @@ pub fn deblock_plane<T: Pixel>(
filter_h_edge( filter_h_edge(
deblock, deblock,
bc, bc,
&BlockOffset { x: bc.cols - (2 << xdec), y: y - (1 << ydec) }, BlockOffset { x: bc.cols - (2 << xdec), y: y - (1 << ydec) },
p, p,
pli, pli,
bd bd
...@@ -1306,7 +1306,7 @@ pub fn deblock_plane<T: Pixel>( ...@@ -1306,7 +1306,7 @@ pub fn deblock_plane<T: Pixel>(
filter_h_edge( filter_h_edge(
deblock, deblock,
bc, bc,
&BlockOffset { x: bc.cols - (1 << xdec), y: y - (1 << ydec) }, BlockOffset { x: bc.cols - (1 << xdec), y: y - (1 << ydec) },
p, p,
pli, pli,
bd bd
...@@ -1321,7 +1321,7 @@ pub fn deblock_plane<T: Pixel>( ...@@ -1321,7 +1321,7 @@ pub fn deblock_plane<T: Pixel>(
filter_h_edge( filter_h_edge(
deblock, deblock,
bc, bc,
&BlockOffset { x, y: bc.rows - (1 << ydec) }, BlockOffset { x, y: bc.rows - (1 << ydec) },
p, p,
pli, pli,
bd bd
...@@ -1341,7 +1341,7 @@ fn sse_plane<T: Pixel>( ...@@ -1341,7 +1341,7 @@ fn sse_plane<T: Pixel>(
// No horizontal edge filtering along top of frame // No horizontal edge filtering along top of frame
for x in (1 << xdec..bc.cols).step_by(1 << xdec) { 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 // Unlike actual filtering, we're counting horizontal and vertical
...@@ -1349,10 +1349,10 @@ fn sse_plane<T: Pixel>( ...@@ -1349,10 +1349,10 @@ fn sse_plane<T: Pixel>(
// behind vertical. // behind vertical.
for y in (1 << ydec..bc.rows).step_by(1 << ydec) { for y in (1 << ydec..bc.rows).step_by(1 << ydec) {
// No vertical filtering along left edge of frame // 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) { 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_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_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 { ...@@ -250,7 +250,7 @@ impl IndexMut<usize> for FrameMotionVectors {
} }
fn get_mv_range( 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) { ) -> (isize, isize, isize, isize) {
let border_w = 128 + blk_w as isize * 8; let border_w = 128 + blk_w as isize * 8;
let border_h = 128 + blk_h as isize * 8; let border_h = 128 + blk_h as isize * 8;
...@@ -263,7 +263,7 @@ fn get_mv_range( ...@@ -263,7 +263,7 @@ fn get_mv_range(
} }
pub fn get_subset_predictors<T: Pixel>( pub fn get_subset_predictors<T: Pixel>(
bo: &BlockOffset, cmv: MotionVector, bo: BlockOffset, cmv: MotionVector,
w_in_b: usize, h_in_b: usize, w_in_b: usize, h_in_b: usize,
frame_mvs: &FrameMotionVectors, frame_ref_opt: &Option<Arc<ReferenceFrame<T>>>, frame_mvs: &FrameMotionVectors, frame_ref_opt: &Option<Arc<ReferenceFrame<T>>>,
ref_frame_id: usize ref_frame_id: usize
...@@ -338,7 +338,7 @@ pub fn get_subset_predictors<T: Pixel>( ...@@ -338,7 +338,7 @@ pub fn get_subset_predictors<T: Pixel>(
pub trait MotionEstimation { pub trait MotionEstimation {
fn full_pixel_me<T: Pixel>( 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, bo: BlockOffset, lambda: u32,
cmv: MotionVector, pmv: [MotionVector; 2], cmv: MotionVector, pmv: [MotionVector; 2],
mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize, mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize,
blk_w: usize, blk_h: usize, best_mv: &mut MotionVector, blk_w: usize, blk_h: usize, best_mv: &mut MotionVector,
...@@ -347,7 +347,7 @@ pub trait MotionEstimation { ...@@ -347,7 +347,7 @@ pub trait MotionEstimation {
fn sub_pixel_me<T: Pixel>( 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], bo: BlockOffset, lambda: u32, pmv: [MotionVector; 2],
mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize, mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize,
blk_w: usize, blk_h: usize, best_mv: &mut MotionVector, blk_w: usize, blk_h: usize, best_mv: &mut MotionVector,
lowest_cost: &mut u64, ref_frame: usize, lowest_cost: &mut u64, ref_frame: usize,
...@@ -356,7 +356,7 @@ pub trait MotionEstimation { ...@@ -356,7 +356,7 @@ pub trait MotionEstimation {
fn motion_estimation<T: Pixel> ( fn motion_estimation<T: Pixel> (
fi: &FrameInvariants<T>, fs: &FrameState<T>, bsize: BlockSize, 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] pmv: [MotionVector; 2]
) -> MotionVector { ) -> MotionVector {
match fi.rec_buffer.frames[fi.ref_frames[ref_frame - LAST_FRAME] as usize] match fi.rec_buffer.frames[fi.ref_frames[ref_frame - LAST_FRAME] as usize]
...@@ -398,7 +398,7 @@ pub trait MotionEstimation { ...@@ -398,7 +398,7 @@ pub trait MotionEstimation {
fn estimate_motion_ss2<T: Pixel>( fn estimate_motion_ss2<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, bsize: BlockSize, ref_idx: usize, 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> { ) -> Option<MotionVector> {
if let Some(ref rec) = fi.rec_buffer.frames[ref_idx] { if let Some(ref rec) = fi.rec_buffer.frames[ref_idx] {
let blk_w = bsize.width(); let blk_w = bsize.width();
...@@ -409,7 +409,7 @@ pub trait MotionEstimation { ...@@ -409,7 +409,7 @@ pub trait MotionEstimation {
x: (bo_adj.x as isize) << BLOCK_TO_PLANE_SHIFT >> 1, x: (bo_adj.x as isize) << BLOCK_TO_PLANE_SHIFT >> 1,
y: (bo_adj.y 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 global_mv = [MotionVector{row: 0, col: 0}; 2];
let frame_mvs = &fs.frame_mvs[ref_frame]; let frame_mvs = &fs.frame_mvs[ref_frame];
...@@ -452,7 +452,7 @@ pub struct FullSearch {} ...@@ -452,7 +452,7 @@ pub struct FullSearch {}
impl MotionEstimation for DiamondSearch { impl MotionEstimation for DiamondSearch {
fn full_pixel_me<T: Pixel>( fn full_pixel_me<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, rec: &Arc<ReferenceFrame<T>>, 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, cmv: MotionVector, pmv: [MotionVector; 2], mvx_min: isize, mvx_max: isize,
mvy_min: isize, mvy_max: isize, blk_w: usize, blk_h: usize, mvy_min: isize, mvy_max: isize, blk_w: usize, blk_h: usize,
best_mv: &mut MotionVector, lowest_cost: &mut u64, ref_frame: usize best_mv: &mut MotionVector, lowest_cost: &mut u64, ref_frame: usize
...@@ -486,7 +486,7 @@ impl MotionEstimation for DiamondSearch { ...@@ -486,7 +486,7 @@ impl MotionEstimation for DiamondSearch {
fn sub_pixel_me<T: Pixel>( fn sub_pixel_me<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, rec: &Arc<ReferenceFrame<T>>, 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, pmv: [MotionVector; 2], mvx_min: isize, mvx_max: isize,
mvy_min: isize, mvy_max: isize, blk_w: usize, blk_h: usize, mvy_min: isize, mvy_max: isize, blk_w: usize, blk_h: usize,
best_mv: &mut MotionVector, lowest_cost: &mut u64, ref_frame: usize, best_mv: &mut MotionVector, lowest_cost: &mut u64, ref_frame: usize,
...@@ -529,7 +529,7 @@ impl MotionEstimation for DiamondSearch { ...@@ -529,7 +529,7 @@ impl MotionEstimation for DiamondSearch {
for omv in pmvs.iter() { for omv in pmvs.iter() {
if let Some(pmv) = omv { if let Some(pmv) = omv {
let mut predictors = get_subset_predictors::<T>( let mut predictors = get_subset_predictors::<T>(
&bo_adj_h, bo_adj_h,
MotionVector{row: pmv.row, col: pmv.col}, MotionVector{row: pmv.row, col: pmv.col},
fi.w_in_b, fi.h_in_b, fi.w_in_b, fi.h_in_b,
&frame_mvs, frame_ref_opt, 0 &frame_mvs, frame_ref_opt, 0
...@@ -558,7 +558,7 @@ impl MotionEstimation for DiamondSearch { ...@@ -558,7 +558,7 @@ impl MotionEstimation for DiamondSearch {
impl MotionEstimation for FullSearch { impl MotionEstimation for FullSearch {
fn full_pixel_me<T: Pixel>( fn full_pixel_me<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, rec: &Arc<ReferenceFrame<T>>, 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, cmv: MotionVector, pmv: [MotionVector; 2], mvx_min: isize, mvx_max: isize,
mvy_min: isize, mvy_max: isize, blk_w: usize, blk_h: usize, mvy_min: isize, mvy_max: isize, blk_w: usize, blk_h: usize,
best_mv: &mut MotionVector, lowest_cost: &mut u64, _ref_frame: usize best_mv: &mut MotionVector, lowest_cost: &mut u64, _ref_frame: usize
...@@ -595,7 +595,7 @@ impl MotionEstimation for FullSearch { ...@@ -595,7 +595,7 @@ impl MotionEstimation for FullSearch {
fn sub_pixel_me<T: Pixel>( fn sub_pixel_me<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, _rec: &Arc<ReferenceFrame<T>>, 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, pmv: [MotionVector; 2], mvx_min: isize, mvx_max: isize,
mvy_min: isize, mvy_max: isize, _blk_w: usize, _blk_h: usize, mvy_min: isize, mvy_max: isize, _blk_w: usize, _blk_h: usize,
best_mv: &mut MotionVector, lowest_cost: &mut u64, ref_frame: usize, best_mv: &mut MotionVector, lowest_cost: &mut u64, ref_frame: usize,
...@@ -920,7 +920,7 @@ fn full_search<T: Pixel>( ...@@ -920,7 +920,7 @@ fn full_search<T: Pixel>(
} }
// Adjust block offset such that entire block lies within frame boundaries // 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 { BlockOffset {
x: (bo.x as isize).min(fi.w_in_b as isize - blk_w as isize / 4).max(0) as usize, 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 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) ...@@ -944,7 +944,7 @@ fn get_mv_rate(a: MotionVector, b: MotionVector, allow_high_precision_mv: bool)
pub fn estimate_motion_ss4<T: Pixel>( pub fn estimate_motion_ss4<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, bsize: BlockSize, ref_idx: usize, fi: &FrameInvariants<T>, fs: &FrameState<T>, bsize: BlockSize, ref_idx: usize,
bo: &BlockOffset bo: BlockOffset
) -> Option<MotionVector> { ) -> Option<MotionVector> {
if let Some(ref rec) = fi.rec_buffer.frames[ref_idx] { if let Some(ref rec) = fi.rec_buffer.frames[ref_idx] {
let blk_w = bsize.width(); let blk_w = bsize.width();
...@@ -957,7 +957,7 @@ pub fn estimate_motion_ss4<T: Pixel>( ...@@ -957,7 +957,7 @@ pub fn estimate_motion_ss4<T: Pixel>(
let range_x = 192 * fi.me_range_scale as isize; let range_x = 192 * fi.me_range_scale as isize;
let range_y = 64 * 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_lo = po.x + (((-range_x).max(mvx_min / 8)) >> 2);
let x_hi = po.x + (((range_x).min(mvx_max / 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); let y_lo = po.y + (((-range_y).max(mvy_min / 8)) >> 2);
......
...@@ -921,7 +921,7 @@ pub fn get_intra_edges<T: Pixel>( ...@@ -921,7 +921,7 @@ pub fn get_intra_edges<T: Pixel>(
tx_size.height() << plane_cfg.ydec 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()) tx_size.width().min(plane_cfg.width - x - tx_size.width())
} else { } else {
0 0
...@@ -952,7 +952,7 @@ pub fn get_intra_edges<T: Pixel>( ...@@ -952,7 +952,7 @@ pub fn get_intra_edges<T: Pixel>(
tx_size.height() << plane_cfg.ydec 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()) tx_size.height().min(plane_cfg.height - y - tx_size.height())
} else { } else {
0 0
...@@ -1232,7 +1232,7 @@ pub enum TxSet { ...@@ -1232,7 +1232,7 @@ pub enum TxSet {
TX_SET_ALL16 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 sb_mi_size = BLOCK_64X64.width_mi(); /* Assume 64x64 for now */
let mask_row = bo.y & LOCAL_BLOCK_MASK; let mask_row = bo.y & LOCAL_BLOCK_MASK;
let mask_col = bo.x & LOCAL_BLOCK_MASK; let mask_col = bo.x & LOCAL_BLOCK_MASK;
...@@ -1289,7 +1289,7 @@ pub fn has_tr(bo: &BlockOffset, bsize: BlockSize) -> bool { ...@@ -1289,7 +1289,7 @@ pub fn has_tr(bo: &BlockOffset, bsize: BlockSize) -> bool {
has_tr 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 sb_mi_size = BLOCK_64X64.width_mi(); /* Assume 64x64 for now */
let mask_row = bo.y & LOCAL_BLOCK_MASK; let mask_row = bo.y & LOCAL_BLOCK_MASK;
let mask_col = bo.x & LOCAL_BLOCK_MASK; let mask_col = bo.x & LOCAL_BLOCK_MASK;
......
...@@ -250,7 +250,7 @@ pub fn sse_wxh<T: Pixel>( ...@@ -250,7 +250,7 @@ pub fn sse_wxh<T: Pixel>(
// Compute the pixel-domain distortion for an encode // Compute the pixel-domain distortion for an encode
fn compute_distortion<T: Pixel>( fn compute_distortion<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, w_y: usize, h_y: usize, 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 luma_only: bool
) -> u64 { ) -> u64 {
let po = bo.plane_offset(&fs.input.planes[0].cfg); let po = bo.plane_offset(&fs.input.planes[0].cfg);
...@@ -306,7 +306,7 @@ fn compute_distortion<T: Pixel>( ...@@ -306,7 +306,7 @@ fn compute_distortion<T: Pixel>(
// Compute the transform-domain distortion for an encode // Compute the transform-domain distortion for an encode
fn compute_tx_distortion<T: Pixel>( fn compute_tx_distortion<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, w_y: usize, h_y: usize, 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,