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