1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TComDataCU.cpp |
---|
35 | \brief CU data structure |
---|
36 | \todo not all entities are documented |
---|
37 | */ |
---|
38 | |
---|
39 | #include "TComDataCU.h" |
---|
40 | #include "TComPic.h" |
---|
41 | |
---|
42 | //! \ingroup TLibCommon |
---|
43 | //! \{ |
---|
44 | |
---|
45 | #if ADAPTIVE_QP_SELECTION |
---|
46 | Int * TComDataCU::m_pcGlbArlCoeffY = NULL; |
---|
47 | Int * TComDataCU::m_pcGlbArlCoeffCb = NULL; |
---|
48 | Int * TComDataCU::m_pcGlbArlCoeffCr = NULL; |
---|
49 | #endif |
---|
50 | |
---|
51 | // ==================================================================================================================== |
---|
52 | // Constructor / destructor / create / destroy |
---|
53 | // ==================================================================================================================== |
---|
54 | |
---|
55 | TComDataCU::TComDataCU() |
---|
56 | { |
---|
57 | m_pcPic = NULL; |
---|
58 | m_pcSlice = NULL; |
---|
59 | m_puhDepth = NULL; |
---|
60 | |
---|
61 | m_skipFlag = NULL; |
---|
62 | |
---|
63 | m_pePartSize = NULL; |
---|
64 | m_pePredMode = NULL; |
---|
65 | m_CUTransquantBypass = NULL; |
---|
66 | m_puhWidth = NULL; |
---|
67 | m_puhHeight = NULL; |
---|
68 | m_phQP = NULL; |
---|
69 | m_pbMergeFlag = NULL; |
---|
70 | m_puhMergeIndex = NULL; |
---|
71 | m_puhLumaIntraDir = NULL; |
---|
72 | m_puhChromaIntraDir = NULL; |
---|
73 | m_puhInterDir = NULL; |
---|
74 | m_puhTrIdx = NULL; |
---|
75 | m_puhTransformSkip[0] = NULL; |
---|
76 | m_puhTransformSkip[1] = NULL; |
---|
77 | m_puhTransformSkip[2] = NULL; |
---|
78 | m_puhCbf[0] = NULL; |
---|
79 | m_puhCbf[1] = NULL; |
---|
80 | m_puhCbf[2] = NULL; |
---|
81 | m_pcTrCoeffY = NULL; |
---|
82 | m_pcTrCoeffCb = NULL; |
---|
83 | m_pcTrCoeffCr = NULL; |
---|
84 | #if ADAPTIVE_QP_SELECTION |
---|
85 | m_ArlCoeffIsAliasedAllocation = false; |
---|
86 | m_pcArlCoeffY = NULL; |
---|
87 | m_pcArlCoeffCb = NULL; |
---|
88 | m_pcArlCoeffCr = NULL; |
---|
89 | #endif |
---|
90 | |
---|
91 | m_pbIPCMFlag = NULL; |
---|
92 | m_pcIPCMSampleY = NULL; |
---|
93 | m_pcIPCMSampleCb = NULL; |
---|
94 | m_pcIPCMSampleCr = NULL; |
---|
95 | |
---|
96 | m_pcPattern = NULL; |
---|
97 | |
---|
98 | m_pcCUAboveLeft = NULL; |
---|
99 | m_pcCUAboveRight = NULL; |
---|
100 | m_pcCUAbove = NULL; |
---|
101 | m_pcCULeft = NULL; |
---|
102 | |
---|
103 | m_apcCUColocated[0] = NULL; |
---|
104 | m_apcCUColocated[1] = NULL; |
---|
105 | |
---|
106 | m_apiMVPIdx[0] = NULL; |
---|
107 | m_apiMVPIdx[1] = NULL; |
---|
108 | m_apiMVPNum[0] = NULL; |
---|
109 | m_apiMVPNum[1] = NULL; |
---|
110 | |
---|
111 | m_bDecSubCu = false; |
---|
112 | m_sliceStartCU = 0; |
---|
113 | m_sliceSegmentStartCU = 0; |
---|
114 | } |
---|
115 | |
---|
116 | TComDataCU::~TComDataCU() |
---|
117 | { |
---|
118 | } |
---|
119 | |
---|
120 | Void TComDataCU::create(UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
121 | #if ADAPTIVE_QP_SELECTION |
---|
122 | , Bool bGlobalRMARLBuffer |
---|
123 | #endif |
---|
124 | ) |
---|
125 | { |
---|
126 | m_bDecSubCu = bDecSubCu; |
---|
127 | |
---|
128 | m_pcPic = NULL; |
---|
129 | m_pcSlice = NULL; |
---|
130 | m_uiNumPartition = uiNumPartition; |
---|
131 | m_unitSize = unitSize; |
---|
132 | |
---|
133 | if ( !bDecSubCu ) |
---|
134 | { |
---|
135 | m_phQP = (Char* )xMalloc(Char, uiNumPartition); |
---|
136 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
137 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
138 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
139 | |
---|
140 | m_skipFlag = new Bool[ uiNumPartition ]; |
---|
141 | |
---|
142 | m_pePartSize = new Char[ uiNumPartition ]; |
---|
143 | memset( m_pePartSize, SIZE_NONE,uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
144 | m_pePredMode = new Char[ uiNumPartition ]; |
---|
145 | m_CUTransquantBypass = new Bool[ uiNumPartition ]; |
---|
146 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
147 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
148 | m_puhLumaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
149 | m_puhChromaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
150 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
151 | |
---|
152 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
153 | m_puhTransformSkip[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
154 | m_puhTransformSkip[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
155 | m_puhTransformSkip[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
156 | |
---|
157 | m_puhCbf[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
158 | m_puhCbf[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
159 | m_puhCbf[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
160 | |
---|
161 | m_apiMVPIdx[0] = new Char[ uiNumPartition ]; |
---|
162 | m_apiMVPIdx[1] = new Char[ uiNumPartition ]; |
---|
163 | m_apiMVPNum[0] = new Char[ uiNumPartition ]; |
---|
164 | m_apiMVPNum[1] = new Char[ uiNumPartition ]; |
---|
165 | memset( m_apiMVPIdx[0], -1,uiNumPartition * sizeof( Char ) ); |
---|
166 | memset( m_apiMVPIdx[1], -1,uiNumPartition * sizeof( Char ) ); |
---|
167 | |
---|
168 | m_pcTrCoeffY = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight); |
---|
169 | m_pcTrCoeffCb = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
170 | m_pcTrCoeffCr = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
171 | memset( m_pcTrCoeffY, 0,uiWidth*uiHeight * sizeof( TCoeff ) ); |
---|
172 | memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
---|
173 | memset( m_pcTrCoeffCr, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
---|
174 | #if ADAPTIVE_QP_SELECTION |
---|
175 | if( bGlobalRMARLBuffer ) |
---|
176 | { |
---|
177 | if( m_pcGlbArlCoeffY == NULL ) |
---|
178 | { |
---|
179 | m_pcGlbArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
---|
180 | m_pcGlbArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
181 | m_pcGlbArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
182 | } |
---|
183 | m_pcArlCoeffY = m_pcGlbArlCoeffY; |
---|
184 | m_pcArlCoeffCb = m_pcGlbArlCoeffCb; |
---|
185 | m_pcArlCoeffCr = m_pcGlbArlCoeffCr; |
---|
186 | m_ArlCoeffIsAliasedAllocation = true; |
---|
187 | } |
---|
188 | else |
---|
189 | { |
---|
190 | m_pcArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
---|
191 | m_pcArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
192 | m_pcArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
193 | } |
---|
194 | #endif |
---|
195 | |
---|
196 | m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
197 | m_pcIPCMSampleY = (Pel* )xMalloc(Pel , uiWidth*uiHeight); |
---|
198 | m_pcIPCMSampleCb = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
---|
199 | m_pcIPCMSampleCr = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
---|
200 | |
---|
201 | m_acCUMvField[0].create( uiNumPartition ); |
---|
202 | m_acCUMvField[1].create( uiNumPartition ); |
---|
203 | |
---|
204 | } |
---|
205 | else |
---|
206 | { |
---|
207 | m_acCUMvField[0].setNumPartition(uiNumPartition ); |
---|
208 | m_acCUMvField[1].setNumPartition(uiNumPartition ); |
---|
209 | } |
---|
210 | |
---|
211 | m_sliceStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
212 | m_sliceSegmentStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
213 | |
---|
214 | // create pattern memory |
---|
215 | m_pcPattern = (TComPattern*)xMalloc(TComPattern, 1); |
---|
216 | |
---|
217 | // create motion vector fields |
---|
218 | |
---|
219 | m_pcCUAboveLeft = NULL; |
---|
220 | m_pcCUAboveRight = NULL; |
---|
221 | m_pcCUAbove = NULL; |
---|
222 | m_pcCULeft = NULL; |
---|
223 | |
---|
224 | m_apcCUColocated[0] = NULL; |
---|
225 | m_apcCUColocated[1] = NULL; |
---|
226 | } |
---|
227 | |
---|
228 | Void TComDataCU::destroy() |
---|
229 | { |
---|
230 | m_pcPic = NULL; |
---|
231 | m_pcSlice = NULL; |
---|
232 | |
---|
233 | if ( m_pcPattern ) |
---|
234 | { |
---|
235 | xFree(m_pcPattern); |
---|
236 | m_pcPattern = NULL; |
---|
237 | } |
---|
238 | |
---|
239 | // encoder-side buffer free |
---|
240 | if ( !m_bDecSubCu ) |
---|
241 | { |
---|
242 | if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } |
---|
243 | if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } |
---|
244 | if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } |
---|
245 | if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } |
---|
246 | |
---|
247 | if ( m_skipFlag ) { delete[] m_skipFlag; m_skipFlag = NULL; } |
---|
248 | |
---|
249 | if ( m_pePartSize ) { delete[] m_pePartSize; m_pePartSize = NULL; } |
---|
250 | if ( m_pePredMode ) { delete[] m_pePredMode; m_pePredMode = NULL; } |
---|
251 | if ( m_CUTransquantBypass ) { delete[] m_CUTransquantBypass;m_CUTransquantBypass = NULL; } |
---|
252 | if ( m_puhCbf[0] ) { xFree(m_puhCbf[0]); m_puhCbf[0] = NULL; } |
---|
253 | if ( m_puhCbf[1] ) { xFree(m_puhCbf[1]); m_puhCbf[1] = NULL; } |
---|
254 | if ( m_puhCbf[2] ) { xFree(m_puhCbf[2]); m_puhCbf[2] = NULL; } |
---|
255 | if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } |
---|
256 | if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } |
---|
257 | if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } |
---|
258 | if ( m_puhLumaIntraDir ) { xFree(m_puhLumaIntraDir); m_puhLumaIntraDir = NULL; } |
---|
259 | if ( m_puhChromaIntraDir ) { xFree(m_puhChromaIntraDir); m_puhChromaIntraDir = NULL; } |
---|
260 | if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } |
---|
261 | if ( m_puhTransformSkip[0]) { xFree(m_puhTransformSkip[0]); m_puhTransformSkip[0] = NULL; } |
---|
262 | if ( m_puhTransformSkip[1]) { xFree(m_puhTransformSkip[1]); m_puhTransformSkip[1] = NULL; } |
---|
263 | if ( m_puhTransformSkip[2]) { xFree(m_puhTransformSkip[2]); m_puhTransformSkip[2] = NULL; } |
---|
264 | if ( m_pcTrCoeffY ) { xFree(m_pcTrCoeffY); m_pcTrCoeffY = NULL; } |
---|
265 | if ( m_pcTrCoeffCb ) { xFree(m_pcTrCoeffCb); m_pcTrCoeffCb = NULL; } |
---|
266 | if ( m_pcTrCoeffCr ) { xFree(m_pcTrCoeffCr); m_pcTrCoeffCr = NULL; } |
---|
267 | #if ADAPTIVE_QP_SELECTION |
---|
268 | if (!m_ArlCoeffIsAliasedAllocation) |
---|
269 | { |
---|
270 | xFree(m_pcArlCoeffY); m_pcArlCoeffY = 0; |
---|
271 | xFree(m_pcArlCoeffCb); m_pcArlCoeffCb = 0; |
---|
272 | xFree(m_pcArlCoeffCr); m_pcArlCoeffCr = 0; |
---|
273 | } |
---|
274 | if ( m_pcGlbArlCoeffY ) { xFree(m_pcGlbArlCoeffY); m_pcGlbArlCoeffY = NULL; } |
---|
275 | if ( m_pcGlbArlCoeffCb ) { xFree(m_pcGlbArlCoeffCb); m_pcGlbArlCoeffCb = NULL; } |
---|
276 | if ( m_pcGlbArlCoeffCr ) { xFree(m_pcGlbArlCoeffCr); m_pcGlbArlCoeffCr = NULL; } |
---|
277 | #endif |
---|
278 | if ( m_pbIPCMFlag ) { xFree(m_pbIPCMFlag ); m_pbIPCMFlag = NULL; } |
---|
279 | if ( m_pcIPCMSampleY ) { xFree(m_pcIPCMSampleY); m_pcIPCMSampleY = NULL; } |
---|
280 | if ( m_pcIPCMSampleCb ) { xFree(m_pcIPCMSampleCb); m_pcIPCMSampleCb = NULL; } |
---|
281 | if ( m_pcIPCMSampleCr ) { xFree(m_pcIPCMSampleCr); m_pcIPCMSampleCr = NULL; } |
---|
282 | if ( m_apiMVPIdx[0] ) { delete[] m_apiMVPIdx[0]; m_apiMVPIdx[0] = NULL; } |
---|
283 | if ( m_apiMVPIdx[1] ) { delete[] m_apiMVPIdx[1]; m_apiMVPIdx[1] = NULL; } |
---|
284 | if ( m_apiMVPNum[0] ) { delete[] m_apiMVPNum[0]; m_apiMVPNum[0] = NULL; } |
---|
285 | if ( m_apiMVPNum[1] ) { delete[] m_apiMVPNum[1]; m_apiMVPNum[1] = NULL; } |
---|
286 | |
---|
287 | m_acCUMvField[0].destroy(); |
---|
288 | m_acCUMvField[1].destroy(); |
---|
289 | |
---|
290 | } |
---|
291 | |
---|
292 | m_pcCUAboveLeft = NULL; |
---|
293 | m_pcCUAboveRight = NULL; |
---|
294 | m_pcCUAbove = NULL; |
---|
295 | m_pcCULeft = NULL; |
---|
296 | |
---|
297 | m_apcCUColocated[0] = NULL; |
---|
298 | m_apcCUColocated[1] = NULL; |
---|
299 | |
---|
300 | if( m_sliceStartCU ) |
---|
301 | { |
---|
302 | xFree(m_sliceStartCU); |
---|
303 | m_sliceStartCU=NULL; |
---|
304 | } |
---|
305 | if(m_sliceSegmentStartCU ) |
---|
306 | { |
---|
307 | xFree(m_sliceSegmentStartCU); |
---|
308 | m_sliceSegmentStartCU=NULL; |
---|
309 | } |
---|
310 | } |
---|
311 | |
---|
312 | const NDBFBlockInfo& NDBFBlockInfo::operator= (const NDBFBlockInfo& src) |
---|
313 | { |
---|
314 | this->tileID = src.tileID; |
---|
315 | this->sliceID= src.sliceID; |
---|
316 | this->startSU= src.startSU; |
---|
317 | this->endSU = src.endSU; |
---|
318 | this->widthSU= src.widthSU; |
---|
319 | this->heightSU=src.heightSU; |
---|
320 | this->posX = src.posX; |
---|
321 | this->posY = src.posY; |
---|
322 | this->width = src.width; |
---|
323 | this->height = src.height; |
---|
324 | ::memcpy(this->isBorderAvailable, src.isBorderAvailable, sizeof(Bool)*((Int)NUM_SGU_BORDER)); |
---|
325 | this->allBordersAvailable = src.allBordersAvailable; |
---|
326 | |
---|
327 | return *this; |
---|
328 | } |
---|
329 | |
---|
330 | |
---|
331 | // ==================================================================================================================== |
---|
332 | // Public member functions |
---|
333 | // ==================================================================================================================== |
---|
334 | |
---|
335 | // -------------------------------------------------------------------------------------------------------------------- |
---|
336 | // Initialization |
---|
337 | // -------------------------------------------------------------------------------------------------------------------- |
---|
338 | |
---|
339 | /** |
---|
340 | - initialize top-level CU |
---|
341 | - internal buffers are already created |
---|
342 | - set values before encoding a CU |
---|
343 | . |
---|
344 | \param pcPic picture (TComPic) class pointer |
---|
345 | \param iCUAddr CU address |
---|
346 | */ |
---|
347 | Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr ) |
---|
348 | { |
---|
349 | |
---|
350 | m_pcPic = pcPic; |
---|
351 | m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
352 | m_uiCUAddr = iCUAddr; |
---|
353 | m_uiCUPelX = ( iCUAddr % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth; |
---|
354 | m_uiCUPelY = ( iCUAddr / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight; |
---|
355 | m_uiAbsIdxInLCU = 0; |
---|
356 | m_dTotalCost = MAX_DOUBLE; |
---|
357 | m_uiTotalDistortion = 0; |
---|
358 | m_uiTotalBits = 0; |
---|
359 | m_uiTotalBins = 0; |
---|
360 | m_uiNumPartition = pcPic->getNumPartInCU(); |
---|
361 | |
---|
362 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
---|
363 | { |
---|
364 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceCurStartCUAddr()) |
---|
365 | { |
---|
366 | m_sliceStartCU[i]=getSlice()->getSliceCurStartCUAddr(); |
---|
367 | } |
---|
368 | else |
---|
369 | { |
---|
370 | m_sliceStartCU[i]=pcPic->getCU(getAddr())->m_sliceStartCU[i]; |
---|
371 | } |
---|
372 | } |
---|
373 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
---|
374 | { |
---|
375 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
376 | { |
---|
377 | m_sliceSegmentStartCU[i]=getSlice()->getSliceSegmentCurStartCUAddr(); |
---|
378 | } |
---|
379 | else |
---|
380 | { |
---|
381 | m_sliceSegmentStartCU[i]=pcPic->getCU(getAddr())->m_sliceSegmentStartCU[i]; |
---|
382 | } |
---|
383 | } |
---|
384 | |
---|
385 | Int partStartIdx = getSlice()->getSliceSegmentCurStartCUAddr() - pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr) * pcPic->getNumPartInCU(); |
---|
386 | |
---|
387 | Int numElements = min<Int>( partStartIdx, m_uiNumPartition ); |
---|
388 | for ( Int ui = 0; ui < numElements; ui++ ) |
---|
389 | { |
---|
390 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
---|
391 | m_skipFlag[ui] = pcFrom->getSkipFlag(ui); |
---|
392 | m_pePartSize[ui] = pcFrom->getPartitionSize(ui); |
---|
393 | m_pePredMode[ui] = pcFrom->getPredictionMode(ui); |
---|
394 | m_CUTransquantBypass[ui] = pcFrom->getCUTransquantBypass(ui); |
---|
395 | m_puhDepth[ui] = pcFrom->getDepth(ui); |
---|
396 | m_puhWidth [ui] = pcFrom->getWidth(ui); |
---|
397 | m_puhHeight [ui] = pcFrom->getHeight(ui); |
---|
398 | m_puhTrIdx [ui] = pcFrom->getTransformIdx(ui); |
---|
399 | m_puhTransformSkip[0][ui] = pcFrom->getTransformSkip(ui,TEXT_LUMA); |
---|
400 | m_puhTransformSkip[1][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_U); |
---|
401 | m_puhTransformSkip[2][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_V); |
---|
402 | m_apiMVPIdx[0][ui] = pcFrom->m_apiMVPIdx[0][ui];; |
---|
403 | m_apiMVPIdx[1][ui] = pcFrom->m_apiMVPIdx[1][ui]; |
---|
404 | m_apiMVPNum[0][ui] = pcFrom->m_apiMVPNum[0][ui]; |
---|
405 | m_apiMVPNum[1][ui] = pcFrom->m_apiMVPNum[1][ui]; |
---|
406 | m_phQP[ui]=pcFrom->m_phQP[ui]; |
---|
407 | m_pbMergeFlag[ui]=pcFrom->m_pbMergeFlag[ui]; |
---|
408 | m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui]; |
---|
409 | m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui]; |
---|
410 | m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui]; |
---|
411 | m_puhInterDir[ui]=pcFrom->m_puhInterDir[ui]; |
---|
412 | m_puhCbf[0][ui]=pcFrom->m_puhCbf[0][ui]; |
---|
413 | m_puhCbf[1][ui]=pcFrom->m_puhCbf[1][ui]; |
---|
414 | m_puhCbf[2][ui]=pcFrom->m_puhCbf[2][ui]; |
---|
415 | m_pbIPCMFlag[ui] = pcFrom->m_pbIPCMFlag[ui]; |
---|
416 | } |
---|
417 | |
---|
418 | Int firstElement = max<Int>( partStartIdx, 0 ); |
---|
419 | numElements = m_uiNumPartition - firstElement; |
---|
420 | |
---|
421 | if ( numElements > 0 ) |
---|
422 | { |
---|
423 | memset( m_skipFlag + firstElement, false, numElements * sizeof( *m_skipFlag ) ); |
---|
424 | |
---|
425 | memset( m_pePartSize + firstElement, SIZE_NONE, numElements * sizeof( *m_pePartSize ) ); |
---|
426 | memset( m_pePredMode + firstElement, MODE_NONE, numElements * sizeof( *m_pePredMode ) ); |
---|
427 | memset( m_CUTransquantBypass+ firstElement, false, numElements * sizeof( *m_CUTransquantBypass) ); |
---|
428 | memset( m_puhDepth + firstElement, 0, numElements * sizeof( *m_puhDepth ) ); |
---|
429 | memset( m_puhTrIdx + firstElement, 0, numElements * sizeof( *m_puhTrIdx ) ); |
---|
430 | memset( m_puhTransformSkip[0] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[0]) ); |
---|
431 | memset( m_puhTransformSkip[1] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[1]) ); |
---|
432 | memset( m_puhTransformSkip[2] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[2]) ); |
---|
433 | memset( m_puhWidth + firstElement, g_uiMaxCUWidth, numElements * sizeof( *m_puhWidth ) ); |
---|
434 | memset( m_puhHeight + firstElement, g_uiMaxCUHeight, numElements * sizeof( *m_puhHeight ) ); |
---|
435 | memset( m_apiMVPIdx[0] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[0] ) ); |
---|
436 | memset( m_apiMVPIdx[1] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[1] ) ); |
---|
437 | memset( m_apiMVPNum[0] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[0] ) ); |
---|
438 | memset( m_apiMVPNum[1] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[1] ) ); |
---|
439 | memset( m_phQP + firstElement, getSlice()->getSliceQp(), numElements * sizeof( *m_phQP ) ); |
---|
440 | memset( m_pbMergeFlag + firstElement, false, numElements * sizeof( *m_pbMergeFlag ) ); |
---|
441 | memset( m_puhMergeIndex + firstElement, 0, numElements * sizeof( *m_puhMergeIndex ) ); |
---|
442 | memset( m_puhLumaIntraDir + firstElement, DC_IDX, numElements * sizeof( *m_puhLumaIntraDir ) ); |
---|
443 | memset( m_puhChromaIntraDir + firstElement, 0, numElements * sizeof( *m_puhChromaIntraDir ) ); |
---|
444 | memset( m_puhInterDir + firstElement, 0, numElements * sizeof( *m_puhInterDir ) ); |
---|
445 | memset( m_puhCbf[0] + firstElement, 0, numElements * sizeof( *m_puhCbf[0] ) ); |
---|
446 | memset( m_puhCbf[1] + firstElement, 0, numElements * sizeof( *m_puhCbf[1] ) ); |
---|
447 | memset( m_puhCbf[2] + firstElement, 0, numElements * sizeof( *m_puhCbf[2] ) ); |
---|
448 | memset( m_pbIPCMFlag + firstElement, false, numElements * sizeof( *m_pbIPCMFlag ) ); |
---|
449 | } |
---|
450 | |
---|
451 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight; |
---|
452 | if ( 0 >= partStartIdx ) |
---|
453 | { |
---|
454 | m_acCUMvField[0].clearMvField(); |
---|
455 | m_acCUMvField[1].clearMvField(); |
---|
456 | memset( m_pcTrCoeffY , 0, sizeof( TCoeff ) * uiTmp ); |
---|
457 | #if ADAPTIVE_QP_SELECTION |
---|
458 | memset( m_pcArlCoeffY , 0, sizeof( Int ) * uiTmp ); |
---|
459 | #endif |
---|
460 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
---|
461 | uiTmp >>= 2; |
---|
462 | memset( m_pcTrCoeffCb, 0, sizeof( TCoeff ) * uiTmp ); |
---|
463 | memset( m_pcTrCoeffCr, 0, sizeof( TCoeff ) * uiTmp ); |
---|
464 | #if ADAPTIVE_QP_SELECTION |
---|
465 | memset( m_pcArlCoeffCb, 0, sizeof( Int ) * uiTmp ); |
---|
466 | memset( m_pcArlCoeffCr, 0, sizeof( Int ) * uiTmp ); |
---|
467 | #endif |
---|
468 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
---|
469 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
---|
470 | } |
---|
471 | else |
---|
472 | { |
---|
473 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
---|
474 | m_acCUMvField[0].copyFrom(&pcFrom->m_acCUMvField[0],m_uiNumPartition,0); |
---|
475 | m_acCUMvField[1].copyFrom(&pcFrom->m_acCUMvField[1],m_uiNumPartition,0); |
---|
476 | for(Int i=0; i<uiTmp; i++) |
---|
477 | { |
---|
478 | m_pcTrCoeffY[i]=pcFrom->m_pcTrCoeffY[i]; |
---|
479 | #if ADAPTIVE_QP_SELECTION |
---|
480 | m_pcArlCoeffY[i]=pcFrom->m_pcArlCoeffY[i]; |
---|
481 | #endif |
---|
482 | m_pcIPCMSampleY[i]=pcFrom->m_pcIPCMSampleY[i]; |
---|
483 | } |
---|
484 | for(Int i=0; i<(uiTmp>>2); i++) |
---|
485 | { |
---|
486 | m_pcTrCoeffCb[i]=pcFrom->m_pcTrCoeffCb[i]; |
---|
487 | m_pcTrCoeffCr[i]=pcFrom->m_pcTrCoeffCr[i]; |
---|
488 | #if ADAPTIVE_QP_SELECTION |
---|
489 | m_pcArlCoeffCb[i]=pcFrom->m_pcArlCoeffCb[i]; |
---|
490 | m_pcArlCoeffCr[i]=pcFrom->m_pcArlCoeffCr[i]; |
---|
491 | #endif |
---|
492 | m_pcIPCMSampleCb[i]=pcFrom->m_pcIPCMSampleCb[i]; |
---|
493 | m_pcIPCMSampleCr[i]=pcFrom->m_pcIPCMSampleCr[i]; |
---|
494 | } |
---|
495 | } |
---|
496 | |
---|
497 | // Setting neighbor CU |
---|
498 | m_pcCULeft = NULL; |
---|
499 | m_pcCUAbove = NULL; |
---|
500 | m_pcCUAboveLeft = NULL; |
---|
501 | m_pcCUAboveRight = NULL; |
---|
502 | |
---|
503 | m_apcCUColocated[0] = NULL; |
---|
504 | m_apcCUColocated[1] = NULL; |
---|
505 | |
---|
506 | UInt uiWidthInCU = pcPic->getFrameWidthInCU(); |
---|
507 | if ( m_uiCUAddr % uiWidthInCU ) |
---|
508 | { |
---|
509 | m_pcCULeft = pcPic->getCU( m_uiCUAddr - 1 ); |
---|
510 | } |
---|
511 | |
---|
512 | if ( m_uiCUAddr / uiWidthInCU ) |
---|
513 | { |
---|
514 | m_pcCUAbove = pcPic->getCU( m_uiCUAddr - uiWidthInCU ); |
---|
515 | } |
---|
516 | |
---|
517 | if ( m_pcCULeft && m_pcCUAbove ) |
---|
518 | { |
---|
519 | m_pcCUAboveLeft = pcPic->getCU( m_uiCUAddr - uiWidthInCU - 1 ); |
---|
520 | } |
---|
521 | |
---|
522 | if ( m_pcCUAbove && ( (m_uiCUAddr%uiWidthInCU) < (uiWidthInCU-1) ) ) |
---|
523 | { |
---|
524 | m_pcCUAboveRight = pcPic->getCU( m_uiCUAddr - uiWidthInCU + 1 ); |
---|
525 | } |
---|
526 | |
---|
527 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) |
---|
528 | { |
---|
529 | m_apcCUColocated[0] = getSlice()->getRefPic( REF_PIC_LIST_0, 0)->getCU( m_uiCUAddr ); |
---|
530 | } |
---|
531 | |
---|
532 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) |
---|
533 | { |
---|
534 | m_apcCUColocated[1] = getSlice()->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr ); |
---|
535 | } |
---|
536 | } |
---|
537 | |
---|
538 | /** initialize prediction data with enabling sub-LCU-level delta QP |
---|
539 | *\param uiDepth depth of the current CU |
---|
540 | *\param qp qp for the current CU |
---|
541 | *- set CU width and CU height according to depth |
---|
542 | *- set qp value according to input qp |
---|
543 | *- set last-coded qp value according to input last-coded qp |
---|
544 | */ |
---|
545 | Void TComDataCU::initEstData( UInt uiDepth, Int qp ) |
---|
546 | { |
---|
547 | m_dTotalCost = MAX_DOUBLE; |
---|
548 | m_uiTotalDistortion = 0; |
---|
549 | m_uiTotalBits = 0; |
---|
550 | m_uiTotalBins = 0; |
---|
551 | |
---|
552 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
553 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
554 | |
---|
555 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
556 | { |
---|
557 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui >= getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
558 | { |
---|
559 | m_apiMVPIdx[0][ui] = -1; |
---|
560 | m_apiMVPIdx[1][ui] = -1; |
---|
561 | m_apiMVPNum[0][ui] = -1; |
---|
562 | m_apiMVPNum[1][ui] = -1; |
---|
563 | m_puhDepth [ui] = uiDepth; |
---|
564 | m_puhWidth [ui] = uhWidth; |
---|
565 | m_puhHeight [ui] = uhHeight; |
---|
566 | m_puhTrIdx [ui] = 0; |
---|
567 | m_puhTransformSkip[0][ui] = 0; |
---|
568 | m_puhTransformSkip[1][ui] = 0; |
---|
569 | m_puhTransformSkip[2][ui] = 0; |
---|
570 | m_skipFlag[ui] = false; |
---|
571 | m_pePartSize[ui] = SIZE_NONE; |
---|
572 | m_pePredMode[ui] = MODE_NONE; |
---|
573 | m_CUTransquantBypass[ui] = false; |
---|
574 | m_pbIPCMFlag[ui] = 0; |
---|
575 | m_phQP[ui] = qp; |
---|
576 | m_pbMergeFlag[ui] = 0; |
---|
577 | m_puhMergeIndex[ui] = 0; |
---|
578 | m_puhLumaIntraDir[ui] = DC_IDX; |
---|
579 | m_puhChromaIntraDir[ui] = 0; |
---|
580 | m_puhInterDir[ui] = 0; |
---|
581 | m_puhCbf[0][ui] = 0; |
---|
582 | m_puhCbf[1][ui] = 0; |
---|
583 | m_puhCbf[2][ui] = 0; |
---|
584 | } |
---|
585 | } |
---|
586 | |
---|
587 | UInt uiTmp = uhWidth*uhHeight; |
---|
588 | |
---|
589 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU >= getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
590 | { |
---|
591 | m_acCUMvField[0].clearMvField(); |
---|
592 | m_acCUMvField[1].clearMvField(); |
---|
593 | uiTmp = uhWidth*uhHeight; |
---|
594 | |
---|
595 | memset( m_pcTrCoeffY, 0, uiTmp * sizeof( *m_pcTrCoeffY ) ); |
---|
596 | #if ADAPTIVE_QP_SELECTION |
---|
597 | memset( m_pcArlCoeffY , 0, uiTmp * sizeof( *m_pcArlCoeffY ) ); |
---|
598 | #endif |
---|
599 | memset( m_pcIPCMSampleY, 0, uiTmp * sizeof( *m_pcIPCMSampleY ) ); |
---|
600 | |
---|
601 | uiTmp>>=2; |
---|
602 | memset( m_pcTrCoeffCb, 0, uiTmp * sizeof( *m_pcTrCoeffCb ) ); |
---|
603 | memset( m_pcTrCoeffCr, 0, uiTmp * sizeof( *m_pcTrCoeffCr ) ); |
---|
604 | #if ADAPTIVE_QP_SELECTION |
---|
605 | memset( m_pcArlCoeffCb, 0, uiTmp * sizeof( *m_pcArlCoeffCb ) ); |
---|
606 | memset( m_pcArlCoeffCr, 0, uiTmp * sizeof( *m_pcArlCoeffCr ) ); |
---|
607 | #endif |
---|
608 | memset( m_pcIPCMSampleCb, 0, uiTmp * sizeof( *m_pcIPCMSampleCb ) ); |
---|
609 | memset( m_pcIPCMSampleCr, 0, uiTmp * sizeof( *m_pcIPCMSampleCr ) ); |
---|
610 | } |
---|
611 | } |
---|
612 | |
---|
613 | |
---|
614 | // initialize Sub partition |
---|
615 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ) |
---|
616 | { |
---|
617 | assert( uiPartUnitIdx<4 ); |
---|
618 | |
---|
619 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
---|
620 | |
---|
621 | m_pcPic = pcCU->getPic(); |
---|
622 | m_pcSlice = m_pcPic->getSlice(m_pcPic->getCurrSliceIdx()); |
---|
623 | m_uiCUAddr = pcCU->getAddr(); |
---|
624 | m_uiAbsIdxInLCU = pcCU->getZorderIdxInCU() + uiPartOffset; |
---|
625 | |
---|
626 | m_uiCUPelX = pcCU->getCUPelX() + ( g_uiMaxCUWidth>>uiDepth )*( uiPartUnitIdx & 1 ); |
---|
627 | m_uiCUPelY = pcCU->getCUPelY() + ( g_uiMaxCUHeight>>uiDepth )*( uiPartUnitIdx >> 1 ); |
---|
628 | |
---|
629 | m_dTotalCost = MAX_DOUBLE; |
---|
630 | m_uiTotalDistortion = 0; |
---|
631 | m_uiTotalBits = 0; |
---|
632 | m_uiTotalBins = 0; |
---|
633 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
---|
634 | |
---|
635 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
636 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
637 | |
---|
638 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
639 | memset( m_phQP, qp, sizeInChar ); |
---|
640 | |
---|
641 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
642 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
643 | memset( m_puhLumaIntraDir, DC_IDX, iSizeInUchar ); |
---|
644 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
---|
645 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
646 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
647 | memset( m_puhTransformSkip[0], 0, iSizeInUchar ); |
---|
648 | memset( m_puhTransformSkip[1], 0, iSizeInUchar ); |
---|
649 | memset( m_puhTransformSkip[2], 0, iSizeInUchar ); |
---|
650 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
---|
651 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
---|
652 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
---|
653 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
---|
654 | |
---|
655 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
656 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
657 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
658 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
659 | memset( m_pbIPCMFlag, 0, iSizeInBool ); |
---|
660 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
661 | { |
---|
662 | m_skipFlag[ui] = false; |
---|
663 | m_pePartSize[ui] = SIZE_NONE; |
---|
664 | m_pePredMode[ui] = MODE_NONE; |
---|
665 | m_CUTransquantBypass[ui] = false; |
---|
666 | m_apiMVPIdx[0][ui] = -1; |
---|
667 | m_apiMVPIdx[1][ui] = -1; |
---|
668 | m_apiMVPNum[0][ui] = -1; |
---|
669 | m_apiMVPNum[1][ui] = -1; |
---|
670 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui<getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
671 | { |
---|
672 | m_apiMVPIdx[0][ui] = pcCU->m_apiMVPIdx[0][uiPartOffset+ui]; |
---|
673 | m_apiMVPIdx[1][ui] = pcCU->m_apiMVPIdx[1][uiPartOffset+ui];; |
---|
674 | m_apiMVPNum[0][ui] = pcCU->m_apiMVPNum[0][uiPartOffset+ui];; |
---|
675 | m_apiMVPNum[1][ui] = pcCU->m_apiMVPNum[1][uiPartOffset+ui];; |
---|
676 | m_puhDepth [ui] = pcCU->getDepth(uiPartOffset+ui); |
---|
677 | m_puhWidth [ui] = pcCU->getWidth(uiPartOffset+ui); |
---|
678 | m_puhHeight [ui] = pcCU->getHeight(uiPartOffset+ui); |
---|
679 | m_puhTrIdx [ui] = pcCU->getTransformIdx(uiPartOffset+ui); |
---|
680 | m_puhTransformSkip[0][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_LUMA); |
---|
681 | m_puhTransformSkip[1][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_U); |
---|
682 | m_puhTransformSkip[2][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_V); |
---|
683 | m_skipFlag[ui] = pcCU->getSkipFlag(uiPartOffset+ui); |
---|
684 | m_pePartSize[ui] = pcCU->getPartitionSize(uiPartOffset+ui); |
---|
685 | m_pePredMode[ui] = pcCU->getPredictionMode(uiPartOffset+ui); |
---|
686 | m_CUTransquantBypass[ui] = pcCU->getCUTransquantBypass(uiPartOffset+ui); |
---|
687 | m_pbIPCMFlag[ui]=pcCU->m_pbIPCMFlag[uiPartOffset+ui]; |
---|
688 | m_phQP[ui] = pcCU->m_phQP[uiPartOffset+ui]; |
---|
689 | m_pbMergeFlag[ui]=pcCU->m_pbMergeFlag[uiPartOffset+ui]; |
---|
690 | m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui]; |
---|
691 | m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui]; |
---|
692 | m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui]; |
---|
693 | m_puhInterDir[ui]=pcCU->m_puhInterDir[uiPartOffset+ui]; |
---|
694 | m_puhCbf[0][ui]=pcCU->m_puhCbf[0][uiPartOffset+ui]; |
---|
695 | m_puhCbf[1][ui]=pcCU->m_puhCbf[1][uiPartOffset+ui]; |
---|
696 | m_puhCbf[2][ui]=pcCU->m_puhCbf[2][uiPartOffset+ui]; |
---|
697 | |
---|
698 | } |
---|
699 | } |
---|
700 | UInt uiTmp = uhWidth*uhHeight; |
---|
701 | memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); |
---|
702 | #if ADAPTIVE_QP_SELECTION |
---|
703 | memset( m_pcArlCoeffY , 0, sizeof(Int)*uiTmp ); |
---|
704 | #endif |
---|
705 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
---|
706 | uiTmp >>= 2; |
---|
707 | memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); |
---|
708 | memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); |
---|
709 | #if ADAPTIVE_QP_SELECTION |
---|
710 | memset( m_pcArlCoeffCb, 0, sizeof(Int)*uiTmp ); |
---|
711 | memset( m_pcArlCoeffCr, 0, sizeof(Int)*uiTmp ); |
---|
712 | #endif |
---|
713 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
---|
714 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
---|
715 | m_acCUMvField[0].clearMvField(); |
---|
716 | m_acCUMvField[1].clearMvField(); |
---|
717 | |
---|
718 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU<getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
719 | { |
---|
720 | // Part of this CU contains data from an older slice. Now copy in that data. |
---|
721 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
722 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
723 | TComDataCU * bigCU = getPic()->getCU(getAddr()); |
---|
724 | Int minui = uiPartOffset; |
---|
725 | minui = -minui; |
---|
726 | pcCU->m_acCUMvField[0].copyTo(&m_acCUMvField[0],minui,uiPartOffset,m_uiNumPartition); |
---|
727 | pcCU->m_acCUMvField[1].copyTo(&m_acCUMvField[1],minui,uiPartOffset,m_uiNumPartition); |
---|
728 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*m_uiAbsIdxInLCU/pcCU->getPic()->getNumPartInCU(); |
---|
729 | uiTmp = uhWidth*uhHeight; |
---|
730 | for(Int i=0; i<uiTmp; i++) |
---|
731 | { |
---|
732 | m_pcTrCoeffY[i]=bigCU->m_pcTrCoeffY[uiCoffOffset+i]; |
---|
733 | #if ADAPTIVE_QP_SELECTION |
---|
734 | m_pcArlCoeffY[i]=bigCU->m_pcArlCoeffY[uiCoffOffset+i]; |
---|
735 | #endif |
---|
736 | m_pcIPCMSampleY[i]=bigCU->m_pcIPCMSampleY[uiCoffOffset+i]; |
---|
737 | } |
---|
738 | uiTmp>>=2; |
---|
739 | uiCoffOffset>>=2; |
---|
740 | for(Int i=0; i<uiTmp; i++) |
---|
741 | { |
---|
742 | m_pcTrCoeffCr[i]=bigCU->m_pcTrCoeffCr[uiCoffOffset+i]; |
---|
743 | m_pcTrCoeffCb[i]=bigCU->m_pcTrCoeffCb[uiCoffOffset+i]; |
---|
744 | #if ADAPTIVE_QP_SELECTION |
---|
745 | m_pcArlCoeffCr[i]=bigCU->m_pcArlCoeffCr[uiCoffOffset+i]; |
---|
746 | m_pcArlCoeffCb[i]=bigCU->m_pcArlCoeffCb[uiCoffOffset+i]; |
---|
747 | #endif |
---|
748 | m_pcIPCMSampleCb[i]=bigCU->m_pcIPCMSampleCb[uiCoffOffset+i]; |
---|
749 | m_pcIPCMSampleCr[i]=bigCU->m_pcIPCMSampleCr[uiCoffOffset+i]; |
---|
750 | } |
---|
751 | } |
---|
752 | |
---|
753 | m_pcCULeft = pcCU->getCULeft(); |
---|
754 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
755 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
756 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
757 | |
---|
758 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
759 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
760 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
---|
761 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
---|
762 | } |
---|
763 | |
---|
764 | Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
765 | { |
---|
766 | UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); |
---|
767 | UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
768 | |
---|
769 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
770 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
771 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); |
---|
772 | memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); |
---|
773 | memset( m_puhHeight + uiAbsPartIdx, uhHeight, uiSizeInUchar ); |
---|
774 | } |
---|
775 | |
---|
776 | // -------------------------------------------------------------------------------------------------------------------- |
---|
777 | // Copy |
---|
778 | // -------------------------------------------------------------------------------------------------------------------- |
---|
779 | |
---|
780 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
781 | { |
---|
782 | UInt uiPart = uiAbsPartIdx; |
---|
783 | |
---|
784 | m_pcPic = pcCU->getPic(); |
---|
785 | m_pcSlice = pcCU->getSlice(); |
---|
786 | m_uiCUAddr = pcCU->getAddr(); |
---|
787 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
788 | |
---|
789 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
790 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
791 | |
---|
792 | UInt uiWidth = g_uiMaxCUWidth >> uiDepth; |
---|
793 | UInt uiHeight = g_uiMaxCUHeight >> uiDepth; |
---|
794 | |
---|
795 | m_skipFlag=pcCU->getSkipFlag() + uiPart; |
---|
796 | |
---|
797 | m_phQP=pcCU->getQP() + uiPart; |
---|
798 | m_pePartSize = pcCU->getPartitionSize() + uiPart; |
---|
799 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
---|
800 | m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; |
---|
801 | |
---|
802 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
---|
803 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
---|
804 | |
---|
805 | m_puhLumaIntraDir = pcCU->getLumaIntraDir() + uiPart; |
---|
806 | m_puhChromaIntraDir = pcCU->getChromaIntraDir() + uiPart; |
---|
807 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
---|
808 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
---|
809 | m_puhTransformSkip[0] = pcCU->getTransformSkip(TEXT_LUMA) + uiPart; |
---|
810 | m_puhTransformSkip[1] = pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPart; |
---|
811 | m_puhTransformSkip[2] = pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPart; |
---|
812 | |
---|
813 | m_puhCbf[0]= pcCU->getCbf(TEXT_LUMA) + uiPart; |
---|
814 | m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U) + uiPart; |
---|
815 | m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; |
---|
816 | |
---|
817 | m_puhDepth=pcCU->getDepth() + uiPart; |
---|
818 | m_puhWidth=pcCU->getWidth() + uiPart; |
---|
819 | m_puhHeight=pcCU->getHeight() + uiPart; |
---|
820 | |
---|
821 | m_apiMVPIdx[0]=pcCU->getMVPIdx(REF_PIC_LIST_0) + uiPart; |
---|
822 | m_apiMVPIdx[1]=pcCU->getMVPIdx(REF_PIC_LIST_1) + uiPart; |
---|
823 | m_apiMVPNum[0]=pcCU->getMVPNum(REF_PIC_LIST_0) + uiPart; |
---|
824 | m_apiMVPNum[1]=pcCU->getMVPNum(REF_PIC_LIST_1) + uiPart; |
---|
825 | |
---|
826 | m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; |
---|
827 | |
---|
828 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
829 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
830 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
831 | m_pcCULeft = pcCU->getCULeft(); |
---|
832 | |
---|
833 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
834 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
835 | |
---|
836 | UInt uiTmp = uiWidth*uiHeight; |
---|
837 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
838 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
839 | |
---|
840 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartInCU(); |
---|
841 | |
---|
842 | m_pcTrCoeffY = pcCU->getCoeffY() + uiCoffOffset; |
---|
843 | #if ADAPTIVE_QP_SELECTION |
---|
844 | m_pcArlCoeffY= pcCU->getArlCoeffY() + uiCoffOffset; |
---|
845 | #endif |
---|
846 | m_pcIPCMSampleY = pcCU->getPCMSampleY() + uiCoffOffset; |
---|
847 | |
---|
848 | uiTmp >>= 2; |
---|
849 | uiCoffOffset >>=2; |
---|
850 | m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset; |
---|
851 | m_pcTrCoeffCr=pcCU->getCoeffCr() + uiCoffOffset; |
---|
852 | #if ADAPTIVE_QP_SELECTION |
---|
853 | m_pcArlCoeffCb=pcCU->getArlCoeffCb() + uiCoffOffset; |
---|
854 | m_pcArlCoeffCr=pcCU->getArlCoeffCr() + uiCoffOffset; |
---|
855 | #endif |
---|
856 | m_pcIPCMSampleCb = pcCU->getPCMSampleCb() + uiCoffOffset; |
---|
857 | m_pcIPCMSampleCr = pcCU->getPCMSampleCr() + uiCoffOffset; |
---|
858 | |
---|
859 | m_acCUMvField[0].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_0), uiPart ); |
---|
860 | m_acCUMvField[1].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_1), uiPart ); |
---|
861 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
---|
862 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
---|
863 | } |
---|
864 | |
---|
865 | // Copy inter prediction info from the biggest CU |
---|
866 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList ) |
---|
867 | { |
---|
868 | m_pcPic = pcCU->getPic(); |
---|
869 | m_pcSlice = pcCU->getSlice(); |
---|
870 | m_uiCUAddr = pcCU->getAddr(); |
---|
871 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
872 | |
---|
873 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
874 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() ); |
---|
875 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInWidth() ); |
---|
876 | |
---|
877 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
878 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
879 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
880 | m_pcCULeft = pcCU->getCULeft(); |
---|
881 | |
---|
882 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
883 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
884 | |
---|
885 | m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; |
---|
886 | |
---|
887 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
---|
888 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
---|
889 | m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; |
---|
890 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
---|
891 | |
---|
892 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
893 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
894 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
895 | |
---|
896 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
897 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
898 | |
---|
899 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
---|
900 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
---|
901 | |
---|
902 | m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); |
---|
903 | |
---|
904 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
---|
905 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
---|
906 | } |
---|
907 | |
---|
908 | // Copy small CU to bigger CU. |
---|
909 | // One of quarter parts overwritten by predicted sub part. |
---|
910 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
911 | { |
---|
912 | assert( uiPartUnitIdx<4 ); |
---|
913 | |
---|
914 | m_dTotalCost += pcCU->getTotalCost(); |
---|
915 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
---|
916 | m_uiTotalBits += pcCU->getTotalBits(); |
---|
917 | |
---|
918 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
---|
919 | |
---|
920 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
---|
921 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
922 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
923 | |
---|
924 | Int sizeInChar = sizeof( Char ) * uiNumPartition; |
---|
925 | memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); |
---|
926 | memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); |
---|
927 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); |
---|
928 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); |
---|
929 | memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); |
---|
930 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
---|
931 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
---|
932 | memcpy( m_puhLumaIntraDir + uiOffset, pcCU->getLumaIntraDir(), iSizeInUchar ); |
---|
933 | memcpy( m_puhChromaIntraDir + uiOffset, pcCU->getChromaIntraDir(), iSizeInUchar ); |
---|
934 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
---|
935 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
---|
936 | memcpy( m_puhTransformSkip[0] + uiOffset, pcCU->getTransformSkip(TEXT_LUMA), iSizeInUchar ); |
---|
937 | memcpy( m_puhTransformSkip[1] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_U), iSizeInUchar ); |
---|
938 | memcpy( m_puhTransformSkip[2] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_V), iSizeInUchar ); |
---|
939 | |
---|
940 | memcpy( m_puhCbf[0] + uiOffset, pcCU->getCbf(TEXT_LUMA) , iSizeInUchar ); |
---|
941 | memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar ); |
---|
942 | memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); |
---|
943 | |
---|
944 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
---|
945 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
---|
946 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
---|
947 | |
---|
948 | memcpy( m_apiMVPIdx[0] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_0), iSizeInUchar ); |
---|
949 | memcpy( m_apiMVPIdx[1] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_1), iSizeInUchar ); |
---|
950 | memcpy( m_apiMVPNum[0] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_0), iSizeInUchar ); |
---|
951 | memcpy( m_apiMVPNum[1] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_1), iSizeInUchar ); |
---|
952 | |
---|
953 | memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); |
---|
954 | |
---|
955 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
956 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
957 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
958 | m_pcCULeft = pcCU->getCULeft(); |
---|
959 | |
---|
960 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
961 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
962 | |
---|
963 | m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
964 | m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
965 | |
---|
966 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); |
---|
967 | UInt uiTmp2 = uiPartUnitIdx*uiTmp; |
---|
968 | memcpy( m_pcTrCoeffY + uiTmp2, pcCU->getCoeffY(), sizeof(TCoeff)*uiTmp ); |
---|
969 | #if ADAPTIVE_QP_SELECTION |
---|
970 | memcpy( m_pcArlCoeffY + uiTmp2, pcCU->getArlCoeffY(), sizeof(Int)*uiTmp ); |
---|
971 | #endif |
---|
972 | memcpy( m_pcIPCMSampleY + uiTmp2 , pcCU->getPCMSampleY(), sizeof(Pel) * uiTmp ); |
---|
973 | |
---|
974 | uiTmp >>= 2; uiTmp2>>= 2; |
---|
975 | memcpy( m_pcTrCoeffCb + uiTmp2, pcCU->getCoeffCb(), sizeof(TCoeff)*uiTmp ); |
---|
976 | memcpy( m_pcTrCoeffCr + uiTmp2, pcCU->getCoeffCr(), sizeof(TCoeff)*uiTmp ); |
---|
977 | #if ADAPTIVE_QP_SELECTION |
---|
978 | memcpy( m_pcArlCoeffCb + uiTmp2, pcCU->getArlCoeffCb(), sizeof(Int)*uiTmp ); |
---|
979 | memcpy( m_pcArlCoeffCr + uiTmp2, pcCU->getArlCoeffCr(), sizeof(Int)*uiTmp ); |
---|
980 | #endif |
---|
981 | memcpy( m_pcIPCMSampleCb + uiTmp2 , pcCU->getPCMSampleCb(), sizeof(Pel) * uiTmp ); |
---|
982 | memcpy( m_pcIPCMSampleCr + uiTmp2 , pcCU->getPCMSampleCr(), sizeof(Pel) * uiTmp ); |
---|
983 | m_uiTotalBins += pcCU->getTotalBins(); |
---|
984 | memcpy( m_sliceStartCU + uiOffset, pcCU->m_sliceStartCU, sizeof( UInt ) * uiNumPartition ); |
---|
985 | memcpy( m_sliceSegmentStartCU + uiOffset, pcCU->m_sliceSegmentStartCU, sizeof( UInt ) * uiNumPartition ); |
---|
986 | } |
---|
987 | |
---|
988 | // Copy current predicted part to a CU in picture. |
---|
989 | // It is used to predict for next part |
---|
990 | Void TComDataCU::copyToPic( UChar uhDepth ) |
---|
991 | { |
---|
992 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
993 | |
---|
994 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
995 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
996 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
997 | |
---|
998 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
999 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
1000 | |
---|
1001 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
1002 | |
---|
1003 | memcpy( rpcCU->getSkipFlag() + m_uiAbsIdxInLCU, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); |
---|
1004 | |
---|
1005 | memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, sizeInChar ); |
---|
1006 | |
---|
1007 | memcpy( rpcCU->getPartitionSize() + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); |
---|
1008 | memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); |
---|
1009 | memcpy( rpcCU->getCUTransquantBypass()+ m_uiAbsIdxInLCU, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); |
---|
1010 | memcpy( rpcCU->getMergeFlag() + m_uiAbsIdxInLCU, m_pbMergeFlag, iSizeInBool ); |
---|
1011 | memcpy( rpcCU->getMergeIndex() + m_uiAbsIdxInLCU, m_puhMergeIndex, iSizeInUchar ); |
---|
1012 | memcpy( rpcCU->getLumaIntraDir() + m_uiAbsIdxInLCU, m_puhLumaIntraDir, iSizeInUchar ); |
---|
1013 | memcpy( rpcCU->getChromaIntraDir() + m_uiAbsIdxInLCU, m_puhChromaIntraDir, iSizeInUchar ); |
---|
1014 | memcpy( rpcCU->getInterDir() + m_uiAbsIdxInLCU, m_puhInterDir, iSizeInUchar ); |
---|
1015 | memcpy( rpcCU->getTransformIdx() + m_uiAbsIdxInLCU, m_puhTrIdx, iSizeInUchar ); |
---|
1016 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhTransformSkip[0], iSizeInUchar ); |
---|
1017 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhTransformSkip[1], iSizeInUchar ); |
---|
1018 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhTransformSkip[2], iSizeInUchar ); |
---|
1019 | |
---|
1020 | memcpy( rpcCU->getCbf(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhCbf[0], iSizeInUchar ); |
---|
1021 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhCbf[1], iSizeInUchar ); |
---|
1022 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); |
---|
1023 | |
---|
1024 | memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); |
---|
1025 | memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); |
---|
1026 | memcpy( rpcCU->getHeight() + m_uiAbsIdxInLCU, m_puhHeight, iSizeInUchar ); |
---|
1027 | |
---|
1028 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPIdx[0], iSizeInUchar ); |
---|
1029 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPIdx[1], iSizeInUchar ); |
---|
1030 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPNum[0], iSizeInUchar ); |
---|
1031 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPNum[1], iSizeInUchar ); |
---|
1032 | |
---|
1033 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU ); |
---|
1034 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU ); |
---|
1035 | |
---|
1036 | memcpy( rpcCU->getIPCMFlag() + m_uiAbsIdxInLCU, m_pbIPCMFlag, iSizeInBool ); |
---|
1037 | |
---|
1038 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); |
---|
1039 | UInt uiTmp2 = m_uiAbsIdxInLCU*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
1040 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
1041 | #if ADAPTIVE_QP_SELECTION |
---|
1042 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
---|
1043 | #endif |
---|
1044 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof(Pel)*uiTmp ); |
---|
1045 | |
---|
1046 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
1047 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
1048 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
1049 | #if ADAPTIVE_QP_SELECTION |
---|
1050 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
---|
1051 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
---|
1052 | #endif |
---|
1053 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
---|
1054 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
---|
1055 | rpcCU->getTotalBins() = m_uiTotalBins; |
---|
1056 | memcpy( rpcCU->m_sliceStartCU + m_uiAbsIdxInLCU, m_sliceStartCU, sizeof( UInt ) * m_uiNumPartition ); |
---|
1057 | memcpy( rpcCU->m_sliceSegmentStartCU + m_uiAbsIdxInLCU, m_sliceSegmentStartCU, sizeof( UInt ) * m_uiNumPartition ); |
---|
1058 | } |
---|
1059 | |
---|
1060 | Void TComDataCU::copyToPic( UChar uhDepth, UInt uiPartIdx, UInt uiPartDepth ) |
---|
1061 | { |
---|
1062 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
1063 | UInt uiQNumPart = m_uiNumPartition>>(uiPartDepth<<1); |
---|
1064 | |
---|
1065 | UInt uiPartStart = uiPartIdx*uiQNumPart; |
---|
1066 | UInt uiPartOffset = m_uiAbsIdxInLCU + uiPartStart; |
---|
1067 | |
---|
1068 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
1069 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
1070 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
1071 | |
---|
1072 | Int iSizeInUchar = sizeof( UChar ) * uiQNumPart; |
---|
1073 | Int iSizeInBool = sizeof( Bool ) * uiQNumPart; |
---|
1074 | |
---|
1075 | Int sizeInChar = sizeof( Char ) * uiQNumPart; |
---|
1076 | memcpy( rpcCU->getSkipFlag() + uiPartOffset, m_skipFlag, sizeof( *m_skipFlag ) * uiQNumPart ); |
---|
1077 | |
---|
1078 | memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, sizeInChar ); |
---|
1079 | memcpy( rpcCU->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( *m_pePartSize ) * uiQNumPart ); |
---|
1080 | memcpy( rpcCU->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( *m_pePredMode ) * uiQNumPart ); |
---|
1081 | memcpy( rpcCU->getCUTransquantBypass()+ uiPartOffset, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * uiQNumPart ); |
---|
1082 | memcpy( rpcCU->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); |
---|
1083 | memcpy( rpcCU->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); |
---|
1084 | memcpy( rpcCU->getLumaIntraDir() + uiPartOffset, m_puhLumaIntraDir, iSizeInUchar ); |
---|
1085 | memcpy( rpcCU->getChromaIntraDir() + uiPartOffset, m_puhChromaIntraDir, iSizeInUchar ); |
---|
1086 | memcpy( rpcCU->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); |
---|
1087 | memcpy( rpcCU->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); |
---|
1088 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + uiPartOffset, m_puhTransformSkip[0], iSizeInUchar ); |
---|
1089 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhTransformSkip[1], iSizeInUchar ); |
---|
1090 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhTransformSkip[2], iSizeInUchar ); |
---|
1091 | memcpy( rpcCU->getCbf(TEXT_LUMA) + uiPartOffset, m_puhCbf[0], iSizeInUchar ); |
---|
1092 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar ); |
---|
1093 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); |
---|
1094 | |
---|
1095 | memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); |
---|
1096 | memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); |
---|
1097 | memcpy( rpcCU->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); |
---|
1098 | |
---|
1099 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPIdx[0], iSizeInUchar ); |
---|
1100 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPIdx[1], iSizeInUchar ); |
---|
1101 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPNum[0], iSizeInUchar ); |
---|
1102 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPNum[1], iSizeInUchar ); |
---|
1103 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
1104 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
1105 | |
---|
1106 | memcpy( rpcCU->getIPCMFlag() + uiPartOffset, m_pbIPCMFlag, iSizeInBool ); |
---|
1107 | |
---|
1108 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); |
---|
1109 | UInt uiTmp2 = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
1110 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
1111 | #if ADAPTIVE_QP_SELECTION |
---|
1112 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
---|
1113 | #endif |
---|
1114 | |
---|
1115 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof( Pel ) * uiTmp ); |
---|
1116 | |
---|
1117 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
1118 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
1119 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
1120 | #if ADAPTIVE_QP_SELECTION |
---|
1121 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
---|
1122 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
---|
1123 | #endif |
---|
1124 | |
---|
1125 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
---|
1126 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
---|
1127 | rpcCU->getTotalBins() = m_uiTotalBins; |
---|
1128 | memcpy( rpcCU->m_sliceStartCU + uiPartOffset, m_sliceStartCU, sizeof( UInt ) * uiQNumPart ); |
---|
1129 | memcpy( rpcCU->m_sliceSegmentStartCU + uiPartOffset, m_sliceSegmentStartCU, sizeof( UInt ) * uiQNumPart ); |
---|
1130 | } |
---|
1131 | |
---|
1132 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1133 | // Other public functions |
---|
1134 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1135 | |
---|
1136 | TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, |
---|
1137 | UInt uiCurrPartUnitIdx, |
---|
1138 | Bool bEnforceSliceRestriction, |
---|
1139 | Bool bEnforceTileRestriction ) |
---|
1140 | { |
---|
1141 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1142 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1143 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1144 | |
---|
1145 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1146 | { |
---|
1147 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1148 | if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1149 | { |
---|
1150 | return m_pcPic->getCU( getAddr() ); |
---|
1151 | } |
---|
1152 | else |
---|
1153 | { |
---|
1154 | uiLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1155 | return this; |
---|
1156 | } |
---|
1157 | } |
---|
1158 | |
---|
1159 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth - 1 ]; |
---|
1160 | |
---|
1161 | |
---|
1162 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
---|
1163 | || |
---|
1164 | (bEnforceTileRestriction && ( m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) ) ) |
---|
1165 | ) |
---|
1166 | { |
---|
1167 | return NULL; |
---|
1168 | } |
---|
1169 | return m_pcCULeft; |
---|
1170 | } |
---|
1171 | |
---|
1172 | TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, |
---|
1173 | UInt uiCurrPartUnitIdx, |
---|
1174 | Bool bEnforceSliceRestriction, |
---|
1175 | Bool planarAtLCUBoundary , |
---|
1176 | Bool bEnforceTileRestriction ) |
---|
1177 | { |
---|
1178 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1179 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1180 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1181 | |
---|
1182 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1183 | { |
---|
1184 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth ]; |
---|
1185 | if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1186 | { |
---|
1187 | return m_pcPic->getCU( getAddr() ); |
---|
1188 | } |
---|
1189 | else |
---|
1190 | { |
---|
1191 | uiAPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1192 | return this; |
---|
1193 | } |
---|
1194 | } |
---|
1195 | |
---|
1196 | if(planarAtLCUBoundary) |
---|
1197 | { |
---|
1198 | return NULL; |
---|
1199 | } |
---|
1200 | |
---|
1201 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1202 | |
---|
1203 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
---|
1204 | || |
---|
1205 | (bEnforceTileRestriction &&(m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())))) |
---|
1206 | ) |
---|
1207 | { |
---|
1208 | return NULL; |
---|
1209 | } |
---|
1210 | return m_pcCUAbove; |
---|
1211 | } |
---|
1212 | |
---|
1213 | TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
1214 | { |
---|
1215 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1216 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1217 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1218 | |
---|
1219 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1220 | { |
---|
1221 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1222 | { |
---|
1223 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth - 1 ]; |
---|
1224 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1225 | { |
---|
1226 | return m_pcPic->getCU( getAddr() ); |
---|
1227 | } |
---|
1228 | else |
---|
1229 | { |
---|
1230 | uiALPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1231 | return this; |
---|
1232 | } |
---|
1233 | } |
---|
1234 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartInCU() - uiNumPartInCUWidth - 1 ]; |
---|
1235 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1236 | m_pcCUAbove->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1237 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1238 | )) |
---|
1239 | ) |
---|
1240 | { |
---|
1241 | return NULL; |
---|
1242 | } |
---|
1243 | return m_pcCUAbove; |
---|
1244 | } |
---|
1245 | |
---|
1246 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1247 | { |
---|
1248 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1249 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1250 | m_pcCULeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1251 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1252 | )) |
---|
1253 | ) |
---|
1254 | { |
---|
1255 | return NULL; |
---|
1256 | } |
---|
1257 | return m_pcCULeft; |
---|
1258 | } |
---|
1259 | |
---|
1260 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - 1 ]; |
---|
1261 | if ( (bEnforceSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || |
---|
1262 | m_pcCUAboveLeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1263 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveLeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1264 | )) |
---|
1265 | ) |
---|
1266 | { |
---|
1267 | return NULL; |
---|
1268 | } |
---|
1269 | return m_pcCUAboveLeft; |
---|
1270 | } |
---|
1271 | |
---|
1272 | TComDataCU* TComDataCU::getPUAboveRight( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
1273 | { |
---|
1274 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1275 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1; |
---|
1276 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1277 | |
---|
1278 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
1279 | { |
---|
1280 | uiARPartUnitIdx = MAX_UINT; |
---|
1281 | return NULL; |
---|
1282 | } |
---|
1283 | |
---|
1284 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - 1, uiNumPartInCUWidth ) ) |
---|
1285 | { |
---|
1286 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1287 | { |
---|
1288 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] ) |
---|
1289 | { |
---|
1290 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ]; |
---|
1291 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1292 | { |
---|
1293 | return m_pcPic->getCU( getAddr() ); |
---|
1294 | } |
---|
1295 | else |
---|
1296 | { |
---|
1297 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1298 | return this; |
---|
1299 | } |
---|
1300 | } |
---|
1301 | uiARPartUnitIdx = MAX_UINT; |
---|
1302 | return NULL; |
---|
1303 | } |
---|
1304 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; |
---|
1305 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1306 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1307 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1308 | )) |
---|
1309 | ) |
---|
1310 | { |
---|
1311 | return NULL; |
---|
1312 | } |
---|
1313 | return m_pcCUAbove; |
---|
1314 | } |
---|
1315 | |
---|
1316 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1317 | { |
---|
1318 | uiARPartUnitIdx = MAX_UINT; |
---|
1319 | return NULL; |
---|
1320 | } |
---|
1321 | |
---|
1322 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1323 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
1324 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
1325 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1326 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1327 | )) |
---|
1328 | ) |
---|
1329 | { |
---|
1330 | return NULL; |
---|
1331 | } |
---|
1332 | return m_pcCUAboveRight; |
---|
1333 | } |
---|
1334 | |
---|
1335 | TComDataCU* TComDataCU::getPUBelowLeft( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
1336 | { |
---|
1337 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1338 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*m_pcPic->getNumPartInWidth(); |
---|
1339 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1340 | |
---|
1341 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
1342 | { |
---|
1343 | uiBLPartUnitIdx = MAX_UINT; |
---|
1344 | return NULL; |
---|
1345 | } |
---|
1346 | |
---|
1347 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - 1, uiNumPartInCUWidth ) ) |
---|
1348 | { |
---|
1349 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
---|
1350 | { |
---|
1351 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) |
---|
1352 | { |
---|
1353 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; |
---|
1354 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
---|
1355 | { |
---|
1356 | return m_pcPic->getCU( getAddr() ); |
---|
1357 | } |
---|
1358 | else |
---|
1359 | { |
---|
1360 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1361 | return this; |
---|
1362 | } |
---|
1363 | } |
---|
1364 | uiBLPartUnitIdx = MAX_UINT; |
---|
1365 | return NULL; |
---|
1366 | } |
---|
1367 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; |
---|
1368 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1369 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1370 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1371 | )) |
---|
1372 | ) |
---|
1373 | { |
---|
1374 | return NULL; |
---|
1375 | } |
---|
1376 | return m_pcCULeft; |
---|
1377 | } |
---|
1378 | |
---|
1379 | uiBLPartUnitIdx = MAX_UINT; |
---|
1380 | return NULL; |
---|
1381 | } |
---|
1382 | |
---|
1383 | TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
---|
1384 | { |
---|
1385 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1386 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth(); |
---|
1387 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1388 | |
---|
1389 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) |
---|
1390 | { |
---|
1391 | uiBLPartUnitIdx = MAX_UINT; |
---|
1392 | return NULL; |
---|
1393 | } |
---|
1394 | |
---|
1395 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
---|
1396 | { |
---|
1397 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
---|
1398 | { |
---|
1399 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ] ) |
---|
1400 | { |
---|
1401 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ]; |
---|
1402 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
---|
1403 | { |
---|
1404 | return m_pcPic->getCU( getAddr() ); |
---|
1405 | } |
---|
1406 | else |
---|
1407 | { |
---|
1408 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1409 | return this; |
---|
1410 | } |
---|
1411 | } |
---|
1412 | uiBLPartUnitIdx = MAX_UINT; |
---|
1413 | return NULL; |
---|
1414 | } |
---|
1415 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * uiNumPartInCUWidth - 1 ]; |
---|
1416 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1417 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1418 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1419 | )) |
---|
1420 | ) |
---|
1421 | { |
---|
1422 | return NULL; |
---|
1423 | } |
---|
1424 | return m_pcCULeft; |
---|
1425 | } |
---|
1426 | |
---|
1427 | uiBLPartUnitIdx = MAX_UINT; |
---|
1428 | return NULL; |
---|
1429 | } |
---|
1430 | |
---|
1431 | TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
---|
1432 | { |
---|
1433 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1434 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
---|
1435 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1436 | |
---|
1437 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
1438 | { |
---|
1439 | uiARPartUnitIdx = MAX_UINT; |
---|
1440 | return NULL; |
---|
1441 | } |
---|
1442 | |
---|
1443 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
---|
1444 | { |
---|
1445 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1446 | { |
---|
1447 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ] ) |
---|
1448 | { |
---|
1449 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
1450 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1451 | { |
---|
1452 | return m_pcPic->getCU( getAddr() ); |
---|
1453 | } |
---|
1454 | else |
---|
1455 | { |
---|
1456 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1457 | return this; |
---|
1458 | } |
---|
1459 | } |
---|
1460 | uiARPartUnitIdx = MAX_UINT; |
---|
1461 | return NULL; |
---|
1462 | } |
---|
1463 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
1464 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1465 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1466 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1467 | )) |
---|
1468 | ) |
---|
1469 | { |
---|
1470 | return NULL; |
---|
1471 | } |
---|
1472 | return m_pcCUAbove; |
---|
1473 | } |
---|
1474 | |
---|
1475 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1476 | { |
---|
1477 | uiARPartUnitIdx = MAX_UINT; |
---|
1478 | return NULL; |
---|
1479 | } |
---|
1480 | |
---|
1481 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset-1 ]; |
---|
1482 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
1483 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
1484 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1485 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1486 | )) |
---|
1487 | ) |
---|
1488 | { |
---|
1489 | return NULL; |
---|
1490 | } |
---|
1491 | return m_pcCUAboveRight; |
---|
1492 | } |
---|
1493 | |
---|
1494 | /** Get left QpMinCu |
---|
1495 | *\param uiLPartUnitIdx |
---|
1496 | *\param uiCurrAbsIdxInLCU |
---|
1497 | *\returns TComDataCU* point of TComDataCU of left QpMinCu |
---|
1498 | */ |
---|
1499 | TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInLCU) |
---|
1500 | { |
---|
1501 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1502 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth -getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
---|
1503 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
1504 | |
---|
1505 | // check for left LCU boundary |
---|
1506 | if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCUWidth) ) |
---|
1507 | { |
---|
1508 | return NULL; |
---|
1509 | } |
---|
1510 | |
---|
1511 | // get index of left-CU relative to top-left corner of current quantization group |
---|
1512 | uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; |
---|
1513 | |
---|
1514 | // return pointer to current LCU |
---|
1515 | return m_pcPic->getCU( getAddr() ); |
---|
1516 | } |
---|
1517 | |
---|
1518 | /** Get Above QpMinCu |
---|
1519 | *\param aPartUnitIdx |
---|
1520 | *\param currAbsIdxInLCU |
---|
1521 | *\returns TComDataCU* point of TComDataCU of above QpMinCu |
---|
1522 | */ |
---|
1523 | TComDataCU* TComDataCU::getQpMinCuAbove( UInt& aPartUnitIdx, UInt currAbsIdxInLCU ) |
---|
1524 | { |
---|
1525 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1526 | UInt absZorderQpMinCUIdx = (currAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
---|
1527 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
1528 | |
---|
1529 | // check for top LCU boundary |
---|
1530 | if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCUWidth) ) |
---|
1531 | { |
---|
1532 | return NULL; |
---|
1533 | } |
---|
1534 | |
---|
1535 | // get index of top-CU relative to top-left corner of current quantization group |
---|
1536 | aPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCUWidth]; |
---|
1537 | |
---|
1538 | // return pointer to current LCU |
---|
1539 | return m_pcPic->getCU( getAddr() ); |
---|
1540 | } |
---|
1541 | |
---|
1542 | /** Get reference QP from left QpMinCu or latest coded QP |
---|
1543 | *\param uiCurrAbsIdxInLCU |
---|
1544 | *\returns Char reference QP value |
---|
1545 | */ |
---|
1546 | Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInLCU ) |
---|
1547 | { |
---|
1548 | UInt lPartIdx = 0, aPartIdx = 0; |
---|
1549 | TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
---|
1550 | TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
---|
1551 | return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + 1) >> 1); |
---|
1552 | } |
---|
1553 | |
---|
1554 | Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) |
---|
1555 | { |
---|
1556 | Int iLastValidPartIdx = iAbsPartIdx-1; |
---|
1557 | while ( iLastValidPartIdx >= 0 |
---|
1558 | && getPredictionMode( iLastValidPartIdx ) == MODE_NONE ) |
---|
1559 | { |
---|
1560 | UInt uiDepth = getDepth( iLastValidPartIdx ); |
---|
1561 | iLastValidPartIdx -= m_uiNumPartition>>(uiDepth<<1); |
---|
1562 | } |
---|
1563 | return iLastValidPartIdx; |
---|
1564 | } |
---|
1565 | |
---|
1566 | Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) |
---|
1567 | { |
---|
1568 | UInt uiQUPartIdxMask = ~((1<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); |
---|
1569 | Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); |
---|
1570 | if ( uiAbsPartIdx < m_uiNumPartition |
---|
1571 | && (getSCUAddr()+iLastValidPartIdx < getSliceStartCU(m_uiAbsIdxInLCU+uiAbsPartIdx))) |
---|
1572 | { |
---|
1573 | return getSlice()->getSliceQp(); |
---|
1574 | } |
---|
1575 | else |
---|
1576 | if ( iLastValidPartIdx >= 0 ) |
---|
1577 | { |
---|
1578 | return getQP( iLastValidPartIdx ); |
---|
1579 | } |
---|
1580 | else |
---|
1581 | { |
---|
1582 | if ( getZorderIdxInCU() > 0 ) |
---|
1583 | { |
---|
1584 | return getPic()->getCU( getAddr() )->getLastCodedQP( getZorderIdxInCU() ); |
---|
1585 | } |
---|
1586 | else if ( getPic()->getPicSym()->getInverseCUOrderMap(getAddr()) > 0 |
---|
1587 | && getPic()->getPicSym()->getTileIdxMap(getAddr()) == getPic()->getPicSym()->getTileIdxMap(getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1)) |
---|
1588 | && !( getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() && getAddr() % getPic()->getFrameWidthInCU() == 0 ) ) |
---|
1589 | { |
---|
1590 | return getPic()->getCU( getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1) )->getLastCodedQP( getPic()->getNumPartInCU() ); |
---|
1591 | } |
---|
1592 | else |
---|
1593 | { |
---|
1594 | return getSlice()->getSliceQp(); |
---|
1595 | } |
---|
1596 | } |
---|
1597 | } |
---|
1598 | /** Check whether the CU is coded in lossless coding mode |
---|
1599 | * \param uiAbsPartIdx |
---|
1600 | * \returns true if the CU is coded in lossless coding mode; false if otherwise |
---|
1601 | */ |
---|
1602 | Bool TComDataCU::isLosslessCoded(UInt absPartIdx) |
---|
1603 | { |
---|
1604 | return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx)); |
---|
1605 | } |
---|
1606 | |
---|
1607 | /** Get allowed chroma intra modes |
---|
1608 | *\param uiAbsPartIdx |
---|
1609 | *\param uiModeList pointer to chroma intra modes array |
---|
1610 | *\returns |
---|
1611 | *- fill uiModeList with chroma intra modes |
---|
1612 | */ |
---|
1613 | Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt* uiModeList ) |
---|
1614 | { |
---|
1615 | uiModeList[0] = PLANAR_IDX; |
---|
1616 | uiModeList[1] = VER_IDX; |
---|
1617 | uiModeList[2] = HOR_IDX; |
---|
1618 | uiModeList[3] = DC_IDX; |
---|
1619 | uiModeList[4] = DM_CHROMA_IDX; |
---|
1620 | |
---|
1621 | UInt uiLumaMode = getLumaIntraDir( uiAbsPartIdx ); |
---|
1622 | |
---|
1623 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
---|
1624 | { |
---|
1625 | if( uiLumaMode == uiModeList[i] ) |
---|
1626 | { |
---|
1627 | uiModeList[i] = 34; // VER+8 mode |
---|
1628 | break; |
---|
1629 | } |
---|
1630 | } |
---|
1631 | } |
---|
1632 | |
---|
1633 | /** Get most probable intra modes |
---|
1634 | *\param uiAbsPartIdx |
---|
1635 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
1636 | *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. |
---|
1637 | *\returns Number of MPM |
---|
1638 | */ |
---|
1639 | Int TComDataCU::getIntraDirLumaPredictor( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode ) |
---|
1640 | { |
---|
1641 | TComDataCU* pcTempCU; |
---|
1642 | UInt uiTempPartIdx; |
---|
1643 | Int iLeftIntraDir, iAboveIntraDir; |
---|
1644 | Int uiPredNum = 0; |
---|
1645 | |
---|
1646 | // Get intra direction of left PU |
---|
1647 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1648 | |
---|
1649 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
1650 | |
---|
1651 | // Get intra direction of above PU |
---|
1652 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true ); |
---|
1653 | |
---|
1654 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
1655 | |
---|
1656 | uiPredNum = 3; |
---|
1657 | if(iLeftIntraDir == iAboveIntraDir) |
---|
1658 | { |
---|
1659 | if( piMode ) |
---|
1660 | { |
---|
1661 | *piMode = 1; |
---|
1662 | } |
---|
1663 | |
---|
1664 | if (iLeftIntraDir > 1) // angular modes |
---|
1665 | { |
---|
1666 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
1667 | uiIntraDirPred[1] = ((iLeftIntraDir + 29) % 32) + 2; |
---|
1668 | uiIntraDirPred[2] = ((iLeftIntraDir - 1 ) % 32) + 2; |
---|
1669 | } |
---|
1670 | else //non-angular |
---|
1671 | { |
---|
1672 | uiIntraDirPred[0] = PLANAR_IDX; |
---|
1673 | uiIntraDirPred[1] = DC_IDX; |
---|
1674 | uiIntraDirPred[2] = VER_IDX; |
---|
1675 | } |
---|
1676 | } |
---|
1677 | else |
---|
1678 | { |
---|
1679 | if( piMode ) |
---|
1680 | { |
---|
1681 | *piMode = 2; |
---|
1682 | } |
---|
1683 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
1684 | uiIntraDirPred[1] = iAboveIntraDir; |
---|
1685 | |
---|
1686 | if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar |
---|
1687 | { |
---|
1688 | uiIntraDirPred[2] = PLANAR_IDX; |
---|
1689 | } |
---|
1690 | else |
---|
1691 | { |
---|
1692 | uiIntraDirPred[2] = (iLeftIntraDir+iAboveIntraDir)<2? VER_IDX : DC_IDX; |
---|
1693 | } |
---|
1694 | } |
---|
1695 | |
---|
1696 | return uiPredNum; |
---|
1697 | } |
---|
1698 | |
---|
1699 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1700 | { |
---|
1701 | TComDataCU* pcTempCU; |
---|
1702 | UInt uiTempPartIdx; |
---|
1703 | UInt uiCtx; |
---|
1704 | // Get left split flag |
---|
1705 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1706 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
1707 | |
---|
1708 | // Get above split flag |
---|
1709 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1710 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
1711 | |
---|
1712 | return uiCtx; |
---|
1713 | } |
---|
1714 | |
---|
1715 | UInt TComDataCU::getCtxQtCbf( TextType eType, UInt uiTrDepth ) |
---|
1716 | { |
---|
1717 | if( eType ) |
---|
1718 | { |
---|
1719 | return uiTrDepth; |
---|
1720 | } |
---|
1721 | else |
---|
1722 | { |
---|
1723 | const UInt uiCtx = ( uiTrDepth == 0 ? 1 : 0 ); |
---|
1724 | return uiCtx; |
---|
1725 | } |
---|
1726 | } |
---|
1727 | |
---|
1728 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) |
---|
1729 | { |
---|
1730 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
---|
1731 | PartSize partSize = getPartitionSize( absPartIdx ); |
---|
1732 | UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
1733 | Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA && partSize == SIZE_NxN ) ? 1 : 0; |
---|
1734 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) ); |
---|
1735 | |
---|
1736 | UInt log2MinTUSizeInCU = 0; |
---|
1737 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
---|
1738 | { |
---|
1739 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
---|
1740 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
1741 | } |
---|
1742 | else |
---|
1743 | { |
---|
1744 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
---|
1745 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
---|
1746 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
1747 | { |
---|
1748 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
---|
1749 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
1750 | } |
---|
1751 | } |
---|
1752 | return log2MinTUSizeInCU; |
---|
1753 | } |
---|
1754 | |
---|
1755 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
---|
1756 | { |
---|
1757 | TComDataCU* pcTempCU; |
---|
1758 | UInt uiTempPartIdx; |
---|
1759 | UInt uiCtx = 0; |
---|
1760 | |
---|
1761 | // Get BCBP of left PU |
---|
1762 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1763 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
1764 | |
---|
1765 | // Get BCBP of above PU |
---|
1766 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1767 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
1768 | |
---|
1769 | return uiCtx; |
---|
1770 | } |
---|
1771 | |
---|
1772 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
---|
1773 | { |
---|
1774 | return getDepth( uiAbsPartIdx ); |
---|
1775 | } |
---|
1776 | |
---|
1777 | Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1778 | { |
---|
1779 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1780 | memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
1781 | memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
1782 | memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
1783 | } |
---|
1784 | |
---|
1785 | Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1786 | { |
---|
1787 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1788 | memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
1789 | } |
---|
1790 | |
---|
1791 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
1792 | * \param uiCbf The value of the coded block flag to be set |
---|
1793 | * \param eTType |
---|
1794 | * \param uiAbsPartIdx |
---|
1795 | * \param uiPartIdx |
---|
1796 | * \param uiDepth |
---|
1797 | * \returns Void |
---|
1798 | */ |
---|
1799 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
1800 | { |
---|
1801 | setSubPart<UChar>( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1802 | } |
---|
1803 | |
---|
1804 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
1805 | { |
---|
1806 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1807 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
1808 | } |
---|
1809 | |
---|
1810 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
---|
1811 | { |
---|
1812 | UInt uiPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1813 | return (((m_uiAbsIdxInLCU + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
1814 | } |
---|
1815 | |
---|
1816 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1817 | { |
---|
1818 | assert( sizeof( *m_pePartSize) == 1 ); |
---|
1819 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
1820 | } |
---|
1821 | |
---|
1822 | Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1823 | { |
---|
1824 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
1825 | } |
---|
1826 | |
---|
1827 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
---|
1828 | { |
---|
1829 | assert( sizeof( *m_skipFlag) == 1 ); |
---|
1830 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); |
---|
1831 | } |
---|
1832 | |
---|
1833 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1834 | { |
---|
1835 | assert( sizeof( *m_pePredMode) == 1 ); |
---|
1836 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
1837 | } |
---|
1838 | |
---|
1839 | Void TComDataCU::setQPSubCUs( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
---|
1840 | { |
---|
1841 | UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); |
---|
1842 | UInt currPartNumQ = currPartNumb >> 2; |
---|
1843 | |
---|
1844 | if(!foundNonZeroCbf) |
---|
1845 | { |
---|
1846 | if(pcCU->getDepth(absPartIdx) > depth) |
---|
1847 | { |
---|
1848 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
---|
1849 | { |
---|
1850 | pcCU->setQPSubCUs( qp, pcCU, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
---|
1851 | } |
---|
1852 | } |
---|
1853 | else |
---|
1854 | { |
---|
1855 | if(pcCU->getCbf( absPartIdx, TEXT_LUMA ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_U ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_V ) ) |
---|
1856 | { |
---|
1857 | foundNonZeroCbf = true; |
---|
1858 | } |
---|
1859 | else |
---|
1860 | { |
---|
1861 | setQPSubParts(qp, absPartIdx, depth); |
---|
1862 | } |
---|
1863 | } |
---|
1864 | } |
---|
1865 | } |
---|
1866 | |
---|
1867 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1868 | { |
---|
1869 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1870 | TComSlice * pcSlice = getPic()->getSlice(getPic()->getCurrSliceIdx()); |
---|
1871 | |
---|
1872 | for(UInt uiSCUIdx = uiAbsPartIdx; uiSCUIdx < uiAbsPartIdx+uiCurrPartNumb; uiSCUIdx++) |
---|
1873 | { |
---|
1874 | if( m_pcPic->getCU( getAddr() )->getSliceSegmentStartCU(uiSCUIdx+getZorderIdxInCU()) == pcSlice->getSliceSegmentCurStartCUAddr() ) |
---|
1875 | { |
---|
1876 | m_phQP[uiSCUIdx] = qp; |
---|
1877 | } |
---|
1878 | } |
---|
1879 | } |
---|
1880 | |
---|
1881 | Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1882 | { |
---|
1883 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1884 | |
---|
1885 | memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
1886 | } |
---|
1887 | |
---|
1888 | template<typename T> |
---|
1889 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
1890 | { |
---|
1891 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
---|
1892 | |
---|
1893 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
---|
1894 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
1895 | { |
---|
1896 | case SIZE_2Nx2N: |
---|
1897 | memset( puhBaseLCU + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
---|
1898 | break; |
---|
1899 | case SIZE_2NxN: |
---|
1900 | memset( puhBaseLCU + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
---|
1901 | break; |
---|
1902 | case SIZE_Nx2N: |
---|
1903 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
1904 | memset( puhBaseLCU + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
---|
1905 | break; |
---|
1906 | case SIZE_NxN: |
---|
1907 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
1908 | break; |
---|
1909 | case SIZE_2NxnU: |
---|
1910 | if ( uiPUIdx == 0 ) |
---|
1911 | { |
---|
1912 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1913 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1914 | } |
---|
1915 | else if ( uiPUIdx == 1 ) |
---|
1916 | { |
---|
1917 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1918 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
---|
1919 | } |
---|
1920 | else |
---|
1921 | { |
---|
1922 | assert(0); |
---|
1923 | } |
---|
1924 | break; |
---|
1925 | case SIZE_2NxnD: |
---|
1926 | if ( uiPUIdx == 0 ) |
---|
1927 | { |
---|
1928 | memset( puhBaseLCU + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
---|
1929 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1930 | } |
---|
1931 | else if ( uiPUIdx == 1 ) |
---|
1932 | { |
---|
1933 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1934 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1935 | } |
---|
1936 | else |
---|
1937 | { |
---|
1938 | assert(0); |
---|
1939 | } |
---|
1940 | break; |
---|
1941 | case SIZE_nLx2N: |
---|
1942 | if ( uiPUIdx == 0 ) |
---|
1943 | { |
---|
1944 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1945 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1946 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1947 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1948 | } |
---|
1949 | else if ( uiPUIdx == 1 ) |
---|
1950 | { |
---|
1951 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1952 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
1953 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1954 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
1955 | } |
---|
1956 | else |
---|
1957 | { |
---|
1958 | assert(0); |
---|
1959 | } |
---|
1960 | break; |
---|
1961 | case SIZE_nRx2N: |
---|
1962 | if ( uiPUIdx == 0 ) |
---|
1963 | { |
---|
1964 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
1965 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1966 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
1967 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1968 | } |
---|
1969 | else if ( uiPUIdx == 1 ) |
---|
1970 | { |
---|
1971 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1972 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1973 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1974 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1975 | } |
---|
1976 | else |
---|
1977 | { |
---|
1978 | assert(0); |
---|
1979 | } |
---|
1980 | break; |
---|
1981 | default: |
---|
1982 | assert( 0 ); |
---|
1983 | } |
---|
1984 | } |
---|
1985 | |
---|
1986 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
1987 | { |
---|
1988 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1989 | } |
---|
1990 | |
---|
1991 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
1992 | { |
---|
1993 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1994 | } |
---|
1995 | |
---|
1996 | Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1997 | { |
---|
1998 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1999 | |
---|
2000 | memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2001 | } |
---|
2002 | |
---|
2003 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2004 | { |
---|
2005 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2006 | } |
---|
2007 | |
---|
2008 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2009 | { |
---|
2010 | setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2011 | } |
---|
2012 | |
---|
2013 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2014 | { |
---|
2015 | setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2016 | } |
---|
2017 | |
---|
2018 | |
---|
2019 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2020 | { |
---|
2021 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2022 | |
---|
2023 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
2024 | } |
---|
2025 | |
---|
2026 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2027 | { |
---|
2028 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2029 | |
---|
2030 | memset( m_puhTransformSkip[0] + uiAbsPartIdx, useTransformSkipY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2031 | memset( m_puhTransformSkip[1] + uiAbsPartIdx, useTransformSkipU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2032 | memset( m_puhTransformSkip[2] + uiAbsPartIdx, useTransformSkipV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2033 | } |
---|
2034 | |
---|
2035 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth) |
---|
2036 | { |
---|
2037 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2038 | |
---|
2039 | memset( m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2040 | } |
---|
2041 | |
---|
2042 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2043 | { |
---|
2044 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2045 | |
---|
2046 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2047 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
2048 | } |
---|
2049 | |
---|
2050 | UChar TComDataCU::getNumPartInter() |
---|
2051 | { |
---|
2052 | UChar iNumPart = 0; |
---|
2053 | |
---|
2054 | switch ( m_pePartSize[0] ) |
---|
2055 | { |
---|
2056 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
2057 | case SIZE_2NxN: iNumPart = 2; break; |
---|
2058 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
2059 | case SIZE_NxN: iNumPart = 4; break; |
---|
2060 | case SIZE_2NxnU: iNumPart = 2; break; |
---|
2061 | case SIZE_2NxnD: iNumPart = 2; break; |
---|
2062 | case SIZE_nLx2N: iNumPart = 2; break; |
---|
2063 | case SIZE_nRx2N: iNumPart = 2; break; |
---|
2064 | default: assert (0); break; |
---|
2065 | } |
---|
2066 | |
---|
2067 | return iNumPart; |
---|
2068 | } |
---|
2069 | |
---|
2070 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
---|
2071 | { |
---|
2072 | switch ( m_pePartSize[0] ) |
---|
2073 | { |
---|
2074 | case SIZE_2NxN: |
---|
2075 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2076 | break; |
---|
2077 | case SIZE_Nx2N: |
---|
2078 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
2079 | break; |
---|
2080 | case SIZE_NxN: |
---|
2081 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2082 | break; |
---|
2083 | case SIZE_2NxnU: |
---|
2084 | riWidth = getWidth(0); |
---|
2085 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
2086 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
---|
2087 | break; |
---|
2088 | case SIZE_2NxnD: |
---|
2089 | riWidth = getWidth(0); |
---|
2090 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
2091 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
---|
2092 | break; |
---|
2093 | case SIZE_nLx2N: |
---|
2094 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
2095 | riHeight = getHeight(0); |
---|
2096 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
---|
2097 | break; |
---|
2098 | case SIZE_nRx2N: |
---|
2099 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
2100 | riHeight = getHeight(0); |
---|
2101 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2102 | break; |
---|
2103 | default: |
---|
2104 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
2105 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
2106 | break; |
---|
2107 | } |
---|
2108 | } |
---|
2109 | |
---|
2110 | |
---|
2111 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
2112 | { |
---|
2113 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
2114 | { |
---|
2115 | TComMv cZeroMv; |
---|
2116 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
2117 | return; |
---|
2118 | } |
---|
2119 | |
---|
2120 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
2121 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
2122 | } |
---|
2123 | |
---|
2124 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2125 | { |
---|
2126 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
2127 | UInt uiPUWidth = 0; |
---|
2128 | |
---|
2129 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2130 | { |
---|
2131 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2132 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2133 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2134 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2135 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2136 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2137 | case SIZE_nLx2N: |
---|
2138 | if ( uiPartIdx == 0 ) |
---|
2139 | { |
---|
2140 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
2141 | } |
---|
2142 | else if ( uiPartIdx == 1 ) |
---|
2143 | { |
---|
2144 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
2145 | } |
---|
2146 | else |
---|
2147 | { |
---|
2148 | assert(0); |
---|
2149 | } |
---|
2150 | break; |
---|
2151 | case SIZE_nRx2N: |
---|
2152 | if ( uiPartIdx == 0 ) |
---|
2153 | { |
---|
2154 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
2155 | } |
---|
2156 | else if ( uiPartIdx == 1 ) |
---|
2157 | { |
---|
2158 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
2159 | } |
---|
2160 | else |
---|
2161 | { |
---|
2162 | assert(0); |
---|
2163 | } |
---|
2164 | break; |
---|
2165 | default: |
---|
2166 | assert (0); |
---|
2167 | break; |
---|
2168 | } |
---|
2169 | |
---|
2170 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2171 | } |
---|
2172 | |
---|
2173 | Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2174 | { |
---|
2175 | UInt uiPUHeight = 0; |
---|
2176 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2177 | { |
---|
2178 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2179 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2180 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2181 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2182 | case SIZE_2NxnU: |
---|
2183 | if ( uiPartIdx == 0 ) |
---|
2184 | { |
---|
2185 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
2186 | } |
---|
2187 | else if ( uiPartIdx == 1 ) |
---|
2188 | { |
---|
2189 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
2190 | } |
---|
2191 | else |
---|
2192 | { |
---|
2193 | assert(0); |
---|
2194 | } |
---|
2195 | break; |
---|
2196 | case SIZE_2NxnD: |
---|
2197 | if ( uiPartIdx == 0 ) |
---|
2198 | { |
---|
2199 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
2200 | } |
---|
2201 | else if ( uiPartIdx == 1 ) |
---|
2202 | { |
---|
2203 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
2204 | } |
---|
2205 | else |
---|
2206 | { |
---|
2207 | assert(0); |
---|
2208 | } |
---|
2209 | break; |
---|
2210 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2211 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2212 | default: |
---|
2213 | assert (0); |
---|
2214 | break; |
---|
2215 | } |
---|
2216 | |
---|
2217 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
2218 | } |
---|
2219 | |
---|
2220 | Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2221 | { |
---|
2222 | ruiPartIdxLT = m_uiAbsIdxInLCU; |
---|
2223 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2224 | |
---|
2225 | switch ( m_pePartSize[0] ) |
---|
2226 | { |
---|
2227 | case SIZE_2Nx2N: break; |
---|
2228 | case SIZE_2NxN: |
---|
2229 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2230 | break; |
---|
2231 | case SIZE_Nx2N: |
---|
2232 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
2233 | break; |
---|
2234 | case SIZE_NxN: |
---|
2235 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2236 | break; |
---|
2237 | case SIZE_2NxnU: |
---|
2238 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2239 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2240 | break; |
---|
2241 | case SIZE_2NxnD: |
---|
2242 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2243 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2244 | break; |
---|
2245 | case SIZE_nLx2N: |
---|
2246 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
---|
2247 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2248 | break; |
---|
2249 | case SIZE_nRx2N: |
---|
2250 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2251 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
---|
2252 | break; |
---|
2253 | default: |
---|
2254 | assert (0); |
---|
2255 | break; |
---|
2256 | } |
---|
2257 | |
---|
2258 | } |
---|
2259 | |
---|
2260 | Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2261 | { |
---|
2262 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
2263 | |
---|
2264 | switch ( m_pePartSize[0] ) |
---|
2265 | { |
---|
2266 | case SIZE_2Nx2N: |
---|
2267 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
2268 | break; |
---|
2269 | case SIZE_2NxN: |
---|
2270 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2271 | break; |
---|
2272 | case SIZE_Nx2N: |
---|
2273 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
2274 | break; |
---|
2275 | case SIZE_NxN: |
---|
2276 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2277 | break; |
---|
2278 | case SIZE_2NxnU: |
---|
2279 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
2280 | break; |
---|
2281 | case SIZE_2NxnD: |
---|
2282 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
2283 | break; |
---|
2284 | case SIZE_nLx2N: |
---|
2285 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
---|
2286 | break; |
---|
2287 | case SIZE_nRx2N: |
---|
2288 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2289 | break; |
---|
2290 | default: |
---|
2291 | assert (0); |
---|
2292 | break; |
---|
2293 | } |
---|
2294 | } |
---|
2295 | |
---|
2296 | /** Derives the partition index of neighbouring bottom right block |
---|
2297 | * \param [in] eCUMode |
---|
2298 | * \param [in] uiPartIdx |
---|
2299 | * \param [out] ruiPartIdxRB |
---|
2300 | */ |
---|
2301 | Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxRB ) |
---|
2302 | { |
---|
2303 | ruiPartIdxRB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth() + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1]; |
---|
2304 | |
---|
2305 | switch ( m_pePartSize[0] ) |
---|
2306 | { |
---|
2307 | case SIZE_2Nx2N: |
---|
2308 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
2309 | break; |
---|
2310 | case SIZE_2NxN: |
---|
2311 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2312 | break; |
---|
2313 | case SIZE_Nx2N: |
---|
2314 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
2315 | break; |
---|
2316 | case SIZE_NxN: |
---|
2317 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2318 | break; |
---|
2319 | case SIZE_2NxnU: |
---|
2320 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
2321 | break; |
---|
2322 | case SIZE_2NxnD: |
---|
2323 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
2324 | break; |
---|
2325 | case SIZE_nLx2N: |
---|
2326 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
---|
2327 | break; |
---|
2328 | case SIZE_nRx2N: |
---|
2329 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
---|
2330 | break; |
---|
2331 | default: |
---|
2332 | assert (0); |
---|
2333 | break; |
---|
2334 | } |
---|
2335 | } |
---|
2336 | |
---|
2337 | Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ) |
---|
2338 | { |
---|
2339 | UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; |
---|
2340 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset; |
---|
2341 | ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; |
---|
2342 | } |
---|
2343 | |
---|
2344 | Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ) |
---|
2345 | { |
---|
2346 | UInt uiAbsIdx; |
---|
2347 | UInt uiMinCuWidth, uiWidthInMinCus; |
---|
2348 | |
---|
2349 | uiMinCuWidth = getPic()->getMinCUWidth(); |
---|
2350 | uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; |
---|
2351 | uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; |
---|
2352 | uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); |
---|
2353 | ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; |
---|
2354 | } |
---|
2355 | |
---|
2356 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
2357 | { |
---|
2358 | |
---|
2359 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
2360 | { |
---|
2361 | return false; |
---|
2362 | } |
---|
2363 | |
---|
2364 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
2365 | { |
---|
2366 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
2367 | { |
---|
2368 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
2369 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
2370 | { |
---|
2371 | return false; |
---|
2372 | } |
---|
2373 | } |
---|
2374 | } |
---|
2375 | |
---|
2376 | return true; |
---|
2377 | } |
---|
2378 | |
---|
2379 | /** Constructs a list of merging candidates |
---|
2380 | * \param uiAbsPartIdx |
---|
2381 | * \param uiPUIdx |
---|
2382 | * \param uiDepth |
---|
2383 | * \param pcMvFieldNeighbours |
---|
2384 | * \param puhInterDirNeighbours |
---|
2385 | * \param numValidMergeCand |
---|
2386 | */ |
---|
2387 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) |
---|
2388 | { |
---|
2389 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
2390 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
2391 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
2392 | { |
---|
2393 | abCandIsInter[ui] = false; |
---|
2394 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
2395 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
2396 | } |
---|
2397 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
2398 | // compute the location of the current PU |
---|
2399 | Int xP, yP, nPSW, nPSH; |
---|
2400 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
2401 | |
---|
2402 | Int iCount = 0; |
---|
2403 | |
---|
2404 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
2405 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
2406 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
2407 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
2408 | |
---|
2409 | //left |
---|
2410 | UInt uiLeftPartIdx = 0; |
---|
2411 | TComDataCU* pcCULeft = 0; |
---|
2412 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
2413 | Bool isAvailableA1 = pcCULeft && |
---|
2414 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
2415 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
2416 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
---|
2417 | if ( isAvailableA1 ) |
---|
2418 | { |
---|
2419 | abCandIsInter[iCount] = true; |
---|
2420 | // get Inter Dir |
---|
2421 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
2422 | // get Mv from Left |
---|
2423 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2424 | if ( getSlice()->isInterB() ) |
---|
2425 | { |
---|
2426 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2427 | } |
---|
2428 | if ( mrgCandIdx == iCount ) |
---|
2429 | { |
---|
2430 | return; |
---|
2431 | } |
---|
2432 | iCount ++; |
---|
2433 | } |
---|
2434 | |
---|
2435 | // early termination |
---|
2436 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2437 | { |
---|
2438 | return; |
---|
2439 | } |
---|
2440 | // above |
---|
2441 | UInt uiAbovePartIdx = 0; |
---|
2442 | TComDataCU* pcCUAbove = 0; |
---|
2443 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
2444 | Bool isAvailableB1 = pcCUAbove && |
---|
2445 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
2446 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
2447 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
---|
2448 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
2449 | { |
---|
2450 | abCandIsInter[iCount] = true; |
---|
2451 | // get Inter Dir |
---|
2452 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
2453 | // get Mv from Left |
---|
2454 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2455 | if ( getSlice()->isInterB() ) |
---|
2456 | { |
---|
2457 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2458 | } |
---|
2459 | if ( mrgCandIdx == iCount ) |
---|
2460 | { |
---|
2461 | return; |
---|
2462 | } |
---|
2463 | iCount ++; |
---|
2464 | } |
---|
2465 | // early termination |
---|
2466 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2467 | { |
---|
2468 | return; |
---|
2469 | } |
---|
2470 | |
---|
2471 | // above right |
---|
2472 | UInt uiAboveRightPartIdx = 0; |
---|
2473 | TComDataCU* pcCUAboveRight = 0; |
---|
2474 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
2475 | Bool isAvailableB0 = pcCUAboveRight && |
---|
2476 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
2477 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
---|
2478 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
2479 | { |
---|
2480 | abCandIsInter[iCount] = true; |
---|
2481 | // get Inter Dir |
---|
2482 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
2483 | // get Mv from Left |
---|
2484 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2485 | if ( getSlice()->isInterB() ) |
---|
2486 | { |
---|
2487 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2488 | } |
---|
2489 | if ( mrgCandIdx == iCount ) |
---|
2490 | { |
---|
2491 | return; |
---|
2492 | } |
---|
2493 | iCount ++; |
---|
2494 | } |
---|
2495 | // early termination |
---|
2496 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2497 | { |
---|
2498 | return; |
---|
2499 | } |
---|
2500 | |
---|
2501 | //left bottom |
---|
2502 | UInt uiLeftBottomPartIdx = 0; |
---|
2503 | TComDataCU* pcCULeftBottom = 0; |
---|
2504 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
2505 | Bool isAvailableA0 = pcCULeftBottom && |
---|
2506 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
2507 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
---|
2508 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
2509 | { |
---|
2510 | abCandIsInter[iCount] = true; |
---|
2511 | // get Inter Dir |
---|
2512 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
2513 | // get Mv from Left |
---|
2514 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2515 | if ( getSlice()->isInterB() ) |
---|
2516 | { |
---|
2517 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2518 | } |
---|
2519 | if ( mrgCandIdx == iCount ) |
---|
2520 | { |
---|
2521 | return; |
---|
2522 | } |
---|
2523 | iCount ++; |
---|
2524 | } |
---|
2525 | // early termination |
---|
2526 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2527 | { |
---|
2528 | return; |
---|
2529 | } |
---|
2530 | // above left |
---|
2531 | if( iCount < 4 ) |
---|
2532 | { |
---|
2533 | UInt uiAboveLeftPartIdx = 0; |
---|
2534 | TComDataCU* pcCUAboveLeft = 0; |
---|
2535 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
2536 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
2537 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
2538 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
---|
2539 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
2540 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
2541 | { |
---|
2542 | abCandIsInter[iCount] = true; |
---|
2543 | // get Inter Dir |
---|
2544 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
2545 | // get Mv from Left |
---|
2546 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2547 | if ( getSlice()->isInterB() ) |
---|
2548 | { |
---|
2549 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2550 | } |
---|
2551 | if ( mrgCandIdx == iCount ) |
---|
2552 | { |
---|
2553 | return; |
---|
2554 | } |
---|
2555 | iCount ++; |
---|
2556 | } |
---|
2557 | } |
---|
2558 | // early termination |
---|
2559 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2560 | { |
---|
2561 | return; |
---|
2562 | } |
---|
2563 | if ( getSlice()->getEnableTMVPFlag()) |
---|
2564 | { |
---|
2565 | //>> MTK colocated-RightBottom |
---|
2566 | UInt uiPartIdxRB; |
---|
2567 | Int uiLCUIdx = getAddr(); |
---|
2568 | |
---|
2569 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
2570 | |
---|
2571 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
2572 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
2573 | |
---|
2574 | TComMv cColMv; |
---|
2575 | Int iRefIdx; |
---|
2576 | |
---|
2577 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
2578 | { |
---|
2579 | uiLCUIdx = -1; |
---|
2580 | } |
---|
2581 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
2582 | { |
---|
2583 | uiLCUIdx = -1; |
---|
2584 | } |
---|
2585 | else |
---|
2586 | { |
---|
2587 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
2588 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
2589 | { |
---|
2590 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
2591 | uiLCUIdx = getAddr(); |
---|
2592 | } |
---|
2593 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
2594 | { |
---|
2595 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
2596 | uiLCUIdx = -1 ; |
---|
2597 | } |
---|
2598 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
2599 | { |
---|
2600 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
2601 | uiLCUIdx = getAddr() + 1; |
---|
2602 | } |
---|
2603 | else //is the right bottom corner of LCU |
---|
2604 | { |
---|
2605 | uiAbsPartAddr = 0; |
---|
2606 | uiLCUIdx = -1 ; |
---|
2607 | } |
---|
2608 | } |
---|
2609 | |
---|
2610 | |
---|
2611 | iRefIdx = 0; |
---|
2612 | Bool bExistMV = false; |
---|
2613 | UInt uiPartIdxCenter; |
---|
2614 | UInt uiCurLCUIdx = getAddr(); |
---|
2615 | Int dir = 0; |
---|
2616 | UInt uiArrayAddr = iCount; |
---|
2617 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
2618 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
2619 | if( bExistMV == false ) |
---|
2620 | { |
---|
2621 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
2622 | } |
---|
2623 | if( bExistMV ) |
---|
2624 | { |
---|
2625 | dir |= 1; |
---|
2626 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
2627 | } |
---|
2628 | |
---|
2629 | if ( getSlice()->isInterB() ) |
---|
2630 | { |
---|
2631 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
2632 | if( bExistMV == false ) |
---|
2633 | { |
---|
2634 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
2635 | } |
---|
2636 | if( bExistMV ) |
---|
2637 | { |
---|
2638 | dir |= 2; |
---|
2639 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
2640 | } |
---|
2641 | } |
---|
2642 | |
---|
2643 | if (dir != 0) |
---|
2644 | { |
---|
2645 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
2646 | abCandIsInter[uiArrayAddr] = true; |
---|
2647 | |
---|
2648 | if ( mrgCandIdx == iCount ) |
---|
2649 | { |
---|
2650 | return; |
---|
2651 | } |
---|
2652 | iCount++; |
---|
2653 | } |
---|
2654 | } |
---|
2655 | // early termination |
---|
2656 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2657 | { |
---|
2658 | return; |
---|
2659 | } |
---|
2660 | UInt uiArrayAddr = iCount; |
---|
2661 | UInt uiCutoff = uiArrayAddr; |
---|
2662 | |
---|
2663 | if ( getSlice()->isInterB()) |
---|
2664 | { |
---|
2665 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
2666 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
2667 | |
---|
2668 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
2669 | { |
---|
2670 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
2671 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
2672 | { |
---|
2673 | abCandIsInter[uiArrayAddr] = true; |
---|
2674 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
2675 | |
---|
2676 | // get Mv from cand[i] and cand[j] |
---|
2677 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
2678 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
2679 | |
---|
2680 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
2681 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
2682 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
2683 | { |
---|
2684 | abCandIsInter[uiArrayAddr] = false; |
---|
2685 | } |
---|
2686 | else |
---|
2687 | { |
---|
2688 | uiArrayAddr++; |
---|
2689 | } |
---|
2690 | } |
---|
2691 | } |
---|
2692 | } |
---|
2693 | // early termination |
---|
2694 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
2695 | { |
---|
2696 | return; |
---|
2697 | } |
---|
2698 | Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
2699 | Int r = 0; |
---|
2700 | Int refcnt = 0; |
---|
2701 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
2702 | { |
---|
2703 | abCandIsInter[uiArrayAddr] = true; |
---|
2704 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
2705 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
2706 | |
---|
2707 | if ( getSlice()->isInterB() ) |
---|
2708 | { |
---|
2709 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
2710 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
2711 | } |
---|
2712 | uiArrayAddr++; |
---|
2713 | if ( refcnt == iNumRefIdx - 1 ) |
---|
2714 | { |
---|
2715 | r = 0; |
---|
2716 | } |
---|
2717 | else |
---|
2718 | { |
---|
2719 | ++r; |
---|
2720 | ++refcnt; |
---|
2721 | } |
---|
2722 | } |
---|
2723 | |
---|
2724 | numValidMergeCand = uiArrayAddr; |
---|
2725 | } |
---|
2726 | |
---|
2727 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
---|
2728 | * \param xN, xN location of the upper-left corner pixel of a neighboring PU |
---|
2729 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
2730 | * \returns Bool |
---|
2731 | */ |
---|
2732 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) |
---|
2733 | { |
---|
2734 | |
---|
2735 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
---|
2736 | if ((xN>>plevel)!= (xP>>plevel)) |
---|
2737 | { |
---|
2738 | return true; |
---|
2739 | } |
---|
2740 | if ((yN>>plevel)!= (yP>>plevel)) |
---|
2741 | { |
---|
2742 | return true; |
---|
2743 | } |
---|
2744 | return false; |
---|
2745 | } |
---|
2746 | /** calculate the location of upper-left corner pixel and size of the current PU. |
---|
2747 | * \param partIdx PU index within a CU |
---|
2748 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
2749 | * \param PSW, nPSH size of the curren PU |
---|
2750 | * \returns Void |
---|
2751 | */ |
---|
2752 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) |
---|
2753 | { |
---|
2754 | UInt col = m_uiCUPelX; |
---|
2755 | UInt row = m_uiCUPelY; |
---|
2756 | |
---|
2757 | switch ( m_pePartSize[0] ) |
---|
2758 | { |
---|
2759 | case SIZE_2NxN: |
---|
2760 | nPSW = getWidth(0); |
---|
2761 | nPSH = getHeight(0) >> 1; |
---|
2762 | xP = col; |
---|
2763 | yP = (partIdx ==0)? row: row + nPSH; |
---|
2764 | break; |
---|
2765 | case SIZE_Nx2N: |
---|
2766 | nPSW = getWidth(0) >> 1; |
---|
2767 | nPSH = getHeight(0); |
---|
2768 | xP = (partIdx ==0)? col: col + nPSW; |
---|
2769 | yP = row; |
---|
2770 | break; |
---|
2771 | case SIZE_NxN: |
---|
2772 | nPSW = getWidth(0) >> 1; |
---|
2773 | nPSH = getHeight(0) >> 1; |
---|
2774 | xP = col + (partIdx&0x1)*nPSW; |
---|
2775 | yP = row + (partIdx>>1)*nPSH; |
---|
2776 | break; |
---|
2777 | case SIZE_2NxnU: |
---|
2778 | nPSW = getWidth(0); |
---|
2779 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
2780 | xP = col; |
---|
2781 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
2782 | |
---|
2783 | break; |
---|
2784 | case SIZE_2NxnD: |
---|
2785 | nPSW = getWidth(0); |
---|
2786 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
2787 | xP = col; |
---|
2788 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
2789 | break; |
---|
2790 | case SIZE_nLx2N: |
---|
2791 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
2792 | nPSH = getHeight(0); |
---|
2793 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
2794 | yP = row; |
---|
2795 | break; |
---|
2796 | case SIZE_nRx2N: |
---|
2797 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
2798 | nPSH = getHeight(0); |
---|
2799 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
2800 | yP = row; |
---|
2801 | break; |
---|
2802 | default: |
---|
2803 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
2804 | nPSW = getWidth(0); |
---|
2805 | nPSH = getHeight(0); |
---|
2806 | xP = col ; |
---|
2807 | yP = row ; |
---|
2808 | |
---|
2809 | break; |
---|
2810 | } |
---|
2811 | } |
---|
2812 | |
---|
2813 | /** Constructs a list of candidates for AMVP |
---|
2814 | * \param uiPartIdx |
---|
2815 | * \param uiPartAddr |
---|
2816 | * \param eRefPicList |
---|
2817 | * \param iRefIdx |
---|
2818 | * \param pInfo |
---|
2819 | */ |
---|
2820 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
---|
2821 | { |
---|
2822 | TComMv cMvPred; |
---|
2823 | Bool bAddedSmvp = false; |
---|
2824 | |
---|
2825 | pInfo->iN = 0; |
---|
2826 | if (iRefIdx < 0) |
---|
2827 | { |
---|
2828 | return; |
---|
2829 | } |
---|
2830 | |
---|
2831 | //-- Get Spatial MV |
---|
2832 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
2833 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
2834 | Bool bAdded = false; |
---|
2835 | |
---|
2836 | deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
2837 | deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB ); |
---|
2838 | |
---|
2839 | TComDataCU* tmpCU = NULL; |
---|
2840 | UInt idx; |
---|
2841 | tmpCU = getPUBelowLeft(idx, uiPartIdxLB); |
---|
2842 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
2843 | |
---|
2844 | if (!bAddedSmvp) |
---|
2845 | { |
---|
2846 | tmpCU = getPULeft(idx, uiPartIdxLB); |
---|
2847 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
2848 | } |
---|
2849 | |
---|
2850 | // Left predictor search |
---|
2851 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
2852 | if (!bAdded) |
---|
2853 | { |
---|
2854 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
2855 | } |
---|
2856 | |
---|
2857 | if(!bAdded) |
---|
2858 | { |
---|
2859 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
2860 | if (!bAdded) |
---|
2861 | { |
---|
2862 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
2863 | } |
---|
2864 | } |
---|
2865 | // Above predictor search |
---|
2866 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
2867 | |
---|
2868 | if (!bAdded) |
---|
2869 | { |
---|
2870 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
2871 | } |
---|
2872 | |
---|
2873 | if(!bAdded) |
---|
2874 | { |
---|
2875 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
2876 | } |
---|
2877 | bAdded = bAddedSmvp; |
---|
2878 | if (pInfo->iN==2) bAdded = true; |
---|
2879 | |
---|
2880 | if(!bAdded) |
---|
2881 | { |
---|
2882 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
2883 | if (!bAdded) |
---|
2884 | { |
---|
2885 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
2886 | } |
---|
2887 | |
---|
2888 | if(!bAdded) |
---|
2889 | { |
---|
2890 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
2891 | } |
---|
2892 | } |
---|
2893 | |
---|
2894 | if ( pInfo->iN == 2 ) |
---|
2895 | { |
---|
2896 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
---|
2897 | { |
---|
2898 | pInfo->iN = 1; |
---|
2899 | } |
---|
2900 | } |
---|
2901 | |
---|
2902 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
2903 | { |
---|
2904 | // Get Temporal Motion Predictor |
---|
2905 | Int iRefIdx_Col = iRefIdx; |
---|
2906 | TComMv cColMv; |
---|
2907 | UInt uiPartIdxRB; |
---|
2908 | UInt uiAbsPartIdx; |
---|
2909 | UInt uiAbsPartAddr; |
---|
2910 | Int uiLCUIdx = getAddr(); |
---|
2911 | |
---|
2912 | deriveRightBottomIdx( uiPartIdx, uiPartIdxRB ); |
---|
2913 | uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
---|
2914 | |
---|
2915 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
2916 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
---|
2917 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
2918 | { |
---|
2919 | uiLCUIdx = -1; |
---|
2920 | } |
---|
2921 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
2922 | { |
---|
2923 | uiLCUIdx = -1; |
---|
2924 | } |
---|
2925 | else |
---|
2926 | { |
---|
2927 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
2928 | ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
2929 | { |
---|
2930 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; |
---|
2931 | uiLCUIdx = getAddr(); |
---|
2932 | } |
---|
2933 | else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
2934 | { |
---|
2935 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
2936 | uiLCUIdx = -1 ; |
---|
2937 | } |
---|
2938 | else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
2939 | { |
---|
2940 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
---|
2941 | uiLCUIdx = getAddr() + 1; |
---|
2942 | } |
---|
2943 | else //is the right bottom corner of LCU |
---|
2944 | { |
---|
2945 | uiAbsPartAddr = 0; |
---|
2946 | uiLCUIdx = -1 ; |
---|
2947 | } |
---|
2948 | } |
---|
2949 | if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col ) ) |
---|
2950 | { |
---|
2951 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
2952 | } |
---|
2953 | else |
---|
2954 | { |
---|
2955 | UInt uiPartIdxCenter; |
---|
2956 | UInt uiCurLCUIdx = getAddr(); |
---|
2957 | xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); |
---|
2958 | if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col )) |
---|
2959 | { |
---|
2960 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
2961 | } |
---|
2962 | } |
---|
2963 | //---- co-located RightBottom Temporal Predictor ---// |
---|
2964 | } |
---|
2965 | |
---|
2966 | if (pInfo->iN > AMVP_MAX_NUM_CANDS) |
---|
2967 | { |
---|
2968 | pInfo->iN = AMVP_MAX_NUM_CANDS; |
---|
2969 | } |
---|
2970 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
---|
2971 | { |
---|
2972 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
---|
2973 | pInfo->iN++; |
---|
2974 | } |
---|
2975 | return ; |
---|
2976 | } |
---|
2977 | |
---|
2978 | Bool TComDataCU::isBipredRestriction(UInt puIdx) |
---|
2979 | { |
---|
2980 | Int width = 0; |
---|
2981 | Int height = 0; |
---|
2982 | UInt partAddr; |
---|
2983 | |
---|
2984 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
---|
2985 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
---|
2986 | { |
---|
2987 | return true; |
---|
2988 | } |
---|
2989 | return false; |
---|
2990 | } |
---|
2991 | |
---|
2992 | Void TComDataCU::clipMv (TComMv& rcMv) |
---|
2993 | { |
---|
2994 | Int iMvShift = 2; |
---|
2995 | Int iOffset = 8; |
---|
2996 | Int iHorMax = ( m_pcSlice->getSPS()->getPicWidthInLumaSamples() + iOffset - m_uiCUPelX - 1 ) << iMvShift; |
---|
2997 | Int iHorMin = ( -(Int)g_uiMaxCUWidth - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
---|
2998 | |
---|
2999 | Int iVerMax = ( m_pcSlice->getSPS()->getPicHeightInLumaSamples() + iOffset - m_uiCUPelY - 1 ) << iMvShift; |
---|
3000 | Int iVerMin = ( -(Int)g_uiMaxCUHeight - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
---|
3001 | |
---|
3002 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
---|
3003 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
---|
3004 | } |
---|
3005 | |
---|
3006 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
---|
3007 | { |
---|
3008 | UInt uiShift = ( (m_puhTrIdx[uiAbsPartIdx]==0) && (m_pePartSize[uiAbsPartIdx]==SIZE_NxN) ) ? m_puhTrIdx[uiAbsPartIdx]+1 : m_puhTrIdx[uiAbsPartIdx]; |
---|
3009 | uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
3010 | |
---|
3011 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
3012 | UInt uiCnt = 0; |
---|
3013 | while( uiWidth ) |
---|
3014 | { |
---|
3015 | uiCnt++; |
---|
3016 | uiWidth>>=1; |
---|
3017 | } |
---|
3018 | uiCnt-=2; |
---|
3019 | return uiCnt > 6 ? 6 : uiCnt; |
---|
3020 | } |
---|
3021 | |
---|
3022 | Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts ) |
---|
3023 | { |
---|
3024 | ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
3025 | } |
---|
3026 | |
---|
3027 | /** Set a I_PCM flag for all sub-partitions of a partition. |
---|
3028 | * \param bIpcmFlag I_PCM flag |
---|
3029 | * \param uiAbsPartIdx patition index |
---|
3030 | * \param uiDepth CU depth |
---|
3031 | * \returns Void |
---|
3032 | */ |
---|
3033 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
---|
3034 | { |
---|
3035 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
3036 | |
---|
3037 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
---|
3038 | } |
---|
3039 | |
---|
3040 | /** Test whether the current block is skipped |
---|
3041 | * \param uiPartIdx Block index |
---|
3042 | * \returns Flag indicating whether the block is skipped |
---|
3043 | */ |
---|
3044 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
---|
3045 | { |
---|
3046 | return ( getSkipFlag( uiPartIdx ) ); |
---|
3047 | } |
---|
3048 | |
---|
3049 | // ==================================================================================================================== |
---|
3050 | // Protected member functions |
---|
3051 | // ==================================================================================================================== |
---|
3052 | |
---|
3053 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
3054 | { |
---|
3055 | TComDataCU* pcTmpCU = NULL; |
---|
3056 | UInt uiIdx; |
---|
3057 | switch( eDir ) |
---|
3058 | { |
---|
3059 | case MD_LEFT: |
---|
3060 | { |
---|
3061 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
3062 | break; |
---|
3063 | } |
---|
3064 | case MD_ABOVE: |
---|
3065 | { |
---|
3066 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx ); |
---|
3067 | break; |
---|
3068 | } |
---|
3069 | case MD_ABOVE_RIGHT: |
---|
3070 | { |
---|
3071 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
3072 | break; |
---|
3073 | } |
---|
3074 | case MD_BELOW_LEFT: |
---|
3075 | { |
---|
3076 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
3077 | break; |
---|
3078 | } |
---|
3079 | case MD_ABOVE_LEFT: |
---|
3080 | { |
---|
3081 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
3082 | break; |
---|
3083 | } |
---|
3084 | default: |
---|
3085 | { |
---|
3086 | break; |
---|
3087 | } |
---|
3088 | } |
---|
3089 | |
---|
3090 | if ( pcTmpCU == NULL ) |
---|
3091 | { |
---|
3092 | return false; |
---|
3093 | } |
---|
3094 | |
---|
3095 | #if L0363_MVP_POC |
---|
3096 | if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )) |
---|
3097 | #else |
---|
3098 | if ( m_pcSlice->isEqualRef(eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx), iRefIdx) ) |
---|
3099 | #endif |
---|
3100 | { |
---|
3101 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
3102 | |
---|
3103 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
3104 | return true; |
---|
3105 | } |
---|
3106 | |
---|
3107 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
3108 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
3109 | { |
---|
3110 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
3111 | } |
---|
3112 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
3113 | { |
---|
3114 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
3115 | } |
---|
3116 | |
---|
3117 | |
---|
3118 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
3119 | Int iNeibRefPOC; |
---|
3120 | |
---|
3121 | |
---|
3122 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
---|
3123 | { |
---|
3124 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
3125 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
---|
3126 | { |
---|
3127 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
3128 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
3129 | return true; |
---|
3130 | } |
---|
3131 | } |
---|
3132 | return false; |
---|
3133 | } |
---|
3134 | |
---|
3135 | /** |
---|
3136 | * \param pInfo |
---|
3137 | * \param eRefPicList |
---|
3138 | * \param iRefIdx |
---|
3139 | * \param uiPartUnitIdx |
---|
3140 | * \param eDir |
---|
3141 | * \returns Bool |
---|
3142 | */ |
---|
3143 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
3144 | { |
---|
3145 | TComDataCU* pcTmpCU = NULL; |
---|
3146 | UInt uiIdx; |
---|
3147 | switch( eDir ) |
---|
3148 | { |
---|
3149 | case MD_LEFT: |
---|
3150 | { |
---|
3151 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
3152 | break; |
---|
3153 | } |
---|
3154 | case MD_ABOVE: |
---|
3155 | { |
---|
3156 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
3157 | break; |
---|
3158 | } |
---|
3159 | case MD_ABOVE_RIGHT: |
---|
3160 | { |
---|
3161 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
3162 | break; |
---|
3163 | } |
---|
3164 | case MD_BELOW_LEFT: |
---|
3165 | { |
---|
3166 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
3167 | break; |
---|
3168 | } |
---|
3169 | case MD_ABOVE_LEFT: |
---|
3170 | { |
---|
3171 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
3172 | break; |
---|
3173 | } |
---|
3174 | default: |
---|
3175 | { |
---|
3176 | break; |
---|
3177 | } |
---|
3178 | } |
---|
3179 | |
---|
3180 | if ( pcTmpCU == NULL ) |
---|
3181 | { |
---|
3182 | return false; |
---|
3183 | } |
---|
3184 | |
---|
3185 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
3186 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
3187 | { |
---|
3188 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
3189 | } |
---|
3190 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
3191 | { |
---|
3192 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
3193 | } |
---|
3194 | |
---|
3195 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
3196 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
3197 | Int iNeibPOC = iCurrPOC; |
---|
3198 | Int iNeibRefPOC; |
---|
3199 | |
---|
3200 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
3201 | Bool bIsNeibRefLongTerm = false; |
---|
3202 | |
---|
3203 | //--------------- V1 (END) ------------------// |
---|
3204 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
---|
3205 | { |
---|
3206 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
---|
3207 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
3208 | TComMv rcMv; |
---|
3209 | |
---|
3210 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
3211 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
3212 | { |
---|
3213 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
3214 | { |
---|
3215 | rcMv = cMvPred; |
---|
3216 | } |
---|
3217 | else |
---|
3218 | { |
---|
3219 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
3220 | if ( iScale == 4096 ) |
---|
3221 | { |
---|
3222 | rcMv = cMvPred; |
---|
3223 | } |
---|
3224 | else |
---|
3225 | { |
---|
3226 | rcMv = cMvPred.scaleMv( iScale ); |
---|
3227 | } |
---|
3228 | } |
---|
3229 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
3230 | return true; |
---|
3231 | } |
---|
3232 | } |
---|
3233 | //---------------------- V2(END) --------------------// |
---|
3234 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
---|
3235 | { |
---|
3236 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
3237 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
3238 | TComMv rcMv; |
---|
3239 | |
---|
3240 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
3241 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
3242 | { |
---|
3243 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
3244 | { |
---|
3245 | rcMv = cMvPred; |
---|
3246 | } |
---|
3247 | else |
---|
3248 | { |
---|
3249 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
3250 | if ( iScale == 4096 ) |
---|
3251 | { |
---|
3252 | rcMv = cMvPred; |
---|
3253 | } |
---|
3254 | else |
---|
3255 | { |
---|
3256 | rcMv = cMvPred.scaleMv( iScale ); |
---|
3257 | } |
---|
3258 | } |
---|
3259 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
3260 | return true; |
---|
3261 | } |
---|
3262 | } |
---|
3263 | //---------------------- V3(END) --------------------// |
---|
3264 | return false; |
---|
3265 | } |
---|
3266 | |
---|
3267 | /** |
---|
3268 | * \param eRefPicList |
---|
3269 | * \param uiCUAddr |
---|
3270 | * \param uiPartUnitIdx |
---|
3271 | * \param riRefIdx |
---|
3272 | * \returns Bool |
---|
3273 | */ |
---|
3274 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx ) |
---|
3275 | { |
---|
3276 | UInt uiAbsPartAddr = uiPartUnitIdx; |
---|
3277 | |
---|
3278 | RefPicList eColRefPicList; |
---|
3279 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
---|
3280 | TComMv cColMv; |
---|
3281 | |
---|
3282 | // use coldir. |
---|
3283 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
3284 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
3285 | if(pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE) |
---|
3286 | { |
---|
3287 | return false; |
---|
3288 | } |
---|
3289 | iCurrPOC = m_pcSlice->getPOC(); |
---|
3290 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
3291 | iColPOC = pColCU->getSlice()->getPOC(); |
---|
3292 | |
---|
3293 | if (pColCU->isIntra(uiAbsPartAddr)) |
---|
3294 | { |
---|
3295 | return false; |
---|
3296 | } |
---|
3297 | eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
---|
3298 | |
---|
3299 | Int iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
3300 | |
---|
3301 | if (iColRefIdx < 0 ) |
---|
3302 | { |
---|
3303 | eColRefPicList = RefPicList(1 - eColRefPicList); |
---|
3304 | iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
3305 | |
---|
3306 | if (iColRefIdx < 0 ) |
---|
3307 | { |
---|
3308 | return false; |
---|
3309 | } |
---|
3310 | } |
---|
3311 | |
---|
3312 | // Scale the vector. |
---|
3313 | iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
---|
3314 | cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
3315 | |
---|
3316 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
3317 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
---|
3318 | Bool bIsColRefLongTerm = pColCU->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); |
---|
3319 | |
---|
3320 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
3321 | { |
---|
3322 | return false; |
---|
3323 | } |
---|
3324 | |
---|
3325 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
---|
3326 | { |
---|
3327 | rcMv = cColMv; |
---|
3328 | } |
---|
3329 | else |
---|
3330 | { |
---|
3331 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
3332 | if ( iScale == 4096 ) |
---|
3333 | { |
---|
3334 | rcMv = cColMv; |
---|
3335 | } |
---|
3336 | else |
---|
3337 | { |
---|
3338 | rcMv = cColMv.scaleMv( iScale ); |
---|
3339 | } |
---|
3340 | } |
---|
3341 | return true; |
---|
3342 | } |
---|
3343 | |
---|
3344 | UInt TComDataCU::xGetMvdBits(TComMv cMvd) |
---|
3345 | { |
---|
3346 | return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) ); |
---|
3347 | } |
---|
3348 | |
---|
3349 | UInt TComDataCU::xGetComponentBits(Int iVal) |
---|
3350 | { |
---|
3351 | UInt uiLength = 1; |
---|
3352 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
3353 | |
---|
3354 | assert ( uiTemp ); |
---|
3355 | |
---|
3356 | while ( 1 != uiTemp ) |
---|
3357 | { |
---|
3358 | uiTemp >>= 1; |
---|
3359 | uiLength += 2; |
---|
3360 | } |
---|
3361 | |
---|
3362 | return uiLength; |
---|
3363 | } |
---|
3364 | |
---|
3365 | |
---|
3366 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
3367 | { |
---|
3368 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
3369 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
3370 | |
---|
3371 | if( iDiffPocD == iDiffPocB ) |
---|
3372 | { |
---|
3373 | return 4096; |
---|
3374 | } |
---|
3375 | else |
---|
3376 | { |
---|
3377 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
3378 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
3379 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
3380 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
---|
3381 | return iScale; |
---|
3382 | } |
---|
3383 | } |
---|
3384 | |
---|
3385 | /** |
---|
3386 | * \param eCUMode |
---|
3387 | * \param uiPartIdx |
---|
3388 | * \param ruiPartIdxCenter |
---|
3389 | * \returns Void |
---|
3390 | */ |
---|
3391 | Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
---|
3392 | { |
---|
3393 | UInt uiPartAddr; |
---|
3394 | Int iPartWidth; |
---|
3395 | Int iPartHeight; |
---|
3396 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
3397 | |
---|
3398 | ruiPartIdxCenter = m_uiAbsIdxInLCU+uiPartAddr; // partition origin. |
---|
3399 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
3400 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInWidth() |
---|
3401 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
---|
3402 | } |
---|
3403 | |
---|
3404 | Void TComDataCU::compressMV() |
---|
3405 | { |
---|
3406 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
3407 | if (scaleFactor > 0) |
---|
3408 | { |
---|
3409 | m_acCUMvField[0].compress(m_pePredMode, scaleFactor); |
---|
3410 | m_acCUMvField[1].compress(m_pePredMode, scaleFactor); |
---|
3411 | } |
---|
3412 | } |
---|
3413 | |
---|
3414 | UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) |
---|
3415 | { |
---|
3416 | UInt uiCTXIdx; |
---|
3417 | UInt uiScanIdx; |
---|
3418 | UInt uiDirMode; |
---|
3419 | |
---|
3420 | if ( !bIsIntra ) |
---|
3421 | { |
---|
3422 | uiScanIdx = SCAN_DIAG; |
---|
3423 | return uiScanIdx; |
---|
3424 | } |
---|
3425 | |
---|
3426 | switch(uiWidth) |
---|
3427 | { |
---|
3428 | case 2: uiCTXIdx = 6; break; |
---|
3429 | case 4: uiCTXIdx = 5; break; |
---|
3430 | case 8: uiCTXIdx = 4; break; |
---|
3431 | case 16: uiCTXIdx = 3; break; |
---|
3432 | case 32: uiCTXIdx = 2; break; |
---|
3433 | case 64: uiCTXIdx = 1; break; |
---|
3434 | default: uiCTXIdx = 0; break; |
---|
3435 | } |
---|
3436 | |
---|
3437 | if ( bIsLuma ) |
---|
3438 | { |
---|
3439 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
---|
3440 | uiScanIdx = SCAN_DIAG; |
---|
3441 | if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size |
---|
3442 | { |
---|
3443 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
---|
3444 | } |
---|
3445 | } |
---|
3446 | else |
---|
3447 | { |
---|
3448 | uiDirMode = getChromaIntraDir(uiAbsPartIdx); |
---|
3449 | if( uiDirMode == DM_CHROMA_IDX ) |
---|
3450 | { |
---|
3451 | // get number of partitions in current CU |
---|
3452 | UInt depth = getDepth(uiAbsPartIdx); |
---|
3453 | UInt numParts = getPic()->getNumPartInCU() >> (2 * depth); |
---|
3454 | |
---|
3455 | // get luma mode from upper-left corner of current CU |
---|
3456 | uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); |
---|
3457 | } |
---|
3458 | uiScanIdx = SCAN_DIAG; |
---|
3459 | if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size |
---|
3460 | { |
---|
3461 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
---|
3462 | } |
---|
3463 | } |
---|
3464 | |
---|
3465 | return uiScanIdx; |
---|
3466 | } |
---|
3467 | |
---|
3468 | UInt TComDataCU::getSCUAddr() |
---|
3469 | { |
---|
3470 | return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; |
---|
3471 | } |
---|
3472 | |
---|
3473 | /** Set neighboring blocks availabilities for non-deblocked filtering |
---|
3474 | * \param numLCUInPicWidth number of LCUs in picture width |
---|
3475 | * \param numLCUInPicHeight number of LCUs in picture height |
---|
3476 | * \param numSUInLCUWidth number of SUs in LCU width |
---|
3477 | * \param numSUInLCUHeight number of SUs in LCU height |
---|
3478 | * \param picWidth picture width |
---|
3479 | * \param picHeight picture height |
---|
3480 | * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled |
---|
3481 | * \param bTopTileBoundary true means that top boundary coincides tile boundary |
---|
3482 | * \param bDownTileBoundary true means that bottom boundary coincides tile boundary |
---|
3483 | * \param bLeftTileBoundary true means that left boundary coincides tile boundary |
---|
3484 | * \param bRightTileBoundary true means that right boundary coincides tile boundary |
---|
3485 | * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled |
---|
3486 | */ |
---|
3487 | Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt /*numLCUInPicHeight*/, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight |
---|
3488 | ,std::vector<Bool>& LFCrossSliceBoundary |
---|
3489 | ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary |
---|
3490 | ,Bool bIndependentTileBoundaryEnabled) |
---|
3491 | { |
---|
3492 | UInt numSUInLCU = numSUInLCUWidth*numSUInLCUHeight; |
---|
3493 | Int* pSliceIDMapLCU = m_piSliceSUMap; |
---|
3494 | Bool onlyOneSliceInPic = ((Int)LFCrossSliceBoundary.size() == 1); |
---|
3495 | UInt uiLPelX, uiTPelY; |
---|
3496 | UInt width, height; |
---|
3497 | Bool bPicRBoundary, bPicBBoundary, bPicTBoundary, bPicLBoundary; |
---|
3498 | Bool bLCURBoundary= false, bLCUBBoundary= false, bLCUTBoundary= false, bLCULBoundary= false; |
---|
3499 | Bool* pbAvailBorder; |
---|
3500 | Bool* pbAvail; |
---|
3501 | UInt rTLSU, rBRSU, widthSU, heightSU; |
---|
3502 | UInt zRefSU; |
---|
3503 | Int* pRefID; |
---|
3504 | Int* pRefMapLCU; |
---|
3505 | UInt rTRefSU= 0, rBRefSU= 0, rLRefSU= 0, rRRefSU= 0; |
---|
3506 | Int* pRRefMapLCU= NULL; |
---|
3507 | Int* pLRefMapLCU= NULL; |
---|
3508 | Int* pTRefMapLCU= NULL; |
---|
3509 | Int* pBRefMapLCU= NULL; |
---|
3510 | Int sliceID; |
---|
3511 | UInt numSGU = (UInt)m_vNDFBlock.size(); |
---|
3512 | |
---|
3513 | for(Int i=0; i< numSGU; i++) |
---|
3514 | { |
---|
3515 | NDBFBlockInfo& rSGU = m_vNDFBlock[i]; |
---|
3516 | |
---|
3517 | sliceID = rSGU.sliceID; |
---|
3518 | uiLPelX = rSGU.posX; |
---|
3519 | uiTPelY = rSGU.posY; |
---|
3520 | width = rSGU.width; |
---|
3521 | height = rSGU.height; |
---|
3522 | rTLSU = g_auiZscanToRaster[ rSGU.startSU ]; |
---|
3523 | rBRSU = g_auiZscanToRaster[ rSGU.endSU ]; |
---|
3524 | widthSU = rSGU.widthSU; |
---|
3525 | heightSU = rSGU.heightSU; |
---|
3526 | |
---|
3527 | pbAvailBorder = rSGU.isBorderAvailable; |
---|
3528 | |
---|
3529 | bPicTBoundary= (uiTPelY == 0 )?(true):(false); |
---|
3530 | bPicLBoundary= (uiLPelX == 0 )?(true):(false); |
---|
3531 | bPicRBoundary= (!(uiLPelX+ width < picWidth ) )?(true):(false); |
---|
3532 | bPicBBoundary= (!(uiTPelY + height < picHeight))?(true):(false); |
---|
3533 | |
---|
3534 | bLCULBoundary = (rTLSU % numSUInLCUWidth == 0)?(true):(false); |
---|
3535 | bLCURBoundary = ( (rTLSU+ widthSU) % numSUInLCUWidth == 0)?(true):(false); |
---|
3536 | bLCUTBoundary = ( (UInt)(rTLSU / numSUInLCUWidth)== 0)?(true):(false); |
---|
3537 | bLCUBBoundary = ( (UInt)(rBRSU / numSUInLCUWidth) == (numSUInLCUHeight-1) )?(true):(false); |
---|
3538 | |
---|
3539 | // SGU_L |
---|
3540 | pbAvail = &(pbAvailBorder[SGU_L]); |
---|
3541 | if(bPicLBoundary) |
---|
3542 | { |
---|
3543 | *pbAvail = false; |
---|
3544 | } |
---|
3545 | else if (onlyOneSliceInPic) |
---|
3546 | { |
---|
3547 | *pbAvail = true; |
---|
3548 | } |
---|
3549 | else |
---|
3550 | { |
---|
3551 | // bLCULBoundary = (rTLSU % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
3552 | if(bLCULBoundary) |
---|
3553 | { |
---|
3554 | rLRefSU = rTLSU + numSUInLCUWidth -1; |
---|
3555 | zRefSU = g_auiRasterToZscan[rLRefSU]; |
---|
3556 | pRefMapLCU = pLRefMapLCU= (pSliceIDMapLCU - numSUInLCU); |
---|
3557 | } |
---|
3558 | else |
---|
3559 | { |
---|
3560 | zRefSU = g_auiRasterToZscan[rTLSU - 1]; |
---|
3561 | pRefMapLCU = pSliceIDMapLCU; |
---|
3562 | } |
---|
3563 | pRefID = pRefMapLCU + zRefSU; |
---|
3564 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
3565 | } |
---|
3566 | |
---|
3567 | // SGU_R |
---|
3568 | pbAvail = &(pbAvailBorder[SGU_R]); |
---|
3569 | if(bPicRBoundary) |
---|
3570 | { |
---|
3571 | *pbAvail = false; |
---|
3572 | } |
---|
3573 | else if (onlyOneSliceInPic) |
---|
3574 | { |
---|
3575 | *pbAvail = true; |
---|
3576 | } |
---|
3577 | else |
---|
3578 | { |
---|
3579 | // bLCURBoundary = ( (rTLSU+ uiWidthSU) % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
3580 | if(bLCURBoundary) |
---|
3581 | { |
---|
3582 | rRRefSU = rTLSU + widthSU - numSUInLCUWidth; |
---|
3583 | zRefSU = g_auiRasterToZscan[rRRefSU]; |
---|
3584 | pRefMapLCU = pRRefMapLCU= (pSliceIDMapLCU + numSUInLCU); |
---|
3585 | } |
---|
3586 | else |
---|
3587 | { |
---|
3588 | zRefSU = g_auiRasterToZscan[rTLSU + widthSU]; |
---|
3589 | pRefMapLCU = pSliceIDMapLCU; |
---|
3590 | } |
---|
3591 | pRefID = pRefMapLCU + zRefSU; |
---|
3592 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
3593 | } |
---|
3594 | |
---|
3595 | // SGU_T |
---|
3596 | pbAvail = &(pbAvailBorder[SGU_T]); |
---|
3597 | if(bPicTBoundary) |
---|
3598 | { |
---|
3599 | *pbAvail = false; |
---|
3600 | } |
---|
3601 | else if (onlyOneSliceInPic) |
---|
3602 | { |
---|
3603 | *pbAvail = true; |
---|
3604 | } |
---|
3605 | else |
---|
3606 | { |
---|
3607 | // bLCUTBoundary = ( (UInt)(rTLSU / uiNumSUInLCUWidth)== 0)?(true):(false); |
---|
3608 | if(bLCUTBoundary) |
---|
3609 | { |
---|
3610 | rTRefSU = numSUInLCU - (numSUInLCUWidth - rTLSU); |
---|
3611 | zRefSU = g_auiRasterToZscan[rTRefSU]; |
---|
3612 | pRefMapLCU = pTRefMapLCU= (pSliceIDMapLCU - (numLCUInPicWidth*numSUInLCU)); |
---|
3613 | } |
---|
3614 | else |
---|
3615 | { |
---|
3616 | zRefSU = g_auiRasterToZscan[rTLSU - numSUInLCUWidth]; |
---|
3617 | pRefMapLCU = pSliceIDMapLCU; |
---|
3618 | } |
---|
3619 | pRefID = pRefMapLCU + zRefSU; |
---|
3620 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
3621 | } |
---|
3622 | |
---|
3623 | // SGU_B |
---|
3624 | pbAvail = &(pbAvailBorder[SGU_B]); |
---|
3625 | if(bPicBBoundary) |
---|
3626 | { |
---|
3627 | *pbAvail = false; |
---|
3628 | } |
---|
3629 | else if (onlyOneSliceInPic) |
---|
3630 | { |
---|
3631 | *pbAvail = true; |
---|
3632 | } |
---|
3633 | else |
---|
3634 | { |
---|
3635 | // bLCUBBoundary = ( (UInt)(rBRSU / uiNumSUInLCUWidth) == (uiNumSUInLCUHeight-1) )?(true):(false); |
---|
3636 | if(bLCUBBoundary) |
---|
3637 | { |
---|
3638 | rBRefSU = rTLSU % numSUInLCUWidth; |
---|
3639 | zRefSU = g_auiRasterToZscan[rBRefSU]; |
---|
3640 | pRefMapLCU = pBRefMapLCU= (pSliceIDMapLCU + (numLCUInPicWidth*numSUInLCU)); |
---|
3641 | } |
---|
3642 | else |
---|
3643 | { |
---|
3644 | zRefSU = g_auiRasterToZscan[rTLSU + (heightSU*numSUInLCUWidth)]; |
---|
3645 | pRefMapLCU = pSliceIDMapLCU; |
---|
3646 | } |
---|
3647 | pRefID = pRefMapLCU + zRefSU; |
---|
3648 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
3649 | } |
---|
3650 | |
---|
3651 | // SGU_TL |
---|
3652 | pbAvail = &(pbAvailBorder[SGU_TL]); |
---|
3653 | if(bPicTBoundary || bPicLBoundary) |
---|
3654 | { |
---|
3655 | *pbAvail = false; |
---|
3656 | } |
---|
3657 | else if (onlyOneSliceInPic) |
---|
3658 | { |
---|
3659 | *pbAvail = true; |
---|
3660 | } |
---|
3661 | else |
---|
3662 | { |
---|
3663 | if(bLCUTBoundary && bLCULBoundary) |
---|
3664 | { |
---|
3665 | zRefSU = numSUInLCU -1; |
---|
3666 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
3667 | } |
---|
3668 | else if(bLCUTBoundary) |
---|
3669 | { |
---|
3670 | zRefSU = g_auiRasterToZscan[ rTRefSU- 1]; |
---|
3671 | pRefMapLCU = pTRefMapLCU; |
---|
3672 | } |
---|
3673 | else if(bLCULBoundary) |
---|
3674 | { |
---|
3675 | zRefSU = g_auiRasterToZscan[ rLRefSU- numSUInLCUWidth ]; |
---|
3676 | pRefMapLCU = pLRefMapLCU; |
---|
3677 | } |
---|
3678 | else //inside LCU |
---|
3679 | { |
---|
3680 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth -1]; |
---|
3681 | pRefMapLCU = pSliceIDMapLCU; |
---|
3682 | } |
---|
3683 | pRefID = pRefMapLCU + zRefSU; |
---|
3684 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
3685 | } |
---|
3686 | |
---|
3687 | // SGU_TR |
---|
3688 | pbAvail = &(pbAvailBorder[SGU_TR]); |
---|
3689 | if(bPicTBoundary || bPicRBoundary) |
---|
3690 | { |
---|
3691 | *pbAvail = false; |
---|
3692 | } |
---|
3693 | else if (onlyOneSliceInPic) |
---|
3694 | { |
---|
3695 | *pbAvail = true; |
---|
3696 | } |
---|
3697 | else |
---|
3698 | { |
---|
3699 | if(bLCUTBoundary && bLCURBoundary) |
---|
3700 | { |
---|
3701 | zRefSU = g_auiRasterToZscan[numSUInLCU - numSUInLCUWidth]; |
---|
3702 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
3703 | } |
---|
3704 | else if(bLCUTBoundary) |
---|
3705 | { |
---|
3706 | zRefSU = g_auiRasterToZscan[ rTRefSU+ widthSU]; |
---|
3707 | pRefMapLCU = pTRefMapLCU; |
---|
3708 | } |
---|
3709 | else if(bLCURBoundary) |
---|
3710 | { |
---|
3711 | zRefSU = g_auiRasterToZscan[ rRRefSU- numSUInLCUWidth ]; |
---|
3712 | pRefMapLCU = pRRefMapLCU; |
---|
3713 | } |
---|
3714 | else //inside LCU |
---|
3715 | { |
---|
3716 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth +widthSU]; |
---|
3717 | pRefMapLCU = pSliceIDMapLCU; |
---|
3718 | } |
---|
3719 | pRefID = pRefMapLCU + zRefSU; |
---|
3720 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
3721 | } |
---|
3722 | |
---|
3723 | // SGU_BL |
---|
3724 | pbAvail = &(pbAvailBorder[SGU_BL]); |
---|
3725 | if(bPicBBoundary || bPicLBoundary) |
---|
3726 | { |
---|
3727 | *pbAvail = false; |
---|
3728 | } |
---|
3729 | else if (onlyOneSliceInPic) |
---|
3730 | { |
---|
3731 | *pbAvail = true; |
---|
3732 | } |
---|
3733 | else |
---|
3734 | { |
---|
3735 | if(bLCUBBoundary && bLCULBoundary) |
---|
3736 | { |
---|
3737 | zRefSU = g_auiRasterToZscan[numSUInLCUWidth - 1]; |
---|
3738 | pRefMapLCU = pSliceIDMapLCU + ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
3739 | } |
---|
3740 | else if(bLCUBBoundary) |
---|
3741 | { |
---|
3742 | zRefSU = g_auiRasterToZscan[ rBRefSU - 1]; |
---|
3743 | pRefMapLCU = pBRefMapLCU; |
---|
3744 | } |
---|
3745 | else if(bLCULBoundary) |
---|
3746 | { |
---|
3747 | zRefSU = g_auiRasterToZscan[ rLRefSU+ heightSU*numSUInLCUWidth ]; |
---|
3748 | pRefMapLCU = pLRefMapLCU; |
---|
3749 | } |
---|
3750 | else //inside LCU |
---|
3751 | { |
---|
3752 | zRefSU = g_auiRasterToZscan[ rTLSU + heightSU*numSUInLCUWidth -1]; |
---|
3753 | pRefMapLCU = pSliceIDMapLCU; |
---|
3754 | } |
---|
3755 | pRefID = pRefMapLCU + zRefSU; |
---|
3756 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
3757 | } |
---|
3758 | |
---|
3759 | // SGU_BR |
---|
3760 | pbAvail = &(pbAvailBorder[SGU_BR]); |
---|
3761 | if(bPicBBoundary || bPicRBoundary) |
---|
3762 | { |
---|
3763 | *pbAvail = false; |
---|
3764 | } |
---|
3765 | else if (onlyOneSliceInPic) |
---|
3766 | { |
---|
3767 | *pbAvail = true; |
---|
3768 | } |
---|
3769 | else |
---|
3770 | { |
---|
3771 | if(bLCUBBoundary && bLCURBoundary) |
---|
3772 | { |
---|
3773 | zRefSU = 0; |
---|
3774 | pRefMapLCU = pSliceIDMapLCU+ ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
3775 | } |
---|
3776 | else if(bLCUBBoundary) |
---|
3777 | { |
---|
3778 | zRefSU = g_auiRasterToZscan[ rBRefSU + widthSU]; |
---|
3779 | pRefMapLCU = pBRefMapLCU; |
---|
3780 | } |
---|
3781 | else if(bLCURBoundary) |
---|
3782 | { |
---|
3783 | zRefSU = g_auiRasterToZscan[ rRRefSU + (heightSU*numSUInLCUWidth)]; |
---|
3784 | pRefMapLCU = pRRefMapLCU; |
---|
3785 | } |
---|
3786 | else //inside LCU |
---|
3787 | { |
---|
3788 | zRefSU = g_auiRasterToZscan[ rTLSU + (heightSU*numSUInLCUWidth)+ widthSU]; |
---|
3789 | pRefMapLCU = pSliceIDMapLCU; |
---|
3790 | } |
---|
3791 | pRefID = pRefMapLCU + zRefSU; |
---|
3792 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
3793 | } |
---|
3794 | |
---|
3795 | if(bIndependentTileBoundaryEnabled) |
---|
3796 | { |
---|
3797 | //left LCU boundary |
---|
3798 | if(!bPicLBoundary && bLCULBoundary) |
---|
3799 | { |
---|
3800 | if(bLeftTileBoundary) |
---|
3801 | { |
---|
3802 | pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false; |
---|
3803 | } |
---|
3804 | } |
---|
3805 | //right LCU boundary |
---|
3806 | if(!bPicRBoundary && bLCURBoundary) |
---|
3807 | { |
---|
3808 | if(bRightTileBoundary) |
---|
3809 | { |
---|
3810 | pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false; |
---|
3811 | } |
---|
3812 | } |
---|
3813 | //top LCU boundary |
---|
3814 | if(!bPicTBoundary && bLCUTBoundary) |
---|
3815 | { |
---|
3816 | if(bTopTileBoundary) |
---|
3817 | { |
---|
3818 | pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false; |
---|
3819 | } |
---|
3820 | } |
---|
3821 | //down LCU boundary |
---|
3822 | if(!bPicBBoundary && bLCUBBoundary) |
---|
3823 | { |
---|
3824 | if(bDownTileBoundary) |
---|
3825 | { |
---|
3826 | pbAvailBorder[SGU_B] = pbAvailBorder[SGU_BL] = pbAvailBorder[SGU_BR] = false; |
---|
3827 | } |
---|
3828 | } |
---|
3829 | } |
---|
3830 | rSGU.allBordersAvailable = true; |
---|
3831 | for(Int b=0; b< NUM_SGU_BORDER; b++) |
---|
3832 | { |
---|
3833 | if(pbAvailBorder[b] == false) |
---|
3834 | { |
---|
3835 | rSGU.allBordersAvailable = false; |
---|
3836 | break; |
---|
3837 | } |
---|
3838 | } |
---|
3839 | } |
---|
3840 | } |
---|
3841 | |
---|
3842 | |
---|
3843 | //! \} |
---|