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