📄 cxmisc.h
字号:
//////////////////////////////////////////////////////////////////////////////////////////// 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)/* The header is mostly for internal use and it is likely to change. It contains some macro definitions that are used in cxcore, cv, cvaux and, probably, other libraries. If you need some of this functionality, the safe way is to copy it into your code and rename the macros.*/#ifndef _CXCORE_MISC_H_#define _CXCORE_MISC_H_#include <limits.h>/****************************************************************************************\* Compile-time tuning parameters *\****************************************************************************************//* maximal size of vector to run matrix operations on it inline (i.e. w/o ipp calls) */#define CV_MAX_INLINE_MAT_OP_SIZE 10/* maximal linear size of matrix to allocate it on stack. */#define CV_MAX_LOCAL_MAT_SIZE 32/* maximal size of local memory storage */#define CV_MAX_LOCAL_SIZE \ (CV_MAX_LOCAL_MAT_SIZE*CV_MAX_LOCAL_MAT_SIZE*(int)sizeof(double))/* default image row align (in bytes) */#define CV_DEFAULT_IMAGE_ROW_ALIGN 8/* matrices are continuous by default */#define CV_DEFAULT_MAT_ROW_ALIGN 8/* maximum size of dynamic memory buffer. cvAlloc reports an error if a larger block is requested. */#define CV_MAX_ALLOC_SIZE (((size_t)1 << (sizeof(size_t)*8-2)))/* the alignment of all the allocated buffers */#define CV_MALLOC_ALIGN 8/* default alignment for dynamic data strucutures, resided in storages. */#define CV_STRUCT_ALIGN ((int)sizeof(double))/* default storage block size */#define CV_STORAGE_BLOCK_SIZE ((1<<16) - 128)/* default memory block for sparse array elements */#define CV_SPARSE_MAT_BLOCK (1<<12)/* initial hash table size */#define CV_SPARSE_HASH_SIZE0 (1<<10)/* maximal average node_count/hash_size ratio beyond which hash table is resized */#define CV_SPARSE_HASH_RATIO 3/* max length of strings */#define CV_MAX_STRLEN 1024/* maximum possible number of threads in parallel implementations */#ifdef _OPENMP#define CV_MAX_THREADS 128#else#define CV_MAX_THREADS 1#endif#if 0 /*def CV_CHECK_FOR_NANS*/ #define CV_CHECK_NANS( arr ) cvCheckArray((arr)) #else #define CV_CHECK_NANS( arr )#endif/****************************************************************************************\* Common declarations *\****************************************************************************************//* ! DO NOT make it an inline function */#define cvStackAlloc(size) cvAlignPtr( alloca((size) + CV_MALLOC_ALIGN), CV_MALLOC_ALIGN )#if defined _MSC_VER || defined __BORLANDC__ #define CV_BIG_INT(n) n##I64 #define CV_BIG_UINT(n) n##UI64#else #define CV_BIG_INT(n) n##LL #define CV_BIG_UINT(n) n##ULL#endif#define CV_IMPL CV_EXTERN_C#if defined WIN32 && !defined WIN64 && (_MSC_VER >= 1200 || defined CV_ICC) #define CV_DBG_BREAK() __asm int 3#else #define CV_DBG_BREAK() assert(0);#endif/* default step, set in case of continuous data to work around checks for valid step in some ipp functions */#define CV_STUB_STEP (1 << 30)#define CV_SIZEOF_FLOAT ((int)sizeof(float))#define CV_SIZEOF_SHORT ((int)sizeof(short))#define CV_ORIGIN_TL 0#define CV_ORIGIN_BL 1/* IEEE754 constants and macros */#define CV_POS_INF 0x7f800000#define CV_NEG_INF 0x807fffff /* CV_TOGGLE_FLT(0xff800000) */#define CV_1F 0x3f800000#define CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0))#define CV_TOGGLE_DBL(x) \ ((x)^((int64)(x) < 0 ? CV_BIG_INT(0x7fffffffffffffff) : 0))#define CV_NOP(a) (a)#define CV_ADD(a, b) ((a) + (b))#define CV_SUB(a, b) ((a) - (b))#define CV_MUL(a, b) ((a) * (b))#define CV_AND(a, b) ((a) & (b))#define CV_OR(a, b) ((a) | (b))#define CV_XOR(a, b) ((a) ^ (b))#define CV_ANDN(a, b) (~(a) & (b))#define CV_ORN(a, b) (~(a) | (b))#define CV_SQR(a) ((a) * (a))#define CV_LT(a, b) ((a) < (b))#define CV_LE(a, b) ((a) <= (b))#define CV_EQ(a, b) ((a) == (b))#define CV_NE(a, b) ((a) != (b))#define CV_GT(a, b) ((a) > (b))#define CV_GE(a, b) ((a) >= (b))#define CV_NONZERO(a) ((a) != 0)#define CV_NONZERO_FLT(a) (((a)+(a)) != 0)/* general-purpose saturation macros */ #define CV_CAST_8U(t) (uchar)(!((t) & ~255) ? (t) : (t) > 0 ? 255 : 0)#define CV_CAST_8S(t) (char)(!(((t)+128) & ~255) ? (t) : (t) > 0 ? 127 : -128)#define CV_CAST_16U(t) (ushort)(!((t) & ~65535) ? (t) : (t) > 0 ? 65535 : 0)#define CV_CAST_16S(t) (short)(!(((t)+32768) & ~65535) ? (t) : (t) > 0 ? 32767 : -32768)#define CV_CAST_32S(t) (int)(t)#define CV_CAST_64S(t) (int64)(t)#define CV_CAST_32F(t) (float)(t)#define CV_CAST_64F(t) (double)(t)#define CV_PASTE2(a,b) a##b#define CV_PASTE(a,b) CV_PASTE2(a,b)#define CV_EMPTY#define CV_MAKE_STR(a) #a#define CV_DEFINE_MASK \ float maskTab[2]; maskTab[0] = 0.f; maskTab[1] = 1.f;#define CV_ANDMASK( m, x ) ((x) & (((m) == 0) - 1))/* (x) * ((m) == 1 ? 1.f : (m) == 0 ? 0.f : <ERR> */#define CV_MULMASK( m, x ) (maskTab[(m) != 0]*(x))/* (x) * ((m) == -1 ? 1.f : (m) == 0 ? 0.f : <ERR> */#define CV_MULMASK1( m, x ) (maskTab[(m)+1]*(x))#define CV_ZERO_OBJ(x) memset((x), 0, sizeof(*(x)))#define CV_DIM(static_array) ((int)(sizeof(static_array)/sizeof((static_array)[0])))#define CV_UN_ENTRY_C1(worktype) \ worktype s0 = scalar[0] #define CV_UN_ENTRY_C2(worktype) \ worktype s0 = scalar[0], s1 = scalar[1]#define CV_UN_ENTRY_C3(worktype) \ worktype s0 = scalar[0], s1 = scalar[1], s2 = scalar[2]#define CV_UN_ENTRY_C4(worktype) \ worktype s0 = scalar[0], s1 = scalar[1], s2 = scalar[2], s3 = scalar[3]#define cvUnsupportedFormat "Unsupported format"CV_INLINE void* cvAlignPtr( const void* ptr, int align=32 ){ assert( (align & (align-1)) == 0 ); return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) );}CV_INLINE int cvAlign( int size, int align ){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -