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

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

Changes include: DV-MVP(H_3D_IDV), TMVP merging candidate(H_3D_TMVP, target reference index changes, scaling based on view order index) and cleanups (H_3D_CLEANUPS)

  • Property svn:eol-style set to native
File size: 37.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#include <algorithm>
52#include <vector>
53
54//! \ingroup TLibCommon
55//! \{
56
57// ====================================================================================================================
58// Non-deblocking in-loop filter processing block data structure
59// ====================================================================================================================
60
61/// Non-deblocking filter processing block border tag
62enum NDBFBlockBorderTag
63{
64  SGU_L = 0,
65  SGU_R,
66  SGU_T,
67  SGU_B,
68  SGU_TL,
69  SGU_TR,
70  SGU_BL,
71  SGU_BR,
72  NUM_SGU_BORDER
73};
74
75/// Non-deblocking filter processing block information
76struct NDBFBlockInfo
77{
78  Int   tileID;   //!< tile ID
79  Int   sliceID;  //!< slice ID
80  UInt  startSU;  //!< starting SU z-scan address in LCU
81  UInt  endSU;    //!< ending SU z-scan address in LCU
82  UInt  widthSU;  //!< number of SUs in width
83  UInt  heightSU; //!< number of SUs in height
84  UInt  posX;     //!< top-left X coordinate in picture
85  UInt  posY;     //!< top-left Y coordinate in picture
86  UInt  width;    //!< number of pixels in width
87  UInt  height;   //!< number of pixels in height
88  Bool  isBorderAvailable[NUM_SGU_BORDER];  //!< the border availabilities
89  Bool  allBordersAvailable;
90
91  NDBFBlockInfo():tileID(0), sliceID(0), startSU(0), endSU(0) {} //!< constructor
92  const NDBFBlockInfo& operator= (const NDBFBlockInfo& src);  //!< "=" operator
93};
94
95
96// ====================================================================================================================
97// Class definition
98// ====================================================================================================================
99
100/// CU data structure class
101class TComDataCU
102{
103private:
104 
105  // -------------------------------------------------------------------------------------------------------------------
106  // class pointers
107  // -------------------------------------------------------------------------------------------------------------------
108 
109  TComPic*      m_pcPic;              ///< picture class pointer
110  TComSlice*    m_pcSlice;            ///< slice header pointer
111  TComPattern*  m_pcPattern;          ///< neighbour access class pointer
112 
113  // -------------------------------------------------------------------------------------------------------------------
114  // CU description
115  // -------------------------------------------------------------------------------------------------------------------
116 
117  UInt          m_uiCUAddr;           ///< CU address in a slice
118  UInt          m_uiAbsIdxInLCU;      ///< absolute address in a CU. It's Z scan order
119  UInt          m_uiCUPelX;           ///< CU position in a pixel (X)
120  UInt          m_uiCUPelY;           ///< CU position in a pixel (Y)
121  UInt          m_uiNumPartition;     ///< total number of minimum partitions in a CU
122  UChar*        m_puhWidth;           ///< array of widths
123  UChar*        m_puhHeight;          ///< array of heights
124  UChar*        m_puhDepth;           ///< array of depths
125  Int           m_unitSize;           ///< size of a "minimum partition"
126 
127  // -------------------------------------------------------------------------------------------------------------------
128  // CU data
129  // -------------------------------------------------------------------------------------------------------------------
130  Bool*         m_skipFlag;           ///< array of skip flags
131  Char*         m_pePartSize;         ///< array of partition sizes
132  Char*         m_pePredMode;         ///< array of prediction modes
133  Bool*         m_CUTransquantBypass;   ///< array of cu_transquant_bypass flags
134  Char*         m_phQP;               ///< array of QP values
135  UChar*        m_puhTrIdx;           ///< array of transform indices
136  UChar*        m_puhTransformSkip[3];///< array of transform skipping flags
137  UChar*        m_puhCbf[3];          ///< array of coded block flags (CBF)
138  TComCUMvField m_acCUMvField[2];     ///< array of motion vectors
139  TCoeff*       m_pcTrCoeffY;         ///< transformed coefficient buffer (Y)
140  TCoeff*       m_pcTrCoeffCb;        ///< transformed coefficient buffer (Cb)
141  TCoeff*       m_pcTrCoeffCr;        ///< transformed coefficient buffer (Cr)
142#if ADAPTIVE_QP_SELECTION
143  Int*          m_pcArlCoeffY;        ///< ARL coefficient buffer (Y)
144  Int*          m_pcArlCoeffCb;       ///< ARL coefficient buffer (Cb)
145  Int*          m_pcArlCoeffCr;       ///< ARL coefficient buffer (Cr)
146  Bool          m_ArlCoeffIsAliasedAllocation; ///< ARL coefficient buffer is an alias of the global buffer and must not be free()'d
147
148  static Int*   m_pcGlbArlCoeffY;     ///< ARL coefficient buffer (Y)
149  static Int*   m_pcGlbArlCoeffCb;    ///< ARL coefficient buffer (Cb)
150  static Int*   m_pcGlbArlCoeffCr;    ///< ARL coefficient buffer (Cr)
151#endif
152 
153  Pel*          m_pcIPCMSampleY;      ///< PCM sample buffer (Y)
154  Pel*          m_pcIPCMSampleCb;     ///< PCM sample buffer (Cb)
155  Pel*          m_pcIPCMSampleCr;     ///< PCM sample buffer (Cr)
156
157  Int*          m_piSliceSUMap;       ///< pointer of slice ID map
158  std::vector<NDBFBlockInfo> m_vNDFBlock;
159
160  // -------------------------------------------------------------------------------------------------------------------
161  // neighbour access variables
162  // -------------------------------------------------------------------------------------------------------------------
163 
164  TComDataCU*   m_pcCUAboveLeft;      ///< pointer of above-left CU
165  TComDataCU*   m_pcCUAboveRight;     ///< pointer of above-right CU
166  TComDataCU*   m_pcCUAbove;          ///< pointer of above CU
167  TComDataCU*   m_pcCULeft;           ///< pointer of left CU
168  TComDataCU*   m_apcCUColocated[2];  ///< pointer of temporally colocated CU's for both directions
169  TComMvField   m_cMvFieldA;          ///< motion vector of position A
170  TComMvField   m_cMvFieldB;          ///< motion vector of position B
171  TComMvField   m_cMvFieldC;          ///< motion vector of position C
172  TComMv        m_cMvPred;            ///< motion vector predictor
173 
174  // -------------------------------------------------------------------------------------------------------------------
175  // coding tool information
176  // -------------------------------------------------------------------------------------------------------------------
177 
178  Bool*         m_pbMergeFlag;        ///< array of merge flags
179  UChar*        m_puhMergeIndex;      ///< array of merge candidate indices
180#if AMP_MRG
181  Bool          m_bIsMergeAMP;
182#endif
183  UChar*        m_puhLumaIntraDir;    ///< array of intra directions (luma)
184  UChar*        m_puhChromaIntraDir;  ///< array of intra directions (chroma)
185  UChar*        m_puhInterDir;        ///< array of inter directions
186  Char*         m_apiMVPIdx[2];       ///< array of motion vector predictor candidates
187  Char*         m_apiMVPNum[2];       ///< array of number of possible motion vectors predictors
188  Bool*         m_pbIPCMFlag;         ///< array of intra_pcm flags
189#if H_3D_NBDV
190  DisInfo*      m_pDvInfo;
191#endif
192  // -------------------------------------------------------------------------------------------------------------------
193  // misc. variables
194  // -------------------------------------------------------------------------------------------------------------------
195 
196  Bool          m_bDecSubCu;          ///< indicates decoder-mode
197  Double        m_dTotalCost;         ///< sum of partition RD costs
198#if H_3D_VSO
199  Dist          m_uiTotalDistortion;  ///< sum of partition distortion
200#else
201  UInt          m_uiTotalDistortion;  ///< sum of partition distortion
202#endif
203  UInt          m_uiTotalBits;        ///< sum of partition bits
204  UInt          m_uiTotalBins;       ///< sum of partition bins
205  UInt*         m_sliceStartCU;    ///< Start CU address of current slice
206  UInt*         m_sliceSegmentStartCU; ///< Start CU address of current slice
207  Char          m_codedQP;
208protected:
209 
210  /// add possible motion vector predictor candidates
211  Bool          xAddMVPCand           ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
212  Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
213
214  Void          deriveRightBottomIdx        ( UInt uiPartIdx, UInt& ruiPartIdxRB );
215  Bool          xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx
216#if H_3D_TMVP
217  ,
218  Bool bMRG = true
219#endif
220  );
221 
222  /// compute required bits to encode MVD (used in AMVP)
223  UInt          xGetMvdBits           ( TComMv cMvd );
224  UInt          xGetComponentBits     ( Int iVal );
225 
226  /// compute scaling factor from POC difference
227  Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
228 
229  Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter );
230
231public:
232  TComDataCU();
233  virtual ~TComDataCU();
234 
235  // -------------------------------------------------------------------------------------------------------------------
236  // create / destroy / initialize / copy
237  // -------------------------------------------------------------------------------------------------------------------
238 
239  Void          create                ( UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize
240#if ADAPTIVE_QP_SELECTION
241    , Bool bGlobalRMARLBuffer = false
242#endif 
243    );
244  Void          destroy               ();
245 
246  Void          initCU                ( TComPic* pcPic, UInt uiCUAddr );
247  Void          initEstData           ( UInt uiDepth, Int qp );
248  Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
249  Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
250#if H_3D_NBDV
251  Void          copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx);
252#endif
253  Void          copySubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
254  Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList
255#if H_3D_NBDV
256  , Bool bNBDV = false
257#endif
258  );
259  Void          copyPartFrom          ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
260 
261  Void          copyToPic             ( UChar uiDepth );
262  Void          copyToPic             ( UChar uiDepth, UInt uiPartIdx, UInt uiPartDepth );
263 
264  // -------------------------------------------------------------------------------------------------------------------
265  // member functions for CU description
266  // -------------------------------------------------------------------------------------------------------------------
267 
268  TComPic*      getPic                ()                        { return m_pcPic;           }
269  TComSlice*    getSlice              ()                        { return m_pcSlice;         }
270  UInt&         getAddr               ()                        { return m_uiCUAddr;        }
271  UInt&         getZorderIdxInCU      ()                        { return m_uiAbsIdxInLCU; }
272  UInt          getSCUAddr            ();
273  UInt          getCUPelX             ()                        { return m_uiCUPelX;        }
274  UInt          getCUPelY             ()                        { return m_uiCUPelY;        }
275  TComPattern*  getPattern            ()                        { return m_pcPattern;       }
276 
277  UChar*        getDepth              ()                        { return m_puhDepth;        }
278  UChar         getDepth              ( UInt uiIdx )            { return m_puhDepth[uiIdx]; }
279  Void          setDepth              ( UInt uiIdx, UChar  uh ) { m_puhDepth[uiIdx] = uh;   }
280 
281  Void          setDepthSubParts      ( UInt uiDepth, UInt uiAbsPartIdx );
282#if H_3D
283  Void          getPosInPic           ( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY );
284#endif
285 
286  // -------------------------------------------------------------------------------------------------------------------
287  // member functions for CU data
288  // -------------------------------------------------------------------------------------------------------------------
289 
290  Char*         getPartitionSize      ()                        { return m_pePartSize;        }
291  PartSize      getPartitionSize      ( UInt uiIdx )            { return static_cast<PartSize>( m_pePartSize[uiIdx] ); }
292  Void          setPartitionSize      ( UInt uiIdx, PartSize uh){ m_pePartSize[uiIdx] = uh;   }
293  Void          setPartSizeSubParts   ( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth );
294  Void          setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth );
295 
296  Bool*        getSkipFlag            ()                        { return m_skipFlag;          }
297  Bool         getSkipFlag            (UInt idx)                { return m_skipFlag[idx];     }
298  Void         setSkipFlag           ( UInt idx, Bool skip)     { m_skipFlag[idx] = skip;   }
299  Void         setSkipFlagSubParts   ( Bool skip, UInt absPartIdx, UInt depth );
300
301  Char*         getPredictionMode     ()                        { return m_pePredMode;        }
302  PredMode      getPredictionMode     ( UInt uiIdx )            { return static_cast<PredMode>( m_pePredMode[uiIdx] ); }
303  Bool*         getCUTransquantBypass ()                        { return m_CUTransquantBypass;        }
304  Bool          getCUTransquantBypass( UInt uiIdx )             { return m_CUTransquantBypass[uiIdx]; }
305  Void          setPredictionMode     ( UInt uiIdx, PredMode uh){ m_pePredMode[uiIdx] = uh;   }
306  Void          setPredModeSubParts   ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );
307 
308  UChar*        getWidth              ()                        { return m_puhWidth;          }
309  UChar         getWidth              ( UInt uiIdx )            { return m_puhWidth[uiIdx];   }
310  Void          setWidth              ( UInt uiIdx, UChar  uh ) { m_puhWidth[uiIdx] = uh;     }
311 
312  UChar*        getHeight             ()                        { return m_puhHeight;         }
313  UChar         getHeight             ( UInt uiIdx )            { return m_puhHeight[uiIdx];  }
314  Void          setHeight             ( UInt uiIdx, UChar  uh ) { m_puhHeight[uiIdx] = uh;    }
315 
316  Void          setSizeSubParts       ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth );
317 
318  Char*         getQP                 ()                        { return m_phQP;              }
319  Char          getQP                 ( UInt uiIdx )            { return m_phQP[uiIdx];       }
320  Void          setQP                 ( UInt uiIdx, Char value ){ m_phQP[uiIdx] =  value;     }
321  Void          setQPSubParts         ( Int qp,   UInt uiAbsPartIdx, UInt uiDepth );
322  Int           getLastValidPartIdx   ( Int iAbsPartIdx );
323  Char          getLastCodedQP        ( UInt uiAbsPartIdx );
324  Void          setQPSubCUs           ( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf );
325  Void          setCodedQP            ( Char qp )               { m_codedQP = qp;             }
326  Char          getCodedQP            ()                        { return m_codedQP;           }
327
328  Bool          isLosslessCoded(UInt absPartIdx);
329 
330  UChar*        getTransformIdx       ()                        { return m_puhTrIdx;          }
331  UChar         getTransformIdx       ( UInt uiIdx )            { return m_puhTrIdx[uiIdx];   }
332  Void          setTrIdxSubParts      ( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth );
333
334  UChar*        getTransformSkip      ( TextType eType)    { return m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]];}
335  UChar         getTransformSkip      ( UInt uiIdx,TextType eType)    { return m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]][uiIdx];}
336  Void          setTransformSkipSubParts  ( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth); 
337  Void          setTransformSkipSubParts  ( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth );
338
339  UInt          getQuadtreeTULog2MinSizeInCU( UInt absPartIdx );
340 
341  TComCUMvField* getCUMvField         ( RefPicList e )          { return  &m_acCUMvField[e];  }
342 
343  TCoeff*&      getCoeffY             ()                        { return m_pcTrCoeffY;        }
344  TCoeff*&      getCoeffCb            ()                        { return m_pcTrCoeffCb;       }
345  TCoeff*&      getCoeffCr            ()                        { return m_pcTrCoeffCr;       }
346#if ADAPTIVE_QP_SELECTION
347  Int*&         getArlCoeffY          ()                        { return m_pcArlCoeffY;       }
348  Int*&         getArlCoeffCb         ()                        { return m_pcArlCoeffCb;      }
349  Int*&         getArlCoeffCr         ()                        { return m_pcArlCoeffCr;      }
350#endif
351 
352  Pel*&         getPCMSampleY         ()                        { return m_pcIPCMSampleY;     }
353  Pel*&         getPCMSampleCb        ()                        { return m_pcIPCMSampleCb;    }
354  Pel*&         getPCMSampleCr        ()                        { return m_pcIPCMSampleCr;    }
355
356  UChar         getCbf    ( UInt uiIdx, TextType eType )                  { return m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx];  }
357  UChar*        getCbf    ( TextType eType )                              { return m_puhCbf[g_aucConvertTxtTypeToIdx[eType]];         }
358  UChar         getCbf    ( UInt uiIdx, TextType eType, UInt uiTrDepth )  { return ( ( getCbf( uiIdx, eType ) >> uiTrDepth ) & 0x1 ); }
359  Void          setCbf    ( UInt uiIdx, TextType eType, UChar uh )        { m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx] = uh;    }
360  Void          clearCbf  ( UInt uiIdx, TextType eType, UInt uiNumParts );
361  UChar         getQtRootCbf          ( UInt uiIdx )                      { return getCbf( uiIdx, TEXT_LUMA, 0 ) || getCbf( uiIdx, TEXT_CHROMA_U, 0 ) || getCbf( uiIdx, TEXT_CHROMA_V, 0 ); }
362 
363  Void          setCbfSubParts        ( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth          );
364  Void          setCbfSubParts        ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth                    );
365  Void          setCbfSubParts        ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth    );
366 
367  // -------------------------------------------------------------------------------------------------------------------
368  // member functions for coding tool information
369  // -------------------------------------------------------------------------------------------------------------------
370 
371  Bool*         getMergeFlag          ()                        { return m_pbMergeFlag;               }
372  Bool          getMergeFlag          ( UInt uiIdx )            { return m_pbMergeFlag[uiIdx];        }
373  Void          setMergeFlag          ( UInt uiIdx, Bool b )    { m_pbMergeFlag[uiIdx] = b;           }
374  Void          setMergeFlagSubParts  ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
375
376  UChar*        getMergeIndex         ()                        { return m_puhMergeIndex;                         }
377  UChar         getMergeIndex         ( UInt uiIdx )            { return m_puhMergeIndex[uiIdx];                  }
378  Void          setMergeIndex         ( UInt uiIdx, UInt uiMergeIndex ) { m_puhMergeIndex[uiIdx] = uiMergeIndex;  }
379  Void          setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
380  template <typename T>
381  Void          setSubPart            ( T bParameter, T* pbBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
382
383#if AMP_MRG
384  Void          setMergeAMP( Bool b )      { m_bIsMergeAMP = b; }
385  Bool          getMergeAMP( )             { return m_bIsMergeAMP; }
386#endif
387
388  UChar*        getLumaIntraDir       ()                        { return m_puhLumaIntraDir;           }
389  UChar         getLumaIntraDir       ( UInt uiIdx )            { return m_puhLumaIntraDir[uiIdx];    }
390  Void          setLumaIntraDir       ( UInt uiIdx, UChar  uh ) { m_puhLumaIntraDir[uiIdx] = uh;      }
391  Void          setLumaIntraDirSubParts( UInt uiDir,  UInt uiAbsPartIdx, UInt uiDepth );
392 
393  UChar*        getChromaIntraDir     ()                        { return m_puhChromaIntraDir;         }
394  UChar         getChromaIntraDir     ( UInt uiIdx )            { return m_puhChromaIntraDir[uiIdx];  }
395  Void          setChromaIntraDir     ( UInt uiIdx, UChar  uh ) { m_puhChromaIntraDir[uiIdx] = uh;    }
396  Void          setChromIntraDirSubParts( UInt uiDir,  UInt uiAbsPartIdx, UInt uiDepth );
397 
398  UChar*        getInterDir           ()                        { return m_puhInterDir;               }
399  UChar         getInterDir           ( UInt uiIdx )            { return m_puhInterDir[uiIdx];        }
400  Void          setInterDir           ( UInt uiIdx, UChar  uh ) { m_puhInterDir[uiIdx] = uh;          }
401  Void          setInterDirSubParts   ( UInt uiDir,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
402  Bool*         getIPCMFlag           ()                        { return m_pbIPCMFlag;               }
403  Bool          getIPCMFlag           (UInt uiIdx )             { return m_pbIPCMFlag[uiIdx];        }
404  Void          setIPCMFlag           (UInt uiIdx, Bool b )     { m_pbIPCMFlag[uiIdx] = b;           }
405  Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
406#if H_3D_NBDV
407  Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth );
408  DisInfo*      getDvInfo             ()                        { return m_pDvInfo;                 }
409  DisInfo       getDvInfo             (UInt uiIdx)              { return m_pDvInfo[uiIdx];          }
410#endif
411  /// get slice ID for SU
412  Int           getSUSliceID          (UInt uiIdx)              {return m_piSliceSUMap[uiIdx];      } 
413
414  /// get the pointer of slice ID map
415  Int*          getSliceSUMap         ()                        {return m_piSliceSUMap;             }
416
417  /// set the pointer of slice ID map
418  Void          setSliceSUMap         (Int *pi)                 {m_piSliceSUMap = pi;               }
419
420  std::vector<NDBFBlockInfo>* getNDBFilterBlocks()      {return &m_vNDFBlock;}
421  Void setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt numLCUInPicHeight, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight
422                                          ,std::vector<Bool>& LFCrossSliceBoundary
423                                          ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary
424                                          ,Bool bIndependentTileBoundaryEnabled );
425#if H_3D_NBDV
426  Void          xDeriveRightBottomNbIdx(Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
427  Bool          xCheckSpatialNBDV (TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paMvpDvInfo,
428                                   UInt uiMvpDvPos
429#if H_3D_NBDV_REF
430  , Bool bDepthRefine = false
431#endif
432  );
433  Bool          xGetColDisMV      ( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
434  Bool          getDisMvpCandNBDV ( DisInfo* pDInfo
435#if H_3D_NBDV_REF
436   , Bool bDepthRefine = false
437#endif
438   ); 
439   
440#if H_3D_NBDV_REF
441  Pel           getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT );
442  Void          estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred );
443#endif //H_3D_NBDV_REF
444#endif
445#if H_3D_IV_MERGE
446  Bool          getInterViewMergeCands          ( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc );   
447#endif
448  // -------------------------------------------------------------------------------------------------------------------
449  // member functions for accessing partition information
450  // -------------------------------------------------------------------------------------------------------------------
451 
452  Void          getPartIndexAndSize   ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight );
453  UChar         getNumPartInter       ();
454  Bool          isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth);
455 
456  // -------------------------------------------------------------------------------------------------------------------
457  // member functions for motion vector
458  // -------------------------------------------------------------------------------------------------------------------
459 
460  Void          getMvField            ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField );
461 
462  Void          fillMvpCand           ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo );
463  Bool          isDiffMER             ( Int xN, Int yN, Int xP, Int yP);
464  Void          getPartPosition       ( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH);
465  Void          setMVPIdx             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPIdx)  { m_apiMVPIdx[eRefPicList][uiIdx] = iMVPIdx;  }
466  Int           getMVPIdx             ( RefPicList eRefPicList, UInt uiIdx)               { return m_apiMVPIdx[eRefPicList][uiIdx];     }
467  Char*         getMVPIdx             ( RefPicList eRefPicList )                          { return m_apiMVPIdx[eRefPicList];            }
468
469  Void          setMVPNum             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPNum ) { m_apiMVPNum[eRefPicList][uiIdx] = iMVPNum;  }
470  Int           getMVPNum             ( RefPicList eRefPicList, UInt uiIdx )              { return m_apiMVPNum[eRefPicList][uiIdx];     }
471  Char*         getMVPNum             ( RefPicList eRefPicList )                          { return m_apiMVPNum[eRefPicList];            }
472 
473  Void          setMVPIdxSubParts     ( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
474  Void          setMVPNumSubParts     ( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
475 
476  Void          clipMv                ( TComMv&     rcMv     );
477  Void          getMvPredLeft         ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldA.getMv(); }
478  Void          getMvPredAbove        ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldB.getMv(); }
479  Void          getMvPredAboveRight   ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldC.getMv(); }
480 
481  Void          compressMV            ();
482 
483  // -------------------------------------------------------------------------------------------------------------------
484  // utility functions for neighbouring information
485  // -------------------------------------------------------------------------------------------------------------------
486 
487  TComDataCU*   getCULeft                   () { return m_pcCULeft;       }
488  TComDataCU*   getCUAbove                  () { return m_pcCUAbove;      }
489  TComDataCU*   getCUAboveLeft              () { return m_pcCUAboveLeft;  }
490  TComDataCU*   getCUAboveRight             () { return m_pcCUAboveRight; }
491  TComDataCU*   getCUColocated              ( RefPicList eRefPicList ) { return m_apcCUColocated[eRefPicList]; }
492
493
494  TComDataCU*   getPULeft                   ( UInt&  uiLPartUnitIdx, 
495                                              UInt uiCurrPartUnitIdx, 
496                                              Bool bEnforceSliceRestriction=true, 
497                                              Bool bEnforceTileRestriction=true );
498  TComDataCU*   getPUAbove                  ( UInt&  uiAPartUnitIdx,
499                                              UInt uiCurrPartUnitIdx, 
500                                              Bool bEnforceSliceRestriction=true, 
501                                              Bool planarAtLCUBoundary = false,
502                                              Bool bEnforceTileRestriction=true );
503  TComDataCU*   getPUAboveLeft              ( UInt&  uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );
504  TComDataCU*   getPUAboveRight             ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );
505  TComDataCU*   getPUBelowLeft              ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );
506
507  TComDataCU*   getQpMinCuLeft              ( UInt&  uiLPartUnitIdx , UInt uiCurrAbsIdxInLCU );
508  TComDataCU*   getQpMinCuAbove             ( UInt&  aPartUnitIdx , UInt currAbsIdxInLCU );
509  Char          getRefQP                    ( UInt   uiCurrAbsIdxInLCU                       );
510
511  TComDataCU*   getPUAboveRightAdi          ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );
512  TComDataCU*   getPUBelowLeftAdi           ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );
513 
514  Void          deriveLeftRightTopIdx       ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
515  Void          deriveLeftBottomIdx         ( UInt uiPartIdx, UInt& ruiPartIdxLB );
516 
517  Void          deriveLeftRightTopIdxAdi    ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth );
518  Void          deriveLeftBottomIdxAdi      ( UInt& ruiPartIdxLB, UInt  uiPartOffset, UInt uiPartDepth );
519 
520  Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
521  Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 );
522  Void          deriveLeftRightTopIdxGeneral  ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
523  Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
524 
525 
526  // -------------------------------------------------------------------------------------------------------------------
527  // member functions for modes
528  // -------------------------------------------------------------------------------------------------------------------
529 
530  Bool          isIntra   ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; }
531  Bool          isSkipped ( UInt uiPartIdx );                                                     ///< SKIP (no residual)
532  Bool          isBipredRestriction( UInt puIdx );
533
534  // -------------------------------------------------------------------------------------------------------------------
535  // member functions for symbol prediction (most probable / mode conversion)
536  // -------------------------------------------------------------------------------------------------------------------
537 
538  UInt          getIntraSizeIdx                 ( UInt uiAbsPartIdx                                       );
539 
540  Void          getAllowedChromaDir             ( UInt uiAbsPartIdx, UInt* uiModeList );
541  Int           getIntraDirLumaPredictor        ( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode = NULL );
542 
543  // -------------------------------------------------------------------------------------------------------------------
544  // member functions for SBAC context
545  // -------------------------------------------------------------------------------------------------------------------
546 
547  UInt          getCtxSplitFlag                 ( UInt   uiAbsPartIdx, UInt uiDepth                   );
548  UInt          getCtxQtCbf                     ( TextType eType, UInt uiTrDepth );
549
550  UInt          getCtxSkipFlag                  ( UInt   uiAbsPartIdx                                 );
551  UInt          getCtxInterDir                  ( UInt   uiAbsPartIdx                                 );
552 
553  UInt          getSliceStartCU         ( UInt pos )                  { return m_sliceStartCU[pos-m_uiAbsIdxInLCU];                                                                                          }
554  UInt          getSliceSegmentStartCU  ( UInt pos )                  { return m_sliceSegmentStartCU[pos-m_uiAbsIdxInLCU];                                                                                   }
555  UInt&         getTotalBins            ()                            { return m_uiTotalBins;                                                                                                  }
556  // -------------------------------------------------------------------------------------------------------------------
557  // member functions for RD cost storage
558  // -------------------------------------------------------------------------------------------------------------------
559 
560  Double&       getTotalCost()                  { return m_dTotalCost;        }
561#if H_3D_VSO
562  Dist&         getTotalDistortion()            { return m_uiTotalDistortion; }
563#else
564  UInt&         getTotalDistortion()            { return m_uiTotalDistortion; }
565#endif
566  UInt&         getTotalBits()                  { return m_uiTotalBits;       }
567  UInt&         getTotalNumPart()               { return m_uiNumPartition;    }
568
569  UInt          getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra);
570
571};
572
573namespace RasterAddress
574{
575  /** Check whether 2 addresses point to the same column
576   * \param addrA          First address in raster scan order
577   * \param addrB          Second address in raters scan order
578   * \param numUnitsPerRow Number of units in a row
579   * \return Result of test
580   */
581  static inline Bool isEqualCol( Int addrA, Int addrB, Int numUnitsPerRow )
582  {
583    // addrA % numUnitsPerRow == addrB % numUnitsPerRow
584    return (( addrA ^ addrB ) &  ( numUnitsPerRow - 1 ) ) == 0;
585  }
586 
587  /** Check whether 2 addresses point to the same row
588   * \param addrA          First address in raster scan order
589   * \param addrB          Second address in raters scan order
590   * \param numUnitsPerRow Number of units in a row
591   * \return Result of test
592   */
593  static inline Bool isEqualRow( Int addrA, Int addrB, Int numUnitsPerRow )
594  {
595    // addrA / numUnitsPerRow == addrB / numUnitsPerRow
596    return (( addrA ^ addrB ) &~ ( numUnitsPerRow - 1 ) ) == 0;
597  }
598 
599  /** Check whether 2 addresses point to the same row or column
600   * \param addrA          First address in raster scan order
601   * \param addrB          Second address in raters scan order
602   * \param numUnitsPerRow Number of units in a row
603   * \return Result of test
604   */
605  static inline Bool isEqualRowOrCol( Int addrA, Int addrB, Int numUnitsPerRow )
606  {
607    return isEqualCol( addrA, addrB, numUnitsPerRow ) | isEqualRow( addrA, addrB, numUnitsPerRow );
608  }
609 
610  /** Check whether one address points to the first column
611   * \param addr           Address in raster scan order
612   * \param numUnitsPerRow Number of units in a row
613   * \return Result of test
614   */
615  static inline Bool isZeroCol( Int addr, Int numUnitsPerRow )
616  {
617    // addr % numUnitsPerRow == 0
618    return ( addr & ( numUnitsPerRow - 1 ) ) == 0;
619  }
620 
621  /** Check whether one address points to the first row
622   * \param addr           Address in raster scan order
623   * \param numUnitsPerRow Number of units in a row
624   * \return Result of test
625   */
626  static inline Bool isZeroRow( Int addr, Int numUnitsPerRow )
627  {
628    // addr / numUnitsPerRow == 0
629    return ( addr &~ ( numUnitsPerRow - 1 ) ) == 0;
630  }
631 
632  /** Check whether one address points to a column whose index is smaller than a given value
633   * \param addr           Address in raster scan order
634   * \param val            Given column index value
635   * \param numUnitsPerRow Number of units in a row
636   * \return Result of test
637   */
638  static inline Bool lessThanCol( Int addr, Int val, Int numUnitsPerRow )
639  {
640    // addr % numUnitsPerRow < val
641    return ( addr & ( numUnitsPerRow - 1 ) ) < val;
642  }
643 
644  /** Check whether one address points to a row whose index is smaller than a given value
645   * \param addr           Address in raster scan order
646   * \param val            Given row index value
647   * \param numUnitsPerRow Number of units in a row
648   * \return Result of test
649   */
650  static inline Bool lessThanRow( Int addr, Int val, Int numUnitsPerRow )
651  {
652    // addr / numUnitsPerRow < val
653    return addr < val * numUnitsPerRow;
654  }
655};
656
657//! \}
658
659#endif
Note: See TracBrowser for help on using the repository browser.