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