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