Changeset 125 in SHVCSoftware for trunk/source/App/TAppDecoder


Ignore:
Timestamp:
16 Apr 2013, 06:39:31 (12 years ago)
Author:
seregin
Message:

copy from HM-10.0-dev-SHM

Location:
trunk/source/App/TAppDecoder
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/App/TAppDecoder/TAppDecCfg.cpp

    r55 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    6464Bool TAppDecCfg::parseCfg( Int argc, Char* argv[] )
    6565{
    66   bool do_help = false;
     66  Bool do_help = false;
    6767  string cfg_BitstreamFile;
    6868#if SVC_EXTENSION
     
    7878  string cfg_BLSyntaxFile;
    7979#endif
    80 #if TARGET_DECLAYERID_SET
    8180  string cfg_TargetDecLayerIdSetFile;
    82 #endif
    8381
    8482  po::Options opts;
     
    108106#endif
    109107  ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
    110   ("OutputBitDepth,d", m_outputBitDepth, 0u, "bit depth of YUV output file (use 0 for native depth)")
     108  ("OutputBitDepth,d", m_outputBitDepthY, 0, "bit depth of YUV output luma component (default: use 0 for native depth)")
     109  ("OutputBitDepthC,d", m_outputBitDepthC, 0, "bit depth of YUV output chroma component (default: use 0 for native depth)")
    111110#if SVC_EXTENSION
    112111  ("LayerNum,-ls", nLayerNum, 1, "Number of layers to be decoded.")
    113112#endif
    114113  ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers")
    115   ("SEIpictureDigest", m_decodedPictureHashSEIEnabled, 1, "Control handling of decoded picture hash SEI messages\n"
    116                                               "\t3: checksum\n"
    117                                               "\t2: CRC\n"
    118                                               "\t1: MD5\n"
    119                                               "\t0: ignore")
    120 #if TARGET_DECLAYERID_SET
     114  ("SEIDecodedPictureHash", m_decodedPictureHashSEIEnabled, 1, "Control handling of decoded picture hash SEI messages\n"
     115                                              "\t1: check hash in SEI messages if available in the bitstream\n"
     116                                              "\t0: ignore SEI message")
     117  ("SEIpictureDigest", m_decodedPictureHashSEIEnabled, 1, "deprecated alias for SEIDecodedPictureHash")
    121118  ("TarDecLayerIdSetFile,l", cfg_TargetDecLayerIdSetFile, string(""), "targetDecLayerIdSet file name. The file should include white space separated LayerId values to be decoded. Omitting the option or a value of -1 in the file decodes all layers.")
    122 #endif
     119  ("RespectDefDispWindow,w", m_respectDefDispWindow, 0, "Only output content inside the default display window\n")
    123120  ;
    124121  po::setDefaults(opts);
    125   const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv);
    126 
    127   for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
     122  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
     123
     124  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
    128125  {
    129126    fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
     
    161158  }
    162159
    163 #if TARGET_DECLAYERID_SET
    164160  if ( !cfg_TargetDecLayerIdSetFile.empty() )
    165161  {
     
    206202    }
    207203  }
    208 #endif
    209204
    210205  return true;
  • trunk/source/App/TAppDecoder/TAppDecCfg.h

    r55 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4444
    4545#include "TLibCommon/CommonDef.h"
    46 #if TARGET_DECLAYERID_SET
    4746#include <vector>
    48 #endif
    4947
    5048//! \ingroup TAppDecoder
     
    5957{
    6058protected:
    61   char*         m_pchBitstreamFile;                   ///< input bitstream file name
     59  Char*         m_pchBitstreamFile;                   ///< input bitstream file name
    6260#if SVC_EXTENSION
    63   char*         m_pchReconFile [MAX_LAYERS];          ///< output reconstruction file name
     61  Char*         m_pchReconFile [MAX_LAYERS];          ///< output reconstruction file name
    6462#if AVC_BASE
    65   char*         m_pchBLReconFile;                     ///< input BL reconstruction file name
     63  Char*         m_pchBLReconFile;                     ///< input BL reconstruction file name
    6664  Int           m_iBLSourceWidth;
    6765  Int           m_iBLSourceHeight;
    6866#if AVC_SYNTAX
    69   char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name 
     67  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name 
    7068#endif
    7169#endif
    7270#else
    73   char*         m_pchReconFile;                       ///< output reconstruction file name
     71  Char*         m_pchReconFile;                       ///< output reconstruction file name
    7472#endif
    7573#if SYNTAX_OUTPUT
    76   char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
     74  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
    7775  Int           m_iBLSourceWidth;
    7876  Int           m_iBLSourceHeight;
     
    8078#endif
    8179  Int           m_iSkipFrame;                         ///< counter for frames prior to the random access point to skip
    82   UInt          m_outputBitDepth;                     ///< bit depth used for writing output
     80  Int           m_outputBitDepthY;                     ///< bit depth used for writing output (luma)
     81  Int           m_outputBitDepthC;                     ///< bit depth used for writing output (chroma)t
    8382
    8483  Int           m_iMaxTemporalLayer;                  ///< maximum temporal layer to be decoded
     
    8887  Int           m_tgtLayerId;                        ///< target layer ID
    8988#endif
     89  std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
     90  Int           m_respectDefDispWindow;               ///< Only output content inside the default display window
    9091
    91 #if TARGET_DECLAYERID_SET
    92   std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
     92public:
     93  TAppDecCfg()
     94  : m_pchBitstreamFile(NULL)
     95#if !SVC_EXTENSION
     96  , m_pchReconFile(NULL)
    9397#endif
    94  
    95 public:
    96   TAppDecCfg()          {}
     98  , m_iSkipFrame(0)
     99  , m_outputBitDepthY(0)
     100  , m_outputBitDepthC(0)
     101  , m_iMaxTemporalLayer(-1)
     102  , m_decodedPictureHashSEIEnabled(0)
     103#if SVC_EXTENSION
     104  , m_tgtLayerId(0)
     105#endif
     106  , m_respectDefDispWindow(0)
     107#if AVC_BASE
     108  , m_iBLSourceWidth(0)
     109  , m_iBLSourceHeight(0)
     110#endif
     111#if SYNTAX_OUTPUT
     112  , m_iBLSourceWidth(0)
     113  , m_iBLSourceHeight(0)
     114  , m_iBLFrames(0)
     115#endif
     116  {}
    97117  virtual ~TAppDecCfg() {}
    98118 
  • trunk/source/App/TAppDecoder/TAppDecTop.cpp

    r55 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5353// ====================================================================================================================
    5454
     55#if SVC_EXTENSION
    5556TAppDecTop::TAppDecTop()
    5657{
    5758  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
    58 #if SVC_EXTENSION
    5959  for(UInt layer=0; layer < MAX_LAYERS; layer++)
    6060  {
     
    6262    m_apcTDecTop[layer] = &m_acTDecTop[layer];
    6363  }
    64 #else
    65   m_iPOCLastDisplay  = -MAX_INT;
    66 #endif
    67 
    68 }
     64}
     65#else
     66TAppDecTop::TAppDecTop()
     67: m_iPOCLastDisplay(-MAX_INT)
     68{
     69  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
     70}
     71#endif
    6972
    7073Void TAppDecTop::create()
     
    126129Void TAppDecTop::decode()
    127130{
    128   UInt                uiPOC;
     131  Int                poc;
    129132  TComList<TComPic*>* pcListPic = NULL;
    130133
     
    143146
    144147  // main decoder loop
    145   bool recon_opened[MAX_LAYERS]; // reconstruction file not yet opened. (must be performed after SPS is seen)
     148  Bool recon_opened[MAX_LAYERS]; // reconstruction file not yet opened. (must be performed after SPS is seen)
    146149  for(UInt layer=0; layer<=m_tgtLayerId; layer++)
    147150  {
     
    200203
    201204    // call actual decoding function
    202     bool bNewPicture = false;
    203     bool bNewPOC = false;
     205    Bool bNewPicture = false;
     206    Bool bNewPOC = false;
    204207    if (nalUnit.empty())
    205208    {
     
    214217    {
    215218      read(nalu, nalUnit);
    216 #if TARGET_DECLAYERID_SET
    217219      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  ||
    218220        (nalu.m_layerId > m_tgtLayerId) )
    219 #else
    220       if(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer ||
    221         (nalu.m_layerId > m_tgtLayerId) )
    222 #endif
    223221      {
    224222        bNewPicture = false;
     
    241239    if (bNewPicture || !bitstreamFile)
    242240    {
    243       m_acTDecTop[curLayerId].executeDeblockAndAlf(uiPOC, pcListPic, m_iSkipFrame, m_aiPOCLastDisplay[curLayerId]);
     241      m_acTDecTop[curLayerId].executeLoopFilters(poc, pcListPic);
    244242    }
    245243
     
    248246      if ( m_pchReconFile[curLayerId] && !recon_opened[curLayerId] )
    249247      {
    250         if ( m_outputBitDepth == 0 )
    251         {
    252           m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
    253         }
    254 
    255         m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement ); // write mode
     248        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }       
     249        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
     250
     251        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
     252
    256253        recon_opened[curLayerId] = true;
    257254      }
    258255      if ( bNewPicture && bNewPOC &&
    259256           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
    260 #if SUPPORT_FOR_RAP_N_LP
    261257            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
    262258            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
    263 #endif
    264259            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
    265260            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA ) )
     
    306301Void TAppDecTop::decode()
    307302{
    308   UInt                uiPOC;
     303  Int                 poc;
    309304  TComList<TComPic*>* pcListPic = NULL;
    310305
     
    324319
    325320  // main decoder loop
    326   bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
     321  Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
    327322
    328323#if SYNTAX_OUTPUT
     
    355350    streampos location = bitstreamFile.tellg();
    356351    AnnexBStats stats = AnnexBStats();
    357     bool bPreviousPictureDecoded = false;
     352    Bool bPreviousPictureDecoded = false;
    358353
    359354    vector<uint8_t> nalUnit;
     
    362357
    363358    // call actual decoding function
    364     bool bNewPicture = false;
     359    Bool bNewPicture = false;
    365360    if (nalUnit.empty())
    366361    {
     
    375370    {
    376371      read(nalu, nalUnit);
    377 #if TARGET_DECLAYERID_SET
    378372      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
    379 #else
    380       if(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer)
    381 #endif
    382373      {
    383374        if(bPreviousPictureDecoded)
     
    409400    if (bNewPicture || !bitstreamFile)
    410401    {
    411       m_cTDecTop.executeDeblockAndAlf(uiPOC, pcListPic, m_iSkipFrame, m_iPOCLastDisplay);
     402      m_cTDecTop.executeLoopFilters(poc, pcListPic);
    412403    }
    413404
     
    416407      if ( m_pchReconFile && !recon_opened )
    417408      {
    418         if ( m_outputBitDepth == 0 )
    419         {
    420           m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
    421         }
    422 
    423         m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement ); // write mode
     409        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
     410        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
     411
     412        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
    424413        recon_opened = true;
    425414      }
    426415      if ( bNewPicture &&
    427416           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
    428 #if SUPPORT_FOR_RAP_N_LP
    429417            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
    430418            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
    431 #endif
    432419            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
    433420            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA ) )
     
    442429    }
    443430  }
    444 
     431 
    445432#if SYNTAX_OUTPUT
    446433  if( streamSyntaxFile.is_open() )
     
    559546  {
    560547    TComPic* pcPic = *(iterPic);
    561     TComSPS *sps = pcPic->getSlice(0)->getSPS();
    562548   
    563549#if SVC_EXTENSION
    564     if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getSlice(0)->getSPS()->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId]))
    565 #else
    566     if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getSlice(0)->getSPS()->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
     550    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId]))
     551#else
     552    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
    567553#endif
    568554    {
     
    572558      if ( m_pchReconFile[layerId] )
    573559      {
    574         m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
     560        const Window &conf = pcPic->getConformanceWindow();
     561        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     562        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
     563                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     564                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     565                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     566                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    575567      }
    576568     
     
    580572      if ( m_pchReconFile )
    581573      {
    582         m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
     574        const Window &conf = pcPic->getConformanceWindow();
     575        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     576        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     577                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     578                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     579                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     580                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    583581      }
    584582     
     
    630628  {
    631629    TComPic* pcPic = *(iterPic);
    632     TComSPS *sps = pcPic->getSlice(0)->getSPS();
    633630
    634631    if ( pcPic->getOutputMark() )
     
    638635      if ( m_pchReconFile[layerId] )
    639636      {
    640         m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
     637        const Window &conf = pcPic->getConformanceWindow();
     638        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     639        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
     640                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     641                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     642                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     643                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    641644      }
    642645     
     
    646649      if ( m_pchReconFile )
    647650      {
    648         m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
     651        const Window &conf = pcPic->getConformanceWindow();
     652        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     653        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     654                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     655                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     656                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     657                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    649658      }
    650659     
     
    679688      pcPic = NULL;
    680689    }
    681 #endif
     690#endif   
    682691#endif
    683692    iterPic++;
     
    686695  m_aiPOCLastDisplay[layerId] = -MAX_INT;
    687696#else
    688   pcListPic->clear(); //k Cannot be cleared here. Otherwise, pictures will never be destroyed.
     697  pcListPic->clear();
    689698  m_iPOCLastDisplay = -MAX_INT;
    690699#endif
    691700}
    692701
    693 #if TARGET_DECLAYERID_SET
    694702/** \param nalu Input nalu to check whether its LayerId is within targetDecLayerIdSet
    695703 */
     
    709717  return false;
    710718}
    711 #endif
    712719
    713720//! \}
  • trunk/source/App/TAppDecoder/TAppDecTop.h

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    9898  Void  xFlushOutput      ( TComList<TComPic*>* pcListPic ); ///< flush all remaining decoded pictures to file
    9999#endif
    100 #if TARGET_DECLAYERID_SET
    101100  Bool  isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet
    102 #endif
    103101};
    104102
  • trunk/source/App/TAppDecoder/decmain.cpp

    r14 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
Note: See TracChangeset for help on using the changeset viewer.