From c72be96b0a4b9ea6dfa03b259b88164a13993870 Mon Sep 17 00:00:00 2001 From: Jim Bankoski Date: Thu, 8 Nov 2012 15:44:39 -0800 Subject: [PATCH] remove macros obfuscating mv costing cleanup Change-Id: I565eee40d900e0441ad211b65ac829fc5b93d94a --- vp9/encoder/bitstream.c | 12 +-- vp9/encoder/block.h | 2 + vp9/encoder/firstpass.c | 6 +- vp9/encoder/mbgraph.c | 6 +- vp9/encoder/mcomp.c | 166 +++++++++++++++++++++++------------------- vp9/encoder/mcomp.h | 31 ++++---- vp9/encoder/onyx_if.c | 13 ++++ vp9/encoder/rdopt.c | 27 ++++--- vp9/encoder/temporal_filter.c | 4 +- 9 files changed, 147 insertions(+), 120 deletions(-) diff --git a/vp9/encoder/bitstream.c b/vp9/encoder/bitstream.c index b7bc99c..ffb2395 100644 --- a/vp9/encoder/bitstream.c +++ b/vp9/encoder/bitstream.c @@ -690,10 +690,8 @@ static unsigned int pick_best_mv_ref(MACROBLOCK *x, int max_mv = MV_MAX; cost = vp9_cost_mv_ref_id(xd->mb_mv_ref_id_probs[ref_frame], 0) + - vp9_mv_bit_cost(&target_mv, - &mv_ref_list[0], - XMVCOST, 96, - xd->allow_high_precision_mv); + vp9_mv_bit_cost(&target_mv, &mv_ref_list[0], x->nmvjointcost, + x->mvcost, 96, xd->allow_high_precision_mv); // Use 4 for now : for (i = 1; i < MAX_MV_REFS; ++i ) { @@ -714,10 +712,8 @@ static unsigned int pick_best_mv_ref(MACROBLOCK *x, } cost2 = vp9_cost_mv_ref_id(xd->mb_mv_ref_id_probs[ref_frame], i) + - vp9_mv_bit_cost(&target_mv, - &mv_ref_list[i], - XMVCOST, 96, - xd->allow_high_precision_mv); + vp9_mv_bit_cost(&target_mv, &mv_ref_list[i], x->nmvjointcost, + x->mvcost, 96, xd->allow_high_precision_mv); if (cost2 < cost) { cost = cost2; diff --git a/vp9/encoder/block.h b/vp9/encoder/block.h index 3b3794c..3f2910d 100644 --- a/vp9/encoder/block.h +++ b/vp9/encoder/block.h @@ -118,12 +118,14 @@ typedef struct macroblock { int *nmvcost[2]; int nmvcosts_hp[2][MV_VALS]; int *nmvcost_hp[2]; + int **mvcost; int nmvjointsadcost[MV_JOINTS]; int nmvsadcosts[2][MV_VALS]; int *nmvsadcost[2]; int nmvsadcosts_hp[2][MV_VALS]; int *nmvsadcost_hp[2]; + int **mvsadcost; int mbmode_cost[2][MB_MODE_COUNT]; int intra_uv_mode_cost[2][MB_MODE_COUNT]; diff --git a/vp9/encoder/firstpass.c b/vp9/encoder/firstpass.c index 0238232..efc9fb3 100644 --- a/vp9/encoder/firstpass.c +++ b/vp9/encoder/firstpass.c @@ -394,7 +394,8 @@ static void first_pass_motion_search(VP9_COMP *cpi, MACROBLOCK *x, ref_mv_full.as_mv.row = ref_mv->as_mv.row >> 3; tmp_err = cpi->diamond_search_sad(x, b, d, &ref_mv_full, &tmp_mv, step_param, x->sadperbit16, &num00, &v_fn_ptr, - XMVCOST, ref_mv); + x->nmvjointcost, + x->mvcost, ref_mv); if (tmp_err < INT_MAX - new_mv_mode_penalty) tmp_err += new_mv_mode_penalty; @@ -417,7 +418,8 @@ static void first_pass_motion_search(VP9_COMP *cpi, MACROBLOCK *x, tmp_err = cpi->diamond_search_sad(x, b, d, &ref_mv_full, &tmp_mv, step_param + n, x->sadperbit16, &num00, &v_fn_ptr, - XMVCOST, ref_mv); + x->nmvjointcost, + x->mvcost, ref_mv); if (tmp_err < INT_MAX - new_mv_mode_penalty) tmp_err += new_mv_mode_penalty; diff --git a/vp9/encoder/mbgraph.c b/vp9/encoder/mbgraph.c index e750616..2bcb3b5 100644 --- a/vp9/encoder/mbgraph.c +++ b/vp9/encoder/mbgraph.c @@ -56,8 +56,8 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, step_param, x->errorperbit, &v_fn_ptr, - NULLMVCOST, - NULLMVCOST, + NULL, NULL, + NULL, NULL, ref_mv); // Try sub-pixel MC @@ -69,7 +69,7 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, x, b, d, dst_mv, ref_mv, x->errorperbit, &v_fn_ptr, - NULLMVCOST, + NULL, NULL, & distortion, &sse); } diff --git a/vp9/encoder/mcomp.c b/vp9/encoder/mcomp.c index aaff8bc..90e944f 100644 --- a/vp9/encoder/mcomp.c +++ b/vp9/encoder/mcomp.c @@ -42,7 +42,7 @@ void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv) { x->mv_row_max = row_max; } -int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, DEC_MVCOSTS, +int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2], int Weight, int ishp) { MV v; v.row = (mv->as_mv.row - ref->as_mv.row); @@ -52,7 +52,7 @@ int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, DEC_MVCOSTS, Weight) >> 7; } -static int mv_err_cost(int_mv *mv, int_mv *ref, DEC_MVCOSTS, +static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2], int error_per_bit, int ishp) { if (mvcost) { MV v; @@ -65,8 +65,8 @@ static int mv_err_cost(int_mv *mv, int_mv *ref, DEC_MVCOSTS, return 0; } -static int mvsad_err_cost(int_mv *mv, int_mv *ref, DEC_MVSADCOSTS, - int error_per_bit) { +static int mvsad_err_cost(int_mv *mv, int_mv *ref, int *mvjsadcost, + int *mvsadcost[2], int error_per_bit) { if (mvsadcost) { MV v; @@ -248,7 +248,7 @@ int vp9_find_best_sub_pixel_step_iteratively(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *bestmv, int_mv *ref_mv, int error_per_bit, const vp9_variance_fn_ptr_t *vfp, - DEC_MVCOSTS, + int *mvjcost, int *mvcost[2], int *distortion, unsigned int *sse1) { unsigned char *z = (*(b->base_src) + b->src); @@ -316,7 +316,7 @@ int vp9_find_best_sub_pixel_step_iteratively(MACROBLOCK *x, BLOCK *b, BLOCKD *d, // calculate central point error besterr = vfp->vf(y, y_stride, z, b->src_stride, sse1); *distortion = besterr; - besterr += mv_err_cost(bestmv, ref_mv, MVCOSTS, + besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); // TODO: Each subsequent iteration checks at least one point in @@ -447,7 +447,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *bestmv, int_mv *ref_mv, int error_per_bit, const vp9_variance_fn_ptr_t *vfp, - DEC_MVCOSTS, int *distortion, + int *mvjcost, int *mvcost[2], int *distortion, unsigned int *sse1) { int bestmse = INT_MAX; int_mv startmv; @@ -485,14 +485,14 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, // calculate central point error bestmse = vfp->vf(y, y_stride, z, b->src_stride, sse1); *distortion = bestmse; - bestmse += mv_err_cost(bestmv, ref_mv, MVCOSTS, error_per_bit, + bestmse += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); // go left then right and check error this_mv.as_mv.row = startmv.as_mv.row; this_mv.as_mv.col = ((startmv.as_mv.col - 8) | 4); thismse = vfp->svf_halfpix_h(y - 1, y_stride, z, b->src_stride, &sse); - left = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + left = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (left < bestmse) { @@ -504,8 +504,8 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, this_mv.as_mv.col += 8; thismse = vfp->svf_halfpix_h(y, y_stride, z, b->src_stride, &sse); - right = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, - xd->allow_high_precision_mv); + right = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, + error_per_bit, xd->allow_high_precision_mv); if (right < bestmse) { *bestmv = this_mv; @@ -518,7 +518,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, this_mv.as_mv.col = startmv.as_mv.col; this_mv.as_mv.row = ((startmv.as_mv.row - 8) | 4); thismse = vfp->svf_halfpix_v(y - y_stride, y_stride, z, b->src_stride, &sse); - up = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + up = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (up < bestmse) { @@ -530,7 +530,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, this_mv.as_mv.row += 8; thismse = vfp->svf_halfpix_v(y, y_stride, z, b->src_stride, &sse); - down = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + down = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (down < bestmse) { @@ -571,7 +571,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, break; } - diag = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + diag = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (diag < bestmse) { @@ -613,7 +613,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, b->src_stride, &sse); } - left = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + left = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (left < bestmse) { @@ -627,8 +627,8 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse); - right = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, - xd->allow_high_precision_mv); + right = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, + error_per_bit, xd->allow_high_precision_mv); if (right < bestmse) { *bestmv = this_mv; @@ -651,7 +651,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, z, b->src_stride, &sse); } - up = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + up = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (up < bestmse) { @@ -664,7 +664,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, this_mv.as_mv.row += 4; thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse); - down = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + down = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (down < bestmse) { @@ -743,7 +743,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, break; } - diag = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + diag = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (diag < bestmse) { @@ -788,7 +788,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, z, b->src_stride, &sse); } - left = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + left = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (left < bestmse) { @@ -801,8 +801,8 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, this_mv.as_mv.col += 2; thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse); - right = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, - xd->allow_high_precision_mv); + right = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, + error_per_bit, xd->allow_high_precision_mv); if (right < bestmse) { *bestmv = this_mv; @@ -822,7 +822,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(7), z, b->src_stride, &sse); } - up = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + up = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (up < bestmse) { @@ -834,7 +834,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, this_mv.as_mv.row += 2; thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row), z, b->src_stride, &sse); - down = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + down = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (down < bestmse) { @@ -908,7 +908,7 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, break; } - diag = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + diag = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (diag < bestmse) { @@ -927,7 +927,7 @@ int vp9_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *bestmv, int_mv *ref_mv, int error_per_bit, const vp9_variance_fn_ptr_t *vfp, - DEC_MVCOSTS, + int *mvjcost, int *mvcost[2], int *distortion, unsigned int *sse1) { int bestmse = INT_MAX; @@ -964,14 +964,14 @@ int vp9_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, // calculate central point error bestmse = vfp->vf(y, y_stride, z, b->src_stride, sse1); *distortion = bestmse; - bestmse += mv_err_cost(bestmv, ref_mv, MVCOSTS, error_per_bit, + bestmse += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); // go left then right and check error this_mv.as_mv.row = startmv.as_mv.row; this_mv.as_mv.col = ((startmv.as_mv.col - 8) | 4); thismse = vfp->svf_halfpix_h(y - 1, y_stride, z, b->src_stride, &sse); - left = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + left = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (left < bestmse) { @@ -983,8 +983,8 @@ int vp9_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, this_mv.as_mv.col += 8; thismse = vfp->svf_halfpix_h(y, y_stride, z, b->src_stride, &sse); - right = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, - xd->allow_high_precision_mv); + right = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, + error_per_bit, xd->allow_high_precision_mv); if (right < bestmse) { *bestmv = this_mv; @@ -997,7 +997,7 @@ int vp9_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, this_mv.as_mv.col = startmv.as_mv.col; this_mv.as_mv.row = ((startmv.as_mv.row - 8) | 4); thismse = vfp->svf_halfpix_v(y - y_stride, y_stride, z, b->src_stride, &sse); - up = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + up = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (up < bestmse) { @@ -1009,7 +1009,7 @@ int vp9_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, this_mv.as_mv.row += 8; thismse = vfp->svf_halfpix_v(y, y_stride, z, b->src_stride, &sse); - down = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + down = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (down < bestmse) { @@ -1047,7 +1047,7 @@ int vp9_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, break; } - diag = thismse + mv_err_cost(&this_mv, ref_mv, MVCOSTS, error_per_bit, + diag = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit, xd->allow_high_precision_mv); if (diag < bestmse) { @@ -1081,7 +1081,8 @@ int vp9_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d, {\ if (thissad < bestsad)\ {\ - thissad += mvsad_err_cost(&this_mv, &fcenter_mv, MVSADCOSTS, sad_per_bit);\ + thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvjsadcost, mvsadcost, \ + sad_per_bit);\ if (thissad < bestsad)\ {\ bestsad = thissad;\ @@ -1109,8 +1110,8 @@ int vp9_hex_search int search_param, int sad_per_bit, const vp9_variance_fn_ptr_t *vfp, - DEC_MVSADCOSTS, - DEC_MVCOSTS, + int *mvjsadcost, int *mvsadcost[2], + int *mvjcost, int *mvcost[2], int_mv *center_mv ) { MV hex[6] = { { -1, -2}, {1, -2}, {2, 0}, {1, 2}, { -1, 2}, { -2, 0} }; @@ -1146,7 +1147,8 @@ int vp9_hex_search 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, MVSADCOSTS, sad_per_bit); + + mvsad_err_cost(&this_mv, &fcenter_mv, mvjsadcost, mvsadcost, + sad_per_bit); // hex search // j=0 @@ -1258,8 +1260,8 @@ cal_neighbors: int vp9_diamond_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int_mv *best_mv, int search_param, int sad_per_bit, int *num00, - vp9_variance_fn_ptr_t *fn_ptr, DEC_MVCOSTS, - int_mv *center_mv) { + vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, + int *mvcost[2], int_mv *center_mv) { int i, j, step; unsigned char *what = (*(b->base_src) + b->src); @@ -1304,7 +1306,8 @@ int vp9_diamond_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, // Check the starting position bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) - + mvsad_err_cost(best_mv, &fcenter_mv, MVSADCOSTS, sad_per_bit); + + mvsad_err_cost(best_mv, &fcenter_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. @@ -1330,7 +1333,7 @@ int vp9_diamond_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, this_mv.as_mv.row = this_row_offset; this_mv.as_mv.col = this_col_offset; thissad += mvsad_err_cost(&this_mv, &fcenter_mv, - MVSADCOSTS, sad_per_bit); + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1360,7 +1363,7 @@ int vp9_diamond_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad)) + - mv_err_cost(&this_mv, center_mv, MVCOSTS, x->errorperbit, + mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, xd->allow_high_precision_mv); } @@ -1368,7 +1371,7 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int_mv *best_mv, int search_param, int sad_per_bit, int *num00, vp9_variance_fn_ptr_t *fn_ptr, - DEC_MVCOSTS, int_mv *center_mv) { + int *mvjcost, int *mvcost[2], int_mv *center_mv) { int i, j, step; unsigned char *what = (*(b->base_src) + b->src); @@ -1415,7 +1418,8 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, // Check the starting position bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) - + mvsad_err_cost(best_mv, &fcenter_mv, MVSADCOSTS, sad_per_bit); + + mvsad_err_cost(best_mv, &fcenter_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. @@ -1451,7 +1455,7 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, 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, - MVSADCOSTS, sad_per_bit); + mvjsadcost, mvsadcost, sad_per_bit); if (sad_array[t] < bestsad) { bestsad = sad_array[t]; @@ -1475,7 +1479,7 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, this_mv.as_mv.row = this_row_offset; this_mv.as_mv.col = this_col_offset; thissad += mvsad_err_cost(&this_mv, &fcenter_mv, - MVSADCOSTS, sad_per_bit); + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1505,7 +1509,7 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad)) + - mv_err_cost(&this_mv, center_mv, MVCOSTS, x->errorperbit, + mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, xd->allow_high_precision_mv); } @@ -1521,7 +1525,8 @@ int vp9_full_pixel_diamond(VP9_COMP *cpi, MACROBLOCK *x, BLOCK *b, int thissme, n, num00; int bestsme = cpi->diamond_search_sad(x, b, d, mvp_full, &temp_mv, step_param, sadpb, &num00, - fn_ptr, XMVCOST, ref_mv); + fn_ptr, x->nmvjointcost, + x->mvcost, ref_mv); dst_mv->as_int = temp_mv.as_int; n = num00; @@ -1539,7 +1544,8 @@ int vp9_full_pixel_diamond(VP9_COMP *cpi, MACROBLOCK *x, BLOCK *b, else { thissme = cpi->diamond_search_sad(x, b, d, mvp_full, &temp_mv, step_param + n, sadpb, &num00, - fn_ptr, XMVCOST, ref_mv); + fn_ptr, x->nmvjointcost, x->mvcost, + ref_mv); /* check to see if refining search is needed. */ if (num00 > (further_steps - n)) @@ -1558,7 +1564,8 @@ int vp9_full_pixel_diamond(VP9_COMP *cpi, MACROBLOCK *x, BLOCK *b, int_mv best_mv; best_mv.as_int = dst_mv->as_int; thissme = cpi->refining_search_sad(x, b, d, &best_mv, sadpb, search_range, - fn_ptr, XMVCOST, ref_mv); + fn_ptr, x->nmvjointcost, x->mvcost, + ref_mv); if (thissme < bestsme) { bestsme = thissme; @@ -1570,7 +1577,8 @@ int vp9_full_pixel_diamond(VP9_COMP *cpi, MACROBLOCK *x, BLOCK *b, int vp9_full_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int sad_per_bit, int distance, - vp9_variance_fn_ptr_t *fn_ptr, DEC_MVCOSTS, + vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, + int *mvcost[2], int_mv *center_mv) { unsigned char *what = (*(b->base_src) + b->src); int what_stride = b->src_stride; @@ -1612,7 +1620,8 @@ int vp9_full_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, 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, MVSADCOSTS, sad_per_bit); + + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost, + sad_per_bit); // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border if (col_min < x->mv_col_min) @@ -1636,7 +1645,7 @@ int vp9_full_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, this_mv.as_mv.col = c; thissad += mvsad_err_cost(&this_mv, &fcenter_mv, - MVSADCOSTS, sad_per_bit); + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1656,7 +1665,7 @@ int vp9_full_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, (unsigned int *)(&thissad)) + - mv_err_cost(&this_mv, center_mv, MVCOSTS, x->errorperbit, + mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, xd->allow_high_precision_mv); else return INT_MAX; @@ -1664,8 +1673,8 @@ int vp9_full_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int vp9_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int sad_per_bit, int distance, - vp9_variance_fn_ptr_t *fn_ptr, DEC_MVCOSTS, - int_mv *center_mv) { + vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, + int *mvcost[2], int_mv *center_mv) { unsigned char *what = (*(b->base_src) + b->src); int what_stride = b->src_stride; unsigned char *in_what; @@ -1708,7 +1717,8 @@ int vp9_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, 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, MVSADCOSTS, sad_per_bit); + + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost, + sad_per_bit); // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border if (col_min < x->mv_col_min) @@ -1739,7 +1749,7 @@ int vp9_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, if (thissad < bestsad) { this_mv.as_mv.col = c; thissad += mvsad_err_cost(&this_mv, &fcenter_mv, - MVSADCOSTS, sad_per_bit); + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1760,7 +1770,7 @@ int vp9_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, if (thissad < bestsad) { this_mv.as_mv.col = c; thissad += mvsad_err_cost(&this_mv, &fcenter_mv, - MVSADCOSTS, sad_per_bit); + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1783,7 +1793,7 @@ int vp9_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, (unsigned int *)(&thissad)) + - mv_err_cost(&this_mv, center_mv, MVCOSTS, x->errorperbit, + mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, xd->allow_high_precision_mv); else return INT_MAX; @@ -1792,7 +1802,7 @@ int vp9_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int vp9_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int sad_per_bit, int distance, vp9_variance_fn_ptr_t *fn_ptr, - DEC_MVCOSTS, + int *mvjcost, int *mvcost[2], int_mv *center_mv) { unsigned char *what = (*(b->base_src) + b->src); int what_stride = b->src_stride; @@ -1837,7 +1847,8 @@ int vp9_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, 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, MVSADCOSTS, sad_per_bit); + + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost, + sad_per_bit); // Apply further limits to prevent us looking using vectors that stretch beyiond the UMV border if (col_min < x->mv_col_min) @@ -1868,7 +1879,7 @@ int vp9_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, if (thissad < bestsad) { this_mv.as_mv.col = c; thissad += mvsad_err_cost(&this_mv, &fcenter_mv, - MVSADCOSTS, sad_per_bit); + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1894,7 +1905,7 @@ int vp9_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, if (thissad < bestsad) { this_mv.as_mv.col = c; thissad += mvsad_err_cost(&this_mv, &fcenter_mv, - MVSADCOSTS, sad_per_bit); + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1915,7 +1926,7 @@ int vp9_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, if (thissad < bestsad) { this_mv.as_mv.col = c; thissad += mvsad_err_cost(&this_mv, &fcenter_mv, - MVSADCOSTS, sad_per_bit); + mvjsadcost, mvsadcost, sad_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -1937,7 +1948,7 @@ int vp9_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, (unsigned int *)(&thissad)) + - mv_err_cost(&this_mv, center_mv, MVCOSTS, x->errorperbit, + mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, xd->allow_high_precision_mv); else return INT_MAX; @@ -1945,7 +1956,7 @@ int vp9_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int vp9_refining_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int error_per_bit, int search_range, vp9_variance_fn_ptr_t *fn_ptr, - DEC_MVCOSTS, int_mv *center_mv) { + int *mvjcost, int *mvcost[2], int_mv *center_mv) { MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; int i, j; short this_row_offset, this_col_offset; @@ -1969,7 +1980,7 @@ int vp9_refining_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, 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, MVSADCOSTS, error_per_bit); + mvsad_err_cost(ref_mv, &fcenter_mv, mvjsadcost, mvsadcost, error_per_bit); for (i = 0; i < search_range; i++) { int best_site = -1; @@ -1986,7 +1997,8 @@ int vp9_refining_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, 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, MVSADCOSTS, error_per_bit); + thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvjsadcost, + mvsadcost, error_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -2012,7 +2024,7 @@ int vp9_refining_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad)) + - mv_err_cost(&this_mv, center_mv, MVCOSTS, x->errorperbit, + mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, xd->allow_high_precision_mv); else return INT_MAX; @@ -2021,7 +2033,7 @@ int vp9_refining_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int vp9_refining_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int error_per_bit, int search_range, vp9_variance_fn_ptr_t *fn_ptr, - DEC_MVCOSTS, int_mv *center_mv) { + int *mvjcost, int *mvcost[2], int_mv *center_mv) { MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; int i, j; short this_row_offset, this_col_offset; @@ -2045,7 +2057,7 @@ int vp9_refining_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, 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, MVSADCOSTS, error_per_bit); + mvsad_err_cost(ref_mv, &fcenter_mv, mvjsadcost, mvsadcost, error_per_bit); for (i = 0; i < search_range; i++) { int best_site = -1; @@ -2070,7 +2082,8 @@ int vp9_refining_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, 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, MVSADCOSTS, error_per_bit); + sad_array[j] += mvsad_err_cost(&this_mv, &fcenter_mv, mvjsadcost, + mvsadcost, error_per_bit); if (sad_array[j] < bestsad) { bestsad = sad_array[j]; @@ -2091,7 +2104,8 @@ int vp9_refining_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, 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, MVSADCOSTS, error_per_bit); + thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvjsadcost, + mvsadcost, error_per_bit); if (thissad < bestsad) { bestsad = thissad; @@ -2118,7 +2132,7 @@ int vp9_refining_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, return fn_ptr->vf(what, what_stride, best_address, in_what_stride, (unsigned int *)(&thissad)) + - mv_err_cost(&this_mv, center_mv, MVCOSTS, x->errorperbit, + mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, xd->allow_high_precision_mv); else return INT_MAX; diff --git a/vp9/encoder/mcomp.h b/vp9/encoder/mcomp.h index ac8c8ef..924ff21 100644 --- a/vp9/encoder/mcomp.h +++ b/vp9/encoder/mcomp.h @@ -15,13 +15,6 @@ #include "block.h" #include "variance.h" -#define MVCOSTS mvjcost, mvcost -#define MVSADCOSTS mvjsadcost, mvsadcost -#define DEC_MVCOSTS int *mvjcost, int *mvcost[2] -#define DEC_MVSADCOSTS int *mvjsadcost, int *mvsadcost[2] -#define NULLMVCOST NULL, NULL -#define XMVCOST x->nmvjointcost, (x->e_mbd.allow_high_precision_mv?x->nmvcost_hp:x->nmvcost) - #ifdef ENTROPY_STATS extern void init_mv_ref_counts(); extern void accum_mv_refs(MB_PREDICTION_MODE, const int near_mv_ref_cts[4]); @@ -33,8 +26,8 @@ extern void accum_mv_refs(MB_PREDICTION_MODE, const int near_mv_ref_cts[4]); #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1)) // Maximum size of the first step in full pel units extern void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv); -extern int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, DEC_MVCOSTS, - int Weight, int ishp); +extern int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvjcost, + int *mvcost[2], int Weight, int ishp); extern void vp9_init_dsmotion_compensation(MACROBLOCK *x, int stride); extern void vp9_init3smotion_compensation(MACROBLOCK *x, int stride); // Runs sequence of diamond searches in smaller steps for RD @@ -55,15 +48,14 @@ extern int vp9_hex_search int search_param, int error_per_bit, const vp9_variance_fn_ptr_t *vf, - DEC_MVSADCOSTS, - DEC_MVCOSTS, + int *mvjsadcost, int *mvsadcost[2], + int *mvjcost, int *mvcost[2], int_mv *center_mv ); -typedef int (fractional_mv_step_fp) -(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *bestmv, int_mv *ref_mv, - int error_per_bit, const vp9_variance_fn_ptr_t *vfp, DEC_MVCOSTS, - int *distortion, unsigned int *sse); +typedef int (fractional_mv_step_fp) (MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv + *bestmv, int_mv *ref_mv, int error_per_bit, const vp9_variance_fn_ptr_t *vfp, + int *mvjcost, int *mvcost[2], int *distortion, unsigned int *sse); extern fractional_mv_step_fp vp9_find_best_sub_pixel_step_iteratively; extern fractional_mv_step_fp vp9_find_best_sub_pixel_step; extern fractional_mv_step_fp vp9_find_best_half_pixel_step; @@ -71,20 +63,23 @@ extern fractional_mv_step_fp vp9_find_best_half_pixel_step; typedef int (*vp9_full_search_fn_t)(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int sad_per_bit, int distance, vp9_variance_fn_ptr_t *fn_ptr, - DEC_MVCOSTS, int_mv *center_mv); + int *mvjcost, int *mvcost[2], + int_mv *center_mv); typedef int (*vp9_refining_search_fn_t)(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int sad_per_bit, int distance, vp9_variance_fn_ptr_t *fn_ptr, - DEC_MVCOSTS, int_mv *center_mv); + int *mvjcost, int *mvcost[2], + int_mv *center_mv); typedef int (*vp9_diamond_search_fn_t)(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv, int_mv *best_mv, int search_param, int sad_per_bit, int *num00, vp9_variance_fn_ptr_t *fn_ptr, - DEC_MVCOSTS, int_mv *center_mv); + int *mvjcost, int *mvcost[2], + int_mv *center_mv); #if CONFIG_RUNTIME_CPU_DETECT diff --git a/vp9/encoder/onyx_if.c b/vp9/encoder/onyx_if.c index bd8e6d4..88ec5ec 100644 --- a/vp9/encoder/onyx_if.c +++ b/vp9/encoder/onyx_if.c @@ -222,7 +222,16 @@ static void init_minq_luts(void) { } } +static void set_mvcost(MACROBLOCK *mb) { + if (mb->e_mbd.allow_high_precision_mv) { + mb->mvcost = mb->nmvcost_hp; + mb->mvsadcost = mb->nmvsadcost_hp; + } else { + mb->mvcost = mb->nmvcost; + mb->mvsadcost = mb->nmvsadcost; + } +} static void init_base_skip_probs(void) { int i; double q; @@ -1518,6 +1527,7 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) { setup_features(cpi); cpi->mb.e_mbd.allow_high_precision_mv = 0; // Default mv precision adaptation + set_mvcost(&cpi->mb); { int i; @@ -3122,6 +3132,7 @@ static void encode_frame_to_data_rate } /* TODO: Decide this more intelligently */ xd->allow_high_precision_mv = (Q < HIGH_PRECISION_MV_QTHRESH); + set_mvcost(&cpi->mb); } #if CONFIG_POSTPROC @@ -4028,6 +4039,8 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, cpi->source = NULL; cpi->mb.e_mbd.allow_high_precision_mv = ALTREF_HIGH_PRECISION_MV; + set_mvcost(&cpi->mb); + // Should we code an alternate reference frame if (cpi->oxcf.play_alternate && cpi->source_alt_ref_pending) { diff --git a/vp9/encoder/rdopt.c b/vp9/encoder/rdopt.c index 19b96af..641f533 100644 --- a/vp9/encoder/rdopt.c +++ b/vp9/encoder/rdopt.c @@ -1912,7 +1912,7 @@ static int labels2mode( int_mv seg_mvs[MAX_REF_FRAMES - 1], int_mv *best_ref_mv, int_mv *second_best_ref_mv, - DEC_MVCOSTS) { + int *mvjcost, int *mvcost[2]) { MACROBLOCKD *const xd = &x->e_mbd; MODE_INFO *const mic = xd->mode_info_context; MB_MODE_INFO * mbmi = &mic->mbmi; @@ -1947,11 +1947,11 @@ static int labels2mode( seg_mvs[mbmi->second_ref_frame - 1].as_int; } - thismvcost = vp9_mv_bit_cost(this_mv, best_ref_mv, MVCOSTS, + thismvcost = vp9_mv_bit_cost(this_mv, best_ref_mv, mvjcost, mvcost, 102, xd->allow_high_precision_mv); if (mbmi->second_ref_frame) { thismvcost += vp9_mv_bit_cost(this_second_mv, second_best_ref_mv, - MVCOSTS, 102, + mvjcost, mvcost, 102, xd->allow_high_precision_mv); } break; @@ -2318,7 +2318,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, thissme = cpi->full_search_sad(x, c, e, &mvp_full, sadpb, 16, v_fn_ptr, - XMVCOST, bsi->ref_mv); + x->nmvjointcost, x->mvcost, + bsi->ref_mv); if (thissme < bestsme) { bestsme = thissme; @@ -2336,7 +2337,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, unsigned int sse; cpi->find_fractional_mv_step(x, c, e, &mode_mv[NEW4X4], bsi->ref_mv, x->errorperbit, v_fn_ptr, - XMVCOST, &distortion, &sse); + x->nmvjointcost, x->mvcost, + &distortion, &sse); // safe motion search result for use in compound prediction seg_mvs[i][mbmi->ref_frame - 1].as_int = mode_mv[NEW4X4].as_int; @@ -2353,7 +2355,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, rate = labels2mode(x, labels, i, this_mode, &mode_mv[this_mode], &second_mode_mv[this_mode], seg_mvs[i], - bsi->ref_mv, bsi->second_ref_mv, XMVCOST); + bsi->ref_mv, bsi->second_ref_mv, x->nmvjointcost, + x->mvcost); // Trap vectors that reach beyond the UMV borders if (((mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) || @@ -2411,7 +2414,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, labels2mode(x, labels, i, mode_selected, &mode_mv[mode_selected], &second_mode_mv[mode_selected], seg_mvs[i], - bsi->ref_mv, bsi->second_ref_mv, XMVCOST); + bsi->ref_mv, bsi->second_ref_mv, x->nmvjointcost, x->mvcost); br += sbr; bd += sbd; @@ -3244,11 +3247,11 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, return INT64_MAX; *rate2 += vp9_mv_bit_cost(&frame_mv[NEWMV][refs[0]], &frame_best_ref_mv[refs[0]], - XMVCOST, 96, + x->nmvjointcost, x->mvcost, 96, x->e_mbd.allow_high_precision_mv); *rate2 += vp9_mv_bit_cost(&frame_mv[NEWMV][refs[1]], &frame_best_ref_mv[refs[1]], - XMVCOST, 96, + x->nmvjointcost, x->mvcost, 96, x->e_mbd.allow_high_precision_mv); } else { int bestsme = INT_MAX; @@ -3300,14 +3303,16 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, &frame_best_ref_mv[refs[0]], x->errorperbit, &cpi->fn_ptr[block_size], - XMVCOST, &dis, &sse); + x->nmvjointcost, x->mvcost, + &dis, &sse); } d->bmi.as_mv.first.as_int = tmp_mv.as_int; frame_mv[NEWMV][refs[0]].as_int = d->bmi.as_mv.first.as_int; // Add the new motion vector cost to our rolling cost variable *rate2 += vp9_mv_bit_cost(&tmp_mv, &frame_best_ref_mv[refs[0]], - XMVCOST, 96, xd->allow_high_precision_mv); + x->nmvjointcost, x->mvcost, + 96, xd->allow_high_precision_mv); } break; case NEARESTMV: diff --git a/vp9/encoder/temporal_filter.c b/vp9/encoder/temporal_filter.c index c2657e9..e2695de 100644 --- a/vp9/encoder/temporal_filter.c +++ b/vp9/encoder/temporal_filter.c @@ -185,7 +185,7 @@ static int temporal_filter_find_matching_mb_c // Ignore mv costing by sending NULL pointer instead of cost arrays bestsme = vp9_hex_search(x, b, d, &best_ref_mv1_full, &d->bmi.as_mv.first, step_param, sadpb, &cpi->fn_ptr[BLOCK_16X16], - NULLMVCOST, NULLMVCOST, + NULL, NULL, NULL, NULL, &best_ref_mv1); #if ALT_REF_SUBPEL_ENABLED @@ -199,7 +199,7 @@ static int temporal_filter_find_matching_mb_c &best_ref_mv1, x->errorperbit, &cpi->fn_ptr[BLOCK_16X16], - NULLMVCOST, + NULL, NULL, &distortion, &sse); } #endif -- 2.7.4