} \
}
-int vp9_find_best_sub_pixel_iterative(MACROBLOCK *x,
- MV *bestmv, const MV *ref_mv,
- int allow_hp,
- int error_per_bit,
- const vp9_variance_fn_ptr_t *vfp,
- int forced_stop,
- int iters_per_step,
- int *mvjcost, int *mvcost[2],
- int *distortion,
- unsigned int *sse1) {
- uint8_t *z = x->plane[0].src.buf;
- int src_stride = x->plane[0].src.stride;
- MACROBLOCKD *xd = &x->e_mbd;
-
- unsigned int besterr = INT_MAX;
- unsigned int sse;
- unsigned int whichdir;
- unsigned int halfiters = iters_per_step;
- unsigned int quarteriters = iters_per_step;
- unsigned int eighthiters = iters_per_step;
- int thismse;
-
- const int y_stride = xd->plane[0].pre[0].stride;
- const int offset = bestmv->row * y_stride + bestmv->col;
- uint8_t *y = xd->plane[0].pre[0].buf + offset;
-
- 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->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->row <<= 3;
- bestmv->col <<= 3;
-
- // calculate central point error
- besterr = vfp->vf(y, y_stride, z, src_stride, sse1);
- *distortion = besterr;
- besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
-
- // TODO(jbb): Each subsequent iteration checks at least one point in
- // common with the last iteration could be 2 if diagonal is selected.
- while (halfiters--) {
- // 1/2 pel
- FIRST_LEVEL_CHECKS;
- // no reason to check the same one again.
- if (tr == br && tc == bc)
- break;
- tr = br;
- tc = bc;
- }
-
- // TODO(yaowu): Each subsequent iteration checks at least one point in common
- // with the last iteration could be 2 if diagonal is selected.
-
- // Note forced_stop: 0 - full, 1 - qtr only, 2 - half only
- if (forced_stop != 2) {
- hstep >>= 1;
- while (quarteriters--) {
- FIRST_LEVEL_CHECKS;
- // no reason to check the same one again.
- if (tr == br && tc == bc)
- break;
- tr = br;
- tc = bc;
- }
- }
-
- if (allow_hp && vp9_use_mv_hp(ref_mv) && forced_stop == 0) {
- hstep >>= 1;
- while (eighthiters--) {
- FIRST_LEVEL_CHECKS;
- // no reason to check the same one again.
- if (tr == br && tc == bc)
- break;
- tr = br;
- tc = bc;
- }
- }
-
- bestmv->row = br;
- bestmv->col = bc;
-
- 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,
MV *bestmv, const MV *ref_mv,
int allow_hp,
vfp->svaf(PRE(r, c), y_stride, SP(c), SP(r), \
z, src_stride, &sse, second_pred)
-int vp9_find_best_sub_pixel_comp_iterative(MACROBLOCK *x,
- MV *bestmv, const MV *ref_mv,
- int allow_hp,
- int error_per_bit,
- const vp9_variance_fn_ptr_t *vfp,
- int forced_stop,
- int iters_per_step,
- int *mvjcost, int *mvcost[2],
- int *distortion,
- unsigned int *sse1,
- const uint8_t *second_pred,
- int w, int h) {
- uint8_t *const z = x->plane[0].src.buf;
- const int src_stride = x->plane[0].src.stride;
- MACROBLOCKD *const xd = &x->e_mbd;
-
- unsigned int besterr = INT_MAX;
- unsigned int sse;
- unsigned int whichdir;
- unsigned int halfiters = iters_per_step;
- unsigned int quarteriters = iters_per_step;
- unsigned int eighthiters = iters_per_step;
- int thismse;
-
- DECLARE_ALIGNED_ARRAY(16, uint8_t, comp_pred, 64 * 64);
- const int y_stride = xd->plane[0].pre[0].stride;
- const int offset = bestmv->row * y_stride + bestmv->col;
- uint8_t *const y = xd->plane[0].pre[0].buf + offset;
-
- 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->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->row *= 8;
- bestmv->col *= 8;
-
- // calculate central point error
- // TODO(yunqingwang): central pointer error was already calculated in full-
- // pixel search, and can be passed in this function.
- comp_avg_pred(comp_pred, second_pred, w, h, y, y_stride);
- besterr = vfp->vf(comp_pred, w, z, src_stride, sse1);
- *distortion = besterr;
- besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
-
- // Each subsequent iteration checks at least one point in
- // common with the last iteration could be 2 ( if diag selected)
- while (halfiters--) {
- // 1/2 pel
- FIRST_LEVEL_CHECKS;
- // no reason to check the same one again.
- if (tr == br && tc == bc)
- break;
- tr = br;
- tc = bc;
- }
-
- // Each subsequent iteration checks at least one point in common with
- // the last iteration could be 2 ( if diag selected) 1/4 pel
-
- // Note forced_stop: 0 - full, 1 - qtr only, 2 - half only
- if (forced_stop != 2) {
- hstep >>= 1;
- while (quarteriters--) {
- FIRST_LEVEL_CHECKS;
- // no reason to check the same one again.
- if (tr == br && tc == bc)
- break;
- tr = br;
- tc = bc;
- }
- }
-
- if (allow_hp && vp9_use_mv_hp(ref_mv) && forced_stop == 0) {
- hstep >>= 1;
- while (eighthiters--) {
- FIRST_LEVEL_CHECKS;
- // no reason to check the same one again.
- if (tr == br && tc == bc)
- break;
- tr = br;
- tc = bc;
- }
- }
- bestmv->row = br;
- bestmv->col = bc;
-
- 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,
MV *bestmv, const MV *ref_mv,
int allow_hp,