Changeset 1413 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncTop.cpp


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

Merged HTM-16.2-dev@1412

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibEncoder/TEncTop.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 *
     
    5454// ====================================================================================================================
    5555
    56 TEncTop::TEncTop()
    57 {
     56#if !NH_MV
     57TEncTop::TEncTop() :
     58    m_spsMap(MAX_NUM_SPS)
     59  , m_ppsMap(MAX_NUM_PPS)
     60#else
     61   TEncTop::TEncTop( ParameterSetMap<TComSPS>& spsMap, ParameterSetMap<TComPPS>& ppsMap ) :
     62     m_spsMap(spsMap)
     63   , m_ppsMap(ppsMap)
     64#endif
     65      {
     66
    5867  m_iPOCLast          = -1;
    5968  m_iNumPicRcvd       =  0;
     
    7988  m_ivPicLists = NULL;
    8089#endif
    81 #if NH_3D_IC
     90#if NH_3D
    8291  m_aICEnableCandidate = NULL;
    8392  m_aICEnableNum = NULL;
     
    91100TEncTop::~TEncTop()
    92101{
    93 #if NH_3D_FIX_LEAK
    94 #if NH_3D_IC
     102#if NH_3D
    95103  if ( m_aICEnableCandidate != NULL )
    96104  {
     
    104112#endif
    105113
    106 #endif
    107114#if ENC_DEC_TRACE
    108115  if (g_hTrace != stdout)
     
    222229#endif
    223230{
     231#if NH_MV
     232  Int parameterSetId     =  getParameterSetId( );
     233
     234  TComSPS& sps0 = *(m_spsMap.allocatePS( parameterSetId ) ); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues.
     235  TComPPS& pps0 = *(m_ppsMap.allocatePS( parameterSetId ) );
     236#else
     237  TComSPS &sps0=*(m_spsMap.allocatePS(0)); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues.
     238  TComPPS &pps0=*(m_ppsMap.allocatePS(0));
     239#endif
    224240  // initialize SPS
    225241#if H_3D
    226242  // Assuming that all PPS indirectly refer to the same VPS via different SPS
    227   m_cSPS.setVPS(m_cVPS);
    228 #endif
    229   xInitSPS();
    230   xInitVPS();
    231 
    232 #if U0132_TARGET_BITS_SATURATION
     243  sps.setVPS(m_cVPS);
     244#endif
     245
     246#if NH_MV
     247  Bool initParameterSets = getSendParameterSets();
     248
     249  if ( initParameterSets )
     250  {
     251    xInitSPS( sps0 );
     252  }
     253#else
     254  xInitSPS( sps0 );
     255  xInitVPS((*m_cVPS), sps0);
     256#endif
     257
    233258  if (m_RCCpbSaturationEnabled)
    234259  {
    235     m_cRateCtrl.initHrdParam(m_cSPS.getVuiParameters()->getHrdParameters(), m_iFrameRate, m_RCInitialCpbFullness);
    236   }
    237 #endif
     260    m_cRateCtrl.initHrdParam(sps0.getVuiParameters()->getHrdParameters(), m_iFrameRate, m_RCInitialCpbFullness);
     261  }
     262
    238263  m_cRdCost.setCostMode(m_costMode);
    239264
    240265#if NH_MV
    241   // This seems to be incorrect, but irrelevant for the MV-HEVC
    242   *(m_cVPS->getPTL()) = *m_cSPS.getPTL();
    243   m_cVPS->getTimingInfo()->setTimingInfoPresentFlag       ( false );
    244 #endif
    245   // initialize PPS
    246   xInitPPS();
    247   xInitRPS(isFieldCoding);
    248 
    249   xInitPPSforTiles();
    250 #if NH_3D_IC
     266  if ( initParameterSets )
     267  {
     268    // This seems to be incorrect, but irrelevant for the MV-HEVC
     269    if (m_layerId == 0 )
     270    {
     271      *(m_cVPS->getPTL()) = *sps0.getPTL();
     272      m_cVPS->getTimingInfo()->setTimingInfoPresentFlag       ( false );
     273    }
     274#endif
     275    // initialize PPS
     276    xInitPPS(pps0, sps0);
     277    xInitRPS(sps0, isFieldCoding);
     278    xInitScalingLists(sps0, pps0);
     279
     280    if (m_wcgChromaQpControl.isEnabled())
     281    {
     282#if NH_MV
     283      AOT( true ); // This is currently not supported.
     284#endif
     285      TComPPS &pps1=*(m_ppsMap.allocatePS(1));
     286      xInitPPS(pps1, sps0);
     287      xInitScalingLists(sps0, pps1);
     288    }
     289#if NH_MV
     290  }
     291
     292  // Copy initialized PS
     293  m_activeSps    = sps0;
     294  m_activePps    = pps0;
     295 
     296  // Infer layer specific values for copy
     297  m_activeSps.inferRepFormat( m_cVPS, getLayerId(), initParameterSets );
     298#endif
     299
     300#if NH_3D
    251301  m_aICEnableCandidate = new Int[ 10 ];
    252302  m_aICEnableNum = new Int[ 10 ];
     
    258308  }
    259309#endif
     310
    260311
    261312  // initialize processing unit classes
     
    263314  m_cSliceEncoder.init( this );
    264315  m_cCuEncoder.   init( this );
     316  m_cCuEncoder.setSliceEncoder(&m_cSliceEncoder);
    265317
    266318#if KWU_RC_MADPRED_E0227
     
    273325                   m_useRDOQ,
    274326                   m_useRDOQTS,
    275 #if T0196_SELECTIVE_RDOQ
    276327                   m_useSelectiveRDOQ,
    277 #endif
    278328                   true
    279329                  ,m_useTransformSkipFast
     
    287337
    288338  m_iMaxRefPicNum = 0;
    289 
    290   xInitScalingLists();
    291 }
    292 
    293 Void TEncTop::xInitScalingLists()
     339}
     340
     341Void TEncTop::xInitScalingLists(TComSPS &sps, TComPPS &pps)
    294342{
    295343  // Initialise scaling lists
     
    297345  const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] =
    298346  {
    299       m_cSPS.getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA),
    300       m_cSPS.getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA)
     347      sps.getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA),
     348      sps.getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA)
    301349  };
    302350  if(getUseScalingListId() == SCALING_LIST_OFF)
    303351  {
    304     getTrQuant()->setFlatScalingList(maxLog2TrDynamicRange, m_cSPS.getBitDepths());
     352    getTrQuant()->setFlatScalingList(maxLog2TrDynamicRange, sps.getBitDepths());
    305353    getTrQuant()->setUseScalingList(false);
    306     m_cSPS.setScalingListPresentFlag(false);
    307     m_cPPS.setScalingListPresentFlag(false);
     354    sps.setScalingListPresentFlag(false);
     355    pps.setScalingListPresentFlag(false);
    308356  }
    309357  else if(getUseScalingListId() == SCALING_LIST_DEFAULT)
    310358  {
    311     m_cSPS.getScalingList().setDefaultScalingList ();
    312     m_cSPS.setScalingListPresentFlag(false);
    313     m_cPPS.setScalingListPresentFlag(false);
    314 
    315     getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), maxLog2TrDynamicRange, m_cSPS.getBitDepths());
     359    sps.getScalingList().setDefaultScalingList ();
     360    sps.setScalingListPresentFlag(false);
     361    pps.setScalingListPresentFlag(false);
     362
     363    getTrQuant()->setScalingList(&(sps.getScalingList()), maxLog2TrDynamicRange, sps.getBitDepths());
    316364    getTrQuant()->setUseScalingList(true);
    317365  }
    318366  else if(getUseScalingListId() == SCALING_LIST_FILE_READ)
    319367  {
    320     m_cSPS.getScalingList().setDefaultScalingList ();
    321     if(m_cSPS.getScalingList().xParseScalingList(getScalingListFileName()))
     368    sps.getScalingList().setDefaultScalingList ();
     369    if(sps.getScalingList().xParseScalingList(getScalingListFileName()))
    322370    {
    323371      Bool bParsedScalingList=false; // Use of boolean so that assertion outputs useful string
     
    325373      exit(1);
    326374    }
    327     m_cSPS.getScalingList().checkDcOfMatrix();
    328     m_cSPS.setScalingListPresentFlag(m_cSPS.getScalingList().checkDefaultScalingList());
    329     m_cPPS.setScalingListPresentFlag(false);
    330     getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), maxLog2TrDynamicRange, m_cSPS.getBitDepths());
     375    sps.getScalingList().checkDcOfMatrix();
     376    sps.setScalingListPresentFlag(sps.getScalingList().checkDefaultScalingList());
     377    pps.setScalingListPresentFlag(false);
     378    getTrQuant()->setScalingList(&(sps.getScalingList()), maxLog2TrDynamicRange, sps.getBitDepths());
    331379    getTrQuant()->setUseScalingList(true);
    332380  }
     
    346394    for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep)
    347395    {
    348       m_cSPS.getScalingList().checkPredMode( sizeId, listId );
     396        sps.getScalingList().checkPredMode( sizeId, listId );
    349397    }
    350398  }
     
    362410
    363411  // get original YUV
    364   xGetNewPicBuffer( pcPicCurr );
     412
     413  xGetNewPicBuffer( pcPicCurr, getParameterSetId() );
    365414  pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
    366415
     
    431480    TComPic* pcPicCurr = NULL;
    432481
    433     xGetNewPicBuffer( pcPicCurr );
     482    Int ppsID=-1; // Use default PPS ID
     483    if (getWCGChromaQPControl().isEnabled())
     484    {
     485      ppsID=getdQPs()[ m_iPOCLast+1 ];
     486    }
     487    xGetNewPicBuffer( pcPicCurr, ppsID );
    434488    pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
    435489    pcPicYuvTrueOrg->copyToPic( pcPicCurr->getPicYuvTrueOrg() );
     
    454508#if NH_MV
    455509  }
    456   m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb(getLayerId(), false) ), rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, gopId);
     510  m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb(getLayerId(), false) ), rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE,  m_printMSSSIM, gopId);
    457511
    458512  if( gopId + 1 == m_cGOPEncoder.getGOPSize() )
     
    460514#else
    461515  // compress GOP
     516#if JVET_F0064_MSSSIM
     517  m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, m_printMSSSIM);
     518#else
    462519  m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE);
     520#endif
    463521#endif
    464522  if ( m_RCEnableRateControl )
     
    515573
    516574      TComPic *pcField;
    517       xGetNewPicBuffer( pcField );
     575      xGetNewPicBuffer( pcField, -1 );
    518576      pcField->setReconMark (false);                     // where is this normally?
    519577
     
    536594
    537595      pcField->getSlice(0)->setPOC( m_iPOCLast );        // superfluous?
     596#if !REDUCED_ENCODER_MEMORY
    538597      pcField->getPicYuvRec()->setBorderExtension(false);// where is this normally?
     598#endif
    539599
    540600      pcField->setTopField(isTopField);                  // interlaced requirement
     
    570630    {
    571631      // compress GOP
     632#if JVET_F0064_MSSSIM
     633      m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff, snrCSC, m_printFrameMSE, m_printMSSSIM);
     634#else
    572635      m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff, snrCSC, m_printFrameMSE);
     636#endif
    573637
    574638      iNumEncoded += m_iNumPicRcvd;
     
    590654 \retval rpcPic obtained picture buffer
    591655 */
    592 Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic )
    593 {
     656Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic, Int ppsId )
     657{
     658  rpcPic=0;
     659
     660#if NH_MV
     661  const TComPPS &pps = m_activePps;
     662  const TComSPS &sps = m_activeSps;
     663 
     664  if ( ppsId > 0 )
     665  {
     666    assert( pps.getPPSId() == ppsId );
     667    assert( sps.getSPSId() == pps.getSPSId() );
     668  }
     669#else
     670  const TComSPS *pSPS=m_spsMap.getPS(pps.getSPSId());
    594671  // At this point, the SPS and PPS can be considered activated - they are copied to the new TComPic.
     672  const TComPPS *pPPS=(ppsId<0) ? m_ppsMap.getFirstPS() : m_ppsMap.getPS(ppsId);
     673  assert (pPPS!=0);
     674  const TComPPS &pps=*pPPS;
     675  assert (pSPS!=0);
     676
     677  assert (pSPS!=0);
     678  const TComSPS &sps=*pSPS;
     679
     680#endif
     681
    595682
    596683#if NH_MV
    597684  TComList<TComPic*>& cListPic = *(m_ivPicLists->getSubDpb(getLayerId(), false) );
    598685  TComSlice::sortPicList(cListPic);
     686  // Infer the correct rep format
     687
     688  // As
    599689#else
    600690  TComSlice::sortPicList(m_cListPic);
     
    608698    Int iSize = Int( cListPic.size() );
    609699#else
     700  // use an entry in the buffered list if the maximum number that need buffering has been reached:
     701
    610702  if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) )
    611703  {
     
    615707    for ( Int i = 0; i < iSize; i++ )
    616708    {
    617       rpcPic = *(iterPic++);
     709      rpcPic = *iterPic;
    618710      if(rpcPic->getSlice(0)->isReferenced() == false)
    619711      {
    620712        break;
    621713      }
    622     }
    623   }
    624   else
     714      iterPic++;
     715    }
     716    // If PPS ID is the same, we will assume that it has not changed since it was last used
     717    // and return the old object.
     718    if (pps.getPPSId() == rpcPic->getPicSym()->getPPS().getPPSId())
     719    {
     720#if REDUCED_ENCODER_MEMORY
     721      rpcPic->releaseAllReconstructionData();
     722      rpcPic->prepareForEncoderSourcePicYuv();
     723#endif
     724    }
     725    else
     726    {
     727      // the IDs differ - free up an entry in the list, and then create a new one, as with the case where the max buffering state has not been reached.
     728      delete rpcPic;
     729      cListPic.erase(iterPic);
     730      rpcPic=0;
     731    }
     732  }
     733
     734  if (rpcPic==0)
    625735  {
    626736    if ( getUseAdaptiveQP() )
    627737    {
    628738      TEncPic* pcEPic = new TEncPic;
    629       pcEPic->create( m_cSPS, m_cPPS, m_cPPS.getMaxCuDQPDepth()+1, false);
     739#if REDUCED_ENCODER_MEMORY
     740      pcEPic->create( sps, pps, pps.getMaxCuDQPDepth()+1);
     741#else
     742      pcEPic->create( sps, pps, pps.getMaxCuDQPDepth()+1, false);
     743#endif
    630744      rpcPic = pcEPic;
    631745    }
     
    633747    {
    634748      rpcPic = new TComPic;
    635       rpcPic->create( m_cSPS, m_cPPS, false );
     749#if REDUCED_ENCODER_MEMORY
     750      rpcPic->create( sps, pps, true, false );
     751#else
     752      rpcPic->create( sps, pps, false );
     753#endif
    636754    }
    637755
     
    648766
    649767  rpcPic->getSlice(0)->setPOC( m_iPOCLast );
     768#if !REDUCED_ENCODER_MEMORY
    650769  // mark it should be extended
    651770  rpcPic->getPicYuvRec()->setBorderExtension(false);
     
    653772  rpcPic->getPicYuvOrg()->setBorderExtension(false);
    654773#endif
    655 
    656 }
    657 
    658 Void TEncTop::xInitVPS()
     774#endif
     775}
     776
     777Void TEncTop::xInitVPS(TComVPS &vps, const TComSPS &sps)
    659778{
    660779  // The SPS must have already been set up.
     
    663782  // Do initialization in TAppEncTop
    664783#else
    665   *m_cVPS.getPTL() = *m_cSPS.getPTL();
    666   m_cVPS.setMaxOpSets(1);
    667   m_cVPS.getTimingInfo()->setTimingInfoPresentFlag       ( false );
    668   m_cVPS.setNumHrdParameters( 0 );
    669 
    670   m_cVPS.createHrdParamBuffer();
    671   for( UInt i = 0; i < m_cVPS.getNumHrdParameters(); i ++ )
    672   {
    673     m_cVPS.setHrdOpSetIdx( 0, i );
    674     m_cVPS.setCprmsPresentFlag( false, i );
     784  *vps.getPTL() = *sps.getPTL();
     785  vps.setMaxOpSets(1);
     786  vps.getTimingInfo()->setTimingInfoPresentFlag       ( false );
     787  vps.setNumHrdParameters( 0 );
     788
     789  vps.createHrdParamBuffer();
     790  for( UInt i = 0; i < vps.getNumHrdParameters(); i ++ )
     791  {
     792    vps.setHrdOpSetIdx( 0, i );
     793    vps.setCprmsPresentFlag( false, i );
    675794    // Set up HrdParameters here.
    676795  }
     
    678797}
    679798
    680 Void TEncTop::xInitSPS()
    681 {
    682 #if NH_MV
    683   m_cSPS.setSPSId( getLayerIdInVps() );
    684   m_cSPS.setLayerId( getLayerId() );
     799Void TEncTop::xInitSPS(TComSPS &sps)
     800{
     801#if NH_MV
     802  //AOF( sps.getSPSId() == getLayerIdInVps() );
     803  sps.setLayerId( getLayerId() );
    685804 // Code below needs to be moved to VPS
    686805#endif
    687   ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
     806  ProfileTierLevel& profileTierLevel = *sps.getPTL()->getGeneralPTL();
    688807  profileTierLevel.setLevelIdc(m_level);
    689808  profileTierLevel.setTierFlag(m_levelTier);
     
    714833   * that chooses the actual compatibility based upon options */
    715834#if NH_MV 
    716   m_cSPS.setUpdateRepFormatFlag           ( false );   
    717   Bool multiLayerExtensionFlag  = ( getLayerId() > 0 ) && ( m_cVPS->getNumRefLayers( getLayerId() ) > 0 );
     835  sps.setUpdateRepFormatFlag           ( false );   
    718836 
    719   m_cSPS.setSpsExtOrMaxSubLayersMinus1( multiLayerExtensionFlag ? 7 : m_maxTempLayer - 1 );
     837  Bool multiLayerExtensionFlag  =      ( getLayerId() > 0  &&  m_cVPS->getNumRefLayers( getLayerId() ) > 0 );
     838  sps.setSpsExtOrMaxSubLayersMinus1( multiLayerExtensionFlag ? 7 : m_maxTempLayer - 1 );
    720839  if ( multiLayerExtensionFlag )
    721840  {
    722     m_cSPS.setSpsInferScalingListFlag   ( true );
    723     m_cSPS.setSpsScalingListRefLayerId( m_cVPS->getIdRefLayer( getLayerId(), 0 ) );
     841    sps.setSpsInferScalingListFlag   ( true );
     842    sps.setSpsScalingListRefLayerId( m_cVPS->getIdRefLayer( getLayerId(), 0 ) );
    724843#if NH_MV
    725844    if ( m_bUseDisparitySearchRangeRestriction )
    726845    {
    727       m_cSPS.setInterViewMvVertConstraintFlag ( true ) ;
     846      sps.setInterViewMvVertConstraintFlag ( true ) ;
    728847    }
    729848#endif
    730849  } 
    731   m_cSPS.setSpsExtensionPresentFlag       ( true );
    732   m_cSPS.setSpsMultilayerExtensionFlag    ( true );
     850  sps.setSpsExtensionPresentFlag       ( true );
     851  sps.setSpsMultilayerExtensionFlag    ( true );
    733852#if NH_3D
    734   m_cSPS.setSps3dExtensionFlag            ( true );
    735 #endif
    736 #endif
    737 
    738   m_cSPS.setPicWidthInLumaSamples  ( m_iSourceWidth      );
    739   m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight     );
    740   m_cSPS.setConformanceWindow      ( m_conformanceWindow );
    741   m_cSPS.setMaxCUWidth             ( m_maxCUWidth        );
    742   m_cSPS.setMaxCUHeight            ( m_maxCUHeight       );
    743   m_cSPS.setMaxTotalCUDepth        ( m_maxTotalCUDepth   );
     853  sps.setSps3dExtensionFlag            ( true );
     854#endif
     855#endif
     856
     857  sps.setPicWidthInLumaSamples  ( m_iSourceWidth      );
     858  sps.setPicHeightInLumaSamples ( m_iSourceHeight     );
     859  sps.setConformanceWindow      ( m_conformanceWindow );
     860  sps.setMaxCUWidth             ( m_maxCUWidth        );
     861  sps.setMaxCUHeight            ( m_maxCUHeight       );
     862  sps.setMaxTotalCUDepth        ( m_maxTotalCUDepth   );
    744863#if NH_3D
    745864  assert( !getIsDepth()  || m_chromaFormatIDC == CHROMA_400 );
    746865#endif
    747   m_cSPS.setChromaFormatIdc( m_chromaFormatIDC);
    748   m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_log2DiffMaxMinCodingBlockSize);
    749 
    750   Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getLog2DiffMaxMinCodingBlockSize() );
     866  sps.setChromaFormatIdc( m_chromaFormatIDC);
     867  sps.setLog2DiffMaxMinCodingBlockSize(m_log2DiffMaxMinCodingBlockSize);
     868
     869  Int minCUSize = sps.getMaxCUWidth() >> ( sps.getLog2DiffMaxMinCodingBlockSize() );
    751870  Int log2MinCUSize = 0;
    752871  while(minCUSize > 1)
     
    756875  }
    757876
    758   m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize);
    759 
    760   m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize);
    761   m_cSPS.setUsePCM        ( m_usePCM           );
    762   m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize  );
    763 
    764   m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize );
    765   m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize );
    766   m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter    );
    767   m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra    );
    768 
    769   m_cSPS.setTMVPFlagsPresent((getTMVPModeId() == 2 || getTMVPModeId() == 1));
    770 
    771   m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
    772 
    773   m_cSPS.setUseAMP ( m_useAMP );
     877  sps.setLog2MinCodingBlockSize(log2MinCUSize);
     878
     879  sps.setPCMLog2MinSize (m_uiPCMLog2MinSize);
     880  sps.setUsePCM        ( m_usePCM           );
     881  sps.setPCMLog2MaxSize( m_pcmLog2MaxSize  );
     882
     883  sps.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize );
     884  sps.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize );
     885  sps.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter    );
     886  sps.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra    );
     887
     888  sps.setSPSTemporalMVPEnabledFlag((getTMVPModeId() == 2 || getTMVPModeId() == 1));
     889
     890  sps.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
     891
     892  sps.setUseAMP ( m_useAMP );
    774893
    775894  for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
    776895  {
    777     m_cSPS.setBitDepth      (ChannelType(channelType), m_bitDepth[channelType] );
     896    sps.setBitDepth      (ChannelType(channelType), m_bitDepth[channelType] );
    778897#if O0043_BEST_EFFORT_DECODING
    779     m_cSPS.setStreamBitDepth(ChannelType(channelType), m_bitDepth[channelType] );
    780 #endif
    781     m_cSPS.setQpBDOffset  (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8)));
    782     m_cSPS.setPCMBitDepth (ChannelType(channelType), m_PCMBitDepth[channelType]         );
    783   }
    784 #if NH_MV
    785   m_cSPS.inferRepFormat( m_cVPS, getLayerId(), true );
    786 #endif
    787 m_cSPS.setUseSAO( m_bUseSAO );
    788 
    789   m_cSPS.setMaxTLayers( m_maxTempLayer );
    790   m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false );
    791 
    792   for (Int i = 0; i < min(m_cSPS.getMaxTLayers(),(UInt) MAX_TLAYER); i++ )
    793   {
    794     m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i);
    795     m_cSPS.setNumReorderPics(m_numReorderPics[i], i);
     898    sps.setStreamBitDepth(ChannelType(channelType), m_bitDepth[channelType] );
     899#endif
     900    sps.setQpBDOffset  (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8)));
     901    sps.setPCMBitDepth (ChannelType(channelType), m_PCMBitDepth[channelType]         );
     902  }
     903  sps.setUseSAO( m_bUseSAO );
     904
     905  sps.setMaxTLayers( m_maxTempLayer );
     906  sps.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false );
     907
     908  for (Int i = 0; i < min(sps.getMaxTLayers(),(UInt) MAX_TLAYER); i++ )
     909  {
     910    sps.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i);
     911    sps.setNumReorderPics(m_numReorderPics[i], i);
    796912  }
    797913#if NH_MV
     
    804920      if ( m_cVPS->getNecessaryLayerFlag( ols, is ) )
    805921      {     
    806         m_cSPS.inferSpsMaxDecPicBufferingMinus1( m_cVPS, ols, targetDecLayerIdList[is], true );       
    807       }
    808     }
    809   }
    810 #endif
    811 
    812 
    813   m_cSPS.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag );
    814   m_cSPS.setScalingListFlag ( (m_useScalingListId == SCALING_LIST_OFF) ? 0 : 1 );
    815   m_cSPS.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
    816   m_cSPS.setVuiParametersPresentFlag(getVuiParametersPresentFlag());
    817 
    818   if (m_cSPS.getVuiParametersPresentFlag())
    819   {
    820     TComVUI* pcVUI = m_cSPS.getVuiParameters();
     922        sps.inferSpsMaxDecPicBufferingMinus1( m_cVPS, ols, targetDecLayerIdList[is], true );       
     923      }
     924    }
     925  }
     926#endif
     927
     928
     929  sps.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag );
     930  sps.setScalingListFlag ( (m_useScalingListId == SCALING_LIST_OFF) ? 0 : 1 );
     931  sps.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
     932  sps.setVuiParametersPresentFlag(getVuiParametersPresentFlag());
     933
     934  if (sps.getVuiParametersPresentFlag())
     935  {
     936    TComVUI* pcVUI = sps.getVuiParameters();
    821937    pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag());
    822938    pcVUI->setAspectRatioIdc(getAspectRatioIdc());
     
    855971    pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical());
    856972  }
    857   m_cSPS.setNumLongTermRefPicSPS(NUM_LONG_TERM_REF_PIC_SPS);
     973  sps.setNumLongTermRefPicSPS(NUM_LONG_TERM_REF_PIC_SPS);
    858974  assert (NUM_LONG_TERM_REF_PIC_SPS <= MAX_NUM_LONG_TERM_REF_PICS);
    859975  for (Int k = 0; k < NUM_LONG_TERM_REF_PIC_SPS; k++)
    860976  {
    861     m_cSPS.setLtRefPicPocLsbSps(k, 0);
    862     m_cSPS.setUsedByCurrPicLtSPSFlag(k, 0);
    863   }
    864 
    865 #if U0132_TARGET_BITS_SATURATION
     977    sps.setLtRefPicPocLsbSps(k, 0);
     978    sps.setUsedByCurrPicLtSPSFlag(k, 0);
     979  }
     980
    866981  if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() || getCpbSaturationEnabled() )
    867 #else
    868   if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() )
    869 #endif
    870   {
    871     xInitHrdParameters();
     982  {
     983    xInitHrdParameters(sps);
    872984  }
    873985  if( getBufferingPeriodSEIEnabled() || getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() )
    874986  {
    875     m_cSPS.getVuiParameters()->setHrdParametersPresentFlag( true );
     987    sps.getVuiParameters()->setHrdParametersPresentFlag( true );
    876988  }
    877989
    878990  // Set up SPS range extension settings
    879   m_cSPS.getSpsRangeExtension().setTransformSkipRotationEnabledFlag(m_transformSkipRotationEnabledFlag);
    880   m_cSPS.getSpsRangeExtension().setTransformSkipContextEnabledFlag(m_transformSkipContextEnabledFlag);
     991  sps.getSpsRangeExtension().setTransformSkipRotationEnabledFlag(m_transformSkipRotationEnabledFlag);
     992  sps.getSpsRangeExtension().setTransformSkipContextEnabledFlag(m_transformSkipContextEnabledFlag);
    881993  for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++)
    882994  {
    883     m_cSPS.getSpsRangeExtension().setRdpcmEnabledFlag(RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]);
    884   }
    885   m_cSPS.getSpsRangeExtension().setExtendedPrecisionProcessingFlag(m_extendedPrecisionProcessingFlag);
    886   m_cSPS.getSpsRangeExtension().setIntraSmoothingDisabledFlag( m_intraSmoothingDisabledFlag );
    887   m_cSPS.getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag(m_highPrecisionOffsetsEnabledFlag);
    888   m_cSPS.getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag(m_persistentRiceAdaptationEnabledFlag);
    889   m_cSPS.getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag(m_cabacBypassAlignmentEnabledFlag);
    890 #if NH_MV
    891   m_cSPS.setSpsRangeExtensionsFlag( m_cSPS.getSpsRangeExtension().settingsDifferFromDefaults() );
    892 #endif
    893 }
    894 #if U0132_TARGET_BITS_SATURATION
     995    sps.getSpsRangeExtension().setRdpcmEnabledFlag(RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]);
     996  }
     997  sps.getSpsRangeExtension().setExtendedPrecisionProcessingFlag(m_extendedPrecisionProcessingFlag);
     998  sps.getSpsRangeExtension().setIntraSmoothingDisabledFlag( m_intraSmoothingDisabledFlag );
     999  sps.getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag(m_highPrecisionOffsetsEnabledFlag);
     1000  sps.getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag(m_persistentRiceAdaptationEnabledFlag);
     1001  sps.getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag(m_cabacBypassAlignmentEnabledFlag);
     1002#if NH_MV
     1003  sps.setSpsRangeExtensionsFlag( sps.getSpsRangeExtension().settingsDifferFromDefaults() );
     1004#endif
     1005#if NH_3D
     1006  sps.setSps3dExtension( m_sps3dExtension );
     1007#endif
     1008}
    8951009// calculate scale value of bitrate and initial delay
    8961010Int calcScale(Int x)
    8971011{
     1012  if (x==0)
     1013  {
     1014    return 0;
     1015  }
    8981016  UInt iMask = 0xffffffff;
    8991017  Int ScaleValue = 32;
     
    9071025  return ScaleValue;
    9081026}
    909 #endif
    910 Void TEncTop::xInitHrdParameters()
     1027Void TEncTop::xInitHrdParameters(TComSPS &sps)
    9111028{
    9121029  Bool useSubCpbParams = (getSliceMode() > 0) || (getSliceSegmentMode() > 0);
    9131030  Int  bitRate         = getTargetBitrate();
    9141031  Bool isRandomAccess  = getIntraPeriod() > 0;
    915 # if U0132_TARGET_BITS_SATURATION
    9161032  Int cpbSize          = getCpbSize();
    9171033
     1034  assert (cpbSize!=0);  // CPB size may not be equal to zero. ToDo: have a better default and check for level constraints
    9181035  if( !getVuiParametersPresentFlag() && !getCpbSaturationEnabled() )
    919 #else
    920   if( !getVuiParametersPresentFlag() )
    921 #endif
    9221036  {
    9231037    return;
    9241038  }
    9251039
    926   TComVUI *vui = m_cSPS.getVuiParameters();
     1040  TComVUI *vui = sps.getVuiParameters();
    9271041  TComHRD *hrd = vui->getHrdParameters();
    9281042
     
    9821096  }
    9831097
    984 #if U0132_TARGET_BITS_SATURATION
    9851098  if (calcScale(bitRate) <= 6)
    9861099  {
     
    10001113    hrd->setCpbSizeScale(calcScale(cpbSize) - 4);
    10011114  }
    1002 #else
    1003   hrd->setBitRateScale( 4 );                                       // in units of 2^( 6 + 4 ) = 1,024 bps
    1004   hrd->setCpbSizeScale( 6 );                                       // in units of 2^( 4 + 6 ) = 1,024 bit
    1005 #endif
    10061115
    10071116  hrd->setDuCpbSizeScale( 6 );                                     // in units of 2^( 4 + 6 ) = 1,024 bit
     
    10361145    bitrateValue = bitRate / (1 << (6 + hrd->getBitRateScale()) );      // bitRate is in bits, so it needs to be scaled down
    10371146    // CpbSize[ i ] = ( cpb_size_value_minus1[ i ] + 1 ) * 2^( 4 + cpb_size_scale )
    1038 #if U0132_TARGET_BITS_SATURATION
    10391147    cpbSizeValue = cpbSize / (1 << (4 + hrd->getCpbSizeScale()) );      // using bitRate results in 1 second CPB size
    1040 #else
    1041     cpbSizeValue = bitRate / (1 << (4 + hrd->getCpbSizeScale()) );      // using bitRate results in 1 second CPB size
    1042 #endif
    1043 
    10441148
    10451149    // DU CPB size could be smaller (i.e. bitrateValue / number of DUs), but we don't know
     
    10661170
    10671171
    1068 Void TEncTop::xInitPPS()
    1069 {
    1070 #if NH_MV
    1071   m_cPPS.setLayerId( getLayerId() );
     1172Void TEncTop::xInitPPS(TComPPS &pps, const TComSPS &sps) const
     1173{
     1174
     1175  // pps ID already initialised.
     1176  pps.setSPSId(sps.getSPSId());
     1177
     1178#if NH_MV
     1179  AOF( pps.getPPSId() ==  getLayerIdInVps() );
     1180  pps.setLayerId( getLayerId() );
    10721181#if NH_3D
    10731182  // Check if this condition is still correct
     
    10771186#endif
    10781187  {
    1079     m_cPPS.setListsModificationPresentFlag( true );
    1080   }
    1081   m_cPPS.setPPSId( getLayerIdInVps() );
    1082   m_cPPS.setSPSId( getLayerIdInVps() );
    1083   m_cPPS.setPpsMultilayerExtensionFlag    ( true );
     1188    pps.setListsModificationPresentFlag( true );
     1189  }
     1190  pps.setPpsMultilayerExtensionFlag    ( true );
    10841191#if NH_3D
    10851192  // Might be used for DLT
    1086   m_cPPS.setPps3dExtensionFlag            ( getIsDepth() );
    1087 #endif
    1088 #endif
    1089 
    1090 #if NH_3D_DLT
     1193  pps.setPps3dExtensionFlag            ( getIsDepth() );
     1194#endif
     1195#endif
     1196
     1197#if NH_3D
     1198  // This should be done in TEncAppTop
     1199  TComDLT curDlt = m_cDLT;
    10911200  // create mapping from depth layer indexes to layer ids
    10921201  Int j=0;
     
    10951204    Int layerId = getVPS()->getLayerIdInNuh(i);
    10961205    if( getVPS()->getDepthId(layerId) )
    1097       m_cDLT.setDepthIdxToLayerId(j++, layerId);
    1098   }
    1099   m_cPPS.setDLT( m_cDLT );
    1100 #endif
    1101 
    1102   m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
     1206      curDlt.setDepthIdxToLayerId(j++, layerId);
     1207  }
     1208  pps.setDLT( curDlt );
     1209#endif
     1210
     1211  pps.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
    11031212  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
    11041213
     
    11081217  }
    11091218
     1219  if ( getLumaLevelToDeltaQPMapping().isEnabled() )
     1220  {
     1221    bUseDQP = true;
     1222  }
     1223
    11101224  if (m_costMode==COST_SEQUENCE_LEVEL_LOSSLESS || m_costMode==COST_LOSSLESS_CODING)
    11111225  {
     
    11131227  }
    11141228
    1115 
    11161229  if ( m_RCEnableRateControl )
    11171230  {
    1118     m_cPPS.setUseDQP(true);
    1119     m_cPPS.setMaxCuDQPDepth( 0 );
     1231    pps.setUseDQP(true);
     1232    pps.setMaxCuDQPDepth( 0 );
    11201233  }
    11211234  else if(bUseDQP)
    11221235  {
    1123     m_cPPS.setUseDQP(true);
    1124     m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth );
     1236    pps.setUseDQP(true);
     1237    pps.setMaxCuDQPDepth( m_iMaxCuDQPDepth );
    11251238  }
    11261239  else
    11271240  {
    1128     m_cPPS.setUseDQP(false);
    1129     m_cPPS.setMaxCuDQPDepth( 0 );
     1241    pps.setUseDQP(false);
     1242    pps.setMaxCuDQPDepth( 0 );
    11301243  }
    11311244
    11321245  if ( m_diffCuChromaQpOffsetDepth >= 0 )
    11331246  {
    1134     m_cPPS.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(m_diffCuChromaQpOffsetDepth);
    1135     m_cPPS.getPpsRangeExtension().clearChromaQpOffsetList();
    1136     m_cPPS.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6);
     1247    pps.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(m_diffCuChromaQpOffsetDepth);
     1248    pps.getPpsRangeExtension().clearChromaQpOffsetList();
     1249    pps.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6);
    11371250    /* todo, insert table entries from command line (NB, 0 should not be touched) */
    11381251  }
    11391252  else
    11401253  {
    1141     m_cPPS.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(0);
    1142     m_cPPS.getPpsRangeExtension().clearChromaQpOffsetList();
    1143   }
    1144   m_cPPS.getPpsRangeExtension().setCrossComponentPredictionEnabledFlag(m_crossComponentPredictionEnabledFlag);
    1145   m_cPPS.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA,   m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA  ]);
    1146   m_cPPS.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA]);
    1147 
    1148   m_cPPS.setQpOffset(COMPONENT_Cb, m_chromaCbQpOffset );
    1149   m_cPPS.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset );
    1150 #if W0038_CQP_ADJ
     1254    pps.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(0);
     1255    pps.getPpsRangeExtension().clearChromaQpOffsetList();
     1256  }
     1257  pps.getPpsRangeExtension().setCrossComponentPredictionEnabledFlag(m_crossComponentPredictionEnabledFlag);
     1258  pps.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA,   m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA  ]);
     1259  pps.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA]);
     1260
     1261  if (getWCGChromaQPControl().isEnabled())
     1262  {
     1263    const Int baseQp=m_iQP+pps.getPPSId();
     1264    const Double chromaQp = m_wcgChromaQpControl.chromaQpScale * baseQp + m_wcgChromaQpControl.chromaQpOffset;
     1265    const Double dcbQP = m_wcgChromaQpControl.chromaCbQpScale * chromaQp;
     1266    const Double dcrQP = m_wcgChromaQpControl.chromaCrQpScale * chromaQp;
     1267    const Int cbQP =(Int)(dcbQP + ( dcbQP < 0 ? -0.5 : 0.5) );
     1268    const Int crQP =(Int)(dcrQP + ( dcrQP < 0 ? -0.5 : 0.5) );
     1269    pps.setQpOffset(COMPONENT_Cb, Clip3( -12, 12, min(0, cbQP) + m_chromaCbQpOffset ));
     1270    pps.setQpOffset(COMPONENT_Cr, Clip3( -12, 12, min(0, crQP) + m_chromaCrQpOffset));
     1271  }
     1272  else
     1273  {
     1274    pps.setQpOffset(COMPONENT_Cb, m_chromaCbQpOffset );
     1275    pps.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset );
     1276  }
    11511277  Bool bChromaDeltaQPEnabled = false;
    11521278  {
     
    11641290    }
    11651291  }
    1166   m_cPPS.setSliceChromaQpFlag(bChromaDeltaQPEnabled);
    1167 #endif
    1168 
    1169   m_cPPS.setEntropyCodingSyncEnabledFlag( m_entropyCodingSyncEnabledFlag );
    1170   m_cPPS.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) );
    1171   m_cPPS.setUseWP( m_useWeightedPred );
    1172   m_cPPS.setWPBiPred( m_useWeightedBiPred );
    1173   m_cPPS.setOutputFlagPresentFlag( false );
    1174 #if NH_MV
    1175   m_cPPS.setNumExtraSliceHeaderBits( 2 );
    1176 #endif
    1177   m_cPPS.setSignHideFlag(getSignHideFlag());
     1292  pps.setSliceChromaQpFlag(bChromaDeltaQPEnabled);
     1293
     1294  pps.setEntropyCodingSyncEnabledFlag( m_entropyCodingSyncEnabledFlag );
     1295  pps.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) );
     1296  pps.setUseWP( m_useWeightedPred );
     1297  pps.setWPBiPred( m_useWeightedBiPred );
     1298  pps.setOutputFlagPresentFlag( false );
     1299#if NH_MV
     1300  pps.setNumExtraSliceHeaderBits( 2 );
     1301#endif
     1302  pps.setSignDataHidingEnabledFlag(getSignDataHidingEnabledFlag());
     1303
    11781304  if ( getDeblockingFilterMetric() )
    11791305  {
    1180     m_cPPS.setDeblockingFilterOverrideEnabledFlag(true);
    1181     m_cPPS.setPicDisableDeblockingFilterFlag(false);
     1306    pps.setDeblockingFilterOverrideEnabledFlag(true);
     1307    pps.setPPSDeblockingFilterDisabledFlag(false);
    11821308  }
    11831309  else
    11841310  {
    1185       m_cPPS.setDeblockingFilterOverrideEnabledFlag( !getLoopFilterOffsetInPPS() );
    1186       m_cPPS.setPicDisableDeblockingFilterFlag( getLoopFilterDisable() );
    1187     }
    1188 
    1189   if (! m_cPPS.getPicDisableDeblockingFilterFlag())
    1190   {
    1191     m_cPPS.setDeblockingFilterBetaOffsetDiv2( getLoopFilterBetaOffset() );
    1192     m_cPPS.setDeblockingFilterTcOffsetDiv2( getLoopFilterTcOffset() );
     1311    pps.setDeblockingFilterOverrideEnabledFlag( !getLoopFilterOffsetInPPS() );
     1312    pps.setPPSDeblockingFilterDisabledFlag( getLoopFilterDisable() );
     1313    }
     1314
     1315  if (! pps.getPPSDeblockingFilterDisabledFlag())
     1316  {
     1317    pps.setDeblockingFilterBetaOffsetDiv2( getLoopFilterBetaOffset() );
     1318    pps.setDeblockingFilterTcOffsetDiv2( getLoopFilterTcOffset() );
    11931319  }
    11941320  else
    11951321  {
    1196     m_cPPS.setDeblockingFilterBetaOffsetDiv2(0);
    1197     m_cPPS.setDeblockingFilterTcOffsetDiv2(0);
     1322    pps.setDeblockingFilterBetaOffsetDiv2(0);
     1323    pps.setDeblockingFilterTcOffsetDiv2(0);
    11981324  }
    11991325
    12001326  // deblockingFilterControlPresentFlag is true if any of the settings differ from the inferred values:
    1201   const Bool deblockingFilterControlPresentFlag = m_cPPS.getDeblockingFilterOverrideEnabledFlag() ||
    1202                                                   m_cPPS.getPicDisableDeblockingFilterFlag()      ||
    1203                                                   m_cPPS.getDeblockingFilterBetaOffsetDiv2() != 0 ||
    1204                                                   m_cPPS.getDeblockingFilterTcOffsetDiv2() != 0;
    1205 
    1206   m_cPPS.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag);
    1207 
    1208   m_cPPS.setLog2ParallelMergeLevelMinus2   (m_log2ParallelMergeLevelMinus2 );
    1209   m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
    1210   m_cPPS.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag );
     1327  const Bool deblockingFilterControlPresentFlag = pps.getDeblockingFilterOverrideEnabledFlag() ||
     1328                                                  pps.getPPSDeblockingFilterDisabledFlag()     ||
     1329                                                  pps.getDeblockingFilterBetaOffsetDiv2() != 0 ||
     1330                                                  pps.getDeblockingFilterTcOffsetDiv2() != 0;
     1331
     1332  pps.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag);
     1333
     1334  pps.setLog2ParallelMergeLevelMinus2   (m_log2ParallelMergeLevelMinus2 );
     1335  pps.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
     1336  pps.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag );
    12111337
    12121338
     
    12331359  }
    12341360  assert(bestPos <= 15);
    1235   m_cPPS.setNumRefIdxL0DefaultActive(bestPos);
    1236   m_cPPS.setNumRefIdxL1DefaultActive(bestPos);
    1237   m_cPPS.setTransquantBypassEnableFlag(getTransquantBypassEnableFlag());
    1238   m_cPPS.setUseTransformSkip( m_useTransformSkip );
    1239   m_cPPS.getPpsRangeExtension().setLog2MaxTransformSkipBlockSize( m_log2MaxTransformSkipBlockSize  );
     1361  pps.setNumRefIdxL0DefaultActive(bestPos);
     1362  pps.setNumRefIdxL1DefaultActive(bestPos);
     1363  pps.setTransquantBypassEnabledFlag(getTransquantBypassEnabledFlag());
     1364  pps.setUseTransformSkip( m_useTransformSkip );
     1365  pps.getPpsRangeExtension().setLog2MaxTransformSkipBlockSize( m_log2MaxTransformSkipBlockSize  );
    12401366
    12411367  if (m_sliceSegmentMode != NO_SLICES)
    12421368  {
    1243     m_cPPS.setDependentSliceSegmentsEnabledFlag( true );
    1244   }
     1369    pps.setDependentSliceSegmentsEnabledFlag( true );
     1370  }
     1371
     1372  xInitPPSforTiles(pps);
    12451373}
    12461374
    12471375//Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file.
    1248 Void TEncTop::xInitRPS(Bool isFieldCoding)
     1376Void TEncTop::xInitRPS(TComSPS &sps, Bool isFieldCoding)
    12491377{
    12501378  TComReferencePictureSet*      rps;
    12511379
    1252   m_cSPS.createRPSList(getGOPSize() + m_extraRPSs + 1);
    1253   TComRPSList* rpsList = m_cSPS.getRPSList();
     1380  sps.createRPSList(getGOPSize() + m_extraRPSs + 1);
     1381  TComRPSList* rpsList = sps.getRPSList();
    12541382
    12551383  for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++)
    12561384  {
    1257     GOPEntry ge = getGOPEntry(i);
     1385    const GOPEntry &ge = getGOPEntry(i);
    12581386    rps = rpsList->getReferencePictureSet(i);
    12591387    rps->setNumberOfPictures(ge.m_numRefPics);
     
    14801608}
    14811609
    1482 Void  TEncTop::xInitPPSforTiles()
    1483 {
    1484   m_cPPS.setTileUniformSpacingFlag( m_tileUniformSpacingFlag );
    1485   m_cPPS.setNumTileColumnsMinus1( m_iNumColumnsMinus1 );
    1486   m_cPPS.setNumTileRowsMinus1( m_iNumRowsMinus1 );
     1610Void  TEncTop::xInitPPSforTiles(TComPPS &pps)
     1611#if NH_MV
     1612  const
     1613#endif
     1614{
     1615  pps.setTileUniformSpacingFlag( m_tileUniformSpacingFlag );
     1616  pps.setNumTileColumnsMinus1( m_iNumColumnsMinus1 );
     1617  pps.setNumTileRowsMinus1( m_iNumRowsMinus1 );
    14871618  if( !m_tileUniformSpacingFlag )
    14881619  {
    1489     m_cPPS.setTileColumnWidth( m_tileColumnWidth );
    1490     m_cPPS.setTileRowHeight( m_tileRowHeight );
    1491   }
    1492   m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag );
     1620    pps.setTileColumnWidth( m_tileColumnWidth );
     1621    pps.setTileRowHeight( m_tileRowHeight );
     1622  }
     1623  pps.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag );
    14931624
    14941625  // # substreams is "per tile" when tiles are independent.
     
    15571688}
    15581689
     1690#if JCTVC_Y0038_PARAMS
     1691#if NH_MV
     1692Void TEncTop::setParamSetChanged(Int id, Bool isPps )
     1693{
     1694  if ( isPps )
     1695  {
     1696    m_ppsMap.setChangedFlag(id);
     1697  }
     1698  else
     1699  {
     1700    m_spsMap.setChangedFlag(id);
     1701  }
     1702}
     1703#else
     1704
     1705Void TEncTop::setParamSetChanged(Int spsId, Int ppsId)
     1706{
     1707  m_ppsMap.setChangedFlag(ppsId);
     1708  m_spsMap.setChangedFlag(spsId);
     1709}
     1710#endif
     1711#endif
     1712
     1713Bool TEncTop::PPSNeedsWriting(Int ppsId)
     1714{
     1715  Bool bChanged=m_ppsMap.getChangedFlag(ppsId);
     1716  m_ppsMap.clearChangedFlag(ppsId);
     1717  return bChanged;
     1718}
     1719
     1720Bool TEncTop::SPSNeedsWriting(Int spsId)
     1721{
     1722  Bool bChanged=m_spsMap.getChangedFlag(spsId);
     1723  m_spsMap.clearChangedFlag(spsId);
     1724  return bChanged;
     1725}
     1726
     1727#if X0038_LAMBDA_FROM_QP_CAPABILITY
     1728Int TEncCfg::getQPForPicture(const UInt gopIndex, const TComSlice *pSlice) const
     1729{
     1730  const Int lumaQpBDOffset = pSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
     1731  Int qp;
     1732
     1733  if (getCostMode()==COST_LOSSLESS_CODING)
     1734  {
     1735    qp=LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP;
     1736  }
     1737  else
     1738  {
     1739    const SliceType sliceType=pSlice->getSliceType();
     1740
     1741    qp = getBaseQP();
     1742
     1743#if JVET_G0101_QP_SWITCHING
     1744    // modify QP if a fractional QP was originally specified, cause dQPs to be 0 or 1.
     1745    const Int* pdQPs = getdQPs();
     1746    if ( pdQPs )
     1747    {
     1748      qp += pdQPs[ pSlice->getPOC() ];
     1749    }
     1750#endif
     1751
     1752    if(sliceType==I_SLICE)
     1753    {
     1754      qp += getIntraQPOffset();
     1755    }
     1756    else
     1757    {
     1758      // Only adjust QP when not lossless
     1759      if (!(( getMaxDeltaQP() == 0 ) && (!getLumaLevelToDeltaQPMapping().isEnabled()) && (qp == -lumaQpBDOffset ) && (pSlice->getPPS()->getTransquantBypassEnabledFlag())))
     1760      {
     1761        const GOPEntry &gopEntry=getGOPEntry(gopIndex);
     1762        // adjust QP according to the QP offset for the GOP entry.
     1763        qp +=gopEntry.m_QPOffset;
     1764
     1765        // adjust QP according to QPOffsetModel for the GOP entry.
     1766        Double dqpOffset=qp*gopEntry.m_QPOffsetModelScale+gopEntry.m_QPOffsetModelOffset+0.5;
     1767        Int qpOffset = (Int)floor(Clip3<Double>(0.0, 3.0, dqpOffset));
     1768        qp += qpOffset ;
     1769      }
     1770    }
     1771
     1772#if !JVET_G0101_QP_SWITCHING
     1773    // modify QP if a fractional QP was originally specified, cause dQPs to be 0 or 1.
     1774    const Int* pdQPs = getdQPs();
     1775    if ( pdQPs )
     1776    {
     1777      qp += pdQPs[ pSlice->getPOC() ];
     1778    }
     1779#endif
     1780  }
     1781  qp = Clip3( -lumaQpBDOffset, MAX_QP, qp );
     1782  return qp;
     1783}
     1784#endif
     1785
     1786
    15591787#if NH_MV
    15601788Int TEncTop::getFrameId(Int iGOPid) 
     
    15831811  }
    15841812  return pcPic;
     1813}
     1814
     1815
     1816Int TEncTop::xGetPsIdAndPsLayerId( )
     1817{
     1818  // LayerId of the parameter set and the Parameter set id are always equal in HTM
     1819  return ( m_sendParameterSets ?  ( getLayerId() == 0 ?  0 : 1 )  : getLayerId() );
    15851820}
    15861821
     
    17001935  }
    17011936}
    1702 #endif
     1937
     1938
     1939#endif
     1940
    17031941
    17041942//! \}
Note: See TracChangeset for help on using the changeset viewer.