ref: 43cab8f4e84b5baadda093a5a204a746921f0ac0
parent: 19bda215d0be6995ba230f31939c2743fc8b98ac
author: Angie Chiang <[email protected]>
date: Thu Jul 11 11:25:31 EDT 2019
Simplify code in exhaustive_mesh_search_new Change-Id: Id6a8b117b066a56e9312f528ec8f417dd4b2a2d8
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -1932,7 +1932,6 @@
const MACROBLOCKD *const xd = &x->e_mbd;
const struct buf_2d *const what = &x->plane[0].src;
const struct buf_2d *const in_what = &xd->plane[0].pre[0];
- MV fcenter_mv = { center_mv->row, center_mv->col };
int64_t best_sad;
int r, c, i;
int start_col, end_col, start_row, end_row;
@@ -1939,26 +1938,25 @@
int col_step = (step > 1) ? step : 4;
assert(step >= 1);
+ assert(is_mv_in(&x->mv_limits, center_mv));
- clamp_mv(&fcenter_mv, x->mv_limits.col_min, x->mv_limits.col_max,
- x->mv_limits.row_min, x->mv_limits.row_max);
- *best_mv = fcenter_mv;
+ *best_mv = *center_mv;
best_sad =
((int64_t)fn_ptr->sdf(what->buf, what->stride,
- get_buf_from_mv(in_what, &fcenter_mv),
+ get_buf_from_mv(in_what, center_mv),
in_what->stride)
<< LOG2_PRECISION) +
- lambda * vp9_nb_mvs_inconsistency(&fcenter_mv, nb_full_mvs, full_mv_num);
- start_row = VPXMAX(-range, x->mv_limits.row_min - fcenter_mv.row);
- start_col = VPXMAX(-range, x->mv_limits.col_min - fcenter_mv.col);
- end_row = VPXMIN(range, x->mv_limits.row_max - fcenter_mv.row);
- end_col = VPXMIN(range, x->mv_limits.col_max - fcenter_mv.col);
+ lambda * vp9_nb_mvs_inconsistency(best_mv, nb_full_mvs, full_mv_num);
+ start_row = VPXMAX(center_mv->row - range, x->mv_limits.row_min);
+ start_col = VPXMAX(center_mv->col - range, x->mv_limits.col_min);
+ end_row = VPXMIN(center_mv->row + range, x->mv_limits.row_max);
+ end_col = VPXMIN(center_mv->col + range, x->mv_limits.col_max);
for (r = start_row; r <= end_row; r += step) {
for (c = start_col; c <= end_col; c += col_step) {
// Step > 1 means we are not checking every location in this pass.
if (step > 1) {
- const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c };
+ const MV mv = { r, c };
int64_t sad =
(int64_t)fn_ptr->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &mv), in_what->stride)
@@ -1977,7 +1975,7 @@
unsigned int sads[4];
const uint8_t *addrs[4];
for (i = 0; i < 4; ++i) {
- const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c + i };
+ const MV mv = { r, c + i };
addrs[i] = get_buf_from_mv(in_what, &mv);
}
fn_ptr->sdx4df(what->buf, what->stride, addrs, in_what->stride, sads);
@@ -1985,7 +1983,7 @@
for (i = 0; i < 4; ++i) {
int64_t sad = (int64_t)sads[i] << LOG2_PRECISION;
if (sad < best_sad) {
- const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c + i };
+ const MV mv = { r, c + i };
sad += lambda *
vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
if (sad < best_sad) {
@@ -1996,7 +1994,7 @@
}
} else {
for (i = 0; i < end_col - c; ++i) {
- const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c + i };
+ const MV mv = { r, c + i };
int64_t sad = (int64_t)fn_ptr->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &mv),
in_what->stride)