X-Git-Url: http://git.maemo.org/git/?p=opencv;a=blobdiff_plain;f=cxcore%2Fsrc%2Fcxlut.cpp;fp=cxcore%2Fsrc%2Fcxlut.cpp;h=0000000000000000000000000000000000000000;hp=166e6cebb92561f31eb4d3b228ffc8e4231e4c4c;hb=e4c14cdbdf2fe805e79cd96ded236f57e7b89060;hpb=454138ff8a20f6edb9b65a910101403d8b520643 diff --git a/cxcore/src/cxlut.cpp b/cxcore/src/cxlut.cpp deleted file mode 100644 index 166e6ce..0000000 --- a/cxcore/src/cxlut.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/*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*/ - -#include "_cxcore.h" - -/****************************************************************************************\ -* LUT Transform * -\****************************************************************************************/ - -#define ICV_LUT_CASE_C1( type ) \ - for( i = 0; i <= size.width-4; i += 4 ) \ - { \ - type t0 = lut[src[i]]; \ - type t1 = lut[src[i+1]]; \ - dst[i] = t0; \ - dst[i+1] = t1; \ - \ - t0 = lut[src[i+2]]; \ - t1 = lut[src[i+3]]; \ - dst[i+2] = t0; \ - dst[i+3] = t1; \ - } \ - \ - for( ; i < size.width; i++ ) \ - { \ - type t0 = lut[src[i]]; \ - dst[i] = t0; \ - } - - -#define ICV_LUT_CASE_C2( type ) \ - for( i = 0; i < size.width; i += 2 ) \ - { \ - type t0 = lut[src[i]*2]; \ - type t1 = lut[src[i+1]*2 + 1]; \ - dst[i] = t0; \ - dst[i+1] = t1; \ - } - -#define ICV_LUT_CASE_C3( type ) \ - for( i = 0; i < size.width; i += 3 ) \ - { \ - type t0 = lut[src[i]*3]; \ - type t1 = lut[src[i+1]*3 + 1]; \ - type t2 = lut[src[i+2]*3 + 2]; \ - dst[i] = t0; \ - dst[i+1] = t1; \ - dst[i+2] = t2; \ - } - -#define ICV_LUT_CASE_C4( type ) \ - for( i = 0; i < size.width; i += 4 ) \ - { \ - type t0 = lut[src[i]*4]; \ - type t1 = lut[src[i+1]*4 + 1]; \ - dst[i] = t0; \ - dst[i+1] = t1; \ - t0 = lut[src[i+2]*4 + 2]; \ - t1 = lut[src[i+3]*4 + 3]; \ - dst[i+2] = t0; \ - dst[i+3] = t1; \ - } - - -#define ICV_DEF_LUT_FUNC_8U_CN( flavor, dsttype, cn ) \ -CvStatus CV_STDCALL icvLUT_Transform8u_##flavor##_C##cn##R( \ - const uchar* src, int srcstep, \ - dsttype* dst, int dststep, CvSize size, \ - const dsttype* lut ) \ -{ \ - size.width *= cn; \ - dststep /= sizeof(dst[0]); \ - for( ; size.height--; src += srcstep, dst += dststep ) \ - { \ - int i; \ - ICV_LUT_CASE_C##cn( dsttype ) \ - } \ - \ - return CV_OK; \ -} - - -ICV_DEF_LUT_FUNC_8U_CN( 8u, uchar, 1 ) -ICV_DEF_LUT_FUNC_8U_CN( 16u, ushort, 1 ) -ICV_DEF_LUT_FUNC_8U_CN( 32s, int, 1 ) -ICV_DEF_LUT_FUNC_8U_CN( 64f, double, 1 ) - -ICV_DEF_LUT_FUNC_8U_CN( 8u, uchar, 2 ) -ICV_DEF_LUT_FUNC_8U_CN( 8u, uchar, 3 ) -ICV_DEF_LUT_FUNC_8U_CN( 8u, uchar, 4 ) - - -#define ICV_DEF_LUT_FUNC_8U( flavor, dsttype ) \ -static CvStatus CV_STDCALL \ -icvLUT_Transform8u_##flavor##_CnR( \ - const uchar* src, int srcstep, \ - dsttype* dst, int dststep, CvSize size, \ - const dsttype* _lut, int cn ) \ -{ \ - int max_block_size = (1 << 10)*cn; \ - dsttype lutp[1024]; \ - int i, k; \ - \ - size.width *= cn; \ - dststep /= sizeof(dst[0]); \ - \ - if( size.width*size.height < 256 ) \ - { \ - for( ; size.height--; src+=srcstep, dst+=dststep ) \ - for( k = 0; k < cn; k++ ) \ - for( i = 0; i < size.width; i += cn ) \ - dst[i+k] = _lut[src[i+k]*cn+k]; \ - return CV_OK; \ - } \ - \ - /* repack the lut to planar layout */ \ - for( k = 0; k < cn; k++ ) \ - for( i = 0; i < 256; i++ ) \ - lutp[i+k*256] = _lut[i*cn+k]; \ - \ - for( ; size.height--; src += srcstep, dst += dststep ) \ - { \ - for( i = 0; i < size.width; ) \ - { \ - int j, limit = MIN(size.width,i+max_block_size);\ - for( k=0; ktype ) > CV_8S ) - CV_ERROR( CV_StsUnsupportedFormat, "" ); - - depth = CV_MAT_DEPTH( dst->type ); - cn = CV_MAT_CN( dst->type ); - lut_cn = CV_MAT_CN( lut->type ); - - if( !CV_IS_MAT_CONT(lut->type) || (lut_cn != 1 && lut_cn != cn) || - !CV_ARE_DEPTHS_EQ( dst, lut ) || lut->width*lut->height != 256 ) - CV_ERROR( CV_StsBadArg, "The LUT must be continuous array \n" - "with 256 elements of the same type as destination" ); - - size = cvGetMatSize( src ); - if( lut_cn == 1 ) - { - size.width *= cn; - cn = 1; - } - - if( CV_IS_MAT_CONT( src->type & dst->type )) - { - size.width *= size.height; - size.height = 1; - } - - lut_data = lut->data.ptr; - - if( CV_MAT_DEPTH( src->type ) == CV_8S ) - { - int half_size = CV_ELEM_SIZE1(depth)*cn*128; - shuffled_lut = (uchar*)cvStackAlloc(half_size*2); - - // shuffle lut - memcpy( shuffled_lut, lut_data + half_size, half_size ); - memcpy( shuffled_lut + half_size, lut_data, half_size ); - - lut_data = shuffled_lut; - } - - if( lut_cn == 1 || lut_cn <= 4 && depth == CV_8U ) - { - CvLUT_TransformFunc func = depth == CV_8U ? lut_8u_tab[cn-1] : - (CvLUT_TransformFunc)(lut_c1_tab.fn_2d[depth]); - - if( !func ) - CV_ERROR( CV_StsUnsupportedFormat, "" ); - - IPPI_CALL( func( src->data.ptr, src->step, dst->data.ptr, - dst->step, size, lut_data )); - } - else - { - CvLUT_TransformCnFunc func = - (CvLUT_TransformCnFunc)(lut_cn_tab.fn_2d[depth]); - - if( !func ) - CV_ERROR( CV_StsUnsupportedFormat, "" ); - - IPPI_CALL( func( src->data.ptr, src->step, dst->data.ptr, - dst->step, size, lut_data, cn )); - } - - __END__; -} - -/* End of file. */