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