Fix some interger overflow errors

Change-Id: I7e44bd952f28ce9925e8bdf6ee8ca2bb13de1b49
This commit is contained in:
hui su 2016-02-02 13:50:26 -08:00
Родитель 614f0727e4
Коммит 1c9b0918b3
2 изменённых файлов: 13 добавлений и 12 удалений

Просмотреть файл

@ -153,10 +153,10 @@ void vp9_init3smotion_compensation(search_site_config *cfg, int stride) {
*/ */
/* estimated cost of a motion vector (r,c) */ /* estimated cost of a motion vector (r,c) */
#define MVC(r, c) \ #define MVC(r, c) \
(mvcost ? \ (mvcost ? \
((mvjcost[((r) != rr) * 2 + ((c) != rc)] + \ ((unsigned)(mvjcost[((r) != rr) * 2 + ((c) != rc)] + \
mvcost[0][((r) - rr)] + mvcost[1][((c) - rc)]) * \ mvcost[0][((r) - rr)] + mvcost[1][((c) - rc)]) * \
error_per_bit + 4096) >> 13 : 0) error_per_bit + 4096) >> 13 : 0)
@ -849,9 +849,9 @@ static INLINE void calc_int_cost_list(const MACROBLOCK *x,
cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride, cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride,
get_buf_from_mv(in_what, &this_mv), get_buf_from_mv(in_what, &this_mv),
in_what->stride, &sse) + in_what->stride, &sse) +
// mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb); mv_err_cost(&this_mv, &fcenter_mv,
mv_err_cost(&this_mv, &fcenter_mv, x->nmvjointcost, x->mvcost, x->nmvjointcost, x->mvcost,
x->errorperbit); x->errorperbit);
} }
} else { } else {
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
@ -863,9 +863,9 @@ static INLINE void calc_int_cost_list(const MACROBLOCK *x,
cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride, cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride,
get_buf_from_mv(in_what, &this_mv), get_buf_from_mv(in_what, &this_mv),
in_what->stride, &sse) + in_what->stride, &sse) +
// mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb); mv_err_cost(&this_mv, &fcenter_mv,
mv_err_cost(&this_mv, &fcenter_mv, x->nmvjointcost, x->mvcost, x->nmvjointcost, x->mvcost,
x->errorperbit); x->errorperbit);
} }
} }
} }

Просмотреть файл

@ -50,8 +50,9 @@ static int mvsad_err_cost(const MACROBLOCK *x, const int_mv mv, const MV *ref,
int error_per_bit) { int error_per_bit) {
const int_mv diff = pack_int_mv(mv.as_mv.row - ref->row, const int_mv diff = pack_int_mv(mv.as_mv.row - ref->row,
mv.as_mv.col - ref->col); mv.as_mv.col - ref->col);
return ROUND_POWER_OF_TWO(mv_cost(diff, x->nmvjointsadcost, return ROUND_POWER_OF_TWO((unsigned)mv_cost(diff, x->nmvjointsadcost,
x->nmvsadcost) * error_per_bit, 8); x->nmvsadcost) *
error_per_bit, 8);
} }
/***************************************************************************** /*****************************************************************************