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