1 | |
---|
2 | |
---|
3 | /** \file TComDataCU.cpp |
---|
4 | \brief CU data structure |
---|
5 | \todo not all entities are documented |
---|
6 | */ |
---|
7 | |
---|
8 | #include "TComDataCU.h" |
---|
9 | #include "TComPic.h" |
---|
10 | #include "TComDepthMapGenerator.h" |
---|
11 | #include "TComResidualGenerator.h" |
---|
12 | |
---|
13 | // ==================================================================================================================== |
---|
14 | // Constructor / destructor / create / destroy |
---|
15 | // ==================================================================================================================== |
---|
16 | |
---|
17 | TComDataCU::TComDataCU() |
---|
18 | { |
---|
19 | m_pcPic = NULL; |
---|
20 | m_pcSlice = NULL; |
---|
21 | m_puhDepth = NULL; |
---|
22 | m_piTextureModeDepth = NULL; |
---|
23 | |
---|
24 | m_pePartSize = NULL; |
---|
25 | m_pePredMode = NULL; |
---|
26 | m_puiAlfCtrlFlag = NULL; |
---|
27 | m_puiTmpAlfCtrlFlag = NULL; |
---|
28 | m_puhWidth = NULL; |
---|
29 | m_puhHeight = NULL; |
---|
30 | m_phQP = NULL; |
---|
31 | m_pbMergeFlag = NULL; |
---|
32 | m_puhMergeIndex = NULL; |
---|
33 | m_pbResPredAvailable = NULL; |
---|
34 | m_pbResPredFlag = NULL; |
---|
35 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
36 | { |
---|
37 | m_apuhNeighbourCandIdx[ui] = NULL; |
---|
38 | } |
---|
39 | m_puhLumaIntraDir = NULL; |
---|
40 | m_puhChromaIntraDir = NULL; |
---|
41 | m_puhInterDir = NULL; |
---|
42 | m_puhTrIdx = NULL; |
---|
43 | m_puhCbf[0] = NULL; |
---|
44 | m_puhCbf[1] = NULL; |
---|
45 | m_puhCbf[2] = NULL; |
---|
46 | m_pcTrCoeffY = NULL; |
---|
47 | m_pcTrCoeffCb = NULL; |
---|
48 | m_pcTrCoeffCr = NULL; |
---|
49 | |
---|
50 | m_pcPattern = NULL; |
---|
51 | |
---|
52 | m_pcCUAboveLeft = NULL; |
---|
53 | m_pcCUAboveRight = NULL; |
---|
54 | m_pcCUAbove = NULL; |
---|
55 | m_pcCULeft = NULL; |
---|
56 | |
---|
57 | m_apcCUColocated[0] = NULL; |
---|
58 | m_apcCUColocated[1] = NULL; |
---|
59 | |
---|
60 | m_apiMVPIdx[0] = NULL; |
---|
61 | m_apiMVPIdx[1] = NULL; |
---|
62 | m_apiMVPNum[0] = NULL; |
---|
63 | m_apiMVPNum[1] = NULL; |
---|
64 | |
---|
65 | m_bDecSubCu = false; |
---|
66 | m_uiSliceStartCU = 0; |
---|
67 | m_uiEntropySliceStartCU = 0; |
---|
68 | |
---|
69 | #if SNY_DQP |
---|
70 | m_bdQP = false; |
---|
71 | #endif//SNY_DQP |
---|
72 | |
---|
73 | #if HHI_DMM_INTRA |
---|
74 | m_puiWedgeFullTabIdx = NULL; |
---|
75 | m_piWedgeFullDeltaDC1 = NULL; |
---|
76 | m_piWedgeFullDeltaDC2 = NULL; |
---|
77 | |
---|
78 | m_puiWedgePredDirTabIdx = NULL; |
---|
79 | m_piWedgePredDirDeltaDC1 = NULL; |
---|
80 | m_piWedgePredDirDeltaDC2 = NULL; |
---|
81 | m_piWedgePredDirDeltaEnd = NULL; |
---|
82 | |
---|
83 | m_puiWedgePredTexTabIdx = NULL; |
---|
84 | m_piWedgePredTexDeltaDC1 = NULL; |
---|
85 | m_piWedgePredTexDeltaDC2 = NULL; |
---|
86 | |
---|
87 | m_piContourPredTexDeltaDC1 = NULL; |
---|
88 | m_piContourPredTexDeltaDC2 = NULL; |
---|
89 | |
---|
90 | m_pbTextureModesAllowed = NULL; |
---|
91 | #endif |
---|
92 | } |
---|
93 | |
---|
94 | TComDataCU::~TComDataCU() |
---|
95 | { |
---|
96 | } |
---|
97 | |
---|
98 | Void TComDataCU::create(UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu) |
---|
99 | { |
---|
100 | m_bDecSubCu = bDecSubCu; |
---|
101 | |
---|
102 | m_pcPic = NULL; |
---|
103 | m_pcSlice = NULL; |
---|
104 | m_uiNumPartition = uiNumPartition; |
---|
105 | |
---|
106 | if ( !bDecSubCu ) |
---|
107 | { |
---|
108 | m_phQP = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
109 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
110 | m_piTextureModeDepth = (Int* )xMalloc(Int, uiNumPartition); |
---|
111 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
112 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
113 | m_pePartSize = (PartSize* )xMalloc(PartSize, uiNumPartition); |
---|
114 | m_pePredMode = (PredMode* )xMalloc(PredMode, uiNumPartition); |
---|
115 | |
---|
116 | m_puiAlfCtrlFlag = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
117 | |
---|
118 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
119 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
120 | m_pbResPredAvailable = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
121 | m_pbResPredFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
122 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
123 | { |
---|
124 | m_apuhNeighbourCandIdx[ ui ] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
125 | } |
---|
126 | |
---|
127 | m_puhLumaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
128 | m_puhChromaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
129 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
130 | |
---|
131 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
132 | |
---|
133 | m_puhCbf[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
134 | m_puhCbf[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
135 | m_puhCbf[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
136 | |
---|
137 | m_apiMVPIdx[0] = (Int* )xMalloc(Int, uiNumPartition); |
---|
138 | m_apiMVPIdx[1] = (Int* )xMalloc(Int, uiNumPartition); |
---|
139 | m_apiMVPNum[0] = (Int* )xMalloc(Int, uiNumPartition); |
---|
140 | m_apiMVPNum[1] = (Int* )xMalloc(Int, uiNumPartition); |
---|
141 | |
---|
142 | m_pcTrCoeffY = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight); |
---|
143 | m_pcTrCoeffCb = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
144 | m_pcTrCoeffCr = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
145 | |
---|
146 | m_acCUMvField[0].create( uiNumPartition ); |
---|
147 | m_acCUMvField[1].create( uiNumPartition ); |
---|
148 | |
---|
149 | #if HHI_DMM_INTRA |
---|
150 | m_puiWedgeFullTabIdx = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
151 | m_piWedgeFullDeltaDC1 = (Int* )xMalloc(Int, uiNumPartition); |
---|
152 | m_piWedgeFullDeltaDC2 = (Int* )xMalloc(Int, uiNumPartition); |
---|
153 | |
---|
154 | m_puiWedgePredDirTabIdx = (UInt*)xMalloc(UInt, uiNumPartition); |
---|
155 | m_piWedgePredDirDeltaDC1 = (Int* )xMalloc(Int, uiNumPartition); |
---|
156 | m_piWedgePredDirDeltaDC2 = (Int* )xMalloc(Int, uiNumPartition); |
---|
157 | m_piWedgePredDirDeltaEnd = (Int* )xMalloc(Int, uiNumPartition); |
---|
158 | |
---|
159 | m_puiWedgePredTexTabIdx = (UInt*)xMalloc(UInt, uiNumPartition); |
---|
160 | m_piWedgePredTexDeltaDC1 = (Int* )xMalloc(Int, uiNumPartition); |
---|
161 | m_piWedgePredTexDeltaDC2 = (Int* )xMalloc(Int, uiNumPartition); |
---|
162 | |
---|
163 | m_piContourPredTexDeltaDC1 = (Int* )xMalloc(Int, uiNumPartition); |
---|
164 | m_piContourPredTexDeltaDC2 = (Int* )xMalloc(Int, uiNumPartition); |
---|
165 | |
---|
166 | m_pbTextureModesAllowed = (Bool*)xMalloc(Bool, uiNumPartition); |
---|
167 | #endif |
---|
168 | } |
---|
169 | else |
---|
170 | { |
---|
171 | m_acCUMvField[0].setNumPartition(uiNumPartition ); |
---|
172 | m_acCUMvField[1].setNumPartition(uiNumPartition ); |
---|
173 | } |
---|
174 | |
---|
175 | // create pattern memory |
---|
176 | m_pcPattern = (TComPattern*)xMalloc(TComPattern, 1); |
---|
177 | |
---|
178 | // create motion vector fields |
---|
179 | |
---|
180 | m_pcCUAboveLeft = NULL; |
---|
181 | m_pcCUAboveRight = NULL; |
---|
182 | m_pcCUAbove = NULL; |
---|
183 | m_pcCULeft = NULL; |
---|
184 | |
---|
185 | m_apcCUColocated[0] = NULL; |
---|
186 | m_apcCUColocated[1] = NULL; |
---|
187 | } |
---|
188 | |
---|
189 | Void TComDataCU::destroy() |
---|
190 | { |
---|
191 | m_pcPic = NULL; |
---|
192 | m_pcSlice = NULL; |
---|
193 | |
---|
194 | if ( m_pcPattern ) |
---|
195 | { |
---|
196 | xFree(m_pcPattern); |
---|
197 | m_pcPattern = NULL; |
---|
198 | } |
---|
199 | |
---|
200 | // encoder-side buffer free |
---|
201 | if ( !m_bDecSubCu ) |
---|
202 | { |
---|
203 | if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } |
---|
204 | if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } |
---|
205 | if ( m_piTextureModeDepth ) { xFree(m_piTextureModeDepth); m_piTextureModeDepth= NULL; } |
---|
206 | if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } |
---|
207 | if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } |
---|
208 | if ( m_pePartSize ) { xFree(m_pePartSize); m_pePartSize = NULL; } |
---|
209 | if ( m_pePredMode ) { xFree(m_pePredMode); m_pePredMode = NULL; } |
---|
210 | if ( m_puhCbf[0] ) { xFree(m_puhCbf[0]); m_puhCbf[0] = NULL; } |
---|
211 | if ( m_puhCbf[1] ) { xFree(m_puhCbf[1]); m_puhCbf[1] = NULL; } |
---|
212 | if ( m_puhCbf[2] ) { xFree(m_puhCbf[2]); m_puhCbf[2] = NULL; } |
---|
213 | if ( m_puiAlfCtrlFlag ) { xFree(m_puiAlfCtrlFlag); m_puiAlfCtrlFlag = NULL; } |
---|
214 | if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } |
---|
215 | if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } |
---|
216 | if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } |
---|
217 | if ( m_pbResPredAvailable ) { xFree(m_pbResPredAvailable); m_pbResPredAvailable= NULL; } |
---|
218 | if ( m_pbResPredFlag ) { xFree(m_pbResPredFlag); m_pbResPredFlag = NULL; } |
---|
219 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
220 | { |
---|
221 | if( m_apuhNeighbourCandIdx[ ui ] ) { xFree(m_apuhNeighbourCandIdx[ ui ]); m_apuhNeighbourCandIdx[ ui ] = NULL; } |
---|
222 | } |
---|
223 | if ( m_puhLumaIntraDir ) { xFree(m_puhLumaIntraDir); m_puhLumaIntraDir = NULL; } |
---|
224 | if ( m_puhChromaIntraDir ) { xFree(m_puhChromaIntraDir); m_puhChromaIntraDir = NULL; } |
---|
225 | if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } |
---|
226 | if ( m_pcTrCoeffY ) { xFree(m_pcTrCoeffY); m_pcTrCoeffY = NULL; } |
---|
227 | if ( m_pcTrCoeffCb ) { xFree(m_pcTrCoeffCb); m_pcTrCoeffCb = NULL; } |
---|
228 | if ( m_pcTrCoeffCr ) { xFree(m_pcTrCoeffCr); m_pcTrCoeffCr = NULL; } |
---|
229 | if ( m_apiMVPIdx[0] ) { xFree(m_apiMVPIdx[0]); m_apiMVPIdx[0] = NULL; } |
---|
230 | if ( m_apiMVPIdx[1] ) { xFree(m_apiMVPIdx[1]); m_apiMVPIdx[1] = NULL; } |
---|
231 | if ( m_apiMVPNum[0] ) { xFree(m_apiMVPNum[0]); m_apiMVPNum[0] = NULL; } |
---|
232 | if ( m_apiMVPNum[1] ) { xFree(m_apiMVPNum[1]); m_apiMVPNum[1] = NULL; } |
---|
233 | |
---|
234 | m_acCUMvField[0].destroy(); |
---|
235 | m_acCUMvField[1].destroy(); |
---|
236 | |
---|
237 | #if HHI_DMM_INTRA |
---|
238 | if ( m_puiWedgeFullTabIdx ) { xFree(m_puiWedgeFullTabIdx); m_puiWedgeFullTabIdx = NULL; } |
---|
239 | if ( m_piWedgeFullDeltaDC1 ) { xFree(m_piWedgeFullDeltaDC1); m_piWedgeFullDeltaDC1 = NULL; } |
---|
240 | if ( m_piWedgeFullDeltaDC2 ) { xFree(m_piWedgeFullDeltaDC2); m_piWedgeFullDeltaDC2 = NULL; } |
---|
241 | |
---|
242 | if ( m_puiWedgePredDirTabIdx ) { xFree(m_puiWedgePredDirTabIdx); m_puiWedgePredDirTabIdx = NULL; } |
---|
243 | if ( m_piWedgePredDirDeltaEnd ) { xFree(m_piWedgePredDirDeltaEnd); m_piWedgePredDirDeltaEnd = NULL; } |
---|
244 | if ( m_piWedgePredDirDeltaDC1 ) { xFree(m_piWedgePredDirDeltaDC1); m_piWedgePredDirDeltaDC1 = NULL; } |
---|
245 | if ( m_piWedgePredDirDeltaDC2 ) { xFree(m_piWedgePredDirDeltaDC2); m_piWedgePredDirDeltaDC2 = NULL; } |
---|
246 | |
---|
247 | if ( m_puiWedgePredTexTabIdx ) { xFree(m_puiWedgePredTexTabIdx); m_puiWedgePredTexTabIdx = NULL; } |
---|
248 | if ( m_piWedgePredTexDeltaDC1 ) { xFree(m_piWedgePredTexDeltaDC1); m_piWedgePredTexDeltaDC1 = NULL; } |
---|
249 | if ( m_piWedgePredTexDeltaDC2 ) { xFree(m_piWedgePredTexDeltaDC2); m_piWedgePredTexDeltaDC2 = NULL; } |
---|
250 | |
---|
251 | if ( m_piContourPredTexDeltaDC1 ) { xFree(m_piContourPredTexDeltaDC1); m_piContourPredTexDeltaDC1 = NULL; } |
---|
252 | if ( m_piContourPredTexDeltaDC2 ) { xFree(m_piContourPredTexDeltaDC2); m_piContourPredTexDeltaDC2 = NULL; } |
---|
253 | |
---|
254 | if ( m_pbTextureModesAllowed ) { xFree(m_pbTextureModesAllowed ); m_pbTextureModesAllowed = NULL; } |
---|
255 | #endif |
---|
256 | } |
---|
257 | |
---|
258 | m_pcCUAboveLeft = NULL; |
---|
259 | m_pcCUAboveRight = NULL; |
---|
260 | m_pcCUAbove = NULL; |
---|
261 | m_pcCULeft = NULL; |
---|
262 | |
---|
263 | m_apcCUColocated[0] = NULL; |
---|
264 | m_apcCUColocated[1] = NULL; |
---|
265 | } |
---|
266 | |
---|
267 | // ==================================================================================================================== |
---|
268 | // Public member functions |
---|
269 | // ==================================================================================================================== |
---|
270 | |
---|
271 | // -------------------------------------------------------------------------------------------------------------------- |
---|
272 | // Initialization |
---|
273 | // -------------------------------------------------------------------------------------------------------------------- |
---|
274 | |
---|
275 | /** |
---|
276 | - initialize top-level CU |
---|
277 | - internal buffers are already created |
---|
278 | - set values before encoding a CU |
---|
279 | . |
---|
280 | \param pcPic picture (TComPic) class pointer |
---|
281 | \param iCUAddr CU address |
---|
282 | */ |
---|
283 | Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr ) |
---|
284 | { |
---|
285 | TComSlice* pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
286 | m_pcSlice = pcSlice; |
---|
287 | m_uiSliceStartCU = pcSlice->getSliceCurStartCUAddr(); |
---|
288 | m_uiEntropySliceStartCU = pcSlice->getEntropySliceCurStartCUAddr(); |
---|
289 | m_pcPic = pcPic; |
---|
290 | m_uiCUAddr = iCUAddr; |
---|
291 | m_uiCUPelX = ( iCUAddr % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth; |
---|
292 | m_uiCUPelY = ( iCUAddr / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight; |
---|
293 | m_uiAbsIdxInLCU = 0; |
---|
294 | |
---|
295 | m_dTotalCost = MAX_DOUBLE; |
---|
296 | m_uiTotalDistortion = 0; |
---|
297 | m_uiTotalBits = 0; |
---|
298 | m_uiNumPartition = pcPic->getNumPartInCU(); |
---|
299 | |
---|
300 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
301 | Int iSizeInUInt = sizeof( UInt ) * m_uiNumPartition; |
---|
302 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
303 | |
---|
304 | Int iSizeInInt = sizeof( Int ) * m_uiNumPartition; |
---|
305 | |
---|
306 | memset( m_phQP, pcSlice->getSliceQp(), iSizeInUchar ); |
---|
307 | memset( m_puiAlfCtrlFlag, 0, iSizeInUInt ); |
---|
308 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
309 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
310 | memset( m_pbResPredAvailable, 0, iSizeInBool ); |
---|
311 | memset( m_pbResPredFlag, 0, iSizeInBool ); |
---|
312 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
313 | { |
---|
314 | memset( m_apuhNeighbourCandIdx[ ui ], 0, iSizeInUchar ); |
---|
315 | } |
---|
316 | memset( m_puhLumaIntraDir, 2, iSizeInUchar ); |
---|
317 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
---|
318 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
319 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
320 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
---|
321 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
---|
322 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
---|
323 | memset( m_puhDepth, 0, iSizeInUchar ); |
---|
324 | memset( m_piTextureModeDepth,-1, iSizeInInt ); |
---|
325 | |
---|
326 | UChar uhWidth = g_uiMaxCUWidth; |
---|
327 | UChar uhHeight = g_uiMaxCUHeight; |
---|
328 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
329 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
330 | |
---|
331 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
332 | { |
---|
333 | m_pePartSize[ui] = SIZE_NONE; |
---|
334 | m_pePredMode[ui] = MODE_NONE; |
---|
335 | |
---|
336 | m_apiMVPIdx[0][ui] = -1; |
---|
337 | m_apiMVPIdx[1][ui] = -1; |
---|
338 | m_apiMVPNum[0][ui] = -1; |
---|
339 | m_apiMVPNum[1][ui] = -1; |
---|
340 | } |
---|
341 | |
---|
342 | m_acCUMvField[0].clearMvField(); |
---|
343 | m_acCUMvField[1].clearMvField(); |
---|
344 | |
---|
345 | UInt uiTmp = m_puhWidth[0]*m_puhHeight[0]; |
---|
346 | memset( m_pcTrCoeffY , 0, sizeof( TCoeff ) * uiTmp ); |
---|
347 | |
---|
348 | uiTmp >>= 2; |
---|
349 | memset( m_pcTrCoeffCb, 0, sizeof( TCoeff ) * uiTmp ); |
---|
350 | memset( m_pcTrCoeffCr, 0, sizeof( TCoeff ) * uiTmp ); |
---|
351 | |
---|
352 | // setting neighbor CU |
---|
353 | m_pcCULeft = NULL; |
---|
354 | m_pcCUAbove = NULL; |
---|
355 | m_pcCUAboveLeft = NULL; |
---|
356 | m_pcCUAboveRight = NULL; |
---|
357 | |
---|
358 | m_apcCUColocated[0] = NULL; |
---|
359 | m_apcCUColocated[1] = NULL; |
---|
360 | |
---|
361 | UInt uiWidthInCU = pcPic->getFrameWidthInCU(); |
---|
362 | if ( m_uiCUAddr % uiWidthInCU ) |
---|
363 | { |
---|
364 | m_pcCULeft = pcPic->getCU( m_uiCUAddr - 1 ); |
---|
365 | } |
---|
366 | |
---|
367 | if ( m_uiCUAddr / uiWidthInCU ) |
---|
368 | { |
---|
369 | m_pcCUAbove = pcPic->getCU( m_uiCUAddr - uiWidthInCU ); |
---|
370 | } |
---|
371 | |
---|
372 | if ( m_pcCULeft && m_pcCUAbove ) |
---|
373 | { |
---|
374 | m_pcCUAboveLeft = pcPic->getCU( m_uiCUAddr - uiWidthInCU - 1 ); |
---|
375 | } |
---|
376 | |
---|
377 | if ( m_pcCUAbove && ( (m_uiCUAddr%uiWidthInCU) < (uiWidthInCU-1) ) ) |
---|
378 | { |
---|
379 | m_pcCUAboveRight = pcPic->getCU( m_uiCUAddr - uiWidthInCU + 1 ); |
---|
380 | } |
---|
381 | |
---|
382 | if ( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) |
---|
383 | { |
---|
384 | m_apcCUColocated[0] = pcSlice->getRefPic( REF_PIC_LIST_0, 0)->getCU( m_uiCUAddr ); |
---|
385 | } |
---|
386 | |
---|
387 | if ( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) |
---|
388 | { |
---|
389 | m_apcCUColocated[1] = pcSlice->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr ); |
---|
390 | } |
---|
391 | |
---|
392 | #if HHI_DMM_INTRA |
---|
393 | memset( m_puiWedgeFullTabIdx, 0, iSizeInUInt ); |
---|
394 | memset( m_piWedgeFullDeltaDC1, 0, iSizeInInt ); |
---|
395 | memset( m_piWedgeFullDeltaDC2, 0, iSizeInInt ); |
---|
396 | |
---|
397 | memset( m_puiWedgePredDirTabIdx, 0, iSizeInUInt ); |
---|
398 | memset( m_piWedgePredDirDeltaDC1, 0, iSizeInInt ); |
---|
399 | memset( m_piWedgePredDirDeltaDC2, 0, iSizeInInt ); |
---|
400 | memset( m_piWedgePredDirDeltaEnd, 0, iSizeInInt ); |
---|
401 | |
---|
402 | memset( m_puiWedgePredTexTabIdx, 0, iSizeInUInt ); |
---|
403 | memset( m_piWedgePredTexDeltaDC1, 0, iSizeInInt ); |
---|
404 | memset( m_piWedgePredTexDeltaDC2, 0, iSizeInInt ); |
---|
405 | |
---|
406 | memset( m_piContourPredTexDeltaDC1, 0, iSizeInInt ); |
---|
407 | memset( m_piContourPredTexDeltaDC2, 0, iSizeInInt ); |
---|
408 | |
---|
409 | memset( m_pbTextureModesAllowed, false, iSizeInBool ); |
---|
410 | #endif |
---|
411 | } |
---|
412 | |
---|
413 | // initialize prediction data |
---|
414 | Void TComDataCU::initEstData() |
---|
415 | { |
---|
416 | m_dTotalCost = MAX_DOUBLE; |
---|
417 | m_uiTotalDistortion = 0; |
---|
418 | m_uiTotalBits = 0; |
---|
419 | |
---|
420 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
421 | Int iSizeInUInt = sizeof( UInt ) * m_uiNumPartition; |
---|
422 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
423 | Int iSizeInInt = sizeof( Int ) * m_uiNumPartition; |
---|
424 | memset( m_phQP, getSlice()->getSliceQp(), iSizeInUchar ); |
---|
425 | memset( m_puiAlfCtrlFlag, 0, iSizeInUInt ); |
---|
426 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
427 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
428 | memset( m_pbResPredAvailable, 0, iSizeInBool ); |
---|
429 | memset( m_pbResPredFlag, 0, iSizeInBool ); |
---|
430 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
431 | { |
---|
432 | memset( m_apuhNeighbourCandIdx[ ui ], 0, iSizeInUchar ); |
---|
433 | } |
---|
434 | memset( m_puhLumaIntraDir, 2, iSizeInUchar ); |
---|
435 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
---|
436 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
437 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
438 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
---|
439 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
---|
440 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
---|
441 | |
---|
442 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
443 | { |
---|
444 | m_pePartSize[ui] = SIZE_NONE; |
---|
445 | m_pePredMode[ui] = MODE_NONE; |
---|
446 | |
---|
447 | m_apiMVPIdx[0][ui] = -1; |
---|
448 | m_apiMVPIdx[1][ui] = -1; |
---|
449 | m_apiMVPNum[0][ui] = -1; |
---|
450 | m_apiMVPNum[1][ui] = -1; |
---|
451 | } |
---|
452 | |
---|
453 | UInt uiTmp = m_puhWidth[0]*m_puhHeight[0]; |
---|
454 | memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); |
---|
455 | |
---|
456 | uiTmp >>= 2; |
---|
457 | memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); |
---|
458 | memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); |
---|
459 | |
---|
460 | m_acCUMvField[0].clearMvField(); |
---|
461 | m_acCUMvField[1].clearMvField(); |
---|
462 | |
---|
463 | #if HHI_DMM_INTRA |
---|
464 | memset( m_puiWedgeFullTabIdx, 0, iSizeInUInt ); |
---|
465 | memset( m_piWedgeFullDeltaDC1, 0, iSizeInInt ); |
---|
466 | memset( m_piWedgeFullDeltaDC2, 0, iSizeInInt ); |
---|
467 | |
---|
468 | memset( m_puiWedgePredDirTabIdx, 0, iSizeInUInt ); |
---|
469 | memset( m_piWedgePredDirDeltaDC1, 0, iSizeInInt ); |
---|
470 | memset( m_piWedgePredDirDeltaDC2, 0, iSizeInInt ); |
---|
471 | memset( m_piWedgePredDirDeltaEnd, 0, iSizeInInt ); |
---|
472 | |
---|
473 | memset( m_puiWedgePredTexTabIdx, 0, iSizeInUInt ); |
---|
474 | memset( m_piWedgePredTexDeltaDC1, 0, iSizeInInt ); |
---|
475 | memset( m_piWedgePredTexDeltaDC2, 0, iSizeInInt ); |
---|
476 | |
---|
477 | memset( m_piContourPredTexDeltaDC1, 0, iSizeInInt ); |
---|
478 | memset( m_piContourPredTexDeltaDC2, 0, iSizeInInt ); |
---|
479 | |
---|
480 | memset( m_pbTextureModesAllowed, false, iSizeInBool ); |
---|
481 | #endif |
---|
482 | |
---|
483 | memset( m_piTextureModeDepth, -1, iSizeInInt ); |
---|
484 | } |
---|
485 | |
---|
486 | // initialize Sub partition |
---|
487 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
488 | { |
---|
489 | assert( uiPartUnitIdx<4 ); |
---|
490 | |
---|
491 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
---|
492 | |
---|
493 | m_pcPic = pcCU->getPic(); |
---|
494 | m_pcSlice = pcCU->getSlice(); |
---|
495 | m_uiCUAddr = pcCU->getAddr(); |
---|
496 | m_uiAbsIdxInLCU = pcCU->getZorderIdxInCU() + uiPartOffset; |
---|
497 | m_uiCUPelX = pcCU->getCUPelX() + ( g_uiMaxCUWidth >> uiDepth )*( uiPartUnitIdx & 1 ); |
---|
498 | m_uiCUPelY = pcCU->getCUPelY() + ( g_uiMaxCUHeight >> uiDepth )*( uiPartUnitIdx >> 1 ); |
---|
499 | |
---|
500 | m_dTotalCost = MAX_DOUBLE; |
---|
501 | m_uiTotalDistortion = 0; |
---|
502 | m_uiTotalBits = 0; |
---|
503 | |
---|
504 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
---|
505 | |
---|
506 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
507 | Int iSizeInUInt = sizeof( UInt ) * m_uiNumPartition; |
---|
508 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
509 | Int iSizeInInt = sizeof( Int ) * m_uiNumPartition; |
---|
510 | |
---|
511 | memset( m_phQP, getSlice()->getSliceQp(), iSizeInUchar ); |
---|
512 | memset( m_puiAlfCtrlFlag, 0, iSizeInUInt ); |
---|
513 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
514 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
515 | memset( m_pbResPredAvailable, 0, iSizeInBool ); |
---|
516 | memset( m_pbResPredFlag, 0, iSizeInBool ); |
---|
517 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
518 | { |
---|
519 | memset( m_apuhNeighbourCandIdx[ ui ], 0, iSizeInUchar ); |
---|
520 | } |
---|
521 | memset( m_puhLumaIntraDir, 2, iSizeInUchar ); |
---|
522 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
---|
523 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
524 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
525 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
---|
526 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
---|
527 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
---|
528 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
---|
529 | memset( m_piTextureModeDepth, -1, iSizeInInt ); |
---|
530 | |
---|
531 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
532 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
533 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
534 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
535 | |
---|
536 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
537 | { |
---|
538 | m_pePartSize[ui] = SIZE_NONE; |
---|
539 | m_pePredMode[ui] = MODE_NONE; |
---|
540 | |
---|
541 | m_apiMVPIdx[0][ui] = -1; |
---|
542 | m_apiMVPIdx[1][ui] = -1; |
---|
543 | m_apiMVPNum[0][ui] = -1; |
---|
544 | m_apiMVPNum[1][ui] = -1; |
---|
545 | } |
---|
546 | |
---|
547 | UInt uiTmp = m_puhWidth[0]*m_puhHeight[0]; |
---|
548 | memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); |
---|
549 | |
---|
550 | uiTmp >>= 2; |
---|
551 | memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); |
---|
552 | memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); |
---|
553 | |
---|
554 | m_pcCULeft = pcCU->getCULeft(); |
---|
555 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
556 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
557 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
558 | |
---|
559 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
560 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
561 | |
---|
562 | m_acCUMvField[0].clearMvField(); |
---|
563 | m_acCUMvField[1].clearMvField(); |
---|
564 | m_uiSliceStartCU = pcCU->getSliceStartCU(); |
---|
565 | m_uiEntropySliceStartCU = pcCU->getEntropySliceStartCU(); |
---|
566 | |
---|
567 | #if HHI_DMM_INTRA |
---|
568 | memset( m_puiWedgeFullTabIdx, 0, iSizeInUInt ); |
---|
569 | memset( m_piWedgeFullDeltaDC1, 0, iSizeInInt ); |
---|
570 | memset( m_piWedgeFullDeltaDC2, 0, iSizeInInt ); |
---|
571 | |
---|
572 | memset( m_puiWedgePredDirTabIdx, 0, iSizeInUInt ); |
---|
573 | memset( m_piWedgePredDirDeltaDC1, 0, iSizeInInt ); |
---|
574 | memset( m_piWedgePredDirDeltaDC2, 0, iSizeInInt ); |
---|
575 | memset( m_piWedgePredDirDeltaEnd, 0, iSizeInInt ); |
---|
576 | |
---|
577 | memset( m_puiWedgePredTexTabIdx, 0, iSizeInUInt ); |
---|
578 | memset( m_piWedgePredTexDeltaDC1, 0, iSizeInInt ); |
---|
579 | memset( m_piWedgePredTexDeltaDC2, 0, iSizeInInt ); |
---|
580 | |
---|
581 | memset( m_piContourPredTexDeltaDC1, 0, iSizeInInt ); |
---|
582 | memset( m_piContourPredTexDeltaDC2, 0, iSizeInInt ); |
---|
583 | |
---|
584 | memset( m_pbTextureModesAllowed, false, iSizeInBool ); |
---|
585 | #endif |
---|
586 | } |
---|
587 | |
---|
588 | // -------------------------------------------------------------------------------------------------------------------- |
---|
589 | // Copy |
---|
590 | // -------------------------------------------------------------------------------------------------------------------- |
---|
591 | |
---|
592 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
593 | { |
---|
594 | UInt uiPart = uiAbsPartIdx; |
---|
595 | |
---|
596 | m_pcPic = pcCU->getPic(); |
---|
597 | m_pcSlice = pcCU->getSlice(); |
---|
598 | m_uiCUAddr = pcCU->getAddr(); |
---|
599 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
600 | |
---|
601 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
602 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
603 | |
---|
604 | UInt uiWidth = g_uiMaxCUWidth >> uiDepth; |
---|
605 | UInt uiHeight = g_uiMaxCUHeight >> uiDepth; |
---|
606 | |
---|
607 | m_phQP=pcCU->getQP() + uiPart; |
---|
608 | m_pePartSize=pcCU->getPartitionSize() + uiPart; |
---|
609 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
---|
610 | |
---|
611 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
---|
612 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
---|
613 | m_pbResPredAvailable = pcCU->getResPredAvail() + uiPart; |
---|
614 | m_pbResPredFlag = pcCU->getResPredFlag () + uiPart; |
---|
615 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
616 | { |
---|
617 | m_apuhNeighbourCandIdx[ ui ] = pcCU->getNeighbourCandIdx( ui ) + uiPart; |
---|
618 | } |
---|
619 | |
---|
620 | m_puhLumaIntraDir = pcCU->getLumaIntraDir() + uiPart; |
---|
621 | m_puhChromaIntraDir = pcCU->getChromaIntraDir() + uiPart; |
---|
622 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
---|
623 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
---|
624 | |
---|
625 | m_puhCbf[0]= pcCU->getCbf(TEXT_LUMA) + uiPart; |
---|
626 | m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U) + uiPart; |
---|
627 | m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; |
---|
628 | |
---|
629 | m_puhDepth=pcCU->getDepth() + uiPart; |
---|
630 | m_puhWidth=pcCU->getWidth() + uiPart; |
---|
631 | m_puhHeight=pcCU->getHeight() + uiPart; |
---|
632 | m_piTextureModeDepth=pcCU->getTextureModeDepth()+ uiPart; |
---|
633 | |
---|
634 | m_apiMVPIdx[0]=pcCU->getMVPIdx(REF_PIC_LIST_0) + uiPart; |
---|
635 | m_apiMVPIdx[1]=pcCU->getMVPIdx(REF_PIC_LIST_1) + uiPart; |
---|
636 | m_apiMVPNum[0]=pcCU->getMVPNum(REF_PIC_LIST_0) + uiPart; |
---|
637 | m_apiMVPNum[1]=pcCU->getMVPNum(REF_PIC_LIST_1) + uiPart; |
---|
638 | |
---|
639 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
640 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
641 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
642 | m_pcCULeft = pcCU->getCULeft(); |
---|
643 | |
---|
644 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
645 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
646 | |
---|
647 | UInt uiTmp = uiWidth*uiHeight; |
---|
648 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
649 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
650 | |
---|
651 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartInCU(); |
---|
652 | |
---|
653 | m_pcTrCoeffY=pcCU->getCoeffY() + uiCoffOffset; |
---|
654 | |
---|
655 | uiTmp >>= 2; |
---|
656 | uiCoffOffset >>=2; |
---|
657 | m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset; |
---|
658 | m_pcTrCoeffCr=pcCU->getCoeffCr() + uiCoffOffset; |
---|
659 | |
---|
660 | m_acCUMvField[0].setMvPtr(pcCU->getCUMvField(REF_PIC_LIST_0)->getMv() + uiPart); |
---|
661 | m_acCUMvField[0].setMvdPtr(pcCU->getCUMvField(REF_PIC_LIST_0)->getMvd() + uiPart); |
---|
662 | m_acCUMvField[0].setRefIdxPtr(pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx() + uiPart); |
---|
663 | m_acCUMvField[1].setMvPtr(pcCU->getCUMvField(REF_PIC_LIST_1)->getMv() + uiPart); |
---|
664 | m_acCUMvField[1].setMvdPtr(pcCU->getCUMvField(REF_PIC_LIST_1)->getMvd() + uiPart); |
---|
665 | m_acCUMvField[1].setRefIdxPtr(pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx() + uiPart); |
---|
666 | m_uiSliceStartCU = pcCU->getSliceStartCU(); |
---|
667 | m_uiEntropySliceStartCU = pcCU->getEntropySliceStartCU(); |
---|
668 | |
---|
669 | #if HHI_DMM_INTRA |
---|
670 | m_puiWedgeFullTabIdx = pcCU->getWedgeFullTabIdx() + uiPart; |
---|
671 | m_piWedgeFullDeltaDC1 = pcCU->getWedgeFullDeltaDC1() + uiPart; |
---|
672 | m_piWedgeFullDeltaDC2 = pcCU->getWedgeFullDeltaDC2() + uiPart; |
---|
673 | |
---|
674 | m_puiWedgePredDirTabIdx = pcCU->getWedgePredDirTabIdx() + uiPart; |
---|
675 | m_piWedgePredDirDeltaDC1 = pcCU->getWedgePredDirDeltaDC1() + uiPart; |
---|
676 | m_piWedgePredDirDeltaDC2 = pcCU->getWedgePredDirDeltaDC2() + uiPart; |
---|
677 | m_piWedgePredDirDeltaEnd = pcCU->getWedgePredDirDeltaEnd() + uiPart; |
---|
678 | |
---|
679 | m_puiWedgePredTexTabIdx = pcCU->getWedgePredTexTabIdx() + uiPart; |
---|
680 | m_piWedgePredTexDeltaDC1 = pcCU->getWedgePredTexDeltaDC1() + uiPart; |
---|
681 | m_piWedgePredTexDeltaDC2 = pcCU->getWedgePredTexDeltaDC2() + uiPart; |
---|
682 | |
---|
683 | m_piContourPredTexDeltaDC1 = pcCU->getContourPredTexDeltaDC1() + uiPart; |
---|
684 | m_piContourPredTexDeltaDC2 = pcCU->getContourPredTexDeltaDC2() + uiPart; |
---|
685 | |
---|
686 | m_pbTextureModesAllowed = pcCU->getTextureModeAllowance() + uiPart; |
---|
687 | #endif |
---|
688 | } |
---|
689 | |
---|
690 | // Copy inter prediction info from the biggest CU |
---|
691 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList ) |
---|
692 | { |
---|
693 | m_pcPic = pcCU->getPic(); |
---|
694 | m_pcSlice = pcCU->getSlice(); |
---|
695 | m_uiCUAddr = pcCU->getAddr(); |
---|
696 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
697 | |
---|
698 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
699 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() ); |
---|
700 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInWidth() ); |
---|
701 | |
---|
702 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
703 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
704 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
705 | m_pcCULeft = pcCU->getCULeft(); |
---|
706 | |
---|
707 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
708 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
709 | |
---|
710 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
---|
711 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
---|
712 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
---|
713 | |
---|
714 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
715 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
716 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
717 | |
---|
718 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
719 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
720 | m_pbResPredAvailable = pcCU->getResPredAvail() + uiAbsPartIdx; |
---|
721 | m_pbResPredFlag = pcCU->getResPredFlag () + uiAbsPartIdx; |
---|
722 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui ++ ) |
---|
723 | { |
---|
724 | m_apuhNeighbourCandIdx[ui] = pcCU->getNeighbourCandIdx( ui ) + uiAbsPartIdx; |
---|
725 | } |
---|
726 | |
---|
727 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
---|
728 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
---|
729 | |
---|
730 | m_acCUMvField[eRefPicList].setMvPtr(pcCU->getCUMvField(eRefPicList)->getMv() + uiAbsPartIdx); |
---|
731 | m_acCUMvField[eRefPicList].setMvdPtr(pcCU->getCUMvField(eRefPicList)->getMvd() + uiAbsPartIdx); |
---|
732 | m_acCUMvField[eRefPicList].setRefIdxPtr(pcCU->getCUMvField(eRefPicList)->getRefIdx() + uiAbsPartIdx); |
---|
733 | m_piTextureModeDepth = pcCU->getTextureModeDepth() + uiAbsPartIdx; |
---|
734 | |
---|
735 | m_uiSliceStartCU = pcCU->getSliceStartCU(); |
---|
736 | m_uiEntropySliceStartCU = pcCU->getEntropySliceStartCU(); |
---|
737 | } |
---|
738 | |
---|
739 | // Copy small CU to bigger CU. |
---|
740 | // One of quarter parts overwritten by predicted sub part. |
---|
741 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
742 | { |
---|
743 | assert( uiPartUnitIdx<4 ); |
---|
744 | |
---|
745 | m_dTotalCost += pcCU->getTotalCost(); |
---|
746 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
---|
747 | m_uiTotalBits += pcCU->getTotalBits(); |
---|
748 | |
---|
749 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
---|
750 | |
---|
751 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
---|
752 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
753 | Int iSizeInUInt = sizeof( UInt ) * uiNumPartition; |
---|
754 | Int iSizeInInt = sizeof( Int ) * uiNumPartition; |
---|
755 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
756 | |
---|
757 | memcpy( m_phQP + uiOffset, pcCU->getQP(), iSizeInUchar ); |
---|
758 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( PartSize ) * uiNumPartition ); |
---|
759 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( PredMode ) * uiNumPartition ); |
---|
760 | |
---|
761 | memcpy( m_puiAlfCtrlFlag + uiOffset, pcCU->getAlfCtrlFlag(), iSizeInUInt ); |
---|
762 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
---|
763 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
---|
764 | memcpy( m_pbResPredAvailable + uiOffset, pcCU->getResPredAvail(), iSizeInBool ); |
---|
765 | memcpy( m_pbResPredFlag + uiOffset, pcCU->getResPredFlag(), iSizeInBool ); |
---|
766 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
767 | { |
---|
768 | memcpy( m_apuhNeighbourCandIdx[ ui ] + uiOffset, pcCU->getNeighbourCandIdx( ui ), iSizeInUchar ); |
---|
769 | } |
---|
770 | memcpy( m_puhLumaIntraDir + uiOffset, pcCU->getLumaIntraDir(), iSizeInUchar ); |
---|
771 | memcpy( m_puhChromaIntraDir + uiOffset, pcCU->getChromaIntraDir(), iSizeInUchar ); |
---|
772 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
---|
773 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
---|
774 | |
---|
775 | memcpy( m_puhCbf[0] + uiOffset, pcCU->getCbf(TEXT_LUMA) , iSizeInUchar ); |
---|
776 | memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar ); |
---|
777 | memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); |
---|
778 | |
---|
779 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
---|
780 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
---|
781 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
---|
782 | |
---|
783 | memcpy( m_apiMVPIdx[0] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_0), iSizeInInt ); |
---|
784 | memcpy( m_apiMVPIdx[1] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_1), iSizeInInt ); |
---|
785 | memcpy( m_apiMVPNum[0] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_0), iSizeInInt ); |
---|
786 | memcpy( m_apiMVPNum[1] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_1), iSizeInInt ); |
---|
787 | |
---|
788 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
789 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
790 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
791 | m_pcCULeft = pcCU->getCULeft(); |
---|
792 | |
---|
793 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
794 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
795 | |
---|
796 | m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
797 | m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
798 | |
---|
799 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); |
---|
800 | UInt uiTmp2 = uiPartUnitIdx*uiTmp; |
---|
801 | memcpy( m_pcTrCoeffY + uiTmp2, pcCU->getCoeffY(), sizeof(TCoeff)*uiTmp ); |
---|
802 | |
---|
803 | uiTmp >>= 2; uiTmp2>>= 2; |
---|
804 | memcpy( m_pcTrCoeffCb + uiTmp2, pcCU->getCoeffCb(), sizeof(TCoeff)*uiTmp ); |
---|
805 | memcpy( m_pcTrCoeffCr + uiTmp2, pcCU->getCoeffCr(), sizeof(TCoeff)*uiTmp ); |
---|
806 | m_uiSliceStartCU = pcCU->getSliceStartCU(); |
---|
807 | m_uiEntropySliceStartCU = pcCU->getEntropySliceStartCU(); |
---|
808 | |
---|
809 | #if HHI_DMM_INTRA |
---|
810 | memcpy( m_puiWedgeFullTabIdx + uiOffset, pcCU->getWedgeFullTabIdx(), iSizeInUInt ); |
---|
811 | memcpy( m_piWedgeFullDeltaDC1 + uiOffset, pcCU->getWedgeFullDeltaDC1(), iSizeInInt ); |
---|
812 | memcpy( m_piWedgeFullDeltaDC2 + uiOffset, pcCU->getWedgeFullDeltaDC2(), iSizeInInt ); |
---|
813 | |
---|
814 | memcpy( m_puiWedgePredDirTabIdx + uiOffset, pcCU->getWedgePredDirTabIdx(), iSizeInUInt ); |
---|
815 | memcpy( m_piWedgePredDirDeltaDC1 + uiOffset, pcCU->getWedgePredDirDeltaDC1(), iSizeInInt ); |
---|
816 | memcpy( m_piWedgePredDirDeltaDC2 + uiOffset, pcCU->getWedgePredDirDeltaDC2(), iSizeInInt ); |
---|
817 | memcpy( m_piWedgePredDirDeltaEnd + uiOffset, pcCU->getWedgePredDirDeltaEnd(), iSizeInInt ); |
---|
818 | |
---|
819 | memcpy( m_puiWedgePredTexTabIdx + uiOffset, pcCU->getWedgePredTexTabIdx(), iSizeInUInt ); |
---|
820 | memcpy( m_piWedgePredTexDeltaDC1 + uiOffset, pcCU->getWedgePredTexDeltaDC1(), iSizeInInt ); |
---|
821 | memcpy( m_piWedgePredTexDeltaDC2 + uiOffset, pcCU->getWedgePredTexDeltaDC2(), iSizeInInt ); |
---|
822 | |
---|
823 | memcpy( m_piContourPredTexDeltaDC1 + uiOffset, pcCU->getContourPredTexDeltaDC1(), iSizeInInt ); |
---|
824 | memcpy( m_piContourPredTexDeltaDC2 + uiOffset, pcCU->getContourPredTexDeltaDC2(), iSizeInInt ); |
---|
825 | |
---|
826 | memcpy( m_pbTextureModesAllowed + uiOffset, pcCU->getTextureModeAllowance(), iSizeInBool ); |
---|
827 | #endif |
---|
828 | |
---|
829 | memcpy( m_piTextureModeDepth + uiOffset, pcCU->getTextureModeDepth(), iSizeInInt ); |
---|
830 | } |
---|
831 | |
---|
832 | // Copy current predicted part to a CU in picture. |
---|
833 | // It is used to predict for next part |
---|
834 | Void TComDataCU::copyToPic( UChar uhDepth ) |
---|
835 | { |
---|
836 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
837 | |
---|
838 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
839 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
840 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
841 | |
---|
842 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
843 | Int iSizeInUInt = sizeof( UInt ) * m_uiNumPartition; |
---|
844 | Int iSizeInInt = sizeof( Int ) * m_uiNumPartition; |
---|
845 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
846 | |
---|
847 | memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, iSizeInUchar ); |
---|
848 | |
---|
849 | memcpy( rpcCU->getPartitionSize() + m_uiAbsIdxInLCU, m_pePartSize, sizeof( PartSize ) * m_uiNumPartition ); |
---|
850 | memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( PredMode ) * m_uiNumPartition ); |
---|
851 | |
---|
852 | memcpy( rpcCU->getAlfCtrlFlag() + m_uiAbsIdxInLCU, m_puiAlfCtrlFlag, iSizeInUInt ); |
---|
853 | |
---|
854 | memcpy( rpcCU->getMergeFlag() + m_uiAbsIdxInLCU, m_pbMergeFlag, iSizeInBool ); |
---|
855 | memcpy( rpcCU->getMergeIndex() + m_uiAbsIdxInLCU, m_puhMergeIndex, iSizeInUchar ); |
---|
856 | memcpy( rpcCU->getResPredAvail() + m_uiAbsIdxInLCU, m_pbResPredAvailable, iSizeInBool ); |
---|
857 | memcpy( rpcCU->getResPredFlag() + m_uiAbsIdxInLCU, m_pbResPredFlag, iSizeInBool ); |
---|
858 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
859 | { |
---|
860 | memcpy( rpcCU->getNeighbourCandIdx( ui ) + m_uiAbsIdxInLCU, m_apuhNeighbourCandIdx[ui], iSizeInUchar ); |
---|
861 | } |
---|
862 | memcpy( rpcCU->getLumaIntraDir() + m_uiAbsIdxInLCU, m_puhLumaIntraDir, iSizeInUchar ); |
---|
863 | memcpy( rpcCU->getChromaIntraDir() + m_uiAbsIdxInLCU, m_puhChromaIntraDir, iSizeInUchar ); |
---|
864 | memcpy( rpcCU->getInterDir() + m_uiAbsIdxInLCU, m_puhInterDir, iSizeInUchar ); |
---|
865 | memcpy( rpcCU->getTransformIdx() + m_uiAbsIdxInLCU, m_puhTrIdx, iSizeInUchar ); |
---|
866 | |
---|
867 | memcpy( rpcCU->getCbf(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhCbf[0], iSizeInUchar ); |
---|
868 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhCbf[1], iSizeInUchar ); |
---|
869 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); |
---|
870 | |
---|
871 | memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); |
---|
872 | memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); |
---|
873 | memcpy( rpcCU->getHeight() + m_uiAbsIdxInLCU, m_puhHeight, iSizeInUchar ); |
---|
874 | |
---|
875 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPIdx[0], iSizeInInt ); |
---|
876 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPIdx[1], iSizeInInt ); |
---|
877 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPNum[0], iSizeInInt ); |
---|
878 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPNum[1], iSizeInInt ); |
---|
879 | |
---|
880 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU ); |
---|
881 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU ); |
---|
882 | |
---|
883 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); |
---|
884 | UInt uiTmp2 = m_uiAbsIdxInLCU*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
885 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
886 | |
---|
887 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
888 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
889 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
890 | rpcCU->setSliceStartCU( m_uiSliceStartCU ); |
---|
891 | rpcCU->setEntropySliceStartCU( m_uiEntropySliceStartCU ); |
---|
892 | |
---|
893 | #if HHI_DMM_INTRA |
---|
894 | memcpy( rpcCU->getWedgeFullTabIdx() + m_uiAbsIdxInLCU, m_puiWedgeFullTabIdx, iSizeInUInt ); |
---|
895 | memcpy( rpcCU->getWedgeFullDeltaDC1() + m_uiAbsIdxInLCU, m_piWedgeFullDeltaDC1, iSizeInInt ); |
---|
896 | memcpy( rpcCU->getWedgeFullDeltaDC2() + m_uiAbsIdxInLCU, m_piWedgeFullDeltaDC2, iSizeInInt ); |
---|
897 | |
---|
898 | memcpy( rpcCU->getWedgePredDirTabIdx() + m_uiAbsIdxInLCU, m_puiWedgePredDirTabIdx, iSizeInUInt ); |
---|
899 | memcpy( rpcCU->getWedgePredDirDeltaDC1() + m_uiAbsIdxInLCU, m_piWedgePredDirDeltaDC1, iSizeInInt ); |
---|
900 | memcpy( rpcCU->getWedgePredDirDeltaDC2() + m_uiAbsIdxInLCU, m_piWedgePredDirDeltaDC2, iSizeInInt ); |
---|
901 | memcpy( rpcCU->getWedgePredDirDeltaEnd() + m_uiAbsIdxInLCU, m_piWedgePredDirDeltaEnd, iSizeInInt ); |
---|
902 | |
---|
903 | memcpy( rpcCU->getWedgePredTexTabIdx() + m_uiAbsIdxInLCU, m_puiWedgePredTexTabIdx, iSizeInUInt ); |
---|
904 | memcpy( rpcCU->getWedgePredTexDeltaDC1() + m_uiAbsIdxInLCU, m_piWedgePredTexDeltaDC1, iSizeInInt ); |
---|
905 | memcpy( rpcCU->getWedgePredTexDeltaDC2() + m_uiAbsIdxInLCU, m_piWedgePredTexDeltaDC2, iSizeInInt ); |
---|
906 | |
---|
907 | memcpy( rpcCU->getContourPredTexDeltaDC1() + m_uiAbsIdxInLCU, m_piContourPredTexDeltaDC1, iSizeInInt ); |
---|
908 | memcpy( rpcCU->getContourPredTexDeltaDC2() + m_uiAbsIdxInLCU, m_piContourPredTexDeltaDC2, iSizeInInt ); |
---|
909 | |
---|
910 | memcpy( rpcCU->getTextureModeAllowance() + m_uiAbsIdxInLCU, m_pbTextureModesAllowed, iSizeInBool ); |
---|
911 | #endif |
---|
912 | |
---|
913 | memcpy( rpcCU->getTextureModeDepth() + m_uiAbsIdxInLCU, m_piTextureModeDepth, iSizeInInt ); |
---|
914 | } |
---|
915 | |
---|
916 | Void TComDataCU::copyToPic( UChar uhDepth, UInt uiPartIdx, UInt uiPartDepth ) |
---|
917 | { |
---|
918 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
919 | UInt uiQNumPart = m_uiNumPartition>>(uiPartDepth<<1); |
---|
920 | |
---|
921 | UInt uiPartStart = uiPartIdx*uiQNumPart; |
---|
922 | UInt uiPartOffset = m_uiAbsIdxInLCU + uiPartStart; |
---|
923 | |
---|
924 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
925 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
926 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
927 | |
---|
928 | Int iSizeInUchar = sizeof( UChar ) * uiQNumPart; |
---|
929 | Int iSizeInUInt = sizeof( UInt ) * uiQNumPart; |
---|
930 | Int iSizeInInt = sizeof( Int ) * uiQNumPart; |
---|
931 | Int iSizeInBool = sizeof( Bool ) * uiQNumPart; |
---|
932 | |
---|
933 | memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, iSizeInUchar ); |
---|
934 | |
---|
935 | memcpy( rpcCU->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( PartSize ) * uiQNumPart ); |
---|
936 | memcpy( rpcCU->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( PredMode ) * uiQNumPart ); |
---|
937 | |
---|
938 | memcpy( rpcCU->getAlfCtrlFlag() + uiPartOffset, m_puiAlfCtrlFlag, iSizeInUInt ); |
---|
939 | memcpy( rpcCU->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); |
---|
940 | memcpy( rpcCU->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); |
---|
941 | memcpy( rpcCU->getResPredAvail() + uiPartOffset, m_pbResPredAvailable, iSizeInBool ); |
---|
942 | memcpy( rpcCU->getResPredFlag() + uiPartOffset, m_pbResPredFlag, iSizeInBool ); |
---|
943 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
944 | { |
---|
945 | memcpy( rpcCU->getNeighbourCandIdx( ui ) + uiPartOffset, m_apuhNeighbourCandIdx[ui], iSizeInUchar ); |
---|
946 | } |
---|
947 | memcpy( rpcCU->getLumaIntraDir() + uiPartOffset, m_puhLumaIntraDir, iSizeInUchar ); |
---|
948 | memcpy( rpcCU->getChromaIntraDir() + uiPartOffset, m_puhChromaIntraDir, iSizeInUchar ); |
---|
949 | memcpy( rpcCU->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); |
---|
950 | memcpy( rpcCU->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); |
---|
951 | |
---|
952 | memcpy( rpcCU->getCbf(TEXT_LUMA) + uiPartOffset, m_puhCbf[0], iSizeInUchar ); |
---|
953 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar ); |
---|
954 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); |
---|
955 | |
---|
956 | memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); |
---|
957 | memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); |
---|
958 | memcpy( rpcCU->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); |
---|
959 | |
---|
960 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPIdx[0], iSizeInInt ); |
---|
961 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPIdx[1], iSizeInInt ); |
---|
962 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPNum[0], iSizeInInt ); |
---|
963 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPNum[1], iSizeInInt ); |
---|
964 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
965 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
966 | |
---|
967 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); |
---|
968 | UInt uiTmp2 = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
969 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
970 | |
---|
971 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
972 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
973 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
974 | rpcCU->setSliceStartCU( m_uiSliceStartCU ); |
---|
975 | rpcCU->setEntropySliceStartCU( m_uiEntropySliceStartCU ); |
---|
976 | |
---|
977 | #if HHI_DMM_INTRA |
---|
978 | memcpy( rpcCU->getWedgeFullTabIdx() + uiPartOffset, m_puiWedgeFullTabIdx, iSizeInUInt ); |
---|
979 | memcpy( rpcCU->getWedgeFullDeltaDC1() + uiPartOffset, m_piWedgeFullDeltaDC1, iSizeInInt ); |
---|
980 | memcpy( rpcCU->getWedgeFullDeltaDC2() + uiPartOffset, m_piWedgeFullDeltaDC2, iSizeInInt ); |
---|
981 | |
---|
982 | memcpy( rpcCU->getWedgePredDirTabIdx() + uiPartOffset, m_puiWedgePredDirTabIdx, iSizeInUInt ); |
---|
983 | memcpy( rpcCU->getWedgePredDirDeltaDC1() + uiPartOffset, m_piWedgePredDirDeltaDC1, iSizeInInt ); |
---|
984 | memcpy( rpcCU->getWedgePredDirDeltaDC2() + uiPartOffset, m_piWedgePredDirDeltaDC2, iSizeInInt ); |
---|
985 | memcpy( rpcCU->getWedgePredDirDeltaEnd() + uiPartOffset, m_piWedgePredDirDeltaEnd, iSizeInInt ); |
---|
986 | |
---|
987 | memcpy( rpcCU->getWedgePredTexTabIdx() + uiPartOffset, m_puiWedgePredTexTabIdx, iSizeInUInt ); |
---|
988 | memcpy( rpcCU->getWedgePredTexDeltaDC1() + uiPartOffset, m_piWedgePredTexDeltaDC1, iSizeInInt ); |
---|
989 | memcpy( rpcCU->getWedgePredTexDeltaDC2() + uiPartOffset, m_piWedgePredTexDeltaDC2, iSizeInInt ); |
---|
990 | |
---|
991 | memcpy( rpcCU->getContourPredTexDeltaDC1() + uiPartOffset, m_piContourPredTexDeltaDC1, iSizeInInt ); |
---|
992 | memcpy( rpcCU->getContourPredTexDeltaDC2() + uiPartOffset, m_piContourPredTexDeltaDC2, iSizeInInt ); |
---|
993 | |
---|
994 | memcpy( rpcCU->getTextureModeAllowance() + uiPartOffset, m_pbTextureModesAllowed, iSizeInBool ); |
---|
995 | #endif |
---|
996 | |
---|
997 | memcpy( rpcCU->getTextureModeDepth() + uiPartOffset, m_piTextureModeDepth, iSizeInInt ); |
---|
998 | } |
---|
999 | |
---|
1000 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1001 | // Other public functions |
---|
1002 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1003 | |
---|
1004 | TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1005 | { |
---|
1006 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1007 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1008 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1009 | |
---|
1010 | if( uiAbsPartIdx % uiNumPartInCUWidth ) |
---|
1011 | { |
---|
1012 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1013 | if ( uiAbsPartIdx % uiNumPartInCUWidth == uiAbsZorderCUIdx % uiNumPartInCUWidth ) |
---|
1014 | { |
---|
1015 | return m_pcPic->getCU( getAddr() ); |
---|
1016 | } |
---|
1017 | else |
---|
1018 | { |
---|
1019 | uiLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1020 | return this; |
---|
1021 | } |
---|
1022 | } |
---|
1023 | |
---|
1024 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth - 1 ]; |
---|
1025 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiSliceStartCU)) || |
---|
1026 | (bEnforceEntropySliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1027 | { |
---|
1028 | return NULL; |
---|
1029 | } |
---|
1030 | return m_pcCULeft; |
---|
1031 | } |
---|
1032 | |
---|
1033 | TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1034 | { |
---|
1035 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1036 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1037 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1038 | |
---|
1039 | if( uiAbsPartIdx / uiNumPartInCUWidth ) |
---|
1040 | { |
---|
1041 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth ]; |
---|
1042 | if ( uiAbsPartIdx / uiNumPartInCUWidth == uiAbsZorderCUIdx / uiNumPartInCUWidth ) |
---|
1043 | { |
---|
1044 | return m_pcPic->getCU( getAddr() ); |
---|
1045 | } |
---|
1046 | else |
---|
1047 | { |
---|
1048 | uiAPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1049 | return this; |
---|
1050 | } |
---|
1051 | } |
---|
1052 | |
---|
1053 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1054 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiSliceStartCU)) || |
---|
1055 | (bEnforceEntropySliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1056 | { |
---|
1057 | return NULL; |
---|
1058 | } |
---|
1059 | return m_pcCUAbove; |
---|
1060 | } |
---|
1061 | |
---|
1062 | TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1063 | { |
---|
1064 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1065 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1066 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1067 | |
---|
1068 | if( uiAbsPartIdx % uiNumPartInCUWidth ) |
---|
1069 | { |
---|
1070 | if( uiAbsPartIdx / uiNumPartInCUWidth ) |
---|
1071 | { |
---|
1072 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth - 1 ]; |
---|
1073 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth == uiAbsZorderCUIdx % uiNumPartInCUWidth ) || ( uiAbsPartIdx / uiNumPartInCUWidth == uiAbsZorderCUIdx / uiNumPartInCUWidth ) ) |
---|
1074 | { |
---|
1075 | return m_pcPic->getCU( getAddr() ); |
---|
1076 | } |
---|
1077 | else |
---|
1078 | { |
---|
1079 | uiALPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1080 | return this; |
---|
1081 | } |
---|
1082 | } |
---|
1083 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartInCU() - uiNumPartInCUWidth - 1 ]; |
---|
1084 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiSliceStartCU)) || |
---|
1085 | (bEnforceEntropySliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1086 | { |
---|
1087 | return NULL; |
---|
1088 | } |
---|
1089 | return m_pcCUAbove; |
---|
1090 | } |
---|
1091 | |
---|
1092 | if( uiAbsPartIdx / uiNumPartInCUWidth ) |
---|
1093 | { |
---|
1094 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1095 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiSliceStartCU)) || |
---|
1096 | (bEnforceEntropySliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1097 | { |
---|
1098 | return NULL; |
---|
1099 | } |
---|
1100 | return m_pcCULeft; |
---|
1101 | } |
---|
1102 | |
---|
1103 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - 1 ]; |
---|
1104 | if ( (bEnforceSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || m_pcCUAboveLeft->getAddr() < m_uiSliceStartCU)) || |
---|
1105 | (bEnforceEntropySliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL|| m_pcCUAboveLeft->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1106 | { |
---|
1107 | return NULL; |
---|
1108 | } |
---|
1109 | return m_pcCUAboveLeft; |
---|
1110 | } |
---|
1111 | |
---|
1112 | TComDataCU* TComDataCU::getPUAboveRight( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1113 | { |
---|
1114 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1115 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1; |
---|
1116 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1117 | |
---|
1118 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getWidth() ) |
---|
1119 | { |
---|
1120 | uiARPartUnitIdx = MAX_UINT; |
---|
1121 | return NULL; |
---|
1122 | } |
---|
1123 | |
---|
1124 | if ( uiAbsPartIdxRT % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) |
---|
1125 | { |
---|
1126 | if ( uiAbsPartIdxRT / uiNumPartInCUWidth ) |
---|
1127 | { |
---|
1128 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] ) |
---|
1129 | { |
---|
1130 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ]; |
---|
1131 | if ( ( uiAbsPartIdxRT % uiNumPartInCUWidth == uiAbsZorderCUIdx % uiNumPartInCUWidth ) || ( uiAbsPartIdxRT / uiNumPartInCUWidth == uiAbsZorderCUIdx / uiNumPartInCUWidth ) ) |
---|
1132 | { |
---|
1133 | return m_pcPic->getCU( getAddr() ); |
---|
1134 | } |
---|
1135 | else |
---|
1136 | { |
---|
1137 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1138 | return this; |
---|
1139 | } |
---|
1140 | } |
---|
1141 | uiARPartUnitIdx = MAX_UINT; |
---|
1142 | return NULL; |
---|
1143 | } |
---|
1144 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; |
---|
1145 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiSliceStartCU)) || |
---|
1146 | (bEnforceEntropySliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1147 | { |
---|
1148 | return NULL; |
---|
1149 | } |
---|
1150 | return m_pcCUAbove; |
---|
1151 | } |
---|
1152 | |
---|
1153 | if ( uiAbsPartIdxRT / uiNumPartInCUWidth ) |
---|
1154 | { |
---|
1155 | uiARPartUnitIdx = MAX_UINT; |
---|
1156 | return NULL; |
---|
1157 | } |
---|
1158 | |
---|
1159 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1160 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || m_pcCUAboveRight->getAddr() < m_uiSliceStartCU)) || |
---|
1161 | (bEnforceEntropySliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || m_pcCUAboveRight->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1162 | { |
---|
1163 | return NULL; |
---|
1164 | } |
---|
1165 | return m_pcCUAboveRight; |
---|
1166 | } |
---|
1167 | |
---|
1168 | TComDataCU* TComDataCU::getPUBelowLeft( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1169 | { |
---|
1170 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1171 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*m_pcPic->getNumPartInWidth(); |
---|
1172 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1173 | |
---|
1174 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getHeight() ) |
---|
1175 | { |
---|
1176 | uiBLPartUnitIdx = MAX_UINT; |
---|
1177 | return NULL; |
---|
1178 | } |
---|
1179 | |
---|
1180 | if ( uiAbsPartIdxLB / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) |
---|
1181 | { |
---|
1182 | if ( uiAbsPartIdxLB % uiNumPartInCUWidth ) |
---|
1183 | { |
---|
1184 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) |
---|
1185 | { |
---|
1186 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; |
---|
1187 | if ( ( (uiAbsPartIdxLB % uiNumPartInCUWidth) == (uiAbsZorderCUIdxLB % uiNumPartInCUWidth) ) || ( (uiAbsPartIdxLB / uiNumPartInCUWidth) == (uiAbsZorderCUIdxLB / uiNumPartInCUWidth) ) ) |
---|
1188 | { |
---|
1189 | return m_pcPic->getCU( getAddr() ); |
---|
1190 | } |
---|
1191 | else |
---|
1192 | { |
---|
1193 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1194 | return this; |
---|
1195 | } |
---|
1196 | } |
---|
1197 | uiBLPartUnitIdx = MAX_UINT; |
---|
1198 | return NULL; |
---|
1199 | } |
---|
1200 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; |
---|
1201 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiSliceStartCU)) || |
---|
1202 | (bEnforceEntropySliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1203 | { |
---|
1204 | return NULL; |
---|
1205 | } |
---|
1206 | return m_pcCULeft; |
---|
1207 | } |
---|
1208 | |
---|
1209 | uiBLPartUnitIdx = MAX_UINT; |
---|
1210 | return NULL; |
---|
1211 | } |
---|
1212 | |
---|
1213 | #if CONSTRAINED_INTRA_PRED |
---|
1214 | TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiPuHeight, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1215 | #else //CONSTRAINED_INTRA_PRED |
---|
1216 | TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiPuHeight, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1217 | #endif //CONSTRAINED_INTRA_PRED |
---|
1218 | { |
---|
1219 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1220 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth(); |
---|
1221 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1222 | |
---|
1223 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + uiPuHeight ) >= m_pcSlice->getSPS()->getHeight() ) |
---|
1224 | { |
---|
1225 | uiBLPartUnitIdx = MAX_UINT; |
---|
1226 | return NULL; |
---|
1227 | } |
---|
1228 | |
---|
1229 | #if CONSTRAINED_INTRA_PRED |
---|
1230 | if ( uiAbsPartIdxLB / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - uiPartUnitOffset ) |
---|
1231 | #else |
---|
1232 | if ( uiAbsPartIdxLB / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) |
---|
1233 | #endif |
---|
1234 | { |
---|
1235 | if ( uiAbsPartIdxLB % uiNumPartInCUWidth ) |
---|
1236 | { |
---|
1237 | #if CONSTRAINED_INTRA_PRED |
---|
1238 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ] ) |
---|
1239 | #else |
---|
1240 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) |
---|
1241 | #endif |
---|
1242 | { |
---|
1243 | #if CONSTRAINED_INTRA_PRED |
---|
1244 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ]; |
---|
1245 | #else |
---|
1246 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; |
---|
1247 | #endif |
---|
1248 | if ( ( (uiAbsPartIdxLB % uiNumPartInCUWidth) == (uiAbsZorderCUIdxLB % uiNumPartInCUWidth) ) || ( (uiAbsPartIdxLB / uiNumPartInCUWidth) == (uiAbsZorderCUIdxLB / uiNumPartInCUWidth) ) ) |
---|
1249 | { |
---|
1250 | return m_pcPic->getCU( getAddr() ); |
---|
1251 | } |
---|
1252 | else |
---|
1253 | { |
---|
1254 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1255 | return this; |
---|
1256 | } |
---|
1257 | } |
---|
1258 | uiBLPartUnitIdx = MAX_UINT; |
---|
1259 | return NULL; |
---|
1260 | } |
---|
1261 | #if CONSTRAINED_INTRA_PRED |
---|
1262 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * uiNumPartInCUWidth - 1 ]; |
---|
1263 | #else |
---|
1264 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; |
---|
1265 | #endif |
---|
1266 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiSliceStartCU)) || |
---|
1267 | (bEnforceEntropySliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1268 | { |
---|
1269 | return NULL; |
---|
1270 | } |
---|
1271 | return m_pcCULeft; |
---|
1272 | } |
---|
1273 | |
---|
1274 | uiBLPartUnitIdx = MAX_UINT; |
---|
1275 | return NULL; |
---|
1276 | } |
---|
1277 | |
---|
1278 | #if CONSTRAINED_INTRA_PRED |
---|
1279 | TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiPuWidth, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1280 | #else //CONSTRAINED_INTRA_PRED |
---|
1281 | TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiPuWidth, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1282 | #endif //CONSTRAINED_INTRA_PRED |
---|
1283 | { |
---|
1284 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1285 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
---|
1286 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1287 | |
---|
1288 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + uiPuWidth ) >= m_pcSlice->getSPS()->getWidth() ) |
---|
1289 | { |
---|
1290 | uiARPartUnitIdx = MAX_UINT; |
---|
1291 | return NULL; |
---|
1292 | } |
---|
1293 | |
---|
1294 | #if CONSTRAINED_INTRA_PRED |
---|
1295 | if ( uiAbsPartIdxRT % uiNumPartInCUWidth < uiNumPartInCUWidth - uiPartUnitOffset ) |
---|
1296 | #else |
---|
1297 | if ( uiAbsPartIdxRT % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) |
---|
1298 | #endif |
---|
1299 | { |
---|
1300 | if ( uiAbsPartIdxRT / uiNumPartInCUWidth ) |
---|
1301 | { |
---|
1302 | #if CONSTRAINED_INTRA_PRED |
---|
1303 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ] ) |
---|
1304 | #else |
---|
1305 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] ) |
---|
1306 | #endif |
---|
1307 | { |
---|
1308 | #if CONSTRAINED_INTRA_PRED |
---|
1309 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
1310 | #else |
---|
1311 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ]; |
---|
1312 | #endif |
---|
1313 | if ( ( uiAbsPartIdxRT % uiNumPartInCUWidth == uiAbsZorderCUIdx % uiNumPartInCUWidth ) || ( uiAbsPartIdxRT / uiNumPartInCUWidth == uiAbsZorderCUIdx / uiNumPartInCUWidth ) ) |
---|
1314 | { |
---|
1315 | return m_pcPic->getCU( getAddr() ); |
---|
1316 | } |
---|
1317 | else |
---|
1318 | { |
---|
1319 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1320 | return this; |
---|
1321 | } |
---|
1322 | } |
---|
1323 | uiARPartUnitIdx = MAX_UINT; |
---|
1324 | return NULL; |
---|
1325 | } |
---|
1326 | #if CONSTRAINED_INTRA_PRED |
---|
1327 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
1328 | #else |
---|
1329 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; |
---|
1330 | #endif |
---|
1331 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiSliceStartCU)) || |
---|
1332 | (bEnforceEntropySliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1333 | { |
---|
1334 | return NULL; |
---|
1335 | } |
---|
1336 | return m_pcCUAbove; |
---|
1337 | } |
---|
1338 | |
---|
1339 | if ( uiAbsPartIdxRT / uiNumPartInCUWidth ) |
---|
1340 | { |
---|
1341 | uiARPartUnitIdx = MAX_UINT; |
---|
1342 | return NULL; |
---|
1343 | } |
---|
1344 | |
---|
1345 | #if CONSTRAINED_INTRA_PRED |
---|
1346 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset-1 ]; |
---|
1347 | #else |
---|
1348 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1349 | #endif |
---|
1350 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || m_pcCUAboveRight->getAddr() < m_uiSliceStartCU)) || |
---|
1351 | (bEnforceEntropySliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || m_pcCUAboveRight->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1352 | { |
---|
1353 | return NULL; |
---|
1354 | } |
---|
1355 | return m_pcCUAboveRight; |
---|
1356 | } |
---|
1357 | |
---|
1358 | |
---|
1359 | #if HHI_DMM_INTRA |
---|
1360 | Void TComDataCU::setWedgeFullTabIdxSubParts( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1361 | { |
---|
1362 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1363 | |
---|
1364 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1365 | { |
---|
1366 | m_puiWedgeFullTabIdx[uiAbsPartIdx+ui] = uiTIdx; |
---|
1367 | } |
---|
1368 | } |
---|
1369 | |
---|
1370 | Void TComDataCU::setWedgeFullDeltaDC1SubParts( Int iDC1, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1371 | { |
---|
1372 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1373 | |
---|
1374 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1375 | { |
---|
1376 | m_piWedgeFullDeltaDC1[uiAbsPartIdx+ui] = iDC1; |
---|
1377 | } |
---|
1378 | } |
---|
1379 | |
---|
1380 | Void TComDataCU::setWedgeFullDeltaDC2SubParts( Int iDC2, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1381 | { |
---|
1382 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1383 | |
---|
1384 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1385 | { |
---|
1386 | m_piWedgeFullDeltaDC2[uiAbsPartIdx+ui] = iDC2; |
---|
1387 | } |
---|
1388 | } |
---|
1389 | |
---|
1390 | Void TComDataCU::setWedgePredDirTabIdxSubParts( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1391 | { |
---|
1392 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1393 | |
---|
1394 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1395 | { |
---|
1396 | m_puiWedgePredDirTabIdx[uiAbsPartIdx+ui] = uiTIdx; |
---|
1397 | } |
---|
1398 | } |
---|
1399 | |
---|
1400 | Void TComDataCU::setWedgePredDirDeltaDC1SubParts( Int iDC1, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1401 | { |
---|
1402 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1403 | |
---|
1404 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1405 | { |
---|
1406 | m_piWedgePredDirDeltaDC1[uiAbsPartIdx+ui] = iDC1; |
---|
1407 | } |
---|
1408 | } |
---|
1409 | |
---|
1410 | Void TComDataCU::setWedgePredDirDeltaDC2SubParts( Int iDC2, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1411 | { |
---|
1412 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1413 | |
---|
1414 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1415 | { |
---|
1416 | m_piWedgePredDirDeltaDC2[uiAbsPartIdx+ui] = iDC2; |
---|
1417 | } |
---|
1418 | } |
---|
1419 | |
---|
1420 | Void TComDataCU::setWedgePredDirDeltaEndSubParts( Int iDelta, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1421 | { |
---|
1422 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1423 | |
---|
1424 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1425 | { |
---|
1426 | m_piWedgePredDirDeltaEnd[uiAbsPartIdx+ui] = iDelta; |
---|
1427 | } |
---|
1428 | } |
---|
1429 | |
---|
1430 | Void TComDataCU::setWedgePredTexTabIdxSubParts( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1431 | { |
---|
1432 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1433 | |
---|
1434 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1435 | { |
---|
1436 | m_puiWedgePredTexTabIdx[uiAbsPartIdx+ui] = uiTIdx; |
---|
1437 | } |
---|
1438 | } |
---|
1439 | |
---|
1440 | Void TComDataCU::setWedgePredTexDeltaDC1SubParts( Int iDC1, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1441 | { |
---|
1442 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1443 | |
---|
1444 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1445 | { |
---|
1446 | m_piWedgePredTexDeltaDC1[uiAbsPartIdx+ui] = iDC1; |
---|
1447 | } |
---|
1448 | } |
---|
1449 | |
---|
1450 | Void TComDataCU::setWedgePredTexDeltaDC2SubParts( Int iDC2, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1451 | { |
---|
1452 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1453 | |
---|
1454 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1455 | { |
---|
1456 | m_piWedgePredTexDeltaDC2[uiAbsPartIdx+ui] = iDC2; |
---|
1457 | } |
---|
1458 | } |
---|
1459 | |
---|
1460 | Void TComDataCU::setContourPredTexDeltaDC1SubParts( Int iDC1, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1461 | { |
---|
1462 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1463 | |
---|
1464 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1465 | { |
---|
1466 | m_piContourPredTexDeltaDC1[uiAbsPartIdx+ui] = iDC1; |
---|
1467 | } |
---|
1468 | } |
---|
1469 | |
---|
1470 | Void TComDataCU::setContourPredTexDeltaDC2SubParts( Int iDC2, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1471 | { |
---|
1472 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1473 | |
---|
1474 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1475 | { |
---|
1476 | m_piContourPredTexDeltaDC2[uiAbsPartIdx+ui] = iDC2; |
---|
1477 | } |
---|
1478 | } |
---|
1479 | |
---|
1480 | Void TComDataCU::setTextureModeAllowanceSubParts ( Bool bTMAllowed, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1481 | { |
---|
1482 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1483 | |
---|
1484 | memset( m_pbTextureModesAllowed + uiAbsPartIdx, bTMAllowed, sizeof(Bool)*uiCurrPartNumb ); |
---|
1485 | } |
---|
1486 | #endif |
---|
1487 | |
---|
1488 | Int |
---|
1489 | TComDataCU::getPdmMergeCandidate( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv ) |
---|
1490 | { |
---|
1491 | TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator(); |
---|
1492 | ROFRS( pcDepthMapGenerator, 0 ); |
---|
1493 | return pcDepthMapGenerator->getPdmMergeCandidate( this, uiPartIdx, paiPdmRefIdx, pacPdmMv ); |
---|
1494 | } |
---|
1495 | |
---|
1496 | |
---|
1497 | Bool |
---|
1498 | TComDataCU::getPdmMvPred( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, Bool bMerge ) |
---|
1499 | { |
---|
1500 | TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator(); |
---|
1501 | ROFRS( pcDepthMapGenerator, false ); |
---|
1502 | return pcDepthMapGenerator->getPdmMvPred( this, uiPartIdx, eRefPicList, iRefIdx, rcMv, bMerge ); |
---|
1503 | } |
---|
1504 | |
---|
1505 | |
---|
1506 | Bool |
---|
1507 | TComDataCU::getIViewOrgDepthMvPred( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv ) |
---|
1508 | { |
---|
1509 | TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator(); |
---|
1510 | ROFRS( pcDepthMapGenerator, false ); |
---|
1511 | return pcDepthMapGenerator->getIViewOrgDepthMvPred( this, uiPartIdx, eRefPicList, iRefIdx, rcMv ); |
---|
1512 | } |
---|
1513 | |
---|
1514 | Bool |
---|
1515 | TComDataCU::getResidualSamples( UInt uiPartIdx, TComYuv* pcYuv ) |
---|
1516 | { |
---|
1517 | TComResidualGenerator* pcResidualGenerator = m_pcSlice->getSPS()->getResidualGenerator(); |
---|
1518 | ROFRS( pcResidualGenerator, false ); |
---|
1519 | return pcResidualGenerator->getResidualSamples( this, uiPartIdx, pcYuv ); |
---|
1520 | } |
---|
1521 | |
---|
1522 | |
---|
1523 | Int TComDataCU::getMostProbableIntraDirLuma( UInt uiAbsPartIdx ) |
---|
1524 | { |
---|
1525 | TComDataCU* pcTempCU; |
---|
1526 | UInt uiTempPartIdx; |
---|
1527 | Int iLeftIntraDir, iAboveIntraDir, iMostProbable; |
---|
1528 | |
---|
1529 | // Get intra direction of left PU |
---|
1530 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, false ); |
---|
1531 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : NOT_VALID; |
---|
1532 | #if ADD_PLANAR_MODE |
---|
1533 | mapPlanartoDC( iLeftIntraDir ); |
---|
1534 | #endif |
---|
1535 | #if HHI_DMM_INTRA |
---|
1536 | mapDMMtoDC( iLeftIntraDir ); |
---|
1537 | #endif |
---|
1538 | |
---|
1539 | // Get intra direction of above PU |
---|
1540 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, false ); |
---|
1541 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : NOT_VALID; |
---|
1542 | #if ADD_PLANAR_MODE |
---|
1543 | mapPlanartoDC( iAboveIntraDir ); |
---|
1544 | #endif |
---|
1545 | #if HHI_DMM_INTRA |
---|
1546 | mapDMMtoDC( iAboveIntraDir ); |
---|
1547 | #endif |
---|
1548 | |
---|
1549 | iMostProbable = Min( iLeftIntraDir, iAboveIntraDir ); |
---|
1550 | |
---|
1551 | // Mode conversion process for blocks with different number of available prediction directions |
---|
1552 | Int iIdx = getIntraSizeIdx(uiAbsPartIdx); |
---|
1553 | |
---|
1554 | if ( iMostProbable >= g_aucIntraModeNumAng[iIdx] ) |
---|
1555 | { |
---|
1556 | if ( g_aucIntraModeNumAng[iIdx] == 5 ) |
---|
1557 | iMostProbable = g_aucAngModeMapping[0][g_aucAngIntraModeOrder[iMostProbable]]; |
---|
1558 | if ( g_aucIntraModeNumAng[iIdx] == 3 ) |
---|
1559 | iMostProbable = g_aucAngModeMapping[3][g_aucAngIntraModeOrder[iMostProbable]]; |
---|
1560 | else |
---|
1561 | iMostProbable = g_aucAngModeMapping[1][g_aucAngIntraModeOrder[iMostProbable]]; |
---|
1562 | } |
---|
1563 | |
---|
1564 | return ( NOT_VALID == iMostProbable ) ? 2 : iMostProbable; |
---|
1565 | } |
---|
1566 | #if MTK_DCM_MPM |
---|
1567 | Int TComDataCU::getIntraDirLumaPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[] ) |
---|
1568 | { |
---|
1569 | TComDataCU* pcTempCU; |
---|
1570 | UInt uiTempPartIdx; |
---|
1571 | Int iLeftIntraDir, iAboveIntraDir; |
---|
1572 | Int uiPredNum = 0; |
---|
1573 | |
---|
1574 | // Get intra direction of left PU |
---|
1575 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1576 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : 2; |
---|
1577 | #if ADD_PLANAR_MODE |
---|
1578 | mapPlanartoDC( iLeftIntraDir ); |
---|
1579 | #endif |
---|
1580 | #if HHI_DMM_INTRA |
---|
1581 | mapDMMtoDC( iLeftIntraDir ); |
---|
1582 | #endif |
---|
1583 | |
---|
1584 | // Get intra direction of above PU |
---|
1585 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1586 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : 2; |
---|
1587 | #if ADD_PLANAR_MODE |
---|
1588 | mapPlanartoDC( iAboveIntraDir ); |
---|
1589 | #endif |
---|
1590 | #if HHI_DMM_INTRA |
---|
1591 | mapDMMtoDC( iAboveIntraDir ); |
---|
1592 | #endif |
---|
1593 | |
---|
1594 | Int iIdx = getIntraSizeIdx(uiAbsPartIdx); |
---|
1595 | |
---|
1596 | if ( iLeftIntraDir >= g_aucIntraModeNumAng[iIdx] ) |
---|
1597 | { |
---|
1598 | if ( g_aucIntraModeNumAng[iIdx] == 5 ) |
---|
1599 | { |
---|
1600 | iLeftIntraDir = g_aucAngModeMapping[0][g_aucAngIntraModeOrder[iLeftIntraDir]]; |
---|
1601 | } |
---|
1602 | if ( g_aucIntraModeNumAng[iIdx] == 3 ) |
---|
1603 | { |
---|
1604 | iLeftIntraDir = g_aucAngModeMapping[3][g_aucAngIntraModeOrder[iLeftIntraDir]]; |
---|
1605 | } |
---|
1606 | else |
---|
1607 | { |
---|
1608 | iLeftIntraDir = g_aucAngModeMapping[1][g_aucAngIntraModeOrder[iLeftIntraDir]]; |
---|
1609 | } |
---|
1610 | } |
---|
1611 | |
---|
1612 | |
---|
1613 | if ( iAboveIntraDir >= g_aucIntraModeNumAng[iIdx] ) |
---|
1614 | { |
---|
1615 | if ( g_aucIntraModeNumAng[iIdx] == 5 ) |
---|
1616 | { |
---|
1617 | iAboveIntraDir = g_aucAngModeMapping[0][g_aucAngIntraModeOrder[iAboveIntraDir]]; |
---|
1618 | } |
---|
1619 | if ( g_aucIntraModeNumAng[iIdx] == 3 ) |
---|
1620 | { |
---|
1621 | iAboveIntraDir = g_aucAngModeMapping[3][g_aucAngIntraModeOrder[iAboveIntraDir]]; |
---|
1622 | } |
---|
1623 | else |
---|
1624 | { |
---|
1625 | iAboveIntraDir = g_aucAngModeMapping[1][g_aucAngIntraModeOrder[iAboveIntraDir]]; |
---|
1626 | } |
---|
1627 | } |
---|
1628 | |
---|
1629 | if(iLeftIntraDir == iAboveIntraDir) |
---|
1630 | { |
---|
1631 | uiPredNum = 1; |
---|
1632 | uiIntraDirPred[0] = iLeftIntraDir ; |
---|
1633 | } |
---|
1634 | else |
---|
1635 | { |
---|
1636 | uiPredNum = 2; |
---|
1637 | uiIntraDirPred[0] = Min(iLeftIntraDir, iAboveIntraDir); |
---|
1638 | uiIntraDirPred[1] = Max(iLeftIntraDir, iAboveIntraDir); |
---|
1639 | } |
---|
1640 | |
---|
1641 | |
---|
1642 | return uiPredNum; |
---|
1643 | } |
---|
1644 | #endif |
---|
1645 | #if LCEC_INTRA_MODE |
---|
1646 | Int TComDataCU::getLeftIntraDirLuma( UInt uiAbsPartIdx ) |
---|
1647 | { |
---|
1648 | TComDataCU* pcTempCU; |
---|
1649 | UInt uiTempPartIdx; |
---|
1650 | Int iLeftIntraDir; |
---|
1651 | |
---|
1652 | // Get intra direction of left PU |
---|
1653 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1654 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : NOT_VALID; |
---|
1655 | #if ADD_PLANAR_MODE |
---|
1656 | mapPlanartoDC( iLeftIntraDir ); |
---|
1657 | #endif |
---|
1658 | |
---|
1659 | return iLeftIntraDir; |
---|
1660 | } |
---|
1661 | |
---|
1662 | Int TComDataCU::getAboveIntraDirLuma( UInt uiAbsPartIdx ) |
---|
1663 | { |
---|
1664 | TComDataCU* pcTempCU; |
---|
1665 | UInt uiTempPartIdx; |
---|
1666 | Int iAboveIntraDir; |
---|
1667 | |
---|
1668 | // Get intra direction of above PU |
---|
1669 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1670 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : NOT_VALID; |
---|
1671 | #if ADD_PLANAR_MODE |
---|
1672 | mapPlanartoDC( iAboveIntraDir ); |
---|
1673 | #endif |
---|
1674 | |
---|
1675 | return iAboveIntraDir; |
---|
1676 | } |
---|
1677 | #endif |
---|
1678 | |
---|
1679 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1680 | { |
---|
1681 | TComDataCU* pcTempCU; |
---|
1682 | UInt uiTempPartIdx; |
---|
1683 | UInt uiCtx; |
---|
1684 | // Get left split flag |
---|
1685 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1686 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
1687 | |
---|
1688 | // Get above split flag |
---|
1689 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1690 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
1691 | |
---|
1692 | return uiCtx; |
---|
1693 | } |
---|
1694 | |
---|
1695 | #if MW_MVI_SIGNALLING_MODE == 0 |
---|
1696 | UInt TComDataCU::getCtxMvInheritanceFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1697 | { |
---|
1698 | // return 0; // MW |
---|
1699 | TComDataCU* pcTempCU; |
---|
1700 | UInt uiTempPartIdx; |
---|
1701 | UInt uiCtx; |
---|
1702 | // Get left split flag |
---|
1703 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1704 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getTextureModeDepth( uiTempPartIdx ) == uiDepth ) ? 1 : 0 ) : 0; |
---|
1705 | |
---|
1706 | // Get above split flag |
---|
1707 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1708 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getTextureModeDepth( uiTempPartIdx ) == uiDepth ) ? 1 : 0 ) : 0; |
---|
1709 | |
---|
1710 | return uiCtx; |
---|
1711 | } |
---|
1712 | #endif |
---|
1713 | |
---|
1714 | UInt TComDataCU::getCtxIntraDirChroma( UInt uiAbsPartIdx ) |
---|
1715 | { |
---|
1716 | TComDataCU* pcTempCU; |
---|
1717 | UInt uiTempPartIdx; |
---|
1718 | UInt uiCtx; |
---|
1719 | |
---|
1720 | // Get intra direction of left PU |
---|
1721 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1722 | #if CHROMA_CODEWORD |
---|
1723 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->isIntra( uiTempPartIdx ) && pcTempCU->getChromaIntraDir( uiTempPartIdx ) == 4 ) ? 1 : 0 ) : 0; |
---|
1724 | #else |
---|
1725 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->isIntra( uiTempPartIdx ) && pcTempCU->getChromaIntraDir( uiTempPartIdx ) > 0 ) ? 1 : 0 ) : 0; |
---|
1726 | #endif |
---|
1727 | |
---|
1728 | // Get intra direction of above PU |
---|
1729 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1730 | #if CHROMA_CODEWORD |
---|
1731 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->isIntra( uiTempPartIdx ) && pcTempCU->getChromaIntraDir( uiTempPartIdx ) == 4 ) ? 1 : 0 ) : 0; |
---|
1732 | #else |
---|
1733 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->isIntra( uiTempPartIdx ) && pcTempCU->getChromaIntraDir( uiTempPartIdx ) > 0 ) ? 1 : 0 ) : 0; |
---|
1734 | #endif |
---|
1735 | |
---|
1736 | return uiCtx; |
---|
1737 | } |
---|
1738 | |
---|
1739 | UInt TComDataCU::getCtxCbf( UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
1740 | { |
---|
1741 | TComDataCU* pcTempCU; |
---|
1742 | UInt uiTempPartIdx, uiTempTrDepth; |
---|
1743 | UInt uiErrRet = !isIntra(uiAbsPartIdx) ? 0 : 1; |
---|
1744 | UInt uiCtx = 0; |
---|
1745 | |
---|
1746 | // Get Cbf of left PU |
---|
1747 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1748 | if ( pcTempCU ) |
---|
1749 | { |
---|
1750 | uiTempTrDepth = pcTempCU->getTransformIdx( uiTempPartIdx ); |
---|
1751 | uiCtx = pcTempCU->getCbf( uiTempPartIdx, eType, uiTempTrDepth < uiTrDepth ? uiTempTrDepth : uiTrDepth ); |
---|
1752 | } |
---|
1753 | else |
---|
1754 | { |
---|
1755 | uiCtx = uiErrRet; |
---|
1756 | } |
---|
1757 | |
---|
1758 | // Get Cbf of above PU |
---|
1759 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1760 | if ( pcTempCU ) |
---|
1761 | { |
---|
1762 | uiTempTrDepth = pcTempCU->getTransformIdx( uiTempPartIdx ); |
---|
1763 | uiCtx += pcTempCU->getCbf( uiTempPartIdx, eType, uiTempTrDepth < uiTrDepth ? uiTempTrDepth : uiTrDepth ) << 1; |
---|
1764 | } |
---|
1765 | else |
---|
1766 | { |
---|
1767 | uiCtx += uiErrRet << 1; |
---|
1768 | } |
---|
1769 | |
---|
1770 | return uiCtx; |
---|
1771 | } |
---|
1772 | |
---|
1773 | UInt TComDataCU::getCtxQtCbf( UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
1774 | { |
---|
1775 | if( getPredictionMode( uiAbsPartIdx ) != MODE_INTRA && eType != TEXT_LUMA ) |
---|
1776 | { |
---|
1777 | return uiTrDepth; |
---|
1778 | } |
---|
1779 | UInt uiCtx = 0; |
---|
1780 | const UInt uiDepth = getDepth( uiAbsPartIdx ); |
---|
1781 | const UInt uiLog2TrafoSize = g_aucConvertToBit[getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth - uiTrDepth; |
---|
1782 | |
---|
1783 | if( uiTrDepth == 0 || uiLog2TrafoSize == getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
1784 | { |
---|
1785 | TComDataCU* pcTempCU; |
---|
1786 | UInt uiTempPartIdx, uiTempTrDepth; |
---|
1787 | |
---|
1788 | // Get Cbf of left PU |
---|
1789 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1790 | if ( pcTempCU ) |
---|
1791 | { |
---|
1792 | uiTempTrDepth = pcTempCU->getTransformIdx( uiTempPartIdx ); |
---|
1793 | uiCtx = pcTempCU->getCbf( uiTempPartIdx, eType, uiTempTrDepth ); |
---|
1794 | } |
---|
1795 | |
---|
1796 | // Get Cbf of above PU |
---|
1797 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1798 | if ( pcTempCU ) |
---|
1799 | { |
---|
1800 | uiTempTrDepth = pcTempCU->getTransformIdx( uiTempPartIdx ); |
---|
1801 | uiCtx += pcTempCU->getCbf( uiTempPartIdx, eType, uiTempTrDepth ) << 1; |
---|
1802 | } |
---|
1803 | uiCtx++; |
---|
1804 | } |
---|
1805 | return uiCtx; |
---|
1806 | } |
---|
1807 | |
---|
1808 | UInt TComDataCU::getCtxQtRootCbf( UInt uiAbsPartIdx ) |
---|
1809 | { |
---|
1810 | UInt uiCtx = 0; |
---|
1811 | TComDataCU* pcTempCU; |
---|
1812 | UInt uiTempPartIdx; |
---|
1813 | |
---|
1814 | // Get RootCbf of left PU |
---|
1815 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1816 | if ( pcTempCU ) |
---|
1817 | { |
---|
1818 | uiCtx = pcTempCU->getQtRootCbf( uiTempPartIdx ); |
---|
1819 | } |
---|
1820 | |
---|
1821 | // Get RootCbf of above PU |
---|
1822 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1823 | if ( pcTempCU ) |
---|
1824 | { |
---|
1825 | uiCtx += pcTempCU->getQtRootCbf( uiTempPartIdx ) << 1; |
---|
1826 | } |
---|
1827 | |
---|
1828 | return uiCtx; |
---|
1829 | } |
---|
1830 | |
---|
1831 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt uiIdx ) |
---|
1832 | { |
---|
1833 | #if HHI_RQT_DISABLE_SUB |
---|
1834 | return getQuadtreeTULog2RootSizeInCU(uiIdx); |
---|
1835 | #else |
---|
1836 | #if HHI_RQT_FORCE_SPLIT_ACC2_PU |
---|
1837 | UInt uiLog2MinTUSizeInCU = getQuadtreeTULog2RootSizeInCU(uiIdx); |
---|
1838 | #else |
---|
1839 | UInt uiLog2MinTUSizeInCU = g_aucConvertToBit[getWidth( uiIdx )] + 2; |
---|
1840 | |
---|
1841 | if ( getPredictionMode( uiIdx ) == MODE_INTRA && getPartitionSize( uiIdx ) == SIZE_NxN ) |
---|
1842 | { |
---|
1843 | uiLog2MinTUSizeInCU--; |
---|
1844 | } |
---|
1845 | #endif |
---|
1846 | |
---|
1847 | UInt uiQuadtreeTUMaxDepth = getPredictionMode( uiIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
1848 | if (uiLog2MinTUSizeInCU < m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + uiQuadtreeTUMaxDepth - 1) |
---|
1849 | { |
---|
1850 | uiLog2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
1851 | } |
---|
1852 | else |
---|
1853 | { |
---|
1854 | uiLog2MinTUSizeInCU -= uiQuadtreeTUMaxDepth - 1; |
---|
1855 | } |
---|
1856 | |
---|
1857 | if ( uiLog2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
1858 | { |
---|
1859 | uiLog2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
1860 | } |
---|
1861 | return uiLog2MinTUSizeInCU; |
---|
1862 | #endif |
---|
1863 | } |
---|
1864 | |
---|
1865 | #if HHI_RQT_FORCE_SPLIT_ACC2_PU || HHI_RQT_DISABLE_SUB |
---|
1866 | UInt TComDataCU::getQuadtreeTULog2RootSizeInCU( UInt uiIdx ) |
---|
1867 | { |
---|
1868 | UInt uiLog2RootTUSizeInCU = g_aucConvertToBit[getWidth( uiIdx )] +2; |
---|
1869 | |
---|
1870 | #if !HHI_RQT_FORCE_SPLIT_NxN && !HHI_RQT_DISABLE_SUB |
---|
1871 | if ( getPredictionMode( uiIdx ) == MODE_INTRA && getPartitionSize( uiIdx ) == SIZE_NxN ) |
---|
1872 | { |
---|
1873 | uiLog2RootTUSizeInCU--; |
---|
1874 | return (uiLog2RootTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() ? m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() : uiLog2RootTUSizeInCU); |
---|
1875 | } |
---|
1876 | #endif |
---|
1877 | |
---|
1878 | if (m_pePartSize[ uiIdx ] == SIZE_2Nx2N) |
---|
1879 | { |
---|
1880 | return (uiLog2RootTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() ? m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() : uiLog2RootTUSizeInCU); |
---|
1881 | } |
---|
1882 | else if (m_pePartSize[ uiIdx ] >= SIZE_2NxN && m_pePartSize[ uiIdx ] <= SIZE_Nx2N) |
---|
1883 | { |
---|
1884 | #if HHI_RQT_FORCE_SPLIT_RECT || HHI_RQT_DISABLE_SUB |
---|
1885 | uiLog2RootTUSizeInCU--; |
---|
1886 | #endif |
---|
1887 | return (uiLog2RootTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() ? m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() : uiLog2RootTUSizeInCU); |
---|
1888 | } |
---|
1889 | else if (m_pePartSize[ uiIdx ] == SIZE_NxN) |
---|
1890 | { |
---|
1891 | #if HHI_RQT_FORCE_SPLIT_NxN || HHI_RQT_DISABLE_SUB |
---|
1892 | uiLog2RootTUSizeInCU--; |
---|
1893 | #endif |
---|
1894 | return (uiLog2RootTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() ? m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() : uiLog2RootTUSizeInCU); |
---|
1895 | } |
---|
1896 | |
---|
1897 | return (uiLog2RootTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() ? m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() : uiLog2RootTUSizeInCU); |
---|
1898 | } |
---|
1899 | #endif |
---|
1900 | |
---|
1901 | UInt TComDataCU::getCtxAlfCtrlFlag( UInt uiAbsPartIdx ) |
---|
1902 | { |
---|
1903 | TComDataCU* pcTempCU; |
---|
1904 | UInt uiTempPartIdx; |
---|
1905 | UInt uiCtx = 0; |
---|
1906 | |
---|
1907 | // Get BCBP of left PU |
---|
1908 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1909 | uiCtx = ( pcTempCU ) ? pcTempCU->getAlfCtrlFlag( uiTempPartIdx ) : 0; |
---|
1910 | |
---|
1911 | // Get BCBP of above PU |
---|
1912 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1913 | uiCtx += ( pcTempCU ) ? pcTempCU->getAlfCtrlFlag( uiTempPartIdx ) : 0; |
---|
1914 | |
---|
1915 | return uiCtx; |
---|
1916 | } |
---|
1917 | |
---|
1918 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
---|
1919 | { |
---|
1920 | TComDataCU* pcTempCU; |
---|
1921 | UInt uiTempPartIdx; |
---|
1922 | UInt uiCtx = 0; |
---|
1923 | |
---|
1924 | // Get BCBP of left PU |
---|
1925 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1926 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
1927 | |
---|
1928 | // Get BCBP of above PU |
---|
1929 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1930 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
1931 | |
---|
1932 | return uiCtx; |
---|
1933 | } |
---|
1934 | |
---|
1935 | /** CABAC context derivation for merge flag |
---|
1936 | * \param uiAbsPartIdx |
---|
1937 | * \returns context offset |
---|
1938 | */ |
---|
1939 | UInt TComDataCU::getCtxMergeFlag( UInt uiAbsPartIdx ) |
---|
1940 | { |
---|
1941 | UInt uiCtx = 0; |
---|
1942 | #if CHANGE_MERGE_CONTEXT |
---|
1943 | TComDataCU* pcTempCU; |
---|
1944 | UInt uiTempPartIdx; |
---|
1945 | |
---|
1946 | // Get BCBP of left PU |
---|
1947 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1948 | uiCtx = ( pcTempCU ) ? pcTempCU->getMergeFlag( uiTempPartIdx ) : 0; |
---|
1949 | |
---|
1950 | // Get BCBP of above PU |
---|
1951 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1952 | uiCtx += ( pcTempCU ) ? pcTempCU->getMergeFlag( uiTempPartIdx ) : 0; |
---|
1953 | #endif |
---|
1954 | return uiCtx; |
---|
1955 | } |
---|
1956 | |
---|
1957 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
---|
1958 | { |
---|
1959 | TComDataCU* pcTempCU; |
---|
1960 | UInt uiTempPartIdx; |
---|
1961 | UInt uiCtx = 0; |
---|
1962 | |
---|
1963 | // Get BCBP of left PU |
---|
1964 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1965 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getInterDir( uiTempPartIdx ) % 3 ) ? 0 : 1 ) : 0; |
---|
1966 | |
---|
1967 | // Get BCBP of Above PU |
---|
1968 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1969 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getInterDir( uiTempPartIdx ) % 3 ) ? 0 : 1 ) : 0; |
---|
1970 | |
---|
1971 | return uiCtx; |
---|
1972 | } |
---|
1973 | |
---|
1974 | UInt TComDataCU::getCtxRefIdx( UInt uiAbsPartIdx, RefPicList eRefPicList ) |
---|
1975 | { |
---|
1976 | TComDataCU* pcTempCU; |
---|
1977 | UInt uiTempPartIdx; |
---|
1978 | TComMvField cMvFieldTemp; |
---|
1979 | UInt uiCtx = 0; |
---|
1980 | |
---|
1981 | // Get BCBP of left PU |
---|
1982 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1983 | getMvField( pcTempCU, uiTempPartIdx, eRefPicList, cMvFieldTemp ); |
---|
1984 | uiCtx += cMvFieldTemp.getRefIdx() > 0 ? 1 : 0; |
---|
1985 | |
---|
1986 | // Get BCBP of Above PU |
---|
1987 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1988 | getMvField( pcTempCU, uiTempPartIdx, eRefPicList, cMvFieldTemp ); |
---|
1989 | uiCtx += cMvFieldTemp.getRefIdx() > 0 ? 2 : 0; |
---|
1990 | |
---|
1991 | return uiCtx; |
---|
1992 | } |
---|
1993 | |
---|
1994 | Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1995 | { |
---|
1996 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1997 | memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
1998 | memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
1999 | memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2000 | } |
---|
2001 | |
---|
2002 | Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2003 | { |
---|
2004 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2005 | memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2006 | } |
---|
2007 | |
---|
2008 | #if HHI_MRG_SKIP |
---|
2009 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
2010 | * \param uiCbf The value of the coded block flag to be set |
---|
2011 | * \param eTType |
---|
2012 | * \param uiAbsPartIdx |
---|
2013 | * \param uiPartIdx |
---|
2014 | * \param uiDepth |
---|
2015 | * \returns Void |
---|
2016 | */ |
---|
2017 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2018 | { |
---|
2019 | setSubPartUChar( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2020 | } |
---|
2021 | #endif |
---|
2022 | |
---|
2023 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
2024 | { |
---|
2025 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2026 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2027 | } |
---|
2028 | |
---|
2029 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
---|
2030 | { |
---|
2031 | UInt uiPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2032 | return (((m_uiAbsIdxInLCU + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
2033 | } |
---|
2034 | |
---|
2035 | Void TComDataCU::setAlfCtrlFlagSubParts ( UInt uiFlag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2036 | { |
---|
2037 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2038 | |
---|
2039 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
2040 | { |
---|
2041 | m_puiAlfCtrlFlag[uiAbsPartIdx + ui] = uiFlag; |
---|
2042 | } |
---|
2043 | } |
---|
2044 | |
---|
2045 | Void TComDataCU::createTmpAlfCtrlFlag() |
---|
2046 | { |
---|
2047 | m_puiTmpAlfCtrlFlag = (UInt* )xMalloc(UInt, m_uiNumPartition); |
---|
2048 | } |
---|
2049 | |
---|
2050 | Void TComDataCU::destroyTmpAlfCtrlFlag() |
---|
2051 | { |
---|
2052 | if(m_puiTmpAlfCtrlFlag) |
---|
2053 | { |
---|
2054 | xFree(m_puiTmpAlfCtrlFlag); m_puiTmpAlfCtrlFlag = NULL; |
---|
2055 | } |
---|
2056 | } |
---|
2057 | |
---|
2058 | Void TComDataCU::copyAlfCtrlFlagToTmp() |
---|
2059 | { |
---|
2060 | memcpy( m_puiTmpAlfCtrlFlag, m_puiAlfCtrlFlag, sizeof(UInt)*m_uiNumPartition ); |
---|
2061 | } |
---|
2062 | |
---|
2063 | Void TComDataCU::copyAlfCtrlFlagFromTmp() |
---|
2064 | { |
---|
2065 | memcpy( m_puiAlfCtrlFlag, m_puiTmpAlfCtrlFlag, sizeof(UInt)*m_uiNumPartition ); |
---|
2066 | } |
---|
2067 | |
---|
2068 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2069 | { |
---|
2070 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2071 | |
---|
2072 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
2073 | { |
---|
2074 | m_pePartSize[uiAbsPartIdx + ui] = eMode; |
---|
2075 | } |
---|
2076 | } |
---|
2077 | |
---|
2078 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2079 | { |
---|
2080 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2081 | |
---|
2082 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
2083 | { |
---|
2084 | m_pePredMode[uiAbsPartIdx + ui] = eMode; |
---|
2085 | } |
---|
2086 | } |
---|
2087 | |
---|
2088 | Void TComDataCU::setQPSubParts( UInt uiQP, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2089 | { |
---|
2090 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2091 | |
---|
2092 | memset( m_phQP + uiAbsPartIdx, uiQP, sizeof(Char)*uiCurrPartNumb ); |
---|
2093 | } |
---|
2094 | |
---|
2095 | Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2096 | { |
---|
2097 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2098 | |
---|
2099 | memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2100 | } |
---|
2101 | |
---|
2102 | Void TComDataCU::setSubPartUChar( UInt uiParameter, UChar* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2103 | { |
---|
2104 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (uiCUDepth << 1)) >> 2; |
---|
2105 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2106 | { |
---|
2107 | case SIZE_2Nx2N: |
---|
2108 | memset( puhBaseLCU + uiCUAddr, uiParameter, sizeof(UChar)*uiCurrPartNumQ << 2 ); break; |
---|
2109 | case SIZE_2NxN: |
---|
2110 | memset( puhBaseLCU + uiCUAddr, uiParameter, sizeof(UChar)*uiCurrPartNumQ << 1 ); break; |
---|
2111 | case SIZE_Nx2N: |
---|
2112 | memset( puhBaseLCU + uiCUAddr, uiParameter, sizeof(UChar)*uiCurrPartNumQ ); |
---|
2113 | memset( puhBaseLCU + uiCUAddr + ( uiCurrPartNumQ << 1 ), uiParameter, sizeof(UChar)*uiCurrPartNumQ ); break; |
---|
2114 | case SIZE_NxN: |
---|
2115 | memset( puhBaseLCU + uiCUAddr, uiParameter, sizeof(UChar)*uiCurrPartNumQ ); break; |
---|
2116 | default: |
---|
2117 | assert( 0 ); |
---|
2118 | } |
---|
2119 | } |
---|
2120 | |
---|
2121 | Void TComDataCU::setSubPartBool( Bool bParameter, Bool* pbBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2122 | { |
---|
2123 | UInt uiQuaterCUPartNum = (m_pcPic->getNumPartInCU() >> (uiCUDepth << 1)) >> 2; |
---|
2124 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2125 | { |
---|
2126 | case SIZE_2Nx2N: |
---|
2127 | memset( pbBaseLCU + uiCUAddr, bParameter, sizeof(Bool)*uiQuaterCUPartNum << 2 ); break; |
---|
2128 | case SIZE_2NxN: |
---|
2129 | memset( pbBaseLCU + uiCUAddr, bParameter, sizeof(Bool)*uiQuaterCUPartNum << 1 ); break; |
---|
2130 | case SIZE_Nx2N: |
---|
2131 | memset( pbBaseLCU + uiCUAddr, bParameter, sizeof(Bool)*uiQuaterCUPartNum ); |
---|
2132 | memset( pbBaseLCU + uiCUAddr + ( uiQuaterCUPartNum << 1 ), bParameter, sizeof(Bool)*uiQuaterCUPartNum ); break; |
---|
2133 | case SIZE_NxN: |
---|
2134 | memset( pbBaseLCU + uiCUAddr, bParameter, sizeof(Bool)*uiQuaterCUPartNum ); break; |
---|
2135 | default: |
---|
2136 | assert( 0 ); |
---|
2137 | } |
---|
2138 | } |
---|
2139 | |
---|
2140 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2141 | { |
---|
2142 | setSubPartBool( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2143 | } |
---|
2144 | |
---|
2145 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2146 | { |
---|
2147 | setSubPartUChar( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2148 | } |
---|
2149 | |
---|
2150 | Void TComDataCU::setResPredAvailSubParts( Bool bResPredAvailable, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2151 | { |
---|
2152 | setSubPartBool( bResPredAvailable, m_pbResPredAvailable, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2153 | } |
---|
2154 | |
---|
2155 | Void TComDataCU::setResPredFlagSubParts( Bool bResPredFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2156 | { |
---|
2157 | setSubPartBool( bResPredFlag, m_pbResPredFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2158 | } |
---|
2159 | |
---|
2160 | Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2161 | { |
---|
2162 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2163 | |
---|
2164 | memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2165 | } |
---|
2166 | |
---|
2167 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2168 | { |
---|
2169 | setSubPartUChar( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2170 | } |
---|
2171 | |
---|
2172 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2173 | { |
---|
2174 | UInt uiCurrPartNumQ = m_pcPic->getNumPartInCU() >> (uiDepth << 1) >> 2; |
---|
2175 | UInt i; |
---|
2176 | Int* pi; |
---|
2177 | switch ( m_pePartSize[ uiAbsPartIdx ] ) |
---|
2178 | { |
---|
2179 | case SIZE_2Nx2N: |
---|
2180 | { |
---|
2181 | pi = m_apiMVPIdx[eRefPicList] + uiAbsPartIdx; |
---|
2182 | for (i = 0; i < (uiCurrPartNumQ << 2); i++) |
---|
2183 | { |
---|
2184 | pi[i] = iMVPIdx; |
---|
2185 | } |
---|
2186 | } |
---|
2187 | break; |
---|
2188 | case SIZE_2NxN: |
---|
2189 | { |
---|
2190 | pi = m_apiMVPIdx[eRefPicList] + uiAbsPartIdx; |
---|
2191 | for (i = 0; i < (uiCurrPartNumQ << 1); i++) |
---|
2192 | { |
---|
2193 | pi[i] = iMVPIdx; |
---|
2194 | } |
---|
2195 | } |
---|
2196 | break; |
---|
2197 | case SIZE_Nx2N: |
---|
2198 | { |
---|
2199 | Int* pi2 = m_apiMVPIdx[eRefPicList] + uiAbsPartIdx + ( uiCurrPartNumQ << 1 ); |
---|
2200 | pi = m_apiMVPIdx[eRefPicList] + uiAbsPartIdx; |
---|
2201 | for (i = 0; i < uiCurrPartNumQ; i++) |
---|
2202 | { |
---|
2203 | pi [i] = iMVPIdx; |
---|
2204 | pi2[i] = iMVPIdx; |
---|
2205 | } |
---|
2206 | break; |
---|
2207 | } |
---|
2208 | case SIZE_NxN: |
---|
2209 | { |
---|
2210 | pi = m_apiMVPIdx[eRefPicList] + uiAbsPartIdx; |
---|
2211 | for (i = 0; i < uiCurrPartNumQ; i++) |
---|
2212 | { |
---|
2213 | pi[i] = iMVPIdx; |
---|
2214 | } |
---|
2215 | break; |
---|
2216 | } |
---|
2217 | default: |
---|
2218 | assert( 0 ); |
---|
2219 | } |
---|
2220 | } |
---|
2221 | |
---|
2222 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2223 | { |
---|
2224 | UInt uiCurrPartNumQ = m_pcPic->getNumPartInCU() >> (uiDepth << 1) >> 2; |
---|
2225 | UInt i; |
---|
2226 | Int* pi; |
---|
2227 | switch ( m_pePartSize[ uiAbsPartIdx ] ) |
---|
2228 | { |
---|
2229 | case SIZE_2Nx2N: |
---|
2230 | { |
---|
2231 | pi = m_apiMVPNum[eRefPicList] + uiAbsPartIdx; |
---|
2232 | for (i = 0; i < (uiCurrPartNumQ << 2); i++) |
---|
2233 | { |
---|
2234 | pi[i] = iMVPNum; |
---|
2235 | } |
---|
2236 | } |
---|
2237 | break; |
---|
2238 | case SIZE_2NxN: |
---|
2239 | { |
---|
2240 | pi = m_apiMVPNum[eRefPicList] + uiAbsPartIdx; |
---|
2241 | for (i = 0; i < (uiCurrPartNumQ << 1); i++) |
---|
2242 | { |
---|
2243 | pi[i] = iMVPNum; |
---|
2244 | } |
---|
2245 | } |
---|
2246 | break; |
---|
2247 | case SIZE_Nx2N: |
---|
2248 | { |
---|
2249 | pi = m_apiMVPNum[eRefPicList] + uiAbsPartIdx; |
---|
2250 | for (i = 0; i < uiCurrPartNumQ; i++) |
---|
2251 | { |
---|
2252 | pi[i] = iMVPNum; |
---|
2253 | } |
---|
2254 | pi = m_apiMVPNum[eRefPicList] + uiAbsPartIdx + ( uiCurrPartNumQ << 1 ); |
---|
2255 | for (i = 0; i < uiCurrPartNumQ; i++) |
---|
2256 | { |
---|
2257 | pi[i] = iMVPNum; |
---|
2258 | } |
---|
2259 | } |
---|
2260 | break; |
---|
2261 | case SIZE_NxN: |
---|
2262 | { |
---|
2263 | pi = m_apiMVPNum[eRefPicList] + uiAbsPartIdx; |
---|
2264 | for (i = 0; i < uiCurrPartNumQ; i++) |
---|
2265 | { |
---|
2266 | pi[i] = iMVPNum; |
---|
2267 | } |
---|
2268 | } |
---|
2269 | break; |
---|
2270 | default: |
---|
2271 | assert( 0 ); |
---|
2272 | } |
---|
2273 | } |
---|
2274 | |
---|
2275 | |
---|
2276 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2277 | { |
---|
2278 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2279 | |
---|
2280 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
2281 | } |
---|
2282 | |
---|
2283 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2284 | { |
---|
2285 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2286 | |
---|
2287 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2288 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
2289 | } |
---|
2290 | |
---|
2291 | UChar TComDataCU::getNumPartInter() |
---|
2292 | { |
---|
2293 | UChar iNumPart = 0; |
---|
2294 | |
---|
2295 | switch ( m_pePartSize[0] ) |
---|
2296 | { |
---|
2297 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
2298 | case SIZE_2NxN: iNumPart = 2; break; |
---|
2299 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
2300 | case SIZE_NxN: iNumPart = 4; break; |
---|
2301 | default: assert (0); break; |
---|
2302 | } |
---|
2303 | |
---|
2304 | return iNumPart; |
---|
2305 | } |
---|
2306 | |
---|
2307 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
---|
2308 | { |
---|
2309 | switch ( m_pePartSize[0] ) |
---|
2310 | { |
---|
2311 | case SIZE_2NxN: |
---|
2312 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2313 | break; |
---|
2314 | case SIZE_Nx2N: |
---|
2315 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
2316 | break; |
---|
2317 | case SIZE_NxN: |
---|
2318 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2319 | break; |
---|
2320 | default: |
---|
2321 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
2322 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
2323 | break; |
---|
2324 | } |
---|
2325 | } |
---|
2326 | |
---|
2327 | |
---|
2328 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
2329 | { |
---|
2330 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
2331 | { |
---|
2332 | TComMv cZeroMv; |
---|
2333 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
2334 | return; |
---|
2335 | } |
---|
2336 | |
---|
2337 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
2338 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
2339 | } |
---|
2340 | |
---|
2341 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2342 | { |
---|
2343 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
2344 | UInt uiPUWidth = 0; |
---|
2345 | |
---|
2346 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2347 | { |
---|
2348 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2349 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2350 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2351 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2352 | default: |
---|
2353 | assert (0); |
---|
2354 | break; |
---|
2355 | } |
---|
2356 | |
---|
2357 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2358 | } |
---|
2359 | |
---|
2360 | Void TComDataCU::deriveLeftBottomIdxGeneral( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2361 | { |
---|
2362 | UInt uiPUHeight = 0; |
---|
2363 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2364 | { |
---|
2365 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2366 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2367 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2368 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2369 | default: |
---|
2370 | assert (0); |
---|
2371 | break; |
---|
2372 | } |
---|
2373 | |
---|
2374 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
2375 | } |
---|
2376 | |
---|
2377 | Void TComDataCU::deriveLeftRightTopIdx ( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2378 | { |
---|
2379 | ruiPartIdxLT = m_uiAbsIdxInLCU; |
---|
2380 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2381 | |
---|
2382 | switch ( m_pePartSize[0] ) |
---|
2383 | { |
---|
2384 | case SIZE_2Nx2N: break; |
---|
2385 | case SIZE_2NxN: |
---|
2386 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2387 | break; |
---|
2388 | case SIZE_Nx2N: |
---|
2389 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
2390 | break; |
---|
2391 | case SIZE_NxN: |
---|
2392 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2393 | break; |
---|
2394 | default: |
---|
2395 | assert (0); |
---|
2396 | break; |
---|
2397 | } |
---|
2398 | |
---|
2399 | } |
---|
2400 | |
---|
2401 | Void TComDataCU::deriveLeftBottomIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2402 | { |
---|
2403 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
2404 | |
---|
2405 | switch ( m_pePartSize[0] ) |
---|
2406 | { |
---|
2407 | case SIZE_2Nx2N: |
---|
2408 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
2409 | break; |
---|
2410 | case SIZE_2NxN: |
---|
2411 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2412 | break; |
---|
2413 | case SIZE_Nx2N: |
---|
2414 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
2415 | break; |
---|
2416 | case SIZE_NxN: |
---|
2417 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2418 | break; |
---|
2419 | default: |
---|
2420 | assert (0); |
---|
2421 | break; |
---|
2422 | } |
---|
2423 | } |
---|
2424 | |
---|
2425 | #if MTK_TMVP_H_MRG || MTK_TMVP_H_AMVP |
---|
2426 | /** Derives the partition index of neighbouring bottom right block |
---|
2427 | * \param in eCUMode |
---|
2428 | * \param in uiPartIdx |
---|
2429 | * \param out ruiPartIdx |
---|
2430 | * \returns Void |
---|
2431 | */ |
---|
2432 | Void TComDataCU::deriveRightBottomIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxRB ) |
---|
2433 | { |
---|
2434 | 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]; |
---|
2435 | |
---|
2436 | switch ( m_pePartSize[0] ) |
---|
2437 | { |
---|
2438 | case SIZE_2Nx2N: |
---|
2439 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
2440 | break; |
---|
2441 | case SIZE_2NxN: |
---|
2442 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2443 | break; |
---|
2444 | case SIZE_Nx2N: |
---|
2445 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
2446 | break; |
---|
2447 | case SIZE_NxN: |
---|
2448 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2449 | break; |
---|
2450 | default: |
---|
2451 | assert (0); |
---|
2452 | break; |
---|
2453 | } |
---|
2454 | } |
---|
2455 | #endif |
---|
2456 | |
---|
2457 | Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ) |
---|
2458 | { |
---|
2459 | UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; |
---|
2460 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset; |
---|
2461 | ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; |
---|
2462 | } |
---|
2463 | |
---|
2464 | Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ) |
---|
2465 | { |
---|
2466 | UInt uiAbsIdx; |
---|
2467 | UInt uiMinCuWidth, uiWidthInMinCus; |
---|
2468 | |
---|
2469 | uiMinCuWidth = getPic()->getMinCUWidth(); |
---|
2470 | uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; |
---|
2471 | uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; |
---|
2472 | uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); |
---|
2473 | ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; |
---|
2474 | } |
---|
2475 | |
---|
2476 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, UInt uiCandInterDir, Int* paiCandRefIdx, TComMv* pacCandMv ) |
---|
2477 | { |
---|
2478 | AOT ( getInterDir( uiAbsPartIdx ) == 0 ); |
---|
2479 | ROTRS( getInterDir( uiAbsPartIdx ) == uiCandInterDir, false ); |
---|
2480 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
2481 | { |
---|
2482 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
2483 | { |
---|
2484 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != paiCandRefIdx[ uiRefListIdx ] || |
---|
2485 | getCUMvField( RefPicList( uiRefListIdx ) )->getMv ( uiAbsPartIdx ) != pacCandMv [ uiRefListIdx ] ) |
---|
2486 | { |
---|
2487 | return false; |
---|
2488 | } |
---|
2489 | } |
---|
2490 | } |
---|
2491 | return true; |
---|
2492 | } |
---|
2493 | |
---|
2494 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
2495 | { |
---|
2496 | assert( getInterDir( uiAbsPartIdx ) != 0 ); |
---|
2497 | |
---|
2498 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
2499 | { |
---|
2500 | return false; |
---|
2501 | } |
---|
2502 | |
---|
2503 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
2504 | { |
---|
2505 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
2506 | { |
---|
2507 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
2508 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
2509 | { |
---|
2510 | return false; |
---|
2511 | } |
---|
2512 | } |
---|
2513 | } |
---|
2514 | |
---|
2515 | return true; |
---|
2516 | } |
---|
2517 | |
---|
2518 | Bool TComDataCU::avoidMergeCandidate( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, UInt uiCandInterDir, Int* paiCandRefIdx, TComMv* pacCandMv ) |
---|
2519 | { |
---|
2520 | // uiAbsPartIdx has to be the first index of the current PU |
---|
2521 | PartSize ePartSize = getPartitionSize( uiAbsPartIdx ); |
---|
2522 | |
---|
2523 | if ( ePartSize != SIZE_NxN && ePartSize != SIZE_2Nx2N ) |
---|
2524 | { |
---|
2525 | // we have exactly 2 PUs. Avoid imitating 2Nx2N. |
---|
2526 | if ( uiPUIdx == 1 ) |
---|
2527 | { |
---|
2528 | // we would merge the second PU |
---|
2529 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
2530 | UInt uiAbsPartIdxOfFirstPU = uiAbsPartIdx - uiPUOffset; |
---|
2531 | if ( hasEqualMotion( uiAbsPartIdxOfFirstPU, uiCandInterDir, paiCandRefIdx, pacCandMv ) ) |
---|
2532 | { |
---|
2533 | // don't merge |
---|
2534 | return true; |
---|
2535 | } |
---|
2536 | } |
---|
2537 | } |
---|
2538 | if ( ePartSize == SIZE_NxN ) |
---|
2539 | { |
---|
2540 | if ( uiPUIdx == 3 ) |
---|
2541 | { |
---|
2542 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
2543 | UInt uiPUOffsetIdx0 = uiAbsPartIdx - 3*uiPUOffset; |
---|
2544 | UInt uiPUOffsetIdx1 = uiAbsPartIdx - 2*uiPUOffset; |
---|
2545 | UInt uiPUOffsetIdx2 = uiAbsPartIdx - uiPUOffset; |
---|
2546 | |
---|
2547 | // avoid imitating 2Nx2N and Nx2N partitioning. |
---|
2548 | if ( hasEqualMotion( uiPUOffsetIdx0, this, uiPUOffsetIdx2 ) && |
---|
2549 | hasEqualMotion( uiPUOffsetIdx1, uiCandInterDir, paiCandRefIdx, pacCandMv ) ) |
---|
2550 | { |
---|
2551 | // don't merge |
---|
2552 | return true; |
---|
2553 | } |
---|
2554 | |
---|
2555 | // avoid imitating 2NxN partitioning. |
---|
2556 | if ( hasEqualMotion( uiPUOffsetIdx0, this, uiPUOffsetIdx1 ) && |
---|
2557 | hasEqualMotion( uiPUOffsetIdx2, uiCandInterDir, paiCandRefIdx, pacCandMv ) ) |
---|
2558 | { |
---|
2559 | // don't merge |
---|
2560 | return true; |
---|
2561 | } |
---|
2562 | } |
---|
2563 | } |
---|
2564 | return false; |
---|
2565 | } |
---|
2566 | |
---|
2567 | Bool TComDataCU::avoidMergeCandidate( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
2568 | { |
---|
2569 | // uiAbsPartIdx has to be the first index of the current PU |
---|
2570 | |
---|
2571 | if ( !pcCandCU ) |
---|
2572 | { |
---|
2573 | return true; |
---|
2574 | } |
---|
2575 | |
---|
2576 | PartSize ePartSize = getPartitionSize( uiAbsPartIdx ); |
---|
2577 | |
---|
2578 | if ( ePartSize != SIZE_NxN && ePartSize != SIZE_2Nx2N ) |
---|
2579 | { |
---|
2580 | // we have exactly 2 PUs. Avoid imitating 2Nx2N. |
---|
2581 | if ( uiPUIdx == 1 ) |
---|
2582 | { |
---|
2583 | // we would merge the second PU |
---|
2584 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
2585 | UInt uiAbsPartIdxOfFirstPU = uiAbsPartIdx - uiPUOffset; |
---|
2586 | if ( hasEqualMotion( uiAbsPartIdxOfFirstPU, pcCandCU, uiCandAbsPartIdx ) ) |
---|
2587 | { |
---|
2588 | // don't merge |
---|
2589 | return true; |
---|
2590 | } |
---|
2591 | } |
---|
2592 | } |
---|
2593 | if ( ePartSize == SIZE_NxN ) |
---|
2594 | { |
---|
2595 | if ( uiPUIdx == 3 ) |
---|
2596 | { |
---|
2597 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
2598 | UInt uiPUOffsetIdx0 = uiAbsPartIdx - 3*uiPUOffset; |
---|
2599 | UInt uiPUOffsetIdx1 = uiAbsPartIdx - 2*uiPUOffset; |
---|
2600 | UInt uiPUOffsetIdx2 = uiAbsPartIdx - uiPUOffset; |
---|
2601 | |
---|
2602 | // avoid imitating 2Nx2N and Nx2N partitioning. |
---|
2603 | if ( hasEqualMotion( uiPUOffsetIdx0, this, uiPUOffsetIdx2 ) && |
---|
2604 | hasEqualMotion( uiPUOffsetIdx1, pcCandCU, uiCandAbsPartIdx ) ) |
---|
2605 | { |
---|
2606 | // don't merge |
---|
2607 | return true; |
---|
2608 | } |
---|
2609 | |
---|
2610 | // avoid imitating 2NxN partitioning. |
---|
2611 | if ( hasEqualMotion( uiPUOffsetIdx0, this, uiPUOffsetIdx1 ) && |
---|
2612 | hasEqualMotion( uiPUOffsetIdx2, pcCandCU, uiCandAbsPartIdx ) ) |
---|
2613 | { |
---|
2614 | // don't merge |
---|
2615 | return true; |
---|
2616 | } |
---|
2617 | } |
---|
2618 | } |
---|
2619 | return false; |
---|
2620 | } |
---|
2621 | |
---|
2622 | /** Constructs a list of merging candidates |
---|
2623 | * \param uiAbsPartIdx |
---|
2624 | * \param uiPUIdx |
---|
2625 | * \param uiDepth |
---|
2626 | * \param pcMvFieldNeighbours |
---|
2627 | * \param puhInterDirNeighbours |
---|
2628 | * \param puiNeighbourCandIdx |
---|
2629 | * \returns Void |
---|
2630 | */ |
---|
2631 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, UInt* puiNeighbourCandIdx ) |
---|
2632 | { |
---|
2633 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
2634 | Bool bNoPdmMerge = ( m_pcSlice->getSPS()->getViewId() == 0 || ( m_pcSlice->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) != PDM_USE_FOR_MERGE ); |
---|
2635 | UInt uiPdmMergePos = ( bNoPdmMerge ? 5 : PDM_MERGE_POS ); |
---|
2636 | UInt uiLeftAddr = ( uiPdmMergePos < 1 ? 1 : 0 ); |
---|
2637 | UInt uiAboveAddr = ( uiPdmMergePos < 2 ? 2 : 1 ); |
---|
2638 | UInt uiColocAddr = ( uiPdmMergePos < 3 ? 3 : 2 ); |
---|
2639 | UInt uiCorRTAddr = ( uiPdmMergePos < 4 ? 4 : 3 ); |
---|
2640 | UInt uiCorBLAddr = ( uiPdmMergePos < 5 ? 5 : 4 ); |
---|
2641 | UInt uiPdmAddr = uiPdmMergePos; |
---|
2642 | |
---|
2643 | bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
2644 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui ) |
---|
2645 | { |
---|
2646 | abCandIsInter[ui] = false; |
---|
2647 | } |
---|
2648 | |
---|
2649 | //===== left ===== |
---|
2650 | UInt uiLeftPartIdx = 0; |
---|
2651 | TComDataCU* pcCULeft = 0; |
---|
2652 | pcCULeft = getPULeft( uiLeftPartIdx, uiAbsPartAddr ); |
---|
2653 | if( avoidMergeCandidate( uiAbsPartIdx, uiPUIdx, uiDepth, pcCULeft, uiLeftPartIdx ) ) |
---|
2654 | { |
---|
2655 | pcCULeft = NULL; |
---|
2656 | } |
---|
2657 | if( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx ) ) |
---|
2658 | { |
---|
2659 | abCandIsInter[uiLeftAddr] = true; |
---|
2660 | puiNeighbourCandIdx[uiLeftAddr] = uiLeftAddr+1; |
---|
2661 | } |
---|
2662 | if( abCandIsInter[uiLeftAddr] ) |
---|
2663 | { |
---|
2664 | // get Inter Dir |
---|
2665 | puhInterDirNeighbours[uiLeftAddr] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
2666 | // get Mv from Left |
---|
2667 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[uiLeftAddr<<1] ); |
---|
2668 | if ( getSlice()->isInterB() ) |
---|
2669 | { |
---|
2670 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(uiLeftAddr<<1)+1] ); |
---|
2671 | } |
---|
2672 | } |
---|
2673 | |
---|
2674 | |
---|
2675 | //===== top ===== |
---|
2676 | UInt uiAbovePartIdx = 0; |
---|
2677 | TComDataCU* pcCUAbove = 0; |
---|
2678 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiAbsPartAddr ); |
---|
2679 | if( avoidMergeCandidate( uiAbsPartIdx, uiPUIdx, uiDepth, pcCUAbove, uiAbovePartIdx ) ) |
---|
2680 | { |
---|
2681 | pcCUAbove = NULL; |
---|
2682 | } |
---|
2683 | if ( pcCUAbove && !pcCUAbove->isIntra( uiAbovePartIdx ) ) |
---|
2684 | { |
---|
2685 | abCandIsInter[uiAboveAddr] = true; |
---|
2686 | puiNeighbourCandIdx[uiAboveAddr] = uiAboveAddr+1; |
---|
2687 | } |
---|
2688 | if ( abCandIsInter[uiAboveAddr] ) |
---|
2689 | { |
---|
2690 | // get Inter Dir |
---|
2691 | puhInterDirNeighbours[uiAboveAddr] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
2692 | // get Mv from Above |
---|
2693 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[uiAboveAddr<<1] ); |
---|
2694 | if ( getSlice()->isInterB() ) |
---|
2695 | { |
---|
2696 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(uiAboveAddr<<1)+1] ); |
---|
2697 | } |
---|
2698 | } |
---|
2699 | |
---|
2700 | |
---|
2701 | //===== colocated ===== |
---|
2702 | #if MRG_NEIGH_COL |
---|
2703 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2704 | Int iRefIdxSkip[2] = {-1, -1}; |
---|
2705 | TComDataCU* pcTmpCU = NULL; |
---|
2706 | UInt uiIdxblk; |
---|
2707 | Int iRefIdxLeft[2] = {-1, -1}; |
---|
2708 | Int iRefIdxAbove[2] = {-1, -1}; |
---|
2709 | Int iRefIdxCor[2] = {-1, -1}; |
---|
2710 | |
---|
2711 | UInt uiPUIdxLT = 0; |
---|
2712 | UInt uiPUIdxRT = 0; |
---|
2713 | UInt uiPUIdxLB = 0; |
---|
2714 | PartSize cCurPS = m_pePartSize[uiAbsPartIdx]; |
---|
2715 | deriveLeftRightTopIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPUIdxLT, uiPUIdxRT ); |
---|
2716 | deriveLeftBottomIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPUIdxLB ); |
---|
2717 | |
---|
2718 | for (int i=0; i<2; i++) |
---|
2719 | { |
---|
2720 | RefPicList eRefPicList = ( i==1 ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2721 | |
---|
2722 | pcTmpCU = getPULeft(uiIdxblk, uiPUIdxLT); |
---|
2723 | iRefIdxLeft[i] = (pcTmpCU != NULL) ? pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdxblk) : -1; |
---|
2724 | pcTmpCU = getPUAbove(uiIdxblk, uiPUIdxLT); |
---|
2725 | iRefIdxAbove[i] = (pcTmpCU != NULL) ? pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdxblk) : -1; |
---|
2726 | pcTmpCU = getPUAboveRight( uiIdxblk, uiPUIdxRT ); |
---|
2727 | if (pcTmpCU == NULL) |
---|
2728 | { |
---|
2729 | pcTmpCU = getPUBelowLeft( uiIdxblk, uiPUIdxLB ); |
---|
2730 | } |
---|
2731 | if (pcTmpCU == NULL) |
---|
2732 | { |
---|
2733 | pcTmpCU = getPUAboveLeft( uiIdxblk, uiPUIdxLT ); |
---|
2734 | } |
---|
2735 | iRefIdxCor[i] = (pcTmpCU != NULL) ? pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdxblk) : -1; |
---|
2736 | |
---|
2737 | if (iRefIdxLeft[i] == iRefIdxAbove[i] && iRefIdxAbove[i] == iRefIdxCor[i]) |
---|
2738 | { |
---|
2739 | iRefIdxSkip[i] = (iRefIdxLeft[i] == -1) ? 0 : iRefIdxLeft[i]; |
---|
2740 | } |
---|
2741 | else if (iRefIdxLeft[i] == iRefIdxAbove[i]) |
---|
2742 | { |
---|
2743 | iRefIdxSkip[i] = (iRefIdxLeft[i] == -1) ? iRefIdxCor[i] : iRefIdxLeft[i]; |
---|
2744 | } |
---|
2745 | else if (iRefIdxAbove[i] == iRefIdxCor[i]) |
---|
2746 | { |
---|
2747 | iRefIdxSkip[i] = (iRefIdxAbove[i] == -1) ? iRefIdxLeft[i] : iRefIdxAbove[i]; |
---|
2748 | } |
---|
2749 | else if (iRefIdxLeft[i] == iRefIdxCor[i]) |
---|
2750 | { |
---|
2751 | iRefIdxSkip[i] = (iRefIdxLeft[i] == -1) ? iRefIdxAbove[i] : iRefIdxLeft[i]; |
---|
2752 | } |
---|
2753 | else if (iRefIdxLeft[i] == -1) |
---|
2754 | { |
---|
2755 | iRefIdxSkip[i] = min(iRefIdxAbove[i], iRefIdxCor[i]); |
---|
2756 | } |
---|
2757 | else if (iRefIdxAbove[i] == -1) |
---|
2758 | { |
---|
2759 | iRefIdxSkip[i] = min(iRefIdxLeft[i], iRefIdxCor[i]); |
---|
2760 | } |
---|
2761 | else if (iRefIdxCor[i] == -1) |
---|
2762 | { |
---|
2763 | iRefIdxSkip[i] = min(iRefIdxLeft[i], iRefIdxAbove[i]); |
---|
2764 | } |
---|
2765 | else |
---|
2766 | { |
---|
2767 | iRefIdxSkip[i] = min( min(iRefIdxLeft[i], iRefIdxAbove[i]), iRefIdxCor[i]); |
---|
2768 | } |
---|
2769 | } |
---|
2770 | #endif |
---|
2771 | #if MTK_TMVP_H_MRG |
---|
2772 | //>> MTK colocated-RightBottom |
---|
2773 | UInt uiPartIdxRB; |
---|
2774 | Int uiLCUIdx = getAddr(); |
---|
2775 | PartSize eCUMode = m_pePartSize[0]; |
---|
2776 | |
---|
2777 | deriveRightBottomIdx( eCUMode, uiPUIdx, uiPartIdxRB ); |
---|
2778 | |
---|
2779 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
2780 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
2781 | |
---|
2782 | TComMv cColMv; |
---|
2783 | Int iRefIdx; |
---|
2784 | |
---|
2785 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getWidth() ) // image boundary check |
---|
2786 | { |
---|
2787 | uiLCUIdx = -1; |
---|
2788 | } |
---|
2789 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getHeight() ) |
---|
2790 | { |
---|
2791 | uiLCUIdx = -1; |
---|
2792 | } |
---|
2793 | else |
---|
2794 | { |
---|
2795 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
2796 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
2797 | { |
---|
2798 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
2799 | uiLCUIdx = getAddr(); |
---|
2800 | } |
---|
2801 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
2802 | { |
---|
2803 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
2804 | uiLCUIdx = getAddr() + m_pcPic->getFrameWidthInCU(); |
---|
2805 | } |
---|
2806 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
2807 | { |
---|
2808 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
2809 | uiLCUIdx = getAddr() + 1; |
---|
2810 | } |
---|
2811 | else //is the right bottom corner of LCU |
---|
2812 | { |
---|
2813 | uiAbsPartAddr = 0; |
---|
2814 | uiLCUIdx = getAddr() + m_pcPic->getFrameWidthInCU() + 1; |
---|
2815 | } |
---|
2816 | } |
---|
2817 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2818 | iRefIdx = iRefIdxSkip[0]; |
---|
2819 | #else |
---|
2820 | iRefIdx = 0; // scaled to 1st ref pic for List0/List1 |
---|
2821 | #endif |
---|
2822 | |
---|
2823 | #if FT_TCTR_MRG |
---|
2824 | Bool bExistMV = false; |
---|
2825 | UInt uiPartIdxCenter; |
---|
2826 | UInt uiCurLCUIdx = getAddr(); |
---|
2827 | xDeriveCenterIdx( eCUMode, uiPUIdx, uiPartIdxCenter ); |
---|
2828 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
2829 | if( bExistMV == false ) |
---|
2830 | { |
---|
2831 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
2832 | } |
---|
2833 | if( bExistMV ) |
---|
2834 | #else |
---|
2835 | if (uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ) ) |
---|
2836 | #endif |
---|
2837 | { |
---|
2838 | abCandIsInter[uiColocAddr] = true; |
---|
2839 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2840 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cColMv, iRefIdx ); |
---|
2841 | #else |
---|
2842 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cColMv, 0 ); |
---|
2843 | #endif |
---|
2844 | puiNeighbourCandIdx[uiColocAddr] = uiColocAddr+1; |
---|
2845 | |
---|
2846 | if ( getSlice()->isInterB() ) |
---|
2847 | { |
---|
2848 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2849 | iRefIdx = iRefIdxSkip[1]; |
---|
2850 | #endif |
---|
2851 | #if FT_TCTR_MRG |
---|
2852 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
2853 | if( bExistMV == false ) |
---|
2854 | { |
---|
2855 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
2856 | } |
---|
2857 | if( bExistMV ) |
---|
2858 | #else |
---|
2859 | if (xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx) ) |
---|
2860 | #endif |
---|
2861 | { |
---|
2862 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2863 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cColMv, iRefIdx ); |
---|
2864 | #else |
---|
2865 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cColMv, 0 ); |
---|
2866 | #endif |
---|
2867 | puhInterDirNeighbours[uiColocAddr] = 3; |
---|
2868 | } |
---|
2869 | else |
---|
2870 | { |
---|
2871 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
2872 | } |
---|
2873 | } |
---|
2874 | else |
---|
2875 | { |
---|
2876 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
2877 | } |
---|
2878 | } |
---|
2879 | #else //MTK_TMVP_H_MRG |
---|
2880 | #if FT_TCTR_MRG |
---|
2881 | TComMv cMvTCenter[2]; |
---|
2882 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2883 | Int iRefIdx = iRefIdxSkip[0]; |
---|
2884 | if (xGetCenterCol( uiPUIdx, REF_PIC_LIST_0, iRefIdx, &cMvTCenter[0] )) |
---|
2885 | #else |
---|
2886 | if (xGetCenterCol( uiPUIdx, REF_PIC_LIST_0, 0, &cMvTCenter[0] )) |
---|
2887 | #endif |
---|
2888 | { |
---|
2889 | abCandIsInter[uiColocAddr] = true; |
---|
2890 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2891 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cMvTCenter[0], iRefIdx ); |
---|
2892 | #else |
---|
2893 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cMvTCenter[0], 0 ); |
---|
2894 | #endif |
---|
2895 | puiNeighbourCandIdx[uiColocAddr] = uiIdx; |
---|
2896 | |
---|
2897 | if ( getSlice()->isInterB() ) |
---|
2898 | { |
---|
2899 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2900 | if ( xGetCenterCol( uiPUIdx, REF_PIC_LIST_1, iRefIdx, &cMvTCenter[1] ) ) |
---|
2901 | #else |
---|
2902 | if ( xGetCenterCol( uiPUIdx, REF_PIC_LIST_1, 0, &cMvTCenter[1] ) ) |
---|
2903 | #endif |
---|
2904 | { |
---|
2905 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2906 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cMvTCenter[1], iRefIdx ); |
---|
2907 | #else |
---|
2908 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cMvTCenter[1], 0 ); |
---|
2909 | #endif |
---|
2910 | puhInterDirNeighbours[uiColocAddr] = 3; |
---|
2911 | } |
---|
2912 | else |
---|
2913 | { |
---|
2914 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
2915 | } |
---|
2916 | } |
---|
2917 | else |
---|
2918 | { |
---|
2919 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
2920 | } |
---|
2921 | } |
---|
2922 | #else //FT_TCTR_MRG |
---|
2923 | UInt uiColDir = ( m_pcSlice->isInterB()? m_pcSlice->getColDir() : 0 ); |
---|
2924 | TComDataCU* pcCUColocated = getCUColocated( RefPicList( uiColDir ) ); |
---|
2925 | RefPicList eColRefPicList = ( m_pcSlice->isInterB()? RefPicList( 1-uiColDir ) : REF_PIC_LIST_0 ); |
---|
2926 | #if PANASONIC_MERGETEMPORALEXT |
---|
2927 | RefPicList eColRefPicList2 = (m_pcSlice->isInterB()? RefPicList(uiColDir) : REF_PIC_LIST_0); |
---|
2928 | #endif |
---|
2929 | if( pcCUColocated && !pcCUColocated->isIntra( uiAbsPartAddr ) && |
---|
2930 | pcCUColocated->getCUMvField( eColRefPicList )->getRefIdx( uiAbsPartAddr ) >= 0 ) |
---|
2931 | { |
---|
2932 | Int iColPOC = pcCUColocated->getSlice()->getPOC(); |
---|
2933 | Int iColRefPOC = pcCUColocated->getSlice()->getRefPOC( eColRefPicList, pcCUColocated->getCUMvField( eColRefPicList )->getRefIdx( uiAbsPartAddr ) ); |
---|
2934 | TComMv cColMv = pcCUColocated->getCUMvField( eColRefPicList )->getMv( uiAbsPartAddr ); |
---|
2935 | |
---|
2936 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
2937 | Int iCurrRefPOC = m_pcSlice->getRefPic( REF_PIC_LIST_0, 0 )->getPOC(); |
---|
2938 | |
---|
2939 | TComMv cMv; |
---|
2940 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC ); |
---|
2941 | |
---|
2942 | if( iScale == 1024 ) |
---|
2943 | { |
---|
2944 | cMv = cColMv; |
---|
2945 | } |
---|
2946 | else |
---|
2947 | { |
---|
2948 | cMv = cColMv.scaleMv( iScale ); |
---|
2949 | } |
---|
2950 | clipMv( cMv ); |
---|
2951 | abCandIsInter[uiColocAddr] = true; |
---|
2952 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cMv, 0 ); |
---|
2953 | puiNeighbourCandIdx[uiColocAddr] = uiIdx; |
---|
2954 | if ( getSlice()->isInterB() ) |
---|
2955 | { |
---|
2956 | iCurrRefPOC = m_pcSlice->getRefPic( REF_PIC_LIST_1, 0 )->getPOC(); |
---|
2957 | TComMv cMvB; |
---|
2958 | iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC ); |
---|
2959 | if( iScale == 1024 ) |
---|
2960 | { |
---|
2961 | cMvB = cColMv; |
---|
2962 | } |
---|
2963 | else |
---|
2964 | { |
---|
2965 | cMvB = cColMv.scaleMv( iScale ); |
---|
2966 | } |
---|
2967 | clipMv( cMvB ); |
---|
2968 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cMvB, 0 ); |
---|
2969 | puhInterDirNeighbours[uiColocAddr] = 3; |
---|
2970 | } |
---|
2971 | else |
---|
2972 | { |
---|
2973 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
2974 | } |
---|
2975 | } |
---|
2976 | #if PANASONIC_MERGETEMPORALEXT |
---|
2977 | else if( pcCUColocated && !pcCUColocated->isIntra( uiAbsPartAddr ) && |
---|
2978 | pcCUColocated->getCUMvField( eColRefPicList2 )->getRefIdx( uiAbsPartAddr ) >= 0 ) |
---|
2979 | { |
---|
2980 | Int iColPOC = pcCUColocated->getSlice()->getPOC(); |
---|
2981 | Int iColRefPOC = pcCUColocated->getSlice()->getRefPOC( eColRefPicList2, pcCUColocated->getCUMvField( eColRefPicList2 )->getRefIdx( uiAbsPartAddr ) ); |
---|
2982 | TComMv cColMv = pcCUColocated->getCUMvField( eColRefPicList2 )->getMv( uiAbsPartAddr ); |
---|
2983 | |
---|
2984 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
2985 | Int iCurrRefPOC = m_pcSlice->getRefPic( REF_PIC_LIST_0, 0 )->getPOC(); |
---|
2986 | |
---|
2987 | TComMv cMv; |
---|
2988 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC ); |
---|
2989 | |
---|
2990 | if( iScale == 1024 ) |
---|
2991 | { |
---|
2992 | cMv = cColMv; |
---|
2993 | } |
---|
2994 | else |
---|
2995 | { |
---|
2996 | cMv = cColMv.scaleMv( iScale ); |
---|
2997 | } |
---|
2998 | clipMv( cMv ); |
---|
2999 | abCandIsInter[uiColocAddr] = true; |
---|
3000 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cMv, 0 ); |
---|
3001 | puiNeighbourCandIdx[uiColocAddr] = uiIdx; |
---|
3002 | if ( getSlice()->isInterB() ) |
---|
3003 | { |
---|
3004 | iCurrRefPOC = m_pcSlice->getRefPic( REF_PIC_LIST_1, 0 )->getPOC(); |
---|
3005 | TComMv cMvB; |
---|
3006 | iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC ); |
---|
3007 | if( iScale == 1024 ) |
---|
3008 | { |
---|
3009 | cMvB = cColMv; |
---|
3010 | } |
---|
3011 | else |
---|
3012 | { |
---|
3013 | cMvB = cColMv.scaleMv( iScale ); |
---|
3014 | } |
---|
3015 | clipMv( cMvB ); |
---|
3016 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cMvB, 0 ); |
---|
3017 | puhInterDirNeighbours[uiColocAddr] = 3; |
---|
3018 | } |
---|
3019 | else |
---|
3020 | { |
---|
3021 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
3022 | } |
---|
3023 | } |
---|
3024 | #endif // PANASONIC_MERGETEMPORALEXT |
---|
3025 | #endif // FT_TCTR_MRG |
---|
3026 | #endif // MTK_TMVP_H_MRG |
---|
3027 | #endif // MRG_NEIGH_COL |
---|
3028 | |
---|
3029 | |
---|
3030 | //===== corners ===== |
---|
3031 | #if MRG_NEIGH_COL && PANASONIC_MRG_TMVP_REFIDX |
---|
3032 | uiPUIdxLT = 0; |
---|
3033 | uiPUIdxRT = 0; |
---|
3034 | uiPUIdxLB = 0; |
---|
3035 | cCurPS = m_pePartSize[uiAbsPartIdx]; |
---|
3036 | #else |
---|
3037 | UInt uiPUIdxLT = 0; |
---|
3038 | UInt uiPUIdxRT = 0; |
---|
3039 | UInt uiPUIdxLB = 0; |
---|
3040 | PartSize cCurPS = m_pePartSize[uiAbsPartIdx]; |
---|
3041 | #endif |
---|
3042 | |
---|
3043 | deriveLeftRightTopIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPUIdxLT, uiPUIdxRT ); |
---|
3044 | deriveLeftBottomIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPUIdxLB ); |
---|
3045 | |
---|
3046 | TComDataCU* pcCorner = 0; |
---|
3047 | UInt uiCornerIdx = 0; |
---|
3048 | |
---|
3049 | Bool bRTCornerCand = false; |
---|
3050 | Bool bLBCornerCand = false; |
---|
3051 | for( UInt uiIter = 0; uiIter < 2; uiIter++ ) |
---|
3052 | { |
---|
3053 | if( !bRTCornerCand ) |
---|
3054 | { |
---|
3055 | pcCorner = getPUAboveRight( uiCornerIdx, uiPUIdxRT ); |
---|
3056 | xCheckCornerCand( pcCorner, uiCornerIdx, uiIter, bRTCornerCand ); |
---|
3057 | if( avoidMergeCandidate( uiAbsPartIdx, uiPUIdx, uiDepth, pcCorner, uiCornerIdx ) ) |
---|
3058 | { |
---|
3059 | bRTCornerCand = false; |
---|
3060 | } |
---|
3061 | if( bRTCornerCand ) |
---|
3062 | { |
---|
3063 | abCandIsInter[uiCorRTAddr] = true; |
---|
3064 | puiNeighbourCandIdx[uiCorRTAddr] = uiCorRTAddr+1; |
---|
3065 | // get Inter Dir |
---|
3066 | puhInterDirNeighbours[uiCorRTAddr] = pcCorner->getInterDir( uiCornerIdx ); |
---|
3067 | // get Mv from Left |
---|
3068 | pcCorner->getMvField( pcCorner, uiCornerIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[uiCorRTAddr << 1] ); |
---|
3069 | if ( getSlice()->isInterB() ) |
---|
3070 | { |
---|
3071 | pcCorner->getMvField( pcCorner, uiCornerIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[( uiCorRTAddr << 1 ) + 1] ); |
---|
3072 | } |
---|
3073 | } |
---|
3074 | } |
---|
3075 | if( !bLBCornerCand ) |
---|
3076 | { |
---|
3077 | pcCorner = getPUBelowLeft( uiCornerIdx, uiPUIdxLB ); |
---|
3078 | xCheckCornerCand( pcCorner, uiCornerIdx, uiIter, bLBCornerCand ); |
---|
3079 | if( avoidMergeCandidate( uiAbsPartIdx, uiPUIdx, uiDepth, pcCorner, uiCornerIdx ) ) |
---|
3080 | { |
---|
3081 | bLBCornerCand = false; |
---|
3082 | } |
---|
3083 | if( bLBCornerCand ) |
---|
3084 | { |
---|
3085 | uiCorBLAddr = 4; |
---|
3086 | abCandIsInter[uiCorBLAddr] = true; |
---|
3087 | puiNeighbourCandIdx[uiCorBLAddr] = uiCorBLAddr+1; |
---|
3088 | // get Inter Dir |
---|
3089 | puhInterDirNeighbours[uiCorBLAddr] = pcCorner->getInterDir( uiCornerIdx ); |
---|
3090 | // get Mv from Left |
---|
3091 | pcCorner->getMvField( pcCorner, uiCornerIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[uiCorBLAddr << 1] ); |
---|
3092 | if ( getSlice()->isInterB() ) |
---|
3093 | { |
---|
3094 | pcCorner->getMvField( pcCorner, uiCornerIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[( uiCorBLAddr << 1 ) + 1] ); |
---|
3095 | } |
---|
3096 | } |
---|
3097 | } |
---|
3098 | } |
---|
3099 | |
---|
3100 | |
---|
3101 | //===== add merge with predicted depth maps ===== |
---|
3102 | TComMv acPdmMv [2]; |
---|
3103 | Int aiPdmRefIdx [2] = {-1,-1}; |
---|
3104 | Int iPdmInterDir = getPdmMergeCandidate( uiPUIdx, aiPdmRefIdx, acPdmMv ); |
---|
3105 | if( iPdmInterDir ) |
---|
3106 | { |
---|
3107 | if( avoidMergeCandidate( uiAbsPartIdx, uiPUIdx, uiDepth, iPdmInterDir, aiPdmRefIdx, acPdmMv ) ) |
---|
3108 | { |
---|
3109 | iPdmInterDir = 0; |
---|
3110 | } |
---|
3111 | } |
---|
3112 | if( iPdmInterDir ) |
---|
3113 | { |
---|
3114 | abCandIsInter [ uiPdmAddr ] = true; |
---|
3115 | puiNeighbourCandIdx [ uiPdmAddr ] = uiPdmAddr + 1; |
---|
3116 | puhInterDirNeighbours[ uiPdmAddr ] = iPdmInterDir; |
---|
3117 | if( ( iPdmInterDir & 1 ) == 1 ) |
---|
3118 | { |
---|
3119 | pcMvFieldNeighbours[ uiPdmAddr<<1 ].setMvField( acPdmMv[ 0 ], aiPdmRefIdx[ 0 ] ); |
---|
3120 | } |
---|
3121 | if( ( iPdmInterDir & 2 ) == 2 ) |
---|
3122 | { |
---|
3123 | pcMvFieldNeighbours[(uiPdmAddr<<1)+1 ].setMvField( acPdmMv[ 1 ], aiPdmRefIdx[ 1 ] ); |
---|
3124 | } |
---|
3125 | } |
---|
3126 | |
---|
3127 | |
---|
3128 | //===== remove duplicates ===== |
---|
3129 | for( UInt uiOuter = 0; uiOuter < MRG_MAX_NUM_CANDS; uiOuter++ ) |
---|
3130 | { |
---|
3131 | if( abCandIsInter[ uiOuter ] && ( puiNeighbourCandIdx[uiOuter] == uiOuter + 1 ) ) |
---|
3132 | { |
---|
3133 | for( UInt uiIter = uiOuter + 1; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
3134 | { |
---|
3135 | if( abCandIsInter[ uiIter ] ) |
---|
3136 | { |
---|
3137 | UInt uiMvFieldNeighIdxCurr = uiOuter << 1; |
---|
3138 | UInt uiMvFieldNeighIdxComp = uiIter << 1; |
---|
3139 | if( getSlice()->isInterB() ) |
---|
3140 | { |
---|
3141 | if( puhInterDirNeighbours[ uiOuter ] == 3 ) |
---|
3142 | { |
---|
3143 | if( pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getRefIdx() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getRefIdx() && pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr + 1 ].getRefIdx() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp + 1 ].getRefIdx() && |
---|
3144 | pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getMv() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getMv() && pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr + 1 ].getMv() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp + 1 ].getMv() && |
---|
3145 | puhInterDirNeighbours[ uiOuter ] == puhInterDirNeighbours[ uiIter ] ) |
---|
3146 | { |
---|
3147 | puiNeighbourCandIdx[ uiIter ] = puiNeighbourCandIdx[ uiOuter ]; |
---|
3148 | abCandIsInter[ uiIter ] = false; |
---|
3149 | } |
---|
3150 | } |
---|
3151 | else if( puhInterDirNeighbours[ uiOuter ] == 2 ) |
---|
3152 | { |
---|
3153 | if( pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr + 1 ].getRefIdx() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp + 1 ].getRefIdx() && |
---|
3154 | pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr + 1 ].getMv() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp + 1 ].getMv() && |
---|
3155 | puhInterDirNeighbours[ uiOuter ] == puhInterDirNeighbours[ uiIter ] ) |
---|
3156 | { |
---|
3157 | puiNeighbourCandIdx[ uiIter ] = puiNeighbourCandIdx[ uiOuter ]; |
---|
3158 | abCandIsInter[ uiIter ] = false; |
---|
3159 | } |
---|
3160 | } |
---|
3161 | else |
---|
3162 | { |
---|
3163 | if( pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getRefIdx() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getRefIdx() && |
---|
3164 | pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getMv() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getMv() && |
---|
3165 | puhInterDirNeighbours[ uiOuter ] == puhInterDirNeighbours[ uiIter ] ) |
---|
3166 | { |
---|
3167 | puiNeighbourCandIdx[ uiIter ] = puiNeighbourCandIdx[ uiOuter ]; |
---|
3168 | abCandIsInter[ uiIter ] = false; |
---|
3169 | } |
---|
3170 | } |
---|
3171 | } |
---|
3172 | else |
---|
3173 | { |
---|
3174 | if( pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getRefIdx() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getRefIdx() && |
---|
3175 | pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getMv() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getMv() ) |
---|
3176 | { |
---|
3177 | assert( puhInterDirNeighbours[ uiOuter ] == puhInterDirNeighbours[ uiIter ] ); |
---|
3178 | puiNeighbourCandIdx[ uiIter ] = puiNeighbourCandIdx[ uiOuter ]; |
---|
3179 | abCandIsInter[ uiIter ] = false; |
---|
3180 | } |
---|
3181 | } |
---|
3182 | } |
---|
3183 | } |
---|
3184 | } |
---|
3185 | } |
---|
3186 | #if AVOID_ZERO_MERGE_CANDIDATE |
---|
3187 | // if all merge candidate |
---|
3188 | int i; |
---|
3189 | for ( i=0; i<MRG_MAX_NUM_CANDS; i++ ) |
---|
3190 | { |
---|
3191 | if ( abCandIsInter[i] ) |
---|
3192 | { |
---|
3193 | break; |
---|
3194 | } |
---|
3195 | } |
---|
3196 | if ( i==MRG_MAX_NUM_CANDS ) // no merge candidate |
---|
3197 | { |
---|
3198 | abCandIsInter[0] = true; |
---|
3199 | puiNeighbourCandIdx[0] = 1; |
---|
3200 | puhInterDirNeighbours[0] = 1; |
---|
3201 | pcMvFieldNeighbours[0].setMvField( TComMv(0, 0), 0 ); |
---|
3202 | if ( getSlice()->isInterB() ) |
---|
3203 | { |
---|
3204 | puhInterDirNeighbours[0] = 3; |
---|
3205 | pcMvFieldNeighbours[1].setMvField( TComMv(0, 0), 0 ); |
---|
3206 | } |
---|
3207 | } |
---|
3208 | #endif |
---|
3209 | } |
---|
3210 | |
---|
3211 | Void TComDataCU::xCheckCornerCand( TComDataCU* pcCorner, UInt uiCornerPUIdx, UInt uiIter, Bool& rbValidCand ) |
---|
3212 | { |
---|
3213 | if( uiIter == 0 ) |
---|
3214 | { |
---|
3215 | if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) ) |
---|
3216 | { |
---|
3217 | rbValidCand = true; |
---|
3218 | if( getSlice()->isInterB() ) |
---|
3219 | { |
---|
3220 | if ( pcCorner->getInterDir( uiCornerPUIdx ) == 1 ) |
---|
3221 | { |
---|
3222 | if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) != 0 ) |
---|
3223 | { |
---|
3224 | rbValidCand = false; |
---|
3225 | } |
---|
3226 | } |
---|
3227 | else if ( pcCorner->getInterDir( uiCornerPUIdx ) == 2 ) |
---|
3228 | { |
---|
3229 | if( pcCorner->getCUMvField(REF_PIC_LIST_1)->getRefIdx( uiCornerPUIdx ) != 0 ) |
---|
3230 | { |
---|
3231 | rbValidCand = false; |
---|
3232 | } |
---|
3233 | } |
---|
3234 | else |
---|
3235 | { |
---|
3236 | if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) != 0 || pcCorner->getCUMvField(REF_PIC_LIST_1)->getRefIdx( uiCornerPUIdx ) != 0 ) |
---|
3237 | { |
---|
3238 | rbValidCand = false; |
---|
3239 | } |
---|
3240 | } |
---|
3241 | } |
---|
3242 | else if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) != 0 ) |
---|
3243 | { |
---|
3244 | rbValidCand = false; |
---|
3245 | } |
---|
3246 | } |
---|
3247 | } |
---|
3248 | else |
---|
3249 | { |
---|
3250 | if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) ) |
---|
3251 | { |
---|
3252 | rbValidCand = true; |
---|
3253 | if( getSlice()->isInterB() ) |
---|
3254 | { |
---|
3255 | if ( pcCorner->getInterDir( uiCornerPUIdx ) == 1 ) |
---|
3256 | { |
---|
3257 | if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) < 0 ) |
---|
3258 | { |
---|
3259 | rbValidCand = false; |
---|
3260 | } |
---|
3261 | } |
---|
3262 | else if ( pcCorner->getInterDir( uiCornerPUIdx ) == 2 ) |
---|
3263 | { |
---|
3264 | if( pcCorner->getCUMvField(REF_PIC_LIST_1)->getRefIdx( uiCornerPUIdx ) < 0 ) |
---|
3265 | { |
---|
3266 | rbValidCand = false; |
---|
3267 | } |
---|
3268 | } |
---|
3269 | else |
---|
3270 | { |
---|
3271 | if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) < 0 || pcCorner->getCUMvField(REF_PIC_LIST_1)->getRefIdx( uiCornerPUIdx ) < 0 ) |
---|
3272 | { |
---|
3273 | rbValidCand = false; |
---|
3274 | } |
---|
3275 | } |
---|
3276 | } |
---|
3277 | else if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) < 0 ) |
---|
3278 | { |
---|
3279 | rbValidCand = false; |
---|
3280 | } |
---|
3281 | } |
---|
3282 | } |
---|
3283 | } |
---|
3284 | |
---|
3285 | Void TComDataCU::setNeighbourCandIdxSubParts( UInt uiCandIdx, UChar uhNumCands, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth ) |
---|
3286 | { |
---|
3287 | setSubPartUChar( uhNumCands, m_apuhNeighbourCandIdx[uiCandIdx], uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
3288 | } |
---|
3289 | |
---|
3290 | AMVP_MODE TComDataCU::getAMVPMode(UInt uiIdx) |
---|
3291 | { |
---|
3292 | return m_pcSlice->getSPS()->getAMVPMode(m_puhDepth[uiIdx]); |
---|
3293 | } |
---|
3294 | |
---|
3295 | /** Constructs a list of candidates for AMVP |
---|
3296 | * \param uiPartIdx |
---|
3297 | * \param uiPartAddr |
---|
3298 | * \param eRefPicList |
---|
3299 | * \param iRefIdx |
---|
3300 | * \param pInfo |
---|
3301 | * \param puiNeighbourCandIdx |
---|
3302 | * \returns Void |
---|
3303 | */ |
---|
3304 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
---|
3305 | { |
---|
3306 | PartSize eCUMode = m_pePartSize[0]; |
---|
3307 | |
---|
3308 | TComMv cMvPred; |
---|
3309 | |
---|
3310 | pInfo->iN = 0; |
---|
3311 | #if !DCM_SIMPLIFIED_MVP |
---|
3312 | UInt uiIdx; |
---|
3313 | #endif |
---|
3314 | |
---|
3315 | if (iRefIdx < 0) |
---|
3316 | { |
---|
3317 | return; |
---|
3318 | } |
---|
3319 | |
---|
3320 | Int iLeftIdx = -1; |
---|
3321 | |
---|
3322 | #if ( PDM_AMVP_POS == 0 ) |
---|
3323 | // get inter-view mv predictor (at position 0) |
---|
3324 | TComMv cPdmMvPred; |
---|
3325 | if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) ) |
---|
3326 | { |
---|
3327 | clipMv( cPdmMvPred ); |
---|
3328 | pInfo->m_acMvCand[ pInfo->iN++ ] = cPdmMvPred; |
---|
3329 | } |
---|
3330 | #endif |
---|
3331 | |
---|
3332 | #if !DCM_SIMPLIFIED_MVP |
---|
3333 | pInfo->m_acMvCand[pInfo->iN++] = cMvPred; //dummy mv |
---|
3334 | #endif |
---|
3335 | |
---|
3336 | //-- Get Spatial MV |
---|
3337 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
3338 | #if (DCM_SIMPLIFIED_MVP && !TI_AMVP_SMVP_SIMPLIFIED) || (!DCM_SIMPLIFIED_MVP) || MTK_TMVP_H_AMVP |
---|
3339 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
3340 | #endif |
---|
3341 | Bool bAdded = false; |
---|
3342 | #if !DCM_SIMPLIFIED_MVP |
---|
3343 | Int iLeftMvIdx = -1; |
---|
3344 | Int iAboveMvIdx = -1; |
---|
3345 | Int iCornerMvIdx = -1; |
---|
3346 | #endif |
---|
3347 | |
---|
3348 | deriveLeftRightTopIdx( eCUMode, uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
3349 | deriveLeftBottomIdx( eCUMode, uiPartIdx, uiPartIdxLB ); |
---|
3350 | |
---|
3351 | #if DCM_SIMPLIFIED_MVP |
---|
3352 | // Left predictor search |
---|
3353 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
3354 | #if TI_AMVP_SMVP_SIMPLIFIED |
---|
3355 | if (!bAdded) |
---|
3356 | { |
---|
3357 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
3358 | } |
---|
3359 | #else |
---|
3360 | for ( Int idx = (Int)g_auiZscanToRaster[uiPartIdxLB]; !bAdded && idx >= (Int)g_auiZscanToRaster[uiPartIdxLT]; idx-= uiNumPartInCUWidth ) |
---|
3361 | { |
---|
3362 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[idx], MD_LEFT ); |
---|
3363 | } |
---|
3364 | #endif |
---|
3365 | |
---|
3366 | #if MTK_AMVP_SMVP_DERIVATION |
---|
3367 | if(!bAdded) |
---|
3368 | { |
---|
3369 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
3370 | #if TI_AMVP_SMVP_SIMPLIFIED |
---|
3371 | if (!bAdded) |
---|
3372 | { |
---|
3373 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
3374 | } |
---|
3375 | #else |
---|
3376 | for ( Int idx = (Int)g_auiZscanToRaster[uiPartIdxLB]; !bAdded && idx >= (Int)g_auiZscanToRaster[uiPartIdxLT]; idx-= uiNumPartInCUWidth ) |
---|
3377 | { |
---|
3378 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[idx], MD_LEFT ); |
---|
3379 | } |
---|
3380 | #endif |
---|
3381 | } |
---|
3382 | #endif |
---|
3383 | if( bAdded ) |
---|
3384 | { |
---|
3385 | iLeftIdx = pInfo->iN - 1; |
---|
3386 | } |
---|
3387 | |
---|
3388 | |
---|
3389 | |
---|
3390 | #if ( PDM_AMVP_POS == 1 ) |
---|
3391 | // get inter-view mv predictor (at position 1) |
---|
3392 | TComMv cPdmMvPred; |
---|
3393 | if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) ) |
---|
3394 | { |
---|
3395 | clipMv( cPdmMvPred ); |
---|
3396 | pInfo->m_acMvCand[ pInfo->iN++ ] = cPdmMvPred; |
---|
3397 | } |
---|
3398 | #endif |
---|
3399 | |
---|
3400 | |
---|
3401 | |
---|
3402 | // Above predictor search |
---|
3403 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
3404 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3405 | { |
---|
3406 | pInfo->iN--; //remove duplicate entries |
---|
3407 | bAdded = false; |
---|
3408 | } |
---|
3409 | #if TI_AMVP_SMVP_SIMPLIFIED |
---|
3410 | if (!bAdded) |
---|
3411 | { |
---|
3412 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
3413 | } |
---|
3414 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3415 | { |
---|
3416 | pInfo->iN--; //remove duplicate entries |
---|
3417 | bAdded = false; |
---|
3418 | } |
---|
3419 | #else |
---|
3420 | for ( Int idx = (Int)g_auiZscanToRaster[uiPartIdxRT]; !bAdded && idx >= (Int)g_auiZscanToRaster[uiPartIdxLT]; idx-- ) |
---|
3421 | { |
---|
3422 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[idx], MD_ABOVE); |
---|
3423 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3424 | { |
---|
3425 | pInfo->iN--; //remove duplicate entries |
---|
3426 | bAdded = false; |
---|
3427 | } |
---|
3428 | } |
---|
3429 | #endif |
---|
3430 | if(!bAdded) |
---|
3431 | { |
---|
3432 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
3433 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3434 | { |
---|
3435 | pInfo->iN--; //remove duplicate entries |
---|
3436 | } |
---|
3437 | } |
---|
3438 | #if MTK_AMVP_SMVP_DERIVATION |
---|
3439 | if(!bAdded) |
---|
3440 | { |
---|
3441 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
3442 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3443 | { |
---|
3444 | pInfo->iN--; //remove duplicate entries |
---|
3445 | bAdded = false; |
---|
3446 | } |
---|
3447 | #if TI_AMVP_SMVP_SIMPLIFIED |
---|
3448 | if (!bAdded) |
---|
3449 | { |
---|
3450 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
3451 | } |
---|
3452 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3453 | { |
---|
3454 | pInfo->iN--; //remove duplicate entries |
---|
3455 | bAdded = false; |
---|
3456 | } |
---|
3457 | #else |
---|
3458 | for ( Int idx = (Int)g_auiZscanToRaster[uiPartIdxRT]; !bAdded && idx >= (Int)g_auiZscanToRaster[uiPartIdxLT]; idx-- ) |
---|
3459 | { |
---|
3460 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[idx], MD_ABOVE); |
---|
3461 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3462 | { |
---|
3463 | pInfo->iN--; //remove duplicate entries |
---|
3464 | bAdded = false; |
---|
3465 | } |
---|
3466 | } |
---|
3467 | #endif |
---|
3468 | if(!bAdded) |
---|
3469 | { |
---|
3470 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
3471 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3472 | { |
---|
3473 | pInfo->iN--; //remove duplicate entries |
---|
3474 | } |
---|
3475 | } |
---|
3476 | } |
---|
3477 | #endif |
---|
3478 | #else |
---|
3479 | //Left |
---|
3480 | for ( uiIdx = g_auiZscanToRaster[uiPartIdxLT]; uiIdx <= g_auiZscanToRaster[uiPartIdxLB]; uiIdx+= uiNumPartInCUWidth ) |
---|
3481 | { |
---|
3482 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[uiIdx], MD_LEFT ); |
---|
3483 | if (bAdded && iLeftMvIdx < 0) |
---|
3484 | { |
---|
3485 | iLeftMvIdx = pInfo->iN-1; |
---|
3486 | } |
---|
3487 | if (bAdded) break; |
---|
3488 | } |
---|
3489 | |
---|
3490 | bAdded = false; |
---|
3491 | //Above |
---|
3492 | for ( uiIdx = g_auiZscanToRaster[uiPartIdxLT]; uiIdx <= g_auiZscanToRaster[uiPartIdxRT]; uiIdx++ ) |
---|
3493 | { |
---|
3494 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[uiIdx], MD_ABOVE); |
---|
3495 | if (bAdded && iAboveMvIdx < 0) |
---|
3496 | { |
---|
3497 | iAboveMvIdx = pInfo->iN-1; |
---|
3498 | } |
---|
3499 | if (bAdded) break; |
---|
3500 | } |
---|
3501 | |
---|
3502 | bAdded = false; |
---|
3503 | //Above Right |
---|
3504 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
3505 | if (bAdded && iCornerMvIdx < 0) |
---|
3506 | { |
---|
3507 | iCornerMvIdx = pInfo->iN-1; |
---|
3508 | } |
---|
3509 | |
---|
3510 | //Below Left |
---|
3511 | if (!bAdded) |
---|
3512 | { |
---|
3513 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
3514 | } |
---|
3515 | if (bAdded && iCornerMvIdx < 0) |
---|
3516 | { |
---|
3517 | iCornerMvIdx = pInfo->iN-1; |
---|
3518 | } |
---|
3519 | |
---|
3520 | //Above Left |
---|
3521 | if (!bAdded) |
---|
3522 | { |
---|
3523 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
3524 | } |
---|
3525 | |
---|
3526 | if (bAdded && iCornerMvIdx < 0) |
---|
3527 | { |
---|
3528 | iCornerMvIdx = pInfo->iN-1; |
---|
3529 | } |
---|
3530 | |
---|
3531 | assert(iLeftMvIdx!=0 && iAboveMvIdx!=0 && iCornerMvIdx!=0); |
---|
3532 | |
---|
3533 | if (iLeftMvIdx < 0 && iAboveMvIdx < 0 && iCornerMvIdx < 0) |
---|
3534 | { |
---|
3535 | //done --> already zero Mv |
---|
3536 | } |
---|
3537 | else if ( (iLeftMvIdx > 0 && iAboveMvIdx > 0 && iCornerMvIdx > 0) || iLeftMvIdx*iAboveMvIdx*iCornerMvIdx < 0) |
---|
3538 | { |
---|
3539 | TComMv cLeftMv, cAboveMv, cCornerMv; |
---|
3540 | |
---|
3541 | if (iLeftMvIdx > 0) |
---|
3542 | { |
---|
3543 | cLeftMv = pInfo->m_acMvCand[iLeftMvIdx]; |
---|
3544 | } |
---|
3545 | if (iAboveMvIdx > 0) |
---|
3546 | { |
---|
3547 | cAboveMv = pInfo->m_acMvCand[iAboveMvIdx]; |
---|
3548 | } |
---|
3549 | if (iCornerMvIdx > 0) |
---|
3550 | { |
---|
3551 | cCornerMv = pInfo->m_acMvCand[iCornerMvIdx]; |
---|
3552 | } |
---|
3553 | pInfo->m_acMvCand[0].setHor ( Median (cLeftMv.getHor(), cAboveMv.getHor(), cCornerMv.getHor()) ); |
---|
3554 | pInfo->m_acMvCand[0].setVer ( Median (cLeftMv.getVer(), cAboveMv.getVer(), cCornerMv.getVer()) ); |
---|
3555 | } |
---|
3556 | else //only one is available among three candidates |
---|
3557 | { |
---|
3558 | if (iLeftMvIdx > 0) |
---|
3559 | { |
---|
3560 | pInfo->m_acMvCand[0] = pInfo->m_acMvCand[iLeftMvIdx]; |
---|
3561 | } |
---|
3562 | else if (iAboveMvIdx > 0) |
---|
3563 | { |
---|
3564 | pInfo->m_acMvCand[0] = pInfo->m_acMvCand[iAboveMvIdx]; |
---|
3565 | } |
---|
3566 | else if (iCornerMvIdx > 0) |
---|
3567 | { |
---|
3568 | pInfo->m_acMvCand[0] = pInfo->m_acMvCand[iCornerMvIdx]; |
---|
3569 | } |
---|
3570 | else |
---|
3571 | { |
---|
3572 | assert(0); |
---|
3573 | } |
---|
3574 | } |
---|
3575 | |
---|
3576 | clipMv(pInfo->m_acMvCand[0]); |
---|
3577 | TComMv cTempMv; |
---|
3578 | if ( ( ( ((eCUMode == SIZE_2NxN)) && uiPartIdx == 1 ) || |
---|
3579 | ( ((eCUMode == SIZE_Nx2N)) && uiPartIdx == 0 ) ) |
---|
3580 | && iLeftMvIdx > 0 ) |
---|
3581 | { |
---|
3582 | cTempMv = pInfo->m_acMvCand[0]; |
---|
3583 | pInfo->m_acMvCand[0] = pInfo->m_acMvCand[iLeftMvIdx]; |
---|
3584 | pInfo->m_acMvCand[iLeftMvIdx] = cTempMv; |
---|
3585 | } |
---|
3586 | #endif |
---|
3587 | |
---|
3588 | if (getAMVPMode(uiPartAddr) == AM_NONE) //Should be optimized later for special cases |
---|
3589 | { |
---|
3590 | assert(pInfo->iN > 0); |
---|
3591 | pInfo->iN = 1; |
---|
3592 | return; |
---|
3593 | } |
---|
3594 | |
---|
3595 | |
---|
3596 | |
---|
3597 | #if ( PDM_AMVP_POS == 2 ) |
---|
3598 | // get inter-view mv predictor (at position 2) |
---|
3599 | TComMv cPdmMvPred; |
---|
3600 | if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) ) |
---|
3601 | { |
---|
3602 | clipMv( cPdmMvPred ); |
---|
3603 | pInfo->m_acMvCand[ pInfo->iN++ ] = cPdmMvPred; |
---|
3604 | } |
---|
3605 | #endif |
---|
3606 | |
---|
3607 | |
---|
3608 | // Get Temporal Motion Predictor |
---|
3609 | #if AMVP_NEIGH_COL |
---|
3610 | #if MTK_TMVP_H_AMVP |
---|
3611 | int iRefIdx_Col = iRefIdx; |
---|
3612 | TComMv cColMv; |
---|
3613 | UInt uiPartIdxRB; |
---|
3614 | UInt uiAbsPartIdx; |
---|
3615 | UInt uiAbsPartAddr; |
---|
3616 | int uiLCUIdx = getAddr(); |
---|
3617 | |
---|
3618 | deriveRightBottomIdx( eCUMode, uiPartIdx, uiPartIdxRB ); |
---|
3619 | uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
---|
3620 | |
---|
3621 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
3622 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
---|
3623 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getWidth() ) // image boundary check |
---|
3624 | { |
---|
3625 | uiLCUIdx = -1; |
---|
3626 | } |
---|
3627 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getHeight() ) |
---|
3628 | { |
---|
3629 | uiLCUIdx = -1; |
---|
3630 | } |
---|
3631 | else |
---|
3632 | { |
---|
3633 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
3634 | ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
3635 | { |
---|
3636 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; |
---|
3637 | uiLCUIdx = getAddr(); |
---|
3638 | } |
---|
3639 | else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
3640 | { |
---|
3641 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
3642 | uiLCUIdx = getAddr() + m_pcPic->getFrameWidthInCU(); |
---|
3643 | } |
---|
3644 | else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
3645 | { |
---|
3646 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
---|
3647 | uiLCUIdx = getAddr() + 1; |
---|
3648 | } |
---|
3649 | else //is the right bottom corner of LCU |
---|
3650 | { |
---|
3651 | uiAbsPartAddr = 0; |
---|
3652 | uiLCUIdx = getAddr() + m_pcPic->getFrameWidthInCU() + 1; |
---|
3653 | } |
---|
3654 | } |
---|
3655 | if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col ) ) |
---|
3656 | { |
---|
3657 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
3658 | } |
---|
3659 | #if FT_TCTR_AMVP |
---|
3660 | else |
---|
3661 | { |
---|
3662 | UInt uiPartIdxCenter; |
---|
3663 | UInt uiCurLCUIdx = getAddr(); |
---|
3664 | xDeriveCenterIdx( eCUMode, uiPartIdx, uiPartIdxCenter ); |
---|
3665 | if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col )) |
---|
3666 | { |
---|
3667 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
3668 | } |
---|
3669 | } |
---|
3670 | #endif |
---|
3671 | //---- co-located RightBottom Temporal Predictor ---// |
---|
3672 | |
---|
3673 | #else //MTK_TMVP_H_AMVP |
---|
3674 | #if FT_TCTR_AMVP |
---|
3675 | TComMv cMvTCenter; |
---|
3676 | if (xGetCenterCol( uiPartIdx, eRefPicList, iRefIdx, &cMvTCenter )) |
---|
3677 | { |
---|
3678 | for (int i = pInfo->iN-1; i >= 0; i--) |
---|
3679 | { |
---|
3680 | pInfo->m_acMvCand[i+1] = pInfo->m_acMvCand[i]; |
---|
3681 | } |
---|
3682 | pInfo->m_acMvCand[0] = cMvTCenter; |
---|
3683 | pInfo->iN++; |
---|
3684 | } |
---|
3685 | #else //FT_TCTR_AMVP |
---|
3686 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
---|
3687 | |
---|
3688 | UInt uiColDir = (m_pcSlice->isInterB()? m_pcSlice->getColDir() : 0); |
---|
3689 | |
---|
3690 | TComDataCU* pcCUColocated = getCUColocated(RefPicList(uiColDir)); |
---|
3691 | |
---|
3692 | RefPicList eColRefPicList = (m_pcSlice->isInterB()? RefPicList(1-uiColDir) : REF_PIC_LIST_0); |
---|
3693 | #if PANASONIC_AMVPTEMPORALEXT |
---|
3694 | RefPicList eColRefPicList2 = (m_pcSlice->isInterB()? RefPicList(uiColDir) : REF_PIC_LIST_0); |
---|
3695 | #endif |
---|
3696 | |
---|
3697 | if ( pcCUColocated && !pcCUColocated->isIntra(uiAbsPartAddr) && |
---|
3698 | pcCUColocated->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr) >= 0 ) |
---|
3699 | { |
---|
3700 | Int iColPOC = pcCUColocated->getSlice()->getPOC(); |
---|
3701 | Int iColRefPOC = pcCUColocated->getSlice()->getRefPOC(eColRefPicList, pcCUColocated->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr)); |
---|
3702 | TComMv cColMv = pcCUColocated->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
3703 | |
---|
3704 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
3705 | Int iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getPOC(); |
---|
3706 | |
---|
3707 | TComMv cMv; |
---|
3708 | Int iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
3709 | |
---|
3710 | if (iScale == 1024) |
---|
3711 | { |
---|
3712 | cMv = cColMv; |
---|
3713 | } |
---|
3714 | else |
---|
3715 | { |
---|
3716 | cMv = cColMv.scaleMv( iScale ); |
---|
3717 | } |
---|
3718 | |
---|
3719 | clipMv(cMv); |
---|
3720 | |
---|
3721 | pInfo->m_acMvCand[pInfo->iN++] = cMv ; |
---|
3722 | } |
---|
3723 | #if PANASONIC_AMVPTEMPORALEXT |
---|
3724 | else if ( pcCUColocated && !pcCUColocated->isIntra(uiAbsPartAddr) && |
---|
3725 | pcCUColocated->getCUMvField(eColRefPicList2)->getRefIdx(uiAbsPartAddr) >= 0 ) |
---|
3726 | { |
---|
3727 | Int iColPOC = pcCUColocated->getSlice()->getPOC(); |
---|
3728 | Int iColRefPOC = pcCUColocated->getSlice()->getRefPOC(eColRefPicList2, pcCUColocated->getCUMvField(eColRefPicList2)->getRefIdx(uiAbsPartAddr)); |
---|
3729 | TComMv cColMv = pcCUColocated->getCUMvField(eColRefPicList2)->getMv(uiAbsPartAddr); |
---|
3730 | |
---|
3731 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
3732 | Int iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getPOC(); |
---|
3733 | |
---|
3734 | TComMv cMv; |
---|
3735 | Int iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
3736 | |
---|
3737 | if (iScale == 1024) |
---|
3738 | { |
---|
3739 | cMv = cColMv; |
---|
3740 | } |
---|
3741 | else |
---|
3742 | { |
---|
3743 | cMv = cColMv.scaleMv( iScale ); |
---|
3744 | } |
---|
3745 | |
---|
3746 | clipMv(cMv); |
---|
3747 | |
---|
3748 | pInfo->m_acMvCand[pInfo->iN++] = cMv ; |
---|
3749 | } |
---|
3750 | #endif // PANASONIC_AMVPTEMPORALEXT |
---|
3751 | #endif // FT_TCTR_AMVP |
---|
3752 | #endif // MTK_TMVP_H_AMVP |
---|
3753 | #endif // AMVP_NEIGH_COL |
---|
3754 | |
---|
3755 | |
---|
3756 | #if ( PDM_AMVP_POS == 3 ) |
---|
3757 | // get inter-view mv predictor (at position 3) |
---|
3758 | TComMv cPdmMvPred; |
---|
3759 | if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) ) |
---|
3760 | { |
---|
3761 | clipMv( cPdmMvPred ); |
---|
3762 | pInfo->m_acMvCand[ pInfo->iN++ ] = cPdmMvPred; |
---|
3763 | } |
---|
3764 | #endif |
---|
3765 | |
---|
3766 | |
---|
3767 | // Check No MV Candidate |
---|
3768 | xUniqueMVPCand( pInfo ); |
---|
3769 | return ; |
---|
3770 | } |
---|
3771 | |
---|
3772 | #if DCM_SIMPLIFIED_MVP==0 |
---|
3773 | Bool TComDataCU::clearMVPCand( TComMv cMvd, AMVPInfo* pInfo ) |
---|
3774 | { |
---|
3775 | // only works for multiple candidates |
---|
3776 | if (pInfo->iN <= 1) |
---|
3777 | { |
---|
3778 | return false; |
---|
3779 | } |
---|
3780 | |
---|
3781 | // only works for non-zero mvd case |
---|
3782 | if (cMvd.getHor() == 0 && cMvd.getVer() == 0) |
---|
3783 | { |
---|
3784 | return false; |
---|
3785 | } |
---|
3786 | |
---|
3787 | TComMv acMv[ AMVP_MAX_NUM_CANDS ]; |
---|
3788 | Int aiValid [ AMVP_MAX_NUM_CANDS ]; |
---|
3789 | |
---|
3790 | Int iNTmp, i, j; |
---|
3791 | |
---|
3792 | for ( i=0; i<pInfo->iN; i++ ) |
---|
3793 | { |
---|
3794 | aiValid[i] = 1; |
---|
3795 | } |
---|
3796 | |
---|
3797 | for ( i=0; i<pInfo->iN; i++ ) |
---|
3798 | { |
---|
3799 | TComMv cMvCand = pInfo->m_acMvCand[i] + cMvd; |
---|
3800 | |
---|
3801 | UInt uiBestBits = xGetMvdBits(cMvd); |
---|
3802 | for ( j=0; j<pInfo->iN; j++ ) |
---|
3803 | { |
---|
3804 | if (aiValid[j] && i!=j && xGetMvdBits(cMvCand-pInfo->m_acMvCand[j]) < uiBestBits) |
---|
3805 | { |
---|
3806 | aiValid[i] = 0; |
---|
3807 | } |
---|
3808 | } |
---|
3809 | } |
---|
3810 | |
---|
3811 | iNTmp = 0; |
---|
3812 | for ( i=0; i<pInfo->iN; i++ ) |
---|
3813 | { |
---|
3814 | if (aiValid[i]) |
---|
3815 | iNTmp++; |
---|
3816 | } |
---|
3817 | |
---|
3818 | if (iNTmp == pInfo->iN) |
---|
3819 | { |
---|
3820 | return false; |
---|
3821 | } |
---|
3822 | |
---|
3823 | assert(iNTmp > 0); |
---|
3824 | |
---|
3825 | iNTmp = 0; |
---|
3826 | for ( i=0; i<pInfo->iN; i++ ) |
---|
3827 | { |
---|
3828 | if (aiValid[i]) |
---|
3829 | { |
---|
3830 | acMv[iNTmp++] = pInfo->m_acMvCand[i]; |
---|
3831 | } |
---|
3832 | } |
---|
3833 | |
---|
3834 | for ( i=0; i<iNTmp; i++ ) pInfo->m_acMvCand[i] = acMv[i]; |
---|
3835 | pInfo->iN = iNTmp; |
---|
3836 | |
---|
3837 | return true; |
---|
3838 | } |
---|
3839 | #endif |
---|
3840 | |
---|
3841 | Int TComDataCU::searchMVPIdx(TComMv cMv, AMVPInfo* pInfo) |
---|
3842 | { |
---|
3843 | for ( Int i=0; i<pInfo->iN; i++ ) |
---|
3844 | { |
---|
3845 | if (cMv == pInfo->m_acMvCand[i]) |
---|
3846 | return i; |
---|
3847 | } |
---|
3848 | |
---|
3849 | assert(0); |
---|
3850 | return -1; |
---|
3851 | } |
---|
3852 | |
---|
3853 | Void TComDataCU::clipMv (TComMv& rcMv) |
---|
3854 | { |
---|
3855 | Int iMvShift = 2; |
---|
3856 | #if MW_DEPTH_MAP_INTERP_FILTER == 2 && MW_FULL_PEL_DEPTH_MAP_MV_SIGNALLING |
---|
3857 | if( getSlice()->getSPS()->isDepth() ) |
---|
3858 | iMvShift = 0; |
---|
3859 | #endif |
---|
3860 | Int iHorMax = (m_pcSlice->getSPS()->getWidth() - m_uiCUPelX - 1 )<<iMvShift; |
---|
3861 | Int iHorMin = ( -(Int)g_uiMaxCUWidth - (Int)m_uiCUPelX + 1 )<<iMvShift; |
---|
3862 | |
---|
3863 | Int iVerMax = (m_pcSlice->getSPS()->getHeight() - m_uiCUPelY - 1 )<<iMvShift; |
---|
3864 | Int iVerMin = ( -(Int)g_uiMaxCUHeight - (Int)m_uiCUPelY + 1 )<<iMvShift; |
---|
3865 | |
---|
3866 | rcMv.setHor( Min (iHorMax, Max (iHorMin, rcMv.getHor())) ); |
---|
3867 | rcMv.setVer( Min (iVerMax, Max (iVerMin, rcMv.getVer())) ); |
---|
3868 | } |
---|
3869 | |
---|
3870 | |
---|
3871 | Void TComDataCU::convertTransIdx( UInt uiAbsPartIdx, UInt uiTrIdx, UInt& ruiLumaTrMode, UInt& ruiChromaTrMode ) |
---|
3872 | { |
---|
3873 | ruiLumaTrMode = uiTrIdx; |
---|
3874 | ruiChromaTrMode = uiTrIdx; |
---|
3875 | return; |
---|
3876 | } |
---|
3877 | |
---|
3878 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
---|
3879 | { |
---|
3880 | UInt uiShift = ( (m_puhTrIdx[uiAbsPartIdx]==0) && (m_pePartSize[uiAbsPartIdx]==SIZE_NxN) ) ? m_puhTrIdx[uiAbsPartIdx]+1 : m_puhTrIdx[uiAbsPartIdx]; |
---|
3881 | uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
3882 | |
---|
3883 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
3884 | UInt uiCnt = 0; |
---|
3885 | while( uiWidth ) |
---|
3886 | { |
---|
3887 | uiCnt++; |
---|
3888 | uiWidth>>=1; |
---|
3889 | } |
---|
3890 | uiCnt-=2; |
---|
3891 | return uiCnt > 6 ? 6 : uiCnt; |
---|
3892 | } |
---|
3893 | |
---|
3894 | Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts ) |
---|
3895 | { |
---|
3896 | ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
3897 | } |
---|
3898 | |
---|
3899 | /** Test if the current block is skipped or not |
---|
3900 | * \param uiPartIdx |
---|
3901 | * \returns Bool |
---|
3902 | */ |
---|
3903 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
---|
3904 | { |
---|
3905 | if ( m_pcSlice->isIntra () ) |
---|
3906 | { |
---|
3907 | return false; |
---|
3908 | } |
---|
3909 | #if HHI_MRG_SKIP |
---|
3910 | return ( m_pePredMode[ uiPartIdx ] == MODE_SKIP && getMergeFlag( uiPartIdx ) && !getQtRootCbf( uiPartIdx ) ); |
---|
3911 | #else |
---|
3912 | if ( m_pcSlice->isInterP() ) |
---|
3913 | { |
---|
3914 | return ( ( m_pePredMode[ uiPartIdx ] == MODE_SKIP ) && ( ( m_puhCbf[0][uiPartIdx] & 0x1 ) + ( m_puhCbf[1][uiPartIdx] & 0x1 ) + ( m_puhCbf[2][uiPartIdx] & 0x1 ) == 0) ); |
---|
3915 | } |
---|
3916 | else //if ( m_pcSlice->isInterB() ) |
---|
3917 | { |
---|
3918 | return ( ( m_pePredMode[ uiPartIdx ] == MODE_SKIP ) && ( ( m_puhCbf[0][uiPartIdx] & 0x1 ) + ( m_puhCbf[1][uiPartIdx] & 0x1 ) + ( m_puhCbf[2][uiPartIdx] & 0x1 ) == 0) && (m_puhInterDir[uiPartIdx] == 3) ); |
---|
3919 | } |
---|
3920 | #endif |
---|
3921 | } |
---|
3922 | |
---|
3923 | // ==================================================================================================================== |
---|
3924 | // Protected member functions |
---|
3925 | // ==================================================================================================================== |
---|
3926 | |
---|
3927 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
3928 | { |
---|
3929 | TComDataCU* pcTmpCU = NULL; |
---|
3930 | UInt uiIdx; |
---|
3931 | switch( eDir ) |
---|
3932 | { |
---|
3933 | case MD_LEFT: |
---|
3934 | { |
---|
3935 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
3936 | break; |
---|
3937 | } |
---|
3938 | case MD_ABOVE: |
---|
3939 | { |
---|
3940 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
3941 | break; |
---|
3942 | } |
---|
3943 | case MD_ABOVE_RIGHT: |
---|
3944 | { |
---|
3945 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
3946 | break; |
---|
3947 | } |
---|
3948 | case MD_BELOW_LEFT: |
---|
3949 | { |
---|
3950 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
3951 | break; |
---|
3952 | } |
---|
3953 | case MD_ABOVE_LEFT: |
---|
3954 | { |
---|
3955 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
3956 | break; |
---|
3957 | } |
---|
3958 | default: |
---|
3959 | { |
---|
3960 | break; |
---|
3961 | } |
---|
3962 | } |
---|
3963 | |
---|
3964 | if ( pcTmpCU != NULL && m_pcSlice->isEqualRef(eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx), iRefIdx) ) |
---|
3965 | { |
---|
3966 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
3967 | clipMv(cMvPred); |
---|
3968 | |
---|
3969 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
3970 | return true; |
---|
3971 | } |
---|
3972 | return false; |
---|
3973 | } |
---|
3974 | |
---|
3975 | Void TComDataCU::xUniqueMVPCand(AMVPInfo* pInfo) |
---|
3976 | { |
---|
3977 | if ( pInfo->iN == 0 ) |
---|
3978 | { |
---|
3979 | pInfo->m_acMvCand[ pInfo->iN++ ].setZero(); |
---|
3980 | return; |
---|
3981 | } |
---|
3982 | |
---|
3983 | TComMv acMv[ AMVP_MAX_NUM_CANDS ]; |
---|
3984 | Int iNTmp, i, j; |
---|
3985 | |
---|
3986 | // make it be unique |
---|
3987 | iNTmp = 0; |
---|
3988 | acMv[ iNTmp++ ] = pInfo->m_acMvCand[0]; |
---|
3989 | for ( i=1; i<pInfo->iN; i++ ) |
---|
3990 | { |
---|
3991 | // BugFix for 1603 |
---|
3992 | for ( j=iNTmp - 1; j>=0; j-- ) |
---|
3993 | { |
---|
3994 | if ( pInfo->m_acMvCand[i] == acMv[j] ) break; |
---|
3995 | } |
---|
3996 | if ( j<0 ) |
---|
3997 | { |
---|
3998 | acMv[ iNTmp++ ] = pInfo->m_acMvCand[i]; |
---|
3999 | } |
---|
4000 | } |
---|
4001 | for ( i=0; i<iNTmp; i++ ) pInfo->m_acMvCand[i] = acMv[i]; |
---|
4002 | pInfo->iN = iNTmp; |
---|
4003 | |
---|
4004 | return ; |
---|
4005 | } |
---|
4006 | |
---|
4007 | #if MTK_AMVP_SMVP_DERIVATION |
---|
4008 | /** |
---|
4009 | * \param pInfo |
---|
4010 | * \param eRefPicList |
---|
4011 | * \param iRefIdx |
---|
4012 | * \param uiPartUnitIdx |
---|
4013 | * \param eDir |
---|
4014 | * \returns Bool |
---|
4015 | */ |
---|
4016 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
4017 | { |
---|
4018 | TComDataCU* pcTmpCU = NULL; |
---|
4019 | UInt uiIdx; |
---|
4020 | switch( eDir ) |
---|
4021 | { |
---|
4022 | case MD_LEFT: |
---|
4023 | { |
---|
4024 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
4025 | break; |
---|
4026 | } |
---|
4027 | case MD_ABOVE: |
---|
4028 | { |
---|
4029 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
4030 | break; |
---|
4031 | } |
---|
4032 | case MD_ABOVE_RIGHT: |
---|
4033 | { |
---|
4034 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
4035 | break; |
---|
4036 | } |
---|
4037 | case MD_BELOW_LEFT: |
---|
4038 | { |
---|
4039 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
4040 | break; |
---|
4041 | } |
---|
4042 | case MD_ABOVE_LEFT: |
---|
4043 | { |
---|
4044 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
4045 | break; |
---|
4046 | } |
---|
4047 | default: |
---|
4048 | { |
---|
4049 | break; |
---|
4050 | } |
---|
4051 | } |
---|
4052 | |
---|
4053 | if ( pcTmpCU == NULL ) |
---|
4054 | return false; |
---|
4055 | |
---|
4056 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
4057 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
4058 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
4059 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
4060 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
4061 | |
---|
4062 | |
---|
4063 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
4064 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
4065 | Int iNeibPOC = iCurrPOC; |
---|
4066 | Int iNeibRefPOC; |
---|
4067 | |
---|
4068 | |
---|
4069 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
---|
4070 | { |
---|
4071 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
4072 | if( pcTmpCU->getSlice()->getRefViewIdx( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) != m_pcSlice->getRefViewIdx( eRefPicList, iRefIdx ) ) |
---|
4073 | return false; |
---|
4074 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
---|
4075 | { |
---|
4076 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
4077 | |
---|
4078 | clipMv(cMvPred); |
---|
4079 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
4080 | return true; |
---|
4081 | } |
---|
4082 | } |
---|
4083 | //--------------- V1 (END) ------------------// |
---|
4084 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
---|
4085 | { |
---|
4086 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
---|
4087 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
4088 | TComMv rcMv; |
---|
4089 | |
---|
4090 | if( pcTmpCU->getSlice()->getRefViewIdx( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ) != m_pcSlice->getRefViewIdx( eRefPicList, iRefIdx ) ) |
---|
4091 | return false; |
---|
4092 | |
---|
4093 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
4094 | if ( iScale == 1024 ) |
---|
4095 | { |
---|
4096 | rcMv = cMvPred; |
---|
4097 | } |
---|
4098 | else |
---|
4099 | { |
---|
4100 | rcMv = cMvPred.scaleMv( iScale ); |
---|
4101 | } |
---|
4102 | |
---|
4103 | clipMv(rcMv); |
---|
4104 | |
---|
4105 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
4106 | return true; |
---|
4107 | } |
---|
4108 | //---------------------- V2(END) --------------------// |
---|
4109 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
---|
4110 | { |
---|
4111 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
4112 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
4113 | TComMv rcMv; |
---|
4114 | |
---|
4115 | if( pcTmpCU->getSlice()->getRefViewIdx( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) != m_pcSlice->getRefViewIdx( eRefPicList, iRefIdx ) ) |
---|
4116 | return false; |
---|
4117 | |
---|
4118 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
4119 | if ( iScale == 1024 ) |
---|
4120 | { |
---|
4121 | rcMv = cMvPred; |
---|
4122 | } |
---|
4123 | else |
---|
4124 | { |
---|
4125 | rcMv = cMvPred.scaleMv( iScale ); |
---|
4126 | } |
---|
4127 | |
---|
4128 | clipMv(rcMv); |
---|
4129 | |
---|
4130 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
4131 | return true; |
---|
4132 | } |
---|
4133 | //---------------------- V3(END) --------------------// |
---|
4134 | return false; |
---|
4135 | } |
---|
4136 | #endif |
---|
4137 | |
---|
4138 | /** |
---|
4139 | * \param eRefPicList |
---|
4140 | * \param uiCUAddr |
---|
4141 | * \param uiPartUnitIdx |
---|
4142 | * \param riRefIdx |
---|
4143 | * \returns Bool |
---|
4144 | */ |
---|
4145 | #if MTK_TMVP_H_MRG || MTK_TMVP_H_AMVP |
---|
4146 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx ) |
---|
4147 | { |
---|
4148 | UInt uiAbsPartAddr = uiPartUnitIdx; |
---|
4149 | |
---|
4150 | RefPicList eColRefPicList; |
---|
4151 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
---|
4152 | TComMv cColMv; |
---|
4153 | |
---|
4154 | iCurrPOC = m_pcSlice->getPOC(); |
---|
4155 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
4156 | |
---|
4157 | // use coldir. |
---|
4158 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0), 0); |
---|
4159 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
4160 | iColPOC = pColCU->getSlice()->getPOC(); |
---|
4161 | |
---|
4162 | if (pColCU->isIntra(uiAbsPartAddr)) |
---|
4163 | { |
---|
4164 | return false; |
---|
4165 | } |
---|
4166 | |
---|
4167 | if( m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewIdx() != m_pcSlice->getViewIdx() ) |
---|
4168 | return false; |
---|
4169 | |
---|
4170 | // Prefer a vector crossing us. Prefer shortest. |
---|
4171 | eColRefPicList = REF_PIC_LIST_0; |
---|
4172 | bool bFirstCrosses = false; |
---|
4173 | Int iFirstColDist = -1; |
---|
4174 | |
---|
4175 | for (Int l = 0; l < 2; l++) |
---|
4176 | { |
---|
4177 | bool bSaveIt = false; |
---|
4178 | int iColRefIdx = pColCU->getCUMvField(RefPicList(l))->getRefIdx(uiAbsPartAddr); |
---|
4179 | if (iColRefIdx < 0) |
---|
4180 | { |
---|
4181 | continue; |
---|
4182 | } |
---|
4183 | iColRefPOC = pColCU->getSlice()->getRefPOC(RefPicList(l), iColRefIdx); |
---|
4184 | if( pColCU->getSlice()->getRefViewIdx(RefPicList(l), iColRefIdx) != pColCU->getSlice()->getViewIdx() ) |
---|
4185 | continue; |
---|
4186 | int iColDist = abs(iColRefPOC - iColPOC); |
---|
4187 | bool bCrosses = iColPOC < iCurrPOC ? iColRefPOC > iCurrPOC : iColRefPOC < iCurrPOC; |
---|
4188 | if (iFirstColDist < 0) |
---|
4189 | { |
---|
4190 | bSaveIt = true; |
---|
4191 | } |
---|
4192 | else if (bCrosses && !bFirstCrosses) |
---|
4193 | { |
---|
4194 | bSaveIt = true; |
---|
4195 | } |
---|
4196 | #if PANASONIC_AMVPTEMPORALMOD |
---|
4197 | else if (bCrosses == bFirstCrosses && l == eRefPicList) |
---|
4198 | #else |
---|
4199 | else if (bCrosses == bFirstCrosses && iColDist < iFirstColDist) |
---|
4200 | #endif |
---|
4201 | { |
---|
4202 | bSaveIt = true; |
---|
4203 | } |
---|
4204 | if (bSaveIt) |
---|
4205 | { |
---|
4206 | bFirstCrosses = bCrosses; |
---|
4207 | iFirstColDist = iColDist; |
---|
4208 | eColRefPicList = RefPicList(l); |
---|
4209 | } |
---|
4210 | } |
---|
4211 | if( iFirstColDist < 0 ) |
---|
4212 | return false; |
---|
4213 | // Scale the vector. |
---|
4214 | iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr)); |
---|
4215 | cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
4216 | |
---|
4217 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
4218 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
4219 | if (iScale == 1024) |
---|
4220 | { |
---|
4221 | rcMv = cColMv; |
---|
4222 | } |
---|
4223 | else |
---|
4224 | { |
---|
4225 | rcMv = cColMv.scaleMv( iScale ); |
---|
4226 | } |
---|
4227 | clipMv(rcMv); |
---|
4228 | return true; |
---|
4229 | } |
---|
4230 | #endif |
---|
4231 | |
---|
4232 | UInt TComDataCU::xGetMvdBits(TComMv cMvd) |
---|
4233 | { |
---|
4234 | return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) ); |
---|
4235 | } |
---|
4236 | |
---|
4237 | UInt TComDataCU::xGetComponentBits(Int iVal) |
---|
4238 | { |
---|
4239 | UInt uiLength = 1; |
---|
4240 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
4241 | |
---|
4242 | assert ( uiTemp ); |
---|
4243 | |
---|
4244 | while ( 1 != uiTemp ) |
---|
4245 | { |
---|
4246 | uiTemp >>= 1; |
---|
4247 | uiLength += 2; |
---|
4248 | } |
---|
4249 | |
---|
4250 | return uiLength; |
---|
4251 | } |
---|
4252 | |
---|
4253 | |
---|
4254 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
4255 | { |
---|
4256 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
4257 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
4258 | |
---|
4259 | if( iDiffPocD == iDiffPocB ) |
---|
4260 | { |
---|
4261 | return 1024; |
---|
4262 | } |
---|
4263 | else |
---|
4264 | { |
---|
4265 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
4266 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
4267 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
4268 | Int iScale = Clip3( -1024, 1023, (iTDB * iX + 32) >> 6 ); |
---|
4269 | return iScale; |
---|
4270 | } |
---|
4271 | } |
---|
4272 | |
---|
4273 | Void TComDataCU::xCalcCuCbf( UChar* puhCbf, UInt uiTrDepth, UInt uiCbfDepth, UInt uiCuDepth ) |
---|
4274 | { |
---|
4275 | if ( uiTrDepth == 0 ) |
---|
4276 | return; |
---|
4277 | |
---|
4278 | UInt ui, uiNumSig = 0; |
---|
4279 | |
---|
4280 | UInt uiNumPart = m_pcPic->getNumPartInCU() >> ( uiCuDepth << 1 ); |
---|
4281 | UInt uiQNumPart = uiNumPart >> 2; |
---|
4282 | |
---|
4283 | UInt uiCbfDepth1 = uiCbfDepth + 1; |
---|
4284 | if( uiNumPart == 1 ) |
---|
4285 | { |
---|
4286 | if ( ( puhCbf[0] >> uiCbfDepth1 ) & 0x1 ) |
---|
4287 | { |
---|
4288 | uiNumSig = 1; |
---|
4289 | } |
---|
4290 | puhCbf[0] |= uiNumSig << uiCbfDepth; |
---|
4291 | |
---|
4292 | return; |
---|
4293 | } |
---|
4294 | assert( uiQNumPart ); |
---|
4295 | |
---|
4296 | if ( uiCbfDepth < ( uiTrDepth - 1 ) ) |
---|
4297 | { |
---|
4298 | UChar* puhNextCbf = puhCbf; |
---|
4299 | xCalcCuCbf( puhNextCbf, uiTrDepth, uiCbfDepth1, uiCuDepth+1 ); puhNextCbf += uiQNumPart; |
---|
4300 | xCalcCuCbf( puhNextCbf, uiTrDepth, uiCbfDepth1, uiCuDepth+1 ); puhNextCbf += uiQNumPart; |
---|
4301 | xCalcCuCbf( puhNextCbf, uiTrDepth, uiCbfDepth1, uiCuDepth+1 ); puhNextCbf += uiQNumPart; |
---|
4302 | xCalcCuCbf( puhNextCbf, uiTrDepth, uiCbfDepth1, uiCuDepth+1 ); |
---|
4303 | } |
---|
4304 | |
---|
4305 | for ( ui = 0; ui < uiNumPart; ui += uiQNumPart ) |
---|
4306 | { |
---|
4307 | if ( ( puhCbf[ui] >> uiCbfDepth1 ) & 0x1 ) |
---|
4308 | { |
---|
4309 | uiNumSig = 1; |
---|
4310 | break; |
---|
4311 | } |
---|
4312 | } |
---|
4313 | |
---|
4314 | uiNumSig <<= uiCbfDepth; |
---|
4315 | for ( ui = 0; ui < uiNumPart; ui++ ) |
---|
4316 | { |
---|
4317 | puhCbf[ui] |= uiNumSig; |
---|
4318 | } |
---|
4319 | } |
---|
4320 | |
---|
4321 | #if FT_TCTR_AMVP || FT_TCTR_MRG |
---|
4322 | /** |
---|
4323 | * \param eCUMode |
---|
4324 | * \param uiPartIdx |
---|
4325 | * \param ruiPartIdxCenter |
---|
4326 | * \returns Void |
---|
4327 | */ |
---|
4328 | Void TComDataCU::xDeriveCenterIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
---|
4329 | { |
---|
4330 | UInt uiPartAddr; |
---|
4331 | Int iPartWidth; |
---|
4332 | Int iPartHeight; |
---|
4333 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
4334 | |
---|
4335 | ruiPartIdxCenter = m_uiAbsIdxInLCU+uiPartAddr; // partition origin. |
---|
4336 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
4337 | + ( iPartHeight/m_pcPic->getMinCUHeight() -1 )/2*m_pcPic->getNumPartInWidth() |
---|
4338 | + ( iPartWidth/m_pcPic->getMinCUWidth() -1 )/2]; |
---|
4339 | } |
---|
4340 | |
---|
4341 | /** |
---|
4342 | * \param uiPartIdx |
---|
4343 | * \param eRefPicList |
---|
4344 | * \param iRefIdx |
---|
4345 | * \param pcMv |
---|
4346 | * \returns Bool |
---|
4347 | */ |
---|
4348 | Bool TComDataCU::xGetCenterCol( UInt uiPartIdx, RefPicList eRefPicList, int iRefIdx, TComMv *pcMv ) |
---|
4349 | { |
---|
4350 | PartSize eCUMode = m_pePartSize[0]; |
---|
4351 | |
---|
4352 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
4353 | |
---|
4354 | // use coldir. |
---|
4355 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0), 0); |
---|
4356 | TComDataCU *pColCU = pColPic->getCU( m_uiCUAddr ); |
---|
4357 | |
---|
4358 | Int iColPOC = pColCU->getSlice()->getPOC(); |
---|
4359 | UInt uiPartIdxCenter; |
---|
4360 | xDeriveCenterIdx( eCUMode, uiPartIdx, uiPartIdxCenter ); |
---|
4361 | |
---|
4362 | if (pColCU->isIntra(uiPartIdxCenter)) |
---|
4363 | return false; |
---|
4364 | |
---|
4365 | if( m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getViewIdx() != m_pcSlice->getViewIdx() ) |
---|
4366 | return false; |
---|
4367 | |
---|
4368 | // Prefer a vector crossing us. Prefer shortest. |
---|
4369 | RefPicList eColRefPicList = REF_PIC_LIST_0; |
---|
4370 | bool bFirstCrosses = false; |
---|
4371 | Int iFirstColDist = -1; |
---|
4372 | for (Int l = 0; l < 2; l++) |
---|
4373 | { |
---|
4374 | bool bSaveIt = false; |
---|
4375 | int iColRefIdx = pColCU->getCUMvField(RefPicList(l))->getRefIdx(uiPartIdxCenter); |
---|
4376 | if (iColRefIdx < 0) |
---|
4377 | continue; |
---|
4378 | int iColRefPOC = pColCU->getSlice()->getRefPOC(RefPicList(l), iColRefIdx); |
---|
4379 | if( pColCU->getSlice()->getRefViewIdx(RefPicList(l), iColRefIdx) != pColCU->getSlice()->getViewIdx() ) |
---|
4380 | continue; |
---|
4381 | int iColDist = abs(iColRefPOC - iColPOC); |
---|
4382 | bool bCrosses = iColPOC < iCurrPOC ? iColRefPOC > iCurrPOC : iColRefPOC < iCurrPOC; |
---|
4383 | if (iFirstColDist < 0) |
---|
4384 | bSaveIt = true; |
---|
4385 | else if (bCrosses && !bFirstCrosses) |
---|
4386 | bSaveIt = true; |
---|
4387 | #if PANASONIC_AMVPTEMPORALMOD |
---|
4388 | else if (bCrosses == bFirstCrosses && l == eRefPicList) |
---|
4389 | #else |
---|
4390 | else if (bCrosses == bFirstCrosses && iColDist < iFirstColDist) |
---|
4391 | #endif |
---|
4392 | bSaveIt = true; |
---|
4393 | |
---|
4394 | if (bSaveIt) |
---|
4395 | { |
---|
4396 | bFirstCrosses = bCrosses; |
---|
4397 | iFirstColDist = iColDist; |
---|
4398 | eColRefPicList = RefPicList(l); |
---|
4399 | } |
---|
4400 | } |
---|
4401 | if( iFirstColDist < 0 ) |
---|
4402 | return false; |
---|
4403 | |
---|
4404 | // Scale the vector. |
---|
4405 | Int iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartIdxCenter)); |
---|
4406 | TComMv cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartIdxCenter); |
---|
4407 | |
---|
4408 | Int iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getPOC(); |
---|
4409 | Int iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
4410 | if (iScale == 1024) |
---|
4411 | { |
---|
4412 | pcMv[0] = cColMv; |
---|
4413 | } |
---|
4414 | else |
---|
4415 | { |
---|
4416 | pcMv[0] = cColMv.scaleMv( iScale ); |
---|
4417 | } |
---|
4418 | clipMv(pcMv[0]); |
---|
4419 | |
---|
4420 | return true; |
---|
4421 | } |
---|
4422 | #endif |
---|
4423 | |
---|
4424 | #if AMVP_BUFFERCOMPRESS |
---|
4425 | Void TComDataCU::compressMV() |
---|
4426 | { |
---|
4427 | m_acCUMvField[0].compress(m_pePredMode,m_puhInterDir); |
---|
4428 | m_acCUMvField[1].compress(m_pePredMode,m_puhInterDir); |
---|
4429 | } |
---|
4430 | #endif |
---|
4431 | |
---|
4432 | #if QC_MDCS |
---|
4433 | UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) |
---|
4434 | { |
---|
4435 | static const UChar aucIntraLumaDirToScanIdx[MAX_CU_DEPTH][34] = |
---|
4436 | { |
---|
4437 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
---|
4438 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
---|
4439 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
---|
4440 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
---|
4441 | {1, 2, 0, 0, 1, 1, 0, 2, 2, 0, 0, 1, 1, 0, 0, 2, 2, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, }, |
---|
4442 | {1, 2, 0, 0, 1, 1, 0, 2, 2, 0, 0, 1, 1, 0, 0, 2, 2, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, }, |
---|
4443 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
---|
4444 | }; |
---|
4445 | static const UChar aucIntraChromaDirToScanIdx[MAX_CU_DEPTH][5] = |
---|
4446 | { |
---|
4447 | {0, 0, 0, 0, 0, }, |
---|
4448 | {0, 0, 0, 0, 0, }, |
---|
4449 | {0, 0, 0, 0, 0, }, |
---|
4450 | {0, 0, 0, 0, 0, }, |
---|
4451 | {0, 0, 0, 0, 0, }, |
---|
4452 | {1, 2, 0, 0, 0, }, |
---|
4453 | {1, 2, 0, 0, 0, }, |
---|
4454 | }; |
---|
4455 | |
---|
4456 | UInt uiCTXIdx; |
---|
4457 | UInt uiScanIdx; |
---|
4458 | UInt uiDirMode; |
---|
4459 | |
---|
4460 | if ( !bIsIntra ) |
---|
4461 | { |
---|
4462 | uiScanIdx = SCAN_ZIGZAG; |
---|
4463 | return uiScanIdx; |
---|
4464 | } |
---|
4465 | |
---|
4466 | switch(uiWidth) |
---|
4467 | { |
---|
4468 | case 2: uiCTXIdx = 6; break; |
---|
4469 | case 4: uiCTXIdx = 5; break; |
---|
4470 | case 8: uiCTXIdx = 4; break; |
---|
4471 | case 16: uiCTXIdx = 3; break; |
---|
4472 | case 32: uiCTXIdx = 2; break; |
---|
4473 | case 64: uiCTXIdx = 1; break; |
---|
4474 | default: uiCTXIdx = 0; break; |
---|
4475 | } |
---|
4476 | |
---|
4477 | if ( bIsLuma ) |
---|
4478 | { |
---|
4479 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
---|
4480 | #if ADD_PLANAR_MODE |
---|
4481 | mapPlanartoDC( uiDirMode ); |
---|
4482 | #endif |
---|
4483 | uiScanIdx = aucIntraLumaDirToScanIdx[uiCTXIdx][uiDirMode]; |
---|
4484 | } |
---|
4485 | else |
---|
4486 | { |
---|
4487 | uiDirMode = getChromaIntraDir(uiAbsPartIdx); |
---|
4488 | #if ADD_PLANAR_MODE |
---|
4489 | mapPlanartoDC( uiDirMode ); |
---|
4490 | #endif |
---|
4491 | if (uiDirMode < 4) |
---|
4492 | { |
---|
4493 | uiScanIdx = (aucIntraChromaDirToScanIdx[uiCTXIdx][uiDirMode]); |
---|
4494 | } |
---|
4495 | else |
---|
4496 | { |
---|
4497 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
---|
4498 | #if ADD_PLANAR_MODE |
---|
4499 | mapPlanartoDC( uiDirMode ); |
---|
4500 | #endif |
---|
4501 | uiScanIdx = aucIntraLumaDirToScanIdx[max<UInt>(uiCTXIdx-1,0)][uiDirMode]; |
---|
4502 | } |
---|
4503 | } |
---|
4504 | |
---|
4505 | return uiScanIdx; |
---|
4506 | } |
---|
4507 | #endif //QC_MDCS |
---|
4508 | |
---|
4509 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
4510 | Bool TComDataCU::isSuroundingRefIdxException ( UInt uiAbsPartIdx ) |
---|
4511 | { |
---|
4512 | if ( !getSlice()->isInterB() ) |
---|
4513 | return true; |
---|
4514 | |
---|
4515 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) <= 2 && getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) <= 2) |
---|
4516 | { |
---|
4517 | return false; |
---|
4518 | } |
---|
4519 | |
---|
4520 | TComDataCU* pcTempCU; |
---|
4521 | UInt uiTempPartIdx; |
---|
4522 | TComMvField cMvFieldTemp; |
---|
4523 | |
---|
4524 | if ( getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 0 ) // combined list case |
---|
4525 | { |
---|
4526 | // Left PU |
---|
4527 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4528 | if ( pcTempCU ) |
---|
4529 | { |
---|
4530 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4531 | { |
---|
4532 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_0, pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4533 | return true; |
---|
4534 | } |
---|
4535 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4536 | { |
---|
4537 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_1, pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4538 | return true; |
---|
4539 | } |
---|
4540 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4541 | { |
---|
4542 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4543 | return true; |
---|
4544 | |
---|
4545 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4546 | return true; |
---|
4547 | } |
---|
4548 | } |
---|
4549 | |
---|
4550 | // Above PU |
---|
4551 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4552 | if ( pcTempCU ) |
---|
4553 | { |
---|
4554 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4555 | { |
---|
4556 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_0, pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4557 | return true; |
---|
4558 | } |
---|
4559 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4560 | { |
---|
4561 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_1, pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4562 | return true; |
---|
4563 | } |
---|
4564 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4565 | { |
---|
4566 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4567 | return true; |
---|
4568 | |
---|
4569 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4570 | return true; |
---|
4571 | } |
---|
4572 | } |
---|
4573 | |
---|
4574 | // Above left PU |
---|
4575 | pcTempCU = getPUAboveLeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4576 | if ( pcTempCU ) |
---|
4577 | { |
---|
4578 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4579 | { |
---|
4580 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_0, pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4581 | return true; |
---|
4582 | } |
---|
4583 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4584 | { |
---|
4585 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_1, pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4586 | return true; |
---|
4587 | } |
---|
4588 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4589 | { |
---|
4590 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4591 | return true; |
---|
4592 | |
---|
4593 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4594 | return true; |
---|
4595 | } |
---|
4596 | } |
---|
4597 | |
---|
4598 | return false; |
---|
4599 | } |
---|
4600 | |
---|
4601 | // not combined list case |
---|
4602 | // Left PU |
---|
4603 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4604 | if ( pcTempCU ) |
---|
4605 | { |
---|
4606 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4607 | { |
---|
4608 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4609 | return true; |
---|
4610 | } |
---|
4611 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4612 | { |
---|
4613 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4614 | return true; |
---|
4615 | } |
---|
4616 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4617 | { |
---|
4618 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4619 | return true; |
---|
4620 | |
---|
4621 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4622 | return true; |
---|
4623 | } |
---|
4624 | } |
---|
4625 | |
---|
4626 | // Above PU |
---|
4627 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4628 | if ( pcTempCU ) |
---|
4629 | { |
---|
4630 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4631 | { |
---|
4632 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4633 | return true; |
---|
4634 | } |
---|
4635 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4636 | { |
---|
4637 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4638 | return true; |
---|
4639 | } |
---|
4640 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4641 | { |
---|
4642 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4643 | return true; |
---|
4644 | |
---|
4645 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4646 | return true; |
---|
4647 | } |
---|
4648 | } |
---|
4649 | |
---|
4650 | // Above left PU |
---|
4651 | pcTempCU = getPUAboveLeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4652 | if ( pcTempCU ) |
---|
4653 | { |
---|
4654 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4655 | { |
---|
4656 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4657 | return true; |
---|
4658 | } |
---|
4659 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4660 | { |
---|
4661 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4662 | return true; |
---|
4663 | } |
---|
4664 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4665 | { |
---|
4666 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4667 | return true; |
---|
4668 | |
---|
4669 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4670 | return true; |
---|
4671 | } |
---|
4672 | } |
---|
4673 | |
---|
4674 | return false; |
---|
4675 | } |
---|
4676 | #endif |
---|
4677 | |
---|
4678 | Void TComDataCU::setTextureModeDepthSubParts( Int iTextureModeDepth, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
4679 | { |
---|
4680 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
4681 | |
---|
4682 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
4683 | { |
---|
4684 | m_piTextureModeDepth[uiAbsPartIdx + ui] = iTextureModeDepth; |
---|
4685 | } |
---|
4686 | } |
---|
4687 | |
---|
4688 | Void TComDataCU::copyTextureMotionDataFrom( TComDataCU* pcCU, UInt uiDepth, UInt uiAbsPartIdxSrc, UInt uiAbsPartIdxDst ) |
---|
4689 | { |
---|
4690 | assert( getSlice()->getSPS()->isDepth() && ! pcCU->getSlice()->getSPS()->isDepth() ); |
---|
4691 | UInt uiNumPartition = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
4692 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
4693 | Int iSizeInInt = sizeof( Int ) * uiNumPartition; |
---|
4694 | //#if HHI_MRG |
---|
4695 | // Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
4696 | //#endif |
---|
4697 | |
---|
4698 | // memcpy( m_pePartSize + uiAbsPartIdxDst, pcCU->getPartitionSize() + uiAbsPartIdxSrc, sizeof( PartSize ) * uiNumPartition ); |
---|
4699 | memcpy( m_pePredMode + uiAbsPartIdxDst, pcCU->getPredictionMode() + uiAbsPartIdxSrc, sizeof( PredMode ) * uiNumPartition ); |
---|
4700 | memcpy( m_puhInterDir + uiAbsPartIdxDst, pcCU->getInterDir() + uiAbsPartIdxSrc, iSizeInUchar ); |
---|
4701 | |
---|
4702 | //#if HHI_MRG |
---|
4703 | // m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
4704 | // m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
4705 | // for( UInt ui = 0; ui < HHI_NUM_MRG_CAND; ui ++ ) |
---|
4706 | // { |
---|
4707 | // m_apuhNeighbourCandIdx[ui] = pcCU->getNeighbourCandIdx( ui ) + uiAbsPartIdx; |
---|
4708 | // } |
---|
4709 | //#endif |
---|
4710 | |
---|
4711 | memcpy( m_apiMVPIdx[0] + uiAbsPartIdxDst, pcCU->getMVPIdx(REF_PIC_LIST_0) + uiAbsPartIdxSrc, iSizeInInt ); |
---|
4712 | memcpy( m_apiMVPIdx[1] + uiAbsPartIdxDst, pcCU->getMVPIdx(REF_PIC_LIST_1) + uiAbsPartIdxSrc, iSizeInInt ); |
---|
4713 | memcpy( m_apiMVPNum[0] + uiAbsPartIdxDst, pcCU->getMVPNum(REF_PIC_LIST_0) + uiAbsPartIdxSrc, iSizeInInt ); |
---|
4714 | memcpy( m_apiMVPNum[1] + uiAbsPartIdxDst, pcCU->getMVPNum(REF_PIC_LIST_1) + uiAbsPartIdxSrc, iSizeInInt ); |
---|
4715 | |
---|
4716 | // m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), 0 ); |
---|
4717 | // m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), 0 ); |
---|
4718 | |
---|
4719 | pcCU->getCUMvField( REF_PIC_LIST_0 )->copyTo( &m_acCUMvField[0], -Int(uiAbsPartIdxSrc) + uiAbsPartIdxDst, uiAbsPartIdxSrc, uiNumPartition ); |
---|
4720 | pcCU->getCUMvField( REF_PIC_LIST_1 )->copyTo( &m_acCUMvField[1], -Int(uiAbsPartIdxSrc) + uiAbsPartIdxDst, uiAbsPartIdxSrc, uiNumPartition ); |
---|
4721 | #if MW_DEPTH_MAP_INTERP_FILTER == 2 && MW_FULL_PEL_DEPTH_MAP_MV_SIGNALLING |
---|
4722 | for( UInt ui = 0; ui < uiNumPartition; ui++ ) |
---|
4723 | { |
---|
4724 | m_acCUMvField[0].getMv( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 ); |
---|
4725 | m_acCUMvField[0].getMv( uiAbsPartIdxDst + ui ) >>= 2; |
---|
4726 | |
---|
4727 | m_acCUMvField[1].getMv( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 ); |
---|
4728 | m_acCUMvField[1].getMv( uiAbsPartIdxDst + ui ) >>= 2; |
---|
4729 | |
---|
4730 | m_acCUMvField[0].getMvd( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 ); |
---|
4731 | m_acCUMvField[0].getMvd( uiAbsPartIdxDst + ui ) >>= 2; |
---|
4732 | |
---|
4733 | m_acCUMvField[1].getMvd( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 ); |
---|
4734 | m_acCUMvField[1].getMvd( uiAbsPartIdxDst + ui ) >>= 2; |
---|
4735 | } |
---|
4736 | #endif |
---|
4737 | } |
---|
4738 | |
---|
4739 | Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) |
---|
4740 | { |
---|
4741 | riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX(); |
---|
4742 | riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY(); |
---|
4743 | } |
---|