Changeset 1377 in SHVCSoftware for branches/SHM-dev/source/App


Ignore:
Timestamp:
23 Jul 2015, 01:02:36 (9 years ago)
Author:
seregin
Message:

dynamic memory allocation at encoder

Location:
branches/SHM-dev/source/App
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp

    r1323 r1377  
    9292  ("BitstreamFile,b",           cfg_BitstreamFile,                     string(""), "bitstream input file name")
    9393#if SVC_EXTENSION
    94   ("ReconFileL%d,-o%d",   cfg_ReconFile,   string(""), MAX_LAYERS, "Layer %d reconstructed YUV output file name\n"
    95                                                      "YUV writing is skipped if omitted")
     94  ("ReconFileL%d,-o%d",                   cfg_ReconFile,   string(""), MAX_LAYERS, "Layer %d reconstructed YUV output file name\n"
     95                                                                                   "YUV writing is skipped if omitted")
    9696#if AVC_BASE
    97   ("BLReconFile,-ibl",    cfg_BLReconFile,  string(""), "BL reconstructed YUV input file name")
    98 #endif
    99   ("TargetLayerId,-lid", targetLayerId, -1, "Target layer id")
    100   ("LayerNum,-ls", layerNum, MAX_NUM_LAYER_IDS, "Target layer id") // Legacy option
    101   ("OutpuLayerSetIdx,-olsidx", olsIdx, -1, "Index of output layer set to be decoded.")
    102 #if CONFORMANCE_BITSTREAM_MODE
    103   ("ConformanceBitstremMode,-confMode", m_confModeFlag, false, "Enable generation of conformance bitstream metadata; True: Generate metadata, False: No metadata generated")
    104   ("ConformanceMetadataPrefix,-confPrefix", cfg_confPrefix, string(""), "Prefix for the file name of the conformance data. Default name - 'decodedBitstream'")
     97  ("BLReconFile,-ibl",                               cfg_BLReconFile,  string(""), "BL reconstructed YUV input file name")
     98#endif
     99  ("TargetLayerId,-lid",                                        targetLayerId, -1, "Target layer id")
     100  ("LayerNum,-ls",                                    layerNum, MAX_NUM_LAYER_IDS, "Target layer id") // Legacy option
     101  ("OutpuLayerSetIdx,-olsidx",                                         olsIdx, -1, "Index of output layer set to be decoded.")
     102#if CONFORMANCE_BITSTREAM_MODE
     103  ("ConformanceBitstremMode,-confMode",                     m_confModeFlag, false, "Enable generation of conformance bitstream metadata; True: Generate metadata, False: No metadata generated")
     104  ("ConformanceMetadataPrefix,           -confPrefix", cfg_confPrefix, string(""), "Prefix for the file name of the conformance data. Default name - 'decodedBitstream'")
    105105#endif
    106106#else
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r1375 r1377  
    122122, m_elRapSliceBEnabled(0)
    123123{
    124   for(UInt layer=0; layer<MAX_LAYERS; layer++)
    125   {
    126     m_acLayerCfg[layer].setAppEncCfg(this);
    127   }
     124  memset( m_apcLayerCfg, NULL, sizeof(m_apcLayerCfg) );
    128125  memset( m_scalabilityMask, 0, sizeof(m_scalabilityMask) );
    129126}
     
    186183{
    187184#if SVC_EXTENSION
    188   for(Int layer = 0; layer < MAX_LAYERS; layer++)
    189   {
    190     if( m_acLayerCfg[layer].m_numSamplePredRefLayers > 0 )
    191     {
    192       delete [] m_acLayerCfg[layer].m_samplePredRefLayerIds;
    193       m_acLayerCfg[layer].m_samplePredRefLayerIds = NULL;
    194     }
    195     if( m_acLayerCfg[layer].m_numMotionPredRefLayers > 0 )
    196     {
    197       delete [] m_acLayerCfg[layer].m_motionPredRefLayerIds;
    198       m_acLayerCfg[layer].m_motionPredRefLayerIds = NULL;
    199     }
    200     if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 )
    201     {
    202       delete [] m_acLayerCfg[layer].m_predLayerIds;
    203       m_acLayerCfg[layer].m_predLayerIds = NULL;
     185  for( Int layer = 0; layer < m_numLayers; layer++ )
     186  {
     187    if( m_apcLayerCfg[layer]->m_numSamplePredRefLayers > 0 )
     188    {
     189      delete [] m_apcLayerCfg[layer]->m_samplePredRefLayerIds;
     190      m_apcLayerCfg[layer]->m_samplePredRefLayerIds = NULL;
     191    }
     192    if( m_apcLayerCfg[layer]->m_numMotionPredRefLayers > 0 )
     193    {
     194      delete [] m_apcLayerCfg[layer]->m_motionPredRefLayerIds;
     195      m_apcLayerCfg[layer]->m_motionPredRefLayerIds = NULL;
     196    }
     197    if( m_apcLayerCfg[layer]->m_numActiveRefLayers > 0 )
     198    {
     199      delete [] m_apcLayerCfg[layer]->m_predLayerIds;
     200      m_apcLayerCfg[layer]->m_predLayerIds = NULL;
     201    }
     202    if( m_apcLayerCfg[layer] )
     203    {
     204      delete m_apcLayerCfg[layer];
     205      m_apcLayerCfg[layer] = NULL;
    204206    }
    205207  }
     
    752754// ====================================================================================================================
    753755
     756#if SVC_EXTENSION
     757/** \param  argc        number of arguments
     758    \param  argv        array of arguments
     759    \retval             true when success
     760 */
     761Bool TAppEncCfg::parseCfgNumLayersAndInit( Int argc, Char* argv[] )
     762{
     763  po::Options opts;
     764  opts.addOptions()
     765  ("c",    po::parseConfigFile, "configuration file name")
     766  ("NumLayers",                                     m_numLayers,                                             1, "Number of layers to code")
     767  ;
     768
     769  po::setDefaults(opts);
     770  po::ErrorReporter err;
     771  err.verbose = false;
     772  po::scanArgv(opts, argc, (const Char**) argv, err);
     773
     774  if( m_numLayers <= 0 )
     775  {
     776    printf("Wrong number of layers %d\n", m_numLayers);
     777    return false;
     778  }
     779
     780  for( Int layer = 0; layer < m_numLayers; layer++ )
     781  {
     782    m_apcLayerCfg[layer] = new TAppEncLayerCfg;
     783    m_apcLayerCfg[layer]->setAppEncCfg(this);
     784  }
     785
     786  return true;
     787}
     788#endif
     789
    754790/** \param  argc        number of arguments
    755791    \param  argv        array of arguments
     
    866902  Int*    cfg_layerPTLIdx[MAX_VPS_LAYER_IDX_PLUS1];
    867903
    868   for( UInt layer = 0; layer < MAX_LAYERS; layer++ )
    869   {
    870     cfg_InputFile[layer]    = &m_acLayerCfg[layer].m_cInputFile;
    871     cfg_ReconFile[layer]    = &m_acLayerCfg[layer].m_cReconFile;
    872     cfg_fQP[layer]          = &m_acLayerCfg[layer].m_fQP;
     904  for( UInt layer = 0; layer < m_numLayers; layer++ )
     905  {
     906    cfg_InputFile[layer]    = &m_apcLayerCfg[layer]->m_cInputFile;
     907    cfg_ReconFile[layer]    = &m_apcLayerCfg[layer]->m_cReconFile;
     908    cfg_fQP[layer]          = &m_apcLayerCfg[layer]->m_fQP;
    873909#if Q0074_COLOUR_REMAPPING_SEI
    874     cfg_colourRemapSEIFileRoot[layer] = &m_acLayerCfg[layer].m_colourRemapSEIFileRoot;
    875 #endif
    876     cfg_repFormatIdx[layer]         = &m_acLayerCfg[layer].m_repFormatIdx;
    877     cfg_layerId[layer]              = &m_acLayerCfg[layer].m_layerId;
    878     cfg_SourceWidth[layer]          = &m_acLayerCfg[layer].m_iSourceWidth;
    879     cfg_SourceHeight[layer]         = &m_acLayerCfg[layer].m_iSourceHeight;
    880     cfg_FrameRate[layer]            = &m_acLayerCfg[layer].m_iFrameRate;
    881     cfg_IntraPeriod[layer]          = &m_acLayerCfg[layer].m_iIntraPeriod;
    882     cfg_conformanceMode[layer]      = &m_acLayerCfg[layer].m_conformanceMode;
    883     cfg_confWinLeft[layer]          = &m_acLayerCfg[layer].m_confWinLeft;
    884     cfg_confWinRight[layer]         = &m_acLayerCfg[layer].m_confWinRight;
    885     cfg_confWinTop[layer]           = &m_acLayerCfg[layer].m_confWinTop;
    886     cfg_confWinBottom[layer]        = &m_acLayerCfg[layer].m_confWinBottom;
    887     cfg_aiPadX[layer]               = &m_acLayerCfg[layer].m_aiPad[0];
    888     cfg_aiPadY[layer]               = &m_acLayerCfg[layer].m_aiPad[1];
    889     cfg_useExtendedPrecision[layer] = &m_acLayerCfg[layer].m_extendedPrecisionProcessingFlag;
    890 
    891     cfg_maxCuDQPDepth[layer]        = &m_acLayerCfg[layer].m_iMaxCuDQPDepth;
     910    cfg_colourRemapSEIFileRoot[layer] = &m_apcLayerCfg[layer]->m_colourRemapSEIFileRoot;
     911#endif
     912    cfg_repFormatIdx[layer]         = &m_apcLayerCfg[layer]->m_repFormatIdx;
     913    cfg_layerId[layer]              = &m_apcLayerCfg[layer]->m_layerId;
     914    cfg_SourceWidth[layer]          = &m_apcLayerCfg[layer]->m_iSourceWidth;
     915    cfg_SourceHeight[layer]         = &m_apcLayerCfg[layer]->m_iSourceHeight;
     916    cfg_FrameRate[layer]            = &m_apcLayerCfg[layer]->m_iFrameRate;
     917    cfg_IntraPeriod[layer]          = &m_apcLayerCfg[layer]->m_iIntraPeriod;
     918    cfg_conformanceMode[layer]      = &m_apcLayerCfg[layer]->m_conformanceMode;
     919    cfg_confWinLeft[layer]          = &m_apcLayerCfg[layer]->m_confWinLeft;
     920    cfg_confWinRight[layer]         = &m_apcLayerCfg[layer]->m_confWinRight;
     921    cfg_confWinTop[layer]           = &m_apcLayerCfg[layer]->m_confWinTop;
     922    cfg_confWinBottom[layer]        = &m_apcLayerCfg[layer]->m_confWinBottom;
     923    cfg_aiPadX[layer]               = &m_apcLayerCfg[layer]->m_aiPad[0];
     924    cfg_aiPadY[layer]               = &m_apcLayerCfg[layer]->m_aiPad[1];
     925    cfg_useExtendedPrecision[layer] = &m_apcLayerCfg[layer]->m_extendedPrecisionProcessingFlag;
     926
     927    cfg_maxCuDQPDepth[layer]        = &m_apcLayerCfg[layer]->m_iMaxCuDQPDepth;
    892928
    893929    // coding unit (CU) definition
    894     cfg_uiMaxCUWidth[layer]  = &m_acLayerCfg[layer].m_uiMaxCUWidth;
    895     cfg_uiMaxCUHeight[layer] = &m_acLayerCfg[layer].m_uiMaxCUHeight;
    896     cfg_uiMaxCUDepth[layer]  = &m_acLayerCfg[layer].m_uiMaxCUDepth;
     930    cfg_uiMaxCUWidth[layer]  = &m_apcLayerCfg[layer]->m_uiMaxCUWidth;
     931    cfg_uiMaxCUHeight[layer] = &m_apcLayerCfg[layer]->m_uiMaxCUHeight;
     932    cfg_uiMaxCUDepth[layer]  = &m_apcLayerCfg[layer]->m_uiMaxCUDepth;
    897933
    898934    // transfom unit (TU) definition.
    899     cfg_uiQuadtreeTULog2MaxSize[layer] = &m_acLayerCfg[layer].m_uiQuadtreeTULog2MaxSize;
    900     cfg_uiQuadtreeTULog2MinSize[layer] = &m_acLayerCfg[layer].m_uiQuadtreeTULog2MinSize;
    901 
    902     cfg_uiQuadtreeTUMaxDepthInter[layer] = &m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthInter;
    903     cfg_uiQuadtreeTUMaxDepthIntra[layer] = &m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthIntra;
    904 
    905     cfg_numSamplePredRefLayers  [layer] = &m_acLayerCfg[layer].m_numSamplePredRefLayers;
     935    cfg_uiQuadtreeTULog2MaxSize[layer] = &m_apcLayerCfg[layer]->m_uiQuadtreeTULog2MaxSize;
     936    cfg_uiQuadtreeTULog2MinSize[layer] = &m_apcLayerCfg[layer]->m_uiQuadtreeTULog2MinSize;
     937
     938    cfg_uiQuadtreeTUMaxDepthInter[layer] = &m_apcLayerCfg[layer]->m_uiQuadtreeTUMaxDepthInter;
     939    cfg_uiQuadtreeTUMaxDepthIntra[layer] = &m_apcLayerCfg[layer]->m_uiQuadtreeTUMaxDepthIntra;
     940
     941    cfg_numSamplePredRefLayers  [layer] = &m_apcLayerCfg[layer]->m_numSamplePredRefLayers;
    906942    cfg_samplePredRefLayerIdsPtr[layer] = &cfg_samplePredRefLayerIds[layer];
    907     cfg_numMotionPredRefLayers  [layer] = &m_acLayerCfg[layer].m_numMotionPredRefLayers;
     943    cfg_numMotionPredRefLayers  [layer] = &m_apcLayerCfg[layer]->m_numMotionPredRefLayers;
    908944    cfg_motionPredRefLayerIdsPtr[layer] = &cfg_motionPredRefLayerIds[layer];
    909     cfg_numActiveRefLayers  [layer] = &m_acLayerCfg[layer].m_numActiveRefLayers;
     945    cfg_numActiveRefLayers  [layer] = &m_apcLayerCfg[layer]->m_numActiveRefLayers;
    910946    cfg_predLayerIdsPtr     [layer] = &cfg_predLayerIds[layer];
    911947
    912     cfg_numRefLayerLocationOffsets [layer] = &m_acLayerCfg[layer].m_numRefLayerLocationOffsets;
    913     cfg_waveFrontSynchro[layer]  = &m_acLayerCfg[layer].m_waveFrontSynchro;
    914     for(Int i = 0; i < MAX_LAYERS; i++)
     948    cfg_numRefLayerLocationOffsets [layer] = &m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets;
     949    cfg_waveFrontSynchro[layer]  = &m_apcLayerCfg[layer]->m_waveFrontSynchro;
     950    for(Int i = 0; i < m_numLayers; i++)
    915951    {
    916952      cfg_refLocationOffsetLayerIdPtr  [layer] = &cfg_refLocationOffsetLayerId[layer];
     
    932968    }
    933969#if RC_SHVC_HARMONIZATION
    934     cfg_RCEnableRateControl[layer]   = &m_acLayerCfg[layer].m_RCEnableRateControl;
    935     cfg_RCTargetBitRate[layer]       = &m_acLayerCfg[layer].m_RCTargetBitrate;
    936     cfg_RCKeepHierarchicalBit[layer] = &m_acLayerCfg[layer].m_RCKeepHierarchicalBit;
    937     cfg_RCLCULevelRC[layer]          = &m_acLayerCfg[layer].m_RCLCULevelRC;
    938     cfg_RCUseLCUSeparateModel[layer] = &m_acLayerCfg[layer].m_RCUseLCUSeparateModel;
    939     cfg_RCInitialQP[layer]           = &m_acLayerCfg[layer].m_RCInitialQP;
    940     cfg_RCForceIntraQP[layer]        = &m_acLayerCfg[layer].m_RCForceIntraQP;
    941 #endif
    942 
    943     cfg_InputBitDepth   [CHANNEL_TYPE_LUMA][layer] = &m_acLayerCfg[layer].m_inputBitDepth[CHANNEL_TYPE_LUMA];
    944     cfg_InternalBitDepth[CHANNEL_TYPE_LUMA][layer] = &m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA];
    945     cfg_OutputBitDepth  [CHANNEL_TYPE_LUMA][layer] = &m_acLayerCfg[layer].m_outputBitDepth[CHANNEL_TYPE_LUMA];
    946     cfg_InternalBitDepth[CHANNEL_TYPE_CHROMA][layer] = &m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA];
    947     cfg_InputBitDepth   [CHANNEL_TYPE_CHROMA][layer] = &m_acLayerCfg[layer].m_inputBitDepth[CHANNEL_TYPE_CHROMA];
    948     cfg_OutputBitDepth  [CHANNEL_TYPE_CHROMA][layer] = &m_acLayerCfg[layer].m_outputBitDepth[CHANNEL_TYPE_CHROMA];
    949 
    950     cfg_maxTidIlRefPicsPlus1[layer] = &m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1;
     970    cfg_RCEnableRateControl[layer]   = &m_apcLayerCfg[layer]->m_RCEnableRateControl;
     971    cfg_RCTargetBitRate[layer]       = &m_apcLayerCfg[layer]->m_RCTargetBitrate;
     972    cfg_RCKeepHierarchicalBit[layer] = &m_apcLayerCfg[layer]->m_RCKeepHierarchicalBit;
     973    cfg_RCLCULevelRC[layer]          = &m_apcLayerCfg[layer]->m_RCLCULevelRC;
     974    cfg_RCUseLCUSeparateModel[layer] = &m_apcLayerCfg[layer]->m_RCUseLCUSeparateModel;
     975    cfg_RCInitialQP[layer]           = &m_apcLayerCfg[layer]->m_RCInitialQP;
     976    cfg_RCForceIntraQP[layer]        = &m_apcLayerCfg[layer]->m_RCForceIntraQP;
     977#endif
     978
     979    cfg_InputBitDepth   [CHANNEL_TYPE_LUMA][layer] = &m_apcLayerCfg[layer]->m_inputBitDepth[CHANNEL_TYPE_LUMA];
     980    cfg_InternalBitDepth[CHANNEL_TYPE_LUMA][layer] = &m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA];
     981    cfg_OutputBitDepth  [CHANNEL_TYPE_LUMA][layer] = &m_apcLayerCfg[layer]->m_outputBitDepth[CHANNEL_TYPE_LUMA];
     982    cfg_InternalBitDepth[CHANNEL_TYPE_CHROMA][layer] = &m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA];
     983    cfg_InputBitDepth   [CHANNEL_TYPE_CHROMA][layer] = &m_apcLayerCfg[layer]->m_inputBitDepth[CHANNEL_TYPE_CHROMA];
     984    cfg_OutputBitDepth  [CHANNEL_TYPE_CHROMA][layer] = &m_apcLayerCfg[layer]->m_outputBitDepth[CHANNEL_TYPE_CHROMA];
     985
     986    cfg_maxTidIlRefPicsPlus1[layer] = &m_apcLayerCfg[layer]->m_maxTidIlRefPicsPlus1;
    951987#if AUXILIARY_PICTURES
    952     cfg_auxId[layer]                = &m_acLayerCfg[layer].m_auxId;
    953 #endif
    954     cfg_layerSwitchOffBegin[layer]  = &m_acLayerCfg[layer].m_layerSwitchOffBegin;
    955     cfg_layerSwitchOffEnd[layer]    = &m_acLayerCfg[layer].m_layerSwitchOffEnd;
    956     cfg_layerPTLIdx[layer]          = &m_acLayerCfg[layer].m_layerPTLIdx;
     988    cfg_auxId[layer]                = &m_apcLayerCfg[layer]->m_auxId;
     989#endif
     990    cfg_layerSwitchOffBegin[layer]  = &m_apcLayerCfg[layer]->m_layerSwitchOffBegin;
     991    cfg_layerSwitchOffEnd[layer]    = &m_apcLayerCfg[layer]->m_layerSwitchOffEnd;
     992    cfg_layerPTLIdx[layer]          = &m_apcLayerCfg[layer]->m_layerPTLIdx;
    957993  }
    958994
     
    10641100  // File, I/O and source parameters
    10651101#if SVC_EXTENSION
    1066   ("InputFile%d,-i%d",                              cfg_InputFile,                      string(""), MAX_LAYERS, "original YUV input file name for layer %d")
    1067   ("ReconFile%d,-o%d",                              cfg_ReconFile,                      string(""), MAX_LAYERS, "reconstruction YUV input file name for layer %d")
    1068   ("LayerConfig%d,-lc%d",                           cfg_LayerCfgFile,                   string(""), MAX_LAYERS, "layer %d configuration file name")
    1069   ("SourceWidth%d,-wdt%d",                          cfg_SourceWidth,                             0, MAX_LAYERS, "Source picture width for layer %d")
    1070   ("SourceHeight%d,-hgt%d",                         cfg_SourceHeight,                            0, MAX_LAYERS, "Source picture height for layer %d")
    1071   ("FrameRate%d,-fr%d",                             cfg_FrameRate,                               0, MAX_LAYERS, "Frame rate for layer %d")
    1072   ("LambdaModifier%d,-LM%d",                        m_adLambdaModifier,                Double(1.0), MAX_TLAYER, "Lambda modifier for temporal layer %d")
    1073   ("RepFormatIdx%d",                                cfg_repFormatIdx,                           -1, MAX_LAYERS, "Index to the representation format structure used from the VPS")
    1074   ("LayerId%d",                                     cfg_layerId,                                -1, MAX_LAYERS,  "Layer id")
    1075 
    1076   ("NumSamplePredRefLayers%d",                      cfg_numSamplePredRefLayers,                 -1, MAX_LAYERS, "Number of sample prediction reference layers")
    1077   ("SamplePredRefLayerIds%d",                       cfg_samplePredRefLayerIdsPtr,       string(""), MAX_LAYERS, "sample pred reference layer IDs")
    1078   ("NumMotionPredRefLayers%d",                      cfg_numMotionPredRefLayers,                 -1, MAX_LAYERS, "Number of motion prediction reference layers")
    1079   ("MotionPredRefLayerIds%d",                       cfg_motionPredRefLayerIdsPtr,       string(""), MAX_LAYERS, "motion pred reference layer IDs")
    1080   ("NumActiveRefLayers%d",                          cfg_numActiveRefLayers,                     -1, MAX_LAYERS, "Number of active reference layers")
    1081   ("PredLayerIds%d",                                cfg_predLayerIdsPtr,                string(""), MAX_LAYERS, "inter-layer prediction layer IDs")
    1082 
    1083   ("NumLayers",                                     m_numLayers,                                             1, "Number of layers to code") 
    1084 
    1085   ("NumLayerSets",                                  m_numLayerSets,                                          1, "Number of layer sets")
    1086   ("NumLayerInIdList%d",                            cfg_numLayerInIdList,            0, MAX_VPS_LAYER_IDX_PLUS1, "Number of layers in the set")
    1087   ("LayerSetLayerIdList%d",                         cfg_layerSetLayerIdListPtr, string(""), MAX_VPS_LAYER_IDX_PLUS1, "Layer IDs for the set")
    1088   ("NumAddLayerSets",                               m_numAddLayerSets,                                       0, "Number of additional layer sets")
    1089   ("NumHighestLayerIdx%d",                          cfg_numHighestLayerIdx,          0, MAX_VPS_LAYER_IDX_PLUS1, "Number of highest layer idx")
    1090   ("HighestLayerIdx%d",                             cfg_highestLayerIdxPtr, string(""), MAX_VPS_LAYER_IDX_PLUS1, "Highest layer idx for an additional layer set")
    1091 
    1092   ("DefaultTargetOutputLayerIdc",                   m_defaultTargetOutputLayerIdc,                           1, "Default target output layers. 0: All layers are output layer, 1: Only highest layer is output layer, 2 or 3: No default output layers")
    1093   ("NumOutputLayerSets",                            m_numOutputLayerSets,                                    1, "Number of output layer sets excluding the 0-th output layer set")
    1094   ("NumOutputLayersInOutputLayerSet",               cfg_numOutputLayersInOutputLayerSet,         string(""), 1, "List containing number of output layers in the output layer sets")
    1095   ("ListOfOutputLayers%d",                          cfg_listOfOutputLayers, string(""), MAX_VPS_LAYER_IDX_PLUS1, "Layer IDs for the set, in terms of layer ID in the output layer set Range: [0..NumLayersInOutputLayerSet-1]")
    1096   ("OutputLayerSetIdx",                             cfg_outputLayerSetIdx,                       string(""), 1, "Corresponding layer set index, only for non-default output layer sets")
     1102  ("InputFile%d,-i%d",                              cfg_InputFile,                    string(""), m_numLayers, "original YUV input file name for layer %d")
     1103  ("ReconFile%d,-o%d",                              cfg_ReconFile,                    string(""), m_numLayers, "reconstruction YUV input file name for layer %d")
     1104  ("LayerConfig%d,-lc%d",                           cfg_LayerCfgFile,                 string(""), m_numLayers, "layer %d configuration file name")
     1105  ("SourceWidth%d,-wdt%d",                          cfg_SourceWidth,                           0, m_numLayers, "Source picture width for layer %d")
     1106  ("SourceHeight%d,-hgt%d",                         cfg_SourceHeight,                          0, m_numLayers, "Source picture height for layer %d")
     1107  ("FrameRate%d,-fr%d",                             cfg_FrameRate,                             0, m_numLayers, "Frame rate for layer %d")
     1108  ("LambdaModifier%d,-LM%d",                        m_adLambdaModifier,               Double(1.0), MAX_TLAYER, "Lambda modifier for temporal layer %d")
     1109  ("RepFormatIdx%d",                                cfg_repFormatIdx,                         -1, m_numLayers, "Index to the representation format structure used from the VPS")
     1110  ("LayerId%d",                                     cfg_layerId,                              -1, m_numLayers,  "Layer id")
     1111
     1112  ("NumSamplePredRefLayers%d",                      cfg_numSamplePredRefLayers,               -1, m_numLayers, "Number of sample prediction reference layers")
     1113  ("SamplePredRefLayerIds%d",                       cfg_samplePredRefLayerIdsPtr,     string(""), m_numLayers, "sample pred reference layer IDs")
     1114  ("NumMotionPredRefLayers%d",                      cfg_numMotionPredRefLayers,               -1, m_numLayers, "Number of motion prediction reference layers")
     1115  ("MotionPredRefLayerIds%d",                       cfg_motionPredRefLayerIdsPtr,     string(""), m_numLayers, "motion pred reference layer IDs")
     1116  ("NumActiveRefLayers%d",                          cfg_numActiveRefLayers,                   -1, m_numLayers, "Number of active reference layers")
     1117  ("PredLayerIds%d",                                cfg_predLayerIdsPtr,              string(""), m_numLayers, "inter-layer prediction layer IDs")
     1118
     1119  ("NumLayers",                                     m_numLayers,                                            1, "Number of layers to code") 
     1120
     1121  ("NumLayerSets",                                  m_numLayerSets,                                         1, "Number of layer sets")
     1122  ("NumLayerInIdList%d",                            cfg_numLayerInIdList,          0, MAX_VPS_LAYER_IDX_PLUS1, "Number of layers in the set")
     1123  ("LayerSetLayerIdList%d",                   cfg_layerSetLayerIdListPtr, string(""), MAX_VPS_LAYER_IDX_PLUS1, "Layer IDs for the set")
     1124  ("NumAddLayerSets",                               m_numAddLayerSets,                                      0, "Number of additional layer sets")
     1125  ("NumHighestLayerIdx%d",                        cfg_numHighestLayerIdx,          0, MAX_VPS_LAYER_IDX_PLUS1, "Number of highest layer idx")
     1126  ("HighestLayerIdx%d",                           cfg_highestLayerIdxPtr, string(""), MAX_VPS_LAYER_IDX_PLUS1, "Highest layer idx for an additional layer set")
     1127
     1128  ("DefaultTargetOutputLayerIdc",                   m_defaultTargetOutputLayerIdc,                          1, "Default target output layers. 0: All layers are output layer, 1: Only highest layer is output layer, 2 or 3: No default output layers")
     1129  ("NumOutputLayerSets",                            m_numOutputLayerSets,                                   1, "Number of output layer sets excluding the 0-th output layer set")
     1130  ("NumOutputLayersInOutputLayerSet",               cfg_numOutputLayersInOutputLayerSet,        string(""), 1, "List containing number of output layers in the output layer sets")
     1131  ("ListOfOutputLayers%d",                        cfg_listOfOutputLayers, string(""), MAX_VPS_LAYER_IDX_PLUS1, "Layer IDs for the set, in terms of layer ID in the output layer set Range: [0..NumLayersInOutputLayerSet-1]")
     1132  ("OutputLayerSetIdx",                             cfg_outputLayerSetIdx,                      string(""), 1, "Corresponding layer set index, only for non-default output layer sets")
    10971133#if AUXILIARY_PICTURES
    1098   ("AuxId%d",                                       cfg_auxId,                                   0, MAX_LAYERS, "Auxilary picture ID for layer %d (0: Not aux pic, 1: Alpha plane, 2: Depth picture, 3: Cb enh, 4: Cr enh")
    1099 #endif
    1100   ("ExtendedPrecision%d",                           cfg_useExtendedPrecision,                false, MAX_LAYERS, "Increased internal accuracies to support high bit depths (not valid in V1 profiles)")
    1101   ("ConformanceMode%d",                             cfg_conformanceMode,                         0, MAX_LAYERS, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
    1102   ("ConfLeft%d",                                    cfg_confWinLeft,                             0, MAX_LAYERS, "Deprecated alias of ConfWinLeft")
    1103   ("ConfRight%d",                                   cfg_confWinRight,                            0, MAX_LAYERS, "Deprecated alias of ConfWinRight")
    1104   ("ConfTop%d",                                     cfg_confWinTop,                              0, MAX_LAYERS, "Deprecated alias of ConfWinTop")
    1105   ("ConfBottom%d",                                  cfg_confWinBottom,                           0, MAX_LAYERS, "Deprecated alias of ConfWinBottom")
    1106   ("ConfWinLeft%d",                                 cfg_confWinLeft,                             0, MAX_LAYERS, "Left offset for window conformance mode 3")
    1107   ("ConfWinRight%d",                                cfg_confWinRight,                            0, MAX_LAYERS, "Right offset for window conformance mode 3")
    1108   ("ConfWinTop%d",                                  cfg_confWinTop,                              0, MAX_LAYERS, "Top offset for window conformance mode 3")
    1109   ("ConfWinBottom%d",                               cfg_confWinBottom,                           0, MAX_LAYERS, "Bottom offset for window conformance mode 3")
    1110   ("HorizontalPadding%d,-pdx%d",                    cfg_aiPadX,                                  0, MAX_LAYERS, "Horizontal source padding for conformance window mode 2")
    1111   ("VerticalPadding%d,-pdy%d",                      cfg_aiPadY,                                  0, MAX_LAYERS, "Vertical source padding for conformance window mode 2")
    1112   ("ScalabilityMask1",                              m_scalabilityMask[VIEW_ORDER_INDEX],                     0, "scalability_mask[1] (multiview)")
    1113   ("ScalabilityMask2",                              m_scalabilityMask[SCALABILITY_ID],                       1, "scalability_mask[2] (scalable)" )
     1134  ("AuxId%d",                                       cfg_auxId,                                 0, m_numLayers, "Auxilary picture ID for layer %d (0: Not aux pic, 1: Alpha plane, 2: Depth picture, 3: Cb enh, 4: Cr enh")
     1135#endif
     1136  ("ExtendedPrecision%d",                           cfg_useExtendedPrecision,              false, m_numLayers, "Increased internal accuracies to support high bit depths (not valid in V1 profiles)")
     1137  ("ConformanceMode%d",                             cfg_conformanceMode,                       0, m_numLayers, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
     1138  ("ConfLeft%d",                                    cfg_confWinLeft,                           0, m_numLayers, "Deprecated alias of ConfWinLeft")
     1139  ("ConfRight%d",                                   cfg_confWinRight,                          0, m_numLayers, "Deprecated alias of ConfWinRight")
     1140  ("ConfTop%d",                                     cfg_confWinTop,                            0, m_numLayers, "Deprecated alias of ConfWinTop")
     1141  ("ConfBottom%d",                                  cfg_confWinBottom,                         0, m_numLayers, "Deprecated alias of ConfWinBottom")
     1142  ("ConfWinLeft%d",                                 cfg_confWinLeft,                           0, m_numLayers, "Left offset for window conformance mode 3")
     1143  ("ConfWinRight%d",                                cfg_confWinRight,                          0, m_numLayers, "Right offset for window conformance mode 3")
     1144  ("ConfWinTop%d",                                  cfg_confWinTop,                            0, m_numLayers, "Top offset for window conformance mode 3")
     1145  ("ConfWinBottom%d",                               cfg_confWinBottom,                         0, m_numLayers, "Bottom offset for window conformance mode 3")
     1146  ("HorizontalPadding%d,-pdx%d",                    cfg_aiPadX,                                0, m_numLayers, "Horizontal source padding for conformance window mode 2")
     1147  ("VerticalPadding%d,-pdy%d",                      cfg_aiPadY,                                0, m_numLayers, "Vertical source padding for conformance window mode 2")
     1148  ("ScalabilityMask1",                              m_scalabilityMask[VIEW_ORDER_INDEX],                    0, "scalability_mask[1] (multiview)")
     1149  ("ScalabilityMask2",                              m_scalabilityMask[SCALABILITY_ID],                      1, "scalability_mask[2] (scalable)" )
    11141150#if AUXILIARY_PICTURES
    1115   ("ScalabilityMask3",                              m_scalabilityMask[AUX_ID],                               0, "scalability_mask[3] (auxiliary pictures)" )
    1116 #endif
    1117   ("BitstreamFile,b",                               cfg_BitstreamFile, string(""), "Bitstream output file name")
    1118   ("NumRefLocationOffsets%d",                       cfg_numRefLayerLocationOffsets,              0, MAX_LAYERS,  "Number of reference layer offset sets ")
    1119   ("RefLocationOffsetLayerId%d",                    cfg_refLocationOffsetLayerIdPtr,    string(""), MAX_LAYERS, "Layer ID of reference location offset")
    1120   ("ScaledRefLayerLeftOffset%d",                    cfg_scaledRefLayerLeftOffsetPtr,    string(""), MAX_LAYERS, "Horizontal offset of top-left luma sample of scaled base layer picture with respect to"
     1151  ("ScalabilityMask3",                              m_scalabilityMask[AUX_ID],                              0, "scalability_mask[3] (auxiliary pictures)" )
     1152#endif
     1153  ("BitstreamFile,b",                               cfg_BitstreamFile,                             string(""), "Bitstream output file name")
     1154  ("NumRefLocationOffsets%d",                       cfg_numRefLayerLocationOffsets,            0, m_numLayers,  "Number of reference layer offset sets ")
     1155  ("RefLocationOffsetLayerId%d",                    cfg_refLocationOffsetLayerIdPtr,  string(""), m_numLayers, "Layer ID of reference location offset")
     1156  ("ScaledRefLayerLeftOffset%d",                    cfg_scaledRefLayerLeftOffsetPtr,  string(""), m_numLayers, "Horizontal offset of top-left luma sample of scaled base layer picture with respect to"
    11211157                                                                                                                " top-left luma sample of the EL picture, in units of two luma samples")
    1122   ("ScaledRefLayerTopOffset%d",                     cfg_scaledRefLayerTopOffsetPtr,     string(""), MAX_LAYERS, "Vertical offset of top-left luma sample of scaled base layer picture with respect to"
     1158  ("ScaledRefLayerTopOffset%d",                     cfg_scaledRefLayerTopOffsetPtr,   string(""), m_numLayers, "Vertical offset of top-left luma sample of scaled base layer picture with respect to"
    11231159                                                                                                                " top-left luma sample of the EL picture, in units of two luma samples")
    1124   ("ScaledRefLayerRightOffset%d",                   cfg_scaledRefLayerRightOffsetPtr,   string(""), MAX_LAYERS, "Horizontal offset of bottom-right luma sample of scaled base layer picture with respect to"
     1160  ("ScaledRefLayerRightOffset%d",                   cfg_scaledRefLayerRightOffsetPtr, string(""), m_numLayers, "Horizontal offset of bottom-right luma sample of scaled base layer picture with respect to"
    11251161                                                                                                                " bottom-right luma sample of the EL picture, in units of two luma samples")
    1126   ("ScaledRefLayerBottomOffset%d",                  cfg_scaledRefLayerBottomOffsetPtr,  string(""), MAX_LAYERS, "Vertical offset of bottom-right luma sample of scaled base layer picture with respect to"
     1162  ("ScaledRefLayerBottomOffset%d",                  cfg_scaledRefLayerBottomOffsetPtr,string(""), m_numLayers, "Vertical offset of bottom-right luma sample of scaled base layer picture with respect to"
    11271163                                                                                                                "  bottom-right luma sample of the EL picture, in units of two luma samples")
    1128   ("ScaledRefLayerOffsetPresentFlag%d",         cfg_scaledRefLayerOffsetPresentFlagPtr, string(""), MAX_LAYERS, "presense flag of scaled reference layer offsets")
    1129   ("RefRegionOffsetPresentFlag%d",                  cfg_refRegionOffsetPresentFlagPtr,  string(""), MAX_LAYERS, "presense flag of reference region offsets")
    1130   ("RefRegionLeftOffset%d",                         cfg_refRegionLeftOffsetPtr,         string(""), MAX_LAYERS, "Horizontal offset of top-left luma sample of ref region with respect to"
     1164  ("ScaledRefLayerOffsetPresentFlag%d",        cfg_scaledRefLayerOffsetPresentFlagPtr,string(""), m_numLayers, "presense flag of scaled reference layer offsets")
     1165  ("RefRegionOffsetPresentFlag%d",                  cfg_refRegionOffsetPresentFlagPtr,string(""), m_numLayers, "presense flag of reference region offsets")
     1166  ("RefRegionLeftOffset%d",                         cfg_refRegionLeftOffsetPtr,       string(""), m_numLayers, "Horizontal offset of top-left luma sample of ref region with respect to"
    11311167                                                                                                                "  top-left luma sample of the BL picture, in units of two luma samples")
    1132   ("RefRegionTopOffset%d",                          cfg_refRegionTopOffsetPtr,          string(""), MAX_LAYERS, "Vertical offset of top-left luma sample of ref region with respect to"
     1168  ("RefRegionTopOffset%d",                          cfg_refRegionTopOffsetPtr,        string(""), m_numLayers, "Vertical offset of top-left luma sample of ref region with respect to"
    11331169                                                                                                                "  top-left luma sample of the BL picture, in units of two luma samples")
    1134   ("RefRegionRightOffset%d",                        cfg_refRegionRightOffsetPtr,        string(""), MAX_LAYERS, "Horizontal offset of bottom-right luma sample of ref region with respect to"
     1170  ("RefRegionRightOffset%d",                        cfg_refRegionRightOffsetPtr,      string(""), m_numLayers, "Horizontal offset of bottom-right luma sample of ref region with respect to"
    11351171                                                                                                                "  bottom-right luma sample of the BL picture, in units of two luma samples")
    1136   ("RefRegionBottomOffset%d",                       cfg_refRegionBottomOffsetPtr,       string(""), MAX_LAYERS, "Vertical offset of bottom-right luma sample of ref region with respect to"
     1172  ("RefRegionBottomOffset%d",                       cfg_refRegionBottomOffsetPtr,     string(""), m_numLayers, "Vertical offset of bottom-right luma sample of ref region with respect to"
    11371173                                                                                                                "  bottom-right luma sample of the BL picture, in units of two luma samples")
    1138   ("ResamplePhaseSetPresentFlag%d",                 cfg_resamplePhaseSetPresentFlagPtr, string(""), MAX_LAYERS, "presense flag of resample phase set")
    1139   ("PhaseHorLuma%d",                                cfg_phaseHorLumaPtr,                string(""), MAX_LAYERS, "luma shift in the horizontal direction used in resampling proces")
    1140   ("PhaseVerLuma%d",                                cfg_phaseVerLumaPtr,                string(""), MAX_LAYERS, "luma shift in the vertical   direction used in resampling proces")
    1141   ("PhaseHorChroma%d",                              cfg_phaseHorChromaPtr,              string(""), MAX_LAYERS, "chroma shift in the horizontal direction used in resampling proces")
    1142   ("PhaseVerChroma%d",                              cfg_phaseVerChromaPtr,              string(""), MAX_LAYERS, "chroma shift in the vertical   direction used in resampling proces")
     1174  ("ResamplePhaseSetPresentFlag%d",                cfg_resamplePhaseSetPresentFlagPtr,string(""), m_numLayers, "presense flag of resample phase set")
     1175  ("PhaseHorLuma%d",                                cfg_phaseHorLumaPtr,              string(""), m_numLayers, "luma shift in the horizontal direction used in resampling proces")
     1176  ("PhaseVerLuma%d",                                cfg_phaseVerLumaPtr,              string(""), m_numLayers, "luma shift in the vertical   direction used in resampling proces")
     1177  ("PhaseHorChroma%d",                              cfg_phaseHorChromaPtr,            string(""), m_numLayers, "chroma shift in the horizontal direction used in resampling proces")
     1178  ("PhaseVerChroma%d",                              cfg_phaseVerChromaPtr,            string(""), m_numLayers, "chroma shift in the vertical   direction used in resampling proces")
    11431179#if Q0074_COLOUR_REMAPPING_SEI
    1144   ("SEIColourRemappingInfoFileRoot%d",              cfg_colourRemapSEIFileRoot,           string(""), MAX_LAYERS, "Colour Remapping Information SEI parameters file name for layer %d")
    1145 #endif
    1146   ("InputBitDepth%d",                                cfg_InputBitDepth[CHANNEL_TYPE_LUMA],      8, MAX_LAYERS, "Bit-depth of input file for layer %d")
    1147   ("InternalBitDepth%d",                             cfg_InternalBitDepth[CHANNEL_TYPE_LUMA],   0, MAX_LAYERS, "Bit-depth the codec operates at. (default:InputBitDepth) for layer %d "
     1180  ("SEIColourRemappingInfoFileRoot%d",              cfg_colourRemapSEIFileRoot,       string(""), m_numLayers, "Colour Remapping Information SEI parameters file name for layer %d")
     1181#endif
     1182  ("InputBitDepth%d",                                cfg_InputBitDepth[CHANNEL_TYPE_LUMA],     8, m_numLayers, "Bit-depth of input file for layer %d")
     1183  ("InternalBitDepth%d",                             cfg_InternalBitDepth[CHANNEL_TYPE_LUMA],  0, m_numLayers, "Bit-depth the codec operates at. (default:InputBitDepth) for layer %d "
    11481184                                                                                                               " If different to InputBitDepth, source data will be converted")
    1149   ("OutputBitDepth%d",                               cfg_OutputBitDepth[CHANNEL_TYPE_LUMA],     0, MAX_LAYERS, "Bit-depth of output file (default:InternalBitDepth)")
    1150   ("InputBitDepthC%d",                               cfg_InputBitDepth[CHANNEL_TYPE_CHROMA],    0, MAX_LAYERS, "As per InputBitDepth but for chroma component. (default:InputBitDepth) for layer %d")
    1151   ("InternalBitDepthC%d",                            cfg_InternalBitDepth[CHANNEL_TYPE_CHROMA], 0, MAX_LAYERS, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth) for layer %d")
    1152   ("OutputBitDepthC%d",                              cfg_OutputBitDepth[CHANNEL_TYPE_CHROMA],   0, MAX_LAYERS, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
     1185  ("OutputBitDepth%d",                               cfg_OutputBitDepth[CHANNEL_TYPE_LUMA],    0, m_numLayers, "Bit-depth of output file (default:InternalBitDepth)")
     1186  ("InputBitDepthC%d",                               cfg_InputBitDepth[CHANNEL_TYPE_CHROMA],   0, m_numLayers, "As per InputBitDepth but for chroma component. (default:InputBitDepth) for layer %d")
     1187  ("InternalBitDepthC%d",                            cfg_InternalBitDepth[CHANNEL_TYPE_CHROMA],0, m_numLayers, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth) for layer %d")
     1188  ("OutputBitDepthC%d",                              cfg_OutputBitDepth[CHANNEL_TYPE_CHROMA],  0, m_numLayers, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
    11531189
    11541190  ("MaxTidRefPresentFlag",                           m_maxTidRefPresentFlag,                            false, "max_tid_ref_present_flag (0: not present, 1: present) " )
    1155   ("MaxTidIlRefPicsPlus1%d",                         cfg_maxTidIlRefPicsPlus1,                  7, MAX_LAYERS, "allowed maximum temporal_id for inter-layer prediction")
     1191  ("MaxTidIlRefPicsPlus1%d",                         cfg_maxTidIlRefPicsPlus1,                 7, m_numLayers, "allowed maximum temporal_id for inter-layer prediction")
    11561192  ("CrossLayerPictureTypeAlignFlag",                 m_crossLayerPictureTypeAlignFlag,                   true, "align picture type across layers" ) 
    11571193  ("CrossLayerIrapAlignFlag",                        m_crossLayerIrapAlignFlag,                          true, "align IRAP across layers" ) 
    11581194  ("CrossLayerAlignedIdrOnlyFlag",                   m_crossLayerAlignedIdrOnlyFlag,                     true, "only idr for IRAP across layers" ) 
    1159   ("InterLayerWeightedPred",                          m_useInterLayerWeightedPred,                       false, "enable IL WP parameters estimation at encoder" ) 
     1195  ("InterLayerWeightedPred",                          m_useInterLayerWeightedPred,                      false, "enable IL WP parameters estimation at encoder" ) 
    11601196#if AVC_BASE
    1161   ("NonHEVCBase,-nonhevc",                            m_nonHEVCBaseLayerFlag,                                0, "BL is available but not internal")
    1162   ("InputBLFile,-ibl",                                cfg_BLInputFile,                              string(""), "Base layer rec YUV input file name")
     1197  ("NonHEVCBase,-nonhevc",                            m_nonHEVCBaseLayerFlag,                               0, "BL is available but not internal")
     1198  ("InputBLFile,-ibl",                                cfg_BLInputFile,                             string(""), "Base layer rec YUV input file name")
    11631199#endif
    11641200  ("EnableElRapB,-use-rap-b",                         m_elRapSliceBEnabled,                                 0, "Set ILP over base-layer I picture to B picture (default is P picture)")
     
    12341270  ("IntraConstraintFlag",                             tmpIntraConstraintFlag,                           false, "Value of general_intra_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
    12351271  ("OnePictureOnlyConstraintFlag",                    tmpOnePictureOnlyConstraintFlag,                  false, "Value of general_one_picture_only_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
    1236   ("LowerBitRateConstraintFlag",                      tmpLowerBitRateConstraintFlag,                      true, "Value of general_lower_bit_rate_constraint_flag to use for RExt profiles")
    1237 
    1238   ("ProfileCompatibility%d",                          m_profileCompatibility, Profile::NONE, (MAX_NUM_LAYER_IDS + 1), "Compatible profile to be used when encoding")
    1239   ("ProgressiveSource%d",                             m_progressiveSourceFlagList,   false, (MAX_NUM_LAYER_IDS + 1), "Indicate that source is progressive")
    1240   ("InterlacedSource%d",                              m_interlacedSourceFlagList,    false, (MAX_NUM_LAYER_IDS + 1), "Indicate that source is interlaced")
    1241   ("NonPackedSource%d",                               m_nonPackedConstraintFlagList, false, (MAX_NUM_LAYER_IDS + 1), "Indicate that source does not contain frame packing")
    1242   ("FrameOnly%d",                                     m_frameOnlyConstraintFlagList, false, (MAX_NUM_LAYER_IDS + 1), "Indicate that the bitstream contains only frames")
     1272  ("LowerBitRateConstraintFlag",                      tmpLowerBitRateConstraintFlag,                     true, "Value of general_lower_bit_rate_constraint_flag to use for RExt profiles")
     1273
     1274  ("ProfileCompatibility%d",                   m_profileCompatibility, Profile::NONE, (MAX_NUM_LAYER_IDS + 1), "Compatible profile to be used when encoding")
     1275  ("ProgressiveSource%d",                       m_progressiveSourceFlagList,   false, (MAX_NUM_LAYER_IDS + 1), "Indicate that source is progressive")
     1276  ("InterlacedSource%d",                        m_interlacedSourceFlagList,    false, (MAX_NUM_LAYER_IDS + 1), "Indicate that source is interlaced")
     1277  ("NonPackedSource%d",                         m_nonPackedConstraintFlagList, false, (MAX_NUM_LAYER_IDS + 1), "Indicate that source does not contain frame packing")
     1278  ("FrameOnly%d",                               m_frameOnlyConstraintFlagList, false, (MAX_NUM_LAYER_IDS + 1), "Indicate that the bitstream contains only frames")
    12431279 
    1244   ("LayerPTLIndex%d",                                 cfg_layerPTLIdx,               0, MAX_VPS_LAYER_IDX_PLUS1, "Index of PTL for each layer")
    1245   ("ListOfProfileTierLevelOls%d",                     cfg_listOfLayerPTLOfOlss, string(""), MAX_VPS_OUTPUT_LAYER_SETS_PLUS1, "PTL Index for each layer in each OLS except the first OLS. The PTL index for layer in the first OLS is set to 1")
     1280  ("LayerPTLIndex%d",                                 cfg_layerPTLIdx,                         0, m_numLayers, "Index of PTL for each layer")
     1281  ("ListOfProfileTierLevelOls%d",       cfg_listOfLayerPTLOfOlss, string(""), MAX_VPS_OUTPUT_LAYER_SETS_PLUS1, "PTL Index for each layer in each OLS except the first OLS. The PTL index for layer in the first OLS is set to 1")
    12461282
    12471283  // Unit definition parameters
    1248   ("MaxCUWidth%d",                                    cfg_uiMaxCUWidth,                       64u, MAX_LAYERS, "Maximum CU width")
    1249   ("MaxCUHeight%d",                                   cfg_uiMaxCUHeight,                      64u, MAX_LAYERS, "Maximum CU height")
     1284  ("MaxCUWidth%d",                                    cfg_uiMaxCUWidth,                      64u, m_numLayers, "Maximum CU width")
     1285  ("MaxCUHeight%d",                                   cfg_uiMaxCUHeight,                     64u, m_numLayers, "Maximum CU height")
    12501286  // todo: remove defaults from MaxCUSize
    1251   ("MaxCUSize%d,s",                                   cfg_uiMaxCUWidth,                       64u, MAX_LAYERS, "Maximum CU size")
    1252   ("MaxCUSize%d,s",                                   cfg_uiMaxCUHeight,                      64u, MAX_LAYERS, "Maximum CU size")
    1253   ("MaxPartitionDepth%d,h%d",                         cfg_uiMaxCUDepth,                        4u, MAX_LAYERS, "CU depth")
    1254 
    1255   ("QuadtreeTULog2MaxSize%d",                         cfg_uiQuadtreeTULog2MaxSize,             5u, MAX_LAYERS, "Maximum TU size in logarithm base 2")
    1256   ("QuadtreeTULog2MinSize%d",                         cfg_uiQuadtreeTULog2MinSize,             2u, MAX_LAYERS, "Minimum TU size in logarithm base 2")
     1287  ("MaxCUSize%d,s",                                   cfg_uiMaxCUWidth,                      64u, m_numLayers, "Maximum CU size")
     1288  ("MaxCUSize%d,s",                                   cfg_uiMaxCUHeight,                     64u, m_numLayers, "Maximum CU size")
     1289  ("MaxPartitionDepth%d,h%d",                         cfg_uiMaxCUDepth,                       4u, m_numLayers, "CU depth")
     1290
     1291  ("QuadtreeTULog2MaxSize%d",                         cfg_uiQuadtreeTULog2MaxSize,            5u, m_numLayers, "Maximum TU size in logarithm base 2")
     1292  ("QuadtreeTULog2MinSize%d",                         cfg_uiQuadtreeTULog2MinSize,            2u, m_numLayers, "Minimum TU size in logarithm base 2")
    12571293                                                                                               
    1258   ("QuadtreeTUMaxDepthIntra%d",                       cfg_uiQuadtreeTUMaxDepthIntra,           3u, MAX_LAYERS, "Depth of TU tree for intra CUs")
    1259   ("QuadtreeTUMaxDepthInter%d",                       cfg_uiQuadtreeTUMaxDepthInter,           3u, MAX_LAYERS, "Depth of TU tree for inter CUs")
     1294  ("QuadtreeTUMaxDepthIntra%d",                       cfg_uiQuadtreeTUMaxDepthIntra,          3u, m_numLayers, "Depth of TU tree for intra CUs")
     1295  ("QuadtreeTUMaxDepthInter%d",                       cfg_uiQuadtreeTUMaxDepthInter,          3u, m_numLayers, "Depth of TU tree for inter CUs")
    12601296#else
    12611297  ("Profile",                                         extendedProfile,                                   NONE, "Profile name to use for encoding. Use main (for main), main10 (for main10), main-still-picture, main-RExt (for Range Extensions profile), any of the RExt specific profile names, or none")
     
    12911327  // Coding structure paramters
    12921328#if SVC_EXTENSION
    1293   ("IntraPeriod%d,-ip%d",                             cfg_IntraPeriod, -1, MAX_LAYERS, "intra period in frames for layer %d, (-1: only first frame)")
     1329  ("IntraPeriod%d,-ip%d",                             cfg_IntraPeriod,                        -1, m_numLayers, "intra period in frames for layer %d, (-1: only first frame)")
    12941330#else
    12951331  ("IntraPeriod,-ip",                                 m_iIntraPeriod,                                      -1, "Intra period in frames, (-1: only first frame)")
     
    13101346
    13111347#if SVC_EXTENSION
    1312   ("LambdaModifier%d,-LM%d",                          m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
     1348  ("LambdaModifier%d,-LM%d",                          m_adLambdaModifier,           ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
    13131349#else
    13141350  // Mode decision parameters
     
    13251361  /* Quantization parameters */
    13261362#if SVC_EXTENSION
    1327   ("QP%d,-q%d",                                       cfg_fQP,  30.0, MAX_LAYERS, "Qp value for layer %d, if value is float, QP is switched once during encoding")
     1363  ("QP%d,-q%d",                                                                   cfg_fQP,  30.0, m_numLayers, "Qp value for layer %d, if value is float, QP is switched once during encoding")
    13281364#else
    13291365  ("QP,q",                                            m_fQP,                                             30.0, "Qp value, if value is float, QP is switched once during encoding")
     
    13321368  ("MaxDeltaQP,d",                                    m_iMaxDeltaQP,                                        0, "max dQp offset for block")
    13331369#if SVC_EXTENSION
    1334   ("MaxCuDQPDepth%d,-dqd",                            cfg_maxCuDQPDepth,                        0, MAX_LAYERS, "max depth for a minimum CuDQP")
     1370  ("MaxCuDQPDepth%d,-dqd",                            cfg_maxCuDQPDepth,                       0, m_numLayers, "max depth for a minimum CuDQP")
    13351371#else
    13361372  ("MaxCuDQPDepth,-dqd",                              m_iMaxCuDQPDepth,                                     0, "max depth for a minimum CuDQP")
     
    14131449  ("Log2ParallelMergeLevel",                          m_log2ParallelMergeLevel,                            2u, "Parallel merge estimation region")
    14141450    //deprecated copies of renamed tile parameters
    1415   ("UniformSpacingIdc",                               m_tileUniformSpacingFlag,                         false,      "deprecated alias of TileUniformSpacing")
     1451  ("UniformSpacingIdc",                               m_tileUniformSpacingFlag,                         false, "deprecated alias of TileUniformSpacing")
    14161452  ("ColumnWidthArray",                                cfg_ColumnWidth,                        cfg_ColumnWidth, "deprecated alias of TileColumnWidthArray")
    14171453  ("RowHeightArray",                                  cfg_RowHeight,                            cfg_RowHeight, "deprecated alias of TileRowHeightArray")
    14181454
    1419   ("TileUniformSpacing",                              m_tileUniformSpacingFlag,                         false,      "Indicates that tile columns and rows are distributed uniformly")
    1420   ("NumTileColumnsMinus1",                            m_numTileColumnsMinus1,                               0,          "Number of tile columns in a picture minus 1")
    1421   ("NumTileRowsMinus1",                               m_numTileRowsMinus1,                                  0,          "Number of rows in a picture minus 1")
     1455  ("TileUniformSpacing",                              m_tileUniformSpacingFlag,                         false, "Indicates that tile columns and rows are distributed uniformly")
     1456  ("NumTileColumnsMinus1",                            m_numTileColumnsMinus1,                               0, "Number of tile columns in a picture minus 1")
     1457  ("NumTileRowsMinus1",                               m_numTileRowsMinus1,                                  0, "Number of rows in a picture minus 1")
    14221458  ("TileColumnWidthArray",                            cfg_ColumnWidth,                        cfg_ColumnWidth, "Array containing tile column width values in units of CTU")
    14231459  ("TileRowHeightArray",                              cfg_RowHeight,                            cfg_RowHeight, "Array containing tile row height values in units of CTU")
    14241460  ("LFCrossTileBoundaryFlag",                         m_bLFCrossTileBoundaryFlag,                        true, "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
    14251461#if SVC_EXTENSION
    1426   ("WaveFrontSynchro%d",                              cfg_waveFrontSynchro,             0,  MAX_LAYERS,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
     1462  ("WaveFrontSynchro%d",                              cfg_waveFrontSynchro,                   0,  m_numLayers, "0: no synchro; 1 synchro with TR; 2 TRR etc")
    14271463#else
    14281464  ("WaveFrontSynchro",                                m_iWaveFrontSynchro,                                  0, "0: no synchro; 1 synchro with top-right-right")
     
    14481484#endif
    14491485#if RC_SHVC_HARMONIZATION
    1450   ("RateControl%d",                                   cfg_RCEnableRateControl, false, MAX_LAYERS, "Rate control: enable rate control for layer %d")
    1451   ("TargetBitrate%d",                                 cfg_RCTargetBitRate, 0, MAX_LAYERS, "Rate control: target bitrate for layer %d")
    1452   ("KeepHierarchicalBit%d",                           cfg_RCKeepHierarchicalBit, false, MAX_LAYERS, "Rate control: keep hierarchical bit allocation for layer %d")
    1453   ("LCULevelRateControl%d",                           cfg_RCLCULevelRC, true, MAX_LAYERS, "Rate control: LCU level RC")
    1454   ("RCLCUSeparateModel%d",                            cfg_RCUseLCUSeparateModel, true, MAX_LAYERS, "Rate control: Use LCU level separate R-lambda model")
    1455   ("InitialQP%d",                                     cfg_RCInitialQP, 0, MAX_LAYERS, "Rate control: initial QP")
    1456   ("RCForceIntraQP%d",                                cfg_RCForceIntraQP, false, MAX_LAYERS, "Rate control: force intra QP to be equal to initial QP")
     1486  ("RateControl%d",                                   cfg_RCEnableRateControl,             false, m_numLayers, "Rate control: enable rate control for layer %d")
     1487  ("TargetBitrate%d",                                 cfg_RCTargetBitRate,                     0, m_numLayers, "Rate control: target bitrate for layer %d")
     1488  ("KeepHierarchicalBit%d",                           cfg_RCKeepHierarchicalBit,           false, m_numLayers, "Rate control: keep hierarchical bit allocation for layer %d")
     1489  ("LCULevelRateControl%d",                           cfg_RCLCULevelRC,                     true, m_numLayers, "Rate control: LCU level RC")
     1490  ("RCLCUSeparateModel%d",                            cfg_RCUseLCUSeparateModel,            true, m_numLayers, "Rate control: Use LCU level separate R-lambda model")
     1491  ("InitialQP%d",                                     cfg_RCInitialQP,                         0, m_numLayers, "Rate control: initial QP")
     1492  ("RCForceIntraQP%d",                                cfg_RCForceIntraQP,                  false, m_numLayers, "Rate control: force intra QP to be equal to initial QP")
    14571493#else
    14581494  ( "RateControl",                                    m_RCEnableRateControl,                            false, "Rate control: enable rate control" )
     
    16761712  ("SEITemporalMotionVectorPredictionConstraints",             m_TMVPConstraintsSEIEnabled,              0, "Control generation of TMVP constrants SEI message")
    16771713#endif
    1678   ("AdaptiveResolutionChange",     m_adaptiveResolutionChange, 0, "Adaptive resolution change frame number. Should coincide with EL RAP picture. (0: disable)")
    1679   ("LayerSwitchOffBegin%d", cfg_layerSwitchOffBegin, 0, MAX_LAYERS, "Switch layer %d off after given poc")
    1680   ("LayerSwitchOffEnd%d", cfg_layerSwitchOffEnd, 0, MAX_LAYERS, "Switch layer %d on at given poc")
    1681   ("SkipPictureAtArcSwitch",     m_skipPictureAtArcSwitch, false, "Code the higher layer picture in ARC up-switching as a skip picture. (0: disable)")
     1714  ("AdaptiveResolutionChange",                                  m_adaptiveResolutionChange, 0, "Adaptive resolution change frame number. Should coincide with EL RAP picture. (0: disable)")
     1715  ("LayerSwitchOffBegin%d",                           cfg_layerSwitchOffBegin, 0, m_numLayers, "Switch layer %d off after given poc")
     1716  ("LayerSwitchOffEnd%d",                               cfg_layerSwitchOffEnd, 0, m_numLayers, "Switch layer %d on at given poc")
     1717  ("SkipPictureAtArcSwitch",                                  m_skipPictureAtArcSwitch, false, "Code the higher layer picture in ARC up-switching as a skip picture. (0: disable)")
    16821718#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    1683   ("SEIInterLayerConstrainedTileSets", m_interLayerConstrainedTileSetsSEIEnabled, false, "Control generation of inter layer constrained tile sets SEI message")
    1684   ("IlNumSetsInMessage",               m_ilNumSetsInMessage,                         0u, "Number of inter layer constrained tile sets")
    1685   ("TileSetsArray",                    cfg_tileSets,                         string(""), "Array containing tile sets params (TopLeftTileIndex, BottonRightTileIndex and ilcIdc for each set) ")
    1686 #endif
    1687   ("AltOutputLayerFlag",               m_altOutputLayerFlag,                      false, "Specifies the value of alt_output_layer_flag in VPS extension")
    1688   ("CrossLayerBLAFlag",                m_crossLayerBLAFlag,                       false, "Specifies the value of cross_layer_bla_flag in VPS")
     1719  ("SEIInterLayerConstrainedTileSets",       m_interLayerConstrainedTileSetsSEIEnabled, false, "Control generation of inter layer constrained tile sets SEI message")
     1720  ("IlNumSetsInMessage",                     m_ilNumSetsInMessage,                         0u, "Number of inter layer constrained tile sets")
     1721  ("TileSetsArray",                          cfg_tileSets,                         string(""), "Array containing tile sets params (TopLeftTileIndex, BottonRightTileIndex and ilcIdc for each set) ")
     1722#endif
     1723  ("AltOutputLayerFlag",                     m_altOutputLayerFlag,                      false, "Specifies the value of alt_output_layer_flag in VPS extension")
     1724  ("CrossLayerBLAFlag",                      m_crossLayerBLAFlag,                       false, "Specifies the value of cross_layer_bla_flag in VPS")
    16891725#if CGS_3D_ASYMLUT
    1690   ("CGS",     m_nCGSFlag , 0, "whether CGS is enabled")
    1691   ("CGSMaxOctantDepth", m_nCGSMaxOctantDepth , 1, "max octant depth")
    1692   ("CGSMaxYPartNumLog",  m_nCGSMaxYPartNumLog2 , 2, "max Y part number ")
    1693   ("CGSLUTBit",     m_nCGSLUTBit , 12, "bit depth of CGS LUT")
    1694   ("CGSAdaptC",     m_nCGSAdaptiveChroma , 1, "adaptive chroma partition (only for the case of two chroma partitions)")
     1726  ("CGS",                                                                       m_nCGSFlag, 0, "whether CGS is enabled")
     1727  ("CGSMaxOctantDepth",                                               m_nCGSMaxOctantDepth, 1, "max octant depth")
     1728  ("CGSMaxYPartNumLog",                                              m_nCGSMaxYPartNumLog2, 2, "max Y part number ")
     1729  ("CGSLUTBit",                                                              m_nCGSLUTBit, 12, "bit depth of CGS LUT")
     1730  ("CGSAdaptC",                                                       m_nCGSAdaptiveChroma, 1, "adaptive chroma partition (only for the case of two chroma partitions)")
    16951731#if R0179_ENC_OPT_3DLUT_SIZE
    1696   ("CGSSizeRDO",     m_nCGSLutSizeRDO , 0, "RDOpt selection of best table size (effective when large maximum table size such as 8x8x8 is used)")
    1697 #endif
    1698 #endif
    1699   ("InheritCodingStruct%d",m_inheritCodingStruct, 0, MAX_LAYERS, "Predicts the GOP structure of one layer for another layer")
     1732  ("CGSSizeRDO",                                                          m_nCGSLutSizeRDO, 0, "RDOpt selection of best table size (effective when large maximum table size such as 8x8x8 is used)")
     1733#endif
     1734#endif
     1735  ("InheritCodingStruct%d",                             m_inheritCodingStruct, 0, m_numLayers, "Predicts the GOP structure of one layer for another layer")
    17001736#endif //SVC_EXTENSION
    17011737  ;
     
    17091745
    17101746#if SVC_EXTENSION
    1711   for (Int i=1; i<MAX_LAYERS; i++)
     1747  for (Int i=1; i<m_numLayers; i++)
    17121748  {
    17131749    for(Int j=1; j<MAX_GOP+1; j++)
     
    17251761
    17261762#if SVC_EXTENSION
    1727   for (Int i=1; i<MAX_LAYERS; i++)
     1763  for (Int i=1; i<m_numLayers; i++)
    17281764  {
    17291765    if(m_inheritCodingStruct[i] == 0)
     
    17951831  {
    17961832#if SVC_EXTENSION
    1797     for(Int layer = 0; layer < MAX_LAYERS; layer++)
     1833    for(Int layer = 0; layer < m_numLayers; layer++)
    17981834    {
    17991835      //Frame height
    1800       m_acLayerCfg[layer].m_iSourceHeightOrg = m_acLayerCfg[layer].m_iSourceHeight;
     1836      m_apcLayerCfg[layer]->m_iSourceHeightOrg = m_apcLayerCfg[layer]->m_iSourceHeight;
    18011837      //Field height
    1802       m_acLayerCfg[layer].m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight >> 1;
     1838      m_apcLayerCfg[layer]->m_iSourceHeight = m_apcLayerCfg[layer]->m_iSourceHeight >> 1;
    18031839    }
    18041840#else
     
    18701906  /* rules for input, output and internal bitdepths as per help text */
    18711907#if SVC_EXTENSION
    1872   for( Int layer = 0; layer < MAX_LAYERS; layer++ )
    1873   {
    1874     if( m_acLayerCfg[layer].m_layerId < 0 )
    1875     {
    1876       m_acLayerCfg[layer].m_layerId = layer;
    1877     }
    1878 
    1879     m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] = m_acLayerCfg[layer].m_inputBitDepth      [CHANNEL_TYPE_LUMA  ];
    1880     m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ];
    1881 
    1882     if (m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] == 0) { m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] = m_acLayerCfg[layer].m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ]; }
    1883     if (m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_CHROMA] == 0) { m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_LUMA  ]; }
    1884     if (m_acLayerCfg[layer].m_inputBitDepth      [CHANNEL_TYPE_CHROMA] == 0) { m_acLayerCfg[layer].m_inputBitDepth      [CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layer].m_inputBitDepth      [CHANNEL_TYPE_LUMA  ]; }
    1885     if (m_acLayerCfg[layer].m_outputBitDepth     [CHANNEL_TYPE_LUMA  ] == 0) { m_acLayerCfg[layer].m_outputBitDepth     [CHANNEL_TYPE_LUMA  ] = m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_LUMA  ]; }
    1886     if (m_acLayerCfg[layer].m_outputBitDepth     [CHANNEL_TYPE_CHROMA] == 0) { m_acLayerCfg[layer].m_outputBitDepth     [CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layer].m_internalBitDepth   [CHANNEL_TYPE_CHROMA]; }
    1887 
    1888     m_acLayerCfg[layer].m_InputChromaFormatIDC = numberToChromaFormat(tmpInputChromaFormat);
    1889     m_acLayerCfg[layer].m_chromaFormatIDC      = ((tmpChromaFormat == 0) ? (m_acLayerCfg[layer].m_InputChromaFormatIDC) : (numberToChromaFormat(tmpChromaFormat)));
    1890 
    1891     m_acLayerCfg[layer].m_highPrecisionOffsetsEnabledFlag = false;
    1892     m_acLayerCfg[layer].m_extendedPrecisionProcessingFlag = false;
    1893 
    1894     if( m_acLayerCfg[layer].m_layerSwitchOffBegin < m_acLayerCfg[layer].m_layerSwitchOffEnd )
    1895     {
    1896       if( m_iGOPSize > 0 && (m_acLayerCfg[layer].m_layerSwitchOffBegin % m_iGOPSize) != 0 )
     1908  for( Int layer = 0; layer < m_numLayers; layer++ )
     1909  {
     1910    if( m_apcLayerCfg[layer]->m_layerId < 0 )
     1911    {
     1912      m_apcLayerCfg[layer]->m_layerId = layer;
     1913    }
     1914
     1915    m_apcLayerCfg[layer]->m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] = m_apcLayerCfg[layer]->m_inputBitDepth      [CHANNEL_TYPE_LUMA  ];
     1916    m_apcLayerCfg[layer]->m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] = m_apcLayerCfg[layer]->m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ];
     1917
     1918    if (m_apcLayerCfg[layer]->m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] == 0) { m_apcLayerCfg[layer]->m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] = m_apcLayerCfg[layer]->m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ]; }
     1919    if (m_apcLayerCfg[layer]->m_internalBitDepth   [CHANNEL_TYPE_CHROMA] == 0) { m_apcLayerCfg[layer]->m_internalBitDepth   [CHANNEL_TYPE_CHROMA] = m_apcLayerCfg[layer]->m_internalBitDepth   [CHANNEL_TYPE_LUMA  ]; }
     1920    if (m_apcLayerCfg[layer]->m_inputBitDepth      [CHANNEL_TYPE_CHROMA] == 0) { m_apcLayerCfg[layer]->m_inputBitDepth      [CHANNEL_TYPE_CHROMA] = m_apcLayerCfg[layer]->m_inputBitDepth      [CHANNEL_TYPE_LUMA  ]; }
     1921    if (m_apcLayerCfg[layer]->m_outputBitDepth     [CHANNEL_TYPE_LUMA  ] == 0) { m_apcLayerCfg[layer]->m_outputBitDepth     [CHANNEL_TYPE_LUMA  ] = m_apcLayerCfg[layer]->m_internalBitDepth   [CHANNEL_TYPE_LUMA  ]; }
     1922    if (m_apcLayerCfg[layer]->m_outputBitDepth     [CHANNEL_TYPE_CHROMA] == 0) { m_apcLayerCfg[layer]->m_outputBitDepth     [CHANNEL_TYPE_CHROMA] = m_apcLayerCfg[layer]->m_internalBitDepth   [CHANNEL_TYPE_CHROMA]; }
     1923
     1924    m_apcLayerCfg[layer]->m_InputChromaFormatIDC = numberToChromaFormat(tmpInputChromaFormat);
     1925    m_apcLayerCfg[layer]->m_chromaFormatIDC      = ((tmpChromaFormat == 0) ? (m_apcLayerCfg[layer]->m_InputChromaFormatIDC) : (numberToChromaFormat(tmpChromaFormat)));
     1926
     1927    m_apcLayerCfg[layer]->m_highPrecisionOffsetsEnabledFlag = false;
     1928    m_apcLayerCfg[layer]->m_extendedPrecisionProcessingFlag = false;
     1929
     1930    if( m_apcLayerCfg[layer]->m_layerSwitchOffBegin < m_apcLayerCfg[layer]->m_layerSwitchOffEnd )
     1931    {
     1932      if( m_iGOPSize > 0 && (m_apcLayerCfg[layer]->m_layerSwitchOffBegin % m_iGOPSize) != 0 )
    18971933      {
    18981934        printf("LayerSwitchOffBegin%d: Must be multiple of GOP size.\n", layer);
    18991935        exit(EXIT_FAILURE);
    19001936      }
    1901       if( m_acLayerCfg[layer].m_iIntraPeriod > 0 && (m_acLayerCfg[layer].m_layerSwitchOffEnd % m_acLayerCfg[layer].m_iIntraPeriod) != 0 )
     1937      if( m_apcLayerCfg[layer]->m_iIntraPeriod > 0 && (m_apcLayerCfg[layer]->m_layerSwitchOffEnd % m_apcLayerCfg[layer]->m_iIntraPeriod) != 0 )
    19021938      {
    19031939        printf("LayerSwitchOffEnd%d: Must be IRAP picture.\n", layer);
     
    19061942    }
    19071943
    1908     m_acLayerCfg[layer].m_bitDepthConstraint = tmpBitDepthConstraint;
    1909     m_acLayerCfg[layer].m_intraConstraintFlag = tmpIntraConstraintFlag;
    1910     m_acLayerCfg[layer].m_lowerBitRateConstraintFlag = tmpLowerBitRateConstraintFlag;   
     1944    m_apcLayerCfg[layer]->m_bitDepthConstraint = tmpBitDepthConstraint;
     1945    m_apcLayerCfg[layer]->m_intraConstraintFlag = tmpIntraConstraintFlag;
     1946    m_apcLayerCfg[layer]->m_lowerBitRateConstraintFlag = tmpLowerBitRateConstraintFlag;   
    19111947
    19121948    for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
    19131949    {
    1914       m_acLayerCfg[layer].m_log2SaoOffsetScale[channelType] = 0;
     1950      m_apcLayerCfg[layer]->m_log2SaoOffsetScale[channelType] = 0;
    19151951    }
    19161952       
    1917     Int layerPTLIdx = m_acLayerCfg[layer].m_layerPTLIdx;
     1953    Int layerPTLIdx = m_apcLayerCfg[layer]->m_layerPTLIdx;
    19181954
    19191955    if( extendedProfile[layerPTLIdx] >= 1000 && extendedProfile[layerPTLIdx] <= 2316 )
     
    19211957      m_profileList[layerPTLIdx] = Profile::MAINREXT;           
    19221958
    1923       if( m_acLayerCfg[layer].m_bitDepthConstraint != 0 || tmpConstraintChromaFormat != 0)
     1959      if( m_apcLayerCfg[layer]->m_bitDepthConstraint != 0 || tmpConstraintChromaFormat != 0)
    19241960      {
    19251961        fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
    19261962        exit(EXIT_FAILURE);
    19271963      }
    1928       m_acLayerCfg[layer].m_bitDepthConstraint  = (extendedProfile[layerPTLIdx]%100);
    1929       m_acLayerCfg[layer].m_intraConstraintFlag = (extendedProfile[layerPTLIdx]>=2000);
     1964      m_apcLayerCfg[layer]->m_bitDepthConstraint  = (extendedProfile[layerPTLIdx]%100);
     1965      m_apcLayerCfg[layer]->m_intraConstraintFlag = (extendedProfile[layerPTLIdx]>=2000);
    19301966      switch ((extendedProfile[layerPTLIdx]/100)%10)
    19311967      {
     
    19481984    if( m_profileList[layerPTLIdx] == Profile::HIGHTHROUGHPUTREXT )
    19491985    {
    1950       if( m_acLayerCfg[layer].m_bitDepthConstraint == 0 ) m_acLayerCfg[layer].m_bitDepthConstraint = 16;
    1951       m_acLayerCfg[layer].m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? CHROMA_444 : numberToChromaFormat(tmpConstraintChromaFormat);
     1986      if( m_apcLayerCfg[layer]->m_bitDepthConstraint == 0 ) m_apcLayerCfg[layer]->m_bitDepthConstraint = 16;
     1987      m_apcLayerCfg[layer]->m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? CHROMA_444 : numberToChromaFormat(tmpConstraintChromaFormat);
    19521988    }
    19531989    else if( m_profileList[layerPTLIdx] == Profile::MAINREXT )
    19541990    {
    1955       if( m_acLayerCfg[layer].m_bitDepthConstraint == 0 && tmpConstraintChromaFormat == 0 )
     1991      if( m_apcLayerCfg[layer]->m_bitDepthConstraint == 0 && tmpConstraintChromaFormat == 0 )
    19561992      {
    19571993        // produce a valid combination, if possible.
     
    19642000          m_log2MaxTransformSkipBlockSize!=2;
    19652001        const Bool bUsingChromaQPAdjustment= m_diffCuChromaQpOffsetDepth >= 0;
    1966         const Bool bUsingExtendedPrecision = m_acLayerCfg[layer].m_extendedPrecisionProcessingFlag;
    1967         m_acLayerCfg[layer].m_chromaFormatConstraint = NUM_CHROMA_FORMAT;
     2002        const Bool bUsingExtendedPrecision = m_apcLayerCfg[layer]->m_extendedPrecisionProcessingFlag;
     2003        m_apcLayerCfg[layer]->m_chromaFormatConstraint = NUM_CHROMA_FORMAT;
    19682004        automaticallySelectRExtProfile(bUsingGeneralRExtTools,
    19692005          bUsingChromaQPAdjustment,
    19702006          bUsingExtendedPrecision,
    1971           m_acLayerCfg[layer].m_intraConstraintFlag,
    1972           m_acLayerCfg[layer].m_bitDepthConstraint,
    1973           m_acLayerCfg[layer].m_chromaFormatConstraint,
    1974           m_acLayerCfg[layer].m_chromaFormatIDC==CHROMA_400 ? m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]),
    1975           m_acLayerCfg[layer].m_chromaFormatIDC);
    1976       }
    1977       else if( m_acLayerCfg[layer].m_bitDepthConstraint == 0 || tmpConstraintChromaFormat == 0)
     2007          m_apcLayerCfg[layer]->m_intraConstraintFlag,
     2008          m_apcLayerCfg[layer]->m_bitDepthConstraint,
     2009          m_apcLayerCfg[layer]->m_chromaFormatConstraint,
     2010          m_apcLayerCfg[layer]->m_chromaFormatIDC==CHROMA_400 ? m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]),
     2011          m_apcLayerCfg[layer]->m_chromaFormatIDC);
     2012      }
     2013      else if( m_apcLayerCfg[layer]->m_bitDepthConstraint == 0 || tmpConstraintChromaFormat == 0)
    19782014      {
    19792015        fprintf(stderr, "Error: The bit depth and chroma format constraints must either both be specified or both be configured automatically\n");
     
    19822018      else
    19832019      {
    1984         m_acLayerCfg[layer].m_chromaFormatConstraint = numberToChromaFormat(tmpConstraintChromaFormat);
     2020        m_apcLayerCfg[layer]->m_chromaFormatConstraint = numberToChromaFormat(tmpConstraintChromaFormat);
    19852021      }
    19862022    }
    19872023    else
    19882024    {
    1989       m_acLayerCfg[layer].m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? m_acLayerCfg[layer].m_chromaFormatIDC : numberToChromaFormat(tmpConstraintChromaFormat);
    1990       m_acLayerCfg[layer].m_bitDepthConstraint = (m_profileList[layerPTLIdx] == Profile::MAIN10 || m_profileList[layerPTLIdx] == Profile::SCALABLEMAIN10) ? 10 : 8;
     2025      m_apcLayerCfg[layer]->m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? m_apcLayerCfg[layer]->m_chromaFormatIDC : numberToChromaFormat(tmpConstraintChromaFormat);
     2026      m_apcLayerCfg[layer]->m_bitDepthConstraint = (m_profileList[layerPTLIdx] == Profile::MAIN10 || m_profileList[layerPTLIdx] == Profile::SCALABLEMAIN10) ? 10 : 8;
    19912027    }
    19922028  }
     
    21152151
    21162152#if SVC_EXTENSION
    2117   for(Int layer = 0; layer < MAX_LAYERS; layer++)
     2153  for(Int layer = 0; layer < m_numLayers; layer++)
    21182154  {
    21192155    // If number of scaled ref. layer offsets is non-zero, at least one of the offsets should be specified
    2120     if(m_acLayerCfg[layer].m_numRefLayerLocationOffsets)
     2156    if(m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets)
    21212157    {
    21222158      assert( strcmp(cfg_refLocationOffsetLayerId[layer].c_str(),  ""));
     
    21472183    if(strcmp(cfg_refLocationOffsetLayerId[layer].c_str(),  ""))
    21482184    {
    2149       cfgStringToArray( &tempArray, cfg_refLocationOffsetLayerId[layer], m_acLayerCfg[layer].m_numRefLayerLocationOffsets, "RefLocationOffsetLayerId");
     2185      cfgStringToArray( &tempArray, cfg_refLocationOffsetLayerId[layer], m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets, "RefLocationOffsetLayerId");
    21502186      if(tempArray)
    21512187      {
    2152         for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
     2188        for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
    21532189        {
    2154           m_acLayerCfg[layer].m_refLocationOffsetLayerId[i] = tempArray[i];
     2190          m_apcLayerCfg[layer]->m_refLocationOffsetLayerId[i] = tempArray[i];
    21552191        }
    21562192        delete [] tempArray; tempArray = NULL;
     
    21612197    if(strcmp(cfg_scaledRefLayerOffsetPresentFlag[layer].c_str(),  ""))
    21622198    {
    2163       cfgStringToArray( &tempArray, cfg_scaledRefLayerOffsetPresentFlag[layer], m_acLayerCfg[layer].m_numRefLayerLocationOffsets, "ScaledRefLayerOffsetPresentFlag");
     2199      cfgStringToArray( &tempArray, cfg_scaledRefLayerOffsetPresentFlag[layer], m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets, "ScaledRefLayerOffsetPresentFlag");
    21642200      if(tempArray)
    21652201      {
    2166         for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
     2202        for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
    21672203        {
    2168           m_acLayerCfg[layer].m_scaledRefLayerOffsetPresentFlag[i] = tempArray[i];
     2204          m_apcLayerCfg[layer]->m_scaledRefLayerOffsetPresentFlag[i] = tempArray[i];
    21692205        }
    21702206        delete [] tempArray; tempArray = NULL;
     
    21752211    if(strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(),  ""))
    21762212    {
    2177       cfgStringToArray( &tempArray, cfg_scaledRefLayerLeftOffset[layer], m_acLayerCfg[layer].m_numRefLayerLocationOffsets, "LeftOffset");
     2213      cfgStringToArray( &tempArray, cfg_scaledRefLayerLeftOffset[layer], m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets, "LeftOffset");
    21782214      if(tempArray)
    21792215      {
    2180         for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
     2216        for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
    21812217        {
    2182           m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i] = tempArray[i];
     2218          m_apcLayerCfg[layer]->m_scaledRefLayerLeftOffset[i] = tempArray[i];
    21832219        }
    21842220        delete [] tempArray; tempArray = NULL;
     
    21892225    if(strcmp(cfg_scaledRefLayerTopOffset[layer].c_str(),  ""))
    21902226    {
    2191       cfgStringToArray( &tempArray, cfg_scaledRefLayerTopOffset[layer], m_acLayerCfg[layer].m_numRefLayerLocationOffsets, "TopOffset");
     2227      cfgStringToArray( &tempArray, cfg_scaledRefLayerTopOffset[layer], m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets, "TopOffset");
    21922228      if(tempArray)
    21932229      {
    2194         for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
     2230        for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
    21952231        {
    2196           m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i] = tempArray[i];
     2232          m_apcLayerCfg[layer]->m_scaledRefLayerTopOffset[i] = tempArray[i];
    21972233        }
    21982234        delete [] tempArray; tempArray = NULL;
     
    22032239    if(strcmp(cfg_scaledRefLayerRightOffset[layer].c_str(),  ""))
    22042240    {
    2205       cfgStringToArray( &tempArray, cfg_scaledRefLayerRightOffset[layer], m_acLayerCfg[layer].m_numRefLayerLocationOffsets, "RightOffset");
     2241      cfgStringToArray( &tempArray, cfg_scaledRefLayerRightOffset[layer], m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets, "RightOffset");
    22062242      if(tempArray)
    22072243      {
    2208         for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
     2244        for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
    22092245        {
    2210           m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i] = tempArray[i];
     2246          m_apcLayerCfg[layer]->m_scaledRefLayerRightOffset[i] = tempArray[i];
    22112247        }
    22122248        delete [] tempArray; tempArray = NULL;
     
    22172253    if(strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(),  ""))
    22182254    {
    2219       cfgStringToArray( &tempArray, cfg_scaledRefLayerBottomOffset[layer], m_acLayerCfg[layer].m_numRefLayerLocationOffsets, "BottomOffset");
     2255      cfgStringToArray( &tempArray, cfg_scaledRefLayerBottomOffset[layer], m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets, "BottomOffset");
    22202256      if(tempArray)
    22212257      {
    2222         for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
     2258        for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
    22232259        {
    2224           m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i] = tempArray[i];
     2260          m_apcLayerCfg[layer]->m_scaledRefLayerBottomOffset[i] = tempArray[i];
    22252261        }
    22262262        delete [] tempArray; tempArray = NULL;
     
    22312267    if(strcmp(cfg_refRegionOffsetPresentFlag[layer].c_str(),  ""))
    22322268    {
    2233       cfgStringToArray( &tempArray, cfg_refRegionOffsetPresentFlag[layer], m_acLayerCfg[layer].m_numRefLayerLocationOffsets, "RefRegionOffsetPresentFlag");
     2269      cfgStringToArray( &tempArray, cfg_refRegionOffsetPresentFlag[layer], m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets, "RefRegionOffsetPresentFlag");
    22342270      if(tempArray)
    22352271      {
    2236         for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
     2272        for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
    22372273        {
    2238           m_acLayerCfg[layer].m_refRegionOffsetPresentFlag[i] = tempArray[i];
     2274          m_apcLayerCfg[layer]->m_refRegionOffsetPresentFlag[i] = tempArray[i];
    22392275        }
    22402276        delete [] tempArray; tempArray = NULL;
     
    22452281    if(strcmp(cfg_refRegionLeftOffset[layer].c_str(),  ""))
    22462282    {
    2247       cfgStringToArray( &tempArray, cfg_refRegionLeftOffset[layer], m_acLayerCfg[layer].m_numRefLayerLocationOffsets, "RefRegionLeftOffset");
     2283      cfgStringToArray( &tempArray, cfg_refRegionLeftOffset[layer], m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets, "RefRegionLeftOffset");
    22482284      if(tempArray)
    22492285      {
    2250         for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
     2286        for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
    22512287        {
    2252           m_acLayerCfg[layer].m_refRegionLeftOffset[i] = tempArray[i];
     2288          m_apcLayerCfg[layer]->m_refRegionLeftOffset[i] = tempArray[i];
    22532289        }
    22542290        delete [] tempArray; tempArray = NULL;
     
    22592295    if(strcmp(cfg_refRegionTopOffset[layer].c_str(),  ""))
    22602296    {
    2261       cfgStringToArray( &tempArray, cfg_refRegionTopOffset[layer], m_acLayerCfg[layer].m_numRefLayerLocationOffsets, "RefRegionTopOffset");
     2297      cfgStringToArray( &tempArray, cfg_refRegionTopOffset[layer], m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets, "RefRegionTopOffset");
    22622298      if(tempArray)
    22632299      {
    2264         for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
     2300        for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
    22652301        {
    2266           m_acLayerCfg[layer].m_refRegionTopOffset[i] = tempArray[i];
     2302          m_apcLayerCfg[layer]->m_refRegionTopOffset[i] = tempArray[i];
    22672303        }
    22682304        delete [] tempArray; tempArray = NULL;
     
    22732309    if(strcmp(cfg_refRegionRightOffset[layer].c_str(),  ""))
    22742310    {
    2275       cfgStringToArray( &tempArray, cfg_refRegionRightOffset[layer], m_acLayerCfg[layer].m_numRefLayerLocationOffsets, "RefRegionRightOffset");
     2311      cfgStringToArray( &tempArray, cfg_refRegionRightOffset[layer], m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets, "RefRegionRightOffset");
    22762312      if(tempArray)
    22772313      {
    2278         for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
     2314        for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
    22792315        {
    2280           m_acLayerCfg[layer].m_refRegionRightOffset[i] = tempArray[i];
     2316          m_apcLayerCfg[layer]->m_refRegionRightOffset[i] = tempArray[i];
    22812317        }
    22822318        delete [] tempArray; tempArray = NULL;
     
    22872323    if(strcmp(cfg_refRegionBottomOffset[layer].c_str(),  ""))
    22882324    {
    2289       cfgStringToArray( &tempArray, cfg_refRegionBottomOffset[layer], m_acLayerCfg[layer].m_numRefLayerLocationOffsets, "RefRegionBottomOffset");
     2325      cfgStringToArray( &tempArray, cfg_refRegionBottomOffset[layer], m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets, "RefRegionBottomOffset");
    22902326      if(tempArray)
    22912327      {
    2292         for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
     2328        for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
    22932329        {
    2294           m_acLayerCfg[layer].m_refRegionBottomOffset[i] = tempArray[i];
     2330          m_apcLayerCfg[layer]->m_refRegionBottomOffset[i] = tempArray[i];
    22952331        }
    22962332        delete [] tempArray; tempArray = NULL;
     
    22982334    }
    22992335
    2300     Int numPhaseSet = m_acLayerCfg[layer].m_numRefLayerLocationOffsets;
     2336    Int numPhaseSet = m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets;
    23012337
    23022338    // Presense Flag //
     
    23082344        for(Int i = 0; i < numPhaseSet; i++)
    23092345        {
    2310           m_acLayerCfg[layer].m_resamplePhaseSetPresentFlag[i] = tempArray[i];
     2346          m_apcLayerCfg[layer]->m_resamplePhaseSetPresentFlag[i] = tempArray[i];
    23112347        }
    23122348        delete [] tempArray; tempArray = NULL;
     
    23222358        for(Int i = 0; i < numPhaseSet; i++)
    23232359        {
    2324           m_acLayerCfg[layer].m_phaseHorLuma[i] = tempArray[i];
     2360          m_apcLayerCfg[layer]->m_phaseHorLuma[i] = tempArray[i];
    23252361        }
    23262362        delete [] tempArray; tempArray = NULL;
     
    23362372        for(Int i = 0; i < numPhaseSet; i++)
    23372373        {
    2338           m_acLayerCfg[layer].m_phaseVerLuma[i] = tempArray[i];
     2374          m_apcLayerCfg[layer]->m_phaseVerLuma[i] = tempArray[i];
    23392375        }
    23402376        delete [] tempArray; tempArray = NULL;
     
    23502386        for(Int i = 0; i < numPhaseSet; i++)
    23512387        {
    2352           m_acLayerCfg[layer].m_phaseHorChroma[i] = tempArray[i];
     2388          m_apcLayerCfg[layer]->m_phaseHorChroma[i] = tempArray[i];
    23532389        }
    23542390        delete [] tempArray; tempArray = NULL;
     
    23642400        for(Int i = 0; i < numPhaseSet; i++)
    23652401        {
    2366           m_acLayerCfg[layer].m_phaseVerChroma[i] = tempArray[i];
     2402          m_apcLayerCfg[layer]->m_phaseVerChroma[i] = tempArray[i];
    23672403        }
    23682404        delete [] tempArray; tempArray = NULL;
     
    23712407
    23722408    Char* pSamplePredRefLayerIds = cfg_samplePredRefLayerIds[layer].empty() ? NULL: strdup(cfg_samplePredRefLayerIds[layer].c_str());
    2373     if( m_acLayerCfg[layer].m_numSamplePredRefLayers > 0 )
     2409    if( m_apcLayerCfg[layer]->m_numSamplePredRefLayers > 0 )
    23742410    {
    23752411      char *samplePredRefLayerId;
    23762412      int  i=0;
    2377       m_acLayerCfg[layer].m_samplePredRefLayerIds = new Int[m_acLayerCfg[layer].m_numSamplePredRefLayers];
     2413      m_apcLayerCfg[layer]->m_samplePredRefLayerIds = new Int[m_apcLayerCfg[layer]->m_numSamplePredRefLayers];
    23782414      samplePredRefLayerId = strtok(pSamplePredRefLayerIds, " ,-");
    23792415      while(samplePredRefLayerId != NULL)
    23802416      {
    2381         if( i >= m_acLayerCfg[layer].m_numSamplePredRefLayers )
     2417        if( i >= m_apcLayerCfg[layer]->m_numSamplePredRefLayers )
    23822418        {
    23832419          printf( "NumSamplePredRefLayers%d: The number of columns whose width are defined is larger than the allowed number of columns.\n", layer );
    23842420          exit( EXIT_FAILURE );
    23852421        }
    2386         *( m_acLayerCfg[layer].m_samplePredRefLayerIds + i ) = atoi( samplePredRefLayerId );
     2422        *( m_apcLayerCfg[layer]->m_samplePredRefLayerIds + i ) = atoi( samplePredRefLayerId );
    23872423        samplePredRefLayerId = strtok(NULL, " ,-");
    23882424        i++;
    23892425      }
    2390       if( i < m_acLayerCfg[layer].m_numSamplePredRefLayers )
     2426      if( i < m_apcLayerCfg[layer]->m_numSamplePredRefLayers )
    23912427      {
    23922428        printf( "NumSamplePredRefLayers%d: The width of some columns is not defined.\n", layer );
     
    23962432    else
    23972433    {
    2398       m_acLayerCfg[layer].m_samplePredRefLayerIds = NULL;
     2434      m_apcLayerCfg[layer]->m_samplePredRefLayerIds = NULL;
    23992435    }
    24002436
     
    24062442
    24072443    Char* pMotionPredRefLayerIds = cfg_motionPredRefLayerIds[layer].empty() ? NULL: strdup(cfg_motionPredRefLayerIds[layer].c_str());
    2408     if( m_acLayerCfg[layer].m_numMotionPredRefLayers > 0 )
     2444    if( m_apcLayerCfg[layer]->m_numMotionPredRefLayers > 0 )
    24092445    {
    24102446      char *motionPredRefLayerId;
    24112447      int  i=0;
    2412       m_acLayerCfg[layer].m_motionPredRefLayerIds = new Int[m_acLayerCfg[layer].m_numMotionPredRefLayers];
     2448      m_apcLayerCfg[layer]->m_motionPredRefLayerIds = new Int[m_apcLayerCfg[layer]->m_numMotionPredRefLayers];
    24132449      motionPredRefLayerId = strtok(pMotionPredRefLayerIds, " ,-");
    24142450      while(motionPredRefLayerId != NULL)
    24152451      {
    2416         if( i >= m_acLayerCfg[layer].m_numMotionPredRefLayers )
     2452        if( i >= m_apcLayerCfg[layer]->m_numMotionPredRefLayers )
    24172453        {
    24182454          printf( "NumMotionPredRefLayers%d: The number of columns whose width are defined is larger than the allowed number of columns.\n", layer );
    24192455          exit( EXIT_FAILURE );
    24202456        }
    2421         *( m_acLayerCfg[layer].m_motionPredRefLayerIds + i ) = atoi( motionPredRefLayerId );
     2457        *( m_apcLayerCfg[layer]->m_motionPredRefLayerIds + i ) = atoi( motionPredRefLayerId );
    24222458        motionPredRefLayerId = strtok(NULL, " ,-");
    24232459        i++;
    24242460      }
    2425       if( i < m_acLayerCfg[layer].m_numMotionPredRefLayers )
     2461      if( i < m_apcLayerCfg[layer]->m_numMotionPredRefLayers )
    24262462      {
    24272463        printf( "NumMotionPredRefLayers%d: The width of some columns is not defined.\n", layer );
     
    24312467    else
    24322468    {
    2433       m_acLayerCfg[layer].m_motionPredRefLayerIds = NULL;
     2469      m_apcLayerCfg[layer]->m_motionPredRefLayerIds = NULL;
    24342470    }
    24352471
     
    24412477
    24422478    Char* pPredLayerIds = cfg_predLayerIds[layer].empty() ? NULL: strdup(cfg_predLayerIds[layer].c_str());
    2443     if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 )
     2479    if( m_apcLayerCfg[layer]->m_numActiveRefLayers > 0 )
    24442480    {
    24452481      char *refLayerId;
    24462482      int  i=0;
    2447       m_acLayerCfg[layer].m_predLayerIds = new Int[m_acLayerCfg[layer].m_numActiveRefLayers];
     2483      m_apcLayerCfg[layer]->m_predLayerIds = new Int[m_apcLayerCfg[layer]->m_numActiveRefLayers];
    24482484      refLayerId = strtok(pPredLayerIds, " ,-");
    24492485      while(refLayerId != NULL)
    24502486      {
    2451         if( i >= m_acLayerCfg[layer].m_numActiveRefLayers )
     2487        if( i >= m_apcLayerCfg[layer]->m_numActiveRefLayers )
    24522488        {
    24532489          printf( "NumActiveRefLayers%d: The number of columns whose width are defined is larger than the allowed number of columns.\n", layer );
    24542490          exit( EXIT_FAILURE );
    24552491        }
    2456         *( m_acLayerCfg[layer].m_predLayerIds + i ) = atoi( refLayerId );
     2492        *( m_apcLayerCfg[layer]->m_predLayerIds + i ) = atoi( refLayerId );
    24572493        refLayerId = strtok(NULL, " ,-");
    24582494        i++;
    24592495      }
    2460       if( i < m_acLayerCfg[layer].m_numActiveRefLayers )
     2496      if( i < m_apcLayerCfg[layer]->m_numActiveRefLayers )
    24612497      {
    24622498        printf( "NumActiveRefLayers%d: The width of some columns is not defined.\n", layer );
     
    24662502    else
    24672503    {
    2468       m_acLayerCfg[layer].m_predLayerIds = NULL;
     2504      m_apcLayerCfg[layer]->m_predLayerIds = NULL;
    24692505    }
    24702506
     
    24742510      pPredLayerIds = NULL;
    24752511    }
    2476   } //for(Int layer = 0; layer < MAX_LAYERS; layer++)
     2512  } //for(Int layer = 0; layer < m_numLayers; layer++)
    24772513
    24782514  for (Int layerSet = 1; layerSet < m_numLayerSets; layerSet++)
     
    29192955  {
    29202956    UInt uiAddCUDepth  = 0;
    2921     while( (m_acLayerCfg[layerIdx].m_uiMaxCUWidth>>m_acLayerCfg[layerIdx].m_uiMaxCUDepth) > ( 1 << ( m_acLayerCfg[layerIdx].m_uiQuadtreeTULog2MinSize + uiAddCUDepth )  ) )
     2957    while( (m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth>>m_apcLayerCfg[layerIdx]->m_uiMaxCUDepth) > ( 1 << ( m_apcLayerCfg[layerIdx]->m_uiQuadtreeTULog2MinSize + uiAddCUDepth )  ) )
    29222958    {
    29232959      uiAddCUDepth++;
    29242960    }
    29252961
    2926     m_acLayerCfg[layerIdx].m_uiMaxTotalCUDepth = m_acLayerCfg[layerIdx].m_uiMaxCUDepth + uiAddCUDepth + getMaxCUDepthOffset(m_acLayerCfg[layerIdx].m_chromaFormatIDC, m_acLayerCfg[layerIdx].m_uiQuadtreeTULog2MinSize); // if minimum TU larger than 4x4, allow for additional part indices for 4:2:2 SubTUs.   
    2927     m_acLayerCfg[layerIdx].m_uiLog2DiffMaxMinCodingBlockSize = m_acLayerCfg[layerIdx].m_uiMaxCUDepth - 1;
     2962    m_apcLayerCfg[layerIdx]->m_uiMaxTotalCUDepth = m_apcLayerCfg[layerIdx]->m_uiMaxCUDepth + uiAddCUDepth + getMaxCUDepthOffset(m_apcLayerCfg[layerIdx]->m_chromaFormatIDC, m_apcLayerCfg[layerIdx]->m_uiQuadtreeTULog2MinSize); // if minimum TU larger than 4x4, allow for additional part indices for 4:2:2 SubTUs.   
     2963    m_apcLayerCfg[layerIdx]->m_uiLog2DiffMaxMinCodingBlockSize = m_apcLayerCfg[layerIdx]->m_uiMaxCUDepth - 1;
    29282964  }
    29292965#else 
     
    29522988Void TAppEncCfg::xCheckParameter(UInt layerIdx)
    29532989{
    2954   Bool m_extendedPrecisionProcessingFlag     = m_acLayerCfg[layerIdx].m_extendedPrecisionProcessingFlag;
    2955   Bool m_highPrecisionOffsetsEnabledFlag     = m_acLayerCfg[layerIdx].m_highPrecisionOffsetsEnabledFlag;
    2956   ChromaFormat m_chromaFormatIDC             = m_acLayerCfg[layerIdx].m_chromaFormatIDC;
    2957   ChromaFormat m_chromaFormatConstraint      = m_acLayerCfg[layerIdx].m_chromaFormatConstraint;
    2958   ChromaFormat m_InputChromaFormatIDC        = m_acLayerCfg[layerIdx].m_InputChromaFormatIDC;
    2959 
    2960   Int m_inputBitDepth[]       = {m_acLayerCfg[layerIdx].m_inputBitDepth[CHANNEL_TYPE_LUMA],       m_acLayerCfg[layerIdx].m_inputBitDepth[CHANNEL_TYPE_CHROMA]};
    2961   Int m_internalBitDepth[]    = {m_acLayerCfg[layerIdx].m_internalBitDepth[CHANNEL_TYPE_LUMA],    m_acLayerCfg[layerIdx].m_internalBitDepth[CHANNEL_TYPE_CHROMA]};
    2962   Int m_MSBExtendedBitDepth[] = {m_acLayerCfg[layerIdx].m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layerIdx].m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA]}; 
    2963 
    2964   m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA]   = m_acLayerCfg[layerIdx].m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA];
    2965   m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layerIdx].m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA];
    2966 
    2967   Int layerPTLIdx = m_acLayerCfg[layerIdx].m_layerPTLIdx;
     2990  Bool m_extendedPrecisionProcessingFlag     = m_apcLayerCfg[layerIdx]->m_extendedPrecisionProcessingFlag;
     2991  Bool m_highPrecisionOffsetsEnabledFlag     = m_apcLayerCfg[layerIdx]->m_highPrecisionOffsetsEnabledFlag;
     2992  ChromaFormat m_chromaFormatIDC             = m_apcLayerCfg[layerIdx]->m_chromaFormatIDC;
     2993  ChromaFormat m_chromaFormatConstraint      = m_apcLayerCfg[layerIdx]->m_chromaFormatConstraint;
     2994  ChromaFormat m_InputChromaFormatIDC        = m_apcLayerCfg[layerIdx]->m_InputChromaFormatIDC;
     2995
     2996  Int m_inputBitDepth[]       = {m_apcLayerCfg[layerIdx]->m_inputBitDepth[CHANNEL_TYPE_LUMA],       m_apcLayerCfg[layerIdx]->m_inputBitDepth[CHANNEL_TYPE_CHROMA]};
     2997  Int m_internalBitDepth[]    = {m_apcLayerCfg[layerIdx]->m_internalBitDepth[CHANNEL_TYPE_LUMA],    m_apcLayerCfg[layerIdx]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]};
     2998  Int m_MSBExtendedBitDepth[] = {m_apcLayerCfg[layerIdx]->m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layerIdx]->m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA]}; 
     2999
     3000  m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA]   = m_apcLayerCfg[layerIdx]->m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA];
     3001  m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] = m_apcLayerCfg[layerIdx]->m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA];
     3002
     3003  Int layerPTLIdx = m_apcLayerCfg[layerIdx]->m_layerPTLIdx;
    29683004  Profile::Name m_profile             = m_profileList[layerPTLIdx];
    2969   UInt m_bitDepthConstraint           = m_acLayerCfg[layerIdx].m_bitDepthConstraint;
    2970   Bool m_intraConstraintFlag          = m_acLayerCfg[layerIdx].m_intraConstraintFlag;
    2971   Bool m_lowerBitRateConstraintFlag   = m_acLayerCfg[layerIdx].m_lowerBitRateConstraintFlag;
    2972   Bool m_onePictureOnlyConstraintFlag = m_acLayerCfg[layerIdx].m_onePictureOnlyConstraintFlag;
     3005  UInt m_bitDepthConstraint           = m_apcLayerCfg[layerIdx]->m_bitDepthConstraint;
     3006  Bool m_intraConstraintFlag          = m_apcLayerCfg[layerIdx]->m_intraConstraintFlag;
     3007  Bool m_lowerBitRateConstraintFlag   = m_apcLayerCfg[layerIdx]->m_lowerBitRateConstraintFlag;
     3008  Bool m_onePictureOnlyConstraintFlag = m_apcLayerCfg[layerIdx]->m_onePictureOnlyConstraintFlag;
    29733009#else
    29743010Void TAppEncCfg::xCheckParameter()
     
    33233359   * This permits the ability to omit a GOP structure specification */
    33243360#if SVC_EXTENSION
    3325   if( m_acLayerCfg[0].m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1 )
     3361  if( m_apcLayerCfg[0]->m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1 )
    33263362  {
    33273363    m_GOPList[0] = GOPEntry();
     
    33373373  }
    33383374
    3339   if (m_acLayerCfg[layerIdx].m_iIntraPeriod == 1 && m_EhGOPList[layerIdx][0].m_POC == -1) {
     3375  if (m_apcLayerCfg[layerIdx]->m_iIntraPeriod == 1 && m_EhGOPList[layerIdx][0].m_POC == -1) {
    33403376    m_EhGOPList[layerIdx][0] = GOPEntry();
    33413377    m_EhGOPList[layerIdx][0].m_QPFactor = 1;
     
    34063442
    34073443  // verify layer configuration parameters
    3408   if(m_acLayerCfg[layerIdx].xCheckParameter(m_isField))
     3444  if(m_apcLayerCfg[layerIdx]->xCheckParameter(m_isField))
    34093445  {
    34103446    printf("\nError: invalid configuration parameter found in layer %d \n", layerIdx);
     
    34133449
    34143450  // verify layer configuration parameters
    3415   Int m_iIntraPeriod = m_acLayerCfg[layerIdx].m_iIntraPeriod;
     3451  Int m_iIntraPeriod = m_apcLayerCfg[layerIdx]->m_iIntraPeriod;
    34163452#endif
    34173453  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && (!m_bLoopFilterDisable) )
     
    37263762    for(UInt layer=0; layer<m_numLayers; layer++)
    37273763    {
    3728       if ( (m_acLayerCfg[layer].m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && (!m_bLoopFilterDisable) )
     3764      if ( (m_apcLayerCfg[layer]->m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && (!m_bLoopFilterDisable) )
    37293765      {
    37303766        for(Int i=0; i<m_iGOPSize; i++)
     
    40184054
    40194055#if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers
    4020   Int m_iSourceWidth = m_acLayerCfg[layerIdx].m_iSourceWidth;
    4021   Int m_iSourceHeight = m_acLayerCfg[layerIdx].m_iSourceHeight;
    4022   Int m_uiMaxCUWidth = m_acLayerCfg[layerIdx].m_uiMaxCUWidth;
    4023   Int m_uiMaxCUHeight = m_acLayerCfg[layerIdx].m_uiMaxCUHeight;
     4056  Int m_iSourceWidth = m_apcLayerCfg[layerIdx]->m_iSourceWidth;
     4057  Int m_iSourceHeight = m_apcLayerCfg[layerIdx]->m_iSourceHeight;
     4058  Int m_uiMaxCUWidth = m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth;
     4059  Int m_uiMaxCUHeight = m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight;
    40244060
    40254061  Bool tileFlag = (m_numTileColumnsMinus1 > 0 || m_numTileRowsMinus1 > 0 );
    4026   Int m_iWaveFrontSynchro = m_acLayerCfg[layerIdx].m_waveFrontSynchro;
     4062  Int m_iWaveFrontSynchro = m_apcLayerCfg[layerIdx]->m_waveFrontSynchro;
    40274063  xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
    40284064#endif
     
    41574193
    41584194#if RC_SHVC_HARMONIZATION
    4159   if ( m_acLayerCfg[layerIdx].m_RCEnableRateControl )
    4160   {
    4161     if ( m_acLayerCfg[layerIdx].m_RCForceIntraQP )
    4162     {
    4163       if ( m_acLayerCfg[layerIdx].m_RCInitialQP == 0 )
     4195  if ( m_apcLayerCfg[layerIdx]->m_RCEnableRateControl )
     4196  {
     4197    if ( m_apcLayerCfg[layerIdx]->m_RCForceIntraQP )
     4198    {
     4199      if ( m_apcLayerCfg[layerIdx]->m_RCInitialQP == 0 )
    41644200      {
    41654201        printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" );
    4166         m_acLayerCfg[layerIdx].m_RCForceIntraQP = false;
     4202        m_apcLayerCfg[layerIdx]->m_RCForceIntraQP = false;
    41674203      }
    41684204    }
     
    42104246
    42114247#if SVC_EXTENSION
    4212   xConfirmPara( (m_acLayerCfg[0].m_numSamplePredRefLayers != 0) && (m_acLayerCfg[0].m_numSamplePredRefLayers != -1), "Layer 0 cannot have any reference layers" );
     4248  xConfirmPara( (m_apcLayerCfg[0]->m_numSamplePredRefLayers != 0) && (m_apcLayerCfg[0]->m_numSamplePredRefLayers != -1), "Layer 0 cannot have any reference layers" );
    42134249  // NOTE: m_numSamplePredRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
    42144250  if( layerIdx > 0 )
    42154251  {
    4216     xConfirmPara(m_acLayerCfg[layerIdx].m_numSamplePredRefLayers > layerIdx, "Cannot reference more layers than before current layer");
    4217     for(Int i = 0; i < m_acLayerCfg[layerIdx].m_numSamplePredRefLayers; i++)
    4218     {
    4219       xConfirmPara(m_acLayerCfg[layerIdx].m_samplePredRefLayerIds[i] > m_acLayerCfg[layerIdx].m_layerId, "Cannot reference higher layers");
    4220       xConfirmPara(m_acLayerCfg[layerIdx].m_samplePredRefLayerIds[i] == m_acLayerCfg[layerIdx].m_layerId, "Cannot reference the current layer itself");
    4221     }
    4222   }
    4223   xConfirmPara( (m_acLayerCfg[0].m_numMotionPredRefLayers != 0) && (m_acLayerCfg[0].m_numMotionPredRefLayers != -1), "Layer 0 cannot have any reference layers" );
     4252    xConfirmPara(m_apcLayerCfg[layerIdx]->m_numSamplePredRefLayers > layerIdx, "Cannot reference more layers than before current layer");
     4253    for(Int i = 0; i < m_apcLayerCfg[layerIdx]->m_numSamplePredRefLayers; i++)
     4254    {
     4255      xConfirmPara(m_apcLayerCfg[layerIdx]->m_samplePredRefLayerIds[i] > m_apcLayerCfg[layerIdx]->m_layerId, "Cannot reference higher layers");
     4256      xConfirmPara(m_apcLayerCfg[layerIdx]->m_samplePredRefLayerIds[i] == m_apcLayerCfg[layerIdx]->m_layerId, "Cannot reference the current layer itself");
     4257    }
     4258  }
     4259  xConfirmPara( (m_apcLayerCfg[0]->m_numMotionPredRefLayers != 0) && (m_apcLayerCfg[0]->m_numMotionPredRefLayers != -1), "Layer 0 cannot have any reference layers" );
    42244260  // NOTE: m_numMotionPredRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
    42254261  if( layerIdx > 0 )
    42264262  {
    4227     xConfirmPara(m_acLayerCfg[layerIdx].m_numMotionPredRefLayers > layerIdx, "Cannot reference more layers than before current layer");
    4228     for(Int i = 0; i < m_acLayerCfg[layerIdx].m_numMotionPredRefLayers; i++)
    4229     {
    4230       xConfirmPara(m_acLayerCfg[layerIdx].m_motionPredRefLayerIds[i] > m_acLayerCfg[layerIdx].m_layerId, "Cannot reference higher layers");
    4231       xConfirmPara(m_acLayerCfg[layerIdx].m_motionPredRefLayerIds[i] == m_acLayerCfg[layerIdx].m_layerId, "Cannot reference the current layer itself");
    4232     }
    4233   }
    4234 
    4235   xConfirmPara( (m_acLayerCfg[0].m_numActiveRefLayers != 0) && (m_acLayerCfg[0].m_numActiveRefLayers != -1), "Layer 0 cannot have any active reference layers" );
     4263    xConfirmPara(m_apcLayerCfg[layerIdx]->m_numMotionPredRefLayers > layerIdx, "Cannot reference more layers than before current layer");
     4264    for(Int i = 0; i < m_apcLayerCfg[layerIdx]->m_numMotionPredRefLayers; i++)
     4265    {
     4266      xConfirmPara(m_apcLayerCfg[layerIdx]->m_motionPredRefLayerIds[i] > m_apcLayerCfg[layerIdx]->m_layerId, "Cannot reference higher layers");
     4267      xConfirmPara(m_apcLayerCfg[layerIdx]->m_motionPredRefLayerIds[i] == m_apcLayerCfg[layerIdx]->m_layerId, "Cannot reference the current layer itself");
     4268    }
     4269  }
     4270
     4271  xConfirmPara( (m_apcLayerCfg[0]->m_numActiveRefLayers != 0) && (m_apcLayerCfg[0]->m_numActiveRefLayers != -1), "Layer 0 cannot have any active reference layers" );
    42364272  // NOTE: m_numActiveRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
    42374273  if( layerIdx > 0 )
     
    42424278      predEnabledFlag[refLayer] = false;
    42434279    }
    4244     for(Int i = 0; i < m_acLayerCfg[layerIdx].m_numSamplePredRefLayers; i++)
    4245     {
    4246       predEnabledFlag[m_acLayerCfg[layerIdx].m_samplePredRefLayerIds[i]] = true;
    4247     }
    4248     for(Int i = 0; i < m_acLayerCfg[layerIdx].m_numMotionPredRefLayers; i++)
    4249     {
    4250       predEnabledFlag[m_acLayerCfg[layerIdx].m_motionPredRefLayerIds[i]] = true;
     4280    for(Int i = 0; i < m_apcLayerCfg[layerIdx]->m_numSamplePredRefLayers; i++)
     4281    {
     4282      predEnabledFlag[m_apcLayerCfg[layerIdx]->m_samplePredRefLayerIds[i]] = true;
     4283    }
     4284    for(Int i = 0; i < m_apcLayerCfg[layerIdx]->m_numMotionPredRefLayers; i++)
     4285    {
     4286      predEnabledFlag[m_apcLayerCfg[layerIdx]->m_motionPredRefLayerIds[i]] = true;
    42514287    }
    42524288    Int numDirectRefLayers = 0;
     
    42554291      if (predEnabledFlag[refLayer] == true) numDirectRefLayers++;
    42564292    }
    4257     xConfirmPara(m_acLayerCfg[layerIdx].m_numActiveRefLayers > numDirectRefLayers, "Cannot reference more layers than NumDirectRefLayers");
    4258     for(Int i = 0; i < m_acLayerCfg[layerIdx].m_numActiveRefLayers; i++)
    4259     {
    4260       xConfirmPara(m_acLayerCfg[layerIdx].m_predLayerIds[i] >= numDirectRefLayers, "Cannot reference higher layers");
     4293    xConfirmPara(m_apcLayerCfg[layerIdx]->m_numActiveRefLayers > numDirectRefLayers, "Cannot reference more layers than NumDirectRefLayers");
     4294    for(Int i = 0; i < m_apcLayerCfg[layerIdx]->m_numActiveRefLayers; i++)
     4295    {
     4296      xConfirmPara(m_apcLayerCfg[layerIdx]->m_predLayerIds[i] >= numDirectRefLayers, "Cannot reference higher layers");
    42614297    }
    42624298  }
     
    42654301  {
    42664302    xConfirmPara(m_numLayers != 2, "Adaptive resolution change works with 2 layers only");
    4267     xConfirmPara(m_acLayerCfg[1].m_iIntraPeriod == 0 || (m_adaptiveResolutionChange % m_acLayerCfg[1].m_iIntraPeriod) != 0, "Adaptive resolution change must happen at enhancement layer RAP picture");
     4303    xConfirmPara(m_apcLayerCfg[1]->m_iIntraPeriod == 0 || (m_adaptiveResolutionChange % m_apcLayerCfg[1]->m_iIntraPeriod) != 0, "Adaptive resolution change must happen at enhancement layer RAP picture");
    42684304  }
    42694305
     
    42804316  if( layerIdx < MAX_LAYERS-1 )
    42814317  {
    4282     xConfirmPara(m_acLayerCfg[layerIdx].m_maxTidIlRefPicsPlus1 < 0 || m_acLayerCfg[layerIdx].m_maxTidIlRefPicsPlus1 > 7, "MaxTidIlRefPicsPlus1 must be in range 0 to 7");
     4318    xConfirmPara(m_apcLayerCfg[layerIdx]->m_maxTidIlRefPicsPlus1 < 0 || m_apcLayerCfg[layerIdx]->m_maxTidIlRefPicsPlus1 > 7, "MaxTidIlRefPicsPlus1 must be in range 0 to 7");
    42834319  }
    42844320#if AUXILIARY_PICTURES
    42854321  if( layerIdx < MAX_LAYERS-1 )
    42864322  {
    4287     xConfirmPara(m_acLayerCfg[layerIdx].m_auxId < 0 || m_acLayerCfg[layerIdx].m_auxId > 2, "AuxId must be in range 0 to 2");
     4323    xConfirmPara(m_apcLayerCfg[layerIdx]->m_auxId < 0 || m_apcLayerCfg[layerIdx]->m_auxId > 2, "AuxId must be in range 0 to 2");
    42884324  }
    42894325#endif
     
    43414377  {
    43424378    printf("=== Layer %d settings === \n", layer);
    4343     m_acLayerCfg[layer].xPrintParameter();
     4379    m_apcLayerCfg[layer]->xPrintParameter();
    43444380    printf("\n");
    43454381  }
     
    47044740{
    47054741  Int *tempArray = NULL;
    4706   numEntries = MAX_LAYERS;
     4742  numEntries = m_numLayers;
    47074743  // For all layer sets
    47084744  cfgStringToArrayNumEntries(&tempArray, cfgString, numEntries, logString);
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h

    r1375 r1377  
    6060  // file I/O
    6161#if SVC_EXTENSION
    62   TAppEncLayerCfg m_acLayerCfg [MAX_LAYERS];
     62  TAppEncLayerCfg* m_apcLayerCfg[MAX_LAYERS];
    6363  Int       m_layerId;
    6464  Int       m_numLayers;                                      ///< number of layers
     
    551551 
    552552#if SVC_EXTENSION
     553  Bool parseCfgNumLayersAndInit( Int argc, Char* argv[] );    ///< parse configuration file to to get number of layers and allocate memory
    553554  Int  getNumFrameToBeEncoded()                               { return m_framesToBeEncoded;                          }
    554555  Int  getNumLayer()                                          { return m_numLayers;                                  }
     
    559560  UInt getPCMLog2MinSize  ()                                  { return  m_uiPCMLog2MinSize;                          }
    560561
    561   UInt getInternalBitDepth(Int iLayer, ChannelType type)      { return m_acLayerCfg[iLayer].m_internalBitDepth[type];}
    562   Bool getPCMInputBitDepthFlag()                              { return m_bPCMInputBitDepthFlag;                      }
     562  UInt getInternalBitDepth(Int layer, ChannelType type)       { return m_apcLayerCfg[layer]->m_internalBitDepth[type];}
     563  Bool getPCMInputBitDepthFlag()                              { return m_bPCMInputBitDepthFlag;                       }
    563564
    564565  Int  getDecodingRefreshType()                               { return m_iDecodingRefreshType;                       }
    565   Int  getWaveFrontSynchro(Int layerIdx)                      { return m_acLayerCfg[layerIdx].m_waveFrontSynchro;    }
     566  Int  getWaveFrontSynchro(Int layerIdx)                      { return m_apcLayerCfg[layerIdx]->m_waveFrontSynchro;  }
    566567  Void getDirFilename(string& filename, string& dir, const string path);
    567568
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r1376 r1377  
    6464  m_essentialBytes = 0;
    6565#if SVC_EXTENSION
    66   for(UInt layer=0; layer < MAX_LAYERS; layer++)
    67   {
    68     m_apcTEncTop[layer] = &m_acTEncTop[layer];
    69   }
     66  memset( m_apcTVideoIOYuvInputFile, NULL, sizeof(m_apcTVideoIOYuvInputFile) );
     67  memset( m_apcTVideoIOYuvReconFile, NULL, sizeof(m_apcTVideoIOYuvReconFile) );
     68  memset( m_apcTEncTop, NULL, sizeof(m_apcTEncTop) );
    7069#endif
    7170}
     
    7574}
    7675
    77 #if SVC_EXTENSION
    7876Void TAppEncTop::xInitLibCfg()
    7977{
    80   TComVPS* vps = m_acTEncTop[0].getVPS();
    81 
    82   vps->setVpsPocLsbAlignedFlag(false);
    83 
    84   vps->setMaxTLayers                                                      ( m_maxTempLayer );
     78#if SVC_EXTENSION
     79  TComVPS& vps = *m_apcTEncTop[0]->getVPS();
     80#else
     81  TComVPS vps;
     82#endif
     83
     84  vps.setMaxTLayers                                               ( m_maxTempLayer );
    8585  if (m_maxTempLayer == 1)
    8686  {
    87     vps->setTemporalNestingFlag(true);
    88   }
     87    vps.setTemporalNestingFlag(true);
     88  }
     89  vps.setMaxLayers                                                ( 1 );
    8990  for(Int i = 0; i < MAX_TLAYER; i++)
    9091  {
    91     vps->setNumReorderPics                                                ( m_numReorderPics[i], i );
    92     vps->setMaxDecPicBuffering                                            ( m_maxDecPicBuffering[i], i );
    93   }
     92    vps.setNumReorderPics                                         ( m_numReorderPics[i], i );
     93    vps.setMaxDecPicBuffering                                     ( m_maxDecPicBuffering[i], i );
     94  }
     95
     96#if !SVC_EXTENSION
     97  m_cTEncTop.setVPS(&vps);
     98#endif
     99 
     100#if SVC_EXTENSION
     101  vps.setVpsPocLsbAlignedFlag(false); 
    94102
    95103  Int maxRepFormatIdx = -1;
     
    98106  {
    99107    // Auto generation of the format index
    100     if( m_acLayerCfg[layer].getRepFormatIdx() == -1 )
     108    if( m_apcLayerCfg[layer]->getRepFormatIdx() == -1 )
    101109    {     
    102110      Bool found = false;
    103111      for( UInt idx = 0; idx < layer; idx++ )
    104112      {
    105         if( m_acLayerCfg[layer].getSourceWidth() == m_acLayerCfg[idx].getSourceWidth() && m_acLayerCfg[layer].getSourceHeight() == m_acLayerCfg[idx].getSourceHeight()
     113        if( m_apcLayerCfg[layer]->getSourceWidth() == m_apcLayerCfg[idx]->getSourceWidth() && m_apcLayerCfg[layer]->getSourceHeight() == m_apcLayerCfg[idx]->getSourceHeight()
    106114#if AUXILIARY_PICTURES
    107           && m_acLayerCfg[layer].getChromaFormatIDC() == m_acLayerCfg[idx].getChromaFormatIDC()
    108 #endif
    109           && m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA] == m_acLayerCfg[idx].m_internalBitDepth[CHANNEL_TYPE_LUMA] && m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA] == m_acLayerCfg[idx].m_internalBitDepth[CHANNEL_TYPE_CHROMA]
     115          && m_apcLayerCfg[layer]->getChromaFormatIDC() == m_apcLayerCfg[idx]->getChromaFormatIDC()
     116#endif
     117          && m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA] == m_apcLayerCfg[idx]->m_internalBitDepth[CHANNEL_TYPE_LUMA] && m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA] == m_apcLayerCfg[idx]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]
    110118          )
    111119        {
     
    119127      }
    120128
    121       m_acLayerCfg[layer].setRepFormatIdx( formatIdx );
    122     }
    123 
    124     assert( m_acLayerCfg[layer].getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" );
    125 
    126     vps->setVpsRepFormatIdx( layer, m_acLayerCfg[layer].getRepFormatIdx() );
    127 
    128     maxRepFormatIdx = std::max( m_acLayerCfg[layer].getRepFormatIdx(), maxRepFormatIdx );
    129   }
    130 
    131   assert( vps->getVpsRepFormatIdx( 0 ) == 0 );  // Base layer should point to the first one.
     129      m_apcLayerCfg[layer]->setRepFormatIdx( formatIdx );
     130    }
     131
     132    assert( m_apcLayerCfg[layer]->getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" );
     133
     134    vps.setVpsRepFormatIdx( layer, m_apcLayerCfg[layer]->getRepFormatIdx() );
     135
     136    maxRepFormatIdx = std::max( m_apcLayerCfg[layer]->getRepFormatIdx(), maxRepFormatIdx );
     137  }
     138
     139  assert( vps.getVpsRepFormatIdx( 0 ) == 0 );  // Base layer should point to the first one.
    132140
    133141  Int* mapIdxToLayer = new Int[maxRepFormatIdx + 1];
     
    140148    for(layer=0; layer < m_numLayers; layer++)
    141149    {
    142       if( vps->getVpsRepFormatIdx(layer) == i )
     150      if( vps.getVpsRepFormatIdx(layer) == i )
    143151      {
    144152        mapIdxToLayer[i] = layer;
     
    149157  }
    150158
    151   vps->setVpsNumRepFormats                                                ( maxRepFormatIdx + 1 );
     159  vps.setVpsNumRepFormats                                                ( maxRepFormatIdx + 1 );
    152160
    153161  // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0
    154   vps->setRepFormatIdxPresentFlag                                         ( vps->getVpsNumRepFormats() > 1 ? true : false );
    155 
    156   for(UInt idx=0; idx < vps->getVpsNumRepFormats(); idx++)
    157   {
    158     RepFormat *repFormat = vps->getVpsRepFormat( idx );
     162  vps.setRepFormatIdxPresentFlag                                         ( vps.getVpsNumRepFormats() > 1 ? true : false );
     163
     164  for(UInt idx=0; idx < vps.getVpsNumRepFormats(); idx++)
     165  {
     166    RepFormat *repFormat = vps.getVpsRepFormat( idx );
    159167    repFormat->setChromaAndBitDepthVpsPresentFlag                         ( true );
    160168    if (idx==0)
     
    163171    }
    164172
    165     repFormat->setPicWidthVpsInLumaSamples                                ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceWidth()   );
    166     repFormat->setPicHeightVpsInLumaSamples                               ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceHeight()  );
     173    repFormat->setPicWidthVpsInLumaSamples                                ( m_apcLayerCfg[mapIdxToLayer[idx]]->getSourceWidth()   );
     174    repFormat->setPicHeightVpsInLumaSamples                               ( m_apcLayerCfg[mapIdxToLayer[idx]]->getSourceHeight()  );
    167175#if AUXILIARY_PICTURES
    168     repFormat->setChromaFormatVpsIdc                                      ( m_acLayerCfg[mapIdxToLayer[idx]].getChromaFormatIDC() );
     176    repFormat->setChromaFormatVpsIdc                                      ( m_apcLayerCfg[mapIdxToLayer[idx]]->getChromaFormatIDC() );
    169177#else
    170178    repFormat->setChromaFormatVpsIdc                                      ( 1 );  // Need modification to change for each layer - corresponds to 420
     
    175183    repFormat->setBitDepthVpsChroma                                       ( getInternalBitDepth(mapIdxToLayer[idx], CHANNEL_TYPE_CHROMA)    );  // Need modification to change for each layer
    176184
    177     repFormat->getConformanceWindowVps().setWindow                        ( m_acLayerCfg[mapIdxToLayer[idx]].m_confWinLeft,                                                                             
    178                                                                             m_acLayerCfg[mapIdxToLayer[idx]].m_confWinRight,
    179                                                                             m_acLayerCfg[mapIdxToLayer[idx]].m_confWinTop,
    180                                                                             m_acLayerCfg[mapIdxToLayer[idx]].m_confWinBottom );
    181 
    182     m_acTEncTop[mapIdxToLayer[idx]].setSkipPictureAtArcSwitch             ( m_skipPictureAtArcSwitch );
     185    repFormat->getConformanceWindowVps().setWindow                        ( m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinLeft,                                                                             
     186                                                                            m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinRight,
     187                                                                            m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinTop,
     188                                                                            m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinBottom );
     189
     190    m_apcTEncTop[mapIdxToLayer[idx]]->setSkipPictureAtArcSwitch           ( m_skipPictureAtArcSwitch );
    183191  }
    184192
     
    186194
    187195  //Populate PTL in VPS
    188   TComVPS *pVPS = m_acTEncTop[0].getVPS();
    189196  for( Int ii = 0; ii < m_numPTLInfo; ii++ )
    190197  {
    191     pVPS->getPTL(ii)->getGeneralPTL()->setLevelIdc(m_levelList[ii]);
    192     pVPS->getPTL(ii)->getGeneralPTL()->setTierFlag(m_levelTierList[ii]);
    193     pVPS->getPTL(ii)->getGeneralPTL()->setProfileIdc(m_profileList[ii]);
    194     pVPS->getPTL(ii)->getGeneralPTL()->setProfileCompatibilityFlag(m_profileCompatibility[ii], 1);
    195     pVPS->getPTL(ii)->getGeneralPTL()->setProgressiveSourceFlag(m_progressiveSourceFlagList[ii]);
    196     pVPS->getPTL(ii)->getGeneralPTL()->setInterlacedSourceFlag(m_interlacedSourceFlagList[ii]);
    197     pVPS->getPTL(ii)->getGeneralPTL()->setNonPackedConstraintFlag(m_nonPackedConstraintFlagList[ii]);
    198     pVPS->getPTL(ii)->getGeneralPTL()->setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlagList[ii]);
    199   }
    200   pVPS->setNumProfileTierLevel(m_numPTLInfo);
     198    vps.getPTL(ii)->getGeneralPTL()->setLevelIdc(m_levelList[ii]);
     199    vps.getPTL(ii)->getGeneralPTL()->setTierFlag(m_levelTierList[ii]);
     200    vps.getPTL(ii)->getGeneralPTL()->setProfileIdc(m_profileList[ii]);
     201    vps.getPTL(ii)->getGeneralPTL()->setProfileCompatibilityFlag(m_profileCompatibility[ii], 1);
     202    vps.getPTL(ii)->getGeneralPTL()->setProgressiveSourceFlag(m_progressiveSourceFlagList[ii]);
     203    vps.getPTL(ii)->getGeneralPTL()->setInterlacedSourceFlag(m_interlacedSourceFlagList[ii]);
     204    vps.getPTL(ii)->getGeneralPTL()->setNonPackedConstraintFlag(m_nonPackedConstraintFlagList[ii]);
     205    vps.getPTL(ii)->getGeneralPTL()->setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlagList[ii]);
     206  }
     207  vps.setNumProfileTierLevel(m_numPTLInfo);
    201208
    202209  std::vector<Int> myvector;
    203   vps->getProfileLevelTierIdx()->resize(m_numOutputLayerSets);
     210  vps.getProfileLevelTierIdx()->resize(m_numOutputLayerSets);
    204211  for( Int ii = 0; ii < m_numOutputLayerSets; ii++ )
    205212  {
     
    208215    for( std::vector<Int>::iterator it = myvector.begin() ; it != myvector.end(); ++it )
    209216    {
    210       pVPS->addProfileLevelTierIdx(ii, it[0]);
     217      vps.addProfileLevelTierIdx(ii, it[0]);
    211218    }
    212219  }
     
    214221  assert( m_numLayers <= MAX_LAYERS );
    215222
    216   for(UInt layer=0; layer<m_numLayers; layer++)
    217   {
     223  for( UInt layer=0; layer < m_numLayers; layer++ )
     224  {
     225    TEncTop& m_cTEncTop = *m_apcTEncTop[layer];
    218226    //1
    219     m_acTEncTop[layer].setInterLayerWeightedPredFlag                      ( m_useInterLayerWeightedPred );
    220    
    221     Int layerPTLIdx = m_acLayerCfg[layer].m_layerPTLIdx;
    222     m_acTEncTop[layer].setProfile                                         ( m_profileList[layerPTLIdx] );
    223     m_acTEncTop[layer].setLevel                                           ( m_levelTierList[layerPTLIdx], m_levelList[layerPTLIdx] );
    224     m_acTEncTop[layer].setProgressiveSourceFlag                           ( m_progressiveSourceFlagList[layerPTLIdx] );
    225     m_acTEncTop[layer].setInterlacedSourceFlag                            ( m_interlacedSourceFlagList[layerPTLIdx] );
    226     m_acTEncTop[layer].setNonPackedConstraintFlag                         ( m_nonPackedConstraintFlagList[layerPTLIdx] );
    227     m_acTEncTop[layer].setFrameOnlyConstraintFlag                         ( m_frameOnlyConstraintFlagList[layerPTLIdx] );
    228     m_acTEncTop[layer].setBitDepthConstraintValue                         ( m_acLayerCfg[layer].m_bitDepthConstraint );
    229     m_acTEncTop[layer].setChromaFormatConstraintValue                     ( m_acLayerCfg[layer].m_chromaFormatConstraint );
    230     m_acTEncTop[layer].setIntraConstraintFlag                             ( m_acLayerCfg[layer].m_intraConstraintFlag );
    231     m_acTEncTop[layer].setOnePictureOnlyConstraintFlag                    ( m_acLayerCfg[layer].m_onePictureOnlyConstraintFlag );
    232     m_acTEncTop[layer].setLowerBitRateConstraintFlag                      ( m_acLayerCfg[layer].m_lowerBitRateConstraintFlag );
    233 
    234     m_acTEncTop[layer].setPrintMSEBasedSequencePSNR                       ( m_printMSEBasedSequencePSNR);
    235     m_acTEncTop[layer].setPrintFrameMSE                                   ( m_printFrameMSE);
    236     m_acTEncTop[layer].setPrintSequenceMSE                                ( m_printSequenceMSE);
    237     m_acTEncTop[layer].setCabacZeroWordPaddingEnabled                     ( m_cabacZeroWordPaddingEnabled );
    238 
    239     m_acTEncTop[layer].setFrameRate                                       ( m_acLayerCfg[layer].getFrameRate() );
    240     m_acTEncTop[layer].setFrameSkip                                       ( m_FrameSkip );
    241     m_acTEncTop[layer].setSourceWidth                                     ( m_acLayerCfg[layer].getSourceWidth() );
    242     m_acTEncTop[layer].setSourceHeight                                    ( m_acLayerCfg[layer].getSourceHeight() );
    243     m_acTEncTop[layer].setConformanceWindow                               ( m_acLayerCfg[layer].m_confWinLeft, m_acLayerCfg[layer].m_confWinRight, m_acLayerCfg[layer].m_confWinTop, m_acLayerCfg[layer].m_confWinBottom );
    244     m_acTEncTop[layer].setFramesToBeEncoded                               ( m_framesToBeEncoded );
    245 
    246 #if AVC_BASE
    247     m_acTEncTop[layer].setMFMEnabledFlag                                  (layer == 0 ? false : ( m_nonHEVCBaseLayerFlag ? false : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers());
    248 #else
    249     m_acTEncTop[layer].setMFMEnabledFlag                                  (layer == 0 ? false : ( m_acLayerCfg[layer].getNumMotionPredRefLayers() > 0 ) );
    250 #endif
     227    m_cTEncTop.setInterLayerWeightedPredFlag                      ( m_useInterLayerWeightedPred );
     228    m_cTEncTop.setMFMEnabledFlag                                  ( layer == 0 ? false : ( m_nonHEVCBaseLayerFlag ? false : true ) && m_apcLayerCfg[layer]->getNumMotionPredRefLayers());
    251229
    252230    // set layer ID
    253     m_acTEncTop[layer].setLayerId                                         ( m_acLayerCfg[layer].m_layerId );
    254     m_acTEncTop[layer].setNumLayer                                        ( m_numLayers );
    255     m_acTEncTop[layer].setLayerEnc                                        ( m_apcTEncTop );
    256 
    257     //====== Coding Structure ========
    258     m_acTEncTop[layer].setIntraPeriod                                     ( m_acLayerCfg[layer].m_iIntraPeriod );
    259     m_acTEncTop[layer].setDecodingRefreshType                             ( m_iDecodingRefreshType );
    260     m_acTEncTop[layer].setGOPSize                                         ( m_iGOPSize );
    261 
    262     m_acTEncTop[layer].setGopList                                         ( layer ? m_EhGOPList[layer] : m_GOPList );
    263     m_acTEncTop[layer].setExtraRPSs                                       ( m_extraRPSs[layer] );
    264 
    265     for(Int i = 0; i < MAX_TLAYER; i++)
    266     {
    267       m_acTEncTop[layer].setNumReorderPics                                ( m_numReorderPics[i], i );
    268       m_acTEncTop[layer].setMaxDecPicBuffering                            ( m_maxDecPicBuffering[i], i );
    269     }
    270     for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
    271     {
    272       m_acTEncTop[layer].setLambdaModifier                                ( uiLoop, m_adLambdaModifier[ uiLoop ] );
    273     }
    274     m_acTEncTop[layer].setQP                                              ( m_acLayerCfg[layer].getIntQP() );
    275 
    276     m_acTEncTop[layer].setPad                                             ( m_acLayerCfg[layer].getPad() );
    277 
    278     if (layer== 0)
    279     {
    280       m_acTEncTop[layer].setMaxTempLayer                                  ( m_maxTempLayer );
    281     }
    282     else
    283     {
    284       m_acTEncTop[layer].setMaxTempLayer                                  ( m_EhMaxTempLayer[layer] );
    285     }
    286 
    287     m_acTEncTop[layer].setUseAMP( m_enableAMP );
     231    m_cTEncTop.setLayerId                                         ( m_apcLayerCfg[layer]->m_layerId );
     232    m_cTEncTop.setNumLayer                                        ( m_numLayers );
     233    m_cTEncTop.setLayerEnc                                        ( m_apcTEncTop );
    288234
    289235    if( layer < m_numLayers - 1 )
    290236    {
    291        m_acTEncTop[layer].setMaxTidIlRefPicsPlus1                         ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1());
     237       m_cTEncTop.setMaxTidIlRefPicsPlus1                         ( m_apcLayerCfg[layer]->getMaxTidIlRefPicsPlus1());
    292238    }
    293239
     
    296242      UInt prevLayerIdx = 0;
    297243      UInt prevLayerId  = 0;
    298       if (m_acLayerCfg[layer].getNumActiveRefLayers() > 0)
    299       {
    300         prevLayerIdx = m_acLayerCfg[layer].getPredLayerIdx(m_acLayerCfg[layer].getNumActiveRefLayers() - 1);
    301         prevLayerId  = m_acTEncTop[layer].getRefLayerId(prevLayerIdx);
     244      if (m_apcLayerCfg[layer]->getNumActiveRefLayers() > 0)
     245      {
     246        prevLayerIdx = m_apcLayerCfg[layer]->getPredLayerIdx(m_apcLayerCfg[layer]->getNumActiveRefLayers() - 1);
     247        prevLayerId  = m_cTEncTop.getRefLayerId(prevLayerIdx);
    302248      }
    303249      for(Int i = 0; i < MAX_VPS_LAYER_IDX_PLUS1; i++)
    304250      {
    305         m_acTEncTop[layer].setSamplePredEnabledFlag                       (i, false);
    306         m_acTEncTop[layer].setMotionPredEnabledFlag                       (i, false);
    307       }
    308       if(m_acLayerCfg[layer].getNumSamplePredRefLayers() == -1)
     251        m_cTEncTop.setSamplePredEnabledFlag                       (i, false);
     252        m_cTEncTop.setMotionPredEnabledFlag                       (i, false);
     253      }
     254      if(m_apcLayerCfg[layer]->getNumSamplePredRefLayers() == -1)
    309255      {
    310256        // Not included in the configuration file; assume that each layer depends on previous layer
    311         m_acTEncTop[layer].setNumSamplePredRefLayers                      (1);      // One sample pred ref. layer
    312         m_acTEncTop[layer].setSamplePredRefLayerId                        (prevLayerIdx, prevLayerId);   // Previous layer
    313         m_acTEncTop[layer].setSamplePredEnabledFlag                       (prevLayerIdx, true);
     257        m_cTEncTop.setNumSamplePredRefLayers                      (1);      // One sample pred ref. layer
     258        m_cTEncTop.setSamplePredRefLayerId                        (prevLayerIdx, prevLayerId);   // Previous layer
     259        m_cTEncTop.setSamplePredEnabledFlag                       (prevLayerIdx, true);
    314260      }
    315261      else
    316262      {
    317         m_acTEncTop[layer].setNumSamplePredRefLayers                      ( m_acLayerCfg[layer].getNumSamplePredRefLayers() );
    318         for(Int i = 0; i < m_acTEncTop[layer].getNumSamplePredRefLayers(); i++)
    319         {
    320           m_acTEncTop[layer].setSamplePredRefLayerId                      ( i, m_acLayerCfg[layer].getSamplePredRefLayerId(i));
    321         }
    322       }
    323       if(m_acLayerCfg[layer].getNumMotionPredRefLayers() == -1)
     263        m_cTEncTop.setNumSamplePredRefLayers                      ( m_apcLayerCfg[layer]->getNumSamplePredRefLayers() );
     264        for( Int i = 0; i < m_cTEncTop.getNumSamplePredRefLayers(); i++ )
     265        {
     266          m_cTEncTop.setSamplePredRefLayerId                      ( i, m_apcLayerCfg[layer]->getSamplePredRefLayerId(i));
     267        }
     268      }
     269      if( m_apcLayerCfg[layer]->getNumMotionPredRefLayers() == -1)
    324270      {
    325271        // Not included in the configuration file; assume that each layer depends on previous layer
    326         m_acTEncTop[layer].setNumMotionPredRefLayers                      (1);      // One motion pred ref. layer
    327         m_acTEncTop[layer].setMotionPredRefLayerId                        (prevLayerIdx, prevLayerId);   // Previous layer
    328         m_acTEncTop[layer].setMotionPredEnabledFlag                       (prevLayerIdx, true);
     272        m_cTEncTop.setNumMotionPredRefLayers                      (1);      // One motion pred ref. layer
     273        m_cTEncTop.setMotionPredRefLayerId                        (prevLayerIdx, prevLayerId);   // Previous layer
     274        m_cTEncTop.setMotionPredEnabledFlag                       (prevLayerIdx, true);
    329275      }
    330276      else
    331277      {
    332         m_acTEncTop[layer].setNumMotionPredRefLayers                      ( m_acLayerCfg[layer].getNumMotionPredRefLayers() );
    333         for(Int i = 0; i < m_acTEncTop[layer].getNumMotionPredRefLayers(); i++)
    334         {
    335           m_acTEncTop[layer].setMotionPredRefLayerId                      ( i, m_acLayerCfg[layer].getMotionPredRefLayerId(i));
     278        m_cTEncTop.setNumMotionPredRefLayers                      ( m_apcLayerCfg[layer]->getNumMotionPredRefLayers() );
     279        for( Int i = 0; i < m_cTEncTop.getNumMotionPredRefLayers(); i++ )
     280        {
     281          m_cTEncTop.setMotionPredRefLayerId                      ( i, m_apcLayerCfg[layer]->getMotionPredRefLayerId(i));
    336282        }
    337283      }
     
    340286      assert( layer < MAX_LAYERS );
    341287
    342       for (Int i = 0; i < m_acLayerCfg[layer].m_layerId; i++)
     288      for (Int i = 0; i < m_apcLayerCfg[layer]->m_layerId; i++)
    343289      {
    344290        Int refLayerId = -1;
    345291
    346         for( Int layerIdc = 0; layerIdc < m_acTEncTop[layer].getNumSamplePredRefLayers(); layerIdc++ )
    347         {
    348           if( m_acLayerCfg[layer].getSamplePredRefLayerId(layerIdc) == i )
     292        for( Int layerIdc = 0; layerIdc < m_cTEncTop.getNumSamplePredRefLayers(); layerIdc++ )
     293        {
     294          if( m_apcLayerCfg[layer]->getSamplePredRefLayerId(layerIdc) == i )
    349295          {
    350296            refLayerId = i;
    351             m_acTEncTop[layer].setSamplePredEnabledFlag( numDirectRefLayers, true );
     297            m_cTEncTop.setSamplePredEnabledFlag( numDirectRefLayers, true );
    352298            break;
    353299          }
    354300        }
    355301
    356         for( Int layerIdc = 0; layerIdc < m_acTEncTop[layer].getNumMotionPredRefLayers(); layerIdc++ )
    357         {
    358           if( m_acLayerCfg[layer].getMotionPredRefLayerId(layerIdc) == i )
     302        for( Int layerIdc = 0; layerIdc < m_cTEncTop.getNumMotionPredRefLayers(); layerIdc++ )
     303        {
     304          if( m_apcLayerCfg[layer]->getMotionPredRefLayerId(layerIdc) == i )
    359305          {
    360306            refLayerId = i;
    361             m_acTEncTop[layer].setMotionPredEnabledFlag( numDirectRefLayers, true );
     307            m_cTEncTop.setMotionPredEnabledFlag( numDirectRefLayers, true );
    362308            break;
    363309          }
     
    366312        if( refLayerId >= 0 )
    367313        {
    368           m_acTEncTop[layer].setRefLayerId                                ( numDirectRefLayers, refLayerId );
     314          m_cTEncTop.setRefLayerId                                ( numDirectRefLayers, refLayerId );
    369315          numDirectRefLayers++;
    370316        }
    371317      }
    372318
    373       m_acTEncTop[layer].setNumDirectRefLayers                            ( numDirectRefLayers );
    374 
    375       if(m_acLayerCfg[layer].getNumActiveRefLayers() == -1)
    376       {
    377         m_acTEncTop[layer].setNumActiveRefLayers                          ( m_acTEncTop[layer].getNumDirectRefLayers() );
    378         for( Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++ )
    379         {
    380           m_acTEncTop[layer].setPredLayerIdx(i, i);
     319      m_cTEncTop.setNumDirectRefLayers                            ( numDirectRefLayers );
     320
     321      if(m_apcLayerCfg[layer]->getNumActiveRefLayers() == -1)
     322      {
     323        m_cTEncTop.setNumActiveRefLayers                          ( m_cTEncTop.getNumDirectRefLayers() );
     324        for( Int i = 0; i < m_cTEncTop.getNumActiveRefLayers(); i++ )
     325        {
     326          m_cTEncTop.setPredLayerIdx(i, i);
    381327        }
    382328      }
    383329      else
    384330      {
    385         m_acTEncTop[layer].setNumActiveRefLayers                          ( m_acLayerCfg[layer].getNumActiveRefLayers() );
    386         for(Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++)
    387         {
    388           m_acTEncTop[layer].setPredLayerIdx                              ( i, m_acLayerCfg[layer].getPredLayerIdx(i));
     331        m_cTEncTop.setNumActiveRefLayers                          ( m_apcLayerCfg[layer]->getNumActiveRefLayers() );
     332        for(Int i = 0; i < m_cTEncTop.getNumActiveRefLayers(); i++)
     333        {
     334          m_cTEncTop.setPredLayerIdx                              ( i, m_apcLayerCfg[layer]->getPredLayerIdx(i));
    389335        }
    390336      }
     
    393339    {
    394340      assert( layer == 0 );
    395       m_acTEncTop[layer].setNumDirectRefLayers(0);
    396     }
    397 
    398     //===== Slice ========
    399 
    400     //====== Loop/Deblock Filter ========
    401     m_acTEncTop[layer].setLoopFilterDisable                                ( m_bLoopFilterDisable       );
    402     m_acTEncTop[layer].setLoopFilterOffsetInPPS                            ( m_loopFilterOffsetInPPS );
    403     m_acTEncTop[layer].setLoopFilterBetaOffset                             ( m_loopFilterBetaOffsetDiv2  );
    404     m_acTEncTop[layer].setLoopFilterTcOffset                               ( m_loopFilterTcOffsetDiv2    );   
    405     m_acTEncTop[layer].setDeblockingFilterMetric                           ( m_DeblockingFilterMetric );
    406 
    407     //====== Motion search ========
    408     m_acTEncTop[layer].setDisableIntraPUsInInterSlices                     ( m_bDisableIntraPUsInInterSlices );
    409     m_acTEncTop[layer].setFastSearch                                       ( m_iFastSearch  );
    410     m_acTEncTop[layer].setSearchRange                                      ( m_iSearchRange );
    411     m_acTEncTop[layer].setBipredSearchRange                                ( m_bipredSearchRange );
    412     m_acTEncTop[layer].setClipForBiPredMeEnabled                           ( m_bClipForBiPredMeEnabled );
    413     m_acTEncTop[layer].setFastMEAssumingSmootherMVEnabled                  ( m_bFastMEAssumingSmootherMVEnabled );
    414 
    415     //====== Quality control ========
    416     m_acTEncTop[layer].setMaxDeltaQP                                       ( m_iMaxDeltaQP  );
    417     m_acTEncTop[layer].setMaxCuDQPDepth                                    ( m_acLayerCfg[layer].m_iMaxCuDQPDepth  );
    418     m_acTEncTop[layer].setDiffCuChromaQpOffsetDepth                        ( m_diffCuChromaQpOffsetDepth );
    419     m_acTEncTop[layer].setChromaCbQpOffset                                 ( m_cbQpOffset     );
    420     m_acTEncTop[layer].setChromaCrQpOffset                                 ( m_crQpOffset  );
    421 
    422     m_acTEncTop[layer].setChromaFormatIdc                                  ( m_acLayerCfg[layer].m_chromaFormatIDC  );
    423 
    424 #if ADAPTIVE_QP_SELECTION
    425     m_acTEncTop[layer].setUseAdaptQpSelect                                 ( m_bUseAdaptQpSelect   );
    426 #endif
    427    
    428     m_acTEncTop[layer].setUseAdaptiveQP                                    ( m_bUseAdaptiveQP  );
    429     m_acTEncTop[layer].setQPAdaptationRange                                ( m_iQPAdaptationRange );
    430     m_acTEncTop[layer].setExtendedPrecisionProcessingFlag                  ( m_acLayerCfg[layer].m_extendedPrecisionProcessingFlag );
    431     m_acTEncTop[layer].setHighPrecisionOffsetsEnabledFlag                  ( m_acLayerCfg[layer].m_highPrecisionOffsetsEnabledFlag );
    432 
    433     //====== Tool list ========   
    434     m_acTEncTop[layer].setDeltaQpRD                                        ( m_uiDeltaQpRD  );
    435     m_acTEncTop[layer].setFastDeltaQp                                      ( m_bFastDeltaQP  );
    436     m_acTEncTop[layer].setUseASR                                           ( m_bUseASR      );
    437     m_acTEncTop[layer].setUseHADME                                         ( m_bUseHADME    );   
    438     m_acTEncTop[layer].setdQPs                                             ( m_acLayerCfg[layer].getdQPs() );
    439     m_acTEncTop[layer].setUseRDOQ                                          ( m_useRDOQ     );
    440     m_acTEncTop[layer].setUseRDOQTS                                        ( m_useRDOQTS   );
    441 #if T0196_SELECTIVE_RDOQ
    442     m_acTEncTop[layer].setUseSelectiveRDOQ                                 ( m_useSelectiveRDOQ );
    443 #endif
    444     m_acTEncTop[layer].setRDpenalty                                        ( m_rdPenalty );
    445     m_acTEncTop[layer].setMaxCUWidth                                       ( m_acLayerCfg[layer].m_uiMaxCUWidth );
    446     m_acTEncTop[layer].setMaxCUHeight                                      ( m_acLayerCfg[layer].m_uiMaxCUHeight );
    447     m_acTEncTop[layer].setMaxTotalCUDepth                                  ( m_acLayerCfg[layer].m_uiMaxTotalCUDepth );
    448     m_acTEncTop[layer].setLog2DiffMaxMinCodingBlockSize                    ( m_acLayerCfg[layer].m_uiLog2DiffMaxMinCodingBlockSize );
    449 
    450     m_acTEncTop[layer].setQuadtreeTULog2MaxSize                            ( m_acLayerCfg[layer].m_uiQuadtreeTULog2MaxSize );
    451     m_acTEncTop[layer].setQuadtreeTULog2MinSize                            ( m_acLayerCfg[layer].m_uiQuadtreeTULog2MinSize );
    452     m_acTEncTop[layer].setQuadtreeTUMaxDepthInter                          ( m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthInter );
    453     m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra                          ( m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthIntra );
    454 
    455     m_acTEncTop[layer].setUseFastEnc                                       ( m_bUseFastEnc  );
    456     m_acTEncTop[layer].setUseEarlyCU                                       ( m_bUseEarlyCU  );
    457     m_acTEncTop[layer].setUseFastDecisionForMerge                          ( m_useFastDecisionForMerge  );
    458     m_acTEncTop[layer].setUseCbfFastMode                                   ( m_bUseCbfFastMode  );
    459     m_acTEncTop[layer].setUseEarlySkipDetection                            ( m_useEarlySkipDetection );
    460     m_acTEncTop[layer].setCrossComponentPredictionEnabledFlag              ( m_crossComponentPredictionEnabledFlag );
    461     m_acTEncTop[layer].setUseReconBasedCrossCPredictionEstimate            ( m_reconBasedCrossCPredictionEstimate );
    462     m_acTEncTop[layer].setLog2SaoOffsetScale                               ( CHANNEL_TYPE_LUMA  , m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA]   );
    463     m_acTEncTop[layer].setLog2SaoOffsetScale                               ( CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] );
    464     m_acTEncTop[layer].setUseTransformSkip                                 ( m_useTransformSkip      );
    465     m_acTEncTop[layer].setUseTransformSkipFast                             ( m_useTransformSkipFast  );
    466     m_acTEncTop[layer].setTransformSkipRotationEnabledFlag                 ( m_transformSkipRotationEnabledFlag   );
    467     m_acTEncTop[layer].setTransformSkipContextEnabledFlag                  ( m_transformSkipContextEnabledFlag   );
    468     m_acTEncTop[layer].setPersistentRiceAdaptationEnabledFlag              ( m_persistentRiceAdaptationEnabledFlag );
    469     m_acTEncTop[layer].setCabacBypassAlignmentEnabledFlag                  ( m_cabacBypassAlignmentEnabledFlag );
    470     m_acTEncTop[layer].setLog2MaxTransformSkipBlockSize                    ( m_log2MaxTransformSkipBlockSize  );
    471     for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++)
    472     {
    473       m_acTEncTop[layer].setRdpcmEnabledFlag                               ( RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]);
    474     }
    475     m_acTEncTop[layer].setUseConstrainedIntraPred                          ( m_bUseConstrainedIntraPred );
    476     m_acTEncTop[layer].setFastUDIUseMPMEnabled                             ( m_bFastUDIUseMPMEnabled );
    477     m_acTEncTop[layer].setFastMEForGenBLowDelayEnabled                     ( m_bFastMEForGenBLowDelayEnabled );
    478     m_acTEncTop[layer].setUseBLambdaForNonKeyLowDelayPictures              ( m_bUseBLambdaForNonKeyLowDelayPictures );
    479     m_acTEncTop[layer].setPCMLog2MinSize                                   ( m_uiPCMLog2MinSize);
    480     m_acTEncTop[layer].setUsePCM                                           ( m_usePCM );
    481 
    482     for( UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++ )
    483     {
    484       m_acTEncTop[layer].setBitDepth                                       ((ChannelType)channelType, m_acLayerCfg[layer].m_internalBitDepth[channelType]);
    485       m_acTEncTop[layer].setPCMBitDepth                                    ((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_MSBExtendedBitDepth[channelType] : m_acLayerCfg[layer].m_internalBitDepth[channelType]);
    486     }
    487     m_acTEncTop[layer].setPCMLog2MaxSize                                   ( m_pcmLog2MaxSize);
    488     m_acTEncTop[layer].setMaxNumMergeCand                                  ( m_maxNumMergeCand );
    489 
    490 
    491     //====== Weighted Prediction ========
    492     m_acTEncTop[layer].setUseWP                                            ( m_useWeightedPred      );
    493     m_acTEncTop[layer].setWPBiPred                                         ( m_useWeightedBiPred   );
    494 #if FAST_INTRA_SHVC
    495     m_acTEncTop[layer].setUseFastIntraScalable                             ( m_useFastIntraScalable );
    496 #endif
    497 
    498     if( layer != 0 && m_useInterLayerWeightedPred )
    499     {
    500       // Enable weighted prediction for enhancement layer
    501       m_acTEncTop[layer].setUseWP                                           ( true   );
    502       m_acTEncTop[layer].setWPBiPred                                        ( true   );
    503     }
    504 
    505     //====== Parallel Merge Estimation ========
    506     m_acTEncTop[layer].setLog2ParallelMergeLevelMinus2                      ( m_log2ParallelMergeLevel - 2 );
    507 
    508     //====== Slice ========
    509     m_acTEncTop[layer].setSliceMode                                         ( (SliceConstraint) m_sliceMode );
    510     m_acTEncTop[layer].setSliceArgument                                     ( m_sliceArgument            );
    511 
    512     //====== Dependent Slice ========
    513     m_acTEncTop[layer].setSliceSegmentMode                                  ( (SliceConstraint) m_sliceSegmentMode );
    514     m_acTEncTop[layer].setSliceSegmentArgument                              ( m_sliceSegmentArgument     );
    515 
    516     if(m_sliceMode == NO_SLICES )
    517     {
    518       m_bLFCrossSliceBoundaryFlag = true;
    519     }
    520 
    521     m_acTEncTop[layer].setLFCrossSliceBoundaryFlag                          ( m_bLFCrossSliceBoundaryFlag );
    522     m_acTEncTop[layer].setUseSAO                                            ( m_bUseSAO );
    523     m_acTEncTop[layer].setTestSAODisableAtPictureLevel                      ( m_bTestSAODisableAtPictureLevel );
    524     m_acTEncTop[layer].setSaoEncodingRate                                   ( m_saoEncodingRate );
    525     m_acTEncTop[layer].setSaoEncodingRateChroma                             ( m_saoEncodingRateChroma );
    526     m_acTEncTop[layer].setMaxNumOffsetsPerPic                               ( m_maxNumOffsetsPerPic );
    527 
    528     m_acTEncTop[layer].setSaoCtuBoundary                                    ( m_saoCtuBoundary );
    529     m_acTEncTop[layer].setPCMInputBitDepthFlag                              ( m_bPCMInputBitDepthFlag);
    530     m_acTEncTop[layer].setPCMFilterDisableFlag                              ( m_bPCMFilterDisableFlag);
    531 
    532     m_acTEncTop[layer].setIntraSmoothingDisabledFlag                        (!m_enableIntraReferenceSmoothing );
    533     m_acTEncTop[layer].setDecodedPictureHashSEIEnabled                      ( m_decodedPictureHashSEIEnabled );
    534     m_acTEncTop[layer].setRecoveryPointSEIEnabled                           ( m_recoveryPointSEIEnabled );
    535     m_acTEncTop[layer].setBufferingPeriodSEIEnabled                         ( m_bufferingPeriodSEIEnabled );
    536     m_acTEncTop[layer].setPictureTimingSEIEnabled                           ( m_pictureTimingSEIEnabled );
    537     m_acTEncTop[layer].setToneMappingInfoSEIEnabled                         ( m_toneMappingInfoSEIEnabled );
    538     m_acTEncTop[layer].setTMISEIToneMapId                                   ( m_toneMapId );
    539     m_acTEncTop[layer].setTMISEIToneMapCancelFlag                           ( m_toneMapCancelFlag );
    540     m_acTEncTop[layer].setTMISEIToneMapPersistenceFlag                      ( m_toneMapPersistenceFlag );
    541     m_acTEncTop[layer].setTMISEICodedDataBitDepth                           ( m_toneMapCodedDataBitDepth );
    542     m_acTEncTop[layer].setTMISEITargetBitDepth                              ( m_toneMapTargetBitDepth );
    543     m_acTEncTop[layer].setTMISEIModelID                                     ( m_toneMapModelId );
    544     m_acTEncTop[layer].setTMISEIMinValue                                    ( m_toneMapMinValue );
    545     m_acTEncTop[layer].setTMISEIMaxValue                                    ( m_toneMapMaxValue );
    546     m_acTEncTop[layer].setTMISEISigmoidMidpoint                             ( m_sigmoidMidpoint );
    547     m_acTEncTop[layer].setTMISEISigmoidWidth                                ( m_sigmoidWidth );
    548     m_acTEncTop[layer].setTMISEIStartOfCodedInterva                         ( m_startOfCodedInterval );
    549     m_acTEncTop[layer].setTMISEINumPivots                                   ( m_numPivots );
    550     m_acTEncTop[layer].setTMISEICodedPivotValue                             ( m_codedPivotValue );
    551     m_acTEncTop[layer].setTMISEITargetPivotValue                            ( m_targetPivotValue );
    552     m_acTEncTop[layer].setTMISEICameraIsoSpeedIdc                           ( m_cameraIsoSpeedIdc );
    553     m_acTEncTop[layer].setTMISEICameraIsoSpeedValue                         ( m_cameraIsoSpeedValue );
    554     m_acTEncTop[layer].setTMISEIExposureIndexIdc                            ( m_exposureIndexIdc );
    555     m_acTEncTop[layer].setTMISEIExposureIndexValue                          ( m_exposureIndexValue );
    556     m_acTEncTop[layer].setTMISEIExposureCompensationValueSignFlag           ( m_exposureCompensationValueSignFlag );
    557     m_acTEncTop[layer].setTMISEIExposureCompensationValueNumerator          ( m_exposureCompensationValueNumerator );
    558     m_acTEncTop[layer].setTMISEIExposureCompensationValueDenomIdc           ( m_exposureCompensationValueDenomIdc );
    559     m_acTEncTop[layer].setTMISEIRefScreenLuminanceWhite                     ( m_refScreenLuminanceWhite );
    560     m_acTEncTop[layer].setTMISEIExtendedRangeWhiteLevel                     ( m_extendedRangeWhiteLevel );
    561     m_acTEncTop[layer].setTMISEINominalBlackLevelLumaCodeValue              ( m_nominalBlackLevelLumaCodeValue );
    562     m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue              ( m_nominalWhiteLevelLumaCodeValue );
    563     m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue             ( m_extendedWhiteLevelLumaCodeValue );
    564     m_acTEncTop[layer].setChromaSamplingFilterHintEnabled                   ( m_chromaSamplingFilterSEIenabled );
    565     m_acTEncTop[layer].setChromaSamplingHorFilterIdc                        ( m_chromaSamplingHorFilterIdc );
    566     m_acTEncTop[layer].setChromaSamplingVerFilterIdc                        ( m_chromaSamplingVerFilterIdc );
    567     m_acTEncTop[layer].setFramePackingArrangementSEIEnabled                 ( m_framePackingSEIEnabled );
    568     m_acTEncTop[layer].setFramePackingArrangementSEIType                    ( m_framePackingSEIType );
    569     m_acTEncTop[layer].setFramePackingArrangementSEIId                      ( m_framePackingSEIId );
    570     m_acTEncTop[layer].setFramePackingArrangementSEIQuincunx                ( m_framePackingSEIQuincunx );
    571     m_acTEncTop[layer].setFramePackingArrangementSEIInterpretation          ( m_framePackingSEIInterpretation );
    572     m_acTEncTop[layer].setSegmentedRectFramePackingArrangementSEIEnabled    ( m_segmentedRectFramePackingSEIEnabled );
    573     m_acTEncTop[layer].setSegmentedRectFramePackingArrangementSEICancel     ( m_segmentedRectFramePackingSEICancel );
    574     m_acTEncTop[layer].setSegmentedRectFramePackingArrangementSEIType       ( m_segmentedRectFramePackingSEIType );
    575     m_acTEncTop[layer].setSegmentedRectFramePackingArrangementSEIPersistence( m_segmentedRectFramePackingSEIPersistence );
    576     m_acTEncTop[layer].setDisplayOrientationSEIAngle                        ( m_displayOrientationSEIAngle );
    577     m_acTEncTop[layer].setTemporalLevel0IndexSEIEnabled                     ( m_temporalLevel0IndexSEIEnabled );
    578     m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled                 ( m_gradualDecodingRefreshInfoEnabled );
    579     m_acTEncTop[layer].setNoDisplaySEITLayer                                ( m_noDisplaySEITLayer );
    580     m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled                        ( m_decodingUnitInfoSEIEnabled );
    581     m_acTEncTop[layer].setSOPDescriptionSEIEnabled                          ( m_SOPDescriptionSEIEnabled );
    582     m_acTEncTop[layer].setScalableNestingSEIEnabled                         ( m_scalableNestingSEIEnabled );
    583     m_acTEncTop[layer].setTMCTSSEIEnabled                                   ( m_tmctsSEIEnabled );
    584     m_acTEncTop[layer].setTimeCodeSEIEnabled                                ( m_timeCodeSEIEnabled );
    585     m_acTEncTop[layer].setNumberOfTimeSets                                  ( m_timeCodeSEINumTs );
    586     for(Int i = 0; i < m_timeCodeSEINumTs; i++)
    587     {
    588       m_acTEncTop[layer].setTimeSet(m_timeSetArray[i], i);
    589     }
    590     m_acTEncTop[layer].setKneeSEIEnabled                                    ( m_kneeSEIEnabled );
    591     m_acTEncTop[layer].setKneeSEIId                                         ( m_kneeSEIId );
    592     m_acTEncTop[layer].setKneeSEICancelFlag                                 ( m_kneeSEICancelFlag );
    593     m_acTEncTop[layer].setKneeSEIPersistenceFlag                            ( m_kneeSEIPersistenceFlag );   
    594     m_acTEncTop[layer].setKneeSEIInputDrange                                ( m_kneeSEIInputDrange );
    595     m_acTEncTop[layer].setKneeSEIInputDispLuminance                         ( m_kneeSEIInputDispLuminance );
    596     m_acTEncTop[layer].setKneeSEIOutputDrange                               ( m_kneeSEIOutputDrange );
    597     m_acTEncTop[layer].setKneeSEIOutputDispLuminance                        ( m_kneeSEIOutputDispLuminance );
    598     m_acTEncTop[layer].setKneeSEINumKneePointsMinus1                        ( m_kneeSEINumKneePointsMinus1 );
    599     m_acTEncTop[layer].setKneeSEIInputKneePoint                             ( m_kneeSEIInputKneePoint );
    600     m_acTEncTop[layer].setKneeSEIOutputKneePoint                            ( m_kneeSEIOutputKneePoint );
    601     m_acTEncTop[layer].setMasteringDisplaySEI                               ( m_masteringDisplay );
    602 #if P0123_ALPHA_CHANNEL_SEI
    603     m_acTEncTop[layer].setAlphaSEIEnabled                                   ( m_alphaSEIEnabled );
    604     m_acTEncTop[layer].setAlphaCancelFlag                                   ( m_alphaCancelFlag );
    605     m_acTEncTop[layer].setAlphaUseIdc                                       ( m_alphaUseIdc );
    606     m_acTEncTop[layer].setAlphaBitDepthMinus8                               ( m_alphaBitDepthMinus8 );
    607     m_acTEncTop[layer].setAlphaTransparentValue                             ( m_alphaTransparentValue );
    608     m_acTEncTop[layer].setAlphaOpaqueValue                                  ( m_alphaOpaqueValue );
    609     m_acTEncTop[layer].setAlphaIncrementFlag                                ( m_alphaIncrementFlag );
    610     m_acTEncTop[layer].setAlphaClipFlag                                     ( m_alphaClipFlag );
    611     m_acTEncTop[layer].setAlphaClipTypeFlag                                 ( m_alphaClipTypeFlag );
    612 #endif
    613 #if Q0096_OVERLAY_SEI
    614     m_acTEncTop[layer].setOverlaySEIEnabled                                 ( m_overlaySEIEnabled );
    615     m_acTEncTop[layer].setOverlaySEICancelFlag                              ( m_overlayInfoCancelFlag );
    616     m_acTEncTop[layer].setOverlaySEIContentAuxIdMinus128                    ( m_overlayContentAuxIdMinus128 );
    617     m_acTEncTop[layer].setOverlaySEILabelAuxIdMinus128                      ( m_overlayLabelAuxIdMinus128 );
    618     m_acTEncTop[layer].setOverlaySEIAlphaAuxIdMinus128                      ( m_overlayAlphaAuxIdMinus128 );
    619     m_acTEncTop[layer].setOverlaySEIElementLabelValueLengthMinus8           ( m_overlayElementLabelValueLengthMinus8 );
    620     m_acTEncTop[layer].setOverlaySEINumOverlaysMinus1                       ( m_numOverlaysMinus1 );
    621     m_acTEncTop[layer].setOverlaySEIIdx                                     ( m_overlayIdx );
    622     m_acTEncTop[layer].setOverlaySEILanguagePresentFlag                     ( m_overlayLanguagePresentFlag );
    623     m_acTEncTop[layer].setOverlaySEIContentLayerId                          ( m_overlayContentLayerId );
    624     m_acTEncTop[layer].setOverlaySEILabelPresentFlag                        ( m_overlayLabelPresentFlag );
    625     m_acTEncTop[layer].setOverlaySEILabelLayerId                            ( m_overlayLabelLayerId );
    626     m_acTEncTop[layer].setOverlaySEIAlphaPresentFlag                        ( m_overlayAlphaPresentFlag );
    627     m_acTEncTop[layer].setOverlaySEIAlphaLayerId                            ( m_overlayAlphaLayerId );
    628     m_acTEncTop[layer].setOverlaySEINumElementsMinus1                       ( m_numOverlayElementsMinus1 );
    629     m_acTEncTop[layer].setOverlaySEIElementLabelMin                         ( m_overlayElementLabelMin );
    630     m_acTEncTop[layer].setOverlaySEIElementLabelMax                         ( m_overlayElementLabelMax );
    631     m_acTEncTop[layer].setOverlaySEILanguage                                ( m_overlayLanguage );
    632     m_acTEncTop[layer].setOverlaySEIName                                    ( m_overlayName );
    633     m_acTEncTop[layer].setOverlaySEIElementName                             ( m_overlayElementName );
    634     m_acTEncTop[layer].setOverlaySEIPersistenceFlag                         ( m_overlayInfoPersistenceFlag );
    635 #endif
    636 #if Q0074_COLOUR_REMAPPING_SEI
    637     m_acTEncTop[layer].setCRISEIFileRoot                                    ( const_cast<Char*>(m_acLayerCfg[layer].m_colourRemapSEIFileRoot.c_str()) );
    638 #endif   
    639 #if LAYERS_NOT_PRESENT_SEI
    640     m_acTEncTop[layer].setLayersNotPresentSEIEnabled            ( m_layersNotPresentSEIEnabled );
    641 #endif   
    642 #if Q0189_TMVP_CONSTRAINTS
    643     m_acTEncTop[layer].setTMVPConstraintsSEIEnabled             ( m_TMVPConstraintsSEIEnabled);           
    644 #endif
    645 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    646     m_acTEncTop[layer].setInterLayerConstrainedTileSetsSEIEnabled( m_interLayerConstrainedTileSetsSEIEnabled );
    647     m_acTEncTop[layer].setIlNumSetsInMessage                    ( m_ilNumSetsInMessage );
    648     m_acTEncTop[layer].setSkippedTileSetPresentFlag             ( m_skippedTileSetPresentFlag );
    649     m_acTEncTop[layer].setTopLeftTileIndex                      ( m_topLeftTileIndex );
    650     m_acTEncTop[layer].setBottomRightTileIndex                  ( m_bottomRightTileIndex );
    651     m_acTEncTop[layer].setIlcIdc                                ( m_ilcIdc );
    652 #endif
    653     m_acTEncTop[layer].setTileUniformSpacingFlag                ( m_tileUniformSpacingFlag );
    654     m_acTEncTop[layer].setNumColumnsMinus1                      ( m_numTileColumnsMinus1 );
    655     m_acTEncTop[layer].setNumRowsMinus1                         ( m_numTileRowsMinus1 );
    656     if(!m_tileUniformSpacingFlag)
    657     {
    658       m_acTEncTop[layer].setColumnWidth                         ( m_tileColumnWidth );
    659       m_acTEncTop[layer].setRowHeight                           ( m_tileRowHeight );
    660     }
    661     m_acTEncTop[layer].xCheckGSParameters();
    662     Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1);
    663     if(uiTilesCount == 1)
    664     {
    665       m_bLFCrossTileBoundaryFlag = true;
    666     }
    667     m_acTEncTop[layer].setLFCrossTileBoundaryFlag               ( m_bLFCrossTileBoundaryFlag );
    668     m_acTEncTop[layer].setWaveFrontSynchro                      ( m_acLayerCfg[layer].m_waveFrontSynchro );
    669     m_acTEncTop[layer].setTMVPModeId                            ( m_TMVPModeId );
    670     m_acTEncTop[layer].setUseScalingListId                      ( m_useScalingListId  );
    671     m_acTEncTop[layer].setScalingListFile                       ( m_scalingListFile   );
    672     m_acTEncTop[layer].setSignHideFlag                          ( m_signHideFlag );
    673 #if RC_SHVC_HARMONIZATION
    674     m_acTEncTop[layer].setUseRateCtrl                           ( m_acLayerCfg[layer].getRCEnableRateControl() );
    675     m_acTEncTop[layer].setTargetBitrate                         ( m_acLayerCfg[layer].getRCTargetBitrate() );
    676     m_acTEncTop[layer].setKeepHierBit                           ( m_acLayerCfg[layer].getRCKeepHierarchicalBit() );
    677     m_acTEncTop[layer].setLCULevelRC                            ( m_acLayerCfg[layer].getRCLCULevelRC() );
    678     m_acTEncTop[layer].setUseLCUSeparateModel                   ( m_acLayerCfg[layer].getRCUseLCUSeparateModel() );
    679     m_acTEncTop[layer].setInitialQP                             ( m_acLayerCfg[layer].getRCInitialQP() );
    680     m_acTEncTop[layer].setForceIntraQP                          ( m_acLayerCfg[layer].getRCForceIntraQP() );
    681 #else
    682     m_acTEncTop[layer].setUseRateCtrl                           ( m_RCEnableRateControl );
    683     m_acTEncTop[layer].setTargetBitrate                         ( m_RCTargetBitrate );
    684     m_acTEncTop[layer].setKeepHierBit                           ( m_RCKeepHierarchicalBit );
    685     m_acTEncTop[layer].setLCULevelRC                            ( m_RCLCULevelRC );
    686     m_acTEncTop[layer].setUseLCUSeparateModel                   ( m_RCUseLCUSeparateModel );
    687     m_acTEncTop[layer].setInitialQP                             ( m_RCInitialQP );
    688     m_acTEncTop[layer].setForceIntraQP                          ( m_RCForceIntraQP );
    689 #endif
    690     m_acTEncTop[layer].setTransquantBypassEnableFlag            ( m_TransquantBypassEnableFlag );
    691     m_acTEncTop[layer].setCUTransquantBypassFlagForceValue      ( m_CUTransquantBypassFlagForce );
    692     m_acTEncTop[layer].setCostMode                              ( m_costMode );
    693     m_acTEncTop[layer].setUseRecalculateQPAccordingToLambda     ( m_recalculateQPAccordingToLambda );
    694     m_acTEncTop[layer].setUseStrongIntraSmoothing               ( m_useStrongIntraSmoothing );
    695     m_acTEncTop[layer].setActiveParameterSetsSEIEnabled         ( m_activeParameterSetsSEIEnabled );
    696     m_acTEncTop[layer].setVuiParametersPresentFlag              ( m_vuiParametersPresentFlag );
    697     m_acTEncTop[layer].setAspectRatioInfoPresentFlag            ( m_aspectRatioInfoPresentFlag);
    698     m_acTEncTop[layer].setAspectRatioIdc                        ( m_aspectRatioIdc );
    699     m_acTEncTop[layer].setSarWidth                              ( m_sarWidth );
    700     m_acTEncTop[layer].setSarHeight                             ( m_sarHeight );
    701     m_acTEncTop[layer].setOverscanInfoPresentFlag               ( m_overscanInfoPresentFlag );
    702     m_acTEncTop[layer].setOverscanAppropriateFlag               ( m_overscanAppropriateFlag );
    703     m_acTEncTop[layer].setVideoSignalTypePresentFlag            ( m_videoSignalTypePresentFlag );
    704     m_acTEncTop[layer].setVideoFormat                           ( m_videoFormat );
    705     m_acTEncTop[layer].setVideoFullRangeFlag                    ( m_videoFullRangeFlag );
    706     m_acTEncTop[layer].setColourDescriptionPresentFlag          ( m_colourDescriptionPresentFlag );
    707     m_acTEncTop[layer].setColourPrimaries                       ( m_colourPrimaries );
    708     m_acTEncTop[layer].setTransferCharacteristics               ( m_transferCharacteristics );
    709     m_acTEncTop[layer].setMatrixCoefficients                    ( m_matrixCoefficients );
    710     m_acTEncTop[layer].setChromaLocInfoPresentFlag              ( m_chromaLocInfoPresentFlag );
    711     m_acTEncTop[layer].setChromaSampleLocTypeTopField           ( m_chromaSampleLocTypeTopField );
    712     m_acTEncTop[layer].setChromaSampleLocTypeBottomField        ( m_chromaSampleLocTypeBottomField );
    713     m_acTEncTop[layer].setNeutralChromaIndicationFlag           ( m_neutralChromaIndicationFlag );
    714     m_acTEncTop[layer].setDefaultDisplayWindow                  ( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
    715     m_acTEncTop[layer].setFrameFieldInfoPresentFlag             ( m_frameFieldInfoPresentFlag );
    716     m_acTEncTop[layer].setPocProportionalToTimingFlag           ( m_pocProportionalToTimingFlag );
    717     m_acTEncTop[layer].setNumTicksPocDiffOneMinus1              ( m_numTicksPocDiffOneMinus1    );
    718     m_acTEncTop[layer].setBitstreamRestrictionFlag              ( m_bitstreamRestrictionFlag );
    719     m_acTEncTop[layer].setTilesFixedStructureFlag               ( m_tilesFixedStructureFlag );
    720     m_acTEncTop[layer].setMotionVectorsOverPicBoundariesFlag    ( m_motionVectorsOverPicBoundariesFlag );
    721     m_acTEncTop[layer].setMinSpatialSegmentationIdc             ( m_minSpatialSegmentationIdc );
    722     m_acTEncTop[layer].setMaxBytesPerPicDenom                   ( m_maxBytesPerPicDenom );
    723     m_acTEncTop[layer].setMaxBitsPerMinCuDenom                  ( m_maxBitsPerMinCuDenom );
    724     m_acTEncTop[layer].setLog2MaxMvLengthHorizontal             ( m_log2MaxMvLengthHorizontal );
    725     m_acTEncTop[layer].setLog2MaxMvLengthVertical               ( m_log2MaxMvLengthVertical );
    726     m_acTEncTop[layer].setElRapSliceTypeB                       (layer == 0? 0 : m_elRapSliceBEnabled);
    727     m_acTEncTop[layer].setEfficientFieldIRAPEnabled             ( m_bEfficientFieldIRAPEnabled );
    728     m_acTEncTop[layer].setHarmonizeGopFirstFieldCoupleEnabled   ( m_bHarmonizeGopFirstFieldCoupleEnabled );
    729 
    730     m_acTEncTop[layer].setSummaryOutFilename                    ( m_summaryOutFilename );
    731     m_acTEncTop[layer].setSummaryPicFilenameBase                ( m_summaryPicFilenameBase );
    732     m_acTEncTop[layer].setSummaryVerboseness                    ( m_summaryVerboseness );
     341      m_cTEncTop.setNumDirectRefLayers(0);
     342    }
    733343
    734344    if( layer > 0 )
    735345    {
    736346#if AUXILIARY_PICTURES
    737       Int subWidthC  = ( m_acLayerCfg[layer].m_chromaFormatIDC == CHROMA_420 || m_acLayerCfg[layer].m_chromaFormatIDC == CHROMA_422 ) ? 2 : 1;
    738       Int subHeightC = ( m_acLayerCfg[layer].m_chromaFormatIDC == CHROMA_420 ) ? 2 : 1;
     347      Int subWidthC  = ( m_apcLayerCfg[layer]->m_chromaFormatIDC == CHROMA_420 || m_apcLayerCfg[layer]->m_chromaFormatIDC == CHROMA_422 ) ? 2 : 1;
     348      Int subHeightC = ( m_apcLayerCfg[layer]->m_chromaFormatIDC == CHROMA_420 ) ? 2 : 1;
    739349#else
    740350      Int subWidthC  = 2;
    741351      Int subHeightC = 2;
    742352#endif
    743       m_acTEncTop[layer].setNumRefLayerLocationOffsets          ( m_acLayerCfg[layer].m_numRefLayerLocationOffsets );
    744       for(Int i = 0; i < m_acLayerCfg[layer].m_numRefLayerLocationOffsets; i++)
    745       {
    746         m_acTEncTop[layer].setRefLocationOffsetLayerId          (i, m_acLayerCfg[layer].m_refLocationOffsetLayerId[i]);
    747         m_acTEncTop[layer].setScaledRefLayerOffsetPresentFlag   ( i, m_acLayerCfg[layer].m_scaledRefLayerOffsetPresentFlag[i] );
    748         m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow ( subWidthC  * m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], subWidthC  * m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i],
    749                                                                   subHeightC * m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i],  subHeightC * m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]);
    750 
    751         Int rlSubWidthC  = ( m_acLayerCfg[i].m_chromaFormatIDC == CHROMA_420 || m_acLayerCfg[i].m_chromaFormatIDC == CHROMA_422 ) ? 2 : 1;
    752         Int rlSubHeightC = ( m_acLayerCfg[i].m_chromaFormatIDC == CHROMA_420 ) ? 2 : 1;
    753 
    754         m_acTEncTop[layer].setRefRegionOffsetPresentFlag        ( i, m_acLayerCfg[layer].m_refRegionOffsetPresentFlag[i] );
    755         m_acTEncTop[layer].getRefLayerWindow(i).setWindow       ( rlSubWidthC  * m_acLayerCfg[layer].m_refRegionLeftOffset[i], rlSubWidthC  * m_acLayerCfg[layer].m_refRegionRightOffset[i],
    756                                                                   rlSubHeightC * m_acLayerCfg[layer].m_refRegionTopOffset[i],  rlSubHeightC * m_acLayerCfg[layer].m_refRegionBottomOffset[i]);
    757         m_acTEncTop[layer].setResamplePhaseSetPresentFlag       ( i, m_acLayerCfg[layer].m_resamplePhaseSetPresentFlag[i] );
    758         m_acTEncTop[layer].setPhaseHorLuma                      ( i, m_acLayerCfg[layer].m_phaseHorLuma[i] );
    759         m_acTEncTop[layer].setPhaseVerLuma                      ( i, m_acLayerCfg[layer].m_phaseVerLuma[i] );
    760         m_acTEncTop[layer].setPhaseHorChroma                    ( i, m_acLayerCfg[layer].m_phaseHorChroma[i] );
    761         m_acTEncTop[layer].setPhaseVerChroma                    ( i, m_acLayerCfg[layer].m_phaseVerChroma[i] );
    762       }
    763     }
    764 
    765     m_acTEncTop[layer].setAdaptiveResolutionChange               ( m_adaptiveResolutionChange );
    766     m_acTEncTop[layer].setLayerSwitchOffBegin                    ( m_acLayerCfg[layer].m_layerSwitchOffBegin );
    767     m_acTEncTop[layer].setLayerSwitchOffEnd                      ( m_acLayerCfg[layer].m_layerSwitchOffEnd );
    768 #if AUXILIARY_PICTURES
    769     m_acTEncTop[layer].setChromaFormatIDC                        ( m_acLayerCfg[layer].m_chromaFormatIDC );
    770 #endif
    771     m_acTEncTop[layer].setAltOuputLayerFlag                      ( m_altOutputLayerFlag );
    772     m_acTEncTop[layer].setCrossLayerBLAFlag                      ( m_crossLayerBLAFlag );
     353      m_cTEncTop.setNumRefLayerLocationOffsets          ( m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets );
     354      for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++)
     355      {
     356        m_cTEncTop.setRefLocationOffsetLayerId          ( i, m_apcLayerCfg[layer]->m_refLocationOffsetLayerId[i]);
     357        m_cTEncTop.setScaledRefLayerOffsetPresentFlag   ( i, m_apcLayerCfg[layer]->m_scaledRefLayerOffsetPresentFlag[i] );
     358        m_cTEncTop.getScaledRefLayerWindow(i).setWindow ( subWidthC  * m_apcLayerCfg[layer]->m_scaledRefLayerLeftOffset[i], subWidthC  * m_apcLayerCfg[layer]->m_scaledRefLayerRightOffset[i],
     359          subHeightC * m_apcLayerCfg[layer]->m_scaledRefLayerTopOffset[i],  subHeightC * m_apcLayerCfg[layer]->m_scaledRefLayerBottomOffset[i]);
     360
     361        Int rlSubWidthC  = ( m_apcLayerCfg[i]->m_chromaFormatIDC == CHROMA_420 || m_apcLayerCfg[i]->m_chromaFormatIDC == CHROMA_422 ) ? 2 : 1;
     362        Int rlSubHeightC = ( m_apcLayerCfg[i]->m_chromaFormatIDC == CHROMA_420 ) ? 2 : 1;
     363
     364        m_cTEncTop.setRefRegionOffsetPresentFlag        ( i, m_apcLayerCfg[layer]->m_refRegionOffsetPresentFlag[i] );
     365        m_cTEncTop.getRefLayerWindow(i).setWindow       ( rlSubWidthC  * m_apcLayerCfg[layer]->m_refRegionLeftOffset[i], rlSubWidthC  * m_apcLayerCfg[layer]->m_refRegionRightOffset[i],
     366          rlSubHeightC * m_apcLayerCfg[layer]->m_refRegionTopOffset[i],  rlSubHeightC * m_apcLayerCfg[layer]->m_refRegionBottomOffset[i]);
     367        m_cTEncTop.setResamplePhaseSetPresentFlag       ( i, m_apcLayerCfg[layer]->m_resamplePhaseSetPresentFlag[i] );
     368        m_cTEncTop.setPhaseHorLuma                      ( i, m_apcLayerCfg[layer]->m_phaseHorLuma[i] );
     369        m_cTEncTop.setPhaseVerLuma                      ( i, m_apcLayerCfg[layer]->m_phaseVerLuma[i] );
     370        m_cTEncTop.setPhaseHorChroma                    ( i, m_apcLayerCfg[layer]->m_phaseHorChroma[i] );
     371        m_cTEncTop.setPhaseVerChroma                    ( i, m_apcLayerCfg[layer]->m_phaseVerChroma[i] );
     372      }
     373    }
     374
     375    m_cTEncTop.setAdaptiveResolutionChange               ( m_adaptiveResolutionChange );
     376    m_cTEncTop.setLayerSwitchOffBegin                    ( m_apcLayerCfg[layer]->m_layerSwitchOffBegin );
     377    m_cTEncTop.setLayerSwitchOffEnd                      ( m_apcLayerCfg[layer]->m_layerSwitchOffEnd );
     378    m_cTEncTop.setChromaFormatIDC                        ( m_apcLayerCfg[layer]->m_chromaFormatIDC );
     379    m_cTEncTop.setAltOuputLayerFlag                      ( m_altOutputLayerFlag );
     380    m_cTEncTop.setCrossLayerBLAFlag                      ( m_crossLayerBLAFlag );
    773381#if CGS_3D_ASYMLUT
    774     m_acTEncTop[layer].setCGSFlag                                ( layer == 0 ? 0 : m_nCGSFlag );
    775     m_acTEncTop[layer].setCGSMaxOctantDepth                      ( m_nCGSMaxOctantDepth );
    776     m_acTEncTop[layer].setCGSMaxYPartNumLog2                     ( m_nCGSMaxYPartNumLog2 );
    777     m_acTEncTop[layer].setCGSLUTBit                              ( m_nCGSLUTBit );
    778     m_acTEncTop[layer].setCGSAdaptChroma                         ( m_nCGSAdaptiveChroma );
     382    m_cTEncTop.setCGSFlag                                ( layer == 0 ? 0 : m_nCGSFlag );
     383    m_cTEncTop.setCGSMaxOctantDepth                      ( m_nCGSMaxOctantDepth );
     384    m_cTEncTop.setCGSMaxYPartNumLog2                     ( m_nCGSMaxYPartNumLog2 );
     385    m_cTEncTop.setCGSLUTBit                              ( m_nCGSLUTBit );
     386    m_cTEncTop.setCGSAdaptChroma                         ( m_nCGSAdaptiveChroma );
    779387#if R0179_ENC_OPT_3DLUT_SIZE
    780     m_acTEncTop[layer].setCGSLutSizeRDO                          ( m_nCGSLutSizeRDO );
    781 #endif
    782 #endif
    783     m_acTEncTop[layer].setNumAddLayerSets                        ( m_numAddLayerSets );
    784   }
    785 }
    786 #else //SVC_EXTENSION
    787 Void TAppEncTop::xInitLibCfg()
    788 {
    789   TComVPS vps;
    790 
    791   vps.setMaxTLayers                                               ( m_maxTempLayer );
    792   if (m_maxTempLayer == 1)
    793   {
    794     vps.setTemporalNestingFlag(true);
    795   }
    796   vps.setMaxLayers                                                ( 1 );
    797   for(Int i = 0; i < MAX_TLAYER; i++)
    798   {
    799     vps.setNumReorderPics                                         ( m_numReorderPics[i], i );
    800     vps.setMaxDecPicBuffering                                     ( m_maxDecPicBuffering[i], i );
    801   }
    802   m_cTEncTop.setVPS(&vps);
     388    m_cTEncTop.setCGSLutSizeRDO                          ( m_nCGSLutSizeRDO );
     389#endif
     390#endif
     391    m_cTEncTop.setNumAddLayerSets                        ( m_numAddLayerSets );
     392
     393#if P0123_ALPHA_CHANNEL_SEI
     394    m_cTEncTop.setAlphaSEIEnabled                                   ( m_alphaSEIEnabled );
     395    m_cTEncTop.setAlphaCancelFlag                                   ( m_alphaCancelFlag );
     396    m_cTEncTop.setAlphaUseIdc                                       ( m_alphaUseIdc );
     397    m_cTEncTop.setAlphaBitDepthMinus8                               ( m_alphaBitDepthMinus8 );
     398    m_cTEncTop.setAlphaTransparentValue                             ( m_alphaTransparentValue );
     399    m_cTEncTop.setAlphaOpaqueValue                                  ( m_alphaOpaqueValue );
     400    m_cTEncTop.setAlphaIncrementFlag                                ( m_alphaIncrementFlag );
     401    m_cTEncTop.setAlphaClipFlag                                     ( m_alphaClipFlag );
     402    m_cTEncTop.setAlphaClipTypeFlag                                 ( m_alphaClipTypeFlag );
     403#endif
     404#if Q0096_OVERLAY_SEI
     405    m_cTEncTop.setOverlaySEIEnabled                                 ( m_overlaySEIEnabled );
     406    m_cTEncTop.setOverlaySEICancelFlag                              ( m_overlayInfoCancelFlag );
     407    m_cTEncTop.setOverlaySEIContentAuxIdMinus128                    ( m_overlayContentAuxIdMinus128 );
     408    m_cTEncTop.setOverlaySEILabelAuxIdMinus128                      ( m_overlayLabelAuxIdMinus128 );
     409    m_cTEncTop.setOverlaySEIAlphaAuxIdMinus128                      ( m_overlayAlphaAuxIdMinus128 );
     410    m_cTEncTop.setOverlaySEIElementLabelValueLengthMinus8           ( m_overlayElementLabelValueLengthMinus8 );
     411    m_cTEncTop.setOverlaySEINumOverlaysMinus1                       ( m_numOverlaysMinus1 );
     412    m_cTEncTop.setOverlaySEIIdx                                     ( m_overlayIdx );
     413    m_cTEncTop.setOverlaySEILanguagePresentFlag                     ( m_overlayLanguagePresentFlag );
     414    m_cTEncTop.setOverlaySEIContentLayerId                          ( m_overlayContentLayerId );
     415    m_cTEncTop.setOverlaySEILabelPresentFlag                        ( m_overlayLabelPresentFlag );
     416    m_cTEncTop.setOverlaySEILabelLayerId                            ( m_overlayLabelLayerId );
     417    m_cTEncTop.setOverlaySEIAlphaPresentFlag                        ( m_overlayAlphaPresentFlag );
     418    m_cTEncTop.setOverlaySEIAlphaLayerId                            ( m_overlayAlphaLayerId );
     419    m_cTEncTop.setOverlaySEINumElementsMinus1                       ( m_numOverlayElementsMinus1 );
     420    m_cTEncTop.setOverlaySEIElementLabelMin                         ( m_overlayElementLabelMin );
     421    m_cTEncTop.setOverlaySEIElementLabelMax                         ( m_overlayElementLabelMax );
     422    m_cTEncTop.setOverlaySEILanguage                                ( m_overlayLanguage );
     423    m_cTEncTop.setOverlaySEIName                                    ( m_overlayName );
     424    m_cTEncTop.setOverlaySEIElementName                             ( m_overlayElementName );
     425    m_cTEncTop.setOverlaySEIPersistenceFlag                         ( m_overlayInfoPersistenceFlag );
     426#endif 
     427#if Q0189_TMVP_CONSTRAINTS
     428    m_cTEncTop.setTMVPConstraintsSEIEnabled                         ( m_TMVPConstraintsSEIEnabled);           
     429#endif
     430#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     431    m_cTEncTop.setInterLayerConstrainedTileSetsSEIEnabled           ( m_interLayerConstrainedTileSetsSEIEnabled );
     432    m_cTEncTop.setIlNumSetsInMessage                                ( m_ilNumSetsInMessage );
     433    m_cTEncTop.setSkippedTileSetPresentFlag                         ( m_skippedTileSetPresentFlag );
     434    m_cTEncTop.setTopLeftTileIndex                                  ( m_topLeftTileIndex );
     435    m_cTEncTop.setBottomRightTileIndex                              ( m_bottomRightTileIndex );
     436    m_cTEncTop.setIlcIdc                                            ( m_ilcIdc );
     437#endif
     438
     439    Int layerPTLIdx = m_apcLayerCfg[layer]->m_layerPTLIdx;
     440
     441    Profile::Name m_profile                                    = m_profileList[layerPTLIdx];
     442    Level::Tier   m_levelTier                                  = m_levelTierList[layerPTLIdx];
     443    Level::Name   m_level                                      = m_levelList[layerPTLIdx];
     444    UInt          m_bitDepthConstraint                         = m_apcLayerCfg[layer]->m_bitDepthConstraint;
     445    ChromaFormat  m_chromaFormatConstraint                     = m_apcLayerCfg[layer]->m_chromaFormatConstraint;
     446    Bool          m_intraConstraintFlag                        = m_apcLayerCfg[layer]->m_intraConstraintFlag;
     447    Bool          m_onePictureOnlyConstraintFlag               = m_apcLayerCfg[layer]->m_onePictureOnlyConstraintFlag;
     448    Bool          m_lowerBitRateConstraintFlag                 = m_apcLayerCfg[layer]->m_lowerBitRateConstraintFlag;
     449    Bool          m_progressiveSourceFlag                      = m_progressiveSourceFlagList[layerPTLIdx];
     450    Bool          m_interlacedSourceFlag                       = m_interlacedSourceFlagList[layerPTLIdx];
     451    Bool          m_nonPackedConstraintFlag                    = m_nonPackedConstraintFlagList[layerPTLIdx];
     452    Bool          m_frameOnlyConstraintFlag                    = m_frameOnlyConstraintFlagList[layerPTLIdx];
     453
     454    Int           m_iFrameRate                                 = m_apcLayerCfg[layer]->getFrameRate();
     455    Int           m_iSourceWidth                               = m_apcLayerCfg[layer]->getSourceWidth();
     456    Int           m_iSourceHeight                              = m_apcLayerCfg[layer]->getSourceHeight();
     457    Int           m_confWinLeft                                = m_apcLayerCfg[layer]->m_confWinLeft;
     458    Int           m_confWinRight                               = m_apcLayerCfg[layer]->m_confWinRight;
     459    Int           m_confWinTop                                 = m_apcLayerCfg[layer]->m_confWinTop;
     460    Int           m_confWinBottom                              = m_apcLayerCfg[layer]->m_confWinBottom;
     461
     462    Int           m_iIntraPeriod                               = m_apcLayerCfg[layer]->m_iIntraPeriod;
     463    Int           m_iQP                                        = m_apcLayerCfg[layer]->getIntQP();
     464    Int          *m_aiPad                                      = m_apcLayerCfg[layer]->getPad();
     465
     466    Int           m_iMaxCuDQPDepth                             = m_apcLayerCfg[layer]->m_iMaxCuDQPDepth;
     467    ChromaFormat  m_chromaFormatIDC                            = m_apcLayerCfg[layer]->m_chromaFormatIDC;
     468    Bool          m_extendedPrecisionProcessingFlag            = m_apcLayerCfg[layer]->m_extendedPrecisionProcessingFlag;
     469    Bool          m_highPrecisionOffsetsEnabledFlag            = m_apcLayerCfg[layer]->m_highPrecisionOffsetsEnabledFlag;
     470    Int           *m_aidQP                                     = m_apcLayerCfg[layer]->getdQPs();
     471
     472    UInt          m_uiMaxCUWidth                               = m_apcLayerCfg[layer]->m_uiMaxCUWidth;
     473    UInt          m_uiMaxCUHeight                              = m_apcLayerCfg[layer]->m_uiMaxCUHeight;
     474    UInt          m_uiMaxTotalCUDepth                          = m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth;
     475    UInt          m_uiLog2DiffMaxMinCodingBlockSize            = m_apcLayerCfg[layer]->m_uiLog2DiffMaxMinCodingBlockSize;
     476    UInt          m_uiQuadtreeTULog2MaxSize                    = m_apcLayerCfg[layer]->m_uiQuadtreeTULog2MaxSize;
     477    UInt          m_uiQuadtreeTULog2MinSize                    = m_apcLayerCfg[layer]->m_uiQuadtreeTULog2MinSize;
     478    UInt          m_uiQuadtreeTUMaxDepthInter                  = m_apcLayerCfg[layer]->m_uiQuadtreeTUMaxDepthInter;
     479    UInt          m_uiQuadtreeTUMaxDepthIntra                  = m_apcLayerCfg[layer]->m_uiQuadtreeTUMaxDepthIntra;
     480
     481    Int           m_iWaveFrontSynchro                          = m_apcLayerCfg[layer]->m_waveFrontSynchro;
     482    Bool          m_RCEnableRateControl                        = m_apcLayerCfg[layer]->getRCEnableRateControl();
     483    Int           m_RCTargetBitrate                            = m_apcLayerCfg[layer]->getRCTargetBitrate();
     484    Bool          m_RCKeepHierarchicalBit                      = m_apcLayerCfg[layer]->getRCKeepHierarchicalBit();
     485    Bool          m_RCLCULevelRC                               = m_apcLayerCfg[layer]->getRCLCULevelRC();
     486    Bool          m_RCUseLCUSeparateModel                      = m_apcLayerCfg[layer]->getRCUseLCUSeparateModel();
     487    Int           m_RCInitialQP                                = m_apcLayerCfg[layer]->getRCInitialQP();
     488    Bool          m_RCForceIntraQP                             = m_apcLayerCfg[layer]->getRCForceIntraQP();
     489#endif
    803490
    804491  m_cTEncTop.setProfile                                           ( m_profile);
     
    830517  m_cTEncTop.setDecodingRefreshType                               ( m_iDecodingRefreshType );
    831518  m_cTEncTop.setGOPSize                                           ( m_iGOPSize );
     519#if SVC_EXTENSION
     520  m_cTEncTop.setGopList                                           ( layer ? m_EhGOPList[layer] : m_GOPList );
     521  m_cTEncTop.setExtraRPSs                                         ( m_extraRPSs[layer] );
     522#else
    832523  m_cTEncTop.setGopList                                           ( m_GOPList );
    833524  m_cTEncTop.setExtraRPSs                                         ( m_extraRPSs );
     525#endif
     526
    834527  for(Int i = 0; i < MAX_TLAYER; i++)
    835528  {
     
    845538  m_cTEncTop.setPad                                               ( m_aiPad );
    846539
     540#if SVC_EXTENSION
     541  m_cTEncTop.setMaxTempLayer                                      ( layer ? m_EhMaxTempLayer[layer] : m_maxTempLayer );
     542#else
    847543  m_cTEncTop.setMaxTempLayer                                      ( m_maxTempLayer );
     544#endif
    848545  m_cTEncTop.setUseAMP( m_enableAMP );
    849546
     
    907604  m_cTEncTop.setUseCbfFastMode                                    ( m_bUseCbfFastMode  );
    908605  m_cTEncTop.setUseEarlySkipDetection                             ( m_useEarlySkipDetection );
    909 #if FAST_INTRA_SHVC
    910   m_cTEncTop.setUseFastIntraScalable                              ( m_useFastIntraScalable );
    911 #endif
    912606  m_cTEncTop.setCrossComponentPredictionEnabledFlag               ( m_crossComponentPredictionEnabledFlag );
    913607  m_cTEncTop.setUseReconBasedCrossCPredictionEstimate             ( m_reconBasedCrossCPredictionEstimate );
     
    935629  for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
    936630  {
     631#if SVC_EXTENSION
     632    m_cTEncTop.setBitDepth((ChannelType)channelType, m_apcLayerCfg[layer]->m_internalBitDepth[channelType]);
     633    m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_apcLayerCfg[layer]->m_MSBExtendedBitDepth[channelType] : m_apcLayerCfg[layer]->m_internalBitDepth[channelType]);
     634#else
    937635    m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepth[channelType]);
    938636    m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType]);
     637#endif
    939638  }
    940639
     
    1042741  m_cTEncTop.setKneeSEIOutputKneePoint                            ( m_kneeSEIOutputKneePoint );
    1043742  m_cTEncTop.setMasteringDisplaySEI                               ( m_masteringDisplay );
    1044 #if Q0074_COLOUR_REMAPPING_SEI
    1045   m_cTEncTop.setCRISEIFileRoot                                    ( const_cast<Char*>(m_colourRemapSEIFileRoot.c_str()) );
    1046 #endif
    1047 #if LAYERS_NOT_PRESENT_SEI
    1048   m_cTEncTop.setLayersNotPresentSEIEnabled( m_layersNotPresentSEIEnabled );
    1049 #endif
     743
    1050744  m_cTEncTop.setTileUniformSpacingFlag                            ( m_tileUniformSpacingFlag );
    1051745  m_cTEncTop.setNumColumnsMinus1                                  ( m_numTileColumnsMinus1 );
     
    1117811  m_cTEncTop.setSummaryPicFilenameBase                            ( m_summaryPicFilenameBase );
    1118812  m_cTEncTop.setSummaryVerboseness                                ( m_summaryVerboseness );
     813
     814#if FAST_INTRA_SHVC
     815  m_cTEncTop.setUseFastIntraScalable                              ( m_useFastIntraScalable );
     816#endif
     817#if Q0074_COLOUR_REMAPPING_SEI
     818#if SVC_EXTENSION
     819  m_cTEncTop.setCRISEIFileRoot                                    ( const_cast<Char*>(m_apcLayerCfg[layer]->m_colourRemapSEIFileRoot.c_str()) );
     820#else
     821  m_cTEncTop.setCRISEIFileRoot                                    ( const_cast<Char*>(m_colourRemapSEIFileRoot.c_str()) );
     822#endif
     823#endif
     824#if LAYERS_NOT_PRESENT_SEI
     825  m_cTEncTop.setLayersNotPresentSEIEnabled                        ( m_layersNotPresentSEIEnabled );
     826#endif 
     827
     828
     829#if SVC_EXTENSION
     830  if( layer != 0 && m_useInterLayerWeightedPred )
     831  {
     832    // Enable weighted prediction for enhancement layer
     833    m_cTEncTop.setUseWP                                           ( true   );
     834    m_cTEncTop.setWPBiPred                                        ( true   );
     835  }
     836
     837  }
     838#endif
    1119839}
    1120 #endif //SVC_EXTENSION
    1121840
    1122841Void TAppEncTop::xCreateLib()
     
    1131850    //2
    1132851    // Video I/O
    1133     m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(),  false, m_acLayerCfg[layer].m_inputBitDepth, m_acLayerCfg[layer].m_MSBExtendedBitDepth, m_acLayerCfg[layer].m_internalBitDepth );  // read  mode
    1134     m_acTVideoIOYuvInputFile[layer].skipFrames(m_FrameSkip, m_acLayerCfg[layer].getSourceWidth() - m_acLayerCfg[layer].getPad()[0], m_acLayerCfg[layer].getSourceHeight() - m_acLayerCfg[layer].getPad()[1], m_acLayerCfg[layer].m_InputChromaFormatIDC);
    1135 
    1136     if( !m_acLayerCfg[layer].getReconFile().empty() )
    1137     {
    1138       m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_acLayerCfg[layer].m_outputBitDepth, m_acLayerCfg[layer].m_MSBExtendedBitDepth, m_acLayerCfg[layer].m_internalBitDepth );  // write mode
     852    m_apcTVideoIOYuvInputFile[layer]->open( (Char *)m_apcLayerCfg[layer]->getInputFile().c_str(),  false, m_apcLayerCfg[layer]->m_inputBitDepth, m_apcLayerCfg[layer]->m_MSBExtendedBitDepth, m_apcLayerCfg[layer]->m_internalBitDepth );  // read  mode
     853    m_apcTVideoIOYuvInputFile[layer]->skipFrames(m_FrameSkip, m_apcLayerCfg[layer]->getSourceWidth() - m_apcLayerCfg[layer]->getPad()[0], m_apcLayerCfg[layer]->getSourceHeight() - m_apcLayerCfg[layer]->getPad()[1], m_apcLayerCfg[layer]->m_InputChromaFormatIDC);
     854
     855    if( !m_apcLayerCfg[layer]->getReconFile().empty() )
     856    {
     857      m_apcTVideoIOYuvReconFile[layer]->open((Char *)m_apcLayerCfg[layer]->getReconFile().c_str(), true, m_apcLayerCfg[layer]->m_outputBitDepth, m_apcLayerCfg[layer]->m_MSBExtendedBitDepth, m_apcLayerCfg[layer]->m_internalBitDepth );  // write mode
    1139858    }
    1140859
    1141860    // Neo Decoder
    1142     m_acTEncTop[layer].create();
     861    m_apcTEncTop[layer]->create();
    1143862  }
    1144863#else //SVC_EXTENSION
     
    1164883  destroyROM();
    1165884
    1166   for(UInt layer=0; layer<m_numLayers; layer++)
    1167   {
    1168 #if LAYER_CTB
    1169     g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
    1170     g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
    1171     g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
    1172     g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
    1173 #endif
    1174 
    1175     m_acTVideoIOYuvInputFile[layer].close();
    1176     m_acTVideoIOYuvReconFile[layer].close();
    1177 
    1178     m_acTEncTop[layer].destroy();
     885  for( UInt layer=0; layer < m_numLayers; layer++ )
     886  {
     887    if( m_apcTVideoIOYuvInputFile[layer] )
     888    {
     889      m_apcTVideoIOYuvInputFile[layer]->close();
     890      delete m_apcTVideoIOYuvInputFile[layer];
     891      m_apcTVideoIOYuvInputFile[layer] = NULL;
     892    }
     893
     894    if( m_apcTVideoIOYuvReconFile[layer] )
     895    {
     896      m_apcTVideoIOYuvReconFile[layer]->close();
     897      delete m_apcTVideoIOYuvReconFile[layer];
     898      m_apcTVideoIOYuvReconFile[layer] = NULL;
     899    }
     900
     901    if( m_apcTEncTop[layer] )
     902    {
     903      m_apcTEncTop[layer]->destroy();
     904      delete m_apcTEncTop[layer];
     905      m_apcTEncTop[layer] = NULL;
     906    }
    1179907  }
    1180908#else //SVC_EXTENSION
     
    1190918{
    1191919#if SVC_EXTENSION
    1192   TComVPS* vps = m_acTEncTop[0].getVPS();
    1193   m_acTEncTop[0].getVPS()->setMaxLayers( m_numLayers );
     920  TComVPS* vps = m_apcTEncTop[0]->getVPS();
     921  m_apcTEncTop[0]->getVPS()->setMaxLayers( m_numLayers );
    1194922
    1195923  UInt i = 0, dimIdLen = 0;
     
    1205933  for(i = 1; i < vps->getMaxLayers(); i++)
    1206934  {
    1207     vps->setLayerIdInNuh(i, m_acLayerCfg[i].m_layerId);   
     935    vps->setLayerIdInNuh(i, m_apcLayerCfg[i]->m_layerId);   
    1208936    vps->setLayerIdxInVps(vps->getLayerIdInNuh(i), i);
    1209937    vps->setDimensionId(i, 0, i);
    1210938
    1211     if( m_acLayerCfg[i].m_layerId != i )
     939    if( m_apcLayerCfg[i]->m_layerId != i )
    1212940    {
    1213941      vps->setNuhLayerIdPresentFlag(true);
     
    1224952    memcpy( g_auiRasterToPelY,  g_auiLayerRasterToPelY[layer],  sizeof( g_auiRasterToPelY ) );
    1225953#endif
    1226     m_acTEncTop[layer].init(isFieldCoding);
     954    m_apcTEncTop[layer]->init(isFieldCoding);
    1227955  }
    1228956
    1229957  // Set max-layer ID
    1230   vps->setMaxLayerId( m_acLayerCfg[m_numLayers - 1].m_layerId );
     958  vps->setMaxLayerId( m_apcLayerCfg[m_numLayers - 1]->m_layerId );
    1231959  vps->setVpsExtensionFlag( m_numLayers > 1 ? true : false );
    1232960
     
    13381066    for(i = 1; i < vps->getMaxLayers(); i++)
    13391067    {
    1340       if (m_acLayerCfg[i].getAuxId() > maxAuxId)
    1341       {
    1342         maxAuxId = m_acLayerCfg[i].getAuxId();
     1068      if (m_apcLayerCfg[i]->getAuxId() > maxAuxId)
     1069      {
     1070        maxAuxId = m_apcLayerCfg[i]->getAuxId();
    13431071      }
    13441072    }
     
    13501078    for(i = 1; i < vps->getMaxLayers(); i++)
    13511079    {
    1352       vps->setDimensionId(i, auxId, m_acLayerCfg[i].getAuxId());
     1080      vps->setDimensionId(i, auxId, m_apcLayerCfg[i]->getAuxId());
    13531081    }
    13541082  }
     
    13691097      for( Int j = i+1; j < vps->getMaxLayers(); j++)
    13701098      {
    1371         vps->setMaxTidIlRefPicsPlus1(i, j, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
     1099        vps->setMaxTidIlRefPicsPlus1(i, j, m_apcTEncTop[i]->getMaxTidIlRefPicsPlus1());
    13721100      }
    13731101    }
     
    13941122    Int numDirectRefLayers = 0;
    13951123
    1396     vps->setNumDirectRefLayers(layerId, m_acTEncTop[layerCtr].getNumDirectRefLayers());
     1124    vps->setNumDirectRefLayers(layerId, m_apcTEncTop[layerCtr]->getNumDirectRefLayers());
    13971125    maxDirectRefLayers = max<UInt>(maxDirectRefLayers, vps->getNumDirectRefLayers(layerId));
    13981126
    13991127    for (i = 0; i < vps->getNumDirectRefLayers(layerId); i++)
    14001128    {
    1401       vps->setRefLayerId(layerId, i, m_acTEncTop[layerCtr].getRefLayerId(i));
     1129      vps->setRefLayerId(layerId, i, m_apcTEncTop[layerCtr]->getRefLayerId(i));
    14021130    }
    14031131    // Set direct dependency flag
     
    14091137    for (i = 0; i < vps->getNumDirectRefLayers(layerId); i++)
    14101138    {
    1411       vps->setDirectDependencyFlag(layerCtr, vps->getLayerIdxInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true);
     1139      vps->setDirectDependencyFlag(layerCtr, vps->getLayerIdxInVps(m_apcTEncTop[layerCtr]->getRefLayerId(i)), true);
    14121140    }
    14131141    // prediction indications
     
    14171145      if (vps->getDirectDependencyFlag(layerCtr, refLayerCtr))
    14181146      {
    1419         assert(m_acTEncTop[layerCtr].getSamplePredEnabledFlag(numDirectRefLayers) || m_acTEncTop[layerCtr].getMotionPredEnabledFlag(numDirectRefLayers));
    1420         vps->setDirectDependencyType(layerCtr, refLayerCtr, ((m_acTEncTop[layerCtr].getSamplePredEnabledFlag(numDirectRefLayers) ? 1 : 0) |
    1421           (m_acTEncTop[layerCtr].getMotionPredEnabledFlag(numDirectRefLayers) ? 2 : 0)) - 1);
     1147        assert(m_apcTEncTop[layerCtr]->getSamplePredEnabledFlag(numDirectRefLayers) || m_apcTEncTop[layerCtr]->getMotionPredEnabledFlag(numDirectRefLayers));
     1148        vps->setDirectDependencyType(layerCtr, refLayerCtr, ((m_apcTEncTop[layerCtr]->getSamplePredEnabledFlag(numDirectRefLayers) ? 1 : 0) |
     1149          (m_apcTEncTop[layerCtr]->getMotionPredEnabledFlag(numDirectRefLayers) ? 2 : 0)) - 1);
    14221150
    14231151        if (!isDefaultDirectDependencyTypeSet)
     
    15351263      {
    15361264        Int layerId = vps->getLayerSetLayerIdList(layerSetId, k); // k-th layer in the output layer set
    1537         vps->setMaxVpsDecPicBufferingMinus1( i, k, j,  m_acTEncTop[vps->getLayerIdxInVps(layerId)].getMaxDecPicBuffering(j) - 1 );
    1538         maxNumReorderPics       = std::max( maxNumReorderPics, m_acTEncTop[vps->getLayerIdxInVps(layerId)].getNumReorderPics(j));
     1265        vps->setMaxVpsDecPicBufferingMinus1( i, k, j,  m_apcTEncTop[vps->getLayerIdxInVps(layerId)]->getMaxDecPicBuffering(j) - 1 );
     1266        maxNumReorderPics       = std::max( maxNumReorderPics, m_apcTEncTop[vps->getLayerIdxInVps(layerId)]->getNumReorderPics(j));
    15391267      }
    15401268      vps->setMaxVpsNumReorderPics(i, j, maxNumReorderPics);
     
    15721300      if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr))
    15731301      {
    1574         if(m_acTEncTop[layerCtr].getIntraPeriod() !=  m_acTEncTop[refLayerCtr].getIntraPeriod())
     1302        if(m_apcTEncTop[layerCtr]->getIntraPeriod() !=  m_apcTEncTop[refLayerCtr]->getIntraPeriod())
    15751303        {
    15761304          vps->setCrossLayerIrapAlignFlag(false);
     
    15901318  // VPS VUI BSP HRD parameters
    15911319  vps->setVpsVuiBspHrdPresentFlag(false);
    1592   TEncTop *pcCfg = &m_acTEncTop[0];
     1320  TEncTop *pcCfg = m_apcTEncTop[0];
    15931321  if( pcCfg->getBufferingPeriodSEIEnabled() )
    15941322  {
     
    16031331
    16041332      UInt layerIdx = j;
    1605       TEncTop *pcCfgLayer = &m_acTEncTop[layerIdx];
     1333      TEncTop *pcCfgLayer = m_apcTEncTop[layerIdx];
    16061334
    16071335      Int iPicWidth         = pcCfgLayer->getSourceWidth();
    16081336      Int iPicHeight        = pcCfgLayer->getSourceHeight();
    16091337
    1610       UInt uiWidthInCU      = ( iPicWidth  % m_acLayerCfg[layerIdx].m_uiMaxCUWidth  ) ? iPicWidth  / m_acLayerCfg[layerIdx].m_uiMaxCUWidth  + 1 : iPicWidth  / m_acLayerCfg[layerIdx].m_uiMaxCUWidth;
    1611       UInt uiHeightInCU     = ( iPicHeight % m_acLayerCfg[layerIdx].m_uiMaxCUHeight ) ? iPicHeight / m_acLayerCfg[layerIdx].m_uiMaxCUHeight + 1 : iPicHeight / m_acLayerCfg[layerIdx].m_uiMaxCUHeight;
    1612       UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_acLayerCfg[layerIdx].m_uiMaxCUDepth << 1);
     1338      UInt uiWidthInCU      = ( iPicWidth  % m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth  ) ? iPicWidth  / m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth  + 1 : iPicWidth  / m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth;
     1339      UInt uiHeightInCU     = ( iPicHeight % m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight ) ? iPicHeight / m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight + 1 : iPicHeight / m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight;
     1340      UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_apcLayerCfg[layerIdx]->m_uiMaxCUDepth << 1);
    16131341
    16141342      UInt uiNumCUsInFrame   = uiWidthInCU * uiHeightInCU;
     
    16891417  }
    16901418
     1419  // allocated memory
     1420  for( Int layer = 0; layer < m_numLayers; layer++ )
     1421  {
     1422    m_apcTVideoIOYuvInputFile[layer] = new TVideoIOYuv;   
     1423    m_apcTVideoIOYuvReconFile[layer] = new TVideoIOYuv;
     1424    m_apcTEncTop[layer] = new TEncTop;
     1425  }
     1426
    16911427  TComPicYuv*       pcPicYuvOrg [MAX_LAYERS];
    16921428  TComPicYuv*       pcPicYuvRec = NULL;
     
    17151451    if( m_isField )
    17161452    {
    1717       pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxTotalCUDepth, true, NULL );
    1718       acPicYuvTrueOrg[layer].create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxTotalCUDepth, true, NULL );
     1453      pcPicYuvOrg[layer]->create( m_apcLayerCfg[layer]->getSourceWidth(), m_apcLayerCfg[layer]->getSourceHeightOrg(), m_apcLayerCfg[layer]->getChromaFormatIDC(), m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL );
     1454      acPicYuvTrueOrg[layer].create( m_apcLayerCfg[layer]->getSourceWidth(), m_apcLayerCfg[layer]->getSourceHeightOrg(), m_apcLayerCfg[layer]->getChromaFormatIDC(), m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL );
    17191455    }
    17201456    else
    17211457    {
    1722       pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxTotalCUDepth, true, NULL );
    1723       acPicYuvTrueOrg[layer].create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxTotalCUDepth, true, NULL );
     1458      pcPicYuvOrg[layer]->create( m_apcLayerCfg[layer]->getSourceWidth(), m_apcLayerCfg[layer]->getSourceHeight(), m_apcLayerCfg[layer]->getChromaFormatIDC(), m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL );
     1459      acPicYuvTrueOrg[layer].create( m_apcLayerCfg[layer]->getSourceWidth(), m_apcLayerCfg[layer]->getSourceHeight(), m_apcLayerCfg[layer]->getChromaFormatIDC(), m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL );
    17241460    }
    17251461  }
     
    17351471      {
    17361472        //6
    1737 #if LAYER_CTB
    1738         g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
    1739         g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
    1740         g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
    1741         g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
    1742 #endif
    1743 
    17441473        // get buffers
    17451474        xGetBuffer(pcPicYuvRec, layer);
    17461475
    17471476        // read input YUV file
    1748         m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer], ipCSC, m_acLayerCfg[layer].getPad(), m_acLayerCfg[layer].getInputChromaFormat(), m_bClipInputVideoToRec709Range );
     1477        m_apcTVideoIOYuvInputFile[layer]->read( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer], ipCSC, m_apcLayerCfg[layer]->getPad(), m_apcLayerCfg[layer]->getInputChromaFormat(), m_bClipInputVideoToRec709Range );
    17491478
    17501479#if AUXILIARY_PICTURES
    1751         if( m_acLayerCfg[layer].getChromaFormatIDC() == CHROMA_400 || (m_apcTEncTop[0]->getVPS()->getScalabilityMask(AUX_ID) && (m_acLayerCfg[layer].getAuxId() == AUX_ALPHA || m_acLayerCfg[layer].getAuxId() == AUX_DEPTH)) )
    1752         {
    1753           pcPicYuvOrg[layer]->convertToMonochrome(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1480        if( m_apcLayerCfg[layer]->getChromaFormatIDC() == CHROMA_400 || (m_apcTEncTop[0]->getVPS()->getScalabilityMask(AUX_ID) && (m_apcLayerCfg[layer]->getAuxId() == AUX_ALPHA || m_apcLayerCfg[layer]->getAuxId() == AUX_DEPTH)) )
     1481        {
     1482          pcPicYuvOrg[layer]->convertToMonochrome(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
    17541483        }
    17551484#endif
     
    17651494        if ( m_isField )
    17661495        {
    1767           m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer], m_isTopFieldFirst );
     1496          m_apcTEncTop[layer]->encodePrep( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer], m_isTopFieldFirst );
    17681497        }
    17691498        else
    17701499        {
    1771           m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer] );
    1772         }
    1773       }
    1774 
    1775       bFramesReadyToCode = !(!bFirstFrame && ( m_acTEncTop[m_numLayers-1].getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos );
     1500          m_apcTEncTop[layer]->encodePrep( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer] );
     1501        }
     1502      }
     1503
     1504      bFramesReadyToCode = !(!bFirstFrame && ( m_apcTEncTop[m_numLayers-1]->getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos );
    17761505    }
    17771506    Bool flush = 0;
    17781507    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
    1779     if (m_acTVideoIOYuvInputFile[m_numLayers-1].isEof())
     1508    if (m_apcTVideoIOYuvInputFile[m_numLayers-1]->isEof())
    17801509    {
    17811510      flush = true;
    17821511      bEos = true;
    17831512      m_iFrameRcvd--;
    1784       m_acTEncTop[m_numLayers-1].setFramesToBeEncoded(m_iFrameRcvd);
     1513      m_apcTEncTop[m_numLayers-1]->setFramesToBeEncoded(m_iFrameRcvd);
    17851514    }
    17861515
    17871516#if RC_SHVC_HARMONIZATION
    1788     for(UInt layer=0; layer<m_numLayers; layer++)
    1789     {
    1790       if ( m_acTEncTop[layer].getUseRateCtrl() )
    1791       {
    1792         (m_acTEncTop[layer].getRateCtrl())->initRCGOP(m_acTEncTop[layer].getNumPicRcvd());
     1517    for( UInt layer=0; layer<m_numLayers; layer++ )
     1518    {
     1519      if( m_apcTEncTop[layer]->getUseRateCtrl() )
     1520      {
     1521        m_apcTEncTop[layer]->getRateCtrl()->initRCGOP(m_apcTEncTop[layer]->getNumPicRcvd());
    17931522      }
    17941523    }
     
    18241553        if ( m_isField )
    18251554        {
    1826           m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst );
     1555          m_apcTEncTop[layer]->encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst );
    18271556        }
    18281557        else
    18291558        {
    1830           m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
     1559          m_apcTEncTop[layer]->encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
    18311560        }
    18321561      }
     
    18671596    for(UInt layer=0; layer<m_numLayers; layer++)
    18681597    {
    1869       if ( m_acTEncTop[layer].getUseRateCtrl() )
    1870       {
    1871         (m_acTEncTop[layer].getRateCtrl())->destroyRCGOP();
     1598      if ( m_apcTEncTop[layer]->getUseRateCtrl() )
     1599      {
     1600        (m_apcTEncTop[layer]->getRateCtrl())->destroyRCGOP();
    18721601      }
    18731602    }
     
    18791608      //8
    18801609      // write bistream to file if necessary
    1881       iNumEncoded = m_acTEncTop[layer].getNumPicRcvd();
     1610      iNumEncoded = m_apcTEncTop[layer]->getNumPicRcvd();
    18821611      if ( iNumEncoded > 0 )
    18831612      {
     
    18851614        iTotalNumEncoded += iNumEncoded;
    18861615      }
    1887       m_acTEncTop[layer].setNumPicRcvd( 0 );
     1616      m_apcTEncTop[layer]->setNumPicRcvd( 0 );
    18881617    }
    18891618
     
    19211650
    19221651    // delete used buffers in encoder class
    1923     m_acTEncTop[layer].deletePicBuffer();
     1652    m_apcTEncTop[layer]->deletePicBuffer();
    19241653    acPicYuvTrueOrg[layer].destroy();
    19251654  }
     
    19431672  for(layer = 0; layer < m_numLayers; layer++)
    19441673  {
    1945     m_apcTEncTop[layer]->getAnalyzeAll()->setFrmRate( m_acLayerCfg[layer].getFrameRate() * rateMultiplier );
    1946     m_apcTEncTop[layer]->getAnalyzeI()->setFrmRate( m_acLayerCfg[layer].getFrameRate() * rateMultiplier );
    1947     m_apcTEncTop[layer]->getAnalyzeP()->setFrmRate( m_acLayerCfg[layer].getFrameRate() * rateMultiplier );
    1948     m_apcTEncTop[layer]->getAnalyzeB()->setFrmRate( m_acLayerCfg[layer].getFrameRate() * rateMultiplier );
     1674    m_apcTEncTop[layer]->getAnalyzeAll()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier );
     1675    m_apcTEncTop[layer]->getAnalyzeI()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier );
     1676    m_apcTEncTop[layer]->getAnalyzeP()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier );
     1677    m_apcTEncTop[layer]->getAnalyzeB()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier );
    19491678  }
    19501679
     
    19531682  for(layer = 0; layer < m_numLayers; layer++)
    19541683  {
    1955     const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);   
    1956     m_apcTEncTop[layer]->getAnalyzeAll()->printOut('a', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
     1684    const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]);   
     1685    m_apcTEncTop[layer]->getAnalyzeAll()->printOut('a', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
    19571686  }
    19581687
     
    19601689  for(layer = 0; layer < m_numLayers; layer++)
    19611690  {
    1962     const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
    1963     m_apcTEncTop[layer]->getAnalyzeI()->printOut('i', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
     1691    const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1692    m_apcTEncTop[layer]->getAnalyzeI()->printOut('i', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
    19641693  }
    19651694
     
    19671696  for(layer = 0; layer < m_numLayers; layer++)
    19681697  {
    1969     const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
    1970     m_apcTEncTop[layer]->getAnalyzeP()->printOut('p', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
     1698    const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1699    m_apcTEncTop[layer]->getAnalyzeP()->printOut('p', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
    19711700  }
    19721701
     
    19741703  for(layer = 0; layer < m_numLayers; layer++)
    19751704  {
    1976     const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
    1977     m_apcTEncTop[layer]->getAnalyzeB()->printOut('b', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
     1705    const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1706    m_apcTEncTop[layer]->getAnalyzeB()->printOut('b', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
    19781707  }
    19791708
     
    19821711    if (!m_apcTEncTop[layer]->getSummaryOutFilename().empty())
    19831712    {
    1984       const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
    1985 
    1986       m_apcTEncTop[layer]->getAnalyzeAll()->printSummary(m_acLayerCfg[layer].getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryOutFilename());
     1713      const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1714
     1715      m_apcTEncTop[layer]->getAnalyzeAll()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryOutFilename());
    19871716    }
    19881717  }
     
    19921721    if (!m_apcTEncTop[layer]->getSummaryPicFilenameBase().empty())
    19931722    {
    1994       const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
    1995 
    1996       m_apcTEncTop[layer]->getAnalyzeI()->printSummary(m_acLayerCfg[layer].getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"I.txt");
    1997       m_apcTEncTop[layer]->getAnalyzeP()->printSummary(m_acLayerCfg[layer].getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"P.txt");
    1998       m_apcTEncTop[layer]->getAnalyzeB()->printSummary(m_acLayerCfg[layer].getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"B.txt");
     1723      const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1724
     1725      m_apcTEncTop[layer]->getAnalyzeI()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"I.txt");
     1726      m_apcTEncTop[layer]->getAnalyzeP()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"P.txt");
     1727      m_apcTEncTop[layer]->getAnalyzeB()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"B.txt");
    19991728    }
    20001729  }
     
    20041733    for(layer = 0; layer < m_numLayers; layer++)
    20051734    {
    2006       const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1735      const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
    20071736      TEncAnalyze *analyze = m_apcTEncTop[layer]->getAnalyzeAllin();
    20081737
    20091738      //-- interlaced summary
    2010       analyze->setFrmRate( m_acLayerCfg[layer].getFrameRate());
     1739      analyze->setFrmRate( m_apcLayerCfg[layer]->getFrameRate());
    20111740      analyze->setBits(m_apcTEncTop[layer]->getAnalyzeB()->getBits());
    20121741      // prior to the above statement, the interlace analyser does not contain the correct total number of bits.
    20131742
    20141743      printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" );
    2015       analyze->printOut('a', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
     1744      analyze->printOut('a', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
    20161745
    20171746      if (!m_apcTEncTop[layer]->getSummaryOutFilename().empty())
    20181747      {
    2019         analyze->printSummary(m_acLayerCfg[layer].getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryOutFilename());
     1748        analyze->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryOutFilename());
    20201749      }
    20211750    }
     
    21701899    rpcPicYuvRec = new TComPicYuv;
    21711900
    2172     rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxTotalCUDepth, true, NULL );
     1901    rpcPicYuvRec->create( m_apcLayerCfg[layer]->getSourceWidth(), m_apcLayerCfg[layer]->getSourceHeight(), m_apcLayerCfg[layer]->getChromaFormatIDC(), m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL );
    21731902  }
    21741903  m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec );
     
    21941923Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded)
    21951924{
    2196   ChromaFormat chromaFormatIdc = m_acLayerCfg[layer].getChromaFormatIDC();
     1925  ChromaFormat chromaFormatIdc = m_apcLayerCfg[layer]->getChromaFormatIDC();
    21971926  Int xScal = TComSPS::getWinUnitX( chromaFormatIdc );
    21981927  Int yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     
    22161945      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
    22171946
    2218       if( !m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed() )
    2219       {
    2220         m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_acLayerCfg[layer].getConfWinLeft() * xScal, m_acLayerCfg[layer].getConfWinRight() * xScal,
    2221         m_acLayerCfg[layer].getConfWinTop() * yScal, m_acLayerCfg[layer].getConfWinBottom() * yScal, NUM_CHROMA_FORMAT, m_isTopFieldFirst );
     1947      if( !m_apcLayerCfg[layer]->getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed() )
     1948      {
     1949        m_apcTVideoIOYuvReconFile[layer]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_apcLayerCfg[layer]->getConfWinLeft() * xScal, m_apcLayerCfg[layer]->getConfWinRight() * xScal,
     1950        m_apcLayerCfg[layer]->getConfWinTop() * yScal, m_apcLayerCfg[layer]->getConfWinBottom() * yScal, NUM_CHROMA_FORMAT, m_isTopFieldFirst );
    22221951      }
    22231952    }
     
    22371966    {
    22381967      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
    2239       if( !m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed() )
    2240       {
    2241         m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, ipCSC, m_acLayerCfg[layer].getConfWinLeft() * xScal, m_acLayerCfg[layer].getConfWinRight() * xScal,
    2242           m_acLayerCfg[layer].getConfWinTop() * yScal, m_acLayerCfg[layer].getConfWinBottom() * yScal,
     1968      if( !m_apcLayerCfg[layer]->getReconFile().empty() && pcPicYuvRec->isReconstructed() )
     1969      {
     1970        m_apcTVideoIOYuvReconFile[layer]->write( pcPicYuvRec, ipCSC, m_apcLayerCfg[layer]->getConfWinLeft() * xScal, m_apcLayerCfg[layer]->getConfWinRight() * xScal,
     1971          m_apcLayerCfg[layer]->getConfWinTop() * yScal, m_apcLayerCfg[layer]->getConfWinBottom() * yScal,
    22431972          NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range  );
    22441973      }
     
    24312160{
    24322161#if SVC_EXTENSION
    2433   Double time = (Double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate();
     2162  Double time = (Double) m_iFrameRcvd / m_apcLayerCfg[m_numLayers-1]->getFrameRate();
    24342163#else
    24352164  Double time = (Double) m_iFrameRcvd / m_iFrameRate;
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.h

    r1292 r1377  
    6060  // class interface
    6161#if SVC_EXTENSION
    62   TEncTop                    m_acTEncTop [MAX_LAYERS];                    ///< encoder class
    63   TEncTop*                   m_apcTEncTop [MAX_LAYERS];                   ///< encoder pointer class
    64   TVideoIOYuv                m_acTVideoIOYuvInputFile [MAX_LAYERS];       ///< input YUV file
    65   TVideoIOYuv                m_acTVideoIOYuvReconFile [MAX_LAYERS];       ///< output reconstruction file
     62  TEncTop*                   m_apcTEncTop[MAX_LAYERS];                    ///< encoder pointer class
     63  TVideoIOYuv*               m_apcTVideoIOYuvInputFile[MAX_LAYERS];       ///< input YUV file
     64  TVideoIOYuv*               m_apcTVideoIOYuvReconFile[MAX_LAYERS];       ///< output reconstruction file
    6665
    6766  TComList<TComPicYuv*>      m_acListPicYuvRec [MAX_LAYERS];              ///< list of reconstruction YUV files
     
    114113  Void        encode      ();                               ///< main encoding function
    115114#if SVC_EXTENSION
    116   TEncTop&    getTEncTop  (UInt layer)   { return  m_acTEncTop[layer]; }      ///< return encoder class pointer reference
     115  TEncTop&    getTEncTop  (UInt layer)   { return  *m_apcTEncTop[layer]; }      ///< return encoder class pointer reference
    117116#else
    118117  TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
  • branches/SHM-dev/source/App/TAppEncoder/encmain.cpp

    r1259 r1377  
    7272  try
    7373  {
     74#if SVC_EXTENSION
     75    // parse number of layers first to allocate memory in the buffers
     76    if(!cTAppEncTop.parseCfgNumLayersAndInit( argc, argv ))
     77    {
     78      cTAppEncTop.destroy();
     79#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
     80      EnvVar::printEnvVar();
     81#endif
     82      return 1;
     83    }
     84#endif
     85
    7486    if(!cTAppEncTop.parseCfg( argc, argv ))
    7587    {
Note: See TracChangeset for help on using the changeset viewer.