/******************************************************************** ** Image Component Library (ICL) ** ** ** ** Copyright (C) 2006-2012 CITEC, University of Bielefeld ** ** Neuroinformatics Group ** ** Website: www.iclcv.org and ** ** http://opensource.cit-ec.de/projects/icl ** ** ** ** File : ICLIO/src/DefaultConvertEngine.cpp ** ** Module : ICLIO ** ** Authors: Christof Elbrechter ** ** ** ** ** ** Commercial License ** ** ICL can be used commercially, please refer to our website ** ** www.iclcv.org for more details. ** ** ** ** GNU General Public License Usage ** ** Alternatively, this file may be used under the terms of the ** ** GNU General Public License version 3.0 as published by the ** ** Free Software Foundation and appearing in the file LICENSE.GPL ** ** included in the packaging of this file. Please review the ** ** following information to ensure the GNU General Public License ** ** version 3.0 requirements will be met: ** ** http://www.gnu.org/copyleft/gpl.html. ** ** ** ** The development of this software was supported by the ** ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** ** Forschungsgemeinschaft (DFG) in the context of the German ** ** Excellence Initiative. ** ** ** *********************************************************************/ #include #include #include #include #include #include #include #include using namespace std; namespace icl{ namespace { inline void yuv_to_rgb(const icl32s y,const icl32s u,const icl32s v, icl8u &r, icl8u &g, icl8u &b){ // {{{ open icl32s u2 = 14343*u - 1828717; icl32s v2 = 20231*v - 2579497; r = clipped_cast(y + ( ( 290 * v2 ) >> 22 )); g = clipped_cast(y - ( ( 100 * u2 + 148 * v2) >> 22 )); b = clipped_cast(y + ( ( 518 * u2 ) >> 22 )); } } bool DefaultConvertEngine::isAbleToProvideParams(const ImgParams &desiredParams, depth desiredDepth) const{ UnicapFormat f = m_poDevice->getCurrentUnicapFormat(); if(desiredDepth == depth8u && desiredParams.getFormat() == formatRGB && desiredParams.getSize() == f.getSize() ){ return true; }else{ return false; } } void DefaultConvertEngine::cvt(const icl8u *rawData, const ImgParams &desiredParams, depth desiredDepth, ImgBase **ppoDst){ UnicapFormat f = m_poDevice->getCurrentUnicapFormat(); string fourcc = f.getFourCC(); Size size = f.getSize(); if(desiredParams.getFormat() == formatYUV){ // do something else !!! .. something faster ?? } if(fourcc == "Y444"){ // YUV444 size 160x120 ORDER: U Y V ensureCompatible(ppoDst,depth8u,size,formatRGB); icl8u *dstR = (*ppoDst)->asImg()->getData(0); icl8u *dstG = (*ppoDst)->asImg()->getData(1); icl8u *dstB = (*ppoDst)->asImg()->getData(2); const icl8u *pSrcEnd = rawData+size.getDim()*3; for(const icl8u *pSrc = rawData; pSrc asImg()); #else const icl8u *s = rawData; register int width = size.width; register int cnt = size.getDim(); register int col = 0; register int row = 0; register int pixpos = 0; register int tar_pos = 0; icl8u *dstR = (*ppoDst)->asImg()->getData(0); icl8u *dstG = (*ppoDst)->asImg()->getData(1); icl8u *dstB = (*ppoDst)->asImg()->getData(2); for (int i=0; iasImg()); #else icl8u *dstR = (*ppoDst)->asImg()->getData(0); icl8u *dstG = (*ppoDst)->asImg()->getData(1); icl8u *dstB = (*ppoDst)->asImg()->getData(2); const icl8u *pSrcEnd = rawData+2*size.getDim(); for(const icl8u *pSrc = rawData; pSrc asImg()->getData(0); icl8u *dstG = (*ppoDst)->asImg()->getData(1); icl8u *dstB = (*ppoDst)->asImg()->getData(2); const icl8u *pSrcEnd = rawData+size.getDim()+size.getDim()/2; for(const icl8u *pSrc = rawData; pSrc asImg()->getData(0)); }else if(fourcc == "BGR3"){ ensureCompatible(ppoDst,depth8u,size,formatRGB); icl8u *dstR = (*ppoDst)->asImg()->getData(0); icl8u *dstG = (*ppoDst)->asImg()->getData(1); icl8u *dstB = (*ppoDst)->asImg()->getData(2); const icl8u *r = rawData; const icl8u *rEnd = r + size.getDim()*3; while(rasImg()->getData(0); icl8u *dstG = (*ppoDst)->asImg()->getData(1); icl8u *dstB = (*ppoDst)->asImg()->getData(2); const icl8u *r = rawData; const icl8u *rEnd = r + size.getDim()*4; while(rasImg()->getData(0); icl8u *dstG = (*ppoDst)->asImg()->getData(1); icl8u *dstB = (*ppoDst)->asImg()->getData(2); const icl8u *r = rawData; const icl8u *rEnd = r + size.getDim()*4; while(r