ref: e49ef1476db5083e002863c7c2b8b5188c298d48
parent: 7fc5f6739a953735db0bd7e2dd38d22849d98d14
author: Angie Chiang <angiebird@google.com>
date: Thu Oct 4 11:17:02 EDT 2018
Fix bug in prepare_nb_full_mvs Previously, the prepare_nb_full_mvs might construct nb_full_mv with wrong mvs (from other ref frame). The following changes will fix the bug. 1) Let ready in TplDepStats becomes int array 2) Add parameter rf_idx 3) Use mv_arr instead of mv to build the nb_full_mv Change-Id: I199798aec4c6762d54799562e142457cc26ee043
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5445,7 +5445,7 @@
#if CONFIG_NON_GREEDY_MV
static void prepare_nb_full_mvs(const TplDepFrame *tpl_frame, int mi_row,
- int mi_col, int_mv *nb_full_mvs) {
+ int mi_col, int rf_idx, int_mv *nb_full_mvs) {
const int dirs[NB_MVS_NUM][2] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } };
int i;
for (i = 0; i < NB_MVS_NUM; ++i) {
@@ -5456,9 +5456,9 @@
const TplDepStats *tpl_ptr =
&tpl_frame
->tpl_stats_ptr[(mi_row + r) * tpl_frame->stride + mi_col + c];
- if (tpl_ptr->ready) {
- nb_full_mvs[i].as_mv.row = tpl_ptr->mv.as_mv.row >> 3;
- nb_full_mvs[i].as_mv.col = tpl_ptr->mv.as_mv.col >> 3;
+ if (tpl_ptr->ready[rf_idx]) {
+ nb_full_mvs[i].as_mv.row = tpl_ptr->mv_arr[rf_idx].as_mv.row >> 3;
+ nb_full_mvs[i].as_mv.col = tpl_ptr->mv_arr[rf_idx].as_mv.col >> 3;
} else {
nb_full_mvs[i].as_int = INVALID_MV;
}
@@ -5521,7 +5521,8 @@
#if CONFIG_NON_GREEDY_MV
(void)search_method;
(void)sadpb;
- prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row, mi_col, nb_full_mvs);
+ prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row, mi_col, rf_idx,
+ 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,
@@ -5608,6 +5609,7 @@
#if CONFIG_NON_GREEDY_MV
int rf_idx;
for (rf_idx = 0; rf_idx < 3; ++rf_idx) {
+ tpl_ptr->ready[rf_idx] = src_stats->ready[rf_idx];
tpl_ptr->mv_dist[rf_idx] = src_stats->mv_dist[rf_idx];
tpl_ptr->mv_cost[rf_idx] = src_stats->mv_cost[rf_idx];
tpl_ptr->inter_cost_arr[rf_idx] = src_stats->inter_cost;
@@ -5616,7 +5618,6 @@
tpl_ptr->mv_arr[rf_idx].as_int = src_stats->mv_arr[rf_idx].as_int;
}
tpl_ptr->feature_score = src_stats->feature_score;
- tpl_ptr->ready = 1;
#endif
tpl_ptr->intra_cost = intra_cost;
tpl_ptr->inter_cost = inter_cost;
@@ -5837,9 +5838,13 @@
int_mv mv;
if (ref_frame[rf_idx] == NULL) {
#if CONFIG_NON_GREEDY_MV
- tpl_stats->inter_cost_arr[rf_idx] = -1;
+ tpl_stats->ready[rf_idx] = 0;
#endif
continue;
+ } else {
+#if CONFIG_NON_GREEDY_MV
+ tpl_stats->ready[rf_idx] = 1;
+#endif
}
#if CONFIG_NON_GREEDY_MV
--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -291,7 +291,7 @@
int_mv mv;
#if CONFIG_NON_GREEDY_MV
- int ready;
+ int ready[3];
double mv_dist[3];
double mv_cost[3];
int64_t inter_cost_arr[3];