Changeset 1413 in 3DVCSoftware for trunk/source


Ignore:
Timestamp:
11 Jul 2018, 15:19:49 (6 years ago)
Author:
tech
Message:

Merged HTM-16.2-dev@1412

Location:
trunk/source
Files:
2 added
159 edited

Legend:

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

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    115115#endif
    116116  ("ClipOutputVideoToRec709Range",      m_bClipOutputVideoToRec709Range,  false, "If true then clip output video to the Rec. 709 Range on saving")
     117#if MCTS_ENC_CHECK
     118  ("TMCTSCheck",                  m_tmctsCheck,                          false,    "If enabled, the decoder checks for violations of mc_exact_sample_value_match_flag in Temporal MCTS ")
     119#endif
    117120  ;
    118121
  • trunk/source/App/TAppDecoder/TAppDecCfg.h

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    7878  std::string   m_outputDecodedSEIMessagesFilename;   ///< filename to output decoded SEI messages to. If '-', then use stdout. If empty, do not output details.
    7979  Bool          m_bClipOutputVideoToRec709Range;      ///< If true, clip the output video to the Rec 709 range on saving.
     80#if MCTS_ENC_CHECK
     81  Bool          m_tmctsCheck;
     82#endif
     83
    8084#if NH_MV
    8185  std::vector<TChar*> m_pchReconFiles;                ///< array of output reconstruction file name create from output reconstruction file name
     
    122126  , m_outputDecodedSEIMessagesFilename()
    123127  , m_bClipOutputVideoToRec709Range(false)
     128#if MCTS_ENC_CHECK
     129  , m_tmctsCheck(false)
     130#endif
    124131#if NH_MV
    125132  , m_highestTid(-1)
    126133  , m_targetDecLayerIdSetFileEmpty(true)
    127134#endif
    128 
    129135  {
    130136    for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
  • trunk/source/App/TAppDecoder/TAppDecTop.cpp

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    405405  // initialize global variables
    406406  initROM();
    407 #if NH_3D_DMM
     407#if NH_3D
    408408  initWedgeLists();
    409409#endif
     
    474474  m_cTDecTop.init();
    475475  m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     476#if MCTS_ENC_CHECK
     477  m_cTDecTop.setTMctsCheckEnabled(m_tmctsCheck);
     478#endif
    476479#if O0043_BEST_EFFORT_DECODING
    477480  m_cTDecTop.setForceDecodeBitDepth(m_forceDecodeBitDepth);
     
    12621265    m_vps->printLayerSets();
    12631266    m_vps->printPTL();
     1267    m_vps->printRepFormat();
    12641268  }
    12651269}
     
    22232227  ////////////////////////////////////////////////////////////////////////////////
    22242228
    2225   const TComDpbSize* dpbSize = m_vps->getDpbSize();
    2226   m_maxNumReorderPics       = dpbSize->getMaxVpsNumReorderPics      ( m_targetOptLayerSetIdx, m_highestTid );
    2227   m_maxLatencyIncreasePlus1 = dpbSize->getMaxVpsLatencyIncreasePlus1( m_targetOptLayerSetIdx, m_highestTid );
    2228   m_maxLatencyValue         = dpbSize->getVpsMaxLatencyPictures     ( m_targetOptLayerSetIdx, m_highestTid );
    2229 
    2230   for(Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
    2231   {
    2232     m_maxDecPicBufferingMinus1[ i ] = MIN_INT;
    2233   }
    2234   for( Int i = 0; i <= m_vps->getMaxLayersMinus1(); i++ )
    2235   {
    2236     Int currLayerId = m_vps->getLayerIdInNuh( i );
    2237     for(Int layerIdx = 0 ; layerIdx < m_vps->getNumLayersInIdList( m_targetDecLayerSetIdx); layerIdx++ )
    2238     {
    2239       if( m_vps->getLayerSetLayerIdList( m_targetDecLayerSetIdx, layerIdx ) == currLayerId )
    2240       {
    2241         m_maxDecPicBufferingMinus1[currLayerId] = dpbSize->getMaxVpsDecPicBufferingMinus1( m_targetDecLayerSetIdx, layerIdx, m_highestTid );
     2229  // According to spec, no dbpSize values are given for OLS 0, however they are used in F.13.5.2.1.
     2230  // This might be an issue of the spec. As workaround use sps for OLS 0 here.
     2231
     2232  if ( m_targetOptLayerSetIdx == 0 )
     2233  {
     2234    m_maxNumReorderPics            = m_sps->getSpsMaxNumReorderPics      ( m_highestTid );
     2235    m_maxLatencyIncreasePlus1      = m_sps->getSpsMaxLatencyIncreasePlus1( m_highestTid );
     2236    m_maxLatencyValue              = m_sps->getSpsMaxLatencyPictures     ( m_highestTid );
     2237    m_maxDecPicBufferingMinus1[0]  = m_sps->getMaxDecPicBuffering        ( m_highestTid );
     2238  }
     2239  else
     2240  {
     2241    const TComDpbSize* dpbSize = m_vps->getDpbSize();
     2242    m_maxNumReorderPics       = dpbSize->getMaxVpsNumReorderPics      ( m_targetOptLayerSetIdx, m_highestTid );
     2243    m_maxLatencyIncreasePlus1 = dpbSize->getMaxVpsLatencyIncreasePlus1( m_targetOptLayerSetIdx, m_highestTid );
     2244    m_maxLatencyValue         = dpbSize->getVpsMaxLatencyPictures     ( m_targetOptLayerSetIdx, m_highestTid );
     2245
     2246    for(Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
     2247    {
     2248      m_maxDecPicBufferingMinus1[ i ] = MIN_INT;
     2249    }
     2250    for( Int i = 0; i <= m_vps->getMaxLayersMinus1(); i++ )
     2251    {
     2252      Int currLayerId = m_vps->getLayerIdInNuh( i );
     2253      for(Int layerIdx = 0 ; layerIdx < m_vps->getNumLayersInIdList( m_targetDecLayerSetIdx); layerIdx++ )
     2254      {
     2255        if( m_vps->getLayerSetLayerIdList( m_targetDecLayerSetIdx, layerIdx ) == currLayerId )
     2256        {
     2257          m_maxDecPicBufferingMinus1[currLayerId] = dpbSize->getMaxVpsDecPicBufferingMinus1( m_targetDecLayerSetIdx, layerIdx, m_highestTid );
     2258        }
    22422259      }
    22432260    }
     
    26732690    m_tDecTop[ decIdx ]->setLayerId( layerId );
    26742691    m_tDecTop[ decIdx ]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     2692#if MCTS_ENC_CHECK
     2693    m_tDecTop[ decIdx ]->setTMctsCheckEnabled( m_tmctsCheck );
     2694#endif
    26752695    m_tDecTop[ decIdx ]->setDpb( &m_dpb );
    26762696    m_tDecTop[ decIdx ]->setTargetOlsIdx( m_targetOptLayerSetIdx );
     
    26782698    m_tDecTop[ decIdx ]->setPocDecrementedInDPBFlag   ( m_pocDecrementedInDpbFlag    );
    26792699    m_tDecTop[ decIdx ]->setLastPresentPocResetIdc    ( m_lastPresentPocResetIdc );
    2680 
    2681 
    26822700#if O0043_BEST_EFFORT_DECODING
    26832701    m_cTDecTop[ decIdx ]->setForceDecodeBitDepth(m_forceDecodeBitDepth);
  • trunk/source/App/TAppDecoder/TAppDecTop.h

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • trunk/source/App/TAppDecoder/decmain.cpp

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    7070  Int curDecoding  = 0;
    7171  Double dResult = 0;
    72   do {
     72  do
     73  {
    7374    TAppDecTop  cTAppDecTop;
    7475#endif
  • trunk/source/App/TAppEncoder/TAppEncCfg.cpp

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4646#include "TAppCommon/program_options_lite.h"
    4747#include "TLibEncoder/TEncRateCtrl.h"
     48#if NH_MV
     49#include <set>
     50#endif
     51
    4852#ifdef WIN32
    4953#define strdup _strdup
     
    5761
    5862
    59 
    60 enum ExtendedProfileName // this is used for determining profile strings, where multiple profiles map to a single profile idc with various constraint flag combinations
     63#if !NH_MV
     64enum UIProfileName // this is used for determining profile strings, where multiple profiles map to a single profile idc with various constraint flag combinations
    6165{
    62   NONE = 0,
    63   MAIN = 1,
    64   MAIN10 = 2,
    65   MAINSTILLPICTURE = 3,
    66   MAINREXT = 4,
    67   HIGHTHROUGHPUTREXT = 5, // Placeholder profile for development
     66  UI_NONE = 0,
     67  UI_MAIN = 1,
     68  UI_MAIN10 = 2,
     69  UI_MAIN10_STILL_PICTURE=10002,
     70  UI_MAINSTILLPICTURE = 3,
     71  UI_MAINREXT = 4,
     72  UI_HIGHTHROUGHPUTREXT = 5,
    6873  // The following are RExt profiles, which would map to the MAINREXT profile idc.
    6974  // The enumeration indicates the bit-depth constraint in the bottom 2 digits
    7075  //                           the chroma format in the next digit
    71     //                           the intra constraint in the next digit
     76  //                           the intra constraint in the next digit (1 for no intra constraint, 2 for intra constraint)
    7277//                           If it is a RExt still picture, there is a '1' for the top digit.
    7378#if NH_MV
    74   MULTIVIEWMAIN = 6,
     79  UI_MULTIVIEWMAIN    = 6,
    7580#if NH_3D
    76   MAIN3D = 8,
    77 #endif
    78 #endif
    79   MONOCHROME_8      = 1008,
    80   MONOCHROME_12     = 1012,
    81   MONOCHROME_16     = 1016,
    82   MAIN_12           = 1112,
    83   MAIN_422_10       = 1210,
    84   MAIN_422_12       = 1212,
    85   MAIN_444          = 1308,
    86   MAIN_444_10       = 1310,
    87   MAIN_444_12       = 1312,
    88   MAIN_444_16       = 1316, // non-standard profile definition, used for development purposes
    89   MAIN_INTRA        = 2108,
    90   MAIN_10_INTRA     = 2110,
    91   MAIN_12_INTRA     = 2112,
    92   MAIN_422_10_INTRA = 2210,
    93   MAIN_422_12_INTRA = 2212,
    94   MAIN_444_INTRA    = 2308,
    95   MAIN_444_10_INTRA = 2310,
    96   MAIN_444_12_INTRA = 2312,
    97   MAIN_444_16_INTRA = 2316,
    98   MAIN_444_STILL_PICTURE = 11308,
    99   MAIN_444_16_STILL_PICTURE = 12316
     81  UI_MAIN3D            = 8,
     82#endif
     83#endif
     84  UI_MONOCHROME_8      = 1008,
     85  UI_MONOCHROME_12     = 1012,
     86  UI_MONOCHROME_16     = 1016,
     87  UI_MAIN_12           = 1112,
     88  UI_MAIN_422_10       = 1210,
     89  UI_MAIN_422_12       = 1212,
     90  UI_MAIN_444          = 1308,
     91  UI_MAIN_444_10       = 1310,
     92  UI_MAIN_444_12       = 1312,
     93  UI_MAIN_444_16       = 1316, // non-standard profile definition, used for development purposes
     94  UI_MAIN_INTRA        = 2108,
     95  UI_MAIN_10_INTRA     = 2110,
     96  UI_MAIN_12_INTRA     = 2112,
     97  UI_MAIN_422_10_INTRA = 2210,
     98  UI_MAIN_422_12_INTRA = 2212,
     99  UI_MAIN_444_INTRA    = 2308,
     100  UI_MAIN_444_10_INTRA = 2310,
     101  UI_MAIN_444_12_INTRA = 2312,
     102  UI_MAIN_444_16_INTRA = 2316,
     103  UI_MAIN_444_STILL_PICTURE = 11308,
     104  UI_MAIN_444_16_STILL_PICTURE = 12316,
     105  // The following are high throughput profiles, which would map to the HIGHTHROUGHPUTREXT profile idc.
     106  // The enumeration indicates the bit-depth constraint in the bottom 2 digits
     107  //                           the chroma format in the next digit
     108  //                           the intra constraint in the next digit
     109  //                           There is a '2' for the top digit to indicate it is high throughput profile
     110 
     111  UI_HIGHTHROUGHPUT_444     = 21308,
     112  UI_HIGHTHROUGHPUT_444_10  = 21310,
     113  UI_HIGHTHROUGHPUT_444_14  = 21314,
     114  UI_HIGHTHROUGHPUT_444_16_INTRA  = 22316
    100115};
    101 
     116#endif
    102117
    103118//! \ingroup TAppEncoder
     
    112127, m_snrInternalColourSpace(false)
    113128, m_outputInternalColourSpace(false)
     129#if EXTENSION_360_VIDEO
     130, m_ext360(*this)
     131#endif
    114132{
    115133#if !NH_MV
     
    208226
    209227#if NH_MV
     228
     229GOPEntry* TAppEncCfg::xGetGopEntries(Int layerIdInVps)
     230{
     231  return m_GOPListMvc[ m_layerIdxInVpsToGopDefIdx[ layerIdInVps ] ];
     232}
     233
     234GOPEntry* TAppEncCfg::xGetGopEntry(Int layerIdInVps, Int poc)
     235{
     236  GOPEntry* geFound = NULL;
     237  for( Int i = 0; i < ( getGOPSize() + 1) && geFound == NULL ; i++ )
     238  {
     239    GOPEntry* ge = &(xGetGopEntries( layerIdInVps)[ ( i < getGOPSize()  ? i : MAX_GOP ) ]);
     240    if ( ge->m_POC == poc )
     241    {
     242      geFound = ge;       
     243    }
     244  }
     245  assert( geFound != NULL );
     246  return geFound;
     247}
     248
    210249Void TAppEncCfg::xParseSeiCfg()
    211250{
     
    239278  in>>entry.m_POC;
    240279  in>>entry.m_QPOffset;
    241 #if W0038_CQP_ADJ
     280#if X0038_LAMBDA_FROM_QP_CAPABILITY
     281  in>>entry.m_QPOffsetModelOffset;
     282  in>>entry.m_QPOffsetModelScale;
     283#endif
    242284  in>>entry.m_CbQPoffset;
    243285  in>>entry.m_CrQPoffset;
    244 #endif
    245286  in>>entry.m_QPFactor;
    246287  in>>entry.m_tcOffsetDiv2;
     
    302343  }
    303344}
     345
     346#if NH_MV
     347static inline std::vector<ChromaFormat> numberToChromaFormat(const IntAry1d val)
     348{
     349  std::vector<ChromaFormat> chromaFormats;
     350  for( Int i = 0; i < val.size(); i++)
     351  {
     352    chromaFormats.push_back( numberToChromaFormat( val[i] ) );
     353  }
     354  return chromaFormats;
     355}
     356#endif
     357
    304358
    305359static const struct MapStrToProfile
     
    314368  {"main10",               Profile::MAIN10             },
    315369  {"main-still-picture",   Profile::MAINSTILLPICTURE   },
     370  {"main10-still-picture", Profile::MAIN10             },
    316371  {"main-RExt",            Profile::MAINREXT           },
    317372  {"high-throughput-RExt", Profile::HIGHTHROUGHPUTREXT }
    318373#if NH_MV
    319   ,{"multiview-main"     , Profile::MULTIVIEWMAIN      },
     374  ,{"multiview-main"     , Profile::MULTIVIEWMAIN      }
     375#if NH_MV_ALLOW_NON_CONFORMING
     376  ,{"multiview-main_NONCONFORMING", Profile::MULTIVIEWMAIN_NONCONFORMING }
    320377#if NH_3D
    321    {"3d-main"            , Profile::MAIN3D             }
     378  ,{"3d-main_NONCONFORMING"       , Profile::MAIN3D_NONCONFORMING }
     379#endif
     380#endif
     381#if NH_3D
     382   ,{"3d-main"                    , Profile::MAIN3D             }   
    322383#endif
    323384#endif
     
    325386};
    326387
    327 static const struct MapStrToExtendedProfile
     388static const struct MapStrToUIProfileName
    328389{
    329390  const TChar* str;
    330   ExtendedProfileName value;
     391  UIProfileName value;
    331392}
    332 strToExtendedProfile[] =
     393strToUIProfileName[] =
    333394{
    334     {"none",               NONE             },
    335     {"main",               MAIN             },
    336     {"main10",             MAIN10           },
    337     {"main_still_picture",        MAINSTILLPICTURE },
    338     {"main-still-picture",        MAINSTILLPICTURE },
    339     {"main_RExt",                 MAINREXT         },
    340     {"main-RExt",                 MAINREXT         },
    341     {"main_rext",                 MAINREXT         },
    342     {"main-rext",                 MAINREXT         },
    343     {"high_throughput_RExt",      HIGHTHROUGHPUTREXT },
    344     {"high-throughput-RExt",      HIGHTHROUGHPUTREXT },
    345     {"high_throughput_rext",      HIGHTHROUGHPUTREXT },
    346     {"high-throughput-rext",      HIGHTHROUGHPUTREXT },
    347 #if NH_MV
    348     {"multiview-main"     , MULTIVIEWMAIN   },
     395    {"none",                      UI_NONE             },
     396    {"main",                      UI_MAIN             },
     397    {"main10",                    UI_MAIN10           },
     398    {"main10_still_picture",      UI_MAIN10_STILL_PICTURE },
     399    {"main10-still-picture",      UI_MAIN10_STILL_PICTURE },
     400    {"main_still_picture",        UI_MAINSTILLPICTURE },
     401    {"main-still-picture",        UI_MAINSTILLPICTURE },
     402    {"main_RExt",                 UI_MAINREXT         },
     403    {"main-RExt",                 UI_MAINREXT         },
     404    {"main_rext",                 UI_MAINREXT         },
     405    {"main-rext",                 UI_MAINREXT         },
     406    {"high_throughput_RExt",      UI_HIGHTHROUGHPUTREXT },
     407    {"high-throughput-RExt",      UI_HIGHTHROUGHPUTREXT },
     408    {"high_throughput_rext",      UI_HIGHTHROUGHPUTREXT },
     409    {"high-throughput-rext",      UI_HIGHTHROUGHPUTREXT },
     410#if NH_MV
     411    {"multiview-main"     , UI_MULTIVIEWMAIN   },
    349412#if NH_3D
    350     {"3d-main"            , MAIN3D          },
    351 #endif
    352 #endif
    353     {"monochrome",         MONOCHROME_8     },
    354     {"monochrome12",       MONOCHROME_12    },
    355     {"monochrome16",       MONOCHROME_16    },
    356     {"main12",             MAIN_12          },
    357     {"main_422_10",        MAIN_422_10      },
    358     {"main_422_12",        MAIN_422_12      },
    359     {"main_444",           MAIN_444         },
    360     {"main_444_10",        MAIN_444_10      },
    361     {"main_444_12",        MAIN_444_12      },
    362     {"main_444_16",        MAIN_444_16      },
    363     {"main_intra",         MAIN_INTRA       },
    364     {"main_10_intra",      MAIN_10_INTRA    },
    365     {"main_12_intra",      MAIN_12_INTRA    },
    366     {"main_422_10_intra",  MAIN_422_10_INTRA},
    367     {"main_422_12_intra",  MAIN_422_12_INTRA},
    368     {"main_444_intra",     MAIN_444_INTRA   },
    369     {"main_444_still_picture",    MAIN_444_STILL_PICTURE },
    370     {"main_444_10_intra",  MAIN_444_10_INTRA},
    371     {"main_444_12_intra",  MAIN_444_12_INTRA},
    372     {"main_444_16_intra",         MAIN_444_16_INTRA},
    373     {"main_444_16_still_picture", MAIN_444_16_STILL_PICTURE }
     413    {"3d-main"            , UI_MAIN3D          },
     414#endif
     415#if NH_MV_ALLOW_NON_CONFORMING
     416    {"multiview-main_NONCONFORMING"     , UI_MULTIVIEWMAIN_NONCONF   },
     417#if NH_3D
     418    {"3d-main_NONCONFORMING"            , UI_MAIN3D_NONCONF          },
     419#endif
     420#endif
     421#endif
     422    {"monochrome",                UI_MONOCHROME_8     },
     423    {"monochrome12",              UI_MONOCHROME_12    },
     424    {"monochrome16",              UI_MONOCHROME_16    },
     425    {"main12",                    UI_MAIN_12          },
     426    {"main_422_10",               UI_MAIN_422_10      },
     427    {"main_422_12",               UI_MAIN_422_12      },
     428    {"main_444",                  UI_MAIN_444         },
     429    {"main_444_10",               UI_MAIN_444_10      },
     430    {"main_444_12",               UI_MAIN_444_12      },
     431    {"main_444_16",               UI_MAIN_444_16      },
     432    {"main_intra",                UI_MAIN_INTRA       },
     433    {"main_10_intra",             UI_MAIN_10_INTRA    },
     434    {"main_12_intra",             UI_MAIN_12_INTRA    },
     435    {"main_422_10_intra",         UI_MAIN_422_10_INTRA},
     436    {"main_422_12_intra",         UI_MAIN_422_12_INTRA},
     437    {"main_444_intra",            UI_MAIN_444_INTRA   },
     438    {"main_444_still_picture",    UI_MAIN_444_STILL_PICTURE },
     439    {"main_444_10_intra",         UI_MAIN_444_10_INTRA},
     440    {"main_444_12_intra",         UI_MAIN_444_12_INTRA},
     441    {"main_444_16_intra",         UI_MAIN_444_16_INTRA},
     442    {"main_444_16_still_picture", UI_MAIN_444_16_STILL_PICTURE },
     443    {"high_throughput_444",       UI_HIGHTHROUGHPUT_444    },
     444    {"high_throughput_444_10",    UI_HIGHTHROUGHPUT_444_10 },
     445    {"high_throughput_444_14",    UI_HIGHTHROUGHPUT_444_14 },
     446    {"high_throughput_444_16_intra", UI_HIGHTHROUGHPUT_444_16_INTRA }
    374447};
    375448
    376 static const ExtendedProfileName validRExtProfileNames[2/* intraConstraintFlag*/][4/* bit depth constraint 8=0, 10=1, 12=2, 16=3*/][4/*chroma format*/]=
     449static const UIProfileName validRExtHighThroughPutProfileNames[2/* intraConstraintFlag*/][4/* bit depth constraint 8=0, 10=1, 12=2, 16=3*/]=
    377450{
    378     {
    379         { MONOCHROME_8,  NONE,          NONE,              MAIN_444          }, // 8-bit  inter for 400, 420, 422 and 444
    380         { NONE,          NONE,          MAIN_422_10,       MAIN_444_10       }, // 10-bit inter for 400, 420, 422 and 444
    381         { MONOCHROME_12, MAIN_12,       MAIN_422_12,       MAIN_444_12       }, // 12-bit inter for 400, 420, 422 and 444
    382         { MONOCHROME_16, NONE,          NONE,              MAIN_444_16       }  // 16-bit inter for 400, 420, 422 and 444 (the latter is non standard used for development)
     451    { UI_HIGHTHROUGHPUT_444,          UI_HIGHTHROUGHPUT_444_10,          UI_HIGHTHROUGHPUT_444_14,         UI_NONE                         }, // intraConstraintFlag 0 - 8-bit,10-bit,14-bit and 16-bit
     452    { UI_NONE,                        UI_NONE,                           UI_NONE,                          UI_HIGHTHROUGHPUT_444_16_INTRA  }  // intraConstraintFlag 1 - 8-bit,10-bit,14-bit and 16-bit
     453};
     454
     455static const UIProfileName validRExtProfileNames[2/* intraConstraintFlag*/][4/* bit depth constraint 8=0, 10=1, 12=2, 16=3*/][4/*chroma format*/]=
     456{
     457    {
     458        { UI_MONOCHROME_8,  UI_NONE,          UI_NONE,              UI_MAIN_444          }, // 8-bit  inter for 400, 420, 422 and 444
     459        { UI_NONE,          UI_NONE,          UI_MAIN_422_10,       UI_MAIN_444_10       }, // 10-bit inter for 400, 420, 422 and 444
     460        { UI_MONOCHROME_12, UI_MAIN_12,       UI_MAIN_422_12,       UI_MAIN_444_12       }, // 12-bit inter for 400, 420, 422 and 444
     461        { UI_MONOCHROME_16, UI_NONE,          UI_NONE,              UI_MAIN_444_16       }  // 16-bit inter for 400, 420, 422 and 444 (the latter is non standard used for development)
    383462    },
    384463    {
    385         { NONE,          MAIN_INTRA,    NONE,              MAIN_444_INTRA    }, // 8-bit  intra for 400, 420, 422 and 444
    386         { NONE,          MAIN_10_INTRA, MAIN_422_10_INTRA, MAIN_444_10_INTRA }, // 10-bit intra for 400, 420, 422 and 444
    387         { NONE,          MAIN_12_INTRA, MAIN_422_12_INTRA, MAIN_444_12_INTRA }, // 12-bit intra for 400, 420, 422 and 444
    388         { NONE,          NONE,          NONE,              MAIN_444_16_INTRA }  // 16-bit intra for 400, 420, 422 and 444
     464        { UI_NONE,          UI_MAIN_INTRA,    UI_NONE,              UI_MAIN_444_INTRA    }, // 8-bit  intra for 400, 420, 422 and 444
     465        { UI_NONE,          UI_MAIN_10_INTRA, UI_MAIN_422_10_INTRA, UI_MAIN_444_10_INTRA }, // 10-bit intra for 400, 420, 422 and 444
     466        { UI_NONE,          UI_MAIN_12_INTRA, UI_MAIN_422_12_INTRA, UI_MAIN_444_12_INTRA }, // 12-bit intra for 400, 420, 422 and 444
     467        { UI_NONE,          UI_NONE,          UI_NONE,              UI_MAIN_444_16_INTRA }  // 16-bit intra for 400, 420, 422 and 444
    389468    }
    390469};
     
    425504};
    426505
    427 #if U0132_TARGET_BITS_SATURATION
    428506UInt g_uiMaxCpbSize[2][21] =
    429507{
     
    432510  { 0, 0, 0,      0, 0, 0,       0,       0, 0,       0,        0, 0, 30000000, 50000000, 0, 100000000, 160000000, 240000000, 240000000, 480000000, 800000000 }
    433511};
    434 #endif
    435512
    436513static const struct MapStrToCostMode
     
    481558  in >> str;
    482559
    483   for (UInt i = 0; i < mapLen; i++)
    484   {
    485     if (str == map[i].str)
     560  UInt i=0;
     561  for (; i < mapLen && str!=map[i].str; i++);
     562
     563  if (i < mapLen)
    486564    {
    487565      val = map[i].value;
    488       goto found;
    489     }
    490   }
    491   /* not found */
     566    }
     567  else
     568  {
    492569  in.setstate(ios::failbit);
    493 found:
     570  }
    494571  return in;
    495572}
     
    497574//inline to prevent compiler warnings for "unused static function"
    498575
    499 static inline istream& operator >> (istream &in, ExtendedProfileName &profile)
     576static inline istream& operator >> (istream &in, UIProfileName &profile)
    500577{
    501   return readStrToEnum(strToExtendedProfile, sizeof(strToExtendedProfile)/sizeof(*strToExtendedProfile), in, profile);
     578  return readStrToEnum(strToUIProfileName, sizeof(strToUIProfileName)/sizeof(*strToUIProfileName), in, profile);
    502579}
    503580
     
    640717}
    641718
     719#if JVET_E0059_FLOATING_POINT_QP_FIX
     720template <class T>
     721static inline istream& operator >> (std::istream &in, TAppEncCfg::OptionalValue<T> &value)
     722{
     723  in >> std::ws;
     724  if (in.eof())
     725  {
     726    value.bPresent=false;
     727  }
     728  else
     729  {
     730    in >> value.value;
     731    value.bPresent=true;
     732  }
     733  return in;
     734}
     735#endif
     736
    642737static Void
    643738automaticallySelectRExtProfile(const Bool bUsingGeneralRExtTools,
     
    740835#endif
    741836
     837#if NH_MV
     838  IntAry1d tmpInputChromaFormat;
     839  IntAry1d tmpChromaFormat;
     840#if NH_3D
     841  IntAry1d tmpChromaFormatInit;
     842  tmpChromaFormatInit.push_back(420);
     843  tmpChromaFormatInit.push_back(400);
     844#endif
     845  IntAry2d tmpPad(2);
     846
     847  IntAry2d tmpInputBitDepth      (2);
     848  IntAry2d tmpOutputBitDepth     (2);
     849  IntAry2d tmpMSBExtendedBitDepth(2);
     850  IntAry2d tmpInternalBitDepth   (2);
     851
     852#else
     853  Int tmpInputChromaFormat;
    742854  Int tmpChromaFormat;
    743   Int tmpInputChromaFormat;
    744855  Int tmpConstraintChromaFormat;
     856#endif
    745857  Int tmpWeightedPredictionMethod;
    746858  Int tmpFastInterSearchMode;
     
    751863  string inputColourSpaceConvert;
    752864#if NH_MV
    753   std::vector<ExtendedProfileName> extendedProfiles;
    754 #else
    755   ExtendedProfileName extendedProfile;
     865  std::vector<UIProfileName> UIProfiles;
     866#else
     867  UIProfileName UIProfile;
    756868#endif
    757869  Int saoOffsetBitShift[MAX_NUM_CHANNEL_TYPE];
     
    766878  SMultiValueInput<Double> cfg_adIntraLambdaModifier         (0, std::numeric_limits<Double>::max(), 0, MAX_TLAYER); ///< Lambda modifier for Intra pictures, one for each temporal layer. If size>temporalLayer, then use [temporalLayer], else if size>0, use [size()-1], else use m_adLambdaModifier.
    767879
     880  const Int defaultLumaLevelTodQp_QpChangePoints[]   =  {-3,  -2,  -1,   0,   1,   2,   3,   4,   5,   6};
     881  const Int defaultLumaLevelTodQp_LumaChangePoints[] =  { 0, 301, 367, 434, 501, 567, 634, 701, 767, 834};
     882  SMultiValueInput<Int>  cfg_lumaLeveltoDQPMappingQP         (-MAX_QP, MAX_QP,                    0, LUMA_LEVEL_TO_DQP_LUT_MAXSIZE, defaultLumaLevelTodQp_QpChangePoints,   sizeof(defaultLumaLevelTodQp_QpChangePoints  )/sizeof(Int));
     883  SMultiValueInput<Int>  cfg_lumaLeveltoDQPMappingLuma       (0, std::numeric_limits<Int>::max(), 0, LUMA_LEVEL_TO_DQP_LUT_MAXSIZE, defaultLumaLevelTodQp_LumaChangePoints, sizeof(defaultLumaLevelTodQp_LumaChangePoints)/sizeof(Int));
     884  UInt lumaLevelToDeltaQPMode;
    768885
    769886  const UInt defaultInputKneeCodes[3]  = { 600, 800, 900 };
     
    842959  ("ProfileTierLevelIdx_%d"        , m_profileTierLevelIdx         , IntAry1d(0)  , MAX_NUM_LAYERS,                  "Indices to profile level tier for ols")
    843960  // Layer dependencies
    844   ("DirectRefLayers_%d"            , m_directRefLayers             , IntAry1d(0,0), MAX_NUM_LAYERS,                  "LayerIdx in VPS of direct reference layers")
    845   ("DependencyTypes_%d"            , m_dependencyTypes             , IntAry1d(0,0), MAX_NUM_LAYERS,                  "Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion")
    846 #endif
     961  ("DirectRefLayers_%d"            , m_directRefLayers               , IntAry1d(0,0), MAX_NUM_LAYERS,                  "LayerIdx in VPS of direct reference layers")
     962  ("DependencyTypes_%d"            , m_dependencyTypes               , IntAry1d(0,0), MAX_NUM_LAYERS,                  "Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion")
     963  ("ShareParameterSets"            , m_shareParameterSets            , false        ,                                  "Signal parameter sets only in the base layer.") 
     964  ("LayerIdxInVpsToGopDefIdx"      , m_layerIdxInVpsToGopDefIdx      , IntAry1d(0,0),                                  "Maps the layers to the GOP definitions in the cfg-file.")
     965  ("LayerIdxInVpsToRepFormatIdx"   , m_layerIdxInVpsToRepFormatIdx   , IntAry1d(0,0),                                  "Maps the layers to the vps representation formats, i.e. values of SourceWidth, SourceHeight, InternalBitDepth, ChromaFormatIDC, InputBitDepth, OutputBitDepth, MSBExtendedBitDepth, InputChromaFormat, ConfWinBottom, ConfWinTop, ConfWinRight, ConfWinLeft, VerticalPadding, HorizontalPadding." ) 
     966#endif
     967#if NH_MV
     968  ("SourceWidth,-wdt",                                m_iSourceWidths,                            IntAry1d(1,0), "Source picture width")
     969  ("SourceHeight,-hgt",                               m_iSourceHeights,                           IntAry1d(1,0), "Source picture height")
     970  ("InputBitDepth",                                   tmpInputBitDepth      [CHANNEL_TYPE_LUMA  ], IntAry1d(1,8), "Bit-depth of input file")
     971  ("OutputBitDepth",                                  tmpOutputBitDepth     [CHANNEL_TYPE_LUMA  ], IntAry1d(1,0), "Bit-depth of output file (default:InternalBitDepth)")
     972  ("MSBExtendedBitDepth",                             tmpMSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ], IntAry1d(1,0), "bit depth of luma component after addition of MSBs of value 0 (used for synthesising High Dynamic Range source material). (default:InputBitDepth)")
     973  ("InternalBitDepth",                                tmpInternalBitDepth   [CHANNEL_TYPE_LUMA  ], IntAry1d(1,0), "Bit-depth the codec operates at. (default:MSBExtendedBitDepth). If different to MSBExtendedBitDepth, source data will be converted")
     974  ("InputBitDepthC",                                  tmpInputBitDepth      [CHANNEL_TYPE_CHROMA], IntAry1d(1,0), "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
     975  ("OutputBitDepthC",                                 tmpOutputBitDepth     [CHANNEL_TYPE_CHROMA], IntAry1d(1,0), "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
     976  ("MSBExtendedBitDepthC",                            tmpMSBExtendedBitDepth[CHANNEL_TYPE_CHROMA], IntAry1d(1,0), "As per MSBExtendedBitDepth but for chroma component. (default:MSBExtendedBitDepth)")
     977  ("InternalBitDepthC",                               tmpInternalBitDepth   [CHANNEL_TYPE_CHROMA], IntAry1d(1,0), "As per InternalBitDepth but for chroma component. (default:InternalBitDepth)")
     978#else
    847979  ("SourceWidth,-wdt",                                m_iSourceWidth,                                       0, "Source picture width")
    848980  ("SourceHeight,-hgt",                               m_iSourceHeight,                                      0, "Source picture height")
     
    855987  ("MSBExtendedBitDepthC",                            m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA],           0, "As per MSBExtendedBitDepth but for chroma component. (default:MSBExtendedBitDepth)")
    856988  ("InternalBitDepthC",                               m_internalBitDepth[CHANNEL_TYPE_CHROMA],              0, "As per InternalBitDepth but for chroma component. (default:InternalBitDepth)")
     989#endif
    857990  ("ExtendedPrecision",                               m_extendedPrecisionProcessingFlag,                false, "Increased internal accuracies to support high bit depths (not valid in V1 profiles)")
    858991  ("HighPrecisionPredictionWeighting",                m_highPrecisionOffsetsEnabledFlag,                false, "Use high precision option for weighted prediction (not valid in V1 profiles)")
     
    860993  ("SNRInternalColourSpace",                          m_snrInternalColourSpace,                         false, "If true, then no colour space conversion is applied prior to SNR, otherwise inverse of input is applied.")
    861994  ("OutputInternalColourSpace",                       m_outputInternalColourSpace,                      false, "If true, then no colour space conversion is applied for reconstructed video, otherwise inverse of input is applied.")
     995#if NH_MV
     996  ("InputChromaFormat",                               tmpInputChromaFormat,                   IntAry1d(1,420), "InputChromaFormatIDC")
     997#else
    862998  ("InputChromaFormat",                               tmpInputChromaFormat,                               420, "InputChromaFormatIDC")
     999#endif
    8631000  ("MSEBasedSequencePSNR",                            m_printMSEBasedSequencePSNR,                      false, "0 (default) emit sequence PSNR only as a linear average of the frame PSNRs, 1 = also emit a sequence PSNR based on an average of the frame MSEs")
    8641001  ("PrintFrameMSE",                                   m_printFrameMSE,                                  false, "0 (default) emit only bit count and PSNRs for each frame, 1 = also emit MSE values")
    8651002  ("PrintSequenceMSE",                                m_printSequenceMSE,                               false, "0 (default) emit only bit rate and PSNRs for the whole sequence, 1 = also emit MSE values")
     1003#if JVET_F0064_MSSSIM 
     1004  ("PrintMSSSIM",                                     m_printMSSSIM,                                    false, "0 (default) do not print MS-SSIM scores, 1 = print MS-SSIM scores for each frame and for the whole sequence")
     1005#endif
    8661006  ("CabacZeroWordPaddingEnabled",                     m_cabacZeroWordPaddingEnabled,                     true, "0 do not add conforming cabac-zero-words to bit streams, 1 (default) = add cabac-zero-words as required")
     1007#if NH_MV
     1008#if NH_3D
     1009  ("ChromaFormatIDC,-cf",                             tmpChromaFormat,                    tmpChromaFormatInit, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
     1010#else
     1011  ("ChromaFormatIDC,-cf",                             tmpChromaFormat,                          IntAry1d(1,0), "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
     1012#endif
     1013#else
    8671014  ("ChromaFormatIDC,-cf",                             tmpChromaFormat,                                      0, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
     1015#endif
    8681016  ("ConformanceMode",                                 m_conformanceWindowMode,                              0, "Deprecated alias of ConformanceWindowMode")
    8691017  ("ConformanceWindowMode",                           m_conformanceWindowMode,                              0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
     1018#if NH_MV
     1019  ("HorizontalPadding,-pdx",                          tmpPad[0] ,                               IntAry1d(1,0), "Horizontal source padding for conformance window mode 2")
     1020  ("VerticalPadding,-pdy",                            tmpPad[1] ,                               IntAry1d(1,0), "Vertical source padding for conformance window mode 2")
     1021#else
    8701022  ("HorizontalPadding,-pdx",                          m_aiPad[0],                                           0, "Horizontal source padding for conformance window mode 2")
    8711023  ("VerticalPadding,-pdy",                            m_aiPad[1],                                           0, "Vertical source padding for conformance window mode 2")
     1024#endif
     1025
     1026#if NH_MV
     1027  ("ConfWinLeft",                                     m_confWinLefts,                         IntAry1d(1, 0) , "Left offset for window conformance mode 3")
     1028  ("ConfWinRight",                                    m_confWinRights,                        IntAry1d(1, 0) , "Right offset for window conformance mode 3")
     1029  ("ConfWinTop",                                      m_confWinTops,                          IntAry1d(1, 0) , "Top offset for window conformance mode 3")
     1030  ("ConfWinBottom",                                   m_confWinBottoms,                       IntAry1d(1, 0) , "Bottom offset for window conformance mode 3")
     1031#else
    8721032  ("ConfLeft",                                        m_confWinLeft,                                        0, "Deprecated alias of ConfWinLeft")
    8731033  ("ConfRight",                                       m_confWinRight,                                       0, "Deprecated alias of ConfWinRight")
    8741034  ("ConfTop",                                         m_confWinTop,                                         0, "Deprecated alias of ConfWinTop")
    8751035  ("ConfBottom",                                      m_confWinBottom,                                      0, "Deprecated alias of ConfWinBottom")
     1036
    8761037  ("ConfWinLeft",                                     m_confWinLeft,                                        0, "Left offset for window conformance mode 3")
    8771038  ("ConfWinRight",                                    m_confWinRight,                                       0, "Right offset for window conformance mode 3")
    8781039  ("ConfWinTop",                                      m_confWinTop,                                         0, "Top offset for window conformance mode 3")
    8791040  ("ConfWinBottom",                                   m_confWinBottom,                                      0, "Bottom offset for window conformance mode 3")
     1041#endif
     1042 
    8801043  ("AccessUnitDelimiter",                             m_AccessUnitDelimiter,                            false, "Enable Access Unit Delimiter NALUs")
    8811044  ("FrameRate,-fr",                                   m_iFrameRate,                                         0, "Frame rate")
     
    9011064  ("Tier"    ,                                        cfg_tiers  ,                                 string(""), "Tier indication in VpsProfileTierLevel (Indication only)")
    9021065  ("InblFlag",                                        m_inblFlag ,                       std::vector<Bool>(0), "InblFlags in VpsProfileTierLevel (Indication only)" )
    903 #else
    904   ("Profile",                                         extendedProfile,                                   NONE, "Profile name to use for encoding. Use main (for main), main10 (for main10), main-still-picture, main-RExt (for Range Extensions profile), any of the RExt specific profile names, or none")
     1066
     1067  ("MaxBitDepthConstraint",                           m_bitDepthConstraints,           std::vector<Int>( 1,0u) , "Bit depth to use for profile-constraint for RExt profiles. 0=automatically choose based upon other parameters")
     1068  ("MaxChromaFormatConstraint",                       m_tmpConstraintChromaFormats,    IntAry1d(1,     0)       , "Chroma-format to use for the profile-constraint for RExt profiles. 0=automatically choose based upon other parameters")
     1069  ("IntraConstraintFlag",                             m_intraConstraintFlags,          BoolAry1d(1,false)       , "Value of general_intra_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
     1070  ("OnePictureOnlyConstraintFlag",                    m_onePictureOnlyConstraintFlags, BoolAry1d(1,false)       , "Value of general_one_picture_only_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
     1071  ("LowerBitRateConstraintFlag",                      m_lowerBitRateConstraintFlags,   BoolAry1d(1,true)        , "Value of general_lower_bit_rate_constraint_flag to use for RExt profiles")
     1072  ("ProgressiveSource",                               m_progressiveSourceFlags,        BoolAry1d(1,false)       , "Indicate that source is progressive")
     1073  ("InterlacedSource",                                m_interlacedSourceFlags,         BoolAry1d(1,false)       , "Indicate that source is interlaced")
     1074  ("NonPackedSource",                                 m_nonPackedConstraintFlags,      BoolAry1d(1,false)       , "Indicate that source does not contain frame packing")
     1075  ("FrameOnly",                                       m_frameOnlyConstraintFlags,      BoolAry1d(1,false)       , "Indicate that the bitstream contains only frames")
     1076
     1077#else
     1078  ("Profile",                                         UIProfile,                                      UI_NONE, "Profile name to use for encoding. Use main (for main), main10 (for main10), main-still-picture, main-RExt (for Range Extensions profile), any of the RExt specific profile names, or none")
    9051079  ("Level",                                           m_level,                                    Level::NONE, "Level limit to be used, eg 5.1, or none")
    9061080  ("Tier",                                            m_levelTier,                                Level::MAIN, "Tier to use for interpretation of --Level (main or high only)")
    907 #endif
    9081081  ("MaxBitDepthConstraint",                           m_bitDepthConstraint,                                0u, "Bit depth to use for profile-constraint for RExt profiles. 0=automatically choose based upon other parameters")
    9091082  ("MaxChromaFormatConstraint",                       tmpConstraintChromaFormat,                            0, "Chroma-format to use for the profile-constraint for RExt profiles. 0=automatically choose based upon other parameters")
     
    9111084  ("OnePictureOnlyConstraintFlag",                    m_onePictureOnlyConstraintFlag,                   false, "Value of general_one_picture_only_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
    9121085  ("LowerBitRateConstraintFlag",                      m_lowerBitRateConstraintFlag,                      true, "Value of general_lower_bit_rate_constraint_flag to use for RExt profiles")
    913 
    9141086  ("ProgressiveSource",                               m_progressiveSourceFlag,                          false, "Indicate that source is progressive")
    9151087  ("InterlacedSource",                                m_interlacedSourceFlag,                           false, "Indicate that source is interlaced")
    9161088  ("NonPackedSource",                                 m_nonPackedConstraintFlag,                        false, "Indicate that source does not contain frame packing")
    9171089  ("FrameOnly",                                       m_frameOnlyConstraintFlag,                        false, "Indicate that the bitstream contains only frames")
     1090
     1091#endif
     1092
    9181093
    9191094  // Unit definition parameters
     
    9391114  ("DecodingRefreshType,-dr",                         m_iDecodingRefreshType,                               0, "Intra refresh type (0:none 1:CRA 2:IDR 3:RecPointSEI)")
    9401115  ("GOPSize,g",                                       m_iGOPSize,                                           1, "GOP size of temporal structure")
     1116#if JCTVC_Y0038_PARAMS
     1117#if NH_MV
     1118  // To keep compatibility to legacy bit streams.
     1119  ("ReWriteParamSetsFlag",                            m_bReWriteParamSetsFlag,                           false, "Enable rewriting of Parameter sets before every (intra) random access point")
     1120#else
     1121  ("ReWriteParamSetsFlag",                            m_bReWriteParamSetsFlag,                           true, "Enable rewriting of Parameter sets before every (intra) random access point")
     1122#endif
     1123#endif
    9411124
    9421125  // motion search options
     
    9671150  ("LambdaModifier6,-LM6",                            m_adLambdaModifier[ 6 ],                  ( Double )1.0, "Lambda modifier for temporal layer 6. If LambdaModifierI is used, this will not affect intra pictures")
    9681151  ("LambdaModifierI,-LMI",                            cfg_adIntraLambdaModifier,    cfg_adIntraLambdaModifier, "Lambda modifiers for Intra pictures, comma separated, up to one the number of temporal layer. If entry for temporalLayer exists, then use it, else if some are specified, use the last, else use the standard LambdaModifiers.")
    969   ("IQPFactor,-IQF",                                  m_dIntraQpFactor,                                  -1.0, "Intra QP Factor for Lambda Computation. If negative, use the default equation: 0.57*(1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? (GopSize-1)/2 : GopSize-1) ))")
     1152  ("IQPFactor,-IQF",                                  m_dIntraQpFactor,                                  -1.0, "Intra QP Factor for Lambda Computation. If negative, the default will scale lambda based on GOP size (unless LambdaFromQpEnable then IntraQPOffset is used instead)")
    9701153
    9711154  /* Quantization parameters */
    9721155#if NH_MV
     1156#if JVET_E0059_FLOATING_POINT_QP_FIX
     1157  ("QP,q",                                            m_iQP,                                               std::vector<Int>(1,30)  , "Qp value")
     1158  ("QPIncrementFrame,-qpif",                          m_qpIncrementAtSourceFrame,                          std::vector<Int>( 0 ), "If a source file frame number is specified, the internal QP will be incremented for all POCs associated with source frames >= frame number. If empty, do not increment.")
     1159#else
    9731160  ("QP,q",          m_fQP, std::vector<double>(1,30.0), "Qp values for each layer, if value is float, QP is switched once during encoding")
     1161#endif
     1162#else
     1163#if JVET_E0059_FLOATING_POINT_QP_FIX
     1164  ("QP,q",                                            m_iQP,                                               30, "Qp value")
     1165  ("QPIncrementFrame,-qpif",                          m_qpIncrementAtSourceFrame,       OptionalValue<UInt>(), "If a source file frame number is specified, the internal QP will be incremented for all POCs associated with source frames >= frame number. If empty, do not increment.")
    9741166#else
    9751167  ("QP,q",                                            m_fQP,                                             30.0, "Qp value, if value is float, QP is switched once during encoding")
     1168#endif
     1169#endif
     1170#if X0038_LAMBDA_FROM_QP_CAPABILITY
     1171  ("IntraQPOffset",                                   m_intraQPOffset,                                      0, "Qp offset value for intra slice, typically determined based on GOP size")
     1172  ("LambdaFromQpEnable",                              m_lambdaFromQPEnable,                             false, "Enable flag for derivation of lambda from QP")
    9761173#endif
    9771174  ("DeltaQpRD,-dqr",                                  m_uiDeltaQpRD,                                       0u, "max dQp offset for slice")
     
    9811178  ("FastDeltaQP",                                     m_bFastDeltaQP,                                   false, "Fast Delta QP Algorithm")
    9821179
     1180  ("LumaLevelToDeltaQPMode",                          lumaLevelToDeltaQPMode,                              0u, "Luma based Delta QP 0(default): not used. 1: Based on CTU average, 2: Based on Max luma in CTU")
     1181  ("LumaLevelToDeltaQPMaxValWeight",                  m_lumaLevelToDeltaQPMapping.maxMethodWeight,        1.0, "Weight of block max luma val when LumaLevelToDeltaQPMode = 2")
     1182  ("LumaLevelToDeltaQPMappingLuma",                   cfg_lumaLeveltoDQPMappingLuma,  cfg_lumaLeveltoDQPMappingLuma, "Luma to Delta QP Mapping - luma thresholds")
     1183  ("LumaLevelToDeltaQPMappingDQP",                    cfg_lumaLeveltoDQPMappingQP,  cfg_lumaLeveltoDQPMappingQP, "Luma to Delta QP Mapping - DQP values")
    9831184  ("CbQpOffset,-cbqpofs",                             m_cbQpOffset,                                         0, "Chroma Cb QP Offset")
    9841185  ("CrQpOffset,-crqpofs",                             m_crQpOffset,                                         0, "Chroma Cr QP Offset")
    985 
    986 #if W0038_CQP_ADJ
    987   ("SliceChromaQPOffsetPeriodicity",                  m_sliceChromaQpOffsetPeriodicity,                    0u, "Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature.")
     1186  ("WCGPPSEnable",                                    m_wcgChromaQpControl.enabled,                     false, "1: Enable the WCG PPS chroma modulation scheme. 0 (default) disabled")
     1187  ("WCGPPSCbQpScale",                                 m_wcgChromaQpControl.chromaCbQpScale,               1.0, "WCG PPS Chroma Cb QP Scale")
     1188  ("WCGPPSCrQpScale",                                 m_wcgChromaQpControl.chromaCrQpScale,               1.0, "WCG PPS Chroma Cr QP Scale")
     1189  ("WCGPPSChromaQpScale",                             m_wcgChromaQpControl.chromaQpScale,                 0.0, "WCG PPS Chroma QP Scale")
     1190  ("WCGPPSChromaQpOffset",                            m_wcgChromaQpControl.chromaQpOffset,                0.0, "WCG PPS Chroma QP Offset")
     1191("SliceChromaQPOffsetPeriodicity",                  m_sliceChromaQpOffsetPeriodicity,                    0u, "Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature.")
    9881192  ("SliceCbQpOffsetIntraOrPeriodic",                  m_sliceChromaQpOffsetIntraOrPeriodic[0],              0, "Chroma Cb QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.")
    9891193  ("SliceCrQpOffsetIntraOrPeriodic",                  m_sliceChromaQpOffsetIntraOrPeriodic[1],              0, "Chroma Cr QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.")
    990 #endif
    9911194#if ADAPTIVE_QP_SELECTION
    9921195  ("AdaptiveQpSelection,-aqps",                       m_bUseAdaptQpSelect,                              false, "AdaptiveQpSelection")
     
    9981201  ("RDOQ",                                            m_useRDOQ,                                         true)
    9991202  ("RDOQTS",                                          m_useRDOQTS,                                       true)
    1000 #if T0196_SELECTIVE_RDOQ
    10011203  ("SelectiveRDOQ",                                   m_useSelectiveRDOQ,                               false, "Enable selective RDOQ")
    1002 #endif
    10031204  ("RDpenalty",                                       m_rdPenalty,                                          0,  "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disabled  1:RD-penalty  2:maximum RD-penalty")
    10041205
     
    10121213  ("LoopFilterBetaOffset_div2",                       m_loopFilterBetaOffsetDiv2,                           0)
    10131214  ("LoopFilterTcOffset_div2",                         m_loopFilterTcOffsetDiv2,                             0)
    1014 #if W0038_DB_OPT
    10151215  ("DeblockingFilterMetric",                          m_deblockingFilterMetric,                             0)
    1016 #else
    1017   ("DeblockingFilterMetric",                          m_DeblockingFilterMetric,                         false)
    1018 #endif
    10191216  // Coding tools
    10201217  ("AMP",                                             m_enableAMP,                                       true, "Enable asymmetric motion partitions")
     
    10421239  ("MaxNumOffsetsPerPic",                             m_maxNumOffsetsPerPic,                             2048, "Max number of SAO offset per picture (Default: 2048)")
    10431240  ("SAOLcuBoundary",                                  m_saoCtuBoundary,                                 false, "0: right/bottom CTU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
    1044 #if OPTIONAL_RESET_SAO_ENCODING_AFTER_IRAP
    10451241  ("SAOResetEncoderStateAfterIRAP",                   m_saoResetEncoderStateAfterIRAP,                  false, "When true, resets the encoder's SAO state after an IRAP (POC order). Disabled by default.")
    1046 #endif
    10471242  ("SliceMode",                                       tmpSliceMode,                            Int(NO_SLICES), "0: Disable all Recon slice limits, 1: Enforce max # of CTUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
    10481243  ("SliceArgument",                                   m_sliceArgument,                                      0, "Depending on SliceMode being:"
     
    10861281  ("ScalingList",                                     m_useScalingListId,                    SCALING_LIST_OFF, "0/off: no scaling list, 1/default: default scaling lists, 2/file: scaling lists specified in ScalingListFile")
    10871282  ("ScalingListFile",                                 m_scalingListFileName,                       string(""), "Scaling list file name. Use an empty string to produce help.")
    1088   ("SignHideFlag,-SBH",                               m_signHideFlag,                                    true)
     1283  ("SignHideFlag,-SBH",                               m_signDataHidingEnabledFlag,                                    true)
    10891284  ("MaxNumMergeCand",                                 m_maxNumMergeCand,                                   5u, "Maximum number of merge candidates")
    10901285  /* Misc. */
     
    11071302  ( "InitialQP",                                      m_RCInitialQP,                                        0, "Rate control: initial QP" )
    11081303  ( "RCForceIntraQP",                                 m_RCForceIntraQP,                                 false, "Rate control: force intra QP to be equal to initial QP" )
    1109 
    1110 #if U0132_TARGET_BITS_SATURATION
    11111304  ( "RCCpbSaturation",                                m_RCCpbSaturationEnabled,                         false, "Rate control: enable target bits saturation to avoid CPB overflow and underflow" )
    11121305  ( "RCCpbSize",                                      m_RCCpbSize,                                         0u, "Rate control: CPB size" )
    11131306  ( "RCInitialCpbFullness",                           m_RCInitialCpbFullness,                             0.9, "Rate control: initial CPB fullness" )
    1114 #endif
    1115 
    11161307#if KWU_RC_VIEWRC_E0227
    11171308  ("ViewWiseTargetBits, -vtbr" ,  m_viewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
     
    11501341#endif
    11511342
    1152   ("TransquantBypassEnableFlag",                      m_TransquantBypassEnableFlag,                     false, "transquant_bypass_enable_flag indicator in PPS")
    1153   ("CUTransquantBypassFlagForce",                     m_CUTransquantBypassFlagForce,                    false, "Force transquant bypass mode, when transquant_bypass_enable_flag is enabled")
     1343  ("TransquantBypassEnable",                          m_TransquantBypassEnabledFlag,                    false, "transquant_bypass_enabled_flag indicator in PPS")
     1344  ("TransquantBypassEnableFlag",                      m_TransquantBypassEnabledFlag,                    false, "deprecated alias for TransquantBypassEnable")
     1345  ("CUTransquantBypassFlagForce",                     m_CUTransquantBypassFlagForce,                    false, "Force transquant bypass mode, when transquant_bypass_enabled_flag is enabled")
    11541346  ("CostMode",                                        m_costMode,                         COST_STANDARD_LOSSY, "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).")
    11551347  ("RecalculateQPAccordingToLambda",                  m_recalculateQPAccordingToLambda,                 false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
     
    12631455  ("SEIScalableNesting",                              m_scalableNestingSEIEnabled,                      false, "Control generation of scalable nesting SEI messages")
    12641456  ("SEITempMotionConstrainedTileSets",                m_tmctsSEIEnabled,                                false, "Control generation of temporal motion constrained tile sets SEI message")
     1457#if MCTS_ENC_CHECK
     1458  ("SEITMCTSTileConstraint",                          m_tmctsSEITileConstraint,                         false, "Constrain motion vectors at tile boundaries")
     1459#endif
    12651460  ("SEITimeCodeEnabled",                              m_timeCodeSEIEnabled,                             false, "Control generation of time code information SEI message")
    12661461  ("SEITimeCodeNumClockTs",                           m_timeCodeSEINumTs,                                   0, "Number of clock time sets [0..3]")
     
    12961491  ("SEIMasteringDisplayPrimaries",                    cfg_DisplayPrimariesCode,       cfg_DisplayPrimariesCode, "Mastering display primaries for all three colour planes in CIE xy coordinates in increments of 1/50000 (results in the ranges 0 to 50000 inclusive)")
    12971492  ("SEIMasteringDisplayWhitePoint",                   cfg_DisplayWhitePointCode,     cfg_DisplayWhitePointCode, "Mastering display white point CIE xy coordinates in normalised increments of 1/50000 (e.g. 0.333 = 16667)")
    1298 #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
    12991493  ("SEIPreferredTransferCharacterisics",              m_preferredTransferCharacteristics,                   -1, "Value for the preferred_transfer_characteristics field of the Alternative transfer characteristics SEI which will override the corresponding entry in the VUI. If negative, do not produce the respective SEI message")
    1300 #endif
     1494  ("SEIGreenMetadataType",                            m_greenMetadataType,                   0u, "Value for the green_metadata_type specifies the type of metadata that is present in the SEI message. If green_metadata_type is 1, then metadata enabling quality recovery after low-power encoding is present")
     1495  ("SEIXSDMetricType",                                m_xsdMetricType,                      0u, "Value for the xsd_metric_type indicates the type of the objective quality metric. PSNR is the only type currently supported")
     1496
    13011497#if NH_MV
    13021498  ("SeiCfgFileName_%d",                               m_seiCfgFileNames,             (TChar *) 0 ,MAX_NUM_SEIS , "SEI cfg file name %d")
     
    13311527  ("DWeight",                                         m_iDWeight                , 1                             ,"Depth Distortion weight" )
    13321528#endif //HHI_VSO
     1529
     1530#if NH_3D
    13331531/* 3D- HEVC Tools */                                                           
    1334 #if NH_3D_QTL
    13351532  ("QTL"                   ,                          m_bUseQTL                 , true                          , "Use depth quad tree limitation (encoder only)" )
    1336 #endif
    1337 #if NH_3D
    13381533
    13391534  ("IvMvPredFlag"          ,                          m_ivMvPredFlag            , BoolAry1d(2,true)             , "Inter-view motion prediction"              )
     
    13551550  ("IlluCompEnable"        ,                          m_abUseIC                 , true                          , "Enable illumination compensation"          )
    13561551  ("IlluCompLowLatencyEnc" ,                          m_bUseLowLatencyICEnc     , false                         , "Enable low-latency illumination compensation encoding")
    1357 #endif //NH_3D
    1358    
     1552#endif //NH_3D   
    13591553  ;
    13601554
    1361 #if NH_MV
    1362   // parse coding structure
     1555#if EXTENSION_360_VIDEO
     1556  TExt360AppEncCfg::TExt360AppEncCfgContext ext360CfgContext;
     1557  m_ext360.addOptions(opts, ext360CfgContext);
     1558#endif
     1559
     1560
     1561#if NH_MV
    13631562  for( Int k = 0; k < MAX_NUM_LAYERS; k++ )
    13641563  {
     
    14141613  const list<const TChar*>& argv_unhandled = po::scanArgv(opts, argc, (const TChar**) argv, err);
    14151614
     1615
    14161616  for (list<const TChar*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
    14171617  {
     
    14351635  }
    14361636
     1637#if NH_MV
     1638  if ( m_layerIdxInVpsToRepFormatIdx.size() == 0 )
     1639  {
     1640    m_layerIdxInVpsToRepFormatIdx.push_back( 0 );
     1641#if NH_3D
     1642    m_layerIdxInVpsToRepFormatIdx.push_back( 1 );
     1643#endif
     1644  }
     1645
     1646  xResizeVector( m_layerIdxInVpsToRepFormatIdx );
     1647
     1648  // parse coding structure
     1649  if ( m_layerIdxInVpsToGopDefIdx.size() == 0 )
     1650  {
     1651    for( Int k = 0; k < m_numberOfLayers; k++ )
     1652    {
     1653      m_layerIdxInVpsToGopDefIdx.push_back( k );
     1654    }
     1655  }
     1656
     1657  xConvertRepFormatParameters(
     1658    tmpPad                       ,             
     1659    tmpInputBitDepth             ,
     1660    tmpOutputBitDepth            ,
     1661    tmpMSBExtendedBitDepth       ,
     1662    tmpInternalBitDepth          ,
     1663    tmpInputChromaFormat         ,
     1664    tmpChromaFormat
     1665    );
     1666#endif
    14371667  /*
    14381668   * Set any derived parameters
    14391669   */
     1670#if NH_MV
     1671  m_inputFileWidths  = m_iSourceWidths;
     1672  m_inputFileHeights = m_iSourceHeights;
     1673#else
     1674  m_inputFileWidth  = m_iSourceWidth;
     1675  m_inputFileHeight = m_iSourceHeight;
     1676#endif
    14401677
    14411678  m_framesToBeEncoded = ( m_framesToBeEncoded + m_temporalSubsampleRatio - 1 ) / m_temporalSubsampleRatio;
    14421679  m_adIntraLambdaModifier = cfg_adIntraLambdaModifier.values;
     1680
     1681#if NH_MV
     1682  m_iSourceHeightOrgs = m_iSourceHeights;
     1683#endif
    14431684  if(m_isField)
    14441685  {
     1686#if NH_MV
     1687    //Frame height
     1688    m_iSourceHeightOrgs = m_iSourceHeights;
     1689    //Field height
     1690    for (Int i = 0; i < m_iSourceHeights.size(); i++ )
     1691    {
     1692      m_iSourceHeights[i] = m_iSourceHeights[i] >> 1;
     1693    }
     1694#else
    14451695    //Frame height
    14461696    m_iSourceHeightOrg = m_iSourceHeight;
    14471697    //Field height
    14481698    m_iSourceHeight = m_iSourceHeight >> 1;
     1699#endif
    14491700    //number of fields to encode
    14501701    m_framesToBeEncoded *= 2;
     
    15031754  }
    15041755
     1756#if NH_MV
     1757  for (Int i = 0; i < m_numRepFormats; i++ )
     1758  {
     1759    Int* m_MSBExtendedBitDepth   = &m_MSBExtendedBitDepths[i][0];
     1760    Int* m_internalBitDepth      = &m_internalBitDepths   [i][0];
     1761    Int* m_outputBitDepth        = &m_outputBitDepths     [i][0];
     1762    Int* m_inputBitDepth         = &m_inputBitDepths      [i][0];
     1763#endif
    15051764  /* rules for input, output and internal bitdepths as per help text */
    15061765  if (m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] == 0)
     
    15331792  }
    15341793
     1794 
     1795#if NH_MV
     1796  }
    15351797  m_InputChromaFormatIDC = numberToChromaFormat(tmpInputChromaFormat);
     1798#endif
     1799
     1800
     1801#if NH_MV
     1802  std::vector<ChromaFormat> tempChromaFormatIdc = numberToChromaFormat(tmpChromaFormat);
     1803  for(Int i = 0 ; i < m_InputChromaFormatIDC.size(); i++)
     1804  {
     1805    m_chromaFormatIDCs.push_back( ((tmpChromaFormat[i] == 0) ? (m_InputChromaFormatIDC[i]) : tempChromaFormatIdc[i] ) );
     1806  }
     1807#else
    15361808  m_chromaFormatIDC      = ((tmpChromaFormat == 0) ? (m_InputChromaFormatIDC) : (numberToChromaFormat(tmpChromaFormat)));
    1537 
     1809#endif
     1810
     1811#if EXTENSION_360_VIDEO
     1812  m_ext360.processOptions(ext360CfgContext);
     1813#endif
    15381814
    15391815  assert(tmpWeightedPredictionMethod>=0 && tmpWeightedPredictionMethod<=WP_PER_PICTURE_WITH_HISTOGRAM_AND_PER_COMPONENT_AND_CLIPPING_AND_EXTENSION);
     
    15581834  m_motionEstimationSearchMethod=MESearchMethod(tmpMotionEstimationSearchMethod);
    15591835
    1560 #if NH_MV
    1561   // parse PTL
     1836#if NH_MV 
     1837
    15621838  Bool anyEmpty = false;
    15631839  if( cfg_profiles.empty() )
     
    16021878  }
    16031879
    1604   xReadStrToEnum( cfg_profiles, extendedProfiles  );
     1880  xReadStrToEnum( cfg_profiles, m_uiProfiles  );
    16051881  xReadStrToEnum( cfg_levels,   m_level     );
    16061882  xReadStrToEnum( cfg_tiers ,   m_levelTier );
    1607 
    1608 
    1609 #if NH_MV
    1610   m_profiles.resize( extendedProfiles.size());
    1611 
    1612   for (Int i = 0; i < m_profiles.size(); i++)
    1613   {
    1614     Profile::Name& m_profile             = m_profiles      [i]; 
    1615     ExtendedProfileName& extendedProfile = extendedProfiles[i]; 
    1616 #endif
    1617 #endif
    1618 
    1619   if (extendedProfile >= 1000 && extendedProfile <= 12316)
    1620     {
     1883   
     1884#else
     1885    switch (UIProfile)
     1886    {
     1887    case UI_NONE:
     1888      m_profile = Profile::NONE;
     1889      m_onePictureOnlyConstraintFlag = false;
     1890      break;
     1891    case UI_MAIN:
     1892      m_profile = Profile::MAIN;
     1893      m_onePictureOnlyConstraintFlag = false;
     1894      break;
     1895    case UI_MAIN10:
     1896      m_profile = Profile::MAIN10;
     1897      m_onePictureOnlyConstraintFlag = false;
     1898      break;
     1899    case UI_MAINSTILLPICTURE:
     1900      m_profile = Profile::MAINSTILLPICTURE;
     1901      m_onePictureOnlyConstraintFlag = false;
     1902      break;
     1903    case UI_MAIN10_STILL_PICTURE:
     1904      m_profile = Profile::MAIN10;
     1905      m_onePictureOnlyConstraintFlag = true;
     1906      break;
     1907    case UI_MAINREXT:
    16211908      m_profile = Profile::MAINREXT;
    1622       if (m_bitDepthConstraint != 0 || tmpConstraintChromaFormat != 0)
    1623       {
    1624         fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
    1625         exit(EXIT_FAILURE);
    1626       }
    1627       m_bitDepthConstraint     = (extendedProfile%100);
    1628     m_intraConstraintFlag          = ((extendedProfile%10000)>=2000);
    1629     m_onePictureOnlyConstraintFlag = (extendedProfile >= 10000);
    1630       switch ((extendedProfile/100)%10)
    1631       {
    1632       case 0:  tmpConstraintChromaFormat=400; break;
    1633       case 1:  tmpConstraintChromaFormat=420; break;
    1634       case 2:  tmpConstraintChromaFormat=422; break;
    1635       default: tmpConstraintChromaFormat=444; break;
    1636       }
    1637     }
    1638     else
    1639     {
    1640       m_profile = Profile::Name(extendedProfile);
    1641     }
    1642 
    1643     if (m_profile == Profile::HIGHTHROUGHPUTREXT )
    1644     {
    1645       if (m_bitDepthConstraint == 0)
    1646       {
    1647         m_bitDepthConstraint = 16;
    1648       }
    1649       m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? CHROMA_444 : numberToChromaFormat(tmpConstraintChromaFormat);
    1650     }
    1651     else if (m_profile == Profile::MAINREXT)
    1652     {
    1653       if (m_bitDepthConstraint == 0 && tmpConstraintChromaFormat == 0)
    1654       {
    1655         // produce a valid combination, if possible.
    1656       const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag        ||
    1657                                            m_transformSkipContextEnabledFlag         ||
    1658                                            m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT] ||
    1659                                            m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT] ||
    1660           !m_enableIntraReferenceSmoothing         ||
    1661                                            m_persistentRiceAdaptationEnabledFlag     ||
    1662                                            m_log2MaxTransformSkipBlockSize!=2;
    1663       const Bool bUsingChromaQPAdjustment= m_diffCuChromaQpOffsetDepth >= 0;
    1664       const Bool bUsingExtendedPrecision = m_extendedPrecisionProcessingFlag;
    1665       if (m_onePictureOnlyConstraintFlag)
    1666       {
    1667         m_chromaFormatConstraint = CHROMA_444;
    1668         if (m_intraConstraintFlag != true)
     1909      m_onePictureOnlyConstraintFlag = false;
     1910      break;
     1911    case UI_HIGHTHROUGHPUTREXT:
     1912      m_profile = Profile::HIGHTHROUGHPUTREXT;
     1913      m_onePictureOnlyConstraintFlag = false;
     1914      break;
     1915    default:
     1916      if (UIProfile >= 1000 && UIProfile <= 12316)
     1917      {
     1918        m_profile = Profile::MAINREXT;
     1919        if (m_bitDepthConstraint != 0 || tmpConstraintChromaFormat != 0)
    16691920        {
    1670           fprintf(stderr, "Error: Intra constraint flag must be true when one_picture_only_constraint_flag is true\n");
     1921          fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
    16711922          exit(EXIT_FAILURE);
    16721923        }
    1673         const Int maxBitDepth = m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
    1674         m_bitDepthConstraint = maxBitDepth>8 ? 16:8;
     1924        m_bitDepthConstraint           = (UIProfile%100);
     1925        m_intraConstraintFlag          = ((UIProfile%10000)>=2000);
     1926        m_onePictureOnlyConstraintFlag = (UIProfile >= 10000);
     1927        switch ((UIProfile/100)%10)
     1928        {
     1929        case 0:  tmpConstraintChromaFormat=400; break;
     1930        case 1:  tmpConstraintChromaFormat=420; break;
     1931        case 2:  tmpConstraintChromaFormat=422; break;
     1932        default: tmpConstraintChromaFormat=444; break;
     1933        }
     1934      }
     1935      else if (UIProfile >= 21308 && UIProfile <= 22316)
     1936      {
     1937        m_profile = Profile::HIGHTHROUGHPUTREXT;
     1938        if (m_bitDepthConstraint != 0 || tmpConstraintChromaFormat != 0)
     1939        {
     1940          fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
     1941          exit(EXIT_FAILURE);
     1942        }
     1943        m_bitDepthConstraint           = (UIProfile%100);
     1944        m_intraConstraintFlag          = ((UIProfile%10000)>=2000);
     1945        m_onePictureOnlyConstraintFlag = 0;
     1946        if((UIProfile == UI_HIGHTHROUGHPUT_444) || (UIProfile == UI_HIGHTHROUGHPUT_444_10) )
     1947        {
     1948          assert(m_cabacBypassAlignmentEnabledFlag==0);
     1949        }
     1950        switch ((UIProfile/100)%10)
     1951        {
     1952        case 0:  tmpConstraintChromaFormat=400; break;
     1953        case 1:  tmpConstraintChromaFormat=420; break;
     1954        case 2:  tmpConstraintChromaFormat=422; break;
     1955        default: tmpConstraintChromaFormat=444; break;
     1956        }
    16751957      }
    16761958      else
    16771959      {
    1678         m_chromaFormatConstraint = NUM_CHROMA_FORMAT;
    1679         automaticallySelectRExtProfile(bUsingGeneralRExtTools,
    1680           bUsingChromaQPAdjustment,
    1681           bUsingExtendedPrecision,
    1682           m_intraConstraintFlag,
    1683           m_bitDepthConstraint,
    1684           m_chromaFormatConstraint,
    1685           m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]),
    1686           m_chromaFormatIDC);
    1687       }
    1688     }
    1689       else if (m_bitDepthConstraint == 0 || tmpConstraintChromaFormat == 0)
    1690       {
    1691         fprintf(stderr, "Error: The bit depth and chroma format constraints must either both be specified or both be configured automatically\n");
     1960        fprintf(stderr, "Error: Unprocessed UI profile\n");
     1961        assert(0);
    16921962        exit(EXIT_FAILURE);
    16931963      }
    1694       else
    1695       {
    1696         m_chromaFormatConstraint = numberToChromaFormat(tmpConstraintChromaFormat);
    1697       }
    1698     }
    1699     else
    1700     {
     1964      break;
     1965    }
     1966
     1967    switch (m_profile)
     1968    {
     1969    case Profile::HIGHTHROUGHPUTREXT:
     1970      {
     1971        if (m_bitDepthConstraint == 0)
     1972        {
     1973          m_bitDepthConstraint = 16;
     1974        }
     1975        m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? CHROMA_444 : numberToChromaFormat(tmpConstraintChromaFormat);
     1976      }
     1977      break;
     1978    case Profile::MAINREXT:
     1979
     1980      {
     1981        if (m_bitDepthConstraint == 0 && tmpConstraintChromaFormat == 0)
     1982        {
     1983          // produce a valid combination, if possible.
     1984          const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag        ||
     1985            m_transformSkipContextEnabledFlag         ||
     1986            m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT] ||
     1987            m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT] ||
     1988            !m_enableIntraReferenceSmoothing         ||
     1989            m_persistentRiceAdaptationEnabledFlag     ||
     1990            m_log2MaxTransformSkipBlockSize!=2;
     1991          const Bool bUsingChromaQPAdjustment= m_diffCuChromaQpOffsetDepth >= 0;
     1992          const Bool bUsingExtendedPrecision = m_extendedPrecisionProcessingFlag;
     1993          if (m_onePictureOnlyConstraintFlag)
     1994          {
     1995            m_chromaFormatConstraint = CHROMA_444;
     1996            if (m_intraConstraintFlag != true)
     1997            {
     1998              fprintf(stderr, "Error: Intra constraint flag must be true when one_picture_only_constraint_flag is true\n");
     1999              exit(EXIT_FAILURE);
     2000            }
     2001            const Int maxBitDepth = m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     2002            m_bitDepthConstraint = maxBitDepth>8 ? 16:8;
     2003          }
     2004          else
     2005          {
     2006            m_chromaFormatConstraint = NUM_CHROMA_FORMAT;
     2007            automaticallySelectRExtProfile(bUsingGeneralRExtTools,
     2008              bUsingChromaQPAdjustment,
     2009              bUsingExtendedPrecision,
     2010              m_intraConstraintFlag,
     2011              m_bitDepthConstraint,
     2012              m_chromaFormatConstraint,
     2013              m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]),
     2014              m_chromaFormatIDC);
     2015          }
     2016        }
     2017        else if (m_bitDepthConstraint == 0 || tmpConstraintChromaFormat == 0)
     2018        {
     2019          fprintf(stderr, "Error: The bit depth and chroma format constraints must either both be specified or both be configured automatically\n");
     2020          exit(EXIT_FAILURE);
     2021        }
     2022        else
     2023        {
     2024          m_chromaFormatConstraint = numberToChromaFormat(tmpConstraintChromaFormat);
     2025        }
     2026      }
     2027      break;
     2028    case Profile::MAIN:
     2029    case Profile::MAIN10:
     2030    case Profile::MAINSTILLPICTURE:
    17012031      m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? m_chromaFormatIDC : numberToChromaFormat(tmpConstraintChromaFormat);
    17022032      m_bitDepthConstraint = (m_profile == Profile::MAIN10?10:8);
    1703     }
    1704 #if NH_MV
    1705   }
    1706 
    1707   if ( m_numberOfLayers != 0 && ( m_profiles[0] != Profile::MAIN || m_profiles[1] != Profile::MAIN )  )
    1708   {
    1709     fprintf(stderr, "Error: The base layer must conform to the Main profile for Multilayer coding.\n");
    1710     exit(EXIT_FAILURE);
    1711   }
    1712 #endif
    1713 
     2033      break;
     2034    case Profile::NONE:
     2035      m_chromaFormatConstraint = m_chromaFormatIDC;
     2036      m_bitDepthConstraint = m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     2037      break;
     2038    default:
     2039      fprintf(stderr, "Unknown profile selected\n");
     2040      exit(EXIT_FAILURE);
     2041      break;
     2042    }
     2043#endif
    17142044
    17152045  m_inputColourSpaceConvert = stringToInputColourSpaceConvert(inputColourSpaceConvert, true);
    17162046
     2047
     2048#if NH_MV
     2049  for (Int i = 0; i < m_numRepFormats; i++ )
     2050  {
     2051    Int*          m_aiPad            = &m_aiPads[i][0];
     2052    ChromaFormat &m_chromaFormatIDC  = m_chromaFormatIDCs [i];
     2053    Int          &m_confWinRight     = m_confWinRights    [i];
     2054    Int          &m_confWinBottom    = m_confWinBottoms   [i];
     2055    Int          &m_confWinLeft      = m_confWinLefts     [i];
     2056    Int          &m_confWinTop       = m_confWinTops      [i];
     2057    Int          &m_iSourceHeight    = m_iSourceHeights   [i];
     2058    Int          &m_iSourceWidth     = m_iSourceWidths    [i];
     2059    Int          &m_iSourceHeightOrg = m_iSourceHeightOrgs[i];
     2060#endif
    17172061  switch (m_conformanceWindowMode)
    17182062  {
     
    17792123    }
    17802124  }
     2125#if NH_MV
     2126  }
     2127#endif
    17812128
    17822129  if (tmpSliceMode<0 || tmpSliceMode>=Int(NUMBER_OF_SLICE_CONSTRAINT_MODES))
     
    18372184  xResizeVector( m_depthFlag );
    18382185#endif
     2186
     2187#if JVET_E0059_FLOATING_POINT_QP_FIX 
     2188  if ( !m_qpIncrementAtSourceFrame.empty() )
     2189  {
     2190    xResizeVector( m_qpIncrementAtSourceFrame );
     2191  }
     2192  xResizeVector( m_iQP );
     2193#else
    18392194  xResizeVector( m_fQP );
     2195#endif
    18402196
    18412197  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
     
    18442200    ::memset( m_aidQP[layer], 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
    18452201
     2202#if JVET_E0059_FLOATING_POINT_QP_FIX
     2203    if ( !m_qpIncrementAtSourceFrame.empty() )
     2204    {
     2205      UInt switchingPOC=0;
     2206      if (m_qpIncrementAtSourceFrame[layer] > m_FrameSkip)
     2207      {
     2208        // if switch source frame (ssf) = 10, and frame skip (fs)=2 and temporal subsample ratio (tsr) =1, then
     2209        //    for this simulation switch at POC 8 (=10-2).
     2210        // if ssf=10, fs=2, tsr=2, then for this simulation, switch at POC 4 (=(10-2)/2): POC0=Src2, POC1=Src4, POC2=Src6, POC3=Src8, POC4=Src10
     2211        switchingPOC = (m_qpIncrementAtSourceFrame[layer] - m_FrameSkip) / m_temporalSubsampleRatio;
     2212      }
     2213      for(UInt i=switchingPOC; i<( m_framesToBeEncoded + m_iGOPSize + 1 ); i++)
     2214      {
     2215        m_aidQP[layer][i]=1;
     2216      }
     2217    }
     2218#else
    18462219    // handling of floating-point QP values
    18472220    // if QP is not integer, sequence is split into two sections having QP and QP+1
     
    18572230      }
    18582231    }
     2232#endif
    18592233
    18602234    for(UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
     
    18622236      if (saoOffsetBitShift[ch]<0)
    18632237      {
     2238#if NH_MV
     2239        Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[ layer ];
     2240        if (m_internalBitDepths[repFormatIdx][ch]>10)
     2241#else
    18642242        if (m_internalBitDepth[ch]>10)
     2243#endif
    18652244        {
    1866           m_log2SaoOffsetScale[layer][ch]=UInt(Clip3<Int>(0, m_internalBitDepth[ch]-10, Int(m_internalBitDepth[ch]-10 + 0.165*m_iQP[layer] - 3.22 + 0.5) ) );
     2245          m_log2SaoOffsetScale[layer][ch]=UInt(Clip3<Int>(0, m_internalBitDepths[repFormatIdx][ch]-10, Int(m_internalBitDepths[repFormatIdx][ch]-10 + 0.165*m_iQP[layer] - 3.22 + 0.5) ) );
    18672246        }
    18682247        else
     
    18932272  ::memset( m_aidQP, 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
    18942273
     2274#if JVET_E0059_FLOATING_POINT_QP_FIX
     2275  if (m_qpIncrementAtSourceFrame.bPresent)
     2276  {
     2277    UInt switchingPOC=0;
     2278    if (m_qpIncrementAtSourceFrame.value > m_FrameSkip)
     2279    {
     2280      // if switch source frame (ssf) = 10, and frame skip (fs)=2 and temporal subsample ratio (tsr) =1, then
     2281      //    for this simulation switch at POC 8 (=10-2).
     2282      // if ssf=10, fs=2, tsr=2, then for this simulation, switch at POC 4 (=(10-2)/2): POC0=Src2, POC1=Src4, POC2=Src6, POC3=Src8, POC4=Src10
     2283      switchingPOC = (m_qpIncrementAtSourceFrame.value - m_FrameSkip) / m_temporalSubsampleRatio;
     2284    }
     2285    for(UInt i=switchingPOC; i<( m_framesToBeEncoded + m_iGOPSize + 1 ); i++)
     2286    {
     2287      m_aidQP[i]=1;
     2288    }
     2289  }
     2290#else
    18952291  // handling of floating-point QP values
    18962292  // if QP is not integer, sequence is split into two sections having QP and QP+1
     
    19062302    }
    19072303  }
     2304#endif
    19082305
    19092306  for(UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
     
    19272324
    19282325#endif
     2326
     2327  assert(lumaLevelToDeltaQPMode<LUMALVL_TO_DQP_NUM_MODES);
     2328  if (lumaLevelToDeltaQPMode>=LUMALVL_TO_DQP_NUM_MODES)
     2329  {
     2330    exit(EXIT_FAILURE);
     2331  }
     2332  m_lumaLevelToDeltaQPMapping.mode=LumaLevelToDQPMode(lumaLevelToDeltaQPMode);
     2333
     2334  if (m_lumaLevelToDeltaQPMapping.mode)
     2335  {
     2336    assert(  cfg_lumaLeveltoDQPMappingLuma.values.size() == cfg_lumaLeveltoDQPMappingQP.values.size() );
     2337    m_lumaLevelToDeltaQPMapping.mapping.resize(cfg_lumaLeveltoDQPMappingLuma.values.size());
     2338    for(UInt i=0; i<cfg_lumaLeveltoDQPMappingLuma.values.size(); i++)
     2339    {
     2340      m_lumaLevelToDeltaQPMapping.mapping[i]=std::pair<Int,Int>(cfg_lumaLeveltoDQPMappingLuma.values[i], cfg_lumaLeveltoDQPMappingQP.values[i]);
     2341    }
     2342  }
    19292343
    19302344  // reading external dQP description from file
     
    20702484    m_dLambdaScaleVSO *= adLambdaScaleTable[m_iQP[firstDepthLayer]];
    20712485  }
     2486
    20722487  if ( m_bUseVSO && m_uiVSOMode == 4)
    20732488  {
    20742489    m_cRenModStrParser.setString( m_iNumberOfViews, m_pchVSOConfig );
    20752490    m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ),
    2076       m_internalBitDepth[ CHANNEL_TYPE_LUMA],
     2491      m_internalBitDepths[0][ CHANNEL_TYPE_LUMA],
    20772492      (UInt)m_iCodedCamParPrecision,
    20782493      m_FrameSkip,
     
    20872502  {
    20882503    m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ),
    2089       m_internalBitDepth[ CHANNEL_TYPE_LUMA],
     2504      m_internalBitDepths[0][ CHANNEL_TYPE_LUMA],
    20902505      (UInt)m_iCodedCamParPrecision,
    20912506      m_FrameSkip,
     
    21022517  {
    21032518    m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ),
    2104       m_internalBitDepth[ CHANNEL_TYPE_LUMA],
     2519      m_internalBitDepths[0][ CHANNEL_TYPE_LUMA],
    21052520      (UInt) m_iCodedCamParPrecision,
    21062521      m_FrameSkip,
     
    21252540  }
    21262541
    2127   m_uiMaxTotalCUDepth = m_uiMaxCUDepth + uiAddCUDepth + getMaxCUDepthOffset(m_chromaFormatIDC, m_uiQuadtreeTULog2MinSize); // if minimum TU larger than 4x4, allow for additional part indices for 4:2:2 SubTUs.
     2542
     2543#if NH_MV
     2544  for (Int i = 0; i < m_numRepFormats; i++ )
     2545  {
     2546    m_uiMaxTotalCUDepth               .push_back( m_uiMaxCUDepth + uiAddCUDepth + getMaxCUDepthOffset(m_chromaFormatIDCs[i], m_uiQuadtreeTULog2MinSize) ); // if minimum TU larger than 4x4, allow for additional part indices for 4:2:2 SubTUs.   
     2547  }
     2548#else
     2549  m_uiMaxTotalCUDepth = m_uiMaxCUDepth + uiAddCUDepth + getMaxCUDepthOffset(m_chromaFormatIDC, m_uiQuadtreeTULog2MinSize); // if minimum TU larger than 4x4, allow for additional part indices for 4:2:2 SubTUs. 
     2550#endif
     2551
    21282552  m_uiLog2DiffMaxMinCodingBlockSize = m_uiMaxCUDepth - 1;
    21292553
     
    21342558}
    21352559
     2560#if NH_MV
     2561Void TAppEncCfg::xDeriveProfAndConstrFlags( const TComVPS& vps )
     2562{
     2563
     2564  UInt numPtl = (Int) m_uiProfiles.size();
     2565  m_profiles.resize( numPtl );
     2566  m_chromaFormatConstraints.resize( m_uiProfiles.size() );
     2567 
     2568  xResizeVector( m_onePictureOnlyConstraintFlags , numPtl );
     2569  xResizeVector( m_bitDepthConstraints           , numPtl );
     2570  xResizeVector( m_frameOnlyConstraintFlags      , numPtl );
     2571  xResizeVector( m_nonPackedConstraintFlags      , numPtl );
     2572  xResizeVector( m_intraConstraintFlags          , numPtl ); 
     2573  xResizeVector( m_interlacedSourceFlags         , numPtl );
     2574  xResizeVector( m_progressiveSourceFlags        , numPtl );
     2575  xResizeVector( m_lowerBitRateConstraintFlags   , numPtl );
     2576  xResizeVector( m_tmpConstraintChromaFormats    , numPtl );
     2577
     2578  for (Int i = 0; i < m_profiles.size(); i++)
     2579  {
     2580    UIProfileName UIProfile = m_uiProfiles[i];
     2581
     2582    ChromaFormat maxChromaFormatIdc       ;
     2583    Int          maxInternalBitDepthLuma  ;
     2584    Int          maxInternalBitDepthChroma;
     2585    Int          maxNumRefLayers          ;
     2586
     2587    xGetMaxValuesOfApplicableLayers(vps, i, maxInternalBitDepthLuma,maxInternalBitDepthChroma, maxChromaFormatIdc, maxNumRefLayers );
     2588
     2589    switch ( UIProfile )
     2590    {
     2591    case UI_MULTIVIEWMAIN:
     2592      m_profiles[i] = Profile::MULTIVIEWMAIN;
     2593      m_onePictureOnlyConstraintFlags[i] = false;
     2594      break;
     2595#if NH_3D
     2596    case UI_MAIN3D:
     2597      m_profiles[i] = Profile::MAIN3D;
     2598      m_onePictureOnlyConstraintFlags[i] = false;
     2599      break;
     2600#endif
     2601    case UI_NONE:
     2602      m_profiles[i] = Profile::NONE;
     2603      m_onePictureOnlyConstraintFlags[i] = false;
     2604      break;
     2605    case UI_MAIN:
     2606      m_profiles[i] = Profile::MAIN;
     2607      m_onePictureOnlyConstraintFlags[i] = false;
     2608      break;
     2609    case UI_MAIN10:
     2610      m_profiles[i] = Profile::MAIN10;
     2611      m_onePictureOnlyConstraintFlags[i] = false;
     2612      break;
     2613    case UI_MAINSTILLPICTURE:
     2614      m_profiles[i] = Profile::MAINSTILLPICTURE;
     2615      m_onePictureOnlyConstraintFlags[i] = false;
     2616      break;
     2617    case UI_MAIN10_STILL_PICTURE:
     2618      m_profiles[i] = Profile::MAIN10;
     2619      m_onePictureOnlyConstraintFlags[i] = true;
     2620      break;
     2621    case UI_MAINREXT:
     2622      m_profiles[i] = Profile::MAINREXT;
     2623      m_onePictureOnlyConstraintFlags[i] = false;
     2624      break;
     2625    case UI_HIGHTHROUGHPUTREXT:
     2626      m_profiles[i] = Profile::HIGHTHROUGHPUTREXT;
     2627      m_onePictureOnlyConstraintFlags[i] = false;
     2628      break;
     2629#if NH_MV_ALLOW_NON_CONFORMING
     2630    case UI_MULTIVIEWMAIN_NONCONF:
     2631      m_profiles[i] = Profile::MULTIVIEWMAIN_NONCONFORMING;
     2632      m_onePictureOnlyConstraintFlags[i] = false;
     2633      break;
     2634#if NH_3D
     2635    case UI_MAIN3D_NONCONF:
     2636      m_profiles[i] = Profile::MAIN3D_NONCONFORMING;
     2637      m_onePictureOnlyConstraintFlags[i] = false;
     2638      break;
     2639#endif
     2640#endif
     2641
     2642    default:
     2643      if (UIProfile >= 1000 && UIProfile <= 12316)
     2644      {
     2645        m_profiles[i] = Profile::MAINREXT;
     2646        if (m_bitDepthConstraints[i] != 0 || m_tmpConstraintChromaFormats[i] != 0)
     2647        {
     2648          fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
     2649          exit(EXIT_FAILURE);
     2650        }
     2651        m_bitDepthConstraints[i]           = (UIProfile%100);
     2652        m_intraConstraintFlags[i]          = ((UIProfile%10000)>=2000);
     2653        m_onePictureOnlyConstraintFlags[i] = (UIProfile >= 10000);
     2654        switch ((UIProfile/100)%10)
     2655        {
     2656        case 0:  m_tmpConstraintChromaFormats[i]=400; break;
     2657        case 1:  m_tmpConstraintChromaFormats[i]=420; break;
     2658        case 2:  m_tmpConstraintChromaFormats[i]=422; break;
     2659        default: m_tmpConstraintChromaFormats[i]=444; break;
     2660        }
     2661      }
     2662      else if (UIProfile >= 21308 && UIProfile <= 22316)
     2663      {
     2664        m_profiles[i] = Profile::HIGHTHROUGHPUTREXT;
     2665        if (m_bitDepthConstraints[i] != 0 || m_tmpConstraintChromaFormats[i] != 0)
     2666        {
     2667          fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
     2668          exit(EXIT_FAILURE);
     2669        }
     2670        m_bitDepthConstraints[i]           = (UIProfile%100);
     2671        m_intraConstraintFlags[i]          = ((UIProfile%10000)>=2000);
     2672        m_onePictureOnlyConstraintFlags[i] = 0;
     2673        if((UIProfile == UI_HIGHTHROUGHPUT_444) || (UIProfile == UI_HIGHTHROUGHPUT_444_10) )
     2674        {
     2675          assert(m_cabacBypassAlignmentEnabledFlag==0);
     2676        }
     2677        switch ((UIProfile/100)%10)
     2678        {
     2679        case 0:  m_tmpConstraintChromaFormats[i]=400; break;
     2680        case 1:  m_tmpConstraintChromaFormats[i]=420; break;
     2681        case 2:  m_tmpConstraintChromaFormats[i]=422; break;
     2682        default: m_tmpConstraintChromaFormats[i]=444; break;
     2683        }
     2684      }
     2685      else
     2686      {
     2687        fprintf(stderr, "Error: Unprocessed UI profile\n");
     2688        assert(0);
     2689        exit(EXIT_FAILURE);
     2690      }
     2691      break;
     2692    }
     2693
     2694    switch (m_profiles[i])
     2695    {
     2696    case Profile::HIGHTHROUGHPUTREXT:
     2697      {
     2698        if (m_bitDepthConstraints[i] == 0)
     2699        {
     2700          m_bitDepthConstraints[i] = 16;
     2701        }
     2702        m_chromaFormatConstraints[i] = (m_tmpConstraintChromaFormats[i] == 0) ? CHROMA_444 : numberToChromaFormat(m_tmpConstraintChromaFormats[i]);
     2703      }
     2704      break;
     2705    case Profile::MAINREXT:
     2706
     2707      {
     2708        if (m_bitDepthConstraints[i] == 0 && m_tmpConstraintChromaFormats[i] == 0)
     2709        {
     2710          // produce a valid combination, if possible.
     2711          const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag        ||
     2712            m_transformSkipContextEnabledFlag         ||
     2713            m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT] ||
     2714            m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT] ||
     2715            !m_enableIntraReferenceSmoothing         ||
     2716            m_persistentRiceAdaptationEnabledFlag     ||
     2717            m_log2MaxTransformSkipBlockSize!=2;
     2718          const Bool bUsingChromaQPAdjustment= m_diffCuChromaQpOffsetDepth >= 0;
     2719          const Bool bUsingExtendedPrecision = m_extendedPrecisionProcessingFlag;
     2720          if (m_onePictureOnlyConstraintFlags[i])
     2721          {
     2722            m_chromaFormatConstraints[i] = CHROMA_444;
     2723            if (m_intraConstraintFlags[i] != true)
     2724            {
     2725              fprintf(stderr, "Error: Intra constraint flag must be true when one_picture_only_constraint_flag is true\n");
     2726              exit(EXIT_FAILURE);
     2727            }
     2728            const Int maxBitDepth = maxChromaFormatIdc==CHROMA_400 ? maxInternalBitDepthLuma : std::max( maxInternalBitDepthLuma, maxInternalBitDepthChroma);
     2729            m_bitDepthConstraints[i] = maxBitDepth>8 ? 16:8;
     2730          }
     2731          else
     2732          {
     2733            m_chromaFormatConstraints[i] = NUM_CHROMA_FORMAT;
     2734
     2735            UInt tempBitDepthConstraint = (UInt) m_bitDepthConstraints[i];
     2736
     2737            automaticallySelectRExtProfile(bUsingGeneralRExtTools,
     2738              bUsingChromaQPAdjustment,
     2739              bUsingExtendedPrecision,
     2740              m_intraConstraintFlags[i],
     2741              tempBitDepthConstraint,
     2742              m_chromaFormatConstraints[i],
     2743              maxChromaFormatIdc==CHROMA_400 ? maxInternalBitDepthLuma : std::max(maxInternalBitDepthLuma, maxInternalBitDepthChroma),
     2744              maxChromaFormatIdc);
     2745
     2746            m_bitDepthConstraints[i] = (Int) tempBitDepthConstraint;
     2747          }
     2748        }
     2749        else if (m_bitDepthConstraints[i] == 0 || m_tmpConstraintChromaFormats[i] == 0)
     2750        {
     2751          fprintf(stderr, "Error: The bit depth and chroma format constraints must either both be specified or both be configured automatically\n");
     2752          exit(EXIT_FAILURE);
     2753        }
     2754        else
     2755        {
     2756          m_chromaFormatConstraints[i] = numberToChromaFormat(m_tmpConstraintChromaFormats[i]);
     2757        }
     2758      }
     2759      break;
     2760    case Profile::MAIN:
     2761    case Profile::MAIN10:
     2762    case Profile::MAINSTILLPICTURE:
     2763      m_chromaFormatConstraints[i] = (m_tmpConstraintChromaFormats[i] == 0) ? maxChromaFormatIdc : numberToChromaFormat(m_tmpConstraintChromaFormats[i]);
     2764      m_bitDepthConstraints[i] = (m_profiles[i] == Profile::MAIN10?10:8);
     2765      break;
     2766#if NH_MV_ALLOW_NON_CONFORMING
     2767    case Profile::MULTIVIEWMAIN_NONCONFORMING:
     2768#if NH_3D
     2769    case Profile::MAIN3D_NONCONFORMING:
     2770#endif
     2771#endif
     2772    case Profile::NONE:
     2773
     2774      m_chromaFormatConstraints[i] = maxChromaFormatIdc;
     2775      m_bitDepthConstraints[i]     = maxChromaFormatIdc==CHROMA_400 ? maxInternalBitDepthLuma : std::max(maxInternalBitDepthLuma, maxInternalBitDepthChroma);
     2776      break;
     2777    case Profile::MULTIVIEWMAIN:
     2778      m_chromaFormatConstraints[i] = CHROMA_420;
     2779      m_bitDepthConstraints[i]     = 8;
     2780      break;
     2781
     2782#if NH_3D
     2783    case Profile::MAIN3D:
     2784      // Here depth layers could use a different ptl struct.
     2785      // For simplicity, depth and texture share currently the same.
     2786      m_chromaFormatConstraints[i] = CHROMA_420;
     2787      m_bitDepthConstraints[i]     = 8;
     2788      break;
     2789#endif
     2790    default:
     2791      fprintf(stderr, "Unknown profile selected\n");
     2792      exit(EXIT_FAILURE);
     2793      break;
     2794    }
     2795  }
     2796}
     2797#endif
    21362798
    21372799// ====================================================================================================================
    21382800// Private member functions
    21392801// ====================================================================================================================
     2802
     2803#if NH_MV
     2804Void TAppEncCfg::xCheckProfiles( const TComVPS& vps )
     2805{
     2806  Bool check_failed = false;
     2807
     2808
     2809#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
     2810
     2811  // TBD: disallow 3D tools when 3D Main profile is not used.
     2812
     2813  for (Int i = 0; i < m_profiles.size(); i++ )
     2814  {
     2815    ChromaFormat maxChromaFormatIdc;
     2816    Int          maxBitDepthLuma   ;
     2817    Int          maxBitDepthChroma ;
     2818    Int          maxNumRefLayers   ;
     2819
     2820    xGetMaxValuesOfApplicableLayers(vps, i, maxBitDepthLuma, maxBitDepthChroma , maxChromaFormatIdc, maxNumRefLayers );
     2821
     2822    const UInt maxBitDepth=(maxChromaFormatIdc==CHROMA_400) ? maxBitDepthLuma : std::max(maxBitDepthLuma, maxBitDepthChroma);
     2823
     2824    xConfirmPara(m_bitDepthConstraints    [i] < maxBitDepth       , "The internalBitDepth must not be greater than the bitDepthConstraint value"      );
     2825    xConfirmPara(m_chromaFormatConstraints[i] < maxChromaFormatIdc, "The chroma format used must not be greater than the chromaFormatConstraint value");
     2826
     2827    switch (m_profiles[i] )
     2828    {
     2829    case Profile::MAINREXT:
     2830    case Profile::HIGHTHROUGHPUTREXT:
     2831
     2832      {
     2833        xConfirmPara(m_lowerBitRateConstraintFlags[i] == false  &&  m_intraConstraintFlags[i] == false                        , "The lowerBitRateConstraint flag cannot be false when intraConstraintFlag is false");
     2834        xConfirmPara(m_cabacBypassAlignmentEnabledFlag          &&              m_profiles[i] != Profile::HIGHTHROUGHPUTREXT  , "AlignCABACBeforeBypass must not be enabled unless the high throughput profile is being used.");
     2835
     2836        if (m_profiles[i] == Profile::MAINREXT)
     2837        {
     2838          const UInt intraIdx        = m_intraConstraintFlags[i] ? 1:0;
     2839          const UInt bitDepthIdx     = (m_bitDepthConstraints[i] == 8 ? 0 : (m_bitDepthConstraints[i] ==10 ? 1 : (m_bitDepthConstraints[i] == 12 ? 2 : (m_bitDepthConstraints[i] == 16 ? 3 : 4 ))));
     2840          const UInt chromaFormatIdx = UInt(m_chromaFormatConstraints[i]);
     2841          const Bool bValidProfile   = (bitDepthIdx > 3 || chromaFormatIdx>3) ? false : (validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx] != UI_NONE);
     2842
     2843          xConfirmPara(!bValidProfile, "Invalid intra constraint flag, bit depth constraint flag and chroma format constraint flag combination for a RExt profile");
     2844          const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag   ||
     2845            m_transformSkipContextEnabledFlag                                       ||
     2846            m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT]                               ||
     2847            m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT]                               ||
     2848            !m_enableIntraReferenceSmoothing                                        ||
     2849            m_persistentRiceAdaptationEnabledFlag                                   ||
     2850            m_log2MaxTransformSkipBlockSize!=2;
     2851          const Bool bUsingChromaQPTool      = m_diffCuChromaQpOffsetDepth >= 0;
     2852          const Bool bUsingExtendedPrecision = m_extendedPrecisionProcessingFlag;
     2853
     2854          xConfirmPara((m_chromaFormatConstraints[i]==CHROMA_420 || m_chromaFormatConstraints[i]==CHROMA_400) && bUsingChromaQPTool, "CU Chroma QP adjustment cannot be used for 4:0:0 or 4:2:0 RExt profiles");
     2855          xConfirmPara(m_bitDepthConstraints[i] != 16 && bUsingExtendedPrecision, "Extended precision can only be used in 16-bit RExt profiles");
     2856          if (!(m_chromaFormatConstraints[i] == CHROMA_400 && m_bitDepthConstraints[i] == 16) && m_chromaFormatConstraints[i]!=CHROMA_444)
     2857          {
     2858            xConfirmPara(bUsingGeneralRExtTools, "Combination of tools and profiles are not possible in the specified RExt profile.");
     2859          }
     2860          xConfirmPara( m_onePictureOnlyConstraintFlags[i] && m_chromaFormatConstraints[i]!=CHROMA_444, "chroma format constraint must be 4:4:4 when one-picture-only constraint flag is 1");
     2861          xConfirmPara( m_onePictureOnlyConstraintFlags[i] && m_bitDepthConstraints[i] != 8 && m_bitDepthConstraints[i] != 16, "bit depth constraint must be 8 or 16 when one-picture-only constraint flag is 1");
     2862          xConfirmPara( m_onePictureOnlyConstraintFlags[i] && m_framesToBeEncoded > 1, "Number of frames to be encoded must be 1 when one-picture-only constraint flag is 1.");
     2863
     2864          if (!m_intraConstraintFlags[i] && m_bitDepthConstraints[i]==16 && m_chromaFormatConstraints[i]==CHROMA_444)
     2865          {
     2866            fprintf(stderr, "********************************************************************************************************\n");
     2867            fprintf(stderr, "** WARNING: The RExt constraint flags describe a non standard combination (used for development only) **\n");
     2868            fprintf(stderr, "********************************************************************************************************\n");
     2869          }
     2870        }
     2871        else
     2872        {
     2873          xConfirmPara( m_chromaFormatConstraints[i] != CHROMA_444, "chroma format constraint must be 4:4:4 in the High Throughput 4:4:4 16-bit Intra profile.");
     2874          const UInt intraIdx      =   m_intraConstraintFlags[i]     ? 1     : 0;
     2875          const UInt bitDepthIdx   = ( m_bitDepthConstraints[i] == 8 ? 0     : (m_bitDepthConstraints[i] == 10 ? 1 : (m_bitDepthConstraints[i] == 14 ? 2 : (m_bitDepthConstraints[i] == 16 ? 3 : 4 ))));
     2876          const Bool bValidProfile = ( bitDepthIdx > 3)              ? false : (validRExtHighThroughPutProfileNames[intraIdx][bitDepthIdx] != UI_NONE);
     2877          xConfirmPara(!bValidProfile, "Invalid intra constraint flag and bit depth constraint flag combination for a RExt high profile throughput profile");
     2878          if(bitDepthIdx < 2)
     2879          {
     2880            xConfirmPara((m_extendedPrecisionProcessingFlag || m_cabacBypassAlignmentEnabledFlag), "Invalid configuration for a RExt high throughput 8 and 10 bit profile");
     2881          }
     2882          if(bitDepthIdx == 3)
     2883          {
     2884            xConfirmPara(!m_cabacBypassAlignmentEnabledFlag, "Cabac Bypass Alignment flag must be 1 in the High Throughput 4:4:4 16-bit Intra profile");
     2885          }
     2886          else if(bitDepthIdx < 3)
     2887          {
     2888            xConfirmPara(!m_entropyCodingSyncEnabledFlag, "WPP flag must be 1 in the High Throughput 4:4:4 non 16-bit Intra profile");
     2889          }
     2890        }
     2891      }
     2892      break;
     2893    case Profile::MAIN:
     2894    case Profile::MAIN10:
     2895    case Profile::MAINSTILLPICTURE:
     2896    case Profile::MULTIVIEWMAIN:
     2897#if NH_3D
     2898    case Profile::MAIN3D:
     2899#endif
     2900      {
     2901        xConfirmPara(m_bitDepthConstraints        [i] != ((m_profiles[i]==Profile::MAIN10)?10:8), "BitDepthConstraint must be 8 for MAIN profile, Multiview main profile, and 3D Main profile and 10 for MAIN10 profile.");
     2902#if NH_3D
     2903        if (m_profiles[i] == Profile::MAIN3D )
     2904        {
     2905          xConfirmPara(m_chromaFormatConstraints    [i] != CHROMA_420 && m_chromaFormatConstraints    [i] != CHROMA_400   , "ChromaFormatConstraint must be 420 or 400 for the 3D main profile.");
     2906        }
     2907        else
     2908#endif
     2909        {
     2910          xConfirmPara(m_chromaFormatConstraints    [i] != CHROMA_420   , "ChromaFormatConstraint must be 420 for non main-RExt profiles.");
     2911        }
     2912       
     2913        xConfirmPara(m_intraConstraintFlags       [i] == true         , "IntraConstraintFlag must be false for non main_RExt profiles.");
     2914        xConfirmPara(m_lowerBitRateConstraintFlags[i] == false        , "LowerBitrateConstraintFlag must be true for non main-RExt profiles.");
     2915        xConfirmPara(m_profiles[i] == Profile::MAINSTILLPICTURE && m_framesToBeEncoded > 1, "Number of frames to be encoded must be 1 when main still picture profile is used.");
     2916
     2917        xConfirmPara(m_crossComponentPredictionEnabledFlag    == true , "CrossComponentPrediction must not be used for non main-RExt profiles.");
     2918        xConfirmPara(m_log2MaxTransformSkipBlockSize          != 2    , "Transform Skip Log2 Max Size must be 2 for V1 profiles.");
     2919        xConfirmPara(m_transformSkipRotationEnabledFlag       == true , "UseResidualRotation must not be enabled for non main-RExt profiles.");
     2920        xConfirmPara(m_transformSkipContextEnabledFlag        == true , "UseSingleSignificanceMapContext must not be enabled for non main-RExt profiles.");
     2921        xConfirmPara(m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT]== true , "ImplicitResidualDPCM must not be enabled for non main-RExt profiles.");
     2922        xConfirmPara(m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT]== true , "ExplicitResidualDPCM must not be enabled for non main-RExt profiles.");
     2923        xConfirmPara(m_persistentRiceAdaptationEnabledFlag    == true , "GolombRiceParameterAdaption must not be enabled for non main-RExt profiles.");
     2924        xConfirmPara(m_extendedPrecisionProcessingFlag        == true , "UseExtendedPrecision must not be enabled for non main-RExt profiles.");
     2925        xConfirmPara(m_highPrecisionOffsetsEnabledFlag        == true , "UseHighPrecisionPredictionWeighting must not be enabled for non main-RExt profiles.");
     2926        xConfirmPara(m_enableIntraReferenceSmoothing          == false, "EnableIntraReferenceSmoothing must be enabled for non main-RExt profiles.");
     2927        xConfirmPara(m_cabacBypassAlignmentEnabledFlag                , "AlignCABACBeforeBypass cannot be enabled for non main-RExt profiles.");
     2928
     2929        if ( m_profiles[i] == Profile::MULTIVIEWMAIN )
     2930        {
     2931          xConfirmPara( maxNumRefLayers > 4, "When using the MV-Main profile, NumRefLayers must be less than or equal to 4 for all layers in the subBitstream"  );
     2932          // -  For a layer with nuh_layer_id iNuhLId equal to any value included in layerIdListTarget that was used to derive subBitstream,
     2933          //    the value of NumRefLayers[ iNuhLId ], which specifies the total number of direct and indirect reference layers and is derived as
     2934          //    specified in F.7.4.3.1, shall be less than or equal to 4.
     2935        }
     2936
     2937#if NH_3D
     2938        if ( m_profiles[i] == Profile::MAIN3D )
     2939        {
     2940          xConfirmPara( maxNumRefLayers > 9, "When using the 3D-Main profile, NumRefLayers must be less than or equal to 9 for all layers in the subBitstream."  );
     2941            // -  For a layer with nuh_layer_id iNuhLId equal to any value included in layerIdListTarget that was used to derive subBitstream,
     2942            //   the value of NumRefLayers[ iNuhLId ], which specifies the total number of direct and indirect reference layers and is derived as
     2943            //   specified in F.7.4.3.1, shall be less than or equal to 9.
     2944        }
     2945#endif
     2946
     2947
     2948      }
     2949      break;
     2950#if NH_MV_ALLOW_NON_CONFORMING
     2951    case Profile::MULTIVIEWMAIN_NONCONFORMING:
     2952#if NH_3D
     2953    case Profile::MAIN3D_NONCONFORMING:
     2954#endif
     2955#endif
     2956    case Profile::NONE:
     2957      // Non-conforming configuration, so all settings are valid.
     2958      break;
     2959    default:
     2960      xConfirmPara( 1, "Unknown profile selected.");
     2961      break;
     2962    }
     2963
     2964    if ( check_failed )
     2965    {
     2966      printf("Error: Checking VpsProfileTierLevel[%d]. \n", i );
     2967      exit(EXIT_FAILURE);
     2968    }
     2969
     2970  }
     2971  #undef xConfirmPara
     2972
     2973  Bool anyMultiLayerProfile = false;
     2974
     2975  for (Int i = 0; i < m_profiles.size(); i++ )
     2976  {
     2977    anyMultiLayerProfile = ( anyMultiLayerProfile
     2978       
     2979      ||  (m_profiles[i] == Profile::MULTIVIEWMAIN)
     2980#if NH_3D
     2981      || ( m_profiles[i] == Profile::MAIN3D       )
     2982#endif
     2983      ) ;
     2984  }
     2985
     2986  if ( anyMultiLayerProfile && ( m_profiles[0] != Profile::MAIN || m_profiles[1] != Profile::MAIN  ) )
     2987  {
     2988    fprintf(stderr, "Error: The base layer must conform to the Main profile for Multilayer coding.\n");
     2989    exit(EXIT_FAILURE);
     2990  }
     2991
     2992}
     2993
     2994#endif
    21402995
    21412996Void TAppEncCfg::xCheckParameter()
     
    21683023  Bool check_failed = false; /* abort if there is a fatal configuration problem */
    21693024#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
    2170 
     3025 
    21713026  xConfirmPara(m_bitstreamFileName.empty(), "A bitstream file name must be specified (BitstreamFile)");
     3027#if !NH_MV
    21723028  const UInt maxBitDepth=(m_chromaFormatIDC==CHROMA_400) ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     3029
    21733030  xConfirmPara(m_bitDepthConstraint<maxBitDepth, "The internalBitDepth must not be greater than the bitDepthConstraint value");
    21743031  xConfirmPara(m_chromaFormatConstraint<m_chromaFormatIDC, "The chroma format used must not be greater than the chromaFormatConstraint value");
    2175 #if NH_MV
    2176   Profile::Name & m_profile = m_profiles[0];
    2177 #endif
    2178 
    2179   if (m_profile==Profile::MAINREXT || m_profile==Profile::HIGHTHROUGHPUTREXT)
     3032
     3033  switch (m_profile)
     3034  {
     3035    case Profile::MAINREXT:
     3036    case Profile::HIGHTHROUGHPUTREXT:
     3037
    21803038  {
    21813039    xConfirmPara(m_lowerBitRateConstraintFlag==false && m_intraConstraintFlag==false, "The lowerBitRateConstraint flag cannot be false when intraConstraintFlag is false");
     
    21863044      const UInt bitDepthIdx = (m_bitDepthConstraint == 8 ? 0 : (m_bitDepthConstraint ==10 ? 1 : (m_bitDepthConstraint == 12 ? 2 : (m_bitDepthConstraint == 16 ? 3 : 4 ))));
    21873045      const UInt chromaFormatIdx = UInt(m_chromaFormatConstraint);
    2188       const Bool bValidProfile = (bitDepthIdx > 3 || chromaFormatIdx>3) ? false : (validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx] != NONE);
     3046          const Bool bValidProfile = (bitDepthIdx > 3 || chromaFormatIdx>3) ? false : (validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx] != UI_NONE);
    21893047      xConfirmPara(!bValidProfile, "Invalid intra constraint flag, bit depth constraint flag and chroma format constraint flag combination for a RExt profile");
    21903048      const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag        ||
     
    22183076    {
    22193077      xConfirmPara( m_chromaFormatConstraint != CHROMA_444, "chroma format constraint must be 4:4:4 in the High Throughput 4:4:4 16-bit Intra profile.");
    2220       xConfirmPara( m_bitDepthConstraint     != 16,         "bit depth constraint must be 4:4:4 in the High Throughput 4:4:4 16-bit Intra profile.");
    2221       xConfirmPara( m_intraConstraintFlag    != 1,          "intra constraint flag must be 1 in the High Throughput 4:4:4 16-bit Intra profile.");
    2222     }
    2223   }
    2224   else
     3078          const UInt intraIdx = m_intraConstraintFlag ? 1:0;
     3079          const UInt bitDepthIdx = (m_bitDepthConstraint == 8 ? 0 : (m_bitDepthConstraint ==10 ? 1 : (m_bitDepthConstraint == 14 ? 2 : (m_bitDepthConstraint == 16 ? 3 : 4 ))));
     3080          const Bool bValidProfile = (bitDepthIdx > 3) ? false : (validRExtHighThroughPutProfileNames[intraIdx][bitDepthIdx] != UI_NONE);
     3081          xConfirmPara(!bValidProfile, "Invalid intra constraint flag and bit depth constraint flag combination for a RExt high profile throughput profile");
     3082          if(bitDepthIdx < 2)
     3083          {
     3084            xConfirmPara((m_extendedPrecisionProcessingFlag || m_cabacBypassAlignmentEnabledFlag), "Invalid configuration for a RExt high throughput 8 and 10 bit profile");
     3085    }
     3086          if(bitDepthIdx == 3)
     3087          {
     3088            xConfirmPara(!m_cabacBypassAlignmentEnabledFlag, "Cabac Bypass Alignment flag must be 1 in the High Throughput 4:4:4 16-bit Intra profile");
     3089  }
     3090          else if(bitDepthIdx < 3)
     3091          {
     3092            xConfirmPara(!m_entropyCodingSyncEnabledFlag, "WPP flag must be 1 in the High Throughput 4:4:4 non 16-bit Intra profile");
     3093          }
     3094        }
     3095      }
     3096      break;
     3097    case Profile::MAIN:
     3098    case Profile::MAIN10:
     3099    case Profile::MAINSTILLPICTURE:
    22253100  {
    22263101    xConfirmPara(m_bitDepthConstraint!=((m_profile==Profile::MAIN10)?10:8), "BitDepthConstraint must be 8 for MAIN profile and 10 for MAIN10 profile.");
     
    22423117    xConfirmPara(m_cabacBypassAlignmentEnabledFlag, "AlignCABACBeforeBypass cannot be enabled for non main-RExt profiles.");
    22433118  }
    2244 
     3119      break;
     3120    case Profile::NONE:
     3121      // Non-conforming configuration, so all settings are valid.
     3122      break;
     3123    default:
     3124      xConfirmPara( 1, "Unknown profile selected.");
     3125      break;
     3126  }
     3127#endif
     3128
     3129#if NH_MV
     3130  for (Int i = 0; i < m_numRepFormats; i++ )
     3131  {
     3132    Int* m_internalBitDepth    = &m_internalBitDepths   [i][0];
     3133    Int* m_inputBitDepth       = &m_inputBitDepths      [i][0];
     3134    Int* m_MSBExtendedBitDepth = &m_MSBExtendedBitDepths[i][0]; 
     3135#endif
    22453136  // check range of parameters
    22463137  xConfirmPara( m_inputBitDepth[CHANNEL_TYPE_LUMA  ] < 8,                                   "InputBitDepth must be at least 8" );
     
    22633154  }
    22643155#endif
    2265 
    22663156  xConfirmPara( (m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] < m_inputBitDepth[CHANNEL_TYPE_LUMA  ]), "MSB-extended bit depth for luma channel (--MSBExtendedBitDepth) must be greater than or equal to input bit depth for luma channel (--InputBitDepth)" );
    22673157  xConfirmPara( (m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] < m_inputBitDepth[CHANNEL_TYPE_CHROMA]), "MSB-extended bit depth for chroma channel (--MSBExtendedBitDepthC) must be greater than or equal to input bit depth for chroma channel (--InputBitDepthC)" );
    22683158
    22693159#if NH_MV
     3160  }
    22703161  for (Int i = 0; i < m_numberOfLayers; i++)
    22713162  {
    2272     xConfirmPara( m_log2SaoOffsetScale[i][CHANNEL_TYPE_LUMA]   > (m_internalBitDepth[CHANNEL_TYPE_LUMA  ]<10?0:(m_internalBitDepth[CHANNEL_TYPE_LUMA  ]-10)), "SaoLumaOffsetBitShift must be in the range of 0 to InternalBitDepth-10, inclusive");
    2273     xConfirmPara( m_log2SaoOffsetScale[i][CHANNEL_TYPE_CHROMA] > (m_internalBitDepth[CHANNEL_TYPE_CHROMA]<10?0:(m_internalBitDepth[CHANNEL_TYPE_CHROMA]-10)), "SaoChromaOffsetBitShift must be in the range of 0 to InternalBitDepthC-10, inclusive");
     3163    Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[i];
     3164    xConfirmPara( m_log2SaoOffsetScale[i][CHANNEL_TYPE_LUMA]   > (m_internalBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA  ]<10?0:(m_internalBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA  ]-10)), "SaoLumaOffsetBitShift must be in the range of 0 to InternalBitDepth-10, inclusive");
     3165    xConfirmPara( m_log2SaoOffsetScale[i][CHANNEL_TYPE_CHROMA] > (m_internalBitDepths[repFormatIdx][CHANNEL_TYPE_CHROMA]<10?0:(m_internalBitDepths[repFormatIdx][CHANNEL_TYPE_CHROMA]-10)), "SaoChromaOffsetBitShift must be in the range of 0 to InternalBitDepthC-10, inclusive");
     3166  }
     3167
     3168  for (Int i = 0; i < m_numRepFormats; i++)
     3169  {
     3170    xConfirmPara( m_chromaFormatIDCs[i] >= NUM_CHROMA_FORMAT,                                     "ChromaFormatIDC must be either 400, 420, 422 or 444" );
    22743171  }
    22753172#else
    22763173  xConfirmPara( m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA]   > (m_internalBitDepth[CHANNEL_TYPE_LUMA  ]<10?0:(m_internalBitDepth[CHANNEL_TYPE_LUMA  ]-10)), "SaoLumaOffsetBitShift must be in the range of 0 to InternalBitDepth-10, inclusive");
    22773174  xConfirmPara( m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] > (m_internalBitDepth[CHANNEL_TYPE_CHROMA]<10?0:(m_internalBitDepth[CHANNEL_TYPE_CHROMA]-10)), "SaoChromaOffsetBitShift must be in the range of 0 to InternalBitDepthC-10, inclusive");
    2278 #endif
    2279 
    22803175  xConfirmPara( m_chromaFormatIDC >= NUM_CHROMA_FORMAT,                                     "ChromaFormatIDC must be either 400, 420, 422 or 444" );
     3176#endif
     3177
    22813178  std::string sTempIPCSC="InputColourSpaceConvert must be empty, "+getListOfColourSpaceConverts(true);
    22823179  xConfirmPara( m_inputColourSpaceConvert >= NUMBER_INPUT_COLOUR_SPACE_CONVERSIONS,         sTempIPCSC.c_str() );
     3180#if NH_MV
     3181  for (Int i = 0 ; i < m_InputChromaFormatIDC.size(); i++ )
     3182  {
     3183    xConfirmPara( m_InputChromaFormatIDC[i] >= NUM_CHROMA_FORMAT,                                "InputChromaFormatIDC must be either 400, 420, 422 or 444" );
     3184  }
     3185#else
    22833186  xConfirmPara( m_InputChromaFormatIDC >= NUM_CHROMA_FORMAT,                                "InputChromaFormatIDC must be either 400, 420, 422 or 444" );
     3187#endif
    22843188  xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
    22853189  xConfirmPara( m_temporalSubsampleRatio < 1,                                               "Temporal subsample rate must be no less than 1" );
     
    22913195  xConfirmPara( m_layerIdInNuh[0] != 0      , "LayerIdInNuh must be 0 for the first layer. ");
    22923196  xConfirmPara( (m_layerIdInNuh.size()!=1) && (m_layerIdInNuh.size() < m_numberOfLayers) , "LayerIdInNuh must be given for all layers. ");
     3197
     3198#if NH_MV
     3199  xConfirmPara( !m_shareParameterSets && (m_numberOfLayers > 16)                            , "When NumberOfLayers is greater than 16, ShareParameterSets must be 1."); 
     3200  xConfirmPara( ! (m_layerIdxInVpsToGopDefIdx.size() == 0     || m_layerIdxInVpsToGopDefIdx.size() == m_numberOfLayers), "The number of entries in LayerIdxInVpsToGopDefIdx must zero or equal to NumberOfLayers."); 
     3201  xConfirmPara( ! (m_layerIdxInVpsToRepFormatIdx.size() == 0  || m_layerIdxInVpsToRepFormatIdx.size() == m_numberOfLayers), "The number of entries in LayerIdxInVpsToRepFormatIdx must zero or equal to NumberOfLayers."); 
     3202 
     3203#endif
    22933204
    22943205#if NH_3D
     
    23703281      xConfirmPara( allEqual , "Each layer shall have a different position in scalability space." );
    23713282
    2372 #if !H_3D_FCO
    23733283      if ( numDiff  == 1 )
    23743284      {
     
    23813291        xConfirmPara( shallBeButIsNotIncreasing,  "DimensionIds shall be increasing within one dimension. " );
    23823292      }
    2383 #endif
    23843293    }
    23853294  }
     
    24473356
    24483357  // PTL
    2449   xConfirmPara( ( m_profiles.size() != m_inblFlag.size() || m_profiles.size() != m_level.size()  ||  m_profiles.size() != m_levelTier.size() ), "The number of Profiles, Levels, Tiers and InblFlags must be equal." );
     3358  xConfirmPara( ( m_uiProfiles.size() != m_inblFlag.size() || m_uiProfiles.size() != m_level.size()  ||  m_uiProfiles.size() != m_levelTier.size() ), "The number of Profiles, Levels, Tiers and InblFlags must be equal." );
    24503359
    24513360  if ( m_numberOfLayers > 1)
    24523361  {
    2453     xConfirmPara( m_profiles.size() <= 1, "The number of profiles, tiers, levels, and inblFlags must be greater than 1.");
     3362    xConfirmPara( m_uiProfiles.size() <= 1, "The number of profiles, tiers, levels, and inblFlags must be greater than 1.");
    24543363    xConfirmPara( m_inblFlag[0], "VpsProfileTierLevel[0] must have inblFlag equal to 0");
    2455     if (m_profiles.size() > 1 )
    2456     {
    2457       xConfirmPara( m_profiles[0]  != m_profiles[1], "The profile in VpsProfileTierLevel[1] must be equal to the profile in VpsProfileTierLevel[0].");
     3364    if (m_uiProfiles.size() > 1 )
     3365    {
     3366      xConfirmPara( m_uiProfiles[0]  != m_uiProfiles[1], "The profile in VpsProfileTierLevel[1] must be equal to the profile in VpsProfileTierLevel[0].");
    24583367      xConfirmPara( m_inblFlag[0] != m_inblFlag[1], "inblFlag in VpsProfileTierLevel[1] must be equal to the inblFlag in VpsProfileTierLevel[0].");
    24593368    }
     
    24673376    for (Int j = 0; j < m_directRefLayers[i].size(); j++)
    24683377    {
    2469       xConfirmPara( m_directRefLayers[i][j] < 0 || m_directRefLayers[i][j] >= i , "Reference layer id shall be greater than or equal to 0 and less than dependent layer id");
     3378      if ( m_directRefLayers[i][j] < 0 || m_directRefLayers[i][j] >= i )
     3379      {
     3380        printf( "Error: Reference layer id (%d) shall be greater than or equal to 0 and less than dependent layer id (%d). ", m_directRefLayers[i][j],  i );
     3381        check_failed = true;
     3382      }       
     3383
    24703384      xConfirmPara( m_dependencyTypes[i][j] < 0 || m_dependencyTypes[i][j] >  6 , "Dependency type shall be greater than or equal to 0 and less than 7");
    24713385    }       
     
    24993413  }
    25003414
     3415#if NH_MV
     3416  for (Int i = 0; i < m_numRepFormats; i++)
     3417  {
     3418    if(m_crossComponentPredictionEnabledFlag && (m_chromaFormatIDCs[i] != CHROMA_444))
     3419#else
    25013420  if(m_crossComponentPredictionEnabledFlag && (m_chromaFormatIDC != CHROMA_444))
     3421#endif
    25023422  {
    25033423    fprintf(stderr, "****************************************************************************\n");
     
    25073427    m_crossComponentPredictionEnabledFlag = false;
    25083428  }
     3429#if NH_MV
     3430  }
     3431#endif
    25093432
    25103433  if ( m_CUTransquantBypassFlagForce && m_bUseHADME )
     
    25313454  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
    25323455  {
    2533     xConfirmPara( m_iQP[layer] <  -6 * (m_internalBitDepth[CHANNEL_TYPE_LUMA] - 8) || m_iQP[layer] > 51,      "QP exceeds supported range (-QpBDOffsety to 51)" );
     3456    Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
     3457    xConfirmPara( m_iQP[layer] <  -6 * (m_internalBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA] - 8) || m_iQP[layer] > 51,      "QP exceeds supported range (-QpBDOffsety to 51)" );
    25343458    xConfirmPara( m_deblockingFilterMetric!=0 && (m_bLoopFilterDisable[layer] || m_loopFilterOffsetInPPS), "If DeblockingFilterMetric is true then both LoopFilterDisable and LoopFilterOffsetInPPS must be 0");
    25353459  }
    25363460#else
    25373461  xConfirmPara( m_iQP <  -6 * (m_internalBitDepth[CHANNEL_TYPE_LUMA] - 8) || m_iQP > 51,    "QP exceeds supported range (-QpBDOffsety to 51)" );
    2538 #if W0038_DB_OPT
    25393462  xConfirmPara( m_deblockingFilterMetric!=0 && (m_bLoopFilterDisable || m_loopFilterOffsetInPPS), "If DeblockingFilterMetric is non-zero then both LoopFilterDisable and LoopFilterOffsetInPPS must be 0");
    2540 #else
    2541   xConfirmPara( m_DeblockingFilterMetric && (m_bLoopFilterDisable || m_loopFilterOffsetInPPS), "If DeblockingFilterMetric is true then both LoopFilterDisable and LoopFilterOffsetInPPS must be 0");
    2542 #endif
    25433463#endif
    25443464 
     
    25523472#endif
    25533473  xConfirmPara( m_iMaxDeltaQP > 7,                                                          "Absolute Delta QP exceeds supported range (0 to 7)" );
     3474  xConfirmPara(m_lumaLevelToDeltaQPMapping.mode &&  m_uiDeltaQpRD > 0, "Luma-level-based Delta QP cannot be used together with slice level multiple-QP optimization\n" );
    25543475  xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1,                                          "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" );
    25553476
     
    25603481
    25613482  xConfirmPara( m_iQPAdaptationRange <= 0,                                                  "QP Adaptation Range must be more than 0" );
     3483#if NH_MV
     3484  for (Int i = 0; i < m_numberOfLayers; i++ )
     3485  {
     3486    if (m_iDecodingRefreshType == 2 || m_saoResetEncoderStateAfterIRAP)
     3487    {
     3488      xConfirmPara( m_iIntraPeriod[i] > 0 && m_iIntraPeriod[i] <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
     3489    }
     3490  }
     3491#else
    25623492  if (m_iDecodingRefreshType == 2)
    25633493  {
    2564 #if NH_MV
    2565     for (Int i = 0; i < m_numberOfLayers; i++ )
    2566     {
    2567       xConfirmPara( m_iIntraPeriod[i] > 0 && m_iIntraPeriod[i] <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
    2568 #if OPTIONAL_RESET_SAO_ENCODING_AFTER_IRAP
     3494   xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
     3495  }
    25693496  if (m_saoResetEncoderStateAfterIRAP)
    25703497  {
    2571     xConfirmPara( m_iIntraPeriod[i] > 0 && m_iIntraPeriod[i] <= m_iGOPSize ,                      "Intra period must be larger than GOP size when SAOResetEncoderStateAfterIRAP is enabled");
    2572   }
    2573 #endif
    2574 
    2575     }
    2576 #else
    2577 #if OPTIONAL_RESET_SAO_ENCODING_AFTER_IRAP
    2578   if (m_saoResetEncoderStateAfterIRAP)
    2579   {
    25803498    xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size when SAOResetEncoderStateAfterIRAP is enabled");
    25813499  }
    25823500#endif
    2583 
    2584    xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
    2585 #endif
    2586   }
     3501 
    25873502  xConfirmPara( m_uiMaxCUDepth < 1,                                                         "MaxPartitionDepth must be greater than zero");
    25883503  xConfirmPara( (m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,                                    "Minimum partition width size should be larger than or equal to 8");
     
    25903505  xConfirmPara( m_uiMaxCUWidth < 16,                                                        "Maximum partition width size should be larger than or equal to 16");
    25913506  xConfirmPara( m_uiMaxCUHeight < 16,                                                       "Maximum partition height size should be larger than or equal to 16");
     3507#if NH_MV
     3508  for (Int i = 0; i < m_numRepFormats; i++ )
     3509  {
     3510    xConfirmPara( (m_iSourceWidths[i]  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
     3511    xConfirmPara( (m_iSourceHeights[i] % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
     3512  }
     3513#else
    25923514  xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
    25933515  xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
     3516#endif
    25943517
    25953518  xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
     
    26313554    for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
    26323555    {
     3556#if NH_MV
     3557      for (Int i = 0; i < m_numRepFormats; i++)
     3558      {
     3559        xConfirmPara(((m_MSBExtendedBitDepths[i][channelType] > m_internalBitDepths[i][channelType]) && m_bPCMInputBitDepthFlag), "PCM bit depth cannot be greater than internal bit depth (PCMInputBitDepthFlag cannot be used when InputBitDepth or MSBExtendedBitDepth > InternalBitDepth)");
     3560      }
     3561#else
    26333562      xConfirmPara(((m_MSBExtendedBitDepth[channelType] > m_internalBitDepth[channelType]) && m_bPCMInputBitDepthFlag), "PCM bit depth cannot be greater than internal bit depth (PCMInputBitDepthFlag cannot be used when InputBitDepth or MSBExtendedBitDepth > InternalBitDepth)");
     3563#endif
    26343564    }
    26353565    xConfirmPara(  m_uiPCMLog2MinSize < 3,                                      "PCMLog2MinSize must be 3 or greater.");
     
    26493579
    26503580  Bool tileFlag = (m_numTileColumnsMinus1 > 0 || m_numTileRowsMinus1 > 0 );
     3581
     3582#if !NH_MV
    26513583  if (m_profile!=Profile::HIGHTHROUGHPUTREXT)
    26523584  {
    26533585    xConfirmPara( tileFlag && m_entropyCodingSyncEnabledFlag, "Tiles and entropy-coding-sync (Wavefronts) can not be applied together, except in the High Throughput Intra 4:4:4 16 profile");
    26543586  }
     3587#else
     3588  for (Int i = 0; i < m_numRepFormats; i++)
     3589  {
     3590    ChromaFormat m_chromaFormatIDC  = m_chromaFormatIDCs[i];
     3591    Int*         m_aiPad            = &m_aiPads          [i][0];
     3592    Int          m_confWinLeft      = m_confWinLefts    [i];
     3593    Int          m_confWinRight     = m_confWinRights   [i];
     3594    Int          m_confWinTop       = m_confWinTops     [i];
     3595    Int          m_confWinBottom    = m_confWinBottoms  [i]; 
     3596    Int          m_iSourceWidth     = m_iSourceWidths   [i];
     3597    Int          m_iSourceHeight    = m_iSourceHeights  [i];
     3598#endif
    26553599
    26563600  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
     
    26743618    xConfirmPara( m_defDispWinBottomOffset % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Bottom default display window offset must be an integer multiple of the specified chroma subsampling");
    26753619  }
     3620
     3621#if NH_MV
     3622  }
     3623#endif
    26763624
    26773625#if NH_3D_VSO || NH_3D
     
    27173665      for( Int i = 0; i < MAX_GOP; i++ )
    27183666      {
    2719         if( m_GOPListMvc[k][i].m_POC != m_GOPListMvc[0][i].m_POC )
     3667        if( xGetGopEntries(k)[i].m_POC != xGetGopEntries(0)[i].m_POC )
    27203668        {
    2721           printf( "\nError: Frame%d_l%d POC %d is not identical to Frame%d POC\n", i, k, m_GOPListMvc[k][i].m_POC, i );
     3669          printf( "\nError: Frame%d_l%d POC %d is not identical to Frame%d POC\n", i, k, xGetGopEntries(k)[i].m_POC, i );
    27223670          bErrorMvePoc = true;
    27233671        }
     
    27313679  for( Int i = 0; i < MAX_GOP; i++ )
    27323680  {
    2733     if( m_GOPListMvc[0][i].m_numActiveRefLayerPics != 0 )
     3681    if( xGetGopEntries(0)[i].m_numActiveRefLayerPics != 0 )
    27343682    {
    27353683      printf( "\nError: Frame%d inter_layer refs not available in layer 0\n", i );
     
    27473695      for( Int i = 0; i < MAX_GOP+1; i++ )
    27483696      {
    2749         GOPEntry gopEntry = m_GOPListMvc[layer][i]; 
     3697        GOPEntry gopEntry = xGetGopEntries(layer)[i]; 
    27503698        for( Int j = 0; j < gopEntry.m_numActiveRefLayerPics; j++ )
    27513699        {
     
    27903738          {
    27913739            printf( "\nWarning: temporal references not possible for FrameI_l%d\n", layer );
    2792             for( Int j = 0; j < m_GOPListMvc[layer][MAX_GOP].m_numRefPics; j++ )
     3740            for( Int j = 0; j < xGetGopEntries(layer)[MAX_GOP].m_numRefPics; j++ )
    27933741            {
    27943742              gopEntry.m_referencePics[j] = 0;
     
    28503798    for( Int layer = 0; layer < m_numberOfLayers; layer++ )
    28513799    {
    2852       GOPEntry* m_GOPList            = m_GOPListMvc           [layer]; // It is not a member, but this name helps avoiding code duplication !!!
     3800      GOPEntry* m_GOPList            = xGetGopEntries         (layer); // It is not a member, but this name helps avoiding code duplication !!!
    28533801      Int&      m_extraRPSs          = m_extraRPSsMvc         [layer]; // It is not a member, but this name helps avoiding code duplication !!!
    28543802      Int&      m_maxTempLayer       = m_maxTempLayerMvc      [layer]; // It is not a member, but this name helps avoiding code duplication !!!
    28553803      Int*      m_maxDecPicBuffering = m_maxDecPicBufferingMvc[layer]; // It is not a member, but this name helps avoiding code duplication !!!
    2856       Int*      m_numReorderPics     = m_numReorderPicsMvc    [layer]; // It is not a member, but this name helps avoiding code duplication !!!
     3804      Int*      m_numReorderPics     = m_numReorderPicsMvc    [layer]; // It is not a member, but this name helps avoiding code duplication !!!     
    28573805#endif
    28583806
     
    28743822  else
    28753823  {
     3824#if !NH_MV
    28763825    xConfirmPara( m_intraConstraintFlag, "IntraConstraintFlag cannot be 1 for inter sequences");
     3826#endif
    28773827  }
    28783828
     
    29203870  }
    29213871
    2922 #if W0038_CQP_ADJ
    29233872  for(Int i=0; i<m_iGOPSize; i++)
    29243873  {
     
    29283877    xConfirmPara( abs(m_GOPList[i].m_CrQPoffset + m_crQpOffset) > 12, "Cr QP Offset for one of the GOP entries, when combined with the PPS Cr offset, exceeds supported range (-12 to 12)" );
    29293878  }
    2930   xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[0]                 > 12), "Intra/periodic Cb QP Offset exceeds supported range (-12 to 12)" );
    2931   xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[0]  + m_cbQpOffset > 12), "Intra/periodic Cb QP Offset, when combined with the PPS Cb offset, exceeds supported range (-12 to 12)" );
    2932   xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[1]                 > 12), "Intra/periodic Cr QP Offset exceeds supported range (-12 to 12)" );
    2933   xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[1]  + m_crQpOffset > 12), "Intra/periodic Cr QP Offset, when combined with the PPS Cr offset, exceeds supported range (-12 to 12)" );
    2934 #endif
     3879  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[0]                 ) > 12, "Intra/periodic Cb QP Offset exceeds supported range (-12 to 12)" );
     3880  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[0]  + m_cbQpOffset ) > 12, "Intra/periodic Cb QP Offset, when combined with the PPS Cb offset, exceeds supported range (-12 to 12)" );
     3881  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[1]                 ) > 12, "Intra/periodic Cr QP Offset exceeds supported range (-12 to 12)" );
     3882  xConfirmPara( abs(m_sliceChromaQpOffsetIntraOrPeriodic[1]  + m_crQpOffset ) > 12, "Intra/periodic Cr QP Offset, when combined with the PPS Cr offset, exceeds supported range (-12 to 12)" );
    29353883
    29363884  m_extraRPSs=0;
     
    32064154  if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
    32074155  {
     4156#if NH_MV
     4157
     4158    if( m_numRepFormats > 1 )
     4159    {
     4160        AOT( true ); //TBD
     4161    }
     4162
     4163    Int m_iSourceWidth  = m_iSourceWidths [0];
     4164    Int m_iSourceHeight = m_iSourceHeights[0];
     4165#endif
    32084166    Int PicSizeInSamplesY =  m_iSourceWidth * m_iSourceHeight;
    32094167    if(tileFlag)
     
    33074265  if (m_chromaResamplingFilterSEIenabled)
    33084266  {
     4267#if NH_MV
     4268    for (Int i = 0 ; i < m_numRepFormats; i++ )
     4269    {
     4270      xConfirmPara( (m_chromaFormatIDCs[i] == CHROMA_400 ), "chromaResamplingFilterSEI is not allowed to be present when ChromaFormatIDC is equal to zero (4:0:0)" );
     4271    }
     4272#else
    33094273    xConfirmPara( (m_chromaFormatIDC == CHROMA_400 ), "chromaResamplingFilterSEI is not allowed to be present when ChromaFormatIDC is equal to zero (4:0:0)" );
     4274#endif
    33104275    xConfirmPara(m_vuiParametersPresentFlag && m_chromaLocInfoPresentFlag && (m_chromaSampleLocTypeTopField != m_chromaSampleLocTypeBottomField ), "When chromaResamplingFilterSEI is enabled, ChromaSampleLocTypeTopField has to be equal to ChromaSampleLocTypeBottomField" );
    33114276  }
     
    33224287    }
    33234288    xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
    3324 #if U0132_TARGET_BITS_SATURATION
    3325 #if NH_MV
    3326     if ((m_RCCpbSaturationEnabled) && (m_level[0]!=Level::NONE) && (m_profile!=Profile::NONE))
    3327     {
    3328       UInt uiLevelIdx = (m_level[0] / 10) + (UInt)((m_level[0] % 10) / 3);    // (m_level / 30)*3 + ((m_level % 10) / 3);
    3329       xConfirmPara(m_RCCpbSize > g_uiMaxCpbSize[m_levelTier[0]][uiLevelIdx], "RCCpbSize should be smaller than or equal to Max CPB size according to tier and level");
    3330       xConfirmPara(m_RCInitialCpbFullness > 1, "RCInitialCpbFullness should be smaller than or equal to 1");
    3331     }
    3332 #else
     4289#if !NH_MV   
    33334290    if ((m_RCCpbSaturationEnabled) && (m_level!=Level::NONE) && (m_profile!=Profile::NONE))
    33344291    {
     
    33384295    }
    33394296#endif
    3340 #endif
    3341   }
    3342 #if U0132_TARGET_BITS_SATURATION
     4297  }
    33434298  else
    33444299  {
    33454300    xConfirmPara( m_RCCpbSaturationEnabled != 0, "Target bits saturation cannot be processed without Rate control" );
    33464301  }
    3347 #endif
     4302
     4303  if (m_vuiParametersPresentFlag)
     4304  {
     4305    xConfirmPara(m_RCTargetBitrate == 0, "A target bit rate is required to be set for VUI/HRD parameters.");
     4306    if (m_RCCpbSize == 0)
     4307    {
     4308      printf ("Warning: CPB size is set equal to zero. Adjusting value to be equal to TargetBitrate!\n");
     4309      m_RCCpbSize = m_RCTargetBitrate;
     4310    }
     4311  }
    33484312
    33494313#if NH_MV
     
    33704334#endif
    33714335
    3372   xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce, "CUTransquantBypassFlagForce cannot be 1 when TransquantBypassEnableFlag is 0");
     4336  xConfirmPara(!m_TransquantBypassEnabledFlag && m_CUTransquantBypassFlagForce, "CUTransquantBypassFlagForce cannot be 1 when TransquantBypassEnableFlag is 0");
    33734337
    33744338  xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
     
    33944358  }
    33954359
     4360#if MCTS_ENC_CHECK
     4361  if ((m_tmctsSEIEnabled) && (m_tmctsSEITileConstraint) && (m_bLFCrossTileBoundaryFlag) )
     4362  {
     4363    printf("Warning: Constrained Encoding for Temporal Motion Constrained Tile Sets is enabled. Disabling filtering across tile boundaries!\n");
     4364    m_bLFCrossTileBoundaryFlag = false;
     4365  }
     4366#endif
     4367
    33964368  if(m_timeCodeSEIEnabled)
    33974369  {
     
    33994371  }
    34004372
    3401 #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
    34024373  xConfirmPara(m_preferredTransferCharacteristics > 255, "transfer_characteristics_idc should not be greater than 255.");
     4374
     4375#if EXTENSION_360_VIDEO
     4376  check_failed |= m_ext360.verifyParameters();
    34034377#endif
    34044378
     
    34294403}
    34304404
     4405#if NH_MV
     4406Void TAppEncCfg::xPrintProfiles()
     4407{
     4408  printf("Profiles                          :");
     4409  for (Int i = 0; i < m_profiles.size(); i++)
     4410  {
     4411    if (m_profiles[i] == Profile::MAINREXT)
     4412    {
     4413      UIProfileName validProfileName;
     4414      if (m_onePictureOnlyConstraintFlags[i])
     4415      {
     4416        validProfileName = m_bitDepthConstraints[i] == 8 ? UI_MAIN_444_STILL_PICTURE : (m_bitDepthConstraints[i] == 16 ? UI_MAIN_444_16_STILL_PICTURE : UI_NONE);
     4417      }
     4418      else
     4419      {
     4420        const UInt intraIdx        =  m_intraConstraintFlags[i] ? 1:0;
     4421        const UInt bitDepthIdx     = (m_bitDepthConstraints[i] == 8 ? 0 : (m_bitDepthConstraints[i] ==10 ? 1 : (m_bitDepthConstraints[i] == 12 ? 2 : (m_bitDepthConstraints[i] == 16 ? 3 : 4 ))));
     4422        const UInt chromaFormatIdx = UInt(m_chromaFormatConstraints[i]);
     4423        validProfileName = (bitDepthIdx > 3 || chromaFormatIdx>3) ? UI_NONE : validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx];
     4424      }
     4425      std::string rextSubProfile;
     4426      if (validProfileName!=UI_NONE)
     4427      {
     4428        rextSubProfile=enumToString(strToUIProfileName, sizeof(strToUIProfileName)/sizeof(*strToUIProfileName), validProfileName);
     4429      }
     4430      if (rextSubProfile == "main_444_16")
     4431      {
     4432        rextSubProfile="main_444_16 [NON STANDARD]";
     4433      }
     4434      printf(" %s (%s) ", profileToString(m_profiles[i]), (rextSubProfile.empty())?"INVALID REXT PROFILE":rextSubProfile.c_str() );
     4435
     4436    }
     4437    else if (m_profiles[i] == Profile::HIGHTHROUGHPUTREXT)
     4438    {
     4439      UIProfileName validProfileName;
     4440      const UInt intraIdx    = m_intraConstraintFlags[i] ? 1 : 0;
     4441      const UInt bitDepthIdx = (m_bitDepthConstraints[i] == 8 ? 0 : (m_bitDepthConstraints[i] ==10 ? 1 : (m_bitDepthConstraints[i] == 12 ? 2 : (m_bitDepthConstraints[i] == 16 ? 3 : 4 ))));
     4442      validProfileName = (bitDepthIdx > 3) ? UI_NONE : validRExtHighThroughPutProfileNames[intraIdx][bitDepthIdx];
     4443      std::string subProfile;
     4444      if (validProfileName!=UI_NONE)
     4445      {
     4446        subProfile=enumToString(strToUIProfileName, sizeof(strToUIProfileName)/sizeof(*strToUIProfileName), validProfileName);
     4447      }
     4448      printf(" : %s (%s)\n", profileToString(m_profiles[i]), (subProfile.empty())?"INVALID HIGH THROUGHPUT REXT PROFILE":subProfile.c_str() );
     4449    }
     4450    else if (m_profiles[i] == Profile::MAIN10 && m_onePictureOnlyConstraintFlags[i])
     4451    {
     4452      printf(" : %s (main10-still-picture)\n", profileToString(m_profiles[i]) );
     4453    }
     4454    else
     4455    {
     4456      printf(" %s ", profileToString(m_profiles[i]) );
     4457    }
     4458  }
     4459  printf("\n\n");
     4460
     4461}
     4462#endif
     4463
    34314464Void TAppEncCfg::xPrintParameter()
    34324465{
     
    34354468  for( Int layer = 0; layer < m_numberOfLayers; layer++)
    34364469  {
    3437     printf("Input File %i                     : %s\n", layer, m_pchInputFileList[layer]);
     4470    printf("Input          File %i             : %s\n", layer, m_pchInputFileList[layer]);   
    34384471  }
    34394472#else
    34404473  printf("Input          File                    : %s\n", m_inputFileName.c_str()          );
    34414474#endif
    3442   printf("Bitstream      File                    : %s\n", m_bitstreamFileName.c_str()      );
     4475  printf("Bitstream      File               : %s\n", m_bitstreamFileName.c_str()      );
    34434476#if NH_MV
    34444477  for( Int layer = 0; layer < m_numberOfLayers; layer++)
    3445   {
    3446     printf("Reconstruction File %i            : %s\n", layer, m_pchReconFileList[layer]);
     4478  { 
     4479    printf("Reconstruction File %i             : %s\n", layer, m_pchReconFileList[layer]);
    34474480  }
    34484481#else
     
    34644497#endif
    34654498#if NH_MV 
     4499#if !JVET_E0059_FLOATING_POINT_QP_FIX
    34664500  xPrintParaVector( "QP"               , m_fQP                );
     4501#endif
    34674502  xPrintParaVector( "LoopFilterDisable", m_bLoopFilterDisable );
    34684503  xPrintParaVector( "SAO"              , m_bUseSAO            );
    3469 #endif
    3470 
     4504  printf("ShareParameterSets                : %d\n",  m_shareParameterSets ?  1  : 0  );         
     4505#endif
     4506
     4507#if NH_MV
     4508  printf("Real     Format                   :");
     4509  for(Int i = 0; i < m_numRepFormats; i++ )
     4510  {
     4511    printf(" (%dx%d %gHz)", m_iSourceWidths[i] - m_confWinLefts[i] - m_confWinRights[i], m_iSourceHeights[i] - m_confWinTops[i] - m_confWinBottoms[i], (Double)m_iFrameRate/m_temporalSubsampleRatio );
     4512  }
     4513
     4514  printf("\nInternal Format                   :" );
     4515  for(Int i = 0; i < m_numRepFormats; i++ )
     4516  {
     4517
     4518    printf(" (%dx%d %gHz)", m_iSourceWidths[i], m_iSourceHeights[i], (Double)m_iFrameRate/m_temporalSubsampleRatio );
     4519  } 
     4520  printf("\n");
     4521#else
    34714522  printf("Real     Format                        : %dx%d %gHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, (Double)m_iFrameRate/m_temporalSubsampleRatio );
    34724523  printf("Internal Format                        : %dx%d %gHz\n", m_iSourceWidth, m_iSourceHeight, (Double)m_iFrameRate/m_temporalSubsampleRatio );
     4524
     4525#endif
    34734526  printf("Sequence PSNR output              : %s\n", (m_printMSEBasedSequencePSNR ? "Linear average, MSE-based" : "Linear average only") );
    34744527  printf("Sequence MSE output               : %s\n", (m_printSequenceMSE ? "Enabled" : "Disabled") );
    34754528  printf("Frame MSE output                  : %s\n", (m_printFrameMSE    ? "Enabled" : "Disabled") );
     4529#if JVET_F0064_MSSSIM 
     4530  printf("MS-SSIM output                    : %s\n", (m_printMSSSIM      ? "Enabled" : "Disabled") );
     4531#endif
    34764532  printf("Cabac-zero-word-padding           : %s\n", (m_cabacZeroWordPaddingEnabled? "Enabled" : "Disabled") );
    34774533  if (m_isField)
     
    34874543    printf("Frame index                       : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
    34884544  }
    3489 #if NH_MV
    3490   printf("Profile                           :");
    3491   for (Int i = 0; i < m_profiles.size(); i++)
    3492   {
    3493     Profile::Name m_profile = m_profiles[i];
    3494 
    3495 #endif
     4545#if !NH_MV
    34964546    if (m_profile == Profile::MAINREXT)
    34974547    {
    3498     ExtendedProfileName validProfileName;
     4548    UIProfileName validProfileName;
    34994549    if (m_onePictureOnlyConstraintFlag)
    35004550    {
    3501       validProfileName = m_bitDepthConstraint == 8 ? MAIN_444_STILL_PICTURE : (m_bitDepthConstraint == 16 ? MAIN_444_16_STILL_PICTURE : NONE);
     4551      validProfileName = m_bitDepthConstraint == 8 ? UI_MAIN_444_STILL_PICTURE : (m_bitDepthConstraint == 16 ? UI_MAIN_444_16_STILL_PICTURE : UI_NONE);
    35024552    }
    35034553    else
     
    35064556      const UInt bitDepthIdx = (m_bitDepthConstraint == 8 ? 0 : (m_bitDepthConstraint ==10 ? 1 : (m_bitDepthConstraint == 12 ? 2 : (m_bitDepthConstraint == 16 ? 3 : 4 ))));
    35074557      const UInt chromaFormatIdx = UInt(m_chromaFormatConstraint);
    3508       validProfileName = (bitDepthIdx > 3 || chromaFormatIdx>3) ? NONE : validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx];
     4558      validProfileName = (bitDepthIdx > 3 || chromaFormatIdx>3) ? UI_NONE : validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx];
    35094559    }
    35104560      std::string rextSubProfile;
    3511       if (validProfileName!=NONE)
    3512       {
    3513         rextSubProfile=enumToString(strToExtendedProfile, sizeof(strToExtendedProfile)/sizeof(*strToExtendedProfile), validProfileName);
     4561    if (validProfileName!=UI_NONE)
     4562      {
     4563      rextSubProfile=enumToString(strToUIProfileName, sizeof(strToUIProfileName)/sizeof(*strToUIProfileName), validProfileName);
    35144564      }
    35154565      if (rextSubProfile == "main_444_16")
     
    35174567        rextSubProfile="main_444_16 [NON STANDARD]";
    35184568      }
    3519 #if NH_MV
    3520       printf(" %s (%s) ", profileToString(m_profile), (rextSubProfile.empty())?"INVALID REXT PROFILE":rextSubProfile.c_str() );
    3521 #else
    35224569      printf("Profile                           : %s (%s)\n", profileToString(m_profile), (rextSubProfile.empty())?"INVALID REXT PROFILE":rextSubProfile.c_str() );
    3523 #endif
    3524     }
    3525     else
    3526     {
    3527 #if NH_MV
    3528       printf(" %s ", profileToString(m_profile) );
    3529 #else
     4570  }
     4571  else if (m_profile == Profile::HIGHTHROUGHPUTREXT)
     4572  {
     4573    UIProfileName validProfileName;
     4574    const UInt intraIdx = m_intraConstraintFlag ? 1:0;
     4575    const UInt bitDepthIdx = (m_bitDepthConstraint == 8 ? 0 : (m_bitDepthConstraint ==10 ? 1 : (m_bitDepthConstraint == 12 ? 2 : (m_bitDepthConstraint == 16 ? 3 : 4 ))));
     4576    validProfileName = (bitDepthIdx > 3) ? UI_NONE : validRExtHighThroughPutProfileNames[intraIdx][bitDepthIdx];
     4577    std::string subProfile;
     4578    if (validProfileName!=UI_NONE)
     4579    {
     4580      subProfile=enumToString(strToUIProfileName, sizeof(strToUIProfileName)/sizeof(*strToUIProfileName), validProfileName);
     4581    }
     4582    printf("Profile                                : %s (%s)\n", profileToString(m_profile), (subProfile.empty())?"INVALID HIGH THROUGHPUT REXT PROFILE":subProfile.c_str() );
     4583  }
     4584  else if (m_profile == Profile::MAIN10 && m_onePictureOnlyConstraintFlag)
     4585  {
     4586    printf("Profile                                : %s (main10-still-picture)\n", profileToString(m_profile) );
     4587  }
     4588  else
     4589  {
    35304590      printf("Profile                           : %s\n", profileToString(m_profile) );
    3531 #endif
    3532     }
    3533 #if NH_MV   
    3534   }
    3535   printf("\n");
    3536 #endif
    3537 
     4591   }
     4592#endif
     4593
     4594#if NH_MV
     4595  printf("CU size / depth / total-depth     : %d / %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth, m_uiMaxTotalCUDepth[0] );
     4596#else
    35384597  printf("CU size / depth / total-depth     : %d / %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth, m_uiMaxTotalCUDepth );
     4598#endif
    35394599  printf("RQT trans. size (min / max)       : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
    35404600  printf("Max RQT depth inter               : %d\n", m_uiQuadtreeTUMaxDepthInter);
     
    35524612#endif
    35534613  printf("Decoding refresh type             : %d\n", m_iDecodingRefreshType );
    3554 #if !NH_MV
     4614#if JVET_E0059_FLOATING_POINT_QP_FIX
     4615
     4616#if NH_MV
     4617  if ( !m_qpIncrementAtSourceFrame.empty() )
     4618  {
     4619    xPrintParaVector( "QPIncrementFrame", m_qpIncrementAtSourceFrame );     
     4620  }
     4621#else
     4622  if (m_qpIncrementAtSourceFrame.bPresent)
     4623  {
     4624    printf("QP                                     : %d (incrementing internal QP at source frame %d)\n", m_iQP, m_qpIncrementAtSourceFrame.value );
     4625  }
     4626#endif
     4627  else
     4628  {
     4629#if NH_MV
     4630    xPrintParaVector( "QP", m_iQP );
     4631#else
     4632    printf("QP                                     : %d\n", m_iQP );
     4633#endif
     4634  }
     4635#else
    35554636  printf("QP                                : %5.2f\n", m_fQP );
    35564637#endif
     
    35614642  printf("QP adaptation                     : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) );
    35624643  printf("GOP size                          : %d\n", m_iGOPSize );
     4644
     4645#if NH_MV
     4646  printf("Input bit depth                   :");
     4647  for (Int i = 0; i < m_numRepFormats; i++ )
     4648  {
     4649    printf(" (Y:%d, C:%d)", m_inputBitDepths[i][CHANNEL_TYPE_LUMA], m_inputBitDepths[i][CHANNEL_TYPE_CHROMA] );
     4650  }
     4651
     4652  printf("\nMSB-extended bit depth            :");
     4653  for (Int i = 0; i < m_numRepFormats; i++ )
     4654  {
     4655    printf(" (Y:%d, C:%d)", m_MSBExtendedBitDepths[i][CHANNEL_TYPE_LUMA], m_MSBExtendedBitDepths[i][CHANNEL_TYPE_CHROMA] );
     4656  }
     4657
     4658  printf("\nInternal bit depth                :");
     4659  for (Int i = 0; i < m_numRepFormats; i++ )
     4660  {
     4661    printf(" (Y:%d, C:%d)", m_internalBitDepths[i][CHANNEL_TYPE_LUMA], m_internalBitDepths[i][CHANNEL_TYPE_CHROMA] );
     4662  }
     4663 
     4664  printf("\nPCM sample bit depth              :");
     4665  for (Int i = 0; i < m_numRepFormats; i++ )
     4666  {
     4667    printf(" (Y:%d, C:%d)", m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepths[i][CHANNEL_TYPE_LUMA]   : m_internalBitDepths[i][CHANNEL_TYPE_LUMA],
     4668                             m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepths[i][CHANNEL_TYPE_CHROMA] : m_internalBitDepths[i][CHANNEL_TYPE_CHROMA] );
     4669  }
     4670  printf("\n" );
     4671#else
    35634672  printf("Input bit depth                   : (Y:%d, C:%d)\n", m_inputBitDepth[CHANNEL_TYPE_LUMA], m_inputBitDepth[CHANNEL_TYPE_CHROMA] );
    35644673  printf("MSB-extended bit depth            : (Y:%d, C:%d)\n", m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA], m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] );
     
    35664675  printf("PCM sample bit depth              : (Y:%d, C:%d)\n", m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA] : m_internalBitDepth[CHANNEL_TYPE_LUMA],
    35674676                                                               m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] : m_internalBitDepth[CHANNEL_TYPE_CHROMA] );
     4677#endif
    35684678  printf("Intra reference smoothing         : %s\n", (m_enableIntraReferenceSmoothing          ? "Enabled" : "Disabled") );
    35694679  printf("diff_cu_chroma_qp_offset_depth         : %d\n", m_diffCuChromaQpOffsetDepth);
     
    36294739    printf("InitialQP                         : %d\n", m_RCInitialQP );
    36304740    printf("ForceIntraQP                      : %d\n", m_RCForceIntraQP );
    3631 
    3632 #if U0132_TARGET_BITS_SATURATION
    36334741    printf("CpbSaturation                          : %d\n", m_RCCpbSaturationEnabled );
    36344742    if (m_RCCpbSaturationEnabled)
     
    36374745      printf("InitalCpbFullness                      : %.2f\n", m_RCInitialCpbFullness);
    36384746    }
    3639 #endif
    36404747
    36414748#if KWU_RC_MADPRED_E0227
     
    36864793#if NH_MV
    36874794  printf("TOOL CFG General: ");
     4795
     4796  for( Int i = 0; i < m_numRepFormats; i++)
     4797  {
     4798    printf("IBD(%d):%d ", i, ((m_internalBitDepths[i][CHANNEL_TYPE_LUMA] > m_MSBExtendedBitDepths[i][CHANNEL_TYPE_LUMA]) || (m_internalBitDepths[i][CHANNEL_TYPE_CHROMA] > m_MSBExtendedBitDepths[i][CHANNEL_TYPE_CHROMA])));
     4799  }
    36884800#else
    36894801  printf("TOOL CFG: ");
    3690 #endif
    3691   printf("IBD:%d ", ((m_internalBitDepth[CHANNEL_TYPE_LUMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA]) || (m_internalBitDepth[CHANNEL_TYPE_CHROMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA])));
     4802    printf("IBD:%d ", ((m_internalBitDepth[CHANNEL_TYPE_LUMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA]) || (m_internalBitDepth[CHANNEL_TYPE_CHROMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA])));
     4803#endif
     4804
    36924805  printf("HAD:%d ", m_bUseHADME           );
    36934806  printf("RDQ:%d ", m_useRDOQ            );
    36944807  printf("RDQTS:%d ", m_useRDOQTS        );
    36954808  printf("RDpenalty:%d ", m_rdPenalty  );
     4809  printf("LQP:%d ", m_lumaLevelToDeltaQPMapping.mode     );
    36964810  printf("SQP:%d ", m_uiDeltaQpRD         );
    36974811  printf("ASR:%d ", m_bUseASR             );
     
    37234837  printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
    37244838
    3725   if (m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce)
     4839  if (m_TransquantBypassEnabledFlag && m_CUTransquantBypassFlagForce)
    37264840  {
    37274841    printf("TransQuantBypassEnabled: =1");
     
    37294843  else
    37304844  {
    3731     printf("TransQuantBypassEnabled:%d ", (m_TransquantBypassEnableFlag)? 1:0 );
     4845    printf("TransQuantBypassEnabled:%d ", (m_TransquantBypassEnabledFlag)? 1:0 );
    37324846  }
    37334847
     
    37354849  printf("WPB:%d ", (Int)m_useWeightedBiPred);
    37364850  printf("PME:%d ", m_log2ParallelMergeLevel);
     4851#if NH_MV
     4852  for( Int i = 0; i < m_numRepFormats; i++ )
     4853  {
     4854    const Int iWaveFrontSubstreams = m_entropyCodingSyncEnabledFlag ? (m_iSourceHeights[i] + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
     4855    printf(" WaveFrontSynchro(%d):%d WaveFrontSubstreams(%d):%d", i, m_entropyCodingSyncEnabledFlag?1:0, i, iWaveFrontSubstreams );
     4856  }
     4857#else
    37374858  const Int iWaveFrontSubstreams = m_entropyCodingSyncEnabledFlag ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
    37384859  printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_entropyCodingSyncEnabledFlag?1:0, iWaveFrontSubstreams);
     4860#endif
    37394861  printf(" ScalingList:%d ", m_useScalingListId );
    37404862  printf("TMVPMode:%d ", m_TMVPModeId     );
     
    37434865#endif
    37444866
    3745   printf(" SignBitHidingFlag:%d ", m_signHideFlag);
     4867  printf(" SignBitHidingFlag:%d ", m_signDataHidingEnabledFlag);
    37464868  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
     4869#if EXTENSION_360_VIDEO
     4870  m_ext360.outputConfigurationSummary();
     4871#endif
    37474872#if NH_3D_VSO
    37484873  printf(" VSO:%d ", m_bUseVSO   );
    37494874  printf("WVSO:%d ", m_bUseWVSO ); 
    37504875#endif
    3751 #if NH_3D_QTL
     4876#if NH_3D
    37524877  printf( "QTL:%d "                  , m_bUseQTL);
    3753 #endif
    3754 #if NH_3D
    37554878  printf( "IlluCompEnable:%d "       , m_abUseIC);
    37564879  printf( "IlluCompLowLatencyEnc:%d ",  m_bUseLowLatencyICEnc);
     
    37804903  fflush(stdout);
    37814904}
     4905#if NH_MV
     4906
     4907Void TAppEncCfg::xConfirmRepFormat(const TComVPS& vps )
     4908{
     4909  Bool checkFailed = false;
     4910
     4911  // This might not cover all disallowed cases. To be further tested.
     4912#if NH_3D
     4913  Bool allDepthSameBitDepth = true;
     4914  Bool allSameSize          = true;
     4915  Bool allTextureChroma420  = true;
     4916 
     4917  Int  lastBitDepth         = -1;
     4918  Int  lastWidth            = -1;
     4919  Int  lastHeight           = -1;
     4920
     4921  Int lastChromaFormat     = (Int) CHROMA_420;
     4922
     4923  for(Int i = 0; i <= vps.getMaxLayersMinus1(); i++ )
     4924  {
     4925    Int curLayerIdInNuh = vps.getLayerIdInNuh( i );
     4926
     4927    const TComRepFormat* repFormat = vps.getRepFormat( vps.getVpsRepFormatIdx( i  ) );
     4928
     4929    Int curWidth = repFormat->getPicWidthVpsInLumaSamples();
     4930    allSameSize  = allSameSize && ( lastWidth == -1 || lastWidth  == curWidth );
     4931    lastWidth    = curWidth;
     4932
     4933    Int curHeight = repFormat->getPicHeightVpsInLumaSamples();
     4934    allSameSize   = allSameSize && ( lastHeight == -1 || lastHeight  == curHeight );
     4935    lastHeight    = curHeight;
     4936
     4937    if ( vps.getVpsDepthFlag( curLayerIdInNuh ))
     4938    {
     4939      Int curBitDepth      = repFormat->getBitDepthVpsLumaMinus8();
     4940      allDepthSameBitDepth = allDepthSameBitDepth && ( lastBitDepth == -1 || lastBitDepth  == curBitDepth );
     4941      lastBitDepth         = curBitDepth;
     4942    }
     4943    else
     4944    {
     4945      Int curChromaFormat = repFormat->getChromaFormatVpsIdc();
     4946      allTextureChroma420 = allTextureChroma420 && ( lastChromaFormat  == curChromaFormat );
     4947      lastChromaFormat    = curChromaFormat;
     4948    }
     4949  }
     4950
     4951  checkFailed |= confirmPara( !allDepthSameBitDepth                                         ,  "The HTM implementation requires that InternalBitDepth of all depth layers must be equal."  );
     4952  checkFailed |= confirmPara( !allSameSize           && ( m_bUseVSO || m_bUseEstimatedVSD ) ,  "When VSO or VSD are enabled, the HTM implementation requires that SourceHeight and SourceWidth of all layers must be equal."  );
     4953  checkFailed |= confirmPara( !allTextureChroma420   &&  m_bUseVSO                          ,  "When VSO is enabled, the HTM implementation requires that all textures have ChromaFormat 420."  ); 
     4954#endif
     4955
     4956  // Check reference layers
     4957  for (Int curLayerId = 0; curLayerId <= vps.getMaxLayersMinus1(); curLayerId++ )
     4958  { 
     4959
     4960    const TComRepFormat* curRepFormat = vps.getRepFormat( vps.getVpsRepFormatIdx( curLayerId  ) );
     4961
     4962    Int curLayerIdInNuh      = vps.getLayerIdInNuh( curLayerId );
     4963   
     4964    for( Int i = 0; i < vps.getNumDirectRefLayers( curLayerIdInNuh ); i++ )
     4965    {
     4966      Int refLayerId =  vps.getLayerIdInVps( vps.getIdDirectRefLayer( curLayerIdInNuh, i ));//   refLayers[i];
     4967      const TComRepFormat* refRepFormat = vps.getRepFormat( vps.getVpsRepFormatIdx( refLayerId ) );
     4968
     4969      // Require equal size
     4970      xConfirmSingleRepFormat( checkFailed, "SourceHeight",curLayerId, refLayerId,  curRepFormat->getPicHeightVpsInLumaSamples(), refRepFormat->getPicHeightVpsInLumaSamples() );
     4971      xConfirmSingleRepFormat( checkFailed, "SourceWidth" ,curLayerId, refLayerId,  curRepFormat->getPicWidthVpsInLumaSamples() , refRepFormat->getPicWidthVpsInLumaSamples () );
     4972#if NH_3D
     4973
     4974      // For 3D-HEVC, dependencies can be e.g. from texture 4:2:0 to depth 4:0:0, so check only layers that might be inserted to the reference lists.
     4975    }
     4976
     4977    for( Int i = 0; i < vps.getNumRefListLayers( curLayerIdInNuh  ); i++ )
     4978    {
     4979      Int refLayerId =  vps.getLayerIdInVps( vps.getIdRefListLayer( curLayerIdInNuh, i ) );//   refLayers[i];
     4980      const TComRepFormat* refRepFormat = vps.getRepFormat( vps.getVpsRepFormatIdx( refLayerId ) );
     4981#endif
     4982      // Sample dependency -> require same bit depth and chroma format
     4983      xConfirmSingleRepFormat( checkFailed, "ChromaFormatIDC"          , curLayerId, refLayerId,  curRepFormat->getChromaFormatVpsIdc()     , refRepFormat->getChromaFormatVpsIdc()  );
     4984      xConfirmSingleRepFormat( checkFailed, "InternalBitDepth (Luma)"  , curLayerId, refLayerId,  curRepFormat->getBitDepthVpsLumaMinus8()  , refRepFormat->getBitDepthVpsLumaMinus8());
     4985      xConfirmSingleRepFormat( checkFailed, "InternalBitDepth (Chroma)", curLayerId, refLayerId,  curRepFormat->getBitDepthVpsChromaMinus8(), refRepFormat->getBitDepthVpsChromaMinus8());
     4986    }
     4987    // TBD: add 3D-HEVC constraints e.g. for VSP, QTL
     4988  }
     4989
     4990  if( checkFailed )
     4991  {
     4992    exit(0);
     4993  }
     4994}
     4995
     4996Void TAppEncCfg::xConvertRepFormatParameters(
     4997  IntAry2d& tmpPad                       ,             
     4998  IntAry2d& tmpInputBitDepth             ,
     4999  IntAry2d& tmpOutputBitDepth            ,
     5000  IntAry2d& tmpMSBExtendedBitDepth       ,
     5001  IntAry2d& tmpInternalBitDepth          ,
     5002  IntAry1d& tmpInputChromaFormat         ,
     5003  IntAry1d& tmpChromaFormat
     5004  )
     5005{
     5006  typedef std::pair< IntAry2d*,  IntAry2d* > ParamMapPair;
     5007  std::vector< ParamMapPair > paramTwoElem;
     5008  paramTwoElem.push_back( ParamMapPair( &tmpPad                ,  &m_aiPads               )  );
     5009  paramTwoElem.push_back( ParamMapPair( &tmpInputBitDepth      ,  &m_inputBitDepths       )  );
     5010  paramTwoElem.push_back( ParamMapPair( &tmpOutputBitDepth     ,  &m_outputBitDepths      )  );
     5011  paramTwoElem.push_back( ParamMapPair( &tmpMSBExtendedBitDepth,  &m_MSBExtendedBitDepths )  );
     5012  paramTwoElem.push_back( ParamMapPair( &tmpInternalBitDepth   ,  &m_internalBitDepths    )  );
     5013 
     5014  std::vector< IntAry1d* > paramOneElem;
     5015  paramOneElem.push_back(  &m_confWinLefts  ); 
     5016  paramOneElem.push_back(  &m_confWinRights );
     5017  paramOneElem.push_back(  &m_confWinTops   );
     5018  paramOneElem.push_back(  &m_confWinBottoms);
     5019  paramOneElem.push_back(  &m_iSourceWidths );
     5020  paramOneElem.push_back(  &m_iSourceHeights);
     5021  paramOneElem.push_back(  &tmpInputChromaFormat );
     5022  paramOneElem.push_back(  &tmpChromaFormat );
     5023
     5024
     5025  // Get maximum number of representation formats
     5026  size_t maxSize = 0;
     5027
     5028  for (Int i = 0; i < paramTwoElem.size(); i++)
     5029  {
     5030    for (Int j = 0; j < 2; j++ )
     5031    {
     5032      IntAry1d& curElems = (* (paramTwoElem[i].first) )[j];
     5033      maxSize = std::max<size_t>(  maxSize, curElems.size()  );
     5034    }   
     5035  }
     5036
     5037  for (Int i = 0; i < paramOneElem.size(); i++)
     5038  {
     5039    maxSize = std::max<size_t>(  maxSize, (paramOneElem[i]->size() ) );
     5040  }
     5041
     5042  // Resize to maximum
     5043  for (Int i = 0; i < paramTwoElem.size(); i++)
     5044  {
     5045    IntAry2d& curElems = (* (paramTwoElem[i].first) );   
     5046    for (Int j = 0; j < 2; j++ )
     5047    {
     5048      xResizeVector( curElems[j], (UInt) maxSize );       
     5049    }
     5050  }
     5051
     5052  for (Int i = 0; i < paramOneElem.size(); i++)
     5053  {
     5054    xResizeVector( (*paramOneElem[i]), (UInt) maxSize );             
     5055  }
     5056 
     5057  // Transpose
     5058  for (Int i = 0; i < paramTwoElem.size(); i++)
     5059  {
     5060    IntAry2d&  curElem  = (* (paramTwoElem[i].first  ) );
     5061    IntAry2d&  curElemT = (* (paramTwoElem[i].second ) );
     5062
     5063    curElemT.resize(maxSize);
     5064    for (Int k = 0; k < maxSize; k++ )
     5065    {
     5066      curElemT[k].resize(2);
     5067      for (Int j = 0; j < 2; j++ )
     5068      {
     5069        curElemT[k][j] = curElem[j][k];
     5070      }
     5071    }   
     5072  }
     5073
     5074  m_numRepFormats = (Int) maxSize;
     5075}
     5076
     5077
     5078
     5079Void TAppEncCfg::xGetMaxValuesOfApplicableLayers(const TComVPS& vps, Int vpsPtlIdx, Int& maxBitDepthLuma, Int& maxBitDepthChroma, ChromaFormat& maxChromaFormatIdc, Int& maxNumRefLayers )
     5080{
     5081  maxChromaFormatIdc        = CHROMA_400;
     5082  maxBitDepthLuma   = -1;
     5083  maxBitDepthChroma = -1;
     5084  maxNumRefLayers   = 0;
     5085
     5086  IntAry1d applicableLayerIdsInVps = vps.getLayersOfVpsPtl( vpsPtlIdx );
     5087
     5088  for (Int i = 0; i < applicableLayerIdsInVps.size(); i++ )
     5089  {
     5090    Int curLayerIdInVps       = applicableLayerIdsInVps[ i ];
     5091    Int repFormatIdx          = m_layerIdxInVpsToRepFormatIdx[ curLayerIdInVps ];
     5092    maxChromaFormatIdc        = std::max<ChromaFormat> ( m_chromaFormatIDCs[ repFormatIdx], maxChromaFormatIdc );
     5093    maxBitDepthLuma   = std::max<Int> ( m_internalBitDepths[ repFormatIdx ][CHANNEL_TYPE_LUMA  ], maxBitDepthLuma   );
     5094    maxBitDepthChroma = std::max<Int> ( m_internalBitDepths[ repFormatIdx ][CHANNEL_TYPE_CHROMA], maxBitDepthChroma );
     5095    maxNumRefLayers   = std::max<Int> ( vps.getNumRefLayers( vps.getLayerIdInNuh( curLayerIdInVps ) ), maxNumRefLayers ) ;
     5096  }
     5097}
     5098
     5099#endif
    37825100
    37835101Bool confirmPara(Bool bflag, const TChar* message)
  • trunk/source/App/TAppEncoder/TAppEncCfg.h

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4242
    4343#include "TLibEncoder/TEncCfg.h"
     44#if EXTENSION_360_VIDEO
     45#include "TAppEncHelper360/TExt360AppEncCfg.h"
     46#endif
    4447#include <sstream>
    4548#include <vector>
     
    5659// ====================================================================================================================
    5760
     61#if NH_MV
     62enum UIProfileName // this is used for determining profile strings, where multiple profiles map to a single profile idc with various constraint flag combinations
     63{
     64  UI_NONE = 0,
     65  UI_MAIN = 1,
     66  UI_MAIN10 = 2,
     67  UI_MAIN10_STILL_PICTURE=10002,
     68  UI_MAINSTILLPICTURE = 3,
     69  UI_MAINREXT = 4,
     70  UI_HIGHTHROUGHPUTREXT = 5,
     71  // The following are RExt profiles, which would map to the MAINREXT profile idc.
     72  // The enumeration indicates the bit-depth constraint in the bottom 2 digits
     73  //                           the chroma format in the next digit
     74  //                           the intra constraint in the next digit (1 for no intra constraint, 2 for intra constraint)
     75  //                           If it is a RExt still picture, there is a '1' for the top digit.
     76#if NH_MV
     77  UI_MULTIVIEWMAIN     = 6,
     78#if NH_3D
     79  UI_MAIN3D            = 8,
     80#endif
     81#endif
     82  UI_MONOCHROME_8      = 1008,
     83  UI_MONOCHROME_12     = 1012,
     84  UI_MONOCHROME_16     = 1016,
     85  UI_MAIN_12           = 1112,
     86  UI_MAIN_422_10       = 1210,
     87  UI_MAIN_422_12       = 1212,
     88  UI_MAIN_444          = 1308,
     89  UI_MAIN_444_10       = 1310,
     90  UI_MAIN_444_12       = 1312,
     91  UI_MAIN_444_16       = 1316, // non-standard profile definition, used for development purposes
     92  UI_MAIN_INTRA        = 2108,
     93  UI_MAIN_10_INTRA     = 2110,
     94  UI_MAIN_12_INTRA     = 2112,
     95  UI_MAIN_422_10_INTRA = 2210,
     96  UI_MAIN_422_12_INTRA = 2212,
     97  UI_MAIN_444_INTRA    = 2308,
     98  UI_MAIN_444_10_INTRA = 2310,
     99  UI_MAIN_444_12_INTRA = 2312,
     100  UI_MAIN_444_16_INTRA = 2316,
     101  UI_MAIN_444_STILL_PICTURE = 11308,
     102  UI_MAIN_444_16_STILL_PICTURE = 12316,
     103  // The following are high throughput profiles, which would map to the HIGHTHROUGHPUTREXT profile idc.
     104  // The enumeration indicates the bit-depth constraint in the bottom 2 digits
     105  //                           the chroma format in the next digit
     106  //                           the intra constraint in the next digit
     107  //                           There is a '2' for the top digit to indicate it is high throughput profile
     108
     109  UI_HIGHTHROUGHPUT_444     = 21308,
     110  UI_HIGHTHROUGHPUT_444_10  = 21310,
     111  UI_HIGHTHROUGHPUT_444_14  = 21314,
     112  UI_HIGHTHROUGHPUT_444_16_INTRA  = 22316
     113#if NH_MV_ALLOW_NON_CONFORMING
     114  ,
     115  UI_MULTIVIEWMAIN_NONCONF     = 10000006,
     116#if NH_3D
     117  UI_MAIN3D_NONCONF            = 10000008,
     118#endif
     119#endif
     120};
     121#endif
     122
    58123/// encoder configuration class
    59124class TAppEncCfg
    60125{
     126#if JVET_E0059_FLOATING_POINT_QP_FIX
     127public:
     128  template <class T>
     129  struct OptionalValue
     130  {
     131    Bool bPresent;
     132    T    value;
     133    OptionalValue() : bPresent(false), value() { }
     134  };
     135#endif
     136
    61137protected:
    62138  // file I/O
     
    71147  Int                    m_numberOfLayers;                    ///< number of Layers to Encode
    72148  Int                    m_iNumberOfViews;                    ///< number of Layers that are views
     149#if NH_MV
     150  Bool                   m_shareParameterSets;
     151  IntAry1d               m_layerIdxInVpsToGopDefIdx;
     152  IntAry1d               m_layerIdxInVpsToRepFormatIdx; 
     153  Int                    m_numRepFormats;
     154  Int                    m_numInputOutputRepFormats;
     155#endif
    73156#else
    74157  std::string m_reconFileName;                                ///< output reconstruction file
     
    91174// layer sets   
    92175  Int                    m_vpsNumLayerSets;                   ///< Number of layer sets
    93   IntAry2d m_layerIdxInVpsInSets;           ///< LayerIds in vps of layer set
    94   Int                    m_numAddLayerSets;                    ///< Number of additional layer sets
    95   IntAry2d m_highestLayerIdxPlus1;      ///< HighestLayerIdxPlus1 for each additional layer set and each independent layer (value with index 0 will be ignored)
     176  IntAry2d               m_layerIdxInVpsInSets;               ///< LayerIds in vps of layer set
     177  Int                    m_numAddLayerSets;                   ///< Number of additional layer sets
     178  IntAry2d               m_highestLayerIdxPlus1;              ///< HighestLayerIdxPlus1 for each additional layer set and each independent layer (value with index 0 will be ignored)
    96179  Int                    m_defaultOutputLayerIdc;             ///< Specifies output layers of layer sets, 0: output all layers, 1: output highest layers, 2: specified by LayerIdsInDefOuputLayerSet
    97180  IntAry1d               m_outputLayerSetIdx;                 ///< Indices of layer sets used as additional output layer sets 
    98   IntAry2d m_layerIdsInAddOutputLayerSet; ///< LayerIds in vps of additional output layers
    99   IntAry2d m_layerIdsInDefOutputLayerSet; ///< Indices in vps of output layers in layer sets
    100   IntAry2d               m_profileTierLevelIdx;      ///< Indices of of profile, per layer in layer set
     181  IntAry2d               m_layerIdsInAddOutputLayerSet;      ///< LayerIds in vps of additional output layers
     182  IntAry2d               m_layerIdsInDefOutputLayerSet;      ///< Indices in vps of output layers in layer sets
     183  IntAry2d               m_profileTierLevelIdx;               ///< Indices of of profile, per layer in layer set
    101184  BoolAry1d              m_altOutputLayerFlag;                ///< Alt output layer flag
    102185
     
    145228  UInt      m_FrameSkip;                                   ///< number of skipped frames from the beginning
    146229  UInt      m_temporalSubsampleRatio;                         ///< temporal subsample ratio, 2 means code every two frames
    147   Int       m_iSourceWidth;                                   ///< source width in pixel
    148   Int       m_iSourceHeight;                                  ///< source height in pixel (when interlaced = field height)
     230 
     231#if NH_MV
     232  IntAry1d       m_iSourceWidths   ;                                   ///< source width in pixel
     233  IntAry1d       m_iSourceHeights  ;                                  ///< source height in pixel (when interlaced = field height)
     234  IntAry1d       m_inputFileWidths ;                                 ///< width of image in input file  (this is equivalent to sourceWidth,  if sourceWidth  is not subsequently altered due to padding)
     235  IntAry1d       m_inputFileHeights;                                ///< height of image in input file (this is equivalent to sourceHeight, if sourceHeight is not subsequently altered due to padding)
     236
     237  IntAry1d       m_iSourceHeightOrgs;                               ///< original source height in pixel (when interlaced = frame height)
     238#else
     239  Int       m_iSourceWidth   ;                                   ///< source width in pixel
     240  Int       m_iSourceHeight  ;                                  ///< source height in pixel (when interlaced = field height)
     241  Int       m_inputFileWidth ;                                 ///< width of image in input file  (this is equivalent to sourceWidth,  if sourceWidth  is not subsequently altered due to padding)
     242  Int       m_inputFileHeight;                                ///< height of image in input file (this is equivalent to sourceHeight, if sourceHeight is not subsequently altered due to padding)
    149243
    150244  Int       m_iSourceHeightOrg;                               ///< original source height in pixel (when interlaced = frame height)
     245#endif
    151246
    152247  Bool      m_isField;                                        ///< enable field coding
     
    156251
    157252  Int       m_conformanceWindowMode;
     253#if NH_MV
     254  IntAry1d  m_confWinLefts  ;
     255  IntAry1d  m_confWinRights ;
     256  IntAry1d  m_confWinTops   ;
     257  IntAry1d  m_confWinBottoms;
     258#else
    158259  Int       m_confWinLeft;
    159260  Int       m_confWinRight;
    160261  Int       m_confWinTop;
    161262  Int       m_confWinBottom;
     263#endif
    162264  Int       m_framesToBeEncoded;                              ///< number of encoded frames
     265#if NH_MV
     266  IntAry2d  m_aiPads;                              ///< number of padded pixels for width and height
     267#else
    163268  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
     269#endif
    164270  Bool      m_AccessUnitDelimiter;                            ///< add Access Unit Delimiter NAL units
    165271  InputColourSpaceConversion m_inputColourSpaceConvert;       ///< colour space conversion to apply to input video
    166272  Bool      m_snrInternalColourSpace;                       ///< if true, then no colour space conversion is applied for snr calculation, otherwise inverse of input is applied.
    167273  Bool      m_outputInternalColourSpace;                    ///< if true, then no colour space conversion is applied for reconstructed video, otherwise inverse of input is applied.
     274#if NH_MV
     275  std::vector<ChromaFormat> m_InputChromaFormatIDC;
     276#else
    168277  ChromaFormat m_InputChromaFormatIDC;
     278#endif
    169279
    170280  Bool      m_printMSEBasedSequencePSNR;
    171281  Bool      m_printFrameMSE;
    172282  Bool      m_printSequenceMSE;
     283#if JVET_F0064_MSSSIM
     284  Bool      m_printMSSSIM;
     285#endif
    173286  Bool      m_cabacZeroWordPaddingEnabled;
    174287  Bool      m_bClipInputVideoToRec709Range;
     
    178291#if NH_MV
    179292  std::vector< Profile::Name > m_profiles;
     293 
     294  std::vector<UIProfileName>   m_uiProfiles;
     295
    180296  std::vector< Level::Tier   > m_levelTier;
    181297  std::vector< Level::Name   > m_level;
    182298  std::vector< Bool          > m_inblFlag;
     299
     300  IntAry1d                    m_bitDepthConstraints          ;
     301  IntAry1d                    m_tmpConstraintChromaFormats   ;
     302  std::vector< ChromaFormat > m_chromaFormatConstraints      ;
     303  BoolAry1d                   m_intraConstraintFlags         ;
     304  BoolAry1d                   m_onePictureOnlyConstraintFlags;
     305  BoolAry1d                   m_lowerBitRateConstraintFlags  ;
     306  BoolAry1d                   m_progressiveSourceFlags       ;
     307  BoolAry1d                   m_interlacedSourceFlags        ;
     308  BoolAry1d                   m_nonPackedConstraintFlags     ;
     309  BoolAry1d                   m_frameOnlyConstraintFlags     ;
     310
    183311#else
    184312  Profile::Name m_profile;
    185313  Level::Tier   m_levelTier;
    186314  Level::Name   m_level;
    187 #endif
    188315  UInt          m_bitDepthConstraint;
    189316  ChromaFormat  m_chromaFormatConstraint;
     
    191318  Bool          m_onePictureOnlyConstraintFlag;
    192319  Bool          m_lowerBitRateConstraintFlag;
    193   Bool m_progressiveSourceFlag;
    194   Bool m_interlacedSourceFlag;
    195   Bool m_nonPackedConstraintFlag;
    196   Bool m_frameOnlyConstraintFlag;
     320  Bool          m_progressiveSourceFlag;
     321  Bool          m_interlacedSourceFlag;
     322  Bool          m_nonPackedConstraintFlag;
     323  Bool          m_frameOnlyConstraintFlag;
     324#endif
    197325
    198326  // coding structure
     
    204332  Int       m_iDecodingRefreshType;                           ///< random access type
    205333  Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
     334#if JCTVC_Y0038_PARAMS
     335  Bool      m_bReWriteParamSetsFlag;                          ///< Flag to enable rewriting of parameter sets at random access points
     336#endif 
    206337#if NH_MV
    207338  Int       m_extraRPSsMvc[MAX_NUM_LAYERS];                       ///< extra RPSs added to handle CRA for each layer
     
    234365  // coding quality
    235366#if NH_MV
     367#if JVET_E0059_FLOATING_POINT_QP_FIX
     368  std::vector<Int>   m_qpIncrementAtSourceFrame;             ///< Optional source frame number at which all subsequent frames are to use an increased internal QP.
     369#else
    236370  std::vector<Double>  m_fQP;                                 ///< QP value of key-picture (floating point) for each layer
     371#endif
    237372  std::vector<Int>     m_iQP;                                 ///< QP value of key-picture (integer) for each layer
    238373#else
     374#if JVET_E0059_FLOATING_POINT_QP_FIX
     375  OptionalValue<UInt> m_qpIncrementAtSourceFrame;             ///< Optional source frame number at which all subsequent frames are to use an increased internal QP.
     376#else
    239377  Double    m_fQP;                                            ///< QP value of key-picture (floating point)
     378#endif
    240379  Int       m_iQP;                                            ///< QP value of key-picture (integer)
     380#endif
     381#if X0038_LAMBDA_FROM_QP_CAPABILITY
     382  Int       m_intraQPOffset;                                  ///< QP offset for intra slice (integer)
     383  Bool      m_lambdaFromQPEnable;                             ///< enable flag for QP:lambda fix
    241384#endif
    242385  std::string m_dQPFileName;                                  ///< QP offset for each slice (initialized from external file)
     
    254397  Int       m_cbQpOffset;                                     ///< Chroma Cb QP Offset (0:default)
    255398  Int       m_crQpOffset;                                     ///< Chroma Cr QP Offset (0:default)
    256 
    257 #if W0038_CQP_ADJ
     399  WCGChromaQPControl m_wcgChromaQpControl;                    ///< Wide-colour-gamut chroma QP control.
    258400  UInt      m_sliceChromaQpOffsetPeriodicity;                 ///< Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature.
    259401  Int       m_sliceChromaQpOffsetIntraOrPeriodic[2/*Cb,Cr*/]; ///< Chroma Cb QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.
    260 #endif
     402  LumaLevelToDeltaQPMapping m_lumaLevelToDeltaQPMapping;      ///< mapping from luma level to Delta QP.
    261403#if ADAPTIVE_QP_SELECTION
    262404  Bool      m_bUseAdaptQpSelect;
     
    282424  UInt      m_uiMaxCUHeight;                                  ///< max. CU height in pixel
    283425  UInt      m_uiMaxCUDepth;                                   ///< max. CU depth (as specified by command line)
    284   UInt      m_uiMaxTotalCUDepth;                              ///< max. total CU depth - includes depth of transform-block structure
     426#if NH_MV
     427  IntAry1d  m_uiMaxTotalCUDepth;                              ///< max. total CU depth - includes depth of transform-block structure 
     428#else
     429  UInt      m_uiMaxTotalCUDepth;                              ///< max. total CU depth - includes depth of transform-block structure 
     430#endif
    285431  UInt      m_uiLog2DiffMaxMinCodingBlockSize;                ///< difference between largest and smallest CU depth
    286432
     
    293439
    294440  // coding tools (bit-depth)
     441#if NH_MV
     442  IntAry2d  m_inputBitDepths      ;         ///< bit-depth of input file
     443  IntAry2d  m_outputBitDepths     ;         ///< bit-depth of output file
     444  IntAry2d  m_MSBExtendedBitDepths;         ///< bit-depth of input samples after MSB extension
     445  IntAry2d  m_internalBitDepths   ;         ///< bit-depth codec operates at (input/output files will be converted)
     446#else
    295447  Int       m_inputBitDepth   [MAX_NUM_CHANNEL_TYPE];         ///< bit-depth of input file
    296448  Int       m_outputBitDepth  [MAX_NUM_CHANNEL_TYPE];         ///< bit-depth of output file
    297449  Int       m_MSBExtendedBitDepth[MAX_NUM_CHANNEL_TYPE];      ///< bit-depth of input samples after MSB extension
    298450  Int       m_internalBitDepth[MAX_NUM_CHANNEL_TYPE];         ///< bit-depth codec operates at (input/output files will be converted)
     451#endif
     452
    299453  Bool      m_extendedPrecisionProcessingFlag;
    300454  Bool      m_highPrecisionOffsetsEnabledFlag;
    301455
    302456  //coding tools (chroma format)
     457#if NH_MV
     458  std::vector<ChromaFormat> m_chromaFormatIDCs;
     459#else
    303460  ChromaFormat m_chromaFormatIDC;
     461#endif
    304462
    305463  // coding tools (PCM bit-depth)
     
    317475  Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
    318476  Bool      m_saoCtuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for CTU bottom and right boundary areas
    319 #if OPTIONAL_RESET_SAO_ENCODING_AFTER_IRAP
    320477  Bool      m_saoResetEncoderStateAfterIRAP;                  ///< When true, SAO encoder state will be reset following an IRAP.
    321 #endif
    322478  // coding tools (loop filter)
    323479#if NH_MV
     
    329485  Int       m_loopFilterBetaOffsetDiv2;                     ///< beta offset for deblocking filter
    330486  Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
    331 #if W0038_DB_OPT
    332487  Int       m_deblockingFilterMetric;                         ///< blockiness metric in encoder
    333 #else
    334   Bool      m_DeblockingFilterMetric;                         ///< blockiness metric in encoder
    335 #endif
    336488  // coding tools (PCM)
    337489  Bool      m_usePCM;                                         ///< flag for using IPCM
     
    346498  Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
    347499  Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
    348 #if T0196_SELECTIVE_RDOQ
    349500  Bool      m_useSelectiveRDOQ;                               ///< flag for using selective RDOQ
    350 #endif
    351501  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)
    352502  Bool      m_bDisableIntraPUsInInterSlices;                  ///< Flag for disabling intra predicted PUs in inter slices.
     
    437587  Bool      m_scalableNestingSEIEnabled;
    438588  Bool      m_tmctsSEIEnabled;
     589#if MCTS_ENC_CHECK
     590  Bool      m_tmctsSEITileConstraint;
     591#endif
    439592  Bool      m_timeCodeSEIEnabled;
    440593  Int       m_timeCodeSEINumTs;
     
    451604  Int*      m_kneeSEIInputKneePoint;
    452605  Int*      m_kneeSEIOutputKneePoint;
    453 #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
    454606  Int       m_preferredTransferCharacteristics;
    455 #endif
     607  UInt      m_greenMetadataType;
     608  UInt      m_xsdMetricType;
    456609
    457610  // weighted prediction
     
    464617
    465618  Int       m_TMVPModeId;
    466   Bool      m_signHideFlag;
     619  Bool      m_signDataHidingEnabledFlag;
    467620  Bool      m_RCEnableRateControl;                ///< enable rate control or not
    468621  Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
     
    472625  Int       m_RCInitialQP;                        ///< inital QP for rate control
    473626  Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
    474 
    475 #if U0132_TARGET_BITS_SATURATION
    476627  Bool      m_RCCpbSaturationEnabled;             ///< enable target bits saturation to avoid CPB overflow and underflow
    477628  UInt      m_RCCpbSize;                          ///< CPB size
    478629  Double    m_RCInitialCpbFullness;               ///< initial CPB fullness
    479 #endif
    480630
    481631#if KWU_RC_VIEWRC_E0227
     
    490640  std::string m_scalingListFileName;                          ///< quantization matrix file name
    491641
    492   Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
    493   Bool      m_CUTransquantBypassFlagForce;                    ///< if transquant_bypass_enable_flag, then, if true, all CU transquant bypass flags will be set to true.
     642  Bool      m_TransquantBypassEnabledFlag;                    ///< transquant_bypass_enabled_flag setting in PPS.
     643  Bool      m_CUTransquantBypassFlagForce;                    ///< if transquant_bypass_enabled_flag, then, if true, all CU transquant bypass flags will be set to true.
    494644  CostMode  m_costMode;                                       ///< Cost mode to use
    495645
     
    537687  std::string m_summaryPicFilenameBase;                       ///< Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended.
    538688  UInt        m_summaryVerboseness;                           ///< Specifies the level of the verboseness of the text output.
     689
     690#if EXTENSION_360_VIDEO
     691  TExt360AppEncCfg m_ext360;
     692  friend class TExt360AppEncCfg;
     693  friend class TExt360AppEncTop;
     694#endif
     695
    539696#if NH_MV
    540697  Bool              m_outputVpsInfo;
     
    546703  Bool      m_depth420OutputFlag;                             ///< Output depth layers in 4:2:0 format
    547704#endif
     705
     706#if NH_3D || NH_3D_VSO
    548707    // Camera parameters
    549 #if NH_3D || NH_3D_VSO
    550708  TChar*    m_pchCameraParameterFile;                         ///< camera parameter file
    551709  TAppComCamPara m_cCameraData;
     
    578736#if NH_3D
    579737  Bool       m_useDLT;                                        ///< flag for using DLT
    580 #endif
    581 #if NH_3D_QTL
    582738  Bool       m_bUseQTL;                                        ///< flag for using depth QuadTree Limitation
    583 #endif
    584 #if NH_3D
     739
    585740  BoolAry1d  m_ivMvPredFlag;
    586741  BoolAry1d  m_ivMvScalingFlag;
     
    601756  // internal member functions
    602757  Void  xCheckParameter ();                                   ///< check validity of configuration values
    603   Void  xPrintParameter ();                                   ///< print configuration values
     758  Void  xPrintParameter ();                                   ///< print configuration values 
     759 
    604760  Void  xPrintUsage     ();                                   ///< print usage
    605761#if NH_MV
     762  Void xConfirmRepFormat( const TComVPS& vps);
     763  Void xDeriveProfAndConstrFlags( const TComVPS& vps );
     764  Void xCheckProfiles           ( const TComVPS& vps );
     765
     766  Void xPrintProfiles();
     767
     768  template< typename T >
     769  Void xConfirmSingleRepFormat(Bool& checkFailed, std::string name, Int curLayer, Int refLayer, T valCur, T valRef )
     770  {
     771    if ( valCur != valRef )
     772    {
     773      printf("Error: %s of layer %d and its reference layer %d must be equal. \n", name.c_str(), curLayer, refLayer );
     774      checkFailed = true;
     775    }
     776  }
     777
     778  GOPEntry*  xGetGopEntries( Int layerIdInVps );
     779  GOPEntry*  xGetGopEntry( Int layerIdInVps, Int poc );
    606780
    607781  template<typename T>
     
    697871  Bool  parseCfg  ( Int argc, TChar* argv[] );                ///< parse configuration file to fill member variables
    698872
     873private:
     874  Void   xConvertRepFormatParameters(
     875    IntAry2d& tmpPad                       ,             
     876    IntAry2d& tmpInputBitDepth             ,
     877    IntAry2d& tmpOutputBitDepth            ,
     878    IntAry2d& tmpMSBExtendedBitDepth       ,
     879    IntAry2d& tmpInternalBitDepth          ,
     880    IntAry1d& tmpInputChromaFormat         ,
     881    IntAry1d& tmpChromaFormat
     882    );
     883
     884  Void xGetMaxValuesOfApplicableLayers(const TComVPS& vps, Int vpsPtlIdx, Int& maxBitDepthLuma, Int& maxBitDepthChroma, ChromaFormat& maxChromaFormatIdc, Int& maxNumRefLayers);
    699885};// END CLASS DEFINITION TAppEncCfg
    700886
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4747#include "TLibEncoder/AnnexBwrite.h"
    4848
     49#if EXTENSION_360_VIDEO
     50#include "TAppEncHelper360/TExt360AppEncTop.h"
     51#endif
     52
    4953using namespace std;
    5054
     
    5761
    5862TAppEncTop::TAppEncTop()
     63#if NH_MV
     64  : m_spsMap( MAX_NUM_SPS ),
     65    m_ppsMap( MAX_NUM_PPS )
     66#endif
    5967{
    60 
    6168#if NH_MV
    6269  m_vps = new TComVPS;
     
    8895 
    8996#if NH_3D
    90   vps.createCamPars(m_iNumberOfViews); 
    91 #endif
    92 
    93 #if NH_3D_DLT
    94   TComDLT dlt = TComDLT();
     97  vps.createCamPars(m_iNumberOfViews);   
    9598#endif
    9699
     
    140143  xSetDimensionIdAndLength ( vps );
    141144  xSetDependencies         ( vps );
    142   xSetRepFormat            ( vps );
    143   xSetProfileTierLevel     ( vps );
    144   xSetLayerSets            ( vps );
     145  xSetRepFormat            ( vps );  
     146  xSetLayerSets            ( vps ); 
     147  xSetProfileTierLevel     ( vps ); 
    145148  xSetDpbSize              ( vps );
    146149  xSetVPSVUI               ( vps );
     
    151154  m_ivPicLists.setVPS      ( &vps );
    152155#endif
    153 #if NH_3D_DLT
     156#if NH_3D
     157  TComDLT dlt = TComDLT();
    154158  xDeriveDltArray          ( vps, &dlt );
    155159#endif
     160
     161
     162  xDeriveParameterSetIds( vps );
     163
    156164  if ( m_targetEncLayerIdList.size() == 0 )
    157165  {
     
    182190    vps.printLayerSets();
    183191    vps.printPTL();
     192    vps.printRepFormat();
    184193  }
    185194
     
    188197  for (Int d = 0; d < 2; d++)
    189198  { 
    190     m_sps3dExtension.setIvDiMcEnabledFlag          ( d, m_ivMvPredFlag[d]       );
    191     m_sps3dExtension.setIvMvScalEnabledFlag       ( d, m_ivMvScalingFlag[d]    );
     199    m_sps3dExtension.setIvDiMcEnabledFlag             ( d, m_ivMvPredFlag[d]       );
     200    m_sps3dExtension.setIvMvScalEnabledFlag           ( d, m_ivMvScalingFlag[d]    );
    192201    if (d == 0 )
    193202    {   
    194       m_sps3dExtension.setLog2IvmcSubPbSizeMinus3   ( d, m_log2SubPbSizeMinus3   );
    195       m_sps3dExtension.setIvResPredEnabledFlag         ( d, m_ivResPredFlag         );
    196       m_sps3dExtension.setDepthRefEnabledFlag   ( d, m_depthRefinementFlag   );
    197       m_sps3dExtension.setVspMcEnabledFlag ( d, m_viewSynthesisPredFlag );
    198       m_sps3dExtension.setDbbpEnabledFlag ( d, m_depthBasedBlkPartFlag );
     203      m_sps3dExtension.setLog2IvmcSubPbSizeMinus3     ( d, m_log2SubPbSizeMinus3   );
     204      m_sps3dExtension.setIvResPredEnabledFlag        ( d, m_ivResPredFlag         );
     205      m_sps3dExtension.setDepthRefEnabledFlag         ( d, m_depthRefinementFlag   );
     206      m_sps3dExtension.setVspMcEnabledFlag            ( d, m_viewSynthesisPredFlag );
     207      m_sps3dExtension.setDbbpEnabledFlag             ( d, m_depthBasedBlkPartFlag );
    199208    }
    200209    else
    201210    {   
    202       m_sps3dExtension.setTexMcEnabledFlag               ( d, m_mpiFlag               );
    203       m_sps3dExtension.setLog2TexmcSubPbSizeMinus3( d, m_log2MpiSubPbSizeMinus3);
    204       m_sps3dExtension.setIntraContourEnabledFlag      ( d, m_intraContourFlag      );
    205       m_sps3dExtension.setIntraDcOnlyWedgeEnabledFlag     ( d, m_intraSdcFlag || m_intraWedgeFlag     );
    206       m_sps3dExtension.setCqtCuPartPredEnabledFlag            ( d, m_qtPredFlag            );
    207       m_sps3dExtension.setInterDcOnlyEnabledFlag          ( d, m_interSdcFlag          );
    208       m_sps3dExtension.setSkipIntraEnabledFlag    ( d, m_depthIntraSkipFlag    ); 
     211      m_sps3dExtension.setTexMcEnabledFlag            ( d, m_mpiFlag               );
     212      m_sps3dExtension.setLog2TexmcSubPbSizeMinus3    ( d, m_log2MpiSubPbSizeMinus3);
     213      m_sps3dExtension.setIntraContourEnabledFlag     ( d, m_intraContourFlag      );
     214      m_sps3dExtension.setIntraDcOnlyWedgeEnabledFlag ( d, m_intraSdcFlag || m_intraWedgeFlag     );
     215      m_sps3dExtension.setCqtCuPartPredEnabledFlag    ( d, m_qtPredFlag            );
     216      m_sps3dExtension.setInterDcOnlyEnabledFlag      ( d, m_interSdcFlag          );
     217      m_sps3dExtension.setSkipIntraEnabledFlag        ( d, m_depthIntraSkipFlag    ); 
    209218    }
    210219  }
     
    216225  {
    217226    m_frameRcvd                 .push_back(0);
     227#if NH_MV
     228    m_acTEncTopList             .push_back(new TEncTop( m_spsMap, m_ppsMap ) );
     229#else
    218230    m_acTEncTopList             .push_back(new TEncTop);
     231#endif
    219232    m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
    220233    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
     
    261274  for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++)
    262275  {
     276    Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layerIdInVps];
    263277    m_cListPicYuvRec            .push_back(new TComList<TComPicYuv*>) ;
    264 
    265 #if !NH_MV
    266     m_ivPicLists.push_back( m_acTEncTopList[ layerIdInVps ]->getListPic()  );
    267 #endif
    268 
    269278    TEncTop& m_cTEncTop = *m_acTEncTopList[ layerIdInVps ];  // It is not a member, but this name helps avoiding code duplication !!!
    270279
    271280    Int layerId = vps.getLayerIdInNuh          ( layerIdInVps );
    272 #if NH_MV
    273281    m_ivPicLists.getSubDpb( layerId, true );
    274 #endif
    275282
    276283    m_cTEncTop.setLayerIdInVps                 ( layerIdInVps );
     
    278285    m_cTEncTop.setViewId                       ( vps.getViewId      (  layerId ) );
    279286    m_cTEncTop.setViewIndex                    ( vps.getViewIndex   (  layerId ) );
     287    m_cTEncTop.setSendParameterSets            ( m_sendParameterSets[ layerIdInVps ]  );
     288    m_cTEncTop.setParameterSetId               ( m_parameterSetId   [ layerIdInVps ]  );
    280289#if NH_3D_VSO || NH_3D
    281290    Bool isDepth    = ( vps.getDepthId     ( layerId ) != 0  ) ;
     
    305314#endif // H_3D_VSO
    306315#if NH_3D
    307 #if NH_3D_IC
    308316    m_cTEncTop.setUseIC                        ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_abUseIC );
    309317    m_cTEncTop.setUseICLowLatencyEnc           ( m_bUseLowLatencyICEnc );
    310 #endif
    311 
    312    
     318
    313319    m_cTEncTop.setUseDMM                       ( isDepth ? m_intraWedgeFlag   : false );
    314320    m_cTEncTop.setUseSDC                       ( isDepth ? m_intraSdcFlag     : false );
    315321    m_cTEncTop.setUseDLT                       ( isDepth ? m_useDLT   : false );
    316 #endif
    317 #if NH_3D_QTL
     322
    318323    m_cTEncTop.setUseQTL                       ( isDepth || isAuxDepth ? m_bUseQTL  : false );
    319 #endif
    320 #if NH_3D
     324
    321325    m_cTEncTop.setSps3dExtension               ( m_sps3dExtension );
    322326#endif // NH_3D
     
    326330  m_cTEncTop.setVPS(&vps);
    327331
    328 #if NH_3D_DLT
     332#if NH_3D
    329333  m_cTEncTop.setDLT(dlt);
    330334#endif
    331335
    332336#if NH_MV
    333   m_cTEncTop.setProfile                                           ( m_profiles[0]);
    334   m_cTEncTop.setLevel                                             ( m_levelTier[0], m_level[0] );
     337  // These values go to the SPS of the base layer only and should apply as follows:
     338  // –  If the profile_tier_level( ) syntax structure is included in an active SPS for the base layer
     339  //    or is the profile_tier_level( ) syntax structure VpsProfileTierLevel[ 0 ],
     340  //    it applies to the OLS containing all layers in the bitstream but with only the base layer being the output layer.
     341  // –  Otherwise, if the profile_tier_level( ) syntax structure is included in an active SPS
     342  //    for an independent non-base layer with nuh_layer_id equal to layerId, it applies to the output bitstream
     343  //    of the independent non-base layer rewriting process of clause F.10.2 with the input variables assignedBaseLayerId equal to layerId and tIdTarget equal to 6.
     344
     345  m_cTEncTop.setProfile                                           ( m_profiles[0]                       );
     346  m_cTEncTop.setLevel                                             ( m_levelTier[0], m_level[0]          );
     347  m_cTEncTop.setProgressiveSourceFlag                             ( m_progressiveSourceFlags        [0] );
     348  m_cTEncTop.setInterlacedSourceFlag                              ( m_interlacedSourceFlags         [0] );
     349  m_cTEncTop.setNonPackedConstraintFlag                           ( m_nonPackedConstraintFlags      [0] );
     350  m_cTEncTop.setFrameOnlyConstraintFlag                           ( m_frameOnlyConstraintFlags      [0] );
     351  m_cTEncTop.setBitDepthConstraintValue                           ( m_bitDepthConstraints           [0] );
     352  m_cTEncTop.setChromaFormatConstraintValue                       ( m_chromaFormatConstraints       [0] );
     353  m_cTEncTop.setIntraConstraintFlag                               ( m_intraConstraintFlags          [0] );
     354  m_cTEncTop.setOnePictureOnlyConstraintFlag                      ( m_onePictureOnlyConstraintFlags [0] );
     355  m_cTEncTop.setLowerBitRateConstraintFlag                        ( m_lowerBitRateConstraintFlags   [0] );
    335356#else
    336357  m_cTEncTop.setProfile                                           ( m_profile);
    337358  m_cTEncTop.setLevel                                             ( m_levelTier, m_level);
    338 #endif
    339359  m_cTEncTop.setProgressiveSourceFlag                             ( m_progressiveSourceFlag);
    340360  m_cTEncTop.setInterlacedSourceFlag                              ( m_interlacedSourceFlag);
     
    347367  m_cTEncTop.setLowerBitRateConstraintFlag                        ( m_lowerBitRateConstraintFlag );
    348368
     369#endif
     370
    349371  m_cTEncTop.setPrintMSEBasedSequencePSNR                         ( m_printMSEBasedSequencePSNR);
    350372  m_cTEncTop.setPrintFrameMSE                                     ( m_printFrameMSE);
    351373  m_cTEncTop.setPrintSequenceMSE                                  ( m_printSequenceMSE);
     374#if JVET_F0064_MSSSIM
     375  m_cTEncTop.setPrintMSSSIM                                       ( m_printMSSSIM );
     376#endif
    352377  m_cTEncTop.setCabacZeroWordPaddingEnabled                       ( m_cabacZeroWordPaddingEnabled );
    353378
     
    355380  m_cTEncTop.setFrameSkip                                         ( m_FrameSkip );
    356381  m_cTEncTop.setTemporalSubsampleRatio                            ( m_temporalSubsampleRatio );
     382#if NH_MV
     383  m_cTEncTop.setSourceWidth                                       ( m_iSourceWidths [repFormatIdx] );
     384  m_cTEncTop.setSourceHeight                                      ( m_iSourceHeights[repFormatIdx] );
     385
     386  m_cTEncTop.setConformanceWindow                                 ( m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx] );
     387#else
    357388  m_cTEncTop.setSourceWidth                                       ( m_iSourceWidth );
    358389  m_cTEncTop.setSourceHeight                                      ( m_iSourceHeight );
    359390  m_cTEncTop.setConformanceWindow                                 ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
     391#endif
    360392  m_cTEncTop.setFramesToBeEncoded                                 ( m_framesToBeEncoded );
    361393
     
    368400  m_cTEncTop.setDecodingRefreshType                               ( m_iDecodingRefreshType );
    369401  m_cTEncTop.setGOPSize                                           ( m_iGOPSize );
    370 #if NH_MV
    371   m_cTEncTop.setGopList                                           ( m_GOPListMvc[layerIdInVps] );
     402#if JCTVC_Y0038_PARAMS
     403  m_cTEncTop.setReWriteParamSetsFlag                              ( m_bReWriteParamSetsFlag );
     404#endif
     405#if NH_MV
     406  m_cTEncTop.setGopList                                           ( xGetGopEntries(layerIdInVps) );
    372407  m_cTEncTop.setExtraRPSs                                         ( m_extraRPSsMvc[layerIdInVps] );
    373408  for(Int i = 0; i < MAX_TLAYER; i++)
     
    398433#endif
    399434
     435#if X0038_LAMBDA_FROM_QP_CAPABILITY
     436  m_cTEncTop.setIntraQPOffset                                     ( m_intraQPOffset );
     437  m_cTEncTop.setLambdaFromQPEnable                                ( m_lambdaFromQPEnable );
     438#endif
     439#if NH_MV
     440  m_cTEncTop.setPad                                               ( &m_aiPads[ repFormatIdx ][0] );
     441#else
    400442  m_cTEncTop.setPad                                               ( m_aiPad );
     443#endif
     444
    401445  m_cTEncTop.setAccessUnitDelimiter                               ( m_AccessUnitDelimiter );
    402446#if NH_MV
     
    418462  m_cTEncTop.setLoopFilterBetaOffset                              ( m_loopFilterBetaOffsetDiv2  );
    419463  m_cTEncTop.setLoopFilterTcOffset                                ( m_loopFilterTcOffsetDiv2    );
    420 #if W0038_DB_OPT
    421464  m_cTEncTop.setDeblockingFilterMetric                            ( m_deblockingFilterMetric );
    422 #else
    423   m_cTEncTop.setDeblockingFilterMetric                            ( m_DeblockingFilterMetric );
    424 #endif
    425465
    426466  //====== Motion search ========
     
    444484  m_cTEncTop.setChromaCbQpOffset                                  ( m_cbQpOffset     );
    445485  m_cTEncTop.setChromaCrQpOffset                                  ( m_crQpOffset  );
    446 #if W0038_CQP_ADJ
     486  m_cTEncTop.setWCGChromaQpControl                                ( m_wcgChromaQpControl );
    447487  m_cTEncTop.setSliceChromaOffsetQpIntraOrPeriodic                ( m_sliceChromaQpOffsetPeriodicity, m_sliceChromaQpOffsetIntraOrPeriodic );
    448 #endif
    449 
    450 #if NH_3D
    451   m_cTEncTop.setChromaFormatIdc                                   ( isDepth ? CHROMA_400 : m_chromaFormatIDC );
     488
     489#if NH_MV
     490  m_cTEncTop.setChromaFormatIdc                                   ( m_chromaFormatIDCs[ repFormatIdx ] );
    452491#else
    453492  m_cTEncTop.setChromaFormatIdc                                   ( m_chromaFormatIDC  );
     
    466505
    467506  //====== Tool list ========
     507  m_cTEncTop.setLumaLevelToDeltaQPControls                        ( m_lumaLevelToDeltaQPMapping );
     508#if X0038_LAMBDA_FROM_QP_CAPABILITY
     509  m_cTEncTop.setDeltaQpRD( (m_costMode==COST_LOSSLESS_CODING) ? 0 : m_uiDeltaQpRD );
     510#else
    468511  m_cTEncTop.setDeltaQpRD                                         ( m_uiDeltaQpRD  );
     512#endif
    469513  m_cTEncTop.setFastDeltaQp                                       ( m_bFastDeltaQP  );
    470514  m_cTEncTop.setUseASR                                            ( m_bUseASR      );
     
    477521  m_cTEncTop.setUseRDOQ                                           ( m_useRDOQ     );
    478522  m_cTEncTop.setUseRDOQTS                                         ( m_useRDOQTS   );
    479 #if T0196_SELECTIVE_RDOQ
    480523  m_cTEncTop.setUseSelectiveRDOQ                                  ( m_useSelectiveRDOQ );
    481 #endif
    482524  m_cTEncTop.setRDpenalty                                         ( m_rdPenalty );
    483525  m_cTEncTop.setMaxCUWidth                                        ( m_uiMaxCUWidth );
    484526  m_cTEncTop.setMaxCUHeight                                       ( m_uiMaxCUHeight );
     527#if NH_MV
     528  m_cTEncTop.setMaxTotalCUDepth                                   ( m_uiMaxTotalCUDepth[ repFormatIdx] );
     529#else
    485530  m_cTEncTop.setMaxTotalCUDepth                                   ( m_uiMaxTotalCUDepth );
     531#endif
    486532  m_cTEncTop.setLog2DiffMaxMinCodingBlockSize                     ( m_uiLog2DiffMaxMinCodingBlockSize );
    487533  m_cTEncTop.setQuadtreeTULog2MaxSize                             ( m_uiQuadtreeTULog2MaxSize );
     
    524570  for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
    525571  {
     572#if NH_MV
     573    m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepths[repFormatIdx][channelType]);
     574    m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepths[repFormatIdx][channelType] : m_internalBitDepths[repFormatIdx][channelType]);
     575#else
    526576    m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepth[channelType]);
    527577    m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType]);
     578#endif
    528579  }
    529580
     
    562613
    563614  m_cTEncTop.setSaoCtuBoundary                                    ( m_saoCtuBoundary);
    564 #if OPTIONAL_RESET_SAO_ENCODING_AFTER_IRAP
    565615  m_cTEncTop.setSaoResetEncoderStateAfterIRAP                     ( m_saoResetEncoderStateAfterIRAP);
    566 #endif
    567616  m_cTEncTop.setPCMInputBitDepthFlag                              ( m_bPCMInputBitDepthFlag);
    568617  m_cTEncTop.setPCMFilterDisableFlag                              ( m_bPCMFilterDisableFlag);
     
    620669  m_cTEncTop.setScalableNestingSEIEnabled                         ( m_scalableNestingSEIEnabled );
    621670  m_cTEncTop.setTMCTSSEIEnabled                                   ( m_tmctsSEIEnabled );
     671#if MCTS_ENC_CHECK
     672  m_cTEncTop.setTMCTSSEITileConstraint                            ( m_tmctsSEITileConstraint );
     673#endif
    622674  m_cTEncTop.setTimeCodeSEIEnabled                                ( m_timeCodeSEIEnabled );
    623675  m_cTEncTop.setNumberOfTimeSets                                  ( m_timeCodeSEINumTs );
     
    639691  m_cTEncTop.setColourRemapInfoSEIFileRoot                        ( m_colourRemapSEIFileRoot );
    640692  m_cTEncTop.setMasteringDisplaySEI                               ( m_masteringDisplay );
    641 #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
    642693  m_cTEncTop.setSEIAlternativeTransferCharacteristicsSEIEnable    ( m_preferredTransferCharacteristics>=0     );
    643694  m_cTEncTop.setSEIPreferredTransferCharacteristics               ( UChar(m_preferredTransferCharacteristics) );
    644 #endif
    645 
     695  m_cTEncTop.setSEIGreenMetadataInfoSEIEnable                     ( m_greenMetadataType > 0 );
     696  m_cTEncTop.setSEIGreenMetadataType                              ( UChar(m_greenMetadataType) );
     697  m_cTEncTop.setSEIXSDMetricType                                  ( UChar(m_xsdMetricType) );
    646698#if NH_MV
    647699  m_cTEncTop.setSeiMessages                                       ( &m_seiMessages );
     
    667719  m_cTEncTop.setUseScalingListId                                  ( m_useScalingListId  );
    668720  m_cTEncTop.setScalingListFileName                               ( m_scalingListFileName );
    669   m_cTEncTop.setSignHideFlag                                      ( m_signHideFlag);
     721  m_cTEncTop.setSignDataHidingEnabledFlag                         ( m_signDataHidingEnabledFlag);
     722
    670723#if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
    671724  if(!m_cTEncTop.getIsDepth())    //only for texture
     
    688741  m_cTEncTop.setInitialQP                                         ( m_RCInitialQP );
    689742  m_cTEncTop.setForceIntraQP                                      ( m_RCForceIntraQP );
    690 #if U0132_TARGET_BITS_SATURATION
    691743  m_cTEncTop.setCpbSaturationEnabled                              ( m_RCCpbSaturationEnabled );
    692744  m_cTEncTop.setCpbSize                                           ( m_RCCpbSize );
    693745  m_cTEncTop.setInitialCpbFullness                                ( m_RCInitialCpbFullness );
    694 #endif
    695746
    696747#if KWU_RC_MADPRED_E0227
     
    761812  }
    762813#endif
    763   m_cTEncTop.setTransquantBypassEnableFlag                        ( m_TransquantBypassEnableFlag );
     814  m_cTEncTop.setTransquantBypassEnabledFlag                       ( m_TransquantBypassEnabledFlag );
    764815  m_cTEncTop.setCUTransquantBypassFlagForceValue                  ( m_CUTransquantBypassFlagForce );
    765816  m_cTEncTop.setCostMode                                          ( m_costMode );
     
    812863    if ( m_uiVSOMode == 4 )
    813864    {
     865
     866      for( Int i = 1; i < m_numRepFormats; i++)
     867      {
     868        if ( m_iSourceWidths[0] != m_iSourceWidths[i] || m_iSourceHeights[0] != m_iSourceHeights[i] )
     869        {
     870          std::cout << "Enabling the RM requires equal size of all layers." << std::endl;
     871          AOF( false );
     872        }
     873      }
     874
    814875#if H_3D_VSO_EARLY_SKIP
    815       m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, true, m_bVSOEarlySkip );
    816 #else
    817       m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 , true);
     876      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidths[0], m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, true, m_bVSOEarlySkip );
     877#else
     878      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidths[0], m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 , true);
    818879#endif
    819880      for ( Int layer = 0; layer < m_numberOfLayers ; layer++ )
     
    851912  // initialize global variables
    852913  initROM();
    853 #if NH_3D_DMM
     914#if NH_3D
    854915  initWedgeLists( true );
    855916#endif
     
    857918  for( Int layer=0; layer < m_numberOfLayers; layer++)
    858919  {
    859     m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer],     false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );  // read  mode
    860     m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC);
     920    Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
     921    m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer],     false, &m_inputBitDepths[repFormatIdx][0], &m_MSBExtendedBitDepths[repFormatIdx][0], &m_internalBitDepths[repFormatIdx][0] );  // read  mode
     922    m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidths[repFormatIdx] - m_aiPads[repFormatIdx][0], m_iSourceHeights[repFormatIdx] - m_aiPads[repFormatIdx][1], m_InputChromaFormatIDC[repFormatIdx]);
    861923
    862924    if (m_pchReconFileList[layer])
    863925    {
    864       m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth);  // write mode
     926      m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, &m_outputBitDepths[repFormatIdx][0], &m_outputBitDepths[repFormatIdx][0], &m_internalBitDepths[repFormatIdx][0]);  // write mode
    865927    }
    866928    m_acTEncTopList[layer]->create();
     
    869931  // Video I/O
    870932  m_cTVideoIOYuvInputFile.open( m_inputFileName,     false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );  // read  mode
    871   m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC);
     933  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC);
    872934
    873935  if (!m_reconFileName.empty())
     
    9491011  }
    9501012
    951 #if !NH_3D
     1013#if !NH_MV
    9521014  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
    9531015#endif
     
    9581020  xCreateLib();
    9591021  xInitLib(m_isField);
    960 
     1022#if NH_MV
    9611023  printChromaFormat();
     1024#endif
    9621025
    9631026  // main encoder loop
     
    9851048  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
    9861049 
    987 #if NH_3D
    988   TComPicYuv* picYuvOrg[2];
    989   TComPicYuv  picYuvTrueOrg[2];
    990   for (Int d = 0; d < 2 ; d++)
    991   {
     1050#if NH_MV
     1051  std::vector<TComPicYuv*> picYuvOrg    ( m_numRepFormats );
     1052  std::vector<TComPicYuv > picYuvTrueOrg( m_numRepFormats );
     1053  for (Int d = 0; d < m_numRepFormats ; d++)
     1054  { 
    9921055    picYuvOrg[d] = new TComPicYuv;
    993     picYuvOrg[d]   ->create( m_iSourceWidth, m_isField ? m_iSourceHeightOrg : m_iSourceHeight, ( d > 0 ) ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
    994     picYuvTrueOrg[d].create( m_iSourceWidth, m_isField ? m_iSourceHeightOrg : m_iSourceHeight, ( d > 0 ) ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
     1056    picYuvOrg[d]   ->create( m_iSourceWidths[d], m_isField ? m_iSourceHeightOrgs[d] : m_iSourceHeights[d], m_chromaFormatIDCs[d], m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[d], true );
     1057    picYuvTrueOrg[d].create( m_iSourceWidths[d], m_isField ? m_iSourceHeightOrgs[d] : m_iSourceHeights[d], m_chromaFormatIDCs[d], m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[d], true );
    9951058  }
    9961059#else
     
    10091072  }
    10101073#endif
     1074
     1075
     1076#if EXTENSION_360_VIDEO
     1077  TExt360AppEncTop           ext360(*this, m_cTEncTop.getGOPEncoder()->getExt360Data(), *(m_cTEncTop.getGOPEncoder()), *pcPicYuvOrg);
     1078#endif
     1079
    10111080#if NH_MV
    10121081  while ( (m_targetEncLayerIdList.size() != 0 ) && !allEos )
     
    10141083    for(Int layer=0; layer < m_numberOfLayers; layer++ )
    10151084    {
    1016 #if NH_3D
    1017       TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ m_depthFlag[layer] ];
    1018       TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ m_depthFlag[layer] ];
    1019 #endif
     1085      Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
     1086
     1087      TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ repFormatIdx ];
     1088      TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ repFormatIdx ];
     1089
    10201090      if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) ))
    10211091      {
     
    10301100
    10311101        // read input YUV file       
    1032         m_acTVideoIOYuvInputFileList[layer]->read      ( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC );
     1102        m_acTVideoIOYuvInputFileList[layer]->read      ( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, &m_aiPads[repFormatIdx][0], m_InputChromaFormatIDC[repFormatIdx] );
    10331103        m_acTEncTopList             [layer]->initNewPic( pcPicYuvOrg );
    10341104
     
    10621132      for(Int layer=0; layer < m_numberOfLayers; layer++ )
    10631133      {
    1064 #if NH_3D
    1065         TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ m_depthFlag[layer] ];
    1066         TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ m_depthFlag[layer] ];
     1134        Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
     1135#if NH_MV
     1136        TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ repFormatIdx ];
     1137        TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ repFormatIdx ];
    10671138#endif
    10681139        if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) ))
     
    11041175    // get buffers
    11051176    xGetBuffer(pcPicYuvRec);
    1106 
    11071177    // read input YUV file
     1178#if EXTENSION_360_VIDEO
     1179    if (ext360.isEnabled())
     1180    {
     1181      ext360.read(m_cTVideoIOYuvInputFile, *pcPicYuvOrg, cPicYuvTrueOrg, ipCSC);
     1182    }
     1183    else
     1184    {
     1185      m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
     1186    }
     1187#else
    11081188    m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
     1189#endif
    11091190
    11101191    // increase number of received frames
     
    11421223    if( m_temporalSubsampleRatio > 1 )
    11431224    {
    1144       m_cTVideoIOYuvInputFile.skipFrames(m_temporalSubsampleRatio-1, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC);
     1225      m_cTVideoIOYuvInputFile.skipFrames(m_temporalSubsampleRatio-1, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC);
    11451226    }
    11461227  }
     
    11491230#endif
    11501231
    1151 #if NH_3D
     1232#if NH_MV
    11521233  // delete original YUV buffer
    1153   for (Int d = 0; d < 2; d++)
     1234  for (Int d = 0; d < m_numRepFormats; d++)
    11541235  {
    11551236    picYuvOrg[d]->destroy();
     
    11691250  // delete used buffers in encoder class
    11701251  m_cTEncTop.deletePicBuffer();
    1171 #endif
    1172 #if !NH_3D
    11731252  cPicYuvTrueOrg.destroy();
    11741253#endif
     
    12121291  // org. buffer
    12131292#if NH_MV
     1293  Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
     1294
    12141295  if ( m_cListPicYuvRec[layer]->size() == (UInt)m_iGOPSize )
    12151296  {
     
    12241305  {
    12251306    rpcPicYuvRec = new TComPicYuv;
    1226 #if NH_3D
    1227     rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_depthFlag[layer] > 0 ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
     1307#if NH_MV
     1308    rpcPicYuvRec->create( m_iSourceWidths[ repFormatIdx ], m_iSourceHeights[ repFormatIdx ], m_chromaFormatIDCs[ repFormatIdx ], m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[repFormatIdx], true );
    12281309#else
    12291310    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
     
    13061387      if (m_pchReconFileList[layerIdx])
    13071388      {
     1389        Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layerIdx];
    13081390#if NH_3D
    1309         m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT, m_isTopFieldFirst );
    1310 #else
    1311         m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, NUM_CHROMA_FORMAT, m_isTopFieldFirst );
     1391        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx], m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT, m_isTopFieldFirst );
     1392#else
     1393        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx], NUM_CHROMA_FORMAT, m_isTopFieldFirst );
    13121394#endif
    13131395      }
     
    13611443      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
    13621444#if NH_MV
     1445      Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layerIdx];
    13631446      if (m_pchReconFileList[layerIdx])
    13641447      {
    13651448#if NH_3D
    1366         m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT  );
    1367 #else
    1368         m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
     1449        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx], m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT  );
     1450#else
     1451        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx] );
    13691452#endif
    13701453
     
    14541537Void TAppEncTop::printChromaFormat()
    14551538{
     1539 
     1540#if NH_MV   
     1541  std::cout << "Input ChromaFormatIDC             : ";
     1542  for (Int i = 0; i < m_numRepFormats; i++)
     1543  {
     1544   
     1545   
     1546    switch (m_InputChromaFormatIDC[i])
     1547#else
    14561548  std::cout << std::setw(43) << "Input ChromaFormatIDC = ";
    14571549  switch (m_InputChromaFormatIDC)
     1550#endif
    14581551  {
    14591552  case CHROMA_400:  std::cout << "  4:0:0"; break;
     
    14651558    exit(1);
    14661559  }
     1560#if NH_MV
     1561  std::cout << " ";
     1562}
     1563#endif
     1564
    14671565  std::cout << std::endl;
    14681566
    14691567#if NH_MV
    1470   for (Int i = 0; i < m_numberOfLayers; i++)
    1471   {
    1472     std::cout << "Layer " << i << std::setw( 43 - (i > 9 ? 6 : 7) ) << "Internal ChromaFormatIDC = ";
    1473     switch (m_acTEncTopList[i]->getChromaFormatIdc())
     1568  std::cout << "Output (internal) ChromaFormatIDC : ";
     1569  for (Int i = 0; i < m_numRepFormats; i++)
     1570  {
     1571   
     1572    switch ( m_chromaFormatIDCs[i] )
    14741573#else
    14751574    std::cout << std::setw(43) << "Output (internal) ChromaFormatIDC = ";
     
    14861585    }
    14871586#if NH_MV
    1488     std::cout << std::endl;
     1587    std::cout << " ";
    14891588  }
    14901589#endif
     
    14921591}
    14931592
    1494 #if NH_3D_DLT
     1593#if NH_3D
    14951594Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt)
    14961595{
     1596  Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
     1597
    14971598  TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
    14981599  TComPicYuv*       pcDepthPicYuvTrueOrg = new TComPicYuv;
    14991600  // allocate original YUV buffer
    1500   pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, false );
    1501   pcDepthPicYuvTrueOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, false );
     1601  pcDepthPicYuvOrg->create( m_iSourceWidths[ repFormatIdx ], m_iSourceHeights[ repFormatIdx ], CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight    , m_uiMaxTotalCUDepth[repFormatIdx], false );
     1602  pcDepthPicYuvTrueOrg->create( m_iSourceWidths[ repFormatIdx ], m_iSourceHeights[ repFormatIdx ], CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[repFormatIdx], false );
    15021603 
    15031604  TVideoIOYuv* depthVideoFile = new TVideoIOYuv;
    15041605 
    1505   UInt uiMaxDepthValue = ((1 << m_inputBitDepth[CHANNEL_TYPE_LUMA])-1);
     1606  UInt uiMaxDepthValue = ((1 << m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA])-1);
    15061607 
    15071608  std::vector<Bool> abValidDepths(256, false);
    15081609 
    1509   depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );
     1610  depthVideoFile->open( m_pchInputFileList[layer], false, &m_inputBitDepths[repFormatIdx][0], &m_MSBExtendedBitDepths[repFormatIdx][0], &m_internalBitDepths[repFormatIdx][0] );
    15101611 
    15111612  Int iHeight   = pcDepthPicYuvOrg->getHeight(COMPONENT_Y);
     
    15151616  Pel* pInDM    = pcDepthPicYuvOrg->getAddr(COMPONENT_Y);
    15161617 
     1618 
    15171619  for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ )
    15181620  {
    1519     depthVideoFile->read( pcDepthPicYuvOrg, pcDepthPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
     1621    depthVideoFile->read( pcDepthPicYuvOrg, pcDepthPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, &m_aiPads[repFormatIdx][0], m_InputChromaFormatIDC[repFormatIdx], m_bClipInputVideoToRec709Range );
    15201622   
    15211623    // check all pixel values
     
    15511653  }
    15521654 
    1553   if( uiNumFrames == 0 || gCeilLog2(iNumDepthValues) == m_inputBitDepth[CHANNEL_TYPE_LUMA] )
     1655  if( uiNumFrames == 0 || gCeilLog2(iNumDepthValues) == m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA] )
    15541656  {
    15551657    dlt->setUseDLTFlag(layer, false);
     
    16531755    for( Int i = 0; i < getGOPSize(); i++ )
    16541756    {
    1655       GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][i];
     1757      GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[i];
    16561758      curSubLayersMaxMinus1 = std::max( curSubLayersMaxMinus1, geCur.m_temporalId );
    16571759    } 
     
    16791781          for( Int i = 0; i < ( getGOPSize() + 1); i++ )
    16801782          {       
    1681             GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
    1682             GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
     1783            GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
     1784            GOPEntry geRef =  xGetGopEntries(refLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
    16831785            for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++)
    16841786            {
     
    17051807              for( Int i = 0; i < ( getGOPSize() + 1); i++ )
    17061808              {       
    1707                 GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
    1708                 GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
     1809                GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
     1810                GOPEntry geRef =  xGetGopEntries(refLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
    17091811                if ( geCur.m_interCompPredFlag )
    17101812                {
     
    17191821            for( Int i = 0; i < ( getGOPSize() + 1); i++ )
    17201822            {       
    1721               GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
    1722               GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][( i < getGOPSize()  ? i : MAX_GOP )];
     1823              GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
     1824              GOPEntry geRef =  xGetGopEntries(refLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
    17231825
    17241826              if ( geCur.m_interCompPredFlag )
     
    17611863    for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ )
    17621864    {       
    1763       GOPEntry ge =  m_GOPListMvc[layerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ];
     1865      GOPEntry ge =  xGetGopEntries(layerIdInVps)[ ( i < getGOPSize()  ? i : MAX_GOP ) ];
    17641866      maxOneActiveRefLayerFlag =  maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1);
    17651867    }           
     
    17841886    for( Int i = 0; i < ( getGOPSize() + 1) && allRefLayersActiveFlag; i++ )
    17851887    {       
    1786       GOPEntry ge =  m_GOPListMvc[layerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ];
     1888      GOPEntry ge =  xGetGopEntries(layerIdInVps)[ ( i < getGOPSize()  ? i : MAX_GOP ) ];
    17871889      Int tId = ge.m_temporalId;  // Should be equal for all layers.
    17881890     
     
    18381940
    18391941
    1840 GOPEntry* TAppEncTop::xGetGopEntry( Int layerIdInVps, Int poc )
    1841 {
    1842   GOPEntry* geFound = NULL;
    1843   for( Int i = 0; i < ( getGOPSize() + 1) && geFound == NULL ; i++ )
    1844   {
    1845     GOPEntry* ge = &(m_GOPListMvc[layerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ]);
    1846     if ( ge->m_POC == poc )
    1847     {
    1848       geFound = ge;       
    1849     }
    1850   }
    1851   assert( geFound != NULL );
    1852   return geFound;
    1853 }
    1854 
    1855 
    18561942Void TAppEncTop::xSetTimingInfo( TComVPS& vps )
    18571943{
     
    19051991{
    19061992
     1993  xDeriveProfAndConstrFlags( vps ); 
     1994  xCheckProfiles           ( vps );
     1995  xPrintProfiles           (  );
     1996 
    19071997  // SET PTL
    19081998  assert( m_profiles.size() == m_level.size() && m_profiles.size() == m_levelTier.size() );
     
    19122002    if ( ptlIdx > 1 )
    19132003    {
    1914       Bool vpsProfilePresentFlag = ( m_profiles[ptlIdx] != m_profiles[ptlIdx - 1] )
    1915         || ( m_inblFlag[ptlIdx ] != m_inblFlag[ptlIdx - 1] );
     2004      Bool vpsProfilePresentFlag =
     2005           ( m_profiles                [ptlIdx ] != m_profiles                [ptlIdx - 1] )
     2006        || ( m_progressiveSourceFlags  [ptlIdx ] != m_progressiveSourceFlags  [ptlIdx - 1] )
     2007        || ( m_interlacedSourceFlags   [ptlIdx ] != m_interlacedSourceFlags   [ptlIdx - 1] )
     2008        || ( m_nonPackedConstraintFlags[ptlIdx ] != m_nonPackedConstraintFlags[ptlIdx - 1] )
     2009        || ( m_frameOnlyConstraintFlags[ptlIdx ] != m_frameOnlyConstraintFlags[ptlIdx - 1] )
     2010        || ( m_inblFlag                [ptlIdx ] != m_inblFlag                [ptlIdx - 1] );
     2011
     2012     
     2013      if ( m_profiles[ ptlIdx ] >= 4 && m_profiles[ ptlIdx ] <= 7 )
     2014      {
     2015
     2016        vpsProfilePresentFlag = vpsProfilePresentFlag
     2017          || ( m_profiles                [ptlIdx ] != m_profiles                [ptlIdx - 1] )
     2018          || ( m_progressiveSourceFlags  [ptlIdx ] != m_progressiveSourceFlags  [ptlIdx - 1] )
     2019          || ( m_interlacedSourceFlags   [ptlIdx ] != m_interlacedSourceFlags   [ptlIdx - 1] )
     2020          || ( m_nonPackedConstraintFlags[ptlIdx ] != m_nonPackedConstraintFlags[ptlIdx - 1] )
     2021          || ( m_frameOnlyConstraintFlags[ptlIdx ] != m_frameOnlyConstraintFlags[ptlIdx - 1] )
     2022          || ( m_inblFlag                [ptlIdx ] != m_inblFlag                [ptlIdx - 1] );
     2023
     2024      }
     2025
     2026     
    19162027      vps.setVpsProfilePresentFlag( ptlIdx, vpsProfilePresentFlag );
    19172028    }
    19182029
    19192030    xSetProfileTierLevel( vps, ptlIdx, -1, m_profiles[ptlIdx], m_level[ptlIdx],
    1920       m_levelTier[ ptlIdx ], m_progressiveSourceFlag, m_interlacedSourceFlag,
    1921       m_nonPackedConstraintFlag, m_frameOnlyConstraintFlag,  m_inblFlag[ptlIdx] );     
    1922   } 
    1923 }
    1924 
    1925 Void TAppEncTop::xSetProfileTierLevel(TComVPS& vps, Int profileTierLevelIdx, Int subLayer, Profile::Name profile, Level::Name level, Level::Tier tier, Bool progressiveSourceFlag, Bool interlacedSourceFlag, Bool nonPackedConstraintFlag, Bool frameOnlyConstraintFlag, Bool inbldFlag)
     2031      m_levelTier[ ptlIdx ], m_progressiveSourceFlags[ptlIdx], m_interlacedSourceFlags[ptlIdx],
     2032      m_nonPackedConstraintFlags[ptlIdx], m_frameOnlyConstraintFlags[ptlIdx],  m_inblFlag[ptlIdx] );     
     2033  }
     2034}
     2035
     2036Void TAppEncTop::xSetProfileTierLevel(TComVPS& vps, Int ptlIdx, Int subLayer, Profile::Name profile, Level::Name level, Level::Tier tier, Bool progressiveSourceFlag, Bool interlacedSourceFlag, Bool nonPackedConstraintFlag, Bool frameOnlyConstraintFlag, Bool inbldFlag)
    19262037{
    1927   TComPTL* ptlStruct = vps.getPTL( profileTierLevelIdx );   
     2038 
     2039  TComPTL* ptlStruct = vps.getPTL( ptlIdx );   
    19282040  assert( ptlStruct != NULL );
    19292041
     
    19402052  assert( ptl != NULL );
    19412053
    1942   ptl->setProfileIdc( profile );
    1943   ptl->setTierFlag  ( tier    );
    1944   ptl->setLevelIdc  ( level   );
    1945   ptl->setProfileCompatibilityFlag( profile, true );
    1946   ptl->setInbldFlag( inbldFlag );
    1947 
    1948   switch ( profile )
    1949   {
    1950   case Profile::MAIN:
    1951     break;
    1952   case Profile::MULTIVIEWMAIN:
    1953 #if NH_3D
    1954   case Profile::MAIN3D:
    1955 #endif
    1956     ptl->setMax12bitConstraintFlag      ( true  );
    1957     ptl->setMax12bitConstraintFlag      ( true  );
    1958     ptl->setMax10bitConstraintFlag      ( true  );
    1959     ptl->setMax8bitConstraintFlag       ( true  );
    1960     ptl->setMax422chromaConstraintFlag  ( true  );
    1961     ptl->setMax420chromaConstraintFlag  ( true  );
    1962     ptl->setMaxMonochromeConstraintFlag ( false );
    1963     ptl->setIntraConstraintFlag         ( false );
    1964     ptl->setOnePictureOnlyConstraintFlag( false );
    1965     ptl->setLowerBitRateConstraintFlag  ( true  );       
    1966     break;
    1967   default:
    1968     assert( 0 ); // other profiles currently not supported
    1969     break;
    1970   }
     2054  ptl->setProfileIdc              ( m_profiles [ ptlIdx ] );
     2055  ptl->setTierFlag                ( m_levelTier[ ptlIdx ] );
     2056  ptl->setLevelIdc                ( m_level    [ ptlIdx ] );
     2057  ptl->setProfileCompatibilityFlag( m_profiles [ ptlIdx ], true );
     2058  ptl->setInbldFlag               ( m_inblFlag [ ptlIdx ] );
     2059
     2060  Int        bitDepth = m_bitDepthConstraints[ptlIdx];
     2061  ChromaFormat chroma = m_chromaFormatConstraints[ptlIdx];
     2062
     2063  ptl->setMax12bitConstraintFlag      (  bitDepth <= 12  );   
     2064  ptl->setMax10bitConstraintFlag      (  bitDepth <= 10 );
     2065  ptl->setMax8bitConstraintFlag       (  bitDepth <= 8 );
     2066  ptl->setMax422chromaConstraintFlag  ( chroma == CHROMA_400 || chroma == CHROMA_420 || chroma == CHROMA_422    );
     2067  ptl->setMax420chromaConstraintFlag  ( chroma == CHROMA_400 || chroma == CHROMA_420                            );                         ;
     2068  ptl->setMaxMonochromeConstraintFlag ( chroma == CHROMA_400                       );
     2069  ptl->setIntraConstraintFlag         ( m_intraConstraintFlags[ ptlIdx ]           );
     2070  ptl->setOnePictureOnlyConstraintFlag( m_onePictureOnlyConstraintFlags[ ptlIdx ]  );
     2071  ptl->setLowerBitRateConstraintFlag  ( m_lowerBitRateConstraintFlags[ ptlIdx ]    );   
    19712072}
    19722073
    19732074Void TAppEncTop::xSetRepFormat( TComVPS& vps )
    19742075{
    1975 
    1976   Bool anyDepth = false;
    1977 #if NH_3D
    1978   for ( Int i = 0; i < m_numberOfLayers; i++ )
    1979   {
    1980     vps.setVpsRepFormatIdx( i, m_depthFlag[ i ] ? 1 : 0 );
    1981     anyDepth = anyDepth || m_depthFlag[ i ];
    1982   }
    1983 #endif
    1984 
    1985   vps.setRepFormatIdxPresentFlag( anyDepth );
    1986   vps.setVpsNumRepFormatsMinus1 ( anyDepth ? 1 : 0     );
     2076  vps.setVpsNumRepFormatsMinus1 ( m_numRepFormats - 1 );
    19872077
    19882078
     
    19912081  for ( Int j = 0; j <= vps.getVpsNumRepFormatsMinus1(); j++ )
    19922082  {           
    1993     repFormat[j].setBitDepthVpsChromaMinus8   ( m_internalBitDepth[CHANNEL_TYPE_LUMA  ] - 8 );
    1994     repFormat[j].setBitDepthVpsLumaMinus8     ( m_internalBitDepth[CHANNEL_TYPE_CHROMA] - 8 );
    1995     repFormat[j].setChromaFormatVpsIdc        ( j == 1 ? CHROMA_400 :  CHROMA_420 );
    1996     repFormat[j].setPicHeightVpsInLumaSamples ( m_iSourceHeight );
    1997     repFormat[j].setPicWidthVpsInLumaSamples  ( m_iSourceWidth  );   
     2083    repFormat[j].setBitDepthVpsChromaMinus8   ( m_internalBitDepths[j][CHANNEL_TYPE_LUMA  ] - 8 );
     2084    repFormat[j].setBitDepthVpsLumaMinus8     ( m_internalBitDepths[j][CHANNEL_TYPE_CHROMA] - 8 );
     2085    repFormat[j].setChromaFormatVpsIdc        ( m_chromaFormatIDCs[j] );
     2086    repFormat[j].setPicHeightVpsInLumaSamples ( m_iSourceHeights[j] );
     2087    repFormat[j].setPicWidthVpsInLumaSamples  ( m_iSourceWidths [j] );   
    19982088    repFormat[j].setChromaAndBitDepthVpsPresentFlag( true );   
    19992089    // ToDo not supported yet.
     
    20012091
    20022092    repFormat[j].setConformanceWindowVpsFlag( true );
    2003     repFormat[j].setConfWinVpsLeftOffset    ( m_confWinLeft  / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() ) );
    2004     repFormat[j].setConfWinVpsRightOffset   ( m_confWinRight  / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() ) );
    2005     repFormat[j].setConfWinVpsTopOffset     ( m_confWinTop    / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() ) );
    2006     repFormat[j].setConfWinVpsBottomOffset  ( m_confWinBottom / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() ) );
     2093    repFormat[j].setConfWinVpsLeftOffset    ( m_confWinLefts  [j] / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() ) );
     2094    repFormat[j].setConfWinVpsRightOffset   ( m_confWinRights [j] / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() ) );
     2095    repFormat[j].setConfWinVpsTopOffset     ( m_confWinTops   [j] / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() ) );
     2096    repFormat[j].setConfWinVpsBottomOffset  ( m_confWinBottoms[j] / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() ) );
    20072097  }
    20082098
    20092099  vps.setRepFormat( repFormat );
     2100
     2101
     2102  if ( vps.getVpsNumRepFormatsMinus1() > 0 )
     2103  {
     2104    Bool repFormatIdxPresentFlag = false;
     2105    for( Int i = vps.getVpsBaseLayerInternalFlag() ? 1 : 0; i <= vps.getMaxLayersMinus1(); i++ )
     2106    {
     2107      repFormatIdxPresentFlag = repFormatIdxPresentFlag ||  ( m_layerIdxInVpsToRepFormatIdx[i]  != vps.inferVpsRepFormatIdx( i ) );
     2108    }
     2109    vps.setRepFormatIdxPresentFlag( repFormatIdxPresentFlag );
     2110  }
     2111
     2112  for( Int i =  0; i <=  vps.getMaxLayersMinus1(); i++ )
     2113  {
     2114    // When base_layer_internal_flag is equal to 1, the first repFormatIdx cannot be signaled but is inferred.
     2115    if( !vps.getRepFormatIdxPresentFlag() || ( vps.getVpsBaseLayerInternalFlag() && i == 0 )   )
     2116    {
     2117      vps.setVpsRepFormatIdx( i, vps.inferVpsRepFormatIdx( i ) );
     2118      AOF( vps.getVpsRepFormatIdx( i ) == m_layerIdxInVpsToRepFormatIdx[i] );
     2119    }
     2120    else
     2121    {
     2122      vps.setVpsRepFormatIdx( i, m_layerIdxInVpsToRepFormatIdx[i] );         
     2123    }
     2124  }
     2125
     2126
     2127  xConfirmRepFormat( vps );
    20102128
    20112129}
     
    24312549
    24322550
    2433 #if NH_3D_DLT
     2551#if NH_3D
    24342552Void TAppEncTop::xDeriveDltArray( TComVPS& vps, TComDLT* dlt )
    24352553{
     2554  std::cout << "Analyzing input depth for DLT ";
    24362555  Int  iNumDepthViews  = 0;
    24372556  Bool bDltPresentFlag = false;
     
    24492568    if( dlt->getUseDLTFlag( layer ) )
    24502569    {
     2570      std::cout << ".";
    24512571      xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod[layer], 24), &vps, dlt);
    24522572      bDltPresentFlag = bDltPresentFlag || dlt->getUseDLTFlag(layer);
     
    25232643     
    25242644      // bit map branch
    2525       uiNumBitsBitMap = 1 << m_inputBitDepth[CHANNEL_TYPE_LUMA];
     2645      Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[ layer ];
     2646      uiNumBitsBitMap = 1 << m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA];
    25262647     
    25272648      // determine bDltBitMapFlag
     
    25292650     
    25302651      dlt->setUseBitmapRep(layer, bDltBitMapRepFlag);
    2531     }
     2652
     2653      AOF( m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA] == m_inputBitDepths[0][CHANNEL_TYPE_LUMA] )
     2654    }
     2655   
    25322656  }
    25332657
    25342658  dlt->setDltPresentFlag( bDltPresentFlag );
    25352659  dlt->setNumDepthViews ( iNumDepthViews  );
    2536   dlt->setDepthViewBitDepth( m_inputBitDepth[CHANNEL_TYPE_LUMA] );
     2660  dlt->setDepthViewBitDepth( m_inputBitDepths[CHANNEL_TYPE_LUMA][0] );
     2661  std::cout << " done." << std::endl;
    25372662}
    25382663#endif
  • trunk/source/App/TAppEncoder/TAppEncTop.h

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    7373
    7474  std::vector<Int>           m_frameRcvd;                   ///< number of received frames
    75 
    7675  TComPicLists               m_ivPicLists;                  ///< picture buffers of encoder instances
     76
     77  ParameterSetMap<TComSPS>   m_spsMap;
     78  ParameterSetMap<TComPPS>   m_ppsMap;
     79 
     80  IntAry1d                   m_parameterSetId; 
     81  BoolAry1d                  m_sendParameterSets;
     82
     83
    7784#if NH_MV
    7885  TComVPS*                   m_vps;                         ///< vps
     
    147154  Void xSetCamPara                ( TComVPS& vps );
    148155#endif
    149   GOPEntry* xGetGopEntry( Int layerIdInVps, Int poc );
     156
     157  Void xDeriveParameterSetIds( TComVPS& vps )
     158  {
     159
     160    m_parameterSetId  .clear();
     161    m_sendParameterSets.clear();
     162
     163    m_parameterSetId  .resize( m_numberOfLayers, -1 );
     164    m_sendParameterSets.resize( m_numberOfLayers, false );
     165    if ( !m_shareParameterSets )
     166    {
     167      AOT( m_numberOfLayers > 16 );
     168      for (Int curVpsLayerId = 0; curVpsLayerId < m_numberOfLayers; curVpsLayerId++ )
     169      {
     170        m_parameterSetId   [curVpsLayerId] = curVpsLayerId;
     171        m_sendParameterSets[curVpsLayerId] = true         ;
     172      }
     173    }
     174    else
     175    {
     176      // The spec requires e.g.:
     177      // - It is a requirement of bitstream conformance that, when present, the value of chroma_format_idc shall be less than or equal to chroma_format_vps_idc
     178      //   of the vps_rep_format_idx[ j ]-th rep_format( ) syntax structure in the active VPS, where j is equal to LayerIdxInVps[ layerIdCurr ]. 
     179
     180      // Consequently, a depth layer with chorma format 4:0:0 cannot refer to a base layer SPS with chroma format 4:2:0
     181
     182      // Furthermore, it is required that
     183      // - the SPS RBSP shall have nuh_layer_id equal to 0, nuhLayerId, or IdRefLayer[ nuhLayerId ][ i ] with any value of i in the range of 0 to NumRefLayers[ nuhLayerId ] - 1, inclusive.
     184
     185      // Because of these requirements and when parameter set sharing is enabled, HTM sends the parameter sets for a current layer in its smallest reference layer having the same representation format.
     186
     187
     188      Int curPsId = 0;
     189
     190      // Loop all layers
     191      for (Int curVpsLayerId = 0; curVpsLayerId < m_numberOfLayers; curVpsLayerId++ )
     192      {
     193        // Get smallest reference layer with same rep format idx
     194        Int curNuhLayerId = vps.getLayerIdInNuh(curVpsLayerId);
     195        Int smallestRefNuhLIdSameRepFmt   = curNuhLayerId;
     196
     197        Int curRepFormatIdx = m_layerIdxInVpsToRepFormatIdx[ curVpsLayerId ];
     198
     199        for (Int j = 0; j < vps.getNumRefLayers( curNuhLayerId ); j++ )
     200        {
     201          Int refNuhLayerId = vps.getIdRefLayer( curNuhLayerId, j );
     202          Int refVpsLayerId = vps.getLayerIdInVps( refNuhLayerId );
     203
     204          if ( smallestRefNuhLIdSameRepFmt > refNuhLayerId &&  m_layerIdxInVpsToRepFormatIdx[refVpsLayerId] == curRepFormatIdx  )
     205          {
     206            smallestRefNuhLIdSameRepFmt = refNuhLayerId;
     207          }
     208        }
     209
     210        Int smallestRefVpsLIdSameRepFmt =   vps.getLayerIdInVps(  smallestRefNuhLIdSameRepFmt );
     211
     212        if (smallestRefVpsLIdSameRepFmt == curVpsLayerId )
     213        {
     214          m_sendParameterSets[ curVpsLayerId ] = true;         
     215          m_parameterSetId   [ curVpsLayerId ] = curPsId;
     216          curPsId++;
     217          AOT( curPsId > 15 );
     218        }
     219        else
     220        {
     221          AOT( m_parameterSetId   [ smallestRefVpsLIdSameRepFmt  ] == -1 );
     222          m_parameterSetId   [ curVpsLayerId ] = m_parameterSetId   [ smallestRefVpsLIdSameRepFmt  ];
     223        }
     224
     225       
     226      }
     227    }
     228  }
     229
    150230  Int  xGetMax( std::vector<Int>& vec);
    151231  Bool xLayerIdInTargetEncLayerIdList( Int nuhLayerId );
    152232#endif
    153 #if NH_3D_DLT
     233#if NH_3D
    154234  Void xDeriveDltArray( TComVPS& vps, TComDLT* dlt );
    155235  Void xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt);
     
    165245#else
    166246  TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
    167 #endif
     247 
     248#endif
     249private:
     250
    168251};// END CLASS DEFINITION TAppEncTop
    169252
  • trunk/source/App/TAppEncoder/encmain.cpp

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5757  fprintf( stdout, "\n" );
    5858#if NH_MV
    59   fprintf( stdout, "3D-HTM Software: Encoder Version [%s] based on HM Version [%s]", NV_VERSION, HM_VERSION ); 
     59#if NH_3D
     60  const char* hevcExt = "3D";
     61#else
     62  const char* hevcExt = "MV";
     63#endif
     64  fprintf( stdout, "HTM Software: Encoder Version [%s][%s] based on HM Version [%s]", NV_VERSION, hevcExt , HM_VERSION); 
    6065#else
    6166  fprintf( stdout, "HM software: Encoder Version [%s] (including RExt)", NV_VERSION );
     
    6570  fprintf( stdout, NVM_BITS );
    6671  fprintf( stdout, "\n\n" );
    67 
     72#if NH_MV
     73  fprintf( stdout, "Use the HEVC_EXT define to select between MV- and 3D-HEVC. \n\n" ); 
     74#endif
    6875  // create application encoder class
    6976  cTAppEncTop.create();
  • trunk/source/App/utils/BitrateTargeting/ExtractBitrates.cpp

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *