diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index e0e0c2afcbc0aa9c9301b6b3f11bd056cc1c3c7e..0600de2e49204ebbf10916b72811ca8ba2049fa6 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -602,7 +602,7 @@ static int block_error(int16_t *coeff, int16_t *dqcoeff,
 
   for (i = 0; i < block_size; i++) {
     int this_diff = coeff[i] - dqcoeff[i];
-    error += this_diff * this_diff;
+    error += (unsigned)this_diff * this_diff;
   }
   error >>= shift;