Commit f22b828d authored by Yunqing Wang's avatar Yunqing Wang

Fix an integer overflow in vp9_mcomp.c

The MV unit test revealed an integer overflow issue in vp9_mcomp.c.
This was caused if the MV was very large. In mv_err_cost(), when
mv->row = 8184, mv->col = 8184 and ref_mv is 0, mv_cost = 34363
and error_per_bit = 132412, causing the overflow.


Change-Id: I35f8299f22f9bee39cd9153d7b00d0993838845e
parent 2420f443
......@@ -101,10 +101,8 @@ static int mv_err_cost(const MV *mv, const MV *ref, const int *mvjcost,
int *mvcost[2], int error_per_bit) {
if (mvcost) {
const MV diff = { mv->row - ref->row, mv->col - ref->col };
// This product sits at a 32-bit ceiling right now and any additional
// accuracy in either bit cost or error cost will cause it to overflow.
(unsigned)mv_cost(&diff, mvjcost, mvcost) * error_per_bit,
return (int)ROUND64_POWER_OF_TWO(
(int64_t)mv_cost(&diff, mvjcost, mvcost) * error_per_bit,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment