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