mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 21:20:18 +08:00
fix data overflow problem in GaussianBlur
This commit is contained in:
parent
5f4e55bc68
commit
7499a15c92
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user