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