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