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