1 | |
---|
2 | |
---|
3 | #include "TComMP.h" |
---|
4 | //#include "../TLibSynth/TComMatrix.h" |
---|
5 | //#include "../TLibSynth/TSynthD2Z.h" |
---|
6 | //#include "../TLibSynth/TSynthZ2D.h" |
---|
7 | //#include "../TLibSynth/TSynthD2D.h" |
---|
8 | |
---|
9 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
10 | #include "../TLibCommon/TComDepthMapGenerator.h" |
---|
11 | #else |
---|
12 | #include "../../App/TAppCommon/TAppComCamPara.h" |
---|
13 | #endif |
---|
14 | |
---|
15 | #if POZNAN_MP |
---|
16 | |
---|
17 | |
---|
18 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
19 | TComMP::TComMP(UInt uiHeight, UInt uiWidth) |
---|
20 | #else |
---|
21 | //TComMP::TComMP(UInt uiHeight, UInt uiWidth, TAppComCamPara* pcCameraData) |
---|
22 | TComMP::TComMP(UInt uiHeight, UInt uiWidth, Int**** aiBaseViewShiftLUT) |
---|
23 | #endif |
---|
24 | { |
---|
25 | m_ppiMvPtCorrX = NULL; |
---|
26 | m_ppiMvPtCorrY = NULL; |
---|
27 | m_ppiMvPtCorrZ = NULL; |
---|
28 | m_ppiMvPtCorrRefViewIdx = NULL; |
---|
29 | m_pppcRefCU = NULL; |
---|
30 | m_ppuicRefPartAddr = NULL; |
---|
31 | |
---|
32 | m_bInit = false; |
---|
33 | m_bEnabled = false; |
---|
34 | m_bDBMPEnabled = false; |
---|
35 | |
---|
36 | m_uiHeight = 0; |
---|
37 | m_uiWidth = 0; |
---|
38 | |
---|
39 | m_pcRefPicsList = NULL; |
---|
40 | m_pcDepthRefPicsList = NULL; |
---|
41 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
42 | m_pcDepthMapGenerator = NULL; |
---|
43 | #else |
---|
44 | //m_pcCameraData = NULL; |
---|
45 | m_aiBaseViewShiftLUT = NULL; |
---|
46 | #if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE |
---|
47 | m_ppiTempMvPtCorrX = NULL; |
---|
48 | m_ppiTempMvPtCorrY = NULL; |
---|
49 | m_ppiTempMvPtCorrZ = NULL; |
---|
50 | #endif |
---|
51 | #endif |
---|
52 | |
---|
53 | #if POZNAN_DBMP_CALC_PRED_DATA |
---|
54 | m_piTempL0RefIdx = NULL; |
---|
55 | m_piTempL0MvX = NULL; |
---|
56 | m_piTempL0MvY = NULL; |
---|
57 | m_piTempL1RefIdx = NULL; |
---|
58 | m_piTempL1MvX = NULL; |
---|
59 | m_piTempL1MvY = NULL; |
---|
60 | |
---|
61 | m_piTempBuff = NULL; |
---|
62 | m_piResBuff = NULL; |
---|
63 | #endif |
---|
64 | |
---|
65 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
66 | if(uiHeight>0 && uiWidth>0) init(uiHeight, uiWidth); |
---|
67 | #else |
---|
68 | //if(uiHeight>0 && uiWidth>0) init(uiHeight, uiWidth, pcCameraData); |
---|
69 | if(uiHeight>0 && uiWidth>0) init(uiHeight, uiWidth, aiBaseViewShiftLUT); |
---|
70 | #endif |
---|
71 | } |
---|
72 | |
---|
73 | TComMP::~TComMP() |
---|
74 | { |
---|
75 | uninit(); |
---|
76 | } |
---|
77 | |
---|
78 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
79 | Void TComMP::init(UInt uiHeight, UInt uiWidth) |
---|
80 | #else |
---|
81 | //Void TComMP::init(UInt uiHeight, UInt uiWidth, TAppComCamPara* pcCameraData) |
---|
82 | Void TComMP::init(UInt uiHeight, UInt uiWidth, Int**** aiBaseViewShiftLUT) |
---|
83 | #endif |
---|
84 | { |
---|
85 | if(m_bInit) uninit(); |
---|
86 | |
---|
87 | m_bInit = true; |
---|
88 | m_bEnabled = false; |
---|
89 | m_bDBMPEnabled = false; |
---|
90 | |
---|
91 | m_uiHeight = uiHeight; |
---|
92 | m_uiWidth = uiWidth; |
---|
93 | |
---|
94 | m_pcRefPicsList = NULL; |
---|
95 | m_pcDepthRefPicsList = NULL; |
---|
96 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
97 | m_pcDepthMapGenerator = NULL; |
---|
98 | #else |
---|
99 | //m_pcCameraData = pcCameraData; |
---|
100 | m_aiBaseViewShiftLUT = aiBaseViewShiftLUT; |
---|
101 | #endif |
---|
102 | |
---|
103 | Short* piPtr; |
---|
104 | UShort* puiPtr; |
---|
105 | TComDataCU** ppcPtr; |
---|
106 | |
---|
107 | m_ppiMvPtCorrX = (Short**)malloc(sizeof(Short*)*m_uiHeight); |
---|
108 | piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth); |
---|
109 | for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiMvPtCorrX[i] = &(piPtr[addr]); |
---|
110 | |
---|
111 | m_ppiMvPtCorrY = (Short**)malloc(sizeof(Short*)*m_uiHeight); |
---|
112 | piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth); |
---|
113 | for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiMvPtCorrY[i] = &(piPtr[addr]); |
---|
114 | |
---|
115 | m_ppiMvPtCorrZ = (Short**)malloc(sizeof(Short*)*m_uiHeight); |
---|
116 | piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth); |
---|
117 | for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiMvPtCorrZ[i] = &(piPtr[addr]); |
---|
118 | |
---|
119 | m_ppiMvPtCorrRefViewIdx = (Short**)malloc(sizeof(Short*)*m_uiHeight); |
---|
120 | piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth); |
---|
121 | for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiMvPtCorrRefViewIdx[i] = &(piPtr[addr]); |
---|
122 | |
---|
123 | m_pppcRefCU = (TComDataCU***)malloc(sizeof(TComDataCU**)*m_uiHeight); |
---|
124 | ppcPtr = (TComDataCU**)malloc(sizeof(TComDataCU*)*m_uiHeight*m_uiWidth); |
---|
125 | for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_pppcRefCU[i] = &(ppcPtr[addr]); |
---|
126 | |
---|
127 | m_ppuicRefPartAddr = (UShort**)malloc(sizeof(UShort*)*m_uiHeight); |
---|
128 | puiPtr = (UShort*)malloc(sizeof(UShort)*m_uiHeight*m_uiWidth); |
---|
129 | for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppuicRefPartAddr[i] = &(puiPtr[addr]); |
---|
130 | |
---|
131 | #if !POZNAN_MP_USE_DEPTH_MAP_GENERATION && POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE |
---|
132 | m_ppiTempMvPtCorrX = (Short**)malloc(sizeof(Short*)*m_uiHeight); |
---|
133 | piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth); |
---|
134 | for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiTempMvPtCorrX[i] = &(piPtr[addr]); |
---|
135 | |
---|
136 | m_ppiTempMvPtCorrY = (Short**)malloc(sizeof(Short*)*m_uiHeight); |
---|
137 | piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth); |
---|
138 | for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiTempMvPtCorrY[i] = &(piPtr[addr]); |
---|
139 | |
---|
140 | m_ppiTempMvPtCorrZ = (Short**)malloc(sizeof(Short*)*m_uiHeight); |
---|
141 | piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth); |
---|
142 | for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiTempMvPtCorrZ[i] = &(piPtr[addr]); |
---|
143 | #endif |
---|
144 | |
---|
145 | #if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA |
---|
146 | m_ppiL0RefPOC.clear(); |
---|
147 | m_ppiL0MvX.clear(); |
---|
148 | m_ppiL0MvY.clear(); |
---|
149 | m_ppiL1RefPOC.clear(); |
---|
150 | m_ppiL1MvX.clear(); |
---|
151 | m_ppiL1MvY.clear(); |
---|
152 | #endif |
---|
153 | |
---|
154 | #if POZNAN_DBMP_CALC_PRED_DATA |
---|
155 | UInt uiSize = g_uiMaxCUHeight*g_uiMaxCUWidth; |
---|
156 | m_piTempL0RefIdx = new Int[uiSize]; |
---|
157 | m_piTempL0MvX = new Int[uiSize]; |
---|
158 | m_piTempL0MvY = new Int[uiSize]; |
---|
159 | m_piTempL1RefIdx = new Int[uiSize]; |
---|
160 | m_piTempL1MvX = new Int[uiSize]; |
---|
161 | m_piTempL1MvY = new Int[uiSize]; |
---|
162 | m_piTempBuff = new Int[uiSize]; |
---|
163 | m_piResBuff = new Int[uiSize]; |
---|
164 | #endif |
---|
165 | |
---|
166 | #if POZNAN_DBMP_CALC_PRED_DATA |
---|
167 | apcDBMPPredMVField[0] = new TComCUMvField(); apcDBMPPredMVField[0]->create(uiSize); |
---|
168 | apcDBMPPredMVField[1] = new TComCUMvField(); apcDBMPPredMVField[1]->create(uiSize); |
---|
169 | #endif |
---|
170 | |
---|
171 | } |
---|
172 | |
---|
173 | #if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA |
---|
174 | Void TComMP::initArrayMap(UInt uiViewId, Bool bIsDepth) |
---|
175 | { |
---|
176 | if(bIsDepth) uiViewId += MAX_NUMBER_VIEWS; |
---|
177 | |
---|
178 | if(m_ppiL0RefPOC.count(uiViewId)) return; |
---|
179 | |
---|
180 | PUT_MP_ARRAY_TYPE** ppiTemp; |
---|
181 | PUT_MP_ARRAY_TYPE* piTemp; |
---|
182 | |
---|
183 | /* |
---|
184 | ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth]; |
---|
185 | m_ppiL0RefPOC.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
186 | |
---|
187 | ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth]; |
---|
188 | m_ppiL0MvX.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
189 | |
---|
190 | ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth]; |
---|
191 | m_ppiL0MvY.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
192 | |
---|
193 | ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth]; |
---|
194 | m_ppiL1RefPOC.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
195 | |
---|
196 | ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth]; |
---|
197 | m_ppiL1MvX.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
198 | |
---|
199 | ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth]; |
---|
200 | m_ppiL1MvY.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
201 | */ |
---|
202 | |
---|
203 | ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); |
---|
204 | piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); |
---|
205 | for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]); |
---|
206 | m_ppiL0RefPOC.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
207 | |
---|
208 | ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); |
---|
209 | piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); |
---|
210 | for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]); |
---|
211 | m_ppiL0MvX.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
212 | |
---|
213 | ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); |
---|
214 | piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); |
---|
215 | for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]); |
---|
216 | m_ppiL0MvY.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
217 | |
---|
218 | ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); |
---|
219 | piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); |
---|
220 | for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]); |
---|
221 | m_ppiL1RefPOC.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
222 | |
---|
223 | ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); |
---|
224 | piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); |
---|
225 | for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]); |
---|
226 | m_ppiL1MvX.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
227 | |
---|
228 | ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); |
---|
229 | piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); |
---|
230 | for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]); |
---|
231 | m_ppiL1MvY.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp)); |
---|
232 | } |
---|
233 | #endif |
---|
234 | |
---|
235 | Void TComMP::uninit() |
---|
236 | { |
---|
237 | if(!m_bInit) return; |
---|
238 | |
---|
239 | m_bInit = false; |
---|
240 | m_bEnabled = false; |
---|
241 | m_bDBMPEnabled = false; |
---|
242 | |
---|
243 | m_pcRefPicsList = NULL; |
---|
244 | m_pcDepthRefPicsList = NULL; |
---|
245 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
246 | m_pcDepthMapGenerator = NULL; |
---|
247 | #else |
---|
248 | //m_pcCameraData = NULL; |
---|
249 | m_aiBaseViewShiftLUT = NULL; |
---|
250 | #endif |
---|
251 | |
---|
252 | if(m_ppiMvPtCorrX!=NULL) |
---|
253 | { |
---|
254 | //for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiMvPtCorrX[i]; |
---|
255 | //delete [] m_ppiMvPtCorrX; |
---|
256 | free(m_ppiMvPtCorrX[0]); |
---|
257 | free(m_ppiMvPtCorrX); |
---|
258 | m_ppiMvPtCorrX = NULL; |
---|
259 | } |
---|
260 | |
---|
261 | if(m_ppiMvPtCorrY!=NULL) |
---|
262 | { |
---|
263 | //for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiMvPtCorrY[i]; |
---|
264 | //delete [] m_ppiMvPtCorrY; |
---|
265 | free(m_ppiMvPtCorrY[0]); |
---|
266 | free(m_ppiMvPtCorrY); |
---|
267 | m_ppiMvPtCorrY = NULL; |
---|
268 | } |
---|
269 | |
---|
270 | if(m_ppiMvPtCorrZ!=NULL) |
---|
271 | { |
---|
272 | //for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiMvPtCorrZ[i]; |
---|
273 | //delete [] m_ppiMvPtCorrZ; |
---|
274 | free(m_ppiMvPtCorrZ[0]); |
---|
275 | free(m_ppiMvPtCorrZ); |
---|
276 | m_ppiMvPtCorrZ = NULL; |
---|
277 | } |
---|
278 | |
---|
279 | if(m_ppiMvPtCorrRefViewIdx!=NULL) |
---|
280 | { |
---|
281 | //for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiMvPtCorrRefViewIdx[i]; |
---|
282 | //delete [] m_ppiMvPtCorrRefViewIdx; |
---|
283 | free(m_ppiMvPtCorrRefViewIdx[0]); |
---|
284 | free(m_ppiMvPtCorrRefViewIdx); |
---|
285 | m_ppiMvPtCorrRefViewIdx = NULL; |
---|
286 | } |
---|
287 | |
---|
288 | if(m_pppcRefCU!=NULL) |
---|
289 | { |
---|
290 | //for(Int i=0;i<m_uiHeight;i++) delete [] m_pppcRefCU[i]; |
---|
291 | //delete [] m_pppcRefCU; |
---|
292 | free(m_pppcRefCU[0]); |
---|
293 | free(m_pppcRefCU); |
---|
294 | m_pppcRefCU = NULL; |
---|
295 | } |
---|
296 | |
---|
297 | if(m_ppuicRefPartAddr!=NULL) |
---|
298 | { |
---|
299 | //for(Int i=0;i<m_uiHeight;i++) delete [] m_ppuicRefPartAddr[i]; |
---|
300 | //delete [] m_ppuicRefPartAddr; |
---|
301 | free(m_ppuicRefPartAddr[0]); |
---|
302 | free(m_ppuicRefPartAddr); |
---|
303 | m_ppuicRefPartAddr = NULL; |
---|
304 | } |
---|
305 | |
---|
306 | #if !POZNAN_MP_USE_DEPTH_MAP_GENERATION && POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE |
---|
307 | if(m_ppiTempMvPtCorrX!=NULL) |
---|
308 | { |
---|
309 | //for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiTempMvPtCorrX[i]; |
---|
310 | //delete [] m_ppiTempMvPtCorrX; |
---|
311 | free(m_ppiTempMvPtCorrX[0]); |
---|
312 | free(m_ppiTempMvPtCorrX); |
---|
313 | m_ppiTempMvPtCorrX = NULL; |
---|
314 | } |
---|
315 | |
---|
316 | if(m_ppiTempMvPtCorrY!=NULL) |
---|
317 | { |
---|
318 | //for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiTempMvPtCorrY[i]; |
---|
319 | //delete [] m_ppiTempMvPtCorrY; |
---|
320 | free(m_ppiTempMvPtCorrY[0]); |
---|
321 | free(m_ppiTempMvPtCorrY); |
---|
322 | m_ppiTempMvPtCorrY = NULL; |
---|
323 | } |
---|
324 | |
---|
325 | if(m_ppiTempMvPtCorrZ!=NULL) |
---|
326 | { |
---|
327 | //for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiTempMvPtCorrZ[i]; |
---|
328 | //delete [] m_ppiTempMvPtCorrZ; |
---|
329 | free(m_ppiTempMvPtCorrZ[0]); |
---|
330 | free(m_ppiTempMvPtCorrZ); |
---|
331 | m_ppiTempMvPtCorrZ = NULL; |
---|
332 | } |
---|
333 | |
---|
334 | #endif |
---|
335 | |
---|
336 | #if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA |
---|
337 | PUT_MP_ARRAY_TYPE** ppiTemp; |
---|
338 | TComMapppi::const_iterator cMapIter; |
---|
339 | |
---|
340 | for (cMapIter = m_ppiL0RefPOC.begin(); cMapIter != m_ppiL0RefPOC.end(); cMapIter++) |
---|
341 | { |
---|
342 | ppiTemp = cMapIter->second; |
---|
343 | if(ppiTemp!=NULL) |
---|
344 | { |
---|
345 | //for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i]; |
---|
346 | //delete [] ppiTemp; |
---|
347 | free(ppiTemp[0]); |
---|
348 | free(ppiTemp); |
---|
349 | ppiTemp = NULL; |
---|
350 | } |
---|
351 | } |
---|
352 | |
---|
353 | for (cMapIter = m_ppiL0MvX.begin(); cMapIter != m_ppiL0MvX.end(); cMapIter++) |
---|
354 | { |
---|
355 | ppiTemp = cMapIter->second; |
---|
356 | if(ppiTemp!=NULL) |
---|
357 | { |
---|
358 | //for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i]; |
---|
359 | //delete [] ppiTemp; |
---|
360 | free(ppiTemp[0]); |
---|
361 | free(ppiTemp); |
---|
362 | ppiTemp = NULL; |
---|
363 | } |
---|
364 | } |
---|
365 | |
---|
366 | for (cMapIter = m_ppiL0MvY.begin(); cMapIter != m_ppiL0MvY.end(); cMapIter++) |
---|
367 | { |
---|
368 | ppiTemp = cMapIter->second; |
---|
369 | if(ppiTemp!=NULL) |
---|
370 | { |
---|
371 | //for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i]; |
---|
372 | //delete [] ppiTemp; |
---|
373 | free(ppiTemp[0]); |
---|
374 | free(ppiTemp); |
---|
375 | ppiTemp = NULL; |
---|
376 | } |
---|
377 | } |
---|
378 | |
---|
379 | for (cMapIter = m_ppiL1RefPOC.begin(); cMapIter != m_ppiL1RefPOC.end(); cMapIter++) |
---|
380 | { |
---|
381 | ppiTemp = cMapIter->second; |
---|
382 | if(ppiTemp!=NULL) |
---|
383 | { |
---|
384 | //for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i]; |
---|
385 | //delete [] ppiTemp; |
---|
386 | free(ppiTemp[0]); |
---|
387 | free(ppiTemp); |
---|
388 | ppiTemp = NULL; |
---|
389 | } |
---|
390 | } |
---|
391 | |
---|
392 | for (cMapIter = m_ppiL1MvX.begin(); cMapIter != m_ppiL1MvX.end(); cMapIter++) |
---|
393 | { |
---|
394 | ppiTemp = cMapIter->second; |
---|
395 | if(ppiTemp!=NULL) |
---|
396 | { |
---|
397 | //for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i]; |
---|
398 | //delete [] ppiTemp; |
---|
399 | free(ppiTemp[0]); |
---|
400 | free(ppiTemp); |
---|
401 | ppiTemp = NULL; |
---|
402 | } |
---|
403 | } |
---|
404 | |
---|
405 | for (cMapIter = m_ppiL1MvY.begin(); cMapIter != m_ppiL1MvY.end(); cMapIter++) |
---|
406 | { |
---|
407 | ppiTemp = cMapIter->second; |
---|
408 | if(ppiTemp!=NULL) |
---|
409 | { |
---|
410 | //for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i]; |
---|
411 | //delete [] ppiTemp; |
---|
412 | free(ppiTemp[0]); |
---|
413 | free(ppiTemp); |
---|
414 | ppiTemp = NULL; |
---|
415 | } |
---|
416 | } |
---|
417 | #endif |
---|
418 | |
---|
419 | #if POZNAN_DBMP_CALC_PRED_DATA |
---|
420 | if(m_piTempL0RefIdx!=NULL) { delete [] m_piTempL0RefIdx; m_piTempL0RefIdx = NULL; } |
---|
421 | if(m_piTempL0MvX!=NULL) { delete [] m_piTempL0MvX; m_piTempL0MvX = NULL; } |
---|
422 | if(m_piTempL0MvY!=NULL) { delete [] m_piTempL0MvY; m_piTempL0MvY = NULL; } |
---|
423 | if(m_piTempL1RefIdx!=NULL) { delete [] m_piTempL1RefIdx; m_piTempL1RefIdx = NULL; } |
---|
424 | if(m_piTempL1MvX!=NULL) { delete [] m_piTempL1MvX; m_piTempL1MvX = NULL; } |
---|
425 | if(m_piTempL1MvY!=NULL) { delete [] m_piTempL1MvY; m_piTempL1MvY = NULL; } |
---|
426 | if(m_piTempBuff!=NULL) { delete [] m_piTempBuff; m_piTempBuff = NULL; } |
---|
427 | if(m_piResBuff!=NULL) { delete [] m_piResBuff; m_piResBuff = NULL; } |
---|
428 | #endif |
---|
429 | |
---|
430 | #if POZNAN_DBMP_CALC_PRED_DATA |
---|
431 | apcDBMPPredMVField[0]->destroy(); delete apcDBMPPredMVField[0]; apcDBMPPredMVField[0] = NULL; |
---|
432 | apcDBMPPredMVField[1]->destroy(); delete apcDBMPPredMVField[1]; apcDBMPPredMVField[1] = NULL; |
---|
433 | #endif |
---|
434 | |
---|
435 | m_uiHeight = 0; |
---|
436 | m_uiWidth = 0; |
---|
437 | } |
---|
438 | |
---|
439 | Void TComMP::clear() |
---|
440 | { |
---|
441 | Int i,j; |
---|
442 | |
---|
443 | m_bEnabled = false; |
---|
444 | m_bDBMPEnabled = false; |
---|
445 | |
---|
446 | for(i=0;i<m_uiHeight;i++) |
---|
447 | for(j=0;j<m_uiWidth;j++) |
---|
448 | { |
---|
449 | m_ppiMvPtCorrX[i][j] = TComMP::OCCLUSION; |
---|
450 | m_ppiMvPtCorrY[i][j] = TComMP::OCCLUSION; |
---|
451 | //m_ppiMvPtCorrZ[i][j] = 0x7FFF; //Depth |
---|
452 | m_ppiMvPtCorrZ[i][j] = TComMP::OCCLUSION; //Disparity |
---|
453 | m_ppiMvPtCorrRefViewIdx[i][j] = TComMP::OCCLUSION; |
---|
454 | |
---|
455 | m_pppcRefCU[i][j] = NULL; |
---|
456 | m_ppuicRefPartAddr[i][j] = 0; |
---|
457 | } |
---|
458 | } |
---|
459 | |
---|
460 | Void TComMP::disable() |
---|
461 | { |
---|
462 | m_bEnabled = false; |
---|
463 | m_bDBMPEnabled = false; |
---|
464 | |
---|
465 | m_pcRefPicsList = NULL; |
---|
466 | m_pcDepthRefPicsList = NULL; |
---|
467 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
468 | m_pcDepthMapGenerator = NULL; |
---|
469 | #endif |
---|
470 | } |
---|
471 | |
---|
472 | #if !POZNAN_MP_USE_DEPTH_MAP_GENERATION && POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE |
---|
473 | Void TComMP::clearTemp() |
---|
474 | { |
---|
475 | if(!isInit()) return; |
---|
476 | |
---|
477 | for(Int i=0;i<m_uiHeight;i++) |
---|
478 | for(Int j=0;j<m_uiWidth;j++) |
---|
479 | { |
---|
480 | m_ppiTempMvPtCorrX[i][j] = TComMP::OCCLUSION; |
---|
481 | m_ppiTempMvPtCorrY[i][j] = TComMP::OCCLUSION; |
---|
482 | //m_ppiTempMvPtCorrZ[i][j] = 0x7FFF; //Depth |
---|
483 | m_ppiTempMvPtCorrZ[i][j] = TComMP::OCCLUSION; //Disparity |
---|
484 | } |
---|
485 | } |
---|
486 | #endif |
---|
487 | |
---|
488 | Bool TComMP::isInit() |
---|
489 | { |
---|
490 | return m_bInit; |
---|
491 | } |
---|
492 | |
---|
493 | Bool TComMP::isEnabled() |
---|
494 | { |
---|
495 | return m_bEnabled; |
---|
496 | } |
---|
497 | |
---|
498 | Bool TComMP::isDBMPEnabled() |
---|
499 | { |
---|
500 | return m_bDBMPEnabled; |
---|
501 | } |
---|
502 | |
---|
503 | Bool TComMP::pairMultiview(TComPic* pcPic) |
---|
504 | { |
---|
505 | m_bEnabled = false; |
---|
506 | m_bDBMPEnabled = false; |
---|
507 | |
---|
508 | if(!isInit() || pcPic==NULL) return false; |
---|
509 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
510 | if(m_pcDepthMapGenerator==NULL) return false; |
---|
511 | #else |
---|
512 | //if(m_pcCameraData==NULL) return false; |
---|
513 | if(m_aiBaseViewShiftLUT==NULL) return false; |
---|
514 | #endif |
---|
515 | //if(pcPic->getSlice(0)->isIntra()) return true; //no motion compenstation is used!!! |
---|
516 | |
---|
517 | UInt uiViewId = pcPic->getSPS()->getViewId(); //pcPic->getViewIdx();//??? |
---|
518 | UInt uiPOC = pcPic->getPOC(); |
---|
519 | Bool bIsDepth = pcPic->getSPS()->isDepth(); |
---|
520 | |
---|
521 | if(uiViewId==0) return true; //no reference view available!!! |
---|
522 | |
---|
523 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
524 | if(pcPic->getPredDepthMap()==NULL) return false; //no depth available!!! |
---|
525 | #else |
---|
526 | if(m_pcDepthRefPicsList->empty()) return false; //no depth in reference views available!!! |
---|
527 | #endif |
---|
528 | |
---|
529 | Int iRefX, iRefY; |
---|
530 | Int iCurX, iCurY; |
---|
531 | UInt uiRefViewId; |
---|
532 | TComPic* pcRefPic; |
---|
533 | Int iDisparity; |
---|
534 | TComDataCU* pcRefCU; |
---|
535 | |
---|
536 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
537 | Int iShiftX; |
---|
538 | Int iAddX; |
---|
539 | #else |
---|
540 | Int iSynthViewIdx; |
---|
541 | Int** ppiShiftLUTLeft; |
---|
542 | TComPic* pcDepthPic; |
---|
543 | Int iStride; |
---|
544 | Pel* pDepth; |
---|
545 | //Bool bIsLeft; |
---|
546 | Int iDepth; |
---|
547 | #if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE |
---|
548 | Int iSrcX, iSrcY; |
---|
549 | #endif |
---|
550 | #endif |
---|
551 | |
---|
552 | Bool bIsRefNoISliceAvailable = false; |
---|
553 | Bool bIsAnchorPicture = false; |
---|
554 | |
---|
555 | clear(); |
---|
556 | |
---|
557 | #if POZNAN_MP_USE_DEPTH_MAP_GENERATION |
---|
558 | for( UInt uiIdx = 0; uiIdx < uiViewId; uiIdx++ ) |
---|
559 | //for( UInt uiIdx = uiViewId-1; uiIdx >= uiViewId; uiIdx-- ) |
---|
560 | { |
---|
561 | uiRefViewId = m_pcDepthMapGenerator->getBaseViewId( uiIdx ); |
---|
562 | |
---|
563 | iShiftX = m_pcDepthMapGenerator->getSubSampExpX() + 2; |
---|
564 | iAddX = ( 1 << iShiftX ) >> 1; |
---|
565 | |
---|
566 | pcRefPic = (*m_pcRefPicsList)[uiRefViewId]; |
---|
567 | |
---|
568 | if(!pcRefPic->getSlice(0)->isIntra()) bIsRefNoISliceAvailable = true; |
---|
569 | else bIsAnchorPicture = true; |
---|
570 | |
---|
571 | for(iCurY=0; iCurY<(Int)m_uiHeight; iCurY++) |
---|
572 | for(iCurX=0; iCurX<(Int)m_uiWidth; iCurX++) |
---|
573 | if((m_ppiMvPtCorrX[iCurY][iCurX]==TComMP::OCCLUSION || m_ppiMvPtCorrY[iCurY][iCurX]==TComMP::OCCLUSION)) |
---|
574 | { |
---|
575 | iDisparity = m_pcDepthMapGenerator->getDisparity( pcPic, iCurX >> m_pcDepthMapGenerator->getSubSampExpX(), iCurY >> m_pcDepthMapGenerator->getSubSampExpY(), uiRefViewId ); |
---|
576 | iRefX = iCurX + ( ( iDisparity + iAddX ) >> iShiftX ); |
---|
577 | iRefY = iCurY; |
---|
578 | |
---|
579 | if(iRefX>=0 && iRefX<m_uiWidth && iRefY>=0 && iRefY<m_uiHeight) |
---|
580 | { |
---|
581 | //m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] = (Short)uiRefViewId; |
---|
582 | m_ppiMvPtCorrX[iCurY][iCurX] = (Short)iRefX; |
---|
583 | m_ppiMvPtCorrY[iCurY][iCurX] = (Short)iRefY; |
---|
584 | |
---|
585 | Pel* piPdmMap = pcPic->getPredDepthMap()->getLumaAddr( 0 ); |
---|
586 | Int iStride = pcPic->getPredDepthMap()->getStride (); |
---|
587 | Int iPrdDepth = piPdmMap[ iCurX + iCurY * iStride ]; |
---|
588 | m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iPrdDepth; |
---|
589 | //m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity; |
---|
590 | |
---|
591 | pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth())); |
---|
592 | |
---|
593 | m_pppcRefCU[iCurY][iCurX] = pcRefCU; |
---|
594 | m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()]; |
---|
595 | } |
---|
596 | } |
---|
597 | } |
---|
598 | #else |
---|
599 | |
---|
600 | #if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE |
---|
601 | //pcDepthPic = GetPicFromList(m_pcDepthRefPicsList, uiPOC, uiViewId); |
---|
602 | if(pcPic->getSlice(0)->getDepthPic()!=NULL && pcPic->getSlice(0)->getDepthPic()->getReconMark()) |
---|
603 | pcDepthPic = pcPic->getSlice(0)->getDepthPic(); |
---|
604 | else |
---|
605 | pcDepthPic = NULL; |
---|
606 | |
---|
607 | if(pcDepthPic!=NULL) |
---|
608 | { |
---|
609 | pDepth = pcDepthPic->getPicYuvRec()->getLumaAddr(); |
---|
610 | iStride = pcDepthPic->getPicYuvRec()->getStride(); |
---|
611 | |
---|
612 | for( UInt uiIdx = 0; uiIdx < uiViewId; uiIdx++ ) |
---|
613 | //for( UInt uiIdx = uiViewId-1; uiIdx >= uiViewId; uiIdx-- ) |
---|
614 | { |
---|
615 | uiRefViewId = uiIdx; |
---|
616 | |
---|
617 | pcRefPic = GetPicFromList(m_pcRefPicsList, uiPOC, uiRefViewId); |
---|
618 | assert(pcRefPic!=NULL);//test |
---|
619 | if(pcRefPic==NULL) return false; //No ref pic with current POC and RefView found in ref list!!! |
---|
620 | |
---|
621 | if(!pcRefPic->getSlice(0)->isIntra()) bIsRefNoISliceAvailable = true; |
---|
622 | else bIsAnchorPicture = true; |
---|
623 | |
---|
624 | //ppiShiftLUTLeft = m_pcCameraData->getBaseViewShiftLUTI()[uiViewId][uiRefViewId]; |
---|
625 | ppiShiftLUTLeft = m_aiBaseViewShiftLUT[uiViewId][uiRefViewId]; |
---|
626 | |
---|
627 | clearTemp(); |
---|
628 | |
---|
629 | for(iCurY=0; iCurY<(Int)m_uiHeight; iCurY++) |
---|
630 | for(iCurX=0; iCurX<(Int)m_uiWidth; iCurX++) |
---|
631 | { |
---|
632 | //Check if point already has its reference: |
---|
633 | if(m_ppiMvPtCorrX[iCurY][iCurX]!=TComMP::OCCLUSION && m_ppiMvPtCorrY[iCurY][iCurX]!=TComMP::OCCLUSION) continue; |
---|
634 | |
---|
635 | iDepth = pDepth[ iCurX + iCurY * iStride ]; |
---|
636 | iDepth = RemoveBitIncrement(iDepth); |
---|
637 | assert( iDepth >= 0 && iDepth <= 256 ); |
---|
638 | |
---|
639 | //if(bIsLeft) iDisparity = ppiShiftLUTLeft[0][iDepth]; |
---|
640 | //else iDisparity = -ppiShiftLUTLeft[0][iDepth]; |
---|
641 | iDisparity = ppiShiftLUTLeft[0][iDepth]; //!!! |
---|
642 | |
---|
643 | iRefX = iCurX - ( ( iDisparity + 2 ) >> 2 ); |
---|
644 | iRefY = iCurY; |
---|
645 | |
---|
646 | if(iRefX>=0 && iRefX<m_uiWidth && iRefY>=0 && iRefY<m_uiHeight) |
---|
647 | { |
---|
648 | iSrcX = m_ppiTempMvPtCorrX[iRefY][iRefX]; |
---|
649 | iSrcY = m_ppiTempMvPtCorrY[iRefY][iRefX]; |
---|
650 | |
---|
651 | if(iSrcX==TComMP::OCCLUSION || iSrcY==TComMP::OCCLUSION) |
---|
652 | { |
---|
653 | m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] = (Short)uiRefViewId; |
---|
654 | m_ppiMvPtCorrX[iCurY][iCurX] = (Short)iRefX; |
---|
655 | m_ppiMvPtCorrY[iCurY][iCurX] = (Short)iRefY; |
---|
656 | |
---|
657 | m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDepth; |
---|
658 | //m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity; |
---|
659 | |
---|
660 | pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth())); |
---|
661 | |
---|
662 | m_pppcRefCU[iCurY][iCurX] = pcRefCU; |
---|
663 | m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()]; |
---|
664 | |
---|
665 | m_ppiTempMvPtCorrX[iRefY][iRefX] = iCurX; |
---|
666 | m_ppiTempMvPtCorrY[iRefY][iRefX] = iCurY; |
---|
667 | m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDepth; |
---|
668 | //m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDisparity; |
---|
669 | } |
---|
670 | else if((Short)iDepth>m_ppiTempMvPtCorrZ[iRefY][iRefX]) //Point assigned earlier to this location is occluded |
---|
671 | //else if((Short)iDisparity>m_ppiTempMvPtCorrZ[iRefY][iRefX]) //Point assigned earlier to this location is occluded |
---|
672 | { |
---|
673 | m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] = (Short)uiRefViewId; |
---|
674 | m_ppiMvPtCorrX[iCurY][iCurX] = (Short)iRefX; |
---|
675 | m_ppiMvPtCorrY[iCurY][iCurX] = (Short)iRefY; |
---|
676 | |
---|
677 | m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDepth; |
---|
678 | //m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity; |
---|
679 | |
---|
680 | pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth())); |
---|
681 | |
---|
682 | m_pppcRefCU[iCurY][iCurX] = pcRefCU; |
---|
683 | m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()]; |
---|
684 | |
---|
685 | m_ppiTempMvPtCorrX[iRefY][iRefX] = iCurX; |
---|
686 | m_ppiTempMvPtCorrY[iRefY][iRefX] = iCurY; |
---|
687 | m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDepth; |
---|
688 | //m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDisparity; |
---|
689 | |
---|
690 | //Mark point assigned earlier to this location as occluded: |
---|
691 | m_ppiMvPtCorrRefViewIdx[iSrcY][iSrcX] = TComMP::OCCLUSION; |
---|
692 | m_ppiMvPtCorrX[iSrcY][iSrcX] = TComMP::OCCLUSION; |
---|
693 | m_ppiMvPtCorrY[iSrcY][iSrcX] = TComMP::OCCLUSION; |
---|
694 | |
---|
695 | //m_ppiMvPtCorrZ[iSrcY][iSrcX] = 0x7FFF; |
---|
696 | m_ppiMvPtCorrZ[iSrcY][iSrcX] = TComMP::OCCLUSION; |
---|
697 | |
---|
698 | m_pppcRefCU[iSrcY][iSrcX] = NULL; |
---|
699 | m_ppuicRefPartAddr[iSrcY][iSrcX] = 0; |
---|
700 | } |
---|
701 | } |
---|
702 | } |
---|
703 | } |
---|
704 | } |
---|
705 | else |
---|
706 | #endif |
---|
707 | { |
---|
708 | iSynthViewIdx = uiViewId; |
---|
709 | |
---|
710 | for( UInt uiIdx = 0; uiIdx < uiViewId; uiIdx++ ) |
---|
711 | //for( UInt uiIdx = uiViewId-1; uiIdx >= uiViewId; uiIdx-- ) |
---|
712 | { |
---|
713 | uiRefViewId = uiIdx; |
---|
714 | |
---|
715 | pcRefPic = GetPicFromList(m_pcRefPicsList, uiPOC, uiRefViewId); |
---|
716 | assert(pcRefPic!=NULL);//test |
---|
717 | if(pcRefPic==NULL) return false; //No ref pic with current POC and RefView found in ref list!!! |
---|
718 | |
---|
719 | if(!pcRefPic->getSlice(0)->isIntra()) bIsRefNoISliceAvailable = true; |
---|
720 | else bIsAnchorPicture = true; |
---|
721 | |
---|
722 | //ppiShiftLUTLeft = m_pcCameraData->getBaseViewShiftLUTI()[uiRefViewId][iSynthViewIdx]; |
---|
723 | ppiShiftLUTLeft = m_aiBaseViewShiftLUT[uiRefViewId][iSynthViewIdx]; |
---|
724 | |
---|
725 | pcDepthPic = GetPicFromList(m_pcDepthRefPicsList, uiPOC, uiRefViewId); |
---|
726 | assert(pcDepthPic!=NULL);//test |
---|
727 | if(pcDepthPic==NULL) return false; //No depth with current POC and RefView found in ref list!!! |
---|
728 | |
---|
729 | pDepth = pcDepthPic->getPicYuvRec()->getLumaAddr(); |
---|
730 | iStride = pcDepthPic->getPicYuvRec()->getStride(); |
---|
731 | |
---|
732 | //bIsLeft = m_pcCameraData->isLeftView(iSynthViewIdx, uiRefViewId); |
---|
733 | |
---|
734 | for(iRefY=0; iRefY<(Int)m_uiHeight; iRefY++) |
---|
735 | for(iRefX=0; iRefX<(Int)m_uiWidth; iRefX++) |
---|
736 | { |
---|
737 | iDepth = pDepth[ iRefX + iRefY * iStride ]; |
---|
738 | iDepth = RemoveBitIncrement(iDepth); |
---|
739 | assert( iDepth >= 0 && iDepth <= 256 ); |
---|
740 | |
---|
741 | //if(bIsLeft) iDisparity = ppiShiftLUTLeft[0][iDepth]; |
---|
742 | //else iDisparity = -ppiShiftLUTLeft[0][iDepth]; |
---|
743 | iDisparity = ppiShiftLUTLeft[0][iDepth]; //!!! |
---|
744 | |
---|
745 | iCurX = iRefX - ( ( iDisparity + 2 ) >> 2 ); |
---|
746 | iCurY = iRefY; |
---|
747 | |
---|
748 | if(iCurX>=0 && iCurX<m_uiWidth && iCurY>=0 && iCurY<m_uiHeight |
---|
749 | && ((m_ppiMvPtCorrX[iCurY][iCurX]==TComMP::OCCLUSION || m_ppiMvPtCorrY[iCurY][iCurX]==TComMP::OCCLUSION) |
---|
750 | || ((m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] == (Short)uiRefViewId) && (m_ppiMvPtCorrZ[iCurY][iCurX]<iDepth)))) |
---|
751 | { |
---|
752 | m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] = (Short)uiRefViewId; |
---|
753 | m_ppiMvPtCorrX[iCurY][iCurX] = (Short)iRefX; |
---|
754 | m_ppiMvPtCorrY[iCurY][iCurX] = (Short)iRefY; |
---|
755 | |
---|
756 | m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDepth; |
---|
757 | //m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity; |
---|
758 | |
---|
759 | pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth())); |
---|
760 | |
---|
761 | m_pppcRefCU[iCurY][iCurX] = pcRefCU; |
---|
762 | m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()]; |
---|
763 | } |
---|
764 | } |
---|
765 | } |
---|
766 | } |
---|
767 | #endif |
---|
768 | |
---|
769 | #if POZNAN_MP_FILL |
---|
770 | fillMultiview(uiViewId); |
---|
771 | #endif |
---|
772 | |
---|
773 | #if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA |
---|
774 | for( UInt uiIdx = 0; uiIdx <= uiViewId; uiIdx++ ) initArrayMap(uiIdx, bIsDepth); |
---|
775 | #endif |
---|
776 | |
---|
777 | m_uiView = uiViewId; |
---|
778 | m_uiPOC = uiPOC; |
---|
779 | m_bIsDepth = bIsDepth; |
---|
780 | m_bEnabled = true; |
---|
781 | |
---|
782 | #if POZNAN_DBMP |
---|
783 | m_bDBMPEnabled = (pcPic->getSPS()->getDBMP() > 0) & m_bEnabled & bIsRefNoISliceAvailable; //no reference view with motion data available |
---|
784 | #if POZNAN_DBMP_USE_IN_NONANCHOR_PIC_ONLY |
---|
785 | m_bDBMPEnabled &= !bIsAnchorPicture; //is non-anchor picture |
---|
786 | #endif |
---|
787 | #if !POZNAN_DBMP_USE_FOR_TEXTURE |
---|
788 | if(!m_bIsDepth) m_bDBMPEnabled = false; |
---|
789 | #endif |
---|
790 | #if !POZNAN_DBMP_USE_FOR_DEPTH |
---|
791 | if(m_bIsDepth) m_bDBMPEnabled = false; |
---|
792 | #endif |
---|
793 | #else |
---|
794 | m_bDBMPEnabled = false; |
---|
795 | #endif |
---|
796 | |
---|
797 | return true; |
---|
798 | |
---|
799 | } |
---|
800 | |
---|
801 | #if POZNAN_MP_FILL |
---|
802 | Void TComMP::fillMultiview(UInt uiViewId) |
---|
803 | { |
---|
804 | Int iPicXpos,iPicYpos; |
---|
805 | Int iRefXpos,iRefYpos; |
---|
806 | Int iRefXPos1,iRefYPos1,iRefXPos2,iRefYPos2; |
---|
807 | |
---|
808 | for(iPicYpos=0; iPicYpos<(Int)m_uiHeight;iPicYpos++) |
---|
809 | for(iPicXpos=0; iPicXpos<(Int)m_uiWidth;iPicXpos++) |
---|
810 | if(m_ppiMvPtCorrX[iPicYpos][iPicXpos] == TComMP::OCCLUSION) |
---|
811 | { |
---|
812 | //Check left-hand neighbours: |
---|
813 | iRefXPos1=TComMP::OCCLUSION; |
---|
814 | iRefYPos1=TComMP::OCCLUSION; |
---|
815 | |
---|
816 | iRefYpos=iPicYpos; |
---|
817 | for(iRefXpos=iPicXpos-1;iRefXpos>=0;iRefXpos--) |
---|
818 | if(m_ppiMvPtCorrX[iRefYpos][iRefXpos]!=TComMP::OCCLUSION)//Counterpart pixel in reference view exists |
---|
819 | { |
---|
820 | iRefXPos1 = iRefXpos; |
---|
821 | iRefYPos1 = iRefYpos; |
---|
822 | break; |
---|
823 | } |
---|
824 | |
---|
825 | //Check right-hand neighbours: |
---|
826 | iRefXPos2=TComMP::OCCLUSION; |
---|
827 | iRefYPos2=TComMP::OCCLUSION; |
---|
828 | |
---|
829 | iRefYpos=iPicYpos; |
---|
830 | for(iRefXpos=iPicXpos+1;iRefXpos<m_uiWidth;iRefXpos++) |
---|
831 | if(m_ppiMvPtCorrX[iRefYpos][iRefXpos]!=TComMP::OCCLUSION)//Counterpart pixel in reference view exists |
---|
832 | { |
---|
833 | iRefXPos2 = iRefXpos; |
---|
834 | iRefYPos2 = iRefYpos; |
---|
835 | break; |
---|
836 | } |
---|
837 | |
---|
838 | #if POZNAN_MP_FILL_TYPE==0 |
---|
839 | |
---|
840 | //Choose point with smaller disparity: |
---|
841 | if(iRefXPos1!=TComMP::OCCLUSION && iRefYPos1!=TComMP::OCCLUSION) |
---|
842 | { |
---|
843 | if(iRefXPos2!=TComMP::OCCLUSION && iRefYPos2!=TComMP::OCCLUSION && m_ppiMvPtCorrZ[iRefYPos1][iRefXPos1]>m_ppiMvPtCorrZ[iRefYPos2][iRefXPos2]) |
---|
844 | { |
---|
845 | iRefXpos=iRefXPos2; |
---|
846 | iRefYpos=iRefYPos2; |
---|
847 | } |
---|
848 | else |
---|
849 | { |
---|
850 | iRefXpos=iRefXPos1; |
---|
851 | iRefYpos=iRefYPos1; |
---|
852 | } |
---|
853 | } |
---|
854 | else |
---|
855 | { |
---|
856 | iRefXpos=iRefXPos2; |
---|
857 | iRefYpos=iRefYPos2; |
---|
858 | } |
---|
859 | if(iRefXpos==TComMP::OCCLUSION && iRefYpos==TComMP::OCCLUSION) continue; |
---|
860 | |
---|
861 | #elif POZNAN_MP_FILL_TYPE==1 |
---|
862 | |
---|
863 | //Choose point with larger disparity: |
---|
864 | if(iRefXPos1!=TComMP::OCCLUSION && iRefYPos1!=TComMP::OCCLUSION) |
---|
865 | { |
---|
866 | if(iRefXPos2!=TComMP::OCCLUSION && iRefYPos2!=TComMP::OCCLUSION && m_ppiMvPtCorrZ[iRefYPos1][iRefXPos1]<m_ppiMvPtCorrZ[iRefYPos2][iRefXPos2]) |
---|
867 | { |
---|
868 | iRefXpos=iRefXPos2; |
---|
869 | iRefYpos=iRefYPos2; |
---|
870 | } |
---|
871 | else |
---|
872 | { |
---|
873 | iRefXpos=iRefXPos1; |
---|
874 | iRefYpos=iRefYPos1; |
---|
875 | } |
---|
876 | } |
---|
877 | else |
---|
878 | { |
---|
879 | iRefXpos=iRefXPos2; |
---|
880 | iRefYpos=iRefYPos2; |
---|
881 | } |
---|
882 | if(iRefXpos==TComMP::OCCLUSION && iRefYpos==TComMP::OCCLUSION) continue; |
---|
883 | |
---|
884 | #else |
---|
885 | assert(0); |
---|
886 | #endif |
---|
887 | |
---|
888 | //m_ppiMvPtCorrRefViewIdx[iPicYpos][iPicXpos] = m_ppiMvPtCorrRefViewIdx[iRefYpos][iRefXpos]; |
---|
889 | m_ppiMvPtCorrX[iPicYpos][iPicXpos] = m_ppiMvPtCorrX[iRefYpos][iRefXpos]; //m_ppiMvPtCorrX[iPicYpos][iPicXpos] = iRefXpos; |
---|
890 | m_ppiMvPtCorrY[iPicYpos][iPicXpos] = m_ppiMvPtCorrY[iRefYpos][iRefXpos]; //m_ppiMvPtCorrY[iPicYpos][iPicXpos] = iRefYpos; |
---|
891 | |
---|
892 | //m_ppiMvPtCorrZ[iPicYpos][iPicXpos] = m_ppiMvPtCorrZ[iRefYpos][iRefXpos]; |
---|
893 | m_pppcRefCU[iPicYpos][iPicXpos] = m_pppcRefCU[iRefYpos][iRefXpos]; |
---|
894 | m_ppuicRefPartAddr[iPicYpos][iPicXpos] = m_ppuicRefPartAddr[iRefYpos][iRefXpos]; |
---|
895 | } |
---|
896 | |
---|
897 | return; |
---|
898 | } |
---|
899 | #endif |
---|
900 | |
---|
901 | TComPic* TComMP::GetPicFromList(std::vector<TComPic*>* pcListPic,UInt uiPOC, UInt uiView) //Get Pic from list based on POC ad View |
---|
902 | { |
---|
903 | // find current position |
---|
904 | std::vector<TComPic*>::iterator iterPic; |
---|
905 | TComPic* pcPic = NULL; |
---|
906 | |
---|
907 | for(iterPic = pcListPic->begin(); iterPic != pcListPic->end(); iterPic++) |
---|
908 | { |
---|
909 | pcPic = *(iterPic); |
---|
910 | if((pcPic->getPOC() == (Int)uiPOC) && (pcPic->getViewIdx() == (Int)uiView) && pcPic->getReconMark()) return pcPic; |
---|
911 | //if((pcPic->getPOC() == (Int)uiPOC) && (pcPic->getViewIdx() == (Int)uiView) ) return pcPic; |
---|
912 | } |
---|
913 | assert (0); |
---|
914 | |
---|
915 | return NULL; |
---|
916 | } |
---|
917 | |
---|
918 | Int TComMP::GetRepresentativeVal(UInt &uiCntMax, Int* piIn, UInt uiLen, Int* piTemp, Bool bUseRestrictedVal, Int iRestrictedVal) |
---|
919 | { |
---|
920 | UInt i,j,cnt,idx; |
---|
921 | |
---|
922 | uiCntMax = 0; idx = -1; |
---|
923 | for(i=0;i<uiLen;i++) piTemp[i] = 0; |
---|
924 | for(i=0;i<uiLen;i++) |
---|
925 | { |
---|
926 | if(piTemp[i] || (bUseRestrictedVal && piIn[i]==iRestrictedVal)) continue; |
---|
927 | cnt = 0; for(j=0;j<uiLen;j++) if(piIn[j]==piIn[i]) {cnt++; piTemp[j] = 1;} |
---|
928 | if(cnt>uiCntMax || (cnt==uiCntMax && abs(piIn[i])<abs(piIn[idx]))) {uiCntMax = cnt; idx = i;} |
---|
929 | } |
---|
930 | |
---|
931 | if(idx==-1) return iRestrictedVal; |
---|
932 | return piIn[idx]; |
---|
933 | } |
---|
934 | |
---|
935 | #if POZNAN_DBMP |
---|
936 | Void TComMP::getDBMPPredData(TComDataCU* pcCU, Int x, Int y, |
---|
937 | Int &ref_frame0, Int &ref_frame0_idx, TComMv &mv0, Int ref_frame0_idx_2nd, TComMv mv0_2nd, |
---|
938 | Int &ref_frame1, Int &ref_frame1_idx, TComMv &mv1, Int ref_frame1_idx_2nd, TComMv mv1_2nd) |
---|
939 | { |
---|
940 | UInt uiViewId = pcCU->getSlice()->getSPS()->getViewId(); |
---|
941 | Bool bIsDepth = pcCU->getSlice()->getSPS()->isDepth(); |
---|
942 | Int iRefIdx; |
---|
943 | TComPic* pcPic; |
---|
944 | TComMP* pcMP = pcCU->getSlice()->getMP(); |
---|
945 | |
---|
946 | TComDataCU*pcRefCU = pcMP->getMPCRefCU()[y][x]; |
---|
947 | UInt uiRefPartAddr = pcMP->getMPCRefPartAddr()[y][x]; |
---|
948 | |
---|
949 | Int x_ref = pcMP->getMPCx()[y][x]; |
---|
950 | Int y_ref = pcMP->getMPCy()[y][x]; |
---|
951 | |
---|
952 | ref_frame0 = -1; |
---|
953 | ref_frame1 = -1; |
---|
954 | |
---|
955 | if(pcRefCU != NULL) //Point has its counterpart in the reference view |
---|
956 | { |
---|
957 | #if !POZNAN_DBMP_COMPRESS_ME_DATA |
---|
958 | if(pcRefCU->getMergeIndex(uiRefPartAddr)==POZNAN_DBMP_MRG_CAND) |
---|
959 | { |
---|
960 | UInt uiRefViewId = pcRefCU->getSlice()->getSPS()->getViewId(); |
---|
961 | |
---|
962 | ref_frame0 = pcMP->getL0RefPOC(uiRefViewId, bIsDepth)[y_ref][x_ref]; |
---|
963 | mv0.setHor(pcMP->getL0MvX(uiRefViewId, bIsDepth)[y_ref][x_ref]); |
---|
964 | mv0.setVer(pcMP->getL0MvY(uiRefViewId, bIsDepth)[y_ref][x_ref]); |
---|
965 | |
---|
966 | ref_frame1 = pcMP->getL1RefPOC(uiRefViewId, bIsDepth)[y_ref][x_ref]; |
---|
967 | mv1.setHor(pcMP->getL1MvX(uiRefViewId, bIsDepth)[y_ref][x_ref]); |
---|
968 | mv1.setVer(pcMP->getL1MvY(uiRefViewId, bIsDepth)[y_ref][x_ref]); |
---|
969 | } |
---|
970 | else |
---|
971 | { |
---|
972 | #endif |
---|
973 | if(pcRefCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiRefPartAddr)>=0) |
---|
974 | { |
---|
975 | ref_frame0 = pcRefCU->getSlice()->getRefPOC( REF_PIC_LIST_0, pcRefCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiRefPartAddr) ); |
---|
976 | mv0 = pcRefCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiRefPartAddr ); |
---|
977 | } |
---|
978 | |
---|
979 | if(pcRefCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiRefPartAddr)>=0) |
---|
980 | { |
---|
981 | ref_frame1 = pcRefCU->getSlice()->getRefPOC( REF_PIC_LIST_1, pcRefCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiRefPartAddr) ); |
---|
982 | mv1 = pcRefCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiRefPartAddr ); |
---|
983 | } |
---|
984 | #if !POZNAN_DBMP_COMPRESS_ME_DATA |
---|
985 | } |
---|
986 | #endif |
---|
987 | } |
---|
988 | |
---|
989 | //Find ref_frame0 index on REF_PIC_LIST_0 |
---|
990 | ref_frame0_idx = -1; |
---|
991 | if(ref_frame0 != -1) |
---|
992 | { |
---|
993 | for( iRefIdx = 0; iRefIdx < pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0); iRefIdx++ ) |
---|
994 | { |
---|
995 | pcPic = pcCU->getSlice()->getRefPic( REF_PIC_LIST_0, iRefIdx ); |
---|
996 | if(ref_frame0 == pcPic->getPOC() && uiViewId==pcPic->getSPS()->getViewId()){ ref_frame0_idx = iRefIdx; break;} |
---|
997 | } |
---|
998 | if(ref_frame0_idx == -1) ref_frame0 = -1; |
---|
999 | } |
---|
1000 | //Find ref_frame1 index on REF_PIC_LIST_1 |
---|
1001 | ref_frame1_idx = -1; |
---|
1002 | if(ref_frame1 != -1) |
---|
1003 | { |
---|
1004 | for( iRefIdx = 0; iRefIdx < pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1); iRefIdx++ ) |
---|
1005 | { |
---|
1006 | pcPic = pcCU->getSlice()->getRefPic( REF_PIC_LIST_1, iRefIdx ); |
---|
1007 | if(ref_frame1 == pcPic->getPOC() && uiViewId==pcCU->getSlice()->getSPS()->getViewId()){ ref_frame1_idx = iRefIdx; break;} |
---|
1008 | } |
---|
1009 | if(ref_frame1_idx == -1) ref_frame1 = -1; |
---|
1010 | } |
---|
1011 | |
---|
1012 | if(ref_frame0_idx < 0 && ref_frame1_idx < 0) //No counterpart pixel in reference view found or no motion data was found |
---|
1013 | { |
---|
1014 | ref_frame0_idx = ref_frame0_idx_2nd; |
---|
1015 | mv0 = mv0_2nd; |
---|
1016 | if(ref_frame0_idx_2nd == -1) ref_frame0 = -1; |
---|
1017 | else ref_frame0 = pcCU->getSlice()->getRefPic( REF_PIC_LIST_0, ref_frame0_idx_2nd )->getPOC(); |
---|
1018 | |
---|
1019 | ref_frame1_idx = ref_frame1_idx_2nd; |
---|
1020 | mv1 = mv1_2nd; |
---|
1021 | if(ref_frame1_idx_2nd == -1) ref_frame1 = -1; |
---|
1022 | else ref_frame1 = pcCU->getSlice()->getRefPic( REF_PIC_LIST_1, ref_frame1_idx_2nd )->getPOC(); |
---|
1023 | } |
---|
1024 | else //Counterpart point with motion data was found |
---|
1025 | { |
---|
1026 | if(ref_frame0_idx < 0) |
---|
1027 | { |
---|
1028 | ref_frame0_idx = -1; |
---|
1029 | mv0.setZero(); |
---|
1030 | } |
---|
1031 | else |
---|
1032 | { |
---|
1033 | //use mv0 and RefIdx obtained by the DBMP algorithm |
---|
1034 | } |
---|
1035 | |
---|
1036 | if(ref_frame1_idx < 0) |
---|
1037 | { |
---|
1038 | ref_frame1_idx = -1; |
---|
1039 | mv1.setZero(); |
---|
1040 | } |
---|
1041 | else |
---|
1042 | { |
---|
1043 | //use mv0 and RefIdx obtained by the DBMP algorithm |
---|
1044 | } |
---|
1045 | } |
---|
1046 | } |
---|
1047 | |
---|
1048 | #if !POZNAN_DBMP_COMPRESS_ME_DATA |
---|
1049 | Void TComMP::saveDBMPData(TComDataCU* pcCU) |
---|
1050 | { |
---|
1051 | if(!isDBMPEnabled()) return; |
---|
1052 | |
---|
1053 | Int px,py,x,y,iCUBaseX,iCUBaseY; |
---|
1054 | |
---|
1055 | Int ref_frame0, ref_frame1; |
---|
1056 | Int ref_frame0_idx, ref_frame1_idx; |
---|
1057 | TComMv mv0,mv1; |
---|
1058 | |
---|
1059 | Int ref_frame0_idx_2nd, ref_frame1_idx_2nd; |
---|
1060 | TComMv mv0_2nd,mv1_2nd; |
---|
1061 | |
---|
1062 | UInt uiViewId = pcCU->getSlice()->getSPS()->getViewId(); |
---|
1063 | Bool bIsDepth = pcCU->getSlice()->getSPS()->isDepth(); |
---|
1064 | Int iWidth = g_uiMaxCUWidth>>g_uiMaxCUDepth; |
---|
1065 | Int iHeight = g_uiMaxCUHeight>>g_uiMaxCUDepth; |
---|
1066 | |
---|
1067 | for (UInt uiPartAddr = 0; uiPartAddr < pcCU->getTotalNumPart(); uiPartAddr++ ) |
---|
1068 | { |
---|
1069 | if(pcCU->getMergeIndex(uiPartAddr)==POZNAN_DBMP_MRG_CAND) |
---|
1070 | { |
---|
1071 | #if POZNAN_DBMP_CALC_PRED_DATA |
---|
1072 | ref_frame0_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getRefIdx(uiPartAddr); |
---|
1073 | mv0_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->getMv( uiPartAddr ); |
---|
1074 | |
---|
1075 | ref_frame1_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getRefIdx(uiPartAddr); |
---|
1076 | mv1_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->getMv( uiPartAddr ); |
---|
1077 | #else |
---|
1078 | ref_frame0_idx_2nd = pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartAddr); |
---|
1079 | mv0_2nd = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiPartAddr ); |
---|
1080 | |
---|
1081 | ref_frame1_idx_2nd = pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartAddr); |
---|
1082 | mv1_2nd = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiPartAddr ); |
---|
1083 | #endif |
---|
1084 | iCUBaseX = pcCU->getCUPelX()+g_auiRasterToPelX[ g_auiZscanToRaster[uiPartAddr] ]; |
---|
1085 | iCUBaseY = pcCU->getCUPelY()+g_auiRasterToPelY[ g_auiZscanToRaster[uiPartAddr] ]; |
---|
1086 | for( py = 0; py < iHeight; py++) |
---|
1087 | { |
---|
1088 | y = iCUBaseY+py; |
---|
1089 | for( px = 0; px < iWidth; px++) |
---|
1090 | { |
---|
1091 | x = iCUBaseX+px; |
---|
1092 | |
---|
1093 | getDBMPPredData(pcCU, x, y, ref_frame0, ref_frame0_idx, mv0, ref_frame0_idx_2nd, mv0_2nd, |
---|
1094 | ref_frame1, ref_frame1_idx, mv1, ref_frame1_idx_2nd, mv1_2nd); |
---|
1095 | |
---|
1096 | setL0RefPOC(uiViewId,bIsDepth,x,y,ref_frame0); |
---|
1097 | setL0MvX(uiViewId,bIsDepth,x,y,mv0.getHor()); |
---|
1098 | setL0MvY(uiViewId,bIsDepth,x,y,mv0.getVer()); |
---|
1099 | |
---|
1100 | setL1RefPOC(uiViewId,bIsDepth,x,y,ref_frame1); |
---|
1101 | setL1MvX(uiViewId,bIsDepth,x,y,mv1.getHor()); |
---|
1102 | setL1MvY(uiViewId,bIsDepth,x,y,mv1.getVer()); |
---|
1103 | } |
---|
1104 | } |
---|
1105 | } |
---|
1106 | } |
---|
1107 | } |
---|
1108 | #endif |
---|
1109 | #endif |
---|
1110 | |
---|
1111 | #if POZNAN_DBMP_CALC_PRED_DATA |
---|
1112 | Void TComMP::calcDBMPPredData(TComDataCU* pcCU, UInt uiAbsPartIdx, Int &ref_frame0_idx, TComMv &mv0, Int &ref_frame1_idx, TComMv &mv1) |
---|
1113 | { |
---|
1114 | if(!isDBMPEnabled() || pcCU->getMergeIndex(uiAbsPartIdx)!=POZNAN_DBMP_MRG_CAND) return; |
---|
1115 | |
---|
1116 | Int iWidth,iHeight; |
---|
1117 | Int x,y,iCUBaseX,iCUBaseY; |
---|
1118 | |
---|
1119 | switch(pcCU->getPartitionSize( uiAbsPartIdx )) |
---|
1120 | { |
---|
1121 | case SIZE_2Nx2N: |
---|
1122 | iWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
1123 | iHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
1124 | break; |
---|
1125 | case SIZE_2NxN: |
---|
1126 | iWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
1127 | iHeight = pcCU->getHeight(uiAbsPartIdx) >> 1; |
---|
1128 | break; |
---|
1129 | case SIZE_Nx2N: |
---|
1130 | iWidth = pcCU->getWidth(uiAbsPartIdx) >> 1; |
---|
1131 | iHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
1132 | break; |
---|
1133 | case SIZE_NxN: |
---|
1134 | iWidth = pcCU->getWidth(uiAbsPartIdx) >> 1; |
---|
1135 | iHeight = pcCU->getHeight(uiAbsPartIdx) >> 1; |
---|
1136 | break; |
---|
1137 | default: assert(0); |
---|
1138 | } |
---|
1139 | |
---|
1140 | Int ref_frame0, ref_frame1; |
---|
1141 | |
---|
1142 | Int ref_frame0_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getRefIdx(uiAbsPartIdx); |
---|
1143 | TComMv mv0_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->getMv( uiAbsPartIdx ); |
---|
1144 | |
---|
1145 | Int ref_frame1_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getRefIdx(uiAbsPartIdx); |
---|
1146 | TComMv mv1_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->getMv( uiAbsPartIdx ); |
---|
1147 | |
---|
1148 | iCUBaseX = pcCU->getCUPelX()+g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1149 | iCUBaseY = pcCU->getCUPelY()+g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1150 | |
---|
1151 | UInt uiPointCnt = 0; |
---|
1152 | |
---|
1153 | for( y = iCUBaseY; y < iCUBaseY+iHeight; y++) |
---|
1154 | for( x = iCUBaseX; x < iCUBaseX+iWidth; x++) |
---|
1155 | { |
---|
1156 | getDBMPPredData(pcCU, x, y, ref_frame0, ref_frame0_idx, mv0, ref_frame0_idx_2nd, mv0_2nd, |
---|
1157 | ref_frame1, ref_frame1_idx, mv1, ref_frame1_idx_2nd, mv1_2nd); |
---|
1158 | |
---|
1159 | m_piTempL0RefIdx[uiPointCnt] = ref_frame0_idx; |
---|
1160 | m_piTempL0MvX[uiPointCnt] = mv0.getHor(); |
---|
1161 | m_piTempL0MvY[uiPointCnt] = mv0.getVer(); |
---|
1162 | |
---|
1163 | m_piTempL1RefIdx[uiPointCnt] = ref_frame1_idx; |
---|
1164 | m_piTempL1MvX[uiPointCnt] = mv1.getHor(); |
---|
1165 | m_piTempL1MvY[uiPointCnt] = mv1.getVer(); |
---|
1166 | |
---|
1167 | uiPointCnt++; |
---|
1168 | } |
---|
1169 | |
---|
1170 | xCalcDBMPPredData(uiPointCnt, ref_frame0_idx, mv0, ref_frame1_idx, mv1); |
---|
1171 | } |
---|
1172 | |
---|
1173 | Void TComMP::setDBMPPredMVField(RefPicList eRefListIdx, TComDataCU* pcCU) |
---|
1174 | { |
---|
1175 | apcDBMPPredMVField[eRefListIdx]->copyFrom(pcCU->getCUMvField(eRefListIdx), pcCU->getTotalNumPart(), 0); |
---|
1176 | } |
---|
1177 | |
---|
1178 | Void TComMP::setDBMPPredMVField(RefPicList eRefListIdx, TComDataCU* pcCU, Int iNumPartSrc, Int iPartAddrDst) |
---|
1179 | { |
---|
1180 | apcDBMPPredMVField[eRefListIdx]->copyFrom(pcCU->getCUMvField(eRefListIdx), iNumPartSrc, iPartAddrDst); |
---|
1181 | } |
---|
1182 | #endif |
---|
1183 | |
---|
1184 | #if POZNAN_DBMP_CALC_PRED_DATA |
---|
1185 | Void TComMP::xCalcDBMPPredData(UInt uiCnt, Int &ref_frame0_idx, TComMv &mv0, Int &ref_frame1_idx, TComMv &mv1) |
---|
1186 | { |
---|
1187 | if(uiCnt==0) return; |
---|
1188 | |
---|
1189 | Int iVal; |
---|
1190 | UInt i,uiCntMax,uiCntTemp; |
---|
1191 | |
---|
1192 | //for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL0RefIdx[i]; iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff); ref_frame0_idx = iVal; |
---|
1193 | //for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL0MvX[i]; iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff); mv0.setHor(iVal); |
---|
1194 | //for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL0MvY[i]; iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff); mv0.setVer(iVal); |
---|
1195 | //for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL1RefIdx[i]; iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff); ref_frame1_idx = iVal; |
---|
1196 | //for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL1MvX[i]; iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff); mv1.setHor(iVal); |
---|
1197 | //for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL1MvY[i]; iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff); mv1.setVer(iVal); |
---|
1198 | |
---|
1199 | //iVal = GetRepresentativeVal(uiCntMax, m_piTempL0RefIdx, uiCnt, m_piTempBuff); ref_frame0_idx = iVal; |
---|
1200 | //iVal = GetRepresentativeVal(uiCntMax, m_piTempL0MvX, uiCnt, m_piTempBuff); mv0.setHor(iVal); |
---|
1201 | //iVal = GetRepresentativeVal(uiCntMax, m_piTempL0MvY, uiCnt, m_piTempBuff); mv0.setVer(iVal); |
---|
1202 | //iVal = GetRepresentativeVal(uiCntMax, m_piTempL1RefIdx, uiCnt, m_piTempBuff); ref_frame1_idx = iVal; |
---|
1203 | //iVal = GetRepresentativeVal(uiCntMax, m_piTempL1MvX, uiCnt, m_piTempBuff); mv1.setHor(iVal); |
---|
1204 | //iVal = GetRepresentativeVal(uiCntMax, m_piTempL1MvY, uiCnt, m_piTempBuff); mv1.setVer(iVal); |
---|
1205 | |
---|
1206 | iVal = GetRepresentativeVal(uiCntMax, m_piTempL0RefIdx, uiCnt, m_piTempBuff); ref_frame0_idx = iVal; |
---|
1207 | //if(ref_frame0_idx==-1 && (uiCntMax<<1)==uiCnt) |
---|
1208 | //{ |
---|
1209 | // iVal = GetRepresentativeVal(uiCntMax, m_piTempL0RefIdx, uiCnt, m_piTempBuff, true, -1); |
---|
1210 | // if((uiCntMax<<1)==uiCnt) ref_frame0_idx = iVal; |
---|
1211 | //} |
---|
1212 | //if((uiCntMax<<1)==uiCnt) |
---|
1213 | //{ |
---|
1214 | // iVal = GetRepresentativeVal(uiCntMax, m_piTempL0RefIdx, uiCnt, m_piTempBuff, true, ref_frame0_idx); |
---|
1215 | // if((uiCntMax<<1)==uiCnt && (ref_frame0_idx==-1 || (iVal!=-1 && iVal<ref_frame0_idx))) ref_frame0_idx = iVal; |
---|
1216 | //} |
---|
1217 | if((uiCntMax<<1)<=uiCnt) |
---|
1218 | { |
---|
1219 | iVal = GetRepresentativeVal(uiCntTemp, m_piTempL0RefIdx, uiCnt, m_piTempBuff, true, ref_frame0_idx); |
---|
1220 | if(uiCntTemp==uiCntMax && (ref_frame0_idx==-1 || (iVal!=-1 && iVal<ref_frame0_idx))) ref_frame0_idx = iVal; |
---|
1221 | } |
---|
1222 | |
---|
1223 | iVal = GetRepresentativeVal(uiCntMax, m_piTempL1RefIdx, uiCnt, m_piTempBuff); ref_frame1_idx = iVal; |
---|
1224 | //if(ref_frame1_idx==-1 && (uiCntMax<<1)==uiCnt) |
---|
1225 | //{ |
---|
1226 | // iVal = GetRepresentativeVal(uiCntMax, m_piTempL1RefIdx, uiCnt, m_piTempBuff, true, -1); |
---|
1227 | // if((uiCntMax<<1)==uiCnt) ref_frame1_idx = iVal; |
---|
1228 | //} |
---|
1229 | //if((uiCntMax<<1)==uiCnt) |
---|
1230 | //{ |
---|
1231 | // iVal = GetRepresentativeVal(uiCntMax, m_piTempL1RefIdx, uiCnt, m_piTempBuff, true, ref_frame1_idx); |
---|
1232 | // if((uiCntMax<<1)==uiCnt && (ref_frame1_idx==-1 || (iVal!=-1 && iVal<ref_frame1_idx))) ref_frame1_idx = iVal; |
---|
1233 | //} |
---|
1234 | if((uiCntMax<<1)<=uiCnt) |
---|
1235 | { |
---|
1236 | iVal = GetRepresentativeVal(uiCntTemp, m_piTempL1RefIdx, uiCnt, m_piTempBuff, true, ref_frame1_idx); |
---|
1237 | if(uiCntTemp==uiCntMax && (ref_frame1_idx==-1 || (iVal!=-1 && iVal<ref_frame1_idx))) ref_frame1_idx = iVal; |
---|
1238 | } |
---|
1239 | |
---|
1240 | if(ref_frame0_idx==-1 && ref_frame1_idx==-1) |
---|
1241 | { |
---|
1242 | iVal = GetRepresentativeVal(uiCntMax, m_piTempL0RefIdx, uiCnt, m_piTempBuff, true, -1); ref_frame0_idx = iVal; |
---|
1243 | iVal = GetRepresentativeVal(uiCntMax, m_piTempL1RefIdx, uiCnt, m_piTempBuff, true, -1); ref_frame1_idx = iVal; |
---|
1244 | } |
---|
1245 | |
---|
1246 | if(ref_frame0_idx==-1) |
---|
1247 | { |
---|
1248 | mv0.setHor(0); |
---|
1249 | mv0.setVer(0); |
---|
1250 | } |
---|
1251 | else |
---|
1252 | { |
---|
1253 | uiCntTemp=0; for(i=0;i<uiCnt;i++) if(m_piTempL0RefIdx[i]==ref_frame0_idx) m_piResBuff[uiCntTemp++] = (Int)m_piTempL0MvX[i]; |
---|
1254 | iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCntTemp, m_piTempBuff); mv0.setHor(iVal); |
---|
1255 | |
---|
1256 | uiCntTemp=0; for(i=0;i<uiCnt;i++) if(m_piTempL0RefIdx[i]==ref_frame0_idx) m_piResBuff[uiCntTemp++] = (Int)m_piTempL0MvY[i]; |
---|
1257 | iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCntTemp, m_piTempBuff); mv0.setVer(iVal); |
---|
1258 | } |
---|
1259 | |
---|
1260 | if(ref_frame1_idx==-1) |
---|
1261 | { |
---|
1262 | mv1.setHor(0); |
---|
1263 | mv1.setVer(0); |
---|
1264 | } |
---|
1265 | else |
---|
1266 | { |
---|
1267 | uiCntTemp=0; for(i=0;i<uiCnt;i++) if(m_piTempL1RefIdx[i]==ref_frame1_idx) m_piResBuff[uiCntTemp++] = (Int)m_piTempL1MvX[i]; |
---|
1268 | iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCntTemp, m_piTempBuff); mv1.setHor(iVal); |
---|
1269 | |
---|
1270 | uiCntTemp=0; for(i=0;i<uiCnt;i++) if(m_piTempL1RefIdx[i]==ref_frame1_idx) m_piResBuff[uiCntTemp++] = (Int)m_piTempL1MvY[i]; |
---|
1271 | iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCntTemp, m_piTempBuff); mv1.setVer(iVal); |
---|
1272 | } |
---|
1273 | } |
---|
1274 | #endif |
---|
1275 | |
---|
1276 | |
---|
1277 | |
---|
1278 | |
---|
1279 | #endif // POZNAN_MP |
---|