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