summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Chiang <angiebird@google.com>2018-11-15 23:40:59 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-11-15 23:40:59 +0000
commit22ca684d8879c3897c97c1c96b5b6506b7d93840 (patch)
treef66cc0b1cd50ff01bc5946bb6da953b569124d37
parente6f889c120f65bb3d612aec8e6b1e7e4fcd25378 (diff)
parentba4fbc4b8d46be713b171fd8e28ad23a164ecdfa (diff)
downloadlibvpx-22ca684d8879c3897c97c1c96b5b6506b7d93840.tar
libvpx-22ca684d8879c3897c97c1c96b5b6506b7d93840.tar.gz
libvpx-22ca684d8879c3897c97c1c96b5b6506b7d93840.tar.bz2
libvpx-22ca684d8879c3897c97c1c96b5b6506b7d93840.zip
Merge changes Ib9d16a4b,I6061f38c
* changes: Refactor av1_nb_mvs_inconsistency() Recompute mv inconsistency after mv search is done
-rw-r--r--vp9/encoder/vp9_encoder.c16
-rw-r--r--vp9/encoder/vp9_mcomp.c28
-rw-r--r--vp9/encoder/vp9_mcomp.h2
3 files changed, 31 insertions, 15 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 35f5aa324..549430ab7 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -52,6 +52,9 @@
#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"
@@ -6089,6 +6092,7 @@ static void do_motion_search(VP9_COMP *cpi, ThreadData *td, int frame_idx,
#define CHANGE_MV_SEARCH_ORDER 1
#define USE_PQSORT 1
+#define RE_COMPUTE_MV_INCONSISTENCY 1
#if CHANGE_MV_SEARCH_ORDER
#if USE_PQSORT
@@ -6327,11 +6331,21 @@ void mc_flow_dispenser(VP9_COMP *cpi, GF_PICTURE *gf_picture, int frame_idx,
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
}
}
}
diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c
index 496251622..a2543035c 100644
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -1733,9 +1733,10 @@ static int exhuastive_mesh_search(const MACROBLOCK *x, MV *ref_mv, MV *best_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;
+ int update = 0;
+ double best_cost = 0;
vpx_clear_system_state();
for (i = 0; i < NB_MVS_NUM; ++i) {
if (nb_mvs[i].as_int != INVALID_MV) {
@@ -1744,18 +1745,15 @@ static double nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs) {
const double col_diff = mv->col - nb_mv.col;
double cost = row_diff * row_diff + col_diff * col_diff;
cost = log2(1 + cost);
- if (best_cost < 0) {
+ if (update == 0) {
best_cost = cost;
+ update = 1;
} else {
best_cost = cost < best_cost ? cost : best_cost;
}
}
}
- if (best_cost < 0) {
- return 0;
- } else {
- return best_cost;
- }
+ return best_cost;
}
double vp9_diamond_search_sad_new(const MACROBLOCK *x,
@@ -1801,7 +1799,7 @@ double vp9_diamond_search_sad_new(const MACROBLOCK *x,
// 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;
@@ -1834,7 +1832,8 @@ double vp9_diamond_search_sad_new(const MACROBLOCK *x,
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;
@@ -1854,7 +1853,8 @@ double vp9_diamond_search_sad_new(const MACROBLOCK *x,
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;
@@ -2440,7 +2440,7 @@ double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
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++) {
@@ -2462,7 +2462,7 @@ double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
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;
@@ -2480,7 +2480,7 @@ double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
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;
diff --git a/vp9/encoder/vp9_mcomp.h b/vp9/encoder/vp9_mcomp.h
index 558ecbcd8..a159cb288 100644
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -134,6 +134,8 @@ double vp9_full_pixel_diamond_new(const struct VP9_COMP *cpi, MACROBLOCK *x,
const vp9_variance_fn_ptr_t *fn_ptr,
const int_mv *nb_full_mvs,
struct TplDepStats *tpl_stats, int rf_idx);
+
+double av1_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs);
#endif // CONFIG_NON_GREEDY_MV
#ifdef __cplusplus
} // extern "C"