Unverified Commit a12dcbbb authored by fbossen's avatar fbossen Committed by GitHub

Change MV mode if NEAREST isn't NEAREST anymore (#533)

Change MV mode if NEAREST isn't NEAREST anymore instead of doing repeated RDO optimizations. Improves run time by about 20-25%.
parent fd6d02d1
......@@ -1778,9 +1778,7 @@ fn encode_partition_topdown(seq: &Sequence, fi: &FrameInvariants, fs: &mut Frame
match partition {
PartitionType::PARTITION_NONE => {
// FIXME: For now always redo RDO since prior RDO may have relied on inaccurate
// neighbours
let part_decision = if !rdo_output.part_modes.is_empty() && false {
let part_decision = if !rdo_output.part_modes.is_empty() {
// The optimal prediction mode is known from a previous iteration
rdo_output.part_modes[0].clone()
} else {
......@@ -1788,7 +1786,9 @@ fn encode_partition_topdown(seq: &Sequence, fi: &FrameInvariants, fs: &mut Frame
rdo_mode_decision(seq, fi, fs, cw, bsize, bo).part_modes[0].clone()
};
let (mode_luma, mode_chroma) = (part_decision.pred_mode_luma, part_decision.pred_mode_chroma);
let mut mode_luma = part_decision.pred_mode_luma;
let mut mode_chroma = part_decision.pred_mode_chroma;
let cfl = part_decision.pred_cfl_params;
let skip = part_decision.skip;
let ref_frame = part_decision.ref_frame;
......@@ -1801,6 +1801,13 @@ fn encode_partition_topdown(seq: &Sequence, fi: &FrameInvariants, fs: &mut Frame
let mut mv_stack = Vec::new();
let mode_context = cw.find_mvrefs(bo, ref_frame, &mut mv_stack, bsize, false);
if mode_luma == PredictionMode::NEARESTMV &&
(mv_stack.len() > 0 && (mv_stack[0].this_mv.row != mv.row || mv_stack[0].this_mv.col != mv.col) ||
mv_stack.len() == 0 && (0 != mv.row || 0 != mv.col)) {
mode_luma = PredictionMode::NEWMV;
mode_chroma = PredictionMode::NEWMV;
}
// FIXME: every final block that has gone through the RDO decision process is encoded twice
cdef_coded = encode_block_a(seq, cw, if cdef_coded {w_post_cdef} else {w_pre_cdef},
bsize, bo, skip);
......
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