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 | |
---|
190 | // ------------------------------------------------------------------------------------------------------------------- |
---|
191 | // misc. variables |
---|
192 | // ------------------------------------------------------------------------------------------------------------------- |
---|
193 | |
---|
194 | Bool m_bDecSubCu; ///< indicates decoder-mode |
---|
195 | Double m_dTotalCost; ///< sum of partition RD costs |
---|
196 | #if H_3D_VSO |
---|
197 | Dist m_uiTotalDistortion; ///< sum of partition distortion |
---|
198 | #else |
---|
199 | UInt m_uiTotalDistortion; ///< sum of partition distortion |
---|
200 | #endif |
---|
201 | UInt m_uiTotalBits; ///< sum of partition bits |
---|
202 | UInt m_uiTotalBins; ///< sum of partition bins |
---|
203 | UInt* m_sliceStartCU; ///< Start CU address of current slice |
---|
204 | UInt* m_sliceSegmentStartCU; ///< Start CU address of current slice |
---|
205 | Char m_codedQP; |
---|
206 | protected: |
---|
207 | |
---|
208 | /// add possible motion vector predictor candidates |
---|
209 | Bool xAddMVPCand ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ); |
---|
210 | Bool xAddMVPCandOrder ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ); |
---|
211 | |
---|
212 | Void deriveRightBottomIdx ( UInt uiPartIdx, UInt& ruiPartIdxRB ); |
---|
213 | Bool xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx ); |
---|
214 | |
---|
215 | /// compute required bits to encode MVD (used in AMVP) |
---|
216 | UInt xGetMvdBits ( TComMv cMvd ); |
---|
217 | UInt xGetComponentBits ( Int iVal ); |
---|
218 | |
---|
219 | /// compute scaling factor from POC difference |
---|
220 | Int xGetDistScaleFactor ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC ); |
---|
221 | |
---|
222 | Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ); |
---|
223 | |
---|
224 | public: |
---|
225 | TComDataCU(); |
---|
226 | virtual ~TComDataCU(); |
---|
227 | |
---|
228 | // ------------------------------------------------------------------------------------------------------------------- |
---|
229 | // create / destroy / initialize / copy |
---|
230 | // ------------------------------------------------------------------------------------------------------------------- |
---|
231 | |
---|
232 | Void create ( UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
233 | #if ADAPTIVE_QP_SELECTION |
---|
234 | , Bool bGlobalRMARLBuffer = false |
---|
235 | #endif |
---|
236 | ); |
---|
237 | Void destroy (); |
---|
238 | |
---|
239 | Void initCU ( TComPic* pcPic, UInt uiCUAddr ); |
---|
240 | Void initEstData ( UInt uiDepth, Int qp ); |
---|
241 | Void initSubCU ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ); |
---|
242 | Void setOutsideCUPart ( UInt uiAbsPartIdx, UInt uiDepth ); |
---|
243 | |
---|
244 | Void copySubCU ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ); |
---|
245 | Void copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList ); |
---|
246 | Void copyPartFrom ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ); |
---|
247 | |
---|
248 | Void copyToPic ( UChar uiDepth ); |
---|
249 | Void copyToPic ( UChar uiDepth, UInt uiPartIdx, UInt uiPartDepth ); |
---|
250 | |
---|
251 | // ------------------------------------------------------------------------------------------------------------------- |
---|
252 | // member functions for CU description |
---|
253 | // ------------------------------------------------------------------------------------------------------------------- |
---|
254 | |
---|
255 | TComPic* getPic () { return m_pcPic; } |
---|
256 | TComSlice* getSlice () { return m_pcSlice; } |
---|
257 | UInt& getAddr () { return m_uiCUAddr; } |
---|
258 | UInt& getZorderIdxInCU () { return m_uiAbsIdxInLCU; } |
---|
259 | UInt getSCUAddr (); |
---|
260 | UInt getCUPelX () { return m_uiCUPelX; } |
---|
261 | UInt getCUPelY () { return m_uiCUPelY; } |
---|
262 | TComPattern* getPattern () { return m_pcPattern; } |
---|
263 | |
---|
264 | UChar* getDepth () { return m_puhDepth; } |
---|
265 | UChar getDepth ( UInt uiIdx ) { return m_puhDepth[uiIdx]; } |
---|
266 | Void setDepth ( UInt uiIdx, UChar uh ) { m_puhDepth[uiIdx] = uh; } |
---|
267 | |
---|
268 | Void setDepthSubParts ( UInt uiDepth, UInt uiAbsPartIdx ); |
---|
269 | #if H_3D |
---|
270 | Void getPosInPic ( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ); |
---|
271 | #endif |
---|
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 | /// get slice ID for SU |
---|
395 | Int getSUSliceID (UInt uiIdx) {return m_piSliceSUMap[uiIdx]; } |
---|
396 | |
---|
397 | /// get the pointer of slice ID map |
---|
398 | Int* getSliceSUMap () {return m_piSliceSUMap; } |
---|
399 | |
---|
400 | /// set the pointer of slice ID map |
---|
401 | Void setSliceSUMap (Int *pi) {m_piSliceSUMap = pi; } |
---|
402 | |
---|
403 | std::vector<NDBFBlockInfo>* getNDBFilterBlocks() {return &m_vNDFBlock;} |
---|
404 | Void setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt numLCUInPicHeight, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight |
---|
405 | ,std::vector<Bool>& LFCrossSliceBoundary |
---|
406 | ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary |
---|
407 | ,Bool bIndependentTileBoundaryEnabled ); |
---|
408 | // ------------------------------------------------------------------------------------------------------------------- |
---|
409 | // member functions for accessing partition information |
---|
410 | // ------------------------------------------------------------------------------------------------------------------- |
---|
411 | |
---|
412 | Void getPartIndexAndSize ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ); |
---|
413 | UChar getNumPartInter (); |
---|
414 | Bool isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth); |
---|
415 | |
---|
416 | // ------------------------------------------------------------------------------------------------------------------- |
---|
417 | // member functions for motion vector |
---|
418 | // ------------------------------------------------------------------------------------------------------------------- |
---|
419 | |
---|
420 | Void getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ); |
---|
421 | |
---|
422 | Void fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ); |
---|
423 | Bool isDiffMER ( Int xN, Int yN, Int xP, Int yP); |
---|
424 | Void getPartPosition ( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH); |
---|
425 | Void setMVPIdx ( RefPicList eRefPicList, UInt uiIdx, Int iMVPIdx) { m_apiMVPIdx[eRefPicList][uiIdx] = iMVPIdx; } |
---|
426 | Int getMVPIdx ( RefPicList eRefPicList, UInt uiIdx) { return m_apiMVPIdx[eRefPicList][uiIdx]; } |
---|
427 | Char* getMVPIdx ( RefPicList eRefPicList ) { return m_apiMVPIdx[eRefPicList]; } |
---|
428 | |
---|
429 | Void setMVPNum ( RefPicList eRefPicList, UInt uiIdx, Int iMVPNum ) { m_apiMVPNum[eRefPicList][uiIdx] = iMVPNum; } |
---|
430 | Int getMVPNum ( RefPicList eRefPicList, UInt uiIdx ) { return m_apiMVPNum[eRefPicList][uiIdx]; } |
---|
431 | Char* getMVPNum ( RefPicList eRefPicList ) { return m_apiMVPNum[eRefPicList]; } |
---|
432 | |
---|
433 | Void setMVPIdxSubParts ( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
434 | Void setMVPNumSubParts ( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
435 | |
---|
436 | Void clipMv ( TComMv& rcMv ); |
---|
437 | Void getMvPredLeft ( TComMv& rcMvPred ) { rcMvPred = m_cMvFieldA.getMv(); } |
---|
438 | Void getMvPredAbove ( TComMv& rcMvPred ) { rcMvPred = m_cMvFieldB.getMv(); } |
---|
439 | Void getMvPredAboveRight ( TComMv& rcMvPred ) { rcMvPred = m_cMvFieldC.getMv(); } |
---|
440 | |
---|
441 | Void compressMV (); |
---|
442 | |
---|
443 | // ------------------------------------------------------------------------------------------------------------------- |
---|
444 | // utility functions for neighbouring information |
---|
445 | // ------------------------------------------------------------------------------------------------------------------- |
---|
446 | |
---|
447 | TComDataCU* getCULeft () { return m_pcCULeft; } |
---|
448 | TComDataCU* getCUAbove () { return m_pcCUAbove; } |
---|
449 | TComDataCU* getCUAboveLeft () { return m_pcCUAboveLeft; } |
---|
450 | TComDataCU* getCUAboveRight () { return m_pcCUAboveRight; } |
---|
451 | TComDataCU* getCUColocated ( RefPicList eRefPicList ) { return m_apcCUColocated[eRefPicList]; } |
---|
452 | |
---|
453 | |
---|
454 | TComDataCU* getPULeft ( UInt& uiLPartUnitIdx, |
---|
455 | UInt uiCurrPartUnitIdx, |
---|
456 | Bool bEnforceSliceRestriction=true, |
---|
457 | Bool bEnforceTileRestriction=true ); |
---|
458 | TComDataCU* getPUAbove ( UInt& uiAPartUnitIdx, |
---|
459 | UInt uiCurrPartUnitIdx, |
---|
460 | Bool bEnforceSliceRestriction=true, |
---|
461 | Bool planarAtLCUBoundary = false, |
---|
462 | Bool bEnforceTileRestriction=true ); |
---|
463 | TComDataCU* getPUAboveLeft ( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true ); |
---|
464 | TComDataCU* getPUAboveRight ( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true ); |
---|
465 | TComDataCU* getPUBelowLeft ( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true ); |
---|
466 | |
---|
467 | TComDataCU* getQpMinCuLeft ( UInt& uiLPartUnitIdx , UInt uiCurrAbsIdxInLCU ); |
---|
468 | TComDataCU* getQpMinCuAbove ( UInt& aPartUnitIdx , UInt currAbsIdxInLCU ); |
---|
469 | Char getRefQP ( UInt uiCurrAbsIdxInLCU ); |
---|
470 | |
---|
471 | TComDataCU* getPUAboveRightAdi ( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true ); |
---|
472 | TComDataCU* getPUBelowLeftAdi ( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true ); |
---|
473 | |
---|
474 | Void deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ); |
---|
475 | Void deriveLeftBottomIdx ( UInt uiPartIdx, UInt& ruiPartIdxLB ); |
---|
476 | |
---|
477 | Void deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ); |
---|
478 | Void deriveLeftBottomIdxAdi ( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ); |
---|
479 | |
---|
480 | Bool hasEqualMotion ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ); |
---|
481 | Void getInterMergeCandidates ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 ); |
---|
482 | Void deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ); |
---|
483 | Void deriveLeftBottomIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ); |
---|
484 | |
---|
485 | |
---|
486 | // ------------------------------------------------------------------------------------------------------------------- |
---|
487 | // member functions for modes |
---|
488 | // ------------------------------------------------------------------------------------------------------------------- |
---|
489 | |
---|
490 | Bool isIntra ( UInt uiPartIdx ) { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; } |
---|
491 | Bool isSkipped ( UInt uiPartIdx ); ///< SKIP (no residual) |
---|
492 | Bool isBipredRestriction( UInt puIdx ); |
---|
493 | |
---|
494 | // ------------------------------------------------------------------------------------------------------------------- |
---|
495 | // member functions for symbol prediction (most probable / mode conversion) |
---|
496 | // ------------------------------------------------------------------------------------------------------------------- |
---|
497 | |
---|
498 | UInt getIntraSizeIdx ( UInt uiAbsPartIdx ); |
---|
499 | |
---|
500 | Void getAllowedChromaDir ( UInt uiAbsPartIdx, UInt* uiModeList ); |
---|
501 | Int getIntraDirLumaPredictor ( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode = NULL ); |
---|
502 | |
---|
503 | // ------------------------------------------------------------------------------------------------------------------- |
---|
504 | // member functions for SBAC context |
---|
505 | // ------------------------------------------------------------------------------------------------------------------- |
---|
506 | |
---|
507 | UInt getCtxSplitFlag ( UInt uiAbsPartIdx, UInt uiDepth ); |
---|
508 | UInt getCtxQtCbf ( TextType eType, UInt uiTrDepth ); |
---|
509 | |
---|
510 | UInt getCtxSkipFlag ( UInt uiAbsPartIdx ); |
---|
511 | UInt getCtxInterDir ( UInt uiAbsPartIdx ); |
---|
512 | |
---|
513 | UInt getSliceStartCU ( UInt pos ) { return m_sliceStartCU[pos-m_uiAbsIdxInLCU]; } |
---|
514 | UInt getSliceSegmentStartCU ( UInt pos ) { return m_sliceSegmentStartCU[pos-m_uiAbsIdxInLCU]; } |
---|
515 | UInt& getTotalBins () { return m_uiTotalBins; } |
---|
516 | // ------------------------------------------------------------------------------------------------------------------- |
---|
517 | // member functions for RD cost storage |
---|
518 | // ------------------------------------------------------------------------------------------------------------------- |
---|
519 | |
---|
520 | Double& getTotalCost() { return m_dTotalCost; } |
---|
521 | #if H_3D_VSO |
---|
522 | Dist& getTotalDistortion() { return m_uiTotalDistortion; } |
---|
523 | #else |
---|
524 | UInt& getTotalDistortion() { return m_uiTotalDistortion; } |
---|
525 | #endif |
---|
526 | UInt& getTotalBits() { return m_uiTotalBits; } |
---|
527 | UInt& getTotalNumPart() { return m_uiNumPartition; } |
---|
528 | |
---|
529 | UInt getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra); |
---|
530 | |
---|
531 | }; |
---|
532 | |
---|
533 | namespace RasterAddress |
---|
534 | { |
---|
535 | /** Check whether 2 addresses point to the same column |
---|
536 | * \param addrA First address in raster scan order |
---|
537 | * \param addrB Second address in raters scan order |
---|
538 | * \param numUnitsPerRow Number of units in a row |
---|
539 | * \return Result of test |
---|
540 | */ |
---|
541 | static inline Bool isEqualCol( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
542 | { |
---|
543 | // addrA % numUnitsPerRow == addrB % numUnitsPerRow |
---|
544 | return (( addrA ^ addrB ) & ( numUnitsPerRow - 1 ) ) == 0; |
---|
545 | } |
---|
546 | |
---|
547 | /** Check whether 2 addresses point to the same row |
---|
548 | * \param addrA First address in raster scan order |
---|
549 | * \param addrB Second address in raters scan order |
---|
550 | * \param numUnitsPerRow Number of units in a row |
---|
551 | * \return Result of test |
---|
552 | */ |
---|
553 | static inline Bool isEqualRow( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
554 | { |
---|
555 | // addrA / numUnitsPerRow == addrB / numUnitsPerRow |
---|
556 | return (( addrA ^ addrB ) &~ ( numUnitsPerRow - 1 ) ) == 0; |
---|
557 | } |
---|
558 | |
---|
559 | /** Check whether 2 addresses point to the same row or column |
---|
560 | * \param addrA First address in raster scan order |
---|
561 | * \param addrB Second address in raters scan order |
---|
562 | * \param numUnitsPerRow Number of units in a row |
---|
563 | * \return Result of test |
---|
564 | */ |
---|
565 | static inline Bool isEqualRowOrCol( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
566 | { |
---|
567 | return isEqualCol( addrA, addrB, numUnitsPerRow ) | isEqualRow( addrA, addrB, numUnitsPerRow ); |
---|
568 | } |
---|
569 | |
---|
570 | /** Check whether one address points to the first column |
---|
571 | * \param addr Address in raster scan order |
---|
572 | * \param numUnitsPerRow Number of units in a row |
---|
573 | * \return Result of test |
---|
574 | */ |
---|
575 | static inline Bool isZeroCol( Int addr, Int numUnitsPerRow ) |
---|
576 | { |
---|
577 | // addr % numUnitsPerRow == 0 |
---|
578 | return ( addr & ( numUnitsPerRow - 1 ) ) == 0; |
---|
579 | } |
---|
580 | |
---|
581 | /** Check whether one address points to the first row |
---|
582 | * \param addr Address in raster scan order |
---|
583 | * \param numUnitsPerRow Number of units in a row |
---|
584 | * \return Result of test |
---|
585 | */ |
---|
586 | static inline Bool isZeroRow( Int addr, Int numUnitsPerRow ) |
---|
587 | { |
---|
588 | // addr / numUnitsPerRow == 0 |
---|
589 | return ( addr &~ ( numUnitsPerRow - 1 ) ) == 0; |
---|
590 | } |
---|
591 | |
---|
592 | /** Check whether one address points to a column whose index is smaller than a given value |
---|
593 | * \param addr Address in raster scan order |
---|
594 | * \param val Given column index value |
---|
595 | * \param numUnitsPerRow Number of units in a row |
---|
596 | * \return Result of test |
---|
597 | */ |
---|
598 | static inline Bool lessThanCol( Int addr, Int val, Int numUnitsPerRow ) |
---|
599 | { |
---|
600 | // addr % numUnitsPerRow < val |
---|
601 | return ( addr & ( numUnitsPerRow - 1 ) ) < val; |
---|
602 | } |
---|
603 | |
---|
604 | /** Check whether one address points to a row whose index is smaller than a given value |
---|
605 | * \param addr Address in raster scan order |
---|
606 | * \param val Given row index value |
---|
607 | * \param numUnitsPerRow Number of units in a row |
---|
608 | * \return Result of test |
---|
609 | */ |
---|
610 | static inline Bool lessThanRow( Int addr, Int val, Int numUnitsPerRow ) |
---|
611 | { |
---|
612 | // addr / numUnitsPerRow < val |
---|
613 | return addr < val * numUnitsPerRow; |
---|
614 | } |
---|
615 | }; |
---|
616 | |
---|
617 | //! \} |
---|
618 | |
---|
619 | #endif |
---|