summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_encoder.c8
-rw-r--r--vp9/encoder/vp9_mcomp.c41
-rw-r--r--vp9/encoder/vp9_mcomp.h6
-rw-r--r--vp9/encoder/vp9_rdopt.c34
4 files changed, 58 insertions, 31 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 41f94197f..04d25247d 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5660,10 +5660,10 @@ uint32_t motion_compensated_prediction(VP9_COMP *cpi, ThreadData *td,
(void)sadpb;
prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row, mi_col, rf_idx, bsize,
nb_full_mvs);
- vp9_full_pixel_diamond_new(cpi, x, &best_ref_mv1_full, step_param, lambda,
- MAX_MVSEARCH_STEPS - 1 - step_param, 1,
- &cpi->fn_ptr[bsize], nb_full_mvs, tpl_stats,
- rf_idx);
+ vp9_full_pixel_diamond_new(
+ cpi, x, &best_ref_mv1_full, step_param, lambda, 1, &cpi->fn_ptr[bsize],
+ nb_full_mvs, &tpl_stats->mv_arr[rf_idx].as_mv,
+ &tpl_stats->mv_dist[rf_idx], &tpl_stats->mv_cost[rf_idx]);
#else
(void)frame_idx;
(void)mi_row;
diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c
index a2543035c..235f0345e 100644
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -2240,24 +2240,18 @@ unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x,
refining search */
double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
MV *mvp_full, int step_param, double lambda,
- int further_steps, int do_refine,
+ int do_refine,
const vp9_variance_fn_ptr_t *fn_ptr,
- const int_mv *nb_full_mvs,
- TplDepStats *tpl_stats, int rf_idx) {
- MV *dst_mv = &tpl_stats->mv_arr[rf_idx].as_mv;
- MV temp_mv;
+ const int_mv *nb_full_mvs, MV *best_mv,
+ double *best_mv_dist, double *best_mv_cost) {
int n, num00 = 0;
double thissme;
- double mv_dist;
- double mv_cost;
double bestsme;
+ const int further_steps = MAX_MVSEARCH_STEPS - 1 - step_param;
vpx_clear_system_state();
- bestsme = vp9_diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, &temp_mv,
- &mv_dist, &mv_cost, step_param, lambda,
- &n, fn_ptr, nb_full_mvs);
- *dst_mv = temp_mv;
- tpl_stats->mv_dist[rf_idx] = mv_dist;
- tpl_stats->mv_cost[rf_idx] = mv_cost;
+ bestsme = vp9_diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, best_mv,
+ best_mv_dist, best_mv_cost, step_param,
+ lambda, &n, fn_ptr, nb_full_mvs);
// If there won't be more n-step search, check to see if refining search is
// needed.
@@ -2268,6 +2262,9 @@ double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
if (num00) {
num00--;
} else {
+ MV temp_mv;
+ double mv_dist;
+ double mv_cost;
thissme = vp9_diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, &temp_mv,
&mv_dist, &mv_cost, step_param + n,
lambda, &num00, fn_ptr, nb_full_mvs);
@@ -2276,9 +2273,9 @@ double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
if (thissme < bestsme) {
bestsme = thissme;
- *dst_mv = temp_mv;
- tpl_stats->mv_dist[rf_idx] = mv_dist;
- tpl_stats->mv_cost[rf_idx] = mv_cost;
+ *best_mv = temp_mv;
+ *best_mv_dist = mv_dist;
+ *best_mv_cost = mv_cost;
}
}
}
@@ -2286,15 +2283,17 @@ double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
// final 1-away diamond refining search
if (do_refine) {
const int search_range = 8;
- MV best_mv = *dst_mv;
+ MV temp_mv = *best_mv;
+ double mv_dist;
+ double mv_cost;
thissme =
- vp9_refining_search_sad_new(x, &best_mv, &mv_dist, &mv_cost, lambda,
+ vp9_refining_search_sad_new(x, &temp_mv, &mv_dist, &mv_cost, lambda,
search_range, fn_ptr, nb_full_mvs);
if (thissme < bestsme) {
bestsme = thissme;
- *dst_mv = best_mv;
- tpl_stats->mv_dist[rf_idx] = mv_dist;
- tpl_stats->mv_cost[rf_idx] = mv_cost;
+ *best_mv = temp_mv;
+ *best_mv_dist = mv_dist;
+ *best_mv_cost = mv_cost;
}
}
return bestsme;
diff --git a/vp9/encoder/vp9_mcomp.h b/vp9/encoder/vp9_mcomp.h
index a159cb288..54f68ca74 100644
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -130,10 +130,10 @@ double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
double vp9_full_pixel_diamond_new(const struct VP9_COMP *cpi, MACROBLOCK *x,
MV *mvp_full, int step_param, double lambda,
- int further_steps, int do_refine,
+ int do_refine,
const vp9_variance_fn_ptr_t *fn_ptr,
- const int_mv *nb_full_mvs,
- struct TplDepStats *tpl_stats, int rf_idx);
+ const int_mv *nb_full_mvs, MV *best_mv,
+ double *best_mv_dist, double *best_mv_cost);
double av1_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs);
#endif // CONFIG_NON_GREEDY_MV
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 9cde479cd..2e1aa1d30 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -2322,9 +2322,7 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
const VP9_COMMON *cm = &cpi->common;
MODE_INFO *mi = xd->mi[0];
struct buf_2d backup_yv12[MAX_MB_PLANE] = { { 0, 0 } };
- int bestsme = INT_MAX;
int step_param;
- int sadpb = x->sadperbit16;
MV mvp_full;
int ref = mi->ref_frame[0];
MV ref_mv = x->mbmi_ext->ref_mvs[ref][0].as_mv;
@@ -2335,8 +2333,21 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
vp9_get_scaled_ref_frame(cpi, ref);
const int pw = num_4x4_blocks_wide_lookup[bsize] << 2;
const int ph = num_4x4_blocks_high_lookup[bsize] << 2;
-
MV pred_mv[3];
+
+#if CONFIG_NON_GREEDY_MV
+ double mv_dist = 0;
+ double mv_cost = 0;
+ double lambda = 0;
+ double bestsme;
+ int_mv nb_full_mvs[NB_MVS_NUM];
+ // TODO(angiebird): Set nb_full_mvs properly.
+ vp9_zero(nb_full_mvs);
+#else // CONFIG_NON_GREEDY_MV
+ int bestsme = INT_MAX;
+ int sadpb = x->sadperbit16;
+#endif // CONFIG_NON_GREEDY_MV
+
pred_mv[0] = x->mbmi_ext->ref_mvs[ref][0].as_mv;
pred_mv[1] = x->mbmi_ext->ref_mvs[ref][1].as_mv;
pred_mv[2] = x->pred_mv[ref];
@@ -2406,14 +2417,24 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
mvp_full.col >>= 3;
mvp_full.row >>= 3;
+#if CONFIG_NON_GREEDY_MV
+ bestsme = vp9_full_pixel_diamond_new(cpi, x, &mvp_full, step_param, lambda, 1,
+ &cpi->fn_ptr[bsize], nb_full_mvs,
+ &tmp_mv->as_mv, &mv_dist, &mv_cost);
+#else // CONFIG_NON_GREEDY_MV
bestsme = vp9_full_pixel_search(
cpi, x, bsize, &mvp_full, step_param, cpi->sf.mv.search_method, sadpb,
cond_cost_list(cpi, cost_list), &ref_mv, &tmp_mv->as_mv, INT_MAX, 1);
+#endif // CONFIG_NON_GREEDY_MV
if (cpi->sf.enhanced_full_pixel_motion_search) {
int i;
for (i = 0; i < 3; ++i) {
+#if CONFIG_NON_GREEDY_MV
+ double this_me;
+#else // CONFIG_NON_GREEDY_MV
int this_me;
+#endif // CONFIG_NON_GREEDY_MV
MV this_mv;
int diff_row;
int diff_col;
@@ -2437,11 +2458,18 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
mvp_full = pred_mv[i];
mvp_full.col >>= 3;
mvp_full.row >>= 3;
+#if CONFIG_NON_GREEDY_MV
+ this_me = vp9_full_pixel_diamond_new(
+ cpi, x, &mvp_full, VPXMAX(step_param, MAX_MVSEARCH_STEPS - step),
+ lambda, 1, &cpi->fn_ptr[bsize], nb_full_mvs, &tmp_mv->as_mv, &mv_dist,
+ &mv_cost);
+#else // CONFIG_NON_GREEDY_MV
this_me = vp9_full_pixel_search(
cpi, x, bsize, &mvp_full,
VPXMAX(step_param, MAX_MVSEARCH_STEPS - step),
cpi->sf.mv.search_method, sadpb, cond_cost_list(cpi, cost_list),
&ref_mv, &this_mv, INT_MAX, 1);
+#endif // CONFIG_NON_GREEDY_MV
if (this_me < bestsme) {
tmp_mv->as_mv = this_mv;
bestsme = this_me;