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-2014, 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 | #endif |
---|
123 | #if H_3D_DIM_SDC |
---|
124 | m_pbSDCFlag = NULL; |
---|
125 | m_apSegmentDCOffset[0] = NULL; |
---|
126 | m_apSegmentDCOffset[1] = NULL; |
---|
127 | #endif |
---|
128 | #endif |
---|
129 | m_bDecSubCu = false; |
---|
130 | m_sliceStartCU = 0; |
---|
131 | m_sliceSegmentStartCU = 0; |
---|
132 | #if H_3D_NBDV |
---|
133 | m_pDvInfo = NULL; |
---|
134 | #endif |
---|
135 | #if H_3D_VSP |
---|
136 | m_piVSPFlag = NULL; |
---|
137 | #endif |
---|
138 | #if H_3D_SPIVMP |
---|
139 | m_pbSPIVMPFlag = NULL; |
---|
140 | #endif |
---|
141 | #if H_3D_ARP |
---|
142 | m_puhARPW = NULL; |
---|
143 | #endif |
---|
144 | #if H_3D_IC |
---|
145 | m_pbICFlag = NULL; |
---|
146 | #endif |
---|
147 | #if H_3D_INTER_SDC |
---|
148 | #endif |
---|
149 | #if H_3D_DBBP |
---|
150 | m_pbDBBPFlag = NULL; |
---|
151 | #endif |
---|
152 | |
---|
153 | #if H_3D_DDD |
---|
154 | m_pucDisparityDerivedDepth = NULL; |
---|
155 | m_pbUseDDD = NULL; |
---|
156 | #endif |
---|
157 | } |
---|
158 | |
---|
159 | TComDataCU::~TComDataCU() |
---|
160 | { |
---|
161 | } |
---|
162 | |
---|
163 | Void TComDataCU::create(UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
164 | #if ADAPTIVE_QP_SELECTION |
---|
165 | , Bool bGlobalRMARLBuffer |
---|
166 | #endif |
---|
167 | ) |
---|
168 | { |
---|
169 | m_bDecSubCu = bDecSubCu; |
---|
170 | |
---|
171 | m_pcPic = NULL; |
---|
172 | m_pcSlice = NULL; |
---|
173 | m_uiNumPartition = uiNumPartition; |
---|
174 | m_unitSize = unitSize; |
---|
175 | |
---|
176 | if ( !bDecSubCu ) |
---|
177 | { |
---|
178 | m_phQP = (Char* )xMalloc(Char, uiNumPartition); |
---|
179 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
180 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
181 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
182 | |
---|
183 | m_skipFlag = new Bool[ uiNumPartition ]; |
---|
184 | |
---|
185 | m_pePartSize = new Char[ uiNumPartition ]; |
---|
186 | memset( m_pePartSize, SIZE_NONE,uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
187 | m_pePredMode = new Char[ uiNumPartition ]; |
---|
188 | m_CUTransquantBypass = new Bool[ uiNumPartition ]; |
---|
189 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
190 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
191 | #if H_3D_VSP |
---|
192 | m_piVSPFlag = (Char* )xMalloc(Char, uiNumPartition); |
---|
193 | #endif |
---|
194 | #if H_3D_SPIVMP |
---|
195 | m_pbSPIVMPFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
196 | #endif |
---|
197 | m_puhLumaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
198 | m_puhChromaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
199 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
200 | |
---|
201 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
202 | m_puhTransformSkip[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
203 | m_puhTransformSkip[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
204 | m_puhTransformSkip[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
205 | |
---|
206 | m_puhCbf[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
207 | m_puhCbf[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
208 | m_puhCbf[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
209 | |
---|
210 | m_apiMVPIdx[0] = new Char[ uiNumPartition ]; |
---|
211 | m_apiMVPIdx[1] = new Char[ uiNumPartition ]; |
---|
212 | m_apiMVPNum[0] = new Char[ uiNumPartition ]; |
---|
213 | m_apiMVPNum[1] = new Char[ uiNumPartition ]; |
---|
214 | memset( m_apiMVPIdx[0], -1,uiNumPartition * sizeof( Char ) ); |
---|
215 | memset( m_apiMVPIdx[1], -1,uiNumPartition * sizeof( Char ) ); |
---|
216 | |
---|
217 | m_pcTrCoeffY = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight); |
---|
218 | m_pcTrCoeffCb = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
219 | m_pcTrCoeffCr = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
220 | #if H_3D_NBDV |
---|
221 | m_pDvInfo = (DisInfo* )xMalloc(DisInfo, uiNumPartition); |
---|
222 | #endif |
---|
223 | memset( m_pcTrCoeffY, 0,uiWidth*uiHeight * sizeof( TCoeff ) ); |
---|
224 | memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
---|
225 | memset( m_pcTrCoeffCr, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
---|
226 | #if ADAPTIVE_QP_SELECTION |
---|
227 | if( bGlobalRMARLBuffer ) |
---|
228 | { |
---|
229 | if( m_pcGlbArlCoeffY == NULL ) |
---|
230 | { |
---|
231 | m_pcGlbArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
---|
232 | m_pcGlbArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
233 | m_pcGlbArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
234 | } |
---|
235 | m_pcArlCoeffY = m_pcGlbArlCoeffY; |
---|
236 | m_pcArlCoeffCb = m_pcGlbArlCoeffCb; |
---|
237 | m_pcArlCoeffCr = m_pcGlbArlCoeffCr; |
---|
238 | m_ArlCoeffIsAliasedAllocation = true; |
---|
239 | } |
---|
240 | else |
---|
241 | { |
---|
242 | m_pcArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
---|
243 | m_pcArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
244 | m_pcArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
245 | } |
---|
246 | #endif |
---|
247 | |
---|
248 | m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
249 | m_pcIPCMSampleY = (Pel* )xMalloc(Pel , uiWidth*uiHeight); |
---|
250 | m_pcIPCMSampleCb = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
---|
251 | m_pcIPCMSampleCr = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
---|
252 | |
---|
253 | m_acCUMvField[0].create( uiNumPartition ); |
---|
254 | m_acCUMvField[1].create( uiNumPartition ); |
---|
255 | |
---|
256 | #if H_3D_ARP |
---|
257 | m_puhARPW = new UChar[ uiNumPartition]; |
---|
258 | #endif |
---|
259 | #if H_3D_IC |
---|
260 | m_pbICFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
261 | #endif |
---|
262 | #if H_3D_DIM |
---|
263 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
264 | { |
---|
265 | m_dimDeltaDC[i][0] = (Pel* )xMalloc(Pel, uiNumPartition); |
---|
266 | m_dimDeltaDC[i][1] = (Pel* )xMalloc(Pel, uiNumPartition); |
---|
267 | } |
---|
268 | #if H_3D_DIM_DMM |
---|
269 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
270 | { |
---|
271 | m_dmmWedgeTabIdx[i] = (UInt*)xMalloc(UInt, uiNumPartition); |
---|
272 | } |
---|
273 | #endif |
---|
274 | #if H_3D_DIM_SDC |
---|
275 | m_pbSDCFlag = (Bool*)xMalloc(Bool, uiNumPartition); |
---|
276 | m_apSegmentDCOffset[0] = (Pel*)xMalloc(Pel, uiNumPartition); |
---|
277 | m_apSegmentDCOffset[1] = (Pel*)xMalloc(Pel, uiNumPartition); |
---|
278 | #endif |
---|
279 | #endif |
---|
280 | #if H_3D_DBBP |
---|
281 | m_pbDBBPFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
282 | #endif |
---|
283 | } |
---|
284 | else |
---|
285 | { |
---|
286 | m_acCUMvField[0].setNumPartition(uiNumPartition ); |
---|
287 | m_acCUMvField[1].setNumPartition(uiNumPartition ); |
---|
288 | } |
---|
289 | m_sliceStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
290 | m_sliceSegmentStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
291 | |
---|
292 | // create pattern memory |
---|
293 | m_pcPattern = (TComPattern*)xMalloc(TComPattern, 1); |
---|
294 | |
---|
295 | #if H_3D_DDD |
---|
296 | m_pucDisparityDerivedDepth = (UChar* )xMalloc( UChar, uiNumPartition); |
---|
297 | m_pbUseDDD = (Bool* ) xMalloc( Bool, uiNumPartition); |
---|
298 | #endif |
---|
299 | |
---|
300 | // create motion vector fields |
---|
301 | |
---|
302 | m_pcCUAboveLeft = NULL; |
---|
303 | m_pcCUAboveRight = NULL; |
---|
304 | m_pcCUAbove = NULL; |
---|
305 | m_pcCULeft = NULL; |
---|
306 | |
---|
307 | m_apcCUColocated[0] = NULL; |
---|
308 | m_apcCUColocated[1] = NULL; |
---|
309 | } |
---|
310 | |
---|
311 | Void TComDataCU::destroy() |
---|
312 | { |
---|
313 | m_pcPic = NULL; |
---|
314 | m_pcSlice = NULL; |
---|
315 | |
---|
316 | if ( m_pcPattern ) |
---|
317 | { |
---|
318 | xFree(m_pcPattern); |
---|
319 | m_pcPattern = NULL; |
---|
320 | } |
---|
321 | |
---|
322 | // encoder-side buffer free |
---|
323 | if ( !m_bDecSubCu ) |
---|
324 | { |
---|
325 | if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } |
---|
326 | if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } |
---|
327 | if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } |
---|
328 | if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } |
---|
329 | |
---|
330 | if ( m_skipFlag ) { delete[] m_skipFlag; m_skipFlag = NULL; } |
---|
331 | |
---|
332 | if ( m_pePartSize ) { delete[] m_pePartSize; m_pePartSize = NULL; } |
---|
333 | if ( m_pePredMode ) { delete[] m_pePredMode; m_pePredMode = NULL; } |
---|
334 | if ( m_CUTransquantBypass ) { delete[] m_CUTransquantBypass;m_CUTransquantBypass = NULL; } |
---|
335 | if ( m_puhCbf[0] ) { xFree(m_puhCbf[0]); m_puhCbf[0] = NULL; } |
---|
336 | if ( m_puhCbf[1] ) { xFree(m_puhCbf[1]); m_puhCbf[1] = NULL; } |
---|
337 | if ( m_puhCbf[2] ) { xFree(m_puhCbf[2]); m_puhCbf[2] = NULL; } |
---|
338 | if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } |
---|
339 | if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } |
---|
340 | if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } |
---|
341 | #if H_3D_VSP |
---|
342 | if ( m_piVSPFlag ) { xFree(m_piVSPFlag); m_piVSPFlag = NULL; } |
---|
343 | #endif |
---|
344 | #if H_3D_SPIVMP |
---|
345 | if ( m_pbSPIVMPFlag ) { xFree(m_pbSPIVMPFlag); m_pbSPIVMPFlag = NULL; } |
---|
346 | #endif |
---|
347 | if ( m_puhLumaIntraDir ) { xFree(m_puhLumaIntraDir); m_puhLumaIntraDir = NULL; } |
---|
348 | if ( m_puhChromaIntraDir ) { xFree(m_puhChromaIntraDir); m_puhChromaIntraDir = NULL; } |
---|
349 | if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } |
---|
350 | if ( m_puhTransformSkip[0]) { xFree(m_puhTransformSkip[0]); m_puhTransformSkip[0] = NULL; } |
---|
351 | if ( m_puhTransformSkip[1]) { xFree(m_puhTransformSkip[1]); m_puhTransformSkip[1] = NULL; } |
---|
352 | if ( m_puhTransformSkip[2]) { xFree(m_puhTransformSkip[2]); m_puhTransformSkip[2] = NULL; } |
---|
353 | if ( m_pcTrCoeffY ) { xFree(m_pcTrCoeffY); m_pcTrCoeffY = NULL; } |
---|
354 | if ( m_pcTrCoeffCb ) { xFree(m_pcTrCoeffCb); m_pcTrCoeffCb = NULL; } |
---|
355 | if ( m_pcTrCoeffCr ) { xFree(m_pcTrCoeffCr); m_pcTrCoeffCr = NULL; } |
---|
356 | #if ADAPTIVE_QP_SELECTION |
---|
357 | if (!m_ArlCoeffIsAliasedAllocation) |
---|
358 | { |
---|
359 | xFree(m_pcArlCoeffY); m_pcArlCoeffY = 0; |
---|
360 | xFree(m_pcArlCoeffCb); m_pcArlCoeffCb = 0; |
---|
361 | xFree(m_pcArlCoeffCr); m_pcArlCoeffCr = 0; |
---|
362 | } |
---|
363 | if ( m_pcGlbArlCoeffY ) { xFree(m_pcGlbArlCoeffY); m_pcGlbArlCoeffY = NULL; } |
---|
364 | if ( m_pcGlbArlCoeffCb ) { xFree(m_pcGlbArlCoeffCb); m_pcGlbArlCoeffCb = NULL; } |
---|
365 | if ( m_pcGlbArlCoeffCr ) { xFree(m_pcGlbArlCoeffCr); m_pcGlbArlCoeffCr = NULL; } |
---|
366 | #endif |
---|
367 | if ( m_pbIPCMFlag ) { xFree(m_pbIPCMFlag ); m_pbIPCMFlag = NULL; } |
---|
368 | if ( m_pcIPCMSampleY ) { xFree(m_pcIPCMSampleY); m_pcIPCMSampleY = NULL; } |
---|
369 | if ( m_pcIPCMSampleCb ) { xFree(m_pcIPCMSampleCb); m_pcIPCMSampleCb = NULL; } |
---|
370 | if ( m_pcIPCMSampleCr ) { xFree(m_pcIPCMSampleCr); m_pcIPCMSampleCr = NULL; } |
---|
371 | if ( m_apiMVPIdx[0] ) { delete[] m_apiMVPIdx[0]; m_apiMVPIdx[0] = NULL; } |
---|
372 | if ( m_apiMVPIdx[1] ) { delete[] m_apiMVPIdx[1]; m_apiMVPIdx[1] = NULL; } |
---|
373 | if ( m_apiMVPNum[0] ) { delete[] m_apiMVPNum[0]; m_apiMVPNum[0] = NULL; } |
---|
374 | if ( m_apiMVPNum[1] ) { delete[] m_apiMVPNum[1]; m_apiMVPNum[1] = NULL; } |
---|
375 | #if H_3D_NBDV |
---|
376 | if ( m_pDvInfo ) { xFree(m_pDvInfo); m_pDvInfo = NULL; } |
---|
377 | #endif |
---|
378 | |
---|
379 | #if H_3D_DDD |
---|
380 | if ( m_pucDisparityDerivedDepth ) { xFree(m_pucDisparityDerivedDepth); m_pucDisparityDerivedDepth = NULL; } |
---|
381 | if ( m_pbUseDDD ) { xFree(m_pbUseDDD); m_pbUseDDD = NULL; } |
---|
382 | #endif |
---|
383 | |
---|
384 | #if H_3D_ARP |
---|
385 | if ( m_puhARPW ) { delete[] m_puhARPW; m_puhARPW = NULL; } |
---|
386 | #endif |
---|
387 | #if H_3D_IC |
---|
388 | if ( m_pbICFlag ) { xFree(m_pbICFlag); m_pbICFlag = NULL; } |
---|
389 | #endif |
---|
390 | m_acCUMvField[0].destroy(); |
---|
391 | m_acCUMvField[1].destroy(); |
---|
392 | |
---|
393 | #if H_3D_DIM |
---|
394 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
395 | { |
---|
396 | if ( m_dimDeltaDC[i][0] ) { xFree( m_dimDeltaDC[i][0] ); m_dimDeltaDC[i][0] = NULL; } |
---|
397 | if ( m_dimDeltaDC[i][1] ) { xFree( m_dimDeltaDC[i][1] ); m_dimDeltaDC[i][1] = NULL; } |
---|
398 | } |
---|
399 | #if H_3D_DIM_DMM |
---|
400 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
401 | { |
---|
402 | if ( m_dmmWedgeTabIdx[i] ) { xFree( m_dmmWedgeTabIdx[i] ); m_dmmWedgeTabIdx[i] = NULL; } |
---|
403 | } |
---|
404 | #endif |
---|
405 | #if H_3D_DIM_SDC |
---|
406 | if ( m_pbSDCFlag ) { xFree(m_pbSDCFlag); m_pbSDCFlag = NULL; } |
---|
407 | if ( m_apSegmentDCOffset[0] ) { xFree(m_apSegmentDCOffset[0]); m_apSegmentDCOffset[0] = NULL; } |
---|
408 | if ( m_apSegmentDCOffset[1] ) { xFree(m_apSegmentDCOffset[1]); m_apSegmentDCOffset[1] = NULL; } |
---|
409 | #endif |
---|
410 | #endif |
---|
411 | #if H_3D_DBBP |
---|
412 | if ( m_pbDBBPFlag ) { xFree(m_pbDBBPFlag); m_pbDBBPFlag = NULL; } |
---|
413 | #endif |
---|
414 | } |
---|
415 | m_pcCUAboveLeft = NULL; |
---|
416 | m_pcCUAboveRight = NULL; |
---|
417 | m_pcCUAbove = NULL; |
---|
418 | m_pcCULeft = NULL; |
---|
419 | |
---|
420 | m_apcCUColocated[0] = NULL; |
---|
421 | m_apcCUColocated[1] = NULL; |
---|
422 | |
---|
423 | if( m_sliceStartCU ) |
---|
424 | { |
---|
425 | xFree(m_sliceStartCU); |
---|
426 | m_sliceStartCU=NULL; |
---|
427 | } |
---|
428 | if(m_sliceSegmentStartCU ) |
---|
429 | { |
---|
430 | xFree(m_sliceSegmentStartCU); |
---|
431 | m_sliceSegmentStartCU=NULL; |
---|
432 | } |
---|
433 | } |
---|
434 | |
---|
435 | // ==================================================================================================================== |
---|
436 | // Public member functions |
---|
437 | // ==================================================================================================================== |
---|
438 | |
---|
439 | // -------------------------------------------------------------------------------------------------------------------- |
---|
440 | // Initialization |
---|
441 | // -------------------------------------------------------------------------------------------------------------------- |
---|
442 | |
---|
443 | /** |
---|
444 | - initialize top-level CU |
---|
445 | - internal buffers are already created |
---|
446 | - set values before encoding a CU |
---|
447 | . |
---|
448 | \param pcPic picture (TComPic) class pointer |
---|
449 | \param iCUAddr CU address |
---|
450 | */ |
---|
451 | Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr ) |
---|
452 | { |
---|
453 | |
---|
454 | m_pcPic = pcPic; |
---|
455 | m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
456 | m_uiCUAddr = iCUAddr; |
---|
457 | m_uiCUPelX = ( iCUAddr % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth; |
---|
458 | m_uiCUPelY = ( iCUAddr / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight; |
---|
459 | m_uiAbsIdxInLCU = 0; |
---|
460 | m_dTotalCost = MAX_DOUBLE; |
---|
461 | m_uiTotalDistortion = 0; |
---|
462 | m_uiTotalBits = 0; |
---|
463 | m_uiTotalBins = 0; |
---|
464 | m_uiNumPartition = pcPic->getNumPartInCU(); |
---|
465 | |
---|
466 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
---|
467 | { |
---|
468 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceCurStartCUAddr()) |
---|
469 | { |
---|
470 | m_sliceStartCU[i]=getSlice()->getSliceCurStartCUAddr(); |
---|
471 | } |
---|
472 | else |
---|
473 | { |
---|
474 | m_sliceStartCU[i]=pcPic->getCU(getAddr())->m_sliceStartCU[i]; |
---|
475 | } |
---|
476 | } |
---|
477 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
---|
478 | { |
---|
479 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
480 | { |
---|
481 | m_sliceSegmentStartCU[i]=getSlice()->getSliceSegmentCurStartCUAddr(); |
---|
482 | } |
---|
483 | else |
---|
484 | { |
---|
485 | m_sliceSegmentStartCU[i]=pcPic->getCU(getAddr())->m_sliceSegmentStartCU[i]; |
---|
486 | } |
---|
487 | } |
---|
488 | |
---|
489 | Int partStartIdx = getSlice()->getSliceSegmentCurStartCUAddr() - pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr) * pcPic->getNumPartInCU(); |
---|
490 | |
---|
491 | Int numElements = min<Int>( partStartIdx, m_uiNumPartition ); |
---|
492 | for ( Int ui = 0; ui < numElements; ui++ ) |
---|
493 | { |
---|
494 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
---|
495 | m_skipFlag[ui] = pcFrom->getSkipFlag(ui); |
---|
496 | m_pePartSize[ui] = pcFrom->getPartitionSize(ui); |
---|
497 | m_pePredMode[ui] = pcFrom->getPredictionMode(ui); |
---|
498 | m_CUTransquantBypass[ui] = pcFrom->getCUTransquantBypass(ui); |
---|
499 | m_puhDepth[ui] = pcFrom->getDepth(ui); |
---|
500 | #if H_3D_ARP |
---|
501 | m_puhARPW [ui] = pcFrom->getARPW( ui ); |
---|
502 | #endif |
---|
503 | #if H_3D_IC |
---|
504 | m_pbICFlag[ui] = pcFrom->m_pbICFlag[ui]; |
---|
505 | #endif |
---|
506 | |
---|
507 | #if H_3D_DDD |
---|
508 | m_pucDisparityDerivedDepth[ui] = pcFrom->m_pucDisparityDerivedDepth[ui]; |
---|
509 | m_pbUseDDD[ui] = pcFrom->m_pbUseDDD[ui]; |
---|
510 | #endif |
---|
511 | |
---|
512 | m_puhWidth [ui] = pcFrom->getWidth(ui); |
---|
513 | m_puhHeight [ui] = pcFrom->getHeight(ui); |
---|
514 | m_puhTrIdx [ui] = pcFrom->getTransformIdx(ui); |
---|
515 | m_puhTransformSkip[0][ui] = pcFrom->getTransformSkip(ui,TEXT_LUMA); |
---|
516 | m_puhTransformSkip[1][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_U); |
---|
517 | m_puhTransformSkip[2][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_V); |
---|
518 | m_apiMVPIdx[0][ui] = pcFrom->m_apiMVPIdx[0][ui];; |
---|
519 | m_apiMVPIdx[1][ui] = pcFrom->m_apiMVPIdx[1][ui]; |
---|
520 | m_apiMVPNum[0][ui] = pcFrom->m_apiMVPNum[0][ui]; |
---|
521 | m_apiMVPNum[1][ui] = pcFrom->m_apiMVPNum[1][ui]; |
---|
522 | m_phQP[ui]=pcFrom->m_phQP[ui]; |
---|
523 | m_pbMergeFlag[ui]=pcFrom->m_pbMergeFlag[ui]; |
---|
524 | m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui]; |
---|
525 | #if H_3D_VSP |
---|
526 | m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui]; |
---|
527 | #endif |
---|
528 | #if H_3D_SPIVMP |
---|
529 | m_pbSPIVMPFlag[ui] = pcFrom->m_pbSPIVMPFlag[ui]; |
---|
530 | #endif |
---|
531 | m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui]; |
---|
532 | m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui]; |
---|
533 | m_puhInterDir[ui]=pcFrom->m_puhInterDir[ui]; |
---|
534 | m_puhCbf[0][ui]=pcFrom->m_puhCbf[0][ui]; |
---|
535 | m_puhCbf[1][ui]=pcFrom->m_puhCbf[1][ui]; |
---|
536 | m_puhCbf[2][ui]=pcFrom->m_puhCbf[2][ui]; |
---|
537 | m_pbIPCMFlag[ui] = pcFrom->m_pbIPCMFlag[ui]; |
---|
538 | #if H_3D_DIM_SDC |
---|
539 | m_pbSDCFlag[ui] = pcFrom->m_pbSDCFlag[ui]; |
---|
540 | #endif |
---|
541 | #if H_3D_DBBP |
---|
542 | m_pbDBBPFlag[ui] = pcFrom->m_pbDBBPFlag[ui]; |
---|
543 | #endif |
---|
544 | } |
---|
545 | |
---|
546 | Int firstElement = max<Int>( partStartIdx, 0 ); |
---|
547 | numElements = m_uiNumPartition - firstElement; |
---|
548 | |
---|
549 | if ( numElements > 0 ) |
---|
550 | { |
---|
551 | memset( m_skipFlag + firstElement, false, numElements * sizeof( *m_skipFlag ) ); |
---|
552 | |
---|
553 | memset( m_pePartSize + firstElement, SIZE_NONE, numElements * sizeof( *m_pePartSize ) ); |
---|
554 | memset( m_pePredMode + firstElement, MODE_NONE, numElements * sizeof( *m_pePredMode ) ); |
---|
555 | memset( m_CUTransquantBypass+ firstElement, false, numElements * sizeof( *m_CUTransquantBypass) ); |
---|
556 | memset( m_puhDepth + firstElement, 0, numElements * sizeof( *m_puhDepth ) ); |
---|
557 | memset( m_puhTrIdx + firstElement, 0, numElements * sizeof( *m_puhTrIdx ) ); |
---|
558 | memset( m_puhTransformSkip[0] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[0]) ); |
---|
559 | memset( m_puhTransformSkip[1] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[1]) ); |
---|
560 | memset( m_puhTransformSkip[2] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[2]) ); |
---|
561 | memset( m_puhWidth + firstElement, g_uiMaxCUWidth, numElements * sizeof( *m_puhWidth ) ); |
---|
562 | memset( m_puhHeight + firstElement, g_uiMaxCUHeight, numElements * sizeof( *m_puhHeight ) ); |
---|
563 | memset( m_apiMVPIdx[0] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[0] ) ); |
---|
564 | memset( m_apiMVPIdx[1] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[1] ) ); |
---|
565 | memset( m_apiMVPNum[0] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[0] ) ); |
---|
566 | memset( m_apiMVPNum[1] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[1] ) ); |
---|
567 | memset( m_phQP + firstElement, getSlice()->getSliceQp(), numElements * sizeof( *m_phQP ) ); |
---|
568 | memset( m_pbMergeFlag + firstElement, false, numElements * sizeof( *m_pbMergeFlag ) ); |
---|
569 | memset( m_puhMergeIndex + firstElement, 0, numElements * sizeof( *m_puhMergeIndex ) ); |
---|
570 | #if H_3D_VSP |
---|
571 | memset( m_piVSPFlag + firstElement, 0, numElements * sizeof( *m_piVSPFlag ) ); |
---|
572 | #endif |
---|
573 | #if H_3D_SPIVMP |
---|
574 | memset( m_pbSPIVMPFlag + firstElement, 0, numElements * sizeof( *m_pbSPIVMPFlag ) ); |
---|
575 | #endif |
---|
576 | memset( m_puhLumaIntraDir + firstElement, DC_IDX, numElements * sizeof( *m_puhLumaIntraDir ) ); |
---|
577 | memset( m_puhChromaIntraDir + firstElement, 0, numElements * sizeof( *m_puhChromaIntraDir ) ); |
---|
578 | memset( m_puhInterDir + firstElement, 0, numElements * sizeof( *m_puhInterDir ) ); |
---|
579 | memset( m_puhCbf[0] + firstElement, 0, numElements * sizeof( *m_puhCbf[0] ) ); |
---|
580 | memset( m_puhCbf[1] + firstElement, 0, numElements * sizeof( *m_puhCbf[1] ) ); |
---|
581 | memset( m_puhCbf[2] + firstElement, 0, numElements * sizeof( *m_puhCbf[2] ) ); |
---|
582 | memset( m_pbIPCMFlag + firstElement, false, numElements * sizeof( *m_pbIPCMFlag ) ); |
---|
583 | #if H_3D_ARP |
---|
584 | memset( m_puhARPW + firstElement, 0, numElements * sizeof( UChar ) ); |
---|
585 | #endif |
---|
586 | #if H_3D_IC |
---|
587 | memset( m_pbICFlag + firstElement, false, numElements * sizeof( *m_pbICFlag ) ); |
---|
588 | #endif |
---|
589 | |
---|
590 | #if H_3D_DDD |
---|
591 | memset( m_pucDisparityDerivedDepth + firstElement, 0, numElements * sizeof( *m_pucDisparityDerivedDepth ) ); |
---|
592 | memset( m_pbUseDDD + firstElement, 0, numElements * sizeof( *m_pbUseDDD ) ); |
---|
593 | #endif |
---|
594 | |
---|
595 | #if H_3D_DIM |
---|
596 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
597 | { |
---|
598 | memset( m_dimDeltaDC[i][0] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][0] ) ); |
---|
599 | memset( m_dimDeltaDC[i][1] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][1] ) ); |
---|
600 | } |
---|
601 | #if H_3D_DIM_DMM |
---|
602 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
603 | { |
---|
604 | memset( m_dmmWedgeTabIdx[i] + firstElement, 0, numElements * sizeof( *m_dmmWedgeTabIdx[i] ) ); |
---|
605 | } |
---|
606 | #endif |
---|
607 | #if H_3D_DIM_SDC |
---|
608 | memset( m_pbSDCFlag + firstElement, 0, numElements * sizeof( *m_pbSDCFlag ) ); |
---|
609 | memset( m_apSegmentDCOffset[0] + firstElement, 0, numElements * sizeof( *m_apSegmentDCOffset[0] ) ); |
---|
610 | memset( m_apSegmentDCOffset[1] + firstElement, 0, numElements * sizeof( *m_apSegmentDCOffset[1] ) ); |
---|
611 | #endif |
---|
612 | m_apDmmPredictor[0] = 0; |
---|
613 | m_apDmmPredictor[1] = 0; |
---|
614 | #endif |
---|
615 | #if H_3D_DBBP |
---|
616 | memset( m_pbDBBPFlag + firstElement, false, numElements * sizeof( *m_pbDBBPFlag ) ); |
---|
617 | #endif |
---|
618 | } |
---|
619 | |
---|
620 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight; |
---|
621 | if ( 0 >= partStartIdx ) |
---|
622 | { |
---|
623 | m_acCUMvField[0].clearMvField(); |
---|
624 | m_acCUMvField[1].clearMvField(); |
---|
625 | memset( m_pcTrCoeffY , 0, sizeof( TCoeff ) * uiTmp ); |
---|
626 | #if ADAPTIVE_QP_SELECTION |
---|
627 | memset( m_pcArlCoeffY , 0, sizeof( Int ) * uiTmp ); |
---|
628 | #endif |
---|
629 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
---|
630 | uiTmp >>= 2; |
---|
631 | memset( m_pcTrCoeffCb, 0, sizeof( TCoeff ) * uiTmp ); |
---|
632 | memset( m_pcTrCoeffCr, 0, sizeof( TCoeff ) * uiTmp ); |
---|
633 | #if ADAPTIVE_QP_SELECTION |
---|
634 | memset( m_pcArlCoeffCb, 0, sizeof( Int ) * uiTmp ); |
---|
635 | memset( m_pcArlCoeffCr, 0, sizeof( Int ) * uiTmp ); |
---|
636 | #endif |
---|
637 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
---|
638 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
---|
639 | } |
---|
640 | else |
---|
641 | { |
---|
642 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
---|
643 | m_acCUMvField[0].copyFrom(&pcFrom->m_acCUMvField[0],m_uiNumPartition,0); |
---|
644 | m_acCUMvField[1].copyFrom(&pcFrom->m_acCUMvField[1],m_uiNumPartition,0); |
---|
645 | for(Int i=0; i<uiTmp; i++) |
---|
646 | { |
---|
647 | m_pcTrCoeffY[i]=pcFrom->m_pcTrCoeffY[i]; |
---|
648 | #if ADAPTIVE_QP_SELECTION |
---|
649 | m_pcArlCoeffY[i]=pcFrom->m_pcArlCoeffY[i]; |
---|
650 | #endif |
---|
651 | m_pcIPCMSampleY[i]=pcFrom->m_pcIPCMSampleY[i]; |
---|
652 | } |
---|
653 | for(Int i=0; i<(uiTmp>>2); i++) |
---|
654 | { |
---|
655 | m_pcTrCoeffCb[i]=pcFrom->m_pcTrCoeffCb[i]; |
---|
656 | m_pcTrCoeffCr[i]=pcFrom->m_pcTrCoeffCr[i]; |
---|
657 | #if ADAPTIVE_QP_SELECTION |
---|
658 | m_pcArlCoeffCb[i]=pcFrom->m_pcArlCoeffCb[i]; |
---|
659 | m_pcArlCoeffCr[i]=pcFrom->m_pcArlCoeffCr[i]; |
---|
660 | #endif |
---|
661 | m_pcIPCMSampleCb[i]=pcFrom->m_pcIPCMSampleCb[i]; |
---|
662 | m_pcIPCMSampleCr[i]=pcFrom->m_pcIPCMSampleCr[i]; |
---|
663 | } |
---|
664 | } |
---|
665 | |
---|
666 | // Setting neighbor CU |
---|
667 | m_pcCULeft = NULL; |
---|
668 | m_pcCUAbove = NULL; |
---|
669 | m_pcCUAboveLeft = NULL; |
---|
670 | m_pcCUAboveRight = NULL; |
---|
671 | |
---|
672 | m_apcCUColocated[0] = NULL; |
---|
673 | m_apcCUColocated[1] = NULL; |
---|
674 | |
---|
675 | UInt uiWidthInCU = pcPic->getFrameWidthInCU(); |
---|
676 | if ( m_uiCUAddr % uiWidthInCU ) |
---|
677 | { |
---|
678 | m_pcCULeft = pcPic->getCU( m_uiCUAddr - 1 ); |
---|
679 | } |
---|
680 | |
---|
681 | if ( m_uiCUAddr / uiWidthInCU ) |
---|
682 | { |
---|
683 | m_pcCUAbove = pcPic->getCU( m_uiCUAddr - uiWidthInCU ); |
---|
684 | } |
---|
685 | |
---|
686 | if ( m_pcCULeft && m_pcCUAbove ) |
---|
687 | { |
---|
688 | m_pcCUAboveLeft = pcPic->getCU( m_uiCUAddr - uiWidthInCU - 1 ); |
---|
689 | } |
---|
690 | |
---|
691 | if ( m_pcCUAbove && ( (m_uiCUAddr%uiWidthInCU) < (uiWidthInCU-1) ) ) |
---|
692 | { |
---|
693 | m_pcCUAboveRight = pcPic->getCU( m_uiCUAddr - uiWidthInCU + 1 ); |
---|
694 | } |
---|
695 | |
---|
696 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) |
---|
697 | { |
---|
698 | m_apcCUColocated[0] = getSlice()->getRefPic( REF_PIC_LIST_0, 0)->getCU( m_uiCUAddr ); |
---|
699 | } |
---|
700 | |
---|
701 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) |
---|
702 | { |
---|
703 | m_apcCUColocated[1] = getSlice()->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr ); |
---|
704 | } |
---|
705 | } |
---|
706 | |
---|
707 | /** initialize prediction data with enabling sub-LCU-level delta QP |
---|
708 | *\param uiDepth depth of the current CU |
---|
709 | *\param qp qp for the current CU |
---|
710 | *- set CU width and CU height according to depth |
---|
711 | *- set qp value according to input qp |
---|
712 | *- set last-coded qp value according to input last-coded qp |
---|
713 | */ |
---|
714 | Void TComDataCU::initEstData( UInt uiDepth, Int qp, Bool bTransquantBypass ) |
---|
715 | { |
---|
716 | m_dTotalCost = MAX_DOUBLE; |
---|
717 | m_uiTotalDistortion = 0; |
---|
718 | m_uiTotalBits = 0; |
---|
719 | m_uiTotalBins = 0; |
---|
720 | |
---|
721 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
722 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
723 | |
---|
724 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
725 | { |
---|
726 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui >= getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
727 | { |
---|
728 | m_apiMVPIdx[0][ui] = -1; |
---|
729 | m_apiMVPIdx[1][ui] = -1; |
---|
730 | m_apiMVPNum[0][ui] = -1; |
---|
731 | m_apiMVPNum[1][ui] = -1; |
---|
732 | m_puhDepth [ui] = uiDepth; |
---|
733 | m_puhWidth [ui] = uhWidth; |
---|
734 | m_puhHeight [ui] = uhHeight; |
---|
735 | m_puhTrIdx [ui] = 0; |
---|
736 | m_puhTransformSkip[0][ui] = 0; |
---|
737 | m_puhTransformSkip[1][ui] = 0; |
---|
738 | m_puhTransformSkip[2][ui] = 0; |
---|
739 | m_skipFlag[ui] = false; |
---|
740 | m_pePartSize[ui] = SIZE_NONE; |
---|
741 | m_pePredMode[ui] = MODE_NONE; |
---|
742 | m_CUTransquantBypass[ui] = bTransquantBypass; |
---|
743 | m_pbIPCMFlag[ui] = 0; |
---|
744 | m_phQP[ui] = qp; |
---|
745 | m_pbMergeFlag[ui] = 0; |
---|
746 | m_puhMergeIndex[ui] = 0; |
---|
747 | #if H_3D_VSP |
---|
748 | m_piVSPFlag[ui] = 0; |
---|
749 | #endif |
---|
750 | #if H_3D_SPIVMP |
---|
751 | m_pbSPIVMPFlag[ui] = 0; |
---|
752 | #endif |
---|
753 | m_puhLumaIntraDir[ui] = DC_IDX; |
---|
754 | m_puhChromaIntraDir[ui] = 0; |
---|
755 | m_puhInterDir[ui] = 0; |
---|
756 | m_puhCbf[0][ui] = 0; |
---|
757 | m_puhCbf[1][ui] = 0; |
---|
758 | m_puhCbf[2][ui] = 0; |
---|
759 | #if H_3D_ARP |
---|
760 | m_puhARPW[ui] = 0; |
---|
761 | #endif |
---|
762 | #if H_3D_IC |
---|
763 | m_pbICFlag[ui] = false; |
---|
764 | #endif |
---|
765 | |
---|
766 | #if H_3D_DDD |
---|
767 | m_pucDisparityDerivedDepth[ui] = 0; |
---|
768 | m_pbUseDDD[ui] = 0; |
---|
769 | #endif |
---|
770 | |
---|
771 | #if H_3D_DIM |
---|
772 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
773 | { |
---|
774 | m_dimDeltaDC[i][0] [ui] = 0; |
---|
775 | m_dimDeltaDC[i][1] [ui] = 0; |
---|
776 | } |
---|
777 | #if H_3D_DIM_DMM |
---|
778 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
779 | { |
---|
780 | m_dmmWedgeTabIdx[i] [ui] = 0; |
---|
781 | } |
---|
782 | #endif |
---|
783 | #if H_3D_DIM_SDC |
---|
784 | m_pbSDCFlag [ui] = false; |
---|
785 | m_apSegmentDCOffset[0][ui] = 0; |
---|
786 | m_apSegmentDCOffset[1][ui] = 0; |
---|
787 | #endif |
---|
788 | m_apDmmPredictor[0] = 0; |
---|
789 | m_apDmmPredictor[1] = 0; |
---|
790 | #endif |
---|
791 | #if H_3D_DBBP |
---|
792 | m_pbDBBPFlag[ui] = false; |
---|
793 | #endif |
---|
794 | } |
---|
795 | } |
---|
796 | |
---|
797 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU >= getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
798 | { |
---|
799 | m_acCUMvField[0].clearMvField(); |
---|
800 | m_acCUMvField[1].clearMvField(); |
---|
801 | UInt uiTmp = uhWidth*uhHeight; |
---|
802 | |
---|
803 | memset( m_pcTrCoeffY, 0, uiTmp * sizeof( *m_pcTrCoeffY ) ); |
---|
804 | #if ADAPTIVE_QP_SELECTION |
---|
805 | memset( m_pcArlCoeffY , 0, uiTmp * sizeof( *m_pcArlCoeffY ) ); |
---|
806 | #endif |
---|
807 | memset( m_pcIPCMSampleY, 0, uiTmp * sizeof( *m_pcIPCMSampleY ) ); |
---|
808 | |
---|
809 | uiTmp>>=2; |
---|
810 | memset( m_pcTrCoeffCb, 0, uiTmp * sizeof( *m_pcTrCoeffCb ) ); |
---|
811 | memset( m_pcTrCoeffCr, 0, uiTmp * sizeof( *m_pcTrCoeffCr ) ); |
---|
812 | #if ADAPTIVE_QP_SELECTION |
---|
813 | memset( m_pcArlCoeffCb, 0, uiTmp * sizeof( *m_pcArlCoeffCb ) ); |
---|
814 | memset( m_pcArlCoeffCr, 0, uiTmp * sizeof( *m_pcArlCoeffCr ) ); |
---|
815 | #endif |
---|
816 | memset( m_pcIPCMSampleCb, 0, uiTmp * sizeof( *m_pcIPCMSampleCb ) ); |
---|
817 | memset( m_pcIPCMSampleCr, 0, uiTmp * sizeof( *m_pcIPCMSampleCr ) ); |
---|
818 | } |
---|
819 | } |
---|
820 | |
---|
821 | |
---|
822 | // initialize Sub partition |
---|
823 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ) |
---|
824 | { |
---|
825 | assert( uiPartUnitIdx<4 ); |
---|
826 | |
---|
827 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
---|
828 | |
---|
829 | m_pcPic = pcCU->getPic(); |
---|
830 | m_pcSlice = m_pcPic->getSlice(m_pcPic->getCurrSliceIdx()); |
---|
831 | m_uiCUAddr = pcCU->getAddr(); |
---|
832 | m_uiAbsIdxInLCU = pcCU->getZorderIdxInCU() + uiPartOffset; |
---|
833 | |
---|
834 | m_uiCUPelX = pcCU->getCUPelX() + ( g_uiMaxCUWidth>>uiDepth )*( uiPartUnitIdx & 1 ); |
---|
835 | m_uiCUPelY = pcCU->getCUPelY() + ( g_uiMaxCUHeight>>uiDepth )*( uiPartUnitIdx >> 1 ); |
---|
836 | |
---|
837 | m_dTotalCost = MAX_DOUBLE; |
---|
838 | m_uiTotalDistortion = 0; |
---|
839 | m_uiTotalBits = 0; |
---|
840 | m_uiTotalBins = 0; |
---|
841 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
---|
842 | |
---|
843 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
844 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
845 | |
---|
846 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
847 | memset( m_phQP, qp, sizeInChar ); |
---|
848 | |
---|
849 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
850 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
851 | #if H_3D_VSP |
---|
852 | memset( m_piVSPFlag, 0, sizeof( Char ) * m_uiNumPartition ); |
---|
853 | #endif |
---|
854 | #if H_3D_SPIVMP |
---|
855 | memset( m_pbSPIVMPFlag, 0, sizeof( Bool ) * m_uiNumPartition ); |
---|
856 | #endif |
---|
857 | memset( m_puhLumaIntraDir, DC_IDX, iSizeInUchar ); |
---|
858 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
---|
859 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
860 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
861 | memset( m_puhTransformSkip[0], 0, iSizeInUchar ); |
---|
862 | memset( m_puhTransformSkip[1], 0, iSizeInUchar ); |
---|
863 | memset( m_puhTransformSkip[2], 0, iSizeInUchar ); |
---|
864 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
---|
865 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
---|
866 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
---|
867 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
---|
868 | #if H_3D_NBDV |
---|
869 | m_pDvInfo->bDV = false; |
---|
870 | #endif |
---|
871 | #if H_3D_ARP |
---|
872 | memset( m_puhARPW, 0, iSizeInUchar ); |
---|
873 | #endif |
---|
874 | |
---|
875 | #if H_3D_DDD |
---|
876 | memset( m_pucDisparityDerivedDepth, 0, iSizeInUchar ); |
---|
877 | memset( m_pbUseDDD, 0, iSizeInBool ); |
---|
878 | #endif |
---|
879 | |
---|
880 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
881 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
882 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
883 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
884 | memset( m_pbIPCMFlag, 0, iSizeInBool ); |
---|
885 | #if H_3D_IC |
---|
886 | memset( m_pbICFlag, 0, iSizeInBool ); |
---|
887 | #endif |
---|
888 | #if H_3D_DIM |
---|
889 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
890 | { |
---|
891 | memset( m_dimDeltaDC[i][0], 0, sizeof(Pel ) * m_uiNumPartition ); |
---|
892 | memset( m_dimDeltaDC[i][1], 0, sizeof(Pel ) * m_uiNumPartition ); |
---|
893 | } |
---|
894 | #if H_3D_DIM_DMM |
---|
895 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
896 | { |
---|
897 | memset( m_dmmWedgeTabIdx[i], 0, sizeof(UInt) * m_uiNumPartition ); |
---|
898 | } |
---|
899 | #endif |
---|
900 | #if H_3D_DIM_SDC |
---|
901 | memset( m_pbSDCFlag, 0, sizeof(Bool) * m_uiNumPartition ); |
---|
902 | memset( m_apSegmentDCOffset[0], 0, sizeof(Pel) * m_uiNumPartition ); |
---|
903 | memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition ); |
---|
904 | #endif |
---|
905 | m_apDmmPredictor[0] = 0; |
---|
906 | m_apDmmPredictor[1] = 0; |
---|
907 | #endif |
---|
908 | #if H_3D_DBBP |
---|
909 | memset( m_pbDBBPFlag, 0, iSizeInBool ); |
---|
910 | #endif |
---|
911 | |
---|
912 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
913 | { |
---|
914 | m_skipFlag[ui] = false; |
---|
915 | m_pePartSize[ui] = SIZE_NONE; |
---|
916 | m_pePredMode[ui] = MODE_NONE; |
---|
917 | m_CUTransquantBypass[ui] = false; |
---|
918 | m_apiMVPIdx[0][ui] = -1; |
---|
919 | m_apiMVPIdx[1][ui] = -1; |
---|
920 | m_apiMVPNum[0][ui] = -1; |
---|
921 | m_apiMVPNum[1][ui] = -1; |
---|
922 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui<getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
923 | { |
---|
924 | m_apiMVPIdx[0][ui] = pcCU->m_apiMVPIdx[0][uiPartOffset+ui]; |
---|
925 | m_apiMVPIdx[1][ui] = pcCU->m_apiMVPIdx[1][uiPartOffset+ui];; |
---|
926 | m_apiMVPNum[0][ui] = pcCU->m_apiMVPNum[0][uiPartOffset+ui];; |
---|
927 | m_apiMVPNum[1][ui] = pcCU->m_apiMVPNum[1][uiPartOffset+ui];; |
---|
928 | m_puhDepth [ui] = pcCU->getDepth(uiPartOffset+ui); |
---|
929 | m_puhWidth [ui] = pcCU->getWidth(uiPartOffset+ui); |
---|
930 | m_puhHeight [ui] = pcCU->getHeight(uiPartOffset+ui); |
---|
931 | m_puhTrIdx [ui] = pcCU->getTransformIdx(uiPartOffset+ui); |
---|
932 | m_puhTransformSkip[0][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_LUMA); |
---|
933 | m_puhTransformSkip[1][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_U); |
---|
934 | m_puhTransformSkip[2][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_V); |
---|
935 | m_skipFlag[ui] = pcCU->getSkipFlag(uiPartOffset+ui); |
---|
936 | m_pePartSize[ui] = pcCU->getPartitionSize(uiPartOffset+ui); |
---|
937 | m_pePredMode[ui] = pcCU->getPredictionMode(uiPartOffset+ui); |
---|
938 | m_CUTransquantBypass[ui] = pcCU->getCUTransquantBypass(uiPartOffset+ui); |
---|
939 | m_pbIPCMFlag[ui]=pcCU->m_pbIPCMFlag[uiPartOffset+ui]; |
---|
940 | m_phQP[ui] = pcCU->m_phQP[uiPartOffset+ui]; |
---|
941 | m_pbMergeFlag[ui]=pcCU->m_pbMergeFlag[uiPartOffset+ui]; |
---|
942 | m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui]; |
---|
943 | #if H_3D_VSP |
---|
944 | m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui]; |
---|
945 | m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui]; |
---|
946 | #endif |
---|
947 | #if H_3D_SPIVMP |
---|
948 | m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui]; |
---|
949 | #endif |
---|
950 | m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui]; |
---|
951 | m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui]; |
---|
952 | m_puhInterDir[ui]=pcCU->m_puhInterDir[uiPartOffset+ui]; |
---|
953 | m_puhCbf[0][ui]=pcCU->m_puhCbf[0][uiPartOffset+ui]; |
---|
954 | m_puhCbf[1][ui]=pcCU->m_puhCbf[1][uiPartOffset+ui]; |
---|
955 | m_puhCbf[2][ui]=pcCU->m_puhCbf[2][uiPartOffset+ui]; |
---|
956 | |
---|
957 | #if H_3D_ARP |
---|
958 | m_puhARPW [ui] = pcCU->getARPW( uiPartOffset+ui ); |
---|
959 | #endif |
---|
960 | #if H_3D_IC |
---|
961 | m_pbICFlag [ui] = pcCU->m_pbICFlag[uiPartOffset+ui]; |
---|
962 | #endif |
---|
963 | |
---|
964 | #if H_3D_DDD |
---|
965 | m_pucDisparityDerivedDepth[ui] = pcCU->m_pucDisparityDerivedDepth[uiPartOffset+ui]; |
---|
966 | m_pbUseDDD[ui] = pcCU->m_pbUseDDD[uiPartOffset+ui]; |
---|
967 | #endif |
---|
968 | |
---|
969 | #if H_3D_DIM |
---|
970 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
971 | { |
---|
972 | m_dimDeltaDC[i][0] [ui] = pcCU->m_dimDeltaDC[i][0] [uiPartOffset+ui]; |
---|
973 | m_dimDeltaDC[i][1] [ui] = pcCU->m_dimDeltaDC[i][1] [uiPartOffset+ui]; |
---|
974 | } |
---|
975 | #if H_3D_DIM_DMM |
---|
976 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
977 | { |
---|
978 | m_dmmWedgeTabIdx[i] [ui] = pcCU->m_dmmWedgeTabIdx[i] [uiPartOffset+ui]; |
---|
979 | } |
---|
980 | #endif |
---|
981 | #if H_3D_DIM_SDC |
---|
982 | m_pbSDCFlag [ui] = pcCU->m_pbSDCFlag [ uiPartOffset + ui ]; |
---|
983 | m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0] [ uiPartOffset + ui ]; |
---|
984 | m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ]; |
---|
985 | #endif |
---|
986 | #endif |
---|
987 | #if H_3D_DBBP |
---|
988 | m_pbDBBPFlag[ui]=pcCU->m_pbDBBPFlag[uiPartOffset+ui]; |
---|
989 | #endif |
---|
990 | } |
---|
991 | } |
---|
992 | UInt uiTmp = uhWidth*uhHeight; |
---|
993 | memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); |
---|
994 | #if ADAPTIVE_QP_SELECTION |
---|
995 | memset( m_pcArlCoeffY , 0, sizeof(Int)*uiTmp ); |
---|
996 | #endif |
---|
997 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
---|
998 | uiTmp >>= 2; |
---|
999 | memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); |
---|
1000 | memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); |
---|
1001 | #if ADAPTIVE_QP_SELECTION |
---|
1002 | memset( m_pcArlCoeffCb, 0, sizeof(Int)*uiTmp ); |
---|
1003 | memset( m_pcArlCoeffCr, 0, sizeof(Int)*uiTmp ); |
---|
1004 | #endif |
---|
1005 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
---|
1006 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
---|
1007 | m_acCUMvField[0].clearMvField(); |
---|
1008 | m_acCUMvField[1].clearMvField(); |
---|
1009 | |
---|
1010 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU<getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
1011 | { |
---|
1012 | // Part of this CU contains data from an older slice. Now copy in that data. |
---|
1013 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1014 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1015 | TComDataCU * bigCU = getPic()->getCU(getAddr()); |
---|
1016 | Int minui = uiPartOffset; |
---|
1017 | minui = -minui; |
---|
1018 | pcCU->m_acCUMvField[0].copyTo(&m_acCUMvField[0],minui,uiPartOffset,m_uiNumPartition); |
---|
1019 | pcCU->m_acCUMvField[1].copyTo(&m_acCUMvField[1],minui,uiPartOffset,m_uiNumPartition); |
---|
1020 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*m_uiAbsIdxInLCU/pcCU->getPic()->getNumPartInCU(); |
---|
1021 | uiTmp = uhWidth*uhHeight; |
---|
1022 | for(Int i=0; i<uiTmp; i++) |
---|
1023 | { |
---|
1024 | m_pcTrCoeffY[i]=bigCU->m_pcTrCoeffY[uiCoffOffset+i]; |
---|
1025 | #if ADAPTIVE_QP_SELECTION |
---|
1026 | m_pcArlCoeffY[i]=bigCU->m_pcArlCoeffY[uiCoffOffset+i]; |
---|
1027 | #endif |
---|
1028 | m_pcIPCMSampleY[i]=bigCU->m_pcIPCMSampleY[uiCoffOffset+i]; |
---|
1029 | } |
---|
1030 | uiTmp>>=2; |
---|
1031 | uiCoffOffset>>=2; |
---|
1032 | for(Int i=0; i<uiTmp; i++) |
---|
1033 | { |
---|
1034 | m_pcTrCoeffCr[i]=bigCU->m_pcTrCoeffCr[uiCoffOffset+i]; |
---|
1035 | m_pcTrCoeffCb[i]=bigCU->m_pcTrCoeffCb[uiCoffOffset+i]; |
---|
1036 | #if ADAPTIVE_QP_SELECTION |
---|
1037 | m_pcArlCoeffCr[i]=bigCU->m_pcArlCoeffCr[uiCoffOffset+i]; |
---|
1038 | m_pcArlCoeffCb[i]=bigCU->m_pcArlCoeffCb[uiCoffOffset+i]; |
---|
1039 | #endif |
---|
1040 | m_pcIPCMSampleCb[i]=bigCU->m_pcIPCMSampleCb[uiCoffOffset+i]; |
---|
1041 | m_pcIPCMSampleCr[i]=bigCU->m_pcIPCMSampleCr[uiCoffOffset+i]; |
---|
1042 | } |
---|
1043 | } |
---|
1044 | |
---|
1045 | m_pcCULeft = pcCU->getCULeft(); |
---|
1046 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
1047 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
1048 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
1049 | |
---|
1050 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
1051 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
1052 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
---|
1053 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
---|
1054 | } |
---|
1055 | |
---|
1056 | Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1057 | { |
---|
1058 | UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); |
---|
1059 | UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
1060 | |
---|
1061 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
1062 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
1063 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); |
---|
1064 | memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); |
---|
1065 | memset( m_puhHeight + uiAbsPartIdx, uhHeight, uiSizeInUchar ); |
---|
1066 | } |
---|
1067 | |
---|
1068 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1069 | // Copy |
---|
1070 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1071 | |
---|
1072 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1073 | { |
---|
1074 | UInt uiPart = uiAbsPartIdx; |
---|
1075 | |
---|
1076 | m_pcPic = pcCU->getPic(); |
---|
1077 | m_pcSlice = pcCU->getSlice(); |
---|
1078 | m_uiCUAddr = pcCU->getAddr(); |
---|
1079 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
1080 | |
---|
1081 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1082 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1083 | |
---|
1084 | m_skipFlag=pcCU->getSkipFlag() + uiPart; |
---|
1085 | |
---|
1086 | m_phQP=pcCU->getQP() + uiPart; |
---|
1087 | m_pePartSize = pcCU->getPartitionSize() + uiPart; |
---|
1088 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
---|
1089 | m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; |
---|
1090 | |
---|
1091 | #if H_3D_NBDV |
---|
1092 | m_pDvInfo = pcCU->getDvInfo() + uiPart; |
---|
1093 | #endif |
---|
1094 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
---|
1095 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
---|
1096 | #if H_3D_VSP |
---|
1097 | m_piVSPFlag = pcCU->getVSPFlag() + uiPart; |
---|
1098 | #endif |
---|
1099 | #if H_3D_SPIVMP |
---|
1100 | m_pbSPIVMPFlag = pcCU->getSPIVMPFlag() + uiPart; |
---|
1101 | #endif |
---|
1102 | |
---|
1103 | #if H_3D_ARP |
---|
1104 | m_puhARPW = pcCU->getARPW() + uiPart; |
---|
1105 | #endif |
---|
1106 | #if H_3D_IC |
---|
1107 | m_pbICFlag = pcCU->getICFlag() + uiPart; |
---|
1108 | #endif |
---|
1109 | |
---|
1110 | #if H_3D_DDD |
---|
1111 | m_pucDisparityDerivedDepth = pcCU->getDDDepth() + uiPart; |
---|
1112 | m_pbUseDDD = pcCU->getUseDDD() + uiPart; |
---|
1113 | #endif |
---|
1114 | |
---|
1115 | m_puhLumaIntraDir = pcCU->getLumaIntraDir() + uiPart; |
---|
1116 | m_puhChromaIntraDir = pcCU->getChromaIntraDir() + uiPart; |
---|
1117 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
---|
1118 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
---|
1119 | m_puhTransformSkip[0] = pcCU->getTransformSkip(TEXT_LUMA) + uiPart; |
---|
1120 | m_puhTransformSkip[1] = pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPart; |
---|
1121 | m_puhTransformSkip[2] = pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPart; |
---|
1122 | |
---|
1123 | m_puhCbf[0]= pcCU->getCbf(TEXT_LUMA) + uiPart; |
---|
1124 | m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U) + uiPart; |
---|
1125 | m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; |
---|
1126 | #if H_3D_DIM |
---|
1127 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
1128 | { |
---|
1129 | m_dimDeltaDC[i][0] = pcCU->getDimDeltaDC( i, 0 ) + uiPart; |
---|
1130 | m_dimDeltaDC[i][1] = pcCU->getDimDeltaDC( i, 1 ) + uiPart; |
---|
1131 | } |
---|
1132 | #if H_3D_DIM_DMM |
---|
1133 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1134 | { |
---|
1135 | m_dmmWedgeTabIdx[i] = pcCU->getDmmWedgeTabIdx( i ) + uiPart; |
---|
1136 | } |
---|
1137 | #endif |
---|
1138 | #if H_3D_DIM_SDC |
---|
1139 | m_pbSDCFlag = pcCU->getSDCFlag() + uiPart; |
---|
1140 | m_apSegmentDCOffset[0] = pcCU->getSDCSegmentDCOffset(0) + uiPart; |
---|
1141 | m_apSegmentDCOffset[1] = pcCU->getSDCSegmentDCOffset(1) + uiPart; |
---|
1142 | #endif |
---|
1143 | #endif |
---|
1144 | #if H_3D_DBBP |
---|
1145 | m_pbDBBPFlag = pcCU->getDBBPFlag() + uiPart; |
---|
1146 | #endif |
---|
1147 | m_puhDepth=pcCU->getDepth() + uiPart; |
---|
1148 | m_puhWidth=pcCU->getWidth() + uiPart; |
---|
1149 | m_puhHeight=pcCU->getHeight() + uiPart; |
---|
1150 | |
---|
1151 | m_apiMVPIdx[0]=pcCU->getMVPIdx(REF_PIC_LIST_0) + uiPart; |
---|
1152 | m_apiMVPIdx[1]=pcCU->getMVPIdx(REF_PIC_LIST_1) + uiPart; |
---|
1153 | m_apiMVPNum[0]=pcCU->getMVPNum(REF_PIC_LIST_0) + uiPart; |
---|
1154 | m_apiMVPNum[1]=pcCU->getMVPNum(REF_PIC_LIST_1) + uiPart; |
---|
1155 | |
---|
1156 | m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; |
---|
1157 | |
---|
1158 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
1159 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
1160 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
1161 | m_pcCULeft = pcCU->getCULeft(); |
---|
1162 | |
---|
1163 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
1164 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
1165 | |
---|
1166 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1167 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1168 | |
---|
1169 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartInCU(); |
---|
1170 | |
---|
1171 | m_pcTrCoeffY = pcCU->getCoeffY() + uiCoffOffset; |
---|
1172 | #if ADAPTIVE_QP_SELECTION |
---|
1173 | m_pcArlCoeffY= pcCU->getArlCoeffY() + uiCoffOffset; |
---|
1174 | #endif |
---|
1175 | m_pcIPCMSampleY = pcCU->getPCMSampleY() + uiCoffOffset; |
---|
1176 | |
---|
1177 | uiCoffOffset >>=2; |
---|
1178 | m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset; |
---|
1179 | m_pcTrCoeffCr=pcCU->getCoeffCr() + uiCoffOffset; |
---|
1180 | #if ADAPTIVE_QP_SELECTION |
---|
1181 | m_pcArlCoeffCb=pcCU->getArlCoeffCb() + uiCoffOffset; |
---|
1182 | m_pcArlCoeffCr=pcCU->getArlCoeffCr() + uiCoffOffset; |
---|
1183 | #endif |
---|
1184 | m_pcIPCMSampleCb = pcCU->getPCMSampleCb() + uiCoffOffset; |
---|
1185 | m_pcIPCMSampleCr = pcCU->getPCMSampleCr() + uiCoffOffset; |
---|
1186 | |
---|
1187 | m_acCUMvField[0].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_0), uiPart ); |
---|
1188 | m_acCUMvField[1].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_1), uiPart ); |
---|
1189 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
---|
1190 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
---|
1191 | } |
---|
1192 | #if H_3D_NBDV |
---|
1193 | Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx) |
---|
1194 | { |
---|
1195 | m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; |
---|
1196 | } |
---|
1197 | #endif |
---|
1198 | // Copy inter prediction info from the biggest CU |
---|
1199 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList |
---|
1200 | #if H_3D_NBDV |
---|
1201 | , Bool bNBDV |
---|
1202 | #endif |
---|
1203 | ) |
---|
1204 | { |
---|
1205 | m_pcPic = pcCU->getPic(); |
---|
1206 | m_pcSlice = pcCU->getSlice(); |
---|
1207 | m_uiCUAddr = pcCU->getAddr(); |
---|
1208 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
1209 | |
---|
1210 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
1211 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() ); |
---|
1212 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInWidth() ); |
---|
1213 | |
---|
1214 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
1215 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
1216 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
1217 | m_pcCULeft = pcCU->getCULeft(); |
---|
1218 | |
---|
1219 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
1220 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
1221 | |
---|
1222 | m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; |
---|
1223 | |
---|
1224 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
---|
1225 | #if H_3D_NBDV |
---|
1226 | if(bNBDV == true) |
---|
1227 | { |
---|
1228 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
1229 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
1230 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
1231 | } |
---|
1232 | else |
---|
1233 | { |
---|
1234 | #endif |
---|
1235 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
---|
1236 | m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; |
---|
1237 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
---|
1238 | |
---|
1239 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
1240 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
1241 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
1242 | |
---|
1243 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
1244 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
1245 | #if H_3D_VSP |
---|
1246 | m_piVSPFlag = pcCU->getVSPFlag() + uiAbsPartIdx; |
---|
1247 | m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; |
---|
1248 | #endif |
---|
1249 | #if H_3D_SPIVMP |
---|
1250 | m_pbSPIVMPFlag = pcCU->getSPIVMPFlag() + uiAbsPartIdx; |
---|
1251 | #endif |
---|
1252 | |
---|
1253 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
---|
1254 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
---|
1255 | |
---|
1256 | #if H_3D_ARP |
---|
1257 | m_puhARPW = pcCU->getARPW() + uiAbsPartIdx; |
---|
1258 | #endif |
---|
1259 | |
---|
1260 | #if H_3D_DDD |
---|
1261 | m_pucDisparityDerivedDepth = pcCU->getDDDepth() + uiAbsPartIdx; |
---|
1262 | m_pbUseDDD = pcCU->getUseDDD() + uiAbsPartIdx; |
---|
1263 | #endif |
---|
1264 | |
---|
1265 | #if H_3D_DBBP |
---|
1266 | m_pbDBBPFlag = pcCU->getDBBPFlag() + uiAbsPartIdx; |
---|
1267 | #endif |
---|
1268 | |
---|
1269 | m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); |
---|
1270 | |
---|
1271 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
---|
1272 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
---|
1273 | #if H_3D_NBDV |
---|
1274 | } |
---|
1275 | #endif |
---|
1276 | #if H_3D_IC |
---|
1277 | m_pbICFlag = pcCU->getICFlag() + uiAbsPartIdx; |
---|
1278 | #endif |
---|
1279 | } |
---|
1280 | |
---|
1281 | // Copy small CU to bigger CU. |
---|
1282 | // One of quarter parts overwritten by predicted sub part. |
---|
1283 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
1284 | { |
---|
1285 | assert( uiPartUnitIdx<4 ); |
---|
1286 | |
---|
1287 | m_dTotalCost += pcCU->getTotalCost(); |
---|
1288 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
---|
1289 | m_uiTotalBits += pcCU->getTotalBits(); |
---|
1290 | |
---|
1291 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
---|
1292 | |
---|
1293 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
---|
1294 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
1295 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
1296 | |
---|
1297 | Int sizeInChar = sizeof( Char ) * uiNumPartition; |
---|
1298 | memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); |
---|
1299 | memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); |
---|
1300 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); |
---|
1301 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); |
---|
1302 | memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); |
---|
1303 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
---|
1304 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
---|
1305 | #if H_3D_VSP |
---|
1306 | memcpy( m_piVSPFlag + uiOffset, pcCU->getVSPFlag(), sizeof( Char ) * uiNumPartition ); |
---|
1307 | memcpy( m_pDvInfo + uiOffset, pcCU->getDvInfo(), sizeof( *m_pDvInfo ) * uiNumPartition ); |
---|
1308 | |
---|
1309 | #endif |
---|
1310 | #if H_3D_SPIVMP |
---|
1311 | memcpy( m_pbSPIVMPFlag + uiOffset, pcCU->getSPIVMPFlag(), sizeof( Bool ) * uiNumPartition ); |
---|
1312 | #endif |
---|
1313 | memcpy( m_puhLumaIntraDir + uiOffset, pcCU->getLumaIntraDir(), iSizeInUchar ); |
---|
1314 | memcpy( m_puhChromaIntraDir + uiOffset, pcCU->getChromaIntraDir(), iSizeInUchar ); |
---|
1315 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
---|
1316 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
---|
1317 | memcpy( m_puhTransformSkip[0] + uiOffset, pcCU->getTransformSkip(TEXT_LUMA), iSizeInUchar ); |
---|
1318 | memcpy( m_puhTransformSkip[1] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_U), iSizeInUchar ); |
---|
1319 | memcpy( m_puhTransformSkip[2] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_V), iSizeInUchar ); |
---|
1320 | |
---|
1321 | memcpy( m_puhCbf[0] + uiOffset, pcCU->getCbf(TEXT_LUMA) , iSizeInUchar ); |
---|
1322 | memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar ); |
---|
1323 | memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); |
---|
1324 | |
---|
1325 | #if H_3D_DDD |
---|
1326 | memcpy( m_pucDisparityDerivedDepth + uiOffset, pcCU->getDDDepth(), iSizeInUchar ); |
---|
1327 | memcpy( m_pbUseDDD + uiOffset, pcCU->getUseDDD(), iSizeInBool ); |
---|
1328 | #endif |
---|
1329 | |
---|
1330 | |
---|
1331 | #if H_3D_DIM |
---|
1332 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
1333 | { |
---|
1334 | memcpy( m_dimDeltaDC[i][0] + uiOffset, pcCU->getDimDeltaDC( i, 0 ), sizeof(Pel ) * uiNumPartition ); |
---|
1335 | memcpy( m_dimDeltaDC[i][1] + uiOffset, pcCU->getDimDeltaDC( i, 1 ), sizeof(Pel ) * uiNumPartition ); |
---|
1336 | } |
---|
1337 | #if H_3D_DIM_DMM |
---|
1338 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1339 | { |
---|
1340 | memcpy( m_dmmWedgeTabIdx[i] + uiOffset, pcCU->getDmmWedgeTabIdx( i ), sizeof(UInt) * uiNumPartition ); |
---|
1341 | } |
---|
1342 | #endif |
---|
1343 | #if H_3D_DIM_SDC |
---|
1344 | memcpy( m_pbSDCFlag + uiOffset, pcCU->getSDCFlag(), iSizeInBool ); |
---|
1345 | memcpy( m_apSegmentDCOffset[0] + uiOffset, pcCU->getSDCSegmentDCOffset(0), sizeof( Pel ) * uiNumPartition); |
---|
1346 | memcpy( m_apSegmentDCOffset[1] + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition); |
---|
1347 | #endif |
---|
1348 | #endif |
---|
1349 | #if H_3D_DBBP |
---|
1350 | memcpy( m_pbDBBPFlag + uiOffset, pcCU->getDBBPFlag(), iSizeInBool ); |
---|
1351 | #endif |
---|
1352 | |
---|
1353 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
---|
1354 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
---|
1355 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
---|
1356 | |
---|
1357 | memcpy( m_apiMVPIdx[0] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_0), iSizeInUchar ); |
---|
1358 | memcpy( m_apiMVPIdx[1] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_1), iSizeInUchar ); |
---|
1359 | memcpy( m_apiMVPNum[0] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_0), iSizeInUchar ); |
---|
1360 | memcpy( m_apiMVPNum[1] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_1), iSizeInUchar ); |
---|
1361 | |
---|
1362 | memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); |
---|
1363 | |
---|
1364 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
1365 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
1366 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
1367 | m_pcCULeft = pcCU->getCULeft(); |
---|
1368 | |
---|
1369 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
1370 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
1371 | |
---|
1372 | m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
1373 | m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
1374 | |
---|
1375 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); |
---|
1376 | UInt uiTmp2 = uiPartUnitIdx*uiTmp; |
---|
1377 | memcpy( m_pcTrCoeffY + uiTmp2, pcCU->getCoeffY(), sizeof(TCoeff)*uiTmp ); |
---|
1378 | #if ADAPTIVE_QP_SELECTION |
---|
1379 | memcpy( m_pcArlCoeffY + uiTmp2, pcCU->getArlCoeffY(), sizeof(Int)*uiTmp ); |
---|
1380 | #endif |
---|
1381 | memcpy( m_pcIPCMSampleY + uiTmp2 , pcCU->getPCMSampleY(), sizeof(Pel) * uiTmp ); |
---|
1382 | |
---|
1383 | uiTmp >>= 2; uiTmp2>>= 2; |
---|
1384 | memcpy( m_pcTrCoeffCb + uiTmp2, pcCU->getCoeffCb(), sizeof(TCoeff)*uiTmp ); |
---|
1385 | memcpy( m_pcTrCoeffCr + uiTmp2, pcCU->getCoeffCr(), sizeof(TCoeff)*uiTmp ); |
---|
1386 | #if ADAPTIVE_QP_SELECTION |
---|
1387 | memcpy( m_pcArlCoeffCb + uiTmp2, pcCU->getArlCoeffCb(), sizeof(Int)*uiTmp ); |
---|
1388 | memcpy( m_pcArlCoeffCr + uiTmp2, pcCU->getArlCoeffCr(), sizeof(Int)*uiTmp ); |
---|
1389 | #endif |
---|
1390 | memcpy( m_pcIPCMSampleCb + uiTmp2 , pcCU->getPCMSampleCb(), sizeof(Pel) * uiTmp ); |
---|
1391 | memcpy( m_pcIPCMSampleCr + uiTmp2 , pcCU->getPCMSampleCr(), sizeof(Pel) * uiTmp ); |
---|
1392 | m_uiTotalBins += pcCU->getTotalBins(); |
---|
1393 | memcpy( m_sliceStartCU + uiOffset, pcCU->m_sliceStartCU, sizeof( UInt ) * uiNumPartition ); |
---|
1394 | memcpy( m_sliceSegmentStartCU + uiOffset, pcCU->m_sliceSegmentStartCU, sizeof( UInt ) * uiNumPartition ); |
---|
1395 | #if H_3D_ARP |
---|
1396 | memcpy( m_puhARPW + uiOffset, pcCU->getARPW(), iSizeInUchar ); |
---|
1397 | #endif |
---|
1398 | #if H_3D_IC |
---|
1399 | memcpy( m_pbICFlag + uiOffset, pcCU->getICFlag(), iSizeInBool ); |
---|
1400 | #endif |
---|
1401 | } |
---|
1402 | |
---|
1403 | // Copy current predicted part to a CU in picture. |
---|
1404 | // It is used to predict for next part |
---|
1405 | Void TComDataCU::copyToPic( UChar uhDepth ) |
---|
1406 | { |
---|
1407 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
1408 | |
---|
1409 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
1410 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
1411 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
1412 | |
---|
1413 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
1414 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
1415 | |
---|
1416 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
1417 | |
---|
1418 | memcpy( rpcCU->getSkipFlag() + m_uiAbsIdxInLCU, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); |
---|
1419 | |
---|
1420 | memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, sizeInChar ); |
---|
1421 | #if H_3D_NBDV |
---|
1422 | memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition ); |
---|
1423 | #endif |
---|
1424 | |
---|
1425 | #if H_3D_DDD |
---|
1426 | memcpy( rpcCU->getDDDepth() + m_uiAbsIdxInLCU, m_pucDisparityDerivedDepth, iSizeInUchar ); |
---|
1427 | memcpy( rpcCU->getUseDDD() + m_uiAbsIdxInLCU, m_pbUseDDD, iSizeInBool ); |
---|
1428 | #endif |
---|
1429 | |
---|
1430 | memcpy( rpcCU->getPartitionSize() + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); |
---|
1431 | memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); |
---|
1432 | memcpy( rpcCU->getCUTransquantBypass()+ m_uiAbsIdxInLCU, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); |
---|
1433 | memcpy( rpcCU->getMergeFlag() + m_uiAbsIdxInLCU, m_pbMergeFlag, iSizeInBool ); |
---|
1434 | memcpy( rpcCU->getMergeIndex() + m_uiAbsIdxInLCU, m_puhMergeIndex, iSizeInUchar ); |
---|
1435 | #if H_3D_VSP |
---|
1436 | memcpy( rpcCU->getVSPFlag() + m_uiAbsIdxInLCU, m_piVSPFlag, sizeof( Char ) * m_uiNumPartition ); |
---|
1437 | memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof( *m_pDvInfo ) * m_uiNumPartition ); |
---|
1438 | #endif |
---|
1439 | #if H_3D_SPIVMP |
---|
1440 | memcpy( rpcCU->getSPIVMPFlag() + m_uiAbsIdxInLCU, m_pbSPIVMPFlag, sizeof( Bool ) * m_uiNumPartition ); |
---|
1441 | #endif |
---|
1442 | memcpy( rpcCU->getLumaIntraDir() + m_uiAbsIdxInLCU, m_puhLumaIntraDir, iSizeInUchar ); |
---|
1443 | memcpy( rpcCU->getChromaIntraDir() + m_uiAbsIdxInLCU, m_puhChromaIntraDir, iSizeInUchar ); |
---|
1444 | memcpy( rpcCU->getInterDir() + m_uiAbsIdxInLCU, m_puhInterDir, iSizeInUchar ); |
---|
1445 | memcpy( rpcCU->getTransformIdx() + m_uiAbsIdxInLCU, m_puhTrIdx, iSizeInUchar ); |
---|
1446 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhTransformSkip[0], iSizeInUchar ); |
---|
1447 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhTransformSkip[1], iSizeInUchar ); |
---|
1448 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhTransformSkip[2], iSizeInUchar ); |
---|
1449 | |
---|
1450 | memcpy( rpcCU->getCbf(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhCbf[0], iSizeInUchar ); |
---|
1451 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhCbf[1], iSizeInUchar ); |
---|
1452 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); |
---|
1453 | |
---|
1454 | #if H_3D_DIM |
---|
1455 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
---|
1456 | { |
---|
1457 | memcpy( rpcCU->getDimDeltaDC( i, 0 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][0], sizeof(Pel ) * m_uiNumPartition ); |
---|
1458 | memcpy( rpcCU->getDimDeltaDC( i, 1 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][1], sizeof(Pel ) * m_uiNumPartition ); |
---|
1459 | } |
---|
1460 | #if H_3D_DIM_DMM |
---|
1461 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1462 | { |
---|
1463 | memcpy( rpcCU->getDmmWedgeTabIdx( i ) + m_uiAbsIdxInLCU, m_dmmWedgeTabIdx[i], sizeof(UInt) * m_uiNumPartition ); |
---|
1464 | } |
---|
1465 | #endif |
---|
1466 | #if H_3D_DIM_SDC |
---|
1467 | memcpy( rpcCU->getSDCFlag() + m_uiAbsIdxInLCU, m_pbSDCFlag, iSizeInBool ); |
---|
1468 | memcpy( rpcCU->getSDCSegmentDCOffset(0) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[0], sizeof( Pel ) * m_uiNumPartition); |
---|
1469 | memcpy( rpcCU->getSDCSegmentDCOffset(1) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition); |
---|
1470 | #endif |
---|
1471 | #endif |
---|
1472 | #if H_3D_DBBP |
---|
1473 | memcpy( rpcCU->getDBBPFlag() + m_uiAbsIdxInLCU, m_pbDBBPFlag, iSizeInBool ); |
---|
1474 | #endif |
---|
1475 | |
---|
1476 | memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); |
---|
1477 | memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); |
---|
1478 | memcpy( rpcCU->getHeight() + m_uiAbsIdxInLCU, m_puhHeight, iSizeInUchar ); |
---|
1479 | |
---|
1480 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPIdx[0], iSizeInUchar ); |
---|
1481 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPIdx[1], iSizeInUchar ); |
---|
1482 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPNum[0], iSizeInUchar ); |
---|
1483 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPNum[1], iSizeInUchar ); |
---|
1484 | |
---|
1485 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU ); |
---|
1486 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU ); |
---|
1487 | |
---|
1488 | memcpy( rpcCU->getIPCMFlag() + m_uiAbsIdxInLCU, m_pbIPCMFlag, iSizeInBool ); |
---|
1489 | |
---|
1490 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); |
---|
1491 | UInt uiTmp2 = m_uiAbsIdxInLCU*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
1492 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
1493 | #if ADAPTIVE_QP_SELECTION |
---|
1494 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
---|
1495 | #endif |
---|
1496 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof(Pel)*uiTmp ); |
---|
1497 | |
---|
1498 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
1499 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
1500 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
1501 | #if ADAPTIVE_QP_SELECTION |
---|
1502 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
---|
1503 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
---|
1504 | #endif |
---|
1505 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
---|
1506 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
---|
1507 | rpcCU->getTotalBins() = m_uiTotalBins; |
---|
1508 | memcpy( rpcCU->m_sliceStartCU + m_uiAbsIdxInLCU, m_sliceStartCU, sizeof( UInt ) * m_uiNumPartition ); |
---|
1509 | memcpy( rpcCU->m_sliceSegmentStartCU + m_uiAbsIdxInLCU, m_sliceSegmentStartCU, sizeof( UInt ) * m_uiNumPartition ); |
---|
1510 | #if H_3D_ARP |
---|
1511 | memcpy( rpcCU->getARPW() + m_uiAbsIdxInLCU, m_puhARPW, iSizeInUchar ); |
---|
1512 | #endif |
---|
1513 | #if H_3D_IC |
---|
1514 | memcpy( rpcCU->getICFlag() + m_uiAbsIdxInLCU, m_pbICFlag, iSizeInBool ); |
---|
1515 | #endif |
---|
1516 | } |
---|
1517 | |
---|
1518 | Void TComDataCU::copyToPic( UChar uhDepth, UInt uiPartIdx, UInt uiPartDepth ) |
---|
1519 | { |
---|
1520 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
1521 | UInt uiQNumPart = m_uiNumPartition>>(uiPartDepth<<1); |
---|
1522 | |
---|
1523 | UInt uiPartStart = uiPartIdx*uiQNumPart; |
---|
1524 | UInt uiPartOffset = m_uiAbsIdxInLCU + uiPartStart; |
---|
1525 | |
---|
1526 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
1527 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
1528 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
1529 | |
---|
1530 | Int iSizeInUchar = sizeof( UChar ) * uiQNumPart; |
---|
1531 | Int iSizeInBool = sizeof( Bool ) * uiQNumPart; |
---|
1532 | |
---|
1533 | Int sizeInChar = sizeof( Char ) * uiQNumPart; |
---|
1534 | memcpy( rpcCU->getSkipFlag() + uiPartOffset, m_skipFlag, sizeof( *m_skipFlag ) * uiQNumPart ); |
---|
1535 | |
---|
1536 | memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, sizeInChar ); |
---|
1537 | memcpy( rpcCU->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( *m_pePartSize ) * uiQNumPart ); |
---|
1538 | memcpy( rpcCU->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( *m_pePredMode ) * uiQNumPart ); |
---|
1539 | memcpy( rpcCU->getCUTransquantBypass()+ uiPartOffset, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * uiQNumPart ); |
---|
1540 | memcpy( rpcCU->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); |
---|
1541 | memcpy( rpcCU->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); |
---|
1542 | #if H_3D_VSP |
---|
1543 | memcpy( rpcCU->getVSPFlag() + uiPartOffset, m_piVSPFlag, sizeof(Char) * uiQNumPart ); |
---|
1544 | #endif |
---|
1545 | #if H_3D_SPIVMP |
---|
1546 | memcpy( rpcCU->getSPIVMPFlag() + uiPartOffset, m_pbSPIVMPFlag, sizeof(Bool) * uiQNumPart ); |
---|
1547 | #endif |
---|
1548 | memcpy( rpcCU->getLumaIntraDir() + uiPartOffset, m_puhLumaIntraDir, iSizeInUchar ); |
---|
1549 | memcpy( rpcCU->getChromaIntraDir() + uiPartOffset, m_puhChromaIntraDir, iSizeInUchar ); |
---|
1550 | memcpy( rpcCU->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); |
---|
1551 | memcpy( rpcCU->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); |
---|
1552 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + uiPartOffset, m_puhTransformSkip[0], iSizeInUchar ); |
---|
1553 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhTransformSkip[1], iSizeInUchar ); |
---|
1554 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhTransformSkip[2], iSizeInUchar ); |
---|
1555 | memcpy( rpcCU->getCbf(TEXT_LUMA) + uiPartOffset, m_puhCbf[0], iSizeInUchar ); |
---|
1556 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar ); |
---|
1557 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); |
---|
1558 | |
---|
1559 | #if H_3D_DDD |
---|
1560 | memcpy( rpcCU->getDDDepth() + uiPartOffset, m_pucDisparityDerivedDepth, iSizeInUchar ); |
---|
1561 | memcpy( rpcCU->getUseDDD() + uiPartOffset, m_pbUseDDD, iSizeInBool ); |
---|
1562 | #endif |
---|
1563 | |
---|
1564 | #if H_3D_DIM |
---|
1565 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1566 | { |
---|
1567 | memcpy( rpcCU->getDimDeltaDC( i, 0 ) + uiPartOffset, m_dimDeltaDC[i][0], sizeof(Pel ) * uiQNumPart ); |
---|
1568 | memcpy( rpcCU->getDimDeltaDC( i, 1 ) + uiPartOffset, m_dimDeltaDC[i][1], sizeof(Pel ) * uiQNumPart ); |
---|
1569 | } |
---|
1570 | #if H_3D_DIM_DMM |
---|
1571 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
---|
1572 | { |
---|
1573 | memcpy( rpcCU->getDmmWedgeTabIdx( i ) + uiPartOffset, m_dmmWedgeTabIdx[i], sizeof(UInt) * uiQNumPart ); |
---|
1574 | } |
---|
1575 | #endif |
---|
1576 | #if H_3D_DIM_SDC |
---|
1577 | memcpy( rpcCU->getSDCFlag() + uiPartOffset, m_pbSDCFlag, iSizeInBool ); |
---|
1578 | memcpy( rpcCU->getSDCSegmentDCOffset(0) + uiPartOffset, m_apSegmentDCOffset[0], sizeof( Pel ) * uiQNumPart); |
---|
1579 | memcpy( rpcCU->getSDCSegmentDCOffset(1) + uiPartOffset, m_apSegmentDCOffset[1], sizeof( Pel ) * uiQNumPart); |
---|
1580 | #endif |
---|
1581 | #endif |
---|
1582 | #if H_3D_DBBP |
---|
1583 | memcpy( rpcCU->getDBBPFlag() + uiPartOffset, m_pbDBBPFlag, iSizeInBool ); |
---|
1584 | #endif |
---|
1585 | |
---|
1586 | memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); |
---|
1587 | memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); |
---|
1588 | memcpy( rpcCU->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); |
---|
1589 | |
---|
1590 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPIdx[0], iSizeInUchar ); |
---|
1591 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPIdx[1], iSizeInUchar ); |
---|
1592 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPNum[0], iSizeInUchar ); |
---|
1593 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPNum[1], iSizeInUchar ); |
---|
1594 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
1595 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
1596 | |
---|
1597 | memcpy( rpcCU->getIPCMFlag() + uiPartOffset, m_pbIPCMFlag, iSizeInBool ); |
---|
1598 | |
---|
1599 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); |
---|
1600 | UInt uiTmp2 = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
1601 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
1602 | #if ADAPTIVE_QP_SELECTION |
---|
1603 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
---|
1604 | #endif |
---|
1605 | |
---|
1606 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof( Pel ) * uiTmp ); |
---|
1607 | |
---|
1608 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
1609 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
1610 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
1611 | #if ADAPTIVE_QP_SELECTION |
---|
1612 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
---|
1613 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
---|
1614 | #endif |
---|
1615 | |
---|
1616 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
---|
1617 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
---|
1618 | rpcCU->getTotalBins() = m_uiTotalBins; |
---|
1619 | memcpy( rpcCU->m_sliceStartCU + uiPartOffset, m_sliceStartCU, sizeof( UInt ) * uiQNumPart ); |
---|
1620 | memcpy( rpcCU->m_sliceSegmentStartCU + uiPartOffset, m_sliceSegmentStartCU, sizeof( UInt ) * uiQNumPart ); |
---|
1621 | #if H_3D_ARP |
---|
1622 | memcpy( rpcCU->getARPW() + uiPartOffset, m_puhARPW, iSizeInUchar ); |
---|
1623 | #endif |
---|
1624 | #if H_3D_IC |
---|
1625 | memcpy( rpcCU->getICFlag() + uiPartOffset, m_pbICFlag, iSizeInBool ); |
---|
1626 | #endif |
---|
1627 | } |
---|
1628 | |
---|
1629 | #if H_3D_DDD |
---|
1630 | Void TComDataCU::setDDDepthSubParts ( UChar ucDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
1631 | { |
---|
1632 | setSubPart<UChar>( ucDDD, m_pucDisparityDerivedDepth, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1633 | } |
---|
1634 | |
---|
1635 | Void TComDataCU::setUseDDD ( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
1636 | { |
---|
1637 | setSubPart<Bool>( bUseDDD, m_pbUseDDD, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
1638 | } |
---|
1639 | |
---|
1640 | Void TComDataCU::setUseDDD( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1641 | { |
---|
1642 | memset( m_pbUseDDD + uiAbsPartIdx, bUseDDD, (m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ))*sizeof(Bool) ); |
---|
1643 | } |
---|
1644 | |
---|
1645 | #endif |
---|
1646 | |
---|
1647 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1648 | // Other public functions |
---|
1649 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1650 | |
---|
1651 | TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, |
---|
1652 | UInt uiCurrPartUnitIdx, |
---|
1653 | Bool bEnforceSliceRestriction, |
---|
1654 | Bool bEnforceTileRestriction ) |
---|
1655 | { |
---|
1656 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1657 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1658 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1659 | |
---|
1660 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1661 | { |
---|
1662 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1663 | if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1664 | { |
---|
1665 | return m_pcPic->getCU( getAddr() ); |
---|
1666 | } |
---|
1667 | else |
---|
1668 | { |
---|
1669 | uiLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1670 | return this; |
---|
1671 | } |
---|
1672 | } |
---|
1673 | |
---|
1674 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth - 1 ]; |
---|
1675 | |
---|
1676 | |
---|
1677 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
---|
1678 | || |
---|
1679 | (bEnforceTileRestriction && ( m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) ) ) |
---|
1680 | ) |
---|
1681 | { |
---|
1682 | return NULL; |
---|
1683 | } |
---|
1684 | return m_pcCULeft; |
---|
1685 | } |
---|
1686 | |
---|
1687 | TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, |
---|
1688 | UInt uiCurrPartUnitIdx, |
---|
1689 | Bool bEnforceSliceRestriction, |
---|
1690 | Bool planarAtLCUBoundary , |
---|
1691 | Bool bEnforceTileRestriction ) |
---|
1692 | { |
---|
1693 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1694 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1695 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1696 | |
---|
1697 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1698 | { |
---|
1699 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth ]; |
---|
1700 | if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1701 | { |
---|
1702 | return m_pcPic->getCU( getAddr() ); |
---|
1703 | } |
---|
1704 | else |
---|
1705 | { |
---|
1706 | uiAPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1707 | return this; |
---|
1708 | } |
---|
1709 | } |
---|
1710 | |
---|
1711 | if(planarAtLCUBoundary) |
---|
1712 | { |
---|
1713 | return NULL; |
---|
1714 | } |
---|
1715 | |
---|
1716 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1717 | |
---|
1718 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
---|
1719 | || |
---|
1720 | (bEnforceTileRestriction &&(m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())))) |
---|
1721 | ) |
---|
1722 | { |
---|
1723 | return NULL; |
---|
1724 | } |
---|
1725 | return m_pcCUAbove; |
---|
1726 | } |
---|
1727 | |
---|
1728 | TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
1729 | { |
---|
1730 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1731 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1732 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1733 | |
---|
1734 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1735 | { |
---|
1736 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1737 | { |
---|
1738 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth - 1 ]; |
---|
1739 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1740 | { |
---|
1741 | return m_pcPic->getCU( getAddr() ); |
---|
1742 | } |
---|
1743 | else |
---|
1744 | { |
---|
1745 | uiALPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1746 | return this; |
---|
1747 | } |
---|
1748 | } |
---|
1749 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartInCU() - uiNumPartInCUWidth - 1 ]; |
---|
1750 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1751 | m_pcCUAbove->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1752 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1753 | )) |
---|
1754 | ) |
---|
1755 | { |
---|
1756 | return NULL; |
---|
1757 | } |
---|
1758 | return m_pcCUAbove; |
---|
1759 | } |
---|
1760 | |
---|
1761 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
1762 | { |
---|
1763 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1764 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1765 | m_pcCULeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1766 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1767 | )) |
---|
1768 | ) |
---|
1769 | { |
---|
1770 | return NULL; |
---|
1771 | } |
---|
1772 | return m_pcCULeft; |
---|
1773 | } |
---|
1774 | |
---|
1775 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - 1 ]; |
---|
1776 | if ( (bEnforceSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || |
---|
1777 | m_pcCUAboveLeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1778 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveLeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1779 | )) |
---|
1780 | ) |
---|
1781 | { |
---|
1782 | return NULL; |
---|
1783 | } |
---|
1784 | return m_pcCUAboveLeft; |
---|
1785 | } |
---|
1786 | |
---|
1787 | TComDataCU* TComDataCU::getPUAboveRight( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
1788 | { |
---|
1789 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1790 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1; |
---|
1791 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1792 | |
---|
1793 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
1794 | { |
---|
1795 | uiARPartUnitIdx = MAX_UINT; |
---|
1796 | return NULL; |
---|
1797 | } |
---|
1798 | |
---|
1799 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - 1, uiNumPartInCUWidth ) ) |
---|
1800 | { |
---|
1801 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1802 | { |
---|
1803 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] ) |
---|
1804 | { |
---|
1805 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ]; |
---|
1806 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1807 | { |
---|
1808 | return m_pcPic->getCU( getAddr() ); |
---|
1809 | } |
---|
1810 | else |
---|
1811 | { |
---|
1812 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1813 | return this; |
---|
1814 | } |
---|
1815 | } |
---|
1816 | uiARPartUnitIdx = MAX_UINT; |
---|
1817 | return NULL; |
---|
1818 | } |
---|
1819 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; |
---|
1820 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1821 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1822 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1823 | )) |
---|
1824 | ) |
---|
1825 | { |
---|
1826 | return NULL; |
---|
1827 | } |
---|
1828 | return m_pcCUAbove; |
---|
1829 | } |
---|
1830 | |
---|
1831 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1832 | { |
---|
1833 | uiARPartUnitIdx = MAX_UINT; |
---|
1834 | return NULL; |
---|
1835 | } |
---|
1836 | |
---|
1837 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1838 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
1839 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
1840 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1841 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1842 | )) |
---|
1843 | ) |
---|
1844 | { |
---|
1845 | return NULL; |
---|
1846 | } |
---|
1847 | return m_pcCUAboveRight; |
---|
1848 | } |
---|
1849 | |
---|
1850 | TComDataCU* TComDataCU::getPUBelowLeft( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
1851 | { |
---|
1852 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1853 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*m_pcPic->getNumPartInWidth(); |
---|
1854 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1855 | |
---|
1856 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
1857 | { |
---|
1858 | uiBLPartUnitIdx = MAX_UINT; |
---|
1859 | return NULL; |
---|
1860 | } |
---|
1861 | |
---|
1862 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - 1, uiNumPartInCUWidth ) ) |
---|
1863 | { |
---|
1864 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
---|
1865 | { |
---|
1866 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) |
---|
1867 | { |
---|
1868 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; |
---|
1869 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
---|
1870 | { |
---|
1871 | return m_pcPic->getCU( getAddr() ); |
---|
1872 | } |
---|
1873 | else |
---|
1874 | { |
---|
1875 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1876 | return this; |
---|
1877 | } |
---|
1878 | } |
---|
1879 | uiBLPartUnitIdx = MAX_UINT; |
---|
1880 | return NULL; |
---|
1881 | } |
---|
1882 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; |
---|
1883 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1884 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1885 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1886 | )) |
---|
1887 | ) |
---|
1888 | { |
---|
1889 | return NULL; |
---|
1890 | } |
---|
1891 | return m_pcCULeft; |
---|
1892 | } |
---|
1893 | |
---|
1894 | uiBLPartUnitIdx = MAX_UINT; |
---|
1895 | return NULL; |
---|
1896 | } |
---|
1897 | |
---|
1898 | TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
---|
1899 | { |
---|
1900 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1901 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth(); |
---|
1902 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1903 | |
---|
1904 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) |
---|
1905 | { |
---|
1906 | uiBLPartUnitIdx = MAX_UINT; |
---|
1907 | return NULL; |
---|
1908 | } |
---|
1909 | |
---|
1910 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
---|
1911 | { |
---|
1912 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
---|
1913 | { |
---|
1914 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ] ) |
---|
1915 | { |
---|
1916 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ]; |
---|
1917 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
---|
1918 | { |
---|
1919 | return m_pcPic->getCU( getAddr() ); |
---|
1920 | } |
---|
1921 | else |
---|
1922 | { |
---|
1923 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1924 | return this; |
---|
1925 | } |
---|
1926 | } |
---|
1927 | uiBLPartUnitIdx = MAX_UINT; |
---|
1928 | return NULL; |
---|
1929 | } |
---|
1930 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * uiNumPartInCUWidth - 1 ]; |
---|
1931 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
1932 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1933 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1934 | )) |
---|
1935 | ) |
---|
1936 | { |
---|
1937 | return NULL; |
---|
1938 | } |
---|
1939 | return m_pcCULeft; |
---|
1940 | } |
---|
1941 | |
---|
1942 | uiBLPartUnitIdx = MAX_UINT; |
---|
1943 | return NULL; |
---|
1944 | } |
---|
1945 | |
---|
1946 | TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
---|
1947 | { |
---|
1948 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1949 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
---|
1950 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1951 | |
---|
1952 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
1953 | { |
---|
1954 | uiARPartUnitIdx = MAX_UINT; |
---|
1955 | return NULL; |
---|
1956 | } |
---|
1957 | |
---|
1958 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
---|
1959 | { |
---|
1960 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1961 | { |
---|
1962 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ] ) |
---|
1963 | { |
---|
1964 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
1965 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
1966 | { |
---|
1967 | return m_pcPic->getCU( getAddr() ); |
---|
1968 | } |
---|
1969 | else |
---|
1970 | { |
---|
1971 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1972 | return this; |
---|
1973 | } |
---|
1974 | } |
---|
1975 | uiARPartUnitIdx = MAX_UINT; |
---|
1976 | return NULL; |
---|
1977 | } |
---|
1978 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
1979 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
1980 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
1981 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
1982 | )) |
---|
1983 | ) |
---|
1984 | { |
---|
1985 | return NULL; |
---|
1986 | } |
---|
1987 | return m_pcCUAbove; |
---|
1988 | } |
---|
1989 | |
---|
1990 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
1991 | { |
---|
1992 | uiARPartUnitIdx = MAX_UINT; |
---|
1993 | return NULL; |
---|
1994 | } |
---|
1995 | |
---|
1996 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset-1 ]; |
---|
1997 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
1998 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
1999 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
2000 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
2001 | )) |
---|
2002 | ) |
---|
2003 | { |
---|
2004 | return NULL; |
---|
2005 | } |
---|
2006 | return m_pcCUAboveRight; |
---|
2007 | } |
---|
2008 | |
---|
2009 | /** Get left QpMinCu |
---|
2010 | *\param uiLPartUnitIdx |
---|
2011 | *\param uiCurrAbsIdxInLCU |
---|
2012 | *\returns TComDataCU* point of TComDataCU of left QpMinCu |
---|
2013 | */ |
---|
2014 | TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInLCU) |
---|
2015 | { |
---|
2016 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
2017 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth -getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
---|
2018 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
2019 | |
---|
2020 | // check for left LCU boundary |
---|
2021 | if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCUWidth) ) |
---|
2022 | { |
---|
2023 | return NULL; |
---|
2024 | } |
---|
2025 | |
---|
2026 | // get index of left-CU relative to top-left corner of current quantization group |
---|
2027 | uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; |
---|
2028 | |
---|
2029 | // return pointer to current LCU |
---|
2030 | return m_pcPic->getCU( getAddr() ); |
---|
2031 | } |
---|
2032 | |
---|
2033 | /** Get Above QpMinCu |
---|
2034 | *\param aPartUnitIdx |
---|
2035 | *\param currAbsIdxInLCU |
---|
2036 | *\returns TComDataCU* point of TComDataCU of above QpMinCu |
---|
2037 | */ |
---|
2038 | TComDataCU* TComDataCU::getQpMinCuAbove( UInt& aPartUnitIdx, UInt currAbsIdxInLCU ) |
---|
2039 | { |
---|
2040 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
2041 | UInt absZorderQpMinCUIdx = (currAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
---|
2042 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
2043 | |
---|
2044 | // check for top LCU boundary |
---|
2045 | if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCUWidth) ) |
---|
2046 | { |
---|
2047 | return NULL; |
---|
2048 | } |
---|
2049 | |
---|
2050 | // get index of top-CU relative to top-left corner of current quantization group |
---|
2051 | aPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCUWidth]; |
---|
2052 | |
---|
2053 | // return pointer to current LCU |
---|
2054 | return m_pcPic->getCU( getAddr() ); |
---|
2055 | } |
---|
2056 | |
---|
2057 | /** Get reference QP from left QpMinCu or latest coded QP |
---|
2058 | *\param uiCurrAbsIdxInLCU |
---|
2059 | *\returns Char reference QP value |
---|
2060 | */ |
---|
2061 | Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInLCU ) |
---|
2062 | { |
---|
2063 | UInt lPartIdx = 0, aPartIdx = 0; |
---|
2064 | TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
---|
2065 | TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
---|
2066 | return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + 1) >> 1); |
---|
2067 | } |
---|
2068 | |
---|
2069 | Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) |
---|
2070 | { |
---|
2071 | Int iLastValidPartIdx = iAbsPartIdx-1; |
---|
2072 | while ( iLastValidPartIdx >= 0 |
---|
2073 | && getPredictionMode( iLastValidPartIdx ) == MODE_NONE ) |
---|
2074 | { |
---|
2075 | UInt uiDepth = getDepth( iLastValidPartIdx ); |
---|
2076 | iLastValidPartIdx -= m_uiNumPartition>>(uiDepth<<1); |
---|
2077 | } |
---|
2078 | return iLastValidPartIdx; |
---|
2079 | } |
---|
2080 | |
---|
2081 | Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) |
---|
2082 | { |
---|
2083 | UInt uiQUPartIdxMask = ~((1<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); |
---|
2084 | Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); |
---|
2085 | if ( uiAbsPartIdx < m_uiNumPartition |
---|
2086 | && (getSCUAddr()+iLastValidPartIdx < getSliceStartCU(m_uiAbsIdxInLCU+uiAbsPartIdx))) |
---|
2087 | { |
---|
2088 | return getSlice()->getSliceQp(); |
---|
2089 | } |
---|
2090 | else if ( iLastValidPartIdx >= 0 ) |
---|
2091 | { |
---|
2092 | return getQP( iLastValidPartIdx ); |
---|
2093 | } |
---|
2094 | else |
---|
2095 | { |
---|
2096 | if ( getZorderIdxInCU() > 0 ) |
---|
2097 | { |
---|
2098 | return getPic()->getCU( getAddr() )->getLastCodedQP( getZorderIdxInCU() ); |
---|
2099 | } |
---|
2100 | else if ( getPic()->getPicSym()->getInverseCUOrderMap(getAddr()) > 0 |
---|
2101 | && getPic()->getPicSym()->getTileIdxMap(getAddr()) == getPic()->getPicSym()->getTileIdxMap(getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1)) |
---|
2102 | && !( getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() && getAddr() % getPic()->getFrameWidthInCU() == 0 ) ) |
---|
2103 | { |
---|
2104 | return getPic()->getCU( getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1) )->getLastCodedQP( getPic()->getNumPartInCU() ); |
---|
2105 | } |
---|
2106 | else |
---|
2107 | { |
---|
2108 | return getSlice()->getSliceQp(); |
---|
2109 | } |
---|
2110 | } |
---|
2111 | } |
---|
2112 | /** Check whether the CU is coded in lossless coding mode |
---|
2113 | * \param uiAbsPartIdx |
---|
2114 | * \returns true if the CU is coded in lossless coding mode; false if otherwise |
---|
2115 | */ |
---|
2116 | Bool TComDataCU::isLosslessCoded(UInt absPartIdx) |
---|
2117 | { |
---|
2118 | return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx)); |
---|
2119 | } |
---|
2120 | |
---|
2121 | /** Get allowed chroma intra modes |
---|
2122 | *\param uiAbsPartIdx |
---|
2123 | *\param uiModeList pointer to chroma intra modes array |
---|
2124 | *\returns |
---|
2125 | *- fill uiModeList with chroma intra modes |
---|
2126 | */ |
---|
2127 | Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt* uiModeList ) |
---|
2128 | { |
---|
2129 | uiModeList[0] = PLANAR_IDX; |
---|
2130 | uiModeList[1] = VER_IDX; |
---|
2131 | uiModeList[2] = HOR_IDX; |
---|
2132 | uiModeList[3] = DC_IDX; |
---|
2133 | uiModeList[4] = DM_CHROMA_IDX; |
---|
2134 | |
---|
2135 | UInt uiLumaMode = getLumaIntraDir( uiAbsPartIdx ); |
---|
2136 | |
---|
2137 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
---|
2138 | { |
---|
2139 | if( uiLumaMode == uiModeList[i] ) |
---|
2140 | { |
---|
2141 | uiModeList[i] = 34; // VER+8 mode |
---|
2142 | break; |
---|
2143 | } |
---|
2144 | } |
---|
2145 | } |
---|
2146 | |
---|
2147 | /** Get most probable intra modes |
---|
2148 | *\param uiAbsPartIdx |
---|
2149 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
2150 | *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. |
---|
2151 | *\returns Number of MPM |
---|
2152 | */ |
---|
2153 | Int TComDataCU::getIntraDirLumaPredictor( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode ) |
---|
2154 | { |
---|
2155 | TComDataCU* pcTempCU; |
---|
2156 | UInt uiTempPartIdx; |
---|
2157 | Int iLeftIntraDir, iAboveIntraDir; |
---|
2158 | Int uiPredNum = 0; |
---|
2159 | |
---|
2160 | // Get intra direction of left PU |
---|
2161 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2162 | |
---|
2163 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
2164 | #if H_3D_DIM |
---|
2165 | mapDepthModeToIntraDir( iLeftIntraDir ); |
---|
2166 | #endif |
---|
2167 | |
---|
2168 | // Get intra direction of above PU |
---|
2169 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true ); |
---|
2170 | |
---|
2171 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
2172 | #if H_3D_DIM |
---|
2173 | mapDepthModeToIntraDir( iAboveIntraDir ); |
---|
2174 | #endif |
---|
2175 | |
---|
2176 | uiPredNum = 3; |
---|
2177 | if(iLeftIntraDir == iAboveIntraDir) |
---|
2178 | { |
---|
2179 | if( piMode ) |
---|
2180 | { |
---|
2181 | *piMode = 1; |
---|
2182 | } |
---|
2183 | |
---|
2184 | if (iLeftIntraDir > 1) // angular modes |
---|
2185 | { |
---|
2186 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
2187 | uiIntraDirPred[1] = ((iLeftIntraDir + 29) % 32) + 2; |
---|
2188 | uiIntraDirPred[2] = ((iLeftIntraDir - 1 ) % 32) + 2; |
---|
2189 | } |
---|
2190 | else //non-angular |
---|
2191 | { |
---|
2192 | uiIntraDirPred[0] = PLANAR_IDX; |
---|
2193 | uiIntraDirPred[1] = DC_IDX; |
---|
2194 | uiIntraDirPred[2] = VER_IDX; |
---|
2195 | } |
---|
2196 | } |
---|
2197 | else |
---|
2198 | { |
---|
2199 | if( piMode ) |
---|
2200 | { |
---|
2201 | *piMode = 2; |
---|
2202 | } |
---|
2203 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
2204 | uiIntraDirPred[1] = iAboveIntraDir; |
---|
2205 | |
---|
2206 | if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar |
---|
2207 | { |
---|
2208 | uiIntraDirPred[2] = PLANAR_IDX; |
---|
2209 | } |
---|
2210 | else |
---|
2211 | { |
---|
2212 | uiIntraDirPred[2] = (iLeftIntraDir+iAboveIntraDir)<2? VER_IDX : DC_IDX; |
---|
2213 | } |
---|
2214 | } |
---|
2215 | |
---|
2216 | return uiPredNum; |
---|
2217 | } |
---|
2218 | |
---|
2219 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2220 | { |
---|
2221 | TComDataCU* pcTempCU; |
---|
2222 | UInt uiTempPartIdx; |
---|
2223 | UInt uiCtx; |
---|
2224 | // Get left split flag |
---|
2225 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2226 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
2227 | |
---|
2228 | // Get above split flag |
---|
2229 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2230 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
2231 | |
---|
2232 | return uiCtx; |
---|
2233 | } |
---|
2234 | |
---|
2235 | UInt TComDataCU::getCtxQtCbf( TextType eType, UInt uiTrDepth ) |
---|
2236 | { |
---|
2237 | if( eType ) |
---|
2238 | { |
---|
2239 | return uiTrDepth; |
---|
2240 | } |
---|
2241 | else |
---|
2242 | { |
---|
2243 | const UInt uiCtx = ( uiTrDepth == 0 ? 1 : 0 ); |
---|
2244 | return uiCtx; |
---|
2245 | } |
---|
2246 | } |
---|
2247 | |
---|
2248 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) |
---|
2249 | { |
---|
2250 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
---|
2251 | PartSize partSize = getPartitionSize( absPartIdx ); |
---|
2252 | UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
2253 | Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA && partSize == SIZE_NxN ) ? 1 : 0; |
---|
2254 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) ); |
---|
2255 | |
---|
2256 | UInt log2MinTUSizeInCU = 0; |
---|
2257 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
---|
2258 | { |
---|
2259 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
---|
2260 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
2261 | } |
---|
2262 | else |
---|
2263 | { |
---|
2264 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
---|
2265 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
---|
2266 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
2267 | { |
---|
2268 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
---|
2269 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
2270 | } |
---|
2271 | } |
---|
2272 | return log2MinTUSizeInCU; |
---|
2273 | } |
---|
2274 | |
---|
2275 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
---|
2276 | { |
---|
2277 | TComDataCU* pcTempCU; |
---|
2278 | UInt uiTempPartIdx; |
---|
2279 | UInt uiCtx = 0; |
---|
2280 | |
---|
2281 | // Get BCBP of left PU |
---|
2282 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2283 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2284 | |
---|
2285 | // Get BCBP of above PU |
---|
2286 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2287 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
2288 | |
---|
2289 | return uiCtx; |
---|
2290 | } |
---|
2291 | |
---|
2292 | #if H_3D_ARP |
---|
2293 | UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx ) |
---|
2294 | { |
---|
2295 | TComDataCU* pcTempCU; |
---|
2296 | UInt uiTempPartIdx; |
---|
2297 | UInt uiCtx = 0; |
---|
2298 | |
---|
2299 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2300 | uiCtx = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0; |
---|
2301 | return uiCtx; |
---|
2302 | } |
---|
2303 | #endif |
---|
2304 | #if H_3D_DBBP |
---|
2305 | Pel* TComDataCU::getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride) |
---|
2306 | { |
---|
2307 | // get coded and reconstructed depth view |
---|
2308 | TComPicYuv* depthPicYuv = NULL; |
---|
2309 | Pel* pDepthPels = NULL; |
---|
2310 | |
---|
2311 | // DBBP is a texture coding tool |
---|
2312 | if( getSlice()->getIsDepth() ) |
---|
2313 | { |
---|
2314 | return NULL; |
---|
2315 | } |
---|
2316 | |
---|
2317 | #if H_3D_FCO |
---|
2318 | TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); |
---|
2319 | |
---|
2320 | if( depthPic && depthPic->getPicYuvRec() != NULL && depthPic->getIsDepth() ) // depth first |
---|
2321 | { |
---|
2322 | depthPicYuv = depthPic->getPicYuvRec(); |
---|
2323 | depthPicYuv->extendPicBorder(); |
---|
2324 | |
---|
2325 | // get collocated depth block for current CU |
---|
2326 | uiDepthStride = depthPicYuv->getStride(); |
---|
2327 | pDepthPels = depthPicYuv->getLumaAddr( getAddr(), uiAbsPartIdx ); |
---|
2328 | } |
---|
2329 | else // texture first |
---|
2330 | #else |
---|
2331 | { |
---|
2332 | DisInfo DvInfo = getDvInfo(uiAbsPartIdx); |
---|
2333 | |
---|
2334 | TComPic* baseDepthPic = getSlice()->getIvPic (true, DvInfo.m_aVIdxCan); |
---|
2335 | |
---|
2336 | if( baseDepthPic == NULL || baseDepthPic->getPicYuvRec() == NULL ) |
---|
2337 | { |
---|
2338 | return NULL; |
---|
2339 | } |
---|
2340 | |
---|
2341 | depthPicYuv = baseDepthPic->getPicYuvRec(); |
---|
2342 | depthPicYuv->extendPicBorder(); |
---|
2343 | uiDepthStride = depthPicYuv->getStride(); |
---|
2344 | |
---|
2345 | Int iBlkX = ( getAddr() % baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ]; |
---|
2346 | Int iBlkY = ( getAddr() / baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ]; |
---|
2347 | |
---|
2348 | Int iPictureWidth = depthPicYuv->getWidth(); |
---|
2349 | Int iPictureHeight = depthPicYuv->getHeight(); |
---|
2350 | |
---|
2351 | Int iWidth = uiWidth; |
---|
2352 | Int iHeight = uiHeight; |
---|
2353 | |
---|
2354 | Bool depthRefineFlag = false; |
---|
2355 | #if H_3D_NBDV_REF |
---|
2356 | depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ); |
---|
2357 | #endif // H_3D_NBDV_REF |
---|
2358 | |
---|
2359 | TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV; |
---|
2360 | if( depthRefineFlag ) |
---|
2361 | { |
---|
2362 | cDv.setVer(0); |
---|
2363 | } |
---|
2364 | |
---|
2365 | Int depthPosX = Clip3(0, iPictureWidth - iWidth, iBlkX + ((cDv.getHor()+2)>>2)); |
---|
2366 | Int depthPosY = Clip3(0, iPictureHeight- iHeight, iBlkY + ((cDv.getVer()+2)>>2)); |
---|
2367 | |
---|
2368 | pDepthPels = depthPicYuv->getLumaAddr() + depthPosX + depthPosY * uiDepthStride; |
---|
2369 | } |
---|
2370 | #endif |
---|
2371 | |
---|
2372 | AOF( depthPicYuv != NULL ); |
---|
2373 | AOF( pDepthPels != NULL ); |
---|
2374 | AOF( uiDepthStride != 0 ); |
---|
2375 | |
---|
2376 | return pDepthPels; |
---|
2377 | } |
---|
2378 | #endif |
---|
2379 | |
---|
2380 | #if H_3D_DBBP |
---|
2381 | Void TComDataCU::setDBBPFlagSubParts ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2382 | { |
---|
2383 | setSubPart( bDBBPFlag, m_pbDBBPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2384 | } |
---|
2385 | #endif |
---|
2386 | |
---|
2387 | #if H_3D_DIM_SDC |
---|
2388 | UInt TComDataCU::getCtxSDCFlag( UInt uiAbsPartIdx ) |
---|
2389 | { |
---|
2390 | return 0; |
---|
2391 | } |
---|
2392 | |
---|
2393 | #endif |
---|
2394 | |
---|
2395 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
---|
2396 | { |
---|
2397 | return getDepth( uiAbsPartIdx ); |
---|
2398 | } |
---|
2399 | |
---|
2400 | Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2401 | { |
---|
2402 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2403 | memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2404 | memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2405 | memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2406 | } |
---|
2407 | |
---|
2408 | Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2409 | { |
---|
2410 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2411 | memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2412 | } |
---|
2413 | |
---|
2414 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
2415 | * \param uiCbf The value of the coded block flag to be set |
---|
2416 | * \param eTType |
---|
2417 | * \param uiAbsPartIdx |
---|
2418 | * \param uiPartIdx |
---|
2419 | * \param uiDepth |
---|
2420 | * \returns Void |
---|
2421 | */ |
---|
2422 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2423 | { |
---|
2424 | setSubPart<UChar>( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2425 | } |
---|
2426 | |
---|
2427 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
2428 | { |
---|
2429 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2430 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2431 | } |
---|
2432 | |
---|
2433 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
---|
2434 | { |
---|
2435 | UInt uiPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2436 | return (((m_uiAbsIdxInLCU + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
2437 | } |
---|
2438 | |
---|
2439 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2440 | { |
---|
2441 | assert( sizeof( *m_pePartSize) == 1 ); |
---|
2442 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2443 | } |
---|
2444 | |
---|
2445 | Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2446 | { |
---|
2447 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2448 | } |
---|
2449 | |
---|
2450 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
---|
2451 | { |
---|
2452 | assert( sizeof( *m_skipFlag) == 1 ); |
---|
2453 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); |
---|
2454 | } |
---|
2455 | |
---|
2456 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2457 | { |
---|
2458 | assert( sizeof( *m_pePredMode) == 1 ); |
---|
2459 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2460 | } |
---|
2461 | |
---|
2462 | Void TComDataCU::setQPSubCUs( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
---|
2463 | { |
---|
2464 | UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); |
---|
2465 | UInt currPartNumQ = currPartNumb >> 2; |
---|
2466 | |
---|
2467 | if(!foundNonZeroCbf) |
---|
2468 | { |
---|
2469 | if(pcCU->getDepth(absPartIdx) > depth) |
---|
2470 | { |
---|
2471 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
---|
2472 | { |
---|
2473 | pcCU->setQPSubCUs( qp, pcCU, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
---|
2474 | } |
---|
2475 | } |
---|
2476 | else |
---|
2477 | { |
---|
2478 | if(pcCU->getCbf( absPartIdx, TEXT_LUMA ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_U ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_V ) ) |
---|
2479 | { |
---|
2480 | foundNonZeroCbf = true; |
---|
2481 | } |
---|
2482 | else |
---|
2483 | { |
---|
2484 | setQPSubParts(qp, absPartIdx, depth); |
---|
2485 | } |
---|
2486 | } |
---|
2487 | } |
---|
2488 | } |
---|
2489 | |
---|
2490 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2491 | { |
---|
2492 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2493 | TComSlice * pcSlice = getPic()->getSlice(getPic()->getCurrSliceIdx()); |
---|
2494 | |
---|
2495 | for(UInt uiSCUIdx = uiAbsPartIdx; uiSCUIdx < uiAbsPartIdx+uiCurrPartNumb; uiSCUIdx++) |
---|
2496 | { |
---|
2497 | if( m_pcPic->getCU( getAddr() )->getSliceSegmentStartCU(uiSCUIdx+getZorderIdxInCU()) == pcSlice->getSliceSegmentCurStartCUAddr() ) |
---|
2498 | { |
---|
2499 | m_phQP[uiSCUIdx] = qp; |
---|
2500 | } |
---|
2501 | } |
---|
2502 | } |
---|
2503 | |
---|
2504 | Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2505 | { |
---|
2506 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2507 | |
---|
2508 | memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2509 | } |
---|
2510 | |
---|
2511 | template<typename T> |
---|
2512 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2513 | { |
---|
2514 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
---|
2515 | |
---|
2516 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
---|
2517 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2518 | { |
---|
2519 | case SIZE_2Nx2N: |
---|
2520 | memset( puhBaseLCU + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
---|
2521 | break; |
---|
2522 | case SIZE_2NxN: |
---|
2523 | memset( puhBaseLCU + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
---|
2524 | break; |
---|
2525 | case SIZE_Nx2N: |
---|
2526 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2527 | memset( puhBaseLCU + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
---|
2528 | break; |
---|
2529 | case SIZE_NxN: |
---|
2530 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
2531 | break; |
---|
2532 | case SIZE_2NxnU: |
---|
2533 | if ( uiPUIdx == 0 ) |
---|
2534 | { |
---|
2535 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2536 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2537 | } |
---|
2538 | else if ( uiPUIdx == 1 ) |
---|
2539 | { |
---|
2540 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2541 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
---|
2542 | } |
---|
2543 | else |
---|
2544 | { |
---|
2545 | assert(0); |
---|
2546 | } |
---|
2547 | break; |
---|
2548 | case SIZE_2NxnD: |
---|
2549 | if ( uiPUIdx == 0 ) |
---|
2550 | { |
---|
2551 | memset( puhBaseLCU + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
---|
2552 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2553 | } |
---|
2554 | else if ( uiPUIdx == 1 ) |
---|
2555 | { |
---|
2556 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2557 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
2558 | } |
---|
2559 | else |
---|
2560 | { |
---|
2561 | assert(0); |
---|
2562 | } |
---|
2563 | break; |
---|
2564 | case SIZE_nLx2N: |
---|
2565 | if ( uiPUIdx == 0 ) |
---|
2566 | { |
---|
2567 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2568 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2569 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2570 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2571 | } |
---|
2572 | else if ( uiPUIdx == 1 ) |
---|
2573 | { |
---|
2574 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2575 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2576 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2577 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2578 | } |
---|
2579 | else |
---|
2580 | { |
---|
2581 | assert(0); |
---|
2582 | } |
---|
2583 | break; |
---|
2584 | case SIZE_nRx2N: |
---|
2585 | if ( uiPUIdx == 0 ) |
---|
2586 | { |
---|
2587 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2588 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2589 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
2590 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2591 | } |
---|
2592 | else if ( uiPUIdx == 1 ) |
---|
2593 | { |
---|
2594 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2595 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2596 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2597 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
2598 | } |
---|
2599 | else |
---|
2600 | { |
---|
2601 | assert(0); |
---|
2602 | } |
---|
2603 | break; |
---|
2604 | default: |
---|
2605 | assert( 0 ); |
---|
2606 | } |
---|
2607 | } |
---|
2608 | |
---|
2609 | #if H_3D_DIM_SDC |
---|
2610 | Void TComDataCU::setSDCFlagSubParts ( Bool bSDCFlag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2611 | { |
---|
2612 | assert( sizeof( *m_pbSDCFlag) == 1 ); |
---|
2613 | memset( m_pbSDCFlag + uiAbsPartIdx, bSDCFlag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
2614 | } |
---|
2615 | |
---|
2616 | Bool TComDataCU::getSDCAvailable( UInt uiAbsPartIdx ) |
---|
2617 | { |
---|
2618 | // check general CU information |
---|
2619 | if( !getSlice()->getIsDepth() || !isIntra(uiAbsPartIdx) || getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) |
---|
2620 | { |
---|
2621 | return false; |
---|
2622 | } |
---|
2623 | |
---|
2624 | if( isDimMode( getLumaIntraDir( uiAbsPartIdx ) ) && !isDimDeltaDC( getLumaIntraDir( uiAbsPartIdx ) ) ) |
---|
2625 | { |
---|
2626 | return true; |
---|
2627 | } |
---|
2628 | |
---|
2629 | if( getLumaIntraDir( uiAbsPartIdx ) < NUM_INTRA_MODE ) |
---|
2630 | { |
---|
2631 | return true; |
---|
2632 | } |
---|
2633 | |
---|
2634 | return false; |
---|
2635 | // check prediction mode |
---|
2636 | UInt uiLumaPredMode = getLumaIntraDir( uiAbsPartIdx ); |
---|
2637 | if( uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX && !isDimDeltaDC( uiLumaPredMode ) ) ) |
---|
2638 | return true; |
---|
2639 | |
---|
2640 | // else |
---|
2641 | return false; |
---|
2642 | } |
---|
2643 | #endif |
---|
2644 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2645 | { |
---|
2646 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2647 | } |
---|
2648 | |
---|
2649 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2650 | { |
---|
2651 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2652 | } |
---|
2653 | |
---|
2654 | #if H_3D_SPIVMP |
---|
2655 | Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2656 | { |
---|
2657 | setSubPart<Bool>( bSPIVMPFlag, m_pbSPIVMPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2658 | } |
---|
2659 | #endif |
---|
2660 | |
---|
2661 | #if H_3D_VSP |
---|
2662 | Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2663 | { |
---|
2664 | setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2665 | } |
---|
2666 | #if H_3D_VSP |
---|
2667 | template<typename T> |
---|
2668 | Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2669 | { |
---|
2670 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
---|
2671 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2672 | { |
---|
2673 | case SIZE_2Nx2N: |
---|
2674 | for (UInt ui = 0; ui < 4 * uiCurrPartNumQ; ui++) |
---|
2675 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2676 | |
---|
2677 | break; |
---|
2678 | case SIZE_2NxN: |
---|
2679 | for (UInt ui = 0; ui < 2 * uiCurrPartNumQ; ui++) |
---|
2680 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2681 | break; |
---|
2682 | case SIZE_Nx2N: |
---|
2683 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2684 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2685 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2686 | puhBaseLCU[uiCUAddr + 2 * uiCurrPartNumQ + ui] = uiParameter; |
---|
2687 | break; |
---|
2688 | case SIZE_NxN: |
---|
2689 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
---|
2690 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2691 | break; |
---|
2692 | case SIZE_2NxnU: |
---|
2693 | if ( uiPUIdx == 0 ) |
---|
2694 | { |
---|
2695 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2696 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2697 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2698 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2699 | |
---|
2700 | } |
---|
2701 | else if ( uiPUIdx == 1 ) |
---|
2702 | { |
---|
2703 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2704 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2705 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1); ui++) |
---|
2706 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2707 | |
---|
2708 | } |
---|
2709 | else |
---|
2710 | { |
---|
2711 | assert(0); |
---|
2712 | } |
---|
2713 | break; |
---|
2714 | case SIZE_2NxnD: |
---|
2715 | if ( uiPUIdx == 0 ) |
---|
2716 | { |
---|
2717 | for (UInt ui = 0; ui < ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)); ui++) |
---|
2718 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2719 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2720 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + ui] = uiParameter; |
---|
2721 | |
---|
2722 | } |
---|
2723 | else if ( uiPUIdx == 1 ) |
---|
2724 | { |
---|
2725 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2726 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2727 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
---|
2728 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
---|
2729 | |
---|
2730 | } |
---|
2731 | else |
---|
2732 | { |
---|
2733 | assert(0); |
---|
2734 | } |
---|
2735 | break; |
---|
2736 | case SIZE_nLx2N: |
---|
2737 | if ( uiPUIdx == 0 ) |
---|
2738 | { |
---|
2739 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2740 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2741 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2742 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2743 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2744 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2745 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2746 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2747 | |
---|
2748 | } |
---|
2749 | else if ( uiPUIdx == 1 ) |
---|
2750 | { |
---|
2751 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2752 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2753 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2754 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2755 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2756 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2757 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2758 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2759 | |
---|
2760 | } |
---|
2761 | else |
---|
2762 | { |
---|
2763 | assert(0); |
---|
2764 | } |
---|
2765 | break; |
---|
2766 | case SIZE_nRx2N: |
---|
2767 | if ( uiPUIdx == 0 ) |
---|
2768 | { |
---|
2769 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2770 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2771 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2772 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2773 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
---|
2774 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2775 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2776 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2777 | |
---|
2778 | } |
---|
2779 | else if ( uiPUIdx == 1 ) |
---|
2780 | { |
---|
2781 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2782 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
---|
2783 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2784 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2785 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2786 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
---|
2787 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
---|
2788 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
---|
2789 | |
---|
2790 | } |
---|
2791 | else |
---|
2792 | { |
---|
2793 | assert(0); |
---|
2794 | } |
---|
2795 | break; |
---|
2796 | default: |
---|
2797 | assert( 0 ); |
---|
2798 | } |
---|
2799 | |
---|
2800 | } |
---|
2801 | #endif |
---|
2802 | #endif |
---|
2803 | Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2804 | { |
---|
2805 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2806 | |
---|
2807 | memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2808 | } |
---|
2809 | |
---|
2810 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2811 | { |
---|
2812 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2813 | } |
---|
2814 | |
---|
2815 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2816 | { |
---|
2817 | setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2818 | } |
---|
2819 | |
---|
2820 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2821 | { |
---|
2822 | setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2823 | } |
---|
2824 | |
---|
2825 | |
---|
2826 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2827 | { |
---|
2828 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2829 | |
---|
2830 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
2831 | } |
---|
2832 | |
---|
2833 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2834 | { |
---|
2835 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2836 | |
---|
2837 | memset( m_puhTransformSkip[0] + uiAbsPartIdx, useTransformSkipY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2838 | memset( m_puhTransformSkip[1] + uiAbsPartIdx, useTransformSkipU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2839 | memset( m_puhTransformSkip[2] + uiAbsPartIdx, useTransformSkipV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2840 | } |
---|
2841 | |
---|
2842 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth) |
---|
2843 | { |
---|
2844 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2845 | |
---|
2846 | memset( m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2847 | } |
---|
2848 | |
---|
2849 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2850 | { |
---|
2851 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2852 | |
---|
2853 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2854 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
2855 | } |
---|
2856 | |
---|
2857 | UChar TComDataCU::getNumPartitions() |
---|
2858 | { |
---|
2859 | UChar iNumPart = 0; |
---|
2860 | |
---|
2861 | switch ( m_pePartSize[0] ) |
---|
2862 | { |
---|
2863 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
2864 | case SIZE_2NxN: iNumPart = 2; break; |
---|
2865 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
2866 | case SIZE_NxN: iNumPart = 4; break; |
---|
2867 | case SIZE_2NxnU: iNumPart = 2; break; |
---|
2868 | case SIZE_2NxnD: iNumPart = 2; break; |
---|
2869 | case SIZE_nLx2N: iNumPart = 2; break; |
---|
2870 | case SIZE_nRx2N: iNumPart = 2; break; |
---|
2871 | default: assert (0); break; |
---|
2872 | } |
---|
2873 | |
---|
2874 | return iNumPart; |
---|
2875 | } |
---|
2876 | |
---|
2877 | #if H_3D_IC |
---|
2878 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU) |
---|
2879 | { |
---|
2880 | UInt uiNumPartition = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition; |
---|
2881 | UInt uiTmpAbsPartIdx = bLCU ? uiAbsPartIdx : 0; |
---|
2882 | |
---|
2883 | switch ( m_pePartSize[uiTmpAbsPartIdx] ) |
---|
2884 | { |
---|
2885 | case SIZE_2NxN: |
---|
2886 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1; |
---|
2887 | break; |
---|
2888 | case SIZE_Nx2N: |
---|
2889 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2; |
---|
2890 | break; |
---|
2891 | case SIZE_NxN: |
---|
2892 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx; |
---|
2893 | break; |
---|
2894 | case SIZE_2NxnU: |
---|
2895 | riWidth = getWidth( uiTmpAbsPartIdx ); |
---|
2896 | riHeight = ( uiPartIdx == 0 ) ? getHeight( uiTmpAbsPartIdx ) >> 2 : ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ); |
---|
2897 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3; |
---|
2898 | break; |
---|
2899 | case SIZE_2NxnD: |
---|
2900 | riWidth = getWidth( uiTmpAbsPartIdx ); |
---|
2901 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ) : getHeight( uiTmpAbsPartIdx ) >> 2; |
---|
2902 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3); |
---|
2903 | break; |
---|
2904 | case SIZE_nLx2N: |
---|
2905 | riWidth = ( uiPartIdx == 0 ) ? getWidth( uiTmpAbsPartIdx ) >> 2 : ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ); |
---|
2906 | riHeight = getHeight( uiTmpAbsPartIdx ); |
---|
2907 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4; |
---|
2908 | break; |
---|
2909 | case SIZE_nRx2N: |
---|
2910 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ) : getWidth( uiTmpAbsPartIdx ) >> 2; |
---|
2911 | riHeight = getHeight( uiTmpAbsPartIdx ); |
---|
2912 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4); |
---|
2913 | break; |
---|
2914 | default: |
---|
2915 | assert ( m_pePartSize[uiTmpAbsPartIdx] == SIZE_2Nx2N ); |
---|
2916 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = 0; |
---|
2917 | break; |
---|
2918 | } |
---|
2919 | } |
---|
2920 | #else |
---|
2921 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
---|
2922 | { |
---|
2923 | switch ( m_pePartSize[0] ) |
---|
2924 | { |
---|
2925 | case SIZE_2NxN: |
---|
2926 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2927 | break; |
---|
2928 | case SIZE_Nx2N: |
---|
2929 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
2930 | break; |
---|
2931 | case SIZE_NxN: |
---|
2932 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2933 | break; |
---|
2934 | case SIZE_2NxnU: |
---|
2935 | riWidth = getWidth(0); |
---|
2936 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
2937 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
---|
2938 | break; |
---|
2939 | case SIZE_2NxnD: |
---|
2940 | riWidth = getWidth(0); |
---|
2941 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
2942 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
---|
2943 | break; |
---|
2944 | case SIZE_nLx2N: |
---|
2945 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
2946 | riHeight = getHeight(0); |
---|
2947 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
---|
2948 | break; |
---|
2949 | case SIZE_nRx2N: |
---|
2950 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
2951 | riHeight = getHeight(0); |
---|
2952 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
2953 | break; |
---|
2954 | default: |
---|
2955 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
2956 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
2957 | break; |
---|
2958 | } |
---|
2959 | } |
---|
2960 | #endif |
---|
2961 | |
---|
2962 | |
---|
2963 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
2964 | { |
---|
2965 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
2966 | { |
---|
2967 | TComMv cZeroMv; |
---|
2968 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
2969 | return; |
---|
2970 | } |
---|
2971 | |
---|
2972 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
2973 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
2974 | } |
---|
2975 | |
---|
2976 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2977 | { |
---|
2978 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
2979 | UInt uiPUWidth = 0; |
---|
2980 | |
---|
2981 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2982 | { |
---|
2983 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2984 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2985 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2986 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2987 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2988 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2989 | case SIZE_nLx2N: |
---|
2990 | if ( uiPartIdx == 0 ) |
---|
2991 | { |
---|
2992 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
2993 | } |
---|
2994 | else if ( uiPartIdx == 1 ) |
---|
2995 | { |
---|
2996 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
2997 | } |
---|
2998 | else |
---|
2999 | { |
---|
3000 | assert(0); |
---|
3001 | } |
---|
3002 | break; |
---|
3003 | case SIZE_nRx2N: |
---|
3004 | if ( uiPartIdx == 0 ) |
---|
3005 | { |
---|
3006 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
3007 | } |
---|
3008 | else if ( uiPartIdx == 1 ) |
---|
3009 | { |
---|
3010 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
3011 | } |
---|
3012 | else |
---|
3013 | { |
---|
3014 | assert(0); |
---|
3015 | } |
---|
3016 | break; |
---|
3017 | default: |
---|
3018 | assert (0); |
---|
3019 | break; |
---|
3020 | } |
---|
3021 | |
---|
3022 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
3023 | } |
---|
3024 | |
---|
3025 | Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
3026 | { |
---|
3027 | UInt uiPUHeight = 0; |
---|
3028 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
3029 | { |
---|
3030 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
3031 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
3032 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
3033 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
3034 | case SIZE_2NxnU: |
---|
3035 | if ( uiPartIdx == 0 ) |
---|
3036 | { |
---|
3037 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
3038 | } |
---|
3039 | else if ( uiPartIdx == 1 ) |
---|
3040 | { |
---|
3041 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
3042 | } |
---|
3043 | else |
---|
3044 | { |
---|
3045 | assert(0); |
---|
3046 | } |
---|
3047 | break; |
---|
3048 | case SIZE_2NxnD: |
---|
3049 | if ( uiPartIdx == 0 ) |
---|
3050 | { |
---|
3051 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
3052 | } |
---|
3053 | else if ( uiPartIdx == 1 ) |
---|
3054 | { |
---|
3055 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
3056 | } |
---|
3057 | else |
---|
3058 | { |
---|
3059 | assert(0); |
---|
3060 | } |
---|
3061 | break; |
---|
3062 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
3063 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
3064 | default: |
---|
3065 | assert (0); |
---|
3066 | break; |
---|
3067 | } |
---|
3068 | |
---|
3069 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
3070 | } |
---|
3071 | |
---|
3072 | Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
3073 | { |
---|
3074 | ruiPartIdxLT = m_uiAbsIdxInLCU; |
---|
3075 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
3076 | |
---|
3077 | switch ( m_pePartSize[0] ) |
---|
3078 | { |
---|
3079 | case SIZE_2Nx2N: break; |
---|
3080 | case SIZE_2NxN: |
---|
3081 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
3082 | break; |
---|
3083 | case SIZE_Nx2N: |
---|
3084 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
3085 | break; |
---|
3086 | case SIZE_NxN: |
---|
3087 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
3088 | break; |
---|
3089 | case SIZE_2NxnU: |
---|
3090 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
3091 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
3092 | break; |
---|
3093 | case SIZE_2NxnD: |
---|
3094 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
3095 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
3096 | break; |
---|
3097 | case SIZE_nLx2N: |
---|
3098 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
---|
3099 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
3100 | break; |
---|
3101 | case SIZE_nRx2N: |
---|
3102 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
3103 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
---|
3104 | break; |
---|
3105 | default: |
---|
3106 | assert (0); |
---|
3107 | break; |
---|
3108 | } |
---|
3109 | |
---|
3110 | } |
---|
3111 | |
---|
3112 | Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
3113 | { |
---|
3114 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
3115 | |
---|
3116 | switch ( m_pePartSize[0] ) |
---|
3117 | { |
---|
3118 | case SIZE_2Nx2N: |
---|
3119 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
3120 | break; |
---|
3121 | case SIZE_2NxN: |
---|
3122 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
3123 | break; |
---|
3124 | case SIZE_Nx2N: |
---|
3125 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
3126 | break; |
---|
3127 | case SIZE_NxN: |
---|
3128 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
3129 | break; |
---|
3130 | case SIZE_2NxnU: |
---|
3131 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
3132 | break; |
---|
3133 | case SIZE_2NxnD: |
---|
3134 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
3135 | break; |
---|
3136 | case SIZE_nLx2N: |
---|
3137 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
---|
3138 | break; |
---|
3139 | case SIZE_nRx2N: |
---|
3140 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
3141 | break; |
---|
3142 | default: |
---|
3143 | assert (0); |
---|
3144 | break; |
---|
3145 | } |
---|
3146 | } |
---|
3147 | |
---|
3148 | /** Derives the partition index of neighbouring bottom right block |
---|
3149 | * \param [in] eCUMode |
---|
3150 | * \param [in] uiPartIdx |
---|
3151 | * \param [out] ruiPartIdxRB |
---|
3152 | */ |
---|
3153 | Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxRB ) |
---|
3154 | { |
---|
3155 | 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]; |
---|
3156 | |
---|
3157 | switch ( m_pePartSize[0] ) |
---|
3158 | { |
---|
3159 | case SIZE_2Nx2N: |
---|
3160 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
3161 | break; |
---|
3162 | case SIZE_2NxN: |
---|
3163 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
3164 | break; |
---|
3165 | case SIZE_Nx2N: |
---|
3166 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
3167 | break; |
---|
3168 | case SIZE_NxN: |
---|
3169 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
3170 | break; |
---|
3171 | case SIZE_2NxnU: |
---|
3172 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
3173 | break; |
---|
3174 | case SIZE_2NxnD: |
---|
3175 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
3176 | break; |
---|
3177 | case SIZE_nLx2N: |
---|
3178 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
---|
3179 | break; |
---|
3180 | case SIZE_nRx2N: |
---|
3181 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
---|
3182 | break; |
---|
3183 | default: |
---|
3184 | assert (0); |
---|
3185 | break; |
---|
3186 | } |
---|
3187 | } |
---|
3188 | |
---|
3189 | Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ) |
---|
3190 | { |
---|
3191 | UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; |
---|
3192 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset; |
---|
3193 | ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; |
---|
3194 | } |
---|
3195 | |
---|
3196 | Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ) |
---|
3197 | { |
---|
3198 | UInt uiAbsIdx; |
---|
3199 | UInt uiMinCuWidth, uiWidthInMinCus; |
---|
3200 | |
---|
3201 | uiMinCuWidth = getPic()->getMinCUWidth(); |
---|
3202 | uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; |
---|
3203 | uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; |
---|
3204 | uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); |
---|
3205 | ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; |
---|
3206 | } |
---|
3207 | |
---|
3208 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
3209 | { |
---|
3210 | |
---|
3211 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
3212 | { |
---|
3213 | return false; |
---|
3214 | } |
---|
3215 | |
---|
3216 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
3217 | { |
---|
3218 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
3219 | { |
---|
3220 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
3221 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
3222 | { |
---|
3223 | return false; |
---|
3224 | } |
---|
3225 | } |
---|
3226 | } |
---|
3227 | |
---|
3228 | return true; |
---|
3229 | } |
---|
3230 | |
---|
3231 | #if H_3D_VSP |
---|
3232 | |
---|
3233 | /** Add a VSP merging candidate |
---|
3234 | * \Inputs |
---|
3235 | * \param uiPUIdx: PU index within a CU |
---|
3236 | * \param ucVspMergePos: Specify the VSP merge candidate position |
---|
3237 | * \param mrgCandIdx: Target merge candidate index. At encoder, it is set equal to -1, such that the whole merge candidate list will be constructed. |
---|
3238 | * \param pDinfo: The "disparity information" derived from neighboring blocks. Type 1 MV. |
---|
3239 | * \param uiCount: The next position to add VSP merge candidate |
---|
3240 | * |
---|
3241 | * \Outputs |
---|
3242 | * \param uiCount: The next position to add merge candidate. Will be updated if VSP is successfully added |
---|
3243 | * \param abCandIsInter: abCandIsInter[iCount] tells that VSP candidate is an Inter candidate, if VSP is successfully added |
---|
3244 | * \param pcMvFieldNeighbours: Return combined motion information, then stored to a global buffer |
---|
3245 | * 1) the "disparity vector". Type 1 MV. To be used to fetch a depth block. |
---|
3246 | * 2) the ref index /list. Type 2 reference picture pointer, typically for texture |
---|
3247 | * \param puhInterDirNeighbours: Indicate the VSP prediction direction. |
---|
3248 | * \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 |
---|
3249 | * |
---|
3250 | * \Return |
---|
3251 | * true: if the VSP candidate is added at the target position |
---|
3252 | * false: otherwise |
---|
3253 | */ |
---|
3254 | inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount) |
---|
3255 | { |
---|
3256 | if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) || m_pcSlice->getIsDepth() || pDInfo->m_aVIdxCan == -1) |
---|
3257 | { |
---|
3258 | return false; |
---|
3259 | } |
---|
3260 | |
---|
3261 | Int refViewIdx = pDInfo->m_aVIdxCan; |
---|
3262 | TComPic* picDepth = getSlice()->getIvPic( true, refViewIdx ); |
---|
3263 | |
---|
3264 | if( picDepth == NULL ) // No depth reference avail |
---|
3265 | { |
---|
3266 | // Is this allowed to happen? When not an assertion should be added here! |
---|
3267 | return false; |
---|
3268 | } |
---|
3269 | |
---|
3270 | TComMvField mvVSP[2]; |
---|
3271 | UChar dirVSP; |
---|
3272 | Bool refViewAvailFlag = false; |
---|
3273 | UChar predFlag[2] = {0, 0}; |
---|
3274 | |
---|
3275 | for( Int iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ ) |
---|
3276 | { |
---|
3277 | RefPicList eRefPicListX = RefPicList( iRefListIdX ); |
---|
3278 | for ( Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicListX) && !refViewAvailFlag; i++ ) |
---|
3279 | { |
---|
3280 | Int viewIdxRefInListX = m_pcSlice->getRefPic(eRefPicListX, i)->getViewIndex(); |
---|
3281 | if ( viewIdxRefInListX == refViewIdx ) |
---|
3282 | { |
---|
3283 | refViewAvailFlag = true; |
---|
3284 | predFlag[iRefListIdX] = 1; |
---|
3285 | mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i ); |
---|
3286 | #if H_3D_NBDV |
---|
3287 | mvVSP[0+iRefListIdX].getMv().setIDVFlag (false); |
---|
3288 | #endif |
---|
3289 | } |
---|
3290 | } |
---|
3291 | } |
---|
3292 | |
---|
3293 | dirVSP = (predFlag[0] | (predFlag[1] << 1)); |
---|
3294 | m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true, false); |
---|
3295 | if ( mrgCandIdx == iCount ) |
---|
3296 | { |
---|
3297 | return true; |
---|
3298 | } |
---|
3299 | |
---|
3300 | iCount++; |
---|
3301 | |
---|
3302 | return false; |
---|
3303 | } |
---|
3304 | |
---|
3305 | #endif |
---|
3306 | |
---|
3307 | #if H_3D_IV_MERGE |
---|
3308 | inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx ) |
---|
3309 | { |
---|
3310 | for(Int iLoop = 0; iLoop < 2; iLoop ++ ) |
---|
3311 | { |
---|
3312 | // IvDcShift (Derived from spatial Iv neighboring blocks) |
---|
3313 | if( iLoop == 1 ) |
---|
3314 | { |
---|
3315 | Int iFirDispCand = -1; |
---|
3316 | TComMvField mvIvDcShift[2]; |
---|
3317 | UChar dirIvDcShift; |
---|
3318 | |
---|
3319 | if (xGetPosFirstAvailDmvCand(MRG_IVSHIFT, iFirDispCand)) |
---|
3320 | { |
---|
3321 | TComMv cMv; |
---|
3322 | cMv = m_mergCands[iFirDispCand].m_cMvField[0].getMv(); |
---|
3323 | cMv.setHor(cMv.getHor()+4); |
---|
3324 | if(m_pcSlice->getVPS()->getViewSynthesisPredFlag(m_pcSlice->getLayerIdInVps())) |
---|
3325 | { |
---|
3326 | cMv.setVer(0); |
---|
3327 | } |
---|
3328 | #if !(NTT_BUG_FIX_TK54) |
---|
3329 | clipMv( cMv ); |
---|
3330 | #endif |
---|
3331 | |
---|
3332 | dirIvDcShift = m_mergCands[iFirDispCand].m_uDir; |
---|
3333 | mvIvDcShift[0].setMvField(cMv, m_mergCands[iFirDispCand].m_cMvField[0].getRefIdx() ); |
---|
3334 | mvIvDcShift[1].setMvField(m_mergCands[iFirDispCand].m_cMvField[1].getMv(), m_mergCands[iFirDispCand].m_cMvField[1].getRefIdx() ); |
---|
3335 | m_mergCands[MRG_IVSHIFT].setCand(mvIvDcShift, dirIvDcShift, false, false); |
---|
3336 | |
---|
3337 | if( mrgCandIdx == iCount ) |
---|
3338 | { |
---|
3339 | return true; |
---|
3340 | } |
---|
3341 | iCount++; |
---|
3342 | break; |
---|
3343 | } |
---|
3344 | } |
---|
3345 | |
---|
3346 | /// iLoop = 0 --> IvMCShift |
---|
3347 | /// iLoop = 1 --> IvDCShift (Derived from IvDC) |
---|
3348 | if(ivCandDir[iLoop + 2]) |
---|
3349 | { |
---|
3350 | TComMvField tmpMV[2]; |
---|
3351 | UChar tmpDir = ivCandDir[iLoop + 2]; |
---|
3352 | if( ( ivCandDir[iLoop + 2] & 1 ) == 1 ) |
---|
3353 | { |
---|
3354 | tmpMV[0].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] ); |
---|
3355 | } |
---|
3356 | if( ( ivCandDir[iLoop + 2] & 2 ) == 2 ) |
---|
3357 | { |
---|
3358 | tmpMV[1].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] ); |
---|
3359 | } |
---|
3360 | |
---|
3361 | // Prune IvMC vs. IvMcShift |
---|
3362 | Bool bRemove = false; |
---|
3363 | if( !iLoop && ivCandDir[0] > 0) |
---|
3364 | { |
---|
3365 | if(tmpDir == m_mergCands[MRG_IVMC].m_uDir && m_mergCands[MRG_IVMC].m_cMvField[0]==tmpMV[0] && m_mergCands[MRG_IVMC].m_cMvField[1]==tmpMV[1]) |
---|
3366 | { |
---|
3367 | bRemove = true; |
---|
3368 | } |
---|
3369 | } |
---|
3370 | if(!bRemove) |
---|
3371 | { |
---|
3372 | #if H_3D_NBDV |
---|
3373 | if(iLoop) // For IvMcShift candidate |
---|
3374 | { |
---|
3375 | tmpMV[0].getMv().setIDVFlag (false); |
---|
3376 | tmpMV[1].getMv().setIDVFlag (false); |
---|
3377 | } |
---|
3378 | #endif |
---|
3379 | m_mergCands[MRG_IVSHIFT].setCand(tmpMV, tmpDir, false, false); |
---|
3380 | if( mrgCandIdx == iCount ) |
---|
3381 | { |
---|
3382 | return true; |
---|
3383 | } |
---|
3384 | iCount++; |
---|
3385 | } |
---|
3386 | break; |
---|
3387 | } |
---|
3388 | } |
---|
3389 | return false; |
---|
3390 | } |
---|
3391 | |
---|
3392 | inline Bool TComDataCU::xGetPosFirstAvailDmvCand(Int iCount, Int& posFirstAvailDmvCand ) |
---|
3393 | { |
---|
3394 | for ( Int currListPos = 0; currListPos < iCount; currListPos++ ) |
---|
3395 | { |
---|
3396 | if ( !m_mergCands[currListPos].m_bAvailable || ( currListPos == MRG_IVMC ) || ( currListPos == MRG_IVDC ) || ( m_mergCands[currListPos].m_iVspFlag != 0 )) |
---|
3397 | { |
---|
3398 | continue; |
---|
3399 | } |
---|
3400 | else if((m_mergCands[currListPos].m_bAvailable) && (m_mergCands[currListPos].m_cMvField[0].getRefIdx() != -1 ) && (getSlice()->getViewIndex() != getSlice()->getRefPic(RefPicList(0), m_mergCands[currListPos].m_cMvField[0].getRefIdx())->getViewIndex())) |
---|
3401 | { |
---|
3402 | posFirstAvailDmvCand = currListPos; |
---|
3403 | return true; |
---|
3404 | } |
---|
3405 | } |
---|
3406 | return false; |
---|
3407 | } |
---|
3408 | |
---|
3409 | #endif |
---|
3410 | |
---|
3411 | #if H_3D |
---|
3412 | Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
3413 | #if H_3D_VSP |
---|
3414 | , Int* vspFlag |
---|
3415 | #endif |
---|
3416 | #if H_3D_SPIVMP |
---|
3417 | , Bool* pbSPIVMPFlag |
---|
3418 | #endif |
---|
3419 | , Int& numValidMergeCand |
---|
3420 | ) |
---|
3421 | { |
---|
3422 | if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) // for only dependent texture |
---|
3423 | { |
---|
3424 | return; |
---|
3425 | } |
---|
3426 | |
---|
3427 | Int iCount = 0; |
---|
3428 | TComMv cZeroMv; |
---|
3429 | |
---|
3430 | // init temporal list |
---|
3431 | TComMvField extMergeCandList[MRG_MAX_NUM_CANDS_MEM << 1]; |
---|
3432 | UChar uhInterDirNeighboursExt[MRG_MAX_NUM_CANDS_MEM]; |
---|
3433 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
3434 | { |
---|
3435 | uhInterDirNeighboursExt[ui] = puhInterDirNeighbours[ui]; |
---|
3436 | extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID); |
---|
3437 | extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID); |
---|
3438 | vspFlag[ui] = 0; |
---|
3439 | } |
---|
3440 | |
---|
3441 | // add candidates to temporal list |
---|
3442 | // insert MPI ... IvShift candidate |
---|
3443 | for (Int i=0; i<=MRG_IVSHIFT; i++) |
---|
3444 | { |
---|
3445 | if (m_mergCands[i].m_bAvailable) |
---|
3446 | { |
---|
3447 | m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt, vspFlag, pbSPIVMPFlag); |
---|
3448 | iCount++; |
---|
3449 | if (iCount >= getSlice()->getMaxNumMergeCand()) |
---|
3450 | break; |
---|
3451 | } |
---|
3452 | } |
---|
3453 | |
---|
3454 | // insert remaining base candidates |
---|
3455 | while (iCount < getSlice()->getMaxNumMergeCand() && m_baseListidc < getSlice()->getMaxNumMergeCand()) |
---|
3456 | { |
---|
3457 | uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[m_baseListidc]; |
---|
3458 | extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[m_baseListidc<<1].getMv(), pcMvFieldNeighbours[m_baseListidc<<1].getRefIdx()); |
---|
3459 | if ( getSlice()->isInterB() ) |
---|
3460 | { |
---|
3461 | extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(m_baseListidc<<1)+1].getMv(), pcMvFieldNeighbours[(m_baseListidc<<1)+1].getRefIdx()); |
---|
3462 | } |
---|
3463 | m_baseListidc++; |
---|
3464 | iCount++; |
---|
3465 | } |
---|
3466 | |
---|
3467 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ ) |
---|
3468 | { |
---|
3469 | puhInterDirNeighbours[ui] = 0; |
---|
3470 | pcMvFieldNeighbours[ui<<1].setMvField(cZeroMv, NOT_VALID); |
---|
3471 | pcMvFieldNeighbours[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID); |
---|
3472 | } |
---|
3473 | // copy extMergeCandList to output |
---|
3474 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ ) |
---|
3475 | { |
---|
3476 | puhInterDirNeighbours[ui] = uhInterDirNeighboursExt[ui]; |
---|
3477 | pcMvFieldNeighbours[ui<<1].setMvField(extMergeCandList[ui<<1].getMv(), extMergeCandList[ui<<1].getRefIdx()); |
---|
3478 | if ( getSlice()->isInterB() ) |
---|
3479 | pcMvFieldNeighbours[(ui<<1)+1].setMvField(extMergeCandList[(ui<<1)+1].getMv(), extMergeCandList[(ui<<1)+1].getRefIdx()); |
---|
3480 | } |
---|
3481 | numValidMergeCand = iCount; |
---|
3482 | assert(iCount == getSlice()->getMaxNumMergeCand()); |
---|
3483 | } |
---|
3484 | |
---|
3485 | /** Constructs a list of merging candidates |
---|
3486 | * \param uiAbsPartIdx |
---|
3487 | * \param uiPUIdx |
---|
3488 | * \param uiDepth |
---|
3489 | * \param pcMvFieldNeighbours |
---|
3490 | * \param puhInterDirNeighbours |
---|
3491 | * \param numValidMergeCand |
---|
3492 | */ |
---|
3493 | // HM 12.0 based merge candidate list construction |
---|
3494 | |
---|
3495 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) |
---|
3496 | { |
---|
3497 | |
---|
3498 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
3499 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ]; |
---|
3500 | TComMv cZeroMv; |
---|
3501 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
3502 | { |
---|
3503 | abCandIsInter[ui] = false; |
---|
3504 | pcMvFieldNeighbours[ ( ui << 1 ) ].setMvField(cZeroMv, NOT_VALID); |
---|
3505 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID); |
---|
3506 | } |
---|
3507 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
3508 | // compute the location of the current PU |
---|
3509 | Int xP, yP, nPSW, nPSH; |
---|
3510 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
3511 | |
---|
3512 | Int iCount = 0; |
---|
3513 | |
---|
3514 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
3515 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
3516 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
3517 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
3518 | |
---|
3519 | //left |
---|
3520 | UInt uiLeftPartIdx = 0; |
---|
3521 | TComDataCU* pcCULeft = 0; |
---|
3522 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
3523 | Bool isAvailableA1 = pcCULeft && |
---|
3524 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
3525 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
3526 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
---|
3527 | if ( isAvailableA1 ) |
---|
3528 | { |
---|
3529 | m_bAvailableFlagA1 = 1; |
---|
3530 | abCandIsInter[iCount] = true; |
---|
3531 | // get Inter Dir |
---|
3532 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
3533 | // get Mv from Left |
---|
3534 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3535 | if ( getSlice()->isInterB() ) |
---|
3536 | { |
---|
3537 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3538 | } |
---|
3539 | |
---|
3540 | iCount ++; |
---|
3541 | } |
---|
3542 | |
---|
3543 | // early termination |
---|
3544 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3545 | { |
---|
3546 | return; |
---|
3547 | } |
---|
3548 | // above |
---|
3549 | UInt uiAbovePartIdx = 0; |
---|
3550 | TComDataCU* pcCUAbove = 0; |
---|
3551 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
3552 | Bool isAvailableB1 = pcCUAbove && |
---|
3553 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
3554 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
3555 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
---|
3556 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
3557 | { |
---|
3558 | m_bAvailableFlagB1 = 1; |
---|
3559 | abCandIsInter[iCount] = true; |
---|
3560 | // get Inter Dir |
---|
3561 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
3562 | // get Mv from Left |
---|
3563 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3564 | if ( getSlice()->isInterB() ) |
---|
3565 | { |
---|
3566 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3567 | } |
---|
3568 | if ( mrgCandIdx == iCount ) |
---|
3569 | { |
---|
3570 | return; |
---|
3571 | } |
---|
3572 | iCount ++; |
---|
3573 | } |
---|
3574 | // early termination |
---|
3575 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3576 | { |
---|
3577 | return; |
---|
3578 | } |
---|
3579 | |
---|
3580 | // above right |
---|
3581 | UInt uiAboveRightPartIdx = 0; |
---|
3582 | TComDataCU* pcCUAboveRight = 0; |
---|
3583 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
3584 | Bool isAvailableB0 = pcCUAboveRight && |
---|
3585 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
3586 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
---|
3587 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
3588 | { |
---|
3589 | m_bAvailableFlagB0 = 1; |
---|
3590 | abCandIsInter[iCount] = true; |
---|
3591 | // get Inter Dir |
---|
3592 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
3593 | // get Mv from Left |
---|
3594 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3595 | if ( getSlice()->isInterB() ) |
---|
3596 | { |
---|
3597 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3598 | } |
---|
3599 | if ( mrgCandIdx == iCount ) |
---|
3600 | { |
---|
3601 | return; |
---|
3602 | } |
---|
3603 | iCount ++; |
---|
3604 | } |
---|
3605 | // early termination |
---|
3606 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3607 | { |
---|
3608 | return; |
---|
3609 | } |
---|
3610 | |
---|
3611 | //left bottom |
---|
3612 | UInt uiLeftBottomPartIdx = 0; |
---|
3613 | TComDataCU* pcCULeftBottom = 0; |
---|
3614 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
3615 | Bool isAvailableA0 = pcCULeftBottom && |
---|
3616 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
3617 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
---|
3618 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
3619 | { |
---|
3620 | m_bAvailableFlagA0 = 1; |
---|
3621 | abCandIsInter[iCount] = true; |
---|
3622 | // get Inter Dir |
---|
3623 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
3624 | // get Mv from Left |
---|
3625 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3626 | if ( getSlice()->isInterB() ) |
---|
3627 | { |
---|
3628 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3629 | } |
---|
3630 | if ( mrgCandIdx == iCount ) |
---|
3631 | { |
---|
3632 | return; |
---|
3633 | } |
---|
3634 | iCount ++; |
---|
3635 | } |
---|
3636 | // early termination |
---|
3637 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3638 | { |
---|
3639 | return; |
---|
3640 | } |
---|
3641 | // above left |
---|
3642 | if( iCount < 4 ) |
---|
3643 | { |
---|
3644 | UInt uiAboveLeftPartIdx = 0; |
---|
3645 | TComDataCU* pcCUAboveLeft = 0; |
---|
3646 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
3647 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
3648 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
3649 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
---|
3650 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
3651 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
3652 | { |
---|
3653 | m_bAvailableFlagB2 = 1; |
---|
3654 | abCandIsInter[iCount] = true; |
---|
3655 | // get Inter Dir |
---|
3656 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
3657 | // get Mv from Left |
---|
3658 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
3659 | if ( getSlice()->isInterB() ) |
---|
3660 | { |
---|
3661 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
3662 | } |
---|
3663 | if ( mrgCandIdx == iCount ) |
---|
3664 | { |
---|
3665 | return; |
---|
3666 | } |
---|
3667 | iCount ++; |
---|
3668 | } |
---|
3669 | } |
---|
3670 | // early termination |
---|
3671 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3672 | { |
---|
3673 | return; |
---|
3674 | } |
---|
3675 | if ( getSlice()->getEnableTMVPFlag()) |
---|
3676 | { |
---|
3677 | //>> MTK colocated-RightBottom |
---|
3678 | UInt uiPartIdxRB; |
---|
3679 | |
---|
3680 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
3681 | |
---|
3682 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
3683 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
3684 | |
---|
3685 | TComMv cColMv; |
---|
3686 | Int iRefIdx; |
---|
3687 | Int uiLCUIdx = -1; |
---|
3688 | |
---|
3689 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
3690 | { |
---|
3691 | } |
---|
3692 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
3693 | { |
---|
3694 | } |
---|
3695 | else |
---|
3696 | { |
---|
3697 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
3698 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
3699 | { |
---|
3700 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
3701 | uiLCUIdx = getAddr(); |
---|
3702 | } |
---|
3703 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
3704 | { |
---|
3705 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
3706 | } |
---|
3707 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
3708 | { |
---|
3709 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
3710 | uiLCUIdx = getAddr() + 1; |
---|
3711 | } |
---|
3712 | else //is the right bottom corner of LCU |
---|
3713 | { |
---|
3714 | uiAbsPartAddr = 0; |
---|
3715 | } |
---|
3716 | } |
---|
3717 | |
---|
3718 | iRefIdx = 0; |
---|
3719 | Bool bExistMV = false; |
---|
3720 | UInt uiPartIdxCenter; |
---|
3721 | UInt uiCurLCUIdx = getAddr(); |
---|
3722 | Int dir = 0; |
---|
3723 | UInt uiArrayAddr = iCount; |
---|
3724 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
3725 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
3726 | if( bExistMV == false ) |
---|
3727 | { |
---|
3728 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
3729 | } |
---|
3730 | if( bExistMV ) |
---|
3731 | { |
---|
3732 | dir |= 1; |
---|
3733 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
3734 | } |
---|
3735 | |
---|
3736 | if ( getSlice()->isInterB() ) |
---|
3737 | { |
---|
3738 | #if H_3D_TMVP |
---|
3739 | iRefIdx = 0; |
---|
3740 | #endif |
---|
3741 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
3742 | if( bExistMV == false ) |
---|
3743 | { |
---|
3744 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
3745 | } |
---|
3746 | if( bExistMV ) |
---|
3747 | { |
---|
3748 | dir |= 2; |
---|
3749 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
3750 | } |
---|
3751 | } |
---|
3752 | |
---|
3753 | if (dir != 0) |
---|
3754 | { |
---|
3755 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
3756 | abCandIsInter[uiArrayAddr] = true; |
---|
3757 | #if H_3D_NBDV |
---|
3758 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
---|
3759 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
---|
3760 | #endif |
---|
3761 | if ( mrgCandIdx == iCount ) |
---|
3762 | { |
---|
3763 | return; |
---|
3764 | } |
---|
3765 | iCount++; |
---|
3766 | } |
---|
3767 | } |
---|
3768 | // early termination |
---|
3769 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
3770 | { |
---|
3771 | return; |
---|
3772 | } |
---|
3773 | UInt uiArrayAddr = iCount; |
---|
3774 | UInt uiCutoff = uiArrayAddr; |
---|
3775 | |
---|
3776 | if ( getSlice()->isInterB() && iCount<5) // JCT3V-F0129 by Qualcomm |
---|
3777 | { |
---|
3778 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
3779 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
3780 | |
---|
3781 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
3782 | { |
---|
3783 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
3784 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
3785 | { |
---|
3786 | abCandIsInter[uiArrayAddr] = true; |
---|
3787 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3788 | |
---|
3789 | // get Mv from cand[i] and cand[j] |
---|
3790 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
3791 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
3792 | |
---|
3793 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
3794 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
3795 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
3796 | { |
---|
3797 | abCandIsInter[uiArrayAddr] = false; |
---|
3798 | } |
---|
3799 | else |
---|
3800 | { |
---|
3801 | uiArrayAddr++; |
---|
3802 | } |
---|
3803 | } |
---|
3804 | } |
---|
3805 | } |
---|
3806 | // early termination |
---|
3807 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
3808 | { |
---|
3809 | return; |
---|
3810 | } |
---|
3811 | |
---|
3812 | 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); |
---|
3813 | Int r = 0; |
---|
3814 | Int refcnt = 0; |
---|
3815 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
3816 | { |
---|
3817 | abCandIsInter[uiArrayAddr] = true; |
---|
3818 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
3819 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
3820 | |
---|
3821 | if ( getSlice()->isInterB() ) |
---|
3822 | { |
---|
3823 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
3824 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
3825 | } |
---|
3826 | uiArrayAddr++; |
---|
3827 | if ( refcnt == iNumRefIdx - 1 ) |
---|
3828 | { |
---|
3829 | r = 0; |
---|
3830 | } |
---|
3831 | else |
---|
3832 | { |
---|
3833 | ++r; |
---|
3834 | ++refcnt; |
---|
3835 | } |
---|
3836 | } |
---|
3837 | |
---|
3838 | numValidMergeCand = uiArrayAddr; |
---|
3839 | } |
---|
3840 | |
---|
3841 | |
---|
3842 | |
---|
3843 | /** Constructs a list of merging candidates |
---|
3844 | * \param uiAbsPartIdx |
---|
3845 | * \param uiPUIdx |
---|
3846 | * \param uiDepth |
---|
3847 | * \param pcMvFieldNeighbours |
---|
3848 | * \param puhInterDirNeighbours |
---|
3849 | * \param numValidMergeCand |
---|
3850 | */ |
---|
3851 | #if H_3D |
---|
3852 | Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
3853 | #else |
---|
3854 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
3855 | #endif |
---|
3856 | #if H_3D_VSP |
---|
3857 | , InheritedVSPDisInfo* inheritedVSPDisInfo |
---|
3858 | #endif |
---|
3859 | #if H_3D_SPIVMP |
---|
3860 | , TComMvField* pcMvFieldSP, UChar* puhInterDirSP |
---|
3861 | #endif |
---|
3862 | , Int& numValidMergeCand, Int mrgCandIdx |
---|
3863 | ) |
---|
3864 | { |
---|
3865 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
3866 | #if H_3D_IV_MERGE |
---|
3867 | //////////////////////////// |
---|
3868 | //////// INIT LISTS //////// |
---|
3869 | //////////////////////////// |
---|
3870 | TComMv cZeroMv; |
---|
3871 | #else |
---|
3872 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
3873 | #endif |
---|
3874 | #if H_3D |
---|
3875 | TComMvField tmpMV[2]; |
---|
3876 | UChar tmpDir; |
---|
3877 | |
---|
3878 | #if H_3D_DDD |
---|
3879 | m_iUseDDDCandIdx = -1; |
---|
3880 | #endif |
---|
3881 | |
---|
3882 | ////////////////////////////////// |
---|
3883 | //////// GET DISPARITIES //////// |
---|
3884 | ////////////////////////////////// |
---|
3885 | DisInfo cDisInfo = getDvInfo(uiAbsPartIdx); |
---|
3886 | for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) |
---|
3887 | { |
---|
3888 | inheritedVSPDisInfo[i].m_acDvInfo = cDisInfo; // To prevent run-time error, this code must be executed always for merging process. |
---|
3889 | } |
---|
3890 | m_cDefaultDisInfo = cDisInfo; |
---|
3891 | |
---|
3892 | if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) // current slice is not both dependent view or depth |
---|
3893 | { |
---|
3894 | return; |
---|
3895 | } |
---|
3896 | #else |
---|
3897 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
3898 | { |
---|
3899 | abCandIsInter[ui] = false; |
---|
3900 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
3901 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
3902 | } |
---|
3903 | #endif |
---|
3904 | |
---|
3905 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
3906 | #if H_3D |
---|
3907 | ////////////////////////////////// |
---|
3908 | //////// DERIVE LOCATIONS //////// |
---|
3909 | ////////////////////////////////// |
---|
3910 | #endif |
---|
3911 | // compute the location of the current PU |
---|
3912 | Int xP, yP, nPSW, nPSH; |
---|
3913 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
3914 | |
---|
3915 | Int iCount = 0; |
---|
3916 | |
---|
3917 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
3918 | #if !H_3D |
---|
3919 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
3920 | #endif |
---|
3921 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
3922 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
3923 | #if H_3D |
---|
3924 | Bool bMPIFlag = getSlice()->getVPS()->getMPIFlag( getSlice()->getLayerIdInVps() ); |
---|
3925 | Bool bIsDepth = getSlice()->getIsDepth(); |
---|
3926 | #endif |
---|
3927 | |
---|
3928 | #if H_3D_IC |
---|
3929 | Bool bICFlag = getICFlag(uiAbsPartIdx); |
---|
3930 | #endif |
---|
3931 | #if H_3D_ARP |
---|
3932 | Bool bARPFlag = getARPW(uiAbsPartIdx)>0 ? true : false; |
---|
3933 | #endif |
---|
3934 | #if H_3D_DBBP |
---|
3935 | Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx); |
---|
3936 | assert(bDBBPFlag == getDBBPFlag(0)); |
---|
3937 | #endif |
---|
3938 | |
---|
3939 | #if H_3D |
---|
3940 | #if H_3D_NBDV |
---|
3941 | for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) |
---|
3942 | { |
---|
3943 | pcMvFieldNeighbours[i<<1 ].getMv().setIDVFlag (false); |
---|
3944 | pcMvFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false); |
---|
3945 | } |
---|
3946 | #endif |
---|
3947 | // Clean version for MCL construction align with WD |
---|
3948 | // init mergCands list |
---|
3949 | for (Int i = 0; i<MRG_IVSHIFT+1; i++) |
---|
3950 | { |
---|
3951 | m_mergCands[i].init(); |
---|
3952 | } |
---|
3953 | |
---|
3954 | m_baseListidc = 0; |
---|
3955 | |
---|
3956 | //left |
---|
3957 | UInt uiLeftPartIdx = 0; |
---|
3958 | TComDataCU* pcCULeft = 0; |
---|
3959 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
3960 | |
---|
3961 | if (getAvailableFlagA1()) |
---|
3962 | { |
---|
3963 | m_mergCands[MRG_A1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3964 | #if H_3D_VSP |
---|
3965 | , |
---|
3966 | (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0 |
---|
3967 | #if H_3D_IC |
---|
3968 | && !bICFlag |
---|
3969 | #endif |
---|
3970 | #if H_3D_ARP |
---|
3971 | && !bARPFlag |
---|
3972 | #endif |
---|
3973 | #if H_3D_DBBP |
---|
3974 | && !bDBBPFlag |
---|
3975 | #endif |
---|
3976 | ) |
---|
3977 | #endif |
---|
3978 | , false |
---|
3979 | ); |
---|
3980 | m_baseListidc++; |
---|
3981 | } |
---|
3982 | |
---|
3983 | // above |
---|
3984 | UInt uiAbovePartIdx = 0; |
---|
3985 | TComDataCU* pcCUAbove = 0; |
---|
3986 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
3987 | |
---|
3988 | if (getAvailableFlagB1()) |
---|
3989 | { |
---|
3990 | m_mergCands[MRG_B1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
3991 | #if H_3D_VSP |
---|
3992 | , |
---|
3993 | ( ( ( getAddr() - pcCUAbove->getAddr() ) == 0) && (pcCUAbove->getVSPFlag(uiAbovePartIdx) != 0) |
---|
3994 | #if H_3D_IC |
---|
3995 | && !bICFlag |
---|
3996 | #endif |
---|
3997 | #if H_3D_ARP |
---|
3998 | && !bARPFlag |
---|
3999 | #endif |
---|
4000 | #if H_3D_DBBP |
---|
4001 | && !bDBBPFlag |
---|
4002 | #endif |
---|
4003 | ) |
---|
4004 | #endif |
---|
4005 | , false |
---|
4006 | ); |
---|
4007 | m_baseListidc++; |
---|
4008 | } |
---|
4009 | |
---|
4010 | // above right |
---|
4011 | UInt uiAboveRightPartIdx = 0; |
---|
4012 | TComDataCU* pcCUAboveRight = 0; |
---|
4013 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
4014 | |
---|
4015 | if (getAvailableFlagB0()) |
---|
4016 | { |
---|
4017 | m_mergCands[MRG_B0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
4018 | #if H_3D_VSP |
---|
4019 | , |
---|
4020 | ( ( ( getAddr() - pcCUAboveRight->getAddr() ) == 0) && (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) != 0) |
---|
4021 | #if H_3D_IC |
---|
4022 | && !bICFlag |
---|
4023 | #endif |
---|
4024 | #if H_3D_ARP |
---|
4025 | && !bARPFlag |
---|
4026 | #endif |
---|
4027 | #if H_3D_DBBP |
---|
4028 | && !bDBBPFlag |
---|
4029 | #endif |
---|
4030 | ) |
---|
4031 | #endif |
---|
4032 | , false |
---|
4033 | ); |
---|
4034 | m_baseListidc++; |
---|
4035 | } |
---|
4036 | |
---|
4037 | // left bottom |
---|
4038 | UInt uiLeftBottomPartIdx = 0; |
---|
4039 | TComDataCU* pcCULeftBottom = getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
4040 | |
---|
4041 | if (getAvailableFlagA0()) |
---|
4042 | { |
---|
4043 | m_mergCands[MRG_A0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
4044 | #if H_3D_VSP |
---|
4045 | , |
---|
4046 | (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) != 0 |
---|
4047 | #if H_3D_IC |
---|
4048 | && !bICFlag |
---|
4049 | #endif |
---|
4050 | #if H_3D_ARP |
---|
4051 | && !bARPFlag |
---|
4052 | #endif |
---|
4053 | #if H_3D_DBBP |
---|
4054 | && !bDBBPFlag |
---|
4055 | #endif |
---|
4056 | ) |
---|
4057 | #endif |
---|
4058 | , false |
---|
4059 | ); |
---|
4060 | m_baseListidc++; |
---|
4061 | } |
---|
4062 | |
---|
4063 | // above left |
---|
4064 | UInt uiAboveLeftPartIdx = 0; |
---|
4065 | TComDataCU* pcCUAboveLeft = 0; |
---|
4066 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
4067 | |
---|
4068 | if (getAvailableFlagB2()) |
---|
4069 | { |
---|
4070 | m_mergCands[MRG_B2].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc] |
---|
4071 | #if H_3D_VSP |
---|
4072 | , |
---|
4073 | ( ( ( getAddr() - pcCUAboveLeft->getAddr() ) == 0) && (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) != 0) |
---|
4074 | #if H_3D_IC |
---|
4075 | && !bICFlag |
---|
4076 | #endif |
---|
4077 | #if H_3D_ARP |
---|
4078 | && !bARPFlag |
---|
4079 | #endif |
---|
4080 | #if H_3D_DBBP |
---|
4081 | && !bDBBPFlag |
---|
4082 | #endif |
---|
4083 | ) |
---|
4084 | #endif |
---|
4085 | , false |
---|
4086 | ); |
---|
4087 | m_baseListidc++; |
---|
4088 | } |
---|
4089 | |
---|
4090 | #endif |
---|
4091 | |
---|
4092 | |
---|
4093 | #if H_3D_IV_MERGE |
---|
4094 | |
---|
4095 | ///////////////////////////////////////////// |
---|
4096 | //////// TEXTURE MERGE CANDIDATE (T) //////// |
---|
4097 | ///////////////////////////////////////////// |
---|
4098 | |
---|
4099 | bMPIFlag &= (nPSW + nPSH > 12); |
---|
4100 | if( bMPIFlag) |
---|
4101 | { |
---|
4102 | tmpMV[0].setMvField( cZeroMv, NOT_VALID ); |
---|
4103 | tmpMV[1].setMvField( cZeroMv, NOT_VALID ); |
---|
4104 | tmpDir = 0; |
---|
4105 | |
---|
4106 | Bool bSPIVMPFlag = false; |
---|
4107 | |
---|
4108 | TComPic * pcTexPic = m_pcSlice->getTexturePic(); |
---|
4109 | #if H_3D_FCO |
---|
4110 | if (pcTexturePic->getReconMark()) |
---|
4111 | { |
---|
4112 | #endif |
---|
4113 | TComPicYuv* pcTexRec = pcTexPic->getPicYuvRec (); |
---|
4114 | UInt uiPartAddr; |
---|
4115 | Int iWidth, iHeight; |
---|
4116 | Int iCurrPosX, iCurrPosY; |
---|
4117 | |
---|
4118 | this->getPartIndexAndSize( uiPUIdx, uiPartAddr, iWidth, iHeight ); |
---|
4119 | pcTexRec->getTopLeftSamplePos( this->getAddr(), this->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
4120 | |
---|
4121 | Int iPUWidth, iPUHeight, iNumPart, iNumPartLine; |
---|
4122 | this->getSPPara(iWidth, iHeight, iNumPart, iNumPartLine, iPUWidth, iPUHeight); |
---|
4123 | |
---|
4124 | for (Int i=0; i<iNumPart; i++) |
---|
4125 | { |
---|
4126 | puhInterDirSP[i] = 0; |
---|
4127 | pcMvFieldSP[2*i].getMv().set(0, 0); |
---|
4128 | pcMvFieldSP[2*i+1].getMv().set(0, 0); |
---|
4129 | pcMvFieldSP[2*i].setRefIdx(-1); |
---|
4130 | pcMvFieldSP[2*i+1].setRefIdx(-1); |
---|
4131 | } |
---|
4132 | |
---|
4133 | Int iTexCUAddr; |
---|
4134 | Int iTexAbsPartIdx; |
---|
4135 | TComDataCU* pcTexCU; |
---|
4136 | Int iPartition = 0; |
---|
4137 | Int iInterDirSaved = 0; |
---|
4138 | TComMvField cMvFieldSaved[2]; |
---|
4139 | |
---|
4140 | Int iOffsetX = iPUWidth/2;; |
---|
4141 | Int iOffsetY = iPUHeight/2; |
---|
4142 | |
---|
4143 | Int iTexPosX, iTexPosY; |
---|
4144 | const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); |
---|
4145 | |
---|
4146 | Int iCenterPosX = iCurrPosX + ( ( iWidth / iPUWidth ) >> 1 ) * iPUWidth + ( iPUWidth >> 1 ); |
---|
4147 | Int iCenterPosY = iCurrPosY + ( ( iHeight / iPUHeight ) >> 1 ) * iPUHeight + (iPUHeight >> 1); |
---|
4148 | Int iTexCenterCUAddr, iTexCenterAbsPartIdx; |
---|
4149 | |
---|
4150 | if(iWidth == iPUWidth && iHeight == iPUHeight) |
---|
4151 | { |
---|
4152 | iCenterPosX = iCurrPosX + (iWidth >> 1); |
---|
4153 | iCenterPosY = iCurrPosY + (iHeight >> 1); |
---|
4154 | } |
---|
4155 | |
---|
4156 | // derivation of center motion parameters from the collocated texture CU |
---|
4157 | |
---|
4158 | pcTexRec->getCUAddrAndPartIdx( iCenterPosX , iCenterPosY , iTexCenterCUAddr, iTexCenterAbsPartIdx ); |
---|
4159 | TComDataCU* pcDefaultCU = pcTexPic->getCU( iTexCenterCUAddr ); |
---|
4160 | |
---|
4161 | if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA ) |
---|
4162 | { |
---|
4163 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
4164 | { |
---|
4165 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
4166 | |
---|
4167 | TComMvField cDefaultMvField; |
---|
4168 | pcDefaultCU->getMvField( pcDefaultCU, iTexCenterAbsPartIdx, eCurrRefPicList, cDefaultMvField ); |
---|
4169 | Int iDefaultRefIdx = cDefaultMvField.getRefIdx(); |
---|
4170 | if (iDefaultRefIdx >= 0) |
---|
4171 | { |
---|
4172 | Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eCurrRefPicList, iDefaultRefIdx); |
---|
4173 | for (Int iRefPicList = 0; iRefPicList < m_pcSlice->getNumRefIdx( eCurrRefPicList ); iRefPicList++) |
---|
4174 | { |
---|
4175 | if (iDefaultRefPOC == m_pcSlice->getRefPOC(eCurrRefPicList, iRefPicList)) |
---|
4176 | { |
---|
4177 | bSPIVMPFlag = true; |
---|
4178 | TComMv cMv = cDefaultMvField.getMv() + cMvRounding; |
---|
4179 | cMv >>= 2; |
---|
4180 | clipMv( cMv ); |
---|
4181 | cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ; |
---|
4182 | break; |
---|
4183 | } |
---|
4184 | } |
---|
4185 | } |
---|
4186 | } |
---|
4187 | } |
---|
4188 | if ( bSPIVMPFlag == true ) |
---|
4189 | { |
---|
4190 | iInterDirSaved = (cMvFieldSaved[0].getRefIdx()!=-1 ? 1: 0) + (cMvFieldSaved[1].getRefIdx()!=-1 ? 2: 0); |
---|
4191 | tmpDir = iInterDirSaved; |
---|
4192 | tmpMV[0] = cMvFieldSaved[0]; |
---|
4193 | tmpMV[1] = cMvFieldSaved[1]; |
---|
4194 | } |
---|
4195 | |
---|
4196 | if ( iInterDirSaved != 0 ) |
---|
4197 | { |
---|
4198 | for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iPUHeight) |
---|
4199 | { |
---|
4200 | for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iPUWidth) |
---|
4201 | { |
---|
4202 | iTexPosX = j + iOffsetX; |
---|
4203 | iTexPosY = i + iOffsetY; |
---|
4204 | pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx ); |
---|
4205 | pcTexCU = pcTexPic->getCU( iTexCUAddr ); |
---|
4206 | |
---|
4207 | if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) ) |
---|
4208 | { |
---|
4209 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
4210 | { |
---|
4211 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
4212 | TComMvField cTexMvField; |
---|
4213 | pcTexCU->getMvField( pcTexCU, iTexAbsPartIdx, eCurrRefPicList, cTexMvField ); |
---|
4214 | Int iValidDepRef = getPic()->isTextRefValid( eCurrRefPicList, cTexMvField.getRefIdx() ); |
---|
4215 | if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) ) |
---|
4216 | { |
---|
4217 | TComMv cMv = cTexMvField.getMv() + cMvRounding; |
---|
4218 | cMv >>=2; |
---|
4219 | #if !(NTT_BUG_FIX_TK54) |
---|
4220 | this->clipMv( cMv ); |
---|
4221 | #endif |
---|
4222 | pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef); |
---|
4223 | } |
---|
4224 | } |
---|
4225 | } |
---|
4226 | puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0); |
---|
4227 | if (puhInterDirSP[iPartition] == 0) |
---|
4228 | { |
---|
4229 | if (iInterDirSaved != 0) |
---|
4230 | { |
---|
4231 | puhInterDirSP[iPartition] = iInterDirSaved; |
---|
4232 | pcMvFieldSP[2*iPartition] = cMvFieldSaved[0]; |
---|
4233 | pcMvFieldSP[2*iPartition + 1] = cMvFieldSaved[1]; |
---|
4234 | } |
---|
4235 | } |
---|
4236 | if (iPUHeight + iPUWidth == 12) |
---|
4237 | { |
---|
4238 | if (puhInterDirSP[iPartition] == 3) |
---|
4239 | { |
---|
4240 | puhInterDirSP[iPartition] = 1; |
---|
4241 | pcMvFieldSP[2*iPartition + 1].setMvField(TComMv(0,0), -1); |
---|
4242 | } |
---|
4243 | } |
---|
4244 | |
---|
4245 | iPartition ++; |
---|
4246 | } |
---|
4247 | } |
---|
4248 | #if H_3D |
---|
4249 | } |
---|
4250 | #endif |
---|
4251 | #if H_3D_FCO |
---|
4252 | } |
---|
4253 | #endif |
---|
4254 | if( tmpDir != 0 ) |
---|
4255 | { |
---|
4256 | Int iCnloop = 0; |
---|
4257 | for(iCnloop = 0; iCnloop < 2; iCnloop ++) |
---|
4258 | { |
---|
4259 | if ( !m_mergCands[MRG_A1+iCnloop].m_bAvailable ) // prunning to A1, B1 |
---|
4260 | { |
---|
4261 | continue; |
---|
4262 | } |
---|
4263 | if (tmpDir == m_mergCands[MRG_A1+iCnloop].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+iCnloop].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+iCnloop].m_cMvField[1]) |
---|
4264 | { |
---|
4265 | m_mergCands[MRG_A1+iCnloop].m_bAvailable = false; |
---|
4266 | break; |
---|
4267 | } |
---|
4268 | } |
---|
4269 | m_mergCands[MRG_T].setCand( tmpMV, tmpDir, false, bSPIVMPFlag); |
---|
4270 | |
---|
4271 | if ( mrgCandIdx == iCount ) |
---|
4272 | { |
---|
4273 | return; |
---|
4274 | } |
---|
4275 | iCount ++; |
---|
4276 | } |
---|
4277 | } |
---|
4278 | #if H_3D_DDD |
---|
4279 | if( m_pcSlice->getIsDepth() && m_pcSlice->getViewIndex() != 0 && bMPIFlag ) |
---|
4280 | { |
---|
4281 | UInt uiPartIdx; |
---|
4282 | TComDataCU *pcTextureCU = m_pcSlice->getTexturePic()->getCU( getAddr() ); |
---|
4283 | TComSlice *pcTextureSlice = pcTextureCU->getSlice(); |
---|
4284 | |
---|
4285 | |
---|
4286 | tmpMV[0].setMvField( cZeroMv, NOT_VALID ); |
---|
4287 | tmpMV[1].setMvField( cZeroMv, NOT_VALID ); |
---|
4288 | tmpDir = 0; |
---|
4289 | |
---|
4290 | xDeriveCenterIdx( uiPUIdx, uiPartIdx); |
---|
4291 | |
---|
4292 | if ( pcTextureCU && !pcTextureCU->isIntra( uiPartIdx ) ) |
---|
4293 | { |
---|
4294 | |
---|
4295 | TComMvField cMVField; |
---|
4296 | Int iDV = 0; |
---|
4297 | Int iViewIdx = 0; |
---|
4298 | pcTextureCU->getMvField( pcTextureCU, uiPartIdx, REF_PIC_LIST_0, cMVField ); |
---|
4299 | if( cMVField.getRefIdx() >= 0 ) |
---|
4300 | { |
---|
4301 | if( pcTextureSlice->getRefPOC( REF_PIC_LIST_0, cMVField.getRefIdx()) == pcTextureSlice->getPOC() ) |
---|
4302 | { |
---|
4303 | iViewIdx = pcTextureSlice->getRefPic( REF_PIC_LIST_0, cMVField.getRefIdx())->getViewIndex(); |
---|
4304 | iDV = cMVField.getHor(); |
---|
4305 | |
---|
4306 | |
---|
4307 | Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_0, cMVField.getRefIdx() ); |
---|
4308 | |
---|
4309 | if( iValidDepRef >= 0 ) |
---|
4310 | { |
---|
4311 | const TComMv cAdd( 2, 2 ); |
---|
4312 | cMVField.getMv() += cAdd; |
---|
4313 | cMVField.getMv() >>= 2; |
---|
4314 | #if !(NTT_BUG_FIX_TK54) |
---|
4315 | clipMv( cMVField.getMv() ); |
---|
4316 | #endif |
---|
4317 | tmpMV[ 0 ].setMvField( cMVField.getMv(), iValidDepRef ); |
---|
4318 | tmpDir = 1; |
---|
4319 | } |
---|
4320 | } |
---|
4321 | } |
---|
4322 | |
---|
4323 | pcTextureCU->getMvField( pcTextureCU, uiPartIdx, REF_PIC_LIST_1, cMVField ); |
---|
4324 | |
---|
4325 | if( !tmpDir && cMVField.getRefIdx() >= 0 ) |
---|
4326 | { |
---|
4327 | if( pcTextureSlice->getRefPOC( REF_PIC_LIST_1, cMVField.getRefIdx()) == pcTextureSlice->getPOC() ) |
---|
4328 | { |
---|
4329 | iViewIdx = pcTextureSlice->getRefPic( REF_PIC_LIST_1, cMVField.getRefIdx())->getViewIndex(); |
---|
4330 | iDV = cMVField.getHor(); |
---|
4331 | |
---|
4332 | Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_1, cMVField.getRefIdx() ); |
---|
4333 | |
---|
4334 | if( iValidDepRef >= 0 ) |
---|
4335 | { |
---|
4336 | const TComMv cAdd( 2, 2 ); |
---|
4337 | cMVField.getMv() += cAdd; |
---|
4338 | cMVField.getMv() >>= 2; |
---|
4339 | #if !(NTT_BUG_FIX_TK54) |
---|
4340 | clipMv( cMVField.getMv() ); |
---|
4341 | #endif |
---|
4342 | tmpMV[ 1 ].setMvField( cMVField.getMv(), iValidDepRef ); |
---|
4343 | tmpDir = 2; |
---|
4344 | } |
---|
4345 | } |
---|
4346 | } |
---|
4347 | if( tmpDir != 0 ) |
---|
4348 | { |
---|
4349 | m_ucDDTmpDepth = m_pcSlice->getDepthFromDV( iDV, iViewIdx ); |
---|
4350 | m_iUseDDDCandIdx = iCount; |
---|
4351 | |
---|
4352 | m_mergCands[MRG_D].setCand( tmpMV, tmpDir, false, false); |
---|
4353 | if ( mrgCandIdx == iCount ) |
---|
4354 | { |
---|
4355 | return; |
---|
4356 | } |
---|
4357 | iCount ++; |
---|
4358 | } |
---|
4359 | } |
---|
4360 | } |
---|
4361 | #endif |
---|
4362 | ///////////////////////////////////////////////////////////////// |
---|
4363 | //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC Candidates ///// |
---|
4364 | ///////////////////////////////////////////////////////////////// |
---|
4365 | |
---|
4366 | // { IvMCL0, IvMCL1, IvDCL0, IvDCL1, IvMCL0Shift, IvMCL1Shift, IvDCL0Shift, IvDCL1Shift }; |
---|
4367 | // An enumerator would be appropriate here! |
---|
4368 | TComMv ivCandMv [8]; |
---|
4369 | Int ivCandRefIdx[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; |
---|
4370 | |
---|
4371 | // { IvMC, IvDC, IvMCShift, IvDCShift }; |
---|
4372 | Int ivCandDir [4] = {0, 0, 0, 0}; |
---|
4373 | |
---|
4374 | Bool ivMvPredFlag = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() ); |
---|
4375 | |
---|
4376 | ivMvPredFlag &= (nPSW + nPSH > 12); |
---|
4377 | if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1) |
---|
4378 | { |
---|
4379 | getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag ); |
---|
4380 | } |
---|
4381 | |
---|
4382 | /////////////////////////////////////////////// |
---|
4383 | //////// INTER VIEW MOTION COMP(IvMC) ///////// |
---|
4384 | /////////////////////////////////////////////// |
---|
4385 | if( getSlice()->getIsDepth() ) |
---|
4386 | { |
---|
4387 | ivCandDir[1] = ivCandDir[2] = ivCandDir[3] = 0; |
---|
4388 | } |
---|
4389 | |
---|
4390 | if( ivCandDir[0] ) |
---|
4391 | { |
---|
4392 | tmpMV[0].setMvField( cZeroMv, NOT_VALID ); |
---|
4393 | tmpMV[1].setMvField( cZeroMv, NOT_VALID ); |
---|
4394 | |
---|
4395 | if( ( ivCandDir[0] & 1 ) == 1 ) |
---|
4396 | { |
---|
4397 | tmpMV[0].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] ); |
---|
4398 | } |
---|
4399 | if( ( ivCandDir[0] & 2 ) == 2 ) |
---|
4400 | { |
---|
4401 | tmpMV[1].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] ); |
---|
4402 | } |
---|
4403 | |
---|
4404 | Bool bRemoveSpa = false; //pruning |
---|
4405 | |
---|
4406 | if (!bIsDepth) |
---|
4407 | { |
---|
4408 | for(Int i = 0; i < 2; i ++) |
---|
4409 | { |
---|
4410 | if ( !m_mergCands[MRG_A1 + i].m_bAvailable ) // prunning to A1, B1 |
---|
4411 | { |
---|
4412 | continue; |
---|
4413 | } |
---|
4414 | if (ivCandDir[0] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1]) |
---|
4415 | { |
---|
4416 | m_mergCands[MRG_A1+i].m_bAvailable = false; |
---|
4417 | break; |
---|
4418 | } |
---|
4419 | } |
---|
4420 | } |
---|
4421 | if (bIsDepth) |
---|
4422 | { |
---|
4423 | if (m_mergCands[MRG_T].m_bAvailable && ivCandDir[0] == m_mergCands[MRG_T].m_uDir && tmpMV[0]==m_mergCands[MRG_T].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_T].m_cMvField[1]) |
---|
4424 | { |
---|
4425 | bRemoveSpa = true; |
---|
4426 | } |
---|
4427 | } |
---|
4428 | if (!bRemoveSpa) |
---|
4429 | { |
---|
4430 | Bool SPIVMPFlag = false; |
---|
4431 | if(!m_pcSlice->getIsDepth()) |
---|
4432 | { |
---|
4433 | SPIVMPFlag = true; |
---|
4434 | } |
---|
4435 | #if H_3D_DBBP |
---|
4436 | SPIVMPFlag &= !bDBBPFlag; |
---|
4437 | #endif |
---|
4438 | |
---|
4439 | m_mergCands[MRG_IVMC].setCand( tmpMV, ivCandDir[0], false, SPIVMPFlag); |
---|
4440 | |
---|
4441 | if ( mrgCandIdx == iCount ) |
---|
4442 | { |
---|
4443 | return; |
---|
4444 | } |
---|
4445 | iCount ++; |
---|
4446 | } |
---|
4447 | } |
---|
4448 | |
---|
4449 | // early termination |
---|
4450 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4451 | { |
---|
4452 | return; |
---|
4453 | } |
---|
4454 | #endif |
---|
4455 | |
---|
4456 | #if H_3D |
---|
4457 | iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable + m_mergCands[MRG_B0].m_bAvailable; |
---|
4458 | #else |
---|
4459 | //left |
---|
4460 | UInt uiLeftPartIdx = 0; |
---|
4461 | TComDataCU* pcCULeft = 0; |
---|
4462 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
4463 | Bool isAvailableA1 = pcCULeft && |
---|
4464 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
4465 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
4466 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
---|
4467 | if ( isAvailableA1 ) |
---|
4468 | { |
---|
4469 | abCandIsInter[iCount] = true; |
---|
4470 | // get Inter Dir |
---|
4471 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
4472 | // get Mv from Left |
---|
4473 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4474 | if ( getSlice()->isInterB() ) |
---|
4475 | { |
---|
4476 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4477 | } |
---|
4478 | |
---|
4479 | if ( mrgCandIdx == iCount ) |
---|
4480 | { |
---|
4481 | return; |
---|
4482 | } |
---|
4483 | iCount ++; |
---|
4484 | } |
---|
4485 | |
---|
4486 | // early termination |
---|
4487 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4488 | { |
---|
4489 | return; |
---|
4490 | } |
---|
4491 | |
---|
4492 | // above |
---|
4493 | UInt uiAbovePartIdx = 0; |
---|
4494 | TComDataCU* pcCUAbove = 0; |
---|
4495 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
4496 | Bool isAvailableB1 = pcCUAbove && |
---|
4497 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
4498 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
4499 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
---|
4500 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
4501 | { |
---|
4502 | abCandIsInter[iCount] = true; |
---|
4503 | // get Inter Dir |
---|
4504 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
4505 | // get Mv from Left |
---|
4506 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4507 | if ( getSlice()->isInterB() ) |
---|
4508 | { |
---|
4509 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4510 | } |
---|
4511 | |
---|
4512 | if ( mrgCandIdx == iCount ) |
---|
4513 | { |
---|
4514 | return; |
---|
4515 | } |
---|
4516 | iCount ++; |
---|
4517 | } |
---|
4518 | // early termination |
---|
4519 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4520 | { |
---|
4521 | return; |
---|
4522 | } |
---|
4523 | |
---|
4524 | // above right |
---|
4525 | UInt uiAboveRightPartIdx = 0; |
---|
4526 | TComDataCU* pcCUAboveRight = 0; |
---|
4527 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
4528 | Bool isAvailableB0 = pcCUAboveRight && |
---|
4529 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
4530 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
---|
4531 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
4532 | { |
---|
4533 | abCandIsInter[iCount] = true; |
---|
4534 | // get Inter Dir |
---|
4535 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
4536 | // get Mv from Left |
---|
4537 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4538 | if ( getSlice()->isInterB() ) |
---|
4539 | { |
---|
4540 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4541 | } |
---|
4542 | |
---|
4543 | if ( mrgCandIdx == iCount ) |
---|
4544 | { |
---|
4545 | return; |
---|
4546 | } |
---|
4547 | iCount ++; |
---|
4548 | } |
---|
4549 | // early termination |
---|
4550 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4551 | { |
---|
4552 | return; |
---|
4553 | } |
---|
4554 | #endif |
---|
4555 | |
---|
4556 | #if H_3D_DDD |
---|
4557 | // early termination |
---|
4558 | if ( iCount >= getSlice()->getMaxNumMergeCand()) |
---|
4559 | { |
---|
4560 | return; |
---|
4561 | } |
---|
4562 | #endif |
---|
4563 | |
---|
4564 | #if H_3D_IV_MERGE |
---|
4565 | ///////////////////////////////////////////// |
---|
4566 | //////// INTER VIEW DISP COMP (IvDC) //////// |
---|
4567 | ///////////////////////////////////////////// |
---|
4568 | if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) |
---|
4569 | { |
---|
4570 | assert(iCount < getSlice()->getMaxNumMergeCand()); |
---|
4571 | |
---|
4572 | tmpMV[0].setMvField( cZeroMv, NOT_VALID ); |
---|
4573 | tmpMV[1].setMvField( cZeroMv, NOT_VALID ); |
---|
4574 | if( ( ivCandDir[1] & 1 ) == 1 ) |
---|
4575 | { |
---|
4576 | tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] ); |
---|
4577 | } |
---|
4578 | if( ( ivCandDir[1] & 2 ) == 2 ) |
---|
4579 | { |
---|
4580 | tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] ); |
---|
4581 | } |
---|
4582 | |
---|
4583 | Bool bRemoveSpa = false; //pruning to A1, B1 |
---|
4584 | for(Int i = 0; i < 2; i ++) |
---|
4585 | { |
---|
4586 | if ( !m_mergCands[MRG_A1+i].m_bAvailable ) |
---|
4587 | { |
---|
4588 | continue; |
---|
4589 | } |
---|
4590 | if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1]) |
---|
4591 | { |
---|
4592 | bRemoveSpa = true; |
---|
4593 | break; |
---|
4594 | } |
---|
4595 | } |
---|
4596 | if(!bRemoveSpa) |
---|
4597 | { |
---|
4598 | #if H_3D_NBDV |
---|
4599 | tmpMV[0].getMv().setIDVFlag (false); |
---|
4600 | tmpMV[1].getMv().setIDVFlag (false); |
---|
4601 | #endif |
---|
4602 | m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false); |
---|
4603 | |
---|
4604 | if ( mrgCandIdx == iCount ) |
---|
4605 | return; |
---|
4606 | iCount ++; |
---|
4607 | |
---|
4608 | // early termination |
---|
4609 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4610 | { |
---|
4611 | return; |
---|
4612 | } |
---|
4613 | } |
---|
4614 | } |
---|
4615 | #endif // H_3D_IV_MERGE |
---|
4616 | |
---|
4617 | #if H_3D_VSP |
---|
4618 | ///////////////////////////////////////////////// |
---|
4619 | //////// VIEW SYNTHESIS PREDICTION (VSP) //////// |
---|
4620 | ///////////////////////////////////////////////// |
---|
4621 | if (iCount<getSlice()->getMaxNumMergeCand()) |
---|
4622 | { |
---|
4623 | |
---|
4624 | if ( |
---|
4625 | #if H_3D_IC |
---|
4626 | !bICFlag && |
---|
4627 | #endif |
---|
4628 | #if H_3D_ARP |
---|
4629 | !bARPFlag && |
---|
4630 | #endif |
---|
4631 | #if H_3D |
---|
4632 | (nPSW + nPSH > 12) && |
---|
4633 | #endif |
---|
4634 | #if H_3D_DBBP |
---|
4635 | !bDBBPFlag && |
---|
4636 | #endif |
---|
4637 | xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) ) |
---|
4638 | { |
---|
4639 | return; |
---|
4640 | } |
---|
4641 | |
---|
4642 | // early termination |
---|
4643 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4644 | { |
---|
4645 | return; |
---|
4646 | } |
---|
4647 | #endif |
---|
4648 | #if H_3D |
---|
4649 | } |
---|
4650 | #endif |
---|
4651 | |
---|
4652 | #if H_3D |
---|
4653 | iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable; |
---|
4654 | #else |
---|
4655 | //left bottom |
---|
4656 | UInt uiLeftBottomPartIdx = 0; |
---|
4657 | TComDataCU* pcCULeftBottom = 0; |
---|
4658 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
4659 | Bool isAvailableA0 = pcCULeftBottom && |
---|
4660 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
4661 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
---|
4662 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
4663 | { |
---|
4664 | abCandIsInter[iCount] = true; |
---|
4665 | // get Inter Dir |
---|
4666 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
4667 | // get Mv from Left |
---|
4668 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4669 | if ( getSlice()->isInterB() ) |
---|
4670 | { |
---|
4671 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4672 | } |
---|
4673 | if ( mrgCandIdx == iCount ) |
---|
4674 | { |
---|
4675 | return; |
---|
4676 | } |
---|
4677 | iCount ++; |
---|
4678 | } |
---|
4679 | // early termination |
---|
4680 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4681 | { |
---|
4682 | return; |
---|
4683 | } |
---|
4684 | |
---|
4685 | // above left |
---|
4686 | if( iCount < 4 ) |
---|
4687 | { |
---|
4688 | UInt uiAboveLeftPartIdx = 0; |
---|
4689 | TComDataCU* pcCUAboveLeft = 0; |
---|
4690 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
4691 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
4692 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
4693 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
---|
4694 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
4695 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
4696 | { |
---|
4697 | abCandIsInter[iCount] = true; |
---|
4698 | // get Inter Dir |
---|
4699 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
4700 | // get Mv from Left |
---|
4701 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4702 | if ( getSlice()->isInterB() ) |
---|
4703 | { |
---|
4704 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4705 | } |
---|
4706 | if ( mrgCandIdx == iCount ) |
---|
4707 | { |
---|
4708 | return; |
---|
4709 | } |
---|
4710 | iCount ++; |
---|
4711 | } |
---|
4712 | } |
---|
4713 | // early termination |
---|
4714 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4715 | { |
---|
4716 | return; |
---|
4717 | } |
---|
4718 | #endif |
---|
4719 | |
---|
4720 | |
---|
4721 | #if H_3D_IV_MERGE |
---|
4722 | //////////////////////////////////////////////////// |
---|
4723 | //////// SHIFTED IV (IvMCShift + IvDCShift) //////// |
---|
4724 | //////////////////////////////////////////////////// |
---|
4725 | if( ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) |
---|
4726 | { |
---|
4727 | if(xAddIvMRGCand( mrgCandIdx, iCount, ivCandDir, ivCandMv, ivCandRefIdx ) ) |
---|
4728 | { |
---|
4729 | return; |
---|
4730 | } |
---|
4731 | //early termination |
---|
4732 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4733 | { |
---|
4734 | return; |
---|
4735 | } |
---|
4736 | } |
---|
4737 | #endif |
---|
4738 | #if !H_3D |
---|
4739 | if ( getSlice()->getEnableTMVPFlag()) |
---|
4740 | { |
---|
4741 | //>> MTK colocated-RightBottom |
---|
4742 | UInt uiPartIdxRB; |
---|
4743 | |
---|
4744 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
4745 | |
---|
4746 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
4747 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
4748 | |
---|
4749 | TComMv cColMv; |
---|
4750 | Int iRefIdx; |
---|
4751 | Int uiLCUIdx = -1; |
---|
4752 | |
---|
4753 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
4754 | { |
---|
4755 | } |
---|
4756 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
4757 | { |
---|
4758 | } |
---|
4759 | else |
---|
4760 | { |
---|
4761 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
4762 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
4763 | { |
---|
4764 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
4765 | uiLCUIdx = getAddr(); |
---|
4766 | } |
---|
4767 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
4768 | { |
---|
4769 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
4770 | } |
---|
4771 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
4772 | { |
---|
4773 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
4774 | uiLCUIdx = getAddr() + 1; |
---|
4775 | } |
---|
4776 | else //is the right bottom corner of LCU |
---|
4777 | { |
---|
4778 | uiAbsPartAddr = 0; |
---|
4779 | } |
---|
4780 | } |
---|
4781 | |
---|
4782 | |
---|
4783 | iRefIdx = 0; |
---|
4784 | Bool bExistMV = false; |
---|
4785 | UInt uiPartIdxCenter; |
---|
4786 | UInt uiCurLCUIdx = getAddr(); |
---|
4787 | Int dir = 0; |
---|
4788 | UInt uiArrayAddr = iCount; |
---|
4789 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
4790 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
4791 | if( bExistMV == false ) |
---|
4792 | { |
---|
4793 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4794 | } |
---|
4795 | if( bExistMV ) |
---|
4796 | { |
---|
4797 | dir |= 1; |
---|
4798 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
4799 | } |
---|
4800 | |
---|
4801 | if ( getSlice()->isInterB() ) |
---|
4802 | { |
---|
4803 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
4804 | if( bExistMV == false ) |
---|
4805 | { |
---|
4806 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
4807 | } |
---|
4808 | if( bExistMV ) |
---|
4809 | { |
---|
4810 | dir |= 2; |
---|
4811 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
4812 | } |
---|
4813 | } |
---|
4814 | |
---|
4815 | if (dir != 0) |
---|
4816 | { |
---|
4817 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
4818 | abCandIsInter[uiArrayAddr] = true; |
---|
4819 | if ( mrgCandIdx == iCount ) |
---|
4820 | { |
---|
4821 | return; |
---|
4822 | } |
---|
4823 | iCount++; |
---|
4824 | } |
---|
4825 | } |
---|
4826 | // early termination |
---|
4827 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4828 | { |
---|
4829 | return; |
---|
4830 | } |
---|
4831 | UInt uiArrayAddr = iCount; |
---|
4832 | UInt uiCutoff = uiArrayAddr; |
---|
4833 | |
---|
4834 | if ( getSlice()->isInterB()) |
---|
4835 | { |
---|
4836 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
4837 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
4838 | |
---|
4839 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
4840 | { |
---|
4841 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
4842 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
4843 | { |
---|
4844 | abCandIsInter[uiArrayAddr] = true; |
---|
4845 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4846 | |
---|
4847 | // get Mv from cand[i] and cand[j] |
---|
4848 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
4849 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
4850 | |
---|
4851 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
4852 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
4853 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
4854 | { |
---|
4855 | abCandIsInter[uiArrayAddr] = false; |
---|
4856 | } |
---|
4857 | else |
---|
4858 | { |
---|
4859 | uiArrayAddr++; |
---|
4860 | } |
---|
4861 | } |
---|
4862 | } |
---|
4863 | } |
---|
4864 | // early termination |
---|
4865 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
4866 | { |
---|
4867 | return; |
---|
4868 | } |
---|
4869 | 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); |
---|
4870 | Int r = 0; |
---|
4871 | Int refcnt = 0; |
---|
4872 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
4873 | { |
---|
4874 | abCandIsInter[uiArrayAddr] = true; |
---|
4875 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
4876 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
4877 | |
---|
4878 | if ( getSlice()->isInterB() ) |
---|
4879 | { |
---|
4880 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
4881 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
4882 | } |
---|
4883 | uiArrayAddr++; |
---|
4884 | if ( refcnt == iNumRefIdx - 1 ) |
---|
4885 | { |
---|
4886 | r = 0; |
---|
4887 | } |
---|
4888 | else |
---|
4889 | { |
---|
4890 | ++r; |
---|
4891 | ++refcnt; |
---|
4892 | } |
---|
4893 | } |
---|
4894 | |
---|
4895 | numValidMergeCand = uiArrayAddr; |
---|
4896 | #endif |
---|
4897 | } |
---|
4898 | #else |
---|
4899 | |
---|
4900 | /** Constructs a list of merging candidates |
---|
4901 | * \param uiAbsPartIdx |
---|
4902 | * \param uiPUIdx |
---|
4903 | * \param uiDepth |
---|
4904 | * \param pcMvFieldNeighbours |
---|
4905 | * \param puhInterDirNeighbours |
---|
4906 | * \param numValidMergeCand |
---|
4907 | */ |
---|
4908 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
---|
4909 | , Int& numValidMergeCand, Int mrgCandIdx |
---|
4910 | ) |
---|
4911 | { |
---|
4912 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
4913 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
4914 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
4915 | { |
---|
4916 | abCandIsInter[ui] = false; |
---|
4917 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
4918 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
4919 | } |
---|
4920 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
4921 | // compute the location of the current PU |
---|
4922 | Int xP, yP, nPSW, nPSH; |
---|
4923 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
4924 | |
---|
4925 | Int iCount = 0; |
---|
4926 | |
---|
4927 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
4928 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
4929 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
4930 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
4931 | |
---|
4932 | //left |
---|
4933 | UInt uiLeftPartIdx = 0; |
---|
4934 | TComDataCU* pcCULeft = 0; |
---|
4935 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
4936 | Bool isAvailableA1 = pcCULeft && |
---|
4937 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
4938 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
4939 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
---|
4940 | if ( isAvailableA1 ) |
---|
4941 | { |
---|
4942 | abCandIsInter[iCount] = true; |
---|
4943 | // get Inter Dir |
---|
4944 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
4945 | // get Mv from Left |
---|
4946 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4947 | if ( getSlice()->isInterB() ) |
---|
4948 | { |
---|
4949 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4950 | } |
---|
4951 | if ( mrgCandIdx == iCount ) |
---|
4952 | { |
---|
4953 | return; |
---|
4954 | } |
---|
4955 | iCount ++; |
---|
4956 | } |
---|
4957 | |
---|
4958 | // early termination |
---|
4959 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4960 | { |
---|
4961 | return; |
---|
4962 | } |
---|
4963 | |
---|
4964 | // above |
---|
4965 | UInt uiAbovePartIdx = 0; |
---|
4966 | TComDataCU* pcCUAbove = 0; |
---|
4967 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
4968 | Bool isAvailableB1 = pcCUAbove && |
---|
4969 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
4970 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
4971 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
---|
4972 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
4973 | { |
---|
4974 | abCandIsInter[iCount] = true; |
---|
4975 | // get Inter Dir |
---|
4976 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
4977 | // get Mv from Left |
---|
4978 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
4979 | if ( getSlice()->isInterB() ) |
---|
4980 | { |
---|
4981 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
4982 | } |
---|
4983 | |
---|
4984 | if ( mrgCandIdx == iCount ) |
---|
4985 | { |
---|
4986 | return; |
---|
4987 | } |
---|
4988 | iCount ++; |
---|
4989 | } |
---|
4990 | // early termination |
---|
4991 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
4992 | { |
---|
4993 | return; |
---|
4994 | } |
---|
4995 | |
---|
4996 | |
---|
4997 | // above right |
---|
4998 | UInt uiAboveRightPartIdx = 0; |
---|
4999 | TComDataCU* pcCUAboveRight = 0; |
---|
5000 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
5001 | Bool isAvailableB0 = pcCUAboveRight && |
---|
5002 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
5003 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
---|
5004 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
5005 | { |
---|
5006 | abCandIsInter[iCount] = true; |
---|
5007 | // get Inter Dir |
---|
5008 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
5009 | // get Mv from Left |
---|
5010 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
5011 | if ( getSlice()->isInterB() ) |
---|
5012 | { |
---|
5013 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
5014 | } |
---|
5015 | if ( mrgCandIdx == iCount ) |
---|
5016 | { |
---|
5017 | return; |
---|
5018 | } |
---|
5019 | iCount ++; |
---|
5020 | } |
---|
5021 | // early termination |
---|
5022 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
5023 | { |
---|
5024 | return; |
---|
5025 | } |
---|
5026 | |
---|
5027 | //left bottom |
---|
5028 | UInt uiLeftBottomPartIdx = 0; |
---|
5029 | TComDataCU* pcCULeftBottom = 0; |
---|
5030 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
5031 | Bool isAvailableA0 = pcCULeftBottom && |
---|
5032 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
5033 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
---|
5034 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
5035 | { |
---|
5036 | abCandIsInter[iCount] = true; |
---|
5037 | // get Inter Dir |
---|
5038 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
5039 | // get Mv from Left |
---|
5040 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
5041 | if ( getSlice()->isInterB() ) |
---|
5042 | { |
---|
5043 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
5044 | } |
---|
5045 | |
---|
5046 | if ( mrgCandIdx == iCount ) |
---|
5047 | { |
---|
5048 | return; |
---|
5049 | } |
---|
5050 | iCount ++; |
---|
5051 | } |
---|
5052 | // early termination |
---|
5053 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
5054 | { |
---|
5055 | return; |
---|
5056 | } |
---|
5057 | |
---|
5058 | // above left |
---|
5059 | if( iCount < 4 ) |
---|
5060 | { |
---|
5061 | UInt uiAboveLeftPartIdx = 0; |
---|
5062 | TComDataCU* pcCUAboveLeft = 0; |
---|
5063 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
5064 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
5065 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
5066 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
---|
5067 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
5068 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
5069 | { |
---|
5070 | abCandIsInter[iCount] = true; |
---|
5071 | // get Inter Dir |
---|
5072 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
5073 | // get Mv from Left |
---|
5074 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
5075 | if ( getSlice()->isInterB() ) |
---|
5076 | { |
---|
5077 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
5078 | } |
---|
5079 | if ( mrgCandIdx == iCount ) |
---|
5080 | { |
---|
5081 | return; |
---|
5082 | } |
---|
5083 | iCount ++; |
---|
5084 | } |
---|
5085 | } |
---|
5086 | // early termination |
---|
5087 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
5088 | { |
---|
5089 | return; |
---|
5090 | } |
---|
5091 | |
---|
5092 | if ( getSlice()->getEnableTMVPFlag()) |
---|
5093 | { |
---|
5094 | //>> MTK colocated-RightBottom |
---|
5095 | UInt uiPartIdxRB; |
---|
5096 | |
---|
5097 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
5098 | |
---|
5099 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
5100 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
5101 | |
---|
5102 | TComMv cColMv; |
---|
5103 | Int iRefIdx; |
---|
5104 | Int uiLCUIdx = -1; |
---|
5105 | |
---|
5106 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
5107 | { |
---|
5108 | } |
---|
5109 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
5110 | { |
---|
5111 | } |
---|
5112 | else |
---|
5113 | { |
---|
5114 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
5115 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
5116 | { |
---|
5117 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
5118 | uiLCUIdx = getAddr(); |
---|
5119 | } |
---|
5120 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
5121 | { |
---|
5122 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
5123 | } |
---|
5124 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
5125 | { |
---|
5126 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
5127 | uiLCUIdx = getAddr() + 1; |
---|
5128 | } |
---|
5129 | else //is the right bottom corner of LCU |
---|
5130 | { |
---|
5131 | uiAbsPartAddr = 0; |
---|
5132 | } |
---|
5133 | } |
---|
5134 | |
---|
5135 | |
---|
5136 | iRefIdx = 0; |
---|
5137 | Bool bExistMV = false; |
---|
5138 | UInt uiPartIdxCenter; |
---|
5139 | UInt uiCurLCUIdx = getAddr(); |
---|
5140 | Int dir = 0; |
---|
5141 | UInt uiArrayAddr = iCount; |
---|
5142 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
5143 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
5144 | if( bExistMV == false ) |
---|
5145 | { |
---|
5146 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
5147 | } |
---|
5148 | if( bExistMV ) |
---|
5149 | { |
---|
5150 | dir |= 1; |
---|
5151 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
5152 | } |
---|
5153 | |
---|
5154 | if ( getSlice()->isInterB() ) |
---|
5155 | { |
---|
5156 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
5157 | if( bExistMV == false ) |
---|
5158 | { |
---|
5159 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
5160 | } |
---|
5161 | if( bExistMV ) |
---|
5162 | { |
---|
5163 | dir |= 2; |
---|
5164 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
5165 | } |
---|
5166 | } |
---|
5167 | |
---|
5168 | if (dir != 0) |
---|
5169 | { |
---|
5170 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
5171 | abCandIsInter[uiArrayAddr] = true; |
---|
5172 | if ( mrgCandIdx == iCount ) |
---|
5173 | { |
---|
5174 | return; |
---|
5175 | } |
---|
5176 | iCount++; |
---|
5177 | } |
---|
5178 | } |
---|
5179 | // early termination |
---|
5180 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
5181 | { |
---|
5182 | return; |
---|
5183 | } |
---|
5184 | UInt uiArrayAddr = iCount; |
---|
5185 | UInt uiCutoff = uiArrayAddr; |
---|
5186 | |
---|
5187 | if ( getSlice()->isInterB()) |
---|
5188 | { |
---|
5189 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
5190 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
5191 | |
---|
5192 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
5193 | { |
---|
5194 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
5195 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
5196 | { |
---|
5197 | abCandIsInter[uiArrayAddr] = true; |
---|
5198 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
5199 | |
---|
5200 | // get Mv from cand[i] and cand[j] |
---|
5201 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
5202 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
5203 | |
---|
5204 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
5205 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
5206 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
5207 | { |
---|
5208 | abCandIsInter[uiArrayAddr] = false; |
---|
5209 | } |
---|
5210 | else |
---|
5211 | { |
---|
5212 | uiArrayAddr++; |
---|
5213 | } |
---|
5214 | } |
---|
5215 | } |
---|
5216 | } |
---|
5217 | // early termination |
---|
5218 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
5219 | { |
---|
5220 | return; |
---|
5221 | } |
---|
5222 | 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); |
---|
5223 | Int r = 0; |
---|
5224 | Int refcnt = 0; |
---|
5225 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
5226 | { |
---|
5227 | abCandIsInter[uiArrayAddr] = true; |
---|
5228 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
5229 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
5230 | |
---|
5231 | if ( getSlice()->isInterB() ) |
---|
5232 | { |
---|
5233 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
5234 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
5235 | } |
---|
5236 | uiArrayAddr++; |
---|
5237 | if ( refcnt == iNumRefIdx - 1 ) |
---|
5238 | { |
---|
5239 | r = 0; |
---|
5240 | } |
---|
5241 | else |
---|
5242 | { |
---|
5243 | ++r; |
---|
5244 | ++refcnt; |
---|
5245 | } |
---|
5246 | } |
---|
5247 | |
---|
5248 | numValidMergeCand = uiArrayAddr; |
---|
5249 | } |
---|
5250 | #endif |
---|
5251 | |
---|
5252 | |
---|
5253 | #if H_3D_VSP |
---|
5254 | inline Void TComDataCU::xInheritVSPDisInfo(TComDataCU* pcCURef, UInt uiAbsPartIdx, Int iCount, InheritedVSPDisInfo* inheritedVSPDisInfo) |
---|
5255 | { |
---|
5256 | inheritedVSPDisInfo[iCount].m_acDvInfo.m_acNBDV = pcCURef->getDvInfo(uiAbsPartIdx).m_acNBDV; |
---|
5257 | inheritedVSPDisInfo[iCount].m_acDvInfo.m_aVIdxCan = pcCURef->getDvInfo(uiAbsPartIdx).m_aVIdxCan; |
---|
5258 | } |
---|
5259 | #endif |
---|
5260 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
---|
5261 | * \param xN, xN location of the upper-left corner pixel of a neighboring PU |
---|
5262 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
5263 | * \returns Bool |
---|
5264 | */ |
---|
5265 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) |
---|
5266 | { |
---|
5267 | |
---|
5268 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
---|
5269 | if ((xN>>plevel)!= (xP>>plevel)) |
---|
5270 | { |
---|
5271 | return true; |
---|
5272 | } |
---|
5273 | if ((yN>>plevel)!= (yP>>plevel)) |
---|
5274 | { |
---|
5275 | return true; |
---|
5276 | } |
---|
5277 | return false; |
---|
5278 | } |
---|
5279 | /** calculate the location of upper-left corner pixel and size of the current PU. |
---|
5280 | * \param partIdx PU index within a CU |
---|
5281 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
5282 | * \param PSW, nPSH size of the curren PU |
---|
5283 | * \returns Void |
---|
5284 | */ |
---|
5285 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) |
---|
5286 | { |
---|
5287 | UInt col = m_uiCUPelX; |
---|
5288 | UInt row = m_uiCUPelY; |
---|
5289 | |
---|
5290 | switch ( m_pePartSize[0] ) |
---|
5291 | { |
---|
5292 | case SIZE_2NxN: |
---|
5293 | nPSW = getWidth(0); |
---|
5294 | nPSH = getHeight(0) >> 1; |
---|
5295 | xP = col; |
---|
5296 | yP = (partIdx ==0)? row: row + nPSH; |
---|
5297 | break; |
---|
5298 | case SIZE_Nx2N: |
---|
5299 | nPSW = getWidth(0) >> 1; |
---|
5300 | nPSH = getHeight(0); |
---|
5301 | xP = (partIdx ==0)? col: col + nPSW; |
---|
5302 | yP = row; |
---|
5303 | break; |
---|
5304 | case SIZE_NxN: |
---|
5305 | nPSW = getWidth(0) >> 1; |
---|
5306 | nPSH = getHeight(0) >> 1; |
---|
5307 | xP = col + (partIdx&0x1)*nPSW; |
---|
5308 | yP = row + (partIdx>>1)*nPSH; |
---|
5309 | break; |
---|
5310 | case SIZE_2NxnU: |
---|
5311 | nPSW = getWidth(0); |
---|
5312 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
5313 | xP = col; |
---|
5314 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
5315 | |
---|
5316 | break; |
---|
5317 | case SIZE_2NxnD: |
---|
5318 | nPSW = getWidth(0); |
---|
5319 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
5320 | xP = col; |
---|
5321 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
5322 | break; |
---|
5323 | case SIZE_nLx2N: |
---|
5324 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
5325 | nPSH = getHeight(0); |
---|
5326 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
5327 | yP = row; |
---|
5328 | break; |
---|
5329 | case SIZE_nRx2N: |
---|
5330 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
5331 | nPSH = getHeight(0); |
---|
5332 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
5333 | yP = row; |
---|
5334 | break; |
---|
5335 | default: |
---|
5336 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
5337 | nPSW = getWidth(0); |
---|
5338 | nPSH = getHeight(0); |
---|
5339 | xP = col ; |
---|
5340 | yP = row ; |
---|
5341 | |
---|
5342 | break; |
---|
5343 | } |
---|
5344 | } |
---|
5345 | |
---|
5346 | /** Constructs a list of candidates for AMVP |
---|
5347 | * \param uiPartIdx |
---|
5348 | * \param uiPartAddr |
---|
5349 | * \param eRefPicList |
---|
5350 | * \param iRefIdx |
---|
5351 | * \param pInfo |
---|
5352 | */ |
---|
5353 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
---|
5354 | { |
---|
5355 | TComMv cMvPred; |
---|
5356 | Bool bAddedSmvp = false; |
---|
5357 | |
---|
5358 | pInfo->iN = 0; |
---|
5359 | if (iRefIdx < 0) |
---|
5360 | { |
---|
5361 | return; |
---|
5362 | } |
---|
5363 | |
---|
5364 | //-- Get Spatial MV |
---|
5365 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
5366 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
5367 | Bool bAdded = false; |
---|
5368 | |
---|
5369 | deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
5370 | deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB ); |
---|
5371 | |
---|
5372 | TComDataCU* tmpCU = NULL; |
---|
5373 | UInt idx; |
---|
5374 | tmpCU = getPUBelowLeft(idx, uiPartIdxLB); |
---|
5375 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
5376 | |
---|
5377 | if (!bAddedSmvp) |
---|
5378 | { |
---|
5379 | tmpCU = getPULeft(idx, uiPartIdxLB); |
---|
5380 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
5381 | } |
---|
5382 | |
---|
5383 | // Left predictor search |
---|
5384 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
5385 | if (!bAdded) |
---|
5386 | { |
---|
5387 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
5388 | } |
---|
5389 | |
---|
5390 | if(!bAdded) |
---|
5391 | { |
---|
5392 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
5393 | if (!bAdded) |
---|
5394 | { |
---|
5395 | xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
5396 | } |
---|
5397 | } |
---|
5398 | // Above predictor search |
---|
5399 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
5400 | |
---|
5401 | if (!bAdded) |
---|
5402 | { |
---|
5403 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
5404 | } |
---|
5405 | |
---|
5406 | if(!bAdded) |
---|
5407 | { |
---|
5408 | xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
5409 | } |
---|
5410 | |
---|
5411 | if (!bAddedSmvp) |
---|
5412 | { |
---|
5413 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
5414 | if (!bAdded) |
---|
5415 | { |
---|
5416 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
5417 | } |
---|
5418 | |
---|
5419 | if(!bAdded) |
---|
5420 | { |
---|
5421 | xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
5422 | } |
---|
5423 | } |
---|
5424 | |
---|
5425 | if ( pInfo->iN == 2 ) |
---|
5426 | { |
---|
5427 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
---|
5428 | { |
---|
5429 | pInfo->iN = 1; |
---|
5430 | } |
---|
5431 | } |
---|
5432 | |
---|
5433 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
5434 | { |
---|
5435 | // Get Temporal Motion Predictor |
---|
5436 | Int iRefIdx_Col = iRefIdx; |
---|
5437 | TComMv cColMv; |
---|
5438 | UInt uiPartIdxRB; |
---|
5439 | UInt uiAbsPartIdx; |
---|
5440 | UInt uiAbsPartAddr; |
---|
5441 | |
---|
5442 | deriveRightBottomIdx( uiPartIdx, uiPartIdxRB ); |
---|
5443 | uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
---|
5444 | |
---|
5445 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
5446 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
---|
5447 | Int uiLCUIdx = -1; |
---|
5448 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
5449 | { |
---|
5450 | } |
---|
5451 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
5452 | { |
---|
5453 | } |
---|
5454 | else |
---|
5455 | { |
---|
5456 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
5457 | ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
5458 | { |
---|
5459 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; |
---|
5460 | uiLCUIdx = getAddr(); |
---|
5461 | } |
---|
5462 | else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
5463 | { |
---|
5464 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
5465 | } |
---|
5466 | else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
5467 | { |
---|
5468 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
---|
5469 | uiLCUIdx = getAddr() + 1; |
---|
5470 | } |
---|
5471 | else //is the right bottom corner of LCU |
---|
5472 | { |
---|
5473 | uiAbsPartAddr = 0; |
---|
5474 | } |
---|
5475 | } |
---|
5476 | if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col |
---|
5477 | #if H_3D_TMVP |
---|
5478 | , 0 |
---|
5479 | #endif |
---|
5480 | ) ) |
---|
5481 | { |
---|
5482 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
5483 | } |
---|
5484 | else |
---|
5485 | { |
---|
5486 | UInt uiPartIdxCenter; |
---|
5487 | UInt uiCurLCUIdx = getAddr(); |
---|
5488 | xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); |
---|
5489 | if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col |
---|
5490 | #if H_3D_TMVP |
---|
5491 | , 0 |
---|
5492 | #endif |
---|
5493 | )) |
---|
5494 | { |
---|
5495 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
5496 | } |
---|
5497 | } |
---|
5498 | //---- co-located RightBottom Temporal Predictor ---// |
---|
5499 | } |
---|
5500 | |
---|
5501 | if (pInfo->iN > AMVP_MAX_NUM_CANDS) |
---|
5502 | { |
---|
5503 | pInfo->iN = AMVP_MAX_NUM_CANDS; |
---|
5504 | } |
---|
5505 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
---|
5506 | { |
---|
5507 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
---|
5508 | pInfo->iN++; |
---|
5509 | } |
---|
5510 | return ; |
---|
5511 | } |
---|
5512 | |
---|
5513 | Bool TComDataCU::isBipredRestriction(UInt puIdx) |
---|
5514 | { |
---|
5515 | Int width = 0; |
---|
5516 | Int height = 0; |
---|
5517 | UInt partAddr; |
---|
5518 | |
---|
5519 | #if H_3D_DBBP |
---|
5520 | if( getDBBPFlag(0) ) |
---|
5521 | { |
---|
5522 | return true; |
---|
5523 | } |
---|
5524 | #endif |
---|
5525 | |
---|
5526 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
---|
5527 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
---|
5528 | { |
---|
5529 | return true; |
---|
5530 | } |
---|
5531 | return false; |
---|
5532 | } |
---|
5533 | |
---|
5534 | Void TComDataCU::clipMv (TComMv& rcMv) |
---|
5535 | { |
---|
5536 | Int iMvShift = 2; |
---|
5537 | #if H_3D_IC |
---|
5538 | if( getSlice()->getIsDepth() ) |
---|
5539 | iMvShift = 0; |
---|
5540 | #endif |
---|
5541 | Int iOffset = 8; |
---|
5542 | Int iHorMax = ( m_pcSlice->getSPS()->getPicWidthInLumaSamples() + iOffset - m_uiCUPelX - 1 ) << iMvShift; |
---|
5543 | Int iHorMin = ( -(Int)g_uiMaxCUWidth - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
---|
5544 | |
---|
5545 | Int iVerMax = ( m_pcSlice->getSPS()->getPicHeightInLumaSamples() + iOffset - m_uiCUPelY - 1 ) << iMvShift; |
---|
5546 | Int iVerMin = ( -(Int)g_uiMaxCUHeight - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
---|
5547 | |
---|
5548 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
---|
5549 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
---|
5550 | } |
---|
5551 | |
---|
5552 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
---|
5553 | { |
---|
5554 | UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
5555 | |
---|
5556 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
5557 | UInt uiCnt = 0; |
---|
5558 | while( uiWidth ) |
---|
5559 | { |
---|
5560 | uiCnt++; |
---|
5561 | uiWidth>>=1; |
---|
5562 | } |
---|
5563 | uiCnt-=2; |
---|
5564 | return uiCnt > 6 ? 6 : uiCnt; |
---|
5565 | } |
---|
5566 | |
---|
5567 | Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts ) |
---|
5568 | { |
---|
5569 | ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
5570 | } |
---|
5571 | |
---|
5572 | /** Set a I_PCM flag for all sub-partitions of a partition. |
---|
5573 | * \param bIpcmFlag I_PCM flag |
---|
5574 | * \param uiAbsPartIdx patition index |
---|
5575 | * \param uiDepth CU depth |
---|
5576 | * \returns Void |
---|
5577 | */ |
---|
5578 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
---|
5579 | { |
---|
5580 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
5581 | |
---|
5582 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
---|
5583 | } |
---|
5584 | |
---|
5585 | /** Test whether the current block is skipped |
---|
5586 | * \param uiPartIdx Block index |
---|
5587 | * \returns Flag indicating whether the block is skipped |
---|
5588 | */ |
---|
5589 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
---|
5590 | { |
---|
5591 | return ( getSkipFlag( uiPartIdx ) ); |
---|
5592 | } |
---|
5593 | |
---|
5594 | #if H_3D_IC |
---|
5595 | Bool TComDataCU::isIC( UInt uiPartIdx ) |
---|
5596 | { |
---|
5597 | if ( m_pcSlice->isIntra () ) |
---|
5598 | { |
---|
5599 | return false; |
---|
5600 | } |
---|
5601 | return ( ( getSkipFlag(uiPartIdx) || getPredictionMode(uiPartIdx) == MODE_INTER) && getICFlag( uiPartIdx ) && isICFlagRequired( uiPartIdx ) ); |
---|
5602 | } |
---|
5603 | #endif |
---|
5604 | |
---|
5605 | // ==================================================================================================================== |
---|
5606 | // Protected member functions |
---|
5607 | // ==================================================================================================================== |
---|
5608 | |
---|
5609 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
5610 | { |
---|
5611 | TComDataCU* pcTmpCU = NULL; |
---|
5612 | UInt uiIdx; |
---|
5613 | switch( eDir ) |
---|
5614 | { |
---|
5615 | case MD_LEFT: |
---|
5616 | { |
---|
5617 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
5618 | break; |
---|
5619 | } |
---|
5620 | case MD_ABOVE: |
---|
5621 | { |
---|
5622 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx ); |
---|
5623 | break; |
---|
5624 | } |
---|
5625 | case MD_ABOVE_RIGHT: |
---|
5626 | { |
---|
5627 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
5628 | break; |
---|
5629 | } |
---|
5630 | case MD_BELOW_LEFT: |
---|
5631 | { |
---|
5632 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
5633 | break; |
---|
5634 | } |
---|
5635 | case MD_ABOVE_LEFT: |
---|
5636 | { |
---|
5637 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
5638 | break; |
---|
5639 | } |
---|
5640 | default: |
---|
5641 | { |
---|
5642 | break; |
---|
5643 | } |
---|
5644 | } |
---|
5645 | |
---|
5646 | if ( pcTmpCU == NULL ) |
---|
5647 | { |
---|
5648 | return false; |
---|
5649 | } |
---|
5650 | |
---|
5651 | if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )) |
---|
5652 | { |
---|
5653 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
5654 | |
---|
5655 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
5656 | return true; |
---|
5657 | } |
---|
5658 | |
---|
5659 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
5660 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
5661 | { |
---|
5662 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
5663 | } |
---|
5664 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
5665 | { |
---|
5666 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
5667 | } |
---|
5668 | |
---|
5669 | |
---|
5670 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
5671 | Int iNeibRefPOC; |
---|
5672 | |
---|
5673 | |
---|
5674 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
---|
5675 | { |
---|
5676 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
5677 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
---|
5678 | { |
---|
5679 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
5680 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
5681 | return true; |
---|
5682 | } |
---|
5683 | } |
---|
5684 | return false; |
---|
5685 | } |
---|
5686 | |
---|
5687 | /** |
---|
5688 | * \param pInfo |
---|
5689 | * \param eRefPicList |
---|
5690 | * \param iRefIdx |
---|
5691 | * \param uiPartUnitIdx |
---|
5692 | * \param eDir |
---|
5693 | * \returns Bool |
---|
5694 | */ |
---|
5695 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
5696 | { |
---|
5697 | TComDataCU* pcTmpCU = NULL; |
---|
5698 | UInt uiIdx; |
---|
5699 | switch( eDir ) |
---|
5700 | { |
---|
5701 | case MD_LEFT: |
---|
5702 | { |
---|
5703 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
5704 | break; |
---|
5705 | } |
---|
5706 | case MD_ABOVE: |
---|
5707 | { |
---|
5708 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
5709 | break; |
---|
5710 | } |
---|
5711 | case MD_ABOVE_RIGHT: |
---|
5712 | { |
---|
5713 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
5714 | break; |
---|
5715 | } |
---|
5716 | case MD_BELOW_LEFT: |
---|
5717 | { |
---|
5718 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
5719 | break; |
---|
5720 | } |
---|
5721 | case MD_ABOVE_LEFT: |
---|
5722 | { |
---|
5723 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
5724 | break; |
---|
5725 | } |
---|
5726 | default: |
---|
5727 | { |
---|
5728 | break; |
---|
5729 | } |
---|
5730 | } |
---|
5731 | |
---|
5732 | if ( pcTmpCU == NULL ) |
---|
5733 | { |
---|
5734 | return false; |
---|
5735 | } |
---|
5736 | |
---|
5737 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
5738 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
5739 | { |
---|
5740 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
5741 | } |
---|
5742 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
5743 | { |
---|
5744 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
5745 | } |
---|
5746 | |
---|
5747 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
5748 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
5749 | Int iNeibPOC = iCurrPOC; |
---|
5750 | Int iNeibRefPOC; |
---|
5751 | |
---|
5752 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
5753 | Bool bIsNeibRefLongTerm = false; |
---|
5754 | //--------------- V1 (END) ------------------// |
---|
5755 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
---|
5756 | { |
---|
5757 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
---|
5758 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
5759 | TComMv rcMv; |
---|
5760 | |
---|
5761 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
5762 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
5763 | { |
---|
5764 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
5765 | { |
---|
5766 | rcMv = cMvPred; |
---|
5767 | } |
---|
5768 | else |
---|
5769 | { |
---|
5770 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
5771 | if ( iScale == 4096 ) |
---|
5772 | { |
---|
5773 | rcMv = cMvPred; |
---|
5774 | } |
---|
5775 | else |
---|
5776 | { |
---|
5777 | rcMv = cMvPred.scaleMv( iScale ); |
---|
5778 | } |
---|
5779 | } |
---|
5780 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
5781 | return true; |
---|
5782 | } |
---|
5783 | } |
---|
5784 | //---------------------- V2(END) --------------------// |
---|
5785 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
---|
5786 | { |
---|
5787 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
5788 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
5789 | TComMv rcMv; |
---|
5790 | |
---|
5791 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
5792 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
5793 | { |
---|
5794 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
5795 | { |
---|
5796 | rcMv = cMvPred; |
---|
5797 | } |
---|
5798 | else |
---|
5799 | { |
---|
5800 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
5801 | if ( iScale == 4096 ) |
---|
5802 | { |
---|
5803 | rcMv = cMvPred; |
---|
5804 | } |
---|
5805 | else |
---|
5806 | { |
---|
5807 | rcMv = cMvPred.scaleMv( iScale ); |
---|
5808 | } |
---|
5809 | } |
---|
5810 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
5811 | return true; |
---|
5812 | } |
---|
5813 | } |
---|
5814 | //---------------------- V3(END) --------------------// |
---|
5815 | return false; |
---|
5816 | } |
---|
5817 | |
---|
5818 | /** |
---|
5819 | * \param eRefPicList |
---|
5820 | * \param uiCUAddr |
---|
5821 | * \param uiPartUnitIdx |
---|
5822 | * \param riRefIdx |
---|
5823 | * \returns Bool |
---|
5824 | */ |
---|
5825 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx |
---|
5826 | #if H_3D_TMVP |
---|
5827 | , Bool bMRG |
---|
5828 | #endif |
---|
5829 | ) |
---|
5830 | { |
---|
5831 | UInt uiAbsPartAddr = uiPartUnitIdx; |
---|
5832 | |
---|
5833 | RefPicList eColRefPicList; |
---|
5834 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
---|
5835 | TComMv cColMv; |
---|
5836 | |
---|
5837 | // use coldir. |
---|
5838 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
5839 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
5840 | if(pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE) |
---|
5841 | { |
---|
5842 | return false; |
---|
5843 | } |
---|
5844 | iCurrPOC = m_pcSlice->getPOC(); |
---|
5845 | iColPOC = pColCU->getSlice()->getPOC(); |
---|
5846 | |
---|
5847 | if (pColCU->isIntra(uiAbsPartAddr)) |
---|
5848 | { |
---|
5849 | return false; |
---|
5850 | } |
---|
5851 | eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
---|
5852 | |
---|
5853 | Int iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
5854 | |
---|
5855 | if (iColRefIdx < 0 ) |
---|
5856 | { |
---|
5857 | eColRefPicList = RefPicList(1 - eColRefPicList); |
---|
5858 | iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
5859 | |
---|
5860 | if (iColRefIdx < 0 ) |
---|
5861 | { |
---|
5862 | return false; |
---|
5863 | } |
---|
5864 | } |
---|
5865 | |
---|
5866 | // Scale the vector. |
---|
5867 | iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
---|
5868 | cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
5869 | |
---|
5870 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
5871 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
---|
5872 | Bool bIsColRefLongTerm = pColCU->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); |
---|
5873 | |
---|
5874 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
5875 | { |
---|
5876 | #if H_3D_TMVP |
---|
5877 | Int iAlterRefIdx = m_pcSlice->getAlterRefIdx(eRefPicList); |
---|
5878 | if(bMRG && iAlterRefIdx > 0) |
---|
5879 | { |
---|
5880 | riRefIdx = iAlterRefIdx; |
---|
5881 | bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
---|
5882 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
5883 | assert(bIsCurrRefLongTerm == bIsColRefLongTerm); |
---|
5884 | } |
---|
5885 | else |
---|
5886 | { |
---|
5887 | #endif |
---|
5888 | return false; |
---|
5889 | #if H_3D_TMVP |
---|
5890 | } |
---|
5891 | #endif |
---|
5892 | } |
---|
5893 | |
---|
5894 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
---|
5895 | { |
---|
5896 | #if H_3D_TMVP |
---|
5897 | Int iCurrViewId = m_pcSlice->getViewIndex (); |
---|
5898 | Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewIndex (); |
---|
5899 | Int iColViewId = pColCU->getSlice()->getViewIndex(); |
---|
5900 | Int iColRefViewId = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewIndex(); |
---|
5901 | iScale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId ); |
---|
5902 | if ( iScale != 4096 && m_pcSlice->getVPS()->getIvMvScalingFlag() ) |
---|
5903 | { |
---|
5904 | rcMv = cColMv.scaleMv( iScale ); |
---|
5905 | } |
---|
5906 | else |
---|
5907 | { |
---|
5908 | #endif |
---|
5909 | rcMv = cColMv; |
---|
5910 | #if H_3D_TMVP |
---|
5911 | } |
---|
5912 | #endif |
---|
5913 | } |
---|
5914 | else |
---|
5915 | { |
---|
5916 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
5917 | if ( iScale == 4096 ) |
---|
5918 | { |
---|
5919 | rcMv = cColMv; |
---|
5920 | } |
---|
5921 | else |
---|
5922 | { |
---|
5923 | rcMv = cColMv.scaleMv( iScale ); |
---|
5924 | } |
---|
5925 | } |
---|
5926 | return true; |
---|
5927 | } |
---|
5928 | |
---|
5929 | UInt TComDataCU::xGetMvdBits(TComMv cMvd) |
---|
5930 | { |
---|
5931 | return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) ); |
---|
5932 | } |
---|
5933 | |
---|
5934 | UInt TComDataCU::xGetComponentBits(Int iVal) |
---|
5935 | { |
---|
5936 | UInt uiLength = 1; |
---|
5937 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
5938 | |
---|
5939 | assert ( uiTemp ); |
---|
5940 | |
---|
5941 | while ( 1 != uiTemp ) |
---|
5942 | { |
---|
5943 | uiTemp >>= 1; |
---|
5944 | uiLength += 2; |
---|
5945 | } |
---|
5946 | |
---|
5947 | return uiLength; |
---|
5948 | } |
---|
5949 | |
---|
5950 | |
---|
5951 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
5952 | { |
---|
5953 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
5954 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
5955 | |
---|
5956 | if( iDiffPocD == iDiffPocB ) |
---|
5957 | { |
---|
5958 | return 4096; |
---|
5959 | } |
---|
5960 | else |
---|
5961 | { |
---|
5962 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
5963 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
5964 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
5965 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
---|
5966 | return iScale; |
---|
5967 | } |
---|
5968 | } |
---|
5969 | |
---|
5970 | /** |
---|
5971 | * \param eCUMode |
---|
5972 | * \param uiPartIdx |
---|
5973 | * \param ruiPartIdxCenter |
---|
5974 | * \returns Void |
---|
5975 | */ |
---|
5976 | Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
---|
5977 | { |
---|
5978 | UInt uiPartAddr; |
---|
5979 | Int iPartWidth; |
---|
5980 | Int iPartHeight; |
---|
5981 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
5982 | |
---|
5983 | ruiPartIdxCenter = m_uiAbsIdxInLCU+uiPartAddr; // partition origin. |
---|
5984 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
5985 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInWidth() |
---|
5986 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
---|
5987 | } |
---|
5988 | #if H_3D |
---|
5989 | Void TComDataCU::compressMV(Int scale) |
---|
5990 | #else |
---|
5991 | Void TComDataCU::compressMV() |
---|
5992 | #endif |
---|
5993 | { |
---|
5994 | #if H_3D |
---|
5995 | Int scaleFactor = (4 / scale ) * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
5996 | #else |
---|
5997 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
5998 | #endif |
---|
5999 | if (scaleFactor > 0) |
---|
6000 | { |
---|
6001 | m_acCUMvField[0].compress(m_pePredMode, scaleFactor); |
---|
6002 | m_acCUMvField[1].compress(m_pePredMode, scaleFactor); |
---|
6003 | } |
---|
6004 | } |
---|
6005 | |
---|
6006 | UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) |
---|
6007 | { |
---|
6008 | UInt uiCTXIdx; |
---|
6009 | UInt uiScanIdx; |
---|
6010 | UInt uiDirMode; |
---|
6011 | |
---|
6012 | if ( !bIsIntra ) |
---|
6013 | { |
---|
6014 | uiScanIdx = SCAN_DIAG; |
---|
6015 | return uiScanIdx; |
---|
6016 | } |
---|
6017 | |
---|
6018 | switch(uiWidth) |
---|
6019 | { |
---|
6020 | case 2: uiCTXIdx = 6; break; |
---|
6021 | case 4: uiCTXIdx = 5; break; |
---|
6022 | case 8: uiCTXIdx = 4; break; |
---|
6023 | case 16: uiCTXIdx = 3; break; |
---|
6024 | case 32: uiCTXIdx = 2; break; |
---|
6025 | case 64: uiCTXIdx = 1; break; |
---|
6026 | default: uiCTXIdx = 0; break; |
---|
6027 | } |
---|
6028 | |
---|
6029 | if ( bIsLuma ) |
---|
6030 | { |
---|
6031 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
---|
6032 | #if H_3D_DIM |
---|
6033 | mapDepthModeToIntraDir( uiDirMode ); |
---|
6034 | #endif |
---|
6035 | uiScanIdx = SCAN_DIAG; |
---|
6036 | if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size |
---|
6037 | { |
---|
6038 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
---|
6039 | } |
---|
6040 | } |
---|
6041 | else |
---|
6042 | { |
---|
6043 | uiDirMode = getChromaIntraDir(uiAbsPartIdx); |
---|
6044 | if( uiDirMode == DM_CHROMA_IDX ) |
---|
6045 | { |
---|
6046 | // get number of partitions in current CU |
---|
6047 | UInt depth = getDepth(uiAbsPartIdx); |
---|
6048 | UInt numParts = getPic()->getNumPartInCU() >> (2 * depth); |
---|
6049 | |
---|
6050 | // get luma mode from upper-left corner of current CU |
---|
6051 | uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); |
---|
6052 | #if H_3D_DIM |
---|
6053 | mapDepthModeToIntraDir( uiDirMode ); |
---|
6054 | #endif |
---|
6055 | } |
---|
6056 | uiScanIdx = SCAN_DIAG; |
---|
6057 | if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size |
---|
6058 | { |
---|
6059 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
---|
6060 | } |
---|
6061 | } |
---|
6062 | |
---|
6063 | return uiScanIdx; |
---|
6064 | } |
---|
6065 | |
---|
6066 | UInt TComDataCU::getSCUAddr() |
---|
6067 | { |
---|
6068 | return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; |
---|
6069 | } |
---|
6070 | |
---|
6071 | #if H_3D |
---|
6072 | Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) |
---|
6073 | { |
---|
6074 | riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX(); |
---|
6075 | riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY(); |
---|
6076 | } |
---|
6077 | #endif |
---|
6078 | #if H_3D_IV_MERGE |
---|
6079 | Bool TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp) |
---|
6080 | { |
---|
6081 | |
---|
6082 | assert(getPartitionSize( uiPartAddr ) == SIZE_2Nx2N); |
---|
6083 | |
---|
6084 | TComMv cMv; |
---|
6085 | Int iDisp = getSlice()->getDepthToDisparityB( 0 )[ 128 ]; |
---|
6086 | cMv.setHor(iDisp); |
---|
6087 | cMv.setVer(0); |
---|
6088 | pDisp->m_acNBDV = cMv; |
---|
6089 | pDisp->m_aVIdxCan = 0; |
---|
6090 | |
---|
6091 | return true; |
---|
6092 | } |
---|
6093 | #endif |
---|
6094 | #if H_3D_NBDV |
---|
6095 | //Notes from QC: |
---|
6096 | //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 |
---|
6097 | //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 |
---|
6098 | //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 |
---|
6099 | Bool TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo |
---|
6100 | #if H_3D_NBDV_REF |
---|
6101 | , Bool bDepthRefine |
---|
6102 | #endif |
---|
6103 | ) |
---|
6104 | { |
---|
6105 | //// ******* Init variables ******* ///// |
---|
6106 | // Init disparity struct for results |
---|
6107 | pDInfo->bDV = false; |
---|
6108 | pDInfo->m_aVIdxCan = -1; |
---|
6109 | |
---|
6110 | // Init struct for disparities from MCP neighboring blocks |
---|
6111 | IDVInfo cIDVInfo; |
---|
6112 | cIDVInfo.m_bFound = false; |
---|
6113 | UInt uiPartIdx = 0; |
---|
6114 | UInt uiPartAddr = 0; |
---|
6115 | for (UInt iCurDvMcpCand = 0; iCurDvMcpCand < IDV_CANDS; iCurDvMcpCand++) |
---|
6116 | { |
---|
6117 | for (UInt iList = 0; iList < 2; iList++) |
---|
6118 | { |
---|
6119 | cIDVInfo.m_acMvCand[iList][iCurDvMcpCand].setZero(); |
---|
6120 | cIDVInfo.m_aVIdxCan[iList][iCurDvMcpCand] = 0; |
---|
6121 | cIDVInfo.m_bAvailab[iList][iCurDvMcpCand] = false; |
---|
6122 | } |
---|
6123 | } |
---|
6124 | #if H_3D_NBDV_REF |
---|
6125 | if( !m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ) ) |
---|
6126 | { |
---|
6127 | bDepthRefine = false; |
---|
6128 | } |
---|
6129 | #endif |
---|
6130 | // Get Positions |
---|
6131 | PartSize eCUMode = getPartitionSize( uiPartAddr ); |
---|
6132 | assert(eCUMode == SIZE_2Nx2N); |
---|
6133 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
6134 | |
---|
6135 | deriveLeftRightTopIdxGeneral(uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
6136 | deriveLeftBottomIdxGeneral (uiPartAddr, uiPartIdx, uiPartIdxLB ); |
---|
6137 | |
---|
6138 | //// ******* Get disparity from temporal neighboring blocks ******* ///// |
---|
6139 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
6140 | { |
---|
6141 | TComMv cColMv; |
---|
6142 | Int iTargetViewIdx = 0; |
---|
6143 | Int iTStartViewIdx = 0; |
---|
6144 | |
---|
6145 | ///*** Derive center position *** |
---|
6146 | UInt uiPartIdxCenter; |
---|
6147 | Int uiLCUIdx = getAddr(); |
---|
6148 | xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter ); |
---|
6149 | |
---|
6150 | ///*** Search temporal candidate pictures for disparity vector *** |
---|
6151 | const Int iNumCandPics = getPic()->getNumDdvCandPics(); |
---|
6152 | for(Int curCandPic = 0; curCandPic < iNumCandPics; curCandPic++) |
---|
6153 | { |
---|
6154 | RefPicList eCurRefPicList = REF_PIC_LIST_0 ; |
---|
6155 | Int curCandPicRefIdx = 0; |
---|
6156 | if( curCandPic == 0 ) |
---|
6157 | { |
---|
6158 | eCurRefPicList = RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0); |
---|
6159 | curCandPicRefIdx = getSlice()->getColRefIdx(); |
---|
6160 | } |
---|
6161 | else |
---|
6162 | { |
---|
6163 | eCurRefPicList = getPic()->getRapRefList(); |
---|
6164 | curCandPicRefIdx = getPic()->getRapRefIdx(); |
---|
6165 | } |
---|
6166 | |
---|
6167 | Bool bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, uiLCUIdx, uiPartIdxCenter, cColMv, iTargetViewIdx, iTStartViewIdx ); |
---|
6168 | |
---|
6169 | if( bCheck ) |
---|
6170 | { |
---|
6171 | #if !(NTT_BUG_FIX_TK54) |
---|
6172 | clipMv(cColMv); |
---|
6173 | #endif |
---|
6174 | pDInfo->m_acNBDV = cColMv; |
---|
6175 | pDInfo->m_aVIdxCan = iTargetViewIdx; |
---|
6176 | |
---|
6177 | #if H_3D_NBDV_REF |
---|
6178 | TComPic* picDepth = NULL; |
---|
6179 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
6180 | picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); |
---|
6181 | if ( picDepth->getPicYuvRec() != NULL ) |
---|
6182 | { |
---|
6183 | cColMv.setZero(); |
---|
6184 | } |
---|
6185 | else // Go back with virtual depth |
---|
6186 | { |
---|
6187 | picDepth = getSlice()->getIvPic( true, iTargetViewIdx ); |
---|
6188 | } |
---|
6189 | |
---|
6190 | assert(picDepth != NULL); |
---|
6191 | #else |
---|
6192 | picDepth = getSlice()->getIvPic( true, iTargetViewIdx ); |
---|
6193 | #if !BUG_FIX_TK65 |
---|
6194 | assert(picDepth != NULL); |
---|
6195 | #endif |
---|
6196 | #endif |
---|
6197 | if (picDepth && bDepthRefine) |
---|
6198 | estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv ); |
---|
6199 | |
---|
6200 | pDInfo->m_acDoNBDV = cColMv; |
---|
6201 | #endif //H_3D_NBDV_REF |
---|
6202 | return true; |
---|
6203 | } |
---|
6204 | } |
---|
6205 | } |
---|
6206 | |
---|
6207 | UInt uiIdx = 0; |
---|
6208 | Bool bCheckMcpDv = false; |
---|
6209 | TComDataCU* pcTmpCU = NULL; |
---|
6210 | |
---|
6211 | //// ******* Get disparity from left block ******* ///// |
---|
6212 | pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false); |
---|
6213 | bCheckMcpDv = true; |
---|
6214 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT |
---|
6215 | #if H_3D_NBDV_REF |
---|
6216 | , bDepthRefine |
---|
6217 | #endif |
---|
6218 | ) ) |
---|
6219 | return true; |
---|
6220 | |
---|
6221 | //// ******* Get disparity from above block ******* ///// |
---|
6222 | pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true); |
---|
6223 | if(pcTmpCU != NULL ) |
---|
6224 | { |
---|
6225 | bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0); |
---|
6226 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE |
---|
6227 | #if H_3D_NBDV_REF |
---|
6228 | , bDepthRefine |
---|
6229 | #endif |
---|
6230 | ) ) |
---|
6231 | return true; |
---|
6232 | } |
---|
6233 | |
---|
6234 | //// ******* Search MCP blocks ******* ///// |
---|
6235 | if( cIDVInfo.m_bFound ) |
---|
6236 | { |
---|
6237 | for( Int curPos = 0 ; curPos < IDV_CANDS ; curPos++ ) |
---|
6238 | { |
---|
6239 | for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) |
---|
6240 | { |
---|
6241 | if( cIDVInfo.m_bAvailab[iList][curPos] ) |
---|
6242 | { |
---|
6243 | TComMv cDispVec = cIDVInfo.m_acMvCand[iList][ curPos ]; |
---|
6244 | #if !(NTT_BUG_FIX_TK54) |
---|
6245 | clipMv( cDispVec ); |
---|
6246 | #endif |
---|
6247 | pDInfo->m_acNBDV = cDispVec; |
---|
6248 | pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ]; |
---|
6249 | #if H_3D_NBDV_REF |
---|
6250 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
6251 | TComPic* picDepth = NULL; |
---|
6252 | |
---|
6253 | picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); |
---|
6254 | if ( picDepth->getPicYuvRec() != NULL ) |
---|
6255 | { |
---|
6256 | cDispVec.setZero(); |
---|
6257 | } |
---|
6258 | else // Go back with virtual depth |
---|
6259 | { |
---|
6260 | picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan ); |
---|
6261 | } |
---|
6262 | |
---|
6263 | assert(picDepth != NULL); |
---|
6264 | #else |
---|
6265 | TComPic* picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan ); |
---|
6266 | #if !BUG_FIX_TK65 |
---|
6267 | assert(picDepth!=NULL); |
---|
6268 | #endif |
---|
6269 | #endif |
---|
6270 | |
---|
6271 | if (picDepth && bDepthRefine) |
---|
6272 | { |
---|
6273 | estimateDVFromDM (pDInfo->m_aVIdxCan, uiPartIdx, picDepth, uiPartAddr, &cDispVec); |
---|
6274 | } |
---|
6275 | pDInfo->m_acDoNBDV = cDispVec; |
---|
6276 | #endif |
---|
6277 | return true; |
---|
6278 | } |
---|
6279 | } |
---|
6280 | } |
---|
6281 | } |
---|
6282 | |
---|
6283 | TComMv defaultDV(0, 0); |
---|
6284 | pDInfo->m_acNBDV = defaultDV; |
---|
6285 | |
---|
6286 | Int valid = 0; |
---|
6287 | Int viewIndex = 0; |
---|
6288 | for( UInt uiBId = 0; uiBId < getSlice()->getViewIndex() && valid==0; uiBId++ ) |
---|
6289 | { |
---|
6290 | UInt uiBaseId = uiBId; |
---|
6291 | TComPic* pcBasePic = getSlice()->getIvPic( false, uiBaseId ); |
---|
6292 | for( Int iRefListId = 0; ( iRefListId < (getSlice()->isInterB()? 2:1) ) && !getSlice()->isIntra() && valid==0; iRefListId++ ) |
---|
6293 | { |
---|
6294 | RefPicList eRefPicListTest = RefPicList( iRefListId ); |
---|
6295 | Int iNumRefPics = getSlice()->getNumRefIdx( eRefPicListTest ) ; |
---|
6296 | for( Int iRefIndex = 0; iRefIndex < iNumRefPics; iRefIndex++ ) |
---|
6297 | { |
---|
6298 | if(pcBasePic->getPOC() == getSlice()->getRefPic( eRefPicListTest, iRefIndex )->getPOC() |
---|
6299 | && pcBasePic->getViewIndex() == getSlice()->getRefPic( eRefPicListTest, iRefIndex )->getViewIndex()) |
---|
6300 | { |
---|
6301 | valid=1; |
---|
6302 | viewIndex = uiBaseId; |
---|
6303 | break; |
---|
6304 | } |
---|
6305 | } |
---|
6306 | } |
---|
6307 | } |
---|
6308 | if(valid) |
---|
6309 | { |
---|
6310 | pDInfo->m_aVIdxCan = viewIndex; |
---|
6311 | #if H_3D_NBDV_REF |
---|
6312 | TComPic* picDepth = NULL; |
---|
6313 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
6314 | picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); |
---|
6315 | if ( picDepth->getPicYuvRec() != NULL ) |
---|
6316 | { |
---|
6317 | defaultDV.setZero(); |
---|
6318 | } |
---|
6319 | else // Go back with virtual depth |
---|
6320 | { |
---|
6321 | picDepth = getSlice()->getIvPic( true, viewIndex ); |
---|
6322 | } |
---|
6323 | |
---|
6324 | assert(picDepth != NULL); |
---|
6325 | #else |
---|
6326 | picDepth = getSlice()->getIvPic( true, viewIndex ); |
---|
6327 | #if !BUG_FIX_TK65 |
---|
6328 | assert(picDepth!=NULL); |
---|
6329 | #endif |
---|
6330 | #endif |
---|
6331 | if (picDepth && bDepthRefine) |
---|
6332 | { |
---|
6333 | estimateDVFromDM(viewIndex, uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view |
---|
6334 | } |
---|
6335 | pDInfo->m_acDoNBDV = defaultDV; |
---|
6336 | #endif |
---|
6337 | } |
---|
6338 | return false; |
---|
6339 | } |
---|
6340 | |
---|
6341 | #if H_3D_NBDV_REF |
---|
6342 | Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT ) |
---|
6343 | { |
---|
6344 | Int iPictureWidth = pcBaseViewDepthPicYuv->getWidth(); |
---|
6345 | Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(); |
---|
6346 | |
---|
6347 | Int depthStartPosX = Clip3(0, iPictureWidth - 1, iBlkX + ((mv->getHor()+2)>>2)); |
---|
6348 | Int depthStartPosY = Clip3(0, iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2)); |
---|
6349 | Int depthEndPosX = Clip3(0, iPictureWidth - 1, iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2)); |
---|
6350 | Int depthEndPosY = Clip3(0, iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2)); |
---|
6351 | |
---|
6352 | Pel* depthTL = pcBaseViewDepthPicYuv->getLumaAddr(); |
---|
6353 | Int depStride = pcBaseViewDepthPicYuv->getStride(); |
---|
6354 | |
---|
6355 | Pel maxDepthVal = 0; |
---|
6356 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthStartPosX ]); // Left Top |
---|
6357 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthStartPosX ]); // Left Bottom |
---|
6358 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthEndPosX ]); // Right Top |
---|
6359 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthEndPosX ]); // Right Bottom |
---|
6360 | |
---|
6361 | return aiShiftLUT[ maxDepthVal ]; |
---|
6362 | } |
---|
6363 | |
---|
6364 | Void TComDataCU::estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred ) |
---|
6365 | { |
---|
6366 | if (picDepth) |
---|
6367 | { |
---|
6368 | UInt uiAbsPartAddrCurrCU = m_uiAbsIdxInLCU + uiPartAddr; |
---|
6369 | Int iWidth, iHeight; |
---|
6370 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more |
---|
6371 | |
---|
6372 | TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec(); |
---|
6373 | Int iBlkX = ( getAddr() % picDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; |
---|
6374 | Int iBlkY = ( getAddr() / picDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; |
---|
6375 | |
---|
6376 | Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx ); |
---|
6377 | |
---|
6378 | Pel iDisp = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT ); |
---|
6379 | cMvPred->setHor( iDisp ); |
---|
6380 | #if !(NTT_BUG_FIX_TK54) |
---|
6381 | clipMv(*cMvPred); |
---|
6382 | #endif |
---|
6383 | } |
---|
6384 | } |
---|
6385 | #endif //H_3D_NBDV_REF |
---|
6386 | |
---|
6387 | |
---|
6388 | Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos |
---|
6389 | #if H_3D_NBDV_REF |
---|
6390 | , Bool bDepthRefine |
---|
6391 | #endif |
---|
6392 | ) |
---|
6393 | { |
---|
6394 | if( pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) ) |
---|
6395 | { |
---|
6396 | Bool bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx ); |
---|
6397 | for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) |
---|
6398 | { |
---|
6399 | RefPicList eRefPicList = RefPicList(iList); |
---|
6400 | Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ; |
---|
6401 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
6402 | |
---|
6403 | if( refId >= 0) |
---|
6404 | { |
---|
6405 | Int refViewIdx = pcTmpCU->getSlice()->getRefPic(eRefPicList, refId)->getViewIndex(); |
---|
6406 | if (refViewIdx != m_pcSlice->getViewIndex()) |
---|
6407 | { |
---|
6408 | #if !(NTT_BUG_FIX_TK54) |
---|
6409 | clipMv(cMvPred); |
---|
6410 | #endif |
---|
6411 | pNbDvInfo->m_acNBDV = cMvPred; |
---|
6412 | pNbDvInfo->m_aVIdxCan = refViewIdx; |
---|
6413 | #if H_3D_NBDV_REF |
---|
6414 | TComPic* picDepth = NULL; |
---|
6415 | assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC()); |
---|
6416 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
6417 | picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); |
---|
6418 | if ( picDepth->getPicYuvRec() != NULL ) |
---|
6419 | { |
---|
6420 | cMvPred.setZero(); |
---|
6421 | } |
---|
6422 | else// Go back with virtual depth |
---|
6423 | { |
---|
6424 | picDepth = getSlice()->getIvPic (true, refViewIdx ); |
---|
6425 | } |
---|
6426 | assert(picDepth != NULL); |
---|
6427 | #else |
---|
6428 | picDepth = getSlice()->getIvPic (true, refViewIdx ); |
---|
6429 | #if !BUG_FIX_TK65 |
---|
6430 | assert(picDepth != NULL); |
---|
6431 | #endif |
---|
6432 | #endif |
---|
6433 | UInt uiPartIdx = 0; //Notes from MTK: Please confirm that using 0 as partition index and partition address is correct for CU-level DoNBDV |
---|
6434 | UInt uiPartAddr = 0; //QC: confirmed |
---|
6435 | |
---|
6436 | if (picDepth && bDepthRefine) |
---|
6437 | estimateDVFromDM(refViewIdx, uiPartIdx, picDepth, uiPartAddr, &cMvPred ); |
---|
6438 | |
---|
6439 | pNbDvInfo->m_acDoNBDV = cMvPred; |
---|
6440 | #endif |
---|
6441 | return true; |
---|
6442 | } |
---|
6443 | else if ( bSearchForMvpDv && cMvPred.getIDVFlag() && bTmpIsSkipped ) |
---|
6444 | { |
---|
6445 | assert( uiMvpDvPos < IDV_CANDS ); |
---|
6446 | paIDVInfo->m_acMvCand[iList][ uiMvpDvPos ] = TComMv( cMvPred.getIDVHor(), cMvPred.getIDVVer() ); |
---|
6447 | //Notes from QC: DvMCP is implemented in a way that doesnot carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design. |
---|
6448 | paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = cMvPred.getIDVVId(); |
---|
6449 | paIDVInfo->m_bAvailab[iList][ uiMvpDvPos ] = true; |
---|
6450 | paIDVInfo->m_bFound = true; |
---|
6451 | } |
---|
6452 | } |
---|
6453 | } |
---|
6454 | } |
---|
6455 | return false; |
---|
6456 | } |
---|
6457 | |
---|
6458 | Void TComDataCU::xDeriveRightBottomNbIdx(Int &riLCUIdxRBNb, Int &riPartIdxRBNb ) |
---|
6459 | { |
---|
6460 | UInt uiPartIdx = 0; |
---|
6461 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
6462 | Int uiLCUIdx = getAddr(); |
---|
6463 | |
---|
6464 | UInt uiPartIdxRB; |
---|
6465 | deriveRightBottomIdx(uiPartIdx, uiPartIdxRB ); |
---|
6466 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
6467 | |
---|
6468 | if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
6469 | { |
---|
6470 | riLCUIdxRBNb = -1; |
---|
6471 | riPartIdxRBNb = -1; |
---|
6472 | } |
---|
6473 | else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
6474 | { |
---|
6475 | riLCUIdxRBNb = -1; |
---|
6476 | riPartIdxRBNb = -1; |
---|
6477 | } |
---|
6478 | else |
---|
6479 | { |
---|
6480 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
6481 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
6482 | { |
---|
6483 | riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
6484 | riLCUIdxRBNb = uiLCUIdx; |
---|
6485 | } |
---|
6486 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
6487 | { |
---|
6488 | riPartIdxRBNb = -1; |
---|
6489 | riLCUIdxRBNb = -1; |
---|
6490 | } |
---|
6491 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
6492 | { |
---|
6493 | riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
6494 | riLCUIdxRBNb = uiLCUIdx + 1; |
---|
6495 | } |
---|
6496 | else //is the right bottom corner of LCU |
---|
6497 | { |
---|
6498 | riPartIdxRBNb = -1; |
---|
6499 | riLCUIdxRBNb = -1; |
---|
6500 | } |
---|
6501 | } |
---|
6502 | } |
---|
6503 | |
---|
6504 | |
---|
6505 | Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
6506 | { |
---|
6507 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
6508 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
6509 | { |
---|
6510 | m_pDvInfo[uiAbsPartIdx + ui] = cDvInfo; |
---|
6511 | } |
---|
6512 | } |
---|
6513 | #if H_3D_VSP |
---|
6514 | Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth ) |
---|
6515 | { |
---|
6516 | setSubPartT<DisInfo>( cDvInfo, m_pDvInfo, uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
6517 | } |
---|
6518 | #endif |
---|
6519 | |
---|
6520 | Bool TComDataCU::xGetColDisMV( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx ) |
---|
6521 | { |
---|
6522 | |
---|
6523 | RefPicList eColRefPicList = REF_PIC_LIST_0; |
---|
6524 | Int iColViewIdx, iColRefViewIdx; |
---|
6525 | TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx); |
---|
6526 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
6527 | iColViewIdx = pColCU->getSlice()->getViewIndex(); |
---|
6528 | if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiPartUnitIdx)) |
---|
6529 | { |
---|
6530 | return false; |
---|
6531 | } |
---|
6532 | for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++) |
---|
6533 | { |
---|
6534 | if(pColCU->getSlice()->isInterB()) |
---|
6535 | { |
---|
6536 | eColRefPicList = RefPicList(ilist); |
---|
6537 | } |
---|
6538 | |
---|
6539 | Int iColRefIdx = pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartUnitIdx); |
---|
6540 | |
---|
6541 | if (iColRefIdx < 0) |
---|
6542 | { |
---|
6543 | continue; |
---|
6544 | } |
---|
6545 | |
---|
6546 | iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewIndex(); |
---|
6547 | |
---|
6548 | if ( iColViewIdx == iColRefViewIdx ) // temporal vector |
---|
6549 | { |
---|
6550 | continue; |
---|
6551 | } |
---|
6552 | else |
---|
6553 | { |
---|
6554 | if(getPic()->isTempIVRefValid(currCandPic, ilist, iColRefIdx)) |
---|
6555 | { |
---|
6556 | rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartUnitIdx); |
---|
6557 | rcMv.setIDVFlag(0); |
---|
6558 | iTargetViewIdx = iColRefViewIdx ; |
---|
6559 | iStartViewIdx = iColViewIdx ; |
---|
6560 | return true; |
---|
6561 | } |
---|
6562 | } |
---|
6563 | } |
---|
6564 | |
---|
6565 | return false; |
---|
6566 | } |
---|
6567 | #endif |
---|
6568 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
6569 | Void |
---|
6570 | TComDataCU::getIVNStatus ( UInt uiPartIdx, DisInfo* pDInfo, Bool& bIVFMerge, Int& iIVFMaxD) |
---|
6571 | { |
---|
6572 | TComSlice* pcSlice = getSlice (); |
---|
6573 | Int iViewIndex = pDInfo->m_aVIdxCan; |
---|
6574 | //--- get base CU/PU and check prediction mode --- |
---|
6575 | TComPic* pcBasePic = pcSlice->getIvPic( false, iViewIndex ); |
---|
6576 | TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); |
---|
6577 | |
---|
6578 | UInt uiPartAddr; |
---|
6579 | Int iWidth; |
---|
6580 | Int iHeight; |
---|
6581 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
6582 | |
---|
6583 | Int iCurrPosX, iCurrPosY; |
---|
6584 | pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
6585 | |
---|
6586 | iCurrPosX += ( ( iWidth - 1 ) >> 1 ); |
---|
6587 | iCurrPosY += ( ( iHeight - 1 ) >> 1 ); |
---|
6588 | |
---|
6589 | Bool depthRefineFlag = false; |
---|
6590 | #if H_3D_NBDV_REF |
---|
6591 | depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ); |
---|
6592 | #endif // H_3D_NBDV_REF |
---|
6593 | |
---|
6594 | TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
---|
6595 | if( depthRefineFlag ) |
---|
6596 | { |
---|
6597 | cDv.setVer(0); |
---|
6598 | } |
---|
6599 | |
---|
6600 | Int iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6601 | Int iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6602 | Int iBaseLPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX - (iWidth >> 1) + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6603 | Int iBaseLPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6604 | Int iBaseRPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + (iWidth >> 1) + 1 + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6605 | Int iBaseRPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6606 | Int iBaseUPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6607 | Int iBaseUPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY - (iHeight >> 1) + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6608 | Int iBaseDPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6609 | Int iBaseDPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + (iHeight >> 1) + 1 + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6610 | |
---|
6611 | Int iBaseCUAddr; |
---|
6612 | Int iBaseAbsPartIdx; |
---|
6613 | Int iBaseLCUAddr; |
---|
6614 | Int iBaseLAbsPartIdx; |
---|
6615 | Int iBaseRCUAddr; |
---|
6616 | Int iBaseRAbsPartIdx; |
---|
6617 | Int iBaseUCUAddr; |
---|
6618 | Int iBaseUAbsPartIdx; |
---|
6619 | Int iBaseDCUAddr; |
---|
6620 | Int iBaseDAbsPartIdx; |
---|
6621 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); |
---|
6622 | pcBaseRec->getCUAddrAndPartIdx( iBaseLPosX , iBaseLPosY , iBaseLCUAddr, iBaseLAbsPartIdx ); |
---|
6623 | pcBaseRec->getCUAddrAndPartIdx( iBaseRPosX , iBaseRPosY , iBaseRCUAddr, iBaseRAbsPartIdx ); |
---|
6624 | pcBaseRec->getCUAddrAndPartIdx( iBaseUPosX , iBaseUPosY , iBaseUCUAddr, iBaseUAbsPartIdx ); |
---|
6625 | pcBaseRec->getCUAddrAndPartIdx( iBaseDPosX , iBaseDPosY , iBaseDCUAddr, iBaseDAbsPartIdx ); |
---|
6626 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
---|
6627 | TComDataCU* pcBaseLCU = pcBasePic->getCU( iBaseLCUAddr ); |
---|
6628 | TComDataCU* pcBaseRCU = pcBasePic->getCU( iBaseRCUAddr ); |
---|
6629 | TComDataCU* pcBaseUCU = pcBasePic->getCU( iBaseUCUAddr ); |
---|
6630 | TComDataCU* pcBaseDCU = pcBasePic->getCU( iBaseDCUAddr ); |
---|
6631 | bIVFMerge = pcBaseLCU->getMergeFlag( iBaseLAbsPartIdx ) && pcBaseCU->getMergeFlag( iBaseAbsPartIdx ) && pcBaseRCU->getMergeFlag( iBaseRAbsPartIdx ) && pcBaseUCU->getMergeFlag( iBaseUAbsPartIdx ) && pcBaseDCU->getMergeFlag( iBaseDAbsPartIdx ); |
---|
6632 | Int aiDepthL[5]; //depth level |
---|
6633 | aiDepthL[0] = pcBaseCU->getDepth(iBaseAbsPartIdx); |
---|
6634 | aiDepthL[1] = pcBaseLCU->getDepth(iBaseLAbsPartIdx); |
---|
6635 | aiDepthL[2] = pcBaseRCU->getDepth(iBaseRAbsPartIdx); |
---|
6636 | aiDepthL[3] = pcBaseUCU->getDepth(iBaseUAbsPartIdx); |
---|
6637 | aiDepthL[4] = pcBaseDCU->getDepth(iBaseDAbsPartIdx); |
---|
6638 | for (Int i = 0; i < 5; i++) |
---|
6639 | { |
---|
6640 | if (iIVFMaxD < aiDepthL[i]) |
---|
6641 | iIVFMaxD = aiDepthL[i]; |
---|
6642 | } |
---|
6643 | } |
---|
6644 | #endif |
---|
6645 | |
---|
6646 | #if H_3D_SPIVMP |
---|
6647 | Void TComDataCU::getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight) |
---|
6648 | { |
---|
6649 | Int iSubPUSize = 1<<getSlice()->getVPS()->getSubPULog2Size(getSlice()->getLayerId()); |
---|
6650 | if( getSlice()->getIsDepth() ) |
---|
6651 | { |
---|
6652 | iSubPUSize = 1 << getSlice()->getVPS()->getSubPUMPILog2Size(); |
---|
6653 | } |
---|
6654 | |
---|
6655 | iNumSPInOneLine = iPUWidth/iSubPUSize; |
---|
6656 | iNumSPInOneLine = iNumSPInOneLine < 1 ? 1: iNumSPInOneLine; |
---|
6657 | Int iNumSPInOneColumn = iPUHeight/iSubPUSize; |
---|
6658 | iNumSPInOneColumn = iNumSPInOneColumn < 1 ? 1: iNumSPInOneColumn; |
---|
6659 | iNumSP = iNumSPInOneLine * iNumSPInOneColumn; |
---|
6660 | |
---|
6661 | iSPWidth = iNumSPInOneLine == 1 ? iPUWidth: iSubPUSize; |
---|
6662 | iSPHeight = iNumSPInOneColumn == 1 ? iPUHeight: iSubPUSize; |
---|
6663 | } |
---|
6664 | |
---|
6665 | Void TComDataCU::getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr ) |
---|
6666 | { |
---|
6667 | uiBaseAbsPartIdx += m_uiAbsIdxInLCU; |
---|
6668 | Int iBasePelX = g_auiRasterToPelX[g_auiZscanToRaster[uiBaseAbsPartIdx]]; |
---|
6669 | Int iBasePelY = g_auiRasterToPelY[g_auiZscanToRaster[uiBaseAbsPartIdx]]; |
---|
6670 | Int iCurrPelX = iBasePelX + iPartIdx%iNumPartLine * iWidth; |
---|
6671 | Int iCurrPelY = iBasePelY + iPartIdx/iNumPartLine * iHeight; |
---|
6672 | Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + iCurrPelX/getPic()->getMinCUWidth(); |
---|
6673 | ruiPartAddr = g_auiRasterToZscan[iCurrRaster]; |
---|
6674 | ruiPartAddr -= m_uiAbsIdxInLCU; |
---|
6675 | } |
---|
6676 | |
---|
6677 | Void TComDataCU::setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight ) |
---|
6678 | { |
---|
6679 | uiAbsPartIdx += getZorderIdxInCU(); |
---|
6680 | Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]]; |
---|
6681 | Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]]; |
---|
6682 | Int iEndPelX = iStartPelX + iWidth; |
---|
6683 | Int iEndPelY = iStartPelY + iHeight; |
---|
6684 | |
---|
6685 | Int iCurrRaster, uiPartAddr; |
---|
6686 | |
---|
6687 | for (Int i=iStartPelY; i<iEndPelY; i+=getPic()->getMinCUHeight()) |
---|
6688 | { |
---|
6689 | for (Int j=iStartPelX; j < iEndPelX; j += getPic()->getMinCUWidth()) |
---|
6690 | { |
---|
6691 | iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + j/getPic()->getMinCUWidth(); |
---|
6692 | uiPartAddr = g_auiRasterToZscan[iCurrRaster]; |
---|
6693 | uiPartAddr -= getZorderIdxInCU(); |
---|
6694 | |
---|
6695 | m_puhInterDir[uiPartAddr] = uiDir; |
---|
6696 | } |
---|
6697 | } |
---|
6698 | } |
---|
6699 | #endif |
---|
6700 | |
---|
6701 | #if H_3D_IV_MERGE |
---|
6702 | Bool |
---|
6703 | TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc , Bool bIsDepth |
---|
6704 | #if H_3D_SPIVMP |
---|
6705 | , TComMvField* pcMvFieldSP, UChar* puhInterDirSP |
---|
6706 | #endif |
---|
6707 | , Bool bICFlag |
---|
6708 | ) |
---|
6709 | { |
---|
6710 | TComSlice* pcSlice = getSlice (); |
---|
6711 | Int iViewIndex = pDInfo->m_aVIdxCan; |
---|
6712 | |
---|
6713 | //--- get base CU/PU and check prediction mode --- |
---|
6714 | TComPic* pcBasePic = pcSlice->getIvPic( bIsDepth, iViewIndex ); |
---|
6715 | TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); |
---|
6716 | |
---|
6717 | UInt uiPartAddr; |
---|
6718 | Int iWidth; |
---|
6719 | Int iHeight; |
---|
6720 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
6721 | |
---|
6722 | Int iCurrPosX, iCurrPosY; |
---|
6723 | pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
6724 | |
---|
6725 | #if !H_3D_SPIVMP |
---|
6726 | iCurrPosX += ( iWidth >> 1 ); |
---|
6727 | iCurrPosY += ( iHeight >> 1 ); |
---|
6728 | #endif |
---|
6729 | |
---|
6730 | Bool depthRefineFlag = false; |
---|
6731 | #if H_3D_NBDV_REF |
---|
6732 | depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ); |
---|
6733 | #endif // H_3D_NBDV_REF |
---|
6734 | |
---|
6735 | TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
---|
6736 | if( depthRefineFlag ) |
---|
6737 | { |
---|
6738 | cDv.setVer(0); |
---|
6739 | } |
---|
6740 | |
---|
6741 | Bool abPdmAvailable[8] = {false, false, false, false, false, false, false, false}; |
---|
6742 | #if H_3D_NBDV |
---|
6743 | for( Int i = 0; i < 8; i++) |
---|
6744 | { |
---|
6745 | pacPdmMv[i].setIDVFlag (false); |
---|
6746 | } |
---|
6747 | #endif |
---|
6748 | |
---|
6749 | if(!bICFlag) |
---|
6750 | { |
---|
6751 | |
---|
6752 | #if H_3D_SPIVMP |
---|
6753 | //////////////////////////////// |
---|
6754 | //////////sub-PU IvMC/////////// |
---|
6755 | //////////////////////////////// |
---|
6756 | if(!m_pcSlice->getIsDepth()) |
---|
6757 | { |
---|
6758 | if (!getDBBPFlag(0)) |
---|
6759 | { |
---|
6760 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
6761 | getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
6762 | |
---|
6763 | for (Int i=0; i<iNumSP; i++) |
---|
6764 | { |
---|
6765 | puhInterDirSP[i] = 0; |
---|
6766 | pcMvFieldSP[2*i].getMv().set(0, 0); |
---|
6767 | pcMvFieldSP[2*i+1].getMv().set(0,0); |
---|
6768 | pcMvFieldSP[2*i].setRefIdx(-1); |
---|
6769 | pcMvFieldSP[2*i+1].setRefIdx(-1); |
---|
6770 | } |
---|
6771 | |
---|
6772 | Int iBaseCUAddr; |
---|
6773 | Int iBaseAbsPartIdx; |
---|
6774 | TComDataCU* pcBaseCU; |
---|
6775 | Int iPartition = 0; |
---|
6776 | |
---|
6777 | Int iDelX = iSPWidth/2; |
---|
6778 | Int iDelY = iSPHeight/2; |
---|
6779 | |
---|
6780 | Int iCenterPosX = iCurrPosX + ( ( iWidth / iSPWidth ) >> 1 ) * iSPWidth + ( iSPWidth >> 1 ); |
---|
6781 | Int iCenterPosY = iCurrPosY + ( ( iHeight / iSPHeight ) >> 1 ) * iSPHeight + (iSPHeight >> 1); |
---|
6782 | Int iRefCenterCUAddr, iRefCenterAbsPartIdx; |
---|
6783 | |
---|
6784 | if(iWidth == iSPWidth && iHeight == iSPHeight) |
---|
6785 | { |
---|
6786 | iCenterPosX = iCurrPosX + (iWidth >> 1); |
---|
6787 | iCenterPosY = iCurrPosY + (iHeight >> 1); |
---|
6788 | } |
---|
6789 | |
---|
6790 | Int iRefCenterPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
---|
6791 | Int iRefCenterPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) ); |
---|
6792 | |
---|
6793 | pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx ); |
---|
6794 | TComDataCU* pcDefaultCU = pcBasePic->getCU( iRefCenterCUAddr ); |
---|
6795 | if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA )) |
---|
6796 | { |
---|
6797 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
6798 | { |
---|
6799 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
6800 | Bool stopLoop = false; |
---|
6801 | for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop) |
---|
6802 | { |
---|
6803 | RefPicList eDefaultRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); |
---|
6804 | TComMvField cDefaultMvField; |
---|
6805 | pcDefaultCU->getMvField( pcDefaultCU, iRefCenterAbsPartIdx, eDefaultRefPicList, cDefaultMvField ); |
---|
6806 | Int iDefaultRefIdx = cDefaultMvField.getRefIdx(); |
---|
6807 | if (iDefaultRefIdx >= 0) |
---|
6808 | { |
---|
6809 | Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eDefaultRefPicList, iDefaultRefIdx); |
---|
6810 | if (iDefaultRefPOC != pcSlice->getPOC()) |
---|
6811 | { |
---|
6812 | for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) |
---|
6813 | { |
---|
6814 | if (iDefaultRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) |
---|
6815 | { |
---|
6816 | abPdmAvailable[ uiCurrRefListId ] = true; |
---|
6817 | TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer()); |
---|
6818 | #if H_3D_NBDV |
---|
6819 | #if H_3D_IV_MERGE |
---|
6820 | if( !bIsDepth ) |
---|
6821 | { |
---|
6822 | #endif |
---|
6823 | cMv.setIDVFlag (true); |
---|
6824 | cMv.setIDVHor (cDv.getHor()); |
---|
6825 | cMv.setIDVVer (cDv.getVer()); |
---|
6826 | cMv.setIDVVId (iViewIndex); |
---|
6827 | #if H_3D_IV_MERGE |
---|
6828 | } |
---|
6829 | #endif |
---|
6830 | #endif |
---|
6831 | #if !(NTT_BUG_FIX_TK54) |
---|
6832 | clipMv( cMv ); |
---|
6833 | #endif |
---|
6834 | paiPdmRefIdx [ uiCurrRefListId ] = iPdmRefIdx; |
---|
6835 | pacPdmMv [ uiCurrRefListId ] = cMv; |
---|
6836 | stopLoop = true; |
---|
6837 | break; |
---|
6838 | } |
---|
6839 | } |
---|
6840 | } |
---|
6841 | } |
---|
6842 | } |
---|
6843 | } |
---|
6844 | } |
---|
6845 | availableMcDc[0] = ( abPdmAvailable[0]? 1 : 0) + (abPdmAvailable[1]? 2 : 0); |
---|
6846 | |
---|
6847 | if(availableMcDc[0]) |
---|
6848 | { |
---|
6849 | |
---|
6850 | Int iBasePosX, iBasePosY; |
---|
6851 | for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iSPHeight) |
---|
6852 | { |
---|
6853 | for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth) |
---|
6854 | { |
---|
6855 | iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 )); |
---|
6856 | iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 )); |
---|
6857 | |
---|
6858 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx ); |
---|
6859 | pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
---|
6860 | if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA )) |
---|
6861 | { |
---|
6862 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
6863 | { |
---|
6864 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
6865 | Bool bLoop_stop = false; |
---|
6866 | for(Int iLoop = 0; iLoop < 2 && !bLoop_stop; ++iLoop) |
---|
6867 | { |
---|
6868 | RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); |
---|
6869 | TComMvField cBaseMvField; |
---|
6870 | pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField ); |
---|
6871 | Int iBaseRefIdx = cBaseMvField.getRefIdx(); |
---|
6872 | if (iBaseRefIdx >= 0) |
---|
6873 | { |
---|
6874 | Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx); |
---|
6875 | if (iBaseRefPOC != pcSlice->getPOC()) |
---|
6876 | { |
---|
6877 | for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) |
---|
6878 | { |
---|
6879 | if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) |
---|
6880 | { |
---|
6881 | abPdmAvailable[ uiCurrRefListId ] = true; |
---|
6882 | TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer()); |
---|
6883 | |
---|
6884 | if( !bIsDepth ) |
---|
6885 | { |
---|
6886 | cMv.setIDVFlag (true); |
---|
6887 | cMv.setIDVHor (cDv.getHor()); |
---|
6888 | cMv.setIDVVer (cDv.getVer()); |
---|
6889 | cMv.setIDVVId (iViewIndex); |
---|
6890 | } |
---|
6891 | |
---|
6892 | #if !(NTT_BUG_FIX_TK54) |
---|
6893 | clipMv( cMv ); |
---|
6894 | #endif |
---|
6895 | bLoop_stop = true; |
---|
6896 | |
---|
6897 | pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iPdmRefIdx); |
---|
6898 | break; |
---|
6899 | } |
---|
6900 | } |
---|
6901 | } |
---|
6902 | } |
---|
6903 | } |
---|
6904 | } |
---|
6905 | } |
---|
6906 | |
---|
6907 | puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0); |
---|
6908 | if (puhInterDirSP[iPartition] == 0) |
---|
6909 | { |
---|
6910 | puhInterDirSP[iPartition] = availableMcDc[0]; |
---|
6911 | pcMvFieldSP[2*iPartition].setMvField(pacPdmMv[0], paiPdmRefIdx[0]); |
---|
6912 | pcMvFieldSP[2*iPartition + 1].setMvField(pacPdmMv[1], paiPdmRefIdx[1]); |
---|
6913 | |
---|
6914 | } |
---|
6915 | if (iSPHeight + iSPWidth == 12) |
---|
6916 | { |
---|
6917 | if (puhInterDirSP[iPartition] == 3) |
---|
6918 | { |
---|
6919 | puhInterDirSP[iPartition] = 1; |
---|
6920 | pcMvFieldSP[2*iPartition + 1].setMvField(TComMv(0,0), -1); |
---|
6921 | } |
---|
6922 | } |
---|
6923 | iPartition ++; |
---|
6924 | } |
---|
6925 | } |
---|
6926 | } |
---|
6927 | } |
---|
6928 | |
---|
6929 | iCurrPosX += ( iWidth >> 1 ); |
---|
6930 | iCurrPosY += ( iHeight >> 1 ); |
---|
6931 | } |
---|
6932 | #endif |
---|
6933 | |
---|
6934 | //////////////////////////////// |
---|
6935 | /////// IvMC + IvMCShift /////// |
---|
6936 | //////////////////////////////// |
---|
6937 | |
---|
6938 | #if H_3D_SPIVMP |
---|
6939 | if(m_pcSlice->getIsDepth()) |
---|
6940 | { |
---|
6941 | iCurrPosX += ( iWidth >> 1 ); |
---|
6942 | iCurrPosY += ( iHeight >> 1 ); |
---|
6943 | } |
---|
6944 | for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) |
---|
6945 | #else |
---|
6946 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
6947 | #endif |
---|
6948 | { |
---|
6949 | // iLoopCan == 0 --> IvMC |
---|
6950 | // iLoopCan == 1 --> IvMCShift |
---|
6951 | |
---|
6952 | Int iBaseCUAddr; |
---|
6953 | Int iBaseAbsPartIdx; |
---|
6954 | |
---|
6955 | Int offsetW = (iLoopCan == 0) ? 0 : ( ((iWidth /2)*4) + 4 ); |
---|
6956 | Int offsetH = (iLoopCan == 0) ? 0 : ( ((iHeight/2)*4) + 4 ); |
---|
6957 | |
---|
6958 | Int iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) ); |
---|
6959 | Int iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); |
---|
6960 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); |
---|
6961 | |
---|
6962 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
---|
6963 | if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA )) |
---|
6964 | { |
---|
6965 | // Loop reference picture list of current slice (X in spec). |
---|
6966 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
---|
6967 | { |
---|
6968 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
---|
6969 | |
---|
6970 | Bool stopLoop = false; |
---|
6971 | // Loop reference picture list of candidate slice (Y in spec) |
---|
6972 | for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop) |
---|
6973 | { |
---|
6974 | RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); |
---|
6975 | TComMvField cBaseMvField; |
---|
6976 | pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField ); |
---|
6977 | Int iBaseRefIdx = cBaseMvField.getRefIdx(); |
---|
6978 | if (iBaseRefIdx >= 0) |
---|
6979 | { |
---|
6980 | Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx); |
---|
6981 | if (iBaseRefPOC != pcSlice->getPOC()) |
---|
6982 | { |
---|
6983 | for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) |
---|
6984 | { |
---|
6985 | if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) |
---|
6986 | { |
---|
6987 | abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true; |
---|
6988 | TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer()); |
---|
6989 | #if H_3D_NBDV |
---|
6990 | #if H_3D_IV_MERGE |
---|
6991 | if( !bIsDepth ) |
---|
6992 | { |
---|
6993 | #endif |
---|
6994 | cMv.setIDVFlag (true); |
---|
6995 | cMv.setIDVHor (cDv.getHor()); |
---|
6996 | cMv.setIDVVer (cDv.getVer()); |
---|
6997 | cMv.setIDVVId (iViewIndex); |
---|
6998 | #if H_3D_IV_MERGE |
---|
6999 | } |
---|
7000 | #endif |
---|
7001 | #endif |
---|
7002 | #if !(NTT_BUG_FIX_TK54) |
---|
7003 | clipMv( cMv ); |
---|
7004 | #endif |
---|
7005 | paiPdmRefIdx [ (uiCurrRefListId + (iLoopCan<<2)) ] = iPdmRefIdx; |
---|
7006 | pacPdmMv [ (uiCurrRefListId + (iLoopCan<<2)) ] = cMv; |
---|
7007 | stopLoop = true; |
---|
7008 | break; |
---|
7009 | } |
---|
7010 | } |
---|
7011 | } |
---|
7012 | } |
---|
7013 | } |
---|
7014 | } |
---|
7015 | } |
---|
7016 | } |
---|
7017 | #if H_3D_SPIVMP |
---|
7018 | for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) |
---|
7019 | #else |
---|
7020 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
7021 | #endif |
---|
7022 | { |
---|
7023 | availableMcDc[(iLoopCan << 1)] = ( abPdmAvailable[(iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[1 + (iLoopCan<<2)] ? 2 : 0); |
---|
7024 | } |
---|
7025 | |
---|
7026 | } |
---|
7027 | |
---|
7028 | //////////////////////////////// |
---|
7029 | /////// IvDC + IvDCShift /////// |
---|
7030 | //////////////////////////////// |
---|
7031 | |
---|
7032 | if( !getSlice()->getIsDepth() ) |
---|
7033 | { |
---|
7034 | for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ ) |
---|
7035 | { |
---|
7036 | RefPicList eRefPicListDMV = RefPicList( iRefListId ); |
---|
7037 | Int iNumRefPics = pcSlice->getNumRefIdx( eRefPicListDMV ); |
---|
7038 | for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ ) |
---|
7039 | { |
---|
7040 | if(( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC()) && (pcSlice->getRefPic( eRefPicListDMV, iPdmRefIdx )->getViewIndex() == pDInfo->m_aVIdxCan)) |
---|
7041 | { |
---|
7042 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
7043 | { |
---|
7044 | Int ioffsetDV = (iLoopCan == 0) ? 0 : 4; |
---|
7045 | abPdmAvailable[ iRefListId + 2 + (iLoopCan<<2) ] = true; |
---|
7046 | paiPdmRefIdx [ iRefListId + 2 + (iLoopCan<<2) ] = iPdmRefIdx; |
---|
7047 | #if H_3D_NBDV_REF |
---|
7048 | TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
---|
7049 | #endif |
---|
7050 | cMv.setHor( cMv.getHor() + ioffsetDV ); |
---|
7051 | #if H_3D_IV_MERGE |
---|
7052 | if( bIsDepth ) |
---|
7053 | { |
---|
7054 | cMv.setHor((cMv.getHor()+2)>>2); |
---|
7055 | } |
---|
7056 | #endif |
---|
7057 | cMv.setVer( 0 ); |
---|
7058 | #if !(NTT_BUG_FIX_TK54) |
---|
7059 | clipMv( cMv ); |
---|
7060 | #endif |
---|
7061 | pacPdmMv [iRefListId + 2 + (iLoopCan<<2)] = cMv; |
---|
7062 | } |
---|
7063 | break; |
---|
7064 | } |
---|
7065 | } |
---|
7066 | } |
---|
7067 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
---|
7068 | { |
---|
7069 | availableMcDc[1 + (iLoopCan << 1)] = ( abPdmAvailable[2 + (iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[3 + (iLoopCan<<2)] ? 2 : 0 ); |
---|
7070 | } |
---|
7071 | } |
---|
7072 | return false; |
---|
7073 | } |
---|
7074 | #endif |
---|
7075 | #if H_3D_ARP |
---|
7076 | Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
7077 | { |
---|
7078 | assert( sizeof( *m_puhARPW) == 1 ); |
---|
7079 | memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
7080 | } |
---|
7081 | #endif |
---|
7082 | |
---|
7083 | #if H_3D_IC |
---|
7084 | Void TComDataCU::setICFlagSubParts( Bool bICFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
7085 | { |
---|
7086 | memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ))*sizeof(Bool) ); |
---|
7087 | } |
---|
7088 | |
---|
7089 | Bool TComDataCU::isICFlagRequired( UInt uiAbsPartIdx ) |
---|
7090 | { |
---|
7091 | UInt uiPartAddr; |
---|
7092 | UInt iNumbPart; |
---|
7093 | |
---|
7094 | if( !( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ) |
---|
7095 | { |
---|
7096 | return false; |
---|
7097 | } |
---|
7098 | |
---|
7099 | if( getSlice()->getIcSkipParseFlag() ) |
---|
7100 | { |
---|
7101 | if( getMergeFlag( uiAbsPartIdx ) && getMergeIndex( uiAbsPartIdx ) == 0 ) |
---|
7102 | { |
---|
7103 | return false; |
---|
7104 | } |
---|
7105 | } |
---|
7106 | |
---|
7107 | if( getMergeFlag( uiAbsPartIdx ) ) |
---|
7108 | { |
---|
7109 | return true; |
---|
7110 | } |
---|
7111 | |
---|
7112 | |
---|
7113 | Int iWidth, iHeight; |
---|
7114 | |
---|
7115 | iNumbPart = ( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ? 1 : ( getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 ) ); |
---|
7116 | |
---|
7117 | for(UInt i = 0; i < iNumbPart; i++) |
---|
7118 | { |
---|
7119 | getPartIndexAndSize( i, uiPartAddr, iWidth, iHeight, uiAbsPartIdx, true ); |
---|
7120 | uiPartAddr += uiAbsPartIdx; |
---|
7121 | |
---|
7122 | for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++) |
---|
7123 | { |
---|
7124 | RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
7125 | Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr); |
---|
7126 | |
---|
7127 | if( ( getInterDir( uiPartAddr ) & ( uiRefIdx+1 ) ) && iBestRefIdx >= 0 && getSlice()->getViewIndex() != getSlice()->getRefPic( eRefList, iBestRefIdx )->getViewIndex() ) |
---|
7128 | { |
---|
7129 | return true; |
---|
7130 | } |
---|
7131 | } |
---|
7132 | } |
---|
7133 | |
---|
7134 | return false; |
---|
7135 | } |
---|
7136 | #endif |
---|
7137 | #if H_3D_DIM_DMM |
---|
7138 | Void TComDataCU::setDmmWedgeTabIdxSubParts( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
7139 | { |
---|
7140 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
7141 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmmWedgeTabIdx[dmmType][uiAbsPartIdx+ui] = tabIdx; } |
---|
7142 | } |
---|
7143 | #endif |
---|
7144 | |
---|
7145 | #if H_3D_VSP |
---|
7146 | Void TComDataCU::setMvFieldPUForVSP( TComDataCU* pcCU, UInt partAddr, Int width, Int height, RefPicList eRefPicList, Int iRefIdx, Int &vspSize ) |
---|
7147 | { |
---|
7148 | // Get depth reference |
---|
7149 | Int depthRefViewIdx = pcCU->getDvInfo(partAddr).m_aVIdxCan; |
---|
7150 | |
---|
7151 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
7152 | TComPic* pRefPicBaseDepth = 0; |
---|
7153 | Bool bIsCurrDepthCoded = false; |
---|
7154 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() ); |
---|
7155 | if ( pRefPicBaseDepth->getPicYuvRec() != NULL ) |
---|
7156 | { |
---|
7157 | bIsCurrDepthCoded = true; |
---|
7158 | } |
---|
7159 | else |
---|
7160 | { |
---|
7161 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
7162 | } |
---|
7163 | #else |
---|
7164 | TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
7165 | #endif |
---|
7166 | assert(pRefPicBaseDepth != NULL); |
---|
7167 | TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); |
---|
7168 | assert(pcBaseViewDepthPicYuv != NULL); |
---|
7169 | pcBaseViewDepthPicYuv->extendPicBorder(); |
---|
7170 | |
---|
7171 | // Get texture reference |
---|
7172 | assert(iRefIdx >= 0); |
---|
7173 | TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); |
---|
7174 | TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); |
---|
7175 | assert(pcBaseViewTxtPicYuv != NULL); |
---|
7176 | |
---|
7177 | // Initialize LUT according to the reference viewIdx |
---|
7178 | Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex(); |
---|
7179 | Int* pShiftLUT = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx ); |
---|
7180 | assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() ); |
---|
7181 | |
---|
7182 | // prepare Dv to access depth map or reference view |
---|
7183 | TComMv cDv = pcCU->getDvInfo(partAddr).m_acNBDV; |
---|
7184 | pcCU->clipMv(cDv); |
---|
7185 | |
---|
7186 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
7187 | if ( bIsCurrDepthCoded ) |
---|
7188 | { |
---|
7189 | cDv.setZero(); |
---|
7190 | } |
---|
7191 | #endif |
---|
7192 | |
---|
7193 | // fetch virtual depth map & convert depth to motion vector, which are stored in the motion memory |
---|
7194 | xSetMvFieldForVSP( pcCU, pcBaseViewDepthPicYuv, &cDv, partAddr, width, height, pShiftLUT, eRefPicList, iRefIdx, pcCU->getSlice()->getIsDepth(), vspSize ); |
---|
7195 | } |
---|
7196 | |
---|
7197 | Void TComDataCU::xSetMvFieldForVSP( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, Int *shiftLUT, RefPicList refPicList, Int refIdx, Bool isDepth, Int &vspSize ) |
---|
7198 | { |
---|
7199 | TComCUMvField *cuMvField = cu->getCUMvField( refPicList ); |
---|
7200 | Int partAddrRasterSubPULine = g_auiZscanToRaster[ partAddr ]; |
---|
7201 | Int numPartsLine = cu->getPic()->getNumPartInWidth(); |
---|
7202 | |
---|
7203 | Int nTxtPerMvInfoX = 4; // cu->getPic()->getMinCUWidth(); |
---|
7204 | Int nTxtPerMvInfoY = 4; // cu->getPic()->getMinCUHeight(); |
---|
7205 | |
---|
7206 | Int refDepStride = picRefDepth->getStride(); |
---|
7207 | |
---|
7208 | TComMv tmpMv(0, 0); |
---|
7209 | tmpMv.setIDVFlag(false); |
---|
7210 | |
---|
7211 | Int refDepOffset = ( (dv->getHor()+2) >> 2 ) + ( (dv->getVer()+2) >> 2 ) * refDepStride; |
---|
7212 | Pel *refDepth = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refDepOffset; |
---|
7213 | |
---|
7214 | if ((height % 8)) |
---|
7215 | { |
---|
7216 | vspSize = 1; // 8x4 |
---|
7217 | } |
---|
7218 | else if ((width % 8)) |
---|
7219 | { |
---|
7220 | vspSize = 0; // 4x8 |
---|
7221 | } |
---|
7222 | else |
---|
7223 | { |
---|
7224 | Bool ULvsBR, URvsBL; |
---|
7225 | ULvsBR = refDepth[0] < refDepth[refDepStride * (height-1) + width-1]; |
---|
7226 | URvsBL = refDepth[width-1] < refDepth[refDepStride * (height-1)]; |
---|
7227 | vspSize = ( ULvsBR ^ URvsBL ) ? 0 : 1; |
---|
7228 | } |
---|
7229 | |
---|
7230 | Int subBlockW, subBlockH; |
---|
7231 | if (vspSize) |
---|
7232 | { |
---|
7233 | subBlockW = 8; |
---|
7234 | subBlockH = 4; |
---|
7235 | } |
---|
7236 | else |
---|
7237 | { |
---|
7238 | subBlockW = 4; |
---|
7239 | subBlockH = 8; |
---|
7240 | } |
---|
7241 | |
---|
7242 | Int numPartsInSubPUW = subBlockW / nTxtPerMvInfoX; |
---|
7243 | Int numPartsInSubPUH = subBlockH / nTxtPerMvInfoY * numPartsLine; |
---|
7244 | |
---|
7245 | for( Int y=0; y<height; y+=subBlockH, partAddrRasterSubPULine+=numPartsInSubPUH ) |
---|
7246 | { |
---|
7247 | Pel *refDepthTmp[4]; |
---|
7248 | refDepthTmp[0] = refDepth + refDepStride * y; |
---|
7249 | refDepthTmp[1] = refDepthTmp[0] + subBlockW - 1; |
---|
7250 | refDepthTmp[2] = refDepthTmp[0] + refDepStride * (subBlockH - 1); |
---|
7251 | refDepthTmp[3] = refDepthTmp[2] + subBlockW - 1; |
---|
7252 | |
---|
7253 | Int partAddrRasterSubPU = partAddrRasterSubPULine; |
---|
7254 | for( Int x=0; x<width; x+=subBlockW, partAddrRasterSubPU+=numPartsInSubPUW ) |
---|
7255 | { |
---|
7256 | Pel maxDepthVal; |
---|
7257 | maxDepthVal = refDepthTmp[0][x]; |
---|
7258 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[1][x]); |
---|
7259 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[2][x]); |
---|
7260 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[3][x]); |
---|
7261 | tmpMv.setHor( (Short) shiftLUT[ maxDepthVal ] ); |
---|
7262 | |
---|
7263 | Int partAddrRasterPartLine = partAddrRasterSubPU; |
---|
7264 | for( Int sY=0; sY<numPartsInSubPUH; sY+=numPartsLine, partAddrRasterPartLine += numPartsLine ) |
---|
7265 | { |
---|
7266 | Int partAddrRasterPart = partAddrRasterPartLine; |
---|
7267 | for( Int sX=0; sX<numPartsInSubPUW; sX+=1, partAddrRasterPart++ ) |
---|
7268 | { |
---|
7269 | cuMvField->setMv ( g_auiRasterToZscan[ partAddrRasterPart ], tmpMv ); |
---|
7270 | cuMvField->setRefIdx( g_auiRasterToZscan[ partAddrRasterPart ], refIdx ); |
---|
7271 | } |
---|
7272 | } |
---|
7273 | } |
---|
7274 | } |
---|
7275 | |
---|
7276 | vspSize = (vspSize<<2)+1; |
---|
7277 | |
---|
7278 | } |
---|
7279 | #endif |
---|
7280 | |
---|
7281 | //! \} |
---|