Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
1c0b9469
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1c0b9469
编写于
9月 22, 2014
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3248 from ilya-lavrenov:arm_sum
上级
48892016
27b933ba
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
173 addition
and
6 deletion
+173
-6
modules/core/src/stat.cpp
modules/core/src/stat.cpp
+173
-6
未找到文件。
modules/core/src/stat.cpp
浏览文件 @
1c0b9469
...
...
@@ -63,14 +63,181 @@ template<typename T> static inline Scalar rawToScalar(const T& v)
* sum *
\****************************************************************************************/
template
<
typename
T
,
typename
ST
>
struct
Sum_SIMD
{
int
operator
()
(
const
T
*
,
const
uchar
*
,
ST
*
,
int
,
int
)
const
{
return
0
;
}
};
#if CV_NEON
template
<
>
struct
Sum_SIMD
<
uchar
,
int
>
{
int
operator
()
(
const
uchar
*
src0
,
const
uchar
*
mask
,
int
*
dst
,
int
len
,
int
cn
)
const
{
if
(
mask
||
(
cn
!=
1
&&
cn
!=
2
&&
cn
!=
4
))
return
0
;
int
x
=
0
;
uint32x4_t
v_sum
=
vdupq_n_u32
(
0u
);
for
(
;
x
<=
len
-
16
;
x
+=
16
)
{
uint8x16_t
v_src
=
vld1q_u8
(
src0
+
x
);
uint16x8_t
v_half
=
vmovl_u8
(
vget_low_u8
(
v_src
));
v_sum
=
vaddq_u32
(
v_sum
,
vmovl_u16
(
vget_low_u16
(
v_half
)));
v_sum
=
vaddq_u32
(
v_sum
,
vmovl_u16
(
vget_high_u16
(
v_half
)));
v_half
=
vmovl_u8
(
vget_high_u8
(
v_src
));
v_sum
=
vaddq_u32
(
v_sum
,
vmovl_u16
(
vget_low_u16
(
v_half
)));
v_sum
=
vaddq_u32
(
v_sum
,
vmovl_u16
(
vget_high_u16
(
v_half
)));
}
for
(
;
x
<=
len
-
8
;
x
+=
8
)
{
uint16x8_t
v_src
=
vmovl_u8
(
vld1_u8
(
src0
+
x
));
v_sum
=
vaddq_u32
(
v_sum
,
vmovl_u16
(
vget_low_u16
(
v_src
)));
v_sum
=
vaddq_u32
(
v_sum
,
vmovl_u16
(
vget_high_u16
(
v_src
)));
}
unsigned
int
CV_DECL_ALIGNED
(
16
)
ar
[
4
];
vst1q_u32
(
ar
,
v_sum
);
for
(
int
i
=
0
;
i
<
4
;
i
+=
cn
)
for
(
int
j
=
0
;
j
<
cn
;
++
j
)
dst
[
j
]
+=
ar
[
j
+
i
];
return
x
/
cn
;
}
};
template
<
>
struct
Sum_SIMD
<
schar
,
int
>
{
int
operator
()
(
const
schar
*
src0
,
const
uchar
*
mask
,
int
*
dst
,
int
len
,
int
cn
)
const
{
if
(
mask
||
(
cn
!=
1
&&
cn
!=
2
&&
cn
!=
4
))
return
0
;
int
x
=
0
;
int32x4_t
v_sum
=
vdupq_n_s32
(
0
);
for
(
;
x
<=
len
-
16
;
x
+=
16
)
{
int8x16_t
v_src
=
vld1q_s8
(
src0
+
x
);
int16x8_t
v_half
=
vmovl_s8
(
vget_low_s8
(
v_src
));
v_sum
=
vaddq_s32
(
v_sum
,
vmovl_s16
(
vget_low_s16
(
v_half
)));
v_sum
=
vaddq_s32
(
v_sum
,
vmovl_s16
(
vget_high_s16
(
v_half
)));
v_half
=
vmovl_s8
(
vget_high_s8
(
v_src
));
v_sum
=
vaddq_s32
(
v_sum
,
vmovl_s16
(
vget_low_s16
(
v_half
)));
v_sum
=
vaddq_s32
(
v_sum
,
vmovl_s16
(
vget_high_s16
(
v_half
)));
}
for
(
;
x
<=
len
-
8
;
x
+=
8
)
{
int16x8_t
v_src
=
vmovl_s8
(
vld1_s8
(
src0
+
x
));
v_sum
=
vaddq_s32
(
v_sum
,
vmovl_s16
(
vget_low_s16
(
v_src
)));
v_sum
=
vaddq_s32
(
v_sum
,
vmovl_s16
(
vget_high_s16
(
v_src
)));
}
int
CV_DECL_ALIGNED
(
16
)
ar
[
4
];
vst1q_s32
(
ar
,
v_sum
);
for
(
int
i
=
0
;
i
<
4
;
i
+=
cn
)
for
(
int
j
=
0
;
j
<
cn
;
++
j
)
dst
[
j
]
+=
ar
[
j
+
i
];
return
x
/
cn
;
}
};
template
<
>
struct
Sum_SIMD
<
ushort
,
int
>
{
int
operator
()
(
const
ushort
*
src0
,
const
uchar
*
mask
,
int
*
dst
,
int
len
,
int
cn
)
const
{
if
(
mask
||
(
cn
!=
1
&&
cn
!=
2
&&
cn
!=
4
))
return
0
;
int
x
=
0
;
uint32x4_t
v_sum
=
vdupq_n_u32
(
0u
);
for
(
;
x
<=
len
-
8
;
x
+=
8
)
{
uint16x8_t
v_src
=
vld1q_u16
(
src0
+
x
);
v_sum
=
vaddq_u32
(
v_sum
,
vmovl_u16
(
vget_low_u16
(
v_src
)));
v_sum
=
vaddq_u32
(
v_sum
,
vmovl_u16
(
vget_high_u16
(
v_src
)));
}
for
(
;
x
<=
len
-
4
;
x
+=
4
)
v_sum
=
vaddq_u32
(
v_sum
,
vmovl_u16
(
vld1_u16
(
src0
+
x
)));
unsigned
int
CV_DECL_ALIGNED
(
16
)
ar
[
4
];
vst1q_u32
(
ar
,
v_sum
);
for
(
int
i
=
0
;
i
<
4
;
i
+=
cn
)
for
(
int
j
=
0
;
j
<
cn
;
++
j
)
dst
[
j
]
+=
ar
[
j
+
i
];
return
x
/
cn
;
}
};
template
<
>
struct
Sum_SIMD
<
short
,
int
>
{
int
operator
()
(
const
short
*
src0
,
const
uchar
*
mask
,
int
*
dst
,
int
len
,
int
cn
)
const
{
if
(
mask
||
(
cn
!=
1
&&
cn
!=
2
&&
cn
!=
4
))
return
0
;
int
x
=
0
;
int32x4_t
v_sum
=
vdupq_n_s32
(
0u
);
for
(
;
x
<=
len
-
8
;
x
+=
8
)
{
int16x8_t
v_src
=
vld1q_s16
(
src0
+
x
);
v_sum
=
vaddq_s32
(
v_sum
,
vmovl_s16
(
vget_low_s16
(
v_src
)));
v_sum
=
vaddq_s32
(
v_sum
,
vmovl_s16
(
vget_high_s16
(
v_src
)));
}
for
(
;
x
<=
len
-
4
;
x
+=
4
)
v_sum
=
vaddq_s32
(
v_sum
,
vmovl_s16
(
vld1_s16
(
src0
+
x
)));
int
CV_DECL_ALIGNED
(
16
)
ar
[
4
];
vst1q_s32
(
ar
,
v_sum
);
for
(
int
i
=
0
;
i
<
4
;
i
+=
cn
)
for
(
int
j
=
0
;
j
<
cn
;
++
j
)
dst
[
j
]
+=
ar
[
j
+
i
];
return
x
/
cn
;
}
};
#endif
template
<
typename
T
,
typename
ST
>
static
int
sum_
(
const
T
*
src0
,
const
uchar
*
mask
,
ST
*
dst
,
int
len
,
int
cn
)
{
const
T
*
src
=
src0
;
if
(
!
mask
)
{
int
i
=
0
;
int
k
=
cn
%
4
;
Sum_SIMD
<
T
,
ST
>
vop
;
int
i
=
vop
(
src0
,
mask
,
dst
,
len
,
cn
),
k
=
cn
%
4
;
src
+=
i
*
cn
;
if
(
k
==
1
)
{
ST
s0
=
dst
[
0
];
...
...
@@ -86,7 +253,7 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn )
else
if
(
k
==
2
)
{
ST
s0
=
dst
[
0
],
s1
=
dst
[
1
];
for
(
i
=
0
;
i
<
len
;
i
++
,
src
+=
cn
)
for
(
;
i
<
len
;
i
++
,
src
+=
cn
)
{
s0
+=
src
[
0
];
s1
+=
src
[
1
];
...
...
@@ -97,7 +264,7 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn )
else
if
(
k
==
3
)
{
ST
s0
=
dst
[
0
],
s1
=
dst
[
1
],
s2
=
dst
[
2
];
for
(
i
=
0
;
i
<
len
;
i
++
,
src
+=
cn
)
for
(
;
i
<
len
;
i
++
,
src
+=
cn
)
{
s0
+=
src
[
0
];
s1
+=
src
[
1
];
...
...
@@ -110,9 +277,9 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn )
for
(
;
k
<
cn
;
k
+=
4
)
{
src
=
src0
+
k
;
src
=
src0
+
i
*
cn
+
k
;
ST
s0
=
dst
[
k
],
s1
=
dst
[
k
+
1
],
s2
=
dst
[
k
+
2
],
s3
=
dst
[
k
+
3
];
for
(
i
=
0
;
i
<
len
;
i
++
,
src
+=
cn
)
for
(
;
i
<
len
;
i
++
,
src
+=
cn
)
{
s0
+=
src
[
0
];
s1
+=
src
[
1
];
s2
+=
src
[
2
];
s3
+=
src
[
3
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录