source: 3DVCSoftware/branches/HTM-14.0-MV-draft-3/source/Lib/TLibCommon/TComDataCU.h @ 1417

Last change on this file since 1417 was 1191, checked in by tech, 10 years ago

Removed 3D-HEVC.

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