Changeset 928 in SHVCSoftware


Ignore:
Timestamp:
16 Dec 2014, 19:17:49 (10 years ago)
Author:
seregin
Message:

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

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

Legend:

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

    r916 r928  
    7373  Int olsIdx;
    7474#endif
     75#if CONFORMANCE_BITSTREAM_MODE
     76  string cfg_confPrefix;
     77#endif
    7578#if AVC_BASE
    7679  string cfg_BLReconFile;
     
    102105#if OUTPUT_LAYER_SET_INDEX
    103106  ("OutpuLayerSetIdx,-olsidx", olsIdx, -1, "Index of output layer set to be decoded.")
     107#endif
     108#if CONFORMANCE_BITSTREAM_MODE
     109  ("ConformanceBitstremMode,-confMode", m_confModeFlag, false, "Enable generation of conformance bitstream metadata; True: Generate metadata, False: No metadata generated")
     110  ("ConformanceMetadataPrefix,-confPrefix", cfg_confPrefix, string(""), "Prefix for the file name of the conformance data. Default name - 'decodedBitstream'")
    104111#endif
    105112#else
     
    160167  assert( m_tgtLayerId < MAX_NUM_LAYER_IDS );
    161168#endif
    162 #if OUTPUT_LAYER_SET_INDEX 
     169#if OUTPUT_LAYER_SET_INDEX
     170#if CONFORMANCE_BITSTREAM_MODE
     171  if( m_confModeFlag )
     172  {
     173    assert( olsIdx != -1 ); // In the conformance mode, target output layer set index is to be explicitly specified.
     174
     175    if( cfg_confPrefix.empty() )
     176    {
     177      m_confPrefix = string("decodedBitstream");
     178    }
     179    else
     180    {
     181      m_confPrefix = cfg_confPrefix;
     182    }
     183      // Open metadata file and write
     184    char fileNameSuffix[255];
     185    sprintf(fileNameSuffix, "%s-OLS%d.opl", m_confPrefix.c_str(), olsIdx);  // olsIdx is the target output layer set index.
     186    m_metadataFileName = string(fileNameSuffix);
     187    m_metadataFileRefresh = true;
     188
     189    // Decoded layer YUV files
     190    for(UInt layer=0; layer<= m_tgtLayerId; layer++)
     191    {
     192      sprintf(fileNameSuffix, "%s-L%d.yuv", m_confPrefix.c_str(), layer);  // olsIdx is the target output layer set index.
     193      m_decodedYuvLayerFileName[layer] = std::string( fileNameSuffix );
     194      m_decodedYuvLayerRefresh[layer] = true;
     195    }
     196  }
     197#endif
    163198  this->getCommonDecoderParams()->setTargetOutputLayerSetIdx( olsIdx       );
    164199  this->getCommonDecoderParams()->setTargetLayerId    ( m_tgtLayerId );
  • branches/SHM-upgrade/source/App/TAppDecoder/TAppDecCfg.h

    r916 r928  
    9494  CommonDecoderParams             m_commonDecoderParams;
    9595#endif
     96#if CONFORMANCE_BITSTREAM_MODE
     97  Bool          m_confModeFlag;
     98  std::string   m_confPrefix;
     99  std::string   m_metadataFileName;
     100  Bool          m_metadataFileRefresh;
     101  std::string   m_decodedYuvLayerFileName[63];
     102  Bool          m_decodedYuvLayerRefresh[63];
     103#endif
    96104
    97105public:
     
    131139  CommonDecoderParams* getCommonDecoderParams() {return &m_commonDecoderParams;}
    132140#endif
     141#if CONFORMANCE_BITSTREAM_MODE
     142  Bool const getConfModeFlag() { return m_confModeFlag;  }
     143  std::string const getConfPrefix() { return m_confPrefix;}
     144  std::string const getMetadataFileName() { return m_metadataFileName; }
     145  Bool const getMetadataFileRefresh() {return m_metadataFileRefresh; }
     146  Void setMetadataFileRefresh(Bool const x) {m_metadataFileRefresh = x; }
     147  Void setDecodedYuvLayerFileName(Int layerId, std::string x) {  m_decodedYuvLayerFileName[layerId] = x; }
     148  std::string const getDecodedYuvLayerFileName(Int layerId) {  return m_decodedYuvLayerFileName[layerId]; }
     149  Bool const getDecodedYuvLayerRefresh(Int const layerId) {return m_decodedYuvLayerRefresh[layerId]; }
     150  Void setDecodedYuvLayerRefresh(Int const layerId, Bool const x) {m_decodedYuvLayerRefresh[layerId] = x; }
     151#endif
    133152};
    134153
  • branches/SHM-upgrade/source/App/TAppDecoder/TAppDecTop.cpp

    r918 r928  
    4848#include "TLibCommon/TComCodingStatistics.h"
    4949#endif
     50#if CONFORMANCE_BITSTREAM_MODE
     51#include "TLibCommon/TComPicYuv.h"
     52#include "libmd5/MD5.h"
     53#endif
    5054
    5155//! \ingroup TAppDecoder
     
    630634    m_acTDecTop[layer].setNumLayer( m_tgtLayerId + 1 );
    631635#if OUTPUT_LAYER_SET_INDEX
    632     m_acTDecTop[layer].setCommonDecoderParams( this->getCommonDecoderParams() );
    633 #endif
    634   }
     636    m_acTDecTop[layer].setCommonDecoderParams( &m_commonDecoderParams );
     637#endif
     638  }
     639#if CONFORMANCE_BITSTREAM_MODE
     640  for(UInt layer = 0; layer <= MAX_LAYERS; layer++)
     641  {
     642    m_acTDecTop[layer].setConfModeFlag ( m_confModeFlag );
     643  }
     644#endif
    635645#else
    636646  m_cTDecTop.init();
     
    14081418
    14091419      xOutputAndMarkPic( pic, m_pchReconFile[layerIdx], layerIdx, m_aiPOCLastDisplay[layerIdx], dpbStatus );
     1420
     1421#if CONFORMANCE_BITSTREAM_MODE
     1422      FILE *fptr;
     1423      if( m_confModeFlag )
     1424      {
     1425        if( m_metadataFileRefresh )
     1426        {
     1427          fptr = fopen( this->getMetadataFileName().c_str(), "w" );
     1428          fprintf(fptr, " LayerId      POC    MD5\n");
     1429          fprintf(fptr, "------------------------\n");
     1430        }
     1431        else
     1432        {
     1433          fptr = fopen( this->getMetadataFileName().c_str(), "a+" );
     1434        }
     1435        this->setMetadataFileRefresh(false);
     1436
     1437        TComDigest recon_digest;
     1438        calcMD5(*pic->getPicYuvRec(), recon_digest);
     1439        fprintf(fptr, "%8d%9d    MD5:%s\n", pic->getLayerId(), pic->getSlice(0)->getPOC(), digestToString(recon_digest, 16));
     1440        fclose(fptr);
     1441
     1442        // Output all picutres "decoded" in that layer that have POC less than the current picture
     1443        std::vector<TComPic> *layerBuffer = (m_acTDecTop->getLayerDec(pic->getLayerId()))->getConfListPic();
     1444        // Write all pictures to the file.
     1445        if( this->getDecodedYuvLayerRefresh(layerIdx) )
     1446        {
     1447          if (!m_outputBitDepth[CHANNEL_TYPE_LUMA]) { m_outputBitDepth[CHANNEL_TYPE_LUMA] = g_bitDepth[CHANNEL_TYPE_LUMA]; }
     1448          if (!m_outputBitDepth[CHANNEL_TYPE_CHROMA]) { m_outputBitDepth[CHANNEL_TYPE_CHROMA] = g_bitDepth[CHANNEL_TYPE_CHROMA]; }
     1449
     1450          char tempFileName[256];
     1451          strcpy(tempFileName, this->getDecodedYuvLayerFileName( layerIdx ).c_str());
     1452          m_confReconFile[layerIdx].open(tempFileName, true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
     1453          this->setDecodedYuvLayerRefresh( layerIdx, false );
     1454        }
     1455        const Window &conf = pic->getConformanceWindow();
     1456        const Window &defDisp = m_respectDefDispWindow ? pic->getDefDisplayWindow() : Window();
     1457        Int xScal =  1, yScal = 1;
     1458#if REPN_FORMAT_IN_VPS
     1459        UInt chromaFormatIdc = pic->getSlice(0)->getChromaFormatIdc();
     1460        xScal = TComSPS::getWinUnitX( chromaFormatIdc );
     1461        yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     1462#endif
     1463        std::vector<TComPic>::iterator iterPic;
     1464        for(iterPic = layerBuffer->begin(); iterPic != layerBuffer->end(); iterPic++)
     1465        {
     1466          TComPic checkPic = *iterPic;
     1467          if( checkPic.getPOC() <= pic->getPOC() )
     1468          {
     1469            TComPicYuv* pPicCYuvRec = checkPic.getPicYuvRec();
     1470            m_confReconFile[layerIdx].write( pPicCYuvRec, m_outputColourSpaceConvert,
     1471              conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
     1472              conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
     1473              conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
     1474              conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
     1475            layerBuffer->erase(iterPic);
     1476            iterPic = layerBuffer->begin();  // Ensure doesn't go to infinite loop
     1477            if(layerBuffer->size() == 0)
     1478            {
     1479              break;
     1480            }
     1481          }
     1482        }
     1483      }
     1484      // Now to remove the pictures that have been output
     1485#endif
    14101486
    14111487      listOfPocsInEachLayer[layerIdx].erase( it );
  • branches/SHM-upgrade/source/App/TAppDecoder/TAppDecTop.h

    r916 r928  
    7474  // for output control 
    7575#if SVC_EXTENSION
     76#if CONFORMANCE_BITSTREAM_MODE
     77  TVideoIOYuv                      m_confReconFile[63];        ///< decode YUV files
     78#endif
    7679  Int                             m_aiPOCLastDisplay [MAX_LAYERS]; ///< last POC in display order
    7780#else
  • branches/SHM-upgrade/source/App/TAppEncoder/TAppEncTop.cpp

    r918 r928  
    16161616  vps->deriveNumberOfSubDpbs();
    16171617#endif
     1618  vps->setOutputLayerFlag( 0, 0, 1 );
    16181619
    16191620  // derive OutputLayerFlag[i][j]
  • branches/SHM-upgrade/source/Lib/TLibCommon/TypeDef.h

    r917 r928  
    4646#define MAX_LAYERS                       8      ///< max number of layers the codec is supposed to handle
    4747
     48#define CONFORMANCE_BITSTREAM_MODE       1      ///< In order to generate the metadata related to conformance bitstreams
    4849#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
    4950#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-upgrade/source/Lib/TLibDecoder/TDecGop.cpp

    r921 r928  
    4545#if SVC_EXTENSION
    4646#include "TDecTop.h"
     47#if CONFORMANCE_BITSTREAM_MODE
     48#include <algorithm>
     49#endif
    4750#endif
    4851
     
    5053
    5154extern Bool g_md5_mismatch; ///< top level flag to signal when there is a decode problem
     55
     56#if CONFORMANCE_BITSTREAM_MODE
     57Bool pocCompareFunction( TComPic &pic1, TComPic &pic2 )
     58{
     59  return (pic1.getPOC() < pic2.getPOC());
     60}
     61#endif
    5262
    5363//! \ingroup TLibDecoder
     
    241251    calcAndPrintHashStatus(*(pcPic->getPicYuvRec()), hash);
    242252  }
     253#if CONFORMANCE_BITSTREAM_MODE
     254  if( this->getLayerDec(pcPic->getLayerId())->getConfModeFlag() )
     255  {
     256    // Add this reconstructed picture to the parallel buffer.
     257    std::vector<TComPic> *thisLayerBuffer = (this->getLayerDec(pcPic->getLayerId()))->getConfListPic();
     258    thisLayerBuffer->push_back(*pcPic);
     259    std::sort( thisLayerBuffer->begin(), thisLayerBuffer->end(), pocCompareFunction );
     260  }
     261#endif
    243262#if Q0074_COLOUR_REMAPPING_SEI
    244263  if (m_colourRemapSEIEnabled)
  • branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.cpp

    r916 r928  
    129129  m_pocDecrementedInDPBFlag = false;
    130130#endif
     131#if CONFORMANCE_BITSTREAM_MODE
     132  m_confModeFlag = false;
     133#endif
    131134}
    132135
     
    29602963  {
    29612964    // Check if the target decoded layer is the highest layer in the list
     2965#if !CONFORMANCE_BITSTREAM_MODE
    29622966    assert( params->getTargetOutputLayerSetIdx() < vps->getNumLayerSets() );
     2967#endif
    29632968    Int layerSetIdx = vps->getOutputLayerSetIdx( params->getTargetOutputLayerSetIdx() );  // Index to the layer set
     2969#if !CONFORMANCE_BITSTREAM_MODE
    29642970    assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1);
     2971#endif
    29652972
    29662973    Bool layerSetMatchFlag = true;
  • branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.h

    r916 r928  
    170170                                           // When new VPS is activated, this should be re-initialized to -1
    171171#endif
     172#if CONFORMANCE_BITSTREAM_MODE
     173  Bool m_confModeFlag;
     174  std::vector<TComPic>   m_confListPic;         //  Dynamic buffer for storing pictures for conformance purposes
     175#endif
    172176public:
    173177#if POC_RESET_RESTRICTIONS
     
    304308  Void assignSubDpbs(TComVPS *vps);
    305309#endif
     310#if CONFORMANCE_BITSTREAM_MODE
     311  std::vector<TComPic>* getConfListPic() {return &m_confListPic; }
     312  // std::string const getDecodedYuvLayerFileName(Int layerId) { return m_decodedYuvLayerFileName[layerId]; }
     313  Bool const getConfModeFlag() { return m_confModeFlag; }
     314  Void setConfModeFlag(Bool x) { m_confModeFlag = x; }
     315#endif
    306316#endif //SVC_EXTENSION
    307317
Note: See TracChangeset for help on using the changeset viewer.