shithub: libvpx

Download patch

ref: a77df0c473dcaddd5e1b7c80ef08510fed185965
parent: 16e268668204566d7f4b2d4fc6775f996773d74d
parent: a0993703702ba1c1af9d4c04debe3f040f18a98d
author: Ronald S. Bultje <rbultje@google.com>
date: Wed Nov 14 10:43:19 EST 2012

Merge "Prevent overflow in variance32x32." into experimental

--- a/vp9/encoder/variance_c.c
+++ b/vp9/encoder/variance_c.c
@@ -12,8 +12,8 @@
 #include "variance.h"
 #include "vp9/common/filter.h"
 #include "vp9/common/subpelvar.h"
+#include "vpx/vpx_integer.h"
 
-
 unsigned int vp9_get_mb_ss_c(const short *src_ptr) {
   unsigned int i, sum = 0;
 
@@ -37,8 +37,7 @@
 
   variance(src_ptr, source_stride, ref_ptr, recon_stride, 32, 32, &var, &avg);
   *sse = var;
-  // TODO(rbultje): in extreme cases these products will rollover.
-  return (var - (((unsigned int)avg * avg) >> 10));
+  return (var - (((int64_t)avg * avg) >> 10));
 }
 #endif