]> granicus.if.org Git - libvpx/commitdiff
Fix a signed overflow in vp9 motion cost.
authorAlex Converse <aconverse@google.com>
Mon, 1 Feb 2016 17:47:39 +0000 (09:47 -0800)
committerAlex Converse <aconverse@google.com>
Mon, 1 Feb 2016 22:27:32 +0000 (14:27 -0800)
Change-Id: I5975e3aede62202d8ee6ced33889350c0a56554a

vp9/encoder/vp9_mcomp.c

index 84ef1b43e22849bab581ff466b9f89a142a89aef..4004dd3db55396e3c27e3da24999bb28f355fa45 100644 (file)
@@ -86,7 +86,9 @@ static int mv_err_cost(const MV *mv, const MV *ref,
   if (mvcost) {
     const MV diff = { mv->row - ref->row,
                       mv->col - ref->col };
-    return ROUND_POWER_OF_TWO(mv_cost(&diff, mvjcost, mvcost) *
+    // TODO(aconverse): See if this shift needs to be tied to
+    // VP9_PROB_COST_SHIFT.
+    return ROUND_POWER_OF_TWO((unsigned)mv_cost(&diff, mvjcost, mvcost) *
                                   error_per_bit, 13);
   }
   return 0;
@@ -96,8 +98,9 @@ static int mvsad_err_cost(const MACROBLOCK *x, const MV *mv, const MV *ref,
                           int error_per_bit) {
   const MV diff = { mv->row - ref->row,
                     mv->col - ref->col };
-  return ROUND_POWER_OF_TWO(mv_cost(&diff, x->nmvjointsadcost,
-                                    x->nmvsadcost) * error_per_bit, 8);
+  // TODO(aconverse): See if this shift needs to be tied to VP9_PROB_COST_SHIFT.
+  return ROUND_POWER_OF_TWO((unsigned)mv_cost(&diff, x->nmvjointsadcost,
+                                      x->nmvsadcost) * error_per_bit, 8);
 }
 
 void vp9_init_dsmotion_compensation(search_site_config *cfg, int stride) {