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 H_3D |
---|
58 | m_bDISFlag = NULL; |
---|
59 | m_uiDISType = 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 H_3D_DIM |
---|
107 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
108 | { |
---|
109 | m_dimDeltaDC[i][0] = NULL; |
---|
110 | m_dimDeltaDC[i][1] = NULL; |
---|
111 | } |
---|
112 | #if H_3D_DIM_DMM |
---|
113 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
114 | { |
---|
115 | m_dmmWedgeTabIdx[i] = NULL; |
---|
116 | } |
---|
117 | #endif |
---|
118 | #if H_3D_DIM_SDC |
---|
119 | m_pbSDCFlag = NULL; |
---|
120 | m_apSegmentDCOffset[0] = NULL; |
---|
121 | m_apSegmentDCOffset[1] = NULL; |
---|
122 | #endif |
---|
123 | #endif |
---|
124 | |
---|
125 | m_bDecSubCu = false; |
---|
126 | |
---|
127 | #if H_3D_NBDV |
---|
128 | m_pDvInfo = NULL; |
---|
129 | #endif |
---|
130 | #if H_3D_VSP |
---|
131 | m_piVSPFlag = NULL; |
---|
132 | #endif |
---|
133 | #if H_3D_SPIVMP |
---|
134 | m_pbSPIVMPFlag = NULL; |
---|
135 | #endif |
---|
136 | #if H_3D_ARP |
---|
137 | m_puhARPW = NULL; |
---|
138 | #endif |
---|
139 | #if NH_3D_IC |
---|
140 | m_pbICFlag = NULL; |
---|
141 | #endif |
---|
142 | #if H_3D_INTER_SDC |
---|
143 | #endif |
---|
144 | #if H_3D_DBBP |
---|
145 | m_pbDBBPFlag = NULL; |
---|
146 | #endif |
---|
147 | |
---|
148 | } |
---|
149 | |
---|
150 | TComDataCU::~TComDataCU() |
---|
151 | { |
---|
152 | } |
---|
153 | |
---|
154 | Void TComDataCU::create( ChromaFormat chromaFormatIDC, UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
155 | #if ADAPTIVE_QP_SELECTION |
---|
156 | , TCoeff *pParentARLBuffer |
---|
157 | #endif |
---|
158 | ) |
---|
159 | { |
---|
160 | m_bDecSubCu = bDecSubCu; |
---|
161 | |
---|
162 | m_pcPic = NULL; |
---|
163 | m_pcSlice = NULL; |
---|
164 | m_uiNumPartition = uiNumPartition; |
---|
165 | m_unitSize = unitSize; |
---|
166 | |
---|
167 | if ( !bDecSubCu ) |
---|
168 | { |
---|
169 | m_phQP = (Char* )xMalloc(Char, uiNumPartition); |
---|
170 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
171 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
172 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
173 | |
---|
174 | m_ChromaQpAdj = new UChar[ uiNumPartition ]; |
---|
175 | m_skipFlag = new Bool[ uiNumPartition ]; |
---|
176 | #if H_3D |
---|
177 | m_bDISFlag = new Bool[ uiNumPartition ]; |
---|
178 | m_uiDISType = (UInt*)xMalloc(UInt, uiNumPartition); |
---|
179 | #endif |
---|
180 | m_pePartSize = new Char[ uiNumPartition ]; |
---|
181 | memset( m_pePartSize, NUMBER_OF_PART_SIZES,uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
182 | m_pePredMode = new Char[ uiNumPartition ]; |
---|
183 | m_CUTransquantBypass = new Bool[ uiNumPartition ]; |
---|
184 | |
---|
185 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
186 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
187 | #if H_3D_VSP |
---|
188 | m_piVSPFlag = (Char* )xMalloc(Char, uiNumPartition); |
---|
189 | #endif |
---|
190 | #if H_3D_SPIVMP |
---|
191 | m_pbSPIVMPFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
192 | #endif |
---|
193 | |
---|
194 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
195 | { |
---|
196 | m_puhIntraDir[ch] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
197 | } |
---|
198 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
199 | |
---|
200 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
201 | |
---|
202 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
203 | { |
---|
204 | const RefPicList rpl=RefPicList(i); |
---|
205 | m_apiMVPIdx[rpl] = new Char[ uiNumPartition ]; |
---|
206 | m_apiMVPNum[rpl] = new Char[ uiNumPartition ]; |
---|
207 | memset( m_apiMVPIdx[rpl], -1,uiNumPartition * sizeof( Char ) ); |
---|
208 | } |
---|
209 | |
---|
210 | #if H_3D_NBDV |
---|
211 | m_pDvInfo = (DisInfo* )xMalloc(DisInfo, uiNumPartition); |
---|
212 | #endif |
---|
213 | |
---|
214 | |
---|
215 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
216 | { |
---|
217 | const ComponentID compID = ComponentID(comp); |
---|
218 | const UInt chromaShift = getComponentScaleX(compID, chromaFormatIDC) + getComponentScaleY(compID, chromaFormatIDC); |
---|
219 | const UInt totalSize = (uiWidth * uiHeight) >> chromaShift; |
---|
220 | |
---|
221 | m_crossComponentPredictionAlpha[compID] = (Char* )xMalloc(Char, uiNumPartition); |
---|
222 | m_puhTransformSkip[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
223 | m_explicitRdpcmMode[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
224 | m_puhCbf[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
225 | m_pcTrCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); |
---|
226 | memset( m_pcTrCoeff[compID], 0, (totalSize * sizeof( TCoeff )) ); |
---|
227 | |
---|
228 | #if ADAPTIVE_QP_SELECTION |
---|
229 | if( pParentARLBuffer != 0 ) |
---|
230 | { |
---|
231 | m_pcArlCoeff[compID] = pParentARLBuffer; |
---|
232 | m_ArlCoeffIsAliasedAllocation = true; |
---|
233 | pParentARLBuffer += totalSize; |
---|
234 | } |
---|
235 | else |
---|
236 | { |
---|
237 | m_pcArlCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); |
---|
238 | m_ArlCoeffIsAliasedAllocation = false; |
---|
239 | } |
---|
240 | #endif |
---|
241 | m_pcIPCMSample[compID] = (Pel* )xMalloc(Pel , totalSize); |
---|
242 | } |
---|
243 | |
---|
244 | m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
245 | |
---|
246 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
247 | { |
---|
248 | m_acCUMvField[i].create( uiNumPartition ); |
---|
249 | } |
---|
250 | |
---|
251 | #if H_3D_ARP |
---|
252 | m_puhARPW = new UChar[ uiNumPartition]; |
---|
253 | #endif |
---|
254 | #if NH_3D_IC |
---|
255 | m_pbICFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
256 | #endif |
---|
257 | #if H_3D_DIM |
---|
258 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
259 | { |
---|
260 | m_dimDeltaDC[i][0] = (Pel* )xMalloc(Pel, uiNumPartition); |
---|
261 | m_dimDeltaDC[i][1] = (Pel* )xMalloc(Pel, uiNumPartition); |
---|
262 | } |
---|
263 | #if H_3D_DIM_DMM |
---|
264 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
265 | { |
---|
266 | m_dmmWedgeTabIdx[i] = (UInt*)xMalloc(UInt, uiNumPartition); |
---|
267 | } |
---|
268 | #endif |
---|
269 | #if H_3D_DIM_SDC |
---|
270 | m_pbSDCFlag = (Bool*)xMalloc(Bool, uiNumPartition); |
---|
271 | m_apSegmentDCOffset[0] = (Pel*)xMalloc(Pel, uiNumPartition); |
---|
272 | m_apSegmentDCOffset[1] = (Pel*)xMalloc(Pel, uiNumPartition); |
---|
273 | #endif |
---|
274 | #endif |
---|
275 | #if H_3D_DBBP |
---|
276 | m_pbDBBPFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
277 | #endif |
---|
278 | |
---|
279 | } |
---|
280 | else |
---|
281 | { |
---|
282 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
283 | { |
---|
284 | m_acCUMvField[i].setNumPartition(uiNumPartition ); |
---|
285 | } |
---|
286 | } |
---|
287 | |
---|
288 | // create motion vector fields |
---|
289 | |
---|
290 | m_pCtuAboveLeft = NULL; |
---|
291 | m_pCtuAboveRight = NULL; |
---|
292 | m_pCtuAbove = NULL; |
---|
293 | m_pCtuLeft = NULL; |
---|
294 | |
---|
295 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
296 | { |
---|
297 | m_apcCUColocated[i] = NULL; |
---|
298 | } |
---|
299 | } |
---|
300 | |
---|
301 | Void TComDataCU::destroy() |
---|
302 | { |
---|
303 | // encoder-side buffer free |
---|
304 | if ( !m_bDecSubCu ) |
---|
305 | { |
---|
306 | if ( m_phQP ) |
---|
307 | { |
---|
308 | xFree(m_phQP); |
---|
309 | m_phQP = NULL; |
---|
310 | } |
---|
311 | if ( m_puhDepth ) |
---|
312 | { |
---|
313 | xFree(m_puhDepth); |
---|
314 | m_puhDepth = NULL; |
---|
315 | } |
---|
316 | if ( m_puhWidth ) |
---|
317 | { |
---|
318 | xFree(m_puhWidth); |
---|
319 | m_puhWidth = NULL; |
---|
320 | } |
---|
321 | if ( m_puhHeight ) |
---|
322 | { |
---|
323 | xFree(m_puhHeight); |
---|
324 | m_puhHeight = NULL; |
---|
325 | } |
---|
326 | |
---|
327 | if ( m_skipFlag ) |
---|
328 | { |
---|
329 | delete[] m_skipFlag; |
---|
330 | m_skipFlag = NULL; |
---|
331 | } |
---|
332 | |
---|
333 | #if H_3D |
---|
334 | if ( m_bDISFlag ) { delete[] m_bDISFlag; m_bDISFlag = NULL; } |
---|
335 | if ( m_uiDISType ) { xFree(m_uiDISType); m_uiDISType = NULL; } |
---|
336 | #endif |
---|
337 | |
---|
338 | if ( m_pePartSize ) |
---|
339 | { |
---|
340 | delete[] m_pePartSize; |
---|
341 | m_pePartSize = NULL; |
---|
342 | } |
---|
343 | if ( m_pePredMode ) |
---|
344 | { |
---|
345 | delete[] m_pePredMode; |
---|
346 | m_pePredMode = NULL; |
---|
347 | } |
---|
348 | if ( m_ChromaQpAdj ) |
---|
349 | { |
---|
350 | delete[] m_ChromaQpAdj; |
---|
351 | m_ChromaQpAdj = NULL; |
---|
352 | } |
---|
353 | if ( m_CUTransquantBypass ) |
---|
354 | { |
---|
355 | delete[] m_CUTransquantBypass; |
---|
356 | m_CUTransquantBypass = NULL; |
---|
357 | } |
---|
358 | if ( m_puhInterDir ) |
---|
359 | { |
---|
360 | xFree(m_puhInterDir); |
---|
361 | m_puhInterDir = NULL; |
---|
362 | } |
---|
363 | if ( m_pbMergeFlag ) |
---|
364 | { |
---|
365 | xFree(m_pbMergeFlag); |
---|
366 | m_pbMergeFlag = NULL; |
---|
367 | } |
---|
368 | if ( m_puhMergeIndex ) |
---|
369 | { |
---|
370 | xFree(m_puhMergeIndex); |
---|
371 | m_puhMergeIndex = NULL; |
---|
372 | } |
---|
373 | |
---|
374 | #if H_3D_VSP |
---|
375 | if ( m_piVSPFlag ) { xFree(m_piVSPFlag); m_piVSPFlag = NULL; } |
---|
376 | #endif |
---|
377 | #if H_3D_SPIVMP |
---|
378 | if ( m_pbSPIVMPFlag ) { xFree(m_pbSPIVMPFlag); m_pbSPIVMPFlag = NULL; } |
---|
379 | #endif |
---|
380 | |
---|
381 | |
---|
382 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
383 | { |
---|
384 | xFree(m_puhIntraDir[ch]); |
---|
385 | m_puhIntraDir[ch] = NULL; |
---|
386 | } |
---|
387 | |
---|
388 | if ( m_puhTrIdx ) |
---|
389 | { |
---|
390 | xFree(m_puhTrIdx); |
---|
391 | m_puhTrIdx = NULL; |
---|
392 | } |
---|
393 | |
---|
394 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
395 | { |
---|
396 | if ( m_crossComponentPredictionAlpha[comp] ) |
---|
397 | { |
---|
398 | xFree(m_crossComponentPredictionAlpha[comp]); |
---|
399 | m_crossComponentPredictionAlpha[comp] = NULL; |
---|
400 | } |
---|
401 | if ( m_puhTransformSkip[comp] ) |
---|
402 | { |
---|
403 | xFree(m_puhTransformSkip[comp]); |
---|
404 | m_puhTransformSkip[comp] = NULL; |
---|
405 | } |
---|
406 | if ( m_puhCbf[comp] ) |
---|
407 | { |
---|
408 | xFree(m_puhCbf[comp]); |
---|
409 | m_puhCbf[comp] = NULL; |
---|
410 | } |
---|
411 | if ( m_pcTrCoeff[comp] ) |
---|
412 | { |
---|
413 | xFree(m_pcTrCoeff[comp]); |
---|
414 | m_pcTrCoeff[comp] = NULL; |
---|
415 | } |
---|
416 | if ( m_explicitRdpcmMode[comp] ) |
---|
417 | { |
---|
418 | xFree(m_explicitRdpcmMode[comp]); |
---|
419 | m_explicitRdpcmMode[comp] = NULL; |
---|
420 | } |
---|
421 | |
---|
422 | #if ADAPTIVE_QP_SELECTION |
---|
423 | if (!m_ArlCoeffIsAliasedAllocation) |
---|
424 | { |
---|
425 | if ( m_pcArlCoeff[comp] ) |
---|
426 | { |
---|
427 | xFree(m_pcArlCoeff[comp]); |
---|
428 | m_pcArlCoeff[comp] = NULL; |
---|
429 | } |
---|
430 | } |
---|
431 | #endif |
---|
432 | |
---|
433 | if ( m_pcIPCMSample[comp] ) |
---|
434 | { |
---|
435 | xFree(m_pcIPCMSample[comp]); |
---|
436 | m_pcIPCMSample[comp] = NULL; |
---|
437 | } |
---|
438 | } |
---|
439 | if ( m_pbIPCMFlag ) |
---|
440 | { |
---|
441 | xFree(m_pbIPCMFlag ); |
---|
442 | m_pbIPCMFlag = NULL; |
---|
443 | } |
---|
444 | |
---|
445 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
446 | { |
---|
447 | const RefPicList rpl=RefPicList(i); |
---|
448 | if ( m_apiMVPIdx[rpl] ) |
---|
449 | { |
---|
450 | delete[] m_apiMVPIdx[rpl]; |
---|
451 | m_apiMVPIdx[rpl] = NULL; |
---|
452 | } |
---|
453 | if ( m_apiMVPNum[rpl] ) |
---|
454 | { |
---|
455 | delete[] m_apiMVPNum[rpl]; |
---|
456 | m_apiMVPNum[rpl] = NULL; |
---|
457 | } |
---|
458 | } |
---|
459 | |
---|
460 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
461 | { |
---|
462 | const RefPicList rpl=RefPicList(i); |
---|
463 | m_acCUMvField[rpl].destroy(); |
---|
464 | } |
---|
465 | #if H_3D_NBDV |
---|
466 | if ( m_pDvInfo ) { xFree(m_pDvInfo); m_pDvInfo = NULL; } |
---|
467 | #endif |
---|
468 | |
---|
469 | |
---|
470 | #if H_3D_ARP |
---|
471 | if ( m_puhARPW ) { delete[] m_puhARPW; m_puhARPW = NULL; } |
---|
472 | #endif |
---|
473 | #if NH_3D_IC |
---|
474 | if ( m_pbICFlag ) { xFree(m_pbICFlag); m_pbICFlag = NULL; } |
---|
475 | #endif |
---|
476 | |
---|
477 | #if H_3D_DIM |
---|
478 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
479 | { |
---|
480 | if ( m_dimDeltaDC[i][0] ) { xFree( m_dimDeltaDC[i][0] ); m_dimDeltaDC[i][0] = NULL; } |
---|
481 | if ( m_dimDeltaDC[i][1] ) { xFree( m_dimDeltaDC[i][1] ); m_dimDeltaDC[i][1] = NULL; } |
---|
482 | } |
---|
483 | #if H_3D_DIM_DMM |
---|
484 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
485 | { |
---|
486 | if ( m_dmmWedgeTabIdx[i] ) { xFree( m_dmmWedgeTabIdx[i] ); m_dmmWedgeTabIdx[i] = NULL; } |
---|
487 | } |
---|
488 | #endif |
---|
489 | #if H_3D_DIM_SDC |
---|
490 | if ( m_pbSDCFlag ) { xFree(m_pbSDCFlag); m_pbSDCFlag = NULL; } |
---|
491 | if ( m_apSegmentDCOffset[0] ) { xFree(m_apSegmentDCOffset[0]); m_apSegmentDCOffset[0] = NULL; } |
---|
492 | if ( m_apSegmentDCOffset[1] ) { xFree(m_apSegmentDCOffset[1]); m_apSegmentDCOffset[1] = NULL; } |
---|
493 | #endif |
---|
494 | #endif |
---|
495 | #if H_3D_DBBP |
---|
496 | if ( m_pbDBBPFlag ) { xFree(m_pbDBBPFlag); m_pbDBBPFlag = NULL; } |
---|
497 | #endif |
---|
498 | |
---|
499 | } |
---|
500 | |
---|
501 | m_pcPic = NULL; |
---|
502 | m_pcSlice = NULL; |
---|
503 | |
---|
504 | m_pCtuAboveLeft = NULL; |
---|
505 | m_pCtuAboveRight = NULL; |
---|
506 | m_pCtuAbove = NULL; |
---|
507 | m_pCtuLeft = NULL; |
---|
508 | |
---|
509 | |
---|
510 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
511 | { |
---|
512 | m_apcCUColocated[i] = NULL; |
---|
513 | } |
---|
514 | |
---|
515 | } |
---|
516 | |
---|
517 | Bool TComDataCU::CUIsFromSameTile ( const TComDataCU *pCU /* Can be NULL */) const |
---|
518 | { |
---|
519 | return pCU!=NULL && |
---|
520 | pCU->getSlice() != NULL && |
---|
521 | m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()); |
---|
522 | } |
---|
523 | |
---|
524 | Bool TComDataCU::CUIsFromSameSliceAndTile ( const TComDataCU *pCU /* Can be NULL */) const |
---|
525 | { |
---|
526 | return pCU!=NULL && |
---|
527 | pCU->getSlice() != NULL && |
---|
528 | pCU->getSlice()->getSliceCurStartCtuTsAddr() == getSlice()->getSliceCurStartCtuTsAddr() && |
---|
529 | m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()) |
---|
530 | ; |
---|
531 | } |
---|
532 | |
---|
533 | Bool TComDataCU::CUIsFromSameSliceTileAndWavefrontRow( const TComDataCU *pCU /* Can be NULL */) const |
---|
534 | { |
---|
535 | return CUIsFromSameSliceAndTile(pCU) |
---|
536 | && (!getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() || getPic()->getCtu(getCtuRsAddr())->getCUPelY() == getPic()->getCtu(pCU->getCtuRsAddr())->getCUPelY()); |
---|
537 | } |
---|
538 | |
---|
539 | Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx) |
---|
540 | { |
---|
541 | const TComSPS &sps=*(getSlice()->getSPS()); |
---|
542 | |
---|
543 | const UInt picWidth = sps.getPicWidthInLumaSamples(); |
---|
544 | const UInt picHeight = sps.getPicHeightInLumaSamples(); |
---|
545 | const UInt granularityWidth = sps.getMaxCUWidth(); |
---|
546 | |
---|
547 | const UInt cuPosX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[absPartIdx] ]; |
---|
548 | const UInt cuPosY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[absPartIdx] ]; |
---|
549 | |
---|
550 | return (((cuPosX+getWidth( absPartIdx))%granularityWidth==0||(cuPosX+getWidth( absPartIdx)==picWidth )) |
---|
551 | && ((cuPosY+getHeight(absPartIdx))%granularityWidth==0||(cuPosY+getHeight(absPartIdx)==picHeight))); |
---|
552 | } |
---|
553 | |
---|
554 | // ==================================================================================================================== |
---|
555 | // Public member functions |
---|
556 | // ==================================================================================================================== |
---|
557 | |
---|
558 | // -------------------------------------------------------------------------------------------------------------------- |
---|
559 | // Initialization |
---|
560 | // -------------------------------------------------------------------------------------------------------------------- |
---|
561 | |
---|
562 | /** |
---|
563 | Initialize top-level CU: create internal buffers and set initial values before encoding the CTU. |
---|
564 | |
---|
565 | \param pcPic picture (TComPic) class pointer |
---|
566 | \param ctuRsAddr CTU address in raster scan order |
---|
567 | */ |
---|
568 | Void TComDataCU::initCtu( TComPic* pcPic, UInt ctuRsAddr ) |
---|
569 | { |
---|
570 | |
---|
571 | const UInt maxCUWidth = pcPic->getPicSym()->getSPS().getMaxCUWidth(); |
---|
572 | const UInt maxCUHeight= pcPic->getPicSym()->getSPS().getMaxCUHeight(); |
---|
573 | m_pcPic = pcPic; |
---|
574 | m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
575 | m_ctuRsAddr = ctuRsAddr; |
---|
576 | m_uiCUPelX = ( ctuRsAddr % pcPic->getFrameWidthInCtus() ) * maxCUWidth; |
---|
577 | m_uiCUPelY = ( ctuRsAddr / pcPic->getFrameWidthInCtus() ) * maxCUHeight; |
---|
578 | m_absZIdxInCtu = 0; |
---|
579 | m_dTotalCost = MAX_DOUBLE; |
---|
580 | m_uiTotalDistortion = 0; |
---|
581 | m_uiTotalBits = 0; |
---|
582 | m_uiTotalBins = 0; |
---|
583 | m_uiNumPartition = pcPic->getNumPartitionsInCtu(); |
---|
584 | |
---|
585 | memset( m_skipFlag , false, m_uiNumPartition * sizeof( *m_skipFlag ) ); |
---|
586 | |
---|
587 | #if H_3D |
---|
588 | m_bDISFlag[ui] = pcFrom->getDISFlag(ui); |
---|
589 | m_uiDISType[ui] = pcFrom->getDISType(ui); |
---|
590 | #endif |
---|
591 | |
---|
592 | memset( m_pePartSize , NUMBER_OF_PART_SIZES, m_uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
593 | memset( m_pePredMode , NUMBER_OF_PREDICTION_MODES, m_uiNumPartition * sizeof( *m_pePredMode ) ); |
---|
594 | memset( m_CUTransquantBypass, false, m_uiNumPartition * sizeof( *m_CUTransquantBypass) ); |
---|
595 | memset( m_puhDepth , 0, m_uiNumPartition * sizeof( *m_puhDepth ) ); |
---|
596 | memset( m_puhTrIdx , 0, m_uiNumPartition * sizeof( *m_puhTrIdx ) ); |
---|
597 | memset( m_puhWidth , maxCUWidth, m_uiNumPartition * sizeof( *m_puhWidth ) ); |
---|
598 | memset( m_puhHeight , maxCUHeight, m_uiNumPartition * sizeof( *m_puhHeight ) ); |
---|
599 | |
---|
600 | #if H_3D_ARP |
---|
601 | m_puhARPW [ui] = pcFrom->getARPW( ui ); |
---|
602 | #endif |
---|
603 | #if NH_3D_IC |
---|
604 | memset( m_pbICFlag , false, m_uiNumPartition * sizeof( *m_pbICFlag ) ); |
---|
605 | #endif |
---|
606 | |
---|
607 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
608 | { |
---|
609 | const RefPicList rpl=RefPicList(i); |
---|
610 | memset( m_apiMVPIdx[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPIdx[rpl] ) ); |
---|
611 | memset( m_apiMVPNum[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPNum[rpl] ) ); |
---|
612 | } |
---|
613 | memset( m_phQP , getSlice()->getSliceQp(), m_uiNumPartition * sizeof( *m_phQP ) ); |
---|
614 | memset( m_ChromaQpAdj , 0, m_uiNumPartition * sizeof( *m_ChromaQpAdj ) ); |
---|
615 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
616 | { |
---|
617 | memset( m_crossComponentPredictionAlpha[comp] , 0, m_uiNumPartition * sizeof( *m_crossComponentPredictionAlpha[comp] ) ); |
---|
618 | memset( m_puhTransformSkip[comp] , 0, m_uiNumPartition * sizeof( *m_puhTransformSkip[comp]) ); |
---|
619 | memset( m_puhCbf[comp] , 0, m_uiNumPartition * sizeof( *m_puhCbf[comp] ) ); |
---|
620 | memset( m_explicitRdpcmMode[comp] , NUMBER_OF_RDPCM_MODES, m_uiNumPartition * sizeof( *m_explicitRdpcmMode[comp] ) ); |
---|
621 | } |
---|
622 | memset( m_pbMergeFlag , false, m_uiNumPartition * sizeof( *m_pbMergeFlag ) ); |
---|
623 | memset( m_puhMergeIndex , 0, m_uiNumPartition * sizeof( *m_puhMergeIndex ) ); |
---|
624 | |
---|
625 | #if H_3D_VSP |
---|
626 | m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui]; |
---|
627 | #endif |
---|
628 | #if H_3D_SPIVMP |
---|
629 | m_pbSPIVMPFlag[ui] = pcFrom->m_pbSPIVMPFlag[ui]; |
---|
630 | #endif |
---|
631 | #if H_3D_DIM_SDC |
---|
632 | m_pbSDCFlag[ui] = pcFrom->m_pbSDCFlag[ui]; |
---|
633 | #endif |
---|
634 | #if H_3D_DBBP |
---|
635 | m_pbDBBPFlag[ui] = pcFrom->m_pbDBBPFlag[ui]; |
---|
636 | #endif |
---|
637 | #if H_3D |
---|
638 | memset( m_bDISFlag + firstElement, false, numElements * sizeof( *m_bDISFlag ) ); |
---|
639 | memset( m_uiDISType + firstElement, 0, numElements * sizeof( *m_uiDISType) ); |
---|
640 | #endif |
---|
641 | #if H_3D_VSP |
---|
642 | memset( m_piVSPFlag + firstElement, 0, numElements * sizeof( *m_piVSPFlag ) ); |
---|
643 | #endif |
---|
644 | #if H_3D_SPIVMP |
---|
645 | memset( m_pbSPIVMPFlag + firstElement, 0, numElements * sizeof( *m_pbSPIVMPFlag ) ); |
---|
646 | #endif |
---|
647 | |
---|
648 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
649 | { |
---|
650 | memset( m_puhIntraDir[ch] , ((ch==0) ? DC_IDX : 0), m_uiNumPartition * sizeof( *(m_puhIntraDir[ch]) ) ); |
---|
651 | } |
---|
652 | |
---|
653 | #if H_3D_ARP |
---|
654 | memset( m_puhARPW + firstElement, 0, numElements * sizeof( UChar ) ); |
---|
655 | #endif |
---|
656 | |
---|
657 | #if H_3D_DIM |
---|
658 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
659 | { |
---|
660 | memset( m_dimDeltaDC[i][0] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][0] ) ); |
---|
661 | memset( m_dimDeltaDC[i][1] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][1] ) ); |
---|
662 | } |
---|
663 | #if H_3D_DIM_DMM |
---|
664 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
665 | { |
---|
666 | memset( m_dmmWedgeTabIdx[i] + firstElement, 0, numElements * sizeof( *m_dmmWedgeTabIdx[i] ) ); |
---|
667 | } |
---|
668 | #endif |
---|
669 | #if H_3D_DIM_SDC |
---|
670 | memset( m_pbSDCFlag + firstElement, 0, numElements * sizeof( *m_pbSDCFlag ) ); |
---|
671 | memset( m_apSegmentDCOffset[0] + firstElement, 0, numElements * sizeof( *m_apSegmentDCOffset[0] ) ); |
---|
672 | memset( m_apSegmentDCOffset[1] + firstElement, 0, numElements * sizeof( *m_apSegmentDCOffset[1] ) ); |
---|
673 | #endif |
---|
674 | m_apDmmPredictor[0] = 0; |
---|
675 | m_apDmmPredictor[1] = 0; |
---|
676 | #endif |
---|
677 | #if H_3D_DBBP |
---|
678 | memset( m_pbDBBPFlag + firstElement, false, numElements * sizeof( *m_pbDBBPFlag ) ); |
---|
679 | #endif |
---|
680 | |
---|
681 | memset( m_puhInterDir , 0, m_uiNumPartition * sizeof( *m_puhInterDir ) ); |
---|
682 | memset( m_pbIPCMFlag , false, m_uiNumPartition * sizeof( *m_pbIPCMFlag ) ); |
---|
683 | |
---|
684 | const UInt numCoeffY = maxCUWidth*maxCUHeight; |
---|
685 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
686 | { |
---|
687 | const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(comp)) + m_pcPic->getComponentScaleY(ComponentID(comp)); |
---|
688 | memset( m_pcTrCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); |
---|
689 | #if ADAPTIVE_QP_SELECTION |
---|
690 | memset( m_pcArlCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); |
---|
691 | #endif |
---|
692 | } |
---|
693 | |
---|
694 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
695 | { |
---|
696 | m_acCUMvField[i].clearMvField(); |
---|
697 | } |
---|
698 | |
---|
699 | // Setting neighbor CU |
---|
700 | m_pCtuLeft = NULL; |
---|
701 | m_pCtuAbove = NULL; |
---|
702 | m_pCtuAboveLeft = NULL; |
---|
703 | m_pCtuAboveRight = NULL; |
---|
704 | |
---|
705 | |
---|
706 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
707 | { |
---|
708 | m_apcCUColocated[i] = NULL; |
---|
709 | } |
---|
710 | |
---|
711 | UInt frameWidthInCtus = pcPic->getFrameWidthInCtus(); |
---|
712 | if ( m_ctuRsAddr % frameWidthInCtus ) |
---|
713 | { |
---|
714 | m_pCtuLeft = pcPic->getCtu( m_ctuRsAddr - 1 ); |
---|
715 | } |
---|
716 | |
---|
717 | if ( m_ctuRsAddr / frameWidthInCtus ) |
---|
718 | { |
---|
719 | m_pCtuAbove = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus ); |
---|
720 | } |
---|
721 | |
---|
722 | if ( m_pCtuLeft && m_pCtuAbove ) |
---|
723 | { |
---|
724 | m_pCtuAboveLeft = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus - 1 ); |
---|
725 | } |
---|
726 | |
---|
727 | if ( m_pCtuAbove && ( (m_ctuRsAddr%frameWidthInCtus) < (frameWidthInCtus-1) ) ) |
---|
728 | { |
---|
729 | m_pCtuAboveRight = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus + 1 ); |
---|
730 | } |
---|
731 | |
---|
732 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
733 | { |
---|
734 | const RefPicList rpl=RefPicList(i); |
---|
735 | if ( getSlice()->getNumRefIdx( rpl ) > 0 ) |
---|
736 | { |
---|
737 | m_apcCUColocated[rpl] = getSlice()->getRefPic( rpl, 0)->getCtu( m_ctuRsAddr ); |
---|
738 | } |
---|
739 | } |
---|
740 | } |
---|
741 | |
---|
742 | |
---|
743 | /** Initialize prediction data with enabling sub-CTU-level delta QP. |
---|
744 | * - set CU width and CU height according to depth |
---|
745 | * - set qp value according to input qp |
---|
746 | * - set last-coded qp value according to input last-coded qp |
---|
747 | * |
---|
748 | * \param uiDepth depth of the current CU |
---|
749 | * \param qp qp for the current CU |
---|
750 | * \param bTransquantBypass true for transquant bypass |
---|
751 | */ |
---|
752 | Void TComDataCU::initEstData( const UInt uiDepth, const Int qp, const Bool bTransquantBypass ) |
---|
753 | { |
---|
754 | m_dTotalCost = MAX_DOUBLE; |
---|
755 | m_uiTotalDistortion = 0; |
---|
756 | m_uiTotalBits = 0; |
---|
757 | m_uiTotalBins = 0; |
---|
758 | |
---|
759 | const UChar uhWidth = getSlice()->getSPS()->getMaxCUWidth() >> uiDepth; |
---|
760 | const UChar uhHeight = getSlice()->getSPS()->getMaxCUHeight() >> uiDepth; |
---|
761 | |
---|
762 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
763 | { |
---|
764 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
765 | { |
---|
766 | const RefPicList rpl=RefPicList(i); |
---|
767 | m_apiMVPIdx[rpl][ui] = -1; |
---|
768 | m_apiMVPNum[rpl][ui] = -1; |
---|
769 | } |
---|
770 | m_puhDepth [ui] = uiDepth; |
---|
771 | m_puhWidth [ui] = uhWidth; |
---|
772 | m_puhHeight [ui] = uhHeight; |
---|
773 | m_puhTrIdx [ui] = 0; |
---|
774 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
775 | { |
---|
776 | m_crossComponentPredictionAlpha[comp][ui] = 0; |
---|
777 | m_puhTransformSkip [comp][ui] = 0; |
---|
778 | m_explicitRdpcmMode [comp][ui] = NUMBER_OF_RDPCM_MODES; |
---|
779 | } |
---|
780 | m_skipFlag[ui] = false; |
---|
781 | #if H_3D |
---|
782 | m_bDISFlag[ui] = false; |
---|
783 | m_uiDISType[ui] = 0; |
---|
784 | #endif |
---|
785 | m_pePartSize[ui] = NUMBER_OF_PART_SIZES; |
---|
786 | m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; |
---|
787 | m_CUTransquantBypass[ui] = bTransquantBypass; |
---|
788 | m_pbIPCMFlag[ui] = 0; |
---|
789 | m_phQP[ui] = qp; |
---|
790 | m_ChromaQpAdj[ui] = 0; |
---|
791 | m_pbMergeFlag[ui] = 0; |
---|
792 | m_puhMergeIndex[ui] = 0; |
---|
793 | #if H_3D_VSP |
---|
794 | m_piVSPFlag[ui] = 0; |
---|
795 | #endif |
---|
796 | #if H_3D_SPIVMP |
---|
797 | m_pbSPIVMPFlag[ui] = 0; |
---|
798 | #endif |
---|
799 | |
---|
800 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
801 | { |
---|
802 | m_puhIntraDir[ch][ui] = ((ch==0) ? DC_IDX : 0); |
---|
803 | } |
---|
804 | |
---|
805 | m_puhInterDir[ui] = 0; |
---|
806 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
807 | { |
---|
808 | m_puhCbf[comp][ui] = 0; |
---|
809 | } |
---|
810 | #if H_3D_ARP |
---|
811 | m_puhARPW[ui] = 0; |
---|
812 | #endif |
---|
813 | #if NH_3D_IC |
---|
814 | m_pbICFlag[ui] = false; |
---|
815 | #endif |
---|
816 | |
---|
817 | |
---|
818 | #if H_3D_DIM |
---|
819 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
820 | { |
---|
821 | m_dimDeltaDC[i][0] [ui] = 0; |
---|
822 | m_dimDeltaDC[i][1] [ui] = 0; |
---|
823 | } |
---|
824 | #if H_3D_DIM_DMM |
---|
825 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
826 | { |
---|
827 | m_dmmWedgeTabIdx[i] [ui] = 0; |
---|
828 | } |
---|
829 | #endif |
---|
830 | #if H_3D_DIM_SDC |
---|
831 | m_pbSDCFlag [ui] = false; |
---|
832 | m_apSegmentDCOffset[0][ui] = 0; |
---|
833 | m_apSegmentDCOffset[1][ui] = 0; |
---|
834 | #endif |
---|
835 | m_apDmmPredictor[0] = 0; |
---|
836 | m_apDmmPredictor[1] = 0; |
---|
837 | #endif |
---|
838 | #if H_3D_DBBP |
---|
839 | m_pbDBBPFlag[ui] = false; |
---|
840 | #endif |
---|
841 | } |
---|
842 | |
---|
843 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
844 | { |
---|
845 | m_acCUMvField[i].clearMvField(); |
---|
846 | } |
---|
847 | |
---|
848 | const UInt numCoeffY = uhWidth*uhHeight; |
---|
849 | |
---|
850 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
851 | { |
---|
852 | const ComponentID component = ComponentID(comp); |
---|
853 | const UInt numCoeff = numCoeffY >> (getPic()->getComponentScaleX(component) + getPic()->getComponentScaleY(component)); |
---|
854 | memset( m_pcTrCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); |
---|
855 | #if ADAPTIVE_QP_SELECTION |
---|
856 | memset( m_pcArlCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); |
---|
857 | #endif |
---|
858 | memset( m_pcIPCMSample[comp], 0, numCoeff * sizeof( Pel) ); |
---|
859 | } |
---|
860 | } |
---|
861 | |
---|
862 | |
---|
863 | // initialize Sub partition |
---|
864 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ) |
---|
865 | { |
---|
866 | assert( uiPartUnitIdx<4 ); |
---|
867 | |
---|
868 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
---|
869 | |
---|
870 | m_pcPic = pcCU->getPic(); |
---|
871 | m_pcSlice = pcCU->getSlice(); |
---|
872 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
873 | m_absZIdxInCtu = pcCU->getZorderIdxInCtu() + uiPartOffset; |
---|
874 | |
---|
875 | const UChar uhWidth = getSlice()->getSPS()->getMaxCUWidth() >> uiDepth; |
---|
876 | const UChar uhHeight = getSlice()->getSPS()->getMaxCUHeight() >> uiDepth; |
---|
877 | |
---|
878 | m_uiCUPelX = pcCU->getCUPelX() + ( uhWidth )*( uiPartUnitIdx & 1 ); |
---|
879 | m_uiCUPelY = pcCU->getCUPelY() + ( uhHeight)*( uiPartUnitIdx >> 1 ); |
---|
880 | |
---|
881 | m_dTotalCost = MAX_DOUBLE; |
---|
882 | m_uiTotalDistortion = 0; |
---|
883 | m_uiTotalBits = 0; |
---|
884 | m_uiTotalBins = 0; |
---|
885 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
---|
886 | |
---|
887 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
888 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
889 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
890 | |
---|
891 | memset( m_phQP, qp, sizeInChar ); |
---|
892 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
893 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
894 | #if H_3D_VSP |
---|
895 | memset( m_piVSPFlag, 0, sizeof( Char ) * m_uiNumPartition ); |
---|
896 | #endif |
---|
897 | #if H_3D_SPIVMP |
---|
898 | memset( m_pbSPIVMPFlag, 0, sizeof( Bool ) * m_uiNumPartition ); |
---|
899 | #endif |
---|
900 | |
---|
901 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
902 | { |
---|
903 | memset( m_puhIntraDir[ch], ((ch==0) ? DC_IDX : 0), iSizeInUchar ); |
---|
904 | } |
---|
905 | |
---|
906 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
907 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
908 | |
---|
909 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
910 | { |
---|
911 | memset( m_crossComponentPredictionAlpha[comp], 0, iSizeInUchar ); |
---|
912 | memset( m_puhTransformSkip[comp], 0, iSizeInUchar ); |
---|
913 | memset( m_puhCbf[comp], 0, iSizeInUchar ); |
---|
914 | memset( m_explicitRdpcmMode[comp], NUMBER_OF_RDPCM_MODES, iSizeInUchar ); |
---|
915 | } |
---|
916 | #if H_3D_ARP |
---|
917 | memset( m_puhARPW, 0, iSizeInUchar ); |
---|
918 | #endif |
---|
919 | |
---|
920 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
---|
921 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
922 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
923 | memset( m_pbIPCMFlag, 0, iSizeInBool ); |
---|
924 | #if NH_3D_IC |
---|
925 | memset( m_pbICFlag, 0, iSizeInBool ); |
---|
926 | #endif |
---|
927 | #if H_3D_DIM |
---|
928 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
929 | { |
---|
930 | memset( m_dimDeltaDC[i][0], 0, sizeof(Pel ) * m_uiNumPartition ); |
---|
931 | memset( m_dimDeltaDC[i][1], 0, sizeof(Pel ) * m_uiNumPartition ); |
---|
932 | } |
---|
933 | #if H_3D_DIM_DMM |
---|
934 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
935 | { |
---|
936 | memset( m_dmmWedgeTabIdx[i], 0, sizeof(UInt) * m_uiNumPartition ); |
---|
937 | } |
---|
938 | #endif |
---|
939 | #if H_3D_DIM_SDC |
---|
940 | memset( m_pbSDCFlag, 0, sizeof(Bool) * m_uiNumPartition ); |
---|
941 | memset( m_apSegmentDCOffset[0], 0, sizeof(Pel) * m_uiNumPartition ); |
---|
942 | memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition ); |
---|
943 | #endif |
---|
944 | m_apDmmPredictor[0] = 0; |
---|
945 | m_apDmmPredictor[1] = 0; |
---|
946 | #endif |
---|
947 | #if H_3D_DBBP |
---|
948 | memset( m_pbDBBPFlag, 0, iSizeInBool ); |
---|
949 | #endif |
---|
950 | |
---|
951 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
952 | { |
---|
953 | m_skipFlag[ui] = false; |
---|
954 | #if H_3D |
---|
955 | m_bDISFlag[ui] = false; |
---|
956 | m_uiDISType[ui] = 0; |
---|
957 | #endif |
---|
958 | |
---|
959 | m_pePartSize[ui] = NUMBER_OF_PART_SIZES; |
---|
960 | m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; |
---|
961 | m_CUTransquantBypass[ui] = false; |
---|
962 | m_ChromaQpAdj[ui] = 0; |
---|
963 | |
---|
964 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
965 | { |
---|
966 | const RefPicList rpl=RefPicList(i); |
---|
967 | m_apiMVPIdx[rpl][ui] = -1; |
---|
968 | m_apiMVPNum[rpl][ui] = -1; |
---|
969 | } |
---|
970 | #if H_3D |
---|
971 | m_bDISFlag[ui] = pcCU->getDISFlag(uiPartOffset+ui); |
---|
972 | m_uiDISType[ui] = pcCU->getDISType(uiPartOffset+ui); |
---|
973 | #endif |
---|
974 | #if H_3D_VSP |
---|
975 | m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui]; |
---|
976 | m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui]; |
---|
977 | #endif |
---|
978 | #if H_3D_SPIVMP |
---|
979 | m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui]; |
---|
980 | #endif |
---|
981 | #if H_3D_ARP |
---|
982 | m_puhARPW [ui] = pcCU->getARPW( uiPartOffset+ui ); |
---|
983 | #endif |
---|
984 | #if NH_3D_IC |
---|
985 | m_pbICFlag [ui] = pcCU->m_pbICFlag[uiPartOffset+ui]; |
---|
986 | #endif |
---|
987 | #if H_3D_DIM |
---|
988 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
989 | { |
---|
990 | m_dimDeltaDC[i][0] [ui] = pcCU->m_dimDeltaDC[i][0] [uiPartOffset+ui]; |
---|
991 | m_dimDeltaDC[i][1] [ui] = pcCU->m_dimDeltaDC[i][1] [uiPartOffset+ui]; |
---|
992 | } |
---|
993 | #if H_3D_DIM_DMM |
---|
994 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
995 | { |
---|
996 | m_dmmWedgeTabIdx[i] [ui] = pcCU->m_dmmWedgeTabIdx[i] [uiPartOffset+ui]; |
---|
997 | } |
---|
998 | #endif |
---|
999 | #if H_3D_DIM_SDC |
---|
1000 | m_pbSDCFlag [ui] = pcCU->m_pbSDCFlag [ uiPartOffset + ui ]; |
---|
1001 | m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0] [ uiPartOffset + ui ]; |
---|
1002 | m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ]; |
---|
1003 | #endif |
---|
1004 | #endif |
---|
1005 | #if H_3D_DBBP |
---|
1006 | m_pbDBBPFlag[ui]=pcCU->m_pbDBBPFlag[uiPartOffset+ui]; |
---|
1007 | #endif |
---|
1008 | } |
---|
1009 | |
---|
1010 | const UInt numCoeffY = uhWidth*uhHeight; |
---|
1011 | for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
1012 | { |
---|
1013 | const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(ch)) + m_pcPic->getComponentScaleY(ComponentID(ch)); |
---|
1014 | memset( m_pcTrCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
1015 | #if ADAPTIVE_QP_SELECTION |
---|
1016 | memset( m_pcArlCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
1017 | #endif |
---|
1018 | memset( m_pcIPCMSample[ch], 0, sizeof(Pel)* (numCoeffY>>componentShift) ); |
---|
1019 | } |
---|
1020 | |
---|
1021 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1022 | { |
---|
1023 | m_acCUMvField[i].clearMvField(); |
---|
1024 | } |
---|
1025 | |
---|
1026 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
1027 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
1028 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
1029 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
1030 | |
---|
1031 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1032 | { |
---|
1033 | m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); |
---|
1034 | } |
---|
1035 | } |
---|
1036 | |
---|
1037 | Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1038 | { |
---|
1039 | const UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); |
---|
1040 | const UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
1041 | const TComSPS &sps = *(getSlice()->getSPS()); |
---|
1042 | const UChar uhWidth = sps.getMaxCUWidth() >> uiDepth; |
---|
1043 | const UChar uhHeight = sps.getMaxCUHeight() >> uiDepth; |
---|
1044 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); |
---|
1045 | memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); |
---|
1046 | memset( m_puhHeight + uiAbsPartIdx, uhHeight, uiSizeInUchar ); |
---|
1047 | } |
---|
1048 | |
---|
1049 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1050 | // Copy |
---|
1051 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1052 | |
---|
1053 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1054 | { |
---|
1055 | UInt uiPart = uiAbsPartIdx; |
---|
1056 | |
---|
1057 | m_pcPic = pcCU->getPic(); |
---|
1058 | m_pcSlice = pcCU->getSlice(); |
---|
1059 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
1060 | m_absZIdxInCtu = uiAbsPartIdx; |
---|
1061 | |
---|
1062 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1063 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1064 | |
---|
1065 | m_skipFlag=pcCU->getSkipFlag() + uiPart; |
---|
1066 | #if H_3D |
---|
1067 | m_bDISFlag = pcCU->getDISFlag() + uiPart; |
---|
1068 | m_uiDISType = pcCU->getDISType() + uiPart; |
---|
1069 | #endif |
---|
1070 | |
---|
1071 | m_phQP=pcCU->getQP() + uiPart; |
---|
1072 | m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiPart; |
---|
1073 | m_pePartSize = pcCU->getPartitionSize() + uiPart; |
---|
1074 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
---|
1075 | m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; |
---|
1076 | #if H_3D_NBDV |
---|
1077 | m_pDvInfo = pcCU->getDvInfo() + uiPart; |
---|
1078 | #endif |
---|
1079 | |
---|
1080 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
---|
1081 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
---|
1082 | #if H_3D_VSP |
---|
1083 | m_piVSPFlag = pcCU->getVSPFlag() + uiPart; |
---|
1084 | #endif |
---|
1085 | #if H_3D_SPIVMP |
---|
1086 | m_pbSPIVMPFlag = pcCU->getSPIVMPFlag() + uiPart; |
---|
1087 | #endif |
---|
1088 | #if H_3D_ARP |
---|
1089 | m_puhARPW = pcCU->getARPW() + uiPart; |
---|
1090 | #endif |
---|
1091 | #if NH_3D_IC |
---|
1092 | m_pbICFlag = pcCU->getICFlag() + uiPart; |
---|
1093 | #endif |
---|
1094 | |
---|
1095 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
1096 | { |
---|
1097 | m_puhIntraDir[ch] = pcCU->getIntraDir(ChannelType(ch)) + uiPart; |
---|
1098 | } |
---|
1099 | |
---|
1100 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
---|
1101 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
---|
1102 | |
---|
1103 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
1104 | { |
---|
1105 | m_crossComponentPredictionAlpha[comp] = pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)) + uiPart; |
---|
1106 | m_puhTransformSkip[comp] = pcCU->getTransformSkip(ComponentID(comp)) + uiPart; |
---|
1107 | m_puhCbf[comp] = pcCU->getCbf(ComponentID(comp)) + uiPart; |
---|
1108 | m_explicitRdpcmMode[comp] = pcCU->getExplicitRdpcmMode(ComponentID(comp)) + uiPart; |
---|
1109 | } |
---|
1110 | #if H_3D_DIM |
---|
1111 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
1112 | { |
---|
1113 | m_dimDeltaDC[i][0] = pcCU->getDimDeltaDC( i, 0 ) + uiPart; |
---|
1114 | m_dimDeltaDC[i][1] = pcCU->getDimDeltaDC( i, 1 ) + uiPart; |
---|
1115 | } |
---|
1116 | #if H_3D_DIM_DMM |
---|
1117 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1118 | { |
---|
1119 | m_dmmWedgeTabIdx[i] = pcCU->getDmmWedgeTabIdx( i ) + uiPart; |
---|
1120 | } |
---|
1121 | #endif |
---|
1122 | #if H_3D_DIM_SDC |
---|
1123 | m_pbSDCFlag = pcCU->getSDCFlag() + uiPart; |
---|
1124 | m_apSegmentDCOffset[0] = pcCU->getSDCSegmentDCOffset(0) + uiPart; |
---|
1125 | m_apSegmentDCOffset[1] = pcCU->getSDCSegmentDCOffset(1) + uiPart; |
---|
1126 | #endif |
---|
1127 | #endif |
---|
1128 | #if H_3D_DBBP |
---|
1129 | m_pbDBBPFlag = pcCU->getDBBPFlag() + uiPart; |
---|
1130 | #endif |
---|
1131 | |
---|
1132 | m_puhDepth=pcCU->getDepth() + uiPart; |
---|
1133 | m_puhWidth=pcCU->getWidth() + uiPart; |
---|
1134 | m_puhHeight=pcCU->getHeight() + uiPart; |
---|
1135 | |
---|
1136 | m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; |
---|
1137 | |
---|
1138 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
1139 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
1140 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
1141 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
1142 | |
---|
1143 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1144 | { |
---|
1145 | const RefPicList rpl=RefPicList(i); |
---|
1146 | m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); |
---|
1147 | m_apiMVPIdx[rpl]=pcCU->getMVPIdx(rpl) + uiPart; |
---|
1148 | m_apiMVPNum[rpl]=pcCU->getMVPNum(rpl) + uiPart; |
---|
1149 | } |
---|
1150 | |
---|
1151 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1152 | { |
---|
1153 | const RefPicList rpl=RefPicList(i); |
---|
1154 | m_acCUMvField[rpl].linkToWithOffset( pcCU->getCUMvField(rpl), uiPart ); |
---|
1155 | } |
---|
1156 | |
---|
1157 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1158 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1159 | |
---|
1160 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartitionsInCtu(); |
---|
1161 | |
---|
1162 | for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
1163 | { |
---|
1164 | const ComponentID component = ComponentID(ch); |
---|
1165 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
1166 | const UInt offset = uiCoffOffset >> componentShift; |
---|
1167 | m_pcTrCoeff[ch] = pcCU->getCoeff(component) + offset; |
---|
1168 | #if ADAPTIVE_QP_SELECTION |
---|
1169 | m_pcArlCoeff[ch] = pcCU->getArlCoeff(component) + offset; |
---|
1170 | #endif |
---|
1171 | m_pcIPCMSample[ch] = pcCU->getPCMSample(component) + offset; |
---|
1172 | } |
---|
1173 | } |
---|
1174 | |
---|
1175 | #if H_3D_NBDV |
---|
1176 | Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx) |
---|
1177 | { |
---|
1178 | m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; |
---|
1179 | } |
---|
1180 | #endif |
---|
1181 | |
---|
1182 | // Copy inter prediction info from the biggest CU |
---|
1183 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList |
---|
1184 | #if H_3D_NBDV |
---|
1185 | , Bool bNBDV |
---|
1186 | #endif |
---|
1187 | ) |
---|
1188 | { |
---|
1189 | m_pcPic = pcCU->getPic(); |
---|
1190 | m_pcSlice = pcCU->getSlice(); |
---|
1191 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
1192 | m_absZIdxInCtu = uiAbsPartIdx; |
---|
1193 | |
---|
1194 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
1195 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInCtuWidth() ); |
---|
1196 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInCtuWidth() ); |
---|
1197 | |
---|
1198 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
1199 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
1200 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
1201 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
1202 | |
---|
1203 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1204 | { |
---|
1205 | m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); |
---|
1206 | } |
---|
1207 | |
---|
1208 | m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; |
---|
1209 | #if H_3D |
---|
1210 | m_bDISFlag = pcCU->getDISFlag () + uiAbsPartIdx; |
---|
1211 | m_uiDISType = pcCU->getDISType() + uiAbsPartIdx; |
---|
1212 | #endif |
---|
1213 | |
---|
1214 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
---|
1215 | #if H_3D_NBDV |
---|
1216 | if(bNBDV == true) |
---|
1217 | { |
---|
1218 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
1219 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
1220 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
1221 | } |
---|
1222 | else |
---|
1223 | { |
---|
1224 | #endif |
---|
1225 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
---|
1226 | m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiAbsPartIdx; |
---|
1227 | m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; |
---|
1228 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
---|
1229 | |
---|
1230 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
1231 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
1232 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
1233 | |
---|
1234 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
1235 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
1236 | #if H_3D_VSP |
---|
1237 | m_piVSPFlag = pcCU->getVSPFlag() + uiAbsPartIdx; |
---|
1238 | m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; |
---|
1239 | #endif |
---|
1240 | #if H_3D_SPIVMP |
---|
1241 | m_pbSPIVMPFlag = pcCU->getSPIVMPFlag() + uiAbsPartIdx; |
---|
1242 | #endif |
---|
1243 | |
---|
1244 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
---|
1245 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
---|
1246 | #if H_3D_ARP |
---|
1247 | m_puhARPW = pcCU->getARPW() + uiAbsPartIdx; |
---|
1248 | #endif |
---|
1249 | #if H_3D_DBBP |
---|
1250 | m_pbDBBPFlag = pcCU->getDBBPFlag() + uiAbsPartIdx; |
---|
1251 | #endif |
---|
1252 | |
---|
1253 | m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); |
---|
1254 | #if H_3D_NBDV |
---|
1255 | } |
---|
1256 | #endif |
---|
1257 | #if NH_3D_IC |
---|
1258 | m_pbICFlag = pcCU->getICFlag() + uiAbsPartIdx; |
---|
1259 | #endif |
---|
1260 | |
---|
1261 | } |
---|
1262 | |
---|
1263 | // Copy small CU to bigger CU. |
---|
1264 | // One of quarter parts overwritten by predicted sub part. |
---|
1265 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
1266 | { |
---|
1267 | assert( uiPartUnitIdx<4 ); |
---|
1268 | |
---|
1269 | m_dTotalCost += pcCU->getTotalCost(); |
---|
1270 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
---|
1271 | m_uiTotalBits += pcCU->getTotalBits(); |
---|
1272 | |
---|
1273 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
---|
1274 | const UInt numValidComp=pcCU->getPic()->getNumberValidComponents(); |
---|
1275 | const UInt numValidChan=pcCU->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; |
---|
1276 | |
---|
1277 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
---|
1278 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
1279 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
1280 | |
---|
1281 | Int sizeInChar = sizeof( Char ) * uiNumPartition; |
---|
1282 | memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); |
---|
1283 | #if H_3D |
---|
1284 | memcpy( m_bDISFlag + uiOffset, pcCU->getDISFlag(), sizeof( *m_bDISFlag ) * uiNumPartition ); |
---|
1285 | memcpy( m_uiDISType + uiOffset, pcCU->getDISType(), sizeof( *m_uiDISType ) * uiNumPartition); |
---|
1286 | #endif |
---|
1287 | memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); |
---|
1288 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); |
---|
1289 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); |
---|
1290 | memcpy( m_ChromaQpAdj + uiOffset, pcCU->getChromaQpAdj(), sizeof( *m_ChromaQpAdj ) * uiNumPartition ); |
---|
1291 | memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); |
---|
1292 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
---|
1293 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
---|
1294 | #if H_3D_VSP |
---|
1295 | memcpy( m_piVSPFlag + uiOffset, pcCU->getVSPFlag(), sizeof( Char ) * uiNumPartition ); |
---|
1296 | memcpy( m_pDvInfo + uiOffset, pcCU->getDvInfo(), sizeof( *m_pDvInfo ) * uiNumPartition ); |
---|
1297 | #endif |
---|
1298 | #if H_3D_SPIVMP |
---|
1299 | memcpy( m_pbSPIVMPFlag + uiOffset, pcCU->getSPIVMPFlag(), sizeof( Bool ) * uiNumPartition ); |
---|
1300 | #endif |
---|
1301 | |
---|
1302 | for (UInt ch=0; ch<numValidChan; ch++) |
---|
1303 | { |
---|
1304 | memcpy( m_puhIntraDir[ch] + uiOffset, pcCU->getIntraDir(ChannelType(ch)), iSizeInUchar ); |
---|
1305 | } |
---|
1306 | |
---|
1307 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
---|
1308 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
---|
1309 | |
---|
1310 | for(UInt comp=0; comp<numValidComp; comp++) |
---|
1311 | { |
---|
1312 | memcpy( m_crossComponentPredictionAlpha[comp] + uiOffset, pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)), iSizeInUchar ); |
---|
1313 | memcpy( m_puhTransformSkip[comp] + uiOffset, pcCU->getTransformSkip(ComponentID(comp)) , iSizeInUchar ); |
---|
1314 | memcpy( m_puhCbf[comp] + uiOffset, pcCU->getCbf(ComponentID(comp)) , iSizeInUchar ); |
---|
1315 | memcpy( m_explicitRdpcmMode[comp] + uiOffset, pcCU->getExplicitRdpcmMode(ComponentID(comp)) , iSizeInUchar ); |
---|
1316 | } |
---|
1317 | #if H_3D_DIM |
---|
1318 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
1319 | { |
---|
1320 | memcpy( m_dimDeltaDC[i][0] + uiOffset, pcCU->getDimDeltaDC( i, 0 ), sizeof(Pel ) * uiNumPartition ); |
---|
1321 | memcpy( m_dimDeltaDC[i][1] + uiOffset, pcCU->getDimDeltaDC( i, 1 ), sizeof(Pel ) * uiNumPartition ); |
---|
1322 | } |
---|
1323 | #if H_3D_DIM_DMM |
---|
1324 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1325 | { |
---|
1326 | memcpy( m_dmmWedgeTabIdx[i] + uiOffset, pcCU->getDmmWedgeTabIdx( i ), sizeof(UInt) * uiNumPartition ); |
---|
1327 | } |
---|
1328 | #endif |
---|
1329 | #if H_3D_DIM_SDC |
---|
1330 | memcpy( m_pbSDCFlag + uiOffset, pcCU->getSDCFlag(), iSizeInBool ); |
---|
1331 | memcpy( m_apSegmentDCOffset[0] + uiOffset, pcCU->getSDCSegmentDCOffset(0), sizeof( Pel ) * uiNumPartition); |
---|
1332 | memcpy( m_apSegmentDCOffset[1] + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition); |
---|
1333 | #endif |
---|
1334 | #endif |
---|
1335 | #if H_3D_DBBP |
---|
1336 | memcpy( m_pbDBBPFlag + uiOffset, pcCU->getDBBPFlag(), iSizeInBool ); |
---|
1337 | #endif |
---|
1338 | |
---|
1339 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
---|
1340 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
---|
1341 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
---|
1342 | |
---|
1343 | memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); |
---|
1344 | |
---|
1345 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
1346 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
1347 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
1348 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
1349 | |
---|
1350 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1351 | { |
---|
1352 | const RefPicList rpl=RefPicList(i); |
---|
1353 | memcpy( m_apiMVPIdx[rpl] + uiOffset, pcCU->getMVPIdx(rpl), iSizeInUchar ); |
---|
1354 | memcpy( m_apiMVPNum[rpl] + uiOffset, pcCU->getMVPNum(rpl), iSizeInUchar ); |
---|
1355 | m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); |
---|
1356 | } |
---|
1357 | |
---|
1358 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1359 | { |
---|
1360 | const RefPicList rpl=RefPicList(i); |
---|
1361 | m_acCUMvField[rpl].copyFrom( pcCU->getCUMvField( rpl ), pcCU->getTotalNumPart(), uiOffset ); |
---|
1362 | } |
---|
1363 | |
---|
1364 | const UInt numCoeffY = (pcCU->getSlice()->getSPS()->getMaxCUWidth()*pcCU->getSlice()->getSPS()->getMaxCUHeight()) >> (uiDepth<<1); |
---|
1365 | const UInt offsetY = uiPartUnitIdx*numCoeffY; |
---|
1366 | for (UInt ch=0; ch<numValidComp; ch++) |
---|
1367 | { |
---|
1368 | const ComponentID component = ComponentID(ch); |
---|
1369 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
1370 | const UInt offset = offsetY>>componentShift; |
---|
1371 | memcpy( m_pcTrCoeff [ch] + offset, pcCU->getCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
1372 | #if ADAPTIVE_QP_SELECTION |
---|
1373 | memcpy( m_pcArlCoeff[ch] + offset, pcCU->getArlCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
1374 | #endif |
---|
1375 | memcpy( m_pcIPCMSample[ch] + offset, pcCU->getPCMSample(component), sizeof(Pel)*(numCoeffY>>componentShift) ); |
---|
1376 | } |
---|
1377 | |
---|
1378 | #if H_3D_ARP |
---|
1379 | memcpy( m_puhARPW + uiOffset, pcCU->getARPW(), iSizeInUchar ); |
---|
1380 | #endif |
---|
1381 | #if NH_3D_IC |
---|
1382 | memcpy( m_pbICFlag + uiOffset, pcCU->getICFlag(), iSizeInBool ); |
---|
1383 | #endif |
---|
1384 | |
---|
1385 | m_uiTotalBins += pcCU->getTotalBins(); |
---|
1386 | } |
---|
1387 | |
---|
1388 | // Copy current predicted part to a CU in picture. |
---|
1389 | // It is used to predict for next part |
---|
1390 | Void TComDataCU::copyToPic( UChar uhDepth ) |
---|
1391 | { |
---|
1392 | TComDataCU* pCtu = m_pcPic->getCtu( m_ctuRsAddr ); |
---|
1393 | const UInt numValidComp=pCtu->getPic()->getNumberValidComponents(); |
---|
1394 | const UInt numValidChan=pCtu->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; |
---|
1395 | |
---|
1396 | pCtu->getTotalCost() = m_dTotalCost; |
---|
1397 | pCtu->getTotalDistortion() = m_uiTotalDistortion; |
---|
1398 | pCtu->getTotalBits() = m_uiTotalBits; |
---|
1399 | |
---|
1400 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
1401 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
1402 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
1403 | |
---|
1404 | memcpy( pCtu->getSkipFlag() + m_absZIdxInCtu, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); |
---|
1405 | #if H_3D |
---|
1406 | memcpy( rpcCU->getDISFlag() + m_uiAbsIdxInLCU, m_bDISFlag, sizeof( *m_bDISFlag ) * m_uiNumPartition ); |
---|
1407 | memcpy( rpcCU->getDISType() + m_uiAbsIdxInLCU, m_uiDISType, sizeof( *m_uiDISType ) * m_uiNumPartition ); |
---|
1408 | #endif |
---|
1409 | |
---|
1410 | memcpy( pCtu->getQP() + m_absZIdxInCtu, m_phQP, sizeInChar ); |
---|
1411 | #if H_3D_NBDV |
---|
1412 | memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition ); |
---|
1413 | #endif |
---|
1414 | |
---|
1415 | memcpy( pCtu->getPartitionSize() + m_absZIdxInCtu, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); |
---|
1416 | memcpy( pCtu->getPredictionMode() + m_absZIdxInCtu, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); |
---|
1417 | memcpy( pCtu->getChromaQpAdj() + m_absZIdxInCtu, m_ChromaQpAdj, sizeof( *m_ChromaQpAdj ) * m_uiNumPartition ); |
---|
1418 | memcpy( pCtu->getCUTransquantBypass()+ m_absZIdxInCtu, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); |
---|
1419 | memcpy( pCtu->getMergeFlag() + m_absZIdxInCtu, m_pbMergeFlag, iSizeInBool ); |
---|
1420 | memcpy( pCtu->getMergeIndex() + m_absZIdxInCtu, m_puhMergeIndex, iSizeInUchar ); |
---|
1421 | #if H_3D_VSP |
---|
1422 | memcpy( rpcCU->getVSPFlag() + m_uiAbsIdxInLCU, m_piVSPFlag, sizeof( Char ) * m_uiNumPartition ); |
---|
1423 | memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof( *m_pDvInfo ) * m_uiNumPartition ); |
---|
1424 | #endif |
---|
1425 | #if H_3D_SPIVMP |
---|
1426 | memcpy( rpcCU->getSPIVMPFlag() + m_uiAbsIdxInLCU, m_pbSPIVMPFlag, sizeof( Bool ) * m_uiNumPartition ); |
---|
1427 | #endif |
---|
1428 | |
---|
1429 | for (UInt ch=0; ch<numValidChan; ch++) |
---|
1430 | { |
---|
1431 | memcpy( pCtu->getIntraDir(ChannelType(ch)) + m_absZIdxInCtu, m_puhIntraDir[ch], iSizeInUchar); |
---|
1432 | } |
---|
1433 | |
---|
1434 | memcpy( pCtu->getInterDir() + m_absZIdxInCtu, m_puhInterDir, iSizeInUchar ); |
---|
1435 | memcpy( pCtu->getTransformIdx() + m_absZIdxInCtu, m_puhTrIdx, iSizeInUchar ); |
---|
1436 | |
---|
1437 | for(UInt comp=0; comp<numValidComp; comp++) |
---|
1438 | { |
---|
1439 | memcpy( pCtu->getCrossComponentPredictionAlpha(ComponentID(comp)) + m_absZIdxInCtu, m_crossComponentPredictionAlpha[comp], iSizeInUchar ); |
---|
1440 | memcpy( pCtu->getTransformSkip(ComponentID(comp)) + m_absZIdxInCtu, m_puhTransformSkip[comp], iSizeInUchar ); |
---|
1441 | memcpy( pCtu->getCbf(ComponentID(comp)) + m_absZIdxInCtu, m_puhCbf[comp], iSizeInUchar ); |
---|
1442 | memcpy( pCtu->getExplicitRdpcmMode(ComponentID(comp)) + m_absZIdxInCtu, m_explicitRdpcmMode[comp], iSizeInUchar ); |
---|
1443 | } |
---|
1444 | |
---|
1445 | #if H_3D_DIM |
---|
1446 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
1447 | { |
---|
1448 | memcpy( rpcCU->getDimDeltaDC( i, 0 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][0], sizeof(Pel ) * m_uiNumPartition ); |
---|
1449 | memcpy( rpcCU->getDimDeltaDC( i, 1 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][1], sizeof(Pel ) * m_uiNumPartition ); |
---|
1450 | } |
---|
1451 | #if H_3D_DIM_DMM |
---|
1452 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1453 | { |
---|
1454 | memcpy( rpcCU->getDmmWedgeTabIdx( i ) + m_uiAbsIdxInLCU, m_dmmWedgeTabIdx[i], sizeof(UInt) * m_uiNumPartition ); |
---|
1455 | } |
---|
1456 | #endif |
---|
1457 | #if H_3D_DIM_SDC |
---|
1458 | memcpy( rpcCU->getSDCFlag() + m_uiAbsIdxInLCU, m_pbSDCFlag, iSizeInBool ); |
---|
1459 | memcpy( rpcCU->getSDCSegmentDCOffset(0) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[0], sizeof( Pel ) * m_uiNumPartition); |
---|
1460 | memcpy( rpcCU->getSDCSegmentDCOffset(1) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition); |
---|
1461 | #endif |
---|
1462 | #endif |
---|
1463 | #if H_3D_DBBP |
---|
1464 | memcpy( rpcCU->getDBBPFlag() + m_uiAbsIdxInLCU, m_pbDBBPFlag, iSizeInBool ); |
---|
1465 | #endif |
---|
1466 | |
---|
1467 | memcpy( pCtu->getDepth() + m_absZIdxInCtu, m_puhDepth, iSizeInUchar ); |
---|
1468 | memcpy( pCtu->getWidth() + m_absZIdxInCtu, m_puhWidth, iSizeInUchar ); |
---|
1469 | memcpy( pCtu->getHeight() + m_absZIdxInCtu, m_puhHeight, iSizeInUchar ); |
---|
1470 | |
---|
1471 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1472 | { |
---|
1473 | const RefPicList rpl=RefPicList(i); |
---|
1474 | memcpy( pCtu->getMVPIdx(rpl) + m_absZIdxInCtu, m_apiMVPIdx[rpl], iSizeInUchar ); |
---|
1475 | memcpy( pCtu->getMVPNum(rpl) + m_absZIdxInCtu, m_apiMVPNum[rpl], iSizeInUchar ); |
---|
1476 | } |
---|
1477 | |
---|
1478 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
1479 | { |
---|
1480 | const RefPicList rpl=RefPicList(i); |
---|
1481 | m_acCUMvField[rpl].copyTo( pCtu->getCUMvField( rpl ), m_absZIdxInCtu ); |
---|
1482 | } |
---|
1483 | |
---|
1484 | memcpy( pCtu->getIPCMFlag() + m_absZIdxInCtu, m_pbIPCMFlag, iSizeInBool ); |
---|
1485 | |
---|
1486 | const UInt numCoeffY = (pCtu->getSlice()->getSPS()->getMaxCUWidth()*pCtu->getSlice()->getSPS()->getMaxCUHeight())>>(uhDepth<<1); |
---|
1487 | const UInt offsetY = m_absZIdxInCtu*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
1488 | for (UInt comp=0; comp<numValidComp; comp++) |
---|
1489 | { |
---|
1490 | const ComponentID component = ComponentID(comp); |
---|
1491 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
1492 | memcpy( pCtu->getCoeff(component) + (offsetY>>componentShift), m_pcTrCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
1493 | #if ADAPTIVE_QP_SELECTION |
---|
1494 | memcpy( pCtu->getArlCoeff(component) + (offsetY>>componentShift), m_pcArlCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
1495 | #endif |
---|
1496 | memcpy( pCtu->getPCMSample(component) + (offsetY>>componentShift), m_pcIPCMSample[component], sizeof(Pel)*(numCoeffY>>componentShift) ); |
---|
1497 | } |
---|
1498 | |
---|
1499 | #if H_3D_ARP |
---|
1500 | memcpy( rpcCU->getARPW() + m_uiAbsIdxInLCU, m_puhARPW, iSizeInUchar ); |
---|
1501 | #endif |
---|
1502 | #if NH_3D_IC |
---|
1503 | memcpy( pCtu->getICFlag() + m_absZIdxInCtu, m_pbICFlag, sizeof( *m_pbICFlag ) * m_uiNumPartition ); |
---|
1504 | #endif |
---|
1505 | |
---|
1506 | pCtu->getTotalBins() = m_uiTotalBins; |
---|
1507 | } |
---|
1508 | |
---|
1509 | #if H_3D |
---|
1510 | memcpy( rpcCU->getDISFlag() + uiPartOffset, m_bDISFlag, sizeof( *m_bDISFlag ) * uiQNumPart ); |
---|
1511 | memcpy( rpcCU->getDISType() + uiPartOffset, m_uiDISType, sizeof( *m_uiDISType ) * uiQNumPart ); |
---|
1512 | #endif |
---|
1513 | |
---|
1514 | #if H_3D_VSP |
---|
1515 | memcpy( rpcCU->getVSPFlag() + uiPartOffset, m_piVSPFlag, sizeof(Char) * uiQNumPart ); |
---|
1516 | #endif |
---|
1517 | #if H_3D_SPIVMP |
---|
1518 | memcpy( rpcCU->getSPIVMPFlag() + uiPartOffset, m_pbSPIVMPFlag, sizeof(Bool) * uiQNumPart ); |
---|
1519 | #endif |
---|
1520 | #if H_3D_DIM |
---|
1521 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1522 | { |
---|
1523 | memcpy( rpcCU->getDimDeltaDC( i, 0 ) + uiPartOffset, m_dimDeltaDC[i][0], sizeof(Pel ) * uiQNumPart ); |
---|
1524 | memcpy( rpcCU->getDimDeltaDC( i, 1 ) + uiPartOffset, m_dimDeltaDC[i][1], sizeof(Pel ) * uiQNumPart ); |
---|
1525 | } |
---|
1526 | #if H_3D_DIM_DMM |
---|
1527 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1528 | { |
---|
1529 | memcpy( rpcCU->getDmmWedgeTabIdx( i ) + uiPartOffset, m_dmmWedgeTabIdx[i], sizeof(UInt) * uiQNumPart ); |
---|
1530 | } |
---|
1531 | #endif |
---|
1532 | #if H_3D_DIM_SDC |
---|
1533 | memcpy( rpcCU->getSDCFlag() + uiPartOffset, m_pbSDCFlag, iSizeInBool ); |
---|
1534 | memcpy( rpcCU->getSDCSegmentDCOffset(0) + uiPartOffset, m_apSegmentDCOffset[0], sizeof( Pel ) * uiQNumPart); |
---|
1535 | memcpy( rpcCU->getSDCSegmentDCOffset(1) + uiPartOffset, m_apSegmentDCOffset[1], sizeof( Pel ) * uiQNumPart); |
---|
1536 | #endif |
---|
1537 | #endif |
---|
1538 | #if H_3D_DBBP |
---|
1539 | memcpy( rpcCU->getDBBPFlag() + uiPartOffset, m_pbDBBPFlag, iSizeInBool ); |
---|
1540 | #endif |
---|
1541 | #if H_3D_ARP |
---|
1542 | memcpy( rpcCU->getARPW() + uiPartOffset, m_puhARPW, iSizeInUchar ); |
---|
1543 | #endif |
---|
1544 | |
---|
1545 | |
---|
1546 | |
---|
1547 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1548 | // Other public functions |
---|
1549 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1550 | |
---|
1551 | TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, |
---|
1552 | UInt uiCurrPartUnitIdx, |
---|
1553 | Bool bEnforceSliceRestriction, |
---|
1554 | Bool bEnforceTileRestriction ) |
---|
1555 | { |
---|
1556 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1557 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
1558 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1559 | |
---|
1560 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1561 | { |
---|
1562 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1563 | if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1564 | { |
---|
1565 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1566 | } |
---|
1567 | else |
---|
1568 | { |
---|
1569 | uiLPartUnitIdx -= m_absZIdxInCtu; |
---|
1570 | return this; |
---|
1571 | } |
---|
1572 | } |
---|
1573 | |
---|
1574 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth - 1 ]; |
---|
1575 | if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuLeft)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuLeft)) ) |
---|
1576 | { |
---|
1577 | return NULL; |
---|
1578 | } |
---|
1579 | return m_pCtuLeft; |
---|
1580 | } |
---|
1581 | |
---|
1582 | |
---|
1583 | TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, |
---|
1584 | UInt uiCurrPartUnitIdx, |
---|
1585 | Bool bEnforceSliceRestriction, |
---|
1586 | Bool planarAtCtuBoundary, |
---|
1587 | Bool bEnforceTileRestriction ) |
---|
1588 | { |
---|
1589 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1590 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
1591 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1592 | |
---|
1593 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1594 | { |
---|
1595 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth ]; |
---|
1596 | if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1597 | { |
---|
1598 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1599 | } |
---|
1600 | else |
---|
1601 | { |
---|
1602 | uiAPartUnitIdx -= m_absZIdxInCtu; |
---|
1603 | return this; |
---|
1604 | } |
---|
1605 | } |
---|
1606 | |
---|
1607 | if(planarAtCtuBoundary) |
---|
1608 | { |
---|
1609 | return NULL; |
---|
1610 | } |
---|
1611 | |
---|
1612 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth ]; |
---|
1613 | |
---|
1614 | if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuAbove)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuAbove)) ) |
---|
1615 | { |
---|
1616 | return NULL; |
---|
1617 | } |
---|
1618 | return m_pCtuAbove; |
---|
1619 | } |
---|
1620 | |
---|
1621 | TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
1622 | { |
---|
1623 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1624 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
1625 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1626 | |
---|
1627 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1628 | { |
---|
1629 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1630 | { |
---|
1631 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth - 1 ]; |
---|
1632 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1633 | { |
---|
1634 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1635 | } |
---|
1636 | else |
---|
1637 | { |
---|
1638 | uiALPartUnitIdx -= m_absZIdxInCtu; |
---|
1639 | return this; |
---|
1640 | } |
---|
1641 | } |
---|
1642 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartitionsInCtu() - numPartInCtuWidth - 1 ]; |
---|
1643 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) |
---|
1644 | { |
---|
1645 | return NULL; |
---|
1646 | } |
---|
1647 | return m_pCtuAbove; |
---|
1648 | } |
---|
1649 | |
---|
1650 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
1651 | { |
---|
1652 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1653 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) |
---|
1654 | { |
---|
1655 | return NULL; |
---|
1656 | } |
---|
1657 | return m_pCtuLeft; |
---|
1658 | } |
---|
1659 | |
---|
1660 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - 1 ]; |
---|
1661 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveLeft) ) |
---|
1662 | { |
---|
1663 | return NULL; |
---|
1664 | } |
---|
1665 | return m_pCtuAboveLeft; |
---|
1666 | } |
---|
1667 | |
---|
1668 | TComDataCU* TComDataCU::getPUBelowLeft(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) |
---|
1669 | { |
---|
1670 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1671 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1672 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_absZIdxInCtu ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*numPartInCtuWidth; |
---|
1673 | |
---|
1674 | if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) |
---|
1675 | { |
---|
1676 | uiBLPartUnitIdx = MAX_UINT; |
---|
1677 | return NULL; |
---|
1678 | } |
---|
1679 | |
---|
1680 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInCtuHeight() - uiPartUnitOffset, numPartInCtuWidth ) ) |
---|
1681 | { |
---|
1682 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, numPartInCtuWidth ) ) |
---|
1683 | { |
---|
1684 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ] ) |
---|
1685 | { |
---|
1686 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ]; |
---|
1687 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, numPartInCtuWidth ) ) |
---|
1688 | { |
---|
1689 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1690 | } |
---|
1691 | else |
---|
1692 | { |
---|
1693 | uiBLPartUnitIdx -= m_absZIdxInCtu; |
---|
1694 | return this; |
---|
1695 | } |
---|
1696 | } |
---|
1697 | uiBLPartUnitIdx = MAX_UINT; |
---|
1698 | return NULL; |
---|
1699 | } |
---|
1700 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * numPartInCtuWidth - 1 ]; |
---|
1701 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) |
---|
1702 | { |
---|
1703 | return NULL; |
---|
1704 | } |
---|
1705 | return m_pCtuLeft; |
---|
1706 | } |
---|
1707 | |
---|
1708 | uiBLPartUnitIdx = MAX_UINT; |
---|
1709 | return NULL; |
---|
1710 | } |
---|
1711 | |
---|
1712 | TComDataCU* TComDataCU::getPUAboveRight(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) |
---|
1713 | { |
---|
1714 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1715 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_absZIdxInCtu ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
---|
1716 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1717 | |
---|
1718 | if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
1719 | { |
---|
1720 | uiARPartUnitIdx = MAX_UINT; |
---|
1721 | return NULL; |
---|
1722 | } |
---|
1723 | |
---|
1724 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, numPartInCtuWidth - uiPartUnitOffset, numPartInCtuWidth ) ) |
---|
1725 | { |
---|
1726 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) |
---|
1727 | { |
---|
1728 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ] ) |
---|
1729 | { |
---|
1730 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ]; |
---|
1731 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
1732 | { |
---|
1733 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1734 | } |
---|
1735 | else |
---|
1736 | { |
---|
1737 | uiARPartUnitIdx -= m_absZIdxInCtu; |
---|
1738 | return this; |
---|
1739 | } |
---|
1740 | } |
---|
1741 | uiARPartUnitIdx = MAX_UINT; |
---|
1742 | return NULL; |
---|
1743 | } |
---|
1744 | |
---|
1745 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset ]; |
---|
1746 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) |
---|
1747 | { |
---|
1748 | return NULL; |
---|
1749 | } |
---|
1750 | return m_pCtuAbove; |
---|
1751 | } |
---|
1752 | |
---|
1753 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) |
---|
1754 | { |
---|
1755 | uiARPartUnitIdx = MAX_UINT; |
---|
1756 | return NULL; |
---|
1757 | } |
---|
1758 | |
---|
1759 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset-1 ]; |
---|
1760 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveRight) ) |
---|
1761 | { |
---|
1762 | return NULL; |
---|
1763 | } |
---|
1764 | return m_pCtuAboveRight; |
---|
1765 | } |
---|
1766 | |
---|
1767 | /** Get left QpMinCu |
---|
1768 | *\param uiLPartUnitIdx |
---|
1769 | *\param uiCurrAbsIdxInCtu |
---|
1770 | *\returns TComDataCU* point of TComDataCU of left QpMinCu |
---|
1771 | */ |
---|
1772 | TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu ) |
---|
1773 | { |
---|
1774 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1775 | const UInt maxCUDepth = getSlice()->getSPS()->getMaxTotalCUDepth(); |
---|
1776 | const UInt maxCuDQPDepth = getSlice()->getPPS()->getMaxCuDQPDepth(); |
---|
1777 | const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); |
---|
1778 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>doubleDepthDifference)<<doubleDepthDifference; |
---|
1779 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
1780 | |
---|
1781 | // check for left CTU boundary |
---|
1782 | if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCtuWidth) ) |
---|
1783 | { |
---|
1784 | return NULL; |
---|
1785 | } |
---|
1786 | |
---|
1787 | // get index of left-CU relative to top-left corner of current quantization group |
---|
1788 | uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; |
---|
1789 | |
---|
1790 | // return pointer to current CTU |
---|
1791 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1792 | } |
---|
1793 | |
---|
1794 | /** Get Above QpMinCu |
---|
1795 | *\param uiAPartUnitIdx |
---|
1796 | *\param uiCurrAbsIdxInCtu |
---|
1797 | *\returns TComDataCU* point of TComDataCU of above QpMinCu |
---|
1798 | */ |
---|
1799 | TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu ) |
---|
1800 | { |
---|
1801 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
1802 | const UInt maxCUDepth = getSlice()->getSPS()->getMaxTotalCUDepth(); |
---|
1803 | const UInt maxCuDQPDepth = getSlice()->getPPS()->getMaxCuDQPDepth(); |
---|
1804 | const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); |
---|
1805 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>doubleDepthDifference)<<doubleDepthDifference; |
---|
1806 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
1807 | |
---|
1808 | // check for top CTU boundary |
---|
1809 | if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCtuWidth) ) |
---|
1810 | { |
---|
1811 | return NULL; |
---|
1812 | } |
---|
1813 | |
---|
1814 | // get index of top-CU relative to top-left corner of current quantization group |
---|
1815 | uiAPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCtuWidth]; |
---|
1816 | |
---|
1817 | // return pointer to current CTU |
---|
1818 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
1819 | } |
---|
1820 | |
---|
1821 | |
---|
1822 | |
---|
1823 | /** Get reference QP from left QpMinCu or latest coded QP |
---|
1824 | *\param uiCurrAbsIdxInCtu |
---|
1825 | *\returns Char reference QP value |
---|
1826 | */ |
---|
1827 | Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu ) |
---|
1828 | { |
---|
1829 | UInt lPartIdx = MAX_UINT; |
---|
1830 | UInt aPartIdx = MAX_UINT; |
---|
1831 | TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); |
---|
1832 | TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); |
---|
1833 | return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + 1) >> 1); |
---|
1834 | } |
---|
1835 | |
---|
1836 | Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) |
---|
1837 | { |
---|
1838 | Int iLastValidPartIdx = iAbsPartIdx-1; |
---|
1839 | while ( iLastValidPartIdx >= 0 |
---|
1840 | && getPredictionMode( iLastValidPartIdx ) == NUMBER_OF_PREDICTION_MODES ) |
---|
1841 | { |
---|
1842 | UInt uiDepth = getDepth( iLastValidPartIdx ); |
---|
1843 | iLastValidPartIdx -= m_uiNumPartition>>(uiDepth<<1); |
---|
1844 | } |
---|
1845 | return iLastValidPartIdx; |
---|
1846 | } |
---|
1847 | |
---|
1848 | Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) |
---|
1849 | { |
---|
1850 | UInt uiQUPartIdxMask = ~((1<<((getSlice()->getSPS()->getMaxTotalCUDepth() - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); |
---|
1851 | Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); // A idx will be invalid if it is off the right or bottom edge of the picture. |
---|
1852 | // If this CU is in the first CTU of the slice and there is no valid part before this one, use slice QP |
---|
1853 | if ( getPic()->getPicSym()->getCtuTsToRsAddrMap(getSlice()->getSliceCurStartCtuTsAddr()) == getCtuRsAddr() && Int(getZorderIdxInCtu())+iLastValidPartIdx<0) |
---|
1854 | { |
---|
1855 | return getSlice()->getSliceQp(); |
---|
1856 | } |
---|
1857 | else if ( iLastValidPartIdx >= 0 ) |
---|
1858 | { |
---|
1859 | // If there is a valid part within the current Sub-CU, use it |
---|
1860 | return getQP( iLastValidPartIdx ); |
---|
1861 | } |
---|
1862 | else |
---|
1863 | { |
---|
1864 | if ( getZorderIdxInCtu() > 0 ) |
---|
1865 | { |
---|
1866 | // If this wasn't the first sub-cu within the Ctu, explore the CTU itself. |
---|
1867 | return getPic()->getCtu( getCtuRsAddr() )->getLastCodedQP( getZorderIdxInCtu() ); // TODO - remove this recursion |
---|
1868 | } |
---|
1869 | else if ( getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr()) > 0 |
---|
1870 | && CUIsFromSameSliceTileAndWavefrontRow(getPic()->getCtu(getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1))) ) |
---|
1871 | { |
---|
1872 | // 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. |
---|
1873 | return getPic()->getCtu( getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1) )->getLastCodedQP( getPic()->getNumPartitionsInCtu() ); // TODO - remove this recursion |
---|
1874 | } |
---|
1875 | else |
---|
1876 | { |
---|
1877 | // No other options available - use the slice-level QP. |
---|
1878 | return getSlice()->getSliceQp(); |
---|
1879 | } |
---|
1880 | } |
---|
1881 | } |
---|
1882 | |
---|
1883 | |
---|
1884 | /** Check whether the CU is coded in lossless coding mode. |
---|
1885 | * \param absPartIdx |
---|
1886 | * \returns true if the CU is coded in lossless coding mode; false if otherwise |
---|
1887 | */ |
---|
1888 | Bool TComDataCU::isLosslessCoded(UInt absPartIdx) |
---|
1889 | { |
---|
1890 | return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx)); |
---|
1891 | } |
---|
1892 | |
---|
1893 | |
---|
1894 | /** Get allowed chroma intra modes |
---|
1895 | * - fills uiModeList with chroma intra modes |
---|
1896 | * |
---|
1897 | *\param [in] uiAbsPartIdx |
---|
1898 | *\param [out] uiModeList pointer to chroma intra modes array |
---|
1899 | */ |
---|
1900 | Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] ) |
---|
1901 | { |
---|
1902 | uiModeList[0] = PLANAR_IDX; |
---|
1903 | uiModeList[1] = VER_IDX; |
---|
1904 | uiModeList[2] = HOR_IDX; |
---|
1905 | uiModeList[3] = DC_IDX; |
---|
1906 | uiModeList[4] = DM_CHROMA_IDX; |
---|
1907 | assert(4<NUM_CHROMA_MODE); |
---|
1908 | |
---|
1909 | UInt uiLumaMode = getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ); |
---|
1910 | |
---|
1911 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
---|
1912 | { |
---|
1913 | if( uiLumaMode == uiModeList[i] ) |
---|
1914 | { |
---|
1915 | uiModeList[i] = 34; // VER+8 mode |
---|
1916 | break; |
---|
1917 | } |
---|
1918 | } |
---|
1919 | } |
---|
1920 | |
---|
1921 | /** Get most probable intra modes |
---|
1922 | *\param uiAbsPartIdx partition index |
---|
1923 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
1924 | *\param compID colour component ID |
---|
1925 | *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. |
---|
1926 | *\returns Number of MPM |
---|
1927 | */ |
---|
1928 | Void TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode ) |
---|
1929 | { |
---|
1930 | TComDataCU* pcCULeft, *pcCUAbove; |
---|
1931 | UInt LeftPartIdx = MAX_UINT; |
---|
1932 | UInt AbovePartIdx = MAX_UINT; |
---|
1933 | Int iLeftIntraDir, iAboveIntraDir; |
---|
1934 | const TComSPS *sps=getSlice()->getSPS(); |
---|
1935 | const UInt partsPerMinCU = 1<<(2*(sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize())); |
---|
1936 | |
---|
1937 | const ChannelType chType = toChannelType(compID); |
---|
1938 | const ChromaFormat chForm = getPic()->getChromaFormat(); |
---|
1939 | // Get intra direction of left PU |
---|
1940 | pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
1941 | |
---|
1942 | if (isChroma(compID)) |
---|
1943 | { |
---|
1944 | LeftPartIdx = getChromasCorrespondingPULumaIdx(LeftPartIdx, chForm, partsPerMinCU); |
---|
1945 | } |
---|
1946 | iLeftIntraDir = pcCULeft ? ( pcCULeft->isIntra( LeftPartIdx ) ? pcCULeft->getIntraDir( chType, LeftPartIdx ) : DC_IDX ) : DC_IDX; |
---|
1947 | #if H_3D_DIM |
---|
1948 | mapDepthModeToIntraDir( iLeftIntraDir ); |
---|
1949 | #endif |
---|
1950 | |
---|
1951 | // Get intra direction of above PU |
---|
1952 | pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true ); |
---|
1953 | |
---|
1954 | if (isChroma(compID)) |
---|
1955 | { |
---|
1956 | AbovePartIdx = getChromasCorrespondingPULumaIdx(AbovePartIdx, chForm, partsPerMinCU); |
---|
1957 | } |
---|
1958 | iAboveIntraDir = pcCUAbove ? ( pcCUAbove->isIntra( AbovePartIdx ) ? pcCUAbove->getIntraDir( chType, AbovePartIdx ) : DC_IDX ) : DC_IDX; |
---|
1959 | #if H_3D_DIM |
---|
1960 | mapDepthModeToIntraDir( iAboveIntraDir ); |
---|
1961 | #endif |
---|
1962 | |
---|
1963 | |
---|
1964 | if (isChroma(chType)) |
---|
1965 | { |
---|
1966 | if (iLeftIntraDir == DM_CHROMA_IDX) |
---|
1967 | { |
---|
1968 | iLeftIntraDir = pcCULeft-> getIntraDir( CHANNEL_TYPE_LUMA, LeftPartIdx ); |
---|
1969 | } |
---|
1970 | if (iAboveIntraDir == DM_CHROMA_IDX) |
---|
1971 | { |
---|
1972 | iAboveIntraDir = pcCUAbove->getIntraDir( CHANNEL_TYPE_LUMA, AbovePartIdx ); |
---|
1973 | } |
---|
1974 | } |
---|
1975 | |
---|
1976 | assert (2<NUM_MOST_PROBABLE_MODES); |
---|
1977 | if(iLeftIntraDir == iAboveIntraDir) |
---|
1978 | { |
---|
1979 | if( piMode ) |
---|
1980 | { |
---|
1981 | *piMode = 1; |
---|
1982 | } |
---|
1983 | |
---|
1984 | if (iLeftIntraDir > 1) // angular modes |
---|
1985 | { |
---|
1986 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
1987 | uiIntraDirPred[1] = ((iLeftIntraDir + 29) % 32) + 2; |
---|
1988 | uiIntraDirPred[2] = ((iLeftIntraDir - 1 ) % 32) + 2; |
---|
1989 | } |
---|
1990 | else //non-angular |
---|
1991 | { |
---|
1992 | uiIntraDirPred[0] = PLANAR_IDX; |
---|
1993 | uiIntraDirPred[1] = DC_IDX; |
---|
1994 | uiIntraDirPred[2] = VER_IDX; |
---|
1995 | } |
---|
1996 | } |
---|
1997 | else |
---|
1998 | { |
---|
1999 | if( piMode ) |
---|
2000 | { |
---|
2001 | *piMode = 2; |
---|
2002 | } |
---|
2003 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
2004 | uiIntraDirPred[1] = iAboveIntraDir; |
---|
2005 | |
---|
2006 | if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar |
---|
2007 | { |
---|
2008 | uiIntraDirPred[2] = PLANAR_IDX; |
---|
2009 | } |
---|
2010 | else |
---|
2011 | { |
---|
2012 | uiIntraDirPred[2] = (iLeftIntraDir+iAboveIntraDir)<2? VER_IDX : DC_IDX; |
---|
2013 | } |
---|
2014 | } |
---|
2015 | for (UInt i=0; i<NUM_MOST_PROBABLE_MODES; i++) |
---|
2016 | { |
---|
2017 | assert(uiIntraDirPred[i] < 35); |
---|
2018 | } |
---|
2019 | } |
---|
2020 | |
---|
2021 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2022 | { |
---|
2023 | TComDataCU* pcTempCU; |
---|
2024 | UInt uiTempPartIdx; |
---|
2025 | UInt uiCtx; |
---|
2026 | // Get left split flag |
---|
2027 | pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
2028 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
2029 | |
---|
2030 | // Get above split flag |
---|
2031 | pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
2032 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
2033 | |
---|
2034 | return uiCtx; |
---|
2035 | } |
---|
2036 | |
---|
2037 | UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType ) |
---|
2038 | { |
---|
2039 | const UInt transformDepth = rTu.GetTransformDepthRel(); |
---|
2040 | |
---|
2041 | if (isChroma(chType)) |
---|
2042 | { |
---|
2043 | return transformDepth; |
---|
2044 | } |
---|
2045 | else |
---|
2046 | { |
---|
2047 | const UInt uiCtx = ( transformDepth == 0 ? 1 : 0 ); |
---|
2048 | return uiCtx; |
---|
2049 | } |
---|
2050 | } |
---|
2051 | |
---|
2052 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) |
---|
2053 | { |
---|
2054 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
---|
2055 | PartSize partSize = getPartitionSize( absPartIdx ); |
---|
2056 | UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
2057 | Int intraSplitFlag = ( isIntra( absPartIdx ) && partSize == SIZE_NxN ) ? 1 : 0; |
---|
2058 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && isInter( absPartIdx ) && (partSize != SIZE_2Nx2N) ); |
---|
2059 | |
---|
2060 | UInt log2MinTUSizeInCU = 0; |
---|
2061 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
---|
2062 | { |
---|
2063 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
---|
2064 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
2065 | } |
---|
2066 | else |
---|
2067 | { |
---|
2068 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
---|
2069 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
---|
2070 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
2071 | { |
---|
2072 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
---|
2073 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
2074 | } |
---|
2075 | } |
---|
2076 | return log2MinTUSizeInCU; |
---|
2077 | } |
---|
2078 | |
---|
2079 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
---|
2080 | { |
---|
2081 | TComDataCU* pcTempCU; |
---|
2082 | UInt uiTempPartIdx; |
---|
2083 | UInt uiCtx = 0; |
---|
2084 | |
---|
2085 | // Get BCBP of left PU |
---|
2086 | pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
2087 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2088 | |
---|
2089 | // Get BCBP of above PU |
---|
2090 | pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
2091 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2092 | |
---|
2093 | return uiCtx; |
---|
2094 | } |
---|
2095 | #if H_3D_ARP |
---|
2096 | UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx ) |
---|
2097 | { |
---|
2098 | TComDataCU* pcTempCU; |
---|
2099 | UInt uiTempPartIdx; |
---|
2100 | UInt uiCtx = 0; |
---|
2101 | |
---|
2102 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2103 | uiCtx = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0; |
---|
2104 | return uiCtx; |
---|
2105 | } |
---|
2106 | #endif |
---|
2107 | #if H_3D_DBBP |
---|
2108 | Pel* TComDataCU::getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride) |
---|
2109 | { |
---|
2110 | // get coded and reconstructed depth view |
---|
2111 | TComPicYuv* depthPicYuv = NULL; |
---|
2112 | Pel* pDepthPels = NULL; |
---|
2113 | |
---|
2114 | // DBBP is a texture coding tool |
---|
2115 | if( getSlice()->getIsDepth() ) |
---|
2116 | { |
---|
2117 | return NULL; |
---|
2118 | } |
---|
2119 | #if H_3D_FCO |
---|
2120 | TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); |
---|
2121 | |
---|
2122 | if( depthPic && depthPic->getPicYuvRec() != NULL && depthPic->getIsDepth() ) // depth first |
---|
2123 | { |
---|
2124 | depthPicYuv = depthPic->getPicYuvRec(); |
---|
2125 | depthPicYuv->extendPicBorder(); |
---|
2126 | |
---|
2127 | // get collocated depth block for current CU |
---|
2128 | uiDepthStride = depthPicYuv->getStride(); |
---|
2129 | pDepthPels = depthPicYuv->getLumaAddr( getAddr(), uiAbsPartIdx ); |
---|
2130 | } |
---|
2131 | else // texture first |
---|
2132 | #else |
---|
2133 | { |
---|
2134 | DisInfo DvInfo = getDvInfo(uiAbsPartIdx); |
---|
2135 | |
---|
2136 | TComPic* baseDepthPic = getSlice()->getIvPic (true, DvInfo.m_aVIdxCan); |
---|
2137 | |
---|
2138 | if( baseDepthPic == NULL || baseDepthPic->getPicYuvRec() == NULL ) |
---|
2139 | { |
---|
2140 | return NULL; |
---|
2141 | } |
---|
2142 | |
---|
2143 | depthPicYuv = baseDepthPic->getPicYuvRec(); |
---|
2144 | depthPicYuv->extendPicBorder(); |
---|
2145 | uiDepthStride = depthPicYuv->getStride(); |
---|
2146 | |
---|
2147 | Int iBlkX = ( getAddr() % baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ]; |
---|
2148 | Int iBlkY = ( getAddr() / baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ]; |
---|
2149 | |
---|
2150 | Int iPictureWidth = depthPicYuv->getWidth(); |
---|
2151 | Int iPictureHeight = depthPicYuv->getHeight(); |
---|
2152 | |
---|
2153 | |
---|
2154 | Bool depthRefineFlag = false; |
---|
2155 | #if H_3D_NBDV_REF |
---|
2156 | depthRefineFlag = m_pcSlice->getDepthRefinementFlag( ); |
---|
2157 | #endif // H_3D_NBDV_REF |
---|
2158 | |
---|
2159 | TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV; |
---|
2160 | if( depthRefineFlag ) |
---|
2161 | { |
---|
2162 | cDv.setVer(0); |
---|
2163 | } |
---|
2164 | |
---|
2165 | Int depthPosX = Clip3(0, iPictureWidth - 1, iBlkX + ((cDv.getHor()+2)>>2)); |
---|
2166 | Int depthPosY = Clip3(0, iPictureHeight - 1, iBlkY + ((cDv.getVer()+2)>>2)); |
---|
2167 | |
---|
2168 | pDepthPels = depthPicYuv->getLumaAddr() + depthPosX + depthPosY * uiDepthStride; |
---|
2169 | } |
---|
2170 | #endif |
---|
2171 | |
---|
2172 | AOF( depthPicYuv != NULL ); |
---|
2173 | AOF( pDepthPels != NULL ); |
---|
2174 | AOF( uiDepthStride != 0 ); |
---|
2175 | |
---|
2176 | return pDepthPels; |
---|
2177 | } |
---|
2178 | #endif |
---|
2179 | |
---|
2180 | #if H_3D_DBBP |
---|
2181 | Void TComDataCU::setDBBPFlagSubParts ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2182 | { |
---|
2183 | setSubPart( bDBBPFlag, m_pbDBBPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2184 | } |
---|
2185 | #endif |
---|
2186 | |
---|
2187 | #if H_3D_DIM_SDC |
---|
2188 | UInt TComDataCU::getCtxSDCFlag( UInt uiAbsPartIdx ) |
---|
2189 | { |
---|
2190 | return 0; |
---|
2191 | } |
---|
2192 | |
---|
2193 | #endif |
---|
2194 | |
---|
2195 | |
---|
2196 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
---|
2197 | { |
---|
2198 | return getDepth( uiAbsPartIdx ); |
---|
2199 | } |
---|
2200 | |
---|
2201 | |
---|
2202 | UChar TComDataCU::getQtRootCbf( UInt uiIdx ) |
---|
2203 | { |
---|
2204 | const UInt numberValidComponents = getPic()->getNumberValidComponents(); |
---|
2205 | return getCbf( uiIdx, COMPONENT_Y, 0 ) |
---|
2206 | || ((numberValidComponents > COMPONENT_Cb) && getCbf( uiIdx, COMPONENT_Cb, 0 )) |
---|
2207 | || ((numberValidComponents > COMPONENT_Cr) && getCbf( uiIdx, COMPONENT_Cr, 0 )); |
---|
2208 | } |
---|
2209 | |
---|
2210 | Void TComDataCU::setCbfSubParts( const UInt uiCbf[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2211 | { |
---|
2212 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2213 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
2214 | { |
---|
2215 | memset( m_puhCbf[comp] + uiAbsPartIdx, uiCbf[comp], sizeof( UChar ) * uiCurrPartNumb ); |
---|
2216 | } |
---|
2217 | } |
---|
2218 | |
---|
2219 | Void TComDataCU::setCbfSubParts( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2220 | { |
---|
2221 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2222 | memset( m_puhCbf[compID] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2223 | } |
---|
2224 | |
---|
2225 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
2226 | * \param uiCbf The value of the coded block flag to be set |
---|
2227 | * \param compID |
---|
2228 | * \param uiAbsPartIdx |
---|
2229 | * \param uiPartIdx |
---|
2230 | * \param uiDepth |
---|
2231 | */ |
---|
2232 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2233 | { |
---|
2234 | setSubPart<UChar>( uiCbf, m_puhCbf[compID], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2235 | } |
---|
2236 | |
---|
2237 | Void TComDataCU::setCbfPartRange ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
2238 | { |
---|
2239 | memset((m_puhCbf[compID] + uiAbsPartIdx), uiCbf, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
2240 | } |
---|
2241 | |
---|
2242 | Void TComDataCU::bitwiseOrCbfPartRange( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
2243 | { |
---|
2244 | const UInt stopAbsPartIdx = uiAbsPartIdx + uiCoveredPartIdxes; |
---|
2245 | |
---|
2246 | for (UInt subPartIdx = uiAbsPartIdx; subPartIdx < stopAbsPartIdx; subPartIdx++) |
---|
2247 | { |
---|
2248 | m_puhCbf[compID][subPartIdx] |= uiCbf; |
---|
2249 | } |
---|
2250 | } |
---|
2251 | |
---|
2252 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
2253 | { |
---|
2254 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2255 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2256 | } |
---|
2257 | |
---|
2258 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
---|
2259 | { |
---|
2260 | UInt uiPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2261 | return (((m_absZIdxInCtu + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
2262 | } |
---|
2263 | |
---|
2264 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2265 | { |
---|
2266 | assert( sizeof( *m_pePartSize) == 1 ); |
---|
2267 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
2268 | } |
---|
2269 | |
---|
2270 | Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2271 | { |
---|
2272 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
2273 | } |
---|
2274 | |
---|
2275 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
---|
2276 | { |
---|
2277 | assert( sizeof( *m_skipFlag) == 1 ); |
---|
2278 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); |
---|
2279 | } |
---|
2280 | |
---|
2281 | #if H_3D |
---|
2282 | Void TComDataCU::setDISFlagSubParts( Bool bDIS, UInt absPartIdx, UInt depth ) |
---|
2283 | { |
---|
2284 | assert( sizeof( *m_bDISFlag) == 1 ); |
---|
2285 | memset( m_bDISFlag + absPartIdx, bDIS, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); |
---|
2286 | } |
---|
2287 | |
---|
2288 | Void TComDataCU::setDISTypeSubParts(UInt uiDISType, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth ) |
---|
2289 | { |
---|
2290 | setSubPartT( uiDISType, m_uiDISType, uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
2291 | } |
---|
2292 | #endif |
---|
2293 | |
---|
2294 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2295 | { |
---|
2296 | assert( sizeof( *m_pePredMode) == 1 ); |
---|
2297 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
2298 | } |
---|
2299 | |
---|
2300 | Void TComDataCU::setChromaQpAdjSubParts( UChar val, Int absPartIdx, Int depth ) |
---|
2301 | { |
---|
2302 | assert( sizeof(*m_ChromaQpAdj) == 1 ); |
---|
2303 | memset( m_ChromaQpAdj + absPartIdx, val, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); |
---|
2304 | } |
---|
2305 | |
---|
2306 | Void TComDataCU::setQPSubCUs( Int qp, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
---|
2307 | { |
---|
2308 | UInt currPartNumb = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); |
---|
2309 | UInt currPartNumQ = currPartNumb >> 2; |
---|
2310 | const UInt numValidComp = m_pcPic->getNumberValidComponents(); |
---|
2311 | |
---|
2312 | if(!foundNonZeroCbf) |
---|
2313 | { |
---|
2314 | if(getDepth(absPartIdx) > depth) |
---|
2315 | { |
---|
2316 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
---|
2317 | { |
---|
2318 | setQPSubCUs( qp, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
---|
2319 | } |
---|
2320 | } |
---|
2321 | else |
---|
2322 | { |
---|
2323 | if(getCbf( absPartIdx, COMPONENT_Y ) || (numValidComp>COMPONENT_Cb && getCbf( absPartIdx, COMPONENT_Cb )) || (numValidComp>COMPONENT_Cr && getCbf( absPartIdx, COMPONENT_Cr) ) ) |
---|
2324 | { |
---|
2325 | foundNonZeroCbf = true; |
---|
2326 | } |
---|
2327 | else |
---|
2328 | { |
---|
2329 | setQPSubParts(qp, absPartIdx, depth); |
---|
2330 | } |
---|
2331 | } |
---|
2332 | } |
---|
2333 | } |
---|
2334 | |
---|
2335 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2336 | { |
---|
2337 | const UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2338 | memset(m_phQP+uiAbsPartIdx, qp, numPart); |
---|
2339 | } |
---|
2340 | |
---|
2341 | Void TComDataCU::setIntraDirSubParts( const ChannelType channelType, const UInt dir, const UInt absPartIdx, const UInt depth ) |
---|
2342 | { |
---|
2343 | UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); |
---|
2344 | memset( m_puhIntraDir[channelType] + absPartIdx, dir,sizeof(UChar)*numPart ); |
---|
2345 | } |
---|
2346 | |
---|
2347 | template<typename T> |
---|
2348 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2349 | { |
---|
2350 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
---|
2351 | |
---|
2352 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2; |
---|
2353 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2354 | { |
---|
2355 | case SIZE_2Nx2N: |
---|
2356 | memset( puhBaseCtu + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
---|
2357 | break; |
---|
2358 | case SIZE_2NxN: |
---|
2359 | memset( puhBaseCtu + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
---|
2360 | break; |
---|
2361 | case SIZE_Nx2N: |
---|
2362 | memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2363 | memset( puhBaseCtu + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
---|
2364 | break; |
---|
2365 | case SIZE_NxN: |
---|
2366 | memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2367 | break; |
---|
2368 | case SIZE_2NxnU: |
---|
2369 | if ( uiPUIdx == 0 ) |
---|
2370 | { |
---|
2371 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2372 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2373 | } |
---|
2374 | else if ( uiPUIdx == 1 ) |
---|
2375 | { |
---|
2376 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2377 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
---|
2378 | } |
---|
2379 | else |
---|
2380 | { |
---|
2381 | assert(0); |
---|
2382 | } |
---|
2383 | break; |
---|
2384 | case SIZE_2NxnD: |
---|
2385 | if ( uiPUIdx == 0 ) |
---|
2386 | { |
---|
2387 | memset( puhBaseCtu + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
---|
2388 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2389 | } |
---|
2390 | else if ( uiPUIdx == 1 ) |
---|
2391 | { |
---|
2392 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2393 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2394 | } |
---|
2395 | else |
---|
2396 | { |
---|
2397 | assert(0); |
---|
2398 | } |
---|
2399 | break; |
---|
2400 | case SIZE_nLx2N: |
---|
2401 | if ( uiPUIdx == 0 ) |
---|
2402 | { |
---|
2403 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2404 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2405 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2406 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2407 | } |
---|
2408 | else if ( uiPUIdx == 1 ) |
---|
2409 | { |
---|
2410 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2411 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2412 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2413 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2414 | } |
---|
2415 | else |
---|
2416 | { |
---|
2417 | assert(0); |
---|
2418 | } |
---|
2419 | break; |
---|
2420 | case SIZE_nRx2N: |
---|
2421 | if ( uiPUIdx == 0 ) |
---|
2422 | { |
---|
2423 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2424 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2425 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2426 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2427 | } |
---|
2428 | else if ( uiPUIdx == 1 ) |
---|
2429 | { |
---|
2430 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2431 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2432 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2433 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2434 | } |
---|
2435 | else |
---|
2436 | { |
---|
2437 | assert(0); |
---|
2438 | } |
---|
2439 | break; |
---|
2440 | default: |
---|
2441 | assert( 0 ); |
---|
2442 | break; |
---|
2443 | } |
---|
2444 | } |
---|
2445 | |
---|
2446 | #if H_3D_DIM_SDC |
---|
2447 | Void TComDataCU::setSDCFlagSubParts ( Bool bSDCFlag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2448 | { |
---|
2449 | assert( sizeof( *m_pbSDCFlag) == 1 ); |
---|
2450 | memset( m_pbSDCFlag + uiAbsPartIdx, bSDCFlag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2451 | } |
---|
2452 | |
---|
2453 | Bool TComDataCU::getSDCAvailable( UInt uiAbsPartIdx ) |
---|
2454 | { |
---|
2455 | // check general CU information |
---|
2456 | if( !getSlice()->getIsDepth() || !isIntra(uiAbsPartIdx) || getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) |
---|
2457 | { |
---|
2458 | return false; |
---|
2459 | } |
---|
2460 | |
---|
2461 | if( isDimMode( getLumaIntraDir( uiAbsPartIdx ) ) ) |
---|
2462 | { |
---|
2463 | return true; |
---|
2464 | } |
---|
2465 | |
---|
2466 | if( getLumaIntraDir( uiAbsPartIdx ) < NUM_INTRA_MODE ) |
---|
2467 | { |
---|
2468 | return true; |
---|
2469 | } |
---|
2470 | |
---|
2471 | return false; |
---|
2472 | // check prediction mode |
---|
2473 | UInt uiLumaPredMode = getLumaIntraDir( uiAbsPartIdx ); |
---|
2474 | if( uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX ) ) |
---|
2475 | return true; |
---|
2476 | |
---|
2477 | // else |
---|
2478 | return false; |
---|
2479 | } |
---|
2480 | #endif |
---|
2481 | |
---|
2482 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2483 | { |
---|
2484 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2485 | } |
---|
2486 | |
---|
2487 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2488 | { |
---|
2489 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2490 | } |
---|
2491 | |
---|
2492 | #if H_3D_SPIVMP |
---|
2493 | Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2494 | { |
---|
2495 | setSubPart<Bool>( bSPIVMPFlag, m_pbSPIVMPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2496 | } |
---|
2497 | #endif |
---|
2498 | |
---|
2499 | #if H_3D_VSP |
---|
2500 | Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2501 | { |
---|
2502 | setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2503 | } |
---|
2504 | #if H_3D_VSP |
---|
2505 | template<typename T> |
---|
2506 | Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2507 | { |
---|
2508 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
---|
2509 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2510 | { |
---|
2511 | case SIZE_2Nx2N: |
---|
2512 | for (UInt ui = 0; ui < 4 * uiCurrPartNumQ; ui++) |
---|
2513 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2514 | |
---|
2515 | break; |
---|
2516 | case SIZE_2NxN: |
---|
2517 | for (UInt ui = 0; ui < 2 * uiCurrPartNumQ; ui++) |
---|
2518 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2519 | break; |
---|
2520 | case SIZE_Nx2N: |
---|
2521 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2522 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2523 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2524 | puhBaseLCU[uiCUAddr + 2 * uiCurrPartNumQ + ui] = uiParameter; |
---|
2525 | break; |
---|
2526 | case SIZE_NxN: |
---|
2527 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2528 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2529 | break; |
---|
2530 | case SIZE_2NxnU: |
---|
2531 | if ( uiPUIdx == 0 ) |
---|
2532 | { |
---|
2533 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2534 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2535 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2536 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2537 | |
---|
2538 | } |
---|
2539 | else if ( uiPUIdx == 1 ) |
---|
2540 | { |
---|
2541 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2542 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2543 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1); ui++) |
---|
2544 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2545 | |
---|
2546 | } |
---|
2547 | else |
---|
2548 | { |
---|
2549 | assert(0); |
---|
2550 | } |
---|
2551 | break; |
---|
2552 | case SIZE_2NxnD: |
---|
2553 | if ( uiPUIdx == 0 ) |
---|
2554 | { |
---|
2555 | for (UInt ui = 0; ui < ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)); ui++) |
---|
2556 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2557 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2558 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + ui] = uiParameter; |
---|
2559 | |
---|
2560 | } |
---|
2561 | else if ( uiPUIdx == 1 ) |
---|
2562 | { |
---|
2563 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2564 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2565 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2566 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2567 | |
---|
2568 | } |
---|
2569 | else |
---|
2570 | { |
---|
2571 | assert(0); |
---|
2572 | } |
---|
2573 | break; |
---|
2574 | case SIZE_nLx2N: |
---|
2575 | if ( uiPUIdx == 0 ) |
---|
2576 | { |
---|
2577 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2578 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2579 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2580 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2581 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2582 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2583 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2584 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2585 | |
---|
2586 | } |
---|
2587 | else if ( uiPUIdx == 1 ) |
---|
2588 | { |
---|
2589 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2590 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2591 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2592 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2593 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2594 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2595 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2596 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2597 | |
---|
2598 | } |
---|
2599 | else |
---|
2600 | { |
---|
2601 | assert(0); |
---|
2602 | } |
---|
2603 | break; |
---|
2604 | case SIZE_nRx2N: |
---|
2605 | if ( uiPUIdx == 0 ) |
---|
2606 | { |
---|
2607 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2608 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2609 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2610 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2611 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2612 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2613 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2614 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2615 | |
---|
2616 | } |
---|
2617 | else if ( uiPUIdx == 1 ) |
---|
2618 | { |
---|
2619 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2620 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2621 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2622 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2623 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2624 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2625 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2626 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2627 | |
---|
2628 | } |
---|
2629 | else |
---|
2630 | { |
---|
2631 | assert(0); |
---|
2632 | } |
---|
2633 | break; |
---|
2634 | default: |
---|
2635 | assert( 0 ); |
---|
2636 | } |
---|
2637 | |
---|
2638 | } |
---|
2639 | #endif |
---|
2640 | #endif |
---|
2641 | |
---|
2642 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2643 | { |
---|
2644 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2645 | } |
---|
2646 | |
---|
2647 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2648 | { |
---|
2649 | setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2650 | } |
---|
2651 | |
---|
2652 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2653 | { |
---|
2654 | setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2655 | } |
---|
2656 | |
---|
2657 | |
---|
2658 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2659 | { |
---|
2660 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2661 | |
---|
2662 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
2663 | } |
---|
2664 | |
---|
2665 | Void TComDataCU::setTransformSkipSubParts( const UInt useTransformSkip[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2666 | { |
---|
2667 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2668 | |
---|
2669 | for(UInt i=0; i<MAX_NUM_COMPONENT; i++) |
---|
2670 | { |
---|
2671 | memset( m_puhTransformSkip[i] + uiAbsPartIdx, useTransformSkip[i], sizeof( UChar ) * uiCurrPartNumb ); |
---|
2672 | } |
---|
2673 | } |
---|
2674 | |
---|
2675 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth) |
---|
2676 | { |
---|
2677 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2678 | |
---|
2679 | memset( m_puhTransformSkip[compID] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2680 | } |
---|
2681 | |
---|
2682 | Void TComDataCU::setTransformSkipPartRange ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
2683 | { |
---|
2684 | memset((m_puhTransformSkip[compID] + uiAbsPartIdx), useTransformSkip, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
2685 | } |
---|
2686 | |
---|
2687 | Void TComDataCU::setCrossComponentPredictionAlphaPartRange( Char alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
2688 | { |
---|
2689 | memset((m_crossComponentPredictionAlpha[compID] + uiAbsPartIdx), alphaValue, (sizeof(Char) * uiCoveredPartIdxes)); |
---|
2690 | } |
---|
2691 | |
---|
2692 | Void TComDataCU::setExplicitRdpcmModePartRange ( UInt rdpcmMode, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
2693 | { |
---|
2694 | memset((m_explicitRdpcmMode[compID] + uiAbsPartIdx), rdpcmMode, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
2695 | } |
---|
2696 | |
---|
2697 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2698 | { |
---|
2699 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
2700 | |
---|
2701 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2702 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
2703 | } |
---|
2704 | |
---|
2705 | UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx) |
---|
2706 | { |
---|
2707 | UChar iNumPart = 0; |
---|
2708 | |
---|
2709 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2710 | { |
---|
2711 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
2712 | case SIZE_2NxN: iNumPart = 2; break; |
---|
2713 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
2714 | case SIZE_NxN: iNumPart = 4; break; |
---|
2715 | case SIZE_2NxnU: iNumPart = 2; break; |
---|
2716 | case SIZE_2NxnD: iNumPart = 2; break; |
---|
2717 | case SIZE_nLx2N: iNumPart = 2; break; |
---|
2718 | case SIZE_nRx2N: iNumPart = 2; break; |
---|
2719 | default: assert (0); break; |
---|
2720 | } |
---|
2721 | |
---|
2722 | return iNumPart; |
---|
2723 | } |
---|
2724 | |
---|
2725 | // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx |
---|
2726 | #if NH_3D_IC |
---|
2727 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU) |
---|
2728 | { |
---|
2729 | UInt uiNumPartition = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition; |
---|
2730 | UInt uiTmpAbsPartIdx = bLCU ? uiAbsPartIdx : 0; |
---|
2731 | |
---|
2732 | switch ( m_pePartSize[uiTmpAbsPartIdx] ) |
---|
2733 | { |
---|
2734 | case SIZE_2NxN: |
---|
2735 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1; |
---|
2736 | break; |
---|
2737 | case SIZE_Nx2N: |
---|
2738 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2; |
---|
2739 | break; |
---|
2740 | case SIZE_NxN: |
---|
2741 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx; |
---|
2742 | break; |
---|
2743 | case SIZE_2NxnU: |
---|
2744 | riWidth = getWidth( uiTmpAbsPartIdx ); |
---|
2745 | riHeight = ( uiPartIdx == 0 ) ? getHeight( uiTmpAbsPartIdx ) >> 2 : ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ); |
---|
2746 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3; |
---|
2747 | break; |
---|
2748 | case SIZE_2NxnD: |
---|
2749 | riWidth = getWidth( uiTmpAbsPartIdx ); |
---|
2750 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ) : getHeight( uiTmpAbsPartIdx ) >> 2; |
---|
2751 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3); |
---|
2752 | break; |
---|
2753 | case SIZE_nLx2N: |
---|
2754 | riWidth = ( uiPartIdx == 0 ) ? getWidth( uiTmpAbsPartIdx ) >> 2 : ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ); |
---|
2755 | riHeight = getHeight( uiTmpAbsPartIdx ); |
---|
2756 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4; |
---|
2757 | break; |
---|
2758 | case SIZE_nRx2N: |
---|
2759 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ) : getWidth( uiTmpAbsPartIdx ) >> 2; |
---|
2760 | riHeight = getHeight( uiTmpAbsPartIdx ); |
---|
2761 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4); |
---|
2762 | break; |
---|
2763 | default: |
---|
2764 | assert ( m_pePartSize[uiTmpAbsPartIdx] == SIZE_2Nx2N ); |
---|
2765 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = 0; |
---|
2766 | break; |
---|
2767 | } |
---|
2768 | } |
---|
2769 | #else |
---|
2770 | |
---|
2771 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
---|
2772 | { |
---|
2773 | switch ( m_pePartSize[0] ) |
---|
2774 | { |
---|
2775 | case SIZE_2NxN: |
---|
2776 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2777 | break; |
---|
2778 | case SIZE_Nx2N: |
---|
2779 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
2780 | break; |
---|
2781 | case SIZE_NxN: |
---|
2782 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2783 | break; |
---|
2784 | case SIZE_2NxnU: |
---|
2785 | riWidth = getWidth(0); |
---|
2786 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
2787 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
---|
2788 | break; |
---|
2789 | case SIZE_2NxnD: |
---|
2790 | riWidth = getWidth(0); |
---|
2791 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
2792 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
---|
2793 | break; |
---|
2794 | case SIZE_nLx2N: |
---|
2795 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
2796 | riHeight = getHeight(0); |
---|
2797 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
---|
2798 | break; |
---|
2799 | case SIZE_nRx2N: |
---|
2800 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
2801 | riHeight = getHeight(0); |
---|
2802 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2803 | break; |
---|
2804 | default: |
---|
2805 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
2806 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
2807 | break; |
---|
2808 | } |
---|
2809 | } |
---|
2810 | #endif |
---|
2811 | |
---|
2812 | |
---|
2813 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
2814 | { |
---|
2815 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
2816 | { |
---|
2817 | TComMv cZeroMv; |
---|
2818 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
2819 | return; |
---|
2820 | } |
---|
2821 | |
---|
2822 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
2823 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
2824 | } |
---|
2825 | |
---|
2826 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2827 | { |
---|
2828 | ruiPartIdxLT = m_absZIdxInCtu + uiAbsPartIdx; |
---|
2829 | UInt uiPUWidth = 0; |
---|
2830 | |
---|
2831 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2832 | { |
---|
2833 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2834 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2835 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2836 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2837 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2838 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2839 | case SIZE_nLx2N: |
---|
2840 | if ( uiPartIdx == 0 ) |
---|
2841 | { |
---|
2842 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
2843 | } |
---|
2844 | else if ( uiPartIdx == 1 ) |
---|
2845 | { |
---|
2846 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
2847 | } |
---|
2848 | else |
---|
2849 | { |
---|
2850 | assert(0); |
---|
2851 | } |
---|
2852 | break; |
---|
2853 | case SIZE_nRx2N: |
---|
2854 | if ( uiPartIdx == 0 ) |
---|
2855 | { |
---|
2856 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
2857 | } |
---|
2858 | else if ( uiPartIdx == 1 ) |
---|
2859 | { |
---|
2860 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
2861 | } |
---|
2862 | else |
---|
2863 | { |
---|
2864 | assert(0); |
---|
2865 | } |
---|
2866 | break; |
---|
2867 | default: |
---|
2868 | assert (0); |
---|
2869 | break; |
---|
2870 | } |
---|
2871 | |
---|
2872 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2873 | } |
---|
2874 | |
---|
2875 | Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2876 | { |
---|
2877 | UInt uiPUHeight = 0; |
---|
2878 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2879 | { |
---|
2880 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2881 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2882 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2883 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2884 | case SIZE_2NxnU: |
---|
2885 | if ( uiPartIdx == 0 ) |
---|
2886 | { |
---|
2887 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
2888 | } |
---|
2889 | else if ( uiPartIdx == 1 ) |
---|
2890 | { |
---|
2891 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
2892 | } |
---|
2893 | else |
---|
2894 | { |
---|
2895 | assert(0); |
---|
2896 | } |
---|
2897 | break; |
---|
2898 | case SIZE_2NxnD: |
---|
2899 | if ( uiPartIdx == 0 ) |
---|
2900 | { |
---|
2901 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
2902 | } |
---|
2903 | else if ( uiPartIdx == 1 ) |
---|
2904 | { |
---|
2905 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
2906 | } |
---|
2907 | else |
---|
2908 | { |
---|
2909 | assert(0); |
---|
2910 | } |
---|
2911 | break; |
---|
2912 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2913 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2914 | default: |
---|
2915 | assert (0); |
---|
2916 | break; |
---|
2917 | } |
---|
2918 | |
---|
2919 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInCtuWidth()]; |
---|
2920 | } |
---|
2921 | |
---|
2922 | Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2923 | { |
---|
2924 | ruiPartIdxLT = m_absZIdxInCtu; |
---|
2925 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2926 | |
---|
2927 | switch ( m_pePartSize[0] ) |
---|
2928 | { |
---|
2929 | case SIZE_2Nx2N: break; |
---|
2930 | case SIZE_2NxN: |
---|
2931 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2932 | break; |
---|
2933 | case SIZE_Nx2N: |
---|
2934 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
2935 | break; |
---|
2936 | case SIZE_NxN: |
---|
2937 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2938 | break; |
---|
2939 | case SIZE_2NxnU: |
---|
2940 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2941 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
2942 | break; |
---|
2943 | case SIZE_2NxnD: |
---|
2944 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2945 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
2946 | break; |
---|
2947 | case SIZE_nLx2N: |
---|
2948 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
---|
2949 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2950 | break; |
---|
2951 | case SIZE_nRx2N: |
---|
2952 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
2953 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
---|
2954 | break; |
---|
2955 | default: |
---|
2956 | assert (0); |
---|
2957 | break; |
---|
2958 | } |
---|
2959 | |
---|
2960 | } |
---|
2961 | |
---|
2962 | Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2963 | { |
---|
2964 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth()]; |
---|
2965 | |
---|
2966 | switch ( m_pePartSize[0] ) |
---|
2967 | { |
---|
2968 | case SIZE_2Nx2N: |
---|
2969 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
2970 | break; |
---|
2971 | case SIZE_2NxN: |
---|
2972 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2973 | break; |
---|
2974 | case SIZE_Nx2N: |
---|
2975 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
2976 | break; |
---|
2977 | case SIZE_NxN: |
---|
2978 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2979 | break; |
---|
2980 | case SIZE_2NxnU: |
---|
2981 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
2982 | break; |
---|
2983 | case SIZE_2NxnD: |
---|
2984 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
2985 | break; |
---|
2986 | case SIZE_nLx2N: |
---|
2987 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
---|
2988 | break; |
---|
2989 | case SIZE_nRx2N: |
---|
2990 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2991 | break; |
---|
2992 | default: |
---|
2993 | assert (0); |
---|
2994 | break; |
---|
2995 | } |
---|
2996 | } |
---|
2997 | |
---|
2998 | /** Derive the partition index of neighbouring bottom right block |
---|
2999 | * \param [in] uiPartIdx current partition index |
---|
3000 | * \param [out] ruiPartIdxRB partition index of neighbouring bottom right block |
---|
3001 | */ |
---|
3002 | Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt &ruiPartIdxRB ) |
---|
3003 | { |
---|
3004 | 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]; |
---|
3005 | |
---|
3006 | switch ( m_pePartSize[0] ) |
---|
3007 | { |
---|
3008 | case SIZE_2Nx2N: |
---|
3009 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
3010 | break; |
---|
3011 | case SIZE_2NxN: |
---|
3012 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
3013 | break; |
---|
3014 | case SIZE_Nx2N: |
---|
3015 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
3016 | break; |
---|
3017 | case SIZE_NxN: |
---|
3018 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
3019 | break; |
---|
3020 | case SIZE_2NxnU: |
---|
3021 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
3022 | break; |
---|
3023 | case SIZE_2NxnD: |
---|
3024 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
3025 | break; |
---|
3026 | case SIZE_nLx2N: |
---|
3027 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
---|
3028 | break; |
---|
3029 | case SIZE_nRx2N: |
---|
3030 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
---|
3031 | break; |
---|
3032 | default: |
---|
3033 | assert (0); |
---|
3034 | break; |
---|
3035 | } |
---|
3036 | } |
---|
3037 | |
---|
3038 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
3039 | { |
---|
3040 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
3041 | { |
---|
3042 | return false; |
---|
3043 | } |
---|
3044 | |
---|
3045 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
3046 | { |
---|
3047 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
3048 | { |
---|
3049 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
3050 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
3051 | { |
---|
3052 | return false; |
---|
3053 | } |
---|
3054 | } |
---|
3055 | } |
---|
3056 | |
---|
3057 | return true; |
---|
3058 | } |
---|
3059 | |
---|
3060 | #if H_3D_VSP |
---|
3061 | |
---|
3062 | /** Add a VSP merging candidate |
---|
3063 | * \Inputs |
---|
3064 | * \param uiPUIdx: PU index within a CU |
---|
3065 | * \param ucVspMergePos: Specify the VSP merge candidate position |
---|
3066 | * \param mrgCandIdx: Target merge candidate index. At encoder, it is set equal to -1, such that the whole merge candidate list will be constructed. |
---|
3067 | * \param pDinfo: The "disparity information" derived from neighboring blocks. Type 1 MV. |
---|
3068 | * \param uiCount: The next position to add VSP merge candidate |
---|
3069 | * |
---|
3070 | * \Outputs |
---|
3071 | * \param uiCount: The next position to add merge candidate. Will be updated if VSP is successfully added |
---|
3072 | * \param abCandIsInter: abCandIsInter[iCount] tells that VSP candidate is an Inter candidate, if VSP is successfully added |
---|
3073 | * \param pcMvFieldNeighbours: Return combined motion information, then stored to a global buffer |
---|
3074 | * 1) the "disparity vector". Type 1 MV. To be used to fetch a depth block. |
---|
3075 | * 2) the ref index /list. Type 2 reference picture pointer, typically for texture |
---|
3076 | * \param puhInterDirNeighbours: Indicate the VSP prediction direction. |
---|
3077 | * \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 |
---|
3078 | * |
---|
3079 | * \Return |
---|
3080 | * true: if the VSP candidate is added at the target position |
---|
3081 | * false: otherwise |
---|
3082 | */ |
---|
3083 | inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount) |
---|
3084 | { |
---|
3085 | if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getViewSynthesisPredFlag( ) || m_pcSlice->getIsDepth() || pDInfo->m_aVIdxCan == -1) |
---|
3086 | { |
---|
3087 | return false; |
---|
3088 | } |
---|
3089 | |
---|
3090 | Int refViewIdx = pDInfo->m_aVIdxCan; |
---|
3091 | TComPic* picDepth = getSlice()->getIvPic( true, refViewIdx ); |
---|
3092 | |
---|
3093 | if( picDepth == NULL ) // No depth reference avail |
---|
3094 | { |
---|
3095 | // Is this allowed to happen? When not an assertion should be added here! |
---|
3096 | return false; |
---|
3097 | } |
---|
3098 | |
---|
3099 | TComMvField mvVSP[2]; |
---|
3100 | UChar dirVSP; |
---|
3101 | Bool refViewAvailFlag = false; |
---|
3102 | UChar predFlag[2] = {0, 0}; |
---|
3103 | |
---|
3104 | for( Int iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ ) |
---|
3105 | { |
---|
3106 | RefPicList eRefPicListX = RefPicList( iRefListIdX ); |
---|
3107 | for ( Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicListX) && !refViewAvailFlag; i++ ) |
---|
3108 | { |
---|
3109 | Int viewIdxRefInListX = m_pcSlice->getRefPic(eRefPicListX, i)->getViewIndex(); |
---|
3110 | if ( viewIdxRefInListX == refViewIdx ) |
---|
3111 | { |
---|
3112 | refViewAvailFlag = true; |
---|
3113 | predFlag[iRefListIdX] = 1; |
---|
3114 | mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i ); |
---|
3115 | #if H_3D_NBDV |
---|
3116 | mvVSP[0+iRefListIdX].getMv().setIDVFlag (false); |
---|
3117 | #endif |
---|
3118 | } |
---|
3119 | } |
---|
3120 | } |
---|
3121 | |
---|
3122 | dirVSP = (predFlag[0] | (predFlag[1] << 1)); |
---|
3123 | m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true, false); |
---|
3124 | if ( mrgCandIdx == iCount ) |
---|
3125 | { |
---|
3126 | return true; |
---|
3127 | } |
---|
3128 | |
---|
3129 | iCount++; |
---|
3130 | |
---|
3131 | return false; |
---|
3132 | } |
---|
3133 | |
---|
3134 | #endif |
---|
3135 | |
---|
3136 | #if H_3D_IV_MERGE |
---|
3137 | inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx ) |
---|
3138 | { |
---|
3139 | for(Int iLoop = 0; iLoop < 2; iLoop ++ ) |
---|
3140 | { |
---|
3141 | /// iLoop = 0 --> IvMCShift |
---|
3142 | /// iLoop = 1 --> IvDCShift (Derived from IvDC) |
---|
3143 | if(ivCandDir[iLoop + 2]) |
---|
3144 | { |
---|
3145 | TComMvField tmpMV[2]; |
---|
3146 | UChar tmpDir = ivCandDir[iLoop + 2]; |
---|
3147 | if( ( ivCandDir[iLoop + 2] & 1 ) == 1 ) |
---|
3148 | { |
---|
3149 | tmpMV[0].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] ); |
---|
3150 | } |
---|
3151 | if( ( ivCandDir[iLoop + 2] & 2 ) == 2 ) |
---|
3152 | { |
---|
3153 | tmpMV[1].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] ); |
---|
3154 | } |
---|
3155 | |
---|
3156 | // Prune IvMC vs. IvMcShift |
---|
3157 | Bool bRemove = false; |
---|
3158 | if( !iLoop && ivCandDir[0] > 0) |
---|
3159 | { |
---|
3160 | 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]) |
---|
3161 | { |
---|
3162 | bRemove = true; |
---|
3163 | } |
---|
3164 | } |
---|
3165 | if(!bRemove) |
---|
3166 | { |
---|
3167 | #if H_3D_NBDV |
---|
3168 | if(iLoop) // For IvMcShift candidate |
---|
3169 | { |
---|
3170 | tmpMV[0].getMv().setIDVFlag (false); |
---|
3171 | tmpMV[1].getMv().setIDVFlag (false); |
---|
3172 | } |
---|
3173 | #endif |
---|
3174 | m_mergCands[MRG_IVSHIFT].setCand(tmpMV, tmpDir, false, false); |
---|
3175 | if( mrgCandIdx == iCount ) |
---|
3176 | { |
---|
3177 | return true; |
---|
3178 | } |
---|
3179 | iCount++; |
---|
3180 | } |
---|
3181 | break; |
---|
3182 | } |
---|
3183 | } |
---|
3184 | return false; |
---|
3185 | } |
---|
3186 | |
---|
3187 | #endif |
---|
3188 | #if H_3D |
---|
3189 | Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
3190 | #if H_3D_VSP |
---|
3191 | , Int* vspFlag |
---|
3192 | #endif |
---|
3193 | #if H_3D_SPIVMP |
---|
3194 | , Bool* pbSPIVMPFlag |
---|
3195 | #endif |
---|
3196 | , Int& numValidMergeCand |
---|
3197 | ) |
---|
3198 | { |
---|
3199 | if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) // for only dependent texture |
---|
3200 | { |
---|
3201 | return; |
---|
3202 | } |
---|
3203 | |
---|
3204 | Int iCount = 0; |
---|
3205 | TComMv cZeroMv; |
---|
3206 | |
---|
3207 | // init temporal list |
---|
3208 | TComMvField extMergeCandList[MRG_MAX_NUM_CANDS_MEM << 1]; |
---|
3209 | UChar uhInterDirNeighboursExt[MRG_MAX_NUM_CANDS_MEM]; |
---|
3210 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
3211 | { |
---|
3212 | uhInterDirNeighboursExt[ui] = puhInterDirNeighbours[ui]; |
---|
3213 | extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID); |
---|
3214 | extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID); |
---|
3215 | vspFlag[ui] = 0; |
---|
3216 | } |
---|
3217 | |
---|
3218 | // add candidates to temporal list |
---|
3219 | // insert MPI ... IvShift candidate |
---|
3220 | for (Int i=0; i<=MRG_IVSHIFT; i++) |
---|
3221 | { |
---|
3222 | if (m_mergCands[i].m_bAvailable) |
---|
3223 | { |
---|
3224 | m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt, vspFlag, pbSPIVMPFlag); |
---|
3225 | iCount++; |
---|
3226 | if (iCount >= getSlice()->getMaxNumMergeCand()) |
---|
3227 | break; |
---|
3228 | } |
---|
3229 | } |
---|
3230 | |
---|
3231 | // insert remaining base candidates |
---|
3232 | while (iCount < getSlice()->getMaxNumMergeCand() && m_baseListidc < getSlice()->getMaxNumMergeCand()) |
---|
3233 | { |
---|
3234 | uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[m_baseListidc]; |
---|
3235 | extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[m_baseListidc<<1].getMv(), pcMvFieldNeighbours[m_baseListidc<<1].getRefIdx()); |
---|
3236 | if ( getSlice()->isInterB() ) |
---|
3237 | { |
---|
3238 | extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(m_baseListidc<<1)+1].getMv(), pcMvFieldNeighbours[(m_baseListidc<<1)+1].getRefIdx()); |
---|
3239 | } |
---|
3240 | m_baseListidc++; |
---|
3241 | iCount++; |
---|
3242 | } |
---|
3243 | |
---|
3244 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ ) |
---|
3245 | { |
---|
3246 | puhInterDirNeighbours[ui] = 0; |
---|
3247 | pcMvFieldNeighbours[ui<<1].setMvField(cZeroMv, NOT_VALID); |
---|
3248 | pcMvFieldNeighbours[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID); |
---|
3249 | } |
---|
3250 | // copy extMergeCandList to output |
---|
3251 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ ) |
---|
3252 | { |
---|
3253 | puhInterDirNeighbours[ui] = uhInterDirNeighboursExt[ui]; |
---|
3254 | pcMvFieldNeighbours[ui<<1].setMvField(extMergeCandList[ui<<1].getMv(), extMergeCandList[ui<<1].getRefIdx()); |
---|
3255 | if ( getSlice()->isInterB() ) |
---|
3256 | pcMvFieldNeighbours[(ui<<1)+1].setMvField(extMergeCandList[(ui<<1)+1].getMv(), extMergeCandList[(ui<<1)+1].getRefIdx()); |
---|
3257 | } |
---|
3258 | numValidMergeCand = iCount; |
---|
3259 | assert(iCount == getSlice()->getMaxNumMergeCand()); |
---|
3260 | } |
---|
3261 | |
---|
3262 | /** Constructs a list of merging candidates |
---|
3263 | * \param uiAbsPartIdx |
---|
3264 | * \param uiPUIdx |
---|
3265 | * \param uiDepth |
---|
3266 | * \param pcMvFieldNeighbours |
---|
3267 | * \param puhInterDirNeighbours |
---|
3268 | * \param numValidMergeCand |
---|
3269 | */ |
---|
3270 | // HM 12.0 based merge candidate list construction |
---|
3271 | |
---|
3272 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) |
---|
3273 | { |
---|
3274 | |
---|
3275 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
3276 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ]; |
---|
3277 | TComMv cZeroMv; |
---|
3278 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
3279 | { |
---|
3280 | abCandIsInter[ui] = false; |
---|
3281 | pcMvFieldNeighbours[ ( ui << 1 ) ].setMvField(cZeroMv, NOT_VALID); |
---|
3282 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID); |
---|
3283 | } |
---|
3284 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
3285 | // compute the location of the current PU |
---|
3286 | Int xP, yP, nPSW, nPSH; |
---|
3287 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
3288 | |
---|
3289 | Int iCount = 0; |
---|
3290 | |
---|
3291 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
3292 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
3293 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
3294 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
3295 | |
---|
3296 | //left |
---|
3297 | UInt uiLeftPartIdx = 0; |
---|
3298 | TComDataCU* pcCULeft = 0; |
---|
3299 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
3300 | Bool isAvailableA1 = pcCULeft && |
---|
3301 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
3302 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
3303 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
---|
3304 | if ( isAvailableA1 ) |
---|
3305 | { |
---|
3306 | m_bAvailableFlagA1 = 1; |
---|
3307 | abCandIsInter[iCount] = true; |
---|
3308 | // get Inter Dir |
---|
3309 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
3310 | // get Mv from Left |
---|
3311 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3312 | if ( getSlice()->isInterB() ) |
---|
3313 | { |
---|
3314 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3315 | } |
---|
3316 | |
---|
3317 | iCount ++; |
---|
3318 | } |
---|
3319 | |
---|
3320 | // early termination |
---|
3321 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3322 | { |
---|
3323 | return; |
---|
3324 | } |
---|
3325 | // above |
---|
3326 | UInt uiAbovePartIdx = 0; |
---|
3327 | TComDataCU* pcCUAbove = 0; |
---|
3328 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
3329 | Bool isAvailableB1 = pcCUAbove && |
---|
3330 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
3331 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
3332 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
---|
3333 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
3334 | { |
---|
3335 | m_bAvailableFlagB1 = 1; |
---|
3336 | abCandIsInter[iCount] = true; |
---|
3337 | // get Inter Dir |
---|
3338 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
3339 | // get Mv from Left |
---|
3340 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3341 | if ( getSlice()->isInterB() ) |
---|
3342 | { |
---|
3343 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3344 | } |
---|
3345 | if ( mrgCandIdx == iCount ) |
---|
3346 | { |
---|
3347 | return; |
---|
3348 | } |
---|
3349 | iCount ++; |
---|
3350 | } |
---|
3351 | // early termination |
---|
3352 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3353 | { |
---|
3354 | return; |
---|
3355 | } |
---|
3356 | |
---|
3357 | // above right |
---|
3358 | UInt uiAboveRightPartIdx = 0; |
---|
3359 | TComDataCU* pcCUAboveRight = 0; |
---|
3360 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
3361 | Bool isAvailableB0 = pcCUAboveRight && |
---|
3362 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
3363 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
---|
3364 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
3365 | { |
---|
3366 | m_bAvailableFlagB0 = 1; |
---|
3367 | abCandIsInter[iCount] = true; |
---|
3368 | // get Inter Dir |
---|
3369 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
3370 | // get Mv from Left |
---|
3371 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3372 | if ( getSlice()->isInterB() ) |
---|
3373 | { |
---|
3374 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3375 | } |
---|
3376 | if ( mrgCandIdx == iCount ) |
---|
3377 | { |
---|
3378 | return; |
---|
3379 | } |
---|
3380 | iCount ++; |
---|
3381 | } |
---|
3382 | // early termination |
---|
3383 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3384 | { |
---|
3385 | return; |
---|
3386 | } |
---|
3387 | |
---|
3388 | //left bottom |
---|
3389 | UInt uiLeftBottomPartIdx = 0; |
---|
3390 | TComDataCU* pcCULeftBottom = 0; |
---|
3391 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
3392 | Bool isAvailableA0 = pcCULeftBottom && |
---|
3393 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
3394 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
---|
3395 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
3396 | { |
---|
3397 | m_bAvailableFlagA0 = 1; |
---|
3398 | abCandIsInter[iCount] = true; |
---|
3399 | // get Inter Dir |
---|
3400 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
3401 | // get Mv from Left |
---|
3402 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3403 | if ( getSlice()->isInterB() ) |
---|
3404 | { |
---|
3405 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3406 | } |
---|
3407 | if ( mrgCandIdx == iCount ) |
---|
3408 | { |
---|
3409 | return; |
---|
3410 | } |
---|
3411 | iCount ++; |
---|
3412 | } |
---|
3413 | // early termination |
---|
3414 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3415 | { |
---|
3416 | return; |
---|
3417 | } |
---|
3418 | // above left |
---|
3419 | if( iCount < 4 ) |
---|
3420 | { |
---|
3421 | UInt uiAboveLeftPartIdx = 0; |
---|
3422 | TComDataCU* pcCUAboveLeft = 0; |
---|
3423 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
3424 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
3425 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
3426 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
---|
3427 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
3428 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
3429 | { |
---|
3430 | m_bAvailableFlagB2 = 1; |
---|
3431 | abCandIsInter[iCount] = true; |
---|
3432 | // get Inter Dir |
---|
3433 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
3434 | // get Mv from Left |
---|
3435 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3436 | if ( getSlice()->isInterB() ) |
---|
3437 | { |
---|
3438 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3439 | } |
---|
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 | if ( getSlice()->getEnableTMVPFlag()) |
---|
3453 | { |
---|
3454 | //>> MTK colocated-RightBottom |
---|
3455 | UInt uiPartIdxRB; |
---|
3456 | |
---|
3457 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
3458 | |
---|
3459 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
3460 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
3461 | |
---|
3462 | TComMv cColMv; |
---|
3463 | Int iRefIdx; |
---|
3464 | Int uiLCUIdx = -1; |
---|
3465 | |
---|
3466 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
3467 | { |
---|
3468 | } |
---|
3469 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
3470 | { |
---|
3471 | } |
---|
3472 | else |
---|
3473 | { |
---|
3474 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
3475 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
3476 | { |
---|
3477 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
3478 | uiLCUIdx = getAddr(); |
---|
3479 | } |
---|
3480 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
3481 | { |
---|
3482 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
3483 | } |
---|
3484 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
3485 | { |
---|
3486 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
3487 | uiLCUIdx = getAddr() + 1; |
---|
3488 | } |
---|
3489 | else //is the right bottom corner of LCU |
---|
3490 | { |
---|
3491 | uiAbsPartAddr = 0; |
---|
3492 | } |
---|
3493 | } |
---|
3494 | |
---|
3495 | iRefIdx = 0; |
---|
3496 | Bool bExistMV = false; |
---|
3497 | UInt uiPartIdxCenter; |
---|
3498 | UInt uiCurLCUIdx = getAddr(); |
---|
3499 | Int dir = 0; |
---|
3500 | UInt uiArrayAddr = iCount; |
---|
3501 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
3502 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
3503 | if( bExistMV == false ) |
---|
3504 | { |
---|
3505 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
3506 | } |
---|
3507 | if( bExistMV ) |
---|
3508 | { |
---|
3509 | dir |= 1; |
---|
3510 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
3511 | } |
---|
3512 | |
---|
3513 | if ( getSlice()->isInterB() ) |
---|
3514 | { |
---|
3515 | #if NH_3D_TMVP //to be changed to NH_3D_TMVP in future migration |
---|
3516 | iRefIdx = 0; |
---|
3517 | #endif |
---|
3518 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
3519 | if( bExistMV == false ) |
---|
3520 | { |
---|
3521 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
3522 | } |
---|
3523 | if( bExistMV ) |
---|
3524 | { |
---|
3525 | dir |= 2; |
---|
3526 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
3527 | } |
---|
3528 | } |
---|
3529 | |
---|
3530 | if (dir != 0) |
---|
3531 | { |
---|
3532 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
3533 | abCandIsInter[uiArrayAddr] = true; |
---|
3534 | #if H_3D_NBDV |
---|
3535 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
---|
3536 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
---|
3537 | #endif |
---|
3538 | if ( mrgCandIdx == iCount ) |
---|
3539 | { |
---|
3540 | return; |
---|
3541 | } |
---|
3542 | iCount++; |
---|
3543 | } |
---|
3544 | } |
---|
3545 | // early termination |
---|
3546 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3547 | { |
---|
3548 | return; |
---|
3549 | } |
---|
3550 | UInt uiArrayAddr = iCount; |
---|
3551 | UInt uiCutoff = uiArrayAddr; |
---|
3552 | |
---|
3553 | if ( getSlice()->isInterB() && iCount<5) // JCT3V-F0129 by Qualcomm |
---|
3554 | { |
---|
3555 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
3556 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
3557 | |
---|
3558 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
3559 | { |
---|
3560 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
3561 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
3562 | { |
---|
3563 | abCandIsInter[uiArrayAddr] = true; |
---|
3564 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3565 | |
---|
3566 | // get Mv from cand[i] and cand[j] |
---|
3567 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
3568 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
3569 | |
---|
3570 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
3571 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
3572 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
3573 | { |
---|
3574 | abCandIsInter[uiArrayAddr] = false; |
---|
3575 | } |
---|
3576 | else |
---|
3577 | { |
---|
3578 | uiArrayAddr++; |
---|
3579 | } |
---|
3580 | } |
---|
3581 | } |
---|
3582 | } |
---|
3583 | // early termination |
---|
3584 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
3585 | { |
---|
3586 | return; |
---|
3587 | } |
---|
3588 | |
---|
3589 | 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); |
---|
3590 | Int r = 0; |
---|
3591 | Int refcnt = 0; |
---|
3592 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
3593 | { |
---|
3594 | abCandIsInter[uiArrayAddr] = true; |
---|
3595 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
3596 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
3597 | |
---|
3598 | if ( getSlice()->isInterB() ) |
---|
3599 | { |
---|
3600 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3601 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
3602 | } |
---|
3603 | uiArrayAddr++; |
---|
3604 | if ( refcnt == iNumRefIdx - 1 ) |
---|
3605 | { |
---|
3606 | r = 0; |
---|
3607 | } |
---|
3608 | else |
---|
3609 | { |
---|
3610 | ++r; |
---|
3611 | ++refcnt; |
---|
3612 | } |
---|
3613 | } |
---|
3614 | |
---|
3615 | numValidMergeCand = uiArrayAddr; |
---|
3616 | } |
---|
3617 | |
---|
3618 | |
---|
3619 | |
---|
3620 | /** Constructs a list of merging candidates |
---|
3621 | * \param uiAbsPartIdx |
---|
3622 | * \param uiPUIdx |
---|
3623 | * \param uiDepth |
---|
3624 | * \param pcMvFieldNeighbours |
---|
3625 | * \param puhInterDirNeighbours |
---|
3626 | * \param numValidMergeCand |
---|
3627 | */ |
---|
3628 | #if H_3D |
---|
3629 | Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
3630 | #else |
---|
3631 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
3632 | #endif |
---|
3633 | #if H_3D_SPIVMP |
---|
3634 | , TComMvField* pcMvFieldSP, UChar* puhInterDirSP |
---|
3635 | #endif |
---|
3636 | , Int& numValidMergeCand, Int mrgCandIdx |
---|
3637 | ) |
---|
3638 | { |
---|
3639 | #if H_3D_IV_MERGE |
---|
3640 | //////////////////////////// |
---|
3641 | //////// INIT LISTS //////// |
---|
3642 | //////////////////////////// |
---|
3643 | TComMv cZeroMv; |
---|
3644 | #else |
---|
3645 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
3646 | #endif |
---|
3647 | #if H_3D |
---|
3648 | TComMvField tmpMV[2]; |
---|
3649 | UChar tmpDir; |
---|
3650 | |
---|
3651 | |
---|
3652 | ////////////////////////////////// |
---|
3653 | //////// GET DISPARITIES //////// |
---|
3654 | ////////////////////////////////// |
---|
3655 | DisInfo cDisInfo = getDvInfo(uiAbsPartIdx); |
---|
3656 | m_cDefaultDisInfo = cDisInfo; |
---|
3657 | |
---|
3658 | if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) // current slice is not both dependent view or depth |
---|
3659 | { |
---|
3660 | return; |
---|
3661 | } |
---|
3662 | #else |
---|
3663 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
3664 | { |
---|
3665 | abCandIsInter[ui] = false; |
---|
3666 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
3667 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
3668 | } |
---|
3669 | #endif |
---|
3670 | |
---|
3671 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
3672 | #if H_3D |
---|
3673 | ////////////////////////////////// |
---|
3674 | //////// DERIVE LOCATIONS //////// |
---|
3675 | ////////////////////////////////// |
---|
3676 | #endif |
---|
3677 | // compute the location of the current PU |
---|
3678 | Int xP, yP, nPSW, nPSH; |
---|
3679 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
3680 | |
---|
3681 | Int iCount = 0; |
---|
3682 | |
---|
3683 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
3684 | #if !H_3D |
---|
3685 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
3686 | #endif |
---|
3687 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
3688 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
3689 | #if H_3D |
---|
3690 | Bool bMPIFlag = getSlice()->getMpiFlag(); |
---|
3691 | Bool bIsDepth = getSlice()->getIsDepth(); |
---|
3692 | #endif |
---|
3693 | |
---|
3694 | #if NH_3D_IC |
---|
3695 | Bool bICFlag = getICFlag(uiAbsPartIdx); |
---|
3696 | #endif |
---|
3697 | #if H_3D_ARP |
---|
3698 | Bool bARPFlag = getARPW(uiAbsPartIdx) > 0; |
---|
3699 | #endif |
---|
3700 | #if H_3D_DBBP |
---|
3701 | Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx); |
---|
3702 | assert(bDBBPFlag == getDBBPFlag(0)); |
---|
3703 | #endif |
---|
3704 | |
---|
3705 | #if H_3D |
---|
3706 | #if H_3D_NBDV |
---|
3707 | for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) |
---|
3708 | { |
---|
3709 | pcMvFieldNeighbours[i<<1 ].getMv().setIDVFlag (false); |
---|
3710 | pcMvFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false); |
---|
3711 | } |
---|
3712 | #endif |
---|
3713 | // Clean version for MCL construction align with WD |
---|
3714 | // init mergCands list |
---|
3715 | for (Int i = 0; i<MRG_IVSHIFT+1; i++) |
---|
3716 | { |
---|
3717 | m_mergCands[i].init(); |
---|
3718 | } |
---|
3719 | |
---|
3720 | m_baseListidc = 0; |
---|
3721 | |
---|
3722 | //left |
---|
3723 | UInt uiLeftPartIdx = 0; |
---|
3724 | TComDataCU* pcCULeft = 0; |
---|
3725 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
3726 | |
---|
3727 | if (getAvailableFlagA1()) |
---|
3728 | { |
---|
3729 | m_mergCands[MRG_A1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3730 | #if H_3D_VSP |
---|
3731 | , (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0 |
---|
3732 | #if NH_3D_IC |
---|
3733 | && !bICFlag |
---|
3734 | #endif |
---|
3735 | #if H_3D_ARP |
---|
3736 | && !bARPFlag |
---|
3737 | #endif |
---|
3738 | #if H_3D_DBBP |
---|
3739 | && !bDBBPFlag |
---|
3740 | #endif |
---|
3741 | ) |
---|
3742 | #endif |
---|
3743 | , false |
---|
3744 | ); |
---|
3745 | m_baseListidc++; |
---|
3746 | } |
---|
3747 | |
---|
3748 | // above |
---|
3749 | |
---|
3750 | if (getAvailableFlagB1()) |
---|
3751 | { |
---|
3752 | m_mergCands[MRG_B1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3753 | #if H_3D_VSP |
---|
3754 | , false |
---|
3755 | #endif |
---|
3756 | , false |
---|
3757 | ); |
---|
3758 | m_baseListidc++; |
---|
3759 | } |
---|
3760 | |
---|
3761 | // above right |
---|
3762 | |
---|
3763 | if (getAvailableFlagB0()) |
---|
3764 | { |
---|
3765 | m_mergCands[MRG_B0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3766 | #if H_3D_VSP |
---|
3767 | , |
---|
3768 | false |
---|
3769 | #endif |
---|
3770 | , false |
---|
3771 | ); |
---|
3772 | m_baseListidc++; |
---|
3773 | } |
---|
3774 | |
---|
3775 | // left bottom |
---|
3776 | |
---|
3777 | if (getAvailableFlagA0()) |
---|
3778 | { |
---|
3779 | m_mergCands[MRG_A0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3780 | #if H_3D_VSP |
---|
3781 | , false |
---|
3782 | #endif |
---|
3783 | , false |
---|
3784 | ); |
---|
3785 | m_baseListidc++; |
---|
3786 | } |
---|
3787 | |
---|
3788 | // above left |
---|
3789 | |
---|
3790 | if (getAvailableFlagB2()) |
---|
3791 | { |
---|
3792 | m_mergCands[MRG_B2].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3793 | #if H_3D_VSP |
---|
3794 | , false |
---|
3795 | #endif |
---|
3796 | , false |
---|
3797 | ); |
---|
3798 | m_baseListidc++; |
---|
3799 | } |
---|
3800 | |
---|
3801 | #endif |
---|
3802 | |
---|
3803 | |
---|
3804 | #if H_3D_IV_MERGE |
---|
3805 | |
---|
3806 | ///////////////////////////////////////////// |
---|
3807 | //////// TEXTURE MERGE CANDIDATE (T) //////// |
---|
3808 | ///////////////////////////////////////////// |
---|
3809 | |
---|
3810 | bMPIFlag &= (nPSW + nPSH > 12); |
---|
3811 | if( bMPIFlag) |
---|
3812 | { |
---|
3813 | tmpMV[0].setMvField( cZeroMv, NOT_VALID ); |
---|
3814 | tmpMV[1].setMvField( cZeroMv, NOT_VALID ); |
---|
3815 | tmpDir = 0; |
---|
3816 | |
---|
3817 | Bool bSPIVMPFlag = false; |
---|
3818 | |
---|
3819 | TComPic * pcTexPic = m_pcSlice->getTexturePic(); |
---|
3820 | #if H_3D_FCO |
---|
3821 | if (pcTexPic && pcTexPic->getReconMark()) |
---|
3822 | { |
---|
3823 | #endif |
---|
3824 | TComPicYuv* pcTexRec = pcTexPic->getPicYuvRec (); |
---|
3825 | UInt uiPartAddr; |
---|
3826 | Int iWidth, iHeight; |
---|
3827 | Int iCurrPosX, iCurrPosY; |
---|
3828 | |
---|
3829 | this->getPartIndexAndSize( uiPUIdx, uiPartAddr, iWidth, iHeight ); |
---|
3830 | pcTexRec->getTopLeftSamplePos( this->getAddr(), this->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
3831 | |
---|
3832 | Int iPUWidth, iPUHeight, iNumPart, iNumPartLine; |
---|
3833 | this->getSPPara(iWidth, iHeight, iNumPart, iNumPartLine, iPUWidth, iPUHeight); |
---|
3834 | |
---|
3835 | for (Int i=0; i<iNumPart; i++) |
---|
3836 | { |
---|
3837 | puhInterDirSP[i] = 0; |
---|
3838 | pcMvFieldSP[2*i].getMv().set(0, 0); |
---|
3839 | pcMvFieldSP[2*i+1].getMv().set(0, 0); |
---|
3840 | pcMvFieldSP[2*i].setRefIdx(-1); |
---|
3841 | pcMvFieldSP[2*i+1].setRefIdx(-1); |
---|
3842 | } |
---|
3843 | |
---|
3844 | Int iTexCUAddr; |
---|
3845 | Int iTexAbsPartIdx; |
---|
3846 | TComDataCU* pcTexCU; |
---|
3847 | Int iPartition = 0; |
---|
3848 | Int iInterDirSaved = 0; |
---|
3849 | TComMvField cMvFieldSaved[2]; |
---|
3850 | |
---|
3851 | Int iOffsetX = iPUWidth/2;; |
---|
3852 | Int iOffsetY = iPUHeight/2; |
---|
3853 | |
---|
3854 | Int iTexPosX, iTexPosY; |
---|
3855 | const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); |
---|
3856 | |
---|
3857 | Int iCenterPosX = iCurrPosX + ( ( iWidth / iPUWidth ) >> 1 ) * iPUWidth + ( iPUWidth >> 1 ); |
---|
3858 | Int iCenterPosY = iCurrPosY + ( ( iHeight / iPUHeight ) >> 1 ) * iPUHeight + (iPUHeight >> 1); |
---|
3859 | Int iTexCenterCUAddr, iTexCenterAbsPartIdx; |
---|
3860 | |
---|
3861 | if(iWidth == iPUWidth && iHeight == iPUHeight) |
---|
3862 | { |
---|
3863 | iCenterPosX = iCurrPosX + (iWidth >> 1); |
---|
3864 | iCenterPosY = iCurrPosY + (iHeight >> 1); |
---|
3865 | } |
---|
3866 | |
---|
3867 | // derivation of center motion parameters from the collocated texture CU |
---|
3868 | |
---|
3869 | pcTexRec->getCUAddrAndPartIdx( iCenterPosX , iCenterPosY , iTexCenterCUAddr, iTexCenterAbsPartIdx ); |
---|
3870 | TComDataCU* pcDefaultCU = pcTexPic->getCU( iTexCenterCUAddr ); |
---|
3871 | |
---|
3872 | if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA ) |
---|
3873 | { |
---|
3874 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
3875 | { |
---|
3876 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
3877 | |
---|
3878 | TComMvField cDefaultMvField; |
---|
3879 | pcDefaultCU->getMvField( pcDefaultCU, iTexCenterAbsPartIdx, eCurrRefPicList, cDefaultMvField ); |
---|
3880 | Int iDefaultRefIdx = cDefaultMvField.getRefIdx(); |
---|
3881 | if (iDefaultRefIdx >= 0) |
---|
3882 | { |
---|
3883 | Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eCurrRefPicList, iDefaultRefIdx); |
---|
3884 | for (Int iRefPicList = 0; iRefPicList < m_pcSlice->getNumRefIdx( eCurrRefPicList ); iRefPicList++) |
---|
3885 | { |
---|
3886 | if (iDefaultRefPOC == m_pcSlice->getRefPOC(eCurrRefPicList, iRefPicList)) |
---|
3887 | { |
---|
3888 | bSPIVMPFlag = true; |
---|
3889 | TComMv cMv = cDefaultMvField.getMv() + cMvRounding; |
---|
3890 | cMv >>= 2; |
---|
3891 | cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ; |
---|
3892 | break; |
---|
3893 | } |
---|
3894 | } |
---|
3895 | } |
---|
3896 | } |
---|
3897 | } |
---|
3898 | if ( bSPIVMPFlag == true ) |
---|
3899 | { |
---|
3900 | iInterDirSaved = (cMvFieldSaved[0].getRefIdx()!=-1 ? 1: 0) + (cMvFieldSaved[1].getRefIdx()!=-1 ? 2: 0); |
---|
3901 | tmpDir = iInterDirSaved; |
---|
3902 | tmpMV[0] = cMvFieldSaved[0]; |
---|
3903 | tmpMV[1] = cMvFieldSaved[1]; |
---|
3904 | } |
---|
3905 | |
---|
3906 | if ( iInterDirSaved != 0 ) |
---|
3907 | { |
---|
3908 | for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iPUHeight) |
---|
3909 | { |
---|
3910 | for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iPUWidth) |
---|
3911 | { |
---|
3912 | iTexPosX = j + iOffsetX; |
---|
3913 | iTexPosY = i + iOffsetY; |
---|
3914 | pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx ); |
---|
3915 | pcTexCU = pcTexPic->getCU( iTexCUAddr ); |
---|
3916 | |
---|
3917 | if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) ) |
---|
3918 | { |
---|
3919 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
3920 | { |
---|
3921 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
3922 | TComMvField cTexMvField; |
---|
3923 | pcTexCU->getMvField( pcTexCU, iTexAbsPartIdx, eCurrRefPicList, cTexMvField ); |
---|
3924 | Int iValidDepRef = getPic()->isTextRefValid( eCurrRefPicList, cTexMvField.getRefIdx() ); |
---|
3925 | if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) ) |
---|
3926 | { |
---|
3927 | TComMv cMv = cTexMvField.getMv() + cMvRounding; |
---|
3928 | cMv >>=2; |
---|
3929 | pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef); |
---|
3930 | } |
---|
3931 | } |
---|
3932 | } |
---|
3933 | puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0); |
---|
3934 | if (puhInterDirSP[iPartition] == 0) |
---|
3935 | { |
---|
3936 | if (iInterDirSaved != 0) |
---|
3937 | { |
---|
3938 | puhInterDirSP[iPartition] = iInterDirSaved; |
---|
3939 | pcMvFieldSP[2*iPartition] = cMvFieldSaved[0]; |
---|
3940 | pcMvFieldSP[2*iPartition + 1] = cMvFieldSaved[1]; |
---|
3941 | } |
---|
3942 | } |
---|
3943 | |
---|
3944 | iPartition ++; |
---|
3945 | } |
---|
3946 | } |
---|
3947 | #if H_3D |
---|
3948 | } |
---|
3949 | #endif |
---|
3950 | #if H_3D_FCO |
---|
3951 | } |
---|
3952 | #endif |
---|
3953 | if( tmpDir != 0 ) |
---|
3954 | { |
---|
3955 | Int iCnloop = 0; |
---|
3956 | for(iCnloop = 0; iCnloop < 2; iCnloop ++) |
---|
3957 | { |
---|
3958 | if ( !m_mergCands[MRG_A1+iCnloop].m_bAvailable ) // prunning to A1, B1 |
---|
3959 | { |
---|
3960 | continue; |
---|
3961 | } |
---|
3962 | 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]) |
---|
3963 | { |
---|
3964 | m_mergCands[MRG_A1+iCnloop].m_bAvailable = false; |
---|
3965 | break; |
---|
3966 | } |
---|
3967 | } |
---|
3968 | m_mergCands[MRG_T].setCand( tmpMV, tmpDir, false, bSPIVMPFlag); |
---|
3969 | |
---|
3970 | if ( mrgCandIdx == iCount ) |
---|
3971 | { |
---|
3972 | return; |
---|
3973 | } |
---|
3974 | iCount ++; |
---|
3975 | } |
---|
3976 | } |
---|
3977 | ///////////////////////////////////////////////////////////////// |
---|
3978 | //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC Candidates ///// |
---|
3979 | ///////////////////////////////////////////////////////////////// |
---|
3980 | |
---|
3981 | // { IvMCL0, IvMCL1, IvDCL0, IvDCL1, IvMCL0Shift, IvMCL1Shift, IvDCL0Shift, IvDCL1Shift }; |
---|
3982 | // An enumerator would be appropriate here! |
---|
3983 | TComMv ivCandMv [8]; |
---|
3984 | Int ivCandRefIdx[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; |
---|
3985 | |
---|
3986 | // { IvMC, IvDC, IvMCShift, IvDCShift }; |
---|
3987 | Int ivCandDir [4] = {0, 0, 0, 0}; |
---|
3988 | |
---|
3989 | Bool ivMvPredFlag = getSlice()->getIvMvPredFlag(); |
---|
3990 | |
---|
3991 | ivMvPredFlag &= (nPSW + nPSH > 12); |
---|
3992 | if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1) |
---|
3993 | { |
---|
3994 | getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag ); |
---|
3995 | } |
---|
3996 | |
---|
3997 | /////////////////////////////////////////////// |
---|
3998 | //////// INTER VIEW MOTION COMP(IvMC) ///////// |
---|
3999 | /////////////////////////////////////////////// |
---|
4000 | if( getSlice()->getIsDepth() ) |
---|
4001 | { |
---|
4002 | ivCandDir[1] = ivCandDir[2] = ivCandDir[3] = 0; |
---|
4003 | } |
---|
4004 | |
---|
4005 | if( ivCandDir[0] ) |
---|
4006 | { |
---|
4007 | tmpMV[0].setMvField( cZeroMv, NOT_VALID ); |
---|
4008 | tmpMV[1].setMvField( cZeroMv, NOT_VALID ); |
---|
4009 | |
---|
4010 | if( ( ivCandDir[0] & 1 ) == 1 ) |
---|
4011 | { |
---|
4012 | tmpMV[0].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] ); |
---|
4013 | } |
---|
4014 | if( ( ivCandDir[0] & 2 ) == 2 ) |
---|
4015 | { |
---|
4016 | tmpMV[1].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] ); |
---|
4017 | } |
---|
4018 | |
---|
4019 | Bool bRemoveSpa = false; //pruning |
---|
4020 | |
---|
4021 | if (!bIsDepth) |
---|
4022 | { |
---|
4023 | for(Int i = 0; i < 2; i ++) |
---|
4024 | { |
---|
4025 | if ( !m_mergCands[MRG_A1 + i].m_bAvailable ) // prunning to A1, B1 |
---|
4026 | { |
---|
4027 | continue; |
---|
4028 | } |
---|
4029 | 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]) |
---|
4030 | { |
---|
4031 | m_mergCands[MRG_A1+i].m_bAvailable = false; |
---|
4032 | break; |
---|
4033 | } |
---|
4034 | } |
---|
4035 | } |
---|
4036 | if (bIsDepth) |
---|
4037 | { |
---|
4038 | 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]) |
---|
4039 | { |
---|
4040 | bRemoveSpa = true; |
---|
4041 | } |
---|
4042 | } |
---|
4043 | if (!bRemoveSpa) |
---|
4044 | { |
---|
4045 | Bool spiMvpFlag = false; |
---|
4046 | if(!m_pcSlice->getIsDepth()) |
---|
4047 | { |
---|
4048 | spiMvpFlag = true; |
---|
4049 | } |
---|
4050 | #if H_3D_DBBP |
---|
4051 | spiMvpFlag &= !bDBBPFlag; |
---|
4052 | #endif |
---|
4053 | |
---|
4054 | m_mergCands[MRG_IVMC].setCand( tmpMV, ivCandDir[0], false, spiMvpFlag); |
---|
4055 | |
---|
4056 | if ( mrgCandIdx == iCount ) |
---|
4057 | { |
---|
4058 | return; |
---|
4059 | } |
---|
4060 | iCount ++; |
---|
4061 | } |
---|
4062 | } |
---|
4063 | |
---|
4064 | // early termination |
---|
4065 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4066 | { |
---|
4067 | return; |
---|
4068 | } |
---|
4069 | #endif |
---|
4070 | |
---|
4071 | #if H_3D |
---|
4072 | iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable; |
---|
4073 | #else |
---|
4074 | //left |
---|
4075 | UInt uiLeftPartIdx = 0; |
---|
4076 | TComDataCU* pcCULeft = 0; |
---|
4077 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
4078 | Bool isAvailableA1 = pcCULeft && |
---|
4079 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
4080 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
4081 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
---|
4082 | if ( isAvailableA1 ) |
---|
4083 | { |
---|
4084 | abCandIsInter[iCount] = true; |
---|
4085 | // get Inter Dir |
---|
4086 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
4087 | // get Mv from Left |
---|
4088 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4089 | if ( getSlice()->isInterB() ) |
---|
4090 | { |
---|
4091 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4092 | } |
---|
4093 | |
---|
4094 | if ( mrgCandIdx == iCount ) |
---|
4095 | { |
---|
4096 | return; |
---|
4097 | } |
---|
4098 | iCount ++; |
---|
4099 | } |
---|
4100 | |
---|
4101 | // early termination |
---|
4102 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4103 | { |
---|
4104 | return; |
---|
4105 | } |
---|
4106 | |
---|
4107 | // above |
---|
4108 | UInt uiAbovePartIdx = 0; |
---|
4109 | TComDataCU* pcCUAbove = 0; |
---|
4110 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
4111 | Bool isAvailableB1 = pcCUAbove && |
---|
4112 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
4113 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
4114 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
---|
4115 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
4116 | { |
---|
4117 | abCandIsInter[iCount] = true; |
---|
4118 | // get Inter Dir |
---|
4119 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
4120 | // get Mv from Left |
---|
4121 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4122 | if ( getSlice()->isInterB() ) |
---|
4123 | { |
---|
4124 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4125 | } |
---|
4126 | |
---|
4127 | if ( mrgCandIdx == iCount ) |
---|
4128 | { |
---|
4129 | return; |
---|
4130 | } |
---|
4131 | iCount ++; |
---|
4132 | } |
---|
4133 | // early termination |
---|
4134 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4135 | { |
---|
4136 | return; |
---|
4137 | } |
---|
4138 | |
---|
4139 | // above right |
---|
4140 | UInt uiAboveRightPartIdx = 0; |
---|
4141 | TComDataCU* pcCUAboveRight = 0; |
---|
4142 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
4143 | Bool isAvailableB0 = pcCUAboveRight && |
---|
4144 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
4145 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
---|
4146 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
4147 | { |
---|
4148 | abCandIsInter[iCount] = true; |
---|
4149 | // get Inter Dir |
---|
4150 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
4151 | // get Mv from Left |
---|
4152 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4153 | if ( getSlice()->isInterB() ) |
---|
4154 | { |
---|
4155 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4156 | } |
---|
4157 | |
---|
4158 | if ( mrgCandIdx == iCount ) |
---|
4159 | { |
---|
4160 | return; |
---|
4161 | } |
---|
4162 | iCount ++; |
---|
4163 | } |
---|
4164 | // early termination |
---|
4165 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4166 | { |
---|
4167 | return; |
---|
4168 | } |
---|
4169 | #endif |
---|
4170 | |
---|
4171 | |
---|
4172 | #if H_3D_VSP |
---|
4173 | ///////////////////////////////////////////////// |
---|
4174 | //////// VIEW SYNTHESIS PREDICTION (VSP) //////// |
---|
4175 | ///////////////////////////////////////////////// |
---|
4176 | if (iCount<getSlice()->getMaxNumMergeCand()) |
---|
4177 | { |
---|
4178 | if ( |
---|
4179 | (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) && |
---|
4180 | #if NH_3D_IC |
---|
4181 | !bICFlag && |
---|
4182 | #endif |
---|
4183 | #if H_3D_ARP |
---|
4184 | !bARPFlag && |
---|
4185 | #endif |
---|
4186 | #if H_3D |
---|
4187 | (nPSW + nPSH > 12) && |
---|
4188 | #endif |
---|
4189 | #if H_3D_DBBP |
---|
4190 | !bDBBPFlag && |
---|
4191 | #endif |
---|
4192 | xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) ) |
---|
4193 | { |
---|
4194 | return; |
---|
4195 | } |
---|
4196 | |
---|
4197 | // early termination |
---|
4198 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4199 | { |
---|
4200 | return; |
---|
4201 | } |
---|
4202 | #endif |
---|
4203 | #if H_3D_VSP |
---|
4204 | } |
---|
4205 | #endif |
---|
4206 | |
---|
4207 | #if H_3D |
---|
4208 | iCount += m_mergCands[MRG_B0].m_bAvailable; |
---|
4209 | #endif |
---|
4210 | |
---|
4211 | |
---|
4212 | #if H_3D_IV_MERGE |
---|
4213 | ///////////////////////////////////////////// |
---|
4214 | //////// INTER VIEW DISP COMP (IvDC) //////// |
---|
4215 | ///////////////////////////////////////////// |
---|
4216 | if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) |
---|
4217 | { |
---|
4218 | assert(iCount < getSlice()->getMaxNumMergeCand()); |
---|
4219 | |
---|
4220 | tmpMV[0].setMvField( cZeroMv, NOT_VALID ); |
---|
4221 | tmpMV[1].setMvField( cZeroMv, NOT_VALID ); |
---|
4222 | if( ( ivCandDir[1] & 1 ) == 1 ) |
---|
4223 | { |
---|
4224 | tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] ); |
---|
4225 | } |
---|
4226 | if( ( ivCandDir[1] & 2 ) == 2 ) |
---|
4227 | { |
---|
4228 | tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] ); |
---|
4229 | } |
---|
4230 | |
---|
4231 | Bool bRemoveSpa = false; //pruning to A1, B1 |
---|
4232 | for(Int i = 0; i < 2; i ++) |
---|
4233 | { |
---|
4234 | if ( !m_mergCands[MRG_A1+i].m_bAvailable ) |
---|
4235 | { |
---|
4236 | continue; |
---|
4237 | } |
---|
4238 | 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]) |
---|
4239 | { |
---|
4240 | bRemoveSpa = true; |
---|
4241 | break; |
---|
4242 | } |
---|
4243 | } |
---|
4244 | if(!bRemoveSpa) |
---|
4245 | { |
---|
4246 | #if H_3D_NBDV |
---|
4247 | tmpMV[0].getMv().setIDVFlag (false); |
---|
4248 | tmpMV[1].getMv().setIDVFlag (false); |
---|
4249 | #endif |
---|
4250 | m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false); |
---|
4251 | |
---|
4252 | if ( mrgCandIdx == iCount ) |
---|
4253 | return; |
---|
4254 | iCount ++; |
---|
4255 | |
---|
4256 | // early termination |
---|
4257 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4258 | { |
---|
4259 | return; |
---|
4260 | } |
---|
4261 | } |
---|
4262 | } |
---|
4263 | #endif // H_3D_IV_MERGE |
---|
4264 | |
---|
4265 | |
---|
4266 | #if H_3D |
---|
4267 | iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable; |
---|
4268 | #else |
---|
4269 | //left bottom |
---|
4270 | UInt uiLeftBottomPartIdx = 0; |
---|
4271 | TComDataCU* pcCULeftBottom = 0; |
---|
4272 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
4273 | Bool isAvailableA0 = pcCULeftBottom && |
---|
4274 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
4275 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
---|
4276 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
4277 | { |
---|
4278 | abCandIsInter[iCount] = true; |
---|
4279 | // get Inter Dir |
---|
4280 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
4281 | // get Mv from Left |
---|
4282 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4283 | if ( getSlice()->isInterB() ) |
---|
4284 | { |
---|
4285 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4286 | } |
---|
4287 | if ( mrgCandIdx == iCount ) |
---|
4288 | { |
---|
4289 | return; |
---|
4290 | } |
---|
4291 | iCount ++; |
---|
4292 | } |
---|
4293 | // early termination |
---|
4294 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4295 | { |
---|
4296 | return; |
---|
4297 | } |
---|
4298 | |
---|
4299 | // above left |
---|
4300 | if( iCount < 4 ) |
---|
4301 | { |
---|
4302 | UInt uiAboveLeftPartIdx = 0; |
---|
4303 | TComDataCU* pcCUAboveLeft = 0; |
---|
4304 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
4305 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
4306 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
4307 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
---|
4308 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
4309 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
4310 | { |
---|
4311 | abCandIsInter[iCount] = true; |
---|
4312 | // get Inter Dir |
---|
4313 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
4314 | // get Mv from Left |
---|
4315 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4316 | if ( getSlice()->isInterB() ) |
---|
4317 | { |
---|
4318 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4319 | } |
---|
4320 | if ( mrgCandIdx == iCount ) |
---|
4321 | { |
---|
4322 | return; |
---|
4323 | } |
---|
4324 | iCount ++; |
---|
4325 | } |
---|
4326 | } |
---|
4327 | // early termination |
---|
4328 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4329 | { |
---|
4330 | return; |
---|
4331 | } |
---|
4332 | #endif |
---|
4333 | |
---|
4334 | |
---|
4335 | #if H_3D_IV_MERGE |
---|
4336 | //////////////////////////////////////////////////// |
---|
4337 | //////// SHIFTED IV (IvMCShift + IvDCShift) //////// |
---|
4338 | //////////////////////////////////////////////////// |
---|
4339 | if( ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) |
---|
4340 | { |
---|
4341 | if(xAddIvMRGCand( mrgCandIdx, iCount, ivCandDir, ivCandMv, ivCandRefIdx ) ) |
---|
4342 | { |
---|
4343 | return; |
---|
4344 | } |
---|
4345 | //early termination |
---|
4346 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4347 | { |
---|
4348 | return; |
---|
4349 | } |
---|
4350 | } |
---|
4351 | #endif |
---|
4352 | #if !H_3D |
---|
4353 | if ( getSlice()->getEnableTMVPFlag()) |
---|
4354 | { |
---|
4355 | //>> MTK colocated-RightBottom |
---|
4356 | UInt uiPartIdxRB; |
---|
4357 | |
---|
4358 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
4359 | |
---|
4360 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
4361 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
4362 | |
---|
4363 | TComMv cColMv; |
---|
4364 | Int iRefIdx; |
---|
4365 | Int uiLCUIdx = -1; |
---|
4366 | |
---|
4367 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
4368 | { |
---|
4369 | } |
---|
4370 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
4371 | { |
---|
4372 | } |
---|
4373 | else |
---|
4374 | { |
---|
4375 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
4376 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
4377 | { |
---|
4378 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
4379 | uiLCUIdx = getAddr(); |
---|
4380 | } |
---|
4381 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
4382 | { |
---|
4383 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
4384 | } |
---|
4385 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
4386 | { |
---|
4387 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
4388 | uiLCUIdx = getAddr() + 1; |
---|
4389 | } |
---|
4390 | else //is the right bottom corner of LCU |
---|
4391 | { |
---|
4392 | uiAbsPartAddr = 0; |
---|
4393 | } |
---|
4394 | } |
---|
4395 | |
---|
4396 | |
---|
4397 | iRefIdx = 0; |
---|
4398 | Bool bExistMV = false; |
---|
4399 | UInt uiPartIdxCenter; |
---|
4400 | UInt uiCurLCUIdx = getAddr(); |
---|
4401 | Int dir = 0; |
---|
4402 | UInt uiArrayAddr = iCount; |
---|
4403 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
4404 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
4405 | if( bExistMV == false ) |
---|
4406 | { |
---|
4407 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4408 | } |
---|
4409 | if( bExistMV ) |
---|
4410 | { |
---|
4411 | dir |= 1; |
---|
4412 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
4413 | } |
---|
4414 | |
---|
4415 | if ( getSlice()->isInterB() ) |
---|
4416 | { |
---|
4417 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
4418 | if( bExistMV == false ) |
---|
4419 | { |
---|
4420 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4421 | } |
---|
4422 | if( bExistMV ) |
---|
4423 | { |
---|
4424 | dir |= 2; |
---|
4425 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
4426 | } |
---|
4427 | } |
---|
4428 | |
---|
4429 | if (dir != 0) |
---|
4430 | { |
---|
4431 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
4432 | abCandIsInter[uiArrayAddr] = true; |
---|
4433 | if ( mrgCandIdx == iCount ) |
---|
4434 | { |
---|
4435 | return; |
---|
4436 | } |
---|
4437 | iCount++; |
---|
4438 | } |
---|
4439 | } |
---|
4440 | // early termination |
---|
4441 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4442 | { |
---|
4443 | return; |
---|
4444 | } |
---|
4445 | UInt uiArrayAddr = iCount; |
---|
4446 | UInt uiCutoff = uiArrayAddr; |
---|
4447 | |
---|
4448 | if ( getSlice()->isInterB()) |
---|
4449 | { |
---|
4450 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
4451 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
4452 | |
---|
4453 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
4454 | { |
---|
4455 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
4456 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
4457 | { |
---|
4458 | abCandIsInter[uiArrayAddr] = true; |
---|
4459 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4460 | |
---|
4461 | // get Mv from cand[i] and cand[j] |
---|
4462 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
4463 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
4464 | |
---|
4465 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
4466 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
4467 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
4468 | { |
---|
4469 | abCandIsInter[uiArrayAddr] = false; |
---|
4470 | } |
---|
4471 | else |
---|
4472 | { |
---|
4473 | uiArrayAddr++; |
---|
4474 | } |
---|
4475 | } |
---|
4476 | } |
---|
4477 | } |
---|
4478 | // early termination |
---|
4479 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
4480 | { |
---|
4481 | return; |
---|
4482 | } |
---|
4483 | 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); |
---|
4484 | Int r = 0; |
---|
4485 | Int refcnt = 0; |
---|
4486 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
4487 | { |
---|
4488 | abCandIsInter[uiArrayAddr] = true; |
---|
4489 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
4490 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
4491 | |
---|
4492 | if ( getSlice()->isInterB() ) |
---|
4493 | { |
---|
4494 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4495 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
4496 | } |
---|
4497 | uiArrayAddr++; |
---|
4498 | if ( refcnt == iNumRefIdx - 1 ) |
---|
4499 | { |
---|
4500 | r = 0; |
---|
4501 | } |
---|
4502 | else |
---|
4503 | { |
---|
4504 | ++r; |
---|
4505 | ++refcnt; |
---|
4506 | } |
---|
4507 | } |
---|
4508 | |
---|
4509 | numValidMergeCand = uiArrayAddr; |
---|
4510 | #endif |
---|
4511 | } |
---|
4512 | #else |
---|
4513 | |
---|
4514 | //! Construct a list of merging candidates |
---|
4515 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) |
---|
4516 | { |
---|
4517 | UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx; |
---|
4518 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
4519 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
4520 | { |
---|
4521 | abCandIsInter[ui] = false; |
---|
4522 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
4523 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
4524 | } |
---|
4525 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
4526 | // compute the location of the current PU |
---|
4527 | Int xP, yP, nPSW, nPSH; |
---|
4528 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
4529 | |
---|
4530 | Int iCount = 0; |
---|
4531 | |
---|
4532 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
4533 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
4534 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
4535 | deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
4536 | |
---|
4537 | //left |
---|
4538 | UInt uiLeftPartIdx = 0; |
---|
4539 | TComDataCU* pcCULeft = 0; |
---|
4540 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
4541 | |
---|
4542 | Bool isAvailableA1 = pcCULeft && |
---|
4543 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
4544 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
4545 | pcCULeft->isInter( uiLeftPartIdx ) ; |
---|
4546 | |
---|
4547 | if ( isAvailableA1 ) |
---|
4548 | { |
---|
4549 | abCandIsInter[iCount] = true; |
---|
4550 | // get Inter Dir |
---|
4551 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
4552 | // get Mv from Left |
---|
4553 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4554 | if ( getSlice()->isInterB() ) |
---|
4555 | { |
---|
4556 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4557 | } |
---|
4558 | if ( mrgCandIdx == iCount ) |
---|
4559 | { |
---|
4560 | return; |
---|
4561 | } |
---|
4562 | iCount ++; |
---|
4563 | } |
---|
4564 | |
---|
4565 | // early termination |
---|
4566 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4567 | { |
---|
4568 | return; |
---|
4569 | } |
---|
4570 | // above |
---|
4571 | UInt uiAbovePartIdx = 0; |
---|
4572 | TComDataCU* pcCUAbove = 0; |
---|
4573 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
4574 | |
---|
4575 | Bool isAvailableB1 = pcCUAbove && |
---|
4576 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
4577 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
4578 | pcCUAbove->isInter( uiAbovePartIdx ); |
---|
4579 | |
---|
4580 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
4581 | { |
---|
4582 | abCandIsInter[iCount] = true; |
---|
4583 | // get Inter Dir |
---|
4584 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
4585 | // get Mv from Left |
---|
4586 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4587 | if ( getSlice()->isInterB() ) |
---|
4588 | { |
---|
4589 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4590 | } |
---|
4591 | if ( mrgCandIdx == iCount ) |
---|
4592 | { |
---|
4593 | return; |
---|
4594 | } |
---|
4595 | iCount ++; |
---|
4596 | } |
---|
4597 | // early termination |
---|
4598 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4599 | { |
---|
4600 | return; |
---|
4601 | } |
---|
4602 | |
---|
4603 | // above right |
---|
4604 | UInt uiAboveRightPartIdx = 0; |
---|
4605 | TComDataCU* pcCUAboveRight = 0; |
---|
4606 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
4607 | |
---|
4608 | Bool isAvailableB0 = pcCUAboveRight && |
---|
4609 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
4610 | pcCUAboveRight->isInter( uiAboveRightPartIdx ); |
---|
4611 | |
---|
4612 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
4613 | { |
---|
4614 | abCandIsInter[iCount] = true; |
---|
4615 | // get Inter Dir |
---|
4616 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
4617 | // get Mv from Left |
---|
4618 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4619 | if ( getSlice()->isInterB() ) |
---|
4620 | { |
---|
4621 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4622 | } |
---|
4623 | if ( mrgCandIdx == iCount ) |
---|
4624 | { |
---|
4625 | return; |
---|
4626 | } |
---|
4627 | iCount ++; |
---|
4628 | } |
---|
4629 | // early termination |
---|
4630 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4631 | { |
---|
4632 | return; |
---|
4633 | } |
---|
4634 | |
---|
4635 | //left bottom |
---|
4636 | UInt uiLeftBottomPartIdx = 0; |
---|
4637 | TComDataCU* pcCULeftBottom = 0; |
---|
4638 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
4639 | |
---|
4640 | Bool isAvailableA0 = pcCULeftBottom && |
---|
4641 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
4642 | pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ; |
---|
4643 | |
---|
4644 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
4645 | { |
---|
4646 | abCandIsInter[iCount] = true; |
---|
4647 | // get Inter Dir |
---|
4648 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
4649 | // get Mv from Left |
---|
4650 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4651 | if ( getSlice()->isInterB() ) |
---|
4652 | { |
---|
4653 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4654 | } |
---|
4655 | if ( mrgCandIdx == iCount ) |
---|
4656 | { |
---|
4657 | return; |
---|
4658 | } |
---|
4659 | iCount ++; |
---|
4660 | } |
---|
4661 | // early termination |
---|
4662 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4663 | { |
---|
4664 | return; |
---|
4665 | } |
---|
4666 | |
---|
4667 | // above left |
---|
4668 | if( iCount < 4 ) |
---|
4669 | { |
---|
4670 | UInt uiAboveLeftPartIdx = 0; |
---|
4671 | TComDataCU* pcCUAboveLeft = 0; |
---|
4672 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
4673 | |
---|
4674 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
4675 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
4676 | pcCUAboveLeft->isInter( uiAboveLeftPartIdx ); |
---|
4677 | |
---|
4678 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
4679 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
4680 | { |
---|
4681 | abCandIsInter[iCount] = true; |
---|
4682 | // get Inter Dir |
---|
4683 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
4684 | // get Mv from Left |
---|
4685 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4686 | if ( getSlice()->isInterB() ) |
---|
4687 | { |
---|
4688 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4689 | } |
---|
4690 | if ( mrgCandIdx == iCount ) |
---|
4691 | { |
---|
4692 | return; |
---|
4693 | } |
---|
4694 | iCount ++; |
---|
4695 | } |
---|
4696 | } |
---|
4697 | // early termination |
---|
4698 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4699 | { |
---|
4700 | return; |
---|
4701 | } |
---|
4702 | |
---|
4703 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
4704 | { |
---|
4705 | //>> MTK colocated-RightBottom |
---|
4706 | UInt uiPartIdxRB; |
---|
4707 | |
---|
4708 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
4709 | |
---|
4710 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
4711 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
4712 | const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); |
---|
4713 | |
---|
4714 | TComMv cColMv; |
---|
4715 | Int iRefIdx; |
---|
4716 | Int ctuRsAddr = -1; |
---|
4717 | |
---|
4718 | if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check |
---|
4719 | && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
4720 | { |
---|
4721 | if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU |
---|
4722 | ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU |
---|
4723 | { |
---|
4724 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ]; |
---|
4725 | ctuRsAddr = getCtuRsAddr(); |
---|
4726 | } |
---|
4727 | else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU |
---|
4728 | { |
---|
4729 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; |
---|
4730 | } |
---|
4731 | else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU |
---|
4732 | { |
---|
4733 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
4734 | ctuRsAddr = getCtuRsAddr() + 1; |
---|
4735 | } |
---|
4736 | else //is the right bottom corner of CTU |
---|
4737 | { |
---|
4738 | uiAbsPartAddr = 0; |
---|
4739 | } |
---|
4740 | } |
---|
4741 | |
---|
4742 | iRefIdx = 0; |
---|
4743 | |
---|
4744 | Bool bExistMV = false; |
---|
4745 | UInt uiPartIdxCenter; |
---|
4746 | Int dir = 0; |
---|
4747 | UInt uiArrayAddr = iCount; |
---|
4748 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
4749 | bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
4750 | if( bExistMV == false ) |
---|
4751 | { |
---|
4752 | bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4753 | } |
---|
4754 | if( bExistMV ) |
---|
4755 | { |
---|
4756 | dir |= 1; |
---|
4757 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
4758 | } |
---|
4759 | |
---|
4760 | if ( getSlice()->isInterB() ) |
---|
4761 | { |
---|
4762 | #if NH_3D_TMVP |
---|
4763 | iRefIdx =0; |
---|
4764 | #endif |
---|
4765 | bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx); |
---|
4766 | if( bExistMV == false ) |
---|
4767 | { |
---|
4768 | bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4769 | } |
---|
4770 | if( bExistMV ) |
---|
4771 | { |
---|
4772 | dir |= 2; |
---|
4773 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
4774 | } |
---|
4775 | } |
---|
4776 | |
---|
4777 | if (dir != 0) |
---|
4778 | { |
---|
4779 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
4780 | abCandIsInter[uiArrayAddr] = true; |
---|
4781 | |
---|
4782 | if ( mrgCandIdx == iCount ) |
---|
4783 | { |
---|
4784 | return; |
---|
4785 | } |
---|
4786 | iCount++; |
---|
4787 | } |
---|
4788 | } |
---|
4789 | // early termination |
---|
4790 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4791 | { |
---|
4792 | return; |
---|
4793 | } |
---|
4794 | |
---|
4795 | UInt uiArrayAddr = iCount; |
---|
4796 | UInt uiCutoff = uiArrayAddr; |
---|
4797 | |
---|
4798 | if ( getSlice()->isInterB() ) |
---|
4799 | { |
---|
4800 | static const UInt NUM_PRIORITY_LIST=12; |
---|
4801 | static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
4802 | static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
4803 | |
---|
4804 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
4805 | { |
---|
4806 | assert(idx<NUM_PRIORITY_LIST); |
---|
4807 | Int i = uiPriorityList0[idx]; |
---|
4808 | Int j = uiPriorityList1[idx]; |
---|
4809 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
4810 | { |
---|
4811 | abCandIsInter[uiArrayAddr] = true; |
---|
4812 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4813 | |
---|
4814 | // get Mv from cand[i] and cand[j] |
---|
4815 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
4816 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
4817 | |
---|
4818 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
4819 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
4820 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
4821 | { |
---|
4822 | abCandIsInter[uiArrayAddr] = false; |
---|
4823 | } |
---|
4824 | else |
---|
4825 | { |
---|
4826 | uiArrayAddr++; |
---|
4827 | } |
---|
4828 | } |
---|
4829 | } |
---|
4830 | } |
---|
4831 | // early termination |
---|
4832 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
4833 | { |
---|
4834 | return; |
---|
4835 | } |
---|
4836 | |
---|
4837 | 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); |
---|
4838 | |
---|
4839 | Int r = 0; |
---|
4840 | Int refcnt = 0; |
---|
4841 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
4842 | { |
---|
4843 | abCandIsInter[uiArrayAddr] = true; |
---|
4844 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
4845 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
4846 | |
---|
4847 | if ( getSlice()->isInterB() ) |
---|
4848 | { |
---|
4849 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4850 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
4851 | } |
---|
4852 | uiArrayAddr++; |
---|
4853 | |
---|
4854 | if ( refcnt == iNumRefIdx - 1 ) |
---|
4855 | { |
---|
4856 | r = 0; |
---|
4857 | } |
---|
4858 | else |
---|
4859 | { |
---|
4860 | ++r; |
---|
4861 | ++refcnt; |
---|
4862 | } |
---|
4863 | } |
---|
4864 | numValidMergeCand = uiArrayAddr; |
---|
4865 | } |
---|
4866 | #endif |
---|
4867 | |
---|
4868 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
---|
4869 | * \param xN, yN location of the upper-left corner pixel of a neighboring PU |
---|
4870 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
4871 | */ |
---|
4872 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) |
---|
4873 | { |
---|
4874 | |
---|
4875 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
---|
4876 | if ((xN>>plevel)!= (xP>>plevel)) |
---|
4877 | { |
---|
4878 | return true; |
---|
4879 | } |
---|
4880 | if ((yN>>plevel)!= (yP>>plevel)) |
---|
4881 | { |
---|
4882 | return true; |
---|
4883 | } |
---|
4884 | return false; |
---|
4885 | } |
---|
4886 | |
---|
4887 | /** Calculate the location of upper-left corner pixel and size of the current PU. |
---|
4888 | * \param partIdx PU index within a CU |
---|
4889 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
4890 | * \param nPSW, nPSH size of the current PU |
---|
4891 | */ |
---|
4892 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) |
---|
4893 | { |
---|
4894 | UInt col = m_uiCUPelX; |
---|
4895 | UInt row = m_uiCUPelY; |
---|
4896 | |
---|
4897 | switch ( m_pePartSize[0] ) |
---|
4898 | { |
---|
4899 | case SIZE_2NxN: |
---|
4900 | nPSW = getWidth(0); |
---|
4901 | nPSH = getHeight(0) >> 1; |
---|
4902 | xP = col; |
---|
4903 | yP = (partIdx ==0)? row: row + nPSH; |
---|
4904 | break; |
---|
4905 | case SIZE_Nx2N: |
---|
4906 | nPSW = getWidth(0) >> 1; |
---|
4907 | nPSH = getHeight(0); |
---|
4908 | xP = (partIdx ==0)? col: col + nPSW; |
---|
4909 | yP = row; |
---|
4910 | break; |
---|
4911 | case SIZE_NxN: |
---|
4912 | nPSW = getWidth(0) >> 1; |
---|
4913 | nPSH = getHeight(0) >> 1; |
---|
4914 | xP = col + (partIdx&0x1)*nPSW; |
---|
4915 | yP = row + (partIdx>>1)*nPSH; |
---|
4916 | break; |
---|
4917 | case SIZE_2NxnU: |
---|
4918 | nPSW = getWidth(0); |
---|
4919 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
4920 | xP = col; |
---|
4921 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
4922 | |
---|
4923 | break; |
---|
4924 | case SIZE_2NxnD: |
---|
4925 | nPSW = getWidth(0); |
---|
4926 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
4927 | xP = col; |
---|
4928 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
4929 | break; |
---|
4930 | case SIZE_nLx2N: |
---|
4931 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
4932 | nPSH = getHeight(0); |
---|
4933 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
4934 | yP = row; |
---|
4935 | break; |
---|
4936 | case SIZE_nRx2N: |
---|
4937 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
4938 | nPSH = getHeight(0); |
---|
4939 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
4940 | yP = row; |
---|
4941 | break; |
---|
4942 | default: |
---|
4943 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
4944 | nPSW = getWidth(0); |
---|
4945 | nPSH = getHeight(0); |
---|
4946 | xP = col ; |
---|
4947 | yP = row ; |
---|
4948 | |
---|
4949 | break; |
---|
4950 | } |
---|
4951 | } |
---|
4952 | |
---|
4953 | /** Constructs a list of candidates for AMVP |
---|
4954 | * \param uiPartIdx |
---|
4955 | * \param uiPartAddr |
---|
4956 | * \param eRefPicList |
---|
4957 | * \param iRefIdx |
---|
4958 | * \param pInfo |
---|
4959 | */ |
---|
4960 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
---|
4961 | { |
---|
4962 | TComMv cMvPred; |
---|
4963 | Bool bAddedSmvp = false; |
---|
4964 | |
---|
4965 | pInfo->iN = 0; |
---|
4966 | if (iRefIdx < 0) |
---|
4967 | { |
---|
4968 | return; |
---|
4969 | } |
---|
4970 | |
---|
4971 | //-- Get Spatial MV |
---|
4972 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
4973 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
4974 | const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); |
---|
4975 | Bool bAdded = false; |
---|
4976 | |
---|
4977 | deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
4978 | deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB ); |
---|
4979 | |
---|
4980 | TComDataCU* tmpCU = NULL; |
---|
4981 | UInt idx; |
---|
4982 | tmpCU = getPUBelowLeft(idx, uiPartIdxLB); |
---|
4983 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx)); |
---|
4984 | |
---|
4985 | if (!bAddedSmvp) |
---|
4986 | { |
---|
4987 | tmpCU = getPULeft(idx, uiPartIdxLB); |
---|
4988 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx)); |
---|
4989 | } |
---|
4990 | |
---|
4991 | // Left predictor search |
---|
4992 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
4993 | if (!bAdded) |
---|
4994 | { |
---|
4995 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
4996 | } |
---|
4997 | |
---|
4998 | if(!bAdded) |
---|
4999 | { |
---|
5000 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
5001 | if (!bAdded) |
---|
5002 | { |
---|
5003 | xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
5004 | } |
---|
5005 | } |
---|
5006 | |
---|
5007 | // Above predictor search |
---|
5008 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
5009 | |
---|
5010 | if (!bAdded) |
---|
5011 | { |
---|
5012 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
5013 | } |
---|
5014 | |
---|
5015 | if(!bAdded) |
---|
5016 | { |
---|
5017 | xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
5018 | } |
---|
5019 | |
---|
5020 | if(!bAddedSmvp) |
---|
5021 | { |
---|
5022 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
5023 | if (!bAdded) |
---|
5024 | { |
---|
5025 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
5026 | } |
---|
5027 | |
---|
5028 | if(!bAdded) |
---|
5029 | { |
---|
5030 | xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
5031 | } |
---|
5032 | } |
---|
5033 | |
---|
5034 | if ( pInfo->iN == 2 ) |
---|
5035 | { |
---|
5036 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
---|
5037 | { |
---|
5038 | pInfo->iN = 1; |
---|
5039 | } |
---|
5040 | } |
---|
5041 | |
---|
5042 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
5043 | { |
---|
5044 | // Get Temporal Motion Predictor |
---|
5045 | Int iRefIdx_Col = iRefIdx; |
---|
5046 | TComMv cColMv; |
---|
5047 | UInt uiPartIdxRB; |
---|
5048 | UInt uiAbsPartIdx; |
---|
5049 | UInt uiAbsPartAddr; |
---|
5050 | |
---|
5051 | deriveRightBottomIdx( uiPartIdx, uiPartIdxRB ); |
---|
5052 | uiAbsPartAddr = m_absZIdxInCtu + uiPartAddr; |
---|
5053 | |
---|
5054 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
5055 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
---|
5056 | Int ctuRsAddr = -1; |
---|
5057 | if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check |
---|
5058 | && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
5059 | { |
---|
5060 | if ( ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU |
---|
5061 | ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU |
---|
5062 | { |
---|
5063 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth + 1 ]; |
---|
5064 | ctuRsAddr = getCtuRsAddr(); |
---|
5065 | } |
---|
5066 | else if ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU |
---|
5067 | { |
---|
5068 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; |
---|
5069 | } |
---|
5070 | else if ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU |
---|
5071 | { |
---|
5072 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
---|
5073 | ctuRsAddr = getCtuRsAddr() + 1; |
---|
5074 | } |
---|
5075 | else //is the right bottom corner of CTU |
---|
5076 | { |
---|
5077 | uiAbsPartAddr = 0; |
---|
5078 | } |
---|
5079 | } |
---|
5080 | if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx_Col |
---|
5081 | #if NH_3D_TMVP |
---|
5082 | , 0 |
---|
5083 | #endif |
---|
5084 | ) ) |
---|
5085 | { |
---|
5086 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
5087 | } |
---|
5088 | else |
---|
5089 | { |
---|
5090 | UInt uiPartIdxCenter; |
---|
5091 | xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); |
---|
5092 | if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx_Col |
---|
5093 | #if NH_3D_TMVP |
---|
5094 | , 0 |
---|
5095 | #endif |
---|
5096 | )) |
---|
5097 | { |
---|
5098 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
5099 | } |
---|
5100 | } |
---|
5101 | //---- co-located RightBottom Temporal Predictor ---// |
---|
5102 | } |
---|
5103 | |
---|
5104 | if (pInfo->iN > AMVP_MAX_NUM_CANDS) |
---|
5105 | { |
---|
5106 | pInfo->iN = AMVP_MAX_NUM_CANDS; |
---|
5107 | } |
---|
5108 | |
---|
5109 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
---|
5110 | { |
---|
5111 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
---|
5112 | pInfo->iN++; |
---|
5113 | } |
---|
5114 | return ; |
---|
5115 | } |
---|
5116 | |
---|
5117 | |
---|
5118 | Bool TComDataCU::isBipredRestriction(UInt puIdx) |
---|
5119 | { |
---|
5120 | Int width = 0; |
---|
5121 | Int height = 0; |
---|
5122 | UInt partAddr; |
---|
5123 | |
---|
5124 | #if H_3D_DBBP |
---|
5125 | if( getDBBPFlag(0) ) |
---|
5126 | { |
---|
5127 | return true; |
---|
5128 | } |
---|
5129 | #endif |
---|
5130 | |
---|
5131 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
---|
5132 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
---|
5133 | { |
---|
5134 | return true; |
---|
5135 | } |
---|
5136 | return false; |
---|
5137 | } |
---|
5138 | |
---|
5139 | |
---|
5140 | Void TComDataCU::clipMv (TComMv& rcMv) |
---|
5141 | { |
---|
5142 | const TComSPS &sps=*(m_pcSlice->getSPS()); |
---|
5143 | Int iMvShift = 2; |
---|
5144 | #if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
5145 | if( getSlice()->getIsDepth() ) |
---|
5146 | iMvShift = 0; |
---|
5147 | #endif |
---|
5148 | |
---|
5149 | Int iOffset = 8; |
---|
5150 | Int iHorMax = ( sps.getPicWidthInLumaSamples() + iOffset - (Int)m_uiCUPelX - 1 ) << iMvShift; |
---|
5151 | Int iHorMin = ( -(Int)sps.getMaxCUWidth() - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
---|
5152 | |
---|
5153 | Int iVerMax = ( sps.getPicHeightInLumaSamples() + iOffset - (Int)m_uiCUPelY - 1 ) << iMvShift; |
---|
5154 | Int iVerMin = ( -(Int)sps.getMaxCUHeight() - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
---|
5155 | |
---|
5156 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
---|
5157 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
---|
5158 | } |
---|
5159 | |
---|
5160 | #if NH_MV |
---|
5161 | Void TComDataCU::checkMvVertRest (TComMv& rcMv, RefPicList eRefPicList, int iRefIdx ) |
---|
5162 | { |
---|
5163 | if ( getSlice()->getSPS()->getInterViewMvVertConstraintFlag() ) |
---|
5164 | { |
---|
5165 | if ( getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC() == getSlice()->getPOC() ) |
---|
5166 | { |
---|
5167 | //When inter_view_mv_vert_constraint_flag is equal to 1, |
---|
5168 | //the vertical component of the motion vectors used for inter-layer prediction |
---|
5169 | //shall be equal to or less than 56 in units of luma samples |
---|
5170 | assert ( rcMv.getVer() <= (56<<2) ); |
---|
5171 | } |
---|
5172 | } |
---|
5173 | } |
---|
5174 | #endif |
---|
5175 | |
---|
5176 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
---|
5177 | { |
---|
5178 | UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
5179 | |
---|
5180 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
5181 | UInt uiCnt = 0; |
---|
5182 | while( uiWidth ) |
---|
5183 | { |
---|
5184 | uiCnt++; |
---|
5185 | uiWidth>>=1; |
---|
5186 | } |
---|
5187 | uiCnt-=2; |
---|
5188 | return uiCnt > 6 ? 6 : uiCnt; |
---|
5189 | } |
---|
5190 | |
---|
5191 | Void TComDataCU::clearCbf( UInt uiIdx, ComponentID compID, UInt uiNumParts ) |
---|
5192 | { |
---|
5193 | memset( &m_puhCbf[compID][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
5194 | } |
---|
5195 | |
---|
5196 | /** Set a I_PCM flag for all sub-partitions of a partition. |
---|
5197 | * \param bIpcmFlag I_PCM flag |
---|
5198 | * \param uiAbsPartIdx patition index |
---|
5199 | * \param uiDepth CU depth |
---|
5200 | * \returns Void |
---|
5201 | */ |
---|
5202 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
---|
5203 | { |
---|
5204 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
5205 | |
---|
5206 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
---|
5207 | } |
---|
5208 | |
---|
5209 | /** Test whether the block at uiPartIdx is skipped. |
---|
5210 | * \param uiPartIdx Partition index |
---|
5211 | * \returns true if the current the block is skipped |
---|
5212 | */ |
---|
5213 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
---|
5214 | { |
---|
5215 | return ( getSkipFlag( uiPartIdx ) ); |
---|
5216 | } |
---|
5217 | |
---|
5218 | // ==================================================================================================================== |
---|
5219 | // Protected member functions |
---|
5220 | // ==================================================================================================================== |
---|
5221 | |
---|
5222 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
5223 | { |
---|
5224 | TComDataCU* pcTmpCU = NULL; |
---|
5225 | UInt uiIdx; |
---|
5226 | switch( eDir ) |
---|
5227 | { |
---|
5228 | case MD_LEFT: |
---|
5229 | { |
---|
5230 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
5231 | break; |
---|
5232 | } |
---|
5233 | case MD_ABOVE: |
---|
5234 | { |
---|
5235 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
5236 | break; |
---|
5237 | } |
---|
5238 | case MD_ABOVE_RIGHT: |
---|
5239 | { |
---|
5240 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
5241 | break; |
---|
5242 | } |
---|
5243 | case MD_BELOW_LEFT: |
---|
5244 | { |
---|
5245 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
5246 | break; |
---|
5247 | } |
---|
5248 | case MD_ABOVE_LEFT: |
---|
5249 | { |
---|
5250 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
5251 | break; |
---|
5252 | } |
---|
5253 | default: |
---|
5254 | { |
---|
5255 | break; |
---|
5256 | } |
---|
5257 | } |
---|
5258 | |
---|
5259 | if ( pcTmpCU == NULL ) |
---|
5260 | { |
---|
5261 | return false; |
---|
5262 | } |
---|
5263 | |
---|
5264 | if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )) |
---|
5265 | { |
---|
5266 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
5267 | |
---|
5268 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
5269 | return true; |
---|
5270 | } |
---|
5271 | |
---|
5272 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
5273 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
5274 | { |
---|
5275 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
5276 | } |
---|
5277 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
5278 | { |
---|
5279 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
5280 | } |
---|
5281 | |
---|
5282 | |
---|
5283 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
5284 | Int iNeibRefPOC; |
---|
5285 | |
---|
5286 | |
---|
5287 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
---|
5288 | { |
---|
5289 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
5290 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
---|
5291 | { |
---|
5292 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
5293 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
5294 | return true; |
---|
5295 | } |
---|
5296 | } |
---|
5297 | return false; |
---|
5298 | } |
---|
5299 | |
---|
5300 | /** |
---|
5301 | * \param pInfo |
---|
5302 | * \param eRefPicList |
---|
5303 | * \param iRefIdx |
---|
5304 | * \param uiPartUnitIdx |
---|
5305 | * \param eDir |
---|
5306 | * \returns Bool |
---|
5307 | */ |
---|
5308 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
5309 | { |
---|
5310 | TComDataCU* pcTmpCU = NULL; |
---|
5311 | UInt uiIdx; |
---|
5312 | switch( eDir ) |
---|
5313 | { |
---|
5314 | case MD_LEFT: |
---|
5315 | { |
---|
5316 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
5317 | break; |
---|
5318 | } |
---|
5319 | case MD_ABOVE: |
---|
5320 | { |
---|
5321 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
5322 | break; |
---|
5323 | } |
---|
5324 | case MD_ABOVE_RIGHT: |
---|
5325 | { |
---|
5326 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
5327 | break; |
---|
5328 | } |
---|
5329 | case MD_BELOW_LEFT: |
---|
5330 | { |
---|
5331 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
5332 | break; |
---|
5333 | } |
---|
5334 | case MD_ABOVE_LEFT: |
---|
5335 | { |
---|
5336 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
5337 | break; |
---|
5338 | } |
---|
5339 | default: |
---|
5340 | { |
---|
5341 | break; |
---|
5342 | } |
---|
5343 | } |
---|
5344 | |
---|
5345 | if ( pcTmpCU == NULL ) |
---|
5346 | { |
---|
5347 | return false; |
---|
5348 | } |
---|
5349 | |
---|
5350 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
5351 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
5352 | { |
---|
5353 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
5354 | } |
---|
5355 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
5356 | { |
---|
5357 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
5358 | } |
---|
5359 | |
---|
5360 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
5361 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
5362 | Int iNeibPOC = iCurrPOC; |
---|
5363 | Int iNeibRefPOC; |
---|
5364 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
5365 | Bool bIsNeibRefLongTerm = false; |
---|
5366 | |
---|
5367 | //--------------- V1 (END) ------------------// |
---|
5368 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
---|
5369 | { |
---|
5370 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
---|
5371 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
5372 | TComMv rcMv; |
---|
5373 | |
---|
5374 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
5375 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
5376 | { |
---|
5377 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
5378 | { |
---|
5379 | rcMv = cMvPred; |
---|
5380 | } |
---|
5381 | else |
---|
5382 | { |
---|
5383 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
5384 | if ( iScale == 4096 ) |
---|
5385 | { |
---|
5386 | rcMv = cMvPred; |
---|
5387 | } |
---|
5388 | else |
---|
5389 | { |
---|
5390 | rcMv = cMvPred.scaleMv( iScale ); |
---|
5391 | } |
---|
5392 | } |
---|
5393 | |
---|
5394 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
5395 | return true; |
---|
5396 | } |
---|
5397 | } |
---|
5398 | //---------------------- V2(END) --------------------// |
---|
5399 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
---|
5400 | { |
---|
5401 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
5402 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
5403 | TComMv rcMv; |
---|
5404 | |
---|
5405 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
5406 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
5407 | { |
---|
5408 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
5409 | { |
---|
5410 | rcMv = cMvPred; |
---|
5411 | } |
---|
5412 | else |
---|
5413 | { |
---|
5414 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
5415 | if ( iScale == 4096 ) |
---|
5416 | { |
---|
5417 | rcMv = cMvPred; |
---|
5418 | } |
---|
5419 | else |
---|
5420 | { |
---|
5421 | rcMv = cMvPred.scaleMv( iScale ); |
---|
5422 | } |
---|
5423 | } |
---|
5424 | |
---|
5425 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
5426 | return true; |
---|
5427 | } |
---|
5428 | } |
---|
5429 | //---------------------- V3(END) --------------------// |
---|
5430 | return false; |
---|
5431 | } |
---|
5432 | |
---|
5433 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int ctuRsAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx |
---|
5434 | #if NH_3D_TMVP |
---|
5435 | , Bool bMRG |
---|
5436 | #endif |
---|
5437 | ) |
---|
5438 | { |
---|
5439 | UInt uiAbsPartAddr = uiPartUnitIdx; |
---|
5440 | |
---|
5441 | RefPicList eColRefPicList; |
---|
5442 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
---|
5443 | TComMv cColMv; |
---|
5444 | |
---|
5445 | // use coldir. |
---|
5446 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
5447 | TComDataCU *pColCtu = pColPic->getCtu( ctuRsAddr ); |
---|
5448 | if(pColCtu->getPic()==0||pColCtu->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES) |
---|
5449 | { |
---|
5450 | return false; |
---|
5451 | } |
---|
5452 | iCurrPOC = m_pcSlice->getPOC(); |
---|
5453 | iColPOC = pColCtu->getSlice()->getPOC(); |
---|
5454 | |
---|
5455 | if (!pColCtu->isInter(uiAbsPartAddr)) |
---|
5456 | { |
---|
5457 | return false; |
---|
5458 | } |
---|
5459 | |
---|
5460 | eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
---|
5461 | |
---|
5462 | Int iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
5463 | |
---|
5464 | if (iColRefIdx < 0 ) |
---|
5465 | { |
---|
5466 | eColRefPicList = RefPicList(1 - eColRefPicList); |
---|
5467 | iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
5468 | |
---|
5469 | if (iColRefIdx < 0 ) |
---|
5470 | { |
---|
5471 | return false; |
---|
5472 | } |
---|
5473 | } |
---|
5474 | |
---|
5475 | // Scale the vector. |
---|
5476 | iColRefPOC = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
---|
5477 | cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
5478 | |
---|
5479 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
5480 | |
---|
5481 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
---|
5482 | Bool bIsColRefLongTerm = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); |
---|
5483 | |
---|
5484 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
5485 | { |
---|
5486 | #if NH_3D_TMVP |
---|
5487 | Int iAlterRefIdx = m_pcSlice->getAlterRefIdx(eRefPicList); |
---|
5488 | if(bMRG && iAlterRefIdx > 0) |
---|
5489 | { |
---|
5490 | riRefIdx = iAlterRefIdx; |
---|
5491 | bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
---|
5492 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
5493 | assert(bIsCurrRefLongTerm == bIsColRefLongTerm); |
---|
5494 | } |
---|
5495 | else |
---|
5496 | { |
---|
5497 | #endif |
---|
5498 | return false; |
---|
5499 | #if NH_3D_TMVP |
---|
5500 | } |
---|
5501 | #endif |
---|
5502 | } |
---|
5503 | |
---|
5504 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
---|
5505 | { |
---|
5506 | #if NH_3D_TMVP |
---|
5507 | Int iCurrViewId = m_pcSlice->getViewId (); |
---|
5508 | Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewId (); |
---|
5509 | Int iColViewId = pColCtu->getSlice()->getViewId(); |
---|
5510 | Int iColRefViewId = pColCtu->getSlice()->getRefPic( eColRefPicList, pColCtu->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewId(); |
---|
5511 | iScale = 4096; |
---|
5512 | if ( iCurrRefViewId != iCurrViewId && iColViewId != iColRefViewId ) |
---|
5513 | { |
---|
5514 | iScale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId ); |
---|
5515 | } |
---|
5516 | if ( bMRG && iScale != 4096 && m_pcSlice->getIvMvScalingFlag( ) ) |
---|
5517 | { |
---|
5518 | rcMv = cColMv.scaleMv( iScale ); |
---|
5519 | } |
---|
5520 | else |
---|
5521 | { |
---|
5522 | #endif |
---|
5523 | rcMv = cColMv; |
---|
5524 | #if NH_3D_TMVP |
---|
5525 | } |
---|
5526 | #endif |
---|
5527 | } |
---|
5528 | else |
---|
5529 | { |
---|
5530 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
5531 | if ( iScale == 4096 ) |
---|
5532 | { |
---|
5533 | rcMv = cColMv; |
---|
5534 | } |
---|
5535 | else |
---|
5536 | { |
---|
5537 | rcMv = cColMv.scaleMv( iScale ); |
---|
5538 | } |
---|
5539 | } |
---|
5540 | |
---|
5541 | return true; |
---|
5542 | } |
---|
5543 | |
---|
5544 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
5545 | { |
---|
5546 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
5547 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
5548 | |
---|
5549 | if( iDiffPocD == iDiffPocB ) |
---|
5550 | { |
---|
5551 | return 4096; |
---|
5552 | } |
---|
5553 | else |
---|
5554 | { |
---|
5555 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
5556 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
5557 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
5558 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
---|
5559 | return iScale; |
---|
5560 | } |
---|
5561 | } |
---|
5562 | |
---|
5563 | Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
---|
5564 | { |
---|
5565 | UInt uiPartAddr; |
---|
5566 | Int iPartWidth; |
---|
5567 | Int iPartHeight; |
---|
5568 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
5569 | |
---|
5570 | ruiPartIdxCenter = m_absZIdxInCtu+uiPartAddr; // partition origin. |
---|
5571 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
5572 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInCtuWidth() |
---|
5573 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
---|
5574 | } |
---|
5575 | |
---|
5576 | #if NH_3D |
---|
5577 | Void TComDataCU::compressMV(Int scale) |
---|
5578 | { |
---|
5579 | Int scaleFactor = (4 / scale ) * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
5580 | #else |
---|
5581 | Void TComDataCU::compressMV() |
---|
5582 | { |
---|
5583 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
5584 | #endif |
---|
5585 | if (scaleFactor > 0) |
---|
5586 | { |
---|
5587 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
5588 | { |
---|
5589 | m_acCUMvField[i].compress(m_pePredMode, scaleFactor); |
---|
5590 | } |
---|
5591 | } |
---|
5592 | } |
---|
5593 | |
---|
5594 | UInt TComDataCU::getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const |
---|
5595 | { |
---|
5596 | //------------------------------------------------ |
---|
5597 | |
---|
5598 | //this mechanism is available for intra only |
---|
5599 | |
---|
5600 | if (!isIntra(uiAbsPartIdx)) |
---|
5601 | { |
---|
5602 | return SCAN_DIAG; |
---|
5603 | } |
---|
5604 | |
---|
5605 | //------------------------------------------------ |
---|
5606 | |
---|
5607 | //check that MDCS can be used for this TU |
---|
5608 | |
---|
5609 | const ChromaFormat format = getPic()->getChromaFormat(); |
---|
5610 | |
---|
5611 | const UInt maximumWidth = MDCS_MAXIMUM_WIDTH >> getComponentScaleX(compID, format); |
---|
5612 | const UInt maximumHeight = MDCS_MAXIMUM_HEIGHT >> getComponentScaleY(compID, format); |
---|
5613 | |
---|
5614 | if ((uiWidth > maximumWidth) || (uiHeight > maximumHeight)) |
---|
5615 | { |
---|
5616 | return SCAN_DIAG; |
---|
5617 | } |
---|
5618 | |
---|
5619 | //------------------------------------------------ |
---|
5620 | |
---|
5621 | //otherwise, select the appropriate mode |
---|
5622 | |
---|
5623 | UInt uiDirMode = getIntraDir(toChannelType(compID), uiAbsPartIdx); |
---|
5624 | |
---|
5625 | #if H_3D_DIM |
---|
5626 | mapDepthModeToIntraDir( uiDirMode ); |
---|
5627 | #endif |
---|
5628 | |
---|
5629 | if (uiDirMode==DM_CHROMA_IDX) |
---|
5630 | { |
---|
5631 | const TComSPS *sps=getSlice()->getSPS(); |
---|
5632 | const UInt partsPerMinCU = 1<<(2*(sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize())); |
---|
5633 | uiDirMode = getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, getPic()->getChromaFormat(), partsPerMinCU)); |
---|
5634 | #if H_3D_DIM |
---|
5635 | mapDepthModeToIntraDir( uiDirMode ); |
---|
5636 | #endif |
---|
5637 | } |
---|
5638 | |
---|
5639 | if (isChroma(compID) && (format == CHROMA_422)) |
---|
5640 | { |
---|
5641 | uiDirMode = g_chroma422IntraAngleMappingTable[uiDirMode]; |
---|
5642 | } |
---|
5643 | |
---|
5644 | //------------------ |
---|
5645 | |
---|
5646 | if (abs((Int)uiDirMode - VER_IDX) <= MDCS_ANGLE_LIMIT) |
---|
5647 | { |
---|
5648 | return SCAN_HOR; |
---|
5649 | } |
---|
5650 | else if (abs((Int)uiDirMode - HOR_IDX) <= MDCS_ANGLE_LIMIT) |
---|
5651 | { |
---|
5652 | return SCAN_VER; |
---|
5653 | } |
---|
5654 | else |
---|
5655 | { |
---|
5656 | return SCAN_DIAG; |
---|
5657 | } |
---|
5658 | } |
---|
5659 | |
---|
5660 | #if NH_3D_VSO |
---|
5661 | Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) const |
---|
5662 | { |
---|
5663 | riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX(); |
---|
5664 | riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY(); |
---|
5665 | } |
---|
5666 | #endif |
---|
5667 | |
---|
5668 | #if H_3D_IV_MERGE |
---|
5669 | Void TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp) |
---|
5670 | { |
---|
5671 | assert(getPartitionSize( uiPartAddr ) == SIZE_2Nx2N); |
---|
5672 | |
---|
5673 | TComMv cMv; |
---|
5674 | if ( getSlice()->getDefaultRefViewIdxAvailableFlag() ) |
---|
5675 | { |
---|
5676 | Int iViewIdx = getSlice()->getDefaultRefViewIdx(); |
---|
5677 | pDisp->m_aVIdxCan = iViewIdx; |
---|
5678 | Int iDisp = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepthY() - 1 )) ]; |
---|
5679 | |
---|
5680 | cMv.setHor(iDisp); |
---|
5681 | cMv.setVer(0); |
---|
5682 | pDisp->m_acNBDV = cMv; |
---|
5683 | pDisp->m_aVIdxCan = iViewIdx; |
---|
5684 | } |
---|
5685 | } |
---|
5686 | #endif |
---|
5687 | |
---|
5688 | #if H_3D |
---|
5689 | Bool TComDataCU::getNeighDepth ( UInt uiPartIdx, UInt uiPartAddr, Pel* pNeighDepth, Int index ) |
---|
5690 | { |
---|
5691 | UInt uiPartIdxLT, uiPartIdxRT; |
---|
5692 | this->deriveLeftRightTopIdxAdi( uiPartIdxLT, uiPartIdxRT, 0, 0 ); |
---|
5693 | UInt uiMidPart, uiPartNeighbor; |
---|
5694 | TComDataCU* pcCUNeighbor; |
---|
5695 | Bool bDepAvail = false; |
---|
5696 | Pel *pDepth = this->getPic()->getPicYuvRec()->getLumaAddr(); |
---|
5697 | Int iDepStride = this->getPic()->getPicYuvRec()->getStride(); |
---|
5698 | |
---|
5699 | Int xP, yP, nPSW, nPSH; |
---|
5700 | this->getPartPosition( uiPartIdx, xP, yP, nPSW, nPSH ); |
---|
5701 | |
---|
5702 | switch( index ) |
---|
5703 | { |
---|
5704 | case 0: // Mid Left |
---|
5705 | uiMidPart = g_auiZscanToRaster[uiPartIdxLT] + (nPSH>>1) / this->getPic()->getMinCUHeight() * this->getPic()->getNumPartInWidth(); |
---|
5706 | pcCUNeighbor = this->getPULeft( uiPartNeighbor, g_auiRasterToZscan[uiMidPart] ); |
---|
5707 | if ( pcCUNeighbor ) |
---|
5708 | { |
---|
5709 | if( !this->getSlice()->getPPS()->getConstrainedIntraPred() ) |
---|
5710 | { |
---|
5711 | *pNeighDepth = pDepth[ (yP+(nPSH>>1)) * iDepStride + (xP-1) ]; |
---|
5712 | bDepAvail = true; |
---|
5713 | } |
---|
5714 | else if ( pcCUNeighbor->getPredictionMode( uiPartNeighbor ) == MODE_INTRA ) |
---|
5715 | { |
---|
5716 | *pNeighDepth = pDepth[ (yP+(nPSH>>1)) * iDepStride + (xP-1) ]; |
---|
5717 | bDepAvail = true; |
---|
5718 | } |
---|
5719 | } |
---|
5720 | break; |
---|
5721 | case 1: // Mid Above |
---|
5722 | uiMidPart = g_auiZscanToRaster[uiPartIdxLT] + (nPSW>>1) / this->getPic()->getMinCUWidth(); |
---|
5723 | pcCUNeighbor = this->getPUAbove( uiPartNeighbor, g_auiRasterToZscan[uiMidPart] ); |
---|
5724 | if( pcCUNeighbor ) |
---|
5725 | { |
---|
5726 | if( !this->getSlice()->getPPS()->getConstrainedIntraPred() ) |
---|
5727 | { |
---|
5728 | *pNeighDepth = pDepth[ (yP-1) * iDepStride + (xP + (nPSW>>1)) ]; |
---|
5729 | bDepAvail = true; |
---|
5730 | } |
---|
5731 | else if ( pcCUNeighbor->getPredictionMode( uiPartNeighbor ) == MODE_INTRA ) |
---|
5732 | { |
---|
5733 | *pNeighDepth = pDepth[ (yP-1) * iDepStride + (xP + (nPSW>>1)) ]; |
---|
5734 | bDepAvail = true; |
---|
5735 | } |
---|
5736 | } |
---|
5737 | break; |
---|
5738 | default: |
---|
5739 | break; |
---|
5740 | } |
---|
5741 | |
---|
5742 | return bDepAvail; |
---|
5743 | } |
---|
5744 | #endif |
---|
5745 | #if H_3D_NBDV |
---|
5746 | //Notes from QC: |
---|
5747 | //TBD#1: DoNBDV related contributions are just partially integrated under the marco of H_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done |
---|
5748 | //TBD#2: set of DvMCP values need to be done as part of inter-view motion prediction process. Remove this comment once merge related integration is done |
---|
5749 | //To be checked: Parallel Merge features for NBDV, related to DV_DERIVATION_PARALLEL_B0096 and LGE_IVMP_PARALLEL_MERGE_B0136 are not integrated. The need of these features due to the adoption of CU-based NBDV is not clear. We need confirmation on this, especially by proponents |
---|
5750 | Void TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo |
---|
5751 | #if H_3D_NBDV_REF |
---|
5752 | , Bool bDepthRefine |
---|
5753 | #endif |
---|
5754 | ) |
---|
5755 | { |
---|
5756 | //// ******* Init variables ******* ///// |
---|
5757 | // Init disparity struct for results |
---|
5758 | pDInfo->m_aVIdxCan = -1; |
---|
5759 | |
---|
5760 | // Init struct for disparities from MCP neighboring blocks |
---|
5761 | IDVInfo cIDVInfo; |
---|
5762 | cIDVInfo.m_bFound = false; |
---|
5763 | UInt uiPartIdx = 0; |
---|
5764 | UInt uiPartAddr = 0; |
---|
5765 | for (UInt iCurDvMcpCand = 0; iCurDvMcpCand < IDV_CANDS; iCurDvMcpCand++) |
---|
5766 | { |
---|
5767 | for (UInt iList = 0; iList < 2; iList++) |
---|
5768 | { |
---|
5769 | cIDVInfo.m_acMvCand[iList][iCurDvMcpCand].setZero(); |
---|
5770 | cIDVInfo.m_aVIdxCan[iList][iCurDvMcpCand] = 0; |
---|
5771 | cIDVInfo.m_bAvailab[iList][iCurDvMcpCand] = false; |
---|
5772 | } |
---|
5773 | } |
---|
5774 | #if H_3D_NBDV_REF |
---|
5775 | if( !m_pcSlice->getDepthRefinementFlag( ) ) |
---|
5776 | { |
---|
5777 | bDepthRefine = false; |
---|
5778 | } |
---|
5779 | #endif |
---|
5780 | // Get Positions |
---|
5781 | PartSize eCUMode = getPartitionSize( uiPartAddr ); |
---|
5782 | assert(eCUMode == SIZE_2Nx2N); |
---|
5783 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
5784 | |
---|
5785 | deriveLeftRightTopIdxGeneral(uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
5786 | deriveLeftBottomIdxGeneral (uiPartAddr, uiPartIdx, uiPartIdxLB ); |
---|
5787 | |
---|
5788 | //// ******* Get disparity from temporal neighboring blocks ******* ///// |
---|
5789 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
5790 | { |
---|
5791 | TComMv cColMv; |
---|
5792 | Int iTargetViewIdx = 0; |
---|
5793 | Int iTStartViewIdx = 0; |
---|
5794 | |
---|
5795 | ///*** Derive center position *** |
---|
5796 | UInt uiPartIdxCenter; |
---|
5797 | Int uiLCUIdx = getAddr(); |
---|
5798 | xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter ); |
---|
5799 | |
---|
5800 | ///*** Search temporal candidate pictures for disparity vector *** |
---|
5801 | const Int iNumCandPics = getPic()->getNumDdvCandPics(); |
---|
5802 | for(Int curCandPic = 0; curCandPic < iNumCandPics; curCandPic++) |
---|
5803 | { |
---|
5804 | RefPicList eCurRefPicList = REF_PIC_LIST_0 ; |
---|
5805 | Int curCandPicRefIdx = 0; |
---|
5806 | if( curCandPic == 0 ) |
---|
5807 | { |
---|
5808 | eCurRefPicList = RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0); |
---|
5809 | curCandPicRefIdx = getSlice()->getColRefIdx(); |
---|
5810 | } |
---|
5811 | else |
---|
5812 | { |
---|
5813 | eCurRefPicList = getPic()->getRapRefList(); |
---|
5814 | curCandPicRefIdx = getPic()->getRapRefIdx(); |
---|
5815 | } |
---|
5816 | |
---|
5817 | Bool bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, uiLCUIdx, uiPartIdxCenter, cColMv, iTargetViewIdx, iTStartViewIdx ); |
---|
5818 | |
---|
5819 | if( bCheck ) |
---|
5820 | { |
---|
5821 | pDInfo->m_acNBDV = cColMv; |
---|
5822 | pDInfo->m_aVIdxCan = iTargetViewIdx; |
---|
5823 | |
---|
5824 | #if H_3D_NBDV_REF |
---|
5825 | TComPic* picDepth = NULL; |
---|
5826 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
5827 | picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); |
---|
5828 | if ( picDepth->getPicYuvRec() != NULL ) |
---|
5829 | { |
---|
5830 | cColMv.setZero(); |
---|
5831 | } |
---|
5832 | else // Go back with virtual depth |
---|
5833 | { |
---|
5834 | picDepth = getSlice()->getIvPic( true, iTargetViewIdx ); |
---|
5835 | } |
---|
5836 | |
---|
5837 | assert(picDepth != NULL); |
---|
5838 | #else |
---|
5839 | picDepth = getSlice()->getIvPic( true, iTargetViewIdx ); |
---|
5840 | #endif |
---|
5841 | if (picDepth && bDepthRefine) |
---|
5842 | { |
---|
5843 | estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv ); |
---|
5844 | } |
---|
5845 | pDInfo->m_acDoNBDV = cColMv; |
---|
5846 | #endif //H_3D_NBDV_REF |
---|
5847 | return; |
---|
5848 | } |
---|
5849 | } |
---|
5850 | } |
---|
5851 | |
---|
5852 | UInt uiIdx = 0; |
---|
5853 | Bool bCheckMcpDv = false; |
---|
5854 | TComDataCU* pcTmpCU = NULL; |
---|
5855 | |
---|
5856 | //// ******* Get disparity from left block ******* ///// |
---|
5857 | pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false); |
---|
5858 | bCheckMcpDv = true; |
---|
5859 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT |
---|
5860 | #if H_3D_NBDV_REF |
---|
5861 | , bDepthRefine |
---|
5862 | #endif |
---|
5863 | ) ) |
---|
5864 | return; |
---|
5865 | |
---|
5866 | //// ******* Get disparity from above block ******* ///// |
---|
5867 | pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true); |
---|
5868 | if(pcTmpCU != NULL ) |
---|
5869 | { |
---|
5870 | bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0); |
---|
5871 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE |
---|
5872 | #if H_3D_NBDV_REF |
---|
5873 | , bDepthRefine |
---|
5874 | #endif |
---|
5875 | ) ) |
---|
5876 | return; |
---|
5877 | } |
---|
5878 | |
---|
5879 | //// ******* Search MCP blocks ******* ///// |
---|
5880 | if( cIDVInfo.m_bFound ) |
---|
5881 | { |
---|
5882 | for( Int curPos = 0 ; curPos < IDV_CANDS ; curPos++ ) |
---|
5883 | { |
---|
5884 | for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) |
---|
5885 | { |
---|
5886 | if( cIDVInfo.m_bAvailab[iList][curPos] ) |
---|
5887 | { |
---|
5888 | TComMv cDispVec = cIDVInfo.m_acMvCand[iList][ curPos ]; |
---|
5889 | pDInfo->m_acNBDV = cDispVec; |
---|
5890 | pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ]; |
---|
5891 | #if H_3D_NBDV_REF |
---|
5892 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
5893 | TComPic* picDepth = NULL; |
---|
5894 | |
---|
5895 | picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); |
---|
5896 | if ( picDepth->getPicYuvRec() != NULL ) |
---|
5897 | { |
---|
5898 | cDispVec.setZero(); |
---|
5899 | } |
---|
5900 | else // Go back with virtual depth |
---|
5901 | { |
---|
5902 | picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan ); |
---|
5903 | } |
---|
5904 | |
---|
5905 | assert(picDepth != NULL); |
---|
5906 | #else |
---|
5907 | TComPic* picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan ); |
---|
5908 | #endif |
---|
5909 | |
---|
5910 | if (picDepth && bDepthRefine) |
---|
5911 | { |
---|
5912 | estimateDVFromDM (pDInfo->m_aVIdxCan, uiPartIdx, picDepth, uiPartAddr, &cDispVec); |
---|
5913 | } |
---|
5914 | pDInfo->m_acDoNBDV = cDispVec; |
---|
5915 | #endif |
---|
5916 | return; |
---|
5917 | } |
---|
5918 | } |
---|
5919 | } |
---|
5920 | } |
---|
5921 | |
---|
5922 | TComMv defaultDV(0, 0); |
---|
5923 | pDInfo->m_acNBDV = defaultDV; |
---|
5924 | |
---|
5925 | if (getSlice()->getDefaultRefViewIdxAvailableFlag()) |
---|
5926 | { |
---|
5927 | pDInfo->m_aVIdxCan = getSlice()->getDefaultRefViewIdx(); |
---|
5928 | |
---|
5929 | #if H_3D_NBDV_REF |
---|
5930 | TComPic* picDepth = NULL; |
---|
5931 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
5932 | picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); |
---|
5933 | if ( picDepth->getPicYuvRec() != NULL ) |
---|
5934 | { |
---|
5935 | defaultDV.setZero(); |
---|
5936 | } |
---|
5937 | else // Go back with virtual depth |
---|
5938 | { |
---|
5939 | picDepth = getSlice()->getIvPic( true, getSlice()->getDefaultRefViewIdx()); |
---|
5940 | } |
---|
5941 | |
---|
5942 | assert(picDepth != NULL); |
---|
5943 | #else |
---|
5944 | picDepth = getSlice()->getIvPic( true, getSlice()->getDefaultRefViewIdx()); |
---|
5945 | #endif |
---|
5946 | if (picDepth && bDepthRefine) |
---|
5947 | { |
---|
5948 | estimateDVFromDM(getSlice()->getDefaultRefViewIdx(), uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view |
---|
5949 | } |
---|
5950 | pDInfo->m_acDoNBDV = defaultDV; |
---|
5951 | #endif |
---|
5952 | } |
---|
5953 | } |
---|
5954 | |
---|
5955 | #if H_3D_NBDV_REF |
---|
5956 | Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT ) |
---|
5957 | { |
---|
5958 | Int iPictureWidth = pcBaseViewDepthPicYuv->getWidth(); |
---|
5959 | Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(); |
---|
5960 | |
---|
5961 | Int depthStartPosX = Clip3(0, iPictureWidth - 1, iBlkX + ((mv->getHor()+2)>>2)); |
---|
5962 | Int depthStartPosY = Clip3(0, iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2)); |
---|
5963 | Int depthEndPosX = Clip3(0, iPictureWidth - 1, iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2)); |
---|
5964 | Int depthEndPosY = Clip3(0, iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2)); |
---|
5965 | |
---|
5966 | Pel* depthTL = pcBaseViewDepthPicYuv->getLumaAddr(); |
---|
5967 | Int depStride = pcBaseViewDepthPicYuv->getStride(); |
---|
5968 | |
---|
5969 | Pel maxDepthVal = 0; |
---|
5970 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthStartPosX ]); // Left Top |
---|
5971 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthStartPosX ]); // Left Bottom |
---|
5972 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthEndPosX ]); // Right Top |
---|
5973 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthEndPosX ]); // Right Bottom |
---|
5974 | |
---|
5975 | return aiShiftLUT[ maxDepthVal ]; |
---|
5976 | } |
---|
5977 | |
---|
5978 | Void TComDataCU::estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred ) |
---|
5979 | { |
---|
5980 | if (picDepth) |
---|
5981 | { |
---|
5982 | UInt uiAbsPartAddrCurrCU = m_uiAbsIdxInLCU + uiPartAddr; |
---|
5983 | Int iWidth, iHeight; |
---|
5984 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more |
---|
5985 | |
---|
5986 | TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec(); |
---|
5987 | Int iBlkX = ( getAddr() % picDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; |
---|
5988 | Int iBlkY = ( getAddr() / picDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; |
---|
5989 | |
---|
5990 | Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx ); |
---|
5991 | |
---|
5992 | Pel iDisp = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT ); |
---|
5993 | cMvPred->setHor( iDisp ); |
---|
5994 | } |
---|
5995 | } |
---|
5996 | #endif //H_3D_NBDV_REF |
---|
5997 | |
---|
5998 | |
---|
5999 | Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos |
---|
6000 | #if H_3D_NBDV_REF |
---|
6001 | , Bool bDepthRefine |
---|
6002 | #endif |
---|
6003 | ) |
---|
6004 | { |
---|
6005 | if( pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) ) |
---|
6006 | { |
---|
6007 | Bool bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx ); |
---|
6008 | for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) |
---|
6009 | { |
---|
6010 | RefPicList eRefPicList = RefPicList(iList); |
---|
6011 | Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ; |
---|
6012 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
6013 | |
---|
6014 | if( refId >= 0) |
---|
6015 | { |
---|
6016 | Int refViewIdx = pcTmpCU->getSlice()->getRefPic(eRefPicList, refId)->getViewIndex(); |
---|
6017 | if (refViewIdx != m_pcSlice->getViewIndex()) |
---|
6018 | { |
---|
6019 | pNbDvInfo->m_acNBDV = cMvPred; |
---|
6020 | pNbDvInfo->m_aVIdxCan = refViewIdx; |
---|
6021 | #if H_3D_NBDV_REF |
---|
6022 | TComPic* picDepth = NULL; |
---|
6023 | assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC()); |
---|
6024 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
6025 | picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); |
---|
6026 | if ( picDepth->getPicYuvRec() != NULL ) |
---|
6027 | { |
---|
6028 | cMvPred.setZero(); |
---|
6029 | } |
---|
6030 | else// Go back with virtual depth |
---|
6031 | { |
---|
6032 | picDepth = getSlice()->getIvPic (true, refViewIdx ); |
---|
6033 | } |
---|
6034 | assert(picDepth != NULL); |
---|
6035 | #else |
---|
6036 | picDepth = getSlice()->getIvPic (true, refViewIdx ); |
---|
6037 | #endif |
---|
6038 | UInt uiPartIdx = 0; //Notes from MTK: Please confirm that using 0 as partition index and partition address is correct for CU-level DoNBDV |
---|
6039 | UInt uiPartAddr = 0; //QC: confirmed |
---|
6040 | |
---|
6041 | if (picDepth && bDepthRefine) |
---|
6042 | { |
---|
6043 | estimateDVFromDM(refViewIdx, uiPartIdx, picDepth, uiPartAddr, &cMvPred ); |
---|
6044 | } |
---|
6045 | pNbDvInfo->m_acDoNBDV = cMvPred; |
---|
6046 | #endif |
---|
6047 | return true; |
---|
6048 | } |
---|
6049 | else if ( bSearchForMvpDv && cMvPred.getIDVFlag() && bTmpIsSkipped ) |
---|
6050 | { |
---|
6051 | assert( uiMvpDvPos < IDV_CANDS ); |
---|
6052 | paIDVInfo->m_acMvCand[iList][ uiMvpDvPos ] = TComMv( cMvPred.getIDVHor(), cMvPred.getIDVVer() ); |
---|
6053 | //Notes from QC: DvMCP is implemented in a way that doesnot carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design. |
---|
6054 | paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = cMvPred.getIDVVId(); |
---|
6055 | paIDVInfo->m_bAvailab[iList][ uiMvpDvPos ] = true; |
---|
6056 | paIDVInfo->m_bFound = true; |
---|
6057 | } |
---|
6058 | } |
---|
6059 | } |
---|
6060 | } |
---|
6061 | return false; |
---|
6062 | } |
---|
6063 | |
---|
6064 | Void TComDataCU::xDeriveRightBottomNbIdx(Int &riLCUIdxRBNb, Int &riPartIdxRBNb ) |
---|
6065 | { |
---|
6066 | UInt uiPartIdx = 0; |
---|
6067 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
6068 | Int uiLCUIdx = getAddr(); |
---|
6069 | |
---|
6070 | UInt uiPartIdxRB; |
---|
6071 | deriveRightBottomIdx(uiPartIdx, uiPartIdxRB ); |
---|
6072 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
6073 | |
---|
6074 | if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
6075 | { |
---|
6076 | riLCUIdxRBNb = -1; |
---|
6077 | riPartIdxRBNb = -1; |
---|
6078 | } |
---|
6079 | else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
6080 | { |
---|
6081 | riLCUIdxRBNb = -1; |
---|
6082 | riPartIdxRBNb = -1; |
---|
6083 | } |
---|
6084 | else |
---|
6085 | { |
---|
6086 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
6087 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
6088 | { |
---|
6089 | riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
6090 | riLCUIdxRBNb = uiLCUIdx; |
---|
6091 | } |
---|
6092 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
6093 | { |
---|
6094 | riPartIdxRBNb = -1; |
---|
6095 | riLCUIdxRBNb = -1; |
---|
6096 | } |
---|
6097 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
6098 | { |
---|
6099 | riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
6100 | riLCUIdxRBNb = uiLCUIdx + 1; |
---|
6101 | } |
---|
6102 | else //is the right bottom corner of LCU |
---|
6103 | { |
---|
6104 | riPartIdxRBNb = -1; |
---|
6105 | riLCUIdxRBNb = -1; |
---|
6106 | } |
---|
6107 | } |
---|
6108 | } |
---|
6109 | |
---|
6110 | |
---|
6111 | Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
6112 | { |
---|
6113 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
6114 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
6115 | { |
---|
6116 | m_pDvInfo[uiAbsPartIdx + ui] = cDvInfo; |
---|
6117 | } |
---|
6118 | } |
---|
6119 | #if H_3D_VSP |
---|
6120 | Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth ) |
---|
6121 | { |
---|
6122 | setSubPartT<DisInfo>( cDvInfo, m_pDvInfo, uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
6123 | } |
---|
6124 | #endif |
---|
6125 | |
---|
6126 | Bool TComDataCU::xGetColDisMV( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx ) |
---|
6127 | { |
---|
6128 | |
---|
6129 | RefPicList eColRefPicList = REF_PIC_LIST_0; |
---|
6130 | Int iColViewIdx, iColRefViewIdx; |
---|
6131 | TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx); |
---|
6132 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
6133 | iColViewIdx = pColCU->getSlice()->getViewIndex(); |
---|
6134 | if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiPartUnitIdx)) |
---|
6135 | { |
---|
6136 | return false; |
---|
6137 | } |
---|
6138 | for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++) |
---|
6139 | { |
---|
6140 | if(pColCU->getSlice()->isInterB()) |
---|
6141 | { |
---|
6142 | eColRefPicList = RefPicList(ilist); |
---|
6143 | } |
---|
6144 | |
---|
6145 | Int iColRefIdx = pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartUnitIdx); |
---|
6146 | |
---|
6147 | if (iColRefIdx < 0) |
---|
6148 | { |
---|
6149 | continue; |
---|
6150 | } |
---|
6151 | |
---|
6152 | iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewIndex(); |
---|
6153 | |
---|
6154 | if ( iColViewIdx == iColRefViewIdx ) // temporal vector |
---|
6155 | { |
---|
6156 | continue; |
---|
6157 | } |
---|
6158 | else |
---|
6159 | { |
---|
6160 | if(getPic()->isTempIVRefValid(currCandPic, ilist, iColRefIdx)) |
---|
6161 | { |
---|
6162 | rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartUnitIdx); |
---|
6163 | rcMv.setIDVFlag(0); |
---|
6164 | iTargetViewIdx = iColRefViewIdx ; |
---|
6165 | iStartViewIdx = iColViewIdx ; |
---|
6166 | return true; |
---|
6167 | } |
---|
6168 | } |
---|
6169 | } |
---|
6170 | |
---|
6171 | return false; |
---|
6172 | } |
---|
6173 | #endif |
---|
6174 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
6175 | Void |
---|
6176 | TComDataCU::getIVNStatus ( UInt uiPartIdx, DisInfo* pDInfo, Bool& bIVFMerge, Int& iIVFMaxD) |
---|
6177 | { |
---|
6178 | TComSlice* pcSlice = getSlice (); |
---|
6179 | Int iViewIndex = pDInfo->m_aVIdxCan; |
---|
6180 | //--- get base CU/PU and check prediction mode --- |
---|
6181 | TComPic* pcBasePic = pcSlice->getIvPic( false, iViewIndex ); |
---|
6182 | TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); |
---|
6183 | |
---|
6184 | UInt uiPartAddr; |
---|
6185 | Int iWidth; |
---|
6186 | Int iHeight; |
---|
6187 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
6188 | |
---|
6189 | Int iCurrPosX, iCurrPosY; |
---|
6190 | pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
6191 | |
---|
6192 | iCurrPosX += ( ( iWidth - 1 ) >> 1 ); |
---|
6193 | iCurrPosY += ( ( iHeight - 1 ) >> 1 ); |
---|
6194 | |
---|
6195 | Bool depthRefineFlag = false; |
---|
6196 | #if H_3D_NBDV_REF |
---|
6197 | depthRefineFlag = m_pcSlice->getDepthRefinementFlag( ); |
---|
6198 | #endif // H_3D_NBDV_REF |
---|
6199 | |
---|
6200 | TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
---|
6201 | if( depthRefineFlag ) |
---|
6202 | { |
---|
6203 | cDv.setVer(0); |
---|
6204 | } |
---|
6205 | |
---|
6206 | Int iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6207 | Int iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6208 | Int iBaseLPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX - (iWidth >> 1) + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6209 | Int iBaseLPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6210 | Int iBaseRPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + (iWidth >> 1) + 1 + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6211 | Int iBaseRPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6212 | Int iBaseUPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6213 | Int iBaseUPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY - (iHeight >> 1) + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6214 | Int iBaseDPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6215 | Int iBaseDPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + (iHeight >> 1) + 1 + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6216 | |
---|
6217 | Int iBaseCUAddr; |
---|
6218 | Int iBaseAbsPartIdx; |
---|
6219 | Int iBaseLCUAddr; |
---|
6220 | Int iBaseLAbsPartIdx; |
---|
6221 | Int iBaseRCUAddr; |
---|
6222 | Int iBaseRAbsPartIdx; |
---|
6223 | Int iBaseUCUAddr; |
---|
6224 | Int iBaseUAbsPartIdx; |
---|
6225 | Int iBaseDCUAddr; |
---|
6226 | Int iBaseDAbsPartIdx; |
---|
6227 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); |
---|
6228 | pcBaseRec->getCUAddrAndPartIdx( iBaseLPosX , iBaseLPosY , iBaseLCUAddr, iBaseLAbsPartIdx ); |
---|
6229 | pcBaseRec->getCUAddrAndPartIdx( iBaseRPosX , iBaseRPosY , iBaseRCUAddr, iBaseRAbsPartIdx ); |
---|
6230 | pcBaseRec->getCUAddrAndPartIdx( iBaseUPosX , iBaseUPosY , iBaseUCUAddr, iBaseUAbsPartIdx ); |
---|
6231 | pcBaseRec->getCUAddrAndPartIdx( iBaseDPosX , iBaseDPosY , iBaseDCUAddr, iBaseDAbsPartIdx ); |
---|
6232 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
---|
6233 | TComDataCU* pcBaseLCU = pcBasePic->getCU( iBaseLCUAddr ); |
---|
6234 | TComDataCU* pcBaseRCU = pcBasePic->getCU( iBaseRCUAddr ); |
---|
6235 | TComDataCU* pcBaseUCU = pcBasePic->getCU( iBaseUCUAddr ); |
---|
6236 | TComDataCU* pcBaseDCU = pcBasePic->getCU( iBaseDCUAddr ); |
---|
6237 | bIVFMerge = pcBaseLCU->getMergeFlag( iBaseLAbsPartIdx ) && pcBaseCU->getMergeFlag( iBaseAbsPartIdx ) && pcBaseRCU->getMergeFlag( iBaseRAbsPartIdx ) && pcBaseUCU->getMergeFlag( iBaseUAbsPartIdx ) && pcBaseDCU->getMergeFlag( iBaseDAbsPartIdx ); |
---|
6238 | Int aiDepthL[5]; //depth level |
---|
6239 | aiDepthL[0] = pcBaseCU->getDepth(iBaseAbsPartIdx); |
---|
6240 | aiDepthL[1] = pcBaseLCU->getDepth(iBaseLAbsPartIdx); |
---|
6241 | aiDepthL[2] = pcBaseRCU->getDepth(iBaseRAbsPartIdx); |
---|
6242 | aiDepthL[3] = pcBaseUCU->getDepth(iBaseUAbsPartIdx); |
---|
6243 | aiDepthL[4] = pcBaseDCU->getDepth(iBaseDAbsPartIdx); |
---|
6244 | for (Int i = 0; i < 5; i++) |
---|
6245 | { |
---|
6246 | if (iIVFMaxD < aiDepthL[i]) |
---|
6247 | iIVFMaxD = aiDepthL[i]; |
---|
6248 | } |
---|
6249 | } |
---|
6250 | #endif |
---|
6251 | |
---|
6252 | #if H_3D_SPIVMP |
---|
6253 | Void TComDataCU::getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight) |
---|
6254 | { |
---|
6255 | Int iSubPUSize = ( getSlice()->getIsDepth() ? getSlice()->getMpiSubPbSize() : getSlice()->getSubPbSize() ); |
---|
6256 | |
---|
6257 | iNumSPInOneLine = iPUWidth/iSubPUSize; |
---|
6258 | Int iNumSPInOneColumn = iPUHeight/iSubPUSize; |
---|
6259 | iNumSPInOneLine = (iPUHeight % iSubPUSize != 0 || iPUWidth % iSubPUSize != 0 ) ? 1 : iNumSPInOneLine; |
---|
6260 | iNumSPInOneColumn = (iPUHeight % iSubPUSize != 0 || iPUWidth % iSubPUSize != 0 ) ? 1 : iNumSPInOneColumn; |
---|
6261 | iNumSP = iNumSPInOneLine * iNumSPInOneColumn; |
---|
6262 | |
---|
6263 | iSPWidth = iNumSPInOneLine == 1 ? iPUWidth: iSubPUSize; |
---|
6264 | iSPHeight = iNumSPInOneColumn == 1 ? iPUHeight: iSubPUSize; |
---|
6265 | } |
---|
6266 | |
---|
6267 | Void TComDataCU::getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr ) |
---|
6268 | { |
---|
6269 | uiBaseAbsPartIdx += m_uiAbsIdxInLCU; |
---|
6270 | Int iBasePelX = g_auiRasterToPelX[g_auiZscanToRaster[uiBaseAbsPartIdx]]; |
---|
6271 | Int iBasePelY = g_auiRasterToPelY[g_auiZscanToRaster[uiBaseAbsPartIdx]]; |
---|
6272 | Int iCurrPelX = iBasePelX + iPartIdx%iNumPartLine * iWidth; |
---|
6273 | Int iCurrPelY = iBasePelY + iPartIdx/iNumPartLine * iHeight; |
---|
6274 | Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + iCurrPelX/getPic()->getMinCUWidth(); |
---|
6275 | ruiPartAddr = g_auiRasterToZscan[iCurrRaster]; |
---|
6276 | ruiPartAddr -= m_uiAbsIdxInLCU; |
---|
6277 | } |
---|
6278 | |
---|
6279 | Void TComDataCU::setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight ) |
---|
6280 | { |
---|
6281 | uiAbsPartIdx += getZorderIdxInCU(); |
---|
6282 | Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]]; |
---|
6283 | Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]]; |
---|
6284 | Int iEndPelX = iStartPelX + iWidth; |
---|
6285 | Int iEndPelY = iStartPelY + iHeight; |
---|
6286 | |
---|
6287 | Int iCurrRaster, uiPartAddr; |
---|
6288 | |
---|
6289 | for (Int i=iStartPelY; i<iEndPelY; i+=getPic()->getMinCUHeight()) |
---|
6290 | { |
---|
6291 | for (Int j=iStartPelX; j < iEndPelX; j += getPic()->getMinCUWidth()) |
---|
6292 | { |
---|
6293 | iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + j/getPic()->getMinCUWidth(); |
---|
6294 | uiPartAddr = g_auiRasterToZscan[iCurrRaster]; |
---|
6295 | uiPartAddr -= getZorderIdxInCU(); |
---|
6296 | |
---|
6297 | m_puhInterDir[uiPartAddr] = uiDir; |
---|
6298 | } |
---|
6299 | } |
---|
6300 | } |
---|
6301 | #endif |
---|
6302 | |
---|
6303 | #if H_3D_IV_MERGE |
---|
6304 | Bool |
---|
6305 | TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc , Bool bIsDepth |
---|
6306 | #if H_3D_SPIVMP |
---|
6307 | , TComMvField* pcMvFieldSP, UChar* puhInterDirSP |
---|
6308 | #endif |
---|
6309 | , Bool bICFlag |
---|
6310 | ) |
---|
6311 | { |
---|
6312 | TComSlice* pcSlice = getSlice (); |
---|
6313 | Int iViewIndex = pDInfo->m_aVIdxCan; |
---|
6314 | |
---|
6315 | //--- get base CU/PU and check prediction mode --- |
---|
6316 | TComPic* pcBasePic = pcSlice->getIvPic( bIsDepth, iViewIndex ); |
---|
6317 | TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); |
---|
6318 | |
---|
6319 | UInt uiPartAddr; |
---|
6320 | Int iWidth; |
---|
6321 | Int iHeight; |
---|
6322 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
6323 | |
---|
6324 | Int iCurrPosX, iCurrPosY; |
---|
6325 | pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
6326 | |
---|
6327 | #if !H_3D_SPIVMP |
---|
6328 | iCurrPosX += ( iWidth >> 1 ); |
---|
6329 | iCurrPosY += ( iHeight >> 1 ); |
---|
6330 | #endif |
---|
6331 | |
---|
6332 | Bool depthRefineFlag = false; |
---|
6333 | #if H_3D_NBDV_REF |
---|
6334 | depthRefineFlag = m_pcSlice->getDepthRefinementFlag( ); |
---|
6335 | #endif // H_3D_NBDV_REF |
---|
6336 | |
---|
6337 | TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
---|
6338 | if( depthRefineFlag ) |
---|
6339 | { |
---|
6340 | cDv.setVer(0); |
---|
6341 | } |
---|
6342 | |
---|
6343 | Bool abPdmAvailable[8] = {false, false, false, false, false, false, false, false}; |
---|
6344 | #if H_3D_NBDV |
---|
6345 | for( Int i = 0; i < 8; i++) |
---|
6346 | { |
---|
6347 | pacPdmMv[i].setIDVFlag (false); |
---|
6348 | } |
---|
6349 | #endif |
---|
6350 | |
---|
6351 | if(!bICFlag) |
---|
6352 | { |
---|
6353 | |
---|
6354 | #if H_3D_SPIVMP |
---|
6355 | //////////////////////////////// |
---|
6356 | //////////sub-PU IvMC/////////// |
---|
6357 | //////////////////////////////// |
---|
6358 | if(!m_pcSlice->getIsDepth()) |
---|
6359 | { |
---|
6360 | if (!getDBBPFlag(0)) |
---|
6361 | { |
---|
6362 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
6363 | getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
6364 | |
---|
6365 | for (Int i=0; i<iNumSP; i++) |
---|
6366 | { |
---|
6367 | puhInterDirSP[i] = 0; |
---|
6368 | pcMvFieldSP[2*i].getMv().set(0, 0); |
---|
6369 | pcMvFieldSP[2*i+1].getMv().set(0,0); |
---|
6370 | pcMvFieldSP[2*i].setRefIdx(-1); |
---|
6371 | pcMvFieldSP[2*i+1].setRefIdx(-1); |
---|
6372 | } |
---|
6373 | |
---|
6374 | Int iBaseCUAddr; |
---|
6375 | Int iBaseAbsPartIdx; |
---|
6376 | TComDataCU* pcBaseCU; |
---|
6377 | Int iPartition = 0; |
---|
6378 | |
---|
6379 | Int iDelX = iSPWidth/2; |
---|
6380 | Int iDelY = iSPHeight/2; |
---|
6381 | |
---|
6382 | Int iCenterPosX = iCurrPosX + ( ( iWidth / iSPWidth ) >> 1 ) * iSPWidth + ( iSPWidth >> 1 ); |
---|
6383 | Int iCenterPosY = iCurrPosY + ( ( iHeight / iSPHeight ) >> 1 ) * iSPHeight + (iSPHeight >> 1); |
---|
6384 | Int iRefCenterCUAddr, iRefCenterAbsPartIdx; |
---|
6385 | |
---|
6386 | if(iWidth == iSPWidth && iHeight == iSPHeight) |
---|
6387 | { |
---|
6388 | iCenterPosX = iCurrPosX + (iWidth >> 1); |
---|
6389 | iCenterPosY = iCurrPosY + (iHeight >> 1); |
---|
6390 | } |
---|
6391 | |
---|
6392 | Int iRefCenterPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6393 | Int iRefCenterPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) ); |
---|
6394 | |
---|
6395 | pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx ); |
---|
6396 | TComDataCU* pcDefaultCU = pcBasePic->getCU( iRefCenterCUAddr ); |
---|
6397 | if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA )) |
---|
6398 | { |
---|
6399 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
6400 | { |
---|
6401 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
6402 | Bool stopLoop = false; |
---|
6403 | for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop) |
---|
6404 | { |
---|
6405 | RefPicList eDefaultRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); |
---|
6406 | TComMvField cDefaultMvField; |
---|
6407 | pcDefaultCU->getMvField( pcDefaultCU, iRefCenterAbsPartIdx, eDefaultRefPicList, cDefaultMvField ); |
---|
6408 | Int iDefaultRefIdx = cDefaultMvField.getRefIdx(); |
---|
6409 | if (iDefaultRefIdx >= 0) |
---|
6410 | { |
---|
6411 | Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eDefaultRefPicList, iDefaultRefIdx); |
---|
6412 | if (iDefaultRefPOC != pcSlice->getPOC()) |
---|
6413 | { |
---|
6414 | for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) |
---|
6415 | { |
---|
6416 | if (iDefaultRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) |
---|
6417 | { |
---|
6418 | abPdmAvailable[ uiCurrRefListId ] = true; |
---|
6419 | TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer()); |
---|
6420 | #if H_3D_NBDV |
---|
6421 | #if H_3D_IV_MERGE |
---|
6422 | if( !bIsDepth ) |
---|
6423 | { |
---|
6424 | #endif |
---|
6425 | cMv.setIDVFlag (true); |
---|
6426 | cMv.setIDVHor (cDv.getHor()); |
---|
6427 | cMv.setIDVVer (cDv.getVer()); |
---|
6428 | cMv.setIDVVId (iViewIndex); |
---|
6429 | #if H_3D_IV_MERGE |
---|
6430 | } |
---|
6431 | #endif |
---|
6432 | #endif |
---|
6433 | paiPdmRefIdx [ uiCurrRefListId ] = iPdmRefIdx; |
---|
6434 | pacPdmMv [ uiCurrRefListId ] = cMv; |
---|
6435 | stopLoop = true; |
---|
6436 | break; |
---|
6437 | } |
---|
6438 | } |
---|
6439 | } |
---|
6440 | } |
---|
6441 | } |
---|
6442 | } |
---|
6443 | } |
---|
6444 | availableMcDc[0] = ( abPdmAvailable[0]? 1 : 0) + (abPdmAvailable[1]? 2 : 0); |
---|
6445 | |
---|
6446 | if(availableMcDc[0]) |
---|
6447 | { |
---|
6448 | |
---|
6449 | Int iBasePosX, iBasePosY; |
---|
6450 | for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iSPHeight) |
---|
6451 | { |
---|
6452 | for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth) |
---|
6453 | { |
---|
6454 | iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 )); |
---|
6455 | iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6456 | |
---|
6457 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx ); |
---|
6458 | pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
---|
6459 | if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA )) |
---|
6460 | { |
---|
6461 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
6462 | { |
---|
6463 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
6464 | Bool bLoopStop = false; |
---|
6465 | for(Int iLoop = 0; iLoop < 2 && !bLoopStop; ++iLoop) |
---|
6466 | { |
---|
6467 | RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); |
---|
6468 | TComMvField cBaseMvField; |
---|
6469 | pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField ); |
---|
6470 | Int iBaseRefIdx = cBaseMvField.getRefIdx(); |
---|
6471 | if (iBaseRefIdx >= 0) |
---|
6472 | { |
---|
6473 | Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx); |
---|
6474 | if (iBaseRefPOC != pcSlice->getPOC()) |
---|
6475 | { |
---|
6476 | for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) |
---|
6477 | { |
---|
6478 | if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) |
---|
6479 | { |
---|
6480 | abPdmAvailable[ uiCurrRefListId ] = true; |
---|
6481 | TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer()); |
---|
6482 | |
---|
6483 | if( !bIsDepth ) |
---|
6484 | { |
---|
6485 | cMv.setIDVFlag (true); |
---|
6486 | cMv.setIDVHor (cDv.getHor()); |
---|
6487 | cMv.setIDVVer (cDv.getVer()); |
---|
6488 | cMv.setIDVVId (iViewIndex); |
---|
6489 | } |
---|
6490 | |
---|
6491 | bLoopStop = true; |
---|
6492 | |
---|
6493 | pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iPdmRefIdx); |
---|
6494 | break; |
---|
6495 | } |
---|
6496 | } |
---|
6497 | } |
---|
6498 | } |
---|
6499 | } |
---|
6500 | } |
---|
6501 | } |
---|
6502 | |
---|
6503 | puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0); |
---|
6504 | if (puhInterDirSP[iPartition] == 0) |
---|
6505 | { |
---|
6506 | puhInterDirSP[iPartition] = availableMcDc[0]; |
---|
6507 | pcMvFieldSP[2*iPartition].setMvField(pacPdmMv[0], paiPdmRefIdx[0]); |
---|
6508 | pcMvFieldSP[2*iPartition + 1].setMvField(pacPdmMv[1], paiPdmRefIdx[1]); |
---|
6509 | |
---|
6510 | } |
---|
6511 | iPartition ++; |
---|
6512 | } |
---|
6513 | } |
---|
6514 | } |
---|
6515 | } |
---|
6516 | |
---|
6517 | iCurrPosX += ( iWidth >> 1 ); |
---|
6518 | iCurrPosY += ( iHeight >> 1 ); |
---|
6519 | } |
---|
6520 | #endif |
---|
6521 | |
---|
6522 | //////////////////////////////// |
---|
6523 | /////// IvMC + IvMCShift /////// |
---|
6524 | //////////////////////////////// |
---|
6525 | |
---|
6526 | #if H_3D_SPIVMP |
---|
6527 | if(m_pcSlice->getIsDepth()) |
---|
6528 | { |
---|
6529 | iCurrPosX += ( iWidth >> 1 ); |
---|
6530 | iCurrPosY += ( iHeight >> 1 ); |
---|
6531 | } |
---|
6532 | for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) |
---|
6533 | #else |
---|
6534 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
6535 | #endif |
---|
6536 | { |
---|
6537 | // iLoopCan == 0 --> IvMC |
---|
6538 | // iLoopCan == 1 --> IvMCShift |
---|
6539 | |
---|
6540 | Int iBaseCUAddr; |
---|
6541 | Int iBaseAbsPartIdx; |
---|
6542 | |
---|
6543 | Int offsetW = (iLoopCan == 0) ? 0 : ( iWidth * 2 ); |
---|
6544 | Int offsetH = (iLoopCan == 0) ? 0 : ( iHeight * 2 ); |
---|
6545 | |
---|
6546 | Int iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) ); |
---|
6547 | Int iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); |
---|
6548 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); |
---|
6549 | |
---|
6550 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
---|
6551 | if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA )) |
---|
6552 | { |
---|
6553 | // Loop reference picture list of current slice (X in spec). |
---|
6554 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
6555 | { |
---|
6556 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
6557 | |
---|
6558 | Bool stopLoop = false; |
---|
6559 | // Loop reference picture list of candidate slice (Y in spec) |
---|
6560 | for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop) |
---|
6561 | { |
---|
6562 | RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); |
---|
6563 | TComMvField cBaseMvField; |
---|
6564 | pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField ); |
---|
6565 | Int iBaseRefIdx = cBaseMvField.getRefIdx(); |
---|
6566 | if (iBaseRefIdx >= 0) |
---|
6567 | { |
---|
6568 | Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx); |
---|
6569 | if (iBaseRefPOC != pcSlice->getPOC()) |
---|
6570 | { |
---|
6571 | for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) |
---|
6572 | { |
---|
6573 | if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) |
---|
6574 | { |
---|
6575 | abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true; |
---|
6576 | TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer()); |
---|
6577 | #if H_3D_NBDV |
---|
6578 | #if H_3D_IV_MERGE |
---|
6579 | if( !bIsDepth ) |
---|
6580 | { |
---|
6581 | #endif |
---|
6582 | cMv.setIDVFlag (true); |
---|
6583 | cMv.setIDVHor (cDv.getHor()); |
---|
6584 | cMv.setIDVVer (cDv.getVer()); |
---|
6585 | cMv.setIDVVId (iViewIndex); |
---|
6586 | #if H_3D_IV_MERGE |
---|
6587 | } |
---|
6588 | #endif |
---|
6589 | #endif |
---|
6590 | paiPdmRefIdx [ (uiCurrRefListId + (iLoopCan<<2)) ] = iPdmRefIdx; |
---|
6591 | pacPdmMv [ (uiCurrRefListId + (iLoopCan<<2)) ] = cMv; |
---|
6592 | stopLoop = true; |
---|
6593 | break; |
---|
6594 | } |
---|
6595 | } |
---|
6596 | } |
---|
6597 | } |
---|
6598 | } |
---|
6599 | } |
---|
6600 | } |
---|
6601 | } |
---|
6602 | #if H_3D_SPIVMP |
---|
6603 | for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) |
---|
6604 | #else |
---|
6605 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
6606 | #endif |
---|
6607 | { |
---|
6608 | availableMcDc[(iLoopCan << 1)] = ( abPdmAvailable[(iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[1 + (iLoopCan<<2)] ? 2 : 0); |
---|
6609 | } |
---|
6610 | |
---|
6611 | } |
---|
6612 | |
---|
6613 | //////////////////////////////// |
---|
6614 | /////// IvDC + IvDCShift /////// |
---|
6615 | //////////////////////////////// |
---|
6616 | |
---|
6617 | if( !getSlice()->getIsDepth() ) |
---|
6618 | { |
---|
6619 | for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ ) |
---|
6620 | { |
---|
6621 | RefPicList eRefPicListDMV = RefPicList( iRefListId ); |
---|
6622 | Int iNumRefPics = pcSlice->getNumRefIdx( eRefPicListDMV ); |
---|
6623 | for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ ) |
---|
6624 | { |
---|
6625 | if(( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC()) && (pcSlice->getRefPic( eRefPicListDMV, iPdmRefIdx )->getViewIndex() == pDInfo->m_aVIdxCan)) |
---|
6626 | { |
---|
6627 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
6628 | { |
---|
6629 | Int ioffsetDV = (iLoopCan == 0) ? 0 : 4; |
---|
6630 | abPdmAvailable[ iRefListId + 2 + (iLoopCan<<2) ] = true; |
---|
6631 | paiPdmRefIdx [ iRefListId + 2 + (iLoopCan<<2) ] = iPdmRefIdx; |
---|
6632 | #if H_3D_NBDV_REF |
---|
6633 | TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
---|
6634 | #endif |
---|
6635 | cMv.setHor( cMv.getHor() + ioffsetDV ); |
---|
6636 | #if H_3D_IV_MERGE |
---|
6637 | if( bIsDepth ) |
---|
6638 | { |
---|
6639 | cMv.setHor((cMv.getHor()+2)>>2); |
---|
6640 | } |
---|
6641 | #endif |
---|
6642 | cMv.setVer( 0 ); |
---|
6643 | pacPdmMv [iRefListId + 2 + (iLoopCan<<2)] = cMv; |
---|
6644 | } |
---|
6645 | break; |
---|
6646 | } |
---|
6647 | } |
---|
6648 | } |
---|
6649 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
6650 | { |
---|
6651 | availableMcDc[1 + (iLoopCan << 1)] = ( abPdmAvailable[2 + (iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[3 + (iLoopCan<<2)] ? 2 : 0 ); |
---|
6652 | } |
---|
6653 | } |
---|
6654 | return false; |
---|
6655 | } |
---|
6656 | #endif |
---|
6657 | #if H_3D_ARP |
---|
6658 | Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
6659 | { |
---|
6660 | assert( sizeof( *m_puhARPW) == 1 ); |
---|
6661 | memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
6662 | } |
---|
6663 | #endif |
---|
6664 | |
---|
6665 | #if NH_3D_IC |
---|
6666 | Void TComDataCU::setICFlagSubParts( Bool bICFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
6667 | { |
---|
6668 | memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ))*sizeof(Bool) ); |
---|
6669 | } |
---|
6670 | |
---|
6671 | Bool TComDataCU::isICFlagRequired( UInt uiAbsPartIdx ) |
---|
6672 | { |
---|
6673 | UInt uiPartAddr; |
---|
6674 | UInt iNumbPart; |
---|
6675 | |
---|
6676 | if( !( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ) |
---|
6677 | { |
---|
6678 | return false; |
---|
6679 | } |
---|
6680 | |
---|
6681 | if( getSlice()->getIcSkipParseFlag() ) |
---|
6682 | { |
---|
6683 | if( getMergeFlag( uiAbsPartIdx ) && getMergeIndex( uiAbsPartIdx ) == 0 ) |
---|
6684 | { |
---|
6685 | return false; |
---|
6686 | } |
---|
6687 | } |
---|
6688 | |
---|
6689 | if( getMergeFlag( uiAbsPartIdx ) ) |
---|
6690 | { |
---|
6691 | return true; |
---|
6692 | } |
---|
6693 | |
---|
6694 | |
---|
6695 | Int iWidth, iHeight; |
---|
6696 | |
---|
6697 | iNumbPart = ( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ? 1 : ( getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 ) ); |
---|
6698 | |
---|
6699 | for(UInt i = 0; i < iNumbPart; i++) |
---|
6700 | { |
---|
6701 | getPartIndexAndSize( i, uiPartAddr, iWidth, iHeight, uiAbsPartIdx, true ); |
---|
6702 | uiPartAddr += uiAbsPartIdx; |
---|
6703 | |
---|
6704 | for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++) |
---|
6705 | { |
---|
6706 | RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
6707 | Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr); |
---|
6708 | |
---|
6709 | if( ( getInterDir( uiPartAddr ) & ( uiRefIdx+1 ) ) && iBestRefIdx >= 0 && getSlice()->getViewIndex() != getSlice()->getRefPic( eRefList, iBestRefIdx )->getViewIndex() ) |
---|
6710 | { |
---|
6711 | return true; |
---|
6712 | } |
---|
6713 | } |
---|
6714 | } |
---|
6715 | |
---|
6716 | return false; |
---|
6717 | } |
---|
6718 | #endif |
---|
6719 | #if H_3D_DIM_DMM |
---|
6720 | Void TComDataCU::setDmmWedgeTabIdxSubParts( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
6721 | { |
---|
6722 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
6723 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
6724 | { |
---|
6725 | m_dmmWedgeTabIdx[dmmType][uiAbsPartIdx+ui] = tabIdx; |
---|
6726 | } |
---|
6727 | } |
---|
6728 | #endif |
---|
6729 | |
---|
6730 | #if H_3D_VSP |
---|
6731 | Void TComDataCU::setMvFieldPUForVSP( TComDataCU* pcCU, UInt partAddr, Int width, Int height, RefPicList eRefPicList, Int iRefIdx, Int &vspSize ) |
---|
6732 | { |
---|
6733 | // Get depth reference |
---|
6734 | Int depthRefViewIdx = pcCU->getDvInfo(partAddr).m_aVIdxCan; |
---|
6735 | |
---|
6736 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
6737 | TComPic* pRefPicBaseDepth = 0; |
---|
6738 | Bool bIsCurrDepthCoded = false; |
---|
6739 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() ); |
---|
6740 | if ( pRefPicBaseDepth->getPicYuvRec() != NULL ) |
---|
6741 | { |
---|
6742 | bIsCurrDepthCoded = true; |
---|
6743 | } |
---|
6744 | else |
---|
6745 | { |
---|
6746 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
6747 | } |
---|
6748 | #else |
---|
6749 | TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
6750 | #endif |
---|
6751 | assert(pRefPicBaseDepth != NULL); |
---|
6752 | TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); |
---|
6753 | assert(pcBaseViewDepthPicYuv != NULL); |
---|
6754 | pcBaseViewDepthPicYuv->extendPicBorder(); |
---|
6755 | |
---|
6756 | // Get texture reference |
---|
6757 | assert(iRefIdx >= 0); |
---|
6758 | TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); |
---|
6759 | TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); |
---|
6760 | assert(pcBaseViewTxtPicYuv != NULL); |
---|
6761 | |
---|
6762 | // Initialize LUT according to the reference viewIdx |
---|
6763 | Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex(); |
---|
6764 | Int* pShiftLUT = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx ); |
---|
6765 | assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() ); |
---|
6766 | |
---|
6767 | // prepare Dv to access depth map or reference view |
---|
6768 | TComMv cDv = pcCU->getDvInfo(partAddr).m_acNBDV; |
---|
6769 | pcCU->clipMv(cDv); |
---|
6770 | |
---|
6771 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
6772 | if ( bIsCurrDepthCoded ) |
---|
6773 | { |
---|
6774 | cDv.setZero(); |
---|
6775 | } |
---|
6776 | #endif |
---|
6777 | |
---|
6778 | // fetch virtual depth map & convert depth to motion vector, which are stored in the motion memory |
---|
6779 | xSetMvFieldForVSP( pcCU, pcBaseViewDepthPicYuv, &cDv, partAddr, width, height, pShiftLUT, eRefPicList, iRefIdx, pcCU->getSlice()->getIsDepth(), vspSize ); |
---|
6780 | } |
---|
6781 | |
---|
6782 | Void TComDataCU::xSetMvFieldForVSP( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, Int *shiftLUT, RefPicList refPicList, Int refIdx, Bool isDepth, Int &vspSize ) |
---|
6783 | { |
---|
6784 | TComCUMvField *cuMvField = cu->getCUMvField( refPicList ); |
---|
6785 | Int partAddrRasterSubPULine = g_auiZscanToRaster[ partAddr ]; |
---|
6786 | Int numPartsLine = cu->getPic()->getNumPartInWidth(); |
---|
6787 | |
---|
6788 | Int nTxtPerMvInfoX = 4; // cu->getPic()->getMinCUWidth(); |
---|
6789 | Int nTxtPerMvInfoY = 4; // cu->getPic()->getMinCUHeight(); |
---|
6790 | |
---|
6791 | Int refDepStride = picRefDepth->getStride(); |
---|
6792 | |
---|
6793 | TComMv tmpMv(0, 0); |
---|
6794 | tmpMv.setIDVFlag(false); |
---|
6795 | |
---|
6796 | Int refDepOffset = ( (dv->getHor()+2) >> 2 ) + ( (dv->getVer()+2) >> 2 ) * refDepStride; |
---|
6797 | Pel *refDepth = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refDepOffset; |
---|
6798 | |
---|
6799 | if ((height % 8)) |
---|
6800 | { |
---|
6801 | vspSize = 1; // 8x4 |
---|
6802 | } |
---|
6803 | else if ((width % 8)) |
---|
6804 | { |
---|
6805 | vspSize = 0; // 4x8 |
---|
6806 | } |
---|
6807 | else |
---|
6808 | { |
---|
6809 | Bool ULvsBR, URvsBL; |
---|
6810 | ULvsBR = refDepth[0] < refDepth[refDepStride * (height-1) + width-1]; |
---|
6811 | URvsBL = refDepth[width-1] < refDepth[refDepStride * (height-1)]; |
---|
6812 | vspSize = ( ULvsBR ^ URvsBL ) ? 0 : 1; |
---|
6813 | } |
---|
6814 | |
---|
6815 | Int subBlockW, subBlockH; |
---|
6816 | if (vspSize) |
---|
6817 | { |
---|
6818 | subBlockW = 8; |
---|
6819 | subBlockH = 4; |
---|
6820 | } |
---|
6821 | else |
---|
6822 | { |
---|
6823 | subBlockW = 4; |
---|
6824 | subBlockH = 8; |
---|
6825 | } |
---|
6826 | |
---|
6827 | Int numPartsInSubPUW = subBlockW / nTxtPerMvInfoX; |
---|
6828 | Int numPartsInSubPUH = subBlockH / nTxtPerMvInfoY * numPartsLine; |
---|
6829 | |
---|
6830 | for( Int y=0; y<height; y+=subBlockH, partAddrRasterSubPULine+=numPartsInSubPUH ) |
---|
6831 | { |
---|
6832 | Pel *refDepthTmp[4]; |
---|
6833 | refDepthTmp[0] = refDepth + refDepStride * y; |
---|
6834 | refDepthTmp[1] = refDepthTmp[0] + subBlockW - 1; |
---|
6835 | refDepthTmp[2] = refDepthTmp[0] + refDepStride * (subBlockH - 1); |
---|
6836 | refDepthTmp[3] = refDepthTmp[2] + subBlockW - 1; |
---|
6837 | |
---|
6838 | Int partAddrRasterSubPU = partAddrRasterSubPULine; |
---|
6839 | for( Int x=0; x<width; x+=subBlockW, partAddrRasterSubPU+=numPartsInSubPUW ) |
---|
6840 | { |
---|
6841 | Pel maxDepthVal; |
---|
6842 | maxDepthVal = refDepthTmp[0][x]; |
---|
6843 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[1][x]); |
---|
6844 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[2][x]); |
---|
6845 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[3][x]); |
---|
6846 | tmpMv.setHor( (Short) shiftLUT[ maxDepthVal ] ); |
---|
6847 | |
---|
6848 | Int partAddrRasterPartLine = partAddrRasterSubPU; |
---|
6849 | for( Int sY=0; sY<numPartsInSubPUH; sY+=numPartsLine, partAddrRasterPartLine += numPartsLine ) |
---|
6850 | { |
---|
6851 | Int partAddrRasterPart = partAddrRasterPartLine; |
---|
6852 | for( Int sX=0; sX<numPartsInSubPUW; sX+=1, partAddrRasterPart++ ) |
---|
6853 | { |
---|
6854 | cuMvField->setMv ( g_auiRasterToZscan[ partAddrRasterPart ], tmpMv ); |
---|
6855 | cuMvField->setRefIdx( g_auiRasterToZscan[ partAddrRasterPart ], refIdx ); |
---|
6856 | } |
---|
6857 | } |
---|
6858 | } |
---|
6859 | } |
---|
6860 | |
---|
6861 | vspSize = (vspSize<<2)+1; |
---|
6862 | |
---|
6863 | } |
---|
6864 | #endif |
---|
6865 | |
---|
6866 | //! \} |
---|