Changeset 367 in 3DVCSoftware for branches/HTM-DEV-0.1-dev/source/App/TAppDecoder
- Timestamp:
- 3 May 2013, 17:09:57 (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
r364 r367 42 42 #include "TAppCommon/program_options_lite.h" 43 43 44 #if H_MV45 #include <cassert>46 #endif47 44 #ifdef WIN32 48 45 #define strdup _strdup … … 78 75 ("OutputBitDepth,d", m_outputBitDepthY, 0, "bit depth of YUV output luma component (default: use 0 for native depth)") 79 76 ("OutputBitDepthC,d", m_outputBitDepthC, 0, "bit depth of YUV output chroma component (default: use 0 for native depth)") 80 #if H_MV81 ("MaxLayerId,-ls", m_maxLayerId, MAX_NUM_LAYER_IDS-1, "Maximum LayerId to be decoded.")82 #endif83 77 ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers") 84 78 ("SEIDecodedPictureHash", m_decodedPictureHashSEIEnabled, 1, "Control handling of decoded picture hash SEI messages\n" … … 157 151 } 158 152 } 159 #if H_MV160 else161 {162 for ( Int curLayerId = 0; curLayerId <= m_maxLayerId; curLayerId++ )163 {164 m_targetDecLayerIdSet.push_back( curLayerId );165 }166 }167 #endif168 153 169 154 return true; 170 155 } 171 156 172 #if H_MV173 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 #endif189 157 //! \} -
branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/TAppDecCfg.h
r365 r367 58 58 protected: 59 59 Char* m_pchBitstreamFile; ///< input bitstream file name 60 #if H_MV61 Int m_maxLayerId; ///< maximum nuh_layer_id decoded62 std::vector<Char*> m_pchReconFiles; ///< array of output reconstruction file name create from output reconstruction file name63 #endif64 60 Char* m_pchReconFile; ///< output reconstruction file name 65 61 Int m_iSkipFrame; ///< counter for frames prior to the random access point to skip … … 73 69 Int m_respectDefDispWindow; ///< Only output content inside the default display window 74 70 75 #if H_MV76 Void xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName); ///< create filenames77 #endif78 71 public: 79 72 TAppDecCfg() 80 73 : m_pchBitstreamFile(NULL) 81 #if H_MV82 , m_maxLayerId(0)83 , m_pchReconFiles(NULL)84 #endif85 74 , m_pchReconFile(NULL) 86 75 , m_iSkipFrame(0) -
branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/TAppDecTop.cpp
r366 r367 54 54 55 55 TAppDecTop::TAppDecTop() 56 #if !H_MV57 56 : m_iPOCLastDisplay(-MAX_INT) 58 #else59 : m_numDecoders( 0 )60 #endif61 57 { 62 58 ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag)); 63 #if H_MV64 for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) m_layerIdToDecIdx[i] = -1;65 #endif66 59 } 67 60 … … 77 70 m_pchBitstreamFile = NULL; 78 71 } 79 #if H_MV80 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 #endif89 72 if (m_pchReconFile) 90 73 { … … 109 92 { 110 93 Int poc; 111 #if H_MV112 poc = -1;113 #endif114 94 TComList<TComPic*>* pcListPic = NULL; 115 95 … … 126 106 xCreateDecLib(); 127 107 xInitDecLib (); 128 #if !H_MV129 108 m_iPOCLastDisplay += m_iSkipFrame; // set the last displayed POC correctly for skip forward. 130 109 131 110 // main decoder loop 132 111 Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen) 133 #else134 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 #endif145 112 146 113 while (!!bitstreamFile) … … 152 119 streampos location = bitstreamFile.tellg(); 153 120 AnnexBStats stats = AnnexBStats(); 154 #if !H_MV155 121 Bool bPreviousPictureDecoded = false; 156 #endif157 122 158 123 vector<uint8_t> nalUnit; … … 162 127 // call actual decoding function 163 128 Bool bNewPicture = false; 164 #if H_MV165 Bool newSliceDiffPoc = false;166 Bool newSliceDiffLayer = false;167 Bool allLayersDecoded = false;168 #endif169 129 if (nalUnit.empty()) 170 130 { … … 179 139 { 180 140 read(nalu, nalUnit); 181 #if H_MV182 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 else189 {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 true193 // - poc in particular layer changes194 // - nalu does not belong to first slice in layer195 // - nalu.isSlice() == true196 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 #else223 141 if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) ) 224 142 { … … 236 154 { 237 155 bNewPicture = m_cTDecTop.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay); 238 #endif239 156 if (bNewPicture) 240 157 { … … 247 164 bytestream.reset(); 248 165 } 249 #if !H_MV250 166 bPreviousPictureDecoded = true; 251 #endif252 167 } 253 168 } 254 169 if (bNewPicture || !bitstreamFile) 255 170 { 256 #if H_MV257 assert( decIdxLastPic != -1 );258 m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet );259 #else260 171 m_cTDecTop.executeLoopFilters(poc, pcListPic); 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 172 } 274 173 275 174 if( pcListPic ) 276 175 { 277 #if H_MV278 if ( m_pchReconFiles[decIdxLastPic] && !m_reconOpen[decIdxLastPic] )279 #else280 176 if ( m_pchReconFile && !recon_opened ) 281 #endif282 177 { 283 178 if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; } 284 179 if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; } 285 180 286 #if H_MV287 m_tVideoIOYuvReconFile[decIdxLastPic]->open( m_pchReconFiles[decIdxLastPic], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode288 m_reconOpen[decIdxLastPic] = true;289 }290 if ( bNewPicture && newSliceDiffPoc &&291 #else292 181 m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode 293 182 recon_opened = true; 294 183 } 295 184 if ( bNewPicture && 296 #endif297 185 ( nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL 298 186 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP … … 301 189 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) ) 302 190 { 303 #if H_MV304 xFlushOutput( pcListPic, decIdxLastPic );305 #else306 191 xFlushOutput( pcListPic ); 307 #endif308 192 } 309 193 // write reconstruction to file 310 194 if(bNewPicture) 311 195 { 312 #if H_MV313 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 #else323 196 xWriteOutput( pcListPic, nalu.m_temporalId ); 324 197 } … … 329 202 // delete buffers 330 203 m_cTDecTop.deletePicBuffer(); 331 #endif332 204 333 205 // destroy internal classes … … 341 213 Void TAppDecTop::xCreateDecLib() 342 214 { 343 #if H_MV344 // initialize global variables345 initROM();346 #else347 215 // create decoder class 348 216 m_cTDecTop.create(); 349 #endif350 217 } 351 218 352 219 Void TAppDecTop::xDestroyDecLib() 353 220 { 354 #if H_MV355 // destroy ROM356 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 #else376 221 if ( m_pchReconFile ) 377 222 { … … 381 226 // destroy decoder class 382 227 m_cTDecTop.destroy(); 383 #endif384 228 } 385 229 386 230 Void TAppDecTop::xInitDecLib() 387 231 { 388 #if !H_MV389 232 // initialize decoder class 390 233 m_cTDecTop.init(); 391 234 m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); 392 #endif393 235 } 394 236 … … 396 238 \todo DYN_REF_FREE should be revised 397 239 */ 398 #if H_MV399 Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int decIdx, Int tId )400 #else401 240 Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt tId ) 402 #endif403 241 { 404 242 TComList<TComPic*>::iterator iterPic = pcListPic->begin(); … … 408 246 { 409 247 TComPic* pcPic = *(iterPic); 410 #if H_MV411 if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx])412 #else413 248 if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay) 414 #endif415 249 { 416 250 not_displayed++; … … 424 258 TComPic* pcPic = *(iterPic); 425 259 426 #if H_MV427 if ( pcPic->getOutputMark() && (not_displayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[decIdx]))428 #else429 260 if ( pcPic->getOutputMark() && (not_displayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay)) 430 #endif431 261 { 432 262 // write to file 433 263 not_displayed--; 434 #if H_MV435 if ( m_pchReconFiles[decIdx] )436 #else437 264 if ( m_pchReconFile ) 438 #endif439 265 { 440 266 const Window &conf = pcPic->getConformanceWindow(); 441 267 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 442 #if H_MV443 m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),444 #else445 268 m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), 446 #endif447 269 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 448 270 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), … … 452 274 453 275 // update POC of display order 454 #if H_MV455 m_pocLastDisplay[decIdx] = pcPic->getPOC();456 #else457 276 m_iPOCLastDisplay = pcPic->getPOC(); 458 #endif459 277 460 278 // erase non-referenced picture in the reference picture list after display … … 484 302 \todo DYN_REF_FREE should be revised 485 303 */ 486 #if H_MV487 Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int decIdx )488 #else489 304 Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic ) 490 #endif491 305 { 492 306 if(!pcListPic) … … 505 319 { 506 320 // write to file 507 #if H_MV508 if ( m_pchReconFiles[decIdx] )509 #else510 321 if ( m_pchReconFile ) 511 #endif512 322 { 513 323 const Window &conf = pcPic->getConformanceWindow(); 514 324 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 515 #if H_MV516 m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),517 #else518 325 m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), 519 #endif520 326 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 521 327 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), … … 525 331 526 332 // update POC of display order 527 #if H_MV528 m_pocLastDisplay[decIdx] = pcPic->getPOC();529 #else530 333 m_iPOCLastDisplay = pcPic->getPOC(); 531 #endif532 334 533 335 // erase non-referenced picture in the reference picture list after display … … 549 351 pcPic->setOutputMark(false); 550 352 } 551 #if !H_MV552 353 #if !DYN_REF_FREE 553 354 if(pcPic) … … 558 359 } 559 360 #endif 560 #endif561 361 iterPic++; 562 362 } 563 #if H_MV564 m_pocLastDisplay[decIdx] = -MAX_INT;565 #else566 363 pcListPic->clear(); 567 364 m_iPOCLastDisplay = -MAX_INT; 568 #endif569 365 } 570 366 … … 579 375 for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++) 580 376 { 581 #if H_MV582 if ( nalu->m_layerId == (*it) )583 #else584 377 if ( nalu->m_reservedZero6Bits == (*it) ) 585 #endif586 378 { 587 379 return true; -
branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/TAppDecTop.h
r365 r367 61 61 private: 62 62 // class interface 63 #if H_MV64 TDecTop* m_tDecTop [ MAX_NUM_LAYERS ]; ///< decoder classes65 TVideoIOYuv* m_tVideoIOYuvReconFile[ MAX_NUM_LAYERS ]; ///< reconstruction YUV class66 Int m_layerIdToDecIdx [ MAX_NUM_LAYER_IDS ]; ///< maping from layer id to decoder index67 Int m_numDecoders; ///< number of decoder instances68 TComPicLists m_ivPicLists; ///< picture buffers of decoder instances69 #else70 63 TDecTop m_cTDecTop; ///< decoder class 71 64 TVideoIOYuv m_cTVideoIOYuvReconFile; ///< reconstruction YUV class 72 #endif73 65 74 66 // for output control 75 67 Bool m_abDecFlag[ MAX_GOP ]; ///< decoded flag in one GOP 76 #if H_MV77 Int m_pocLastDisplay [ MAX_NUM_LAYERS ]; ///< last POC in display order78 Bool m_reconOpen [ MAX_NUM_LAYERS ]; ///< reconstruction file opened79 #else80 68 Int m_iPOCLastDisplay; ///< last POC in display order 81 #endif82 69 83 70 public: … … 94 81 Void xInitDecLib (); ///< initialize decoder class 95 82 96 #if H_MV97 Void xWriteOutput ( TComList<TComPic*>* pcListPic, Int layerId, Int tId ); ///< write YUV to file98 Void xFlushOutput ( TComList<TComPic*>* pcListPic, Int layerId ); ///< flush all remaining decoded pictures to file99 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 else107 {108 assert ( createFlag );109 assert( m_numDecoders < MAX_NUM_LAYERS );110 111 decIdx = m_numDecoders;112 113 // Init decoder114 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 PicLists122 assert( m_ivPicLists.size() == m_numDecoders );123 m_ivPicLists.push_back( m_tDecTop[ decIdx ]->getListPic() );124 125 // create recon file related stuff126 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 others142 m_pocLastDisplay [ decIdx ] = -MAX_INT;143 m_layerIdToDecIdx [ layerId ] = decIdx;144 145 m_numDecoders++;146 };147 return decIdx;148 }149 #else150 83 Void xWriteOutput ( TComList<TComPic*>* pcListPic , UInt tId); ///< write YUV to file 151 84 Void xFlushOutput ( TComList<TComPic*>* pcListPic ); ///< flush all remaining decoded pictures to file 152 #endif153 85 Bool isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet 154 86 }; -
branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/decmain.cpp
r324 r367 56 56 // print information 57 57 fprintf( stdout, "\n" ); 58 #if H_MV59 fprintf( stdout, "3D-HTM Software: Decoder Version [%s] based on HM Version [%s]", NV_VERSION, HM_VERSION );60 #else61 58 fprintf( stdout, "HM software: Decoder Version [%s]", NV_VERSION ); 62 #endif63 59 fprintf( stdout, NVM_ONOS ); 64 60 fprintf( stdout, NVM_COMPILEDBY );
Note: See TracChangeset for help on using the changeset viewer.