diff options
Diffstat (limited to 'vp9/encoder/vp9_mcomp.c')
-rw-r--r-- | vp9/encoder/vp9_mcomp.c | 492 |
1 files changed, 245 insertions, 247 deletions
diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index 7dd786904..44eaa657c 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -59,38 +59,39 @@ int vp9_init_search_range(VP9_COMP *cpi, int size) { return sr; } -int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2], - int weight) { - MV v; - v.row = mv->as_mv.row - ref->as_mv.row; - v.col = mv->as_mv.col - ref->as_mv.col; - return ROUND_POWER_OF_TWO((mvjcost[vp9_get_mv_joint(&v)] + - mvcost[0][v.row] + - mvcost[1][v.col]) * weight, 7); +static INLINE int mv_cost(const MV *mv, + const int *joint_cost, int *comp_cost[2]) { + return joint_cost[vp9_get_mv_joint(mv)] + + comp_cost[0][mv->row] + comp_cost[1][mv->col]; } -static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2], +int vp9_mv_bit_cost(const MV *mv, const MV *ref, + const int *mvjcost, int *mvcost[2], int weight) { + const MV diff = { mv->row - ref->row, + mv->col - ref->col }; + return ROUND_POWER_OF_TWO(mv_cost(&diff, mvjcost, mvcost) * weight, 7); +} + +static int mv_err_cost(const MV *mv, const MV *ref, + const int *mvjcost, int *mvcost[2], int error_per_bit) { if (mvcost) { - MV v; - v.row = mv->as_mv.row - ref->as_mv.row; - v.col = mv->as_mv.col - ref->as_mv.col; - return ROUND_POWER_OF_TWO((mvjcost[vp9_get_mv_joint(&v)] + - mvcost[0][v.row] + - mvcost[1][v.col]) * error_per_bit, 13); + const MV diff = { mv->row - ref->row, + mv->col - ref->col }; + return ROUND_POWER_OF_TWO(mv_cost(&diff, mvjcost, mvcost) * + error_per_bit, 13); } return 0; } -static int mvsad_err_cost(int_mv *mv, int_mv *ref, int *mvjsadcost, - int *mvsadcost[2], int error_per_bit) { +static int mvsad_err_cost(const MV *mv, const MV *ref, + const int *mvjsadcost, int *mvsadcost[2], + int error_per_bit) { if (mvsadcost) { - MV v; - v.row = mv->as_mv.row - ref->as_mv.row; - v.col = mv->as_mv.col - ref->as_mv.col; - return ROUND_POWER_OF_TWO((mvjsadcost[vp9_get_mv_joint(&v)] + - mvsadcost[0][v.row] + - mvsadcost[1][v.col]) * error_per_bit, 8); + const MV diff = { mv->row - ref->row, + mv->col - ref->col }; + return ROUND_POWER_OF_TWO(mv_cost(&diff, mvjsadcost, mvsadcost) * + error_per_bit, 8); } return 0; } @@ -273,7 +274,7 @@ void vp9_init3smotion_compensation(MACROBLOCK *x, int stride) { } int vp9_find_best_sub_pixel_iterative(MACROBLOCK *x, - int_mv *bestmv, int_mv *ref_mv, + MV *bestmv, const MV *ref_mv, int error_per_bit, const vp9_variance_fn_ptr_t *vfp, int forced_stop, @@ -294,25 +295,25 @@ int vp9_find_best_sub_pixel_iterative(MACROBLOCK *x, int thismse; const int y_stride = xd->plane[0].pre[0].stride; - const int offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col; + const int offset = bestmv->row * y_stride + bestmv->col; uint8_t *y = xd->plane[0].pre[0].buf + offset; - int rr = ref_mv->as_mv.row; - int rc = ref_mv->as_mv.col; - int br = bestmv->as_mv.row * 8; - int bc = bestmv->as_mv.col * 8; + int rr = ref_mv->row; + int rc = ref_mv->col; + int br = bestmv->row * 8; + int bc = bestmv->col * 8; int hstep = 4; - const int minc = MAX(x->mv_col_min * 8, ref_mv->as_mv.col - MV_MAX); - const int maxc = MIN(x->mv_col_max * 8, ref_mv->as_mv.col + MV_MAX); - const int minr = MAX(x->mv_row_min * 8, ref_mv->as_mv.row - MV_MAX); - const int maxr = MIN(x->mv_row_max * 8, ref_mv->as_mv.row + MV_MAX); + const int minc = MAX(x->mv_col_min * 8, ref_mv->col - MV_MAX); + const int maxc = MIN(x->mv_col_max * 8, ref_mv->col + MV_MAX); + const int minr = MAX(x->mv_row_min * 8, ref_mv->row - MV_MAX); + const int maxr = MIN(x->mv_row_max * 8, ref_mv->row + MV_MAX); int tr = br; int tc = bc; // central mv - bestmv->as_mv.row <<= 3; - bestmv->as_mv.col <<= 3; + bestmv->row <<= 3; + bestmv->col <<= 3; // calculate central point error besterr = vfp->vf(y, y_stride, z, src_stride, sse1); @@ -347,7 +348,7 @@ int vp9_find_best_sub_pixel_iterative(MACROBLOCK *x, } } - if (xd->allow_high_precision_mv && vp9_use_mv_hp(&ref_mv->as_mv) && + if (xd->allow_high_precision_mv && vp9_use_mv_hp(ref_mv) && forced_stop == 0) { hstep >>= 1; while (eighthiters--) { @@ -360,18 +361,18 @@ int vp9_find_best_sub_pixel_iterative(MACROBLOCK *x, } } - bestmv->as_mv.row = br; - bestmv->as_mv.col = bc; + bestmv->row = br; + bestmv->col = bc; - if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) || - (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3))) + if ((abs(bestmv->col - ref_mv->col) > (MAX_FULL_PEL_VAL << 3)) || + (abs(bestmv->row - ref_mv->row) > (MAX_FULL_PEL_VAL << 3))) return INT_MAX; return besterr; } int vp9_find_best_sub_pixel_tree(MACROBLOCK *x, - int_mv *bestmv, int_mv *ref_mv, + MV *bestmv, const MV *ref_mv, int error_per_bit, const vp9_variance_fn_ptr_t *vfp, int forced_stop, @@ -391,25 +392,25 @@ int vp9_find_best_sub_pixel_tree(MACROBLOCK *x, unsigned int eighthiters = iters_per_step; const int y_stride = xd->plane[0].pre[0].stride; - const int offset = bestmv->as_mv.row * y_stride + bestmv->as_mv.col; + const int offset = bestmv->row * y_stride + bestmv->col; uint8_t *y = xd->plane[0].pre[0].buf + offset; - int rr = ref_mv->as_mv.row; - int rc = ref_mv->as_mv.col; - int br = bestmv->as_mv.row * 8; - int bc = bestmv->as_mv.col * 8; + int rr = ref_mv->row; + int rc = ref_mv->col; + int br = bestmv->row * 8; + int bc = bestmv->col * 8; int hstep = 4; - const int minc = MAX(x->mv_col_min * 8, ref_mv->as_mv.col - MV_MAX); - const int maxc = MIN(x->mv_col_max * 8, ref_mv->as_mv.col + MV_MAX); - const int minr = MAX(x->mv_row_min * 8, ref_mv->as_mv.row - MV_MAX); - const int maxr = MIN(x->mv_row_max * 8, ref_mv->as_mv.row + MV_MAX); + const int minc = MAX(x->mv_col_min * 8, ref_mv->col - MV_MAX); + const int maxc = MIN(x->mv_col_max * 8, ref_mv->col + MV_MAX); + const int minr = MAX(x->mv_row_min * 8, ref_mv->row - MV_MAX); + const int maxr = MIN(x->mv_row_max * 8, ref_mv->row + MV_MAX); int tr = br; int tc = bc; // central mv - bestmv->as_mv.row *= 8; - bestmv->as_mv.col *= 8; + bestmv->row *= 8; + bestmv->col *= 8; // calculate central point error besterr = vfp->vf(y, y_stride, z, src_stride, sse1); @@ -435,7 +436,7 @@ int vp9_find_best_sub_pixel_tree(MACROBLOCK *x, tc = bc; } - if (xd->allow_high_precision_mv && vp9_use_mv_hp(&ref_mv->as_mv) && + if (xd->allow_high_precision_mv && vp9_use_mv_hp(ref_mv) && forced_stop == 0) { hstep >>= 1; FIRST_LEVEL_CHECKS; @@ -446,11 +447,11 @@ int vp9_find_best_sub_pixel_tree(MACROBLOCK *x, tc = bc; } - bestmv->as_mv.row = br; - bestmv->as_mv.col = bc; + bestmv->row = br; + bestmv->col = bc; - if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) || - (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3))) + if ((abs(bestmv->col - ref_mv->col) > (MAX_FULL_PEL_VAL << 3)) || + (abs(bestmv->row - ref_mv->row) > (MAX_FULL_PEL_VAL << 3))) return INT_MAX; return besterr; @@ -463,7 +464,7 @@ int vp9_find_best_sub_pixel_tree(MACROBLOCK *x, z, src_stride, &sse, second_pred) int vp9_find_best_sub_pixel_comp_iterative(MACROBLOCK *x, - int_mv *bestmv, int_mv *ref_mv, + MV *bestmv, const MV *ref_mv, int error_per_bit, const vp9_variance_fn_ptr_t *vfp, int forced_stop, @@ -487,25 +488,25 @@ int vp9_find_best_sub_pixel_comp_iterative(MACROBLOCK *x, DECLARE_ALIGNED_ARRAY(16, uint8_t, comp_pred, 64 * 64); const int y_stride = xd->plane[0].pre[0].stride; - const int offset = bestmv->as_mv.row * y_stride + bestmv->as_mv.col; + const int offset = bestmv->row * y_stride + bestmv->col; uint8_t *const y = xd->plane[0].pre[0].buf + offset; - int rr = ref_mv->as_mv.row; - int rc = ref_mv->as_mv.col; - int br = bestmv->as_mv.row * 8; - int bc = bestmv->as_mv.col * 8; + int rr = ref_mv->row; + int rc = ref_mv->col; + int br = bestmv->row * 8; + int bc = bestmv->col * 8; int hstep = 4; - const int minc = MAX(x->mv_col_min * 8, ref_mv->as_mv.col - MV_MAX); - const int maxc = MIN(x->mv_col_max * 8, ref_mv->as_mv.col + MV_MAX); - const int minr = MAX(x->mv_row_min * 8, ref_mv->as_mv.row - MV_MAX); - const int maxr = MIN(x->mv_row_max * 8, ref_mv->as_mv.row + MV_MAX); + const int minc = MAX(x->mv_col_min * 8, ref_mv->col - MV_MAX); + const int maxc = MIN(x->mv_col_max * 8, ref_mv->col + MV_MAX); + const int minr = MAX(x->mv_row_min * 8, ref_mv->row - MV_MAX); + const int maxr = MIN(x->mv_row_max * 8, ref_mv->row + MV_MAX); int tr = br; int tc = bc; // central mv - bestmv->as_mv.row *= 8; - bestmv->as_mv.col *= 8; + bestmv->row *= 8; + bestmv->col *= 8; // calculate central point error // TODO(yunqingwang): central pointer error was already calculated in full- @@ -543,7 +544,7 @@ int vp9_find_best_sub_pixel_comp_iterative(MACROBLOCK *x, } } - if (xd->allow_high_precision_mv && vp9_use_mv_hp(&ref_mv->as_mv) && + if (xd->allow_high_precision_mv && vp9_use_mv_hp(ref_mv) && forced_stop == 0) { hstep >>= 1; while (eighthiters--) { @@ -555,18 +556,18 @@ int vp9_find_best_sub_pixel_comp_iterative(MACROBLOCK *x, tc = bc; } } - bestmv->as_mv.row = br; - bestmv->as_mv.col = bc; + bestmv->row = br; + bestmv->col = bc; - if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) || - (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3))) + if ((abs(bestmv->col - ref_mv->col) > (MAX_FULL_PEL_VAL << 3)) || + (abs(bestmv->row - ref_mv->row) > (MAX_FULL_PEL_VAL << 3))) return INT_MAX; return besterr; } int vp9_find_best_sub_pixel_comp_tree(MACROBLOCK *x, - int_mv *bestmv, int_mv *ref_mv, + MV *bestmv, const MV *ref_mv, int error_per_bit, const vp9_variance_fn_ptr_t *vfp, int forced_stop, @@ -589,25 +590,25 @@ int vp9_find_best_sub_pixel_comp_tree(MACROBLOCK *x, DECLARE_ALIGNED_ARRAY(16, uint8_t, comp_pred, 64 * 64); const int y_stride = xd->plane[0].pre[0].stride; - const int offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col; + const int offset = bestmv->row * y_stride + bestmv->col; uint8_t *y = xd->plane[0].pre[0].buf + offset; - int rr = ref_mv->as_mv.row; - int rc = ref_mv->as_mv.col; - int br = bestmv->as_mv.row * 8; - int bc = bestmv->as_mv.col * 8; + int rr = ref_mv->row; + int rc = ref_mv->col; + int br = bestmv->row * 8; + int bc = bestmv->col * 8; int hstep = 4; - const int minc = MAX(x->mv_col_min * 8, ref_mv->as_mv.col - MV_MAX); - const int maxc = MIN(x->mv_col_max * 8, ref_mv->as_mv.col + MV_MAX); - const int minr = MAX(x->mv_row_min * 8, ref_mv->as_mv.row - MV_MAX); - const int maxr = MIN(x->mv_row_max * 8, ref_mv->as_mv.row + MV_MAX); + const int minc = MAX(x->mv_col_min * 8, ref_mv->col - MV_MAX); + const int maxc = MIN(x->mv_col_max * 8, ref_mv->col + MV_MAX); + const int minr = MAX(x->mv_row_min * 8, ref_mv->row - MV_MAX); + const int maxr = MIN(x->mv_row_max * 8, ref_mv->row + MV_MAX); int tr = br; int tc = bc; // central mv - bestmv->as_mv.row *= 8; - bestmv->as_mv.col *= 8; + bestmv->row *= 8; + bestmv->col *= 8; // calculate central point error // TODO(yunqingwang): central pointer error was already calculated in full- @@ -641,7 +642,7 @@ int vp9_find_best_sub_pixel_comp_tree(MACROBLOCK *x, tc = bc; } - if (xd->allow_high_precision_mv && vp9_use_mv_hp(&ref_mv->as_mv) && + if (xd->allow_high_precision_mv && vp9_use_mv_hp(ref_mv) && forced_stop == 0) { hstep >>= 1; FIRST_LEVEL_CHECKS; @@ -651,11 +652,11 @@ int vp9_find_best_sub_pixel_comp_tree(MACROBLOCK *x, tr = br; tc = bc; } - bestmv->as_mv.row = br; - bestmv->as_mv.col = bc; + bestmv->row = br; + bestmv->col = bc; - if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) || - (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3))) + if ((abs(bestmv->col - ref_mv->col) > (MAX_FULL_PEL_VAL << 3)) || + (abs(bestmv->row - ref_mv->row) > (MAX_FULL_PEL_VAL << 3))) return INT_MAX; return besterr; @@ -679,10 +680,10 @@ int vp9_find_best_sub_pixel_comp_tree(MACROBLOCK *x, #define CHECK_POINT \ {\ - if (this_mv.as_mv.col < x->mv_col_min) continue;\ - if (this_mv.as_mv.col > x->mv_col_max) continue;\ - if (this_mv.as_mv.row < x->mv_row_min) continue;\ - if (this_mv.as_mv.row > x->mv_row_max) continue;\ + if (this_mv.col < x->mv_col_min) continue;\ + if (this_mv.col > x->mv_col_max) continue;\ + if (this_mv.row < x->mv_row_min) continue;\ + if (this_mv.row > x->mv_row_max) continue;\ } #define CHECK_BETTER \ @@ -690,7 +691,7 @@ int vp9_find_best_sub_pixel_comp_tree(MACROBLOCK *x, if (thissad < bestsad)\ {\ if (use_mvcost) \ - thissad += mvsad_err_cost(&this_mv, &fcenter_mv, \ + thissad += mvsad_err_cost(&this_mv, &fcenter_mv.as_mv, \ mvjsadcost, mvsadcost, \ sad_per_bit);\ if (thissad < bestsad)\ @@ -715,14 +716,14 @@ int vp9_find_best_sub_pixel_comp_tree(MACROBLOCK *x, // candidates as indicated in the num_candidates and candidates arrays // passed into this function static int vp9_pattern_search(MACROBLOCK *x, - int_mv *ref_mv, + MV *ref_mv, int search_param, int sad_per_bit, int do_init_search, int do_refine, const vp9_variance_fn_ptr_t *vfp, int use_mvcost, - int_mv *center_mv, int_mv *best_mv, + const MV *center_mv, MV *best_mv, const int num_candidates[MAX_PATTERN_SCALES], const MV candidates[MAX_PATTERN_SCALES] [MAX_PATTERN_CANDIDATES]) { @@ -735,7 +736,7 @@ static int vp9_pattern_search(MACROBLOCK *x, int what_stride = x->plane[0].src.stride; int in_what_stride = xd->plane[0].pre[0].stride; int br, bc; - int_mv this_mv; + MV this_mv; int bestsad = INT_MAX; int thissad; uint8_t *base_offset; @@ -748,24 +749,22 @@ static int vp9_pattern_search(MACROBLOCK *x, 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; // adjust ref_mv to make sure it is within MV range - clamp_mv(&ref_mv->as_mv, - x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max); - br = ref_mv->as_mv.row; - bc = 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); + br = ref_mv->row; + bc = ref_mv->col; // Work out the start point for the search base_offset = (uint8_t *)(xd->plane[0].pre[0].buf); this_offset = base_offset + (br * in_what_stride) + bc; - this_mv.as_mv.row = br; - this_mv.as_mv.col = bc; - bestsad = vfp->sdf(what, what_stride, this_offset, - in_what_stride, 0x7fffffff) - + mvsad_err_cost(&this_mv, &fcenter_mv, mvjsadcost, mvsadcost, - sad_per_bit); + this_mv.row = br; + this_mv.col = bc; + bestsad = vfp->sdf(what, what_stride, this_offset, in_what_stride, 0x7fffffff) + + mvsad_err_cost(&this_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, 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 @@ -778,21 +777,21 @@ static int vp9_pattern_search(MACROBLOCK *x, CHECK_BOUNDS((1 << t)) if (all_in) { for (i = 0; i < num_candidates[t]; i++) { - this_mv.as_mv.row = br + candidates[t][i].row; - this_mv.as_mv.col = bc + candidates[t][i].col; - this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + - this_mv.as_mv.col; + this_mv.row = br + candidates[t][i].row; + this_mv.col = bc + candidates[t][i].col; + this_offset = base_offset + (this_mv.row * in_what_stride) + + this_mv.col; thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad); CHECK_BETTER } } else { for (i = 0; i < num_candidates[t]; i++) { - this_mv.as_mv.row = br + candidates[t][i].row; - this_mv.as_mv.col = bc + candidates[t][i].col; + this_mv.row = br + candidates[t][i].row; + this_mv.col = bc + candidates[t][i].col; CHECK_POINT - this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + - this_mv.as_mv.col; + this_offset = base_offset + (this_mv.row * in_what_stride) + + this_mv.col; thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad); CHECK_BETTER @@ -822,21 +821,21 @@ static int vp9_pattern_search(MACROBLOCK *x, CHECK_BOUNDS((1 << s)) if (all_in) { for (i = 0; i < num_candidates[s]; i++) { - this_mv.as_mv.row = br + candidates[s][i].row; - this_mv.as_mv.col = bc + candidates[s][i].col; - this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + - this_mv.as_mv.col; + this_mv.row = br + candidates[s][i].row; + this_mv.col = bc + candidates[s][i].col; + this_offset = base_offset + (this_mv.row * in_what_stride) + + this_mv.col; thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad); CHECK_BETTER } } else { for (i = 0; i < num_candidates[s]; i++) { - this_mv.as_mv.row = br + candidates[s][i].row; - this_mv.as_mv.col = bc + candidates[s][i].col; + this_mv.row = br + candidates[s][i].row; + this_mv.col = bc + candidates[s][i].col; CHECK_POINT - this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + - this_mv.as_mv.col; + this_offset = base_offset + (this_mv.row * in_what_stride) + + this_mv.col; thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad); CHECK_BETTER @@ -860,25 +859,21 @@ static int vp9_pattern_search(MACROBLOCK *x, get_next_chkpts(next_chkpts_indices, k, num_candidates[s]); if (all_in) { for (i = 0; i < PATTERN_CANDIDATES_REF; i++) { - this_mv.as_mv.row = br + - candidates[s][next_chkpts_indices[i]].row; - this_mv.as_mv.col = bc + - candidates[s][next_chkpts_indices[i]].col; - this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + - this_mv.as_mv.col; + this_mv.row = br + candidates[s][next_chkpts_indices[i]].row; + this_mv.col = bc + candidates[s][next_chkpts_indices[i]].col; + this_offset = base_offset + (this_mv.row * (in_what_stride)) + + this_mv.col; thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad); CHECK_BETTER } } else { for (i = 0; i < PATTERN_CANDIDATES_REF; i++) { - this_mv.as_mv.row = br + - candidates[s][next_chkpts_indices[i]].row; - this_mv.as_mv.col = bc + - candidates[s][next_chkpts_indices[i]].col; + this_mv.row = br + candidates[s][next_chkpts_indices[i]].row; + this_mv.col = bc + candidates[s][next_chkpts_indices[i]].col; CHECK_POINT - this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + - this_mv.as_mv.col; + this_offset = base_offset + (this_mv.row * (in_what_stride)) + + this_mv.col; thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad); CHECK_BETTER @@ -905,21 +900,21 @@ static int vp9_pattern_search(MACROBLOCK *x, CHECK_BOUNDS(1) if (all_in) { for (i = 0; i < 4; i++) { - this_mv.as_mv.row = br + neighbors[i].row; - this_mv.as_mv.col = bc + neighbors[i].col; - this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + - this_mv.as_mv.col; + this_mv.row = br + neighbors[i].row; + this_mv.col = bc + neighbors[i].col; + this_offset = base_offset + (this_mv.row * (in_what_stride)) + + this_mv.col; thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad); CHECK_BETTER } } else { for (i = 0; i < 4; i++) { - this_mv.as_mv.row = br + neighbors[i].row; - this_mv.as_mv.col = bc + neighbors[i].col; + this_mv.row = br + neighbors[i].row; + this_mv.col = bc + neighbors[i].col; CHECK_POINT - this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + - this_mv.as_mv.col; + this_offset = base_offset + (this_mv.row * (in_what_stride)) + + this_mv.col; thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad); CHECK_BETTER @@ -935,31 +930,32 @@ static int vp9_pattern_search(MACROBLOCK *x, } } - best_mv->as_mv.row = br; - best_mv->as_mv.col = bc; + best_mv->row = br; + best_mv->col = bc; - this_offset = base_offset + (best_mv->as_mv.row * (in_what_stride)) + - best_mv->as_mv.col; - this_mv.as_mv.row = best_mv->as_mv.row * 8; - this_mv.as_mv.col = best_mv->as_mv.col * 8; + this_offset = base_offset + (best_mv->row * in_what_stride) + + best_mv->col; + this_mv.row = best_mv->row * 8; + this_mv.col = best_mv->col * 8; if (bestsad == INT_MAX) return INT_MAX; - return - vfp->vf(what, what_stride, this_offset, in_what_stride, - (unsigned int *)(&bestsad)) + - use_mvcost ? mv_err_cost(&this_mv, center_mv, x->nmvjointcost, x->mvcost, - x->errorperbit) : 0; + + return vfp->vf(what, what_stride, this_offset, in_what_stride, + (unsigned int *)&bestsad) + + use_mvcost ? mv_err_cost(&this_mv, center_mv, + x->nmvjointcost, x->mvcost, x->errorperbit) + : 0; } int vp9_hex_search(MACROBLOCK *x, - int_mv *ref_mv, + MV *ref_mv, int search_param, int sad_per_bit, int do_init_search, const vp9_variance_fn_ptr_t *vfp, int use_mvcost, - int_mv *center_mv, int_mv *best_mv) { + const MV *center_mv, MV *best_mv) { // First scale has 8-closest points, the rest have 6 points in hex shape // at increasing scales static const int hex_num_candidates[MAX_PATTERN_SCALES] = { @@ -988,14 +984,14 @@ int vp9_hex_search(MACROBLOCK *x, } int vp9_bigdia_search(MACROBLOCK *x, - int_mv *ref_mv, + MV *ref_mv, int search_param, int sad_per_bit, int do_init_search, const vp9_variance_fn_ptr_t *vfp, int use_mvcost, - int_mv *center_mv, - int_mv *best_mv) { + const MV *center_mv, + MV *best_mv) { // First scale has 4-closest points, the rest have 8 points in diamond // shape at increasing scales static const int bigdia_num_candidates[MAX_PATTERN_SCALES] = { @@ -1022,22 +1018,21 @@ int vp9_bigdia_search(MACROBLOCK *x, {{-512, -512}, {0, -1024}, {512, -512}, {1024, 0}, {512, 512}, {0, 1024}, {-512, 512}, {-1024, 0}}, }; - return - vp9_pattern_search(x, ref_mv, search_param, sad_per_bit, - do_init_search, 0, vfp, use_mvcost, - center_mv, best_mv, - bigdia_num_candidates, bigdia_candidates); + return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit, + do_init_search, 0, vfp, use_mvcost, + center_mv, best_mv, + bigdia_num_candidates, bigdia_candidates); } int vp9_square_search(MACROBLOCK *x, - int_mv *ref_mv, + MV *ref_mv, int search_param, int sad_per_bit, int do_init_search, const vp9_variance_fn_ptr_t *vfp, int use_mvcost, - int_mv *center_mv, - int_mv *best_mv) { + const MV *center_mv, + MV *best_mv) { // All scales have 8 closest points in square shape static const int square_num_candidates[MAX_PATTERN_SCALES] = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, @@ -1064,11 +1059,10 @@ int vp9_square_search(MACROBLOCK *x, {{-1024, -1024}, {0, -1024}, {1024, -1024}, {1024, 0}, {1024, 1024}, {0, 1024}, {-1024, 1024}, {-1024, 0}}, }; - return - vp9_pattern_search(x, ref_mv, search_param, sad_per_bit, - do_init_search, 0, vfp, use_mvcost, - center_mv, best_mv, - square_num_candidates, square_candidates); + return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit, + do_init_search, 0, vfp, use_mvcost, + center_mv, best_mv, + square_num_candidates, square_candidates); }; #undef CHECK_BOUNDS @@ -1124,10 +1118,9 @@ int vp9_diamond_search_sad_c(MACROBLOCK *x, 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); + bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) + + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, sad_per_bit); // search_param determines the length of the initial step and hence the number of iterations // 0 = initial step (MAX_FIRST_STEP) pel : 1 = (MAX_FIRST_STEP/2) pel, 2 = (MAX_FIRST_STEP/4) pel... etc. @@ -1153,7 +1146,7 @@ int vp9_diamond_search_sad_c(MACROBLOCK *x, 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, &fcenter_mv, + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { @@ -1185,7 +1178,7 @@ int vp9_diamond_search_sad_c(MACROBLOCK *x, 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, &fcenter_mv, + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1210,8 +1203,9 @@ int vp9_diamond_search_sad_c(MACROBLOCK *x, 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); + (unsigned int *)(&thissad)) + + mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, + mvjcost, mvcost, x->errorperbit); } int vp9_diamond_search_sadx4(MACROBLOCK *x, @@ -1265,10 +1259,9 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, 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); + bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) + + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, sad_per_bit); // search_param determines the length of the initial step and hence the number of iterations // 0 = initial step (MAX_FIRST_STEP) pel : 1 = (MAX_FIRST_STEP/2) pel, 2 = (MAX_FIRST_STEP/4) pel... etc. @@ -1303,7 +1296,7 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, 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, &fcenter_mv, + sad_array[t] += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, mvjsadcost, mvsadcost, sad_per_bit); if (sad_array[t] < bestsad) { @@ -1327,7 +1320,7 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, 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, &fcenter_mv, + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { @@ -1358,7 +1351,7 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, 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, &fcenter_mv, + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1383,8 +1376,9 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, 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); + (unsigned int *)(&thissad)) + + mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, + mvjcost, mvcost, x->errorperbit); } /* do_refine: If last step (1-away) of n-step search doesn't pick the center @@ -1495,8 +1489,8 @@ int vp9_full_search_sad_c(MACROBLOCK *x, int_mv *ref_mv, // Baseline value at the centre bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) - + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost, - sad_per_bit); + + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, sad_per_bit); // Apply further limits to prevent us looking using vectors that stretch // beyond the UMV border @@ -1513,8 +1507,8 @@ int vp9_full_search_sad_c(MACROBLOCK *x, int_mv *ref_mv, 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, &fcenter_mv, - mvjsadcost, mvsadcost, sad_per_bit); + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1531,10 +1525,10 @@ int vp9_full_search_sad_c(MACROBLOCK *x, int_mv *ref_mv, this_mv.as_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, center_mv, mvjcost, mvcost, x->errorperbit); + return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, + (unsigned int *)(&thissad)) + + mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, + mvjcost, mvcost, x->errorperbit); else return INT_MAX; } @@ -1585,8 +1579,8 @@ int vp9_full_search_sadx3(MACROBLOCK *x, int_mv *ref_mv, // Baseline value at the centre bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) - + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost, - sad_per_bit); + + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, sad_per_bit); // Apply further limits to prevent us looking using vectors that stretch // beyond the UMV border @@ -1610,8 +1604,8 @@ int vp9_full_search_sadx3(MACROBLOCK *x, int_mv *ref_mv, if (thissad < bestsad) { this_mv.as_mv.col = c; - thissad += mvsad_err_cost(&this_mv, &fcenter_mv, - mvjsadcost, mvsadcost, sad_per_bit); + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1631,7 +1625,7 @@ int vp9_full_search_sadx3(MACROBLOCK *x, int_mv *ref_mv, if (thissad < bestsad) { this_mv.as_mv.col = c; - thissad += mvsad_err_cost(&this_mv, &fcenter_mv, + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { @@ -1652,10 +1646,10 @@ int vp9_full_search_sadx3(MACROBLOCK *x, int_mv *ref_mv, this_mv.as_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, center_mv, mvjcost, mvcost, x->errorperbit); + return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, + (unsigned int *)(&thissad)) + + mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, + mvjcost, mvcost, x->errorperbit); else return INT_MAX; } @@ -1708,8 +1702,8 @@ int vp9_full_search_sadx8(MACROBLOCK *x, int_mv *ref_mv, // Baseline value at the centre bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride, 0x7fffffff) - + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost, - sad_per_bit); + + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, sad_per_bit); // Apply further limits to prevent us looking using vectors that stretch // beyond the UMV border @@ -1733,8 +1727,8 @@ int vp9_full_search_sadx8(MACROBLOCK *x, int_mv *ref_mv, if (thissad < bestsad) { this_mv.as_mv.col = c; - thissad += mvsad_err_cost(&this_mv, &fcenter_mv, - mvjsadcost, mvsadcost, sad_per_bit); + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1759,7 +1753,7 @@ int vp9_full_search_sadx8(MACROBLOCK *x, int_mv *ref_mv, if (thissad < bestsad) { this_mv.as_mv.col = c; - thissad += mvsad_err_cost(&this_mv, &fcenter_mv, + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { @@ -1780,8 +1774,8 @@ int vp9_full_search_sadx8(MACROBLOCK *x, int_mv *ref_mv, if (thissad < bestsad) { this_mv.as_mv.col = c; - thissad += mvsad_err_cost(&this_mv, &fcenter_mv, - mvjsadcost, mvsadcost, sad_per_bit); + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1800,10 +1794,10 @@ int vp9_full_search_sadx8(MACROBLOCK *x, int_mv *ref_mv, this_mv.as_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, center_mv, mvjcost, mvcost, x->errorperbit); + return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, + (unsigned int *)(&thissad)) + + mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, + mvjcost, mvcost, x->errorperbit); else return INT_MAX; } @@ -1834,8 +1828,10 @@ int vp9_refining_search_sad_c(MACROBLOCK *x, fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; - bestsad = fn_ptr->sdf(what, what_stride, best_address, in_what_stride, 0x7fffffff) + - mvsad_err_cost(ref_mv, &fcenter_mv, mvjsadcost, mvsadcost, error_per_bit); + bestsad = fn_ptr->sdf(what, what_stride, best_address, + in_what_stride, 0x7fffffff) + + mvsad_err_cost(&ref_mv->as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, error_per_bit); for (i = 0; i < search_range; i++) { int best_site = -1; @@ -1852,8 +1848,8 @@ int vp9_refining_search_sad_c(MACROBLOCK *x, 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, &fcenter_mv, mvjsadcost, - mvsadcost, error_per_bit); + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, error_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1876,10 +1872,10 @@ int vp9_refining_search_sad_c(MACROBLOCK *x, this_mv.as_mv.col = ref_mv->as_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, center_mv, mvjcost, mvcost, x->errorperbit); + return fn_ptr->vf(what, what_stride, best_address, in_what_stride, + (unsigned int *)(&thissad)) + + mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, + mvjcost, mvcost, x->errorperbit); else return INT_MAX; } @@ -1911,8 +1907,10 @@ int vp9_refining_search_sadx4(MACROBLOCK *x, fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; - bestsad = fn_ptr->sdf(what, what_stride, best_address, in_what_stride, 0x7fffffff) + - mvsad_err_cost(ref_mv, &fcenter_mv, mvjsadcost, mvsadcost, error_per_bit); + bestsad = fn_ptr->sdf(what, what_stride, best_address, + in_what_stride, 0x7fffffff) + + mvsad_err_cost(&ref_mv->as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, error_per_bit); for (i = 0; i < search_range; i++) { int best_site = -1; @@ -1935,8 +1933,8 @@ int vp9_refining_search_sadx4(MACROBLOCK *x, 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, &fcenter_mv, mvjsadcost, - mvsadcost, error_per_bit); + sad_array[j] += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, error_per_bit); if (sad_array[j] < bestsad) { bestsad = sad_array[j]; @@ -1957,8 +1955,8 @@ int vp9_refining_search_sadx4(MACROBLOCK *x, 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, &fcenter_mv, mvjsadcost, - mvsadcost, error_per_bit); + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, error_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1982,10 +1980,10 @@ int vp9_refining_search_sadx4(MACROBLOCK *x, this_mv.as_mv.col = ref_mv->as_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, center_mv, mvjcost, mvcost, x->errorperbit); + return fn_ptr->vf(what, what_stride, best_address, in_what_stride, + (unsigned int *)(&thissad)) + + mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, + mvjcost, mvcost, x->errorperbit); else return INT_MAX; } @@ -2025,7 +2023,8 @@ int vp9_refining_search_8p_c(MACROBLOCK *x, /* Get compound pred by averaging two pred blocks. */ bestsad = fn_ptr->sdaf(what, what_stride, best_address, in_what_stride, second_pred, 0x7fffffff) + - mvsad_err_cost(ref_mv, &fcenter_mv, mvjsadcost, mvsadcost, error_per_bit); + mvsad_err_cost(&ref_mv->as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, error_per_bit); for (i = 0; i < search_range; i++) { int best_site = -1; @@ -2048,9 +2047,8 @@ int vp9_refining_search_8p_c(MACROBLOCK *x, 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, &fcenter_mv, mvjsadcost, - mvsadcost, error_per_bit); - + thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, + mvjsadcost, mvsadcost, error_per_bit); if (thissad < bestsad) { bestsad = thissad; best_site = j; @@ -2075,10 +2073,10 @@ int vp9_refining_search_8p_c(MACROBLOCK *x, if (bestsad < INT_MAX) { // FIXME(rbultje, yunqing): add full-pixel averaging variance functions // so we don't have to use the subpixel with xoff=0,yoff=0 here. - return fn_ptr->svaf(best_address, in_what_stride, 0, 0, - what, what_stride, (unsigned int *)(&thissad), - second_pred) + - mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit); + return fn_ptr->svaf(best_address, in_what_stride, 0, 0, what, what_stride, + (unsigned int *)(&thissad), second_pred) + + mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, + mvjcost, mvcost, x->errorperbit); } else { return INT_MAX; } |