1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TComDataCU.cpp |
---|
35 | \brief CU data structure |
---|
36 | \todo not all entities are documented |
---|
37 | */ |
---|
38 | |
---|
39 | #include "TComDataCU.h" |
---|
40 | #include "TComPic.h" |
---|
41 | |
---|
42 | //! \ingroup TLibCommon |
---|
43 | //! \{ |
---|
44 | |
---|
45 | #if ADAPTIVE_QP_SELECTION |
---|
46 | Int * TComDataCU::m_pcGlbArlCoeffY = NULL; |
---|
47 | Int * TComDataCU::m_pcGlbArlCoeffCb = NULL; |
---|
48 | Int * TComDataCU::m_pcGlbArlCoeffCr = NULL; |
---|
49 | #endif |
---|
50 | |
---|
51 | // ==================================================================================================================== |
---|
52 | // Constructor / destructor / create / destroy |
---|
53 | // ==================================================================================================================== |
---|
54 | |
---|
55 | TComDataCU::TComDataCU() |
---|
56 | { |
---|
57 | m_pcPic = NULL; |
---|
58 | m_pcSlice = NULL; |
---|
59 | m_puhDepth = NULL; |
---|
60 | |
---|
61 | m_skipFlag = NULL; |
---|
62 | |
---|
63 | m_pePartSize = NULL; |
---|
64 | m_pePredMode = NULL; |
---|
65 | m_CUTransquantBypass = NULL; |
---|
66 | m_puhWidth = NULL; |
---|
67 | m_puhHeight = NULL; |
---|
68 | m_phQP = NULL; |
---|
69 | m_pbMergeFlag = NULL; |
---|
70 | m_puhMergeIndex = NULL; |
---|
71 | m_puhLumaIntraDir = NULL; |
---|
72 | m_puhChromaIntraDir = NULL; |
---|
73 | m_puhInterDir = NULL; |
---|
74 | m_puhTrIdx = NULL; |
---|
75 | m_puhTransformSkip[0] = NULL; |
---|
76 | m_puhTransformSkip[1] = NULL; |
---|
77 | m_puhTransformSkip[2] = NULL; |
---|
78 | m_puhCbf[0] = NULL; |
---|
79 | m_puhCbf[1] = NULL; |
---|
80 | m_puhCbf[2] = NULL; |
---|
81 | m_pcTrCoeffY = NULL; |
---|
82 | m_pcTrCoeffCb = NULL; |
---|
83 | m_pcTrCoeffCr = NULL; |
---|
84 | #if ADAPTIVE_QP_SELECTION |
---|
85 | m_ArlCoeffIsAliasedAllocation = false; |
---|
86 | m_pcArlCoeffY = NULL; |
---|
87 | m_pcArlCoeffCb = NULL; |
---|
88 | m_pcArlCoeffCr = NULL; |
---|
89 | #endif |
---|
90 | |
---|
91 | m_pbIPCMFlag = NULL; |
---|
92 | m_pcIPCMSampleY = NULL; |
---|
93 | m_pcIPCMSampleCb = NULL; |
---|
94 | m_pcIPCMSampleCr = NULL; |
---|
95 | |
---|
96 | m_pcPattern = NULL; |
---|
97 | |
---|
98 | m_pcCUAboveLeft = NULL; |
---|
99 | m_pcCUAboveRight = NULL; |
---|
100 | m_pcCUAbove = NULL; |
---|
101 | m_pcCULeft = NULL; |
---|
102 | |
---|
103 | m_apcCUColocated[0] = NULL; |
---|
104 | m_apcCUColocated[1] = NULL; |
---|
105 | |
---|
106 | m_apiMVPIdx[0] = NULL; |
---|
107 | m_apiMVPIdx[1] = NULL; |
---|
108 | m_apiMVPNum[0] = NULL; |
---|
109 | m_apiMVPNum[1] = NULL; |
---|
110 | |
---|
111 | #if H_3D_DIM |
---|
112 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
113 | { |
---|
114 | m_dimDeltaDC[i][0] = NULL; |
---|
115 | m_dimDeltaDC[i][1] = NULL; |
---|
116 | } |
---|
117 | #if H_3D_DIM_DMM |
---|
118 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
119 | { |
---|
120 | m_dmmWedgeTabIdx[i] = NULL; |
---|
121 | } |
---|
122 | #if !SEC_DMM2_E0146_HHIFIX |
---|
123 | m_dmm2DeltaEnd = NULL; |
---|
124 | #endif |
---|
125 | m_dmm3IntraTabIdx = NULL; |
---|
126 | #endif |
---|
127 | #if H_3D_DIM_RBC |
---|
128 | m_pucEdgeCode = NULL; |
---|
129 | m_pucEdgeNumber = NULL; |
---|
130 | m_pucEdgeStartPos = NULL; |
---|
131 | m_pbEdgeLeftFirst = NULL; |
---|
132 | m_pbEdgePartition = NULL; |
---|
133 | #endif |
---|
134 | #if H_3D_DIM_SDC |
---|
135 | m_pbSDCFlag = NULL; |
---|
136 | m_apSegmentDCOffset[0] = NULL; |
---|
137 | m_apSegmentDCOffset[1] = NULL; |
---|
138 | #endif |
---|
139 | #endif |
---|
140 | m_bDecSubCu = false; |
---|
141 | m_sliceStartCU = 0; |
---|
142 | m_sliceSegmentStartCU = 0; |
---|
143 | #if H_3D_NBDV |
---|
144 | m_pDvInfo = NULL; |
---|
145 | #endif |
---|
146 | #if H_3D_VSP |
---|
147 | m_piVSPFlag = NULL; |
---|
148 | #endif |
---|
149 | #if H_3D_ARP |
---|
150 | m_puhARPW = NULL; |
---|
151 | #endif |
---|
152 | #if H_3D_IC |
---|
153 | m_pbICFlag = NULL; |
---|
154 | #endif |
---|
155 | #if LGE_INTER_SDC_E0156 |
---|
156 | m_pbInterSDCFlag = NULL; |
---|
157 | for( Int i = 0; i < 4; i++ ) |
---|
158 | { |
---|
159 | m_apSegmentInterDCOffset[i] = NULL; |
---|
160 | } |
---|
161 | m_pucInterSDCMask = NULL; |
---|
162 | #endif |
---|
163 | } |
---|
164 | |
---|
165 | TComDataCU::~TComDataCU() |
---|
166 | { |
---|
167 | } |
---|
168 | |
---|
169 | Void TComDataCU::create(UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
170 | #if ADAPTIVE_QP_SELECTION |
---|
171 | , Bool bGlobalRMARLBuffer |
---|
172 | #endif |
---|
173 | ) |
---|
174 | { |
---|
175 | m_bDecSubCu = bDecSubCu; |
---|
176 | |
---|
177 | m_pcPic = NULL; |
---|
178 | m_pcSlice = NULL; |
---|
179 | m_uiNumPartition = uiNumPartition; |
---|
180 | m_unitSize = unitSize; |
---|
181 | |
---|
182 | if ( !bDecSubCu ) |
---|
183 | { |
---|
184 | m_phQP = (Char* )xMalloc(Char, uiNumPartition); |
---|
185 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
186 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
187 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
188 | |
---|
189 | m_skipFlag = new Bool[ uiNumPartition ]; |
---|
190 | |
---|
191 | m_pePartSize = new Char[ uiNumPartition ]; |
---|
192 | memset( m_pePartSize, SIZE_NONE,uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
193 | m_pePredMode = new Char[ uiNumPartition ]; |
---|
194 | m_CUTransquantBypass = new Bool[ uiNumPartition ]; |
---|
195 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
196 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
197 | #if H_3D_VSP |
---|
198 | m_piVSPFlag = (Char* )xMalloc(Char, uiNumPartition); |
---|
199 | #endif |
---|
200 | m_puhLumaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
201 | m_puhChromaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
202 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
203 | |
---|
204 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
205 | m_puhTransformSkip[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
206 | m_puhTransformSkip[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
207 | m_puhTransformSkip[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
208 | |
---|
209 | m_puhCbf[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
210 | m_puhCbf[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
211 | m_puhCbf[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
212 | |
---|
213 | m_apiMVPIdx[0] = new Char[ uiNumPartition ]; |
---|
214 | m_apiMVPIdx[1] = new Char[ uiNumPartition ]; |
---|
215 | m_apiMVPNum[0] = new Char[ uiNumPartition ]; |
---|
216 | m_apiMVPNum[1] = new Char[ uiNumPartition ]; |
---|
217 | memset( m_apiMVPIdx[0], -1,uiNumPartition * sizeof( Char ) ); |
---|
218 | memset( m_apiMVPIdx[1], -1,uiNumPartition * sizeof( Char ) ); |
---|
219 | |
---|
220 | m_pcTrCoeffY = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight); |
---|
221 | m_pcTrCoeffCb = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
222 | m_pcTrCoeffCr = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
223 | #if H_3D_NBDV |
---|
224 | m_pDvInfo = (DisInfo* )xMalloc(DisInfo, uiNumPartition); |
---|
225 | #endif |
---|
226 | memset( m_pcTrCoeffY, 0,uiWidth*uiHeight * sizeof( TCoeff ) ); |
---|
227 | memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
---|
228 | memset( m_pcTrCoeffCr, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
---|
229 | #if ADAPTIVE_QP_SELECTION |
---|
230 | if( bGlobalRMARLBuffer ) |
---|
231 | { |
---|
232 | if( m_pcGlbArlCoeffY == NULL ) |
---|
233 | { |
---|
234 | m_pcGlbArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
---|
235 | m_pcGlbArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
236 | m_pcGlbArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
237 | } |
---|
238 | m_pcArlCoeffY = m_pcGlbArlCoeffY; |
---|
239 | m_pcArlCoeffCb = m_pcGlbArlCoeffCb; |
---|
240 | m_pcArlCoeffCr = m_pcGlbArlCoeffCr; |
---|
241 | m_ArlCoeffIsAliasedAllocation = true; |
---|
242 | } |
---|
243 | else |
---|
244 | { |
---|
245 | m_pcArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
---|
246 | m_pcArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
247 | m_pcArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
248 | } |
---|
249 | #endif |
---|
250 | |
---|
251 | m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
252 | m_pcIPCMSampleY = (Pel* )xMalloc(Pel , uiWidth*uiHeight); |
---|
253 | m_pcIPCMSampleCb = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
---|
254 | m_pcIPCMSampleCr = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
---|
255 | |
---|
256 | m_acCUMvField[0].create( uiNumPartition ); |
---|
257 | m_acCUMvField[1].create( uiNumPartition ); |
---|
258 | |
---|
259 | #if H_3D_ARP |
---|
260 | m_puhARPW = new UChar[ uiNumPartition]; |
---|
261 | #endif |
---|
262 | #if H_3D_IC |
---|
263 | m_pbICFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
264 | #endif |
---|
265 | #if H_3D_DIM |
---|
266 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
267 | { |
---|
268 | m_dimDeltaDC[i][0] = (Pel* )xMalloc(Pel, uiNumPartition); |
---|
269 | m_dimDeltaDC[i][1] = (Pel* )xMalloc(Pel, uiNumPartition); |
---|
270 | } |
---|
271 | #if H_3D_DIM_DMM |
---|
272 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
273 | { |
---|
274 | m_dmmWedgeTabIdx[i] = (UInt*)xMalloc(UInt, uiNumPartition); |
---|
275 | } |
---|
276 | #if !SEC_DMM2_E0146_HHIFIX |
---|
277 | m_dmm2DeltaEnd = (Int* )xMalloc(Int, uiNumPartition); |
---|
278 | #endif |
---|
279 | m_dmm3IntraTabIdx = (UInt*)xMalloc(UInt, uiNumPartition); |
---|
280 | #endif |
---|
281 | #if H_3D_DIM_RBC |
---|
282 | m_pucEdgeCode = (UChar*)xMalloc(UChar, uiNumPartition * RBC_MAX_EDGE_NUM_PER_4x4); |
---|
283 | m_pucEdgeNumber = (UChar*)xMalloc(UChar, uiNumPartition); |
---|
284 | m_pucEdgeStartPos = (UChar*)xMalloc(UChar, uiNumPartition); |
---|
285 | m_pbEdgeLeftFirst = (Bool*)xMalloc(Bool, uiNumPartition); |
---|
286 | m_pbEdgePartition = (Bool*)xMalloc(Bool, uiNumPartition * 16); |
---|
287 | #endif |
---|
288 | #if H_3D_DIM_SDC |
---|
289 | m_pbSDCFlag = (Bool*)xMalloc(Bool, uiNumPartition); |
---|
290 | m_apSegmentDCOffset[0] = (Pel*)xMalloc(Pel, uiNumPartition); |
---|
291 | m_apSegmentDCOffset[1] = (Pel*)xMalloc(Pel, uiNumPartition); |
---|
292 | #endif |
---|
293 | #endif |
---|
294 | #if LGE_INTER_SDC_E0156 |
---|
295 | m_pbInterSDCFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
296 | for( Int i = 0; i < 4; i++ ) |
---|
297 | { |
---|
298 | m_apSegmentInterDCOffset[i] = (Int*)xMalloc(Int, uiNumPartition); |
---|
299 | } |
---|
300 | #endif |
---|
301 | } |
---|
302 | else |
---|
303 | { |
---|
304 | m_acCUMvField[0].setNumPartition(uiNumPartition ); |
---|
305 | m_acCUMvField[1].setNumPartition(uiNumPartition ); |
---|
306 | } |
---|
307 | #if LGE_INTER_SDC_E0156 |
---|
308 | m_pucInterSDCMask = (UChar* )xMalloc(UChar, g_uiMaxCUHeight*g_uiMaxCUWidth); |
---|
309 | #endif |
---|
310 | m_sliceStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
311 | m_sliceSegmentStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
312 | |
---|
313 | // create pattern memory |
---|
314 | m_pcPattern = (TComPattern*)xMalloc(TComPattern, 1); |
---|
315 | |
---|
316 | // create motion vector fields |
---|
317 | |
---|
318 | m_pcCUAboveLeft = NULL; |
---|
319 | m_pcCUAboveRight = NULL; |
---|
320 | m_pcCUAbove = NULL; |
---|
321 | m_pcCULeft = NULL; |
---|
322 | |
---|
323 | m_apcCUColocated[0] = NULL; |
---|
324 | m_apcCUColocated[1] = NULL; |
---|
325 | } |
---|
326 | |
---|
327 | Void TComDataCU::destroy() |
---|
328 | { |
---|
329 | m_pcPic = NULL; |
---|
330 | m_pcSlice = NULL; |
---|
331 | |
---|
332 | if ( m_pcPattern ) |
---|
333 | { |
---|
334 | xFree(m_pcPattern); |
---|
335 | m_pcPattern = NULL; |
---|
336 | } |
---|
337 | |
---|
338 | // encoder-side buffer free |
---|
339 | if ( !m_bDecSubCu ) |
---|
340 | { |
---|
341 | if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } |
---|
342 | if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } |
---|
343 | if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } |
---|
344 | if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } |
---|
345 | |
---|
346 | if ( m_skipFlag ) { delete[] m_skipFlag; m_skipFlag = NULL; } |
---|
347 | |
---|
348 | if ( m_pePartSize ) { delete[] m_pePartSize; m_pePartSize = NULL; } |
---|
349 | if ( m_pePredMode ) { delete[] m_pePredMode; m_pePredMode = NULL; } |
---|
350 | if ( m_CUTransquantBypass ) { delete[] m_CUTransquantBypass;m_CUTransquantBypass = NULL; } |
---|
351 | if ( m_puhCbf[0] ) { xFree(m_puhCbf[0]); m_puhCbf[0] = NULL; } |
---|
352 | if ( m_puhCbf[1] ) { xFree(m_puhCbf[1]); m_puhCbf[1] = NULL; } |
---|
353 | if ( m_puhCbf[2] ) { xFree(m_puhCbf[2]); m_puhCbf[2] = NULL; } |
---|
354 | if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } |
---|
355 | if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } |
---|
356 | if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } |
---|
357 | #if H_3D_VSP |
---|
358 | if ( m_piVSPFlag ) { xFree(m_piVSPFlag); m_piVSPFlag = NULL; } |
---|
359 | #endif |
---|
360 | if ( m_puhLumaIntraDir ) { xFree(m_puhLumaIntraDir); m_puhLumaIntraDir = NULL; } |
---|
361 | if ( m_puhChromaIntraDir ) { xFree(m_puhChromaIntraDir); m_puhChromaIntraDir = NULL; } |
---|
362 | if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } |
---|
363 | if ( m_puhTransformSkip[0]) { xFree(m_puhTransformSkip[0]); m_puhTransformSkip[0] = NULL; } |
---|
364 | if ( m_puhTransformSkip[1]) { xFree(m_puhTransformSkip[1]); m_puhTransformSkip[1] = NULL; } |
---|
365 | if ( m_puhTransformSkip[2]) { xFree(m_puhTransformSkip[2]); m_puhTransformSkip[2] = NULL; } |
---|
366 | if ( m_pcTrCoeffY ) { xFree(m_pcTrCoeffY); m_pcTrCoeffY = NULL; } |
---|
367 | if ( m_pcTrCoeffCb ) { xFree(m_pcTrCoeffCb); m_pcTrCoeffCb = NULL; } |
---|
368 | if ( m_pcTrCoeffCr ) { xFree(m_pcTrCoeffCr); m_pcTrCoeffCr = NULL; } |
---|
369 | #if ADAPTIVE_QP_SELECTION |
---|
370 | if (!m_ArlCoeffIsAliasedAllocation) |
---|
371 | { |
---|
372 | xFree(m_pcArlCoeffY); m_pcArlCoeffY = 0; |
---|
373 | xFree(m_pcArlCoeffCb); m_pcArlCoeffCb = 0; |
---|
374 | xFree(m_pcArlCoeffCr); m_pcArlCoeffCr = 0; |
---|
375 | } |
---|
376 | if ( m_pcGlbArlCoeffY ) { xFree(m_pcGlbArlCoeffY); m_pcGlbArlCoeffY = NULL; } |
---|
377 | if ( m_pcGlbArlCoeffCb ) { xFree(m_pcGlbArlCoeffCb); m_pcGlbArlCoeffCb = NULL; } |
---|
378 | if ( m_pcGlbArlCoeffCr ) { xFree(m_pcGlbArlCoeffCr); m_pcGlbArlCoeffCr = NULL; } |
---|
379 | #endif |
---|
380 | if ( m_pbIPCMFlag ) { xFree(m_pbIPCMFlag ); m_pbIPCMFlag = NULL; } |
---|
381 | if ( m_pcIPCMSampleY ) { xFree(m_pcIPCMSampleY); m_pcIPCMSampleY = NULL; } |
---|
382 | if ( m_pcIPCMSampleCb ) { xFree(m_pcIPCMSampleCb); m_pcIPCMSampleCb = NULL; } |
---|
383 | if ( m_pcIPCMSampleCr ) { xFree(m_pcIPCMSampleCr); m_pcIPCMSampleCr = NULL; } |
---|
384 | if ( m_apiMVPIdx[0] ) { delete[] m_apiMVPIdx[0]; m_apiMVPIdx[0] = NULL; } |
---|
385 | if ( m_apiMVPIdx[1] ) { delete[] m_apiMVPIdx[1]; m_apiMVPIdx[1] = NULL; } |
---|
386 | if ( m_apiMVPNum[0] ) { delete[] m_apiMVPNum[0]; m_apiMVPNum[0] = NULL; } |
---|
387 | if ( m_apiMVPNum[1] ) { delete[] m_apiMVPNum[1]; m_apiMVPNum[1] = NULL; } |
---|
388 | #if H_3D_NBDV |
---|
389 | if ( m_pDvInfo ) { xFree(m_pDvInfo); m_pDvInfo = NULL; } |
---|
390 | #endif |
---|
391 | |
---|
392 | #if H_3D_ARP |
---|
393 | if ( m_puhARPW ) { delete[] m_puhARPW; m_puhARPW = NULL; } |
---|
394 | #endif |
---|
395 | #if H_3D_IC |
---|
396 | if ( m_pbICFlag ) { xFree(m_pbICFlag); m_pbICFlag = NULL; } |
---|
397 | #endif |
---|
398 | m_acCUMvField[0].destroy(); |
---|
399 | m_acCUMvField[1].destroy(); |
---|
400 | |
---|
401 | #if H_3D_DIM |
---|
402 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
403 | { |
---|
404 | if ( m_dimDeltaDC[i][0] ) { xFree( m_dimDeltaDC[i][0] ); m_dimDeltaDC[i][0] = NULL; } |
---|
405 | if ( m_dimDeltaDC[i][1] ) { xFree( m_dimDeltaDC[i][1] ); m_dimDeltaDC[i][1] = NULL; } |
---|
406 | } |
---|
407 | #if H_3D_DIM_DMM |
---|
408 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
409 | { |
---|
410 | if ( m_dmmWedgeTabIdx[i] ) { xFree( m_dmmWedgeTabIdx[i] ); m_dmmWedgeTabIdx[i] = NULL; } |
---|
411 | } |
---|
412 | #if !SEC_DMM2_E0146_HHIFIX |
---|
413 | if ( m_dmm2DeltaEnd ) { xFree( m_dmm2DeltaEnd ); m_dmm2DeltaEnd = NULL; } |
---|
414 | #endif |
---|
415 | if ( m_dmm3IntraTabIdx ) { xFree( m_dmm3IntraTabIdx ); m_dmm3IntraTabIdx = NULL; } |
---|
416 | #endif |
---|
417 | #if H_3D_DIM_RBC |
---|
418 | if ( m_pbEdgeLeftFirst ) { xFree( m_pbEdgeLeftFirst ); m_pbEdgeLeftFirst = NULL; } |
---|
419 | if ( m_pucEdgeStartPos ) { xFree( m_pucEdgeStartPos ); m_pucEdgeStartPos = NULL; } |
---|
420 | if ( m_pucEdgeNumber ) { xFree( m_pucEdgeNumber ); m_pucEdgeNumber = NULL; } |
---|
421 | if ( m_pucEdgeCode ) { xFree( m_pucEdgeCode ); m_pucEdgeCode = NULL; } |
---|
422 | if ( m_pbEdgePartition ) { xFree( m_pbEdgePartition ); m_pbEdgePartition = NULL; } |
---|
423 | #endif |
---|
424 | #if H_3D_DIM_SDC |
---|
425 | if ( m_pbSDCFlag ) { xFree(m_pbSDCFlag); m_pbSDCFlag = NULL; } |
---|
426 | if ( m_apSegmentDCOffset[0] ) { xFree(m_apSegmentDCOffset[0]); m_apSegmentDCOffset[0] = NULL; } |
---|
427 | if ( m_apSegmentDCOffset[1] ) { xFree(m_apSegmentDCOffset[1]); m_apSegmentDCOffset[1] = NULL; } |
---|
428 | #endif |
---|
429 | #endif |
---|
430 | #if LGE_INTER_SDC_E0156 |
---|
431 | if ( m_pbInterSDCFlag ) { xFree(m_pbInterSDCFlag); m_pbInterSDCFlag = NULL; } |
---|
432 | for(Int i = 0; i < 4; i++ ) |
---|
433 | { |
---|
434 | if ( m_apSegmentInterDCOffset[i] ) { xFree( m_apSegmentInterDCOffset[i] ); m_apSegmentInterDCOffset[i] = NULL; } |
---|
435 | } |
---|
436 | #endif |
---|
437 | } |
---|
438 | #if LGE_INTER_SDC_E0156 |
---|
439 | if ( m_pucInterSDCMask ) { xFree(m_pucInterSDCMask); m_pucInterSDCMask = NULL; } |
---|
440 | #endif |
---|
441 | m_pcCUAboveLeft = NULL; |
---|
442 | m_pcCUAboveRight = NULL; |
---|
443 | m_pcCUAbove = NULL; |
---|
444 | m_pcCULeft = NULL; |
---|
445 | |
---|
446 | m_apcCUColocated[0] = NULL; |
---|
447 | m_apcCUColocated[1] = NULL; |
---|
448 | |
---|
449 | if( m_sliceStartCU ) |
---|
450 | { |
---|
451 | xFree(m_sliceStartCU); |
---|
452 | m_sliceStartCU=NULL; |
---|
453 | } |
---|
454 | if(m_sliceSegmentStartCU ) |
---|
455 | { |
---|
456 | xFree(m_sliceSegmentStartCU); |
---|
457 | m_sliceSegmentStartCU=NULL; |
---|
458 | } |
---|
459 | } |
---|
460 | |
---|
461 | const NDBFBlockInfo& NDBFBlockInfo::operator= (const NDBFBlockInfo& src) |
---|
462 | { |
---|
463 | this->tileID = src.tileID; |
---|
464 | this->sliceID= src.sliceID; |
---|
465 | this->startSU= src.startSU; |
---|
466 | this->endSU = src.endSU; |
---|
467 | this->widthSU= src.widthSU; |
---|
468 | this->heightSU=src.heightSU; |
---|
469 | this->posX = src.posX; |
---|
470 | this->posY = src.posY; |
---|
471 | this->width = src.width; |
---|
472 | this->height = src.height; |
---|
473 | ::memcpy(this->isBorderAvailable, src.isBorderAvailable, sizeof(Bool)*((Int)NUM_SGU_BORDER)); |
---|
474 | this->allBordersAvailable = src.allBordersAvailable; |
---|
475 | |
---|
476 | return *this; |
---|
477 | } |
---|
478 | |
---|
479 | |
---|
480 | // ==================================================================================================================== |
---|
481 | // Public member functions |
---|
482 | // ==================================================================================================================== |
---|
483 | |
---|
484 | // -------------------------------------------------------------------------------------------------------------------- |
---|
485 | // Initialization |
---|
486 | // -------------------------------------------------------------------------------------------------------------------- |
---|
487 | |
---|
488 | /** |
---|
489 | - initialize top-level CU |
---|
490 | - internal buffers are already created |
---|
491 | - set values before encoding a CU |
---|
492 | . |
---|
493 | \param pcPic picture (TComPic) class pointer |
---|
494 | \param iCUAddr CU address |
---|
495 | */ |
---|
496 | Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr ) |
---|
497 | { |
---|
498 | |
---|
499 | m_pcPic = pcPic; |
---|
500 | m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
501 | m_uiCUAddr = iCUAddr; |
---|
502 | m_uiCUPelX = ( iCUAddr % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth; |
---|
503 | m_uiCUPelY = ( iCUAddr / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight; |
---|
504 | m_uiAbsIdxInLCU = 0; |
---|
505 | m_dTotalCost = MAX_DOUBLE; |
---|
506 | m_uiTotalDistortion = 0; |
---|
507 | m_uiTotalBits = 0; |
---|
508 | m_uiTotalBins = 0; |
---|
509 | m_uiNumPartition = pcPic->getNumPartInCU(); |
---|
510 | |
---|
511 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
---|
512 | { |
---|
513 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceCurStartCUAddr()) |
---|
514 | { |
---|
515 | m_sliceStartCU[i]=getSlice()->getSliceCurStartCUAddr(); |
---|
516 | } |
---|
517 | else |
---|
518 | { |
---|
519 | m_sliceStartCU[i]=pcPic->getCU(getAddr())->m_sliceStartCU[i]; |
---|
520 | } |
---|
521 | } |
---|
522 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
---|
523 | { |
---|
524 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
525 | { |
---|
526 | m_sliceSegmentStartCU[i]=getSlice()->getSliceSegmentCurStartCUAddr(); |
---|
527 | } |
---|
528 | else |
---|
529 | { |
---|
530 | m_sliceSegmentStartCU[i]=pcPic->getCU(getAddr())->m_sliceSegmentStartCU[i]; |
---|
531 | } |
---|
532 | } |
---|
533 | |
---|
534 | Int partStartIdx = getSlice()->getSliceSegmentCurStartCUAddr() - pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr) * pcPic->getNumPartInCU(); |
---|
535 | |
---|
536 | Int numElements = min<Int>( partStartIdx, m_uiNumPartition ); |
---|
537 | for ( Int ui = 0; ui < numElements; ui++ ) |
---|
538 | { |
---|
539 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
---|
540 | m_skipFlag[ui] = pcFrom->getSkipFlag(ui); |
---|
541 | m_pePartSize[ui] = pcFrom->getPartitionSize(ui); |
---|
542 | m_pePredMode[ui] = pcFrom->getPredictionMode(ui); |
---|
543 | m_CUTransquantBypass[ui] = pcFrom->getCUTransquantBypass(ui); |
---|
544 | m_puhDepth[ui] = pcFrom->getDepth(ui); |
---|
545 | #if H_3D_ARP |
---|
546 | m_puhARPW [ui] = pcFrom->getARPW( ui ); |
---|
547 | #endif |
---|
548 | #if H_3D_IC |
---|
549 | m_pbICFlag[ui] = pcFrom->m_pbICFlag[ui]; |
---|
550 | #endif |
---|
551 | m_puhWidth [ui] = pcFrom->getWidth(ui); |
---|
552 | m_puhHeight [ui] = pcFrom->getHeight(ui); |
---|
553 | m_puhTrIdx [ui] = pcFrom->getTransformIdx(ui); |
---|
554 | m_puhTransformSkip[0][ui] = pcFrom->getTransformSkip(ui,TEXT_LUMA); |
---|
555 | m_puhTransformSkip[1][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_U); |
---|
556 | m_puhTransformSkip[2][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_V); |
---|
557 | m_apiMVPIdx[0][ui] = pcFrom->m_apiMVPIdx[0][ui];; |
---|
558 | m_apiMVPIdx[1][ui] = pcFrom->m_apiMVPIdx[1][ui]; |
---|
559 | m_apiMVPNum[0][ui] = pcFrom->m_apiMVPNum[0][ui]; |
---|
560 | m_apiMVPNum[1][ui] = pcFrom->m_apiMVPNum[1][ui]; |
---|
561 | m_phQP[ui]=pcFrom->m_phQP[ui]; |
---|
562 | m_pbMergeFlag[ui]=pcFrom->m_pbMergeFlag[ui]; |
---|
563 | m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui]; |
---|
564 | #if H_3D_VSP |
---|
565 | m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui]; |
---|
566 | #endif |
---|
567 | m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui]; |
---|
568 | m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui]; |
---|
569 | m_puhInterDir[ui]=pcFrom->m_puhInterDir[ui]; |
---|
570 | m_puhCbf[0][ui]=pcFrom->m_puhCbf[0][ui]; |
---|
571 | m_puhCbf[1][ui]=pcFrom->m_puhCbf[1][ui]; |
---|
572 | m_puhCbf[2][ui]=pcFrom->m_puhCbf[2][ui]; |
---|
573 | m_pbIPCMFlag[ui] = pcFrom->m_pbIPCMFlag[ui]; |
---|
574 | #if H_3D_DIM_SDC |
---|
575 | m_pbSDCFlag[ui] = pcFrom->m_pbSDCFlag[ui]; |
---|
576 | #endif |
---|
577 | #if LGE_INTER_SDC_E0156 |
---|
578 | m_pbInterSDCFlag[ui] = pcFrom->m_pbInterSDCFlag[ui]; |
---|
579 | #endif |
---|
580 | } |
---|
581 | |
---|
582 | Int firstElement = max<Int>( partStartIdx, 0 ); |
---|
583 | numElements = m_uiNumPartition - firstElement; |
---|
584 | |
---|
585 | if ( numElements > 0 ) |
---|
586 | { |
---|
587 | memset( m_skipFlag + firstElement, false, numElements * sizeof( *m_skipFlag ) ); |
---|
588 | |
---|
589 | memset( m_pePartSize + firstElement, SIZE_NONE, numElements * sizeof( *m_pePartSize ) ); |
---|
590 | memset( m_pePredMode + firstElement, MODE_NONE, numElements * sizeof( *m_pePredMode ) ); |
---|
591 | memset( m_CUTransquantBypass+ firstElement, false, numElements * sizeof( *m_CUTransquantBypass) ); |
---|
592 | memset( m_puhDepth + firstElement, 0, numElements * sizeof( *m_puhDepth ) ); |
---|
593 | memset( m_puhTrIdx + firstElement, 0, numElements * sizeof( *m_puhTrIdx ) ); |
---|
594 | memset( m_puhTransformSkip[0] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[0]) ); |
---|
595 | memset( m_puhTransformSkip[1] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[1]) ); |
---|
596 | memset( m_puhTransformSkip[2] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[2]) ); |
---|
597 | memset( m_puhWidth + firstElement, g_uiMaxCUWidth, numElements * sizeof( *m_puhWidth ) ); |
---|
598 | memset( m_puhHeight + firstElement, g_uiMaxCUHeight, numElements * sizeof( *m_puhHeight ) ); |
---|
599 | memset( m_apiMVPIdx[0] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[0] ) ); |
---|
600 | memset( m_apiMVPIdx[1] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[1] ) ); |
---|
601 | memset( m_apiMVPNum[0] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[0] ) ); |
---|
602 | memset( m_apiMVPNum[1] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[1] ) ); |
---|
603 | memset( m_phQP + firstElement, getSlice()->getSliceQp(), numElements * sizeof( *m_phQP ) ); |
---|
604 | memset( m_pbMergeFlag + firstElement, false, numElements * sizeof( *m_pbMergeFlag ) ); |
---|
605 | memset( m_puhMergeIndex + firstElement, 0, numElements * sizeof( *m_puhMergeIndex ) ); |
---|
606 | #if H_3D_VSP |
---|
607 | memset( m_piVSPFlag + firstElement, 0, numElements * sizeof( *m_piVSPFlag ) ); |
---|
608 | #endif |
---|
609 | memset( m_puhLumaIntraDir + firstElement, DC_IDX, numElements * sizeof( *m_puhLumaIntraDir ) ); |
---|
610 | memset( m_puhChromaIntraDir + firstElement, 0, numElements * sizeof( *m_puhChromaIntraDir ) ); |
---|
611 | memset( m_puhInterDir + firstElement, 0, numElements * sizeof( *m_puhInterDir ) ); |
---|
612 | memset( m_puhCbf[0] + firstElement, 0, numElements * sizeof( *m_puhCbf[0] ) ); |
---|
613 | memset( m_puhCbf[1] + firstElement, 0, numElements * sizeof( *m_puhCbf[1] ) ); |
---|
614 | memset( m_puhCbf[2] + firstElement, 0, numElements * sizeof( *m_puhCbf[2] ) ); |
---|
615 | memset( m_pbIPCMFlag + firstElement, false, numElements * sizeof( *m_pbIPCMFlag ) ); |
---|
616 | #if H_3D_ARP |
---|
617 | memset( m_puhARPW + firstElement, 0, numElements * sizeof( UChar ) ); |
---|
618 | #endif |
---|
619 | #if H_3D_IC |
---|
620 | memset( m_pbICFlag + firstElement, false, numElements * sizeof( *m_pbICFlag ) ); |
---|
621 | #endif |
---|
622 | #if H_3D_DIM |
---|
623 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
624 | { |
---|
625 | memset( m_dimDeltaDC[i][0] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][0] ) ); |
---|
626 | memset( m_dimDeltaDC[i][1] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][1] ) ); |
---|
627 | } |
---|
628 | #if H_3D_DIM_DMM |
---|
629 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
630 | { |
---|
631 | memset( m_dmmWedgeTabIdx[i] + firstElement, 0, numElements * sizeof( *m_dmmWedgeTabIdx[i] ) ); |
---|
632 | } |
---|
633 | #if !SEC_DMM2_E0146_HHIFIX |
---|
634 | memset( m_dmm2DeltaEnd + firstElement, 0, numElements * sizeof( *m_dmm2DeltaEnd ) ); |
---|
635 | #endif |
---|
636 | memset( m_dmm3IntraTabIdx + firstElement, 0, numElements * sizeof( *m_dmm3IntraTabIdx ) ); |
---|
637 | #endif |
---|
638 | #if H_3D_DIM_RBC |
---|
639 | memset( m_pucEdgeCode + firstElement, 0, numElements * sizeof( *m_pucEdgeCode ) * RBC_MAX_EDGE_NUM_PER_4x4 ); |
---|
640 | memset( m_pucEdgeNumber + firstElement, 0, numElements * sizeof( *m_pucEdgeNumber ) ); |
---|
641 | memset( m_pucEdgeStartPos + firstElement, 0, numElements * sizeof( *m_pucEdgeStartPos ) ); |
---|
642 | memset( m_pbEdgeLeftFirst + firstElement, false, numElements * sizeof( *m_pbEdgeLeftFirst ) ); |
---|
643 | memset( m_pbEdgePartition + firstElement, false, numElements * sizeof( *m_pbEdgePartition ) * 16 ); |
---|
644 | #endif |
---|
645 | #if H_3D_DIM_SDC |
---|
646 | memset( m_pbSDCFlag + firstElement, 0, numElements * sizeof( *m_pbSDCFlag ) ); |
---|
647 | memset( m_apSegmentDCOffset[0] + firstElement, 0, numElements * sizeof( *m_apSegmentDCOffset[0] ) ); |
---|
648 | memset( m_apSegmentDCOffset[1] + firstElement, 0, numElements * sizeof( *m_apSegmentDCOffset[1] ) ); |
---|
649 | #endif |
---|
650 | #endif |
---|
651 | #if LGE_INTER_SDC_E0156 |
---|
652 | memset( m_pbInterSDCFlag + firstElement, 0, numElements * sizeof( *m_pbInterSDCFlag ) ); |
---|
653 | for( Int i = 0; i < 4; i++ ) |
---|
654 | { |
---|
655 | memset( m_apSegmentInterDCOffset[i] + firstElement, 0, numElements * sizeof( *m_apSegmentInterDCOffset[i] ) ); |
---|
656 | } |
---|
657 | #endif |
---|
658 | } |
---|
659 | |
---|
660 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight; |
---|
661 | if ( 0 >= partStartIdx ) |
---|
662 | { |
---|
663 | m_acCUMvField[0].clearMvField(); |
---|
664 | m_acCUMvField[1].clearMvField(); |
---|
665 | memset( m_pcTrCoeffY , 0, sizeof( TCoeff ) * uiTmp ); |
---|
666 | #if ADAPTIVE_QP_SELECTION |
---|
667 | memset( m_pcArlCoeffY , 0, sizeof( Int ) * uiTmp ); |
---|
668 | #endif |
---|
669 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
---|
670 | uiTmp >>= 2; |
---|
671 | memset( m_pcTrCoeffCb, 0, sizeof( TCoeff ) * uiTmp ); |
---|
672 | memset( m_pcTrCoeffCr, 0, sizeof( TCoeff ) * uiTmp ); |
---|
673 | #if ADAPTIVE_QP_SELECTION |
---|
674 | memset( m_pcArlCoeffCb, 0, sizeof( Int ) * uiTmp ); |
---|
675 | memset( m_pcArlCoeffCr, 0, sizeof( Int ) * uiTmp ); |
---|
676 | #endif |
---|
677 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
---|
678 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
---|
679 | } |
---|
680 | else |
---|
681 | { |
---|
682 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
---|
683 | m_acCUMvField[0].copyFrom(&pcFrom->m_acCUMvField[0],m_uiNumPartition,0); |
---|
684 | m_acCUMvField[1].copyFrom(&pcFrom->m_acCUMvField[1],m_uiNumPartition,0); |
---|
685 | for(Int i=0; i<uiTmp; i++) |
---|
686 | { |
---|
687 | m_pcTrCoeffY[i]=pcFrom->m_pcTrCoeffY[i]; |
---|
688 | #if ADAPTIVE_QP_SELECTION |
---|
689 | m_pcArlCoeffY[i]=pcFrom->m_pcArlCoeffY[i]; |
---|
690 | #endif |
---|
691 | m_pcIPCMSampleY[i]=pcFrom->m_pcIPCMSampleY[i]; |
---|
692 | } |
---|
693 | for(Int i=0; i<(uiTmp>>2); i++) |
---|
694 | { |
---|
695 | m_pcTrCoeffCb[i]=pcFrom->m_pcTrCoeffCb[i]; |
---|
696 | m_pcTrCoeffCr[i]=pcFrom->m_pcTrCoeffCr[i]; |
---|
697 | #if ADAPTIVE_QP_SELECTION |
---|
698 | m_pcArlCoeffCb[i]=pcFrom->m_pcArlCoeffCb[i]; |
---|
699 | m_pcArlCoeffCr[i]=pcFrom->m_pcArlCoeffCr[i]; |
---|
700 | #endif |
---|
701 | m_pcIPCMSampleCb[i]=pcFrom->m_pcIPCMSampleCb[i]; |
---|
702 | m_pcIPCMSampleCr[i]=pcFrom->m_pcIPCMSampleCr[i]; |
---|
703 | } |
---|
704 | } |
---|
705 | |
---|
706 | // Setting neighbor CU |
---|
707 | m_pcCULeft = NULL; |
---|
708 | m_pcCUAbove = NULL; |
---|
709 | m_pcCUAboveLeft = NULL; |
---|
710 | m_pcCUAboveRight = NULL; |
---|
711 | |
---|
712 | m_apcCUColocated[0] = NULL; |
---|
713 | m_apcCUColocated[1] = NULL; |
---|
714 | |
---|
715 | UInt uiWidthInCU = pcPic->getFrameWidthInCU(); |
---|
716 | if ( m_uiCUAddr % uiWidthInCU ) |
---|
717 | { |
---|
718 | m_pcCULeft = pcPic->getCU( m_uiCUAddr - 1 ); |
---|
719 | } |
---|
720 | |
---|
721 | if ( m_uiCUAddr / uiWidthInCU ) |
---|
722 | { |
---|
723 | m_pcCUAbove = pcPic->getCU( m_uiCUAddr - uiWidthInCU ); |
---|
724 | } |
---|
725 | |
---|
726 | if ( m_pcCULeft && m_pcCUAbove ) |
---|
727 | { |
---|
728 | m_pcCUAboveLeft = pcPic->getCU( m_uiCUAddr - uiWidthInCU - 1 ); |
---|
729 | } |
---|
730 | |
---|
731 | if ( m_pcCUAbove && ( (m_uiCUAddr%uiWidthInCU) < (uiWidthInCU-1) ) ) |
---|
732 | { |
---|
733 | m_pcCUAboveRight = pcPic->getCU( m_uiCUAddr - uiWidthInCU + 1 ); |
---|
734 | } |
---|
735 | |
---|
736 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) |
---|
737 | { |
---|
738 | m_apcCUColocated[0] = getSlice()->getRefPic( REF_PIC_LIST_0, 0)->getCU( m_uiCUAddr ); |
---|
739 | } |
---|
740 | |
---|
741 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) |
---|
742 | { |
---|
743 | m_apcCUColocated[1] = getSlice()->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr ); |
---|
744 | } |
---|
745 | } |
---|
746 | |
---|
747 | /** initialize prediction data with enabling sub-LCU-level delta QP |
---|
748 | *\param uiDepth depth of the current CU |
---|
749 | *\param qp qp for the current CU |
---|
750 | *- set CU width and CU height according to depth |
---|
751 | *- set qp value according to input qp |
---|
752 | *- set last-coded qp value according to input last-coded qp |
---|
753 | */ |
---|
754 | Void TComDataCU::initEstData( UInt uiDepth, Int qp ) |
---|
755 | { |
---|
756 | m_dTotalCost = MAX_DOUBLE; |
---|
757 | m_uiTotalDistortion = 0; |
---|
758 | m_uiTotalBits = 0; |
---|
759 | m_uiTotalBins = 0; |
---|
760 | |
---|
761 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
762 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
763 | |
---|
764 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
765 | { |
---|
766 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui >= getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
767 | { |
---|
768 | m_apiMVPIdx[0][ui] = -1; |
---|
769 | m_apiMVPIdx[1][ui] = -1; |
---|
770 | m_apiMVPNum[0][ui] = -1; |
---|
771 | m_apiMVPNum[1][ui] = -1; |
---|
772 | m_puhDepth [ui] = uiDepth; |
---|
773 | m_puhWidth [ui] = uhWidth; |
---|
774 | m_puhHeight [ui] = uhHeight; |
---|
775 | m_puhTrIdx [ui] = 0; |
---|
776 | m_puhTransformSkip[0][ui] = 0; |
---|
777 | m_puhTransformSkip[1][ui] = 0; |
---|
778 | m_puhTransformSkip[2][ui] = 0; |
---|
779 | m_skipFlag[ui] = false; |
---|
780 | m_pePartSize[ui] = SIZE_NONE; |
---|
781 | m_pePredMode[ui] = MODE_NONE; |
---|
782 | m_CUTransquantBypass[ui] = false; |
---|
783 | m_pbIPCMFlag[ui] = 0; |
---|
784 | m_phQP[ui] = qp; |
---|
785 | m_pbMergeFlag[ui] = 0; |
---|
786 | m_puhMergeIndex[ui] = 0; |
---|
787 | #if H_3D_VSP |
---|
788 | m_piVSPFlag[ui] = 0; |
---|
789 | #endif |
---|
790 | m_puhLumaIntraDir[ui] = DC_IDX; |
---|
791 | m_puhChromaIntraDir[ui] = 0; |
---|
792 | m_puhInterDir[ui] = 0; |
---|
793 | m_puhCbf[0][ui] = 0; |
---|
794 | m_puhCbf[1][ui] = 0; |
---|
795 | m_puhCbf[2][ui] = 0; |
---|
796 | #if H_3D_ARP |
---|
797 | m_puhARPW[ui] = 0; |
---|
798 | #endif |
---|
799 | #if H_3D_IC |
---|
800 | m_pbICFlag[ui] = false; |
---|
801 | #endif |
---|
802 | #if H_3D_DIM |
---|
803 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
804 | { |
---|
805 | m_dimDeltaDC[i][0] [ui] = 0; |
---|
806 | m_dimDeltaDC[i][1] [ui] = 0; |
---|
807 | } |
---|
808 | #if H_3D_DIM_DMM |
---|
809 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
810 | { |
---|
811 | m_dmmWedgeTabIdx[i] [ui] = 0; |
---|
812 | } |
---|
813 | #if !SEC_DMM2_E0146_HHIFIX |
---|
814 | m_dmm2DeltaEnd [ui] = 0; |
---|
815 | #endif |
---|
816 | m_dmm3IntraTabIdx [ui] = 0; |
---|
817 | #endif |
---|
818 | #if H_3D_DIM_SDC |
---|
819 | m_pbSDCFlag [ui] = false; |
---|
820 | m_apSegmentDCOffset[0][ui] = 0; |
---|
821 | m_apSegmentDCOffset[1][ui] = 0; |
---|
822 | #endif |
---|
823 | #endif |
---|
824 | #if LGE_INTER_SDC_E0156 |
---|
825 | m_pbInterSDCFlag[ui] = false; |
---|
826 | for( Int i = 0; i < 4; i++ ) |
---|
827 | { |
---|
828 | m_apSegmentInterDCOffset[i][ui] = 0; |
---|
829 | } |
---|
830 | #endif |
---|
831 | } |
---|
832 | } |
---|
833 | |
---|
834 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU >= getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
835 | { |
---|
836 | m_acCUMvField[0].clearMvField(); |
---|
837 | m_acCUMvField[1].clearMvField(); |
---|
838 | UInt uiTmp = uhWidth*uhHeight; |
---|
839 | |
---|
840 | memset( m_pcTrCoeffY, 0, uiTmp * sizeof( *m_pcTrCoeffY ) ); |
---|
841 | #if ADAPTIVE_QP_SELECTION |
---|
842 | memset( m_pcArlCoeffY , 0, uiTmp * sizeof( *m_pcArlCoeffY ) ); |
---|
843 | #endif |
---|
844 | memset( m_pcIPCMSampleY, 0, uiTmp * sizeof( *m_pcIPCMSampleY ) ); |
---|
845 | |
---|
846 | uiTmp>>=2; |
---|
847 | memset( m_pcTrCoeffCb, 0, uiTmp * sizeof( *m_pcTrCoeffCb ) ); |
---|
848 | memset( m_pcTrCoeffCr, 0, uiTmp * sizeof( *m_pcTrCoeffCr ) ); |
---|
849 | #if ADAPTIVE_QP_SELECTION |
---|
850 | memset( m_pcArlCoeffCb, 0, uiTmp * sizeof( *m_pcArlCoeffCb ) ); |
---|
851 | memset( m_pcArlCoeffCr, 0, uiTmp * sizeof( *m_pcArlCoeffCr ) ); |
---|
852 | #endif |
---|
853 | memset( m_pcIPCMSampleCb, 0, uiTmp * sizeof( *m_pcIPCMSampleCb ) ); |
---|
854 | memset( m_pcIPCMSampleCr, 0, uiTmp * sizeof( *m_pcIPCMSampleCr ) ); |
---|
855 | } |
---|
856 | } |
---|
857 | |
---|
858 | |
---|
859 | // initialize Sub partition |
---|
860 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ) |
---|
861 | { |
---|
862 | assert( uiPartUnitIdx<4 ); |
---|
863 | |
---|
864 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
---|
865 | |
---|
866 | m_pcPic = pcCU->getPic(); |
---|
867 | m_pcSlice = m_pcPic->getSlice(m_pcPic->getCurrSliceIdx()); |
---|
868 | m_uiCUAddr = pcCU->getAddr(); |
---|
869 | m_uiAbsIdxInLCU = pcCU->getZorderIdxInCU() + uiPartOffset; |
---|
870 | |
---|
871 | m_uiCUPelX = pcCU->getCUPelX() + ( g_uiMaxCUWidth>>uiDepth )*( uiPartUnitIdx & 1 ); |
---|
872 | m_uiCUPelY = pcCU->getCUPelY() + ( g_uiMaxCUHeight>>uiDepth )*( uiPartUnitIdx >> 1 ); |
---|
873 | |
---|
874 | m_dTotalCost = MAX_DOUBLE; |
---|
875 | m_uiTotalDistortion = 0; |
---|
876 | m_uiTotalBits = 0; |
---|
877 | m_uiTotalBins = 0; |
---|
878 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
---|
879 | |
---|
880 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
881 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
882 | |
---|
883 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
884 | memset( m_phQP, qp, sizeInChar ); |
---|
885 | |
---|
886 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
887 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
888 | #if H_3D_VSP |
---|
889 | memset( m_piVSPFlag, 0, sizeof( Char ) * m_uiNumPartition ); |
---|
890 | #endif |
---|
891 | memset( m_puhLumaIntraDir, DC_IDX, iSizeInUchar ); |
---|
892 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
---|
893 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
894 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
895 | memset( m_puhTransformSkip[0], 0, iSizeInUchar ); |
---|
896 | memset( m_puhTransformSkip[1], 0, iSizeInUchar ); |
---|
897 | memset( m_puhTransformSkip[2], 0, iSizeInUchar ); |
---|
898 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
---|
899 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
---|
900 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
---|
901 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
---|
902 | #if H_3D_NBDV |
---|
903 | m_pDvInfo->bDV = false; |
---|
904 | #endif |
---|
905 | #if H_3D_ARP |
---|
906 | memset( m_puhARPW, 0, iSizeInUchar ); |
---|
907 | #endif |
---|
908 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
909 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
910 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
911 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
912 | memset( m_pbIPCMFlag, 0, iSizeInBool ); |
---|
913 | #if H_3D_IC |
---|
914 | memset( m_pbICFlag, 0, iSizeInBool ); |
---|
915 | #endif |
---|
916 | #if H_3D_DIM |
---|
917 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
918 | { |
---|
919 | memset( m_dimDeltaDC[i][0], 0, sizeof(Pel ) * m_uiNumPartition ); |
---|
920 | memset( m_dimDeltaDC[i][1], 0, sizeof(Pel ) * m_uiNumPartition ); |
---|
921 | } |
---|
922 | #if H_3D_DIM_DMM |
---|
923 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
924 | { |
---|
925 | memset( m_dmmWedgeTabIdx[i], 0, sizeof(UInt) * m_uiNumPartition ); |
---|
926 | } |
---|
927 | #if !SEC_DMM2_E0146_HHIFIX |
---|
928 | memset( m_dmm2DeltaEnd , 0, sizeof(Int ) * m_uiNumPartition ); |
---|
929 | #endif |
---|
930 | memset( m_dmm3IntraTabIdx, 0, sizeof(UInt) * m_uiNumPartition ); |
---|
931 | #endif |
---|
932 | #if H_3D_DIM_RBC |
---|
933 | memset( m_pucEdgeCode , 0, iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); |
---|
934 | memset( m_pucEdgeNumber , 0, iSizeInUchar ); |
---|
935 | memset( m_pucEdgeStartPos, 0, iSizeInUchar ); |
---|
936 | memset( m_pbEdgeLeftFirst, 0, iSizeInBool ); |
---|
937 | memset( m_pbEdgePartition, 0, iSizeInBool * 16 ); |
---|
938 | #endif |
---|
939 | #if H_3D_DIM_SDC |
---|
940 | memset( m_pbSDCFlag, 0, sizeof(Bool) * m_uiNumPartition ); |
---|
941 | memset( m_apSegmentDCOffset[0], 0, sizeof(Pel) * m_uiNumPartition ); |
---|
942 | memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition ); |
---|
943 | #endif |
---|
944 | #endif |
---|
945 | #if LGE_INTER_SDC_E0156 |
---|
946 | memset( m_pbInterSDCFlag, 0, sizeof( Bool ) * m_uiNumPartition ); |
---|
947 | for( Int i = 0; i < 4; i++ ) |
---|
948 | { |
---|
949 | memset( m_apSegmentInterDCOffset[i], 0, sizeof( Int ) * m_uiNumPartition ); |
---|
950 | } |
---|
951 | #endif |
---|
952 | |
---|
953 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
954 | { |
---|
955 | m_skipFlag[ui] = false; |
---|
956 | m_pePartSize[ui] = SIZE_NONE; |
---|
957 | m_pePredMode[ui] = MODE_NONE; |
---|
958 | m_CUTransquantBypass[ui] = false; |
---|
959 | m_apiMVPIdx[0][ui] = -1; |
---|
960 | m_apiMVPIdx[1][ui] = -1; |
---|
961 | m_apiMVPNum[0][ui] = -1; |
---|
962 | m_apiMVPNum[1][ui] = -1; |
---|
963 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui<getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
964 | { |
---|
965 | m_apiMVPIdx[0][ui] = pcCU->m_apiMVPIdx[0][uiPartOffset+ui]; |
---|
966 | m_apiMVPIdx[1][ui] = pcCU->m_apiMVPIdx[1][uiPartOffset+ui];; |
---|
967 | m_apiMVPNum[0][ui] = pcCU->m_apiMVPNum[0][uiPartOffset+ui];; |
---|
968 | m_apiMVPNum[1][ui] = pcCU->m_apiMVPNum[1][uiPartOffset+ui];; |
---|
969 | m_puhDepth [ui] = pcCU->getDepth(uiPartOffset+ui); |
---|
970 | m_puhWidth [ui] = pcCU->getWidth(uiPartOffset+ui); |
---|
971 | m_puhHeight [ui] = pcCU->getHeight(uiPartOffset+ui); |
---|
972 | m_puhTrIdx [ui] = pcCU->getTransformIdx(uiPartOffset+ui); |
---|
973 | m_puhTransformSkip[0][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_LUMA); |
---|
974 | m_puhTransformSkip[1][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_U); |
---|
975 | m_puhTransformSkip[2][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_V); |
---|
976 | m_skipFlag[ui] = pcCU->getSkipFlag(uiPartOffset+ui); |
---|
977 | m_pePartSize[ui] = pcCU->getPartitionSize(uiPartOffset+ui); |
---|
978 | m_pePredMode[ui] = pcCU->getPredictionMode(uiPartOffset+ui); |
---|
979 | m_CUTransquantBypass[ui] = pcCU->getCUTransquantBypass(uiPartOffset+ui); |
---|
980 | m_pbIPCMFlag[ui]=pcCU->m_pbIPCMFlag[uiPartOffset+ui]; |
---|
981 | m_phQP[ui] = pcCU->m_phQP[uiPartOffset+ui]; |
---|
982 | m_pbMergeFlag[ui]=pcCU->m_pbMergeFlag[uiPartOffset+ui]; |
---|
983 | m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui]; |
---|
984 | #if H_3D_VSP |
---|
985 | m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui]; |
---|
986 | m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui]; |
---|
987 | #endif |
---|
988 | m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui]; |
---|
989 | m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui]; |
---|
990 | m_puhInterDir[ui]=pcCU->m_puhInterDir[uiPartOffset+ui]; |
---|
991 | m_puhCbf[0][ui]=pcCU->m_puhCbf[0][uiPartOffset+ui]; |
---|
992 | m_puhCbf[1][ui]=pcCU->m_puhCbf[1][uiPartOffset+ui]; |
---|
993 | m_puhCbf[2][ui]=pcCU->m_puhCbf[2][uiPartOffset+ui]; |
---|
994 | |
---|
995 | #if H_3D_ARP |
---|
996 | m_puhARPW [ui] = pcCU->getARPW( uiPartOffset+ui ); |
---|
997 | #endif |
---|
998 | #if H_3D_IC |
---|
999 | m_pbICFlag [ui] = pcCU->m_pbICFlag[uiPartOffset+ui]; |
---|
1000 | #endif |
---|
1001 | #if H_3D_DIM |
---|
1002 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
1003 | { |
---|
1004 | m_dimDeltaDC[i][0] [ui] = pcCU->m_dimDeltaDC[i][0] [uiPartOffset+ui]; |
---|
1005 | m_dimDeltaDC[i][1] [ui] = pcCU->m_dimDeltaDC[i][1] [uiPartOffset+ui]; |
---|
1006 | } |
---|
1007 | #if H_3D_DIM_DMM |
---|
1008 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1009 | { |
---|
1010 | m_dmmWedgeTabIdx[i] [ui] = pcCU->m_dmmWedgeTabIdx[i] [uiPartOffset+ui]; |
---|
1011 | } |
---|
1012 | #if !SEC_DMM2_E0146_HHIFIX |
---|
1013 | m_dmm2DeltaEnd [ui] = pcCU->m_dmm2DeltaEnd [uiPartOffset+ui]; |
---|
1014 | #endif |
---|
1015 | m_dmm3IntraTabIdx [ui] = pcCU->m_dmm3IntraTabIdx[uiPartOffset+ui]; |
---|
1016 | #endif |
---|
1017 | #if H_3D_DIM_SDC |
---|
1018 | m_pbSDCFlag [ui] = pcCU->m_pbSDCFlag [ uiPartOffset + ui ]; |
---|
1019 | m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0] [ uiPartOffset + ui ]; |
---|
1020 | m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ]; |
---|
1021 | #endif |
---|
1022 | #endif |
---|
1023 | #if LGE_INTER_SDC_E0156 |
---|
1024 | m_pbInterSDCFlag [ui] = pcCU->m_pbInterSDCFlag [ uiPartOffset + ui ]; |
---|
1025 | for( Int i = 0; i < 4; i++ ) |
---|
1026 | { |
---|
1027 | m_apSegmentInterDCOffset[i][ui] = pcCU->m_apSegmentInterDCOffset[i][ uiPartOffset + ui ]; |
---|
1028 | } |
---|
1029 | #endif |
---|
1030 | } |
---|
1031 | } |
---|
1032 | UInt uiTmp = uhWidth*uhHeight; |
---|
1033 | memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); |
---|
1034 | #if ADAPTIVE_QP_SELECTION |
---|
1035 | memset( m_pcArlCoeffY , 0, sizeof(Int)*uiTmp ); |
---|
1036 | #endif |
---|
1037 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
---|
1038 | uiTmp >>= 2; |
---|
1039 | memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); |
---|
1040 | memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); |
---|
1041 | #if ADAPTIVE_QP_SELECTION |
---|
1042 | memset( m_pcArlCoeffCb, 0, sizeof(Int)*uiTmp ); |
---|
1043 | memset( m_pcArlCoeffCr, 0, sizeof(Int)*uiTmp ); |
---|
1044 | #endif |
---|
1045 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
---|
1046 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
---|
1047 | m_acCUMvField[0].clearMvField(); |
---|
1048 | m_acCUMvField[1].clearMvField(); |
---|
1049 | |
---|
1050 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU<getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
1051 | { |
---|
1052 | // Part of this CU contains data from an older slice. Now copy in that data. |
---|
1053 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1054 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1055 | TComDataCU * bigCU = getPic()->getCU(getAddr()); |
---|
1056 | Int minui = uiPartOffset; |
---|
1057 | minui = -minui; |
---|
1058 | pcCU->m_acCUMvField[0].copyTo(&m_acCUMvField[0],minui,uiPartOffset,m_uiNumPartition); |
---|
1059 | pcCU->m_acCUMvField[1].copyTo(&m_acCUMvField[1],minui,uiPartOffset,m_uiNumPartition); |
---|
1060 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*m_uiAbsIdxInLCU/pcCU->getPic()->getNumPartInCU(); |
---|
1061 | uiTmp = uhWidth*uhHeight; |
---|
1062 | for(Int i=0; i<uiTmp; i++) |
---|
1063 | { |
---|
1064 | m_pcTrCoeffY[i]=bigCU->m_pcTrCoeffY[uiCoffOffset+i]; |
---|
1065 | #if ADAPTIVE_QP_SELECTION |
---|
1066 | m_pcArlCoeffY[i]=bigCU->m_pcArlCoeffY[uiCoffOffset+i]; |
---|
1067 | #endif |
---|
1068 | m_pcIPCMSampleY[i]=bigCU->m_pcIPCMSampleY[uiCoffOffset+i]; |
---|
1069 | } |
---|
1070 | uiTmp>>=2; |
---|
1071 | uiCoffOffset>>=2; |
---|
1072 | for(Int i=0; i<uiTmp; i++) |
---|
1073 | { |
---|
1074 | m_pcTrCoeffCr[i]=bigCU->m_pcTrCoeffCr[uiCoffOffset+i]; |
---|
1075 | m_pcTrCoeffCb[i]=bigCU->m_pcTrCoeffCb[uiCoffOffset+i]; |
---|
1076 | #if ADAPTIVE_QP_SELECTION |
---|
1077 | m_pcArlCoeffCr[i]=bigCU->m_pcArlCoeffCr[uiCoffOffset+i]; |
---|
1078 | m_pcArlCoeffCb[i]=bigCU->m_pcArlCoeffCb[uiCoffOffset+i]; |
---|
1079 | #endif |
---|
1080 | m_pcIPCMSampleCb[i]=bigCU->m_pcIPCMSampleCb[uiCoffOffset+i]; |
---|
1081 | m_pcIPCMSampleCr[i]=bigCU->m_pcIPCMSampleCr[uiCoffOffset+i]; |
---|
1082 | } |
---|
1083 | } |
---|
1084 | |
---|
1085 | m_pcCULeft = pcCU->getCULeft(); |
---|
1086 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
1087 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
1088 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
1089 | |
---|
1090 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
1091 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
1092 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
---|
1093 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
---|
1094 | } |
---|
1095 | |
---|
1096 | Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1097 | { |
---|
1098 | UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); |
---|
1099 | UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
1100 | |
---|
1101 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
1102 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
1103 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); |
---|
1104 | memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); |
---|
1105 | memset( m_puhHeight + uiAbsPartIdx, uhHeight, uiSizeInUchar ); |
---|
1106 | } |
---|
1107 | |
---|
1108 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1109 | // Copy |
---|
1110 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1111 | |
---|
1112 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1113 | { |
---|
1114 | UInt uiPart = uiAbsPartIdx; |
---|
1115 | |
---|
1116 | m_pcPic = pcCU->getPic(); |
---|
1117 | m_pcSlice = pcCU->getSlice(); |
---|
1118 | m_uiCUAddr = pcCU->getAddr(); |
---|
1119 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
1120 | |
---|
1121 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1122 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1123 | |
---|
1124 | m_skipFlag=pcCU->getSkipFlag() + uiPart; |
---|
1125 | |
---|
1126 | m_phQP=pcCU->getQP() + uiPart; |
---|
1127 | m_pePartSize = pcCU->getPartitionSize() + uiPart; |
---|
1128 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
---|
1129 | m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; |
---|
1130 | |
---|
1131 | #if H_3D_NBDV |
---|
1132 | m_pDvInfo = pcCU->getDvInfo() + uiPart; |
---|
1133 | #endif |
---|
1134 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
---|
1135 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
---|
1136 | #if H_3D_VSP |
---|
1137 | m_piVSPFlag = pcCU->getVSPFlag() + uiPart; |
---|
1138 | #endif |
---|
1139 | |
---|
1140 | #if H_3D_ARP |
---|
1141 | m_puhARPW = pcCU->getARPW() + uiPart; |
---|
1142 | #endif |
---|
1143 | #if H_3D_IC |
---|
1144 | m_pbICFlag = pcCU->getICFlag() + uiPart; |
---|
1145 | #endif |
---|
1146 | |
---|
1147 | m_puhLumaIntraDir = pcCU->getLumaIntraDir() + uiPart; |
---|
1148 | m_puhChromaIntraDir = pcCU->getChromaIntraDir() + uiPart; |
---|
1149 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
---|
1150 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
---|
1151 | m_puhTransformSkip[0] = pcCU->getTransformSkip(TEXT_LUMA) + uiPart; |
---|
1152 | m_puhTransformSkip[1] = pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPart; |
---|
1153 | m_puhTransformSkip[2] = pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPart; |
---|
1154 | |
---|
1155 | m_puhCbf[0]= pcCU->getCbf(TEXT_LUMA) + uiPart; |
---|
1156 | m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U) + uiPart; |
---|
1157 | m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; |
---|
1158 | #if H_3D_DIM |
---|
1159 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
1160 | { |
---|
1161 | m_dimDeltaDC[i][0] = pcCU->getDimDeltaDC( i, 0 ) + uiPart; |
---|
1162 | m_dimDeltaDC[i][1] = pcCU->getDimDeltaDC( i, 1 ) + uiPart; |
---|
1163 | } |
---|
1164 | #if H_3D_DIM_DMM |
---|
1165 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1166 | { |
---|
1167 | m_dmmWedgeTabIdx[i] = pcCU->getDmmWedgeTabIdx( i ) + uiPart; |
---|
1168 | } |
---|
1169 | #if !SEC_DMM2_E0146_HHIFIX |
---|
1170 | m_dmm2DeltaEnd = pcCU->getDmm2DeltaEnd() + uiPart; |
---|
1171 | #endif |
---|
1172 | m_dmm3IntraTabIdx = pcCU->getDmm3IntraTabIdx() + uiPart; |
---|
1173 | #endif |
---|
1174 | #if H_3D_DIM_RBC |
---|
1175 | m_pucEdgeCode = pcCU->getEdgeCode( uiPart ); |
---|
1176 | m_pucEdgeNumber = pcCU->getEdgeNumber() + uiPart; |
---|
1177 | m_pucEdgeStartPos = pcCU->getEdgeStartPos() + uiPart; |
---|
1178 | m_pbEdgeLeftFirst = pcCU->getEdgeLeftFirst() + uiPart; |
---|
1179 | m_pbEdgePartition = pcCU->getEdgePartition( uiPart ); |
---|
1180 | #endif |
---|
1181 | #if H_3D_DIM_SDC |
---|
1182 | m_pbSDCFlag = pcCU->getSDCFlag() + uiPart; |
---|
1183 | m_apSegmentDCOffset[0] = pcCU->getSDCSegmentDCOffset(0) + uiPart; |
---|
1184 | m_apSegmentDCOffset[1] = pcCU->getSDCSegmentDCOffset(1) + uiPart; |
---|
1185 | #endif |
---|
1186 | #endif |
---|
1187 | #if LGE_INTER_SDC_E0156 |
---|
1188 | m_pbInterSDCFlag = pcCU->getInterSDCFlag() + uiPart; |
---|
1189 | for( Int i = 0; i < 4; i++ ) |
---|
1190 | { |
---|
1191 | m_apSegmentInterDCOffset[i] = pcCU->getInterSDCSegmentDCOffset( i ) + uiPart; |
---|
1192 | } |
---|
1193 | #endif |
---|
1194 | m_puhDepth=pcCU->getDepth() + uiPart; |
---|
1195 | m_puhWidth=pcCU->getWidth() + uiPart; |
---|
1196 | m_puhHeight=pcCU->getHeight() + uiPart; |
---|
1197 | |
---|
1198 | m_apiMVPIdx[0]=pcCU->getMVPIdx(REF_PIC_LIST_0) + uiPart; |
---|
1199 | m_apiMVPIdx[1]=pcCU->getMVPIdx(REF_PIC_LIST_1) + uiPart; |
---|
1200 | m_apiMVPNum[0]=pcCU->getMVPNum(REF_PIC_LIST_0) + uiPart; |
---|
1201 | m_apiMVPNum[1]=pcCU->getMVPNum(REF_PIC_LIST_1) + uiPart; |
---|
1202 | |
---|
1203 | m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; |
---|
1204 | |
---|
1205 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
1206 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
1207 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
1208 | m_pcCULeft = pcCU->getCULeft(); |
---|
1209 | |
---|
1210 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
1211 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
1212 | |
---|
1213 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1214 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1215 | |
---|
1216 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartInCU(); |
---|
1217 | |
---|
1218 | m_pcTrCoeffY = pcCU->getCoeffY() + uiCoffOffset; |
---|
1219 | #if ADAPTIVE_QP_SELECTION |
---|
1220 | m_pcArlCoeffY= pcCU->getArlCoeffY() + uiCoffOffset; |
---|
1221 | #endif |
---|
1222 | m_pcIPCMSampleY = pcCU->getPCMSampleY() + uiCoffOffset; |
---|
1223 | |
---|
1224 | uiCoffOffset >>=2; |
---|
1225 | m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset; |
---|
1226 | m_pcTrCoeffCr=pcCU->getCoeffCr() + uiCoffOffset; |
---|
1227 | #if ADAPTIVE_QP_SELECTION |
---|
1228 | m_pcArlCoeffCb=pcCU->getArlCoeffCb() + uiCoffOffset; |
---|
1229 | m_pcArlCoeffCr=pcCU->getArlCoeffCr() + uiCoffOffset; |
---|
1230 | #endif |
---|
1231 | m_pcIPCMSampleCb = pcCU->getPCMSampleCb() + uiCoffOffset; |
---|
1232 | m_pcIPCMSampleCr = pcCU->getPCMSampleCr() + uiCoffOffset; |
---|
1233 | |
---|
1234 | m_acCUMvField[0].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_0), uiPart ); |
---|
1235 | m_acCUMvField[1].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_1), uiPart ); |
---|
1236 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
---|
1237 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
---|
1238 | } |
---|
1239 | #if H_3D_NBDV |
---|
1240 | Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx) |
---|
1241 | { |
---|
1242 | m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; |
---|
1243 | } |
---|
1244 | #endif |
---|
1245 | // Copy inter prediction info from the biggest CU |
---|
1246 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList |
---|
1247 | #if H_3D_NBDV |
---|
1248 | , Bool bNBDV |
---|
1249 | #endif |
---|
1250 | ) |
---|
1251 | { |
---|
1252 | m_pcPic = pcCU->getPic(); |
---|
1253 | m_pcSlice = pcCU->getSlice(); |
---|
1254 | m_uiCUAddr = pcCU->getAddr(); |
---|
1255 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
1256 | |
---|
1257 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
1258 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() ); |
---|
1259 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInWidth() ); |
---|
1260 | |
---|
1261 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
1262 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
1263 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
1264 | m_pcCULeft = pcCU->getCULeft(); |
---|
1265 | |
---|
1266 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
1267 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
1268 | |
---|
1269 | m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; |
---|
1270 | |
---|
1271 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
---|
1272 | #if H_3D_NBDV |
---|
1273 | if(bNBDV == true) |
---|
1274 | { |
---|
1275 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
1276 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
1277 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
1278 | } |
---|
1279 | else |
---|
1280 | { |
---|
1281 | #endif |
---|
1282 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
---|
1283 | m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; |
---|
1284 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
---|
1285 | |
---|
1286 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
1287 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
1288 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
1289 | |
---|
1290 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
1291 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
1292 | #if H_3D_VSP |
---|
1293 | m_piVSPFlag = pcCU->getVSPFlag() + uiAbsPartIdx; |
---|
1294 | m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; |
---|
1295 | #endif |
---|
1296 | |
---|
1297 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
---|
1298 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
---|
1299 | |
---|
1300 | #if H_3D_ARP |
---|
1301 | m_puhARPW = pcCU->getARPW() + uiAbsPartIdx; |
---|
1302 | #endif |
---|
1303 | |
---|
1304 | m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); |
---|
1305 | |
---|
1306 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
---|
1307 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
---|
1308 | #if H_3D_NBDV |
---|
1309 | } |
---|
1310 | #endif |
---|
1311 | #if H_3D_IC |
---|
1312 | m_pbICFlag = pcCU->getICFlag() + uiAbsPartIdx; |
---|
1313 | #endif |
---|
1314 | } |
---|
1315 | |
---|
1316 | // Copy small CU to bigger CU. |
---|
1317 | // One of quarter parts overwritten by predicted sub part. |
---|
1318 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
1319 | { |
---|
1320 | assert( uiPartUnitIdx<4 ); |
---|
1321 | |
---|
1322 | m_dTotalCost += pcCU->getTotalCost(); |
---|
1323 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
---|
1324 | m_uiTotalBits += pcCU->getTotalBits(); |
---|
1325 | |
---|
1326 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
---|
1327 | |
---|
1328 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
---|
1329 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
1330 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
1331 | |
---|
1332 | Int sizeInChar = sizeof( Char ) * uiNumPartition; |
---|
1333 | memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); |
---|
1334 | memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); |
---|
1335 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); |
---|
1336 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); |
---|
1337 | memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); |
---|
1338 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
---|
1339 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
---|
1340 | #if H_3D_VSP |
---|
1341 | memcpy( m_piVSPFlag + uiOffset, pcCU->getVSPFlag(), sizeof( Char ) * uiNumPartition ); |
---|
1342 | memcpy( m_pDvInfo + uiOffset, pcCU->getDvInfo(), sizeof( *m_pDvInfo ) * uiNumPartition ); |
---|
1343 | |
---|
1344 | #endif |
---|
1345 | memcpy( m_puhLumaIntraDir + uiOffset, pcCU->getLumaIntraDir(), iSizeInUchar ); |
---|
1346 | memcpy( m_puhChromaIntraDir + uiOffset, pcCU->getChromaIntraDir(), iSizeInUchar ); |
---|
1347 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
---|
1348 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
---|
1349 | memcpy( m_puhTransformSkip[0] + uiOffset, pcCU->getTransformSkip(TEXT_LUMA), iSizeInUchar ); |
---|
1350 | memcpy( m_puhTransformSkip[1] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_U), iSizeInUchar ); |
---|
1351 | memcpy( m_puhTransformSkip[2] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_V), iSizeInUchar ); |
---|
1352 | |
---|
1353 | memcpy( m_puhCbf[0] + uiOffset, pcCU->getCbf(TEXT_LUMA) , iSizeInUchar ); |
---|
1354 | memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar ); |
---|
1355 | memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); |
---|
1356 | |
---|
1357 | #if H_3D_DIM |
---|
1358 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
1359 | { |
---|
1360 | memcpy( m_dimDeltaDC[i][0] + uiOffset, pcCU->getDimDeltaDC( i, 0 ), sizeof(Pel ) * uiNumPartition ); |
---|
1361 | memcpy( m_dimDeltaDC[i][1] + uiOffset, pcCU->getDimDeltaDC( i, 1 ), sizeof(Pel ) * uiNumPartition ); |
---|
1362 | } |
---|
1363 | #if H_3D_DIM_DMM |
---|
1364 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1365 | { |
---|
1366 | memcpy( m_dmmWedgeTabIdx[i] + uiOffset, pcCU->getDmmWedgeTabIdx( i ), sizeof(UInt) * uiNumPartition ); |
---|
1367 | } |
---|
1368 | #if !SEC_DMM2_E0146_HHIFIX |
---|
1369 | memcpy( m_dmm2DeltaEnd + uiOffset, pcCU->getDmm2DeltaEnd() , sizeof(Int ) * uiNumPartition ); |
---|
1370 | #endif |
---|
1371 | memcpy( m_dmm3IntraTabIdx + uiOffset, pcCU->getDmm3IntraTabIdx(), sizeof(UInt) * uiNumPartition ); |
---|
1372 | #endif |
---|
1373 | #if H_3D_DIM_RBC |
---|
1374 | memcpy( getEdgeCode( uiOffset ), pcCU->getEdgeCode(0), iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); |
---|
1375 | memcpy( getEdgeNumber() + uiOffset, pcCU->getEdgeNumber(), iSizeInUchar ); |
---|
1376 | memcpy( getEdgeStartPos() + uiOffset, pcCU->getEdgeStartPos(), iSizeInUchar ); |
---|
1377 | memcpy( getEdgeLeftFirst() + uiOffset, pcCU->getEdgeLeftFirst(), iSizeInBool ); |
---|
1378 | memcpy( getEdgePartition( uiOffset ), pcCU->getEdgePartition(0), iSizeInBool * 16 ); |
---|
1379 | #endif |
---|
1380 | #if H_3D_DIM_SDC |
---|
1381 | memcpy( m_pbSDCFlag + uiOffset, pcCU->getSDCFlag(), iSizeInBool ); |
---|
1382 | memcpy( m_apSegmentDCOffset[0] + uiOffset, pcCU->getSDCSegmentDCOffset(0), sizeof( Pel ) * uiNumPartition); |
---|
1383 | memcpy( m_apSegmentDCOffset[1] + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition); |
---|
1384 | #endif |
---|
1385 | #endif |
---|
1386 | #if LGE_INTER_SDC_E0156 |
---|
1387 | memcpy( m_pbInterSDCFlag + uiOffset, pcCU->getInterSDCFlag(), iSizeInBool ); |
---|
1388 | for( Int i = 0; i < 4; i++ ) |
---|
1389 | { |
---|
1390 | memcpy( m_apSegmentInterDCOffset[i] + uiOffset, pcCU->getInterSDCSegmentDCOffset( i ), sizeof( Int ) * uiNumPartition); |
---|
1391 | } |
---|
1392 | #endif |
---|
1393 | |
---|
1394 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
---|
1395 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
---|
1396 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
---|
1397 | |
---|
1398 | memcpy( m_apiMVPIdx[0] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_0), iSizeInUchar ); |
---|
1399 | memcpy( m_apiMVPIdx[1] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_1), iSizeInUchar ); |
---|
1400 | memcpy( m_apiMVPNum[0] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_0), iSizeInUchar ); |
---|
1401 | memcpy( m_apiMVPNum[1] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_1), iSizeInUchar ); |
---|
1402 | |
---|
1403 | memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); |
---|
1404 | |
---|
1405 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
1406 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
1407 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
1408 | m_pcCULeft = pcCU->getCULeft(); |
---|
1409 | |
---|
1410 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
1411 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
1412 | |
---|
1413 | m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
1414 | m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
1415 | |
---|
1416 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); |
---|
1417 | UInt uiTmp2 = uiPartUnitIdx*uiTmp; |
---|
1418 | memcpy( m_pcTrCoeffY + uiTmp2, pcCU->getCoeffY(), sizeof(TCoeff)*uiTmp ); |
---|
1419 | #if ADAPTIVE_QP_SELECTION |
---|
1420 | memcpy( m_pcArlCoeffY + uiTmp2, pcCU->getArlCoeffY(), sizeof(Int)*uiTmp ); |
---|
1421 | #endif |
---|
1422 | memcpy( m_pcIPCMSampleY + uiTmp2 , pcCU->getPCMSampleY(), sizeof(Pel) * uiTmp ); |
---|
1423 | |
---|
1424 | uiTmp >>= 2; uiTmp2>>= 2; |
---|
1425 | memcpy( m_pcTrCoeffCb + uiTmp2, pcCU->getCoeffCb(), sizeof(TCoeff)*uiTmp ); |
---|
1426 | memcpy( m_pcTrCoeffCr + uiTmp2, pcCU->getCoeffCr(), sizeof(TCoeff)*uiTmp ); |
---|
1427 | #if ADAPTIVE_QP_SELECTION |
---|
1428 | memcpy( m_pcArlCoeffCb + uiTmp2, pcCU->getArlCoeffCb(), sizeof(Int)*uiTmp ); |
---|
1429 | memcpy( m_pcArlCoeffCr + uiTmp2, pcCU->getArlCoeffCr(), sizeof(Int)*uiTmp ); |
---|
1430 | #endif |
---|
1431 | memcpy( m_pcIPCMSampleCb + uiTmp2 , pcCU->getPCMSampleCb(), sizeof(Pel) * uiTmp ); |
---|
1432 | memcpy( m_pcIPCMSampleCr + uiTmp2 , pcCU->getPCMSampleCr(), sizeof(Pel) * uiTmp ); |
---|
1433 | m_uiTotalBins += pcCU->getTotalBins(); |
---|
1434 | memcpy( m_sliceStartCU + uiOffset, pcCU->m_sliceStartCU, sizeof( UInt ) * uiNumPartition ); |
---|
1435 | memcpy( m_sliceSegmentStartCU + uiOffset, pcCU->m_sliceSegmentStartCU, sizeof( UInt ) * uiNumPartition ); |
---|
1436 | #if H_3D_ARP |
---|
1437 | memcpy( m_puhARPW + uiOffset, pcCU->getARPW(), iSizeInUchar ); |
---|
1438 | #endif |
---|
1439 | #if H_3D_IC |
---|
1440 | memcpy( m_pbICFlag + uiOffset, pcCU->getICFlag(), iSizeInBool ); |
---|
1441 | #endif |
---|
1442 | } |
---|
1443 | |
---|
1444 | // Copy current predicted part to a CU in picture. |
---|
1445 | // It is used to predict for next part |
---|
1446 | Void TComDataCU::copyToPic( UChar uhDepth ) |
---|
1447 | { |
---|
1448 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
1449 | |
---|
1450 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
1451 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
1452 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
1453 | |
---|
1454 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
1455 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
1456 | |
---|
1457 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
1458 | |
---|
1459 | memcpy( rpcCU->getSkipFlag() + m_uiAbsIdxInLCU, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); |
---|
1460 | |
---|
1461 | memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, sizeInChar ); |
---|
1462 | #if H_3D_NBDV |
---|
1463 | memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition ); |
---|
1464 | #endif |
---|
1465 | |
---|
1466 | memcpy( rpcCU->getPartitionSize() + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); |
---|
1467 | memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); |
---|
1468 | memcpy( rpcCU->getCUTransquantBypass()+ m_uiAbsIdxInLCU, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); |
---|
1469 | memcpy( rpcCU->getMergeFlag() + m_uiAbsIdxInLCU, m_pbMergeFlag, iSizeInBool ); |
---|
1470 | memcpy( rpcCU->getMergeIndex() + m_uiAbsIdxInLCU, m_puhMergeIndex, iSizeInUchar ); |
---|
1471 | #if H_3D_VSP |
---|
1472 | memcpy( rpcCU->getVSPFlag() + m_uiAbsIdxInLCU, m_piVSPFlag, sizeof( Char ) * m_uiNumPartition ); |
---|
1473 | memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof( *m_pDvInfo ) * m_uiNumPartition ); |
---|
1474 | #endif |
---|
1475 | memcpy( rpcCU->getLumaIntraDir() + m_uiAbsIdxInLCU, m_puhLumaIntraDir, iSizeInUchar ); |
---|
1476 | memcpy( rpcCU->getChromaIntraDir() + m_uiAbsIdxInLCU, m_puhChromaIntraDir, iSizeInUchar ); |
---|
1477 | memcpy( rpcCU->getInterDir() + m_uiAbsIdxInLCU, m_puhInterDir, iSizeInUchar ); |
---|
1478 | memcpy( rpcCU->getTransformIdx() + m_uiAbsIdxInLCU, m_puhTrIdx, iSizeInUchar ); |
---|
1479 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhTransformSkip[0], iSizeInUchar ); |
---|
1480 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhTransformSkip[1], iSizeInUchar ); |
---|
1481 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhTransformSkip[2], iSizeInUchar ); |
---|
1482 | |
---|
1483 | memcpy( rpcCU->getCbf(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhCbf[0], iSizeInUchar ); |
---|
1484 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhCbf[1], iSizeInUchar ); |
---|
1485 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); |
---|
1486 | |
---|
1487 | #if H_3D_DIM |
---|
1488 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
1489 | { |
---|
1490 | memcpy( rpcCU->getDimDeltaDC( i, 0 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][0], sizeof(Pel ) * m_uiNumPartition ); |
---|
1491 | memcpy( rpcCU->getDimDeltaDC( i, 1 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][1], sizeof(Pel ) * m_uiNumPartition ); |
---|
1492 | } |
---|
1493 | #if H_3D_DIM_DMM |
---|
1494 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1495 | { |
---|
1496 | memcpy( rpcCU->getDmmWedgeTabIdx( i ) + m_uiAbsIdxInLCU, m_dmmWedgeTabIdx[i], sizeof(UInt) * m_uiNumPartition ); |
---|
1497 | } |
---|
1498 | #if !SEC_DMM2_E0146_HHIFIX |
---|
1499 | memcpy( rpcCU->getDmm2DeltaEnd() + m_uiAbsIdxInLCU, m_dmm2DeltaEnd , sizeof(Int ) * m_uiNumPartition ); |
---|
1500 | #endif |
---|
1501 | memcpy( rpcCU->getDmm3IntraTabIdx() + m_uiAbsIdxInLCU, m_dmm3IntraTabIdx, sizeof(UInt) * m_uiNumPartition ); |
---|
1502 | #endif |
---|
1503 | #if H_3D_DIM_RBC |
---|
1504 | memcpy( rpcCU->getEdgeCode( m_uiAbsIdxInLCU ), m_pucEdgeCode, iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); |
---|
1505 | memcpy( rpcCU->getEdgeNumber() + m_uiAbsIdxInLCU, m_pucEdgeNumber, iSizeInUchar ); |
---|
1506 | memcpy( rpcCU->getEdgeStartPos() + m_uiAbsIdxInLCU, m_pucEdgeStartPos, iSizeInUchar ); |
---|
1507 | memcpy( rpcCU->getEdgeLeftFirst() + m_uiAbsIdxInLCU, m_pbEdgeLeftFirst, iSizeInBool ); |
---|
1508 | memcpy( rpcCU->getEdgePartition( m_uiAbsIdxInLCU ), m_pbEdgePartition, iSizeInBool * 16 ); |
---|
1509 | #endif |
---|
1510 | #if H_3D_DIM_SDC |
---|
1511 | memcpy( rpcCU->getSDCFlag() + m_uiAbsIdxInLCU, m_pbSDCFlag, iSizeInBool ); |
---|
1512 | memcpy( rpcCU->getSDCSegmentDCOffset(0) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[0], sizeof( Pel ) * m_uiNumPartition); |
---|
1513 | memcpy( rpcCU->getSDCSegmentDCOffset(1) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition); |
---|
1514 | #endif |
---|
1515 | #endif |
---|
1516 | #if LGE_INTER_SDC_E0156 |
---|
1517 | memcpy( rpcCU->getInterSDCFlag() + m_uiAbsIdxInLCU, m_pbInterSDCFlag, iSizeInBool ); |
---|
1518 | for( Int i = 0;i < 4; i++ ) |
---|
1519 | { |
---|
1520 | memcpy( rpcCU->getInterSDCSegmentDCOffset( i ) + m_uiAbsIdxInLCU, m_apSegmentInterDCOffset[i], sizeof( Int ) * m_uiNumPartition); |
---|
1521 | } |
---|
1522 | #endif |
---|
1523 | memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); |
---|
1524 | memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); |
---|
1525 | memcpy( rpcCU->getHeight() + m_uiAbsIdxInLCU, m_puhHeight, iSizeInUchar ); |
---|
1526 | |
---|
1527 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPIdx[0], iSizeInUchar ); |
---|
1528 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPIdx[1], iSizeInUchar ); |
---|
1529 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPNum[0], iSizeInUchar ); |
---|
1530 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPNum[1], iSizeInUchar ); |
---|
1531 | |
---|
1532 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU ); |
---|
1533 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU ); |
---|
1534 | |
---|
1535 | memcpy( rpcCU->getIPCMFlag() + m_uiAbsIdxInLCU, m_pbIPCMFlag, iSizeInBool ); |
---|
1536 | |
---|
1537 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); |
---|
1538 | UInt uiTmp2 = m_uiAbsIdxInLCU*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
1539 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
1540 | #if ADAPTIVE_QP_SELECTION |
---|
1541 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
---|
1542 | #endif |
---|
1543 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof(Pel)*uiTmp ); |
---|
1544 | |
---|
1545 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
1546 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
1547 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
1548 | #if ADAPTIVE_QP_SELECTION |
---|
1549 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
---|
1550 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
---|
1551 | #endif |
---|
1552 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
---|
1553 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
---|
1554 | rpcCU->getTotalBins() = m_uiTotalBins; |
---|
1555 | memcpy( rpcCU->m_sliceStartCU + m_uiAbsIdxInLCU, m_sliceStartCU, sizeof( UInt ) * m_uiNumPartition ); |
---|
1556 | memcpy( rpcCU->m_sliceSegmentStartCU + m_uiAbsIdxInLCU, m_sliceSegmentStartCU, sizeof( UInt ) * m_uiNumPartition ); |
---|
1557 | #if H_3D_ARP |
---|
1558 | memcpy( rpcCU->getARPW() + m_uiAbsIdxInLCU, m_puhARPW, iSizeInUchar ); |
---|
1559 | #endif |
---|
1560 | #if H_3D_IC |
---|
1561 | memcpy( rpcCU->getICFlag() + m_uiAbsIdxInLCU, m_pbICFlag, iSizeInBool ); |
---|
1562 | #endif |
---|
1563 | } |
---|
1564 | |
---|
1565 | Void TComDataCU::copyToPic( UChar uhDepth, UInt uiPartIdx, UInt uiPartDepth ) |
---|
1566 | { |
---|
1567 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
1568 | UInt uiQNumPart = m_uiNumPartition>>(uiPartDepth<<1); |
---|
1569 | |
---|
1570 | UInt uiPartStart = uiPartIdx*uiQNumPart; |
---|
1571 | UInt uiPartOffset = m_uiAbsIdxInLCU + uiPartStart; |
---|
1572 | |
---|
1573 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
1574 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
1575 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
1576 | |
---|
1577 | Int iSizeInUchar = sizeof( UChar ) * uiQNumPart; |
---|
1578 | Int iSizeInBool = sizeof( Bool ) * uiQNumPart; |
---|
1579 | |
---|
1580 | Int sizeInChar = sizeof( Char ) * uiQNumPart; |
---|
1581 | memcpy( rpcCU->getSkipFlag() + uiPartOffset, m_skipFlag, sizeof( *m_skipFlag ) * uiQNumPart ); |
---|
1582 | |
---|
1583 | memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, sizeInChar ); |
---|
1584 | memcpy( rpcCU->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( *m_pePartSize ) * uiQNumPart ); |
---|
1585 | memcpy( rpcCU->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( *m_pePredMode ) * uiQNumPart ); |
---|
1586 | memcpy( rpcCU->getCUTransquantBypass()+ uiPartOffset, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * uiQNumPart ); |
---|
1587 | memcpy( rpcCU->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); |
---|
1588 | memcpy( rpcCU->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); |
---|
1589 | #if H_3D_VSP |
---|
1590 | memcpy( rpcCU->getVSPFlag() + uiPartOffset, m_piVSPFlag, sizeof(Char) * uiQNumPart ); |
---|
1591 | #endif |
---|
1592 | memcpy( rpcCU->getLumaIntraDir() + uiPartOffset, m_puhLumaIntraDir, iSizeInUchar ); |
---|
1593 | memcpy( rpcCU->getChromaIntraDir() + uiPartOffset, m_puhChromaIntraDir, iSizeInUchar ); |
---|
1594 | memcpy( rpcCU->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); |
---|
1595 | memcpy( rpcCU->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); |
---|
1596 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + uiPartOffset, m_puhTransformSkip[0], iSizeInUchar ); |
---|
1597 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhTransformSkip[1], iSizeInUchar ); |
---|
1598 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhTransformSkip[2], iSizeInUchar ); |
---|
1599 | memcpy( rpcCU->getCbf(TEXT_LUMA) + uiPartOffset, m_puhCbf[0], iSizeInUchar ); |
---|
1600 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar ); |
---|
1601 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); |
---|
1602 | |
---|
1603 | #if H_3D_DIM |
---|
1604 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1605 | { |
---|
1606 | memcpy( rpcCU->getDimDeltaDC( i, 0 ) + uiPartOffset, m_dimDeltaDC[i][0], sizeof(Pel ) * uiQNumPart ); |
---|
1607 | memcpy( rpcCU->getDimDeltaDC( i, 1 ) + uiPartOffset, m_dimDeltaDC[i][1], sizeof(Pel ) * uiQNumPart ); |
---|
1608 | } |
---|
1609 | #if H_3D_DIM_DMM |
---|
1610 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1611 | { |
---|
1612 | memcpy( rpcCU->getDmmWedgeTabIdx( i ) + uiPartOffset, m_dmmWedgeTabIdx[i], sizeof(UInt) * uiQNumPart ); |
---|
1613 | } |
---|
1614 | #if !SEC_DMM2_E0146_HHIFIX |
---|
1615 | memcpy( rpcCU->getDmm2DeltaEnd() + uiPartOffset, m_dmm2DeltaEnd , sizeof(Int ) * uiQNumPart ); |
---|
1616 | #endif |
---|
1617 | memcpy( rpcCU->getDmm3IntraTabIdx() + uiPartOffset, m_dmm3IntraTabIdx, sizeof(UInt) * uiQNumPart ); |
---|
1618 | #endif |
---|
1619 | #if H_3D_DIM_RBC |
---|
1620 | memcpy( rpcCU->getEdgeCode( uiPartOffset ), m_pucEdgeCode, iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); |
---|
1621 | memcpy( rpcCU->getEdgeNumber() + uiPartOffset, m_pucEdgeNumber, iSizeInUchar ); |
---|
1622 | memcpy( rpcCU->getEdgeStartPos() + uiPartOffset, m_pucEdgeStartPos, iSizeInUchar ); |
---|
1623 | memcpy( rpcCU->getEdgeLeftFirst() + uiPartOffset, m_pbEdgeLeftFirst, iSizeInBool ); |
---|
1624 | memcpy( rpcCU->getEdgePartition( uiPartOffset ), m_pbEdgePartition, iSizeInBool * 16 ); |
---|
1625 | #endif |
---|
1626 | #if H_3D_DIM_SDC |
---|
1627 | memcpy( rpcCU->getSDCFlag() + uiPartOffset, m_pbSDCFlag, iSizeInBool ); |
---|
1628 | memcpy( rpcCU->getSDCSegmentDCOffset(0) + uiPartOffset, m_apSegmentDCOffset[0], sizeof( Pel ) * uiQNumPart); |
---|
1629 | memcpy( rpcCU->getSDCSegmentDCOffset(1) + uiPartOffset, m_apSegmentDCOffset[1], sizeof( Pel ) * uiQNumPart); |
---|
1630 | #endif |
---|
1631 | #endif |
---|
1632 | #if LGE_INTER_SDC_E0156 |
---|
1633 | memcpy( rpcCU->getInterSDCFlag() + uiPartOffset, m_pbInterSDCFlag, iSizeInBool ); |
---|
1634 | for( Int i = 0; i < 4; i++ ) |
---|
1635 | { |
---|
1636 | memcpy( rpcCU->getInterSDCSegmentDCOffset( i ) + uiPartOffset, m_apSegmentInterDCOffset[i], sizeof( Int ) * uiQNumPart); |
---|
1637 | } |
---|
1638 | #endif |
---|
1639 | memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); |
---|
1640 | memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); |
---|
1641 | memcpy( rpcCU->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); |
---|
1642 | |
---|
1643 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPIdx[0], iSizeInUchar ); |
---|
1644 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPIdx[1], iSizeInUchar ); |
---|
1645 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPNum[0], iSizeInUchar ); |
---|
1646 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPNum[1], iSizeInUchar ); |
---|
1647 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
1648 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
1649 | |
---|
1650 | memcpy( rpcCU->getIPCMFlag() + uiPartOffset, m_pbIPCMFlag, iSizeInBool ); |
---|
1651 | |
---|
1652 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); |
---|
1653 | UInt uiTmp2 = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
1654 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
1655 | #if ADAPTIVE_QP_SELECTION |
---|
1656 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
---|
1657 | #endif |
---|
1658 | |
---|
1659 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof( Pel ) * uiTmp ); |
---|
1660 | |
---|
1661 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
1662 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
1663 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
1664 | #if ADAPTIVE_QP_SELECTION |
---|
1665 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
---|
1666 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
---|
1667 | #endif |
---|
1668 | |
---|
1669 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
---|
1670 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
---|
1671 | rpcCU->getTotalBins() = m_uiTotalBins; |
---|
1672 | memcpy( rpcCU->m_sliceStartCU + uiPartOffset, m_sliceStartCU, sizeof( UInt ) * uiQNumPart ); |
---|
1673 | memcpy( rpcCU->m_sliceSegmentStartCU + uiPartOffset, m_sliceSegmentStartCU, sizeof( UInt ) * uiQNumPart ); |
---|
1674 | #if H_3D_ARP |
---|
1675 | memcpy( rpcCU->getARPW() + uiPartOffset, m_puhARPW, iSizeInUchar ); |
---|
1676 | #endif |
---|
1677 | #if H_3D_IC |
---|
1678 | memcpy( rpcCU->getICFlag() + uiPartOffset, m_pbICFlag, iSizeInBool ); |
---|
1679 | #endif |
---|
1680 | } |
---|
1681 | |
---|
1682 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1683 | // Other public functions |
---|
1684 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1685 | |
---|
1686 | TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, |
---|
1687 | UInt uiCurrPartUnitIdx, |
---|
1688 | Bool bEnforceSliceRestriction, |
---|
1689 | Bool bEnforceTileRestriction ) |
---|
1690 | { |
---|
1691 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1692 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1693 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1694 | |
---|
1695 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1696 | { |
---|
1697 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1698 | if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1699 | { |
---|
1700 | return m_pcPic->getCU( getAddr() ); |
---|
1701 | } |
---|
1702 | else |
---|
1703 | { |
---|
1704 | uiLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1705 | return this; |
---|
1706 | } |
---|
1707 | } |
---|
1708 | |
---|
1709 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth - 1 ]; |
---|
1710 | |
---|
1711 | |
---|
1712 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
---|
1713 | || |
---|
1714 | (bEnforceTileRestriction && ( m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) ) ) |
---|
1715 | ) |
---|
1716 | { |
---|
1717 | return NULL; |
---|
1718 | } |
---|
1719 | return m_pcCULeft; |
---|
1720 | } |
---|
1721 | |
---|
1722 | TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, |
---|
1723 | UInt uiCurrPartUnitIdx, |
---|
1724 | Bool bEnforceSliceRestriction, |
---|
1725 | Bool planarAtLCUBoundary , |
---|
1726 | Bool bEnforceTileRestriction ) |
---|
1727 | { |
---|
1728 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1729 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1730 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1731 | |
---|
1732 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1733 | { |
---|
1734 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth ]; |
---|
1735 | if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1736 | { |
---|
1737 | return m_pcPic->getCU( getAddr() ); |
---|
1738 | } |
---|
1739 | else |
---|
1740 | { |
---|
1741 | uiAPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1742 | return this; |
---|
1743 | } |
---|
1744 | } |
---|
1745 | |
---|
1746 | if(planarAtLCUBoundary) |
---|
1747 | { |
---|
1748 | return NULL; |
---|
1749 | } |
---|
1750 | |
---|
1751 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1752 | |
---|
1753 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
---|
1754 | || |
---|
1755 | (bEnforceTileRestriction &&(m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())))) |
---|
1756 | ) |
---|
1757 | { |
---|
1758 | return NULL; |
---|
1759 | } |
---|
1760 | return m_pcCUAbove; |
---|
1761 | } |
---|
1762 | |
---|
1763 | TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
1764 | { |
---|
1765 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1766 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1767 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1768 | |
---|
1769 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1770 | { |
---|
1771 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1772 | { |
---|
1773 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth - 1 ]; |
---|
1774 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1775 | { |
---|
1776 | return m_pcPic->getCU( getAddr() ); |
---|
1777 | } |
---|
1778 | else |
---|
1779 | { |
---|
1780 | uiALPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1781 | return this; |
---|
1782 | } |
---|
1783 | } |
---|
1784 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartInCU() - uiNumPartInCUWidth - 1 ]; |
---|
1785 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1786 | m_pcCUAbove->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1787 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1788 | )) |
---|
1789 | ) |
---|
1790 | { |
---|
1791 | return NULL; |
---|
1792 | } |
---|
1793 | return m_pcCUAbove; |
---|
1794 | } |
---|
1795 | |
---|
1796 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1797 | { |
---|
1798 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1799 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1800 | m_pcCULeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1801 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1802 | )) |
---|
1803 | ) |
---|
1804 | { |
---|
1805 | return NULL; |
---|
1806 | } |
---|
1807 | return m_pcCULeft; |
---|
1808 | } |
---|
1809 | |
---|
1810 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - 1 ]; |
---|
1811 | if ( (bEnforceSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || |
---|
1812 | m_pcCUAboveLeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1813 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveLeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1814 | )) |
---|
1815 | ) |
---|
1816 | { |
---|
1817 | return NULL; |
---|
1818 | } |
---|
1819 | return m_pcCUAboveLeft; |
---|
1820 | } |
---|
1821 | |
---|
1822 | TComDataCU* TComDataCU::getPUAboveRight( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
1823 | { |
---|
1824 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1825 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1; |
---|
1826 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1827 | |
---|
1828 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
1829 | { |
---|
1830 | uiARPartUnitIdx = MAX_UINT; |
---|
1831 | return NULL; |
---|
1832 | } |
---|
1833 | |
---|
1834 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - 1, uiNumPartInCUWidth ) ) |
---|
1835 | { |
---|
1836 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1837 | { |
---|
1838 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] ) |
---|
1839 | { |
---|
1840 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ]; |
---|
1841 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1842 | { |
---|
1843 | return m_pcPic->getCU( getAddr() ); |
---|
1844 | } |
---|
1845 | else |
---|
1846 | { |
---|
1847 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1848 | return this; |
---|
1849 | } |
---|
1850 | } |
---|
1851 | uiARPartUnitIdx = MAX_UINT; |
---|
1852 | return NULL; |
---|
1853 | } |
---|
1854 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; |
---|
1855 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1856 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1857 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1858 | )) |
---|
1859 | ) |
---|
1860 | { |
---|
1861 | return NULL; |
---|
1862 | } |
---|
1863 | return m_pcCUAbove; |
---|
1864 | } |
---|
1865 | |
---|
1866 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1867 | { |
---|
1868 | uiARPartUnitIdx = MAX_UINT; |
---|
1869 | return NULL; |
---|
1870 | } |
---|
1871 | |
---|
1872 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1873 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
1874 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
1875 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1876 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1877 | )) |
---|
1878 | ) |
---|
1879 | { |
---|
1880 | return NULL; |
---|
1881 | } |
---|
1882 | return m_pcCUAboveRight; |
---|
1883 | } |
---|
1884 | |
---|
1885 | TComDataCU* TComDataCU::getPUBelowLeft( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
1886 | { |
---|
1887 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1888 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*m_pcPic->getNumPartInWidth(); |
---|
1889 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1890 | |
---|
1891 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
1892 | { |
---|
1893 | uiBLPartUnitIdx = MAX_UINT; |
---|
1894 | return NULL; |
---|
1895 | } |
---|
1896 | |
---|
1897 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - 1, uiNumPartInCUWidth ) ) |
---|
1898 | { |
---|
1899 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
---|
1900 | { |
---|
1901 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) |
---|
1902 | { |
---|
1903 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; |
---|
1904 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
---|
1905 | { |
---|
1906 | return m_pcPic->getCU( getAddr() ); |
---|
1907 | } |
---|
1908 | else |
---|
1909 | { |
---|
1910 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1911 | return this; |
---|
1912 | } |
---|
1913 | } |
---|
1914 | uiBLPartUnitIdx = MAX_UINT; |
---|
1915 | return NULL; |
---|
1916 | } |
---|
1917 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; |
---|
1918 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1919 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1920 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1921 | )) |
---|
1922 | ) |
---|
1923 | { |
---|
1924 | return NULL; |
---|
1925 | } |
---|
1926 | return m_pcCULeft; |
---|
1927 | } |
---|
1928 | |
---|
1929 | uiBLPartUnitIdx = MAX_UINT; |
---|
1930 | return NULL; |
---|
1931 | } |
---|
1932 | |
---|
1933 | TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
---|
1934 | { |
---|
1935 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1936 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth(); |
---|
1937 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1938 | |
---|
1939 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) |
---|
1940 | { |
---|
1941 | uiBLPartUnitIdx = MAX_UINT; |
---|
1942 | return NULL; |
---|
1943 | } |
---|
1944 | |
---|
1945 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
---|
1946 | { |
---|
1947 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
---|
1948 | { |
---|
1949 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ] ) |
---|
1950 | { |
---|
1951 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ]; |
---|
1952 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
---|
1953 | { |
---|
1954 | return m_pcPic->getCU( getAddr() ); |
---|
1955 | } |
---|
1956 | else |
---|
1957 | { |
---|
1958 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1959 | return this; |
---|
1960 | } |
---|
1961 | } |
---|
1962 | uiBLPartUnitIdx = MAX_UINT; |
---|
1963 | return NULL; |
---|
1964 | } |
---|
1965 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * uiNumPartInCUWidth - 1 ]; |
---|
1966 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1967 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1968 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1969 | )) |
---|
1970 | ) |
---|
1971 | { |
---|
1972 | return NULL; |
---|
1973 | } |
---|
1974 | return m_pcCULeft; |
---|
1975 | } |
---|
1976 | |
---|
1977 | uiBLPartUnitIdx = MAX_UINT; |
---|
1978 | return NULL; |
---|
1979 | } |
---|
1980 | |
---|
1981 | TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
---|
1982 | { |
---|
1983 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1984 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
---|
1985 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1986 | |
---|
1987 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
1988 | { |
---|
1989 | uiARPartUnitIdx = MAX_UINT; |
---|
1990 | return NULL; |
---|
1991 | } |
---|
1992 | |
---|
1993 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
---|
1994 | { |
---|
1995 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1996 | { |
---|
1997 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ] ) |
---|
1998 | { |
---|
1999 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
2000 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
2001 | { |
---|
2002 | return m_pcPic->getCU( getAddr() ); |
---|
2003 | } |
---|
2004 | else |
---|
2005 | { |
---|
2006 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
2007 | return this; |
---|
2008 | } |
---|
2009 | } |
---|
2010 | uiARPartUnitIdx = MAX_UINT; |
---|
2011 | return NULL; |
---|
2012 | } |
---|
2013 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
2014 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
2015 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
2016 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
2017 | )) |
---|
2018 | ) |
---|
2019 | { |
---|
2020 | return NULL; |
---|
2021 | } |
---|
2022 | return m_pcCUAbove; |
---|
2023 | } |
---|
2024 | |
---|
2025 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
2026 | { |
---|
2027 | uiARPartUnitIdx = MAX_UINT; |
---|
2028 | return NULL; |
---|
2029 | } |
---|
2030 | |
---|
2031 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset-1 ]; |
---|
2032 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
2033 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
2034 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
2035 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
2036 | )) |
---|
2037 | ) |
---|
2038 | { |
---|
2039 | return NULL; |
---|
2040 | } |
---|
2041 | return m_pcCUAboveRight; |
---|
2042 | } |
---|
2043 | |
---|
2044 | /** Get left QpMinCu |
---|
2045 | *\param uiLPartUnitIdx |
---|
2046 | *\param uiCurrAbsIdxInLCU |
---|
2047 | *\returns TComDataCU* point of TComDataCU of left QpMinCu |
---|
2048 | */ |
---|
2049 | TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInLCU) |
---|
2050 | { |
---|
2051 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
2052 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth -getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
---|
2053 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
2054 | |
---|
2055 | // check for left LCU boundary |
---|
2056 | if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCUWidth) ) |
---|
2057 | { |
---|
2058 | return NULL; |
---|
2059 | } |
---|
2060 | |
---|
2061 | // get index of left-CU relative to top-left corner of current quantization group |
---|
2062 | uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; |
---|
2063 | |
---|
2064 | // return pointer to current LCU |
---|
2065 | return m_pcPic->getCU( getAddr() ); |
---|
2066 | } |
---|
2067 | |
---|
2068 | /** Get Above QpMinCu |
---|
2069 | *\param aPartUnitIdx |
---|
2070 | *\param currAbsIdxInLCU |
---|
2071 | *\returns TComDataCU* point of TComDataCU of above QpMinCu |
---|
2072 | */ |
---|
2073 | TComDataCU* TComDataCU::getQpMinCuAbove( UInt& aPartUnitIdx, UInt currAbsIdxInLCU ) |
---|
2074 | { |
---|
2075 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
2076 | UInt absZorderQpMinCUIdx = (currAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
---|
2077 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
2078 | |
---|
2079 | // check for top LCU boundary |
---|
2080 | if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCUWidth) ) |
---|
2081 | { |
---|
2082 | return NULL; |
---|
2083 | } |
---|
2084 | |
---|
2085 | // get index of top-CU relative to top-left corner of current quantization group |
---|
2086 | aPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCUWidth]; |
---|
2087 | |
---|
2088 | // return pointer to current LCU |
---|
2089 | return m_pcPic->getCU( getAddr() ); |
---|
2090 | } |
---|
2091 | |
---|
2092 | /** Get reference QP from left QpMinCu or latest coded QP |
---|
2093 | *\param uiCurrAbsIdxInLCU |
---|
2094 | *\returns Char reference QP value |
---|
2095 | */ |
---|
2096 | Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInLCU ) |
---|
2097 | { |
---|
2098 | UInt lPartIdx = 0, aPartIdx = 0; |
---|
2099 | TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
---|
2100 | TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
---|
2101 | return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + 1) >> 1); |
---|
2102 | } |
---|
2103 | |
---|
2104 | Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) |
---|
2105 | { |
---|
2106 | Int iLastValidPartIdx = iAbsPartIdx-1; |
---|
2107 | while ( iLastValidPartIdx >= 0 |
---|
2108 | && getPredictionMode( iLastValidPartIdx ) == MODE_NONE ) |
---|
2109 | { |
---|
2110 | UInt uiDepth = getDepth( iLastValidPartIdx ); |
---|
2111 | iLastValidPartIdx -= m_uiNumPartition>>(uiDepth<<1); |
---|
2112 | } |
---|
2113 | return iLastValidPartIdx; |
---|
2114 | } |
---|
2115 | |
---|
2116 | Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) |
---|
2117 | { |
---|
2118 | UInt uiQUPartIdxMask = ~((1<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); |
---|
2119 | Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); |
---|
2120 | if ( uiAbsPartIdx < m_uiNumPartition |
---|
2121 | && (getSCUAddr()+iLastValidPartIdx < getSliceStartCU(m_uiAbsIdxInLCU+uiAbsPartIdx))) |
---|
2122 | { |
---|
2123 | return getSlice()->getSliceQp(); |
---|
2124 | } |
---|
2125 | else if ( iLastValidPartIdx >= 0 ) |
---|
2126 | { |
---|
2127 | return getQP( iLastValidPartIdx ); |
---|
2128 | } |
---|
2129 | else |
---|
2130 | { |
---|
2131 | if ( getZorderIdxInCU() > 0 ) |
---|
2132 | { |
---|
2133 | return getPic()->getCU( getAddr() )->getLastCodedQP( getZorderIdxInCU() ); |
---|
2134 | } |
---|
2135 | else if ( getPic()->getPicSym()->getInverseCUOrderMap(getAddr()) > 0 |
---|
2136 | && getPic()->getPicSym()->getTileIdxMap(getAddr()) == getPic()->getPicSym()->getTileIdxMap(getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1)) |
---|
2137 | && !( getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() && getAddr() % getPic()->getFrameWidthInCU() == 0 ) ) |
---|
2138 | { |
---|
2139 | return getPic()->getCU( getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1) )->getLastCodedQP( getPic()->getNumPartInCU() ); |
---|
2140 | } |
---|
2141 | else |
---|
2142 | { |
---|
2143 | return getSlice()->getSliceQp(); |
---|
2144 | } |
---|
2145 | } |
---|
2146 | } |
---|
2147 | /** Check whether the CU is coded in lossless coding mode |
---|
2148 | * \param uiAbsPartIdx |
---|
2149 | * \returns true if the CU is coded in lossless coding mode; false if otherwise |
---|
2150 | */ |
---|
2151 | Bool TComDataCU::isLosslessCoded(UInt absPartIdx) |
---|
2152 | { |
---|
2153 | return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx)); |
---|
2154 | } |
---|
2155 | |
---|
2156 | /** Get allowed chroma intra modes |
---|
2157 | *\param uiAbsPartIdx |
---|
2158 | *\param uiModeList pointer to chroma intra modes array |
---|
2159 | *\returns |
---|
2160 | *- fill uiModeList with chroma intra modes |
---|
2161 | */ |
---|
2162 | Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt* uiModeList ) |
---|
2163 | { |
---|
2164 | uiModeList[0] = PLANAR_IDX; |
---|
2165 | uiModeList[1] = VER_IDX; |
---|
2166 | uiModeList[2] = HOR_IDX; |
---|
2167 | uiModeList[3] = DC_IDX; |
---|
2168 | uiModeList[4] = DM_CHROMA_IDX; |
---|
2169 | |
---|
2170 | UInt uiLumaMode = getLumaIntraDir( uiAbsPartIdx ); |
---|
2171 | |
---|
2172 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
---|
2173 | { |
---|
2174 | if( uiLumaMode == uiModeList[i] ) |
---|
2175 | { |
---|
2176 | uiModeList[i] = 34; // VER+8 mode |
---|
2177 | break; |
---|
2178 | } |
---|
2179 | } |
---|
2180 | } |
---|
2181 | |
---|
2182 | /** Get most probable intra modes |
---|
2183 | *\param uiAbsPartIdx |
---|
2184 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
2185 | *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. |
---|
2186 | *\returns Number of MPM |
---|
2187 | */ |
---|
2188 | Int TComDataCU::getIntraDirLumaPredictor( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode ) |
---|
2189 | { |
---|
2190 | TComDataCU* pcTempCU; |
---|
2191 | UInt uiTempPartIdx; |
---|
2192 | Int iLeftIntraDir, iAboveIntraDir; |
---|
2193 | Int uiPredNum = 0; |
---|
2194 | |
---|
2195 | // Get intra direction of left PU |
---|
2196 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2197 | |
---|
2198 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
2199 | #if H_3D_DIM |
---|
2200 | mapDepthModeToIntraDir( iLeftIntraDir ); |
---|
2201 | #endif |
---|
2202 | |
---|
2203 | // Get intra direction of above PU |
---|
2204 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true ); |
---|
2205 | |
---|
2206 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
2207 | #if H_3D_DIM |
---|
2208 | mapDepthModeToIntraDir( iAboveIntraDir ); |
---|
2209 | #endif |
---|
2210 | |
---|
2211 | uiPredNum = 3; |
---|
2212 | if(iLeftIntraDir == iAboveIntraDir) |
---|
2213 | { |
---|
2214 | if( piMode ) |
---|
2215 | { |
---|
2216 | *piMode = 1; |
---|
2217 | } |
---|
2218 | |
---|
2219 | if (iLeftIntraDir > 1) // angular modes |
---|
2220 | { |
---|
2221 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
2222 | uiIntraDirPred[1] = ((iLeftIntraDir + 29) % 32) + 2; |
---|
2223 | uiIntraDirPred[2] = ((iLeftIntraDir - 1 ) % 32) + 2; |
---|
2224 | } |
---|
2225 | else //non-angular |
---|
2226 | { |
---|
2227 | uiIntraDirPred[0] = PLANAR_IDX; |
---|
2228 | uiIntraDirPred[1] = DC_IDX; |
---|
2229 | uiIntraDirPred[2] = VER_IDX; |
---|
2230 | } |
---|
2231 | } |
---|
2232 | else |
---|
2233 | { |
---|
2234 | if( piMode ) |
---|
2235 | { |
---|
2236 | *piMode = 2; |
---|
2237 | } |
---|
2238 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
2239 | uiIntraDirPred[1] = iAboveIntraDir; |
---|
2240 | |
---|
2241 | if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar |
---|
2242 | { |
---|
2243 | uiIntraDirPred[2] = PLANAR_IDX; |
---|
2244 | } |
---|
2245 | else |
---|
2246 | { |
---|
2247 | uiIntraDirPred[2] = (iLeftIntraDir+iAboveIntraDir)<2? VER_IDX : DC_IDX; |
---|
2248 | } |
---|
2249 | } |
---|
2250 | |
---|
2251 | return uiPredNum; |
---|
2252 | } |
---|
2253 | |
---|
2254 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2255 | { |
---|
2256 | TComDataCU* pcTempCU; |
---|
2257 | UInt uiTempPartIdx; |
---|
2258 | UInt uiCtx; |
---|
2259 | // Get left split flag |
---|
2260 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2261 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
2262 | |
---|
2263 | // Get above split flag |
---|
2264 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2265 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
2266 | |
---|
2267 | return uiCtx; |
---|
2268 | } |
---|
2269 | |
---|
2270 | UInt TComDataCU::getCtxQtCbf( TextType eType, UInt uiTrDepth ) |
---|
2271 | { |
---|
2272 | if( eType ) |
---|
2273 | { |
---|
2274 | return uiTrDepth; |
---|
2275 | } |
---|
2276 | else |
---|
2277 | { |
---|
2278 | const UInt uiCtx = ( uiTrDepth == 0 ? 1 : 0 ); |
---|
2279 | return uiCtx; |
---|
2280 | } |
---|
2281 | } |
---|
2282 | |
---|
2283 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) |
---|
2284 | { |
---|
2285 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
---|
2286 | PartSize partSize = getPartitionSize( absPartIdx ); |
---|
2287 | UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
2288 | Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA && partSize == SIZE_NxN ) ? 1 : 0; |
---|
2289 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) ); |
---|
2290 | |
---|
2291 | UInt log2MinTUSizeInCU = 0; |
---|
2292 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
---|
2293 | { |
---|
2294 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
---|
2295 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
2296 | } |
---|
2297 | else |
---|
2298 | { |
---|
2299 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
---|
2300 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
---|
2301 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
2302 | { |
---|
2303 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
---|
2304 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
2305 | } |
---|
2306 | } |
---|
2307 | return log2MinTUSizeInCU; |
---|
2308 | } |
---|
2309 | |
---|
2310 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
---|
2311 | { |
---|
2312 | TComDataCU* pcTempCU; |
---|
2313 | UInt uiTempPartIdx; |
---|
2314 | UInt uiCtx = 0; |
---|
2315 | |
---|
2316 | // Get BCBP of left PU |
---|
2317 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2318 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2319 | |
---|
2320 | // Get BCBP of above PU |
---|
2321 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2322 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2323 | |
---|
2324 | return uiCtx; |
---|
2325 | } |
---|
2326 | |
---|
2327 | #if H_3D_ARP |
---|
2328 | UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx ) |
---|
2329 | { |
---|
2330 | TComDataCU* pcTempCU; |
---|
2331 | UInt uiTempPartIdx; |
---|
2332 | UInt uiCtx = 0; |
---|
2333 | |
---|
2334 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2335 | uiCtx = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0; |
---|
2336 | |
---|
2337 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2338 | uiCtx += ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1): 0; |
---|
2339 | |
---|
2340 | return uiCtx; |
---|
2341 | } |
---|
2342 | #endif |
---|
2343 | |
---|
2344 | #if H_3D_IC |
---|
2345 | UInt TComDataCU::getCtxICFlag( UInt uiAbsPartIdx ) |
---|
2346 | { |
---|
2347 | UInt uiCtx = 0; |
---|
2348 | |
---|
2349 | return uiCtx; |
---|
2350 | } |
---|
2351 | #endif |
---|
2352 | |
---|
2353 | #if LGE_INTER_SDC_E0156 |
---|
2354 | Void TComDataCU::setInterSDCFlagSubParts ( Bool bInterSDCFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2355 | { |
---|
2356 | setSubPart( bInterSDCFlag, m_pbInterSDCFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2357 | } |
---|
2358 | |
---|
2359 | UInt TComDataCU::getCtxInterSDCFlag( UInt uiAbsPartIdx ) |
---|
2360 | { |
---|
2361 | return 0; |
---|
2362 | } |
---|
2363 | |
---|
2364 | Void TComDataCU::xSetInterSDCCUMask( TComDataCU *pcCU, UChar *pMask ) |
---|
2365 | { |
---|
2366 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
2367 | UInt uiHeight = pcCU->getHeight( 0 ); |
---|
2368 | UInt uiPartitionSize = pcCU->getPartitionSize( 0 ); |
---|
2369 | UInt uiXOffset = 0, uiYOffset = 0; |
---|
2370 | |
---|
2371 | switch( uiPartitionSize ) |
---|
2372 | { |
---|
2373 | case SIZE_2NxN: |
---|
2374 | uiXOffset = uiWidth; uiYOffset = uiHeight >> 1; break; |
---|
2375 | case SIZE_2NxnU: |
---|
2376 | uiXOffset = uiWidth; uiYOffset = uiHeight >> 2; break; |
---|
2377 | case SIZE_2NxnD: |
---|
2378 | uiXOffset = uiWidth; uiYOffset = ( uiHeight >> 1 ) + ( uiHeight >> 2 ); break; |
---|
2379 | case SIZE_Nx2N: |
---|
2380 | uiXOffset = uiWidth >> 1; uiYOffset = uiHeight; break; |
---|
2381 | case SIZE_nLx2N: |
---|
2382 | uiXOffset = uiWidth >> 2; uiYOffset = uiHeight; break; |
---|
2383 | case SIZE_nRx2N: |
---|
2384 | uiXOffset = ( uiWidth >> 1 ) + ( uiWidth >> 2 ); uiYOffset = uiHeight; break; |
---|
2385 | case SIZE_NxN: |
---|
2386 | uiXOffset = uiWidth >> 1; uiYOffset = uiHeight >> 1; break; |
---|
2387 | default: |
---|
2388 | assert( uiPartitionSize == SIZE_2Nx2N ); |
---|
2389 | uiXOffset = uiWidth; uiYOffset = uiHeight; break; |
---|
2390 | } |
---|
2391 | |
---|
2392 | UInt uiPelX, uiPelY; |
---|
2393 | |
---|
2394 | memset( pMask, 0, uiWidth*uiHeight ); |
---|
2395 | |
---|
2396 | //mask |
---|
2397 | if( uiPartitionSize == SIZE_2NxN || uiPartitionSize == SIZE_2NxnD || uiPartitionSize == SIZE_2NxnU ) |
---|
2398 | { |
---|
2399 | for( uiPelY = 0; uiPelY < uiYOffset; uiPelY++ ) |
---|
2400 | { |
---|
2401 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
---|
2402 | { |
---|
2403 | pMask[uiPelX + uiPelY*uiWidth] = 0; |
---|
2404 | } |
---|
2405 | } |
---|
2406 | |
---|
2407 | for( ; uiPelY < uiHeight; uiPelY++ ) |
---|
2408 | { |
---|
2409 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
---|
2410 | { |
---|
2411 | pMask[uiPelX + uiPelY*uiWidth] = 1; |
---|
2412 | } |
---|
2413 | } |
---|
2414 | } |
---|
2415 | else if( uiPartitionSize == SIZE_Nx2N || uiPartitionSize == SIZE_nLx2N || uiPartitionSize == SIZE_nRx2N ) |
---|
2416 | { |
---|
2417 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
---|
2418 | { |
---|
2419 | for( uiPelX = 0; uiPelX < uiXOffset; uiPelX++ ) |
---|
2420 | { |
---|
2421 | pMask[uiPelX + uiPelY*uiWidth] = 0; |
---|
2422 | } |
---|
2423 | |
---|
2424 | for( ; uiPelX < uiWidth; uiPelX++ ) |
---|
2425 | { |
---|
2426 | pMask[uiPelX + uiPelY*uiWidth] = 1; |
---|
2427 | } |
---|
2428 | } |
---|
2429 | } |
---|
2430 | else if( uiPartitionSize == SIZE_NxN ) |
---|
2431 | { |
---|
2432 | for( uiPelY = 0; uiPelY < uiYOffset; uiPelY++ ) |
---|
2433 | { |
---|
2434 | for( uiPelX = 0; uiPelX < uiXOffset; uiPelX++ ) |
---|
2435 | { |
---|
2436 | pMask[uiPelX + uiPelY*uiWidth] = 0; |
---|
2437 | } |
---|
2438 | |
---|
2439 | for( ; uiPelX < uiWidth; uiPelX++ ) |
---|
2440 | { |
---|
2441 | pMask[uiPelX + uiPelY*uiWidth] = 1; |
---|
2442 | } |
---|
2443 | } |
---|
2444 | |
---|
2445 | for( ; uiPelY < uiHeight; uiPelY++ ) |
---|
2446 | { |
---|
2447 | for( uiPelX = 0; uiPelX < uiXOffset; uiPelX++ ) |
---|
2448 | { |
---|
2449 | pMask[uiPelX + uiPelY*uiWidth] = 2; |
---|
2450 | } |
---|
2451 | |
---|
2452 | for( ; uiPelX < uiWidth; uiPelX++ ) |
---|
2453 | { |
---|
2454 | pMask[uiPelX + uiPelY*uiWidth] = 3; |
---|
2455 | } |
---|
2456 | } |
---|
2457 | } |
---|
2458 | |
---|
2459 | } |
---|
2460 | #endif |
---|
2461 | |
---|
2462 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
---|
2463 | { |
---|
2464 | return getDepth( uiAbsPartIdx ); |
---|
2465 | } |
---|
2466 | |
---|
2467 | Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2468 | { |
---|
2469 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2470 | memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2471 | memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2472 | memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2473 | } |
---|
2474 | |
---|
2475 | Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2476 | { |
---|
2477 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2478 | memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2479 | } |
---|
2480 | |
---|
2481 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
2482 | * \param uiCbf The value of the coded block flag to be set |
---|
2483 | * \param eTType |
---|
2484 | * \param uiAbsPartIdx |
---|
2485 | * \param uiPartIdx |
---|
2486 | * \param uiDepth |
---|
2487 | * \returns Void |
---|
2488 | */ |
---|
2489 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2490 | { |
---|
2491 | setSubPart<UChar>( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2492 | } |
---|
2493 | |
---|
2494 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
2495 | { |
---|
2496 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2497 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2498 | } |
---|
2499 | |
---|
2500 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
---|
2501 | { |
---|
2502 | UInt uiPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2503 | return (((m_uiAbsIdxInLCU + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
2504 | } |
---|
2505 | |
---|
2506 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2507 | { |
---|
2508 | assert( sizeof( *m_pePartSize) == 1 ); |
---|
2509 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2510 | } |
---|
2511 | |
---|
2512 | Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2513 | { |
---|
2514 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2515 | } |
---|
2516 | |
---|
2517 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
---|
2518 | { |
---|
2519 | assert( sizeof( *m_skipFlag) == 1 ); |
---|
2520 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); |
---|
2521 | } |
---|
2522 | |
---|
2523 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2524 | { |
---|
2525 | assert( sizeof( *m_pePredMode) == 1 ); |
---|
2526 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2527 | } |
---|
2528 | |
---|
2529 | Void TComDataCU::setQPSubCUs( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
---|
2530 | { |
---|
2531 | UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); |
---|
2532 | UInt currPartNumQ = currPartNumb >> 2; |
---|
2533 | |
---|
2534 | if(!foundNonZeroCbf) |
---|
2535 | { |
---|
2536 | if(pcCU->getDepth(absPartIdx) > depth) |
---|
2537 | { |
---|
2538 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
---|
2539 | { |
---|
2540 | pcCU->setQPSubCUs( qp, pcCU, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
---|
2541 | } |
---|
2542 | } |
---|
2543 | else |
---|
2544 | { |
---|
2545 | if(pcCU->getCbf( absPartIdx, TEXT_LUMA ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_U ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_V ) ) |
---|
2546 | { |
---|
2547 | foundNonZeroCbf = true; |
---|
2548 | } |
---|
2549 | else |
---|
2550 | { |
---|
2551 | setQPSubParts(qp, absPartIdx, depth); |
---|
2552 | } |
---|
2553 | } |
---|
2554 | } |
---|
2555 | } |
---|
2556 | |
---|
2557 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2558 | { |
---|
2559 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2560 | TComSlice * pcSlice = getPic()->getSlice(getPic()->getCurrSliceIdx()); |
---|
2561 | |
---|
2562 | for(UInt uiSCUIdx = uiAbsPartIdx; uiSCUIdx < uiAbsPartIdx+uiCurrPartNumb; uiSCUIdx++) |
---|
2563 | { |
---|
2564 | if( m_pcPic->getCU( getAddr() )->getSliceSegmentStartCU(uiSCUIdx+getZorderIdxInCU()) == pcSlice->getSliceSegmentCurStartCUAddr() ) |
---|
2565 | { |
---|
2566 | m_phQP[uiSCUIdx] = qp; |
---|
2567 | } |
---|
2568 | } |
---|
2569 | } |
---|
2570 | |
---|
2571 | Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2572 | { |
---|
2573 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2574 | |
---|
2575 | memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2576 | } |
---|
2577 | |
---|
2578 | template<typename T> |
---|
2579 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2580 | { |
---|
2581 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
---|
2582 | |
---|
2583 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
---|
2584 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2585 | { |
---|
2586 | case SIZE_2Nx2N: |
---|
2587 | memset( puhBaseLCU + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
---|
2588 | break; |
---|
2589 | case SIZE_2NxN: |
---|
2590 | memset( puhBaseLCU + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
---|
2591 | break; |
---|
2592 | case SIZE_Nx2N: |
---|
2593 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2594 | memset( puhBaseLCU + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
---|
2595 | break; |
---|
2596 | case SIZE_NxN: |
---|
2597 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2598 | break; |
---|
2599 | case SIZE_2NxnU: |
---|
2600 | if ( uiPUIdx == 0 ) |
---|
2601 | { |
---|
2602 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2603 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2604 | } |
---|
2605 | else if ( uiPUIdx == 1 ) |
---|
2606 | { |
---|
2607 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2608 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
---|
2609 | } |
---|
2610 | else |
---|
2611 | { |
---|
2612 | assert(0); |
---|
2613 | } |
---|
2614 | break; |
---|
2615 | case SIZE_2NxnD: |
---|
2616 | if ( uiPUIdx == 0 ) |
---|
2617 | { |
---|
2618 | memset( puhBaseLCU + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
---|
2619 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2620 | } |
---|
2621 | else if ( uiPUIdx == 1 ) |
---|
2622 | { |
---|
2623 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2624 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2625 | } |
---|
2626 | else |
---|
2627 | { |
---|
2628 | assert(0); |
---|
2629 | } |
---|
2630 | break; |
---|
2631 | case SIZE_nLx2N: |
---|
2632 | if ( uiPUIdx == 0 ) |
---|
2633 | { |
---|
2634 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2635 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2636 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2637 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2638 | } |
---|
2639 | else if ( uiPUIdx == 1 ) |
---|
2640 | { |
---|
2641 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2642 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2643 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2644 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2645 | } |
---|
2646 | else |
---|
2647 | { |
---|
2648 | assert(0); |
---|
2649 | } |
---|
2650 | break; |
---|
2651 | case SIZE_nRx2N: |
---|
2652 | if ( uiPUIdx == 0 ) |
---|
2653 | { |
---|
2654 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2655 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2656 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2657 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2658 | } |
---|
2659 | else if ( uiPUIdx == 1 ) |
---|
2660 | { |
---|
2661 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2662 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2663 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2664 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2665 | } |
---|
2666 | else |
---|
2667 | { |
---|
2668 | assert(0); |
---|
2669 | } |
---|
2670 | break; |
---|
2671 | default: |
---|
2672 | assert( 0 ); |
---|
2673 | } |
---|
2674 | } |
---|
2675 | |
---|
2676 | #if H_3D_DIM_SDC |
---|
2677 | Void TComDataCU::setSDCFlagSubParts ( Bool bSDCFlag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2678 | { |
---|
2679 | assert( sizeof( *m_pbSDCFlag) == 1 ); |
---|
2680 | memset( m_pbSDCFlag + uiAbsPartIdx, bSDCFlag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2681 | } |
---|
2682 | |
---|
2683 | Bool TComDataCU::getSDCAvailable( UInt uiAbsPartIdx ) |
---|
2684 | { |
---|
2685 | // check general CU information |
---|
2686 | if( !getSlice()->getIsDepth() || !isIntra(uiAbsPartIdx) || getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) |
---|
2687 | return false; |
---|
2688 | |
---|
2689 | // check prediction mode |
---|
2690 | UInt uiLumaPredMode = getLumaIntraDir( uiAbsPartIdx ); |
---|
2691 | #if LGE_SDC_REMOVE_DC_E0158 |
---|
2692 | if( uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX && !isDimDeltaDC( uiLumaPredMode ) ) ) |
---|
2693 | #else |
---|
2694 | if( uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX && !isDimDeltaDC( uiLumaPredMode ) ) ) |
---|
2695 | #endif |
---|
2696 | return true; |
---|
2697 | |
---|
2698 | // else |
---|
2699 | return false; |
---|
2700 | } |
---|
2701 | #endif |
---|
2702 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2703 | { |
---|
2704 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2705 | } |
---|
2706 | |
---|
2707 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2708 | { |
---|
2709 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2710 | } |
---|
2711 | |
---|
2712 | #if H_3D_VSP |
---|
2713 | Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2714 | { |
---|
2715 | setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2716 | } |
---|
2717 | #if H_3D_VSP |
---|
2718 | template<typename T> |
---|
2719 | Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2720 | { |
---|
2721 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
---|
2722 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2723 | { |
---|
2724 | case SIZE_2Nx2N: |
---|
2725 | for (UInt ui = 0; ui < 4 * uiCurrPartNumQ; ui++) |
---|
2726 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2727 | |
---|
2728 | break; |
---|
2729 | case SIZE_2NxN: |
---|
2730 | for (UInt ui = 0; ui < 2 * uiCurrPartNumQ; ui++) |
---|
2731 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2732 | break; |
---|
2733 | case SIZE_Nx2N: |
---|
2734 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2735 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2736 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2737 | puhBaseLCU[uiCUAddr + 2 * uiCurrPartNumQ + ui] = uiParameter; |
---|
2738 | break; |
---|
2739 | case SIZE_NxN: |
---|
2740 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2741 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2742 | break; |
---|
2743 | case SIZE_2NxnU: |
---|
2744 | if ( uiPUIdx == 0 ) |
---|
2745 | { |
---|
2746 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2747 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2748 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2749 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2750 | |
---|
2751 | } |
---|
2752 | else if ( uiPUIdx == 1 ) |
---|
2753 | { |
---|
2754 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2755 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2756 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1); ui++) |
---|
2757 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2758 | |
---|
2759 | } |
---|
2760 | else |
---|
2761 | { |
---|
2762 | assert(0); |
---|
2763 | } |
---|
2764 | break; |
---|
2765 | case SIZE_2NxnD: |
---|
2766 | if ( uiPUIdx == 0 ) |
---|
2767 | { |
---|
2768 | for (UInt ui = 0; ui < ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)); ui++) |
---|
2769 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2770 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2771 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + ui] = uiParameter; |
---|
2772 | |
---|
2773 | } |
---|
2774 | else if ( uiPUIdx == 1 ) |
---|
2775 | { |
---|
2776 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2777 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2778 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2779 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2780 | |
---|
2781 | } |
---|
2782 | else |
---|
2783 | { |
---|
2784 | assert(0); |
---|
2785 | } |
---|
2786 | break; |
---|
2787 | case SIZE_nLx2N: |
---|
2788 | if ( uiPUIdx == 0 ) |
---|
2789 | { |
---|
2790 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2791 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2792 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2793 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2794 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2795 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2796 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2797 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2798 | |
---|
2799 | } |
---|
2800 | else if ( uiPUIdx == 1 ) |
---|
2801 | { |
---|
2802 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2803 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2804 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2805 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2806 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2807 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2808 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2809 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2810 | |
---|
2811 | } |
---|
2812 | else |
---|
2813 | { |
---|
2814 | assert(0); |
---|
2815 | } |
---|
2816 | break; |
---|
2817 | case SIZE_nRx2N: |
---|
2818 | if ( uiPUIdx == 0 ) |
---|
2819 | { |
---|
2820 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2821 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2822 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2823 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2824 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2825 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2826 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2827 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2828 | |
---|
2829 | } |
---|
2830 | else if ( uiPUIdx == 1 ) |
---|
2831 | { |
---|
2832 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2833 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2834 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2835 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2836 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2837 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2838 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2839 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2840 | |
---|
2841 | } |
---|
2842 | else |
---|
2843 | { |
---|
2844 | assert(0); |
---|
2845 | } |
---|
2846 | break; |
---|
2847 | default: |
---|
2848 | assert( 0 ); |
---|
2849 | } |
---|
2850 | |
---|
2851 | } |
---|
2852 | #endif |
---|
2853 | #endif |
---|
2854 | Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2855 | { |
---|
2856 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2857 | |
---|
2858 | memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2859 | } |
---|
2860 | |
---|
2861 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2862 | { |
---|
2863 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2864 | } |
---|
2865 | |
---|
2866 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2867 | { |
---|
2868 | setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2869 | } |
---|
2870 | |
---|
2871 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2872 | { |
---|
2873 | setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2874 | } |
---|
2875 | |
---|
2876 | |
---|
2877 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2878 | { |
---|
2879 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2880 | |
---|
2881 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
2882 | } |
---|
2883 | |
---|
2884 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2885 | { |
---|
2886 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2887 | |
---|
2888 | memset( m_puhTransformSkip[0] + uiAbsPartIdx, useTransformSkipY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2889 | memset( m_puhTransformSkip[1] + uiAbsPartIdx, useTransformSkipU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2890 | memset( m_puhTransformSkip[2] + uiAbsPartIdx, useTransformSkipV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2891 | } |
---|
2892 | |
---|
2893 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth) |
---|
2894 | { |
---|
2895 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2896 | |
---|
2897 | memset( m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2898 | } |
---|
2899 | |
---|
2900 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2901 | { |
---|
2902 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2903 | |
---|
2904 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2905 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
2906 | } |
---|
2907 | |
---|
2908 | UChar TComDataCU::getNumPartInter() |
---|
2909 | { |
---|
2910 | UChar iNumPart = 0; |
---|
2911 | |
---|
2912 | switch ( m_pePartSize[0] ) |
---|
2913 | { |
---|
2914 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
2915 | case SIZE_2NxN: iNumPart = 2; break; |
---|
2916 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
2917 | case SIZE_NxN: iNumPart = 4; break; |
---|
2918 | case SIZE_2NxnU: iNumPart = 2; break; |
---|
2919 | case SIZE_2NxnD: iNumPart = 2; break; |
---|
2920 | case SIZE_nLx2N: iNumPart = 2; break; |
---|
2921 | case SIZE_nRx2N: iNumPart = 2; break; |
---|
2922 | default: assert (0); break; |
---|
2923 | } |
---|
2924 | |
---|
2925 | return iNumPart; |
---|
2926 | } |
---|
2927 | |
---|
2928 | #if H_3D_IC |
---|
2929 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU) |
---|
2930 | { |
---|
2931 | UInt uiNumPartition = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition; |
---|
2932 | UInt uiTmpAbsPartIdx = bLCU ? uiAbsPartIdx : 0; |
---|
2933 | |
---|
2934 | switch ( m_pePartSize[uiTmpAbsPartIdx] ) |
---|
2935 | { |
---|
2936 | case SIZE_2NxN: |
---|
2937 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1; |
---|
2938 | break; |
---|
2939 | case SIZE_Nx2N: |
---|
2940 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2; |
---|
2941 | break; |
---|
2942 | case SIZE_NxN: |
---|
2943 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx; |
---|
2944 | break; |
---|
2945 | case SIZE_2NxnU: |
---|
2946 | riWidth = getWidth( uiTmpAbsPartIdx ); |
---|
2947 | riHeight = ( uiPartIdx == 0 ) ? getHeight( uiTmpAbsPartIdx ) >> 2 : ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ); |
---|
2948 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3; |
---|
2949 | break; |
---|
2950 | case SIZE_2NxnD: |
---|
2951 | riWidth = getWidth( uiTmpAbsPartIdx ); |
---|
2952 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ) : getHeight( uiTmpAbsPartIdx ) >> 2; |
---|
2953 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3); |
---|
2954 | break; |
---|
2955 | case SIZE_nLx2N: |
---|
2956 | riWidth = ( uiPartIdx == 0 ) ? getWidth( uiTmpAbsPartIdx ) >> 2 : ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ); |
---|
2957 | riHeight = getHeight( uiTmpAbsPartIdx ); |
---|
2958 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4; |
---|
2959 | break; |
---|
2960 | case SIZE_nRx2N: |
---|
2961 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ) : getWidth( uiTmpAbsPartIdx ) >> 2; |
---|
2962 | riHeight = getHeight( uiTmpAbsPartIdx ); |
---|
2963 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4); |
---|
2964 | break; |
---|
2965 | default: |
---|
2966 | assert ( m_pePartSize[uiTmpAbsPartIdx] == SIZE_2Nx2N ); |
---|
2967 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = 0; |
---|
2968 | break; |
---|
2969 | } |
---|
2970 | } |
---|
2971 | #else |
---|
2972 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
---|
2973 | { |
---|
2974 | switch ( m_pePartSize[0] ) |
---|
2975 | { |
---|
2976 | case SIZE_2NxN: |
---|
2977 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2978 | break; |
---|
2979 | case SIZE_Nx2N: |
---|
2980 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
2981 | break; |
---|
2982 | case SIZE_NxN: |
---|
2983 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2984 | break; |
---|
2985 | case SIZE_2NxnU: |
---|
2986 | riWidth = getWidth(0); |
---|
2987 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
2988 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
---|
2989 | break; |
---|
2990 | case SIZE_2NxnD: |
---|
2991 | riWidth = getWidth(0); |
---|
2992 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
2993 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
---|
2994 | break; |
---|
2995 | case SIZE_nLx2N: |
---|
2996 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
2997 | riHeight = getHeight(0); |
---|
2998 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
---|
2999 | break; |
---|
3000 | case SIZE_nRx2N: |
---|
3001 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
3002 | riHeight = getHeight(0); |
---|
3003 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
3004 | break; |
---|
3005 | default: |
---|
3006 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
3007 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
3008 | break; |
---|
3009 | } |
---|
3010 | } |
---|
3011 | #endif |
---|
3012 | |
---|
3013 | |
---|
3014 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
3015 | { |
---|
3016 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
3017 | { |
---|
3018 | TComMv cZeroMv; |
---|
3019 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
3020 | return; |
---|
3021 | } |
---|
3022 | |
---|
3023 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
3024 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
3025 | } |
---|
3026 | |
---|
3027 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
3028 | { |
---|
3029 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
3030 | UInt uiPUWidth = 0; |
---|
3031 | |
---|
3032 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
3033 | { |
---|
3034 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
3035 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
3036 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
3037 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
3038 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
3039 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
3040 | case SIZE_nLx2N: |
---|
3041 | if ( uiPartIdx == 0 ) |
---|
3042 | { |
---|
3043 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
3044 | } |
---|
3045 | else if ( uiPartIdx == 1 ) |
---|
3046 | { |
---|
3047 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
3048 | } |
---|
3049 | else |
---|
3050 | { |
---|
3051 | assert(0); |
---|
3052 | } |
---|
3053 | break; |
---|
3054 | case SIZE_nRx2N: |
---|
3055 | if ( uiPartIdx == 0 ) |
---|
3056 | { |
---|
3057 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
3058 | } |
---|
3059 | else if ( uiPartIdx == 1 ) |
---|
3060 | { |
---|
3061 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
3062 | } |
---|
3063 | else |
---|
3064 | { |
---|
3065 | assert(0); |
---|
3066 | } |
---|
3067 | break; |
---|
3068 | default: |
---|
3069 | assert (0); |
---|
3070 | break; |
---|
3071 | } |
---|
3072 | |
---|
3073 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
3074 | } |
---|
3075 | |
---|
3076 | Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
3077 | { |
---|
3078 | UInt uiPUHeight = 0; |
---|
3079 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
3080 | { |
---|
3081 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
3082 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
3083 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
3084 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
3085 | case SIZE_2NxnU: |
---|
3086 | if ( uiPartIdx == 0 ) |
---|
3087 | { |
---|
3088 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
3089 | } |
---|
3090 | else if ( uiPartIdx == 1 ) |
---|
3091 | { |
---|
3092 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
3093 | } |
---|
3094 | else |
---|
3095 | { |
---|
3096 | assert(0); |
---|
3097 | } |
---|
3098 | break; |
---|
3099 | case SIZE_2NxnD: |
---|
3100 | if ( uiPartIdx == 0 ) |
---|
3101 | { |
---|
3102 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
3103 | } |
---|
3104 | else if ( uiPartIdx == 1 ) |
---|
3105 | { |
---|
3106 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
3107 | } |
---|
3108 | else |
---|
3109 | { |
---|
3110 | assert(0); |
---|
3111 | } |
---|
3112 | break; |
---|
3113 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
3114 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
3115 | default: |
---|
3116 | assert (0); |
---|
3117 | break; |
---|
3118 | } |
---|
3119 | |
---|
3120 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
3121 | } |
---|
3122 | |
---|
3123 | Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
3124 | { |
---|
3125 | ruiPartIdxLT = m_uiAbsIdxInLCU; |
---|
3126 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
3127 | |
---|
3128 | switch ( m_pePartSize[0] ) |
---|
3129 | { |
---|
3130 | case SIZE_2Nx2N: break; |
---|
3131 | case SIZE_2NxN: |
---|
3132 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
3133 | break; |
---|
3134 | case SIZE_Nx2N: |
---|
3135 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
3136 | break; |
---|
3137 | case SIZE_NxN: |
---|
3138 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
3139 | break; |
---|
3140 | case SIZE_2NxnU: |
---|
3141 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
3142 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
3143 | break; |
---|
3144 | case SIZE_2NxnD: |
---|
3145 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
3146 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
3147 | break; |
---|
3148 | case SIZE_nLx2N: |
---|
3149 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
---|
3150 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
3151 | break; |
---|
3152 | case SIZE_nRx2N: |
---|
3153 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
3154 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
---|
3155 | break; |
---|
3156 | default: |
---|
3157 | assert (0); |
---|
3158 | break; |
---|
3159 | } |
---|
3160 | |
---|
3161 | } |
---|
3162 | |
---|
3163 | Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
3164 | { |
---|
3165 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
3166 | |
---|
3167 | switch ( m_pePartSize[0] ) |
---|
3168 | { |
---|
3169 | case SIZE_2Nx2N: |
---|
3170 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
3171 | break; |
---|
3172 | case SIZE_2NxN: |
---|
3173 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
3174 | break; |
---|
3175 | case SIZE_Nx2N: |
---|
3176 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
3177 | break; |
---|
3178 | case SIZE_NxN: |
---|
3179 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
3180 | break; |
---|
3181 | case SIZE_2NxnU: |
---|
3182 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
3183 | break; |
---|
3184 | case SIZE_2NxnD: |
---|
3185 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
3186 | break; |
---|
3187 | case SIZE_nLx2N: |
---|
3188 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
---|
3189 | break; |
---|
3190 | case SIZE_nRx2N: |
---|
3191 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
3192 | break; |
---|
3193 | default: |
---|
3194 | assert (0); |
---|
3195 | break; |
---|
3196 | } |
---|
3197 | } |
---|
3198 | |
---|
3199 | /** Derives the partition index of neighbouring bottom right block |
---|
3200 | * \param [in] eCUMode |
---|
3201 | * \param [in] uiPartIdx |
---|
3202 | * \param [out] ruiPartIdxRB |
---|
3203 | */ |
---|
3204 | Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxRB ) |
---|
3205 | { |
---|
3206 | ruiPartIdxRB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth() + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1]; |
---|
3207 | |
---|
3208 | switch ( m_pePartSize[0] ) |
---|
3209 | { |
---|
3210 | case SIZE_2Nx2N: |
---|
3211 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
3212 | break; |
---|
3213 | case SIZE_2NxN: |
---|
3214 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
3215 | break; |
---|
3216 | case SIZE_Nx2N: |
---|
3217 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
3218 | break; |
---|
3219 | case SIZE_NxN: |
---|
3220 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
3221 | break; |
---|
3222 | case SIZE_2NxnU: |
---|
3223 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
3224 | break; |
---|
3225 | case SIZE_2NxnD: |
---|
3226 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
3227 | break; |
---|
3228 | case SIZE_nLx2N: |
---|
3229 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
---|
3230 | break; |
---|
3231 | case SIZE_nRx2N: |
---|
3232 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
---|
3233 | break; |
---|
3234 | default: |
---|
3235 | assert (0); |
---|
3236 | break; |
---|
3237 | } |
---|
3238 | } |
---|
3239 | |
---|
3240 | Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ) |
---|
3241 | { |
---|
3242 | UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; |
---|
3243 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset; |
---|
3244 | ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; |
---|
3245 | } |
---|
3246 | |
---|
3247 | Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ) |
---|
3248 | { |
---|
3249 | UInt uiAbsIdx; |
---|
3250 | UInt uiMinCuWidth, uiWidthInMinCus; |
---|
3251 | |
---|
3252 | uiMinCuWidth = getPic()->getMinCUWidth(); |
---|
3253 | uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; |
---|
3254 | uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; |
---|
3255 | uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); |
---|
3256 | ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; |
---|
3257 | } |
---|
3258 | |
---|
3259 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
3260 | { |
---|
3261 | |
---|
3262 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
3263 | { |
---|
3264 | return false; |
---|
3265 | } |
---|
3266 | |
---|
3267 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
3268 | { |
---|
3269 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
3270 | { |
---|
3271 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
3272 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
3273 | { |
---|
3274 | return false; |
---|
3275 | } |
---|
3276 | } |
---|
3277 | } |
---|
3278 | |
---|
3279 | return true; |
---|
3280 | } |
---|
3281 | |
---|
3282 | #if H_3D_VSP |
---|
3283 | |
---|
3284 | /** Add a VSP merging candidate |
---|
3285 | * \Inputs |
---|
3286 | * \param uiPUIdx: PU index within a CU |
---|
3287 | * \param ucVspMergePos: Specify the VSP merge candidate position |
---|
3288 | * \param mrgCandIdx: Target merge candidate index. At encoder, it is set equal to -1, such that the whole merge candidate list will be constructed. |
---|
3289 | * \param pDinfo: The "disparity information" derived from neighboring blocks. Type 1 MV. |
---|
3290 | * \param uiCount: The next position to add VSP merge candidate |
---|
3291 | * |
---|
3292 | * \Outputs |
---|
3293 | * \param uiCount: The next position to add merge candidate. Will be updated if VSP is successfully added |
---|
3294 | * \param abCandIsInter: abCandIsInter[iCount] tells that VSP candidate is an Inter candidate, if VSP is successfully added |
---|
3295 | * \param pcMvFieldNeighbours: Return combined motion information, then stored to a global buffer |
---|
3296 | * 1) the "disparity vector". Type 1 MV. To be used to fetch a depth block. |
---|
3297 | * 2) the ref index /list. Type 2 reference picture pointer, typically for texture |
---|
3298 | * \param puhInterDirNeighbours: Indicate the VSP prediction direction. |
---|
3299 | * \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 |
---|
3300 | * |
---|
3301 | * \Return |
---|
3302 | * true: if the VSP candidate is added at the target position |
---|
3303 | * false: otherwise |
---|
3304 | */ |
---|
3305 | inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount, |
---|
3306 | Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag ) |
---|
3307 | { |
---|
3308 | if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) || m_pcSlice->getIsDepth() ) |
---|
3309 | { |
---|
3310 | return false; |
---|
3311 | } |
---|
3312 | |
---|
3313 | Int refViewIdx = pDInfo->m_aVIdxCan; |
---|
3314 | TComPic* picDepth = getSlice()->getIvPic( true, refViewIdx ); |
---|
3315 | |
---|
3316 | if( picDepth == NULL ) // No depth reference avail |
---|
3317 | { |
---|
3318 | // Is this allowed to happen? When not an assertion should be added here! |
---|
3319 | return false; |
---|
3320 | } |
---|
3321 | |
---|
3322 | Bool refViewAvailFlag = false; |
---|
3323 | UChar predFlag[2] = {0, 0}; |
---|
3324 | Int refListIdY = 0; |
---|
3325 | Int viewIdInRefListX = -1; |
---|
3326 | |
---|
3327 | for( Int iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ ) |
---|
3328 | { |
---|
3329 | RefPicList eRefPicListX = RefPicList( iRefListIdX ); |
---|
3330 | for ( Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicListX) && !refViewAvailFlag; i++ ) |
---|
3331 | { |
---|
3332 | Int viewIdxRefInListX = m_pcSlice->getRefPic(eRefPicListX, i)->getViewIndex(); |
---|
3333 | if ( viewIdxRefInListX == refViewIdx ) |
---|
3334 | { |
---|
3335 | refViewAvailFlag = true; |
---|
3336 | predFlag[iRefListIdX] = 1; |
---|
3337 | viewIdInRefListX = m_pcSlice->getRefPic(eRefPicListX, i)->getViewId(); |
---|
3338 | refListIdY = 1 - iRefListIdX; |
---|
3339 | pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acNBDV, i ); |
---|
3340 | #if H_3D_NBDV |
---|
3341 | pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].getMv().setIDVFlag (false); |
---|
3342 | #endif |
---|
3343 | } |
---|
3344 | } |
---|
3345 | } |
---|
3346 | |
---|
3347 | if (m_pcSlice->isInterB() && refViewAvailFlag) |
---|
3348 | { |
---|
3349 | RefPicList eRefPicListY = RefPicList( refListIdY ); |
---|
3350 | refViewAvailFlag = false; |
---|
3351 | for ( Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicListY) && !refViewAvailFlag; i++ ) |
---|
3352 | { |
---|
3353 | Int viewIdxRefInListY = m_pcSlice->getRefPic(eRefPicListY, i)->getViewIndex(); |
---|
3354 | if ( viewIdxRefInListY != refViewIdx && viewIdxRefInListY != m_pcSlice->getViewIndex() ) |
---|
3355 | { |
---|
3356 | refViewAvailFlag = true; |
---|
3357 | predFlag[refListIdY] = 1; |
---|
3358 | TComMv cMv = pDInfo->m_acNBDV; |
---|
3359 | |
---|
3360 | Int viewIdInRefListY = m_pcSlice->getRefPic( eRefPicListY, i)->getViewId(); |
---|
3361 | Int currViewId = m_pcSlice->getViewId(); |
---|
3362 | |
---|
3363 | //// Following might be added here when MV-HEVC 5 HLS is included (and derivations above removed): |
---|
3364 | // Int viewIdInRefListX = m_pcSlice->getVPS()->getViewIdVal( refViewIdx ); |
---|
3365 | |
---|
3366 | Int iScale = xGetDistScaleFactor( currViewId, viewIdInRefListY, currViewId, viewIdInRefListX ); |
---|
3367 | |
---|
3368 | // Can iScale == 4096 happen?, I guess not since viewIdInRefListY is always unequal to viewIdInRefListX. |
---|
3369 | if ( iScale != 4096 && m_pcSlice->getVPS()->getIvMvScalingFlag() ) |
---|
3370 | { |
---|
3371 | cMv = cMv.scaleMv( iScale ); |
---|
3372 | } |
---|
3373 | else |
---|
3374 | { |
---|
3375 | |
---|
3376 | cMv = cMv; |
---|
3377 | } |
---|
3378 | clipMv( cMv ); |
---|
3379 | pcMvFieldNeighbours[(iCount<<1)+refListIdY].setMvField( cMv, i ); |
---|
3380 | #if H_3D_NBDV |
---|
3381 | pcMvFieldNeighbours[(iCount<<1)+refListIdY].getMv().setIDVFlag (false); |
---|
3382 | #endif |
---|
3383 | } |
---|
3384 | } |
---|
3385 | } |
---|
3386 | |
---|
3387 | // Set values to be returned |
---|
3388 | abCandIsInter [iCount] = true; |
---|
3389 | puhInterDirNeighbours[iCount] = (predFlag[0] | (predFlag[1] << 1)); |
---|
3390 | vspFlag [iCount] = 1; |
---|
3391 | |
---|
3392 | if ( mrgCandIdx == iCount ) |
---|
3393 | { |
---|
3394 | return true; |
---|
3395 | } |
---|
3396 | |
---|
3397 | iCount++; |
---|
3398 | |
---|
3399 | return false; |
---|
3400 | } |
---|
3401 | |
---|
3402 | #endif |
---|
3403 | |
---|
3404 | #if H_3D_IV_MERGE |
---|
3405 | inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* ivCandDir, TComMv* ivCandMv, |
---|
3406 | Int* ivCandRefIdx, Int iPosIvDC, Int* vspFlag ) |
---|
3407 | { |
---|
3408 | for(Int iLoop = 0; iLoop < 2; iLoop ++ ) |
---|
3409 | { |
---|
3410 | // IvDcShift (Derived from spatial Iv neighboring blocks) |
---|
3411 | if( iLoop == 1 ) |
---|
3412 | { |
---|
3413 | Int iFirDispCand = -1; |
---|
3414 | if (xGetPosFirstAvailDmvCand(iCount, pcMvFieldNeighbours, ivCandDir, iPosIvDC, vspFlag, iFirDispCand)) |
---|
3415 | { |
---|
3416 | TComMv cMv; |
---|
3417 | cMv = pcMvFieldNeighbours[(iFirDispCand<<1)].getMv(); |
---|
3418 | cMv.setHor(cMv.getHor()+4); |
---|
3419 | if(m_pcSlice->getVPS()->getViewSynthesisPredFlag(m_pcSlice->getLayerIdInVps())) |
---|
3420 | { |
---|
3421 | cMv.setVer(0); |
---|
3422 | } |
---|
3423 | clipMv( cMv ); |
---|
3424 | abCandIsInter [ iCount ] = true; |
---|
3425 | puhInterDirNeighbours[ iCount ] = puhInterDirNeighbours[iFirDispCand]; |
---|
3426 | pcMvFieldNeighbours [ iCount << 1 ].setMvField(cMv, pcMvFieldNeighbours[( iFirDispCand << 1)].getRefIdx() ); |
---|
3427 | pcMvFieldNeighbours [(iCount << 1) + 1 ].setMvField(pcMvFieldNeighbours[(iFirDispCand << 1) + 1].getMv(), pcMvFieldNeighbours[( iFirDispCand << 1) + 1].getRefIdx() ); |
---|
3428 | |
---|
3429 | if( mrgCandIdx == iCount ) |
---|
3430 | { |
---|
3431 | return true; |
---|
3432 | } |
---|
3433 | |
---|
3434 | iCount++; |
---|
3435 | break; |
---|
3436 | } |
---|
3437 | } |
---|
3438 | |
---|
3439 | /// iLoop = 0 --> IvMCShift |
---|
3440 | /// iLoop = 1 --> IvDCShift (Derived from IvDC) |
---|
3441 | if(ivCandDir[iLoop + 2]) |
---|
3442 | { |
---|
3443 | abCandIsInter [ iCount ] = true; |
---|
3444 | puhInterDirNeighbours[ iCount ] = ivCandDir[iLoop + 2]; |
---|
3445 | if( ( ivCandDir[iLoop + 2] & 1 ) == 1 ) |
---|
3446 | { |
---|
3447 | pcMvFieldNeighbours[ iCount<<1 ].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] ); |
---|
3448 | } |
---|
3449 | if( ( ivCandDir[iLoop + 2] & 2 ) == 2 ) |
---|
3450 | { |
---|
3451 | pcMvFieldNeighbours[ (iCount<<1)+1 ].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] ); |
---|
3452 | } |
---|
3453 | |
---|
3454 | // Prune IvMC vs. IvMcShift |
---|
3455 | Bool bRemove = false; |
---|
3456 | if( !iLoop && ivCandDir[0] > 0) |
---|
3457 | { |
---|
3458 | if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[0] && pcMvFieldNeighbours[0 ]== pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[1]==pcMvFieldNeighbours[(iCount<<1)+1]) |
---|
3459 | { |
---|
3460 | bRemove = true; |
---|
3461 | abCandIsInter [ iCount ] = false; |
---|
3462 | puhInterDirNeighbours[ iCount ] = 0; |
---|
3463 | TComMv cZeroMv; |
---|
3464 | pcMvFieldNeighbours [ iCount<<1 ].setMvField( cZeroMv, NOT_VALID ); |
---|
3465 | pcMvFieldNeighbours [(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID ); |
---|
3466 | } |
---|
3467 | } |
---|
3468 | if(!bRemove) |
---|
3469 | { |
---|
3470 | #if H_3D_NBDV |
---|
3471 | if(iLoop) // For IvMcShift candidate |
---|
3472 | { |
---|
3473 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
---|
3474 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
---|
3475 | } |
---|
3476 | #endif |
---|
3477 | if( mrgCandIdx == iCount ) |
---|
3478 | { |
---|
3479 | return true; |
---|
3480 | } |
---|
3481 | iCount++; |
---|
3482 | } |
---|
3483 | break; |
---|
3484 | } |
---|
3485 | } |
---|
3486 | return false; |
---|
3487 | } |
---|
3488 | |
---|
3489 | inline Bool TComDataCU::xGetPosFirstAvailDmvCand( Int iCount, TComMvField* pcMvFieldNeighbours, Int* ivCandDir, Int posIvDC, Int* vspFlag, Int& posFirstAvailDmvCand ) |
---|
3490 | { |
---|
3491 | // ivCandDir[0] == true --> IvMC is available and excluded in loop over merge list. |
---|
3492 | for ( Int currListPos = (ivCandDir[0] ? 1 : 0); currListPos < iCount; currListPos++ ) |
---|
3493 | { |
---|
3494 | if ( ( currListPos == posIvDC ) || ( vspFlag[ currListPos ] == 1 ) ) |
---|
3495 | { |
---|
3496 | continue; |
---|
3497 | } |
---|
3498 | else if((pcMvFieldNeighbours[currListPos<<1].getRefIdx() != -1 ) && (getSlice()->getViewIndex() != getSlice()->getRefPic(RefPicList(0), pcMvFieldNeighbours[currListPos<<1].getRefIdx())->getViewIndex())) |
---|
3499 | { |
---|
3500 | posFirstAvailDmvCand = currListPos; |
---|
3501 | return true; |
---|
3502 | } |
---|
3503 | } |
---|
3504 | return false; |
---|
3505 | } |
---|
3506 | |
---|
3507 | #endif |
---|
3508 | /** Constructs a list of merging candidates |
---|
3509 | * \param uiAbsPartIdx |
---|
3510 | * \param uiPUIdx |
---|
3511 | * \param uiDepth |
---|
3512 | * \param pcMvFieldNeighbours |
---|
3513 | * \param puhInterDirNeighbours |
---|
3514 | * \param numValidMergeCand |
---|
3515 | */ |
---|
3516 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
3517 | #if H_3D_VSP |
---|
3518 | , Int* vspFlag |
---|
3519 | , InheritedVSPDisInfo* inheritedVSPDisInfo |
---|
3520 | #endif |
---|
3521 | , Int& numValidMergeCand, Int mrgCandIdx |
---|
3522 | ) |
---|
3523 | { |
---|
3524 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
3525 | #if H_3D_IV_MERGE |
---|
3526 | //////////////////////////// |
---|
3527 | //////// INIT LISTS //////// |
---|
3528 | //////////////////////////// |
---|
3529 | TComMv cZeroMv; |
---|
3530 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ]; |
---|
3531 | #else |
---|
3532 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
3533 | #endif |
---|
3534 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
3535 | { |
---|
3536 | abCandIsInter[ui] = false; |
---|
3537 | #if H_3D_IV_MERGE |
---|
3538 | pcMvFieldNeighbours[ ( ui << 1 ) ].setMvField(cZeroMv, NOT_VALID); |
---|
3539 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID); |
---|
3540 | #else |
---|
3541 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
3542 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
3543 | #endif |
---|
3544 | } |
---|
3545 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
3546 | #if H_3D |
---|
3547 | ////////////////////////////////// |
---|
3548 | //////// DERIVE LOCATIONS //////// |
---|
3549 | ////////////////////////////////// |
---|
3550 | #endif |
---|
3551 | // compute the location of the current PU |
---|
3552 | Int xP, yP, nPSW, nPSH; |
---|
3553 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
3554 | |
---|
3555 | Int iCount = 0; |
---|
3556 | |
---|
3557 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
3558 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
3559 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
3560 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
3561 | #if H_3D_IV_MERGE |
---|
3562 | |
---|
3563 | ///////////////////////////////////////////// |
---|
3564 | //////// TEXTURE MERGE CANDIDATE (T) //////// |
---|
3565 | ///////////////////////////////////////////// |
---|
3566 | |
---|
3567 | if( m_pcSlice->getIsDepth()) |
---|
3568 | { |
---|
3569 | UInt uiPartIdxCenter; |
---|
3570 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
3571 | TComDataCU *pcTextureCU = m_pcSlice->getTexturePic()->getCU( getAddr() ); |
---|
3572 | |
---|
3573 | if ( pcTextureCU && !pcTextureCU->isIntra( uiPartIdxCenter ) ) |
---|
3574 | { |
---|
3575 | pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3576 | Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1].getRefIdx() ); |
---|
3577 | if( (pcMvFieldNeighbours[iCount<<1].getRefIdx()>=0) && ( iValidDepRef >= 0 ) ) |
---|
3578 | { |
---|
3579 | TComMv cMvPred = pcMvFieldNeighbours[iCount<<1].getMv(); |
---|
3580 | const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); |
---|
3581 | cMvPred+=cAdd; |
---|
3582 | cMvPred>>=2; |
---|
3583 | clipMv(cMvPred); |
---|
3584 | pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,iValidDepRef); |
---|
3585 | } |
---|
3586 | |
---|
3587 | if ( getSlice()->isInterB() ) |
---|
3588 | { |
---|
3589 | pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3590 | iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx() ); |
---|
3591 | if( (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()>=0) && ( iValidDepRef >= 0) ) |
---|
3592 | { |
---|
3593 | TComMv cMvPred = pcMvFieldNeighbours[(iCount<<1)+1].getMv(); |
---|
3594 | const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); |
---|
3595 | cMvPred+=cAdd; |
---|
3596 | cMvPred>>=2; |
---|
3597 | clipMv(cMvPred); |
---|
3598 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField(cMvPred,iValidDepRef); |
---|
3599 | } |
---|
3600 | } |
---|
3601 | |
---|
3602 | puhInterDirNeighbours[iCount] = (pcMvFieldNeighbours[iCount<<1].getRefIdx()>=0)?1:0; |
---|
3603 | puhInterDirNeighbours[iCount] += (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()>=0)?2:0; |
---|
3604 | |
---|
3605 | if( puhInterDirNeighbours[iCount] != 0 ) |
---|
3606 | { |
---|
3607 | abCandIsInter[iCount] = true; |
---|
3608 | if ( mrgCandIdx == iCount ) |
---|
3609 | { |
---|
3610 | return; |
---|
3611 | } |
---|
3612 | iCount ++; |
---|
3613 | } |
---|
3614 | } |
---|
3615 | } |
---|
3616 | |
---|
3617 | ////////////////////////////////// |
---|
3618 | //////// GET DISPARITIES //////// |
---|
3619 | ////////////////////////////////// |
---|
3620 | |
---|
3621 | DisInfo cDisInfo = getDvInfo(uiAbsPartIdx); |
---|
3622 | |
---|
3623 | for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) |
---|
3624 | { |
---|
3625 | inheritedVSPDisInfo[i].m_acDvInfo = cDisInfo; |
---|
3626 | } |
---|
3627 | |
---|
3628 | ///////////////////////////////////////////////////////////////// |
---|
3629 | //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC Candidates ///// |
---|
3630 | ///////////////////////////////////////////////////////////////// |
---|
3631 | |
---|
3632 | Int posIvDC = -1; |
---|
3633 | Bool bLeftAvai = false; |
---|
3634 | Int iPosLeftAbove[2] = {-1, -1}; |
---|
3635 | |
---|
3636 | |
---|
3637 | // { IvMCL0, IvMCL1, IvDCL0, IvDCL1, IvMCL0Shift, IvMCL1Shift, IvDCL0Shift, IvDCL1Shift }; |
---|
3638 | // An enumerator would be appropriate here! |
---|
3639 | TComMv ivCandMv [8]; |
---|
3640 | Int ivCandRefIdx[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; |
---|
3641 | |
---|
3642 | // { IvMC, IvDC, IvMCShift, IvDCShift }; |
---|
3643 | Int ivCandDir [4] = {0, 0, 0, 0}; |
---|
3644 | |
---|
3645 | Bool ivMvPredFlag = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() ); |
---|
3646 | |
---|
3647 | if ( ivMvPredFlag ) |
---|
3648 | { |
---|
3649 | getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir ); |
---|
3650 | } |
---|
3651 | |
---|
3652 | /////////////////////////////////////////////// |
---|
3653 | //////// INTER VIEW MOTION COMP(IvMC) ///////// |
---|
3654 | /////////////////////////////////////////////// |
---|
3655 | |
---|
3656 | if( ivCandDir[0] ) |
---|
3657 | { |
---|
3658 | abCandIsInter [ iCount ] = true; |
---|
3659 | puhInterDirNeighbours[ iCount ] = ivCandDir[0]; |
---|
3660 | |
---|
3661 | if( ( ivCandDir[0] & 1 ) == 1 ) |
---|
3662 | { |
---|
3663 | pcMvFieldNeighbours[ iCount<<1 ].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] ); |
---|
3664 | } |
---|
3665 | if( ( ivCandDir[0] & 2 ) == 2 ) |
---|
3666 | { |
---|
3667 | pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] ); |
---|
3668 | } |
---|
3669 | |
---|
3670 | if ( mrgCandIdx == iCount ) |
---|
3671 | { |
---|
3672 | return; |
---|
3673 | } |
---|
3674 | iCount ++; |
---|
3675 | } |
---|
3676 | |
---|
3677 | // early termination |
---|
3678 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3679 | { |
---|
3680 | return; |
---|
3681 | } |
---|
3682 | #endif |
---|
3683 | |
---|
3684 | #if H_3D |
---|
3685 | //////////////////////////// |
---|
3686 | //////// LEFT (A1) ///////// |
---|
3687 | //////////////////////////// |
---|
3688 | #endif |
---|
3689 | //left |
---|
3690 | UInt uiLeftPartIdx = 0; |
---|
3691 | TComDataCU* pcCULeft = 0; |
---|
3692 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
3693 | Bool isAvailableA1 = pcCULeft && |
---|
3694 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
3695 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
3696 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
---|
3697 | if ( isAvailableA1 ) |
---|
3698 | { |
---|
3699 | abCandIsInter[iCount] = true; |
---|
3700 | // get Inter Dir |
---|
3701 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
3702 | // get Mv from Left |
---|
3703 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3704 | if ( getSlice()->isInterB() ) |
---|
3705 | { |
---|
3706 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3707 | } |
---|
3708 | #if H_3D_IV_MERGE |
---|
3709 | Bool bRemoveSpa = false; //pruning to inter-view candidates |
---|
3710 | Int iCnloop = iCount - 1; |
---|
3711 | for(; iCnloop >= 0; iCnloop --) |
---|
3712 | { |
---|
3713 | if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1]) |
---|
3714 | { |
---|
3715 | bRemoveSpa = true; |
---|
3716 | abCandIsInter [ iCount ] = false; |
---|
3717 | |
---|
3718 | //reset to the default value for MC |
---|
3719 | puhInterDirNeighbours[iCount] = 0; |
---|
3720 | pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID ); |
---|
3721 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID ); |
---|
3722 | break; |
---|
3723 | } |
---|
3724 | } |
---|
3725 | if(!bRemoveSpa) |
---|
3726 | { |
---|
3727 | bLeftAvai = true; |
---|
3728 | iPosLeftAbove[0] = iCount; |
---|
3729 | #if H_3D_NBDV |
---|
3730 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
---|
3731 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
---|
3732 | #endif |
---|
3733 | #if H_3D_VSP |
---|
3734 | if (pcCULeft->getVSPFlag(uiLeftPartIdx) == 1) |
---|
3735 | { |
---|
3736 | vspFlag[iCount] = 1; |
---|
3737 | xInheritVSPDisInfo(pcCULeft,uiLeftPartIdx,iCount,inheritedVSPDisInfo); |
---|
3738 | } |
---|
3739 | #endif |
---|
3740 | if ( mrgCandIdx == iCount ) |
---|
3741 | { |
---|
3742 | return; |
---|
3743 | } |
---|
3744 | iCount ++; |
---|
3745 | } |
---|
3746 | #else // H_3D_IV_MERGE |
---|
3747 | if ( mrgCandIdx == iCount ) |
---|
3748 | { |
---|
3749 | return; |
---|
3750 | } |
---|
3751 | iCount ++; |
---|
3752 | #endif // H_3D_IV_MERGE |
---|
3753 | } |
---|
3754 | |
---|
3755 | // early termination |
---|
3756 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3757 | { |
---|
3758 | return; |
---|
3759 | } |
---|
3760 | #if H_3D |
---|
3761 | //////////////////////////// |
---|
3762 | //////// ABOVE (B1) //////// |
---|
3763 | //////////////////////////// |
---|
3764 | #endif |
---|
3765 | // above |
---|
3766 | UInt uiAbovePartIdx = 0; |
---|
3767 | TComDataCU* pcCUAbove = 0; |
---|
3768 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
3769 | Bool isAvailableB1 = pcCUAbove && |
---|
3770 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
3771 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
3772 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
---|
3773 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
3774 | { |
---|
3775 | abCandIsInter[iCount] = true; |
---|
3776 | // get Inter Dir |
---|
3777 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
3778 | // get Mv from Left |
---|
3779 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3780 | if ( getSlice()->isInterB() ) |
---|
3781 | { |
---|
3782 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3783 | } |
---|
3784 | #if H_3D_IV_MERGE |
---|
3785 | Bool bRemoveSpa = false; //pruning to inter-view candidates |
---|
3786 | Int iCnloop = bLeftAvai? (iCount-2): (iCount-1); |
---|
3787 | for(; iCnloop >= 0; iCnloop --) |
---|
3788 | { |
---|
3789 | if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1]) |
---|
3790 | { |
---|
3791 | bRemoveSpa = true; |
---|
3792 | abCandIsInter [ iCount ] = false; |
---|
3793 | |
---|
3794 | //reset to the default value for MC |
---|
3795 | puhInterDirNeighbours[iCount] = 0; |
---|
3796 | |
---|
3797 | pcMvFieldNeighbours[iCount<<1] .setMvField( cZeroMv, NOT_VALID ); |
---|
3798 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID ); |
---|
3799 | break; |
---|
3800 | } |
---|
3801 | } |
---|
3802 | |
---|
3803 | if(!bRemoveSpa) |
---|
3804 | { |
---|
3805 | iPosLeftAbove[1] = iCount; |
---|
3806 | #if H_3D_NBDV |
---|
3807 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
---|
3808 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
---|
3809 | #endif |
---|
3810 | #if H_3D_VSP |
---|
3811 | if (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1) |
---|
3812 | { |
---|
3813 | |
---|
3814 | vspFlag[iCount] = 1; |
---|
3815 | xInheritVSPDisInfo(pcCUAbove,uiAbovePartIdx,iCount,inheritedVSPDisInfo); |
---|
3816 | } |
---|
3817 | #endif |
---|
3818 | if ( mrgCandIdx == iCount ) |
---|
3819 | { |
---|
3820 | return; |
---|
3821 | } |
---|
3822 | iCount ++; |
---|
3823 | } |
---|
3824 | #else // H_3D_IV_MERGE |
---|
3825 | if ( mrgCandIdx == iCount ) |
---|
3826 | { |
---|
3827 | return; |
---|
3828 | } |
---|
3829 | iCount ++; |
---|
3830 | #endif // H_3D_IV_MERGE |
---|
3831 | } |
---|
3832 | // early termination |
---|
3833 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3834 | { |
---|
3835 | return; |
---|
3836 | } |
---|
3837 | |
---|
3838 | #if H_3D |
---|
3839 | ////////////////////////////////// |
---|
3840 | //////// ABOVE RIGHT (B0) //////// |
---|
3841 | ////////////////////////////////// |
---|
3842 | #endif |
---|
3843 | |
---|
3844 | // above right |
---|
3845 | UInt uiAboveRightPartIdx = 0; |
---|
3846 | TComDataCU* pcCUAboveRight = 0; |
---|
3847 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
3848 | Bool isAvailableB0 = pcCUAboveRight && |
---|
3849 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
3850 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
---|
3851 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
3852 | { |
---|
3853 | abCandIsInter[iCount] = true; |
---|
3854 | // get Inter Dir |
---|
3855 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
3856 | // get Mv from Left |
---|
3857 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3858 | if ( getSlice()->isInterB() ) |
---|
3859 | { |
---|
3860 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3861 | } |
---|
3862 | #if H_3D_NBDV |
---|
3863 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
---|
3864 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
---|
3865 | #endif |
---|
3866 | #if H_3D_VSP |
---|
3867 | if (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1) |
---|
3868 | { |
---|
3869 | vspFlag[iCount] = 1; |
---|
3870 | xInheritVSPDisInfo(pcCUAboveRight,uiAboveRightPartIdx,iCount,inheritedVSPDisInfo); |
---|
3871 | } |
---|
3872 | #endif |
---|
3873 | if ( mrgCandIdx == iCount ) |
---|
3874 | { |
---|
3875 | return; |
---|
3876 | } |
---|
3877 | iCount ++; |
---|
3878 | } |
---|
3879 | // early termination |
---|
3880 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3881 | { |
---|
3882 | return; |
---|
3883 | } |
---|
3884 | |
---|
3885 | #if H_3D_IV_MERGE |
---|
3886 | ///////////////////////////////////////////// |
---|
3887 | //////// INTER VIEW DISP COMP (IvDC) //////// |
---|
3888 | ///////////////////////////////////////////// |
---|
3889 | |
---|
3890 | if( ivCandDir[1] ) |
---|
3891 | { |
---|
3892 | assert(iCount < getSlice()->getMaxNumMergeCand()); |
---|
3893 | abCandIsInter [ iCount ] = true; |
---|
3894 | puhInterDirNeighbours[ iCount ] = ivCandDir[1]; |
---|
3895 | if( ( ivCandDir[1] & 1 ) == 1 ) |
---|
3896 | { |
---|
3897 | pcMvFieldNeighbours[ iCount<<1 ].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] ); |
---|
3898 | } |
---|
3899 | if( ( ivCandDir[1] & 2 ) == 2 ) |
---|
3900 | { |
---|
3901 | pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] ); |
---|
3902 | } |
---|
3903 | |
---|
3904 | Bool bRemoveSpa = false; //pruning to A1, B1 |
---|
3905 | for(Int i = 0; i < 2; i ++) |
---|
3906 | { |
---|
3907 | Int iCnloop = iPosLeftAbove[i]; |
---|
3908 | if ( iCnloop == -1 ) |
---|
3909 | { |
---|
3910 | continue; |
---|
3911 | } |
---|
3912 | if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1]) |
---|
3913 | { |
---|
3914 | bRemoveSpa = true; |
---|
3915 | abCandIsInter [ iCount ] = false; |
---|
3916 | //reset to the default value for MC |
---|
3917 | puhInterDirNeighbours[iCount] = 0; |
---|
3918 | pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID ); |
---|
3919 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID ); |
---|
3920 | break; |
---|
3921 | } |
---|
3922 | } |
---|
3923 | if(!bRemoveSpa) |
---|
3924 | { |
---|
3925 | #if H_3D_NBDV |
---|
3926 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
---|
3927 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
---|
3928 | #endif |
---|
3929 | posIvDC = iCount; |
---|
3930 | if ( mrgCandIdx == iCount ) |
---|
3931 | return; |
---|
3932 | iCount ++; |
---|
3933 | |
---|
3934 | // early termination |
---|
3935 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3936 | { |
---|
3937 | return; |
---|
3938 | } |
---|
3939 | } |
---|
3940 | } |
---|
3941 | #endif // H_3D_IV_MERGE |
---|
3942 | |
---|
3943 | #if H_3D_VSP |
---|
3944 | ///////////////////////////////////////////////// |
---|
3945 | //////// VIEW SYNTHESIS PREDICTION (VSP) //////// |
---|
3946 | ///////////////////////////////////////////////// |
---|
3947 | |
---|
3948 | if ( xAddVspCand( mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag ) ) |
---|
3949 | { |
---|
3950 | return; |
---|
3951 | } |
---|
3952 | |
---|
3953 | // early termination |
---|
3954 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3955 | { |
---|
3956 | return; |
---|
3957 | } |
---|
3958 | #endif |
---|
3959 | #if H_3D |
---|
3960 | /////////////////////////////////// |
---|
3961 | //////// LEFT BOTTOM (A0) //////// |
---|
3962 | /////////////////////////////////// |
---|
3963 | #endif |
---|
3964 | |
---|
3965 | //left bottom |
---|
3966 | UInt uiLeftBottomPartIdx = 0; |
---|
3967 | TComDataCU* pcCULeftBottom = 0; |
---|
3968 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
3969 | Bool isAvailableA0 = pcCULeftBottom && |
---|
3970 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
3971 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
---|
3972 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
3973 | { |
---|
3974 | abCandIsInter[iCount] = true; |
---|
3975 | // get Inter Dir |
---|
3976 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
3977 | // get Mv from Left |
---|
3978 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3979 | if ( getSlice()->isInterB() ) |
---|
3980 | { |
---|
3981 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3982 | } |
---|
3983 | #if H_3D_NBDV |
---|
3984 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
---|
3985 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
---|
3986 | #endif |
---|
3987 | #if H_3D_VSP |
---|
3988 | if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) == 1) |
---|
3989 | { |
---|
3990 | vspFlag[iCount] = 1; |
---|
3991 | xInheritVSPDisInfo(pcCULeftBottom,uiLeftBottomPartIdx,iCount,inheritedVSPDisInfo); |
---|
3992 | } |
---|
3993 | #endif |
---|
3994 | if ( mrgCandIdx == iCount ) |
---|
3995 | { |
---|
3996 | return; |
---|
3997 | } |
---|
3998 | iCount ++; |
---|
3999 | } |
---|
4000 | // early termination |
---|
4001 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4002 | { |
---|
4003 | return; |
---|
4004 | } |
---|
4005 | #if H_3D |
---|
4006 | /////////////////////////////////// |
---|
4007 | //////// LEFT ABOVE (B2) //////// |
---|
4008 | /////////////////////////////////// |
---|
4009 | #endif |
---|
4010 | |
---|
4011 | // above left |
---|
4012 | if( iCount < 4 ) |
---|
4013 | { |
---|
4014 | UInt uiAboveLeftPartIdx = 0; |
---|
4015 | TComDataCU* pcCUAboveLeft = 0; |
---|
4016 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
4017 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
4018 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
4019 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
---|
4020 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
4021 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
4022 | { |
---|
4023 | abCandIsInter[iCount] = true; |
---|
4024 | // get Inter Dir |
---|
4025 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
4026 | // get Mv from Left |
---|
4027 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4028 | if ( getSlice()->isInterB() ) |
---|
4029 | { |
---|
4030 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4031 | } |
---|
4032 | #if H_3D_NBDV |
---|
4033 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
---|
4034 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
---|
4035 | #endif |
---|
4036 | #if H_3D_VSP |
---|
4037 | if (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1) |
---|
4038 | { |
---|
4039 | vspFlag[iCount] = 1; |
---|
4040 | xInheritVSPDisInfo(pcCUAboveLeft,uiAboveLeftPartIdx,iCount,inheritedVSPDisInfo); |
---|
4041 | } |
---|
4042 | #endif |
---|
4043 | if ( mrgCandIdx == iCount ) |
---|
4044 | { |
---|
4045 | return; |
---|
4046 | } |
---|
4047 | iCount ++; |
---|
4048 | } |
---|
4049 | } |
---|
4050 | // early termination |
---|
4051 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4052 | { |
---|
4053 | return; |
---|
4054 | } |
---|
4055 | #if H_3D_IV_MERGE |
---|
4056 | //////////////////////////////////////////////////// |
---|
4057 | //////// SHIFTED IV (IvMCShift + IvDCShift) //////// |
---|
4058 | //////////////////////////////////////////////////// |
---|
4059 | |
---|
4060 | if( ivMvPredFlag ) |
---|
4061 | { |
---|
4062 | if(xAddIvMRGCand( mrgCandIdx, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, ivCandDir, ivCandMv, ivCandRefIdx, posIvDC, vspFlag)) |
---|
4063 | { |
---|
4064 | return; |
---|
4065 | } |
---|
4066 | //early termination |
---|
4067 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4068 | { |
---|
4069 | return; |
---|
4070 | } |
---|
4071 | } |
---|
4072 | #endif |
---|
4073 | #if H_3D |
---|
4074 | ///////////////////////////////// |
---|
4075 | //////// Collocate (COL) //////// |
---|
4076 | ///////////////////////////////// |
---|
4077 | #endif |
---|
4078 | if ( getSlice()->getEnableTMVPFlag()) |
---|
4079 | { |
---|
4080 | //>> MTK colocated-RightBottom |
---|
4081 | UInt uiPartIdxRB; |
---|
4082 | |
---|
4083 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
4084 | |
---|
4085 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
4086 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
4087 | |
---|
4088 | TComMv cColMv; |
---|
4089 | Int iRefIdx; |
---|
4090 | Int uiLCUIdx = -1; |
---|
4091 | |
---|
4092 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
4093 | { |
---|
4094 | } |
---|
4095 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
4096 | { |
---|
4097 | } |
---|
4098 | else |
---|
4099 | { |
---|
4100 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
4101 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
4102 | { |
---|
4103 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
4104 | uiLCUIdx = getAddr(); |
---|
4105 | } |
---|
4106 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
4107 | { |
---|
4108 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
4109 | } |
---|
4110 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
4111 | { |
---|
4112 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
4113 | uiLCUIdx = getAddr() + 1; |
---|
4114 | } |
---|
4115 | else //is the right bottom corner of LCU |
---|
4116 | { |
---|
4117 | uiAbsPartAddr = 0; |
---|
4118 | } |
---|
4119 | } |
---|
4120 | |
---|
4121 | |
---|
4122 | iRefIdx = 0; |
---|
4123 | Bool bExistMV = false; |
---|
4124 | UInt uiPartIdxCenter; |
---|
4125 | UInt uiCurLCUIdx = getAddr(); |
---|
4126 | Int dir = 0; |
---|
4127 | UInt uiArrayAddr = iCount; |
---|
4128 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
4129 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
4130 | if( bExistMV == false ) |
---|
4131 | { |
---|
4132 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4133 | } |
---|
4134 | if( bExistMV ) |
---|
4135 | { |
---|
4136 | dir |= 1; |
---|
4137 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
4138 | } |
---|
4139 | |
---|
4140 | if ( getSlice()->isInterB() ) |
---|
4141 | { |
---|
4142 | #if H_3D_TMVP |
---|
4143 | iRefIdx = 0; |
---|
4144 | #endif |
---|
4145 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
4146 | if( bExistMV == false ) |
---|
4147 | { |
---|
4148 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4149 | } |
---|
4150 | if( bExistMV ) |
---|
4151 | { |
---|
4152 | dir |= 2; |
---|
4153 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
4154 | } |
---|
4155 | } |
---|
4156 | |
---|
4157 | if (dir != 0) |
---|
4158 | { |
---|
4159 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
4160 | abCandIsInter[uiArrayAddr] = true; |
---|
4161 | #if H_3D_NBDV |
---|
4162 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
---|
4163 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
---|
4164 | #endif |
---|
4165 | if ( mrgCandIdx == iCount ) |
---|
4166 | { |
---|
4167 | return; |
---|
4168 | } |
---|
4169 | iCount++; |
---|
4170 | } |
---|
4171 | } |
---|
4172 | // early termination |
---|
4173 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4174 | { |
---|
4175 | return; |
---|
4176 | } |
---|
4177 | UInt uiArrayAddr = iCount; |
---|
4178 | UInt uiCutoff = uiArrayAddr; |
---|
4179 | |
---|
4180 | if ( getSlice()->isInterB()) |
---|
4181 | { |
---|
4182 | #if H_3D_IV_MERGE |
---|
4183 | UInt uiPriorityList0[20] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4, 2, 4, 3, 4 }; |
---|
4184 | UInt uiPriorityList1[20] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2, 4, 0, 4, 1, 4, 2, 4, 3 }; |
---|
4185 | #else |
---|
4186 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
4187 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
4188 | #endif |
---|
4189 | |
---|
4190 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
4191 | { |
---|
4192 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
4193 | #if H_3D_VSP |
---|
4194 | Bool bValid = true; |
---|
4195 | if ( vspFlag[i] == 1 || vspFlag[j] == 1 ) |
---|
4196 | { |
---|
4197 | bValid = false; |
---|
4198 | } |
---|
4199 | if( !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) ) |
---|
4200 | { |
---|
4201 | assert(bValid == true); |
---|
4202 | } |
---|
4203 | #endif |
---|
4204 | #if H_3D_VSP |
---|
4205 | if (abCandIsInter[i] && abCandIsInter[j] && (puhInterDirNeighbours[i]&0x1) && (puhInterDirNeighbours[j]&0x2) && bValid) |
---|
4206 | #else |
---|
4207 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
4208 | #endif |
---|
4209 | { |
---|
4210 | abCandIsInter[uiArrayAddr] = true; |
---|
4211 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4212 | |
---|
4213 | // get Mv from cand[i] and cand[j] |
---|
4214 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
4215 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
4216 | |
---|
4217 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
4218 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
4219 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
4220 | { |
---|
4221 | abCandIsInter[uiArrayAddr] = false; |
---|
4222 | } |
---|
4223 | else |
---|
4224 | { |
---|
4225 | uiArrayAddr++; |
---|
4226 | } |
---|
4227 | } |
---|
4228 | } |
---|
4229 | } |
---|
4230 | // early termination |
---|
4231 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
4232 | { |
---|
4233 | return; |
---|
4234 | } |
---|
4235 | 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); |
---|
4236 | Int r = 0; |
---|
4237 | Int refcnt = 0; |
---|
4238 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
4239 | { |
---|
4240 | abCandIsInter[uiArrayAddr] = true; |
---|
4241 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
4242 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
4243 | |
---|
4244 | if ( getSlice()->isInterB() ) |
---|
4245 | { |
---|
4246 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4247 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
4248 | } |
---|
4249 | uiArrayAddr++; |
---|
4250 | if ( refcnt == iNumRefIdx - 1 ) |
---|
4251 | { |
---|
4252 | r = 0; |
---|
4253 | } |
---|
4254 | else |
---|
4255 | { |
---|
4256 | ++r; |
---|
4257 | ++refcnt; |
---|
4258 | } |
---|
4259 | } |
---|
4260 | |
---|
4261 | numValidMergeCand = uiArrayAddr; |
---|
4262 | } |
---|
4263 | #if H_3D_VSP |
---|
4264 | inline Void TComDataCU::xInheritVSPDisInfo(TComDataCU* pcCURef, UInt uiAbsPartIdx, Int iCount, InheritedVSPDisInfo* inheritedVSPDisInfo) |
---|
4265 | { |
---|
4266 | inheritedVSPDisInfo[iCount].m_acDvInfo.m_acNBDV = pcCURef->getDvInfo(uiAbsPartIdx).m_acNBDV; |
---|
4267 | inheritedVSPDisInfo[iCount].m_acDvInfo.m_aVIdxCan = pcCURef->getDvInfo(uiAbsPartIdx).m_aVIdxCan; |
---|
4268 | } |
---|
4269 | #endif |
---|
4270 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
---|
4271 | * \param xN, xN location of the upper-left corner pixel of a neighboring PU |
---|
4272 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
4273 | * \returns Bool |
---|
4274 | */ |
---|
4275 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) |
---|
4276 | { |
---|
4277 | |
---|
4278 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
---|
4279 | if ((xN>>plevel)!= (xP>>plevel)) |
---|
4280 | { |
---|
4281 | return true; |
---|
4282 | } |
---|
4283 | if ((yN>>plevel)!= (yP>>plevel)) |
---|
4284 | { |
---|
4285 | return true; |
---|
4286 | } |
---|
4287 | return false; |
---|
4288 | } |
---|
4289 | /** calculate the location of upper-left corner pixel and size of the current PU. |
---|
4290 | * \param partIdx PU index within a CU |
---|
4291 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
4292 | * \param PSW, nPSH size of the curren PU |
---|
4293 | * \returns Void |
---|
4294 | */ |
---|
4295 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) |
---|
4296 | { |
---|
4297 | UInt col = m_uiCUPelX; |
---|
4298 | UInt row = m_uiCUPelY; |
---|
4299 | |
---|
4300 | switch ( m_pePartSize[0] ) |
---|
4301 | { |
---|
4302 | case SIZE_2NxN: |
---|
4303 | nPSW = getWidth(0); |
---|
4304 | nPSH = getHeight(0) >> 1; |
---|
4305 | xP = col; |
---|
4306 | yP = (partIdx ==0)? row: row + nPSH; |
---|
4307 | break; |
---|
4308 | case SIZE_Nx2N: |
---|
4309 | nPSW = getWidth(0) >> 1; |
---|
4310 | nPSH = getHeight(0); |
---|
4311 | xP = (partIdx ==0)? col: col + nPSW; |
---|
4312 | yP = row; |
---|
4313 | break; |
---|
4314 | case SIZE_NxN: |
---|
4315 | nPSW = getWidth(0) >> 1; |
---|
4316 | nPSH = getHeight(0) >> 1; |
---|
4317 | xP = col + (partIdx&0x1)*nPSW; |
---|
4318 | yP = row + (partIdx>>1)*nPSH; |
---|
4319 | break; |
---|
4320 | case SIZE_2NxnU: |
---|
4321 | nPSW = getWidth(0); |
---|
4322 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
4323 | xP = col; |
---|
4324 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
4325 | |
---|
4326 | break; |
---|
4327 | case SIZE_2NxnD: |
---|
4328 | nPSW = getWidth(0); |
---|
4329 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
4330 | xP = col; |
---|
4331 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
4332 | break; |
---|
4333 | case SIZE_nLx2N: |
---|
4334 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
4335 | nPSH = getHeight(0); |
---|
4336 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
4337 | yP = row; |
---|
4338 | break; |
---|
4339 | case SIZE_nRx2N: |
---|
4340 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
4341 | nPSH = getHeight(0); |
---|
4342 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
4343 | yP = row; |
---|
4344 | break; |
---|
4345 | default: |
---|
4346 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
4347 | nPSW = getWidth(0); |
---|
4348 | nPSH = getHeight(0); |
---|
4349 | xP = col ; |
---|
4350 | yP = row ; |
---|
4351 | |
---|
4352 | break; |
---|
4353 | } |
---|
4354 | } |
---|
4355 | |
---|
4356 | /** Constructs a list of candidates for AMVP |
---|
4357 | * \param uiPartIdx |
---|
4358 | * \param uiPartAddr |
---|
4359 | * \param eRefPicList |
---|
4360 | * \param iRefIdx |
---|
4361 | * \param pInfo |
---|
4362 | */ |
---|
4363 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
---|
4364 | { |
---|
4365 | TComMv cMvPred; |
---|
4366 | Bool bAddedSmvp = false; |
---|
4367 | |
---|
4368 | pInfo->iN = 0; |
---|
4369 | if (iRefIdx < 0) |
---|
4370 | { |
---|
4371 | return; |
---|
4372 | } |
---|
4373 | |
---|
4374 | //-- Get Spatial MV |
---|
4375 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
4376 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
4377 | Bool bAdded = false; |
---|
4378 | |
---|
4379 | deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
4380 | deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB ); |
---|
4381 | |
---|
4382 | TComDataCU* tmpCU = NULL; |
---|
4383 | UInt idx; |
---|
4384 | tmpCU = getPUBelowLeft(idx, uiPartIdxLB); |
---|
4385 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
4386 | |
---|
4387 | if (!bAddedSmvp) |
---|
4388 | { |
---|
4389 | tmpCU = getPULeft(idx, uiPartIdxLB); |
---|
4390 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
4391 | } |
---|
4392 | |
---|
4393 | // Left predictor search |
---|
4394 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
4395 | if (!bAdded) |
---|
4396 | { |
---|
4397 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
4398 | } |
---|
4399 | |
---|
4400 | if(!bAdded) |
---|
4401 | { |
---|
4402 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
4403 | if (!bAdded) |
---|
4404 | { |
---|
4405 | xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
4406 | } |
---|
4407 | } |
---|
4408 | // Above predictor search |
---|
4409 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
4410 | |
---|
4411 | if (!bAdded) |
---|
4412 | { |
---|
4413 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
4414 | } |
---|
4415 | |
---|
4416 | if(!bAdded) |
---|
4417 | { |
---|
4418 | xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
4419 | } |
---|
4420 | bAdded = bAddedSmvp; |
---|
4421 | if (pInfo->iN==2) bAdded = true; |
---|
4422 | |
---|
4423 | if(!bAdded) |
---|
4424 | { |
---|
4425 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
4426 | if (!bAdded) |
---|
4427 | { |
---|
4428 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
4429 | } |
---|
4430 | |
---|
4431 | if(!bAdded) |
---|
4432 | { |
---|
4433 | xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
4434 | } |
---|
4435 | } |
---|
4436 | |
---|
4437 | if ( pInfo->iN == 2 ) |
---|
4438 | { |
---|
4439 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
---|
4440 | { |
---|
4441 | pInfo->iN = 1; |
---|
4442 | } |
---|
4443 | } |
---|
4444 | |
---|
4445 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
4446 | { |
---|
4447 | // Get Temporal Motion Predictor |
---|
4448 | Int iRefIdx_Col = iRefIdx; |
---|
4449 | TComMv cColMv; |
---|
4450 | UInt uiPartIdxRB; |
---|
4451 | UInt uiAbsPartIdx; |
---|
4452 | UInt uiAbsPartAddr; |
---|
4453 | |
---|
4454 | deriveRightBottomIdx( uiPartIdx, uiPartIdxRB ); |
---|
4455 | uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
---|
4456 | |
---|
4457 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
4458 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
---|
4459 | Int uiLCUIdx = -1; |
---|
4460 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
4461 | { |
---|
4462 | } |
---|
4463 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
4464 | { |
---|
4465 | } |
---|
4466 | else |
---|
4467 | { |
---|
4468 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
4469 | ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
4470 | { |
---|
4471 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; |
---|
4472 | uiLCUIdx = getAddr(); |
---|
4473 | } |
---|
4474 | else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
4475 | { |
---|
4476 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
4477 | } |
---|
4478 | else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
4479 | { |
---|
4480 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
---|
4481 | uiLCUIdx = getAddr() + 1; |
---|
4482 | } |
---|
4483 | else //is the right bottom corner of LCU |
---|
4484 | { |
---|
4485 | uiAbsPartAddr = 0; |
---|
4486 | } |
---|
4487 | } |
---|
4488 | if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col |
---|
4489 | #if H_3D_TMVP |
---|
4490 | , 0 |
---|
4491 | #endif |
---|
4492 | ) ) |
---|
4493 | { |
---|
4494 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
4495 | } |
---|
4496 | else |
---|
4497 | { |
---|
4498 | UInt uiPartIdxCenter; |
---|
4499 | UInt uiCurLCUIdx = getAddr(); |
---|
4500 | xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); |
---|
4501 | if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col |
---|
4502 | #if H_3D_TMVP |
---|
4503 | , 0 |
---|
4504 | #endif |
---|
4505 | )) |
---|
4506 | { |
---|
4507 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
4508 | } |
---|
4509 | } |
---|
4510 | //---- co-located RightBottom Temporal Predictor ---// |
---|
4511 | } |
---|
4512 | |
---|
4513 | if (pInfo->iN > AMVP_MAX_NUM_CANDS) |
---|
4514 | { |
---|
4515 | pInfo->iN = AMVP_MAX_NUM_CANDS; |
---|
4516 | } |
---|
4517 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
---|
4518 | { |
---|
4519 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
---|
4520 | pInfo->iN++; |
---|
4521 | } |
---|
4522 | return ; |
---|
4523 | } |
---|
4524 | |
---|
4525 | Bool TComDataCU::isBipredRestriction(UInt puIdx) |
---|
4526 | { |
---|
4527 | Int width = 0; |
---|
4528 | Int height = 0; |
---|
4529 | UInt partAddr; |
---|
4530 | |
---|
4531 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
---|
4532 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
---|
4533 | { |
---|
4534 | return true; |
---|
4535 | } |
---|
4536 | return false; |
---|
4537 | } |
---|
4538 | |
---|
4539 | Void TComDataCU::clipMv (TComMv& rcMv) |
---|
4540 | { |
---|
4541 | Int iMvShift = 2; |
---|
4542 | #if H_3D_IC |
---|
4543 | if( getSlice()->getIsDepth() ) |
---|
4544 | iMvShift = 0; |
---|
4545 | #endif |
---|
4546 | Int iOffset = 8; |
---|
4547 | Int iHorMax = ( m_pcSlice->getSPS()->getPicWidthInLumaSamples() + iOffset - m_uiCUPelX - 1 ) << iMvShift; |
---|
4548 | Int iHorMin = ( -(Int)g_uiMaxCUWidth - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
---|
4549 | |
---|
4550 | Int iVerMax = ( m_pcSlice->getSPS()->getPicHeightInLumaSamples() + iOffset - m_uiCUPelY - 1 ) << iMvShift; |
---|
4551 | Int iVerMin = ( -(Int)g_uiMaxCUHeight - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
---|
4552 | |
---|
4553 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
---|
4554 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
---|
4555 | } |
---|
4556 | |
---|
4557 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
---|
4558 | { |
---|
4559 | UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
4560 | |
---|
4561 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
4562 | UInt uiCnt = 0; |
---|
4563 | while( uiWidth ) |
---|
4564 | { |
---|
4565 | uiCnt++; |
---|
4566 | uiWidth>>=1; |
---|
4567 | } |
---|
4568 | uiCnt-=2; |
---|
4569 | return uiCnt > 6 ? 6 : uiCnt; |
---|
4570 | } |
---|
4571 | |
---|
4572 | Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts ) |
---|
4573 | { |
---|
4574 | ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
4575 | } |
---|
4576 | |
---|
4577 | /** Set a I_PCM flag for all sub-partitions of a partition. |
---|
4578 | * \param bIpcmFlag I_PCM flag |
---|
4579 | * \param uiAbsPartIdx patition index |
---|
4580 | * \param uiDepth CU depth |
---|
4581 | * \returns Void |
---|
4582 | */ |
---|
4583 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
---|
4584 | { |
---|
4585 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
4586 | |
---|
4587 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
---|
4588 | } |
---|
4589 | |
---|
4590 | /** Test whether the current block is skipped |
---|
4591 | * \param uiPartIdx Block index |
---|
4592 | * \returns Flag indicating whether the block is skipped |
---|
4593 | */ |
---|
4594 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
---|
4595 | { |
---|
4596 | return ( getSkipFlag( uiPartIdx ) ); |
---|
4597 | } |
---|
4598 | |
---|
4599 | // ==================================================================================================================== |
---|
4600 | // Protected member functions |
---|
4601 | // ==================================================================================================================== |
---|
4602 | |
---|
4603 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
4604 | { |
---|
4605 | TComDataCU* pcTmpCU = NULL; |
---|
4606 | UInt uiIdx; |
---|
4607 | switch( eDir ) |
---|
4608 | { |
---|
4609 | case MD_LEFT: |
---|
4610 | { |
---|
4611 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
4612 | break; |
---|
4613 | } |
---|
4614 | case MD_ABOVE: |
---|
4615 | { |
---|
4616 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx ); |
---|
4617 | break; |
---|
4618 | } |
---|
4619 | case MD_ABOVE_RIGHT: |
---|
4620 | { |
---|
4621 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
4622 | break; |
---|
4623 | } |
---|
4624 | case MD_BELOW_LEFT: |
---|
4625 | { |
---|
4626 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
4627 | break; |
---|
4628 | } |
---|
4629 | case MD_ABOVE_LEFT: |
---|
4630 | { |
---|
4631 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
4632 | break; |
---|
4633 | } |
---|
4634 | default: |
---|
4635 | { |
---|
4636 | break; |
---|
4637 | } |
---|
4638 | } |
---|
4639 | |
---|
4640 | if ( pcTmpCU == NULL ) |
---|
4641 | { |
---|
4642 | return false; |
---|
4643 | } |
---|
4644 | |
---|
4645 | if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )) |
---|
4646 | { |
---|
4647 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
4648 | |
---|
4649 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
4650 | return true; |
---|
4651 | } |
---|
4652 | |
---|
4653 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
4654 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
4655 | { |
---|
4656 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
4657 | } |
---|
4658 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
4659 | { |
---|
4660 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
4661 | } |
---|
4662 | |
---|
4663 | |
---|
4664 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
4665 | Int iNeibRefPOC; |
---|
4666 | |
---|
4667 | |
---|
4668 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
---|
4669 | { |
---|
4670 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
4671 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
---|
4672 | { |
---|
4673 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
4674 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
4675 | return true; |
---|
4676 | } |
---|
4677 | } |
---|
4678 | return false; |
---|
4679 | } |
---|
4680 | |
---|
4681 | /** |
---|
4682 | * \param pInfo |
---|
4683 | * \param eRefPicList |
---|
4684 | * \param iRefIdx |
---|
4685 | * \param uiPartUnitIdx |
---|
4686 | * \param eDir |
---|
4687 | * \returns Bool |
---|
4688 | */ |
---|
4689 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
4690 | { |
---|
4691 | TComDataCU* pcTmpCU = NULL; |
---|
4692 | UInt uiIdx; |
---|
4693 | switch( eDir ) |
---|
4694 | { |
---|
4695 | case MD_LEFT: |
---|
4696 | { |
---|
4697 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
4698 | break; |
---|
4699 | } |
---|
4700 | case MD_ABOVE: |
---|
4701 | { |
---|
4702 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
4703 | break; |
---|
4704 | } |
---|
4705 | case MD_ABOVE_RIGHT: |
---|
4706 | { |
---|
4707 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
4708 | break; |
---|
4709 | } |
---|
4710 | case MD_BELOW_LEFT: |
---|
4711 | { |
---|
4712 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
4713 | break; |
---|
4714 | } |
---|
4715 | case MD_ABOVE_LEFT: |
---|
4716 | { |
---|
4717 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
4718 | break; |
---|
4719 | } |
---|
4720 | default: |
---|
4721 | { |
---|
4722 | break; |
---|
4723 | } |
---|
4724 | } |
---|
4725 | |
---|
4726 | if ( pcTmpCU == NULL ) |
---|
4727 | { |
---|
4728 | return false; |
---|
4729 | } |
---|
4730 | |
---|
4731 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
4732 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
4733 | { |
---|
4734 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
4735 | } |
---|
4736 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
4737 | { |
---|
4738 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
4739 | } |
---|
4740 | |
---|
4741 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
4742 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
4743 | Int iNeibPOC = iCurrPOC; |
---|
4744 | Int iNeibRefPOC; |
---|
4745 | |
---|
4746 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
4747 | Bool bIsNeibRefLongTerm = false; |
---|
4748 | //--------------- V1 (END) ------------------// |
---|
4749 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
---|
4750 | { |
---|
4751 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
---|
4752 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
4753 | TComMv rcMv; |
---|
4754 | |
---|
4755 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
4756 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
4757 | { |
---|
4758 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
4759 | { |
---|
4760 | rcMv = cMvPred; |
---|
4761 | } |
---|
4762 | else |
---|
4763 | { |
---|
4764 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
4765 | if ( iScale == 4096 ) |
---|
4766 | { |
---|
4767 | rcMv = cMvPred; |
---|
4768 | } |
---|
4769 | else |
---|
4770 | { |
---|
4771 | rcMv = cMvPred.scaleMv( iScale ); |
---|
4772 | } |
---|
4773 | } |
---|
4774 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
4775 | return true; |
---|
4776 | } |
---|
4777 | } |
---|
4778 | //---------------------- V2(END) --------------------// |
---|
4779 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
---|
4780 | { |
---|
4781 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
4782 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
4783 | TComMv rcMv; |
---|
4784 | |
---|
4785 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
4786 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
4787 | { |
---|
4788 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
4789 | { |
---|
4790 | rcMv = cMvPred; |
---|
4791 | } |
---|
4792 | else |
---|
4793 | { |
---|
4794 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
4795 | if ( iScale == 4096 ) |
---|
4796 | { |
---|
4797 | rcMv = cMvPred; |
---|
4798 | } |
---|
4799 | else |
---|
4800 | { |
---|
4801 | rcMv = cMvPred.scaleMv( iScale ); |
---|
4802 | } |
---|
4803 | } |
---|
4804 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
4805 | return true; |
---|
4806 | } |
---|
4807 | } |
---|
4808 | //---------------------- V3(END) --------------------// |
---|
4809 | return false; |
---|
4810 | } |
---|
4811 | |
---|
4812 | /** |
---|
4813 | * \param eRefPicList |
---|
4814 | * \param uiCUAddr |
---|
4815 | * \param uiPartUnitIdx |
---|
4816 | * \param riRefIdx |
---|
4817 | * \returns Bool |
---|
4818 | */ |
---|
4819 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx |
---|
4820 | #if H_3D_TMVP |
---|
4821 | , Bool bMRG |
---|
4822 | #endif |
---|
4823 | ) |
---|
4824 | { |
---|
4825 | UInt uiAbsPartAddr = uiPartUnitIdx; |
---|
4826 | |
---|
4827 | RefPicList eColRefPicList; |
---|
4828 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
---|
4829 | TComMv cColMv; |
---|
4830 | |
---|
4831 | // use coldir. |
---|
4832 | #if H_MV5 |
---|
4833 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
4834 | #else |
---|
4835 | #if H_MV |
---|
4836 | TComPic *pColPic; |
---|
4837 | if (getSlice()->getAltCollocatedIndicationFlag() ) |
---|
4838 | { |
---|
4839 | pColPic = getSlice()->getPicFromRefPicSetInterLayer( getSlice()->getActiveMotionPredRefLayerId( getSlice()->getCollocatedRefLayerIdx() )); |
---|
4840 | } |
---|
4841 | else |
---|
4842 | { |
---|
4843 | pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
4844 | } |
---|
4845 | #else |
---|
4846 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
4847 | #endif |
---|
4848 | #endif |
---|
4849 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
4850 | if(pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE) |
---|
4851 | { |
---|
4852 | return false; |
---|
4853 | } |
---|
4854 | iCurrPOC = m_pcSlice->getPOC(); |
---|
4855 | iColPOC = pColCU->getSlice()->getPOC(); |
---|
4856 | |
---|
4857 | if (pColCU->isIntra(uiAbsPartAddr)) |
---|
4858 | { |
---|
4859 | return false; |
---|
4860 | } |
---|
4861 | eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
---|
4862 | |
---|
4863 | Int iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
4864 | |
---|
4865 | if (iColRefIdx < 0 ) |
---|
4866 | { |
---|
4867 | eColRefPicList = RefPicList(1 - eColRefPicList); |
---|
4868 | iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
4869 | |
---|
4870 | if (iColRefIdx < 0 ) |
---|
4871 | { |
---|
4872 | return false; |
---|
4873 | } |
---|
4874 | } |
---|
4875 | |
---|
4876 | // Scale the vector. |
---|
4877 | iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
---|
4878 | cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
4879 | |
---|
4880 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
4881 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
---|
4882 | Bool bIsColRefLongTerm = pColCU->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); |
---|
4883 | |
---|
4884 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
4885 | { |
---|
4886 | #if H_3D_TMVP |
---|
4887 | Int iAlterRefIdx = m_pcSlice->getAlterRefIdx(eRefPicList); |
---|
4888 | if(bMRG && iAlterRefIdx > 0) |
---|
4889 | { |
---|
4890 | riRefIdx = iAlterRefIdx; |
---|
4891 | bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
---|
4892 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
4893 | assert(bIsCurrRefLongTerm == bIsColRefLongTerm); |
---|
4894 | } |
---|
4895 | else |
---|
4896 | { |
---|
4897 | #endif |
---|
4898 | return false; |
---|
4899 | #if H_3D_TMVP |
---|
4900 | } |
---|
4901 | #endif |
---|
4902 | } |
---|
4903 | |
---|
4904 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
---|
4905 | { |
---|
4906 | #if H_3D_TMVP |
---|
4907 | Int iCurrViewId = m_pcSlice->getViewIndex (); |
---|
4908 | Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewIndex (); |
---|
4909 | Int iColViewId = pColCU->getSlice()->getViewIndex(); |
---|
4910 | Int iColRefViewId = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewIndex(); |
---|
4911 | iScale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId ); |
---|
4912 | if ( iScale != 4096 && m_pcSlice->getVPS()->getIvMvScalingFlag() ) |
---|
4913 | { |
---|
4914 | rcMv = cColMv.scaleMv( iScale ); |
---|
4915 | } |
---|
4916 | else |
---|
4917 | { |
---|
4918 | #endif |
---|
4919 | rcMv = cColMv; |
---|
4920 | #if H_3D_TMVP |
---|
4921 | } |
---|
4922 | #endif |
---|
4923 | } |
---|
4924 | else |
---|
4925 | { |
---|
4926 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
4927 | if ( iScale == 4096 ) |
---|
4928 | { |
---|
4929 | rcMv = cColMv; |
---|
4930 | } |
---|
4931 | else |
---|
4932 | { |
---|
4933 | rcMv = cColMv.scaleMv( iScale ); |
---|
4934 | } |
---|
4935 | } |
---|
4936 | return true; |
---|
4937 | } |
---|
4938 | |
---|
4939 | UInt TComDataCU::xGetMvdBits(TComMv cMvd) |
---|
4940 | { |
---|
4941 | return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) ); |
---|
4942 | } |
---|
4943 | |
---|
4944 | UInt TComDataCU::xGetComponentBits(Int iVal) |
---|
4945 | { |
---|
4946 | UInt uiLength = 1; |
---|
4947 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
4948 | |
---|
4949 | assert ( uiTemp ); |
---|
4950 | |
---|
4951 | while ( 1 != uiTemp ) |
---|
4952 | { |
---|
4953 | uiTemp >>= 1; |
---|
4954 | uiLength += 2; |
---|
4955 | } |
---|
4956 | |
---|
4957 | return uiLength; |
---|
4958 | } |
---|
4959 | |
---|
4960 | |
---|
4961 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
4962 | { |
---|
4963 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
4964 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
4965 | |
---|
4966 | if( iDiffPocD == iDiffPocB ) |
---|
4967 | { |
---|
4968 | return 4096; |
---|
4969 | } |
---|
4970 | else |
---|
4971 | { |
---|
4972 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
4973 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
4974 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
4975 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
---|
4976 | return iScale; |
---|
4977 | } |
---|
4978 | } |
---|
4979 | |
---|
4980 | /** |
---|
4981 | * \param eCUMode |
---|
4982 | * \param uiPartIdx |
---|
4983 | * \param ruiPartIdxCenter |
---|
4984 | * \returns Void |
---|
4985 | */ |
---|
4986 | Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
---|
4987 | { |
---|
4988 | UInt uiPartAddr; |
---|
4989 | Int iPartWidth; |
---|
4990 | Int iPartHeight; |
---|
4991 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
4992 | |
---|
4993 | ruiPartIdxCenter = m_uiAbsIdxInLCU+uiPartAddr; // partition origin. |
---|
4994 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
4995 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInWidth() |
---|
4996 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
---|
4997 | } |
---|
4998 | #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 |
---|
4999 | Void TComDataCU::compressMV(int scale) |
---|
5000 | #else |
---|
5001 | Void TComDataCU::compressMV() |
---|
5002 | #endif |
---|
5003 | { |
---|
5004 | #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 |
---|
5005 | Int scaleFactor = (4 / scale ) * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
5006 | #else |
---|
5007 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
5008 | #endif |
---|
5009 | if (scaleFactor > 0) |
---|
5010 | { |
---|
5011 | m_acCUMvField[0].compress(m_pePredMode, scaleFactor); |
---|
5012 | m_acCUMvField[1].compress(m_pePredMode, scaleFactor); |
---|
5013 | } |
---|
5014 | } |
---|
5015 | |
---|
5016 | UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) |
---|
5017 | { |
---|
5018 | UInt uiCTXIdx; |
---|
5019 | UInt uiScanIdx; |
---|
5020 | UInt uiDirMode; |
---|
5021 | |
---|
5022 | if ( !bIsIntra ) |
---|
5023 | { |
---|
5024 | uiScanIdx = SCAN_DIAG; |
---|
5025 | return uiScanIdx; |
---|
5026 | } |
---|
5027 | |
---|
5028 | switch(uiWidth) |
---|
5029 | { |
---|
5030 | case 2: uiCTXIdx = 6; break; |
---|
5031 | case 4: uiCTXIdx = 5; break; |
---|
5032 | case 8: uiCTXIdx = 4; break; |
---|
5033 | case 16: uiCTXIdx = 3; break; |
---|
5034 | case 32: uiCTXIdx = 2; break; |
---|
5035 | case 64: uiCTXIdx = 1; break; |
---|
5036 | default: uiCTXIdx = 0; break; |
---|
5037 | } |
---|
5038 | |
---|
5039 | if ( bIsLuma ) |
---|
5040 | { |
---|
5041 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
---|
5042 | #if H_3D_DIM |
---|
5043 | mapDepthModeToIntraDir( uiDirMode ); |
---|
5044 | #endif |
---|
5045 | uiScanIdx = SCAN_DIAG; |
---|
5046 | if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size |
---|
5047 | { |
---|
5048 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
---|
5049 | } |
---|
5050 | } |
---|
5051 | else |
---|
5052 | { |
---|
5053 | uiDirMode = getChromaIntraDir(uiAbsPartIdx); |
---|
5054 | if( uiDirMode == DM_CHROMA_IDX ) |
---|
5055 | { |
---|
5056 | // get number of partitions in current CU |
---|
5057 | UInt depth = getDepth(uiAbsPartIdx); |
---|
5058 | UInt numParts = getPic()->getNumPartInCU() >> (2 * depth); |
---|
5059 | |
---|
5060 | // get luma mode from upper-left corner of current CU |
---|
5061 | uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); |
---|
5062 | #if H_3D_DIM |
---|
5063 | mapDepthModeToIntraDir( uiDirMode ); |
---|
5064 | #endif |
---|
5065 | } |
---|
5066 | uiScanIdx = SCAN_DIAG; |
---|
5067 | if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size |
---|
5068 | { |
---|
5069 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
---|
5070 | } |
---|
5071 | } |
---|
5072 | |
---|
5073 | return uiScanIdx; |
---|
5074 | } |
---|
5075 | |
---|
5076 | UInt TComDataCU::getSCUAddr() |
---|
5077 | { |
---|
5078 | return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; |
---|
5079 | } |
---|
5080 | |
---|
5081 | /** Set neighboring blocks availabilities for non-deblocked filtering |
---|
5082 | * \param numLCUInPicWidth number of LCUs in picture width |
---|
5083 | * \param numLCUInPicHeight number of LCUs in picture height |
---|
5084 | * \param numSUInLCUWidth number of SUs in LCU width |
---|
5085 | * \param numSUInLCUHeight number of SUs in LCU height |
---|
5086 | * \param picWidth picture width |
---|
5087 | * \param picHeight picture height |
---|
5088 | * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled |
---|
5089 | * \param bTopTileBoundary true means that top boundary coincides tile boundary |
---|
5090 | * \param bDownTileBoundary true means that bottom boundary coincides tile boundary |
---|
5091 | * \param bLeftTileBoundary true means that left boundary coincides tile boundary |
---|
5092 | * \param bRightTileBoundary true means that right boundary coincides tile boundary |
---|
5093 | * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled |
---|
5094 | */ |
---|
5095 | Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt /*numLCUInPicHeight*/, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight |
---|
5096 | ,std::vector<Bool>& LFCrossSliceBoundary |
---|
5097 | ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary |
---|
5098 | ,Bool bIndependentTileBoundaryEnabled) |
---|
5099 | { |
---|
5100 | UInt numSUInLCU = numSUInLCUWidth*numSUInLCUHeight; |
---|
5101 | Int* pSliceIDMapLCU = m_piSliceSUMap; |
---|
5102 | Bool onlyOneSliceInPic = ((Int)LFCrossSliceBoundary.size() == 1); |
---|
5103 | UInt uiLPelX, uiTPelY; |
---|
5104 | UInt width, height; |
---|
5105 | Bool bPicRBoundary, bPicBBoundary, bPicTBoundary, bPicLBoundary; |
---|
5106 | Bool bLCURBoundary= false, bLCUBBoundary= false, bLCUTBoundary= false, bLCULBoundary= false; |
---|
5107 | Bool* pbAvailBorder; |
---|
5108 | Bool* pbAvail; |
---|
5109 | UInt rTLSU, rBRSU, widthSU, heightSU; |
---|
5110 | UInt zRefSU; |
---|
5111 | Int* pRefID; |
---|
5112 | Int* pRefMapLCU; |
---|
5113 | UInt rTRefSU= 0, rBRefSU= 0, rLRefSU= 0, rRRefSU= 0; |
---|
5114 | Int* pRRefMapLCU= NULL; |
---|
5115 | Int* pLRefMapLCU= NULL; |
---|
5116 | Int* pTRefMapLCU= NULL; |
---|
5117 | Int* pBRefMapLCU= NULL; |
---|
5118 | Int sliceID; |
---|
5119 | UInt numSGU = (UInt)m_vNDFBlock.size(); |
---|
5120 | |
---|
5121 | for(Int i=0; i< numSGU; i++) |
---|
5122 | { |
---|
5123 | NDBFBlockInfo& rSGU = m_vNDFBlock[i]; |
---|
5124 | |
---|
5125 | sliceID = rSGU.sliceID; |
---|
5126 | uiLPelX = rSGU.posX; |
---|
5127 | uiTPelY = rSGU.posY; |
---|
5128 | width = rSGU.width; |
---|
5129 | height = rSGU.height; |
---|
5130 | rTLSU = g_auiZscanToRaster[ rSGU.startSU ]; |
---|
5131 | rBRSU = g_auiZscanToRaster[ rSGU.endSU ]; |
---|
5132 | widthSU = rSGU.widthSU; |
---|
5133 | heightSU = rSGU.heightSU; |
---|
5134 | |
---|
5135 | pbAvailBorder = rSGU.isBorderAvailable; |
---|
5136 | |
---|
5137 | bPicTBoundary= (uiTPelY == 0 )?(true):(false); |
---|
5138 | bPicLBoundary= (uiLPelX == 0 )?(true):(false); |
---|
5139 | bPicRBoundary= (!(uiLPelX+ width < picWidth ) )?(true):(false); |
---|
5140 | bPicBBoundary= (!(uiTPelY + height < picHeight))?(true):(false); |
---|
5141 | |
---|
5142 | bLCULBoundary = (rTLSU % numSUInLCUWidth == 0)?(true):(false); |
---|
5143 | bLCURBoundary = ( (rTLSU+ widthSU) % numSUInLCUWidth == 0)?(true):(false); |
---|
5144 | bLCUTBoundary = ( (UInt)(rTLSU / numSUInLCUWidth)== 0)?(true):(false); |
---|
5145 | bLCUBBoundary = ( (UInt)(rBRSU / numSUInLCUWidth) == (numSUInLCUHeight-1) )?(true):(false); |
---|
5146 | |
---|
5147 | // SGU_L |
---|
5148 | pbAvail = &(pbAvailBorder[SGU_L]); |
---|
5149 | if(bPicLBoundary) |
---|
5150 | { |
---|
5151 | *pbAvail = false; |
---|
5152 | } |
---|
5153 | else if (onlyOneSliceInPic) |
---|
5154 | { |
---|
5155 | *pbAvail = true; |
---|
5156 | } |
---|
5157 | else |
---|
5158 | { |
---|
5159 | // bLCULBoundary = (rTLSU % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
5160 | if(bLCULBoundary) |
---|
5161 | { |
---|
5162 | rLRefSU = rTLSU + numSUInLCUWidth -1; |
---|
5163 | zRefSU = g_auiRasterToZscan[rLRefSU]; |
---|
5164 | pRefMapLCU = pLRefMapLCU= (pSliceIDMapLCU - numSUInLCU); |
---|
5165 | } |
---|
5166 | else |
---|
5167 | { |
---|
5168 | zRefSU = g_auiRasterToZscan[rTLSU - 1]; |
---|
5169 | pRefMapLCU = pSliceIDMapLCU; |
---|
5170 | } |
---|
5171 | pRefID = pRefMapLCU + zRefSU; |
---|
5172 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
5173 | } |
---|
5174 | |
---|
5175 | // SGU_R |
---|
5176 | pbAvail = &(pbAvailBorder[SGU_R]); |
---|
5177 | if(bPicRBoundary) |
---|
5178 | { |
---|
5179 | *pbAvail = false; |
---|
5180 | } |
---|
5181 | else if (onlyOneSliceInPic) |
---|
5182 | { |
---|
5183 | *pbAvail = true; |
---|
5184 | } |
---|
5185 | else |
---|
5186 | { |
---|
5187 | // bLCURBoundary = ( (rTLSU+ uiWidthSU) % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
5188 | if(bLCURBoundary) |
---|
5189 | { |
---|
5190 | rRRefSU = rTLSU + widthSU - numSUInLCUWidth; |
---|
5191 | zRefSU = g_auiRasterToZscan[rRRefSU]; |
---|
5192 | pRefMapLCU = pRRefMapLCU= (pSliceIDMapLCU + numSUInLCU); |
---|
5193 | } |
---|
5194 | else |
---|
5195 | { |
---|
5196 | zRefSU = g_auiRasterToZscan[rTLSU + widthSU]; |
---|
5197 | pRefMapLCU = pSliceIDMapLCU; |
---|
5198 | } |
---|
5199 | pRefID = pRefMapLCU + zRefSU; |
---|
5200 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
5201 | } |
---|
5202 | |
---|
5203 | // SGU_T |
---|
5204 | pbAvail = &(pbAvailBorder[SGU_T]); |
---|
5205 | if(bPicTBoundary) |
---|
5206 | { |
---|
5207 | *pbAvail = false; |
---|
5208 | } |
---|
5209 | else if (onlyOneSliceInPic) |
---|
5210 | { |
---|
5211 | *pbAvail = true; |
---|
5212 | } |
---|
5213 | else |
---|
5214 | { |
---|
5215 | // bLCUTBoundary = ( (UInt)(rTLSU / uiNumSUInLCUWidth)== 0)?(true):(false); |
---|
5216 | if(bLCUTBoundary) |
---|
5217 | { |
---|
5218 | rTRefSU = numSUInLCU - (numSUInLCUWidth - rTLSU); |
---|
5219 | zRefSU = g_auiRasterToZscan[rTRefSU]; |
---|
5220 | pRefMapLCU = pTRefMapLCU= (pSliceIDMapLCU - (numLCUInPicWidth*numSUInLCU)); |
---|
5221 | } |
---|
5222 | else |
---|
5223 | { |
---|
5224 | zRefSU = g_auiRasterToZscan[rTLSU - numSUInLCUWidth]; |
---|
5225 | pRefMapLCU = pSliceIDMapLCU; |
---|
5226 | } |
---|
5227 | pRefID = pRefMapLCU + zRefSU; |
---|
5228 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
5229 | } |
---|
5230 | |
---|
5231 | // SGU_B |
---|
5232 | pbAvail = &(pbAvailBorder[SGU_B]); |
---|
5233 | if(bPicBBoundary) |
---|
5234 | { |
---|
5235 | *pbAvail = false; |
---|
5236 | } |
---|
5237 | else if (onlyOneSliceInPic) |
---|
5238 | { |
---|
5239 | *pbAvail = true; |
---|
5240 | } |
---|
5241 | else |
---|
5242 | { |
---|
5243 | // bLCUBBoundary = ( (UInt)(rBRSU / uiNumSUInLCUWidth) == (uiNumSUInLCUHeight-1) )?(true):(false); |
---|
5244 | if(bLCUBBoundary) |
---|
5245 | { |
---|
5246 | rBRefSU = rTLSU % numSUInLCUWidth; |
---|
5247 | zRefSU = g_auiRasterToZscan[rBRefSU]; |
---|
5248 | pRefMapLCU = pBRefMapLCU= (pSliceIDMapLCU + (numLCUInPicWidth*numSUInLCU)); |
---|
5249 | } |
---|
5250 | else |
---|
5251 | { |
---|
5252 | zRefSU = g_auiRasterToZscan[rTLSU + (heightSU*numSUInLCUWidth)]; |
---|
5253 | pRefMapLCU = pSliceIDMapLCU; |
---|
5254 | } |
---|
5255 | pRefID = pRefMapLCU + zRefSU; |
---|
5256 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
5257 | } |
---|
5258 | |
---|
5259 | // SGU_TL |
---|
5260 | pbAvail = &(pbAvailBorder[SGU_TL]); |
---|
5261 | if(bPicTBoundary || bPicLBoundary) |
---|
5262 | { |
---|
5263 | *pbAvail = false; |
---|
5264 | } |
---|
5265 | else if (onlyOneSliceInPic) |
---|
5266 | { |
---|
5267 | *pbAvail = true; |
---|
5268 | } |
---|
5269 | else |
---|
5270 | { |
---|
5271 | if(bLCUTBoundary && bLCULBoundary) |
---|
5272 | { |
---|
5273 | zRefSU = numSUInLCU -1; |
---|
5274 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
5275 | } |
---|
5276 | else if(bLCUTBoundary) |
---|
5277 | { |
---|
5278 | zRefSU = g_auiRasterToZscan[ rTRefSU- 1]; |
---|
5279 | pRefMapLCU = pTRefMapLCU; |
---|
5280 | } |
---|
5281 | else if(bLCULBoundary) |
---|
5282 | { |
---|
5283 | zRefSU = g_auiRasterToZscan[ rLRefSU- numSUInLCUWidth ]; |
---|
5284 | pRefMapLCU = pLRefMapLCU; |
---|
5285 | } |
---|
5286 | else //inside LCU |
---|
5287 | { |
---|
5288 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth -1]; |
---|
5289 | pRefMapLCU = pSliceIDMapLCU; |
---|
5290 | } |
---|
5291 | pRefID = pRefMapLCU + zRefSU; |
---|
5292 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
5293 | } |
---|
5294 | |
---|
5295 | // SGU_TR |
---|
5296 | pbAvail = &(pbAvailBorder[SGU_TR]); |
---|
5297 | if(bPicTBoundary || bPicRBoundary) |
---|
5298 | { |
---|
5299 | *pbAvail = false; |
---|
5300 | } |
---|
5301 | else if (onlyOneSliceInPic) |
---|
5302 | { |
---|
5303 | *pbAvail = true; |
---|
5304 | } |
---|
5305 | else |
---|
5306 | { |
---|
5307 | if(bLCUTBoundary && bLCURBoundary) |
---|
5308 | { |
---|
5309 | zRefSU = g_auiRasterToZscan[numSUInLCU - numSUInLCUWidth]; |
---|
5310 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
5311 | } |
---|
5312 | else if(bLCUTBoundary) |
---|
5313 | { |
---|
5314 | zRefSU = g_auiRasterToZscan[ rTRefSU+ widthSU]; |
---|
5315 | pRefMapLCU = pTRefMapLCU; |
---|
5316 | } |
---|
5317 | else if(bLCURBoundary) |
---|
5318 | { |
---|
5319 | zRefSU = g_auiRasterToZscan[ rRRefSU- numSUInLCUWidth ]; |
---|
5320 | pRefMapLCU = pRRefMapLCU; |
---|
5321 | } |
---|
5322 | else //inside LCU |
---|
5323 | { |
---|
5324 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth +widthSU]; |
---|
5325 | pRefMapLCU = pSliceIDMapLCU; |
---|
5326 | } |
---|
5327 | pRefID = pRefMapLCU + zRefSU; |
---|
5328 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
5329 | } |
---|
5330 | |
---|
5331 | // SGU_BL |
---|
5332 | pbAvail = &(pbAvailBorder[SGU_BL]); |
---|
5333 | if(bPicBBoundary || bPicLBoundary) |
---|
5334 | { |
---|
5335 | *pbAvail = false; |
---|
5336 | } |
---|
5337 | else if (onlyOneSliceInPic) |
---|
5338 | { |
---|
5339 | *pbAvail = true; |
---|
5340 | } |
---|
5341 | else |
---|
5342 | { |
---|
5343 | if(bLCUBBoundary && bLCULBoundary) |
---|
5344 | { |
---|
5345 | zRefSU = g_auiRasterToZscan[numSUInLCUWidth - 1]; |
---|
5346 | pRefMapLCU = pSliceIDMapLCU + ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
5347 | } |
---|
5348 | else if(bLCUBBoundary) |
---|
5349 | { |
---|
5350 | zRefSU = g_auiRasterToZscan[ rBRefSU - 1]; |
---|
5351 | pRefMapLCU = pBRefMapLCU; |
---|
5352 | } |
---|
5353 | else if(bLCULBoundary) |
---|
5354 | { |
---|
5355 | zRefSU = g_auiRasterToZscan[ rLRefSU+ heightSU*numSUInLCUWidth ]; |
---|
5356 | pRefMapLCU = pLRefMapLCU; |
---|
5357 | } |
---|
5358 | else //inside LCU |
---|
5359 | { |
---|
5360 | zRefSU = g_auiRasterToZscan[ rTLSU + heightSU*numSUInLCUWidth -1]; |
---|
5361 | pRefMapLCU = pSliceIDMapLCU; |
---|
5362 | } |
---|
5363 | pRefID = pRefMapLCU + zRefSU; |
---|
5364 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
5365 | } |
---|
5366 | |
---|
5367 | // SGU_BR |
---|
5368 | pbAvail = &(pbAvailBorder[SGU_BR]); |
---|
5369 | if(bPicBBoundary || bPicRBoundary) |
---|
5370 | { |
---|
5371 | *pbAvail = false; |
---|
5372 | } |
---|
5373 | else if (onlyOneSliceInPic) |
---|
5374 | { |
---|
5375 | *pbAvail = true; |
---|
5376 | } |
---|
5377 | else |
---|
5378 | { |
---|
5379 | if(bLCUBBoundary && bLCURBoundary) |
---|
5380 | { |
---|
5381 | zRefSU = 0; |
---|
5382 | pRefMapLCU = pSliceIDMapLCU+ ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
5383 | } |
---|
5384 | else if(bLCUBBoundary) |
---|
5385 | { |
---|
5386 | zRefSU = g_auiRasterToZscan[ rBRefSU + widthSU]; |
---|
5387 | pRefMapLCU = pBRefMapLCU; |
---|
5388 | } |
---|
5389 | else if(bLCURBoundary) |
---|
5390 | { |
---|
5391 | zRefSU = g_auiRasterToZscan[ rRRefSU + (heightSU*numSUInLCUWidth)]; |
---|
5392 | pRefMapLCU = pRRefMapLCU; |
---|
5393 | } |
---|
5394 | else //inside LCU |
---|
5395 | { |
---|
5396 | zRefSU = g_auiRasterToZscan[ rTLSU + (heightSU*numSUInLCUWidth)+ widthSU]; |
---|
5397 | pRefMapLCU = pSliceIDMapLCU; |
---|
5398 | } |
---|
5399 | pRefID = pRefMapLCU + zRefSU; |
---|
5400 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
5401 | } |
---|
5402 | |
---|
5403 | if(bIndependentTileBoundaryEnabled) |
---|
5404 | { |
---|
5405 | //left LCU boundary |
---|
5406 | if(!bPicLBoundary && bLCULBoundary) |
---|
5407 | { |
---|
5408 | if(bLeftTileBoundary) |
---|
5409 | { |
---|
5410 | pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false; |
---|
5411 | } |
---|
5412 | } |
---|
5413 | //right LCU boundary |
---|
5414 | if(!bPicRBoundary && bLCURBoundary) |
---|
5415 | { |
---|
5416 | if(bRightTileBoundary) |
---|
5417 | { |
---|
5418 | pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false; |
---|
5419 | } |
---|
5420 | } |
---|
5421 | //top LCU boundary |
---|
5422 | if(!bPicTBoundary && bLCUTBoundary) |
---|
5423 | { |
---|
5424 | if(bTopTileBoundary) |
---|
5425 | { |
---|
5426 | pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false; |
---|
5427 | } |
---|
5428 | } |
---|
5429 | //down LCU boundary |
---|
5430 | if(!bPicBBoundary && bLCUBBoundary) |
---|
5431 | { |
---|
5432 | if(bDownTileBoundary) |
---|
5433 | { |
---|
5434 | pbAvailBorder[SGU_B] = pbAvailBorder[SGU_BL] = pbAvailBorder[SGU_BR] = false; |
---|
5435 | } |
---|
5436 | } |
---|
5437 | } |
---|
5438 | rSGU.allBordersAvailable = true; |
---|
5439 | for(Int b=0; b< NUM_SGU_BORDER; b++) |
---|
5440 | { |
---|
5441 | if(pbAvailBorder[b] == false) |
---|
5442 | { |
---|
5443 | rSGU.allBordersAvailable = false; |
---|
5444 | break; |
---|
5445 | } |
---|
5446 | } |
---|
5447 | } |
---|
5448 | } |
---|
5449 | |
---|
5450 | #if H_3D |
---|
5451 | Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) |
---|
5452 | { |
---|
5453 | riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX(); |
---|
5454 | riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY(); |
---|
5455 | } |
---|
5456 | #endif |
---|
5457 | #if H_3D_NBDV |
---|
5458 | //Notes from QC: |
---|
5459 | //TBD#1: DoNBDV related contributions are just partially integrated under the marco of H_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done |
---|
5460 | //TBD#2: set of DvMCP values need to be done as part of inter-view motion prediction process. Remove this comment once merge related integration is done |
---|
5461 | //To be checked: Parallel Merge features for NBDV, related to DV_DERIVATION_PARALLEL_B0096 and LGE_IVMP_PARALLEL_MERGE_B0136 are not integrated. The need of these features due to the adoption of CU-based NBDV is not clear. We need confirmation on this, especially by proponents |
---|
5462 | Bool TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo |
---|
5463 | #if H_3D_NBDV_REF |
---|
5464 | , Bool bDepthRefine |
---|
5465 | #endif |
---|
5466 | ) |
---|
5467 | { |
---|
5468 | //// ******* Init variables ******* ///// |
---|
5469 | // Init disparity struct for results |
---|
5470 | pDInfo->bDV = false; |
---|
5471 | // Init struct for disparities from MCP neighboring blocks |
---|
5472 | IDVInfo cIDVInfo; |
---|
5473 | cIDVInfo.m_bFound = false; |
---|
5474 | UInt uiPartIdx = 0; |
---|
5475 | UInt uiPartAddr = 0; |
---|
5476 | for (UInt iCurDvMcpCand = 0; iCurDvMcpCand < IDV_CANDS; iCurDvMcpCand++) |
---|
5477 | { |
---|
5478 | for (UInt iList = 0; iList < 2; iList++) |
---|
5479 | { |
---|
5480 | cIDVInfo.m_acMvCand[iList][iCurDvMcpCand].setZero(); |
---|
5481 | cIDVInfo.m_aVIdxCan[iList][iCurDvMcpCand] = 0; |
---|
5482 | cIDVInfo.m_bAvailab[iList][iCurDvMcpCand] = false; |
---|
5483 | } |
---|
5484 | } |
---|
5485 | #if H_3D_NBDV_REF |
---|
5486 | if( !m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ) ) |
---|
5487 | { |
---|
5488 | bDepthRefine = false; |
---|
5489 | } |
---|
5490 | #endif |
---|
5491 | // Get Positions |
---|
5492 | PartSize eCUMode = getPartitionSize( uiPartAddr ); |
---|
5493 | assert(eCUMode == SIZE_2Nx2N); |
---|
5494 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
5495 | |
---|
5496 | deriveLeftRightTopIdxGeneral(uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
5497 | deriveLeftBottomIdxGeneral (uiPartAddr, uiPartIdx, uiPartIdxLB ); |
---|
5498 | |
---|
5499 | //// ******* Get disparity from temporal neighboring blocks ******* ///// |
---|
5500 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
5501 | { |
---|
5502 | TComMv cColMv; |
---|
5503 | Int iTargetViewIdx = 0; |
---|
5504 | Int iTStartViewIdx = 0; |
---|
5505 | |
---|
5506 | ///*** Derive center position *** |
---|
5507 | UInt uiPartIdxCenter; |
---|
5508 | Int uiLCUIdx = getAddr(); |
---|
5509 | xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter ); |
---|
5510 | |
---|
5511 | ///*** Derive bottom right neighbour position *** |
---|
5512 | #if !SEC_SIMPLIFIED_NBDV_E0142 |
---|
5513 | Int iLCUIdxRBNb = -1; |
---|
5514 | Int iPartIdxRBNb = -1; |
---|
5515 | xDeriveRightBottomNbIdx(iLCUIdxRBNb, iPartIdxRBNb ); |
---|
5516 | #endif |
---|
5517 | |
---|
5518 | ///*** Search temporal candidate pictures for disparity vector *** |
---|
5519 | const Int iNumCandPics = getPic()->getNumDdvCandPics(); |
---|
5520 | for(Int curCandPic = 0; curCandPic < iNumCandPics; curCandPic++) |
---|
5521 | { |
---|
5522 | RefPicList eCurRefPicList = REF_PIC_LIST_0 ; |
---|
5523 | Int curCandPicRefIdx = 0; |
---|
5524 | if( curCandPic == 0 ) |
---|
5525 | { |
---|
5526 | eCurRefPicList = RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0); |
---|
5527 | curCandPicRefIdx = getSlice()->getColRefIdx(); |
---|
5528 | } |
---|
5529 | else |
---|
5530 | { |
---|
5531 | eCurRefPicList = getPic()->getRapRefList(); |
---|
5532 | curCandPicRefIdx = getPic()->getRapRefIdx(); |
---|
5533 | } |
---|
5534 | |
---|
5535 | #if !SEC_SIMPLIFIED_NBDV_E0142 |
---|
5536 | // Check BR and Center |
---|
5537 | for(Int curPosition = 0; curPosition < 2; curPosition++) |
---|
5538 | { |
---|
5539 | #endif |
---|
5540 | Bool bCheck = false; |
---|
5541 | #if !SEC_SIMPLIFIED_NBDV_E0142 |
---|
5542 | if ( curPosition == 0 && iLCUIdxRBNb >= 0 ) |
---|
5543 | #if MTK_NBDV_TN_FIX_E0172 |
---|
5544 | bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, iLCUIdxRBNb, iPartIdxRBNb, cColMv, iTargetViewIdx, iTStartViewIdx); |
---|
5545 | #else |
---|
5546 | bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, iLCUIdxRBNb, iPartIdxRBNb, cColMv, iTargetViewIdx, iTStartViewIdx); |
---|
5547 | #endif |
---|
5548 | |
---|
5549 | if (curPosition == 1 ) |
---|
5550 | #endif |
---|
5551 | #if MTK_NBDV_TN_FIX_E0172 |
---|
5552 | bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, uiLCUIdx, uiPartIdxCenter, cColMv, iTargetViewIdx, iTStartViewIdx ); |
---|
5553 | #else |
---|
5554 | bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, uiLCUIdx, uiPartIdxCenter, cColMv, iTargetViewIdx, iTStartViewIdx ); |
---|
5555 | #endif |
---|
5556 | |
---|
5557 | if( bCheck ) |
---|
5558 | { |
---|
5559 | clipMv(cColMv); |
---|
5560 | pDInfo->m_acNBDV = cColMv; |
---|
5561 | pDInfo->m_aVIdxCan = iTargetViewIdx; |
---|
5562 | |
---|
5563 | #if H_3D_NBDV_REF |
---|
5564 | TComPic* picDepth = NULL; |
---|
5565 | picDepth = getSlice()->getIvPic( true, iTargetViewIdx ); |
---|
5566 | assert(picDepth != NULL); |
---|
5567 | if (picDepth && bDepthRefine) |
---|
5568 | estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv ); |
---|
5569 | |
---|
5570 | pDInfo->m_acDoNBDV = cColMv; |
---|
5571 | #endif //H_3D_NBDV_REF |
---|
5572 | return true; |
---|
5573 | } |
---|
5574 | #if !SEC_SIMPLIFIED_NBDV_E0142 |
---|
5575 | } |
---|
5576 | #endif |
---|
5577 | } |
---|
5578 | } |
---|
5579 | |
---|
5580 | UInt uiIdx = 0; |
---|
5581 | Bool bCheckMcpDv = false; |
---|
5582 | TComDataCU* pcTmpCU = NULL; |
---|
5583 | |
---|
5584 | //// ******* Get disparity from left block ******* ///// |
---|
5585 | pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false); |
---|
5586 | bCheckMcpDv = true; |
---|
5587 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT |
---|
5588 | #if H_3D_NBDV_REF |
---|
5589 | , bDepthRefine |
---|
5590 | #endif |
---|
5591 | ) ) |
---|
5592 | return true; |
---|
5593 | |
---|
5594 | //// ******* Get disparity from above block ******* ///// |
---|
5595 | pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true); |
---|
5596 | if(pcTmpCU != NULL ) |
---|
5597 | { |
---|
5598 | bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0); |
---|
5599 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE |
---|
5600 | #if H_3D_NBDV_REF |
---|
5601 | , bDepthRefine |
---|
5602 | #endif |
---|
5603 | ) ) |
---|
5604 | return true; |
---|
5605 | } |
---|
5606 | |
---|
5607 | #if !SEC_SIMPLIFIED_NBDV_E0142 |
---|
5608 | //// ******* Get disparity from above right block ******* ///// |
---|
5609 | pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true); |
---|
5610 | if(pcTmpCU != NULL ) |
---|
5611 | { |
---|
5612 | bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0); |
---|
5613 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVERIGHT |
---|
5614 | #if H_3D_NBDV_REF |
---|
5615 | , bDepthRefine |
---|
5616 | #endif |
---|
5617 | ) ) |
---|
5618 | return true; |
---|
5619 | } |
---|
5620 | |
---|
5621 | //// ******* Get disparity from below left block ******* ///// |
---|
5622 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true); |
---|
5623 | if( pcTmpCU != NULL ) |
---|
5624 | { |
---|
5625 | bCheckMcpDv = true; |
---|
5626 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFTBELOW |
---|
5627 | #if H_3D_NBDV_REF |
---|
5628 | , bDepthRefine |
---|
5629 | #endif |
---|
5630 | ) ) |
---|
5631 | return true; |
---|
5632 | } |
---|
5633 | |
---|
5634 | //// ******* Get disparity from above left block ******* ///// |
---|
5635 | pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true); |
---|
5636 | assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr)); |
---|
5637 | |
---|
5638 | if( pcTmpCU != NULL ) |
---|
5639 | { |
---|
5640 | bCheckMcpDv = (( getAddr() - pcTmpCU->getAddr() ) <= 1); |
---|
5641 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVELEFT |
---|
5642 | #if H_3D_NBDV_REF |
---|
5643 | , bDepthRefine |
---|
5644 | #endif |
---|
5645 | ) ) |
---|
5646 | return true; |
---|
5647 | } |
---|
5648 | #endif |
---|
5649 | |
---|
5650 | //// ******* Search MCP blocks ******* ///// |
---|
5651 | if( cIDVInfo.m_bFound ) |
---|
5652 | { |
---|
5653 | for( Int curPos = 0 ; curPos < IDV_CANDS ; curPos++ ) |
---|
5654 | { |
---|
5655 | for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) |
---|
5656 | { |
---|
5657 | if( cIDVInfo.m_bAvailab[iList][curPos] ) |
---|
5658 | { |
---|
5659 | TComMv cDispVec = cIDVInfo.m_acMvCand[iList][ curPos ]; |
---|
5660 | clipMv( cDispVec ); |
---|
5661 | pDInfo->m_acNBDV = cDispVec; |
---|
5662 | pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ]; |
---|
5663 | #if H_3D_NBDV_REF |
---|
5664 | TComPic* picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan ); |
---|
5665 | assert(picDepth!=NULL); |
---|
5666 | |
---|
5667 | if (picDepth && bDepthRefine) |
---|
5668 | { |
---|
5669 | estimateDVFromDM (pDInfo->m_aVIdxCan, uiPartIdx, picDepth, uiPartAddr, &cDispVec); |
---|
5670 | } |
---|
5671 | pDInfo->m_acDoNBDV = cDispVec; |
---|
5672 | #endif |
---|
5673 | return true; |
---|
5674 | } |
---|
5675 | } |
---|
5676 | } |
---|
5677 | } |
---|
5678 | |
---|
5679 | TComMv defaultDV(0, 0); |
---|
5680 | pDInfo->m_acNBDV = defaultDV; |
---|
5681 | #if NBDV_DEFAULT_VIEWIDX_BUGFIX |
---|
5682 | Int valid = 0; |
---|
5683 | Int viewIndex = 0; |
---|
5684 | for( UInt uiBId = 0; uiBId < getSlice()->getViewIndex() && valid==0; uiBId++ ) |
---|
5685 | { |
---|
5686 | UInt uiBaseId = uiBId; |
---|
5687 | TComPic* pcBasePic = getSlice()->getIvPic( false, uiBaseId ); |
---|
5688 | for( Int iRefListId = 0; ( iRefListId < (getSlice()->isInterB()? 2:1) ) && !getSlice()->isIntra() && valid==0; iRefListId++ ) |
---|
5689 | { |
---|
5690 | RefPicList eRefPicListTest = RefPicList( iRefListId ); |
---|
5691 | Int iNumRefPics = getSlice()->getNumRefIdx( eRefPicListTest ) ; |
---|
5692 | for( Int iRefIndex = 0; iRefIndex < iNumRefPics; iRefIndex++ ) |
---|
5693 | { |
---|
5694 | if(pcBasePic->getPOC() == getSlice()->getRefPic( eRefPicListTest, iRefIndex )->getPOC() |
---|
5695 | && pcBasePic->getViewIndex() == getSlice()->getRefPic( eRefPicListTest, iRefIndex )->getViewIndex()) |
---|
5696 | { |
---|
5697 | valid=1; |
---|
5698 | viewIndex = uiBaseId; |
---|
5699 | break; |
---|
5700 | } |
---|
5701 | } |
---|
5702 | } |
---|
5703 | } |
---|
5704 | if(valid) |
---|
5705 | { |
---|
5706 | pDInfo->m_aVIdxCan = viewIndex; |
---|
5707 | #if H_3D_NBDV_REF |
---|
5708 | TComPic* picDepth = NULL; |
---|
5709 | picDepth = getSlice()->getIvPic( true, viewIndex ); |
---|
5710 | assert(picDepth!=NULL); |
---|
5711 | |
---|
5712 | if (picDepth && bDepthRefine) |
---|
5713 | { |
---|
5714 | estimateDVFromDM(viewIndex, uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view |
---|
5715 | } |
---|
5716 | pDInfo->m_acDoNBDV = defaultDV; |
---|
5717 | #endif |
---|
5718 | } |
---|
5719 | #else |
---|
5720 | pDInfo->m_aVIdxCan = 0; |
---|
5721 | #if H_3D_NBDV_REF |
---|
5722 | TComPic* picDepth = NULL; |
---|
5723 | picDepth = getSlice()->getIvPic( true, 0 ); |
---|
5724 | assert(picDepth!=NULL); |
---|
5725 | |
---|
5726 | if (picDepth && bDepthRefine) |
---|
5727 | { |
---|
5728 | estimateDVFromDM(0, uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view |
---|
5729 | } |
---|
5730 | pDInfo->m_acDoNBDV = defaultDV; |
---|
5731 | #endif |
---|
5732 | #endif |
---|
5733 | return false; |
---|
5734 | } |
---|
5735 | |
---|
5736 | #if H_3D_NBDV_REF |
---|
5737 | Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT ) |
---|
5738 | { |
---|
5739 | Int iPictureWidth = pcBaseViewDepthPicYuv->getWidth(); |
---|
5740 | Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(); |
---|
5741 | |
---|
5742 | #if NTT_DoNBDV_VECTOR_CLIP_E0141 |
---|
5743 | Int depthStartPosX = Clip3(0, iPictureWidth - 1, iBlkX + ((mv->getHor()+2)>>2)); |
---|
5744 | Int depthStartPosY = Clip3(0, iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2)); |
---|
5745 | Int depthEndPosX = Clip3(0, iPictureWidth - 1, iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2)); |
---|
5746 | Int depthEndPosY = Clip3(0, iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2)); |
---|
5747 | #else |
---|
5748 | Int depthStartPosX = Clip3(0, iPictureWidth - iBlkWidth, iBlkX + ((mv->getHor()+2)>>2)); |
---|
5749 | Int depthStartPosY = Clip3(0, iPictureHeight- iBlkHeight, iBlkY + ((mv->getVer()+2)>>2)); |
---|
5750 | Int depthEndPosX = Clip3(0, iPictureWidth - 1, iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2)); |
---|
5751 | Int depthEndPosY = Clip3(0, iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2)); |
---|
5752 | #endif |
---|
5753 | |
---|
5754 | Pel* depthTL = pcBaseViewDepthPicYuv->getLumaAddr(); |
---|
5755 | Int depStride = pcBaseViewDepthPicYuv->getStride(); |
---|
5756 | |
---|
5757 | Pel maxDepthVal = 0; |
---|
5758 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthStartPosX ]); // Left Top |
---|
5759 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthStartPosX ]); // Left Bottom |
---|
5760 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthEndPosX ]); // Right Top |
---|
5761 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthEndPosX ]); // Right Bottom |
---|
5762 | |
---|
5763 | return aiShiftLUT[ maxDepthVal ]; |
---|
5764 | } |
---|
5765 | |
---|
5766 | Void TComDataCU::estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred ) |
---|
5767 | { |
---|
5768 | if (picDepth) |
---|
5769 | { |
---|
5770 | UInt uiAbsPartAddrCurrCU = m_uiAbsIdxInLCU + uiPartAddr; |
---|
5771 | Int iWidth, iHeight; |
---|
5772 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more |
---|
5773 | |
---|
5774 | TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec(); |
---|
5775 | Int iBlkX = ( getAddr() % picDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; |
---|
5776 | Int iBlkY = ( getAddr() / picDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; |
---|
5777 | |
---|
5778 | Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx ); |
---|
5779 | |
---|
5780 | Pel iDisp = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT ); |
---|
5781 | cMvPred->setHor( iDisp ); |
---|
5782 | clipMv(*cMvPred); |
---|
5783 | } |
---|
5784 | } |
---|
5785 | #endif //H_3D_NBDV_REF |
---|
5786 | |
---|
5787 | |
---|
5788 | Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos |
---|
5789 | #if H_3D_NBDV_REF |
---|
5790 | , Bool bDepthRefine |
---|
5791 | #endif |
---|
5792 | ) |
---|
5793 | { |
---|
5794 | if( pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) ) |
---|
5795 | { |
---|
5796 | Bool bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx ); |
---|
5797 | for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) |
---|
5798 | { |
---|
5799 | RefPicList eRefPicList = RefPicList(iList); |
---|
5800 | Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ; |
---|
5801 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
5802 | |
---|
5803 | if( refId >= 0) |
---|
5804 | { |
---|
5805 | Int refViewIdx = pcTmpCU->getSlice()->getRefPic(eRefPicList, refId)->getViewIndex(); |
---|
5806 | if (refViewIdx != m_pcSlice->getViewIndex()) |
---|
5807 | { |
---|
5808 | clipMv(cMvPred); |
---|
5809 | pNbDvInfo->m_acNBDV = cMvPred; |
---|
5810 | pNbDvInfo->m_aVIdxCan = refViewIdx; |
---|
5811 | #if H_3D_NBDV_REF |
---|
5812 | TComPic* picDepth = NULL; |
---|
5813 | assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC()); |
---|
5814 | picDepth = getSlice()->getIvPic (true, refViewIdx ); |
---|
5815 | assert(picDepth != NULL); |
---|
5816 | |
---|
5817 | UInt uiPartIdx = 0; //Notes from MTK: Please confirm that using 0 as partition index and partition address is correct for CU-level DoNBDV |
---|
5818 | UInt uiPartAddr = 0; //QC: confirmed |
---|
5819 | |
---|
5820 | if (picDepth && bDepthRefine) |
---|
5821 | estimateDVFromDM(refViewIdx, uiPartIdx, picDepth, uiPartAddr, &cMvPred ); |
---|
5822 | |
---|
5823 | pNbDvInfo->m_acDoNBDV = cMvPred; |
---|
5824 | #endif |
---|
5825 | return true; |
---|
5826 | } |
---|
5827 | else if ( bSearchForMvpDv && cMvPred.getIDVFlag() && bTmpIsSkipped ) |
---|
5828 | { |
---|
5829 | assert( uiMvpDvPos < IDV_CANDS ); |
---|
5830 | paIDVInfo->m_acMvCand[iList][ uiMvpDvPos ] = TComMv( cMvPred.getIDVHor(), cMvPred.getIDVVer() ); |
---|
5831 | //Notes from QC: DvMCP is implemented in a way that doesnE½t carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design. |
---|
5832 | paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = cMvPred.getIDVVId(); |
---|
5833 | paIDVInfo->m_bAvailab[iList][ uiMvpDvPos ] = true; |
---|
5834 | paIDVInfo->m_bFound = true; |
---|
5835 | } |
---|
5836 | } |
---|
5837 | } |
---|
5838 | } |
---|
5839 | return false; |
---|
5840 | } |
---|
5841 | |
---|
5842 | Void TComDataCU::xDeriveRightBottomNbIdx(Int &riLCUIdxRBNb, Int &riPartIdxRBNb ) |
---|
5843 | { |
---|
5844 | UInt uiPartIdx = 0; |
---|
5845 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
5846 | Int uiLCUIdx = getAddr(); |
---|
5847 | |
---|
5848 | UInt uiPartIdxRB; |
---|
5849 | deriveRightBottomIdx(uiPartIdx, uiPartIdxRB ); |
---|
5850 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
5851 | |
---|
5852 | if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
5853 | { |
---|
5854 | riLCUIdxRBNb = -1; |
---|
5855 | riPartIdxRBNb = -1; |
---|
5856 | } |
---|
5857 | else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
5858 | { |
---|
5859 | riLCUIdxRBNb = -1; |
---|
5860 | riPartIdxRBNb = -1; |
---|
5861 | } |
---|
5862 | else |
---|
5863 | { |
---|
5864 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
5865 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
5866 | { |
---|
5867 | riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
5868 | riLCUIdxRBNb = uiLCUIdx; |
---|
5869 | } |
---|
5870 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
5871 | { |
---|
5872 | riPartIdxRBNb = -1; |
---|
5873 | riLCUIdxRBNb = -1; |
---|
5874 | } |
---|
5875 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
5876 | { |
---|
5877 | riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
5878 | riLCUIdxRBNb = uiLCUIdx + 1; |
---|
5879 | } |
---|
5880 | else //is the right bottom corner of LCU |
---|
5881 | { |
---|
5882 | riPartIdxRBNb = -1; |
---|
5883 | riLCUIdxRBNb = -1; |
---|
5884 | } |
---|
5885 | } |
---|
5886 | } |
---|
5887 | |
---|
5888 | |
---|
5889 | Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
5890 | { |
---|
5891 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
5892 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
5893 | { |
---|
5894 | m_pDvInfo[uiAbsPartIdx + ui] = cDvInfo; |
---|
5895 | } |
---|
5896 | } |
---|
5897 | #if H_3D_VSP |
---|
5898 | Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth ) |
---|
5899 | { |
---|
5900 | setSubPartT<DisInfo>( cDvInfo, m_pDvInfo, uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
5901 | } |
---|
5902 | #endif |
---|
5903 | #if MTK_NBDV_TN_FIX_E0172 |
---|
5904 | Bool TComDataCU::xGetColDisMV( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx ) |
---|
5905 | #else |
---|
5906 | Bool TComDataCU::xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx ) |
---|
5907 | #endif |
---|
5908 | { |
---|
5909 | |
---|
5910 | RefPicList eColRefPicList = REF_PIC_LIST_0; |
---|
5911 | Int iColViewIdx, iColRefViewIdx; |
---|
5912 | TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx); |
---|
5913 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
5914 | iColViewIdx = pColCU->getSlice()->getViewIndex(); |
---|
5915 | if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiPartUnitIdx)) |
---|
5916 | { |
---|
5917 | return false; |
---|
5918 | } |
---|
5919 | for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++) |
---|
5920 | { |
---|
5921 | if(pColCU->getSlice()->isInterB()) |
---|
5922 | { |
---|
5923 | eColRefPicList = RefPicList(ilist); |
---|
5924 | } |
---|
5925 | |
---|
5926 | Int iColRefIdx = pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartUnitIdx); |
---|
5927 | |
---|
5928 | if (iColRefIdx < 0) |
---|
5929 | { |
---|
5930 | continue; |
---|
5931 | } |
---|
5932 | |
---|
5933 | iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewIndex(); |
---|
5934 | |
---|
5935 | if ( iColViewIdx == iColRefViewIdx ) // temporal vector |
---|
5936 | { |
---|
5937 | continue; |
---|
5938 | } |
---|
5939 | else |
---|
5940 | { |
---|
5941 | #if MTK_NBDV_TN_FIX_E0172 |
---|
5942 | if(getPic()->isTempIVRefValid(currCandPic, ilist, iColRefIdx)) |
---|
5943 | { |
---|
5944 | #endif |
---|
5945 | rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartUnitIdx); |
---|
5946 | rcMv.setIDVFlag(0); |
---|
5947 | iTargetViewIdx = iColRefViewIdx ; |
---|
5948 | iStartViewIdx = iColViewIdx ; |
---|
5949 | return true; |
---|
5950 | #if MTK_NBDV_TN_FIX_E0172 |
---|
5951 | } |
---|
5952 | #endif |
---|
5953 | } |
---|
5954 | } |
---|
5955 | |
---|
5956 | return false; |
---|
5957 | } |
---|
5958 | #endif |
---|
5959 | #if MTK_FAST_TEXTURE_ENCODING_E0173 |
---|
5960 | Void |
---|
5961 | TComDataCU::getIVNStatus ( UInt uiPartIdx, DisInfo* pDInfo, Bool& bIVFMerge, Int& iIVFMaxD) |
---|
5962 | { |
---|
5963 | TComSlice* pcSlice = getSlice (); |
---|
5964 | Int iViewIndex = pDInfo->m_aVIdxCan; |
---|
5965 | //--- get base CU/PU and check prediction mode --- |
---|
5966 | TComPic* pcBasePic = pcSlice->getIvPic( false, iViewIndex ); |
---|
5967 | TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); |
---|
5968 | |
---|
5969 | UInt uiPartAddr; |
---|
5970 | Int iWidth; |
---|
5971 | Int iHeight; |
---|
5972 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
5973 | |
---|
5974 | Int iCurrPosX, iCurrPosY; |
---|
5975 | pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
5976 | |
---|
5977 | iCurrPosX += ( ( iWidth - 1 ) >> 1 ); |
---|
5978 | iCurrPosY += ( ( iHeight - 1 ) >> 1 ); |
---|
5979 | |
---|
5980 | Bool depthRefineFlag = false; |
---|
5981 | #if H_3D_NBDV_REF |
---|
5982 | depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ); |
---|
5983 | #endif // H_3D_NBDV_REF |
---|
5984 | |
---|
5985 | TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
---|
5986 | |
---|
5987 | Int iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
5988 | Int iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
5989 | Int iBaseLPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX - (iWidth >> 1) + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
5990 | Int iBaseLPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
5991 | Int iBaseRPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + (iWidth >> 1) + 1 + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
5992 | Int iBaseRPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
5993 | Int iBaseUPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
5994 | Int iBaseUPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY - (iHeight >> 1) + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
5995 | Int iBaseDPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
5996 | Int iBaseDPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + (iHeight >> 1) + 1 + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
5997 | |
---|
5998 | Int iBaseCUAddr; |
---|
5999 | Int iBaseAbsPartIdx; |
---|
6000 | Int iBaseLCUAddr; |
---|
6001 | Int iBaseLAbsPartIdx; |
---|
6002 | Int iBaseRCUAddr; |
---|
6003 | Int iBaseRAbsPartIdx; |
---|
6004 | Int iBaseUCUAddr; |
---|
6005 | Int iBaseUAbsPartIdx; |
---|
6006 | Int iBaseDCUAddr; |
---|
6007 | Int iBaseDAbsPartIdx; |
---|
6008 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); |
---|
6009 | pcBaseRec->getCUAddrAndPartIdx( iBaseLPosX , iBaseLPosY , iBaseLCUAddr, iBaseLAbsPartIdx ); |
---|
6010 | pcBaseRec->getCUAddrAndPartIdx( iBaseRPosX , iBaseRPosY , iBaseRCUAddr, iBaseRAbsPartIdx ); |
---|
6011 | pcBaseRec->getCUAddrAndPartIdx( iBaseUPosX , iBaseUPosY , iBaseUCUAddr, iBaseUAbsPartIdx ); |
---|
6012 | pcBaseRec->getCUAddrAndPartIdx( iBaseDPosX , iBaseDPosY , iBaseDCUAddr, iBaseDAbsPartIdx ); |
---|
6013 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
---|
6014 | TComDataCU* pcBaseLCU = pcBasePic->getCU( iBaseLCUAddr ); |
---|
6015 | TComDataCU* pcBaseRCU = pcBasePic->getCU( iBaseRCUAddr ); |
---|
6016 | TComDataCU* pcBaseUCU = pcBasePic->getCU( iBaseUCUAddr ); |
---|
6017 | TComDataCU* pcBaseDCU = pcBasePic->getCU( iBaseDCUAddr ); |
---|
6018 | bIVFMerge = pcBaseLCU->getMergeFlag( iBaseLAbsPartIdx ) && pcBaseCU->getMergeFlag( iBaseAbsPartIdx ) && pcBaseRCU->getMergeFlag( iBaseRAbsPartIdx ) && pcBaseUCU->getMergeFlag( iBaseUAbsPartIdx ) && pcBaseDCU->getMergeFlag( iBaseDAbsPartIdx ); |
---|
6019 | Int aiDepthL[5]; //depth level |
---|
6020 | aiDepthL[0] = pcBaseCU->getDepth(iBaseAbsPartIdx); |
---|
6021 | aiDepthL[1] = pcBaseLCU->getDepth(iBaseLAbsPartIdx); |
---|
6022 | aiDepthL[2] = pcBaseRCU->getDepth(iBaseRAbsPartIdx); |
---|
6023 | aiDepthL[3] = pcBaseUCU->getDepth(iBaseUAbsPartIdx); |
---|
6024 | aiDepthL[4] = pcBaseDCU->getDepth(iBaseDAbsPartIdx); |
---|
6025 | for (Int i = 0; i < 5; i++) |
---|
6026 | { |
---|
6027 | if (iIVFMaxD < aiDepthL[i]) |
---|
6028 | iIVFMaxD = aiDepthL[i]; |
---|
6029 | } |
---|
6030 | } |
---|
6031 | #endif |
---|
6032 | #if H_3D_IV_MERGE |
---|
6033 | Bool |
---|
6034 | TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc ) |
---|
6035 | { |
---|
6036 | TComSlice* pcSlice = getSlice (); |
---|
6037 | Int iViewIndex = pDInfo->m_aVIdxCan; |
---|
6038 | |
---|
6039 | //--- get base CU/PU and check prediction mode --- |
---|
6040 | TComPic* pcBasePic = pcSlice->getIvPic( false, iViewIndex ); |
---|
6041 | TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); |
---|
6042 | |
---|
6043 | UInt uiPartAddr; |
---|
6044 | Int iWidth; |
---|
6045 | Int iHeight; |
---|
6046 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
6047 | |
---|
6048 | Int iCurrPosX, iCurrPosY; |
---|
6049 | pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
6050 | |
---|
6051 | iCurrPosX += ( ( iWidth - 1 ) >> 1 ); |
---|
6052 | iCurrPosY += ( ( iHeight - 1 ) >> 1 ); |
---|
6053 | |
---|
6054 | Bool depthRefineFlag = false; |
---|
6055 | #if H_3D_NBDV_REF |
---|
6056 | depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ); |
---|
6057 | #endif // H_3D_NBDV_REF |
---|
6058 | |
---|
6059 | TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
---|
6060 | |
---|
6061 | Bool abPdmAvailable[8] = {false, false, false, false, false, false, false, false}; |
---|
6062 | #if H_3D_NBDV |
---|
6063 | for( Int i = 0; i < 8; i++) |
---|
6064 | { |
---|
6065 | pacPdmMv[i].setIDVFlag (false); |
---|
6066 | } |
---|
6067 | #endif |
---|
6068 | |
---|
6069 | //////////////////////////////// |
---|
6070 | /////// IvMC + IvMCShift /////// |
---|
6071 | //////////////////////////////// |
---|
6072 | |
---|
6073 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
6074 | { |
---|
6075 | // iLoopCan == 0 --> IvMC |
---|
6076 | // iLoopCan == 1 --> IvMCShift |
---|
6077 | |
---|
6078 | Int iBaseCUAddr; |
---|
6079 | Int iBaseAbsPartIdx; |
---|
6080 | |
---|
6081 | Int offsetW = (iLoopCan == 0) ? 0 : ( ((iWidth /2)*4) + 4 ); |
---|
6082 | Int offsetH = (iLoopCan == 0) ? 0 : ( ((iHeight/2)*4) + 4 ); |
---|
6083 | |
---|
6084 | Int iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) ); |
---|
6085 | Int iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); |
---|
6086 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); |
---|
6087 | |
---|
6088 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
---|
6089 | if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA )) |
---|
6090 | { |
---|
6091 | // Loop reference picture list of current slice (X in spec). |
---|
6092 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
6093 | { |
---|
6094 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
6095 | |
---|
6096 | Bool stopLoop = false; |
---|
6097 | // Loop reference picture list of candidate slice (Y in spec) |
---|
6098 | for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop) |
---|
6099 | { |
---|
6100 | RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); |
---|
6101 | TComMvField cBaseMvField; |
---|
6102 | pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField ); |
---|
6103 | Int iBaseRefIdx = cBaseMvField.getRefIdx(); |
---|
6104 | if (iBaseRefIdx >= 0) |
---|
6105 | { |
---|
6106 | Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx); |
---|
6107 | if (iBaseRefPOC != pcSlice->getPOC()) |
---|
6108 | { |
---|
6109 | for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) |
---|
6110 | { |
---|
6111 | if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) |
---|
6112 | { |
---|
6113 | abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true; |
---|
6114 | TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer()); |
---|
6115 | #if H_3D_NBDV |
---|
6116 | cMv.setIDVFlag (true); |
---|
6117 | cMv.setIDVHor (cDv.getHor()); |
---|
6118 | cMv.setIDVVer (cDv.getVer()); |
---|
6119 | cMv.setIDVVId (iViewIndex); |
---|
6120 | #endif |
---|
6121 | clipMv( cMv ); |
---|
6122 | paiPdmRefIdx [ (uiCurrRefListId + (iLoopCan<<2)) ] = iPdmRefIdx; |
---|
6123 | pacPdmMv [ (uiCurrRefListId + (iLoopCan<<2)) ] = cMv; |
---|
6124 | stopLoop = true; |
---|
6125 | break; |
---|
6126 | } |
---|
6127 | } |
---|
6128 | } |
---|
6129 | } |
---|
6130 | } |
---|
6131 | } |
---|
6132 | } |
---|
6133 | } |
---|
6134 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
6135 | { |
---|
6136 | availableMcDc[(iLoopCan << 1)] = ( abPdmAvailable[(iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[1 + (iLoopCan<<2)] ? 2 : 0); |
---|
6137 | } |
---|
6138 | |
---|
6139 | |
---|
6140 | //////////////////////////////// |
---|
6141 | /////// IvDC + IvDCShift /////// |
---|
6142 | //////////////////////////////// |
---|
6143 | |
---|
6144 | for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ ) |
---|
6145 | { |
---|
6146 | RefPicList eRefPicListDMV = RefPicList( iRefListId ); |
---|
6147 | Int iNumRefPics = pcSlice->getNumRefIdx( eRefPicListDMV ); |
---|
6148 | for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ ) |
---|
6149 | { |
---|
6150 | if(( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC()) && (pcSlice->getRefPic( eRefPicListDMV, iPdmRefIdx )->getViewIndex() == pDInfo->m_aVIdxCan)) |
---|
6151 | { |
---|
6152 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
6153 | { |
---|
6154 | Int ioffsetDV = (iLoopCan == 0) ? 0 : 4; |
---|
6155 | abPdmAvailable[ iRefListId + 2 + (iLoopCan<<2) ] = true; |
---|
6156 | paiPdmRefIdx [ iRefListId + 2 + (iLoopCan<<2) ] = iPdmRefIdx; |
---|
6157 | #if H_3D_NBDV_REF |
---|
6158 | TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
---|
6159 | #endif |
---|
6160 | cMv.setHor( cMv.getHor() + ioffsetDV ); |
---|
6161 | cMv.setVer( 0 ); |
---|
6162 | clipMv( cMv ); |
---|
6163 | pacPdmMv [iRefListId + 2 + (iLoopCan<<2)] = cMv; |
---|
6164 | } |
---|
6165 | break; |
---|
6166 | } |
---|
6167 | } |
---|
6168 | } |
---|
6169 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
6170 | { |
---|
6171 | availableMcDc[1 + (iLoopCan << 1)] = ( abPdmAvailable[2 + (iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[3 + (iLoopCan<<2)] ? 2 : 0 ); |
---|
6172 | } |
---|
6173 | return false; |
---|
6174 | } |
---|
6175 | #endif |
---|
6176 | #if H_3D_ARP |
---|
6177 | Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
6178 | { |
---|
6179 | assert( sizeof( *m_puhARPW) == 1 ); |
---|
6180 | memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
6181 | } |
---|
6182 | #endif |
---|
6183 | |
---|
6184 | #if H_3D_IC |
---|
6185 | Void TComDataCU::setICFlagSubParts( Bool bICFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
6186 | { |
---|
6187 | memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ))*sizeof(Bool) ); |
---|
6188 | } |
---|
6189 | |
---|
6190 | Bool TComDataCU::isICFlagRequired( UInt uiAbsPartIdx ) |
---|
6191 | { |
---|
6192 | UInt uiPartAddr; |
---|
6193 | UInt iNumbPart; |
---|
6194 | |
---|
6195 | if( !( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ) |
---|
6196 | { |
---|
6197 | return false; |
---|
6198 | } |
---|
6199 | |
---|
6200 | if( getSlice()->getIcSkipParseFlag() ) |
---|
6201 | { |
---|
6202 | if( getMergeFlag( uiAbsPartIdx ) && getMergeIndex( uiAbsPartIdx ) == 0 ) |
---|
6203 | { |
---|
6204 | return false; |
---|
6205 | } |
---|
6206 | } |
---|
6207 | |
---|
6208 | if( getMergeFlag( uiAbsPartIdx ) ) |
---|
6209 | { |
---|
6210 | return true; |
---|
6211 | } |
---|
6212 | |
---|
6213 | |
---|
6214 | Int iWidth, iHeight; |
---|
6215 | |
---|
6216 | iNumbPart = ( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ? 1 : ( getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 ) ); |
---|
6217 | |
---|
6218 | for(UInt i = 0; i < iNumbPart; i++) |
---|
6219 | { |
---|
6220 | getPartIndexAndSize( i, uiPartAddr, iWidth, iHeight, uiAbsPartIdx, true ); |
---|
6221 | uiPartAddr += uiAbsPartIdx; |
---|
6222 | |
---|
6223 | for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++) |
---|
6224 | { |
---|
6225 | RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
6226 | Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr); |
---|
6227 | |
---|
6228 | if( ( getInterDir( uiPartAddr ) & ( uiRefIdx+1 ) ) && iBestRefIdx >= 0 && getSlice()->getViewIndex() != getSlice()->getRefPic( eRefList, iBestRefIdx )->getViewIndex() ) |
---|
6229 | { |
---|
6230 | return true; |
---|
6231 | } |
---|
6232 | } |
---|
6233 | } |
---|
6234 | |
---|
6235 | return false; |
---|
6236 | } |
---|
6237 | #endif |
---|
6238 | #if H_3D_DIM_DMM |
---|
6239 | Void TComDataCU::setDmmWedgeTabIdxSubParts( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
6240 | { |
---|
6241 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
6242 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmmWedgeTabIdx[dmmType][uiAbsPartIdx+ui] = tabIdx; } |
---|
6243 | } |
---|
6244 | #if !SEC_DMM2_E0146_HHIFIX |
---|
6245 | Void TComDataCU::setDmm2DeltaEndSubParts( Int iDelta, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
6246 | { |
---|
6247 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
6248 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmm2DeltaEnd[uiAbsPartIdx+ui] = iDelta; } |
---|
6249 | } |
---|
6250 | #endif |
---|
6251 | Void TComDataCU::setDmm3IntraTabIdxSubParts( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
6252 | { |
---|
6253 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
6254 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmm3IntraTabIdx[uiAbsPartIdx+ui] = uiTIdx; } |
---|
6255 | } |
---|
6256 | #endif |
---|
6257 | #if H_3D_DIM_RBC |
---|
6258 | Void TComDataCU::reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion ) |
---|
6259 | { |
---|
6260 | Int iWidth; |
---|
6261 | Int iHeight; |
---|
6262 | if( uiDepth == 0 ) |
---|
6263 | { |
---|
6264 | iWidth = 64; |
---|
6265 | iHeight = 64; |
---|
6266 | } |
---|
6267 | else if( uiDepth == 1 ) |
---|
6268 | { |
---|
6269 | iWidth = 32; |
---|
6270 | iHeight = 32; |
---|
6271 | } |
---|
6272 | else if( uiDepth == 2 ) |
---|
6273 | { |
---|
6274 | iWidth = 16; |
---|
6275 | iHeight = 16; |
---|
6276 | } |
---|
6277 | else if( uiDepth == 3 ) |
---|
6278 | { |
---|
6279 | iWidth = 8; |
---|
6280 | iHeight = 8; |
---|
6281 | } |
---|
6282 | else // uiDepth == 4 |
---|
6283 | { |
---|
6284 | iWidth = 4; |
---|
6285 | iHeight = 4; |
---|
6286 | } |
---|
6287 | |
---|
6288 | Int iPtr = 0; |
---|
6289 | Int iX, iY; |
---|
6290 | Int iDir = -1; |
---|
6291 | Int iDiffX = 0, iDiffY = 0; |
---|
6292 | |
---|
6293 | // 1. Edge Code -> Vert & Horz Edges |
---|
6294 | Bool* pbEdge = (Bool*) xMalloc( Bool, 4 * iWidth * iHeight ); |
---|
6295 | |
---|
6296 | for( UInt ui = 0; ui < 4 * iWidth * iHeight; ui++ ) |
---|
6297 | pbEdge [ ui ] = false; |
---|
6298 | |
---|
6299 | // Direction : left(0), right(1), top(2), bottom(3), left-top(4), right-top(5), left-bottom(6), right-bottom(7) |
---|
6300 | // Code : 0deg(0), 45deg(1), -45deg(2), 90deg(3), -90deg(4), 135deg(5), -135deg(6) |
---|
6301 | const UChar tableDir[8][7] = { { 0, 6, 4, 3, 2, 7, 5 }, |
---|
6302 | { 1, 5, 7, 2, 3, 4, 6 }, |
---|
6303 | { 2, 4, 5, 0, 1, 6, 7 }, |
---|
6304 | { 3, 7, 6, 1, 0, 5, 4 }, |
---|
6305 | { 4, 0, 2, 6, 5, 3, 1 }, |
---|
6306 | { 5, 2, 1, 4, 7, 0, 3 }, |
---|
6307 | { 6, 3, 0, 7, 4, 1, 2 }, |
---|
6308 | { 7, 1, 3, 5, 6, 2, 0 }}; |
---|
6309 | |
---|
6310 | UChar ucCode = pucEdgeCode[iPtr++]; |
---|
6311 | |
---|
6312 | if( !bLeft ) |
---|
6313 | { |
---|
6314 | iX = ucStartPos; |
---|
6315 | iY = 0; |
---|
6316 | |
---|
6317 | switch(ucCode) |
---|
6318 | { |
---|
6319 | case 0: // bottom |
---|
6320 | iDir = 3; |
---|
6321 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6322 | break; |
---|
6323 | case 2: // left-bottom |
---|
6324 | iDir = 6; |
---|
6325 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6326 | break; |
---|
6327 | case 1: // right-bottom |
---|
6328 | iDir = 7; |
---|
6329 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6330 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6331 | break; |
---|
6332 | case 4: // left |
---|
6333 | iDir = 0; |
---|
6334 | assert(false); |
---|
6335 | break; |
---|
6336 | case 3: // right |
---|
6337 | iDir = 1; |
---|
6338 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6339 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6340 | break; |
---|
6341 | } |
---|
6342 | } |
---|
6343 | else |
---|
6344 | { |
---|
6345 | iX = 0; |
---|
6346 | iY = ucStartPos; |
---|
6347 | |
---|
6348 | switch(ucCode) |
---|
6349 | { |
---|
6350 | case 0: // right |
---|
6351 | iDir = 1; |
---|
6352 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6353 | break; |
---|
6354 | case 1: // right-top |
---|
6355 | iDir = 5; |
---|
6356 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6357 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6358 | break; |
---|
6359 | case 2: // right-bottom |
---|
6360 | iDir = 7; |
---|
6361 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6362 | break; |
---|
6363 | case 3: // top |
---|
6364 | iDir = 2; |
---|
6365 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6366 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6367 | break; |
---|
6368 | case 4: // bottom |
---|
6369 | iDir = 3; |
---|
6370 | assert(false); |
---|
6371 | break; |
---|
6372 | } |
---|
6373 | } |
---|
6374 | |
---|
6375 | switch( iDir ) |
---|
6376 | { |
---|
6377 | case 0: // left |
---|
6378 | iDiffX = -1; |
---|
6379 | iDiffY = 0; |
---|
6380 | break; |
---|
6381 | case 1: // right |
---|
6382 | iDiffX = +1; |
---|
6383 | iDiffY = 0; |
---|
6384 | break; |
---|
6385 | case 2: // top |
---|
6386 | iDiffX = 0; |
---|
6387 | iDiffY = -1; |
---|
6388 | break; |
---|
6389 | case 3: // bottom |
---|
6390 | iDiffX = 0; |
---|
6391 | iDiffY = +1; |
---|
6392 | break; |
---|
6393 | case 4: // left-top |
---|
6394 | iDiffX = -1; |
---|
6395 | iDiffY = -1; |
---|
6396 | break; |
---|
6397 | case 5: // right-top |
---|
6398 | iDiffX = +1; |
---|
6399 | iDiffY = -1; |
---|
6400 | break; |
---|
6401 | case 6: // left-bottom |
---|
6402 | iDiffX = -1; |
---|
6403 | iDiffY = +1; |
---|
6404 | break; |
---|
6405 | case 7: // right-bottom |
---|
6406 | iDiffX = +1; |
---|
6407 | iDiffY = +1; |
---|
6408 | break; |
---|
6409 | } |
---|
6410 | |
---|
6411 | iX += iDiffX; |
---|
6412 | iY += iDiffY; |
---|
6413 | |
---|
6414 | while( iPtr < ucNumEdge ) |
---|
6415 | { |
---|
6416 | ucCode = pucEdgeCode[iPtr++]; |
---|
6417 | |
---|
6418 | Int iNewDir = tableDir[iDir][ucCode]; |
---|
6419 | |
---|
6420 | switch( iNewDir ) |
---|
6421 | { |
---|
6422 | case 0: // left |
---|
6423 | iDiffX = -1; |
---|
6424 | iDiffY = 0; |
---|
6425 | break; |
---|
6426 | case 1: // right |
---|
6427 | iDiffX = +1; |
---|
6428 | iDiffY = 0; |
---|
6429 | break; |
---|
6430 | case 2: // top |
---|
6431 | iDiffX = 0; |
---|
6432 | iDiffY = -1; |
---|
6433 | break; |
---|
6434 | case 3: // bottom |
---|
6435 | iDiffX = 0; |
---|
6436 | iDiffY = +1; |
---|
6437 | break; |
---|
6438 | case 4: // left-top |
---|
6439 | iDiffX = -1; |
---|
6440 | iDiffY = -1; |
---|
6441 | break; |
---|
6442 | case 5: // right-top |
---|
6443 | iDiffX = +1; |
---|
6444 | iDiffY = -1; |
---|
6445 | break; |
---|
6446 | case 6: // left-bottom |
---|
6447 | iDiffX = -1; |
---|
6448 | iDiffY = +1; |
---|
6449 | break; |
---|
6450 | case 7: // right-bottom |
---|
6451 | iDiffX = +1; |
---|
6452 | iDiffY = +1; |
---|
6453 | break; |
---|
6454 | } |
---|
6455 | |
---|
6456 | switch( iDir ) |
---|
6457 | { |
---|
6458 | case 0: // left |
---|
6459 | switch( ucCode ) |
---|
6460 | { |
---|
6461 | case 0: |
---|
6462 | case 2: |
---|
6463 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6464 | break; |
---|
6465 | case 1: |
---|
6466 | case 3: |
---|
6467 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6468 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6469 | break; |
---|
6470 | case 4: |
---|
6471 | case 6: |
---|
6472 | // no |
---|
6473 | break; |
---|
6474 | case 5: |
---|
6475 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6476 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6477 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6478 | break; |
---|
6479 | } |
---|
6480 | break; |
---|
6481 | case 1: // right |
---|
6482 | switch( ucCode ) |
---|
6483 | { |
---|
6484 | case 0: |
---|
6485 | case 2: |
---|
6486 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6487 | break; |
---|
6488 | case 1: |
---|
6489 | case 3: |
---|
6490 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6491 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6492 | break; |
---|
6493 | case 4: |
---|
6494 | case 6: |
---|
6495 | // no |
---|
6496 | break; |
---|
6497 | case 5: |
---|
6498 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6499 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6500 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6501 | break; |
---|
6502 | } |
---|
6503 | break; |
---|
6504 | case 2: // top |
---|
6505 | switch( ucCode ) |
---|
6506 | { |
---|
6507 | case 0: |
---|
6508 | case 2: |
---|
6509 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6510 | break; |
---|
6511 | case 1: |
---|
6512 | case 3: |
---|
6513 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6514 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6515 | break; |
---|
6516 | case 4: |
---|
6517 | case 6: |
---|
6518 | // no |
---|
6519 | break; |
---|
6520 | case 5: |
---|
6521 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6522 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6523 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6524 | break; |
---|
6525 | } |
---|
6526 | break; |
---|
6527 | case 3: // bottom |
---|
6528 | switch( ucCode ) |
---|
6529 | { |
---|
6530 | case 0: |
---|
6531 | case 2: |
---|
6532 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6533 | break; |
---|
6534 | case 1: |
---|
6535 | case 3: |
---|
6536 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6537 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6538 | break; |
---|
6539 | case 4: |
---|
6540 | case 6: |
---|
6541 | // no |
---|
6542 | break; |
---|
6543 | case 5: |
---|
6544 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6545 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6546 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6547 | break; |
---|
6548 | } |
---|
6549 | break; |
---|
6550 | case 4: // left-top |
---|
6551 | switch( ucCode ) |
---|
6552 | { |
---|
6553 | case 0: |
---|
6554 | case 1: |
---|
6555 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6556 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6557 | break; |
---|
6558 | case 2: |
---|
6559 | case 4: |
---|
6560 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6561 | break; |
---|
6562 | case 3: |
---|
6563 | case 5: |
---|
6564 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6565 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6566 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6567 | break; |
---|
6568 | case 6: |
---|
6569 | // no |
---|
6570 | break; |
---|
6571 | } |
---|
6572 | break; |
---|
6573 | case 5: // right-top |
---|
6574 | switch( ucCode ) |
---|
6575 | { |
---|
6576 | case 0: |
---|
6577 | case 1: |
---|
6578 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6579 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6580 | break; |
---|
6581 | case 2: |
---|
6582 | case 4: |
---|
6583 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6584 | break; |
---|
6585 | case 3: |
---|
6586 | case 5: |
---|
6587 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6588 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6589 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6590 | break; |
---|
6591 | case 6: |
---|
6592 | // no |
---|
6593 | break; |
---|
6594 | } |
---|
6595 | break; |
---|
6596 | case 6: // left-bottom |
---|
6597 | switch( ucCode ) |
---|
6598 | { |
---|
6599 | case 0: |
---|
6600 | case 1: |
---|
6601 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6602 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6603 | break; |
---|
6604 | case 2: |
---|
6605 | case 4: |
---|
6606 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6607 | break; |
---|
6608 | case 3: |
---|
6609 | case 5: |
---|
6610 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
---|
6611 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6612 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6613 | break; |
---|
6614 | case 6: |
---|
6615 | // no |
---|
6616 | break; |
---|
6617 | } |
---|
6618 | break; |
---|
6619 | case 7: // right-bottom |
---|
6620 | switch( ucCode ) |
---|
6621 | { |
---|
6622 | case 0: |
---|
6623 | case 1: |
---|
6624 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6625 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6626 | break; |
---|
6627 | case 2: |
---|
6628 | case 4: |
---|
6629 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6630 | break; |
---|
6631 | case 3: |
---|
6632 | case 5: |
---|
6633 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
---|
6634 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
---|
6635 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
---|
6636 | break; |
---|
6637 | case 6: |
---|
6638 | // no |
---|
6639 | break; |
---|
6640 | } |
---|
6641 | break; |
---|
6642 | } |
---|
6643 | |
---|
6644 | assert( iX >= 0 && iX <= iWidth ); |
---|
6645 | assert( iY >= 0 && iY <= iHeight ); |
---|
6646 | |
---|
6647 | iX += iDiffX; |
---|
6648 | iY += iDiffY; |
---|
6649 | iDir = iNewDir; |
---|
6650 | } |
---|
6651 | |
---|
6652 | // finalize edge chain |
---|
6653 | if( iX == iWidth-1 ) |
---|
6654 | { |
---|
6655 | if( iY == 0 ) |
---|
6656 | { |
---|
6657 | if( iDir == 1 ) |
---|
6658 | { |
---|
6659 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
---|
6660 | } |
---|
6661 | else if( iDir == 5 ) |
---|
6662 | { |
---|
6663 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
---|
6664 | } |
---|
6665 | else |
---|
6666 | { |
---|
6667 | assert(false); |
---|
6668 | } |
---|
6669 | } |
---|
6670 | else if( iY == iHeight-1 ) |
---|
6671 | { |
---|
6672 | if( iDir == 3 ) |
---|
6673 | { |
---|
6674 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6675 | } |
---|
6676 | else if( iDir == 7 ) |
---|
6677 | { |
---|
6678 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6679 | } |
---|
6680 | else |
---|
6681 | { |
---|
6682 | assert(false); |
---|
6683 | } |
---|
6684 | } |
---|
6685 | else |
---|
6686 | { |
---|
6687 | if( iDir == 1 ) |
---|
6688 | { |
---|
6689 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
---|
6690 | } |
---|
6691 | else if( iDir == 3 ) |
---|
6692 | { |
---|
6693 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6694 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
---|
6695 | } |
---|
6696 | else if( iDir == 5 ) |
---|
6697 | { |
---|
6698 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
---|
6699 | } |
---|
6700 | else if( iDir == 7 ) |
---|
6701 | { |
---|
6702 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6703 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
---|
6704 | } |
---|
6705 | else |
---|
6706 | { |
---|
6707 | assert(false); |
---|
6708 | } |
---|
6709 | } |
---|
6710 | } |
---|
6711 | else if( iX == 0 ) |
---|
6712 | { |
---|
6713 | if( iY == 0 ) |
---|
6714 | { |
---|
6715 | if( iDir == 2 ) |
---|
6716 | { |
---|
6717 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6718 | } |
---|
6719 | else if( iDir == 4 ) |
---|
6720 | { |
---|
6721 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6722 | } |
---|
6723 | else |
---|
6724 | { |
---|
6725 | assert(false); |
---|
6726 | } |
---|
6727 | } |
---|
6728 | else if( iY == iHeight-1 ) |
---|
6729 | { |
---|
6730 | if( iDir == 0 ) |
---|
6731 | { |
---|
6732 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
---|
6733 | } |
---|
6734 | else if( iDir == 6 ) |
---|
6735 | { |
---|
6736 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
---|
6737 | } |
---|
6738 | else |
---|
6739 | { |
---|
6740 | assert(false); |
---|
6741 | } |
---|
6742 | } |
---|
6743 | else |
---|
6744 | { |
---|
6745 | if( iDir == 0 ) |
---|
6746 | { |
---|
6747 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
---|
6748 | } |
---|
6749 | else if( iDir == 2 ) |
---|
6750 | { |
---|
6751 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6752 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
---|
6753 | } |
---|
6754 | else if( iDir == 4 ) |
---|
6755 | { |
---|
6756 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6757 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
---|
6758 | } |
---|
6759 | else if( iDir == 6 ) |
---|
6760 | { |
---|
6761 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
---|
6762 | } |
---|
6763 | else |
---|
6764 | { |
---|
6765 | assert(false); |
---|
6766 | } |
---|
6767 | } |
---|
6768 | } |
---|
6769 | else if( iY == 0 ) |
---|
6770 | { |
---|
6771 | if( iDir == 1 ) |
---|
6772 | { |
---|
6773 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
---|
6774 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6775 | } |
---|
6776 | else if( iDir == 2 ) |
---|
6777 | { |
---|
6778 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6779 | } |
---|
6780 | else if( iDir == 4 ) |
---|
6781 | { |
---|
6782 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6783 | } |
---|
6784 | else if( iDir == 5 ) |
---|
6785 | { |
---|
6786 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
---|
6787 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6788 | } |
---|
6789 | else |
---|
6790 | { |
---|
6791 | assert(false); |
---|
6792 | } |
---|
6793 | } |
---|
6794 | else if( iY == iHeight-1 ) |
---|
6795 | { |
---|
6796 | if( iDir == 0 ) |
---|
6797 | { |
---|
6798 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
---|
6799 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6800 | } |
---|
6801 | else if( iDir == 3 ) |
---|
6802 | { |
---|
6803 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6804 | } |
---|
6805 | else if( iDir == 6 ) |
---|
6806 | { |
---|
6807 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
---|
6808 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6809 | } |
---|
6810 | else if( iDir == 7 ) |
---|
6811 | { |
---|
6812 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
---|
6813 | } |
---|
6814 | else |
---|
6815 | { |
---|
6816 | assert(false); |
---|
6817 | } |
---|
6818 | } |
---|
6819 | else |
---|
6820 | { |
---|
6821 | printf("reconPartiton: wrong termination\n"); |
---|
6822 | assert(false); |
---|
6823 | } |
---|
6824 | |
---|
6825 | // Reconstruct Region from Chain Code |
---|
6826 | Bool* pbVisit = (Bool*) xMalloc( Bool, iWidth * iHeight ); |
---|
6827 | Int* piStack = (Int* ) xMalloc( Int, iWidth * iHeight ); |
---|
6828 | |
---|
6829 | for( UInt ui = 0; ui < iWidth * iHeight; ui++ ) |
---|
6830 | { |
---|
6831 | pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next) |
---|
6832 | pbVisit [ ui ] = false; |
---|
6833 | } |
---|
6834 | |
---|
6835 | iPtr = 0; |
---|
6836 | piStack[iPtr++] = (0 << 8) | (0); |
---|
6837 | pbRegion[ 0 ] = false; |
---|
6838 | |
---|
6839 | while(iPtr > 0) |
---|
6840 | { |
---|
6841 | Int iTmp = piStack[--iPtr]; |
---|
6842 | Int iX1, iY1; |
---|
6843 | iX1 = iTmp & 0xff; |
---|
6844 | iY1 = (iTmp >> 8) & 0xff; |
---|
6845 | |
---|
6846 | pbVisit[ iX1 + iY1 * iWidth ] = true; |
---|
6847 | |
---|
6848 | assert( iX1 >= 0 && iX1 < iWidth ); |
---|
6849 | assert( iY1 >= 0 && iY1 < iHeight ); |
---|
6850 | |
---|
6851 | if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] ) |
---|
6852 | { |
---|
6853 | piStack[iPtr++] = (iY1 << 8) | (iX1 - 1); |
---|
6854 | pbRegion[ iX1 - 1 + iY1 * iWidth ] = false; |
---|
6855 | } |
---|
6856 | if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] ) |
---|
6857 | { |
---|
6858 | piStack[iPtr++] = (iY1 << 8) | (iX1 + 1); |
---|
6859 | pbRegion[ iX1 + 1 + iY1 * iWidth ] = false; |
---|
6860 | } |
---|
6861 | if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] ) |
---|
6862 | { |
---|
6863 | piStack[iPtr++] = ((iY1 - 1) << 8) | iX1; |
---|
6864 | pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false; |
---|
6865 | } |
---|
6866 | if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] ) |
---|
6867 | { |
---|
6868 | piStack[iPtr++] = ((iY1 + 1) << 8) | iX1; |
---|
6869 | pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false; |
---|
6870 | } |
---|
6871 | } |
---|
6872 | |
---|
6873 | xFree( pbEdge ); |
---|
6874 | xFree( pbVisit ); |
---|
6875 | xFree( piStack ); |
---|
6876 | } |
---|
6877 | #endif |
---|
6878 | |
---|
6879 | |
---|
6880 | //! \} |
---|