Changeset 608 in 3DVCSoftware for trunk/source/App/TAppDecoder/TAppDecTop.cpp
- Timestamp:
- 1 Sep 2013, 22:47:26 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/App/TAppDecoder/TAppDecTop.cpp
r443 r608 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 2, ITU/ISO/IEC6 * Copyright (c) 2010-2013, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 54 54 55 55 TAppDecTop::TAppDecTop() 56 #if !H_MV 57 : m_iPOCLastDisplay(-MAX_INT) 58 #else 59 : m_numDecoders( 0 ) 60 #endif 56 61 { 57 62 ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag)); 58 m_useDepth = false; 59 m_pScaleOffsetFile = 0; 63 #if H_MV 64 for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) m_layerIdToDecIdx[i] = -1; 65 #endif 66 #if H_3D 67 m_pScaleOffsetFile = 0; 68 #endif 60 69 } 61 70 … … 66 75 Void TAppDecTop::destroy() 67 76 { 77 if (m_pchBitstreamFile) 78 { 79 free (m_pchBitstreamFile); 80 m_pchBitstreamFile = NULL; 81 } 82 #if H_MV 83 for (Int decIdx = 0; decIdx < m_numDecoders; decIdx++) 84 { 85 if (m_pchReconFiles[decIdx]) 86 { 87 free (m_pchReconFiles[decIdx]); 88 m_pchReconFiles[decIdx] = NULL; 89 } 90 } 91 #endif 92 if (m_pchReconFile) 93 { 94 free (m_pchReconFile); 95 m_pchReconFile = NULL; 96 } 97 #if H_3D 98 if (m_pchScaleOffsetFile) 99 { 100 free (m_pchScaleOffsetFile); 101 m_pchScaleOffsetFile = NULL; 102 } 103 #endif 68 104 } 69 105 … … 82 118 Void TAppDecTop::decode() 83 119 { 84 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 85 increaseNumberOfViews( 0, 0, 0 ); 86 #else 87 increaseNumberOfViews( 1 ); 88 #endif 89 90 #if FLEX_CODING_ORDER_M23723 91 Int iDepthViewIdx = 0; 92 Int iTextureViewIdx=0; 93 Bool firstFrame=1; 94 Bool viewIdZero=true; 95 Int fcoIndex=0; //when the current frame is not first frame,use FCO_index stand for viewDepth. 96 #endif 97 98 Int viewDepthId = 0; 99 Int previousViewDepthId = 0; 100 UInt uiPOC[MAX_VIEW_NUM*2]; 101 TComList<TComPic*>* pcListPic[MAX_VIEW_NUM*2]; 102 Bool newPicture[MAX_VIEW_NUM*2]; 103 Bool previousPictureDecoded = false; 104 for( Int i = 0; i < MAX_VIEW_NUM*2; i++ ) 105 { 106 uiPOC[i] = 0; 107 pcListPic[i] = NULL; 108 newPicture[i] = false; 109 #if FLEX_CODING_ORDER_M23723 110 m_fcoOrder[i] = ' '; 111 #endif 112 113 } 120 Int poc; 121 #if H_MV 122 poc = -1; 123 #endif 124 TComList<TComPic*>* pcListPic = NULL; 114 125 115 126 ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary); … … 120 131 } 121 132 133 #if H_3D 122 134 if( m_pchScaleOffsetFile ) 123 135 { … … 126 138 } 127 139 m_cCamParsCollector.init( m_pScaleOffsetFile ); 128 140 #endif 129 141 InputByteStream bytestream(bitstreamFile); 130 142 143 // create & initialize internal classes 144 xCreateDecLib(); 145 xInitDecLib (); 146 #if !H_MV 147 m_iPOCLastDisplay += m_iSkipFrame; // set the last displayed POC correctly for skip forward. 148 149 // main decoder loop 150 Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen) 151 #else 152 #if H_3D 153 Int pocCurrPic = -MAX_INT; 154 Int pocLastPic = -MAX_INT; 155 #endif 156 157 Int layerIdCurrPic = 0; 158 159 Int decIdxLastPic = 0; 160 Int decIdxCurrPic = 0; 161 162 Bool firstSlice = true; 163 #endif 164 131 165 while (!!bitstreamFile) 132 166 { … … 136 170 * nal unit. */ 137 171 streampos location = bitstreamFile.tellg(); 172 #if H_MV 173 #if ENC_DEC_TRACE 174 Int64 symCount = g_nSymbolCounter; 175 #endif 176 #endif 138 177 AnnexBStats stats = AnnexBStats(); 178 #if !H_MV 179 Bool bPreviousPictureDecoded = false; 180 #endif 181 139 182 vector<uint8_t> nalUnit; 140 183 InputNALUnit nalu; … … 142 185 143 186 // call actual decoding function 187 Bool bNewPicture = false; 188 #if H_MV 189 Bool newSliceDiffPoc = false; 190 Bool newSliceDiffLayer = false; 191 #if H_3D 192 Bool allLayersDecoded = false; 193 #endif 194 #endif 144 195 if (nalUnit.empty()) 145 196 { … … 154 205 { 155 206 read(nalu, nalUnit); 156 #if QC_MVHEVC_B0046 157 viewDepthId = nalu.m_layerId; 158 Int depth = 0; 159 Int viewId = viewDepthId; 160 #else 161 #if VIDYO_VPS_INTEGRATION 162 Int viewId = 0; 163 Int depth = 0; 207 #if H_MV 208 Int decIdx = xGetDecoderIdx( nalu.m_layerId , true ); 164 209 165 if(nalu.m_nalUnitType != NAL_UNIT_VPS || nalu.m_layerId) 166 { 167 // code assumes that the first nal unit is VPS 168 // currently, this is a hack that requires non-first VPSs have non-zero layer_id 169 viewId = getVPSAccess()->getActiveVPS()->getViewId(nalu.m_layerId); 170 depth = getVPSAccess()->getActiveVPS()->getDepthFlag(nalu.m_layerId); 171 } 172 #if FLEX_CODING_ORDER_M23723 173 if (viewId>0) 174 { 175 viewIdZero=false; 176 } 177 if (viewIdZero==false&&viewId==0) 178 { 179 firstFrame=0; //if viewId has been more than zero and now it set to zero again, we can see that it is not the first view 180 } 181 if (firstFrame) 182 { // if the current view is first frame, we set the viewDepthId as texture plus depth and get the FCO order 183 viewDepthId = iDepthViewIdx+iTextureViewIdx; 184 m_fcoViewDepthId=viewDepthId; 210 if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) ) 211 { 212 bNewPicture = false; 185 213 } 186 214 else 187 {//if current view is not first frame, we set the viewDepthId depended on the FCO order 188 viewDepthId=0; 189 if (depth) 215 { 216 newSliceDiffLayer = nalu.isSlice() && ( nalu.m_layerId != layerIdCurrPic ) && !firstSlice; 217 newSliceDiffPoc = m_tDecTop[decIdx]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[decIdx], newSliceDiffLayer ); 218 // decode function only returns true when all of the following conditions are true 219 // - poc in particular layer changes 220 // - nalu does not belong to first slice in layer 221 // - nalu.isSlice() == true 222 223 bNewPicture = newSliceDiffLayer || newSliceDiffPoc; 224 225 if ( nalu.isSlice() && firstSlice ) 190 226 { 191 for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ ) 192 { 193 if (m_fcoOrder[fcoIndex]=='D') 194 { 195 if (viewId==viewDepthId) 196 break; 197 else 198 viewDepthId++; 199 } 200 } 227 layerIdCurrPic = nalu.m_layerId; 228 #if H_3D 229 pocCurrPic = m_tDecTop[decIdx]->getCurrPoc(); 230 #endif 231 decIdxCurrPic = decIdx; 232 firstSlice = false; 233 } 234 235 if ( bNewPicture || !bitstreamFile ) 236 { 237 layerIdCurrPic = nalu.m_layerId; 238 #if H_3D 239 pocLastPic = pocCurrPic; 240 pocCurrPic = m_tDecTop[decIdx]->getCurrPoc(); 241 #endif 242 decIdxLastPic = decIdxCurrPic; 243 decIdxCurrPic = decIdx; 244 #if H_3D 245 allLayersDecoded = ( pocCurrPic != pocLastPic ); 246 #endif 247 } 248 249 250 #else 251 if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) ) 252 { 253 if(bPreviousPictureDecoded) 254 { 255 bNewPicture = true; 256 bPreviousPictureDecoded = false; 201 257 } 202 258 else 203 259 { 204 for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ ) 205 { 206 if (m_fcoOrder[fcoIndex]=='T') 207 { 208 if (viewId==viewDepthId) 209 break; 210 else 211 viewDepthId++; 212 } 213 } 260 bNewPicture = false; 214 261 } 215 216 viewDepthId=fcoIndex;217 218 }219 220 221 #else222 viewDepthId = nalu.m_layerId; // coding order T0D0T1D1T2D2223 #endif224 225 #else226 Int viewId = nalu.m_viewId;227 Int depth = nalu.m_isDepth ? 1 : 0;228 #if FLEX_CODING_ORDER_M23723229 if (viewId>0)230 {231 viewIdZero=false;232 }233 if (viewIdZero==false&&viewId==0)234 {235 firstFrame=0;236 }237 if (firstFrame)238 {239 viewDepthId = iDepthViewIdx+iTextureViewIdx;240 m_fcoViewDepthId=viewDepthId;241 262 } 242 263 else 243 264 { 244 viewDepthId=0; 245 if (depth) 246 { 247 for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ ) 248 { 249 if (m_fcoOrder[fcoIndex]=='D') 250 { 251 if (viewId==viewDepthId) 252 break; 253 else 254 viewDepthId++; 255 } 256 } 257 } 258 else 259 { 260 for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ ) 261 { 262 if (m_fcoOrder[fcoIndex]=='T') 263 { 264 if (viewId==viewDepthId) 265 break; 266 else 267 viewDepthId++; 268 } 269 } 270 } 271 viewDepthId=fcoIndex; 272 } 273 #else 274 viewDepthId = viewId * 2 + depth; // coding order T0D0T1D1T2D2 275 #endif 276 #endif 277 #endif 278 newPicture[viewDepthId] = false; 279 if( viewDepthId >= m_tDecTop.size() ) 280 { 281 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 282 increaseNumberOfViews( viewDepthId, viewId, depth ); 283 #else 284 increaseNumberOfViews( viewDepthId +1 ); 285 #endif 286 } 287 if(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) 288 { 289 previousPictureDecoded = false; 290 } 291 if(m_tDecTop.size() > 1 && (viewDepthId != previousViewDepthId) && previousPictureDecoded ) 292 { 293 m_tDecTop[previousViewDepthId]->executeDeblockAndAlf(uiPOC[previousViewDepthId], pcListPic[previousViewDepthId], m_iSkipFrame, m_pocLastDisplay[previousViewDepthId]); 294 } 295 if( ( viewDepthId == 0 && (viewDepthId != previousViewDepthId) ) || m_tDecTop.size() == 1 ) 296 { 297 #if H3D_IVRP 298 for( Int i = 0; i < m_tDecTop.size(); i++ ) 299 { 300 m_tDecTop[i]->deleteExtraPicBuffers( uiPOC[i] ); 301 } 302 #endif 303 for( Int i = 0; i < m_tDecTop.size(); i++ ) 304 { 305 m_tDecTop[i]->compressMotion( uiPOC[i] ); 306 } 307 } 308 if( !(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) ) 309 { 310 #if QC_MVHEVC_B0046 311 if(viewDepthId && m_tDecTop[viewDepthId]->m_bFirstNal== false) 312 { 313 m_tDecTop[viewDepthId]->m_bFirstNal = true; 314 ParameterSetManagerDecoder* pDecV0 = m_tDecTop[0]->xGetParaSetDec(); 315 m_tDecTop[viewDepthId]->xCopyVPS(pDecV0->getPrefetchedVPS(0)); 316 m_tDecTop[viewDepthId]->xCopySPS(pDecV0->getPrefetchedSPS(0)); 317 m_tDecTop[viewDepthId]->xCopyPPS(pDecV0->getPrefetchedPPS(0)); 318 } 319 #endif 320 newPicture[viewDepthId] = m_tDecTop[viewDepthId]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[viewDepthId]); 321 if (newPicture[viewDepthId]) 265 bNewPicture = m_cTDecTop.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay); 266 #endif 267 if (bNewPicture) 322 268 { 323 269 bitstreamFile.clear(); … … 328 274 bitstreamFile.seekg(location-streamoff(3)); 329 275 bytestream.reset(); 276 #if ENC_DEC_TRACE 277 #if H_MV_ENC_DEC_TRAC 278 const Bool resetCounter = false; 279 if ( resetCounter ) 280 { 281 g_nSymbolCounter = symCount; // Only reset counter SH becomes traced twice 282 } 283 else 284 { 285 g_disableHLSTrace = true; // Trancing of second parsing of SH is not carried out 286 } 287 #else 288 g_nSymbolCounter = symCount; 289 #endif 290 #endif 330 291 } 331 if( nalu.isSlice() ) 332 { 333 previousPictureDecoded = true; 334 #if FLEX_CODING_ORDER_M23723 335 if (firstFrame) 336 { 337 if (depth) 338 { 339 iDepthViewIdx++; 340 m_fcoOrder[viewDepthId]='D'; 341 } 342 else 343 { 344 iTextureViewIdx++; 345 m_fcoOrder[viewDepthId]='T'; 346 } 347 } 348 349 #endif 350 } 351 } 352 } 353 if( ( (newPicture[viewDepthId] || !bitstreamFile) && m_tDecTop.size() == 1) || (!bitstreamFile && previousPictureDecoded == true) ) 354 { 355 m_tDecTop[viewDepthId]->executeDeblockAndAlf(uiPOC[viewDepthId], pcListPic[viewDepthId], m_iSkipFrame, m_pocLastDisplay[viewDepthId]); 356 } 357 if( pcListPic[viewDepthId] ) 358 { 359 #if QC_REM_IDV_B0046 360 Int iviewId = m_tDecTop[viewDepthId]->getViewId(); 361 if( newPicture[viewDepthId] && (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR || ((nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR && iviewId) && m_tDecTop[viewDepthId]->getNalUnitTypeBaseView() == NAL_UNIT_CODED_SLICE_IDR)) ) 362 #else 363 if( newPicture[viewDepthId] && (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDV && m_tDecTop[viewDepthId]->getNalUnitTypeBaseView() == NAL_UNIT_CODED_SLICE_IDR)) ) 364 #endif 365 { 366 xFlushOutput( pcListPic[viewDepthId], viewDepthId ); 292 #if !H_MV 293 bPreviousPictureDecoded = true; 294 #endif 295 } 296 } 297 if (bNewPicture || !bitstreamFile) 298 { 299 #if H_MV 300 assert( decIdxLastPic != -1 ); 301 m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet ); 302 #else 303 m_cTDecTop.executeLoopFilters(poc, pcListPic); 304 #endif 305 } 306 #if H_3D 307 if ( allLayersDecoded || !bitstreamFile ) 308 { 309 for( Int dI = 0; dI < m_numDecoders; dI++ ) 310 { 311 TComPic* picLastCoded = m_ivPicLists.getPic( m_tDecTop[dI]->getLayerId(), pocLastPic ); 312 assert( picLastCoded != NULL ); 313 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 314 picLastCoded->compressMotion(1); 315 #else 316 picLastCoded->compressMotion(); 317 #endif 318 } 319 } 320 #endif 321 322 if( pcListPic ) 323 { 324 #if H_MV 325 if ( m_pchReconFiles[decIdxLastPic] && !m_reconOpen[decIdxLastPic] ) 326 #else 327 if ( m_pchReconFile && !recon_opened ) 328 #endif 329 { 330 if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; } 331 if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; } 332 333 #if H_MV 334 m_tVideoIOYuvReconFile[decIdxLastPic]->open( m_pchReconFiles[decIdxLastPic], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode 335 m_reconOpen[decIdxLastPic] = true; 336 } 337 if ( bNewPicture && newSliceDiffPoc && 338 #else 339 m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode 340 recon_opened = true; 341 } 342 if ( bNewPicture && 343 #endif 344 ( nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL 345 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP 346 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP 347 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL 348 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) ) 349 { 350 #if H_MV 351 xFlushOutput( pcListPic, decIdxLastPic ); 352 #else 353 xFlushOutput( pcListPic ); 354 #endif 367 355 } 368 356 // write reconstruction to file 369 if(newPicture[viewDepthId]) 370 { 371 xWriteOutput( pcListPic[viewDepthId], viewDepthId, nalu.m_temporalId ); 372 } 373 } 374 previousViewDepthId = viewDepthId; 375 } 357 if(bNewPicture) 358 { 359 #if H_MV 360 xWriteOutput( pcListPic, decIdxLastPic, nalu.m_temporalId ); 361 } 362 } 363 } 364 365 #if H_3D 376 366 if( m_cCamParsCollector.isInitialized() ) 377 367 { 378 368 m_cCamParsCollector.setSlice( 0 ); 379 369 } 380 // last frame 381 for( Int viewDepthIdx = 0; viewDepthIdx < m_tDecTop.size(); viewDepthIdx++ ) 382 { 383 xFlushOutput( pcListPic[viewDepthIdx], viewDepthIdx ); 384 } 370 #endif 371 for(UInt decIdx = 0; decIdx < m_numDecoders; decIdx++) 372 { 373 xFlushOutput( m_tDecTop[decIdx]->getListPic(), decIdx ); 374 } 375 #else 376 xWriteOutput( pcListPic, nalu.m_temporalId ); 377 } 378 } 379 } 380 381 xFlushOutput( pcListPic ); 382 // delete buffers 383 m_cTDecTop.deletePicBuffer(); 384 #endif 385 386 // destroy internal classes 385 387 xDestroyDecLib(); 386 388 } … … 390 392 // ==================================================================================================================== 391 393 394 Void TAppDecTop::xCreateDecLib() 395 { 396 #if H_MV 397 // initialize global variables 398 initROM(); 399 #if H_3D_DIM_DMM 400 initWedgeLists(); 401 #endif 402 #else 403 // create decoder class 404 m_cTDecTop.create(); 405 #endif 406 } 407 392 408 Void TAppDecTop::xDestroyDecLib() 393 409 { 394 395 for(Int viewDepthIdx=0; viewDepthIdx<m_tVideoIOYuvReconFile.size() ; viewDepthIdx++) 396 { 397 if( m_tVideoIOYuvReconFile[viewDepthIdx] ) 398 { 399 m_tVideoIOYuvReconFile[viewDepthIdx]->close(); 400 delete m_tVideoIOYuvReconFile[viewDepthIdx]; 401 m_tVideoIOYuvReconFile[viewDepthIdx] = NULL ; 402 } 403 } 404 405 for(Int viewDepthIdx=0; viewDepthIdx<m_tDecTop.size() ; viewDepthIdx++) 406 { 407 if( m_tDecTop[viewDepthIdx] ) 408 { 409 if( !m_useDepth && (viewDepthIdx % 2 == 1) ) 410 { 411 } 412 else 413 { 414 m_tDecTop[viewDepthIdx]->deletePicBuffer(); 415 m_tDecTop[viewDepthIdx]->destroy() ; 416 } 417 #if QC_MVHEVC_B0046 418 if(viewDepthIdx) 419 { 420 //Call clear function to remove the record, which has been freed during viewDepthIdx = 0 case. 421 m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearSPS(); 422 m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearVPS(); 423 m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearPPS(); 424 } 425 #endif 426 delete m_tDecTop[viewDepthIdx] ; 427 m_tDecTop[viewDepthIdx] = NULL ; 428 } 429 } 430 410 #if H_MV 411 // destroy ROM 412 destroyROM(); 413 414 for(Int decIdx = 0; decIdx < m_numDecoders ; decIdx++) 415 { 416 if( m_tVideoIOYuvReconFile[decIdx] ) 417 { 418 m_tVideoIOYuvReconFile[decIdx]->close(); 419 delete m_tVideoIOYuvReconFile[decIdx]; 420 m_tVideoIOYuvReconFile[decIdx] = NULL ; 421 } 422 423 if( m_tDecTop[decIdx] ) 424 { 425 m_tDecTop[decIdx]->deletePicBuffer(); 426 m_tDecTop[decIdx]->destroy() ; 427 } 428 delete m_tDecTop[decIdx] ; 429 m_tDecTop[decIdx] = NULL ; 430 } 431 #else 432 if ( m_pchReconFile ) 433 { 434 m_cTVideoIOYuvReconFile. close(); 435 } 436 437 // destroy decoder class 438 m_cTDecTop.destroy(); 439 #endif 440 #if H_3D 431 441 m_cCamParsCollector.uninit(); 432 442 if( m_pScaleOffsetFile ) … … 434 444 ::fclose( m_pScaleOffsetFile ); 435 445 } 436 } 437 438 Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int viewDepthId, UInt tId ) 446 #endif 447 } 448 449 Void TAppDecTop::xInitDecLib() 450 { 451 #if !H_MV 452 // initialize decoder class 453 m_cTDecTop.init(); 454 m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); 455 #endif 456 } 457 458 /** \param pcListPic list of pictures to be written to file 459 \todo DYN_REF_FREE should be revised 460 */ 461 #if H_MV 462 Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int decIdx, Int tId ) 463 #else 464 Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt tId ) 465 #endif 439 466 { 440 467 TComList<TComPic*>::iterator iterPic = pcListPic->begin(); … … 444 471 { 445 472 TComPic* pcPic = *(iterPic); 446 if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[viewDepthId]) 473 #if H_MV 474 if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx]) 475 #else 476 if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay) 477 #endif 447 478 { 448 479 not_displayed++; … … 455 486 { 456 487 TComPic* pcPic = *(iterPic); 457 TComSPS *sps = pcPic->getSlice(0)->getSPS();458 488 459 if ( pcPic->getOutputMark() && (not_displayed > pcPic->getSlice(0)->getSPS()->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[viewDepthId])) 489 #if H_MV 490 if ( pcPic->getOutputMark() && (not_displayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[decIdx])) 491 #else 492 if ( pcPic->getOutputMark() && (not_displayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay)) 493 #endif 460 494 { 461 495 // write to file 462 496 not_displayed--; 497 #if H_MV 498 if ( m_pchReconFiles[decIdx] ) 499 #else 463 500 if ( m_pchReconFile ) 464 { 465 m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() ); 501 #endif 502 { 503 const Window &conf = pcPic->getConformanceWindow(); 504 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 505 #if H_MV 506 m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(), 507 #else 508 m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), 509 #endif 510 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 511 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 512 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 513 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); 466 514 } 467 515 468 516 // update POC of display order 469 m_pocLastDisplay[viewDepthId] = pcPic->getPOC(); 517 #if H_MV 518 m_pocLastDisplay[decIdx] = pcPic->getPOC(); 519 #else 520 m_iPOCLastDisplay = pcPic->getPOC(); 521 #endif 470 522 471 523 // erase non-referenced picture in the reference picture list after display … … 495 547 \todo DYN_REF_FREE should be revised 496 548 */ 497 Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int viewDepthId ) 549 #if H_MV 550 Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int decIdx ) 551 #else 552 Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic ) 553 #endif 498 554 { 499 555 if(!pcListPic) … … 508 564 { 509 565 TComPic* pcPic = *(iterPic); 510 TComSPS *sps = pcPic->getSlice(0)->getSPS();511 566 512 567 if ( pcPic->getOutputMark() ) 513 568 { 514 569 // write to file 570 #if H_MV 571 if ( m_pchReconFiles[decIdx] ) 572 #else 515 573 if ( m_pchReconFile ) 516 { 517 m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() ); 574 #endif 575 { 576 const Window &conf = pcPic->getConformanceWindow(); 577 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 578 #if H_MV 579 m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(), 580 #else 581 m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), 582 #endif 583 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 584 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 585 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 586 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); 518 587 } 519 588 520 589 // update POC of display order 521 m_pocLastDisplay[viewDepthId] = pcPic->getPOC(); 590 #if H_MV 591 m_pocLastDisplay[decIdx] = pcPic->getPOC(); 592 #else 593 m_iPOCLastDisplay = pcPic->getPOC(); 594 #endif 522 595 523 596 // erase non-referenced picture in the reference picture list after display … … 539 612 pcPic->setOutputMark(false); 540 613 } 541 614 #if !H_MV 615 #if !DYN_REF_FREE 616 if(pcPic) 617 { 618 pcPic->destroy(); 619 delete pcPic; 620 pcPic = NULL; 621 } 622 #endif 623 #endif 542 624 iterPic++; 543 625 } 626 #if H_MV 627 m_pocLastDisplay[decIdx] = -MAX_INT; 628 #else 544 629 pcListPic->clear(); 545 m_pocLastDisplay[viewDepthId] = -MAX_INT; 546 } 547 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 548 Void TAppDecTop::increaseNumberOfViews ( UInt layerId, UInt viewId, UInt isDepth ) 549 #else 550 Void TAppDecTop::increaseNumberOfViews ( Int newNumberOfViewDepth ) 551 #endif 552 { 553 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 554 Int newNumberOfViewDepth = layerId + 1; 555 #endif 556 if ( m_outputBitDepth == 0 ) 557 { 558 m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement; 559 } 560 #if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046 561 Int viewId = (newNumberOfViewDepth-1)>>1; // coding order T0D0T1D1T2D2 562 Bool isDepth = ((newNumberOfViewDepth % 2) == 0); // coding order T0D0T1D1T2D2 563 #endif 564 if( isDepth ) 565 m_useDepth = true; 566 567 if ( m_pchReconFile ) 568 { 569 while( m_tVideoIOYuvReconFile.size() < newNumberOfViewDepth) 570 { 571 m_tVideoIOYuvReconFile.push_back(new TVideoIOYuv); 572 Char buffer[4]; 573 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 574 sprintf(buffer,"_%i", viewId ); 575 #else 576 sprintf(buffer,"_%i", (Int)(m_tVideoIOYuvReconFile.size()-1) / 2 ); 577 #endif 578 Char* nextFilename = NULL; 579 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 580 if( isDepth) 581 #else 582 if( (m_tVideoIOYuvReconFile.size() % 2) == 0 ) 583 #endif 584 { 585 Char* pchTempFilename = NULL; 586 xAppendToFileNameEnd( m_pchReconFile, "_depth", pchTempFilename); 587 xAppendToFileNameEnd( pchTempFilename, buffer, nextFilename); 588 free ( pchTempFilename ); 589 } 590 else 591 { 592 xAppendToFileNameEnd( m_pchReconFile, buffer, nextFilename); 593 } 594 #if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046 595 if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) ) 596 #endif 597 { 598 m_tVideoIOYuvReconFile.back()->open( nextFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement ); 599 } 600 free ( nextFilename ); 601 } 602 } 603 604 while( m_pocLastDisplay.size() < newNumberOfViewDepth ) 605 { 606 m_pocLastDisplay.push_back(-MAX_INT+m_iSkipFrame); 607 } 608 while( m_tDecTop.size() < newNumberOfViewDepth) 609 { 610 m_tDecTop.push_back(new TDecTop); 611 #if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046 612 if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) ) 613 { 614 #endif 615 m_tDecTop.back()->create(); 616 m_tDecTop.back()->init( this, newNumberOfViewDepth == 1); 617 m_tDecTop.back()->setViewId( viewId ); 618 m_tDecTop.back()->setIsDepth( isDepth ); 619 m_tDecTop.back()->setPictureDigestEnabled(m_pictureDigestEnabled); 620 m_tDecTop.back()->setCamParsCollector( &m_cCamParsCollector ); 621 #if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046 622 } 623 #endif 624 } 625 } 626 627 TDecTop* TAppDecTop::getTDecTop( Int viewId, Bool isDepth ) 628 { 629 #if FLEX_CODING_ORDER_M23723 630 Int viewnumber=0; 631 Int i=0; 632 Bool fcoFlag=0; 633 if (viewId>m_fcoViewDepthId) 634 { 635 return NULL; 630 m_iPOCLastDisplay = -MAX_INT; 631 #endif 632 } 633 634 /** \param nalu Input nalu to check whether its LayerId is within targetDecLayerIdSet 635 */ 636 Bool TAppDecTop::isNaluWithinTargetDecLayerIdSet( InputNALUnit* nalu ) 637 { 638 if ( m_targetDecLayerIdSet.size() == 0 ) // By default, the set is empty, meaning all LayerIds are allowed 639 { 640 return true; 641 } 642 for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++) 643 { 644 #if H_MV 645 if ( nalu->m_layerId == (*it) ) 646 #else 647 if ( nalu->m_reservedZero6Bits == (*it) ) 648 #endif 649 { 650 return true; 651 } 652 } 653 return false; 654 } 655 656 #if H_MV 657 Int TAppDecTop::xGetDecoderIdx( Int layerId, Bool createFlag /*= false */ ) 658 { 659 Int decIdx = -1; 660 if ( m_layerIdToDecIdx[ layerId ] != -1 ) 661 { 662 decIdx = m_layerIdToDecIdx[ layerId ]; 636 663 } 637 664 else 638 { 639 if (isDepth) 640 { 641 for ( i=0; i<=m_fcoViewDepthId;i++) 642 { 643 if (m_fcoOrder[i]=='D') 644 { 645 if (viewnumber==viewId) 646 { 647 fcoFlag=1; 648 break; 649 } 650 else 651 viewnumber++; 652 } 653 } 654 } 655 else 656 { 657 for ( i=0; i<=m_fcoViewDepthId;i++) 658 { 659 if (m_fcoOrder[i]=='T') 660 { 661 if (viewnumber==viewId) 662 { 663 fcoFlag=1; 664 break; 665 } 666 else 667 viewnumber++; 668 } 669 } 670 } 671 if (fcoFlag) 672 { 673 return m_tDecTop[i]; 674 } 675 else 676 return NULL; 677 678 } 679 680 // coding order T0D0T1D1T2D2 681 #else 682 return m_tDecTop[(isDepth ? 1 : 0) + viewId * 2]; // coding order T0D0T1D1T2D2 683 #endif 684 685 } 686 687 std::vector<TComPic*> TAppDecTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps ) 688 { 689 std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL ); 690 for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ ) 691 { 692 TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth ); 693 assert( pcRefPic != NULL ); 694 apcRefPics[k] = pcRefPic; 695 } 696 return apcRefPics; 697 } 698 699 TComPic* TAppDecTop::xGetPicFromView( Int viewId, Int poc, Bool isDepth ) 700 { 701 assert( ( viewId >= 0 ) ); 702 703 #if FLEX_CODING_ORDER_M23723 704 if (getTDecTop(viewId,isDepth)) 705 { 706 TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic(); 707 TComPic* pcPic = NULL; 708 for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ ) 709 { 710 if( (*it)->getPOC() == poc ) 711 { 712 pcPic = *it; 713 break; 714 } 715 } 716 return pcPic; 717 } 718 else 719 return NULL; 720 #else 721 722 TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic(); 723 TComPic* pcPic = NULL; 724 for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ ) 725 { 726 if( (*it)->getPOC() == poc ) 727 { 728 pcPic = *it; 729 break; 730 } 731 } 732 return pcPic; 733 #endif 734 } 735 736 #if MERL_VSP_C0152 737 Void TAppDecTop::setBWVSPLUT( 738 #if MERL_VSP_NBDV_RefVId_Fix_D0166 739 Int iNeighborViewId, 740 #endif 741 TComSlice* pcSlice, Int iCodedViewIdx, Int iCurPoc) 742 743 { 744 //first view does not have VSP 745 if((iCodedViewIdx == 0)) return; 746 747 AOT( iCodedViewIdx <= 0); 748 //AOT( iCodedViewIdx >= m_iNumberOfViews ); 749 #if !MERL_VSP_NBDV_RefVId_Fix_D0166 750 Int iNeighborViewId = 0; 751 #endif 752 // Int* piShiftLUT = bRenderFromLeft ? m_cCamParsCollector.getBaseViewShiftLUTI()[iCodedViewIdx][iNeighborViewId][0] : m_cCamParsCollector.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0]; 753 Int* piShiftLUT = m_cCamParsCollector.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0]; 754 #if MERL_VSP_NBDV_RefVId_Fix_D0166 755 pcSlice->setBWVSPLUTParam(piShiftLUT, 2-LOG2_DISP_PREC_LUT, iNeighborViewId ); 756 #else 757 pcSlice->setBWVSPLUTParam(piShiftLUT, 2-LOG2_DISP_PREC_LUT ); 758 #endif 759 } 760 #endif 761 665 { 666 assert ( createFlag ); 667 assert( m_numDecoders < MAX_NUM_LAYERS ); 668 669 decIdx = m_numDecoders; 670 671 // Init decoder 672 m_tDecTop[ decIdx ] = new TDecTop; 673 m_tDecTop[ decIdx ]->create(); 674 m_tDecTop[ decIdx ]->init( ); 675 m_tDecTop[ decIdx ]->setLayerId( layerId ); 676 m_tDecTop[ decIdx ]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); 677 m_tDecTop[ decIdx ]->setIvPicLists( &m_ivPicLists ); 678 #if H_3D 679 m_tDecTop[ decIdx ]->setCamParsCollector( &m_cCamParsCollector ); 680 #endif 681 682 // append pic list of new decoder to PicLists 683 assert( m_ivPicLists.size() == m_numDecoders ); 684 m_ivPicLists.push_back( m_tDecTop[ decIdx ]->getListPic() ); 685 686 // create recon file related stuff 687 Char* pchTempFilename = NULL; 688 if ( m_pchReconFile ) 689 { 690 Char buffer[4]; 691 sprintf(buffer,"_%i", layerId ); 692 assert ( m_pchReconFile ); 693 xAppendToFileNameEnd( m_pchReconFile , buffer, pchTempFilename ); 694 assert( m_pchReconFiles.size() == m_numDecoders ); 695 } 696 697 m_pchReconFiles.push_back( pchTempFilename ); 698 699 m_tVideoIOYuvReconFile[ decIdx ] = new TVideoIOYuv; 700 m_reconOpen [ decIdx ] = false; 701 702 // set others 703 m_pocLastDisplay [ decIdx ] = -MAX_INT; 704 m_layerIdToDecIdx [ layerId ] = decIdx; 705 706 m_numDecoders++; 707 }; 708 return decIdx; 709 } 710 #endif 762 711 //! \}
Note: See TracChangeset for help on using the changeset viewer.