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