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