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-2012, 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 | #if SKIP_FLAG |
---|
62 | m_skipFlag = NULL; |
---|
63 | #endif |
---|
64 | |
---|
65 | m_pePartSize = NULL; |
---|
66 | m_pePredMode = NULL; |
---|
67 | m_CUTransquantBypass = NULL; |
---|
68 | m_puhWidth = NULL; |
---|
69 | m_puhHeight = NULL; |
---|
70 | m_phQP = NULL; |
---|
71 | m_pbMergeFlag = NULL; |
---|
72 | m_puhMergeIndex = NULL; |
---|
73 | m_puhLumaIntraDir = NULL; |
---|
74 | m_puhChromaIntraDir = NULL; |
---|
75 | m_puhInterDir = NULL; |
---|
76 | m_puhTrIdx = NULL; |
---|
77 | #if !REMOVE_NSQT |
---|
78 | m_nsqtPartIdx = NULL; |
---|
79 | #endif |
---|
80 | m_puhTransformSkip[0] = NULL; |
---|
81 | m_puhTransformSkip[1] = NULL; |
---|
82 | m_puhTransformSkip[2] = NULL; |
---|
83 | m_puhCbf[0] = NULL; |
---|
84 | m_puhCbf[1] = NULL; |
---|
85 | m_puhCbf[2] = NULL; |
---|
86 | m_pcTrCoeffY = NULL; |
---|
87 | m_pcTrCoeffCb = NULL; |
---|
88 | m_pcTrCoeffCr = NULL; |
---|
89 | #if ADAPTIVE_QP_SELECTION |
---|
90 | m_ArlCoeffIsAliasedAllocation = false; |
---|
91 | m_pcArlCoeffY = NULL; |
---|
92 | m_pcArlCoeffCb = NULL; |
---|
93 | m_pcArlCoeffCr = NULL; |
---|
94 | #endif |
---|
95 | |
---|
96 | m_pbIPCMFlag = NULL; |
---|
97 | m_pcIPCMSampleY = NULL; |
---|
98 | m_pcIPCMSampleCb = NULL; |
---|
99 | m_pcIPCMSampleCr = NULL; |
---|
100 | |
---|
101 | m_pcPattern = NULL; |
---|
102 | |
---|
103 | m_pcCUAboveLeft = NULL; |
---|
104 | m_pcCUAboveRight = NULL; |
---|
105 | m_pcCUAbove = NULL; |
---|
106 | m_pcCULeft = NULL; |
---|
107 | |
---|
108 | m_apcCUColocated[0] = NULL; |
---|
109 | m_apcCUColocated[1] = NULL; |
---|
110 | |
---|
111 | m_apiMVPIdx[0] = NULL; |
---|
112 | m_apiMVPIdx[1] = NULL; |
---|
113 | m_apiMVPNum[0] = NULL; |
---|
114 | m_apiMVPNum[1] = NULL; |
---|
115 | |
---|
116 | m_lcuAlfEnabled[0] = false; |
---|
117 | m_lcuAlfEnabled[1] = false; |
---|
118 | m_lcuAlfEnabled[2] = false; |
---|
119 | m_bDecSubCu = false; |
---|
120 | m_uiSliceStartCU = 0; |
---|
121 | m_uiDependentSliceStartCU = 0; |
---|
122 | } |
---|
123 | |
---|
124 | TComDataCU::~TComDataCU() |
---|
125 | { |
---|
126 | } |
---|
127 | |
---|
128 | Void TComDataCU::create(UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
129 | #if ADAPTIVE_QP_SELECTION |
---|
130 | , Bool bGlobalRMARLBuffer |
---|
131 | #endif |
---|
132 | ) |
---|
133 | { |
---|
134 | m_bDecSubCu = bDecSubCu; |
---|
135 | |
---|
136 | m_pcPic = NULL; |
---|
137 | m_pcSlice = NULL; |
---|
138 | m_uiNumPartition = uiNumPartition; |
---|
139 | m_unitSize = unitSize; |
---|
140 | |
---|
141 | if ( !bDecSubCu ) |
---|
142 | { |
---|
143 | m_phQP = (Char* )xMalloc(Char, uiNumPartition); |
---|
144 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
145 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
146 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
147 | |
---|
148 | #if SKIP_FLAG |
---|
149 | m_skipFlag = new Bool[ uiNumPartition ]; |
---|
150 | #endif |
---|
151 | |
---|
152 | m_pePartSize = new Char[ uiNumPartition ]; |
---|
153 | memset( m_pePartSize, SIZE_NONE,uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
154 | m_pePredMode = new Char[ uiNumPartition ]; |
---|
155 | m_CUTransquantBypass = new Bool[ uiNumPartition ]; |
---|
156 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
157 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
158 | m_puhLumaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
159 | m_puhChromaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
160 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
161 | |
---|
162 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
163 | #if !REMOVE_NSQT |
---|
164 | m_nsqtPartIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
165 | #endif |
---|
166 | m_puhTransformSkip[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
167 | m_puhTransformSkip[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
168 | m_puhTransformSkip[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
169 | |
---|
170 | m_puhCbf[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
171 | m_puhCbf[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
172 | m_puhCbf[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
173 | |
---|
174 | m_apiMVPIdx[0] = new Char[ uiNumPartition ]; |
---|
175 | m_apiMVPIdx[1] = new Char[ uiNumPartition ]; |
---|
176 | m_apiMVPNum[0] = new Char[ uiNumPartition ]; |
---|
177 | m_apiMVPNum[1] = new Char[ uiNumPartition ]; |
---|
178 | memset( m_apiMVPIdx[0], -1,uiNumPartition * sizeof( Char ) ); |
---|
179 | memset( m_apiMVPIdx[1], -1,uiNumPartition * sizeof( Char ) ); |
---|
180 | |
---|
181 | m_pcTrCoeffY = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight); |
---|
182 | m_pcTrCoeffCb = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
183 | m_pcTrCoeffCr = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
184 | memset( m_pcTrCoeffY, 0,uiWidth*uiHeight * sizeof( TCoeff ) ); |
---|
185 | memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
---|
186 | memset( m_pcTrCoeffCr, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
---|
187 | #if ADAPTIVE_QP_SELECTION |
---|
188 | if( bGlobalRMARLBuffer ) |
---|
189 | { |
---|
190 | if( m_pcGlbArlCoeffY == NULL ) |
---|
191 | { |
---|
192 | m_pcGlbArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
---|
193 | m_pcGlbArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
194 | m_pcGlbArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
195 | } |
---|
196 | m_pcArlCoeffY = m_pcGlbArlCoeffY; |
---|
197 | m_pcArlCoeffCb = m_pcGlbArlCoeffCb; |
---|
198 | m_pcArlCoeffCr = m_pcGlbArlCoeffCr; |
---|
199 | m_ArlCoeffIsAliasedAllocation = true; |
---|
200 | } |
---|
201 | else |
---|
202 | { |
---|
203 | m_pcArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
---|
204 | m_pcArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
205 | m_pcArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
206 | } |
---|
207 | #endif |
---|
208 | |
---|
209 | m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
210 | m_pcIPCMSampleY = (Pel* )xMalloc(Pel , uiWidth*uiHeight); |
---|
211 | m_pcIPCMSampleCb = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
---|
212 | m_pcIPCMSampleCr = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
---|
213 | |
---|
214 | m_acCUMvField[0].create( uiNumPartition ); |
---|
215 | m_acCUMvField[1].create( uiNumPartition ); |
---|
216 | |
---|
217 | } |
---|
218 | else |
---|
219 | { |
---|
220 | m_acCUMvField[0].setNumPartition(uiNumPartition ); |
---|
221 | m_acCUMvField[1].setNumPartition(uiNumPartition ); |
---|
222 | } |
---|
223 | |
---|
224 | m_uiSliceStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
225 | m_uiDependentSliceStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
226 | |
---|
227 | // create pattern memory |
---|
228 | m_pcPattern = (TComPattern*)xMalloc(TComPattern, 1); |
---|
229 | |
---|
230 | // create motion vector fields |
---|
231 | |
---|
232 | m_pcCUAboveLeft = NULL; |
---|
233 | m_pcCUAboveRight = NULL; |
---|
234 | m_pcCUAbove = NULL; |
---|
235 | m_pcCULeft = NULL; |
---|
236 | |
---|
237 | m_apcCUColocated[0] = NULL; |
---|
238 | m_apcCUColocated[1] = NULL; |
---|
239 | } |
---|
240 | |
---|
241 | Void TComDataCU::destroy() |
---|
242 | { |
---|
243 | m_pcPic = NULL; |
---|
244 | m_pcSlice = NULL; |
---|
245 | |
---|
246 | if ( m_pcPattern ) |
---|
247 | { |
---|
248 | xFree(m_pcPattern); |
---|
249 | m_pcPattern = NULL; |
---|
250 | } |
---|
251 | |
---|
252 | // encoder-side buffer free |
---|
253 | if ( !m_bDecSubCu ) |
---|
254 | { |
---|
255 | if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } |
---|
256 | if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } |
---|
257 | if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } |
---|
258 | if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } |
---|
259 | |
---|
260 | #if SKIP_FLAG |
---|
261 | if ( m_skipFlag ) { delete[] m_skipFlag; m_skipFlag = NULL; } |
---|
262 | #endif |
---|
263 | |
---|
264 | if ( m_pePartSize ) { delete[] m_pePartSize; m_pePartSize = NULL; } |
---|
265 | if ( m_pePredMode ) { delete[] m_pePredMode; m_pePredMode = NULL; } |
---|
266 | if ( m_CUTransquantBypass ) { delete[] m_CUTransquantBypass;m_CUTransquantBypass = NULL; } |
---|
267 | if ( m_puhCbf[0] ) { xFree(m_puhCbf[0]); m_puhCbf[0] = NULL; } |
---|
268 | if ( m_puhCbf[1] ) { xFree(m_puhCbf[1]); m_puhCbf[1] = NULL; } |
---|
269 | if ( m_puhCbf[2] ) { xFree(m_puhCbf[2]); m_puhCbf[2] = NULL; } |
---|
270 | if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } |
---|
271 | if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } |
---|
272 | if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } |
---|
273 | if ( m_puhLumaIntraDir ) { xFree(m_puhLumaIntraDir); m_puhLumaIntraDir = NULL; } |
---|
274 | if ( m_puhChromaIntraDir ) { xFree(m_puhChromaIntraDir); m_puhChromaIntraDir = NULL; } |
---|
275 | if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } |
---|
276 | #if !REMOVE_NSQT |
---|
277 | if ( m_nsqtPartIdx ) { xFree(m_nsqtPartIdx); m_nsqtPartIdx = NULL; } |
---|
278 | #endif |
---|
279 | if ( m_puhTransformSkip[0]) { xFree(m_puhTransformSkip[0]); m_puhTransformSkip[0] = NULL; } |
---|
280 | if ( m_puhTransformSkip[1]) { xFree(m_puhTransformSkip[1]); m_puhTransformSkip[1] = NULL; } |
---|
281 | if ( m_puhTransformSkip[2]) { xFree(m_puhTransformSkip[2]); m_puhTransformSkip[2] = NULL; } |
---|
282 | if ( m_pcTrCoeffY ) { xFree(m_pcTrCoeffY); m_pcTrCoeffY = NULL; } |
---|
283 | if ( m_pcTrCoeffCb ) { xFree(m_pcTrCoeffCb); m_pcTrCoeffCb = NULL; } |
---|
284 | if ( m_pcTrCoeffCr ) { xFree(m_pcTrCoeffCr); m_pcTrCoeffCr = NULL; } |
---|
285 | #if ADAPTIVE_QP_SELECTION |
---|
286 | if (!m_ArlCoeffIsAliasedAllocation) |
---|
287 | { |
---|
288 | xFree(m_pcArlCoeffY); m_pcArlCoeffY = 0; |
---|
289 | xFree(m_pcArlCoeffCb); m_pcArlCoeffCb = 0; |
---|
290 | xFree(m_pcArlCoeffCr); m_pcArlCoeffCr = 0; |
---|
291 | } |
---|
292 | if ( m_pcGlbArlCoeffY ) { xFree(m_pcGlbArlCoeffY); m_pcGlbArlCoeffY = NULL; } |
---|
293 | if ( m_pcGlbArlCoeffCb ) { xFree(m_pcGlbArlCoeffCb); m_pcGlbArlCoeffCb = NULL; } |
---|
294 | if ( m_pcGlbArlCoeffCr ) { xFree(m_pcGlbArlCoeffCr); m_pcGlbArlCoeffCr = NULL; } |
---|
295 | #endif |
---|
296 | if ( m_pbIPCMFlag ) { xFree(m_pbIPCMFlag ); m_pbIPCMFlag = NULL; } |
---|
297 | if ( m_pcIPCMSampleY ) { xFree(m_pcIPCMSampleY); m_pcIPCMSampleY = NULL; } |
---|
298 | if ( m_pcIPCMSampleCb ) { xFree(m_pcIPCMSampleCb); m_pcIPCMSampleCb = NULL; } |
---|
299 | if ( m_pcIPCMSampleCr ) { xFree(m_pcIPCMSampleCr); m_pcIPCMSampleCr = NULL; } |
---|
300 | if ( m_apiMVPIdx[0] ) { delete[] m_apiMVPIdx[0]; m_apiMVPIdx[0] = NULL; } |
---|
301 | if ( m_apiMVPIdx[1] ) { delete[] m_apiMVPIdx[1]; m_apiMVPIdx[1] = NULL; } |
---|
302 | if ( m_apiMVPNum[0] ) { delete[] m_apiMVPNum[0]; m_apiMVPNum[0] = NULL; } |
---|
303 | if ( m_apiMVPNum[1] ) { delete[] m_apiMVPNum[1]; m_apiMVPNum[1] = NULL; } |
---|
304 | |
---|
305 | m_acCUMvField[0].destroy(); |
---|
306 | m_acCUMvField[1].destroy(); |
---|
307 | |
---|
308 | } |
---|
309 | |
---|
310 | m_pcCUAboveLeft = NULL; |
---|
311 | m_pcCUAboveRight = NULL; |
---|
312 | m_pcCUAbove = NULL; |
---|
313 | m_pcCULeft = NULL; |
---|
314 | |
---|
315 | m_apcCUColocated[0] = NULL; |
---|
316 | m_apcCUColocated[1] = NULL; |
---|
317 | |
---|
318 | if( m_uiSliceStartCU ) |
---|
319 | { |
---|
320 | xFree(m_uiSliceStartCU); |
---|
321 | m_uiSliceStartCU=NULL; |
---|
322 | } |
---|
323 | if(m_uiDependentSliceStartCU ) |
---|
324 | { |
---|
325 | xFree(m_uiDependentSliceStartCU); |
---|
326 | m_uiDependentSliceStartCU=NULL; |
---|
327 | } |
---|
328 | } |
---|
329 | |
---|
330 | const NDBFBlockInfo& NDBFBlockInfo::operator= (const NDBFBlockInfo& src) |
---|
331 | { |
---|
332 | this->tileID = src.tileID; |
---|
333 | this->sliceID= src.sliceID; |
---|
334 | this->startSU= src.startSU; |
---|
335 | this->endSU = src.endSU; |
---|
336 | this->widthSU= src.widthSU; |
---|
337 | this->heightSU=src.heightSU; |
---|
338 | this->posX = src.posX; |
---|
339 | this->posY = src.posY; |
---|
340 | this->width = src.width; |
---|
341 | this->height = src.height; |
---|
342 | ::memcpy(this->isBorderAvailable, src.isBorderAvailable, sizeof(Bool)*((Int)NUM_SGU_BORDER)); |
---|
343 | this->allBordersAvailable = src.allBordersAvailable; |
---|
344 | |
---|
345 | return *this; |
---|
346 | } |
---|
347 | |
---|
348 | |
---|
349 | // ==================================================================================================================== |
---|
350 | // Public member functions |
---|
351 | // ==================================================================================================================== |
---|
352 | |
---|
353 | // -------------------------------------------------------------------------------------------------------------------- |
---|
354 | // Initialization |
---|
355 | // -------------------------------------------------------------------------------------------------------------------- |
---|
356 | |
---|
357 | /** |
---|
358 | - initialize top-level CU |
---|
359 | - internal buffers are already created |
---|
360 | - set values before encoding a CU |
---|
361 | . |
---|
362 | \param pcPic picture (TComPic) class pointer |
---|
363 | \param iCUAddr CU address |
---|
364 | */ |
---|
365 | Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr ) |
---|
366 | { |
---|
367 | |
---|
368 | m_pcPic = pcPic; |
---|
369 | m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
370 | m_uiCUAddr = iCUAddr; |
---|
371 | m_uiCUPelX = ( iCUAddr % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth; |
---|
372 | m_uiCUPelY = ( iCUAddr / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight; |
---|
373 | m_uiAbsIdxInLCU = 0; |
---|
374 | m_dTotalCost = MAX_DOUBLE; |
---|
375 | m_uiTotalDistortion = 0; |
---|
376 | m_uiTotalBits = 0; |
---|
377 | m_uiTotalBins = 0; |
---|
378 | m_uiNumPartition = pcPic->getNumPartInCU(); |
---|
379 | m_numSucIPCM = 0; |
---|
380 | m_lastCUSucIPCMFlag = false; |
---|
381 | |
---|
382 | #if SVC_EXTENSION |
---|
383 | m_layerId = pcPic->getLayerId(); |
---|
384 | #endif |
---|
385 | |
---|
386 | for(int i=0; i<pcPic->getNumPartInCU(); i++) |
---|
387 | { |
---|
388 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceCurStartCUAddr()) |
---|
389 | { |
---|
390 | m_uiSliceStartCU[i]=getSlice()->getSliceCurStartCUAddr(); |
---|
391 | } |
---|
392 | else |
---|
393 | { |
---|
394 | m_uiSliceStartCU[i]=pcPic->getCU(getAddr())->m_uiSliceStartCU[i]; |
---|
395 | } |
---|
396 | } |
---|
397 | for(int i=0; i<pcPic->getNumPartInCU(); i++) |
---|
398 | { |
---|
399 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getDependentSliceCurStartCUAddr()) |
---|
400 | { |
---|
401 | m_uiDependentSliceStartCU[i]=getSlice()->getDependentSliceCurStartCUAddr(); |
---|
402 | } |
---|
403 | else |
---|
404 | { |
---|
405 | m_uiDependentSliceStartCU[i]=pcPic->getCU(getAddr())->m_uiDependentSliceStartCU[i]; |
---|
406 | } |
---|
407 | } |
---|
408 | |
---|
409 | Int partStartIdx = getSlice()->getDependentSliceCurStartCUAddr() - pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr) * pcPic->getNumPartInCU(); |
---|
410 | |
---|
411 | Int numElements = min<Int>( partStartIdx, m_uiNumPartition ); |
---|
412 | for ( Int ui = 0; ui < numElements; ui++ ) |
---|
413 | { |
---|
414 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
---|
415 | #if SKIP_FLAG |
---|
416 | m_skipFlag[ui] = pcFrom->getSkipFlag(ui); |
---|
417 | #endif |
---|
418 | m_pePartSize[ui] = pcFrom->getPartitionSize(ui); |
---|
419 | m_pePredMode[ui] = pcFrom->getPredictionMode(ui); |
---|
420 | m_CUTransquantBypass[ui] = pcFrom->getCUTransquantBypass(ui); |
---|
421 | m_puhDepth[ui] = pcFrom->getDepth(ui); |
---|
422 | m_puhWidth [ui] = pcFrom->getWidth(ui); |
---|
423 | m_puhHeight [ui] = pcFrom->getHeight(ui); |
---|
424 | m_puhTrIdx [ui] = pcFrom->getTransformIdx(ui); |
---|
425 | #if !REMOVE_NSQT |
---|
426 | m_nsqtPartIdx[ui] = pcFrom->getNSQTPartIdx(ui); |
---|
427 | #endif |
---|
428 | m_puhTransformSkip[0][ui] = pcFrom->getTransformSkip(ui,TEXT_LUMA); |
---|
429 | m_puhTransformSkip[1][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_U); |
---|
430 | m_puhTransformSkip[2][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_V); |
---|
431 | m_apiMVPIdx[0][ui] = pcFrom->m_apiMVPIdx[0][ui];; |
---|
432 | m_apiMVPIdx[1][ui] = pcFrom->m_apiMVPIdx[1][ui]; |
---|
433 | m_apiMVPNum[0][ui] = pcFrom->m_apiMVPNum[0][ui]; |
---|
434 | m_apiMVPNum[1][ui] = pcFrom->m_apiMVPNum[1][ui]; |
---|
435 | m_phQP[ui]=pcFrom->m_phQP[ui]; |
---|
436 | m_lcuAlfEnabled[0] = pcFrom->m_lcuAlfEnabled[0]; |
---|
437 | m_lcuAlfEnabled[1] = pcFrom->m_lcuAlfEnabled[1]; |
---|
438 | m_lcuAlfEnabled[2] = pcFrom->m_lcuAlfEnabled[2]; |
---|
439 | m_pbMergeFlag[ui]=pcFrom->m_pbMergeFlag[ui]; |
---|
440 | m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui]; |
---|
441 | m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui]; |
---|
442 | m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui]; |
---|
443 | m_puhInterDir[ui]=pcFrom->m_puhInterDir[ui]; |
---|
444 | m_puhCbf[0][ui]=pcFrom->m_puhCbf[0][ui]; |
---|
445 | m_puhCbf[1][ui]=pcFrom->m_puhCbf[1][ui]; |
---|
446 | m_puhCbf[2][ui]=pcFrom->m_puhCbf[2][ui]; |
---|
447 | m_pbIPCMFlag[ui] = pcFrom->m_pbIPCMFlag[ui]; |
---|
448 | } |
---|
449 | |
---|
450 | Int firstElement = max<Int>( partStartIdx, 0 ); |
---|
451 | numElements = m_uiNumPartition - firstElement; |
---|
452 | |
---|
453 | if ( numElements > 0 ) |
---|
454 | { |
---|
455 | #if SKIP_FLAG |
---|
456 | memset( m_skipFlag + firstElement, false, numElements * sizeof( *m_skipFlag ) ); |
---|
457 | #endif |
---|
458 | |
---|
459 | memset( m_pePartSize + firstElement, SIZE_NONE, numElements * sizeof( *m_pePartSize ) ); |
---|
460 | memset( m_pePredMode + firstElement, MODE_NONE, numElements * sizeof( *m_pePredMode ) ); |
---|
461 | memset( m_CUTransquantBypass+ firstElement, false, numElements * sizeof( *m_CUTransquantBypass) ); |
---|
462 | memset( m_puhDepth + firstElement, 0, numElements * sizeof( *m_puhDepth ) ); |
---|
463 | memset( m_puhTrIdx + firstElement, 0, numElements * sizeof( *m_puhTrIdx ) ); |
---|
464 | #if !REMOVE_NSQT |
---|
465 | memset( m_nsqtPartIdx + firstElement, 0, numElements * sizeof( *m_nsqtPartIdx) ); |
---|
466 | #endif |
---|
467 | memset( m_puhTransformSkip[0] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[0]) ); |
---|
468 | memset( m_puhTransformSkip[1] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[1]) ); |
---|
469 | memset( m_puhTransformSkip[2] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[2]) ); |
---|
470 | memset( m_puhWidth + firstElement, g_uiMaxCUWidth, numElements * sizeof( *m_puhWidth ) ); |
---|
471 | memset( m_puhHeight + firstElement, g_uiMaxCUHeight, numElements * sizeof( *m_puhHeight ) ); |
---|
472 | memset( m_apiMVPIdx[0] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[0] ) ); |
---|
473 | memset( m_apiMVPIdx[1] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[1] ) ); |
---|
474 | memset( m_apiMVPNum[0] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[0] ) ); |
---|
475 | memset( m_apiMVPNum[1] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[1] ) ); |
---|
476 | memset( m_phQP + firstElement, getSlice()->getSliceQp(), numElements * sizeof( *m_phQP ) ); |
---|
477 | m_lcuAlfEnabled[0] = m_lcuAlfEnabled[1] = m_lcuAlfEnabled[2] = false; |
---|
478 | memset( m_pbMergeFlag + firstElement, false, numElements * sizeof( *m_pbMergeFlag ) ); |
---|
479 | memset( m_puhMergeIndex + firstElement, 0, numElements * sizeof( *m_puhMergeIndex ) ); |
---|
480 | memset( m_puhLumaIntraDir + firstElement, DC_IDX, numElements * sizeof( *m_puhLumaIntraDir ) ); |
---|
481 | memset( m_puhChromaIntraDir + firstElement, 0, numElements * sizeof( *m_puhChromaIntraDir ) ); |
---|
482 | memset( m_puhInterDir + firstElement, 0, numElements * sizeof( *m_puhInterDir ) ); |
---|
483 | memset( m_puhCbf[0] + firstElement, 0, numElements * sizeof( *m_puhCbf[0] ) ); |
---|
484 | memset( m_puhCbf[1] + firstElement, 0, numElements * sizeof( *m_puhCbf[1] ) ); |
---|
485 | memset( m_puhCbf[2] + firstElement, 0, numElements * sizeof( *m_puhCbf[2] ) ); |
---|
486 | memset( m_pbIPCMFlag + firstElement, false, numElements * sizeof( *m_pbIPCMFlag ) ); |
---|
487 | } |
---|
488 | |
---|
489 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight; |
---|
490 | if ( 0 >= partStartIdx ) |
---|
491 | { |
---|
492 | m_acCUMvField[0].clearMvField(); |
---|
493 | m_acCUMvField[1].clearMvField(); |
---|
494 | memset( m_pcTrCoeffY , 0, sizeof( TCoeff ) * uiTmp ); |
---|
495 | #if ADAPTIVE_QP_SELECTION |
---|
496 | memset( m_pcArlCoeffY , 0, sizeof( Int ) * uiTmp ); |
---|
497 | #endif |
---|
498 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
---|
499 | uiTmp >>= 2; |
---|
500 | memset( m_pcTrCoeffCb, 0, sizeof( TCoeff ) * uiTmp ); |
---|
501 | memset( m_pcTrCoeffCr, 0, sizeof( TCoeff ) * uiTmp ); |
---|
502 | #if ADAPTIVE_QP_SELECTION |
---|
503 | memset( m_pcArlCoeffCb, 0, sizeof( Int ) * uiTmp ); |
---|
504 | memset( m_pcArlCoeffCr, 0, sizeof( Int ) * uiTmp ); |
---|
505 | #endif |
---|
506 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
---|
507 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
---|
508 | } |
---|
509 | else |
---|
510 | { |
---|
511 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
---|
512 | m_acCUMvField[0].copyFrom(&pcFrom->m_acCUMvField[0],m_uiNumPartition,0); |
---|
513 | m_acCUMvField[1].copyFrom(&pcFrom->m_acCUMvField[1],m_uiNumPartition,0); |
---|
514 | for(int i=0; i<uiTmp; i++) |
---|
515 | { |
---|
516 | m_pcTrCoeffY[i]=pcFrom->m_pcTrCoeffY[i]; |
---|
517 | #if ADAPTIVE_QP_SELECTION |
---|
518 | m_pcArlCoeffY[i]=pcFrom->m_pcArlCoeffY[i]; |
---|
519 | #endif |
---|
520 | m_pcIPCMSampleY[i]=pcFrom->m_pcIPCMSampleY[i]; |
---|
521 | } |
---|
522 | for(int i=0; i<(uiTmp>>2); i++) |
---|
523 | { |
---|
524 | m_pcTrCoeffCb[i]=pcFrom->m_pcTrCoeffCb[i]; |
---|
525 | m_pcTrCoeffCr[i]=pcFrom->m_pcTrCoeffCr[i]; |
---|
526 | #if ADAPTIVE_QP_SELECTION |
---|
527 | m_pcArlCoeffCb[i]=pcFrom->m_pcArlCoeffCb[i]; |
---|
528 | m_pcArlCoeffCr[i]=pcFrom->m_pcArlCoeffCr[i]; |
---|
529 | #endif |
---|
530 | m_pcIPCMSampleCb[i]=pcFrom->m_pcIPCMSampleCb[i]; |
---|
531 | m_pcIPCMSampleCr[i]=pcFrom->m_pcIPCMSampleCr[i]; |
---|
532 | } |
---|
533 | } |
---|
534 | |
---|
535 | // Setting neighbor CU |
---|
536 | m_pcCULeft = NULL; |
---|
537 | m_pcCUAbove = NULL; |
---|
538 | m_pcCUAboveLeft = NULL; |
---|
539 | m_pcCUAboveRight = NULL; |
---|
540 | |
---|
541 | m_apcCUColocated[0] = NULL; |
---|
542 | m_apcCUColocated[1] = NULL; |
---|
543 | |
---|
544 | UInt uiWidthInCU = pcPic->getFrameWidthInCU(); |
---|
545 | if ( m_uiCUAddr % uiWidthInCU ) |
---|
546 | { |
---|
547 | m_pcCULeft = pcPic->getCU( m_uiCUAddr - 1 ); |
---|
548 | } |
---|
549 | |
---|
550 | if ( m_uiCUAddr / uiWidthInCU ) |
---|
551 | { |
---|
552 | m_pcCUAbove = pcPic->getCU( m_uiCUAddr - uiWidthInCU ); |
---|
553 | } |
---|
554 | |
---|
555 | if ( m_pcCULeft && m_pcCUAbove ) |
---|
556 | { |
---|
557 | m_pcCUAboveLeft = pcPic->getCU( m_uiCUAddr - uiWidthInCU - 1 ); |
---|
558 | } |
---|
559 | |
---|
560 | if ( m_pcCUAbove && ( (m_uiCUAddr%uiWidthInCU) < (uiWidthInCU-1) ) ) |
---|
561 | { |
---|
562 | m_pcCUAboveRight = pcPic->getCU( m_uiCUAddr - uiWidthInCU + 1 ); |
---|
563 | } |
---|
564 | |
---|
565 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) |
---|
566 | { |
---|
567 | m_apcCUColocated[0] = getSlice()->getRefPic( REF_PIC_LIST_0, 0)->getCU( m_uiCUAddr ); |
---|
568 | } |
---|
569 | |
---|
570 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) |
---|
571 | { |
---|
572 | m_apcCUColocated[1] = getSlice()->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr ); |
---|
573 | } |
---|
574 | } |
---|
575 | |
---|
576 | /** initialize prediction data with enabling sub-LCU-level delta QP |
---|
577 | *\param uiDepth depth of the current CU |
---|
578 | *\param qp qp for the current CU |
---|
579 | *- set CU width and CU height according to depth |
---|
580 | *- set qp value according to input qp |
---|
581 | *- set last-coded qp value according to input last-coded qp |
---|
582 | */ |
---|
583 | Void TComDataCU::initEstData( UInt uiDepth, Int qp ) |
---|
584 | { |
---|
585 | m_dTotalCost = MAX_DOUBLE; |
---|
586 | m_uiTotalDistortion = 0; |
---|
587 | m_uiTotalBits = 0; |
---|
588 | m_uiTotalBins = 0; |
---|
589 | |
---|
590 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
591 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
592 | m_lcuAlfEnabled[0] = m_lcuAlfEnabled[1] = m_lcuAlfEnabled[2] = false; |
---|
593 | |
---|
594 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
595 | { |
---|
596 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui >= getSlice()->getDependentSliceCurStartCUAddr()) |
---|
597 | { |
---|
598 | m_apiMVPIdx[0][ui] = -1; |
---|
599 | m_apiMVPIdx[1][ui] = -1; |
---|
600 | m_apiMVPNum[0][ui] = -1; |
---|
601 | m_apiMVPNum[1][ui] = -1; |
---|
602 | m_puhDepth [ui] = uiDepth; |
---|
603 | m_puhWidth [ui] = uhWidth; |
---|
604 | m_puhHeight [ui] = uhHeight; |
---|
605 | m_puhTrIdx [ui] = 0; |
---|
606 | #if !REMOVE_NSQT |
---|
607 | m_nsqtPartIdx[ui] = 0; |
---|
608 | #endif |
---|
609 | m_puhTransformSkip[0][ui] = 0; |
---|
610 | m_puhTransformSkip[1][ui] = 0; |
---|
611 | m_puhTransformSkip[2][ui] = 0; |
---|
612 | #if SKIP_FLAG |
---|
613 | m_skipFlag[ui] = false; |
---|
614 | #endif |
---|
615 | m_pePartSize[ui] = SIZE_NONE; |
---|
616 | m_pePredMode[ui] = MODE_NONE; |
---|
617 | m_CUTransquantBypass[ui] = false; |
---|
618 | m_pbIPCMFlag[ui] = 0; |
---|
619 | m_phQP[ui] = qp; |
---|
620 | m_pbMergeFlag[ui] = 0; |
---|
621 | m_puhMergeIndex[ui] = 0; |
---|
622 | m_puhLumaIntraDir[ui] = DC_IDX; |
---|
623 | m_puhChromaIntraDir[ui] = 0; |
---|
624 | m_puhInterDir[ui] = 0; |
---|
625 | m_puhCbf[0][ui] = 0; |
---|
626 | m_puhCbf[1][ui] = 0; |
---|
627 | m_puhCbf[2][ui] = 0; |
---|
628 | } |
---|
629 | } |
---|
630 | |
---|
631 | UInt uiTmp = uhWidth*uhHeight; |
---|
632 | |
---|
633 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU >= getSlice()->getDependentSliceCurStartCUAddr()) |
---|
634 | { |
---|
635 | m_acCUMvField[0].clearMvField(); |
---|
636 | m_acCUMvField[1].clearMvField(); |
---|
637 | uiTmp = uhWidth*uhHeight; |
---|
638 | |
---|
639 | memset( m_pcTrCoeffY, 0, uiTmp * sizeof( *m_pcTrCoeffY ) ); |
---|
640 | #if ADAPTIVE_QP_SELECTION |
---|
641 | memset( m_pcArlCoeffY , 0, uiTmp * sizeof( *m_pcArlCoeffY ) ); |
---|
642 | #endif |
---|
643 | memset( m_pcIPCMSampleY, 0, uiTmp * sizeof( *m_pcIPCMSampleY ) ); |
---|
644 | |
---|
645 | uiTmp>>=2; |
---|
646 | memset( m_pcTrCoeffCb, 0, uiTmp * sizeof( *m_pcTrCoeffCb ) ); |
---|
647 | memset( m_pcTrCoeffCr, 0, uiTmp * sizeof( *m_pcTrCoeffCr ) ); |
---|
648 | #if ADAPTIVE_QP_SELECTION |
---|
649 | memset( m_pcArlCoeffCb, 0, uiTmp * sizeof( *m_pcArlCoeffCb ) ); |
---|
650 | memset( m_pcArlCoeffCr, 0, uiTmp * sizeof( *m_pcArlCoeffCr ) ); |
---|
651 | #endif |
---|
652 | memset( m_pcIPCMSampleCb, 0, uiTmp * sizeof( *m_pcIPCMSampleCb ) ); |
---|
653 | memset( m_pcIPCMSampleCr, 0, uiTmp * sizeof( *m_pcIPCMSampleCr ) ); |
---|
654 | } |
---|
655 | } |
---|
656 | |
---|
657 | |
---|
658 | // initialize Sub partition |
---|
659 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ) |
---|
660 | { |
---|
661 | assert( uiPartUnitIdx<4 ); |
---|
662 | |
---|
663 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
---|
664 | |
---|
665 | m_pcPic = pcCU->getPic(); |
---|
666 | m_pcSlice = m_pcPic->getSlice(m_pcPic->getCurrSliceIdx()); |
---|
667 | m_uiCUAddr = pcCU->getAddr(); |
---|
668 | m_uiAbsIdxInLCU = pcCU->getZorderIdxInCU() + uiPartOffset; |
---|
669 | |
---|
670 | m_uiCUPelX = pcCU->getCUPelX() + ( g_uiMaxCUWidth>>uiDepth )*( uiPartUnitIdx & 1 ); |
---|
671 | m_uiCUPelY = pcCU->getCUPelY() + ( g_uiMaxCUHeight>>uiDepth )*( uiPartUnitIdx >> 1 ); |
---|
672 | |
---|
673 | m_dTotalCost = MAX_DOUBLE; |
---|
674 | m_uiTotalDistortion = 0; |
---|
675 | m_uiTotalBits = 0; |
---|
676 | m_uiTotalBins = 0; |
---|
677 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
---|
678 | |
---|
679 | m_numSucIPCM = 0; |
---|
680 | m_lastCUSucIPCMFlag = false; |
---|
681 | |
---|
682 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
683 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
684 | |
---|
685 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
686 | memset( m_phQP, qp, sizeInChar ); |
---|
687 | |
---|
688 | m_lcuAlfEnabled[0] = pcCU->m_lcuAlfEnabled[0]; |
---|
689 | m_lcuAlfEnabled[1] = pcCU->m_lcuAlfEnabled[1]; |
---|
690 | m_lcuAlfEnabled[2] = pcCU->m_lcuAlfEnabled[2]; |
---|
691 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
692 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
693 | memset( m_puhLumaIntraDir, DC_IDX, iSizeInUchar ); |
---|
694 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
---|
695 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
696 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
697 | memset( m_puhTransformSkip[0], 0, iSizeInUchar ); |
---|
698 | memset( m_puhTransformSkip[1], 0, iSizeInUchar ); |
---|
699 | memset( m_puhTransformSkip[2], 0, iSizeInUchar ); |
---|
700 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
---|
701 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
---|
702 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
---|
703 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
---|
704 | |
---|
705 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
706 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
707 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
708 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
709 | memset( m_pbIPCMFlag, 0, iSizeInBool ); |
---|
710 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
711 | { |
---|
712 | #if SKIP_FLAG |
---|
713 | m_skipFlag[ui] = false; |
---|
714 | #endif |
---|
715 | m_pePartSize[ui] = SIZE_NONE; |
---|
716 | m_pePredMode[ui] = MODE_NONE; |
---|
717 | m_CUTransquantBypass[ui] = false; |
---|
718 | m_apiMVPIdx[0][ui] = -1; |
---|
719 | m_apiMVPIdx[1][ui] = -1; |
---|
720 | m_apiMVPNum[0][ui] = -1; |
---|
721 | m_apiMVPNum[1][ui] = -1; |
---|
722 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui<getSlice()->getDependentSliceCurStartCUAddr()) |
---|
723 | { |
---|
724 | m_apiMVPIdx[0][ui] = pcCU->m_apiMVPIdx[0][uiPartOffset+ui]; |
---|
725 | m_apiMVPIdx[1][ui] = pcCU->m_apiMVPIdx[1][uiPartOffset+ui];; |
---|
726 | m_apiMVPNum[0][ui] = pcCU->m_apiMVPNum[0][uiPartOffset+ui];; |
---|
727 | m_apiMVPNum[1][ui] = pcCU->m_apiMVPNum[1][uiPartOffset+ui];; |
---|
728 | m_puhDepth [ui] = pcCU->getDepth(uiPartOffset+ui); |
---|
729 | m_puhWidth [ui] = pcCU->getWidth(uiPartOffset+ui); |
---|
730 | m_puhHeight [ui] = pcCU->getHeight(uiPartOffset+ui); |
---|
731 | m_puhTrIdx [ui] = pcCU->getTransformIdx(uiPartOffset+ui); |
---|
732 | #if !REMOVE_NSQT |
---|
733 | m_nsqtPartIdx[ui] = pcCU->getNSQTPartIdx(uiPartOffset+ui); |
---|
734 | #endif |
---|
735 | m_puhTransformSkip[0][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_LUMA); |
---|
736 | m_puhTransformSkip[1][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_U); |
---|
737 | m_puhTransformSkip[2][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_V); |
---|
738 | #if SKIP_FLAG |
---|
739 | m_skipFlag[ui] = pcCU->getSkipFlag(uiPartOffset+ui); |
---|
740 | #endif |
---|
741 | m_pePartSize[ui] = pcCU->getPartitionSize(uiPartOffset+ui); |
---|
742 | m_pePredMode[ui] = pcCU->getPredictionMode(uiPartOffset+ui); |
---|
743 | m_CUTransquantBypass[ui] = pcCU->getCUTransquantBypass(uiPartOffset+ui); |
---|
744 | m_pbIPCMFlag[ui]=pcCU->m_pbIPCMFlag[uiPartOffset+ui]; |
---|
745 | m_phQP[ui] = pcCU->m_phQP[uiPartOffset+ui]; |
---|
746 | m_pbMergeFlag[ui]=pcCU->m_pbMergeFlag[uiPartOffset+ui]; |
---|
747 | m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui]; |
---|
748 | m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui]; |
---|
749 | m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui]; |
---|
750 | m_puhInterDir[ui]=pcCU->m_puhInterDir[uiPartOffset+ui]; |
---|
751 | m_puhCbf[0][ui]=pcCU->m_puhCbf[0][uiPartOffset+ui]; |
---|
752 | m_puhCbf[1][ui]=pcCU->m_puhCbf[1][uiPartOffset+ui]; |
---|
753 | m_puhCbf[2][ui]=pcCU->m_puhCbf[2][uiPartOffset+ui]; |
---|
754 | |
---|
755 | } |
---|
756 | } |
---|
757 | UInt uiTmp = uhWidth*uhHeight; |
---|
758 | memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); |
---|
759 | #if ADAPTIVE_QP_SELECTION |
---|
760 | memset( m_pcArlCoeffY , 0, sizeof(Int)*uiTmp ); |
---|
761 | #endif |
---|
762 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
---|
763 | uiTmp >>= 2; |
---|
764 | memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); |
---|
765 | memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); |
---|
766 | #if ADAPTIVE_QP_SELECTION |
---|
767 | memset( m_pcArlCoeffCb, 0, sizeof(Int)*uiTmp ); |
---|
768 | memset( m_pcArlCoeffCr, 0, sizeof(Int)*uiTmp ); |
---|
769 | #endif |
---|
770 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
---|
771 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
---|
772 | m_acCUMvField[0].clearMvField(); |
---|
773 | m_acCUMvField[1].clearMvField(); |
---|
774 | |
---|
775 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU<getSlice()->getDependentSliceCurStartCUAddr()) |
---|
776 | { |
---|
777 | // Part of this CU contains data from an older slice. Now copy in that data. |
---|
778 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
779 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
780 | TComDataCU * bigCU = getPic()->getCU(getAddr()); |
---|
781 | Int minui = uiPartOffset; |
---|
782 | minui = -minui; |
---|
783 | pcCU->m_acCUMvField[0].copyTo(&m_acCUMvField[0],minui,uiPartOffset,m_uiNumPartition); |
---|
784 | pcCU->m_acCUMvField[1].copyTo(&m_acCUMvField[1],minui,uiPartOffset,m_uiNumPartition); |
---|
785 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*m_uiAbsIdxInLCU/pcCU->getPic()->getNumPartInCU(); |
---|
786 | uiTmp = uhWidth*uhHeight; |
---|
787 | for(int i=0; i<uiTmp; i++) |
---|
788 | { |
---|
789 | m_pcTrCoeffY[i]=bigCU->m_pcTrCoeffY[uiCoffOffset+i]; |
---|
790 | #if ADAPTIVE_QP_SELECTION |
---|
791 | m_pcArlCoeffY[i]=bigCU->m_pcArlCoeffY[uiCoffOffset+i]; |
---|
792 | #endif |
---|
793 | m_pcIPCMSampleY[i]=bigCU->m_pcIPCMSampleY[uiCoffOffset+i]; |
---|
794 | } |
---|
795 | uiTmp>>=2; |
---|
796 | uiCoffOffset>>=2; |
---|
797 | for(int i=0; i<uiTmp; i++) |
---|
798 | { |
---|
799 | m_pcTrCoeffCr[i]=bigCU->m_pcTrCoeffCr[uiCoffOffset+i]; |
---|
800 | m_pcTrCoeffCb[i]=bigCU->m_pcTrCoeffCb[uiCoffOffset+i]; |
---|
801 | #if ADAPTIVE_QP_SELECTION |
---|
802 | m_pcArlCoeffCr[i]=bigCU->m_pcArlCoeffCr[uiCoffOffset+i]; |
---|
803 | m_pcArlCoeffCb[i]=bigCU->m_pcArlCoeffCb[uiCoffOffset+i]; |
---|
804 | #endif |
---|
805 | m_pcIPCMSampleCb[i]=bigCU->m_pcIPCMSampleCb[uiCoffOffset+i]; |
---|
806 | m_pcIPCMSampleCr[i]=bigCU->m_pcIPCMSampleCr[uiCoffOffset+i]; |
---|
807 | } |
---|
808 | } |
---|
809 | |
---|
810 | m_pcCULeft = pcCU->getCULeft(); |
---|
811 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
812 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
813 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
814 | |
---|
815 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
816 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
817 | memcpy(m_uiSliceStartCU,pcCU->m_uiSliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
---|
818 | memcpy(m_uiDependentSliceStartCU,pcCU->m_uiDependentSliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
---|
819 | } |
---|
820 | |
---|
821 | Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
822 | { |
---|
823 | UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); |
---|
824 | UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
825 | |
---|
826 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
827 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
828 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); |
---|
829 | memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); |
---|
830 | memset( m_puhHeight + uiAbsPartIdx, uhHeight, uiSizeInUchar ); |
---|
831 | } |
---|
832 | |
---|
833 | // -------------------------------------------------------------------------------------------------------------------- |
---|
834 | // Copy |
---|
835 | // -------------------------------------------------------------------------------------------------------------------- |
---|
836 | |
---|
837 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
838 | { |
---|
839 | UInt uiPart = uiAbsPartIdx; |
---|
840 | |
---|
841 | m_pcPic = pcCU->getPic(); |
---|
842 | m_pcSlice = pcCU->getSlice(); |
---|
843 | m_uiCUAddr = pcCU->getAddr(); |
---|
844 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
845 | |
---|
846 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
847 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
848 | |
---|
849 | UInt uiWidth = g_uiMaxCUWidth >> uiDepth; |
---|
850 | UInt uiHeight = g_uiMaxCUHeight >> uiDepth; |
---|
851 | |
---|
852 | #if SKIP_FLAG |
---|
853 | m_skipFlag=pcCU->getSkipFlag() + uiPart; |
---|
854 | #endif |
---|
855 | |
---|
856 | m_phQP=pcCU->getQP() + uiPart; |
---|
857 | m_pePartSize = pcCU->getPartitionSize() + uiPart; |
---|
858 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
---|
859 | m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; |
---|
860 | |
---|
861 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
---|
862 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
---|
863 | |
---|
864 | m_puhLumaIntraDir = pcCU->getLumaIntraDir() + uiPart; |
---|
865 | m_puhChromaIntraDir = pcCU->getChromaIntraDir() + uiPart; |
---|
866 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
---|
867 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
---|
868 | #if !REMOVE_NSQT |
---|
869 | m_nsqtPartIdx = pcCU->getNSQTPartIdx() + uiPart; |
---|
870 | #endif |
---|
871 | m_puhTransformSkip[0] = pcCU->getTransformSkip(TEXT_LUMA) + uiPart; |
---|
872 | m_puhTransformSkip[1] = pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPart; |
---|
873 | m_puhTransformSkip[2] = pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPart; |
---|
874 | |
---|
875 | m_puhCbf[0]= pcCU->getCbf(TEXT_LUMA) + uiPart; |
---|
876 | m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U) + uiPart; |
---|
877 | m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; |
---|
878 | |
---|
879 | m_puhDepth=pcCU->getDepth() + uiPart; |
---|
880 | m_puhWidth=pcCU->getWidth() + uiPart; |
---|
881 | m_puhHeight=pcCU->getHeight() + uiPart; |
---|
882 | |
---|
883 | m_apiMVPIdx[0]=pcCU->getMVPIdx(REF_PIC_LIST_0) + uiPart; |
---|
884 | m_apiMVPIdx[1]=pcCU->getMVPIdx(REF_PIC_LIST_1) + uiPart; |
---|
885 | m_apiMVPNum[0]=pcCU->getMVPNum(REF_PIC_LIST_0) + uiPart; |
---|
886 | m_apiMVPNum[1]=pcCU->getMVPNum(REF_PIC_LIST_1) + uiPart; |
---|
887 | |
---|
888 | m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; |
---|
889 | |
---|
890 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
891 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
892 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
893 | m_pcCULeft = pcCU->getCULeft(); |
---|
894 | |
---|
895 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
896 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
897 | |
---|
898 | UInt uiTmp = uiWidth*uiHeight; |
---|
899 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
900 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
901 | |
---|
902 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartInCU(); |
---|
903 | |
---|
904 | m_pcTrCoeffY = pcCU->getCoeffY() + uiCoffOffset; |
---|
905 | #if ADAPTIVE_QP_SELECTION |
---|
906 | m_pcArlCoeffY= pcCU->getArlCoeffY() + uiCoffOffset; |
---|
907 | #endif |
---|
908 | m_pcIPCMSampleY = pcCU->getPCMSampleY() + uiCoffOffset; |
---|
909 | |
---|
910 | uiTmp >>= 2; |
---|
911 | uiCoffOffset >>=2; |
---|
912 | m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset; |
---|
913 | m_pcTrCoeffCr=pcCU->getCoeffCr() + uiCoffOffset; |
---|
914 | #if ADAPTIVE_QP_SELECTION |
---|
915 | m_pcArlCoeffCb=pcCU->getArlCoeffCb() + uiCoffOffset; |
---|
916 | m_pcArlCoeffCr=pcCU->getArlCoeffCr() + uiCoffOffset; |
---|
917 | #endif |
---|
918 | m_pcIPCMSampleCb = pcCU->getPCMSampleCb() + uiCoffOffset; |
---|
919 | m_pcIPCMSampleCr = pcCU->getPCMSampleCr() + uiCoffOffset; |
---|
920 | |
---|
921 | m_acCUMvField[0].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_0), uiPart ); |
---|
922 | m_acCUMvField[1].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_1), uiPart ); |
---|
923 | memcpy(m_uiSliceStartCU,pcCU->m_uiSliceStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
---|
924 | memcpy(m_uiDependentSliceStartCU,pcCU->m_uiDependentSliceStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
---|
925 | } |
---|
926 | |
---|
927 | // Copy inter prediction info from the biggest CU |
---|
928 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList ) |
---|
929 | { |
---|
930 | m_pcPic = pcCU->getPic(); |
---|
931 | m_pcSlice = pcCU->getSlice(); |
---|
932 | m_uiCUAddr = pcCU->getAddr(); |
---|
933 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
934 | |
---|
935 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
936 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() ); |
---|
937 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInWidth() ); |
---|
938 | |
---|
939 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
940 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
941 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
942 | m_pcCULeft = pcCU->getCULeft(); |
---|
943 | |
---|
944 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
945 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
946 | |
---|
947 | #if SKIP_FLAG |
---|
948 | m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; |
---|
949 | #endif |
---|
950 | |
---|
951 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
---|
952 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
---|
953 | m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; |
---|
954 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
---|
955 | |
---|
956 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
957 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
958 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
959 | |
---|
960 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
961 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
962 | |
---|
963 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
---|
964 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
---|
965 | |
---|
966 | m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); |
---|
967 | |
---|
968 | memcpy(m_uiSliceStartCU,pcCU->m_uiSliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
---|
969 | memcpy(m_uiDependentSliceStartCU,pcCU->m_uiDependentSliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
---|
970 | } |
---|
971 | |
---|
972 | // Copy small CU to bigger CU. |
---|
973 | // One of quarter parts overwritten by predicted sub part. |
---|
974 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
975 | { |
---|
976 | assert( uiPartUnitIdx<4 ); |
---|
977 | |
---|
978 | m_dTotalCost += pcCU->getTotalCost(); |
---|
979 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
---|
980 | m_uiTotalBits += pcCU->getTotalBits(); |
---|
981 | |
---|
982 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
---|
983 | |
---|
984 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
---|
985 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
986 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
987 | |
---|
988 | Int sizeInChar = sizeof( Char ) * uiNumPartition; |
---|
989 | #if SKIP_FLAG |
---|
990 | memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); |
---|
991 | #endif |
---|
992 | memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); |
---|
993 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); |
---|
994 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); |
---|
995 | memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); |
---|
996 | m_lcuAlfEnabled[0] = pcCU->m_lcuAlfEnabled[0]; |
---|
997 | m_lcuAlfEnabled[1] = pcCU->m_lcuAlfEnabled[1]; |
---|
998 | m_lcuAlfEnabled[2] = pcCU->m_lcuAlfEnabled[2]; |
---|
999 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
---|
1000 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
---|
1001 | memcpy( m_puhLumaIntraDir + uiOffset, pcCU->getLumaIntraDir(), iSizeInUchar ); |
---|
1002 | memcpy( m_puhChromaIntraDir + uiOffset, pcCU->getChromaIntraDir(), iSizeInUchar ); |
---|
1003 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
---|
1004 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
---|
1005 | #if !REMOVE_NSQT |
---|
1006 | memcpy( m_nsqtPartIdx + uiOffset, pcCU->getNSQTPartIdx(), iSizeInUchar ); |
---|
1007 | #endif |
---|
1008 | memcpy( m_puhTransformSkip[0] + uiOffset, pcCU->getTransformSkip(TEXT_LUMA), iSizeInUchar ); |
---|
1009 | memcpy( m_puhTransformSkip[1] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_U), iSizeInUchar ); |
---|
1010 | memcpy( m_puhTransformSkip[2] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_V), iSizeInUchar ); |
---|
1011 | |
---|
1012 | memcpy( m_puhCbf[0] + uiOffset, pcCU->getCbf(TEXT_LUMA) , iSizeInUchar ); |
---|
1013 | memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar ); |
---|
1014 | memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); |
---|
1015 | |
---|
1016 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
---|
1017 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
---|
1018 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
---|
1019 | |
---|
1020 | memcpy( m_apiMVPIdx[0] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_0), iSizeInUchar ); |
---|
1021 | memcpy( m_apiMVPIdx[1] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_1), iSizeInUchar ); |
---|
1022 | memcpy( m_apiMVPNum[0] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_0), iSizeInUchar ); |
---|
1023 | memcpy( m_apiMVPNum[1] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_1), iSizeInUchar ); |
---|
1024 | |
---|
1025 | memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); |
---|
1026 | |
---|
1027 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
1028 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
1029 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
1030 | m_pcCULeft = pcCU->getCULeft(); |
---|
1031 | |
---|
1032 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
1033 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
1034 | |
---|
1035 | m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
1036 | m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
1037 | |
---|
1038 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); |
---|
1039 | UInt uiTmp2 = uiPartUnitIdx*uiTmp; |
---|
1040 | memcpy( m_pcTrCoeffY + uiTmp2, pcCU->getCoeffY(), sizeof(TCoeff)*uiTmp ); |
---|
1041 | #if ADAPTIVE_QP_SELECTION |
---|
1042 | memcpy( m_pcArlCoeffY + uiTmp2, pcCU->getArlCoeffY(), sizeof(Int)*uiTmp ); |
---|
1043 | #endif |
---|
1044 | memcpy( m_pcIPCMSampleY + uiTmp2 , pcCU->getPCMSampleY(), sizeof(Pel) * uiTmp ); |
---|
1045 | |
---|
1046 | uiTmp >>= 2; uiTmp2>>= 2; |
---|
1047 | memcpy( m_pcTrCoeffCb + uiTmp2, pcCU->getCoeffCb(), sizeof(TCoeff)*uiTmp ); |
---|
1048 | memcpy( m_pcTrCoeffCr + uiTmp2, pcCU->getCoeffCr(), sizeof(TCoeff)*uiTmp ); |
---|
1049 | #if ADAPTIVE_QP_SELECTION |
---|
1050 | memcpy( m_pcArlCoeffCb + uiTmp2, pcCU->getArlCoeffCb(), sizeof(Int)*uiTmp ); |
---|
1051 | memcpy( m_pcArlCoeffCr + uiTmp2, pcCU->getArlCoeffCr(), sizeof(Int)*uiTmp ); |
---|
1052 | #endif |
---|
1053 | memcpy( m_pcIPCMSampleCb + uiTmp2 , pcCU->getPCMSampleCb(), sizeof(Pel) * uiTmp ); |
---|
1054 | memcpy( m_pcIPCMSampleCr + uiTmp2 , pcCU->getPCMSampleCr(), sizeof(Pel) * uiTmp ); |
---|
1055 | m_uiTotalBins += pcCU->getTotalBins(); |
---|
1056 | memcpy( m_uiSliceStartCU + uiOffset, pcCU->m_uiSliceStartCU, sizeof( UInt ) * uiNumPartition ); |
---|
1057 | memcpy( m_uiDependentSliceStartCU + uiOffset, pcCU->m_uiDependentSliceStartCU, sizeof( UInt ) * uiNumPartition ); |
---|
1058 | } |
---|
1059 | |
---|
1060 | // Copy current predicted part to a CU in picture. |
---|
1061 | // It is used to predict for next part |
---|
1062 | Void TComDataCU::copyToPic( UChar uhDepth ) |
---|
1063 | { |
---|
1064 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
1065 | |
---|
1066 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
1067 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
1068 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
1069 | |
---|
1070 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
1071 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
1072 | |
---|
1073 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
1074 | |
---|
1075 | #if SKIP_FLAG |
---|
1076 | memcpy( rpcCU->getSkipFlag() + m_uiAbsIdxInLCU, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); |
---|
1077 | #endif |
---|
1078 | |
---|
1079 | memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, sizeInChar ); |
---|
1080 | |
---|
1081 | memcpy( rpcCU->getPartitionSize() + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); |
---|
1082 | memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); |
---|
1083 | memcpy( rpcCU->getCUTransquantBypass()+ m_uiAbsIdxInLCU, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); |
---|
1084 | rpcCU->m_lcuAlfEnabled[0] = m_lcuAlfEnabled[0]; |
---|
1085 | rpcCU->m_lcuAlfEnabled[1] = m_lcuAlfEnabled[1]; |
---|
1086 | rpcCU->m_lcuAlfEnabled[2] = m_lcuAlfEnabled[2]; |
---|
1087 | memcpy( rpcCU->getMergeFlag() + m_uiAbsIdxInLCU, m_pbMergeFlag, iSizeInBool ); |
---|
1088 | memcpy( rpcCU->getMergeIndex() + m_uiAbsIdxInLCU, m_puhMergeIndex, iSizeInUchar ); |
---|
1089 | memcpy( rpcCU->getLumaIntraDir() + m_uiAbsIdxInLCU, m_puhLumaIntraDir, iSizeInUchar ); |
---|
1090 | memcpy( rpcCU->getChromaIntraDir() + m_uiAbsIdxInLCU, m_puhChromaIntraDir, iSizeInUchar ); |
---|
1091 | memcpy( rpcCU->getInterDir() + m_uiAbsIdxInLCU, m_puhInterDir, iSizeInUchar ); |
---|
1092 | memcpy( rpcCU->getTransformIdx() + m_uiAbsIdxInLCU, m_puhTrIdx, iSizeInUchar ); |
---|
1093 | #if !REMOVE_NSQT |
---|
1094 | memcpy( rpcCU->getNSQTPartIdx() + m_uiAbsIdxInLCU, m_nsqtPartIdx, iSizeInUchar ); |
---|
1095 | #endif |
---|
1096 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhTransformSkip[0], iSizeInUchar ); |
---|
1097 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhTransformSkip[1], iSizeInUchar ); |
---|
1098 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhTransformSkip[2], iSizeInUchar ); |
---|
1099 | |
---|
1100 | memcpy( rpcCU->getCbf(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhCbf[0], iSizeInUchar ); |
---|
1101 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhCbf[1], iSizeInUchar ); |
---|
1102 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); |
---|
1103 | |
---|
1104 | memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); |
---|
1105 | memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); |
---|
1106 | memcpy( rpcCU->getHeight() + m_uiAbsIdxInLCU, m_puhHeight, iSizeInUchar ); |
---|
1107 | |
---|
1108 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPIdx[0], iSizeInUchar ); |
---|
1109 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPIdx[1], iSizeInUchar ); |
---|
1110 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPNum[0], iSizeInUchar ); |
---|
1111 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPNum[1], iSizeInUchar ); |
---|
1112 | |
---|
1113 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU ); |
---|
1114 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU ); |
---|
1115 | |
---|
1116 | memcpy( rpcCU->getIPCMFlag() + m_uiAbsIdxInLCU, m_pbIPCMFlag, iSizeInBool ); |
---|
1117 | |
---|
1118 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); |
---|
1119 | UInt uiTmp2 = m_uiAbsIdxInLCU*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
1120 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
1121 | #if ADAPTIVE_QP_SELECTION |
---|
1122 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
---|
1123 | #endif |
---|
1124 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof(Pel)*uiTmp ); |
---|
1125 | |
---|
1126 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
1127 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
1128 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
1129 | #if ADAPTIVE_QP_SELECTION |
---|
1130 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
---|
1131 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
---|
1132 | #endif |
---|
1133 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
---|
1134 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
---|
1135 | rpcCU->getTotalBins() = m_uiTotalBins; |
---|
1136 | memcpy( rpcCU->m_uiSliceStartCU + m_uiAbsIdxInLCU, m_uiSliceStartCU, sizeof( UInt ) * m_uiNumPartition ); |
---|
1137 | memcpy( rpcCU->m_uiDependentSliceStartCU + m_uiAbsIdxInLCU, m_uiDependentSliceStartCU, sizeof( UInt ) * m_uiNumPartition ); |
---|
1138 | } |
---|
1139 | |
---|
1140 | Void TComDataCU::copyToPic( UChar uhDepth, UInt uiPartIdx, UInt uiPartDepth ) |
---|
1141 | { |
---|
1142 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
1143 | UInt uiQNumPart = m_uiNumPartition>>(uiPartDepth<<1); |
---|
1144 | |
---|
1145 | UInt uiPartStart = uiPartIdx*uiQNumPart; |
---|
1146 | UInt uiPartOffset = m_uiAbsIdxInLCU + uiPartStart; |
---|
1147 | |
---|
1148 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
1149 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
1150 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
1151 | |
---|
1152 | Int iSizeInUchar = sizeof( UChar ) * uiQNumPart; |
---|
1153 | Int iSizeInBool = sizeof( Bool ) * uiQNumPart; |
---|
1154 | |
---|
1155 | Int sizeInChar = sizeof( Char ) * uiQNumPart; |
---|
1156 | #if SKIP_FLAG |
---|
1157 | memcpy( rpcCU->getSkipFlag() + uiPartOffset, m_skipFlag, sizeof( *m_skipFlag ) * uiQNumPart ); |
---|
1158 | #endif |
---|
1159 | |
---|
1160 | memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, sizeInChar ); |
---|
1161 | memcpy( rpcCU->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( *m_pePartSize ) * uiQNumPart ); |
---|
1162 | memcpy( rpcCU->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( *m_pePredMode ) * uiQNumPart ); |
---|
1163 | memcpy( rpcCU->getCUTransquantBypass()+ uiPartOffset, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * uiQNumPart ); |
---|
1164 | rpcCU->m_lcuAlfEnabled[0] = m_lcuAlfEnabled[0]; |
---|
1165 | rpcCU->m_lcuAlfEnabled[1] = m_lcuAlfEnabled[1]; |
---|
1166 | rpcCU->m_lcuAlfEnabled[2] = m_lcuAlfEnabled[2]; |
---|
1167 | memcpy( rpcCU->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); |
---|
1168 | memcpy( rpcCU->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); |
---|
1169 | memcpy( rpcCU->getLumaIntraDir() + uiPartOffset, m_puhLumaIntraDir, iSizeInUchar ); |
---|
1170 | memcpy( rpcCU->getChromaIntraDir() + uiPartOffset, m_puhChromaIntraDir, iSizeInUchar ); |
---|
1171 | memcpy( rpcCU->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); |
---|
1172 | memcpy( rpcCU->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); |
---|
1173 | #if !REMOVE_NSQT |
---|
1174 | memcpy( rpcCU->getNSQTPartIdx() + uiPartOffset, m_nsqtPartIdx, iSizeInUchar ); |
---|
1175 | #endif |
---|
1176 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + uiPartOffset, m_puhTransformSkip[0], iSizeInUchar ); |
---|
1177 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhTransformSkip[1], iSizeInUchar ); |
---|
1178 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhTransformSkip[2], iSizeInUchar ); |
---|
1179 | memcpy( rpcCU->getCbf(TEXT_LUMA) + uiPartOffset, m_puhCbf[0], iSizeInUchar ); |
---|
1180 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar ); |
---|
1181 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); |
---|
1182 | |
---|
1183 | memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); |
---|
1184 | memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); |
---|
1185 | memcpy( rpcCU->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); |
---|
1186 | |
---|
1187 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPIdx[0], iSizeInUchar ); |
---|
1188 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPIdx[1], iSizeInUchar ); |
---|
1189 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPNum[0], iSizeInUchar ); |
---|
1190 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPNum[1], iSizeInUchar ); |
---|
1191 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
1192 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
1193 | |
---|
1194 | memcpy( rpcCU->getIPCMFlag() + uiPartOffset, m_pbIPCMFlag, iSizeInBool ); |
---|
1195 | |
---|
1196 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); |
---|
1197 | UInt uiTmp2 = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
1198 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
1199 | #if ADAPTIVE_QP_SELECTION |
---|
1200 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
---|
1201 | #endif |
---|
1202 | |
---|
1203 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof( Pel ) * uiTmp ); |
---|
1204 | |
---|
1205 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
1206 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
1207 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
1208 | #if ADAPTIVE_QP_SELECTION |
---|
1209 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
---|
1210 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
---|
1211 | #endif |
---|
1212 | |
---|
1213 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
---|
1214 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
---|
1215 | rpcCU->getTotalBins() = m_uiTotalBins; |
---|
1216 | memcpy( rpcCU->m_uiSliceStartCU + uiPartOffset, m_uiSliceStartCU, sizeof( UInt ) * uiQNumPart ); |
---|
1217 | memcpy( rpcCU->m_uiDependentSliceStartCU + uiPartOffset, m_uiDependentSliceStartCU, sizeof( UInt ) * uiQNumPart ); |
---|
1218 | } |
---|
1219 | |
---|
1220 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1221 | // Other public functions |
---|
1222 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1223 | |
---|
1224 | TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, |
---|
1225 | UInt uiCurrPartUnitIdx, |
---|
1226 | Bool bEnforceSliceRestriction, |
---|
1227 | Bool bEnforceDependentSliceRestriction, |
---|
1228 | Bool bEnforceTileRestriction ) |
---|
1229 | { |
---|
1230 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1231 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1232 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1233 | |
---|
1234 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1235 | { |
---|
1236 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1237 | if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1238 | { |
---|
1239 | #if !REMOVE_FGS |
---|
1240 | TComDataCU* pcTempReconCU = m_pcPic->getCU( getAddr() ); |
---|
1241 | if ((bEnforceSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx))) |
---|
1242 | ||(bEnforceDependentSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)))) |
---|
1243 | { |
---|
1244 | return NULL; |
---|
1245 | } |
---|
1246 | #endif |
---|
1247 | return m_pcPic->getCU( getAddr() ); |
---|
1248 | } |
---|
1249 | else |
---|
1250 | { |
---|
1251 | uiLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1252 | #if !REMOVE_FGS |
---|
1253 | if ((bEnforceSliceRestriction && (this->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx) || m_pcSlice==NULL)) |
---|
1254 | ||(bEnforceDependentSliceRestriction && (this->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx) || m_pcSlice==NULL))) |
---|
1255 | { |
---|
1256 | return NULL; |
---|
1257 | } |
---|
1258 | #endif |
---|
1259 | return this; |
---|
1260 | } |
---|
1261 | } |
---|
1262 | |
---|
1263 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth - 1 ]; |
---|
1264 | |
---|
1265 | |
---|
1266 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
---|
1267 | || |
---|
1268 | (bEnforceDependentSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx))) |
---|
1269 | || |
---|
1270 | (bEnforceTileRestriction && ( m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) ) ) |
---|
1271 | ) |
---|
1272 | { |
---|
1273 | return NULL; |
---|
1274 | } |
---|
1275 | return m_pcCULeft; |
---|
1276 | } |
---|
1277 | |
---|
1278 | |
---|
1279 | TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, |
---|
1280 | UInt uiCurrPartUnitIdx, |
---|
1281 | Bool bEnforceSliceRestriction, |
---|
1282 | Bool bEnforceDependentSliceRestriction, |
---|
1283 | Bool MotionDataCompresssion, |
---|
1284 | Bool planarAtLCUBoundary , |
---|
1285 | Bool bEnforceTileRestriction ) |
---|
1286 | { |
---|
1287 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1288 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1289 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1290 | |
---|
1291 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1292 | { |
---|
1293 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth ]; |
---|
1294 | if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1295 | { |
---|
1296 | #if !REMOVE_FGS |
---|
1297 | TComDataCU* pcTempReconCU = m_pcPic->getCU( getAddr() ); |
---|
1298 | if ((bEnforceSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx))) |
---|
1299 | ||(bEnforceDependentSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)))) |
---|
1300 | { |
---|
1301 | return NULL; |
---|
1302 | } |
---|
1303 | #endif |
---|
1304 | return m_pcPic->getCU( getAddr() ); |
---|
1305 | } |
---|
1306 | else |
---|
1307 | { |
---|
1308 | uiAPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1309 | #if !REMOVE_FGS |
---|
1310 | if ((bEnforceSliceRestriction && (this->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx) || m_pcSlice==NULL)) |
---|
1311 | ||(bEnforceDependentSliceRestriction && (this->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx) || m_pcSlice==NULL))) |
---|
1312 | { |
---|
1313 | return NULL; |
---|
1314 | } |
---|
1315 | #endif |
---|
1316 | return this; |
---|
1317 | } |
---|
1318 | } |
---|
1319 | |
---|
1320 | if(planarAtLCUBoundary) |
---|
1321 | { |
---|
1322 | return NULL; |
---|
1323 | } |
---|
1324 | |
---|
1325 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1326 | if(MotionDataCompresssion) |
---|
1327 | { |
---|
1328 | uiAPartUnitIdx = g_motionRefer[uiAPartUnitIdx]; |
---|
1329 | } |
---|
1330 | |
---|
1331 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
---|
1332 | || |
---|
1333 | (bEnforceDependentSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx))) |
---|
1334 | || |
---|
1335 | (bEnforceTileRestriction &&(m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())))) |
---|
1336 | ) |
---|
1337 | { |
---|
1338 | return NULL; |
---|
1339 | } |
---|
1340 | return m_pcCUAbove; |
---|
1341 | } |
---|
1342 | |
---|
1343 | TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceDependentSliceRestriction, Bool MotionDataCompresssion ) |
---|
1344 | { |
---|
1345 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1346 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1347 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1348 | |
---|
1349 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1350 | { |
---|
1351 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1352 | { |
---|
1353 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth - 1 ]; |
---|
1354 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1355 | { |
---|
1356 | #if !REMOVE_FGS |
---|
1357 | TComDataCU* pcTempReconCU = m_pcPic->getCU( getAddr() ); |
---|
1358 | if ((bEnforceSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx))) |
---|
1359 | ||(bEnforceDependentSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)))) |
---|
1360 | { |
---|
1361 | return NULL; |
---|
1362 | } |
---|
1363 | #endif |
---|
1364 | return m_pcPic->getCU( getAddr() ); |
---|
1365 | } |
---|
1366 | else |
---|
1367 | { |
---|
1368 | uiALPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1369 | #if !REMOVE_FGS |
---|
1370 | if ((bEnforceSliceRestriction && (this->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx) || m_pcSlice==NULL)) |
---|
1371 | ||(bEnforceDependentSliceRestriction && (this->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx) || m_pcSlice==NULL))) |
---|
1372 | { |
---|
1373 | return NULL; |
---|
1374 | } |
---|
1375 | #endif |
---|
1376 | return this; |
---|
1377 | } |
---|
1378 | } |
---|
1379 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartInCU() - uiNumPartInCUWidth - 1 ]; |
---|
1380 | if(MotionDataCompresssion) |
---|
1381 | { |
---|
1382 | uiALPartUnitIdx = g_motionRefer[uiALPartUnitIdx]; |
---|
1383 | } |
---|
1384 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1385 | m_pcCUAbove->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1386 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1387 | ))|| |
---|
1388 | (bEnforceDependentSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1389 | m_pcCUAbove->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1390 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1391 | )) |
---|
1392 | ) |
---|
1393 | { |
---|
1394 | return NULL; |
---|
1395 | } |
---|
1396 | return m_pcCUAbove; |
---|
1397 | } |
---|
1398 | |
---|
1399 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1400 | { |
---|
1401 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1402 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1403 | m_pcCULeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1404 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1405 | ))|| |
---|
1406 | (bEnforceDependentSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1407 | m_pcCULeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1408 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1409 | )) |
---|
1410 | ) |
---|
1411 | { |
---|
1412 | return NULL; |
---|
1413 | } |
---|
1414 | return m_pcCULeft; |
---|
1415 | } |
---|
1416 | |
---|
1417 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - 1 ]; |
---|
1418 | if(MotionDataCompresssion) |
---|
1419 | { |
---|
1420 | uiALPartUnitIdx = g_motionRefer[uiALPartUnitIdx]; |
---|
1421 | } |
---|
1422 | if ( (bEnforceSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || |
---|
1423 | m_pcCUAboveLeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1424 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveLeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1425 | ))|| |
---|
1426 | (bEnforceDependentSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || |
---|
1427 | m_pcCUAboveLeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1428 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveLeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1429 | )) |
---|
1430 | ) |
---|
1431 | { |
---|
1432 | return NULL; |
---|
1433 | } |
---|
1434 | return m_pcCUAboveLeft; |
---|
1435 | } |
---|
1436 | |
---|
1437 | TComDataCU* TComDataCU::getPUAboveRight( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceDependentSliceRestriction, Bool MotionDataCompresssion ) |
---|
1438 | { |
---|
1439 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1440 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1; |
---|
1441 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1442 | |
---|
1443 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
1444 | { |
---|
1445 | uiARPartUnitIdx = MAX_UINT; |
---|
1446 | return NULL; |
---|
1447 | } |
---|
1448 | |
---|
1449 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - 1, uiNumPartInCUWidth ) ) |
---|
1450 | { |
---|
1451 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1452 | { |
---|
1453 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] ) |
---|
1454 | { |
---|
1455 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ]; |
---|
1456 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1457 | { |
---|
1458 | #if !REMOVE_FGS |
---|
1459 | TComDataCU* pcTempReconCU = m_pcPic->getCU( getAddr() ); |
---|
1460 | if ((bEnforceSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx))) |
---|
1461 | ||(bEnforceDependentSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)))) |
---|
1462 | { |
---|
1463 | return NULL; |
---|
1464 | } |
---|
1465 | #endif |
---|
1466 | return m_pcPic->getCU( getAddr() ); |
---|
1467 | } |
---|
1468 | else |
---|
1469 | { |
---|
1470 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1471 | #if !REMOVE_FGS |
---|
1472 | if ((bEnforceSliceRestriction && (this->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx) || m_pcSlice==NULL)) |
---|
1473 | ||(bEnforceDependentSliceRestriction && (this->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx) || m_pcSlice==NULL))) |
---|
1474 | { |
---|
1475 | return NULL; |
---|
1476 | } |
---|
1477 | #endif |
---|
1478 | return this; |
---|
1479 | } |
---|
1480 | } |
---|
1481 | uiARPartUnitIdx = MAX_UINT; |
---|
1482 | return NULL; |
---|
1483 | } |
---|
1484 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; |
---|
1485 | if(MotionDataCompresssion) |
---|
1486 | { |
---|
1487 | uiARPartUnitIdx = g_motionRefer[uiARPartUnitIdx]; |
---|
1488 | } |
---|
1489 | |
---|
1490 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1491 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1492 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1493 | ))|| |
---|
1494 | (bEnforceDependentSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1495 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1496 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1497 | )) |
---|
1498 | ) |
---|
1499 | { |
---|
1500 | return NULL; |
---|
1501 | } |
---|
1502 | return m_pcCUAbove; |
---|
1503 | } |
---|
1504 | |
---|
1505 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1506 | { |
---|
1507 | uiARPartUnitIdx = MAX_UINT; |
---|
1508 | return NULL; |
---|
1509 | } |
---|
1510 | |
---|
1511 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1512 | if(MotionDataCompresssion) |
---|
1513 | { |
---|
1514 | uiARPartUnitIdx = g_motionRefer[uiARPartUnitIdx]; |
---|
1515 | } |
---|
1516 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
1517 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
1518 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1519 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1520 | ))|| |
---|
1521 | (bEnforceDependentSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
1522 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
1523 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1524 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1525 | )) |
---|
1526 | ) |
---|
1527 | { |
---|
1528 | return NULL; |
---|
1529 | } |
---|
1530 | return m_pcCUAboveRight; |
---|
1531 | } |
---|
1532 | |
---|
1533 | TComDataCU* TComDataCU::getPUBelowLeft( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceDependentSliceRestriction ) |
---|
1534 | { |
---|
1535 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1536 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*m_pcPic->getNumPartInWidth(); |
---|
1537 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1538 | |
---|
1539 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
1540 | { |
---|
1541 | uiBLPartUnitIdx = MAX_UINT; |
---|
1542 | return NULL; |
---|
1543 | } |
---|
1544 | |
---|
1545 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - 1, uiNumPartInCUWidth ) ) |
---|
1546 | { |
---|
1547 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
---|
1548 | { |
---|
1549 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) |
---|
1550 | { |
---|
1551 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; |
---|
1552 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
---|
1553 | { |
---|
1554 | #if !REMOVE_FGS |
---|
1555 | TComDataCU* pcTempReconCU = m_pcPic->getCU( getAddr() ); |
---|
1556 | if ((bEnforceSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx))) |
---|
1557 | ||(bEnforceDependentSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)))) |
---|
1558 | { |
---|
1559 | return NULL; |
---|
1560 | } |
---|
1561 | #endif |
---|
1562 | return m_pcPic->getCU( getAddr() ); |
---|
1563 | } |
---|
1564 | else |
---|
1565 | { |
---|
1566 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1567 | #if !REMOVE_FGS |
---|
1568 | if ((bEnforceSliceRestriction && (this->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx) || m_pcSlice==NULL)) |
---|
1569 | ||(bEnforceDependentSliceRestriction && (this->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx) || m_pcSlice==NULL))) |
---|
1570 | { |
---|
1571 | return NULL; |
---|
1572 | } |
---|
1573 | #endif |
---|
1574 | return this; |
---|
1575 | } |
---|
1576 | } |
---|
1577 | uiBLPartUnitIdx = MAX_UINT; |
---|
1578 | return NULL; |
---|
1579 | } |
---|
1580 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; |
---|
1581 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1582 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1583 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1584 | ))|| |
---|
1585 | (bEnforceDependentSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1586 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1587 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1588 | )) |
---|
1589 | ) |
---|
1590 | { |
---|
1591 | return NULL; |
---|
1592 | } |
---|
1593 | return m_pcCULeft; |
---|
1594 | } |
---|
1595 | |
---|
1596 | uiBLPartUnitIdx = MAX_UINT; |
---|
1597 | return NULL; |
---|
1598 | } |
---|
1599 | |
---|
1600 | TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiPuHeight, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction, Bool bEnforceDependentSliceRestriction ) |
---|
1601 | { |
---|
1602 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1603 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth(); |
---|
1604 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1605 | |
---|
1606 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) |
---|
1607 | { |
---|
1608 | uiBLPartUnitIdx = MAX_UINT; |
---|
1609 | return NULL; |
---|
1610 | } |
---|
1611 | |
---|
1612 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
---|
1613 | { |
---|
1614 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
---|
1615 | { |
---|
1616 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ] ) |
---|
1617 | { |
---|
1618 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ]; |
---|
1619 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
---|
1620 | { |
---|
1621 | #if !REMOVE_FGS |
---|
1622 | TComDataCU* pcTempReconCU = m_pcPic->getCU( getAddr() ); |
---|
1623 | if ((bEnforceSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx))) |
---|
1624 | ||(bEnforceDependentSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)))) |
---|
1625 | { |
---|
1626 | return NULL; |
---|
1627 | } |
---|
1628 | #endif |
---|
1629 | return m_pcPic->getCU( getAddr() ); |
---|
1630 | } |
---|
1631 | else |
---|
1632 | { |
---|
1633 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1634 | #if !REMOVE_FGS |
---|
1635 | if ((bEnforceSliceRestriction && (this->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (uiCurrPartUnitIdx) || m_pcSlice==NULL)) |
---|
1636 | ||(bEnforceDependentSliceRestriction && (this->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx) || m_pcSlice==NULL))) |
---|
1637 | { |
---|
1638 | return NULL; |
---|
1639 | } |
---|
1640 | #endif |
---|
1641 | return this; |
---|
1642 | } |
---|
1643 | } |
---|
1644 | uiBLPartUnitIdx = MAX_UINT; |
---|
1645 | return NULL; |
---|
1646 | } |
---|
1647 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * uiNumPartInCUWidth - 1 ]; |
---|
1648 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1649 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1650 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1651 | ))|| |
---|
1652 | (bEnforceDependentSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1653 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1654 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1655 | )) |
---|
1656 | ) |
---|
1657 | { |
---|
1658 | return NULL; |
---|
1659 | } |
---|
1660 | return m_pcCULeft; |
---|
1661 | } |
---|
1662 | |
---|
1663 | uiBLPartUnitIdx = MAX_UINT; |
---|
1664 | return NULL; |
---|
1665 | } |
---|
1666 | |
---|
1667 | TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiPuWidth, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction, Bool bEnforceDependentSliceRestriction ) |
---|
1668 | { |
---|
1669 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1670 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
---|
1671 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1672 | |
---|
1673 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
1674 | { |
---|
1675 | uiARPartUnitIdx = MAX_UINT; |
---|
1676 | return NULL; |
---|
1677 | } |
---|
1678 | |
---|
1679 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
---|
1680 | { |
---|
1681 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1682 | { |
---|
1683 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ] ) |
---|
1684 | { |
---|
1685 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
1686 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1687 | { |
---|
1688 | #if !REMOVE_FGS |
---|
1689 | TComDataCU* pcTempReconCU = m_pcPic->getCU( getAddr() ); |
---|
1690 | if ((bEnforceSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
---|
1691 | ||( bEnforceDependentSliceRestriction && (pcTempReconCU==NULL || pcTempReconCU->getSlice() == NULL || pcTempReconCU->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)))) |
---|
1692 | |
---|
1693 | { |
---|
1694 | return NULL; |
---|
1695 | } |
---|
1696 | #endif |
---|
1697 | return m_pcPic->getCU( getAddr() ); |
---|
1698 | } |
---|
1699 | else |
---|
1700 | { |
---|
1701 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1702 | #if !REMOVE_FGS |
---|
1703 | if ((bEnforceSliceRestriction && (this->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx) || m_pcSlice==NULL)) |
---|
1704 | ||(bEnforceDependentSliceRestriction && (this->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx) || m_pcSlice==NULL))) |
---|
1705 | { |
---|
1706 | return NULL; |
---|
1707 | } |
---|
1708 | #endif |
---|
1709 | return this; |
---|
1710 | } |
---|
1711 | } |
---|
1712 | uiARPartUnitIdx = MAX_UINT; |
---|
1713 | return NULL; |
---|
1714 | } |
---|
1715 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
1716 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1717 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1718 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1719 | ))|| |
---|
1720 | (bEnforceDependentSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1721 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1722 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1723 | )) |
---|
1724 | ) |
---|
1725 | { |
---|
1726 | return NULL; |
---|
1727 | } |
---|
1728 | return m_pcCUAbove; |
---|
1729 | } |
---|
1730 | |
---|
1731 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1732 | { |
---|
1733 | uiARPartUnitIdx = MAX_UINT; |
---|
1734 | return NULL; |
---|
1735 | } |
---|
1736 | |
---|
1737 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset-1 ]; |
---|
1738 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
1739 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
1740 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1741 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1742 | ))|| |
---|
1743 | (bEnforceDependentSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
1744 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
1745 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1746 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1747 | )) |
---|
1748 | ) |
---|
1749 | { |
---|
1750 | return NULL; |
---|
1751 | } |
---|
1752 | return m_pcCUAboveRight; |
---|
1753 | } |
---|
1754 | |
---|
1755 | /** Get left QpMinCu |
---|
1756 | *\param uiLPartUnitIdx |
---|
1757 | *\param uiCurrAbsIdxInLCU |
---|
1758 | *\param bEnforceSliceRestriction |
---|
1759 | *\param bEnforceDependentSliceRestriction |
---|
1760 | *\returns TComDataCU* point of TComDataCU of left QpMinCu |
---|
1761 | */ |
---|
1762 | TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInLCU, Bool bEnforceSliceRestriction, Bool bEnforceDependentSliceRestriction) |
---|
1763 | { |
---|
1764 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1765 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth -getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
---|
1766 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
1767 | |
---|
1768 | // check for left LCU boundary |
---|
1769 | if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCUWidth) ) |
---|
1770 | { |
---|
1771 | return NULL; |
---|
1772 | } |
---|
1773 | |
---|
1774 | // get index of left-CU relative to top-left corner of current quantization group |
---|
1775 | uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; |
---|
1776 | |
---|
1777 | #if !REMOVE_FGS |
---|
1778 | // check for fine-grain slice boundaries |
---|
1779 | if ((bEnforceSliceRestriction && (m_pcPic->getCU( getAddr() )->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (absZorderQpMinCUIdx))) |
---|
1780 | ||(bEnforceDependentSliceRestriction && (m_pcPic->getCU( getAddr() )->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(absZorderQpMinCUIdx)))) |
---|
1781 | { |
---|
1782 | return NULL; |
---|
1783 | } |
---|
1784 | #endif |
---|
1785 | |
---|
1786 | // return pointer to current LCU |
---|
1787 | return m_pcPic->getCU( getAddr() ); |
---|
1788 | } |
---|
1789 | |
---|
1790 | /** Get Above QpMinCu |
---|
1791 | *\param aPartUnitIdx |
---|
1792 | *\param currAbsIdxInLCU |
---|
1793 | *\param enforceSliceRestriction |
---|
1794 | *\param enforceDependentSliceRestriction |
---|
1795 | *\returns TComDataCU* point of TComDataCU of above QpMinCu |
---|
1796 | */ |
---|
1797 | TComDataCU* TComDataCU::getQpMinCuAbove( UInt& aPartUnitIdx, UInt currAbsIdxInLCU, Bool enforceSliceRestriction, Bool enforceDependentSliceRestriction ) |
---|
1798 | { |
---|
1799 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1800 | UInt absZorderQpMinCUIdx = (currAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
---|
1801 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
1802 | |
---|
1803 | // check for top LCU boundary |
---|
1804 | if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCUWidth) ) |
---|
1805 | { |
---|
1806 | return NULL; |
---|
1807 | } |
---|
1808 | |
---|
1809 | // get index of top-CU relative to top-left corner of current quantization group |
---|
1810 | aPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCUWidth]; |
---|
1811 | |
---|
1812 | #if !REMOVE_FGS |
---|
1813 | // check for fine-grain slice boundaries |
---|
1814 | if ((enforceSliceRestriction && (m_pcPic->getCU( getAddr() )->getSCUAddr()+aPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU (absZorderQpMinCUIdx))) |
---|
1815 | ||(enforceDependentSliceRestriction && (m_pcPic->getCU( getAddr() )->getSCUAddr()+aPartUnitIdx < m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(absZorderQpMinCUIdx)))) |
---|
1816 | { |
---|
1817 | return NULL; |
---|
1818 | } |
---|
1819 | #endif |
---|
1820 | |
---|
1821 | // return pointer to current LCU |
---|
1822 | return m_pcPic->getCU( getAddr() ); |
---|
1823 | } |
---|
1824 | |
---|
1825 | /** Get reference QP from left QpMinCu or latest coded QP |
---|
1826 | *\param uiCurrAbsIdxInLCU |
---|
1827 | *\returns Char reference QP value |
---|
1828 | */ |
---|
1829 | Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInLCU ) |
---|
1830 | { |
---|
1831 | UInt lPartIdx = 0, aPartIdx = 0; |
---|
1832 | TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
---|
1833 | TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
---|
1834 | return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + 1) >> 1); |
---|
1835 | } |
---|
1836 | |
---|
1837 | Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) |
---|
1838 | { |
---|
1839 | Int iLastValidPartIdx = iAbsPartIdx-1; |
---|
1840 | while ( iLastValidPartIdx >= 0 |
---|
1841 | && getPredictionMode( iLastValidPartIdx ) == MODE_NONE ) |
---|
1842 | { |
---|
1843 | UInt uiDepth = getDepth( iLastValidPartIdx ); |
---|
1844 | iLastValidPartIdx -= m_uiNumPartition>>(uiDepth<<1); |
---|
1845 | } |
---|
1846 | return iLastValidPartIdx; |
---|
1847 | } |
---|
1848 | |
---|
1849 | Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) |
---|
1850 | { |
---|
1851 | UInt uiQUPartIdxMask = ~((1<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); |
---|
1852 | Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); |
---|
1853 | if ( uiAbsPartIdx < m_uiNumPartition |
---|
1854 | && (getSCUAddr()+iLastValidPartIdx < getSliceStartCU(m_uiAbsIdxInLCU+uiAbsPartIdx) || getSCUAddr()+iLastValidPartIdx < getDependentSliceStartCU(m_uiAbsIdxInLCU+uiAbsPartIdx) )) |
---|
1855 | { |
---|
1856 | return getSlice()->getSliceQp(); |
---|
1857 | } |
---|
1858 | else |
---|
1859 | if ( iLastValidPartIdx >= 0 ) |
---|
1860 | { |
---|
1861 | return getQP( iLastValidPartIdx ); |
---|
1862 | } |
---|
1863 | else |
---|
1864 | { |
---|
1865 | if ( getZorderIdxInCU() > 0 ) |
---|
1866 | { |
---|
1867 | return getPic()->getCU( getAddr() )->getLastCodedQP( getZorderIdxInCU() ); |
---|
1868 | } |
---|
1869 | else if ( getPic()->getPicSym()->getInverseCUOrderMap(getAddr()) > 0 |
---|
1870 | && getPic()->getPicSym()->getTileIdxMap(getAddr()) == getPic()->getPicSym()->getTileIdxMap(getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1)) |
---|
1871 | #if TILES_WPP_ENTROPYSLICES_FLAGS |
---|
1872 | && !( getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() && getAddr() % getPic()->getFrameWidthInCU() == 0 ) ) |
---|
1873 | #else |
---|
1874 | && !( getSlice()->getPPS()->getTilesOrEntropyCodingSyncIdc() == 2 && getAddr() % getPic()->getFrameWidthInCU() == 0 ) ) |
---|
1875 | #endif |
---|
1876 | { |
---|
1877 | return getPic()->getCU( getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1) )->getLastCodedQP( getPic()->getNumPartInCU() ); |
---|
1878 | } |
---|
1879 | else |
---|
1880 | { |
---|
1881 | return getSlice()->getSliceQp(); |
---|
1882 | } |
---|
1883 | } |
---|
1884 | } |
---|
1885 | /** Check whether the CU is coded in lossless coding mode |
---|
1886 | * \param uiAbsPartIdx |
---|
1887 | * \returns true if the CU is coded in lossless coding mode; false if otherwise |
---|
1888 | */ |
---|
1889 | Bool TComDataCU::isLosslessCoded(UInt absPartIdx) |
---|
1890 | { |
---|
1891 | return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx)); |
---|
1892 | } |
---|
1893 | |
---|
1894 | /** Get allowed chroma intra modes |
---|
1895 | *\param uiAbsPartIdx |
---|
1896 | *\param uiModeList pointer to chroma intra modes array |
---|
1897 | *\returns |
---|
1898 | *- fill uiModeList with chroma intra modes |
---|
1899 | */ |
---|
1900 | Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt* uiModeList ) |
---|
1901 | { |
---|
1902 | uiModeList[0] = PLANAR_IDX; |
---|
1903 | uiModeList[1] = VER_IDX; |
---|
1904 | uiModeList[2] = HOR_IDX; |
---|
1905 | uiModeList[3] = DC_IDX; |
---|
1906 | #if !REMOVE_LMCHROMA |
---|
1907 | uiModeList[4] = LM_CHROMA_IDX; |
---|
1908 | uiModeList[5] = DM_CHROMA_IDX; |
---|
1909 | #else |
---|
1910 | uiModeList[4] = DM_CHROMA_IDX; |
---|
1911 | #endif |
---|
1912 | |
---|
1913 | UInt uiLumaMode = getLumaIntraDir( uiAbsPartIdx ); |
---|
1914 | |
---|
1915 | #if REMOVE_LMCHROMA |
---|
1916 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
---|
1917 | #else |
---|
1918 | for( Int i = 0; i < NUM_CHROMA_MODE - 2; i++ ) |
---|
1919 | #endif |
---|
1920 | { |
---|
1921 | if( uiLumaMode == uiModeList[i] ) |
---|
1922 | { |
---|
1923 | uiModeList[i] = 34; // VER+8 mode |
---|
1924 | break; |
---|
1925 | } |
---|
1926 | } |
---|
1927 | } |
---|
1928 | |
---|
1929 | /** Get most probable intra modes |
---|
1930 | *\param uiAbsPartIdx |
---|
1931 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
1932 | *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. |
---|
1933 | *\returns Number of MPM |
---|
1934 | */ |
---|
1935 | Int TComDataCU::getIntraDirLumaPredictor( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode ) |
---|
1936 | { |
---|
1937 | TComDataCU* pcTempCU; |
---|
1938 | UInt uiTempPartIdx; |
---|
1939 | Int iLeftIntraDir, iAboveIntraDir; |
---|
1940 | Int uiPredNum = 0; |
---|
1941 | |
---|
1942 | // Get intra direction of left PU |
---|
1943 | #if DEPENDENT_SLICES |
---|
1944 | Bool bDepSliceRestriction = ( !m_pcSlice->getPPS()->getDependentSliceEnabledFlag()); |
---|
1945 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
1946 | #else |
---|
1947 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1948 | #endif |
---|
1949 | |
---|
1950 | #if INTRA_BL |
---|
1951 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) && ( !pcTempCU->isIntraBL( uiTempPartIdx ) ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
1952 | #else |
---|
1953 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
1954 | #endif |
---|
1955 | |
---|
1956 | // Get intra direction of above PU |
---|
1957 | #if DEPENDENT_SLICES |
---|
1958 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction, false, true ); |
---|
1959 | #else |
---|
1960 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true, false, true ); |
---|
1961 | #endif |
---|
1962 | |
---|
1963 | #if INTRA_BL |
---|
1964 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) && ( !pcTempCU->isIntraBL( uiTempPartIdx ) ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
1965 | #else |
---|
1966 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
1967 | #endif |
---|
1968 | |
---|
1969 | #if SVC_BL_CAND_INTRA |
---|
1970 | if(m_layerId > 0) |
---|
1971 | { |
---|
1972 | UInt uiCUAddrBase, uiAbsPartAddrBase; |
---|
1973 | pcTempCU = getBaseColCU( uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase ); |
---|
1974 | |
---|
1975 | if(pcTempCU->getPredictionMode( uiAbsPartAddrBase ) == MODE_INTRA ) |
---|
1976 | { |
---|
1977 | Int iColBaseDir = pcTempCU->getLumaIntraDir( uiAbsPartAddrBase ); |
---|
1978 | if( iColBaseDir != iAboveIntraDir && iColBaseDir != iLeftIntraDir && iAboveIntraDir != iLeftIntraDir) |
---|
1979 | { |
---|
1980 | uiIntraDirPred[0] = iColBaseDir; |
---|
1981 | uiIntraDirPred[1] = iLeftIntraDir; |
---|
1982 | uiIntraDirPred[2] = iAboveIntraDir; |
---|
1983 | if( piMode ) |
---|
1984 | { |
---|
1985 | *piMode = 2; |
---|
1986 | } |
---|
1987 | uiPredNum = 3; |
---|
1988 | return uiPredNum; |
---|
1989 | } |
---|
1990 | else |
---|
1991 | { |
---|
1992 | iAboveIntraDir = (iColBaseDir == iLeftIntraDir) ? iAboveIntraDir : iLeftIntraDir; |
---|
1993 | iLeftIntraDir = iColBaseDir; |
---|
1994 | } |
---|
1995 | } |
---|
1996 | } |
---|
1997 | #endif |
---|
1998 | |
---|
1999 | uiPredNum = 3; |
---|
2000 | if(iLeftIntraDir == iAboveIntraDir) |
---|
2001 | { |
---|
2002 | if( piMode ) |
---|
2003 | { |
---|
2004 | *piMode = 1; |
---|
2005 | } |
---|
2006 | |
---|
2007 | if (iLeftIntraDir > 1) // angular modes |
---|
2008 | { |
---|
2009 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
2010 | uiIntraDirPred[1] = ((iLeftIntraDir + 29) % 32) + 2; |
---|
2011 | uiIntraDirPred[2] = ((iLeftIntraDir - 1 ) % 32) + 2; |
---|
2012 | } |
---|
2013 | else //non-angular |
---|
2014 | { |
---|
2015 | uiIntraDirPred[0] = PLANAR_IDX; |
---|
2016 | uiIntraDirPred[1] = DC_IDX; |
---|
2017 | uiIntraDirPred[2] = VER_IDX; |
---|
2018 | } |
---|
2019 | } |
---|
2020 | else |
---|
2021 | { |
---|
2022 | if( piMode ) |
---|
2023 | { |
---|
2024 | *piMode = 2; |
---|
2025 | } |
---|
2026 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
2027 | uiIntraDirPred[1] = iAboveIntraDir; |
---|
2028 | |
---|
2029 | if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar |
---|
2030 | { |
---|
2031 | uiIntraDirPred[2] = PLANAR_IDX; |
---|
2032 | } |
---|
2033 | else |
---|
2034 | { |
---|
2035 | uiIntraDirPred[2] = (iLeftIntraDir+iAboveIntraDir)<2? VER_IDX : DC_IDX; |
---|
2036 | } |
---|
2037 | } |
---|
2038 | |
---|
2039 | return uiPredNum; |
---|
2040 | } |
---|
2041 | |
---|
2042 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2043 | { |
---|
2044 | TComDataCU* pcTempCU; |
---|
2045 | UInt uiTempPartIdx; |
---|
2046 | UInt uiCtx; |
---|
2047 | // Get left split flag |
---|
2048 | #if DEPENDENT_SLICES |
---|
2049 | Bool bDepSliceRestriction = ( !m_pcSlice->getPPS()->getDependentSliceEnabledFlag()); |
---|
2050 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
2051 | #else |
---|
2052 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2053 | #endif |
---|
2054 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
2055 | |
---|
2056 | // Get above split flag |
---|
2057 | #if DEPENDENT_SLICES |
---|
2058 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
2059 | #else |
---|
2060 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2061 | #endif |
---|
2062 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
2063 | |
---|
2064 | return uiCtx; |
---|
2065 | } |
---|
2066 | |
---|
2067 | UInt TComDataCU::getCtxQtCbf( UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
2068 | { |
---|
2069 | if( eType ) |
---|
2070 | { |
---|
2071 | return uiTrDepth; |
---|
2072 | } |
---|
2073 | else |
---|
2074 | { |
---|
2075 | #if SIMPLE_LUMA_CBF_CTX_DERIVATION |
---|
2076 | const UInt uiCtx = ( uiTrDepth == 0 ? 1 : 0 ); |
---|
2077 | #else |
---|
2078 | const UInt uiDepth = getDepth( uiAbsPartIdx ); |
---|
2079 | const UInt uiLog2TrafoSize = g_aucConvertToBit[ getSlice()->getSPS()->getMaxCUWidth() ] + 2 - uiDepth - uiTrDepth; |
---|
2080 | const UInt uiCtx = uiTrDepth == 0 || uiLog2TrafoSize == getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ? 1 : 0; |
---|
2081 | #endif |
---|
2082 | return uiCtx; |
---|
2083 | } |
---|
2084 | } |
---|
2085 | |
---|
2086 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) |
---|
2087 | { |
---|
2088 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
---|
2089 | PartSize partSize = getPartitionSize( absPartIdx ); |
---|
2090 | #if INTRA_BL |
---|
2091 | UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
2092 | #else |
---|
2093 | UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
2094 | #endif |
---|
2095 | Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA && partSize == SIZE_NxN ) ? 1 : 0; |
---|
2096 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) ); |
---|
2097 | |
---|
2098 | UInt log2MinTUSizeInCU = 0; |
---|
2099 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
---|
2100 | { |
---|
2101 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
---|
2102 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
2103 | } |
---|
2104 | else |
---|
2105 | { |
---|
2106 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
---|
2107 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
---|
2108 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
2109 | { |
---|
2110 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
---|
2111 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
2112 | } |
---|
2113 | } |
---|
2114 | return log2MinTUSizeInCU; |
---|
2115 | } |
---|
2116 | |
---|
2117 | #if INTRA_BL |
---|
2118 | UInt TComDataCU::getCtxIntraBLFlag( UInt uiAbsPartIdx ) |
---|
2119 | { |
---|
2120 | TComDataCU* pcTempCU; |
---|
2121 | UInt uiTempPartIdx; |
---|
2122 | UInt uiCtx = 0; |
---|
2123 | |
---|
2124 | // Get BCBP of left PU |
---|
2125 | #if DEPENDENT_SLICES |
---|
2126 | Bool bDepSliceRestriction = ( !m_pcSlice->getPPS()->getDependentSliceEnabledFlag()); |
---|
2127 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
2128 | #else |
---|
2129 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2130 | #endif |
---|
2131 | uiCtx = ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0; |
---|
2132 | |
---|
2133 | // Get BCBP of above PU |
---|
2134 | #if DEPENDENT_SLICES |
---|
2135 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
2136 | #else |
---|
2137 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2138 | #endif |
---|
2139 | uiCtx += ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0; |
---|
2140 | |
---|
2141 | return uiCtx; |
---|
2142 | } |
---|
2143 | #endif |
---|
2144 | |
---|
2145 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
---|
2146 | { |
---|
2147 | TComDataCU* pcTempCU; |
---|
2148 | UInt uiTempPartIdx; |
---|
2149 | UInt uiCtx = 0; |
---|
2150 | |
---|
2151 | // Get BCBP of left PU |
---|
2152 | #if DEPENDENT_SLICES |
---|
2153 | Bool bDepSliceRestriction = ( !m_pcSlice->getPPS()->getDependentSliceEnabledFlag()); |
---|
2154 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
2155 | #else |
---|
2156 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2157 | #endif |
---|
2158 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2159 | |
---|
2160 | // Get BCBP of above PU |
---|
2161 | #if DEPENDENT_SLICES |
---|
2162 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
2163 | #else |
---|
2164 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2165 | #endif |
---|
2166 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2167 | |
---|
2168 | return uiCtx; |
---|
2169 | } |
---|
2170 | |
---|
2171 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
---|
2172 | { |
---|
2173 | return getDepth( uiAbsPartIdx ); |
---|
2174 | } |
---|
2175 | |
---|
2176 | Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2177 | { |
---|
2178 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2179 | memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2180 | memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2181 | memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2182 | } |
---|
2183 | |
---|
2184 | Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2185 | { |
---|
2186 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2187 | memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2188 | } |
---|
2189 | |
---|
2190 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
2191 | * \param uiCbf The value of the coded block flag to be set |
---|
2192 | * \param eTType |
---|
2193 | * \param uiAbsPartIdx |
---|
2194 | * \param uiPartIdx |
---|
2195 | * \param uiDepth |
---|
2196 | * \returns Void |
---|
2197 | */ |
---|
2198 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2199 | { |
---|
2200 | setSubPart<UChar>( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2201 | } |
---|
2202 | |
---|
2203 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
2204 | { |
---|
2205 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2206 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2207 | } |
---|
2208 | |
---|
2209 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
---|
2210 | { |
---|
2211 | UInt uiPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2212 | return (((m_uiAbsIdxInLCU + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
2213 | } |
---|
2214 | |
---|
2215 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2216 | { |
---|
2217 | assert( sizeof( *m_pePartSize) == 1 ); |
---|
2218 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2219 | } |
---|
2220 | |
---|
2221 | Void TComDataCU::setCUTransquantBypassSubParts( bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2222 | { |
---|
2223 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2224 | } |
---|
2225 | |
---|
2226 | #if SKIP_FLAG |
---|
2227 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
---|
2228 | { |
---|
2229 | assert( sizeof( *m_skipFlag) == 1 ); |
---|
2230 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); |
---|
2231 | } |
---|
2232 | #endif |
---|
2233 | |
---|
2234 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2235 | { |
---|
2236 | assert( sizeof( *m_pePredMode) == 1 ); |
---|
2237 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2238 | } |
---|
2239 | |
---|
2240 | Void TComDataCU::setQPSubCUs( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
---|
2241 | { |
---|
2242 | UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); |
---|
2243 | UInt currPartNumQ = currPartNumb >> 2; |
---|
2244 | |
---|
2245 | if(!foundNonZeroCbf) |
---|
2246 | { |
---|
2247 | if(pcCU->getDepth(absPartIdx) > depth) |
---|
2248 | { |
---|
2249 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
---|
2250 | { |
---|
2251 | pcCU->setQPSubCUs( qp, pcCU, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
---|
2252 | } |
---|
2253 | } |
---|
2254 | else |
---|
2255 | { |
---|
2256 | if(pcCU->getCbf( absPartIdx, TEXT_LUMA ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_U ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_V ) ) |
---|
2257 | { |
---|
2258 | foundNonZeroCbf = true; |
---|
2259 | } |
---|
2260 | else |
---|
2261 | { |
---|
2262 | setQPSubParts(qp, absPartIdx, depth); |
---|
2263 | } |
---|
2264 | } |
---|
2265 | } |
---|
2266 | } |
---|
2267 | |
---|
2268 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2269 | { |
---|
2270 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2271 | TComSlice * pcSlice = getPic()->getSlice(getPic()->getCurrSliceIdx()); |
---|
2272 | |
---|
2273 | for(UInt uiSCUIdx = uiAbsPartIdx; uiSCUIdx < uiAbsPartIdx+uiCurrPartNumb; uiSCUIdx++) |
---|
2274 | { |
---|
2275 | if( m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiSCUIdx+getZorderIdxInCU()) == pcSlice->getDependentSliceCurStartCUAddr() ) |
---|
2276 | { |
---|
2277 | m_phQP[uiSCUIdx] = qp; |
---|
2278 | } |
---|
2279 | } |
---|
2280 | } |
---|
2281 | |
---|
2282 | Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2283 | { |
---|
2284 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2285 | |
---|
2286 | memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2287 | } |
---|
2288 | |
---|
2289 | template<typename T> |
---|
2290 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2291 | { |
---|
2292 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
---|
2293 | |
---|
2294 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
---|
2295 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2296 | { |
---|
2297 | case SIZE_2Nx2N: |
---|
2298 | memset( puhBaseLCU + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
---|
2299 | break; |
---|
2300 | case SIZE_2NxN: |
---|
2301 | memset( puhBaseLCU + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
---|
2302 | break; |
---|
2303 | case SIZE_Nx2N: |
---|
2304 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2305 | memset( puhBaseLCU + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
---|
2306 | break; |
---|
2307 | case SIZE_NxN: |
---|
2308 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2309 | break; |
---|
2310 | case SIZE_2NxnU: |
---|
2311 | if ( uiPUIdx == 0 ) |
---|
2312 | { |
---|
2313 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2314 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2315 | } |
---|
2316 | else if ( uiPUIdx == 1 ) |
---|
2317 | { |
---|
2318 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2319 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
---|
2320 | } |
---|
2321 | else |
---|
2322 | { |
---|
2323 | assert(0); |
---|
2324 | } |
---|
2325 | break; |
---|
2326 | case SIZE_2NxnD: |
---|
2327 | if ( uiPUIdx == 0 ) |
---|
2328 | { |
---|
2329 | memset( puhBaseLCU + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
---|
2330 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2331 | } |
---|
2332 | else if ( uiPUIdx == 1 ) |
---|
2333 | { |
---|
2334 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2335 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2336 | } |
---|
2337 | else |
---|
2338 | { |
---|
2339 | assert(0); |
---|
2340 | } |
---|
2341 | break; |
---|
2342 | case SIZE_nLx2N: |
---|
2343 | if ( uiPUIdx == 0 ) |
---|
2344 | { |
---|
2345 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2346 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2347 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2348 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2349 | } |
---|
2350 | else if ( uiPUIdx == 1 ) |
---|
2351 | { |
---|
2352 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2353 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2354 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2355 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2356 | } |
---|
2357 | else |
---|
2358 | { |
---|
2359 | assert(0); |
---|
2360 | } |
---|
2361 | break; |
---|
2362 | case SIZE_nRx2N: |
---|
2363 | if ( uiPUIdx == 0 ) |
---|
2364 | { |
---|
2365 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2366 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2367 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2368 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2369 | } |
---|
2370 | else if ( uiPUIdx == 1 ) |
---|
2371 | { |
---|
2372 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2373 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2374 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2375 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2376 | } |
---|
2377 | else |
---|
2378 | { |
---|
2379 | assert(0); |
---|
2380 | } |
---|
2381 | break; |
---|
2382 | default: |
---|
2383 | assert( 0 ); |
---|
2384 | } |
---|
2385 | } |
---|
2386 | |
---|
2387 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2388 | { |
---|
2389 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2390 | } |
---|
2391 | |
---|
2392 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2393 | { |
---|
2394 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2395 | } |
---|
2396 | |
---|
2397 | Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2398 | { |
---|
2399 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2400 | |
---|
2401 | memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2402 | } |
---|
2403 | |
---|
2404 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2405 | { |
---|
2406 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2407 | } |
---|
2408 | |
---|
2409 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2410 | { |
---|
2411 | setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2412 | } |
---|
2413 | |
---|
2414 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2415 | { |
---|
2416 | setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2417 | } |
---|
2418 | |
---|
2419 | |
---|
2420 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2421 | { |
---|
2422 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2423 | |
---|
2424 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
2425 | } |
---|
2426 | |
---|
2427 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2428 | { |
---|
2429 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2430 | |
---|
2431 | memset( m_puhTransformSkip[0] + uiAbsPartIdx, useTransformSkipY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2432 | memset( m_puhTransformSkip[1] + uiAbsPartIdx, useTransformSkipU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2433 | memset( m_puhTransformSkip[2] + uiAbsPartIdx, useTransformSkipV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2434 | } |
---|
2435 | |
---|
2436 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth) |
---|
2437 | { |
---|
2438 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2439 | |
---|
2440 | memset( m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2441 | } |
---|
2442 | |
---|
2443 | #if !REMOVE_NSQT |
---|
2444 | Void TComDataCU::setNSQTIdxSubParts( UInt absPartIdx, UInt depth ) |
---|
2445 | { |
---|
2446 | UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); |
---|
2447 | |
---|
2448 | memset( m_nsqtPartIdx + absPartIdx, absPartIdx, sizeof(UChar)*currPartNumb ); |
---|
2449 | } |
---|
2450 | |
---|
2451 | Void TComDataCU::setNSQTIdxSubParts( UInt log2TrafoSize, UInt absPartIdx, UInt absTUPartIdx, UInt trMode ) |
---|
2452 | { |
---|
2453 | UInt trWidth, trHeight; |
---|
2454 | UInt nsTUWidthInBaseUnits, nsTUHeightInBaseUnits; |
---|
2455 | UInt lcuWidthInBaseUnits = getPic()->getNumPartInWidth(); |
---|
2456 | |
---|
2457 | UInt minTuSize = ( 1 << getSlice()->getSPS()->getQuadtreeTULog2MinSize() ); |
---|
2458 | |
---|
2459 | trWidth = trHeight = ( 1 << log2TrafoSize ); |
---|
2460 | |
---|
2461 | if ( useNonSquareTrans( trMode, absPartIdx ) && ( trWidth > minTuSize ) ) |
---|
2462 | { |
---|
2463 | trWidth = ( m_pePartSize[absPartIdx] == SIZE_Nx2N || m_pePartSize[absPartIdx] == SIZE_nLx2N || m_pePartSize[absPartIdx] == SIZE_nRx2N )? trWidth >> 1 : trWidth << 1; |
---|
2464 | trHeight = ( m_pePartSize[absPartIdx] == SIZE_Nx2N || m_pePartSize[absPartIdx] == SIZE_nLx2N || m_pePartSize[absPartIdx] == SIZE_nRx2N )? trHeight << 1 : trHeight >> 1; |
---|
2465 | } |
---|
2466 | |
---|
2467 | nsTUWidthInBaseUnits = trWidth / getPic()->getMinCUWidth(); |
---|
2468 | nsTUHeightInBaseUnits = trHeight / getPic()->getMinCUHeight(); |
---|
2469 | |
---|
2470 | if ( nsTUWidthInBaseUnits > nsTUHeightInBaseUnits ) |
---|
2471 | { |
---|
2472 | UInt currPartNumb = nsTUHeightInBaseUnits*nsTUHeightInBaseUnits; |
---|
2473 | memset( m_nsqtPartIdx + absTUPartIdx , absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2474 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+ nsTUHeightInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2475 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+2*nsTUHeightInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2476 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+3*nsTUHeightInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2477 | } |
---|
2478 | else if ( nsTUWidthInBaseUnits < nsTUHeightInBaseUnits ) |
---|
2479 | { |
---|
2480 | UInt currPartNumb = nsTUWidthInBaseUnits*nsTUWidthInBaseUnits; |
---|
2481 | memset( m_nsqtPartIdx + absTUPartIdx , absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2482 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+ nsTUWidthInBaseUnits*lcuWidthInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2483 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+2*nsTUWidthInBaseUnits*lcuWidthInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2484 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+3*nsTUWidthInBaseUnits*lcuWidthInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2485 | } |
---|
2486 | else |
---|
2487 | { |
---|
2488 | UInt currPartNumb = nsTUWidthInBaseUnits*nsTUHeightInBaseUnits; |
---|
2489 | memset( m_nsqtPartIdx + absTUPartIdx, absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2490 | } |
---|
2491 | } |
---|
2492 | #endif |
---|
2493 | |
---|
2494 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2495 | { |
---|
2496 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2497 | |
---|
2498 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2499 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
2500 | } |
---|
2501 | |
---|
2502 | UChar TComDataCU::getNumPartInter() |
---|
2503 | { |
---|
2504 | UChar iNumPart = 0; |
---|
2505 | |
---|
2506 | switch ( m_pePartSize[0] ) |
---|
2507 | { |
---|
2508 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
2509 | case SIZE_2NxN: iNumPart = 2; break; |
---|
2510 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
2511 | case SIZE_NxN: iNumPart = 4; break; |
---|
2512 | case SIZE_2NxnU: iNumPart = 2; break; |
---|
2513 | case SIZE_2NxnD: iNumPart = 2; break; |
---|
2514 | case SIZE_nLx2N: iNumPart = 2; break; |
---|
2515 | case SIZE_nRx2N: iNumPart = 2; break; |
---|
2516 | default: assert (0); break; |
---|
2517 | } |
---|
2518 | |
---|
2519 | return iNumPart; |
---|
2520 | } |
---|
2521 | |
---|
2522 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
---|
2523 | { |
---|
2524 | switch ( m_pePartSize[0] ) |
---|
2525 | { |
---|
2526 | case SIZE_2NxN: |
---|
2527 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2528 | break; |
---|
2529 | case SIZE_Nx2N: |
---|
2530 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
2531 | break; |
---|
2532 | case SIZE_NxN: |
---|
2533 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2534 | break; |
---|
2535 | case SIZE_2NxnU: |
---|
2536 | riWidth = getWidth(0); |
---|
2537 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
2538 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
---|
2539 | break; |
---|
2540 | case SIZE_2NxnD: |
---|
2541 | riWidth = getWidth(0); |
---|
2542 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
2543 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
---|
2544 | break; |
---|
2545 | case SIZE_nLx2N: |
---|
2546 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
2547 | riHeight = getHeight(0); |
---|
2548 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
---|
2549 | break; |
---|
2550 | case SIZE_nRx2N: |
---|
2551 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
2552 | riHeight = getHeight(0); |
---|
2553 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2554 | break; |
---|
2555 | default: |
---|
2556 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
2557 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
2558 | break; |
---|
2559 | } |
---|
2560 | } |
---|
2561 | |
---|
2562 | |
---|
2563 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
2564 | { |
---|
2565 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
2566 | { |
---|
2567 | TComMv cZeroMv; |
---|
2568 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
2569 | return; |
---|
2570 | } |
---|
2571 | |
---|
2572 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
2573 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
2574 | } |
---|
2575 | |
---|
2576 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2577 | { |
---|
2578 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
2579 | UInt uiPUWidth = 0; |
---|
2580 | |
---|
2581 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2582 | { |
---|
2583 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2584 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2585 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2586 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2587 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2588 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2589 | case SIZE_nLx2N: |
---|
2590 | if ( uiPartIdx == 0 ) |
---|
2591 | { |
---|
2592 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
2593 | } |
---|
2594 | else if ( uiPartIdx == 1 ) |
---|
2595 | { |
---|
2596 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
2597 | } |
---|
2598 | else |
---|
2599 | { |
---|
2600 | assert(0); |
---|
2601 | } |
---|
2602 | break; |
---|
2603 | case SIZE_nRx2N: |
---|
2604 | if ( uiPartIdx == 0 ) |
---|
2605 | { |
---|
2606 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
2607 | } |
---|
2608 | else if ( uiPartIdx == 1 ) |
---|
2609 | { |
---|
2610 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
2611 | } |
---|
2612 | else |
---|
2613 | { |
---|
2614 | assert(0); |
---|
2615 | } |
---|
2616 | break; |
---|
2617 | default: |
---|
2618 | assert (0); |
---|
2619 | break; |
---|
2620 | } |
---|
2621 | |
---|
2622 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2623 | } |
---|
2624 | |
---|
2625 | Void TComDataCU::deriveLeftBottomIdxGeneral( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2626 | { |
---|
2627 | UInt uiPUHeight = 0; |
---|
2628 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2629 | { |
---|
2630 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2631 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2632 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2633 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2634 | case SIZE_2NxnU: |
---|
2635 | if ( uiPartIdx == 0 ) |
---|
2636 | { |
---|
2637 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
2638 | } |
---|
2639 | else if ( uiPartIdx == 1 ) |
---|
2640 | { |
---|
2641 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
2642 | } |
---|
2643 | else |
---|
2644 | { |
---|
2645 | assert(0); |
---|
2646 | } |
---|
2647 | break; |
---|
2648 | case SIZE_2NxnD: |
---|
2649 | if ( uiPartIdx == 0 ) |
---|
2650 | { |
---|
2651 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
2652 | } |
---|
2653 | else if ( uiPartIdx == 1 ) |
---|
2654 | { |
---|
2655 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
2656 | } |
---|
2657 | else |
---|
2658 | { |
---|
2659 | assert(0); |
---|
2660 | } |
---|
2661 | break; |
---|
2662 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2663 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2664 | default: |
---|
2665 | assert (0); |
---|
2666 | break; |
---|
2667 | } |
---|
2668 | |
---|
2669 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
2670 | } |
---|
2671 | |
---|
2672 | Void TComDataCU::deriveLeftRightTopIdx ( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2673 | { |
---|
2674 | ruiPartIdxLT = m_uiAbsIdxInLCU; |
---|
2675 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2676 | |
---|
2677 | switch ( m_pePartSize[0] ) |
---|
2678 | { |
---|
2679 | case SIZE_2Nx2N: break; |
---|
2680 | case SIZE_2NxN: |
---|
2681 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2682 | break; |
---|
2683 | case SIZE_Nx2N: |
---|
2684 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
2685 | break; |
---|
2686 | case SIZE_NxN: |
---|
2687 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2688 | break; |
---|
2689 | case SIZE_2NxnU: |
---|
2690 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2691 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2692 | break; |
---|
2693 | case SIZE_2NxnD: |
---|
2694 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2695 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2696 | break; |
---|
2697 | case SIZE_nLx2N: |
---|
2698 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
---|
2699 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2700 | break; |
---|
2701 | case SIZE_nRx2N: |
---|
2702 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2703 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
---|
2704 | break; |
---|
2705 | default: |
---|
2706 | assert (0); |
---|
2707 | break; |
---|
2708 | } |
---|
2709 | |
---|
2710 | } |
---|
2711 | |
---|
2712 | Void TComDataCU::deriveLeftBottomIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2713 | { |
---|
2714 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
2715 | |
---|
2716 | switch ( m_pePartSize[0] ) |
---|
2717 | { |
---|
2718 | case SIZE_2Nx2N: |
---|
2719 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
2720 | break; |
---|
2721 | case SIZE_2NxN: |
---|
2722 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2723 | break; |
---|
2724 | case SIZE_Nx2N: |
---|
2725 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
2726 | break; |
---|
2727 | case SIZE_NxN: |
---|
2728 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2729 | break; |
---|
2730 | case SIZE_2NxnU: |
---|
2731 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
2732 | break; |
---|
2733 | case SIZE_2NxnD: |
---|
2734 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
2735 | break; |
---|
2736 | case SIZE_nLx2N: |
---|
2737 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
---|
2738 | break; |
---|
2739 | case SIZE_nRx2N: |
---|
2740 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2741 | break; |
---|
2742 | default: |
---|
2743 | assert (0); |
---|
2744 | break; |
---|
2745 | } |
---|
2746 | } |
---|
2747 | |
---|
2748 | /** Derives the partition index of neighbouring bottom right block |
---|
2749 | * \param [in] eCUMode |
---|
2750 | * \param [in] uiPartIdx |
---|
2751 | * \param [out] ruiPartIdxRB |
---|
2752 | */ |
---|
2753 | Void TComDataCU::deriveRightBottomIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxRB ) |
---|
2754 | { |
---|
2755 | 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]; |
---|
2756 | |
---|
2757 | switch ( m_pePartSize[0] ) |
---|
2758 | { |
---|
2759 | case SIZE_2Nx2N: |
---|
2760 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
2761 | break; |
---|
2762 | case SIZE_2NxN: |
---|
2763 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2764 | break; |
---|
2765 | case SIZE_Nx2N: |
---|
2766 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
2767 | break; |
---|
2768 | case SIZE_NxN: |
---|
2769 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2770 | break; |
---|
2771 | case SIZE_2NxnU: |
---|
2772 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
2773 | break; |
---|
2774 | case SIZE_2NxnD: |
---|
2775 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
2776 | break; |
---|
2777 | case SIZE_nLx2N: |
---|
2778 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
---|
2779 | break; |
---|
2780 | case SIZE_nRx2N: |
---|
2781 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
---|
2782 | break; |
---|
2783 | default: |
---|
2784 | assert (0); |
---|
2785 | break; |
---|
2786 | } |
---|
2787 | } |
---|
2788 | |
---|
2789 | Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ) |
---|
2790 | { |
---|
2791 | UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; |
---|
2792 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset; |
---|
2793 | ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; |
---|
2794 | } |
---|
2795 | |
---|
2796 | Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ) |
---|
2797 | { |
---|
2798 | UInt uiAbsIdx; |
---|
2799 | UInt uiMinCuWidth, uiWidthInMinCus; |
---|
2800 | |
---|
2801 | uiMinCuWidth = getPic()->getMinCUWidth(); |
---|
2802 | uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; |
---|
2803 | uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; |
---|
2804 | uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); |
---|
2805 | ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; |
---|
2806 | } |
---|
2807 | |
---|
2808 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
2809 | { |
---|
2810 | |
---|
2811 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
2812 | { |
---|
2813 | return false; |
---|
2814 | } |
---|
2815 | |
---|
2816 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
2817 | { |
---|
2818 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
2819 | { |
---|
2820 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
2821 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
2822 | { |
---|
2823 | return false; |
---|
2824 | } |
---|
2825 | } |
---|
2826 | } |
---|
2827 | |
---|
2828 | return true; |
---|
2829 | } |
---|
2830 | |
---|
2831 | /** Constructs a list of merging candidates |
---|
2832 | * \param uiAbsPartIdx |
---|
2833 | * \param uiPUIdx |
---|
2834 | * \param uiDepth |
---|
2835 | * \param pcMvFieldNeighbours |
---|
2836 | * \param puhInterDirNeighbours |
---|
2837 | * \param numValidMergeCand |
---|
2838 | */ |
---|
2839 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) |
---|
2840 | { |
---|
2841 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
2842 | UInt uiIdx = 1; |
---|
2843 | bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
2844 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
2845 | { |
---|
2846 | abCandIsInter[ui] = false; |
---|
2847 | } |
---|
2848 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
2849 | // compute the location of the current PU |
---|
2850 | Int xP, yP, nPSW, nPSH; |
---|
2851 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
2852 | |
---|
2853 | Int iCount = 0; |
---|
2854 | |
---|
2855 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
2856 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
2857 | deriveLeftRightTopIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
2858 | deriveLeftBottomIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
2859 | |
---|
2860 | #if SVC_MVP |
---|
2861 | // BL collocated |
---|
2862 | TComDataCU *pcColCU = 0; |
---|
2863 | UInt uiCUAddrBase, uiAbsPartAddrBase ; |
---|
2864 | TComMvField cMvFieldBaseColCU[2]; |
---|
2865 | if(m_layerId) |
---|
2866 | { |
---|
2867 | UInt uiPartIdxCenter; |
---|
2868 | xDeriveCenterIdx( cCurPS, uiPUIdx, uiPartIdxCenter ); |
---|
2869 | uiPartIdxCenter -= m_uiAbsIdxInLCU; |
---|
2870 | pcColCU = getBaseColCU( uiPartIdxCenter, uiCUAddrBase, uiAbsPartAddrBase ); |
---|
2871 | |
---|
2872 | #if INTRA_BL |
---|
2873 | if( pcColCU && pcColCU->isIntraBL( uiAbsPartAddrBase ) ) |
---|
2874 | { |
---|
2875 | pcColCU = NULL; |
---|
2876 | } |
---|
2877 | #endif |
---|
2878 | |
---|
2879 | if(pcColCU && !pcColCU->isIntra( uiAbsPartAddrBase ) ) |
---|
2880 | { |
---|
2881 | abCandIsInter[iCount] = true; |
---|
2882 | |
---|
2883 | // get interDir |
---|
2884 | puhInterDirNeighbours[iCount] = pcColCU->getInterDir( uiAbsPartAddrBase ); |
---|
2885 | |
---|
2886 | pcMvFieldNeighbours[(iCount << 1)].setMvField( TComMv(0,0), -1); |
---|
2887 | pcMvFieldNeighbours[(iCount << 1) + 1].setMvField( TComMv(0,0), -1); |
---|
2888 | |
---|
2889 | if( puhInterDirNeighbours[iCount] & 1 ) |
---|
2890 | { |
---|
2891 | pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_0, cMvFieldBaseColCU[0]); |
---|
2892 | scaleBaseMV( pcMvFieldNeighbours[iCount<<1], cMvFieldBaseColCU[0] ); |
---|
2893 | } |
---|
2894 | |
---|
2895 | if ( getSlice()->isInterB() && puhInterDirNeighbours[iCount] & 2 ) |
---|
2896 | { |
---|
2897 | pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_1, cMvFieldBaseColCU[1] ); |
---|
2898 | scaleBaseMV( pcMvFieldNeighbours[(iCount<<1)+1], cMvFieldBaseColCU[1] ); |
---|
2899 | } |
---|
2900 | |
---|
2901 | if( puhInterDirNeighbours[iCount] > 0 ) |
---|
2902 | { |
---|
2903 | if ( mrgCandIdx == iCount ) |
---|
2904 | { |
---|
2905 | return; |
---|
2906 | } |
---|
2907 | iCount ++; |
---|
2908 | } |
---|
2909 | } |
---|
2910 | } |
---|
2911 | #endif |
---|
2912 | |
---|
2913 | //left |
---|
2914 | UInt uiLeftPartIdx = 0; |
---|
2915 | TComDataCU* pcCULeft = 0; |
---|
2916 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB, true, false ); |
---|
2917 | #if INTRA_BL |
---|
2918 | if( pcCULeft && pcCULeft->isIntraBL( uiLeftPartIdx ) ) |
---|
2919 | { |
---|
2920 | pcCULeft = NULL; |
---|
2921 | } |
---|
2922 | #endif |
---|
2923 | if (pcCULeft) |
---|
2924 | { |
---|
2925 | if (!pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP)) |
---|
2926 | { |
---|
2927 | pcCULeft = NULL; |
---|
2928 | } |
---|
2929 | } |
---|
2930 | PartSize partSize = getPartitionSize( uiAbsPartIdx ); |
---|
2931 | if (!(uiPUIdx == 1 && (partSize == SIZE_Nx2N || partSize == SIZE_nLx2N || partSize == SIZE_nRx2N))) |
---|
2932 | { |
---|
2933 | #if SVC_MVP |
---|
2934 | if ( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx ) && ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0]))) |
---|
2935 | #else |
---|
2936 | if ( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx ) ) |
---|
2937 | #endif |
---|
2938 | { |
---|
2939 | abCandIsInter[iCount] = true; |
---|
2940 | // get Inter Dir |
---|
2941 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
2942 | // get Mv from Left |
---|
2943 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2944 | if ( getSlice()->isInterB() ) |
---|
2945 | { |
---|
2946 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2947 | } |
---|
2948 | if ( mrgCandIdx == iCount ) |
---|
2949 | { |
---|
2950 | return; |
---|
2951 | } |
---|
2952 | iCount ++; |
---|
2953 | } |
---|
2954 | } |
---|
2955 | |
---|
2956 | // early termination |
---|
2957 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2958 | { |
---|
2959 | return; |
---|
2960 | } |
---|
2961 | // above |
---|
2962 | UInt uiAbovePartIdx = 0; |
---|
2963 | TComDataCU* pcCUAbove = 0; |
---|
2964 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT, true, false, true ); |
---|
2965 | #if INTRA_BL |
---|
2966 | if( pcCUAbove && pcCUAbove->isIntraBL( uiAbovePartIdx ) ) |
---|
2967 | { |
---|
2968 | pcCUAbove = NULL; |
---|
2969 | } |
---|
2970 | #endif |
---|
2971 | if (pcCUAbove) |
---|
2972 | { |
---|
2973 | if (!pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP)) |
---|
2974 | { |
---|
2975 | pcCUAbove = NULL; |
---|
2976 | } |
---|
2977 | } |
---|
2978 | #if SVC_MVP |
---|
2979 | if ( pcCUAbove && !pcCUAbove->isIntra( uiAbovePartIdx ) |
---|
2980 | && !(uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD)) |
---|
2981 | && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) |
---|
2982 | && ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) ) |
---|
2983 | #else |
---|
2984 | if ( pcCUAbove && !pcCUAbove->isIntra( uiAbovePartIdx ) |
---|
2985 | && !(uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD)) |
---|
2986 | && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
2987 | #endif |
---|
2988 | { |
---|
2989 | abCandIsInter[iCount] = true; |
---|
2990 | // get Inter Dir |
---|
2991 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
2992 | // get Mv from Left |
---|
2993 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2994 | if ( getSlice()->isInterB() ) |
---|
2995 | { |
---|
2996 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2997 | } |
---|
2998 | if ( mrgCandIdx == iCount ) |
---|
2999 | { |
---|
3000 | return; |
---|
3001 | } |
---|
3002 | iCount ++; |
---|
3003 | } |
---|
3004 | // early termination |
---|
3005 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3006 | { |
---|
3007 | return; |
---|
3008 | } |
---|
3009 | |
---|
3010 | // above right |
---|
3011 | UInt uiAboveRightPartIdx = 0; |
---|
3012 | TComDataCU* pcCUAboveRight = 0; |
---|
3013 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT, true, false, true ); |
---|
3014 | if (pcCUAboveRight) |
---|
3015 | { |
---|
3016 | if (!pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP)) |
---|
3017 | { |
---|
3018 | pcCUAboveRight = NULL; |
---|
3019 | } |
---|
3020 | } |
---|
3021 | #if SVC_MVP |
---|
3022 | if ( pcCUAboveRight && !pcCUAboveRight->isIntra( uiAboveRightPartIdx ) && ( !pcCUAbove || pcCUAbove->isIntra( uiAbovePartIdx ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) |
---|
3023 | && ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveRight->hasEqualMotion( uiAboveRightPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) ) |
---|
3024 | #else |
---|
3025 | if ( pcCUAboveRight && !pcCUAboveRight->isIntra( uiAboveRightPartIdx ) && ( !pcCUAbove || pcCUAbove->isIntra( uiAbovePartIdx ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
3026 | #endif |
---|
3027 | { |
---|
3028 | abCandIsInter[iCount] = true; |
---|
3029 | // get Inter Dir |
---|
3030 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
3031 | // get Mv from Left |
---|
3032 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3033 | if ( getSlice()->isInterB() ) |
---|
3034 | { |
---|
3035 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3036 | } |
---|
3037 | if ( mrgCandIdx == iCount ) |
---|
3038 | { |
---|
3039 | return; |
---|
3040 | } |
---|
3041 | iCount ++; |
---|
3042 | } |
---|
3043 | // early termination |
---|
3044 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3045 | { |
---|
3046 | return; |
---|
3047 | } |
---|
3048 | |
---|
3049 | //left bottom |
---|
3050 | #if SVC_MVP |
---|
3051 | if( iCount < 4 ) |
---|
3052 | { |
---|
3053 | #endif |
---|
3054 | UInt uiLeftBottomPartIdx = 0; |
---|
3055 | TComDataCU* pcCULeftBottom = 0; |
---|
3056 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB, true, false ); |
---|
3057 | if (pcCULeftBottom) |
---|
3058 | { |
---|
3059 | if (!pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP)) |
---|
3060 | { |
---|
3061 | pcCULeftBottom = NULL; |
---|
3062 | } |
---|
3063 | } |
---|
3064 | #if SVC_MVP |
---|
3065 | if ( pcCULeftBottom && !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) |
---|
3066 | && ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeftBottom->hasEqualMotion( uiLeftBottomPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) ) |
---|
3067 | #else |
---|
3068 | if ( pcCULeftBottom && !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
3069 | #endif |
---|
3070 | { |
---|
3071 | abCandIsInter[iCount] = true; |
---|
3072 | // get Inter Dir |
---|
3073 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
3074 | // get Mv from Left |
---|
3075 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3076 | if ( getSlice()->isInterB() ) |
---|
3077 | { |
---|
3078 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3079 | } |
---|
3080 | if ( mrgCandIdx == iCount ) |
---|
3081 | { |
---|
3082 | return; |
---|
3083 | } |
---|
3084 | iCount ++; |
---|
3085 | } |
---|
3086 | // early termination |
---|
3087 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3088 | { |
---|
3089 | return; |
---|
3090 | } |
---|
3091 | #if SVC_MVP |
---|
3092 | } |
---|
3093 | #endif |
---|
3094 | |
---|
3095 | // above left |
---|
3096 | if( iCount < 4 ) |
---|
3097 | { |
---|
3098 | UInt uiAboveLeftPartIdx = 0; |
---|
3099 | TComDataCU* pcCUAboveLeft = 0; |
---|
3100 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr, true, false, true ); |
---|
3101 | if (pcCUAboveLeft) |
---|
3102 | { |
---|
3103 | if (!pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP)) |
---|
3104 | { |
---|
3105 | pcCUAboveLeft = NULL; |
---|
3106 | } |
---|
3107 | } |
---|
3108 | #if SVC_MVP |
---|
3109 | if( pcCUAboveLeft && !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ) |
---|
3110 | && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
3111 | && ( !pcCUAbove || pcCUAbove->isIntra( uiAbovePartIdx ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
3112 | && ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveLeft->hasEqualMotion( uiAboveLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) |
---|
3113 | ) |
---|
3114 | #else |
---|
3115 | if( pcCUAboveLeft && !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ) |
---|
3116 | && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
3117 | && ( !pcCUAbove || pcCUAbove->isIntra( uiAbovePartIdx ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
3118 | ) |
---|
3119 | #endif |
---|
3120 | { |
---|
3121 | abCandIsInter[iCount] = true; |
---|
3122 | // get Inter Dir |
---|
3123 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
3124 | // get Mv from Left |
---|
3125 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3126 | if ( getSlice()->isInterB() ) |
---|
3127 | { |
---|
3128 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3129 | } |
---|
3130 | if ( mrgCandIdx == iCount ) |
---|
3131 | { |
---|
3132 | return; |
---|
3133 | } |
---|
3134 | iCount ++; |
---|
3135 | } |
---|
3136 | } |
---|
3137 | // early termination |
---|
3138 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3139 | { |
---|
3140 | return; |
---|
3141 | } |
---|
3142 | if ( getSlice()->getEnableTMVPFlag()) |
---|
3143 | { |
---|
3144 | //>> MTK colocated-RightBottom |
---|
3145 | UInt uiPartIdxRB; |
---|
3146 | Int uiLCUIdx = getAddr(); |
---|
3147 | PartSize eCUMode = getPartitionSize( 0 ); |
---|
3148 | |
---|
3149 | deriveRightBottomIdx( eCUMode, uiPUIdx, uiPartIdxRB ); |
---|
3150 | |
---|
3151 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
3152 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
3153 | |
---|
3154 | TComMv cColMv; |
---|
3155 | Int iRefIdx; |
---|
3156 | |
---|
3157 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
3158 | { |
---|
3159 | uiLCUIdx = -1; |
---|
3160 | } |
---|
3161 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
3162 | { |
---|
3163 | uiLCUIdx = -1; |
---|
3164 | } |
---|
3165 | else |
---|
3166 | { |
---|
3167 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
3168 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
3169 | { |
---|
3170 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
3171 | uiLCUIdx = getAddr(); |
---|
3172 | } |
---|
3173 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
3174 | { |
---|
3175 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
3176 | uiLCUIdx = -1 ; |
---|
3177 | } |
---|
3178 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
3179 | { |
---|
3180 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
3181 | uiLCUIdx = getAddr() + 1; |
---|
3182 | } |
---|
3183 | else //is the right bottom corner of LCU |
---|
3184 | { |
---|
3185 | uiAbsPartAddr = 0; |
---|
3186 | uiLCUIdx = -1 ; |
---|
3187 | } |
---|
3188 | } |
---|
3189 | iRefIdx = 0; |
---|
3190 | |
---|
3191 | Bool bExistMV = false; |
---|
3192 | UInt uiPartIdxCenter; |
---|
3193 | UInt uiCurLCUIdx = getAddr(); |
---|
3194 | xDeriveCenterIdx( eCUMode, uiPUIdx, uiPartIdxCenter ); |
---|
3195 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
3196 | if( bExistMV == false ) |
---|
3197 | { |
---|
3198 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
3199 | } |
---|
3200 | if( bExistMV ) |
---|
3201 | { |
---|
3202 | UInt uiArrayAddr = iCount; |
---|
3203 | abCandIsInter[uiArrayAddr] = true; |
---|
3204 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( cColMv, iRefIdx ); |
---|
3205 | |
---|
3206 | if ( getSlice()->isInterB() ) |
---|
3207 | { |
---|
3208 | iRefIdx = 0; |
---|
3209 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
3210 | if( bExistMV == false ) |
---|
3211 | { |
---|
3212 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
3213 | } |
---|
3214 | if( bExistMV ) |
---|
3215 | { |
---|
3216 | pcMvFieldNeighbours[ ( uiArrayAddr << 1 ) + 1 ].setMvField( cColMv, iRefIdx ); |
---|
3217 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3218 | } |
---|
3219 | else |
---|
3220 | { |
---|
3221 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
3222 | } |
---|
3223 | } |
---|
3224 | else |
---|
3225 | { |
---|
3226 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
3227 | } |
---|
3228 | if ( mrgCandIdx == iCount ) |
---|
3229 | { |
---|
3230 | return; |
---|
3231 | } |
---|
3232 | iCount++; |
---|
3233 | } |
---|
3234 | uiIdx++; |
---|
3235 | |
---|
3236 | } |
---|
3237 | // early termination |
---|
3238 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3239 | { |
---|
3240 | return; |
---|
3241 | } |
---|
3242 | UInt uiArrayAddr = iCount; |
---|
3243 | UInt uiCutoff = uiArrayAddr; |
---|
3244 | |
---|
3245 | if ( getSlice()->isInterB()) |
---|
3246 | { |
---|
3247 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
3248 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
3249 | |
---|
3250 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
3251 | { |
---|
3252 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
3253 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
3254 | { |
---|
3255 | abCandIsInter[uiArrayAddr] = true; |
---|
3256 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3257 | |
---|
3258 | // get Mv from cand[i] and cand[j] |
---|
3259 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
3260 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
3261 | |
---|
3262 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
3263 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
3264 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
3265 | { |
---|
3266 | abCandIsInter[uiArrayAddr] = false; |
---|
3267 | } |
---|
3268 | else |
---|
3269 | { |
---|
3270 | uiArrayAddr++; |
---|
3271 | } |
---|
3272 | } |
---|
3273 | } |
---|
3274 | } |
---|
3275 | // early termination |
---|
3276 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
3277 | { |
---|
3278 | return; |
---|
3279 | } |
---|
3280 | 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); |
---|
3281 | Int r = 0; |
---|
3282 | Int refcnt = 0; |
---|
3283 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
3284 | { |
---|
3285 | abCandIsInter[uiArrayAddr] = true; |
---|
3286 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
3287 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
3288 | |
---|
3289 | if ( getSlice()->isInterB() ) |
---|
3290 | { |
---|
3291 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3292 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
3293 | } |
---|
3294 | uiArrayAddr++; |
---|
3295 | if ( refcnt == iNumRefIdx - 1 ) |
---|
3296 | { |
---|
3297 | r = 0; |
---|
3298 | } |
---|
3299 | else |
---|
3300 | { |
---|
3301 | ++r; |
---|
3302 | ++refcnt; |
---|
3303 | } |
---|
3304 | } |
---|
3305 | |
---|
3306 | numValidMergeCand = uiArrayAddr; |
---|
3307 | } |
---|
3308 | |
---|
3309 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
---|
3310 | * \param xN, xN location of the upper-left corner pixel of a neighboring PU |
---|
3311 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
3312 | * \returns Bool |
---|
3313 | */ |
---|
3314 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) |
---|
3315 | { |
---|
3316 | |
---|
3317 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
---|
3318 | if ((xN>>plevel)!= (xP>>plevel)) |
---|
3319 | { |
---|
3320 | return true; |
---|
3321 | } |
---|
3322 | if ((yN>>plevel)!= (yP>>plevel)) |
---|
3323 | { |
---|
3324 | return true; |
---|
3325 | } |
---|
3326 | return false; |
---|
3327 | } |
---|
3328 | /** calculate the location of upper-left corner pixel and size of the current PU. |
---|
3329 | * \param partIdx PU index within a CU |
---|
3330 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
3331 | * \param PSW, nPSH size of the curren PU |
---|
3332 | * \returns Void |
---|
3333 | */ |
---|
3334 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) |
---|
3335 | { |
---|
3336 | UInt col = m_uiCUPelX; |
---|
3337 | UInt row = m_uiCUPelY; |
---|
3338 | |
---|
3339 | switch ( m_pePartSize[0] ) |
---|
3340 | { |
---|
3341 | case SIZE_2NxN: |
---|
3342 | nPSW = getWidth(0); |
---|
3343 | nPSH = getHeight(0) >> 1; |
---|
3344 | xP = col; |
---|
3345 | yP = (partIdx ==0)? row: row + nPSH; |
---|
3346 | break; |
---|
3347 | case SIZE_Nx2N: |
---|
3348 | nPSW = getWidth(0) >> 1; |
---|
3349 | nPSH = getHeight(0); |
---|
3350 | xP = (partIdx ==0)? col: col + nPSW; |
---|
3351 | yP = row; |
---|
3352 | break; |
---|
3353 | case SIZE_NxN: |
---|
3354 | nPSW = getWidth(0) >> 1; |
---|
3355 | nPSH = getHeight(0) >> 1; |
---|
3356 | xP = col + (partIdx&0x1)*nPSW; |
---|
3357 | yP = row + (partIdx>>1)*nPSH; |
---|
3358 | break; |
---|
3359 | case SIZE_2NxnU: |
---|
3360 | nPSW = getWidth(0); |
---|
3361 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
3362 | xP = col; |
---|
3363 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
3364 | |
---|
3365 | break; |
---|
3366 | case SIZE_2NxnD: |
---|
3367 | nPSW = getWidth(0); |
---|
3368 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
3369 | xP = col; |
---|
3370 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
3371 | break; |
---|
3372 | case SIZE_nLx2N: |
---|
3373 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
3374 | nPSH = getHeight(0); |
---|
3375 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
3376 | yP = row; |
---|
3377 | break; |
---|
3378 | case SIZE_nRx2N: |
---|
3379 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
3380 | nPSH = getHeight(0); |
---|
3381 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
3382 | yP = row; |
---|
3383 | break; |
---|
3384 | default: |
---|
3385 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
3386 | nPSW = getWidth(0); |
---|
3387 | nPSH = getHeight(0); |
---|
3388 | xP = col ; |
---|
3389 | yP = row ; |
---|
3390 | |
---|
3391 | break; |
---|
3392 | } |
---|
3393 | } |
---|
3394 | |
---|
3395 | #if !SPS_AMVP_CLEANUP |
---|
3396 | AMVP_MODE TComDataCU::getAMVPMode(UInt uiIdx) |
---|
3397 | { |
---|
3398 | return m_pcSlice->getSPS()->getAMVPMode(m_puhDepth[uiIdx]); |
---|
3399 | } |
---|
3400 | #endif |
---|
3401 | |
---|
3402 | /** Constructs a list of candidates for AMVP |
---|
3403 | * \param uiPartIdx |
---|
3404 | * \param uiPartAddr |
---|
3405 | * \param eRefPicList |
---|
3406 | * \param iRefIdx |
---|
3407 | * \param pInfo |
---|
3408 | */ |
---|
3409 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
---|
3410 | { |
---|
3411 | PartSize eCUMode = getPartitionSize( 0 ); |
---|
3412 | |
---|
3413 | TComMv cMvPred; |
---|
3414 | Bool bAddedSmvp = false; |
---|
3415 | |
---|
3416 | pInfo->iN = 0; |
---|
3417 | if (iRefIdx < 0) |
---|
3418 | { |
---|
3419 | return; |
---|
3420 | } |
---|
3421 | |
---|
3422 | //-- Get Spatial MV |
---|
3423 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
3424 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
3425 | Bool bAdded = false; |
---|
3426 | |
---|
3427 | deriveLeftRightTopIdx( eCUMode, uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
3428 | deriveLeftBottomIdx( eCUMode, uiPartIdx, uiPartIdxLB ); |
---|
3429 | |
---|
3430 | TComDataCU* tmpCU = NULL; |
---|
3431 | UInt idx; |
---|
3432 | tmpCU = getPUBelowLeft(idx, uiPartIdxLB, true, false); |
---|
3433 | #if INTRA_BL |
---|
3434 | bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx)); |
---|
3435 | #else |
---|
3436 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
3437 | #endif |
---|
3438 | |
---|
3439 | if (!bAddedSmvp) |
---|
3440 | { |
---|
3441 | tmpCU = getPULeft(idx, uiPartIdxLB, true, false); |
---|
3442 | #if INTRA_BL |
---|
3443 | bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx)); |
---|
3444 | #else |
---|
3445 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
3446 | #endif |
---|
3447 | } |
---|
3448 | |
---|
3449 | // Left predictor search |
---|
3450 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
3451 | if (!bAdded) |
---|
3452 | { |
---|
3453 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
3454 | } |
---|
3455 | |
---|
3456 | if(!bAdded) |
---|
3457 | { |
---|
3458 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
3459 | if (!bAdded) |
---|
3460 | { |
---|
3461 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
3462 | } |
---|
3463 | } |
---|
3464 | // Above predictor search |
---|
3465 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
3466 | |
---|
3467 | if (!bAdded) |
---|
3468 | { |
---|
3469 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
3470 | } |
---|
3471 | |
---|
3472 | if(!bAdded) |
---|
3473 | { |
---|
3474 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
3475 | } |
---|
3476 | bAdded = bAddedSmvp; |
---|
3477 | if (pInfo->iN==2) bAdded = true; |
---|
3478 | |
---|
3479 | if(!bAdded) |
---|
3480 | { |
---|
3481 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
3482 | if (!bAdded) |
---|
3483 | { |
---|
3484 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
3485 | } |
---|
3486 | |
---|
3487 | if(!bAdded) |
---|
3488 | { |
---|
3489 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
3490 | } |
---|
3491 | } |
---|
3492 | |
---|
3493 | #if !SPS_AMVP_CLEANUP |
---|
3494 | if (getAMVPMode(uiPartAddr) == AM_NONE) //Should be optimized later for special cases |
---|
3495 | { |
---|
3496 | assert(pInfo->iN > 0); |
---|
3497 | pInfo->iN = 1; |
---|
3498 | return; |
---|
3499 | } |
---|
3500 | #endif |
---|
3501 | |
---|
3502 | if ( pInfo->iN == 2 ) |
---|
3503 | { |
---|
3504 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
---|
3505 | { |
---|
3506 | pInfo->iN = 1; |
---|
3507 | } |
---|
3508 | } |
---|
3509 | |
---|
3510 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
3511 | { |
---|
3512 | // Get Temporal Motion Predictor |
---|
3513 | int iRefIdx_Col = iRefIdx; |
---|
3514 | TComMv cColMv; |
---|
3515 | UInt uiPartIdxRB; |
---|
3516 | UInt uiAbsPartIdx; |
---|
3517 | UInt uiAbsPartAddr; |
---|
3518 | int uiLCUIdx = getAddr(); |
---|
3519 | |
---|
3520 | deriveRightBottomIdx( eCUMode, uiPartIdx, uiPartIdxRB ); |
---|
3521 | uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
---|
3522 | |
---|
3523 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
3524 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
---|
3525 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
3526 | { |
---|
3527 | uiLCUIdx = -1; |
---|
3528 | } |
---|
3529 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
3530 | { |
---|
3531 | uiLCUIdx = -1; |
---|
3532 | } |
---|
3533 | else |
---|
3534 | { |
---|
3535 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
3536 | ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
3537 | { |
---|
3538 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; |
---|
3539 | uiLCUIdx = getAddr(); |
---|
3540 | } |
---|
3541 | else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
3542 | { |
---|
3543 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
3544 | uiLCUIdx = -1 ; |
---|
3545 | } |
---|
3546 | else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
3547 | { |
---|
3548 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
---|
3549 | uiLCUIdx = getAddr() + 1; |
---|
3550 | } |
---|
3551 | else //is the right bottom corner of LCU |
---|
3552 | { |
---|
3553 | uiAbsPartAddr = 0; |
---|
3554 | uiLCUIdx = -1 ; |
---|
3555 | } |
---|
3556 | } |
---|
3557 | if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col ) ) |
---|
3558 | { |
---|
3559 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
3560 | } |
---|
3561 | else |
---|
3562 | { |
---|
3563 | UInt uiPartIdxCenter; |
---|
3564 | UInt uiCurLCUIdx = getAddr(); |
---|
3565 | xDeriveCenterIdx( eCUMode, uiPartIdx, uiPartIdxCenter ); |
---|
3566 | if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col )) |
---|
3567 | { |
---|
3568 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
3569 | } |
---|
3570 | } |
---|
3571 | //---- co-located RightBottom Temporal Predictor ---// |
---|
3572 | } |
---|
3573 | |
---|
3574 | if (pInfo->iN > AMVP_MAX_NUM_CANDS) |
---|
3575 | { |
---|
3576 | pInfo->iN = AMVP_MAX_NUM_CANDS; |
---|
3577 | } |
---|
3578 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
---|
3579 | { |
---|
3580 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
---|
3581 | pInfo->iN++; |
---|
3582 | } |
---|
3583 | return ; |
---|
3584 | } |
---|
3585 | |
---|
3586 | Bool TComDataCU::isBipredRestriction(UInt puIdx) |
---|
3587 | { |
---|
3588 | Int width = 0; |
---|
3589 | Int height = 0; |
---|
3590 | UInt partAddr; |
---|
3591 | |
---|
3592 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
---|
3593 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
---|
3594 | { |
---|
3595 | return true; |
---|
3596 | } |
---|
3597 | return false; |
---|
3598 | } |
---|
3599 | |
---|
3600 | Void TComDataCU::clipMv (TComMv& rcMv) |
---|
3601 | { |
---|
3602 | Int iMvShift = 2; |
---|
3603 | Int iOffset = 8; |
---|
3604 | Int iHorMax = ( m_pcSlice->getSPS()->getPicWidthInLumaSamples() + iOffset - m_uiCUPelX - 1 ) << iMvShift; |
---|
3605 | Int iHorMin = ( -(Int)g_uiMaxCUWidth - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
---|
3606 | |
---|
3607 | Int iVerMax = ( m_pcSlice->getSPS()->getPicHeightInLumaSamples() + iOffset - m_uiCUPelY - 1 ) << iMvShift; |
---|
3608 | Int iVerMin = ( -(Int)g_uiMaxCUHeight - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
---|
3609 | |
---|
3610 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
---|
3611 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
---|
3612 | } |
---|
3613 | |
---|
3614 | |
---|
3615 | Void TComDataCU::convertTransIdx( UInt uiAbsPartIdx, UInt uiTrIdx, UInt& ruiLumaTrMode, UInt& ruiChromaTrMode ) |
---|
3616 | { |
---|
3617 | ruiLumaTrMode = uiTrIdx; |
---|
3618 | ruiChromaTrMode = uiTrIdx; |
---|
3619 | return; |
---|
3620 | } |
---|
3621 | |
---|
3622 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
---|
3623 | { |
---|
3624 | UInt uiShift = ( (m_puhTrIdx[uiAbsPartIdx]==0) && (m_pePartSize[uiAbsPartIdx]==SIZE_NxN) ) ? m_puhTrIdx[uiAbsPartIdx]+1 : m_puhTrIdx[uiAbsPartIdx]; |
---|
3625 | uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
3626 | |
---|
3627 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
3628 | UInt uiCnt = 0; |
---|
3629 | while( uiWidth ) |
---|
3630 | { |
---|
3631 | uiCnt++; |
---|
3632 | uiWidth>>=1; |
---|
3633 | } |
---|
3634 | uiCnt-=2; |
---|
3635 | return uiCnt > 6 ? 6 : uiCnt; |
---|
3636 | } |
---|
3637 | |
---|
3638 | Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts ) |
---|
3639 | { |
---|
3640 | ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
3641 | } |
---|
3642 | |
---|
3643 | /** Set a I_PCM flag for all sub-partitions of a partition. |
---|
3644 | * \param bIpcmFlag I_PCM flag |
---|
3645 | * \param uiAbsPartIdx patition index |
---|
3646 | * \param uiDepth CU depth |
---|
3647 | * \returns Void |
---|
3648 | */ |
---|
3649 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
---|
3650 | { |
---|
3651 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
3652 | |
---|
3653 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
---|
3654 | } |
---|
3655 | |
---|
3656 | /** Test whether the current block is skipped |
---|
3657 | * \param uiPartIdx Block index |
---|
3658 | * \returns Flag indicating whether the block is skipped |
---|
3659 | */ |
---|
3660 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
---|
3661 | { |
---|
3662 | #if SKIP_FLAG |
---|
3663 | return ( getSkipFlag( uiPartIdx ) ); |
---|
3664 | #else |
---|
3665 | if ( m_pcSlice->isIntra () ) |
---|
3666 | { |
---|
3667 | return false; |
---|
3668 | } |
---|
3669 | return ( getMergeFlag( uiPartIdx ) && getPartitionSize( uiPartIdx ) == SIZE_2Nx2N && !getQtRootCbf( uiPartIdx ) ); |
---|
3670 | #endif |
---|
3671 | } |
---|
3672 | |
---|
3673 | // ==================================================================================================================== |
---|
3674 | // Protected member functions |
---|
3675 | // ==================================================================================================================== |
---|
3676 | |
---|
3677 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
3678 | { |
---|
3679 | TComDataCU* pcTmpCU = NULL; |
---|
3680 | UInt uiIdx; |
---|
3681 | switch( eDir ) |
---|
3682 | { |
---|
3683 | case MD_LEFT: |
---|
3684 | { |
---|
3685 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx, true, false); |
---|
3686 | break; |
---|
3687 | } |
---|
3688 | case MD_ABOVE: |
---|
3689 | { |
---|
3690 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3691 | break; |
---|
3692 | } |
---|
3693 | case MD_ABOVE_RIGHT: |
---|
3694 | { |
---|
3695 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3696 | break; |
---|
3697 | } |
---|
3698 | case MD_BELOW_LEFT: |
---|
3699 | { |
---|
3700 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx, true, false); |
---|
3701 | break; |
---|
3702 | } |
---|
3703 | case MD_ABOVE_LEFT: |
---|
3704 | { |
---|
3705 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3706 | break; |
---|
3707 | } |
---|
3708 | default: |
---|
3709 | { |
---|
3710 | break; |
---|
3711 | } |
---|
3712 | } |
---|
3713 | |
---|
3714 | if ( pcTmpCU != NULL && m_pcSlice->isEqualRef(eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx), iRefIdx) ) |
---|
3715 | { |
---|
3716 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
3717 | |
---|
3718 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
3719 | return true; |
---|
3720 | } |
---|
3721 | |
---|
3722 | if ( pcTmpCU == NULL ) |
---|
3723 | { |
---|
3724 | return false; |
---|
3725 | } |
---|
3726 | |
---|
3727 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
3728 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
3729 | { |
---|
3730 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
3731 | } |
---|
3732 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
3733 | { |
---|
3734 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
3735 | } |
---|
3736 | |
---|
3737 | |
---|
3738 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
3739 | Int iNeibRefPOC; |
---|
3740 | |
---|
3741 | |
---|
3742 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
---|
3743 | { |
---|
3744 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
3745 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
---|
3746 | { |
---|
3747 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
3748 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
3749 | return true; |
---|
3750 | } |
---|
3751 | } |
---|
3752 | return false; |
---|
3753 | } |
---|
3754 | |
---|
3755 | /** |
---|
3756 | * \param pInfo |
---|
3757 | * \param eRefPicList |
---|
3758 | * \param iRefIdx |
---|
3759 | * \param uiPartUnitIdx |
---|
3760 | * \param eDir |
---|
3761 | * \returns Bool |
---|
3762 | */ |
---|
3763 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
3764 | { |
---|
3765 | TComDataCU* pcTmpCU = NULL; |
---|
3766 | UInt uiIdx; |
---|
3767 | switch( eDir ) |
---|
3768 | { |
---|
3769 | case MD_LEFT: |
---|
3770 | { |
---|
3771 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx, true, false); |
---|
3772 | break; |
---|
3773 | } |
---|
3774 | case MD_ABOVE: |
---|
3775 | { |
---|
3776 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3777 | break; |
---|
3778 | } |
---|
3779 | case MD_ABOVE_RIGHT: |
---|
3780 | { |
---|
3781 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3782 | break; |
---|
3783 | } |
---|
3784 | case MD_BELOW_LEFT: |
---|
3785 | { |
---|
3786 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx, true, false); |
---|
3787 | break; |
---|
3788 | } |
---|
3789 | case MD_ABOVE_LEFT: |
---|
3790 | { |
---|
3791 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3792 | break; |
---|
3793 | } |
---|
3794 | default: |
---|
3795 | { |
---|
3796 | break; |
---|
3797 | } |
---|
3798 | } |
---|
3799 | |
---|
3800 | if ( pcTmpCU == NULL ) |
---|
3801 | { |
---|
3802 | return false; |
---|
3803 | } |
---|
3804 | |
---|
3805 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
3806 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
3807 | { |
---|
3808 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
3809 | } |
---|
3810 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
3811 | { |
---|
3812 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
3813 | } |
---|
3814 | |
---|
3815 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
3816 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
3817 | Int iNeibPOC = iCurrPOC; |
---|
3818 | Int iNeibRefPOC; |
---|
3819 | |
---|
3820 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
3821 | Bool bIsNeibRefLongTerm = false; |
---|
3822 | //--------------- V1 (END) ------------------// |
---|
3823 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
---|
3824 | { |
---|
3825 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
---|
3826 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
3827 | TComMv rcMv; |
---|
3828 | |
---|
3829 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
3830 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
3831 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
3832 | { |
---|
3833 | #endif |
---|
3834 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
3835 | { |
---|
3836 | rcMv = cMvPred; |
---|
3837 | } |
---|
3838 | else |
---|
3839 | { |
---|
3840 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
3841 | if ( iScale == 4096 ) |
---|
3842 | { |
---|
3843 | rcMv = cMvPred; |
---|
3844 | } |
---|
3845 | else |
---|
3846 | { |
---|
3847 | rcMv = cMvPred.scaleMv( iScale ); |
---|
3848 | } |
---|
3849 | } |
---|
3850 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
3851 | return true; |
---|
3852 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
3853 | } |
---|
3854 | #endif |
---|
3855 | } |
---|
3856 | //---------------------- V2(END) --------------------// |
---|
3857 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
---|
3858 | { |
---|
3859 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
3860 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
3861 | TComMv rcMv; |
---|
3862 | |
---|
3863 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
3864 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
3865 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
3866 | { |
---|
3867 | #endif |
---|
3868 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
3869 | { |
---|
3870 | rcMv = cMvPred; |
---|
3871 | } |
---|
3872 | else |
---|
3873 | { |
---|
3874 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
3875 | if ( iScale == 4096 ) |
---|
3876 | { |
---|
3877 | rcMv = cMvPred; |
---|
3878 | } |
---|
3879 | else |
---|
3880 | { |
---|
3881 | rcMv = cMvPred.scaleMv( iScale ); |
---|
3882 | } |
---|
3883 | } |
---|
3884 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
3885 | return true; |
---|
3886 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
3887 | } |
---|
3888 | #endif |
---|
3889 | } |
---|
3890 | //---------------------- V3(END) --------------------// |
---|
3891 | return false; |
---|
3892 | } |
---|
3893 | |
---|
3894 | /** |
---|
3895 | * \param eRefPicList |
---|
3896 | * \param uiCUAddr |
---|
3897 | * \param uiPartUnitIdx |
---|
3898 | * \param riRefIdx |
---|
3899 | * \returns Bool |
---|
3900 | */ |
---|
3901 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx ) |
---|
3902 | { |
---|
3903 | UInt uiAbsPartAddr = uiPartUnitIdx; |
---|
3904 | |
---|
3905 | RefPicList eColRefPicList; |
---|
3906 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
---|
3907 | TComMv cColMv; |
---|
3908 | |
---|
3909 | // use coldir. |
---|
3910 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
3911 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
3912 | if(pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE) |
---|
3913 | { |
---|
3914 | return false; |
---|
3915 | } |
---|
3916 | iCurrPOC = m_pcSlice->getPOC(); |
---|
3917 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
3918 | iColPOC = pColCU->getSlice()->getPOC(); |
---|
3919 | |
---|
3920 | if (pColCU->isIntra(uiAbsPartAddr)) |
---|
3921 | { |
---|
3922 | return false; |
---|
3923 | } |
---|
3924 | eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
---|
3925 | |
---|
3926 | Int iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
3927 | |
---|
3928 | if (iColRefIdx < 0 ) |
---|
3929 | { |
---|
3930 | eColRefPicList = RefPicList(1 - eColRefPicList); |
---|
3931 | iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
3932 | |
---|
3933 | if (iColRefIdx < 0 ) |
---|
3934 | { |
---|
3935 | return false; |
---|
3936 | } |
---|
3937 | } |
---|
3938 | |
---|
3939 | // Scale the vector. |
---|
3940 | iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
---|
3941 | cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
3942 | |
---|
3943 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
3944 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
---|
3945 | Bool bIsColRefLongTerm = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getIsUsedAsLongTerm(); |
---|
3946 | |
---|
3947 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
3948 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
3949 | { |
---|
3950 | return false; |
---|
3951 | } |
---|
3952 | #endif |
---|
3953 | |
---|
3954 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
---|
3955 | { |
---|
3956 | rcMv = cColMv; |
---|
3957 | } |
---|
3958 | else |
---|
3959 | { |
---|
3960 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
3961 | if ( iScale == 4096 ) |
---|
3962 | { |
---|
3963 | rcMv = cColMv; |
---|
3964 | } |
---|
3965 | else |
---|
3966 | { |
---|
3967 | rcMv = cColMv.scaleMv( iScale ); |
---|
3968 | } |
---|
3969 | } |
---|
3970 | return true; |
---|
3971 | } |
---|
3972 | |
---|
3973 | UInt TComDataCU::xGetMvdBits(TComMv cMvd) |
---|
3974 | { |
---|
3975 | return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) ); |
---|
3976 | } |
---|
3977 | |
---|
3978 | UInt TComDataCU::xGetComponentBits(Int iVal) |
---|
3979 | { |
---|
3980 | UInt uiLength = 1; |
---|
3981 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
3982 | |
---|
3983 | assert ( uiTemp ); |
---|
3984 | |
---|
3985 | while ( 1 != uiTemp ) |
---|
3986 | { |
---|
3987 | uiTemp >>= 1; |
---|
3988 | uiLength += 2; |
---|
3989 | } |
---|
3990 | |
---|
3991 | return uiLength; |
---|
3992 | } |
---|
3993 | |
---|
3994 | |
---|
3995 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
3996 | { |
---|
3997 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
3998 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
3999 | |
---|
4000 | if( iDiffPocD == iDiffPocB ) |
---|
4001 | { |
---|
4002 | return 4096; |
---|
4003 | } |
---|
4004 | else |
---|
4005 | { |
---|
4006 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
4007 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
4008 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
4009 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
---|
4010 | return iScale; |
---|
4011 | } |
---|
4012 | } |
---|
4013 | |
---|
4014 | /** |
---|
4015 | * \param eCUMode |
---|
4016 | * \param uiPartIdx |
---|
4017 | * \param ruiPartIdxCenter |
---|
4018 | * \returns Void |
---|
4019 | */ |
---|
4020 | Void TComDataCU::xDeriveCenterIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
---|
4021 | { |
---|
4022 | UInt uiPartAddr; |
---|
4023 | Int iPartWidth; |
---|
4024 | Int iPartHeight; |
---|
4025 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
4026 | |
---|
4027 | ruiPartIdxCenter = m_uiAbsIdxInLCU+uiPartAddr; // partition origin. |
---|
4028 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
4029 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInWidth() |
---|
4030 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
---|
4031 | } |
---|
4032 | |
---|
4033 | /** |
---|
4034 | * \param uiPartIdx |
---|
4035 | * \param eRefPicList |
---|
4036 | * \param iRefIdx |
---|
4037 | * \param pcMv |
---|
4038 | * \returns Bool |
---|
4039 | */ |
---|
4040 | Bool TComDataCU::xGetCenterCol( UInt uiPartIdx, RefPicList eRefPicList, int iRefIdx, TComMv *pcMv ) |
---|
4041 | { |
---|
4042 | PartSize eCUMode = getPartitionSize( 0 ); |
---|
4043 | |
---|
4044 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
4045 | |
---|
4046 | // use coldir. |
---|
4047 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
4048 | TComDataCU *pColCU = pColPic->getCU( m_uiCUAddr ); |
---|
4049 | |
---|
4050 | Int iColPOC = pColCU->getSlice()->getPOC(); |
---|
4051 | UInt uiPartIdxCenter; |
---|
4052 | xDeriveCenterIdx( eCUMode, uiPartIdx, uiPartIdxCenter ); |
---|
4053 | |
---|
4054 | if (pColCU->isIntra(uiPartIdxCenter)) |
---|
4055 | { |
---|
4056 | return false; |
---|
4057 | } |
---|
4058 | |
---|
4059 | // Prefer a vector crossing us. Prefer shortest. |
---|
4060 | RefPicList eColRefPicList = REF_PIC_LIST_0; |
---|
4061 | bool bFirstCrosses = false; |
---|
4062 | Int iFirstColDist = -1; |
---|
4063 | for (Int l = 0; l < 2; l++) |
---|
4064 | { |
---|
4065 | bool bSaveIt = false; |
---|
4066 | int iColRefIdx = pColCU->getCUMvField(RefPicList(l))->getRefIdx(uiPartIdxCenter); |
---|
4067 | if (iColRefIdx < 0) |
---|
4068 | { |
---|
4069 | continue; |
---|
4070 | } |
---|
4071 | int iColRefPOC = pColCU->getSlice()->getRefPOC(RefPicList(l), iColRefIdx); |
---|
4072 | int iColDist = abs(iColRefPOC - iColPOC); |
---|
4073 | bool bCrosses = iColPOC < iCurrPOC ? iColRefPOC > iCurrPOC : iColRefPOC < iCurrPOC; |
---|
4074 | if (iFirstColDist < 0) |
---|
4075 | { |
---|
4076 | bSaveIt = true; |
---|
4077 | } |
---|
4078 | else if (bCrosses && !bFirstCrosses) |
---|
4079 | { |
---|
4080 | bSaveIt = true; |
---|
4081 | } |
---|
4082 | else if (bCrosses == bFirstCrosses && l == eRefPicList) |
---|
4083 | { |
---|
4084 | bSaveIt = true; |
---|
4085 | } |
---|
4086 | |
---|
4087 | if (bSaveIt) |
---|
4088 | { |
---|
4089 | bFirstCrosses = bCrosses; |
---|
4090 | iFirstColDist = iColDist; |
---|
4091 | eColRefPicList = RefPicList(l); |
---|
4092 | } |
---|
4093 | } |
---|
4094 | |
---|
4095 | // Scale the vector. |
---|
4096 | Int iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartIdxCenter)); |
---|
4097 | TComMv cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartIdxCenter); |
---|
4098 | |
---|
4099 | Int iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getPOC(); |
---|
4100 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
4101 | Bool bIsColRefLongTerm = pColCU->getSlice()->getRefPic(eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartIdxCenter))->getIsUsedAsLongTerm(); |
---|
4102 | |
---|
4103 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
4104 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
4105 | { |
---|
4106 | return false; |
---|
4107 | } |
---|
4108 | #endif |
---|
4109 | |
---|
4110 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
---|
4111 | { |
---|
4112 | pcMv[0] = cColMv; |
---|
4113 | } |
---|
4114 | else |
---|
4115 | { |
---|
4116 | Int iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
4117 | if ( iScale == 4096 ) |
---|
4118 | { |
---|
4119 | pcMv[0] = cColMv; |
---|
4120 | } |
---|
4121 | else |
---|
4122 | { |
---|
4123 | pcMv[0] = cColMv.scaleMv( iScale ); |
---|
4124 | } |
---|
4125 | } |
---|
4126 | return true; |
---|
4127 | } |
---|
4128 | |
---|
4129 | Void TComDataCU::compressMV() |
---|
4130 | { |
---|
4131 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
4132 | if (scaleFactor > 0) |
---|
4133 | { |
---|
4134 | #if SVC_MVP |
---|
4135 | m_acCUMvField[0].compress(m_pePredMode, m_puhInterDir, scaleFactor); |
---|
4136 | m_acCUMvField[1].compress(m_pePredMode, m_puhInterDir, scaleFactor); |
---|
4137 | #else |
---|
4138 | m_acCUMvField[0].compress(m_pePredMode, scaleFactor); |
---|
4139 | m_acCUMvField[1].compress(m_pePredMode, scaleFactor); |
---|
4140 | #endif |
---|
4141 | } |
---|
4142 | } |
---|
4143 | |
---|
4144 | UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) |
---|
4145 | { |
---|
4146 | UInt uiCTXIdx; |
---|
4147 | UInt uiScanIdx; |
---|
4148 | UInt uiDirMode; |
---|
4149 | |
---|
4150 | if ( !bIsIntra ) |
---|
4151 | { |
---|
4152 | uiScanIdx = SCAN_ZIGZAG; |
---|
4153 | return uiScanIdx; |
---|
4154 | } |
---|
4155 | |
---|
4156 | switch(uiWidth) |
---|
4157 | { |
---|
4158 | case 2: uiCTXIdx = 6; break; |
---|
4159 | case 4: uiCTXIdx = 5; break; |
---|
4160 | case 8: uiCTXIdx = 4; break; |
---|
4161 | case 16: uiCTXIdx = 3; break; |
---|
4162 | case 32: uiCTXIdx = 2; break; |
---|
4163 | case 64: uiCTXIdx = 1; break; |
---|
4164 | default: uiCTXIdx = 0; break; |
---|
4165 | } |
---|
4166 | |
---|
4167 | if ( bIsLuma ) |
---|
4168 | { |
---|
4169 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
---|
4170 | uiScanIdx = SCAN_ZIGZAG; |
---|
4171 | if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size |
---|
4172 | { |
---|
4173 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? 1 : (abs((Int)uiDirMode - HOR_IDX) < 5 ? 2 : 0); |
---|
4174 | } |
---|
4175 | } |
---|
4176 | else |
---|
4177 | { |
---|
4178 | uiDirMode = getChromaIntraDir(uiAbsPartIdx); |
---|
4179 | if( uiDirMode == DM_CHROMA_IDX ) |
---|
4180 | { |
---|
4181 | // get number of partitions in current CU |
---|
4182 | UInt depth = getDepth(uiAbsPartIdx); |
---|
4183 | UInt numParts = getPic()->getNumPartInCU() >> (2 * depth); |
---|
4184 | |
---|
4185 | // get luma mode from upper-left corner of current CU |
---|
4186 | uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); |
---|
4187 | } |
---|
4188 | uiScanIdx = SCAN_ZIGZAG; |
---|
4189 | if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size |
---|
4190 | { |
---|
4191 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? 1 : (abs((Int)uiDirMode - HOR_IDX) < 5 ? 2 : 0); |
---|
4192 | } |
---|
4193 | } |
---|
4194 | |
---|
4195 | return uiScanIdx; |
---|
4196 | } |
---|
4197 | |
---|
4198 | #if !REMOVE_NSQT |
---|
4199 | Bool TComDataCU::useNonSquareTrans(UInt uiTrMode, Int absPartIdx) |
---|
4200 | { |
---|
4201 | UInt minTuSize = ( 1 << ( getSlice()->getSPS()->getQuadtreeTULog2MinSize() + 1 ) ); |
---|
4202 | const UInt uiLog2TrSize = g_aucConvertToBit[ getSlice()->getSPS()->getMaxCUWidth() >> ( m_puhDepth[ absPartIdx ] + uiTrMode ) ] + 2; |
---|
4203 | if ( uiTrMode && uiLog2TrSize < getSlice()->getSPS()->getQuadtreeTULog2MaxSize() && ( getWidth( absPartIdx ) > minTuSize ) && |
---|
4204 | ( m_pePartSize[absPartIdx] == SIZE_Nx2N || m_pePartSize[absPartIdx] == SIZE_2NxN || ( m_pePartSize[absPartIdx] >= SIZE_2NxnU && m_pePartSize[absPartIdx] <= SIZE_nRx2N ) ) ) |
---|
4205 | { |
---|
4206 | return getSlice()->getSPS()->getUseNSQT(); |
---|
4207 | } |
---|
4208 | else |
---|
4209 | { |
---|
4210 | return false; |
---|
4211 | } |
---|
4212 | } |
---|
4213 | |
---|
4214 | Void TComDataCU::getNSQTSize(Int trMode, Int absPartIdx, Int &trWidth, Int &trHeight) |
---|
4215 | { |
---|
4216 | UInt minTuSize = ( 1 << getSlice()->getSPS()->getQuadtreeTULog2MinSize() ); |
---|
4217 | if ( useNonSquareTrans( trMode, absPartIdx ) && ( trWidth > minTuSize ) ) |
---|
4218 | { |
---|
4219 | trWidth = ( m_pePartSize[absPartIdx] == SIZE_Nx2N || m_pePartSize[absPartIdx] == SIZE_nLx2N || m_pePartSize[absPartIdx] == SIZE_nRx2N )? trWidth >> 1 : trWidth << 1; |
---|
4220 | trHeight = ( m_pePartSize[absPartIdx] == SIZE_Nx2N || m_pePartSize[absPartIdx] == SIZE_nLx2N || m_pePartSize[absPartIdx] == SIZE_nRx2N )? trHeight << 1 : trHeight >> 1; |
---|
4221 | } |
---|
4222 | } |
---|
4223 | |
---|
4224 | Bool TComDataCU::useNonSquarePU(UInt absPartIdx) |
---|
4225 | { |
---|
4226 | if ( ( m_pePartSize[absPartIdx] == SIZE_Nx2N ) || ( m_pePartSize[absPartIdx] == SIZE_2NxN ) || ( m_pePartSize[absPartIdx] >= SIZE_2NxnU && m_pePartSize[absPartIdx] <= SIZE_nRx2N ) ) |
---|
4227 | { |
---|
4228 | return true; |
---|
4229 | } |
---|
4230 | else |
---|
4231 | { |
---|
4232 | return false; |
---|
4233 | } |
---|
4234 | } |
---|
4235 | |
---|
4236 | UInt TComDataCU::getInterTUSplitDirection( Int trWidth, Int trHeight, Int trLastWidth, Int trLastHeight ) |
---|
4237 | { |
---|
4238 | UInt interTUSplitDirection = 2; |
---|
4239 | if ( ( trWidth == trLastWidth ) && ( trHeight < trLastHeight ) ) |
---|
4240 | { |
---|
4241 | interTUSplitDirection = 0; |
---|
4242 | } |
---|
4243 | else if ( ( trWidth < trLastWidth ) && ( trHeight == trLastHeight ) ) |
---|
4244 | { |
---|
4245 | interTUSplitDirection = 1; |
---|
4246 | } |
---|
4247 | |
---|
4248 | return interTUSplitDirection; |
---|
4249 | } |
---|
4250 | |
---|
4251 | UInt TComDataCU::getNSAbsPartIdx ( UInt log2TrafoSize, UInt absPartIdx, UInt absTUPartIdx, UInt innerQuadIdx, UInt trMode ) |
---|
4252 | { |
---|
4253 | Int trWidth, trHeight, trLastWidth, trLastHeight; |
---|
4254 | UInt lcuWidthInBaseUnits = getPic()->getNumPartInWidth(); |
---|
4255 | UInt nsTUWidthInBaseUnits, nsTUHeightInBaseUnits; |
---|
4256 | UInt interTUSplitDirection; |
---|
4257 | |
---|
4258 | if( isIntra(absPartIdx) ) |
---|
4259 | { |
---|
4260 | return absPartIdx; |
---|
4261 | } |
---|
4262 | |
---|
4263 | trWidth = trHeight = ( 1 << log2TrafoSize ); |
---|
4264 | trLastWidth = trWidth << 1, trLastHeight = trHeight << 1; |
---|
4265 | |
---|
4266 | getNSQTSize( trMode, absPartIdx, trWidth, trHeight ); |
---|
4267 | getNSQTSize( trMode - 1, absPartIdx, trLastWidth, trLastHeight ); |
---|
4268 | interTUSplitDirection = getInterTUSplitDirection ( trWidth, trHeight, trLastWidth, trLastHeight ); |
---|
4269 | |
---|
4270 | nsTUWidthInBaseUnits = trWidth / getPic()->getMinCUWidth(); |
---|
4271 | nsTUHeightInBaseUnits = trHeight / getPic()->getMinCUHeight(); |
---|
4272 | |
---|
4273 | if ( interTUSplitDirection != 2 ) |
---|
4274 | { |
---|
4275 | UInt uiNSTUBaseUnits = nsTUWidthInBaseUnits < nsTUHeightInBaseUnits ? nsTUWidthInBaseUnits : nsTUHeightInBaseUnits; |
---|
4276 | absTUPartIdx = g_auiRasterToZscan[ g_auiZscanToRaster[absTUPartIdx] + innerQuadIdx * uiNSTUBaseUnits * lcuWidthInBaseUnits * ( 1 - interTUSplitDirection ) + innerQuadIdx * uiNSTUBaseUnits * interTUSplitDirection ]; |
---|
4277 | } |
---|
4278 | else |
---|
4279 | { |
---|
4280 | absTUPartIdx = g_auiRasterToZscan[ g_auiZscanToRaster[absTUPartIdx] + (innerQuadIdx & 0x01) * nsTUWidthInBaseUnits + ( ( innerQuadIdx >> 1 ) & 0x01 ) * nsTUHeightInBaseUnits * lcuWidthInBaseUnits ]; |
---|
4281 | } |
---|
4282 | |
---|
4283 | return absTUPartIdx; |
---|
4284 | } |
---|
4285 | |
---|
4286 | UInt TComDataCU::getNSAddrChroma( UInt uiLog2TrSizeC, UInt uiTrModeC, UInt uiQuadrant, UInt absTUPartIdx ) |
---|
4287 | { |
---|
4288 | if( uiLog2TrSizeC != getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
4289 | { |
---|
4290 | return absTUPartIdx; |
---|
4291 | } |
---|
4292 | |
---|
4293 | UInt lcuWidthInBaseUnits = getPic()->getNumPartInWidth(); |
---|
4294 | Int trWidth = ( 1 << ( uiLog2TrSizeC + 1 ) ); |
---|
4295 | Int trHeight = ( 1 << ( uiLog2TrSizeC + 1 ) ); |
---|
4296 | Int trLastWidth = trWidth << 1, trLastHeight = trHeight << 1; |
---|
4297 | |
---|
4298 | getNSQTSize ( uiTrModeC - 1, absTUPartIdx, trLastWidth, trLastHeight ); |
---|
4299 | getNSQTSize ( uiTrModeC, absTUPartIdx, trWidth, trHeight ); |
---|
4300 | |
---|
4301 | UInt interTUSplitDirection = getInterTUSplitDirection ( trWidth, trHeight, trLastWidth, trLastHeight ); |
---|
4302 | UInt nsTUWidthInBaseUnits = trWidth / getPic()->getMinCUWidth(); |
---|
4303 | UInt nsTUHeightInBaseUnits = trHeight / getPic()->getMinCUHeight(); |
---|
4304 | UInt firstTURasterIdx = 0, absTUPartIdxC = 0; |
---|
4305 | |
---|
4306 | if(interTUSplitDirection != 2) |
---|
4307 | { |
---|
4308 | UInt uiNSTUBaseUnits = nsTUWidthInBaseUnits < nsTUHeightInBaseUnits ? 1 : lcuWidthInBaseUnits; |
---|
4309 | firstTURasterIdx = g_auiZscanToRaster[absTUPartIdx] - uiQuadrant * uiNSTUBaseUnits; |
---|
4310 | absTUPartIdxC = g_auiRasterToZscan[firstTURasterIdx] + uiQuadrant * nsTUWidthInBaseUnits * nsTUHeightInBaseUnits; |
---|
4311 | } |
---|
4312 | else |
---|
4313 | { |
---|
4314 | UInt uiNSTUBaseUnits = nsTUWidthInBaseUnits < nsTUHeightInBaseUnits ? 2 * lcuWidthInBaseUnits : 2; |
---|
4315 | firstTURasterIdx = g_auiZscanToRaster[absTUPartIdx] - ( ( uiQuadrant >> 1 ) & 0x01 ) * nsTUHeightInBaseUnits * lcuWidthInBaseUnits - ( uiQuadrant & 0x01 ) * nsTUWidthInBaseUnits; |
---|
4316 | absTUPartIdxC = g_auiRasterToZscan[firstTURasterIdx + uiQuadrant * uiNSTUBaseUnits]; |
---|
4317 | } |
---|
4318 | |
---|
4319 | return absTUPartIdxC; |
---|
4320 | } |
---|
4321 | #endif |
---|
4322 | |
---|
4323 | UInt TComDataCU::getSCUAddr() |
---|
4324 | { |
---|
4325 | return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; |
---|
4326 | } |
---|
4327 | |
---|
4328 | /** Set neighboring blocks availabilities for non-deblocked filtering |
---|
4329 | * \param numLCUInPicWidth number of LCUs in picture width |
---|
4330 | * \param numLCUInPicHeight number of LCUs in picture height |
---|
4331 | * \param numSUInLCUWidth number of SUs in LCU width |
---|
4332 | * \param numSUInLCUHeight number of SUs in LCU height |
---|
4333 | * \param picWidth picture width |
---|
4334 | * \param picHeight picture height |
---|
4335 | * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled |
---|
4336 | * \param bTopTileBoundary true means that top boundary coincides tile boundary |
---|
4337 | * \param bDownTileBoundary true means that bottom boundary coincides tile boundary |
---|
4338 | * \param bLeftTileBoundary true means that left boundary coincides tile boundary |
---|
4339 | * \param bRightTileBoundary true means that right boundary coincides tile boundary |
---|
4340 | * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled |
---|
4341 | */ |
---|
4342 | Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt numLCUInPicHeight, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight |
---|
4343 | ,std::vector<Bool>& LFCrossSliceBoundary |
---|
4344 | ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary |
---|
4345 | ,Bool bIndependentTileBoundaryEnabled) |
---|
4346 | { |
---|
4347 | UInt numSUInLCU = numSUInLCUWidth*numSUInLCUHeight; |
---|
4348 | Int* pSliceIDMapLCU = m_piSliceSUMap; |
---|
4349 | #if MODIFIED_CROSS_SLICE |
---|
4350 | Bool onlyOneSliceInPic = ((Int)LFCrossSliceBoundary.size() == 1); |
---|
4351 | #endif |
---|
4352 | UInt uiLPelX, uiTPelY; |
---|
4353 | UInt width, height; |
---|
4354 | Bool bPicRBoundary, bPicBBoundary, bPicTBoundary, bPicLBoundary; |
---|
4355 | Bool bLCURBoundary= false, bLCUBBoundary= false, bLCUTBoundary= false, bLCULBoundary= false; |
---|
4356 | Bool* pbAvailBorder; |
---|
4357 | Bool* pbAvail; |
---|
4358 | UInt rTLSU, rBRSU, widthSU, heightSU; |
---|
4359 | UInt zRefSU; |
---|
4360 | Int* pRefID; |
---|
4361 | Int* pRefMapLCU; |
---|
4362 | UInt rTRefSU= 0, rBRefSU= 0, rLRefSU= 0, rRRefSU= 0; |
---|
4363 | Int* pRRefMapLCU= NULL; |
---|
4364 | Int* pLRefMapLCU= NULL; |
---|
4365 | Int* pTRefMapLCU= NULL; |
---|
4366 | Int* pBRefMapLCU= NULL; |
---|
4367 | Int sliceID; |
---|
4368 | UInt numSGU = (UInt)m_vNDFBlock.size(); |
---|
4369 | |
---|
4370 | for(Int i=0; i< numSGU; i++) |
---|
4371 | { |
---|
4372 | NDBFBlockInfo& rSGU = m_vNDFBlock[i]; |
---|
4373 | |
---|
4374 | sliceID = rSGU.sliceID; |
---|
4375 | uiLPelX = rSGU.posX; |
---|
4376 | uiTPelY = rSGU.posY; |
---|
4377 | width = rSGU.width; |
---|
4378 | height = rSGU.height; |
---|
4379 | #if !MODIFIED_CROSS_SLICE |
---|
4380 | Bool bIndependentSliceBoundaryEnabled = !(LFCrossSliceBoundary[sliceID]); |
---|
4381 | #endif |
---|
4382 | rTLSU = g_auiZscanToRaster[ rSGU.startSU ]; |
---|
4383 | rBRSU = g_auiZscanToRaster[ rSGU.endSU ]; |
---|
4384 | widthSU = rSGU.widthSU; |
---|
4385 | heightSU = rSGU.heightSU; |
---|
4386 | |
---|
4387 | pbAvailBorder = rSGU.isBorderAvailable; |
---|
4388 | |
---|
4389 | bPicTBoundary= (uiTPelY == 0 )?(true):(false); |
---|
4390 | bPicLBoundary= (uiLPelX == 0 )?(true):(false); |
---|
4391 | bPicRBoundary= (!(uiLPelX+ width < picWidth ) )?(true):(false); |
---|
4392 | bPicBBoundary= (!(uiTPelY + height < picHeight))?(true):(false); |
---|
4393 | |
---|
4394 | bLCULBoundary = (rTLSU % numSUInLCUWidth == 0)?(true):(false); |
---|
4395 | bLCURBoundary = ( (rTLSU+ widthSU) % numSUInLCUWidth == 0)?(true):(false); |
---|
4396 | bLCUTBoundary = ( (UInt)(rTLSU / numSUInLCUWidth)== 0)?(true):(false); |
---|
4397 | bLCUBBoundary = ( (UInt)(rBRSU / numSUInLCUWidth) == (numSUInLCUHeight-1) )?(true):(false); |
---|
4398 | |
---|
4399 | // SGU_L |
---|
4400 | pbAvail = &(pbAvailBorder[SGU_L]); |
---|
4401 | if(bPicLBoundary) |
---|
4402 | { |
---|
4403 | *pbAvail = false; |
---|
4404 | } |
---|
4405 | #if MODIFIED_CROSS_SLICE |
---|
4406 | else if (onlyOneSliceInPic) |
---|
4407 | #else |
---|
4408 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4409 | #endif |
---|
4410 | { |
---|
4411 | *pbAvail = true; |
---|
4412 | } |
---|
4413 | else |
---|
4414 | { |
---|
4415 | // bLCULBoundary = (rTLSU % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
4416 | if(bLCULBoundary) |
---|
4417 | { |
---|
4418 | rLRefSU = rTLSU + numSUInLCUWidth -1; |
---|
4419 | zRefSU = g_auiRasterToZscan[rLRefSU]; |
---|
4420 | pRefMapLCU = pLRefMapLCU= (pSliceIDMapLCU - numSUInLCU); |
---|
4421 | } |
---|
4422 | else |
---|
4423 | { |
---|
4424 | zRefSU = g_auiRasterToZscan[rTLSU - 1]; |
---|
4425 | pRefMapLCU = pSliceIDMapLCU; |
---|
4426 | } |
---|
4427 | pRefID = pRefMapLCU + zRefSU; |
---|
4428 | #if MODIFIED_CROSS_SLICE |
---|
4429 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4430 | #else |
---|
4431 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4432 | #endif |
---|
4433 | } |
---|
4434 | |
---|
4435 | // SGU_R |
---|
4436 | pbAvail = &(pbAvailBorder[SGU_R]); |
---|
4437 | if(bPicRBoundary) |
---|
4438 | { |
---|
4439 | *pbAvail = false; |
---|
4440 | } |
---|
4441 | #if MODIFIED_CROSS_SLICE |
---|
4442 | else if (onlyOneSliceInPic) |
---|
4443 | #else |
---|
4444 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4445 | #endif |
---|
4446 | { |
---|
4447 | *pbAvail = true; |
---|
4448 | } |
---|
4449 | else |
---|
4450 | { |
---|
4451 | // bLCURBoundary = ( (rTLSU+ uiWidthSU) % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
4452 | if(bLCURBoundary) |
---|
4453 | { |
---|
4454 | rRRefSU = rTLSU + widthSU - numSUInLCUWidth; |
---|
4455 | zRefSU = g_auiRasterToZscan[rRRefSU]; |
---|
4456 | pRefMapLCU = pRRefMapLCU= (pSliceIDMapLCU + numSUInLCU); |
---|
4457 | } |
---|
4458 | else |
---|
4459 | { |
---|
4460 | zRefSU = g_auiRasterToZscan[rTLSU + widthSU]; |
---|
4461 | pRefMapLCU = pSliceIDMapLCU; |
---|
4462 | } |
---|
4463 | pRefID = pRefMapLCU + zRefSU; |
---|
4464 | #if MODIFIED_CROSS_SLICE |
---|
4465 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4466 | #else |
---|
4467 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4468 | #endif |
---|
4469 | } |
---|
4470 | |
---|
4471 | // SGU_T |
---|
4472 | pbAvail = &(pbAvailBorder[SGU_T]); |
---|
4473 | if(bPicTBoundary) |
---|
4474 | { |
---|
4475 | *pbAvail = false; |
---|
4476 | } |
---|
4477 | #if MODIFIED_CROSS_SLICE |
---|
4478 | else if (onlyOneSliceInPic) |
---|
4479 | #else |
---|
4480 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4481 | #endif |
---|
4482 | { |
---|
4483 | *pbAvail = true; |
---|
4484 | } |
---|
4485 | else |
---|
4486 | { |
---|
4487 | // bLCUTBoundary = ( (UInt)(rTLSU / uiNumSUInLCUWidth)== 0)?(true):(false); |
---|
4488 | if(bLCUTBoundary) |
---|
4489 | { |
---|
4490 | rTRefSU = numSUInLCU - (numSUInLCUWidth - rTLSU); |
---|
4491 | zRefSU = g_auiRasterToZscan[rTRefSU]; |
---|
4492 | pRefMapLCU = pTRefMapLCU= (pSliceIDMapLCU - (numLCUInPicWidth*numSUInLCU)); |
---|
4493 | } |
---|
4494 | else |
---|
4495 | { |
---|
4496 | zRefSU = g_auiRasterToZscan[rTLSU - numSUInLCUWidth]; |
---|
4497 | pRefMapLCU = pSliceIDMapLCU; |
---|
4498 | } |
---|
4499 | pRefID = pRefMapLCU + zRefSU; |
---|
4500 | #if MODIFIED_CROSS_SLICE |
---|
4501 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4502 | #else |
---|
4503 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4504 | #endif |
---|
4505 | } |
---|
4506 | |
---|
4507 | // SGU_B |
---|
4508 | pbAvail = &(pbAvailBorder[SGU_B]); |
---|
4509 | if(bPicBBoundary) |
---|
4510 | { |
---|
4511 | *pbAvail = false; |
---|
4512 | } |
---|
4513 | #if MODIFIED_CROSS_SLICE |
---|
4514 | else if (onlyOneSliceInPic) |
---|
4515 | #else |
---|
4516 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4517 | #endif |
---|
4518 | { |
---|
4519 | *pbAvail = true; |
---|
4520 | } |
---|
4521 | else |
---|
4522 | { |
---|
4523 | // bLCUBBoundary = ( (UInt)(rBRSU / uiNumSUInLCUWidth) == (uiNumSUInLCUHeight-1) )?(true):(false); |
---|
4524 | if(bLCUBBoundary) |
---|
4525 | { |
---|
4526 | rBRefSU = rTLSU % numSUInLCUWidth; |
---|
4527 | zRefSU = g_auiRasterToZscan[rBRefSU]; |
---|
4528 | pRefMapLCU = pBRefMapLCU= (pSliceIDMapLCU + (numLCUInPicWidth*numSUInLCU)); |
---|
4529 | } |
---|
4530 | else |
---|
4531 | { |
---|
4532 | zRefSU = g_auiRasterToZscan[rTLSU + (heightSU*numSUInLCUWidth)]; |
---|
4533 | pRefMapLCU = pSliceIDMapLCU; |
---|
4534 | } |
---|
4535 | pRefID = pRefMapLCU + zRefSU; |
---|
4536 | #if MODIFIED_CROSS_SLICE |
---|
4537 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4538 | #else |
---|
4539 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4540 | #endif |
---|
4541 | } |
---|
4542 | |
---|
4543 | // SGU_TL |
---|
4544 | pbAvail = &(pbAvailBorder[SGU_TL]); |
---|
4545 | if(bPicTBoundary || bPicLBoundary) |
---|
4546 | { |
---|
4547 | *pbAvail = false; |
---|
4548 | } |
---|
4549 | #if MODIFIED_CROSS_SLICE |
---|
4550 | else if (onlyOneSliceInPic) |
---|
4551 | #else |
---|
4552 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4553 | #endif |
---|
4554 | { |
---|
4555 | *pbAvail = true; |
---|
4556 | } |
---|
4557 | else |
---|
4558 | { |
---|
4559 | if(bLCUTBoundary && bLCULBoundary) |
---|
4560 | { |
---|
4561 | zRefSU = numSUInLCU -1; |
---|
4562 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
4563 | } |
---|
4564 | else if(bLCUTBoundary) |
---|
4565 | { |
---|
4566 | zRefSU = g_auiRasterToZscan[ rTRefSU- 1]; |
---|
4567 | pRefMapLCU = pTRefMapLCU; |
---|
4568 | } |
---|
4569 | else if(bLCULBoundary) |
---|
4570 | { |
---|
4571 | zRefSU = g_auiRasterToZscan[ rLRefSU- numSUInLCUWidth ]; |
---|
4572 | pRefMapLCU = pLRefMapLCU; |
---|
4573 | } |
---|
4574 | else //inside LCU |
---|
4575 | { |
---|
4576 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth -1]; |
---|
4577 | pRefMapLCU = pSliceIDMapLCU; |
---|
4578 | } |
---|
4579 | pRefID = pRefMapLCU + zRefSU; |
---|
4580 | #if MODIFIED_CROSS_SLICE |
---|
4581 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4582 | #else |
---|
4583 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4584 | #endif |
---|
4585 | } |
---|
4586 | |
---|
4587 | // SGU_TR |
---|
4588 | pbAvail = &(pbAvailBorder[SGU_TR]); |
---|
4589 | if(bPicTBoundary || bPicRBoundary) |
---|
4590 | { |
---|
4591 | *pbAvail = false; |
---|
4592 | } |
---|
4593 | #if MODIFIED_CROSS_SLICE |
---|
4594 | else if (onlyOneSliceInPic) |
---|
4595 | #else |
---|
4596 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4597 | #endif |
---|
4598 | { |
---|
4599 | *pbAvail = true; |
---|
4600 | } |
---|
4601 | else |
---|
4602 | { |
---|
4603 | if(bLCUTBoundary && bLCURBoundary) |
---|
4604 | { |
---|
4605 | zRefSU = g_auiRasterToZscan[numSUInLCU - numSUInLCUWidth]; |
---|
4606 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
4607 | } |
---|
4608 | else if(bLCUTBoundary) |
---|
4609 | { |
---|
4610 | zRefSU = g_auiRasterToZscan[ rTRefSU+ widthSU]; |
---|
4611 | pRefMapLCU = pTRefMapLCU; |
---|
4612 | } |
---|
4613 | else if(bLCURBoundary) |
---|
4614 | { |
---|
4615 | zRefSU = g_auiRasterToZscan[ rRRefSU- numSUInLCUWidth ]; |
---|
4616 | pRefMapLCU = pRRefMapLCU; |
---|
4617 | } |
---|
4618 | else //inside LCU |
---|
4619 | { |
---|
4620 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth +widthSU]; |
---|
4621 | pRefMapLCU = pSliceIDMapLCU; |
---|
4622 | } |
---|
4623 | pRefID = pRefMapLCU + zRefSU; |
---|
4624 | #if MODIFIED_CROSS_SLICE |
---|
4625 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4626 | #else |
---|
4627 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4628 | #endif |
---|
4629 | } |
---|
4630 | |
---|
4631 | // SGU_BL |
---|
4632 | pbAvail = &(pbAvailBorder[SGU_BL]); |
---|
4633 | if(bPicBBoundary || bPicLBoundary) |
---|
4634 | { |
---|
4635 | *pbAvail = false; |
---|
4636 | } |
---|
4637 | #if MODIFIED_CROSS_SLICE |
---|
4638 | else if (onlyOneSliceInPic) |
---|
4639 | #else |
---|
4640 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4641 | #endif |
---|
4642 | { |
---|
4643 | *pbAvail = true; |
---|
4644 | } |
---|
4645 | else |
---|
4646 | { |
---|
4647 | if(bLCUBBoundary && bLCULBoundary) |
---|
4648 | { |
---|
4649 | zRefSU = g_auiRasterToZscan[numSUInLCUWidth - 1]; |
---|
4650 | pRefMapLCU = pSliceIDMapLCU + ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
4651 | } |
---|
4652 | else if(bLCUBBoundary) |
---|
4653 | { |
---|
4654 | zRefSU = g_auiRasterToZscan[ rBRefSU - 1]; |
---|
4655 | pRefMapLCU = pBRefMapLCU; |
---|
4656 | } |
---|
4657 | else if(bLCULBoundary) |
---|
4658 | { |
---|
4659 | zRefSU = g_auiRasterToZscan[ rLRefSU+ heightSU*numSUInLCUWidth ]; |
---|
4660 | pRefMapLCU = pLRefMapLCU; |
---|
4661 | } |
---|
4662 | else //inside LCU |
---|
4663 | { |
---|
4664 | zRefSU = g_auiRasterToZscan[ rTLSU + heightSU*numSUInLCUWidth -1]; |
---|
4665 | pRefMapLCU = pSliceIDMapLCU; |
---|
4666 | } |
---|
4667 | pRefID = pRefMapLCU + zRefSU; |
---|
4668 | #if MODIFIED_CROSS_SLICE |
---|
4669 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4670 | #else |
---|
4671 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4672 | #endif |
---|
4673 | } |
---|
4674 | |
---|
4675 | // SGU_BR |
---|
4676 | pbAvail = &(pbAvailBorder[SGU_BR]); |
---|
4677 | if(bPicBBoundary || bPicRBoundary) |
---|
4678 | { |
---|
4679 | *pbAvail = false; |
---|
4680 | } |
---|
4681 | #if MODIFIED_CROSS_SLICE |
---|
4682 | else if (onlyOneSliceInPic) |
---|
4683 | #else |
---|
4684 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4685 | #endif |
---|
4686 | { |
---|
4687 | *pbAvail = true; |
---|
4688 | } |
---|
4689 | else |
---|
4690 | { |
---|
4691 | if(bLCUBBoundary && bLCURBoundary) |
---|
4692 | { |
---|
4693 | zRefSU = 0; |
---|
4694 | pRefMapLCU = pSliceIDMapLCU+ ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
4695 | } |
---|
4696 | else if(bLCUBBoundary) |
---|
4697 | { |
---|
4698 | zRefSU = g_auiRasterToZscan[ rBRefSU + widthSU]; |
---|
4699 | pRefMapLCU = pBRefMapLCU; |
---|
4700 | } |
---|
4701 | else if(bLCURBoundary) |
---|
4702 | { |
---|
4703 | zRefSU = g_auiRasterToZscan[ rRRefSU + (heightSU*numSUInLCUWidth)]; |
---|
4704 | pRefMapLCU = pRRefMapLCU; |
---|
4705 | } |
---|
4706 | else //inside LCU |
---|
4707 | { |
---|
4708 | zRefSU = g_auiRasterToZscan[ rTLSU + (heightSU*numSUInLCUWidth)+ widthSU]; |
---|
4709 | pRefMapLCU = pSliceIDMapLCU; |
---|
4710 | } |
---|
4711 | pRefID = pRefMapLCU + zRefSU; |
---|
4712 | #if MODIFIED_CROSS_SLICE |
---|
4713 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4714 | #else |
---|
4715 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4716 | #endif |
---|
4717 | } |
---|
4718 | |
---|
4719 | if(bIndependentTileBoundaryEnabled) |
---|
4720 | { |
---|
4721 | //left LCU boundary |
---|
4722 | if(!bPicLBoundary && bLCULBoundary) |
---|
4723 | { |
---|
4724 | if(bLeftTileBoundary) |
---|
4725 | { |
---|
4726 | pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false; |
---|
4727 | } |
---|
4728 | } |
---|
4729 | //right LCU boundary |
---|
4730 | if(!bPicRBoundary && bLCURBoundary) |
---|
4731 | { |
---|
4732 | if(bRightTileBoundary) |
---|
4733 | { |
---|
4734 | pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false; |
---|
4735 | } |
---|
4736 | } |
---|
4737 | //top LCU boundary |
---|
4738 | if(!bPicTBoundary && bLCUTBoundary) |
---|
4739 | { |
---|
4740 | if(bTopTileBoundary) |
---|
4741 | { |
---|
4742 | pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false; |
---|
4743 | } |
---|
4744 | } |
---|
4745 | //down LCU boundary |
---|
4746 | if(!bPicBBoundary && bLCUBBoundary) |
---|
4747 | { |
---|
4748 | if(bDownTileBoundary) |
---|
4749 | { |
---|
4750 | pbAvailBorder[SGU_B] = pbAvailBorder[SGU_BL] = pbAvailBorder[SGU_BR] = false; |
---|
4751 | } |
---|
4752 | } |
---|
4753 | } |
---|
4754 | rSGU.allBordersAvailable = true; |
---|
4755 | for(Int b=0; b< NUM_SGU_BORDER; b++) |
---|
4756 | { |
---|
4757 | if(pbAvailBorder[b] == false) |
---|
4758 | { |
---|
4759 | rSGU.allBordersAvailable = false; |
---|
4760 | break; |
---|
4761 | } |
---|
4762 | } |
---|
4763 | } |
---|
4764 | } |
---|
4765 | |
---|
4766 | #if INTRA_BL |
---|
4767 | Void TComDataCU::getBaseLumaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride ) |
---|
4768 | { |
---|
4769 | TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec(); |
---|
4770 | UInt uiStrideBase = pcBaseRec->getStride(); |
---|
4771 | Pel* piBase = pcBaseRec->getLumaAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
4772 | |
---|
4773 | for ( UInt y = 0; y < uiHeight; y ++ ) |
---|
4774 | { |
---|
4775 | memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) ); |
---|
4776 | } |
---|
4777 | } |
---|
4778 | |
---|
4779 | Void TComDataCU::getBaseChromaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, UInt uiChromaId ) |
---|
4780 | { |
---|
4781 | TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec(); |
---|
4782 | |
---|
4783 | UInt uiStrideBase = pcBaseRec->getCStride(); |
---|
4784 | Pel* piBase; |
---|
4785 | |
---|
4786 | if( uiChromaId == 0 ) |
---|
4787 | { |
---|
4788 | piBase = pcBaseRec->getCbAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
4789 | } |
---|
4790 | else |
---|
4791 | { |
---|
4792 | piBase = pcBaseRec->getCrAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
4793 | } |
---|
4794 | |
---|
4795 | for ( UInt y = 0; y < uiHeight; y ++ ) |
---|
4796 | { |
---|
4797 | memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) ); |
---|
4798 | } |
---|
4799 | } |
---|
4800 | |
---|
4801 | #endif |
---|
4802 | |
---|
4803 | #if SVC_COL_BLK |
---|
4804 | TComDataCU* TComDataCU::getBaseColCU( UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase ) |
---|
4805 | { |
---|
4806 | TComPic* cBaseColPic = m_pcSlice->getBaseColPic(); |
---|
4807 | |
---|
4808 | #if SVC_UPSAMPLING |
---|
4809 | Int iBWidth = cBaseColPic->getPicYuvRec()->getWidth () - cBaseColPic->getPicYuvRec()->getPicCropLeftOffset() - cBaseColPic->getPicYuvRec()->getPicCropRightOffset(); |
---|
4810 | Int iBHeight = cBaseColPic->getPicYuvRec()->getHeight() - cBaseColPic->getPicYuvRec()->getPicCropTopOffset() - cBaseColPic->getPicYuvRec()->getPicCropBottomOffset(); |
---|
4811 | |
---|
4812 | Int iEWidth = m_pcPic->getPicYuvRec()->getWidth() - m_pcPic->getPicYuvRec()->getPicCropLeftOffset() - m_pcPic->getPicYuvRec()->getPicCropRightOffset(); |
---|
4813 | Int iEHeight = m_pcPic->getPicYuvRec()->getHeight() - m_pcPic->getPicYuvRec()->getPicCropTopOffset() - m_pcPic->getPicYuvRec()->getPicCropBottomOffset(); |
---|
4814 | #else |
---|
4815 | Int iBWidth = cBaseColPic->getPicYuvRec()->getWidth(); |
---|
4816 | Int iBHeight = cBaseColPic->getPicYuvRec()->getHeight(); |
---|
4817 | |
---|
4818 | Int iEWidth = m_pcPic->getPicYuvRec()->getWidth(); |
---|
4819 | Int iEHeight = m_pcPic->getPicYuvRec()->getHeight(); |
---|
4820 | #endif |
---|
4821 | |
---|
4822 | if (iBWidth == iEWidth && iEHeight == iBHeight) |
---|
4823 | { |
---|
4824 | uiAbsPartIdxBase = uiCuAbsPartIdx + m_uiAbsIdxInLCU; |
---|
4825 | uiCUAddrBase = m_uiCUAddr; |
---|
4826 | } |
---|
4827 | else |
---|
4828 | { |
---|
4829 | UInt uiMinUnitSize = m_pcPic->getMinCUWidth(); |
---|
4830 | UInt uiRasterAddr = g_auiZscanToRaster[uiCuAbsPartIdx]; |
---|
4831 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
4832 | |
---|
4833 | Int iEX = m_uiCUPelX + uiMinUnitSize*(uiRasterAddr%uiNumPartInCUWidth); |
---|
4834 | Int iEY = m_uiCUPelY + uiMinUnitSize*(uiRasterAddr/uiNumPartInCUWidth); |
---|
4835 | |
---|
4836 | Int iBX = (iEX*iBWidth + iEWidth/2)/iEWidth; |
---|
4837 | Int iBY = (iEY*iBHeight+ iEHeight/2)/iEHeight; |
---|
4838 | |
---|
4839 | uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth); |
---|
4840 | |
---|
4841 | assert(uiCUAddrBase < cBaseColPic->getNumCUsInFrame()); |
---|
4842 | |
---|
4843 | UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*cBaseColPic->getNumPartInWidth() |
---|
4844 | + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize; |
---|
4845 | |
---|
4846 | uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase]; |
---|
4847 | } |
---|
4848 | |
---|
4849 | return cBaseColPic->getCU(uiCUAddrBase); |
---|
4850 | } |
---|
4851 | |
---|
4852 | Void TComDataCU::scaleBaseMV( TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase ) |
---|
4853 | { |
---|
4854 | TComMvField cMvFieldBase; |
---|
4855 | TComMv cMv; |
---|
4856 | |
---|
4857 | Int iBWidth = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth(); |
---|
4858 | Int iBHeight = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight(); |
---|
4859 | |
---|
4860 | Int iEWidth = m_pcPic->getPicYuvRec()->getWidth(); |
---|
4861 | Int iEHeight = m_pcPic->getPicYuvRec()->getHeight(); |
---|
4862 | |
---|
4863 | Int iMvX = (rcMvFieldBase.getHor()*iEWidth + (iBWidth/2 -1) * (rcMvFieldBase.getHor() > 0 ? 1: -1) )/iBWidth; |
---|
4864 | Int iMvY = (rcMvFieldBase.getVer()*iEHeight + (iBHeight/2 -1) * (rcMvFieldBase.getVer() > 0 ? 1: -1) )/iBHeight; |
---|
4865 | |
---|
4866 | cMv.set(iMvX, iMvY); |
---|
4867 | |
---|
4868 | rcMvFieldEnhance.setMvField( cMv, rcMvFieldBase.getRefIdx() ); |
---|
4869 | } |
---|
4870 | #endif |
---|
4871 | |
---|
4872 | #if SVC_MVP |
---|
4873 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, UChar uchInterDir, TComMvField* pcMvField ) |
---|
4874 | { |
---|
4875 | if ( getInterDir( uiAbsPartIdx ) != uchInterDir ) |
---|
4876 | { |
---|
4877 | return false; |
---|
4878 | } |
---|
4879 | |
---|
4880 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
4881 | { |
---|
4882 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
4883 | { |
---|
4884 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcMvField[uiRefListIdx].getMv() || |
---|
4885 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcMvField[uiRefListIdx].getRefIdx() ) |
---|
4886 | { |
---|
4887 | return false; |
---|
4888 | } |
---|
4889 | } |
---|
4890 | } |
---|
4891 | |
---|
4892 | return true; |
---|
4893 | } |
---|
4894 | #endif |
---|
4895 | |
---|
4896 | //! \} |
---|