#include "vp9/encoder/vp9_extend.h"
#include "vp9/encoder/vp9_firstpass.h"
#include "vp9/encoder/vp9_mbgraph.h"
+#if CONFIG_NON_GREEDY_MV
+#include "vp9/encoder/vp9_mcomp.h"
+#endif
#include "vp9/encoder/vp9_multi_thread.h"
#include "vp9/encoder/vp9_noise_estimate.h"
#include "vp9/encoder/vp9_picklpf.h"
#define CHANGE_MV_SEARCH_ORDER 1
#define USE_PQSORT 1
+#define RE_COMPUTE_MV_INCONSISTENCY 1
#if CHANGE_MV_SEARCH_ORDER
#if USE_PQSORT
TplDepStats *this_tpl_stats =
&tpl_frame->tpl_stats_ptr[mi_row * tpl_frame->stride + mi_col];
for (rf_idx = 0; rf_idx < 3; ++rf_idx) {
+#if RE_COMPUTE_MV_INCONSISTENCY
+ MV full_mv;
+ int_mv nb_full_mvs[NB_MVS_NUM];
+ prepare_nb_full_mvs(tpl_frame, mi_row, mi_col, rf_idx, bsize,
+ nb_full_mvs);
+ full_mv.row = this_tpl_stats->mv_arr[rf_idx].as_mv.row >> 3;
+ full_mv.col = this_tpl_stats->mv_arr[rf_idx].as_mv.col >> 3;
+ this_tpl_stats->mv_cost[rf_idx] =
+ av1_nb_mvs_inconsistency(&full_mv, nb_full_mvs);
+#endif // RE_COMPUTE_MV_INCONSISTENCY
tpl_frame->mv_dist_sum[rf_idx] += this_tpl_stats->mv_dist[rf_idx];
tpl_frame->mv_cost_sum[rf_idx] += this_tpl_stats->mv_cost[rf_idx];
}
}
-#endif
+#endif // CONFIG_NON_GREEDY_MV
}
}
}
}
#if CONFIG_NON_GREEDY_MV
-static double nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs) {
+double av1_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs) {
int i;
double best_cost = -1;
vpx_clear_system_state();
// Check the starting position
*best_mv_dist = fn_ptr->sdf(what, what_stride, in_what, in_what_stride);
- *best_mv_cost = nb_mvs_inconsistency(best_full_mv, nb_full_mvs);
+ *best_mv_cost = av1_nb_mvs_inconsistency(best_full_mv, nb_full_mvs);
bestsad = (*best_mv_dist) + lambda * (*best_mv_cost);
i = 0;
const MV this_mv = { best_full_mv->row + ss_mv[i].row,
best_full_mv->col + ss_mv[i].col };
const double mv_dist = sad_array[t];
- const double mv_cost = nb_mvs_inconsistency(&this_mv, nb_full_mvs);
+ const double mv_cost =
+ av1_nb_mvs_inconsistency(&this_mv, nb_full_mvs);
double thissad = mv_dist + lambda * mv_cost;
if (thissad < bestsad) {
bestsad = thissad;
const uint8_t *const check_here = ss_os[i] + best_address;
const double mv_dist =
fn_ptr->sdf(what, what_stride, check_here, in_what_stride);
- const double mv_cost = nb_mvs_inconsistency(&this_mv, nb_full_mvs);
+ const double mv_cost =
+ av1_nb_mvs_inconsistency(&this_mv, nb_full_mvs);
double thissad = mv_dist + lambda * mv_cost;
if (thissad < bestsad) {
bestsad = thissad;
vpx_clear_system_state();
*best_mv_dist =
fn_ptr->sdf(what->buf, what->stride, best_address, in_what->stride);
- *best_mv_cost = nb_mvs_inconsistency(best_full_mv, nb_full_mvs);
+ *best_mv_cost = av1_nb_mvs_inconsistency(best_full_mv, nb_full_mvs);
best_sad = (*best_mv_dist) + lambda * (*best_mv_cost);
for (i = 0; i < search_range; i++) {
const MV mv = { best_full_mv->row + neighbors[j].row,
best_full_mv->col + neighbors[j].col };
const double mv_dist = sads[j];
- const double mv_cost = nb_mvs_inconsistency(&mv, nb_full_mvs);
+ const double mv_cost = av1_nb_mvs_inconsistency(&mv, nb_full_mvs);
const double thissad = mv_dist + lambda * mv_cost;
if (thissad < best_sad) {
best_sad = thissad;
const double mv_dist =
fn_ptr->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &mv), in_what->stride);
- const double mv_cost = nb_mvs_inconsistency(&mv, nb_full_mvs);
+ const double mv_cost = av1_nb_mvs_inconsistency(&mv, nb_full_mvs);
const double thissad = mv_dist + lambda * mv_cost;
if (thissad < best_sad) {
best_sad = thissad;