Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2050)

Unified Diff: source/libvpx/vp9/encoder/vp9_mcomp.c

Issue 111463005: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_mcomp.h ('k') | source/libvpx/vp9/encoder/vp9_modecosts.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp9/encoder/vp9_mcomp.c
===================================================================
--- source/libvpx/vp9/encoder/vp9_mcomp.c (revision 240950)
+++ source/libvpx/vp9/encoder/vp9_mcomp.c (working copy)
@@ -24,7 +24,7 @@
// #define NEW_DIAMOND_SEARCH
-void vp9_clamp_mv_min_max(MACROBLOCK *x, MV *mv) {
+void vp9_set_mv_search_range(MACROBLOCK *x, MV *mv) {
const int col_min = (mv->col >> 3) - MAX_FULL_PEL_VAL + (mv->col & 7 ? 1 : 0);
const int row_min = (mv->row >> 3) - MAX_FULL_PEL_VAL + (mv->row & 7 ? 1 : 0);
const int col_max = (mv->col >> 3) + MAX_FULL_PEL_VAL;
@@ -51,9 +51,6 @@
while ((size << sr) < MAX_FULL_PEL_VAL)
sr++;
- if (sr)
- sr--;
-
sr += cpi->sf.reduce_first_step_size;
sr = MIN(sr, (cpi->sf.max_step_search_steps - 2));
return sr;
@@ -1069,11 +1066,130 @@
#undef CHECK_POINT
#undef CHECK_BETTER
+int vp9_full_range_search_c(MACROBLOCK *x, MV *ref_mv, MV *best_mv,
+ int search_param, int sad_per_bit, int *num00,
+ vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost,
+ int *mvcost[2], const MV *center_mv) {
+ const MACROBLOCKD* const xd = &x->e_mbd;
+ uint8_t *what = x->plane[0].src.buf;
+ int what_stride = x->plane[0].src.stride;
+ uint8_t *in_what;
+ int in_what_stride = xd->plane[0].pre[0].stride;
+ uint8_t *best_address;
+
+ MV this_mv;
+
+ int bestsad = INT_MAX;
+ int ref_row, ref_col;
+
+ uint8_t *check_here;
+ int thissad;
+ MV fcenter_mv;
+
+ int *mvjsadcost = x->nmvjointsadcost;
+ int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
+
+ int tr, tc;
+ int best_tr = 0;
+ int best_tc = 0;
+ int range = 64;
+
+ int start_col, end_col;
+ int start_row, end_row;
+ int i;
+
+ fcenter_mv.row = center_mv->row >> 3;
+ fcenter_mv.col = center_mv->col >> 3;
+
+ clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
+ ref_row = ref_mv->row;
+ ref_col = ref_mv->col;
+ *num00 = 11;
+ best_mv->row = ref_row;
+ best_mv->col = ref_col;
+
+ // Work out the start point for the search
+ in_what = (uint8_t *)(xd->plane[0].pre[0].buf +
+ (ref_row * (xd->plane[0].pre[0].stride)) + ref_col);
+ best_address = in_what;
+
+ // Check the starting position
+ bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff)
+ + mvsad_err_cost(best_mv, &fcenter_mv,
+ mvjsadcost, mvsadcost, sad_per_bit);
+
+ start_row = MAX(-range, x->mv_row_min - ref_row);
+ start_col = MAX(-range, x->mv_col_min - ref_col);
+ end_row = MIN(range, x->mv_row_max - ref_row);
+ end_col = MIN(range, x->mv_col_max - ref_col);
+
+ for (tr = start_row; tr <= end_row; ++tr) {
+ for (tc = start_col; tc <= end_col; tc += 4) {
+ if ((tc + 3) <= end_col) {
+ unsigned int sad_array[4];
+ unsigned char const *addr_ref[4];
+ for (i = 0; i < 4; ++i)
+ addr_ref[i] = in_what + tr * in_what_stride + tc + i;
+
+ fn_ptr->sdx4df(what, what_stride, addr_ref, in_what_stride, sad_array);
+
+ for (i = 0; i < 4; ++i) {
+ if (sad_array[i] < bestsad) {
+ this_mv.row = ref_row + tr;
+ this_mv.col = ref_col + tc + i;
+ thissad = sad_array[i] +
+ mvsad_err_cost(&this_mv, &fcenter_mv,
+ mvjsadcost, mvsadcost, sad_per_bit);
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_tr = tr;
+ best_tc = tc + i;
+ }
+ }
+ }
+ } else {
+ for (i = 0; i < end_col - tc; ++i) {
+ check_here = in_what + tr * in_what_stride + tc + i;
+ thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride,
+ bestsad);
+
+ if (thissad < bestsad) {
+ this_mv.row = ref_row + tr;
+ this_mv.col = ref_col + tc + i;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
+ mvjsadcost, mvsadcost, sad_per_bit);
+
+ if (thissad < bestsad) {
+ bestsad = thissad;
+ best_tr = tr;
+ best_tc = tc + i;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ best_mv->row += best_tr;
+ best_mv->col += best_tc;
+
+ this_mv.row = best_mv->row * 8;
+ this_mv.col = best_mv->col * 8;
+
+ if (bestsad == INT_MAX)
+ return INT_MAX;
+
+ return fn_ptr->vf(what, what_stride, best_address, in_what_stride,
+ (unsigned int *)(&thissad)) +
+ mv_err_cost(&this_mv, center_mv,
+ mvjcost, mvcost, x->errorperbit);
+}
+
int vp9_diamond_search_sad_c(MACROBLOCK *x,
- int_mv *ref_mv, int_mv *best_mv,
+ MV *ref_mv, MV *best_mv,
int search_param, int sad_per_bit, int *num00,
vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost,
- int *mvcost[2], int_mv *center_mv) {
+ int *mvcost[2], const MV *center_mv) {
int i, j, step;
const MACROBLOCKD* const xd = &x->e_mbd;
@@ -1084,7 +1200,7 @@
uint8_t *best_address;
int tot_steps;
- int_mv this_mv;
+ MV this_mv;
int bestsad = INT_MAX;
int best_site = 0;
@@ -1101,25 +1217,24 @@
int *mvjsadcost = x->nmvjointsadcost;
int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+ fcenter_mv.as_mv.row = center_mv->row >> 3;
+ fcenter_mv.as_mv.col = center_mv->col >> 3;
- clamp_mv(&ref_mv->as_mv,
- x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
- ref_row = ref_mv->as_mv.row;
- ref_col = ref_mv->as_mv.col;
+ clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
+ ref_row = ref_mv->row;
+ ref_col = ref_mv->col;
*num00 = 0;
- best_mv->as_mv.row = ref_row;
- best_mv->as_mv.col = ref_col;
+ best_mv->row = ref_row;
+ best_mv->col = ref_col;
// Work out the start point for the search
in_what = (uint8_t *)(xd->plane[0].pre[0].buf +
- (ref_row * (xd->plane[0].pre[0].stride)) + ref_col);
+ ref_row * in_what_stride + ref_col);
best_address = in_what;
// Check the starting position
bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff)
- + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv,
+ + mvsad_err_cost(best_mv, &fcenter_mv.as_mv,
mvjsadcost, mvsadcost, sad_per_bit);
// search_param determines the length of the initial step and hence the number
@@ -1134,8 +1249,8 @@
for (step = 0; step < tot_steps; step++) {
for (j = 0; j < x->searches_per_step; j++) {
// Trap illegal vectors
- this_row_offset = best_mv->as_mv.row + ss[i].mv.row;
- this_col_offset = best_mv->as_mv.col + ss[i].mv.col;
+ this_row_offset = best_mv->row + ss[i].mv.row;
+ this_col_offset = best_mv->col + ss[i].mv.col;
if ((this_col_offset > x->mv_col_min) &&
(this_col_offset < x->mv_col_max) &&
@@ -1146,9 +1261,9 @@
bestsad);
if (thissad < bestsad) {
- this_mv.as_mv.row = this_row_offset;
- this_mv.as_mv.col = this_col_offset;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.row = this_row_offset;
+ this_mv.col = this_col_offset;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv.as_mv,
mvjsadcost, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
@@ -1162,14 +1277,14 @@
}
if (best_site != last_site) {
- best_mv->as_mv.row += ss[best_site].mv.row;
- best_mv->as_mv.col += ss[best_site].mv.col;
+ best_mv->row += ss[best_site].mv.row;
+ best_mv->col += ss[best_site].mv.col;
best_address += ss[best_site].offset;
last_site = best_site;
#if defined(NEW_DIAMOND_SEARCH)
while (1) {
- this_row_offset = best_mv->as_mv.row + ss[best_site].mv.row;
- this_col_offset = best_mv->as_mv.col + ss[best_site].mv.col;
+ this_row_offset = best_mv->row + ss[best_site].mv.row;
+ this_col_offset = best_mv->col + ss[best_site].mv.col;
if ((this_col_offset > x->mv_col_min) &&
(this_col_offset < x->mv_col_max) &&
(this_row_offset > x->mv_row_min) &&
@@ -1178,14 +1293,14 @@
thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride,
bestsad);
if (thissad < bestsad) {
- this_mv.as_mv.row = this_row_offset;
- this_mv.as_mv.col = this_col_offset;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.row = this_row_offset;
+ this_mv.col = this_col_offset;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv.as_mv,
mvjsadcost, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
bestsad = thissad;
- best_mv->as_mv.row += ss[best_site].mv.row;
- best_mv->as_mv.col += ss[best_site].mv.col;
+ best_mv->row += ss[best_site].mv.row;
+ best_mv->col += ss[best_site].mv.col;
best_address += ss[best_site].offset;
continue;
}
@@ -1199,23 +1314,24 @@
}
}
- this_mv.as_mv.row = best_mv->as_mv.row * 8;
- this_mv.as_mv.col = best_mv->as_mv.col * 8;
+ this_mv.row = best_mv->row * 8;
+ this_mv.col = best_mv->col * 8;
if (bestsad == INT_MAX)
return INT_MAX;
return fn_ptr->vf(what, what_stride, best_address, in_what_stride,
(unsigned int *)(&thissad)) +
- mv_err_cost(&this_mv.as_mv, &center_mv->as_mv,
+ mv_err_cost(&this_mv, center_mv,
mvjcost, mvcost, x->errorperbit);
}
int vp9_diamond_search_sadx4(MACROBLOCK *x,
- int_mv *ref_mv, int_mv *best_mv, int search_param,
+ MV *ref_mv, MV *best_mv, int search_param,
int sad_per_bit, int *num00,
vp9_variance_fn_ptr_t *fn_ptr,
- int *mvjcost, int *mvcost[2], int_mv *center_mv) {
+ int *mvjcost, int *mvcost[2],
+ const MV *center_mv) {
int i, j, step;
const MACROBLOCKD* const xd = &x->e_mbd;
@@ -1226,7 +1342,7 @@
uint8_t *best_address;
int tot_steps;
- int_mv this_mv;
+ MV this_mv;
unsigned int bestsad = INT_MAX;
int best_site = 0;
@@ -1245,25 +1361,24 @@
int *mvjsadcost = x->nmvjointsadcost;
int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+ fcenter_mv.as_mv.row = center_mv->row >> 3;
+ fcenter_mv.as_mv.col = center_mv->col >> 3;
- clamp_mv(&ref_mv->as_mv,
- x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
- ref_row = ref_mv->as_mv.row;
- ref_col = ref_mv->as_mv.col;
+ clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
+ ref_row = ref_mv->row;
+ ref_col = ref_mv->col;
*num00 = 0;
- best_mv->as_mv.row = ref_row;
- best_mv->as_mv.col = ref_col;
+ best_mv->row = ref_row;
+ best_mv->col = ref_col;
// Work out the start point for the search
in_what = (uint8_t *)(xd->plane[0].pre[0].buf +
- (ref_row * (xd->plane[0].pre[0].stride)) + ref_col);
+ ref_row * in_what_stride + ref_col);
best_address = in_what;
// Check the starting position
bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff)
- + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv,
+ + mvsad_err_cost(best_mv, &fcenter_mv.as_mv,
mvjsadcost, mvsadcost, sad_per_bit);
// search_param determines the length of the initial step and hence the number
@@ -1281,10 +1396,10 @@
// All_in is true if every one of the points we are checking are within
// the bounds of the image.
- all_in &= ((best_mv->as_mv.row + ss[i].mv.row) > x->mv_row_min);
- all_in &= ((best_mv->as_mv.row + ss[i + 1].mv.row) < x->mv_row_max);
- all_in &= ((best_mv->as_mv.col + ss[i + 2].mv.col) > x->mv_col_min);
- all_in &= ((best_mv->as_mv.col + ss[i + 3].mv.col) < x->mv_col_max);
+ all_in &= ((best_mv->row + ss[i].mv.row) > x->mv_row_min);
+ all_in &= ((best_mv->row + ss[i + 1].mv.row) < x->mv_row_max);
+ all_in &= ((best_mv->col + ss[i + 2].mv.col) > x->mv_col_min);
+ all_in &= ((best_mv->col + ss[i + 3].mv.col) < x->mv_col_max);
// If all the pixels are within the bounds we don't check whether the
// search point is valid in this loop, otherwise we check each point
@@ -1303,9 +1418,9 @@
for (t = 0; t < 4; t++, i++) {
if (sad_array[t] < bestsad) {
- this_mv.as_mv.row = best_mv->as_mv.row + ss[i].mv.row;
- this_mv.as_mv.col = best_mv->as_mv.col + ss[i].mv.col;
- sad_array[t] += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.row = best_mv->row + ss[i].mv.row;
+ this_mv.col = best_mv->col + ss[i].mv.col;
+ sad_array[t] += mvsad_err_cost(&this_mv, &fcenter_mv.as_mv,
mvjsadcost, mvsadcost, sad_per_bit);
if (sad_array[t] < bestsad) {
@@ -1318,8 +1433,8 @@
} else {
for (j = 0; j < x->searches_per_step; j++) {
// Trap illegal vectors
- this_row_offset = best_mv->as_mv.row + ss[i].mv.row;
- this_col_offset = best_mv->as_mv.col + ss[i].mv.col;
+ this_row_offset = best_mv->row + ss[i].mv.row;
+ this_col_offset = best_mv->col + ss[i].mv.col;
if ((this_col_offset > x->mv_col_min) &&
(this_col_offset < x->mv_col_max) &&
@@ -1330,9 +1445,9 @@
bestsad);
if (thissad < bestsad) {
- this_mv.as_mv.row = this_row_offset;
- this_mv.as_mv.col = this_col_offset;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.row = this_row_offset;
+ this_mv.col = this_col_offset;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv.as_mv,
mvjsadcost, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
@@ -1345,14 +1460,14 @@
}
}
if (best_site != last_site) {
- best_mv->as_mv.row += ss[best_site].mv.row;
- best_mv->as_mv.col += ss[best_site].mv.col;
+ best_mv->row += ss[best_site].mv.row;
+ best_mv->col += ss[best_site].mv.col;
best_address += ss[best_site].offset;
last_site = best_site;
#if defined(NEW_DIAMOND_SEARCH)
while (1) {
- this_row_offset = best_mv->as_mv.row + ss[best_site].mv.row;
- this_col_offset = best_mv->as_mv.col + ss[best_site].mv.col;
+ this_row_offset = best_mv->row + ss[best_site].mv.row;
+ this_col_offset = best_mv->col + ss[best_site].mv.col;
if ((this_col_offset > x->mv_col_min) &&
(this_col_offset < x->mv_col_max) &&
(this_row_offset > x->mv_row_min) &&
@@ -1361,14 +1476,14 @@
thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride,
bestsad);
if (thissad < bestsad) {
- this_mv.as_mv.row = this_row_offset;
- this_mv.as_mv.col = this_col_offset;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.row = this_row_offset;
+ this_mv.col = this_col_offset;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv.as_mv,
mvjsadcost, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
bestsad = thissad;
- best_mv->as_mv.row += ss[best_site].mv.row;
- best_mv->as_mv.col += ss[best_site].mv.col;
+ best_mv->row += ss[best_site].mv.row;
+ best_mv->col += ss[best_site].mv.col;
best_address += ss[best_site].offset;
continue;
}
@@ -1382,15 +1497,15 @@
}
}
- this_mv.as_mv.row = best_mv->as_mv.row * 8;
- this_mv.as_mv.col = best_mv->as_mv.col * 8;
+ this_mv.row = best_mv->row * 8;
+ this_mv.col = best_mv->col * 8;
if (bestsad == INT_MAX)
return INT_MAX;
return fn_ptr->vf(what, what_stride, best_address, in_what_stride,
(unsigned int *)(&thissad)) +
- mv_err_cost(&this_mv.as_mv, &center_mv->as_mv,
+ mv_err_cost(&this_mv, center_mv,
mvjcost, mvcost, x->errorperbit);
}
@@ -1405,10 +1520,10 @@
int_mv *ref_mv, int_mv *dst_mv) {
int_mv temp_mv;
int thissme, n, num00;
- int bestsme = cpi->diamond_search_sad(x, mvp_full, &temp_mv,
+ int bestsme = cpi->diamond_search_sad(x, &mvp_full->as_mv, &temp_mv.as_mv,
step_param, sadpb, &num00,
fn_ptr, x->nmvjointcost,
- x->mvcost, ref_mv);
+ x->mvcost, &ref_mv->as_mv);
dst_mv->as_int = temp_mv.as_int;
n = num00;
@@ -1425,10 +1540,10 @@
if (num00) {
num00--;
} else {
- thissme = cpi->diamond_search_sad(x, mvp_full, &temp_mv,
+ thissme = cpi->diamond_search_sad(x, &mvp_full->as_mv, &temp_mv.as_mv,
step_param + n, sadpb, &num00,
fn_ptr, x->nmvjointcost, x->mvcost,
- ref_mv);
+ &ref_mv->as_mv);
/* check to see if refining search is needed. */
if (num00 > (further_steps - n))
@@ -1446,9 +1561,9 @@
int search_range = 8;
int_mv best_mv;
best_mv.as_int = dst_mv->as_int;
- thissme = cpi->refining_search_sad(x, &best_mv, sadpb, search_range,
+ thissme = cpi->refining_search_sad(x, &best_mv.as_mv, sadpb, search_range,
fn_ptr, x->nmvjointcost, x->mvcost,
- ref_mv);
+ &ref_mv->as_mv);
if (thissme < bestsme) {
bestsme = thissme;
@@ -1458,11 +1573,11 @@
return bestsme;
}
-int vp9_full_search_sad_c(MACROBLOCK *x, int_mv *ref_mv,
+int vp9_full_search_sad_c(MACROBLOCK *x, MV *ref_mv,
int sad_per_bit, int distance,
vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost,
int *mvcost[2],
- int_mv *center_mv, int n) {
+ const MV *center_mv, int n) {
const MACROBLOCKD* const xd = &x->e_mbd;
uint8_t *what = x->plane[0].src.buf;
int what_stride = x->plane[0].src.stride;
@@ -1471,27 +1586,27 @@
int mv_stride = xd->plane[0].pre[0].stride;
uint8_t *bestaddress;
int_mv *best_mv = &x->e_mbd.mi_8x8[0]->bmi[n].as_mv[0];
- int_mv this_mv;
+ MV this_mv;
int bestsad = INT_MAX;
int r, c;
uint8_t *check_here;
int thissad;
- int ref_row = ref_mv->as_mv.row;
- int ref_col = ref_mv->as_mv.col;
+ int ref_row = ref_mv->row;
+ int ref_col = ref_mv->col;
int row_min = ref_row - distance;
int row_max = ref_row + distance;
int col_min = ref_col - distance;
int col_max = ref_col + distance;
- int_mv fcenter_mv;
+ MV fcenter_mv;
int *mvjsadcost = x->nmvjointsadcost;
int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+ fcenter_mv.row = center_mv->row >> 3;
+ fcenter_mv.col = center_mv->col >> 3;
// Work out the mid point for the search
in_what = xd->plane[0].pre[0].buf;
@@ -1503,7 +1618,7 @@
// Baseline value at the centre
bestsad = fn_ptr->sdf(what, what_stride, bestaddress,
in_what_stride, 0x7fffffff)
- + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv,
+ + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv,
mvjsadcost, mvsadcost, sad_per_bit);
// Apply further limits to prevent us looking using vectors that stretch
@@ -1514,15 +1629,15 @@
row_max = MIN(row_max, x->mv_row_max);
for (r = row_min; r < row_max; r++) {
- this_mv.as_mv.row = r;
+ this_mv.row = r;
check_here = r * mv_stride + in_what + col_min;
for (c = col_min; c < col_max; c++) {
thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride,
bestsad);
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
mvjsadcost, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
@@ -1536,22 +1651,22 @@
}
}
- this_mv.as_mv.row = best_mv->as_mv.row * 8;
- this_mv.as_mv.col = best_mv->as_mv.col * 8;
+ this_mv.row = best_mv->as_mv.row * 8;
+ this_mv.col = best_mv->as_mv.col * 8;
if (bestsad < INT_MAX)
return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride,
(unsigned int *)(&thissad)) +
- mv_err_cost(&this_mv.as_mv, &center_mv->as_mv,
+ mv_err_cost(&this_mv, center_mv,
mvjcost, mvcost, x->errorperbit);
else
return INT_MAX;
}
-int vp9_full_search_sadx3(MACROBLOCK *x, int_mv *ref_mv,
+int vp9_full_search_sadx3(MACROBLOCK *x, MV *ref_mv,
int sad_per_bit, int distance,
vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost,
- int *mvcost[2], int_mv *center_mv, int n) {
+ int *mvcost[2], const MV *center_mv, int n) {
const MACROBLOCKD* const xd = &x->e_mbd;
uint8_t *what = x->plane[0].src.buf;
int what_stride = x->plane[0].src.stride;
@@ -1560,15 +1675,15 @@
int mv_stride = xd->plane[0].pre[0].stride;
uint8_t *bestaddress;
int_mv *best_mv = &x->e_mbd.mi_8x8[0]->bmi[n].as_mv[0];
- int_mv this_mv;
+ MV this_mv;
unsigned int bestsad = INT_MAX;
int r, c;
uint8_t *check_here;
unsigned int thissad;
- int ref_row = ref_mv->as_mv.row;
- int ref_col = ref_mv->as_mv.col;
+ int ref_row = ref_mv->row;
+ int ref_col = ref_mv->col;
int row_min = ref_row - distance;
int row_max = ref_row + distance;
@@ -1576,13 +1691,13 @@
int col_max = ref_col + distance;
unsigned int sad_array[3];
- int_mv fcenter_mv;
+ MV fcenter_mv;
int *mvjsadcost = x->nmvjointsadcost;
int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+ fcenter_mv.row = center_mv->row >> 3;
+ fcenter_mv.col = center_mv->col >> 3;
// Work out the mid point for the search
in_what = xd->plane[0].pre[0].buf;
@@ -1594,7 +1709,7 @@
// Baseline value at the centre
bestsad = fn_ptr->sdf(what, what_stride,
bestaddress, in_what_stride, 0x7fffffff)
- + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv,
+ + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv,
mvjsadcost, mvsadcost, sad_per_bit);
// Apply further limits to prevent us looking using vectors that stretch
@@ -1605,11 +1720,11 @@
row_max = MIN(row_max, x->mv_row_max);
for (r = row_min; r < row_max; r++) {
- this_mv.as_mv.row = r;
+ this_mv.row = r;
check_here = r * mv_stride + in_what + col_min;
c = col_min;
- while ((c + 2) < col_max) {
+ while ((c + 2) < col_max && fn_ptr->sdx3f != NULL) {
int i;
fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array);
@@ -1618,8 +1733,8 @@
thissad = sad_array[i];
if (thissad < bestsad) {
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
mvjsadcost, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
@@ -1640,8 +1755,8 @@
bestsad);
if (thissad < bestsad) {
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
mvjsadcost, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
@@ -1657,23 +1772,23 @@
}
}
- this_mv.as_mv.row = best_mv->as_mv.row * 8;
- this_mv.as_mv.col = best_mv->as_mv.col * 8;
+ this_mv.row = best_mv->as_mv.row * 8;
+ this_mv.col = best_mv->as_mv.col * 8;
if (bestsad < INT_MAX)
return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride,
(unsigned int *)(&thissad)) +
- mv_err_cost(&this_mv.as_mv, &center_mv->as_mv,
+ mv_err_cost(&this_mv, center_mv,
mvjcost, mvcost, x->errorperbit);
else
return INT_MAX;
}
-int vp9_full_search_sadx8(MACROBLOCK *x, int_mv *ref_mv,
+int vp9_full_search_sadx8(MACROBLOCK *x, MV *ref_mv,
int sad_per_bit, int distance,
vp9_variance_fn_ptr_t *fn_ptr,
int *mvjcost, int *mvcost[2],
- int_mv *center_mv, int n) {
+ const MV *center_mv, int n) {
const MACROBLOCKD* const xd = &x->e_mbd;
uint8_t *what = x->plane[0].src.buf;
int what_stride = x->plane[0].src.stride;
@@ -1682,15 +1797,15 @@
int mv_stride = xd->plane[0].pre[0].stride;
uint8_t *bestaddress;
int_mv *best_mv = &x->e_mbd.mi_8x8[0]->bmi[n].as_mv[0];
- int_mv this_mv;
+ MV this_mv;
unsigned int bestsad = INT_MAX;
int r, c;
uint8_t *check_here;
unsigned int thissad;
- int ref_row = ref_mv->as_mv.row;
- int ref_col = ref_mv->as_mv.col;
+ int ref_row = ref_mv->row;
+ int ref_col = ref_mv->col;
int row_min = ref_row - distance;
int row_max = ref_row + distance;
@@ -1699,13 +1814,13 @@
DECLARE_ALIGNED_ARRAY(16, uint32_t, sad_array8, 8);
unsigned int sad_array[3];
- int_mv fcenter_mv;
+ MV fcenter_mv;
int *mvjsadcost = x->nmvjointsadcost;
int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+ fcenter_mv.row = center_mv->row >> 3;
+ fcenter_mv.col = center_mv->col >> 3;
// Work out the mid point for the search
in_what = xd->plane[0].pre[0].buf;
@@ -1717,7 +1832,7 @@
// Baseline value at the centre
bestsad = fn_ptr->sdf(what, what_stride,
bestaddress, in_what_stride, 0x7fffffff)
- + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv,
+ + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv,
mvjsadcost, mvsadcost, sad_per_bit);
// Apply further limits to prevent us looking using vectors that stretch
@@ -1728,7 +1843,7 @@
row_max = MIN(row_max, x->mv_row_max);
for (r = row_min; r < row_max; r++) {
- this_mv.as_mv.row = r;
+ this_mv.row = r;
check_here = r * mv_stride + in_what + col_min;
c = col_min;
@@ -1741,8 +1856,8 @@
thissad = (unsigned int)sad_array8[i];
if (thissad < bestsad) {
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
mvjsadcost, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
@@ -1767,8 +1882,8 @@
thissad = sad_array[i];
if (thissad < bestsad) {
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
mvjsadcost, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
@@ -1789,8 +1904,8 @@
bestsad);
if (thissad < bestsad) {
- this_mv.as_mv.col = c;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.col = c;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
mvjsadcost, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
@@ -1806,21 +1921,22 @@
}
}
- this_mv.as_mv.row = best_mv->as_mv.row * 8;
- this_mv.as_mv.col = best_mv->as_mv.col * 8;
+ this_mv.row = best_mv->as_mv.row * 8;
+ this_mv.col = best_mv->as_mv.col * 8;
if (bestsad < INT_MAX)
return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride,
(unsigned int *)(&thissad)) +
- mv_err_cost(&this_mv.as_mv, &center_mv->as_mv,
+ mv_err_cost(&this_mv, center_mv,
mvjcost, mvcost, x->errorperbit);
else
return INT_MAX;
}
int vp9_refining_search_sad_c(MACROBLOCK *x,
- int_mv *ref_mv, int error_per_bit,
+ MV *ref_mv, int error_per_bit,
int search_range, vp9_variance_fn_ptr_t *fn_ptr,
- int *mvjcost, int *mvcost[2], int_mv *center_mv) {
+ int *mvjcost, int *mvcost[2],
+ const MV *center_mv) {
const MACROBLOCKD* const xd = &x->e_mbd;
MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
int i, j;
@@ -1830,31 +1946,31 @@
int in_what_stride = xd->plane[0].pre[0].stride;
uint8_t *what = x->plane[0].src.buf;
uint8_t *best_address = xd->plane[0].pre[0].buf +
- (ref_mv->as_mv.row * xd->plane[0].pre[0].stride) +
- ref_mv->as_mv.col;
+ (ref_mv->row * xd->plane[0].pre[0].stride) +
+ ref_mv->col;
uint8_t *check_here;
unsigned int thissad;
- int_mv this_mv;
+ MV this_mv;
unsigned int bestsad = INT_MAX;
- int_mv fcenter_mv;
+ MV fcenter_mv;
int *mvjsadcost = x->nmvjointsadcost;
int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+ fcenter_mv.row = center_mv->row >> 3;
+ fcenter_mv.col = center_mv->col >> 3;
bestsad = fn_ptr->sdf(what, what_stride, best_address,
in_what_stride, 0x7fffffff) +
- mvsad_err_cost(&ref_mv->as_mv, &fcenter_mv.as_mv,
+ mvsad_err_cost(ref_mv, &fcenter_mv,
mvjsadcost, mvsadcost, error_per_bit);
for (i = 0; i < search_range; i++) {
int best_site = -1;
for (j = 0; j < 4; j++) {
- this_row_offset = ref_mv->as_mv.row + neighbors[j].row;
- this_col_offset = ref_mv->as_mv.col + neighbors[j].col;
+ this_row_offset = ref_mv->row + neighbors[j].row;
+ this_col_offset = ref_mv->col + neighbors[j].col;
if ((this_col_offset > x->mv_col_min) &&
(this_col_offset < x->mv_col_max) &&
@@ -1866,9 +1982,9 @@
bestsad);
if (thissad < bestsad) {
- this_mv.as_mv.row = this_row_offset;
- this_mv.as_mv.col = this_col_offset;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.row = this_row_offset;
+ this_mv.col = this_col_offset;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
mvjsadcost, mvsadcost, error_per_bit);
if (thissad < bestsad) {
@@ -1882,29 +1998,30 @@
if (best_site == -1) {
break;
} else {
- ref_mv->as_mv.row += neighbors[best_site].row;
- ref_mv->as_mv.col += neighbors[best_site].col;
+ ref_mv->row += neighbors[best_site].row;
+ ref_mv->col += neighbors[best_site].col;
best_address += (neighbors[best_site].row) * in_what_stride +
neighbors[best_site].col;
}
}
- this_mv.as_mv.row = ref_mv->as_mv.row * 8;
- this_mv.as_mv.col = ref_mv->as_mv.col * 8;
+ this_mv.row = ref_mv->row * 8;
+ this_mv.col = ref_mv->col * 8;
if (bestsad < INT_MAX)
return fn_ptr->vf(what, what_stride, best_address, in_what_stride,
(unsigned int *)(&thissad)) +
- mv_err_cost(&this_mv.as_mv, &center_mv->as_mv,
+ mv_err_cost(&this_mv, center_mv,
mvjcost, mvcost, x->errorperbit);
else
return INT_MAX;
}
int vp9_refining_search_sadx4(MACROBLOCK *x,
- int_mv *ref_mv, int error_per_bit,
+ MV *ref_mv, int error_per_bit,
int search_range, vp9_variance_fn_ptr_t *fn_ptr,
- int *mvjcost, int *mvcost[2], int_mv *center_mv) {
+ int *mvjcost, int *mvcost[2],
+ const MV *center_mv) {
const MACROBLOCKD* const xd = &x->e_mbd;
MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
int i, j;
@@ -1914,31 +2031,31 @@
int in_what_stride = xd->plane[0].pre[0].stride;
uint8_t *what = x->plane[0].src.buf;
uint8_t *best_address = xd->plane[0].pre[0].buf +
- (ref_mv->as_mv.row * xd->plane[0].pre[0].stride) +
- ref_mv->as_mv.col;
+ (ref_mv->row * xd->plane[0].pre[0].stride) +
+ ref_mv->col;
uint8_t *check_here;
unsigned int thissad;
- int_mv this_mv;
+ MV this_mv;
unsigned int bestsad = INT_MAX;
- int_mv fcenter_mv;
+ MV fcenter_mv;
int *mvjsadcost = x->nmvjointsadcost;
int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
- fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
- fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
+ fcenter_mv.row = center_mv->row >> 3;
+ fcenter_mv.col = center_mv->col >> 3;
bestsad = fn_ptr->sdf(what, what_stride, best_address,
in_what_stride, 0x7fffffff) +
- mvsad_err_cost(&ref_mv->as_mv, &fcenter_mv.as_mv,
+ mvsad_err_cost(ref_mv, &fcenter_mv,
mvjsadcost, mvsadcost, error_per_bit);
for (i = 0; i < search_range; i++) {
int best_site = -1;
- int all_in = ((ref_mv->as_mv.row - 1) > x->mv_row_min) &
- ((ref_mv->as_mv.row + 1) < x->mv_row_max) &
- ((ref_mv->as_mv.col - 1) > x->mv_col_min) &
- ((ref_mv->as_mv.col + 1) < x->mv_col_max);
+ int all_in = ((ref_mv->row - 1) > x->mv_row_min) &
+ ((ref_mv->row + 1) < x->mv_row_max) &
+ ((ref_mv->col - 1) > x->mv_col_min) &
+ ((ref_mv->col + 1) < x->mv_col_max);
if (all_in) {
unsigned int sad_array[4];
@@ -1953,9 +2070,9 @@
for (j = 0; j < 4; j++) {
if (sad_array[j] < bestsad) {
- this_mv.as_mv.row = ref_mv->as_mv.row + neighbors[j].row;
- this_mv.as_mv.col = ref_mv->as_mv.col + neighbors[j].col;
- sad_array[j] += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.row = ref_mv->row + neighbors[j].row;
+ this_mv.col = ref_mv->col + neighbors[j].col;
+ sad_array[j] += mvsad_err_cost(&this_mv, &fcenter_mv,
mvjsadcost, mvsadcost, error_per_bit);
if (sad_array[j] < bestsad) {
@@ -1966,8 +2083,8 @@
}
} else {
for (j = 0; j < 4; j++) {
- this_row_offset = ref_mv->as_mv.row + neighbors[j].row;
- this_col_offset = ref_mv->as_mv.col + neighbors[j].col;
+ this_row_offset = ref_mv->row + neighbors[j].row;
+ this_col_offset = ref_mv->col + neighbors[j].col;
if ((this_col_offset > x->mv_col_min) &&
(this_col_offset < x->mv_col_max) &&
@@ -1979,9 +2096,9 @@
bestsad);
if (thissad < bestsad) {
- this_mv.as_mv.row = this_row_offset;
- this_mv.as_mv.col = this_col_offset;
- thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv,
+ this_mv.row = this_row_offset;
+ this_mv.col = this_col_offset;
+ thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
mvjsadcost, mvsadcost, error_per_bit);
if (thissad < bestsad) {
@@ -1996,20 +2113,20 @@
if (best_site == -1) {
break;
} else {
- ref_mv->as_mv.row += neighbors[best_site].row;
- ref_mv->as_mv.col += neighbors[best_site].col;
+ ref_mv->row += neighbors[best_site].row;
+ ref_mv->col += neighbors[best_site].col;
best_address += (neighbors[best_site].row) * in_what_stride +
neighbors[best_site].col;
}
}
- this_mv.as_mv.row = ref_mv->as_mv.row * 8;
- this_mv.as_mv.col = ref_mv->as_mv.col * 8;
+ this_mv.row = ref_mv->row * 8;
+ this_mv.col = ref_mv->col * 8;
if (bestsad < INT_MAX)
return fn_ptr->vf(what, what_stride, best_address, in_what_stride,
(unsigned int *)(&thissad)) +
- mv_err_cost(&this_mv.as_mv, &center_mv->as_mv,
+ mv_err_cost(&this_mv, center_mv,
mvjcost, mvcost, x->errorperbit);
else
return INT_MAX;
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_mcomp.h ('k') | source/libvpx/vp9/encoder/vp9_modecosts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698