Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
1d7bfcc9
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
1d7bfcc9
编写于
3月 17, 2020
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16827 from alalek:update_buffer_area
上级
01ea055d
77d1c20f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
10 deletion
+32
-10
modules/core/include/opencv2/core/utils/buffer_area.private.hpp
...s/core/include/opencv2/core/utils/buffer_area.private.hpp
+6
-0
modules/core/src/buffer_area.cpp
modules/core/src/buffer_area.cpp
+26
-10
未找到文件。
modules/core/include/opencv2/core/utils/buffer_area.private.hpp
浏览文件 @
1d7bfcc9
...
@@ -72,6 +72,10 @@ public:
...
@@ -72,6 +72,10 @@ public:
CV_Assert
(
alignment
%
sizeof
(
T
)
==
0
);
CV_Assert
(
alignment
%
sizeof
(
T
)
==
0
);
CV_Assert
((
alignment
&
(
alignment
-
1
))
==
0
);
CV_Assert
((
alignment
&
(
alignment
-
1
))
==
0
);
allocate_
((
void
**
)(
&
ptr
),
static_cast
<
ushort
>
(
sizeof
(
T
)),
count
,
alignment
);
allocate_
((
void
**
)(
&
ptr
),
static_cast
<
ushort
>
(
sizeof
(
T
)),
count
,
alignment
);
#ifndef OPENCV_ENABLE_MEMORY_SANITIZER
if
(
safe
)
#endif
CV_Assert
(
ptr
!=
NULL
);
}
}
/** @brief Fill one of buffers with zeroes
/** @brief Fill one of buffers with zeroes
...
@@ -118,9 +122,11 @@ private:
...
@@ -118,9 +122,11 @@ private:
private:
private:
class
Block
;
class
Block
;
std
::
vector
<
Block
>
blocks
;
std
::
vector
<
Block
>
blocks
;
#ifndef OPENCV_ENABLE_MEMORY_SANITIZER
void
*
oneBuf
;
void
*
oneBuf
;
size_t
totalSize
;
size_t
totalSize
;
const
bool
safe
;
const
bool
safe
;
#endif
};
};
//! @}
//! @}
...
...
modules/core/src/buffer_area.cpp
浏览文件 @
1d7bfcc9
...
@@ -5,14 +5,10 @@
...
@@ -5,14 +5,10 @@
#include "opencv2/core/utils/buffer_area.private.hpp"
#include "opencv2/core/utils/buffer_area.private.hpp"
#include "opencv2/core/utils/configuration.private.hpp"
#include "opencv2/core/utils/configuration.private.hpp"
#ifdef OPENCV_ENABLE_MEMORY_SANITIZER
#ifndef OPENCV_ENABLE_MEMORY_SANITIZER
#define BUFFER_AREA_DEFAULT_MODE true
#else
#define BUFFER_AREA_DEFAULT_MODE false
#endif
static
bool
CV_BUFFER_AREA_OVERRIDE_SAFE_MODE
=
static
bool
CV_BUFFER_AREA_OVERRIDE_SAFE_MODE
=
cv
::
utils
::
getConfigurationParameterBool
(
"OPENCV_BUFFER_AREA_ALWAYS_SAFE"
,
BUFFER_AREA_DEFAULT_MODE
);
cv
::
utils
::
getConfigurationParameterBool
(
"OPENCV_BUFFER_AREA_ALWAYS_SAFE"
,
false
);
#endif
namespace
cv
{
namespace
utils
{
namespace
cv
{
namespace
utils
{
...
@@ -58,6 +54,7 @@ public:
...
@@ -58,6 +54,7 @@ public:
*
ptr
=
raw_mem
;
*
ptr
=
raw_mem
;
}
}
}
}
#ifndef OPENCV_ENABLE_MEMORY_SANITIZER
void
*
fast_allocate
(
void
*
buf
)
const
void
*
fast_allocate
(
void
*
buf
)
const
{
{
CV_Assert
(
ptr
&&
*
ptr
==
NULL
);
CV_Assert
(
ptr
&&
*
ptr
==
NULL
);
...
@@ -66,6 +63,7 @@ public:
...
@@ -66,6 +63,7 @@ public:
*
ptr
=
buf
;
*
ptr
=
buf
;
return
static_cast
<
void
*>
(
static_cast
<
uchar
*>
(
*
ptr
)
+
type_size
*
count
);
return
static_cast
<
void
*>
(
static_cast
<
uchar
*>
(
*
ptr
)
+
type_size
*
count
);
}
}
#endif
bool
operator
==
(
void
**
other
)
const
bool
operator
==
(
void
**
other
)
const
{
{
CV_Assert
(
ptr
&&
other
);
CV_Assert
(
ptr
&&
other
);
...
@@ -86,12 +84,20 @@ private:
...
@@ -86,12 +84,20 @@ private:
//==================================================================================================
//==================================================================================================
#ifndef OPENCV_ENABLE_MEMORY_SANITIZER
BufferArea
::
BufferArea
(
bool
safe_
)
:
BufferArea
::
BufferArea
(
bool
safe_
)
:
oneBuf
(
0
),
oneBuf
(
0
),
totalSize
(
0
),
totalSize
(
0
),
safe
(
safe_
||
CV_BUFFER_AREA_OVERRIDE_SAFE_MODE
)
safe
(
safe_
||
CV_BUFFER_AREA_OVERRIDE_SAFE_MODE
)
{
{
// nothing
}
}
#else
BufferArea
::
BufferArea
(
bool
safe_
)
{
CV_UNUSED
(
safe_
);
}
#endif
BufferArea
::~
BufferArea
()
BufferArea
::~
BufferArea
()
{
{
...
@@ -101,10 +107,16 @@ BufferArea::~BufferArea()
...
@@ -101,10 +107,16 @@ BufferArea::~BufferArea()
void
BufferArea
::
allocate_
(
void
**
ptr
,
ushort
type_size
,
size_t
count
,
ushort
alignment
)
void
BufferArea
::
allocate_
(
void
**
ptr
,
ushort
type_size
,
size_t
count
,
ushort
alignment
)
{
{
blocks
.
push_back
(
Block
(
ptr
,
type_size
,
count
,
alignment
));
blocks
.
push_back
(
Block
(
ptr
,
type_size
,
count
,
alignment
));
if
(
safe
)
#ifndef OPENCV_ENABLE_MEMORY_SANITIZER
blocks
.
back
().
real_allocate
();
if
(
!
safe
)
else
{
totalSize
+=
blocks
.
back
().
getByteCount
();
totalSize
+=
blocks
.
back
().
getByteCount
();
}
else
#endif
{
blocks
.
back
().
real_allocate
();
}
}
}
void
BufferArea
::
zeroFill_
(
void
**
ptr
)
void
BufferArea
::
zeroFill_
(
void
**
ptr
)
...
@@ -129,6 +141,7 @@ void BufferArea::zeroFill()
...
@@ -129,6 +141,7 @@ void BufferArea::zeroFill()
void
BufferArea
::
commit
()
void
BufferArea
::
commit
()
{
{
#ifndef OPENCV_ENABLE_MEMORY_SANITIZER
if
(
!
safe
)
if
(
!
safe
)
{
{
CV_Assert
(
totalSize
>
0
);
CV_Assert
(
totalSize
>
0
);
...
@@ -141,6 +154,7 @@ void BufferArea::commit()
...
@@ -141,6 +154,7 @@ void BufferArea::commit()
ptr
=
i
->
fast_allocate
(
ptr
);
ptr
=
i
->
fast_allocate
(
ptr
);
}
}
}
}
#endif
}
}
void
BufferArea
::
release
()
void
BufferArea
::
release
()
...
@@ -150,11 +164,13 @@ void BufferArea::release()
...
@@ -150,11 +164,13 @@ void BufferArea::release()
i
->
cleanup
();
i
->
cleanup
();
}
}
blocks
.
clear
();
blocks
.
clear
();
#ifndef OPENCV_ENABLE_MEMORY_SANITIZER
if
(
oneBuf
)
if
(
oneBuf
)
{
{
fastFree
(
oneBuf
);
fastFree
(
oneBuf
);
oneBuf
=
0
;
oneBuf
=
0
;
}
}
#endif
}
}
//==================================================================================================
//==================================================================================================
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录