Adjust types in hbd error computation to avoid overflow

Change-Id: I8e08ebc8cbb2d1a1f97c8ef0c9237d8dfe0df208
This commit is contained in:
Sarah Parker 2016-09-06 16:15:07 -07:00
Родитель 497f27ed9d
Коммит ca92da752b
1 изменённых файлов: 3 добавлений и 3 удалений

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

@ -477,7 +477,7 @@ static double highbd_warp_erroradv(WarpedMotionParams *wm, uint8_t *ref8,
uint16_t *dst = CONVERT_TO_SHORTPTR(dst8); uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
uint16_t *ref = CONVERT_TO_SHORTPTR(ref8); uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
int gm_err = 0, no_gm_err = 0; int gm_err = 0, no_gm_err = 0;
int gm_sumerr = 0, no_gm_sumerr = 0; int64_t gm_sumerr = 0, no_gm_sumerr = 0;
for (i = p_row; i < p_row + p_height; ++i) { for (i = p_row; i < p_row + p_height; ++i) {
for (j = p_col; j < p_col + p_width; ++j) { for (j = p_col; j < p_col + p_width; ++j) {
int in[2], out[2]; int in[2], out[2];
@ -492,8 +492,8 @@ static double highbd_warp_erroradv(WarpedMotionParams *wm, uint8_t *ref8,
stride, bd); stride, bd);
no_gm_err = dst[(j - p_col) + (i - p_row) * p_stride] - no_gm_err = dst[(j - p_col) + (i - p_row) * p_stride] -
ref[(j - p_col) + (i - p_row) * stride]; ref[(j - p_col) + (i - p_row) * stride];
gm_sumerr += gm_err * gm_err; gm_sumerr += (int64_t)gm_err * gm_err;
no_gm_sumerr += no_gm_err * no_gm_err; no_gm_sumerr += (int64_t)no_gm_err * no_gm_err;
} }
} }
return (double)gm_sumerr / no_gm_sumerr; return (double)gm_sumerr / no_gm_sumerr;