1 | |
---|
2 | |
---|
3 | #include <list> |
---|
4 | #include <stdio.h> |
---|
5 | #include <fcntl.h> |
---|
6 | #include <assert.h> |
---|
7 | #include <math.h> |
---|
8 | |
---|
9 | #include "TAppRendererTop.h" |
---|
10 | |
---|
11 | // ==================================================================================================================== |
---|
12 | // Constructor / destructor / initialization / destroy |
---|
13 | // ==================================================================================================================== |
---|
14 | |
---|
15 | TAppRendererTop::TAppRendererTop() |
---|
16 | { |
---|
17 | |
---|
18 | } |
---|
19 | |
---|
20 | TAppRendererTop::~TAppRendererTop() |
---|
21 | { |
---|
22 | |
---|
23 | } |
---|
24 | |
---|
25 | |
---|
26 | Void TAppRendererTop::xCreateLib() |
---|
27 | { |
---|
28 | Int iInteralBitDepth = g_uiBitDepth + g_uiBitIncrement; |
---|
29 | Int iFileBitDepth = 8; |
---|
30 | m_pcRenTop = new TRenTop(); |
---|
31 | |
---|
32 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfInputViews; iViewIdx++) |
---|
33 | { |
---|
34 | TVideoIOYuv* pcVideoInput = new TVideoIOYuv; |
---|
35 | TVideoIOYuv* pcDepthInput = new TVideoIOYuv; |
---|
36 | |
---|
37 | pcVideoInput->open( m_pchVideoInputFileList[iViewIdx], false, iFileBitDepth, iInteralBitDepth ); // read mode |
---|
38 | pcDepthInput->open( m_pchDepthInputFileList[iViewIdx], false, iFileBitDepth, iInteralBitDepth ); // read mode |
---|
39 | |
---|
40 | m_apcTVideoIOYuvVideoInput.push_back( pcVideoInput ); |
---|
41 | m_apcTVideoIOYuvDepthInput.push_back( pcDepthInput ); |
---|
42 | } |
---|
43 | |
---|
44 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfOutputViews; iViewIdx++) |
---|
45 | { |
---|
46 | TVideoIOYuv* pcSynthOutput = new TVideoIOYuv; |
---|
47 | pcSynthOutput->open( m_pchSynthOutputFileList[iViewIdx], true, iFileBitDepth, iInteralBitDepth ); // write mode |
---|
48 | m_apcTVideoIOYuvSynthOutput.push_back( pcSynthOutput ); |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | Void TAppRendererTop::xDestroyLib() |
---|
54 | { |
---|
55 | delete m_pcRenTop; |
---|
56 | |
---|
57 | for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfInputViews; iViewIdx++ ) |
---|
58 | { |
---|
59 | m_apcTVideoIOYuvVideoInput[iViewIdx]->close(); |
---|
60 | m_apcTVideoIOYuvDepthInput[iViewIdx]->close(); |
---|
61 | |
---|
62 | delete m_apcTVideoIOYuvDepthInput[iViewIdx]; |
---|
63 | delete m_apcTVideoIOYuvVideoInput[iViewIdx]; |
---|
64 | }; |
---|
65 | |
---|
66 | for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfOutputViews; iViewIdx++ ) |
---|
67 | { |
---|
68 | m_apcTVideoIOYuvSynthOutput[iViewIdx]->close(); |
---|
69 | delete m_apcTVideoIOYuvSynthOutput[iViewIdx]; |
---|
70 | }; |
---|
71 | } |
---|
72 | |
---|
73 | Void TAppRendererTop::xInitLib() |
---|
74 | { |
---|
75 | m_pcRenTop->init( |
---|
76 | m_iSourceWidth, |
---|
77 | m_iSourceHeight, |
---|
78 | (m_iRenderDirection != 0), |
---|
79 | m_iLog2SamplingFactor, |
---|
80 | m_iLog2SamplingFactor+m_iShiftPrecision, |
---|
81 | m_bUVUp, |
---|
82 | m_iPreProcMode, |
---|
83 | m_iPreFilterSize, |
---|
84 | m_iBlendMode, |
---|
85 | m_iBlendZThresPerc, |
---|
86 | m_bBlendUseDistWeight, |
---|
87 | m_iBlendHoleMargin, |
---|
88 | m_iInterpolationMode, |
---|
89 | m_iHoleFillingMode, |
---|
90 | m_iPostProcMode, |
---|
91 | m_iUsedPelMapMarExt |
---|
92 | ); |
---|
93 | } |
---|
94 | |
---|
95 | // ==================================================================================================================== |
---|
96 | // Public member functions |
---|
97 | // ==================================================================================================================== |
---|
98 | |
---|
99 | |
---|
100 | |
---|
101 | Void TAppRendererTop::render() |
---|
102 | { |
---|
103 | xCreateLib(); |
---|
104 | xInitLib(); |
---|
105 | |
---|
106 | // Create Buffers Input Views; |
---|
107 | std::vector<TComPicYuv*> apcPicYuvBaseVideo; |
---|
108 | std::vector<TComPicYuv*> apcPicYuvBaseDepth; |
---|
109 | |
---|
110 | // TemporalImprovement Filter |
---|
111 | std::vector<TComPicYuv*> apcPicYuvLastBaseVideo; |
---|
112 | std::vector<TComPicYuv*> apcPicYuvLastBaseDepth; |
---|
113 | |
---|
114 | Int aiPad[2] = { 0, 0 }; |
---|
115 | |
---|
116 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
117 | { |
---|
118 | TComPicYuv* pcNewVideoPic = new TComPicYuv; |
---|
119 | TComPicYuv* pcNewDepthPic = new TComPicYuv; |
---|
120 | |
---|
121 | pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
122 | apcPicYuvBaseVideo.push_back(pcNewVideoPic); |
---|
123 | |
---|
124 | pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
125 | apcPicYuvBaseDepth.push_back(pcNewDepthPic); |
---|
126 | |
---|
127 | //Temporal improvement Filter |
---|
128 | if ( m_bTempDepthFilter ) |
---|
129 | { |
---|
130 | pcNewVideoPic = new TComPicYuv; |
---|
131 | pcNewDepthPic = new TComPicYuv; |
---|
132 | |
---|
133 | pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
134 | apcPicYuvLastBaseVideo.push_back(pcNewVideoPic); |
---|
135 | |
---|
136 | pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
137 | apcPicYuvLastBaseDepth.push_back(pcNewDepthPic); |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | // Create Buffer for synthesized View |
---|
142 | TComPicYuv* pcPicYuvSynthOut = new TComPicYuv; |
---|
143 | pcPicYuvSynthOut->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
144 | |
---|
145 | Bool bAnyEOS = false; |
---|
146 | |
---|
147 | Int iNumOfRenderedFrames = 0; |
---|
148 | Int iFrame = 0; |
---|
149 | |
---|
150 | while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS ) |
---|
151 | { |
---|
152 | |
---|
153 | // read in depth and video |
---|
154 | for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ ) |
---|
155 | { |
---|
156 | m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad ) ; |
---|
157 | apcPicYuvBaseVideo[iBaseViewIdx]->extendPicBorder(); |
---|
158 | bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof(); |
---|
159 | |
---|
160 | m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad ) ; |
---|
161 | apcPicYuvBaseDepth[iBaseViewIdx]->extendPicBorder(); |
---|
162 | bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof(); |
---|
163 | |
---|
164 | if ( m_bTempDepthFilter && (iFrame >= m_iFrameSkip) ) |
---|
165 | { |
---|
166 | m_pcRenTop->temporalFilterVSRS( apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], apcPicYuvLastBaseVideo[iBaseViewIdx], apcPicYuvLastBaseDepth[iBaseViewIdx], ( iFrame == m_iFrameSkip) ); |
---|
167 | } |
---|
168 | } |
---|
169 | |
---|
170 | if ( iFrame < m_iFrameSkip ) // Skip Frames |
---|
171 | { |
---|
172 | std::cout << "Skipping Frame " << iFrame << std::endl; |
---|
173 | |
---|
174 | iFrame++; |
---|
175 | continue; |
---|
176 | } |
---|
177 | |
---|
178 | m_cCameraData.update( (UInt)iFrame ); |
---|
179 | |
---|
180 | for(Int iSynthViewIdx=0; iSynthViewIdx < m_iNumberOfOutputViews; iSynthViewIdx++ ) |
---|
181 | { |
---|
182 | Int iLeftBaseViewIdx = -1; |
---|
183 | Int iRightBaseViewIdx = -1; |
---|
184 | |
---|
185 | Bool bIsBaseView = false; |
---|
186 | |
---|
187 | Int iRelDistToLeft; |
---|
188 | Bool bHasLRView = m_cCameraData.getLeftRightBaseView( iSynthViewIdx, iLeftBaseViewIdx, iRightBaseViewIdx, iRelDistToLeft, bIsBaseView ); |
---|
189 | Bool bHasLView = ( iLeftBaseViewIdx != -1 ); |
---|
190 | Bool bHasRView = ( iRightBaseViewIdx != -1 ); |
---|
191 | Bool bRender = true; |
---|
192 | |
---|
193 | Int iBlendMode = m_iBlendMode; |
---|
194 | Int iSimEnhBaseView = 0; |
---|
195 | |
---|
196 | switch( m_iRenderDirection ) |
---|
197 | { |
---|
198 | /// INTERPOLATION |
---|
199 | case 0: |
---|
200 | AOF( bHasLRView || bIsBaseView ); |
---|
201 | |
---|
202 | if ( !bHasLRView && bIsBaseView && m_iBlendMode == 0 ) |
---|
203 | { |
---|
204 | bRender = false; |
---|
205 | } |
---|
206 | else |
---|
207 | { |
---|
208 | if ( bIsBaseView ) |
---|
209 | { |
---|
210 | AOF( iLeftBaseViewIdx == iRightBaseViewIdx ); |
---|
211 | Int iSortedBaseViewIdx = m_cCameraData.getBaseId2SortedId() [iLeftBaseViewIdx]; |
---|
212 | |
---|
213 | if ( m_iBlendMode == 1 ) |
---|
214 | { |
---|
215 | if ( iSortedBaseViewIdx - 1 >= 0 ) |
---|
216 | { |
---|
217 | iLeftBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iSortedBaseViewIdx - 1]; |
---|
218 | bRender = true; |
---|
219 | } |
---|
220 | else |
---|
221 | { |
---|
222 | bRender = false; |
---|
223 | } |
---|
224 | } |
---|
225 | else if ( m_iBlendMode == 2 ) |
---|
226 | { |
---|
227 | if ( iSortedBaseViewIdx + 1 < m_iNumberOfInputViews ) |
---|
228 | { |
---|
229 | iRightBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iSortedBaseViewIdx + 1]; |
---|
230 | bRender = true; |
---|
231 | } |
---|
232 | else |
---|
233 | { |
---|
234 | bRender = false; |
---|
235 | } |
---|
236 | } |
---|
237 | } |
---|
238 | |
---|
239 | if ( m_iBlendMode == 3 ) |
---|
240 | { |
---|
241 | if ( bIsBaseView && (iLeftBaseViewIdx == 0) ) |
---|
242 | { |
---|
243 | bRender = false; |
---|
244 | } |
---|
245 | else |
---|
246 | { |
---|
247 | Int iDistLeft = abs( m_cCameraData.getBaseId2SortedId()[0] - m_cCameraData.getBaseId2SortedId() [iLeftBaseViewIdx ] ); |
---|
248 | Int iDistRight = abs( m_cCameraData.getBaseId2SortedId()[0] - m_cCameraData.getBaseId2SortedId() [iRightBaseViewIdx] ); |
---|
249 | |
---|
250 | Int iFillViewIdx = iDistLeft > iDistRight ? iLeftBaseViewIdx : iRightBaseViewIdx; |
---|
251 | |
---|
252 | if( m_cCameraData.getBaseId2SortedId()[0] < m_cCameraData.getBaseId2SortedId() [iFillViewIdx] ) |
---|
253 | { |
---|
254 | iBlendMode = 1; |
---|
255 | iLeftBaseViewIdx = 0; |
---|
256 | iRightBaseViewIdx = iFillViewIdx; |
---|
257 | } |
---|
258 | else |
---|
259 | { |
---|
260 | iBlendMode = 2; |
---|
261 | iLeftBaseViewIdx = iFillViewIdx; |
---|
262 | iRightBaseViewIdx = 0; |
---|
263 | } |
---|
264 | |
---|
265 | } |
---|
266 | } |
---|
267 | else |
---|
268 | { |
---|
269 | iBlendMode = m_iBlendMode; |
---|
270 | } |
---|
271 | } |
---|
272 | |
---|
273 | if ( m_bSimEnhance ) |
---|
274 | { |
---|
275 | if ( m_iNumberOfInputViews == 3 && m_cCameraData.getRelSynthViewNumbers()[ iSynthViewIdx ] < VIEW_NUM_PREC ) |
---|
276 | { |
---|
277 | iSimEnhBaseView = 2; // Take middle view |
---|
278 | } |
---|
279 | else |
---|
280 | { |
---|
281 | iSimEnhBaseView = 1; // Take left view |
---|
282 | } |
---|
283 | } |
---|
284 | |
---|
285 | if ( bRender ) |
---|
286 | { |
---|
287 | std::cout << "Rendering Frame " << iFrame |
---|
288 | << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx ] / VIEW_NUM_PREC |
---|
289 | << " Left BaseView: " << (Double) m_cCameraData.getBaseViewNumbers() [iLeftBaseViewIdx ] / VIEW_NUM_PREC |
---|
290 | << " Right BaseView: " << (Double) m_cCameraData.getBaseViewNumbers() [iRightBaseViewIdx] / VIEW_NUM_PREC |
---|
291 | << " BlendMode: " << iBlendMode |
---|
292 | << std::endl; |
---|
293 | |
---|
294 | m_pcRenTop->setShiftLUTs( |
---|
295 | m_cCameraData.getSynthViewShiftLUTD()[iLeftBaseViewIdx ][iSynthViewIdx], |
---|
296 | m_cCameraData.getSynthViewShiftLUTI()[iLeftBaseViewIdx ][iSynthViewIdx], |
---|
297 | m_cCameraData.getBaseViewShiftLUTI ()[iLeftBaseViewIdx ][iRightBaseViewIdx], |
---|
298 | m_cCameraData.getSynthViewShiftLUTD()[iRightBaseViewIdx][iSynthViewIdx], |
---|
299 | m_cCameraData.getSynthViewShiftLUTI()[iRightBaseViewIdx][iSynthViewIdx], |
---|
300 | m_cCameraData.getBaseViewShiftLUTI ()[iRightBaseViewIdx][iLeftBaseViewIdx ], |
---|
301 | |
---|
302 | iRelDistToLeft |
---|
303 | ); |
---|
304 | |
---|
305 | m_pcRenTop->interpolateView( |
---|
306 | apcPicYuvBaseVideo[iLeftBaseViewIdx ], |
---|
307 | apcPicYuvBaseDepth[iLeftBaseViewIdx ], |
---|
308 | apcPicYuvBaseVideo[iRightBaseViewIdx], |
---|
309 | apcPicYuvBaseDepth[iRightBaseViewIdx], |
---|
310 | pcPicYuvSynthOut, |
---|
311 | iBlendMode, |
---|
312 | iSimEnhBaseView |
---|
313 | ); |
---|
314 | } |
---|
315 | else |
---|
316 | { |
---|
317 | AOT(iLeftBaseViewIdx != iRightBaseViewIdx ); |
---|
318 | apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); |
---|
319 | std::cout << "Copied Frame " << iFrame |
---|
320 | << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC |
---|
321 | << " (BaseView) " << std::endl; |
---|
322 | } |
---|
323 | |
---|
324 | break; |
---|
325 | /// EXTRAPOLATION FROM LEFT |
---|
326 | case 1: |
---|
327 | if ( !bHasLView ) // View to render is BaseView |
---|
328 | { |
---|
329 | bRender = false; |
---|
330 | } |
---|
331 | |
---|
332 | if ( bIsBaseView ) |
---|
333 | { |
---|
334 | AOF( iLeftBaseViewIdx == iRightBaseViewIdx ); |
---|
335 | Int iSortedBaseViewIdx = m_cCameraData.getBaseId2SortedId() [iLeftBaseViewIdx]; |
---|
336 | if ( iSortedBaseViewIdx - 1 >= 0 ) |
---|
337 | { |
---|
338 | iLeftBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iSortedBaseViewIdx - 1]; |
---|
339 | } |
---|
340 | else |
---|
341 | { |
---|
342 | std::cout << "Copied Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
343 | apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original |
---|
344 | bRender = false; |
---|
345 | } |
---|
346 | } |
---|
347 | |
---|
348 | |
---|
349 | if (bRender) |
---|
350 | { |
---|
351 | std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
352 | m_pcRenTop->setShiftLUTs( m_cCameraData.getSynthViewShiftLUTD()[iLeftBaseViewIdx ][iSynthViewIdx], |
---|
353 | m_cCameraData.getSynthViewShiftLUTI()[iLeftBaseViewIdx ][iSynthViewIdx], NULL, NULL, NULL, NULL, -1 ); |
---|
354 | m_pcRenTop->extrapolateView( apcPicYuvBaseVideo[iLeftBaseViewIdx ], apcPicYuvBaseDepth[iLeftBaseViewIdx ], pcPicYuvSynthOut, true ); |
---|
355 | } |
---|
356 | break; |
---|
357 | /// EXTRAPOLATION FROM RIGHT |
---|
358 | case 2: // extrapolation from right |
---|
359 | if ( !bHasRView ) // View to render is BaseView |
---|
360 | { |
---|
361 | bRender = false; |
---|
362 | } |
---|
363 | |
---|
364 | if ( bIsBaseView ) |
---|
365 | { |
---|
366 | |
---|
367 | AOF( iLeftBaseViewIdx == iRightBaseViewIdx ); |
---|
368 | Int iSortedBaseViewIdx = m_cCameraData.getBaseId2SortedId() [iLeftBaseViewIdx]; |
---|
369 | if ( iSortedBaseViewIdx + 1 < m_iNumberOfInputViews ) |
---|
370 | { |
---|
371 | iRightBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iSortedBaseViewIdx + 1]; |
---|
372 | } |
---|
373 | else |
---|
374 | { |
---|
375 | std::cout << "Copied Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
376 | apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original |
---|
377 | bRender = false; |
---|
378 | } |
---|
379 | } |
---|
380 | |
---|
381 | if ( bRender ) |
---|
382 | { |
---|
383 | std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
384 | m_pcRenTop->setShiftLUTs( NULL, NULL,NULL, m_cCameraData.getSynthViewShiftLUTD()[iRightBaseViewIdx ][iSynthViewIdx], |
---|
385 | m_cCameraData.getSynthViewShiftLUTI()[iRightBaseViewIdx ][iSynthViewIdx],NULL, iRelDistToLeft); |
---|
386 | m_pcRenTop->extrapolateView( apcPicYuvBaseVideo[iRightBaseViewIdx ], apcPicYuvBaseDepth[iRightBaseViewIdx ], pcPicYuvSynthOut, false); |
---|
387 | } |
---|
388 | break; |
---|
389 | } |
---|
390 | |
---|
391 | // Write Output |
---|
392 | m_apcTVideoIOYuvSynthOutput[m_bSweep ? 0 : iSynthViewIdx]->write( pcPicYuvSynthOut, aiPad ); |
---|
393 | } |
---|
394 | iFrame++; |
---|
395 | iNumOfRenderedFrames++; |
---|
396 | } |
---|
397 | |
---|
398 | // Delete Buffers |
---|
399 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
400 | { |
---|
401 | apcPicYuvBaseVideo[uiBaseView]->destroy(); |
---|
402 | delete apcPicYuvBaseVideo[uiBaseView]; |
---|
403 | |
---|
404 | apcPicYuvBaseDepth[uiBaseView]->destroy(); |
---|
405 | delete apcPicYuvBaseDepth[uiBaseView]; |
---|
406 | |
---|
407 | // Temporal Filter |
---|
408 | if ( m_bTempDepthFilter ) |
---|
409 | { |
---|
410 | apcPicYuvLastBaseVideo[uiBaseView]->destroy(); |
---|
411 | delete apcPicYuvLastBaseVideo[uiBaseView]; |
---|
412 | |
---|
413 | apcPicYuvLastBaseDepth[uiBaseView]->destroy(); |
---|
414 | delete apcPicYuvLastBaseDepth[uiBaseView]; |
---|
415 | } |
---|
416 | } |
---|
417 | |
---|
418 | pcPicYuvSynthOut->destroy(); |
---|
419 | delete pcPicYuvSynthOut; |
---|
420 | |
---|
421 | xDestroyLib(); |
---|
422 | |
---|
423 | } |
---|
424 | |
---|
425 | Void TAppRendererTop::go() |
---|
426 | { |
---|
427 | switch ( m_iRenderMode ) |
---|
428 | { |
---|
429 | case 0: |
---|
430 | render(); |
---|
431 | break; |
---|
432 | case 1: |
---|
433 | renderModel(); |
---|
434 | break; |
---|
435 | case 10: |
---|
436 | renderUsedPelsMap( ); |
---|
437 | break; |
---|
438 | |
---|
439 | default: |
---|
440 | AOT(true); |
---|
441 | } |
---|
442 | } |
---|
443 | |
---|
444 | Void TAppRendererTop::renderModel() |
---|
445 | { |
---|
446 | if ( m_bUseSetupString ) |
---|
447 | { |
---|
448 | xRenderModelFromString(); |
---|
449 | } |
---|
450 | else |
---|
451 | { |
---|
452 | xRenderModelFromNums(); |
---|
453 | } |
---|
454 | } |
---|
455 | |
---|
456 | Void TAppRendererTop::xRenderModelFromString() |
---|
457 | { |
---|
458 | |
---|
459 | xCreateLib(); |
---|
460 | xInitLib(); |
---|
461 | |
---|
462 | // Create Buffers Input Views; |
---|
463 | std::vector<TComPicYuv*> apcPicYuvBaseVideo; |
---|
464 | std::vector<TComPicYuv*> apcPicYuvBaseDepth; |
---|
465 | |
---|
466 | |
---|
467 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
468 | { |
---|
469 | TComPicYuv* pcNewVideoPic = new TComPicYuv; |
---|
470 | TComPicYuv* pcNewDepthPic = new TComPicYuv; |
---|
471 | |
---|
472 | pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
473 | apcPicYuvBaseVideo.push_back(pcNewVideoPic); |
---|
474 | |
---|
475 | pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
476 | apcPicYuvBaseDepth.push_back(pcNewDepthPic); |
---|
477 | } |
---|
478 | |
---|
479 | Int aiPad[2] = { 0, 0 }; |
---|
480 | |
---|
481 | // Init Model |
---|
482 | TRenModel cCurModel; |
---|
483 | |
---|
484 | AOT( m_iLog2SamplingFactor != 0 ); |
---|
485 | cCurModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin ); |
---|
486 | |
---|
487 | for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfInputViews; iViewIdx++ ) |
---|
488 | { |
---|
489 | Int iNumOfModels = m_cRenModStrParser.getNumOfModelsForView(iViewIdx, 1); |
---|
490 | |
---|
491 | for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ ) |
---|
492 | { |
---|
493 | Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode; |
---|
494 | m_cRenModStrParser.getSingleModelData ( iViewIdx, 1, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ; |
---|
495 | cCurModel .createSingleModel ( iViewIdx, 1, iModelNum, iLeftViewNum, iRightViewNum, false, iBlendMode ); |
---|
496 | |
---|
497 | } |
---|
498 | } |
---|
499 | |
---|
500 | // Create Buffer for synthesized View |
---|
501 | TComPicYuv* pcPicYuvSynthOut = new TComPicYuv; |
---|
502 | pcPicYuvSynthOut->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
503 | |
---|
504 | Bool bAnyEOS = false; |
---|
505 | |
---|
506 | Int iNumOfRenderedFrames = 0; |
---|
507 | Int iFrame = 0; |
---|
508 | |
---|
509 | while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS ) |
---|
510 | { |
---|
511 | // read in depth and video |
---|
512 | for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ ) |
---|
513 | { |
---|
514 | m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad ) ; |
---|
515 | bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof(); |
---|
516 | |
---|
517 | m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad ) ; |
---|
518 | bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof(); |
---|
519 | } |
---|
520 | |
---|
521 | if ( iFrame < m_iFrameSkip ) |
---|
522 | { |
---|
523 | continue; |
---|
524 | } |
---|
525 | |
---|
526 | |
---|
527 | for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ ) |
---|
528 | { |
---|
529 | TComPicYuv* pcPicYuvVideo = apcPicYuvBaseVideo[iBaseViewIdx]; |
---|
530 | TComPicYuv* pcPicYuvDepth = apcPicYuvBaseDepth[iBaseViewIdx]; |
---|
531 | Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx ]; |
---|
532 | cCurModel.setBaseView( iBaseViewSIdx, pcPicYuvVideo, pcPicYuvDepth, NULL, NULL ); |
---|
533 | } |
---|
534 | |
---|
535 | for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ ) |
---|
536 | { |
---|
537 | m_cCameraData.update( (UInt)iFrame ); |
---|
538 | |
---|
539 | // setup virtual views |
---|
540 | Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx]; |
---|
541 | |
---|
542 | cCurModel.setErrorMode( iBaseViewSIdx, 1, 0 ); |
---|
543 | Int iNumOfSV = m_cRenModStrParser.getNumOfModelsForView( iBaseViewSIdx, 1); |
---|
544 | for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ ) |
---|
545 | { |
---|
546 | Int iOrgRefBaseViewSIdx; |
---|
547 | Int iLeftBaseViewSIdx; |
---|
548 | Int iRightBaseViewSIdx; |
---|
549 | Int iSynthViewRelNum; |
---|
550 | Int iModelNum; |
---|
551 | Int iBlendMode; |
---|
552 | |
---|
553 | m_cRenModStrParser.getSingleModelData(iBaseViewSIdx, 1, iCurView, iModelNum, iBlendMode, iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum ); |
---|
554 | |
---|
555 | Int iLeftBaseViewIdx = -1; |
---|
556 | Int iRightBaseViewIdx = -1; |
---|
557 | |
---|
558 | TComPicYuv* pcPicYuvOrgRef = NULL; |
---|
559 | Int** ppiShiftLUTLeft = NULL; |
---|
560 | Int** ppiShiftLUTRight = NULL; |
---|
561 | Int** ppiBaseShiftLUTLeft = NULL; |
---|
562 | Int** ppiBaseShiftLUTRight = NULL; |
---|
563 | |
---|
564 | |
---|
565 | Int iDistToLeft = -1; |
---|
566 | |
---|
567 | Int iSynthViewIdx = m_cCameraData.synthRelNum2Idx( iSynthViewRelNum ); |
---|
568 | |
---|
569 | if ( iLeftBaseViewSIdx != -1 ) |
---|
570 | { |
---|
571 | iLeftBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [ iLeftBaseViewSIdx ]; |
---|
572 | ppiShiftLUTLeft = m_cCameraData.getSynthViewShiftLUTI()[ iLeftBaseViewIdx ][ iSynthViewIdx ]; |
---|
573 | } |
---|
574 | |
---|
575 | if ( iRightBaseViewSIdx != -1 ) |
---|
576 | { |
---|
577 | iRightBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [iRightBaseViewSIdx ]; |
---|
578 | ppiShiftLUTRight = m_cCameraData.getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ]; |
---|
579 | } |
---|
580 | |
---|
581 | if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 ) |
---|
582 | { |
---|
583 | |
---|
584 | ppiBaseShiftLUTLeft = m_cCameraData.getBaseViewShiftLUTI() [ iLeftBaseViewIdx ][ iRightBaseViewIdx ]; |
---|
585 | ppiBaseShiftLUTRight = m_cCameraData.getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx ]; |
---|
586 | iDistToLeft = m_cCameraData.getRelDistLeft( iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx); |
---|
587 | } |
---|
588 | |
---|
589 | std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
590 | |
---|
591 | cCurModel.setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef ); |
---|
592 | |
---|
593 | Int iViewPos; |
---|
594 | if (iLeftBaseViewSIdx != -1 && iRightBaseViewSIdx != -1) |
---|
595 | { |
---|
596 | iViewPos = VIEWPOS_MERGED; |
---|
597 | } |
---|
598 | else if ( iLeftBaseViewSIdx != -1 ) |
---|
599 | { |
---|
600 | iViewPos = VIEWPOS_LEFT; |
---|
601 | } |
---|
602 | else if ( iRightBaseViewSIdx != -1 ) |
---|
603 | { |
---|
604 | iViewPos = VIEWPOS_RIGHT; |
---|
605 | } |
---|
606 | else |
---|
607 | { |
---|
608 | AOT(true); |
---|
609 | } |
---|
610 | |
---|
611 | cCurModel.getSynthVideo ( iModelNum, iViewPos, pcPicYuvSynthOut ); |
---|
612 | |
---|
613 | // Write Output |
---|
614 | m_apcTVideoIOYuvSynthOutput[m_bSweep ? 0 : iModelNum]->write( pcPicYuvSynthOut, aiPad ); |
---|
615 | } |
---|
616 | } |
---|
617 | iFrame++; |
---|
618 | iNumOfRenderedFrames++; |
---|
619 | } |
---|
620 | |
---|
621 | // Delete Buffers |
---|
622 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
623 | { |
---|
624 | apcPicYuvBaseVideo[uiBaseView]->destroy(); |
---|
625 | delete apcPicYuvBaseVideo[uiBaseView]; |
---|
626 | |
---|
627 | apcPicYuvBaseDepth[uiBaseView]->destroy(); |
---|
628 | delete apcPicYuvBaseDepth[uiBaseView]; |
---|
629 | } |
---|
630 | pcPicYuvSynthOut->destroy(); |
---|
631 | delete pcPicYuvSynthOut; |
---|
632 | |
---|
633 | xDestroyLib(); |
---|
634 | } |
---|
635 | |
---|
636 | Void TAppRendererTop::xRenderModelFromNums() |
---|
637 | { |
---|
638 | xCreateLib(); |
---|
639 | xInitLib(); |
---|
640 | |
---|
641 | // Create Buffers Input Views; |
---|
642 | std::vector<TComPicYuv*> apcPicYuvBaseVideo; |
---|
643 | std::vector<TComPicYuv*> apcPicYuvBaseDepth; |
---|
644 | |
---|
645 | |
---|
646 | Int aiPad[2] = { 0, 0 }; |
---|
647 | |
---|
648 | // Init Model |
---|
649 | TRenModel cCurModel; |
---|
650 | |
---|
651 | AOT( m_iLog2SamplingFactor != 0 ); |
---|
652 | cCurModel.create( m_iNumberOfInputViews, m_iNumberOfOutputViews, m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin ); |
---|
653 | |
---|
654 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
655 | { |
---|
656 | TComPicYuv* pcNewVideoPic = new TComPicYuv; |
---|
657 | TComPicYuv* pcNewDepthPic = new TComPicYuv; |
---|
658 | |
---|
659 | pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
660 | apcPicYuvBaseVideo.push_back(pcNewVideoPic); |
---|
661 | |
---|
662 | pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
663 | apcPicYuvBaseDepth.push_back(pcNewDepthPic); |
---|
664 | } |
---|
665 | |
---|
666 | for(Int iSynthViewIdx=0; iSynthViewIdx < m_iNumberOfOutputViews; iSynthViewIdx++ ) |
---|
667 | { |
---|
668 | Int iLeftBaseViewIdx = -1; |
---|
669 | Int iRightBaseViewIdx = -1; |
---|
670 | Bool bIsBaseView = false; |
---|
671 | |
---|
672 | Int iRelDistToLeft; |
---|
673 | m_cCameraData.getLeftRightBaseView( iSynthViewIdx, iLeftBaseViewIdx, iRightBaseViewIdx, iRelDistToLeft, bIsBaseView ); |
---|
674 | |
---|
675 | if (m_iRenderDirection == 1 ) |
---|
676 | { |
---|
677 | iRightBaseViewIdx = -1; |
---|
678 | AOT( iLeftBaseViewIdx == -1); |
---|
679 | } |
---|
680 | |
---|
681 | if (m_iRenderDirection == 2 ) |
---|
682 | { |
---|
683 | iLeftBaseViewIdx = -1; |
---|
684 | AOT( iRightBaseViewIdx == -1); |
---|
685 | } |
---|
686 | |
---|
687 | Int iLeftBaseViewSIdx = -1; |
---|
688 | Int iRightBaseViewSIdx = -1; |
---|
689 | |
---|
690 | if (iLeftBaseViewIdx != -1 ) |
---|
691 | { |
---|
692 | iLeftBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iLeftBaseViewIdx]; |
---|
693 | } |
---|
694 | |
---|
695 | if (iRightBaseViewIdx != -1 ) |
---|
696 | { |
---|
697 | iRightBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iRightBaseViewIdx]; |
---|
698 | } |
---|
699 | cCurModel.createSingleModel(-1, -1, iSynthViewIdx, iLeftBaseViewSIdx, iRightBaseViewSIdx, false, m_iBlendMode ); |
---|
700 | } |
---|
701 | |
---|
702 | // Create Buffer for synthesized View |
---|
703 | TComPicYuv* pcPicYuvSynthOut = new TComPicYuv; |
---|
704 | pcPicYuvSynthOut->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
705 | |
---|
706 | Bool bAnyEOS = false; |
---|
707 | |
---|
708 | Int iNumOfRenderedFrames = 0; |
---|
709 | Int iFrame = 0; |
---|
710 | |
---|
711 | while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS ) |
---|
712 | { |
---|
713 | // read in depth and video |
---|
714 | for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ ) |
---|
715 | { |
---|
716 | m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad ) ; |
---|
717 | bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof(); |
---|
718 | |
---|
719 | m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad ) ; |
---|
720 | bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof(); |
---|
721 | |
---|
722 | if ( iFrame >= m_iFrameSkip ) |
---|
723 | { |
---|
724 | Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx]; |
---|
725 | cCurModel.setBaseView( iBaseViewSIdx, apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], NULL, NULL ); |
---|
726 | } |
---|
727 | } |
---|
728 | |
---|
729 | if ( iFrame < m_iFrameSkip ) // Skip Frames |
---|
730 | { |
---|
731 | iFrame++; |
---|
732 | continue; |
---|
733 | } |
---|
734 | |
---|
735 | m_cCameraData.update( (UInt)iFrame ); |
---|
736 | |
---|
737 | for(Int iSynthViewIdx=0; iSynthViewIdx < m_iNumberOfOutputViews; iSynthViewIdx++ ) |
---|
738 | { |
---|
739 | |
---|
740 | Int iLeftBaseViewIdx = -1; |
---|
741 | Int iRightBaseViewIdx = -1; |
---|
742 | |
---|
743 | Bool bIsBaseView = false; |
---|
744 | |
---|
745 | Int iRelDistToLeft; |
---|
746 | Bool bHasLRView = m_cCameraData.getLeftRightBaseView( iSynthViewIdx, iLeftBaseViewIdx, iRightBaseViewIdx, iRelDistToLeft, bIsBaseView ); |
---|
747 | Bool bHasLView = ( iLeftBaseViewIdx != -1 ); |
---|
748 | Bool bHasRView = ( iRightBaseViewIdx != -1 ); |
---|
749 | |
---|
750 | switch( m_iRenderDirection ) |
---|
751 | { |
---|
752 | /// INTERPOLATION |
---|
753 | case 0: |
---|
754 | assert( bHasLRView || bIsBaseView ); |
---|
755 | |
---|
756 | if ( !bHasLRView && bIsBaseView ) // View to render is BaseView |
---|
757 | { |
---|
758 | std::cout << "Copied Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
759 | apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original |
---|
760 | } |
---|
761 | else // Render |
---|
762 | { |
---|
763 | std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
764 | cCurModel.setSingleModel( iSynthViewIdx, |
---|
765 | m_cCameraData.getSynthViewShiftLUTI()[iLeftBaseViewIdx ][iSynthViewIdx] , |
---|
766 | m_cCameraData.getBaseViewShiftLUTI ()[iLeftBaseViewIdx ][iRightBaseViewIdx], |
---|
767 | m_cCameraData.getSynthViewShiftLUTI()[iRightBaseViewIdx][iSynthViewIdx] , |
---|
768 | m_cCameraData.getBaseViewShiftLUTI ()[iRightBaseViewIdx][iLeftBaseViewIdx] , |
---|
769 | iRelDistToLeft, |
---|
770 | NULL ); |
---|
771 | cCurModel.getSynthVideo ( iSynthViewIdx, VIEWPOS_MERGED, pcPicYuvSynthOut ); |
---|
772 | } |
---|
773 | break; |
---|
774 | /// EXTRAPOLATION FROM LEFT |
---|
775 | case 1: |
---|
776 | |
---|
777 | if ( !bHasLView ) // View to render is BaseView |
---|
778 | { |
---|
779 | std::cout << "Copied Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
780 | apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original |
---|
781 | } |
---|
782 | else // Render |
---|
783 | { |
---|
784 | std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
785 | cCurModel.setSingleModel( iSynthViewIdx, m_cCameraData.getSynthViewShiftLUTI()[iLeftBaseViewIdx ][iSynthViewIdx], NULL, NULL, NULL, -1, NULL); |
---|
786 | cCurModel.getSynthVideo ( iSynthViewIdx, VIEWPOS_LEFT, pcPicYuvSynthOut ); |
---|
787 | } |
---|
788 | break; |
---|
789 | /// EXTRAPOLATION FROM RIGHT |
---|
790 | case 2: // extrapolation from right |
---|
791 | if ( !bHasRView ) // View to render is BaseView |
---|
792 | { |
---|
793 | std::cout << "Copied Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
794 | apcPicYuvBaseVideo[iRightBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original |
---|
795 | } |
---|
796 | else // Render |
---|
797 | { |
---|
798 | std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
799 | cCurModel.setSingleModel( iSynthViewIdx, NULL , NULL, m_cCameraData.getSynthViewShiftLUTI()[iRightBaseViewIdx ][iSynthViewIdx], NULL, -1, NULL); |
---|
800 | cCurModel.getSynthVideo ( iSynthViewIdx, VIEWPOS_RIGHT, pcPicYuvSynthOut ); |
---|
801 | } |
---|
802 | break; |
---|
803 | } |
---|
804 | |
---|
805 | // Write Output |
---|
806 | m_apcTVideoIOYuvSynthOutput[m_bSweep ? 0 : iSynthViewIdx]->write( pcPicYuvSynthOut, aiPad ); |
---|
807 | } |
---|
808 | iFrame++; |
---|
809 | iNumOfRenderedFrames++; |
---|
810 | } |
---|
811 | |
---|
812 | // Delete Buffers |
---|
813 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
814 | { |
---|
815 | apcPicYuvBaseVideo[uiBaseView]->destroy(); |
---|
816 | delete apcPicYuvBaseVideo[uiBaseView]; |
---|
817 | |
---|
818 | apcPicYuvBaseDepth[uiBaseView]->destroy(); |
---|
819 | delete apcPicYuvBaseDepth[uiBaseView]; |
---|
820 | } |
---|
821 | pcPicYuvSynthOut->destroy(); |
---|
822 | delete pcPicYuvSynthOut; |
---|
823 | |
---|
824 | xDestroyLib(); |
---|
825 | |
---|
826 | } |
---|
827 | |
---|
828 | Void TAppRendererTop::renderUsedPelsMap( ) |
---|
829 | { |
---|
830 | xCreateLib(); |
---|
831 | xInitLib(); |
---|
832 | |
---|
833 | // Create Buffers Input Views; |
---|
834 | std::vector<TComPicYuv*> apcPicYuvBaseVideo; |
---|
835 | std::vector<TComPicYuv*> apcPicYuvBaseDepth; |
---|
836 | |
---|
837 | // TemporalImprovement Filter |
---|
838 | std::vector<TComPicYuv*> apcPicYuvLastBaseVideo; |
---|
839 | std::vector<TComPicYuv*> apcPicYuvLastBaseDepth; |
---|
840 | |
---|
841 | Int aiPad[2] = { 0, 0 }; |
---|
842 | |
---|
843 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
844 | { |
---|
845 | TComPicYuv* pcNewVideoPic = new TComPicYuv; |
---|
846 | TComPicYuv* pcNewDepthPic = new TComPicYuv; |
---|
847 | |
---|
848 | pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
849 | apcPicYuvBaseVideo.push_back(pcNewVideoPic); |
---|
850 | |
---|
851 | pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
852 | apcPicYuvBaseDepth.push_back(pcNewDepthPic); |
---|
853 | |
---|
854 | //Temporal improvement Filter |
---|
855 | if ( m_bTempDepthFilter ) |
---|
856 | { |
---|
857 | pcNewVideoPic = new TComPicYuv; |
---|
858 | pcNewDepthPic = new TComPicYuv; |
---|
859 | |
---|
860 | pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
861 | apcPicYuvLastBaseVideo.push_back(pcNewVideoPic); |
---|
862 | |
---|
863 | pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
864 | apcPicYuvLastBaseDepth.push_back(pcNewDepthPic); |
---|
865 | } |
---|
866 | } |
---|
867 | |
---|
868 | // Create Buffer for synthesized View |
---|
869 | TComPicYuv* pcPicYuvSynthOut = new TComPicYuv; |
---|
870 | pcPicYuvSynthOut->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
871 | |
---|
872 | Bool bAnyEOS = false; |
---|
873 | |
---|
874 | Int iNumOfRenderedFrames = 0; |
---|
875 | Int iFrame = 0; |
---|
876 | |
---|
877 | while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS ) |
---|
878 | { |
---|
879 | // set shift LUT |
---|
880 | |
---|
881 | // read in depth and video |
---|
882 | for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ ) |
---|
883 | { |
---|
884 | m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad ) ; |
---|
885 | apcPicYuvBaseVideo[iBaseViewIdx]->extendPicBorder(); |
---|
886 | bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof(); |
---|
887 | |
---|
888 | m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad ) ; |
---|
889 | apcPicYuvBaseDepth[iBaseViewIdx]->extendPicBorder(); |
---|
890 | bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof(); |
---|
891 | |
---|
892 | if ( m_bTempDepthFilter && (iFrame >= m_iFrameSkip) ) |
---|
893 | { |
---|
894 | m_pcRenTop->temporalFilterVSRS( apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], apcPicYuvLastBaseVideo[iBaseViewIdx], apcPicYuvLastBaseDepth[iBaseViewIdx], ( iFrame == m_iFrameSkip) ); |
---|
895 | } |
---|
896 | } |
---|
897 | |
---|
898 | if ( iFrame < m_iFrameSkip ) // Skip Frames |
---|
899 | { |
---|
900 | std::cout << "Skipping Frame " << iFrame << std::endl; |
---|
901 | |
---|
902 | iFrame++; |
---|
903 | continue; |
---|
904 | } |
---|
905 | |
---|
906 | m_cCameraData.update( (UInt)iFrame ); |
---|
907 | |
---|
908 | for(Int iViewIdx=1; iViewIdx < m_iNumberOfInputViews; iViewIdx++ ) |
---|
909 | { |
---|
910 | std::cout << "Rendering UsedPelsMap for Frame " << iFrame << " of View " << (Double) m_cCameraData.getBaseViewNumbers()[iViewIdx] << std::endl; |
---|
911 | |
---|
912 | Int iViewSIdx = m_cCameraData.getBaseId2SortedId()[iViewIdx]; |
---|
913 | Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0]; |
---|
914 | |
---|
915 | AOT( iViewSIdx == iFirstViewSIdx ); |
---|
916 | |
---|
917 | Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx); |
---|
918 | |
---|
919 | m_pcRenTop->setShiftLUTs( |
---|
920 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
921 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
922 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
923 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
924 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
925 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
926 | -1 |
---|
927 | ); |
---|
928 | |
---|
929 | m_pcRenTop->getUsedSamplesMap( apcPicYuvBaseDepth[0], pcPicYuvSynthOut, bFirstIsLeft ); |
---|
930 | |
---|
931 | // Write Output |
---|
932 | m_apcTVideoIOYuvSynthOutput[iViewIdx-1]->write( pcPicYuvSynthOut, aiPad ); |
---|
933 | |
---|
934 | } |
---|
935 | iFrame++; |
---|
936 | iNumOfRenderedFrames++; |
---|
937 | } |
---|
938 | |
---|
939 | // Delete Buffers |
---|
940 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
941 | { |
---|
942 | apcPicYuvBaseVideo[uiBaseView]->destroy(); |
---|
943 | delete apcPicYuvBaseVideo[uiBaseView]; |
---|
944 | |
---|
945 | apcPicYuvBaseDepth[uiBaseView]->destroy(); |
---|
946 | delete apcPicYuvBaseDepth[uiBaseView]; |
---|
947 | |
---|
948 | // Temporal Filter |
---|
949 | if ( m_bTempDepthFilter ) |
---|
950 | { |
---|
951 | apcPicYuvLastBaseVideo[uiBaseView]->destroy(); |
---|
952 | delete apcPicYuvLastBaseVideo[uiBaseView]; |
---|
953 | |
---|
954 | apcPicYuvLastBaseDepth[uiBaseView]->destroy(); |
---|
955 | delete apcPicYuvLastBaseDepth[uiBaseView]; |
---|
956 | } |
---|
957 | } |
---|
958 | pcPicYuvSynthOut->destroy(); |
---|
959 | delete pcPicYuvSynthOut; |
---|
960 | |
---|
961 | xDestroyLib(); |
---|
962 | |
---|
963 | } |
---|