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 | #if REF_IDX_ME_ZEROMV |
---|
2146 | Bool TComDataCU::xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1) |
---|
2147 | { |
---|
2148 | Bool checkZeroMVILR = true; |
---|
2149 | |
---|
2150 | if(uhInterDir&0x1) //list0 |
---|
2151 | { |
---|
2152 | Int refIdxL0 = cMvFieldL0.getRefIdx(); |
---|
2153 | if(getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->getIsILR()) |
---|
2154 | checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0); |
---|
2155 | } |
---|
2156 | if(uhInterDir&0x2) //list1 |
---|
2157 | { |
---|
2158 | Int refIdxL1 = cMvFieldL1.getRefIdx(); |
---|
2159 | if(getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->getIsILR()) |
---|
2160 | checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0); |
---|
2161 | } |
---|
2162 | |
---|
2163 | return checkZeroMVILR; |
---|
2164 | } |
---|
2165 | |
---|
2166 | Bool TComDataCU::xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx) |
---|
2167 | { |
---|
2168 | RefPicList eRefPicList = iRefList > 0? REF_PIC_LIST_1: REF_PIC_LIST_0; |
---|
2169 | assert(eRefPicList == REF_PIC_LIST_1); |
---|
2170 | |
---|
2171 | Bool checkZeroMVILR = true; |
---|
2172 | |
---|
2173 | if(getSlice()->getRefPic(eRefPicList, iRefIdx)->getIsILR()) |
---|
2174 | { |
---|
2175 | AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
2176 | TComMv cMv = pcAMVPInfo->m_acMvCand[MvpIdx]; |
---|
2177 | checkZeroMVILR &= (cMv.getHor() == 0 && cMv.getVer() == 0); |
---|
2178 | } |
---|
2179 | |
---|
2180 | return checkZeroMVILR; |
---|
2181 | } |
---|
2182 | #endif |
---|
2183 | |
---|
2184 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
---|
2185 | { |
---|
2186 | TComDataCU* pcTempCU; |
---|
2187 | UInt uiTempPartIdx; |
---|
2188 | UInt uiCtx = 0; |
---|
2189 | |
---|
2190 | // Get BCBP of left PU |
---|
2191 | #if DEPENDENT_SLICES |
---|
2192 | Bool bDepSliceRestriction = ( !m_pcSlice->getPPS()->getDependentSliceEnabledFlag()); |
---|
2193 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
2194 | #else |
---|
2195 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2196 | #endif |
---|
2197 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2198 | |
---|
2199 | // Get BCBP of above PU |
---|
2200 | #if DEPENDENT_SLICES |
---|
2201 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
2202 | #else |
---|
2203 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2204 | #endif |
---|
2205 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2206 | |
---|
2207 | return uiCtx; |
---|
2208 | } |
---|
2209 | |
---|
2210 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
---|
2211 | { |
---|
2212 | return getDepth( uiAbsPartIdx ); |
---|
2213 | } |
---|
2214 | |
---|
2215 | Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2216 | { |
---|
2217 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2218 | memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2219 | memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2220 | memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2221 | } |
---|
2222 | |
---|
2223 | Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2224 | { |
---|
2225 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2226 | memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2227 | } |
---|
2228 | |
---|
2229 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
2230 | * \param uiCbf The value of the coded block flag to be set |
---|
2231 | * \param eTType |
---|
2232 | * \param uiAbsPartIdx |
---|
2233 | * \param uiPartIdx |
---|
2234 | * \param uiDepth |
---|
2235 | * \returns Void |
---|
2236 | */ |
---|
2237 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2238 | { |
---|
2239 | setSubPart<UChar>( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2240 | } |
---|
2241 | |
---|
2242 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
2243 | { |
---|
2244 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2245 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2246 | } |
---|
2247 | |
---|
2248 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
---|
2249 | { |
---|
2250 | UInt uiPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2251 | return (((m_uiAbsIdxInLCU + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
2252 | } |
---|
2253 | |
---|
2254 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2255 | { |
---|
2256 | assert( sizeof( *m_pePartSize) == 1 ); |
---|
2257 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2258 | } |
---|
2259 | |
---|
2260 | Void TComDataCU::setCUTransquantBypassSubParts( bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2261 | { |
---|
2262 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2263 | } |
---|
2264 | |
---|
2265 | #if SKIP_FLAG |
---|
2266 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
---|
2267 | { |
---|
2268 | assert( sizeof( *m_skipFlag) == 1 ); |
---|
2269 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); |
---|
2270 | } |
---|
2271 | #endif |
---|
2272 | |
---|
2273 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2274 | { |
---|
2275 | assert( sizeof( *m_pePredMode) == 1 ); |
---|
2276 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2277 | } |
---|
2278 | |
---|
2279 | Void TComDataCU::setQPSubCUs( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
---|
2280 | { |
---|
2281 | UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); |
---|
2282 | UInt currPartNumQ = currPartNumb >> 2; |
---|
2283 | |
---|
2284 | if(!foundNonZeroCbf) |
---|
2285 | { |
---|
2286 | if(pcCU->getDepth(absPartIdx) > depth) |
---|
2287 | { |
---|
2288 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
---|
2289 | { |
---|
2290 | pcCU->setQPSubCUs( qp, pcCU, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
---|
2291 | } |
---|
2292 | } |
---|
2293 | else |
---|
2294 | { |
---|
2295 | if(pcCU->getCbf( absPartIdx, TEXT_LUMA ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_U ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_V ) ) |
---|
2296 | { |
---|
2297 | foundNonZeroCbf = true; |
---|
2298 | } |
---|
2299 | else |
---|
2300 | { |
---|
2301 | setQPSubParts(qp, absPartIdx, depth); |
---|
2302 | } |
---|
2303 | } |
---|
2304 | } |
---|
2305 | } |
---|
2306 | |
---|
2307 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2308 | { |
---|
2309 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2310 | TComSlice * pcSlice = getPic()->getSlice(getPic()->getCurrSliceIdx()); |
---|
2311 | |
---|
2312 | for(UInt uiSCUIdx = uiAbsPartIdx; uiSCUIdx < uiAbsPartIdx+uiCurrPartNumb; uiSCUIdx++) |
---|
2313 | { |
---|
2314 | if( m_pcPic->getCU( getAddr() )->getDependentSliceStartCU(uiSCUIdx+getZorderIdxInCU()) == pcSlice->getDependentSliceCurStartCUAddr() ) |
---|
2315 | { |
---|
2316 | m_phQP[uiSCUIdx] = qp; |
---|
2317 | } |
---|
2318 | } |
---|
2319 | } |
---|
2320 | |
---|
2321 | Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2322 | { |
---|
2323 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2324 | |
---|
2325 | memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2326 | } |
---|
2327 | |
---|
2328 | template<typename T> |
---|
2329 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2330 | { |
---|
2331 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
---|
2332 | |
---|
2333 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
---|
2334 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2335 | { |
---|
2336 | case SIZE_2Nx2N: |
---|
2337 | memset( puhBaseLCU + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
---|
2338 | break; |
---|
2339 | case SIZE_2NxN: |
---|
2340 | memset( puhBaseLCU + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
---|
2341 | break; |
---|
2342 | case SIZE_Nx2N: |
---|
2343 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2344 | memset( puhBaseLCU + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
---|
2345 | break; |
---|
2346 | case SIZE_NxN: |
---|
2347 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2348 | break; |
---|
2349 | case SIZE_2NxnU: |
---|
2350 | if ( uiPUIdx == 0 ) |
---|
2351 | { |
---|
2352 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2353 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2354 | } |
---|
2355 | else if ( uiPUIdx == 1 ) |
---|
2356 | { |
---|
2357 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2358 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
---|
2359 | } |
---|
2360 | else |
---|
2361 | { |
---|
2362 | assert(0); |
---|
2363 | } |
---|
2364 | break; |
---|
2365 | case SIZE_2NxnD: |
---|
2366 | if ( uiPUIdx == 0 ) |
---|
2367 | { |
---|
2368 | memset( puhBaseLCU + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
---|
2369 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2370 | } |
---|
2371 | else if ( uiPUIdx == 1 ) |
---|
2372 | { |
---|
2373 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2374 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2375 | } |
---|
2376 | else |
---|
2377 | { |
---|
2378 | assert(0); |
---|
2379 | } |
---|
2380 | break; |
---|
2381 | case SIZE_nLx2N: |
---|
2382 | if ( uiPUIdx == 0 ) |
---|
2383 | { |
---|
2384 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2385 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2386 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2387 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2388 | } |
---|
2389 | else if ( uiPUIdx == 1 ) |
---|
2390 | { |
---|
2391 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2392 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2393 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2394 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2395 | } |
---|
2396 | else |
---|
2397 | { |
---|
2398 | assert(0); |
---|
2399 | } |
---|
2400 | break; |
---|
2401 | case SIZE_nRx2N: |
---|
2402 | if ( uiPUIdx == 0 ) |
---|
2403 | { |
---|
2404 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2405 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2406 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2407 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2408 | } |
---|
2409 | else if ( uiPUIdx == 1 ) |
---|
2410 | { |
---|
2411 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2412 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2413 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2414 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2415 | } |
---|
2416 | else |
---|
2417 | { |
---|
2418 | assert(0); |
---|
2419 | } |
---|
2420 | break; |
---|
2421 | default: |
---|
2422 | assert( 0 ); |
---|
2423 | } |
---|
2424 | } |
---|
2425 | |
---|
2426 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2427 | { |
---|
2428 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2429 | } |
---|
2430 | |
---|
2431 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2432 | { |
---|
2433 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2434 | } |
---|
2435 | |
---|
2436 | Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2437 | { |
---|
2438 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2439 | |
---|
2440 | memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2441 | } |
---|
2442 | |
---|
2443 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2444 | { |
---|
2445 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2446 | } |
---|
2447 | |
---|
2448 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2449 | { |
---|
2450 | setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2451 | } |
---|
2452 | |
---|
2453 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2454 | { |
---|
2455 | setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2456 | } |
---|
2457 | |
---|
2458 | |
---|
2459 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2460 | { |
---|
2461 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2462 | |
---|
2463 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
2464 | } |
---|
2465 | |
---|
2466 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2467 | { |
---|
2468 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2469 | |
---|
2470 | memset( m_puhTransformSkip[0] + uiAbsPartIdx, useTransformSkipY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2471 | memset( m_puhTransformSkip[1] + uiAbsPartIdx, useTransformSkipU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2472 | memset( m_puhTransformSkip[2] + uiAbsPartIdx, useTransformSkipV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2473 | } |
---|
2474 | |
---|
2475 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth) |
---|
2476 | { |
---|
2477 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2478 | |
---|
2479 | memset( m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2480 | } |
---|
2481 | |
---|
2482 | #if !REMOVE_NSQT |
---|
2483 | Void TComDataCU::setNSQTIdxSubParts( UInt absPartIdx, UInt depth ) |
---|
2484 | { |
---|
2485 | UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); |
---|
2486 | |
---|
2487 | memset( m_nsqtPartIdx + absPartIdx, absPartIdx, sizeof(UChar)*currPartNumb ); |
---|
2488 | } |
---|
2489 | |
---|
2490 | Void TComDataCU::setNSQTIdxSubParts( UInt log2TrafoSize, UInt absPartIdx, UInt absTUPartIdx, UInt trMode ) |
---|
2491 | { |
---|
2492 | UInt trWidth, trHeight; |
---|
2493 | UInt nsTUWidthInBaseUnits, nsTUHeightInBaseUnits; |
---|
2494 | UInt lcuWidthInBaseUnits = getPic()->getNumPartInWidth(); |
---|
2495 | |
---|
2496 | UInt minTuSize = ( 1 << getSlice()->getSPS()->getQuadtreeTULog2MinSize() ); |
---|
2497 | |
---|
2498 | trWidth = trHeight = ( 1 << log2TrafoSize ); |
---|
2499 | |
---|
2500 | if ( useNonSquareTrans( trMode, absPartIdx ) && ( trWidth > minTuSize ) ) |
---|
2501 | { |
---|
2502 | trWidth = ( m_pePartSize[absPartIdx] == SIZE_Nx2N || m_pePartSize[absPartIdx] == SIZE_nLx2N || m_pePartSize[absPartIdx] == SIZE_nRx2N )? trWidth >> 1 : trWidth << 1; |
---|
2503 | trHeight = ( m_pePartSize[absPartIdx] == SIZE_Nx2N || m_pePartSize[absPartIdx] == SIZE_nLx2N || m_pePartSize[absPartIdx] == SIZE_nRx2N )? trHeight << 1 : trHeight >> 1; |
---|
2504 | } |
---|
2505 | |
---|
2506 | nsTUWidthInBaseUnits = trWidth / getPic()->getMinCUWidth(); |
---|
2507 | nsTUHeightInBaseUnits = trHeight / getPic()->getMinCUHeight(); |
---|
2508 | |
---|
2509 | if ( nsTUWidthInBaseUnits > nsTUHeightInBaseUnits ) |
---|
2510 | { |
---|
2511 | UInt currPartNumb = nsTUHeightInBaseUnits*nsTUHeightInBaseUnits; |
---|
2512 | memset( m_nsqtPartIdx + absTUPartIdx , absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2513 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+ nsTUHeightInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2514 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+2*nsTUHeightInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2515 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+3*nsTUHeightInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2516 | } |
---|
2517 | else if ( nsTUWidthInBaseUnits < nsTUHeightInBaseUnits ) |
---|
2518 | { |
---|
2519 | UInt currPartNumb = nsTUWidthInBaseUnits*nsTUWidthInBaseUnits; |
---|
2520 | memset( m_nsqtPartIdx + absTUPartIdx , absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2521 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+ nsTUWidthInBaseUnits*lcuWidthInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2522 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+2*nsTUWidthInBaseUnits*lcuWidthInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2523 | memset( m_nsqtPartIdx + g_auiRasterToZscan[g_auiZscanToRaster[absTUPartIdx]+3*nsTUWidthInBaseUnits*lcuWidthInBaseUnits], absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2524 | } |
---|
2525 | else |
---|
2526 | { |
---|
2527 | UInt currPartNumb = nsTUWidthInBaseUnits*nsTUHeightInBaseUnits; |
---|
2528 | memset( m_nsqtPartIdx + absTUPartIdx, absPartIdx, sizeof(UChar)*(currPartNumb) ); |
---|
2529 | } |
---|
2530 | } |
---|
2531 | #endif |
---|
2532 | |
---|
2533 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2534 | { |
---|
2535 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2536 | |
---|
2537 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2538 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
2539 | } |
---|
2540 | |
---|
2541 | UChar TComDataCU::getNumPartInter() |
---|
2542 | { |
---|
2543 | UChar iNumPart = 0; |
---|
2544 | |
---|
2545 | switch ( m_pePartSize[0] ) |
---|
2546 | { |
---|
2547 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
2548 | case SIZE_2NxN: iNumPart = 2; break; |
---|
2549 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
2550 | case SIZE_NxN: iNumPart = 4; break; |
---|
2551 | case SIZE_2NxnU: iNumPart = 2; break; |
---|
2552 | case SIZE_2NxnD: iNumPart = 2; break; |
---|
2553 | case SIZE_nLx2N: iNumPart = 2; break; |
---|
2554 | case SIZE_nRx2N: iNumPart = 2; break; |
---|
2555 | default: assert (0); break; |
---|
2556 | } |
---|
2557 | |
---|
2558 | return iNumPart; |
---|
2559 | } |
---|
2560 | |
---|
2561 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
---|
2562 | { |
---|
2563 | switch ( m_pePartSize[0] ) |
---|
2564 | { |
---|
2565 | case SIZE_2NxN: |
---|
2566 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2567 | break; |
---|
2568 | case SIZE_Nx2N: |
---|
2569 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
2570 | break; |
---|
2571 | case SIZE_NxN: |
---|
2572 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2573 | break; |
---|
2574 | case SIZE_2NxnU: |
---|
2575 | riWidth = getWidth(0); |
---|
2576 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
2577 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
---|
2578 | break; |
---|
2579 | case SIZE_2NxnD: |
---|
2580 | riWidth = getWidth(0); |
---|
2581 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
2582 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
---|
2583 | break; |
---|
2584 | case SIZE_nLx2N: |
---|
2585 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
2586 | riHeight = getHeight(0); |
---|
2587 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
---|
2588 | break; |
---|
2589 | case SIZE_nRx2N: |
---|
2590 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
2591 | riHeight = getHeight(0); |
---|
2592 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2593 | break; |
---|
2594 | default: |
---|
2595 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
2596 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
2597 | break; |
---|
2598 | } |
---|
2599 | } |
---|
2600 | |
---|
2601 | |
---|
2602 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
2603 | { |
---|
2604 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
2605 | { |
---|
2606 | TComMv cZeroMv; |
---|
2607 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
2608 | return; |
---|
2609 | } |
---|
2610 | |
---|
2611 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
2612 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
2613 | } |
---|
2614 | |
---|
2615 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2616 | { |
---|
2617 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
2618 | UInt uiPUWidth = 0; |
---|
2619 | |
---|
2620 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2621 | { |
---|
2622 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2623 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2624 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2625 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2626 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2627 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2628 | case SIZE_nLx2N: |
---|
2629 | if ( uiPartIdx == 0 ) |
---|
2630 | { |
---|
2631 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
2632 | } |
---|
2633 | else if ( uiPartIdx == 1 ) |
---|
2634 | { |
---|
2635 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
2636 | } |
---|
2637 | else |
---|
2638 | { |
---|
2639 | assert(0); |
---|
2640 | } |
---|
2641 | break; |
---|
2642 | case SIZE_nRx2N: |
---|
2643 | if ( uiPartIdx == 0 ) |
---|
2644 | { |
---|
2645 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
2646 | } |
---|
2647 | else if ( uiPartIdx == 1 ) |
---|
2648 | { |
---|
2649 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
2650 | } |
---|
2651 | else |
---|
2652 | { |
---|
2653 | assert(0); |
---|
2654 | } |
---|
2655 | break; |
---|
2656 | default: |
---|
2657 | assert (0); |
---|
2658 | break; |
---|
2659 | } |
---|
2660 | |
---|
2661 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2662 | } |
---|
2663 | |
---|
2664 | Void TComDataCU::deriveLeftBottomIdxGeneral( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2665 | { |
---|
2666 | UInt uiPUHeight = 0; |
---|
2667 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2668 | { |
---|
2669 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2670 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2671 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2672 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2673 | case SIZE_2NxnU: |
---|
2674 | if ( uiPartIdx == 0 ) |
---|
2675 | { |
---|
2676 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
2677 | } |
---|
2678 | else if ( uiPartIdx == 1 ) |
---|
2679 | { |
---|
2680 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
2681 | } |
---|
2682 | else |
---|
2683 | { |
---|
2684 | assert(0); |
---|
2685 | } |
---|
2686 | break; |
---|
2687 | case SIZE_2NxnD: |
---|
2688 | if ( uiPartIdx == 0 ) |
---|
2689 | { |
---|
2690 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
2691 | } |
---|
2692 | else if ( uiPartIdx == 1 ) |
---|
2693 | { |
---|
2694 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
2695 | } |
---|
2696 | else |
---|
2697 | { |
---|
2698 | assert(0); |
---|
2699 | } |
---|
2700 | break; |
---|
2701 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2702 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2703 | default: |
---|
2704 | assert (0); |
---|
2705 | break; |
---|
2706 | } |
---|
2707 | |
---|
2708 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
2709 | } |
---|
2710 | |
---|
2711 | Void TComDataCU::deriveLeftRightTopIdx ( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2712 | { |
---|
2713 | ruiPartIdxLT = m_uiAbsIdxInLCU; |
---|
2714 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2715 | |
---|
2716 | switch ( m_pePartSize[0] ) |
---|
2717 | { |
---|
2718 | case SIZE_2Nx2N: break; |
---|
2719 | case SIZE_2NxN: |
---|
2720 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2721 | break; |
---|
2722 | case SIZE_Nx2N: |
---|
2723 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
2724 | break; |
---|
2725 | case SIZE_NxN: |
---|
2726 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2727 | break; |
---|
2728 | case SIZE_2NxnU: |
---|
2729 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2730 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2731 | break; |
---|
2732 | case SIZE_2NxnD: |
---|
2733 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2734 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2735 | break; |
---|
2736 | case SIZE_nLx2N: |
---|
2737 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
---|
2738 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2739 | break; |
---|
2740 | case SIZE_nRx2N: |
---|
2741 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2742 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
---|
2743 | break; |
---|
2744 | default: |
---|
2745 | assert (0); |
---|
2746 | break; |
---|
2747 | } |
---|
2748 | |
---|
2749 | } |
---|
2750 | |
---|
2751 | Void TComDataCU::deriveLeftBottomIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2752 | { |
---|
2753 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
2754 | |
---|
2755 | switch ( m_pePartSize[0] ) |
---|
2756 | { |
---|
2757 | case SIZE_2Nx2N: |
---|
2758 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
2759 | break; |
---|
2760 | case SIZE_2NxN: |
---|
2761 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2762 | break; |
---|
2763 | case SIZE_Nx2N: |
---|
2764 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
2765 | break; |
---|
2766 | case SIZE_NxN: |
---|
2767 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2768 | break; |
---|
2769 | case SIZE_2NxnU: |
---|
2770 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
2771 | break; |
---|
2772 | case SIZE_2NxnD: |
---|
2773 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
2774 | break; |
---|
2775 | case SIZE_nLx2N: |
---|
2776 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
---|
2777 | break; |
---|
2778 | case SIZE_nRx2N: |
---|
2779 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2780 | break; |
---|
2781 | default: |
---|
2782 | assert (0); |
---|
2783 | break; |
---|
2784 | } |
---|
2785 | } |
---|
2786 | |
---|
2787 | /** Derives the partition index of neighbouring bottom right block |
---|
2788 | * \param [in] eCUMode |
---|
2789 | * \param [in] uiPartIdx |
---|
2790 | * \param [out] ruiPartIdxRB |
---|
2791 | */ |
---|
2792 | Void TComDataCU::deriveRightBottomIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxRB ) |
---|
2793 | { |
---|
2794 | 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]; |
---|
2795 | |
---|
2796 | switch ( m_pePartSize[0] ) |
---|
2797 | { |
---|
2798 | case SIZE_2Nx2N: |
---|
2799 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
2800 | break; |
---|
2801 | case SIZE_2NxN: |
---|
2802 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2803 | break; |
---|
2804 | case SIZE_Nx2N: |
---|
2805 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
2806 | break; |
---|
2807 | case SIZE_NxN: |
---|
2808 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2809 | break; |
---|
2810 | case SIZE_2NxnU: |
---|
2811 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
2812 | break; |
---|
2813 | case SIZE_2NxnD: |
---|
2814 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
2815 | break; |
---|
2816 | case SIZE_nLx2N: |
---|
2817 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
---|
2818 | break; |
---|
2819 | case SIZE_nRx2N: |
---|
2820 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
---|
2821 | break; |
---|
2822 | default: |
---|
2823 | assert (0); |
---|
2824 | break; |
---|
2825 | } |
---|
2826 | } |
---|
2827 | |
---|
2828 | Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ) |
---|
2829 | { |
---|
2830 | UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; |
---|
2831 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset; |
---|
2832 | ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; |
---|
2833 | } |
---|
2834 | |
---|
2835 | Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ) |
---|
2836 | { |
---|
2837 | UInt uiAbsIdx; |
---|
2838 | UInt uiMinCuWidth, uiWidthInMinCus; |
---|
2839 | |
---|
2840 | uiMinCuWidth = getPic()->getMinCUWidth(); |
---|
2841 | uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; |
---|
2842 | uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; |
---|
2843 | uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); |
---|
2844 | ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; |
---|
2845 | } |
---|
2846 | |
---|
2847 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
2848 | { |
---|
2849 | |
---|
2850 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
2851 | { |
---|
2852 | return false; |
---|
2853 | } |
---|
2854 | |
---|
2855 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
2856 | { |
---|
2857 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
2858 | { |
---|
2859 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
2860 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
2861 | { |
---|
2862 | return false; |
---|
2863 | } |
---|
2864 | } |
---|
2865 | } |
---|
2866 | |
---|
2867 | return true; |
---|
2868 | } |
---|
2869 | |
---|
2870 | /** Constructs a list of merging candidates |
---|
2871 | * \param uiAbsPartIdx |
---|
2872 | * \param uiPUIdx |
---|
2873 | * \param uiDepth |
---|
2874 | * \param pcMvFieldNeighbours |
---|
2875 | * \param puhInterDirNeighbours |
---|
2876 | * \param numValidMergeCand |
---|
2877 | */ |
---|
2878 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) |
---|
2879 | { |
---|
2880 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
2881 | #if !BUGFIX_925 |
---|
2882 | UInt uiIdx = 1; |
---|
2883 | #endif |
---|
2884 | bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
2885 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
2886 | { |
---|
2887 | abCandIsInter[ui] = false; |
---|
2888 | } |
---|
2889 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
2890 | // compute the location of the current PU |
---|
2891 | Int xP, yP, nPSW, nPSH; |
---|
2892 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
2893 | |
---|
2894 | Int iCount = 0; |
---|
2895 | |
---|
2896 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
2897 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
2898 | deriveLeftRightTopIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
2899 | deriveLeftBottomIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
2900 | |
---|
2901 | #if SVC_MVP |
---|
2902 | // BL collocated |
---|
2903 | TComDataCU *pcColCU = 0; |
---|
2904 | UInt uiCUAddrBase, uiAbsPartAddrBase ; |
---|
2905 | TComMvField cMvFieldBaseColCU[2]; |
---|
2906 | if(m_layerId) |
---|
2907 | { |
---|
2908 | UInt uiPartIdxCenter; |
---|
2909 | xDeriveCenterIdx( cCurPS, uiPUIdx, uiPartIdxCenter ); |
---|
2910 | uiPartIdxCenter -= m_uiAbsIdxInLCU; |
---|
2911 | pcColCU = getBaseColCU( uiPartIdxCenter, uiCUAddrBase, uiAbsPartAddrBase ); |
---|
2912 | |
---|
2913 | #if INTRA_BL |
---|
2914 | if( pcColCU && pcColCU->isIntraBL( uiAbsPartAddrBase ) ) |
---|
2915 | { |
---|
2916 | pcColCU = NULL; |
---|
2917 | } |
---|
2918 | #endif |
---|
2919 | |
---|
2920 | if(pcColCU && !pcColCU->isIntra( uiAbsPartAddrBase ) ) |
---|
2921 | { |
---|
2922 | abCandIsInter[iCount] = true; |
---|
2923 | |
---|
2924 | // get interDir |
---|
2925 | puhInterDirNeighbours[iCount] = pcColCU->getInterDir( uiAbsPartAddrBase ); |
---|
2926 | |
---|
2927 | pcMvFieldNeighbours[(iCount << 1)].setMvField( TComMv(0,0), -1); |
---|
2928 | pcMvFieldNeighbours[(iCount << 1) + 1].setMvField( TComMv(0,0), -1); |
---|
2929 | |
---|
2930 | if( puhInterDirNeighbours[iCount] & 1 ) |
---|
2931 | { |
---|
2932 | pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_0, cMvFieldBaseColCU[0]); |
---|
2933 | scaleBaseMV( pcMvFieldNeighbours[iCount<<1], cMvFieldBaseColCU[0] ); |
---|
2934 | } |
---|
2935 | |
---|
2936 | if ( getSlice()->isInterB() && puhInterDirNeighbours[iCount] & 2 ) |
---|
2937 | { |
---|
2938 | pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_1, cMvFieldBaseColCU[1] ); |
---|
2939 | scaleBaseMV( pcMvFieldNeighbours[(iCount<<1)+1], cMvFieldBaseColCU[1] ); |
---|
2940 | } |
---|
2941 | |
---|
2942 | if( puhInterDirNeighbours[iCount] > 0 ) |
---|
2943 | { |
---|
2944 | if ( mrgCandIdx == iCount ) |
---|
2945 | { |
---|
2946 | return; |
---|
2947 | } |
---|
2948 | iCount ++; |
---|
2949 | } |
---|
2950 | } |
---|
2951 | } |
---|
2952 | #endif |
---|
2953 | |
---|
2954 | //left |
---|
2955 | UInt uiLeftPartIdx = 0; |
---|
2956 | TComDataCU* pcCULeft = 0; |
---|
2957 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB, true, false ); |
---|
2958 | #if INTRA_BL |
---|
2959 | if( pcCULeft && pcCULeft->isIntraBL( uiLeftPartIdx ) ) |
---|
2960 | { |
---|
2961 | pcCULeft = NULL; |
---|
2962 | } |
---|
2963 | #endif |
---|
2964 | if (pcCULeft) |
---|
2965 | { |
---|
2966 | if (!pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP)) |
---|
2967 | { |
---|
2968 | pcCULeft = NULL; |
---|
2969 | } |
---|
2970 | } |
---|
2971 | PartSize partSize = getPartitionSize( uiAbsPartIdx ); |
---|
2972 | if (!(uiPUIdx == 1 && (partSize == SIZE_Nx2N || partSize == SIZE_nLx2N || partSize == SIZE_nRx2N))) |
---|
2973 | { |
---|
2974 | #if SVC_MVP |
---|
2975 | if ( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx ) && ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0]))) |
---|
2976 | #else |
---|
2977 | if ( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx ) ) |
---|
2978 | #endif |
---|
2979 | { |
---|
2980 | abCandIsInter[iCount] = true; |
---|
2981 | // get Inter Dir |
---|
2982 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
2983 | // get Mv from Left |
---|
2984 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2985 | if ( getSlice()->isInterB() ) |
---|
2986 | { |
---|
2987 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2988 | } |
---|
2989 | if ( mrgCandIdx == iCount ) |
---|
2990 | { |
---|
2991 | return; |
---|
2992 | } |
---|
2993 | iCount ++; |
---|
2994 | } |
---|
2995 | } |
---|
2996 | |
---|
2997 | // early termination |
---|
2998 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2999 | { |
---|
3000 | return; |
---|
3001 | } |
---|
3002 | // above |
---|
3003 | UInt uiAbovePartIdx = 0; |
---|
3004 | TComDataCU* pcCUAbove = 0; |
---|
3005 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT, true, false, true ); |
---|
3006 | #if INTRA_BL |
---|
3007 | if( pcCUAbove && pcCUAbove->isIntraBL( uiAbovePartIdx ) ) |
---|
3008 | { |
---|
3009 | pcCUAbove = NULL; |
---|
3010 | } |
---|
3011 | #endif |
---|
3012 | if (pcCUAbove) |
---|
3013 | { |
---|
3014 | if (!pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP)) |
---|
3015 | { |
---|
3016 | pcCUAbove = NULL; |
---|
3017 | } |
---|
3018 | } |
---|
3019 | #if SVC_MVP |
---|
3020 | if ( pcCUAbove && !pcCUAbove->isIntra( uiAbovePartIdx ) |
---|
3021 | && !(uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD)) |
---|
3022 | && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) |
---|
3023 | && ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) ) |
---|
3024 | #else |
---|
3025 | if ( pcCUAbove && !pcCUAbove->isIntra( uiAbovePartIdx ) |
---|
3026 | && !(uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD)) |
---|
3027 | && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
3028 | #endif |
---|
3029 | { |
---|
3030 | abCandIsInter[iCount] = true; |
---|
3031 | // get Inter Dir |
---|
3032 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
3033 | // get Mv from Left |
---|
3034 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3035 | if ( getSlice()->isInterB() ) |
---|
3036 | { |
---|
3037 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3038 | } |
---|
3039 | if ( mrgCandIdx == iCount ) |
---|
3040 | { |
---|
3041 | return; |
---|
3042 | } |
---|
3043 | iCount ++; |
---|
3044 | } |
---|
3045 | // early termination |
---|
3046 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3047 | { |
---|
3048 | return; |
---|
3049 | } |
---|
3050 | |
---|
3051 | // above right |
---|
3052 | UInt uiAboveRightPartIdx = 0; |
---|
3053 | TComDataCU* pcCUAboveRight = 0; |
---|
3054 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT, true, false, true ); |
---|
3055 | if (pcCUAboveRight) |
---|
3056 | { |
---|
3057 | if (!pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP)) |
---|
3058 | { |
---|
3059 | pcCUAboveRight = NULL; |
---|
3060 | } |
---|
3061 | } |
---|
3062 | #if SVC_MVP |
---|
3063 | if ( pcCUAboveRight && !pcCUAboveRight->isIntra( uiAboveRightPartIdx ) && ( !pcCUAbove || pcCUAbove->isIntra( uiAbovePartIdx ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) |
---|
3064 | && ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveRight->hasEqualMotion( uiAboveRightPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) ) |
---|
3065 | #else |
---|
3066 | if ( pcCUAboveRight && !pcCUAboveRight->isIntra( uiAboveRightPartIdx ) && ( !pcCUAbove || pcCUAbove->isIntra( uiAbovePartIdx ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
3067 | #endif |
---|
3068 | { |
---|
3069 | abCandIsInter[iCount] = true; |
---|
3070 | // get Inter Dir |
---|
3071 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
3072 | // get Mv from Left |
---|
3073 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3074 | if ( getSlice()->isInterB() ) |
---|
3075 | { |
---|
3076 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3077 | } |
---|
3078 | if ( mrgCandIdx == iCount ) |
---|
3079 | { |
---|
3080 | return; |
---|
3081 | } |
---|
3082 | iCount ++; |
---|
3083 | } |
---|
3084 | // early termination |
---|
3085 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3086 | { |
---|
3087 | return; |
---|
3088 | } |
---|
3089 | |
---|
3090 | //left bottom |
---|
3091 | #if SVC_MVP |
---|
3092 | if( iCount < 4 ) |
---|
3093 | { |
---|
3094 | #endif |
---|
3095 | UInt uiLeftBottomPartIdx = 0; |
---|
3096 | TComDataCU* pcCULeftBottom = 0; |
---|
3097 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB, true, false ); |
---|
3098 | if (pcCULeftBottom) |
---|
3099 | { |
---|
3100 | if (!pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP)) |
---|
3101 | { |
---|
3102 | pcCULeftBottom = NULL; |
---|
3103 | } |
---|
3104 | } |
---|
3105 | #if SVC_MVP |
---|
3106 | if ( pcCULeftBottom && !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) |
---|
3107 | && ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeftBottom->hasEqualMotion( uiLeftBottomPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) ) |
---|
3108 | #else |
---|
3109 | if ( pcCULeftBottom && !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
3110 | #endif |
---|
3111 | { |
---|
3112 | abCandIsInter[iCount] = true; |
---|
3113 | // get Inter Dir |
---|
3114 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
3115 | // get Mv from Left |
---|
3116 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3117 | if ( getSlice()->isInterB() ) |
---|
3118 | { |
---|
3119 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3120 | } |
---|
3121 | if ( mrgCandIdx == iCount ) |
---|
3122 | { |
---|
3123 | return; |
---|
3124 | } |
---|
3125 | iCount ++; |
---|
3126 | } |
---|
3127 | // early termination |
---|
3128 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3129 | { |
---|
3130 | return; |
---|
3131 | } |
---|
3132 | #if SVC_MVP |
---|
3133 | } |
---|
3134 | #endif |
---|
3135 | |
---|
3136 | // above left |
---|
3137 | if( iCount < 4 ) |
---|
3138 | { |
---|
3139 | UInt uiAboveLeftPartIdx = 0; |
---|
3140 | TComDataCU* pcCUAboveLeft = 0; |
---|
3141 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr, true, false, true ); |
---|
3142 | if (pcCUAboveLeft) |
---|
3143 | { |
---|
3144 | if (!pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP)) |
---|
3145 | { |
---|
3146 | pcCUAboveLeft = NULL; |
---|
3147 | } |
---|
3148 | } |
---|
3149 | #if SVC_MVP |
---|
3150 | if( pcCUAboveLeft && !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ) |
---|
3151 | && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
3152 | && ( !pcCUAbove || pcCUAbove->isIntra( uiAbovePartIdx ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
3153 | && ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveLeft->hasEqualMotion( uiAboveLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) |
---|
3154 | ) |
---|
3155 | #else |
---|
3156 | if( pcCUAboveLeft && !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ) |
---|
3157 | && ( !pcCULeft || pcCULeft->isIntra( uiLeftPartIdx ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
3158 | && ( !pcCUAbove || pcCUAbove->isIntra( uiAbovePartIdx ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
3159 | ) |
---|
3160 | #endif |
---|
3161 | { |
---|
3162 | abCandIsInter[iCount] = true; |
---|
3163 | // get Inter Dir |
---|
3164 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
3165 | // get Mv from Left |
---|
3166 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3167 | if ( getSlice()->isInterB() ) |
---|
3168 | { |
---|
3169 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3170 | } |
---|
3171 | if ( mrgCandIdx == iCount ) |
---|
3172 | { |
---|
3173 | return; |
---|
3174 | } |
---|
3175 | iCount ++; |
---|
3176 | } |
---|
3177 | } |
---|
3178 | // early termination |
---|
3179 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3180 | { |
---|
3181 | return; |
---|
3182 | } |
---|
3183 | if ( getSlice()->getEnableTMVPFlag()) |
---|
3184 | { |
---|
3185 | //>> MTK colocated-RightBottom |
---|
3186 | UInt uiPartIdxRB; |
---|
3187 | Int uiLCUIdx = getAddr(); |
---|
3188 | PartSize eCUMode = getPartitionSize( 0 ); |
---|
3189 | |
---|
3190 | deriveRightBottomIdx( eCUMode, uiPUIdx, uiPartIdxRB ); |
---|
3191 | |
---|
3192 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
3193 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
3194 | |
---|
3195 | TComMv cColMv; |
---|
3196 | Int iRefIdx; |
---|
3197 | |
---|
3198 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
3199 | { |
---|
3200 | uiLCUIdx = -1; |
---|
3201 | } |
---|
3202 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
3203 | { |
---|
3204 | uiLCUIdx = -1; |
---|
3205 | } |
---|
3206 | else |
---|
3207 | { |
---|
3208 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
3209 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
3210 | { |
---|
3211 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
3212 | uiLCUIdx = getAddr(); |
---|
3213 | } |
---|
3214 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
3215 | { |
---|
3216 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
3217 | uiLCUIdx = -1 ; |
---|
3218 | } |
---|
3219 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
3220 | { |
---|
3221 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
3222 | uiLCUIdx = getAddr() + 1; |
---|
3223 | } |
---|
3224 | else //is the right bottom corner of LCU |
---|
3225 | { |
---|
3226 | uiAbsPartAddr = 0; |
---|
3227 | uiLCUIdx = -1 ; |
---|
3228 | } |
---|
3229 | } |
---|
3230 | iRefIdx = 0; |
---|
3231 | |
---|
3232 | Bool bExistMV = false; |
---|
3233 | UInt uiPartIdxCenter; |
---|
3234 | UInt uiCurLCUIdx = getAddr(); |
---|
3235 | #if BUGFIX_925 |
---|
3236 | Int dir = 0; |
---|
3237 | UInt uiArrayAddr = iCount; |
---|
3238 | #endif |
---|
3239 | xDeriveCenterIdx( eCUMode, uiPUIdx, uiPartIdxCenter ); |
---|
3240 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
3241 | if( bExistMV == false ) |
---|
3242 | { |
---|
3243 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
3244 | } |
---|
3245 | #if BUGFIX_925 |
---|
3246 | if( bExistMV ) |
---|
3247 | { |
---|
3248 | dir |= 1; |
---|
3249 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
3250 | } |
---|
3251 | |
---|
3252 | if( getSlice()->isInterB() ) |
---|
3253 | { |
---|
3254 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
3255 | if( bExistMV == false ) |
---|
3256 | { |
---|
3257 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
3258 | } |
---|
3259 | if( bExistMV ) |
---|
3260 | { |
---|
3261 | dir |= 2; |
---|
3262 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
3263 | } |
---|
3264 | } |
---|
3265 | |
---|
3266 | if( dir != 0 ) |
---|
3267 | { |
---|
3268 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
3269 | abCandIsInter[uiArrayAddr] = true; |
---|
3270 | |
---|
3271 | if( mrgCandIdx == iCount ) |
---|
3272 | { |
---|
3273 | return; |
---|
3274 | } |
---|
3275 | iCount++; |
---|
3276 | } |
---|
3277 | #else |
---|
3278 | if( bExistMV ) |
---|
3279 | { |
---|
3280 | UInt uiArrayAddr = iCount; |
---|
3281 | abCandIsInter[uiArrayAddr] = true; |
---|
3282 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( cColMv, iRefIdx ); |
---|
3283 | |
---|
3284 | if ( getSlice()->isInterB() ) |
---|
3285 | { |
---|
3286 | iRefIdx = 0; |
---|
3287 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
3288 | if( bExistMV == false ) |
---|
3289 | { |
---|
3290 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
3291 | } |
---|
3292 | if( bExistMV ) |
---|
3293 | { |
---|
3294 | pcMvFieldNeighbours[ ( uiArrayAddr << 1 ) + 1 ].setMvField( cColMv, iRefIdx ); |
---|
3295 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3296 | } |
---|
3297 | else |
---|
3298 | { |
---|
3299 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
3300 | } |
---|
3301 | } |
---|
3302 | else |
---|
3303 | { |
---|
3304 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
3305 | } |
---|
3306 | if ( mrgCandIdx == iCount ) |
---|
3307 | { |
---|
3308 | return; |
---|
3309 | } |
---|
3310 | iCount++; |
---|
3311 | } |
---|
3312 | uiIdx++; |
---|
3313 | #endif |
---|
3314 | |
---|
3315 | } |
---|
3316 | // early termination |
---|
3317 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3318 | { |
---|
3319 | return; |
---|
3320 | } |
---|
3321 | UInt uiArrayAddr = iCount; |
---|
3322 | UInt uiCutoff = uiArrayAddr; |
---|
3323 | |
---|
3324 | if ( getSlice()->isInterB()) |
---|
3325 | { |
---|
3326 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
3327 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
3328 | |
---|
3329 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
3330 | { |
---|
3331 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
3332 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
3333 | { |
---|
3334 | abCandIsInter[uiArrayAddr] = true; |
---|
3335 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3336 | |
---|
3337 | // get Mv from cand[i] and cand[j] |
---|
3338 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
3339 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
3340 | |
---|
3341 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
3342 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
3343 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
3344 | { |
---|
3345 | abCandIsInter[uiArrayAddr] = false; |
---|
3346 | } |
---|
3347 | else |
---|
3348 | { |
---|
3349 | uiArrayAddr++; |
---|
3350 | } |
---|
3351 | } |
---|
3352 | } |
---|
3353 | } |
---|
3354 | // early termination |
---|
3355 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
3356 | { |
---|
3357 | return; |
---|
3358 | } |
---|
3359 | 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); |
---|
3360 | Int r = 0; |
---|
3361 | Int refcnt = 0; |
---|
3362 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
3363 | { |
---|
3364 | abCandIsInter[uiArrayAddr] = true; |
---|
3365 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
3366 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
3367 | |
---|
3368 | if ( getSlice()->isInterB() ) |
---|
3369 | { |
---|
3370 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3371 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
3372 | } |
---|
3373 | uiArrayAddr++; |
---|
3374 | if ( refcnt == iNumRefIdx - 1 ) |
---|
3375 | { |
---|
3376 | r = 0; |
---|
3377 | } |
---|
3378 | else |
---|
3379 | { |
---|
3380 | ++r; |
---|
3381 | ++refcnt; |
---|
3382 | } |
---|
3383 | } |
---|
3384 | |
---|
3385 | numValidMergeCand = uiArrayAddr; |
---|
3386 | } |
---|
3387 | |
---|
3388 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
---|
3389 | * \param xN, xN location of the upper-left corner pixel of a neighboring PU |
---|
3390 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
3391 | * \returns Bool |
---|
3392 | */ |
---|
3393 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) |
---|
3394 | { |
---|
3395 | |
---|
3396 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
---|
3397 | if ((xN>>plevel)!= (xP>>plevel)) |
---|
3398 | { |
---|
3399 | return true; |
---|
3400 | } |
---|
3401 | if ((yN>>plevel)!= (yP>>plevel)) |
---|
3402 | { |
---|
3403 | return true; |
---|
3404 | } |
---|
3405 | return false; |
---|
3406 | } |
---|
3407 | /** calculate the location of upper-left corner pixel and size of the current PU. |
---|
3408 | * \param partIdx PU index within a CU |
---|
3409 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
3410 | * \param PSW, nPSH size of the curren PU |
---|
3411 | * \returns Void |
---|
3412 | */ |
---|
3413 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) |
---|
3414 | { |
---|
3415 | UInt col = m_uiCUPelX; |
---|
3416 | UInt row = m_uiCUPelY; |
---|
3417 | |
---|
3418 | switch ( m_pePartSize[0] ) |
---|
3419 | { |
---|
3420 | case SIZE_2NxN: |
---|
3421 | nPSW = getWidth(0); |
---|
3422 | nPSH = getHeight(0) >> 1; |
---|
3423 | xP = col; |
---|
3424 | yP = (partIdx ==0)? row: row + nPSH; |
---|
3425 | break; |
---|
3426 | case SIZE_Nx2N: |
---|
3427 | nPSW = getWidth(0) >> 1; |
---|
3428 | nPSH = getHeight(0); |
---|
3429 | xP = (partIdx ==0)? col: col + nPSW; |
---|
3430 | yP = row; |
---|
3431 | break; |
---|
3432 | case SIZE_NxN: |
---|
3433 | nPSW = getWidth(0) >> 1; |
---|
3434 | nPSH = getHeight(0) >> 1; |
---|
3435 | xP = col + (partIdx&0x1)*nPSW; |
---|
3436 | yP = row + (partIdx>>1)*nPSH; |
---|
3437 | break; |
---|
3438 | case SIZE_2NxnU: |
---|
3439 | nPSW = getWidth(0); |
---|
3440 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
3441 | xP = col; |
---|
3442 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
3443 | |
---|
3444 | break; |
---|
3445 | case SIZE_2NxnD: |
---|
3446 | nPSW = getWidth(0); |
---|
3447 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
3448 | xP = col; |
---|
3449 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
3450 | break; |
---|
3451 | case SIZE_nLx2N: |
---|
3452 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
3453 | nPSH = getHeight(0); |
---|
3454 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
3455 | yP = row; |
---|
3456 | break; |
---|
3457 | case SIZE_nRx2N: |
---|
3458 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
3459 | nPSH = getHeight(0); |
---|
3460 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
3461 | yP = row; |
---|
3462 | break; |
---|
3463 | default: |
---|
3464 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
3465 | nPSW = getWidth(0); |
---|
3466 | nPSH = getHeight(0); |
---|
3467 | xP = col ; |
---|
3468 | yP = row ; |
---|
3469 | |
---|
3470 | break; |
---|
3471 | } |
---|
3472 | } |
---|
3473 | |
---|
3474 | #if !SPS_AMVP_CLEANUP |
---|
3475 | AMVP_MODE TComDataCU::getAMVPMode(UInt uiIdx) |
---|
3476 | { |
---|
3477 | return m_pcSlice->getSPS()->getAMVPMode(m_puhDepth[uiIdx]); |
---|
3478 | } |
---|
3479 | #endif |
---|
3480 | |
---|
3481 | /** Constructs a list of candidates for AMVP |
---|
3482 | * \param uiPartIdx |
---|
3483 | * \param uiPartAddr |
---|
3484 | * \param eRefPicList |
---|
3485 | * \param iRefIdx |
---|
3486 | * \param pInfo |
---|
3487 | */ |
---|
3488 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
---|
3489 | { |
---|
3490 | PartSize eCUMode = getPartitionSize( 0 ); |
---|
3491 | |
---|
3492 | TComMv cMvPred; |
---|
3493 | Bool bAddedSmvp = false; |
---|
3494 | |
---|
3495 | pInfo->iN = 0; |
---|
3496 | if (iRefIdx < 0) |
---|
3497 | { |
---|
3498 | return; |
---|
3499 | } |
---|
3500 | |
---|
3501 | //-- Get Spatial MV |
---|
3502 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
3503 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
3504 | Bool bAdded = false; |
---|
3505 | |
---|
3506 | deriveLeftRightTopIdx( eCUMode, uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
3507 | deriveLeftBottomIdx( eCUMode, uiPartIdx, uiPartIdxLB ); |
---|
3508 | |
---|
3509 | TComDataCU* tmpCU = NULL; |
---|
3510 | UInt idx; |
---|
3511 | tmpCU = getPUBelowLeft(idx, uiPartIdxLB, true, false); |
---|
3512 | #if INTRA_BL |
---|
3513 | bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx)); |
---|
3514 | #else |
---|
3515 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
3516 | #endif |
---|
3517 | |
---|
3518 | if (!bAddedSmvp) |
---|
3519 | { |
---|
3520 | tmpCU = getPULeft(idx, uiPartIdxLB, true, false); |
---|
3521 | #if INTRA_BL |
---|
3522 | bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx)); |
---|
3523 | #else |
---|
3524 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
3525 | #endif |
---|
3526 | } |
---|
3527 | |
---|
3528 | // Left predictor search |
---|
3529 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
3530 | if (!bAdded) |
---|
3531 | { |
---|
3532 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
3533 | } |
---|
3534 | |
---|
3535 | if(!bAdded) |
---|
3536 | { |
---|
3537 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
3538 | if (!bAdded) |
---|
3539 | { |
---|
3540 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
3541 | } |
---|
3542 | } |
---|
3543 | // Above predictor search |
---|
3544 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
3545 | |
---|
3546 | if (!bAdded) |
---|
3547 | { |
---|
3548 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
3549 | } |
---|
3550 | |
---|
3551 | if(!bAdded) |
---|
3552 | { |
---|
3553 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
3554 | } |
---|
3555 | bAdded = bAddedSmvp; |
---|
3556 | if (pInfo->iN==2) bAdded = true; |
---|
3557 | |
---|
3558 | if(!bAdded) |
---|
3559 | { |
---|
3560 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
3561 | if (!bAdded) |
---|
3562 | { |
---|
3563 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
3564 | } |
---|
3565 | |
---|
3566 | if(!bAdded) |
---|
3567 | { |
---|
3568 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
3569 | } |
---|
3570 | } |
---|
3571 | |
---|
3572 | #if !SPS_AMVP_CLEANUP |
---|
3573 | if (getAMVPMode(uiPartAddr) == AM_NONE) //Should be optimized later for special cases |
---|
3574 | { |
---|
3575 | assert(pInfo->iN > 0); |
---|
3576 | pInfo->iN = 1; |
---|
3577 | return; |
---|
3578 | } |
---|
3579 | #endif |
---|
3580 | |
---|
3581 | if ( pInfo->iN == 2 ) |
---|
3582 | { |
---|
3583 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
---|
3584 | { |
---|
3585 | pInfo->iN = 1; |
---|
3586 | } |
---|
3587 | } |
---|
3588 | |
---|
3589 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
3590 | { |
---|
3591 | // Get Temporal Motion Predictor |
---|
3592 | int iRefIdx_Col = iRefIdx; |
---|
3593 | TComMv cColMv; |
---|
3594 | UInt uiPartIdxRB; |
---|
3595 | UInt uiAbsPartIdx; |
---|
3596 | UInt uiAbsPartAddr; |
---|
3597 | int uiLCUIdx = getAddr(); |
---|
3598 | |
---|
3599 | deriveRightBottomIdx( eCUMode, uiPartIdx, uiPartIdxRB ); |
---|
3600 | uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
---|
3601 | |
---|
3602 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
3603 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
---|
3604 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
3605 | { |
---|
3606 | uiLCUIdx = -1; |
---|
3607 | } |
---|
3608 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
3609 | { |
---|
3610 | uiLCUIdx = -1; |
---|
3611 | } |
---|
3612 | else |
---|
3613 | { |
---|
3614 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
3615 | ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
3616 | { |
---|
3617 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; |
---|
3618 | uiLCUIdx = getAddr(); |
---|
3619 | } |
---|
3620 | else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
3621 | { |
---|
3622 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
3623 | uiLCUIdx = -1 ; |
---|
3624 | } |
---|
3625 | else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
3626 | { |
---|
3627 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
---|
3628 | uiLCUIdx = getAddr() + 1; |
---|
3629 | } |
---|
3630 | else //is the right bottom corner of LCU |
---|
3631 | { |
---|
3632 | uiAbsPartAddr = 0; |
---|
3633 | uiLCUIdx = -1 ; |
---|
3634 | } |
---|
3635 | } |
---|
3636 | if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col ) ) |
---|
3637 | { |
---|
3638 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
3639 | } |
---|
3640 | else |
---|
3641 | { |
---|
3642 | UInt uiPartIdxCenter; |
---|
3643 | UInt uiCurLCUIdx = getAddr(); |
---|
3644 | xDeriveCenterIdx( eCUMode, uiPartIdx, uiPartIdxCenter ); |
---|
3645 | if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col )) |
---|
3646 | { |
---|
3647 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
3648 | } |
---|
3649 | } |
---|
3650 | //---- co-located RightBottom Temporal Predictor ---// |
---|
3651 | } |
---|
3652 | |
---|
3653 | if (pInfo->iN > AMVP_MAX_NUM_CANDS) |
---|
3654 | { |
---|
3655 | pInfo->iN = AMVP_MAX_NUM_CANDS; |
---|
3656 | } |
---|
3657 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
---|
3658 | { |
---|
3659 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
---|
3660 | pInfo->iN++; |
---|
3661 | } |
---|
3662 | return ; |
---|
3663 | } |
---|
3664 | |
---|
3665 | Bool TComDataCU::isBipredRestriction(UInt puIdx) |
---|
3666 | { |
---|
3667 | Int width = 0; |
---|
3668 | Int height = 0; |
---|
3669 | UInt partAddr; |
---|
3670 | |
---|
3671 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
---|
3672 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
---|
3673 | { |
---|
3674 | return true; |
---|
3675 | } |
---|
3676 | return false; |
---|
3677 | } |
---|
3678 | |
---|
3679 | Void TComDataCU::clipMv (TComMv& rcMv) |
---|
3680 | { |
---|
3681 | Int iMvShift = 2; |
---|
3682 | Int iOffset = 8; |
---|
3683 | Int iHorMax = ( m_pcSlice->getSPS()->getPicWidthInLumaSamples() + iOffset - m_uiCUPelX - 1 ) << iMvShift; |
---|
3684 | Int iHorMin = ( -(Int)g_uiMaxCUWidth - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
---|
3685 | |
---|
3686 | Int iVerMax = ( m_pcSlice->getSPS()->getPicHeightInLumaSamples() + iOffset - m_uiCUPelY - 1 ) << iMvShift; |
---|
3687 | Int iVerMin = ( -(Int)g_uiMaxCUHeight - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
---|
3688 | |
---|
3689 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
---|
3690 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
---|
3691 | } |
---|
3692 | |
---|
3693 | |
---|
3694 | Void TComDataCU::convertTransIdx( UInt uiAbsPartIdx, UInt uiTrIdx, UInt& ruiLumaTrMode, UInt& ruiChromaTrMode ) |
---|
3695 | { |
---|
3696 | ruiLumaTrMode = uiTrIdx; |
---|
3697 | ruiChromaTrMode = uiTrIdx; |
---|
3698 | return; |
---|
3699 | } |
---|
3700 | |
---|
3701 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
---|
3702 | { |
---|
3703 | UInt uiShift = ( (m_puhTrIdx[uiAbsPartIdx]==0) && (m_pePartSize[uiAbsPartIdx]==SIZE_NxN) ) ? m_puhTrIdx[uiAbsPartIdx]+1 : m_puhTrIdx[uiAbsPartIdx]; |
---|
3704 | uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
3705 | |
---|
3706 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
3707 | UInt uiCnt = 0; |
---|
3708 | while( uiWidth ) |
---|
3709 | { |
---|
3710 | uiCnt++; |
---|
3711 | uiWidth>>=1; |
---|
3712 | } |
---|
3713 | uiCnt-=2; |
---|
3714 | return uiCnt > 6 ? 6 : uiCnt; |
---|
3715 | } |
---|
3716 | |
---|
3717 | Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts ) |
---|
3718 | { |
---|
3719 | ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
3720 | } |
---|
3721 | |
---|
3722 | /** Set a I_PCM flag for all sub-partitions of a partition. |
---|
3723 | * \param bIpcmFlag I_PCM flag |
---|
3724 | * \param uiAbsPartIdx patition index |
---|
3725 | * \param uiDepth CU depth |
---|
3726 | * \returns Void |
---|
3727 | */ |
---|
3728 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
---|
3729 | { |
---|
3730 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
3731 | |
---|
3732 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
---|
3733 | } |
---|
3734 | |
---|
3735 | /** Test whether the current block is skipped |
---|
3736 | * \param uiPartIdx Block index |
---|
3737 | * \returns Flag indicating whether the block is skipped |
---|
3738 | */ |
---|
3739 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
---|
3740 | { |
---|
3741 | #if SKIP_FLAG |
---|
3742 | return ( getSkipFlag( uiPartIdx ) ); |
---|
3743 | #else |
---|
3744 | if ( m_pcSlice->isIntra () ) |
---|
3745 | { |
---|
3746 | return false; |
---|
3747 | } |
---|
3748 | return ( getMergeFlag( uiPartIdx ) && getPartitionSize( uiPartIdx ) == SIZE_2Nx2N && !getQtRootCbf( uiPartIdx ) ); |
---|
3749 | #endif |
---|
3750 | } |
---|
3751 | |
---|
3752 | // ==================================================================================================================== |
---|
3753 | // Protected member functions |
---|
3754 | // ==================================================================================================================== |
---|
3755 | |
---|
3756 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
3757 | { |
---|
3758 | TComDataCU* pcTmpCU = NULL; |
---|
3759 | UInt uiIdx; |
---|
3760 | switch( eDir ) |
---|
3761 | { |
---|
3762 | case MD_LEFT: |
---|
3763 | { |
---|
3764 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx, true, false); |
---|
3765 | break; |
---|
3766 | } |
---|
3767 | case MD_ABOVE: |
---|
3768 | { |
---|
3769 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3770 | break; |
---|
3771 | } |
---|
3772 | case MD_ABOVE_RIGHT: |
---|
3773 | { |
---|
3774 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3775 | break; |
---|
3776 | } |
---|
3777 | case MD_BELOW_LEFT: |
---|
3778 | { |
---|
3779 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx, true, false); |
---|
3780 | break; |
---|
3781 | } |
---|
3782 | case MD_ABOVE_LEFT: |
---|
3783 | { |
---|
3784 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3785 | break; |
---|
3786 | } |
---|
3787 | default: |
---|
3788 | { |
---|
3789 | break; |
---|
3790 | } |
---|
3791 | } |
---|
3792 | |
---|
3793 | if ( pcTmpCU != NULL && m_pcSlice->isEqualRef(eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx), iRefIdx) ) |
---|
3794 | { |
---|
3795 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
3796 | |
---|
3797 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
3798 | return true; |
---|
3799 | } |
---|
3800 | |
---|
3801 | if ( pcTmpCU == NULL ) |
---|
3802 | { |
---|
3803 | return false; |
---|
3804 | } |
---|
3805 | |
---|
3806 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
3807 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
3808 | { |
---|
3809 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
3810 | } |
---|
3811 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
3812 | { |
---|
3813 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
3814 | } |
---|
3815 | |
---|
3816 | |
---|
3817 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
3818 | Int iNeibRefPOC; |
---|
3819 | |
---|
3820 | |
---|
3821 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
---|
3822 | { |
---|
3823 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
3824 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
---|
3825 | { |
---|
3826 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
3827 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
3828 | return true; |
---|
3829 | } |
---|
3830 | } |
---|
3831 | return false; |
---|
3832 | } |
---|
3833 | |
---|
3834 | /** |
---|
3835 | * \param pInfo |
---|
3836 | * \param eRefPicList |
---|
3837 | * \param iRefIdx |
---|
3838 | * \param uiPartUnitIdx |
---|
3839 | * \param eDir |
---|
3840 | * \returns Bool |
---|
3841 | */ |
---|
3842 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
3843 | { |
---|
3844 | TComDataCU* pcTmpCU = NULL; |
---|
3845 | UInt uiIdx; |
---|
3846 | switch( eDir ) |
---|
3847 | { |
---|
3848 | case MD_LEFT: |
---|
3849 | { |
---|
3850 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx, true, false); |
---|
3851 | break; |
---|
3852 | } |
---|
3853 | case MD_ABOVE: |
---|
3854 | { |
---|
3855 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3856 | break; |
---|
3857 | } |
---|
3858 | case MD_ABOVE_RIGHT: |
---|
3859 | { |
---|
3860 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3861 | break; |
---|
3862 | } |
---|
3863 | case MD_BELOW_LEFT: |
---|
3864 | { |
---|
3865 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx, true, false); |
---|
3866 | break; |
---|
3867 | } |
---|
3868 | case MD_ABOVE_LEFT: |
---|
3869 | { |
---|
3870 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx, true, false, true); |
---|
3871 | break; |
---|
3872 | } |
---|
3873 | default: |
---|
3874 | { |
---|
3875 | break; |
---|
3876 | } |
---|
3877 | } |
---|
3878 | |
---|
3879 | if ( pcTmpCU == NULL ) |
---|
3880 | { |
---|
3881 | return false; |
---|
3882 | } |
---|
3883 | |
---|
3884 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
3885 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
3886 | { |
---|
3887 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
3888 | } |
---|
3889 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
3890 | { |
---|
3891 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
3892 | } |
---|
3893 | |
---|
3894 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
3895 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
3896 | Int iNeibPOC = iCurrPOC; |
---|
3897 | Int iNeibRefPOC; |
---|
3898 | |
---|
3899 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
3900 | Bool bIsNeibRefLongTerm = false; |
---|
3901 | //--------------- V1 (END) ------------------// |
---|
3902 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
---|
3903 | { |
---|
3904 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
---|
3905 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
3906 | TComMv rcMv; |
---|
3907 | |
---|
3908 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
3909 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
3910 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
3911 | { |
---|
3912 | #endif |
---|
3913 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
3914 | { |
---|
3915 | rcMv = cMvPred; |
---|
3916 | } |
---|
3917 | else |
---|
3918 | { |
---|
3919 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
3920 | if ( iScale == 4096 ) |
---|
3921 | { |
---|
3922 | rcMv = cMvPred; |
---|
3923 | } |
---|
3924 | else |
---|
3925 | { |
---|
3926 | rcMv = cMvPred.scaleMv( iScale ); |
---|
3927 | } |
---|
3928 | } |
---|
3929 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
3930 | return true; |
---|
3931 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
3932 | } |
---|
3933 | #endif |
---|
3934 | } |
---|
3935 | //---------------------- V2(END) --------------------// |
---|
3936 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
---|
3937 | { |
---|
3938 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
3939 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
3940 | TComMv rcMv; |
---|
3941 | |
---|
3942 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
3943 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
3944 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
3945 | { |
---|
3946 | #endif |
---|
3947 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
3948 | { |
---|
3949 | rcMv = cMvPred; |
---|
3950 | } |
---|
3951 | else |
---|
3952 | { |
---|
3953 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
3954 | if ( iScale == 4096 ) |
---|
3955 | { |
---|
3956 | rcMv = cMvPred; |
---|
3957 | } |
---|
3958 | else |
---|
3959 | { |
---|
3960 | rcMv = cMvPred.scaleMv( iScale ); |
---|
3961 | } |
---|
3962 | } |
---|
3963 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
3964 | return true; |
---|
3965 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
3966 | } |
---|
3967 | #endif |
---|
3968 | } |
---|
3969 | //---------------------- V3(END) --------------------// |
---|
3970 | return false; |
---|
3971 | } |
---|
3972 | |
---|
3973 | /** |
---|
3974 | * \param eRefPicList |
---|
3975 | * \param uiCUAddr |
---|
3976 | * \param uiPartUnitIdx |
---|
3977 | * \param riRefIdx |
---|
3978 | * \returns Bool |
---|
3979 | */ |
---|
3980 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx ) |
---|
3981 | { |
---|
3982 | UInt uiAbsPartAddr = uiPartUnitIdx; |
---|
3983 | |
---|
3984 | RefPicList eColRefPicList; |
---|
3985 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
---|
3986 | TComMv cColMv; |
---|
3987 | |
---|
3988 | // use coldir. |
---|
3989 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
3990 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
3991 | if(pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE) |
---|
3992 | { |
---|
3993 | return false; |
---|
3994 | } |
---|
3995 | iCurrPOC = m_pcSlice->getPOC(); |
---|
3996 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
3997 | iColPOC = pColCU->getSlice()->getPOC(); |
---|
3998 | |
---|
3999 | if (pColCU->isIntra(uiAbsPartAddr)) |
---|
4000 | { |
---|
4001 | return false; |
---|
4002 | } |
---|
4003 | eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
---|
4004 | |
---|
4005 | Int iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
4006 | |
---|
4007 | if (iColRefIdx < 0 ) |
---|
4008 | { |
---|
4009 | eColRefPicList = RefPicList(1 - eColRefPicList); |
---|
4010 | iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
4011 | |
---|
4012 | if (iColRefIdx < 0 ) |
---|
4013 | { |
---|
4014 | return false; |
---|
4015 | } |
---|
4016 | } |
---|
4017 | |
---|
4018 | // Scale the vector. |
---|
4019 | iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
---|
4020 | cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
4021 | |
---|
4022 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
4023 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
---|
4024 | Bool bIsColRefLongTerm = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getIsUsedAsLongTerm(); |
---|
4025 | |
---|
4026 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
4027 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
4028 | { |
---|
4029 | return false; |
---|
4030 | } |
---|
4031 | #endif |
---|
4032 | |
---|
4033 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
---|
4034 | { |
---|
4035 | rcMv = cColMv; |
---|
4036 | } |
---|
4037 | else |
---|
4038 | { |
---|
4039 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
4040 | if ( iScale == 4096 ) |
---|
4041 | { |
---|
4042 | rcMv = cColMv; |
---|
4043 | } |
---|
4044 | else |
---|
4045 | { |
---|
4046 | rcMv = cColMv.scaleMv( iScale ); |
---|
4047 | } |
---|
4048 | } |
---|
4049 | return true; |
---|
4050 | } |
---|
4051 | |
---|
4052 | UInt TComDataCU::xGetMvdBits(TComMv cMvd) |
---|
4053 | { |
---|
4054 | return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) ); |
---|
4055 | } |
---|
4056 | |
---|
4057 | UInt TComDataCU::xGetComponentBits(Int iVal) |
---|
4058 | { |
---|
4059 | UInt uiLength = 1; |
---|
4060 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
4061 | |
---|
4062 | assert ( uiTemp ); |
---|
4063 | |
---|
4064 | while ( 1 != uiTemp ) |
---|
4065 | { |
---|
4066 | uiTemp >>= 1; |
---|
4067 | uiLength += 2; |
---|
4068 | } |
---|
4069 | |
---|
4070 | return uiLength; |
---|
4071 | } |
---|
4072 | |
---|
4073 | |
---|
4074 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
4075 | { |
---|
4076 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
4077 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
4078 | |
---|
4079 | if( iDiffPocD == iDiffPocB ) |
---|
4080 | { |
---|
4081 | return 4096; |
---|
4082 | } |
---|
4083 | else |
---|
4084 | { |
---|
4085 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
4086 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
4087 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
4088 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
---|
4089 | return iScale; |
---|
4090 | } |
---|
4091 | } |
---|
4092 | |
---|
4093 | /** |
---|
4094 | * \param eCUMode |
---|
4095 | * \param uiPartIdx |
---|
4096 | * \param ruiPartIdxCenter |
---|
4097 | * \returns Void |
---|
4098 | */ |
---|
4099 | Void TComDataCU::xDeriveCenterIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
---|
4100 | { |
---|
4101 | UInt uiPartAddr; |
---|
4102 | Int iPartWidth; |
---|
4103 | Int iPartHeight; |
---|
4104 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
4105 | |
---|
4106 | ruiPartIdxCenter = m_uiAbsIdxInLCU+uiPartAddr; // partition origin. |
---|
4107 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
4108 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInWidth() |
---|
4109 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
---|
4110 | } |
---|
4111 | |
---|
4112 | /** |
---|
4113 | * \param uiPartIdx |
---|
4114 | * \param eRefPicList |
---|
4115 | * \param iRefIdx |
---|
4116 | * \param pcMv |
---|
4117 | * \returns Bool |
---|
4118 | */ |
---|
4119 | Bool TComDataCU::xGetCenterCol( UInt uiPartIdx, RefPicList eRefPicList, int iRefIdx, TComMv *pcMv ) |
---|
4120 | { |
---|
4121 | PartSize eCUMode = getPartitionSize( 0 ); |
---|
4122 | |
---|
4123 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
4124 | |
---|
4125 | // use coldir. |
---|
4126 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
4127 | TComDataCU *pColCU = pColPic->getCU( m_uiCUAddr ); |
---|
4128 | |
---|
4129 | Int iColPOC = pColCU->getSlice()->getPOC(); |
---|
4130 | UInt uiPartIdxCenter; |
---|
4131 | xDeriveCenterIdx( eCUMode, uiPartIdx, uiPartIdxCenter ); |
---|
4132 | |
---|
4133 | if (pColCU->isIntra(uiPartIdxCenter)) |
---|
4134 | { |
---|
4135 | return false; |
---|
4136 | } |
---|
4137 | |
---|
4138 | // Prefer a vector crossing us. Prefer shortest. |
---|
4139 | RefPicList eColRefPicList = REF_PIC_LIST_0; |
---|
4140 | bool bFirstCrosses = false; |
---|
4141 | Int iFirstColDist = -1; |
---|
4142 | for (Int l = 0; l < 2; l++) |
---|
4143 | { |
---|
4144 | bool bSaveIt = false; |
---|
4145 | int iColRefIdx = pColCU->getCUMvField(RefPicList(l))->getRefIdx(uiPartIdxCenter); |
---|
4146 | if (iColRefIdx < 0) |
---|
4147 | { |
---|
4148 | continue; |
---|
4149 | } |
---|
4150 | int iColRefPOC = pColCU->getSlice()->getRefPOC(RefPicList(l), iColRefIdx); |
---|
4151 | int iColDist = abs(iColRefPOC - iColPOC); |
---|
4152 | bool bCrosses = iColPOC < iCurrPOC ? iColRefPOC > iCurrPOC : iColRefPOC < iCurrPOC; |
---|
4153 | if (iFirstColDist < 0) |
---|
4154 | { |
---|
4155 | bSaveIt = true; |
---|
4156 | } |
---|
4157 | else if (bCrosses && !bFirstCrosses) |
---|
4158 | { |
---|
4159 | bSaveIt = true; |
---|
4160 | } |
---|
4161 | else if (bCrosses == bFirstCrosses && l == eRefPicList) |
---|
4162 | { |
---|
4163 | bSaveIt = true; |
---|
4164 | } |
---|
4165 | |
---|
4166 | if (bSaveIt) |
---|
4167 | { |
---|
4168 | bFirstCrosses = bCrosses; |
---|
4169 | iFirstColDist = iColDist; |
---|
4170 | eColRefPicList = RefPicList(l); |
---|
4171 | } |
---|
4172 | } |
---|
4173 | |
---|
4174 | // Scale the vector. |
---|
4175 | Int iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartIdxCenter)); |
---|
4176 | TComMv cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartIdxCenter); |
---|
4177 | |
---|
4178 | Int iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getPOC(); |
---|
4179 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
4180 | Bool bIsColRefLongTerm = pColCU->getSlice()->getRefPic(eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartIdxCenter))->getIsUsedAsLongTerm(); |
---|
4181 | |
---|
4182 | #if NO_MV_PRED_IF_DIFFERENT_TERM |
---|
4183 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
4184 | { |
---|
4185 | return false; |
---|
4186 | } |
---|
4187 | #endif |
---|
4188 | |
---|
4189 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
---|
4190 | { |
---|
4191 | pcMv[0] = cColMv; |
---|
4192 | } |
---|
4193 | else |
---|
4194 | { |
---|
4195 | Int iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
4196 | if ( iScale == 4096 ) |
---|
4197 | { |
---|
4198 | pcMv[0] = cColMv; |
---|
4199 | } |
---|
4200 | else |
---|
4201 | { |
---|
4202 | pcMv[0] = cColMv.scaleMv( iScale ); |
---|
4203 | } |
---|
4204 | } |
---|
4205 | return true; |
---|
4206 | } |
---|
4207 | |
---|
4208 | Void TComDataCU::compressMV() |
---|
4209 | { |
---|
4210 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
4211 | if (scaleFactor > 0) |
---|
4212 | { |
---|
4213 | #if SVC_MVP |
---|
4214 | m_acCUMvField[0].compress(m_pePredMode, m_puhInterDir, scaleFactor); |
---|
4215 | m_acCUMvField[1].compress(m_pePredMode, m_puhInterDir, scaleFactor); |
---|
4216 | #else |
---|
4217 | m_acCUMvField[0].compress(m_pePredMode, scaleFactor); |
---|
4218 | m_acCUMvField[1].compress(m_pePredMode, scaleFactor); |
---|
4219 | #endif |
---|
4220 | } |
---|
4221 | } |
---|
4222 | |
---|
4223 | UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) |
---|
4224 | { |
---|
4225 | UInt uiCTXIdx; |
---|
4226 | UInt uiScanIdx; |
---|
4227 | UInt uiDirMode; |
---|
4228 | |
---|
4229 | if ( !bIsIntra ) |
---|
4230 | { |
---|
4231 | uiScanIdx = SCAN_ZIGZAG; |
---|
4232 | return uiScanIdx; |
---|
4233 | } |
---|
4234 | |
---|
4235 | switch(uiWidth) |
---|
4236 | { |
---|
4237 | case 2: uiCTXIdx = 6; break; |
---|
4238 | case 4: uiCTXIdx = 5; break; |
---|
4239 | case 8: uiCTXIdx = 4; break; |
---|
4240 | case 16: uiCTXIdx = 3; break; |
---|
4241 | case 32: uiCTXIdx = 2; break; |
---|
4242 | case 64: uiCTXIdx = 1; break; |
---|
4243 | default: uiCTXIdx = 0; break; |
---|
4244 | } |
---|
4245 | |
---|
4246 | if ( bIsLuma ) |
---|
4247 | { |
---|
4248 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
---|
4249 | uiScanIdx = SCAN_ZIGZAG; |
---|
4250 | if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size |
---|
4251 | { |
---|
4252 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? 1 : (abs((Int)uiDirMode - HOR_IDX) < 5 ? 2 : 0); |
---|
4253 | } |
---|
4254 | } |
---|
4255 | else |
---|
4256 | { |
---|
4257 | uiDirMode = getChromaIntraDir(uiAbsPartIdx); |
---|
4258 | if( uiDirMode == DM_CHROMA_IDX ) |
---|
4259 | { |
---|
4260 | // get number of partitions in current CU |
---|
4261 | UInt depth = getDepth(uiAbsPartIdx); |
---|
4262 | UInt numParts = getPic()->getNumPartInCU() >> (2 * depth); |
---|
4263 | |
---|
4264 | // get luma mode from upper-left corner of current CU |
---|
4265 | uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); |
---|
4266 | } |
---|
4267 | uiScanIdx = SCAN_ZIGZAG; |
---|
4268 | if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size |
---|
4269 | { |
---|
4270 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? 1 : (abs((Int)uiDirMode - HOR_IDX) < 5 ? 2 : 0); |
---|
4271 | } |
---|
4272 | } |
---|
4273 | |
---|
4274 | return uiScanIdx; |
---|
4275 | } |
---|
4276 | |
---|
4277 | #if !REMOVE_NSQT |
---|
4278 | Bool TComDataCU::useNonSquareTrans(UInt uiTrMode, Int absPartIdx) |
---|
4279 | { |
---|
4280 | UInt minTuSize = ( 1 << ( getSlice()->getSPS()->getQuadtreeTULog2MinSize() + 1 ) ); |
---|
4281 | const UInt uiLog2TrSize = g_aucConvertToBit[ getSlice()->getSPS()->getMaxCUWidth() >> ( m_puhDepth[ absPartIdx ] + uiTrMode ) ] + 2; |
---|
4282 | if ( uiTrMode && uiLog2TrSize < getSlice()->getSPS()->getQuadtreeTULog2MaxSize() && ( getWidth( absPartIdx ) > minTuSize ) && |
---|
4283 | ( m_pePartSize[absPartIdx] == SIZE_Nx2N || m_pePartSize[absPartIdx] == SIZE_2NxN || ( m_pePartSize[absPartIdx] >= SIZE_2NxnU && m_pePartSize[absPartIdx] <= SIZE_nRx2N ) ) ) |
---|
4284 | { |
---|
4285 | return getSlice()->getSPS()->getUseNSQT(); |
---|
4286 | } |
---|
4287 | else |
---|
4288 | { |
---|
4289 | return false; |
---|
4290 | } |
---|
4291 | } |
---|
4292 | |
---|
4293 | Void TComDataCU::getNSQTSize(Int trMode, Int absPartIdx, Int &trWidth, Int &trHeight) |
---|
4294 | { |
---|
4295 | UInt minTuSize = ( 1 << getSlice()->getSPS()->getQuadtreeTULog2MinSize() ); |
---|
4296 | if ( useNonSquareTrans( trMode, absPartIdx ) && ( trWidth > minTuSize ) ) |
---|
4297 | { |
---|
4298 | trWidth = ( m_pePartSize[absPartIdx] == SIZE_Nx2N || m_pePartSize[absPartIdx] == SIZE_nLx2N || m_pePartSize[absPartIdx] == SIZE_nRx2N )? trWidth >> 1 : trWidth << 1; |
---|
4299 | trHeight = ( m_pePartSize[absPartIdx] == SIZE_Nx2N || m_pePartSize[absPartIdx] == SIZE_nLx2N || m_pePartSize[absPartIdx] == SIZE_nRx2N )? trHeight << 1 : trHeight >> 1; |
---|
4300 | } |
---|
4301 | } |
---|
4302 | |
---|
4303 | Bool TComDataCU::useNonSquarePU(UInt absPartIdx) |
---|
4304 | { |
---|
4305 | if ( ( m_pePartSize[absPartIdx] == SIZE_Nx2N ) || ( m_pePartSize[absPartIdx] == SIZE_2NxN ) || ( m_pePartSize[absPartIdx] >= SIZE_2NxnU && m_pePartSize[absPartIdx] <= SIZE_nRx2N ) ) |
---|
4306 | { |
---|
4307 | return true; |
---|
4308 | } |
---|
4309 | else |
---|
4310 | { |
---|
4311 | return false; |
---|
4312 | } |
---|
4313 | } |
---|
4314 | |
---|
4315 | UInt TComDataCU::getInterTUSplitDirection( Int trWidth, Int trHeight, Int trLastWidth, Int trLastHeight ) |
---|
4316 | { |
---|
4317 | UInt interTUSplitDirection = 2; |
---|
4318 | if ( ( trWidth == trLastWidth ) && ( trHeight < trLastHeight ) ) |
---|
4319 | { |
---|
4320 | interTUSplitDirection = 0; |
---|
4321 | } |
---|
4322 | else if ( ( trWidth < trLastWidth ) && ( trHeight == trLastHeight ) ) |
---|
4323 | { |
---|
4324 | interTUSplitDirection = 1; |
---|
4325 | } |
---|
4326 | |
---|
4327 | return interTUSplitDirection; |
---|
4328 | } |
---|
4329 | |
---|
4330 | UInt TComDataCU::getNSAbsPartIdx ( UInt log2TrafoSize, UInt absPartIdx, UInt absTUPartIdx, UInt innerQuadIdx, UInt trMode ) |
---|
4331 | { |
---|
4332 | Int trWidth, trHeight, trLastWidth, trLastHeight; |
---|
4333 | UInt lcuWidthInBaseUnits = getPic()->getNumPartInWidth(); |
---|
4334 | UInt nsTUWidthInBaseUnits, nsTUHeightInBaseUnits; |
---|
4335 | UInt interTUSplitDirection; |
---|
4336 | |
---|
4337 | if( isIntra(absPartIdx) ) |
---|
4338 | { |
---|
4339 | return absPartIdx; |
---|
4340 | } |
---|
4341 | |
---|
4342 | trWidth = trHeight = ( 1 << log2TrafoSize ); |
---|
4343 | trLastWidth = trWidth << 1, trLastHeight = trHeight << 1; |
---|
4344 | |
---|
4345 | getNSQTSize( trMode, absPartIdx, trWidth, trHeight ); |
---|
4346 | getNSQTSize( trMode - 1, absPartIdx, trLastWidth, trLastHeight ); |
---|
4347 | interTUSplitDirection = getInterTUSplitDirection ( trWidth, trHeight, trLastWidth, trLastHeight ); |
---|
4348 | |
---|
4349 | nsTUWidthInBaseUnits = trWidth / getPic()->getMinCUWidth(); |
---|
4350 | nsTUHeightInBaseUnits = trHeight / getPic()->getMinCUHeight(); |
---|
4351 | |
---|
4352 | if ( interTUSplitDirection != 2 ) |
---|
4353 | { |
---|
4354 | UInt uiNSTUBaseUnits = nsTUWidthInBaseUnits < nsTUHeightInBaseUnits ? nsTUWidthInBaseUnits : nsTUHeightInBaseUnits; |
---|
4355 | absTUPartIdx = g_auiRasterToZscan[ g_auiZscanToRaster[absTUPartIdx] + innerQuadIdx * uiNSTUBaseUnits * lcuWidthInBaseUnits * ( 1 - interTUSplitDirection ) + innerQuadIdx * uiNSTUBaseUnits * interTUSplitDirection ]; |
---|
4356 | } |
---|
4357 | else |
---|
4358 | { |
---|
4359 | absTUPartIdx = g_auiRasterToZscan[ g_auiZscanToRaster[absTUPartIdx] + (innerQuadIdx & 0x01) * nsTUWidthInBaseUnits + ( ( innerQuadIdx >> 1 ) & 0x01 ) * nsTUHeightInBaseUnits * lcuWidthInBaseUnits ]; |
---|
4360 | } |
---|
4361 | |
---|
4362 | return absTUPartIdx; |
---|
4363 | } |
---|
4364 | |
---|
4365 | UInt TComDataCU::getNSAddrChroma( UInt uiLog2TrSizeC, UInt uiTrModeC, UInt uiQuadrant, UInt absTUPartIdx ) |
---|
4366 | { |
---|
4367 | if( uiLog2TrSizeC != getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
4368 | { |
---|
4369 | return absTUPartIdx; |
---|
4370 | } |
---|
4371 | |
---|
4372 | UInt lcuWidthInBaseUnits = getPic()->getNumPartInWidth(); |
---|
4373 | Int trWidth = ( 1 << ( uiLog2TrSizeC + 1 ) ); |
---|
4374 | Int trHeight = ( 1 << ( uiLog2TrSizeC + 1 ) ); |
---|
4375 | Int trLastWidth = trWidth << 1, trLastHeight = trHeight << 1; |
---|
4376 | |
---|
4377 | getNSQTSize ( uiTrModeC - 1, absTUPartIdx, trLastWidth, trLastHeight ); |
---|
4378 | getNSQTSize ( uiTrModeC, absTUPartIdx, trWidth, trHeight ); |
---|
4379 | |
---|
4380 | UInt interTUSplitDirection = getInterTUSplitDirection ( trWidth, trHeight, trLastWidth, trLastHeight ); |
---|
4381 | UInt nsTUWidthInBaseUnits = trWidth / getPic()->getMinCUWidth(); |
---|
4382 | UInt nsTUHeightInBaseUnits = trHeight / getPic()->getMinCUHeight(); |
---|
4383 | UInt firstTURasterIdx = 0, absTUPartIdxC = 0; |
---|
4384 | |
---|
4385 | if(interTUSplitDirection != 2) |
---|
4386 | { |
---|
4387 | UInt uiNSTUBaseUnits = nsTUWidthInBaseUnits < nsTUHeightInBaseUnits ? 1 : lcuWidthInBaseUnits; |
---|
4388 | firstTURasterIdx = g_auiZscanToRaster[absTUPartIdx] - uiQuadrant * uiNSTUBaseUnits; |
---|
4389 | absTUPartIdxC = g_auiRasterToZscan[firstTURasterIdx] + uiQuadrant * nsTUWidthInBaseUnits * nsTUHeightInBaseUnits; |
---|
4390 | } |
---|
4391 | else |
---|
4392 | { |
---|
4393 | UInt uiNSTUBaseUnits = nsTUWidthInBaseUnits < nsTUHeightInBaseUnits ? 2 * lcuWidthInBaseUnits : 2; |
---|
4394 | firstTURasterIdx = g_auiZscanToRaster[absTUPartIdx] - ( ( uiQuadrant >> 1 ) & 0x01 ) * nsTUHeightInBaseUnits * lcuWidthInBaseUnits - ( uiQuadrant & 0x01 ) * nsTUWidthInBaseUnits; |
---|
4395 | absTUPartIdxC = g_auiRasterToZscan[firstTURasterIdx + uiQuadrant * uiNSTUBaseUnits]; |
---|
4396 | } |
---|
4397 | |
---|
4398 | return absTUPartIdxC; |
---|
4399 | } |
---|
4400 | #endif |
---|
4401 | |
---|
4402 | UInt TComDataCU::getSCUAddr() |
---|
4403 | { |
---|
4404 | return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; |
---|
4405 | } |
---|
4406 | |
---|
4407 | /** Set neighboring blocks availabilities for non-deblocked filtering |
---|
4408 | * \param numLCUInPicWidth number of LCUs in picture width |
---|
4409 | * \param numLCUInPicHeight number of LCUs in picture height |
---|
4410 | * \param numSUInLCUWidth number of SUs in LCU width |
---|
4411 | * \param numSUInLCUHeight number of SUs in LCU height |
---|
4412 | * \param picWidth picture width |
---|
4413 | * \param picHeight picture height |
---|
4414 | * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled |
---|
4415 | * \param bTopTileBoundary true means that top boundary coincides tile boundary |
---|
4416 | * \param bDownTileBoundary true means that bottom boundary coincides tile boundary |
---|
4417 | * \param bLeftTileBoundary true means that left boundary coincides tile boundary |
---|
4418 | * \param bRightTileBoundary true means that right boundary coincides tile boundary |
---|
4419 | * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled |
---|
4420 | */ |
---|
4421 | Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt numLCUInPicHeight, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight |
---|
4422 | ,std::vector<Bool>& LFCrossSliceBoundary |
---|
4423 | ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary |
---|
4424 | ,Bool bIndependentTileBoundaryEnabled) |
---|
4425 | { |
---|
4426 | UInt numSUInLCU = numSUInLCUWidth*numSUInLCUHeight; |
---|
4427 | Int* pSliceIDMapLCU = m_piSliceSUMap; |
---|
4428 | #if MODIFIED_CROSS_SLICE |
---|
4429 | Bool onlyOneSliceInPic = ((Int)LFCrossSliceBoundary.size() == 1); |
---|
4430 | #endif |
---|
4431 | UInt uiLPelX, uiTPelY; |
---|
4432 | UInt width, height; |
---|
4433 | Bool bPicRBoundary, bPicBBoundary, bPicTBoundary, bPicLBoundary; |
---|
4434 | Bool bLCURBoundary= false, bLCUBBoundary= false, bLCUTBoundary= false, bLCULBoundary= false; |
---|
4435 | Bool* pbAvailBorder; |
---|
4436 | Bool* pbAvail; |
---|
4437 | UInt rTLSU, rBRSU, widthSU, heightSU; |
---|
4438 | UInt zRefSU; |
---|
4439 | Int* pRefID; |
---|
4440 | Int* pRefMapLCU; |
---|
4441 | UInt rTRefSU= 0, rBRefSU= 0, rLRefSU= 0, rRRefSU= 0; |
---|
4442 | Int* pRRefMapLCU= NULL; |
---|
4443 | Int* pLRefMapLCU= NULL; |
---|
4444 | Int* pTRefMapLCU= NULL; |
---|
4445 | Int* pBRefMapLCU= NULL; |
---|
4446 | Int sliceID; |
---|
4447 | UInt numSGU = (UInt)m_vNDFBlock.size(); |
---|
4448 | |
---|
4449 | for(Int i=0; i< numSGU; i++) |
---|
4450 | { |
---|
4451 | NDBFBlockInfo& rSGU = m_vNDFBlock[i]; |
---|
4452 | |
---|
4453 | sliceID = rSGU.sliceID; |
---|
4454 | uiLPelX = rSGU.posX; |
---|
4455 | uiTPelY = rSGU.posY; |
---|
4456 | width = rSGU.width; |
---|
4457 | height = rSGU.height; |
---|
4458 | #if !MODIFIED_CROSS_SLICE |
---|
4459 | Bool bIndependentSliceBoundaryEnabled = !(LFCrossSliceBoundary[sliceID]); |
---|
4460 | #endif |
---|
4461 | rTLSU = g_auiZscanToRaster[ rSGU.startSU ]; |
---|
4462 | rBRSU = g_auiZscanToRaster[ rSGU.endSU ]; |
---|
4463 | widthSU = rSGU.widthSU; |
---|
4464 | heightSU = rSGU.heightSU; |
---|
4465 | |
---|
4466 | pbAvailBorder = rSGU.isBorderAvailable; |
---|
4467 | |
---|
4468 | bPicTBoundary= (uiTPelY == 0 )?(true):(false); |
---|
4469 | bPicLBoundary= (uiLPelX == 0 )?(true):(false); |
---|
4470 | bPicRBoundary= (!(uiLPelX+ width < picWidth ) )?(true):(false); |
---|
4471 | bPicBBoundary= (!(uiTPelY + height < picHeight))?(true):(false); |
---|
4472 | |
---|
4473 | bLCULBoundary = (rTLSU % numSUInLCUWidth == 0)?(true):(false); |
---|
4474 | bLCURBoundary = ( (rTLSU+ widthSU) % numSUInLCUWidth == 0)?(true):(false); |
---|
4475 | bLCUTBoundary = ( (UInt)(rTLSU / numSUInLCUWidth)== 0)?(true):(false); |
---|
4476 | bLCUBBoundary = ( (UInt)(rBRSU / numSUInLCUWidth) == (numSUInLCUHeight-1) )?(true):(false); |
---|
4477 | |
---|
4478 | // SGU_L |
---|
4479 | pbAvail = &(pbAvailBorder[SGU_L]); |
---|
4480 | if(bPicLBoundary) |
---|
4481 | { |
---|
4482 | *pbAvail = false; |
---|
4483 | } |
---|
4484 | #if MODIFIED_CROSS_SLICE |
---|
4485 | else if (onlyOneSliceInPic) |
---|
4486 | #else |
---|
4487 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4488 | #endif |
---|
4489 | { |
---|
4490 | *pbAvail = true; |
---|
4491 | } |
---|
4492 | else |
---|
4493 | { |
---|
4494 | // bLCULBoundary = (rTLSU % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
4495 | if(bLCULBoundary) |
---|
4496 | { |
---|
4497 | rLRefSU = rTLSU + numSUInLCUWidth -1; |
---|
4498 | zRefSU = g_auiRasterToZscan[rLRefSU]; |
---|
4499 | pRefMapLCU = pLRefMapLCU= (pSliceIDMapLCU - numSUInLCU); |
---|
4500 | } |
---|
4501 | else |
---|
4502 | { |
---|
4503 | zRefSU = g_auiRasterToZscan[rTLSU - 1]; |
---|
4504 | pRefMapLCU = pSliceIDMapLCU; |
---|
4505 | } |
---|
4506 | pRefID = pRefMapLCU + zRefSU; |
---|
4507 | #if MODIFIED_CROSS_SLICE |
---|
4508 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4509 | #else |
---|
4510 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4511 | #endif |
---|
4512 | } |
---|
4513 | |
---|
4514 | // SGU_R |
---|
4515 | pbAvail = &(pbAvailBorder[SGU_R]); |
---|
4516 | if(bPicRBoundary) |
---|
4517 | { |
---|
4518 | *pbAvail = false; |
---|
4519 | } |
---|
4520 | #if MODIFIED_CROSS_SLICE |
---|
4521 | else if (onlyOneSliceInPic) |
---|
4522 | #else |
---|
4523 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4524 | #endif |
---|
4525 | { |
---|
4526 | *pbAvail = true; |
---|
4527 | } |
---|
4528 | else |
---|
4529 | { |
---|
4530 | // bLCURBoundary = ( (rTLSU+ uiWidthSU) % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
4531 | if(bLCURBoundary) |
---|
4532 | { |
---|
4533 | rRRefSU = rTLSU + widthSU - numSUInLCUWidth; |
---|
4534 | zRefSU = g_auiRasterToZscan[rRRefSU]; |
---|
4535 | pRefMapLCU = pRRefMapLCU= (pSliceIDMapLCU + numSUInLCU); |
---|
4536 | } |
---|
4537 | else |
---|
4538 | { |
---|
4539 | zRefSU = g_auiRasterToZscan[rTLSU + widthSU]; |
---|
4540 | pRefMapLCU = pSliceIDMapLCU; |
---|
4541 | } |
---|
4542 | pRefID = pRefMapLCU + zRefSU; |
---|
4543 | #if MODIFIED_CROSS_SLICE |
---|
4544 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4545 | #else |
---|
4546 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4547 | #endif |
---|
4548 | } |
---|
4549 | |
---|
4550 | // SGU_T |
---|
4551 | pbAvail = &(pbAvailBorder[SGU_T]); |
---|
4552 | if(bPicTBoundary) |
---|
4553 | { |
---|
4554 | *pbAvail = false; |
---|
4555 | } |
---|
4556 | #if MODIFIED_CROSS_SLICE |
---|
4557 | else if (onlyOneSliceInPic) |
---|
4558 | #else |
---|
4559 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4560 | #endif |
---|
4561 | { |
---|
4562 | *pbAvail = true; |
---|
4563 | } |
---|
4564 | else |
---|
4565 | { |
---|
4566 | // bLCUTBoundary = ( (UInt)(rTLSU / uiNumSUInLCUWidth)== 0)?(true):(false); |
---|
4567 | if(bLCUTBoundary) |
---|
4568 | { |
---|
4569 | rTRefSU = numSUInLCU - (numSUInLCUWidth - rTLSU); |
---|
4570 | zRefSU = g_auiRasterToZscan[rTRefSU]; |
---|
4571 | pRefMapLCU = pTRefMapLCU= (pSliceIDMapLCU - (numLCUInPicWidth*numSUInLCU)); |
---|
4572 | } |
---|
4573 | else |
---|
4574 | { |
---|
4575 | zRefSU = g_auiRasterToZscan[rTLSU - numSUInLCUWidth]; |
---|
4576 | pRefMapLCU = pSliceIDMapLCU; |
---|
4577 | } |
---|
4578 | pRefID = pRefMapLCU + zRefSU; |
---|
4579 | #if MODIFIED_CROSS_SLICE |
---|
4580 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4581 | #else |
---|
4582 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4583 | #endif |
---|
4584 | } |
---|
4585 | |
---|
4586 | // SGU_B |
---|
4587 | pbAvail = &(pbAvailBorder[SGU_B]); |
---|
4588 | if(bPicBBoundary) |
---|
4589 | { |
---|
4590 | *pbAvail = false; |
---|
4591 | } |
---|
4592 | #if MODIFIED_CROSS_SLICE |
---|
4593 | else if (onlyOneSliceInPic) |
---|
4594 | #else |
---|
4595 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4596 | #endif |
---|
4597 | { |
---|
4598 | *pbAvail = true; |
---|
4599 | } |
---|
4600 | else |
---|
4601 | { |
---|
4602 | // bLCUBBoundary = ( (UInt)(rBRSU / uiNumSUInLCUWidth) == (uiNumSUInLCUHeight-1) )?(true):(false); |
---|
4603 | if(bLCUBBoundary) |
---|
4604 | { |
---|
4605 | rBRefSU = rTLSU % numSUInLCUWidth; |
---|
4606 | zRefSU = g_auiRasterToZscan[rBRefSU]; |
---|
4607 | pRefMapLCU = pBRefMapLCU= (pSliceIDMapLCU + (numLCUInPicWidth*numSUInLCU)); |
---|
4608 | } |
---|
4609 | else |
---|
4610 | { |
---|
4611 | zRefSU = g_auiRasterToZscan[rTLSU + (heightSU*numSUInLCUWidth)]; |
---|
4612 | pRefMapLCU = pSliceIDMapLCU; |
---|
4613 | } |
---|
4614 | pRefID = pRefMapLCU + zRefSU; |
---|
4615 | #if MODIFIED_CROSS_SLICE |
---|
4616 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4617 | #else |
---|
4618 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4619 | #endif |
---|
4620 | } |
---|
4621 | |
---|
4622 | // SGU_TL |
---|
4623 | pbAvail = &(pbAvailBorder[SGU_TL]); |
---|
4624 | if(bPicTBoundary || bPicLBoundary) |
---|
4625 | { |
---|
4626 | *pbAvail = false; |
---|
4627 | } |
---|
4628 | #if MODIFIED_CROSS_SLICE |
---|
4629 | else if (onlyOneSliceInPic) |
---|
4630 | #else |
---|
4631 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4632 | #endif |
---|
4633 | { |
---|
4634 | *pbAvail = true; |
---|
4635 | } |
---|
4636 | else |
---|
4637 | { |
---|
4638 | if(bLCUTBoundary && bLCULBoundary) |
---|
4639 | { |
---|
4640 | zRefSU = numSUInLCU -1; |
---|
4641 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
4642 | } |
---|
4643 | else if(bLCUTBoundary) |
---|
4644 | { |
---|
4645 | zRefSU = g_auiRasterToZscan[ rTRefSU- 1]; |
---|
4646 | pRefMapLCU = pTRefMapLCU; |
---|
4647 | } |
---|
4648 | else if(bLCULBoundary) |
---|
4649 | { |
---|
4650 | zRefSU = g_auiRasterToZscan[ rLRefSU- numSUInLCUWidth ]; |
---|
4651 | pRefMapLCU = pLRefMapLCU; |
---|
4652 | } |
---|
4653 | else //inside LCU |
---|
4654 | { |
---|
4655 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth -1]; |
---|
4656 | pRefMapLCU = pSliceIDMapLCU; |
---|
4657 | } |
---|
4658 | pRefID = pRefMapLCU + zRefSU; |
---|
4659 | #if MODIFIED_CROSS_SLICE |
---|
4660 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4661 | #else |
---|
4662 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4663 | #endif |
---|
4664 | } |
---|
4665 | |
---|
4666 | // SGU_TR |
---|
4667 | pbAvail = &(pbAvailBorder[SGU_TR]); |
---|
4668 | if(bPicTBoundary || bPicRBoundary) |
---|
4669 | { |
---|
4670 | *pbAvail = false; |
---|
4671 | } |
---|
4672 | #if MODIFIED_CROSS_SLICE |
---|
4673 | else if (onlyOneSliceInPic) |
---|
4674 | #else |
---|
4675 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4676 | #endif |
---|
4677 | { |
---|
4678 | *pbAvail = true; |
---|
4679 | } |
---|
4680 | else |
---|
4681 | { |
---|
4682 | if(bLCUTBoundary && bLCURBoundary) |
---|
4683 | { |
---|
4684 | zRefSU = g_auiRasterToZscan[numSUInLCU - numSUInLCUWidth]; |
---|
4685 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
4686 | } |
---|
4687 | else if(bLCUTBoundary) |
---|
4688 | { |
---|
4689 | zRefSU = g_auiRasterToZscan[ rTRefSU+ widthSU]; |
---|
4690 | pRefMapLCU = pTRefMapLCU; |
---|
4691 | } |
---|
4692 | else if(bLCURBoundary) |
---|
4693 | { |
---|
4694 | zRefSU = g_auiRasterToZscan[ rRRefSU- numSUInLCUWidth ]; |
---|
4695 | pRefMapLCU = pRRefMapLCU; |
---|
4696 | } |
---|
4697 | else //inside LCU |
---|
4698 | { |
---|
4699 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth +widthSU]; |
---|
4700 | pRefMapLCU = pSliceIDMapLCU; |
---|
4701 | } |
---|
4702 | pRefID = pRefMapLCU + zRefSU; |
---|
4703 | #if MODIFIED_CROSS_SLICE |
---|
4704 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4705 | #else |
---|
4706 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4707 | #endif |
---|
4708 | } |
---|
4709 | |
---|
4710 | // SGU_BL |
---|
4711 | pbAvail = &(pbAvailBorder[SGU_BL]); |
---|
4712 | if(bPicBBoundary || bPicLBoundary) |
---|
4713 | { |
---|
4714 | *pbAvail = false; |
---|
4715 | } |
---|
4716 | #if MODIFIED_CROSS_SLICE |
---|
4717 | else if (onlyOneSliceInPic) |
---|
4718 | #else |
---|
4719 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4720 | #endif |
---|
4721 | { |
---|
4722 | *pbAvail = true; |
---|
4723 | } |
---|
4724 | else |
---|
4725 | { |
---|
4726 | if(bLCUBBoundary && bLCULBoundary) |
---|
4727 | { |
---|
4728 | zRefSU = g_auiRasterToZscan[numSUInLCUWidth - 1]; |
---|
4729 | pRefMapLCU = pSliceIDMapLCU + ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
4730 | } |
---|
4731 | else if(bLCUBBoundary) |
---|
4732 | { |
---|
4733 | zRefSU = g_auiRasterToZscan[ rBRefSU - 1]; |
---|
4734 | pRefMapLCU = pBRefMapLCU; |
---|
4735 | } |
---|
4736 | else if(bLCULBoundary) |
---|
4737 | { |
---|
4738 | zRefSU = g_auiRasterToZscan[ rLRefSU+ heightSU*numSUInLCUWidth ]; |
---|
4739 | pRefMapLCU = pLRefMapLCU; |
---|
4740 | } |
---|
4741 | else //inside LCU |
---|
4742 | { |
---|
4743 | zRefSU = g_auiRasterToZscan[ rTLSU + heightSU*numSUInLCUWidth -1]; |
---|
4744 | pRefMapLCU = pSliceIDMapLCU; |
---|
4745 | } |
---|
4746 | pRefID = pRefMapLCU + zRefSU; |
---|
4747 | #if MODIFIED_CROSS_SLICE |
---|
4748 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4749 | #else |
---|
4750 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4751 | #endif |
---|
4752 | } |
---|
4753 | |
---|
4754 | // SGU_BR |
---|
4755 | pbAvail = &(pbAvailBorder[SGU_BR]); |
---|
4756 | if(bPicBBoundary || bPicRBoundary) |
---|
4757 | { |
---|
4758 | *pbAvail = false; |
---|
4759 | } |
---|
4760 | #if MODIFIED_CROSS_SLICE |
---|
4761 | else if (onlyOneSliceInPic) |
---|
4762 | #else |
---|
4763 | else if (!bIndependentSliceBoundaryEnabled) |
---|
4764 | #endif |
---|
4765 | { |
---|
4766 | *pbAvail = true; |
---|
4767 | } |
---|
4768 | else |
---|
4769 | { |
---|
4770 | if(bLCUBBoundary && bLCURBoundary) |
---|
4771 | { |
---|
4772 | zRefSU = 0; |
---|
4773 | pRefMapLCU = pSliceIDMapLCU+ ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
4774 | } |
---|
4775 | else if(bLCUBBoundary) |
---|
4776 | { |
---|
4777 | zRefSU = g_auiRasterToZscan[ rBRefSU + widthSU]; |
---|
4778 | pRefMapLCU = pBRefMapLCU; |
---|
4779 | } |
---|
4780 | else if(bLCURBoundary) |
---|
4781 | { |
---|
4782 | zRefSU = g_auiRasterToZscan[ rRRefSU + (heightSU*numSUInLCUWidth)]; |
---|
4783 | pRefMapLCU = pRRefMapLCU; |
---|
4784 | } |
---|
4785 | else //inside LCU |
---|
4786 | { |
---|
4787 | zRefSU = g_auiRasterToZscan[ rTLSU + (heightSU*numSUInLCUWidth)+ widthSU]; |
---|
4788 | pRefMapLCU = pSliceIDMapLCU; |
---|
4789 | } |
---|
4790 | pRefID = pRefMapLCU + zRefSU; |
---|
4791 | #if MODIFIED_CROSS_SLICE |
---|
4792 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
4793 | #else |
---|
4794 | *pbAvail = (*pRefID == sliceID)?(true):(false); |
---|
4795 | #endif |
---|
4796 | } |
---|
4797 | |
---|
4798 | if(bIndependentTileBoundaryEnabled) |
---|
4799 | { |
---|
4800 | //left LCU boundary |
---|
4801 | if(!bPicLBoundary && bLCULBoundary) |
---|
4802 | { |
---|
4803 | if(bLeftTileBoundary) |
---|
4804 | { |
---|
4805 | pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false; |
---|
4806 | } |
---|
4807 | } |
---|
4808 | //right LCU boundary |
---|
4809 | if(!bPicRBoundary && bLCURBoundary) |
---|
4810 | { |
---|
4811 | if(bRightTileBoundary) |
---|
4812 | { |
---|
4813 | pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false; |
---|
4814 | } |
---|
4815 | } |
---|
4816 | //top LCU boundary |
---|
4817 | if(!bPicTBoundary && bLCUTBoundary) |
---|
4818 | { |
---|
4819 | if(bTopTileBoundary) |
---|
4820 | { |
---|
4821 | pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false; |
---|
4822 | } |
---|
4823 | } |
---|
4824 | //down LCU boundary |
---|
4825 | if(!bPicBBoundary && bLCUBBoundary) |
---|
4826 | { |
---|
4827 | if(bDownTileBoundary) |
---|
4828 | { |
---|
4829 | pbAvailBorder[SGU_B] = pbAvailBorder[SGU_BL] = pbAvailBorder[SGU_BR] = false; |
---|
4830 | } |
---|
4831 | } |
---|
4832 | } |
---|
4833 | rSGU.allBordersAvailable = true; |
---|
4834 | for(Int b=0; b< NUM_SGU_BORDER; b++) |
---|
4835 | { |
---|
4836 | if(pbAvailBorder[b] == false) |
---|
4837 | { |
---|
4838 | rSGU.allBordersAvailable = false; |
---|
4839 | break; |
---|
4840 | } |
---|
4841 | } |
---|
4842 | } |
---|
4843 | } |
---|
4844 | |
---|
4845 | #if INTRA_BL |
---|
4846 | Void TComDataCU::getBaseLumaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride ) |
---|
4847 | { |
---|
4848 | TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec(); |
---|
4849 | UInt uiStrideBase = pcBaseRec->getStride(); |
---|
4850 | Pel* piBase = pcBaseRec->getLumaAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
4851 | |
---|
4852 | for ( UInt y = 0; y < uiHeight; y ++ ) |
---|
4853 | { |
---|
4854 | memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) ); |
---|
4855 | } |
---|
4856 | } |
---|
4857 | |
---|
4858 | Void TComDataCU::getBaseChromaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, UInt uiChromaId ) |
---|
4859 | { |
---|
4860 | TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec(); |
---|
4861 | |
---|
4862 | UInt uiStrideBase = pcBaseRec->getCStride(); |
---|
4863 | Pel* piBase; |
---|
4864 | |
---|
4865 | if( uiChromaId == 0 ) |
---|
4866 | { |
---|
4867 | piBase = pcBaseRec->getCbAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
4868 | } |
---|
4869 | else |
---|
4870 | { |
---|
4871 | piBase = pcBaseRec->getCrAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
4872 | } |
---|
4873 | |
---|
4874 | for ( UInt y = 0; y < uiHeight; y ++ ) |
---|
4875 | { |
---|
4876 | memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) ); |
---|
4877 | } |
---|
4878 | } |
---|
4879 | |
---|
4880 | #endif |
---|
4881 | |
---|
4882 | #if SVC_COL_BLK |
---|
4883 | TComDataCU* TComDataCU::getBaseColCU( UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase ) |
---|
4884 | { |
---|
4885 | TComPic* cBaseColPic = m_pcSlice->getBaseColPic(); |
---|
4886 | |
---|
4887 | #if SVC_UPSAMPLING |
---|
4888 | Int iBWidth = cBaseColPic->getPicYuvRec()->getWidth () - cBaseColPic->getPicYuvRec()->getPicCropLeftOffset() - cBaseColPic->getPicYuvRec()->getPicCropRightOffset(); |
---|
4889 | Int iBHeight = cBaseColPic->getPicYuvRec()->getHeight() - cBaseColPic->getPicYuvRec()->getPicCropTopOffset() - cBaseColPic->getPicYuvRec()->getPicCropBottomOffset(); |
---|
4890 | |
---|
4891 | Int iEWidth = m_pcPic->getPicYuvRec()->getWidth() - m_pcPic->getPicYuvRec()->getPicCropLeftOffset() - m_pcPic->getPicYuvRec()->getPicCropRightOffset(); |
---|
4892 | Int iEHeight = m_pcPic->getPicYuvRec()->getHeight() - m_pcPic->getPicYuvRec()->getPicCropTopOffset() - m_pcPic->getPicYuvRec()->getPicCropBottomOffset(); |
---|
4893 | #else |
---|
4894 | Int iBWidth = cBaseColPic->getPicYuvRec()->getWidth(); |
---|
4895 | Int iBHeight = cBaseColPic->getPicYuvRec()->getHeight(); |
---|
4896 | |
---|
4897 | Int iEWidth = m_pcPic->getPicYuvRec()->getWidth(); |
---|
4898 | Int iEHeight = m_pcPic->getPicYuvRec()->getHeight(); |
---|
4899 | #endif |
---|
4900 | |
---|
4901 | if (iBWidth == iEWidth && iEHeight == iBHeight) |
---|
4902 | { |
---|
4903 | uiAbsPartIdxBase = uiCuAbsPartIdx + m_uiAbsIdxInLCU; |
---|
4904 | uiCUAddrBase = m_uiCUAddr; |
---|
4905 | } |
---|
4906 | else |
---|
4907 | { |
---|
4908 | UInt uiMinUnitSize = m_pcPic->getMinCUWidth(); |
---|
4909 | UInt uiRasterAddr = g_auiZscanToRaster[uiCuAbsPartIdx]; |
---|
4910 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
4911 | |
---|
4912 | Int iEX = m_uiCUPelX + uiMinUnitSize*(uiRasterAddr%uiNumPartInCUWidth); |
---|
4913 | Int iEY = m_uiCUPelY + uiMinUnitSize*(uiRasterAddr/uiNumPartInCUWidth); |
---|
4914 | |
---|
4915 | Int iBX = (iEX*iBWidth + iEWidth/2)/iEWidth; |
---|
4916 | Int iBY = (iEY*iBHeight+ iEHeight/2)/iEHeight; |
---|
4917 | |
---|
4918 | uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth); |
---|
4919 | |
---|
4920 | assert(uiCUAddrBase < cBaseColPic->getNumCUsInFrame()); |
---|
4921 | |
---|
4922 | UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*cBaseColPic->getNumPartInWidth() |
---|
4923 | + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize; |
---|
4924 | |
---|
4925 | uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase]; |
---|
4926 | } |
---|
4927 | |
---|
4928 | return cBaseColPic->getCU(uiCUAddrBase); |
---|
4929 | } |
---|
4930 | |
---|
4931 | Void TComDataCU::scaleBaseMV( TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase ) |
---|
4932 | { |
---|
4933 | TComMvField cMvFieldBase; |
---|
4934 | TComMv cMv; |
---|
4935 | |
---|
4936 | Int iBWidth = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth(); |
---|
4937 | Int iBHeight = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight(); |
---|
4938 | |
---|
4939 | Int iEWidth = m_pcPic->getPicYuvRec()->getWidth(); |
---|
4940 | Int iEHeight = m_pcPic->getPicYuvRec()->getHeight(); |
---|
4941 | |
---|
4942 | Int iMvX = (rcMvFieldBase.getHor()*iEWidth + (iBWidth/2 -1) * (rcMvFieldBase.getHor() > 0 ? 1: -1) )/iBWidth; |
---|
4943 | Int iMvY = (rcMvFieldBase.getVer()*iEHeight + (iBHeight/2 -1) * (rcMvFieldBase.getVer() > 0 ? 1: -1) )/iBHeight; |
---|
4944 | |
---|
4945 | cMv.set(iMvX, iMvY); |
---|
4946 | |
---|
4947 | rcMvFieldEnhance.setMvField( cMv, rcMvFieldBase.getRefIdx() ); |
---|
4948 | } |
---|
4949 | #endif |
---|
4950 | |
---|
4951 | #if SVC_MVP |
---|
4952 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, UChar uchInterDir, TComMvField* pcMvField ) |
---|
4953 | { |
---|
4954 | if ( getInterDir( uiAbsPartIdx ) != uchInterDir ) |
---|
4955 | { |
---|
4956 | return false; |
---|
4957 | } |
---|
4958 | |
---|
4959 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
4960 | { |
---|
4961 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
4962 | { |
---|
4963 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcMvField[uiRefListIdx].getMv() || |
---|
4964 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcMvField[uiRefListIdx].getRefIdx() ) |
---|
4965 | { |
---|
4966 | return false; |
---|
4967 | } |
---|
4968 | } |
---|
4969 | } |
---|
4970 | |
---|
4971 | return true; |
---|
4972 | } |
---|
4973 | #endif |
---|
4974 | |
---|
4975 | //! \} |
---|