Changeset 906 in SHVCSoftware for trunk/source/App


Ignore:
Timestamp:
15 Oct 2014, 07:25:10 (10 years ago)
Author:
seregin
Message:

merge SHM-dev

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/source

  • trunk/source/App/TAppDecoder/TAppDecCfg.cpp

    r815 r906  
    7878  string cfg_ReconFile;
    7979#endif
    80 #if AVC_SYNTAX || SYNTAX_OUTPUT
    81   string cfg_BLSyntaxFile;
    82 #endif
     80
    8381  string cfg_TargetDecLayerIdSetFile;
    8482
     
    9694  ("BLSourceHeight,-hgt",   m_iBLSourceHeight,       0, "BL source picture height")
    9795#endif
    98 #if AVC_SYNTAX
    99   ("BLSyntaxFile,-ibs",    cfg_BLSyntaxFile,  string(""), "BL syntax input file name") 
    100 #endif
    10196#endif
    10297#else
    10398  ("ReconFile,o",     cfg_ReconFile,     string(""), "reconstructed YUV output file name\n"
    10499                                                     "YUV writing is skipped if omitted")
    105 #endif
    106 #if SYNTAX_OUTPUT
    107   ("BLSyntaxFile,-ibs",    cfg_BLSyntaxFile,  string(""), "BL syntax input file name")
    108   ("BLSourceWidth,-wdt",    m_iBLSourceWidth,        0, "BL source picture width")
    109   ("BLSourceHeight,-hgt",   m_iBLSourceHeight,       0, "BL source picture height")
    110   ("BLFrames,-fr",          m_iBLFrames,       0, "BL number of frames")
    111100#endif
    112101  ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
     
    126115  ("TarDecLayerIdSetFile,l", cfg_TargetDecLayerIdSetFile, string(""), "targetDecLayerIdSet file name. The file should include white space separated LayerId values to be decoded. Omitting the option or a value of -1 in the file decodes all layers.")
    127116  ("RespectDefDispWindow,w", m_respectDefDispWindow, 0, "Only output content inside the default display window\n")
     117#if Q0074_COLOUR_REMAPPING_SEI
     118  ("SEIColourRemappingInfo", m_colourRemapSEIEnabled, false, "Control handling of Colour Remapping Information SEI messages\n"
     119                                              "\t1: apply colour remapping on decoded pictures if available in the bitstream\n"
     120                                              "\t0: ignore SEI message")
     121#endif
    128122  ;
    129123  po::setDefaults(opts);
     
    163157#else
    164158  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
    165 #endif
    166 #if AVC_SYNTAX || SYNTAX_OUTPUT
    167   m_pchBLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str());
    168159#endif
    169160
  • trunk/source/App/TAppDecoder/TAppDecCfg.h

    r713 r906  
    6969  Int           m_iMaxTemporalLayer;                  ///< maximum temporal layer to be decoded
    7070  Int           m_decodedPictureHashSEIEnabled;       ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
     71#if Q0074_COLOUR_REMAPPING_SEI
     72  Bool          m_colourRemapSEIEnabled;              ///< Enable the Colour Remapping Information SEI message if available (remapping decoded pictures)
     73#endif
    7174
    7275#if SVC_EXTENSION
     
    7881  Int           m_iBLSourceHeight;
    7982#endif
    80 #if AVC_SYNTAX
    81   Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name 
    8283#endif
    83 #endif
    84 #endif
    85 
    86 #if SYNTAX_OUTPUT
    87   Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
    88 #if !REPN_FORMAT_IN_VPS
    89   Int           m_iBLSourceWidth;
    90   Int           m_iBLSourceHeight;
    91 #endif
    92   Int           m_iBLFrames;
    9384#endif
    9485
     
    110101  , m_iMaxTemporalLayer(-1)
    111102  , m_decodedPictureHashSEIEnabled(0)
     103#if Q0074_COLOUR_REMAPPING_SEI
     104  , m_colourRemapSEIEnabled(0)
     105#endif
    112106#if SVC_EXTENSION
    113107  , m_tgtLayerId(0)
     
    115109  , m_iBLSourceWidth(0)
    116110  , m_iBLSourceHeight(0)
    117 #endif
    118 #if SYNTAX_OUTPUT
    119   , m_iBLSourceWidth(0)
    120   , m_iBLSourceHeight(0)
    121   , m_iBLFrames(0)
    122111#endif
    123112#endif
  • trunk/source/App/TAppDecoder/TAppDecTop.cpp

    r815 r906  
    102102  }
    103103#endif
    104 #if AVC_SYNTAX || SYNTAX_OUTPUT
    105   if( m_pchBLSyntaxFile )
    106   {
    107     free ( m_pchBLSyntaxFile );
    108     m_pchBLSyntaxFile = NULL;
    109   }
    110 #endif
    111104}
    112105
     
    163156  }
    164157  TComList<TComPic*> *cListPic = m_acTDecTop[0].getListPic();
    165 #if AVC_SYNTAX || !REPN_FORMAT_IN_VPS
    166   m_acTDecTop[0].setBLsize( m_iBLSourceWidth, m_iBLSourceHeight );
    167 #endif
    168158  m_acTDecTop[0].setBLReconFile( &streamYUV );
    169159  pcBLPic.setLayerId( 0 );
    170160  cListPic->pushBack( &pcBLPic );
    171 #if AVC_SYNTAX
    172   fstream streamSyntaxFile;
    173   if( m_pchBLSyntaxFile )
    174   {
    175     streamSyntaxFile.open( m_pchBLSyntaxFile, fstream::in | fstream::binary );
    176   }
    177   m_acTDecTop[0].setBLSyntaxFile( &streamSyntaxFile );
    178 #endif
    179161#endif
    180162
     
    363345    streamYUV.close();
    364346  }
    365 #if AVC_SYNTAX
    366   if( streamSyntaxFile.is_open() )
    367   {
    368     streamSyntaxFile.close();
    369   }
    370 #endif
    371347  pcBLPic.destroy();
    372348
     
    405381  Bool openedReconFile = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
    406382  Bool loopFiltered = false;
    407 
    408 #if SYNTAX_OUTPUT
    409   if( !m_pchBLSyntaxFile )
    410   {
    411     printf( "Wrong base layer syntax file\n" );
    412     exit(EXIT_FAILURE);
    413   }
    414   fstream streamSyntaxFile( m_pchBLSyntaxFile, fstream::out | fstream::binary );
    415   if( !streamSyntaxFile.good() )
    416   {
    417     printf( "Base layer syntax input reading error\n" );
    418     exit(EXIT_FAILURE);
    419   }
    420   m_cTDecTop.setBLSyntaxFile( &streamSyntaxFile );
    421 
    422   for( Int i = m_iBLFrames * m_iBLSourceWidth * m_iBLSourceHeight * SYNTAX_BYTES / 16; i >= 0; i-- )
    423   {
    424     streamSyntaxFile.put( 0 );
    425   }
    426   streamSyntaxFile.seekp( 0 );
    427 #endif
    428383
    429384  while (!!bitstreamFile)
     
    543498  }
    544499
    545 #if SYNTAX_OUTPUT
    546   if( streamSyntaxFile.is_open() )
    547   {
    548     streamSyntaxFile.close();
    549   }
    550 #endif
    551 
    552500  xFlushOutput( pcListPic );
    553501  // delete buffers
     
    620568    m_acTDecTop[layer].init();
    621569    m_acTDecTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     570#if Q0074_COLOUR_REMAPPING_SEI
     571    m_acTDecTop[layer].setColourRemappingInfoSEIEnabled(m_colourRemapSEIEnabled);
     572#endif
    622573    m_acTDecTop[layer].setNumLayer( m_tgtLayerId + 1 );
    623574#if OUTPUT_LAYER_SET_INDEX
     
    625576#endif
    626577  }
    627 
    628578#else
    629579  m_cTDecTop.init();
    630580  m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     581#if Q0074_COLOUR_REMAPPING_SEI
     582  m_cTDecTop.setColourRemappingInfoSEIEnabled(m_colourRemapSEIEnabled);
     583#endif
    631584#endif
    632585}
     
    727680          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
    728681          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
    729 #if Q0074_SEI_COLOR_MAPPING
    730           if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
    731           {
    732             pPicCYuvRecTop = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0, layerId );
    733             pPicCYuvRecBot = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1, layerId );
    734           }
    735 #endif
    736682#if REPN_FORMAT_IN_VPS
    737683          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     
    762708          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
    763709          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
    764 #if Q0074_SEI_COLOR_MAPPING
    765           if ( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
    766           {
    767             pPicCYuvRecTop = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0 );
    768             pPicCYuvRecBot = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1 );
    769           }
    770 #endif
    771710          m_cTVideoIOYuvReconFile.write( pPicCYuvRecTop, pPicCYuvRecBot,
    772711            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     
    843782          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    844783          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
    845 #if Q0074_SEI_COLOR_MAPPING
    846           if ( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
    847           {
    848             pPicCYuvRec = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerId );
    849           }
    850 #endif
    851 
    852784#if REPN_FORMAT_IN_VPS
    853785          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     
    873805        if ( m_pchReconFile )
    874806        {
    875 #if SYNTAX_OUTPUT
    876           TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
    877 #if Q0074_SEI_COLOR_MAPPING
    878           if( m_acTDecTop[layerIdx].m_ColorMapping->getColorMappingFlag() )
    879           {
    880             pPicCYuvRec = m_acTDecTop[layerIdx].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerIdx );
    881           }
    882 #endif
    883807          const Window &conf = pcPic->getConformanceWindow();
    884808          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    885           m_cTVideoIOYuvReconFile.write( pPicCYuvRec,
    886             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    887             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    888             conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    889             conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    890 #endif
     809          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     810                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     811                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     812                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     813                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    891814        }
    892815
     
    959882          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
    960883          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
    961 #if Q0074_SEI_COLOR_MAPPING
    962           if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
    963           {
    964             pPicCYuvRecTop = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0, layerId );
    965             pPicCYuvRecBot = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1, layerId );
    966           }
    967 #endif
    968884#if REPN_FORMAT_IN_VPS
    969885          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     
    994910          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
    995911          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
    996 #if Q0074_SEI_COLOR_MAPPING
    997           if( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
    998           {
    999             pPicCYuvRecTop = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0 );
    1000             pPicCYuvRecBot = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1 );
    1001           }
    1002 #endif
    1003912          m_cTVideoIOYuvReconFile.write( pPicCYuvRecTop, pPicCYuvRecBot,
    1004913            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     
    1078987          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    1079988          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
    1080 #if Q0074_SEI_COLOR_MAPPING
    1081           if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
    1082           {
    1083             pPicCYuvRec = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerId );
    1084           }
    1085 #endif
    1086989#if REPN_FORMAT_IN_VPS
    1087990          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     
    11101013          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    11111014          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
    1112 #if Q0074_SEI_COLOR_MAPPING
    1113           if( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
    1114           {
    1115             pPicCYuvRec = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRec );
    1116           }
    1117 #endif
    11181015          m_cTVideoIOYuvReconFile.write( pPicCYuvRec,
    11191016            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     
    11981095#endif
    11991096    TComPicYuv* pPicCYuvRec = pic->getPicYuvRec();
    1200 #if Q0074_SEI_COLOR_MAPPING
    1201     pPicCYuvRec = m_acTDecTop[layerIdx].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerIdx );
    1202 #endif
    12031097    m_acTVideoIOYuvReconFile[layerIdx].write( pPicCYuvRec,
    12041098      conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
     
    12211115    pic->getPicYuvRec()->setBorderExtension( false );
    12221116
     1117#if RESOLUTION_BASED_DPB
    12231118    dpbStatus.m_numPicsInLayer[layerIdx]--;
     1119#endif
     1120    dpbStatus.m_numPicsInSubDpb[layerIdx]--;
    12241121  }
    12251122}
     
    12851182  for(Int i = 0; i < MAX_LAYERS; i++)
    12861183  {
    1287     m_acTDecTop[i].getListPic()->clear();
     1184    markAllPicturesAsErased(i);
    12881185  }
    12891186}
     
    12911188Void TAppDecTop::markAllPicturesAsErased(Int layerIdx)
    12921189{
     1190  TComList<TComPic*>::iterator  iterPic = m_acTDecTop[layerIdx].getListPic()->begin();
     1191  Int iSize = Int( m_acTDecTop[layerIdx].getListPic()->size() );
     1192 
     1193  for (Int i = 0; i < iSize; i++ )
     1194  {
     1195    TComPic* pcPic = *(iterPic++);
     1196
     1197    if( pcPic )
     1198    {
     1199      pcPic->destroy();
     1200
     1201      // pcPic is statically created for the external (AVC) base layer, no need to delete it
     1202#if VPS_AVC_BL_FLAG_REMOVAL
     1203      if( !m_acTDecTop[layerIdx].getParameterSetManager()->getActiveVPS()->getNonHEVCBaseLayerFlag() || layerIdx )
     1204#else
     1205      if( !m_acTDecTop[layerIdx].getParameterSetManager()->getActiveVPS()->getAvcBaseLayerFlag() || layerIdx )
     1206#endif
     1207      {
     1208        delete pcPic;
     1209        pcPic = NULL;
     1210      }
     1211    }
     1212  }
     1213
    12931214  m_acTDecTop[layerIdx].getListPic()->clear();
    12941215}
     
    14341355      maxDpbLimit.m_maxLatencyPictures = sps->getMaxLatencyIncrease( highestTId ) + sps->getNumReorderPics( highestTId ) - 1;
    14351356    }
     1357#if RESOLUTION_BASED_DPB
    14361358    maxDpbLimit.m_numPicsInLayer[0] = sps->getMaxDecPicBuffering( highestTId );
     1359#endif
    14371360    maxDpbLimit.m_numPicsInSubDpb[0] = sps->getMaxDecPicBuffering( highestTId );
    14381361  }
     
    15821505          if( pic->getSlice(0)->isReferenced() || pic->getOutputMark() )
    15831506          {
     1507#if RESOLUTION_BASED_DPB
    15841508            dpbStatus.m_numPicsInLayer[i]++;  // Count pictures that are "used for reference" or "needed for output"
     1509#else
     1510            dpbStatus.m_numPicsInSubDpb[i]++;  // Count pictures that are "used for reference" or "needed for output"
     1511#endif
    15851512          }
    15861513#if POC_RESET_IDC_DECODER
     
    16071534#if RESOLUTION_BASED_DPB
    16081535    dpbStatus.m_numPicsInSubDpb[vps->getSubDpbAssigned(targetLsIdx,i)] += dpbStatus.m_numPicsInLayer[i];
    1609 #else
    16101536    dpbStatus.m_numPicsInSubDpb[i] += dpbStatus.m_numPicsInLayer[i];
    16111537#endif
  • trunk/source/App/TAppDecoder/TAppDecTop.h

    r815 r906  
    135135  Int m_numAUsNotDisplayed;
    136136  Int m_numPicsNotDisplayedInLayer[MAX_LAYERS];
     137#if RESOLUTION_BASED_DPB
    137138  Int m_numPicsInLayer[MAX_LAYERS];   // Pictures marked as used_for_reference or needed for output in the layer
     139#endif
    138140  Int m_numPicsInSubDpb[MAX_LAYERS];  // Pictures marked as used_for_reference or needed for output in the sub-DPB
    139141  Bool m_maxLatencyIncrease;
     
    152154    m_maxLatencyIncrease  = false;
    153155    m_maxLatencyPictures  = 0;
     156#if RESOLUTION_BASED_DPB
    154157    ::memset( m_numPicsInLayer,  0, sizeof(m_numPicsInLayer)  );
     158#endif
    155159    ::memset( m_numPicsInSubDpb, 0, sizeof(m_numPicsInSubDpb) );
    156160    ::memset(m_numPicsNotDisplayedInLayer, 0, sizeof(m_numPicsNotDisplayedInLayer) );
  • trunk/source/App/TAppEncoder/TAppEncCfg.cpp

    r815 r906  
    6767: m_pBitstreamFile()
    6868#if AVC_BASE
     69#if VPS_AVC_BL_FLAG_REMOVAL
     70, m_nonHEVCBaseLayerFlag(0)
     71#else
    6972, m_avcBaseLayerFlag(0)
    7073#endif
     74#endif
    7175, m_maxTidRefPresentFlag(1)
    72 , m_pColumnWidth()
    73 , m_pRowHeight()
     76#if OUTPUT_LAYER_SETS_CONFIG
     77, m_defaultTargetOutputLayerIdc (-1)
     78, m_numOutputLayerSets          (-1)
     79#endif
    7480, m_scalingListFile()
    7581, m_elRapSliceBEnabled(0)
     
    8793, m_pchReconFile()
    8894, m_pchdQPFile()
    89 , m_pColumnWidth()
    90 , m_pRowHeight()
    9195, m_scalingListFile()
    9296{
     
    9599  m_codedPivotValue = NULL;
    96100  m_targetPivotValue = NULL;
     101#if Q0074_COLOUR_REMAPPING_SEI
     102  for( Int c=0 ; c<3 ; c++)
     103  {
     104    m_colourRemapSEIPreLutCodedValue[c]   = NULL;
     105    m_colourRemapSEIPreLutTargetValue[c]  = NULL;
     106    m_colourRemapSEIPostLutCodedValue[c]  = NULL;
     107    m_colourRemapSEIPostLutTargetValue[c] = NULL;
     108  }
     109#endif
    97110}
    98111#endif
     
    101114{
    102115#if SVC_EXTENSION
    103   free(m_pBitstreamFile);
     116  if( m_pBitstreamFile )
     117  {
     118    free(m_pBitstreamFile);
     119    m_pBitstreamFile = NULL;
     120  }
    104121#else 
    105122  if ( m_aidQP )
     
    128145  free(m_pchReconFile);
    129146  free(m_pchdQPFile);
    130 #endif
    131   free(m_pColumnWidth);
    132   free(m_pRowHeight);
     147#if Q0074_COLOUR_REMAPPING_SEI
     148  for( Int c=0 ; c<3 ; c++)
     149  {
     150    if ( m_colourRemapSEIPreLutCodedValue[c] )
     151    {
     152      delete[] m_colourRemapSEIPreLutCodedValue[c];
     153    }
     154    if ( m_colourRemapSEIPreLutTargetValue[c] )
     155    {
     156      delete[] m_colourRemapSEIPreLutTargetValue[c];
     157    }
     158    if ( m_colourRemapSEIPostLutCodedValue[c] )
     159    {
     160      delete[] m_colourRemapSEIPostLutCodedValue[c];
     161    }
     162    if ( m_colourRemapSEIPostLutTargetValue[c] )
     163    {
     164      delete[] m_colourRemapSEIPostLutTargetValue[c];
     165    }
     166  }
     167#endif
     168#endif
    133169  free(m_scalingListFile);
    134170}
     
    337373  string* cfg_ReconFile      [MAX_LAYERS];
    338374  Double* cfg_fQP            [MAX_LAYERS];
    339 #if Q0074_SEI_COLOR_MAPPING
    340   string* cfg_seiColorMappingFile[MAX_LAYERS];
    341 #endif
    342 
    343375#if REPN_FORMAT_IN_VPS
    344376  Int*    cfg_repFormatIdx  [MAX_LAYERS];
     
    386418  string    cfg_scaledRefLayerBottomOffset [MAX_LAYERS];
    387419  Int*      cfg_numScaledRefLayerOffsets[MAX_LAYERS];
     420#if REF_REGION_OFFSET
     421  string    cfg_scaledRefLayerOffsetPresentFlag [MAX_LAYERS];
     422  string    cfg_refRegionOffsetPresentFlag      [MAX_LAYERS];
     423  string    cfg_refRegionLeftOffset   [MAX_LAYERS];
     424  string    cfg_refRegionTopOffset    [MAX_LAYERS];
     425  string    cfg_refRegionRightOffset  [MAX_LAYERS];
     426  string    cfg_refRegionBottomOffset [MAX_LAYERS];
     427#endif
     428#if R0209_GENERIC_PHASE
     429  string    cfg_resamplePhaseSetPresentFlag [MAX_LAYERS];
     430  string    cfg_phaseHorLuma   [MAX_LAYERS];
     431  string    cfg_phaseVerLuma   [MAX_LAYERS];
     432  string    cfg_phaseHorChroma [MAX_LAYERS];
     433  string    cfg_phaseVerChroma [MAX_LAYERS];
     434#else
    388435#if P0312_VERT_PHASE_ADJ
    389436  string    cfg_vertPhasePositionEnableFlag[MAX_LAYERS];
     437#endif
    390438#endif
    391439
     
    397445  string*    cfg_scaledRefLayerRightOffsetPtr  [MAX_LAYERS];
    398446  string*    cfg_scaledRefLayerBottomOffsetPtr [MAX_LAYERS];
     447#if REF_REGION_OFFSET
     448  string*    cfg_scaledRefLayerOffsetPresentFlagPtr [MAX_LAYERS];
     449  string*    cfg_refRegionOffsetPresentFlagPtr      [MAX_LAYERS];
     450  string*    cfg_refRegionLeftOffsetPtr   [MAX_LAYERS];
     451  string*    cfg_refRegionTopOffsetPtr    [MAX_LAYERS];
     452  string*    cfg_refRegionRightOffsetPtr  [MAX_LAYERS];
     453  string*    cfg_refRegionBottomOffsetPtr [MAX_LAYERS];
     454#endif
     455#if R0209_GENERIC_PHASE
     456  string*    cfg_resamplePhaseSetPresentFlagPtr [MAX_LAYERS];
     457  string*    cfg_phaseHorLumaPtr   [MAX_LAYERS];
     458  string*    cfg_phaseVerLumaPtr   [MAX_LAYERS];
     459  string*    cfg_phaseHorChromaPtr [MAX_LAYERS];
     460  string*    cfg_phaseVerChromaPtr [MAX_LAYERS];
     461#endif
    399462#if P0312_VERT_PHASE_ADJ
    400463  string*    cfg_vertPhasePositionEnableFlagPtr[MAX_LAYERS];
     
    419482#endif
    420483  Int*    cfg_maxTidIlRefPicsPlus1[MAX_LAYERS];
     484#if Q0074_COLOUR_REMAPPING_SEI
     485  string* cfg_colourRemapSEIFile[MAX_LAYERS];
     486#endif
     487  Int*    cfg_waveFrontSynchro[MAX_LAYERS];
     488
    421489  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
    422490  {
     
    424492    cfg_ReconFile[layer]    = &m_acLayerCfg[layer].m_cReconFile;
    425493    cfg_fQP[layer]          = &m_acLayerCfg[layer].m_fQP;
     494#if Q0074_COLOUR_REMAPPING_SEI
     495    cfg_colourRemapSEIFile[layer] = &m_acLayerCfg[layer].m_colourRemapSEIFile;
     496#endif
    426497#if REPN_FORMAT_IN_VPS
    427498    cfg_repFormatIdx[layer] = &m_acLayerCfg[layer].m_repFormatIdx;
     
    432503    cfg_IntraPeriod[layer]  = &m_acLayerCfg[layer].m_iIntraPeriod;
    433504    cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode;
    434 #if Q0074_SEI_COLOR_MAPPING
    435     cfg_seiColorMappingFile[layer] = &m_acLayerCfg[layer].m_cSeiColorMappingFile;
    436 #endif
    437505#if LAYER_CTB
    438506    // coding unit (CU) definition
     
    457525#endif
    458526    cfg_numScaledRefLayerOffsets [layer] = &m_acLayerCfg[layer].m_numScaledRefLayerOffsets;
     527    cfg_waveFrontSynchro[layer]  = &m_acLayerCfg[layer].m_waveFrontSynchro;
    459528    for(Int i = 0; i < MAX_LAYERS; i++)
    460529    {
     
    468537#if P0312_VERT_PHASE_ADJ
    469538      cfg_vertPhasePositionEnableFlagPtr[layer] = &cfg_vertPhasePositionEnableFlag[layer];
     539#endif
     540#if REF_REGION_OFFSET
     541      cfg_scaledRefLayerOffsetPresentFlagPtr [layer] = &cfg_scaledRefLayerOffsetPresentFlag [layer];
     542      cfg_refRegionOffsetPresentFlagPtr      [layer] = &cfg_refRegionOffsetPresentFlag      [layer];
     543      cfg_refRegionLeftOffsetPtr  [layer] = &cfg_refRegionLeftOffset  [layer];
     544      cfg_refRegionTopOffsetPtr   [layer] = &cfg_refRegionTopOffset   [layer];
     545      cfg_refRegionRightOffsetPtr [layer] = &cfg_refRegionRightOffset [layer];
     546      cfg_refRegionBottomOffsetPtr[layer] = &cfg_refRegionBottomOffset[layer];
     547#endif
     548#if R0209_GENERIC_PHASE
     549      cfg_resamplePhaseSetPresentFlagPtr [layer] = &cfg_resamplePhaseSetPresentFlag [layer];
     550      cfg_phaseHorLumaPtr   [layer] = &cfg_phaseHorLuma   [layer];
     551      cfg_phaseVerLumaPtr   [layer] = &cfg_phaseVerLuma   [layer];
     552      cfg_phaseHorChromaPtr [layer] = &cfg_phaseHorChroma [layer];
     553      cfg_phaseVerChromaPtr [layer] = &cfg_phaseVerChroma [layer];
    470554#endif
    471555    }
     
    507591  }
    508592#endif
     593#if OUTPUT_LAYER_SETS_CONFIG
     594  string* cfg_numLayersInOutputLayerSet = new string;
     595  string* cfg_listOfOutputLayers     = new string[MAX_VPS_OUTPUT_LAYER_SETS_PLUS1];
     596  string* cfg_outputLayerSetIdx      = new string;
     597#endif
    509598#if AVC_BASE
    510599  string  cfg_BLInputFile;
    511 #endif
    512 #if AVC_SYNTAX
    513   string  cfg_BLSyntaxFile;
    514600#endif
    515601#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     
    521607  string cfg_ReconFile;
    522608  string cfg_dQPFile;
     609#if Q0074_COLOUR_REMAPPING_SEI
     610  string cfg_colourRemapSEIFile;
     611#endif
    523612#endif //SVC_EXTENSION
    524   string cfg_ColumnWidth;
    525   string cfg_RowHeight;
     613  string cfgColumnWidth;
     614  string cfgRowHeight;
    526615  string cfg_ScalingListFile;
    527616  string cfg_startOfCodedInterval;
     
    532621  string cfg_kneeSEIOutputKneePointValue;
    533622#endif
     623
    534624  po::Options opts;
    535625  opts.addOptions()
     
    562652  ("NumLayers",               m_numLayers, 1, "Number of layers to code")
    563653#if Q0078_ADD_LAYER_SETS
     654#if OUTPUT_LAYER_SETS_CONFIG
     655  ("NumLayerSets",            m_numLayerSets, 1, "Number of layer sets")
     656#else
    564657  ("NumLayerSets",            m_numLayerSets, 0, "Number of layer sets")
     658#endif
    565659  ("NumLayerInIdList%d",      cfg_numLayerInIdList, 0, MAX_VPS_LAYER_ID_PLUS1, "Number of layers in the set")
    566660  ("LayerSetLayerIdList%d",   cfg_layerSetLayerIdListPtr, string(""), MAX_VPS_LAYER_ID_PLUS1, "Layer IDs for the set")
     
    568662  ("NumHighestLayerIdx%d",    cfg_numHighestLayerIdx, 0, MAX_VPS_LAYER_ID_PLUS1, "Number of highest layer idx")
    569663  ("HighestLayerIdx%d",       cfg_highestLayerIdxPtr, string(""), MAX_VPS_LAYER_ID_PLUS1, "Highest layer idx for an additional layer set")
     664#endif
     665#if OUTPUT_LAYER_SETS_CONFIG
     666  ("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")
     667  ("NumOutputLayerSets",            m_numOutputLayerSets, 1, "Number of output layer sets excluding the 0-th output layer set")
     668  ("NumLayersInOutputLayerSet",   cfg_numLayersInOutputLayerSet, string(""), 1 , "List containing number of output layers in the output layer sets")
     669  ("ListOfOutputLayers%d",          cfg_listOfOutputLayers, string(""), MAX_VPS_LAYER_ID_PLUS1, "Layer IDs for the set, in terms of layer ID in the output layer set Range: [0..NumLayersInOutputLayerSet-1]")
     670  ("OutputLayerSetIdx",            cfg_outputLayerSetIdx, string(""), 1, "Corresponding layer set index, only for non-default output layer sets")
    570671#endif
    571672#if AUXILIARY_PICTURES
     
    602703  ("ScaledRefLayerBottomOffset%d", cfg_scaledRefLayerBottomOffsetPtr,string(""), MAX_LAYERS, "Vertical offset of bottom-right luma sample of scaled base layer picture with respect to"
    603704  " bottom-right luma sample of the EL picture, in units of two luma samples")
     705#if REF_REGION_OFFSET
     706  ("ScaledRefLayerOffsetPresentFlag%d",      cfg_scaledRefLayerOffsetPresentFlagPtr,     string(""), MAX_LAYERS, "presense flag of scaled reference layer offsets")
     707  ("RefRegionOffsetPresentFlag%d",           cfg_refRegionOffsetPresentFlagPtr,          string(""), MAX_LAYERS, "presense flag of reference region offsets")
     708  ("RefRegionLeftOffset%d",   cfg_refRegionLeftOffsetPtr,  string(""), MAX_LAYERS, "Horizontal offset of top-left luma sample of ref region with respect to"
     709                                                                 " top-left luma sample of the BL picture, in units of two luma samples")
     710  ("RefRegionTopOffset%d",    cfg_refRegionTopOffsetPtr,   string(""), MAX_LAYERS,   "Vertical offset of top-left luma sample of ref region with respect to"
     711                                                                 " top-left luma sample of the BL picture, in units of two luma samples")
     712  ("RefRegionRightOffset%d",  cfg_refRegionRightOffsetPtr, string(""), MAX_LAYERS, "Horizontal offset of bottom-right luma sample of ref region with respect to"
     713                                                                 " bottom-right luma sample of the BL picture, in units of two luma samples")
     714  ("RefRegionBottomOffset%d", cfg_refRegionBottomOffsetPtr,string(""), MAX_LAYERS, "Vertical offset of bottom-right luma sample of ref region with respect to"
     715                                                                 " bottom-right luma sample of the BL picture, in units of two luma samples")
     716#endif
     717#if R0209_GENERIC_PHASE
     718  ("ResamplePhaseSetPresentFlag%d",  cfg_resamplePhaseSetPresentFlagPtr, string(""), MAX_LAYERS, "presense flag of resample phase set")
     719  ("PhaseHorLuma%d",   cfg_phaseHorLumaPtr,   string(""), MAX_LAYERS, "luma shift in the horizontal direction used in resampling proces")
     720  ("PhaseVerLuma%d",   cfg_phaseVerLumaPtr,   string(""), MAX_LAYERS, "luma shift in the vertical   direction used in resampling proces")
     721  ("PhaseHorChroma%d", cfg_phaseHorChromaPtr, string(""), MAX_LAYERS, "chroma shift in the horizontal direction used in resampling proces")
     722  ("PhaseVerChroma%d", cfg_phaseVerChromaPtr, string(""), MAX_LAYERS, "chroma shift in the vertical   direction used in resampling proces")
     723#endif
    604724#if P0312_VERT_PHASE_ADJ
    605725  ("VertPhasePositionEnableFlag%d", cfg_vertPhasePositionEnableFlagPtr,string(""), MAX_LAYERS, "VertPhasePositionEnableFlag for layer %d")
     726#endif
     727#if Q0074_COLOUR_REMAPPING_SEI
     728  ("SEIColourRemappingInfoFile%d", cfg_colourRemapSEIFile, string(""), MAX_LAYERS, "Colour Remapping Information SEI parameters file name for layer %d")
    606729#endif
    607730#if O0194_DIFFERENT_BITDEPTH_EL_BL
     
    627750#endif
    628751#if AVC_BASE
     752#if VPS_AVC_BL_FLAG_REMOVAL
     753  ("NonHEVCBase,-nonhevc",            m_nonHEVCBaseLayerFlag,     0, "BL is available but not internal")
     754#else
    629755  ("AvcBase,-avc",            m_avcBaseLayerFlag,     0, "avc_base_layer_flag")
     756#endif
    630757  ("InputBLFile,-ibl",        cfg_BLInputFile,     string(""), "Base layer rec YUV input file name")
    631 #if AVC_SYNTAX
    632   ("InputBLSyntaxFile,-ibs",  cfg_BLSyntaxFile,     string(""), "Base layer syntax input file name")
    633 #endif
    634758#endif
    635759  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)")
    636 #if Q0074_SEI_COLOR_MAPPING
    637   ("SEIColorMappingFile%d", cfg_seiColorMappingFile, string(""), MAX_LAYERS, "File Containing SEI Color Mapping data")
    638 #endif
    639760#else //SVC_EXTENSION
    640761  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
     
    654775  ("ChromaFormatIDC,-cf",   tmpChromaFormat,                             0, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
    655776#endif
    656   ("ConformanceMode",       m_conformanceMode,     0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
    657   ("HorizontalPadding,-pdx",m_aiPad[0],            0, "Horizontal source padding for conformance window mode 2")
    658   ("VerticalPadding,-pdy",  m_aiPad[1],            0, "Vertical source padding for conformance window mode 2")
    659   ("ConfLeft",              m_confLeft,            0, "Left offset for window conformance mode 3")
    660   ("ConfRight",             m_confRight,           0, "Right offset for window conformance mode 3")
    661   ("ConfTop",               m_confTop,             0, "Top offset for window conformance mode 3")
    662   ("ConfBottom",            m_confBottom,          0, "Bottom offset for window conformance mode 3")
     777  ("ConformanceMode",       m_conformanceWindowMode,  0, "Deprecated alias of ConformanceWindowMode")
     778  ("ConformanceWindowMode", m_conformanceWindowMode,  0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
     779  ("HorizontalPadding,-pdx",m_aiPad[0],               0, "Horizontal source padding for conformance window mode 2")
     780  ("VerticalPadding,-pdy",  m_aiPad[1],               0, "Vertical source padding for conformance window mode 2")
     781  ("ConfLeft",              m_confWinLeft,            0, "Deprecated alias of ConfWinLeft")
     782  ("ConfRight",             m_confWinRight,           0, "Deprecated alias of ConfWinRight")
     783  ("ConfTop",               m_confWinTop,             0, "Deprecated alias of ConfWinTop")
     784  ("ConfBottom",            m_confWinBottom,          0, "Deprecated alias of ConfWinBottom")
     785  ("ConfWinLeft",           m_confWinLeft,            0, "Left offset for window conformance mode 3")
     786  ("ConfWinRight",          m_confWinRight,           0, "Right offset for window conformance mode 3")
     787  ("ConfWinTop",            m_confWinTop,             0, "Top offset for window conformance mode 3")
     788  ("ConfWinBottom",         m_confWinBottom,          0, "Bottom offset for window conformance mode 3")
    663789  ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
     790#if Q0074_COLOUR_REMAPPING_SEI
     791  ("SEIColourRemappingInfoFile", cfg_colourRemapSEIFile, string(""), "Colour Remapping Information SEI parameters file name")
     792#endif
    664793#endif //SVC_EXTENSION
    665794  ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
     
    821950  ("WeightedPredB,-wpB",          m_useWeightedBiPred,             false,      "Use weighted (bidirectional) prediction in B slices")
    822951  ("Log2ParallelMergeLevel",      m_log2ParallelMergeLevel,     2u,          "Parallel merge estimation region")
    823   ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,          "Indicates if the column and row boundaries are distributed uniformly")
    824   ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
    825   ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""), "Array containing ColumnWidth values in units of LCU")
    826   ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
    827   ("RowHeightArray",              cfg_RowHeight,                   string(""), "Array containing RowHeight values in units of LCU")
     952
     953  //deprecated copies of renamed tile parameters
     954  ("UniformSpacingIdc",           m_tileUniformSpacingFlag,        false,      "deprecated alias of TileUniformSpacing")
     955  ("ColumnWidthArray",            cfgColumnWidth,                  string(""), "deprecated alias of TileColumnWidthArray")
     956  ("RowHeightArray",              cfgRowHeight,                    string(""), "deprecated alias of TileRowHeightArray")
     957
     958  ("TileUniformSpacing",          m_tileUniformSpacingFlag,        false,      "Indicates that tile columns and rows are distributed uniformly")
     959  ("NumTileColumnsMinus1",        m_numTileColumnsMinus1,          0,          "Number of tile columns in a picture minus 1")
     960  ("NumTileRowsMinus1",           m_numTileRowsMinus1,             0,          "Number of rows in a picture minus 1")
     961  ("TileColumnWidthArray",        cfgColumnWidth,                  string(""), "Array containing tile column width values in units of LCU")
     962  ("TileRowHeightArray",          cfgRowHeight,                    string(""), "Array containing tile row height values in units of LCU")
    828963  ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,          "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
     964#if SVC_EXTENSION
     965  ("WaveFrontSynchro%d",          cfg_waveFrontSynchro,             0,  MAX_LAYERS,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
     966#else
    829967  ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
     968#endif
    830969  ("ScalingList",                 m_useScalingListId,              0,          "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
    831970  ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
     
    8841023  ("ColourDescriptionPresent",       m_colourDescriptionPresentFlag,       false, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present")
    8851024  ("ColourPrimaries",                m_colourPrimaries,                        2, "Indicates chromaticity coordinates of the source primaries")
    886   ("TransferCharateristics",         m_transferCharacteristics,                2, "Indicates the opto-electronic transfer characteristics of the source")
     1025  ("TransferCharacteristics",        m_transferCharacteristics,                2, "Indicates the opto-electronic transfer characteristics of the source")
    8871026  ("MatrixCoefficients",             m_matrixCoefficients,                     2, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries")
    8881027  ("ChromaLocInfoPresent",           m_chromaLocInfoPresentFlag,           false, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present")
     
    10041143  ("CGSMaxYPartNumLog",  m_nCGSMaxYPartNumLog2 , 2, "max Y part number ")
    10051144  ("CGSLUTBit",     m_nCGSLUTBit , 12, "bit depth of CGS LUT")
     1145#if R0151_CGS_3D_ASYMLUT_IMPROVE
     1146  ("CGSAdaptC",     m_nCGSAdaptiveChroma , 1, "adaptive chroma partition (only for the case of two chroma partitions)")
     1147#endif
     1148#if R0179_ENC_OPT_3DLUT_SIZE
     1149  ("CGSSizeRDO",     m_nCGSLutSizeRDO , 0, "RDOpt selection of best table size (effective when large maximum table size such as 8x8x8 is used)")
     1150#endif
    10061151#endif
    10071152#if Q0108_TSA_STSA
     
    10891234#if SVC_EXTENSION
    10901235#if AVC_BASE
     1236#if VPS_AVC_BL_FLAG_REMOVAL
     1237  if( m_nonHEVCBaseLayerFlag )
     1238#else
    10911239  if( m_avcBaseLayerFlag )
     1240#endif
    10921241  {
    10931242    *cfg_InputFile[0] = cfg_BLInputFile;
     
    10951244#endif
    10961245  m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
    1097 #if AVC_SYNTAX
    1098   m_BLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str());
    1099 #endif
    11001246#else //SVC_EXTENSION
    11011247  m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str());
     
    11031249  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
    11041250  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
    1105 #endif //SVC_EXTENSION
    1106 
    1107   Char* pColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
    1108   Char* pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
    1109   if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 )
    1110   {
    1111     char *columnWidth;
     1251#if Q0074_COLOUR_REMAPPING_SEI
     1252  m_colourRemapSEIFile = cfg_colourRemapSEIFile.empty() ? NULL : strdup(cfg_colourRemapSEIFile.c_str());
     1253#endif
     1254#endif //SVC_EXTENSION
     1255
     1256
     1257  Char* pColumnWidth = cfgColumnWidth.empty() ? NULL: strdup(cfgColumnWidth.c_str());
     1258  Char* pRowHeight = cfgRowHeight.empty() ? NULL : strdup(cfgRowHeight.c_str());
     1259
     1260  if( !m_tileUniformSpacingFlag && m_numTileColumnsMinus1 > 0 )
     1261  {
     1262    char *str;
    11121263    int  i=0;
    1113     m_pColumnWidth = new UInt[m_iNumColumnsMinus1];
    1114     columnWidth = strtok(pColumnWidth, " ,-");
    1115     while(columnWidth!=NULL)
    1116     {
    1117       if( i>=m_iNumColumnsMinus1 )
     1264    m_tileColumnWidth.resize( m_numTileColumnsMinus1 );
     1265    str = strtok(pColumnWidth, " ,-");
     1266    while(str!=NULL)
     1267    {
     1268      if( i >= m_numTileColumnsMinus1 )
    11181269      {
    11191270        printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
    11201271        exit( EXIT_FAILURE );
    11211272      }
    1122       *( m_pColumnWidth + i ) = atoi( columnWidth );
    1123       columnWidth = strtok(NULL, " ,-");
     1273      m_tileColumnWidth[i] = atoi( str );
     1274      str = strtok(NULL, " ,-");
    11241275      i++;
    11251276    }
    1126     if( i<m_iNumColumnsMinus1 )
     1277    if( i < m_numTileColumnsMinus1 )
    11271278    {
    11281279      printf( "The width of some columns is not defined.\n" );
     
    11321283  else
    11331284  {
    1134     m_pColumnWidth = NULL;
    1135   }
    1136 
    1137   if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 )
    1138   {
    1139     char *rowHeight;
     1285    m_tileColumnWidth.clear();
     1286  }
     1287
     1288  if( !m_tileUniformSpacingFlag && m_numTileRowsMinus1 > 0 )
     1289  {
     1290    char *str;
    11401291    int  i=0;
    1141     m_pRowHeight = new UInt[m_iNumRowsMinus1];
    1142     rowHeight = strtok(pRowHeight, " ,-");
    1143     while(rowHeight!=NULL)
    1144     {
    1145       if( i>=m_iNumRowsMinus1 )
     1292    m_tileRowHeight.resize(m_numTileRowsMinus1);
     1293    str = strtok(pRowHeight, " ,-");
     1294    while(str!=NULL)
     1295    {
     1296      if( i>=m_numTileRowsMinus1 )
    11461297      {
    11471298        printf( "The number of rows whose height are defined is larger than the allowed number of rows.\n" );
    11481299        exit( EXIT_FAILURE );
    11491300      }
    1150       *( m_pRowHeight + i ) = atoi( rowHeight );
    1151       rowHeight = strtok(NULL, " ,-");
     1301      m_tileRowHeight[i] = atoi( str );
     1302      str = strtok(NULL, " ,-");
    11521303      i++;
    11531304    }
    1154     if( i<m_iNumRowsMinus1 )
     1305    if( i < m_numTileRowsMinus1 )
    11551306    {
    11561307      printf( "The height of some rows is not defined.\n" );
     
    11601311  else
    11611312  {
    1162     m_pRowHeight = NULL;
     1313    m_tileRowHeight.clear();
    11631314  }
    11641315#if SVC_EXTENSION
     1316  if( pColumnWidth )
     1317  {
     1318    free( pColumnWidth );
     1319    pColumnWidth = NULL;
     1320  }
     1321
     1322  if( pRowHeight )
     1323  {
     1324    free( pRowHeight );
     1325    pRowHeight = NULL;
     1326  }
     1327
    11651328  for(Int layer = 0; layer < MAX_LAYERS; layer++)
    11661329  {
     
    11711334      assert( strcmp(cfg_scaledRefLayerId[layer].c_str(),  ""));
    11721335#endif
     1336#if REF_REGION_OFFSET
     1337      Bool srloFlag =
     1338        strcmp(cfg_scaledRefLayerLeftOffset   [layer].c_str(), "") ||
     1339        strcmp(cfg_scaledRefLayerRightOffset  [layer].c_str(), "") ||
     1340        strcmp(cfg_scaledRefLayerTopOffset    [layer].c_str(), "") ||
     1341        strcmp(cfg_scaledRefLayerBottomOffset [layer].c_str(), "");
     1342      Bool rroFlag =
     1343        strcmp(cfg_refRegionLeftOffset   [layer].c_str(), "") ||
     1344        strcmp(cfg_refRegionRightOffset  [layer].c_str(), "") ||
     1345        strcmp(cfg_refRegionTopOffset    [layer].c_str(), "") ||
     1346        strcmp(cfg_refRegionBottomOffset [layer].c_str(), "");
     1347#if R0209_GENERIC_PHASE
     1348      Bool phaseSetFlag =
     1349        strcmp(cfg_phaseHorLuma   [layer].c_str(), "") ||
     1350        strcmp(cfg_phaseVerLuma  [layer].c_str(), "") ||
     1351        strcmp(cfg_phaseHorChroma    [layer].c_str(), "") ||
     1352        strcmp(cfg_phaseVerChroma [layer].c_str(), "");
     1353      assert( srloFlag || rroFlag || phaseSetFlag);
     1354#else
     1355      assert( srloFlag || rroFlag );
     1356#endif
     1357#else
    11731358#if P0312_VERT_PHASE_ADJ
    11741359      assert( strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(),  "") ||
     
    11831368              strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(),"") );
    11841369#endif
     1370#endif
    11851371    }
    11861372
     
    12031389#endif
    12041390
     1391#if REF_REGION_OFFSET
     1392    // Presense Flag //
     1393    if(strcmp(cfg_scaledRefLayerOffsetPresentFlag[layer].c_str(),  ""))
     1394    {
     1395      cfgStringToArray( &tempArray, cfg_scaledRefLayerOffsetPresentFlag[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "ScaledRefLayerOffsetPresentFlag");
     1396      if(tempArray)
     1397      {
     1398        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1399        {
     1400          m_acLayerCfg[layer].m_scaledRefLayerOffsetPresentFlag[i] = tempArray[i];
     1401        }
     1402        delete [] tempArray; tempArray = NULL;
     1403      }
     1404    }
     1405#endif
     1406
    12051407    // Left offset //
    12061408    if(strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(),  ""))
     
    12731475    }
    12741476#endif
    1275   }
     1477#if REF_REGION_OFFSET
     1478    // Presense Flag //
     1479    if(strcmp(cfg_refRegionOffsetPresentFlag[layer].c_str(),  ""))
     1480    {
     1481      cfgStringToArray( &tempArray, cfg_refRegionOffsetPresentFlag[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RefRegionOffsetPresentFlag");
     1482      if(tempArray)
     1483      {
     1484        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1485        {
     1486          m_acLayerCfg[layer].m_refRegionOffsetPresentFlag[i] = tempArray[i];
     1487        }
     1488        delete [] tempArray; tempArray = NULL;
     1489      }
     1490    }
     1491
     1492    // Left offset //
     1493    if(strcmp(cfg_refRegionLeftOffset[layer].c_str(),  ""))
     1494    {
     1495      cfgStringToArray( &tempArray, cfg_refRegionLeftOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RefRegionLeftOffset");
     1496      if(tempArray)
     1497      {
     1498        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1499        {
     1500          m_acLayerCfg[layer].m_refRegionLeftOffset[i] = tempArray[i];
     1501        }
     1502        delete [] tempArray; tempArray = NULL;
     1503      }
     1504    }
     1505
     1506    // Top offset //
     1507    if(strcmp(cfg_refRegionTopOffset[layer].c_str(),  ""))
     1508    {
     1509      cfgStringToArray( &tempArray, cfg_refRegionTopOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RefRegionTopOffset");
     1510      if(tempArray)
     1511      {
     1512        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1513        {
     1514          m_acLayerCfg[layer].m_refRegionTopOffset[i] = tempArray[i];
     1515        }
     1516        delete [] tempArray; tempArray = NULL;
     1517      }
     1518    }
     1519
     1520    // Right offset //
     1521    if(strcmp(cfg_refRegionRightOffset[layer].c_str(),  ""))
     1522    {
     1523      cfgStringToArray( &tempArray, cfg_refRegionRightOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RefRegionRightOffset");
     1524      if(tempArray)
     1525      {
     1526        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1527        {
     1528          m_acLayerCfg[layer].m_refRegionRightOffset[i] = tempArray[i];
     1529        }
     1530        delete [] tempArray; tempArray = NULL;
     1531      }
     1532    }
     1533
     1534    // Bottom offset //
     1535    if(strcmp(cfg_refRegionBottomOffset[layer].c_str(),  ""))
     1536    {
     1537      cfgStringToArray( &tempArray, cfg_refRegionBottomOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RefRegionBottomOffset");
     1538      if(tempArray)
     1539      {
     1540        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1541        {
     1542          m_acLayerCfg[layer].m_refRegionBottomOffset[i] = tempArray[i];
     1543        }
     1544        delete [] tempArray; tempArray = NULL;
     1545      }
     1546    }
     1547#endif
     1548#if R0209_GENERIC_PHASE
     1549    Int numPhaseSet = m_acLayerCfg[layer].m_numScaledRefLayerOffsets;
     1550
     1551    // Presense Flag //
     1552    if(strcmp(cfg_resamplePhaseSetPresentFlag[layer].c_str(),  ""))
     1553    {
     1554      cfgStringToArray( &tempArray, cfg_resamplePhaseSetPresentFlag[layer], numPhaseSet, "resamplePhaseSetPresentFlag");
     1555      if(tempArray)
     1556      {
     1557        for(Int i = 0; i < numPhaseSet; i++)
     1558        {
     1559          m_acLayerCfg[layer].m_resamplePhaseSetPresentFlag[i] = tempArray[i];
     1560        }
     1561        delete [] tempArray; tempArray = NULL;
     1562      }
     1563    }
     1564
     1565    // Luma horizontal phase //
     1566    if(strcmp(cfg_phaseHorLuma[layer].c_str(),  ""))
     1567    {
     1568      cfgStringToArray( &tempArray, cfg_phaseHorLuma[layer], numPhaseSet, "phaseHorLuma");
     1569      if(tempArray)
     1570      {
     1571        for(Int i = 0; i < numPhaseSet; i++)
     1572        {
     1573          m_acLayerCfg[layer].m_phaseHorLuma[i] = tempArray[i];
     1574        }
     1575        delete [] tempArray; tempArray = NULL;
     1576      }
     1577    }
     1578
     1579    // Luma vertical phase //
     1580    if(strcmp(cfg_phaseVerLuma[layer].c_str(),  ""))
     1581    {
     1582      cfgStringToArray( &tempArray, cfg_phaseVerLuma[layer], numPhaseSet, "phaseVerLuma");
     1583      if(tempArray)
     1584      {
     1585        for(Int i = 0; i < numPhaseSet; i++)
     1586        {
     1587          m_acLayerCfg[layer].m_phaseVerLuma[i] = tempArray[i];
     1588        }
     1589        delete [] tempArray; tempArray = NULL;
     1590      }
     1591    }
     1592
     1593    // Chroma horizontal phase //
     1594    if(strcmp(cfg_phaseHorChroma[layer].c_str(),  ""))
     1595    {
     1596      cfgStringToArray( &tempArray, cfg_phaseHorChroma[layer], numPhaseSet, "phaseHorChroma");
     1597      if(tempArray)
     1598      {
     1599        for(Int i = 0; i < numPhaseSet; i++)
     1600        {
     1601          m_acLayerCfg[layer].m_phaseHorChroma[i] = tempArray[i];
     1602        }
     1603        delete [] tempArray; tempArray = NULL;
     1604      }
     1605    }
     1606
     1607    // Chroma vertical phase //
     1608    if(strcmp(cfg_phaseVerChroma[layer].c_str(),  ""))
     1609    {
     1610      cfgStringToArray( &tempArray, cfg_phaseVerChroma[layer], numPhaseSet, "phaseVerChroma");
     1611      if(tempArray)
     1612      {
     1613        for(Int i = 0; i < numPhaseSet; i++)
     1614        {
     1615          m_acLayerCfg[layer].m_phaseVerChroma[i] = tempArray[i];
     1616        }
     1617        delete [] tempArray; tempArray = NULL;
     1618      }
     1619    }
     1620#endif
     1621  }
     1622
    12761623#if VPS_EXTN_DIRECT_REF_LAYERS
    12771624  for(Int layer = 0; layer < MAX_LAYERS; layer++)
     
    13051652      m_acLayerCfg[layer].m_samplePredRefLayerIds = NULL;
    13061653    }
     1654
     1655    if( pSamplePredRefLayerIds )
     1656    {
     1657      free( pSamplePredRefLayerIds );
     1658      pSamplePredRefLayerIds = NULL;
     1659    }
    13071660  }
    13081661  for(Int layer = 0; layer < MAX_LAYERS; layer++)
     
    13361689      m_acLayerCfg[layer].m_motionPredRefLayerIds = NULL;
    13371690    }
     1691
     1692    if( pMotionPredRefLayerIds )
     1693    {
     1694      free( pMotionPredRefLayerIds );
     1695      pMotionPredRefLayerIds = NULL;
     1696    }
    13381697  }
    13391698
     
    13751734      m_acLayerCfg[layer].m_predLayerIds = NULL;
    13761735    }
     1736
     1737    if( pPredLayerIds )
     1738    {
     1739      free( pPredLayerIds );
     1740      pPredLayerIds = NULL;
     1741    }
    13771742  }
    13781743#endif
    13791744#if Q0078_ADD_LAYER_SETS
     1745#if OUTPUT_LAYER_SETS_CONFIG
     1746  for (Int layerSet = 1; layerSet < m_numLayerSets; layerSet++)
     1747  {
     1748    // Simplifying the code in the #else section, and allowing 0-th layer set t
     1749    assert( scanStringToArray( cfg_layerSetLayerIdList[layerSet], m_numLayerInIdList[layerSet], "NumLayerInIdList", m_layerSetLayerIdList[layerSet] ) );
     1750#else
    13801751  for (Int layerSet = 0; layerSet < m_numLayerSets; layerSet++)
    13811752  {
     
    13961767        i++;
    13971768      }
    1398     }
     1769
     1770      if( layerSetLayerIdListDup )
     1771      {
     1772        free( layerSetLayerIdListDup );
     1773        layerSetLayerIdListDup = NULL;
     1774      }
     1775    }
     1776#endif
    13991777  }
    14001778  for (Int addLayerSet = 0; addLayerSet < m_numAddLayerSets; addLayerSet++)
    14011779  {
     1780#if OUTPUT_LAYER_SETS_CONFIG
     1781    // Simplifying the code in the #else section
     1782    assert( scanStringToArray( cfg_layerSetLayerIdList[addLayerSet], m_numLayerInIdList[addLayerSet], "NumLayerInIdList",  m_highestLayerIdx[addLayerSet] ) );
     1783#else
    14021784    if (m_numHighestLayerIdx[addLayerSet] > 0)
    14031785    {
     
    14161798        i++;
    14171799      }
    1418     }
    1419   }
     1800
     1801      if( highestLayrIdxListDup )
     1802      {
     1803        free( highestLayrIdxListDup );
     1804        highestLayrIdxListDup = NULL;
     1805      }
     1806    }
     1807#endif
     1808  }
     1809#endif
     1810#if OUTPUT_LAYER_SETS_CONFIG
     1811  if( m_defaultTargetOutputLayerIdc != -1 )
     1812  {
     1813    assert( m_defaultTargetOutputLayerIdc >= 0 && m_defaultTargetOutputLayerIdc <= 3 );
     1814  }
     1815  assert( m_numOutputLayerSets != 0 );
     1816  assert( m_numOutputLayerSets >= m_numLayerSets + m_numAddLayerSets ); // Number of output layer sets must be at least as many as layer sets.
     1817
     1818  // If output layer Set Idx is specified, only specify it for the non-default output layer sets
     1819  Int numNonDefaultOls = m_numOutputLayerSets - (m_numLayerSets + m_numAddLayerSets);
     1820  if( numNonDefaultOls )
     1821  {
     1822    assert( scanStringToArray( *cfg_outputLayerSetIdx, numNonDefaultOls, "OutputLayerSetIdx", m_outputLayerSetIdx ) );
     1823    for(Int i = 0; i < numNonDefaultOls; i++)
     1824    {
     1825      assert( m_outputLayerSetIdx[i] >= 0 && m_outputLayerSetIdx[i] < (m_numLayerSets + m_numAddLayerSets) );
     1826    }
     1827  }
     1828
     1829  // Number of output layers in output layer sets
     1830  scanStringToArray( *cfg_numLayersInOutputLayerSet, m_numOutputLayerSets - 1, "NumLayersInOutputLayerSets", m_numLayersInOutputLayerSet );
     1831  m_numLayersInOutputLayerSet.insert(m_numLayersInOutputLayerSet.begin(), 1);
     1832  // Layers in the output layer set
     1833  m_listOfOutputLayers.resize(m_numOutputLayerSets);
     1834  Int startOlsCtr = 1;
     1835  if( m_defaultTargetOutputLayerIdc == 0 || m_defaultTargetOutputLayerIdc == 1 )
     1836  {
     1837    // Default output layer sets defined
     1838    startOlsCtr = m_numLayerSets + m_numAddLayerSets;
     1839  }
     1840  for( Int olsCtr = 1; olsCtr < m_numOutputLayerSets; olsCtr++ )
     1841  {
     1842    if( olsCtr < startOlsCtr )
     1843    {
     1844      if(scanStringToArray( cfg_listOfOutputLayers[olsCtr], m_numLayersInOutputLayerSet[olsCtr], "ListOfOutputLayers", m_listOfOutputLayers[olsCtr] ) )
     1845      {
     1846        std::cout << "Default OLS defined. Ignoring ListOfOutputLayers" << olsCtr << endl;
     1847      }
     1848    }
     1849    else
     1850    {
     1851      assert( scanStringToArray( cfg_listOfOutputLayers[olsCtr], m_numLayersInOutputLayerSet[olsCtr], "ListOfOutputLayers", m_listOfOutputLayers[olsCtr] ) );
     1852    }
     1853  }
     1854  delete cfg_numLayersInOutputLayerSet;
     1855  delete [] cfg_listOfOutputLayers;
     1856  delete cfg_outputLayerSetIdx;
    14201857#endif
    14211858#endif //SVC_EXTENSION
     
    14421879#if !SVC_EXTENSION
    14431880  // TODO:ChromaFmt assumes 4:2:0 below
    1444   switch (m_conformanceMode)
     1881  switch (m_conformanceWindowMode)
    14451882  {
    14461883  case 0:
    14471884    {
    14481885      // no conformance or padding
    1449       m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
     1886      m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0;
    14501887      m_aiPad[1] = m_aiPad[0] = 0;
    14511888      break;
     
    14571894      if (m_iSourceWidth % minCuSize)
    14581895      {
    1459         m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
    1460         m_iSourceWidth  += m_confRight;
     1896        m_aiPad[0] = m_confWinRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
     1897        m_iSourceWidth  += m_confWinRight;
    14611898      }
    14621899      if (m_iSourceHeight % minCuSize)
    14631900      {
    1464         m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    1465         m_iSourceHeight += m_confBottom;
     1901        m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
     1902        m_iSourceHeight += m_confWinBottom;
    14661903        if ( m_isField )
    14671904        {
    1468           m_iSourceHeightOrg += m_confBottom << 1;
    1469           m_aiPad[1] = m_confBottom << 1;
     1905          m_iSourceHeightOrg += m_confWinBottom << 1;
     1906          m_aiPad[1] = m_confWinBottom << 1;
    14701907        }
    14711908      }
     
    14871924      m_iSourceWidth  += m_aiPad[0];
    14881925      m_iSourceHeight += m_aiPad[1];
    1489       m_confRight  = m_aiPad[0];
    1490       m_confBottom = m_aiPad[1];
     1926      m_confWinRight  = m_aiPad[0];
     1927      m_confWinBottom = m_aiPad[1];
    14911928      break;
    14921929    }
     
    14941931    {
    14951932      // conformance
    1496       if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
     1933      if ((m_confWinLeft == 0) && (m_confWinRight == 0) && (m_confWinTop == 0) && (m_confWinBottom == 0))
    14971934      {
    14981935        fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n");
     
    16012038      m_targetPivotValue = NULL;
    16022039    }
     2040
     2041    if( pcStartOfCodedInterval )
     2042    {
     2043      free( pcStartOfCodedInterval );
     2044      pcStartOfCodedInterval = NULL;
     2045    }
     2046
     2047    if( pcCodedPivotValue )
     2048    {
     2049      free( pcCodedPivotValue );
     2050      pcCodedPivotValue = NULL;
     2051    }
     2052
     2053    if( pcTargetPivotValue )
     2054    {
     2055      free( pcTargetPivotValue );
     2056      pcTargetPivotValue = NULL;
     2057    }
    16032058  }
    16042059#if P0050_KNEE_FUNCTION_SEI
     
    16262081      i++;
    16272082    }
    1628   }
    1629 #endif
    1630 
     2083
     2084    if( pcInputKneePointValue )
     2085    {
     2086      free( pcInputKneePointValue );
     2087      pcInputKneePointValue = NULL;
     2088    }
     2089
     2090    if( pcOutputKneePointValue )
     2091    {
     2092      free( pcOutputKneePointValue );
     2093      pcOutputKneePointValue = NULL;
     2094    }
     2095  }
     2096#endif
     2097#if Q0074_COLOUR_REMAPPING_SEI
     2098#if !SVC_EXTENSION
     2099  // reading external Colour Remapping Information SEI message parameters from file
     2100  if( m_colourRemapSEIFile.size() > 0 )
     2101  {
     2102    FILE* fic;
     2103    Int retval;
     2104    if((fic = fopen(m_colourRemapSEIFile.c_str(),"r")) == (FILE*)NULL)
     2105    {
     2106      fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", m_colourRemapSEIFile.c_str());
     2107      exit(EXIT_FAILURE);
     2108    }
     2109
     2110    retval = fscanf( fic, "%d", &m_colourRemapSEIId );
     2111    retval = fscanf( fic, "%d", &m_colourRemapSEICancelFlag );
     2112    if( !m_colourRemapSEICancelFlag )
     2113    {
     2114      retval = fscanf( fic, "%d", &m_colourRemapSEIPersistenceFlag );
     2115      retval = fscanf( fic, "%d", &m_colourRemapSEIVideoSignalInfoPresentFlag);
     2116      if( m_colourRemapSEIVideoSignalInfoPresentFlag )
     2117      {
     2118        retval = fscanf( fic, "%d", &m_colourRemapSEIFullRangeFlag  );
     2119        retval = fscanf( fic, "%d", &m_colourRemapSEIPrimaries );
     2120        retval = fscanf( fic, "%d", &m_colourRemapSEITransferFunction );
     2121        retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixCoefficients );
     2122      }
     2123
     2124      retval = fscanf( fic, "%d", &m_colourRemapSEIInputBitDepth );
     2125      retval = fscanf( fic, "%d", &m_colourRemapSEIBitDepth );
     2126 
     2127      for( Int c=0 ; c<3 ; c++ )
     2128      {
     2129        retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutNumValMinus1[c] );
     2130        if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     2131        {
     2132          m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
     2133          m_colourRemapSEIPreLutTargetValue[c] = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
     2134          for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
     2135          {
     2136            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutCodedValue[c][i] );
     2137            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutTargetValue[c][i] );
     2138          }
     2139        }
     2140      }
     2141
     2142      retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixPresentFlag );
     2143      if( m_colourRemapSEIMatrixPresentFlag )
     2144      {
     2145        retval = fscanf( fic, "%d", &m_colourRemapSEILog2MatrixDenom );
     2146        for( Int c=0 ; c<3 ; c++ )
     2147          for( Int i=0 ; i<3 ; i++ )
     2148            retval = fscanf( fic, "%d", &m_colourRemapSEICoeffs[c][i] );
     2149      }
     2150
     2151      for( Int c=0 ; c<3 ; c++ )
     2152      {
     2153        retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutNumValMinus1[c] );
     2154        if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     2155        {
     2156          m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
     2157          m_colourRemapSEIPostLutTargetValue[c] = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
     2158          for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
     2159          {
     2160            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutCodedValue[c][i] );
     2161            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutTargetValue[c][i] );
     2162          }
     2163        }
     2164      }
     2165    }
     2166
     2167    fclose( fic );
     2168    if( retval != 1 )
     2169    {
     2170      fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");
     2171      exit(EXIT_FAILURE);
     2172    }
     2173  }
     2174#else
     2175   // Reading external Colour Remapping Information SEI message parameters from file
     2176  // It seems that TAppEncLayerCfg::parseCfg is not used
     2177  for(UInt layer = 0; layer < m_numLayers; layer++)
     2178  {
     2179    if( cfg_colourRemapSEIFile[layer]->length() )
     2180    {
     2181      FILE* fic;
     2182      Int retval;
     2183      if((fic = fopen(cfg_colourRemapSEIFile[layer]->c_str(),"r")) == (FILE*)NULL)
     2184      {
     2185        fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", cfg_colourRemapSEIFile[layer]->c_str());
     2186        exit(EXIT_FAILURE);
     2187      }
     2188      Int tempCode;
     2189      retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIId );
     2190      retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEICancelFlag = tempCode ? 1 : 0;
     2191      if( !m_acLayerCfg[layer].m_colourRemapSEICancelFlag )
     2192      {
     2193        retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIPersistenceFlag = tempCode ? 1 : 0;
     2194        retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIVideoSignalInfoPresentFlag = tempCode ? 1 : 0;
     2195        if( m_acLayerCfg[layer].m_colourRemapSEIVideoSignalInfoPresentFlag )
     2196        {
     2197          retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIFullRangeFlag = tempCode ? 1 : 0;
     2198          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPrimaries );
     2199          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEITransferFunction );
     2200          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIMatrixCoefficients );
     2201        }
     2202
     2203        retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIInputBitDepth );
     2204        retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIBitDepth );
     2205 
     2206        for( Int c=0 ; c<3 ; c++ )
     2207        {
     2208          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c] );
     2209          if( m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     2210          {
     2211            m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]+1];
     2212            m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue[c] = new Int[m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]+1];
     2213            for( Int i=0 ; i<=m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
     2214            {
     2215              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue[c][i] );
     2216              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue[c][i] );
     2217            }
     2218          }
     2219        }
     2220
     2221        retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag = tempCode ? 1 : 0;
     2222        if( m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag )
     2223        {
     2224          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEILog2MatrixDenom );
     2225          for( Int c=0 ; c<3 ; c++ )
     2226            for( Int i=0 ; i<3 ; i++ )
     2227              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEICoeffs[c][i] );
     2228        }
     2229
     2230        for( Int c=0 ; c<3 ; c++ )
     2231        {
     2232          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c] );
     2233          if( m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     2234          {
     2235            m_acLayerCfg[layer].m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]+1];
     2236            m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue[c] = new Int[m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]+1];
     2237            for( Int i=0 ; i<=m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
     2238            {
     2239              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutCodedValue[c][i] );
     2240              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue[c][i] );
     2241            }
     2242          }
     2243        }
     2244      }
     2245
     2246      fclose( fic );
     2247      if( retval != 1 )
     2248      {
     2249        fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");
     2250        exit(EXIT_FAILURE);
     2251      }
     2252    }
     2253  }
     2254#endif
     2255#endif
    16312256#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    16322257  if (m_interLayerConstrainedTileSetsSEIEnabled)
    16332258  {
    1634     if (m_iNumColumnsMinus1 == 0 && m_iNumRowsMinus1 == 0)
     2259    if (m_numTileColumnsMinus1 == 0 && m_numTileRowsMinus1 == 0)
    16352260    {
    16362261      printf( "Tiles are not defined (needed for inter-layer comnstrained tile sets SEI).\n" );
     
    16712296    }
    16722297    m_skippedTileSetPresentFlag = false;
     2298
     2299    if( pTileSets )
     2300    {
     2301      free( pTileSets );
     2302      pTileSets = NULL;
     2303    }
    16732304  }
    16742305#endif
     
    18372468  }
    18382469 
    1839   Bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
     2470#if !SVC_EXTENSION
     2471  Bool tileFlag = (m_numTileColumnsMinus1 > 0 || m_numTileRowsMinus1 > 0 );
    18402472  xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
    18412473
    18422474  //TODO:ChromaFmt assumes 4:2:0 below
    1843 #if !SVC_EXTENSION
    18442475  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
    18452476  xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
     
    18482479  xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
    18492480
    1850   xConfirmPara( m_confLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
    1851   xConfirmPara( m_confRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
    1852   xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
    1853   xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
     2481  xConfirmPara( m_confWinLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
     2482  xConfirmPara( m_confWinRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
     2483  xConfirmPara( m_confWinTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
     2484  xConfirmPara( m_confWinBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
     2485
     2486  xConfirmPara( m_defaultDisplayWindowFlag && !m_vuiParametersPresentFlag, "VUI needs to be enabled for default display window");
     2487
     2488  if (m_defaultDisplayWindowFlag)
     2489  {
     2490    xConfirmPara( m_defDispWinLeftOffset   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left default display window offset must be an integer multiple of the specified chroma subsampling");
     2491    xConfirmPara( m_defDispWinRightOffset  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right default display window offset must be an integer multiple of the specified chroma subsampling");
     2492    xConfirmPara( m_defDispWinTopOffset    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top default display window offset must be an integer multiple of the specified chroma subsampling");
     2493    xConfirmPara( m_defDispWinBottomOffset % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom default display window offset must be an integer multiple of the specified chroma subsampling");
     2494  }
    18542495#endif
    18552496
     
    19552596 
    19562597  // it can be updated after AVC BL support will be added to the WD
     2598#if VPS_AVC_BL_FLAG_REMOVAL
     2599  if( m_nonHEVCBaseLayerFlag )
     2600#else
    19572601  if( m_avcBaseLayerFlag )
     2602#endif
    19582603  {
    19592604    m_crossLayerIrapAlignFlag = false;
     
    25933238    Int m_uiMaxCUHeight = m_acLayerCfg[layer].m_uiMaxCUHeight;
    25943239#endif
    2595 #endif
     3240
     3241    Bool tileFlag = (m_numTileColumnsMinus1 > 0 || m_numTileRowsMinus1 > 0 );
     3242    Int m_iWaveFrontSynchro = m_acLayerCfg[layer].m_waveFrontSynchro;
     3243    xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
     3244#endif
     3245
    25963246  if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
    25973247  {
     
    26033253      Int widthInCU = (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth/m_uiMaxCUWidth + 1: m_iSourceWidth/m_uiMaxCUWidth;
    26043254      Int heightInCU = (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight/m_uiMaxCUHeight + 1: m_iSourceHeight/m_uiMaxCUHeight;
    2605       if(m_iUniformSpacingIdr)
    2606       {
    2607         maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_iNumColumnsMinus1)/(m_iNumColumnsMinus1+1));
    2608         maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_iNumRowsMinus1)/(m_iNumRowsMinus1+1));
     3255      if(m_tileUniformSpacingFlag)
     3256      {
     3257        maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_numTileColumnsMinus1)/(m_numTileColumnsMinus1+1));
     3258        maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_numTileRowsMinus1)/(m_numTileRowsMinus1+1));
    26093259        // if only the last tile-row is one treeblock higher than the others
    26103260        // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others
    2611         if(!((heightInCU-1)%(m_iNumRowsMinus1+1)))
     3261        if(!((heightInCU-1)%(m_numTileRowsMinus1+1)))
    26123262        {
    26133263          maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight);
     
    26153265        // if only the last tile-column is one treeblock wider than the others
    26163266        // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others   
    2617         if(!((widthInCU-1)%(m_iNumColumnsMinus1+1)))
     3267        if(!((widthInCU-1)%(m_numTileColumnsMinus1+1)))
    26183268        {
    26193269          maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth);
     
    26223272      else // not uniform spacing
    26233273      {
    2624         if(m_iNumColumnsMinus1<1)
     3274        if(m_numTileColumnsMinus1<1)
    26253275        {
    26263276          maxTileWidth = m_iSourceWidth;
     
    26293279        {
    26303280          Int accColumnWidth = 0;
    2631           for(Int col=0; col<(m_iNumColumnsMinus1); col++)
     3281          for(Int col=0; col<(m_numTileColumnsMinus1); col++)
    26323282          {
    2633             maxTileWidth = m_pColumnWidth[col]>maxTileWidth ? m_pColumnWidth[col]:maxTileWidth;
    2634             accColumnWidth += m_pColumnWidth[col];
     3283            maxTileWidth = m_tileColumnWidth[col]>maxTileWidth ? m_tileColumnWidth[col]:maxTileWidth;
     3284            accColumnWidth += m_tileColumnWidth[col];
    26353285          }
    26363286          maxTileWidth = (widthInCU-accColumnWidth)>maxTileWidth ? m_uiMaxCUWidth*(widthInCU-accColumnWidth):m_uiMaxCUWidth*maxTileWidth;
    26373287        }
    2638         if(m_iNumRowsMinus1<1)
     3288        if(m_numTileRowsMinus1<1)
    26393289        {
    26403290          maxTileHeight = m_iSourceHeight;
     
    26433293        {
    26443294          Int accRowHeight = 0;
    2645           for(Int row=0; row<(m_iNumRowsMinus1); row++)
     3295          for(Int row=0; row<(m_numTileRowsMinus1); row++)
    26463296          {
    2647             maxTileHeight = m_pRowHeight[row]>maxTileHeight ? m_pRowHeight[row]:maxTileHeight;
    2648             accRowHeight += m_pRowHeight[row];
     3297            maxTileHeight = m_tileRowHeight[row]>maxTileHeight ? m_tileRowHeight[row]:maxTileHeight;
     3298            accRowHeight += m_tileRowHeight[row];
    26493299          }
    26503300          maxTileHeight = (heightInCU-accRowHeight)>maxTileHeight ? m_uiMaxCUHeight*(heightInCU-accRowHeight):m_uiMaxCUHeight*maxTileHeight;
     
    26703320  }
    26713321#endif
     3322#if !SVC_EXTENSION
    26723323  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
    2673 #if !SVC_EXTENSION
    26743324  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
    26753325  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
     
    27033353  }
    27043354#endif
     3355#if Q0074_COLOUR_REMAPPING_SEI
     3356#if !SVC_EXTENSION
     3357  if ( ( m_colourRemapSEIFile.size() > 0 ) && !m_colourRemapSEICancelFlag )
     3358  {
     3359    xConfirmPara( m_colourRemapSEIInputBitDepth < 8 || m_colourRemapSEIInputBitDepth > 16 , "colour_remap_input_bit_depth shall be in the range of 8 to 16, inclusive");
     3360    xConfirmPara( m_colourRemapSEIBitDepth < 8 || m_colourRemapSEIBitDepth > 16, "colour_remap_bit_depth shall be in the range of 8 to 16, inclusive");
     3361    for( Int c=0 ; c<3 ; c++)
     3362    {
     3363      xConfirmPara( m_colourRemapSEIPreLutNumValMinus1[c] < 0 || m_colourRemapSEIPreLutNumValMinus1[c] > 32, "pre_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
     3364      if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     3365        for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++)
     3366        {
     3367          xConfirmPara( m_colourRemapSEIPreLutCodedValue[c][i] < 0 || m_colourRemapSEIPreLutCodedValue[c][i] > ((1<<m_colourRemapSEIInputBitDepth)-1), "pre_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_input_bit_depth)-1, inclusive");
     3368          xConfirmPara( m_colourRemapSEIPreLutTargetValue[c][i] < 0 || m_colourRemapSEIPreLutTargetValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "pre_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     3369        }
     3370      xConfirmPara( m_colourRemapSEIPostLutNumValMinus1[c] < 0 || m_colourRemapSEIPostLutNumValMinus1[c] > 32, "post_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
     3371      if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     3372        for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++)
     3373        {
     3374          xConfirmPara( m_colourRemapSEIPostLutCodedValue[c][i] < 0 || m_colourRemapSEIPostLutCodedValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "post_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     3375          xConfirmPara( m_colourRemapSEIPostLutTargetValue[c][i] < 0 || m_colourRemapSEIPostLutTargetValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "post_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     3376        }
     3377    }
     3378    if ( m_colourRemapSEIMatrixPresentFlag )
     3379    {
     3380      xConfirmPara( m_colourRemapSEILog2MatrixDenom < 0 || m_colourRemapSEILog2MatrixDenom > 15, "log2_matrix_denom shall be in the range of 0 to 15, inclusive");
     3381      for( Int c=0 ; c<3 ; c++)
     3382        for( Int i=0 ; i<3 ; i++)
     3383          xConfirmPara( m_colourRemapSEICoeffs[c][i] < -32768 || m_colourRemapSEICoeffs[c][i] > 32767, "colour_remap_coeffs[c][i] shall be in the range of -32768 and 32767, inclusive");
     3384    }
     3385  }
     3386#endif
     3387#endif
    27053388
    27063389#if RC_SHVC_HARMONIZATION
     
    29093592  printf("Scalable                      : %d\n", m_scalabilityMask[SCALABILITY_ID] );
    29103593#if AVC_BASE
     3594#if VPS_AVC_BL_FLAG_REMOVAL
     3595  printf("Base layer                    : %s\n", m_nonHEVCBaseLayerFlag ? "Non-HEVC" : "HEVC");
     3596#else
    29113597  printf("Base layer                    : %s\n", m_avcBaseLayerFlag ? "AVC" : "HEVC");
     3598#endif
    29123599#endif
    29133600#if AUXILIARY_PICTURES
     
    29333620  {
    29343621    printf("=== Layer %d settings === \n", layer);
    2935 #if AVC_SYNTAX
    2936     m_acLayerCfg[layer].xPrintParameter( layer );
    2937 #else
    29383622    m_acLayerCfg[layer].xPrintParameter();
    2939 #endif
    29403623    printf("\n");
    29413624  }
    29423625  printf("=== Common configuration settings === \n");
    29433626  printf("Bitstream      File          : %s\n", m_pBitstreamFile      );
    2944 #else
     3627#else //SVC_EXTENSION
    29453628  printf("Input          File          : %s\n", m_pchInputFile          );
    29463629  printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
    29473630  printf("Reconstruction File          : %s\n", m_pchReconFile          );
    2948   printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
     3631  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, m_iFrameRate );
    29493632  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
    2950 #endif
     3633#endif //SVC_EXTENSION
    29513634  if (m_isField)
    29523635  {
     
    30843767  printf("CGS: %d CGSMaxOctantDepth: %d CGSMaxYPartNumLog2: %d CGSLUTBit:%d " , m_nCGSFlag , m_nCGSMaxOctantDepth , m_nCGSMaxYPartNumLog2 , m_nCGSLUTBit );
    30853768#endif
     3769#if R0151_CGS_3D_ASYMLUT_IMPROVE
     3770  printf("CGSAdaptC:%d " , m_nCGSAdaptiveChroma );
     3771#endif
     3772#if R0179_ENC_OPT_3DLUT_SIZE
     3773  printf("CGSSizeRDO:%d " , m_nCGSLutSizeRDO );
     3774#endif
     3775
    30863776  printf("\n\n");
    30873777 
     
    30993789
    31003790#if SVC_EXTENSION
     3791#if OUTPUT_LAYER_SETS_CONFIG
     3792Void TAppEncCfg::cfgStringToArray(Int **arr, string const cfgString, Int const numEntries, const char* logString)
     3793#else
    31013794Void TAppEncCfg::cfgStringToArray(Int **arr, string cfgString, Int numEntries, const char* logString)
     3795#endif
    31023796{
    31033797  Char *tempChar = cfgString.empty() ? NULL : strdup(cfgString.c_str());
     
    31083802    *arr = new Int[numEntries];
    31093803
     3804#if OUTPUT_LAYER_SETS_CONFIG
     3805    if( tempChar == NULL )
     3806    {
     3807      arrayEntry = NULL;
     3808    }
     3809    else
     3810    {
     3811      arrayEntry = strtok( tempChar, " ,");
     3812    }
     3813#else
    31103814    arrayEntry = strtok( tempChar, " ,");
     3815#endif
    31113816    while(arrayEntry != NULL)
    31123817    {
     
    31303835    *arr = NULL;
    31313836  }
     3837
     3838  if( tempChar )
     3839  {
     3840    free( tempChar );
     3841    tempChar = NULL;
     3842  }
    31323843}
    31333844
     3845#if OUTPUT_LAYER_SETS_CONFIG
     3846Bool TAppEncCfg::scanStringToArray(string const cfgString, Int const numEntries, const char* logString, Int * const returnArray)
     3847{
     3848  Int *tempArray = NULL;
     3849  // For all layer sets
     3850  cfgStringToArray( &tempArray, cfgString, numEntries, logString );
     3851  if(tempArray)
     3852  {
     3853    for(Int i = 0; i < numEntries; i++)
     3854    {
     3855      returnArray[i] = tempArray[i];
     3856    }
     3857    delete [] tempArray; tempArray = NULL;
     3858    return true;
     3859  }
     3860  return false;
     3861}
     3862Bool TAppEncCfg::scanStringToArray(string const cfgString, Int const numEntries, const char* logString, std::vector<Int> & returnVector)
     3863{
     3864  Int *tempArray = NULL;
     3865  // For all layer sets
     3866  cfgStringToArray( &tempArray, cfgString, numEntries, logString );
     3867  if(tempArray)
     3868  {
     3869    returnVector.empty();
     3870    for(Int i = 0; i < numEntries; i++)
     3871    {
     3872      returnVector.push_back(tempArray[i]);
     3873    }
     3874    delete [] tempArray; tempArray = NULL;
     3875    return true;
     3876  }
     3877  return false;
     3878}
     3879#endif
    31343880#endif //SVC_EXTENSION
    31353881//! \}
  • trunk/source/App/TAppEncoder/TAppEncCfg.h

    r815 r906  
    4646#endif
    4747#include <sstream>
     48#include <vector>
    4849//! \ingroup TAppEncoder
    4950//! \{
     
    6869  Int       m_framesToBeEncoded;                              ///< number of encoded frames
    6970#if AVC_BASE
     71#if VPS_AVC_BL_FLAG_REMOVAL
     72  Int       m_nonHEVCBaseLayerFlag;                           ///< non HEVC BL
     73#else
    7074  Int       m_avcBaseLayerFlag;                               ///< avc_baselayer_flag
    7175#endif
    72 #if AVC_SYNTAX
    73   Char*     m_BLSyntaxFile;                                   ///< input syntax file
    7476#endif
    7577  Bool      m_maxTidRefPresentFlag;
     
    8183  Int       m_numHighestLayerIdx[MAX_VPS_LAYER_SETS_PLUS1];
    8284  Int       m_highestLayerIdx[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
     85#endif
     86#if OUTPUT_LAYER_SETS_CONFIG
     87  std::vector<Int>                m_outputLayerSetIdx;
     88  Int       m_defaultTargetOutputLayerIdc;
     89  Int       m_numOutputLayerSets;
     90  std::vector<Int>                m_numLayersInOutputLayerSet;
     91  std::vector< std::vector<Int> > m_listOfOutputLayers;
    8392#endif
    8493#else
     
    96105 
    97106 
    98   Int       m_conformanceMode;
    99   Int       m_confLeft;
    100   Int       m_confRight;
    101   Int       m_confTop;
    102   Int       m_confBottom;
     107  Int       m_conformanceWindowMode;
     108  Int       m_confWinLeft;
     109  Int       m_confWinRight;
     110  Int       m_confWinTop;
     111  Int       m_confWinBottom;
    103112  Int       m_framesToBeEncoded;                              ///< number of encoded frames
    104113  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
     
    222231  Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
    223232  Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
    224   Int      m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty)
     233  Int       m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty)
    225234  Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
    226235  Int       m_iSearchRange;                                   ///< ME search range
     
    243252  Bool      m_bLFCrossSliceBoundaryFlag;  ///< 1: filter across slice boundaries 0: do not filter across slice boundaries
    244253  Bool      m_bLFCrossTileBoundaryFlag;   ///< 1: filter across tile boundaries  0: do not filter across tile boundaries
    245   Int       m_iUniformSpacingIdr;
    246   Int       m_iNumColumnsMinus1;
    247   Char*     m_pchColumnWidth;
    248   Int       m_iNumRowsMinus1;
    249   Char*     m_pchRowHeight;
    250   UInt*     m_pColumnWidth;
    251   UInt*     m_pRowHeight;
     254  Bool      m_tileUniformSpacingFlag;
     255  Int       m_numTileColumnsMinus1;
     256  Int       m_numTileRowsMinus1;
     257  std::vector<Int> m_tileColumnWidth;
     258  std::vector<Int> m_tileRowHeight;
     259#if !SVC_EXTENSION
    252260  Int       m_iWaveFrontSynchro; //< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
    253 #if !SVC_EXTENSION
    254261  Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
    255262#endif
    256 
    257263  Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
    258  
    259264  Int       m_decodedPictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
    260265  Int       m_recoveryPointSEIEnabled;
     
    288293  Int*      m_codedPivotValue;
    289294  Int*      m_targetPivotValue;
    290 #if Q0074_SEI_COLOR_MAPPING
    291   Char*     m_pchSEIColorMappingFile;             ///< SEI Color Mapping File (initialized from external file)
    292 #endif
    293295  Int       m_framePackingSEIEnabled;
    294296  Int       m_framePackingSEIType;
     
    377379  Int       m_elRapSliceBEnabled;
    378380#endif
     381#if Q0074_COLOUR_REMAPPING_SEI
     382#if !SVC_EXTENSION
     383  string    m_colourRemapSEIFile;
     384  Int       m_colourRemapSEIId;
     385  Bool      m_colourRemapSEICancelFlag;
     386  Bool      m_colourRemapSEIPersistenceFlag;
     387  Bool      m_colourRemapSEIVideoSignalInfoPresentFlag;
     388  Bool      m_colourRemapSEIFullRangeFlag;
     389  Int       m_colourRemapSEIPrimaries;
     390  Int       m_colourRemapSEITransferFunction;
     391  Int       m_colourRemapSEIMatrixCoefficients;
     392  Int       m_colourRemapSEIInputBitDepth;
     393  Int       m_colourRemapSEIBitDepth;
     394  Int       m_colourRemapSEIPreLutNumValMinus1[3];
     395  Int*      m_colourRemapSEIPreLutCodedValue[3];
     396  Int*      m_colourRemapSEIPreLutTargetValue[3];
     397  Bool      m_colourRemapSEIMatrixPresentFlag;
     398  Int       m_colourRemapSEILog2MatrixDenom;
     399  Int       m_colourRemapSEICoeffs[3][3];
     400  Int       m_colourRemapSEIPostLutNumValMinus1[3];
     401  Int*      m_colourRemapSEIPostLutCodedValue[3];
     402  Int*      m_colourRemapSEIPostLutTargetValue[3];
     403#endif
     404#endif
    379405  // internal member functions
    380406#if LAYER_CTB
     
    439465  Int  m_nCGSMaxYPartNumLog2;
    440466  Int  m_nCGSLUTBit;
    441 #endif
     467#if R0151_CGS_3D_ASYMLUT_IMPROVE
     468  Int  m_nCGSAdaptiveChroma;
     469#endif
     470#if R0179_ENC_OPT_3DLUT_SIZE
     471  Int  m_nCGSLutSizeRDO;
     472#endif
     473#endif
    442474#endif //SVC_EXTENSION
    443475public:
     
    468500#endif
    469501  Int  getDecodingRefreshType()    {return m_iDecodingRefreshType; }
    470   Int  getWaveFrontSynchro()        { return m_iWaveFrontSynchro; }
     502  Int  getWaveFrontSynchro(Int layerId)        { return m_acLayerCfg[layerId].m_waveFrontSynchro; }
    471503  Void getDirFilename(string& filename, string& dir, const string path);
    472 #if AVC_SYNTAX
    473   Char* getBLSyntaxFile()           { return m_BLSyntaxFile;      }
    474 #endif
     504#if OUTPUT_LAYER_SETS_CONFIG
     505  Bool scanStringToArray(string const cfgString, Int const numEntries, const char* logString, Int * const returnArray);
     506  Bool scanStringToArray(string const cfgString, Int const numEntries, const char* logString, std::vector<Int> &  returnVector);
     507  Void cfgStringToArray(Int **arr, string const cfgString, Int const numEntries, const char* logString);
     508#else
    475509  Void cfgStringToArray(Int **arr, string cfgString, Int numEntries, const char* logString);
     510#endif
    476511#if REPN_FORMAT_IN_VPS
    477512  RepFormatCfg* getRepFormatCfg(Int i)  { return &m_repFormatCfg[i]; }
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp

    r713 r906  
    4949, m_repFormatIdx (-1)
    5050#endif
    51 {
    52   m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
     51#if Q0074_COLOUR_REMAPPING_SEI
     52,  m_colourRemapSEIFile(string(""))
     53#endif
     54{
     55#if Q0074_COLOUR_REMAPPING_SEI
     56  for( Int c=0 ; c<3 ; c++)
     57  {
     58    m_colourRemapSEIPreLutCodedValue[c]   = NULL;
     59    m_colourRemapSEIPreLutTargetValue[c]  = NULL;
     60    m_colourRemapSEIPostLutCodedValue[c]  = NULL;
     61    m_colourRemapSEIPostLutTargetValue[c] = NULL;
     62  }
     63#endif
     64  m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0;
    5365  m_aiPad[1] = m_aiPad[0] = 0;
    5466  m_numScaledRefLayerOffsets = 0;
     
    6072  ::memset(m_scaledRefLayerRightOffset,  0, sizeof(m_scaledRefLayerRightOffset));
    6173  ::memset(m_scaledRefLayerBottomOffset, 0, sizeof(m_scaledRefLayerBottomOffset));
     74#if REF_REGION_OFFSET
     75  ::memset(m_scaledRefLayerOffsetPresentFlag, 0, sizeof(m_scaledRefLayerOffsetPresentFlag));
     76  ::memset(m_refRegionOffsetPresentFlag, 0, sizeof(m_refRegionOffsetPresentFlag));
     77  ::memset(m_refRegionLeftOffset,   0, sizeof(m_refRegionLeftOffset));
     78  ::memset(m_refRegionTopOffset,    0, sizeof(m_refRegionTopOffset));
     79  ::memset(m_refRegionRightOffset,  0, sizeof(m_refRegionRightOffset));
     80  ::memset(m_refRegionBottomOffset, 0, sizeof(m_refRegionBottomOffset));
     81#endif
     82#if R0209_GENERIC_PHASE
     83  ::memset(m_resamplePhaseSetPresentFlag, 0, sizeof(m_resamplePhaseSetPresentFlag));
     84  ::memset(m_phaseHorLuma,   0, sizeof(m_phaseHorLuma));
     85  ::memset(m_phaseVerLuma,   0, sizeof(m_phaseVerLuma));
     86  ::memset(m_phaseHorChroma, 0, sizeof(m_phaseHorChroma));
     87  ::memset(m_phaseVerChroma, 0, sizeof(m_phaseVerChroma));
     88#else
    6289#if P0312_VERT_PHASE_ADJ
    6390  ::memset(m_vertPhasePositionEnableFlag, 0, sizeof(m_vertPhasePositionEnableFlag));
    6491#endif
     92#endif
    6593}
    6694
     
    7199    delete[] m_aidQP;
    72100  }
     101#if Q0074_COLOUR_REMAPPING_SEI
     102  for( Int c=0 ; c<3 ; c++)
     103  {
     104    if ( m_colourRemapSEIPreLutCodedValue[c] )
     105    {
     106      delete[] m_colourRemapSEIPreLutCodedValue[c];
     107    }
     108    if ( m_colourRemapSEIPreLutTargetValue[c] )
     109    {
     110      delete[] m_colourRemapSEIPreLutTargetValue[c];
     111    }
     112    if ( m_colourRemapSEIPostLutCodedValue[c] )
     113    {
     114      delete[] m_colourRemapSEIPostLutCodedValue[c];
     115    }
     116    if ( m_colourRemapSEIPostLutTargetValue[c] )
     117    {
     118      delete[] m_colourRemapSEIPostLutTargetValue[c];
     119    }
     120  }
     121#endif
    73122}
    74123
     
    98147  Int tmpInputChromaFormat;
    99148  Int tmpChromaFormat;
     149#endif
     150#if Q0074_COLOUR_REMAPPING_SEI
     151  string  cfg_colourRemapSEIFile;
    100152#endif
    101153
     
    114166    ("ChromaFormatIDC",       tmpChromaFormat,    420, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
    115167#endif
    116     ("CropLeft",              m_confLeft,      0, "Left cropping/padding for cropping mode 3")
    117     ("CropRight",             m_confRight,     0, "Right cropping/padding for cropping mode 3")
    118     ("CropTop",               m_confTop,       0, "Top cropping/padding for cropping mode 3")
    119     ("CropBottom",            m_confBottom,    0, "Bottom cropping/padding for cropping mode 3")
     168    ("ConfLeft",              m_confWinLeft,            0, "Deprecated alias of ConfWinLeft")
     169    ("ConfRight",             m_confWinRight,           0, "Deprecated alias of ConfWinRight")
     170    ("ConfTop",               m_confWinTop,             0, "Deprecated alias of ConfWinTop")
     171    ("ConfBottom",            m_confWinBottom,          0, "Deprecated alias of ConfWinBottom")
     172    ("ConfWinLeft",           m_confWinLeft,            0, "Left offset for window conformance mode 3")
     173    ("ConfWinRight",          m_confWinRight,           0, "Right offset for window conformance mode 3")
     174    ("ConfWinTop",            m_confWinTop,             0, "Top offset for window conformance mode 3")
     175    ("ConfWinBottom",         m_confWinBottom,          0, "Bottom offset for window conformance mode 3")
    120176    ("HorizontalPadding,-pdx",m_aiPad[0],      0, "horizontal source padding for cropping mode 2")
    121177    ("VerticalPadding,-pdy",  m_aiPad[1],      0, "vertical source padding for cropping mode 2")
     
    124180    ("dQPFile,m",             cfg_dQPFile, string(""), "dQP file name")
    125181    ("QP,q",                  m_fQP,          30.0, "Qp value, if value is float, QP is switched once during encoding")
    126     ;
     182#if Q0074_COLOUR_REMAPPING_SEI
     183    ("SEIColourRemappingInfoFile", cfg_colourRemapSEIFile, string(""), "Colour Remapping Information SEI parameters file name")
     184#endif
     185  ;
    127186
    128187  po::setDefaults(opts);
     
    136195  m_chromaFormatIDC   = ((tmpChromaFormat == 0) ? (m_InputChromaFormat) : (numberToChromaFormat(tmpChromaFormat)));
    137196#endif
     197#if Q0074_COLOUR_REMAPPING_SEI
     198  m_colourRemapSEIFile = cfg_colourRemapSEIFile.empty() ? NULL : strdup(cfg_colourRemapSEIFile.c_str());
     199#endif
    138200
    139201  // reading external dQP description from file
     
    154216    }
    155217  }
     218
     219#if Q0074_COLOUR_REMAPPING_SEI
     220  if( m_colourRemapSEIFile.size() > 0 )
     221  {
     222    FILE* fic;
     223    Int retval;
     224    if((fic = fopen(m_colourRemapSEIFile.c_str(),"r")) == (FILE*)NULL)
     225    {
     226      fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", m_colourRemapSEIFile.c_str());
     227      exit(EXIT_FAILURE);
     228    }
     229
     230    Int tempCode;
     231    retval = fscanf( fic, "%d", &m_colourRemapSEIId );
     232    retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEICancelFlag = tempCode ? 1 : 0;
     233    if( !m_colourRemapSEICancelFlag )
     234    {
     235      retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEIPersistenceFlag = tempCode ? 1 : 0;
     236      retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEIVideoSignalInfoPresentFlag = tempCode ? 1 : 0;
     237      if( m_colourRemapSEIVideoSignalInfoPresentFlag )
     238      {
     239        retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEIFullRangeFlag = tempCode ? 1 : 0;
     240        retval = fscanf( fic, "%d", &m_colourRemapSEIPrimaries );
     241        retval = fscanf( fic, "%d", &m_colourRemapSEITransferFunction );
     242        retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixCoefficients );
     243      }
     244
     245      retval = fscanf( fic, "%d", &m_colourRemapSEIInputBitDepth );
     246      retval = fscanf( fic, "%d", &m_colourRemapSEIBitDepth );
     247 
     248      for( Int c=0 ; c<3 ; c++ )
     249      {
     250        retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutNumValMinus1[c] );
     251        if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     252        {
     253          m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
     254          m_colourRemapSEIPreLutTargetValue[c] = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
     255          for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
     256          {
     257            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutCodedValue[c][i] );
     258            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutTargetValue[c][i] );
     259          }
     260        }
     261      }
     262
     263      retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEIMatrixPresentFlag = tempCode ? 1 : 0;
     264      if( m_colourRemapSEIMatrixPresentFlag )
     265      {
     266        retval = fscanf( fic, "%d", &m_colourRemapSEILog2MatrixDenom );
     267        for( Int c=0 ; c<3 ; c++ )
     268          for( Int i=0 ; i<3 ; i++ )
     269            retval = fscanf( fic, "%d", &m_colourRemapSEICoeffs[c][i] );
     270      }
     271
     272      for( Int c=0 ; c<3 ; c++ )
     273      {
     274        retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutNumValMinus1[c] );
     275        if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     276        {
     277          m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
     278          m_colourRemapSEIPostLutTargetValue[c] = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
     279          for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
     280          {
     281            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutCodedValue[c][i] );
     282            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutTargetValue[c][i] );
     283          }
     284        }
     285      }
     286    }
     287
     288    fclose( fic );
     289    if( retval != 1 )
     290    {
     291      fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");
     292      exit(EXIT_FAILURE);
     293    }
     294  }
     295#endif
     296
    156297  return true;
    157298}
    158299
    159 #if AVC_SYNTAX
    160 Void TAppEncLayerCfg::xPrintParameter( UInt layerId )
    161 #else
    162300Void TAppEncLayerCfg::xPrintParameter()
    163 #endif
    164301{
    165302  printf("Input File                    : %s\n", m_cInputFile.c_str()  );
    166303  printf("Reconstruction File           : %s\n", m_cReconFile.c_str()  );
    167 #if AVC_SYNTAX
    168   if( layerId == 0 )
    169   {
    170     printf("Base layer syntax file        : %s\n", m_cAppEncCfg->getBLSyntaxFile() );
    171   }
    172 #endif
    173304#if REPN_FORMAT_IN_VPS
    174   printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - ( m_confLeft + m_confRight ) * TComSPS::getWinUnitX( m_chromaFormatIDC ), m_iSourceHeight - ( m_confTop + m_confBottom ) * TComSPS::getWinUnitY( m_chromaFormatIDC ), m_iFrameRate );
     305  printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - ( m_confWinLeft + m_confWinRight ) * TComSPS::getWinUnitX( m_chromaFormatIDC ), m_iSourceHeight - ( m_confWinTop + m_confWinBottom ) * TComSPS::getWinUnitY( m_chromaFormatIDC ), m_iFrameRate );
    175306#else
    176   printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
     307  printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, m_iFrameRate );
    177308#endif
    178309  printf("Internal Format               : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
     
    202333  }
    203334#endif
    204   printf("WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_cAppEncCfg->getWaveFrontSynchro(), m_iWaveFrontSubstreams);
     335  printf("WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_waveFrontSynchro, m_iWaveFrontSubstreams);
    205336#if LAYER_CTB
    206337  printf("PCM:%d ", (m_cAppEncCfg->getUsePCM() && (1<<m_cAppEncCfg->getPCMLog2MinSize()) <= m_uiMaxCUWidth)? 1 : 0);
     
    217348    {
    218349      // no cropping or padding
    219       m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
     350      m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0;
    220351      m_aiPad[1] = m_aiPad[0] = 0;
    221352      break;
     
    231362      if (m_iSourceWidth % minCuSize)
    232363      {
    233         m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
    234         m_iSourceWidth  += m_confRight;
     364        m_aiPad[0] = m_confWinRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
     365        m_iSourceWidth  += m_confWinRight;
    235366#if REPN_FORMAT_IN_VPS
    236         m_confRight /= TComSPS::getWinUnitX( m_chromaFormatIDC );
     367        m_confWinRight /= TComSPS::getWinUnitX( m_chromaFormatIDC );
    237368#endif
    238369      }
    239370      if (m_iSourceHeight % minCuSize)
    240371      {
    241         m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    242         m_iSourceHeight += m_confBottom;
     372        m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
     373        m_iSourceHeight += m_confWinBottom;
    243374        if ( isField )
    244375        {
    245           m_iSourceHeightOrg += m_confBottom << 1;
    246           m_aiPad[1] = m_confBottom << 1;
     376          m_iSourceHeightOrg += m_confWinBottom << 1;
     377          m_aiPad[1] = m_confWinBottom << 1;
    247378        }
    248379#if REPN_FORMAT_IN_VPS
    249         m_confBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC );
     380        m_confWinBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC );
    250381#endif
    251382      }
     
    257388      m_iSourceWidth  += m_aiPad[0];
    258389      m_iSourceHeight += m_aiPad[1];
    259       m_confRight  = m_aiPad[0];
    260       m_confBottom = m_aiPad[1];
     390      m_confWinRight  = m_aiPad[0];
     391      m_confWinBottom = m_aiPad[1];
    261392#if REPN_FORMAT_IN_VPS
    262       m_confRight /= TComSPS::getWinUnitX( m_chromaFormatIDC );
    263       m_confBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC );
     393      m_confWinRight /= TComSPS::getWinUnitX( m_chromaFormatIDC );
     394      m_confWinBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC );
    264395#endif
    265396      break;
     
    268399    {
    269400      // conformance
    270       if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
     401      if ((m_confWinLeft == 0) && (m_confWinRight == 0) && (m_confWinTop == 0) && (m_confWinBottom == 0))
    271402      {
    272403        fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n");
     
    333464#endif
    334465
    335 
    336   m_iWaveFrontSubstreams = m_cAppEncCfg->getWaveFrontSynchro() ? (m_iSourceHeight + maxCUHeight - 1) / maxCUHeight : 1;
     466  m_iWaveFrontSubstreams = m_waveFrontSynchro ? (m_iSourceHeight + maxCUHeight - 1) / maxCUHeight : 1;
     467  xConfirmPara( m_waveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
    337468  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
    338   xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_cAppEncCfg->getWaveFrontSynchro(), "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
     469  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_waveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
    339470
    340471  //chekc parameters
     
    386517  }
    387518#endif
     519#if Q0074_COLOUR_REMAPPING_SEI
     520  if ( ( m_colourRemapSEIFile.size() > 0 ) && !m_colourRemapSEICancelFlag )
     521  {
     522    xConfirmPara( m_colourRemapSEIInputBitDepth < 8 || m_colourRemapSEIInputBitDepth > 16 , "colour_remap_input_bit_depth shall be in the range of 8 to 16, inclusive");
     523    xConfirmPara( m_colourRemapSEIBitDepth < 8 || m_colourRemapSEIBitDepth > 16, "colour_remap_bit_depth shall be in the range of 8 to 16, inclusive");
     524    for( Int c=0 ; c<3 ; c++)
     525    {
     526      xConfirmPara( m_colourRemapSEIPreLutNumValMinus1[c] < 0 || m_colourRemapSEIPreLutNumValMinus1[c] > 32, "pre_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
     527      if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     528        for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++)
     529        {
     530          xConfirmPara( m_colourRemapSEIPreLutCodedValue[c][i] < 0 || m_colourRemapSEIPreLutCodedValue[c][i] > ((1<<m_colourRemapSEIInputBitDepth)-1), "pre_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_input_bit_depth)-1, inclusive");
     531          xConfirmPara( m_colourRemapSEIPreLutTargetValue[c][i] < 0 || m_colourRemapSEIPreLutTargetValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "pre_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     532        }
     533      xConfirmPara( m_colourRemapSEIPostLutNumValMinus1[c] < 0 || m_colourRemapSEIPostLutNumValMinus1[c] > 32, "post_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
     534      if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     535        for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++)
     536        {
     537          xConfirmPara( m_colourRemapSEIPostLutCodedValue[c][i] < 0 || m_colourRemapSEIPostLutCodedValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "post_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     538          xConfirmPara( m_colourRemapSEIPostLutTargetValue[c][i] < 0 || m_colourRemapSEIPostLutTargetValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "post_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     539        }
     540    }
     541    if( m_colourRemapSEIMatrixPresentFlag )
     542    {
     543      xConfirmPara( m_colourRemapSEILog2MatrixDenom < 0 || m_colourRemapSEILog2MatrixDenom > 15, "log2_matrix_denom shall be in the range of 0 to 15, inclusive");
     544      for( Int c=0 ; c<3 ; c++)
     545        for( Int i=0 ; i<3 ; i++)
     546          xConfirmPara( m_colourRemapSEICoeffs[c][i] < -32768 || m_colourRemapSEICoeffs[c][i] > 32767, "colour_remap_coeffs[c][i] shall be in the range of -32768 and 32767, inclusive");
     547    }
     548  }
     549#endif
    388550
    389551#undef xConfirmPara
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.h

    r815 r906  
    3535  Int       m_iSourceHeightOrg;                               ///< original source height in pixel (when interlaced = frame height)
    3636  Int       m_conformanceMode;
    37   Int       m_confLeft;
    38   Int       m_confRight;
    39   Int       m_confTop;
    40   Int       m_confBottom;
     37  Int       m_confWinLeft;
     38  Int       m_confWinRight;
     39  Int       m_confWinTop;
     40  Int       m_confWinBottom;
    4141  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
    4242  Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
     
    5454  Int       *m_predLayerIds;
    5555  Int       m_numActiveRefLayers;
    56 #endif
    57 #if Q0074_SEI_COLOR_MAPPING
    58   string    m_cSeiColorMappingFile;
    5956#endif
    6057
     
    8481
    8582  Int       m_maxTidIlRefPicsPlus1;
    86   Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
     83  Int       m_waveFrontSynchro;                   ///< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
     84  Int       m_iWaveFrontSubstreams;               ///< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
    8785
    8886  Int       m_iQP;                                            ///< QP value of key-picture (integer)
     
    9896  Int       m_scaledRefLayerRightOffset [MAX_LAYERS];
    9997  Int       m_scaledRefLayerBottomOffset[MAX_LAYERS];
    100 #if P0312_VERT_PHASE_ADJ
     98#if REF_REGION_OFFSET
     99  Bool      m_scaledRefLayerOffsetPresentFlag [MAX_LAYERS];
     100  Bool      m_refRegionOffsetPresentFlag      [MAX_LAYERS];
     101  Int       m_refRegionLeftOffset  [MAX_LAYERS];
     102  Int       m_refRegionTopOffset   [MAX_LAYERS];
     103  Int       m_refRegionRightOffset [MAX_LAYERS];
     104  Int       m_refRegionBottomOffset[MAX_LAYERS];
     105#endif
     106#if P0312_VERT_PHASE_ADJ
    101107  Bool      m_vertPhasePositionEnableFlag[MAX_LAYERS];
     108#endif
     109#if R0209_GENERIC_PHASE
     110  Int       m_phaseHorLuma  [MAX_LAYERS];
     111  Int       m_phaseVerLuma  [MAX_LAYERS];
     112  Int       m_phaseHorChroma[MAX_LAYERS];
     113  Int       m_phaseVerChroma[MAX_LAYERS];
     114  Bool      m_resamplePhaseSetPresentFlag [MAX_LAYERS];
    102115#endif
    103116
     
    113126  Int       m_repFormatIdx;
    114127#endif
     128#if Q0074_COLOUR_REMAPPING_SEI
     129  string    m_colourRemapSEIFile;                           ///< Colour Remapping Information SEI message parameters file
     130  Int       m_colourRemapSEIId;
     131  Bool      m_colourRemapSEICancelFlag;
     132  Bool      m_colourRemapSEIPersistenceFlag;
     133  Bool      m_colourRemapSEIVideoSignalInfoPresentFlag;
     134  Bool      m_colourRemapSEIFullRangeFlag;
     135  Int       m_colourRemapSEIPrimaries;
     136  Int       m_colourRemapSEITransferFunction;
     137  Int       m_colourRemapSEIMatrixCoefficients;
     138  Int       m_colourRemapSEIInputBitDepth;
     139  Int       m_colourRemapSEIBitDepth;
     140  Int       m_colourRemapSEIPreLutNumValMinus1[3];
     141  Int*      m_colourRemapSEIPreLutCodedValue[3];
     142  Int*      m_colourRemapSEIPreLutTargetValue[3];
     143  Bool      m_colourRemapSEIMatrixPresentFlag;
     144  Int       m_colourRemapSEILog2MatrixDenom;
     145  Int       m_colourRemapSEICoeffs[3][3];
     146  Int       m_colourRemapSEIPostLutNumValMinus1[3];
     147  Int*      m_colourRemapSEIPostLutCodedValue[3];
     148  Int*      m_colourRemapSEIPostLutTargetValue[3];
     149#endif
     150
    115151public:
    116152  TAppEncLayerCfg();
     
    122158  bool  parseCfg  ( const string& cfgFileName );              ///< parse layer configuration file to fill member variables
    123159
    124 #if AVC_SYNTAX
    125   Void  xPrintParameter( UInt layerId );
    126 #else
    127160  Void  xPrintParameter();
    128 #endif
    129161  Bool  xCheckParameter( Bool isField );
    130162
     
    140172  Int*    getPad()                    {return m_aiPad;            }
    141173  Double  getFloatQP()                {return m_fQP;              }
    142   Int     getConfLeft()               {return m_confLeft;         }
    143   Int     getConfRight()              {return m_confRight;        }
    144   Int     getConfTop()                {return m_confTop;          }
    145   Int     getConfBottom()             {return m_confBottom;       }
     174  Int     getConfWinLeft()            {return m_confWinLeft;         }
     175  Int     getConfWinRight()           {return m_confWinRight;        }
     176  Int     getConfWinTop()             {return m_confWinTop;          }
     177  Int     getConfWinBottom()          {return m_confWinBottom;       }
    146178#if AUXILIARY_PICTURES
    147179  ChromaFormat getInputChromaFormat()   {return m_InputChromaFormat;}
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r815 r906  
    7777  TComVPS* vps = m_acTEncTop[0].getVPS();
    7878
     79#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     80  vps->setVpsPocLsbAlignedFlag(false);
     81#endif
    7982  vps->setMaxTLayers                       ( m_maxTempLayer );
    8083  if (m_maxTempLayer == 1)
     
    181184    repFormat->setBitDepthVpsChroma         ( getInternalBitDepthC()                        );  // Need modification to change for each layer
    182185#endif
     186
     187#if R0156_CONF_WINDOW_IN_REP_FORMAT
     188    repFormat->getConformanceWindowVps().setWindow(
     189      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinLeft,
     190      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinRight,
     191      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinTop,
     192      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinBottom );
     193#endif
     194
    183195#if HIGHER_LAYER_IRAP_SKIP_FLAG
    184196    m_acTEncTop[mapIdxToLayer[idx]].setSkipPictureAtArcSwitch( m_skipPictureAtArcSwitch );
     
    213225    m_acTEncTop[layer].setSourceWidth                  ( m_acLayerCfg[layer].getSourceWidth() );
    214226    m_acTEncTop[layer].setSourceHeight                 ( m_acLayerCfg[layer].getSourceHeight() );
    215     m_acTEncTop[layer].setConformanceMode              ( m_acLayerCfg[layer].getConformanceMode() );
    216     m_acTEncTop[layer].setConformanceWindow            ( m_acLayerCfg[layer].m_confLeft, m_acLayerCfg[layer].m_confRight, m_acLayerCfg[layer].m_confTop, m_acLayerCfg[layer].m_confBottom );
     227    m_acTEncTop[layer].setConformanceWindow            ( m_acLayerCfg[layer].m_confWinLeft, m_acLayerCfg[layer].m_confWinRight, m_acLayerCfg[layer].m_confWinTop, m_acLayerCfg[layer].m_confWinBottom );
    217228    m_acTEncTop[layer].setFramesToBeEncoded            ( m_framesToBeEncoded );
    218229
     
    226237#if REF_IDX_MFM
    227238#if AVC_BASE
    228     m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? AVC_SYNTAX : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers());
     239#if VPS_AVC_BL_FLAG_REMOVAL
     240    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_nonHEVCBaseLayerFlag ? false : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers());
     241#else
     242    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? false : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers());
     243#endif
    229244#else
    230245    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_acLayerCfg[layer].getNumMotionPredRefLayers() > 0 ) );
     
    352367        }
    353368      }
     369#if REF_REGION_OFFSET
     370      for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     371      {
     372#if AUXILIARY_PICTURES
     373        Int cf = m_acLayerCfg[i].m_chromaFormatIDC;
     374        Int rlSubWidthC  = ( cf == CHROMA_420 || cf == CHROMA_422 ) ? 2 : 1;
     375        Int rlSubHeightC = ( cf == CHROMA_420 ) ? 2 : 1;
     376#else
     377        Int rlSubWidthC  = 2;
     378        Int rlSubHeightC = 2;
     379#endif
     380        m_acTEncTop[layer].setRefRegionOffsetPresentFlag( i, m_acLayerCfg[layer].m_refRegionOffsetPresentFlag );
     381        m_acTEncTop[layer].getRefLayerWindow(i).setWindow( rlSubWidthC  * m_acLayerCfg[layer].m_refRegionLeftOffset[i], rlSubWidthC  * m_acLayerCfg[layer].m_refRegionRightOffset[i],
     382                                                           rlSubHeightC * m_acLayerCfg[layer].m_refRegionTopOffset[i],  rlSubHeightC * m_acLayerCfg[layer].m_refRegionBottomOffset[i]);
     383      }
     384#endif
     385    }
     386    else
     387    {
     388      assert( layer == 0 );
     389      m_acTEncTop[layer].setNumDirectRefLayers(0);
    354390    }
    355391#endif //VPS_EXTN_DIRECT_REF_LAYERS
     
    514550    m_acTEncTop[layer].setKneeSEIOutputKneePoint                    ( m_kneeSEIOutputKneePoint );
    515551#endif
    516 #if Q0074_SEI_COLOR_MAPPING
    517     m_acTEncTop[layer].setColorMappingInfoSEIFile                   ( m_acLayerCfg[layer].m_cSeiColorMappingFile.empty() ? NULL : const_cast<Char *>(m_acLayerCfg[layer].m_cSeiColorMappingFile.c_str()) );
     552#if Q0074_COLOUR_REMAPPING_SEI
     553    m_acTEncTop[layer].setCRISEIFile                                ( const_cast<Char*>(m_acLayerCfg[layer].m_colourRemapSEIFile.c_str()) );
     554    m_acTEncTop[layer].setCRISEIId                                  ( m_acLayerCfg[layer].m_colourRemapSEIId );
     555    m_acTEncTop[layer].setCRISEICancelFlag                          ( m_acLayerCfg[layer].m_colourRemapSEICancelFlag );
     556    m_acTEncTop[layer].setCRISEIPersistenceFlag                     ( m_acLayerCfg[layer].m_colourRemapSEIPersistenceFlag );
     557    m_acTEncTop[layer].setCRISEIVideoSignalInfoPresentFlag          ( m_acLayerCfg[layer].m_colourRemapSEIVideoSignalInfoPresentFlag );
     558    m_acTEncTop[layer].setCRISEIFullRangeFlag                       ( m_acLayerCfg[layer].m_colourRemapSEIFullRangeFlag );
     559    m_acTEncTop[layer].setCRISEIPrimaries                           ( m_acLayerCfg[layer].m_colourRemapSEIPrimaries );
     560    m_acTEncTop[layer].setCRISEITransferFunction                    ( m_acLayerCfg[layer].m_colourRemapSEITransferFunction );
     561    m_acTEncTop[layer].setCRISEIMatrixCoefficients                  ( m_acLayerCfg[layer].m_colourRemapSEIMatrixCoefficients );
     562    m_acTEncTop[layer].setCRISEIInputBitDepth                       ( m_acLayerCfg[layer].m_colourRemapSEIInputBitDepth );
     563    m_acTEncTop[layer].setCRISEIBitDepth                            ( m_acLayerCfg[layer].m_colourRemapSEIBitDepth );
     564    m_acTEncTop[layer].setCRISEIPreLutNumValMinus1                  ( m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1 );
     565    m_acTEncTop[layer].setCRISEIPreLutCodedValue                    ( m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue );
     566    m_acTEncTop[layer].setCRISEIPreLutTargetValue                   ( m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue );
     567    m_acTEncTop[layer].setCRISEIMatrixPresentFlag                   ( m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag );
     568    m_acTEncTop[layer].setCRISEILog2MatrixDenom                     ( m_acLayerCfg[layer].m_colourRemapSEILog2MatrixDenom );
     569    m_acTEncTop[layer].setCRISEICoeffs                              ( m_acLayerCfg[layer].m_colourRemapSEICoeffs );
     570    m_acTEncTop[layer].setCRISEIPostLutNumValMinus1                 ( m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1 );
     571    m_acTEncTop[layer].setCRISEIPostLutCodedValue                   ( m_acLayerCfg[layer]. m_colourRemapSEIPostLutCodedValue );
     572    m_acTEncTop[layer].setCRISEIPostLutTargetValue                  ( m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue );
    518573#endif
    519574    m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
     
    542597    m_acTEncTop[layer].setIlcIdc( m_ilcIdc );
    543598#endif
    544     m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    545     m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
    546     m_acTEncTop[layer].setNumRowsMinus1              ( m_iNumRowsMinus1 );
    547     if(m_iUniformSpacingIdr==0)
    548     {
    549       m_acTEncTop[layer].setColumnWidth              ( m_pColumnWidth );
    550       m_acTEncTop[layer].setRowHeight                ( m_pRowHeight );
     599    m_acTEncTop[layer].setTileUniformSpacingFlag     ( m_tileUniformSpacingFlag );
     600    m_acTEncTop[layer].setNumColumnsMinus1           ( m_numTileColumnsMinus1 );
     601    m_acTEncTop[layer].setNumRowsMinus1              ( m_numTileRowsMinus1 );
     602    if(!m_tileUniformSpacingFlag)
     603    {
     604      m_acTEncTop[layer].setColumnWidth              ( m_tileColumnWidth );
     605      m_acTEncTop[layer].setRowHeight                ( m_tileRowHeight );
    551606    }
    552607    m_acTEncTop[layer].xCheckGSParameters();
    553     Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
     608    Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1);
    554609    if(uiTilesCount == 1)
    555610    {
     
    557612    }
    558613    m_acTEncTop[layer].setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
    559     m_acTEncTop[layer].setWaveFrontSynchro           ( m_iWaveFrontSynchro );
     614    m_acTEncTop[layer].setWaveFrontSynchro           ( m_acLayerCfg[layer].m_waveFrontSynchro );
    560615    m_acTEncTop[layer].setWaveFrontSubstreams        ( m_acLayerCfg[layer].m_iWaveFrontSubstreams );
    561616    m_acTEncTop[layer].setTMVPModeId ( m_TMVPModeId );
     
    586641    m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
    587642    m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
     643    m_acTEncTop[layer].setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag);
    588644    m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc );
    589645    m_acTEncTop[layer].setSarWidth( m_sarWidth );
     
    617673    if( layer > 0 )
    618674    {
     675#if REF_REGION_OFFSET
     676#if AUXILIARY_PICTURES
     677      Int cf = m_acLayerCfg[layer].m_chromaFormatIDC;
     678      Int subWidthC  = ( cf == CHROMA_420 || cf == CHROMA_422 ) ? 2 : 1;
     679      Int subHeightC = ( cf == CHROMA_420 ) ? 2 : 1;
     680#else
     681      Int subWidthC  = 2;
     682      Int subHeightC = 2;
     683#endif
     684#endif
    619685      m_acTEncTop[layer].setNumScaledRefLayerOffsets( m_acLayerCfg[layer].m_numScaledRefLayerOffsets );
    620686      for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     
    623689        m_acTEncTop[layer].setScaledRefLayerId(i, m_acLayerCfg[layer].m_scaledRefLayerId[i]);
    624690#endif
     691#if REF_REGION_OFFSET
     692        m_acTEncTop[layer].setScaledRefLayerOffsetPresentFlag( i, m_acLayerCfg[layer].m_scaledRefLayerOffsetPresentFlag[i] );
     693        m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( subWidthC  * m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], subWidthC  * m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i],
     694                                                                 subHeightC * m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i],  subHeightC * m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]);
     695#else
    625696#if P0312_VERT_PHASE_ADJ
    626697        m_acTEncTop[layer].setVertPhasePositionEnableFlag( i, m_acLayerCfg[layer].m_vertPhasePositionEnableFlag[i] );
     
    630701        m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i],
    631702                                                  2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]);
     703#endif
     704#endif
     705#if R0209_GENERIC_PHASE
     706        m_acTEncTop[layer].setResamplePhaseSetPresentFlag( i, m_acLayerCfg[layer].m_resamplePhaseSetPresentFlag[i] );
     707        m_acTEncTop[layer].setPhaseHorLuma( i, m_acLayerCfg[layer].m_phaseHorLuma[i] );
     708        m_acTEncTop[layer].setPhaseVerLuma( i, m_acLayerCfg[layer].m_phaseVerLuma[i] );
     709        m_acTEncTop[layer].setPhaseHorChroma( i, m_acLayerCfg[layer].m_phaseHorChroma[i] );
     710        m_acTEncTop[layer].setPhaseVerChroma( i, m_acLayerCfg[layer].m_phaseVerChroma[i] );
    632711#endif
    633712      }
     
    650729    m_acTEncTop[layer].setCGSMaxYPartNumLog2( m_nCGSMaxYPartNumLog2 );
    651730    m_acTEncTop[layer].setCGSLUTBit( m_nCGSLUTBit );
     731#if R0151_CGS_3D_ASYMLUT_IMPROVE
     732    m_acTEncTop[layer].setCGSAdaptChroma( m_nCGSAdaptiveChroma );
     733#endif
     734#if R0179_ENC_OPT_3DLUT_SIZE
     735    m_acTEncTop[layer].setCGSLutSizeRDO( m_nCGSLutSizeRDO );
     736#endif
    652737#endif
    653738#if Q0078_ADD_LAYER_SETS
     
    685770  m_cTEncTop.setSourceWidth                  ( m_iSourceWidth );
    686771  m_cTEncTop.setSourceHeight                 ( m_iSourceHeight );
    687   m_cTEncTop.setConformanceWindow            ( m_confLeft, m_confRight, m_confTop, m_confBottom );
     772  m_cTEncTop.setConformanceWindow            ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
    688773  m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
    689774
     
    853938  m_cTEncTop.setKneeSEIOutputKneePoint      ( m_kneeSEIOutputKneePoint );
    854939#endif
    855 #if Q0074_SEI_COLOR_MAPPING
    856   m_cTEncTop.setColorMappingInfoSEIFile                   ( m_pchSEIColorMappingFile );
     940#if Q0074_COLOUR_REMAPPING_SEI
     941  m_cTEncTop.setCRISEIFile                       ( const_cast<Char*>(m_colourRemapSEIFile.c_str()) );
     942  m_cTEncTop.setCRISEIId                         ( m_colourRemapSEIId );
     943  m_cTEncTop.setCRISEICancelFlag                 ( m_colourRemapSEICancelFlag );
     944  m_cTEncTop.setCRISEIPersistenceFlag            ( m_colourRemapSEIPersistenceFlag );
     945  m_cTEncTop.setCRISEIVideoSignalInfoPresentFlag ( m_colourRemapSEIVideoSignalInfoPresentFlag );
     946  m_cTEncTop.setCRISEIFullRangeFlag              ( m_colourRemapSEIFullRangeFlag );
     947  m_cTEncTop.setCRISEIPrimaries                  ( m_colourRemapSEIPrimaries );
     948  m_cTEncTop.setCRISEITransferFunction           ( m_colourRemapSEITransferFunction );
     949  m_cTEncTop.setCRISEIMatrixCoefficients         ( m_colourRemapSEIMatrixCoefficients );
     950  m_cTEncTop.setCRISEIInputBitDepth              ( m_colourRemapSEIInputBitDepth );
     951  m_cTEncTop.setCRISEIBitDepth                   ( m_colourRemapSEIBitDepth );
     952  m_cTEncTop.setCRISEIPreLutNumValMinus1         ( m_colourRemapSEIPreLutNumValMinus1 );
     953  m_cTEncTop.setCRISEIPreLutCodedValue           ( m_colourRemapSEIPreLutCodedValue );
     954  m_cTEncTop.setCRISEIPreLutTargetValue          ( m_colourRemapSEIPreLutTargetValue );
     955  m_cTEncTop.setCRISEIMatrixPresentFlag          ( m_colourRemapSEIMatrixPresentFlag );
     956  m_cTEncTop.setCRISEILog2MatrixDenom            ( m_colourRemapSEILog2MatrixDenom );
     957  m_cTEncTop.setCRISEICoeffs                     ( m_colourRemapSEICoeffs );
     958  m_cTEncTop.setCRISEIPostLutNumValMinus1        ( m_colourRemapSEIPostLutNumValMinus1 );
     959  m_cTEncTop.setCRISEIPostLutCodedValue          ( m_colourRemapSEIPostLutCodedValue );
     960  m_cTEncTop.setCRISEIPostLutTargetValue         ( m_colourRemapSEIPostLutTargetValue );
    857961#endif
    858962  m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
     
    870974  m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
    871975  m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
    872   m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    873   m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
    874   m_cTEncTop.setNumRowsMinus1              ( m_iNumRowsMinus1 );
    875   if(m_iUniformSpacingIdr==0)
    876   {
    877     m_cTEncTop.setColumnWidth              ( m_pColumnWidth );
    878     m_cTEncTop.setRowHeight                ( m_pRowHeight );
     976  m_cTEncTop.setTileUniformSpacingFlag     ( m_tileUniformSpacingFlag );
     977  m_cTEncTop.setNumColumnsMinus1           ( m_numTileColumnsMinus1 );
     978  m_cTEncTop.setNumRowsMinus1              ( m_numTileRowsMinus1 );
     979  if(!m_tileUniformSpacingFlag)
     980  {
     981    m_cTEncTop.setColumnWidth              ( m_tileColumnWidth );
     982    m_cTEncTop.setRowHeight                ( m_tileRowHeight );
    879983  }
    880984  m_cTEncTop.xCheckGSParameters();
    881   Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
     985  Int uiTilesCount          = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1);
    882986  if(uiTilesCount == 1)
    883987  {
     
    9041008  m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
    9051009  m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
     1010  m_cTEncTop.setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag);
    9061011  m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc );
    9071012  m_cTEncTop.setSarWidth( m_sarWidth );
     
    10561161
    10571162#if Q0078_ADD_LAYER_SETS
     1163#if OUTPUT_LAYER_SETS_CONFIG
     1164  if (m_numLayerSets > 1)
     1165  {
     1166    vps->setNumLayerSets(m_numLayerSets);
     1167#else
    10581168  if (m_numLayerSets > 0)
    10591169  {
    10601170    vps->setNumLayerSets(m_numLayerSets+1);
     1171#endif
    10611172    for (Int setId = 1; setId < vps->getNumLayerSets(); setId++)
    10621173    {
     
    10681179    for (Int setId = 1; setId < vps->getNumLayerSets(); setId++)
    10691180    {
     1181#if OUTPUT_LAYER_SETS_CONFIG
     1182      for (Int i = 0; i < m_numLayerInIdList[setId]; i++)
     1183      {
     1184        Int layerId = m_layerSetLayerIdList[setId][i];
     1185#else
    10701186      for (Int i = 0; i < m_numLayerInIdList[setId-1]; i++)
    10711187      {
    10721188        Int layerId = m_layerSetLayerIdList[setId-1][i];
    1073 
     1189#endif
    10741190#if O0194_DIFFERENT_BITDEPTH_EL_BL
    10751191        //4
     
    11331249  UInt i = 0, dimIdLen = 0;
    11341250#if AVC_BASE
     1251#if VPS_AVC_BL_FLAG_REMOVAL
     1252  vps->setNonHEVCBaseLayerFlag( m_nonHEVCBaseLayerFlag );
     1253  if ( m_nonHEVCBaseLayerFlag )
     1254  {
     1255    vps->setBaseLayerInternalFlag (false);
     1256  }
     1257#else
    11351258  vps->setAvcBaseLayerFlag(m_avcBaseLayerFlag);
     1259#endif
    11361260#else
    11371261  vps->setAvcBaseLayerFlag(false);
     
    12001324#endif
    12011325#if VPS_TSLAYERS
    1202     vps->setMaxTSLayersPresentFlag(true);
    1203 
    1204     for( i = 0; i < vps->getMaxLayers(); i++ )
    1205     {
    1206       vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
    1207     }
     1326  vps->setMaxTSLayersPresentFlag(true);
     1327
     1328  for( i = 0; i < vps->getMaxLayers(); i++ )
     1329  {
     1330    vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
     1331  }
    12081332#endif
    12091333  vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag);
     
    12381362    vps->setIlpSshSignalingEnabledFlag(false);
    12391363#if VPS_EXTN_PROFILE_INFO
     1364
     1365#if LIST_OF_PTL
     1366  vps->getPTLForExtnPtr()->resize(1);   // Dummy object - unused.
     1367  for(i = 0; i < vps->getMaxLayers(); i++)
     1368  {
     1369    // TODO: The profile tier level have to be given support to be included in the configuration files
     1370    if(i == 0)
     1371    {
     1372      if( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 )
     1373      {
     1374        vps->setProfilePresentFlag(1, false);
     1375        vps->getPTLForExtnPtr()->push_back( *(m_acTEncTop[0].getSPS()->getPTL()) );
     1376      }
     1377    }
     1378    else  // i > 0
     1379    {
     1380      vps->setProfilePresentFlag(i, true);
     1381      // Note - may need to be changed for other layer structures.
     1382      vps->getPTLForExtnPtr()->push_back( *(m_acTEncTop[0].getSPS()->getPTL()) );
     1383    }
     1384  }
     1385#else
    12401386  vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets());
    12411387  for(Int setId = 1; setId < vps->getNumLayerSets(); setId++)
     
    12451391    *(vps->getPTLForExtn(setId)) = *(m_acTEncTop[setId].getSPS()->getPTL());
    12461392  }
     1393#endif
    12471394#endif
    12481395#if VPS_EXTN_DIRECT_REF_LAYERS
     
    13171464#endif
    13181465#endif
     1466#if OUTPUT_LAYER_SETS_CONFIG
     1467
     1468  vps->setDefaultTargetOutputLayerIdc( m_defaultTargetOutputLayerIdc ); // As per configuration file
     1469
     1470  if( m_numOutputLayerSets == -1 )  // # of output layer sets not specified in the configuration file
     1471  {
     1472    vps->setNumOutputLayerSets(vps->getNumLayerSets());
     1473
     1474    for(i = 1; i < vps->getNumLayerSets(); i++)
     1475    {
     1476        vps->setOutputLayerSetIdx(i, i);
     1477    }
     1478  }
     1479  else
     1480  {
     1481    vps->setNumOutputLayerSets( m_numOutputLayerSets );
     1482    for( Int olsCtr = 0; olsCtr < vps->getNumLayerSets(); olsCtr ++ ) // Default output layer sets
     1483    {
     1484      vps->setOutputLayerSetIdx(olsCtr, olsCtr);
     1485    }
     1486    for( Int olsCtr = vps->getNumLayerSets(); olsCtr < vps->getNumOutputLayerSets(); olsCtr ++ )  // Non-default output layer sets
     1487    {
     1488      vps->setOutputLayerSetIdx(olsCtr, m_outputLayerSetIdx[olsCtr - vps->getNumLayerSets()]);
     1489    }
     1490  }
     1491#endif
    13191492  // Target output layer
     1493#if LIST_OF_PTL
     1494  vps->setNumProfileTierLevel( vps->getPTLForExtnPtr()->size() ); // +1 for the base VPS PTL()
     1495#else
    13201496  vps->setNumOutputLayerSets(vps->getNumLayerSets());
    13211497  vps->setNumProfileTierLevel(vps->getNumLayerSets());
     1498#endif
     1499#if !OUTPUT_LAYER_SETS_CONFIG // Taken care by configuration file parameter
    13221500#if P0295_DEFAULT_OUT_LAYER_IDC
    13231501  vps->setDefaultTargetOutputLayerIdc(1);
     
    13291507#endif
    13301508#endif
     1509#endif
     1510#if !PER_LAYER_PTL
    13311511  for(i = 1; i < vps->getNumLayerSets(); i++)
    13321512  {
    13331513    vps->setProfileLevelTierIdx(i, i);
     1514#if !OUTPUT_LAYER_SETS_CONFIG
    13341515    vps->setOutputLayerSetIdx(i, i);
     1516#endif
    13351517  } 
     1518#endif
    13361519#endif
    13371520 #if VPS_DPB_SIZE_TABLE
     
    13471530
    13481531  // derive OutputLayerFlag[i][j]
     1532#if !OUTPUT_LAYER_SETS_CONFIG
    13491533  if( vps->getDefaultTargetOutputLayerIdc() == 1 )
     1534#endif
    13501535  {
    13511536    // default_output_layer_idc equal to 1 specifies that only the layer with the highest value of nuh_layer_id such that nuh_layer_id equal to nuhLayerIdA and
     
    13601545        if( vps->getLayerIdIncludedFlag(lsIdx, layer) )     
    13611546#endif
    1362         {       
     1547        {
     1548#if OUTPUT_LAYER_SETS_CONFIG
     1549          switch(vps->getDefaultTargetOutputLayerIdc())
     1550          {
     1551            case 0: vps->setOutputLayerFlag( lsIdx, layer, 1 );
     1552              break;
     1553            case 1: vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 );
     1554              break;
     1555            case 2:
     1556            case 3: vps->setOutputLayerFlag( lsIdx, layer, std::find( m_listOfOutputLayers[lsIdx].begin(), m_listOfOutputLayers[lsIdx].end(), layer) != m_listOfOutputLayers[lsIdx].end() );
     1557              break;
     1558          }
     1559#else
    13631560          vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 );
     1561#endif
    13641562        }
    13651563      }
    13661564    }
    1367   }
     1565#if OUTPUT_LAYER_SETS_CONFIG
     1566    for( Int olsIdx = vps->getNumLayerSets(); olsIdx < vps->getNumOutputLayerSets(); olsIdx++ )
     1567    {
     1568      for( UInt layer = 0; layer < vps->getNumLayersInIdList(vps->getOutputLayerSetIdx(olsIdx)); layer++ )
     1569      {
     1570        vps->setOutputLayerFlag( olsIdx, layer, std::find( m_listOfOutputLayers[olsIdx].begin(), m_listOfOutputLayers[olsIdx].end(), layer) != m_listOfOutputLayers[olsIdx].end());
     1571      }
     1572    }
     1573#endif
     1574  }
     1575#if !OUTPUT_LAYER_SETS_CONFIG
    13681576  else
    13691577  {
     
    13711579    assert(!"default_output_layer_idc not equal to 1 is not yet supported");
    13721580  }
    1373 
     1581#endif
     1582#if NECESSARY_LAYER_FLAG
     1583  vps->deriveNecessaryLayerFlag();
     1584  vps->checkNecessaryLayerFlagCondition();
     1585#endif
     1586#if PER_LAYER_PTL
     1587  vps->getProfileLevelTierIdx()->resize(vps->getNumOutputLayerSets());
     1588  vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0 ); // Default 0-th output layer set
     1589  for(i = 1; i < vps->getNumOutputLayerSets(); i++)
     1590  {
     1591    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i );
     1592    Int numLayerInLayerSet = vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet );
     1593    for(Int j = 0; j < numLayerInLayerSet; j++)
     1594    {
     1595      Int layerIdxInVps = vps->getLayerIdInVps( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j) );
     1596      if( vps->getNecessaryLayerFlag(i, j) )
     1597      {
     1598        vps->getProfileLevelTierIdx(i)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? layerIdxInVps + 1 : layerIdxInVps);
     1599      }
     1600      else
     1601      {
     1602        vps->getProfileLevelTierIdx(i)->push_back( -1 );
     1603      }
     1604    }
     1605  }
     1606#endif
     1607#if SUB_LAYERS_IN_LAYER_SET
     1608  vps->calculateMaxSLInLayerSets();
     1609#endif
    13741610  // Initialize dpb_size_table() for all ouput layer sets in the VPS extension
    13751611  for(i = 1; i < vps->getNumOutputLayerSets(); i++)
     
    15011737#endif
    15021738
     1739#if VPS_VUI_BSP_HRD_PARAMS
     1740  vps->setVpsVuiBspHrdPresentFlag(false);
     1741  TEncTop *pcCfg = &m_acTEncTop[0];
     1742  if( pcCfg->getBufferingPeriodSEIEnabled() )
     1743  {
     1744    Int j;
     1745    vps->setVpsVuiBspHrdPresentFlag(true);
     1746    vps->setVpsNumAddHrdParams( vps->getMaxLayers() );
     1747    vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams() + 1);
     1748    for( i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ )
     1749    {
     1750      vps->setCprmsAddPresentFlag( j, true );
     1751      vps->setNumSubLayerHrdMinus1( j, vps->getMaxTLayers() - 1 );
     1752
     1753      UInt layerId = j;
     1754      TEncTop *pcCfgLayer = &m_acTEncTop[layerId];
     1755
     1756      Int iPicWidth         = pcCfgLayer->getSourceWidth();
     1757      Int iPicHeight        = pcCfgLayer->getSourceHeight();
     1758#if LAYER_CTB
     1759      UInt uiWidthInCU       = ( iPicWidth  % m_acLayerCfg[layerId].m_uiMaxCUWidth  ) ? iPicWidth  / m_acLayerCfg[layerId].m_uiMaxCUWidth  + 1 : iPicWidth  / m_acLayerCfg[layerId].m_uiMaxCUWidth;
     1760      UInt uiHeightInCU      = ( iPicHeight % m_acLayerCfg[layerId].m_uiMaxCUHeight ) ? iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight + 1 : iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight;
     1761      UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_acLayerCfg[layerId].m_uiMaxCUDepth << 1);
     1762#else
     1763      UInt uiWidthInCU       = ( iPicWidth %m_uiMaxCUWidth  ) ? iPicWidth /m_uiMaxCUWidth  + 1 : iPicWidth /m_uiMaxCUWidth;
     1764      UInt uiHeightInCU      = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight;
     1765      UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_uiMaxCUDepth << 1);
     1766#endif
     1767      UInt uiNumCUsInFrame   = uiWidthInCU * uiHeightInCU;
     1768
     1769      UInt numDU = ( pcCfgLayer->getSliceMode() == 1 ) ? ( uiNumCUsInFrame / maxCU ) : ( 0 );
     1770      if( uiNumCUsInFrame % maxCU != 0 || numDU == 0 )
     1771      {
     1772        numDU ++;
     1773      }
     1774      vps->getBspHrd(i)->setNumDU( numDU );
     1775      vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) );
     1776    }
     1777
     1778    // Signalling of additional partitioning schemes
     1779    for(Int h = 1; h < vps->getNumOutputLayerSets(); h++)
     1780    {
     1781      Int lsIdx = vps->getOutputLayerSetIdx( h );
     1782      vps->setNumSignalledPartitioningSchemes(h, 1);  // Only the default per-layer partitioning scheme
     1783      for( j = 1; j < vps->getNumSignalledPartitioningSchemes(h); j++ )
     1784      {
     1785        // ToDo: Add code for additional partitioning schemes here
     1786        // ToDo: Initialize num_partitions_in_scheme_minus1 and layer_included_in_partition_flag
     1787      }
     1788
     1789      for( i = 0; i < vps->getNumSignalledPartitioningSchemes(h); i++ )
     1790      {
     1791        if( i == 0 )
     1792        {
     1793          for(Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1( lsIdx ); t++)
     1794          {
     1795            vps->setNumBspSchedulesMinus1( h, i, t, 0 );
     1796            for( j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ )
     1797            {
     1798              for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, i); k++ )
     1799              {
     1800                // Only for the default partition
     1801                Int nuhlayerId = vps->getLayerSetLayerIdList( lsIdx, k);
     1802                Int layerIdxInVps = vps->getLayerIdInVps( nuhlayerId );
     1803                vps->setBspHrdIdx(h, i, t, j, k, layerIdxInVps + vps->getNumHrdParameters());
     1804
     1805                vps->setBspSchedIdx(h, i, t, j, k, 0);
     1806              }
     1807            }
     1808          }
     1809        }
     1810        else
     1811        {
     1812          assert(0);    // Need to add support for additional partitioning schemes.
     1813        }
     1814      }
     1815    }
     1816  }
     1817#else
     1818
    15031819#if O0164_MULTI_LAYER_HRD
    15041820  vps->setVpsVuiBspHrdPresentFlag(false);
     
    15721888    }
    15731889  }
     1890#endif
    15741891#endif
    15751892
     
    16691986  }
    16701987
    1671 #if AVC_SYNTAX
    1672   fstream streamSyntaxFile;
    1673   if( m_acTEncTop[0].getVPS()->getAvcBaseLayerFlag() )
    1674   {
    1675     if( !m_BLSyntaxFile )
    1676     {
    1677       printf( "Wrong base layer syntax input file\n" );
    1678       exit(EXIT_FAILURE);
    1679     }
    1680     streamSyntaxFile.open( m_BLSyntaxFile, fstream::in | fstream::binary );
    1681     if( !streamSyntaxFile.good() )
    1682     {
    1683       printf( "Base layer syntax input reading error\n" );
    1684       exit(EXIT_FAILURE);
    1685     }
    1686     m_acTEncTop[0].setBLSyntaxFile( &streamSyntaxFile );
    1687   }
    1688 #endif
    1689 
    16901988  Bool bFirstFrame = true;
    16911989  while ( !bEos )
     
    18162114      }
    18172115    }
     2116#if R0247_SEI_ACTIVE
     2117    if(bFirstFrame)
     2118    {
     2119      list<AccessUnit>::iterator first_au = outputAccessUnits.begin();
     2120      AccessUnit::iterator it_sps;
     2121      for (it_sps = first_au->begin(); it_sps != first_au->end(); it_sps++)
     2122      {
     2123        if( (*it_sps)->m_nalUnitType == NAL_UNIT_SPS )
     2124        {
     2125          break;
     2126        }
     2127      }
     2128
     2129      for (list<AccessUnit>::iterator it_au = ++outputAccessUnits.begin(); it_au != outputAccessUnits.end(); it_au++)
     2130      {
     2131        for (AccessUnit::iterator it_nalu = it_au->begin(); it_nalu != it_au->end(); it_nalu++)
     2132        {
     2133          if( (*it_nalu)->m_nalUnitType == NAL_UNIT_SPS )
     2134          {
     2135            first_au->insert(++it_sps, *it_nalu);
     2136            it_nalu = it_au->erase(it_nalu);
     2137          }
     2138        }
     2139      }
     2140    }
     2141
     2142#endif
    18182143
    18192144#if RC_SHVC_HARMONIZATION
     
    18582183
    18592184        AccessUnit& accessUnit = outputAccessUnits.back();
     2185#if T_ID_EOB_BUG_FIX
     2186        nalu.m_temporalId = 0;
     2187#else
    18602188        nalu.m_temporalId = accessUnit.front()->m_temporalId;
     2189#endif
    18612190        accessUnit.push_back(new NALUnitEBSP(nalu));
    18622191      }
     
    18842213    m_acTEncTop[layer].deletePicBuffer();
    18852214  }
    1886 
    1887 #if AVC_SYNTAX
    1888   if( streamSyntaxFile.is_open() )
    1889   {
    1890     streamSyntaxFile.close();
    1891   }
    1892 #endif
    18932215
    18942216  // delete buffers & classes
     
    21542476      {
    21552477#if REPN_FORMAT_IN_VPS
    2156         m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft() * xScal, m_acLayerCfg[layer].getConfRight() * xScal,
    2157           m_acLayerCfg[layer].getConfTop() * yScal, m_acLayerCfg[layer].getConfBottom() * yScal, m_isTopFieldFirst );
    2158 #else
    2159         m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom(), m_isTopFieldFirst );
     2478        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfWinLeft() * xScal, m_acLayerCfg[layer].getConfWinRight() * xScal,
     2479          m_acLayerCfg[layer].getConfWinTop() * yScal, m_acLayerCfg[layer].getConfWinBottom() * yScal, m_isTopFieldFirst );
     2480#else
     2481        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfWinLeft(), m_acLayerCfg[layer].getConfWinRight(), m_acLayerCfg[layer].getConfWinTop(), m_acLayerCfg[layer].getConfWinBottom(), m_isTopFieldFirst );
    21602482#endif
    21612483      }
     
    21832505      {
    21842506#if REPN_FORMAT_IN_VPS
    2185         m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft() * xScal, m_acLayerCfg[layer].getConfRight() * xScal,
    2186           m_acLayerCfg[layer].getConfTop() * yScal, m_acLayerCfg[layer].getConfBottom() * yScal );
    2187 #else
    2188         m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
    2189           m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     2507        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfWinLeft() * xScal, m_acLayerCfg[layer].getConfWinRight() * xScal,
     2508          m_acLayerCfg[layer].getConfWinTop() * yScal, m_acLayerCfg[layer].getConfWinBottom() * yScal );
     2509#else
     2510        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfWinLeft(), m_acLayerCfg[layer].getConfWinRight(),
     2511          m_acLayerCfg[layer].getConfWinTop(), m_acLayerCfg[layer].getConfWinBottom() );
    21902512#endif
    21912513      }
     
    22952617      if (m_pchReconFile)
    22962618      {
    2297         m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
     2619        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst );
    22982620      }
    22992621
     
    23102632  {
    23112633    Int i;
    2312 
    23132634    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
    23142635    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     
    23242645      if (m_pchReconFile)
    23252646      {
    2326 #if SYNTAX_OUTPUT
    2327         m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
    2328 #endif
     2647        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
    23292648      }
    23302649
Note: See TracChangeset for help on using the changeset viewer.