From b87696ac37dbc452b5d58d53d652f71565de4061 Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Tue, 24 Sep 2013 12:48:12 -0700 Subject: [PATCH] Moving from int_mv* to MV* (2). Updating fractional_mv_step_fp and fractional_mv_step_comp_fp function types. Change-Id: I601c4378bc39ac3ffd4e295d9cbd8e1f74829d46 --- vp9/encoder/vp9_mbgraph.c | 2 +- vp9/encoder/vp9_mcomp.c | 148 +++++++++++++++++++------------------- vp9/encoder/vp9_mcomp.h | 5 +- vp9/encoder/vp9_rdopt.c | 12 ++-- vp9/encoder/vp9_temporal_filter.c | 4 +- 5 files changed, 84 insertions(+), 87 deletions(-) diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c index 5a671f2..3349e75 100644 --- a/vp9/encoder/vp9_mbgraph.c +++ b/vp9/encoder/vp9_mbgraph.c @@ -57,7 +57,7 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, unsigned int sse; best_err = cpi->find_fractional_mv_step( x, - dst_mv, ref_mv, + &dst_mv->as_mv, &ref_mv->as_mv, x->errorperbit, &v_fn_ptr, 0, cpi->sf.subpel_iters_per_step, NULL, NULL, & distortion, &sse); diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index a2a0557..ad8ea70 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -274,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, @@ -295,31 +295,30 @@ 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); *distortion = besterr; - besterr += mv_err_cost(&bestmv->as_mv, &ref_mv->as_mv, - mvjcost, mvcost, error_per_bit); + besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit); // TODO: Each subsequent iteration checks at least one point in // common with the last iteration could be 2 ( if diag selected) @@ -349,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--) { @@ -362,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, @@ -393,31 +392,30 @@ 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); *distortion = besterr; - besterr += mv_err_cost(&bestmv->as_mv, &ref_mv->as_mv, - mvjcost, mvcost, error_per_bit); + besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit); // 1/2 pel FIRST_LEVEL_CHECKS; @@ -438,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; @@ -449,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; @@ -466,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, @@ -490,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- @@ -516,8 +514,7 @@ int vp9_find_best_sub_pixel_comp_iterative(MACROBLOCK *x, 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->as_mv, &ref_mv->as_mv, - mvjcost, mvcost, error_per_bit); + 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) @@ -547,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--) { @@ -559,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, @@ -593,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- @@ -619,8 +616,7 @@ int vp9_find_best_sub_pixel_comp_tree(MACROBLOCK *x, 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->as_mv, &ref_mv->as_mv, - mvjcost, mvcost, error_per_bit); + 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) @@ -646,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; @@ -656,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; diff --git a/vp9/encoder/vp9_mcomp.h b/vp9/encoder/vp9_mcomp.h index 3b9b2df..f2b6d80 100644 --- a/vp9/encoder/vp9_mcomp.h +++ b/vp9/encoder/vp9_mcomp.h @@ -69,8 +69,7 @@ int vp9_square_search(MACROBLOCK *x, typedef int (fractional_mv_step_fp) ( 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, // 0 - full, 1 - qtr only, 2 - half only @@ -84,7 +83,7 @@ extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree; typedef int (fractional_mv_step_comp_fp) ( 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, // 0 - full, 1 - qtr only, 2 - half only diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 2fe4d0a..e06b08c 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -1860,8 +1860,10 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, if (bestsme < INT_MAX) { int distortion; unsigned int sse; - cpi->find_fractional_mv_step(x, &mode_mv[NEWMV], - bsi->ref_mv, x->errorperbit, v_fn_ptr, + cpi->find_fractional_mv_step(x, + &mode_mv[NEWMV].as_mv, + &bsi->ref_mv->as_mv, + x->errorperbit, v_fn_ptr, 0, cpi->sf.subpel_iters_per_step, x->nmvjointcost, x->mvcost, &distortion, &sse); @@ -2456,7 +2458,7 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, if (bestsme < INT_MAX) { int dis; /* TODO: use dis in distortion calculation later. */ unsigned int sse; - cpi->find_fractional_mv_step(x, tmp_mv, &ref_mv, + cpi->find_fractional_mv_step(x, &tmp_mv->as_mv, &ref_mv.as_mv, x->errorperbit, &cpi->fn_ptr[block_size], 0, cpi->sf.subpel_iters_per_step, @@ -2590,8 +2592,8 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, unsigned int sse; bestsme = cpi->find_fractional_mv_step_comp( - x, &tmp_mv, - &ref_mv[id], + x, &tmp_mv.as_mv, + &ref_mv[id].as_mv, x->errorperbit, &cpi->fn_ptr[block_size], 0, cpi->sf.subpel_iters_per_step, diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c index 63826ee..0d0fd6d 100644 --- a/vp9/encoder/vp9_temporal_filter.c +++ b/vp9/encoder/vp9_temporal_filter.c @@ -166,8 +166,8 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi, int distortion; unsigned int sse; // Ignore mv costing by sending NULL pointer instead of cost array - bestsme = cpi->find_fractional_mv_step(x, ref_mv, - &best_ref_mv1, + bestsme = cpi->find_fractional_mv_step(x, &ref_mv->as_mv, + &best_ref_mv1.as_mv, x->errorperbit, &cpi->fn_ptr[BLOCK_16X16], 0, cpi->sf.subpel_iters_per_step, -- 2.7.4