[438] | 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 | |
---|
[446] | 43 | #if H_3D |
---|
| 44 | |
---|
[438] | 45 | // ==================================================================================================================== |
---|
| 46 | // Constructor / destructor / initialization / destroy |
---|
| 47 | // ==================================================================================================================== |
---|
[446] | 48 | |
---|
[438] | 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 | |
---|
[446] | 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 |
---|
[438] | 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; |
---|
[446] | 81 | pcSynthOutput->open( m_pchSynthOutputFileList[iViewIdx], true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // write mode |
---|
[438] | 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; |
---|
[446] | 470 | #if H_3D_VSO |
---|
[438] | 471 | case 1: |
---|
| 472 | renderModel(); |
---|
| 473 | break; |
---|
[446] | 474 | #endif |
---|
[438] | 475 | case 10: |
---|
| 476 | renderUsedPelsMap( ); |
---|
| 477 | break; |
---|
| 478 | |
---|
| 479 | default: |
---|
| 480 | AOT(true); |
---|
| 481 | } |
---|
| 482 | } |
---|
| 483 | |
---|
[446] | 484 | #if H_3D_VSO |
---|
[438] | 485 | Void TAppRendererTop::renderModel() |
---|
| 486 | { |
---|
| 487 | if ( m_bUseSetupString ) |
---|
| 488 | { |
---|
| 489 | xRenderModelFromString(); |
---|
| 490 | } |
---|
| 491 | else |
---|
| 492 | { |
---|
| 493 | xRenderModelFromNums(); |
---|
| 494 | } |
---|
| 495 | } |
---|
| 496 | |
---|
[446] | 497 | |
---|
| 498 | |
---|
[438] | 499 | Void TAppRendererTop::xRenderModelFromString() |
---|
| 500 | { |
---|
| 501 | xCreateLib(); |
---|
| 502 | xInitLib(); |
---|
| 503 | |
---|
| 504 | // Create Buffers Input Views; |
---|
| 505 | std::vector<TComPicYuv*> apcPicYuvBaseVideo; |
---|
| 506 | std::vector<TComPicYuv*> apcPicYuvBaseDepth; |
---|
| 507 | |
---|
| 508 | |
---|
| 509 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
| 510 | { |
---|
| 511 | TComPicYuv* pcNewVideoPic = new TComPicYuv; |
---|
| 512 | TComPicYuv* pcNewDepthPic = new TComPicYuv; |
---|
| 513 | |
---|
| 514 | pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
| 515 | apcPicYuvBaseVideo.push_back(pcNewVideoPic); |
---|
| 516 | |
---|
| 517 | pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
| 518 | apcPicYuvBaseDepth.push_back(pcNewDepthPic); |
---|
| 519 | } |
---|
| 520 | |
---|
| 521 | Int aiPad[2] = { 0, 0 }; |
---|
| 522 | |
---|
| 523 | // Init Model |
---|
| 524 | TRenModel cCurModel; |
---|
| 525 | |
---|
| 526 | AOT( m_iLog2SamplingFactor != 0 ); |
---|
[446] | 527 | #if H_3D_VSO_EARLY_SKIP |
---|
[438] | 528 | cCurModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin, false ); |
---|
| 529 | #else |
---|
| 530 | cCurModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin ); |
---|
| 531 | #endif |
---|
| 532 | |
---|
| 533 | cCurModel.setupPart( 0, m_iSourceHeight ); |
---|
| 534 | |
---|
| 535 | for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfInputViews; iViewIdx++ ) |
---|
| 536 | { |
---|
| 537 | Int iNumOfModels = m_cRenModStrParser.getNumOfModelsForView(iViewIdx, 1); |
---|
| 538 | |
---|
| 539 | for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ ) |
---|
| 540 | { |
---|
| 541 | Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode; |
---|
| 542 | m_cRenModStrParser.getSingleModelData ( iViewIdx, 1, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ; |
---|
| 543 | cCurModel .createSingleModel ( iViewIdx, 1, iModelNum, iLeftViewNum, iRightViewNum, false, iBlendMode ); |
---|
| 544 | |
---|
| 545 | } |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | // Create Buffer for synthesized View |
---|
| 549 | TComPicYuv* pcPicYuvSynthOut = new TComPicYuv; |
---|
| 550 | pcPicYuvSynthOut->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
| 551 | |
---|
| 552 | Bool bAnyEOS = false; |
---|
| 553 | |
---|
| 554 | Int iNumOfRenderedFrames = 0; |
---|
| 555 | Int iFrame = 0; |
---|
| 556 | |
---|
| 557 | while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS ) |
---|
| 558 | { |
---|
| 559 | |
---|
| 560 | if ( iFrame >= m_iFrameSkip ) |
---|
| 561 | { |
---|
| 562 | // read in depth and video |
---|
| 563 | for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ ) |
---|
| 564 | { |
---|
| 565 | m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad ) ; |
---|
| 566 | bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof(); |
---|
| 567 | |
---|
| 568 | m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad ) ; |
---|
| 569 | bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof(); |
---|
| 570 | } |
---|
| 571 | } |
---|
| 572 | else |
---|
| 573 | { |
---|
| 574 | iFrame++; |
---|
| 575 | continue; |
---|
| 576 | } |
---|
| 577 | |
---|
| 578 | |
---|
| 579 | for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ ) |
---|
| 580 | { |
---|
| 581 | TComPicYuv* pcPicYuvVideo = apcPicYuvBaseVideo[iBaseViewIdx]; |
---|
| 582 | TComPicYuv* pcPicYuvDepth = apcPicYuvBaseDepth[iBaseViewIdx]; |
---|
| 583 | Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx ]; |
---|
| 584 | cCurModel.setBaseView( iBaseViewSIdx, pcPicYuvVideo, pcPicYuvDepth, NULL, NULL ); |
---|
| 585 | } |
---|
| 586 | |
---|
| 587 | m_cCameraData.update( (UInt) ( iFrame - m_iFrameSkip )); |
---|
| 588 | |
---|
| 589 | for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ ) |
---|
| 590 | { |
---|
| 591 | // setup virtual views |
---|
| 592 | Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx]; |
---|
| 593 | |
---|
| 594 | cCurModel.setErrorMode( iBaseViewSIdx, 1, 0 ); |
---|
| 595 | Int iNumOfSV = m_cRenModStrParser.getNumOfModelsForView( iBaseViewSIdx, 1); |
---|
| 596 | for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ ) |
---|
| 597 | { |
---|
| 598 | Int iOrgRefBaseViewSIdx; |
---|
| 599 | Int iLeftBaseViewSIdx; |
---|
| 600 | Int iRightBaseViewSIdx; |
---|
| 601 | Int iSynthViewRelNum; |
---|
| 602 | Int iModelNum; |
---|
| 603 | Int iBlendMode; |
---|
| 604 | |
---|
| 605 | m_cRenModStrParser.getSingleModelData(iBaseViewSIdx, 1, iCurView, iModelNum, iBlendMode, iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum ); |
---|
| 606 | |
---|
| 607 | Int iLeftBaseViewIdx = -1; |
---|
| 608 | Int iRightBaseViewIdx = -1; |
---|
| 609 | |
---|
| 610 | TComPicYuv* pcPicYuvOrgRef = NULL; |
---|
| 611 | Int** ppiShiftLUTLeft = NULL; |
---|
| 612 | Int** ppiShiftLUTRight = NULL; |
---|
| 613 | Int** ppiBaseShiftLUTLeft = NULL; |
---|
| 614 | Int** ppiBaseShiftLUTRight = NULL; |
---|
| 615 | |
---|
| 616 | |
---|
| 617 | Int iDistToLeft = -1; |
---|
| 618 | |
---|
| 619 | Int iSynthViewIdx = m_cCameraData.synthRelNum2Idx( iSynthViewRelNum ); |
---|
| 620 | |
---|
| 621 | if ( iLeftBaseViewSIdx != -1 ) |
---|
| 622 | { |
---|
| 623 | iLeftBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [ iLeftBaseViewSIdx ]; |
---|
| 624 | ppiShiftLUTLeft = m_cCameraData.getSynthViewShiftLUTI()[ iLeftBaseViewIdx ][ iSynthViewIdx ]; |
---|
| 625 | } |
---|
| 626 | |
---|
| 627 | if ( iRightBaseViewSIdx != -1 ) |
---|
| 628 | { |
---|
| 629 | iRightBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [iRightBaseViewSIdx ]; |
---|
| 630 | ppiShiftLUTRight = m_cCameraData.getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ]; |
---|
| 631 | } |
---|
| 632 | |
---|
| 633 | if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 ) |
---|
| 634 | { |
---|
| 635 | |
---|
| 636 | ppiBaseShiftLUTLeft = m_cCameraData.getBaseViewShiftLUTI() [ iLeftBaseViewIdx ][ iRightBaseViewIdx ]; |
---|
| 637 | ppiBaseShiftLUTRight = m_cCameraData.getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx ]; |
---|
| 638 | iDistToLeft = m_cCameraData.getRelDistLeft( iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx); |
---|
| 639 | } |
---|
| 640 | |
---|
| 641 | std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
| 642 | |
---|
| 643 | cCurModel.setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef ); |
---|
| 644 | |
---|
| 645 | Int iViewPos; |
---|
| 646 | if (iLeftBaseViewSIdx != -1 && iRightBaseViewSIdx != -1) |
---|
| 647 | { |
---|
| 648 | iViewPos = VIEWPOS_MERGED; |
---|
| 649 | } |
---|
| 650 | else if ( iLeftBaseViewSIdx != -1 ) |
---|
| 651 | { |
---|
| 652 | iViewPos = VIEWPOS_LEFT; |
---|
| 653 | } |
---|
| 654 | else if ( iRightBaseViewSIdx != -1 ) |
---|
| 655 | { |
---|
| 656 | iViewPos = VIEWPOS_RIGHT; |
---|
| 657 | } |
---|
| 658 | else |
---|
| 659 | { |
---|
| 660 | AOT(true); |
---|
| 661 | } |
---|
| 662 | |
---|
| 663 | cCurModel.getSynthVideo ( iModelNum, iViewPos, pcPicYuvSynthOut ); |
---|
| 664 | |
---|
| 665 | // Write Output |
---|
| 666 | m_apcTVideoIOYuvSynthOutput[m_bSweep ? 0 : iModelNum]->write( pcPicYuvSynthOut, 0 ,0 ,0, 0 ); |
---|
| 667 | } |
---|
| 668 | } |
---|
| 669 | iFrame++; |
---|
| 670 | iNumOfRenderedFrames++; |
---|
| 671 | } |
---|
| 672 | |
---|
| 673 | // Delete Buffers |
---|
| 674 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
| 675 | { |
---|
| 676 | apcPicYuvBaseVideo[uiBaseView]->destroy(); |
---|
| 677 | delete apcPicYuvBaseVideo[uiBaseView]; |
---|
| 678 | |
---|
| 679 | apcPicYuvBaseDepth[uiBaseView]->destroy(); |
---|
| 680 | delete apcPicYuvBaseDepth[uiBaseView]; |
---|
| 681 | } |
---|
| 682 | pcPicYuvSynthOut->destroy(); |
---|
| 683 | delete pcPicYuvSynthOut; |
---|
| 684 | |
---|
| 685 | xDestroyLib(); |
---|
| 686 | } |
---|
| 687 | |
---|
[446] | 688 | |
---|
[438] | 689 | Void TAppRendererTop::xRenderModelFromNums() |
---|
| 690 | { |
---|
| 691 | xCreateLib(); |
---|
| 692 | xInitLib(); |
---|
| 693 | |
---|
| 694 | // Create Buffers Input Views; |
---|
| 695 | std::vector<TComPicYuv*> apcPicYuvBaseVideo; |
---|
| 696 | std::vector<TComPicYuv*> apcPicYuvBaseDepth; |
---|
| 697 | |
---|
| 698 | |
---|
| 699 | Int aiPad[2] = { 0, 0 }; |
---|
| 700 | |
---|
| 701 | // Init Model |
---|
| 702 | TRenModel cCurModel; |
---|
| 703 | |
---|
| 704 | AOT( m_iLog2SamplingFactor != 0 ); |
---|
| 705 | cCurModel.setupPart( 0, m_iSourceHeight ); |
---|
[446] | 706 | #if H_3D_VSO_EARLY_SKIP |
---|
[438] | 707 | cCurModel.create( m_iNumberOfInputViews, m_iNumberOfOutputViews, m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin, false ); |
---|
| 708 | #else |
---|
| 709 | cCurModel.create( m_iNumberOfInputViews, m_iNumberOfOutputViews, m_iSourceWidth, m_iSourceHeight, m_iShiftPrecision, m_iBlendHoleMargin ); |
---|
| 710 | #endif |
---|
| 711 | |
---|
| 712 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
| 713 | { |
---|
| 714 | TComPicYuv* pcNewVideoPic = new TComPicYuv; |
---|
| 715 | TComPicYuv* pcNewDepthPic = new TComPicYuv; |
---|
| 716 | |
---|
| 717 | pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
| 718 | apcPicYuvBaseVideo.push_back(pcNewVideoPic); |
---|
| 719 | |
---|
| 720 | pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
| 721 | apcPicYuvBaseDepth.push_back(pcNewDepthPic); |
---|
| 722 | } |
---|
| 723 | |
---|
| 724 | for(Int iSynthViewIdx=0; iSynthViewIdx < m_iNumberOfOutputViews; iSynthViewIdx++ ) |
---|
| 725 | { |
---|
| 726 | Int iLeftBaseViewIdx = -1; |
---|
| 727 | Int iRightBaseViewIdx = -1; |
---|
| 728 | Bool bIsBaseView = false; |
---|
| 729 | |
---|
| 730 | Int iRelDistToLeft; |
---|
| 731 | m_cCameraData.getLeftRightBaseView( iSynthViewIdx, iLeftBaseViewIdx, iRightBaseViewIdx, iRelDistToLeft, bIsBaseView ); |
---|
| 732 | |
---|
| 733 | if (m_iRenderDirection == 1 ) |
---|
| 734 | { |
---|
| 735 | iRightBaseViewIdx = -1; |
---|
| 736 | AOT( iLeftBaseViewIdx == -1); |
---|
| 737 | } |
---|
| 738 | |
---|
| 739 | if (m_iRenderDirection == 2 ) |
---|
| 740 | { |
---|
| 741 | iLeftBaseViewIdx = -1; |
---|
| 742 | AOT( iRightBaseViewIdx == -1); |
---|
| 743 | } |
---|
| 744 | |
---|
| 745 | Int iLeftBaseViewSIdx = -1; |
---|
| 746 | Int iRightBaseViewSIdx = -1; |
---|
| 747 | |
---|
| 748 | if (iLeftBaseViewIdx != -1 ) |
---|
| 749 | { |
---|
| 750 | iLeftBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iLeftBaseViewIdx]; |
---|
| 751 | } |
---|
| 752 | |
---|
| 753 | if (iRightBaseViewIdx != -1 ) |
---|
| 754 | { |
---|
| 755 | iRightBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iRightBaseViewIdx]; |
---|
| 756 | } |
---|
| 757 | cCurModel.createSingleModel(-1, -1, iSynthViewIdx, iLeftBaseViewSIdx, iRightBaseViewSIdx, false, m_iBlendMode ); |
---|
| 758 | } |
---|
| 759 | |
---|
| 760 | // Create Buffer for synthesized View |
---|
| 761 | TComPicYuv* pcPicYuvSynthOut = new TComPicYuv; |
---|
| 762 | pcPicYuvSynthOut->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
| 763 | |
---|
| 764 | Bool bAnyEOS = false; |
---|
| 765 | |
---|
| 766 | Int iNumOfRenderedFrames = 0; |
---|
| 767 | Int iFrame = 0; |
---|
| 768 | |
---|
| 769 | while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS ) |
---|
| 770 | { |
---|
| 771 | |
---|
| 772 | if ( iFrame >= m_iFrameSkip ) |
---|
| 773 | { |
---|
| 774 | // read in depth and video |
---|
| 775 | for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ ) |
---|
| 776 | { |
---|
| 777 | m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad ) ; |
---|
| 778 | bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof(); |
---|
| 779 | |
---|
| 780 | m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad ) ; |
---|
| 781 | bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof(); |
---|
| 782 | |
---|
| 783 | if ( iFrame >= m_iFrameSkip ) |
---|
| 784 | { |
---|
| 785 | Int iBaseViewSIdx = m_cCameraData.getBaseId2SortedId()[iBaseViewIdx]; |
---|
| 786 | cCurModel.setBaseView( iBaseViewSIdx, apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], NULL, NULL ); |
---|
| 787 | } |
---|
| 788 | } |
---|
| 789 | } |
---|
| 790 | else |
---|
| 791 | { |
---|
| 792 | iFrame++; |
---|
| 793 | continue; |
---|
| 794 | } |
---|
| 795 | m_cCameraData.update( (UInt) (iFrame - m_iFrameSkip )); |
---|
| 796 | for(Int iSynthViewIdx=0; iSynthViewIdx < m_iNumberOfOutputViews; iSynthViewIdx++ ) |
---|
| 797 | { |
---|
| 798 | |
---|
| 799 | Int iLeftBaseViewIdx = -1; |
---|
| 800 | Int iRightBaseViewIdx = -1; |
---|
| 801 | |
---|
| 802 | Bool bIsBaseView = false; |
---|
| 803 | |
---|
| 804 | Int iRelDistToLeft; |
---|
| 805 | Bool bHasLRView = m_cCameraData.getLeftRightBaseView( iSynthViewIdx, iLeftBaseViewIdx, iRightBaseViewIdx, iRelDistToLeft, bIsBaseView ); |
---|
| 806 | Bool bHasLView = ( iLeftBaseViewIdx != -1 ); |
---|
| 807 | Bool bHasRView = ( iRightBaseViewIdx != -1 ); |
---|
| 808 | |
---|
| 809 | switch( m_iRenderDirection ) |
---|
| 810 | { |
---|
| 811 | /// INTERPOLATION |
---|
| 812 | case 0: |
---|
| 813 | assert( bHasLRView || bIsBaseView ); |
---|
| 814 | |
---|
| 815 | if ( !bHasLRView && bIsBaseView ) // View to render is BaseView |
---|
| 816 | { |
---|
| 817 | std::cout << "Copied Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
| 818 | apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original |
---|
| 819 | } |
---|
| 820 | else // Render |
---|
| 821 | { |
---|
| 822 | std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
| 823 | cCurModel.setSingleModel( iSynthViewIdx, |
---|
| 824 | m_cCameraData.getSynthViewShiftLUTI()[iLeftBaseViewIdx ][iSynthViewIdx] , |
---|
| 825 | m_cCameraData.getBaseViewShiftLUTI ()[iLeftBaseViewIdx ][iRightBaseViewIdx], |
---|
| 826 | m_cCameraData.getSynthViewShiftLUTI()[iRightBaseViewIdx][iSynthViewIdx] , |
---|
| 827 | m_cCameraData.getBaseViewShiftLUTI ()[iRightBaseViewIdx][iLeftBaseViewIdx] , |
---|
| 828 | iRelDistToLeft, |
---|
| 829 | NULL ); |
---|
| 830 | cCurModel.getSynthVideo ( iSynthViewIdx, VIEWPOS_MERGED, pcPicYuvSynthOut ); |
---|
| 831 | } |
---|
| 832 | break; |
---|
| 833 | /// EXTRAPOLATION FROM LEFT |
---|
| 834 | case 1: |
---|
| 835 | |
---|
| 836 | if ( !bHasLView ) // View to render is BaseView |
---|
| 837 | { |
---|
| 838 | std::cout << "Copied Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
| 839 | apcPicYuvBaseVideo[iLeftBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original |
---|
| 840 | } |
---|
| 841 | else // Render |
---|
| 842 | { |
---|
| 843 | std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
| 844 | cCurModel.setSingleModel( iSynthViewIdx, m_cCameraData.getSynthViewShiftLUTI()[iLeftBaseViewIdx ][iSynthViewIdx], NULL, NULL, NULL, -1, NULL); |
---|
| 845 | cCurModel.getSynthVideo ( iSynthViewIdx, VIEWPOS_LEFT, pcPicYuvSynthOut ); |
---|
| 846 | } |
---|
| 847 | break; |
---|
| 848 | /// EXTRAPOLATION FROM RIGHT |
---|
| 849 | case 2: // extrapolation from right |
---|
| 850 | if ( !bHasRView ) // View to render is BaseView |
---|
| 851 | { |
---|
| 852 | std::cout << "Copied Frame " << iFrame << " of BaseView " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
| 853 | apcPicYuvBaseVideo[iRightBaseViewIdx]->copyToPic( pcPicYuvSynthOut ); // Copy Original |
---|
| 854 | } |
---|
| 855 | else // Render |
---|
| 856 | { |
---|
| 857 | std::cout << "Rendering Frame " << iFrame << " of View " << (Double) m_cCameraData.getSynthViewNumbers()[iSynthViewIdx] / VIEW_NUM_PREC << std::endl; |
---|
| 858 | cCurModel.setSingleModel( iSynthViewIdx, NULL , NULL, m_cCameraData.getSynthViewShiftLUTI()[iRightBaseViewIdx ][iSynthViewIdx], NULL, -1, NULL); |
---|
| 859 | cCurModel.getSynthVideo ( iSynthViewIdx, VIEWPOS_RIGHT, pcPicYuvSynthOut ); |
---|
| 860 | } |
---|
| 861 | break; |
---|
| 862 | } |
---|
| 863 | |
---|
| 864 | // Write Output |
---|
| 865 | m_apcTVideoIOYuvSynthOutput[m_bSweep ? 0 : iSynthViewIdx]->write( pcPicYuvSynthOut, 0, 0, 0, 0 ); |
---|
| 866 | } |
---|
| 867 | iFrame++; |
---|
| 868 | iNumOfRenderedFrames++; |
---|
| 869 | } |
---|
| 870 | |
---|
| 871 | // Delete Buffers |
---|
| 872 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
| 873 | { |
---|
| 874 | apcPicYuvBaseVideo[uiBaseView]->destroy(); |
---|
| 875 | delete apcPicYuvBaseVideo[uiBaseView]; |
---|
| 876 | |
---|
| 877 | apcPicYuvBaseDepth[uiBaseView]->destroy(); |
---|
| 878 | delete apcPicYuvBaseDepth[uiBaseView]; |
---|
| 879 | } |
---|
| 880 | pcPicYuvSynthOut->destroy(); |
---|
| 881 | delete pcPicYuvSynthOut; |
---|
| 882 | |
---|
| 883 | xDestroyLib(); |
---|
| 884 | |
---|
| 885 | } |
---|
[446] | 886 | #endif |
---|
[438] | 887 | |
---|
| 888 | Void TAppRendererTop::renderUsedPelsMap( ) |
---|
| 889 | { |
---|
| 890 | xCreateLib(); |
---|
| 891 | xInitLib(); |
---|
| 892 | |
---|
| 893 | // Create Buffers Input Views; |
---|
| 894 | std::vector<TComPicYuv*> apcPicYuvBaseVideo; |
---|
| 895 | std::vector<TComPicYuv*> apcPicYuvBaseDepth; |
---|
| 896 | |
---|
| 897 | // TemporalImprovement Filter |
---|
| 898 | std::vector<TComPicYuv*> apcPicYuvLastBaseVideo; |
---|
| 899 | std::vector<TComPicYuv*> apcPicYuvLastBaseDepth; |
---|
| 900 | |
---|
| 901 | Int aiPad[2] = { 0, 0 }; |
---|
| 902 | |
---|
| 903 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
| 904 | { |
---|
| 905 | TComPicYuv* pcNewVideoPic = new TComPicYuv; |
---|
| 906 | TComPicYuv* pcNewDepthPic = new TComPicYuv; |
---|
| 907 | |
---|
| 908 | pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
| 909 | apcPicYuvBaseVideo.push_back(pcNewVideoPic); |
---|
| 910 | |
---|
| 911 | pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
| 912 | apcPicYuvBaseDepth.push_back(pcNewDepthPic); |
---|
| 913 | |
---|
| 914 | //Temporal improvement Filter |
---|
| 915 | if ( m_bTempDepthFilter ) |
---|
| 916 | { |
---|
| 917 | pcNewVideoPic = new TComPicYuv; |
---|
| 918 | pcNewDepthPic = new TComPicYuv; |
---|
| 919 | |
---|
| 920 | pcNewVideoPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
| 921 | apcPicYuvLastBaseVideo.push_back(pcNewVideoPic); |
---|
| 922 | |
---|
| 923 | pcNewDepthPic->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
| 924 | apcPicYuvLastBaseDepth.push_back(pcNewDepthPic); |
---|
| 925 | } |
---|
| 926 | } |
---|
| 927 | |
---|
| 928 | // Create Buffer for synthesized View |
---|
| 929 | TComPicYuv* pcPicYuvSynthOut = new TComPicYuv; |
---|
| 930 | pcPicYuvSynthOut->create( m_iSourceWidth, m_iSourceHeight, 1, 1, 1 ); |
---|
| 931 | |
---|
| 932 | Bool bAnyEOS = false; |
---|
| 933 | |
---|
| 934 | Int iNumOfRenderedFrames = 0; |
---|
| 935 | Int iFrame = 0; |
---|
| 936 | |
---|
| 937 | while ( ( ( iNumOfRenderedFrames < m_iFramesToBeRendered ) || ( m_iFramesToBeRendered == 0 ) ) && !bAnyEOS ) |
---|
| 938 | { |
---|
| 939 | |
---|
| 940 | |
---|
| 941 | if ( iFrame >= m_iFrameSkip ) |
---|
| 942 | { |
---|
| 943 | // read in depth and video |
---|
| 944 | for(Int iBaseViewIdx=0; iBaseViewIdx < m_iNumberOfInputViews; iBaseViewIdx++ ) |
---|
| 945 | { |
---|
| 946 | m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->read( apcPicYuvBaseVideo[iBaseViewIdx], aiPad ) ; |
---|
| 947 | apcPicYuvBaseVideo[iBaseViewIdx]->extendPicBorder(); |
---|
| 948 | bAnyEOS |= m_apcTVideoIOYuvVideoInput[iBaseViewIdx]->isEof(); |
---|
| 949 | |
---|
| 950 | m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->read( apcPicYuvBaseDepth[iBaseViewIdx], aiPad ) ; |
---|
| 951 | apcPicYuvBaseDepth[iBaseViewIdx]->extendPicBorder(); |
---|
| 952 | bAnyEOS |= m_apcTVideoIOYuvDepthInput[iBaseViewIdx]->isEof(); |
---|
| 953 | |
---|
| 954 | if ( m_bTempDepthFilter && (iFrame >= m_iFrameSkip) ) |
---|
| 955 | { |
---|
| 956 | m_pcRenTop->temporalFilterVSRS( apcPicYuvBaseVideo[iBaseViewIdx], apcPicYuvBaseDepth[iBaseViewIdx], apcPicYuvLastBaseVideo[iBaseViewIdx], apcPicYuvLastBaseDepth[iBaseViewIdx], ( iFrame == m_iFrameSkip) ); |
---|
| 957 | } |
---|
| 958 | } |
---|
| 959 | } |
---|
| 960 | else |
---|
| 961 | { |
---|
| 962 | std::cout << "Skipping Frame " << iFrame << std::endl; |
---|
| 963 | |
---|
| 964 | iFrame++; |
---|
| 965 | continue; |
---|
| 966 | } |
---|
| 967 | m_cCameraData.update( (UInt) ( iFrame - m_iFrameSkip ) ); |
---|
| 968 | |
---|
| 969 | for(Int iViewIdx=1; iViewIdx < m_iNumberOfInputViews; iViewIdx++ ) |
---|
| 970 | { |
---|
| 971 | std::cout << "Rendering UsedPelsMap for Frame " << iFrame << " of View " << (Double) m_cCameraData.getBaseViewNumbers()[iViewIdx] << std::endl; |
---|
| 972 | |
---|
| 973 | Int iViewSIdx = m_cCameraData.getBaseId2SortedId()[iViewIdx]; |
---|
| 974 | Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0]; |
---|
| 975 | |
---|
| 976 | AOT( iViewSIdx == iFirstViewSIdx ); |
---|
| 977 | |
---|
| 978 | Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx); |
---|
| 979 | |
---|
| 980 | m_pcRenTop->setShiftLUTs( |
---|
| 981 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
| 982 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
| 983 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
| 984 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
| 985 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
| 986 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
| 987 | -1 |
---|
| 988 | ); |
---|
| 989 | |
---|
| 990 | m_pcRenTop->getUsedSamplesMap( apcPicYuvBaseDepth[0], pcPicYuvSynthOut, bFirstIsLeft ); |
---|
| 991 | |
---|
| 992 | // Write Output |
---|
| 993 | m_apcTVideoIOYuvSynthOutput[iViewIdx-1]->write( pcPicYuvSynthOut, 0, 0, 0 ); |
---|
| 994 | |
---|
| 995 | } |
---|
| 996 | iFrame++; |
---|
| 997 | iNumOfRenderedFrames++; |
---|
| 998 | } |
---|
| 999 | |
---|
| 1000 | // Delete Buffers |
---|
| 1001 | for ( UInt uiBaseView = 0; uiBaseView < m_iNumberOfInputViews; uiBaseView++ ) |
---|
| 1002 | { |
---|
| 1003 | apcPicYuvBaseVideo[uiBaseView]->destroy(); |
---|
| 1004 | delete apcPicYuvBaseVideo[uiBaseView]; |
---|
| 1005 | |
---|
| 1006 | apcPicYuvBaseDepth[uiBaseView]->destroy(); |
---|
| 1007 | delete apcPicYuvBaseDepth[uiBaseView]; |
---|
| 1008 | |
---|
| 1009 | // Temporal Filter |
---|
| 1010 | if ( m_bTempDepthFilter ) |
---|
| 1011 | { |
---|
| 1012 | apcPicYuvLastBaseVideo[uiBaseView]->destroy(); |
---|
| 1013 | delete apcPicYuvLastBaseVideo[uiBaseView]; |
---|
| 1014 | |
---|
| 1015 | apcPicYuvLastBaseDepth[uiBaseView]->destroy(); |
---|
| 1016 | delete apcPicYuvLastBaseDepth[uiBaseView]; |
---|
| 1017 | } |
---|
| 1018 | } |
---|
| 1019 | pcPicYuvSynthOut->destroy(); |
---|
| 1020 | delete pcPicYuvSynthOut; |
---|
| 1021 | |
---|
| 1022 | xDestroyLib(); |
---|
| 1023 | |
---|
| 1024 | } |
---|
| 1025 | #endif |
---|