Changeset 1313 in 3DVCSoftware for trunk/source/App/TAppEncoder/TAppEncTop.cpp


Ignore:
Timestamp:
13 Aug 2015, 17:38:13 (9 years ago)
Author:
tech
Message:

Merged 14.1-update-dev1@1312.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r1196 r1313  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4242#include <fcntl.h>
    4343#include <assert.h>
     44#include <iomanip>
    4445
    4546#include "TAppEncTop.h"
     
    5859{
    5960
    60 #if H_MV
     61#if NH_MV
    6162  m_vps = new TComVPS;
    6263#else
     
    6970TAppEncTop::~TAppEncTop()
    7071{
    71 #if H_MV
     72#if NH_MV
    7273  if (m_vps)
    7374  {
     
    8081Void TAppEncTop::xInitLibCfg()
    8182{
    82 #if H_MV
     83#if NH_MV
    8384  TComVPS& vps = (*m_vps);   
    8485#else
     
    8687#endif
    8788 
    88 #if H_3D
    89   vps.createCamPars(m_iNumberOfViews);
    90   TComDLT& dlt = m_dlt;
    91 #endif
    92 
    93 #if H_MV
     89#if NH_3D
     90  vps.createCamPars(m_iNumberOfViews); 
     91#endif
     92
     93#if NH_3D_DLT
     94  TComDLT dlt = TComDLT();
     95#endif
     96
     97#if NH_MV
    9498  Int maxTempLayer = -1;
    9599  for (Int j = 0; j < m_numberOfLayers; j++)
     
    118122  }
    119123#else
    120   vps.setMaxTLayers                       ( m_maxTempLayer );
     124  vps.setMaxTLayers                                               ( m_maxTempLayer );
    121125  if (m_maxTempLayer == 1)
    122126  {
    123127    vps.setTemporalNestingFlag(true);
    124128  }
    125   vps.setMaxLayers                        ( 1 );
     129  vps.setMaxLayers                                                ( 1 );
    126130  for(Int i = 0; i < MAX_TLAYER; i++)
    127131  {
    128     vps.setNumReorderPics                 ( m_numReorderPics[i], i );
    129     vps.setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
    130   }
    131 #endif
    132 #if H_MV
     132    vps.setNumReorderPics                                         ( m_numReorderPics[i], i );
     133    vps.setMaxDecPicBuffering                                     ( m_maxDecPicBuffering[i], i );
     134  }
     135#endif
     136#if NH_MV
     137  xSetTimingInfo           ( vps );
     138  xSetHrdParameters        ( vps );
    133139  xSetLayerIds             ( vps );   
    134140  xSetDimensionIdAndLength ( vps );
     
    139145  xSetDpbSize              ( vps );
    140146  xSetVPSVUI               ( vps );
    141 #if H_3D
     147#if NH_3D
    142148  xSetCamPara              ( vps );
    143149  m_ivPicLists.setVPS      ( &vps );
    144   xDeriveDltArray          ( vps, dlt );
     150#endif
     151#if NH_3D_DLT
     152  xDeriveDltArray          ( vps, &dlt );
    145153#endif
    146154  if ( m_targetEncLayerIdList.size() == 0 )
     
    174182  }
    175183
    176 #if H_3D
     184#if NH_3D
    177185  // Set 3d tool parameters
    178 
    179186  for (Int d = 0; d < 2; d++)
    180187  { 
     
    201208  }
    202209#endif
     210
     211
     212  /// Create encoders and set profiles profiles
    203213  for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++)
    204214  {
     
    207217    m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
    208218    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
    209     m_picYuvRec                 .push_back(new TComList<TComPicYuv*>) ;
     219#if NH_3D   
     220    Int profileIdc = -1;
     221    for (Int olsIdx = 0; olsIdx < vps.getNumOutputLayerSets(); olsIdx++ )
     222    {   
     223      Int lsIdx = vps.olsIdxToLsIdx( olsIdx );
     224      for(Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++ )
     225      {
     226        if( vps.getLayerIdInNuh( layerIdInVps) == vps.getLayerSetLayerIdList(lsIdx, i) )
     227        {
     228          Int ptlIdx = vps.getProfileTierLevelIdx( olsIdx, i );
     229          if ( ptlIdx != -1 )
     230          {
     231            Int curProfileIdc = vps.getPTL(ptlIdx)->getGeneralPTL()->getProfileIdc();
     232            if (profileIdc == -1)   
     233            {
     234              profileIdc = curProfileIdc;
     235            }
     236            else
     237            {   
     238              if ( profileIdc != curProfileIdc )
     239              {             
     240                fprintf(stderr, "Error: ProfileIdc for layer with index %d in VPS not equal in all OLSs. \n", layerIdInVps );
     241                exit(EXIT_FAILURE);
     242              }
     243            }
     244          }
     245        }
     246      }
     247    }
     248
     249    if (profileIdc == -1 )
     250    {
     251      fprintf(stderr, "Error: No profile given for layer with index %d in VPS not equal in all OLS. \n", layerIdInVps );
     252      exit(EXIT_FAILURE);
     253    }
     254    m_acTEncTopList[ layerIdInVps ]->setProfileIdc( profileIdc );
     255#endif
     256  }
     257
     258
     259  for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++)
     260  {
     261    m_cListPicYuvRec            .push_back(new TComList<TComPicYuv*>) ;
    210262    m_ivPicLists.push_back( m_acTEncTopList[ layerIdInVps ]->getListPic()  );
    211263    TEncTop& m_cTEncTop = *m_acTEncTopList[ layerIdInVps ];  // It is not a member, but this name helps avoiding code duplication !!!
     
    216268    m_cTEncTop.setViewId                       ( vps.getViewId      (  layerId ) );
    217269    m_cTEncTop.setViewIndex                    ( vps.getViewIndex   (  layerId ) );
    218 #if H_3D
     270#if NH_3D
    219271    Bool isDepth = ( vps.getDepthId     ( layerId ) != 0 ) ;
    220272    m_cTEncTop.setIsDepth                      ( isDepth );
    221273    //====== Camera Parameters =========
    222274    m_cTEncTop.setCameraParameters             ( &m_cCameraData );     
    223 #if H_3D_VSO
     275#if NH_3D_VSO
    224276    //====== VSO =========
    225277    m_cTEncTop.setRenderModelParameters        ( &m_cRenModStrParser );
     
    239291    m_cTEncTop.setDWeight                      ( isDepth ? m_iDWeight             : 0     );
    240292#endif // H_3D_VSO
    241 #if H_3D_IC
     293#if NH_3D_IC
    242294    m_cTEncTop.setUseIC                        ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_abUseIC );
    243295    m_cTEncTop.setUseICLowLatencyEnc           ( m_bUseLowLatencyICEnc );
     
    249301    m_cTEncTop.setUseDLT                       ( isDepth ? m_useDLT   : false );
    250302    m_cTEncTop.setUseQTL                       ( isDepth ? m_bUseQTL  : false );
    251 
    252 
    253   m_cTEncTop.setSps3dExtension                 ( m_sps3dExtension );
    254 #endif // H_3D
     303    m_cTEncTop.setSps3dExtension               ( m_sps3dExtension );
     304#endif // NH_3D
    255305
    256306    m_cTEncTop.setIvPicLists                   ( &m_ivPicLists );
    257 #endif  // H_MV
     307#endif  // NH_MV
    258308  m_cTEncTop.setVPS(&vps);
    259309
    260 #if H_3D
    261   m_cTEncTop.setDLT(&dlt);
    262 #endif
    263 
    264 #if H_MV
    265   m_cTEncTop.setProfile(m_profile[0]);
    266   m_cTEncTop.setLevel  (m_levelTier[0], m_level[0]);
    267 #else
    268   m_cTEncTop.setProfile(m_profile);
    269   m_cTEncTop.setLevel(m_levelTier, m_level);
    270 #endif
    271   m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag);
    272   m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag);
    273   m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
    274   m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
    275  
    276   m_cTEncTop.setFrameRate                    ( m_iFrameRate );
    277   m_cTEncTop.setFrameSkip                    ( m_FrameSkip );
    278   m_cTEncTop.setSourceWidth                  ( m_iSourceWidth );
    279   m_cTEncTop.setSourceHeight                 ( m_iSourceHeight );
    280   m_cTEncTop.setConformanceWindow            ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
    281   m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
    282  
     310#if NH_3D_DLT
     311  m_cTEncTop.setDLT(dlt);
     312#endif
     313
     314#if NH_MV
     315  m_cTEncTop.setProfile                                           ( m_profiles[0]);
     316  m_cTEncTop.setLevel                                             ( m_levelTier[0], m_level[0] );
     317#else
     318  m_cTEncTop.setProfile                                           ( m_profile);
     319  m_cTEncTop.setLevel                                             ( m_levelTier, m_level);
     320#endif
     321  m_cTEncTop.setProgressiveSourceFlag                             ( m_progressiveSourceFlag);
     322  m_cTEncTop.setInterlacedSourceFlag                              ( m_interlacedSourceFlag);
     323  m_cTEncTop.setNonPackedConstraintFlag                           ( m_nonPackedConstraintFlag);
     324  m_cTEncTop.setFrameOnlyConstraintFlag                           ( m_frameOnlyConstraintFlag);
     325  m_cTEncTop.setBitDepthConstraintValue                           ( m_bitDepthConstraint );
     326  m_cTEncTop.setChromaFormatConstraintValue                       ( m_chromaFormatConstraint );
     327  m_cTEncTop.setIntraConstraintFlag                               ( m_intraConstraintFlag );
     328  m_cTEncTop.setOnePictureOnlyConstraintFlag                      ( m_onePictureOnlyConstraintFlag );
     329  m_cTEncTop.setLowerBitRateConstraintFlag                        ( m_lowerBitRateConstraintFlag );
     330
     331  m_cTEncTop.setPrintMSEBasedSequencePSNR                         ( m_printMSEBasedSequencePSNR);
     332  m_cTEncTop.setPrintFrameMSE                                     ( m_printFrameMSE);
     333  m_cTEncTop.setPrintSequenceMSE                                  ( m_printSequenceMSE);
     334  m_cTEncTop.setCabacZeroWordPaddingEnabled                       ( m_cabacZeroWordPaddingEnabled );
     335
     336  m_cTEncTop.setFrameRate                                         ( m_iFrameRate );
     337  m_cTEncTop.setFrameSkip                                         ( m_FrameSkip );
     338  m_cTEncTop.setSourceWidth                                       ( m_iSourceWidth );
     339  m_cTEncTop.setSourceHeight                                      ( m_iSourceHeight );
     340  m_cTEncTop.setConformanceWindow                                 ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
     341  m_cTEncTop.setFramesToBeEncoded                                 ( m_framesToBeEncoded );
     342
    283343  //====== Coding Structure ========
    284 #if H_MV
    285   m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod[ layerIdInVps ] );
    286 #else
    287   m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod );
    288 #endif
    289   m_cTEncTop.setDecodingRefreshType          ( m_iDecodingRefreshType );
    290   m_cTEncTop.setGOPSize                      ( m_iGOPSize );
    291 #if H_MV
    292 m_cTEncTop.setGopList                      ( m_GOPListMvc[layerIdInVps] );
    293   m_cTEncTop.setExtraRPSs                    ( m_extraRPSsMvc[layerIdInVps] );
     344#if NH_MV
     345  m_cTEncTop.setIntraPeriod                                       ( m_iIntraPeriod[ layerIdInVps ] );
     346#else
     347  m_cTEncTop.setIntraPeriod                                       ( m_iIntraPeriod );
     348#endif
     349  m_cTEncTop.setDecodingRefreshType                               ( m_iDecodingRefreshType );
     350  m_cTEncTop.setGOPSize                                           ( m_iGOPSize );
     351#if NH_MV
     352  m_cTEncTop.setGopList                                           ( m_GOPListMvc[layerIdInVps] );
     353  m_cTEncTop.setExtraRPSs                                         ( m_extraRPSsMvc[layerIdInVps] );
    294354  for(Int i = 0; i < MAX_TLAYER; i++)
    295355  {
    296     m_cTEncTop.setNumReorderPics             ( m_numReorderPicsMvc[layerIdInVps][i], i );
    297     m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBufferingMvc[layerIdInVps][i], i );
    298   }
    299 #else
    300   m_cTEncTop.setGopList                      ( m_GOPList );
    301   m_cTEncTop.setExtraRPSs                    ( m_extraRPSs );
     356    m_cTEncTop.setNumReorderPics                                  ( m_numReorderPicsMvc[layerIdInVps][i], i );
     357    m_cTEncTop.setMaxDecPicBuffering                              ( m_maxDecPicBufferingMvc[layerIdInVps][i], i );
     358  }
     359#else
     360  m_cTEncTop.setGopList                                           ( m_GOPList );
     361  m_cTEncTop.setExtraRPSs                                         ( m_extraRPSs );
    302362  for(Int i = 0; i < MAX_TLAYER; i++)
    303363  {
    304     m_cTEncTop.setNumReorderPics             ( m_numReorderPics[i], i );
    305     m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBuffering[i], i );
     364    m_cTEncTop.setNumReorderPics                                  ( m_numReorderPics[i], i );
     365    m_cTEncTop.setMaxDecPicBuffering                              ( m_maxDecPicBuffering[i], i );
    306366  }
    307367#endif
    308368  for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
    309369  {
    310     m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
    311   }
    312 #if H_MV
    313   m_cTEncTop.setQP                           ( m_iQP[layerIdInVps] );
    314 #else
    315   m_cTEncTop.setQP                           ( m_iQP );
    316 #endif
    317 
    318   m_cTEncTop.setPad                          ( m_aiPad );
    319 
    320 #if H_MV
    321   m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayerMvc[layerIdInVps] );
    322 #else
    323   m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayer );
     370    m_cTEncTop.setLambdaModifier                                  ( uiLoop, m_adLambdaModifier[ uiLoop ] );
     371  }
     372#if NH_MV
     373  m_cTEncTop.setQP                                                ( m_iQP[layerIdInVps] );
     374#else
     375  m_cTEncTop.setQP                                                ( m_iQP );
     376#endif
     377
     378  m_cTEncTop.setPad                                               ( m_aiPad );
     379
     380#if NH_MV
     381  m_cTEncTop.setMaxTempLayer                                      ( m_maxTempLayerMvc[layerIdInVps] );
     382#else
     383  m_cTEncTop.setMaxTempLayer                                      ( m_maxTempLayer );
    324384#endif
    325385  m_cTEncTop.setUseAMP( m_enableAMP );
    326  
     386
    327387  //===== Slice ========
    328  
     388
    329389  //====== Loop/Deblock Filter ========
    330 #if H_MV
    331   m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable[layerIdInVps]);
    332 #else
    333   m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable       );
    334 #endif
    335   m_cTEncTop.setLoopFilterOffsetInPPS        ( m_loopFilterOffsetInPPS );
    336   m_cTEncTop.setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
    337   m_cTEncTop.setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
    338   m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
    339   m_cTEncTop.setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
     390#if NH_MV
     391  m_cTEncTop.setLoopFilterDisable                                 ( m_bLoopFilterDisable[layerIdInVps]);
     392#else
     393  m_cTEncTop.setLoopFilterDisable                                 ( m_bLoopFilterDisable       );
     394#endif
     395  m_cTEncTop.setLoopFilterOffsetInPPS                             ( m_loopFilterOffsetInPPS );
     396  m_cTEncTop.setLoopFilterBetaOffset                              ( m_loopFilterBetaOffsetDiv2  );
     397  m_cTEncTop.setLoopFilterTcOffset                                ( m_loopFilterTcOffsetDiv2    );
     398  m_cTEncTop.setDeblockingFilterMetric                            ( m_DeblockingFilterMetric );
    340399
    341400  //====== Motion search ========
    342   m_cTEncTop.setFastSearch                   ( m_iFastSearch  );
    343   m_cTEncTop.setSearchRange                  ( m_iSearchRange );
    344   m_cTEncTop.setBipredSearchRange            ( m_bipredSearchRange );
    345 
    346 #if H_MV
    347   m_cTEncTop.setUseDisparitySearchRangeRestriction ( m_bUseDisparitySearchRangeRestriction );
    348   m_cTEncTop.setVerticalDisparitySearchRange ( m_iVerticalDisparitySearchRange );
     401  m_cTEncTop.setDisableIntraPUsInInterSlices                      ( m_bDisableIntraPUsInInterSlices );
     402  m_cTEncTop.setFastSearch                                        ( m_iFastSearch  );
     403  m_cTEncTop.setSearchRange                                       ( m_iSearchRange );
     404  m_cTEncTop.setBipredSearchRange                                 ( m_bipredSearchRange );
     405  m_cTEncTop.setClipForBiPredMeEnabled                            ( m_bClipForBiPredMeEnabled );
     406  m_cTEncTop.setFastMEAssumingSmootherMVEnabled                   ( m_bFastMEAssumingSmootherMVEnabled );
     407
     408#if NH_MV
     409  m_cTEncTop.setUseDisparitySearchRangeRestriction                ( m_bUseDisparitySearchRangeRestriction );
     410  m_cTEncTop.setVerticalDisparitySearchRange                      ( m_iVerticalDisparitySearchRange );
    349411#endif
    350412  //====== Quality control ========
    351   m_cTEncTop.setMaxDeltaQP                   ( m_iMaxDeltaQP  );
    352   m_cTEncTop.setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
    353 
    354   m_cTEncTop.setChromaCbQpOffset               ( m_cbQpOffset     );
    355   m_cTEncTop.setChromaCrQpOffset            ( m_crQpOffset  );
     413  m_cTEncTop.setMaxDeltaQP                                        ( m_iMaxDeltaQP  );
     414  m_cTEncTop.setMaxCuDQPDepth                                     ( m_iMaxCuDQPDepth  );
     415  m_cTEncTop.setDiffCuChromaQpOffsetDepth                         ( m_diffCuChromaQpOffsetDepth );
     416  m_cTEncTop.setChromaCbQpOffset                                  ( m_cbQpOffset     );
     417  m_cTEncTop.setChromaCrQpOffset                                  ( m_crQpOffset  );
     418
     419#if NH_3D
     420  m_cTEncTop.setChromaFormatIdc                                   ( isDepth ? CHROMA_400 : m_chromaFormatIDC );
     421#else
     422  m_cTEncTop.setChromaFormatIdc                                   ( m_chromaFormatIDC  );
     423#endif
    356424
    357425#if ADAPTIVE_QP_SELECTION
    358   m_cTEncTop.setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
    359 #endif
    360 
    361   m_cTEncTop.setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
    362   m_cTEncTop.setQPAdaptationRange            ( m_iQPAdaptationRange );
    363  
     426  m_cTEncTop.setUseAdaptQpSelect                                  ( m_bUseAdaptQpSelect   );
     427#endif
     428
     429  m_cTEncTop.setUseAdaptiveQP                                     ( m_bUseAdaptiveQP  );
     430  m_cTEncTop.setQPAdaptationRange                                 ( m_iQPAdaptationRange );
     431  m_cTEncTop.setExtendedPrecisionProcessingFlag                   ( m_extendedPrecisionProcessingFlag );
     432  m_cTEncTop.setHighPrecisionOffsetsEnabledFlag                   ( m_highPrecisionOffsetsEnabledFlag );
    364433  //====== Tool list ========
    365   m_cTEncTop.setDeltaQpRD                    ( m_uiDeltaQpRD  );
    366   m_cTEncTop.setUseASR                       ( m_bUseASR      );
    367   m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
    368 #if H_MV
    369   m_cTEncTop.setdQPs                         ( m_aidQP[layerIdInVps]   );
    370 #else
    371   m_cTEncTop.setdQPs                         ( m_aidQP        );
    372 #endif
    373   m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
    374   m_cTEncTop.setUseRDOQTS                    ( m_useRDOQTS   );
    375   m_cTEncTop.setRDpenalty                 ( m_rdPenalty );
    376   m_cTEncTop.setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
    377   m_cTEncTop.setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
    378   m_cTEncTop.setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
    379   m_cTEncTop.setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
    380   m_cTEncTop.setUseFastEnc                   ( m_bUseFastEnc  );
    381   m_cTEncTop.setUseEarlyCU                   ( m_bUseEarlyCU  );
    382   m_cTEncTop.setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
    383   m_cTEncTop.setUseCbfFastMode            ( m_bUseCbfFastMode  );
    384   m_cTEncTop.setUseEarlySkipDetection            ( m_useEarlySkipDetection );
    385 
    386   m_cTEncTop.setUseTransformSkip             ( m_useTransformSkip      );
    387   m_cTEncTop.setUseTransformSkipFast         ( m_useTransformSkipFast  );
    388   m_cTEncTop.setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
    389   m_cTEncTop.setPCMLog2MinSize          ( m_uiPCMLog2MinSize);
    390   m_cTEncTop.setUsePCM                       ( m_usePCM );
    391   m_cTEncTop.setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
    392   m_cTEncTop.setMaxNumMergeCand              ( m_maxNumMergeCand );
    393  
     434  m_cTEncTop.setDeltaQpRD                                         ( m_uiDeltaQpRD  );
     435  m_cTEncTop.setFastDeltaQp                                       ( m_bFastDeltaQP  );
     436  m_cTEncTop.setUseASR                                            ( m_bUseASR      );
     437  m_cTEncTop.setUseHADME                                          ( m_bUseHADME    );
     438#if NH_MV
     439  m_cTEncTop.setdQPs                                              ( m_aidQP[layerIdInVps]   );
     440#else
     441  m_cTEncTop.setdQPs                                              ( m_aidQP        );
     442#endif
     443  m_cTEncTop.setUseRDOQ                                           ( m_useRDOQ     );
     444  m_cTEncTop.setUseRDOQTS                                         ( m_useRDOQTS   );
     445#if T0196_SELECTIVE_RDOQ
     446  m_cTEncTop.setUseSelectiveRDOQ                                  ( m_useSelectiveRDOQ );
     447#endif
     448  m_cTEncTop.setRDpenalty                                         ( m_rdPenalty );
     449  m_cTEncTop.setMaxCUWidth                                        ( m_uiMaxCUWidth );
     450  m_cTEncTop.setMaxCUHeight                                       ( m_uiMaxCUHeight );
     451  m_cTEncTop.setMaxTotalCUDepth                                   ( m_uiMaxTotalCUDepth );
     452  m_cTEncTop.setLog2DiffMaxMinCodingBlockSize                     ( m_uiLog2DiffMaxMinCodingBlockSize );
     453  m_cTEncTop.setQuadtreeTULog2MaxSize                             ( m_uiQuadtreeTULog2MaxSize );
     454  m_cTEncTop.setQuadtreeTULog2MinSize                             ( m_uiQuadtreeTULog2MinSize );
     455  m_cTEncTop.setQuadtreeTUMaxDepthInter                           ( m_uiQuadtreeTUMaxDepthInter );
     456  m_cTEncTop.setQuadtreeTUMaxDepthIntra                           ( m_uiQuadtreeTUMaxDepthIntra );
     457  m_cTEncTop.setUseFastEnc                                        ( m_bUseFastEnc  );
     458  m_cTEncTop.setUseEarlyCU                                        ( m_bUseEarlyCU  );
     459  m_cTEncTop.setUseFastDecisionForMerge                           ( m_useFastDecisionForMerge  );
     460  m_cTEncTop.setUseCbfFastMode                                    ( m_bUseCbfFastMode  );
     461  m_cTEncTop.setUseEarlySkipDetection                             ( m_useEarlySkipDetection );
     462  m_cTEncTop.setCrossComponentPredictionEnabledFlag               ( m_crossComponentPredictionEnabledFlag );
     463  m_cTEncTop.setUseReconBasedCrossCPredictionEstimate             ( m_reconBasedCrossCPredictionEstimate );
     464#if NH_MV
     465  m_cTEncTop.setLog2SaoOffsetScale                                ( CHANNEL_TYPE_LUMA  , m_log2SaoOffsetScale[layerIdInVps][CHANNEL_TYPE_LUMA]   );
     466  m_cTEncTop.setLog2SaoOffsetScale                                ( CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[layerIdInVps][CHANNEL_TYPE_CHROMA] );
     467#else
     468  m_cTEncTop.setLog2SaoOffsetScale                                ( CHANNEL_TYPE_LUMA  , m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA]   );
     469  m_cTEncTop.setLog2SaoOffsetScale                                ( CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] );
     470#endif
     471  m_cTEncTop.setUseTransformSkip                                  ( m_useTransformSkip      );
     472  m_cTEncTop.setUseTransformSkipFast                              ( m_useTransformSkipFast  );
     473  m_cTEncTop.setTransformSkipRotationEnabledFlag                  ( m_transformSkipRotationEnabledFlag );
     474  m_cTEncTop.setTransformSkipContextEnabledFlag                   ( m_transformSkipContextEnabledFlag   );
     475  m_cTEncTop.setPersistentRiceAdaptationEnabledFlag               ( m_persistentRiceAdaptationEnabledFlag );
     476  m_cTEncTop.setCabacBypassAlignmentEnabledFlag                   ( m_cabacBypassAlignmentEnabledFlag );
     477  m_cTEncTop.setLog2MaxTransformSkipBlockSize                     ( m_log2MaxTransformSkipBlockSize  );
     478  for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++)
     479  {
     480    m_cTEncTop.setRdpcmEnabledFlag                                ( RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]);
     481  }
     482  m_cTEncTop.setUseConstrainedIntraPred                           ( m_bUseConstrainedIntraPred );
     483  m_cTEncTop.setFastUDIUseMPMEnabled                              ( m_bFastUDIUseMPMEnabled );
     484  m_cTEncTop.setFastMEForGenBLowDelayEnabled                      ( m_bFastMEForGenBLowDelayEnabled );
     485  m_cTEncTop.setUseBLambdaForNonKeyLowDelayPictures               ( m_bUseBLambdaForNonKeyLowDelayPictures );
     486  m_cTEncTop.setPCMLog2MinSize                                    ( m_uiPCMLog2MinSize);
     487  m_cTEncTop.setUsePCM                                            ( m_usePCM );
     488
     489  // set internal bit-depth and constants
     490  for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
     491  {
     492    m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepth[channelType]);
     493    m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType]);
     494  }
     495
     496  m_cTEncTop.setPCMLog2MaxSize                                    ( m_pcmLog2MaxSize);
     497  m_cTEncTop.setMaxNumMergeCand                                   ( m_maxNumMergeCand );
     498
    394499
    395500  //====== Weighted Prediction ========
    396   m_cTEncTop.setUseWP                   ( m_useWeightedPred      );
    397   m_cTEncTop.setWPBiPred                ( m_useWeightedBiPred   );
     501  m_cTEncTop.setUseWP                                             ( m_useWeightedPred      );
     502  m_cTEncTop.setWPBiPred                                          ( m_useWeightedBiPred   );
    398503  //====== Parallel Merge Estimation ========
    399   m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 );
     504  m_cTEncTop.setLog2ParallelMergeLevelMinus2                      ( m_log2ParallelMergeLevel - 2 );
    400505
    401506  //====== Slice ========
    402   m_cTEncTop.setSliceMode               ( m_sliceMode                );
    403   m_cTEncTop.setSliceArgument           ( m_sliceArgument            );
     507  m_cTEncTop.setSliceMode                                         ( (SliceConstraint) m_sliceMode );
     508  m_cTEncTop.setSliceArgument                                     ( m_sliceArgument            );
    404509
    405510  //====== Dependent Slice ========
    406   m_cTEncTop.setSliceSegmentMode        ( m_sliceSegmentMode         );
    407   m_cTEncTop.setSliceSegmentArgument    ( m_sliceSegmentArgument     );
    408   Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
    409   if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
    410   {
    411     m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU );
    412   }
    413   if(m_sliceMode==FIXED_NUMBER_OF_LCU)
    414   {
    415     m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU );
    416   }
    417   if(m_sliceMode==FIXED_NUMBER_OF_TILES)
    418   {
    419     m_cTEncTop.setSliceArgument ( m_sliceArgument );
    420   }
    421  
    422   if(m_sliceMode == 0 )
     511  m_cTEncTop.setSliceSegmentMode                                  (  (SliceConstraint) m_sliceSegmentMode );
     512  m_cTEncTop.setSliceSegmentArgument                              ( m_sliceSegmentArgument     );
     513
     514  if(m_sliceMode == NO_SLICES )
    423515  {
    424516    m_bLFCrossSliceBoundaryFlag = true;
    425517  }
    426   m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
    427 #if H_MV
     518  m_cTEncTop.setLFCrossSliceBoundaryFlag                          ( m_bLFCrossSliceBoundaryFlag );
     519#if NH_MV
    428520  m_cTEncTop.setUseSAO ( m_bUseSAO[layerIdInVps] );
    429521#else
    430   m_cTEncTop.setUseSAO ( m_bUseSAO );
    431 #endif
    432   m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
    433 
    434   m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary);
    435   m_cTEncTop.setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
    436   m_cTEncTop.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
    437 
    438   m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
    439   m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
    440   m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
    441   m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
    442   m_cTEncTop.setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
    443   m_cTEncTop.setTMISEIToneMapId                           ( m_toneMapId );
    444   m_cTEncTop.setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
    445   m_cTEncTop.setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
    446   m_cTEncTop.setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
    447   m_cTEncTop.setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
    448   m_cTEncTop.setTMISEIModelID                             ( m_toneMapModelId );
    449   m_cTEncTop.setTMISEIMinValue                            ( m_toneMapMinValue );
    450   m_cTEncTop.setTMISEIMaxValue                            ( m_toneMapMaxValue );
    451   m_cTEncTop.setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
    452   m_cTEncTop.setTMISEISigmoidWidth                        ( m_sigmoidWidth );
    453   m_cTEncTop.setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
    454   m_cTEncTop.setTMISEINumPivots                           ( m_numPivots );
    455   m_cTEncTop.setTMISEICodedPivotValue                     ( m_codedPivotValue );
    456   m_cTEncTop.setTMISEITargetPivotValue                    ( m_targetPivotValue );
    457   m_cTEncTop.setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
    458   m_cTEncTop.setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
    459   m_cTEncTop.setTMISEIExposureIndexIdc                    ( m_exposureIndexIdc );
    460   m_cTEncTop.setTMISEIExposureIndexValue                  ( m_exposureIndexValue );
    461   m_cTEncTop.setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
    462   m_cTEncTop.setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
    463   m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
    464   m_cTEncTop.setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
    465   m_cTEncTop.setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
    466   m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
    467   m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
    468   m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
    469   m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
    470   m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
    471   m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId );
    472   m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx );
    473   m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation );
    474   m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle );
    475   m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled );
    476   m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
    477   m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
    478   m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
    479   m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
    480 #if H_MV
    481   m_cTEncTop.setSubBitstreamPropSEIEnabled( m_subBistreamPropSEIEnabled );
    482   if( m_subBistreamPropSEIEnabled )
    483   {
    484     m_cTEncTop.setNumAdditionalSubStreams ( m_sbPropNumAdditionalSubStreams );
    485     m_cTEncTop.setSubBitstreamMode        ( m_sbPropSubBitstreamMode );
    486     m_cTEncTop.setOutputLayerSetIdxToVps  ( m_sbPropOutputLayerSetIdxToVps );
    487     m_cTEncTop.setHighestSublayerId       ( m_sbPropHighestSublayerId );
    488     m_cTEncTop.setAvgBitRate              ( m_sbPropAvgBitRate );
    489     m_cTEncTop.setMaxBitRate              ( m_sbPropMaxBitRate );
    490   }
    491 #endif
    492   m_cTEncTop.setTileUniformSpacingFlag     ( m_tileUniformSpacingFlag );
    493   m_cTEncTop.setNumColumnsMinus1           ( m_numTileColumnsMinus1 );
    494   m_cTEncTop.setNumRowsMinus1              ( m_numTileRowsMinus1 );
     522  m_cTEncTop.setUseSAO                                            ( m_bUseSAO );
     523#endif
     524  m_cTEncTop.setTestSAODisableAtPictureLevel                      ( m_bTestSAODisableAtPictureLevel );
     525  m_cTEncTop.setSaoEncodingRate                                   ( m_saoEncodingRate );
     526  m_cTEncTop.setSaoEncodingRateChroma                             ( m_saoEncodingRateChroma );
     527  m_cTEncTop.setMaxNumOffsetsPerPic                               ( m_maxNumOffsetsPerPic);
     528
     529  m_cTEncTop.setSaoCtuBoundary                                    ( m_saoCtuBoundary);
     530  m_cTEncTop.setPCMInputBitDepthFlag                              ( m_bPCMInputBitDepthFlag);
     531  m_cTEncTop.setPCMFilterDisableFlag                              ( m_bPCMFilterDisableFlag);
     532
     533  m_cTEncTop.setIntraSmoothingDisabledFlag                        (!m_enableIntraReferenceSmoothing );
     534  m_cTEncTop.setDecodedPictureHashSEIEnabled                      ( m_decodedPictureHashSEIEnabled );
     535  m_cTEncTop.setRecoveryPointSEIEnabled                           ( m_recoveryPointSEIEnabled );
     536  m_cTEncTop.setBufferingPeriodSEIEnabled                         ( m_bufferingPeriodSEIEnabled );
     537  m_cTEncTop.setPictureTimingSEIEnabled                           ( m_pictureTimingSEIEnabled );
     538  m_cTEncTop.setToneMappingInfoSEIEnabled                         ( m_toneMappingInfoSEIEnabled );
     539  m_cTEncTop.setTMISEIToneMapId                                   ( m_toneMapId );
     540  m_cTEncTop.setTMISEIToneMapCancelFlag                           ( m_toneMapCancelFlag );
     541  m_cTEncTop.setTMISEIToneMapPersistenceFlag                      ( m_toneMapPersistenceFlag );
     542  m_cTEncTop.setTMISEICodedDataBitDepth                           ( m_toneMapCodedDataBitDepth );
     543  m_cTEncTop.setTMISEITargetBitDepth                              ( m_toneMapTargetBitDepth );
     544  m_cTEncTop.setTMISEIModelID                                     ( m_toneMapModelId );
     545  m_cTEncTop.setTMISEIMinValue                                    ( m_toneMapMinValue );
     546  m_cTEncTop.setTMISEIMaxValue                                    ( m_toneMapMaxValue );
     547  m_cTEncTop.setTMISEISigmoidMidpoint                             ( m_sigmoidMidpoint );
     548  m_cTEncTop.setTMISEISigmoidWidth                                ( m_sigmoidWidth );
     549  m_cTEncTop.setTMISEIStartOfCodedInterva                         ( m_startOfCodedInterval );
     550  m_cTEncTop.setTMISEINumPivots                                   ( m_numPivots );
     551  m_cTEncTop.setTMISEICodedPivotValue                             ( m_codedPivotValue );
     552  m_cTEncTop.setTMISEITargetPivotValue                            ( m_targetPivotValue );
     553  m_cTEncTop.setTMISEICameraIsoSpeedIdc                           ( m_cameraIsoSpeedIdc );
     554  m_cTEncTop.setTMISEICameraIsoSpeedValue                         ( m_cameraIsoSpeedValue );
     555  m_cTEncTop.setTMISEIExposureIndexIdc                            ( m_exposureIndexIdc );
     556  m_cTEncTop.setTMISEIExposureIndexValue                          ( m_exposureIndexValue );
     557  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag           ( m_exposureCompensationValueSignFlag );
     558  m_cTEncTop.setTMISEIExposureCompensationValueNumerator          ( m_exposureCompensationValueNumerator );
     559  m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc           ( m_exposureCompensationValueDenomIdc );
     560  m_cTEncTop.setTMISEIRefScreenLuminanceWhite                     ( m_refScreenLuminanceWhite );
     561  m_cTEncTop.setTMISEIExtendedRangeWhiteLevel                     ( m_extendedRangeWhiteLevel );
     562  m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue              ( m_nominalBlackLevelLumaCodeValue );
     563  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue              ( m_nominalWhiteLevelLumaCodeValue );
     564  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue             ( m_extendedWhiteLevelLumaCodeValue );
     565  m_cTEncTop.setChromaSamplingFilterHintEnabled                   ( m_chromaSamplingFilterSEIenabled );
     566  m_cTEncTop.setChromaSamplingHorFilterIdc                        ( m_chromaSamplingHorFilterIdc );
     567  m_cTEncTop.setChromaSamplingVerFilterIdc                        ( m_chromaSamplingVerFilterIdc );
     568  m_cTEncTop.setFramePackingArrangementSEIEnabled                 ( m_framePackingSEIEnabled );
     569  m_cTEncTop.setFramePackingArrangementSEIType                    ( m_framePackingSEIType );
     570  m_cTEncTop.setFramePackingArrangementSEIId                      ( m_framePackingSEIId );
     571  m_cTEncTop.setFramePackingArrangementSEIQuincunx                ( m_framePackingSEIQuincunx );
     572  m_cTEncTop.setFramePackingArrangementSEIInterpretation          ( m_framePackingSEIInterpretation );
     573  m_cTEncTop.setSegmentedRectFramePackingArrangementSEIEnabled    ( m_segmentedRectFramePackingSEIEnabled );
     574  m_cTEncTop.setSegmentedRectFramePackingArrangementSEICancel     ( m_segmentedRectFramePackingSEICancel );
     575  m_cTEncTop.setSegmentedRectFramePackingArrangementSEIType       ( m_segmentedRectFramePackingSEIType );
     576  m_cTEncTop.setSegmentedRectFramePackingArrangementSEIPersistence( m_segmentedRectFramePackingSEIPersistence );
     577  m_cTEncTop.setDisplayOrientationSEIAngle                        ( m_displayOrientationSEIAngle );
     578  m_cTEncTop.setTemporalLevel0IndexSEIEnabled                     ( m_temporalLevel0IndexSEIEnabled );
     579  m_cTEncTop.setGradualDecodingRefreshInfoEnabled                 ( m_gradualDecodingRefreshInfoEnabled );
     580  m_cTEncTop.setNoDisplaySEITLayer                                ( m_noDisplaySEITLayer );
     581  m_cTEncTop.setDecodingUnitInfoSEIEnabled                        ( m_decodingUnitInfoSEIEnabled );
     582  m_cTEncTop.setSOPDescriptionSEIEnabled                          ( m_SOPDescriptionSEIEnabled );
     583  m_cTEncTop.setScalableNestingSEIEnabled                         ( m_scalableNestingSEIEnabled );
     584#if NH_MV
     585  m_cTEncTop.setSubBitstreamPropSEIEnabled                        ( m_subBistreamPropSEIEnabled );
     586  if( m_subBistreamPropSEIEnabled )                               
     587  {                                                               
     588    m_cTEncTop.setNumAdditionalSubStreams                         ( m_sbPropNumAdditionalSubStreams );
     589    m_cTEncTop.setSubBitstreamMode                                ( m_sbPropSubBitstreamMode );
     590    m_cTEncTop.setOutputLayerSetIdxToVps                          ( m_sbPropOutputLayerSetIdxToVps );
     591    m_cTEncTop.setHighestSublayerId                               ( m_sbPropHighestSublayerId );
     592    m_cTEncTop.setAvgBitRate                                      ( m_sbPropAvgBitRate );
     593    m_cTEncTop.setMaxBitRate                                      ( m_sbPropMaxBitRate );
     594  }
     595#endif
     596
     597  m_cTEncTop.setTMCTSSEIEnabled                                   ( m_tmctsSEIEnabled );
     598  m_cTEncTop.setTimeCodeSEIEnabled                                ( m_timeCodeSEIEnabled );
     599  m_cTEncTop.setNumberOfTimeSets                                  ( m_timeCodeSEINumTs );
     600  for(Int i = 0; i < m_timeCodeSEINumTs; i++)
     601  {
     602    m_cTEncTop.setTimeSet(m_timeSetArray[i], i);
     603  }
     604  m_cTEncTop.setKneeSEIEnabled                                    ( m_kneeSEIEnabled );
     605  m_cTEncTop.setKneeSEIId                                         ( m_kneeSEIId );
     606  m_cTEncTop.setKneeSEICancelFlag                                 ( m_kneeSEICancelFlag );
     607  m_cTEncTop.setKneeSEIPersistenceFlag                            ( m_kneeSEIPersistenceFlag );
     608  m_cTEncTop.setKneeSEIInputDrange                                ( m_kneeSEIInputDrange );
     609  m_cTEncTop.setKneeSEIInputDispLuminance                         ( m_kneeSEIInputDispLuminance );
     610  m_cTEncTop.setKneeSEIOutputDrange                               ( m_kneeSEIOutputDrange );
     611  m_cTEncTop.setKneeSEIOutputDispLuminance                        ( m_kneeSEIOutputDispLuminance );
     612  m_cTEncTop.setKneeSEINumKneePointsMinus1                        ( m_kneeSEINumKneePointsMinus1 );
     613  m_cTEncTop.setKneeSEIInputKneePoint                             ( m_kneeSEIInputKneePoint );
     614  m_cTEncTop.setKneeSEIOutputKneePoint                            ( m_kneeSEIOutputKneePoint );
     615  m_cTEncTop.setMasteringDisplaySEI                               ( m_masteringDisplay );
     616
     617  m_cTEncTop.setTileUniformSpacingFlag                            ( m_tileUniformSpacingFlag );
     618  m_cTEncTop.setNumColumnsMinus1                                  ( m_numTileColumnsMinus1 );
     619  m_cTEncTop.setNumRowsMinus1                                     ( m_numTileRowsMinus1 );
    495620  if(!m_tileUniformSpacingFlag)
    496621  {
    497     m_cTEncTop.setColumnWidth              ( m_tileColumnWidth );
    498     m_cTEncTop.setRowHeight                ( m_tileRowHeight );
     622    m_cTEncTop.setColumnWidth                                     ( m_tileColumnWidth );
     623    m_cTEncTop.setRowHeight                                       ( m_tileRowHeight );
    499624  }
    500625  m_cTEncTop.xCheckGSParameters();
    501   Int uiTilesCount          = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1);
     626  Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1);
    502627  if(uiTilesCount == 1)
    503628  {
    504     m_bLFCrossTileBoundaryFlag = true;
    505   }
    506   m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
    507   m_cTEncTop.setWaveFrontSynchro           ( m_iWaveFrontSynchro );
    508   m_cTEncTop.setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
    509   m_cTEncTop.setTMVPModeId ( m_TMVPModeId );
    510   m_cTEncTop.setUseScalingListId           ( m_useScalingListId  );
    511   m_cTEncTop.setScalingListFile            ( m_scalingListFile   );
    512   m_cTEncTop.setSignHideFlag(m_signHideFlag);
     629    m_bLFCrossTileBoundaryFlag = true;
     630  }
     631  m_cTEncTop.setLFCrossTileBoundaryFlag                           ( m_bLFCrossTileBoundaryFlag );
     632  m_cTEncTop.setWaveFrontSynchro                                  ( m_iWaveFrontSynchro );
     633  m_cTEncTop.setTMVPModeId                                        ( m_TMVPModeId );
     634  m_cTEncTop.setUseScalingListId                                  ( m_useScalingListId  );
     635  m_cTEncTop.setScalingListFile                                   ( m_scalingListFile   );
     636  m_cTEncTop.setSignHideFlag                                      ( m_signHideFlag);
    513637#if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
    514638  if(!m_cTEncTop.getIsDepth())    //only for texture
    515639  {
    516     m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
    517   }
    518   else
    519   {
    520     m_cTEncTop.setUseRateCtrl         ( 0 );
    521   }
    522 #else
    523     m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
     640    m_cTEncTop.setUseRateCtrl                                     ( m_RCEnableRateControl );
     641  }                                                         
     642  else                                                       
     643  {                                                         
     644    m_cTEncTop.setUseRateCtrl                                     ( 0 );
     645  }
     646#else
     647  m_cTEncTop.setUseRateCtrl                                       ( m_RCEnableRateControl );
    524648#endif
    525649#if !KWU_RC_VIEWRC_E0227
    526   m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
    527 #endif
    528   m_cTEncTop.setKeepHierBit         ( m_RCKeepHierarchicalBit );
    529   m_cTEncTop.setLCULevelRC          ( m_RCLCULevelRC );
    530   m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
    531   m_cTEncTop.setInitialQP           ( m_RCInitialQP );
    532   m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
     650  m_cTEncTop.setTargetBitrate                                     ( m_RCTargetBitrate );
     651#endif
     652  m_cTEncTop.setKeepHierBit                                       ( m_RCKeepHierarchicalBit );
     653  m_cTEncTop.setLCULevelRC                                        ( m_RCLCULevelRC );
     654  m_cTEncTop.setUseLCUSeparateModel                               ( m_RCUseLCUSeparateModel );
     655  m_cTEncTop.setInitialQP                                         ( m_RCInitialQP );
     656  m_cTEncTop.setForceIntraQP                                      ( m_RCForceIntraQP );
    533657#if KWU_RC_MADPRED_E0227
    534658  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
     
    598722  }
    599723#endif
    600   m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
    601   m_cTEncTop.setCUTransquantBypassFlagForceValue(m_CUTransquantBypassFlagForce);
    602   m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
    603   m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
    604   m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
    605   m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
    606   m_cTEncTop.setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag);
    607   m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc );
    608   m_cTEncTop.setSarWidth( m_sarWidth );
    609   m_cTEncTop.setSarHeight( m_sarHeight );
    610   m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag );
    611   m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag );
    612   m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag );
    613   m_cTEncTop.setVideoFormat( m_videoFormat );
    614   m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag );
    615   m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag );
    616   m_cTEncTop.setColourPrimaries( m_colourPrimaries );
    617   m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics );
    618   m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients );
    619   m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag );
    620   m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField );
    621   m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField );
    622   m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag );
    623   m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
    624   m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag );
    625   m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag );
    626   m_cTEncTop.setNumTicksPocDiffOneMinus1   ( m_numTicksPocDiffOneMinus1    );
    627   m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag );
    628   m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag );
    629   m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag );
    630   m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc );
    631   m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom );
    632   m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom );
    633   m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
    634   m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
    635 #if H_MV
    636   }
    637 #endif
    638 #if H_3D
    639  /// SET Profiles
    640   for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++)
    641   {
    642     Int profileIdc = -1;
    643     for (Int olsIdx = 0; olsIdx < vps.getNumOutputLayerSets(); olsIdx++ )
    644     {   
    645       Int lsIdx = vps.olsIdxToLsIdx( olsIdx );
    646       for(Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++ )
    647       {
    648         if( vps.getLayerIdInNuh( layerIdInVps) == vps.getLayerSetLayerIdList(lsIdx, i) )
    649         {
    650           Int ptlIdx = vps.getProfileTierLevelIdx( olsIdx, i );
    651           if ( ptlIdx != -1 )
    652           {
    653             Int curProfileIdc = vps.getPTL(ptlIdx)->getGeneralPTL()->getProfileIdc();
    654             if (profileIdc == -1)   
    655             {
    656               profileIdc = curProfileIdc;
    657             }
    658             else
    659             {   
    660               if ( profileIdc != curProfileIdc )
    661               {             
    662                 fprintf(stderr, "Error: ProfileIdc for layer with index %d in VPS not equal in all OLSs. \n", layerIdInVps );
    663                 exit(EXIT_FAILURE);
    664               }
    665             }
    666           }
    667         }
    668       }
    669     }
    670     if (profileIdc == -1 )
    671     {
    672       fprintf(stderr, "Error: No profile given for layer with index %d in VPS not equal in all OLS. \n", layerIdInVps );
    673       exit(EXIT_FAILURE);
    674     }
    675     m_acTEncTopList[ layerIdInVps ]->setProfileIdc( profileIdc );
    676   }
    677 #endif
    678 #if H_3D_VSO
     724  m_cTEncTop.setTransquantBypassEnableFlag                        ( m_TransquantBypassEnableFlag );
     725  m_cTEncTop.setCUTransquantBypassFlagForceValue                  ( m_CUTransquantBypassFlagForce );
     726  m_cTEncTop.setCostMode                                          ( m_costMode );
     727  m_cTEncTop.setUseRecalculateQPAccordingToLambda                 ( m_recalculateQPAccordingToLambda );
     728  m_cTEncTop.setUseStrongIntraSmoothing                           ( m_useStrongIntraSmoothing );
     729  m_cTEncTop.setActiveParameterSetsSEIEnabled                     ( m_activeParameterSetsSEIEnabled );
     730  m_cTEncTop.setVuiParametersPresentFlag                          ( m_vuiParametersPresentFlag );
     731  m_cTEncTop.setAspectRatioInfoPresentFlag                        ( m_aspectRatioInfoPresentFlag);
     732  m_cTEncTop.setAspectRatioIdc                                    ( m_aspectRatioIdc );
     733  m_cTEncTop.setSarWidth                                          ( m_sarWidth );
     734  m_cTEncTop.setSarHeight                                         ( m_sarHeight );
     735  m_cTEncTop.setOverscanInfoPresentFlag                           ( m_overscanInfoPresentFlag );
     736  m_cTEncTop.setOverscanAppropriateFlag                           ( m_overscanAppropriateFlag );
     737  m_cTEncTop.setVideoSignalTypePresentFlag                        ( m_videoSignalTypePresentFlag );
     738  m_cTEncTop.setVideoFormat                                       ( m_videoFormat );
     739  m_cTEncTop.setVideoFullRangeFlag                                ( m_videoFullRangeFlag );
     740  m_cTEncTop.setColourDescriptionPresentFlag                      ( m_colourDescriptionPresentFlag );
     741  m_cTEncTop.setColourPrimaries                                   ( m_colourPrimaries );
     742  m_cTEncTop.setTransferCharacteristics                           ( m_transferCharacteristics );
     743  m_cTEncTop.setMatrixCoefficients                                ( m_matrixCoefficients );
     744  m_cTEncTop.setChromaLocInfoPresentFlag                          ( m_chromaLocInfoPresentFlag );
     745  m_cTEncTop.setChromaSampleLocTypeTopField                       ( m_chromaSampleLocTypeTopField );
     746  m_cTEncTop.setChromaSampleLocTypeBottomField                    ( m_chromaSampleLocTypeBottomField );
     747  m_cTEncTop.setNeutralChromaIndicationFlag                       ( m_neutralChromaIndicationFlag );
     748  m_cTEncTop.setDefaultDisplayWindow                              ( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
     749  m_cTEncTop.setFrameFieldInfoPresentFlag                         ( m_frameFieldInfoPresentFlag );
     750  m_cTEncTop.setPocProportionalToTimingFlag                       ( m_pocProportionalToTimingFlag );
     751  m_cTEncTop.setNumTicksPocDiffOneMinus1                          ( m_numTicksPocDiffOneMinus1    );
     752  m_cTEncTop.setBitstreamRestrictionFlag                          ( m_bitstreamRestrictionFlag );
     753  m_cTEncTop.setTilesFixedStructureFlag                           ( m_tilesFixedStructureFlag );
     754  m_cTEncTop.setMotionVectorsOverPicBoundariesFlag                ( m_motionVectorsOverPicBoundariesFlag );
     755  m_cTEncTop.setMinSpatialSegmentationIdc                         ( m_minSpatialSegmentationIdc );
     756  m_cTEncTop.setMaxBytesPerPicDenom                               ( m_maxBytesPerPicDenom );
     757  m_cTEncTop.setMaxBitsPerMinCuDenom                              ( m_maxBitsPerMinCuDenom );
     758  m_cTEncTop.setLog2MaxMvLengthHorizontal                         ( m_log2MaxMvLengthHorizontal );
     759  m_cTEncTop.setLog2MaxMvLengthVertical                           ( m_log2MaxMvLengthVertical );
     760  m_cTEncTop.setEfficientFieldIRAPEnabled                         ( m_bEfficientFieldIRAPEnabled );
     761  m_cTEncTop.setHarmonizeGopFirstFieldCoupleEnabled               ( m_bHarmonizeGopFirstFieldCoupleEnabled );
     762
     763  m_cTEncTop.setSummaryOutFilename                                ( m_summaryOutFilename );
     764  m_cTEncTop.setSummaryPicFilenameBase                            ( m_summaryPicFilenameBase );
     765  m_cTEncTop.setSummaryVerboseness                                ( m_summaryVerboseness );
     766
     767#if NH_MV
     768  }
     769#endif
     770#if NH_3D_VSO
    679771  if ( m_bUseVSO )
    680772  {
     
    682774    {
    683775#if H_3D_VSO_EARLY_SKIP
    684       m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip );
    685 #else
    686       m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 );
     776      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip );
     777#else
     778      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 );
    687779#endif
    688780      for ( Int layer = 0; layer < m_numberOfLayers ; layer++ )
     
    717809Void TAppEncTop::xCreateLib()
    718810{
    719 #if H_MV
     811#if NH_MV
    720812  // initialize global variables
    721813  initROM();
    722 #if H_3D_DIM_DMM
     814#if NH_3D_DMM
    723815  initWedgeLists( true );
    724816#endif
     
    726818  for( Int layer=0; layer < m_numberOfLayers; layer++)
    727819  {
    728     m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer],     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
    729     m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
     820    m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer],     false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );  // read  mode
     821    m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC);
    730822
    731823    if (m_pchReconFileList[layer])
    732824    {
    733       m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
     825      m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth);  // write mode
    734826    }
    735827    m_acTEncTopList[layer]->create();
     
    737829#else
    738830  // Video I/O
    739   m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
    740   m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
     831  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );  // read  mode
     832  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC);
    741833
    742834  if (m_pchReconFile)
    743     m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
    744  
     835  {
     836    m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth);  // write mode
     837  }
     838
    745839  // Neo Decoder
    746840  m_cTEncTop.create();
     
    750844Void TAppEncTop::xDestroyLib()
    751845{
    752 #if H_MV
     846#if NH_MV
    753847  // destroy ROM
    754848  destroyROM();
     
    766860    delete m_acTEncTopList[layer] ;
    767861    m_acTEncTopList[layer] = NULL;
    768     delete m_picYuvRec[layer] ;
    769     m_picYuvRec[layer] = NULL;
     862    delete m_cListPicYuvRec[layer] ;
     863    m_cListPicYuvRec[layer] = NULL;
    770864  }
    771865#else
     
    773867  m_cTVideoIOYuvInputFile.close();
    774868  m_cTVideoIOYuvReconFile.close();
    775  
     869
    776870  // Neo Decoder
    777871  m_cTEncTop.destroy();
     
    781875Void TAppEncTop::xInitLib(Bool isFieldCoding)
    782876{
    783 #if H_3D
    784 #endif
    785 
    786 #if H_MV
     877#if NH_MV
    787878  for(Int layer=0; layer<m_numberOfLayers; layer++)
    788879  {
     
    794885  }
    795886#else
    796   m_cTEncTop.init( isFieldCoding );
     887  m_cTEncTop.init(isFieldCoding);
    797888#endif
    798889}
     
    819910  }
    820911
     912#if !NH_3D
    821913  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
     914#endif
    822915  TComPicYuv*       pcPicYuvRec = NULL;
    823  
     916
    824917  // initialize internal class & member variables
    825918  xInitLibCfg();
    826919  xCreateLib();
    827920  xInitLib(m_isField);
    828  
     921
     922  printChromaFormat();
     923
    829924  // main encoder loop
    830 #if H_MV
     925#if NH_MV
    831926  Bool  allEos = false;
    832927  std::vector<Bool>  eos ;
     
    846941  Bool  bEos = false;
    847942#endif
    848  
     943  const InputColourSpaceConversion ipCSC  =  m_inputColourSpaceConvert;
     944  const InputColourSpaceConversion snrCSC = (!m_snrInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED;
     945
    849946  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
     947 
     948#if NH_3D
     949  TComPicYuv* picYuvOrg[2];
     950  TComPicYuv  picYuvTrueOrg[2];
     951  for (Int d = 0; d < 2 ; d++)
     952  {
     953    picYuvOrg[d] = new TComPicYuv;
     954    picYuvOrg[d]   ->create( m_iSourceWidth, m_isField ? m_iSourceHeightOrg : m_iSourceHeight, ( d > 0 ) ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
     955    picYuvTrueOrg[d].create( m_iSourceWidth, m_isField ? m_iSourceHeightOrg : m_iSourceHeight, ( d > 0 ) ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
     956  }
     957#else
     958  TComPicYuv cPicYuvTrueOrg;
    850959
    851960  // allocate original YUV buffer
    852961  if( m_isField )
    853962  {
    854     pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     963    pcPicYuvOrg->create  ( m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
     964    cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true);
    855965  }
    856966  else
    857967  {
    858   pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    859   }
    860  
    861 #if H_MV
     968    pcPicYuvOrg->create  ( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
     969    cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
     970  }
     971#endif
     972#if NH_MV
    862973  while ( (m_targetEncLayerIdList.size() != 0 ) && !allEos )
    863974  {
    864975    for(Int layer=0; layer < m_numberOfLayers; layer++ )
    865976    {
     977#if NH_3D
     978      TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ m_depthFlag[layer] ];
     979      TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ m_depthFlag[layer] ];
     980#endif
    866981      if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) ))
    867982      {
     
    875990        xGetBuffer(pcPicYuvRec, layer);
    876991
    877         // read input YUV file
    878         m_acTVideoIOYuvInputFileList[layer]->read      ( pcPicYuvOrg, m_aiPad );
     992        // read input YUV file       
     993        m_acTVideoIOYuvInputFileList[layer]->read      ( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC );
    879994        m_acTEncTopList             [layer]->initNewPic( pcPicYuvOrg );
    880995
     
    8991014    for ( Int gopId=0; gopId < gopSize; gopId++ )
    9001015    {
    901 #if H_3D
     1016#if NH_3D
    9021017      UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
    9031018      if ( iNextPoc < m_framesToBeEncoded )
     
    9081023      for(Int layer=0; layer < m_numberOfLayers; layer++ )
    9091024      {
     1025#if NH_3D
     1026        TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ m_depthFlag[layer] ];
     1027        TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ m_depthFlag[layer] ];
     1028#endif
    9101029        if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) ))
    9111030        {
     
    9131032        }
    9141033
    915 #if H_3D_VSO       
     1034#if NH_3D_VSO       
    9161035          if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded )
    9171036          {
     
    9231042        Int   iNumEncoded = 0;
    9241043
    925         // call encoding function for one frame         
    926         m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, *m_picYuvRec[layer], outputAccessUnits, iNumEncoded, gopId );       
     1044        // call encoding function for one frame                               
     1045        m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, flush[layer] ? 0 : &cPicYuvTrueOrg, snrCSC, *m_cListPicYuvRec[layer], outputAccessUnits, iNumEncoded, gopId );       
    9271046        xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, layer);
    9281047        outputAccessUnits.clear();
     
    9371056    {
    9381057      continue;
    939     }
    940     m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded(), m_isField );
    941   }
    942 #else
     1058    }   
     1059    m_acTEncTopList[layer]->printSummary(m_isField);
     1060  }
     1061#else
     1062
    9431063  while ( !bEos )
    9441064  {
     
    9471067
    9481068    // read input YUV file
    949     m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad );
     1069    m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
    9501070
    9511071    // increase number of received frames
     
    9671087    if ( m_isField )
    9681088    {
    969       m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst);
     1089      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst );
    9701090    }
    9711091    else
    9721092    {
    973     m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
    974     }
    975    
     1093      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
     1094    }
     1095
    9761096    // write bistream to file if necessary
    9771097    if ( iNumEncoded > 0 )
     
    9851105#endif
    9861106
     1107#if NH_3D
     1108  // delete original YUV buffer
     1109  for (Int d = 0; d < 2; d++)
     1110  {
     1111    picYuvOrg[d]->destroy();
     1112    delete picYuvOrg[d];
     1113    picYuvOrg[d] = NULL;
     1114
     1115    picYuvTrueOrg[d].destroy();
     1116  }
     1117#else
    9871118  // delete original YUV buffer
    9881119  pcPicYuvOrg->destroy();
    9891120  delete pcPicYuvOrg;
    9901121  pcPicYuvOrg = NULL;
    991  
    992 #if !H_MV
     1122#endif
     1123
     1124#if !NH_MV
    9931125  // delete used buffers in encoder class
    9941126  m_cTEncTop.deletePicBuffer();
     1127#endif
     1128#if !NH_3D
     1129  cPicYuvTrueOrg.destroy();
    9951130#endif
    9961131
     
    9981133  xDeleteBuffer();
    9991134  xDestroyLib();
    1000  
     1135
    10011136  printRateSummary();
    10021137
     
    10231158 .
    10241159 */
    1025 #if H_MV
     1160#if NH_MV
    10261161Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
    10271162#else
     
    10301165{
    10311166  assert( m_iGOPSize > 0 );
    1032  
     1167
    10331168  // org. buffer
    1034 #if H_MV
    1035   if ( m_picYuvRec[layer]->size() == (UInt)m_iGOPSize )
    1036   {
    1037     rpcPicYuvRec = m_picYuvRec[layer]->popFront();
    1038 #else
    1039   if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize )
     1169#if NH_MV
     1170  if ( m_cListPicYuvRec[layer]->size() == (UInt)m_iGOPSize )
     1171  {
     1172    rpcPicYuvRec = m_cListPicYuvRec[layer]->popFront();
     1173#else
     1174  if ( m_cListPicYuvRec.size() >= (UInt)m_iGOPSize ) // buffer will be 1 element longer when using field coding, to maintain first field whilst processing second.
    10401175  {
    10411176    rpcPicYuvRec = m_cListPicYuvRec.popFront();
    10421177#endif
    1043 
    10441178  }
    10451179  else
    10461180  {
    10471181    rpcPicYuvRec = new TComPicYuv;
    1048    
    1049     rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    1050 
    1051   }
    1052 #if H_MV
    1053   m_picYuvRec[layer]->pushBack( rpcPicYuvRec );
     1182#if NH_3D
     1183    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_depthFlag[layer] > 0 ? CHROMA_400 : m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
     1184#else
     1185    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
     1186#endif
     1187
     1188  }
     1189#if NH_MV
     1190  m_cListPicYuvRec[layer]->pushBack( rpcPicYuvRec );
    10541191#else
    10551192  m_cListPicYuvRec.pushBack( rpcPicYuvRec );
     
    10591196Void TAppEncTop::xDeleteBuffer( )
    10601197{
    1061 #if H_MV
    1062   for(Int layer=0; layer<m_picYuvRec.size(); layer++)
    1063   {
    1064     if(m_picYuvRec[layer])
    1065     {
    1066       TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvRec[layer]->begin();
    1067       Int iSize = Int( m_picYuvRec[layer]->size() );
     1198#if NH_MV
     1199  for(Int layer=0; layer<m_cListPicYuvRec.size(); layer++)
     1200  {
     1201    if(m_cListPicYuvRec[layer])
     1202    {
     1203      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec[layer]->begin();
     1204      Int iSize = Int( m_cListPicYuvRec[layer]->size() );
    10681205#else
    10691206  TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec.begin();
    1070  
     1207
    10711208  Int iSize = Int( m_cListPicYuvRec.size() );
    10721209#endif
     
    10781215    delete pcPicYuvRec; pcPicYuvRec = NULL;
    10791216  }
    1080 
    1081 #if H_MV
     1217#if NH_MV
    10821218    }
    10831219  }
    10841220#endif 
    1085 }
    1086 
    1087 /** \param iNumEncoded  number of encoded frames
     1221
     1222}
     1223
     1224/**
     1225  Write access units to output file.
     1226  \param bitstreamFile  target bitstream file
     1227  \param iNumEncoded    number of encoded frames
     1228  \param accessUnits    list of access units to be written
    10881229 */
    1089 #if H_MV
    1090 Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId)
     1230#if NH_MV
     1231Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerIdx)
    10911232#else
    10921233Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    10931234#endif
    10941235{
     1236  const InputColourSpaceConversion ipCSC = (!m_outputInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED;
     1237
    10951238  if (m_isField)
    10961239  {
    10971240    //Reinterlace fields
    10981241    Int i;
    1099 #if H_MV
     1242#if NH_MV
    11001243    if( iNumEncoded > 0 )
    11011244    {
    1102       TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end();
     1245      TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec[layerIdx]->end();
    11031246#else
    11041247    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     
    11161259      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
    11171260
    1118 #if H_MV
    1119       if (m_pchReconFileList[layerId])
    1120       {
    1121         m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst );
     1261#if NH_MV
     1262      if (m_pchReconFileList[layerIdx])
     1263      {
     1264#if NH_3D
     1265        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 );
     1266#else
     1267        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, NUM_CHROMA_FORMAT, m_isTopFieldFirst );
     1268#endif
    11221269      }
    11231270    }
     
    11361283      if (m_pchReconFile)
    11371284      {
    1138         m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst );
     1285        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, NUM_CHROMA_FORMAT, m_isTopFieldFirst );
    11391286      }
    11401287
     
    11521299  {
    11531300    Int i;
    1154 #if H_MV
     1301#if NH_MV
    11551302    if( iNumEncoded > 0 )
    11561303    {
    1157       TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end();
     1304      TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec[layerIdx]->end();
    11581305#else
    11591306    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     
    11691316    {
    11701317      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
    1171 #if H_MV
    1172       if (m_pchReconFileList[layerId])
    1173       {
    1174         m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
     1318#if NH_MV
     1319      if (m_pchReconFileList[layerIdx])
     1320      {
     1321#if NH_3D
     1322        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT  );
     1323#else
     1324        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
     1325#endif
     1326
    11751327      }   
    11761328    }
     
    11881340      if (m_pchReconFile)
    11891341      {
    1190         m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
     1342        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom,
     1343            NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range  );
    11911344      }
    11921345
    11931346      const AccessUnit& au = *(iterBitstream++);
    11941347      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
    1195       rateStatsAccum(au, stats);   
    1196     }
    1197 #endif
    1198   }
    1199 }
    1200  
     1348      rateStatsAccum(au, stats);
     1349    }
     1350#endif
     1351  }
     1352}
     1353
    12011354/**
    12021355 *
    12031356 */
    1204 void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
     1357Void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
    12051358{
    12061359  AccessUnit::const_iterator it_au = au.begin();
     
    12401393}
    12411394
    1242 void TAppEncTop::printRateSummary()
    1243 {
    1244 #if H_MV
     1395Void TAppEncTop::printRateSummary()
     1396{
     1397#if NH_MV
    12451398  Double time = (Double) m_frameRcvd[0] / m_iFrameRate;
    12461399  printf("\n");
     
    12491402#endif
    12501403  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
    1251 #if VERBOSE_RATE
     1404  if (m_summaryVerboseness > 0)
     1405  {
    12521406  printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time);
    1253 #endif
    1254 }
    1255 
    1256 #if H_3D_DIM_DLT
     1407  }
     1408}
     1409
     1410Void TAppEncTop::printChromaFormat()
     1411{
     1412  std::cout << std::setw(43) << "Input ChromaFormatIDC = ";
     1413  switch (m_InputChromaFormatIDC)
     1414  {
     1415  case CHROMA_400:  std::cout << "  4:0:0"; break;
     1416  case CHROMA_420:  std::cout << "  4:2:0"; break;
     1417  case CHROMA_422:  std::cout << "  4:2:2"; break;
     1418  case CHROMA_444:  std::cout << "  4:4:4"; break;
     1419  default:
     1420    std::cerr << "Invalid";
     1421    exit(1);
     1422  }
     1423  std::cout << std::endl;
     1424
     1425#if NH_MV
     1426  for (Int i = 0; i < m_numberOfLayers; i++)
     1427  {
     1428    std::cout << "Layer " << i << std::setw( 43 - (i > 9 ? 6 : 7) ) << "Internal ChromaFormatIDC = ";
     1429    switch (m_acTEncTopList[i]->getChromaFormatIdc())
     1430#else
     1431    std::cout << std::setw(43) << "Output (internal) ChromaFormatIDC = ";
     1432    switch (m_cTEncTop.getChromaFormatIdc())
     1433#endif
     1434    {
     1435    case CHROMA_400:  std::cout << "  4:0:0"; break;
     1436    case CHROMA_420:  std::cout << "  4:2:0"; break;
     1437    case CHROMA_422:  std::cout << "  4:2:2"; break;
     1438    case CHROMA_444:  std::cout << "  4:4:4"; break;
     1439    default:
     1440      std::cerr << "Invalid";
     1441      exit(1);
     1442    }
     1443#if NH_MV
     1444    std::cout << std::endl;
     1445  }
     1446#endif
     1447  std::cout << "\n" << std::endl;
     1448}
     1449
     1450#if NH_3D_DLT
    12571451Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt)
    12581452{
    12591453  TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
     1454  TComPicYuv*       pcDepthPicYuvTrueOrg = new TComPicYuv;
    12601455  // allocate original YUV buffer
    1261   pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1456  pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, false );
     1457  pcDepthPicYuvTrueOrg->create( m_iSourceWidth, m_iSourceHeight, CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, false );
    12621458 
    12631459  TVideoIOYuv* depthVideoFile = new TVideoIOYuv;
    12641460 
    1265   UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1);
     1461  UInt uiMaxDepthValue = ((1 << m_inputBitDepth[CHANNEL_TYPE_LUMA])-1);
    12661462 
    1267   Bool abValidDepths[256];
     1463  std::vector<Bool> abValidDepths(256, false);
    12681464 
    1269   depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
     1465  depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );
    12701466 
    1271   // initialize boolean array
    1272   for(Int p=0; p<=uiMaxDepthValue; p++)
    1273     abValidDepths[p] = false;
     1467  Int iHeight   = pcDepthPicYuvOrg->getHeight(COMPONENT_Y);
     1468  Int iWidth    = pcDepthPicYuvOrg->getWidth(COMPONENT_Y);
     1469  Int iStride   = pcDepthPicYuvOrg->getStride(COMPONENT_Y);
    12741470 
    1275   Int iHeight   = pcDepthPicYuvOrg->getHeight();
    1276   Int iWidth    = pcDepthPicYuvOrg->getWidth();
    1277   Int iStride   = pcDepthPicYuvOrg->getStride();
    1278  
    1279   Pel* pInDM    = pcDepthPicYuvOrg->getLumaAddr();
     1471  Pel* pInDM    = pcDepthPicYuvOrg->getAddr(COMPONENT_Y);
    12801472 
    12811473  for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ )
    12821474  {
    1283     depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad );
     1475    depthVideoFile->read( pcDepthPicYuvOrg, pcDepthPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
    12841476   
    12851477    // check all pixel values
     
    13011493  pcDepthPicYuvOrg->destroy();
    13021494  delete pcDepthPicYuvOrg;
     1495  pcDepthPicYuvTrueOrg->destroy();
     1496  delete pcDepthPicYuvTrueOrg;
    13031497 
    13041498  // convert boolean array to idx2Depth LUT
    1305   Int* aiIdx2DepthValue = (Int*) calloc(uiMaxDepthValue, sizeof(Int));
     1499  std::vector<Int> aiIdx2DepthValue(256, 0);
    13061500  Int iNumDepthValues = 0;
    13071501  for(Int p=0; p<=uiMaxDepthValue; p++)
     
    13131507  }
    13141508 
    1315   if( uiNumFrames == 0 || numBitsForValue(iNumDepthValues) == g_bitDepthY )
     1509  if( uiNumFrames == 0 || gCeilLog2(iNumDepthValues) == m_inputBitDepth[CHANNEL_TYPE_LUMA] )
    13161510  {
    13171511    dlt->setUseDLTFlag(layer, false);
     
    13231517    dlt->setDepthLUTs(layer, aiIdx2DepthValue, iNumDepthValues);
    13241518  }
    1325  
    1326   // free temporary memory
    1327   free(aiIdx2DepthValue);
    1328 }
    1329 #endif
    1330 
    1331 #if H_MV
     1519}
     1520#endif
     1521
     1522#if NH_MV
    13321523Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps )
    13331524{   
     
    13371528    vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] );
    13381529    for( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ )
    1339 
    13401530    {       
    13411531      vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] );       
     
    13581548
    13591549
    1360 #if H_3D
     1550#if NH_3D
    13611551  vps.initViewCompLayer( );
    13621552#endif
     
    14371627      Int curLayerIdInNuh = vps.getLayerIdInNuh( curLayerIdInVps );     
    14381628      Int maxTid = -1;
    1439 #if H_3D
     1629#if NH_3D
    14401630      if ( vps.getDirectDependencyFlag( curLayerIdInVps, refLayerIdInVps ) )
    14411631      {
     
    14491639            for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++)
    14501640            {
    1451 #if H_3D
     1641#if NH_3D
    14521642              if ( vps.getIdRefListLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[ j ] ) == refLayerIdInNuh )
    14531643#else
     
    14601650            }
    14611651          }             
    1462 #if H_3D
     1652#if NH_3D
    14631653        }
    14641654        else
     
    15541744     
    15551745      // check if all reference layers when allRefLayerActiveFlag is equal to 1 are reference layer pictures specified in the gop entry
    1556 #if H_3D
     1746#if NH_3D
    15571747      for (Int k = 0; k < vps.getNumRefListLayers( layerIdInNuh ) && allRefLayersActiveFlag; k++ )
    15581748      {
     
    15801770      {   
    15811771        Bool referenceLayerFoundFlag = false;
    1582 #if H_3D
     1772#if NH_3D
    15831773        for (Int k = 0; k < vps.getNumRefListLayers( layerIdInNuh ); k++ )
    15841774        {
     
    16191809}
    16201810
     1811
     1812Void TAppEncTop::xSetTimingInfo( TComVPS& vps )
     1813{
     1814  vps.getTimingInfo()->setTimingInfoPresentFlag( false );
     1815}
     1816
     1817Void TAppEncTop::xSetHrdParameters( TComVPS& vps )
     1818{
     1819  vps.createHrdParamBuffer();
     1820  for( Int i = 0; i < vps.getNumHrdParameters(); i++ )
     1821  {
     1822    vps.setHrdOpSetIdx( 0, i );
     1823    vps.setCprmsPresentFlag( false, i );
     1824  }
     1825}
     1826
    16211827Void TAppEncTop::xSetLayerIds( TComVPS& vps )
    16221828{
    16231829  vps.setSplittingFlag     ( m_splittingFlag );
    16241830
    1625   Bool nuhLayerIdPresentFlag = !( m_layerIdInNuh.size() == 1 );
    1626   Int  maxNuhLayerId = nuhLayerIdPresentFlag ? xGetMax( m_layerIdInNuh ) : ( m_numberOfLayers - 1 ) ;
    1627 
    1628   vps.setVpsMaxLayerId( maxNuhLayerId );
     1831  Bool nuhLayerIdPresentFlag = false;
     1832 
     1833
     1834  vps.setVpsMaxLayerId( xGetMax( m_layerIdInNuh ) );
     1835
     1836  for (Int i = 0; i < m_numberOfLayers; i++)
     1837  {
     1838    nuhLayerIdPresentFlag = nuhLayerIdPresentFlag || ( m_layerIdInNuh[i] != i );
     1839  }
     1840
    16291841  vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag );
    16301842
     
    16501862
    16511863  // SET PTL
    1652   assert( m_profile.size() == m_level.size() && m_profile.size() == m_levelTier.size() );
    1653   vps.setVpsNumProfileTierLevelMinus1( (Int) m_profile.size() - 1 );
     1864  assert( m_profiles.size() == m_level.size() && m_profiles.size() == m_levelTier.size() );
     1865  vps.setVpsNumProfileTierLevelMinus1( (Int) m_profiles.size() - 1 );
    16541866  for ( Int ptlIdx = 0; ptlIdx <= vps.getVpsNumProfileTierLevelMinus1(); ptlIdx++ )
    16551867  {
    16561868    if ( ptlIdx > 1 )
    16571869    {
    1658       Bool vpsProfilePresentFlag = ( m_profile[ptlIdx] != m_profile[ptlIdx - 1] )
     1870      Bool vpsProfilePresentFlag = ( m_profiles[ptlIdx] != m_profiles[ptlIdx - 1] )
    16591871        || ( m_inblFlag[ptlIdx ] != m_inblFlag[ptlIdx - 1] );
    16601872      vps.setVpsProfilePresentFlag( ptlIdx, vpsProfilePresentFlag );
    16611873    }
    16621874
    1663     xSetProfileTierLevel( vps, ptlIdx, -1, m_profile[ptlIdx], m_level[ptlIdx],
     1875    xSetProfileTierLevel( vps, ptlIdx, -1, m_profiles[ptlIdx], m_level[ptlIdx],
    16641876      m_levelTier[ ptlIdx ], m_progressiveSourceFlag, m_interlacedSourceFlag,
    16651877      m_nonPackedConstraintFlag, m_frameOnlyConstraintFlag,  m_inblFlag[ptlIdx] );     
     
    16951907    break;
    16961908  case Profile::MULTIVIEWMAIN:
    1697 #if H_3D
     1909#if NH_3D
    16981910  case Profile::MAIN3D:
    16991911#endif
     
    17181930{
    17191931
    1720 #if H_3D_DISABLE_CHROMA
    17211932  Bool anyDepth = false;
     1933#if NH_3D
    17221934  for ( Int i = 0; i < m_numberOfLayers; i++ )
    17231935  {
    17241936    vps.setVpsRepFormatIdx( i, m_depthFlag[ i ] ? 1 : 0 );
    1725     anyDepth = anyDepth || m_depthFlag[ i ];
    1726   } 
     1937    anyDepth = anyDepth || m_depthFlag[ i ];
     1938  }
     1939#endif
    17271940
    17281941  vps.setRepFormatIdxPresentFlag( anyDepth );
    1729   vps.setVpsNumRepFormatsMinus1 ( anyDepth ? 1 : 0  );
    1730 
     1942  vps.setVpsNumRepFormatsMinus1 ( anyDepth ? 1 : 0     );
     1943
     1944
     1945  std::vector<TComRepFormat> repFormat;
     1946  repFormat.resize( vps.getVpsNumRepFormatsMinus1() + 1 );
    17311947  for ( Int j = 0; j <= vps.getVpsNumRepFormatsMinus1(); j++ )
    1732   {
    1733     TComRepFormat* repFormat = new TComRepFormat;
    1734 
    1735     repFormat->setBitDepthVpsChromaMinus8   ( g_bitDepthC - 8 );
    1736     repFormat->setBitDepthVpsLumaMinus8     ( g_bitDepthY - 8 );
    1737     repFormat->setChromaFormatVpsIdc        ( j == 1 ? CHROMA_400 : CHROMA_420 );
    1738     repFormat->setPicHeightVpsInLumaSamples ( m_iSourceHeight );
    1739     repFormat->setPicWidthVpsInLumaSamples  ( m_iSourceWidth  );   
    1740     repFormat->setChromaAndBitDepthVpsPresentFlag( true );   
     1948  {           
     1949    repFormat[j].setBitDepthVpsChromaMinus8   ( m_internalBitDepth[CHANNEL_TYPE_LUMA  ] - 8 );
     1950    repFormat[j].setBitDepthVpsLumaMinus8     ( m_internalBitDepth[CHANNEL_TYPE_CHROMA] - 8 );
     1951    repFormat[j].setChromaFormatVpsIdc        ( j == 1 ? CHROMA_400 :  CHROMA_420 );
     1952    repFormat[j].setPicHeightVpsInLumaSamples ( m_iSourceHeight );
     1953    repFormat[j].setPicWidthVpsInLumaSamples  ( m_iSourceWidth  );   
     1954    repFormat[j].setChromaAndBitDepthVpsPresentFlag( true );   
    17411955    // ToDo not supported yet.
    17421956    //repFormat->setSeparateColourPlaneVpsFlag( );
    1743     Bool conformanceWindowVpsFlag = ( m_confWinBottom != 0 ) || ( m_confWinRight != 0 ) || ( m_confWinTop != 0 ) || ( m_confWinBottom != 0 );
    1744     repFormat->setConformanceWindowVpsFlag( conformanceWindowVpsFlag );
    1745     if ( conformanceWindowVpsFlag )
    1746     {   
    1747       repFormat->setConfWinVpsLeftOffset    ( m_confWinLeft   / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) );
    1748       repFormat->setConfWinVpsRightOffset   ( m_confWinRight  / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() )  );
    1749       repFormat->setConfWinVpsTopOffset     ( m_confWinTop    / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() )  );
    1750       repFormat->setConfWinVpsBottomOffset  ( m_confWinBottom / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) );
    1751     }
    1752     assert( vps.getRepFormat( j ) == NULL );
    1753     vps.setRepFormat( j , repFormat );
    1754   };
    1755 
    1756 
    1757 #else
    1758   vps.setRepFormatIdxPresentFlag( false );
    1759   vps.setVpsNumRepFormatsMinus1 ( 0    );
    1760 
    1761   TComRepFormat* repFormat = new TComRepFormat;
    1762 
    1763   repFormat->setBitDepthVpsChromaMinus8   ( g_bitDepthC - 8 );
    1764   repFormat->setBitDepthVpsLumaMinus8     ( g_bitDepthY - 8 );
    1765   repFormat->setChromaFormatVpsIdc        ( CHROMA_420      );
    1766   repFormat->setPicHeightVpsInLumaSamples ( m_iSourceHeight );
    1767   repFormat->setPicWidthVpsInLumaSamples  ( m_iSourceWidth  );   
    1768   repFormat->setChromaAndBitDepthVpsPresentFlag( true );   
    1769   // ToDo not supported yet.
    1770   //repFormat->setSeparateColourPlaneVpsFlag( );
    1771 
    1772   repFormat->setConformanceWindowVpsFlag( true );
    1773   repFormat->setConfWinVpsLeftOffset    ( m_confWinLeft   / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) );
    1774   repFormat->setConfWinVpsRightOffset   ( m_confWinRight  / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() )  );
    1775   repFormat->setConfWinVpsTopOffset     ( m_confWinTop    / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() )  );
    1776   repFormat->setConfWinVpsBottomOffset  ( m_confWinBottom / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) );
    1777   assert( vps.getRepFormat( 0 ) == NULL );
    1778   vps.setRepFormat( 0 , repFormat );
    1779 #endif
     1957
     1958    repFormat[j].setConformanceWindowVpsFlag( true );
     1959    repFormat[j].setConfWinVpsLeftOffset    ( m_confWinLeft   / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() ) );
     1960    repFormat[j].setConfWinVpsRightOffset   ( m_confWinRight  / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() )  );
     1961    repFormat[j].setConfWinVpsTopOffset     ( m_confWinTop    / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() )  );
     1962    repFormat[j].setConfWinVpsBottomOffset  ( m_confWinBottom / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() ) );
     1963  }
     1964
     1965  vps.setRepFormat( repFormat );
     1966
    17801967}
    17811968
     
    17841971  // These settings need to be verified
    17851972
    1786   TComDpbSize* dpbSize = vps.getDpbSize();
    1787 
    1788   assert ( dpbSize != 0 );
     1973  TComDpbSize dpbSize; 
     1974  dpbSize.init( vps.getNumOutputLayerSets(), vps.getVpsMaxLayerId() + 1, vps.getMaxSubLayersMinus1() + 1 ) ;
     1975 
    17891976
    17901977  for( Int i = 0; i < vps.getNumOutputLayerSets(); i++ )
     
    18011988        if ( vps.getNecessaryLayerFlag( i,k ) && ( vps.getVpsBaseLayerInternalFlag() || vps.getLayerSetLayerIdList( currLsIdx, k ) != 0 ) )
    18021989        {       
    1803           dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, m_maxDecPicBufferingMvc[ layerIdInVps ][ j ] - 1 );
     1990          dpbSize.setMaxVpsDecPicBufferingMinus1( i, k, j, m_maxDecPicBufferingMvc[ layerIdInVps ][ j ] - 1 );
    18041991          if ( j > 0 )
    18051992          {
    1806             subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) != dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) );
     1993            subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize.getMaxVpsDecPicBufferingMinus1( i, k, j ) != dpbSize.getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) );
    18071994          }
    18081995        }
     
    18111998          if (vps.getNecessaryLayerFlag(i,k) && j == 0 && k == 0 )
    18121999          {         
    1813             dpbSize->setMaxVpsDecPicBufferingMinus1(i, k ,j, 0 );
     2000            dpbSize.setMaxVpsDecPicBufferingMinus1(i, k ,j, 0 );
    18142001          }
    18152002        }
     
    18272014      assert( maxNumReorderPics != MIN_INT );
    18282015
    1829       dpbSize->setMaxVpsNumReorderPics( i, j, maxNumReorderPics );
     2016      dpbSize.setMaxVpsNumReorderPics( i, j, maxNumReorderPics );
    18302017      if ( j > 0 )
    18312018      {
    1832         subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsNumReorderPics( i, j ) != dpbSize->getMaxVpsNumReorderPics( i, j - 1 ) );
     2019        subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize.getMaxVpsNumReorderPics( i, j ) != dpbSize.getMaxVpsNumReorderPics( i, j - 1 ) );
    18332020      }
    18342021
    18352022      // To Be Done !
    1836       // dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, xx );
     2023      // dpbSize.setMaxVpsLatencyIncreasePlus1( i, j, xx );
    18372024      if ( j > 0 )
    18382025      {
    1839         subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ) != dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1  ) );
     2026        subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize.getMaxVpsLatencyIncreasePlus1( i, j ) != dpbSize.getMaxVpsLatencyIncreasePlus1( i, j - 1  ) );
    18402027      }
    18412028
    18422029      if( j > 0 ) 
    18432030      {
    1844         dpbSize->setSubLayerDpbInfoPresentFlag( i, j, subLayerDpbInfoPresentFlag );
     2031        dpbSize.setSubLayerDpbInfoPresentFlag( i, j, subLayerDpbInfoPresentFlag );
    18452032        subLayerFlagInfoPresentFlag = subLayerFlagInfoPresentFlag || subLayerDpbInfoPresentFlag;
    18462033      }       
    18472034    } 
    1848     dpbSize->setSubLayerFlagInfoPresentFlag( i, subLayerFlagInfoPresentFlag );
     2035    dpbSize.setSubLayerFlagInfoPresentFlag( i, subLayerFlagInfoPresentFlag );
    18492036  } 
     2037  vps.setDpbSize( dpbSize );
    18502038}
    18512039
     
    20102198  vps.setVpsVuiPresentFlag( m_vpsVuiPresentFlag );
    20112199
    2012   TComVPSVUI* pcVPSVUI = vps.getVPSVUI(  );
    2013   assert( pcVPSVUI );
     2200  TComVPSVUI vpsVui;
     2201  vpsVui.init(vps.getNumAddLayerSets(),vps.getMaxSubLayersMinus1() + 1, vps.getMaxLayersMinus1() + 1 );
    20142202
    20152203  if ( m_vpsVuiPresentFlag )
     
    20182206    // however preliminary setting it from input parameters
    20192207
    2020     pcVPSVUI->setCrossLayerPicTypeAlignedFlag( m_crossLayerPicTypeAlignedFlag );
    2021     pcVPSVUI->setCrossLayerIrapAlignedFlag   ( m_crossLayerIrapAlignedFlag    );
    2022     pcVPSVUI->setAllLayersIdrAlignedFlag     ( m_allLayersIdrAlignedFlag      );
    2023     pcVPSVUI->setBitRatePresentVpsFlag( m_bitRatePresentVpsFlag );
    2024     pcVPSVUI->setPicRatePresentVpsFlag( m_picRatePresentVpsFlag );
    2025 
    2026     if( pcVPSVUI->getBitRatePresentVpsFlag( )  ||  pcVPSVUI->getPicRatePresentVpsFlag( ) )
     2208    vpsVui.setCrossLayerPicTypeAlignedFlag( m_crossLayerPicTypeAlignedFlag );
     2209    vpsVui.setCrossLayerIrapAlignedFlag   ( m_crossLayerIrapAlignedFlag    );
     2210    vpsVui.setAllLayersIdrAlignedFlag     ( m_allLayersIdrAlignedFlag      );
     2211    vpsVui.setBitRatePresentVpsFlag( m_bitRatePresentVpsFlag );
     2212    vpsVui.setPicRatePresentVpsFlag( m_picRatePresentVpsFlag );
     2213
     2214    if( vpsVui.getBitRatePresentVpsFlag( )  ||  vpsVui.getPicRatePresentVpsFlag( ) )
    20272215    {
    20282216      for( Int i = 0; i  <  vps.getNumLayerSets(); i++ )
     
    20302218        for( Int j = 0; j  <=  vps.getMaxTLayers(); j++ )
    20312219        {
    2032           if( pcVPSVUI->getBitRatePresentVpsFlag( ) && m_bitRatePresentFlag[i].size() > j )
     2220          if( vpsVui.getBitRatePresentVpsFlag( ) && m_bitRatePresentFlag[i].size() > j )
    20332221          {
    2034             pcVPSVUI->setBitRatePresentFlag( i, j, m_bitRatePresentFlag[i][j] );           
     2222            vpsVui.setBitRatePresentFlag( i, j, m_bitRatePresentFlag[i][j] );           
    20352223          }
    2036           if( pcVPSVUI->getPicRatePresentVpsFlag( ) && m_picRatePresentFlag[i].size() > j   )
     2224          if( vpsVui.getPicRatePresentVpsFlag( ) && m_picRatePresentFlag[i].size() > j   )
    20372225          {
    2038             pcVPSVUI->setPicRatePresentFlag( i, j, m_picRatePresentFlag[i][j] );
     2226            vpsVui.setPicRatePresentFlag( i, j, m_picRatePresentFlag[i][j] );
    20392227          }
    2040           if( pcVPSVUI->getBitRatePresentFlag( i, j )  && m_avgBitRate[i].size() > j )
     2228          if( vpsVui.getBitRatePresentFlag( i, j )  && m_avgBitRate[i].size() > j )
    20412229          {
    2042             pcVPSVUI->setAvgBitRate( i, j, m_avgBitRate[i][j] );         
     2230            vpsVui.setAvgBitRate( i, j, m_avgBitRate[i][j] );         
    20432231          }
    2044           if( pcVPSVUI->getBitRatePresentFlag( i, j )  && m_maxBitRate[i].size() > j )
     2232          if( vpsVui.getBitRatePresentFlag( i, j )  && m_maxBitRate[i].size() > j )
    20452233          {
    2046             pcVPSVUI->setMaxBitRate( i, j, m_maxBitRate[i][j] );
     2234            vpsVui.setMaxBitRate( i, j, m_maxBitRate[i][j] );
    20472235          }
    2048           if( pcVPSVUI->getPicRatePresentFlag( i, j ) && m_constantPicRateIdc[i].size() > j )
     2236          if( vpsVui.getPicRatePresentFlag( i, j ) && m_constantPicRateIdc[i].size() > j )
    20492237          {
    2050             pcVPSVUI->setConstantPicRateIdc( i, j, m_constantPicRateIdc[i][j] );
     2238            vpsVui.setConstantPicRateIdc( i, j, m_constantPicRateIdc[i][j] );
    20512239          }
    2052           if( pcVPSVUI->getPicRatePresentFlag( i, j ) && m_avgPicRate[i].size() > j )
     2240          if( vpsVui.getPicRatePresentFlag( i, j ) && m_avgPicRate[i].size() > j )
    20532241          {
    2054             pcVPSVUI->setAvgPicRate( i, j, m_avgPicRate[i][j] );
     2242            vpsVui.setAvgPicRate( i, j, m_avgPicRate[i][j] );
    20552243          }
    20562244        }
     
    20582246    }
    20592247
    2060     pcVPSVUI->setTilesNotInUseFlag( m_tilesNotInUseFlag );
    2061 
    2062     if( !pcVPSVUI->getTilesNotInUseFlag() )
     2248    vpsVui.setTilesNotInUseFlag( m_tilesNotInUseFlag );
     2249
     2250    if( !vpsVui.getTilesNotInUseFlag() )
    20632251    {     
    20642252      for( Int i = 0; i  <=  vps.getMaxLayersMinus1(); i++ )
    20652253      {
    2066         pcVPSVUI->setTilesInUseFlag( i, m_tilesInUseFlag[ i ] );
    2067         if( pcVPSVUI->getTilesInUseFlag( i ) ) 
     2254        vpsVui.setTilesInUseFlag( i, m_tilesInUseFlag[ i ] );
     2255        if( vpsVui.getTilesInUseFlag( i ) ) 
    20682256        {
    2069           pcVPSVUI->setLoopFilterNotAcrossTilesFlag( i, m_loopFilterNotAcrossTilesFlag[ i ] );
     2257          vpsVui.setLoopFilterNotAcrossTilesFlag( i, m_loopFilterNotAcrossTilesFlag[ i ] );
    20702258        }
    20712259      } 
     
    20762264        { 
    20772265          Int layerIdx = vps.getLayerIdInVps( vps.getIdDirectRefLayer(vps.getLayerIdInNuh( i ) , j  )); 
    2078           if( pcVPSVUI->getTilesInUseFlag( i )  &&  pcVPSVUI->getTilesInUseFlag( layerIdx ) ) 
     2266          if( vpsVui.getTilesInUseFlag( i )  &&  vpsVui.getTilesInUseFlag( layerIdx ) ) 
    20792267          {
    2080             pcVPSVUI->setTileBoundariesAlignedFlag( i, j, m_tileBoundariesAlignedFlag[i][j] );
     2268            vpsVui.setTileBoundariesAlignedFlag( i, j, m_tileBoundariesAlignedFlag[i][j] );
    20812269          }
    20822270        } 
     
    20842272    } 
    20852273
    2086     pcVPSVUI->setWppNotInUseFlag( m_wppNotInUseFlag );
    2087 
    2088     if( !pcVPSVUI->getWppNotInUseFlag( ) )
     2274    vpsVui.setWppNotInUseFlag( m_wppNotInUseFlag );
     2275
     2276    if( !vpsVui.getWppNotInUseFlag( ) )
    20892277    {
    20902278      for( Int i = 1; i  <=  vps.getMaxLayersMinus1(); i++ ) 
    20912279      {
    2092         pcVPSVUI->setWppInUseFlag( i, m_wppInUseFlag[ i ]);
    2093       }
    2094     }
    2095 
    2096   pcVPSVUI->setSingleLayerForNonIrapFlag( m_singleLayerForNonIrapFlag );
    2097   pcVPSVUI->setHigherLayerIrapSkipFlag( m_higherLayerIrapSkipFlag );
    2098 
    2099     pcVPSVUI->setIlpRestrictedRefLayersFlag( m_ilpRestrictedRefLayersFlag );
    2100 
    2101     if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) )
     2280        vpsVui.setWppInUseFlag( i, m_wppInUseFlag[ i ]);
     2281      }
     2282    }
     2283
     2284  vpsVui.setSingleLayerForNonIrapFlag( m_singleLayerForNonIrapFlag );
     2285  vpsVui.setHigherLayerIrapSkipFlag( m_higherLayerIrapSkipFlag );
     2286
     2287    vpsVui.setIlpRestrictedRefLayersFlag( m_ilpRestrictedRefLayersFlag );
     2288
     2289    if( vpsVui.getIlpRestrictedRefLayersFlag( ) )
    21022290    {
    21032291      for( Int i = 1; i  <=  vps.getMaxLayersMinus1(); i++ )
     
    21072295          if ( m_minSpatialSegmentOffsetPlus1[i].size() > j )
    21082296          {       
    2109             pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, m_minSpatialSegmentOffsetPlus1[i][j] );
     2297            vpsVui.setMinSpatialSegmentOffsetPlus1( i, j, m_minSpatialSegmentOffsetPlus1[i][j] );
    21102298          }
    2111           if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 )
     2299          if( vpsVui.getMinSpatialSegmentOffsetPlus1( i, j ) > 0 )
    21122300          {
    21132301            if ( m_ctuBasedOffsetEnabledFlag[i].size() > j )
    21142302            {       
    2115               pcVPSVUI->setCtuBasedOffsetEnabledFlag( i, j, m_ctuBasedOffsetEnabledFlag[i][j] );
     2303              vpsVui.setCtuBasedOffsetEnabledFlag( i, j, m_ctuBasedOffsetEnabledFlag[i][j] );
    21162304            }
    2117             if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) )
     2305            if( vpsVui.getCtuBasedOffsetEnabledFlag( i, j ) )
    21182306            {
    21192307              if ( m_minHorizontalCtuOffsetPlus1[i].size() > j )
    21202308              {
    2121                 pcVPSVUI->setMinHorizontalCtuOffsetPlus1( i, j, m_minHorizontalCtuOffsetPlus1[i][j] );
     2309                vpsVui.setMinHorizontalCtuOffsetPlus1( i, j, m_minHorizontalCtuOffsetPlus1[i][j] );
    21222310              }
    21232311            }
     
    21262314      }
    21272315    }     
    2128     pcVPSVUI->setVideoSignalInfoIdxPresentFlag( true );
    2129     pcVPSVUI->setVpsNumVideoSignalInfoMinus1  ( 0    );
    2130 
    2131     assert ( pcVPSVUI->getVideoSignalInfo( 0 ) == NULL );
    2132 
    2133     TComVideoSignalInfo* videoSignalInfo = new TComVideoSignalInfo;
    2134 
    2135     videoSignalInfo->setColourPrimariesVps        ( m_colourPrimaries );
    2136     videoSignalInfo->setMatrixCoeffsVps           ( m_matrixCoefficients );
    2137     videoSignalInfo->setTransferCharacteristicsVps( m_transferCharacteristics );
    2138     videoSignalInfo->setVideoVpsFormat            ( m_videoFormat );
    2139     videoSignalInfo->setVideoFullRangeVpsFlag     ( m_videoFullRangeFlag ); 
    2140 
    2141     pcVPSVUI->setVideoSignalInfo( 0, videoSignalInfo );       
     2316    vpsVui.setVideoSignalInfoIdxPresentFlag( true );
     2317    vpsVui.setVpsNumVideoSignalInfoMinus1  ( 0    );     
     2318
     2319    std::vector<TComVideoSignalInfo> videoSignalInfos;
     2320    videoSignalInfos.resize( vpsVui.getVpsNumVideoSignalInfoMinus1() + 1 );
     2321
     2322    videoSignalInfos[0].setColourPrimariesVps        ( m_colourPrimaries );
     2323    videoSignalInfos[0].setMatrixCoeffsVps           ( m_matrixCoefficients );
     2324    videoSignalInfos[0].setTransferCharacteristicsVps( m_transferCharacteristics );
     2325    videoSignalInfos[0].setVideoVpsFormat            ( m_videoFormat );
     2326    videoSignalInfos[0].setVideoFullRangeVpsFlag     ( m_videoFullRangeFlag ); 
     2327
     2328    vpsVui.setVideoSignalInfo( videoSignalInfos );       
    21422329
    21432330    for (Int i = 0; i < m_numberOfLayers; i++)
    21442331    {     
    2145       pcVPSVUI->setVpsVideoSignalInfoIdx( i, 0 );
    2146     }
    2147     pcVPSVUI->setVpsVuiBspHrdPresentFlag( false ); // TBD
     2332      vpsVui.setVpsVideoSignalInfoIdx( i, 0 );
     2333    }
     2334    vpsVui.setVpsVuiBspHrdPresentFlag( false ); // TBD
    21482335  }
    21492336  else
    21502337  {
    2151     pcVPSVUI->setCrossLayerIrapAlignedFlag   ( false   );
    2152   }
    2153 }
    2154 
    2155 #if H_3D
     2338    //Default inference when not present.
     2339    vpsVui.setCrossLayerIrapAlignedFlag   ( false   );
     2340  }
     2341  vps.setVPSVUI( vpsVui );
     2342}
     2343
     2344#if NH_3D
    21562345Void TAppEncTop::xSetCamPara                ( TComVPS& vps )
    21572346{
     
    21982387
    21992388
    2200 #if H_3D
    2201 
    2202 Void TAppEncTop::xDeriveDltArray( TComVPS& vps, TComDLT& dlt )
     2389#if NH_3D_DLT
     2390Void TAppEncTop::xDeriveDltArray( TComVPS& vps, TComDLT* dlt )
    22032391{
    22042392  Int  iNumDepthViews  = 0;
     
    22142402    }
    22152403
    2216     dlt.setUseDLTFlag( layer , isDepth && m_useDLT );
    2217     if( dlt.getUseDLTFlag( layer ) )
    2218     {
    2219       xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod[layer], 24), &vps, &dlt);
    2220       bDltPresentFlag = bDltPresentFlag || dlt.getUseDLTFlag(layer);
    2221       dlt.setInterViewDltPredEnableFlag(layer, (dlt.getUseDLTFlag(layer) && (layer>1)));
    2222     }
    2223   }
    2224 
    2225   dlt.setDltPresentFlag( bDltPresentFlag );
    2226   dlt.setNumDepthViews ( iNumDepthViews  );
     2404    dlt->setUseDLTFlag( layer , isDepth && m_useDLT );
     2405    if( dlt->getUseDLTFlag( layer ) )
     2406    {
     2407      xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod[layer], 24), &vps, dlt);
     2408      bDltPresentFlag = bDltPresentFlag || dlt->getUseDLTFlag(layer);
     2409      dlt->setInterViewDltPredEnableFlag(layer, (dlt->getUseDLTFlag(layer) && (layer>1)));
     2410     
     2411      // ----------------------------- determine whether to use bit-map -----------------------------
     2412      Bool bDltBitMapRepFlag       = false;
     2413      UInt uiNumBitsNonBitMap      = 0;
     2414      UInt uiNumBitsBitMap         = 0;
     2415     
     2416      UInt uiMaxDiff               = 0;
     2417      UInt uiMinDiff               = MAX_INT;
     2418      UInt uiLengthMinDiff         = 0;
     2419      UInt uiLengthDltDiffMinusMin = 0;
     2420     
     2421      std::vector<Int> aiIdx2DepthValue_coded(256, 0);
     2422      UInt uiNumDepthValues_coded = 0;
     2423     
     2424      uiNumDepthValues_coded = dlt->getNumDepthValues(layer);
     2425      for( UInt ui = 0; ui<uiNumDepthValues_coded; ui++ )
     2426      {
     2427        aiIdx2DepthValue_coded[ui] = dlt->idx2DepthValue(layer, ui);
     2428      }
     2429     
     2430      if( dlt->getInterViewDltPredEnableFlag( layer ) )
     2431      {
     2432        AOF( vps.getDepthId( 1 ) == 1 );
     2433        AOF( layer > 1 );
     2434        // assumes ref layer id to be 1
     2435        std::vector<Int> piRefDLT = dlt->idx2DepthValue( 1 );
     2436        UInt uiRefNum = dlt->getNumDepthValues( 1 );
     2437        dlt->getDeltaDLT(layer, piRefDLT, uiRefNum, aiIdx2DepthValue_coded, uiNumDepthValues_coded);
     2438      }
     2439     
     2440      std::vector<UInt> puiDltDiffValues(uiNumDepthValues_coded, 0);
     2441     
     2442      for (UInt d = 1; d < uiNumDepthValues_coded; d++)
     2443      {
     2444        puiDltDiffValues[d] = aiIdx2DepthValue_coded[d] - aiIdx2DepthValue_coded[d-1];
     2445       
     2446        if ( uiMaxDiff < puiDltDiffValues[d] )
     2447        {
     2448          uiMaxDiff = puiDltDiffValues[d];
     2449        }
     2450       
     2451        if ( uiMinDiff > puiDltDiffValues[d] )
     2452        {
     2453          uiMinDiff = puiDltDiffValues[d];
     2454        }
     2455      }
     2456     
     2457      // counting bits
     2458      // diff coding branch
     2459      uiNumBitsNonBitMap += 8;                          // u(v) bits for num_depth_values_in_dlt[layerId] (i.e. num_entry[ layerId ])
     2460     
     2461      if ( uiNumDepthValues_coded > 1 )
     2462      {
     2463        uiNumBitsNonBitMap += 8;                        // u(v) bits for max_diff[ layerId ]
     2464      }
     2465     
     2466      if ( uiNumDepthValues_coded > 2 )
     2467      {
     2468        uiLengthMinDiff    = (UInt) gCeilLog2(uiMaxDiff + 1);
     2469        uiNumBitsNonBitMap += uiLengthMinDiff;          // u(v)  bits for min_diff[ layerId ]
     2470      }
     2471     
     2472      uiNumBitsNonBitMap += 8;                          // u(v) bits for dlt_depth_value0[ layerId ]
     2473     
     2474      if (uiMaxDiff > uiMinDiff)
     2475      {
     2476        uiLengthDltDiffMinusMin = (UInt) gCeilLog2(uiMaxDiff - uiMinDiff + 1);
     2477        uiNumBitsNonBitMap += uiLengthDltDiffMinusMin * (uiNumDepthValues_coded - 1);  // u(v) bits for dlt_depth_value_diff_minus_min[ layerId ][ j ]
     2478      }
     2479     
     2480      // bit map branch
     2481      uiNumBitsBitMap = 1 << m_inputBitDepth[CHANNEL_TYPE_LUMA];
     2482     
     2483      // determine bDltBitMapFlag
     2484      bDltBitMapRepFlag = (uiNumBitsBitMap > uiNumBitsNonBitMap) ? false : true;
     2485     
     2486      dlt->setUseBitmapRep(layer, bDltBitMapRepFlag);
     2487    }
     2488  }
     2489
     2490  dlt->setDltPresentFlag( bDltPresentFlag );
     2491  dlt->setNumDepthViews ( iNumDepthViews  );
     2492  dlt->setDepthViewBitDepth( m_inputBitDepth[CHANNEL_TYPE_LUMA] );
    22272493}
    22282494#endif
Note: See TracChangeset for help on using the changeset viewer.