Changeset 924 in SHVCSoftware for branches


Ignore:
Timestamp:
17 Nov 2014, 17:09:25 (10 years ago)
Author:
seregin
Message:

in order to generate the metadata related to conformance bitstreams, patch was provided by Ramasubramonian, Adarsh Krishnan <aramasub@…>

Location:
branches/SHM-dev/source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp

    r856 r924  
    7272  Int olsIdx;
    7373#endif
     74#if CONFORMANCE_BITSTREAM_MODE
     75  string cfg_confPrefix;
     76#endif
    7477#if AVC_BASE
    7578  string cfg_BLReconFile;
     
    106109#if OUTPUT_LAYER_SET_INDEX
    107110  ("OutpuLayerSetIdx,-olsidx", olsIdx, -1, "Index of output layer set to be decoded.")
     111#endif
     112#if CONFORMANCE_BITSTREAM_MODE
     113  ("ConformanceBitstremMode,-confMode", m_confModeFlag, false, "Enable generation of conformance bitstream metadata; True: Generate metadata, False: No metadata generated")
     114  ("ConformanceMetadataPrefix,-confPrefix", cfg_confPrefix, string(""), "Prefix for the file name of the conformance data. Default name - 'decodedBitstream'")
    108115#endif
    109116#endif
     
    145152#endif
    146153#if OUTPUT_LAYER_SET_INDEX 
     154#if CONFORMANCE_BITSTREAM_MODE
     155  if( m_confModeFlag )
     156  {
     157    assert( olsIdx != -1 ); // In the conformance mode, target output layer set index is to be explicitly specified.
     158
     159    if( cfg_confPrefix.empty() )
     160    {
     161      m_confPrefix = string("decodedBitstream");
     162    }
     163    else
     164    {
     165      m_confPrefix = cfg_confPrefix;
     166    }
     167      // Open metadata file and write
     168    char fileNameSuffix[255];
     169    sprintf(fileNameSuffix, "%s-OLS%d.opl", m_confPrefix.c_str(), olsIdx);  // olsIdx is the target output layer set index.
     170    m_metadataFileName = string(fileNameSuffix);
     171    m_metadataFileRefresh = true;
     172
     173    // Decoded layer YUV files
     174    for(UInt layer=0; layer<= m_tgtLayerId; layer++)
     175    {
     176      sprintf(fileNameSuffix, "%s-L%d.yuv", m_confPrefix.c_str(), layer);  // olsIdx is the target output layer set index.
     177      m_decodedYuvLayerFileName[layer] = std::string( fileNameSuffix );
     178      m_decodedYuvLayerRefresh[layer] = true;
     179    }
     180  }
     181#endif
    147182  this->getCommonDecoderParams()->setTargetOutputLayerSetIdx( olsIdx       );
    148183  this->getCommonDecoderParams()->setTargetLayerId    ( m_tgtLayerId );
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h

    r856 r924  
    8989  CommonDecoderParams             m_commonDecoderParams;
    9090#endif
     91#if CONFORMANCE_BITSTREAM_MODE
     92  Bool          m_confModeFlag;
     93  std::string m_confPrefix;
     94  std::string m_metadataFileName;
     95  Bool m_metadataFileRefresh;
     96  std::string   m_decodedYuvLayerFileName[63];
     97  Bool          m_decodedYuvLayerRefresh[63];
     98#endif
    9199
    92100public:
     
    119127  CommonDecoderParams* getCommonDecoderParams() {return &m_commonDecoderParams;}
    120128#endif
     129#if CONFORMANCE_BITSTREAM_MODE
     130  Bool const getConfModeFlag() { return m_confModeFlag;  }
     131  std::string const getConfPrefix() { return m_confPrefix;}
     132  std::string const getMetadataFileName() { return m_metadataFileName; }
     133  Bool const getMetadataFileRefresh() {return m_metadataFileRefresh; }
     134  Void setMetadataFileRefresh(Bool const x) {m_metadataFileRefresh = x; }
     135  Void setDecodedYuvLayerFileName(Int layerId, std::string x) {  m_decodedYuvLayerFileName[layerId] = x; }
     136  std::string const getDecodedYuvLayerFileName(Int layerId) {  return m_decodedYuvLayerFileName[layerId]; }
     137  Bool const getDecodedYuvLayerRefresh(Int const layerId) {return m_decodedYuvLayerRefresh[layerId]; }
     138  Void setDecodedYuvLayerRefresh(Int const layerId, Bool const x) {m_decodedYuvLayerRefresh[layerId] = x; }
     139#endif
    121140};
    122141
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp

    r874 r924  
    4545#include "TLibDecoder/AnnexBread.h"
    4646#include "TLibDecoder/NALread.h"
     47#include "TLibCommon/TComPicYuv.h"
     48#include "libmd5/MD5.h"
    4749//! \ingroup TAppDecoder
    4850//! \{
     
    576578#endif
    577579  }
     580#if CONFORMANCE_BITSTREAM_MODE
     581  for(UInt layer = 0; layer <= MAX_LAYERS; layer++)
     582  {
     583    m_acTDecTop[layer].setConfModeFlag ( this->getConfModeFlag() );
     584  }
     585#endif
    578586#else
    579587  m_cTDecTop.init();
     
    11011109      conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
    11021110  }
     1111
    11031112  // update POC of display order
    11041113  pocLastDisplay = pic->getPOC();
     
    13131322
    13141323      xOutputAndMarkPic( pic, m_pchReconFile[layerIdx], layerIdx, m_aiPOCLastDisplay[layerIdx], dpbStatus );
     1324
     1325#if CONFORMANCE_BITSTREAM_MODE
     1326  FILE *fptr;
     1327  if( this->getConfModeFlag() )
     1328  {
     1329    if( this->getMetadataFileRefresh() )
     1330    {
     1331      fptr = fopen( this->getMetadataFileName().c_str(), "w" );
     1332      fprintf(fptr, " LayerId      POC    MD5\n");
     1333      fprintf(fptr, "------------------------\n");
     1334    }
     1335    else
     1336    {
     1337      fptr = fopen( this->getMetadataFileName().c_str(), "a+" );
     1338    }
     1339    this->setMetadataFileRefresh(false);
     1340    UChar recon_digest[3][16];
     1341    calcMD5(*pic->getPicYuvRec(), recon_digest);
     1342    fprintf(fptr, "%8d%9d    MD5:%s\n", pic->getLayerId(), pic->getSlice(0)->getPOC(), digestToString(recon_digest, 16));
     1343    fclose(fptr);
     1344
     1345    // Output all picutres "decoded" in that layer that have POC less than the current picture
     1346    std::vector<TComPic> *layerBuffer = (m_acTDecTop->getLayerDec(pic->getLayerId()))->getConfListPic();
     1347    // Write all pictures to the file.
     1348    if( this->getDecodedYuvLayerRefresh(layerIdx) )
     1349    {
     1350      if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
     1351      if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
     1352
     1353      char tempFileName[256];
     1354      strcpy(tempFileName, this->getDecodedYuvLayerFileName( layerIdx ).c_str());
     1355      m_confReconFile[layerIdx].open(tempFileName, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
     1356      this->setDecodedYuvLayerRefresh( layerIdx, false );
     1357    }
     1358    const Window &conf = pic->getConformanceWindow();
     1359    const Window &defDisp = m_respectDefDispWindow ? pic->getDefDisplayWindow() : Window();
     1360    Int xScal =  1, yScal = 1;
     1361  #if REPN_FORMAT_IN_VPS
     1362    UInt chromaFormatIdc = pic->getSlice(0)->getChromaFormatIdc();
     1363    xScal = TComSPS::getWinUnitX( chromaFormatIdc );
     1364    yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     1365  #endif
     1366    std::vector<TComPic>::iterator iterPic;
     1367    for(iterPic = layerBuffer->begin(); iterPic != layerBuffer->end(); iterPic++)
     1368    {
     1369       TComPic checkPic = *iterPic;
     1370       if( checkPic.getPOC() <= pic->getPOC() )
     1371       {
     1372         TComPicYuv* pPicCYuvRec = checkPic.getPicYuvRec();
     1373         m_confReconFile[layerIdx].write( pPicCYuvRec,
     1374                                  conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
     1375                                  conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
     1376                                  conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
     1377                                  conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
     1378         layerBuffer->erase(iterPic);
     1379         iterPic = layerBuffer->begin();  // Ensure doesn't go to infinite loop
     1380         if(layerBuffer->size() == 0)
     1381         {
     1382           break;
     1383         }
     1384       }
     1385    }
     1386  }
     1387  // Now to remove the pictures that have been output
     1388#endif
    13151389
    13161390      listOfPocsInEachLayer[layerIdx].erase( it );
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h

    r845 r924  
    7171  TVideoIOYuv                     m_cTVideoIOYuvReconFile;        ///< reconstruction YUV class
    7272#endif
    73  
     73#if CONFORMANCE_BITSTREAM_MODE
     74  TVideoIOYuv   m_confReconFile[63];        ///< decode YUV files
     75#endif 
    7476  // for output control 
    7577#if SVC_EXTENSION
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r912 r924  
    15631563  vps->deriveNumberOfSubDpbs();
    15641564#endif
    1565 
     1565  vps->setOutputLayerFlag( 0, 0, 1 );
    15661566  // derive OutputLayerFlag[i][j]
    15671567#if !OUTPUT_LAYER_SETS_CONFIG
  • branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h

    r914 r924  
    4444#define MAX_LAYERS                       8      ///< max number of layers the codec is supposed to handle
    4545
     46#define CONFORMANCE_BITSTREAM_MODE       1      ///< In order to generate the metadata related to conformance bitstreams
    4647#define SIGNALLING_BITRATE_PICRATE_FIX   1      ///< Fix for signalling of bitrate and picture rate info in VPS VUI to be more aligned to JCTVC-R1008
    4748#define INFERENCE_POC_MSB_VAL_PRESENT    1      ///< JCTVC-Q0146 -- poc_msb_val_present_flag shall be equal to 0 when slice_header_extension_length is (inferred to be ) equal to 0
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp

    r890 r924  
    4646#include "TDecTop.h"
    4747#endif
    48 
     48#include <algorithm>
    4949#include <time.h>
    5050
    5151extern Bool g_md5_mismatch; ///< top level flag to signal when there is a decode problem
    5252
     53#if CONFORMANCE_BITSTREAM_MODE
     54Bool pocCompareFunction( TComPic &pic1, TComPic &pic2 )
     55{
     56  return (pic1.getPOC() < pic2.getPOC());
     57}
     58#endif
    5359//! \ingroup TLibDecoder
    5460//! \{
     
    256262    calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), hash);
    257263  }
     264#if CONFORMANCE_BITSTREAM_MODE
     265  if( this->getLayerDec(rpcPic->getLayerId())->getConfModeFlag() )
     266  {
     267    // Add this reconstructed picture to the parallel buffer.
     268    std::vector<TComPic> *thisLayerBuffer = (this->getLayerDec(rpcPic->getLayerId()))->getConfListPic();
     269    thisLayerBuffer->push_back(*rpcPic);
     270    std::sort( thisLayerBuffer->begin(), thisLayerBuffer->end(), pocCompareFunction );
     271  }
     272#endif
    258273#if Q0074_COLOUR_REMAPPING_SEI
    259274  if (m_colourRemapSEIEnabled)
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r903 r924  
    123123  m_pocResettingFlag        = false;
    124124  m_pocDecrementedInDPBFlag = false;
     125#endif
     126#if CONFORMANCE_BITSTREAM_MODE
     127  m_confModeFlag = false;
    125128#endif
    126129}
     
    29742977  {
    29752978    // Check if the target decoded layer is the highest layer in the list
     2979#if 0
    29762980    assert( params->getTargetOutputLayerSetIdx() < vps->getNumLayerSets() );
     2981#endif
    29772982    Int layerSetIdx = vps->getOutputLayerSetIdx( params->getTargetOutputLayerSetIdx() );  // Index to the layer set
     2983#if 0
    29782984    assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1);
     2985#endif
    29792986
    29802987    Bool layerSetMatchFlag = true;
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h

    r903 r924  
    167167                                           // When new VPS is activated, this should be re-initialized to -1
    168168#endif
     169#if CONFORMANCE_BITSTREAM_MODE
     170  Bool m_confModeFlag;
     171  std::vector<TComPic>   m_confListPic;         //  Dynamic buffer for storing pictures for conformance purposes
     172#endif
    169173public:
    170174#if POC_RESET_RESTRICTIONS
     
    295299  Void assignSubDpbs(TComVPS *vps);
    296300#endif
     301#if CONFORMANCE_BITSTREAM_MODE
     302  std::vector<TComPic>* getConfListPic() {return &m_confListPic; }
     303  // std::string const getDecodedYuvLayerFileName(Int layerId) { return m_decodedYuvLayerFileName[layerId]; }
     304#endif
    297305#endif //SVC_EXTENSION
    298306
     
    334342  Void resetPocRestrictionCheckParameters();
    335343#endif
     344  public:
     345#if CONFORMANCE_BITSTREAM_MODE
     346  Bool const getConfModeFlag() { return m_confModeFlag; }
     347  Void setConfModeFlag(Bool x) { m_confModeFlag = x; }
     348#endif
    336349};// END CLASS DEFINITION TDecTop
    337350
Note: See TracChangeset for help on using the changeset viewer.