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