diff --git a/vp9/common/vp9_treecoder.h b/vp9/common/vp9_treecoder.h index edf5dc797dca99d662499251dab62441d1a9bb56..ebcd4116f8c05159302024b151ce4607ffb445c7 100644 --- a/vp9/common/vp9_treecoder.h +++ b/vp9/common/vp9_treecoder.h @@ -13,6 +13,7 @@ #include "./vpx_config.h" #include "vpx/vpx_integer.h" +#include "vp9/common/vp9_common.h" typedef uint8_t vp9_prob; @@ -75,7 +76,7 @@ static INLINE vp9_prob get_binary_prob(int n0, int n1) { /* this function assumes prob1 and prob2 are already within [1,255] range */ static INLINE vp9_prob weighted_prob(int prob1, int prob2, int factor) { - return (prob1 * (256 - factor) + prob2 * factor + 128) >> 8; + return ROUND_POWER_OF_TWO(prob1 * (256 - factor) + prob2 * factor, 8); } #endif // VP9_COMMON_VP9_TREECODER_H_ diff --git a/vp9/encoder/vp9_encodemv.c b/vp9/encoder/vp9_encodemv.c index 9431f078105cb56aa11ae60ccbf633e03f6b7257..918a0bd7dd6eef91ce821ce926745f2582ba5911 100644 --- a/vp9/encoder/vp9_encodemv.c +++ b/vp9/encoder/vp9_encodemv.c @@ -603,59 +603,33 @@ void vp9_update_nmv_count(VP9_COMP *cpi, MACROBLOCK *x, if (mbmi->mode == SPLITMV) { int i; - - for (i = 0; i < x->partition_info->count; i++) { - if (x->partition_info->bmi[i].mode == NEW4X4) { - if (x->e_mbd.allow_high_precision_mv) { - mv.row = (x->partition_info->bmi[i].mv.as_mv.row - - best_ref_mv->as_mv.row); - mv.col = (x->partition_info->bmi[i].mv.as_mv.col - - best_ref_mv->as_mv.col); - vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 1); - if (x->e_mbd.mode_info_context->mbmi.second_ref_frame > 0) { - mv.row = (x->partition_info->bmi[i].second_mv.as_mv.row - - second_best_ref_mv->as_mv.row); - mv.col = (x->partition_info->bmi[i].second_mv.as_mv.col - - second_best_ref_mv->as_mv.col); - vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv, - &cpi->NMVcount, 1); - } - } else { - mv.row = (x->partition_info->bmi[i].mv.as_mv.row - - best_ref_mv->as_mv.row); - mv.col = (x->partition_info->bmi[i].mv.as_mv.col - - best_ref_mv->as_mv.col); - vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 0); - if (x->e_mbd.mode_info_context->mbmi.second_ref_frame > 0) { - mv.row = (x->partition_info->bmi[i].second_mv.as_mv.row - - second_best_ref_mv->as_mv.row); - mv.col = (x->partition_info->bmi[i].second_mv.as_mv.col - - second_best_ref_mv->as_mv.col); - vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv, - &cpi->NMVcount, 0); - } + PARTITION_INFO *pi = x->partition_info; + for (i = 0; i < pi->count; i++) { + if (pi->bmi[i].mode == NEW4X4) { + mv.row = (pi->bmi[i].mv.as_mv.row - best_ref_mv->as_mv.row); + mv.col = (pi->bmi[i].mv.as_mv.col - best_ref_mv->as_mv.col); + vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, + x->e_mbd.allow_high_precision_mv); + if (x->e_mbd.mode_info_context->mbmi.second_ref_frame > 0) { + mv.row = pi->bmi[i].second_mv.as_mv.row - + second_best_ref_mv->as_mv.row; + mv.col = pi->bmi[i].second_mv.as_mv.col - + second_best_ref_mv->as_mv.col; + vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv, &cpi->NMVcount, + x->e_mbd.allow_high_precision_mv); } } } } else if (mbmi->mode == NEWMV) { - if (x->e_mbd.allow_high_precision_mv) { - mv.row = (mbmi->mv[0].as_mv.row - best_ref_mv->as_mv.row); - mv.col = (mbmi->mv[0].as_mv.col - best_ref_mv->as_mv.col); - vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 1); - if (mbmi->second_ref_frame > 0) { - mv.row = (mbmi->mv[1].as_mv.row - second_best_ref_mv->as_mv.row); - mv.col = (mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col); - vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv, &cpi->NMVcount, 1); - } - } else { - mv.row = (mbmi->mv[0].as_mv.row - best_ref_mv->as_mv.row); - mv.col = (mbmi->mv[0].as_mv.col - best_ref_mv->as_mv.col); - vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 0); - if (mbmi->second_ref_frame > 0) { - mv.row = (mbmi->mv[1].as_mv.row - second_best_ref_mv->as_mv.row); - mv.col = (mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col); - vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv, &cpi->NMVcount, 0); - } + mv.row = (mbmi->mv[0].as_mv.row - best_ref_mv->as_mv.row); + mv.col = (mbmi->mv[0].as_mv.col - best_ref_mv->as_mv.col); + vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, + x->e_mbd.allow_high_precision_mv); + if (mbmi->second_ref_frame > 0) { + mv.row = (mbmi->mv[1].as_mv.row - second_best_ref_mv->as_mv.row); + mv.col = (mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col); + vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv, &cpi->NMVcount, + x->e_mbd.allow_high_precision_mv); } } } diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index e642b7487b3218a39a2e180e5c9999b5f8bfdbd6..1649ccade648dc3d7fed1ebd7e8069dd5d601761 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -79,9 +79,10 @@ static int mvsad_err_cost(int_mv *mv, int_mv *ref, int *mvjsadcost, MV v; v.row = mv->as_mv.row - ref->as_mv.row; v.col = mv->as_mv.col - ref->as_mv.col; - return ((mvjsadcost[vp9_get_mv_joint(v)] + - mvsadcost[0][v.row] + mvsadcost[1][v.col]) * - error_per_bit + 128) >> 8; + + return ROUND_POWER_OF_TWO((mvjsadcost[vp9_get_mv_joint(v)] + + mvsadcost[0][v.row] + mvsadcost[1][v.col]) * + error_per_bit, 8); } return 0; }