Commit 3755e3b9 authored by Josh Holmer's avatar Josh Holmer Committed by Thomas Daede

Pass more Copy types by value, optimized for 64-bit

Followup to #710
parent 22e213a6
single-char-binding-names-threshold = 10
too-many-arguments-threshold = 16
cyclomatic-complexity-threshold = 40
trivial-copy-size-limit = 16 # 128-bits = 2 64-bit registers
\ No newline at end of file
......@@ -1464,13 +1464,13 @@ impl BlockContext {
self.for_each(bo, bsize, |block| block.skip = skip);
}
pub fn set_ref_frames(&mut self, bo: &BlockOffset, bsize: BlockSize, r: &[usize; 2]) {
pub fn set_ref_frames(&mut self, bo: &BlockOffset, bsize: BlockSize, r: [usize; 2]) {
let bw = bsize.width_mi();
let bh = bsize.height_mi();
for y in 0..bh {
for x in 0..bw {
self.blocks[bo.y + y as usize][bo.x + x as usize].ref_frames = *r;
self.blocks[bo.y + y as usize][bo.x + x as usize].ref_frames = r;
}
}
}
......@@ -2088,7 +2088,7 @@ impl ContextWriter {
false
}
fn add_ref_mv_candidate(&self, ref_frames: &[usize; 2], blk: &Block, mv_stack: &mut Vec<CandidateMV>,
fn add_ref_mv_candidate(&self, ref_frames: [usize; 2], blk: &Block, mv_stack: &mut Vec<CandidateMV>,
weight: u32, newmv_count: &mut usize, is_compound: bool) -> bool {
if !blk.is_inter() { /* For intrabc */
false
......@@ -2153,7 +2153,7 @@ impl ContextWriter {
fn add_extra_mv_candidate(
&self,
blk: &Block,
ref_frames: &[usize; 2],
ref_frames: [usize; 2],
mv_stack: &mut Vec<CandidateMV>,
fi: &FrameInvariants,
is_compound: bool,
......@@ -2208,7 +2208,7 @@ impl ContextWriter {
}
fn scan_row_mbmi(&mut self, bo: &BlockOffset, row_offset: isize, max_row_offs: isize,
processed_rows: &mut isize, ref_frames: &[usize; 2],
processed_rows: &mut isize, ref_frames: [usize; 2],
mv_stack: &mut Vec<CandidateMV>, newmv_count: &mut usize, bsize: BlockSize,
is_compound: bool) -> bool {
let bc = &self.bc;
......@@ -2262,7 +2262,7 @@ impl ContextWriter {
}
fn scan_col_mbmi(&mut self, bo: &BlockOffset, col_offset: isize, max_col_offs: isize,
processed_cols: &mut isize, ref_frames: &[usize; 2],
processed_cols: &mut isize, ref_frames: [usize; 2],
mv_stack: &mut Vec<CandidateMV>, newmv_count: &mut usize, bsize: BlockSize,
is_compound: bool) -> bool {
let bc = &self.bc;
......@@ -2315,7 +2315,7 @@ impl ContextWriter {
found_match
}
fn scan_blk_mbmi(&mut self, bo: &BlockOffset, ref_frames: &[usize; 2],
fn scan_blk_mbmi(&mut self, bo: &BlockOffset, ref_frames: [usize; 2],
mv_stack: &mut Vec<CandidateMV>, newmv_count: &mut usize,
is_compound: bool) -> bool {
if bo.x >= self.bc.cols || bo.y >= self.bc.rows {
......@@ -2333,7 +2333,7 @@ impl ContextWriter {
}
}
fn setup_mvref_list(&mut self, bo: &BlockOffset, ref_frames: &[usize; 2], mv_stack: &mut Vec<CandidateMV>,
fn setup_mvref_list(&mut self, bo: &BlockOffset, ref_frames: [usize; 2], mv_stack: &mut Vec<CandidateMV>,
bsize: BlockSize, is_sec_rect: bool, fi: &FrameInvariants, is_compound: bool) -> usize {
let (_rf, _rf_num) = self.get_mvref_ref_frames(INTRA_FRAME);
......@@ -2549,7 +2549,7 @@ impl ContextWriter {
mode_context
}
pub fn find_mvrefs(&mut self, bo: &BlockOffset, ref_frames: &[usize; 2],
pub fn find_mvrefs(&mut self, bo: &BlockOffset, ref_frames: [usize; 2],
mv_stack: &mut Vec<CandidateMV>, bsize: BlockSize, is_sec_rect: bool,
fi: &FrameInvariants, is_compound: bool) -> usize {
assert!(ref_frames[0] != NONE_FRAME);
......
......@@ -1411,7 +1411,7 @@ pub fn encode_tx_block(
}
pub fn motion_compensate(fi: &FrameInvariants, fs: &mut FrameState, cw: &mut ContextWriter,
luma_mode: PredictionMode, ref_frames: &[usize; 2], mvs: [MotionVector; 2],
luma_mode: PredictionMode, ref_frames: [usize; 2], mvs: [MotionVector; 2],
bsize: BlockSize, bo: &BlockOffset, bit_depth: usize,
luma_only: bool) {
if luma_mode.is_intra() { return; }
......@@ -1441,12 +1441,12 @@ pub fn motion_compensate(fi: &FrameInvariants, fs: &mut FrameState, cw: &mut Con
assert!(xdec == 1 && ydec == 1);
// TODO: these are only valid for 4:2:0
let mv0 = cw.bc.at(&bo.with_offset(-1,-1)).mv;
let rf0 = &cw.bc.at(&bo.with_offset(-1,-1)).ref_frames;
let rf0 = cw.bc.at(&bo.with_offset(-1,-1)).ref_frames;
let mv1 = cw.bc.at(&bo.with_offset(0,-1)).mv;
let rf1 = &cw.bc.at(&bo.with_offset(0,-1)).ref_frames;
let rf1 = cw.bc.at(&bo.with_offset(0,-1)).ref_frames;
let po1 = PlaneOffset { x: po.x+2, y: po.y };
let mv2 = cw.bc.at(&bo.with_offset(-1,0)).mv;
let rf2 = &cw.bc.at(&bo.with_offset(-1,0)).ref_frames;
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, bit_depth);
......@@ -1475,7 +1475,7 @@ pub fn encode_block_a(seq: &Sequence,
pub fn encode_block_b(seq: &Sequence, fi: &FrameInvariants, fs: &mut FrameState,
cw: &mut ContextWriter, w: &mut dyn Writer,
luma_mode: PredictionMode, chroma_mode: PredictionMode,
ref_frames: &[usize; 2], mvs: [MotionVector; 2],
ref_frames: [usize; 2], mvs: [MotionVector; 2],
bsize: BlockSize, bo: &BlockOffset, skip: bool, bit_depth: usize,
cfl: CFLParams, tx_size: TxSize, tx_type: TxType,
mode_context: usize, mv_stack: &[CandidateMV], for_rdo_use: bool)
......@@ -1887,7 +1887,7 @@ fn encode_partition_bottomup(seq: &Sequence, fi: &FrameInvariants, fs: &mut Fram
let (mode_luma, mode_chroma) = (mode_decision.pred_mode_luma, mode_decision.pred_mode_chroma);
let cfl = mode_decision.pred_cfl_params;
{
let ref_frames = &mode_decision.ref_frames;
let ref_frames = mode_decision.ref_frames;
let mvs = mode_decision.mvs;
let skip = mode_decision.skip;
let mut cdef_coded = cw.bc.cdef_coded;
......@@ -1970,7 +1970,7 @@ fn encode_partition_bottomup(seq: &Sequence, fi: &FrameInvariants, fs: &mut Fram
// FIXME: redundant block re-encode
let (mode_luma, mode_chroma) = (best_decision.pred_mode_luma, best_decision.pred_mode_chroma);
let cfl = best_decision.pred_cfl_params;
let ref_frames = &best_decision.ref_frames;
let ref_frames = best_decision.ref_frames;
let mvs = best_decision.mvs;
let skip = best_decision.skip;
let mut cdef_coded = cw.bc.cdef_coded;
......@@ -2072,7 +2072,7 @@ fn encode_partition_topdown(seq: &Sequence, fi: &FrameInvariants, fs: &mut Frame
let cfl = part_decision.pred_cfl_params;
let skip = part_decision.skip;
let ref_frames = &part_decision.ref_frames;
let ref_frames = part_decision.ref_frames;
let mvs = part_decision.mvs;
let mut cdef_coded = cw.bc.cdef_coded;
......
......@@ -108,7 +108,7 @@ pub fn motion_estimation(
&mut tmp_plane.mut_slice(&PlaneOffset { x: 0, y: 0 });
mode.predict_inter(
fi, 0, &po, tmp_slice, blk_w, blk_h, &[ref_frame, NONE_FRAME],
fi, 0, &po, tmp_slice, blk_w, blk_h, [ref_frame, NONE_FRAME],
[cand_mv, MotionVector{ row: 0, col: 0 }], 8,
);
}
......
......@@ -952,7 +952,7 @@ impl PredictionMode {
pub fn predict_inter<'a>(
self, fi: &FrameInvariants, p: usize, po: &PlaneOffset,
dst: &'a mut PlaneMutSlice<'a>, width: usize, height: usize,
ref_frames: &[usize; 2], mvs: [MotionVector; 2], bit_depth: usize
ref_frames: [usize; 2], mvs: [MotionVector; 2], bit_depth: usize
) {
assert!(!self.is_intra());
......
......@@ -271,7 +271,7 @@ fn compute_tx_rd_cost(
pub fn rdo_tx_size_type(
seq: &Sequence, fi: &FrameInvariants, fs: &mut FrameState,
cw: &mut ContextWriter, bsize: BlockSize, bo: &BlockOffset,
luma_mode: PredictionMode, ref_frames: &[usize; 2], mvs: [MotionVector; 2], skip: bool
luma_mode: PredictionMode, ref_frames: [usize; 2], mvs: [MotionVector; 2], skip: bool
) -> (TxSize, TxType) {
// these rules follow TX_MODE_LARGEST
let tx_size = match bsize {
......@@ -397,7 +397,7 @@ pub fn rdo_mode_decision(
for (i, &ref_frames) in ref_frames_set.iter().enumerate() {
let mut mv_stack: Vec<CandidateMV> = Vec::new();
mode_contexts.push(cw.find_mvrefs(bo, &ref_frames, &mut mv_stack, bsize, false, fi, false));
mode_contexts.push(cw.find_mvrefs(bo, ref_frames, &mut mv_stack, bsize, false, fi, false));
if fi.frame_type == FrameType::INTER {
for &x in RAV1E_INTER_MODES_MINIMAL {
......@@ -439,7 +439,7 @@ pub fn rdo_mode_decision(
let mv1 = mvs_from_me[r1][0];
mvs_from_me.push([mv0, mv1]);
let mut mv_stack: Vec<CandidateMV> = Vec::new();
mode_contexts.push(cw.find_mvrefs(bo, &ref_frames, &mut mv_stack, bsize, false, fi, true));
mode_contexts.push(cw.find_mvrefs(bo, ref_frames, &mut mv_stack, bsize, false, fi, true));
for &x in RAV1E_INTER_COMPOUND_MODES {
mode_set.push((x, ref_frames_set.len() - 1));
}
......@@ -449,7 +449,7 @@ pub fn rdo_mode_decision(
}
let luma_rdo = |luma_mode: PredictionMode, fs: &mut FrameState, cw: &mut ContextWriter, best: &mut EncodingSettings,
mvs: [MotionVector; 2], ref_frames: &[usize; 2], mode_set_chroma: &[PredictionMode], luma_mode_is_intra: bool,
mvs: [MotionVector; 2], ref_frames: [usize; 2], mode_set_chroma: &[PredictionMode], luma_mode_is_intra: bool,
mode_context: usize, mv_stack: &Vec<CandidateMV>| {
let (tx_size, mut tx_type) = rdo_tx_size_type(
seq, fi, fs, cw, bsize, bo, luma_mode, ref_frames, mvs, false,
......@@ -520,7 +520,7 @@ pub fn rdo_mode_decision(
best.rd = rd;
best.mode_luma = luma_mode;
best.mode_chroma = chroma_mode;
best.ref_frames = *ref_frames;
best.ref_frames = ref_frames;
best.mvs = mvs;
best.skip = skip;
best.tx_size = tx_size;
......@@ -564,14 +564,14 @@ pub fn rdo_mode_decision(
};
let mode_set_chroma = vec![luma_mode];
luma_rdo(luma_mode, fs, cw, &mut best, mvs, &ref_frames_set[i], &mode_set_chroma, false,
luma_rdo(luma_mode, fs, cw, &mut best, mvs, ref_frames_set[i], &mode_set_chroma, false,
mode_contexts[i], &mv_stacks[i]);
});
if !best.skip {
intra_mode_set.iter().for_each(|&luma_mode| {
let mvs = [MotionVector { row: 0, col: 0 }; 2];
let ref_frames = &[INTRA_FRAME, NONE_FRAME];
let ref_frames = [INTRA_FRAME, NONE_FRAME];
let mut mode_set_chroma = vec![luma_mode];
if is_chroma_block && luma_mode != PredictionMode::DC_PRED {
mode_set_chroma.push(PredictionMode::DC_PRED);
......@@ -616,7 +616,7 @@ pub fn rdo_mode_decision(
wr,
best.mode_luma,
chroma_mode,
&best.ref_frames,
best.ref_frames,
best.mvs,
bsize,
bo,
......@@ -657,7 +657,7 @@ pub fn rdo_mode_decision(
}
cw.bc.set_mode(bo, bsize, best.mode_luma);
cw.bc.set_ref_frames(bo, bsize, &best.ref_frames);
cw.bc.set_ref_frames(bo, bsize, best.ref_frames);
cw.bc.set_motion_vectors(bo, bsize, best.mvs);
assert!(best.rd >= 0_f64);
......@@ -726,7 +726,7 @@ pub fn rdo_cfl_alpha(
// RDO-based transform type decision
pub fn rdo_tx_type_decision(
fi: &FrameInvariants, fs: &mut FrameState, cw: &mut ContextWriter,
mode: PredictionMode, ref_frames: &[usize; 2], mvs: [MotionVector; 2], bsize: BlockSize, bo: &BlockOffset, tx_size: TxSize,
mode: PredictionMode, ref_frames: [usize; 2], mvs: [MotionVector; 2], bsize: BlockSize, bo: &BlockOffset, tx_size: TxSize,
tx_set: TxSet, bit_depth: usize
) -> TxType {
let mut best_type = TxType::DCT_DCT;
......
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