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-2015, 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 | #if NH_3D_DIS |
---|
58 | m_bDISFlag = NULL; |
---|
59 | m_ucDISType = NULL; |
---|
60 | #endif |
---|
61 | m_pePartSize = NULL; |
---|
62 | m_pePredMode = NULL; |
---|
63 | m_CUTransquantBypass = NULL; |
---|
64 | m_puhWidth = NULL; |
---|
65 | m_puhHeight = NULL; |
---|
66 | m_phQP = NULL; |
---|
67 | m_ChromaQpAdj = NULL; |
---|
68 | m_pbMergeFlag = NULL; |
---|
69 | m_puhMergeIndex = NULL; |
---|
70 | for(UInt i=0; i<MAX_NUM_CHANNEL_TYPE; i++) |
---|
71 | { |
---|
72 | m_puhIntraDir[i] = NULL; |
---|
73 | } |
---|
74 | m_puhInterDir = NULL; |
---|
75 | m_puhTrIdx = NULL; |
---|
76 | |
---|
77 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
78 | { |
---|
79 | m_puhCbf[comp] = NULL; |
---|
80 | m_crossComponentPredictionAlpha[comp] = NULL; |
---|
81 | m_puhTransformSkip[comp] = NULL; |
---|
82 | m_pcTrCoeff[comp] = NULL; |
---|
83 | #if ADAPTIVE_QP_SELECTION |
---|
84 | m_pcArlCoeff[comp] = NULL; |
---|
85 | #endif |
---|
86 | m_pcIPCMSample[comp] = NULL; |
---|
87 | m_explicitRdpcmMode[comp] = NULL; |
---|
88 | } |
---|
89 | #if ADAPTIVE_QP_SELECTION |
---|
90 | m_ArlCoeffIsAliasedAllocation = false; |
---|
91 | #endif |
---|
92 | m_pbIPCMFlag = NULL; |
---|
93 | |
---|
94 | m_pCtuAboveLeft = NULL; |
---|
95 | m_pCtuAboveRight = NULL; |
---|
96 | m_pCtuAbove = NULL; |
---|
97 | m_pCtuLeft = NULL; |
---|
98 | |
---|
99 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
100 | { |
---|
101 | m_apcCUColocated[i] = NULL; |
---|
102 | m_apiMVPIdx[i] = NULL; |
---|
103 | m_apiMVPNum[i] = NULL; |
---|
104 | } |
---|
105 | |
---|
106 | #if NH_3D_DMM |
---|
107 | for( Int i = 0; i < NUM_DMM; i++ ) |
---|
108 | { |
---|
109 | m_dmmDeltaDC[i][0] = NULL; |
---|
110 | m_dmmDeltaDC[i][1] = NULL; |
---|
111 | } |
---|
112 | m_dmm1WedgeTabIdx = NULL; |
---|
113 | #endif |
---|
114 | #if NH_3D_SDC_INTRA |
---|
115 | m_pbSDCFlag = NULL; |
---|
116 | m_apSegmentDCOffset[0] = NULL; |
---|
117 | m_apSegmentDCOffset[1] = NULL; |
---|
118 | #endif |
---|
119 | |
---|
120 | m_bDecSubCu = false; |
---|
121 | |
---|
122 | #if H_3D_NBDV |
---|
123 | m_pDvInfo = NULL; |
---|
124 | #endif |
---|
125 | #if H_3D_VSP |
---|
126 | m_piVSPFlag = NULL; |
---|
127 | #endif |
---|
128 | #if H_3D_SPIVMP |
---|
129 | m_pbSPIVMPFlag = NULL; |
---|
130 | #endif |
---|
131 | #if H_3D_ARP |
---|
132 | m_puhARPW = NULL; |
---|
133 | #endif |
---|
134 | #if H_3D_IC |
---|
135 | m_pbICFlag = NULL; |
---|
136 | #endif |
---|
137 | #if H_3D_INTER_SDC |
---|
138 | #endif |
---|
139 | #if H_3D_DBBP |
---|
140 | m_pbDBBPFlag = NULL; |
---|
141 | #endif |
---|
142 | |
---|
143 | } |
---|
144 | |
---|
145 | TComDataCU::~TComDataCU() |
---|
146 | { |
---|
147 | } |
---|
148 | |
---|
149 | Void TComDataCU::create( ChromaFormat chromaFormatIDC, UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
150 | #if ADAPTIVE_QP_SELECTION |
---|
151 | , TCoeff *pParentARLBuffer |
---|
152 | #endif |
---|
153 | ) |
---|
154 | { |
---|
155 | m_bDecSubCu = bDecSubCu; |
---|
156 | |
---|
157 | m_pcPic = NULL; |
---|
158 | m_pcSlice = NULL; |
---|
159 | m_uiNumPartition = uiNumPartition; |
---|
160 | m_unitSize = unitSize; |
---|
161 | |
---|
162 | if ( !bDecSubCu ) |
---|
163 | { |
---|
164 | m_phQP = (Char* )xMalloc(Char, uiNumPartition); |
---|
165 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
166 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
167 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
168 | |
---|
169 | m_ChromaQpAdj = new UChar[ uiNumPartition ]; |
---|
170 | m_skipFlag = new Bool[ uiNumPartition ]; |
---|
171 | #if NH_3D_DIS |
---|
172 | m_bDISFlag = new Bool[ uiNumPartition ]; |
---|
173 | m_ucDISType = (UChar*)xMalloc(UChar, uiNumPartition); |
---|
174 | #endif |
---|
175 | m_pePartSize = new Char[ uiNumPartition ]; |
---|
176 | memset( m_pePartSize, NUMBER_OF_PART_SIZES,uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
177 | m_pePredMode = new Char[ uiNumPartition ]; |
---|
178 | m_CUTransquantBypass = new Bool[ uiNumPartition ]; |
---|
179 | |
---|
180 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
181 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
182 | #if H_3D_VSP |
---|
183 | m_piVSPFlag = (Char* )xMalloc(Char, uiNumPartition); |
---|
184 | #endif |
---|
185 | #if H_3D_SPIVMP |
---|
186 | m_pbSPIVMPFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
187 | #endif |
---|
188 | |
---|
189 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
190 | { |
---|
191 | m_puhIntraDir[ch] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
192 | } |
---|
193 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
194 | |
---|
195 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
196 | |
---|
197 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
198 | { |
---|
199 | const RefPicList rpl=RefPicList(i); |
---|
200 | m_apiMVPIdx[rpl] = new Char[ uiNumPartition ]; |
---|
201 | m_apiMVPNum[rpl] = new Char[ uiNumPartition ]; |
---|
202 | memset( m_apiMVPIdx[rpl], -1,uiNumPartition * sizeof( Char ) ); |
---|
203 | } |
---|
204 | |
---|
205 | #if H_3D_NBDV |
---|
206 | m_pDvInfo = (DisInfo* )xMalloc(DisInfo, uiNumPartition); |
---|
207 | #endif |
---|
208 | |
---|
209 | |
---|
210 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
211 | { |
---|
212 | const ComponentID compID = ComponentID(comp); |
---|
213 | const UInt chromaShift = getComponentScaleX(compID, chromaFormatIDC) + getComponentScaleY(compID, chromaFormatIDC); |
---|
214 | const UInt totalSize = (uiWidth * uiHeight) >> chromaShift; |
---|
215 | |
---|
216 | m_crossComponentPredictionAlpha[compID] = (Char* )xMalloc(Char, uiNumPartition); |
---|
217 | m_puhTransformSkip[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
218 | m_explicitRdpcmMode[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
219 | m_puhCbf[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
220 | m_pcTrCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); |
---|
221 | memset( m_pcTrCoeff[compID], 0, (totalSize * sizeof( TCoeff )) ); |
---|
222 | |
---|
223 | #if ADAPTIVE_QP_SELECTION |
---|
224 | if( pParentARLBuffer != 0 ) |
---|
225 | { |
---|
226 | m_pcArlCoeff[compID] = pParentARLBuffer; |
---|
227 | m_ArlCoeffIsAliasedAllocation = true; |
---|
228 | pParentARLBuffer += totalSize; |
---|
229 | } |
---|
230 | else |
---|
231 | { |
---|
232 | m_pcArlCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); |
---|
233 | m_ArlCoeffIsAliasedAllocation = false; |
---|
234 | } |
---|
235 | #endif |
---|
236 | m_pcIPCMSample[compID] = (Pel* )xMalloc(Pel , totalSize); |
---|
237 | } |
---|
238 | |
---|
239 | m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
240 | |
---|
241 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
242 | { |
---|
243 | m_acCUMvField[i].create( uiNumPartition ); |
---|
244 | } |
---|
245 | |
---|
246 | #if H_3D_ARP |
---|
247 | m_puhARPW = new UChar[ uiNumPartition]; |
---|
248 | #endif |
---|
249 | #if H_3D_IC |
---|
250 | m_pbICFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
251 | #endif |
---|
252 | #if NH_3D_DMM |
---|
253 | for( Int i = 0; i < NUM_DMM; i++ ) |
---|
254 | { |
---|
255 | m_dmmDeltaDC[i][0] = (Pel* )xMalloc(Pel, uiNumPartition); |
---|
256 | m_dmmDeltaDC[i][1] = (Pel* )xMalloc(Pel, uiNumPartition); |
---|
257 | } |
---|
258 | m_dmm1WedgeTabIdx = (UInt*)xMalloc(UInt, uiNumPartition); |
---|
259 | #endif |
---|
260 | #if NH_3D_SDC_INTRA |
---|
261 | m_pbSDCFlag = (Bool*)xMalloc(Bool, uiNumPartition); |
---|
262 | m_apSegmentDCOffset[0] = (Pel*)xMalloc(Pel, uiNumPartition); |
---|
263 | m_apSegmentDCOffset[1] = (Pel*)xMalloc(Pel, uiNumPartition); |
---|
264 | #endif |
---|
265 | #if H_3D_DBBP |
---|
266 | m_pbDBBPFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
267 | #endif |
---|
268 | |
---|
269 | } |
---|
270 | else |
---|
271 | { |
---|
272 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
273 | { |
---|
274 | m_acCUMvField[i].setNumPartition(uiNumPartition ); |
---|
275 | } |
---|
276 | } |
---|
277 | |
---|
278 | // create motion vector fields |
---|
279 | |
---|
280 | m_pCtuAboveLeft = NULL; |
---|
281 | m_pCtuAboveRight = NULL; |
---|
282 | m_pCtuAbove = NULL; |
---|
283 | m_pCtuLeft = NULL; |
---|
284 | |
---|
285 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
286 | { |
---|
287 | m_apcCUColocated[i] = NULL; |
---|
288 | } |
---|
289 | } |
---|
290 | |
---|
291 | Void TComDataCU::destroy() |
---|
292 | { |
---|
293 | // encoder-side buffer free |
---|
294 | if ( !m_bDecSubCu ) |
---|
295 | { |
---|
296 | if ( m_phQP ) |
---|
297 | { |
---|
298 | xFree(m_phQP); |
---|
299 | m_phQP = NULL; |
---|
300 | } |
---|
301 | if ( m_puhDepth ) |
---|
302 | { |
---|
303 | xFree(m_puhDepth); |
---|
304 | m_puhDepth = NULL; |
---|
305 | } |
---|
306 | if ( m_puhWidth ) |
---|
307 | { |
---|
308 | xFree(m_puhWidth); |
---|
309 | m_puhWidth = NULL; |
---|
310 | } |
---|
311 | if ( m_puhHeight ) |
---|
312 | { |
---|
313 | xFree(m_puhHeight); |
---|
314 | m_puhHeight = NULL; |
---|
315 | } |
---|
316 | |
---|
317 | if ( m_skipFlag ) |
---|
318 | { |
---|
319 | delete[] m_skipFlag; |
---|
320 | m_skipFlag = NULL; |
---|
321 | } |
---|
322 | |
---|
323 | #if NH_3D_DIS |
---|
324 | if ( m_bDISFlag ) { delete[] m_bDISFlag; m_bDISFlag = NULL; } |
---|
325 | if ( m_ucDISType ) { xFree(m_ucDISType); m_ucDISType = NULL; } |
---|
326 | #endif |
---|
327 | |
---|
328 | if ( m_pePartSize ) |
---|
329 | { |
---|
330 | delete[] m_pePartSize; |
---|
331 | m_pePartSize = NULL; |
---|
332 | } |
---|
333 | if ( m_pePredMode ) |
---|
334 | { |
---|
335 | delete[] m_pePredMode; |
---|
336 | m_pePredMode = NULL; |
---|
337 | } |
---|
338 | if ( m_ChromaQpAdj ) |
---|
339 | { |
---|
340 | delete[] m_ChromaQpAdj; |
---|
341 | m_ChromaQpAdj = NULL; |
---|
342 | } |
---|
343 | if ( m_CUTransquantBypass ) |
---|
344 | { |
---|
345 | delete[] m_CUTransquantBypass; |
---|
346 | m_CUTransquantBypass = NULL; |
---|
347 | } |
---|
348 | if ( m_puhInterDir ) |
---|
349 | { |
---|
350 | xFree(m_puhInterDir); |
---|
351 | m_puhInterDir = NULL; |
---|
352 | } |
---|
353 | if ( m_pbMergeFlag ) |
---|
354 | { |
---|
355 | xFree(m_pbMergeFlag); |
---|
356 | m_pbMergeFlag = NULL; |
---|
357 | } |
---|
358 | if ( m_puhMergeIndex ) |
---|
359 | { |
---|
360 | xFree(m_puhMergeIndex); |
---|
361 | m_puhMergeIndex = NULL; |
---|
362 | } |
---|
363 | |
---|
364 | #if H_3D_VSP |
---|
365 | if ( m_piVSPFlag ) { xFree(m_piVSPFlag); m_piVSPFlag = NULL; } |
---|
366 | #endif |
---|
367 | #if H_3D_SPIVMP |
---|
368 | if ( m_pbSPIVMPFlag ) { xFree(m_pbSPIVMPFlag); m_pbSPIVMPFlag = NULL; } |
---|
369 | #endif |
---|
370 | |
---|
371 | |
---|
372 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
373 | { |
---|
374 | xFree(m_puhIntraDir[ch]); |
---|
375 | m_puhIntraDir[ch] = NULL; |
---|
376 | } |
---|
377 | |
---|
378 | if ( m_puhTrIdx ) |
---|
379 | { |
---|
380 | xFree(m_puhTrIdx); |
---|
381 | m_puhTrIdx = NULL; |
---|
382 | } |
---|
383 | |
---|
384 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
385 | { |
---|
386 | if ( m_crossComponentPredictionAlpha[comp] ) |
---|
387 | { |
---|
388 | xFree(m_crossComponentPredictionAlpha[comp]); |
---|
389 | m_crossComponentPredictionAlpha[comp] = NULL; |
---|
390 | } |
---|
391 | if ( m_puhTransformSkip[comp] ) |
---|
392 | { |
---|
393 | xFree(m_puhTransformSkip[comp]); |
---|
394 | m_puhTransformSkip[comp] = NULL; |
---|
395 | } |
---|
396 | if ( m_puhCbf[comp] ) |
---|
397 | { |
---|
398 | xFree(m_puhCbf[comp]); |
---|
399 | m_puhCbf[comp] = NULL; |
---|
400 | } |
---|
401 | if ( m_pcTrCoeff[comp] ) |
---|
402 | { |
---|
403 | xFree(m_pcTrCoeff[comp]); |
---|
404 | m_pcTrCoeff[comp] = NULL; |
---|
405 | } |
---|
406 | if ( m_explicitRdpcmMode[comp] ) |
---|
407 | { |
---|
408 | xFree(m_explicitRdpcmMode[comp]); |
---|
409 | m_explicitRdpcmMode[comp] = NULL; |
---|
410 | } |
---|
411 | |
---|
412 | #if ADAPTIVE_QP_SELECTION |
---|
413 | if (!m_ArlCoeffIsAliasedAllocation) |
---|
414 | { |
---|
415 | if ( m_pcArlCoeff[comp] ) |
---|
416 | { |
---|
417 | xFree(m_pcArlCoeff[comp]); |
---|
418 | m_pcArlCoeff[comp] = NULL; |
---|
419 | } |
---|
420 | } |
---|
421 | #endif |
---|
422 | |
---|
423 | if ( m_pcIPCMSample[comp] ) |
---|
424 | { |
---|
425 | xFree(m_pcIPCMSample[comp]); |
---|
426 | m_pcIPCMSample[comp] = NULL; |
---|
427 | } |
---|
428 | } |
---|
429 | if ( m_pbIPCMFlag ) |
---|
430 | { |
---|
431 | xFree(m_pbIPCMFlag ); |
---|
432 | m_pbIPCMFlag = NULL; |
---|
433 | } |
---|
434 | |
---|
435 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
436 | { |
---|
437 | const RefPicList rpl=RefPicList(i); |
---|
438 | if ( m_apiMVPIdx[rpl] ) |
---|
439 | { |
---|
440 | delete[] m_apiMVPIdx[rpl]; |
---|
441 | m_apiMVPIdx[rpl] = NULL; |
---|
442 | } |
---|
443 | if ( m_apiMVPNum[rpl] ) |
---|
444 | { |
---|
445 | delete[] m_apiMVPNum[rpl]; |
---|
446 | m_apiMVPNum[rpl] = NULL; |
---|
447 | } |
---|
448 | } |
---|
449 | |
---|
450 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
451 | { |
---|
452 | const RefPicList rpl=RefPicList(i); |
---|
453 | m_acCUMvField[rpl].destroy(); |
---|
454 | } |
---|
455 | #if H_3D_NBDV |
---|
456 | if ( m_pDvInfo ) { xFree(m_pDvInfo); m_pDvInfo = NULL; } |
---|
457 | #endif |
---|
458 | |
---|
459 | |
---|
460 | #if H_3D_ARP |
---|
461 | if ( m_puhARPW ) { delete[] m_puhARPW; m_puhARPW = NULL; } |
---|
462 | #endif |
---|
463 | #if H_3D_IC |
---|
464 | if ( m_pbICFlag ) { xFree(m_pbICFlag); m_pbICFlag = NULL; } |
---|
465 | #endif |
---|
466 | |
---|
467 | #if NH_3D_DMM |
---|
468 | for( Int i = 0; i < NUM_DMM; i++ ) |
---|
469 | { |
---|
470 | if ( m_dmmDeltaDC[i][0] ) { xFree( m_dmmDeltaDC[i][0] ); m_dmmDeltaDC[i][0] = NULL; } |
---|
471 | if ( m_dmmDeltaDC[i][1] ) { xFree( m_dmmDeltaDC[i][1] ); m_dmmDeltaDC[i][1] = NULL; } |
---|
472 | } |
---|
473 | if ( m_dmm1WedgeTabIdx ) { xFree( m_dmm1WedgeTabIdx ); m_dmm1WedgeTabIdx = NULL; } |
---|
474 | #endif |
---|
475 | #if NH_3D_SDC_INTRA |
---|
476 | if ( m_pbSDCFlag ) { xFree(m_pbSDCFlag); m_pbSDCFlag = NULL; } |
---|
477 | if ( m_apSegmentDCOffset[0] ) { xFree(m_apSegmentDCOffset[0]); m_apSegmentDCOffset[0] = NULL; } |
---|
478 | if ( m_apSegmentDCOffset[1] ) { xFree(m_apSegmentDCOffset[1]); m_apSegmentDCOffset[1] = NULL; } |
---|
479 | #endif |
---|
480 | #if H_3D_DBBP |
---|
481 | if ( m_pbDBBPFlag ) { xFree(m_pbDBBPFlag); m_pbDBBPFlag = NULL; } |
---|
482 | #endif |
---|
483 | |
---|
484 | } |
---|
485 | |
---|
486 | m_pcPic = NULL; |
---|
487 | m_pcSlice = NULL; |
---|
488 | |
---|
489 | m_pCtuAboveLeft = NULL; |
---|
490 | m_pCtuAboveRight = NULL; |
---|
491 | m_pCtuAbove = NULL; |
---|
492 | m_pCtuLeft = NULL; |
---|
493 | |
---|
494 | |
---|
495 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
496 | { |
---|
497 | m_apcCUColocated[i] = NULL; |
---|
498 | } |
---|
499 | |
---|
500 | } |
---|
501 | |
---|
502 | Bool TComDataCU::CUIsFromSameTile ( const TComDataCU *pCU /* Can be NULL */) const |
---|
503 | { |
---|
504 | return pCU!=NULL && |
---|
505 | pCU->getSlice() != NULL && |
---|
506 | m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()); |
---|
507 | } |
---|
508 | |
---|
509 | Bool TComDataCU::CUIsFromSameSliceAndTile ( const TComDataCU *pCU /* Can be NULL */) const |
---|
510 | { |
---|
511 | return pCU!=NULL && |
---|
512 | pCU->getSlice() != NULL && |
---|
513 | pCU->getSlice()->getSliceCurStartCtuTsAddr() == getSlice()->getSliceCurStartCtuTsAddr() && |
---|
514 | m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()) |
---|
515 | ; |
---|
516 | } |
---|
517 | |
---|
518 | Bool TComDataCU::CUIsFromSameSliceTileAndWavefrontRow( const TComDataCU *pCU /* Can be NULL */) const |
---|
519 | { |
---|
520 | return CUIsFromSameSliceAndTile(pCU) |
---|
521 | && (!getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() || getPic()->getCtu(getCtuRsAddr())->getCUPelY() == getPic()->getCtu(pCU->getCtuRsAddr())->getCUPelY()); |
---|
522 | } |
---|
523 | |
---|
524 | Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx) |
---|
525 | { |
---|
526 | const TComSPS &sps=*(getSlice()->getSPS()); |
---|
527 | |
---|
528 | const UInt picWidth = sps.getPicWidthInLumaSamples(); |
---|
529 | const UInt picHeight = sps.getPicHeightInLumaSamples(); |
---|
530 | const UInt granularityWidth = sps.getMaxCUWidth(); |
---|
531 | |
---|
532 | const UInt cuPosX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[absPartIdx] ]; |
---|
533 | const UInt cuPosY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[absPartIdx] ]; |
---|
534 | |
---|
535 | return (((cuPosX+getWidth( absPartIdx))%granularityWidth==0||(cuPosX+getWidth( absPartIdx)==picWidth )) |
---|
536 | && ((cuPosY+getHeight(absPartIdx))%granularityWidth==0||(cuPosY+getHeight(absPartIdx)==picHeight))); |
---|
537 | } |
---|
538 | |
---|
539 | // ==================================================================================================================== |
---|
540 | // Public member functions |
---|
541 | // ==================================================================================================================== |
---|
542 | |
---|
543 | // -------------------------------------------------------------------------------------------------------------------- |
---|
544 | // Initialization |
---|
545 | // -------------------------------------------------------------------------------------------------------------------- |
---|
546 | |
---|
547 | /** |
---|
548 | Initialize top-level CU: create internal buffers and set initial values before encoding the CTU. |
---|
549 | |
---|
550 | \param pcPic picture (TComPic) class pointer |
---|
551 | \param ctuRsAddr CTU address in raster scan order |
---|
552 | */ |
---|
553 | Void TComDataCU::initCtu( TComPic* pcPic, UInt ctuRsAddr ) |
---|
554 | { |
---|
555 | |
---|
556 | const UInt maxCUWidth = pcPic->getPicSym()->getSPS().getMaxCUWidth(); |
---|
557 | const UInt maxCUHeight= pcPic->getPicSym()->getSPS().getMaxCUHeight(); |
---|
558 | m_pcPic = pcPic; |
---|
559 | m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
560 | m_ctuRsAddr = ctuRsAddr; |
---|
561 | m_uiCUPelX = ( ctuRsAddr % pcPic->getFrameWidthInCtus() ) * maxCUWidth; |
---|
562 | m_uiCUPelY = ( ctuRsAddr / pcPic->getFrameWidthInCtus() ) * maxCUHeight; |
---|
563 | m_absZIdxInCtu = 0; |
---|
564 | m_dTotalCost = MAX_DOUBLE; |
---|
565 | m_uiTotalDistortion = 0; |
---|
566 | m_uiTotalBits = 0; |
---|
567 | m_uiTotalBins = 0; |
---|
568 | m_uiNumPartition = pcPic->getNumPartitionsInCtu(); |
---|
569 | |
---|
570 | memset( m_skipFlag , false, m_uiNumPartition * sizeof( *m_skipFlag ) ); |
---|
571 | |
---|
572 | #if NH_3D_DIS |
---|
573 | memset( m_bDISFlag , false, m_uiNumPartition * sizeof( *m_bDISFlag ) ); |
---|
574 | memset( m_ucDISType , false, m_uiNumPartition * sizeof( *m_ucDISType ) ); |
---|
575 | #endif |
---|
576 | |
---|
577 | memset( m_pePartSize , NUMBER_OF_PART_SIZES, m_uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
578 | memset( m_pePredMode , NUMBER_OF_PREDICTION_MODES, m_uiNumPartition * sizeof( *m_pePredMode ) ); |
---|
579 | memset( m_CUTransquantBypass, false, m_uiNumPartition * sizeof( *m_CUTransquantBypass) ); |
---|
580 | memset( m_puhDepth , 0, m_uiNumPartition * sizeof( *m_puhDepth ) ); |
---|
581 | memset( m_puhTrIdx , 0, m_uiNumPartition * sizeof( *m_puhTrIdx ) ); |
---|
582 | memset( m_puhWidth , maxCUWidth, m_uiNumPartition * sizeof( *m_puhWidth ) ); |
---|
583 | memset( m_puhHeight , maxCUHeight, m_uiNumPartition * sizeof( *m_puhHeight ) ); |
---|
584 | |
---|
585 | #if H_3D_ARP |
---|
586 | m_puhARPW [ui] = pcFrom->getARPW( ui ); |
---|
587 | #endif |
---|
588 | #if H_3D_IC |
---|
589 | m_pbICFlag[ui] = pcFrom->m_pbICFlag[ui]; |
---|
590 | #endif |
---|
591 | |
---|
592 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
593 | { |
---|
594 | const RefPicList rpl=RefPicList(i); |
---|
595 | memset( m_apiMVPIdx[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPIdx[rpl] ) ); |
---|
596 | memset( m_apiMVPNum[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPNum[rpl] ) ); |
---|
597 | } |
---|
598 | memset( m_phQP , getSlice()->getSliceQp(), m_uiNumPartition * sizeof( *m_phQP ) ); |
---|
599 | memset( m_ChromaQpAdj , 0, m_uiNumPartition * sizeof( *m_ChromaQpAdj ) ); |
---|
600 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
601 | { |
---|
602 | memset( m_crossComponentPredictionAlpha[comp] , 0, m_uiNumPartition * sizeof( *m_crossComponentPredictionAlpha[comp] ) ); |
---|
603 | memset( m_puhTransformSkip[comp] , 0, m_uiNumPartition * sizeof( *m_puhTransformSkip[comp]) ); |
---|
604 | memset( m_puhCbf[comp] , 0, m_uiNumPartition * sizeof( *m_puhCbf[comp] ) ); |
---|
605 | memset( m_explicitRdpcmMode[comp] , NUMBER_OF_RDPCM_MODES, m_uiNumPartition * sizeof( *m_explicitRdpcmMode[comp] ) ); |
---|
606 | } |
---|
607 | memset( m_pbMergeFlag , false, m_uiNumPartition * sizeof( *m_pbMergeFlag ) ); |
---|
608 | memset( m_puhMergeIndex , 0, m_uiNumPartition * sizeof( *m_puhMergeIndex ) ); |
---|
609 | |
---|
610 | #if H_3D_VSP |
---|
611 | m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui]; |
---|
612 | #endif |
---|
613 | #if H_3D_SPIVMP |
---|
614 | m_pbSPIVMPFlag[ui] = pcFrom->m_pbSPIVMPFlag[ui]; |
---|
615 | #endif |
---|
616 | #if NH_3D_SDC_INTRA |
---|
617 | memset( m_pbSDCFlag, false, m_uiNumPartition * sizeof( *m_pbSDCFlag ) ); |
---|
618 | #endif |
---|
619 | #if H_3D_DBBP |
---|
620 | m_pbDBBPFlag[ui] = pcFrom->m_pbDBBPFlag[ui]; |
---|
621 | #endif |
---|
622 | #if H_3D_VSP |
---|
623 | memset( m_piVSPFlag + firstElement, 0, numElements * sizeof( *m_piVSPFlag ) ); |
---|
624 | #endif |
---|
625 | #if H_3D_SPIVMP |
---|
626 | memset( m_pbSPIVMPFlag + firstElement, 0, numElements * sizeof( *m_pbSPIVMPFlag ) ); |
---|
627 | #endif |
---|
628 | |
---|
629 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
630 | { |
---|
631 | memset( m_puhIntraDir[ch] , ((ch==0) ? DC_IDX : 0), m_uiNumPartition * sizeof( *(m_puhIntraDir[ch]) ) ); |
---|
632 | } |
---|
633 | |
---|
634 | #if H_3D_ARP |
---|
635 | memset( m_puhARPW + firstElement, 0, numElements * sizeof( UChar ) ); |
---|
636 | #endif |
---|
637 | #if H_3D_IC |
---|
638 | memset( m_pbICFlag + firstElement, false, numElements * sizeof( *m_pbICFlag ) ); |
---|
639 | #endif |
---|
640 | |
---|
641 | |
---|
642 | |
---|
643 | #if NH_3D_DMM |
---|
644 | for( Int i = 0; i < NUM_DMM; i++ ) |
---|
645 | { |
---|
646 | memset( m_dmmDeltaDC[i][0], 0, m_uiNumPartition * sizeof( *m_dmmDeltaDC[i][0] ) ); |
---|
647 | memset( m_dmmDeltaDC[i][1], 0, m_uiNumPartition * sizeof( *m_dmmDeltaDC[i][1] ) ); |
---|
648 | } |
---|
649 | memset( m_dmm1WedgeTabIdx, 0, m_uiNumPartition * sizeof( *m_dmm1WedgeTabIdx ) ); |
---|
650 | #endif |
---|
651 | #if NH_3D_SDC_INTRA |
---|
652 | memset( m_pbSDCFlag, false, m_uiNumPartition * sizeof( *m_pbSDCFlag ) ); |
---|
653 | memset( m_apSegmentDCOffset[0], 0, m_uiNumPartition * sizeof( *m_apSegmentDCOffset[0] ) ); |
---|
654 | memset( m_apSegmentDCOffset[1], 0, m_uiNumPartition * sizeof( *m_apSegmentDCOffset[1] ) ); |
---|
655 | #endif |
---|
656 | #if H_3D_DBBP |
---|
657 | memset( m_pbDBBPFlag + firstElement, false, numElements * sizeof( *m_pbDBBPFlag ) ); |
---|
658 | #endif |
---|
659 | |
---|
660 | memset( m_puhInterDir , 0, m_uiNumPartition * sizeof( *m_puhInterDir ) ); |
---|
661 | memset( m_pbIPCMFlag , false, m_uiNumPartition * sizeof( *m_pbIPCMFlag ) ); |
---|
662 | |
---|
663 | const UInt numCoeffY = maxCUWidth*maxCUHeight; |
---|
664 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
665 | { |
---|
666 | const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(comp)) + m_pcPic->getComponentScaleY(ComponentID(comp)); |
---|
667 | memset( m_pcTrCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); |
---|
668 | #if ADAPTIVE_QP_SELECTION |
---|
669 | memset( m_pcArlCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); |
---|
670 | #endif |
---|
671 | } |
---|
672 | |
---|
673 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
674 | { |
---|
675 | m_acCUMvField[i].clearMvField(); |
---|
676 | } |
---|
677 | |
---|
678 | // Setting neighbor CU |
---|
679 | m_pCtuLeft = NULL; |
---|
680 | m_pCtuAbove = NULL; |
---|
681 | m_pCtuAboveLeft = NULL; |
---|
682 | m_pCtuAboveRight = NULL; |
---|
683 | |
---|
684 | |
---|
685 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
686 | { |
---|
687 | m_apcCUColocated[i] = NULL; |
---|
688 | } |
---|
689 | |
---|
690 | UInt frameWidthInCtus = pcPic->getFrameWidthInCtus(); |
---|
691 | if ( m_ctuRsAddr % frameWidthInCtus ) |
---|
692 | { |
---|
693 | m_pCtuLeft = pcPic->getCtu( m_ctuRsAddr - 1 ); |
---|
694 | } |
---|
695 | |
---|
696 | if ( m_ctuRsAddr / frameWidthInCtus ) |
---|
697 | { |
---|
698 | m_pCtuAbove = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus ); |
---|
699 | } |
---|
700 | |
---|
701 | if ( m_pCtuLeft && m_pCtuAbove ) |
---|
702 | { |
---|
703 | m_pCtuAboveLeft = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus - 1 ); |
---|
704 | } |
---|
705 | |
---|
706 | if ( m_pCtuAbove && ( (m_ctuRsAddr%frameWidthInCtus) < (frameWidthInCtus-1) ) ) |
---|
707 | { |
---|
708 | m_pCtuAboveRight = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus + 1 ); |
---|
709 | } |
---|
710 | |
---|
711 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
712 | { |
---|
713 | const RefPicList rpl=RefPicList(i); |
---|
714 | if ( getSlice()->getNumRefIdx( rpl ) > 0 ) |
---|
715 | { |
---|
716 | m_apcCUColocated[rpl] = getSlice()->getRefPic( rpl, 0)->getCtu( m_ctuRsAddr ); |
---|
717 | } |
---|
718 | } |
---|
719 | } |
---|
720 | |
---|
721 | |
---|
722 | /** Initialize prediction data with enabling sub-CTU-level delta QP. |
---|
723 | * - set CU width and CU height according to depth |
---|
724 | * - set qp value according to input qp |
---|
725 | * - set last-coded qp value according to input last-coded qp |
---|
726 | * |
---|
727 | * \param uiDepth depth of the current CU |
---|
728 | * \param qp qp for the current CU |
---|
729 | * \param bTransquantBypass true for transquant bypass |
---|
730 | */ |
---|
731 | Void TComDataCU::initEstData( const UInt uiDepth, const Int qp, const Bool bTransquantBypass ) |
---|
732 | { |
---|
733 | m_dTotalCost = MAX_DOUBLE; |
---|
734 | m_uiTotalDistortion = 0; |
---|
735 | m_uiTotalBits = 0; |
---|
736 | m_uiTotalBins = 0; |
---|
737 | |
---|
738 | const UChar uhWidth = getSlice()->getSPS()->getMaxCUWidth() >> uiDepth; |
---|
739 | const UChar uhHeight = getSlice()->getSPS()->getMaxCUHeight() >> uiDepth; |
---|
740 | |
---|
741 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
742 | { |
---|
743 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
744 | { |
---|
745 | const RefPicList rpl=RefPicList(i); |
---|
746 | m_apiMVPIdx[rpl][ui] = -1; |
---|
747 | m_apiMVPNum[rpl][ui] = -1; |
---|
748 | } |
---|
749 | m_puhDepth [ui] = uiDepth; |
---|
750 | m_puhWidth [ui] = uhWidth; |
---|
751 | m_puhHeight [ui] = uhHeight; |
---|
752 | m_puhTrIdx [ui] = 0; |
---|
753 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
754 | { |
---|
755 | m_crossComponentPredictionAlpha[comp][ui] = 0; |
---|
756 | m_puhTransformSkip [comp][ui] = 0; |
---|
757 | m_explicitRdpcmMode [comp][ui] = NUMBER_OF_RDPCM_MODES; |
---|
758 | } |
---|
759 | m_skipFlag[ui] = false; |
---|
760 | #if NH_3D_DIS |
---|
761 | m_bDISFlag[ui] = false; |
---|
762 | m_ucDISType[ui] = 0; |
---|
763 | #endif |
---|
764 | m_pePartSize[ui] = NUMBER_OF_PART_SIZES; |
---|
765 | m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; |
---|
766 | m_CUTransquantBypass[ui] = bTransquantBypass; |
---|
767 | m_pbIPCMFlag[ui] = 0; |
---|
768 | m_phQP[ui] = qp; |
---|
769 | m_ChromaQpAdj[ui] = 0; |
---|
770 | m_pbMergeFlag[ui] = 0; |
---|
771 | m_puhMergeIndex[ui] = 0; |
---|
772 | #if H_3D_VSP |
---|
773 | m_piVSPFlag[ui] = 0; |
---|
774 | #endif |
---|
775 | #if H_3D_SPIVMP |
---|
776 | m_pbSPIVMPFlag[ui] = 0; |
---|
777 | #endif |
---|
778 | |
---|
779 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
780 | { |
---|
781 | m_puhIntraDir[ch][ui] = ((ch==0) ? DC_IDX : 0); |
---|
782 | } |
---|
783 | |
---|
784 | m_puhInterDir[ui] = 0; |
---|
785 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
786 | { |
---|
787 | m_puhCbf[comp][ui] = 0; |
---|
788 | } |
---|
789 | #if H_3D_ARP |
---|
790 | m_puhARPW[ui] = 0; |
---|
791 | #endif |
---|
792 | #if H_3D_IC |
---|
793 | m_pbICFlag[ui] = false; |
---|
794 | #endif |
---|
795 | |
---|
796 | |
---|
797 | #if NH_3D_DMM |
---|
798 | for( Int i = 0; i < NUM_DMM; i++ ) |
---|
799 | { |
---|
800 | m_dmmDeltaDC[i][0] [ui] = 0; |
---|
801 | m_dmmDeltaDC[i][1] [ui] = 0; |
---|
802 | } |
---|
803 | m_dmm1WedgeTabIdx [ui] = 0; |
---|
804 | #endif |
---|
805 | #if NH_3D_SDC_INTRA |
---|
806 | m_pbSDCFlag [ui] = false; |
---|
807 | m_apSegmentDCOffset[0][ui] = 0; |
---|
808 | m_apSegmentDCOffset[1][ui] = 0; |
---|
809 | #endif |
---|
810 | #if H_3D_DBBP |
---|
811 | m_pbDBBPFlag[ui] = false; |
---|
812 | #endif |
---|
813 | } |
---|
814 | |
---|
815 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
816 | { |
---|
817 | m_acCUMvField[i].clearMvField(); |
---|
818 | } |
---|
819 | |
---|
820 | const UInt numCoeffY = uhWidth*uhHeight; |
---|
821 | |
---|
822 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
823 | { |
---|
824 | const ComponentID component = ComponentID(comp); |
---|
825 | const UInt numCoeff = numCoeffY >> (getPic()->getComponentScaleX(component) + getPic()->getComponentScaleY(component)); |
---|
826 | memset( m_pcTrCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); |
---|
827 | #if ADAPTIVE_QP_SELECTION |
---|
828 | memset( m_pcArlCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); |
---|
829 | #endif |
---|
830 | memset( m_pcIPCMSample[comp], 0, numCoeff * sizeof( Pel) ); |
---|
831 | } |
---|
832 | } |
---|
833 | |
---|
834 | |
---|
835 | // initialize Sub partition |
---|
836 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ) |
---|
837 | { |
---|
838 | assert( uiPartUnitIdx<4 ); |
---|
839 | |
---|
840 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
---|
841 | |
---|
842 | m_pcPic = pcCU->getPic(); |
---|
843 | m_pcSlice = pcCU->getSlice(); |
---|
844 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
845 | m_absZIdxInCtu = pcCU->getZorderIdxInCtu() + uiPartOffset; |
---|
846 | |
---|
847 | const UChar uhWidth = getSlice()->getSPS()->getMaxCUWidth() >> uiDepth; |
---|
848 | const UChar uhHeight = getSlice()->getSPS()->getMaxCUHeight() >> uiDepth; |
---|
849 | |
---|
850 | m_uiCUPelX = pcCU->getCUPelX() + ( uhWidth )*( uiPartUnitIdx & 1 ); |
---|
851 | m_uiCUPelY = pcCU->getCUPelY() + ( uhHeight)*( uiPartUnitIdx >> 1 ); |
---|
852 | |
---|
853 | m_dTotalCost = MAX_DOUBLE; |
---|
854 | m_uiTotalDistortion = 0; |
---|
855 | m_uiTotalBits = 0; |
---|
856 | m_uiTotalBins = 0; |
---|
857 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
---|
858 | |
---|
859 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
860 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
861 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
862 | |
---|
863 | memset( m_phQP, qp, sizeInChar ); |
---|
864 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
865 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
866 | #if H_3D_VSP |
---|
867 | memset( m_piVSPFlag, 0, sizeof( Char ) * m_uiNumPartition ); |
---|
868 | #endif |
---|
869 | #if H_3D_SPIVMP |
---|
870 | memset( m_pbSPIVMPFlag, 0, sizeof( Bool ) * m_uiNumPartition ); |
---|
871 | #endif |
---|
872 | |
---|
873 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
874 | { |
---|
875 | memset( m_puhIntraDir[ch], ((ch==0) ? DC_IDX : 0), iSizeInUchar ); |
---|
876 | } |
---|
877 | |
---|
878 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
879 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
880 | |
---|
881 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
882 | { |
---|
883 | memset( m_crossComponentPredictionAlpha[comp], 0, iSizeInUchar ); |
---|
884 | memset( m_puhTransformSkip[comp], 0, iSizeInUchar ); |
---|
885 | memset( m_puhCbf[comp], 0, iSizeInUchar ); |
---|
886 | memset( m_explicitRdpcmMode[comp], NUMBER_OF_RDPCM_MODES, iSizeInUchar ); |
---|
887 | } |
---|
888 | #if H_3D_ARP |
---|
889 | memset( m_puhARPW, 0, iSizeInUchar ); |
---|
890 | #endif |
---|
891 | |
---|
892 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
---|
893 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
894 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
895 | memset( m_pbIPCMFlag, 0, iSizeInBool ); |
---|
896 | #if H_3D_IC |
---|
897 | memset( m_pbICFlag, 0, iSizeInBool ); |
---|
898 | #endif |
---|
899 | #if NH_3D_DMM |
---|
900 | for( Int i = 0; i < NUM_DMM; i++ ) |
---|
901 | { |
---|
902 | memset( m_dmmDeltaDC[i][0], 0, sizeof(Pel ) * m_uiNumPartition ); |
---|
903 | memset( m_dmmDeltaDC[i][1], 0, sizeof(Pel ) * m_uiNumPartition ); |
---|
904 | } |
---|
905 | memset( m_dmm1WedgeTabIdx, 0, sizeof(UInt) * m_uiNumPartition ); |
---|
906 | #endif |
---|
907 | #if NH_3D_SDC_INTRA |
---|
908 | memset( m_pbSDCFlag, 0, sizeof(Bool) * m_uiNumPartition ); |
---|
909 | memset( m_apSegmentDCOffset[0], 0, sizeof(Pel) * m_uiNumPartition ); |
---|
910 | memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition ); |
---|
911 | #endif |
---|
912 | #if H_3D_DBBP |
---|
913 | memset( m_pbDBBPFlag, 0, iSizeInBool ); |
---|
914 | #endif |
---|
915 | |
---|
916 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
917 | { |
---|
918 | m_skipFlag[ui] = false; |
---|
919 | #if NH_3D_DIS |
---|
920 | m_bDISFlag[ui] = false; |
---|
921 | m_ucDISType[ui] = 0; |
---|
922 | #endif |
---|
923 | |
---|
924 | m_pePartSize[ui] = NUMBER_OF_PART_SIZES; |
---|
925 | m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; |
---|
926 | m_CUTransquantBypass[ui] = false; |
---|
927 | m_ChromaQpAdj[ui] = 0; |
---|
928 | |
---|
929 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
930 | { |
---|
931 | const RefPicList rpl=RefPicList(i); |
---|
932 | m_apiMVPIdx[rpl][ui] = -1; |
---|
933 | m_apiMVPNum[rpl][ui] = -1; |
---|
934 | } |
---|
935 | #if NH_3D_DIS |
---|
936 | m_bDISFlag[ui] = pcCU->getDISFlag(uiPartOffset+ui); |
---|
937 | m_ucDISType[ui] = pcCU->getDISType(uiPartOffset+ui); |
---|
938 | #endif |
---|
939 | #if H_3D_VSP |
---|
940 | m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui]; |
---|
941 | m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui]; |
---|
942 | #endif |
---|
943 | #if H_3D_SPIVMP |
---|
944 | m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui]; |
---|
945 | #endif |
---|
946 | #if H_3D_ARP |
---|
947 | m_puhARPW [ui] = pcCU->getARPW( uiPartOffset+ui ); |
---|
948 | #endif |
---|
949 | #if H_3D_IC |
---|
950 | m_pbICFlag [ui] = pcCU->m_pbICFlag[uiPartOffset+ui]; |
---|
951 | #endif |
---|
952 | #if NH_3D_DMM |
---|
953 | for( Int i = 0; i < NUM_DMM; i++ ) |
---|
954 | { |
---|
955 | m_dmmDeltaDC[i][0] [ui] = pcCU->m_dmmDeltaDC[i][0] [uiPartOffset+ui]; |
---|
956 | m_dmmDeltaDC[i][1] [ui] = pcCU->m_dmmDeltaDC[i][1] [uiPartOffset+ui]; |
---|
957 | } |
---|
958 | m_dmm1WedgeTabIdx [ui] = pcCU->m_dmm1WedgeTabIdx [uiPartOffset+ui]; |
---|
959 | #endif |
---|
960 | #if NH_3D_SDC_INTRA |
---|
961 | m_pbSDCFlag [ui] = pcCU->m_pbSDCFlag [ uiPartOffset + ui ]; |
---|
962 | m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0] [ uiPartOffset + ui ]; |
---|
963 | m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ]; |
---|
964 | #endif |
---|
965 | #if H_3D_DBBP |
---|
966 | m_pbDBBPFlag[ui]=pcCU->m_pbDBBPFlag[uiPartOffset+ui]; |
---|
967 | #endif |
---|
968 | } |
---|
969 | |
---|
970 | const UInt numCoeffY = uhWidth*uhHeight; |
---|
971 | for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
972 | { |
---|
973 | const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(ch)) + m_pcPic->getComponentScaleY(ComponentID(ch)); |
---|
974 | memset( m_pcTrCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
975 | #if ADAPTIVE_QP_SELECTION |
---|
976 | memset( m_pcArlCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
977 | #endif |
---|
978 | memset( m_pcIPCMSample[ch], 0, sizeof(Pel)* (numCoeffY>>componentShift) ); |
---|
979 | } |
---|
980 | |
---|
981 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
982 | { |
---|
983 | m_acCUMvField[i].clearMvField(); |
---|
984 | } |
---|
985 | |
---|
986 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
987 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
988 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
989 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
990 | |
---|
991 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
992 | { |
---|
993 | m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); |
---|
994 | } |
---|
995 | } |
---|
996 | |
---|
997 | Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
998 | { |
---|
999 | const UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); |
---|
1000 | const UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
1001 | const TComSPS &sps = *(getSlice()->getSPS()); |
---|
1002 | const UChar uhWidth = sps.getMaxCUWidth() >> uiDepth; |
---|
1003 | const UChar uhHeight = sps.getMaxCUHeight() >> uiDepth; |
---|
1004 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); |
---|
1005 | memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); |
---|
1006 | memset( m_puhHeight + uiAbsPartIdx, uhHeight, uiSizeInUchar ); |
---|
1007 | } |
---|
1008 | |
---|
1009 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1010 | // Copy |
---|
1011 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1012 | |
---|
1013 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1014 | { |
---|
1015 | UInt uiPart = uiAbsPartIdx; |
---|
1016 | |
---|
1017 | m_pcPic = pcCU->getPic(); |
---|
1018 | m_pcSlice = pcCU->getSlice(); |
---|
1019 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
1020 | m_absZIdxInCtu = uiAbsPartIdx; |
---|
1021 | |
---|
1022 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1023 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1024 | |
---|
1025 | m_skipFlag=pcCU->getSkipFlag() + uiPart; |
---|
1026 | #if NH_3D_DIS |
---|
1027 | m_bDISFlag = pcCU->getDISFlag() + uiPart; |
---|
1028 | m_ucDISType = pcCU->getDISType() + uiPart; |
---|
1029 | #endif |
---|
1030 | |
---|
1031 | m_phQP=pcCU->getQP() + uiPart; |
---|
1032 | m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiPart; |
---|
1033 | m_pePartSize = pcCU->getPartitionSize() + uiPart; |
---|
1034 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
---|
1035 | m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; |
---|
1036 | #if H_3D_NBDV |
---|
1037 | m_pDvInfo = pcCU->getDvInfo() + uiPart; |
---|
1038 | #endif |
---|
1039 | |
---|
1040 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
---|
1041 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
---|
1042 | #if H_3D_VSP |
---|
1043 | m_piVSPFlag = pcCU->getVSPFlag() + uiPart; |
---|
1044 | #endif |
---|
1045 | #if H_3D_SPIVMP |
---|
1046 | m_pbSPIVMPFlag = pcCU->getSPIVMPFlag() + uiPart; |
---|
1047 | #endif |
---|
1048 | #if H_3D_ARP |
---|
1049 | m_puhARPW = pcCU->getARPW() + uiPart; |
---|
1050 | #endif |
---|
1051 | #if H_3D_IC |
---|
1052 | m_pbICFlag = pcCU->getICFlag() + uiPart; |
---|
1053 | #endif |
---|
1054 | |
---|
1055 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
1056 | { |
---|
1057 | m_puhIntraDir[ch] = pcCU->getIntraDir(ChannelType(ch)) + uiPart; |
---|
1058 | } |
---|
1059 | |
---|
1060 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
---|
1061 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
---|
1062 | |
---|
1063 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
1064 | { |
---|
1065 | m_crossComponentPredictionAlpha[comp] = pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)) + uiPart; |
---|
1066 | m_puhTransformSkip[comp] = pcCU->getTransformSkip(ComponentID(comp)) + uiPart; |
---|
1067 | m_puhCbf[comp] = pcCU->getCbf(ComponentID(comp)) + uiPart; |
---|
1068 | m_explicitRdpcmMode[comp] = pcCU->getExplicitRdpcmMode(ComponentID(comp)) + uiPart; |
---|
1069 | } |
---|
1070 | #if NH_3D_DMM |
---|
1071 | for( Int i = 0; i < NUM_DMM; i++ ) |
---|
1072 | { |
---|
1073 | m_dmmDeltaDC[i][0] = pcCU->getDmmDeltaDC( (DmmID)i, 0 ) + uiPart; |
---|
1074 | m_dmmDeltaDC[i][1] = pcCU->getDmmDeltaDC( (DmmID)i, 1 ) + uiPart; |
---|
1075 | } |
---|
1076 | m_dmm1WedgeTabIdx = pcCU->getDmm1WedgeTabIdx() + uiPart; |
---|
1077 | #endif |
---|
1078 | #if NH_3D_SDC_INTRA |
---|
1079 | m_pbSDCFlag = pcCU->getSDCFlag() + uiPart; |
---|
1080 | m_apSegmentDCOffset[0] = pcCU->getSDCSegmentDCOffset(0) + uiPart; |
---|
1081 | m_apSegmentDCOffset[1] = pcCU->getSDCSegmentDCOffset(1) + uiPart; |
---|
1082 | #endif |
---|
1083 | #if H_3D_DBBP |
---|
1084 | m_pbDBBPFlag = pcCU->getDBBPFlag() + uiPart; |
---|
1085 | #endif |
---|
1086 | |
---|
1087 | m_puhDepth=pcCU->getDepth() + uiPart; |
---|
1088 | m_puhWidth=pcCU->getWidth() + uiPart; |
---|
1089 | m_puhHeight=pcCU->getHeight() + uiPart; |
---|
1090 | |
---|
1091 | m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; |
---|
1092 | |
---|
1093 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
1094 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
1095 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
1096 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
1097 | |
---|
1098 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1099 | { |
---|
1100 | const RefPicList rpl=RefPicList(i); |
---|
1101 | m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); |
---|
1102 | m_apiMVPIdx[rpl]=pcCU->getMVPIdx(rpl) + uiPart; |
---|
1103 | m_apiMVPNum[rpl]=pcCU->getMVPNum(rpl) + uiPart; |
---|
1104 | } |
---|
1105 | |
---|
1106 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1107 | { |
---|
1108 | const RefPicList rpl=RefPicList(i); |
---|
1109 | m_acCUMvField[rpl].linkToWithOffset( pcCU->getCUMvField(rpl), uiPart ); |
---|
1110 | } |
---|
1111 | |
---|
1112 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1113 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1114 | |
---|
1115 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartitionsInCtu(); |
---|
1116 | |
---|
1117 | for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
1118 | { |
---|
1119 | const ComponentID component = ComponentID(ch); |
---|
1120 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
1121 | const UInt offset = uiCoffOffset >> componentShift; |
---|
1122 | m_pcTrCoeff[ch] = pcCU->getCoeff(component) + offset; |
---|
1123 | #if ADAPTIVE_QP_SELECTION |
---|
1124 | m_pcArlCoeff[ch] = pcCU->getArlCoeff(component) + offset; |
---|
1125 | #endif |
---|
1126 | m_pcIPCMSample[ch] = pcCU->getPCMSample(component) + offset; |
---|
1127 | } |
---|
1128 | } |
---|
1129 | |
---|
1130 | #if H_3D_NBDV |
---|
1131 | Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx) |
---|
1132 | { |
---|
1133 | m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; |
---|
1134 | } |
---|
1135 | #endif |
---|
1136 | |
---|
1137 | // Copy inter prediction info from the biggest CU |
---|
1138 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList |
---|
1139 | #if H_3D_NBDV |
---|
1140 | , Bool bNBDV |
---|
1141 | #endif |
---|
1142 | ) |
---|
1143 | { |
---|
1144 | m_pcPic = pcCU->getPic(); |
---|
1145 | m_pcSlice = pcCU->getSlice(); |
---|
1146 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
1147 | m_absZIdxInCtu = uiAbsPartIdx; |
---|
1148 | |
---|
1149 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
1150 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInCtuWidth() ); |
---|
1151 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInCtuWidth() ); |
---|
1152 | |
---|
1153 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
1154 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
1155 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
1156 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
1157 | |
---|
1158 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1159 | { |
---|
1160 | m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); |
---|
1161 | } |
---|
1162 | |
---|
1163 | m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; |
---|
1164 | #if NH_3D_DIS |
---|
1165 | m_bDISFlag = pcCU->getDISFlag () + uiAbsPartIdx; |
---|
1166 | m_ucDISType = pcCU->getDISType() + uiAbsPartIdx; |
---|
1167 | #endif |
---|
1168 | |
---|
1169 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
---|
1170 | #if H_3D_NBDV |
---|
1171 | if(bNBDV == true) |
---|
1172 | { |
---|
1173 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
1174 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
1175 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
1176 | } |
---|
1177 | else |
---|
1178 | { |
---|
1179 | #endif |
---|
1180 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
---|
1181 | m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiAbsPartIdx; |
---|
1182 | m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; |
---|
1183 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
---|
1184 | |
---|
1185 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
1186 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
1187 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
1188 | |
---|
1189 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
1190 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
1191 | #if H_3D_VSP |
---|
1192 | m_piVSPFlag = pcCU->getVSPFlag() + uiAbsPartIdx; |
---|
1193 | m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; |
---|
1194 | #endif |
---|
1195 | #if H_3D_SPIVMP |
---|
1196 | m_pbSPIVMPFlag = pcCU->getSPIVMPFlag() + uiAbsPartIdx; |
---|
1197 | #endif |
---|
1198 | |
---|
1199 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
---|
1200 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
---|
1201 | #if H_3D_ARP |
---|
1202 | m_puhARPW = pcCU->getARPW() + uiAbsPartIdx; |
---|
1203 | #endif |
---|
1204 | #if H_3D_DBBP |
---|
1205 | m_pbDBBPFlag = pcCU->getDBBPFlag() + uiAbsPartIdx; |
---|
1206 | #endif |
---|
1207 | |
---|
1208 | m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); |
---|
1209 | #if H_3D_NBDV |
---|
1210 | } |
---|
1211 | #endif |
---|
1212 | #if H_3D_IC |
---|
1213 | m_pbICFlag = pcCU->getICFlag() + uiAbsPartIdx; |
---|
1214 | #endif |
---|
1215 | |
---|
1216 | } |
---|
1217 | |
---|
1218 | // Copy small CU to bigger CU. |
---|
1219 | // One of quarter parts overwritten by predicted sub part. |
---|
1220 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
1221 | { |
---|
1222 | assert( uiPartUnitIdx<4 ); |
---|
1223 | |
---|
1224 | m_dTotalCost += pcCU->getTotalCost(); |
---|
1225 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
---|
1226 | m_uiTotalBits += pcCU->getTotalBits(); |
---|
1227 | |
---|
1228 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
---|
1229 | const UInt numValidComp=pcCU->getPic()->getNumberValidComponents(); |
---|
1230 | const UInt numValidChan=pcCU->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; |
---|
1231 | |
---|
1232 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
---|
1233 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
1234 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
1235 | |
---|
1236 | Int sizeInChar = sizeof( Char ) * uiNumPartition; |
---|
1237 | memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); |
---|
1238 | #if NH_3D_DIS |
---|
1239 | memcpy( m_bDISFlag + uiOffset, pcCU->getDISFlag(), sizeof( *m_bDISFlag ) * uiNumPartition ); |
---|
1240 | memcpy( m_ucDISType + uiOffset, pcCU->getDISType(), sizeof( *m_ucDISType ) * uiNumPartition); |
---|
1241 | #endif |
---|
1242 | memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); |
---|
1243 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); |
---|
1244 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); |
---|
1245 | memcpy( m_ChromaQpAdj + uiOffset, pcCU->getChromaQpAdj(), sizeof( *m_ChromaQpAdj ) * uiNumPartition ); |
---|
1246 | memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); |
---|
1247 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
---|
1248 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
---|
1249 | #if H_3D_VSP |
---|
1250 | memcpy( m_piVSPFlag + uiOffset, pcCU->getVSPFlag(), sizeof( Char ) * uiNumPartition ); |
---|
1251 | memcpy( m_pDvInfo + uiOffset, pcCU->getDvInfo(), sizeof( *m_pDvInfo ) * uiNumPartition ); |
---|
1252 | #endif |
---|
1253 | #if H_3D_SPIVMP |
---|
1254 | memcpy( m_pbSPIVMPFlag + uiOffset, pcCU->getSPIVMPFlag(), sizeof( Bool ) * uiNumPartition ); |
---|
1255 | #endif |
---|
1256 | |
---|
1257 | for (UInt ch=0; ch<numValidChan; ch++) |
---|
1258 | { |
---|
1259 | memcpy( m_puhIntraDir[ch] + uiOffset, pcCU->getIntraDir(ChannelType(ch)), iSizeInUchar ); |
---|
1260 | } |
---|
1261 | |
---|
1262 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
---|
1263 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
---|
1264 | |
---|
1265 | for(UInt comp=0; comp<numValidComp; comp++) |
---|
1266 | { |
---|
1267 | memcpy( m_crossComponentPredictionAlpha[comp] + uiOffset, pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)), iSizeInUchar ); |
---|
1268 | memcpy( m_puhTransformSkip[comp] + uiOffset, pcCU->getTransformSkip(ComponentID(comp)) , iSizeInUchar ); |
---|
1269 | memcpy( m_puhCbf[comp] + uiOffset, pcCU->getCbf(ComponentID(comp)) , iSizeInUchar ); |
---|
1270 | memcpy( m_explicitRdpcmMode[comp] + uiOffset, pcCU->getExplicitRdpcmMode(ComponentID(comp)) , iSizeInUchar ); |
---|
1271 | } |
---|
1272 | #if NH_3D_DMM |
---|
1273 | for( Int i = 0; i < NUM_DMM; i++ ) |
---|
1274 | { |
---|
1275 | memcpy( m_dmmDeltaDC[i][0] + uiOffset, pcCU->getDmmDeltaDC( (DmmID)i, 0 ), sizeof(Pel ) * uiNumPartition ); |
---|
1276 | memcpy( m_dmmDeltaDC[i][1] + uiOffset, pcCU->getDmmDeltaDC( (DmmID)i, 1 ), sizeof(Pel ) * uiNumPartition ); |
---|
1277 | } |
---|
1278 | memcpy( m_dmm1WedgeTabIdx + uiOffset, pcCU->getDmm1WedgeTabIdx(), sizeof(UInt) * uiNumPartition ); |
---|
1279 | #endif |
---|
1280 | #if NH_3D_SDC_INTRA |
---|
1281 | memcpy( m_pbSDCFlag + uiOffset, pcCU->getSDCFlag(), sizeof( *m_pbSDCFlag ) * uiNumPartition ); |
---|
1282 | memcpy( m_apSegmentDCOffset[0] + uiOffset, pcCU->getSDCSegmentDCOffset(0), sizeof( Pel ) * uiNumPartition); |
---|
1283 | memcpy( m_apSegmentDCOffset[1] + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition); |
---|
1284 | #endif |
---|
1285 | #if H_3D_DBBP |
---|
1286 | memcpy( m_pbDBBPFlag + uiOffset, pcCU->getDBBPFlag(), iSizeInBool ); |
---|
1287 | #endif |
---|
1288 | |
---|
1289 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
---|
1290 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
---|
1291 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
---|
1292 | |
---|
1293 | memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); |
---|
1294 | |
---|
1295 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
1296 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
1297 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
1298 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
1299 | |
---|
1300 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1301 | { |
---|
1302 | const RefPicList rpl=RefPicList(i); |
---|
1303 | memcpy( m_apiMVPIdx[rpl] + uiOffset, pcCU->getMVPIdx(rpl), iSizeInUchar ); |
---|
1304 | memcpy( m_apiMVPNum[rpl] + uiOffset, pcCU->getMVPNum(rpl), iSizeInUchar ); |
---|
1305 | m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); |
---|
1306 | } |
---|
1307 | |
---|
1308 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1309 | { |
---|
1310 | const RefPicList rpl=RefPicList(i); |
---|
1311 | m_acCUMvField[rpl].copyFrom( pcCU->getCUMvField( rpl ), pcCU->getTotalNumPart(), uiOffset ); |
---|
1312 | } |
---|
1313 | |
---|
1314 | const UInt numCoeffY = (pcCU->getSlice()->getSPS()->getMaxCUWidth()*pcCU->getSlice()->getSPS()->getMaxCUHeight()) >> (uiDepth<<1); |
---|
1315 | const UInt offsetY = uiPartUnitIdx*numCoeffY; |
---|
1316 | for (UInt ch=0; ch<numValidComp; ch++) |
---|
1317 | { |
---|
1318 | const ComponentID component = ComponentID(ch); |
---|
1319 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
1320 | const UInt offset = offsetY>>componentShift; |
---|
1321 | memcpy( m_pcTrCoeff [ch] + offset, pcCU->getCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
1322 | #if ADAPTIVE_QP_SELECTION |
---|
1323 | memcpy( m_pcArlCoeff[ch] + offset, pcCU->getArlCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
1324 | #endif |
---|
1325 | memcpy( m_pcIPCMSample[ch] + offset, pcCU->getPCMSample(component), sizeof(Pel)*(numCoeffY>>componentShift) ); |
---|
1326 | } |
---|
1327 | |
---|
1328 | #if H_3D_ARP |
---|
1329 | memcpy( m_puhARPW + uiOffset, pcCU->getARPW(), iSizeInUchar ); |
---|
1330 | #endif |
---|
1331 | #if H_3D_IC |
---|
1332 | memcpy( m_pbICFlag + uiOffset, pcCU->getICFlag(), iSizeInBool ); |
---|
1333 | #endif |
---|
1334 | |
---|
1335 | m_uiTotalBins += pcCU->getTotalBins(); |
---|
1336 | } |
---|
1337 | |
---|
1338 | // Copy current predicted part to a CU in picture. |
---|
1339 | // It is used to predict for next part |
---|
1340 | Void TComDataCU::copyToPic( UChar uhDepth ) |
---|
1341 | { |
---|
1342 | TComDataCU* pCtu = m_pcPic->getCtu( m_ctuRsAddr ); |
---|
1343 | const UInt numValidComp=pCtu->getPic()->getNumberValidComponents(); |
---|
1344 | const UInt numValidChan=pCtu->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; |
---|
1345 | |
---|
1346 | pCtu->getTotalCost() = m_dTotalCost; |
---|
1347 | pCtu->getTotalDistortion() = m_uiTotalDistortion; |
---|
1348 | pCtu->getTotalBits() = m_uiTotalBits; |
---|
1349 | |
---|
1350 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
1351 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
1352 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
1353 | |
---|
1354 | memcpy( pCtu->getSkipFlag() + m_absZIdxInCtu, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); |
---|
1355 | #if NH_3D_DIS |
---|
1356 | memcpy( pCtu->getDISFlag() + m_absZIdxInCtu, m_bDISFlag, sizeof( *m_bDISFlag ) * m_uiNumPartition ); |
---|
1357 | memcpy( pCtu->getDISType() + m_absZIdxInCtu, m_ucDISType, sizeof( *m_ucDISType ) * m_uiNumPartition ); |
---|
1358 | #endif |
---|
1359 | |
---|
1360 | memcpy( pCtu->getQP() + m_absZIdxInCtu, m_phQP, sizeInChar ); |
---|
1361 | #if H_3D_NBDV |
---|
1362 | memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition ); |
---|
1363 | #endif |
---|
1364 | |
---|
1365 | memcpy( pCtu->getPartitionSize() + m_absZIdxInCtu, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); |
---|
1366 | memcpy( pCtu->getPredictionMode() + m_absZIdxInCtu, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); |
---|
1367 | memcpy( pCtu->getChromaQpAdj() + m_absZIdxInCtu, m_ChromaQpAdj, sizeof( *m_ChromaQpAdj ) * m_uiNumPartition ); |
---|
1368 | memcpy( pCtu->getCUTransquantBypass()+ m_absZIdxInCtu, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); |
---|
1369 | memcpy( pCtu->getMergeFlag() + m_absZIdxInCtu, m_pbMergeFlag, iSizeInBool ); |
---|
1370 | memcpy( pCtu->getMergeIndex() + m_absZIdxInCtu, m_puhMergeIndex, iSizeInUchar ); |
---|
1371 | #if H_3D_VSP |
---|
1372 | memcpy( rpcCU->getVSPFlag() + m_uiAbsIdxInLCU, m_piVSPFlag, sizeof( Char ) * m_uiNumPartition ); |
---|
1373 | memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof( *m_pDvInfo ) * m_uiNumPartition ); |
---|
1374 | #endif |
---|
1375 | #if H_3D_SPIVMP |
---|
1376 | memcpy( rpcCU->getSPIVMPFlag() + m_uiAbsIdxInLCU, m_pbSPIVMPFlag, sizeof( Bool ) * m_uiNumPartition ); |
---|
1377 | #endif |
---|
1378 | |
---|
1379 | for (UInt ch=0; ch<numValidChan; ch++) |
---|
1380 | { |
---|
1381 | memcpy( pCtu->getIntraDir(ChannelType(ch)) + m_absZIdxInCtu, m_puhIntraDir[ch], iSizeInUchar); |
---|
1382 | } |
---|
1383 | |
---|
1384 | memcpy( pCtu->getInterDir() + m_absZIdxInCtu, m_puhInterDir, iSizeInUchar ); |
---|
1385 | memcpy( pCtu->getTransformIdx() + m_absZIdxInCtu, m_puhTrIdx, iSizeInUchar ); |
---|
1386 | |
---|
1387 | for(UInt comp=0; comp<numValidComp; comp++) |
---|
1388 | { |
---|
1389 | memcpy( pCtu->getCrossComponentPredictionAlpha(ComponentID(comp)) + m_absZIdxInCtu, m_crossComponentPredictionAlpha[comp], iSizeInUchar ); |
---|
1390 | memcpy( pCtu->getTransformSkip(ComponentID(comp)) + m_absZIdxInCtu, m_puhTransformSkip[comp], iSizeInUchar ); |
---|
1391 | memcpy( pCtu->getCbf(ComponentID(comp)) + m_absZIdxInCtu, m_puhCbf[comp], iSizeInUchar ); |
---|
1392 | memcpy( pCtu->getExplicitRdpcmMode(ComponentID(comp)) + m_absZIdxInCtu, m_explicitRdpcmMode[comp], iSizeInUchar ); |
---|
1393 | } |
---|
1394 | |
---|
1395 | #if NH_3D_DMM |
---|
1396 | for( Int i = 0; i < NUM_DMM; i++ ) |
---|
1397 | { |
---|
1398 | memcpy( pCtu->getDmmDeltaDC( (DmmID)i, 0 ) + m_absZIdxInCtu, m_dmmDeltaDC[i][0], sizeof(Pel ) * m_uiNumPartition ); |
---|
1399 | memcpy( pCtu->getDmmDeltaDC( (DmmID)i, 1 ) + m_absZIdxInCtu, m_dmmDeltaDC[i][1], sizeof(Pel ) * m_uiNumPartition ); |
---|
1400 | } |
---|
1401 | memcpy( pCtu->getDmm1WedgeTabIdx() + m_absZIdxInCtu, m_dmm1WedgeTabIdx, sizeof(UInt) * m_uiNumPartition ); |
---|
1402 | #endif |
---|
1403 | #if NH_3D_SDC_INTRA |
---|
1404 | memcpy( pCtu->getSDCFlag() + m_absZIdxInCtu, m_pbSDCFlag, sizeof(Bool) * m_uiNumPartition ); |
---|
1405 | memcpy( pCtu->getSDCSegmentDCOffset(0) + m_absZIdxInCtu, m_apSegmentDCOffset[0], sizeof( Pel ) * m_uiNumPartition); |
---|
1406 | memcpy( pCtu->getSDCSegmentDCOffset(1) + m_absZIdxInCtu, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition); |
---|
1407 | #endif |
---|
1408 | #if H_3D_DBBP |
---|
1409 | memcpy( rpcCU->getDBBPFlag() + m_uiAbsIdxInLCU, m_pbDBBPFlag, iSizeInBool ); |
---|
1410 | #endif |
---|
1411 | |
---|
1412 | memcpy( pCtu->getDepth() + m_absZIdxInCtu, m_puhDepth, iSizeInUchar ); |
---|
1413 | memcpy( pCtu->getWidth() + m_absZIdxInCtu, m_puhWidth, iSizeInUchar ); |
---|
1414 | memcpy( pCtu->getHeight() + m_absZIdxInCtu, m_puhHeight, iSizeInUchar ); |
---|
1415 | |
---|
1416 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1417 | { |
---|
1418 | const RefPicList rpl=RefPicList(i); |
---|
1419 | memcpy( pCtu->getMVPIdx(rpl) + m_absZIdxInCtu, m_apiMVPIdx[rpl], iSizeInUchar ); |
---|
1420 | memcpy( pCtu->getMVPNum(rpl) + m_absZIdxInCtu, m_apiMVPNum[rpl], iSizeInUchar ); |
---|
1421 | } |
---|
1422 | |
---|
1423 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1424 | { |
---|
1425 | const RefPicList rpl=RefPicList(i); |
---|
1426 | m_acCUMvField[rpl].copyTo( pCtu->getCUMvField( rpl ), m_absZIdxInCtu ); |
---|
1427 | } |
---|
1428 | |
---|
1429 | memcpy( pCtu->getIPCMFlag() + m_absZIdxInCtu, m_pbIPCMFlag, iSizeInBool ); |
---|
1430 | |
---|
1431 | const UInt numCoeffY = (pCtu->getSlice()->getSPS()->getMaxCUWidth()*pCtu->getSlice()->getSPS()->getMaxCUHeight())>>(uhDepth<<1); |
---|
1432 | const UInt offsetY = m_absZIdxInCtu*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
1433 | for (UInt comp=0; comp<numValidComp; comp++) |
---|
1434 | { |
---|
1435 | const ComponentID component = ComponentID(comp); |
---|
1436 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
1437 | memcpy( pCtu->getCoeff(component) + (offsetY>>componentShift), m_pcTrCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
1438 | #if ADAPTIVE_QP_SELECTION |
---|
1439 | memcpy( pCtu->getArlCoeff(component) + (offsetY>>componentShift), m_pcArlCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
1440 | #endif |
---|
1441 | memcpy( pCtu->getPCMSample(component) + (offsetY>>componentShift), m_pcIPCMSample[component], sizeof(Pel)*(numCoeffY>>componentShift) ); |
---|
1442 | } |
---|
1443 | |
---|
1444 | #if H_3D_ARP |
---|
1445 | memcpy( rpcCU->getARPW() + m_uiAbsIdxInLCU, m_puhARPW, iSizeInUchar ); |
---|
1446 | #endif |
---|
1447 | #if H_3D_IC |
---|
1448 | memcpy( rpcCU->getICFlag() + m_uiAbsIdxInLCU, m_pbICFlag, iSizeInBool ); |
---|
1449 | #endif |
---|
1450 | |
---|
1451 | pCtu->getTotalBins() = m_uiTotalBins; |
---|
1452 | } |
---|
1453 | #if H_3D_VSP |
---|
1454 | memcpy( rpcCU->getVSPFlag() + uiPartOffset, m_piVSPFlag, sizeof(Char) * uiQNumPart ); |
---|
1455 | #endif |
---|
1456 | #if H_3D_SPIVMP |
---|
1457 | memcpy( rpcCU->getSPIVMPFlag() + uiPartOffset, m_pbSPIVMPFlag, sizeof(Bool) * uiQNumPart ); |
---|
1458 | #endif |
---|
1459 | #if H_3D_DBBP |
---|
1460 | memcpy( rpcCU->getDBBPFlag() + uiPartOffset, m_pbDBBPFlag, iSizeInBool ); |
---|
1461 | #endif |
---|
1462 | #if H_3D_ARP |
---|
1463 | memcpy( rpcCU->getARPW() + uiPartOffset, m_puhARPW, iSizeInUchar ); |
---|
1464 | #endif |
---|
1465 | #if H_3D_IC |
---|
1466 | memcpy( rpcCU->getICFlag() + uiPartOffset, m_pbICFlag, iSizeInBool ); |
---|
1467 | #endif |
---|
1468 | |
---|
1469 | |
---|
1470 | |
---|
1471 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1472 | // Other public functions |
---|
1473 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1474 | |
---|
1475 | TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, |
---|
1476 | UInt uiCurrPartUnitIdx, |
---|
1477 | Bool bEnforceSliceRestriction, |
---|
1478 | Bool bEnforceTileRestriction ) |
---|
1479 | { |
---|
1480 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1481 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
1482 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1483 | |
---|
1484 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1485 | { |
---|
1486 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1487 | if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1488 | { |
---|
1489 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1490 | } |
---|
1491 | else |
---|
1492 | { |
---|
1493 | uiLPartUnitIdx -= m_absZIdxInCtu; |
---|
1494 | return this; |
---|
1495 | } |
---|
1496 | } |
---|
1497 | |
---|
1498 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth - 1 ]; |
---|
1499 | if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuLeft)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuLeft)) ) |
---|
1500 | { |
---|
1501 | return NULL; |
---|
1502 | } |
---|
1503 | return m_pCtuLeft; |
---|
1504 | } |
---|
1505 | |
---|
1506 | |
---|
1507 | TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, |
---|
1508 | UInt uiCurrPartUnitIdx, |
---|
1509 | Bool bEnforceSliceRestriction, |
---|
1510 | Bool planarAtCtuBoundary, |
---|
1511 | Bool bEnforceTileRestriction ) |
---|
1512 | { |
---|
1513 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1514 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
1515 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1516 | |
---|
1517 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1518 | { |
---|
1519 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth ]; |
---|
1520 | if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1521 | { |
---|
1522 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1523 | } |
---|
1524 | else |
---|
1525 | { |
---|
1526 | uiAPartUnitIdx -= m_absZIdxInCtu; |
---|
1527 | return this; |
---|
1528 | } |
---|
1529 | } |
---|
1530 | |
---|
1531 | if(planarAtCtuBoundary) |
---|
1532 | { |
---|
1533 | return NULL; |
---|
1534 | } |
---|
1535 | |
---|
1536 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth ]; |
---|
1537 | |
---|
1538 | if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuAbove)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuAbove)) ) |
---|
1539 | { |
---|
1540 | return NULL; |
---|
1541 | } |
---|
1542 | return m_pCtuAbove; |
---|
1543 | } |
---|
1544 | |
---|
1545 | TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
1546 | { |
---|
1547 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1548 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
1549 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1550 | |
---|
1551 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1552 | { |
---|
1553 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1554 | { |
---|
1555 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth - 1 ]; |
---|
1556 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1557 | { |
---|
1558 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1559 | } |
---|
1560 | else |
---|
1561 | { |
---|
1562 | uiALPartUnitIdx -= m_absZIdxInCtu; |
---|
1563 | return this; |
---|
1564 | } |
---|
1565 | } |
---|
1566 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartitionsInCtu() - numPartInCtuWidth - 1 ]; |
---|
1567 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) |
---|
1568 | { |
---|
1569 | return NULL; |
---|
1570 | } |
---|
1571 | return m_pCtuAbove; |
---|
1572 | } |
---|
1573 | |
---|
1574 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1575 | { |
---|
1576 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1577 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) |
---|
1578 | { |
---|
1579 | return NULL; |
---|
1580 | } |
---|
1581 | return m_pCtuLeft; |
---|
1582 | } |
---|
1583 | |
---|
1584 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - 1 ]; |
---|
1585 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveLeft) ) |
---|
1586 | { |
---|
1587 | return NULL; |
---|
1588 | } |
---|
1589 | return m_pCtuAboveLeft; |
---|
1590 | } |
---|
1591 | |
---|
1592 | TComDataCU* TComDataCU::getPUBelowLeft(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) |
---|
1593 | { |
---|
1594 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1595 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1596 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_absZIdxInCtu ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*numPartInCtuWidth; |
---|
1597 | |
---|
1598 | if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) |
---|
1599 | { |
---|
1600 | uiBLPartUnitIdx = MAX_UINT; |
---|
1601 | return NULL; |
---|
1602 | } |
---|
1603 | |
---|
1604 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInCtuHeight() - uiPartUnitOffset, numPartInCtuWidth ) ) |
---|
1605 | { |
---|
1606 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, numPartInCtuWidth ) ) |
---|
1607 | { |
---|
1608 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ] ) |
---|
1609 | { |
---|
1610 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ]; |
---|
1611 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, numPartInCtuWidth ) ) |
---|
1612 | { |
---|
1613 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1614 | } |
---|
1615 | else |
---|
1616 | { |
---|
1617 | uiBLPartUnitIdx -= m_absZIdxInCtu; |
---|
1618 | return this; |
---|
1619 | } |
---|
1620 | } |
---|
1621 | uiBLPartUnitIdx = MAX_UINT; |
---|
1622 | return NULL; |
---|
1623 | } |
---|
1624 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * numPartInCtuWidth - 1 ]; |
---|
1625 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) |
---|
1626 | { |
---|
1627 | return NULL; |
---|
1628 | } |
---|
1629 | return m_pCtuLeft; |
---|
1630 | } |
---|
1631 | |
---|
1632 | uiBLPartUnitIdx = MAX_UINT; |
---|
1633 | return NULL; |
---|
1634 | } |
---|
1635 | |
---|
1636 | TComDataCU* TComDataCU::getPUAboveRight(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) |
---|
1637 | { |
---|
1638 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1639 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_absZIdxInCtu ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
---|
1640 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1641 | |
---|
1642 | if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
1643 | { |
---|
1644 | uiARPartUnitIdx = MAX_UINT; |
---|
1645 | return NULL; |
---|
1646 | } |
---|
1647 | |
---|
1648 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, numPartInCtuWidth - uiPartUnitOffset, numPartInCtuWidth ) ) |
---|
1649 | { |
---|
1650 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) |
---|
1651 | { |
---|
1652 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ] ) |
---|
1653 | { |
---|
1654 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ]; |
---|
1655 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1656 | { |
---|
1657 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1658 | } |
---|
1659 | else |
---|
1660 | { |
---|
1661 | uiARPartUnitIdx -= m_absZIdxInCtu; |
---|
1662 | return this; |
---|
1663 | } |
---|
1664 | } |
---|
1665 | uiARPartUnitIdx = MAX_UINT; |
---|
1666 | return NULL; |
---|
1667 | } |
---|
1668 | |
---|
1669 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset ]; |
---|
1670 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) |
---|
1671 | { |
---|
1672 | return NULL; |
---|
1673 | } |
---|
1674 | return m_pCtuAbove; |
---|
1675 | } |
---|
1676 | |
---|
1677 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) |
---|
1678 | { |
---|
1679 | uiARPartUnitIdx = MAX_UINT; |
---|
1680 | return NULL; |
---|
1681 | } |
---|
1682 | |
---|
1683 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset-1 ]; |
---|
1684 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveRight) ) |
---|
1685 | { |
---|
1686 | return NULL; |
---|
1687 | } |
---|
1688 | return m_pCtuAboveRight; |
---|
1689 | } |
---|
1690 | |
---|
1691 | /** Get left QpMinCu |
---|
1692 | *\param uiLPartUnitIdx |
---|
1693 | *\param uiCurrAbsIdxInCtu |
---|
1694 | *\returns TComDataCU* point of TComDataCU of left QpMinCu |
---|
1695 | */ |
---|
1696 | TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu ) |
---|
1697 | { |
---|
1698 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1699 | const UInt maxCUDepth = getSlice()->getSPS()->getMaxTotalCUDepth(); |
---|
1700 | const UInt maxCuDQPDepth = getSlice()->getPPS()->getMaxCuDQPDepth(); |
---|
1701 | const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); |
---|
1702 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>doubleDepthDifference)<<doubleDepthDifference; |
---|
1703 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
1704 | |
---|
1705 | // check for left CTU boundary |
---|
1706 | if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCtuWidth) ) |
---|
1707 | { |
---|
1708 | return NULL; |
---|
1709 | } |
---|
1710 | |
---|
1711 | // get index of left-CU relative to top-left corner of current quantization group |
---|
1712 | uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; |
---|
1713 | |
---|
1714 | // return pointer to current CTU |
---|
1715 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1716 | } |
---|
1717 | |
---|
1718 | /** Get Above QpMinCu |
---|
1719 | *\param uiAPartUnitIdx |
---|
1720 | *\param uiCurrAbsIdxInCtu |
---|
1721 | *\returns TComDataCU* point of TComDataCU of above QpMinCu |
---|
1722 | */ |
---|
1723 | TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu ) |
---|
1724 | { |
---|
1725 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1726 | const UInt maxCUDepth = getSlice()->getSPS()->getMaxTotalCUDepth(); |
---|
1727 | const UInt maxCuDQPDepth = getSlice()->getPPS()->getMaxCuDQPDepth(); |
---|
1728 | const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); |
---|
1729 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>doubleDepthDifference)<<doubleDepthDifference; |
---|
1730 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
1731 | |
---|
1732 | // check for top CTU boundary |
---|
1733 | if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCtuWidth) ) |
---|
1734 | { |
---|
1735 | return NULL; |
---|
1736 | } |
---|
1737 | |
---|
1738 | // get index of top-CU relative to top-left corner of current quantization group |
---|
1739 | uiAPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCtuWidth]; |
---|
1740 | |
---|
1741 | // return pointer to current CTU |
---|
1742 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1743 | } |
---|
1744 | |
---|
1745 | |
---|
1746 | |
---|
1747 | /** Get reference QP from left QpMinCu or latest coded QP |
---|
1748 | *\param uiCurrAbsIdxInCtu |
---|
1749 | *\returns Char reference QP value |
---|
1750 | */ |
---|
1751 | Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu ) |
---|
1752 | { |
---|
1753 | UInt lPartIdx = MAX_UINT; |
---|
1754 | UInt aPartIdx = MAX_UINT; |
---|
1755 | TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); |
---|
1756 | TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); |
---|
1757 | return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + 1) >> 1); |
---|
1758 | } |
---|
1759 | |
---|
1760 | Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) |
---|
1761 | { |
---|
1762 | Int iLastValidPartIdx = iAbsPartIdx-1; |
---|
1763 | while ( iLastValidPartIdx >= 0 |
---|
1764 | && getPredictionMode( iLastValidPartIdx ) == NUMBER_OF_PREDICTION_MODES ) |
---|
1765 | { |
---|
1766 | UInt uiDepth = getDepth( iLastValidPartIdx ); |
---|
1767 | iLastValidPartIdx -= m_uiNumPartition>>(uiDepth<<1); |
---|
1768 | } |
---|
1769 | return iLastValidPartIdx; |
---|
1770 | } |
---|
1771 | |
---|
1772 | Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) |
---|
1773 | { |
---|
1774 | UInt uiQUPartIdxMask = ~((1<<((getSlice()->getSPS()->getMaxTotalCUDepth() - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); |
---|
1775 | Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); // A idx will be invalid if it is off the right or bottom edge of the picture. |
---|
1776 | // If this CU is in the first CTU of the slice and there is no valid part before this one, use slice QP |
---|
1777 | if ( getPic()->getPicSym()->getCtuTsToRsAddrMap(getSlice()->getSliceCurStartCtuTsAddr()) == getCtuRsAddr() && Int(getZorderIdxInCtu())+iLastValidPartIdx<0) |
---|
1778 | { |
---|
1779 | return getSlice()->getSliceQp(); |
---|
1780 | } |
---|
1781 | else if ( iLastValidPartIdx >= 0 ) |
---|
1782 | { |
---|
1783 | // If there is a valid part within the current Sub-CU, use it |
---|
1784 | return getQP( iLastValidPartIdx ); |
---|
1785 | } |
---|
1786 | else |
---|
1787 | { |
---|
1788 | if ( getZorderIdxInCtu() > 0 ) |
---|
1789 | { |
---|
1790 | // If this wasn't the first sub-cu within the Ctu, explore the CTU itself. |
---|
1791 | return getPic()->getCtu( getCtuRsAddr() )->getLastCodedQP( getZorderIdxInCtu() ); // TODO - remove this recursion |
---|
1792 | } |
---|
1793 | else if ( getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr()) > 0 |
---|
1794 | && CUIsFromSameSliceTileAndWavefrontRow(getPic()->getCtu(getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1))) ) |
---|
1795 | { |
---|
1796 | // 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. |
---|
1797 | return getPic()->getCtu( getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1) )->getLastCodedQP( getPic()->getNumPartitionsInCtu() ); // TODO - remove this recursion |
---|
1798 | } |
---|
1799 | else |
---|
1800 | { |
---|
1801 | // No other options available - use the slice-level QP. |
---|
1802 | return getSlice()->getSliceQp(); |
---|
1803 | } |
---|
1804 | } |
---|
1805 | } |
---|
1806 | |
---|
1807 | |
---|
1808 | /** Check whether the CU is coded in lossless coding mode. |
---|
1809 | * \param absPartIdx |
---|
1810 | * \returns true if the CU is coded in lossless coding mode; false if otherwise |
---|
1811 | */ |
---|
1812 | Bool TComDataCU::isLosslessCoded(UInt absPartIdx) |
---|
1813 | { |
---|
1814 | return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx)); |
---|
1815 | } |
---|
1816 | |
---|
1817 | |
---|
1818 | /** Get allowed chroma intra modes |
---|
1819 | * - fills uiModeList with chroma intra modes |
---|
1820 | * |
---|
1821 | *\param [in] uiAbsPartIdx |
---|
1822 | *\param [out] uiModeList pointer to chroma intra modes array |
---|
1823 | */ |
---|
1824 | Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] ) |
---|
1825 | { |
---|
1826 | uiModeList[0] = PLANAR_IDX; |
---|
1827 | uiModeList[1] = VER_IDX; |
---|
1828 | uiModeList[2] = HOR_IDX; |
---|
1829 | uiModeList[3] = DC_IDX; |
---|
1830 | uiModeList[4] = DM_CHROMA_IDX; |
---|
1831 | assert(4<NUM_CHROMA_MODE); |
---|
1832 | |
---|
1833 | UInt uiLumaMode = getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ); |
---|
1834 | |
---|
1835 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
---|
1836 | { |
---|
1837 | if( uiLumaMode == uiModeList[i] ) |
---|
1838 | { |
---|
1839 | uiModeList[i] = 34; // VER+8 mode |
---|
1840 | break; |
---|
1841 | } |
---|
1842 | } |
---|
1843 | } |
---|
1844 | |
---|
1845 | /** Get most probable intra modes |
---|
1846 | *\param uiAbsPartIdx partition index |
---|
1847 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
1848 | *\param compID colour component ID |
---|
1849 | *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. |
---|
1850 | *\returns Number of MPM |
---|
1851 | */ |
---|
1852 | Void TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode ) |
---|
1853 | { |
---|
1854 | TComDataCU* pcCULeft, *pcCUAbove; |
---|
1855 | UInt LeftPartIdx = MAX_UINT; |
---|
1856 | UInt AbovePartIdx = MAX_UINT; |
---|
1857 | Int iLeftIntraDir, iAboveIntraDir; |
---|
1858 | const TComSPS *sps=getSlice()->getSPS(); |
---|
1859 | const UInt partsPerMinCU = 1<<(2*(sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize())); |
---|
1860 | |
---|
1861 | const ChannelType chType = toChannelType(compID); |
---|
1862 | const ChromaFormat chForm = getPic()->getChromaFormat(); |
---|
1863 | // Get intra direction of left PU |
---|
1864 | pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
1865 | |
---|
1866 | if (isChroma(compID)) |
---|
1867 | { |
---|
1868 | LeftPartIdx = getChromasCorrespondingPULumaIdx(LeftPartIdx, chForm, partsPerMinCU); |
---|
1869 | } |
---|
1870 | iLeftIntraDir = pcCULeft ? ( pcCULeft->isIntra( LeftPartIdx ) ? pcCULeft->getIntraDir( chType, LeftPartIdx ) : DC_IDX ) : DC_IDX; |
---|
1871 | #if NH_3D_DMM |
---|
1872 | mapDmmToIntraDir( iLeftIntraDir ); |
---|
1873 | #endif |
---|
1874 | |
---|
1875 | // Get intra direction of above PU |
---|
1876 | pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true ); |
---|
1877 | |
---|
1878 | if (isChroma(compID)) |
---|
1879 | { |
---|
1880 | AbovePartIdx = getChromasCorrespondingPULumaIdx(AbovePartIdx, chForm, partsPerMinCU); |
---|
1881 | } |
---|
1882 | iAboveIntraDir = pcCUAbove ? ( pcCUAbove->isIntra( AbovePartIdx ) ? pcCUAbove->getIntraDir( chType, AbovePartIdx ) : DC_IDX ) : DC_IDX; |
---|
1883 | #if NH_3D_DMM |
---|
1884 | mapDmmToIntraDir( iAboveIntraDir ); |
---|
1885 | #endif |
---|
1886 | |
---|
1887 | |
---|
1888 | if (isChroma(chType)) |
---|
1889 | { |
---|
1890 | if (iLeftIntraDir == DM_CHROMA_IDX) |
---|
1891 | { |
---|
1892 | iLeftIntraDir = pcCULeft-> getIntraDir( CHANNEL_TYPE_LUMA, LeftPartIdx ); |
---|
1893 | } |
---|
1894 | if (iAboveIntraDir == DM_CHROMA_IDX) |
---|
1895 | { |
---|
1896 | iAboveIntraDir = pcCUAbove->getIntraDir( CHANNEL_TYPE_LUMA, AbovePartIdx ); |
---|
1897 | } |
---|
1898 | } |
---|
1899 | |
---|
1900 | assert (2<NUM_MOST_PROBABLE_MODES); |
---|
1901 | if(iLeftIntraDir == iAboveIntraDir) |
---|
1902 | { |
---|
1903 | if( piMode ) |
---|
1904 | { |
---|
1905 | *piMode = 1; |
---|
1906 | } |
---|
1907 | |
---|
1908 | if (iLeftIntraDir > 1) // angular modes |
---|
1909 | { |
---|
1910 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
1911 | uiIntraDirPred[1] = ((iLeftIntraDir + 29) % 32) + 2; |
---|
1912 | uiIntraDirPred[2] = ((iLeftIntraDir - 1 ) % 32) + 2; |
---|
1913 | } |
---|
1914 | else //non-angular |
---|
1915 | { |
---|
1916 | uiIntraDirPred[0] = PLANAR_IDX; |
---|
1917 | uiIntraDirPred[1] = DC_IDX; |
---|
1918 | uiIntraDirPred[2] = VER_IDX; |
---|
1919 | } |
---|
1920 | } |
---|
1921 | else |
---|
1922 | { |
---|
1923 | if( piMode ) |
---|
1924 | { |
---|
1925 | *piMode = 2; |
---|
1926 | } |
---|
1927 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
1928 | uiIntraDirPred[1] = iAboveIntraDir; |
---|
1929 | |
---|
1930 | if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar |
---|
1931 | { |
---|
1932 | uiIntraDirPred[2] = PLANAR_IDX; |
---|
1933 | } |
---|
1934 | else |
---|
1935 | { |
---|
1936 | uiIntraDirPred[2] = (iLeftIntraDir+iAboveIntraDir)<2? VER_IDX : DC_IDX; |
---|
1937 | } |
---|
1938 | } |
---|
1939 | for (UInt i=0; i<NUM_MOST_PROBABLE_MODES; i++) |
---|
1940 | { |
---|
1941 | assert(uiIntraDirPred[i] < 35); |
---|
1942 | } |
---|
1943 | } |
---|
1944 | |
---|
1945 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1946 | { |
---|
1947 | TComDataCU* pcTempCU; |
---|
1948 | UInt uiTempPartIdx; |
---|
1949 | UInt uiCtx; |
---|
1950 | // Get left split flag |
---|
1951 | pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
1952 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
1953 | |
---|
1954 | // Get above split flag |
---|
1955 | pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
1956 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
1957 | |
---|
1958 | return uiCtx; |
---|
1959 | } |
---|
1960 | |
---|
1961 | UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType ) |
---|
1962 | { |
---|
1963 | const UInt transformDepth = rTu.GetTransformDepthRel(); |
---|
1964 | |
---|
1965 | if (isChroma(chType)) |
---|
1966 | { |
---|
1967 | return transformDepth; |
---|
1968 | } |
---|
1969 | else |
---|
1970 | { |
---|
1971 | const UInt uiCtx = ( transformDepth == 0 ? 1 : 0 ); |
---|
1972 | return uiCtx; |
---|
1973 | } |
---|
1974 | } |
---|
1975 | |
---|
1976 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) |
---|
1977 | { |
---|
1978 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
---|
1979 | PartSize partSize = getPartitionSize( absPartIdx ); |
---|
1980 | UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
1981 | Int intraSplitFlag = ( isIntra( absPartIdx ) && partSize == SIZE_NxN ) ? 1 : 0; |
---|
1982 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && isInter( absPartIdx ) && (partSize != SIZE_2Nx2N) ); |
---|
1983 | |
---|
1984 | UInt log2MinTUSizeInCU = 0; |
---|
1985 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
---|
1986 | { |
---|
1987 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
---|
1988 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
1989 | } |
---|
1990 | else |
---|
1991 | { |
---|
1992 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
---|
1993 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
---|
1994 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
1995 | { |
---|
1996 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
---|
1997 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
1998 | } |
---|
1999 | } |
---|
2000 | return log2MinTUSizeInCU; |
---|
2001 | } |
---|
2002 | |
---|
2003 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
---|
2004 | { |
---|
2005 | TComDataCU* pcTempCU; |
---|
2006 | UInt uiTempPartIdx; |
---|
2007 | UInt uiCtx = 0; |
---|
2008 | |
---|
2009 | // Get BCBP of left PU |
---|
2010 | pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
2011 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2012 | |
---|
2013 | // Get BCBP of above PU |
---|
2014 | pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
2015 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2016 | |
---|
2017 | return uiCtx; |
---|
2018 | } |
---|
2019 | #if H_3D_ARP |
---|
2020 | UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx ) |
---|
2021 | { |
---|
2022 | TComDataCU* pcTempCU; |
---|
2023 | UInt uiTempPartIdx; |
---|
2024 | UInt uiCtx = 0; |
---|
2025 | |
---|
2026 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2027 | uiCtx = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0; |
---|
2028 | return uiCtx; |
---|
2029 | } |
---|
2030 | #endif |
---|
2031 | #if H_3D_DBBP |
---|
2032 | Pel* TComDataCU::getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride) |
---|
2033 | { |
---|
2034 | // get coded and reconstructed depth view |
---|
2035 | TComPicYuv* depthPicYuv = NULL; |
---|
2036 | Pel* pDepthPels = NULL; |
---|
2037 | |
---|
2038 | // DBBP is a texture coding tool |
---|
2039 | if( getSlice()->getIsDepth() ) |
---|
2040 | { |
---|
2041 | return NULL; |
---|
2042 | } |
---|
2043 | #if H_3D_FCO |
---|
2044 | TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); |
---|
2045 | |
---|
2046 | if( depthPic && depthPic->getPicYuvRec() != NULL && depthPic->getIsDepth() ) // depth first |
---|
2047 | { |
---|
2048 | depthPicYuv = depthPic->getPicYuvRec(); |
---|
2049 | depthPicYuv->extendPicBorder(); |
---|
2050 | |
---|
2051 | // get collocated depth block for current CU |
---|
2052 | uiDepthStride = depthPicYuv->getStride(); |
---|
2053 | pDepthPels = depthPicYuv->getLumaAddr( getAddr(), uiAbsPartIdx ); |
---|
2054 | } |
---|
2055 | else // texture first |
---|
2056 | #else |
---|
2057 | { |
---|
2058 | DisInfo DvInfo = getDvInfo(uiAbsPartIdx); |
---|
2059 | |
---|
2060 | TComPic* baseDepthPic = getSlice()->getIvPic (true, DvInfo.m_aVIdxCan); |
---|
2061 | |
---|
2062 | if( baseDepthPic == NULL || baseDepthPic->getPicYuvRec() == NULL ) |
---|
2063 | { |
---|
2064 | return NULL; |
---|
2065 | } |
---|
2066 | |
---|
2067 | depthPicYuv = baseDepthPic->getPicYuvRec(); |
---|
2068 | depthPicYuv->extendPicBorder(); |
---|
2069 | uiDepthStride = depthPicYuv->getStride(); |
---|
2070 | |
---|
2071 | Int iBlkX = ( getAddr() % baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ]; |
---|
2072 | Int iBlkY = ( getAddr() / baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ]; |
---|
2073 | |
---|
2074 | Int iPictureWidth = depthPicYuv->getWidth(); |
---|
2075 | Int iPictureHeight = depthPicYuv->getHeight(); |
---|
2076 | |
---|
2077 | |
---|
2078 | Bool depthRefineFlag = false; |
---|
2079 | #if H_3D_NBDV_REF |
---|
2080 | depthRefineFlag = m_pcSlice->getDepthRefinementFlag( ); |
---|
2081 | #endif // H_3D_NBDV_REF |
---|
2082 | |
---|
2083 | TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV; |
---|
2084 | if( depthRefineFlag ) |
---|
2085 | { |
---|
2086 | cDv.setVer(0); |
---|
2087 | } |
---|
2088 | |
---|
2089 | Int depthPosX = Clip3(0, iPictureWidth - 1, iBlkX + ((cDv.getHor()+2)>>2)); |
---|
2090 | Int depthPosY = Clip3(0, iPictureHeight - 1, iBlkY + ((cDv.getVer()+2)>>2)); |
---|
2091 | |
---|
2092 | pDepthPels = depthPicYuv->getLumaAddr() + depthPosX + depthPosY * uiDepthStride; |
---|
2093 | } |
---|
2094 | #endif |
---|
2095 | |
---|
2096 | AOF( depthPicYuv != NULL ); |
---|
2097 | AOF( pDepthPels != NULL ); |
---|
2098 | AOF( uiDepthStride != 0 ); |
---|
2099 | |
---|
2100 | return pDepthPels; |
---|
2101 | } |
---|
2102 | #endif |
---|
2103 | |
---|
2104 | #if H_3D_DBBP |
---|
2105 | Void TComDataCU::setDBBPFlagSubParts ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2106 | { |
---|
2107 | setSubPart( bDBBPFlag, m_pbDBBPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2108 | } |
---|
2109 | #endif |
---|
2110 | |
---|
2111 | |
---|
2112 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
---|
2113 | { |
---|
2114 | return getDepth( uiAbsPartIdx ); |
---|
2115 | } |
---|
2116 | |
---|
2117 | |
---|
2118 | UChar TComDataCU::getQtRootCbf( UInt uiIdx ) |
---|
2119 | { |
---|
2120 | const UInt numberValidComponents = getPic()->getNumberValidComponents(); |
---|
2121 | return getCbf( uiIdx, COMPONENT_Y, 0 ) |
---|
2122 | || ((numberValidComponents > COMPONENT_Cb) && getCbf( uiIdx, COMPONENT_Cb, 0 )) |
---|
2123 | || ((numberValidComponents > COMPONENT_Cr) && getCbf( uiIdx, COMPONENT_Cr, 0 )); |
---|
2124 | } |
---|
2125 | |
---|
2126 | Void TComDataCU::setCbfSubParts( const UInt uiCbf[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2127 | { |
---|
2128 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2129 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
2130 | { |
---|
2131 | memset( m_puhCbf[comp] + uiAbsPartIdx, uiCbf[comp], sizeof( UChar ) * uiCurrPartNumb ); |
---|
2132 | } |
---|
2133 | } |
---|
2134 | |
---|
2135 | Void TComDataCU::setCbfSubParts( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2136 | { |
---|
2137 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2138 | memset( m_puhCbf[compID] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2139 | } |
---|
2140 | |
---|
2141 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
2142 | * \param uiCbf The value of the coded block flag to be set |
---|
2143 | * \param compID |
---|
2144 | * \param uiAbsPartIdx |
---|
2145 | * \param uiPartIdx |
---|
2146 | * \param uiDepth |
---|
2147 | */ |
---|
2148 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2149 | { |
---|
2150 | setSubPart<UChar>( uiCbf, m_puhCbf[compID], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2151 | } |
---|
2152 | |
---|
2153 | Void TComDataCU::setCbfPartRange ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
2154 | { |
---|
2155 | memset((m_puhCbf[compID] + uiAbsPartIdx), uiCbf, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
2156 | } |
---|
2157 | |
---|
2158 | Void TComDataCU::bitwiseOrCbfPartRange( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
2159 | { |
---|
2160 | const UInt stopAbsPartIdx = uiAbsPartIdx + uiCoveredPartIdxes; |
---|
2161 | |
---|
2162 | for (UInt subPartIdx = uiAbsPartIdx; subPartIdx < stopAbsPartIdx; subPartIdx++) |
---|
2163 | { |
---|
2164 | m_puhCbf[compID][subPartIdx] |= uiCbf; |
---|
2165 | } |
---|
2166 | } |
---|
2167 | |
---|
2168 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
2169 | { |
---|
2170 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2171 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2172 | } |
---|
2173 | |
---|
2174 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
---|
2175 | { |
---|
2176 | UInt uiPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2177 | return (((m_absZIdxInCtu + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
2178 | } |
---|
2179 | |
---|
2180 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2181 | { |
---|
2182 | assert( sizeof( *m_pePartSize) == 1 ); |
---|
2183 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
2184 | } |
---|
2185 | |
---|
2186 | Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2187 | { |
---|
2188 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
2189 | } |
---|
2190 | |
---|
2191 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
---|
2192 | { |
---|
2193 | assert( sizeof( *m_skipFlag) == 1 ); |
---|
2194 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); |
---|
2195 | } |
---|
2196 | |
---|
2197 | #if NH_3D_DIS |
---|
2198 | Void TComDataCU::setDISFlagSubParts( Bool bDIS, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2199 | { |
---|
2200 | assert( sizeof( *m_bDISFlag) == 1 ); |
---|
2201 | memset( m_bDISFlag + uiAbsPartIdx, bDIS, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
2202 | } |
---|
2203 | |
---|
2204 | Void TComDataCU::setDISTypeSubParts(UChar ucDISType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2205 | { |
---|
2206 | assert( sizeof( *m_ucDISType) == 1 ); |
---|
2207 | memset( m_ucDISType + uiAbsPartIdx, ucDISType, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
2208 | } |
---|
2209 | #endif |
---|
2210 | |
---|
2211 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2212 | { |
---|
2213 | assert( sizeof( *m_pePredMode) == 1 ); |
---|
2214 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
2215 | } |
---|
2216 | |
---|
2217 | Void TComDataCU::setChromaQpAdjSubParts( UChar val, Int absPartIdx, Int depth ) |
---|
2218 | { |
---|
2219 | assert( sizeof(*m_ChromaQpAdj) == 1 ); |
---|
2220 | memset( m_ChromaQpAdj + absPartIdx, val, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); |
---|
2221 | } |
---|
2222 | |
---|
2223 | Void TComDataCU::setQPSubCUs( Int qp, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
---|
2224 | { |
---|
2225 | UInt currPartNumb = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); |
---|
2226 | UInt currPartNumQ = currPartNumb >> 2; |
---|
2227 | const UInt numValidComp = m_pcPic->getNumberValidComponents(); |
---|
2228 | |
---|
2229 | if(!foundNonZeroCbf) |
---|
2230 | { |
---|
2231 | if(getDepth(absPartIdx) > depth) |
---|
2232 | { |
---|
2233 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
---|
2234 | { |
---|
2235 | setQPSubCUs( qp, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
---|
2236 | } |
---|
2237 | } |
---|
2238 | else |
---|
2239 | { |
---|
2240 | if(getCbf( absPartIdx, COMPONENT_Y ) || (numValidComp>COMPONENT_Cb && getCbf( absPartIdx, COMPONENT_Cb )) || (numValidComp>COMPONENT_Cr && getCbf( absPartIdx, COMPONENT_Cr) ) ) |
---|
2241 | { |
---|
2242 | foundNonZeroCbf = true; |
---|
2243 | } |
---|
2244 | else |
---|
2245 | { |
---|
2246 | setQPSubParts(qp, absPartIdx, depth); |
---|
2247 | } |
---|
2248 | } |
---|
2249 | } |
---|
2250 | } |
---|
2251 | |
---|
2252 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2253 | { |
---|
2254 | const UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2255 | memset(m_phQP+uiAbsPartIdx, qp, numPart); |
---|
2256 | } |
---|
2257 | |
---|
2258 | Void TComDataCU::setIntraDirSubParts( const ChannelType channelType, const UInt dir, const UInt absPartIdx, const UInt depth ) |
---|
2259 | { |
---|
2260 | UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); |
---|
2261 | memset( m_puhIntraDir[channelType] + absPartIdx, dir,sizeof(UChar)*numPart ); |
---|
2262 | } |
---|
2263 | |
---|
2264 | template<typename T> |
---|
2265 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2266 | { |
---|
2267 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
---|
2268 | |
---|
2269 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2; |
---|
2270 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2271 | { |
---|
2272 | case SIZE_2Nx2N: |
---|
2273 | memset( puhBaseCtu + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
---|
2274 | break; |
---|
2275 | case SIZE_2NxN: |
---|
2276 | memset( puhBaseCtu + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
---|
2277 | break; |
---|
2278 | case SIZE_Nx2N: |
---|
2279 | memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2280 | memset( puhBaseCtu + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
---|
2281 | break; |
---|
2282 | case SIZE_NxN: |
---|
2283 | memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2284 | break; |
---|
2285 | case SIZE_2NxnU: |
---|
2286 | if ( uiPUIdx == 0 ) |
---|
2287 | { |
---|
2288 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2289 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2290 | } |
---|
2291 | else if ( uiPUIdx == 1 ) |
---|
2292 | { |
---|
2293 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2294 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
---|
2295 | } |
---|
2296 | else |
---|
2297 | { |
---|
2298 | assert(0); |
---|
2299 | } |
---|
2300 | break; |
---|
2301 | case SIZE_2NxnD: |
---|
2302 | if ( uiPUIdx == 0 ) |
---|
2303 | { |
---|
2304 | memset( puhBaseCtu + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
---|
2305 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2306 | } |
---|
2307 | else if ( uiPUIdx == 1 ) |
---|
2308 | { |
---|
2309 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2310 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2311 | } |
---|
2312 | else |
---|
2313 | { |
---|
2314 | assert(0); |
---|
2315 | } |
---|
2316 | break; |
---|
2317 | case SIZE_nLx2N: |
---|
2318 | if ( uiPUIdx == 0 ) |
---|
2319 | { |
---|
2320 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2321 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2322 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2323 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2324 | } |
---|
2325 | else if ( uiPUIdx == 1 ) |
---|
2326 | { |
---|
2327 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2328 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2329 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2330 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2331 | } |
---|
2332 | else |
---|
2333 | { |
---|
2334 | assert(0); |
---|
2335 | } |
---|
2336 | break; |
---|
2337 | case SIZE_nRx2N: |
---|
2338 | if ( uiPUIdx == 0 ) |
---|
2339 | { |
---|
2340 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2341 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2342 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2343 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2344 | } |
---|
2345 | else if ( uiPUIdx == 1 ) |
---|
2346 | { |
---|
2347 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2348 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2349 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2350 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2351 | } |
---|
2352 | else |
---|
2353 | { |
---|
2354 | assert(0); |
---|
2355 | } |
---|
2356 | break; |
---|
2357 | default: |
---|
2358 | assert( 0 ); |
---|
2359 | break; |
---|
2360 | } |
---|
2361 | } |
---|
2362 | |
---|
2363 | #if NH_3D_SDC_INTRA |
---|
2364 | Void TComDataCU::setSDCFlagSubParts ( Bool bSDCFlag, UInt absPartIdx, UInt depth ) |
---|
2365 | { |
---|
2366 | assert( sizeof( *m_pbSDCFlag) == 1 ); |
---|
2367 | memset( m_pbSDCFlag + absPartIdx, bSDCFlag, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); |
---|
2368 | } |
---|
2369 | |
---|
2370 | Bool TComDataCU::getSDCAvailable( UInt uiAbsPartIdx ) |
---|
2371 | { |
---|
2372 | if( getSlice()->getIsDepth() && isIntra(uiAbsPartIdx) && getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ) |
---|
2373 | { |
---|
2374 | UInt lumaPredMode = getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ); |
---|
2375 | if( lumaPredMode < NUM_INTRA_MODE ) { return true; } |
---|
2376 | #if NH_3D_DMM |
---|
2377 | if( isDmmMode( lumaPredMode ) ) { return true; } |
---|
2378 | #endif |
---|
2379 | } |
---|
2380 | return false; |
---|
2381 | } |
---|
2382 | #endif |
---|
2383 | |
---|
2384 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2385 | { |
---|
2386 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2387 | } |
---|
2388 | |
---|
2389 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2390 | { |
---|
2391 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2392 | } |
---|
2393 | |
---|
2394 | #if H_3D_SPIVMP |
---|
2395 | Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2396 | { |
---|
2397 | setSubPart<Bool>( bSPIVMPFlag, m_pbSPIVMPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2398 | } |
---|
2399 | #endif |
---|
2400 | |
---|
2401 | #if H_3D_VSP |
---|
2402 | Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2403 | { |
---|
2404 | setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2405 | } |
---|
2406 | #if H_3D_VSP |
---|
2407 | template<typename T> |
---|
2408 | Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2409 | { |
---|
2410 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
---|
2411 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2412 | { |
---|
2413 | case SIZE_2Nx2N: |
---|
2414 | for (UInt ui = 0; ui < 4 * uiCurrPartNumQ; ui++) |
---|
2415 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2416 | |
---|
2417 | break; |
---|
2418 | case SIZE_2NxN: |
---|
2419 | for (UInt ui = 0; ui < 2 * uiCurrPartNumQ; ui++) |
---|
2420 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2421 | break; |
---|
2422 | case SIZE_Nx2N: |
---|
2423 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2424 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2425 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2426 | puhBaseLCU[uiCUAddr + 2 * uiCurrPartNumQ + ui] = uiParameter; |
---|
2427 | break; |
---|
2428 | case SIZE_NxN: |
---|
2429 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2430 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2431 | break; |
---|
2432 | case SIZE_2NxnU: |
---|
2433 | if ( uiPUIdx == 0 ) |
---|
2434 | { |
---|
2435 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2436 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2437 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2438 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2439 | |
---|
2440 | } |
---|
2441 | else if ( uiPUIdx == 1 ) |
---|
2442 | { |
---|
2443 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2444 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2445 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1); ui++) |
---|
2446 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2447 | |
---|
2448 | } |
---|
2449 | else |
---|
2450 | { |
---|
2451 | assert(0); |
---|
2452 | } |
---|
2453 | break; |
---|
2454 | case SIZE_2NxnD: |
---|
2455 | if ( uiPUIdx == 0 ) |
---|
2456 | { |
---|
2457 | for (UInt ui = 0; ui < ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)); ui++) |
---|
2458 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2459 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2460 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + ui] = uiParameter; |
---|
2461 | |
---|
2462 | } |
---|
2463 | else if ( uiPUIdx == 1 ) |
---|
2464 | { |
---|
2465 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2466 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2467 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2468 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2469 | |
---|
2470 | } |
---|
2471 | else |
---|
2472 | { |
---|
2473 | assert(0); |
---|
2474 | } |
---|
2475 | break; |
---|
2476 | case SIZE_nLx2N: |
---|
2477 | if ( uiPUIdx == 0 ) |
---|
2478 | { |
---|
2479 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2480 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2481 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2482 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2483 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2484 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2485 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2486 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2487 | |
---|
2488 | } |
---|
2489 | else if ( uiPUIdx == 1 ) |
---|
2490 | { |
---|
2491 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2492 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2493 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2494 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2495 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2496 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2497 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2498 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2499 | |
---|
2500 | } |
---|
2501 | else |
---|
2502 | { |
---|
2503 | assert(0); |
---|
2504 | } |
---|
2505 | break; |
---|
2506 | case SIZE_nRx2N: |
---|
2507 | if ( uiPUIdx == 0 ) |
---|
2508 | { |
---|
2509 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2510 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2511 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2512 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2513 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2514 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2515 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2516 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2517 | |
---|
2518 | } |
---|
2519 | else if ( uiPUIdx == 1 ) |
---|
2520 | { |
---|
2521 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2522 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2523 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2524 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2525 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2526 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2527 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2528 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2529 | |
---|
2530 | } |
---|
2531 | else |
---|
2532 | { |
---|
2533 | assert(0); |
---|
2534 | } |
---|
2535 | break; |
---|
2536 | default: |
---|
2537 | assert( 0 ); |
---|
2538 | } |
---|
2539 | |
---|
2540 | } |
---|
2541 | #endif |
---|
2542 | #endif |
---|
2543 | |
---|
2544 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2545 | { |
---|
2546 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2547 | } |
---|
2548 | |
---|
2549 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2550 | { |
---|
2551 | setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2552 | } |
---|
2553 | |
---|
2554 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2555 | { |
---|
2556 | setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2557 | } |
---|
2558 | |
---|
2559 | |
---|
2560 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2561 | { |
---|
2562 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2563 | |
---|
2564 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
2565 | } |
---|
2566 | |
---|
2567 | Void TComDataCU::setTransformSkipSubParts( const UInt useTransformSkip[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2568 | { |
---|
2569 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2570 | |
---|
2571 | for(UInt i=0; i<MAX_NUM_COMPONENT; i++) |
---|
2572 | { |
---|
2573 | memset( m_puhTransformSkip[i] + uiAbsPartIdx, useTransformSkip[i], sizeof( UChar ) * uiCurrPartNumb ); |
---|
2574 | } |
---|
2575 | } |
---|
2576 | |
---|
2577 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth) |
---|
2578 | { |
---|
2579 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2580 | |
---|
2581 | memset( m_puhTransformSkip[compID] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2582 | } |
---|
2583 | |
---|
2584 | Void TComDataCU::setTransformSkipPartRange ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
2585 | { |
---|
2586 | memset((m_puhTransformSkip[compID] + uiAbsPartIdx), useTransformSkip, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
2587 | } |
---|
2588 | |
---|
2589 | Void TComDataCU::setCrossComponentPredictionAlphaPartRange( Char alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
2590 | { |
---|
2591 | memset((m_crossComponentPredictionAlpha[compID] + uiAbsPartIdx), alphaValue, (sizeof(Char) * uiCoveredPartIdxes)); |
---|
2592 | } |
---|
2593 | |
---|
2594 | Void TComDataCU::setExplicitRdpcmModePartRange ( UInt rdpcmMode, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
2595 | { |
---|
2596 | memset((m_explicitRdpcmMode[compID] + uiAbsPartIdx), rdpcmMode, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
2597 | } |
---|
2598 | |
---|
2599 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2600 | { |
---|
2601 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2602 | |
---|
2603 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2604 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
2605 | } |
---|
2606 | |
---|
2607 | UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx) |
---|
2608 | { |
---|
2609 | UChar iNumPart = 0; |
---|
2610 | |
---|
2611 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2612 | { |
---|
2613 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
2614 | case SIZE_2NxN: iNumPart = 2; break; |
---|
2615 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
2616 | case SIZE_NxN: iNumPart = 4; break; |
---|
2617 | case SIZE_2NxnU: iNumPart = 2; break; |
---|
2618 | case SIZE_2NxnD: iNumPart = 2; break; |
---|
2619 | case SIZE_nLx2N: iNumPart = 2; break; |
---|
2620 | case SIZE_nRx2N: iNumPart = 2; break; |
---|
2621 | default: assert (0); break; |
---|
2622 | } |
---|
2623 | |
---|
2624 | return iNumPart; |
---|
2625 | } |
---|
2626 | |
---|
2627 | // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx |
---|
2628 | #if H_3D_IC |
---|
2629 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU) |
---|
2630 | { |
---|
2631 | UInt uiNumPartition = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition; |
---|
2632 | UInt uiTmpAbsPartIdx = bLCU ? uiAbsPartIdx : 0; |
---|
2633 | |
---|
2634 | switch ( m_pePartSize[uiTmpAbsPartIdx] ) |
---|
2635 | { |
---|
2636 | case SIZE_2NxN: |
---|
2637 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1; |
---|
2638 | break; |
---|
2639 | case SIZE_Nx2N: |
---|
2640 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2; |
---|
2641 | break; |
---|
2642 | case SIZE_NxN: |
---|
2643 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx; |
---|
2644 | break; |
---|
2645 | case SIZE_2NxnU: |
---|
2646 | riWidth = getWidth( uiTmpAbsPartIdx ); |
---|
2647 | riHeight = ( uiPartIdx == 0 ) ? getHeight( uiTmpAbsPartIdx ) >> 2 : ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ); |
---|
2648 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3; |
---|
2649 | break; |
---|
2650 | case SIZE_2NxnD: |
---|
2651 | riWidth = getWidth( uiTmpAbsPartIdx ); |
---|
2652 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ) : getHeight( uiTmpAbsPartIdx ) >> 2; |
---|
2653 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3); |
---|
2654 | break; |
---|
2655 | case SIZE_nLx2N: |
---|
2656 | riWidth = ( uiPartIdx == 0 ) ? getWidth( uiTmpAbsPartIdx ) >> 2 : ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ); |
---|
2657 | riHeight = getHeight( uiTmpAbsPartIdx ); |
---|
2658 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4; |
---|
2659 | break; |
---|
2660 | case SIZE_nRx2N: |
---|
2661 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ) : getWidth( uiTmpAbsPartIdx ) >> 2; |
---|
2662 | riHeight = getHeight( uiTmpAbsPartIdx ); |
---|
2663 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4); |
---|
2664 | break; |
---|
2665 | default: |
---|
2666 | assert ( m_pePartSize[uiTmpAbsPartIdx] == SIZE_2Nx2N ); |
---|
2667 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = 0; |
---|
2668 | break; |
---|
2669 | } |
---|
2670 | } |
---|
2671 | #else |
---|
2672 | |
---|
2673 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
---|
2674 | { |
---|
2675 | switch ( m_pePartSize[0] ) |
---|
2676 | { |
---|
2677 | case SIZE_2NxN: |
---|
2678 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2679 | break; |
---|
2680 | case SIZE_Nx2N: |
---|
2681 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
2682 | break; |
---|
2683 | case SIZE_NxN: |
---|
2684 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2685 | break; |
---|
2686 | case SIZE_2NxnU: |
---|
2687 | riWidth = getWidth(0); |
---|
2688 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
2689 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
---|
2690 | break; |
---|
2691 | case SIZE_2NxnD: |
---|
2692 | riWidth = getWidth(0); |
---|
2693 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
2694 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
---|
2695 | break; |
---|
2696 | case SIZE_nLx2N: |
---|
2697 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
2698 | riHeight = getHeight(0); |
---|
2699 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
---|
2700 | break; |
---|
2701 | case SIZE_nRx2N: |
---|
2702 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
2703 | riHeight = getHeight(0); |
---|
2704 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2705 | break; |
---|
2706 | default: |
---|
2707 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
2708 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
2709 | break; |
---|
2710 | } |
---|
2711 | } |
---|
2712 | #endif |
---|
2713 | |
---|
2714 | |
---|
2715 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
2716 | { |
---|
2717 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
2718 | { |
---|
2719 | TComMv cZeroMv; |
---|
2720 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
2721 | return; |
---|
2722 | } |
---|
2723 | |
---|
2724 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
2725 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
2726 | } |
---|
2727 | |
---|
2728 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2729 | { |
---|
2730 | ruiPartIdxLT = m_absZIdxInCtu + uiAbsPartIdx; |
---|
2731 | UInt uiPUWidth = 0; |
---|
2732 | |
---|
2733 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2734 | { |
---|
2735 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2736 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2737 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2738 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2739 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2740 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2741 | case SIZE_nLx2N: |
---|
2742 | if ( uiPartIdx == 0 ) |
---|
2743 | { |
---|
2744 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
2745 | } |
---|
2746 | else if ( uiPartIdx == 1 ) |
---|
2747 | { |
---|
2748 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
2749 | } |
---|
2750 | else |
---|
2751 | { |
---|
2752 | assert(0); |
---|
2753 | } |
---|
2754 | break; |
---|
2755 | case SIZE_nRx2N: |
---|
2756 | if ( uiPartIdx == 0 ) |
---|
2757 | { |
---|
2758 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
2759 | } |
---|
2760 | else if ( uiPartIdx == 1 ) |
---|
2761 | { |
---|
2762 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
2763 | } |
---|
2764 | else |
---|
2765 | { |
---|
2766 | assert(0); |
---|
2767 | } |
---|
2768 | break; |
---|
2769 | default: |
---|
2770 | assert (0); |
---|
2771 | break; |
---|
2772 | } |
---|
2773 | |
---|
2774 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2775 | } |
---|
2776 | |
---|
2777 | Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2778 | { |
---|
2779 | UInt uiPUHeight = 0; |
---|
2780 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2781 | { |
---|
2782 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2783 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2784 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2785 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2786 | case SIZE_2NxnU: |
---|
2787 | if ( uiPartIdx == 0 ) |
---|
2788 | { |
---|
2789 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
2790 | } |
---|
2791 | else if ( uiPartIdx == 1 ) |
---|
2792 | { |
---|
2793 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
2794 | } |
---|
2795 | else |
---|
2796 | { |
---|
2797 | assert(0); |
---|
2798 | } |
---|
2799 | break; |
---|
2800 | case SIZE_2NxnD: |
---|
2801 | if ( uiPartIdx == 0 ) |
---|
2802 | { |
---|
2803 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
2804 | } |
---|
2805 | else if ( uiPartIdx == 1 ) |
---|
2806 | { |
---|
2807 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
2808 | } |
---|
2809 | else |
---|
2810 | { |
---|
2811 | assert(0); |
---|
2812 | } |
---|
2813 | break; |
---|
2814 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2815 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2816 | default: |
---|
2817 | assert (0); |
---|
2818 | break; |
---|
2819 | } |
---|
2820 | |
---|
2821 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInCtuWidth()]; |
---|
2822 | } |
---|
2823 | |
---|
2824 | Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2825 | { |
---|
2826 | ruiPartIdxLT = m_absZIdxInCtu; |
---|
2827 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2828 | |
---|
2829 | switch ( m_pePartSize[0] ) |
---|
2830 | { |
---|
2831 | case SIZE_2Nx2N: break; |
---|
2832 | case SIZE_2NxN: |
---|
2833 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2834 | break; |
---|
2835 | case SIZE_Nx2N: |
---|
2836 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
2837 | break; |
---|
2838 | case SIZE_NxN: |
---|
2839 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2840 | break; |
---|
2841 | case SIZE_2NxnU: |
---|
2842 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2843 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2844 | break; |
---|
2845 | case SIZE_2NxnD: |
---|
2846 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2847 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2848 | break; |
---|
2849 | case SIZE_nLx2N: |
---|
2850 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
---|
2851 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2852 | break; |
---|
2853 | case SIZE_nRx2N: |
---|
2854 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2855 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
---|
2856 | break; |
---|
2857 | default: |
---|
2858 | assert (0); |
---|
2859 | break; |
---|
2860 | } |
---|
2861 | |
---|
2862 | } |
---|
2863 | |
---|
2864 | Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2865 | { |
---|
2866 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth()]; |
---|
2867 | |
---|
2868 | switch ( m_pePartSize[0] ) |
---|
2869 | { |
---|
2870 | case SIZE_2Nx2N: |
---|
2871 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
2872 | break; |
---|
2873 | case SIZE_2NxN: |
---|
2874 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2875 | break; |
---|
2876 | case SIZE_Nx2N: |
---|
2877 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
2878 | break; |
---|
2879 | case SIZE_NxN: |
---|
2880 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2881 | break; |
---|
2882 | case SIZE_2NxnU: |
---|
2883 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
2884 | break; |
---|
2885 | case SIZE_2NxnD: |
---|
2886 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
2887 | break; |
---|
2888 | case SIZE_nLx2N: |
---|
2889 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
---|
2890 | break; |
---|
2891 | case SIZE_nRx2N: |
---|
2892 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2893 | break; |
---|
2894 | default: |
---|
2895 | assert (0); |
---|
2896 | break; |
---|
2897 | } |
---|
2898 | } |
---|
2899 | |
---|
2900 | /** Derive the partition index of neighbouring bottom right block |
---|
2901 | * \param [in] uiPartIdx current partition index |
---|
2902 | * \param [out] ruiPartIdxRB partition index of neighbouring bottom right block |
---|
2903 | */ |
---|
2904 | Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt &ruiPartIdxRB ) |
---|
2905 | { |
---|
2906 | 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]; |
---|
2907 | |
---|
2908 | switch ( m_pePartSize[0] ) |
---|
2909 | { |
---|
2910 | case SIZE_2Nx2N: |
---|
2911 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
2912 | break; |
---|
2913 | case SIZE_2NxN: |
---|
2914 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2915 | break; |
---|
2916 | case SIZE_Nx2N: |
---|
2917 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
2918 | break; |
---|
2919 | case SIZE_NxN: |
---|
2920 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2921 | break; |
---|
2922 | case SIZE_2NxnU: |
---|
2923 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
2924 | break; |
---|
2925 | case SIZE_2NxnD: |
---|
2926 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
2927 | break; |
---|
2928 | case SIZE_nLx2N: |
---|
2929 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
---|
2930 | break; |
---|
2931 | case SIZE_nRx2N: |
---|
2932 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
---|
2933 | break; |
---|
2934 | default: |
---|
2935 | assert (0); |
---|
2936 | break; |
---|
2937 | } |
---|
2938 | } |
---|
2939 | |
---|
2940 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
2941 | { |
---|
2942 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
2943 | { |
---|
2944 | return false; |
---|
2945 | } |
---|
2946 | |
---|
2947 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
2948 | { |
---|
2949 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
2950 | { |
---|
2951 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
2952 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
2953 | { |
---|
2954 | return false; |
---|
2955 | } |
---|
2956 | } |
---|
2957 | } |
---|
2958 | |
---|
2959 | return true; |
---|
2960 | } |
---|
2961 | |
---|
2962 | #if H_3D_VSP |
---|
2963 | |
---|
2964 | /** Add a VSP merging candidate |
---|
2965 | * \Inputs |
---|
2966 | * \param uiPUIdx: PU index within a CU |
---|
2967 | * \param ucVspMergePos: Specify the VSP merge candidate position |
---|
2968 | * \param mrgCandIdx: Target merge candidate index. At encoder, it is set equal to -1, such that the whole merge candidate list will be constructed. |
---|
2969 | * \param pDinfo: The "disparity information" derived from neighboring blocks. Type 1 MV. |
---|
2970 | * \param uiCount: The next position to add VSP merge candidate |
---|
2971 | * |
---|
2972 | * \Outputs |
---|
2973 | * \param uiCount: The next position to add merge candidate. Will be updated if VSP is successfully added |
---|
2974 | * \param abCandIsInter: abCandIsInter[iCount] tells that VSP candidate is an Inter candidate, if VSP is successfully added |
---|
2975 | * \param pcMvFieldNeighbours: Return combined motion information, then stored to a global buffer |
---|
2976 | * 1) the "disparity vector". Type 1 MV. To be used to fetch a depth block. |
---|
2977 | * 2) the ref index /list. Type 2 reference picture pointer, typically for texture |
---|
2978 | * \param puhInterDirNeighbours: Indicate the VSP prediction direction. |
---|
2979 | * \param vspFlag: vspFlag[iCount] will be set (equal to 1), if VSP is successfully added. To be used to indicate the actual position of the VSP candidate |
---|
2980 | * |
---|
2981 | * \Return |
---|
2982 | * true: if the VSP candidate is added at the target position |
---|
2983 | * false: otherwise |
---|
2984 | */ |
---|
2985 | inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount) |
---|
2986 | { |
---|
2987 | if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getViewSynthesisPredFlag( ) || m_pcSlice->getIsDepth() || pDInfo->m_aVIdxCan == -1) |
---|
2988 | { |
---|
2989 | return false; |
---|
2990 | } |
---|
2991 | |
---|
2992 | Int refViewIdx = pDInfo->m_aVIdxCan; |
---|
2993 | TComPic* picDepth = getSlice()->getIvPic( true, refViewIdx ); |
---|
2994 | |
---|
2995 | if( picDepth == NULL ) // No depth reference avail |
---|
2996 | { |
---|
2997 | // Is this allowed to happen? When not an assertion should be added here! |
---|
2998 | return false; |
---|
2999 | } |
---|
3000 | |
---|
3001 | TComMvField mvVSP[2]; |
---|
3002 | UChar dirVSP; |
---|
3003 | Bool refViewAvailFlag = false; |
---|
3004 | UChar predFlag[2] = {0, 0}; |
---|
3005 | |
---|
3006 | for( Int iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ ) |
---|
3007 | { |
---|
3008 | RefPicList eRefPicListX = RefPicList( iRefListIdX ); |
---|
3009 | for ( Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicListX) && !refViewAvailFlag; i++ ) |
---|
3010 | { |
---|
3011 | Int viewIdxRefInListX = m_pcSlice->getRefPic(eRefPicListX, i)->getViewIndex(); |
---|
3012 | if ( viewIdxRefInListX == refViewIdx ) |
---|
3013 | { |
---|
3014 | refViewAvailFlag = true; |
---|
3015 | predFlag[iRefListIdX] = 1; |
---|
3016 | mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i ); |
---|
3017 | #if H_3D_NBDV |
---|
3018 | mvVSP[0+iRefListIdX].getMv().setIDVFlag (false); |
---|
3019 | #endif |
---|
3020 | } |
---|
3021 | } |
---|
3022 | } |
---|
3023 | |
---|
3024 | dirVSP = (predFlag[0] | (predFlag[1] << 1)); |
---|
3025 | m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true, false); |
---|
3026 | if ( mrgCandIdx == iCount ) |
---|
3027 | { |
---|
3028 | return true; |
---|
3029 | } |
---|
3030 | |
---|
3031 | iCount++; |
---|
3032 | |
---|
3033 | return false; |
---|
3034 | } |
---|
3035 | |
---|
3036 | #endif |
---|
3037 | |
---|
3038 | #if H_3D_IV_MERGE |
---|
3039 | inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx ) |
---|
3040 | { |
---|
3041 | for(Int iLoop = 0; iLoop < 2; iLoop ++ ) |
---|
3042 | { |
---|
3043 | /// iLoop = 0 --> IvMCShift |
---|
3044 | /// iLoop = 1 --> IvDCShift (Derived from IvDC) |
---|
3045 | if(ivCandDir[iLoop + 2]) |
---|
3046 | { |
---|
3047 | TComMvField tmpMV[2]; |
---|
3048 | UChar tmpDir = ivCandDir[iLoop + 2]; |
---|
3049 | if( ( ivCandDir[iLoop + 2] & 1 ) == 1 ) |
---|
3050 | { |
---|
3051 | tmpMV[0].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] ); |
---|
3052 | } |
---|
3053 | if( ( ivCandDir[iLoop + 2] & 2 ) == 2 ) |
---|
3054 | { |
---|
3055 | tmpMV[1].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] ); |
---|
3056 | } |
---|
3057 | |
---|
3058 | // Prune IvMC vs. IvMcShift |
---|
3059 | Bool bRemove = false; |
---|
3060 | if( !iLoop && ivCandDir[0] > 0) |
---|
3061 | { |
---|
3062 | if(tmpDir == m_mergCands[MRG_IVMC].m_uDir && m_mergCands[MRG_IVMC].m_cMvField[0]==tmpMV[0] && m_mergCands[MRG_IVMC].m_cMvField[1]==tmpMV[1]) |
---|
3063 | { |
---|
3064 | bRemove = true; |
---|
3065 | } |
---|
3066 | } |
---|
3067 | if(!bRemove) |
---|
3068 | { |
---|
3069 | #if H_3D_NBDV |
---|
3070 | if(iLoop) // For IvMcShift candidate |
---|
3071 | { |
---|
3072 | tmpMV[0].getMv().setIDVFlag (false); |
---|
3073 | tmpMV[1].getMv().setIDVFlag (false); |
---|
3074 | } |
---|
3075 | #endif |
---|
3076 | m_mergCands[MRG_IVSHIFT].setCand(tmpMV, tmpDir, false, false); |
---|
3077 | if( mrgCandIdx == iCount ) |
---|
3078 | { |
---|
3079 | return true; |
---|
3080 | } |
---|
3081 | iCount++; |
---|
3082 | } |
---|
3083 | break; |
---|
3084 | } |
---|
3085 | } |
---|
3086 | return false; |
---|
3087 | } |
---|
3088 | |
---|
3089 | #endif |
---|
3090 | #if H_3D |
---|
3091 | Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
3092 | #if H_3D_VSP |
---|
3093 | , Int* vspFlag |
---|
3094 | #endif |
---|
3095 | #if H_3D_SPIVMP |
---|
3096 | , Bool* pbSPIVMPFlag |
---|
3097 | #endif |
---|
3098 | , Int& numValidMergeCand |
---|
3099 | ) |
---|
3100 | { |
---|
3101 | if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) // for only dependent texture |
---|
3102 | { |
---|
3103 | return; |
---|
3104 | } |
---|
3105 | |
---|
3106 | Int iCount = 0; |
---|
3107 | TComMv cZeroMv; |
---|
3108 | |
---|
3109 | // init temporal list |
---|
3110 | TComMvField extMergeCandList[MRG_MAX_NUM_CANDS_MEM << 1]; |
---|
3111 | UChar uhInterDirNeighboursExt[MRG_MAX_NUM_CANDS_MEM]; |
---|
3112 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
3113 | { |
---|
3114 | uhInterDirNeighboursExt[ui] = puhInterDirNeighbours[ui]; |
---|
3115 | extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID); |
---|
3116 | extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID); |
---|
3117 | vspFlag[ui] = 0; |
---|
3118 | } |
---|
3119 | |
---|
3120 | // add candidates to temporal list |
---|
3121 | // insert MPI ... IvShift candidate |
---|
3122 | for (Int i=0; i<=MRG_IVSHIFT; i++) |
---|
3123 | { |
---|
3124 | if (m_mergCands[i].m_bAvailable) |
---|
3125 | { |
---|
3126 | m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt, vspFlag, pbSPIVMPFlag); |
---|
3127 | iCount++; |
---|
3128 | if (iCount >= getSlice()->getMaxNumMergeCand()) |
---|
3129 | break; |
---|
3130 | } |
---|
3131 | } |
---|
3132 | |
---|
3133 | // insert remaining base candidates |
---|
3134 | while (iCount < getSlice()->getMaxNumMergeCand() && m_baseListidc < getSlice()->getMaxNumMergeCand()) |
---|
3135 | { |
---|
3136 | uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[m_baseListidc]; |
---|
3137 | extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[m_baseListidc<<1].getMv(), pcMvFieldNeighbours[m_baseListidc<<1].getRefIdx()); |
---|
3138 | if ( getSlice()->isInterB() ) |
---|
3139 | { |
---|
3140 | extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(m_baseListidc<<1)+1].getMv(), pcMvFieldNeighbours[(m_baseListidc<<1)+1].getRefIdx()); |
---|
3141 | } |
---|
3142 | m_baseListidc++; |
---|
3143 | iCount++; |
---|
3144 | } |
---|
3145 | |
---|
3146 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ ) |
---|
3147 | { |
---|
3148 | puhInterDirNeighbours[ui] = 0; |
---|
3149 | pcMvFieldNeighbours[ui<<1].setMvField(cZeroMv, NOT_VALID); |
---|
3150 | pcMvFieldNeighbours[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID); |
---|
3151 | } |
---|
3152 | // copy extMergeCandList to output |
---|
3153 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ ) |
---|
3154 | { |
---|
3155 | puhInterDirNeighbours[ui] = uhInterDirNeighboursExt[ui]; |
---|
3156 | pcMvFieldNeighbours[ui<<1].setMvField(extMergeCandList[ui<<1].getMv(), extMergeCandList[ui<<1].getRefIdx()); |
---|
3157 | if ( getSlice()->isInterB() ) |
---|
3158 | pcMvFieldNeighbours[(ui<<1)+1].setMvField(extMergeCandList[(ui<<1)+1].getMv(), extMergeCandList[(ui<<1)+1].getRefIdx()); |
---|
3159 | } |
---|
3160 | numValidMergeCand = iCount; |
---|
3161 | assert(iCount == getSlice()->getMaxNumMergeCand()); |
---|
3162 | } |
---|
3163 | |
---|
3164 | /** Constructs a list of merging candidates |
---|
3165 | * \param uiAbsPartIdx |
---|
3166 | * \param uiPUIdx |
---|
3167 | * \param uiDepth |
---|
3168 | * \param pcMvFieldNeighbours |
---|
3169 | * \param puhInterDirNeighbours |
---|
3170 | * \param numValidMergeCand |
---|
3171 | */ |
---|
3172 | // HM 12.0 based merge candidate list construction |
---|
3173 | |
---|
3174 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) |
---|
3175 | { |
---|
3176 | |
---|
3177 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
3178 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ]; |
---|
3179 | TComMv cZeroMv; |
---|
3180 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
3181 | { |
---|
3182 | abCandIsInter[ui] = false; |
---|
3183 | pcMvFieldNeighbours[ ( ui << 1 ) ].setMvField(cZeroMv, NOT_VALID); |
---|
3184 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID); |
---|
3185 | } |
---|
3186 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
3187 | // compute the location of the current PU |
---|
3188 | Int xP, yP, nPSW, nPSH; |
---|
3189 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
3190 | |
---|
3191 | Int iCount = 0; |
---|
3192 | |
---|
3193 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
3194 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
3195 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
3196 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
3197 | |
---|
3198 | //left |
---|
3199 | UInt uiLeftPartIdx = 0; |
---|
3200 | TComDataCU* pcCULeft = 0; |
---|
3201 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
3202 | Bool isAvailableA1 = pcCULeft && |
---|
3203 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
3204 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
3205 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
---|
3206 | if ( isAvailableA1 ) |
---|
3207 | { |
---|
3208 | m_bAvailableFlagA1 = 1; |
---|
3209 | abCandIsInter[iCount] = true; |
---|
3210 | // get Inter Dir |
---|
3211 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
3212 | // get Mv from Left |
---|
3213 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3214 | if ( getSlice()->isInterB() ) |
---|
3215 | { |
---|
3216 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3217 | } |
---|
3218 | |
---|
3219 | iCount ++; |
---|
3220 | } |
---|
3221 | |
---|
3222 | // early termination |
---|
3223 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3224 | { |
---|
3225 | return; |
---|
3226 | } |
---|
3227 | // above |
---|
3228 | UInt uiAbovePartIdx = 0; |
---|
3229 | TComDataCU* pcCUAbove = 0; |
---|
3230 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
3231 | Bool isAvailableB1 = pcCUAbove && |
---|
3232 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
3233 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
3234 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
---|
3235 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
3236 | { |
---|
3237 | m_bAvailableFlagB1 = 1; |
---|
3238 | abCandIsInter[iCount] = true; |
---|
3239 | // get Inter Dir |
---|
3240 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
3241 | // get Mv from Left |
---|
3242 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3243 | if ( getSlice()->isInterB() ) |
---|
3244 | { |
---|
3245 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3246 | } |
---|
3247 | if ( mrgCandIdx == iCount ) |
---|
3248 | { |
---|
3249 | return; |
---|
3250 | } |
---|
3251 | iCount ++; |
---|
3252 | } |
---|
3253 | // early termination |
---|
3254 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3255 | { |
---|
3256 | return; |
---|
3257 | } |
---|
3258 | |
---|
3259 | // above right |
---|
3260 | UInt uiAboveRightPartIdx = 0; |
---|
3261 | TComDataCU* pcCUAboveRight = 0; |
---|
3262 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
3263 | Bool isAvailableB0 = pcCUAboveRight && |
---|
3264 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
3265 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
---|
3266 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
3267 | { |
---|
3268 | m_bAvailableFlagB0 = 1; |
---|
3269 | abCandIsInter[iCount] = true; |
---|
3270 | // get Inter Dir |
---|
3271 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
3272 | // get Mv from Left |
---|
3273 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3274 | if ( getSlice()->isInterB() ) |
---|
3275 | { |
---|
3276 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3277 | } |
---|
3278 | if ( mrgCandIdx == iCount ) |
---|
3279 | { |
---|
3280 | return; |
---|
3281 | } |
---|
3282 | iCount ++; |
---|
3283 | } |
---|
3284 | // early termination |
---|
3285 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3286 | { |
---|
3287 | return; |
---|
3288 | } |
---|
3289 | |
---|
3290 | //left bottom |
---|
3291 | UInt uiLeftBottomPartIdx = 0; |
---|
3292 | TComDataCU* pcCULeftBottom = 0; |
---|
3293 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
3294 | Bool isAvailableA0 = pcCULeftBottom && |
---|
3295 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
3296 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
---|
3297 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
3298 | { |
---|
3299 | m_bAvailableFlagA0 = 1; |
---|
3300 | abCandIsInter[iCount] = true; |
---|
3301 | // get Inter Dir |
---|
3302 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
3303 | // get Mv from Left |
---|
3304 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3305 | if ( getSlice()->isInterB() ) |
---|
3306 | { |
---|
3307 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3308 | } |
---|
3309 | if ( mrgCandIdx == iCount ) |
---|
3310 | { |
---|
3311 | return; |
---|
3312 | } |
---|
3313 | iCount ++; |
---|
3314 | } |
---|
3315 | // early termination |
---|
3316 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3317 | { |
---|
3318 | return; |
---|
3319 | } |
---|
3320 | // above left |
---|
3321 | if( iCount < 4 ) |
---|
3322 | { |
---|
3323 | UInt uiAboveLeftPartIdx = 0; |
---|
3324 | TComDataCU* pcCUAboveLeft = 0; |
---|
3325 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
3326 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
3327 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
3328 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
---|
3329 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
3330 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
3331 | { |
---|
3332 | m_bAvailableFlagB2 = 1; |
---|
3333 | abCandIsInter[iCount] = true; |
---|
3334 | // get Inter Dir |
---|
3335 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
3336 | // get Mv from Left |
---|
3337 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3338 | if ( getSlice()->isInterB() ) |
---|
3339 | { |
---|
3340 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3341 | } |
---|
3342 | if ( mrgCandIdx == iCount ) |
---|
3343 | { |
---|
3344 | return; |
---|
3345 | } |
---|
3346 | iCount ++; |
---|
3347 | } |
---|
3348 | } |
---|
3349 | // early termination |
---|
3350 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3351 | { |
---|
3352 | return; |
---|
3353 | } |
---|
3354 | if ( getSlice()->getEnableTMVPFlag()) |
---|
3355 | { |
---|
3356 | //>> MTK colocated-RightBottom |
---|
3357 | UInt uiPartIdxRB; |
---|
3358 | |
---|
3359 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
3360 | |
---|
3361 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
3362 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
3363 | |
---|
3364 | TComMv cColMv; |
---|
3365 | Int iRefIdx; |
---|
3366 | Int uiLCUIdx = -1; |
---|
3367 | |
---|
3368 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
3369 | { |
---|
3370 | } |
---|
3371 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
3372 | { |
---|
3373 | } |
---|
3374 | else |
---|
3375 | { |
---|
3376 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
3377 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
3378 | { |
---|
3379 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
3380 | uiLCUIdx = getAddr(); |
---|
3381 | } |
---|
3382 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
3383 | { |
---|
3384 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
3385 | } |
---|
3386 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
3387 | { |
---|
3388 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
3389 | uiLCUIdx = getAddr() + 1; |
---|
3390 | } |
---|
3391 | else //is the right bottom corner of LCU |
---|
3392 | { |
---|
3393 | uiAbsPartAddr = 0; |
---|
3394 | } |
---|
3395 | } |
---|
3396 | |
---|
3397 | iRefIdx = 0; |
---|
3398 | Bool bExistMV = false; |
---|
3399 | UInt uiPartIdxCenter; |
---|
3400 | UInt uiCurLCUIdx = getAddr(); |
---|
3401 | Int dir = 0; |
---|
3402 | UInt uiArrayAddr = iCount; |
---|
3403 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
3404 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
3405 | if( bExistMV == false ) |
---|
3406 | { |
---|
3407 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
3408 | } |
---|
3409 | if( bExistMV ) |
---|
3410 | { |
---|
3411 | dir |= 1; |
---|
3412 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
3413 | } |
---|
3414 | |
---|
3415 | if ( getSlice()->isInterB() ) |
---|
3416 | { |
---|
3417 | #if H_3D_TMVP |
---|
3418 | iRefIdx = 0; |
---|
3419 | #endif |
---|
3420 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
3421 | if( bExistMV == false ) |
---|
3422 | { |
---|
3423 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
3424 | } |
---|
3425 | if( bExistMV ) |
---|
3426 | { |
---|
3427 | dir |= 2; |
---|
3428 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
3429 | } |
---|
3430 | } |
---|
3431 | |
---|
3432 | if (dir != 0) |
---|
3433 | { |
---|
3434 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
3435 | abCandIsInter[uiArrayAddr] = true; |
---|
3436 | #if H_3D_NBDV |
---|
3437 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
---|
3438 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
---|
3439 | #endif |
---|
3440 | if ( mrgCandIdx == iCount ) |
---|
3441 | { |
---|
3442 | return; |
---|
3443 | } |
---|
3444 | iCount++; |
---|
3445 | } |
---|
3446 | } |
---|
3447 | // early termination |
---|
3448 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3449 | { |
---|
3450 | return; |
---|
3451 | } |
---|
3452 | UInt uiArrayAddr = iCount; |
---|
3453 | UInt uiCutoff = uiArrayAddr; |
---|
3454 | |
---|
3455 | if ( getSlice()->isInterB() && iCount<5) // JCT3V-F0129 by Qualcomm |
---|
3456 | { |
---|
3457 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
3458 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
3459 | |
---|
3460 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
3461 | { |
---|
3462 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
3463 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
3464 | { |
---|
3465 | abCandIsInter[uiArrayAddr] = true; |
---|
3466 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3467 | |
---|
3468 | // get Mv from cand[i] and cand[j] |
---|
3469 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
3470 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
3471 | |
---|
3472 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
3473 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
3474 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
3475 | { |
---|
3476 | abCandIsInter[uiArrayAddr] = false; |
---|
3477 | } |
---|
3478 | else |
---|
3479 | { |
---|
3480 | uiArrayAddr++; |
---|
3481 | } |
---|
3482 | } |
---|
3483 | } |
---|
3484 | } |
---|
3485 | // early termination |
---|
3486 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
3487 | { |
---|
3488 | return; |
---|
3489 | } |
---|
3490 | |
---|
3491 | 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); |
---|
3492 | Int r = 0; |
---|
3493 | Int refcnt = 0; |
---|
3494 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
3495 | { |
---|
3496 | abCandIsInter[uiArrayAddr] = true; |
---|
3497 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
3498 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
3499 | |
---|
3500 | if ( getSlice()->isInterB() ) |
---|
3501 | { |
---|
3502 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3503 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
3504 | } |
---|
3505 | uiArrayAddr++; |
---|
3506 | if ( refcnt == iNumRefIdx - 1 ) |
---|
3507 | { |
---|
3508 | r = 0; |
---|
3509 | } |
---|
3510 | else |
---|
3511 | { |
---|
3512 | ++r; |
---|
3513 | ++refcnt; |
---|
3514 | } |
---|
3515 | } |
---|
3516 | |
---|
3517 | numValidMergeCand = uiArrayAddr; |
---|
3518 | } |
---|
3519 | |
---|
3520 | |
---|
3521 | |
---|
3522 | /** Constructs a list of merging candidates |
---|
3523 | * \param uiAbsPartIdx |
---|
3524 | * \param uiPUIdx |
---|
3525 | * \param uiDepth |
---|
3526 | * \param pcMvFieldNeighbours |
---|
3527 | * \param puhInterDirNeighbours |
---|
3528 | * \param numValidMergeCand |
---|
3529 | */ |
---|
3530 | #if H_3D |
---|
3531 | Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
3532 | #else |
---|
3533 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
3534 | #endif |
---|
3535 | #if H_3D_SPIVMP |
---|
3536 | , TComMvField* pcMvFieldSP, UChar* puhInterDirSP |
---|
3537 | #endif |
---|
3538 | , Int& numValidMergeCand, Int mrgCandIdx |
---|
3539 | ) |
---|
3540 | { |
---|
3541 | #if H_3D_IV_MERGE |
---|
3542 | //////////////////////////// |
---|
3543 | //////// INIT LISTS //////// |
---|
3544 | //////////////////////////// |
---|
3545 | TComMv cZeroMv; |
---|
3546 | #else |
---|
3547 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
3548 | #endif |
---|
3549 | #if H_3D |
---|
3550 | TComMvField tmpMV[2]; |
---|
3551 | UChar tmpDir; |
---|
3552 | |
---|
3553 | |
---|
3554 | ////////////////////////////////// |
---|
3555 | //////// GET DISPARITIES //////// |
---|
3556 | ////////////////////////////////// |
---|
3557 | DisInfo cDisInfo = getDvInfo(uiAbsPartIdx); |
---|
3558 | m_cDefaultDisInfo = cDisInfo; |
---|
3559 | |
---|
3560 | if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) // current slice is not both dependent view or depth |
---|
3561 | { |
---|
3562 | return; |
---|
3563 | } |
---|
3564 | #else |
---|
3565 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
3566 | { |
---|
3567 | abCandIsInter[ui] = false; |
---|
3568 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
3569 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
3570 | } |
---|
3571 | #endif |
---|
3572 | |
---|
3573 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
3574 | #if H_3D |
---|
3575 | ////////////////////////////////// |
---|
3576 | //////// DERIVE LOCATIONS //////// |
---|
3577 | ////////////////////////////////// |
---|
3578 | #endif |
---|
3579 | // compute the location of the current PU |
---|
3580 | Int xP, yP, nPSW, nPSH; |
---|
3581 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
3582 | |
---|
3583 | Int iCount = 0; |
---|
3584 | |
---|
3585 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
3586 | #if !H_3D |
---|
3587 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
3588 | #endif |
---|
3589 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
3590 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
3591 | #if H_3D |
---|
3592 | Bool bMPIFlag = getSlice()->getMpiFlag(); |
---|
3593 | Bool bIsDepth = getSlice()->getIsDepth(); |
---|
3594 | #endif |
---|
3595 | |
---|
3596 | #if H_3D_IC |
---|
3597 | Bool bICFlag = getICFlag(uiAbsPartIdx); |
---|
3598 | #endif |
---|
3599 | #if H_3D_ARP |
---|
3600 | Bool bARPFlag = getARPW(uiAbsPartIdx) > 0; |
---|
3601 | #endif |
---|
3602 | #if H_3D_DBBP |
---|
3603 | Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx); |
---|
3604 | assert(bDBBPFlag == getDBBPFlag(0)); |
---|
3605 | #endif |
---|
3606 | |
---|
3607 | #if H_3D |
---|
3608 | #if H_3D_NBDV |
---|
3609 | for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) |
---|
3610 | { |
---|
3611 | pcMvFieldNeighbours[i<<1 ].getMv().setIDVFlag (false); |
---|
3612 | pcMvFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false); |
---|
3613 | } |
---|
3614 | #endif |
---|
3615 | // Clean version for MCL construction align with WD |
---|
3616 | // init mergCands list |
---|
3617 | for (Int i = 0; i<MRG_IVSHIFT+1; i++) |
---|
3618 | { |
---|
3619 | m_mergCands[i].init(); |
---|
3620 | } |
---|
3621 | |
---|
3622 | m_baseListidc = 0; |
---|
3623 | |
---|
3624 | //left |
---|
3625 | UInt uiLeftPartIdx = 0; |
---|
3626 | TComDataCU* pcCULeft = 0; |
---|
3627 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
3628 | |
---|
3629 | if (getAvailableFlagA1()) |
---|
3630 | { |
---|
3631 | m_mergCands[MRG_A1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3632 | #if H_3D_VSP |
---|
3633 | , (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0 |
---|
3634 | #if H_3D_IC |
---|
3635 | && !bICFlag |
---|
3636 | #endif |
---|
3637 | #if H_3D_ARP |
---|
3638 | && !bARPFlag |
---|
3639 | #endif |
---|
3640 | #if H_3D_DBBP |
---|
3641 | && !bDBBPFlag |
---|
3642 | #endif |
---|
3643 | ) |
---|
3644 | #endif |
---|
3645 | , false |
---|
3646 | ); |
---|
3647 | m_baseListidc++; |
---|
3648 | } |
---|
3649 | |
---|
3650 | // above |
---|
3651 | |
---|
3652 | if (getAvailableFlagB1()) |
---|
3653 | { |
---|
3654 | m_mergCands[MRG_B1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3655 | #if H_3D_VSP |
---|
3656 | , false |
---|
3657 | #endif |
---|
3658 | , false |
---|
3659 | ); |
---|
3660 | m_baseListidc++; |
---|
3661 | } |
---|
3662 | |
---|
3663 | // above right |
---|
3664 | |
---|
3665 | if (getAvailableFlagB0()) |
---|
3666 | { |
---|
3667 | m_mergCands[MRG_B0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3668 | #if H_3D_VSP |
---|
3669 | , |
---|
3670 | false |
---|
3671 | #endif |
---|
3672 | , false |
---|
3673 | ); |
---|
3674 | m_baseListidc++; |
---|
3675 | } |
---|
3676 | |
---|
3677 | // left bottom |
---|
3678 | |
---|
3679 | if (getAvailableFlagA0()) |
---|
3680 | { |
---|
3681 | m_mergCands[MRG_A0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3682 | #if H_3D_VSP |
---|
3683 | , false |
---|
3684 | #endif |
---|
3685 | , false |
---|
3686 | ); |
---|
3687 | m_baseListidc++; |
---|
3688 | } |
---|
3689 | |
---|
3690 | // above left |
---|
3691 | |
---|
3692 | if (getAvailableFlagB2()) |
---|
3693 | { |
---|
3694 | m_mergCands[MRG_B2].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3695 | #if H_3D_VSP |
---|
3696 | , false |
---|
3697 | #endif |
---|
3698 | , false |
---|
3699 | ); |
---|
3700 | m_baseListidc++; |
---|
3701 | } |
---|
3702 | |
---|
3703 | #endif |
---|
3704 | |
---|
3705 | |
---|
3706 | #if H_3D_IV_MERGE |
---|
3707 | |
---|
3708 | ///////////////////////////////////////////// |
---|
3709 | //////// TEXTURE MERGE CANDIDATE (T) //////// |
---|
3710 | ///////////////////////////////////////////// |
---|
3711 | |
---|
3712 | bMPIFlag &= (nPSW + nPSH > 12); |
---|
3713 | if( bMPIFlag) |
---|
3714 | { |
---|
3715 | tmpMV[0].setMvField( cZeroMv, NOT_VALID ); |
---|
3716 | tmpMV[1].setMvField( cZeroMv, NOT_VALID ); |
---|
3717 | tmpDir = 0; |
---|
3718 | |
---|
3719 | Bool bSPIVMPFlag = false; |
---|
3720 | |
---|
3721 | TComPic * pcTexPic = m_pcSlice->getTexturePic(); |
---|
3722 | #if H_3D_FCO |
---|
3723 | if (pcTexPic && pcTexPic->getReconMark()) |
---|
3724 | { |
---|
3725 | #endif |
---|
3726 | TComPicYuv* pcTexRec = pcTexPic->getPicYuvRec (); |
---|
3727 | UInt uiPartAddr; |
---|
3728 | Int iWidth, iHeight; |
---|
3729 | Int iCurrPosX, iCurrPosY; |
---|
3730 | |
---|
3731 | this->getPartIndexAndSize( uiPUIdx, uiPartAddr, iWidth, iHeight ); |
---|
3732 | pcTexRec->getTopLeftSamplePos( this->getAddr(), this->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
3733 | |
---|
3734 | Int iPUWidth, iPUHeight, iNumPart, iNumPartLine; |
---|
3735 | this->getSPPara(iWidth, iHeight, iNumPart, iNumPartLine, iPUWidth, iPUHeight); |
---|
3736 | |
---|
3737 | for (Int i=0; i<iNumPart; i++) |
---|
3738 | { |
---|
3739 | puhInterDirSP[i] = 0; |
---|
3740 | pcMvFieldSP[2*i].getMv().set(0, 0); |
---|
3741 | pcMvFieldSP[2*i+1].getMv().set(0, 0); |
---|
3742 | pcMvFieldSP[2*i].setRefIdx(-1); |
---|
3743 | pcMvFieldSP[2*i+1].setRefIdx(-1); |
---|
3744 | } |
---|
3745 | |
---|
3746 | Int iTexCUAddr; |
---|
3747 | Int iTexAbsPartIdx; |
---|
3748 | TComDataCU* pcTexCU; |
---|
3749 | Int iPartition = 0; |
---|
3750 | Int iInterDirSaved = 0; |
---|
3751 | TComMvField cMvFieldSaved[2]; |
---|
3752 | |
---|
3753 | Int iOffsetX = iPUWidth/2;; |
---|
3754 | Int iOffsetY = iPUHeight/2; |
---|
3755 | |
---|
3756 | Int iTexPosX, iTexPosY; |
---|
3757 | const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); |
---|
3758 | |
---|
3759 | Int iCenterPosX = iCurrPosX + ( ( iWidth / iPUWidth ) >> 1 ) * iPUWidth + ( iPUWidth >> 1 ); |
---|
3760 | Int iCenterPosY = iCurrPosY + ( ( iHeight / iPUHeight ) >> 1 ) * iPUHeight + (iPUHeight >> 1); |
---|
3761 | Int iTexCenterCUAddr, iTexCenterAbsPartIdx; |
---|
3762 | |
---|
3763 | if(iWidth == iPUWidth && iHeight == iPUHeight) |
---|
3764 | { |
---|
3765 | iCenterPosX = iCurrPosX + (iWidth >> 1); |
---|
3766 | iCenterPosY = iCurrPosY + (iHeight >> 1); |
---|
3767 | } |
---|
3768 | |
---|
3769 | // derivation of center motion parameters from the collocated texture CU |
---|
3770 | |
---|
3771 | pcTexRec->getCUAddrAndPartIdx( iCenterPosX , iCenterPosY , iTexCenterCUAddr, iTexCenterAbsPartIdx ); |
---|
3772 | TComDataCU* pcDefaultCU = pcTexPic->getCU( iTexCenterCUAddr ); |
---|
3773 | |
---|
3774 | if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA ) |
---|
3775 | { |
---|
3776 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
3777 | { |
---|
3778 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
3779 | |
---|
3780 | TComMvField cDefaultMvField; |
---|
3781 | pcDefaultCU->getMvField( pcDefaultCU, iTexCenterAbsPartIdx, eCurrRefPicList, cDefaultMvField ); |
---|
3782 | Int iDefaultRefIdx = cDefaultMvField.getRefIdx(); |
---|
3783 | if (iDefaultRefIdx >= 0) |
---|
3784 | { |
---|
3785 | Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eCurrRefPicList, iDefaultRefIdx); |
---|
3786 | for (Int iRefPicList = 0; iRefPicList < m_pcSlice->getNumRefIdx( eCurrRefPicList ); iRefPicList++) |
---|
3787 | { |
---|
3788 | if (iDefaultRefPOC == m_pcSlice->getRefPOC(eCurrRefPicList, iRefPicList)) |
---|
3789 | { |
---|
3790 | bSPIVMPFlag = true; |
---|
3791 | TComMv cMv = cDefaultMvField.getMv() + cMvRounding; |
---|
3792 | cMv >>= 2; |
---|
3793 | cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ; |
---|
3794 | break; |
---|
3795 | } |
---|
3796 | } |
---|
3797 | } |
---|
3798 | } |
---|
3799 | } |
---|
3800 | if ( bSPIVMPFlag == true ) |
---|
3801 | { |
---|
3802 | iInterDirSaved = (cMvFieldSaved[0].getRefIdx()!=-1 ? 1: 0) + (cMvFieldSaved[1].getRefIdx()!=-1 ? 2: 0); |
---|
3803 | tmpDir = iInterDirSaved; |
---|
3804 | tmpMV[0] = cMvFieldSaved[0]; |
---|
3805 | tmpMV[1] = cMvFieldSaved[1]; |
---|
3806 | } |
---|
3807 | |
---|
3808 | if ( iInterDirSaved != 0 ) |
---|
3809 | { |
---|
3810 | for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iPUHeight) |
---|
3811 | { |
---|
3812 | for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iPUWidth) |
---|
3813 | { |
---|
3814 | iTexPosX = j + iOffsetX; |
---|
3815 | iTexPosY = i + iOffsetY; |
---|
3816 | pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx ); |
---|
3817 | pcTexCU = pcTexPic->getCU( iTexCUAddr ); |
---|
3818 | |
---|
3819 | if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) ) |
---|
3820 | { |
---|
3821 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
3822 | { |
---|
3823 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
3824 | TComMvField cTexMvField; |
---|
3825 | pcTexCU->getMvField( pcTexCU, iTexAbsPartIdx, eCurrRefPicList, cTexMvField ); |
---|
3826 | Int iValidDepRef = getPic()->isTextRefValid( eCurrRefPicList, cTexMvField.getRefIdx() ); |
---|
3827 | if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) ) |
---|
3828 | { |
---|
3829 | TComMv cMv = cTexMvField.getMv() + cMvRounding; |
---|
3830 | cMv >>=2; |
---|
3831 | pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef); |
---|
3832 | } |
---|
3833 | } |
---|
3834 | } |
---|
3835 | puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0); |
---|
3836 | if (puhInterDirSP[iPartition] == 0) |
---|
3837 | { |
---|
3838 | if (iInterDirSaved != 0) |
---|
3839 | { |
---|
3840 | puhInterDirSP[iPartition] = iInterDirSaved; |
---|
3841 | pcMvFieldSP[2*iPartition] = cMvFieldSaved[0]; |
---|
3842 | pcMvFieldSP[2*iPartition + 1] = cMvFieldSaved[1]; |
---|
3843 | } |
---|
3844 | } |
---|
3845 | |
---|
3846 | iPartition ++; |
---|
3847 | } |
---|
3848 | } |
---|
3849 | #if H_3D |
---|
3850 | } |
---|
3851 | #endif |
---|
3852 | #if H_3D_FCO |
---|
3853 | } |
---|
3854 | #endif |
---|
3855 | if( tmpDir != 0 ) |
---|
3856 | { |
---|
3857 | Int iCnloop = 0; |
---|
3858 | for(iCnloop = 0; iCnloop < 2; iCnloop ++) |
---|
3859 | { |
---|
3860 | if ( !m_mergCands[MRG_A1+iCnloop].m_bAvailable ) // prunning to A1, B1 |
---|
3861 | { |
---|
3862 | continue; |
---|
3863 | } |
---|
3864 | if (tmpDir == m_mergCands[MRG_A1+iCnloop].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+iCnloop].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+iCnloop].m_cMvField[1]) |
---|
3865 | { |
---|
3866 | m_mergCands[MRG_A1+iCnloop].m_bAvailable = false; |
---|
3867 | break; |
---|
3868 | } |
---|
3869 | } |
---|
3870 | m_mergCands[MRG_T].setCand( tmpMV, tmpDir, false, bSPIVMPFlag); |
---|
3871 | |
---|
3872 | if ( mrgCandIdx == iCount ) |
---|
3873 | { |
---|
3874 | return; |
---|
3875 | } |
---|
3876 | iCount ++; |
---|
3877 | } |
---|
3878 | } |
---|
3879 | ///////////////////////////////////////////////////////////////// |
---|
3880 | //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC Candidates ///// |
---|
3881 | ///////////////////////////////////////////////////////////////// |
---|
3882 | |
---|
3883 | // { IvMCL0, IvMCL1, IvDCL0, IvDCL1, IvMCL0Shift, IvMCL1Shift, IvDCL0Shift, IvDCL1Shift }; |
---|
3884 | // An enumerator would be appropriate here! |
---|
3885 | TComMv ivCandMv [8]; |
---|
3886 | Int ivCandRefIdx[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; |
---|
3887 | |
---|
3888 | // { IvMC, IvDC, IvMCShift, IvDCShift }; |
---|
3889 | Int ivCandDir [4] = {0, 0, 0, 0}; |
---|
3890 | |
---|
3891 | Bool ivMvPredFlag = getSlice()->getIvMvPredFlag(); |
---|
3892 | |
---|
3893 | ivMvPredFlag &= (nPSW + nPSH > 12); |
---|
3894 | if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1) |
---|
3895 | { |
---|
3896 | getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag ); |
---|
3897 | } |
---|
3898 | |
---|
3899 | /////////////////////////////////////////////// |
---|
3900 | //////// INTER VIEW MOTION COMP(IvMC) ///////// |
---|
3901 | /////////////////////////////////////////////// |
---|
3902 | if( getSlice()->getIsDepth() ) |
---|
3903 | { |
---|
3904 | ivCandDir[1] = ivCandDir[2] = ivCandDir[3] = 0; |
---|
3905 | } |
---|
3906 | |
---|
3907 | if( ivCandDir[0] ) |
---|
3908 | { |
---|
3909 | tmpMV[0].setMvField( cZeroMv, NOT_VALID ); |
---|
3910 | tmpMV[1].setMvField( cZeroMv, NOT_VALID ); |
---|
3911 | |
---|
3912 | if( ( ivCandDir[0] & 1 ) == 1 ) |
---|
3913 | { |
---|
3914 | tmpMV[0].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] ); |
---|
3915 | } |
---|
3916 | if( ( ivCandDir[0] & 2 ) == 2 ) |
---|
3917 | { |
---|
3918 | tmpMV[1].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] ); |
---|
3919 | } |
---|
3920 | |
---|
3921 | Bool bRemoveSpa = false; //pruning |
---|
3922 | |
---|
3923 | if (!bIsDepth) |
---|
3924 | { |
---|
3925 | for(Int i = 0; i < 2; i ++) |
---|
3926 | { |
---|
3927 | if ( !m_mergCands[MRG_A1 + i].m_bAvailable ) // prunning to A1, B1 |
---|
3928 | { |
---|
3929 | continue; |
---|
3930 | } |
---|
3931 | if (ivCandDir[0] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1]) |
---|
3932 | { |
---|
3933 | m_mergCands[MRG_A1+i].m_bAvailable = false; |
---|
3934 | break; |
---|
3935 | } |
---|
3936 | } |
---|
3937 | } |
---|
3938 | if (bIsDepth) |
---|
3939 | { |
---|
3940 | if (m_mergCands[MRG_T].m_bAvailable && ivCandDir[0] == m_mergCands[MRG_T].m_uDir && tmpMV[0]==m_mergCands[MRG_T].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_T].m_cMvField[1]) |
---|
3941 | { |
---|
3942 | bRemoveSpa = true; |
---|
3943 | } |
---|
3944 | } |
---|
3945 | if (!bRemoveSpa) |
---|
3946 | { |
---|
3947 | Bool spiMvpFlag = false; |
---|
3948 | if(!m_pcSlice->getIsDepth()) |
---|
3949 | { |
---|
3950 | spiMvpFlag = true; |
---|
3951 | } |
---|
3952 | #if H_3D_DBBP |
---|
3953 | spiMvpFlag &= !bDBBPFlag; |
---|
3954 | #endif |
---|
3955 | |
---|
3956 | m_mergCands[MRG_IVMC].setCand( tmpMV, ivCandDir[0], false, spiMvpFlag); |
---|
3957 | |
---|
3958 | if ( mrgCandIdx == iCount ) |
---|
3959 | { |
---|
3960 | return; |
---|
3961 | } |
---|
3962 | iCount ++; |
---|
3963 | } |
---|
3964 | } |
---|
3965 | |
---|
3966 | // early termination |
---|
3967 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3968 | { |
---|
3969 | return; |
---|
3970 | } |
---|
3971 | #endif |
---|
3972 | |
---|
3973 | #if H_3D |
---|
3974 | iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable; |
---|
3975 | #else |
---|
3976 | //left |
---|
3977 | UInt uiLeftPartIdx = 0; |
---|
3978 | TComDataCU* pcCULeft = 0; |
---|
3979 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
3980 | Bool isAvailableA1 = pcCULeft && |
---|
3981 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
3982 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
3983 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
---|
3984 | if ( isAvailableA1 ) |
---|
3985 | { |
---|
3986 | abCandIsInter[iCount] = true; |
---|
3987 | // get Inter Dir |
---|
3988 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
3989 | // get Mv from Left |
---|
3990 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3991 | if ( getSlice()->isInterB() ) |
---|
3992 | { |
---|
3993 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3994 | } |
---|
3995 | |
---|
3996 | if ( mrgCandIdx == iCount ) |
---|
3997 | { |
---|
3998 | return; |
---|
3999 | } |
---|
4000 | iCount ++; |
---|
4001 | } |
---|
4002 | |
---|
4003 | // early termination |
---|
4004 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4005 | { |
---|
4006 | return; |
---|
4007 | } |
---|
4008 | |
---|
4009 | // above |
---|
4010 | UInt uiAbovePartIdx = 0; |
---|
4011 | TComDataCU* pcCUAbove = 0; |
---|
4012 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
4013 | Bool isAvailableB1 = pcCUAbove && |
---|
4014 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
4015 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
4016 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
---|
4017 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
4018 | { |
---|
4019 | abCandIsInter[iCount] = true; |
---|
4020 | // get Inter Dir |
---|
4021 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
4022 | // get Mv from Left |
---|
4023 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4024 | if ( getSlice()->isInterB() ) |
---|
4025 | { |
---|
4026 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4027 | } |
---|
4028 | |
---|
4029 | if ( mrgCandIdx == iCount ) |
---|
4030 | { |
---|
4031 | return; |
---|
4032 | } |
---|
4033 | iCount ++; |
---|
4034 | } |
---|
4035 | // early termination |
---|
4036 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4037 | { |
---|
4038 | return; |
---|
4039 | } |
---|
4040 | |
---|
4041 | // above right |
---|
4042 | UInt uiAboveRightPartIdx = 0; |
---|
4043 | TComDataCU* pcCUAboveRight = 0; |
---|
4044 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
4045 | Bool isAvailableB0 = pcCUAboveRight && |
---|
4046 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
4047 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
---|
4048 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
4049 | { |
---|
4050 | abCandIsInter[iCount] = true; |
---|
4051 | // get Inter Dir |
---|
4052 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
4053 | // get Mv from Left |
---|
4054 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4055 | if ( getSlice()->isInterB() ) |
---|
4056 | { |
---|
4057 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4058 | } |
---|
4059 | |
---|
4060 | if ( mrgCandIdx == iCount ) |
---|
4061 | { |
---|
4062 | return; |
---|
4063 | } |
---|
4064 | iCount ++; |
---|
4065 | } |
---|
4066 | // early termination |
---|
4067 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4068 | { |
---|
4069 | return; |
---|
4070 | } |
---|
4071 | #endif |
---|
4072 | |
---|
4073 | |
---|
4074 | #if H_3D_VSP |
---|
4075 | ///////////////////////////////////////////////// |
---|
4076 | //////// VIEW SYNTHESIS PREDICTION (VSP) //////// |
---|
4077 | ///////////////////////////////////////////////// |
---|
4078 | if (iCount<getSlice()->getMaxNumMergeCand()) |
---|
4079 | { |
---|
4080 | if ( |
---|
4081 | (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) && |
---|
4082 | #if H_3D_IC |
---|
4083 | !bICFlag && |
---|
4084 | #endif |
---|
4085 | #if H_3D_ARP |
---|
4086 | !bARPFlag && |
---|
4087 | #endif |
---|
4088 | #if H_3D |
---|
4089 | (nPSW + nPSH > 12) && |
---|
4090 | #endif |
---|
4091 | #if H_3D_DBBP |
---|
4092 | !bDBBPFlag && |
---|
4093 | #endif |
---|
4094 | xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) ) |
---|
4095 | { |
---|
4096 | return; |
---|
4097 | } |
---|
4098 | |
---|
4099 | // early termination |
---|
4100 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4101 | { |
---|
4102 | return; |
---|
4103 | } |
---|
4104 | #endif |
---|
4105 | #if H_3D_VSP |
---|
4106 | } |
---|
4107 | #endif |
---|
4108 | |
---|
4109 | #if H_3D |
---|
4110 | iCount += m_mergCands[MRG_B0].m_bAvailable; |
---|
4111 | #endif |
---|
4112 | |
---|
4113 | |
---|
4114 | #if H_3D_IV_MERGE |
---|
4115 | ///////////////////////////////////////////// |
---|
4116 | //////// INTER VIEW DISP COMP (IvDC) //////// |
---|
4117 | ///////////////////////////////////////////// |
---|
4118 | if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) |
---|
4119 | { |
---|
4120 | assert(iCount < getSlice()->getMaxNumMergeCand()); |
---|
4121 | |
---|
4122 | tmpMV[0].setMvField( cZeroMv, NOT_VALID ); |
---|
4123 | tmpMV[1].setMvField( cZeroMv, NOT_VALID ); |
---|
4124 | if( ( ivCandDir[1] & 1 ) == 1 ) |
---|
4125 | { |
---|
4126 | tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] ); |
---|
4127 | } |
---|
4128 | if( ( ivCandDir[1] & 2 ) == 2 ) |
---|
4129 | { |
---|
4130 | tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] ); |
---|
4131 | } |
---|
4132 | |
---|
4133 | Bool bRemoveSpa = false; //pruning to A1, B1 |
---|
4134 | for(Int i = 0; i < 2; i ++) |
---|
4135 | { |
---|
4136 | if ( !m_mergCands[MRG_A1+i].m_bAvailable ) |
---|
4137 | { |
---|
4138 | continue; |
---|
4139 | } |
---|
4140 | if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1]) |
---|
4141 | { |
---|
4142 | bRemoveSpa = true; |
---|
4143 | break; |
---|
4144 | } |
---|
4145 | } |
---|
4146 | if(!bRemoveSpa) |
---|
4147 | { |
---|
4148 | #if H_3D_NBDV |
---|
4149 | tmpMV[0].getMv().setIDVFlag (false); |
---|
4150 | tmpMV[1].getMv().setIDVFlag (false); |
---|
4151 | #endif |
---|
4152 | m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false); |
---|
4153 | |
---|
4154 | if ( mrgCandIdx == iCount ) |
---|
4155 | return; |
---|
4156 | iCount ++; |
---|
4157 | |
---|
4158 | // early termination |
---|
4159 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4160 | { |
---|
4161 | return; |
---|
4162 | } |
---|
4163 | } |
---|
4164 | } |
---|
4165 | #endif // H_3D_IV_MERGE |
---|
4166 | |
---|
4167 | |
---|
4168 | #if H_3D |
---|
4169 | iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable; |
---|
4170 | #else |
---|
4171 | //left bottom |
---|
4172 | UInt uiLeftBottomPartIdx = 0; |
---|
4173 | TComDataCU* pcCULeftBottom = 0; |
---|
4174 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
4175 | Bool isAvailableA0 = pcCULeftBottom && |
---|
4176 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
4177 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
---|
4178 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
4179 | { |
---|
4180 | abCandIsInter[iCount] = true; |
---|
4181 | // get Inter Dir |
---|
4182 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
4183 | // get Mv from Left |
---|
4184 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4185 | if ( getSlice()->isInterB() ) |
---|
4186 | { |
---|
4187 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4188 | } |
---|
4189 | if ( mrgCandIdx == iCount ) |
---|
4190 | { |
---|
4191 | return; |
---|
4192 | } |
---|
4193 | iCount ++; |
---|
4194 | } |
---|
4195 | // early termination |
---|
4196 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4197 | { |
---|
4198 | return; |
---|
4199 | } |
---|
4200 | |
---|
4201 | // above left |
---|
4202 | if( iCount < 4 ) |
---|
4203 | { |
---|
4204 | UInt uiAboveLeftPartIdx = 0; |
---|
4205 | TComDataCU* pcCUAboveLeft = 0; |
---|
4206 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
4207 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
4208 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
4209 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
---|
4210 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
4211 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
4212 | { |
---|
4213 | abCandIsInter[iCount] = true; |
---|
4214 | // get Inter Dir |
---|
4215 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
4216 | // get Mv from Left |
---|
4217 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4218 | if ( getSlice()->isInterB() ) |
---|
4219 | { |
---|
4220 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4221 | } |
---|
4222 | if ( mrgCandIdx == iCount ) |
---|
4223 | { |
---|
4224 | return; |
---|
4225 | } |
---|
4226 | iCount ++; |
---|
4227 | } |
---|
4228 | } |
---|
4229 | // early termination |
---|
4230 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4231 | { |
---|
4232 | return; |
---|
4233 | } |
---|
4234 | #endif |
---|
4235 | |
---|
4236 | |
---|
4237 | #if H_3D_IV_MERGE |
---|
4238 | //////////////////////////////////////////////////// |
---|
4239 | //////// SHIFTED IV (IvMCShift + IvDCShift) //////// |
---|
4240 | //////////////////////////////////////////////////// |
---|
4241 | if( ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) |
---|
4242 | { |
---|
4243 | if(xAddIvMRGCand( mrgCandIdx, iCount, ivCandDir, ivCandMv, ivCandRefIdx ) ) |
---|
4244 | { |
---|
4245 | return; |
---|
4246 | } |
---|
4247 | //early termination |
---|
4248 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4249 | { |
---|
4250 | return; |
---|
4251 | } |
---|
4252 | } |
---|
4253 | #endif |
---|
4254 | #if !H_3D |
---|
4255 | if ( getSlice()->getEnableTMVPFlag()) |
---|
4256 | { |
---|
4257 | //>> MTK colocated-RightBottom |
---|
4258 | UInt uiPartIdxRB; |
---|
4259 | |
---|
4260 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
4261 | |
---|
4262 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
4263 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
4264 | |
---|
4265 | TComMv cColMv; |
---|
4266 | Int iRefIdx; |
---|
4267 | Int uiLCUIdx = -1; |
---|
4268 | |
---|
4269 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
4270 | { |
---|
4271 | } |
---|
4272 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
4273 | { |
---|
4274 | } |
---|
4275 | else |
---|
4276 | { |
---|
4277 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
4278 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
4279 | { |
---|
4280 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
4281 | uiLCUIdx = getAddr(); |
---|
4282 | } |
---|
4283 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
4284 | { |
---|
4285 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
4286 | } |
---|
4287 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
4288 | { |
---|
4289 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
4290 | uiLCUIdx = getAddr() + 1; |
---|
4291 | } |
---|
4292 | else //is the right bottom corner of LCU |
---|
4293 | { |
---|
4294 | uiAbsPartAddr = 0; |
---|
4295 | } |
---|
4296 | } |
---|
4297 | |
---|
4298 | |
---|
4299 | iRefIdx = 0; |
---|
4300 | Bool bExistMV = false; |
---|
4301 | UInt uiPartIdxCenter; |
---|
4302 | UInt uiCurLCUIdx = getAddr(); |
---|
4303 | Int dir = 0; |
---|
4304 | UInt uiArrayAddr = iCount; |
---|
4305 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
4306 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
4307 | if( bExistMV == false ) |
---|
4308 | { |
---|
4309 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4310 | } |
---|
4311 | if( bExistMV ) |
---|
4312 | { |
---|
4313 | dir |= 1; |
---|
4314 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
4315 | } |
---|
4316 | |
---|
4317 | if ( getSlice()->isInterB() ) |
---|
4318 | { |
---|
4319 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
4320 | if( bExistMV == false ) |
---|
4321 | { |
---|
4322 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4323 | } |
---|
4324 | if( bExistMV ) |
---|
4325 | { |
---|
4326 | dir |= 2; |
---|
4327 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
4328 | } |
---|
4329 | } |
---|
4330 | |
---|
4331 | if (dir != 0) |
---|
4332 | { |
---|
4333 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
4334 | abCandIsInter[uiArrayAddr] = true; |
---|
4335 | if ( mrgCandIdx == iCount ) |
---|
4336 | { |
---|
4337 | return; |
---|
4338 | } |
---|
4339 | iCount++; |
---|
4340 | } |
---|
4341 | } |
---|
4342 | // early termination |
---|
4343 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4344 | { |
---|
4345 | return; |
---|
4346 | } |
---|
4347 | UInt uiArrayAddr = iCount; |
---|
4348 | UInt uiCutoff = uiArrayAddr; |
---|
4349 | |
---|
4350 | if ( getSlice()->isInterB()) |
---|
4351 | { |
---|
4352 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
4353 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
4354 | |
---|
4355 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
4356 | { |
---|
4357 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
4358 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
4359 | { |
---|
4360 | abCandIsInter[uiArrayAddr] = true; |
---|
4361 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4362 | |
---|
4363 | // get Mv from cand[i] and cand[j] |
---|
4364 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
4365 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
4366 | |
---|
4367 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
4368 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
4369 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
4370 | { |
---|
4371 | abCandIsInter[uiArrayAddr] = false; |
---|
4372 | } |
---|
4373 | else |
---|
4374 | { |
---|
4375 | uiArrayAddr++; |
---|
4376 | } |
---|
4377 | } |
---|
4378 | } |
---|
4379 | } |
---|
4380 | // early termination |
---|
4381 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
4382 | { |
---|
4383 | return; |
---|
4384 | } |
---|
4385 | 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); |
---|
4386 | Int r = 0; |
---|
4387 | Int refcnt = 0; |
---|
4388 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
4389 | { |
---|
4390 | abCandIsInter[uiArrayAddr] = true; |
---|
4391 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
4392 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
4393 | |
---|
4394 | if ( getSlice()->isInterB() ) |
---|
4395 | { |
---|
4396 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4397 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
4398 | } |
---|
4399 | uiArrayAddr++; |
---|
4400 | if ( refcnt == iNumRefIdx - 1 ) |
---|
4401 | { |
---|
4402 | r = 0; |
---|
4403 | } |
---|
4404 | else |
---|
4405 | { |
---|
4406 | ++r; |
---|
4407 | ++refcnt; |
---|
4408 | } |
---|
4409 | } |
---|
4410 | |
---|
4411 | numValidMergeCand = uiArrayAddr; |
---|
4412 | #endif |
---|
4413 | } |
---|
4414 | #else |
---|
4415 | |
---|
4416 | //! Construct a list of merging candidates |
---|
4417 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) |
---|
4418 | { |
---|
4419 | UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx; |
---|
4420 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
4421 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
4422 | { |
---|
4423 | abCandIsInter[ui] = false; |
---|
4424 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
4425 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
4426 | } |
---|
4427 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
4428 | // compute the location of the current PU |
---|
4429 | Int xP, yP, nPSW, nPSH; |
---|
4430 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
4431 | |
---|
4432 | Int iCount = 0; |
---|
4433 | |
---|
4434 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
4435 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
4436 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
4437 | deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
4438 | |
---|
4439 | //left |
---|
4440 | UInt uiLeftPartIdx = 0; |
---|
4441 | TComDataCU* pcCULeft = 0; |
---|
4442 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
4443 | |
---|
4444 | Bool isAvailableA1 = pcCULeft && |
---|
4445 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
4446 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
4447 | pcCULeft->isInter( uiLeftPartIdx ) ; |
---|
4448 | |
---|
4449 | if ( isAvailableA1 ) |
---|
4450 | { |
---|
4451 | abCandIsInter[iCount] = true; |
---|
4452 | // get Inter Dir |
---|
4453 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
4454 | // get Mv from Left |
---|
4455 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4456 | if ( getSlice()->isInterB() ) |
---|
4457 | { |
---|
4458 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4459 | } |
---|
4460 | if ( mrgCandIdx == iCount ) |
---|
4461 | { |
---|
4462 | return; |
---|
4463 | } |
---|
4464 | iCount ++; |
---|
4465 | } |
---|
4466 | |
---|
4467 | // early termination |
---|
4468 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4469 | { |
---|
4470 | return; |
---|
4471 | } |
---|
4472 | // above |
---|
4473 | UInt uiAbovePartIdx = 0; |
---|
4474 | TComDataCU* pcCUAbove = 0; |
---|
4475 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
4476 | |
---|
4477 | Bool isAvailableB1 = pcCUAbove && |
---|
4478 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
4479 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
4480 | pcCUAbove->isInter( uiAbovePartIdx ); |
---|
4481 | |
---|
4482 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
4483 | { |
---|
4484 | abCandIsInter[iCount] = true; |
---|
4485 | // get Inter Dir |
---|
4486 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
4487 | // get Mv from Left |
---|
4488 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4489 | if ( getSlice()->isInterB() ) |
---|
4490 | { |
---|
4491 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4492 | } |
---|
4493 | if ( mrgCandIdx == iCount ) |
---|
4494 | { |
---|
4495 | return; |
---|
4496 | } |
---|
4497 | iCount ++; |
---|
4498 | } |
---|
4499 | // early termination |
---|
4500 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4501 | { |
---|
4502 | return; |
---|
4503 | } |
---|
4504 | |
---|
4505 | // above right |
---|
4506 | UInt uiAboveRightPartIdx = 0; |
---|
4507 | TComDataCU* pcCUAboveRight = 0; |
---|
4508 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
4509 | |
---|
4510 | Bool isAvailableB0 = pcCUAboveRight && |
---|
4511 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
4512 | pcCUAboveRight->isInter( uiAboveRightPartIdx ); |
---|
4513 | |
---|
4514 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
4515 | { |
---|
4516 | abCandIsInter[iCount] = true; |
---|
4517 | // get Inter Dir |
---|
4518 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
4519 | // get Mv from Left |
---|
4520 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4521 | if ( getSlice()->isInterB() ) |
---|
4522 | { |
---|
4523 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4524 | } |
---|
4525 | if ( mrgCandIdx == iCount ) |
---|
4526 | { |
---|
4527 | return; |
---|
4528 | } |
---|
4529 | iCount ++; |
---|
4530 | } |
---|
4531 | // early termination |
---|
4532 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4533 | { |
---|
4534 | return; |
---|
4535 | } |
---|
4536 | |
---|
4537 | //left bottom |
---|
4538 | UInt uiLeftBottomPartIdx = 0; |
---|
4539 | TComDataCU* pcCULeftBottom = 0; |
---|
4540 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
4541 | |
---|
4542 | Bool isAvailableA0 = pcCULeftBottom && |
---|
4543 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
4544 | pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ; |
---|
4545 | |
---|
4546 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
4547 | { |
---|
4548 | abCandIsInter[iCount] = true; |
---|
4549 | // get Inter Dir |
---|
4550 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
4551 | // get Mv from Left |
---|
4552 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4553 | if ( getSlice()->isInterB() ) |
---|
4554 | { |
---|
4555 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4556 | } |
---|
4557 | if ( mrgCandIdx == iCount ) |
---|
4558 | { |
---|
4559 | return; |
---|
4560 | } |
---|
4561 | iCount ++; |
---|
4562 | } |
---|
4563 | // early termination |
---|
4564 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4565 | { |
---|
4566 | return; |
---|
4567 | } |
---|
4568 | |
---|
4569 | // above left |
---|
4570 | if( iCount < 4 ) |
---|
4571 | { |
---|
4572 | UInt uiAboveLeftPartIdx = 0; |
---|
4573 | TComDataCU* pcCUAboveLeft = 0; |
---|
4574 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
4575 | |
---|
4576 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
4577 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
4578 | pcCUAboveLeft->isInter( uiAboveLeftPartIdx ); |
---|
4579 | |
---|
4580 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
4581 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
4582 | { |
---|
4583 | abCandIsInter[iCount] = true; |
---|
4584 | // get Inter Dir |
---|
4585 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
4586 | // get Mv from Left |
---|
4587 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4588 | if ( getSlice()->isInterB() ) |
---|
4589 | { |
---|
4590 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4591 | } |
---|
4592 | if ( mrgCandIdx == iCount ) |
---|
4593 | { |
---|
4594 | return; |
---|
4595 | } |
---|
4596 | iCount ++; |
---|
4597 | } |
---|
4598 | } |
---|
4599 | // early termination |
---|
4600 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4601 | { |
---|
4602 | return; |
---|
4603 | } |
---|
4604 | |
---|
4605 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
4606 | { |
---|
4607 | //>> MTK colocated-RightBottom |
---|
4608 | UInt uiPartIdxRB; |
---|
4609 | |
---|
4610 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
4611 | |
---|
4612 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
4613 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
4614 | const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); |
---|
4615 | |
---|
4616 | TComMv cColMv; |
---|
4617 | Int iRefIdx; |
---|
4618 | Int ctuRsAddr = -1; |
---|
4619 | |
---|
4620 | if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check |
---|
4621 | && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
4622 | { |
---|
4623 | if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU |
---|
4624 | ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU |
---|
4625 | { |
---|
4626 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ]; |
---|
4627 | ctuRsAddr = getCtuRsAddr(); |
---|
4628 | } |
---|
4629 | else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU |
---|
4630 | { |
---|
4631 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; |
---|
4632 | } |
---|
4633 | else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU |
---|
4634 | { |
---|
4635 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
4636 | ctuRsAddr = getCtuRsAddr() + 1; |
---|
4637 | } |
---|
4638 | else //is the right bottom corner of CTU |
---|
4639 | { |
---|
4640 | uiAbsPartAddr = 0; |
---|
4641 | } |
---|
4642 | } |
---|
4643 | |
---|
4644 | iRefIdx = 0; |
---|
4645 | |
---|
4646 | Bool bExistMV = false; |
---|
4647 | UInt uiPartIdxCenter; |
---|
4648 | Int dir = 0; |
---|
4649 | UInt uiArrayAddr = iCount; |
---|
4650 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
4651 | bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
4652 | if( bExistMV == false ) |
---|
4653 | { |
---|
4654 | bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4655 | } |
---|
4656 | if( bExistMV ) |
---|
4657 | { |
---|
4658 | dir |= 1; |
---|
4659 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
4660 | } |
---|
4661 | |
---|
4662 | if ( getSlice()->isInterB() ) |
---|
4663 | { |
---|
4664 | bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx); |
---|
4665 | if( bExistMV == false ) |
---|
4666 | { |
---|
4667 | bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4668 | } |
---|
4669 | if( bExistMV ) |
---|
4670 | { |
---|
4671 | dir |= 2; |
---|
4672 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
4673 | } |
---|
4674 | } |
---|
4675 | |
---|
4676 | if (dir != 0) |
---|
4677 | { |
---|
4678 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
4679 | abCandIsInter[uiArrayAddr] = true; |
---|
4680 | |
---|
4681 | if ( mrgCandIdx == iCount ) |
---|
4682 | { |
---|
4683 | return; |
---|
4684 | } |
---|
4685 | iCount++; |
---|
4686 | } |
---|
4687 | } |
---|
4688 | // early termination |
---|
4689 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4690 | { |
---|
4691 | return; |
---|
4692 | } |
---|
4693 | |
---|
4694 | UInt uiArrayAddr = iCount; |
---|
4695 | UInt uiCutoff = uiArrayAddr; |
---|
4696 | |
---|
4697 | if ( getSlice()->isInterB() ) |
---|
4698 | { |
---|
4699 | static const UInt NUM_PRIORITY_LIST=12; |
---|
4700 | static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
4701 | static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
4702 | |
---|
4703 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
4704 | { |
---|
4705 | assert(idx<NUM_PRIORITY_LIST); |
---|
4706 | Int i = uiPriorityList0[idx]; |
---|
4707 | Int j = uiPriorityList1[idx]; |
---|
4708 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
4709 | { |
---|
4710 | abCandIsInter[uiArrayAddr] = true; |
---|
4711 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4712 | |
---|
4713 | // get Mv from cand[i] and cand[j] |
---|
4714 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
4715 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
4716 | |
---|
4717 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
4718 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
4719 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
4720 | { |
---|
4721 | abCandIsInter[uiArrayAddr] = false; |
---|
4722 | } |
---|
4723 | else |
---|
4724 | { |
---|
4725 | uiArrayAddr++; |
---|
4726 | } |
---|
4727 | } |
---|
4728 | } |
---|
4729 | } |
---|
4730 | // early termination |
---|
4731 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
4732 | { |
---|
4733 | return; |
---|
4734 | } |
---|
4735 | |
---|
4736 | 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); |
---|
4737 | |
---|
4738 | Int r = 0; |
---|
4739 | Int refcnt = 0; |
---|
4740 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
4741 | { |
---|
4742 | abCandIsInter[uiArrayAddr] = true; |
---|
4743 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
4744 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
4745 | |
---|
4746 | if ( getSlice()->isInterB() ) |
---|
4747 | { |
---|
4748 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4749 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
4750 | } |
---|
4751 | uiArrayAddr++; |
---|
4752 | |
---|
4753 | if ( refcnt == iNumRefIdx - 1 ) |
---|
4754 | { |
---|
4755 | r = 0; |
---|
4756 | } |
---|
4757 | else |
---|
4758 | { |
---|
4759 | ++r; |
---|
4760 | ++refcnt; |
---|
4761 | } |
---|
4762 | } |
---|
4763 | numValidMergeCand = uiArrayAddr; |
---|
4764 | } |
---|
4765 | #endif |
---|
4766 | |
---|
4767 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
---|
4768 | * \param xN, yN location of the upper-left corner pixel of a neighboring PU |
---|
4769 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
4770 | */ |
---|
4771 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) |
---|
4772 | { |
---|
4773 | |
---|
4774 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
---|
4775 | if ((xN>>plevel)!= (xP>>plevel)) |
---|
4776 | { |
---|
4777 | return true; |
---|
4778 | } |
---|
4779 | if ((yN>>plevel)!= (yP>>plevel)) |
---|
4780 | { |
---|
4781 | return true; |
---|
4782 | } |
---|
4783 | return false; |
---|
4784 | } |
---|
4785 | |
---|
4786 | /** Calculate the location of upper-left corner pixel and size of the current PU. |
---|
4787 | * \param partIdx PU index within a CU |
---|
4788 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
4789 | * \param nPSW, nPSH size of the current PU |
---|
4790 | */ |
---|
4791 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) |
---|
4792 | { |
---|
4793 | UInt col = m_uiCUPelX; |
---|
4794 | UInt row = m_uiCUPelY; |
---|
4795 | |
---|
4796 | switch ( m_pePartSize[0] ) |
---|
4797 | { |
---|
4798 | case SIZE_2NxN: |
---|
4799 | nPSW = getWidth(0); |
---|
4800 | nPSH = getHeight(0) >> 1; |
---|
4801 | xP = col; |
---|
4802 | yP = (partIdx ==0)? row: row + nPSH; |
---|
4803 | break; |
---|
4804 | case SIZE_Nx2N: |
---|
4805 | nPSW = getWidth(0) >> 1; |
---|
4806 | nPSH = getHeight(0); |
---|
4807 | xP = (partIdx ==0)? col: col + nPSW; |
---|
4808 | yP = row; |
---|
4809 | break; |
---|
4810 | case SIZE_NxN: |
---|
4811 | nPSW = getWidth(0) >> 1; |
---|
4812 | nPSH = getHeight(0) >> 1; |
---|
4813 | xP = col + (partIdx&0x1)*nPSW; |
---|
4814 | yP = row + (partIdx>>1)*nPSH; |
---|
4815 | break; |
---|
4816 | case SIZE_2NxnU: |
---|
4817 | nPSW = getWidth(0); |
---|
4818 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
4819 | xP = col; |
---|
4820 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
4821 | |
---|
4822 | break; |
---|
4823 | case SIZE_2NxnD: |
---|
4824 | nPSW = getWidth(0); |
---|
4825 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
4826 | xP = col; |
---|
4827 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
4828 | break; |
---|
4829 | case SIZE_nLx2N: |
---|
4830 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
4831 | nPSH = getHeight(0); |
---|
4832 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
4833 | yP = row; |
---|
4834 | break; |
---|
4835 | case SIZE_nRx2N: |
---|
4836 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
4837 | nPSH = getHeight(0); |
---|
4838 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
4839 | yP = row; |
---|
4840 | break; |
---|
4841 | default: |
---|
4842 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
4843 | nPSW = getWidth(0); |
---|
4844 | nPSH = getHeight(0); |
---|
4845 | xP = col ; |
---|
4846 | yP = row ; |
---|
4847 | |
---|
4848 | break; |
---|
4849 | } |
---|
4850 | } |
---|
4851 | |
---|
4852 | /** Constructs a list of candidates for AMVP |
---|
4853 | * \param uiPartIdx |
---|
4854 | * \param uiPartAddr |
---|
4855 | * \param eRefPicList |
---|
4856 | * \param iRefIdx |
---|
4857 | * \param pInfo |
---|
4858 | */ |
---|
4859 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
---|
4860 | { |
---|
4861 | TComMv cMvPred; |
---|
4862 | Bool bAddedSmvp = false; |
---|
4863 | |
---|
4864 | pInfo->iN = 0; |
---|
4865 | if (iRefIdx < 0) |
---|
4866 | { |
---|
4867 | return; |
---|
4868 | } |
---|
4869 | |
---|
4870 | //-- Get Spatial MV |
---|
4871 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
4872 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
4873 | const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); |
---|
4874 | Bool bAdded = false; |
---|
4875 | |
---|
4876 | deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
4877 | deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB ); |
---|
4878 | |
---|
4879 | TComDataCU* tmpCU = NULL; |
---|
4880 | UInt idx; |
---|
4881 | tmpCU = getPUBelowLeft(idx, uiPartIdxLB); |
---|
4882 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx)); |
---|
4883 | |
---|
4884 | if (!bAddedSmvp) |
---|
4885 | { |
---|
4886 | tmpCU = getPULeft(idx, uiPartIdxLB); |
---|
4887 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx)); |
---|
4888 | } |
---|
4889 | |
---|
4890 | // Left predictor search |
---|
4891 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
4892 | if (!bAdded) |
---|
4893 | { |
---|
4894 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
4895 | } |
---|
4896 | |
---|
4897 | if(!bAdded) |
---|
4898 | { |
---|
4899 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
4900 | if (!bAdded) |
---|
4901 | { |
---|
4902 | xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
4903 | } |
---|
4904 | } |
---|
4905 | |
---|
4906 | // Above predictor search |
---|
4907 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
4908 | |
---|
4909 | if (!bAdded) |
---|
4910 | { |
---|
4911 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
4912 | } |
---|
4913 | |
---|
4914 | if(!bAdded) |
---|
4915 | { |
---|
4916 | xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
4917 | } |
---|
4918 | |
---|
4919 | if(!bAddedSmvp) |
---|
4920 | { |
---|
4921 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
4922 | if (!bAdded) |
---|
4923 | { |
---|
4924 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
4925 | } |
---|
4926 | |
---|
4927 | if(!bAdded) |
---|
4928 | { |
---|
4929 | xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
4930 | } |
---|
4931 | } |
---|
4932 | |
---|
4933 | if ( pInfo->iN == 2 ) |
---|
4934 | { |
---|
4935 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
---|
4936 | { |
---|
4937 | pInfo->iN = 1; |
---|
4938 | } |
---|
4939 | } |
---|
4940 | |
---|
4941 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
4942 | { |
---|
4943 | // Get Temporal Motion Predictor |
---|
4944 | Int iRefIdx_Col = iRefIdx; |
---|
4945 | TComMv cColMv; |
---|
4946 | UInt uiPartIdxRB; |
---|
4947 | UInt uiAbsPartIdx; |
---|
4948 | UInt uiAbsPartAddr; |
---|
4949 | |
---|
4950 | deriveRightBottomIdx( uiPartIdx, uiPartIdxRB ); |
---|
4951 | uiAbsPartAddr = m_absZIdxInCtu + uiPartAddr; |
---|
4952 | |
---|
4953 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
4954 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
---|
4955 | Int ctuRsAddr = -1; |
---|
4956 | if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check |
---|
4957 | && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
4958 | { |
---|
4959 | if ( ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU |
---|
4960 | ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU |
---|
4961 | { |
---|
4962 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth + 1 ]; |
---|
4963 | ctuRsAddr = getCtuRsAddr(); |
---|
4964 | } |
---|
4965 | else if ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU |
---|
4966 | { |
---|
4967 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; |
---|
4968 | } |
---|
4969 | else if ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU |
---|
4970 | { |
---|
4971 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
---|
4972 | ctuRsAddr = getCtuRsAddr() + 1; |
---|
4973 | } |
---|
4974 | else //is the right bottom corner of CTU |
---|
4975 | { |
---|
4976 | uiAbsPartAddr = 0; |
---|
4977 | } |
---|
4978 | } |
---|
4979 | if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx_Col |
---|
4980 | #if H_3D_TMVP |
---|
4981 | , 0 |
---|
4982 | #endif |
---|
4983 | ) ) |
---|
4984 | { |
---|
4985 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
4986 | } |
---|
4987 | else |
---|
4988 | { |
---|
4989 | UInt uiPartIdxCenter; |
---|
4990 | xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); |
---|
4991 | if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx_Col |
---|
4992 | #if H_3D_TMVP |
---|
4993 | , 0 |
---|
4994 | #endif |
---|
4995 | )) |
---|
4996 | { |
---|
4997 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
4998 | } |
---|
4999 | } |
---|
5000 | //---- co-located RightBottom Temporal Predictor ---// |
---|
5001 | } |
---|
5002 | |
---|
5003 | if (pInfo->iN > AMVP_MAX_NUM_CANDS) |
---|
5004 | { |
---|
5005 | pInfo->iN = AMVP_MAX_NUM_CANDS; |
---|
5006 | } |
---|
5007 | |
---|
5008 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
---|
5009 | { |
---|
5010 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
---|
5011 | pInfo->iN++; |
---|
5012 | } |
---|
5013 | return ; |
---|
5014 | } |
---|
5015 | |
---|
5016 | |
---|
5017 | Bool TComDataCU::isBipredRestriction(UInt puIdx) |
---|
5018 | { |
---|
5019 | Int width = 0; |
---|
5020 | Int height = 0; |
---|
5021 | UInt partAddr; |
---|
5022 | |
---|
5023 | #if H_3D_DBBP |
---|
5024 | if( getDBBPFlag(0) ) |
---|
5025 | { |
---|
5026 | return true; |
---|
5027 | } |
---|
5028 | #endif |
---|
5029 | |
---|
5030 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
---|
5031 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
---|
5032 | { |
---|
5033 | return true; |
---|
5034 | } |
---|
5035 | return false; |
---|
5036 | } |
---|
5037 | |
---|
5038 | |
---|
5039 | Void TComDataCU::clipMv (TComMv& rcMv) |
---|
5040 | { |
---|
5041 | const TComSPS &sps=*(m_pcSlice->getSPS()); |
---|
5042 | Int iMvShift = 2; |
---|
5043 | #if H_3D_IC |
---|
5044 | if( getSlice()->getIsDepth() ) |
---|
5045 | iMvShift = 0; |
---|
5046 | #endif |
---|
5047 | |
---|
5048 | Int iOffset = 8; |
---|
5049 | Int iHorMax = ( sps.getPicWidthInLumaSamples() + iOffset - (Int)m_uiCUPelX - 1 ) << iMvShift; |
---|
5050 | Int iHorMin = ( -(Int)sps.getMaxCUWidth() - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
---|
5051 | |
---|
5052 | Int iVerMax = ( sps.getPicHeightInLumaSamples() + iOffset - (Int)m_uiCUPelY - 1 ) << iMvShift; |
---|
5053 | Int iVerMin = ( -(Int)sps.getMaxCUHeight() - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
---|
5054 | |
---|
5055 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
---|
5056 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
---|
5057 | } |
---|
5058 | |
---|
5059 | #if NH_MV |
---|
5060 | Void TComDataCU::checkMvVertRest (TComMv& rcMv, RefPicList eRefPicList, int iRefIdx ) |
---|
5061 | { |
---|
5062 | if ( getSlice()->getSPS()->getInterViewMvVertConstraintFlag() ) |
---|
5063 | { |
---|
5064 | if ( getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC() == getSlice()->getPOC() ) |
---|
5065 | { |
---|
5066 | //When inter_view_mv_vert_constraint_flag is equal to 1, |
---|
5067 | //the vertical component of the motion vectors used for inter-layer prediction |
---|
5068 | //shall be equal to or less than 56 in units of luma samples |
---|
5069 | assert ( rcMv.getVer() <= (56<<2) ); |
---|
5070 | } |
---|
5071 | } |
---|
5072 | } |
---|
5073 | #endif |
---|
5074 | |
---|
5075 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
---|
5076 | { |
---|
5077 | UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
5078 | |
---|
5079 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
5080 | UInt uiCnt = 0; |
---|
5081 | while( uiWidth ) |
---|
5082 | { |
---|
5083 | uiCnt++; |
---|
5084 | uiWidth>>=1; |
---|
5085 | } |
---|
5086 | uiCnt-=2; |
---|
5087 | return uiCnt > 6 ? 6 : uiCnt; |
---|
5088 | } |
---|
5089 | |
---|
5090 | Void TComDataCU::clearCbf( UInt uiIdx, ComponentID compID, UInt uiNumParts ) |
---|
5091 | { |
---|
5092 | memset( &m_puhCbf[compID][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
5093 | } |
---|
5094 | |
---|
5095 | /** Set a I_PCM flag for all sub-partitions of a partition. |
---|
5096 | * \param bIpcmFlag I_PCM flag |
---|
5097 | * \param uiAbsPartIdx patition index |
---|
5098 | * \param uiDepth CU depth |
---|
5099 | * \returns Void |
---|
5100 | */ |
---|
5101 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
---|
5102 | { |
---|
5103 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
5104 | |
---|
5105 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
---|
5106 | } |
---|
5107 | |
---|
5108 | /** Test whether the block at uiPartIdx is skipped. |
---|
5109 | * \param uiPartIdx Partition index |
---|
5110 | * \returns true if the current the block is skipped |
---|
5111 | */ |
---|
5112 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
---|
5113 | { |
---|
5114 | return ( getSkipFlag( uiPartIdx ) ); |
---|
5115 | } |
---|
5116 | |
---|
5117 | #if H_3D_IC |
---|
5118 | Bool TComDataCU::isIC( UInt uiPartIdx ) |
---|
5119 | { |
---|
5120 | if ( m_pcSlice->isIntra () ) |
---|
5121 | { |
---|
5122 | return false; |
---|
5123 | } |
---|
5124 | return ( ( getSkipFlag(uiPartIdx) || getPredictionMode(uiPartIdx) == MODE_INTER) && getICFlag( uiPartIdx ) && isICFlagRequired( uiPartIdx ) ); |
---|
5125 | } |
---|
5126 | #endif |
---|
5127 | |
---|
5128 | // ==================================================================================================================== |
---|
5129 | // Protected member functions |
---|
5130 | // ==================================================================================================================== |
---|
5131 | |
---|
5132 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
5133 | { |
---|
5134 | TComDataCU* pcTmpCU = NULL; |
---|
5135 | UInt uiIdx; |
---|
5136 | switch( eDir ) |
---|
5137 | { |
---|
5138 | case MD_LEFT: |
---|
5139 | { |
---|
5140 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
5141 | break; |
---|
5142 | } |
---|
5143 | case MD_ABOVE: |
---|
5144 | { |
---|
5145 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
5146 | break; |
---|
5147 | } |
---|
5148 | case MD_ABOVE_RIGHT: |
---|
5149 | { |
---|
5150 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
5151 | break; |
---|
5152 | } |
---|
5153 | case MD_BELOW_LEFT: |
---|
5154 | { |
---|
5155 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
5156 | break; |
---|
5157 | } |
---|
5158 | case MD_ABOVE_LEFT: |
---|
5159 | { |
---|
5160 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
5161 | break; |
---|
5162 | } |
---|
5163 | default: |
---|
5164 | { |
---|
5165 | break; |
---|
5166 | } |
---|
5167 | } |
---|
5168 | |
---|
5169 | if ( pcTmpCU == NULL ) |
---|
5170 | { |
---|
5171 | return false; |
---|
5172 | } |
---|
5173 | |
---|
5174 | if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )) |
---|
5175 | { |
---|
5176 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
5177 | |
---|
5178 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
5179 | return true; |
---|
5180 | } |
---|
5181 | |
---|
5182 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
5183 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
5184 | { |
---|
5185 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
5186 | } |
---|
5187 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
5188 | { |
---|
5189 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
5190 | } |
---|
5191 | |
---|
5192 | |
---|
5193 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
5194 | Int iNeibRefPOC; |
---|
5195 | |
---|
5196 | |
---|
5197 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
---|
5198 | { |
---|
5199 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
5200 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
---|
5201 | { |
---|
5202 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
5203 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
5204 | return true; |
---|
5205 | } |
---|
5206 | } |
---|
5207 | return false; |
---|
5208 | } |
---|
5209 | |
---|
5210 | /** |
---|
5211 | * \param pInfo |
---|
5212 | * \param eRefPicList |
---|
5213 | * \param iRefIdx |
---|
5214 | * \param uiPartUnitIdx |
---|
5215 | * \param eDir |
---|
5216 | * \returns Bool |
---|
5217 | */ |
---|
5218 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
5219 | { |
---|
5220 | TComDataCU* pcTmpCU = NULL; |
---|
5221 | UInt uiIdx; |
---|
5222 | switch( eDir ) |
---|
5223 | { |
---|
5224 | case MD_LEFT: |
---|
5225 | { |
---|
5226 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
5227 | break; |
---|
5228 | } |
---|
5229 | case MD_ABOVE: |
---|
5230 | { |
---|
5231 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
5232 | break; |
---|
5233 | } |
---|
5234 | case MD_ABOVE_RIGHT: |
---|
5235 | { |
---|
5236 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
5237 | break; |
---|
5238 | } |
---|
5239 | case MD_BELOW_LEFT: |
---|
5240 | { |
---|
5241 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
5242 | break; |
---|
5243 | } |
---|
5244 | case MD_ABOVE_LEFT: |
---|
5245 | { |
---|
5246 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
5247 | break; |
---|
5248 | } |
---|
5249 | default: |
---|
5250 | { |
---|
5251 | break; |
---|
5252 | } |
---|
5253 | } |
---|
5254 | |
---|
5255 | if ( pcTmpCU == NULL ) |
---|
5256 | { |
---|
5257 | return false; |
---|
5258 | } |
---|
5259 | |
---|
5260 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
5261 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
5262 | { |
---|
5263 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
5264 | } |
---|
5265 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
5266 | { |
---|
5267 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
5268 | } |
---|
5269 | |
---|
5270 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
5271 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
5272 | Int iNeibPOC = iCurrPOC; |
---|
5273 | Int iNeibRefPOC; |
---|
5274 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
5275 | Bool bIsNeibRefLongTerm = false; |
---|
5276 | |
---|
5277 | //--------------- V1 (END) ------------------// |
---|
5278 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
---|
5279 | { |
---|
5280 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
---|
5281 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
5282 | TComMv rcMv; |
---|
5283 | |
---|
5284 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
5285 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
5286 | { |
---|
5287 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
5288 | { |
---|
5289 | rcMv = cMvPred; |
---|
5290 | } |
---|
5291 | else |
---|
5292 | { |
---|
5293 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
5294 | if ( iScale == 4096 ) |
---|
5295 | { |
---|
5296 | rcMv = cMvPred; |
---|
5297 | } |
---|
5298 | else |
---|
5299 | { |
---|
5300 | rcMv = cMvPred.scaleMv( iScale ); |
---|
5301 | } |
---|
5302 | } |
---|
5303 | |
---|
5304 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
5305 | return true; |
---|
5306 | } |
---|
5307 | } |
---|
5308 | //---------------------- V2(END) --------------------// |
---|
5309 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
---|
5310 | { |
---|
5311 | iNeib |
---|