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-2014, 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 | class TComTU; // forward declaration |
---|
58 | |
---|
59 | static const UInt NUM_MOST_PROBABLE_MODES=3; |
---|
60 | |
---|
61 | // ==================================================================================================================== |
---|
62 | // Class definition |
---|
63 | // ==================================================================================================================== |
---|
64 | |
---|
65 | /// CU data structure class |
---|
66 | class TComDataCU |
---|
67 | { |
---|
68 | private: |
---|
69 | |
---|
70 | // ------------------------------------------------------------------------------------------------------------------- |
---|
71 | // class pointers |
---|
72 | // ------------------------------------------------------------------------------------------------------------------- |
---|
73 | |
---|
74 | TComPic* m_pcPic; ///< picture class pointer |
---|
75 | TComSlice* m_pcSlice; ///< slice header pointer |
---|
76 | |
---|
77 | // ------------------------------------------------------------------------------------------------------------------- |
---|
78 | // CU description |
---|
79 | // ------------------------------------------------------------------------------------------------------------------- |
---|
80 | |
---|
81 | UInt m_ctuRsAddr; ///< CTU (also known as LCU) address in a slice (Raster-scan address, as opposed to tile-scan/encoding order). |
---|
82 | UInt m_absZIdxInCtu; ///< absolute address in a CTU. It's Z scan order |
---|
83 | UInt m_uiCUPelX; ///< CU position in a pixel (X) |
---|
84 | UInt m_uiCUPelY; ///< CU position in a pixel (Y) |
---|
85 | UInt m_uiNumPartition; ///< total number of minimum partitions in a CU |
---|
86 | UChar* m_puhWidth; ///< array of widths |
---|
87 | UChar* m_puhHeight; ///< array of heights |
---|
88 | UChar* m_puhDepth; ///< array of depths |
---|
89 | Int m_unitSize; ///< size of a "minimum partition" |
---|
90 | |
---|
91 | #if SVC_EXTENSION |
---|
92 | UInt m_layerId; ///< layer id |
---|
93 | #endif |
---|
94 | |
---|
95 | // ------------------------------------------------------------------------------------------------------------------- |
---|
96 | // CU data |
---|
97 | // ------------------------------------------------------------------------------------------------------------------- |
---|
98 | |
---|
99 | Bool* m_skipFlag; ///< array of skip flags |
---|
100 | Char* m_pePartSize; ///< array of partition sizes |
---|
101 | Char* m_pePredMode; ///< array of prediction modes |
---|
102 | Char* m_crossComponentPredictionAlpha[MAX_NUM_COMPONENT]; ///< array of cross-component prediction alpha values |
---|
103 | Bool* m_CUTransquantBypass; ///< array of cu_transquant_bypass flags |
---|
104 | Char* m_phQP; ///< array of QP values |
---|
105 | UChar* m_ChromaQpAdj; ///< array of chroma QP adjustments (indexed) |
---|
106 | UInt m_codedChromaQpAdj; |
---|
107 | UChar* m_puhTrIdx; ///< array of transform indices |
---|
108 | UChar* m_puhTransformSkip[MAX_NUM_COMPONENT];///< array of transform skipping flags |
---|
109 | UChar* m_puhCbf[MAX_NUM_COMPONENT]; ///< array of coded block flags (CBF) |
---|
110 | TComCUMvField m_acCUMvField[NUM_REF_PIC_LIST_01]; ///< array of motion vectors. |
---|
111 | TCoeff* m_pcTrCoeff[MAX_NUM_COMPONENT]; ///< array of transform coefficient buffers (0->Y, 1->Cb, 2->Cr) |
---|
112 | #if ADAPTIVE_QP_SELECTION |
---|
113 | TCoeff* m_pcArlCoeff[MAX_NUM_COMPONENT]; // ARL coefficient buffer (0->Y, 1->Cb, 2->Cr) |
---|
114 | static TCoeff* m_pcGlbArlCoeff[MAX_NUM_COMPONENT]; // global ARL buffer |
---|
115 | Bool m_ArlCoeffIsAliasedAllocation; ///< ARL coefficient buffer is an alias of the global buffer and must not be free()'d |
---|
116 | #endif |
---|
117 | |
---|
118 | Pel* m_pcIPCMSample[MAX_NUM_COMPONENT]; ///< PCM sample buffer (0->Y, 1->Cb, 2->Cr) |
---|
119 | |
---|
120 | // ------------------------------------------------------------------------------------------------------------------- |
---|
121 | // neighbour access variables |
---|
122 | // ------------------------------------------------------------------------------------------------------------------- |
---|
123 | |
---|
124 | TComDataCU* m_pCtuAboveLeft; ///< pointer of above-left CTU. |
---|
125 | TComDataCU* m_pCtuAboveRight; ///< pointer of above-right CTU. |
---|
126 | TComDataCU* m_pCtuAbove; ///< pointer of above CTU. |
---|
127 | TComDataCU* m_pCtuLeft; ///< pointer of left CTU |
---|
128 | TComDataCU* m_apcCUColocated[NUM_REF_PIC_LIST_01]; ///< pointer of temporally colocated CU's for both directions |
---|
129 | TComMvField m_cMvFieldA; ///< motion vector of position A |
---|
130 | TComMvField m_cMvFieldB; ///< motion vector of position B |
---|
131 | TComMvField m_cMvFieldC; ///< motion vector of position C |
---|
132 | TComMv m_cMvPred; ///< motion vector predictor |
---|
133 | |
---|
134 | // ------------------------------------------------------------------------------------------------------------------- |
---|
135 | // coding tool information |
---|
136 | // ------------------------------------------------------------------------------------------------------------------- |
---|
137 | |
---|
138 | Bool* m_pbMergeFlag; ///< array of merge flags |
---|
139 | UChar* m_puhMergeIndex; ///< array of merge candidate indices |
---|
140 | #if AMP_MRG |
---|
141 | Bool m_bIsMergeAMP; |
---|
142 | #endif |
---|
143 | UChar* m_puhIntraDir[MAX_NUM_CHANNEL_TYPE]; // 0-> Luma, 1-> Chroma |
---|
144 | UChar* m_puhInterDir; ///< array of inter directions |
---|
145 | Char* m_apiMVPIdx[NUM_REF_PIC_LIST_01]; ///< array of motion vector predictor candidates |
---|
146 | Char* m_apiMVPNum[NUM_REF_PIC_LIST_01]; ///< array of number of possible motion vectors predictors |
---|
147 | Bool* m_pbIPCMFlag; ///< array of intra_pcm flags |
---|
148 | |
---|
149 | // ------------------------------------------------------------------------------------------------------------------- |
---|
150 | // misc. variables |
---|
151 | // ------------------------------------------------------------------------------------------------------------------- |
---|
152 | |
---|
153 | Bool m_bDecSubCu; ///< indicates decoder-mode |
---|
154 | Double m_dTotalCost; ///< sum of partition RD costs |
---|
155 | Distortion m_uiTotalDistortion; ///< sum of partition distortion |
---|
156 | UInt m_uiTotalBits; ///< sum of partition bits |
---|
157 | UInt m_uiTotalBins; ///< sum of partition bins |
---|
158 | Char m_codedQP; |
---|
159 | UChar* m_explicitRdpcmMode[MAX_NUM_COMPONENT]; ///< Stores the explicit RDPCM mode for all TUs belonging to this CU |
---|
160 | |
---|
161 | protected: |
---|
162 | |
---|
163 | /// add possible motion vector predictor candidates |
---|
164 | Bool xAddMVPCand ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ); |
---|
165 | Bool xAddMVPCandOrder ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ); |
---|
166 | |
---|
167 | Void deriveRightBottomIdx ( UInt uiPartIdx, UInt& ruiPartIdxRB ); |
---|
168 | Bool xGetColMVP( RefPicList eRefPicList, Int ctuRsAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx ); |
---|
169 | |
---|
170 | /// compute required bits to encode MVD (used in AMVP) |
---|
171 | UInt xGetMvdBits ( TComMv cMvd ); |
---|
172 | UInt xGetComponentBits ( Int iVal ); |
---|
173 | |
---|
174 | /// compute scaling factor from POC difference |
---|
175 | Int xGetDistScaleFactor ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC ); |
---|
176 | |
---|
177 | Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ); |
---|
178 | |
---|
179 | public: |
---|
180 | TComDataCU(); |
---|
181 | virtual ~TComDataCU(); |
---|
182 | |
---|
183 | // ------------------------------------------------------------------------------------------------------------------- |
---|
184 | // create / destroy / initialize / copy |
---|
185 | // ------------------------------------------------------------------------------------------------------------------- |
---|
186 | |
---|
187 | Void create ( ChromaFormat chromaFormatIDC, UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
188 | #if ADAPTIVE_QP_SELECTION |
---|
189 | , Bool bGlobalRMARLBuffer = false |
---|
190 | #endif |
---|
191 | ); |
---|
192 | Void destroy (); |
---|
193 | |
---|
194 | Void initCtu ( TComPic* pcPic, UInt ctuRsAddr ); |
---|
195 | Void initEstData ( const UInt uiDepth, const Int qp, const Bool bTransquantBypass ); |
---|
196 | Void initSubCU ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ); |
---|
197 | Void setOutsideCUPart ( UInt uiAbsPartIdx, UInt uiDepth ); |
---|
198 | |
---|
199 | Void copySubCU ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ); |
---|
200 | Void copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList ); |
---|
201 | Void copyPartFrom ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ); |
---|
202 | |
---|
203 | Void copyToPic ( UChar uiDepth ); |
---|
204 | Void copyToPic ( UChar uiDepth, UInt uiPartIdx, UInt uiPartDepth ); |
---|
205 | |
---|
206 | // ------------------------------------------------------------------------------------------------------------------- |
---|
207 | // member functions for CU description |
---|
208 | // ------------------------------------------------------------------------------------------------------------------- |
---|
209 | |
---|
210 | TComPic* getPic () { return m_pcPic; } |
---|
211 | const TComPic* getPic () const { return m_pcPic; } |
---|
212 | TComSlice* getSlice () { return m_pcSlice; } |
---|
213 | const TComSlice* getSlice () const { return m_pcSlice; } |
---|
214 | UInt& getCtuRsAddr () { return m_ctuRsAddr; } |
---|
215 | UInt getCtuRsAddr () const { return m_ctuRsAddr; } |
---|
216 | UInt getZorderIdxInCtu () const { return m_absZIdxInCtu; } |
---|
217 | UInt getCUPelX () const { return m_uiCUPelX; } |
---|
218 | UInt getCUPelY () const { return m_uiCUPelY; } |
---|
219 | |
---|
220 | UChar* getDepth () { return m_puhDepth; } |
---|
221 | UChar getDepth ( UInt uiIdx ) const { return m_puhDepth[uiIdx]; } |
---|
222 | Void setDepth ( UInt uiIdx, UChar uh ) { m_puhDepth[uiIdx] = uh; } |
---|
223 | |
---|
224 | Void setDepthSubParts ( UInt uiDepth, UInt uiAbsPartIdx ); |
---|
225 | |
---|
226 | // ------------------------------------------------------------------------------------------------------------------- |
---|
227 | // member functions for CU data |
---|
228 | // ------------------------------------------------------------------------------------------------------------------- |
---|
229 | |
---|
230 | Char* getPartitionSize () { return m_pePartSize; } |
---|
231 | PartSize getPartitionSize ( UInt uiIdx ) { return static_cast<PartSize>( m_pePartSize[uiIdx] ); } |
---|
232 | Void setPartitionSize ( UInt uiIdx, PartSize uh){ m_pePartSize[uiIdx] = uh; } |
---|
233 | Void setPartSizeSubParts ( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
234 | Void setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
235 | |
---|
236 | Bool* getSkipFlag () { return m_skipFlag; } |
---|
237 | Bool getSkipFlag (UInt idx) { return m_skipFlag[idx]; } |
---|
238 | Void setSkipFlag ( UInt idx, Bool skip) { m_skipFlag[idx] = skip; } |
---|
239 | Void setSkipFlagSubParts ( Bool skip, UInt absPartIdx, UInt depth ); |
---|
240 | |
---|
241 | Char* getPredictionMode () { return m_pePredMode; } |
---|
242 | PredMode getPredictionMode ( UInt uiIdx ) { return static_cast<PredMode>( m_pePredMode[uiIdx] ); } |
---|
243 | Void setPredictionMode ( UInt uiIdx, PredMode uh){ m_pePredMode[uiIdx] = uh; } |
---|
244 | Void setPredModeSubParts ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
245 | |
---|
246 | Char* getCrossComponentPredictionAlpha( ComponentID compID ) { return m_crossComponentPredictionAlpha[compID]; } |
---|
247 | Char getCrossComponentPredictionAlpha( UInt uiIdx, ComponentID compID ) { return m_crossComponentPredictionAlpha[compID][uiIdx]; } |
---|
248 | |
---|
249 | Bool* getCUTransquantBypass () { return m_CUTransquantBypass; } |
---|
250 | Bool getCUTransquantBypass( UInt uiIdx ) { return m_CUTransquantBypass[uiIdx]; } |
---|
251 | |
---|
252 | UChar* getWidth () { return m_puhWidth; } |
---|
253 | UChar getWidth ( UInt uiIdx ) { return m_puhWidth[uiIdx]; } |
---|
254 | Void setWidth ( UInt uiIdx, UChar uh ) { m_puhWidth[uiIdx] = uh; } |
---|
255 | |
---|
256 | UChar* getHeight () { return m_puhHeight; } |
---|
257 | UChar getHeight ( UInt uiIdx ) { return m_puhHeight[uiIdx]; } |
---|
258 | Void setHeight ( UInt uiIdx, UChar uh ) { m_puhHeight[uiIdx] = uh; } |
---|
259 | |
---|
260 | Void setSizeSubParts ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
261 | |
---|
262 | Char* getQP () { return m_phQP; } |
---|
263 | Char getQP ( UInt uiIdx ) const { return m_phQP[uiIdx]; } |
---|
264 | Void setQP ( UInt uiIdx, Char value ){ m_phQP[uiIdx] = value; } |
---|
265 | Void setQPSubParts ( Int qp, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
266 | Int getLastValidPartIdx ( Int iAbsPartIdx ); |
---|
267 | Char getLastCodedQP ( UInt uiAbsPartIdx ); |
---|
268 | Void setQPSubCUs ( Int qp, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ); |
---|
269 | Void setCodedQP ( Char qp ) { m_codedQP = qp; } |
---|
270 | Char getCodedQP () { return m_codedQP; } |
---|
271 | |
---|
272 | UChar* getChromaQpAdj () { return m_ChromaQpAdj; } |
---|
273 | UChar getChromaQpAdj (Int idx) const { return m_ChromaQpAdj[idx]; } |
---|
274 | Void setChromaQpAdj (Int idx, UChar val) { m_ChromaQpAdj[idx] = val; } |
---|
275 | Void setChromaQpAdjSubParts( UChar val, Int absPartIdx, Int depth ); |
---|
276 | Void setCodedChromaQpAdj ( Char qp ) { m_codedChromaQpAdj = qp; } |
---|
277 | Char getCodedChromaQpAdj () { return m_codedChromaQpAdj; } |
---|
278 | |
---|
279 | Bool isLosslessCoded ( UInt absPartIdx ); |
---|
280 | |
---|
281 | UChar* getTransformIdx () { return m_puhTrIdx; } |
---|
282 | UChar getTransformIdx ( UInt uiIdx ) { return m_puhTrIdx[uiIdx]; } |
---|
283 | Void setTrIdxSubParts ( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
284 | |
---|
285 | UChar* getTransformSkip ( ComponentID compID ) { return m_puhTransformSkip[compID];} |
---|
286 | UChar getTransformSkip ( UInt uiIdx, ComponentID compID) { return m_puhTransformSkip[compID][uiIdx];} |
---|
287 | Void setTransformSkipSubParts ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth); |
---|
288 | Void setTransformSkipSubParts ( const UInt useTransformSkip[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ); |
---|
289 | |
---|
290 | UChar* getExplicitRdpcmMode ( ComponentID component ) { return m_explicitRdpcmMode[component]; } |
---|
291 | UChar getExplicitRdpcmMode ( ComponentID component, UInt partIdx ) {return m_explicitRdpcmMode[component][partIdx]; } |
---|
292 | Void setExplicitRdpcmModePartRange ( UInt rdpcmMode, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ); |
---|
293 | |
---|
294 | Bool isRDPCMEnabled ( UInt uiAbsPartIdx ) { return getSlice()->getSPS()->getUseResidualDPCM(isIntra(uiAbsPartIdx) ? RDPCM_SIGNAL_IMPLICIT : RDPCM_SIGNAL_EXPLICIT); } |
---|
295 | |
---|
296 | Void setCrossComponentPredictionAlphaPartRange ( Char alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ); |
---|
297 | Void setTransformSkipPartRange ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ); |
---|
298 | |
---|
299 | UInt getQuadtreeTULog2MinSizeInCU( UInt uiIdx ); |
---|
300 | |
---|
301 | TComCUMvField* getCUMvField ( RefPicList e ) { return &m_acCUMvField[e]; } |
---|
302 | |
---|
303 | TCoeff* getCoeff (ComponentID component) { return m_pcTrCoeff[component]; } |
---|
304 | |
---|
305 | #if ADAPTIVE_QP_SELECTION |
---|
306 | TCoeff* getArlCoeff ( ComponentID component ) { return m_pcArlCoeff[component]; } |
---|
307 | #endif |
---|
308 | Pel* getPCMSample ( ComponentID component ) { return m_pcIPCMSample[component]; } |
---|
309 | |
---|
310 | UChar getCbf ( UInt uiIdx, ComponentID eType ) { return m_puhCbf[eType][uiIdx]; } |
---|
311 | UChar* getCbf ( ComponentID eType ) { return m_puhCbf[eType]; } |
---|
312 | UChar getCbf ( UInt uiIdx, ComponentID eType, UInt uiTrDepth ) { return ( ( getCbf( uiIdx, eType ) >> uiTrDepth ) & 0x1 ); } |
---|
313 | Void setCbf ( UInt uiIdx, ComponentID eType, UChar uh ) { m_puhCbf[eType][uiIdx] = uh; } |
---|
314 | Void clearCbf ( UInt uiIdx, ComponentID eType, UInt uiNumParts ); |
---|
315 | UChar getQtRootCbf ( UInt uiIdx ); |
---|
316 | |
---|
317 | Void setCbfSubParts ( const UInt uiCbf[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ); |
---|
318 | Void setCbfSubParts ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth ); |
---|
319 | Void setCbfSubParts ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
320 | |
---|
321 | Void setCbfPartRange ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ); |
---|
322 | Void bitwiseOrCbfPartRange ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ); |
---|
323 | |
---|
324 | // ------------------------------------------------------------------------------------------------------------------- |
---|
325 | // member functions for coding tool information |
---|
326 | // ------------------------------------------------------------------------------------------------------------------- |
---|
327 | |
---|
328 | Bool* getMergeFlag () { return m_pbMergeFlag; } |
---|
329 | Bool getMergeFlag ( UInt uiIdx ) { return m_pbMergeFlag[uiIdx]; } |
---|
330 | Void setMergeFlag ( UInt uiIdx, Bool b ) { m_pbMergeFlag[uiIdx] = b; } |
---|
331 | Void setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
332 | |
---|
333 | UChar* getMergeIndex () { return m_puhMergeIndex; } |
---|
334 | UChar getMergeIndex ( UInt uiIdx ) { return m_puhMergeIndex[uiIdx]; } |
---|
335 | Void setMergeIndex ( UInt uiIdx, UInt uiMergeIndex ) { m_puhMergeIndex[uiIdx] = uiMergeIndex; } |
---|
336 | Void setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
337 | template <typename T> |
---|
338 | Void setSubPart ( T bParameter, T* pbBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ); |
---|
339 | |
---|
340 | #if AMP_MRG |
---|
341 | Void setMergeAMP( Bool b ) { m_bIsMergeAMP = b; } |
---|
342 | Bool getMergeAMP( ) { return m_bIsMergeAMP; } |
---|
343 | #endif |
---|
344 | |
---|
345 | UChar* getIntraDir ( const ChannelType channelType ) const { return m_puhIntraDir[channelType]; } |
---|
346 | UChar getIntraDir ( const ChannelType channelType, const UInt uiIdx ) const { return m_puhIntraDir[channelType][uiIdx]; } |
---|
347 | |
---|
348 | Void setIntraDirSubParts ( const ChannelType channelType, |
---|
349 | const UInt uiDir, |
---|
350 | const UInt uiAbsPartIdx, |
---|
351 | const UInt uiDepth ); |
---|
352 | |
---|
353 | UChar* getInterDir () { return m_puhInterDir; } |
---|
354 | UChar getInterDir ( UInt uiIdx ) { return m_puhInterDir[uiIdx]; } |
---|
355 | Void setInterDir ( UInt uiIdx, UChar uh ) { m_puhInterDir[uiIdx] = uh; } |
---|
356 | Void setInterDirSubParts ( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
357 | Bool* getIPCMFlag () { return m_pbIPCMFlag; } |
---|
358 | Bool getIPCMFlag (UInt uiIdx ) { return m_pbIPCMFlag[uiIdx]; } |
---|
359 | Void setIPCMFlag (UInt uiIdx, Bool b ) { m_pbIPCMFlag[uiIdx] = b; } |
---|
360 | Void setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth); |
---|
361 | |
---|
362 | // ------------------------------------------------------------------------------------------------------------------- |
---|
363 | // member functions for accessing partition information |
---|
364 | // ------------------------------------------------------------------------------------------------------------------- |
---|
365 | |
---|
366 | Void getPartIndexAndSize ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ); |
---|
367 | UChar getNumPartitions ( const UInt uiAbsPartIdx = 0 ); |
---|
368 | Bool isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth); |
---|
369 | |
---|
370 | // ------------------------------------------------------------------------------------------------------------------- |
---|
371 | // member functions for motion vector |
---|
372 | // ------------------------------------------------------------------------------------------------------------------- |
---|
373 | |
---|
374 | Void getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ); |
---|
375 | |
---|
376 | Void fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ); |
---|
377 | Bool isDiffMER ( Int xN, Int yN, Int xP, Int yP); |
---|
378 | Void getPartPosition ( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH); |
---|
379 | |
---|
380 | Void setMVPIdx ( RefPicList eRefPicList, UInt uiIdx, Int iMVPIdx) { m_apiMVPIdx[eRefPicList][uiIdx] = iMVPIdx; } |
---|
381 | Int getMVPIdx ( RefPicList eRefPicList, UInt uiIdx) { return m_apiMVPIdx[eRefPicList][uiIdx]; } |
---|
382 | Char* getMVPIdx ( RefPicList eRefPicList ) { return m_apiMVPIdx[eRefPicList]; } |
---|
383 | |
---|
384 | Void setMVPNum ( RefPicList eRefPicList, UInt uiIdx, Int iMVPNum ) { m_apiMVPNum[eRefPicList][uiIdx] = iMVPNum; } |
---|
385 | Int getMVPNum ( RefPicList eRefPicList, UInt uiIdx ) { return m_apiMVPNum[eRefPicList][uiIdx]; } |
---|
386 | Char* getMVPNum ( RefPicList eRefPicList ) { return m_apiMVPNum[eRefPicList]; } |
---|
387 | |
---|
388 | Void setMVPIdxSubParts ( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
389 | Void setMVPNumSubParts ( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ); |
---|
390 | |
---|
391 | Void clipMv ( TComMv& rcMv ); |
---|
392 | Void getMvPredLeft ( TComMv& rcMvPred ) { rcMvPred = m_cMvFieldA.getMv(); } |
---|
393 | Void getMvPredAbove ( TComMv& rcMvPred ) { rcMvPred = m_cMvFieldB.getMv(); } |
---|
394 | Void getMvPredAboveRight ( TComMv& rcMvPred ) { rcMvPred = m_cMvFieldC.getMv(); } |
---|
395 | |
---|
396 | Void compressMV (); |
---|
397 | |
---|
398 | // ------------------------------------------------------------------------------------------------------------------- |
---|
399 | // utility functions for neighbouring information |
---|
400 | // ------------------------------------------------------------------------------------------------------------------- |
---|
401 | |
---|
402 | TComDataCU* getCtuLeft () { return m_pCtuLeft; } |
---|
403 | TComDataCU* getCtuAbove () { return m_pCtuAbove; } |
---|
404 | TComDataCU* getCtuAboveLeft () { return m_pCtuAboveLeft; } |
---|
405 | TComDataCU* getCtuAboveRight () { return m_pCtuAboveRight; } |
---|
406 | TComDataCU* getCUColocated ( RefPicList eRefPicList ) { return m_apcCUColocated[eRefPicList]; } |
---|
407 | Bool CUIsFromSameSlice ( const TComDataCU *pCU /* Can be NULL */) const { return ( pCU!=NULL && pCU->getSlice()->getSliceCurStartCtuTsAddr() == getSlice()->getSliceCurStartCtuTsAddr() ); } |
---|
408 | Bool CUIsFromSameTile ( const TComDataCU *pCU /* Can be NULL */) const; |
---|
409 | Bool CUIsFromSameSliceAndTile ( const TComDataCU *pCU /* Can be NULL */) const; |
---|
410 | Bool CUIsFromSameSliceTileAndWavefrontRow( const TComDataCU *pCU /* Can be NULL */) const; |
---|
411 | Bool isLastSubCUOfCtu(const UInt absPartIdx); |
---|
412 | |
---|
413 | |
---|
414 | TComDataCU* getPULeft ( UInt& uiLPartUnitIdx, |
---|
415 | UInt uiCurrPartUnitIdx, |
---|
416 | Bool bEnforceSliceRestriction=true, |
---|
417 | Bool bEnforceTileRestriction=true ); |
---|
418 | TComDataCU* getPUAbove ( UInt& uiAPartUnitIdx, |
---|
419 | UInt uiCurrPartUnitIdx, |
---|
420 | Bool bEnforceSliceRestriction=true, |
---|
421 | Bool planarAtCTUBoundary = false, |
---|
422 | Bool bEnforceTileRestriction=true ); |
---|
423 | TComDataCU* getPUAboveLeft ( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true ); |
---|
424 | TComDataCU* getPUAboveRight ( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true ); |
---|
425 | TComDataCU* getPUBelowLeft ( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true ); |
---|
426 | |
---|
427 | TComDataCU* getQpMinCuLeft ( UInt& uiLPartUnitIdx , UInt uiCurrAbsIdxInCtu ); |
---|
428 | TComDataCU* getQpMinCuAbove ( UInt& uiAPartUnitIdx , UInt uiCurrAbsIdxInCtu ); |
---|
429 | Char getRefQP ( UInt uiCurrAbsIdxInCtu ); |
---|
430 | |
---|
431 | TComDataCU* getPUAboveRightAdi ( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true ); |
---|
432 | TComDataCU* getPUBelowLeftAdi ( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true ); |
---|
433 | |
---|
434 | Void deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ); |
---|
435 | Void deriveLeftBottomIdx ( UInt uiPartIdx, UInt& ruiPartIdxLB ); |
---|
436 | |
---|
437 | Void deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ); |
---|
438 | Void deriveLeftBottomIdxAdi ( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ); // NOTE: Unused function. |
---|
439 | |
---|
440 | Bool hasEqualMotion ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ); |
---|
441 | Void getInterMergeCandidates ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 ); |
---|
442 | |
---|
443 | Void deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ); |
---|
444 | Void deriveLeftBottomIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ); |
---|
445 | |
---|
446 | // ------------------------------------------------------------------------------------------------------------------- |
---|
447 | // member functions for modes |
---|
448 | // ------------------------------------------------------------------------------------------------------------------- |
---|
449 | |
---|
450 | Bool isIntra ( UInt uiPartIdx ) const { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; } |
---|
451 | Bool isInter ( UInt uiPartIdx ) const { return m_pePredMode[ uiPartIdx ] == MODE_INTER; } |
---|
452 | Bool isSkipped ( UInt uiPartIdx ); ///< SKIP (no residual) |
---|
453 | Bool isBipredRestriction( UInt puIdx ); |
---|
454 | |
---|
455 | // ------------------------------------------------------------------------------------------------------------------- |
---|
456 | // member functions for symbol prediction (most probable / mode conversion) |
---|
457 | // ------------------------------------------------------------------------------------------------------------------- |
---|
458 | |
---|
459 | UInt getIntraSizeIdx ( UInt uiAbsPartIdx ); |
---|
460 | |
---|
461 | Void getAllowedChromaDir ( UInt uiAbsPartIdx, UInt* uiModeList ); |
---|
462 | Int getIntraDirPredictor ( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode = NULL ); |
---|
463 | |
---|
464 | // ------------------------------------------------------------------------------------------------------------------- |
---|
465 | // member functions for SBAC context |
---|
466 | // ------------------------------------------------------------------------------------------------------------------- |
---|
467 | |
---|
468 | UInt getCtxSplitFlag ( UInt uiAbsPartIdx, UInt uiDepth ); |
---|
469 | UInt getCtxQtCbf ( TComTU &rTu, const ChannelType chType ); |
---|
470 | |
---|
471 | UInt getCtxSkipFlag ( UInt uiAbsPartIdx ); |
---|
472 | UInt getCtxInterDir ( UInt uiAbsPartIdx ); |
---|
473 | |
---|
474 | UInt& getTotalBins () { return m_uiTotalBins; } |
---|
475 | // ------------------------------------------------------------------------------------------------------------------- |
---|
476 | // member functions for RD cost storage |
---|
477 | // ------------------------------------------------------------------------------------------------------------------- |
---|
478 | |
---|
479 | Double& getTotalCost() { return m_dTotalCost; } |
---|
480 | Distortion& getTotalDistortion() { return m_uiTotalDistortion; } |
---|
481 | UInt& getTotalBits() { return m_uiTotalBits; } |
---|
482 | UInt& getTotalNumPart() { return m_uiNumPartition; } |
---|
483 | |
---|
484 | UInt getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const ; |
---|
485 | |
---|
486 | #if SVC_EXTENSION |
---|
487 | Void setLayerId (UInt layerId) { m_layerId = layerId; } |
---|
488 | UInt getLayerId () { return m_layerId; } |
---|
489 | UInt getLayerIdx () { return m_pcSlice->getVPS()->getLayerIdxInVps(m_layerId); } |
---|
490 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
491 | Bool isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1); |
---|
492 | #endif |
---|
493 | #if FAST_INTRA_SHVC |
---|
494 | Int reduceSetOfIntraModes ( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int &fullSetOfModes ); |
---|
495 | #endif |
---|
496 | #if REF_IDX_ME_ZEROMV |
---|
497 | Bool xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1); |
---|
498 | Bool xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx); |
---|
499 | #endif |
---|
500 | TComDataCU* getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Bool motionMapping = false ); |
---|
501 | TComDataCU* getBaseColCU( UInt refLayerIdc, UInt pelX, UInt pelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Bool motionMapping = false ); |
---|
502 | Void scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase ); |
---|
503 | #endif |
---|
504 | }; |
---|
505 | |
---|
506 | namespace RasterAddress |
---|
507 | { |
---|
508 | /** Check whether 2 addresses point to the same column |
---|
509 | * \param addrA First address in raster scan order |
---|
510 | * \param addrB Second address in raters scan order |
---|
511 | * \param numUnitsPerRow Number of units in a row |
---|
512 | * \return Result of test |
---|
513 | */ |
---|
514 | static inline Bool isEqualCol( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
515 | { |
---|
516 | // addrA % numUnitsPerRow == addrB % numUnitsPerRow |
---|
517 | return (( addrA ^ addrB ) & ( numUnitsPerRow - 1 ) ) == 0; |
---|
518 | } |
---|
519 | |
---|
520 | /** Check whether 2 addresses point to the same row |
---|
521 | * \param addrA First address in raster scan order |
---|
522 | * \param addrB Second address in raters scan order |
---|
523 | * \param numUnitsPerRow Number of units in a row |
---|
524 | * \return Result of test |
---|
525 | */ |
---|
526 | static inline Bool isEqualRow( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
527 | { |
---|
528 | // addrA / numUnitsPerRow == addrB / numUnitsPerRow |
---|
529 | return (( addrA ^ addrB ) &~ ( numUnitsPerRow - 1 ) ) == 0; |
---|
530 | } |
---|
531 | |
---|
532 | /** Check whether 2 addresses point to the same row or column |
---|
533 | * \param addrA First address in raster scan order |
---|
534 | * \param addrB Second address in raters scan order |
---|
535 | * \param numUnitsPerRow Number of units in a row |
---|
536 | * \return Result of test |
---|
537 | */ |
---|
538 | static inline Bool isEqualRowOrCol( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
539 | { |
---|
540 | return isEqualCol( addrA, addrB, numUnitsPerRow ) | isEqualRow( addrA, addrB, numUnitsPerRow ); |
---|
541 | } |
---|
542 | |
---|
543 | /** Check whether one address points to the first column |
---|
544 | * \param addr Address in raster scan order |
---|
545 | * \param numUnitsPerRow Number of units in a row |
---|
546 | * \return Result of test |
---|
547 | */ |
---|
548 | static inline Bool isZeroCol( Int addr, Int numUnitsPerRow ) |
---|
549 | { |
---|
550 | // addr % numUnitsPerRow == 0 |
---|
551 | return ( addr & ( numUnitsPerRow - 1 ) ) == 0; |
---|
552 | } |
---|
553 | |
---|
554 | /** Check whether one address points to the first row |
---|
555 | * \param addr Address in raster scan order |
---|
556 | * \param numUnitsPerRow Number of units in a row |
---|
557 | * \return Result of test |
---|
558 | */ |
---|
559 | static inline Bool isZeroRow( Int addr, Int numUnitsPerRow ) |
---|
560 | { |
---|
561 | // addr / numUnitsPerRow == 0 |
---|
562 | return ( addr &~ ( numUnitsPerRow - 1 ) ) == 0; |
---|
563 | } |
---|
564 | |
---|
565 | /** Check whether one address points to a column whose index is smaller than a given value |
---|
566 | * \param addr Address in raster scan order |
---|
567 | * \param val Given column index value |
---|
568 | * \param numUnitsPerRow Number of units in a row |
---|
569 | * \return Result of test |
---|
570 | */ |
---|
571 | static inline Bool lessThanCol( Int addr, Int val, Int numUnitsPerRow ) |
---|
572 | { |
---|
573 | // addr % numUnitsPerRow < val |
---|
574 | return ( addr & ( numUnitsPerRow - 1 ) ) < val; |
---|
575 | } |
---|
576 | |
---|
577 | /** Check whether one address points to a row whose index is smaller than a given value |
---|
578 | * \param addr Address in raster scan order |
---|
579 | * \param val Given row index value |
---|
580 | * \param numUnitsPerRow Number of units in a row |
---|
581 | * \return Result of test |
---|
582 | */ |
---|
583 | static inline Bool lessThanRow( Int addr, Int val, Int numUnitsPerRow ) |
---|
584 | { |
---|
585 | // addr / numUnitsPerRow < val |
---|
586 | return addr < val * numUnitsPerRow; |
---|
587 | } |
---|
588 | } |
---|
589 | |
---|
590 | //! \} |
---|
591 | |
---|
592 | #endif |
---|