source: 3DVCSoftware/branches/HTM-DEV-2.0-dev2-MediaTek/source/Lib/TLibCommon/TComDataCU.h @ 568

Last change on this file since 568 was 564, checked in by mediatek-htm, 12 years ago

Integration of JCT3V-E0170 for motion data storage reduction.
The MACRO is "MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170".

By Yi-Wen Chen (yiwen.chen@…)

  • Property svn:eol-style set to native
File size: 44.4 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-2013, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TComDataCU.h
35    \brief    CU data structure (header)
36    \todo     not all entities are documented
37*/
38
39#ifndef _TCOMDATACU_
40#define _TCOMDATACU_
41
42#include <assert.h>
43
44// Include files
45#include "CommonDef.h"
46#include "TComMotionInfo.h"
47#include "TComSlice.h"
48#include "TComRdCost.h"
49#include "TComPattern.h"
50
51#if H_3D_ARP
52#include "TComYuv.h"
53#endif
54
55#include <algorithm>
56#include <vector>
57
58//! \ingroup TLibCommon
59//! \{
60
61// ====================================================================================================================
62// Non-deblocking in-loop filter processing block data structure
63// ====================================================================================================================
64
65/// Non-deblocking filter processing block border tag
66enum NDBFBlockBorderTag
67{
68  SGU_L = 0,
69  SGU_R,
70  SGU_T,
71  SGU_B,
72  SGU_TL,
73  SGU_TR,
74  SGU_BL,
75  SGU_BR,
76  NUM_SGU_BORDER
77};
78
79/// Non-deblocking filter processing block information
80struct NDBFBlockInfo
81{
82  Int   tileID;   //!< tile ID
83  Int   sliceID;  //!< slice ID
84  UInt  startSU;  //!< starting SU z-scan address in LCU
85  UInt  endSU;    //!< ending SU z-scan address in LCU
86  UInt  widthSU;  //!< number of SUs in width
87  UInt  heightSU; //!< number of SUs in height
88  UInt  posX;     //!< top-left X coordinate in picture
89  UInt  posY;     //!< top-left Y coordinate in picture
90  UInt  width;    //!< number of pixels in width
91  UInt  height;   //!< number of pixels in height
92  Bool  isBorderAvailable[NUM_SGU_BORDER];  //!< the border availabilities
93  Bool  allBordersAvailable;
94
95  NDBFBlockInfo():tileID(0), sliceID(0), startSU(0), endSU(0) {} //!< constructor
96  const NDBFBlockInfo& operator= (const NDBFBlockInfo& src);  //!< "=" operator
97};
98
99
100// ====================================================================================================================
101// Class definition
102// ====================================================================================================================
103
104/// CU data structure class
105class TComDataCU
106{
107private:
108 
109  // -------------------------------------------------------------------------------------------------------------------
110  // class pointers
111  // -------------------------------------------------------------------------------------------------------------------
112 
113  TComPic*      m_pcPic;              ///< picture class pointer
114  TComSlice*    m_pcSlice;            ///< slice header pointer
115  TComPattern*  m_pcPattern;          ///< neighbour access class pointer
116 
117  // -------------------------------------------------------------------------------------------------------------------
118  // CU description
119  // -------------------------------------------------------------------------------------------------------------------
120 
121  UInt          m_uiCUAddr;           ///< CU address in a slice
122  UInt          m_uiAbsIdxInLCU;      ///< absolute address in a CU. It's Z scan order
123  UInt          m_uiCUPelX;           ///< CU position in a pixel (X)
124  UInt          m_uiCUPelY;           ///< CU position in a pixel (Y)
125  UInt          m_uiNumPartition;     ///< total number of minimum partitions in a CU
126  UChar*        m_puhWidth;           ///< array of widths
127  UChar*        m_puhHeight;          ///< array of heights
128  UChar*        m_puhDepth;           ///< array of depths
129  Int           m_unitSize;           ///< size of a "minimum partition"
130 
131  // -------------------------------------------------------------------------------------------------------------------
132  // CU data
133  // -------------------------------------------------------------------------------------------------------------------
134  Bool*         m_skipFlag;           ///< array of skip flags
135  Char*         m_pePartSize;         ///< array of partition sizes
136  Char*         m_pePredMode;         ///< array of prediction modes
137  Bool*         m_CUTransquantBypass;   ///< array of cu_transquant_bypass flags
138  Char*         m_phQP;               ///< array of QP values
139  UChar*        m_puhTrIdx;           ///< array of transform indices
140  UChar*        m_puhTransformSkip[3];///< array of transform skipping flags
141  UChar*        m_puhCbf[3];          ///< array of coded block flags (CBF)
142  TComCUMvField m_acCUMvField[2];     ///< array of motion vectors
143  TCoeff*       m_pcTrCoeffY;         ///< transformed coefficient buffer (Y)
144  TCoeff*       m_pcTrCoeffCb;        ///< transformed coefficient buffer (Cb)
145  TCoeff*       m_pcTrCoeffCr;        ///< transformed coefficient buffer (Cr)
146#if ADAPTIVE_QP_SELECTION
147  Int*          m_pcArlCoeffY;        ///< ARL coefficient buffer (Y)
148  Int*          m_pcArlCoeffCb;       ///< ARL coefficient buffer (Cb)
149  Int*          m_pcArlCoeffCr;       ///< ARL coefficient buffer (Cr)
150  Bool          m_ArlCoeffIsAliasedAllocation; ///< ARL coefficient buffer is an alias of the global buffer and must not be free()'d
151
152  static Int*   m_pcGlbArlCoeffY;     ///< ARL coefficient buffer (Y)
153  static Int*   m_pcGlbArlCoeffCb;    ///< ARL coefficient buffer (Cb)
154  static Int*   m_pcGlbArlCoeffCr;    ///< ARL coefficient buffer (Cr)
155#endif
156 
157  Pel*          m_pcIPCMSampleY;      ///< PCM sample buffer (Y)
158  Pel*          m_pcIPCMSampleCb;     ///< PCM sample buffer (Cb)
159  Pel*          m_pcIPCMSampleCr;     ///< PCM sample buffer (Cr)
160
161  Int*          m_piSliceSUMap;       ///< pointer of slice ID map
162  std::vector<NDBFBlockInfo> m_vNDFBlock;
163
164  // -------------------------------------------------------------------------------------------------------------------
165  // neighbour access variables
166  // -------------------------------------------------------------------------------------------------------------------
167 
168  TComDataCU*   m_pcCUAboveLeft;      ///< pointer of above-left CU
169  TComDataCU*   m_pcCUAboveRight;     ///< pointer of above-right CU
170  TComDataCU*   m_pcCUAbove;          ///< pointer of above CU
171  TComDataCU*   m_pcCULeft;           ///< pointer of left CU
172  TComDataCU*   m_apcCUColocated[2];  ///< pointer of temporally colocated CU's for both directions
173  TComMvField   m_cMvFieldA;          ///< motion vector of position A
174  TComMvField   m_cMvFieldB;          ///< motion vector of position B
175  TComMvField   m_cMvFieldC;          ///< motion vector of position C
176  TComMv        m_cMvPred;            ///< motion vector predictor
177 
178  // -------------------------------------------------------------------------------------------------------------------
179  // coding tool information
180  // -------------------------------------------------------------------------------------------------------------------
181 
182  Bool*         m_pbMergeFlag;        ///< array of merge flags
183  UChar*        m_puhMergeIndex;      ///< array of merge candidate indices
184#if AMP_MRG
185  Bool          m_bIsMergeAMP;
186#endif
187  UChar*        m_puhLumaIntraDir;    ///< array of intra directions (luma)
188  UChar*        m_puhChromaIntraDir;  ///< array of intra directions (chroma)
189  UChar*        m_puhInterDir;        ///< array of inter directions
190  Char*         m_apiMVPIdx[2];       ///< array of motion vector predictor candidates
191  Char*         m_apiMVPNum[2];       ///< array of number of possible motion vectors predictors
192  Bool*         m_pbIPCMFlag;         ///< array of intra_pcm flags
193#if H_3D_NBDV
194  DisInfo*      m_pDvInfo;
195#endif
196#if H_3D_VSP
197  Char*         m_piVSPFlag;          ///< array of VSP flags to indicate whehter a block uses VSP or not
198                                      ///< 0: non-VSP; 1: VSP
199#endif
200#if H_3D_ARP
201  UChar*        m_puhARPW;
202#endif
203#if H_3D_IC
204  Bool*         m_pbICFlag;           ///< array of IC flags
205#endif
206#if H_3D_DIM
207  Pel*          m_dimDeltaDC[DIM_NUM_TYPE][2];
208#if H_3D_DIM_DMM
209  UInt*         m_dmmWedgeTabIdx[DMM_NUM_TYPE]; 
210  Int*          m_dmm2DeltaEnd;
211  UInt*         m_dmm3IntraTabIdx;
212#endif
213#if H_3D_DIM_RBC
214  UChar*        m_pucEdgeCode;          ///< array of edge code
215  UChar*        m_pucEdgeNumber;        ///< total number of edge
216  UChar*        m_pucEdgeStartPos;      ///< starting point position
217  Bool*         m_pbEdgeLeftFirst;      ///< true if edge should be checked in left boundary first
218  Bool*         m_pbEdgePartition;      ///< true if it belongs to region 1, otherwise, region 0
219#endif
220#if H_3D_DIM_SDC
221  Bool*         m_pbSDCFlag;
222  Pel*          m_apSegmentDCOffset[2];
223#endif
224#endif
225
226  // -------------------------------------------------------------------------------------------------------------------
227  // misc. variables
228  // -------------------------------------------------------------------------------------------------------------------
229 
230  Bool          m_bDecSubCu;          ///< indicates decoder-mode
231  Double        m_dTotalCost;         ///< sum of partition RD costs
232#if H_3D_VSO
233  Dist          m_uiTotalDistortion;  ///< sum of partition distortion
234#else
235  UInt          m_uiTotalDistortion;  ///< sum of partition distortion
236#endif
237  UInt          m_uiTotalBits;        ///< sum of partition bits
238  UInt          m_uiTotalBins;       ///< sum of partition bins
239  UInt*         m_sliceStartCU;    ///< Start CU address of current slice
240  UInt*         m_sliceSegmentStartCU; ///< Start CU address of current slice
241  Char          m_codedQP;
242protected:
243 
244  /// add possible motion vector predictor candidates
245  Bool          xAddMVPCand           ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
246  Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
247#if H_3D_VSP
248  Bool          xAddVspCand( UChar ucVspMergePos, Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
249                             Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag );
250#endif
251
252  Void          deriveRightBottomIdx        ( UInt uiPartIdx, UInt& ruiPartIdxRB );
253  Bool          xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx
254#if H_3D_TMVP
255  ,
256  Bool bMRG = true
257#endif
258  );
259 
260  /// compute required bits to encode MVD (used in AMVP)
261  UInt          xGetMvdBits           ( TComMv cMvd );
262  UInt          xGetComponentBits     ( Int iVal );
263 
264  /// compute scaling factor from POC difference
265#if !H_3D_ARP
266  Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
267#endif
268
269  Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter );
270
271public:
272  TComDataCU();
273  virtual ~TComDataCU();
274 
275  // -------------------------------------------------------------------------------------------------------------------
276  // create / destroy / initialize / copy
277  // -------------------------------------------------------------------------------------------------------------------
278#if H_3D_ARP
279  Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
280#endif
281  Void          create                ( UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize
282#if ADAPTIVE_QP_SELECTION
283    , Bool bGlobalRMARLBuffer = false
284#endif 
285    );
286  Void          destroy               ();
287 
288  Void          initCU                ( TComPic* pcPic, UInt uiCUAddr );
289  Void          initEstData           ( UInt uiDepth, Int qp );
290  Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
291  Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
292#if H_3D_NBDV
293  Void          copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx);
294#endif
295  Void          copySubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
296  Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList
297#if H_3D_NBDV
298  , Bool bNBDV = false
299#endif
300  );
301  Void          copyPartFrom          ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
302 
303  Void          copyToPic             ( UChar uiDepth );
304  Void          copyToPic             ( UChar uiDepth, UInt uiPartIdx, UInt uiPartDepth );
305 
306  // -------------------------------------------------------------------------------------------------------------------
307  // member functions for CU description
308  // -------------------------------------------------------------------------------------------------------------------
309 
310  TComPic*      getPic                ()                        { return m_pcPic;           }
311  TComSlice*    getSlice              ()                        { return m_pcSlice;         }
312  UInt&         getAddr               ()                        { return m_uiCUAddr;        }
313  UInt&         getZorderIdxInCU      ()                        { return m_uiAbsIdxInLCU; }
314  UInt          getSCUAddr            ();
315  UInt          getCUPelX             ()                        { return m_uiCUPelX;        }
316  UInt          getCUPelY             ()                        { return m_uiCUPelY;        }
317  TComPattern*  getPattern            ()                        { return m_pcPattern;       }
318 
319  UChar*        getDepth              ()                        { return m_puhDepth;        }
320  UChar         getDepth              ( UInt uiIdx )            { return m_puhDepth[uiIdx]; }
321  Void          setDepth              ( UInt uiIdx, UChar  uh ) { m_puhDepth[uiIdx] = uh;   }
322 
323  Void          setDepthSubParts      ( UInt uiDepth, UInt uiAbsPartIdx );
324#if H_3D
325  Void          getPosInPic           ( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY );
326#endif
327 
328  // -------------------------------------------------------------------------------------------------------------------
329  // member functions for CU data
330  // -------------------------------------------------------------------------------------------------------------------
331 
332  Char*         getPartitionSize      ()                        { return m_pePartSize;        }
333  PartSize      getPartitionSize      ( UInt uiIdx )            { return static_cast<PartSize>( m_pePartSize[uiIdx] ); }
334  Void          setPartitionSize      ( UInt uiIdx, PartSize uh){ m_pePartSize[uiIdx] = uh;   }
335  Void          setPartSizeSubParts   ( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth );
336  Void          setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth );
337 
338  Bool*        getSkipFlag            ()                        { return m_skipFlag;          }
339  Bool         getSkipFlag            (UInt idx)                { return m_skipFlag[idx];     }
340  Void         setSkipFlag           ( UInt idx, Bool skip)     { m_skipFlag[idx] = skip;   }
341  Void         setSkipFlagSubParts   ( Bool skip, UInt absPartIdx, UInt depth );
342
343  Char*         getPredictionMode     ()                        { return m_pePredMode;        }
344  PredMode      getPredictionMode     ( UInt uiIdx )            { return static_cast<PredMode>( m_pePredMode[uiIdx] ); }
345  Bool*         getCUTransquantBypass ()                        { return m_CUTransquantBypass;        }
346  Bool          getCUTransquantBypass( UInt uiIdx )             { return m_CUTransquantBypass[uiIdx]; }
347  Void          setPredictionMode     ( UInt uiIdx, PredMode uh){ m_pePredMode[uiIdx] = uh;   }
348  Void          setPredModeSubParts   ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );
349 
350  UChar*        getWidth              ()                        { return m_puhWidth;          }
351  UChar         getWidth              ( UInt uiIdx )            { return m_puhWidth[uiIdx];   }
352  Void          setWidth              ( UInt uiIdx, UChar  uh ) { m_puhWidth[uiIdx] = uh;     }
353 
354  UChar*        getHeight             ()                        { return m_puhHeight;         }
355  UChar         getHeight             ( UInt uiIdx )            { return m_puhHeight[uiIdx];  }
356  Void          setHeight             ( UInt uiIdx, UChar  uh ) { m_puhHeight[uiIdx] = uh;    }
357 
358  Void          setSizeSubParts       ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth );
359 
360  Char*         getQP                 ()                        { return m_phQP;              }
361  Char          getQP                 ( UInt uiIdx )            { return m_phQP[uiIdx];       }
362  Void          setQP                 ( UInt uiIdx, Char value ){ m_phQP[uiIdx] =  value;     }
363  Void          setQPSubParts         ( Int qp,   UInt uiAbsPartIdx, UInt uiDepth );
364  Int           getLastValidPartIdx   ( Int iAbsPartIdx );
365  Char          getLastCodedQP        ( UInt uiAbsPartIdx );
366  Void          setQPSubCUs           ( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf );
367  Void          setCodedQP            ( Char qp )               { m_codedQP = qp;             }
368  Char          getCodedQP            ()                        { return m_codedQP;           }
369
370  Bool          isLosslessCoded(UInt absPartIdx);
371 
372  UChar*        getTransformIdx       ()                        { return m_puhTrIdx;          }
373  UChar         getTransformIdx       ( UInt uiIdx )            { return m_puhTrIdx[uiIdx];   }
374  Void          setTrIdxSubParts      ( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth );
375
376  UChar*        getTransformSkip      ( TextType eType)    { return m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]];}
377  UChar         getTransformSkip      ( UInt uiIdx,TextType eType)    { return m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]][uiIdx];}
378  Void          setTransformSkipSubParts  ( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth); 
379  Void          setTransformSkipSubParts  ( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth );
380
381  UInt          getQuadtreeTULog2MinSizeInCU( UInt absPartIdx );
382 
383  TComCUMvField* getCUMvField         ( RefPicList e )          { return  &m_acCUMvField[e];  }
384 
385  TCoeff*&      getCoeffY             ()                        { return m_pcTrCoeffY;        }
386  TCoeff*&      getCoeffCb            ()                        { return m_pcTrCoeffCb;       }
387  TCoeff*&      getCoeffCr            ()                        { return m_pcTrCoeffCr;       }
388#if ADAPTIVE_QP_SELECTION
389  Int*&         getArlCoeffY          ()                        { return m_pcArlCoeffY;       }
390  Int*&         getArlCoeffCb         ()                        { return m_pcArlCoeffCb;      }
391  Int*&         getArlCoeffCr         ()                        { return m_pcArlCoeffCr;      }
392#endif
393 
394  Pel*&         getPCMSampleY         ()                        { return m_pcIPCMSampleY;     }
395  Pel*&         getPCMSampleCb        ()                        { return m_pcIPCMSampleCb;    }
396  Pel*&         getPCMSampleCr        ()                        { return m_pcIPCMSampleCr;    }
397
398  UChar         getCbf    ( UInt uiIdx, TextType eType )                  { return m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx];  }
399  UChar*        getCbf    ( TextType eType )                              { return m_puhCbf[g_aucConvertTxtTypeToIdx[eType]];         }
400  UChar         getCbf    ( UInt uiIdx, TextType eType, UInt uiTrDepth )  { return ( ( getCbf( uiIdx, eType ) >> uiTrDepth ) & 0x1 ); }
401  Void          setCbf    ( UInt uiIdx, TextType eType, UChar uh )        { m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx] = uh;    }
402  Void          clearCbf  ( UInt uiIdx, TextType eType, UInt uiNumParts );
403  UChar         getQtRootCbf          ( UInt uiIdx )                      { return getCbf( uiIdx, TEXT_LUMA, 0 ) || getCbf( uiIdx, TEXT_CHROMA_U, 0 ) || getCbf( uiIdx, TEXT_CHROMA_V, 0 ); }
404 
405  Void          setCbfSubParts        ( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth          );
406  Void          setCbfSubParts        ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth                    );
407  Void          setCbfSubParts        ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth    );
408 
409  // -------------------------------------------------------------------------------------------------------------------
410  // member functions for coding tool information
411  // -------------------------------------------------------------------------------------------------------------------
412 
413  Bool*         getMergeFlag          ()                        { return m_pbMergeFlag;               }
414  Bool          getMergeFlag          ( UInt uiIdx )            { return m_pbMergeFlag[uiIdx];        }
415  Void          setMergeFlag          ( UInt uiIdx, Bool b )    { m_pbMergeFlag[uiIdx] = b;           }
416  Void          setMergeFlagSubParts  ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
417
418  UChar*        getMergeIndex         ()                        { return m_puhMergeIndex;                         }
419  UChar         getMergeIndex         ( UInt uiIdx )            { return m_puhMergeIndex[uiIdx];                  }
420  Void          setMergeIndex         ( UInt uiIdx, UInt uiMergeIndex ) { m_puhMergeIndex[uiIdx] = uiMergeIndex;  }
421  Void          setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
422  template <typename T>
423  Void          setSubPart            ( T bParameter, T* pbBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
424
425#if AMP_MRG
426  Void          setMergeAMP( Bool b )      { m_bIsMergeAMP = b; }
427  Bool          getMergeAMP( )             { return m_bIsMergeAMP; }
428#endif
429
430  UChar*        getLumaIntraDir       ()                        { return m_puhLumaIntraDir;           }
431  UChar         getLumaIntraDir       ( UInt uiIdx )            { return m_puhLumaIntraDir[uiIdx];    }
432  Void          setLumaIntraDir       ( UInt uiIdx, UChar  uh ) { m_puhLumaIntraDir[uiIdx] = uh;      }
433  Void          setLumaIntraDirSubParts( UInt uiDir,  UInt uiAbsPartIdx, UInt uiDepth );
434 
435  UChar*        getChromaIntraDir     ()                        { return m_puhChromaIntraDir;         }
436  UChar         getChromaIntraDir     ( UInt uiIdx )            { return m_puhChromaIntraDir[uiIdx];  }
437  Void          setChromaIntraDir     ( UInt uiIdx, UChar  uh ) { m_puhChromaIntraDir[uiIdx] = uh;    }
438  Void          setChromIntraDirSubParts( UInt uiDir,  UInt uiAbsPartIdx, UInt uiDepth );
439 
440  UChar*        getInterDir           ()                        { return m_puhInterDir;               }
441  UChar         getInterDir           ( UInt uiIdx )            { return m_puhInterDir[uiIdx];        }
442  Void          setInterDir           ( UInt uiIdx, UChar  uh ) { m_puhInterDir[uiIdx] = uh;          }
443  Void          setInterDirSubParts   ( UInt uiDir,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
444  Bool*         getIPCMFlag           ()                        { return m_pbIPCMFlag;               }
445  Bool          getIPCMFlag           (UInt uiIdx )             { return m_pbIPCMFlag[uiIdx];        }
446  Void          setIPCMFlag           (UInt uiIdx, Bool b )     { m_pbIPCMFlag[uiIdx] = b;           }
447  Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
448#if H_3D_NBDV
449  Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth );
450  DisInfo*      getDvInfo             ()                        { return m_pDvInfo;                 }
451  DisInfo       getDvInfo             (UInt uiIdx)              { return m_pDvInfo[uiIdx];          }
452#endif
453  /// get slice ID for SU
454  Int           getSUSliceID          (UInt uiIdx)              {return m_piSliceSUMap[uiIdx];      } 
455
456  /// get the pointer of slice ID map
457  Int*          getSliceSUMap         ()                        {return m_piSliceSUMap;             }
458
459  /// set the pointer of slice ID map
460  Void          setSliceSUMap         (Int *pi)                 {m_piSliceSUMap = pi;               }
461
462  std::vector<NDBFBlockInfo>* getNDBFilterBlocks()      {return &m_vNDFBlock;}
463  Void setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt numLCUInPicHeight, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight
464                                          ,std::vector<Bool>& LFCrossSliceBoundary
465                                          ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary
466                                          ,Bool bIndependentTileBoundaryEnabled );
467#if H_3D_NBDV
468  Void          xDeriveRightBottomNbIdx(Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
469  Bool          xCheckSpatialNBDV (TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paMvpDvInfo,
470                                   UInt uiMvpDvPos
471#if H_3D_NBDV_REF
472  , Bool bDepthRefine = false
473#endif
474  );
475  Bool          xGetColDisMV      ( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
476  Bool          getDisMvpCandNBDV ( DisInfo* pDInfo
477#if H_3D_NBDV_REF
478   , Bool bDepthRefine = false
479#endif
480   ); 
481   
482#if H_3D_NBDV_REF
483  Pel           getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT );
484  Void          estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred );
485#endif //H_3D_NBDV_REF
486#endif
487#if  MTK_FAST_TEXTURE_ENCODING_E0173
488  Void          getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge,  Int& iIVFMaxD);
489#endif
490#if H_3D_IV_MERGE
491  Bool          getInterViewMergeCands          ( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc );   
492#endif
493#if H_3D_ARP
494  UChar*        getARPW            ()                        { return m_puhARPW;               }
495  UChar         getARPW            ( UInt uiIdx )            { return m_puhARPW[uiIdx];        }
496  Void          setARPW            ( UInt uiIdx, UChar w )   { m_puhARPW[uiIdx] = w;           }
497  Void          setARPWSubParts    ( UChar w, UInt uiAbsPartIdx, UInt uiDepth );
498  Double        getARPWFactor      ( UInt uiIdx );
499#endif
500#if H_3D_IC
501  Bool*         getICFlag          ()                        { return m_pbICFlag;               }
502  Bool          getICFlag          ( UInt uiIdx )            { return m_pbICFlag[uiIdx];        }
503  Void          setICFlag          ( UInt uiIdx, Bool  uh )  { m_pbICFlag[uiIdx] = uh;          }
504  Void          setICFlagSubParts  ( Bool bICFlag,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
505  Bool          isICFlagRequired   ( UInt uiAbsPartIdx );
506  Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false);
507#else
508  // -------------------------------------------------------------------------------------------------------------------
509  // member functions for accessing partition information
510  // -------------------------------------------------------------------------------------------------------------------
511 
512  Void          getPartIndexAndSize   ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight );
513#endif
514  UChar         getNumPartInter       ();
515  Bool          isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth);
516
517#if H_3D_DIM
518  Pel*  getDimDeltaDC                 ( UInt dimType, UInt segId )                      { return m_dimDeltaDC[dimType][segId];        } 
519  Pel   getDimDeltaDC                 ( UInt dimType, UInt segId, UInt uiIdx )          { return m_dimDeltaDC[dimType][segId][uiIdx]; } 
520  Void  setDimDeltaDC                 ( UInt dimType, UInt segId, UInt uiIdx, Pel val ) { m_dimDeltaDC[dimType][segId][uiIdx] = val;  }
521#if H_3D_DIM_DMM
522  UInt* getDmmWedgeTabIdx             ( UInt dmmType )                          { return m_dmmWedgeTabIdx[dmmType];          }       
523  UInt  getDmmWedgeTabIdx             ( UInt dmmType, UInt uiIdx )              { return m_dmmWedgeTabIdx[dmmType][uiIdx];   }
524  Void  setDmmWedgeTabIdx             ( UInt dmmType, UInt uiIdx, UInt tabIdx ) { m_dmmWedgeTabIdx[dmmType][uiIdx] = tabIdx; }
525  Void  setDmmWedgeTabIdxSubParts     ( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth );
526
527  Int*  getDmm2DeltaEnd               ()                      { return m_dmm2DeltaEnd;        }
528  Int   getDmm2DeltaEnd               ( UInt uiIdx )          { return m_dmm2DeltaEnd[uiIdx]; }
529  Void  setDmm2DeltaEnd               ( UInt uiIdx, Int iD )  { m_dmm2DeltaEnd[uiIdx] = iD;   }
530  Void  setDmm2DeltaEndSubParts       ( Int iDelta, UInt uiAbsPartIdx, UInt uiDepth );
531
532  UInt* getDmm3IntraTabIdx            ()                      { return m_dmm3IntraTabIdx;        }
533  UInt  getDmm3IntraTabIdx            ( UInt uiIdx )          { return m_dmm3IntraTabIdx[uiIdx]; }
534  Void  setDmm3IntraTabIdx            ( UInt uiIdx, UInt uh ) { m_dmm3IntraTabIdx[uiIdx] = uh;   }
535  Void  setDmm3IntraTabIdxSubParts    ( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth );
536#endif
537#if H_3D_DIM_RBC
538  UChar* getEdgeCode( UInt uiIdx )                 { return &m_pucEdgeCode[uiIdx * RBC_MAX_EDGE_NUM_PER_4x4]; }
539
540  UChar* getEdgeNumber( )                          { return m_pucEdgeNumber;           }
541  UChar  getEdgeNumber( UInt uiIdx )               { return m_pucEdgeNumber[uiIdx];    }
542  Void   setEdgeNumber( UInt uiIdx, UChar val )    { m_pucEdgeNumber[uiIdx] = val;     }
543
544  UChar* getEdgeStartPos( )                        { return m_pucEdgeStartPos;         }
545  UChar  getEdgeStartPos( UInt uiIdx )             { return m_pucEdgeStartPos[uiIdx];  }
546  Void   setEdgeStartPos( UInt uiIdx, UChar val )  { m_pucEdgeStartPos[uiIdx] = val;   }
547
548  Bool*  getEdgeLeftFirst( )                       { return m_pbEdgeLeftFirst;         }
549  Bool   getEdgeLeftFirst( UInt uiIdx )            { return m_pbEdgeLeftFirst[uiIdx];  }
550  Void   setEdgeLeftFirst( UInt uiIdx, Bool val )  { m_pbEdgeLeftFirst[uiIdx] = val;   }
551
552  Bool*  getEdgePartition( UInt uiIdx )            { return &m_pbEdgePartition[uiIdx * 16]; }
553
554  Void   reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion );
555#endif
556#if H_3D_DIM_SDC
557  Bool*         getSDCFlag          ()                        { return m_pbSDCFlag;               }
558  Bool          getSDCFlag          ( UInt uiIdx )            { return m_pbSDCFlag[uiIdx];        }
559  Void          setSDCFlagSubParts  ( Bool bSDCFlag, UInt uiAbsPartIdx, UInt uiDepth );
560 
561  Bool          getSDCAvailable             ( UInt uiAbsPartIdx );
562 
563  Pel*          getSDCSegmentDCOffset( UInt uiSeg ) { return m_apSegmentDCOffset[uiSeg]; }
564  Pel           getSDCSegmentDCOffset( UInt uiSeg, UInt uiPartIdx ) { return m_apSegmentDCOffset[uiSeg][uiPartIdx]; }
565  Void          setSDCSegmentDCOffset( Pel pOffset, UInt uiSeg, UInt uiPartIdx) { m_apSegmentDCOffset[uiSeg][uiPartIdx] = pOffset; }
566#endif
567#endif
568 
569  // -------------------------------------------------------------------------------------------------------------------
570  // member functions for motion vector
571  // -------------------------------------------------------------------------------------------------------------------
572 
573  Void          getMvField            ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField );
574 
575  Void          fillMvpCand           ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo );
576  Bool          isDiffMER             ( Int xN, Int yN, Int xP, Int yP);
577  Void          getPartPosition       ( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH);
578  Void          setMVPIdx             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPIdx)  { m_apiMVPIdx[eRefPicList][uiIdx] = iMVPIdx;  }
579  Int           getMVPIdx             ( RefPicList eRefPicList, UInt uiIdx)               { return m_apiMVPIdx[eRefPicList][uiIdx];     }
580  Char*         getMVPIdx             ( RefPicList eRefPicList )                          { return m_apiMVPIdx[eRefPicList];            }
581
582  Void          setMVPNum             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPNum ) { m_apiMVPNum[eRefPicList][uiIdx] = iMVPNum;  }
583  Int           getMVPNum             ( RefPicList eRefPicList, UInt uiIdx )              { return m_apiMVPNum[eRefPicList][uiIdx];     }
584  Char*         getMVPNum             ( RefPicList eRefPicList )                          { return m_apiMVPNum[eRefPicList];            }
585 
586  Void          setMVPIdxSubParts     ( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
587  Void          setMVPNumSubParts     ( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
588 
589  Void          clipMv                ( TComMv&     rcMv     );
590  Void          getMvPredLeft         ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldA.getMv(); }
591  Void          getMvPredAbove        ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldB.getMv(); }
592  Void          getMvPredAboveRight   ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldC.getMv(); }
593#if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
594  Void          compressMV            (int scale);
595#else           
596  Void          compressMV            ();
597#endif 
598  // -------------------------------------------------------------------------------------------------------------------
599  // utility functions for neighbouring information
600  // -------------------------------------------------------------------------------------------------------------------
601 
602  TComDataCU*   getCULeft                   () { return m_pcCULeft;       }
603  TComDataCU*   getCUAbove                  () { return m_pcCUAbove;      }
604  TComDataCU*   getCUAboveLeft              () { return m_pcCUAboveLeft;  }
605  TComDataCU*   getCUAboveRight             () { return m_pcCUAboveRight; }
606  TComDataCU*   getCUColocated              ( RefPicList eRefPicList ) { return m_apcCUColocated[eRefPicList]; }
607
608
609  TComDataCU*   getPULeft                   ( UInt&  uiLPartUnitIdx, 
610                                              UInt uiCurrPartUnitIdx, 
611                                              Bool bEnforceSliceRestriction=true, 
612                                              Bool bEnforceTileRestriction=true );
613  TComDataCU*   getPUAbove                  ( UInt&  uiAPartUnitIdx,
614                                              UInt uiCurrPartUnitIdx, 
615                                              Bool bEnforceSliceRestriction=true, 
616                                              Bool planarAtLCUBoundary = false,
617                                              Bool bEnforceTileRestriction=true );
618  TComDataCU*   getPUAboveLeft              ( UInt&  uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );
619  TComDataCU*   getPUAboveRight             ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );
620  TComDataCU*   getPUBelowLeft              ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );
621
622  TComDataCU*   getQpMinCuLeft              ( UInt&  uiLPartUnitIdx , UInt uiCurrAbsIdxInLCU );
623  TComDataCU*   getQpMinCuAbove             ( UInt&  aPartUnitIdx , UInt currAbsIdxInLCU );
624  Char          getRefQP                    ( UInt   uiCurrAbsIdxInLCU                       );
625
626  TComDataCU*   getPUAboveRightAdi          ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );
627  TComDataCU*   getPUBelowLeftAdi           ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );
628 
629  Void          deriveLeftRightTopIdx       ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
630  Void          deriveLeftBottomIdx         ( UInt uiPartIdx, UInt& ruiPartIdxLB );
631 
632  Void          deriveLeftRightTopIdxAdi    ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth );
633  Void          deriveLeftBottomIdxAdi      ( UInt& ruiPartIdxLB, UInt  uiPartOffset, UInt uiPartDepth );
634 
635  Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
636  Void          getInterMergeCandidates     ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
637#if H_3D_VSP
638                                            , Int* vspFlag
639#endif
640                                            , Int& numValidMergeCand, Int mrgCandIdx = -1 );
641#if H_3D_VSP
642  Char*         getVSPFlag        ()                        { return m_piVSPFlag;          }
643  Char          getVSPFlag        ( UInt uiIdx )            { return m_piVSPFlag[uiIdx];   }
644  Void          setVSPFlag        ( UInt uiIdx, Int n )     { m_piVSPFlag[uiIdx] = n;      }
645  Void          setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
646#endif
647  Void          deriveLeftRightTopIdxGeneral  ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
648  Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
649 
650 
651  // -------------------------------------------------------------------------------------------------------------------
652  // member functions for modes
653  // -------------------------------------------------------------------------------------------------------------------
654 
655  Bool          isIntra   ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; }
656  Bool          isSkipped ( UInt uiPartIdx );                                                     ///< SKIP (no residual)
657  Bool          isBipredRestriction( UInt puIdx );
658
659  // -------------------------------------------------------------------------------------------------------------------
660  // member functions for symbol prediction (most probable / mode conversion)
661  // -------------------------------------------------------------------------------------------------------------------
662 
663  UInt          getIntraSizeIdx                 ( UInt uiAbsPartIdx                                       );
664 
665  Void          getAllowedChromaDir             ( UInt uiAbsPartIdx, UInt* uiModeList );
666  Int           getIntraDirLumaPredictor        ( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode = NULL );
667 
668  // -------------------------------------------------------------------------------------------------------------------
669  // member functions for SBAC context
670  // -------------------------------------------------------------------------------------------------------------------
671 
672  UInt          getCtxSplitFlag                 ( UInt   uiAbsPartIdx, UInt uiDepth                   );
673  UInt          getCtxQtCbf                     ( TextType eType, UInt uiTrDepth );
674
675  UInt          getCtxSkipFlag                  ( UInt   uiAbsPartIdx                                 );
676  UInt          getCtxInterDir                  ( UInt   uiAbsPartIdx                                 );
677 
678#if H_3D_ARP
679  UInt          getCTXARPWFlag                  ( UInt   uiAbsPartIdx                                 );
680#endif 
681#if H_3D_IC
682  UInt          getCtxICFlag                    ( UInt   uiAbsPartIdx                                 );
683#endif
684  UInt          getSliceStartCU         ( UInt pos )                  { return m_sliceStartCU[pos-m_uiAbsIdxInLCU];                                                                                          }
685  UInt          getSliceSegmentStartCU  ( UInt pos )                  { return m_sliceSegmentStartCU[pos-m_uiAbsIdxInLCU];                                                                                   }
686  UInt&         getTotalBins            ()                            { return m_uiTotalBins;                                                                                                  }
687  // -------------------------------------------------------------------------------------------------------------------
688  // member functions for RD cost storage
689  // -------------------------------------------------------------------------------------------------------------------
690 
691  Double&       getTotalCost()                  { return m_dTotalCost;        }
692#if H_3D_VSO
693  Dist&         getTotalDistortion()            { return m_uiTotalDistortion; }
694#else
695  UInt&         getTotalDistortion()            { return m_uiTotalDistortion; }
696#endif
697  UInt&         getTotalBits()                  { return m_uiTotalBits;       }
698  UInt&         getTotalNumPart()               { return m_uiNumPartition;    }
699
700  UInt          getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra);
701
702};
703
704namespace RasterAddress
705{
706  /** Check whether 2 addresses point to the same column
707   * \param addrA          First address in raster scan order
708   * \param addrB          Second address in raters scan order
709   * \param numUnitsPerRow Number of units in a row
710   * \return Result of test
711   */
712  static inline Bool isEqualCol( Int addrA, Int addrB, Int numUnitsPerRow )
713  {
714    // addrA % numUnitsPerRow == addrB % numUnitsPerRow
715    return (( addrA ^ addrB ) &  ( numUnitsPerRow - 1 ) ) == 0;
716  }
717 
718  /** Check whether 2 addresses point to the same row
719   * \param addrA          First address in raster scan order
720   * \param addrB          Second address in raters scan order
721   * \param numUnitsPerRow Number of units in a row
722   * \return Result of test
723   */
724  static inline Bool isEqualRow( Int addrA, Int addrB, Int numUnitsPerRow )
725  {
726    // addrA / numUnitsPerRow == addrB / numUnitsPerRow
727    return (( addrA ^ addrB ) &~ ( numUnitsPerRow - 1 ) ) == 0;
728  }
729 
730  /** Check whether 2 addresses point to the same row or column
731   * \param addrA          First address in raster scan order
732   * \param addrB          Second address in raters scan order
733   * \param numUnitsPerRow Number of units in a row
734   * \return Result of test
735   */
736  static inline Bool isEqualRowOrCol( Int addrA, Int addrB, Int numUnitsPerRow )
737  {
738    return isEqualCol( addrA, addrB, numUnitsPerRow ) | isEqualRow( addrA, addrB, numUnitsPerRow );
739  }
740 
741  /** Check whether one address points to the first column
742   * \param addr           Address in raster scan order
743   * \param numUnitsPerRow Number of units in a row
744   * \return Result of test
745   */
746  static inline Bool isZeroCol( Int addr, Int numUnitsPerRow )
747  {
748    // addr % numUnitsPerRow == 0
749    return ( addr & ( numUnitsPerRow - 1 ) ) == 0;
750  }
751 
752  /** Check whether one address points to the first row
753   * \param addr           Address in raster scan order
754   * \param numUnitsPerRow Number of units in a row
755   * \return Result of test
756   */
757  static inline Bool isZeroRow( Int addr, Int numUnitsPerRow )
758  {
759    // addr / numUnitsPerRow == 0
760    return ( addr &~ ( numUnitsPerRow - 1 ) ) == 0;
761  }
762 
763  /** Check whether one address points to a column whose index is smaller than a given value
764   * \param addr           Address in raster scan order
765   * \param val            Given column index value
766   * \param numUnitsPerRow Number of units in a row
767   * \return Result of test
768   */
769  static inline Bool lessThanCol( Int addr, Int val, Int numUnitsPerRow )
770  {
771    // addr % numUnitsPerRow < val
772    return ( addr & ( numUnitsPerRow - 1 ) ) < val;
773  }
774 
775  /** Check whether one address points to a row whose index is smaller than a given value
776   * \param addr           Address in raster scan order
777   * \param val            Given row index value
778   * \param numUnitsPerRow Number of units in a row
779   * \return Result of test
780   */
781  static inline Bool lessThanRow( Int addr, Int val, Int numUnitsPerRow )
782  {
783    // addr / numUnitsPerRow < val
784    return addr < val * numUnitsPerRow;
785  }
786};
787
788//! \}
789
790#endif
Note: See TracBrowser for help on using the repository browser.