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()->getSpsRangeExtension().getRdpcmEnabledFlag(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 | |
---|
417 | TComDataCU* getQpMinCuLeft ( UInt& uiLPartUnitIdx , UInt uiCurrAbsIdxInCtu ); |
---|
418 | TComDataCU* getQpMinCuAbove ( UInt& uiAPartUnitIdx , UInt uiCurrAbsIdxInCtu ); |
---|
419 | Char getRefQP ( UInt uiCurrAbsIdxInCtu ); |
---|
420 | |
---|
421 | /// returns CU and part index of the PU above the top row of the current uiCurrPartUnitIdx of the CU, at a horizontal offset (to the right) of uiPartUnitOffset (in parts) |
---|
422 | TComDataCU* getPUAboveRight ( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true ); |
---|
423 | /// returns CU and part index of the PU left of the lefthand column of the current uiCurrPartUnitIdx of the CU, at a vertical offset (below) of uiPartUnitOffset (in parts) |
---|
424 | TComDataCU* getPUBelowLeft ( 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 | Bool hasEqualMotion ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ); |
---|
430 | Void getInterMergeCandidates ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 ); |
---|
431 | |
---|
432 | Void deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ); |
---|
433 | Void deriveLeftBottomIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ); |
---|
434 | |
---|
435 | // ------------------------------------------------------------------------------------------------------------------- |
---|
436 | // member functions for modes |
---|
437 | // ------------------------------------------------------------------------------------------------------------------- |
---|
438 | |
---|
439 | Bool isIntra ( UInt uiPartIdx ) const { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; } |
---|
440 | Bool isInter ( UInt uiPartIdx ) const { return m_pePredMode[ uiPartIdx ] == MODE_INTER; } |
---|
441 | Bool isSkipped ( UInt uiPartIdx ); ///< returns true, if the partiton is skipped |
---|
442 | Bool isBipredRestriction( UInt puIdx ); |
---|
443 | |
---|
444 | // ------------------------------------------------------------------------------------------------------------------- |
---|
445 | // member functions for symbol prediction (most probable / mode conversion) |
---|
446 | // ------------------------------------------------------------------------------------------------------------------- |
---|
447 | |
---|
448 | UInt getIntraSizeIdx ( UInt uiAbsPartIdx ); |
---|
449 | |
---|
450 | Void getAllowedChromaDir ( UInt uiAbsPartIdx, UInt* uiModeList ); |
---|
451 | Void getIntraDirPredictor ( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode = NULL ); |
---|
452 | |
---|
453 | // ------------------------------------------------------------------------------------------------------------------- |
---|
454 | // member functions for SBAC context |
---|
455 | // ------------------------------------------------------------------------------------------------------------------- |
---|
456 | |
---|
457 | UInt getCtxSplitFlag ( UInt uiAbsPartIdx, UInt uiDepth ); |
---|
458 | UInt getCtxQtCbf ( TComTU &rTu, const ChannelType chType ); |
---|
459 | |
---|
460 | UInt getCtxSkipFlag ( UInt uiAbsPartIdx ); |
---|
461 | UInt getCtxInterDir ( UInt uiAbsPartIdx ); |
---|
462 | |
---|
463 | UInt& getTotalBins () { return m_uiTotalBins; } |
---|
464 | // ------------------------------------------------------------------------------------------------------------------- |
---|
465 | // member functions for RD cost storage |
---|
466 | // ------------------------------------------------------------------------------------------------------------------- |
---|
467 | |
---|
468 | Double& getTotalCost() { return m_dTotalCost; } |
---|
469 | Distortion& getTotalDistortion() { return m_uiTotalDistortion; } |
---|
470 | UInt& getTotalBits() { return m_uiTotalBits; } |
---|
471 | UInt& getTotalNumPart() { return m_uiNumPartition; } |
---|
472 | |
---|
473 | UInt getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const ; |
---|
474 | |
---|
475 | #if SVC_EXTENSION |
---|
476 | Void setLayerId (UInt layerId) { m_layerId = layerId; } |
---|
477 | UInt getLayerId () { return m_layerId; } |
---|
478 | UInt getLayerIdx () { return m_pcSlice->getVPS()->getLayerIdxInVps(m_layerId); } |
---|
479 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
480 | Bool isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1); |
---|
481 | #endif |
---|
482 | #if FAST_INTRA_SHVC |
---|
483 | Int reduceSetOfIntraModes ( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int &fullSetOfModes ); |
---|
484 | #endif |
---|
485 | #if REF_IDX_ME_ZEROMV |
---|
486 | Bool xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1); |
---|
487 | Bool xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx); |
---|
488 | #endif |
---|
489 | TComDataCU* getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Bool motionMapping = false ); |
---|
490 | TComDataCU* getBaseColCU( UInt refLayerIdc, UInt pelX, UInt pelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Bool motionMapping = false ); |
---|
491 | Void scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase ); |
---|
492 | #endif |
---|
493 | }; |
---|
494 | |
---|
495 | namespace RasterAddress |
---|
496 | { |
---|
497 | /** Check whether 2 addresses point to the same column |
---|
498 | * \param addrA First address in raster scan order |
---|
499 | * \param addrB Second address in raters scan order |
---|
500 | * \param numUnitsPerRow Number of units in a row |
---|
501 | * \return Result of test |
---|
502 | */ |
---|
503 | static inline Bool isEqualCol( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
504 | { |
---|
505 | // addrA % numUnitsPerRow == addrB % numUnitsPerRow |
---|
506 | return (( addrA ^ addrB ) & ( numUnitsPerRow - 1 ) ) == 0; |
---|
507 | } |
---|
508 | |
---|
509 | /** Check whether 2 addresses point to the same row |
---|
510 | * \param addrA First address in raster scan order |
---|
511 | * \param addrB Second address in raters scan order |
---|
512 | * \param numUnitsPerRow Number of units in a row |
---|
513 | * \return Result of test |
---|
514 | */ |
---|
515 | static inline Bool isEqualRow( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
516 | { |
---|
517 | // addrA / numUnitsPerRow == addrB / numUnitsPerRow |
---|
518 | return (( addrA ^ addrB ) &~ ( numUnitsPerRow - 1 ) ) == 0; |
---|
519 | } |
---|
520 | |
---|
521 | /** Check whether 2 addresses point to the same row or column |
---|
522 | * \param addrA First address in raster scan order |
---|
523 | * \param addrB Second address in raters scan order |
---|
524 | * \param numUnitsPerRow Number of units in a row |
---|
525 | * \return Result of test |
---|
526 | */ |
---|
527 | static inline Bool isEqualRowOrCol( Int addrA, Int addrB, Int numUnitsPerRow ) |
---|
528 | { |
---|
529 | return isEqualCol( addrA, addrB, numUnitsPerRow ) | isEqualRow( addrA, addrB, numUnitsPerRow ); |
---|
530 | } |
---|
531 | |
---|
532 | /** Check whether one address points to the first column |
---|
533 | * \param addr Address in raster scan order |
---|
534 | * \param numUnitsPerRow Number of units in a row |
---|
535 | * \return Result of test |
---|
536 | */ |
---|
537 | static inline Bool isZeroCol( Int addr, Int numUnitsPerRow ) |
---|
538 | { |
---|
539 | // addr % numUnitsPerRow == 0 |
---|
540 | return ( addr & ( numUnitsPerRow - 1 ) ) == 0; |
---|
541 | } |
---|
542 | |
---|
543 | /** Check whether one address points to the first row |
---|
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 isZeroRow( Int addr, Int numUnitsPerRow ) |
---|
549 | { |
---|
550 | // addr / numUnitsPerRow == 0 |
---|
551 | return ( addr &~ ( numUnitsPerRow - 1 ) ) == 0; |
---|
552 | } |
---|
553 | |
---|
554 | /** Check whether one address points to a column whose index is smaller than a given value |
---|
555 | * \param addr Address in raster scan order |
---|
556 | * \param val Given column index value |
---|
557 | * \param numUnitsPerRow Number of units in a row |
---|
558 | * \return Result of test |
---|
559 | */ |
---|
560 | static inline Bool lessThanCol( Int addr, Int val, Int numUnitsPerRow ) |
---|
561 | { |
---|
562 | // addr % numUnitsPerRow < val |
---|
563 | return ( addr & ( numUnitsPerRow - 1 ) ) < val; |
---|
564 | } |
---|
565 | |
---|
566 | /** Check whether one address points to a row whose index is smaller than a given value |
---|
567 | * \param addr Address in raster scan order |
---|
568 | * \param val Given row index value |
---|
569 | * \param numUnitsPerRow Number of units in a row |
---|
570 | * \return Result of test |
---|
571 | */ |
---|
572 | static inline Bool lessThanRow( Int addr, Int val, Int numUnitsPerRow ) |
---|
573 | { |
---|
574 | // addr / numUnitsPerRow < val |
---|
575 | return addr < val * numUnitsPerRow; |
---|
576 | } |
---|
577 | } |
---|
578 | |
---|
579 | //! \} |
---|
580 | |
---|
581 | #endif |
---|