| Index: source/libvpx/vp9/encoder/vp9_mcomp.c
|
| ===================================================================
|
| --- source/libvpx/vp9/encoder/vp9_mcomp.c (revision 278778)
|
| +++ source/libvpx/vp9/encoder/vp9_mcomp.c (working copy)
|
| @@ -60,8 +60,8 @@
|
| while ((size << sr) < MAX_FULL_PEL_VAL)
|
| sr++;
|
|
|
| - sr += sf->reduce_first_step_size;
|
| - sr = MIN(sr, (sf->max_step_search_steps - 2));
|
| + sr += sf->mv.reduce_first_step_size;
|
| + sr = MIN(sr, (sf->mv.max_step_search_steps - 2));
|
| return sr;
|
| }
|
|
|
| @@ -524,9 +524,8 @@
|
|
|
| // Work out the start point for the search
|
| bestsad = vfp->sdf(what->buf, what->stride,
|
| - get_buf_from_mv(in_what, ref_mv), in_what->stride,
|
| - 0x7fffffff) + mvsad_err_cost(x, ref_mv, &fcenter_mv,
|
| - sad_per_bit);
|
| + get_buf_from_mv(in_what, ref_mv), in_what->stride) +
|
| + mvsad_err_cost(x, ref_mv, &fcenter_mv, sad_per_bit);
|
|
|
| // Search all possible scales upto the search param around the center point
|
| // pick the scale of the point that is best as the starting scale of
|
| @@ -542,7 +541,7 @@
|
| bc + candidates[t][i].col};
|
| thissad = vfp->sdf(what->buf, what->stride,
|
| get_buf_from_mv(in_what, &this_mv),
|
| - in_what->stride, bestsad);
|
| + in_what->stride);
|
| CHECK_BETTER
|
| }
|
| } else {
|
| @@ -553,7 +552,7 @@
|
| continue;
|
| thissad = vfp->sdf(what->buf, what->stride,
|
| get_buf_from_mv(in_what, &this_mv),
|
| - in_what->stride, bestsad);
|
| + in_what->stride);
|
| CHECK_BETTER
|
| }
|
| }
|
| @@ -585,7 +584,7 @@
|
| bc + candidates[s][i].col};
|
| thissad = vfp->sdf(what->buf, what->stride,
|
| get_buf_from_mv(in_what, &this_mv),
|
| - in_what->stride, bestsad);
|
| + in_what->stride);
|
| CHECK_BETTER
|
| }
|
| } else {
|
| @@ -596,7 +595,7 @@
|
| continue;
|
| thissad = vfp->sdf(what->buf, what->stride,
|
| get_buf_from_mv(in_what, &this_mv),
|
| - in_what->stride, bestsad);
|
| + in_what->stride);
|
| CHECK_BETTER
|
| }
|
| }
|
| @@ -623,7 +622,7 @@
|
| bc + candidates[s][next_chkpts_indices[i]].col};
|
| thissad = vfp->sdf(what->buf, what->stride,
|
| get_buf_from_mv(in_what, &this_mv),
|
| - in_what->stride, bestsad);
|
| + in_what->stride);
|
| CHECK_BETTER
|
| }
|
| } else {
|
| @@ -634,7 +633,7 @@
|
| continue;
|
| thissad = vfp->sdf(what->buf, what->stride,
|
| get_buf_from_mv(in_what, &this_mv),
|
| - in_what->stride, bestsad);
|
| + in_what->stride);
|
| CHECK_BETTER
|
| }
|
| }
|
| @@ -661,7 +660,7 @@
|
| bc + neighbors[i].col};
|
| thissad = vfp->sdf(what->buf, what->stride,
|
| get_buf_from_mv(in_what, &this_mv),
|
| - in_what->stride, bestsad);
|
| + in_what->stride);
|
| CHECK_BETTER
|
| }
|
| } else {
|
| @@ -672,7 +671,7 @@
|
| continue;
|
| thissad = vfp->sdf(what->buf, what->stride,
|
| get_buf_from_mv(in_what, &this_mv),
|
| - in_what->stride, bestsad);
|
| + in_what->stride);
|
| CHECK_BETTER
|
| }
|
| }
|
| @@ -894,8 +893,7 @@
|
| *best_mv = *ref_mv;
|
| *num00 = 11;
|
| best_sad = fn_ptr->sdf(what->buf, what->stride,
|
| - get_buf_from_mv(in_what, ref_mv), in_what->stride,
|
| - 0x7fffffff) +
|
| + get_buf_from_mv(in_what, ref_mv), in_what->stride) +
|
| mvsad_err_cost(x, ref_mv, &fcenter_mv, sad_per_bit);
|
| start_row = MAX(-range, x->mv_row_min - ref_mv->row);
|
| start_col = MAX(-range, x->mv_col_min - ref_mv->col);
|
| @@ -929,7 +927,7 @@
|
| for (i = 0; i < end_col - c; ++i) {
|
| const MV mv = {ref_mv->row + r, ref_mv->col + c + i};
|
| unsigned int sad = fn_ptr->sdf(what->buf, what->stride,
|
| - get_buf_from_mv(in_what, &mv), in_what->stride, best_sad);
|
| + get_buf_from_mv(in_what, &mv), in_what->stride);
|
| if (sad < best_sad) {
|
| sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit);
|
| if (sad < best_sad) {
|
| @@ -975,7 +973,7 @@
|
|
|
| // Check the starting position
|
| best_sad = fn_ptr->sdf(what->buf, what->stride,
|
| - best_address, in_what->stride, 0x7fffffff) +
|
| + best_address, in_what->stride) +
|
| mvsad_err_cost(x, best_mv, &fcenter_mv, sad_per_bit);
|
|
|
| i = 1;
|
| @@ -986,8 +984,7 @@
|
| best_mv->col + ss[i].mv.col};
|
| if (is_mv_in(x, &mv)) {
|
| int sad = fn_ptr->sdf(what->buf, what->stride,
|
| - best_address + ss[i].offset, in_what->stride,
|
| - best_sad);
|
| + best_address + ss[i].offset, in_what->stride);
|
| if (sad < best_sad) {
|
| sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit);
|
| if (sad < best_sad) {
|
| @@ -1012,7 +1009,7 @@
|
| if (is_mv_in(x, &this_mv)) {
|
| int sad = fn_ptr->sdf(what->buf, what->stride,
|
| best_address + ss[best_site].offset,
|
| - in_what->stride, best_sad);
|
| + in_what->stride);
|
| if (sad < best_sad) {
|
| sad += mvsad_err_cost(x, &this_mv, &fcenter_mv, sad_per_bit);
|
| if (sad < best_sad) {
|
| @@ -1077,7 +1074,7 @@
|
| best_address = in_what;
|
|
|
| // Check the starting position
|
| - bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff)
|
| + bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride)
|
| + mvsad_err_cost(x, best_mv, &fcenter_mv, sad_per_bit);
|
|
|
| i = 1;
|
| @@ -1129,7 +1126,7 @@
|
| if (is_mv_in(x, &this_mv)) {
|
| const uint8_t *const check_here = ss[i].offset + best_address;
|
| unsigned int thissad = fn_ptr->sdf(what, what_stride, check_here,
|
| - in_what_stride, bestsad);
|
| + in_what_stride);
|
|
|
| if (thissad < bestsad) {
|
| thissad += mvsad_err_cost(x, &this_mv, &fcenter_mv, sad_per_bit);
|
| @@ -1154,7 +1151,7 @@
|
| if (is_mv_in(x, &this_mv)) {
|
| const uint8_t *const check_here = ss[best_site].offset + best_address;
|
| unsigned int thissad = fn_ptr->sdf(what, what_stride, check_here,
|
| - in_what_stride, bestsad);
|
| + in_what_stride);
|
| if (thissad < bestsad) {
|
| thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
|
| mvjsadcost, mvsadcost, sad_per_bit);
|
| @@ -1253,7 +1250,7 @@
|
| const int col_max = MIN(ref_mv->col + distance, x->mv_col_max);
|
| const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3};
|
| int best_sad = fn_ptr->sdf(what->buf, what->stride,
|
| - get_buf_from_mv(in_what, ref_mv), in_what->stride, 0x7fffffff) +
|
| + get_buf_from_mv(in_what, ref_mv), in_what->stride) +
|
| mvsad_err_cost(x, ref_mv, &fcenter_mv, sad_per_bit);
|
| *best_mv = *ref_mv;
|
|
|
| @@ -1261,7 +1258,7 @@
|
| for (c = col_min; c < col_max; ++c) {
|
| const MV mv = {r, c};
|
| const int sad = fn_ptr->sdf(what->buf, what->stride,
|
| - get_buf_from_mv(in_what, &mv), in_what->stride, best_sad) +
|
| + get_buf_from_mv(in_what, &mv), in_what->stride) +
|
| mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit);
|
| if (sad < best_sad) {
|
| best_sad = sad;
|
| @@ -1286,7 +1283,7 @@
|
| const int col_max = MIN(ref_mv->col + distance, x->mv_col_max);
|
| const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3};
|
| unsigned int best_sad = fn_ptr->sdf(what->buf, what->stride,
|
| - get_buf_from_mv(in_what, ref_mv), in_what->stride, 0x7fffffff) +
|
| + get_buf_from_mv(in_what, ref_mv), in_what->stride) +
|
| mvsad_err_cost(x, ref_mv, &fcenter_mv, sad_per_bit);
|
| *best_mv = *ref_mv;
|
|
|
| @@ -1320,7 +1317,7 @@
|
|
|
| while (c < col_max) {
|
| unsigned int sad = fn_ptr->sdf(what->buf, what->stride,
|
| - check_here, in_what->stride, best_sad);
|
| + check_here, in_what->stride);
|
| if (sad < best_sad) {
|
| const MV mv = {r, c};
|
| sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit);
|
| @@ -1351,7 +1348,7 @@
|
| const int col_max = MIN(ref_mv->col + distance, x->mv_col_max);
|
| const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3};
|
| unsigned int best_sad = fn_ptr->sdf(what->buf, what->stride,
|
| - get_buf_from_mv(in_what, ref_mv), in_what->stride, 0x7fffffff) +
|
| + get_buf_from_mv(in_what, ref_mv), in_what->stride) +
|
| mvsad_err_cost(x, ref_mv, &fcenter_mv, sad_per_bit);
|
| *best_mv = *ref_mv;
|
|
|
| @@ -1409,7 +1406,7 @@
|
|
|
| while (c < col_max) {
|
| unsigned int sad = fn_ptr->sdf(what->buf, what->stride,
|
| - check_here, in_what->stride, best_sad);
|
| + check_here, in_what->stride);
|
| if (sad < best_sad) {
|
| const MV mv = {r, c};
|
| sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit);
|
| @@ -1438,7 +1435,7 @@
|
| const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3};
|
| unsigned int best_sad = fn_ptr->sdf(what->buf, what->stride,
|
| get_buf_from_mv(in_what, ref_mv),
|
| - in_what->stride, 0x7fffffff) +
|
| + in_what->stride) +
|
| mvsad_err_cost(x, ref_mv, &fcenter_mv, error_per_bit);
|
| int i, j;
|
|
|
| @@ -1450,7 +1447,7 @@
|
| ref_mv->col + neighbors[j].col};
|
| if (is_mv_in(x, &mv)) {
|
| unsigned int sad = fn_ptr->sdf(what->buf, what->stride,
|
| - get_buf_from_mv(in_what, &mv), in_what->stride, best_sad);
|
| + get_buf_from_mv(in_what, &mv), in_what->stride);
|
| if (sad < best_sad) {
|
| sad += mvsad_err_cost(x, &mv, &fcenter_mv, error_per_bit);
|
| if (sad < best_sad) {
|
| @@ -1483,7 +1480,7 @@
|
| const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3};
|
| const uint8_t *best_address = get_buf_from_mv(in_what, ref_mv);
|
| unsigned int best_sad = fn_ptr->sdf(what->buf, what->stride, best_address,
|
| - in_what->stride, 0x7fffffff) +
|
| + in_what->stride) +
|
| mvsad_err_cost(x, ref_mv, &fcenter_mv, error_per_bit);
|
| int i, j;
|
|
|
| @@ -1524,7 +1521,7 @@
|
| if (is_mv_in(x, &mv)) {
|
| unsigned int sad = fn_ptr->sdf(what->buf, what->stride,
|
| get_buf_from_mv(in_what, &mv),
|
| - in_what->stride, best_sad);
|
| + in_what->stride);
|
| if (sad < best_sad) {
|
| sad += mvsad_err_cost(x, &mv, &fcenter_mv, error_per_bit);
|
| if (sad < best_sad) {
|
| @@ -1563,8 +1560,7 @@
|
| const struct buf_2d *const in_what = &xd->plane[0].pre[0];
|
| const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3};
|
| unsigned int best_sad = fn_ptr->sdaf(what->buf, what->stride,
|
| - get_buf_from_mv(in_what, ref_mv), in_what->stride,
|
| - second_pred, 0x7fffffff) +
|
| + get_buf_from_mv(in_what, ref_mv), in_what->stride, second_pred) +
|
| mvsad_err_cost(x, ref_mv, &fcenter_mv, error_per_bit);
|
| int i, j;
|
|
|
| @@ -1577,8 +1573,7 @@
|
|
|
| if (is_mv_in(x, &mv)) {
|
| unsigned int sad = fn_ptr->sdaf(what->buf, what->stride,
|
| - get_buf_from_mv(in_what, &mv), in_what->stride,
|
| - second_pred, best_sad);
|
| + get_buf_from_mv(in_what, &mv), in_what->stride, second_pred);
|
| if (sad < best_sad) {
|
| sad += mvsad_err_cost(x, &mv, &fcenter_mv, error_per_bit);
|
| if (sad < best_sad) {
|
| @@ -1598,3 +1593,50 @@
|
| }
|
| return best_sad;
|
| }
|
| +
|
| +int vp9_full_pixel_search(VP9_COMP *cpi, MACROBLOCK *x,
|
| + BLOCK_SIZE bsize, MV *mvp_full,
|
| + int step_param, int error_per_bit,
|
| + const MV *ref_mv, MV *tmp_mv,
|
| + int var_max, int rd) {
|
| + const SPEED_FEATURES *const sf = &cpi->sf;
|
| + const SEARCH_METHODS method = sf->mv.search_method;
|
| + vp9_variance_fn_ptr_t *fn_ptr = &cpi->fn_ptr[bsize];
|
| + int var = 0;
|
| +
|
| + switch (method) {
|
| + case FAST_DIAMOND:
|
| + var = vp9_fast_dia_search(x, mvp_full, step_param, error_per_bit, 0,
|
| + fn_ptr, 1, ref_mv, tmp_mv);
|
| + break;
|
| + case FAST_HEX:
|
| + var = vp9_fast_hex_search(x, mvp_full, step_param, error_per_bit, 0,
|
| + fn_ptr, 1, ref_mv, tmp_mv);
|
| + break;
|
| + case HEX:
|
| + var = vp9_hex_search(x, mvp_full, step_param, error_per_bit, 1,
|
| + fn_ptr, 1, ref_mv, tmp_mv);
|
| + break;
|
| + case SQUARE:
|
| + var = vp9_square_search(x, mvp_full, step_param, error_per_bit, 1,
|
| + fn_ptr, 1, ref_mv, tmp_mv);
|
| + break;
|
| + case BIGDIA:
|
| + var = vp9_bigdia_search(x, mvp_full, step_param, error_per_bit, 1,
|
| + fn_ptr, 1, ref_mv, tmp_mv);
|
| + break;
|
| + case NSTEP:
|
| + var = vp9_full_pixel_diamond(cpi, x, mvp_full, step_param, error_per_bit,
|
| + (sf->mv.max_step_search_steps - 1) -
|
| + step_param,
|
| + 1, fn_ptr, ref_mv, tmp_mv);
|
| + break;
|
| + default:
|
| + assert(!"Invalid search method.");
|
| + }
|
| +
|
| + if (method != NSTEP && rd && var < var_max)
|
| + var = vp9_get_mvpred_var(x, tmp_mv, ref_mv, fn_ptr, 1);
|
| +
|
| + return var;
|
| +}
|
|
|