Commit 0bc9d033 authored by Frank Bossen's avatar Frank Bossen Committed by fbossen

Avoid testing same MV multiple times in RDO loop

Reduces encoder runtime by about 5% at default speed setting
parent 3fb9b3cd
......@@ -43,10 +43,7 @@ pub static RAV1E_INTRA_MODES_MINIMAL: &'static [PredictionMode] = &[
];
pub static RAV1E_INTER_MODES_MINIMAL: &'static [PredictionMode] = &[
PredictionMode::GLOBALMV,
PredictionMode::NEARESTMV,
PredictionMode::NEAR0MV,
PredictionMode::NEWMV
PredictionMode::NEARESTMV
];
pub static RAV1E_INTER_COMPOUND_MODES: &'static [PredictionMode] = &[
......
......@@ -402,7 +402,14 @@ pub fn rdo_mode_decision(
for &x in RAV1E_INTER_MODES_MINIMAL {
mode_set.push((x, i));
}
if fi.config.speed <= 2 {
if mv_stack.len() >= 1 {
mode_set.push((PredictionMode::NEAR0MV, i));
}
if mv_stack.len() >= 2 {
mode_set.push((PredictionMode::GLOBALMV, i));
}
let include_near_mvs = fi.config.speed <= 2;
if include_near_mvs {
if mv_stack.len() >= 3 {
mode_set.push((PredictionMode::NEAR1MV, i));
}
......@@ -410,6 +417,11 @@ pub fn rdo_mode_decision(
mode_set.push((PredictionMode::NEAR2MV, i));
}
}
if !mv_stack.iter().take(if include_near_mvs {4} else {2})
.any(|ref x| x.this_mv.row == mvs_from_me[i][0].row && x.this_mv.col == mvs_from_me[i][0].col)
&& (mvs_from_me[i][0].row != 0 || mvs_from_me[i][0].col != 0) {
mode_set.push((PredictionMode::NEWMV, i));
}
}
mv_stacks.push(mv_stack);
}
......
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