Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

FuncNgbOp2d.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_Pattern_FuncNgbOp2d_h
00002 #define Impala_Core_Array_Pattern_FuncNgbOp2d_h
00003 
00004 #include "Core/Array/Pattern/Categories.h"
00005 #include "Core/Array/Pattern/ArrayFunc.h"
00006 
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace Array
00012 {
00013 namespace Pattern
00014 {
00015 
00016 
00017 #undef Next
00018 
00019 /**********************************************************************/
00051 template <class SrcArrayT, class NgbT>
00052 inline void
00053 FuncNgbOp2d_Pix_P1Cnum(SrcArrayT* src, int x, int y, NgbT& ngb)
00054 {
00055     typedef typename SrcArrayT::StorType SrcStorT;
00056     typedef typename SrcArrayT::ArithType SrcArithT;
00057     typedef typename NgbT::CnumType CnumType;
00058 
00059     for (CnumType cnum = ngb.Begin() ; cnum != ngb.End() ; cnum.Inc())
00060     {
00061         SrcStorT* nPtr = ArrayCPB(src, x + cnum.X(), y + cnum.Y());
00062         ngb.NextEl(cnum.X(), cnum.Y(), PtrRead(nPtr, SrcArithT()));
00063     }
00064 }
00065 
00068 template <class SrcStorT, class SrcArithT, class NgbT>
00069 inline void
00070 FuncNgbOp2d_Pix_P1Loop(SrcStorT* sPtr, NgbT& ngb, int ngbWidth, int ngbHeight,
00071                        int srcIncX, int srcIncY, SrcArithT)
00072 {
00073     for (int j=0 ; j<ngbHeight ; j++)
00074     {
00075         for (int i=0 ; i<ngbWidth ; i++)
00076         {
00077             ngb.NextEl(i, j, PtrRead(sPtr, SrcArithT()));
00078             sPtr += srcIncX;
00079         }
00080         sPtr += srcIncY;
00081     }
00082 }
00083 
00086 template <class SrcStorT, class SrcArithT, class NgbT>
00087 inline void
00088 FuncNgbOp2d_Pix_P2Loop(SrcStorT* sPtr, NgbT& ngb, int ngbWidth, int ngbHeight,
00089                        int srcIncX, int srcIncY, SrcArithT)
00090 {
00091     for (int j=0 ; j<ngbHeight ; j++)
00092     {
00093         for (int i=0 ; i<ngbWidth ; i++)
00094         {
00095             ngb.NextEl2(i, j, PtrRead(sPtr, SrcArithT()));
00096             sPtr += srcIncX;
00097         }
00098         sPtr += srcIncY;
00099     }
00100 }
00101 
00102 
00104 //End of Pix_variations.
00105 
00106 
00108 
00112 template <class DstArrayT, class SrcArrayT, class NgbT>
00113 inline void
00114 FuncNgbOp2d_Row(DstArrayT* dst, SrcArrayT* src, NgbT& ngb, int y,
00115                 Tag1Phase dummy1, TagCnum dummy2)
00116 {
00117     typedef typename DstArrayT::StorType DstStorT;
00118     typedef typename DstArrayT::ArithType DstArithT;
00119     typedef typename SrcArrayT::StorType SrcStorT;
00120     typedef typename SrcArrayT::ArithType SrcArithT;
00121 
00122     int width = ArrayCW(dst);
00123     DstStorT* dPtr = ArrayCPB(dst, 0, y);
00124     SrcStorT* sPtr = ArrayCPB(src, 0, y);
00125     for (int x=0 ; x<width ; x++)
00126     {
00127         ngb.Init(x, y, PtrRead(sPtr, SrcArithT()));
00128         FuncNgbOp2d_Pix_P1Cnum(src, x, y, ngb);
00129         PtrWrite(dPtr, ngb.Result());
00130         dPtr += DstArrayT::ElemSize();
00131         sPtr += SrcArrayT::ElemSize();
00132     }
00133 }
00134 
00137 template <class DstArrayT, class SrcArrayT, class NgbT>
00138 inline void
00139 FuncNgbOp2d_Row(DstArrayT* dst, SrcArrayT* src, NgbT& ngb, int y,
00140                 Tag1Phase dummy1, TagLoop dummy2)
00141 {
00142     typedef typename DstArrayT::StorType DstStorT;
00143     typedef typename DstArrayT::ArithType DstArithT;
00144     typedef typename SrcArrayT::StorType SrcStorT;
00145     typedef typename SrcArrayT::ArithType SrcArithT;
00146 
00147     int ngbWidth = ngb.Width();
00148     int ngbHeight = ngb.Height();
00149     int width = ArrayCW(dst);
00150     DstStorT* dPtr = ArrayCPB(dst, 0, y);
00151     SrcStorT* sPtr = ArrayCPB(src, -ngbWidth/2, y-ngbHeight/2);
00152     SrcStorT* cenPtr = ArrayCPB(src, 0, y);
00153     int srcIncX = ArrayInc(src, 1, 0);
00154     int srcIncY = ArrayInc(src, -ngbWidth, 1);
00155     for (int x=0 ; x<width ; x++)
00156     {
00157         ngb.Init(x, y, PtrRead(cenPtr, SrcArithT()));
00158         FuncNgbOp2d_Pix_P1Loop(sPtr, ngb, ngbWidth, ngbHeight, srcIncX,
00159                                srcIncY, SrcArithT());
00160         PtrWrite(dPtr, ngb.Result());
00161         dPtr += DstArrayT::ElemSize();
00162         sPtr += SrcArrayT::ElemSize();
00163         cenPtr += SrcArrayT::ElemSize();
00164     }
00165 }
00166 
00169 template <class DstArrayT, class SrcArrayT, class NgbT>
00170 inline void
00171 FuncNgbOp2d_Row(DstArrayT* dst, SrcArrayT* src, NgbT& ngb, int y,
00172                 Tag2Phase dummy1, TagLoop dummy2)
00173 {
00174     typedef typename DstArrayT::StorType DstStorT;
00175     typedef typename DstArrayT::ArithType DstArithT;
00176     typedef typename SrcArrayT::StorType SrcStorT;
00177     typedef typename SrcArrayT::ArithType SrcArithT;
00178 
00179     int ngbWidth = ngb.Width();
00180     int ngbHeight = ngb.Height();
00181     int width = ArrayCW(dst);
00182     DstStorT* dPtr = ArrayCPB(dst, 0, y);
00183     SrcStorT* sPtr = ArrayCPB(src, -ngbWidth/2, y-ngbHeight/2);
00184     SrcStorT* cenPtr = ArrayCPB(src, 0, y);
00185     int srcIncX = ArrayInc(src, 1, 0);
00186     int srcIncY = ArrayInc(src, -ngbWidth, 1);
00187     for (int x=0 ; x<width ; x++)
00188     {
00189         ngb.Init(x, y, PtrRead(cenPtr, SrcArithT()));
00190         FuncNgbOp2d_Pix_P1Loop(sPtr, ngb, ngbWidth, ngbHeight, srcIncX,
00191                                srcIncY, SrcArithT());
00192         ngb.Init2(x, y, PtrRead(cenPtr, SrcArithT()));
00193         FuncNgbOp2d_Pix_P2Loop(sPtr, ngb, ngbWidth, ngbHeight, srcIncX,
00194                                srcIncY, SrcArithT());
00195         PtrWrite(dPtr, ngb.Result());
00196         dPtr += DstArrayT::ElemSize();
00197         sPtr += SrcArrayT::ElemSize();
00198         cenPtr += SrcArrayT::ElemSize();
00199     }
00200 }
00201 
00202 
00205 template <class DstArrayT, class SrcArrayT, class NgbT>
00206 inline void
00207 FuncNgbOp2d_Row(DstArrayT* dst, SrcArrayT* src, NgbT& ngb, int y,
00208                 TagNPhase dummy1, TagLoop dummy2)
00209 {
00210     typedef typename DstArrayT::StorType DstStorT;
00211     typedef typename DstArrayT::ArithType DstArithT;
00212     typedef typename SrcArrayT::StorType SrcStorT;
00213     typedef typename SrcArrayT::ArithType SrcArithT;
00214 
00215     int ngbWidth = ngb.Width();
00216     int ngbHeight = ngb.Height();
00217     int width = ArrayCW(dst);
00218     DstStorT* dPtr = ArrayCPB(dst, 0, y);
00219     SrcStorT* sPtr = ArrayCPB(src, -ngbWidth/2, y-ngbHeight/2);
00220     SrcStorT* cenPtr = ArrayCPB(src, 0, y);
00221     int srcIncX = ArrayInc(src, 1, 0);
00222     int srcIncY = ArrayInc(src, -ngbWidth, 1);
00223     for (int x=0 ; x<width ; x++)
00224     {
00225         int phase = 1;
00226         do {
00227             ngb.Init(phase, x, y, PtrRead(cenPtr, SrcArithT()));
00228             FuncNgbOp2d_Pix_P1Loop(sPtr, ngb, ngbWidth, ngbHeight, srcIncX,
00229                                    srcIncY, SrcArithT());
00230             ngb.Done(phase);
00231         } while (ngb.HasNextPhase(phase++));
00232         PtrWrite(dPtr, ngb.Result());
00233         dPtr += DstArrayT::ElemSize();
00234         sPtr += SrcArrayT::ElemSize();
00235         cenPtr += SrcArrayT::ElemSize();
00236     }
00237 }
00238 
00240 //End of Row_variations.
00241 
00245 template<class DstArrayT, class SrcArrayT, class NgbT>
00246 void
00247 FuncNgbOp2dDispatch(DstArrayT* dst, SrcArrayT* src, NgbT& ngb)
00248 {
00249     int height = ArrayCH(dst);
00250     for (int y=0 ; y<height ; y++)
00251     {
00252         FuncNgbOp2d_Row(dst, src, ngb, y,
00253                         typename NgbT::PhaseCategory(),
00254                         typename NgbT::IteratorCategory());
00255     }
00256 }
00257 
00258 } // namespace Pattern
00259 } // namespace Array
00260 } // namespace Core
00261 } // namespace Impala
00262 
00263 #endif

Generated on Fri Mar 19 09:30:50 2010 for ImpalaSrc by  doxygen 1.5.1