Changeset 368 in 3DVCSoftware for branches/HTM-DEV-0.1-dev/source/App/TAppDecoder
- Timestamp:
- 3 May 2013, 17:16:12 (12 years ago)
- Location:
- branches/HTM-DEV-0.1-dev/source/App/TAppDecoder
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/TAppDecCfg.cpp
r367 r368 42 42 #include "TAppCommon/program_options_lite.h" 43 43 44 #if H_MV 45 #include <cassert> 46 #endif 44 47 #ifdef WIN32 45 48 #define strdup _strdup … … 75 78 ("OutputBitDepth,d", m_outputBitDepthY, 0, "bit depth of YUV output luma component (default: use 0 for native depth)") 76 79 ("OutputBitDepthC,d", m_outputBitDepthC, 0, "bit depth of YUV output chroma component (default: use 0 for native depth)") 80 #if H_MV 81 ("MaxLayerId,-ls", m_maxLayerId, MAX_NUM_LAYER_IDS-1, "Maximum LayerId to be decoded.") 82 #endif 77 83 ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers") 78 84 ("SEIDecodedPictureHash", m_decodedPictureHashSEIEnabled, 1, "Control handling of decoded picture hash SEI messages\n" … … 151 157 } 152 158 } 159 #if H_MV 160 else 161 { 162 for ( Int curLayerId = 0; curLayerId <= m_maxLayerId; curLayerId++ ) 163 { 164 m_targetDecLayerIdSet.push_back( curLayerId ); 165 } 166 } 167 #endif 153 168 154 169 return true; 155 170 } 156 171 172 #if H_MV 173 Void TAppDecCfg::xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName) 174 { 175 size_t iInLength = strlen(pchInputFileName); 176 size_t iAppendLength = strlen(pchStringToAppend); 177 178 rpchOutputFileName = (Char*) malloc(iInLength+iAppendLength+1); 179 Char* pCDot = strrchr(pchInputFileName,'.'); 180 pCDot = pCDot ? pCDot : pchInputFileName + iInLength; 181 size_t iCharsToDot = pCDot - pchInputFileName ; 182 size_t iCharsToEnd = iInLength - iCharsToDot; 183 strncpy(rpchOutputFileName , pchInputFileName , iCharsToDot ); 184 strncpy(rpchOutputFileName+ iCharsToDot , pchStringToAppend , iAppendLength); 185 strncpy(rpchOutputFileName+ iCharsToDot+iAppendLength , pchInputFileName+iCharsToDot, iCharsToEnd ); 186 rpchOutputFileName[iInLength+iAppendLength] = '\0'; 187 } 188 #endif 157 189 //! \} -
branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/TAppDecCfg.h
r367 r368 58 58 protected: 59 59 Char* m_pchBitstreamFile; ///< input bitstream file name 60 #if H_MV 61 Int m_maxLayerId; ///< maximum nuh_layer_id decoded 62 std::vector<Char*> m_pchReconFiles; ///< array of output reconstruction file name create from output reconstruction file name 63 #endif 60 64 Char* m_pchReconFile; ///< output reconstruction file name 61 65 Int m_iSkipFrame; ///< counter for frames prior to the random access point to skip … … 69 73 Int m_respectDefDispWindow; ///< Only output content inside the default display window 70 74 75 #if H_MV 76 Void xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName); ///< create filenames 77 #endif 71 78 public: 72 79 TAppDecCfg() 73 80 : m_pchBitstreamFile(NULL) 81 #if H_MV 82 , m_maxLayerId(0) 83 , m_pchReconFiles(NULL) 84 #endif 74 85 , m_pchReconFile(NULL) 75 86 , m_iSkipFrame(0) -
branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/TAppDecTop.cpp
r367 r368 54 54 55 55 TAppDecTop::TAppDecTop() 56 #if !H_MV 56 57 : m_iPOCLastDisplay(-MAX_INT) 58 #else 59 : m_numDecoders( 0 ) 60 #endif 57 61 { 58 62 ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag)); 63 #if H_MV 64 for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) m_layerIdToDecIdx[i] = -1; 65 #endif 59 66 } 60 67 … … 70 77 m_pchBitstreamFile = NULL; 71 78 } 79 #if H_MV 80 for (Int decIdx = 0; decIdx < m_numDecoders; decIdx++) 81 { 82 if (m_pchReconFiles[decIdx]) 83 { 84 free (m_pchReconFiles[decIdx]); 85 m_pchReconFiles[decIdx] = NULL; 86 } 87 } 88 #endif 72 89 if (m_pchReconFile) 73 90 { … … 92 109 { 93 110 Int poc; 111 #if H_MV 112 poc = -1; 113 #endif 94 114 TComList<TComPic*>* pcListPic = NULL; 95 115 … … 106 126 xCreateDecLib(); 107 127 xInitDecLib (); 128 #if !H_MV 108 129 m_iPOCLastDisplay += m_iSkipFrame; // set the last displayed POC correctly for skip forward. 109 130 110 131 // main decoder loop 111 132 Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen) 133 #else 134 Int pocCurrPic = -MAX_INT; 135 Int pocLastPic = -MAX_INT; 136 137 Int layerIdLastPic = 0; 138 Int layerIdCurrPic = 0; 139 140 Int decIdxLastPic = 0; 141 Int decIdxCurrPic = 0; 142 143 Bool firstSlice = true; 144 #endif 112 145 113 146 while (!!bitstreamFile) … … 119 152 streampos location = bitstreamFile.tellg(); 120 153 AnnexBStats stats = AnnexBStats(); 154 #if !H_MV 121 155 Bool bPreviousPictureDecoded = false; 156 #endif 122 157 123 158 vector<uint8_t> nalUnit; … … 127 162 // call actual decoding function 128 163 Bool bNewPicture = false; 164 #if H_MV 165 Bool newSliceDiffPoc = false; 166 Bool newSliceDiffLayer = false; 167 Bool allLayersDecoded = false; 168 #endif 129 169 if (nalUnit.empty()) 130 170 { … … 139 179 { 140 180 read(nalu, nalUnit); 181 #if H_MV 182 Int decIdx = xGetDecoderIdx( nalu.m_layerId , true ); 183 184 if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) ) 185 { 186 bNewPicture = false; 187 } 188 else 189 { 190 newSliceDiffLayer = nalu.isSlice() && ( nalu.m_layerId != layerIdCurrPic ) && !firstSlice; 191 newSliceDiffPoc = m_tDecTop[decIdx]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[decIdx], newSliceDiffLayer ); 192 // decode function only returns true when all of the following conditions are true 193 // - poc in particular layer changes 194 // - nalu does not belong to first slice in layer 195 // - nalu.isSlice() == true 196 197 bNewPicture = newSliceDiffLayer || newSliceDiffPoc; 198 199 if ( nalu.isSlice() && firstSlice ) 200 { 201 layerIdCurrPic = nalu.m_layerId; 202 pocCurrPic = m_tDecTop[decIdx]->getCurrPoc(); 203 decIdxCurrPic = decIdx; 204 firstSlice = false; 205 } 206 207 if ( bNewPicture || !bitstreamFile ) 208 { 209 layerIdLastPic = layerIdCurrPic; 210 layerIdCurrPic = nalu.m_layerId; 211 212 pocLastPic = pocCurrPic; 213 pocCurrPic = m_tDecTop[decIdx]->getCurrPoc(); 214 215 decIdxLastPic = decIdxCurrPic; 216 decIdxCurrPic = decIdx; 217 218 allLayersDecoded = ( pocCurrPic != pocLastPic ); 219 } 220 221 222 #else 141 223 if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) ) 142 224 { … … 154 236 { 155 237 bNewPicture = m_cTDecTop.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay); 238 #endif 156 239 if (bNewPicture) 157 240 { … … 164 247 bytestream.reset(); 165 248 } 249 #if !H_MV 166 250 bPreviousPictureDecoded = true; 251 #endif 167 252 } 168 253 } 169 254 if (bNewPicture || !bitstreamFile) 170 255 { 256 #if H_MV 257 assert( decIdxLastPic != -1 ); 258 m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet ); 259 #else 171 260 m_cTDecTop.executeLoopFilters(poc, pcListPic); 172 } 261 #endif 262 } 263 #if H_3D 264 if ( allLayersDecoded || !bitstreamFile ) 265 { 266 for( Int dI = 0; dI < m_numDecoders; dI++ ) 267 { 268 TComPic* picLastCoded = m_ivPicLists.getPic( m_tDecTop[dI]->getLayerId(), pocLastPic ); 269 assert( picLastCoded != NULL ); 270 picLastCoded->compressMotion(); 271 } 272 } 273 #endif 173 274 174 275 if( pcListPic ) 175 276 { 277 #if H_MV 278 if ( m_pchReconFiles[decIdxLastPic] && !m_reconOpen[decIdxLastPic] ) 279 #else 176 280 if ( m_pchReconFile && !recon_opened ) 281 #endif 177 282 { 178 283 if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; } 179 284 if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; } 180 285 286 #if H_MV 287 m_tVideoIOYuvReconFile[decIdxLastPic]->open( m_pchReconFiles[decIdxLastPic], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode 288 m_reconOpen[decIdxLastPic] = true; 289 } 290 if ( bNewPicture && newSliceDiffPoc && 291 #else 181 292 m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode 182 293 recon_opened = true; 183 294 } 184 295 if ( bNewPicture && 296 #endif 185 297 ( nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL 186 298 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP … … 189 301 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) ) 190 302 { 303 #if H_MV 304 xFlushOutput( pcListPic, decIdxLastPic ); 305 #else 191 306 xFlushOutput( pcListPic ); 307 #endif 192 308 } 193 309 // write reconstruction to file 194 310 if(bNewPicture) 195 311 { 312 #if H_MV 313 xWriteOutput( pcListPic, decIdxLastPic, nalu.m_temporalId ); 314 } 315 } 316 } 317 318 for(UInt decIdx = 0; decIdx < m_numDecoders; decIdx++) 319 { 320 xFlushOutput( m_tDecTop[decIdx]->getListPic(), decIdx ); 321 } 322 #else 196 323 xWriteOutput( pcListPic, nalu.m_temporalId ); 197 324 } … … 202 329 // delete buffers 203 330 m_cTDecTop.deletePicBuffer(); 331 #endif 204 332 205 333 // destroy internal classes … … 213 341 Void TAppDecTop::xCreateDecLib() 214 342 { 343 #if H_MV 344 // initialize global variables 345 initROM(); 346 #else 215 347 // create decoder class 216 348 m_cTDecTop.create(); 349 #endif 217 350 } 218 351 219 352 Void TAppDecTop::xDestroyDecLib() 220 353 { 354 #if H_MV 355 // destroy ROM 356 destroyROM(); 357 358 for(Int decIdx = 0; decIdx < m_numDecoders ; decIdx++) 359 { 360 if( m_tVideoIOYuvReconFile[decIdx] ) 361 { 362 m_tVideoIOYuvReconFile[decIdx]->close(); 363 delete m_tVideoIOYuvReconFile[decIdx]; 364 m_tVideoIOYuvReconFile[decIdx] = NULL ; 365 } 366 367 if( m_tDecTop[decIdx] ) 368 { 369 m_tDecTop[decIdx]->deletePicBuffer(); 370 m_tDecTop[decIdx]->destroy() ; 371 } 372 delete m_tDecTop[decIdx] ; 373 m_tDecTop[decIdx] = NULL ; 374 } 375 #else 221 376 if ( m_pchReconFile ) 222 377 { … … 226 381 // destroy decoder class 227 382 m_cTDecTop.destroy(); 383 #endif 228 384 } 229 385 230 386 Void TAppDecTop::xInitDecLib() 231 387 { 388 #if !H_MV 232 389 // initialize decoder class 233 390 m_cTDecTop.init(); 234 391 m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); 392 #endif 235 393 } 236 394 … … 238 396 \todo DYN_REF_FREE should be revised 239 397 */ 398 #if H_MV 399 Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int decIdx, Int tId ) 400 #else 240 401 Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt tId ) 402 #endif 241 403 { 242 404 TComList<TComPic*>::iterator iterPic = pcListPic->begin(); … … 246 408 { 247 409 TComPic* pcPic = *(iterPic); 410 #if H_MV 411 if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx]) 412 #else 248 413 if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay) 414 #endif 249 415 { 250 416 not_displayed++; … … 258 424 TComPic* pcPic = *(iterPic); 259 425 426 #if H_MV 427 if ( pcPic->getOutputMark() && (not_displayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[decIdx])) 428 #else 260 429 if ( pcPic->getOutputMark() && (not_displayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay)) 430 #endif 261 431 { 262 432 // write to file 263 433 not_displayed--; 434 #if H_MV 435 if ( m_pchReconFiles[decIdx] ) 436 #else 264 437 if ( m_pchReconFile ) 438 #endif 265 439 { 266 440 const Window &conf = pcPic->getConformanceWindow(); 267 441 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 442 #if H_MV 443 m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(), 444 #else 268 445 m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), 446 #endif 269 447 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 270 448 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), … … 274 452 275 453 // update POC of display order 454 #if H_MV 455 m_pocLastDisplay[decIdx] = pcPic->getPOC(); 456 #else 276 457 m_iPOCLastDisplay = pcPic->getPOC(); 458 #endif 277 459 278 460 // erase non-referenced picture in the reference picture list after display … … 302 484 \todo DYN_REF_FREE should be revised 303 485 */ 486 #if H_MV 487 Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int decIdx ) 488 #else 304 489 Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic ) 490 #endif 305 491 { 306 492 if(!pcListPic) … … 319 505 { 320 506 // write to file 507 #if H_MV 508 if ( m_pchReconFiles[decIdx] ) 509 #else 321 510 if ( m_pchReconFile ) 511 #endif 322 512 { 323 513 const Window &conf = pcPic->getConformanceWindow(); 324 514 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 515 #if H_MV 516 m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(), 517 #else 325 518 m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), 519 #endif 326 520 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 327 521 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), … … 331 525 332 526 // update POC of display order 527 #if H_MV 528 m_pocLastDisplay[decIdx] = pcPic->getPOC(); 529 #else 333 530 m_iPOCLastDisplay = pcPic->getPOC(); 531 #endif 334 532 335 533 // erase non-referenced picture in the reference picture list after display … … 351 549 pcPic->setOutputMark(false); 352 550 } 551 #if !H_MV 353 552 #if !DYN_REF_FREE 354 553 if(pcPic) … … 359 558 } 360 559 #endif 560 #endif 361 561 iterPic++; 362 562 } 563 #if H_MV 564 m_pocLastDisplay[decIdx] = -MAX_INT; 565 #else 363 566 pcListPic->clear(); 364 567 m_iPOCLastDisplay = -MAX_INT; 568 #endif 365 569 } 366 570 … … 375 579 for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++) 376 580 { 581 #if H_MV 582 if ( nalu->m_layerId == (*it) ) 583 #else 377 584 if ( nalu->m_reservedZero6Bits == (*it) ) 585 #endif 378 586 { 379 587 return true; -
branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/TAppDecTop.h
r367 r368 61 61 private: 62 62 // class interface 63 #if H_MV 64 TDecTop* m_tDecTop [ MAX_NUM_LAYERS ]; ///< decoder classes 65 TVideoIOYuv* m_tVideoIOYuvReconFile[ MAX_NUM_LAYERS ]; ///< reconstruction YUV class 66 Int m_layerIdToDecIdx [ MAX_NUM_LAYER_IDS ]; ///< maping from layer id to decoder index 67 Int m_numDecoders; ///< number of decoder instances 68 TComPicLists m_ivPicLists; ///< picture buffers of decoder instances 69 #else 63 70 TDecTop m_cTDecTop; ///< decoder class 64 71 TVideoIOYuv m_cTVideoIOYuvReconFile; ///< reconstruction YUV class 72 #endif 65 73 66 74 // for output control 67 75 Bool m_abDecFlag[ MAX_GOP ]; ///< decoded flag in one GOP 76 #if H_MV 77 Int m_pocLastDisplay [ MAX_NUM_LAYERS ]; ///< last POC in display order 78 Bool m_reconOpen [ MAX_NUM_LAYERS ]; ///< reconstruction file opened 79 #else 68 80 Int m_iPOCLastDisplay; ///< last POC in display order 81 #endif 69 82 70 83 public: … … 81 94 Void xInitDecLib (); ///< initialize decoder class 82 95 96 #if H_MV 97 Void xWriteOutput ( TComList<TComPic*>* pcListPic, Int layerId, Int tId ); ///< write YUV to file 98 Void xFlushOutput ( TComList<TComPic*>* pcListPic, Int layerId ); ///< flush all remaining decoded pictures to file 99 Int xGetDecoderIdx ( Int layerId, Bool createFlag = false ) 100 { 101 Int decIdx = -1; 102 if ( m_layerIdToDecIdx[ layerId ] != -1 ) 103 { 104 decIdx = m_layerIdToDecIdx[ layerId ]; 105 } 106 else 107 { 108 assert ( createFlag ); 109 assert( m_numDecoders < MAX_NUM_LAYERS ); 110 111 decIdx = m_numDecoders; 112 113 // Init decoder 114 m_tDecTop[ decIdx ] = new TDecTop; 115 m_tDecTop[ decIdx ]->create(); 116 m_tDecTop[ decIdx ]->init( ); 117 m_tDecTop[ decIdx ]->setLayerId( layerId ); 118 m_tDecTop[ decIdx ]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); 119 m_tDecTop[ decIdx ]->setIvPicLists( &m_ivPicLists ); 120 121 // append pic list of new decoder to PicLists 122 assert( m_ivPicLists.size() == m_numDecoders ); 123 m_ivPicLists.push_back( m_tDecTop[ decIdx ]->getListPic() ); 124 125 // create recon file related stuff 126 Char* pchTempFilename = NULL; 127 if ( m_pchReconFile ) 128 { 129 Char buffer[4]; 130 sprintf(buffer,"_%i", layerId ); 131 assert ( m_pchReconFile ); 132 xAppendToFileNameEnd( m_pchReconFile , buffer, pchTempFilename ); 133 assert( m_pchReconFiles.size() == m_numDecoders ); 134 } 135 136 m_pchReconFiles.push_back( pchTempFilename ); 137 138 m_tVideoIOYuvReconFile[ decIdx ] = new TVideoIOYuv; 139 m_reconOpen [ decIdx ] = false; 140 141 // set others 142 m_pocLastDisplay [ decIdx ] = -MAX_INT; 143 m_layerIdToDecIdx [ layerId ] = decIdx; 144 145 m_numDecoders++; 146 }; 147 return decIdx; 148 } 149 #else 83 150 Void xWriteOutput ( TComList<TComPic*>* pcListPic , UInt tId); ///< write YUV to file 84 151 Void xFlushOutput ( TComList<TComPic*>* pcListPic ); ///< flush all remaining decoded pictures to file 152 #endif 85 153 Bool isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet 86 154 }; -
branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/decmain.cpp
r367 r368 56 56 // print information 57 57 fprintf( stdout, "\n" ); 58 #if H_MV 59 fprintf( stdout, "3D-HTM Software: Decoder Version [%s] based on HM Version [%s]", NV_VERSION, HM_VERSION ); 60 #else 58 61 fprintf( stdout, "HM software: Decoder Version [%s]", NV_VERSION ); 62 #endif 59 63 fprintf( stdout, NVM_ONOS ); 60 64 fprintf( stdout, NVM_COMPILEDBY );
Note: See TracChangeset for help on using the changeset viewer.