提交 7499a15c 编写于 作者: X Xinguang Bian

fix data overflow problem in GaussianBlur

上级 5f4e55bc
......@@ -1236,8 +1236,12 @@ void hlineSmoothONa_yzy_a<uint16_t, ufixedpoint32>(const uint16_t* src, int cn,
v_mul_expand(vx_load(src + pre_shift * cn), vx_setall_u16((uint16_t) *((uint32_t*)(m + pre_shift))), v_res0, v_res1);
for (int j = 0; j < pre_shift; j ++)
{
v_uint16 v_weight = vx_setall_u16((uint16_t) *((uint32_t*)(m + j)));
v_uint32 v_add0, v_add1;
v_mul_expand(vx_load(src + j * cn) + vx_load(src + (n - 1 - j)*cn), vx_setall_u16((uint16_t) *((uint32_t*)(m + j))), v_add0, v_add1);
v_mul_expand(vx_load(src + j * cn), v_weight, v_add0, v_add1);
v_res0 += v_add0;
v_res1 += v_add1;
v_mul_expand(vx_load(src + (n - 1 - j)*cn), v_weight, v_add0, v_add1);
v_res0 += v_add0;
v_res1 += v_add1;
}
......
......@@ -220,6 +220,15 @@ TEST(GaussianBlur_Bitexact, regression_15015)
ASSERT_EQ(0.0, cvtest::norm(dst, src, NORM_INF));
}
TEST(GaussianBlur_Bitexact, overflow_20121)
{
Mat src(100, 100, CV_16UC1, Scalar(65535));
Mat dst;
GaussianBlur(src, dst, cv::Size(9, 9), 0.0);
double min_val;
minMaxLoc(dst, &min_val);
ASSERT_EQ(cvRound(min_val), 65535);
}
static void checkGaussianBlur_8Uvs32F(const Mat& src8u, const Mat& src32f, int N, double sigma)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册