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-2016, 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 "TComTU.h" |
---|
41 | #include "TComPic.h" |
---|
42 | |
---|
43 | //! \ingroup TLibCommon |
---|
44 | //! \{ |
---|
45 | |
---|
46 | // ==================================================================================================================== |
---|
47 | // Constructor / destructor / create / destroy |
---|
48 | // ==================================================================================================================== |
---|
49 | |
---|
50 | TComDataCU::TComDataCU() |
---|
51 | { |
---|
52 | m_pcPic = NULL; |
---|
53 | m_pcSlice = NULL; |
---|
54 | m_puhDepth = NULL; |
---|
55 | |
---|
56 | m_skipFlag = NULL; |
---|
57 | |
---|
58 | m_pePartSize = NULL; |
---|
59 | m_pePredMode = NULL; |
---|
60 | m_CUTransquantBypass = NULL; |
---|
61 | m_puhWidth = NULL; |
---|
62 | m_puhHeight = NULL; |
---|
63 | m_phQP = NULL; |
---|
64 | m_ChromaQpAdj = NULL; |
---|
65 | m_pbMergeFlag = NULL; |
---|
66 | m_puhMergeIndex = NULL; |
---|
67 | for(UInt i=0; i<MAX_NUM_CHANNEL_TYPE; i++) |
---|
68 | { |
---|
69 | m_puhIntraDir[i] = NULL; |
---|
70 | } |
---|
71 | m_puhInterDir = NULL; |
---|
72 | m_puhTrIdx = NULL; |
---|
73 | |
---|
74 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
75 | { |
---|
76 | m_puhCbf[comp] = NULL; |
---|
77 | m_crossComponentPredictionAlpha[comp] = NULL; |
---|
78 | m_puhTransformSkip[comp] = NULL; |
---|
79 | m_pcTrCoeff[comp] = NULL; |
---|
80 | #if ADAPTIVE_QP_SELECTION |
---|
81 | m_pcArlCoeff[comp] = NULL; |
---|
82 | #endif |
---|
83 | m_pcIPCMSample[comp] = NULL; |
---|
84 | m_explicitRdpcmMode[comp] = NULL; |
---|
85 | } |
---|
86 | #if ADAPTIVE_QP_SELECTION |
---|
87 | m_ArlCoeffIsAliasedAllocation = false; |
---|
88 | #endif |
---|
89 | m_pbIPCMFlag = NULL; |
---|
90 | |
---|
91 | m_pCtuAboveLeft = NULL; |
---|
92 | m_pCtuAboveRight = NULL; |
---|
93 | m_pCtuAbove = NULL; |
---|
94 | m_pCtuLeft = NULL; |
---|
95 | |
---|
96 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
97 | { |
---|
98 | m_apiMVPIdx[i] = NULL; |
---|
99 | m_apiMVPNum[i] = NULL; |
---|
100 | } |
---|
101 | |
---|
102 | m_bDecSubCu = false; |
---|
103 | |
---|
104 | #if FAST_INTRA_SHVC |
---|
105 | ::memset( m_reducedSetIntraModes, 0, sizeof(m_reducedSetIntraModes) ); |
---|
106 | #endif |
---|
107 | } |
---|
108 | |
---|
109 | TComDataCU::~TComDataCU() |
---|
110 | { |
---|
111 | } |
---|
112 | |
---|
113 | Void TComDataCU::create( ChromaFormat chromaFormatIDC, UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
114 | #if ADAPTIVE_QP_SELECTION |
---|
115 | , TCoeff *pParentARLBuffer |
---|
116 | #endif |
---|
117 | ) |
---|
118 | { |
---|
119 | m_bDecSubCu = bDecSubCu; |
---|
120 | |
---|
121 | m_pcPic = NULL; |
---|
122 | m_pcSlice = NULL; |
---|
123 | m_uiNumPartition = uiNumPartition; |
---|
124 | m_unitSize = unitSize; |
---|
125 | |
---|
126 | if ( !bDecSubCu ) |
---|
127 | { |
---|
128 | m_phQP = (SChar* )xMalloc(SChar, uiNumPartition); |
---|
129 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
130 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
131 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
132 | |
---|
133 | m_ChromaQpAdj = new UChar[ uiNumPartition ]; |
---|
134 | m_skipFlag = new Bool[ uiNumPartition ]; |
---|
135 | m_pePartSize = new SChar[ uiNumPartition ]; |
---|
136 | memset( m_pePartSize, NUMBER_OF_PART_SIZES,uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
137 | m_pePredMode = new SChar[ uiNumPartition ]; |
---|
138 | m_CUTransquantBypass = new Bool[ uiNumPartition ]; |
---|
139 | |
---|
140 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
141 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
142 | |
---|
143 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
144 | { |
---|
145 | m_puhIntraDir[ch] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
146 | } |
---|
147 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
148 | |
---|
149 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
150 | |
---|
151 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
152 | { |
---|
153 | const RefPicList rpl=RefPicList(i); |
---|
154 | m_apiMVPIdx[rpl] = new SChar[ uiNumPartition ]; |
---|
155 | m_apiMVPNum[rpl] = new SChar[ uiNumPartition ]; |
---|
156 | memset( m_apiMVPIdx[rpl], -1,uiNumPartition * sizeof( SChar ) ); |
---|
157 | } |
---|
158 | |
---|
159 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
160 | { |
---|
161 | const ComponentID compID = ComponentID(comp); |
---|
162 | const UInt chromaShift = getComponentScaleX(compID, chromaFormatIDC) + getComponentScaleY(compID, chromaFormatIDC); |
---|
163 | const UInt totalSize = (uiWidth * uiHeight) >> chromaShift; |
---|
164 | |
---|
165 | m_crossComponentPredictionAlpha[compID] = (SChar* )xMalloc(SChar, uiNumPartition); |
---|
166 | m_puhTransformSkip[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
167 | m_explicitRdpcmMode[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
168 | m_puhCbf[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
169 | m_pcTrCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); |
---|
170 | memset( m_pcTrCoeff[compID], 0, (totalSize * sizeof( TCoeff )) ); |
---|
171 | |
---|
172 | #if ADAPTIVE_QP_SELECTION |
---|
173 | if( pParentARLBuffer != 0 ) |
---|
174 | { |
---|
175 | m_pcArlCoeff[compID] = pParentARLBuffer; |
---|
176 | m_ArlCoeffIsAliasedAllocation = true; |
---|
177 | pParentARLBuffer += totalSize; |
---|
178 | } |
---|
179 | else |
---|
180 | { |
---|
181 | m_pcArlCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); |
---|
182 | m_ArlCoeffIsAliasedAllocation = false; |
---|
183 | } |
---|
184 | #endif |
---|
185 | m_pcIPCMSample[compID] = (Pel* )xMalloc(Pel , totalSize); |
---|
186 | } |
---|
187 | |
---|
188 | m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
189 | |
---|
190 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
191 | { |
---|
192 | m_acCUMvField[i].create( uiNumPartition ); |
---|
193 | } |
---|
194 | |
---|
195 | } |
---|
196 | else |
---|
197 | { |
---|
198 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
199 | { |
---|
200 | m_acCUMvField[i].setNumPartition(uiNumPartition ); |
---|
201 | } |
---|
202 | } |
---|
203 | |
---|
204 | // create motion vector fields |
---|
205 | |
---|
206 | m_pCtuAboveLeft = NULL; |
---|
207 | m_pCtuAboveRight = NULL; |
---|
208 | m_pCtuAbove = NULL; |
---|
209 | m_pCtuLeft = NULL; |
---|
210 | } |
---|
211 | |
---|
212 | Void TComDataCU::destroy() |
---|
213 | { |
---|
214 | // encoder-side buffer free |
---|
215 | if ( !m_bDecSubCu ) |
---|
216 | { |
---|
217 | if ( m_phQP ) |
---|
218 | { |
---|
219 | xFree(m_phQP); |
---|
220 | m_phQP = NULL; |
---|
221 | } |
---|
222 | if ( m_puhDepth ) |
---|
223 | { |
---|
224 | xFree(m_puhDepth); |
---|
225 | m_puhDepth = NULL; |
---|
226 | } |
---|
227 | if ( m_puhWidth ) |
---|
228 | { |
---|
229 | xFree(m_puhWidth); |
---|
230 | m_puhWidth = NULL; |
---|
231 | } |
---|
232 | if ( m_puhHeight ) |
---|
233 | { |
---|
234 | xFree(m_puhHeight); |
---|
235 | m_puhHeight = NULL; |
---|
236 | } |
---|
237 | |
---|
238 | if ( m_skipFlag ) |
---|
239 | { |
---|
240 | delete[] m_skipFlag; |
---|
241 | m_skipFlag = NULL; |
---|
242 | } |
---|
243 | |
---|
244 | if ( m_pePartSize ) |
---|
245 | { |
---|
246 | delete[] m_pePartSize; |
---|
247 | m_pePartSize = NULL; |
---|
248 | } |
---|
249 | if ( m_pePredMode ) |
---|
250 | { |
---|
251 | delete[] m_pePredMode; |
---|
252 | m_pePredMode = NULL; |
---|
253 | } |
---|
254 | if ( m_ChromaQpAdj ) |
---|
255 | { |
---|
256 | delete[] m_ChromaQpAdj; |
---|
257 | m_ChromaQpAdj = NULL; |
---|
258 | } |
---|
259 | if ( m_CUTransquantBypass ) |
---|
260 | { |
---|
261 | delete[] m_CUTransquantBypass; |
---|
262 | m_CUTransquantBypass = NULL; |
---|
263 | } |
---|
264 | if ( m_puhInterDir ) |
---|
265 | { |
---|
266 | xFree(m_puhInterDir); |
---|
267 | m_puhInterDir = NULL; |
---|
268 | } |
---|
269 | if ( m_pbMergeFlag ) |
---|
270 | { |
---|
271 | xFree(m_pbMergeFlag); |
---|
272 | m_pbMergeFlag = NULL; |
---|
273 | } |
---|
274 | if ( m_puhMergeIndex ) |
---|
275 | { |
---|
276 | xFree(m_puhMergeIndex); |
---|
277 | m_puhMergeIndex = NULL; |
---|
278 | } |
---|
279 | |
---|
280 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
281 | { |
---|
282 | xFree(m_puhIntraDir[ch]); |
---|
283 | m_puhIntraDir[ch] = NULL; |
---|
284 | } |
---|
285 | |
---|
286 | if ( m_puhTrIdx ) |
---|
287 | { |
---|
288 | xFree(m_puhTrIdx); |
---|
289 | m_puhTrIdx = NULL; |
---|
290 | } |
---|
291 | |
---|
292 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
293 | { |
---|
294 | if ( m_crossComponentPredictionAlpha[comp] ) |
---|
295 | { |
---|
296 | xFree(m_crossComponentPredictionAlpha[comp]); |
---|
297 | m_crossComponentPredictionAlpha[comp] = NULL; |
---|
298 | } |
---|
299 | if ( m_puhTransformSkip[comp] ) |
---|
300 | { |
---|
301 | xFree(m_puhTransformSkip[comp]); |
---|
302 | m_puhTransformSkip[comp] = NULL; |
---|
303 | } |
---|
304 | if ( m_puhCbf[comp] ) |
---|
305 | { |
---|
306 | xFree(m_puhCbf[comp]); |
---|
307 | m_puhCbf[comp] = NULL; |
---|
308 | } |
---|
309 | if ( m_pcTrCoeff[comp] ) |
---|
310 | { |
---|
311 | xFree(m_pcTrCoeff[comp]); |
---|
312 | m_pcTrCoeff[comp] = NULL; |
---|
313 | } |
---|
314 | if ( m_explicitRdpcmMode[comp] ) |
---|
315 | { |
---|
316 | xFree(m_explicitRdpcmMode[comp]); |
---|
317 | m_explicitRdpcmMode[comp] = NULL; |
---|
318 | } |
---|
319 | |
---|
320 | #if ADAPTIVE_QP_SELECTION |
---|
321 | if (!m_ArlCoeffIsAliasedAllocation) |
---|
322 | { |
---|
323 | if ( m_pcArlCoeff[comp] ) |
---|
324 | { |
---|
325 | xFree(m_pcArlCoeff[comp]); |
---|
326 | m_pcArlCoeff[comp] = NULL; |
---|
327 | } |
---|
328 | } |
---|
329 | #endif |
---|
330 | |
---|
331 | if ( m_pcIPCMSample[comp] ) |
---|
332 | { |
---|
333 | xFree(m_pcIPCMSample[comp]); |
---|
334 | m_pcIPCMSample[comp] = NULL; |
---|
335 | } |
---|
336 | } |
---|
337 | if ( m_pbIPCMFlag ) |
---|
338 | { |
---|
339 | xFree(m_pbIPCMFlag ); |
---|
340 | m_pbIPCMFlag = NULL; |
---|
341 | } |
---|
342 | |
---|
343 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
344 | { |
---|
345 | const RefPicList rpl=RefPicList(i); |
---|
346 | if ( m_apiMVPIdx[rpl] ) |
---|
347 | { |
---|
348 | delete[] m_apiMVPIdx[rpl]; |
---|
349 | m_apiMVPIdx[rpl] = NULL; |
---|
350 | } |
---|
351 | if ( m_apiMVPNum[rpl] ) |
---|
352 | { |
---|
353 | delete[] m_apiMVPNum[rpl]; |
---|
354 | m_apiMVPNum[rpl] = NULL; |
---|
355 | } |
---|
356 | } |
---|
357 | |
---|
358 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
359 | { |
---|
360 | const RefPicList rpl=RefPicList(i); |
---|
361 | m_acCUMvField[rpl].destroy(); |
---|
362 | } |
---|
363 | } |
---|
364 | |
---|
365 | m_pcPic = NULL; |
---|
366 | m_pcSlice = NULL; |
---|
367 | |
---|
368 | m_pCtuAboveLeft = NULL; |
---|
369 | m_pCtuAboveRight = NULL; |
---|
370 | m_pCtuAbove = NULL; |
---|
371 | m_pCtuLeft = NULL; |
---|
372 | |
---|
373 | } |
---|
374 | |
---|
375 | Bool TComDataCU::CUIsFromSameTile ( const TComDataCU *pCU /* Can be NULL */) const |
---|
376 | { |
---|
377 | return pCU!=NULL && |
---|
378 | pCU->getSlice() != NULL && |
---|
379 | m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()); |
---|
380 | } |
---|
381 | |
---|
382 | Bool TComDataCU::CUIsFromSameSliceAndTile ( const TComDataCU *pCU /* Can be NULL */) const |
---|
383 | { |
---|
384 | return pCU!=NULL && |
---|
385 | pCU->getSlice() != NULL && |
---|
386 | pCU->getSlice()->getSliceCurStartCtuTsAddr() == getSlice()->getSliceCurStartCtuTsAddr() && |
---|
387 | m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()) |
---|
388 | ; |
---|
389 | } |
---|
390 | |
---|
391 | Bool TComDataCU::CUIsFromSameSliceTileAndWavefrontRow( const TComDataCU *pCU /* Can be NULL */) const |
---|
392 | { |
---|
393 | return CUIsFromSameSliceAndTile(pCU) |
---|
394 | && (!getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() || getPic()->getCtu(getCtuRsAddr())->getCUPelY() == getPic()->getCtu(pCU->getCtuRsAddr())->getCUPelY()); |
---|
395 | } |
---|
396 | |
---|
397 | Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx) const |
---|
398 | { |
---|
399 | const TComSPS &sps=*(getSlice()->getSPS()); |
---|
400 | |
---|
401 | const UInt picWidth = sps.getPicWidthInLumaSamples(); |
---|
402 | const UInt picHeight = sps.getPicHeightInLumaSamples(); |
---|
403 | const UInt granularityWidth = sps.getMaxCUWidth(); |
---|
404 | |
---|
405 | const UInt cuPosX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[absPartIdx] ]; |
---|
406 | const UInt cuPosY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[absPartIdx] ]; |
---|
407 | |
---|
408 | return (((cuPosX+getWidth( absPartIdx))%granularityWidth==0||(cuPosX+getWidth( absPartIdx)==picWidth )) |
---|
409 | && ((cuPosY+getHeight(absPartIdx))%granularityWidth==0||(cuPosY+getHeight(absPartIdx)==picHeight))); |
---|
410 | } |
---|
411 | |
---|
412 | // ==================================================================================================================== |
---|
413 | // Public member functions |
---|
414 | // ==================================================================================================================== |
---|
415 | |
---|
416 | // -------------------------------------------------------------------------------------------------------------------- |
---|
417 | // Initialization |
---|
418 | // -------------------------------------------------------------------------------------------------------------------- |
---|
419 | |
---|
420 | /** |
---|
421 | Initialize top-level CU: create internal buffers and set initial values before encoding the CTU. |
---|
422 | |
---|
423 | \param pcPic picture (TComPic) class pointer |
---|
424 | \param ctuRsAddr CTU address in raster scan order |
---|
425 | */ |
---|
426 | Void TComDataCU::initCtu( TComPic* pcPic, UInt ctuRsAddr ) |
---|
427 | { |
---|
428 | |
---|
429 | const UInt maxCUWidth = pcPic->getPicSym()->getSPS().getMaxCUWidth(); |
---|
430 | const UInt maxCUHeight= pcPic->getPicSym()->getSPS().getMaxCUHeight(); |
---|
431 | m_pcPic = pcPic; |
---|
432 | m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
433 | m_ctuRsAddr = ctuRsAddr; |
---|
434 | m_uiCUPelX = ( ctuRsAddr % pcPic->getFrameWidthInCtus() ) * maxCUWidth; |
---|
435 | m_uiCUPelY = ( ctuRsAddr / pcPic->getFrameWidthInCtus() ) * maxCUHeight; |
---|
436 | m_absZIdxInCtu = 0; |
---|
437 | m_dTotalCost = MAX_DOUBLE; |
---|
438 | m_uiTotalDistortion = 0; |
---|
439 | m_uiTotalBits = 0; |
---|
440 | m_uiTotalBins = 0; |
---|
441 | m_uiNumPartition = pcPic->getNumPartitionsInCtu(); |
---|
442 | |
---|
443 | memset( m_skipFlag , false, m_uiNumPartition * sizeof( *m_skipFlag ) ); |
---|
444 | |
---|
445 | memset( m_pePartSize , NUMBER_OF_PART_SIZES, m_uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
446 | memset( m_pePredMode , NUMBER_OF_PREDICTION_MODES, m_uiNumPartition * sizeof( *m_pePredMode ) ); |
---|
447 | memset( m_CUTransquantBypass, false, m_uiNumPartition * sizeof( *m_CUTransquantBypass) ); |
---|
448 | memset( m_puhDepth , 0, m_uiNumPartition * sizeof( *m_puhDepth ) ); |
---|
449 | memset( m_puhTrIdx , 0, m_uiNumPartition * sizeof( *m_puhTrIdx ) ); |
---|
450 | memset( m_puhWidth , maxCUWidth, m_uiNumPartition * sizeof( *m_puhWidth ) ); |
---|
451 | memset( m_puhHeight , maxCUHeight, m_uiNumPartition * sizeof( *m_puhHeight ) ); |
---|
452 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
453 | { |
---|
454 | const RefPicList rpl=RefPicList(i); |
---|
455 | memset( m_apiMVPIdx[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPIdx[rpl] ) ); |
---|
456 | memset( m_apiMVPNum[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPNum[rpl] ) ); |
---|
457 | } |
---|
458 | memset( m_phQP , getSlice()->getSliceQp(), m_uiNumPartition * sizeof( *m_phQP ) ); |
---|
459 | memset( m_ChromaQpAdj , 0, m_uiNumPartition * sizeof( *m_ChromaQpAdj ) ); |
---|
460 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
461 | { |
---|
462 | memset( m_crossComponentPredictionAlpha[comp] , 0, m_uiNumPartition * sizeof( *m_crossComponentPredictionAlpha[comp] ) ); |
---|
463 | memset( m_puhTransformSkip[comp] , 0, m_uiNumPartition * sizeof( *m_puhTransformSkip[comp]) ); |
---|
464 | memset( m_puhCbf[comp] , 0, m_uiNumPartition * sizeof( *m_puhCbf[comp] ) ); |
---|
465 | memset( m_explicitRdpcmMode[comp] , NUMBER_OF_RDPCM_MODES, m_uiNumPartition * sizeof( *m_explicitRdpcmMode[comp] ) ); |
---|
466 | } |
---|
467 | memset( m_pbMergeFlag , false, m_uiNumPartition * sizeof( *m_pbMergeFlag ) ); |
---|
468 | memset( m_puhMergeIndex , 0, m_uiNumPartition * sizeof( *m_puhMergeIndex ) ); |
---|
469 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
470 | { |
---|
471 | memset( m_puhIntraDir[ch] , ((ch==0) ? DC_IDX : 0), m_uiNumPartition * sizeof( *(m_puhIntraDir[ch]) ) ); |
---|
472 | } |
---|
473 | memset( m_puhInterDir , 0, m_uiNumPartition * sizeof( *m_puhInterDir ) ); |
---|
474 | memset( m_pbIPCMFlag , false, m_uiNumPartition * sizeof( *m_pbIPCMFlag ) ); |
---|
475 | |
---|
476 | const UInt numCoeffY = maxCUWidth*maxCUHeight; |
---|
477 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
478 | { |
---|
479 | const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(comp)) + m_pcPic->getComponentScaleY(ComponentID(comp)); |
---|
480 | memset( m_pcTrCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); |
---|
481 | #if ADAPTIVE_QP_SELECTION |
---|
482 | memset( m_pcArlCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); |
---|
483 | #endif |
---|
484 | } |
---|
485 | |
---|
486 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
487 | { |
---|
488 | m_acCUMvField[i].clearMvField(); |
---|
489 | } |
---|
490 | |
---|
491 | // Setting neighbor CU |
---|
492 | m_pCtuLeft = NULL; |
---|
493 | m_pCtuAbove = NULL; |
---|
494 | m_pCtuAboveLeft = NULL; |
---|
495 | m_pCtuAboveRight = NULL; |
---|
496 | |
---|
497 | UInt frameWidthInCtus = pcPic->getFrameWidthInCtus(); |
---|
498 | if ( m_ctuRsAddr % frameWidthInCtus ) |
---|
499 | { |
---|
500 | m_pCtuLeft = pcPic->getCtu( m_ctuRsAddr - 1 ); |
---|
501 | } |
---|
502 | |
---|
503 | if ( m_ctuRsAddr / frameWidthInCtus ) |
---|
504 | { |
---|
505 | m_pCtuAbove = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus ); |
---|
506 | } |
---|
507 | |
---|
508 | if ( m_pCtuLeft && m_pCtuAbove ) |
---|
509 | { |
---|
510 | m_pCtuAboveLeft = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus - 1 ); |
---|
511 | } |
---|
512 | |
---|
513 | if ( m_pCtuAbove && ( (m_ctuRsAddr%frameWidthInCtus) < (frameWidthInCtus-1) ) ) |
---|
514 | { |
---|
515 | m_pCtuAboveRight = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus + 1 ); |
---|
516 | } |
---|
517 | } |
---|
518 | |
---|
519 | |
---|
520 | /** Initialize prediction data with enabling sub-CTU-level delta QP. |
---|
521 | * - set CU width and CU height according to depth |
---|
522 | * - set qp value according to input qp |
---|
523 | * - set last-coded qp value according to input last-coded qp |
---|
524 | * |
---|
525 | * \param uiDepth depth of the current CU |
---|
526 | * \param qp qp for the current CU |
---|
527 | * \param bTransquantBypass true for transquant bypass |
---|
528 | */ |
---|
529 | Void TComDataCU::initEstData( const UInt uiDepth, const Int qp, const Bool bTransquantBypass ) |
---|
530 | { |
---|
531 | m_dTotalCost = MAX_DOUBLE; |
---|
532 | m_uiTotalDistortion = 0; |
---|
533 | m_uiTotalBits = 0; |
---|
534 | m_uiTotalBins = 0; |
---|
535 | |
---|
536 | const UChar uhWidth = getSlice()->getSPS()->getMaxCUWidth() >> uiDepth; |
---|
537 | const UChar uhHeight = getSlice()->getSPS()->getMaxCUHeight() >> uiDepth; |
---|
538 | |
---|
539 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
540 | { |
---|
541 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
542 | { |
---|
543 | const RefPicList rpl=RefPicList(i); |
---|
544 | m_apiMVPIdx[rpl][ui] = -1; |
---|
545 | m_apiMVPNum[rpl][ui] = -1; |
---|
546 | } |
---|
547 | m_puhDepth [ui] = uiDepth; |
---|
548 | m_puhWidth [ui] = uhWidth; |
---|
549 | m_puhHeight [ui] = uhHeight; |
---|
550 | m_puhTrIdx [ui] = 0; |
---|
551 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
552 | { |
---|
553 | m_crossComponentPredictionAlpha[comp][ui] = 0; |
---|
554 | m_puhTransformSkip [comp][ui] = 0; |
---|
555 | m_explicitRdpcmMode [comp][ui] = NUMBER_OF_RDPCM_MODES; |
---|
556 | } |
---|
557 | m_skipFlag[ui] = false; |
---|
558 | m_pePartSize[ui] = NUMBER_OF_PART_SIZES; |
---|
559 | m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; |
---|
560 | m_CUTransquantBypass[ui] = bTransquantBypass; |
---|
561 | m_pbIPCMFlag[ui] = 0; |
---|
562 | m_phQP[ui] = qp; |
---|
563 | m_ChromaQpAdj[ui] = 0; |
---|
564 | m_pbMergeFlag[ui] = 0; |
---|
565 | m_puhMergeIndex[ui] = 0; |
---|
566 | |
---|
567 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
568 | { |
---|
569 | m_puhIntraDir[ch][ui] = ((ch==0) ? DC_IDX : 0); |
---|
570 | } |
---|
571 | |
---|
572 | m_puhInterDir[ui] = 0; |
---|
573 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
574 | { |
---|
575 | m_puhCbf[comp][ui] = 0; |
---|
576 | } |
---|
577 | } |
---|
578 | |
---|
579 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
580 | { |
---|
581 | m_acCUMvField[i].clearMvField(); |
---|
582 | } |
---|
583 | |
---|
584 | const UInt numCoeffY = uhWidth*uhHeight; |
---|
585 | |
---|
586 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
587 | { |
---|
588 | const ComponentID component = ComponentID(comp); |
---|
589 | const UInt numCoeff = numCoeffY >> (getPic()->getComponentScaleX(component) + getPic()->getComponentScaleY(component)); |
---|
590 | memset( m_pcTrCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); |
---|
591 | #if ADAPTIVE_QP_SELECTION |
---|
592 | memset( m_pcArlCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); |
---|
593 | #endif |
---|
594 | memset( m_pcIPCMSample[comp], 0, numCoeff * sizeof( Pel) ); |
---|
595 | } |
---|
596 | } |
---|
597 | |
---|
598 | |
---|
599 | // initialize Sub partition |
---|
600 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ) |
---|
601 | { |
---|
602 | assert( uiPartUnitIdx<4 ); |
---|
603 | |
---|
604 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
---|
605 | |
---|
606 | m_pcPic = pcCU->getPic(); |
---|
607 | m_pcSlice = pcCU->getSlice(); |
---|
608 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
609 | m_absZIdxInCtu = pcCU->getZorderIdxInCtu() + uiPartOffset; |
---|
610 | |
---|
611 | const UChar uhWidth = getSlice()->getSPS()->getMaxCUWidth() >> uiDepth; |
---|
612 | const UChar uhHeight = getSlice()->getSPS()->getMaxCUHeight() >> uiDepth; |
---|
613 | |
---|
614 | m_uiCUPelX = pcCU->getCUPelX() + ( uhWidth )*( uiPartUnitIdx & 1 ); |
---|
615 | m_uiCUPelY = pcCU->getCUPelY() + ( uhHeight)*( uiPartUnitIdx >> 1 ); |
---|
616 | |
---|
617 | m_dTotalCost = MAX_DOUBLE; |
---|
618 | m_uiTotalDistortion = 0; |
---|
619 | m_uiTotalBits = 0; |
---|
620 | m_uiTotalBins = 0; |
---|
621 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
---|
622 | |
---|
623 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
624 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
625 | Int sizeInChar = sizeof( SChar ) * m_uiNumPartition; |
---|
626 | |
---|
627 | memset( m_phQP, qp, sizeInChar ); |
---|
628 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
629 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
630 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
631 | { |
---|
632 | memset( m_puhIntraDir[ch], ((ch==0) ? DC_IDX : 0), iSizeInUchar ); |
---|
633 | } |
---|
634 | |
---|
635 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
636 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
637 | |
---|
638 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
639 | { |
---|
640 | memset( m_crossComponentPredictionAlpha[comp], 0, iSizeInUchar ); |
---|
641 | memset( m_puhTransformSkip[comp], 0, iSizeInUchar ); |
---|
642 | memset( m_puhCbf[comp], 0, iSizeInUchar ); |
---|
643 | memset( m_explicitRdpcmMode[comp], NUMBER_OF_RDPCM_MODES, iSizeInUchar ); |
---|
644 | } |
---|
645 | |
---|
646 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
---|
647 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
648 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
649 | memset( m_pbIPCMFlag, 0, iSizeInBool ); |
---|
650 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
651 | { |
---|
652 | m_skipFlag[ui] = false; |
---|
653 | m_pePartSize[ui] = NUMBER_OF_PART_SIZES; |
---|
654 | m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; |
---|
655 | m_CUTransquantBypass[ui] = false; |
---|
656 | m_ChromaQpAdj[ui] = 0; |
---|
657 | |
---|
658 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
659 | { |
---|
660 | const RefPicList rpl=RefPicList(i); |
---|
661 | m_apiMVPIdx[rpl][ui] = -1; |
---|
662 | m_apiMVPNum[rpl][ui] = -1; |
---|
663 | } |
---|
664 | } |
---|
665 | |
---|
666 | const UInt numCoeffY = uhWidth*uhHeight; |
---|
667 | for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
668 | { |
---|
669 | const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(ch)) + m_pcPic->getComponentScaleY(ComponentID(ch)); |
---|
670 | memset( m_pcTrCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
671 | #if ADAPTIVE_QP_SELECTION |
---|
672 | memset( m_pcArlCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
673 | #endif |
---|
674 | memset( m_pcIPCMSample[ch], 0, sizeof(Pel)* (numCoeffY>>componentShift) ); |
---|
675 | } |
---|
676 | |
---|
677 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
678 | { |
---|
679 | m_acCUMvField[i].clearMvField(); |
---|
680 | } |
---|
681 | |
---|
682 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
683 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
684 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
685 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
686 | } |
---|
687 | |
---|
688 | Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
689 | { |
---|
690 | const UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); |
---|
691 | const UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
692 | const TComSPS &sps = *(getSlice()->getSPS()); |
---|
693 | const UChar uhWidth = sps.getMaxCUWidth() >> uiDepth; |
---|
694 | const UChar uhHeight = sps.getMaxCUHeight() >> uiDepth; |
---|
695 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); |
---|
696 | memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); |
---|
697 | memset( m_puhHeight + uiAbsPartIdx, uhHeight, uiSizeInUchar ); |
---|
698 | } |
---|
699 | |
---|
700 | // -------------------------------------------------------------------------------------------------------------------- |
---|
701 | // Copy |
---|
702 | // -------------------------------------------------------------------------------------------------------------------- |
---|
703 | |
---|
704 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
705 | { |
---|
706 | UInt uiPart = uiAbsPartIdx; |
---|
707 | |
---|
708 | m_pcPic = pcCU->getPic(); |
---|
709 | m_pcSlice = pcCU->getSlice(); |
---|
710 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
711 | m_absZIdxInCtu = uiAbsPartIdx; |
---|
712 | |
---|
713 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
714 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
715 | |
---|
716 | m_skipFlag=pcCU->getSkipFlag() + uiPart; |
---|
717 | |
---|
718 | m_phQP=pcCU->getQP() + uiPart; |
---|
719 | m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiPart; |
---|
720 | m_pePartSize = pcCU->getPartitionSize() + uiPart; |
---|
721 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
---|
722 | m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; |
---|
723 | |
---|
724 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
---|
725 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
---|
726 | |
---|
727 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
728 | { |
---|
729 | m_puhIntraDir[ch] = pcCU->getIntraDir(ChannelType(ch)) + uiPart; |
---|
730 | } |
---|
731 | |
---|
732 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
---|
733 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
---|
734 | |
---|
735 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
736 | { |
---|
737 | m_crossComponentPredictionAlpha[comp] = pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)) + uiPart; |
---|
738 | m_puhTransformSkip[comp] = pcCU->getTransformSkip(ComponentID(comp)) + uiPart; |
---|
739 | m_puhCbf[comp] = pcCU->getCbf(ComponentID(comp)) + uiPart; |
---|
740 | m_explicitRdpcmMode[comp] = pcCU->getExplicitRdpcmMode(ComponentID(comp)) + uiPart; |
---|
741 | } |
---|
742 | |
---|
743 | m_puhDepth=pcCU->getDepth() + uiPart; |
---|
744 | m_puhWidth=pcCU->getWidth() + uiPart; |
---|
745 | m_puhHeight=pcCU->getHeight() + uiPart; |
---|
746 | |
---|
747 | m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; |
---|
748 | |
---|
749 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
750 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
751 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
752 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
753 | |
---|
754 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
755 | { |
---|
756 | const RefPicList rpl=RefPicList(i); |
---|
757 | m_apiMVPIdx[rpl]=pcCU->getMVPIdx(rpl) + uiPart; |
---|
758 | m_apiMVPNum[rpl]=pcCU->getMVPNum(rpl) + uiPart; |
---|
759 | } |
---|
760 | |
---|
761 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
762 | { |
---|
763 | const RefPicList rpl=RefPicList(i); |
---|
764 | m_acCUMvField[rpl].linkToWithOffset( pcCU->getCUMvField(rpl), uiPart ); |
---|
765 | } |
---|
766 | |
---|
767 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
768 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
769 | |
---|
770 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartitionsInCtu(); |
---|
771 | |
---|
772 | for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
773 | { |
---|
774 | const ComponentID component = ComponentID(ch); |
---|
775 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
776 | const UInt offset = uiCoffOffset >> componentShift; |
---|
777 | m_pcTrCoeff[ch] = pcCU->getCoeff(component) + offset; |
---|
778 | #if ADAPTIVE_QP_SELECTION |
---|
779 | m_pcArlCoeff[ch] = pcCU->getArlCoeff(component) + offset; |
---|
780 | #endif |
---|
781 | m_pcIPCMSample[ch] = pcCU->getPCMSample(component) + offset; |
---|
782 | } |
---|
783 | } |
---|
784 | |
---|
785 | // Copy inter prediction info from the biggest CU |
---|
786 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList ) |
---|
787 | { |
---|
788 | m_pcPic = pcCU->getPic(); |
---|
789 | m_pcSlice = pcCU->getSlice(); |
---|
790 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
791 | m_absZIdxInCtu = uiAbsPartIdx; |
---|
792 | |
---|
793 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
794 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInCtuWidth() ); |
---|
795 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInCtuWidth() ); |
---|
796 | |
---|
797 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
798 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
799 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
800 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
801 | |
---|
802 | m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; |
---|
803 | |
---|
804 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
---|
805 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
---|
806 | m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiAbsPartIdx; |
---|
807 | m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; |
---|
808 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
---|
809 | |
---|
810 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
811 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
812 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
813 | |
---|
814 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
815 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
816 | |
---|
817 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
---|
818 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
---|
819 | |
---|
820 | m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); |
---|
821 | } |
---|
822 | |
---|
823 | // Copy small CU to bigger CU. |
---|
824 | // One of quarter parts overwritten by predicted sub part. |
---|
825 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
826 | { |
---|
827 | assert( uiPartUnitIdx<4 ); |
---|
828 | |
---|
829 | m_dTotalCost += pcCU->getTotalCost(); |
---|
830 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
---|
831 | m_uiTotalBits += pcCU->getTotalBits(); |
---|
832 | |
---|
833 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
---|
834 | const UInt numValidComp=pcCU->getPic()->getNumberValidComponents(); |
---|
835 | const UInt numValidChan=pcCU->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; |
---|
836 | |
---|
837 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
---|
838 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
839 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
840 | |
---|
841 | Int sizeInChar = sizeof( SChar ) * uiNumPartition; |
---|
842 | memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); |
---|
843 | memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); |
---|
844 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); |
---|
845 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); |
---|
846 | memcpy( m_ChromaQpAdj + uiOffset, pcCU->getChromaQpAdj(), sizeof( *m_ChromaQpAdj ) * uiNumPartition ); |
---|
847 | memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); |
---|
848 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
---|
849 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
---|
850 | |
---|
851 | for (UInt ch=0; ch<numValidChan; ch++) |
---|
852 | { |
---|
853 | memcpy( m_puhIntraDir[ch] + uiOffset, pcCU->getIntraDir(ChannelType(ch)), iSizeInUchar ); |
---|
854 | } |
---|
855 | |
---|
856 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
---|
857 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
---|
858 | |
---|
859 | for(UInt comp=0; comp<numValidComp; comp++) |
---|
860 | { |
---|
861 | memcpy( m_crossComponentPredictionAlpha[comp] + uiOffset, pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)), iSizeInUchar ); |
---|
862 | memcpy( m_puhTransformSkip[comp] + uiOffset, pcCU->getTransformSkip(ComponentID(comp)) , iSizeInUchar ); |
---|
863 | memcpy( m_puhCbf[comp] + uiOffset, pcCU->getCbf(ComponentID(comp)) , iSizeInUchar ); |
---|
864 | memcpy( m_explicitRdpcmMode[comp] + uiOffset, pcCU->getExplicitRdpcmMode(ComponentID(comp)) , iSizeInUchar ); |
---|
865 | } |
---|
866 | |
---|
867 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
---|
868 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
---|
869 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
---|
870 | |
---|
871 | memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); |
---|
872 | |
---|
873 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
874 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
875 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
876 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
877 | |
---|
878 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
879 | { |
---|
880 | const RefPicList rpl=RefPicList(i); |
---|
881 | memcpy( m_apiMVPIdx[rpl] + uiOffset, pcCU->getMVPIdx(rpl), iSizeInUchar ); |
---|
882 | memcpy( m_apiMVPNum[rpl] + uiOffset, pcCU->getMVPNum(rpl), iSizeInUchar ); |
---|
883 | } |
---|
884 | |
---|
885 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
886 | { |
---|
887 | const RefPicList rpl=RefPicList(i); |
---|
888 | m_acCUMvField[rpl].copyFrom( pcCU->getCUMvField( rpl ), pcCU->getTotalNumPart(), uiOffset ); |
---|
889 | } |
---|
890 | |
---|
891 | const UInt numCoeffY = (pcCU->getSlice()->getSPS()->getMaxCUWidth()*pcCU->getSlice()->getSPS()->getMaxCUHeight()) >> (uiDepth<<1); |
---|
892 | const UInt offsetY = uiPartUnitIdx*numCoeffY; |
---|
893 | for (UInt ch=0; ch<numValidComp; ch++) |
---|
894 | { |
---|
895 | const ComponentID component = ComponentID(ch); |
---|
896 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
897 | const UInt offset = offsetY>>componentShift; |
---|
898 | memcpy( m_pcTrCoeff [ch] + offset, pcCU->getCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
899 | #if ADAPTIVE_QP_SELECTION |
---|
900 | memcpy( m_pcArlCoeff[ch] + offset, pcCU->getArlCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
901 | #endif |
---|
902 | memcpy( m_pcIPCMSample[ch] + offset, pcCU->getPCMSample(component), sizeof(Pel)*(numCoeffY>>componentShift) ); |
---|
903 | } |
---|
904 | |
---|
905 | m_uiTotalBins += pcCU->getTotalBins(); |
---|
906 | } |
---|
907 | |
---|
908 | // Copy current predicted part to a CU in picture. |
---|
909 | // It is used to predict for next part |
---|
910 | Void TComDataCU::copyToPic( UChar uhDepth ) |
---|
911 | { |
---|
912 | TComDataCU* pCtu = m_pcPic->getCtu( m_ctuRsAddr ); |
---|
913 | const UInt numValidComp=pCtu->getPic()->getNumberValidComponents(); |
---|
914 | const UInt numValidChan=pCtu->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; |
---|
915 | |
---|
916 | pCtu->getTotalCost() = m_dTotalCost; |
---|
917 | pCtu->getTotalDistortion() = m_uiTotalDistortion; |
---|
918 | pCtu->getTotalBits() = m_uiTotalBits; |
---|
919 | |
---|
920 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
921 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
922 | Int sizeInChar = sizeof( SChar ) * m_uiNumPartition; |
---|
923 | |
---|
924 | memcpy( pCtu->getSkipFlag() + m_absZIdxInCtu, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); |
---|
925 | |
---|
926 | memcpy( pCtu->getQP() + m_absZIdxInCtu, m_phQP, sizeInChar ); |
---|
927 | |
---|
928 | memcpy( pCtu->getPartitionSize() + m_absZIdxInCtu, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); |
---|
929 | memcpy( pCtu->getPredictionMode() + m_absZIdxInCtu, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); |
---|
930 | memcpy( pCtu->getChromaQpAdj() + m_absZIdxInCtu, m_ChromaQpAdj, sizeof( *m_ChromaQpAdj ) * m_uiNumPartition ); |
---|
931 | memcpy( pCtu->getCUTransquantBypass()+ m_absZIdxInCtu, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); |
---|
932 | memcpy( pCtu->getMergeFlag() + m_absZIdxInCtu, m_pbMergeFlag, iSizeInBool ); |
---|
933 | memcpy( pCtu->getMergeIndex() + m_absZIdxInCtu, m_puhMergeIndex, iSizeInUchar ); |
---|
934 | for (UInt ch=0; ch<numValidChan; ch++) |
---|
935 | { |
---|
936 | memcpy( pCtu->getIntraDir(ChannelType(ch)) + m_absZIdxInCtu, m_puhIntraDir[ch], iSizeInUchar); |
---|
937 | } |
---|
938 | |
---|
939 | memcpy( pCtu->getInterDir() + m_absZIdxInCtu, m_puhInterDir, iSizeInUchar ); |
---|
940 | memcpy( pCtu->getTransformIdx() + m_absZIdxInCtu, m_puhTrIdx, iSizeInUchar ); |
---|
941 | |
---|
942 | for(UInt comp=0; comp<numValidComp; comp++) |
---|
943 | { |
---|
944 | memcpy( pCtu->getCrossComponentPredictionAlpha(ComponentID(comp)) + m_absZIdxInCtu, m_crossComponentPredictionAlpha[comp], iSizeInUchar ); |
---|
945 | memcpy( pCtu->getTransformSkip(ComponentID(comp)) + m_absZIdxInCtu, m_puhTransformSkip[comp], iSizeInUchar ); |
---|
946 | memcpy( pCtu->getCbf(ComponentID(comp)) + m_absZIdxInCtu, m_puhCbf[comp], iSizeInUchar ); |
---|
947 | memcpy( pCtu->getExplicitRdpcmMode(ComponentID(comp)) + m_absZIdxInCtu, m_explicitRdpcmMode[comp], iSizeInUchar ); |
---|
948 | } |
---|
949 | |
---|
950 | memcpy( pCtu->getDepth() + m_absZIdxInCtu, m_puhDepth, iSizeInUchar ); |
---|
951 | memcpy( pCtu->getWidth() + m_absZIdxInCtu, m_puhWidth, iSizeInUchar ); |
---|
952 | memcpy( pCtu->getHeight() + m_absZIdxInCtu, m_puhHeight, iSizeInUchar ); |
---|
953 | |
---|
954 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
955 | { |
---|
956 | const RefPicList rpl=RefPicList(i); |
---|
957 | memcpy( pCtu->getMVPIdx(rpl) + m_absZIdxInCtu, m_apiMVPIdx[rpl], iSizeInUchar ); |
---|
958 | memcpy( pCtu->getMVPNum(rpl) + m_absZIdxInCtu, m_apiMVPNum[rpl], iSizeInUchar ); |
---|
959 | } |
---|
960 | |
---|
961 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
962 | { |
---|
963 | const RefPicList rpl=RefPicList(i); |
---|
964 | m_acCUMvField[rpl].copyTo( pCtu->getCUMvField( rpl ), m_absZIdxInCtu ); |
---|
965 | } |
---|
966 | |
---|
967 | memcpy( pCtu->getIPCMFlag() + m_absZIdxInCtu, m_pbIPCMFlag, iSizeInBool ); |
---|
968 | |
---|
969 | const UInt numCoeffY = (pCtu->getSlice()->getSPS()->getMaxCUWidth()*pCtu->getSlice()->getSPS()->getMaxCUHeight())>>(uhDepth<<1); |
---|
970 | const UInt offsetY = m_absZIdxInCtu*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
971 | for (UInt comp=0; comp<numValidComp; comp++) |
---|
972 | { |
---|
973 | const ComponentID component = ComponentID(comp); |
---|
974 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
975 | memcpy( pCtu->getCoeff(component) + (offsetY>>componentShift), m_pcTrCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
976 | #if ADAPTIVE_QP_SELECTION |
---|
977 | memcpy( pCtu->getArlCoeff(component) + (offsetY>>componentShift), m_pcArlCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
978 | #endif |
---|
979 | memcpy( pCtu->getPCMSample(component) + (offsetY>>componentShift), m_pcIPCMSample[component], sizeof(Pel)*(numCoeffY>>componentShift) ); |
---|
980 | } |
---|
981 | |
---|
982 | pCtu->getTotalBins() = m_uiTotalBins; |
---|
983 | } |
---|
984 | |
---|
985 | // -------------------------------------------------------------------------------------------------------------------- |
---|
986 | // Other public functions |
---|
987 | // -------------------------------------------------------------------------------------------------------------------- |
---|
988 | |
---|
989 | const TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, |
---|
990 | UInt uiCurrPartUnitIdx, |
---|
991 | Bool bEnforceSliceRestriction, |
---|
992 | Bool bEnforceTileRestriction ) const |
---|
993 | { |
---|
994 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
995 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
996 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
997 | |
---|
998 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
999 | { |
---|
1000 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1001 | if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1002 | { |
---|
1003 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1004 | } |
---|
1005 | else |
---|
1006 | { |
---|
1007 | uiLPartUnitIdx -= m_absZIdxInCtu; |
---|
1008 | return this; |
---|
1009 | } |
---|
1010 | } |
---|
1011 | |
---|
1012 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth - 1 ]; |
---|
1013 | if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuLeft)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuLeft)) ) |
---|
1014 | { |
---|
1015 | return NULL; |
---|
1016 | } |
---|
1017 | return m_pCtuLeft; |
---|
1018 | } |
---|
1019 | |
---|
1020 | |
---|
1021 | const TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, |
---|
1022 | UInt uiCurrPartUnitIdx, |
---|
1023 | Bool bEnforceSliceRestriction, |
---|
1024 | Bool planarAtCtuBoundary, |
---|
1025 | Bool bEnforceTileRestriction ) const |
---|
1026 | { |
---|
1027 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1028 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
1029 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1030 | |
---|
1031 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1032 | { |
---|
1033 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth ]; |
---|
1034 | if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1035 | { |
---|
1036 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1037 | } |
---|
1038 | else |
---|
1039 | { |
---|
1040 | uiAPartUnitIdx -= m_absZIdxInCtu; |
---|
1041 | return this; |
---|
1042 | } |
---|
1043 | } |
---|
1044 | |
---|
1045 | if(planarAtCtuBoundary) |
---|
1046 | { |
---|
1047 | return NULL; |
---|
1048 | } |
---|
1049 | |
---|
1050 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth ]; |
---|
1051 | |
---|
1052 | if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuAbove)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuAbove)) ) |
---|
1053 | { |
---|
1054 | return NULL; |
---|
1055 | } |
---|
1056 | return m_pCtuAbove; |
---|
1057 | } |
---|
1058 | |
---|
1059 | const TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) const |
---|
1060 | { |
---|
1061 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1062 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
1063 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1064 | |
---|
1065 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1066 | { |
---|
1067 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1068 | { |
---|
1069 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth - 1 ]; |
---|
1070 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1071 | { |
---|
1072 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1073 | } |
---|
1074 | else |
---|
1075 | { |
---|
1076 | uiALPartUnitIdx -= m_absZIdxInCtu; |
---|
1077 | return this; |
---|
1078 | } |
---|
1079 | } |
---|
1080 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartitionsInCtu() - numPartInCtuWidth - 1 ]; |
---|
1081 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) |
---|
1082 | { |
---|
1083 | return NULL; |
---|
1084 | } |
---|
1085 | return m_pCtuAbove; |
---|
1086 | } |
---|
1087 | |
---|
1088 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1089 | { |
---|
1090 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1091 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) |
---|
1092 | { |
---|
1093 | return NULL; |
---|
1094 | } |
---|
1095 | return m_pCtuLeft; |
---|
1096 | } |
---|
1097 | |
---|
1098 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - 1 ]; |
---|
1099 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveLeft) ) |
---|
1100 | { |
---|
1101 | return NULL; |
---|
1102 | } |
---|
1103 | return m_pCtuAboveLeft; |
---|
1104 | } |
---|
1105 | |
---|
1106 | const TComDataCU* TComDataCU::getPUBelowLeft(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) const |
---|
1107 | { |
---|
1108 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1109 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1110 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_absZIdxInCtu ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*numPartInCtuWidth; |
---|
1111 | |
---|
1112 | if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) |
---|
1113 | { |
---|
1114 | uiBLPartUnitIdx = MAX_UINT; |
---|
1115 | return NULL; |
---|
1116 | } |
---|
1117 | |
---|
1118 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInCtuHeight() - uiPartUnitOffset, numPartInCtuWidth ) ) |
---|
1119 | { |
---|
1120 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, numPartInCtuWidth ) ) |
---|
1121 | { |
---|
1122 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ] ) |
---|
1123 | { |
---|
1124 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ]; |
---|
1125 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, numPartInCtuWidth ) ) |
---|
1126 | { |
---|
1127 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1128 | } |
---|
1129 | else |
---|
1130 | { |
---|
1131 | uiBLPartUnitIdx -= m_absZIdxInCtu; |
---|
1132 | return this; |
---|
1133 | } |
---|
1134 | } |
---|
1135 | uiBLPartUnitIdx = MAX_UINT; |
---|
1136 | return NULL; |
---|
1137 | } |
---|
1138 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * numPartInCtuWidth - 1 ]; |
---|
1139 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) |
---|
1140 | { |
---|
1141 | return NULL; |
---|
1142 | } |
---|
1143 | return m_pCtuLeft; |
---|
1144 | } |
---|
1145 | |
---|
1146 | uiBLPartUnitIdx = MAX_UINT; |
---|
1147 | return NULL; |
---|
1148 | } |
---|
1149 | |
---|
1150 | const TComDataCU* TComDataCU::getPUAboveRight(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) const |
---|
1151 | { |
---|
1152 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1153 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_absZIdxInCtu ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
---|
1154 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1155 | |
---|
1156 | if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
1157 | { |
---|
1158 | uiARPartUnitIdx = MAX_UINT; |
---|
1159 | return NULL; |
---|
1160 | } |
---|
1161 | |
---|
1162 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, numPartInCtuWidth - uiPartUnitOffset, numPartInCtuWidth ) ) |
---|
1163 | { |
---|
1164 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) |
---|
1165 | { |
---|
1166 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ] ) |
---|
1167 | { |
---|
1168 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ]; |
---|
1169 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1170 | { |
---|
1171 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1172 | } |
---|
1173 | else |
---|
1174 | { |
---|
1175 | uiARPartUnitIdx -= m_absZIdxInCtu; |
---|
1176 | return this; |
---|
1177 | } |
---|
1178 | } |
---|
1179 | uiARPartUnitIdx = MAX_UINT; |
---|
1180 | return NULL; |
---|
1181 | } |
---|
1182 | |
---|
1183 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset ]; |
---|
1184 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) |
---|
1185 | { |
---|
1186 | return NULL; |
---|
1187 | } |
---|
1188 | return m_pCtuAbove; |
---|
1189 | } |
---|
1190 | |
---|
1191 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) |
---|
1192 | { |
---|
1193 | uiARPartUnitIdx = MAX_UINT; |
---|
1194 | return NULL; |
---|
1195 | } |
---|
1196 | |
---|
1197 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset-1 ]; |
---|
1198 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveRight) ) |
---|
1199 | { |
---|
1200 | return NULL; |
---|
1201 | } |
---|
1202 | return m_pCtuAboveRight; |
---|
1203 | } |
---|
1204 | |
---|
1205 | /** Get left QpMinCu |
---|
1206 | *\param uiLPartUnitIdx |
---|
1207 | *\param uiCurrAbsIdxInCtu |
---|
1208 | *\returns TComDataCU* point of TComDataCU of left QpMinCu |
---|
1209 | */ |
---|
1210 | const TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu ) const |
---|
1211 | { |
---|
1212 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1213 | const UInt maxCUDepth = getSlice()->getSPS()->getMaxTotalCUDepth(); |
---|
1214 | const UInt maxCuDQPDepth = getSlice()->getPPS()->getMaxCuDQPDepth(); |
---|
1215 | const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); |
---|
1216 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>doubleDepthDifference)<<doubleDepthDifference; |
---|
1217 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
1218 | |
---|
1219 | // check for left CTU boundary |
---|
1220 | if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCtuWidth) ) |
---|
1221 | { |
---|
1222 | return NULL; |
---|
1223 | } |
---|
1224 | |
---|
1225 | // get index of left-CU relative to top-left corner of current quantization group |
---|
1226 | uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; |
---|
1227 | |
---|
1228 | // return pointer to current CTU |
---|
1229 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1230 | } |
---|
1231 | |
---|
1232 | /** Get Above QpMinCu |
---|
1233 | *\param uiAPartUnitIdx |
---|
1234 | *\param uiCurrAbsIdxInCtu |
---|
1235 | *\returns TComDataCU* point of TComDataCU of above QpMinCu |
---|
1236 | */ |
---|
1237 | const TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu ) const |
---|
1238 | { |
---|
1239 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1240 | const UInt maxCUDepth = getSlice()->getSPS()->getMaxTotalCUDepth(); |
---|
1241 | const UInt maxCuDQPDepth = getSlice()->getPPS()->getMaxCuDQPDepth(); |
---|
1242 | const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); |
---|
1243 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>doubleDepthDifference)<<doubleDepthDifference; |
---|
1244 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
1245 | |
---|
1246 | // check for top CTU boundary |
---|
1247 | if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCtuWidth) ) |
---|
1248 | { |
---|
1249 | return NULL; |
---|
1250 | } |
---|
1251 | |
---|
1252 | // get index of top-CU relative to top-left corner of current quantization group |
---|
1253 | uiAPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCtuWidth]; |
---|
1254 | |
---|
1255 | // return pointer to current CTU |
---|
1256 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1257 | } |
---|
1258 | |
---|
1259 | |
---|
1260 | |
---|
1261 | /** Get reference QP from left QpMinCu or latest coded QP |
---|
1262 | *\param uiCurrAbsIdxInCtu |
---|
1263 | *\returns SChar reference QP value |
---|
1264 | */ |
---|
1265 | SChar TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu ) const |
---|
1266 | { |
---|
1267 | UInt lPartIdx = MAX_UINT; |
---|
1268 | UInt aPartIdx = MAX_UINT; |
---|
1269 | const TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); |
---|
1270 | const TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); |
---|
1271 | return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + 1) >> 1); |
---|
1272 | } |
---|
1273 | |
---|
1274 | Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) const |
---|
1275 | { |
---|
1276 | Int iLastValidPartIdx = iAbsPartIdx-1; |
---|
1277 | while ( iLastValidPartIdx >= 0 |
---|
1278 | && getPredictionMode( iLastValidPartIdx ) == NUMBER_OF_PREDICTION_MODES ) |
---|
1279 | { |
---|
1280 | UInt uiDepth = getDepth( iLastValidPartIdx ); |
---|
1281 | iLastValidPartIdx -= m_uiNumPartition>>(uiDepth<<1); |
---|
1282 | } |
---|
1283 | return iLastValidPartIdx; |
---|
1284 | } |
---|
1285 | |
---|
1286 | SChar TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) const |
---|
1287 | { |
---|
1288 | UInt uiQUPartIdxMask = ~((1<<((getSlice()->getSPS()->getMaxTotalCUDepth() - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); |
---|
1289 | Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); // A idx will be invalid if it is off the right or bottom edge of the picture. |
---|
1290 | // If this CU is in the first CTU of the slice and there is no valid part before this one, use slice QP |
---|
1291 | if ( getPic()->getPicSym()->getCtuTsToRsAddrMap(getSlice()->getSliceCurStartCtuTsAddr()) == getCtuRsAddr() && Int(getZorderIdxInCtu())+iLastValidPartIdx<0) |
---|
1292 | { |
---|
1293 | return getSlice()->getSliceQp(); |
---|
1294 | } |
---|
1295 | else if ( iLastValidPartIdx >= 0 ) |
---|
1296 | { |
---|
1297 | // If there is a valid part within the current Sub-CU, use it |
---|
1298 | return getQP( iLastValidPartIdx ); |
---|
1299 | } |
---|
1300 | else |
---|
1301 | { |
---|
1302 | if ( getZorderIdxInCtu() > 0 ) |
---|
1303 | { |
---|
1304 | // If this wasn't the first sub-cu within the Ctu, explore the CTU itself. |
---|
1305 | return getPic()->getCtu( getCtuRsAddr() )->getLastCodedQP( getZorderIdxInCtu() ); // TODO - remove this recursion |
---|
1306 | } |
---|
1307 | else if ( getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr()) > 0 |
---|
1308 | && CUIsFromSameSliceTileAndWavefrontRow(getPic()->getCtu(getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1))) ) |
---|
1309 | { |
---|
1310 | // If this isn't the first Ctu (how can it be due to the first 'if'?), and the previous Ctu is from the same tile, examine the previous Ctu. |
---|
1311 | return getPic()->getCtu( getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1) )->getLastCodedQP( getPic()->getNumPartitionsInCtu() ); // TODO - remove this recursion |
---|
1312 | } |
---|
1313 | else |
---|
1314 | { |
---|
1315 | // No other options available - use the slice-level QP. |
---|
1316 | return getSlice()->getSliceQp(); |
---|
1317 | } |
---|
1318 | } |
---|
1319 | } |
---|
1320 | |
---|
1321 | |
---|
1322 | /** Check whether the CU is coded in lossless coding mode. |
---|
1323 | * \param absPartIdx |
---|
1324 | * \returns true if the CU is coded in lossless coding mode; false if otherwise |
---|
1325 | */ |
---|
1326 | Bool TComDataCU::isLosslessCoded(UInt absPartIdx) const |
---|
1327 | { |
---|
1328 | return (getSlice()->getPPS()->getTransquantBypassEnabledFlag() && getCUTransquantBypass (absPartIdx)); |
---|
1329 | } |
---|
1330 | |
---|
1331 | |
---|
1332 | /** Get allowed chroma intra modes |
---|
1333 | * - fills uiModeList with chroma intra modes |
---|
1334 | * |
---|
1335 | *\param [in] uiAbsPartIdx |
---|
1336 | *\param [out] uiModeList pointer to chroma intra modes array |
---|
1337 | */ |
---|
1338 | Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] ) const |
---|
1339 | { |
---|
1340 | uiModeList[0] = PLANAR_IDX; |
---|
1341 | uiModeList[1] = VER_IDX; |
---|
1342 | uiModeList[2] = HOR_IDX; |
---|
1343 | uiModeList[3] = DC_IDX; |
---|
1344 | uiModeList[4] = DM_CHROMA_IDX; |
---|
1345 | assert(4<NUM_CHROMA_MODE); |
---|
1346 | |
---|
1347 | UInt uiLumaMode = getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ); |
---|
1348 | |
---|
1349 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
---|
1350 | { |
---|
1351 | if( uiLumaMode == uiModeList[i] ) |
---|
1352 | { |
---|
1353 | uiModeList[i] = 34; // VER+8 mode |
---|
1354 | break; |
---|
1355 | } |
---|
1356 | } |
---|
1357 | } |
---|
1358 | |
---|
1359 | /** Get most probable intra modes |
---|
1360 | *\param uiAbsPartIdx partition index |
---|
1361 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
1362 | *\param compID colour component ID |
---|
1363 | *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. |
---|
1364 | *\returns Number of MPM |
---|
1365 | */ |
---|
1366 | Void TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode ) const |
---|
1367 | { |
---|
1368 | UInt LeftPartIdx = MAX_UINT; |
---|
1369 | UInt AbovePartIdx = MAX_UINT; |
---|
1370 | Int iLeftIntraDir, iAboveIntraDir; |
---|
1371 | const TComSPS *sps=getSlice()->getSPS(); |
---|
1372 | const UInt partsPerMinCU = 1<<(2*(sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize())); |
---|
1373 | |
---|
1374 | const ChannelType chType = toChannelType(compID); |
---|
1375 | const ChromaFormat chForm = getPic()->getChromaFormat(); |
---|
1376 | // Get intra direction of left PU |
---|
1377 | const TComDataCU *pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
1378 | |
---|
1379 | if (isChroma(compID)) |
---|
1380 | { |
---|
1381 | LeftPartIdx = getChromasCorrespondingPULumaIdx(LeftPartIdx, chForm, partsPerMinCU); |
---|
1382 | } |
---|
1383 | iLeftIntraDir = pcCULeft ? ( pcCULeft->isIntra( LeftPartIdx ) ? pcCULeft->getIntraDir( chType, LeftPartIdx ) : DC_IDX ) : DC_IDX; |
---|
1384 | |
---|
1385 | // Get intra direction of above PU |
---|
1386 | const TComDataCU *pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true ); |
---|
1387 | |
---|
1388 | if (isChroma(compID)) |
---|
1389 | { |
---|
1390 | AbovePartIdx = getChromasCorrespondingPULumaIdx(AbovePartIdx, chForm, partsPerMinCU); |
---|
1391 | } |
---|
1392 | iAboveIntraDir = pcCUAbove ? ( pcCUAbove->isIntra( AbovePartIdx ) ? pcCUAbove->getIntraDir( chType, AbovePartIdx ) : DC_IDX ) : DC_IDX; |
---|
1393 | |
---|
1394 | if (isChroma(chType)) |
---|
1395 | { |
---|
1396 | if (iLeftIntraDir == DM_CHROMA_IDX) |
---|
1397 | { |
---|
1398 | iLeftIntraDir = pcCULeft-> getIntraDir( CHANNEL_TYPE_LUMA, LeftPartIdx ); |
---|
1399 | } |
---|
1400 | if (iAboveIntraDir == DM_CHROMA_IDX) |
---|
1401 | { |
---|
1402 | iAboveIntraDir = pcCUAbove->getIntraDir( CHANNEL_TYPE_LUMA, AbovePartIdx ); |
---|
1403 | } |
---|
1404 | } |
---|
1405 | |
---|
1406 | assert (2<NUM_MOST_PROBABLE_MODES); |
---|
1407 | if(iLeftIntraDir == iAboveIntraDir) |
---|
1408 | { |
---|
1409 | if( piMode ) |
---|
1410 | { |
---|
1411 | *piMode = 1; |
---|
1412 | } |
---|
1413 | |
---|
1414 | if (iLeftIntraDir > 1) // angular modes |
---|
1415 | { |
---|
1416 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
1417 | uiIntraDirPred[1] = ((iLeftIntraDir + 29) % 32) + 2; |
---|
1418 | uiIntraDirPred[2] = ((iLeftIntraDir - 1 ) % 32) + 2; |
---|
1419 | } |
---|
1420 | else //non-angular |
---|
1421 | { |
---|
1422 | uiIntraDirPred[0] = PLANAR_IDX; |
---|
1423 | uiIntraDirPred[1] = DC_IDX; |
---|
1424 | uiIntraDirPred[2] = VER_IDX; |
---|
1425 | } |
---|
1426 | } |
---|
1427 | else |
---|
1428 | { |
---|
1429 | if( piMode ) |
---|
1430 | { |
---|
1431 | *piMode = 2; |
---|
1432 | } |
---|
1433 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
1434 | uiIntraDirPred[1] = iAboveIntraDir; |
---|
1435 | |
---|
1436 | if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar |
---|
1437 | { |
---|
1438 | uiIntraDirPred[2] = PLANAR_IDX; |
---|
1439 | } |
---|
1440 | else |
---|
1441 | { |
---|
1442 | uiIntraDirPred[2] = (iLeftIntraDir+iAboveIntraDir)<2? VER_IDX : DC_IDX; |
---|
1443 | } |
---|
1444 | } |
---|
1445 | for (UInt i=0; i<NUM_MOST_PROBABLE_MODES; i++) |
---|
1446 | { |
---|
1447 | assert(uiIntraDirPred[i] < 35); |
---|
1448 | } |
---|
1449 | } |
---|
1450 | |
---|
1451 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) const |
---|
1452 | { |
---|
1453 | const TComDataCU* pcTempCU; |
---|
1454 | UInt uiTempPartIdx; |
---|
1455 | UInt uiCtx; |
---|
1456 | // Get left split flag |
---|
1457 | pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
1458 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
1459 | |
---|
1460 | // Get above split flag |
---|
1461 | pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
1462 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
1463 | |
---|
1464 | return uiCtx; |
---|
1465 | } |
---|
1466 | |
---|
1467 | UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType ) const |
---|
1468 | { |
---|
1469 | const UInt transformDepth = rTu.GetTransformDepthRel(); |
---|
1470 | |
---|
1471 | if (isChroma(chType)) |
---|
1472 | { |
---|
1473 | return transformDepth; |
---|
1474 | } |
---|
1475 | else |
---|
1476 | { |
---|
1477 | const UInt uiCtx = ( transformDepth == 0 ? 1 : 0 ); |
---|
1478 | return uiCtx; |
---|
1479 | } |
---|
1480 | } |
---|
1481 | |
---|
1482 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) const |
---|
1483 | { |
---|
1484 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
---|
1485 | PartSize partSize = getPartitionSize( absPartIdx ); |
---|
1486 | UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
1487 | Int intraSplitFlag = ( isIntra( absPartIdx ) && partSize == SIZE_NxN ) ? 1 : 0; |
---|
1488 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && isInter( absPartIdx ) && (partSize != SIZE_2Nx2N) ); |
---|
1489 | |
---|
1490 | UInt log2MinTUSizeInCU = 0; |
---|
1491 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
---|
1492 | { |
---|
1493 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
---|
1494 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
1495 | } |
---|
1496 | else |
---|
1497 | { |
---|
1498 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
---|
1499 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
---|
1500 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
1501 | { |
---|
1502 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
---|
1503 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
1504 | } |
---|
1505 | } |
---|
1506 | return log2MinTUSizeInCU; |
---|
1507 | } |
---|
1508 | |
---|
1509 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) const |
---|
1510 | { |
---|
1511 | const TComDataCU* pcTempCU; |
---|
1512 | UInt uiTempPartIdx; |
---|
1513 | UInt uiCtx = 0; |
---|
1514 | |
---|
1515 | // Get BCBP of left PU |
---|
1516 | pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
1517 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
1518 | |
---|
1519 | // Get BCBP of above PU |
---|
1520 | pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
1521 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
1522 | |
---|
1523 | return uiCtx; |
---|
1524 | } |
---|
1525 | |
---|
1526 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) const |
---|
1527 | { |
---|
1528 | return getDepth( uiAbsPartIdx ); |
---|
1529 | } |
---|
1530 | |
---|
1531 | |
---|
1532 | UChar TComDataCU::getQtRootCbf( UInt uiIdx ) const |
---|
1533 | { |
---|
1534 | const UInt numberValidComponents = getPic()->getNumberValidComponents(); |
---|
1535 | return getCbf( uiIdx, COMPONENT_Y, 0 ) |
---|
1536 | || ((numberValidComponents > COMPONENT_Cb) && getCbf( uiIdx, COMPONENT_Cb, 0 )) |
---|
1537 | || ((numberValidComponents > COMPONENT_Cr) && getCbf( uiIdx, COMPONENT_Cr, 0 )); |
---|
1538 | } |
---|
1539 | |
---|
1540 | Void TComDataCU::setCbfSubParts( const UInt uiCbf[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1541 | { |
---|
1542 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
1543 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
1544 | { |
---|
1545 | memset( m_puhCbf[comp] + uiAbsPartIdx, uiCbf[comp], sizeof( UChar ) * uiCurrPartNumb ); |
---|
1546 | } |
---|
1547 | } |
---|
1548 | |
---|
1549 | Void TComDataCU::setCbfSubParts( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1550 | { |
---|
1551 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
1552 | memset( m_puhCbf[compID] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
1553 | } |
---|
1554 | |
---|
1555 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
1556 | * \param uiCbf The value of the coded block flag to be set |
---|
1557 | * \param compID |
---|
1558 | * \param uiAbsPartIdx |
---|
1559 | * \param uiPartIdx |
---|
1560 | * \param uiDepth |
---|
1561 | */ |
---|
1562 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
1563 | { |
---|
1564 | setSubPart<UChar>( uiCbf, m_puhCbf[compID], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1565 | } |
---|
1566 | |
---|
1567 | Void TComDataCU::setCbfPartRange ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
1568 | { |
---|
1569 | memset((m_puhCbf[compID] + uiAbsPartIdx), uiCbf, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
1570 | } |
---|
1571 | |
---|
1572 | Void TComDataCU::bitwiseOrCbfPartRange( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
1573 | { |
---|
1574 | const UInt stopAbsPartIdx = uiAbsPartIdx + uiCoveredPartIdxes; |
---|
1575 | |
---|
1576 | for (UInt subPartIdx = uiAbsPartIdx; subPartIdx < stopAbsPartIdx; subPartIdx++) |
---|
1577 | { |
---|
1578 | m_puhCbf[compID][subPartIdx] |= uiCbf; |
---|
1579 | } |
---|
1580 | } |
---|
1581 | |
---|
1582 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
1583 | { |
---|
1584 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
1585 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
1586 | } |
---|
1587 | |
---|
1588 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) const |
---|
1589 | { |
---|
1590 | UInt uiPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
1591 | return (((m_absZIdxInCtu + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
1592 | } |
---|
1593 | |
---|
1594 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1595 | { |
---|
1596 | assert( sizeof( *m_pePartSize) == 1 ); |
---|
1597 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
1598 | } |
---|
1599 | |
---|
1600 | Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1601 | { |
---|
1602 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
1603 | } |
---|
1604 | |
---|
1605 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
---|
1606 | { |
---|
1607 | assert( sizeof( *m_skipFlag) == 1 ); |
---|
1608 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); |
---|
1609 | } |
---|
1610 | |
---|
1611 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1612 | { |
---|
1613 | assert( sizeof( *m_pePredMode) == 1 ); |
---|
1614 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
1615 | } |
---|
1616 | |
---|
1617 | Void TComDataCU::setChromaQpAdjSubParts( UChar val, Int absPartIdx, Int depth ) |
---|
1618 | { |
---|
1619 | assert( sizeof(*m_ChromaQpAdj) == 1 ); |
---|
1620 | memset( m_ChromaQpAdj + absPartIdx, val, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); |
---|
1621 | } |
---|
1622 | |
---|
1623 | Void TComDataCU::setQPSubCUs( Int qp, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
---|
1624 | { |
---|
1625 | UInt currPartNumb = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); |
---|
1626 | UInt currPartNumQ = currPartNumb >> 2; |
---|
1627 | const UInt numValidComp = m_pcPic->getNumberValidComponents(); |
---|
1628 | |
---|
1629 | if(!foundNonZeroCbf) |
---|
1630 | { |
---|
1631 | if(getDepth(absPartIdx) > depth) |
---|
1632 | { |
---|
1633 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
---|
1634 | { |
---|
1635 | setQPSubCUs( qp, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
---|
1636 | } |
---|
1637 | } |
---|
1638 | else |
---|
1639 | { |
---|
1640 | if(getCbf( absPartIdx, COMPONENT_Y ) || (numValidComp>COMPONENT_Cb && getCbf( absPartIdx, COMPONENT_Cb )) || (numValidComp>COMPONENT_Cr && getCbf( absPartIdx, COMPONENT_Cr) ) ) |
---|
1641 | { |
---|
1642 | foundNonZeroCbf = true; |
---|
1643 | } |
---|
1644 | else |
---|
1645 | { |
---|
1646 | setQPSubParts(qp, absPartIdx, depth); |
---|
1647 | } |
---|
1648 | } |
---|
1649 | } |
---|
1650 | } |
---|
1651 | |
---|
1652 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1653 | { |
---|
1654 | const UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
1655 | memset(m_phQP+uiAbsPartIdx, qp, numPart); |
---|
1656 | } |
---|
1657 | |
---|
1658 | Void TComDataCU::setIntraDirSubParts( const ChannelType channelType, const UInt dir, const UInt absPartIdx, const UInt depth ) |
---|
1659 | { |
---|
1660 | UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); |
---|
1661 | memset( m_puhIntraDir[channelType] + absPartIdx, dir,sizeof(UChar)*numPart ); |
---|
1662 | } |
---|
1663 | |
---|
1664 | template<typename T> |
---|
1665 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
1666 | { |
---|
1667 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
---|
1668 | |
---|
1669 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2; |
---|
1670 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
1671 | { |
---|
1672 | case SIZE_2Nx2N: |
---|
1673 | memset( puhBaseCtu + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
---|
1674 | break; |
---|
1675 | case SIZE_2NxN: |
---|
1676 | memset( puhBaseCtu + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
---|
1677 | break; |
---|
1678 | case SIZE_Nx2N: |
---|
1679 | memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
1680 | memset( puhBaseCtu + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
---|
1681 | break; |
---|
1682 | case SIZE_NxN: |
---|
1683 | memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
1684 | break; |
---|
1685 | case SIZE_2NxnU: |
---|
1686 | if ( uiPUIdx == 0 ) |
---|
1687 | { |
---|
1688 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1689 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1690 | } |
---|
1691 | else if ( uiPUIdx == 1 ) |
---|
1692 | { |
---|
1693 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1694 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
---|
1695 | } |
---|
1696 | else |
---|
1697 | { |
---|
1698 | assert(0); |
---|
1699 | } |
---|
1700 | break; |
---|
1701 | case SIZE_2NxnD: |
---|
1702 | if ( uiPUIdx == 0 ) |
---|
1703 | { |
---|
1704 | memset( puhBaseCtu + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
---|
1705 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1706 | } |
---|
1707 | else if ( uiPUIdx == 1 ) |
---|
1708 | { |
---|
1709 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1710 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
1711 | } |
---|
1712 | else |
---|
1713 | { |
---|
1714 | assert(0); |
---|
1715 | } |
---|
1716 | break; |
---|
1717 | case SIZE_nLx2N: |
---|
1718 | if ( uiPUIdx == 0 ) |
---|
1719 | { |
---|
1720 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1721 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1722 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1723 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1724 | } |
---|
1725 | else if ( uiPUIdx == 1 ) |
---|
1726 | { |
---|
1727 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1728 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
1729 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1730 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
1731 | } |
---|
1732 | else |
---|
1733 | { |
---|
1734 | assert(0); |
---|
1735 | } |
---|
1736 | break; |
---|
1737 | case SIZE_nRx2N: |
---|
1738 | if ( uiPUIdx == 0 ) |
---|
1739 | { |
---|
1740 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
1741 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1742 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
1743 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1744 | } |
---|
1745 | else if ( uiPUIdx == 1 ) |
---|
1746 | { |
---|
1747 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1748 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1749 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1750 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
1751 | } |
---|
1752 | else |
---|
1753 | { |
---|
1754 | assert(0); |
---|
1755 | } |
---|
1756 | break; |
---|
1757 | default: |
---|
1758 | assert( 0 ); |
---|
1759 | break; |
---|
1760 | } |
---|
1761 | } |
---|
1762 | |
---|
1763 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
1764 | { |
---|
1765 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1766 | } |
---|
1767 | |
---|
1768 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
1769 | { |
---|
1770 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1771 | } |
---|
1772 | |
---|
1773 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
1774 | { |
---|
1775 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1776 | } |
---|
1777 | |
---|
1778 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
1779 | { |
---|
1780 | setSubPart<SChar>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1781 | } |
---|
1782 | |
---|
1783 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
1784 | { |
---|
1785 | setSubPart<SChar>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1786 | } |
---|
1787 | |
---|
1788 | |
---|
1789 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1790 | { |
---|
1791 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
1792 | |
---|
1793 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
1794 | } |
---|
1795 | |
---|
1796 | Void TComDataCU::setTransformSkipSubParts( const UInt useTransformSkip[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1797 | { |
---|
1798 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
1799 | |
---|
1800 | for(UInt i=0; i<MAX_NUM_COMPONENT; i++) |
---|
1801 | { |
---|
1802 | memset( m_puhTransformSkip[i] + uiAbsPartIdx, useTransformSkip[i], sizeof( UChar ) * uiCurrPartNumb ); |
---|
1803 | } |
---|
1804 | } |
---|
1805 | |
---|
1806 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth) |
---|
1807 | { |
---|
1808 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
1809 | |
---|
1810 | memset( m_puhTransformSkip[compID] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
---|
1811 | } |
---|
1812 | |
---|
1813 | Void TComDataCU::setTransformSkipPartRange ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
1814 | { |
---|
1815 | memset((m_puhTransformSkip[compID] + uiAbsPartIdx), useTransformSkip, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
1816 | } |
---|
1817 | |
---|
1818 | Void TComDataCU::setCrossComponentPredictionAlphaPartRange( SChar alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
1819 | { |
---|
1820 | memset((m_crossComponentPredictionAlpha[compID] + uiAbsPartIdx), alphaValue, (sizeof(SChar) * uiCoveredPartIdxes)); |
---|
1821 | } |
---|
1822 | |
---|
1823 | Void TComDataCU::setExplicitRdpcmModePartRange ( UInt rdpcmMode, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
1824 | { |
---|
1825 | memset((m_explicitRdpcmMode[compID] + uiAbsPartIdx), rdpcmMode, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
1826 | } |
---|
1827 | |
---|
1828 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1829 | { |
---|
1830 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
1831 | |
---|
1832 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
1833 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
1834 | } |
---|
1835 | |
---|
1836 | UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx) const |
---|
1837 | { |
---|
1838 | UChar iNumPart = 0; |
---|
1839 | |
---|
1840 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
1841 | { |
---|
1842 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
1843 | case SIZE_2NxN: iNumPart = 2; break; |
---|
1844 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
1845 | case SIZE_NxN: iNumPart = 4; break; |
---|
1846 | case SIZE_2NxnU: iNumPart = 2; break; |
---|
1847 | case SIZE_2NxnD: iNumPart = 2; break; |
---|
1848 | case SIZE_nLx2N: iNumPart = 2; break; |
---|
1849 | case SIZE_nRx2N: iNumPart = 2; break; |
---|
1850 | default: assert (0); break; |
---|
1851 | } |
---|
1852 | |
---|
1853 | return iNumPart; |
---|
1854 | } |
---|
1855 | |
---|
1856 | // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx |
---|
1857 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) const |
---|
1858 | { |
---|
1859 | switch ( m_pePartSize[0] ) |
---|
1860 | { |
---|
1861 | case SIZE_2NxN: |
---|
1862 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
1863 | break; |
---|
1864 | case SIZE_Nx2N: |
---|
1865 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
1866 | break; |
---|
1867 | case SIZE_NxN: |
---|
1868 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
1869 | break; |
---|
1870 | case SIZE_2NxnU: |
---|
1871 | riWidth = getWidth(0); |
---|
1872 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
1873 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
---|
1874 | break; |
---|
1875 | case SIZE_2NxnD: |
---|
1876 | riWidth = getWidth(0); |
---|
1877 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
1878 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
---|
1879 | break; |
---|
1880 | case SIZE_nLx2N: |
---|
1881 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
1882 | riHeight = getHeight(0); |
---|
1883 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
---|
1884 | break; |
---|
1885 | case SIZE_nRx2N: |
---|
1886 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
1887 | riHeight = getHeight(0); |
---|
1888 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
1889 | break; |
---|
1890 | default: |
---|
1891 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
1892 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
1893 | break; |
---|
1894 | } |
---|
1895 | } |
---|
1896 | |
---|
1897 | // static member function |
---|
1898 | Void TComDataCU::getMvField ( const TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
1899 | { |
---|
1900 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
1901 | { |
---|
1902 | TComMv cZeroMv; |
---|
1903 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
1904 | return; |
---|
1905 | } |
---|
1906 | |
---|
1907 | const TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
1908 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
1909 | } |
---|
1910 | |
---|
1911 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const |
---|
1912 | { |
---|
1913 | ruiPartIdxLT = m_absZIdxInCtu + uiAbsPartIdx; |
---|
1914 | UInt uiPUWidth = 0; |
---|
1915 | |
---|
1916 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
1917 | { |
---|
1918 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
1919 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
1920 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
1921 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
1922 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
1923 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
1924 | case SIZE_nLx2N: |
---|
1925 | if ( uiPartIdx == 0 ) |
---|
1926 | { |
---|
1927 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
1928 | } |
---|
1929 | else if ( uiPartIdx == 1 ) |
---|
1930 | { |
---|
1931 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
1932 | } |
---|
1933 | else |
---|
1934 | { |
---|
1935 | assert(0); |
---|
1936 | } |
---|
1937 | break; |
---|
1938 | case SIZE_nRx2N: |
---|
1939 | if ( uiPartIdx == 0 ) |
---|
1940 | { |
---|
1941 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
1942 | } |
---|
1943 | else if ( uiPartIdx == 1 ) |
---|
1944 | { |
---|
1945 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
1946 | } |
---|
1947 | else |
---|
1948 | { |
---|
1949 | assert(0); |
---|
1950 | } |
---|
1951 | break; |
---|
1952 | default: |
---|
1953 | assert (0); |
---|
1954 | break; |
---|
1955 | } |
---|
1956 | |
---|
1957 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
1958 | } |
---|
1959 | |
---|
1960 | Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) const |
---|
1961 | { |
---|
1962 | UInt uiPUHeight = 0; |
---|
1963 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
1964 | { |
---|
1965 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
1966 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
1967 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
1968 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
1969 | case SIZE_2NxnU: |
---|
1970 | if ( uiPartIdx == 0 ) |
---|
1971 | { |
---|
1972 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
1973 | } |
---|
1974 | else if ( uiPartIdx == 1 ) |
---|
1975 | { |
---|
1976 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
1977 | } |
---|
1978 | else |
---|
1979 | { |
---|
1980 | assert(0); |
---|
1981 | } |
---|
1982 | break; |
---|
1983 | case SIZE_2NxnD: |
---|
1984 | if ( uiPartIdx == 0 ) |
---|
1985 | { |
---|
1986 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
1987 | } |
---|
1988 | else if ( uiPartIdx == 1 ) |
---|
1989 | { |
---|
1990 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
1991 | } |
---|
1992 | else |
---|
1993 | { |
---|
1994 | assert(0); |
---|
1995 | } |
---|
1996 | break; |
---|
1997 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
1998 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
1999 | default: |
---|
2000 | assert (0); |
---|
2001 | break; |
---|
2002 | } |
---|
2003 | |
---|
2004 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInCtuWidth()]; |
---|
2005 | } |
---|
2006 | |
---|
2007 | Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const |
---|
2008 | { |
---|
2009 | ruiPartIdxLT = m_absZIdxInCtu; |
---|
2010 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2011 | |
---|
2012 | switch ( m_pePartSize[0] ) |
---|
2013 | { |
---|
2014 | case SIZE_2Nx2N: break; |
---|
2015 | case SIZE_2NxN: |
---|
2016 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2017 | break; |
---|
2018 | case SIZE_Nx2N: |
---|
2019 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
2020 | break; |
---|
2021 | case SIZE_NxN: |
---|
2022 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2023 | break; |
---|
2024 | case SIZE_2NxnU: |
---|
2025 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2026 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2027 | break; |
---|
2028 | case SIZE_2NxnD: |
---|
2029 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2030 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2031 | break; |
---|
2032 | case SIZE_nLx2N: |
---|
2033 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
---|
2034 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2035 | break; |
---|
2036 | case SIZE_nRx2N: |
---|
2037 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2038 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
---|
2039 | break; |
---|
2040 | default: |
---|
2041 | assert (0); |
---|
2042 | break; |
---|
2043 | } |
---|
2044 | |
---|
2045 | } |
---|
2046 | |
---|
2047 | Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) const |
---|
2048 | { |
---|
2049 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth()]; |
---|
2050 | |
---|
2051 | switch ( m_pePartSize[0] ) |
---|
2052 | { |
---|
2053 | case SIZE_2Nx2N: |
---|
2054 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
2055 | break; |
---|
2056 | case SIZE_2NxN: |
---|
2057 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2058 | break; |
---|
2059 | case SIZE_Nx2N: |
---|
2060 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
2061 | break; |
---|
2062 | case SIZE_NxN: |
---|
2063 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2064 | break; |
---|
2065 | case SIZE_2NxnU: |
---|
2066 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
2067 | break; |
---|
2068 | case SIZE_2NxnD: |
---|
2069 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
2070 | break; |
---|
2071 | case SIZE_nLx2N: |
---|
2072 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
---|
2073 | break; |
---|
2074 | case SIZE_nRx2N: |
---|
2075 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2076 | break; |
---|
2077 | default: |
---|
2078 | assert (0); |
---|
2079 | break; |
---|
2080 | } |
---|
2081 | } |
---|
2082 | |
---|
2083 | /** Derive the partition index of neighbouring bottom right block |
---|
2084 | * \param [in] uiPartIdx current partition index |
---|
2085 | * \param [out] ruiPartIdxRB partition index of neighbouring bottom right block |
---|
2086 | */ |
---|
2087 | Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt &ruiPartIdxRB ) const |
---|
2088 | { |
---|
2089 | ruiPartIdxRB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth() + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1]; |
---|
2090 | |
---|
2091 | switch ( m_pePartSize[0] ) |
---|
2092 | { |
---|
2093 | case SIZE_2Nx2N: |
---|
2094 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
2095 | break; |
---|
2096 | case SIZE_2NxN: |
---|
2097 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2098 | break; |
---|
2099 | case SIZE_Nx2N: |
---|
2100 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
2101 | break; |
---|
2102 | case SIZE_NxN: |
---|
2103 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2104 | break; |
---|
2105 | case SIZE_2NxnU: |
---|
2106 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
2107 | break; |
---|
2108 | case SIZE_2NxnD: |
---|
2109 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
2110 | break; |
---|
2111 | case SIZE_nLx2N: |
---|
2112 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
---|
2113 | break; |
---|
2114 | case SIZE_nRx2N: |
---|
2115 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
---|
2116 | break; |
---|
2117 | default: |
---|
2118 | assert (0); |
---|
2119 | break; |
---|
2120 | } |
---|
2121 | } |
---|
2122 | |
---|
2123 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, const TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) const |
---|
2124 | { |
---|
2125 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
2126 | { |
---|
2127 | return false; |
---|
2128 | } |
---|
2129 | |
---|
2130 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
2131 | { |
---|
2132 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
2133 | { |
---|
2134 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
2135 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
2136 | { |
---|
2137 | return false; |
---|
2138 | } |
---|
2139 | } |
---|
2140 | } |
---|
2141 | |
---|
2142 | return true; |
---|
2143 | } |
---|
2144 | |
---|
2145 | //! Construct a list of merging candidates |
---|
2146 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) const |
---|
2147 | { |
---|
2148 | UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx; |
---|
2149 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
2150 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
2151 | { |
---|
2152 | abCandIsInter[ui] = false; |
---|
2153 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
2154 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
2155 | } |
---|
2156 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
2157 | // compute the location of the current PU |
---|
2158 | Int xP, yP, nPSW, nPSH; |
---|
2159 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
2160 | |
---|
2161 | Int iCount = 0; |
---|
2162 | |
---|
2163 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
2164 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
2165 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
2166 | deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
2167 | |
---|
2168 | //left |
---|
2169 | UInt uiLeftPartIdx = 0; |
---|
2170 | const TComDataCU *pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
2171 | |
---|
2172 | Bool isAvailableA1 = pcCULeft && |
---|
2173 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
2174 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
2175 | pcCULeft->isInter( uiLeftPartIdx ) ; |
---|
2176 | |
---|
2177 | if ( isAvailableA1 ) |
---|
2178 | { |
---|
2179 | abCandIsInter[iCount] = true; |
---|
2180 | // get Inter Dir |
---|
2181 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
2182 | // get Mv from Left |
---|
2183 | TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2184 | if ( getSlice()->isInterB() ) |
---|
2185 | { |
---|
2186 | TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2187 | } |
---|
2188 | if ( mrgCandIdx == iCount ) |
---|
2189 | { |
---|
2190 | return; |
---|
2191 | } |
---|
2192 | iCount ++; |
---|
2193 | } |
---|
2194 | |
---|
2195 | // early termination |
---|
2196 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2197 | { |
---|
2198 | return; |
---|
2199 | } |
---|
2200 | // above |
---|
2201 | UInt uiAbovePartIdx = 0; |
---|
2202 | const TComDataCU *pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
2203 | |
---|
2204 | Bool isAvailableB1 = pcCUAbove && |
---|
2205 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
2206 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
2207 | pcCUAbove->isInter( uiAbovePartIdx ); |
---|
2208 | |
---|
2209 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
2210 | { |
---|
2211 | abCandIsInter[iCount] = true; |
---|
2212 | // get Inter Dir |
---|
2213 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
2214 | // get Mv from Left |
---|
2215 | TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2216 | if ( getSlice()->isInterB() ) |
---|
2217 | { |
---|
2218 | TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2219 | } |
---|
2220 | if ( mrgCandIdx == iCount ) |
---|
2221 | { |
---|
2222 | return; |
---|
2223 | } |
---|
2224 | iCount ++; |
---|
2225 | } |
---|
2226 | // early termination |
---|
2227 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2228 | { |
---|
2229 | return; |
---|
2230 | } |
---|
2231 | |
---|
2232 | // above right |
---|
2233 | UInt uiAboveRightPartIdx = 0; |
---|
2234 | const TComDataCU *pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
2235 | |
---|
2236 | Bool isAvailableB0 = pcCUAboveRight && |
---|
2237 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
2238 | pcCUAboveRight->isInter( uiAboveRightPartIdx ); |
---|
2239 | |
---|
2240 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
2241 | { |
---|
2242 | abCandIsInter[iCount] = true; |
---|
2243 | // get Inter Dir |
---|
2244 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
2245 | // get Mv from Left |
---|
2246 | TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2247 | if ( getSlice()->isInterB() ) |
---|
2248 | { |
---|
2249 | TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2250 | } |
---|
2251 | if ( mrgCandIdx == iCount ) |
---|
2252 | { |
---|
2253 | return; |
---|
2254 | } |
---|
2255 | iCount ++; |
---|
2256 | } |
---|
2257 | // early termination |
---|
2258 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2259 | { |
---|
2260 | return; |
---|
2261 | } |
---|
2262 | |
---|
2263 | //left bottom |
---|
2264 | UInt uiLeftBottomPartIdx = 0; |
---|
2265 | const TComDataCU *pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
2266 | |
---|
2267 | Bool isAvailableA0 = pcCULeftBottom && |
---|
2268 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
2269 | pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ; |
---|
2270 | |
---|
2271 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
2272 | { |
---|
2273 | abCandIsInter[iCount] = true; |
---|
2274 | // get Inter Dir |
---|
2275 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
2276 | // get Mv from Left |
---|
2277 | TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2278 | if ( getSlice()->isInterB() ) |
---|
2279 | { |
---|
2280 | TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2281 | } |
---|
2282 | if ( mrgCandIdx == iCount ) |
---|
2283 | { |
---|
2284 | return; |
---|
2285 | } |
---|
2286 | iCount ++; |
---|
2287 | } |
---|
2288 | // early termination |
---|
2289 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2290 | { |
---|
2291 | return; |
---|
2292 | } |
---|
2293 | |
---|
2294 | // above left |
---|
2295 | if( iCount < 4 ) |
---|
2296 | { |
---|
2297 | UInt uiAboveLeftPartIdx = 0; |
---|
2298 | const TComDataCU *pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
2299 | |
---|
2300 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
2301 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
2302 | pcCUAboveLeft->isInter( uiAboveLeftPartIdx ); |
---|
2303 | |
---|
2304 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
2305 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
2306 | { |
---|
2307 | abCandIsInter[iCount] = true; |
---|
2308 | // get Inter Dir |
---|
2309 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
2310 | // get Mv from Left |
---|
2311 | TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
2312 | if ( getSlice()->isInterB() ) |
---|
2313 | { |
---|
2314 | TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
2315 | } |
---|
2316 | if ( mrgCandIdx == iCount ) |
---|
2317 | { |
---|
2318 | return; |
---|
2319 | } |
---|
2320 | iCount ++; |
---|
2321 | } |
---|
2322 | } |
---|
2323 | // early termination |
---|
2324 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2325 | { |
---|
2326 | return; |
---|
2327 | } |
---|
2328 | |
---|
2329 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
2330 | { |
---|
2331 | //>> MTK colocated-RightBottom |
---|
2332 | UInt uiPartIdxRB; |
---|
2333 | |
---|
2334 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
2335 | |
---|
2336 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
2337 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
2338 | const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); |
---|
2339 | |
---|
2340 | TComMv cColMv; |
---|
2341 | Int iRefIdx; |
---|
2342 | Int ctuRsAddr = -1; |
---|
2343 | |
---|
2344 | if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check |
---|
2345 | && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
2346 | { |
---|
2347 | if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU |
---|
2348 | ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU |
---|
2349 | { |
---|
2350 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ]; |
---|
2351 | ctuRsAddr = getCtuRsAddr(); |
---|
2352 | } |
---|
2353 | else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU |
---|
2354 | { |
---|
2355 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; |
---|
2356 | } |
---|
2357 | else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU |
---|
2358 | { |
---|
2359 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
2360 | ctuRsAddr = getCtuRsAddr() + 1; |
---|
2361 | } |
---|
2362 | else //is the right bottom corner of CTU |
---|
2363 | { |
---|
2364 | uiAbsPartAddr = 0; |
---|
2365 | } |
---|
2366 | } |
---|
2367 | |
---|
2368 | iRefIdx = 0; |
---|
2369 | |
---|
2370 | Bool bExistMV = false; |
---|
2371 | UInt uiPartIdxCenter; |
---|
2372 | Int dir = 0; |
---|
2373 | UInt uiArrayAddr = iCount; |
---|
2374 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
2375 | bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
2376 | if( bExistMV == false ) |
---|
2377 | { |
---|
2378 | bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); |
---|
2379 | } |
---|
2380 | if( bExistMV ) |
---|
2381 | { |
---|
2382 | dir |= 1; |
---|
2383 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
2384 | } |
---|
2385 | |
---|
2386 | if ( getSlice()->isInterB() ) |
---|
2387 | { |
---|
2388 | bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx); |
---|
2389 | if( bExistMV == false ) |
---|
2390 | { |
---|
2391 | bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); |
---|
2392 | } |
---|
2393 | if( bExistMV ) |
---|
2394 | { |
---|
2395 | dir |= 2; |
---|
2396 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
2397 | } |
---|
2398 | } |
---|
2399 | |
---|
2400 | if (dir != 0) |
---|
2401 | { |
---|
2402 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
2403 | abCandIsInter[uiArrayAddr] = true; |
---|
2404 | |
---|
2405 | if ( mrgCandIdx == iCount ) |
---|
2406 | { |
---|
2407 | return; |
---|
2408 | } |
---|
2409 | iCount++; |
---|
2410 | } |
---|
2411 | } |
---|
2412 | // early termination |
---|
2413 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
2414 | { |
---|
2415 | return; |
---|
2416 | } |
---|
2417 | |
---|
2418 | UInt uiArrayAddr = iCount; |
---|
2419 | UInt uiCutoff = uiArrayAddr; |
---|
2420 | |
---|
2421 | if ( getSlice()->isInterB() ) |
---|
2422 | { |
---|
2423 | static const UInt NUM_PRIORITY_LIST=12; |
---|
2424 | static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
2425 | static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
2426 | |
---|
2427 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
2428 | { |
---|
2429 | assert(idx<NUM_PRIORITY_LIST); |
---|
2430 | Int i = uiPriorityList0[idx]; |
---|
2431 | Int j = uiPriorityList1[idx]; |
---|
2432 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
2433 | { |
---|
2434 | abCandIsInter[uiArrayAddr] = true; |
---|
2435 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
2436 | |
---|
2437 | // get Mv from cand[i] and cand[j] |
---|
2438 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
2439 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
2440 | |
---|
2441 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
2442 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
2443 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
2444 | { |
---|
2445 | abCandIsInter[uiArrayAddr] = false; |
---|
2446 | } |
---|
2447 | else |
---|
2448 | { |
---|
2449 | uiArrayAddr++; |
---|
2450 | } |
---|
2451 | } |
---|
2452 | } |
---|
2453 | } |
---|
2454 | // early termination |
---|
2455 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
2456 | { |
---|
2457 | return; |
---|
2458 | } |
---|
2459 | |
---|
2460 | 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); |
---|
2461 | |
---|
2462 | Int r = 0; |
---|
2463 | Int refcnt = 0; |
---|
2464 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
2465 | { |
---|
2466 | abCandIsInter[uiArrayAddr] = true; |
---|
2467 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
2468 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
2469 | |
---|
2470 | if ( getSlice()->isInterB() ) |
---|
2471 | { |
---|
2472 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
2473 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
2474 | } |
---|
2475 | uiArrayAddr++; |
---|
2476 | |
---|
2477 | if ( refcnt == iNumRefIdx - 1 ) |
---|
2478 | { |
---|
2479 | r = 0; |
---|
2480 | } |
---|
2481 | else |
---|
2482 | { |
---|
2483 | ++r; |
---|
2484 | ++refcnt; |
---|
2485 | } |
---|
2486 | } |
---|
2487 | numValidMergeCand = uiArrayAddr; |
---|
2488 | } |
---|
2489 | |
---|
2490 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
---|
2491 | * \param xN, yN location of the upper-left corner pixel of a neighboring PU |
---|
2492 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
2493 | */ |
---|
2494 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) const |
---|
2495 | { |
---|
2496 | |
---|
2497 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
---|
2498 | if ((xN>>plevel)!= (xP>>plevel)) |
---|
2499 | { |
---|
2500 | return true; |
---|
2501 | } |
---|
2502 | if ((yN>>plevel)!= (yP>>plevel)) |
---|
2503 | { |
---|
2504 | return true; |
---|
2505 | } |
---|
2506 | return false; |
---|
2507 | } |
---|
2508 | |
---|
2509 | /** Calculate the location of upper-left corner pixel and size of the current PU. |
---|
2510 | * \param partIdx PU index within a CU |
---|
2511 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
2512 | * \param nPSW, nPSH size of the current PU |
---|
2513 | */ |
---|
2514 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) const |
---|
2515 | { |
---|
2516 | UInt col = m_uiCUPelX; |
---|
2517 | UInt row = m_uiCUPelY; |
---|
2518 | |
---|
2519 | switch ( m_pePartSize[0] ) |
---|
2520 | { |
---|
2521 | case SIZE_2NxN: |
---|
2522 | nPSW = getWidth(0); |
---|
2523 | nPSH = getHeight(0) >> 1; |
---|
2524 | xP = col; |
---|
2525 | yP = (partIdx ==0)? row: row + nPSH; |
---|
2526 | break; |
---|
2527 | case SIZE_Nx2N: |
---|
2528 | nPSW = getWidth(0) >> 1; |
---|
2529 | nPSH = getHeight(0); |
---|
2530 | xP = (partIdx ==0)? col: col + nPSW; |
---|
2531 | yP = row; |
---|
2532 | break; |
---|
2533 | case SIZE_NxN: |
---|
2534 | nPSW = getWidth(0) >> 1; |
---|
2535 | nPSH = getHeight(0) >> 1; |
---|
2536 | xP = col + (partIdx&0x1)*nPSW; |
---|
2537 | yP = row + (partIdx>>1)*nPSH; |
---|
2538 | break; |
---|
2539 | case SIZE_2NxnU: |
---|
2540 | nPSW = getWidth(0); |
---|
2541 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
2542 | xP = col; |
---|
2543 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
2544 | |
---|
2545 | break; |
---|
2546 | case SIZE_2NxnD: |
---|
2547 | nPSW = getWidth(0); |
---|
2548 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
2549 | xP = col; |
---|
2550 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
2551 | break; |
---|
2552 | case SIZE_nLx2N: |
---|
2553 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
2554 | nPSH = getHeight(0); |
---|
2555 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
2556 | yP = row; |
---|
2557 | break; |
---|
2558 | case SIZE_nRx2N: |
---|
2559 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
2560 | nPSH = getHeight(0); |
---|
2561 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
2562 | yP = row; |
---|
2563 | break; |
---|
2564 | default: |
---|
2565 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
2566 | nPSW = getWidth(0); |
---|
2567 | nPSH = getHeight(0); |
---|
2568 | xP = col ; |
---|
2569 | yP = row ; |
---|
2570 | |
---|
2571 | break; |
---|
2572 | } |
---|
2573 | } |
---|
2574 | |
---|
2575 | /** Constructs a list of candidates for AMVP (See specification, section "Derivation process for motion vector predictor candidates") |
---|
2576 | * \param uiPartIdx |
---|
2577 | * \param uiPartAddr |
---|
2578 | * \param eRefPicList |
---|
2579 | * \param iRefIdx |
---|
2580 | * \param pInfo |
---|
2581 | */ |
---|
2582 | Void TComDataCU::fillMvpCand ( const UInt partIdx, const UInt partAddr, const RefPicList eRefPicList, const Int refIdx, AMVPInfo* pInfo ) const |
---|
2583 | { |
---|
2584 | pInfo->iN = 0; |
---|
2585 | if (refIdx < 0) |
---|
2586 | { |
---|
2587 | return; |
---|
2588 | } |
---|
2589 | |
---|
2590 | //-- Get Spatial MV |
---|
2591 | UInt partIdxLT, partIdxRT, partIdxLB; |
---|
2592 | deriveLeftRightTopIdx( partIdx, partIdxLT, partIdxRT ); |
---|
2593 | deriveLeftBottomIdx( partIdx, partIdxLB ); |
---|
2594 | |
---|
2595 | Bool isScaledFlagLX = false; /// variable name from specification; true when the PUs below left or left are available (availableA0 || availableA1). |
---|
2596 | { |
---|
2597 | UInt idx; |
---|
2598 | const TComDataCU* tmpCU = getPUBelowLeft(idx, partIdxLB); |
---|
2599 | isScaledFlagLX = (tmpCU != NULL) && (tmpCU->isInter(idx)); |
---|
2600 | if (!isScaledFlagLX) |
---|
2601 | { |
---|
2602 | tmpCU = getPULeft(idx, partIdxLB); |
---|
2603 | isScaledFlagLX = (tmpCU != NULL) && (tmpCU->isInter(idx)); |
---|
2604 | } |
---|
2605 | } |
---|
2606 | |
---|
2607 | // Left predictor search |
---|
2608 | if (isScaledFlagLX) |
---|
2609 | { |
---|
2610 | Bool bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLB, MD_BELOW_LEFT); |
---|
2611 | if (!bAdded) |
---|
2612 | { |
---|
2613 | bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLB, MD_LEFT ); |
---|
2614 | if(!bAdded) |
---|
2615 | { |
---|
2616 | bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLB, MD_BELOW_LEFT); |
---|
2617 | if (!bAdded) |
---|
2618 | { |
---|
2619 | xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLB, MD_LEFT ); |
---|
2620 | } |
---|
2621 | } |
---|
2622 | } |
---|
2623 | } |
---|
2624 | |
---|
2625 | // Above predictor search |
---|
2626 | { |
---|
2627 | Bool bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE_RIGHT); |
---|
2628 | if (!bAdded) |
---|
2629 | { |
---|
2630 | bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE); |
---|
2631 | if(!bAdded) |
---|
2632 | { |
---|
2633 | xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLT, MD_ABOVE_LEFT); |
---|
2634 | } |
---|
2635 | } |
---|
2636 | } |
---|
2637 | |
---|
2638 | if(!isScaledFlagLX) |
---|
2639 | { |
---|
2640 | Bool bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE_RIGHT); |
---|
2641 | if (!bAdded) |
---|
2642 | { |
---|
2643 | bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE); |
---|
2644 | if(!bAdded) |
---|
2645 | { |
---|
2646 | xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLT, MD_ABOVE_LEFT); |
---|
2647 | } |
---|
2648 | } |
---|
2649 | } |
---|
2650 | |
---|
2651 | if ( pInfo->iN == 2 ) |
---|
2652 | { |
---|
2653 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
---|
2654 | { |
---|
2655 | pInfo->iN = 1; |
---|
2656 | } |
---|
2657 | } |
---|
2658 | |
---|
2659 | if (pInfo->iN < AMVP_MAX_NUM_CANDS && getSlice()->getEnableTMVPFlag() ) |
---|
2660 | { |
---|
2661 | // Get Temporal Motion Predictor |
---|
2662 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
2663 | const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); |
---|
2664 | const Int refIdx_Col = refIdx; |
---|
2665 | TComMv cColMv; |
---|
2666 | UInt partIdxRB; |
---|
2667 | UInt absPartIdx; |
---|
2668 | |
---|
2669 | deriveRightBottomIdx( partIdx, partIdxRB ); |
---|
2670 | UInt absPartAddr = m_absZIdxInCtu + partAddr; |
---|
2671 | |
---|
2672 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
2673 | absPartIdx = g_auiZscanToRaster[partIdxRB]; |
---|
2674 | Int ctuRsAddr = -1; |
---|
2675 | if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[absPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check |
---|
2676 | && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[absPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
2677 | { |
---|
2678 | if ( ( absPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU |
---|
2679 | ( absPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU |
---|
2680 | { |
---|
2681 | absPartAddr = g_auiRasterToZscan[ absPartIdx + numPartInCtuWidth + 1 ]; |
---|
2682 | ctuRsAddr = getCtuRsAddr(); |
---|
2683 | } |
---|
2684 | else if ( absPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU |
---|
2685 | { |
---|
2686 | absPartAddr = g_auiRasterToZscan[ (absPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; |
---|
2687 | } |
---|
2688 | else if ( absPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU |
---|
2689 | { |
---|
2690 | absPartAddr = g_auiRasterToZscan[ absPartIdx + 1 ]; |
---|
2691 | ctuRsAddr = getCtuRsAddr() + 1; |
---|
2692 | } |
---|
2693 | else //is the right bottom corner of CTU |
---|
2694 | { |
---|
2695 | absPartAddr = 0; |
---|
2696 | } |
---|
2697 | } |
---|
2698 | if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, absPartAddr, cColMv, refIdx_Col ) ) |
---|
2699 | { |
---|
2700 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
2701 | } |
---|
2702 | else |
---|
2703 | { |
---|
2704 | UInt uiPartIdxCenter; |
---|
2705 | xDeriveCenterIdx( partIdx, uiPartIdxCenter ); |
---|
2706 | if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter, cColMv, refIdx_Col )) |
---|
2707 | { |
---|
2708 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
2709 | } |
---|
2710 | } |
---|
2711 | //---- co-located RightBottom Temporal Predictor ---// |
---|
2712 | } |
---|
2713 | |
---|
2714 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
---|
2715 | { |
---|
2716 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
---|
2717 | pInfo->iN++; |
---|
2718 | } |
---|
2719 | return ; |
---|
2720 | } |
---|
2721 | |
---|
2722 | |
---|
2723 | Bool TComDataCU::isBipredRestriction(UInt puIdx) const |
---|
2724 | { |
---|
2725 | Int width = 0; |
---|
2726 | Int height = 0; |
---|
2727 | UInt partAddr; |
---|
2728 | |
---|
2729 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
---|
2730 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
---|
2731 | { |
---|
2732 | return true; |
---|
2733 | } |
---|
2734 | return false; |
---|
2735 | } |
---|
2736 | |
---|
2737 | |
---|
2738 | Void TComDataCU::clipMv (TComMv& rcMv) const |
---|
2739 | { |
---|
2740 | const TComSPS &sps=*(m_pcSlice->getSPS()); |
---|
2741 | Int iMvShift = 2; |
---|
2742 | Int iOffset = 8; |
---|
2743 | Int iHorMax = ( sps.getPicWidthInLumaSamples() + iOffset - (Int)m_uiCUPelX - 1 ) << iMvShift; |
---|
2744 | Int iHorMin = ( -(Int)sps.getMaxCUWidth() - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
---|
2745 | |
---|
2746 | Int iVerMax = ( sps.getPicHeightInLumaSamples() + iOffset - (Int)m_uiCUPelY - 1 ) << iMvShift; |
---|
2747 | Int iVerMin = ( -(Int)sps.getMaxCUHeight() - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
---|
2748 | |
---|
2749 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
---|
2750 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
---|
2751 | } |
---|
2752 | |
---|
2753 | |
---|
2754 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) const |
---|
2755 | { |
---|
2756 | UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
2757 | |
---|
2758 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
2759 | UInt uiCnt = 0; |
---|
2760 | while( uiWidth ) |
---|
2761 | { |
---|
2762 | uiCnt++; |
---|
2763 | uiWidth>>=1; |
---|
2764 | } |
---|
2765 | uiCnt-=2; |
---|
2766 | return uiCnt > 6 ? 6 : uiCnt; |
---|
2767 | } |
---|
2768 | |
---|
2769 | Void TComDataCU::clearCbf( UInt uiIdx, ComponentID compID, UInt uiNumParts ) |
---|
2770 | { |
---|
2771 | memset( &m_puhCbf[compID][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
2772 | } |
---|
2773 | |
---|
2774 | /** Set a I_PCM flag for all sub-partitions of a partition. |
---|
2775 | * \param bIpcmFlag I_PCM flag |
---|
2776 | * \param uiAbsPartIdx patition index |
---|
2777 | * \param uiDepth CU depth |
---|
2778 | * \returns Void |
---|
2779 | */ |
---|
2780 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
---|
2781 | { |
---|
2782 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2783 | |
---|
2784 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
---|
2785 | } |
---|
2786 | |
---|
2787 | /** Test whether the block at uiPartIdx is skipped. |
---|
2788 | * \param uiPartIdx Partition index |
---|
2789 | * \returns true if the current the block is skipped |
---|
2790 | */ |
---|
2791 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) const |
---|
2792 | { |
---|
2793 | return ( getSkipFlag( uiPartIdx ) ); |
---|
2794 | } |
---|
2795 | |
---|
2796 | // ==================================================================================================================== |
---|
2797 | // Protected member functions |
---|
2798 | // ==================================================================================================================== |
---|
2799 | |
---|
2800 | Bool TComDataCU::xAddMVPCandUnscaled( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const |
---|
2801 | { |
---|
2802 | const TComDataCU* neibCU = NULL; |
---|
2803 | UInt neibPUPartIdx; |
---|
2804 | switch( eDir ) |
---|
2805 | { |
---|
2806 | case MD_LEFT: |
---|
2807 | { |
---|
2808 | neibCU = getPULeft(neibPUPartIdx, uiPartUnitIdx); |
---|
2809 | break; |
---|
2810 | } |
---|
2811 | case MD_ABOVE: |
---|
2812 | { |
---|
2813 | neibCU = getPUAbove(neibPUPartIdx, uiPartUnitIdx); |
---|
2814 | break; |
---|
2815 | } |
---|
2816 | case MD_ABOVE_RIGHT: |
---|
2817 | { |
---|
2818 | neibCU = getPUAboveRight(neibPUPartIdx, uiPartUnitIdx); |
---|
2819 | break; |
---|
2820 | } |
---|
2821 | case MD_BELOW_LEFT: |
---|
2822 | { |
---|
2823 | neibCU = getPUBelowLeft(neibPUPartIdx, uiPartUnitIdx); |
---|
2824 | break; |
---|
2825 | } |
---|
2826 | case MD_ABOVE_LEFT: |
---|
2827 | { |
---|
2828 | neibCU = getPUAboveLeft(neibPUPartIdx, uiPartUnitIdx); |
---|
2829 | break; |
---|
2830 | } |
---|
2831 | default: |
---|
2832 | { |
---|
2833 | break; |
---|
2834 | } |
---|
2835 | } |
---|
2836 | |
---|
2837 | if ( neibCU == NULL ) |
---|
2838 | { |
---|
2839 | return false; |
---|
2840 | } |
---|
2841 | |
---|
2842 | const Int currRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
2843 | const RefPicList eRefPicList2nd = (eRefPicList == REF_PIC_LIST_0) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
2844 | |
---|
2845 | for(Int predictorSource=0; predictorSource<2; predictorSource++) // examine the indicated reference picture list, then if not available, examine the other list. |
---|
2846 | { |
---|
2847 | const RefPicList eRefPicListIndex = (predictorSource==0) ? eRefPicList : eRefPicList2nd; |
---|
2848 | const Int neibRefIdx = neibCU->getCUMvField(eRefPicListIndex)->getRefIdx(neibPUPartIdx); |
---|
2849 | |
---|
2850 | if ( neibRefIdx >= 0 && currRefPOC == neibCU->getSlice()->getRefPOC( eRefPicListIndex, neibRefIdx )) |
---|
2851 | { |
---|
2852 | info.m_acMvCand[info.iN++] = neibCU->getCUMvField(eRefPicListIndex)->getMv(neibPUPartIdx); |
---|
2853 | return true; |
---|
2854 | } |
---|
2855 | } |
---|
2856 | |
---|
2857 | return false; |
---|
2858 | } |
---|
2859 | |
---|
2860 | /** |
---|
2861 | * \param pInfo |
---|
2862 | * \param eRefPicList |
---|
2863 | * \param iRefIdx |
---|
2864 | * \param uiPartUnitIdx |
---|
2865 | * \param eDir |
---|
2866 | * \returns Bool |
---|
2867 | */ |
---|
2868 | Bool TComDataCU::xAddMVPCandWithScaling( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const |
---|
2869 | { |
---|
2870 | const TComDataCU* neibCU = NULL; |
---|
2871 | UInt neibPUPartIdx; |
---|
2872 | switch( eDir ) |
---|
2873 | { |
---|
2874 | case MD_LEFT: |
---|
2875 | { |
---|
2876 | neibCU = getPULeft(neibPUPartIdx, uiPartUnitIdx); |
---|
2877 | break; |
---|
2878 | } |
---|
2879 | case MD_ABOVE: |
---|
2880 | { |
---|
2881 | neibCU = getPUAbove(neibPUPartIdx, uiPartUnitIdx); |
---|
2882 | break; |
---|
2883 | } |
---|
2884 | case MD_ABOVE_RIGHT: |
---|
2885 | { |
---|
2886 | neibCU = getPUAboveRight(neibPUPartIdx, uiPartUnitIdx); |
---|
2887 | break; |
---|
2888 | } |
---|
2889 | case MD_BELOW_LEFT: |
---|
2890 | { |
---|
2891 | neibCU = getPUBelowLeft(neibPUPartIdx, uiPartUnitIdx); |
---|
2892 | break; |
---|
2893 | } |
---|
2894 | case MD_ABOVE_LEFT: |
---|
2895 | { |
---|
2896 | neibCU = getPUAboveLeft(neibPUPartIdx, uiPartUnitIdx); |
---|
2897 | break; |
---|
2898 | } |
---|
2899 | default: |
---|
2900 | { |
---|
2901 | break; |
---|
2902 | } |
---|
2903 | } |
---|
2904 | |
---|
2905 | if ( neibCU == NULL ) |
---|
2906 | { |
---|
2907 | return false; |
---|
2908 | } |
---|
2909 | |
---|
2910 | const RefPicList eRefPicList2nd = (eRefPicList == REF_PIC_LIST_0) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
2911 | |
---|
2912 | const Int currPOC = m_pcSlice->getPOC(); |
---|
2913 | const Int currRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
2914 | const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
2915 | const Int neibPOC = currPOC; |
---|
2916 | |
---|
2917 | for(Int predictorSource=0; predictorSource<2; predictorSource++) // examine the indicated reference picture list, then if not available, examine the other list. |
---|
2918 | { |
---|
2919 | const RefPicList eRefPicListIndex = (predictorSource==0) ? eRefPicList : eRefPicList2nd; |
---|
2920 | const Int neibRefIdx = neibCU->getCUMvField(eRefPicListIndex)->getRefIdx(neibPUPartIdx); |
---|
2921 | if( neibRefIdx >= 0) |
---|
2922 | { |
---|
2923 | const Bool bIsNeibRefLongTerm = neibCU->getSlice()->getRefPic( eRefPicListIndex, neibRefIdx )->getIsLongTerm(); |
---|
2924 | |
---|
2925 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
2926 | { |
---|
2927 | const TComMv &cMvPred = neibCU->getCUMvField(eRefPicListIndex)->getMv(neibPUPartIdx); |
---|
2928 | TComMv rcMv; |
---|
2929 | if ( bIsCurrRefLongTerm /* || bIsNeibRefLongTerm*/ ) |
---|
2930 | { |
---|
2931 | rcMv = cMvPred; |
---|
2932 | } |
---|
2933 | else |
---|
2934 | { |
---|
2935 | const Int neibRefPOC = neibCU->getSlice()->getRefPOC( eRefPicListIndex, neibRefIdx ); |
---|
2936 | const Int scale = xGetDistScaleFactor( currPOC, currRefPOC, neibPOC, neibRefPOC ); |
---|
2937 | if ( scale == 4096 ) |
---|
2938 | { |
---|
2939 | rcMv = cMvPred; |
---|
2940 | } |
---|
2941 | else |
---|
2942 | { |
---|
2943 | rcMv = cMvPred.scaleMv( scale ); |
---|
2944 | } |
---|
2945 | } |
---|
2946 | |
---|
2947 | info.m_acMvCand[info.iN++] = rcMv; |
---|
2948 | return true; |
---|
2949 | } |
---|
2950 | } |
---|
2951 | } |
---|
2952 | return false; |
---|
2953 | } |
---|
2954 | |
---|
2955 | Bool TComDataCU::xGetColMVP( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, const Int refIdx ) const |
---|
2956 | { |
---|
2957 | const UInt absPartAddr = partUnitIdx; |
---|
2958 | |
---|
2959 | // use coldir. |
---|
2960 | const TComPic * const pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
2961 | #if REDUCED_ENCODER_MEMORY |
---|
2962 | if (!pColPic->getPicSym()->hasDPBPerCtuData()) |
---|
2963 | { |
---|
2964 | return false; |
---|
2965 | } |
---|
2966 | const TComPicSym::DPBPerCtuData * const pColDpbCtu = &(pColPic->getPicSym()->getDPBPerCtuData(ctuRsAddr)); |
---|
2967 | const TComSlice * const pColSlice = pColDpbCtu->getSlice(); |
---|
2968 | if(pColDpbCtu->getPartitionSize(partUnitIdx)==NUMBER_OF_PART_SIZES) |
---|
2969 | #else |
---|
2970 | const TComDataCU * const pColCtu = pColPic->getCtu( ctuRsAddr ); |
---|
2971 | if(pColCtu->getPic()==0 || pColCtu->getPartitionSize(partUnitIdx)==NUMBER_OF_PART_SIZES) |
---|
2972 | #endif |
---|
2973 | { |
---|
2974 | return false; |
---|
2975 | } |
---|
2976 | |
---|
2977 | #if REDUCED_ENCODER_MEMORY |
---|
2978 | if (!pColDpbCtu->isInter(absPartAddr)) |
---|
2979 | #else |
---|
2980 | if (!pColCtu->isInter(absPartAddr)) |
---|
2981 | #endif |
---|
2982 | { |
---|
2983 | return false; |
---|
2984 | } |
---|
2985 | |
---|
2986 | RefPicList eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
---|
2987 | #if REDUCED_ENCODER_MEMORY |
---|
2988 | Int iColRefIdx = pColDpbCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr); |
---|
2989 | #else |
---|
2990 | Int iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr); |
---|
2991 | #endif |
---|
2992 | |
---|
2993 | if (iColRefIdx < 0 ) |
---|
2994 | { |
---|
2995 | eColRefPicList = RefPicList(1 - eColRefPicList); |
---|
2996 | #if REDUCED_ENCODER_MEMORY |
---|
2997 | iColRefIdx = pColDpbCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr); |
---|
2998 | #else |
---|
2999 | iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr); |
---|
3000 | #endif |
---|
3001 | |
---|
3002 | if (iColRefIdx < 0 ) |
---|
3003 | { |
---|
3004 | return false; |
---|
3005 | } |
---|
3006 | } |
---|
3007 | |
---|
3008 | const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm(); |
---|
3009 | #if REDUCED_ENCODER_MEMORY |
---|
3010 | const Bool bIsColRefLongTerm = pColSlice->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); |
---|
3011 | #else |
---|
3012 | const Bool bIsColRefLongTerm = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); |
---|
3013 | #endif |
---|
3014 | |
---|
3015 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
3016 | { |
---|
3017 | return false; |
---|
3018 | } |
---|
3019 | |
---|
3020 | // Scale the vector. |
---|
3021 | #if REDUCED_ENCODER_MEMORY |
---|
3022 | const TComMv &cColMv = pColDpbCtu->getCUMvField(eColRefPicList)->getMv(absPartAddr); |
---|
3023 | #else |
---|
3024 | const TComMv &cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(absPartAddr); |
---|
3025 | #endif |
---|
3026 | if ( bIsCurrRefLongTerm /*|| bIsColRefLongTerm*/ ) |
---|
3027 | { |
---|
3028 | rcMv = cColMv; |
---|
3029 | } |
---|
3030 | else |
---|
3031 | { |
---|
3032 | const Int currPOC = m_pcSlice->getPOC(); |
---|
3033 | #if REDUCED_ENCODER_MEMORY |
---|
3034 | const Int colPOC = pColSlice->getPOC(); |
---|
3035 | const Int colRefPOC = pColSlice->getRefPOC(eColRefPicList, iColRefIdx); |
---|
3036 | #else |
---|
3037 | const Int colPOC = pColCtu->getSlice()->getPOC(); |
---|
3038 | const Int colRefPOC = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
---|
3039 | #endif |
---|
3040 | const Int currRefPOC = m_pcSlice->getRefPic(eRefPicList, refIdx)->getPOC(); |
---|
3041 | const Int scale = xGetDistScaleFactor(currPOC, currRefPOC, colPOC, colRefPOC); |
---|
3042 | if ( scale == 4096 ) |
---|
3043 | { |
---|
3044 | rcMv = cColMv; |
---|
3045 | } |
---|
3046 | else |
---|
3047 | { |
---|
3048 | rcMv = cColMv.scaleMv( scale ); |
---|
3049 | } |
---|
3050 | } |
---|
3051 | |
---|
3052 | return true; |
---|
3053 | } |
---|
3054 | |
---|
3055 | // Static member |
---|
3056 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
3057 | { |
---|
3058 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
3059 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
3060 | |
---|
3061 | if( iDiffPocD == iDiffPocB ) |
---|
3062 | { |
---|
3063 | return 4096; |
---|
3064 | } |
---|
3065 | else |
---|
3066 | { |
---|
3067 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
3068 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
3069 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
3070 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
---|
3071 | return iScale; |
---|
3072 | } |
---|
3073 | } |
---|
3074 | |
---|
3075 | Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) const |
---|
3076 | { |
---|
3077 | UInt uiPartAddr; |
---|
3078 | Int iPartWidth; |
---|
3079 | Int iPartHeight; |
---|
3080 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
3081 | |
---|
3082 | ruiPartIdxCenter = m_absZIdxInCtu+uiPartAddr; // partition origin. |
---|
3083 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
3084 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInCtuWidth() |
---|
3085 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
---|
3086 | } |
---|
3087 | |
---|
3088 | Void TComDataCU::compressMV() |
---|
3089 | { |
---|
3090 | #if REDUCED_ENCODER_MEMORY |
---|
3091 | const Int scaleFactor = std::max<Int>(1,4 * AMVP_DECIMATION_FACTOR / m_unitSize); |
---|
3092 | TComPicSym &picSym=*(getPic()->getPicSym()); |
---|
3093 | TComPicSym::DPBPerCtuData &dpbForCtu=picSym.getDPBPerCtuData(getCtuRsAddr()); |
---|
3094 | |
---|
3095 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
3096 | { |
---|
3097 | dpbForCtu.m_CUMvField[i].compress(dpbForCtu.m_pePredMode, m_pePredMode, scaleFactor,m_acCUMvField[i]); |
---|
3098 | memcpy(dpbForCtu.m_pePartSize, m_pePartSize, sizeof(*m_pePartSize)*m_uiNumPartition); |
---|
3099 | dpbForCtu.m_pSlice = getSlice(); |
---|
3100 | } |
---|
3101 | #else |
---|
3102 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
3103 | if (scaleFactor > 0) |
---|
3104 | { |
---|
3105 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
3106 | { |
---|
3107 | m_acCUMvField[i].compress(m_pePredMode, scaleFactor); |
---|
3108 | } |
---|
3109 | } |
---|
3110 | #endif |
---|
3111 | } |
---|
3112 | |
---|
3113 | UInt TComDataCU::getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const |
---|
3114 | { |
---|
3115 | //------------------------------------------------ |
---|
3116 | |
---|
3117 | //this mechanism is available for intra only |
---|
3118 | |
---|
3119 | if (!isIntra(uiAbsPartIdx)) |
---|
3120 | { |
---|
3121 | return SCAN_DIAG; |
---|
3122 | } |
---|
3123 | |
---|
3124 | //------------------------------------------------ |
---|
3125 | |
---|
3126 | //check that MDCS can be used for this TU |
---|
3127 | |
---|
3128 | const ChromaFormat format = getPic()->getChromaFormat(); |
---|
3129 | |
---|
3130 | const UInt maximumWidth = MDCS_MAXIMUM_WIDTH >> getComponentScaleX(compID, format); |
---|
3131 | const UInt maximumHeight = MDCS_MAXIMUM_HEIGHT >> getComponentScaleY(compID, format); |
---|
3132 | |
---|
3133 | if ((uiWidth > maximumWidth) || (uiHeight > maximumHeight)) |
---|
3134 | { |
---|
3135 | return SCAN_DIAG; |
---|
3136 | } |
---|
3137 | |
---|
3138 | //------------------------------------------------ |
---|
3139 | |
---|
3140 | //otherwise, select the appropriate mode |
---|
3141 | |
---|
3142 | UInt uiDirMode = getIntraDir(toChannelType(compID), uiAbsPartIdx); |
---|
3143 | |
---|
3144 | if (uiDirMode==DM_CHROMA_IDX) |
---|
3145 | { |
---|
3146 | const TComSPS *sps=getSlice()->getSPS(); |
---|
3147 | const UInt partsPerMinCU = 1<<(2*(sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize())); |
---|
3148 | uiDirMode = getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, getPic()->getChromaFormat(), partsPerMinCU)); |
---|
3149 | } |
---|
3150 | |
---|
3151 | if (isChroma(compID) && (format == CHROMA_422)) |
---|
3152 | { |
---|
3153 | uiDirMode = g_chroma422IntraAngleMappingTable[uiDirMode]; |
---|
3154 | } |
---|
3155 | |
---|
3156 | //------------------ |
---|
3157 | |
---|
3158 | if (abs((Int)uiDirMode - VER_IDX) <= MDCS_ANGLE_LIMIT) |
---|
3159 | { |
---|
3160 | return SCAN_HOR; |
---|
3161 | } |
---|
3162 | else if (abs((Int)uiDirMode - HOR_IDX) <= MDCS_ANGLE_LIMIT) |
---|
3163 | { |
---|
3164 | return SCAN_VER; |
---|
3165 | } |
---|
3166 | else |
---|
3167 | { |
---|
3168 | return SCAN_DIAG; |
---|
3169 | } |
---|
3170 | } |
---|
3171 | |
---|
3172 | #if SVC_EXTENSION |
---|
3173 | TComDataCU* TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int** petPosScalingFactor, Bool motionMapping ) |
---|
3174 | { |
---|
3175 | UInt uiPelX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiCuAbsPartIdx] ]; |
---|
3176 | UInt uiPelY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiCuAbsPartIdx] ]; |
---|
3177 | |
---|
3178 | return getBaseColCU( refLayerIdc, uiPelX, uiPelY, uiCUAddrBase, uiAbsPartIdxBase, petPosScalingFactor, motionMapping ); |
---|
3179 | } |
---|
3180 | |
---|
3181 | TComDataCU* TComDataCU::getBaseColCU( UInt refLayerIdc, UInt pelX, UInt pelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int** posScalingFactor, Bool motionMapping ) |
---|
3182 | { |
---|
3183 | TComPic* baseColPic = m_pcSlice->getBaseColPic(refLayerIdc); |
---|
3184 | |
---|
3185 | Int iPelX = Clip3<Int>(0, m_pcPic->getPicYuvRec()->getWidth(COMPONENT_Y) - 1, pelX); |
---|
3186 | Int iPelY = Clip3<Int>(0, m_pcPic->getPicYuvRec()->getHeight(COMPONENT_Y) - 1, pelY); |
---|
3187 | |
---|
3188 | // centre of the collocated 16x16 block for motion mapping |
---|
3189 | if( motionMapping ) |
---|
3190 | { |
---|
3191 | iPelX = pelX + 8; |
---|
3192 | iPelY = pelY + 8; |
---|
3193 | } |
---|
3194 | |
---|
3195 | Int leftStartL = m_pcSlice->getPPS()->getScaledRefLayerWindowForLayer(baseColPic->getSlice(0)->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowLeftOffset(); |
---|
3196 | Int topStartL = m_pcSlice->getPPS()->getScaledRefLayerWindowForLayer(baseColPic->getSlice(0)->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowTopOffset(); |
---|
3197 | |
---|
3198 | const Window &windowRL = m_pcSlice->getPPS()->getRefLayerWindowForLayer(baseColPic->getSlice(0)->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)); |
---|
3199 | Int iBX = (((iPelX - leftStartL) * posScalingFactor[0][refLayerIdc] + (1<<15)) >> 16) + windowRL.getWindowLeftOffset(); |
---|
3200 | Int iBY = (((iPelY - topStartL ) * posScalingFactor[1][refLayerIdc] + (1<<15)) >> 16) + windowRL.getWindowTopOffset(); |
---|
3201 | |
---|
3202 | // offset for collocated block in the motion mapping |
---|
3203 | if( motionMapping ) |
---|
3204 | { |
---|
3205 | if( m_pcPic->equalPictureSizeAndOffsetFlag(refLayerIdc) ) |
---|
3206 | { |
---|
3207 | // copy motion field from the same sample position for the case of 1x scaling ratio and same offset value between the current and reference layers |
---|
3208 | iBX = pelX; |
---|
3209 | iBY = pelY; |
---|
3210 | } |
---|
3211 | else |
---|
3212 | { |
---|
3213 | // actually, motion field compression is performed in the Void TComPic::compressMotion() function, but with (+4) the rounding may have effect on the picture boundary check. |
---|
3214 | iBX = ( ( iBX + 4 ) >> 4 ) << 4; |
---|
3215 | iBY = ( ( iBY + 4 ) >> 4 ) << 4; |
---|
3216 | } |
---|
3217 | } |
---|
3218 | |
---|
3219 | if ( iBX < 0 || iBX >= baseColPic->getPicYuvRec()->getWidth(COMPONENT_Y) || iBY < 0 || iBY >= baseColPic->getPicYuvRec()->getHeight(COMPONENT_Y) ) |
---|
3220 | { |
---|
3221 | return NULL; |
---|
3222 | } |
---|
3223 | |
---|
3224 | UInt baseMaxCUHeight = baseColPic->getSlice(0)->getSPS()->getMaxCUHeight(); |
---|
3225 | UInt baseMaxCUWidth = baseColPic->getSlice(0)->getSPS()->getMaxCUWidth(); |
---|
3226 | UInt baseMinUnitSize = baseColPic->getMinCUWidth(); |
---|
3227 | |
---|
3228 | uiCUAddrBase = ( iBY / baseMaxCUHeight ) * baseColPic->getFrameWidthInCtus() + ( iBX / baseMaxCUWidth ); |
---|
3229 | |
---|
3230 | assert(uiCUAddrBase < baseColPic->getNumberOfCtusInFrame()); |
---|
3231 | |
---|
3232 | UInt uiRasterAddrBase = ( iBY - (iBY/baseMaxCUHeight)*baseMaxCUHeight ) / baseMinUnitSize * baseColPic->getNumPartInCtuWidth() + ( iBX - (iBX/baseMaxCUWidth)*baseMaxCUWidth ) / baseMinUnitSize; |
---|
3233 | |
---|
3234 | #if LAYER_CTB |
---|
3235 | uiAbsPartIdxBase = g_auiLayerRasterToZscan[baseColPic->getLayerId()][uiRasterAddrBase]; |
---|
3236 | #else |
---|
3237 | uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase]; |
---|
3238 | #endif |
---|
3239 | |
---|
3240 | return baseColPic->getCtu(uiCUAddrBase); |
---|
3241 | } |
---|
3242 | |
---|
3243 | Void TComDataCU::scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase, Int** mvScalingFactor ) |
---|
3244 | { |
---|
3245 | TComMvField cMvFieldBase; |
---|
3246 | TComMv cMv; |
---|
3247 | |
---|
3248 | cMv = rcMvFieldBase.getMv().scaleMv( mvScalingFactor[0][refLayerIdc], mvScalingFactor[1][refLayerIdc] ); |
---|
3249 | |
---|
3250 | rcMvFieldEnhance.setMvField( cMv, rcMvFieldBase.getRefIdx() ); |
---|
3251 | } |
---|
3252 | |
---|
3253 | #if FAST_INTRA_SHVC |
---|
3254 | /** generate limited set of remaining modes |
---|
3255 | *\param uiAbsPartIdx |
---|
3256 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
3257 | *\returns Number of intra coding modes (nb of remaining modes + 3 MPMs) |
---|
3258 | */ |
---|
3259 | Int TComDataCU::reduceSetOfIntraModes( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int** posScalingFactor, Int &fullSetOfModes ) |
---|
3260 | { |
---|
3261 | // check BL mode |
---|
3262 | UInt uiCUAddrBase = 0, uiAbsPartAddrBase = 0; |
---|
3263 | // the right reference layerIdc should be specified, currently it is set to m_layerId-1 |
---|
3264 | TComDataCU* pcTempCU = getBaseColCU(m_pcPic->getLayerId() - 1, uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase, posScalingFactor, false ); |
---|
3265 | |
---|
3266 | if( pcTempCU->getPredictionMode( uiAbsPartAddrBase ) != MODE_INTRA ) |
---|
3267 | { |
---|
3268 | return( NUM_INTRA_MODE-1 ); |
---|
3269 | } |
---|
3270 | |
---|
3271 | // compute set of enabled modes m_reducedSetIntraModes[...] |
---|
3272 | 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}; |
---|
3273 | Int nbModes; |
---|
3274 | for (nbModes=0; nbModes<3; nbModes++) // add 3 MPMs 1st |
---|
3275 | { |
---|
3276 | m_reducedSetIntraModes[nbModes] = uiIntraDirPred[nbModes]; |
---|
3277 | authorizedMode[ uiIntraDirPred[nbModes] ] = 0; |
---|
3278 | } |
---|
3279 | |
---|
3280 | Int iColBaseDir = pcTempCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartAddrBase ); |
---|
3281 | if ( authorizedMode[iColBaseDir] ) //possibly add BL mode |
---|
3282 | { |
---|
3283 | m_reducedSetIntraModes[nbModes++] = iColBaseDir; |
---|
3284 | authorizedMode[ iColBaseDir ] = 0; |
---|
3285 | } |
---|
3286 | |
---|
3287 | Int iRefMode = ( iColBaseDir > 1 ) ? iColBaseDir : uiIntraDirPred[0]; |
---|
3288 | if ( iRefMode > 1 ) //add neighboring modes of refMode |
---|
3289 | { |
---|
3290 | UInt left = iRefMode; |
---|
3291 | UInt right = iRefMode; |
---|
3292 | while ( nbModes < NB_REMAIN_MODES+3 ) |
---|
3293 | { |
---|
3294 | left = ((left + 29) % 32) + 2; |
---|
3295 | right = ((right - 1 ) % 32) + 2; |
---|
3296 | if( authorizedMode[left] ) |
---|
3297 | { |
---|
3298 | m_reducedSetIntraModes[nbModes++] = left; |
---|
3299 | } |
---|
3300 | if( authorizedMode[right] ) |
---|
3301 | { |
---|
3302 | m_reducedSetIntraModes[nbModes++] = right; |
---|
3303 | } |
---|
3304 | } |
---|
3305 | } |
---|
3306 | else //add pre-defined modes |
---|
3307 | { |
---|
3308 | const UChar predefSetIntraModes[NUM_INTRA_MODE-1] = {26,10,18,34,2,22,14,30,6,24,12,28,8,20,16,32,4,17,19,15,21,13,23,11,25,9,27,7,29,5,31,3,33,0,2}; |
---|
3309 | |
---|
3310 | Int idx = 0; |
---|
3311 | while( nbModes < NB_REMAIN_MODES+3 ) |
---|
3312 | { |
---|
3313 | UInt mode = predefSetIntraModes[idx++]; |
---|
3314 | if( authorizedMode[mode] ) |
---|
3315 | { |
---|
3316 | m_reducedSetIntraModes[nbModes++] = mode; |
---|
3317 | } |
---|
3318 | } |
---|
3319 | } |
---|
3320 | |
---|
3321 | fullSetOfModes = 0; |
---|
3322 | |
---|
3323 | return nbModes; |
---|
3324 | } |
---|
3325 | #endif |
---|
3326 | |
---|
3327 | #if REF_IDX_ME_ZEROMV |
---|
3328 | Bool TComDataCU::checkZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1) |
---|
3329 | { |
---|
3330 | Bool checkZeroMVILR = true; |
---|
3331 | |
---|
3332 | if( m_pcSlice->getVPS()->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer |
---|
3333 | { |
---|
3334 | if( uhInterDir & 0x1 ) //list0 |
---|
3335 | { |
---|
3336 | Int refIdxL0 = cMvFieldL0.getRefIdx(); |
---|
3337 | TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_0, refIdxL0); |
---|
3338 | |
---|
3339 | if(refPic->isILR(m_pcPic->getLayerId())) |
---|
3340 | { |
---|
3341 | checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0); |
---|
3342 | |
---|
3343 | // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, |
---|
3344 | // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture |
---|
3345 | checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_pcPic->getLayerIdx(), refPic->getLayerIdx() ); |
---|
3346 | } |
---|
3347 | } |
---|
3348 | |
---|
3349 | if( uhInterDir & 0x2 ) //list1 |
---|
3350 | { |
---|
3351 | Int refIdxL1 = cMvFieldL1.getRefIdx(); |
---|
3352 | TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_1, refIdxL1); |
---|
3353 | |
---|
3354 | if(refPic->isILR(m_pcPic->getLayerId())) |
---|
3355 | { |
---|
3356 | checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0); |
---|
3357 | |
---|
3358 | // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, |
---|
3359 | // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture |
---|
3360 | checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_pcPic->getLayerIdx(), refPic->getLayerIdx() ); |
---|
3361 | } |
---|
3362 | } |
---|
3363 | } |
---|
3364 | |
---|
3365 | return checkZeroMVILR; |
---|
3366 | } |
---|
3367 | |
---|
3368 | Bool TComDataCU::checkZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx) |
---|
3369 | { |
---|
3370 | Bool checkZeroMVILR = true; |
---|
3371 | |
---|
3372 | if( m_pcSlice->getVPS()->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer |
---|
3373 | { |
---|
3374 | RefPicList eRefPicList = iRefList > 0? REF_PIC_LIST_1: REF_PIC_LIST_0; |
---|
3375 | assert(eRefPicList == REF_PIC_LIST_1); |
---|
3376 | |
---|
3377 | if( m_pcSlice->getRefPic(eRefPicList, iRefIdx)->isILR(m_pcPic->getLayerId()) ) |
---|
3378 | { |
---|
3379 | AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
3380 | TComMv cMv = pcAMVPInfo->m_acMvCand[MvpIdx]; |
---|
3381 | checkZeroMVILR &= (cMv.getHor() == 0 && cMv.getVer() == 0); |
---|
3382 | } |
---|
3383 | } |
---|
3384 | |
---|
3385 | return checkZeroMVILR; |
---|
3386 | } |
---|
3387 | #endif |
---|
3388 | |
---|
3389 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
3390 | Bool TComDataCU::isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1) const |
---|
3391 | { |
---|
3392 | Bool checkILR = false; |
---|
3393 | |
---|
3394 | if(uhInterDir&0x1) //list0 |
---|
3395 | { |
---|
3396 | Int refIdxL0 = cMvFieldL0.getRefIdx(); |
---|
3397 | checkILR = getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_pcPic->getLayerId()); |
---|
3398 | } |
---|
3399 | if(uhInterDir&0x2) //list1 |
---|
3400 | { |
---|
3401 | Int refIdxL1 = cMvFieldL1.getRefIdx(); |
---|
3402 | checkILR = checkILR || getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_pcPic->getLayerId()); |
---|
3403 | } |
---|
3404 | |
---|
3405 | return checkILR; |
---|
3406 | } |
---|
3407 | #endif |
---|
3408 | |
---|
3409 | #endif //SVC_EXTENSION |
---|
3410 | //! \} |
---|