Changeset 125 in SHVCSoftware for trunk/source/App


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
Files:
13 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 *
  • trunk/source/App/TAppEncoder/TAppEncCfg.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 *
     
    4242#include "TLibCommon/TComRom.h"
    4343#include "TAppEncCfg.h"
     44
     45static istream& operator>>(istream &, Level::Name &);
     46static istream& operator>>(istream &, Level::Tier &);
     47static istream& operator>>(istream &, Profile::Name &);
     48
    4449#include "TAppCommon/program_options_lite.h"
    4550#include "TLibEncoder/TEncRateCtrl.h"
     
    5863// ====================================================================================================================
    5964
     65#if SVC_EXTENSION
    6066TAppEncCfg::TAppEncCfg()
    61 #if SVC_EXTENSION
    62 : m_pchBitstreamFile()
    63 , m_pchColumnWidth()
    64 , m_pchRowHeight()
     67: m_pBitstreamFile()
     68, m_pColumnWidth()
     69, m_pRowHeight()
    6570, m_scalingListFile()
    6671#if REF_IDX_FRAMEWORK
    6772, m_elRapSliceBEnabled(0)
    6873#endif
     74{
     75  for(UInt layer=0; layer<MAX_LAYERS; layer++)
     76  {
     77    m_acLayerCfg[layer].setAppEncCfg(this);
     78  }
     79}
    6980#else
     81TAppEncCfg::TAppEncCfg()
    7082: m_pchInputFile()
    7183, m_pchBitstreamFile()
    7284, m_pchReconFile()
    7385, m_pchdQPFile()
    74 , m_pchColumnWidth()
    75 , m_pchRowHeight()
     86, m_pColumnWidth()
     87, m_pRowHeight()
    7688, m_scalingListFile()
    77 #endif
     89{
     90  m_aidQP = NULL;
     91}
     92#endif
     93
     94TAppEncCfg::~TAppEncCfg()
    7895{
    7996#if SVC_EXTENSION
    80   for(UInt layer=0; layer<MAX_LAYERS; layer++)
    81   {
    82     m_acLayerCfg[layer].setAppEncCfg(this);
    83   }
     97  free(m_pBitstreamFile);
    8498#else
    85   m_aidQP = NULL;
    86 #endif
    87 }
    88 
    89 TAppEncCfg::~TAppEncCfg()
    90 {
    91 #if !SVC_EXTENSION
     99  free(m_pchBitstreamFile);
    92100  if ( m_aidQP )
    93101  {
    94102    delete[] m_aidQP;
    95103  }
    96   free(m_pchInputFile);
    97 #endif
    98   free(m_pchBitstreamFile);
     104  free(m_pchInputFile);
     105#endif
    99106#if !SVC_EXTENSION 
    100107  free(m_pchReconFile);
    101108  free(m_pchdQPFile);
    102109#endif
    103   free(m_pchColumnWidth);
    104   free(m_pchRowHeight);
     110  free(m_pColumnWidth);
     111  free(m_pRowHeight);
    105112  free(m_scalingListFile);
    106113}
     
    120127  in>>entry.m_QPOffset;
    121128  in>>entry.m_QPFactor;
     129  in>>entry.m_tcOffsetDiv2;
     130  in>>entry.m_betaOffsetDiv2;
    122131  in>>entry.m_temporalId;
    123132  in>>entry.m_numRefPicsActive;
    124 #if !TEMPORAL_LAYER_NON_REFERENCE
    125   in>>entry.m_refPic;
    126 #endif
    127133  in>>entry.m_numRefPics;
    128134  for ( Int i = 0; i < entry.m_numRefPics; i++ )
     
    134140  if (entry.m_interRPSPrediction==1)
    135141  {
    136 #if !J0234_INTER_RPS_SIMPL
    137     in>>entry.m_deltaRIdxMinus1;
    138 #endif
    139142    in>>entry.m_deltaRPS;
    140143    in>>entry.m_numRefIdc;
     
    146149  else if (entry.m_interRPSPrediction==2)
    147150  {
    148 #if !J0234_INTER_RPS_SIMPL
    149     in>>entry.m_deltaRIdxMinus1;
    150 #endif
    151151    in>>entry.m_deltaRPS;
    152152  }
     
    154154  if (entry.m_interRPSPrediction)
    155155  {
    156 #if !J0234_INTER_RPS_SIMPL
    157     in>>entry.m_deltaRIdxMinus1;
    158 #endif
    159156    in>>entry.m_deltaRPS;
    160157    in>>entry.m_numRefIdc;
     
    194191#endif
    195192
     193static const struct MapStrToProfile {
     194  const Char* str;
     195  Profile::Name value;
     196} strToProfile[] = {
     197  {"none", Profile::NONE},
     198  {"main", Profile::MAIN},
     199  {"main10", Profile::MAIN10},
     200  {"main-still-picture", Profile::MAINSTILLPICTURE},
     201};
     202
     203static const struct MapStrToTier {
     204  const Char* str;
     205  Level::Tier value;
     206} strToTier[] = {
     207  {"main", Level::MAIN},
     208  {"high", Level::HIGH},
     209};
     210
     211static const struct MapStrToLevel {
     212  const Char* str;
     213  Level::Name value;
     214} strToLevel[] = {
     215  {"none",Level::NONE},
     216  {"1",   Level::LEVEL1},
     217  {"2",   Level::LEVEL2},
     218  {"2.1", Level::LEVEL2_1},
     219  {"3",   Level::LEVEL3},
     220  {"3.1", Level::LEVEL3_1},
     221  {"4",   Level::LEVEL4},
     222  {"4.1", Level::LEVEL4_1},
     223  {"5",   Level::LEVEL5},
     224  {"5.1", Level::LEVEL5_1},
     225  {"5.2", Level::LEVEL5_2},
     226  {"6",   Level::LEVEL6},
     227  {"6.1", Level::LEVEL6_1},
     228  {"6.2", Level::LEVEL6_2},
     229};
     230
     231template<typename T, typename P>
     232static istream& readStrToEnum(P map[], unsigned long mapLen, istream &in, T &val)
     233{
     234  string str;
     235  in >> str;
     236
     237  for (Int i = 0; i < mapLen; i++)
     238  {
     239    if (str == map[i].str)
     240    {
     241      val = map[i].value;
     242      goto found;
     243    }
     244  }
     245  /* not found */
     246  in.setstate(ios::failbit);
     247found:
     248  return in;
     249}
     250
     251static istream& operator>>(istream &in, Profile::Name &profile)
     252{
     253  return readStrToEnum(strToProfile, sizeof(strToProfile)/sizeof(*strToProfile), in, profile);
     254}
     255
     256static istream& operator>>(istream &in, Level::Tier &tier)
     257{
     258  return readStrToEnum(strToTier, sizeof(strToTier)/sizeof(*strToTier), in, tier);
     259}
     260
     261static istream& operator>>(istream &in, Level::Name &level)
     262{
     263  return readStrToEnum(strToLevel, sizeof(strToLevel)/sizeof(*strToLevel), in, level);
     264}
     265
     266#if SIGNAL_BITRATE_PICRATE_IN_VPS
     267Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName);
     268Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName);
     269#endif
    196270// ====================================================================================================================
    197271// Public member functions
     
    204278Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] )
    205279{
    206   bool do_help = false;
     280  Bool do_help = false;
    207281 
    208282#if SVC_EXTENSION
     
    217291  Int*    cfg_FrameRate     [MAX_LAYERS];
    218292  Int*    cfg_IntraPeriod   [MAX_LAYERS];
    219   Int*    cfg_CroppingMode  [MAX_LAYERS];
     293  Int*    cfg_conformanceMode  [MAX_LAYERS];
     294#if VPS_EXTN_DIRECT_REF_LAYERS
     295  Int*    cfg_numDirectRefLayers [MAX_LAYERS];
     296  string cfg_refLayerIds   [MAX_LAYERS];
     297  string* cfg_refLayerIdsPtr   [MAX_LAYERS];
     298#endif
    220299  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
    221300  {
     
    227306    cfg_FrameRate[layer]    = &m_acLayerCfg[layer].m_iFrameRate;
    228307    cfg_IntraPeriod[layer]  = &m_acLayerCfg[layer].m_iIntraPeriod;
    229     cfg_CroppingMode[layer] = &m_acLayerCfg[layer].m_croppingMode;
     308    cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode;
     309#if VPS_EXTN_DIRECT_REF_LAYERS
     310    cfg_numDirectRefLayers  [layer] = &m_acLayerCfg[layer].m_numDirectRefLayers;
     311    cfg_refLayerIdsPtr      [layer]  = &cfg_refLayerIds[layer];
     312#endif
    230313  }
    231314#if AVC_SYNTAX
     
    241324  string cfg_RowHeight;
    242325  string cfg_ScalingListFile;
     326#if SIGNAL_BITRATE_PICRATE_IN_VPS
     327  string cfg_bitRateInfoPresentFlag;
     328  string cfg_picRateInfoPresentFlag;
     329  string cfg_avgBitRate;
     330  string cfg_maxBitRate;
     331  string cfg_avgPicRate;
     332  string cfg_constantPicRateIdc;
     333#endif
    243334  po::Options opts;
    244335  opts.addOptions()
     
    251342  ("ReconFile%d,-o%d",        cfg_ReconFile,  string(""), MAX_LAYERS, "reconstruction YUV input file name for layer %d")
    252343  ("LayerConfig%d,-lc%d",     cfg_LayerCfgFile, string(""), MAX_LAYERS, "layer %d configuration file name")
    253   ("BitstreamFile,b",         cfg_BitstreamFile, string(""), "bitstream output file name")
    254344  ("SourceWidth%d,-wdt%d",    cfg_SourceWidth, 0, MAX_LAYERS, "Source picture width for layer %d")
    255345  ("SourceHeight%d,-hgt%d",   cfg_SourceHeight, 0, MAX_LAYERS, "Source picture height for layer %d")
    256346  ("FrameRate%d,-fr%d",       cfg_FrameRate,  0, MAX_LAYERS, "Frame rate for layer %d")
    257347  ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
    258   ("CroppingMode%d",          cfg_CroppingMode,0, MAX_LAYERS, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
    259   ("InputBitDepth",           m_uiInputBitDepth, 8u, "bit-depth of input file")
    260   ("BitDepth",                m_uiInputBitDepth, 8u, "deprecated alias of InputBitDepth")
    261   ("OutputBitDepth",          m_uiOutputBitDepth, 0u, "bit-depth of output file")
    262   ("InternalBitDepth",        m_uiInternalBitDepth, 0u, "Internal bit-depth (BitDepth+BitIncrement)")
     348#if VPS_EXTN_DIRECT_REF_LAYERS
     349  ("NumDirectRefLayers%d",    cfg_numDirectRefLayers, -1, MAX_LAYERS, "Number of direct reference layers")
     350  ("RefLayerIds%d",           cfg_refLayerIdsPtr, string(""), MAX_LAYERS, "direct reference layer IDs")
     351#endif
     352  ("NumLayers",               m_numLayers, 1, "Number of layers to code")
     353  ("ConformanceMode%d",       cfg_conformanceMode,0, MAX_LAYERS, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
     354
     355  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
     356  ("InputBitDepth",         m_inputBitDepthY,    8, "Bit-depth of input file")
     357  ("OutputBitDepth",        m_outputBitDepthY,   0, "Bit-depth of output file (default:InternalBitDepth)")
     358  ("InternalBitDepth",      m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)"
     359                                                       "If different to InputBitDepth, source data will be converted")
     360  ("InputBitDepthC",        m_inputBitDepthC,    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
     361  ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
     362  ("InternalBitDepthC",     m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
     363
    263364#if AVC_BASE
    264365  ("InputBLFile,-ibl",        *cfg_InputFile[0],     string(""), "Base layer rec YUV input file name")
     
    269370#if REF_IDX_FRAMEWORK
    270371  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture_")
    271 #endif
    272 #else
     372#endif 
     373#else 
    273374  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
    274375  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
     
    276377  ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
    277378  ("SourceHeight,-hgt",     m_iSourceHeight,       0, "Source picture height")
    278   ("InputBitDepth",         m_uiInputBitDepth,    8u, "Bit-depth of input file")
    279   ("BitDepth",              m_uiInputBitDepth,    8u, "Deprecated alias of InputBitDepth")
    280   ("OutputBitDepth",        m_uiOutputBitDepth,   0u, "Bit-depth of output file")
    281   ("InternalBitDepth",      m_uiInternalBitDepth, 0u, "Internal bit-depth (BitDepth+BitIncrement)")
    282   ("CroppingMode",          m_croppingMode,        0, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
    283   ("HorizontalPadding,-pdx",m_aiPad[0],            0, "Horizontal source padding for cropping mode 2")
    284   ("VerticalPadding,-pdy",  m_aiPad[1],            0, "Vertical source padding for cropping mode 2")
    285   ("CropLeft",              m_cropLeft,            0, "Left cropping for cropping mode 3")
    286   ("CropRight",             m_cropRight,           0, "Right cropping for cropping mode 3")
    287   ("CropTop",               m_cropTop,             0, "Top cropping for cropping mode 3")
    288   ("CropBottom",            m_cropBottom,          0, "Bottom cropping for cropping mode 3")
     379  ("InputBitDepth",         m_inputBitDepthY,    8, "Bit-depth of input file")
     380  ("OutputBitDepth",        m_outputBitDepthY,   0, "Bit-depth of output file (default:InternalBitDepth)")
     381  ("InternalBitDepth",      m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)"
     382                                                       "If different to InputBitDepth, source data will be converted")
     383  ("InputBitDepthC",        m_inputBitDepthC,    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
     384  ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
     385  ("InternalBitDepthC",     m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
     386  ("ConformanceMode",       m_conformanceMode,     0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
     387  ("HorizontalPadding,-pdx",m_aiPad[0],            0, "Horizontal source padding for conformance window mode 2")
     388  ("VerticalPadding,-pdy",  m_aiPad[1],            0, "Vertical source padding for conformance window mode 2")
     389  ("ConfLeft",              m_confLeft,            0, "Left offset for window conformance mode 3")
     390  ("ConfRight",             m_confRight,           0, "Right offset for window conformance mode 3")
     391  ("ConfTop",               m_confTop,             0, "Top offset for window conformance mode 3")
     392  ("ConfBottom",            m_confBottom,          0, "Bottom offset for window conformance mode 3")
    289393  ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
    290394#endif
    291395  ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
    292   ("FramesToBeEncoded,f",   m_iFrameToBeEncoded,   0, "Number of frames to be encoded (default=all)")
    293  
    294 #if SVC_EXTENSION
    295   ("NumLayers",             m_numLayers, 1, "Number of layers to code")
     396  ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
     397 
     398  // Profile and level
     399  ("Profile", m_profile,   Profile::NONE, "Profile to be used when encoding (Incomplete)")
     400  ("Level",   m_level,     Level::NONE,   "Level limit to be used, eg 5.1 (Incomplete)")
     401  ("Tier",    m_levelTier, Level::MAIN,   "Tier to use for interpretation of --Level")
     402
     403#if L0046_CONSTRAINT_FLAGS
     404  ("ProgressiveSource", m_progressiveSourceFlag, false, "Indicate that source is progressive")
     405  ("InterlacedSource",  m_interlacedSourceFlag,  false, "Indicate that source is interlaced")
     406  ("NonPackedSource",   m_nonPackedConstraintFlag, false, "Indicate that source does not contain frame packing")
     407  ("FrameOnly",         m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames")
    296408#endif
    297409
     
    326438  ("ASR",                     m_bUseASR,                false, "Adaptive motion search range")
    327439
    328 #if !SVC_EXTENSION
     440#if SVC_EXTENSION
     441  ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
     442#else
    329443  // Mode decision parameters
    330   ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( double )1.0, "Lambda modifier for temporal layer 0")
    331   ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], ( double )1.0, "Lambda modifier for temporal layer 1")
    332   ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], ( double )1.0, "Lambda modifier for temporal layer 2")
    333   ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], ( double )1.0, "Lambda modifier for temporal layer 3")
    334   ("LambdaModifier4,-LM4", m_adLambdaModifier[ 4 ], ( double )1.0, "Lambda modifier for temporal layer 4")
    335   ("LambdaModifier5,-LM5", m_adLambdaModifier[ 5 ], ( double )1.0, "Lambda modifier for temporal layer 5")
    336   ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( double )1.0, "Lambda modifier for temporal layer 6")
    337   ("LambdaModifier7,-LM7", m_adLambdaModifier[ 7 ], ( double )1.0, "Lambda modifier for temporal layer 7")
     444  ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( Double )1.0, "Lambda modifier for temporal layer 0")
     445  ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], ( Double )1.0, "Lambda modifier for temporal layer 1")
     446  ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], ( Double )1.0, "Lambda modifier for temporal layer 2")
     447  ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], ( Double )1.0, "Lambda modifier for temporal layer 3")
     448  ("LambdaModifier4,-LM4", m_adLambdaModifier[ 4 ], ( Double )1.0, "Lambda modifier for temporal layer 4")
     449  ("LambdaModifier5,-LM5", m_adLambdaModifier[ 5 ], ( Double )1.0, "Lambda modifier for temporal layer 5")
     450  ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( Double )1.0, "Lambda modifier for temporal layer 6")
     451  ("LambdaModifier7,-LM7", m_adLambdaModifier[ 7 ], ( Double )1.0, "Lambda modifier for temporal layer 7")
    338452#endif
    339453
     
    360474  ("dQPFile,m",                     cfg_dQPFile,           string(""), "dQP file name")
    361475#endif
    362   ("RDOQ",                          m_bUseRDOQ,                  true )
    363  
     476  ("RDOQ",                          m_useRDOQ,                  true )
     477  ("RDOQTS",                        m_useRDOQTS,                true )
     478#if L0232_RD_PENALTY
     479  ("RDpenalty",                     m_rdPenalty,                0,  "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disbaled  1:RD-penalty  2:maximum RD-penalty")
     480#endif
    364481  // Entropy coding parameters
    365482  ("SBACRD",                         m_bUseSBACRD,                      true, "SBAC based RD estimation")
     
    373490
    374491  // Coding tools
    375 #if !REMOVE_NSQT
    376   ("NSQT",                    m_enableNSQT,              true, "Enable non-square transforms")
    377 #endif
    378   ("AMP",                     m_enableAMP,               true, "Enable asymmetric motion partitions")
    379 #if !REMOVE_LMCHROMA
    380   ("LMChroma",                m_bUseLMChroma,            true, "Intra chroma prediction based on reconstructed luma")
    381 #endif
    382   ("TransformSkip",           m_useTransformSkip,        false, "Intra transform skipping")
    383   ("TransformSkipFast",       m_useTransformSkipFast,    false, "Fast intra transform skipping")
    384 #if !REMOVE_ALF
    385   ("ALF",                     m_bUseALF,                 true, "Enable Adaptive Loop Filter")
    386 #endif
    387   ("SAO",                     m_bUseSAO,                 true, "Enable Sample Adaptive Offset")
    388   ("MaxNumOffsetsPerPic",     m_maxNumOffsetsPerPic,     2048, "Max number of SAO offset per picture (Default: 2048)")   
    389 #if SAO_LCU_BOUNDARY
    390   ("SAOLcuBoundary",          m_saoLcuBoundary,          false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
    391 #endif
    392   ("SAOLcuBasedOptimization", m_saoLcuBasedOptimization, true, "0: SAO picture-based optimization, 1: SAO LCU-based optimization ")
    393 #if !REMOVE_ALF
    394   ("ALFLowLatencyEncode", m_alfLowLatencyEncoding, false, "Low-latency ALF encoding, 0: picture latency (trained from current frame), 1: LCU latency(trained from previous frame)")
    395 #endif
    396   ("SliceMode",            m_iSliceMode,           0, "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes")
    397     ("SliceArgument",        m_iSliceArgument,       0, "if SliceMode==1 SliceArgument represents max # of LCUs. if SliceMode==2 SliceArgument represents max # of bytes.")
    398     ("DependentSliceMode",     m_iDependentSliceMode,    0, "0: Disable all dependent slice limits, 1: Enforce max # of LCUs, 2: Enforce constraint based dependent slices")
    399     ("DependentSliceArgument", m_iDependentSliceArgument,0, "if DependentSliceMode==1 SliceArgument represents max # of LCUs. if DependentSliceMode==2 DependentSliceArgument represents max # of bins.")
    400 #if DEPENDENT_SLICES
    401 #if TILES_WPP_ENTROPYSLICES_FLAGS
    402     ("EntropySliceEnabledFlag", m_entropySliceEnabledFlag, false, "Enable use of entropy slices instead of dependent slices." )
    403 #else
    404     ("CabacIndependentFlag", m_bCabacIndependentFlag, false)
    405 #endif
    406 #endif
    407 #if !REMOVE_FGS
    408     ("SliceGranularity",     m_iSliceGranularity,    0, "0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.")
    409 #endif
    410     ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true)
    411 
    412     ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction")
    413     ("PCMEnabledFlag", m_usePCM         , false)
    414     ("PCMLog2MaxSize", m_pcmLog2MaxSize, 5u)
    415     ("PCMLog2MinSize", m_uiPCMLog2MinSize, 3u)
    416 
    417     ("PCMInputBitDepthFlag", m_bPCMInputBitDepthFlag, true)
    418     ("PCMFilterDisableFlag", m_bPCMFilterDisableFlag, false)
    419     ("LosslessCuEnabled", m_useLossless, false)
    420     ("weighted_pred_flag,-wpP",     m_bUseWeightPred, false, "weighted prediction flag (P-Slices)")
    421     ("weighted_bipred_flag,-wpB",   m_useWeightedBiPred,    false,    "weighted bipred flag (B-Slices)")
    422     ("Log2ParallelMergeLevel",      m_log2ParallelMergeLevel,     2u,          "Parallel merge estimation region")
    423     ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,          "Indicates if the column and row boundaries are distributed uniformly")
    424     ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
    425     ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""), "Array containing ColumnWidth values in units of LCU")
    426     ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
    427     ("RowHeightArray",              cfg_RowHeight,                   string(""), "Array containing RowHeight values in units of LCU")
    428     ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,          "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
    429     ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
    430     ("ScalingList",                 m_useScalingListId,              0,          "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
    431     ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
    432     ("SignHideFlag,-SBH",                m_signHideFlag, 1)
    433     ("MaxNumMergeCand",             m_maxNumMergeCand,             5u,         "Maximum number of merge candidates")
     492  ("AMP",                      m_enableAMP,                 true,  "Enable asymmetric motion partitions")
     493  ("TransformSkip",            m_useTransformSkip,          false, "Intra transform skipping")
     494  ("TransformSkipFast",        m_useTransformSkipFast,      false, "Fast intra transform skipping")
     495  ("SAO",                      m_bUseSAO,                   true,  "Enable Sample Adaptive Offset")
     496  ("MaxNumOffsetsPerPic",      m_maxNumOffsetsPerPic,       2048,  "Max number of SAO offset per picture (Default: 2048)")   
     497  ("SAOLcuBoundary",           m_saoLcuBoundary,            false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
     498  ("SAOLcuBasedOptimization",  m_saoLcuBasedOptimization,   true,  "0: SAO picture-based optimization, 1: SAO LCU-based optimization ")
     499  ("SliceMode",                m_sliceMode,                0,     "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
     500  ("SliceArgument",            m_sliceArgument,            0,     "Depending on SliceMode being:"
     501                                                                   "\t1: max number of CTUs per slice"
     502                                                                   "\t2: max number of bytes per slice"
     503                                                                   "\t3: max number of tiles per slice")
     504  ("SliceSegmentMode",         m_sliceSegmentMode,       0,     "0: Disable all slice segment limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
     505  ("SliceSegmentArgument",     m_sliceSegmentArgument,   0,     "Depending on SliceSegmentMode being:"
     506                                                                   "\t1: max number of CTUs per slice segment"
     507                                                                   "\t2: max number of bytes per slice segment"
     508                                                                   "\t3: max number of tiles per slice segment")
     509  ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true)
     510
     511  ("ConstrainedIntraPred",     m_bUseConstrainedIntraPred,  false, "Constrained Intra Prediction")
     512
     513  ("PCMEnabledFlag",           m_usePCM,                    false)
     514  ("PCMLog2MaxSize",           m_pcmLog2MaxSize,            5u)
     515  ("PCMLog2MinSize",           m_uiPCMLog2MinSize,          3u)
     516  ("PCMInputBitDepthFlag",     m_bPCMInputBitDepthFlag,     true)
     517  ("PCMFilterDisableFlag",     m_bPCMFilterDisableFlag,    false)
     518
     519  ("LosslessCuEnabled",        m_useLossless, false)
     520
     521  ("WeightedPredP,-wpP",          m_useWeightedPred,               false,      "Use weighted prediction in P slices")
     522  ("WeightedPredB,-wpB",          m_useWeightedBiPred,             false,      "Use weighted (bidirectional) prediction in B slices")
     523  ("Log2ParallelMergeLevel",      m_log2ParallelMergeLevel,     2u,          "Parallel merge estimation region")
     524  ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,          "Indicates if the column and row boundaries are distributed uniformly")
     525  ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
     526  ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""), "Array containing ColumnWidth values in units of LCU")
     527  ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
     528  ("RowHeightArray",              cfg_RowHeight,                   string(""), "Array containing RowHeight values in units of LCU")
     529  ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,          "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
     530  ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
     531  ("ScalingList",                 m_useScalingListId,              0,          "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
     532  ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
     533  ("SignHideFlag,-SBH",                m_signHideFlag, 1)
     534  ("MaxNumMergeCand",             m_maxNumMergeCand,             5u,         "Maximum number of merge candidates")
    434535
    435536  /* Misc. */
    436   ("SEIpictureDigest",  m_decodePictureHashSEIEnabled, 0, "Control generation of decode picture hash SEI messages\n"
    437                                               "\t3: checksum\n"
    438                                               "\t2: CRC\n"
    439                                               "\t1: use MD5\n"
    440                                               "\t0: disable")
     537  ("SEIDecodedPictureHash",       m_decodedPictureHashSEIEnabled, 0, "Control generation of decode picture hash SEI messages\n"
     538                                                                    "\t3: checksum\n"
     539                                                                    "\t2: CRC\n"
     540                                                                    "\t1: use MD5\n"
     541                                                                    "\t0: disable")
     542  ("SEIpictureDigest",            m_decodedPictureHashSEIEnabled, 0, "deprecated alias for SEIDecodedPictureHash")
    441543  ("TMVPMode", m_TMVPModeId, 1, "TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices (default) 2: TMVP enable for certain slices only")
    442544  ("FEN", m_bUseFastEnc, false, "fast encoder setting")
     
    445547  ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting")
    446548  ("ESD", m_useEarlySkipDetection, false, "Early SKIP detection setting")
     549#if RATE_CONTROL_LAMBDA_DOMAIN
     550  ( "RateControl",         m_RCEnableRateControl,   false, "Rate control: enable rate control" )
     551  ( "TargetBitrate",       m_RCTargetBitrate,           0, "Rate control: target bitrate" )
     552  ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit, false, "Rate control: keep hierarchical bit allocation in rate control algorithm" )
     553  ( "LCULevelRateControl", m_RCLCULevelRC,           true, "Rate control: true: LCU level RC; false: picture level RC" )
     554  ( "RCLCUSeparateModel",  m_RCUseLCUSeparateModel,  true, "Rate control: use LCU level separate R-lambda model" )
     555  ( "InitialQP",           m_RCInitialQP,               0, "Rate control: initial QP" )
     556  ( "RCForceIntraQP",      m_RCForceIntraQP,        false, "Rate control: force intra QP to be equal to initial QP" )
     557#else
    447558  ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off")
    448559  ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate")
    449560  ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit")
     561#endif
    450562
    451563  ("TransquantBypassEnableFlag", m_TransquantBypassEnableFlag, false, "transquant_bypass_enable_flag indicator in PPS")
    452564  ("CUTransquantBypassFlagValue", m_CUTransquantBypassFlagValue, false, "Fixed cu_transquant_bypass_flag value, when transquant_bypass_enable_flag is enabled")
    453 #if RECALCULATE_QP_ACCORDING_LAMBDA
    454565  ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
    455 #endif
    456 #if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
    457   ("ActiveParameterSets", m_activeParameterSetsSEIEnabled, 0, "Control generation of active parameter sets SEI messages\n"
    458                                                               "\t2: enable active parameter sets SEI message with active_sps_id\n"
    459                                                               "\t1: enable active parameter sets SEI message without active_sps_id\n"
    460                                                               "\t0: disable")
    461 #endif
    462 #if SUPPORT_FOR_VUI
     566  ("StrongIntraSmoothing,-sis",      m_useStrongIntraSmoothing,           true, "Enable strong intra smoothing for 32x32 blocks")
     567  ("SEIActiveParameterSets",         m_activeParameterSetsSEIEnabled,          0, "Enable generation of active parameter sets SEI messages")
    463568  ("VuiParametersPresent,-vui",      m_vuiParametersPresentFlag,           false, "Enable generation of vui_parameters()")
    464569  ("AspectRatioInfoPresent",         m_aspectRatioInfoPresentFlag,         false, "Signals whether aspect_ratio_idc is present")
     
    466571  ("SarWidth",                       m_sarWidth,                               0, "horizontal size of the sample aspect ratio")
    467572  ("SarHeight",                      m_sarHeight,                              0, "vertical size of the sample aspect ratio")
    468   ("OverscanInfoPresent",            m_overscanInfoPresentFlag,            false, "Indicates whether cropped decoded pictures are suitable for display using overscan\n")
    469   ("OverscanAppropriate",            m_overscanAppropriateFlag,            false, "Indicates whether cropped decoded pictures are suitable for display using overscan\n")
     573  ("OverscanInfoPresent",            m_overscanInfoPresentFlag,            false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
     574  ("OverscanAppropriate",            m_overscanAppropriateFlag,            false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
    470575  ("VideoSignalTypePresent",         m_videoSignalTypePresentFlag,         false, "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present")
    471576  ("VideoFormat",                    m_videoFormat,                            5, "Indicates representation of pictures")
     
    479584  ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField,         0, "Specifies the location of chroma samples for bottom field")
    480585  ("NeutralChromaIndication",        m_neutralChromaIndicationFlag,        false, "Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)")
     586  ("DefaultDisplayWindowFlag",       m_defaultDisplayWindowFlag,           false, "Indicates the presence of the Default Window parameters")
     587  ("DefDispWinLeftOffset",           m_defDispWinLeftOffset,                   0, "Specifies the left offset of the default display window from the conformance window")
     588  ("DefDispWinRightOffset",          m_defDispWinRightOffset,                  0, "Specifies the right offset of the default display window from the conformance window")
     589  ("DefDispWinTopOffset",            m_defDispWinTopOffset,                    0, "Specifies the top offset of the default display window from the conformance window")
     590  ("DefDispWinBottomOffset",         m_defDispWinBottomOffset,                 0, "Specifies the bottom offset of the default display window from the conformance window")
     591  ("FrameFieldInfoPresentFlag",      m_frameFieldInfoPresentFlag,               false, "Indicates that pic_struct and field coding related values are present in picture timing SEI messages")
     592  ("PocProportionalToTimingFlag",   m_pocProportionalToTimingFlag,         false, "Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS")
     593  ("NumTicksPocDiffOneMinus1",      m_numTicksPocDiffOneMinus1,                0, "Number of ticks minus 1 that for a POC difference of one")
    481594  ("BitstreamRestriction",           m_bitstreamRestrictionFlag,           false, "Signals whether bitstream restriction parameters are present")
    482595  ("TilesFixedStructure",            m_tilesFixedStructureFlag,            false, "Indicates that each active picture parameter set has the same values of the syntax elements related to tiles")
     
    486599  ("Log2MaxMvLengthHorizontal",      m_log2MaxMvLengthHorizontal,             15, "Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units")
    487600  ("Log2MaxMvLengthVertical",        m_log2MaxMvLengthVertical,               15, "Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units")
    488 #endif
    489 #if RECOVERY_POINT_SEI
    490601  ("SEIRecoveryPoint",               m_recoveryPointSEIEnabled,                0, "Control generation of recovery point SEI messages")
    491 #endif
    492 #if BUFFERING_PERIOD_AND_TIMING_SEI
    493602  ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0, "Control generation of buffering period SEI messages")
    494603  ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0, "Control generation of picture timing SEI messages")
     604  ("SEIFramePacking",                m_framePackingSEIEnabled,                 0, "Control generation of frame packing SEI messages")
     605  ("SEIFramePackingType",            m_framePackingSEIType,                    0, "Define frame packing arrangement\n"
     606                                                                                  "\t0: checkerboard - pixels alternatively represent either frames\n"
     607                                                                                  "\t1: column alternation - frames are interlaced by column\n"
     608                                                                                  "\t2: row alternation - frames are interlaced by row\n"
     609                                                                                  "\t3: side by side - frames are displayed horizontally\n"
     610                                                                                  "\t4: top bottom - frames are displayed vertically\n"
     611                                                                                  "\t5: frame alternation - one frame is alternated with the other")
     612  ("SEIFramePackingId",              m_framePackingSEIId,                      0, "Id of frame packing SEI message for a given session")
     613  ("SEIFramePackingQuincunx",        m_framePackingSEIQuincunx,                0, "Indicate the presence of a Quincunx type video frame")
     614  ("SEIFramePackingInterpretation",  m_framePackingSEIInterpretation,          0, "Indicate the interpretation of the frame pair\n"
     615                                                                                  "\t0: unspecified\n"
     616                                                                                  "\t1: stereo pair, frame0 represents left view\n"
     617                                                                                  "\t2: stereo pair, frame0 represents right view")
     618  ("SEIDisplayOrientation",          m_displayOrientationSEIAngle,             0, "Control generation of display orientation SEI messages\n"
     619                                                              "\tN: 0 < N < (2^16 - 1) enable display orientation SEI message with anticlockwise_rotation = N and display_orientation_repetition_period = 1\n"
     620                                                              "\t0: disable")
     621  ("SEITemporalLevel0Index",         m_temporalLevel0IndexSEIEnabled,          0, "Control generation of temporal level 0 index SEI messages")
     622  ("SEIGradualDecodingRefreshInfo",  m_gradualDecodingRefreshInfoEnabled,      0, "Control generation of gradual decoding refresh information SEI message")
     623  ("SEIDecodingUnitInfo",             m_decodingUnitInfoSEIEnabled,                       0, "Control generation of decoding unit information SEI message.")
     624#if SIGNAL_BITRATE_PICRATE_IN_VPS
     625  ("BitRatePicRateMaxTLayers",   m_bitRatePicRateMaxTLayers,           0, "Maximum number of sub-layers signalled; can be inferred otherwise; here for easy parsing of config. file")
     626  ("BitRateInfoPresent",         cfg_bitRateInfoPresentFlag,          string(""), "Control signalling of bit rate information of avg. bit rate and max. bit rate in VPS\n"
     627                                                                          "\t0: Do not sent bit rate info\n"
     628                                                                          "\tN (N > 0): Send bit rate info for N sub-layers. N should equal maxTempLayers.")                                                                     
     629  ("PicRateInfoPresent",         cfg_picRateInfoPresentFlag,          string(""), "Control signalling of picture rate information of avg. bit rate and max. bit rate in VPS\n"
     630                                                                          "\t0: Do not sent picture rate info\n"
     631                                                                          "\tN (N > 0): Send picture rate info for N sub-layers. N should equal maxTempLayers.")                                                                     
     632  ("AvgBitRate",                   cfg_avgBitRate,                    string(""), "List of avg. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
     633  ("MaxBitRate",                   cfg_maxBitRate,                    string(""), "List of max. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
     634  ("AvgPicRate",                   cfg_avgPicRate,                    string(""), "List of avg. picture rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
     635  ("ConstantPicRateIdc",           cfg_constantPicRateIdc,            string(""), "List of constant picture rate IDCs; include non-negative number even if corresponding flag is 0")
    495636#endif
    496637  ;
     
    502643  }
    503644  po::setDefaults(opts);
    504   const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv);
    505 
    506   for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
     645  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
     646
     647  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
    507648  {
    508649    fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
     
    521662  /* convert std::string to c string for compatability */
    522663#if SVC_EXTENSION
    523   m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
     664  m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
    524665#if AVC_SYNTAX
    525666  m_BLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str());
     
    530671  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
    531672  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
    532 #endif
    533  
    534   m_pchColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
    535   m_pchRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
     673#endif 
     674
     675  Char* pColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
     676  Char* pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
     677  if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 )
     678  {
     679    char *columnWidth;
     680    int  i=0;
     681    m_pColumnWidth = new UInt[m_iNumColumnsMinus1];
     682    columnWidth = strtok(pColumnWidth, " ,-");
     683    while(columnWidth!=NULL)
     684    {
     685      if( i>=m_iNumColumnsMinus1 )
     686      {
     687        printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
     688        exit( EXIT_FAILURE );
     689      }
     690      *( m_pColumnWidth + i ) = atoi( columnWidth );
     691      columnWidth = strtok(NULL, " ,-");
     692      i++;
     693    }
     694    if( i<m_iNumColumnsMinus1 )
     695    {
     696      printf( "The width of some columns is not defined.\n" );
     697      exit( EXIT_FAILURE );
     698    }
     699  }
     700  else
     701  {
     702    m_pColumnWidth = NULL;
     703  }
     704
     705  if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 )
     706  {
     707    char *rowHeight;
     708    int  i=0;
     709    m_pRowHeight = new UInt[m_iNumRowsMinus1];
     710    rowHeight = strtok(pRowHeight, " ,-");
     711    while(rowHeight!=NULL)
     712    {
     713      if( i>=m_iNumRowsMinus1 )
     714      {
     715        printf( "The number of rows whose height are defined is larger than the allowed number of rows.\n" );
     716        exit( EXIT_FAILURE );
     717      }
     718      *( m_pRowHeight + i ) = atoi( rowHeight );
     719      rowHeight = strtok(NULL, " ,-");
     720      i++;
     721    }
     722    if( i<m_iNumRowsMinus1 )
     723    {
     724      printf( "The height of some rows is not defined.\n" );
     725      exit( EXIT_FAILURE );
     726   }
     727  }
     728  else
     729  {
     730    m_pRowHeight = NULL;
     731  }
     732#if VPS_EXTN_DIRECT_REF_LAYERS
     733  for(Int layer = 0; layer < MAX_LAYERS; layer++)
     734  {
     735    Char* pRefLayerIds = cfg_refLayerIds[layer].empty() ? NULL: strdup(cfg_refLayerIds[layer].c_str());
     736    if( m_acLayerCfg[layer].m_numDirectRefLayers > 0 )
     737    {
     738      char *refLayerId;
     739      int  i=0;
     740      m_acLayerCfg[layer].m_refLayerIds = new Int[m_acLayerCfg[layer].m_numDirectRefLayers];
     741      refLayerId = strtok(pRefLayerIds, " ,-");
     742      while(refLayerId != NULL)
     743      {
     744        if( i >= m_acLayerCfg[layer].m_numDirectRefLayers )
     745        {
     746          printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
     747          exit( EXIT_FAILURE );
     748        }
     749        *( m_acLayerCfg[layer].m_refLayerIds + i ) = atoi( refLayerId );
     750        refLayerId = strtok(NULL, " ,-");
     751        i++;
     752      }
     753      if( i < m_acLayerCfg[layer].m_numDirectRefLayers )
     754      {
     755        printf( "The width of some columns is not defined.\n" );
     756        exit( EXIT_FAILURE );
     757      }
     758    }
     759    else
     760    {
     761      m_acLayerCfg[layer].m_refLayerIds = NULL;
     762    }
     763  }
     764#endif
     765#if SIGNAL_BITRATE_PICRATE_IN_VPS
     766  readBoolString(cfg_bitRateInfoPresentFlag, m_bitRatePicRateMaxTLayers, m_bitRateInfoPresentFlag, "bit rate info. present flag" );
     767  readIntString (cfg_avgBitRate,             m_bitRatePicRateMaxTLayers, m_avgBitRate,             "avg. bit rate"               );
     768  readIntString (cfg_maxBitRate,             m_bitRatePicRateMaxTLayers, m_maxBitRate,             "max. bit rate"               );
     769  readBoolString(cfg_picRateInfoPresentFlag, m_bitRatePicRateMaxTLayers, m_picRateInfoPresentFlag, "bit rate info. present flag" );
     770  readIntString (cfg_avgPicRate,             m_bitRatePicRateMaxTLayers, m_avgPicRate,             "avg. pic rate"               );
     771  readIntString (cfg_constantPicRateIdc,     m_bitRatePicRateMaxTLayers, m_constantPicRateIdc,     "constant pic rate Idc"       );
     772#endif
    536773  m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
    537  
     774 
     775  /* rules for input, output and internal bitdepths as per help text */
     776  if (!m_internalBitDepthY) { m_internalBitDepthY = m_inputBitDepthY; }
     777  if (!m_internalBitDepthC) { m_internalBitDepthC = m_internalBitDepthY; }
     778  if (!m_inputBitDepthC) { m_inputBitDepthC = m_inputBitDepthY; }
     779  if (!m_outputBitDepthY) { m_outputBitDepthY = m_internalBitDepthY; }
     780  if (!m_outputBitDepthC) { m_outputBitDepthC = m_internalBitDepthC; }
     781
    538782#if !SVC_EXTENSION
    539783  // TODO:ChromaFmt assumes 4:2:0 below
    540   switch (m_croppingMode)
     784  switch (m_conformanceMode)
    541785  {
    542786  case 0:
    543787    {
    544       // no cropping or padding
    545       m_cropLeft = m_cropRight = m_cropTop = m_cropBottom = 0;
     788      // no conformance or padding
     789      m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
    546790      m_aiPad[1] = m_aiPad[0] = 0;
    547791      break;
     
    553797      if (m_iSourceWidth % minCuSize)
    554798      {
    555         m_aiPad[0] = m_cropRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
    556         m_iSourceWidth  += m_cropRight;
     799        m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
     800        m_iSourceWidth  += m_confRight;
    557801      }
    558802      if (m_iSourceHeight % minCuSize)
    559803      {
    560         m_aiPad[1] = m_cropBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    561         m_iSourceHeight += m_cropBottom;
    562       }
    563       if (m_aiPad[0] % TComSPS::getCropUnitX(CHROMA_420) != 0)
     804        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
     805        m_iSourceHeight += m_confBottom;
     806      }
     807      if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0)
    564808      {
    565809        fprintf(stderr, "Error: picture width is not an integer multiple of the specified chroma subsampling\n");
    566810        exit(EXIT_FAILURE);
    567811      }
    568       if (m_aiPad[1] % TComSPS::getCropUnitY(CHROMA_420) != 0)
     812      if (m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0)
    569813      {
    570814        fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n");
     
    578822      m_iSourceWidth  += m_aiPad[0];
    579823      m_iSourceHeight += m_aiPad[1];
    580       m_cropRight  = m_aiPad[0];
    581       m_cropBottom = m_aiPad[1];
     824      m_confRight  = m_aiPad[0];
     825      m_confBottom = m_aiPad[1];
    582826      break;
    583827    }
    584828  case 3:
    585829    {
    586       // cropping
    587       if ((m_cropLeft == 0) && (m_cropRight == 0) && (m_cropTop == 0) && (m_cropBottom == 0))
    588       {
    589         fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n");
     830      // conformance
     831      if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
     832      {
     833        fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n");
    590834      }
    591835      if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0))
    592836      {
    593         fprintf(stderr, "Warning: Cropping enabled, padding parameters will be ignored\n");
     837        fprintf(stderr, "Warning: Conformance window enabled, padding parameters will be ignored\n");
    594838      }
    595839      m_aiPad[1] = m_aiPad[0] = 0;
     
    599843 
    600844  // allocate slice-based dQP values
    601   m_aidQP = new Int[ m_iFrameToBeEncoded + m_iGOPSize + 1 ];
    602   ::memset( m_aidQP, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iGOPSize + 1 ) );
     845  m_aidQP = new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ];
     846  ::memset( m_aidQP, 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
    603847 
    604848  // handling of floating-point QP values
     
    607851  if ( m_iQP < m_fQP )
    608852  {
    609     Int iSwitchPOC = (Int)( m_iFrameToBeEncoded - (m_fQP - m_iQP)*m_iFrameToBeEncoded + 0.5 );
     853    Int iSwitchPOC = (Int)( m_framesToBeEncoded - (m_fQP - m_iQP)*m_framesToBeEncoded + 0.5 );
    610854   
    611855    iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
    612     for ( Int i=iSwitchPOC; i<m_iFrameToBeEncoded + m_iGOPSize + 1; i++ )
     856    for ( Int i=iSwitchPOC; i<m_framesToBeEncoded + m_iGOPSize + 1; i++ )
    613857    {
    614858      m_aidQP[i] = 1;
     
    624868      Int iValue;
    625869      Int iPOC = 0;
    626       while ( iPOC < m_iFrameToBeEncoded )
     870      while ( iPOC < m_framesToBeEncoded )
    627871      {
    628872        if ( fscanf(fpt, "%d", &iValue ) == EOF ) break;
     
    633877    }
    634878  }
    635   m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1; 
     879  m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
    636880#endif
    637881  // check validity of input parameters
     
    646890  return true;
    647891}
    648 
     892#if SIGNAL_BITRATE_PICRATE_IN_VPS
     893Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName)
     894{
     895  Char* inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
     896  Int i = 0;
     897  if(numEntries)
     898  {
     899    Char* tempArray = strtok(inpArray, " ,-");
     900    memberArray = new Bool[numEntries];
     901    while( tempArray != NULL )
     902    {
     903      if( i >= numEntries )
     904      {
     905        printf( "The number of %s defined is larger than the allowed number\n", elementName );
     906        exit( EXIT_FAILURE );
     907      }
     908      assert( (atoi(tempArray) == 0) || (atoi(tempArray) == 1) );
     909      *( memberArray + i ) = atoi(tempArray);
     910      tempArray = strtok(NULL, " ,-");
     911      i++;
     912    }
     913    if( i < numEntries )
     914    {
     915      printf( "Some %s are not defined\n", elementName );
     916      exit( EXIT_FAILURE );
     917    }
     918  }
     919  else
     920  {
     921    memberArray = NULL;
     922  }
     923}
     924
     925Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName)
     926{
     927  Char* inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
     928  Int i = 0;
     929  if(numEntries)
     930  {
     931    Char* tempArray = strtok(inpArray, " ,-");
     932    memberArray = new Int[numEntries];
     933    while( tempArray != NULL )
     934    {
     935      if( i >= numEntries )
     936      {
     937        printf( "The number of %s defined is larger than the allowed number\n", elementName );
     938        exit( EXIT_FAILURE );
     939      }
     940      *( memberArray + i ) = atoi(tempArray);
     941      tempArray = strtok(NULL, " ,-");
     942      i++;
     943    }
     944    if( i < numEntries )
     945    {
     946      printf( "Some %s are not defined\n", elementName );
     947      exit( EXIT_FAILURE );
     948    }
     949  }
     950  else
     951  {
     952    memberArray = NULL;
     953  }
     954}
     955#endif
    649956// ====================================================================================================================
    650957// Private member functions
    651958// ====================================================================================================================
    652959
    653 Bool confirmPara(Bool bflag, const char* message);
     960Bool confirmPara(Bool bflag, const Char* message);
    654961
    655962Void TAppEncCfg::xCheckParameter()
    656963{
    657   if (!m_decodePictureHashSEIEnabled)
    658   {
    659     fprintf(stderr, "*************************************************************\n");
    660     fprintf(stderr, "** WARNING: --SEIpictureDigest is now disabled by default. **\n");
    661     fprintf(stderr, "**          Automatic verification of decoded pictures by **\n");
    662     fprintf(stderr, "**          a decoder requires this option to be enabled.  **\n");
    663     fprintf(stderr, "*************************************************************\n");
    664   }
    665 
    666   bool check_failed = false; /* abort if there is a fatal configuration problem */
     964  if (!m_decodedPictureHashSEIEnabled)
     965  {
     966    fprintf(stderr, "******************************************************************\n");
     967    fprintf(stderr, "** WARNING: --SEIDecodedPictureHash is now disabled by default. **\n");
     968    fprintf(stderr, "**          Automatic verification of decoded pictures by a    **\n");
     969    fprintf(stderr, "**          decoder requires this option to be enabled.         **\n");
     970    fprintf(stderr, "******************************************************************\n");
     971  }
     972
     973  Bool check_failed = false; /* abort if there is a fatal configuration problem */
    667974#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
    668975  // check range of parameters
    669   xConfirmPara( m_uiInputBitDepth < 8,                                                      "InputBitDepth must be at least 8" );
    670 #if !SVC_EXTENSION
     976  xConfirmPara( m_inputBitDepthY < 8,                                                     "InputBitDepth must be at least 8" );
     977  xConfirmPara( m_inputBitDepthC < 8,                                                     "InputBitDepthC must be at least 8" );
     978#if !SVC_EXTENSION 
    671979  xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
    672980#endif
    673   xConfirmPara( m_iFrameToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
     981  xConfirmPara( m_framesToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
    674982  xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
    675983  xConfirmPara( m_iGOPSize > 1 &&  m_iGOPSize % 2,                                          "GOP Size must be a multiple of 2, if GOP Size is greater than 1" );
    676 #if !SVC_EXTENSION
     984#if !SVC_EXTENSION 
    677985  xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
    678986#endif
    679987  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
    680988#if !SVC_EXTENSION
    681   xConfirmPara( m_iQP <  -6 * ((Int)m_uiInternalBitDepth - 8) || m_iQP > 51,                "QP exceeds supported range (-QpBDOffsety to 51)" );
     989  xConfirmPara( m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,                    "QP exceeds supported range (-QpBDOffsety to 51)" );
    682990#endif
    683991  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,          "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
     
    7111019 
    7121020  xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
    713   xConfirmPara( m_uiQuadtreeTULog2MinSize > 5,                                        "QuadtreeTULog2MinSize must be 5 or smaller.");
    714   xConfirmPara( m_uiQuadtreeTULog2MaxSize < 2,                                        "QuadtreeTULog2MaxSize must be 2 or greater.");
    7151021  xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5,                                        "QuadtreeTULog2MaxSize must be 5 or smaller.");
     1022  xConfirmPara( (1<<m_uiQuadtreeTULog2MaxSize) > m_uiMaxCUWidth,                                        "QuadtreeTULog2MaxSize must be log2(maxCUSize) or smaller.");
     1023 
    7161024  xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize,                "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize.");
    7171025  xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS
     
    7201028  xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." );
    7211029  xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1,                                                         "QuadtreeTUMaxDepthInter must be greater than or equal to 1" );
    722   xConfirmPara( m_uiQuadtreeTUMaxDepthInter > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthInter must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" );
     1030  xConfirmPara( m_uiMaxCUWidth < ( 1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthInter - 1) ), "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1" );
    7231031  xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1,                                                         "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" );
    724   xConfirmPara( m_uiQuadtreeTUMaxDepthIntra > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthIntra must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" );
     1032  xConfirmPara( m_uiMaxCUWidth < ( 1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthIntra - 1) ), "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1" );
    7251033 
    7261034  xConfirmPara(  m_maxNumMergeCand < 1,  "MaxNumMergeCand must be 1 or greater.");
     
    7421050  }
    7431051
    744   xConfirmPara( m_iSliceMode < 0 || m_iSliceMode > 3, "SliceMode exceeds supported range (0 to 3)" );
    745   if (m_iSliceMode!=0)
    746   {
    747     xConfirmPara( m_iSliceArgument < 1 ,         "SliceArgument should be larger than or equal to 1" );
    748   }
    749 #if !REMOVE_FGS
    750   if (m_iSliceMode==3)
    751   {
    752     xConfirmPara( m_iSliceGranularity > 0 ,      "When SliceMode == 3 is chosen, the SliceGranularity must be 0" );
    753   }
    754 #endif
    755   xConfirmPara( m_iDependentSliceMode < 0 || m_iDependentSliceMode > 2, "DependentSliceMode exceeds supported range (0 to 2)" );
    756   if (m_iDependentSliceMode!=0)
    757   {
    758     xConfirmPara( m_iDependentSliceArgument < 1 ,         "DependentSliceArgument should be larger than or equal to 1" );
    759   }
    760 #if !REMOVE_FGS
    761   xConfirmPara( m_iSliceGranularity >= m_uiMaxCUDepth, "SliceGranularity must be smaller than maximum cu depth");
    762   xConfirmPara( m_iSliceGranularity <0 || m_iSliceGranularity > 3, "SliceGranularity exceeds supported range (0 to 3)" );
    763   xConfirmPara( m_iSliceGranularity > m_iMaxCuDQPDepth, "SliceGranularity must be smaller smaller than or equal to maximum dqp depth" );
    764 #endif
    765  
    766   bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
    767 #if !TILES_WPP_ENTROPYSLICES_FLAGS
    768   xConfirmPara( tileFlag && m_iDependentSliceMode,            "Tile and Dependent Slice can not be applied together");
    769 #endif
     1052  xConfirmPara( m_sliceMode < 0 || m_sliceMode > 3, "SliceMode exceeds supported range (0 to 3)" );
     1053  if (m_sliceMode!=0)
     1054  {
     1055    xConfirmPara( m_sliceArgument < 1 ,         "SliceArgument should be larger than or equal to 1" );
     1056  }
     1057  xConfirmPara( m_sliceSegmentMode < 0 || m_sliceSegmentMode > 3, "SliceSegmentMode exceeds supported range (0 to 3)" );
     1058  if (m_sliceSegmentMode!=0)
     1059  {
     1060    xConfirmPara( m_sliceSegmentArgument < 1 ,         "SliceSegmentArgument should be larger than or equal to 1" );
     1061  }
     1062 
     1063  Bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
    7701064  xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
    771 #if !DEPENDENT_SLICES
    772   xConfirmPara( m_iWaveFrontSynchro && m_iDependentSliceMode, "Wavefront and Dependent Slice can not be applied together");
    773 #endif
    774 #if DEPENDENT_SLICES
    775 #if TILES_WPP_ENTROPYSLICES_FLAGS
    776   xConfirmPara( m_iWaveFrontSynchro && m_entropySliceEnabledFlag, "WaveFrontSynchro and EntropySliceEnabledFlag can not be applied together");
    777 #else
    778   xConfirmPara( m_iWaveFrontSynchro && m_bCabacIndependentFlag, "Wavefront and CabacIndependentFlag can not be applied together");
    779 #endif
    780 #endif
    7811065
    7821066  //TODO:ChromaFmt assumes 4:2:0 below
    7831067#if !SVC_EXTENSION
    784   xConfirmPara( m_iSourceWidth  % TComSPS::getCropUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
    785   xConfirmPara( m_iSourceHeight % TComSPS::getCropUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
    786 #endif
    787 
    788 #if !SVC_EXTENSION
    789   xConfirmPara( m_aiPad[0] % TComSPS::getCropUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
    790   xConfirmPara( m_aiPad[1] % TComSPS::getCropUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
    791 
    792   xConfirmPara( m_cropLeft   % TComSPS::getCropUnitX(CHROMA_420) != 0, "Left cropping must be an integer multiple of the specified chroma subsampling");
    793   xConfirmPara( m_cropRight  % TComSPS::getCropUnitX(CHROMA_420) != 0, "Right cropping must be an integer multiple of the specified chroma subsampling");
    794   xConfirmPara( m_cropTop    % TComSPS::getCropUnitY(CHROMA_420) != 0, "Top cropping must be an integer multiple of the specified chroma subsampling");
    795   xConfirmPara( m_cropBottom % TComSPS::getCropUnitY(CHROMA_420) != 0, "Bottom cropping must be an integer multiple of the specified chroma subsampling");
    796 #endif
    797 
    798 #if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV
    799   xConfirmPara( REF_IDX_ME_AROUND_ZEROMV && REF_IDX_ME_ZEROMV, "REF_IDX_ME_AROUND_ZEROMV and REF_IDX_ME_ZEROMV cannot be enabled simultaneously");
    800 #endif
     1068  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
     1069  xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
     1070
     1071  xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
     1072  xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
     1073
     1074  xConfirmPara( m_confLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
     1075  xConfirmPara( m_confRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
     1076  xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
     1077  xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
     1078#endif
     1079
    8011080  // max CU width and height should be power of 2
    8021081  UInt ui = m_uiMaxCUWidth;
     
    8141093      xConfirmPara( ui != 1 , "Height should be 2^n");
    8151094  }
     1095
     1096
     1097  /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure
     1098   * This permits the ability to omit a GOP structure specification */
     1099#if SVC_EXTENSION
     1100  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
     1101  {
     1102    Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
     1103#endif
     1104  if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1) {
     1105    m_GOPList[0] = GOPEntry();
     1106    m_GOPList[0].m_QPFactor = 1;
     1107    m_GOPList[0].m_betaOffsetDiv2 = 0;
     1108    m_GOPList[0].m_tcOffsetDiv2 = 0;
     1109    m_GOPList[0].m_POC = 1;
     1110    m_GOPList[0].m_numRefPicsActive = 4;
     1111  }
     1112#if SVC_EXTENSION
     1113  }
     1114#endif
    8161115 
    8171116  Bool verifiedGOP=false;
     
    8381137    }
    8391138  }
    840  
    841   m_extraRPSs=0;
    8421139
    8431140#if SVC_EXTENSION
     
    8511148    }
    8521149  }
    853 #endif
    854 
     1150#endif 
     1151
     1152#if SVC_EXTENSION
     1153  // verify layer configuration parameters
     1154  for(UInt layer=0; layer<m_numLayers; layer++)
     1155  {
     1156    Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
     1157#endif
     1158  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) )
     1159  {
     1160    for(Int i=0; i<m_iGOPSize; i++)
     1161    {
     1162      xConfirmPara( (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) < -6 || (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) > 6, "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" );
     1163      xConfirmPara( (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) < -6 || (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) > 6, "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" );
     1164    }
     1165  }
     1166#if SVC_EXTENSION
     1167  }
     1168#endif
     1169
     1170  m_extraRPSs=0;
    8551171  //start looping through frames in coding order until we can verify that the GOP structure is correct.
    8561172  while(!verifiedGOP&&!errorGOP)
     
    8861202                if(absPOC%m_iGOPSize == m_GOPList[k].m_POC%m_iGOPSize)
    8871203                {
    888 #if TEMPORAL_LAYER_NON_REFERENCE
    8891204                  if(m_GOPList[k].m_temporalId==m_GOPList[curGOP].m_temporalId)
    8901205                  {
    8911206                    m_GOPList[k].m_refPic = true;
    8921207                  }
    893 #endif
    8941208                  m_GOPList[curGOP].m_usedByCurrPic[i]=m_GOPList[k].m_temporalId<=m_GOPList[curGOP].m_temporalId;
    8951209                }
     
    9391253          Int offGOP = (checkGOP-1+offset)%m_iGOPSize;
    9401254          Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + m_GOPList[offGOP].m_POC;
    941 #if TEMPORAL_LAYER_NON_REFERENCE
    9421255          if(offPOC>=0&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId)
    943 #else
    944           if(offPOC>=0&&m_GOPList[offGOP].m_refPic&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId)
    945 #endif
    9461256          {
    9471257            Bool newRef=false;
     
    9641274              Int insertPoint=newRefs;
    9651275              //this picture can be added, find appropriate place in list and insert it.
    966 #if TEMPORAL_LAYER_NON_REFERENCE
    9671276              if(m_GOPList[offGOP].m_temporalId==m_GOPList[curGOP].m_temporalId)
    9681277              {
    9691278                m_GOPList[offGOP].m_refPic = true;
    9701279              }
    971 #endif
    9721280              for(Int j=0; j<newRefs; j++)
    9731281              {
     
    10351343          m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = newIdc;
    10361344          m_GOPList[m_iGOPSize+m_extraRPSs].m_deltaRPS = refPOC - m_GOPList[m_iGOPSize+m_extraRPSs].m_POC;
    1037 #if !J0234_INTER_RPS_SIMPL
    1038           m_GOPList[m_iGOPSize+m_extraRPSs].m_deltaRIdxMinus1 = 0;
    1039 #endif
    10401345        }
    10411346        curGOP=m_iGOPSize+m_extraRPSs;
     
    11241429  }
    11251430
     1431#if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers
     1432  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
     1433  {
     1434    Int m_iSourceWidth = m_acLayerCfg[layer].m_iSourceWidth;
     1435    Int m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight;
     1436#endif
     1437  if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
     1438  {
     1439    Int PicSizeInSamplesY =  m_iSourceWidth * m_iSourceHeight;
     1440    if(tileFlag)
     1441    {
     1442      Int maxTileWidth = 0;
     1443      Int maxTileHeight = 0;
     1444      Int widthInCU = (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth/m_uiMaxCUWidth + 1: m_iSourceWidth/m_uiMaxCUWidth;
     1445      Int heightInCU = (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight/m_uiMaxCUHeight + 1: m_iSourceHeight/m_uiMaxCUHeight;
     1446      if(m_iUniformSpacingIdr)
     1447      {
     1448        maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_iNumColumnsMinus1)/(m_iNumColumnsMinus1+1));
     1449        maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_iNumRowsMinus1)/(m_iNumRowsMinus1+1));
     1450        // if only the last tile-row is one treeblock higher than the others
     1451        // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others
     1452        if(!((heightInCU-1)%(m_iNumRowsMinus1+1)))
     1453        {
     1454          maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight);
     1455        }     
     1456        // if only the last tile-column is one treeblock wider than the others
     1457        // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others   
     1458        if(!((widthInCU-1)%(m_iNumColumnsMinus1+1)))
     1459        {
     1460          maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth);
     1461        }
     1462      }
     1463      else // not uniform spacing
     1464      {
     1465        if(m_iNumColumnsMinus1<1)
     1466        {
     1467          maxTileWidth = m_iSourceWidth;
     1468        }
     1469        else
     1470        {
     1471          Int accColumnWidth = 0;
     1472          for(Int col=0; col<(m_iNumColumnsMinus1); col++)
     1473          {
     1474            maxTileWidth = m_pColumnWidth[col]>maxTileWidth ? m_pColumnWidth[col]:maxTileWidth;
     1475            accColumnWidth += m_pColumnWidth[col];
     1476          }
     1477          maxTileWidth = (widthInCU-accColumnWidth)>maxTileWidth ? m_uiMaxCUWidth*(widthInCU-accColumnWidth):m_uiMaxCUWidth*maxTileWidth;
     1478        }
     1479        if(m_iNumRowsMinus1<1)
     1480        {
     1481          maxTileHeight = m_iSourceHeight;
     1482        }
     1483        else
     1484        {
     1485          Int accRowHeight = 0;
     1486          for(Int row=0; row<(m_iNumRowsMinus1); row++)
     1487          {
     1488            maxTileHeight = m_pRowHeight[row]>maxTileHeight ? m_pRowHeight[row]:maxTileHeight;
     1489            accRowHeight += m_pRowHeight[row];
     1490          }
     1491          maxTileHeight = (heightInCU-accRowHeight)>maxTileHeight ? m_uiMaxCUHeight*(heightInCU-accRowHeight):m_uiMaxCUHeight*maxTileHeight;
     1492        }
     1493      }
     1494      Int maxSizeInSamplesY = maxTileWidth*maxTileHeight;
     1495      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/maxSizeInSamplesY-4;
     1496    }
     1497    else if(m_iWaveFrontSynchro)
     1498    {
     1499      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/((2*m_iSourceHeight+m_iSourceWidth)*m_uiMaxCUHeight)-4;
     1500    }
     1501    else if(m_sliceMode == 1)
     1502    {
     1503      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/(m_sliceArgument*m_uiMaxCUWidth*m_uiMaxCUHeight)-4;
     1504    }
     1505    else
     1506    {
     1507      m_minSpatialSegmentationIdc = 0;
     1508    }
     1509  }
     1510#if SVC_EXTENSION
     1511  }
     1512#endif
     1513
    11261514  xConfirmPara( m_bUseLComb==false && m_numReorderPics[MAX_TLAYER-1]!=0, "ListCombination can only be 0 in low delay coding (more precisely when L0 and L1 are identical)" );  // Note however this is not the full necessary condition as ref_pic_list_combination_flag can only be 0 if L0 == L1.
    11271515  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
     
    11311519#endif
    11321520
    1133   xConfirmPara( m_decodePictureHashSEIEnabled<0 || m_decodePictureHashSEIEnabled>3, "this hash type is not correct!\n");
    1134 
    1135 #if !SVC_EXTENSION
     1521  xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
     1522
     1523#if RATE_CONTROL_LAMBDA_DOMAIN
     1524  if ( m_RCEnableRateControl )
     1525  {
     1526    if ( m_RCForceIntraQP )
     1527    {
     1528      if ( m_RCInitialQP == 0 )
     1529      {
     1530        printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" );
     1531        m_RCForceIntraQP = false;
     1532      }
     1533    }
     1534    xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
     1535  }
     1536#else
    11361537  if(m_enableRateCtrl)
    11371538  {
     
    11501551
    11511552  xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
    1152 
    1153 #if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
    1154   xConfirmPara(m_activeParameterSetsSEIEnabled < 0 || m_activeParameterSetsSEIEnabled > 2, "ActiveParametersSEIEnabled exceeds supported range (0 to 2)");
    1155 #endif
    1156 
     1553#if L0444_FPA_TYPE
     1554  if (m_framePackingSEIEnabled)
     1555  {
     1556    xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5 , "SEIFramePackingType must be in rage 3 to 5");
     1557  }
     1558#endif
     1559#if VPS_EXTN_DIRECT_REF_LAYERS
     1560  xConfirmPara( (m_acLayerCfg[0].m_numDirectRefLayers != 0) && (m_acLayerCfg[0].m_numDirectRefLayers != -1), "Layer 0 cannot have any reference layers" );
     1561  // NOTE: m_numDirectRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
     1562  for(Int layer = 1; layer < MAX_LAYERS; layer++)
     1563  {
     1564    xConfirmPara(m_acLayerCfg[layer].m_numDirectRefLayers > layer, "Cannot reference more layers than before current layer");
     1565    for(Int i = 0; i < m_acLayerCfg[layer].m_numDirectRefLayers; i++)
     1566    {
     1567      xConfirmPara(m_acLayerCfg[layer].m_refLayerIds[i] > layer, "Cannot reference higher layers");
     1568      xConfirmPara(m_acLayerCfg[layer].m_refLayerIds[i] == layer, "Cannot reference the current layer itself");
     1569    }
     1570  }
     1571#endif
    11571572#undef xConfirmPara
    11581573  if (check_failed)
     
    11791594 
    11801595  // set internal bit-depth and constants
    1181 #if FULL_NBIT
    1182   g_uiBitDepth = m_uiInternalBitDepth;
    1183   g_uiBitIncrement = 0;
    1184 #else
    1185   g_uiBitDepth = 8;
    1186   g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth;
    1187 #endif
    1188 
    1189   g_uiBASE_MAX     = ((1<<(g_uiBitDepth))-1);
    1190  
    1191 #if IBDI_NOCLIP_RANGE
    1192   g_uiIBDI_MAX     = g_uiBASE_MAX << g_uiBitIncrement;
    1193 #else
    1194   g_uiIBDI_MAX     = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1);
    1195 #endif
    1196  
    1197   if (m_uiOutputBitDepth == 0)
    1198   {
    1199     m_uiOutputBitDepth = m_uiInternalBitDepth;
    1200   }
    1201 
    1202   g_uiPCMBitDepthLuma = m_uiPCMBitDepthLuma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth);
    1203   g_uiPCMBitDepthChroma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth);
     1596  g_bitDepthY = m_internalBitDepthY;
     1597  g_bitDepthC = m_internalBitDepthC;
     1598 
     1599  g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_inputBitDepthY : m_internalBitDepthY;
     1600  g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_inputBitDepthC : m_internalBitDepthC;
    12041601}
    12051602
     
    12161613  }
    12171614  printf("=== Common configuration settings === \n");
    1218   printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
     1615  printf("Bitstream      File          : %s\n", m_pBitstreamFile      );
    12191616#else
    12201617  printf("Input          File          : %s\n", m_pchInputFile          );
    12211618  printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
    12221619  printf("Reconstruction File          : %s\n", m_pchReconFile          );
    1223   printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_cropLeft - m_cropRight, m_iSourceHeight - m_cropTop - m_cropBottom, m_iFrameRate );
     1620  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
    12241621  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
    12251622#endif
    1226   printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_iFrameToBeEncoded-1, m_iFrameToBeEncoded );
     1623  printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
    12271624  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
    12281625  printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
     
    12451642  printf("QP adaptation                : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) );
    12461643  printf("GOP size                     : %d\n", m_iGOPSize );
    1247   printf("Internal bit depth           : %d\n", m_uiInternalBitDepth );
    1248   printf("PCM sample bit depth         : %d\n", m_uiPCMBitDepthLuma );
     1644  printf("Internal bit depth           : (Y:%d, C:%d)\n", m_internalBitDepthY, m_internalBitDepthC );
     1645  printf("PCM sample bit depth         : (Y:%d, C:%d)\n", g_uiPCMBitDepthLuma, g_uiPCMBitDepthChroma );
     1646#if RATE_CONTROL_LAMBDA_DOMAIN
     1647  printf("RateControl                  : %d\n", m_RCEnableRateControl );
     1648  if(m_RCEnableRateControl)
     1649  {
     1650    printf("TargetBitrate                : %d\n", m_RCTargetBitrate );
     1651    printf("KeepHierarchicalBit          : %d\n", m_RCKeepHierarchicalBit );
     1652    printf("LCULevelRC                   : %d\n", m_RCLCULevelRC );
     1653    printf("UseLCUSeparateModel          : %d\n", m_RCUseLCUSeparateModel );
     1654    printf("InitialQP                    : %d\n", m_RCInitialQP );
     1655    printf("ForceIntraQP                 : %d\n", m_RCForceIntraQP );
     1656  }
     1657#else
    12491658  printf("RateControl                  : %d\n", m_enableRateCtrl);
    12501659  if(m_enableRateCtrl)
     
    12531662    printf("NumLCUInUnit                 : %d\n", m_numLCUInUnit);
    12541663  }
     1664#endif
    12551665  printf("Max Num Merge Candidates     : %d\n", m_maxNumMergeCand);
    12561666  printf("\n");
    12571667 
    12581668  printf("TOOL CFG: ");
    1259 #if !REMOVE_ALF
    1260   printf("ALF:%d ", m_bUseALF             );
    1261   printf("ALFLowLatencyEncode:%d ", m_alfLowLatencyEncoding?1:0);
    1262 #endif
    1263   printf("IBD:%d ", !!g_uiBitIncrement);
     1669  printf("IBD:%d ", g_bitDepthY > m_inputBitDepthY || g_bitDepthC > m_inputBitDepthC);
    12641670  printf("HAD:%d ", m_bUseHADME           );
    12651671  printf("SRD:%d ", m_bUseSBACRD          );
    1266   printf("RDQ:%d ", m_bUseRDOQ            );
     1672  printf("RDQ:%d ", m_useRDOQ            );
     1673  printf("RDQTS:%d ", m_useRDOQTS        );
     1674#if L0232_RD_PENALTY
     1675  printf("RDpenalty:%d ", m_rdPenalty  );
     1676#endif
    12671677  printf("SQP:%d ", m_uiDeltaQpRD         );
    12681678  printf("ASR:%d ", m_bUseASR             );
     
    12741684  printf("ESD:%d ", m_useEarlySkipDetection  );
    12751685  printf("RQT:%d ", 1     );
    1276 #if !REMOVE_LMCHROMA
    1277   printf("LMC:%d ", m_bUseLMChroma        );
    1278 #endif
    12791686  printf("TransformSkip:%d ",     m_useTransformSkip              );
    12801687  printf("TransformSkipFast:%d ", m_useTransformSkipFast       );
    1281 #if REMOVE_FGS
    1282   printf("Slice: M=%d ", m_iSliceMode);
    1283 #else
    1284   printf("Slice: G=%d M=%d ", m_iSliceGranularity, m_iSliceMode);
    1285 #endif
    1286   if (m_iSliceMode!=0)
    1287   {
    1288     printf("A=%d ", m_iSliceArgument);
    1289   }
    1290   printf("DependentSlice: M=%d ",m_iDependentSliceMode);
    1291   if (m_iDependentSliceMode!=0)
    1292   {
    1293     printf("A=%d ", m_iDependentSliceArgument);
     1688  printf("Slice: M=%d ", m_sliceMode);
     1689  if (m_sliceMode!=0)
     1690  {
     1691    printf("A=%d ", m_sliceArgument);
     1692  }
     1693  printf("SliceSegment: M=%d ",m_sliceSegmentMode);
     1694  if (m_sliceSegmentMode!=0)
     1695  {
     1696    printf("A=%d ", m_sliceSegmentArgument);
    12941697  }
    12951698  printf("CIP:%d ", m_bUseConstrainedIntraPred);
     
    12991702
    13001703  printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 );
    1301   printf("WPP:%d ", (Int)m_bUseWeightPred);
     1704  printf("WPP:%d ", (Int)m_useWeightedPred);
    13021705  printf("WPB:%d ", (Int)m_useWeightedBiPred);
    13031706  printf("PME:%d ", m_log2ParallelMergeLevel);
     
    13141717  printf(" SignBitHidingFlag:%d ", m_signHideFlag);
    13151718#if SVC_EXTENSION
    1316 #if RECALCULATE_QP_ACCORDING_LAMBDA
    13171719  printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 );
    1318 #endif
    13191720  printf("AVC_BASE:%d ", AVC_BASE);
    13201721#if REF_IDX_FRAMEWORK
    13211722  printf("REF_IDX_FRAMEWORK:%d ", REF_IDX_FRAMEWORK);
    13221723  printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled);
    1323   printf("REF_IDX_ME_AROUND_ZEROMV:%d ", REF_IDX_ME_AROUND_ZEROMV);
    13241724  printf("REF_IDX_ME_ZEROMV: %d", REF_IDX_ME_ZEROMV);
    13251725#elif INTRA_BL
     
    13311731#endif
    13321732#else
    1333 #if RECALCULATE_QP_ACCORDING_LAMBDA
    13341733  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
    1335 #endif
    13361734#endif
    13371735  printf("\n\n");
     
    13401738}
    13411739
    1342 Bool confirmPara(Bool bflag, const char* message)
     1740Bool confirmPara(Bool bflag, const Char* message)
    13431741{
    13441742  if (!bflag)
  • trunk/source/App/TAppEncoder/TAppEncCfg.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 *
     
    6060#if SVC_EXTENSION
    6161  TAppEncLayerCfg m_acLayerCfg [MAX_LAYERS];
    62   Int       m_numLayers;                                     ///< number of layers
    63 
    64   char*     m_pchBitstreamFile;                               ///< output bitstream file
     62  Int       m_numLayers;                                      ///< number of layers
     63
     64  Char*     m_pBitstreamFile;                                 ///< output bitstream file
    6565  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
    6666  // source specification
    67   unsigned int m_FrameSkip;                                   ///< number of skipped frames from the beginning
    68   Int       m_iFrameToBeEncoded;                              ///< number of encoded frames
     67  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
     68  Int       m_framesToBeEncoded;                              ///< number of encoded frames
    6969#if AVC_SYNTAX
    7070  char*     m_BLSyntaxFile;                                   ///< input syntax file
    7171#endif
    7272#else
    73   char*     m_pchInputFile;                                   ///< source file name
    74   char*     m_pchBitstreamFile;                               ///< output bitstream file
    75   char*     m_pchReconFile;                                   ///< output reconstruction file
     73  Char*     m_pchInputFile;                                   ///< source file name
     74  Char*     m_pchBitstreamFile;                               ///< output bitstream file
     75  Char*     m_pchReconFile;                                   ///< output reconstruction file
    7676  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
    7777  // source specification
    7878  Int       m_iFrameRate;                                     ///< source frame-rates (Hz)
    79   unsigned int m_FrameSkip;                                   ///< number of skipped frames from the beginning
     79  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
    8080  Int       m_iSourceWidth;                                   ///< source width in pixel
    8181  Int       m_iSourceHeight;                                  ///< source height in pixel
    82   Int       m_croppingMode;
    83   Int       m_cropLeft;
    84   Int       m_cropRight;
    85   Int       m_cropTop;
    86   Int       m_cropBottom;
    87   Int       m_iFrameToBeEncoded;                              ///< number of encoded frames
     82  Int       m_conformanceMode;
     83  Int       m_confLeft;
     84  Int       m_confRight;
     85  Int       m_confTop;
     86  Int       m_confBottom;
     87  Int       m_framesToBeEncoded;                              ///< number of encoded frames
    8888  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
     89#endif 
     90
     91  // profile/level
     92  Profile::Name m_profile;
     93  Level::Tier   m_levelTier;
     94  Level::Name   m_level;
     95#if L0046_CONSTRAINT_FLAGS
     96  Bool m_progressiveSourceFlag;
     97  Bool m_interlacedSourceFlag;
     98  Bool m_nonPackedConstraintFlag;
     99  Bool m_frameOnlyConstraintFlag;
     100#endif
    89101 
    90102  // coding structure
     103#if !SVC_EXTENSION
    91104  Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
    92105#endif
     
    100113  Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
    101114  Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
    102 #if !REMOVE_NSQT
    103   Bool      m_enableNSQT;                                     ///< flag for enabling NSQT
    104 #endif
    105115  Bool      m_enableAMP;
    106116  // coding quality
     
    108118  Double    m_fQP;                                            ///< QP value of key-picture (floating point)
    109119  Int       m_iQP;                                            ///< QP value of key-picture (integer)
    110   char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
     120  Char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
    111121  Int*      m_aidQP;                                          ///< array of slice QP values
    112122#endif
     
    140150 
    141151  // coding tools (bit-depth)
    142   UInt      m_uiInputBitDepth;                                ///< bit-depth of input file
    143   UInt      m_uiOutputBitDepth;                               ///< bit-depth of output file
    144   UInt      m_uiInternalBitDepth;                             ///< Internal bit-depth (BitDepth+BitIncrement)
     152  Int       m_inputBitDepthY;                               ///< bit-depth of input file (luma component)
     153  Int       m_inputBitDepthC;                               ///< bit-depth of input file (chroma component)
     154  Int       m_outputBitDepthY;                              ///< bit-depth of output file (luma component)
     155  Int       m_outputBitDepthC;                              ///< bit-depth of output file (chroma component)
     156  Int       m_internalBitDepthY;                            ///< bit-depth codec operates at in luma (input/output files will be converted)
     157  Int       m_internalBitDepthC;                            ///< bit-depth codec operates at in chroma (input/output files will be converted)
    145158
    146159  // coding tools (PCM bit-depth)
    147160  Bool      m_bPCMInputBitDepthFlag;                          ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
    148   UInt      m_uiPCMBitDepthLuma;                              ///< PCM bit-depth for luma
    149161
    150162  // coding tool (lossless)
     
    152164  Bool      m_bUseSAO;
    153165  Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
    154 #if SAO_LCU_BOUNDARY
    155166  Bool      m_saoLcuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
    156 #endif
    157167  Bool      m_saoLcuBasedOptimization;                        ///< SAO LCU-based optimization
    158168  // coding tools (loop filter)
    159 #if !REMOVE_ALF
    160   Bool      m_bUseALF;                                        ///< flag for using adaptive loop filter
    161   Bool      m_alfLowLatencyEncoding;
    162 #endif
    163169  Bool      m_bLoopFilterDisable;                             ///< flag for using deblocking filter
    164170  Bool      m_loopFilterOffsetInPPS;                         ///< offset for deblocking filter in 0 = slice header, 1 = PPS
     
    167173  Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
    168174 
    169 #if !REMOVE_LMCHROMA
    170   Bool      m_bUseLMChroma;                                  ///< JL: Chroma intra prediction based on luma signal
    171 #endif
    172  
    173175  // coding tools (PCM)
    174176  Bool      m_usePCM;                                         ///< flag for using IPCM
     
    181183  Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
    182184  Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
    183   Bool      m_bUseRDOQ;                                       ///< flag for using RD optimized quantization
     185  Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
     186  Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
     187#if L0232_RD_PENALTY
     188  Int      m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty)
     189#endif
    184190  Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
    185191  Int       m_iSearchRange;                                   ///< ME search range
     
    190196  Bool      m_bUseCbfFastMode;                              ///< flag for using Cbf Fast PU Mode Decision
    191197  Bool      m_useEarlySkipDetection;                         ///< flag for using Early SKIP Detection
    192   Int       m_iSliceMode;           ///< 0: Disable all Recon slice limits, 1 : Maximum number of largest coding units per slice, 2: Maximum number of bytes in a slice
    193   Int       m_iSliceArgument;       ///< If m_iSliceMode==1, m_iSliceArgument=max. # of largest coding units. If m_iSliceMode==2, m_iSliceArgument=max. # of bytes.
    194   Int       m_iDependentSliceMode;    ///< 0: Disable all dependent slice limits, 1 : Maximum number of largest coding units per slice, 2: Constraint based dependent slice
    195   Int       m_iDependentSliceArgument;///< If m_iDependentSliceMode==1, m_iEDependentSliceArgument=max. # of largest coding units. If m_iDependnetSliceMode==2, m_iDependnetSliceArgument=max. # of bins.
    196 #if DEPENDENT_SLICES
    197 #if TILES_WPP_ENTROPYSLICES_FLAGS
    198   Bool      m_entropySliceEnabledFlag;
    199 #else
    200   Bool       m_bCabacIndependentFlag;  // 0: CABAC dependence between slices, 1:CABAC independence between slices
    201 #endif
    202 #endif
    203 
    204 #if !REMOVE_FGS
    205   Int       m_iSliceGranularity;///< 0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.
    206 #endif
    207   Bool      m_bLFCrossSliceBoundaryFlag;  ///< 0: Cross-slice-boundary in-loop filtering 1: non-cross-slice-boundary in-loop filtering
    208   Bool      m_bLFCrossTileBoundaryFlag;  //!< 1: Cross-tile-boundary in-loop filtering 0: non-cross-tile-boundary in-loop filtering
     198  Int       m_sliceMode;                                     ///< 0: no slice limits, 1 : max number of CTBs per slice, 2: max number of bytes per slice,
     199                                                             ///< 3: max number of tiles per slice
     200  Int       m_sliceArgument;                                 ///< argument according to selected slice mode
     201  Int       m_sliceSegmentMode;                              ///< 0: no slice segment limits, 1 : max number of CTBs per slice segment, 2: max number of bytes per slice segment,
     202                                                             ///< 3: max number of tiles per slice segment
     203  Int       m_sliceSegmentArgument;                          ///< argument according to selected slice segment mode
     204
     205  Bool      m_bLFCrossSliceBoundaryFlag;  ///< 1: filter across slice boundaries 0: do not filter across slice boundaries
     206  Bool      m_bLFCrossTileBoundaryFlag;   ///< 1: filter across tile boundaries  0: do not filter across tile boundaries
    209207  Int       m_iUniformSpacingIdr;
    210208  Int       m_iNumColumnsMinus1;
    211   char*     m_pchColumnWidth;
     209  Char*     m_pchColumnWidth;
    212210  Int       m_iNumRowsMinus1;
    213   char*     m_pchRowHeight;
     211  Char*     m_pchRowHeight;
     212  UInt*     m_pColumnWidth;
     213  UInt*     m_pRowHeight;
    214214  Int       m_iWaveFrontSynchro; //< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
    215215#if !SVC_EXTENSION
     
    219219  Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
    220220 
    221   Int       m_decodePictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
    222 #if RECOVERY_POINT_SEI
     221  Int       m_decodedPictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
    223222  Int       m_recoveryPointSEIEnabled;
    224 #endif
    225 #if BUFFERING_PERIOD_AND_TIMING_SEI
    226223  Int       m_bufferingPeriodSEIEnabled;
    227224  Int       m_pictureTimingSEIEnabled;
    228 #endif
     225  Int       m_framePackingSEIEnabled;
     226  Int       m_framePackingSEIType;
     227  Int       m_framePackingSEIId;
     228  Int       m_framePackingSEIQuincunx;
     229  Int       m_framePackingSEIInterpretation;
     230  Int       m_displayOrientationSEIAngle;
     231  Int       m_temporalLevel0IndexSEIEnabled;
     232  Int       m_gradualDecodingRefreshInfoEnabled;
     233  Int       m_decodingUnitInfoSEIEnabled;
    229234  // weighted prediction
    230   Bool      m_bUseWeightPred;                                 ///< Use of explicit Weighting Prediction for P_SLICE
    231   Bool      m_useWeightedBiPred;                                    ///< Use of Bi-Directional Weighting Prediction (B_SLICE)
     235  Bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
     236  Bool      m_useWeightedBiPred;                  ///< Use of bi-directional weighted prediction in B slices
    232237 
    233238  UInt      m_log2ParallelMergeLevel;                         ///< Parallel merge estimation region
     
    236241  Int       m_TMVPModeId;
    237242  Int       m_signHideFlag;
     243#if RATE_CONTROL_LAMBDA_DOMAIN
     244  Bool      m_RCEnableRateControl;                ///< enable rate control or not
     245  Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
     246  Bool      m_RCKeepHierarchicalBit;              ///< whether keeping hierarchical bit allocation structure or not
     247  Bool      m_RCLCULevelRC;                       ///< true: LCU level rate control; false: picture level rate control
     248  Bool      m_RCUseLCUSeparateModel;              ///< use separate R-lambda model at LCU level
     249  Int       m_RCInitialQP;                        ///< inital QP for rate control
     250  Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
     251#else
    238252  Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
    239253  Int       m_targetBitrate;                                 ///< target bitrate
    240254  Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
     255#endif
    241256  Int       m_useScalingListId;                               ///< using quantization matrix
    242   char*     m_scalingListFile;                                ///< quantization matrix file name
     257  Char*     m_scalingListFile;                                ///< quantization matrix file name
    243258
    244259  Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
    245260  Bool      m_CUTransquantBypassFlagValue;                    ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.
    246261
    247 #if RECALCULATE_QP_ACCORDING_LAMBDA
    248262  Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
    249 #endif
    250 #if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
     263  Bool      m_useStrongIntraSmoothing;                        ///< enable strong intra smoothing for 32x32 blocks where the reference samples are flat
    251264  Int       m_activeParameterSetsSEIEnabled;
    252 #endif
    253 
    254 #if SUPPORT_FOR_VUI
     265
    255266  Bool      m_vuiParametersPresentFlag;                       ///< enable generation of VUI parameters
    256267  Bool      m_aspectRatioInfoPresentFlag;                     ///< Signals whether aspect_ratio_idc is present
     
    259270  Int       m_sarHeight;                                      ///< vertical size of the sample aspect ratio
    260271  Bool      m_overscanInfoPresentFlag;                        ///< Signals whether overscan_appropriate_flag is present
    261   Bool      m_overscanAppropriateFlag;                        ///< Indicates whether cropped decoded pictures are suitable for display using overscan
     272  Bool      m_overscanAppropriateFlag;                        ///< Indicates whether conformant decoded pictures are suitable for display using overscan
    262273  Bool      m_videoSignalTypePresentFlag;                     ///< Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present
    263274  Int       m_videoFormat;                                    ///< Indicates representation of pictures
     
    271282  Int       m_chromaSampleLocTypeBottomField;                 ///< Specifies the location of chroma samples for bottom field
    272283  Bool      m_neutralChromaIndicationFlag;                    ///< Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)
     284  Bool      m_defaultDisplayWindowFlag;                       ///< Indicates the presence of the default window parameters
     285  Int       m_defDispWinLeftOffset;                           ///< Specifies the left offset from the conformance window of the default window
     286  Int       m_defDispWinRightOffset;                          ///< Specifies the right offset from the conformance window of the default window
     287  Int       m_defDispWinTopOffset;                            ///< Specifies the top offset from the conformance window of the default window
     288  Int       m_defDispWinBottomOffset;                         ///< Specifies the bottom offset from the conformance window of the default window
     289  Bool      m_frameFieldInfoPresentFlag;                      ///< Indicates that pic_struct values are present in picture timing SEI messages
     290  Bool      m_pocProportionalToTimingFlag;                    ///< Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS
     291  Int       m_numTicksPocDiffOneMinus1;                       ///< Number of ticks minus 1 that for a POC difference of one
    273292  Bool      m_bitstreamRestrictionFlag;                       ///< Signals whether bitstream restriction parameters are present
    274293  Bool      m_tilesFixedStructureFlag;                        ///< Indicates that each active picture parameter set has the same values of the syntax elements related to tiles
    275294  Bool      m_motionVectorsOverPicBoundariesFlag;             ///< Indicates that no samples outside the picture boundaries are used for inter prediction
     295  Int       m_minSpatialSegmentationIdc;                      ///< Indicates the maximum size of the spatial segments in the pictures in the coded video sequence
    276296  Int       m_maxBytesPerPicDenom;                            ///< Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture
    277297  Int       m_maxBitsPerMinCuDenom;                           ///< Indicates an upper bound for the number of bits of coding_unit() data
    278298  Int       m_log2MaxMvLengthHorizontal;                      ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units
    279299  Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
    280 #endif
     300
    281301#if REF_IDX_FRAMEWORK
    282302  Int       m_elRapSliceBEnabled;
     
    287307  Void  xPrintParameter ();                                   ///< print configuration values
    288308  Void  xPrintUsage     ();                                   ///< print usage
    289  
     309#if SIGNAL_BITRATE_PICRATE_IN_VPS
     310  Int       m_bitRatePicRateMaxTLayers;                       ///< Indicates max. number of sub-layers for which bit rate is signalled.
     311  Bool*     m_bitRateInfoPresentFlag;                         ///< Indicates whether bit rate information is signalled
     312  Bool*     m_picRateInfoPresentFlag;                         ///< Indicates whether pic rate information is signalled
     313  Int*      m_avgBitRate;                                     ///< Indicates avg. bit rate information for various sub-layers
     314  Int*      m_maxBitRate;                                     ///< Indicates max. bit rate information for various sub-layers
     315  Int*      m_avgPicRate;                                     ///< Indicates avg. picture rate information for various sub-layers
     316  Int*      m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
     317#endif
     318  #
    290319public:
    291320  TAppEncCfg();
     
    298327 
    299328#if SVC_EXTENSION
    300   Int  getNumFrameToBeEncoded()    {return m_iFrameToBeEncoded; }
     329  Int  getNumFrameToBeEncoded()    {return m_framesToBeEncoded; }
    301330  Int  getNumLayer()               {return m_numLayers;        }
    302331  Int  getGOPSize()                {return m_iGOPSize;          }
    303   UInt getInternalBitDepth()       {return m_uiInternalBitDepth; }
     332  UInt getInternalBitDepthY()      {return m_internalBitDepthY; }
     333  UInt getInternalBitDepthC()      {return m_internalBitDepthC; }
    304334  UInt getMaxCUWidth()             {return m_uiMaxCUWidth;      }
    305335  UInt getMaxCUHeight()            {return m_uiMaxCUHeight;     }
    306336  UInt getMaxCUDepth()             {return m_uiMaxCUDepth;      }
    307337  Int  getDecodingRefreshType()    {return m_iDecodingRefreshType; }
     338  Int  getWaveFrontSynchro()        { return m_iWaveFrontSynchro; }
    308339  Void getDirFilename(string& filename, string& dir, const string path);
    309   Int  getWaveFrontSynchro()        { return m_iWaveFrontSynchro; }
    310340#if AVC_SYNTAX
    311341  Char* getBLSyntaxFile()           { return m_BLSyntaxFile;      }
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp

    r55 r125  
    11/** \file     TAppEncLayerCfg.cpp
    2     \brief    Handle encoder configuration parameters
     2\brief    Handle encoder configuration parameters
    33*/
    44
     
    2828#if SVC_EXTENSION
    2929TAppEncLayerCfg::TAppEncLayerCfg()
    30 :m_cInputFile(string("")),
    31  m_cReconFile(string("")),
    32  m_croppingMode( 0 ),
    33  m_aidQP(NULL)
    34 {
    35   m_cropLeft = m_cropRight = m_cropTop = m_cropBottom = 0;
     30  :m_cInputFile(string("")),
     31  m_cReconFile(string("")),
     32  m_conformanceMode( 0 ),
     33  m_aidQP(NULL)
     34{
     35  m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
    3636  m_aiPad[1] = m_aiPad[0] = 0;
    3737}
     
    5959
    6060/** \param  argc        number of arguments
    61     \param  argv        array of arguments
    62     \retval             true when success
    63  */
     61\param  argv        array of arguments
     62\retval             true when success
     63*/
    6464bool TAppEncLayerCfg::parseCfg( const string& cfgFileName  )
    6565{
     
    6969  po::Options opts;
    7070  opts.addOptions()
    71   ("InputFile,i",           cfg_InputFile,  string(""), "original YUV input file name")
     71    ("InputFile,i",           cfg_InputFile,  string(""), "original YUV input file name")
    7272#if AVC_BASE
    73   ("InputBLFile,-ibl",      cfg_InputFile,  string(""), "original YUV input file name")
    74 #endif
    75   ("ReconFile,o",           cfg_ReconFile,  string(""), "reconstructed YUV output file name")
    76   ("SourceWidth,-wdt",      m_iSourceWidth,  0, "Source picture width")
    77   ("SourceHeight,-hgt",     m_iSourceHeight, 0, "Source picture height")
    78   ("CroppingMode",          m_croppingMode,  0, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
    79   ("CropLeft",              m_cropLeft,      0, "Left cropping/padding for cropping mode 3")
    80   ("CropRight",             m_cropRight,     0, "Right cropping/padding for cropping mode 3")
    81   ("CropTop",               m_cropTop,       0, "Top cropping/padding for cropping mode 3")
    82   ("CropBottom",            m_cropBottom,    0, "Bottom cropping/padding for cropping mode 3")
    83   ("HorizontalPadding,-pdx",m_aiPad[0],      0, "horizontal source padding for cropping mode 2")
    84   ("VerticalPadding,-pdy",  m_aiPad[1],      0, "vertical source padding for cropping mode 2")
    85   ("IntraPeriod,-ip",       m_iIntraPeriod,  -1, "intra period in frames, (-1: only first frame)")
    86   ("FrameRate,-fr",         m_iFrameRate,    0, "Frame rate")
    87   ("dQPFile,m",             cfg_dQPFile, string(""), "dQP file name")
    88   ("QP,q",                  m_fQP,          30.0, "Qp value, if value is float, QP is switched once during encoding")
    89   ;
    90  
     73    ("InputBLFile,-ibl",      cfg_InputFile,  string(""), "original YUV input file name")
     74#endif
     75    ("ReconFile,o",           cfg_ReconFile,  string(""), "reconstructed YUV output file name")
     76    ("SourceWidth,-wdt",      m_iSourceWidth,  0, "Source picture width")
     77    ("SourceHeight,-hgt",     m_iSourceHeight, 0, "Source picture height")
     78    ("CroppingMode",          m_conformanceMode,  0, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
     79    ("CropLeft",              m_confLeft,      0, "Left cropping/padding for cropping mode 3")
     80    ("CropRight",             m_confRight,     0, "Right cropping/padding for cropping mode 3")
     81    ("CropTop",               m_confTop,       0, "Top cropping/padding for cropping mode 3")
     82    ("CropBottom",            m_confBottom,    0, "Bottom cropping/padding for cropping mode 3")
     83    ("HorizontalPadding,-pdx",m_aiPad[0],      0, "horizontal source padding for cropping mode 2")
     84    ("VerticalPadding,-pdy",  m_aiPad[1],      0, "vertical source padding for cropping mode 2")
     85    ("IntraPeriod,-ip",       m_iIntraPeriod,  -1, "intra period in frames, (-1: only first frame)")
     86    ("FrameRate,-fr",         m_iFrameRate,    0, "Frame rate")
     87    ("dQPFile,m",             cfg_dQPFile, string(""), "dQP file name")
     88    ("QP,q",                  m_fQP,          30.0, "Qp value, if value is float, QP is switched once during encoding")
     89    ;
     90
    9191  po::setDefaults(opts);
    9292  po::parseConfigFile(opts, cfgFileName);
     
    123123  printf("Base layer input file         : %s\n", m_cAppEncCfg->getBLSyntaxFile() );
    124124#endif
    125   printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - m_cropLeft - m_cropRight, m_iSourceHeight - m_cropTop - m_cropBottom, m_iFrameRate );
     125  printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
    126126  printf("Internal Format               : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
    127127  printf("QP                            : %5.2f\n", m_fQP );
    128128  printf("Intra period                  : %d\n", m_iIntraPeriod );
    129 #if SVC_EXTENSION
    130   printf("WaveFrontSynchro:%d WaveFrontSubstreams:%d",
    131           m_cAppEncCfg->getWaveFrontSynchro(), m_iWaveFrontSubstreams);
    132 #endif
     129  printf("WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_cAppEncCfg->getWaveFrontSynchro(), m_iWaveFrontSubstreams);
    133130}
    134131
     
    137134Bool TAppEncLayerCfg::xCheckParameter()
    138135{
    139   switch (m_croppingMode)
     136  switch (m_conformanceMode)
    140137  {
    141138  case 0:
    142139    {
    143140      // no cropping or padding
    144       m_cropLeft = m_cropRight = m_cropTop = m_cropBottom = 0;
     141      m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
    145142      m_aiPad[1] = m_aiPad[0] = 0;
    146143      break;
     
    152149      if (m_iSourceWidth % minCuSize)
    153150      {
    154         m_aiPad[0] = m_cropRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
    155         m_iSourceWidth  += m_cropRight;
     151        m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
     152        m_iSourceWidth  += m_confRight;
    156153      }
    157154      if (m_iSourceHeight % minCuSize)
    158155      {
    159         m_aiPad[1] = m_cropBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    160         m_iSourceHeight += m_cropBottom;
     156        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
     157        m_iSourceHeight += m_confBottom;
    161158      }
    162159      break;
     
    167164      m_iSourceWidth  += m_aiPad[0];
    168165      m_iSourceHeight += m_aiPad[1];
    169       m_cropRight  = m_aiPad[0];
    170       m_cropBottom = m_aiPad[1];
     166      m_confRight  = m_aiPad[0];
     167      m_confBottom = m_aiPad[1];
    171168      break;
    172169    }
    173170  case 3:
    174171    {
    175       // cropping
    176       if ((m_cropLeft == 0) && (m_cropRight == 0) && (m_cropTop == 0) && (m_cropBottom == 0))
     172      // conformance
     173      if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
    177174      {
    178175        fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n");
     
    200197  {
    201198    Int iSwitchPOC = (Int)( iFrameToBeEncoded - (m_fQP - m_iQP)*iFrameToBeEncoded + 0.5 );
    202    
     199
    203200
    204201    iSwitchPOC = (Int)( (Double)iSwitchPOC / iGOPSize + 0.5 )*iGOPSize;
     
    224221  }
    225222
    226   xConfirmPara( m_iQP <  -6 * ((Int)m_cAppEncCfg->getInternalBitDepth() - 8) || m_iQP > 51,                "QP exceeds supported range (-QpBDOffsety to 51)" );
    227 
    228  
    229 #if SVC_EXTENSION
     223  xConfirmPara( m_iQP <  -6 * ((Int)m_cAppEncCfg->getInternalBitDepthY() - 8) || m_iQP > 51,                "QP exceeds supported range (-QpBDOffsety to 51)" );
     224
     225
    230226  m_iWaveFrontSubstreams = m_cAppEncCfg->getWaveFrontSynchro() ? (m_iSourceHeight + m_cAppEncCfg->getMaxCUHeight() - 1) / m_cAppEncCfg->getMaxCUHeight() : 1;
    231227  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
    232228  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_cAppEncCfg->getWaveFrontSynchro(), "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
    233 #endif
    234 
     229
     230  //chekc parameters
     231  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
     232  xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
     233
     234  xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
     235  xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
     236
     237  xConfirmPara( m_confLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
     238  xConfirmPara( m_confRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
     239  xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
     240  xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
    235241#undef xConfirmPara
    236242  return check_failed;
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.h

    r2 r125  
    3434  Int       m_iSourceWidth;                                   ///< source width in pixel
    3535  Int       m_iSourceHeight;                                  ///< source height in pixel
    36   Int       m_croppingMode;
    37   Int       m_cropLeft;
    38   Int       m_cropRight;
    39   Int       m_cropTop;
    40   Int       m_cropBottom;
     36  Int       m_conformanceMode;
     37  Int       m_confLeft;
     38  Int       m_confRight;
     39  Int       m_confTop;
     40  Int       m_confBottom;
    4141  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
    4242  Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
    4343  Double    m_fQP;                                            ///< QP value of key-picture (floating point)
    44 
     44#if VPS_EXTN_DIRECT_REF_LAYERS
     45  Int       *m_refLayerIds;
     46  Int       m_numDirectRefLayers;
     47#endif
    4548#if SVC_EXTENSION
    4649  Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
     
    6467
    6568  Void    setAppEncCfg(TAppEncCfg* p) {m_cAppEncCfg = p;          }
     69
    6670  string  getInputFile()              {return m_cInputFile;       }
    6771  string  getReconFile()              {return m_cReconFile;       }
     
    6973  Int     getSourceWidth()            {return m_iSourceWidth;     }
    7074  Int     getSourceHeight()           {return m_iSourceHeight;    }
    71   Int     getCroppingMode()           {return m_croppingMode;     }
    72   Int     getCropLeft()               {return m_cropLeft;         }
    73   Int     getCropRight()              {return m_cropRight;        }
    74   Int     getCropTop()                {return m_cropTop;          }
    75   Int     getCropBottom()             {return m_cropBottom;       }
     75  Int     getConformanceMode()        { return m_conformanceMode; }
    7676  Int*    getPad()                    {return m_aiPad;            }
    7777  Double  getFloatQP()                {return m_fQP;              }
     78  Int     getConfLeft()               {return m_confLeft;         }
     79  Int     getConfRight()              {return m_confRight;        }
     80  Int     getConfTop()                {return m_confTop;          }
     81  Int     getConfBottom()             {return m_confBottom;       }
    7882
    7983  Int     getIntQP()                  {return m_iQP;              }
    8084  Int*    getdQPs()                   {return m_aidQP;            }
    81 
     85#if VPS_EXTN_DIRECT_REF_LAYERS
     86  Int     getNumDirectRefLayers()     {return m_numDirectRefLayers;}
     87  Int*    getRefLayerIds()            {return m_refLayerIds;      }
     88  Int     getRefLayerId(Int i)        {return m_refLayerIds[i];   }
     89#endif
    8290}; // END CLASS DEFINITION TAppEncLayerCfg
    8391
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r55 r125  
    11/* The copyright in this software is being made available under the BSD
    2  * License, included below. This software may be subject to other third party
    3  * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
    5  *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
    7  * All rights reserved.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
    10  * modification, are permitted provided that the following conditions are met:
    11  *
    12  *  * Redistributions of source code must retain the above copyright notice,
    13  *    this list of conditions and the following disclaimer.
    14  *  * Redistributions in binary form must reproduce the above copyright notice,
    15  *    this list of conditions and the following disclaimer in the documentation
    16  *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    18  *    be used to endorse or promote products derived from this software without
    19  *    specific prior written permission.
    20  *
    21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
    25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
    31  * THE POSSIBILITY OF SUCH DAMAGE.
    32  */
     2* License, included below. This software may be subject to other third party
     3* and contributor rights, including patent rights, and no such rights are
     4* granted under this license. 
     5*
     6* Copyright (c) 2010-2013, ITU/ISO/IEC
     7* All rights reserved.
     8*
     9* Redistribution and use in source and binary forms, with or without
     10* modification, are permitted provided that the following conditions are met:
     11*
     12*  * Redistributions of source code must retain the above copyright notice,
     13*    this list of conditions and the following disclaimer.
     14*  * Redistributions in binary form must reproduce the above copyright notice,
     15*    this list of conditions and the following disclaimer in the documentation
     16*    and/or other materials provided with the distribution.
     17*  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
     18*    be used to endorse or promote products derived from this software without
     19*    specific prior written permission.
     20*
     21* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     22* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
     25* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31* THE POSSIBILITY OF SUCH DAMAGE.
     32*/
    3333
    3434/** \file     TAppEncTop.cpp
    35     \brief    Encoder application class
     35\brief    Encoder application class
    3636*/
    3737
     
    7575Void TAppEncTop::xInitLibCfg()
    7676{
     77  TComVPS* vps = m_acTEncTop[0].getVPS();
     78
     79  vps->setMaxTLayers                       ( m_maxTempLayer );
     80  if (m_maxTempLayer == 1)
     81  {
     82    vps->setTemporalNestingFlag(true);
     83  }
     84#if !VPS_RENAME
     85  vps.setMaxLayers                        ( 1 );
     86#endif
     87  for(Int i = 0; i < MAX_TLAYER; i++)
     88  {
     89    vps->setNumReorderPics                 ( m_numReorderPics[i], i );
     90    vps->setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
     91  }
     92
    7793  for(UInt layer=0; layer<m_numLayers; layer++)
    7894  {
    79     TComVPS vps;
    80 
    81     vps.setMaxTLayers                       ( m_maxTempLayer );
    82     vps.setMaxLayers                        ( 1 );
    83     for(Int i = 0; i < MAX_TLAYER; i++)
    84     {
    85       vps.setNumReorderPics                 ( m_numReorderPics[i], i );
    86       vps.setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
    87     }
    88     m_acTEncTop[layer].setVPS(&vps);
     95    //m_acTEncTop[layer].setVPS(&vps);
    8996    m_acTEncTop[layer].setFrameRate                    ( m_acLayerCfg[layer].getFrameRate() );
    9097    m_acTEncTop[layer].setFrameSkip                    ( m_FrameSkip );
    9198    m_acTEncTop[layer].setSourceWidth                  ( m_acLayerCfg[layer].getSourceWidth() );
    9299    m_acTEncTop[layer].setSourceHeight                 ( m_acLayerCfg[layer].getSourceHeight() );
    93     m_acTEncTop[layer].setCroppingMode                 ( m_acLayerCfg[layer].getCroppingMode() );
    94     m_acTEncTop[layer].setCropLeft                     ( m_acLayerCfg[layer].getCropLeft() );
    95     m_acTEncTop[layer].setCropRight                    ( m_acLayerCfg[layer].getCropRight() );
    96     m_acTEncTop[layer].setCropTop                      ( m_acLayerCfg[layer].getCropTop() );
    97     m_acTEncTop[layer].setCropBottom                   ( m_acLayerCfg[layer].getCropBottom() );
    98     m_acTEncTop[layer].setFrameToBeEncoded             ( m_iFrameToBeEncoded );
     100    m_acTEncTop[layer].setConformanceMode              ( m_acLayerCfg[layer].getConformanceMode() );
     101    m_acTEncTop[layer].setConformanceWindow            ( m_acLayerCfg[layer].m_confLeft, m_acLayerCfg[layer].m_confRight, m_acLayerCfg[layer].m_confTop, m_acLayerCfg[layer].m_confBottom );
     102    m_acTEncTop[layer].setFramesToBeEncoded            ( m_framesToBeEncoded );
     103
     104    m_acTEncTop[layer].setProfile(m_profile);
     105    m_acTEncTop[layer].setLevel(m_levelTier, m_level);
     106#if L0046_CONSTRAINT_FLAGS
     107    m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlag);
     108    m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlag);
     109    m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
     110    m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
     111#endif
    99112
    100113#if REF_IDX_MFM
    101     if(layer == 0)
    102     {
    103       m_acTEncTop[layer].setMFMEnabledFlag(false);
    104     }
    105     else
    106     {
    107       m_acTEncTop[layer].setMFMEnabledFlag(true);
    108     }
     114    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : true);
    109115#endif
    110116    // set layer ID
     
    112118    m_acTEncTop[layer].setNumLayer ( m_numLayers );
    113119    m_acTEncTop[layer].setLayerEnc(m_apcTEncTop);
    114 
    115120
    116121    //====== Coding Structure ========
     
    134139
    135140    m_acTEncTop[layer].setMaxTempLayer                 ( m_maxTempLayer );
    136 #if !REMOVE_NSQT
    137     m_acTEncTop[layer].setUseNSQT( m_enableNSQT );
    138 #endif
    139141    m_acTEncTop[layer].setUseAMP( m_enableAMP );
    140 
     142#if VPS_EXTN_DIRECT_REF_LAYERS
     143    if(layer)
     144    {
     145      if(m_acLayerCfg[layer].getNumDirectRefLayers() == -1)
     146      {
     147        // Not included in the configuration file; assume that each layer depends on previous layer
     148        m_acTEncTop[layer].setNumDirectRefLayers       (1);      // One ref. layer
     149        m_acTEncTop[layer].setRefLayerId               (0, layer - 1);   // Previous layer
     150      }
     151      else
     152      {
     153        m_acTEncTop[layer].setNumDirectRefLayers       ( m_acLayerCfg[layer].getNumDirectRefLayers() );     
     154        for(Int i = 0; i < m_acTEncTop[layer].getNumDirectRefLayers(); i++)
     155        {
     156          m_acTEncTop[layer].setRefLayerId             ( i, m_acLayerCfg[layer].getRefLayerId(i));
     157        }       
     158      }
     159    }
     160#endif
    141161    //===== Slice ========
    142162
     
    157177    m_acTEncTop[layer].setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
    158178
    159     m_acTEncTop[layer].setChromaCbQpOffset               ( m_cbQpOffset     );
    160     m_acTEncTop[layer].setChromaCrQpOffset            ( m_crQpOffset  );
     179    m_acTEncTop[layer].setChromaCbQpOffset             ( m_cbQpOffset     );
     180    m_acTEncTop[layer].setChromaCrQpOffset             ( m_crQpOffset  );
    161181
    162182#if ADAPTIVE_QP_SELECTION
     
    165185
    166186    Int lowestQP;
    167     lowestQP =  - ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
     187    lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
    168188
    169189    if ((m_iMaxDeltaQP == 0 ) && (m_acLayerCfg[layer].getIntQP() == lowestQP) && (m_useLossless == true))
     
    179199    m_acTEncTop[layer].setUseASR                       ( m_bUseASR      );
    180200    m_acTEncTop[layer].setUseHADME                     ( m_bUseHADME    );
    181 #if !REMOVE_ALF
    182     m_acTEncTop[layer].setUseALF                       ( m_bUseALF      );
    183 #endif
    184201    m_acTEncTop[layer].setUseLossless                  ( m_useLossless );
    185202    m_acTEncTop[layer].setUseLComb                     ( m_bUseLComb    );
    186     m_acTEncTop[layer].setdQPs                         ( m_acLayerCfg[layer].getdQPs()        );
    187     m_acTEncTop[layer].setUseRDOQ                      ( m_bUseRDOQ     );
     203    m_acTEncTop[layer].setdQPs                         ( m_acLayerCfg[layer].getdQPs() );
     204    m_acTEncTop[layer].setUseRDOQ                      ( m_useRDOQ     );
     205    m_acTEncTop[layer].setUseRDOQTS                    ( m_useRDOQTS   );
     206#if L0232_RD_PENALTY
     207    m_acTEncTop[layer].setRDpenalty                    ( m_rdPenalty );
     208#endif
    188209    m_acTEncTop[layer].setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
    189210    m_acTEncTop[layer].setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
     
    193214    m_acTEncTop[layer].setUseEarlyCU                   ( m_bUseEarlyCU  );
    194215    m_acTEncTop[layer].setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
    195     m_acTEncTop[layer].setUseCbfFastMode            ( m_bUseCbfFastMode  );
    196     m_acTEncTop[layer].setUseEarlySkipDetection            ( m_useEarlySkipDetection );
    197 
    198 #if !REMOVE_LMCHROMA
    199     m_acTEncTop[layer].setUseLMChroma                  ( m_bUseLMChroma );
    200 #endif
     216    m_acTEncTop[layer].setUseCbfFastMode               ( m_bUseCbfFastMode  );
     217    m_acTEncTop[layer].setUseEarlySkipDetection        ( m_useEarlySkipDetection );
     218
    201219    m_acTEncTop[layer].setUseTransformSkip             ( m_useTransformSkip      );
    202220    m_acTEncTop[layer].setUseTransformSkipFast         ( m_useTransformSkipFast  );
    203221    m_acTEncTop[layer].setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
    204     m_acTEncTop[layer].setPCMLog2MinSize          ( m_uiPCMLog2MinSize);
     222    m_acTEncTop[layer].setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
    205223    m_acTEncTop[layer].setUsePCM                       ( m_usePCM );
    206224    m_acTEncTop[layer].setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
     
    209227
    210228    //====== Weighted Prediction ========
    211     m_acTEncTop[layer].setUseWP                   ( m_bUseWeightPred      );
     229    m_acTEncTop[layer].setUseWP                   ( m_useWeightedPred      );
    212230    m_acTEncTop[layer].setWPBiPred                ( m_useWeightedBiPred   );
    213231    //====== Parallel Merge Estimation ========
     
    215233
    216234    //====== Slice ========
    217     m_acTEncTop[layer].setSliceMode               ( m_iSliceMode                );
    218     m_acTEncTop[layer].setSliceArgument           ( m_iSliceArgument            );
     235    m_acTEncTop[layer].setSliceMode               ( m_sliceMode                );
     236    m_acTEncTop[layer].setSliceArgument           ( m_sliceArgument            );
    219237
    220238    //====== Dependent Slice ========
    221     m_acTEncTop[layer].setDependentSliceMode        ( m_iDependentSliceMode         );
    222     m_acTEncTop[layer].setDependentSliceArgument    ( m_iDependentSliceArgument     );
    223 #if DEPENDENT_SLICES
    224 #if TILES_WPP_ENTROPYSLICES_FLAGS
    225     m_acTEncTop[layer].setEntropySliceEnabledFlag   ( m_entropySliceEnabledFlag );
    226 #else
    227     m_acTEncTop[layer].setCabacIndependentFlag      ( m_bCabacIndependentFlag   );
    228 #endif
    229 #endif
    230     int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
    231     if(m_iDependentSliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_DEPENDENT_SLICE)
    232     {
    233 #if REMOVE_FGS
    234       m_acTEncTop[layer].setDependentSliceArgument ( m_iDependentSliceArgument * iNumPartInCU );
    235 #else
    236       m_acTEncTop[layer].setDependentSliceArgument ( m_iDependentSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
    237 #endif
    238     }
    239     if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
    240     {
    241 #if REMOVE_FGS
    242       m_acTEncTop[layer].setSliceArgument ( m_iSliceArgument * iNumPartInCU );
    243 #else
    244       m_acTEncTop[layer].setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
    245 #endif
    246     }
    247     if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
    248     {
    249       m_acTEncTop[layer].setSliceArgument ( m_iSliceArgument );
    250     }
    251 
    252 #if !REMOVE_FGS
    253     m_acTEncTop[layer].setSliceGranularity        ( m_iSliceGranularity         );
    254 #endif
    255     if(m_iSliceMode == 0 )
     239    m_acTEncTop[layer].setSliceSegmentMode        ( m_sliceSegmentMode         );
     240    m_acTEncTop[layer].setSliceSegmentArgument    ( m_sliceSegmentArgument     );
     241    Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
     242    if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
     243    {
     244      m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU );
     245    }
     246    if(m_sliceMode==FIXED_NUMBER_OF_LCU)
     247    {
     248      m_acTEncTop[layer].setSliceArgument ( m_sliceArgument * iNumPartInCU );
     249    }
     250    if(m_sliceMode==FIXED_NUMBER_OF_TILES)
     251    {
     252      m_acTEncTop[layer].setSliceArgument ( m_sliceArgument );
     253    }
     254
     255    if(m_sliceMode == 0 )
    256256    {
    257257      m_bLFCrossSliceBoundaryFlag = true;
     
    261261    m_acTEncTop[layer].setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
    262262
    263 #if SAO_LCU_BOUNDARY
    264263    m_acTEncTop[layer].setSaoLcuBoundary (m_saoLcuBoundary);
    265 #endif
    266264    m_acTEncTop[layer].setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
    267265    m_acTEncTop[layer].setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
    268266    m_acTEncTop[layer].setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
    269267
    270     m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodePictureHashSEIEnabled);
    271 #if RECOVERY_POINT_SEI
     268    m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
    272269    m_acTEncTop[layer].setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
    273 #endif
    274 #if BUFFERING_PERIOD_AND_TIMING_SEI
    275270    m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
    276271    m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
    277 #endif
     272    m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
     273    m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType );
     274    m_acTEncTop[layer].setFramePackingArrangementSEIId( m_framePackingSEIId );
     275    m_acTEncTop[layer].setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx );
     276    m_acTEncTop[layer].setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation );
     277    m_acTEncTop[layer].setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle );
     278    m_acTEncTop[layer].setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled );
     279    m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
     280    m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
    278281    m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    279282    m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     
    281284    if(m_iUniformSpacingIdr==0)
    282285    {
    283       m_acTEncTop[layer].setColumnWidth              ( m_pchColumnWidth );
    284       m_acTEncTop[layer].setRowHeight                ( m_pchRowHeight );
     286      m_acTEncTop[layer].setColumnWidth              ( m_pColumnWidth );
     287      m_acTEncTop[layer].setRowHeight                ( m_pRowHeight );
    285288    }
    286289    m_acTEncTop[layer].xCheckGSParameters();
     
    297300    m_acTEncTop[layer].setScalingListFile            ( m_scalingListFile   );
    298301    m_acTEncTop[layer].setSignHideFlag(m_signHideFlag);
    299 #if !REMOVE_ALF
    300     m_acTEncTop[layer].setALFLowLatencyEncoding( m_alfLowLatencyEncoding );
    301 #endif
     302#if RATE_CONTROL_LAMBDA_DOMAIN
     303    m_acTEncTop[layer].setUseRateCtrl         ( m_RCEnableRateControl );
     304    m_acTEncTop[layer].setTargetBitrate       ( m_RCTargetBitrate );
     305    m_acTEncTop[layer].setKeepHierBit         ( m_RCKeepHierarchicalBit );
     306    m_acTEncTop[layer].setLCULevelRC          ( m_RCLCULevelRC );
     307    m_acTEncTop[layer].setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
     308    m_acTEncTop[layer].setInitialQP           ( m_RCInitialQP );
     309    m_acTEncTop[layer].setForceIntraQP        ( m_RCForceIntraQP );
     310#else
    302311    m_acTEncTop[layer].setUseRateCtrl     ( m_enableRateCtrl);
    303312    m_acTEncTop[layer].setTargetBitrate   ( m_targetBitrate);
    304313    m_acTEncTop[layer].setNumLCUInUnit    ( m_numLCUInUnit);
     314#endif
    305315    m_acTEncTop[layer].setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
    306316    m_acTEncTop[layer].setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
    307 #if RECALCULATE_QP_ACCORDING_LAMBDA
    308317    m_acTEncTop[layer].setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
    309 #endif
    310 #if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
     318    m_acTEncTop[layer].setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
    311319    m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
    312 #endif
    313 #if SUPPORT_FOR_VUI
    314320    m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
    315321    m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc );
     
    329335    m_acTEncTop[layer].setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField );
    330336    m_acTEncTop[layer].setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag );
     337    m_acTEncTop[layer].setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
     338    m_acTEncTop[layer].setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag );
     339    m_acTEncTop[layer].setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag );
     340    m_acTEncTop[layer].setNumTicksPocDiffOneMinus1   ( m_numTicksPocDiffOneMinus1    );
    331341    m_acTEncTop[layer].setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag );
    332342    m_acTEncTop[layer].setTilesFixedStructureFlag( m_tilesFixedStructureFlag );
    333343    m_acTEncTop[layer].setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag );
     344    m_acTEncTop[layer].setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc );
    334345    m_acTEncTop[layer].setMaxBytesPerPicDenom( m_maxBytesPerPicDenom );
    335346    m_acTEncTop[layer].setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom );
    336347    m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
    337348    m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
     349#if SIGNAL_BITRATE_PICRATE_IN_VPS
     350    TComBitRatePicRateInfo *bitRatePicRateInfo = m_cTEncTop[layer].getVPS()->getBitratePicrateInfo();
     351    // The number of bit rate/pic rate have to equal to number of sub-layers.
     352    if(m_bitRatePicRateMaxTLayers)
     353    {
     354      assert(m_bitRatePicRateMaxTLayers == m_cTEncTop[layer].getVPS()->getMaxTLayers());
     355    }
     356    for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
     357    {
     358      bitRatePicRateInfo->setBitRateInfoPresentFlag( i, m_bitRateInfoPresentFlag[i] );
     359      if( bitRatePicRateInfo->getBitRateInfoPresentFlag(i) )
     360      {
     361        bitRatePicRateInfo->setAvgBitRate(i, m_avgBitRate[i]);
     362        bitRatePicRateInfo->setMaxBitRate(i, m_maxBitRate[i]);
     363      }
     364    }
     365    for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
     366    {
     367      bitRatePicRateInfo->setPicRateInfoPresentFlag( i, m_picRateInfoPresentFlag[i] );
     368      if( bitRatePicRateInfo->getPicRateInfoPresentFlag(i) )
     369      {
     370        bitRatePicRateInfo->setAvgPicRate     (i, m_avgPicRate[i]);
     371        bitRatePicRateInfo->setConstantPicRateIdc(i, m_constantPicRateIdc[i]);
     372      }
     373    }
    338374#endif
    339375#if REF_IDX_FRAMEWORK
     
    346382{
    347383  TComVPS vps;
    348  
     384
    349385  vps.setMaxTLayers                       ( m_maxTempLayer );
     386  if (m_maxTempLayer == 1)
     387  {
     388    vps.setTemporalNestingFlag(true);
     389  }
    350390  vps.setMaxLayers                        ( 1 );
    351391  for(Int i = 0; i < MAX_TLAYER; i++)
     
    355395  }
    356396  m_cTEncTop.setVPS(&vps);
     397
     398  m_cTEncTop.setProfile(m_profile);
     399  m_cTEncTop.setLevel(m_levelTier, m_level);
     400#if L0046_CONSTRAINT_FLAGS
     401  m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag);
     402  m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag);
     403  m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
     404  m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
     405#endif
     406
    357407  m_cTEncTop.setFrameRate                    ( m_iFrameRate );
    358408  m_cTEncTop.setFrameSkip                    ( m_FrameSkip );
    359409  m_cTEncTop.setSourceWidth                  ( m_iSourceWidth );
    360410  m_cTEncTop.setSourceHeight                 ( m_iSourceHeight );
    361   m_cTEncTop.setCroppingMode                 ( m_croppingMode );
    362   m_cTEncTop.setCropLeft                     ( m_cropLeft );
    363   m_cTEncTop.setCropRight                    ( m_cropRight );
    364   m_cTEncTop.setCropTop                      ( m_cropTop );
    365   m_cTEncTop.setCropBottom                   ( m_cropBottom );
    366   m_cTEncTop.setFrameToBeEncoded             ( m_iFrameToBeEncoded );
    367  
     411  m_cTEncTop.setConformanceWindow            ( m_confLeft, m_confRight, m_confTop, m_confBottom );
     412  m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
     413
    368414  //====== Coding Structure ========
    369415  m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod );
     
    382428  }
    383429  m_cTEncTop.setQP                           ( m_iQP );
    384  
     430
    385431  m_cTEncTop.setPad                          ( m_aiPad );
    386    
     432
    387433  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayer );
    388 #if !REMOVE_NSQT
    389   m_cTEncTop.setUseNSQT( m_enableNSQT );
    390 #endif
    391434  m_cTEncTop.setUseAMP( m_enableAMP );
    392  
     435
    393436  //===== Slice ========
    394  
     437
    395438  //====== Loop/Deblock Filter ========
    396439  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable       );
     
    417460
    418461  Int lowestQP;
    419   lowestQP =  - ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
     462  lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
    420463
    421464  if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true))
     
    425468  m_cTEncTop.setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
    426469  m_cTEncTop.setQPAdaptationRange            ( m_iQPAdaptationRange );
    427  
     470
    428471  //====== Tool list ========
    429472  m_cTEncTop.setUseSBACRD                    ( m_bUseSBACRD   );
     
    431474  m_cTEncTop.setUseASR                       ( m_bUseASR      );
    432475  m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
    433 #if !REMOVE_ALF
    434   m_cTEncTop.setUseALF                       ( m_bUseALF      );
    435 #endif
    436476  m_cTEncTop.setUseLossless                  ( m_useLossless );
    437477  m_cTEncTop.setUseLComb                     ( m_bUseLComb    );
    438478  m_cTEncTop.setdQPs                         ( m_aidQP        );
    439   m_cTEncTop.setUseRDOQ                      ( m_bUseRDOQ     );
     479  m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
     480  m_cTEncTop.setUseRDOQTS                    ( m_useRDOQTS   );
     481#if L0232_RD_PENALTY
     482  m_cTEncTop.setRDpenalty                 ( m_rdPenalty );
     483#endif
    440484  m_cTEncTop.setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
    441485  m_cTEncTop.setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
     
    448492  m_cTEncTop.setUseEarlySkipDetection            ( m_useEarlySkipDetection );
    449493
    450 #if !REMOVE_LMCHROMA
    451   m_cTEncTop.setUseLMChroma                  ( m_bUseLMChroma );
    452 #endif
    453494  m_cTEncTop.setUseTransformSkip             ( m_useTransformSkip      );
    454495  m_cTEncTop.setUseTransformSkipFast         ( m_useTransformSkipFast  );
     
    458499  m_cTEncTop.setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
    459500  m_cTEncTop.setMaxNumMergeCand              ( m_maxNumMergeCand );
    460  
     501
    461502
    462503  //====== Weighted Prediction ========
    463   m_cTEncTop.setUseWP                   ( m_bUseWeightPred      );
     504  m_cTEncTop.setUseWP                   ( m_useWeightedPred      );
    464505  m_cTEncTop.setWPBiPred                ( m_useWeightedBiPred   );
    465506  //====== Parallel Merge Estimation ========
     
    467508
    468509  //====== Slice ========
    469   m_cTEncTop.setSliceMode               ( m_iSliceMode                );
    470   m_cTEncTop.setSliceArgument           ( m_iSliceArgument            );
     510  m_cTEncTop.setSliceMode               ( m_sliceMode                );
     511  m_cTEncTop.setSliceArgument           ( m_sliceArgument            );
    471512
    472513  //====== Dependent Slice ========
    473   m_cTEncTop.setDependentSliceMode        ( m_iDependentSliceMode         );
    474   m_cTEncTop.setDependentSliceArgument    ( m_iDependentSliceArgument     );
    475 #if DEPENDENT_SLICES
    476 #if TILES_WPP_ENTROPYSLICES_FLAGS
    477   m_cTEncTop.setEntropySliceEnabledFlag   ( m_entropySliceEnabledFlag );
    478 #else
    479   m_cTEncTop.setCabacIndependentFlag      ( m_bCabacIndependentFlag   );
    480 #endif
    481 #endif
    482   int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
    483   if(m_iDependentSliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_DEPENDENT_SLICE)
    484   {
    485 #if REMOVE_FGS
    486     m_cTEncTop.setDependentSliceArgument ( m_iDependentSliceArgument * iNumPartInCU );
    487 #else
    488     m_cTEncTop.setDependentSliceArgument ( m_iDependentSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
    489 #endif
    490   }
    491   if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
    492   {
    493 #if REMOVE_FGS
    494     m_cTEncTop.setSliceArgument ( m_iSliceArgument * iNumPartInCU );
    495 #else
    496     m_cTEncTop.setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
    497 #endif
    498   }
    499   if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
    500   {
    501     m_cTEncTop.setSliceArgument ( m_iSliceArgument );
    502   }
    503  
    504 #if !REMOVE_FGS
    505   m_cTEncTop.setSliceGranularity        ( m_iSliceGranularity         );
    506 #endif
    507   if(m_iSliceMode == 0 )
     514  m_cTEncTop.setSliceSegmentMode        ( m_sliceSegmentMode         );
     515  m_cTEncTop.setSliceSegmentArgument    ( m_sliceSegmentArgument     );
     516  Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
     517  if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
     518  {
     519    m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU );
     520  }
     521  if(m_sliceMode==FIXED_NUMBER_OF_LCU)
     522  {
     523    m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU );
     524  }
     525  if(m_sliceMode==FIXED_NUMBER_OF_TILES)
     526  {
     527    m_cTEncTop.setSliceArgument ( m_sliceArgument );
     528  }
     529
     530  if(m_sliceMode == 0 )
    508531  {
    509532    m_bLFCrossSliceBoundaryFlag = true;
     
    513536  m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
    514537
    515 #if SAO_LCU_BOUNDARY
    516538  m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary);
    517 #endif
    518539  m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
    519540  m_cTEncTop.setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
    520541  m_cTEncTop.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
    521542
    522   m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodePictureHashSEIEnabled);
    523 #if RECOVERY_POINT_SEI
     543  m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
    524544  m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
    525 #endif
    526 #if BUFFERING_PERIOD_AND_TIMING_SEI
    527545  m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
    528546  m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
    529 #endif
     547  m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
     548  m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
     549  m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId );
     550  m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx );
     551  m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation );
     552  m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle );
     553  m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled );
     554  m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
     555  m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
    530556  m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    531557  m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     
    533559  if(m_iUniformSpacingIdr==0)
    534560  {
    535     m_cTEncTop.setColumnWidth              ( m_pchColumnWidth );
    536     m_cTEncTop.setRowHeight                ( m_pchRowHeight );
     561    m_cTEncTop.setColumnWidth              ( m_pColumnWidth );
     562    m_cTEncTop.setRowHeight                ( m_pRowHeight );
    537563  }
    538564  m_cTEncTop.xCheckGSParameters();
     
    549575  m_cTEncTop.setScalingListFile            ( m_scalingListFile   );
    550576  m_cTEncTop.setSignHideFlag(m_signHideFlag);
    551 #if !REMOVE_ALF
    552   m_cTEncTop.setALFLowLatencyEncoding( m_alfLowLatencyEncoding );
    553 #endif
     577#if RATE_CONTROL_LAMBDA_DOMAIN
     578  m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
     579  m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
     580  m_cTEncTop.setKeepHierBit         ( m_RCKeepHierarchicalBit );
     581  m_cTEncTop.setLCULevelRC          ( m_RCLCULevelRC );
     582  m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
     583  m_cTEncTop.setInitialQP           ( m_RCInitialQP );
     584  m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
     585#else
    554586  m_cTEncTop.setUseRateCtrl     ( m_enableRateCtrl);
    555587  m_cTEncTop.setTargetBitrate   ( m_targetBitrate);
    556588  m_cTEncTop.setNumLCUInUnit    ( m_numLCUInUnit);
     589#endif
    557590  m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
    558591  m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
    559 #if RECALCULATE_QP_ACCORDING_LAMBDA
    560592  m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
    561 #endif
    562 #if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
     593  m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
    563594  m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
    564 #endif
    565 #if SUPPORT_FOR_VUI
    566595  m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
    567596  m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc );
     
    581610  m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField );
    582611  m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag );
     612  m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
     613  m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag );
     614  m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag );
     615  m_cTEncTop.setNumTicksPocDiffOneMinus1   ( m_numTicksPocDiffOneMinus1    );
    583616  m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag );
    584617  m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag );
    585618  m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag );
     619  m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc );
    586620  m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom );
    587621  m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom );
    588622  m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
    589623  m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
     624#if SIGNAL_BITRATE_PICRATE_IN_VPS
     625  TComBitRatePicRateInfo *bitRatePicRateInfo = m_cTEncTop.getVPS()->getBitratePicrateInfo();
     626  // The number of bit rate/pic rate have to equal to number of sub-layers.
     627  if(m_bitRatePicRateMaxTLayers)
     628  {
     629    assert(m_bitRatePicRateMaxTLayers == m_cTEncTop.getVPS()->getMaxTLayers());
     630  }
     631  for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
     632  {
     633    bitRatePicRateInfo->setBitRateInfoPresentFlag( i, m_bitRateInfoPresentFlag[i] );
     634    if( bitRatePicRateInfo->getBitRateInfoPresentFlag(i) )
     635    {
     636      bitRatePicRateInfo->setAvgBitRate(i, m_avgBitRate[i]);
     637      bitRatePicRateInfo->setMaxBitRate(i, m_maxBitRate[i]);
     638    }
     639  }
     640  for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
     641  {
     642    bitRatePicRateInfo->setPicRateInfoPresentFlag( i, m_picRateInfoPresentFlag[i] );
     643    if( bitRatePicRateInfo->getPicRateInfoPresentFlag(i) )
     644    {
     645      bitRatePicRateInfo->setAvgPicRate     (i, m_avgPicRate[i]);
     646      bitRatePicRateInfo->setConstantPicRateIdc(i, m_constantPicRateIdc[i]);
     647    }
     648  }
    590649#endif
    591650}
     
    601660  for(UInt layer=0; layer<m_numLayers; layer++)
    602661  {
    603     m_acTVideoIOYuvInputFile[layer].open( (char *)m_acLayerCfg[layer].getInputFile().c_str(),  false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
     662    m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(),  false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
    604663    m_acTVideoIOYuvInputFile[layer].skipFrames(m_FrameSkip, m_acLayerCfg[layer].getSourceWidth() - m_acLayerCfg[layer].getPad()[0], m_acLayerCfg[layer].getSourceHeight() - m_acLayerCfg[layer].getPad()[1]);
    605664
    606665    if (!m_acLayerCfg[layer].getReconFile().empty())
    607666    {
    608       m_acTVideoIOYuvReconFile[layer].open((char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
     667      m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // write mode
    609668    }
    610669
     
    612671  }
    613672#else
    614   m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
     673  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
    615674  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
    616675
    617676  if (m_pchReconFile)
    618     m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
    619  
     677    m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
     678
    620679  // Neo Decoder
    621680  m_cTEncTop.create();
     
    640699  m_cTVideoIOYuvInputFile.close();
    641700  m_cTVideoIOYuvReconFile.close();
    642  
     701
    643702  // Neo Decoder
    644703  m_cTEncTop.destroy();
     
    653712    m_acTEncTop[layer].init();
    654713  }
     714#if VPS_RENAME
     715  m_acTEncTop[0].getVPS()->setMaxLayers( m_numLayers );
     716#endif
     717#if VPS_EXTN_OP_LAYER_SETS
     718  TComVPS* vps = m_acTEncTop[0].getVPS();
     719  vps->setMaxLayerId(m_numLayers - 1);    // Set max-layer ID
     720
     721  vps->setNumLayerSets(m_numLayers);
     722  for(Int setId = 1; setId < vps->getNumLayerSets(); setId++)
     723  {
     724    for(Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++)
     725    {
     726      vps->setLayerIdIncludedFlag(true, setId, layerId);
     727    }
     728  }
     729#if VPS_EXTN_MASK_AND_DIM_INFO
     730  UInt i = 0, dimIdLen = 0;
     731  vps->setAvcBaseLayerFlag(false);
     732  vps->setSplittingFlag(false);
     733  for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++)
     734  {
     735    vps->setScalabilityMask(i, false);
     736  }
     737  if(m_numLayers > 1)
     738  {
     739    vps->setScalabilityMask(1, true); // Only turn on spatial/SNR scalability
     740    vps->setNumScalabilityTypes(1);
     741  }
     742  else
     743  {
     744    vps->setNumScalabilityTypes(0);
     745  }
     746  while((1 << dimIdLen) < m_numLayers)
     747  {
     748    dimIdLen++;
     749  }
     750  vps->setDimensionIdLen(0, dimIdLen);
     751  vps->setNuhLayerIdPresentFlag(false);
     752  vps->setLayerIdInNuh(0, 0);
     753  vps->setLayerIdInVps(0, 0);
     754  for(i = 1; i < vps->getMaxLayers(); i++)
     755  {
     756    vps->setLayerIdInNuh(i, i);
     757    vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i);
     758    vps->setDimensionId(i, 0, i);
     759  }
     760#endif
     761#if VPS_EXTN_PROFILE_INFO
     762  vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets());
     763  for(Int setId = 1; setId < vps->getNumLayerSets(); setId++)
     764  {
     765    vps->setProfilePresentFlag(setId, true);
     766    // Note - may need to be changed for other layer structures.
     767    *(vps->getPTLForExtn(setId)) = *(m_acTEncTop[setId].getSPS()->getPTL());
     768  }
     769#endif
     770  // Target output layer
     771  vps->setNumOutputLayerSets(1);
     772  Int lsIdx = 1;
     773  vps->setOutputLayerSetIdx(0, lsIdx); // Because only one layer set
     774  // Include the highest layer as output layer
     775  for(UInt layer=0; layer <= vps->getMaxLayerId() ; layer++)
     776  {
     777    if(vps->getLayerIdIncludedFlag(lsIdx, layer))
     778    {
     779      vps->setOutputLayerFlag(lsIdx, layer, layer == (vps->getMaxLayerId()));
     780    }
     781  }
     782#endif
     783#if VPS_EXTN_DIRECT_REF_LAYERS
     784  // Direct reference layers
     785  for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     786  {
     787    vps->setNumDirectRefLayers( layerCtr, m_acTEncTop[layerCtr].getNumDirectRefLayers() );
     788    for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
     789    {
     790      vps->setRefLayerId( layerCtr, i, m_acTEncTop[layerCtr].getRefLayerId(i) );
     791    }
     792    // Set direct dependency flag
     793    // Initialize flag to 0
     794    for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     795    {
     796      vps->setDirectDependencyFlag( layerCtr, refLayerCtr, false );
     797    }
     798    for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
     799    {
     800      vps->setDirectDependencyFlag( layerCtr, vps->getLayerIdInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true);
     801    }
     802  }
     803#endif
    655804#else
    656805  m_cTEncTop.init();
     
    663812
    664813/**
    665  - create internal class
    666  - initialize internal variable
    667  - until the end of input YUV file, call encoding function in TEncTop class
    668  - delete allocated buffers
    669  - destroy internal class
    670  .
    671  */
     814- create internal class
     815- initialize internal variable
     816- until the end of input YUV file, call encoding function in TEncTop class
     817- delete allocated buffers
     818- destroy internal class
     819.
     820*/
    672821#if SVC_EXTENSION
    673822Void TAppEncTop::encode()
    674823{
    675   fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
     824  fstream bitstreamFile(m_pBitstreamFile, fstream::binary | fstream::out);
    676825  if (!bitstreamFile)
    677826  {
    678     fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
     827    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pBitstreamFile);
    679828    exit(EXIT_FAILURE);
    680829  }
     
    682831  TComPicYuv*       pcPicYuvOrg [MAX_LAYERS];
    683832  TComPicYuv*       pcPicYuvRec = NULL;
    684  
     833
    685834  // initialize internal class & member variables
    686 
    687835  xInitLibCfg();
    688836  xCreateLib();
     
    690838
    691839  // main encoder loop
    692   Int   iNumEncoded, iTotalNumEncoded;
    693   Bool  bEos = false, bBaseEos = false;
    694  
     840  Int   iNumEncoded = 0, iTotalNumEncoded = 0;
     841  Bool  bEos = false;
     842
    695843  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
    696844
     
    699847    // allocate original YUV buffer
    700848    pcPicYuvOrg[layer] = new TComPicYuv;
    701 #if SVC_UPSAMPLING 
     849#if SVC_UPSAMPLING
    702850    pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
    703851#else
    704     pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     852    pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    705853#endif
    706854  }
     
    733881        xGetBuffer(pcPicYuvRec, layer);
    734882
     883        // read input YUV file
    735884        m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], m_acLayerCfg[layer].getPad() );
    736    
     885
    737886        if(layer == m_numLayers-1)
    738887        {
     
    740889          m_iFrameRcvd++;
    741890          // check end of file
    742           bEos = ( m_acTVideoIOYuvInputFile[layer].isEof() == 1 ?   true : bBaseEos? true : bEos  );
    743           bEos = ( m_iFrameRcvd == m_iFrameToBeEncoded ?    true : bEos   );
     891          bEos = (m_iFrameRcvd == m_framesToBeEncoded);
    744892        }
    745         else
    746         {
    747           // check end of file of base layers
    748           bBaseEos = ( m_acTVideoIOYuvInputFile[layer].isEof() == 1 ?   true : bBaseEos  );
    749         }
    750         m_acTEncTop[layer].encodePrep( bEos, pcPicYuvOrg[layer] );
     893
     894        m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] );
    751895      }
    752896
    753897      bFramesReadyToCode = !(!bFirstFrame && ( m_acTEncTop[m_numLayers-1].getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos );
     898    }
     899    Bool flush = 0;
     900    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
     901    if (m_acTVideoIOYuvInputFile[m_numLayers-1].isEof())
     902    {
     903      flush = true;
     904      bEos = true;
     905      m_iFrameRcvd--;
     906      m_acTEncTop[m_numLayers-1].setFramesToBeEncoded(m_iFrameRcvd);
    754907    }
    755908
     
    761914      {
    762915        // call encoding function for one frame
    763         m_acTEncTop[layer].encode( pcPicYuvOrg[layer], m_acListPicYuvRec[layer],
    764           outputAccessUnits, iPicIdInGOP );
     916        m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
    765917      }
    766918    }
     
    771923      // write bistream to file if necessary
    772924      iNumEncoded = m_acTEncTop[layer].getNumPicRcvd();
    773       if ( iNumEncoded > 0 ) 
     925      if ( iNumEncoded > 0 )
    774926      {
    775927        xWriteRecon(layer, iNumEncoded);
     
    794946    bFirstFrame = false;
    795947  }
    796 
    797948  // delete original YUV buffer
    798949  for(UInt layer=0; layer<m_numLayers; layer++)
     
    805956    m_acTEncTop[layer].deletePicBuffer();
    806957  }
    807  
     958
    808959#if AVC_SYNTAX
    809960  if( streamSyntaxFile.is_open() )
     
    816967  xDeleteBuffer();
    817968  xDestroyLib();
    818  
     969
    819970  printRateSummary();
    820971
    821972  return;
    822973}
    823 
    824974
    825975Void TAppEncTop::printOutSummary()
     
    843993    m_gcAnalyzeAll[layer].printOut('a', layer);
    844994  }
    845    
     995
    846996  printf( "\n\nI Slices--------------------------------------------------------\n" );
    847997  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     
    8501000    m_gcAnalyzeI[layer].printOut('i', layer);
    8511001  }
    852    
     1002
    8531003  printf( "\n\nP Slices--------------------------------------------------------\n" );
    8541004  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     
    8571007    m_gcAnalyzeP[layer].printOut('p', layer);
    8581008  }
    859    
     1009
    8601010  printf( "\n\nB Slices--------------------------------------------------------\n" );
    8611011  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     
    8781028  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
    8791029  TComPicYuv*       pcPicYuvRec = NULL;
    880  
     1030
    8811031  // initialize internal class & member variables
    8821032  xInitLibCfg();
    8831033  xCreateLib();
    8841034  xInitLib();
    885  
     1035
    8861036  // main encoder loop
    8871037  Int   iNumEncoded = 0;
    8881038  Bool  bEos = false;
    889  
     1039
    8901040  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
    8911041
    8921042  // allocate original YUV buffer
    8931043  pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    894  
     1044
    8951045  while ( !bEos )
    8961046  {
     
    9001050    // read input YUV file
    9011051    m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad );
    902    
     1052
    9031053    // increase number of received frames
    9041054    m_iFrameRcvd++;
    905    
    906     // check end of file
    907     bEos = ( m_cTVideoIOYuvInputFile.isEof() == 1 ?   true : false  );
    908     bEos = ( m_iFrameRcvd == m_iFrameToBeEncoded ?    true : bEos   );
    909    
     1055
     1056    bEos = (m_iFrameRcvd == m_framesToBeEncoded);
     1057
     1058    Bool flush = 0;
     1059    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
     1060    if (m_cTVideoIOYuvInputFile.isEof())
     1061    {
     1062      flush = true;
     1063      bEos = true;
     1064      m_iFrameRcvd--;
     1065      m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd);
     1066    }
     1067
    9101068    // call encoding function for one frame
    911     m_cTEncTop.encode( bEos, pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
    912    
     1069    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
     1070
    9131071    // write bistream to file if necessary
    9141072    if ( iNumEncoded > 0 )
     
    9181076    }
    9191077  }
     1078
     1079  m_cTEncTop.printSummary();
     1080
    9201081  // delete original YUV buffer
    9211082  pcPicYuvOrg->destroy();
    9221083  delete pcPicYuvOrg;
    9231084  pcPicYuvOrg = NULL;
    924  
     1085
    9251086  // delete used buffers in encoder class
    9261087  m_cTEncTop.deletePicBuffer();
    927  
     1088
    9281089  // delete buffers & classes
    9291090  xDeleteBuffer();
    9301091  xDestroyLib();
    931  
     1092
    9321093  printRateSummary();
    9331094
     
    9411102
    9421103/**
    943  - application has picture buffer list with size of GOP
    944  - picture buffer list acts as ring buffer
    945  - end of the list has the latest picture
    946  .
    947  */
     1104- application has picture buffer list with size of GOP
     1105- picture buffer list acts as ring buffer
     1106- end of the list has the latest picture
     1107.
     1108*/
    9481109#if SVC_EXTENSION
    9491110Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
    9501111{
    9511112  assert( m_iGOPSize > 0 );
    952  
     1113
    9531114  // org. buffer
    9541115  if ( m_acListPicYuvRec[layer].size() == (UInt)m_iGOPSize )
     
    9601121  {
    9611122    rpcPicYuvRec = new TComPicYuv;
    962    
     1123
    9631124#if SVC_UPSAMPLING
    9641125    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     
    9761137  {
    9771138    TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_acListPicYuvRec[layer].begin();
    978    
     1139
    9791140    Int iSize = Int( m_acListPicYuvRec[layer].size() );
    980    
     1141
    9811142    for ( Int i = 0; i < iSize; i++ )
    9821143    {
     
    9881149}
    9891150
    990 
    991 
    9921151Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded)
    9931152{
    9941153  Int i;
    995  
     1154
    9961155  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
    997  
     1156
    9981157  for ( i = 0; i < iNumEncoded; i++ )
    9991158  {
    10001159    --iterPicYuvRec;
    10011160  }
    1002  
     1161
    10031162  for ( i = 0; i < iNumEncoded; i++ )
    10041163  {
     
    10061165    if (!m_acLayerCfg[layer].getReconFile().empty())
    10071166    {
    1008       m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getCropLeft(), m_acLayerCfg[layer].getCropRight(),
    1009         m_acLayerCfg[layer].getCropTop(), m_acLayerCfg[layer].getCropBottom() );
    1010     }
    1011   }
    1012 }
    1013 
     1167      m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
     1168        m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     1169    }
     1170  }
     1171}
    10141172
    10151173Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    10161174{
    10171175  Int i;
    1018  
     1176
    10191177  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    1020  
     1178
    10211179  for ( i = 0; i < iNumEncoded; i++ )
    10221180  {
    10231181    const AccessUnit& au = *(iterBitstream++);
    1024     const vector<unsigned>& stats = writeAnnexB(bitstreamFile, au);
     1182    const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
    10251183    rateStatsAccum(au, stats);
    10261184  }
     
    10311189{
    10321190  assert( m_iGOPSize > 0 );
    1033  
     1191
    10341192  // org. buffer
    10351193  if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize )
     
    10411199  {
    10421200    rpcPicYuvRec = new TComPicYuv;
    1043    
     1201
    10441202    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    10451203
     
    10511209{
    10521210  TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec.begin();
    1053  
     1211
    10541212  Int iSize = Int( m_cListPicYuvRec.size() );
    1055  
     1213
    10561214  for ( Int i = 0; i < iSize; i++ )
    10571215  {
     
    10601218    delete pcPicYuvRec; pcPicYuvRec = NULL;
    10611219  }
    1062  
     1220
    10631221}
    10641222
    10651223/** \param iNumEncoded  number of encoded frames
    1066  */
     1224*/
    10671225Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    10681226{
    10691227  Int i;
    1070  
     1228
    10711229  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
    10721230  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    1073  
     1231
    10741232  for ( i = 0; i < iNumEncoded; i++ )
    10751233  {
    10761234    --iterPicYuvRec;
    10771235  }
    1078  
     1236
    10791237  for ( i = 0; i < iNumEncoded; i++ )
    10801238  {
     
    10821240    if (m_pchReconFile)
    10831241    {
    1084       m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom );
     1242      m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
    10851243    }
    10861244
    10871245    const AccessUnit& au = *(iterBitstream++);
    1088     const vector<unsigned>& stats = writeAnnexB(bitstreamFile, au);
     1246    const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
    10891247    rateStatsAccum(au, stats);
    10901248  }
     
    10931251
    10941252/**
    1095  *
    1096  */
    1097 void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<unsigned>& annexBsizes)
     1253*
     1254*/
     1255void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
    10981256{
    10991257  AccessUnit::const_iterator it_au = au.begin();
    1100   vector<unsigned>::const_iterator it_stats = annexBsizes.begin();
     1258  vector<UInt>::const_iterator it_stats = annexBsizes.begin();
    11011259
    11021260  for (; it_au != au.end(); it_au++, it_stats++)
     
    11041262    switch ((*it_au)->m_nalUnitType)
    11051263    {
    1106 #if NAL_UNIT_TYPES_J1003_D7
    11071264    case NAL_UNIT_CODED_SLICE_TRAIL_R:
    11081265    case NAL_UNIT_CODED_SLICE_TRAIL_N:
     
    11171274    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
    11181275    case NAL_UNIT_CODED_SLICE_CRA:
     1276    case NAL_UNIT_CODED_SLICE_RADL_N:
    11191277    case NAL_UNIT_CODED_SLICE_DLP:
     1278    case NAL_UNIT_CODED_SLICE_RASL_N:
    11201279    case NAL_UNIT_CODED_SLICE_TFD:
    1121 #else
    1122     case NAL_UNIT_CODED_SLICE:
    1123     case NAL_UNIT_CODED_SLICE_TFD:
    1124     case NAL_UNIT_CODED_SLICE_TLA:
    1125     case NAL_UNIT_CODED_SLICE_CRA:
    1126     case NAL_UNIT_CODED_SLICE_CRANT:
    1127     case NAL_UNIT_CODED_SLICE_BLA:
    1128     case NAL_UNIT_CODED_SLICE_BLANT:
    1129     case NAL_UNIT_CODED_SLICE_IDR:
    1130 #endif
    11311280    case NAL_UNIT_VPS:
    11321281    case NAL_UNIT_SPS:
     
    11451294{
    11461295#if SVC_EXTENSION
    1147   double time = (double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate();
     1296  Double time = (Double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate();
    11481297#else
    1149   double time = (double) m_iFrameRcvd / m_iFrameRate;
     1298  Double time = (Double) m_iFrameRcvd / m_iFrameRate;
    11501299#endif
    11511300  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
  • trunk/source/App/TAppEncoder/TAppEncTop.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 *
     
    7373  TComList<TComPicYuv*>      m_cListPicYuvRec;              ///< list of reconstruction YUV files
    7474#endif
    75 
     75 
    7676  Int                        m_iFrameRcvd;                  ///< number of received frames
    7777 
    78   unsigned m_essentialBytes;
    79   unsigned m_totalBytes;
     78  UInt m_essentialBytes;
     79  UInt m_totalBytes;
    8080protected:
    8181  // initialization
     
    103103  Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits); ///< write bitstream to file
    104104#endif
    105   void rateStatsAccum(const AccessUnit& au, const std::vector<unsigned>& stats);
     105  void rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& stats);
    106106  void printRateSummary();
    107107 
     
    116116  TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
    117117#endif
    118 
    119 
    120 
    121118};// END CLASS DEFINITION TAppEncTop
    122119
  • trunk/source/App/TAppEncoder/encmain.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 *
     
    3737
    3838#include <time.h>
     39#include <iostream>
    3940#include "TAppEncTop.h"
     41#include "TAppCommon/program_options_lite.h"
     42
     43using namespace std;
     44namespace po = df::program_options_lite;
    4045
    4146//! \ingroup TAppEncoder
     
    6267
    6368  // parse configuration
    64   if(!cTAppEncTop.parseCfg( argc, argv ))
     69  try
    6570  {
    66     cTAppEncTop.destroy();
     71    if(!cTAppEncTop.parseCfg( argc, argv ))
     72    {
     73      cTAppEncTop.destroy();
     74      return 1;
     75    }
     76  }
     77  catch (po::ParseFailure& e)
     78  {
     79    cerr << "Error parsing option \""<< e.arg <<"\" with argument \""<< e.val <<"\"." << endl;
    6780    return 1;
    6881  }
  • trunk/source/App/utils/convert_NtoMbit_YCbCr.cpp

    r2 r125  
    7676  TVideoIOYuv output;
    7777
    78   input.open((char*)filename_in.c_str(), false, bitdepth_in, bitdepth_out);
    79   output.open((char*)filename_out.c_str(), true, bitdepth_out, bitdepth_out);
     78  input.open((char*)filename_in.c_str(), false, bitdepth_in, bitdepth_in, bitdepth_out, bitdepth_out);
     79  output.open((char*)filename_out.c_str(), true, bitdepth_out, bitdepth_out, bitdepth_out, bitdepth_out);
    8080
    8181  input.skipFrames(num_frames_skip, width, height);
Note: See TracChangeset for help on using the changeset viewer.