source: 3DVCSoftware/branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.h @ 504

Last change on this file since 504 was 504, checked in by zhang, 11 years ago

Merge Dev2.a to Dev2 and simulation results updated

  • Property svn:eol-style set to native
File size: 39.0 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_ARP
197  UChar*        m_puhARPW;
198#endif
199#if H_3D_IC
200  Bool*         m_pbICFlag;           ///< array of IC flags
201#endif
202  // -------------------------------------------------------------------------------------------------------------------
203  // misc. variables
204  // -------------------------------------------------------------------------------------------------------------------
205 
206  Bool          m_bDecSubCu;          ///< indicates decoder-mode
207  Double        m_dTotalCost;         ///< sum of partition RD costs
208#if H_3D_VSO
209  Dist          m_uiTotalDistortion;  ///< sum of partition distortion
210#else
211  UInt          m_uiTotalDistortion;  ///< sum of partition distortion
212#endif
213  UInt          m_uiTotalBits;        ///< sum of partition bits
214  UInt          m_uiTotalBins;       ///< sum of partition bins
215  UInt*         m_sliceStartCU;    ///< Start CU address of current slice
216  UInt*         m_sliceSegmentStartCU; ///< Start CU address of current slice
217  Char          m_codedQP;
218protected:
219 
220  /// add possible motion vector predictor candidates
221  Bool          xAddMVPCand           ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
222  Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
223
224  Void          deriveRightBottomIdx        ( UInt uiPartIdx, UInt& ruiPartIdxRB );
225  Bool          xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx
226#if H_3D_TMVP
227  ,
228  Bool bMRG = true
229#endif
230  );
231 
232  /// compute required bits to encode MVD (used in AMVP)
233  UInt          xGetMvdBits           ( TComMv cMvd );
234  UInt          xGetComponentBits     ( Int iVal );
235 
236  /// compute scaling factor from POC difference
237#if !H_3D_ARP
238  Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
239#endif
240
241  Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter );
242
243public:
244  TComDataCU();
245  virtual ~TComDataCU();
246 
247  // -------------------------------------------------------------------------------------------------------------------
248  // create / destroy / initialize / copy
249  // -------------------------------------------------------------------------------------------------------------------
250#if H_3D_ARP
251  Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
252#endif
253  Void          create                ( UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize
254#if ADAPTIVE_QP_SELECTION
255    , Bool bGlobalRMARLBuffer = false
256#endif 
257    );
258  Void          destroy               ();
259 
260  Void          initCU                ( TComPic* pcPic, UInt uiCUAddr );
261  Void          initEstData           ( UInt uiDepth, Int qp );
262  Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
263  Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
264#if H_3D_NBDV
265  Void          copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx);
266#endif
267  Void          copySubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
268  Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList
269#if H_3D_NBDV
270  , Bool bNBDV = false
271#endif
272  );
273  Void          copyPartFrom          ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
274 
275  Void          copyToPic             ( UChar uiDepth );
276  Void          copyToPic             ( UChar uiDepth, UInt uiPartIdx, UInt uiPartDepth );
277 
278  // -------------------------------------------------------------------------------------------------------------------
279  // member functions for CU description
280  // -------------------------------------------------------------------------------------------------------------------
281 
282  TComPic*      getPic                ()                        { return m_pcPic;           }
283  TComSlice*    getSlice              ()                        { return m_pcSlice;         }
284  UInt&         getAddr               ()                        { return m_uiCUAddr;        }
285  UInt&         getZorderIdxInCU      ()                        { return m_uiAbsIdxInLCU; }
286  UInt          getSCUAddr            ();
287  UInt          getCUPelX             ()                        { return m_uiCUPelX;        }
288  UInt          getCUPelY             ()                        { return m_uiCUPelY;        }
289  TComPattern*  getPattern            ()                        { return m_pcPattern;       }
290 
291  UChar*        getDepth              ()                        { return m_puhDepth;        }
292  UChar         getDepth              ( UInt uiIdx )            { return m_puhDepth[uiIdx]; }
293  Void          setDepth              ( UInt uiIdx, UChar  uh ) { m_puhDepth[uiIdx] = uh;   }
294 
295  Void          setDepthSubParts      ( UInt uiDepth, UInt uiAbsPartIdx );
296#if H_3D
297  Void          getPosInPic           ( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY );
298#endif
299 
300  // -------------------------------------------------------------------------------------------------------------------
301  // member functions for CU data
302  // -------------------------------------------------------------------------------------------------------------------
303 
304  Char*         getPartitionSize      ()                        { return m_pePartSize;        }
305  PartSize      getPartitionSize      ( UInt uiIdx )            { return static_cast<PartSize>( m_pePartSize[uiIdx] ); }
306  Void          setPartitionSize      ( UInt uiIdx, PartSize uh){ m_pePartSize[uiIdx] = uh;   }
307  Void          setPartSizeSubParts   ( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth );
308  Void          setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth );
309 
310  Bool*        getSkipFlag            ()                        { return m_skipFlag;          }
311  Bool         getSkipFlag            (UInt idx)                { return m_skipFlag[idx];     }
312  Void         setSkipFlag           ( UInt idx, Bool skip)     { m_skipFlag[idx] = skip;   }
313  Void         setSkipFlagSubParts   ( Bool skip, UInt absPartIdx, UInt depth );
314
315  Char*         getPredictionMode     ()                        { return m_pePredMode;        }
316  PredMode      getPredictionMode     ( UInt uiIdx )            { return static_cast<PredMode>( m_pePredMode[uiIdx] ); }
317  Bool*         getCUTransquantBypass ()                        { return m_CUTransquantBypass;        }
318  Bool          getCUTransquantBypass( UInt uiIdx )             { return m_CUTransquantBypass[uiIdx]; }
319  Void          setPredictionMode     ( UInt uiIdx, PredMode uh){ m_pePredMode[uiIdx] = uh;   }
320  Void          setPredModeSubParts   ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );
321 
322  UChar*        getWidth              ()                        { return m_puhWidth;          }
323  UChar         getWidth              ( UInt uiIdx )            { return m_puhWidth[uiIdx];   }
324  Void          setWidth              ( UInt uiIdx, UChar  uh ) { m_puhWidth[uiIdx] = uh;     }
325 
326  UChar*        getHeight             ()                        { return m_puhHeight;         }
327  UChar         getHeight             ( UInt uiIdx )            { return m_puhHeight[uiIdx];  }
328  Void          setHeight             ( UInt uiIdx, UChar  uh ) { m_puhHeight[uiIdx] = uh;    }
329 
330  Void          setSizeSubParts       ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth );
331 
332  Char*         getQP                 ()                        { return m_phQP;              }
333  Char          getQP                 ( UInt uiIdx )            { return m_phQP[uiIdx];       }
334  Void          setQP                 ( UInt uiIdx, Char value ){ m_phQP[uiIdx] =  value;     }
335  Void          setQPSubParts         ( Int qp,   UInt uiAbsPartIdx, UInt uiDepth );
336  Int           getLastValidPartIdx   ( Int iAbsPartIdx );
337  Char          getLastCodedQP        ( UInt uiAbsPartIdx );
338  Void          setQPSubCUs           ( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf );
339  Void          setCodedQP            ( Char qp )               { m_codedQP = qp;             }
340  Char          getCodedQP            ()                        { return m_codedQP;           }
341
342  Bool          isLosslessCoded(UInt absPartIdx);
343 
344  UChar*        getTransformIdx       ()                        { return m_puhTrIdx;          }
345  UChar         getTransformIdx       ( UInt uiIdx )            { return m_puhTrIdx[uiIdx];   }
346  Void          setTrIdxSubParts      ( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth );
347
348  UChar*        getTransformSkip      ( TextType eType)    { return m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]];}
349  UChar         getTransformSkip      ( UInt uiIdx,TextType eType)    { return m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]][uiIdx];}
350  Void          setTransformSkipSubParts  ( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth); 
351  Void          setTransformSkipSubParts  ( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth );
352
353  UInt          getQuadtreeTULog2MinSizeInCU( UInt absPartIdx );
354 
355  TComCUMvField* getCUMvField         ( RefPicList e )          { return  &m_acCUMvField[e];  }
356 
357  TCoeff*&      getCoeffY             ()                        { return m_pcTrCoeffY;        }
358  TCoeff*&      getCoeffCb            ()                        { return m_pcTrCoeffCb;       }
359  TCoeff*&      getCoeffCr            ()                        { return m_pcTrCoeffCr;       }
360#if ADAPTIVE_QP_SELECTION
361  Int*&         getArlCoeffY          ()                        { return m_pcArlCoeffY;       }
362  Int*&         getArlCoeffCb         ()                        { return m_pcArlCoeffCb;      }
363  Int*&         getArlCoeffCr         ()                        { return m_pcArlCoeffCr;      }
364#endif
365 
366  Pel*&         getPCMSampleY         ()                        { return m_pcIPCMSampleY;     }
367  Pel*&         getPCMSampleCb        ()                        { return m_pcIPCMSampleCb;    }
368  Pel*&         getPCMSampleCr        ()                        { return m_pcIPCMSampleCr;    }
369
370  UChar         getCbf    ( UInt uiIdx, TextType eType )                  { return m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx];  }
371  UChar*        getCbf    ( TextType eType )                              { return m_puhCbf[g_aucConvertTxtTypeToIdx[eType]];         }
372  UChar         getCbf    ( UInt uiIdx, TextType eType, UInt uiTrDepth )  { return ( ( getCbf( uiIdx, eType ) >> uiTrDepth ) & 0x1 ); }
373  Void          setCbf    ( UInt uiIdx, TextType eType, UChar uh )        { m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx] = uh;    }
374  Void          clearCbf  ( UInt uiIdx, TextType eType, UInt uiNumParts );
375  UChar         getQtRootCbf          ( UInt uiIdx )                      { return getCbf( uiIdx, TEXT_LUMA, 0 ) || getCbf( uiIdx, TEXT_CHROMA_U, 0 ) || getCbf( uiIdx, TEXT_CHROMA_V, 0 ); }
376 
377  Void          setCbfSubParts        ( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth          );
378  Void          setCbfSubParts        ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth                    );
379  Void          setCbfSubParts        ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth    );
380 
381  // -------------------------------------------------------------------------------------------------------------------
382  // member functions for coding tool information
383  // -------------------------------------------------------------------------------------------------------------------
384 
385  Bool*         getMergeFlag          ()                        { return m_pbMergeFlag;               }
386  Bool          getMergeFlag          ( UInt uiIdx )            { return m_pbMergeFlag[uiIdx];        }
387  Void          setMergeFlag          ( UInt uiIdx, Bool b )    { m_pbMergeFlag[uiIdx] = b;           }
388  Void          setMergeFlagSubParts  ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
389
390  UChar*        getMergeIndex         ()                        { return m_puhMergeIndex;                         }
391  UChar         getMergeIndex         ( UInt uiIdx )            { return m_puhMergeIndex[uiIdx];                  }
392  Void          setMergeIndex         ( UInt uiIdx, UInt uiMergeIndex ) { m_puhMergeIndex[uiIdx] = uiMergeIndex;  }
393  Void          setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
394  template <typename T>
395  Void          setSubPart            ( T bParameter, T* pbBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
396
397#if AMP_MRG
398  Void          setMergeAMP( Bool b )      { m_bIsMergeAMP = b; }
399  Bool          getMergeAMP( )             { return m_bIsMergeAMP; }
400#endif
401
402  UChar*        getLumaIntraDir       ()                        { return m_puhLumaIntraDir;           }
403  UChar         getLumaIntraDir       ( UInt uiIdx )            { return m_puhLumaIntraDir[uiIdx];    }
404  Void          setLumaIntraDir       ( UInt uiIdx, UChar  uh ) { m_puhLumaIntraDir[uiIdx] = uh;      }
405  Void          setLumaIntraDirSubParts( UInt uiDir,  UInt uiAbsPartIdx, UInt uiDepth );
406 
407  UChar*        getChromaIntraDir     ()                        { return m_puhChromaIntraDir;         }
408  UChar         getChromaIntraDir     ( UInt uiIdx )            { return m_puhChromaIntraDir[uiIdx];  }
409  Void          setChromaIntraDir     ( UInt uiIdx, UChar  uh ) { m_puhChromaIntraDir[uiIdx] = uh;    }
410  Void          setChromIntraDirSubParts( UInt uiDir,  UInt uiAbsPartIdx, UInt uiDepth );
411 
412  UChar*        getInterDir           ()                        { return m_puhInterDir;               }
413  UChar         getInterDir           ( UInt uiIdx )            { return m_puhInterDir[uiIdx];        }
414  Void          setInterDir           ( UInt uiIdx, UChar  uh ) { m_puhInterDir[uiIdx] = uh;          }
415  Void          setInterDirSubParts   ( UInt uiDir,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
416  Bool*         getIPCMFlag           ()                        { return m_pbIPCMFlag;               }
417  Bool          getIPCMFlag           (UInt uiIdx )             { return m_pbIPCMFlag[uiIdx];        }
418  Void          setIPCMFlag           (UInt uiIdx, Bool b )     { m_pbIPCMFlag[uiIdx] = b;           }
419  Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
420#if H_3D_NBDV
421  Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth );
422  DisInfo*      getDvInfo             ()                        { return m_pDvInfo;                 }
423  DisInfo       getDvInfo             (UInt uiIdx)              { return m_pDvInfo[uiIdx];          }
424#endif
425  /// get slice ID for SU
426  Int           getSUSliceID          (UInt uiIdx)              {return m_piSliceSUMap[uiIdx];      } 
427
428  /// get the pointer of slice ID map
429  Int*          getSliceSUMap         ()                        {return m_piSliceSUMap;             }
430
431  /// set the pointer of slice ID map
432  Void          setSliceSUMap         (Int *pi)                 {m_piSliceSUMap = pi;               }
433
434  std::vector<NDBFBlockInfo>* getNDBFilterBlocks()      {return &m_vNDFBlock;}
435  Void setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt numLCUInPicHeight, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight
436                                          ,std::vector<Bool>& LFCrossSliceBoundary
437                                          ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary
438                                          ,Bool bIndependentTileBoundaryEnabled );
439#if H_3D_NBDV
440  Void          xDeriveRightBottomNbIdx(Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
441  Bool          xCheckSpatialNBDV (TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paMvpDvInfo,
442                                   UInt uiMvpDvPos
443#if H_3D_NBDV_REF
444  , Bool bDepthRefine = false
445#endif
446  );
447  Bool          xGetColDisMV      ( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
448  Bool          getDisMvpCandNBDV ( DisInfo* pDInfo
449#if H_3D_NBDV_REF
450   , Bool bDepthRefine = false
451#endif
452   ); 
453   
454#if H_3D_NBDV_REF
455  Pel           getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT );
456  Void          estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred );
457#endif //H_3D_NBDV_REF
458#endif
459#if H_3D_IV_MERGE
460  Bool          getInterViewMergeCands          ( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc );   
461#endif
462#if H_3D_ARP
463  UChar*        getARPW            ()                        { return m_puhARPW;               }
464  UChar         getARPW            ( UInt uiIdx )            { return m_puhARPW[uiIdx];        }
465  Void          setARPW            ( UInt uiIdx, UChar w )   { m_puhARPW[uiIdx] = w;           }
466  Void          setARPWSubParts    ( UChar w, UInt uiAbsPartIdx, UInt uiDepth );
467  Double        getARPWFactor      ( UInt uiIdx );
468#endif
469#if H_3D_IC
470  Bool*         getICFlag          ()                        { return m_pbICFlag;               }
471  Bool          getICFlag          ( UInt uiIdx )            { return m_pbICFlag[uiIdx];        }
472  Void          setICFlag          ( UInt uiIdx, Bool  uh )  { m_pbICFlag[uiIdx] = uh;          }
473  Void          setICFlagSubParts  ( Bool bICFlag,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
474  Bool          isICFlagRequired   ( UInt uiAbsPartIdx );
475  Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false);
476#else
477  // -------------------------------------------------------------------------------------------------------------------
478  // member functions for accessing partition information
479  // -------------------------------------------------------------------------------------------------------------------
480 
481  Void          getPartIndexAndSize   ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight );
482#endif
483  UChar         getNumPartInter       ();
484  Bool          isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth);
485 
486  // -------------------------------------------------------------------------------------------------------------------
487  // member functions for motion vector
488  // -------------------------------------------------------------------------------------------------------------------
489 
490  Void          getMvField            ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField );
491 
492  Void          fillMvpCand           ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo );
493  Bool          isDiffMER             ( Int xN, Int yN, Int xP, Int yP);
494  Void          getPartPosition       ( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH);
495  Void          setMVPIdx             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPIdx)  { m_apiMVPIdx[eRefPicList][uiIdx] = iMVPIdx;  }
496  Int           getMVPIdx             ( RefPicList eRefPicList, UInt uiIdx)               { return m_apiMVPIdx[eRefPicList][uiIdx];     }
497  Char*         getMVPIdx             ( RefPicList eRefPicList )                          { return m_apiMVPIdx[eRefPicList];            }
498
499  Void          setMVPNum             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPNum ) { m_apiMVPNum[eRefPicList][uiIdx] = iMVPNum;  }
500  Int           getMVPNum             ( RefPicList eRefPicList, UInt uiIdx )              { return m_apiMVPNum[eRefPicList][uiIdx];     }
501  Char*         getMVPNum             ( RefPicList eRefPicList )                          { return m_apiMVPNum[eRefPicList];            }
502 
503  Void          setMVPIdxSubParts     ( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
504  Void          setMVPNumSubParts     ( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
505 
506  Void          clipMv                ( TComMv&     rcMv     );
507  Void          getMvPredLeft         ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldA.getMv(); }
508  Void          getMvPredAbove        ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldB.getMv(); }
509  Void          getMvPredAboveRight   ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldC.getMv(); }
510 
511  Void          compressMV            ();
512 
513  // -------------------------------------------------------------------------------------------------------------------
514  // utility functions for neighbouring information
515  // -------------------------------------------------------------------------------------------------------------------
516 
517  TComDataCU*   getCULeft                   () { return m_pcCULeft;       }
518  TComDataCU*   getCUAbove                  () { return m_pcCUAbove;      }
519  TComDataCU*   getCUAboveLeft              () { return m_pcCUAboveLeft;  }
520  TComDataCU*   getCUAboveRight             () { return m_pcCUAboveRight; }
521  TComDataCU*   getCUColocated              ( RefPicList eRefPicList ) { return m_apcCUColocated[eRefPicList]; }
522
523
524  TComDataCU*   getPULeft                   ( UInt&  uiLPartUnitIdx, 
525                                              UInt uiCurrPartUnitIdx, 
526                                              Bool bEnforceSliceRestriction=true, 
527                                              Bool bEnforceTileRestriction=true );
528  TComDataCU*   getPUAbove                  ( UInt&  uiAPartUnitIdx,
529                                              UInt uiCurrPartUnitIdx, 
530                                              Bool bEnforceSliceRestriction=true, 
531                                              Bool planarAtLCUBoundary = false,
532                                              Bool bEnforceTileRestriction=true );
533  TComDataCU*   getPUAboveLeft              ( UInt&  uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );
534  TComDataCU*   getPUAboveRight             ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );
535  TComDataCU*   getPUBelowLeft              ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );
536
537  TComDataCU*   getQpMinCuLeft              ( UInt&  uiLPartUnitIdx , UInt uiCurrAbsIdxInLCU );
538  TComDataCU*   getQpMinCuAbove             ( UInt&  aPartUnitIdx , UInt currAbsIdxInLCU );
539  Char          getRefQP                    ( UInt   uiCurrAbsIdxInLCU                       );
540
541  TComDataCU*   getPUAboveRightAdi          ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );
542  TComDataCU*   getPUBelowLeftAdi           ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );
543 
544  Void          deriveLeftRightTopIdx       ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
545  Void          deriveLeftBottomIdx         ( UInt uiPartIdx, UInt& ruiPartIdxLB );
546 
547  Void          deriveLeftRightTopIdxAdi    ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth );
548  Void          deriveLeftBottomIdxAdi      ( UInt& ruiPartIdxLB, UInt  uiPartOffset, UInt uiPartDepth );
549 
550  Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
551  Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 );
552  Void          deriveLeftRightTopIdxGeneral  ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
553  Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
554 
555 
556  // -------------------------------------------------------------------------------------------------------------------
557  // member functions for modes
558  // -------------------------------------------------------------------------------------------------------------------
559 
560  Bool          isIntra   ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; }
561  Bool          isSkipped ( UInt uiPartIdx );                                                     ///< SKIP (no residual)
562  Bool          isBipredRestriction( UInt puIdx );
563
564  // -------------------------------------------------------------------------------------------------------------------
565  // member functions for symbol prediction (most probable / mode conversion)
566  // -------------------------------------------------------------------------------------------------------------------
567 
568  UInt          getIntraSizeIdx                 ( UInt uiAbsPartIdx                                       );
569 
570  Void          getAllowedChromaDir             ( UInt uiAbsPartIdx, UInt* uiModeList );
571  Int           getIntraDirLumaPredictor        ( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode = NULL );
572 
573  // -------------------------------------------------------------------------------------------------------------------
574  // member functions for SBAC context
575  // -------------------------------------------------------------------------------------------------------------------
576 
577  UInt          getCtxSplitFlag                 ( UInt   uiAbsPartIdx, UInt uiDepth                   );
578  UInt          getCtxQtCbf                     ( TextType eType, UInt uiTrDepth );
579
580  UInt          getCtxSkipFlag                  ( UInt   uiAbsPartIdx                                 );
581  UInt          getCtxInterDir                  ( UInt   uiAbsPartIdx                                 );
582 
583#if H_3D_ARP
584  UInt          getCTXARPWFlag                  ( UInt   uiAbsPartIdx                                 );
585#endif 
586#if H_3D_IC
587  UInt          getCtxICFlag                    ( UInt   uiAbsPartIdx                                 );
588#endif
589  UInt          getSliceStartCU         ( UInt pos )                  { return m_sliceStartCU[pos-m_uiAbsIdxInLCU];                                                                                          }
590  UInt          getSliceSegmentStartCU  ( UInt pos )                  { return m_sliceSegmentStartCU[pos-m_uiAbsIdxInLCU];                                                                                   }
591  UInt&         getTotalBins            ()                            { return m_uiTotalBins;                                                                                                  }
592  // -------------------------------------------------------------------------------------------------------------------
593  // member functions for RD cost storage
594  // -------------------------------------------------------------------------------------------------------------------
595 
596  Double&       getTotalCost()                  { return m_dTotalCost;        }
597#if H_3D_VSO
598  Dist&         getTotalDistortion()            { return m_uiTotalDistortion; }
599#else
600  UInt&         getTotalDistortion()            { return m_uiTotalDistortion; }
601#endif
602  UInt&         getTotalBits()                  { return m_uiTotalBits;       }
603  UInt&         getTotalNumPart()               { return m_uiNumPartition;    }
604
605  UInt          getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra);
606
607};
608
609namespace RasterAddress
610{
611  /** Check whether 2 addresses point to the same column
612   * \param addrA          First address in raster scan order
613   * \param addrB          Second address in raters scan order
614   * \param numUnitsPerRow Number of units in a row
615   * \return Result of test
616   */
617  static inline Bool isEqualCol( Int addrA, Int addrB, Int numUnitsPerRow )
618  {
619    // addrA % numUnitsPerRow == addrB % numUnitsPerRow
620    return (( addrA ^ addrB ) &  ( numUnitsPerRow - 1 ) ) == 0;
621  }
622 
623  /** Check whether 2 addresses point to the same row
624   * \param addrA          First address in raster scan order
625   * \param addrB          Second address in raters scan order
626   * \param numUnitsPerRow Number of units in a row
627   * \return Result of test
628   */
629  static inline Bool isEqualRow( Int addrA, Int addrB, Int numUnitsPerRow )
630  {
631    // addrA / numUnitsPerRow == addrB / numUnitsPerRow
632    return (( addrA ^ addrB ) &~ ( numUnitsPerRow - 1 ) ) == 0;
633  }
634 
635  /** Check whether 2 addresses point to the same row or column
636   * \param addrA          First address in raster scan order
637   * \param addrB          Second address in raters scan order
638   * \param numUnitsPerRow Number of units in a row
639   * \return Result of test
640   */
641  static inline Bool isEqualRowOrCol( Int addrA, Int addrB, Int numUnitsPerRow )
642  {
643    return isEqualCol( addrA, addrB, numUnitsPerRow ) | isEqualRow( addrA, addrB, numUnitsPerRow );
644  }
645 
646  /** Check whether one address points to the first column
647   * \param addr           Address in raster scan order
648   * \param numUnitsPerRow Number of units in a row
649   * \return Result of test
650   */
651  static inline Bool isZeroCol( Int addr, Int numUnitsPerRow )
652  {
653    // addr % numUnitsPerRow == 0
654    return ( addr & ( numUnitsPerRow - 1 ) ) == 0;
655  }
656 
657  /** Check whether one address points to the first row
658   * \param addr           Address in raster scan order
659   * \param numUnitsPerRow Number of units in a row
660   * \return Result of test
661   */
662  static inline Bool isZeroRow( Int addr, Int numUnitsPerRow )
663  {
664    // addr / numUnitsPerRow == 0
665    return ( addr &~ ( numUnitsPerRow - 1 ) ) == 0;
666  }
667 
668  /** Check whether one address points to a column whose index is smaller than a given value
669   * \param addr           Address in raster scan order
670   * \param val            Given column index value
671   * \param numUnitsPerRow Number of units in a row
672   * \return Result of test
673   */
674  static inline Bool lessThanCol( Int addr, Int val, Int numUnitsPerRow )
675  {
676    // addr % numUnitsPerRow < val
677    return ( addr & ( numUnitsPerRow - 1 ) ) < val;
678  }
679 
680  /** Check whether one address points to a row whose index is smaller than a given value
681   * \param addr           Address in raster scan order
682   * \param val            Given row index value
683   * \param numUnitsPerRow Number of units in a row
684   * \return Result of test
685   */
686  static inline Bool lessThanRow( Int addr, Int val, Int numUnitsPerRow )
687  {
688    // addr / numUnitsPerRow < val
689    return addr < val * numUnitsPerRow;
690  }
691};
692
693//! \}
694
695#endif
Note: See TracBrowser for help on using the repository browser.