////////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License For Embedded Computer Vision Library
//
// Copyright (c) 2008, EMCV Project,
// Copyright (c) 2000-2007, Intel Corporation,
// All rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the copyright holders nor the names of their contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
// OF SUCH DAMAGE.
//
// Contributors:
// * Shiqi Yu (Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences)
#include "cxcore.h"
#define ICV_FREE_PTR(storage) \
((char*)(storage)->top + (storage)->block_size - (storage)->free_space)
#define ICV_ALIGNED_SEQ_BLOCK_SIZE \
(int)cvAlign(sizeof(CvSeqBlock), CV_STRUCT_ALIGN)
CV_INLINE int
cvAlignLeft( int size, int align )
{
return size & -align;
}
#define CV_GET_LAST_ELEM( seq, block ) \
((block)->data + ((block)->count - 1)*((seq)->elem_size))
#define CV_SWAP_ELEMS(a,b,elem_size) \
{ \
int k; \
for( k = 0; k < elem_size; k++ ) \
{ \
char t0 = (a)[k]; \
char t1 = (b)[k]; \
(a)[k] = t1; \
(b)[k] = t0; \
} \
}
#define ICV_SHIFT_TAB_MAX 32
static const char icvPower2ShiftTab[] =
{
0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5
};
/****************************************************************************************\
* Functions for manipulating memory storage - list of memory blocks *
\****************************************************************************************/
/* initializes allocated storage */
static void
icvInitMemStorage( CvMemStorage* storage, int block_size )
{
CV_FUNCNAME( "icvInitMemStorage " );
__BEGIN__;
if( !storage )
CV_ERROR( CV_StsNullPtr, "" );
if( block_size <= 0 )
block_size = CV_STORAGE_BLOCK_SIZE;
block_size = cvAlign( block_size, CV_STRUCT_ALIGN );
assert( sizeof(CvMemBlock) % CV_STRUCT_ALIGN == 0 );
memset( storage, 0, sizeof( *storage ));
storage->signature = CV_STORAGE_MAGIC_VAL;
storage->block_size = block_size;
__END__;
}
/* creates root memory storage */
CV_IMPL CvMemStorage*
cvCreateMemStorage( int block_size )
{
CvMemStorage *storage = 0;
CV_FUNCNAME( "cvCreateMemStorage" );
__BEGIN__;
CV_CALL( storage = (CvMemStorage *)cvAlloc( sizeof( CvMemStorage )));
CV_CALL( icvInitMemStorage( storage, block_size ));
__END__;
if( cvGetErrStatus() < 0 )
cvFree( &storage );
return storage;
}
/* creates child memory storage */
CV_IMPL CvMemStorage *
cvCreateChildMemStorage( CvMemStorage * parent )
{
CvMemStorage *storage = 0;
CV_FUNCNAME( "cvCreateChildMemStorage" );
__BEGIN__;
if( !parent )
CV_ERROR( CV_StsNullPtr, "" );
CV_CALL( storage = cvCreateMemStorage(parent->block_size));
storage->parent = parent;
__END__;
if( cvGetErrStatus() < 0 )
cvFree( &storage );
return storage;
}
/* releases all blocks of the storage (or returns them to parent if any) */
static void
icvDestroyMemStorage( CvMemStorage* storage )
{
CV_FUNCNAME( "icvDestroyMemStorage" );
__BEGIN__;
int k = 0;
CvMemBlock *block;
CvMemBlock *dst_top = 0;
if( !storage )
CV_ERROR( CV_StsNullPtr, "" );
if( storage->parent )
dst_top = storage->parent->top;
for( block = storage->bottom; block != 0; k++ )
{
CvMemBlock *temp = block;
block = block->next;
if( storage->parent )
{
if( dst_top )
{
temp->prev = dst_top;
temp->next = dst_top->next;
if( temp->next )
temp->next->prev = temp;
dst_top = dst_top->next = temp;
}
else
{
dst_top = storage->parent->bottom = storage->parent->top = temp;
temp->prev = temp->next = 0;
storage->free_space = storage->block_size - sizeof( *temp );
}
}
else
{
cvFree( &temp );
}
}
storage->top = storage->bottom = 0;
storage->free_space = 0;
__END__;
}
/* releases memory storage */
CV_IMPL void
cvReleaseMemStorage( CvMemStorage** storage )
{
CvMemStorage *st;
CV_FUNCNAME( "cvReleaseMemStorage" );
__BEGIN__;
if( !storage )
CV_ERROR( CV_StsNullPtr, "" );
st = *storage;
*storage = 0;
if( st )
{
CV_CALL( icvDestroyMemStorage( st ));
cvFree( &st );
}
__END__;
}
/* clears memory storage (returns blocks to the parent if any) */
CV_IMPL void
cvClearMemStorage( CvMemStorage * storage )
{
CV_FUNCNAME( "cvClearMemStorage" );
__BEGIN__;
if( !storage )
CV_ERROR( CV_StsNullPtr, "" );
if( storage->parent )
{
icvDestroyMemStorage( storage );
}
else
{
storage->top = storage->bottom;
storage->free_space = storage->bottom ? storage->block_size - sizeof(CvMemBlock) : 0;
}
__END__;
}
/* moves stack pointer to next block.
If no blocks, allocate new one and link it to the storage */
static void
icvGoNextMemBlock( CvMemStorage * storage )
{
CV_FUNCNAME( "icvGoNextMemBlock" );
__BEGIN__;
if( !storage )
CV_ERROR( CV_StsNullPtr, "" );
if( !storage->top || !storage->top->next )
{
CvMemBlock *block;
if( !(storage->parent) )
{
CV_CALL( block = (CvMemBlock *)cvAlloc( storage->block_size ));
}
else
{
CvMemStorage *parent = storage->parent;
CvMemStoragePos parent_pos;
cvSaveMemStoragePos( parent, &parent_pos );
CV_CALL( icvGoNextMemBlock( parent ));
block = parent->top;
cvRestoreMemStoragePos( parent, &parent_pos );
if( block == parent->top ) /* the single allocated block */
{
assert( pare
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
EMCV.rar (86个子文件)
EMCV
cxcore
cxmisc.h 46KB
cxcmp.cpp 4KB
cxerror.cpp 12KB
cxarithm.cpp 4KB
cxdatastructs.cpp 103KB
loadsave.cpp 9KB
_cxcore.h 11KB
cxerror.h 9KB
cxouttext.cpp 98KB
cxarray.cpp 38KB
cxalloc.cpp 3KB
cxtypes.h 48KB
cxcopy.cpp 5KB
cxcore.h 70KB
cxdrawing.cpp 61KB
cxtables.cpp 13KB
.svn
all-wcprops 2KB
prop-base
props
tmp
prop-base
props
text-base
text-base
cxerror.h.svn-base 9KB
cxcmp.cpp.svn-base 4KB
cxouttext.cpp.svn-base 98KB
cxarray.cpp.svn-base 38KB
cxarithm.cpp.svn-base 4KB
cxdatastructs.cpp.svn-base 103KB
cxtypes.h.svn-base 48KB
cxdrawing.cpp.svn-base 61KB
cxerror.cpp.svn-base 12KB
cxcore.h.svn-base 70KB
loadsave.cpp.svn-base 9KB
cxcopy.cpp.svn-base 5KB
_cxcore.h.svn-base 11KB
cxalloc.cpp.svn-base 3KB
cxtables.cpp.svn-base 13KB
cxmisc.h.svn-base 46KB
entries 3KB
License 2KB
cvaux
cvaux.hpp 6KB
cvaux.h 58KB
cvvidsurv.hpp 40KB
cvmat.hpp 69KB
.svn
all-wcprops 469B
prop-base
props
tmp
prop-base
props
text-base
text-base
cvmat.hpp.svn-base 69KB
cvaux.h.svn-base 58KB
cvvidsurv.hpp.svn-base 40KB
cvaux.hpp.svn-base 6KB
entries 795B
cv
cvshapedescr.cpp 9KB
cv.hpp 16KB
cvpyramids.cpp 5KB
cvtables.cpp 17KB
_cv.h 4KB
cvmorph.cpp 8KB
_cvipp.h 36KB
cv.h 52KB
cvfilter.cpp 2KB
cvthresh.cpp 4KB
_cvmatrix.h 11KB
cvcontours.cpp 47KB
cvapprox.cpp 12KB
_cvlist.h 11KB
cvtypes.h 12KB
_cvimgproc.h 5KB
_cvgeom.h 4KB
.svn
all-wcprops 2KB
prop-base
props
tmp
prop-base
props
text-base
text-base
_cvlist.h.svn-base 11KB
cvtables.cpp.svn-base 17KB
cvcontours.cpp.svn-base 47KB
cvshapedescr.cpp.svn-base 9KB
cvpyramids.cpp.svn-base 5KB
cvutils.cpp.svn-base 3KB
cvtypes.h.svn-base 12KB
cvapprox.cpp.svn-base 12KB
_cvmatrix.h.svn-base 11KB
cvfilter.cpp.svn-base 2KB
_cv.h.svn-base 4KB
cv.h.svn-base 52KB
_cvgeom.h.svn-base 4KB
_cvimgproc.h.svn-base 5KB
cv.hpp.svn-base 16KB
cvthresh.cpp.svn-base 4KB
_cvipp.h.svn-base 36KB
cvmorph.cpp.svn-base 8KB
entries 3KB
cvutils.cpp 3KB
.svn
all-wcprops 158B
prop-base
props
tmp
prop-base
props
text-base
text-base
License.svn-base 2KB
entries 378B
共 86 条
- 1
lunat
- 粉丝: 104
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页