/*M///////////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, 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:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of Intel Corporation may not 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 Intel Corporation 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.
//
//M*/
/* ////////////////////////////////////////////////////////////////////
//
// CvMat arithmetic operations: +, - ...
//
// */
#include "_cv.h"
/****************************************************************************************\
* Arithmetic operations (+, -) without mask *
\****************************************************************************************/
#define ICV_DEF_BIN_ARI_OP_CASE( __op__, worktype, cast_macro, len )\
{ \
int i; \
\
for( i = 0; i <= (len) - 4; i += 4 ) \
{ \
worktype t0 = __op__((src1)[i], (src2)[i]); \
worktype t1 = __op__((src1)[i+1], (src2)[i+1]); \
\
(dst)[i] = cast_macro( t0 ); \
(dst)[i+1] = cast_macro( t1 ); \
\
t0 = __op__((src1)[i+2],(src2)[i+2]); \
t1 = __op__((src1)[i+3],(src2)[i+3]); \
\
(dst)[i+2] = cast_macro( t0 ); \
(dst)[i+3] = cast_macro( t1 ); \
} \
\
for( ; i < (len); i++ ) \
{ \
worktype t0 = __op__((src1)[i],(src2)[i]); \
(dst)[i] = cast_macro( t0 ); \
} \
}
#define ICV_DEF_BIN_ARI_OP_2D( __op__, name, type, worktype, cast_macro ) \
IPCVAPI_IMPL( CvStatus, name, ( const type* src1, int step1, \
const type* src2, int step2, \
type* dst, int step, CvSize size )) \
{ \
if( size.width == 1 ) \
{ \
for( ; size.height--; (char*&)src1 += step1, \
(char*&)src2 += step2, \
(char*&)dst += step ) \
{ \
worktype t0 = __op__((src1)[0],(src2)[0]); \
(dst)[0] = cast_macro( t0 ); \
} \
} \
else \
{ \
for( ; size.height--; (char*&)src1 += step1, \
(char*&)src2 += step2, \
(char*&)dst += step ) \
{ \
ICV_DEF_BIN_ARI_OP_CASE( __op__, worktype, \
cast_macro, size.width ); \
} \
} \
\
return CV_OK; \
}
#define ICV_DEF_UN_ARI_OP_CASE( __op__, worktype, cast_macro, \
src, scalar, dst, len ) \
{ \
int i; \
\
for( ; ((len) -= 12) >= 0; (dst) += 12, (src) += 12 ) \
{ \
worktype t0 = __op__((scalar)[0], (src)[0]); \
worktype t1 = __op__((scalar)[1], (src)[1]); \
\
(dst)[0] = cast_macro( t0 ); \
(dst)[1] = cast_macro( t1 ); \
\
t0 = __op__((scalar)[2], (src)[2]); \
t1 = __op__((scalar)[3], (src)[3]); \
\
(dst)[2] = cast_macro( t0 ); \
(dst)[3] = cast_macro( t1 ); \
\
t0 = __op__((scalar)[4], (src)[4]); \
t1 =
评论0